agent-tempo 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CLAUDE.md +219 -219
  2. package/LICENSE +21 -21
  3. package/README.md +289 -289
  4. package/assets/icon-dark.svg +9 -9
  5. package/assets/icon.svg +9 -9
  6. package/assets/logo-dark.svg +11 -11
  7. package/assets/logo-light.svg +11 -11
  8. package/dashboard/README.md +91 -91
  9. package/dashboard/dist/assets/index-D6Xyje_n.js.map +1 -1
  10. package/dashboard/dist/index.html +19 -19
  11. package/dashboard/package.json +47 -47
  12. package/dist/adapters/copilot/adapter.js +12 -1
  13. package/dist/cli/global-wrapper.d.ts +19 -0
  14. package/dist/cli/global-wrapper.js +169 -0
  15. package/dist/cli/help-text.js +97 -97
  16. package/dist/cli/startup.js +11 -0
  17. package/dist/cli/upgrade-command.js +81 -81
  18. package/dist/cli.js +12 -0
  19. package/dist/daemon.js +5 -0
  20. package/dist/scripts/verify-daemon-isolation-guard.js +24 -24
  21. package/dist/server.js +4 -0
  22. package/dist/spawn.js +12 -12
  23. package/dist/tools/coat-check-evict.js +2 -2
  24. package/dist/tools/coat-check-get.js +2 -2
  25. package/dist/tools/coat-check-put.js +4 -4
  26. package/dist/tools/fetch-state.js +2 -2
  27. package/dist/tools/save-state.js +13 -13
  28. package/dist/utils/grpc-shutdown-guard.d.ts +52 -0
  29. package/dist/utils/grpc-shutdown-guard.js +88 -0
  30. package/examples/agents/tempo-composer.md +56 -56
  31. package/examples/agents/tempo-conductor.md +117 -117
  32. package/examples/agents/tempo-critic.md +73 -73
  33. package/examples/agents/tempo-improv.md +74 -74
  34. package/examples/agents/tempo-liner.md +75 -75
  35. package/examples/agents/tempo-roadie.md +61 -61
  36. package/examples/agents/tempo-soloist.md +71 -71
  37. package/examples/agents/tempo-tuner.md +94 -94
  38. package/examples/ensembles/tempo-big-band.yaml +146 -146
  39. package/examples/ensembles/tempo-dev-team.yaml +58 -58
  40. package/examples/ensembles/tempo-headless-jam.yaml +77 -77
  41. package/examples/ensembles/tempo-jam-session.yaml +41 -41
  42. package/examples/ensembles/tempo-mock-jam.yaml +79 -79
  43. package/examples/ensembles/tempo-review-squad.yaml +32 -32
  44. package/package.json +173 -173
  45. package/packaging/launchd/com.agent.tempo.plist +46 -46
  46. package/packaging/systemd/agent-tempo.service +32 -32
  47. package/packaging/windows/install-task.ps1 +71 -71
  48. package/scenarios/conductor-recruit-mock.yaml +33 -33
  49. package/scenarios/echo-roundtrip.yaml +15 -15
  50. package/scenarios/multi-player-handoff.yaml +38 -38
  51. package/scenarios/recruit-cascade.yaml +38 -38
  52. package/scenarios/two-player-conversation.yaml +33 -33
  53. package/workflow-bundle.js +1 -1
  54. package/dist/activities/claude-stop.d.ts +0 -21
  55. package/dist/activities/claude-stop.js +0 -94
  56. package/dist/channel.d.ts +0 -3
  57. package/dist/channel.js +0 -48
  58. package/dist/copilot-bridge.d.ts +0 -22
  59. package/dist/copilot-bridge.js +0 -565
  60. package/dist/scripts/258-spotcheck.js +0 -303
  61. package/dist/tools/detach.d.ts +0 -4
  62. package/dist/tools/detach.js +0 -45
  63. package/dist/tools/encore.d.ts +0 -4
  64. package/dist/tools/encore.js +0 -31
  65. package/dist/tools/pause-ensemble.d.ts +0 -4
  66. package/dist/tools/pause-ensemble.js +0 -58
  67. package/dist/tools/resume-ensemble.d.ts +0 -4
  68. package/dist/tools/resume-ensemble.js +0 -79
  69. package/dist/tools/stop.d.ts +0 -4
  70. package/dist/tools/stop.js +0 -29
  71. package/dist/tui/client.d.ts +0 -6
  72. package/dist/tui/client.js +0 -9
  73. package/dist/tui/components/ActivityLog.d.ts +0 -16
  74. package/dist/tui/components/ActivityLog.js +0 -36
  75. package/dist/tui/components/CommandOverlay.d.ts +0 -15
  76. package/dist/tui/components/CommandOverlay.js +0 -34
  77. package/dist/tui/components/ConductorChat.d.ts +0 -16
  78. package/dist/tui/components/ConductorChat.js +0 -32
  79. package/dist/tui/components/EnsembleListView.d.ts +0 -14
  80. package/dist/tui/components/EnsembleListView.js +0 -32
  81. package/dist/tui/components/EnsemblePanel.d.ts +0 -12
  82. package/dist/tui/components/EnsemblePanel.js +0 -40
  83. package/dist/tui/components/InputBar.d.ts +0 -13
  84. package/dist/tui/components/InputBar.js +0 -58
  85. package/dist/tui/components/ScheduleOverlay.d.ts +0 -13
  86. package/dist/tui/components/ScheduleOverlay.js +0 -113
  87. package/dist/tui/components/TopBar.d.ts +0 -12
  88. package/dist/tui/components/TopBar.js +0 -15
  89. package/dist/tui/core-api.d.ts +0 -26
  90. package/dist/tui/core-api.js +0 -67
  91. package/dist/tui/hooks/useEnsembleDiscovery.d.ts +0 -3
  92. package/dist/tui/hooks/useEnsembleDiscovery.js +0 -30
  93. package/dist/tui/hooks/useMaestroPoller.d.ts +0 -3
  94. package/dist/tui/hooks/useMaestroPoller.js +0 -36
  95. package/dist/tui/hooks/useSendCommand.d.ts +0 -7
  96. package/dist/tui/hooks/useSendCommand.js +0 -29
  97. package/dist/utils/bg-preflight.d.ts +0 -25
  98. package/dist/utils/bg-preflight.js +0 -154
