agent-tempo 1.7.0-beta.8 → 1.7.0-beta.9
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.
- package/CLAUDE.md +13 -6
- package/dashboard/package.json +1 -1
- package/dist/activities/maestro.d.ts +46 -1
- package/dist/activities/maestro.js +69 -20
- package/dist/activities/outbox.d.ts +14 -1
- package/dist/activities/outbox.js +61 -10
- package/dist/activities/resolve.d.ts +36 -0
- package/dist/activities/resolve.js +119 -4
- package/dist/activities/schedule-fire.js +5 -2
- package/dist/adapters/base.d.ts +2 -0
- package/dist/adapters/base.js +9 -0
- package/dist/adapters/claude-api/adapter.js +26 -4
- package/dist/adapters/claude-code/adapter.js +15 -9
- package/dist/adapters/claude-code-headless/adapter.js +22 -4
- package/dist/adapters/copilot/adapter.js +58 -8
- package/dist/adapters/opencode/adapter.js +26 -6
- package/dist/adapters/sdk/base.d.ts +60 -0
- package/dist/adapters/sdk/base.js +83 -0
- package/dist/adapters/sdk/doorbell-client.d.ts +106 -0
- package/dist/adapters/sdk/doorbell-client.js +261 -0
- package/dist/adapters/sdk/idle-backoff.d.ts +71 -0
- package/dist/adapters/sdk/idle-backoff.js +136 -0
- package/dist/cli/commands.js +23 -3
- package/dist/cli/config-command.js +14 -0
- package/dist/cli/daemon-command.js +41 -5
- package/dist/cli/daemon.d.ts +245 -5
- package/dist/cli/daemon.js +505 -44
- package/dist/cli/help-text.js +3 -1
- package/dist/cli/sa-preflight.d.ts +27 -1
- package/dist/cli/sa-preflight.js +29 -5
- package/dist/cli/upgrade-to-2-command.d.ts +10 -0
- package/dist/cli/upgrade-to-2-command.js +159 -0
- package/dist/cli.js +20 -0
- package/dist/client/core.d.ts +6 -0
- package/dist/client/core.js +81 -34
- package/dist/config.d.ts +53 -0
- package/dist/config.js +70 -1
- package/dist/daemon.d.ts +34 -0
- package/dist/daemon.js +259 -21
- package/dist/ensemble/saver.d.ts +10 -0
- package/dist/ensemble/saver.js +18 -6
- package/dist/http/aggregate.d.ts +88 -1
- package/dist/http/aggregate.js +157 -13
- package/dist/http/doorbell-routes.d.ts +32 -0
- package/dist/http/doorbell-routes.js +72 -0
- package/dist/http/doorbell.d.ts +45 -0
- package/dist/http/doorbell.js +162 -0
- package/dist/http/inner-loop-routes.d.ts +9 -0
- package/dist/http/inner-loop-routes.js +4 -0
- package/dist/http/server.d.ts +9 -0
- package/dist/http/server.js +45 -1
- package/dist/http/snapshot.d.ts +28 -5
- package/dist/http/snapshot.js +16 -6
- package/dist/pi/cue-pump.d.ts +107 -7
- package/dist/pi/cue-pump.js +131 -24
- package/dist/pi/extension.js +11 -0
- package/dist/pi/headless.js +49 -13
- package/dist/pi/mission-control/actions.d.ts +22 -1
- package/dist/pi/mission-control/actions.js +20 -0
- package/dist/pi/mission-control/board.d.ts +20 -0
- package/dist/pi/mission-control/board.js +41 -1
- package/dist/pi/mission-control/extension.d.ts +44 -0
- package/dist/pi/mission-control/extension.js +145 -2
- package/dist/pi/mission-control/render.js +16 -1
- package/dist/pi/workflow-client.d.ts +29 -0
- package/dist/pi/workflow-client.js +87 -3
- package/dist/reconcile/orphans.js +8 -9
- package/dist/server-tools.js +1 -1
- package/dist/server.js +11 -1
- package/dist/spawn.d.ts +35 -0
- package/dist/spawn.js +5 -0
- package/dist/tools/broadcast.js +15 -1
- package/dist/tools/cue.js +40 -11
- package/dist/tools/ensemble.js +11 -2
- package/dist/tools/recruit.js +4 -4
- package/dist/tools/who-am-i.d.ts +3 -2
- package/dist/tools/who-am-i.js +9 -2
- package/dist/types.d.ts +42 -0
- package/dist/upgrade/phase-engine.d.ts +160 -0
- package/dist/upgrade/phase-engine.js +555 -0
- package/dist/upgrade/snapshot-v1.d.ts +214 -0
- package/dist/upgrade/snapshot-v1.js +165 -0
- package/dist/utils/action-counters.d.ts +75 -0
- package/dist/utils/action-counters.js +279 -0
- package/dist/utils/format-hosts.js +7 -0
- package/dist/utils/hosts.js +5 -0
- package/dist/utils/search-attributes.d.ts +76 -4
- package/dist/utils/search-attributes.js +89 -4
- package/dist/utils/suspension.d.ts +99 -0
- package/dist/utils/suspension.js +128 -0
- package/dist/utils/visibility-deadline.js +5 -0
- package/dist/worker.d.ts +16 -1
- package/dist/worker.js +25 -4
- package/dist/workflows/maestro.d.ts +10 -0
- package/dist/workflows/maestro.js +126 -21
- package/dist/workflows/scheduler.js +17 -2
- package/dist/workflows/session.js +251 -14
- package/dist/workflows/signals.d.ts +8 -0
- package/dist/workflows/signals.js +3 -2
- package/package.json +1 -1
- package/workflow-bundle.js +580 -40
package/CLAUDE.md
CHANGED
|
@@ -41,7 +41,8 @@ src/
|
|
|
41
41
|
│ ├── sa-preflight.ts # search-attribute preflight — REQUIRED_SEARCH_ATTRIBUTES list (single source of truth), registerSearchAttribute, verifySearchAttributes, assertSearchAttributesOrExit
|
|
42
42
|
│ ├── scenarios-command.ts # scenarios subcommand (dev mode only) — list/show shipped YAML scenario library (ADR 0014 §4.8)
|
|
43
43
|
│ ├── startup.ts # auto-provisioning bootstrap state machine (#289) — six-step idempotent sequence used by bare `agent-tempo` invocation
|
|
44
|
-
│
|
|
44
|
+
│ ├── upgrade-command.ts # upgrade subcommand — crash-proof; dynamic-imports Temporal only for active-session warning
|
|
45
|
+
│ └── upgrade-to-2-command.ts # upgrade-to-2 cutover verb (#785) — crash-proof; dynamic-imports the phase-engine + Temporal inside try/catch; --yes/--dry-run/--force-drain
|
|
45
46
|
├── adapters/
|
|
46
47
|
│ ├── README.md # Adapter contract documentation
|
|
47
48
|
│ ├── index.ts # Adapter registry bootstrap + barrel exports (mock registered iff isDevMode())
|
|
@@ -53,7 +54,7 @@ src/
|
|
|
53
54
|
│ ├── opencode/ # OpenCodeAttachment — headless multi-provider adapter via SST OpenCode subprocess (#449)
|
|
54
55
|
│ ├── pi/ # Headless Pi adapter — descriptor + spawn entry (Phase 3a). No BaseAttachment; the Pi extension singleton owns lifecycle (claim/heartbeat/tools/cue pump). `adapter.ts` is the process entry; `index.ts` is the registry descriptor.
|
|
55
56
|
│ ├── mock/ # MockAttachment — dev-mode-only SDK adapter (ADR 0014 PR-2). prepack strips dist/adapters/mock from npm tarball.
|
|
56
|
-
│ └── sdk/ # SDK-style adapter base (used by Copilot bridge and opencode)
|
|
57
|
+
│ └── sdk/ # SDK-style adapter base (used by Copilot bridge and opencode). Key files: `idle-backoff.ts` (T0.2 IdleBackoff helper — base 2s, cap 30s/60s, reset-on-delivery), `doorbell-client.ts` (T1.1 DoorbellClient + WakeableSleep — reconnecting SSE consumer for `/doorbell`; ding→reset()+wake(); connected ceiling 60s; disconnected falls back to 30s T0.2 floor)
|
|
57
58
|
├── client/
|
|
58
59
|
│ ├── interface.ts # TempoClient TypeScript interface and related types
|
|
59
60
|
│ └── index.ts # TempoClient factory implementation and barrel re-exports
|
|
@@ -85,12 +86,17 @@ src/
|
|
|
85
86
|
│ ├── inner-loop.ts # InnerLoopRegistry + InnerSubscription — daemon-local fine-tail sink (3c MD-F); drop-oldest bounded queue (256) + `compacted{dropped,sinceTs}` marker; NOT on Temporal/bus, ephemeral no-replay
|
|
86
87
|
│ ├── ingest-registry.ts # IngestTokenRegistry — per-player ingest token (mint-on-pi-spawn / revoke-on-destroy / revokeAll-on-shutdown); timing-safe validation; cross-player-spoof guard
|
|
87
88
|
│ ├── inner-loop-routes.ts # 3 inner-loop HTTP routes: POST /inner/ingest + GET /inner/presence (INGRESS, loopback + X-Ingest-Token, uniform 403); GET /inner (EGRESS operator SSE, requireTier(3))
|
|
89
|
+
│ ├── doorbell.ts # DoorbellRegistry — in-process Map<"{ensemble}:{playerId}", Set<waiter>>; ring-with-no-listener drops on floor; level-triggered coalescing; never throws (T1.1 PR-1, #776)
|
|
90
|
+
│ ├── doorbell-routes.ts # GET /doorbell/:ensemble/:playerId SSE route — content-free ding events; loopback + X-Ingest-Token auth (same ingress model as inner-loop); NO event IDs / Last-Event-ID / replay by design; :ka keepalive every 15s (T1.1 PR-1, #776)
|
|
88
91
|
│ ├── auth.ts # 3e MD-E RBAC: two-token model (readToken T1 / adminToken T1+T2+T3 env-var-only); loadRbacTokens; requireTier(tier, input) → TierGuardResult; tierForToken; loadReadToken (env>config>legacy httpToken>auto-gen); loadAdminToken (env-only); TLS/legacy startup warnings in startHttpServer
|
|
89
92
|
│ ├── cors.ts / responses.ts / event-id.ts / port-file.ts / index.ts
|
|
90
93
|
├── reconcile/
|
|
91
94
|
│ └── orphans.ts # Shared orphan-query helper (daemon reconcile-on-boot + CLI restore)
|
|
95
|
+
├── upgrade/ # 1.x→2.0 cutover (#785)
|
|
96
|
+
│ ├── snapshot-v1.ts # VERSIONED upgrade-snapshot-v1.json schema + atomic persistence — the cross-release interface #786 imports (Temporal-free)
|
|
97
|
+
│ └── phase-engine.ts # 6-phase resumable cutover engine (preflight→pause→drain→snapshot→destroy→done); snapshot strictly precedes destroy
|
|
92
98
|
├── ensemble/
|
|
93
|
-
│ ├── schema.ts / loader.ts / saver.ts # Lineup type definitions, load, save
|
|
99
|
+
│ ├── schema.ts / loader.ts / saver.ts # Lineup type definitions, load, save (saver exports buildLineupFromCluster — shared by save_lineup + #785 snapshot)
|
|
94
100
|
│ └── agent-types.ts # Agent type discovery, resolution, and lineup resolution
|
|
95
101
|
├── tools/ # One file per MCP tool — see docs/tools.md for full reference
|
|
96
102
|
│ ├── ensemble.ts / cue.ts / recruit.ts / report.ts / broadcast.ts / recall.ts / listen.ts
|
|
@@ -108,7 +114,7 @@ src/
|
|
|
108
114
|
│ └── descriptor.ts # Transport-neutral tool descriptor (TempoToolDescriptor) + renderToMcp; per-tool `build*Tool` factories live in each tool file (MD-B, Phase 1)
|
|
109
115
|
├── pi/ # Pi-native integration — a Pi session as a first-class player over the Temporal core
|
|
110
116
|
│ ├── extension.ts # `export default function(pi)` — interactive runtime entry. Holds the MODULE-SCOPE singleton `Map<workflowId, PiPlayerRuntime>` that survives Pi's per-switch instance rebuild (rebind, not re-claim); full tool surface via renderToPi; Option-C reason-discriminated teardown
|
|
111
|
-
│ ├── phase-driver.ts / workflow-client.ts / cue-pump.ts # Pi-event→attachment-phase machine, thin client-side WorkflowClient (lease/heartbeat 90/30, handle getter), cue pump (D10 steer/followUp;
|
|
117
|
+
│ ├── phase-driver.ts / workflow-client.ts / cue-pump.ts # Pi-event→attachment-phase machine, thin client-side WorkflowClient (lease/heartbeat 90/30, handle getter), cue pump (D10 steer/followUp; IdleBackoff loop 1s base→30s disconnected/60s connected ceiling + ding wake via DoorbellClient; pendingIntake combined query T0.3; S3 merge, D14 clean-wipe + /tempo-reset operator notice)
|
|
112
118
|
│ ├── lazy-proxy.ts # D11 createLazyProxy — Client/WorkflowHandle proxy resolving the live module-scope target per call (survives instance rebuild)
|
|
113
119
|
│ ├── headless.ts # Headless Pi runtime (Phase 3a) — boots Pi's createAgentSession with inline extension; `noExtensions: true` closes S2 exec-tool bypass; SIGTERM/SIGINT shutdown → reliable detach + dispose
|
|
114
120
|
│ ├── render-tools.ts # renderToPi — registers the shared tool descriptors on Pi's ExtensionAPI (TypeBox params via the converter)
|
|
@@ -208,14 +214,15 @@ daemon worker notes, `npx ts-node` dev runner).
|
|
|
208
214
|
- **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/`.
|
|
209
215
|
- **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/`.
|
|
210
216
|
- **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`.
|
|
211
|
-
- **Pi adapter** (`agent: 'pi'`, #632 / #666): Two modes. **(1) Interactive conductor** (#666): `agent-tempo up --agent pi --ensemble <name>` launches `pi` in a real terminal with the agent-tempo extension auto-loaded (`pi -e dist/pi/extension.js`); the Pi session self-bootstraps its Temporal workflow and attaches as a conductor/player — no separate recruiter step. From the TUI, `/recruit-conductor` relaunches the active ensemble's conductor — set `conductor.agent: pi` in that ensemble's lineup to make it a Pi conductor. Requires `@earendil-works/pi-coding-agent` on Node ≥ 22.19. Recommended: `ANTHROPIC_API_KEY` (without it the session falls back to Pi's own auth/default model). The `AGENT_TEMPO_*` env is auto-wired by `up`; power users can invoke the extension directly with `pi -e dist/pi/extension.js`. `--model provider/model` selector (e.g. `'github-copilot/gpt-4o'`)
|
|
217
|
+
- **Pi adapter** (`agent: 'pi'`, #632 / #666): Two modes. **(1) Interactive conductor** (#666): `agent-tempo up --agent pi --ensemble <name>` launches `pi` in a real terminal with the agent-tempo extension auto-loaded (`pi -e dist/pi/extension.js`); the Pi session self-bootstraps its Temporal workflow and attaches as a conductor/player — no separate recruiter step. From the TUI, `/recruit-conductor` relaunches the active ensemble's conductor — set `conductor.agent: pi` in that ensemble's lineup to make it a Pi conductor. Requires `@earendil-works/pi-coding-agent` on Node ≥ 22.19. Recommended: `ANTHROPIC_API_KEY` (without it the session falls back to Pi's own auth/default model). The `AGENT_TEMPO_*` env is auto-wired by `up`; power users can invoke the extension directly with `pi -e dist/pi/extension.js`. The interactive `--model provider/model` selector (e.g. `'github-copilot/gpt-4o'`) remains a fast-follow. **(2) Headless player** (Phase 3a): `recruit` with `agent: 'pi'` — no terminal, no BaseAttachment; runs `createAgentSession` with an in-memory `SessionManager`; the module-scope singleton owns claim/heartbeat/tools/cue pump (MD-D). Per-player `model: 'provider/model'` on recruit (#734): built-in providers AND custom `~/.pi/agent/models.json` providers (lmstudio, ollama, vllm, …) both resolve, falling back to `AGENT_TEMPO_PI_MODEL` — enables hybrid ensembles (frontier-model conductor, local-model workers). Pi players run the full tool surface — incl. shell — with no permission layer, like the other adapters (the former `toolAccess`/`guardrailPolicy` knobs were removed). `noExtensions: true` stays: it blocks third-party disk/package extensions from loading into a recruited player (supply-chain hygiene). See `src/adapters/pi/` and `src/pi/headless.ts`.
|
|
212
218
|
- **Mission-control / Command-center** (3f, #700 P2): An interactive Pi TUI that is both a live ensemble board + operator controller and an LLM planner. Board side: HTTP-drives the daemon — coarse ensemble view via `/v1/events/:ensemble` SSE + fine per-player tail via `/inner` (T3); operator controls (cue/pause/play/restart/destroy) POST to the daemon write surface using `AGENT_TEMPO_HTTP_ADMIN_TOKEN`. Planner side: registers LLM tools (`ask` / `handoff` / `cue` / `recruit` / `observe_board`) via `MissionControlActions` — HTTP-backed, distinct from the player extension's `renderToPi` MCP surface. **Never claims attachment or registers as a player** — invisible to the ensemble. Launch with **`agent-tempo command-center [ensemble]`** (aliases: `cc`, `board`) — sets `AGENT_TEMPO_MISSION_CONTROL=1`. **Loopback auto-token** (#736): a local (loopback) daemon grants full trust without `AGENT_TEMPO_HTTP_ADMIN_TOKEN`; only a remote daemon requires explicit token configuration. **Role-gated and mutually exclusive** with the player extension (`resolvePiRole` discriminator: explicit `AGENT_TEMPO_PI_ROLE` → `PLAYER_NAME` present → `AGENT_TEMPO_MISSION_CONTROL` → `none`): a bare `pi` keeps both extensions dormant (plain coding session); a player session (`up --agent pi` / `recruit`) keeps the board dormant. Power users invoking `pi -e dist/pi/extension.js` directly without `PLAYER_NAME` also resolve to `none` (dormant) — set `AGENT_TEMPO_PI_ROLE=player` to force player mode. See `src/pi/mission-control/`.
|
|
213
219
|
- **Command-center planner** (#700 P2): An inbox-less interactive Pi session (the operator's planning seat) that routes questions to players via correlated `cue` tags (`[Q <questionId>]`). Players answer with the `respond` MCP tool, which parks the answer on the per-ensemble maestro Q&A mailbox (TTL 1h, 20-slot cap). The planner is woken by an `answer` SSE event when the answer lands (`docs/SSE-PROTOCOL.md` §6). `/handoff` cues hand active work to a conductor (a registered player with a Temporal inbox). See `docs/concepts.md` for the Q&A mechanics.
|
|
214
220
|
- **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/`.
|
|
215
221
|
- **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).
|
|
222
|
+
- **`upgrade-to-2` cutover** (#785, ratified migration protocol A2 — `docs/design/v2-scoping.md` §A.3): The 1.x → 2.0 migration verb. A 2.0 worker can never replay a 1.x-recorded run, so 2.0 ships behind a clean cutover: `agent-tempo upgrade-to-2` runs a six-phase protocol — **preflight** (enumerate ensembles; refuse if any connected daemon is below the 1.7.x version floor — `hostProfile.version` on the global maestro; covers same-host-stale-daemon, #801) → **pause** (brake the work *sources* — maestro + scheduler — leaving sessions live to drain) → **drain** (poll outboxes ≤60s; `--force-drain` records stragglers instead of stopping) → **snapshot** (freeze session dispatch, then capture continuity to `~/.agent-tempo/upgrade-snapshot-v1.json`) → **destroy** (idempotent teardown: peers → scheduler+maestro → conductor) → **done**. **Load-bearing invariant: SNAPSHOT strictly precedes DESTROY** (`destroyAndFinish` takes a persisted snapshot as a required arg); a crash leaves either everything intact or a durable snapshot + partial teardown, never destruction without capture. Resumable via the snapshot's phase stamp. The snapshot captures schedules (durable intent), #334 state slots (continuity), `sessionId` (resume pointer), the non-default recruit `model` (ad-hoc claude-api/opencode/pi continuity), and undelivered cues (operator review, NOT redelivered); coat-check is dropped (TTL-transient); gates/stages/worktrees are intentionally not captured (transient coordination state; worktree continuity rides `workDir`). **`src/upgrade/snapshot-v1.ts` is the cross-release interface the 2.0-side `up --from-upgrade` (#786) imports** — it is VERSIONED and deliberately Temporal-free; additive optional fields do NOT bump the version, only removed/renamed/retyped required fields do (with a 2.0 reader migration). CLI flags: `--yes` (skip confirm), `--dry-run` (print snapshot + destroy list, exit before pausing), `--force-drain`. The verb is crash-proof (`src/cli/upgrade-to-2-command.ts` dynamic-imports the Temporal-touching engine). See `src/upgrade/` and issue #785.
|
|
216
223
|
- **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).
|
|
217
224
|
- **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.
|
|
218
|
-
- **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).
|
|
225
|
+
- **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`). On Windows, invoke via `bash ./scripts/ensemble-gh` — bare PowerShell silently no-ops with no error (see #741). Every bot-authored comment/PR body must include the AI attribution footer documented in [docs/github-app.md](docs/github-app.md).
|
|
219
226
|
|
|
220
227
|
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, Command-center planner, and more).
|
|
221
228
|
|
package/dashboard/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-tempo-dashboard",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "1.7.0-beta.
|
|
4
|
+
"version": "1.7.0-beta.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Web dashboard for agent-tempo. Bundled into the npm package; served by the daemon at /dashboard/*.",
|
|
7
7
|
"scripts": {
|
|
@@ -55,9 +55,54 @@ export interface FetchEnsembleChatResult {
|
|
|
55
55
|
hasConductor: boolean;
|
|
56
56
|
error?: string;
|
|
57
57
|
}
|
|
58
|
+
/** T0.1 (#748) — result of the V2 refresh (cloud-profile maestros). */
|
|
59
|
+
export interface RefreshEnsembleStateV2Result {
|
|
60
|
+
players: MaestroPlayerInfo[];
|
|
61
|
+
/**
|
|
62
|
+
* Whether the daemon currently has any live SSE subscriber (TUI, web
|
|
63
|
+
* dashboard, mission-control board). Read in-process from the
|
|
64
|
+
* AggregateRunner — zero Temporal cost. The maestro workflow stretches
|
|
65
|
+
* its next refresh timer when nobody is watching. `true` when no
|
|
66
|
+
* presence source is wired (fail-open: never stretch by accident).
|
|
67
|
+
*/
|
|
68
|
+
observersPresent: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* T0.1 (#748) — daemon-side observer presence source. A mutable holder
|
|
72
|
+
* because worker/activity construction happens BEFORE the daemon's
|
|
73
|
+
* AggregateRunner exists; daemon.ts fills `current` in once the HTTP/SSE
|
|
74
|
+
* plane is up (same late-wiring pattern as IngestTokenRegistry).
|
|
75
|
+
*/
|
|
76
|
+
export interface ObserverPresenceSource {
|
|
77
|
+
current: (() => number) | null;
|
|
78
|
+
}
|
|
79
|
+
/** Options for {@link createMaestroActivities} (T0.1, #748). */
|
|
80
|
+
export interface MaestroActivityOptions {
|
|
81
|
+
/** Daemon cost profile — drives the V2 scan strategy. Default 'local'. */
|
|
82
|
+
costProfile?: 'local' | 'cloud';
|
|
83
|
+
/** Late-wired SSE subscriber count source (see {@link ObserverPresenceSource}). */
|
|
84
|
+
observerPresence?: ObserverPresenceSource;
|
|
85
|
+
}
|
|
58
86
|
/** Activity interface — used by proxyActivities in the Maestro workflow. */
|
|
59
87
|
export interface MaestroActivities {
|
|
88
|
+
/**
|
|
89
|
+
* Legacy V1 refresh — the `costProfile: 'local'` path AND the replay
|
|
90
|
+
* path for every maestro started before #748.
|
|
91
|
+
* TODO(next major, #748): remove once the minimum deployment age
|
|
92
|
+
* exceeds the longest-lived pre-#748 maestro history (they replay V1);
|
|
93
|
+
* remove together with the V1 branch in workflows/maestro.ts.
|
|
94
|
+
*/
|
|
60
95
|
refreshEnsembleState(ensemble: string): Promise<MaestroPlayerInfo[]>;
|
|
96
|
+
/**
|
|
97
|
+
* T0.1 (#748) — additive V2: called only by maestros started with
|
|
98
|
+
* `costProfile: 'cloud'` in their input. SA/memo-based ensemble-scoped
|
|
99
|
+
* scan + in-process observer presence for workflow-side cadence
|
|
100
|
+
* stretching. V1 stays for in-flight pre-#748 maestros (replay safety)
|
|
101
|
+
* and the local profile.
|
|
102
|
+
*/
|
|
103
|
+
refreshEnsembleStateV2(input: {
|
|
104
|
+
ensemble: string;
|
|
105
|
+
}): Promise<RefreshEnsembleStateV2Result>;
|
|
61
106
|
fetchConductorHistory(input: FetchConductorHistoryInput): Promise<FetchConductorHistoryResult>;
|
|
62
107
|
relayCommandToConductor(input: RelayCommandInput): Promise<RelayCommandResult>;
|
|
63
108
|
discoverEnsembles(): Promise<string[]>;
|
|
@@ -69,4 +114,4 @@ export interface MaestroActivities {
|
|
|
69
114
|
* Create the Maestro activity implementations bound to a Temporal client.
|
|
70
115
|
* Registered with the shared worker.
|
|
71
116
|
*/
|
|
72
|
-
export declare function createMaestroActivities(client: Client): MaestroActivities;
|
|
117
|
+
export declare function createMaestroActivities(client: Client, opts?: MaestroActivityOptions): MaestroActivities;
|
|
@@ -5,40 +5,89 @@ const activity_1 = require("@temporalio/activity");
|
|
|
5
5
|
const config_1 = require("../config");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
const resolve_1 = require("./resolve");
|
|
8
|
+
const action_counters_1 = require("../utils/action-counters");
|
|
8
9
|
const visibility_deadline_1 = require("../utils/visibility-deadline");
|
|
9
10
|
const log = (...args) => console.error('[agent-tempo:maestro]', ...args);
|
|
10
11
|
/**
|
|
11
12
|
* Create the Maestro activity implementations bound to a Temporal client.
|
|
12
13
|
* Registered with the shared worker.
|
|
13
14
|
*/
|
|
14
|
-
function createMaestroActivities(client) {
|
|
15
|
-
|
|
15
|
+
function createMaestroActivities(client, opts = {}) {
|
|
16
|
+
/** Shared row-mapper for both refresh shapes. */
|
|
17
|
+
const toPlayerInfo = (ensemble) => (s) => ({
|
|
18
|
+
playerId: s.playerId,
|
|
19
|
+
ensemble,
|
|
20
|
+
part: s.part,
|
|
21
|
+
hostname: s.hostname,
|
|
22
|
+
workDir: s.workDir,
|
|
23
|
+
gitRoot: s.gitRoot,
|
|
24
|
+
gitBranch: s.gitBranch,
|
|
25
|
+
isConductor: s.isConductor,
|
|
26
|
+
agentType: s.agentType,
|
|
27
|
+
playerType: s.playerType,
|
|
28
|
+
phase: s.phase,
|
|
29
|
+
// #399 W1 — forward the activity-counter pair so the maestro's
|
|
30
|
+
// tempo bucket can diff across refreshes.
|
|
31
|
+
activityCount: s.activityCount,
|
|
32
|
+
lastActivityAt: s.lastActivityAt,
|
|
33
|
+
});
|
|
34
|
+
// #753 — attribute every Temporal call made by these activities (however
|
|
35
|
+
// deep, e.g. scanEnsembleSessions → queryHandleWithTimeout) to the maestro.
|
|
36
|
+
//
|
|
37
|
+
// T0.6/#774 (architect verification prerequisite) — the tag is SPLIT by
|
|
38
|
+
// the CALLING workflow, resolved per invocation from the activity
|
|
39
|
+
// context: the same factory serves the per-ensemble maestro (chat-gated)
|
|
40
|
+
// and the global maestro (never gated — the prime unwatched-residual
|
|
41
|
+
// suspect), and the meter must tell them apart. Anything else (incl.
|
|
42
|
+
// direct test invocation outside an activity context) lands in
|
|
43
|
+
// 'maestro-session'. NOTE: bySource report keys for the maestro line
|
|
44
|
+
// changed from 'maestro' to these three.
|
|
45
|
+
const maestroSource = () => {
|
|
46
|
+
try {
|
|
47
|
+
switch ((0, activity_1.activityInfo)().workflowType) {
|
|
48
|
+
case 'agentMaestroWorkflow': return 'maestro-ensemble';
|
|
49
|
+
case 'agentGlobalMaestroWorkflow': return 'maestro-global';
|
|
50
|
+
default: return 'maestro-session';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return 'maestro-session'; // outside an activity context (tests, direct calls)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return (0, action_counters_1.tagActionSource)(maestroSource, {
|
|
16
58
|
async refreshEnsembleState(ensemble) {
|
|
17
59
|
try {
|
|
18
60
|
const sessions = await (0, resolve_1.scanEnsembleSessions)(client, ensemble);
|
|
19
|
-
return sessions.map((
|
|
20
|
-
playerId: s.playerId,
|
|
21
|
-
ensemble,
|
|
22
|
-
part: s.part,
|
|
23
|
-
hostname: s.hostname,
|
|
24
|
-
workDir: s.workDir,
|
|
25
|
-
gitRoot: s.gitRoot,
|
|
26
|
-
gitBranch: s.gitBranch,
|
|
27
|
-
isConductor: s.isConductor,
|
|
28
|
-
agentType: s.agentType,
|
|
29
|
-
playerType: s.playerType,
|
|
30
|
-
phase: s.phase,
|
|
31
|
-
// #399 W1 — forward the activity-counter pair so the maestro's
|
|
32
|
-
// tempo bucket can diff across refreshes.
|
|
33
|
-
activityCount: s.activityCount,
|
|
34
|
-
lastActivityAt: s.lastActivityAt,
|
|
35
|
-
}));
|
|
61
|
+
return sessions.map(toPlayerInfo(ensemble));
|
|
36
62
|
}
|
|
37
63
|
catch (err) {
|
|
38
64
|
log('refreshEnsembleState failed:', err);
|
|
39
65
|
throw activity_1.ApplicationFailure.nonRetryable(`Failed to scan ensemble: ${err instanceof Error ? err.message : String(err)}`);
|
|
40
66
|
}
|
|
41
67
|
},
|
|
68
|
+
async refreshEnsembleStateV2(input) {
|
|
69
|
+
try {
|
|
70
|
+
// Honor the DAEMON's configured profile for the scan strategy: a
|
|
71
|
+
// cloud-input maestro on a daemon flipped back to 'local' degrades
|
|
72
|
+
// gracefully to the legacy scan (still on the stretched cadence
|
|
73
|
+
// until its next restart).
|
|
74
|
+
const sessions = opts.costProfile === 'cloud'
|
|
75
|
+
? await (0, resolve_1.scanEnsembleSessionsCloud)(client, input.ensemble, log)
|
|
76
|
+
: await (0, resolve_1.scanEnsembleSessions)(client, input.ensemble);
|
|
77
|
+
const count = opts.observerPresence?.current?.();
|
|
78
|
+
return {
|
|
79
|
+
players: sessions.map(toPlayerInfo(input.ensemble)),
|
|
80
|
+
// Fail-open: unknown presence (no aggregate wired yet, e.g. during
|
|
81
|
+
// daemon boot) counts as "observers present" — never stretch the
|
|
82
|
+
// cadence on missing information.
|
|
83
|
+
observersPresent: count === undefined ? true : count > 0,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
log('refreshEnsembleStateV2 failed:', err);
|
|
88
|
+
throw activity_1.ApplicationFailure.nonRetryable(`Failed to scan ensemble: ${err instanceof Error ? err.message : String(err)}`);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
42
91
|
async fetchConductorHistory(input) {
|
|
43
92
|
try {
|
|
44
93
|
const wfId = (0, config_1.conductorWorkflowId)(input.ensemble);
|
|
@@ -250,5 +299,5 @@ function createMaestroActivities(client) {
|
|
|
250
299
|
};
|
|
251
300
|
}
|
|
252
301
|
},
|
|
253
|
-
};
|
|
302
|
+
});
|
|
254
303
|
}
|
|
@@ -218,4 +218,17 @@ export interface OutboxActivities {
|
|
|
218
218
|
* claim — phase is legitimately live) → never skipped. Pure + exported for tests.
|
|
219
219
|
*/
|
|
220
220
|
export declare function shouldSkipDuplicateSpawn(attachmentId: string | undefined, phase: AttachmentPhase): boolean;
|
|
221
|
-
|
|
221
|
+
/**
|
|
222
|
+
* T1.1 PR-1 — late-wired doorbell sink (the ObserverPresenceSource pattern:
|
|
223
|
+
* activity construction happens before the HTTP plane exists, so the daemon
|
|
224
|
+
* fills `current` at boot). A worker process that is not the daemon keeps
|
|
225
|
+
* `current: null` — ring() is a no-op and fallback polling covers it (§2.1).
|
|
226
|
+
* Defined here (not in src/http) so activities never import the HTTP plane.
|
|
227
|
+
*/
|
|
228
|
+
export interface DoorbellSink {
|
|
229
|
+
current: {
|
|
230
|
+
ring(ensemble: string, playerId: string): void;
|
|
231
|
+
closePlayer(ensemble: string, playerId: string): void;
|
|
232
|
+
} | null;
|
|
233
|
+
}
|
|
234
|
+
export declare function createOutboxActivities(client: Client, config: Config, ingestTokens?: IngestTokenRegistry, doorbells?: DoorbellSink): OutboxActivities;
|
|
@@ -46,6 +46,8 @@ const git_info_1 = require("../git-info");
|
|
|
46
46
|
const spawn_1 = require("../spawn");
|
|
47
47
|
const config_2 = require("../config");
|
|
48
48
|
const resolve_1 = require("./resolve");
|
|
49
|
+
const action_counters_1 = require("../utils/action-counters");
|
|
50
|
+
const search_attributes_1 = require("../utils/search-attributes");
|
|
49
51
|
const agent_types_1 = require("../ensemble/agent-types");
|
|
50
52
|
const default_part_1 = require("../utils/default-part");
|
|
51
53
|
const adapters_1 = require("../adapters");
|
|
@@ -156,8 +158,24 @@ function shouldSkipDuplicateSpawn(attachmentId, phase) {
|
|
|
156
158
|
return false; // restart/migrate handoff — must spawn
|
|
157
159
|
return phase === 'attached' || phase === 'processing' || phase === 'awaiting';
|
|
158
160
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Ring the doorbell sink, swallowing EVERYTHING — a ring must never fail or
|
|
163
|
+
* retry the delivery activity it follows (t11 §1: doorbell loss must be
|
|
164
|
+
* indistinguishable from doorbell-never-sent).
|
|
165
|
+
*/
|
|
166
|
+
function ringDoorbell(doorbells, ensemble, playerId) {
|
|
167
|
+
try {
|
|
168
|
+
doorbells?.current?.ring(ensemble, playerId);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
/* never propagate — §1 */
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function createOutboxActivities(client, config, ingestTokens, doorbells) {
|
|
175
|
+
// #753 — attribute every Temporal call made by these activities (however
|
|
176
|
+
// deep, e.g. deliverCue → resolveSession → queryHandleWithTimeout) to the
|
|
177
|
+
// outbox dispatch plane.
|
|
178
|
+
return (0, action_counters_1.tagActionSource)('outbox', {
|
|
161
179
|
async deliverCue(input) {
|
|
162
180
|
const { ensemble, fromPlayerId, targetPlayerId, message, broadcastId, attachmentTicket } = input;
|
|
163
181
|
try {
|
|
@@ -174,6 +192,10 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
174
192
|
...(broadcastId !== undefined ? { broadcastId } : {}),
|
|
175
193
|
...(attachmentTicket !== undefined ? { attachmentTicket } : {}),
|
|
176
194
|
});
|
|
195
|
+
// T1.1 — the signal above has landed durably in history; ring the
|
|
196
|
+
// doorbell so a connected adapter polls now instead of at its
|
|
197
|
+
// backoff ceiling. Fire-and-forget: never fails this activity.
|
|
198
|
+
ringDoorbell(doorbells, ensemble, targetPlayerId);
|
|
177
199
|
return { success: true };
|
|
178
200
|
}
|
|
179
201
|
catch (err) {
|
|
@@ -305,12 +327,19 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
305
327
|
taskQueue,
|
|
306
328
|
args: [sessionInput],
|
|
307
329
|
workflowIdConflictPolicy: client_1.WorkflowIdConflictPolicy.USE_EXISTING,
|
|
330
|
+
// T0.5 (#747) — read-only fields ride the MEMO, not search
|
|
331
|
+
// attributes (fresh namespaces register only the 5 filter SAs).
|
|
308
332
|
searchAttributes: {
|
|
309
|
-
...(gitRoot ? { AgentTempoGitRoot: [gitRoot] } : {}),
|
|
310
333
|
AgentTempoHostname: [os.hostname()],
|
|
311
334
|
AgentTempoEnsemble: [ensemble],
|
|
312
335
|
AgentTempoPlayerId: [targetName],
|
|
313
336
|
},
|
|
337
|
+
memo: {
|
|
338
|
+
...(gitRoot ? { [search_attributes_1.MEMO_KEYS.gitRoot]: gitRoot } : {}),
|
|
339
|
+
...(agentDefinition ? { [search_attributes_1.MEMO_KEYS.playerType]: agentDefinition } : {}),
|
|
340
|
+
[search_attributes_1.MEMO_KEYS.isConductor]: isConductor,
|
|
341
|
+
[search_attributes_1.MEMO_KEYS.part]: sessionInput.autoSummary,
|
|
342
|
+
},
|
|
314
343
|
});
|
|
315
344
|
log(`Pre-created workflow ${workflowId} for recruit "${targetName}" (sessionId=${sessionId}, held=${!!held})`);
|
|
316
345
|
return { success: true, sessionId };
|
|
@@ -357,6 +386,20 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
357
386
|
}
|
|
358
387
|
}
|
|
359
388
|
try {
|
|
389
|
+
// T1.1 PR-1 — mint a per-player ingest token for every SDK-family
|
|
390
|
+
// spawn (was Pi-only since 3c Tier-2). The token authenticates the
|
|
391
|
+
// adapter's loopback HTTP calls: `POST /inner/ingest` (Pi fine-tail)
|
|
392
|
+
// and `GET /doorbell/:e/:p` (PR-2's DoorbellClient, all SDK
|
|
393
|
+
// adapters). Single-token-per-workflowId (mint REPLACES) means a
|
|
394
|
+
// restart re-mints and naturally revokes the stale token. Injected
|
|
395
|
+
// into the subprocess env as AGENT_TEMPO_INGEST_TOKEN. Interactive
|
|
396
|
+
// terminal spawns are deliberately excluded — no doorbell client
|
|
397
|
+
// exists for them (PR-2's consumers are SdkAttachment + the Pi
|
|
398
|
+
// runtime); minting extends trivially if that ever changes.
|
|
399
|
+
const ingestToken = agent === 'mock' || agent === 'copilot' || agent === 'claude-api' ||
|
|
400
|
+
agent === 'opencode' || agent === 'claude-code-headless' || agent === 'pi'
|
|
401
|
+
? ingestTokens?.mint((0, config_1.sessionWorkflowId)(ensemble, targetName))
|
|
402
|
+
: undefined;
|
|
360
403
|
if (agent === 'mock') {
|
|
361
404
|
// ADR 0014 PR-2 — mock adapter spawns headless. No terminal,
|
|
362
405
|
// no Claude binary, no MCP server child. Talks to Temporal
|
|
@@ -377,6 +420,7 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
377
420
|
attachmentId,
|
|
378
421
|
attachmentRunId,
|
|
379
422
|
adapterId,
|
|
423
|
+
ingestToken,
|
|
380
424
|
});
|
|
381
425
|
log(`Spawned mock adapter (pid ${pid}) in ${workDir} as "${targetName}" (mode=${mockMode ?? 'echo'}${attachmentId ? `, attachmentId=${attachmentId}` : ''})`);
|
|
382
426
|
}
|
|
@@ -398,6 +442,7 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
398
442
|
attachmentId,
|
|
399
443
|
attachmentRunId,
|
|
400
444
|
adapterId,
|
|
445
|
+
ingestToken,
|
|
401
446
|
});
|
|
402
447
|
log(`Spawned copilot-bridge (pid ${pid}) in ${workDir} as "${targetName}"${attachmentId ? ` (attachmentId=${attachmentId})` : ''}`);
|
|
403
448
|
}
|
|
@@ -424,6 +469,7 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
424
469
|
attachmentId,
|
|
425
470
|
attachmentRunId,
|
|
426
471
|
adapterId,
|
|
472
|
+
ingestToken,
|
|
427
473
|
});
|
|
428
474
|
log(`Spawned claude-api adapter (pid ${pid}) in ${workDir} as "${targetName}"${model ? ` (model=${model})` : ''}${attachmentId ? ` (attachmentId=${attachmentId})` : ''}`);
|
|
429
475
|
}
|
|
@@ -452,6 +498,7 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
452
498
|
attachmentId,
|
|
453
499
|
attachmentRunId,
|
|
454
500
|
adapterId,
|
|
501
|
+
ingestToken,
|
|
455
502
|
});
|
|
456
503
|
log(`Spawned opencode adapter (pid ${pid}) in ${workDir} as "${targetName}"${model ? ` (model=${model})` : ''}${attachmentId ? ` (attachmentId=${attachmentId})` : ''}`);
|
|
457
504
|
}
|
|
@@ -481,6 +528,7 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
481
528
|
attachmentId,
|
|
482
529
|
attachmentRunId,
|
|
483
530
|
adapterId,
|
|
531
|
+
ingestToken,
|
|
484
532
|
});
|
|
485
533
|
log(`Spawned claude-code-headless adapter (pid ${pid}) in ${workDir} as "${targetName}"${permissionMode ? ` (permissionMode=${permissionMode})` : ''}${dangerouslySkipPermissions ? ' (dangerouslySkipPermissions=true)' : ''}${attachmentId ? ` (attachmentId=${attachmentId})` : ''}`);
|
|
486
534
|
}
|
|
@@ -492,12 +540,6 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
492
540
|
if (allowedTools && allowedTools.length > 0) {
|
|
493
541
|
log(`Warning: allowedTools [${allowedTools.join(', ')}] specified for pi agent "${targetName}" — Pi players run the full tool surface, skipping allowedTools`);
|
|
494
542
|
}
|
|
495
|
-
// 3c Tier-2 — mint a per-player ingest token scoped to this player's
|
|
496
|
-
// session workflowId so the headless Pi subprocess can authenticate its
|
|
497
|
-
// `POST /inner/ingest` frames. Single-token-per-workflowId (mint
|
|
498
|
-
// REPLACES) means a restart re-mints and naturally revokes the stale
|
|
499
|
-
// token. Injected into the subprocess env as AGENT_TEMPO_INGEST_TOKEN.
|
|
500
|
-
const ingestToken = ingestTokens?.mint((0, config_1.sessionWorkflowId)(ensemble, targetName));
|
|
501
543
|
const { pid } = (0, spawn_1.spawnPiHeadless)({
|
|
502
544
|
name: targetName,
|
|
503
545
|
ensemble,
|
|
@@ -680,6 +722,12 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
680
722
|
// revokeIngestToken(workflowId) on detach — deferred; residual surface
|
|
681
723
|
// negligible (dead holder + loopback-only + single-token replacement).
|
|
682
724
|
ingestTokens?.revoke((0, config_1.sessionWorkflowId)(ensemble, targetPlayerId));
|
|
725
|
+
// T1.1 — end the player's doorbell streams too (the registry-side
|
|
726
|
+
// lifecycle mirror of the token revoke; swallow-everything wrapper).
|
|
727
|
+
try {
|
|
728
|
+
doorbells?.current?.closePlayer(ensemble, targetPlayerId);
|
|
729
|
+
}
|
|
730
|
+
catch { /* never propagate */ }
|
|
683
731
|
if (notifyConductor) {
|
|
684
732
|
try {
|
|
685
733
|
const condId = (0, config_1.conductorWorkflowId)(ensemble);
|
|
@@ -722,6 +770,9 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
722
770
|
...(reason !== undefined ? { reason } : {}),
|
|
723
771
|
...(requestedBy !== undefined ? { requestedBy } : {}),
|
|
724
772
|
});
|
|
773
|
+
// T1.1 — ring so a stretched pump's next tickReset looks at
|
|
774
|
+
// ding-latency, not its ceiling. D14 semantics untouched (§2.1).
|
|
775
|
+
ringDoorbell(doorbells, ensemble, targetPlayerId);
|
|
725
776
|
log(`Reset queued for "${targetPlayerId}"${reason ? ` (reason: ${reason})` : ''}`);
|
|
726
777
|
return { success: true };
|
|
727
778
|
}
|
|
@@ -971,5 +1022,5 @@ function createOutboxActivities(client, config, ingestTokens) {
|
|
|
971
1022
|
async hardTerminateAttachment(input) {
|
|
972
1023
|
return (0, hard_terminate_1.hardTerminateAttachment)(input);
|
|
973
1024
|
},
|
|
974
|
-
};
|
|
1025
|
+
});
|
|
975
1026
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Client, WorkflowHandle } from '@temporalio/client';
|
|
2
2
|
import { AttachmentPhase } from '../types';
|
|
3
|
+
/** Shared query for listing running session workflows. Exported for the
|
|
4
|
+
* ensemble-scoped variants in `client/core.ts` (#751). */
|
|
5
|
+
export declare const SESSION_LIST_QUERY = "WorkflowType = \"agentSessionWorkflow\" AND ExecutionStatus = \"Running\"";
|
|
3
6
|
/**
|
|
4
7
|
* Resolve a session by player name.
|
|
5
8
|
* Lists all running session workflows and queries each for metadata.
|
|
@@ -8,6 +11,13 @@ import { AttachmentPhase } from '../types';
|
|
|
8
11
|
*
|
|
9
12
|
* Shared by activity files (outbox, schedule-fire) and the tools layer.
|
|
10
13
|
*
|
|
14
|
+
* DECISION-PATH FENCE (#748): this resolver feeds DECISION paths (outbox
|
|
15
|
+
* delivery addressing, schedule fires, tool targets). It must keep its
|
|
16
|
+
* direct per-session `getMetadata` queries — do NOT migrate it to the
|
|
17
|
+
* eventually-consistent SA/memo read path. Observation-only scans belong
|
|
18
|
+
* in `scanEnsembleSessionsCloud`. Enforced by
|
|
19
|
+
* tests/conformance/decision-path-fence.test.ts.
|
|
20
|
+
*
|
|
11
21
|
* **Deadline (#336/#529):** the visibility iterator is bounded by
|
|
12
22
|
* `VISIBILITY_DEADLINES_MS.resolveSession` (default 10s). On timeout,
|
|
13
23
|
* throws `VisibilityIteratorTimeoutError` rather than returning `null`
|
|
@@ -49,6 +59,28 @@ export interface EnsembleSessionInfo {
|
|
|
49
59
|
*/
|
|
50
60
|
lastActivityAt?: string;
|
|
51
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* T0.1 (#748) — cloud-profile ensemble scan. Observation path ONLY (see the
|
|
64
|
+
* DECISION-PATH FENCE on {@link resolveSession}).
|
|
65
|
+
*
|
|
66
|
+
* Differences vs the legacy {@link scanEnsembleSessions}:
|
|
67
|
+
* - The visibility query is **ensemble-scoped** via the `AgentTempoEnsemble`
|
|
68
|
+
* filter SA — no more cluster-wide list + per-session `getMetadata`
|
|
69
|
+
* pre-filtering (the unfiltered scan was the dominant idle-burn driver).
|
|
70
|
+
* - For v1.8+ runs (memo-complete: `AgentTempoWorkDir` present), the entire
|
|
71
|
+
* player row is read from the list result (SAs + memo) — **zero**
|
|
72
|
+
* per-player queries except the BPM `getActivityState` query, which is
|
|
73
|
+
* intentionally kept per the architect's ruling (deriving BPM from phase
|
|
74
|
+
* transitions would change the metric's meaning).
|
|
75
|
+
* - Pre-v1.8 runs (no observation memo) fall back to the legacy per-player
|
|
76
|
+
* `getMetadata` + `getPart` queries — cost shrinks as old runs cycle out.
|
|
77
|
+
*
|
|
78
|
+
* Staleness: SA/memo reads are eventually consistent (tens of seconds worst
|
|
79
|
+
* case under backlog) — acceptable for the observation path per the design
|
|
80
|
+
* addendum §B; the aggregate's confirm-on-change hook re-validates phase
|
|
81
|
+
* transitions with a direct query before emitting SSE events.
|
|
82
|
+
*/
|
|
83
|
+
export declare function scanEnsembleSessionsCloud(client: Client, ensemble: string, log?: (...args: unknown[]) => void): Promise<EnsembleSessionInfo[]>;
|
|
52
84
|
/**
|
|
53
85
|
* Scan all running session workflows in an ensemble.
|
|
54
86
|
* Returns metadata + part for each session. Shared by the ensemble MCP tool
|
|
@@ -60,5 +92,9 @@ export interface EnsembleSessionInfo {
|
|
|
60
92
|
* warn log. This site is **partial-tolerant by design** — the caller
|
|
61
93
|
* (maestro refresh, ensemble MCP tool) treats the result as a
|
|
62
94
|
* best-effort snapshot that the next tick / re-invocation will fill in.
|
|
95
|
+
*
|
|
96
|
+
* T0.1 (#748): this legacy shape is the `costProfile: 'local'` path —
|
|
97
|
+
* byte-identical to pre-#748 behavior. The cloud profile uses
|
|
98
|
+
* {@link scanEnsembleSessionsCloud}.
|
|
63
99
|
*/
|
|
64
100
|
export declare function scanEnsembleSessions(client: Client, ensemble: string, log?: (...args: unknown[]) => void): Promise<EnsembleSessionInfo[]>;
|