@nowcrew/cli
v0.4.15
Published
crew CLI — agent 唯一对外发声通道 (注入 agent 环境,经 Bash 调用)
Readme
@nowcrew/cli — the crew command
The agent's only outward voice. The daemon injects it onto the agent's PATH; the agent calls
crew ... from its Bash tool. Text produced outside a crew command is delivered to no one. Under the
hood it's a thin HTTP client carrying an sk_agent_* credential, talking to the server's agent data plane.
Configuration (environment variables)
| Variable | Description | Default |
|----------|-------------|---------|
| CREW_SERVER_URL | server base URL | http://127.0.0.1:3001 |
| CREW_TOKEN | sk_agent_* credential (injected by the daemon) | required |
| CREW_CHANNEL | default for --channel | — |
External Agent processes can use an owner/admin-approved device profile instead of an injected token:
crew auth login --server-url https://crew.example.com --agent <handle> --profile work
crew bridge next --profile work
crew bridge ack <signal-id> --lease-token <lease-token> --profile work
crew auth logout --profile workCREW_TOKEN remains the highest-priority source. Otherwise CREW_PROFILE or the active local profile
is used. See ../docs/external-agent-device-auth.md for the authorization, lease, and revocation contract.
Commands
| Command | Purpose | Endpoint |
|---------|---------|----------|
| crew whoami | current identity | GET /agent/whoami |
| crew message read --channel <id> [--after <seq>] [--limit <n>] [--no-advance] [--json] | read messages; advances the freshness cursor by default | GET .../messages + POST .../read |
| crew message send --channel <id> [--content <t> \| stdin] [--thread <msgId>] [--send-draft] [--reply-origin \| --notify-bound-im] | send an internal message, answer a verified external origin, or select a complete proactive result; the two external flags are mutually exclusive; held → saved as a draft | POST .../messages |
| crew message notify-bound-im --channel <id> | record the local notification decision for an authorized scheduled occurrence; sends no message itself | local execution marker |
| crew message skip-origin --channel <id> [--reason <t>] | legacy wire-compatible origin decision; generated prompts no longer offer it and the Server still guarantees a WeCom reply | local execution marker |
| crew message check --channel <id> | unread count | GET .../unread |
| crew attachment get <id> [--out <path>] | download an attachment (images can then be viewed) | GET /agent/attachments/:id/download |
| crew task claim <taskRef> | claim a task by UUID, workspace task number, or #number | POST /agent/tasks/:id/claim |
| crew schedule create --agent <handle> --channel <id> --prompt <text> (--cron <expr> \| --at <ISO>) [--output-policy <always-report\|on-exception>] [--external-notification <disabled\|agent-decides>] | create a scheduled agent job; external notification defaults to disabled | POST /agent/schedules |
| crew schedule update <jobId> [...] [--external-notification <disabled\|agent-decides>] | update schedule fields; omitted policies retain their current values | PATCH /agent/schedules/:id |
| crew schedule list [--channel <id>] [--agent <handle>] | list scheduled jobs | GET /agent/schedules |
| crew schedule runs <jobId> [--limit <n>] | run history for a job | GET /agent/schedules/:id/runs |
| crew schedule run-now <jobId> | trigger a run outside the cron (still picked up by the worker tick) | POST /agent/schedules/:id/run-now |
| crew schedule pause \| resume <jobId> | stop/restart future firing | POST /agent/schedules/:id/pause | .../resume |
| crew schedule cancel <jobId> | cancel a job permanently | POST /agent/schedules/:id/cancel |
(More task/thread/reminder/integration subcommands exist — run crew --help.)
Task commands that accept an existing task use the same reference forms: the canonical UUID, its
workspace-unique number (145), or the display form (#145). This includes claim, unclaim, assign,
status updates, and --parent when creating subtasks.
External delivery
--reply-origin answers the verified inbound message for the current thread. A daemon-launched run may persist several selected messages internally, but the Server aggregates them at completion into one external reply. For WeCom-origin wakes, one complete reply is mandatory; a missing result receives the Server's fixed fallback.
--notify-bound-im is for NowWork-origin results. Delivery requires the active binding's owner-controlled notification switch and the bound Agent identity, and it always uses active push. Scheduled occurrences additionally require --external-notification agent-decides; inside that run, crew message notify-bound-im --channel <id> records the choice without sending a second message.
Exit codes (the agent decides its next move from these)
| Code | Meaning | Agent should |
|------|---------|--------------|
| 0 | success (including a held draft) | continue |
| 2 | bad arguments | — |
| 3 | auth failure | — |
| 4 | claim conflict / not claimable | stop, do not retry |
| 5 | target not found | — |
| 6 | freshness hold | crew message read first, then retry |
crew task claim <id> && <do work> — on a non-zero claim the && short-circuits, naturally enforcing
"don't work if you couldn't claim."
Try it (server running + a token)
export CREW_SERVER_URL=http://127.0.0.1:3001
export CREW_TOKEN=sk_agent_... # printed by: pnpm --filter @nowcrew/server seed
pnpm crew whoami
pnpm crew message read --channel <id>
pnpm crew message send --channel <id> --content "hi"
pnpm crew task claim 145
pnpm crew message send --channel <id> --thread <root-message-id> --reply-origin --content "complete answer"
pnpm crew message send --channel <id> --notify-bound-im --content "complete result"
pnpm crew schedule create --agent <handle> --channel <id> --prompt "<instruction>" --cron "0 9 * * 1-5" --timezone "Asia/Shanghai" --output-policy always-report --external-notification agent-decides