package/CLAUDE.md CHANGED
@@ -1,219 +1,219 @@
1
- # CLAUDE.md
2
-
3
- ## What is this?
4
-
5
- agent-tempo is an MCP server that enables multiple Claude Code sessions to coordinate via Temporal.
6
-
7
- ## Tech Stack
8
-
9
- - **Runtime**: Node.js 20+ with TypeScript
10
- - **MCP**: `@modelcontextprotocol/sdk` (stdio transport)
11
- - **Temporal**: `@temporalio/client`, `@temporalio/worker`, `@temporalio/workflow`, `@temporalio/activity`
12
- - **croner** — cron expression parsing and next-fire computation (used by `schedule` tool)
13
- - **yaml**, **zod** — lineup parsing and schema validation
14
-
15
- ## Project Structure
16
-
17
- ```
18
- src/
19
- ├── server.ts # MCP server entry point
20
- ├── cli.ts # CLI entry point (agent-tempo command)
21
- ├── daemon.ts # Daemon entry point — runs Temporal workers as a detached background process
22
- ├── cli/
23
- │ ├── commands.ts # CLI command implementations (up, start, conduct, status, stop, …)
24
- │ ├── config-command.ts # config subcommand (interactive + set/show) — crash-proof for show/set
25
- │ ├── daemon.ts # Daemon management utilities (start, stop, status, heartbeat, isDaemonRunning)
26
- │ ├── daemon-command.ts # daemon subcommand handler — crash-proof, no Temporal deps
27
- │ ├── dashboard-command.ts # dashboard subcommand — crash-proof; opens the web dashboard, optionally minting a QR-code pairing token (#340)
28
- │ ├── dev-banner.ts # [DEV MODE] banner formatter (ADR 0014 §5.4) — gate 4 production-safety line
29
- │ ├── dev-mode-bootstrap.ts # pre-import side-effect: promotes top-level `--dev` flag to `CLAUDE_TEMPO_DEV_MODE=1` before any other module loads
30
- │ ├── dev-verbs.ts # dev-mode scriptable CLI verbs (#432) — shell-scriptable wrappers over MCP tools for E2E validation; stripped from production surface
31
- │ ├── help-text.ts # help output — crash-proof, no Temporal deps
32
- │ ├── legacy-migration.ts # one-shot idempotent copy `~/.claude-tempo/` → `~/.agent-tempo/` on first v1.0 boot (PR-2 of rebrand)
33
- │ ├── mcp.ts # MCP server registration helpers (init, global vs project)
34
- │ ├── output.ts # Shared CLI output formatting helpers
35
- │ ├── preflight.ts # Environment preflight checks
36
- │ ├── removed-verbs.ts # lookup table for the 10 CLI verbs removed in #288 — dispatches migration hints before loading Temporal surface
37
- │ ├── sa-preflight.ts # search-attribute preflight — REQUIRED_SEARCH_ATTRIBUTES list (single source of truth), registerSearchAttribute, verifySearchAttributes, assertSearchAttributesOrExit
38
- │ ├── scenarios-command.ts # scenarios subcommand (dev mode only) — list/show shipped YAML scenario library (ADR 0014 §4.8)
39
- │ ├── startup.ts # auto-provisioning bootstrap state machine (#289) — six-step idempotent sequence used by bare `agent-tempo` invocation
40
- │ └── upgrade-command.ts # upgrade subcommand — crash-proof; dynamic-imports Temporal only for active-session warning
41
- ├── adapters/
42
- │ ├── README.md # Adapter contract documentation
43
- │ ├── index.ts # Adapter registry bootstrap + barrel exports (mock registered iff isDevMode())
44
- │ ├── base.ts # BaseAttachment + SdkAttachment base classes (lifecycle skeleton)
45
- │ ├── terminal-error.ts # Shared terminal-class error classifier for signal/query failures (#249)
46
- │ ├── claude-code/ # InteractiveAttachment — Claude Code CLI adapter
47
- │ ├── copilot/ # CopilotSdkAttachment — Copilot bridge adapter
48
- │ ├── claude-api/ # ClaudeApiAttachment — headless adapter via Anthropic Messages API (#131)
49
- │ ├── opencode/ # OpenCodeAttachment — headless multi-provider adapter via SST OpenCode subprocess (#449)
50
- │ ├── mock/ # MockAttachment — dev-mode-only SDK adapter (ADR 0014 PR-2). prepack strips dist/adapters/mock from npm tarball.
51
- │ └── sdk/ # SDK-style adapter base (used by Copilot bridge and opencode)
52
- ├── client/
53
- │ ├── interface.ts # TempoClient TypeScript interface and related types
54
- │ └── index.ts # TempoClient factory implementation and barrel re-exports
55
- ├── worker.ts # Temporal worker setup (used by daemon only)
56
- ├── connection.ts # Temporal connection factory (shared by server + CLI)
57
- ├── constants.ts # Shared string constants (ensemble ready banner/directive, etc.)
58
- ├── spawn.ts # Cross-platform process spawning helpers
59
- ├── workflows/
60
- │ ├── session.ts # claude-session workflow
61
- │ ├── scheduler.ts # durable scheduler workflow (one per ensemble)
62
- │ ├── maestro.ts # Maestro workflows — per-ensemble hub and global hub
63
- │ ├── attachment-math.ts # Pure CAN-boundary lease-extension helper (no Temporal imports)
64
- │ ├── maestro-signals.ts / scheduler-signals.ts / signals.ts # Signal/query/update type defs
65
- │ └── index.ts # Workflow re-exports for worker bundle
66
- ├── activities/
67
- │ ├── outbox.ts # Outbox delivery activities (cue, report, recruit, release, spawn)
68
- │ ├── maestro.ts # Maestro activities
69
- │ ├── hard-terminate.ts # Per-host process kill activity (used by destroy when attached)
70
- │ ├── resolve.ts # Session resolver shared by outbox + schedule-fire activities
71
- │ └── schedule-fire.ts
72
- ├── http/ # Daemon HTTP/SSE event source (#94/#95)
73
- │ ├── server.ts # Express-style HTTP server — snapshot + streaming endpoints
74
- │ ├── event-bus.ts # In-process EnsembleEventBus (fanout to SSE clients)
75
- │ ├── event-types.ts # TempoEvent / ClusterEvent wire type definitions
76
- │ ├── sse-handler.ts # SSE response lifecycle (ring-buffer replay, gap detection, backpressure)
77
- │ ├── ring-buffer.ts # Fixed-size event ring buffer (256 events) for Last-Event-ID replay
78
- │ ├── snapshot.ts # On-demand ensemble state snapshot (prelude + poll)
79
- │ ├── aggregate.ts # AggregateRunner — wires bus + snapshot + HTTP server startup
80
- │ ├── auth.ts / cors.ts / responses.ts / event-id.ts / port-file.ts / index.ts
81
- ├── reconcile/
82
- │ └── orphans.ts # Shared orphan-query helper (daemon reconcile-on-boot + CLI restore)
83
- ├── ensemble/
84
- │ ├── schema.ts / loader.ts / saver.ts # Lineup type definitions, load, save
85
- │ └── agent-types.ts # Agent type discovery, resolution, and lineup resolution
86
- ├── tools/ # One file per MCP tool — see docs/tools.md for full reference
87
- │ ├── ensemble.ts / cue.ts / recruit.ts / report.ts / broadcast.ts / recall.ts / listen.ts
88
- │ ├── restart.ts / destroy.ts / migrate.ts / attachment-info.ts
89
- │ ├── schedule.ts / unschedule.ts / schedules.ts
90
- │ ├── quality-gate.ts / evaluate-gate.ts / gates.ts
91
- │ ├── worktree.ts / stage.ts / stages.ts / cancel-stage.ts
92
- │ ├── load-lineup.ts / save-lineup.ts / agent-types.ts / resolve.ts
93
- │ ├── set-name.ts / set-part.ts / who-am-i.ts / release.ts
94
- │ ├── pause.ts / play.ts / shutdown.ts / restore.ts
95
- │ ├── hosts.ts / set-ensemble-description.ts
96
- │ ├── save-state.ts / fetch-state.ts / clear-state.ts
97
- │ ├── coat-check-put.ts / coat-check-get.ts / coat-check-list.ts / coat-check-evict.ts
98
- │ └── helpers.ts # Zod/MCP tool registration wrapper
99
- ├── tui/
100
- │ ├── App.tsx / store.ts / commands.ts # TUI root, state, slash commands
101
- │ ├── sse-handler.ts # SSE event → TUI store dispatch mapping (PR-4a of #94/#95)
102
- │ ├── components/ # Ink components — see docs/tui.md for inventory
103
- │ └── utils/ # format, platform, theme, fullscreen, history
104
- ├── utils/
105
- │ ├── validation.ts / worktree.ts / safe-path.ts / duration.ts / search-attributes.ts
106
- │ ├── attachment-format.ts / recall-format.ts # Shared display formatters (attachment-info, recall)
107
- │ ├── hosts.ts / format-hosts.ts # Host enumeration + shared hosts display formatter (#274)
108
- │ ├── sdk-probe.ts # Filesystem-walk probe for installed optional npm deps (used by opencode adapter + recruit preflight, #449)
109
- │ ├── ensemble-ops.ts # Shared pause/unpause/fan-out helpers for ensemble-scope verbs (pause, play, shutdown, restore, destroy)
110
- │ ├── query-timeout.ts # Bounded WorkflowHandle.query() wrapper with in-flight deduplication; prevents hung queries from wedging snapshot endpoint (#433)
111
- │ ├── visibility-deadline.ts # Iterator-level deadlines for Temporal workflow.list() scans; prevents memory growth from stalled visibility page streams (#336, #529)
112
- │ ├── default-part.ts # Derives human-readable "X session" part string from a player's type name (e.g. tempo-conductor → "Conductor session")
113
- │ ├── restore-format.ts # Pure formatter for restore --all-hosts cluster-view listing; no Temporal/I/O deps (#151)
114
- │ └── parent-death-watchdog.ts # Self-exit watchdog (stdin EOF + PPID poll) so MCP server children don't outlive their parent host (#604)
115
- ├── types.ts # Shared type definitions
116
- ├── git-info.ts # Git repository detection helper
117
- └── config.ts # Env var handling
118
- ```
119
-
120
- See [docs/tui-performance.md](docs/tui-performance.md) for Ink/React performance notes when
121
- touching `src/tui/`.
122
-
123
- ## Development
124
-
125
- ```bash
126
- npm install
127
- npm run build # compiles TS, scripts/*.ts → dist/scripts/, and pre-bundles workflow code into workflow-bundle.js
128
- npm test
129
- npm run check:all # runs every CI gate locally (build, tests, drift checks, lints, dashboard, size-limit, tarball). Run before pushing to catch CI failures up front.
130
- ```
131
-
132
- > **Always run `npm run build` after changing workflow code (`src/workflows/`).** The build
133
- > pre-bundles workflows into `workflow-bundle.js` so all workers use identical code.
134
-
135
- > **Two test directories.** Mocha tests live in `test/` (Temporal workflow integration
136
- > suites, wire-protocol drift detector). Vitest tests live in `tests/` (TUI components,
137
- > TempoClient fallback paths). Both are first-class targets — when doing call-site
138
- > surveys or migrations, always grep **both** `test/` and `tests/` or you will miss
139
- > mocks and assertions that only live in one directory.
140
-
141
- > **Test-only hooks live with the module they reset and follow the
142
- > `__<verb><Noun>ForTests` naming convention** — see
143
- > [docs/adr/0006-test-hooks-naming.md](docs/adr/0006-test-hooks-naming.md). The
144
- > double-underscore prefix telegraphs "test escape hatch, do not call from
145
- > production code"; the hook's doc-comment should restate that explicitly. Hooks
146
- > are never surfaced through barrels or `TempoClient`.
147
-
148
- > **Project standard is npm** (declared via `package.json#packageManager`,
149
- > enforced in CI by `lint:lockfile-canonical`). If `npm` is blocked locally
150
- > (e.g. corp networks), `pnpm` works as a personal workaround — `pnpm-lock.yaml`
151
- > is gitignored, so it can exist on disk but must NOT be committed. The
152
- > `lint:lockfile-canonical` step inside `check:all` fails if any non-npm
153
- > lockfile (`pnpm-lock.yaml`, `yarn.lock`, or their `dashboard/` counterparts)
154
- > appears in `git ls-files`. The `dashboard/` subworkspace also uses npm and
155
- > ships its own `package-lock.json` — see `.github/workflows/ci.yml` for why
156
- > the install is intentionally independent.
157
-
158
- See [docs/development.md](docs/development.md) for full setup (Temporal dev server command,
159
- daemon worker notes, `npx ts-node` dev runner).
160
-
161
- ## Key Concepts
162
-
163
- > **Architecture overview**: See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the three-layer workflow/adapter/process model and ensemble coordination layer.
164
-
165
- - **Player**: A Claude Code session registered as a Temporal workflow
166
- - **Conductor**: A special player that acts as orchestration hub, connected to external interfaces (one per ensemble)
167
- - **Ensemble**: The set of all active players, namespaced by `CLAUDE_TEMPO_ENSEMBLE`
168
- - **Cue**: A message sent to a player by name via Temporal signal
169
- - **Part**: A player's description of what it's working on
170
- - **Outbox**: Outbound requests (cue, report, recruit, restart, detach, destroy, …) go through the session's workflow outbox instead of directly signaling other workflows. The dispatch loop processes entries via activities, decoupling tools from cross-workflow signaling.
171
- - **Attachment phase** (v0.26): Seven phases tracked on the session workflow — `booting → attached → processing | awaiting → draining → detached → gone`. The phase is authoritative for lifecycle truth: adapters drive it via `claimAttachment` / `adapterExited` / `forceDetach` / `destroy`, and the workflow publishes it on the `ClaudeTempoAttachmentState` search attribute. Replaced the v0.25 `ClaudeTempoStatus` heuristic (removed in v0.26). See [docs/concepts.md](docs/concepts.md) for the phase table and [docs/ops/v0.26-migration.md](docs/ops/v0.26-migration.md) for the upgrade path.
172
- - **Adapter heartbeat observability** (#249): After `claimAttachment`, the base adapter logs `first heartbeat scheduled in Xms` then `heartbeat#1 delivered` on the first tick. Every 10 ticks it emits `heartbeats-delivered=N / phase-ticks=N` breadcrumbs. Any silent guard trip in `tickHeartbeat` / `tickPhaseWatcher` now emits a structured `guard tripped: {stopped, reconnecting, …}` log instead of silently orphaning the timer. The phase-watcher emits `WARNING: heartbeat staleness` when `lastHeartbeatAt` falls more than 2× `heartbeatMs` behind `now`. Grep `[agent-tempo:adapter]` to confirm loop health without parsing Temporal history.
173
- - **Per-host task queues**: `host` param on `recruit`/`restart`/`migrate` routes to `agent-tempo-{hostname}` task queue. When `host` is set on `recruit`, a pre-flight check validates the target daemon is live and supports the requested agent type (`force: true` bypasses). Daemon boot profiles (hostname, platform, available player types) are advertised via the `hostProfile` signal and maintained in the global maestro's `hostProfiles` map — surfaced by the `hosts` MCP tool, `agent-tempo hosts` CLI, and `/hosts` TUI command (#274). See [docs/concepts.md](docs/concepts.md) for cross-machine recruiting details.
174
- - **Wire protocol**: All signal/query/update names are documented in [`docs/WIRE-PROTOCOL.md`](docs/WIRE-PROTOCOL.md) and are stable — renaming or removing any is a breaking change. **Process**: update `docs/WIRE-PROTOCOL.md` in the same commit as any new signal, query, or update.
175
- - **Daemon**: Standalone background process (`src/daemon.ts`) that runs all Temporal workers and the HTTP/SSE event source (`src/http/`). Auto-started by any `agent-tempo` command. PID at `~/.agent-tempo/daemon.pid`; logs at `~/.agent-tempo/daemon.log`. Exposes local HTTP endpoints (`/v1/health`, `/v1/ensembles`, `/v1/state/:ensemble`, `/v1/events/:ensemble` SSE stream, etc.) consumed by the TUI and `TempoClient.subscribe()`. See [docs/SSE-PROTOCOL.md](docs/SSE-PROTOCOL.md).
176
- - **Player types**: Reusable agent definitions in Claude Code's subagent format (`.md` files with YAML frontmatter). Three-tier lookup: project `.claude/agents/` → user `~/.claude/agents/` → shipped `examples/agents/`. Discover via `agent_types` tool or `agent-tempo agent-types` CLI. Shipped types: tempo-conductor, tempo-composer, tempo-soloist, tempo-tuner, tempo-critic, tempo-roadie, tempo-improv, tempo-liner.
177
- - **Dev mode** (`--dev` flag or `CLAUDE_TEMPO_DEV_MODE=1`): Isolated testing profile — flips home dir to `~/.agent-tempo-dev/`, HTTP port to 8474, Temporal namespace to `agent-tempo-dev`, task queue to `agent-tempo-dev`. Required to use the mock adapter. Post-#423 isolation guarantees: (1) `TEMPORAL_NAMESPACE` / `TEMPORAL_ADDRESS` shell env vars are ignored in dev mode — the dev namespace is not overridable by shell config, only CLI flags and `~/.agent-tempo-dev/config.json`. (2) `--dev down` will not kill the Temporal server if the prod profile is alive; use `--kill-shared-temporal` to override. Canonical entry point (no global install required): `node dist/cli.js --dev <verb>`. Quick E2E: `node dist/cli.js --dev daemon start && node dist/cli.js --dev up --lineup tempo-mock-jam`. See [docs/dev-mode.md](docs/dev-mode.md) for the full reference.
178
- - **Claude API adapter** (`agent: 'claude-api'`, #131): Headless adapter that drives sessions via the Anthropic Messages API (`@anthropic-ai/sdk`) — no terminal, no Claude Code CLI. Requires `ANTHROPIC_API_KEY` env var and the `@anthropic-ai/sdk` optional dependency. Default model `claude-opus-4-7` (overridable via `model` recruit arg or `CLAUDE_TEMPO_API_MODEL` env). Claude-API players have access to agent-tempo MCP tools (cue, report, recall, ensemble, …) but not file-edit/shell/web tools. See `src/adapters/claude-api/`.
179
- - **OpenCode adapter** (`agent: 'opencode'`, #449): Headless multi-provider adapter that drives sessions via [SST OpenCode](https://opencode.ai) as a managed subprocess — supports Anthropic, OpenAI, Bedrock, Vertex, Ollama, and ~70 other providers via OpenCode's `provider/model` selector. Requires OpenCode CLI (`npm install -g opencode-ai`) and the `@opencode-ai/sdk` optional dependency. Recruit with `model: 'provider/name'` (e.g. `'anthropic/claude-opus-4-7'`). Tool bridging is MCP-native — OpenCode spawns `dist/server.js` as its own stdio MCP child. Session state is persisted server-side by OpenCode; the adapter stashes the session id on workflow metadata for reconnect across `opencode serve` restarts. See `src/adapters/opencode/`.
180
- - **Claude Code headless adapter** (`agent: 'claude-code-headless'`, #520): Headless adapter that drives sessions via the official `claude` CLI as a per-turn `claude -p --output-format stream-json` subprocess. The whole point: turns bill against the host's existing Claude Code subscription extra-usage credits (Pro / Max plans) rather than a Console workspace API key — the only ToS-clean way for a third-party tool to tap that pool. Requires the `claude` binary on PATH AND a logged-in Claude Code session (`claude auth login`); recruit pre-flight rejects with an actionable error otherwise. Tool surface is the union of full Claude Code built-ins (Bash / Read / Write / Edit / Glob / Grep / WebSearch / WebFetch) and the agent-tempo MCP surface — registered via inline `--mcp-config` so `claude` spawns `dist/server.js` as its own MCP child (no in-process bridge). Recruit knobs: `permissionMode` (default `'acceptEdits'`) or `dangerouslySkipPermissions: true` (mutually exclusive). Sessions resume across restart via the existing `sessionId` metadata field — the same UUID is shared with the interactive `claude-code` adapter (per-cwd JSONL is per-cwd, not per-adapter). See `src/adapters/claude-code-headless/` and `examples/ensembles/tempo-headless-jam.yaml`.
181
- - **Mock adapter** (`agent: 'mock'`, dev mode only): Four modes: `echo` (echoes input), `scripted` (replays YAML scenario rules), `silent` (drains messages without replying — heartbeat-stale validation), `chaos` (probabilistic fail/crash injection via seeded PRNG). Only registered when `isDevMode()` is true; stripped from the npm tarball by `prepack`. See `src/adapters/mock/`.
182
- - **Saveable state** (#334, ADR 0011): Per-player curated state slots — the player itself decides what context survives a restart. Three MCP tools: `save_state` (owner-only write, max 4 slots × 32 KiB), `fetch_state` (read self or peer; audit identity recorded on each entry's `savedBy`), `clear_state` (owner-only). `restart` accepts `loadFromState: true | 'someKey'` to seed the new session from a saved-state slot instead of (or, with `transcript: 'replay'`, alongside) transcript replay. Saved-state delivery uses `from: 'self-restart'` as a stable system identity. Empty-slot fallback: graceful — falls through to transcript replay with a log line. See [docs/design/334-player-saveable-state.md](docs/design/334-player-saveable-state.md).
183
- - **Coat-check** (#318, ADR 0008): Per-ensemble transient content store on Maestro state. Solves the 100 KB cue body cap — stash a large artifact with `coat_check_put` (returns a ticket id) and attach the ticket to a `cue` via `attachmentTicket`; the recipient calls `coat_check_get` to pull the full body. Four MCP tools: `coat_check_put` (any player; max 32 KiB per entry, 20 slots per ensemble, TTL 7d default), `coat_check_get` (any player; bumps fetch-audit counters), `coat_check_list` (read-only survey; headers only, content omitted), `coat_check_evict` (owner or conductor). Saturation rejects with `CoatCheckSlotsFull` (no LRU eviction). See `src/tools/coat-check-*.ts` and [docs/adr/0008-coat-check-pattern.md](docs/adr/0008-coat-check-pattern.md).
184
- - **Lineup examples**: Six pre-built ensemble YAML files in `examples/ensembles/` — `tempo-big-band`, `tempo-dev-team`, `tempo-review-squad`, `tempo-jam-session`, `tempo-mock-jam` (dev-mode all-mock ensemble), `tempo-headless-jam` (#520 — all-`claude-code-headless` subscription-billed ensemble). Load with `agent-tempo up --lineup <name>` or the `load_lineup` tool.
185
- - **GitHub App identity** (`agent-tempo[bot]`): When a player writes to GitHub — issue comments, PR creation/merge, commits, labels, check runs — **use `./scripts/ensemble-gh`** instead of `gh`. The wrapper mints a short-lived installation token so the action is attributed to `agent-tempo[bot]`, not to the human maintainer, making the AI authorship visible. Plain `gh` is still correct for read-only local dev (`gh pr view`, `gh repo clone`, `gh auth status`). Every bot-authored comment/PR body must include the AI attribution footer documented in [docs/github-app.md](docs/github-app.md).
186
-
187
- See [docs/concepts.md](docs/concepts.md) for the full glossary (Adapter, Attachment phases, Restart, Detach/Destroy, Migrate, Broadcast, Recall, Schedule, Lineup, Quality Gate, Worktree, Stage, Hold/Release, Pause/Resume, Maestro, TempoClient, and more).
188
-
189
- ## Commit Convention
190
-
191
- Use conventional commits: `type(scope): message`
192
-
193
- Examples:
194
- - `feat(tools): add ensemble discovery tool`
195
- - `fix(workflow): handle signal delivery edge case`
196
- - `docs: update getting started guide`
197
-
198
- ## PR Body Conventions
199
-
200
- GitHub's auto-close keywords (`Closes`, `Fixes`, `Resolves`) ignore any trailing qualifier text. They cannot express "this PR closes part of an issue" — they always close the full issue.
201
-
202
- For multi-PR efforts tracked under a single issue, use these conventions in PR bodies:
203
-
204
- | Form | When to use |
205
- |---|---|
206
- | `Refs #N` | Any intermediate PR of a multi-PR effort. No auto-close. |
207
- | `Implements PR-K of #N` | Same as above, more explicit. No keyword match → no auto-close. |
208
- | `Closes #N` | Final PR of the effort (or single-PR efforts). Triggers auto-close on merge. |
209
-
210
- **Avoid `Closes #N PR-K`** — GitHub ignores the `PR-K` qualifier and auto-closes #N prematurely. If you find yourself wanting to express "closes part of," use `Refs #N` and add a manual close on the final PR.
211
-
212
- When sequencing multi-PR work, name the issue's open question explicitly in the first PR's body (e.g., "PR-1 of 2: foundation; PR-2 follows for the user-visible payoff") so reviewers know more is coming.
213
-
214
- ## Release Process
215
-
216
- > **Release rule**: Bump `package.json` + CHANGELOG before tagging. Never tag a commit that
217
- > doesn't match the version. Tagging prematurely publishes the old version to npm.
218
-
219
- See [docs/release-process.md](docs/release-process.md) for the full 4-step sequence.
1
+ # CLAUDE.md
2
+
3
+ ## What is this?
4
+
5
+ agent-tempo is an MCP server that enables multiple Claude Code sessions to coordinate via Temporal.
6
+
7
+ ## Tech Stack
8
+
9
+ - **Runtime**: Node.js 20+ with TypeScript
10
+ - **MCP**: `@modelcontextprotocol/sdk` (stdio transport)
11
+ - **Temporal**: `@temporalio/client`, `@temporalio/worker`, `@temporalio/workflow`, `@temporalio/activity`
12
+ - **croner** — cron expression parsing and next-fire computation (used by `schedule` tool)
13
+ - **yaml**, **zod** — lineup parsing and schema validation
14
+
15
+ ## Project Structure
16
+
17
+ ```
18
+ src/
19
+ ├── server.ts # MCP server entry point
20
+ ├── cli.ts # CLI entry point (agent-tempo command)
21
+ ├── daemon.ts # Daemon entry point — runs Temporal workers as a detached background process
22
+ ├── cli/
23
+ │ ├── commands.ts # CLI command implementations (up, start, conduct, status, stop, …)
24
+ │ ├── config-command.ts # config subcommand (interactive + set/show) — crash-proof for show/set
25
+ │ ├── daemon.ts # Daemon management utilities (start, stop, status, heartbeat, isDaemonRunning)
26
+ │ ├── daemon-command.ts # daemon subcommand handler — crash-proof, no Temporal deps
27
+ │ ├── dashboard-command.ts # dashboard subcommand — crash-proof; opens the web dashboard, optionally minting a QR-code pairing token (#340)
28
+ │ ├── dev-banner.ts # [DEV MODE] banner formatter (ADR 0014 §5.4) — gate 4 production-safety line
29
+ │ ├── dev-mode-bootstrap.ts # pre-import side-effect: promotes top-level `--dev` flag to `CLAUDE_TEMPO_DEV_MODE=1` before any other module loads
30
+ │ ├── dev-verbs.ts # dev-mode scriptable CLI verbs (#432) — shell-scriptable wrappers over MCP tools for E2E validation; stripped from production surface
31
+ │ ├── help-text.ts # help output — crash-proof, no Temporal deps
32
+ │ ├── legacy-migration.ts # one-shot idempotent copy `~/.claude-tempo/` → `~/.agent-tempo/` on first v1.0 boot (PR-2 of rebrand)
33
+ │ ├── mcp.ts # MCP server registration helpers (init, global vs project)
34
+ │ ├── output.ts # Shared CLI output formatting helpers
35
+ │ ├── preflight.ts # Environment preflight checks
36
+ │ ├── removed-verbs.ts # lookup table for the 10 CLI verbs removed in #288 — dispatches migration hints before loading Temporal surface
37
+ │ ├── sa-preflight.ts # search-attribute preflight — REQUIRED_SEARCH_ATTRIBUTES list (single source of truth), registerSearchAttribute, verifySearchAttributes, assertSearchAttributesOrExit
38
+ │ ├── scenarios-command.ts # scenarios subcommand (dev mode only) — list/show shipped YAML scenario library (ADR 0014 §4.8)
39
+ │ ├── startup.ts # auto-provisioning bootstrap state machine (#289) — six-step idempotent sequence used by bare `agent-tempo` invocation
40
+ │ └── upgrade-command.ts # upgrade subcommand — crash-proof; dynamic-imports Temporal only for active-session warning
41
+ ├── adapters/
42
+ │ ├── README.md # Adapter contract documentation
43
+ │ ├── index.ts # Adapter registry bootstrap + barrel exports (mock registered iff isDevMode())
44
+ │ ├── base.ts # BaseAttachment + SdkAttachment base classes (lifecycle skeleton)
45
+ │ ├── terminal-error.ts # Shared terminal-class error classifier for signal/query failures (#249)
46
+ │ ├── claude-code/ # InteractiveAttachment — Claude Code CLI adapter
47
+ │ ├── copilot/ # CopilotSdkAttachment — Copilot bridge adapter
48
+ │ ├── claude-api/ # ClaudeApiAttachment — headless adapter via Anthropic Messages API (#131)
49
+ │ ├── opencode/ # OpenCodeAttachment — headless multi-provider adapter via SST OpenCode subprocess (#449)
50
+ │ ├── mock/ # MockAttachment — dev-mode-only SDK adapter (ADR 0014 PR-2). prepack strips dist/adapters/mock from npm tarball.
51
+ │ └── sdk/ # SDK-style adapter base (used by Copilot bridge and opencode)
52
+ ├── client/
53
+ │ ├── interface.ts # TempoClient TypeScript interface and related types
54
+ │ └── index.ts # TempoClient factory implementation and barrel re-exports
55
+ ├── worker.ts # Temporal worker setup (used by daemon only)
56
+ ├── connection.ts # Temporal connection factory (shared by server + CLI)
57
+ ├── constants.ts # Shared string constants (ensemble ready banner/directive, etc.)
58
+ ├── spawn.ts # Cross-platform process spawning helpers
59
+ ├── workflows/
60
+ │ ├── session.ts # claude-session workflow
61
+ │ ├── scheduler.ts # durable scheduler workflow (one per ensemble)
62
+ │ ├── maestro.ts # Maestro workflows — per-ensemble hub and global hub
63
+ │ ├── attachment-math.ts # Pure CAN-boundary lease-extension helper (no Temporal imports)
64
+ │ ├── maestro-signals.ts / scheduler-signals.ts / signals.ts # Signal/query/update type defs
65
+ │ └── index.ts # Workflow re-exports for worker bundle
66
+ ├── activities/
67
+ │ ├── outbox.ts # Outbox delivery activities (cue, report, recruit, release, spawn)
68
+ │ ├── maestro.ts # Maestro activities
69
+ │ ├── hard-terminate.ts # Per-host process kill activity (used by destroy when attached)
70
+ │ ├── resolve.ts # Session resolver shared by outbox + schedule-fire activities
71
+ │ └── schedule-fire.ts
72
+ ├── http/ # Daemon HTTP/SSE event source (#94/#95)
73
+ │ ├── server.ts # Express-style HTTP server — snapshot + streaming endpoints
74
+ │ ├── event-bus.ts # In-process EnsembleEventBus (fanout to SSE clients)
75
+ │ ├── event-types.ts # TempoEvent / ClusterEvent wire type definitions
76
+ │ ├── sse-handler.ts # SSE response lifecycle (ring-buffer replay, gap detection, backpressure)
77
+ │ ├── ring-buffer.ts # Fixed-size event ring buffer (256 events) for Last-Event-ID replay
78
+ │ ├── snapshot.ts # On-demand ensemble state snapshot (prelude + poll)
79
+ │ ├── aggregate.ts # AggregateRunner — wires bus + snapshot + HTTP server startup
80
+ │ ├── auth.ts / cors.ts / responses.ts / event-id.ts / port-file.ts / index.ts
81
+ ├── reconcile/
82
+ │ └── orphans.ts # Shared orphan-query helper (daemon reconcile-on-boot + CLI restore)
83
+ ├── ensemble/
84
+ │ ├── schema.ts / loader.ts / saver.ts # Lineup type definitions, load, save
85
+ │ └── agent-types.ts # Agent type discovery, resolution, and lineup resolution
86
+ ├── tools/ # One file per MCP tool — see docs/tools.md for full reference
87
+ │ ├── ensemble.ts / cue.ts / recruit.ts / report.ts / broadcast.ts / recall.ts / listen.ts
88
+ │ ├── restart.ts / destroy.ts / migrate.ts / attachment-info.ts
89
+ │ ├── schedule.ts / unschedule.ts / schedules.ts
90
+ │ ├── quality-gate.ts / evaluate-gate.ts / gates.ts
91
+ │ ├── worktree.ts / stage.ts / stages.ts / cancel-stage.ts
92
+ │ ├── load-lineup.ts / save-lineup.ts / agent-types.ts / resolve.ts
93
+ │ ├── set-name.ts / set-part.ts / who-am-i.ts / release.ts
94
+ │ ├── pause.ts / play.ts / shutdown.ts / restore.ts
95
+ │ ├── hosts.ts / set-ensemble-description.ts
96
+ │ ├── save-state.ts / fetch-state.ts / clear-state.ts
97
+ │ ├── coat-check-put.ts / coat-check-get.ts / coat-check-list.ts / coat-check-evict.ts
98
+ │ └── helpers.ts # Zod/MCP tool registration wrapper
99
+ ├── tui/
100
+ │ ├── App.tsx / store.ts / commands.ts # TUI root, state, slash commands
101
+ │ ├── sse-handler.ts # SSE event → TUI store dispatch mapping (PR-4a of #94/#95)
102
+ │ ├── components/ # Ink components — see docs/tui.md for inventory
103
+ │ └── utils/ # format, platform, theme, fullscreen, history
104
+ ├── utils/
105
+ │ ├── validation.ts / worktree.ts / safe-path.ts / duration.ts / search-attributes.ts
106
+ │ ├── attachment-format.ts / recall-format.ts # Shared display formatters (attachment-info, recall)
107
+ │ ├── hosts.ts / format-hosts.ts # Host enumeration + shared hosts display formatter (#274)
108
+ │ ├── sdk-probe.ts # Filesystem-walk probe for installed optional npm deps (used by opencode adapter + recruit preflight, #449)
109
+ │ ├── ensemble-ops.ts # Shared pause/unpause/fan-out helpers for ensemble-scope verbs (pause, play, shutdown, restore, destroy)
110
+ │ ├── query-timeout.ts # Bounded WorkflowHandle.query() wrapper with in-flight deduplication; prevents hung queries from wedging snapshot endpoint (#433)
111
+ │ ├── visibility-deadline.ts # Iterator-level deadlines for Temporal workflow.list() scans; prevents memory growth from stalled visibility page streams (#336, #529)
112
+ │ ├── default-part.ts # Derives human-readable "X session" part string from a player's type name (e.g. tempo-conductor → "Conductor session")
113
+ │ ├── restore-format.ts # Pure formatter for restore --all-hosts cluster-view listing; no Temporal/I/O deps (#151)
114
+ │ └── parent-death-watchdog.ts # Self-exit watchdog (stdin EOF + PPID poll) so MCP server children don't outlive their parent host (#604)
115
+ ├── types.ts # Shared type definitions
116
+ ├── git-info.ts # Git repository detection helper
117
+ └── config.ts # Env var handling
118
+ ```
119
+
120
+ See [docs/tui-performance.md](docs/tui-performance.md) for Ink/React performance notes when
121
+ touching `src/tui/`.
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ npm install
127
+ npm run build # compiles TS, scripts/*.ts → dist/scripts/, and pre-bundles workflow code into workflow-bundle.js
128
+ npm test
129
+ npm run check:all # runs every CI gate locally (build, tests, drift checks, lints, dashboard, size-limit, tarball). Run before pushing to catch CI failures up front.
130
+ ```
131
+
132
+ > **Always run `npm run build` after changing workflow code (`src/workflows/`).** The build
133
+ > pre-bundles workflows into `workflow-bundle.js` so all workers use identical code.
134
+
135
+ > **Two test directories.** Mocha tests live in `test/` (Temporal workflow integration
136
+ > suites, wire-protocol drift detector). Vitest tests live in `tests/` (TUI components,
137
+ > TempoClient fallback paths). Both are first-class targets — when doing call-site
138
+ > surveys or migrations, always grep **both** `test/` and `tests/` or you will miss
139
+ > mocks and assertions that only live in one directory.
140
+
141
+ > **Test-only hooks live with the module they reset and follow the
142
+ > `__<verb><Noun>ForTests` naming convention** — see
143
+ > [docs/adr/0006-test-hooks-naming.md](docs/adr/0006-test-hooks-naming.md). The
144
+ > double-underscore prefix telegraphs "test escape hatch, do not call from
145
+ > production code"; the hook's doc-comment should restate that explicitly. Hooks
146
+ > are never surfaced through barrels or `TempoClient`.
147
+
148
+ > **Project standard is npm** (declared via `package.json#packageManager`,
149
+ > enforced in CI by `lint:lockfile-canonical`). If `npm` is blocked locally
150
+ > (e.g. corp networks), `pnpm` works as a personal workaround — `pnpm-lock.yaml`
151
+ > is gitignored, so it can exist on disk but must NOT be committed. The
152
+ > `lint:lockfile-canonical` step inside `check:all` fails if any non-npm
153
+ > lockfile (`pnpm-lock.yaml`, `yarn.lock`, or their `dashboard/` counterparts)
154
+ > appears in `git ls-files`. The `dashboard/` subworkspace also uses npm and
155
+ > ships its own `package-lock.json` — see `.github/workflows/ci.yml` for why
156
+ > the install is intentionally independent.
157
+
158
+ See [docs/development.md](docs/development.md) for full setup (Temporal dev server command,
159
+ daemon worker notes, `npx ts-node` dev runner).
160
+
161
+ ## Key Concepts
162
+
163
+ > **Architecture overview**: See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the three-layer workflow/adapter/process model and ensemble coordination layer.
164
+
165
+ - **Player**: A Claude Code session registered as a Temporal workflow
166
+ - **Conductor**: A special player that acts as orchestration hub, connected to external interfaces (one per ensemble)
167
+ - **Ensemble**: The set of all active players, namespaced by `CLAUDE_TEMPO_ENSEMBLE`
168
+ - **Cue**: A message sent to a player by name via Temporal signal
169
+ - **Part**: A player's description of what it's working on
170
+ - **Outbox**: Outbound requests (cue, report, recruit, restart, detach, destroy, …) go through the session's workflow outbox instead of directly signaling other workflows. The dispatch loop processes entries via activities, decoupling tools from cross-workflow signaling.
171
+ - **Attachment phase** (v0.26): Seven phases tracked on the session workflow — `booting → attached → processing | awaiting → draining → detached → gone`. The phase is authoritative for lifecycle truth: adapters drive it via `claimAttachment` / `adapterExited` / `forceDetach` / `destroy`, and the workflow publishes it on the `ClaudeTempoAttachmentState` search attribute. Replaced the v0.25 `ClaudeTempoStatus` heuristic (removed in v0.26). See [docs/concepts.md](docs/concepts.md) for the phase table and [docs/ops/v0.26-migration.md](docs/ops/v0.26-migration.md) for the upgrade path.
172
+ - **Adapter heartbeat observability** (#249): After `claimAttachment`, the base adapter logs `first heartbeat scheduled in Xms` then `heartbeat#1 delivered` on the first tick. Every 10 ticks it emits `heartbeats-delivered=N / phase-ticks=N` breadcrumbs. Any silent guard trip in `tickHeartbeat` / `tickPhaseWatcher` now emits a structured `guard tripped: {stopped, reconnecting, …}` log instead of silently orphaning the timer. The phase-watcher emits `WARNING: heartbeat staleness` when `lastHeartbeatAt` falls more than 2× `heartbeatMs` behind `now`. Grep `[agent-tempo:adapter]` to confirm loop health without parsing Temporal history.
173
+ - **Per-host task queues**: `host` param on `recruit`/`restart`/`migrate` routes to `agent-tempo-{hostname}` task queue. When `host` is set on `recruit`, a pre-flight check validates the target daemon is live and supports the requested agent type (`force: true` bypasses). Daemon boot profiles (hostname, platform, available player types) are advertised via the `hostProfile` signal and maintained in the global maestro's `hostProfiles` map — surfaced by the `hosts` MCP tool, `agent-tempo hosts` CLI, and `/hosts` TUI command (#274). See [docs/concepts.md](docs/concepts.md) for cross-machine recruiting details.
174
+ - **Wire protocol**: All signal/query/update names are documented in [`docs/WIRE-PROTOCOL.md`](docs/WIRE-PROTOCOL.md) and are stable — renaming or removing any is a breaking change. **Process**: update `docs/WIRE-PROTOCOL.md` in the same commit as any new signal, query, or update.
175
+ - **Daemon**: Standalone background process (`src/daemon.ts`) that runs all Temporal workers and the HTTP/SSE event source (`src/http/`). Auto-started by any `agent-tempo` command. PID at `~/.agent-tempo/daemon.pid`; logs at `~/.agent-tempo/daemon.log`. Exposes local HTTP endpoints (`/v1/health`, `/v1/ensembles`, `/v1/state/:ensemble`, `/v1/events/:ensemble` SSE stream, etc.) consumed by the TUI and `TempoClient.subscribe()`. See [docs/SSE-PROTOCOL.md](docs/SSE-PROTOCOL.md).
176
+ - **Player types**: Reusable agent definitions in Claude Code's subagent format (`.md` files with YAML frontmatter). Three-tier lookup: project `.claude/agents/` → user `~/.claude/agents/` → shipped `examples/agents/`. Discover via `agent_types` tool or `agent-tempo agent-types` CLI. Shipped types: tempo-conductor, tempo-composer, tempo-soloist, tempo-tuner, tempo-critic, tempo-roadie, tempo-improv, tempo-liner.
177
+ - **Dev mode** (`--dev` flag or `CLAUDE_TEMPO_DEV_MODE=1`): Isolated testing profile — flips home dir to `~/.agent-tempo-dev/`, HTTP port to 8474, Temporal namespace to `agent-tempo-dev`, task queue to `agent-tempo-dev`. Required to use the mock adapter. Post-#423 isolation guarantees: (1) `TEMPORAL_NAMESPACE` / `TEMPORAL_ADDRESS` shell env vars are ignored in dev mode — the dev namespace is not overridable by shell config, only CLI flags and `~/.agent-tempo-dev/config.json`. (2) `--dev down` will not kill the Temporal server if the prod profile is alive; use `--kill-shared-temporal` to override. Canonical entry point (no global install required): `node dist/cli.js --dev <verb>`. Quick E2E: `node dist/cli.js --dev daemon start && node dist/cli.js --dev up --lineup tempo-mock-jam`. See [docs/dev-mode.md](docs/dev-mode.md) for the full reference.
178
+ - **Claude API adapter** (`agent: 'claude-api'`, #131): Headless adapter that drives sessions via the Anthropic Messages API (`@anthropic-ai/sdk`) — no terminal, no Claude Code CLI. Requires `ANTHROPIC_API_KEY` env var and the `@anthropic-ai/sdk` optional dependency. Default model `claude-opus-4-7` (overridable via `model` recruit arg or `CLAUDE_TEMPO_API_MODEL` env). Claude-API players have access to agent-tempo MCP tools (cue, report, recall, ensemble, …) but not file-edit/shell/web tools. See `src/adapters/claude-api/`.
179
+ - **OpenCode adapter** (`agent: 'opencode'`, #449): Headless multi-provider adapter that drives sessions via [SST OpenCode](https://opencode.ai) as a managed subprocess — supports Anthropic, OpenAI, Bedrock, Vertex, Ollama, and ~70 other providers via OpenCode's `provider/model` selector. Requires OpenCode CLI (`npm install -g opencode-ai`) and the `@opencode-ai/sdk` optional dependency. Recruit with `model: 'provider/name'` (e.g. `'anthropic/claude-opus-4-7'`). Tool bridging is MCP-native — OpenCode spawns `dist/server.js` as its own stdio MCP child. Session state is persisted server-side by OpenCode; the adapter stashes the session id on workflow metadata for reconnect across `opencode serve` restarts. See `src/adapters/opencode/`.
180
+ - **Claude Code headless adapter** (`agent: 'claude-code-headless'`, #520): Headless adapter that drives sessions via the official `claude` CLI as a per-turn `claude -p --output-format stream-json` subprocess. The whole point: turns bill against the host's existing Claude Code subscription extra-usage credits (Pro / Max plans) rather than a Console workspace API key — the only ToS-clean way for a third-party tool to tap that pool. Requires the `claude` binary on PATH AND a logged-in Claude Code session (`claude auth login`); recruit pre-flight rejects with an actionable error otherwise. Tool surface is the union of full Claude Code built-ins (Bash / Read / Write / Edit / Glob / Grep / WebSearch / WebFetch) and the agent-tempo MCP surface — registered via inline `--mcp-config` so `claude` spawns `dist/server.js` as its own MCP child (no in-process bridge). Recruit knobs: `permissionMode` (default `'acceptEdits'`) or `dangerouslySkipPermissions: true` (mutually exclusive). Sessions resume across restart via the existing `sessionId` metadata field — the same UUID is shared with the interactive `claude-code` adapter (per-cwd JSONL is per-cwd, not per-adapter). See `src/adapters/claude-code-headless/` and `examples/ensembles/tempo-headless-jam.yaml`.
181
+ - **Mock adapter** (`agent: 'mock'`, dev mode only): Four modes: `echo` (echoes input), `scripted` (replays YAML scenario rules), `silent` (drains messages without replying — heartbeat-stale validation), `chaos` (probabilistic fail/crash injection via seeded PRNG). Only registered when `isDevMode()` is true; stripped from the npm tarball by `prepack`. See `src/adapters/mock/`.
182
+ - **Saveable state** (#334, ADR 0011): Per-player curated state slots — the player itself decides what context survives a restart. Three MCP tools: `save_state` (owner-only write, max 4 slots × 32 KiB), `fetch_state` (read self or peer; audit identity recorded on each entry's `savedBy`), `clear_state` (owner-only). `restart` accepts `loadFromState: true | 'someKey'` to seed the new session from a saved-state slot instead of (or, with `transcript: 'replay'`, alongside) transcript replay. Saved-state delivery uses `from: 'self-restart'` as a stable system identity. Empty-slot fallback: graceful — falls through to transcript replay with a log line. See [docs/design/334-player-saveable-state.md](docs/design/334-player-saveable-state.md).
183
+ - **Coat-check** (#318, ADR 0008): Per-ensemble transient content store on Maestro state. Solves the 100 KB cue body cap — stash a large artifact with `coat_check_put` (returns a ticket id) and attach the ticket to a `cue` via `attachmentTicket`; the recipient calls `coat_check_get` to pull the full body. Four MCP tools: `coat_check_put` (any player; max 32 KiB per entry, 20 slots per ensemble, TTL 7d default), `coat_check_get` (any player; bumps fetch-audit counters), `coat_check_list` (read-only survey; headers only, content omitted), `coat_check_evict` (owner or conductor). Saturation rejects with `CoatCheckSlotsFull` (no LRU eviction). See `src/tools/coat-check-*.ts` and [docs/adr/0008-coat-check-pattern.md](docs/adr/0008-coat-check-pattern.md).
184
+ - **Lineup examples**: Six pre-built ensemble YAML files in `examples/ensembles/` — `tempo-big-band`, `tempo-dev-team`, `tempo-review-squad`, `tempo-jam-session`, `tempo-mock-jam` (dev-mode all-mock ensemble), `tempo-headless-jam` (#520 — all-`claude-code-headless` subscription-billed ensemble). Load with `agent-tempo up --lineup <name>` or the `load_lineup` tool.
185
+ - **GitHub App identity** (`agent-tempo[bot]`): When a player writes to GitHub — issue comments, PR creation/merge, commits, labels, check runs — **use `./scripts/ensemble-gh`** instead of `gh`. The wrapper mints a short-lived installation token so the action is attributed to `agent-tempo[bot]`, not to the human maintainer, making the AI authorship visible. Plain `gh` is still correct for read-only local dev (`gh pr view`, `gh repo clone`, `gh auth status`). Every bot-authored comment/PR body must include the AI attribution footer documented in [docs/github-app.md](docs/github-app.md).
186
+
187
+ See [docs/concepts.md](docs/concepts.md) for the full glossary (Adapter, Attachment phases, Restart, Detach/Destroy, Migrate, Broadcast, Recall, Schedule, Lineup, Quality Gate, Worktree, Stage, Hold/Release, Pause/Resume, Maestro, TempoClient, and more).
188
+
189
+ ## Commit Convention
190
+
191
+ Use conventional commits: `type(scope): message`
192
+
193
+ Examples:
194
+ - `feat(tools): add ensemble discovery tool`
195
+ - `fix(workflow): handle signal delivery edge case`
196
+ - `docs: update getting started guide`
197
+
198
+ ## PR Body Conventions
199
+
200
+ GitHub's auto-close keywords (`Closes`, `Fixes`, `Resolves`) ignore any trailing qualifier text. They cannot express "this PR closes part of an issue" — they always close the full issue.
201
+
202
+ For multi-PR efforts tracked under a single issue, use these conventions in PR bodies:
203
+
204
+ | Form | When to use |
205
+ |---|---|
206
+ | `Refs #N` | Any intermediate PR of a multi-PR effort. No auto-close. |
207
+ | `Implements PR-K of #N` | Same as above, more explicit. No keyword match → no auto-close. |
208
+ | `Closes #N` | Final PR of the effort (or single-PR efforts). Triggers auto-close on merge. |
209
+
210
+ **Avoid `Closes #N PR-K`** — GitHub ignores the `PR-K` qualifier and auto-closes #N prematurely. If you find yourself wanting to express "closes part of," use `Refs #N` and add a manual close on the final PR.
211
+
212
+ When sequencing multi-PR work, name the issue's open question explicitly in the first PR's body (e.g., "PR-1 of 2: foundation; PR-2 follows for the user-visible payoff") so reviewers know more is coming.
213
+
214
+ ## Release Process
215
+
216
+ > **Release rule**: Bump `package.json` + CHANGELOG before tagging. Never tag a commit that
217
+ > doesn't match the version. Tagging prematurely publishes the old version to npm.
218
+
219
+ See [docs/release-process.md](docs/release-process.md) for the full 4-step sequence.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026-present vinceblank
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present vinceblank
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.