@agentproto/runtime 2.5.0 → 2.7.0

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/dist/index.d.ts CHANGED
@@ -6,20 +6,22 @@ import { AcpMcpServer, AcpPermissionResolution } from '@agentproto/acp';
6
6
  import { SessionMode } from '@agentproto/acp/client';
7
7
  export { SessionMode } from '@agentproto/acp/client';
8
8
  import { ChildProcess } from 'node:child_process';
9
- import { R as RouteSpec, S as SessionConfig, P as Posture, C as ContextProfile, E as EffortLevel, A as AuthMethod, a as CanonicalPosture } from './session-config-DIf6wYYP.js';
10
- export { D as DeclaredAdapterMode, c as composeMode, d as decomposeMode } from './session-config-DIf6wYYP.js';
9
+ import { R as RouteSpec, S as SessionConfig, P as Posture, C as ContextProfile, E as EffortLevel, A as AuthMethod, a as CanonicalPosture } from './session-config-DbWP9RRj.js';
10
+ export { D as DeclaredAdapterMode, c as composeMode, d as decomposeMode } from './session-config-DbWP9RRj.js';
11
11
  import { CostBudget, AuthProfile, CostBudgetScope } from '@agentproto/auth';
12
12
  export { CostBudget, CostBudgetScope } from '@agentproto/auth';
13
- import { R as ResolvedContextContinuityPolicy } from './context-continuity-B9n0t0v-.js';
13
+ import { R as ResolvedContextContinuityPolicy } from './context-continuity-ib9_bVYM.js';
14
14
  import { SandboxMode } from '@agentproto/command-sandbox';
15
15
  import { AdapterHandle, SetupField, AdapterResolver, AdapterLister, HarnessCapabilities, AdapterEntry } from '@agentproto/provider-kit';
16
- import { R as ResolvedAuthSpec, D as DeclaredAdapterOption, A as AdapterAuthDescriptor } from './spawn-defaults-7uHRnYH1.js';
17
- export { a as AuthEcho, b as AuthResolutionError, C as CLAUDE_CODE_OAUTH_SOURCE, c as CredentialSource, d as DefaultsAdapterAuthConfig, e as DefaultsAdapterConfig, f as ResolveSubscriptionCredentialInput, g as ResolvedSpawnAuthMaterial, h as ResolvedSpawnDefaults, S as SpawnDefaultsConfig, i as SubscriptionCredentialResolution, j as SubscriptionSourceError, k as credentialFingerprint, n as normalizeSkillsOption, r as resolveAuthSpec, l as resolveSpawnDefaults, m as resolveSubscriptionCredential } from './spawn-defaults-7uHRnYH1.js';
16
+ import { R as ResolvedAuthSpec, D as DeclaredAdapterOption, A as AdapterAuthDescriptor } from './spawn-defaults-DVgmfxWo.js';
17
+ export { a as AuthEcho, b as AuthResolutionError, C as CLAUDE_CODE_OAUTH_SOURCE, c as CredentialSource, d as DefaultsAdapterAuthConfig, e as DefaultsAdapterConfig, f as ResolveSubscriptionCredentialInput, g as ResolvedSpawnAuthMaterial, h as ResolvedSpawnDefaults, S as SpawnDefaultsConfig, i as SubscriptionCredentialResolution, j as SubscriptionSourceError, k as credentialFingerprint, n as normalizeSkillsOption, r as resolveAuthSpec, l as resolveSpawnDefaults, m as resolveSubscriptionCredential } from './spawn-defaults-DVgmfxWo.js';
18
18
  import { CatalogModelsQuery, CatalogModelsResponse } from './catalog-models.js';
19
19
  export { CatalogAdapterInput, CatalogAdapterModelInput, CatalogPricing, CatalogProduct, CatalogRoute, CatalogRouteSummary, CatalogVendor, buildCatalogModels } from './catalog-models.js';
20
20
  import { FooterSession } from './pr-provenance.js';
21
21
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
22
22
  import { SandboxProvider } from '@agentproto/sandbox';
23
+ import { BrainManager, ExportedSessionLike } from '@agentproto/workspace-brain';
24
+ export { BrainManager, BrainStats, IngestReport, IngestResult } from '@agentproto/workspace-brain';
23
25
  export { UserPreset, UserPresetsFile, deleteUserPreset, getUserPreset, listUserPresets, loadUserPresets, saveUserPreset, userPresetsPath } from './user-presets.js';
24
26
  import { ResolvedModel } from '@agentproto/model-catalog';
25
27
  import { FrameSink, E2eFrameSink } from '@agentproto/acp/tunnel';
@@ -1659,7 +1661,7 @@ declare function createTaskLedger(opts: {
1659
1661
  * and session_monitor MCP tool (long-poll multiplexed).
1660
1662
  */
1661
1663
 
1662
- type SessionEventType = "session:turn-end" | "session:awaiting-input" | "session:permission-request" | "session:permission-resolved" | "session:exited" | "session:reaped" | "session:stalled" | "session:stall-cleared" | "session:resumed" | "session:spawned" | "session:command-done" | "session:model-changed" | "session:config-changed" | "session:renamed" | "policy:passed" | "policy:failed" | "policy:commit-ready" | "policy:committed" | "cron:fired" | "cron:succeeded" | "cron:failed" | "activity:changed" | "task:changed";
1664
+ type SessionEventType = "session:turn-end" | "session:awaiting-input" | "session:awaiting-input-flagged" | "session:permission-request" | "session:permission-resolved" | "session:exited" | "session:reaped" | "session:stalled" | "session:stall-cleared" | "session:watcher-attached" | "session:watcher-detached" | "session:bg-tasks-parked" | "session:bg-tasks-cleared" | "session:resumed" | "session:spawned" | "session:command-done" | "session:model-changed" | "session:config-changed" | "session:renamed" | "session:pinned-changed" | "policy:passed" | "policy:failed" | "policy:commit-ready" | "policy:committed" | "cron:fired" | "cron:succeeded" | "cron:failed" | "activity:changed" | "task:changed";
1663
1665
  /**
1664
1666
  * Fixed severity vocabulary for a judge-gate finding (WP-D). Deliberately
1665
1667
  * small and fixed so `policy_status` output is comparable across different
@@ -1741,6 +1743,39 @@ interface SessionAwaitingInputEvent {
1741
1743
  ts: string;
1742
1744
  question?: SessionAwaitingQuestion;
1743
1745
  }
1746
+ /**
1747
+ * Emitted by `SessionsRegistry.flagAwaitingInput` (the `session_flag_status`
1748
+ * MCP verb) when something EXTERNAL — a human, another agent, the future
1749
+ * session watchdog — manually corrects a session's `awaitingInput`/
1750
+ * `awaitingQuestion` classification, overriding (or confirming) what the
1751
+ * internal heuristic (`deriveHeuristicQuestion`) or a driver-reported
1752
+ * `agent-prompt` last set. Distinct from `session:awaiting-input` (which only
1753
+ * ever fires when the flag flips TRUE, from the daemon's own turn-end
1754
+ * detection): this fires for BOTH directions of a manual override, always
1755
+ * carries the mandatory `reason` the caller gave (audit trail — this is the
1756
+ * one write path for this field with no automatic sensor behind it), and
1757
+ * `awaitingInput` states the value the override just set rather than being
1758
+ * implied by the event firing at all. Same bus distribution as every other
1759
+ * lifecycle event (`session_events_poll`, the webhook notifier, the routine
1760
+ * engine, `session_monitor`).
1761
+ */
1762
+ interface SessionAwaitingInputFlaggedEvent {
1763
+ type: "session:awaiting-input-flagged";
1764
+ sessionId: string;
1765
+ awaitingInput: boolean;
1766
+ /** Required justification the caller passed to `session_flag_status` —
1767
+ * why this override was made. */
1768
+ reason: string;
1769
+ label?: string;
1770
+ ts: string;
1771
+ /** Present only when `awaitingInput:true` and a `question` was attached —
1772
+ * mirrors the descriptor's `awaitingQuestion` after the override, same
1773
+ * shape as every other site that sets it (`source: "structured"`, since a
1774
+ * manual override is at least as authoritative as a driver-reported
1775
+ * prompt). Absent when `awaitingInput:false` (the override always clears
1776
+ * any prior question in that case) or when no `question` was given. */
1777
+ question?: SessionAwaitingQuestion;
1778
+ }
1744
1779
  /**
1745
1780
  * Emitted when a permission-hold session parks a `session/request_permission`
1746
1781
  * (see the pending-permissions inbox in sessions.ts). `permissionId` is the
@@ -1847,6 +1882,94 @@ interface SessionStallClearedEvent {
1847
1882
  label?: string;
1848
1883
  ts: string;
1849
1884
  }
1885
+ /**
1886
+ * Emitted by the wait long-poll helper (`monitorSessionWait`) the moment a
1887
+ * blocking wait actually SUBSCRIBES to this session — a `/sessions/:id/wait`
1888
+ * long-poll or a `session_monitor` call that has to park. This is the bus
1889
+ * twin of the ephemeral `watchers` descriptor counter (`incWatchers`,
1890
+ * #session-visibility): where the counter lets `session_list` surface "N
1891
+ * supervisors are blocked on this session", the event lets a LIVE consumer
1892
+ * (the transcript panel inside the WATCHED session) react the instant a
1893
+ * watcher appears rather than on its next descriptor poll. Detection +
1894
+ * signal ONLY — nothing here changes the wait's own semantics. `watchers`
1895
+ * is the counter AFTER the attach (read back from the registry, so a
1896
+ * concurrent waiter is already reflected). `watcherSessionId` names the
1897
+ * supervising session when the wait was initiated by one (the scoped
1898
+ * orchestrator's `callerScope.ownerSessionId`); `label` is that session's
1899
+ * label/title, resolved once at attach time (a best-effort snapshot, not
1900
+ * live). Both absent for an anonymous CLI/HTTP waiter. Same bus distribution
1901
+ * as every other lifecycle event (`session_events_poll`, the webhook
1902
+ * notifier, the routine engine, `session_monitor`). Paired with
1903
+ * `session:watcher-detached` when the wait resolves or times out.
1904
+ */
1905
+ interface SessionWatcherAttachedEvent {
1906
+ type: "session:watcher-attached";
1907
+ sessionId: string;
1908
+ watchers: number;
1909
+ watcherSessionId?: string;
1910
+ label?: string;
1911
+ ts: string;
1912
+ }
1913
+ /**
1914
+ * Emitted when a blocking wait on this session releases its watcher — the
1915
+ * wait resolved (a matching lifecycle event landed) or timed out; see
1916
+ * {@link SessionWatcherAttachedEvent}. `watchers` is the counter AFTER the
1917
+ * detach, so a consumer can tell "the last watcher left" (`0`) from "one of
1918
+ * several left". Detection + signal only — a zero count does NOT imply the
1919
+ * session is unsupervised in every sense (a completion policy watches via
1920
+ * its own mechanism, not this counter); it only means no `monitorSessionWait`
1921
+ * long-poll is currently parked on it. Same bus distribution as every other
1922
+ * lifecycle event.
1923
+ */
1924
+ interface SessionWatcherDetachedEvent {
1925
+ type: "session:watcher-detached";
1926
+ sessionId: string;
1927
+ watchers: number;
1928
+ watcherSessionId?: string;
1929
+ label?: string;
1930
+ ts: string;
1931
+ }
1932
+ /**
1933
+ * Emitted at turn-end when the turn that just finished started one or more
1934
+ * BACKGROUND tool calls (a tool-call whose `arguments` object carries
1935
+ * `run_in_background: true` — how Claude Code's Bash announces a
1936
+ * `run_in_background` task; matched generically on the property, not the
1937
+ * tool name) AND the session is NOT `awaitingInput`. The target failure
1938
+ * mode is the turn-END twin of `session:stalled`: the harness's own
1939
+ * task-completion notification does NOT trigger a new turn, so the session
1940
+ * sits `busy:false`, `awaitingInput:false`, background tasks pending — a
1941
+ * silent dead end that looks exactly like a session idle and waiting to be
1942
+ * re-prompted. Detection + signal ONLY: nothing here re-prompts or wakes
1943
+ * the session (no auto-wake — a wake-up path would have to decide what to
1944
+ * say, and that policy belongs to the supervisor, not the daemon). `count`
1945
+ * is how many background tool starts the turn observed. Same bus
1946
+ * distribution as every other lifecycle event (`session_events_poll`, the
1947
+ * webhook notifier, the routine engine, `session_monitor`). Paired with
1948
+ * `session:bg-tasks-cleared` when the flag is later cleared.
1949
+ */
1950
+ interface SessionBgTasksParkedEvent {
1951
+ type: "session:bg-tasks-parked";
1952
+ sessionId: string;
1953
+ count: number;
1954
+ label?: string;
1955
+ ts: string;
1956
+ }
1957
+ /**
1958
+ * Emitted when a session's `pendingBgTasks` flag (see {@link
1959
+ * SessionBgTasksParkedEvent}) is cleared — by the next turn starting (the
1960
+ * session was re-prompted, so it is no longer parked: its new turn will see
1961
+ * whatever the background tasks produced) or by the session exiting (a dead
1962
+ * row carries no live flag). Does NOT imply the background tasks finished
1963
+ * or their output was consumed — only that the "ended its turn with
1964
+ * background work pending and no wake-up path" condition no longer holds.
1965
+ * Same bus distribution as every other lifecycle event.
1966
+ */
1967
+ interface SessionBgTasksClearedEvent {
1968
+ type: "session:bg-tasks-cleared";
1969
+ sessionId: string;
1970
+ label?: string;
1971
+ ts: string;
1972
+ }
1850
1973
  /**
1851
1974
  * Emitted when a dead agent-cli row is brought back IN PLACE — same session
1852
1975
  * id, same descriptor — by the lazy resume-on-prompt path (`maybeResumeAgent`)
@@ -1975,6 +2098,24 @@ interface SessionRenamedEvent {
1975
2098
  renamedByUser?: boolean;
1976
2099
  ts: string;
1977
2100
  }
2101
+ /**
2102
+ * Emitted when an operator pins or unpins a session for list visibility
2103
+ * (`POST /sessions/:id/pin`, the `session_set_pinned` MCP verb). Like
2104
+ * `session:renamed`, this is NOT a `SessionConfig` axis — pinning never
2105
+ * touches the live agent, the idle-reaper, or any notification path, it's
2106
+ * purely a `SessionDescriptor.pinned` display/sort flag — so it rides its
2107
+ * own event rather than `session:config-changed`. `pinned` carries the value
2108
+ * now on the descriptor. Same bus distribution as every other lifecycle event
2109
+ * (`session_events_poll`, the webhook notifier, the routine engine), which is
2110
+ * how a live UI (the VS Code sessions webview) learns to resort its list
2111
+ * without waiting for its next snapshot poll.
2112
+ */
2113
+ interface SessionPinnedEvent {
2114
+ type: "session:pinned-changed";
2115
+ sessionId: string;
2116
+ pinned: boolean;
2117
+ ts: string;
2118
+ }
1978
2119
  /**
1979
2120
  * Emitted when a session is first registered in the registry (WP-R3) — both
1980
2121
  * the agent-cli spawn path (`spawnAgent`) and the terminal path (`spawnPty`).
@@ -2097,7 +2238,7 @@ interface TaskChangedEvent {
2097
2238
  sessionId?: string;
2098
2239
  ts: string;
2099
2240
  }
2100
- type SessionEvent = SessionTurnEndEvent | SessionAwaitingInputEvent | SessionPermissionRequestEvent | SessionPermissionResolvedEvent | SessionExitedEvent | SessionReapedEvent | SessionStalledEvent | SessionStallClearedEvent | SessionResumedEvent | SessionSpawnedEvent | SessionCommandDoneEvent | SessionModelChangedEvent | SessionConfigChangedEvent | SessionRenamedEvent | PolicyPassedEvent | PolicyFailedEvent | PolicyCommitReadyEvent | PolicyCommittedEvent | CronFiredEvent | CronSucceededEvent | CronFailedEvent | ActivityChangedEvent | TaskChangedEvent;
2241
+ type SessionEvent = SessionTurnEndEvent | SessionAwaitingInputEvent | SessionAwaitingInputFlaggedEvent | SessionPermissionRequestEvent | SessionPermissionResolvedEvent | SessionExitedEvent | SessionReapedEvent | SessionStalledEvent | SessionStallClearedEvent | SessionWatcherAttachedEvent | SessionWatcherDetachedEvent | SessionBgTasksParkedEvent | SessionBgTasksClearedEvent | SessionResumedEvent | SessionSpawnedEvent | SessionCommandDoneEvent | SessionModelChangedEvent | SessionConfigChangedEvent | SessionRenamedEvent | SessionPinnedEvent | PolicyPassedEvent | PolicyFailedEvent | PolicyCommitReadyEvent | PolicyCommittedEvent | CronFiredEvent | CronSucceededEvent | CronFailedEvent | ActivityChangedEvent | TaskChangedEvent;
2101
2242
  interface SessionEventBus {
2102
2243
  emit(ev: SessionEvent): void;
2103
2244
  /** Subscribe to a specific event type. Returns an unsubscribe fn. */
@@ -3524,6 +3665,14 @@ type AgentAdapterResolver = (slug: string) => Promise<{
3524
3665
  startSession(opts: {
3525
3666
  cwd: string;
3526
3667
  resumeSessionId?: string;
3668
+ /** Persistent isolated-config location for the adapter (claude-code's
3669
+ * `CLAUDE_CONFIG_DIR`) — forwarded to the driver's
3670
+ * `start({ configDir })`. The daemon keys it per session lineage
3671
+ * (`SessionDescriptor.adapterConfigDir`) so the provider's own
3672
+ * conversation store survives adapter respawns and `resumeSessionId`
3673
+ * can restore full context instead of falling back to a digest.
3674
+ * Adapters that don't isolate a config dir ignore it. */
3675
+ configDir?: string;
3527
3676
  /**
3528
3677
  * Manifest-declared mode id forwarded from `agent_start` (AIP-45
3529
3678
  * `AgentCliHandle.modes` — e.g. claude-code's `plan` /
@@ -3748,7 +3897,7 @@ type AdapterCapabilitiesLister = (opts?: {
3748
3897
  interface AdapterInstallResult {
3749
3898
  slug: string;
3750
3899
  ok: boolean;
3751
- method: "npm-global" | "agentproto-install" | "already-installed" | "unsupported";
3900
+ method: "npm-global" | "shell-hint" | "agentproto-install" | "already-installed" | "unsupported";
3752
3901
  /** Human-readable one-liner: what ran, and how it ended. */
3753
3902
  message: string;
3754
3903
  /** The shell command that was run, for surfacing in logs / errors.
@@ -3760,6 +3909,12 @@ interface AdapterInstallResult {
3760
3909
  * post-install re-list failed (the install itself may still have
3761
3910
  * succeeded — read `ok`). */
3762
3911
  status?: "supported" | "available" | "ready" | "unresolvable";
3912
+ /** True when the install failed ONLY because a manifest setup step
3913
+ * declares `interactive: true` and this process has no TTY to run it
3914
+ * in (e.g. openclaw's `onboard --install-daemon` TUI). The remedy is a
3915
+ * real terminal — `agentproto setup <slug>` — which a UI can offer
3916
+ * directly as a PTY terminal session. */
3917
+ needsInteractiveSetup?: boolean;
3763
3918
  }
3764
3919
  /**
3765
3920
  * Installs an agent CLI adapter by slug and reports the outcome. Wired by
@@ -4022,6 +4177,8 @@ interface AgentStreamEvent {
4022
4177
  * @agentproto/acp's `StreamEvent`'s `agent-prompt` kind. Harness-shaped
4023
4178
  * and untyped; don't assume a stable schema across adapters. */
4024
4179
  rawInput?: unknown;
4180
+ /** "plan" event title — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
4181
+ title?: string;
4025
4182
  /** "plan" event entries — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
4026
4183
  entries?: Array<{
4027
4184
  content: string;
@@ -4089,6 +4246,7 @@ declare const SESSION_ID_ENV = "AGENTPROTO_SESSION_ID";
4089
4246
  declare const WORKSPACE_SLUG_ENV = "AGENTPROTO_WORKSPACE_SLUG";
4090
4247
  type SessionKind = "terminal" | "agent-cli" | "command" | "browser";
4091
4248
  type SessionStatus = "starting" | "running" | "exited" | "killed" | "error";
4249
+ type SessionCurrentPhase = "thinking" | `tool-call:${string}` | "awaiting-input" | "awaiting-permission" | "idle" | "completed" | "killed";
4092
4250
  /**
4093
4251
  * The billing-auth resolver's OBSERVABLE echo, recorded on a session
4094
4252
  * descriptor. `mode` + `fingerprint` are always present when recorded (a
@@ -4122,6 +4280,48 @@ interface SessionAccessProfileEcho {
4122
4280
  endpoint: string;
4123
4281
  method: AuthMethod;
4124
4282
  }
4283
+ /**
4284
+ * One live waiter behind a session's {@link SessionDescriptor.watchers} count
4285
+ * (#session-visibility). Captured at `monitorSessionWait` attach time and held
4286
+ * only for the life of that wait — never persisted, never updated in place
4287
+ * (a snapshot of the waiter's label at attach time, not a live mirror of it).
4288
+ */
4289
+ interface SessionWatcherInfo {
4290
+ /** The waiting session's id, when this wait was initiated by an agent
4291
+ * session via the orchestrator scope (`callerScope.ownerSessionId`).
4292
+ * Absent for an anonymous CLI/HTTP waiter — it still counts toward
4293
+ * `watchers`, it just can't be named. */
4294
+ watcherSessionId?: string;
4295
+ /** Best-effort label/title for `watcherSessionId`, resolved once at attach
4296
+ * time. A later rename of the watching session is not reflected. */
4297
+ watcherLabel?: string;
4298
+ /** What this wait is blocking on — mirrors `session_monitor`'s `event`
4299
+ * parameter (`SessionWaitEvent` in orchestration-tools.ts; kept as a plain
4300
+ * string here so the registry doesn't depend on the tool-layer type). */
4301
+ event: string;
4302
+ /** The wait's configured timeout, ms — absent for the MCP tool's default. */
4303
+ timeoutMs?: number;
4304
+ /** ISO 8601 timestamp this waiter attached. */
4305
+ since: string;
4306
+ }
4307
+ /** One prompt waiting in `SessionDescriptor.promptQueue` — see that
4308
+ * field's doc for the FIFO/force ordering contract. */
4309
+ interface QueuedPrompt {
4310
+ /** Stable id, assigned at queue time (by the HTTP layer for
4311
+ * `POST /sessions/:id/prompt`'s `queue` arm so the caller can echo it
4312
+ * straight back in the response, or minted here for any other
4313
+ * caller). Used by `removeQueuedPrompt` to cancel this one item
4314
+ * before it dispatches. */
4315
+ id: string;
4316
+ /** Same shape `runAgentTurn`'s `message` parameter accepts — a raw
4317
+ * string or an ACP content block/array. */
4318
+ message: unknown;
4319
+ /** ISO 8601 timestamp this item was queued. */
4320
+ queuedAt: string;
4321
+ /** Same as `enqueuePrompt`'s `opts.source` — carried through to the
4322
+ * turn this item eventually becomes. */
4323
+ source?: string;
4324
+ }
4125
4325
  interface SessionDescriptor {
4126
4326
  id: string;
4127
4327
  kind: SessionKind;
@@ -4184,6 +4384,18 @@ interface SessionDescriptor {
4184
4384
  * `lastOutputAt` goes stale. Updated on incoming session/update
4185
4385
  * notifications AND on outbound RPC calls. ISO 8601. */
4186
4386
  lastActivityAt?: string;
4387
+ /** Read-time projection of what the session is doing now. Tool-call phases
4388
+ * carry the adapter-reported tool name (for example
4389
+ * `tool-call:file_read`). Ephemeral: recomputed by list()/get() and never
4390
+ * persisted. */
4391
+ currentPhase?: SessionCurrentPhase;
4392
+ /** Whole seconds since `lastActivityAt`, computed at read time. Absent until
4393
+ * the adapter has reported activity; never persisted. */
4394
+ secondsSinceLastActivity?: number;
4395
+ /** Number of distinct tool calls observed in the current (or most recently
4396
+ * completed) turn. Reset when the next turn starts. Tool-call enrichment
4397
+ * events sharing an id count only once. Ephemeral and never persisted. */
4398
+ toolCallsThisTurn?: number;
4187
4399
  /** Whether the underlying OS process is still alive. Computed via
4188
4400
  * `process.kill(pid, 0)` at read time (list()/get()) — cheap,
4189
4401
  * zero-overhead, standard POSIX check. Absent when `pid` is null
@@ -4199,6 +4411,15 @@ interface SessionDescriptor {
4199
4411
  * daemon restart). 0/absent ⇒ nothing is watching. Lets a UI mark a
4200
4412
  * session "supervised — notify on turn-end". */
4201
4413
  watchers?: number;
4414
+ /** Per-waiter detail behind the {@link watchers} count — who is blocked on
4415
+ * this session and what they're blocked on. Same lifetime/source as
4416
+ * `watchers` (stamped at read time from the registry's live waiter list,
4417
+ * never persisted); empty/absent ⇒ nothing is watching. An anonymous
4418
+ * CLI/HTTP waiter (no `callerScope`) carries no `watcherSessionId` — it
4419
+ * still counts, it just can't be named. Lets a UI answer "who is watching
4420
+ * this, and what are they waiting for" without guessing from the bare
4421
+ * count. */
4422
+ watcherDetails?: readonly SessionWatcherInfo[];
4202
4423
  /** Count of DESCENDANT sessions (children, grandchildren, …) currently
4203
4424
  * mid-turn, derived at read time from the `parentSessionId` lineage
4204
4425
  * (#session-visibility, subtree rollup). Lets a UI show an idle parent that
@@ -4234,6 +4455,38 @@ interface SessionDescriptor {
4234
4455
  * stalled. Detection + signal only — nothing here kills or restarts the
4235
4456
  * session. */
4236
4457
  stalledSinceMs?: number;
4458
+ /** Counted background tool starts in the last turn; the session ended its
4459
+ * turn without a wake-up path — likely parked. Stamped at turn-end when
4460
+ * the turn observed one or more tool-calls whose `arguments` object
4461
+ * carries `run_in_background: true` (how Claude Code's Bash announces a
4462
+ * background task — matched generically on the property, not the tool
4463
+ * name) AND the session is not `awaitingInput`. The harness's own
4464
+ * task-completion notification does NOT trigger a new turn, so the
4465
+ * session sits `busy:false`, `awaitingInput:false`, background tasks
4466
+ * pending — a silent dead end. Detection + signal ONLY (same doctrine
4467
+ * as `stalledSinceMs`): nothing here re-prompts or wakes the session.
4468
+ * Cleared (deleted, never a stale value) on the next turn start and on
4469
+ * session exit. Emits `session:bg-tasks-parked` /
4470
+ * `session:bg-tasks-cleared`. */
4471
+ pendingBgTasks?: number;
4472
+ /** ISO 8601 timestamp of the last turn that ended because the ADAPTER
4473
+ * ITSELF reported a failure — `runAgentTurn` observed a `turn-end` event
4474
+ * with `reason:"error"` (session-event-bus.ts's `SessionTurnEndEvent`,
4475
+ * e.g. a refused/errored ACP `stopReason` — see adapters/mastra-agent's
4476
+ * host) — as opposed to a thrown/rejected adapter stream, which flips
4477
+ * `status` to `"error"` directly (a genuinely terminal row the existing
4478
+ * crash/error handling already catches). This is the twin gap for a
4479
+ * turn that fails IN-BAND while the process stays alive: `status` stays
4480
+ * `"running"`, `lastError` stays unset (reserved for `markCrashed`), and
4481
+ * nothing else distinguishes the session from one that simply finished
4482
+ * a clean turn and is idle. Folded into the same "stalled" activity/UI
4483
+ * treatment a mid-turn stall gets (see sessionsTree.logic.ts's
4484
+ * `activityFor`) rather than a new state, on the theory that both mean
4485
+ * "the last thing this session did needs a look, not a re-prompt on
4486
+ * faith". Stamped at turn-end when `turnEndReason === "error"`; cleared
4487
+ * the moment a LATER turn completes without one (same reset shape as
4488
+ * `resumeAttempts`/`restartAttempts`). Detection + signal only. */
4489
+ lastTurnErroredAt?: string;
4237
4490
  /** DERIVED, read-time only (never persisted — stripped by `snapshotRows`,
4238
4491
  * stamped by `stampInterrupted` in list()/get()/findByIdOrName). True when
4239
4492
  * this session died with a turn in flight under a daemon restart —
@@ -4360,6 +4613,17 @@ interface SessionDescriptor {
4360
4613
  * `session_set_keepalive` (`registry.setKeepAlive`). Absent (not `false`)
4361
4614
  * for every session that hasn't opted in. */
4362
4615
  keepAlive?: boolean;
4616
+ /** Server-persisted, list-visibility-only favorite flag — set/cleared via
4617
+ * `session_set_pinned` (`registry.setPinned`) or `POST /sessions/:id/pin`.
4618
+ * Purely a sort/display concern: pinned sessions sort to the top of the
4619
+ * session list (CLI table, VS Code webview's dedicated "Pinned" group).
4620
+ * Deliberately orthogonal to — and must NEVER be confused with —
4621
+ * `keepAlive` (idle-reaper exemption, operational), the VS Code
4622
+ * extension's client-side-only "watch" eye (toast notifications, never
4623
+ * persisted here), or `watchers` (live supervisor wait count). No side
4624
+ * effects on reaping, notifications, or anything else. Absent (not
4625
+ * `false`) for every session that hasn't been pinned. */
4626
+ pinned?: boolean;
4363
4627
  /** True when the session was spawned under a real PTY (node-pty)
4364
4628
  * instead of `child_process.spawn`. PTY sessions carry raw ANSI
4365
4629
  * bytes (alt-screen, key bindings, colors); attach goes through
@@ -4431,6 +4695,23 @@ interface SessionDescriptor {
4431
4695
  * `adapterSlug`, recorded under the canonical axis name. Falls back to
4432
4696
  * `adapterSlug` when not explicitly set. Undefined for pty/command kinds. */
4433
4697
  harness?: string;
4698
+ /**
4699
+ * How this adapter's spawn ROUTE relates to the chosen model (AIP-45
4700
+ * launch-menu drill-down). `"derived-from-model"` means the endpoint falls
4701
+ * out of the model id's own vendor prefix; `"free"`/omitted means the route
4702
+ * is an independent choice. Recorded at spawn time so a live `setModel` can
4703
+ * apply the same wire normalization the spawn path used.
4704
+ */
4705
+ routeSelection?: "free" | "derived-from-model";
4706
+ /**
4707
+ * The adapter manifest's provider (`authDescriptor.provider`) — e.g.
4708
+ * `"anthropic"` for claude-code, `"openai"` for codex. Recorded at spawn
4709
+ * time so a live `setModel` knows when it can safely bare a
4710
+ * `vendor/product` direct ref; ignored for derived-from-model adapters.
4711
+ * Distinct from `auth.provider`, which is the resolved billing wallet and
4712
+ * may name a gateway route.
4713
+ */
4714
+ adapterProvider?: string;
4434
4715
  /**
4435
4716
  * AIP-45 mode the session was spawned with (`AgentCliStartOptions.config.
4436
4717
  * mode` — e.g. claude-code's `plan`/`accept-edits`, a gateway preset mode
@@ -4505,6 +4786,17 @@ interface SessionDescriptor {
4505
4786
  * via sessions.json so `restart` can pass it as `resumeSessionId`
4506
4787
  * and reattach to the prior conversation history. */
4507
4788
  adapterSessionId?: string;
4789
+ /** Persistent isolated-config dir handed to the adapter at spawn time
4790
+ * (`startSession({ configDir })` → claude-code's `CLAUDE_CONFIG_DIR`).
4791
+ * Keyed by the FIRST session id in a restart lineage
4792
+ * (`adapterConfigDirFor`) and carried forward verbatim across
4793
+ * restarts/lazy resumes — the provider's own conversation store lives
4794
+ * inside it, so reusing the SAME dir is what lets `resumeSessionId`
4795
+ * restore full context after the adapter process died (before this,
4796
+ * each respawn minted a fresh temp dir and native resume always
4797
+ * degraded to the daemon-transcript digest). Absent on legacy rows and
4798
+ * adapters that don't isolate a config dir. */
4799
+ adapterConfigDir?: string;
4508
4800
  /** MCP servers mounted into the agent's session at spawn time
4509
4801
  * (orchestrator WP1). Persisted so the resume/re-spawn path can
4510
4802
  * re-mount the same host-chosen toolset instead of resuming a
@@ -4604,6 +4896,23 @@ interface SessionDescriptor {
4604
4896
  * message (`runAgentTurn`) — so delivery survives a busy parent without
4605
4897
  * ever cancelling its in-flight work. Absent when nothing is queued. */
4606
4898
  pendingChildCrashNotices?: string[];
4899
+ /** FIFO of prompts that arrived while this session was mid-turn and
4900
+ * asked to be QUEUED rather than rejected (`enqueuePrompt`'s
4901
+ * `opts.queue` arm — see its doc comment). Index 0 is next to
4902
+ * dispatch. A plain queued item is appended to the back; a
4903
+ * `force`-queued one is inserted at the front, jumping everything
4904
+ * already waiting WITHOUT cancelling the live turn (that's what
4905
+ * `interrupt` is for). Drained one item at a time, in this order, by
4906
+ * `dispatchQueuedPrompt` at the end of every `runAgentTurn` — never
4907
+ * by the caller that queued it, which already returned. Always
4908
+ * replaced with a NEW array reference on every mutation (push, drain,
4909
+ * removal), never mutated in place — the VS Code webview's
4910
+ * `sessionDescriptorsEqual` diff is a shallow `!==` per field, so an
4911
+ * in-place `.shift()` here would silently stop propagating queue
4912
+ * changes to the transcript panel. `[]` (not absent) once anything
4913
+ * has ever been queued, matching `pendingChildCrashNotices`'s
4914
+ * convention above. */
4915
+ promptQueue?: QueuedPrompt[];
4607
4916
  /** Best-effort context-handoff digest (Fix D), stashed on a descriptor
4608
4917
  * whose resume degraded to a BLANK spawn — the adapter's own
4609
4918
  * conversation store was missing, or the adapter declared `resumable:
@@ -4742,6 +5051,9 @@ interface SessionSummary {
4742
5051
  killedMidTurn?: boolean;
4743
5052
  lastOutputAt?: string;
4744
5053
  lastActivityAt?: string;
5054
+ currentPhase?: SessionCurrentPhase;
5055
+ secondsSinceLastActivity?: number;
5056
+ toolCallsThisTurn?: number;
4745
5057
  processAlive?: boolean;
4746
5058
  /** Live supervisor waiter count (#session-visibility) — see
4747
5059
  * `SessionDescriptor.watchers`. Ephemeral, stamped at read time. */
@@ -4755,6 +5067,7 @@ interface SessionSummary {
4755
5067
  activitySummary?: SessionActivitySummary;
4756
5068
  archived?: boolean;
4757
5069
  keepAlive?: boolean;
5070
+ pinned?: boolean;
4758
5071
  pty?: boolean;
4759
5072
  name?: string;
4760
5073
  argv?: readonly string[];
@@ -4777,6 +5090,14 @@ interface SessionSummary {
4777
5090
  busy?: boolean;
4778
5091
  blockedOn?: "subagent" | "command";
4779
5092
  stalledSinceMs?: number;
5093
+ /** Parked-with-background-tasks marker — see
5094
+ * `SessionDescriptor.pendingBgTasks`. Stamped at turn-end, cleared on the
5095
+ * next turn start / exit. */
5096
+ pendingBgTasks?: number;
5097
+ /** Adapter-reported turn-error marker — see
5098
+ * `SessionDescriptor.lastTurnErroredAt`. Stamped at turn-end, cleared on
5099
+ * the next turn that completes without one. */
5100
+ lastTurnErroredAt?: string;
4780
5101
  origin?: string;
4781
5102
  parentSessionId?: string;
4782
5103
  depth?: number;
@@ -5072,11 +5393,41 @@ interface SessionsRegistry {
5072
5393
  * `false` reproduces today's mid-turn rejection byte-for-byte. */
5073
5394
  /** `opts.source` on either prompt verb is the turn's provenance
5074
5395
  * (`agent:<sessionId>` when another session injected it — see
5075
- * `SessionObserver.recordPrompt`); recording-only, never behavioral. */
5396
+ * `SessionObserver.recordPrompt`); recording-only, never behavioral.
5397
+ *
5398
+ * `opts.queue` is the FIFO arm (additive, opt-in — omitted/false
5399
+ * reproduces the byte-for-byte busy rejection above, unchanged):
5400
+ * when the session is mid-turn AND `queue` is true, the prompt is
5401
+ * appended to `SessionDescriptor.promptQueue` instead of being
5402
+ * rejected, and this resolves immediately WITHOUT dispatching
5403
+ * anything — `dispatchQueuedPrompt` fires it once the current (and
5404
+ * any earlier-queued) turns finish. `opts.force` only matters
5405
+ * alongside `queue`: it inserts at the FRONT of the queue instead of
5406
+ * the back, jumping everything already waiting, but — unlike
5407
+ * `interrupt` — never touches the live turn. `opts.queueId` lets the
5408
+ * caller pin the queued item's id up front (the HTTP layer does this
5409
+ * so it can echo the id straight back in its response); omitted, one
5410
+ * is minted here. On an IDLE session `queue`/`force`/`queueId` are
5411
+ * no-ops — admission falls straight through to the normal dispatch
5412
+ * path below, identical to `queue` omitted. `interrupt` is checked
5413
+ * first: an `{interrupt: true, queue: true}` pair interrupts (never
5414
+ * queues) exactly like `interrupt` alone. */
5076
5415
  enqueuePrompt(id: string, message: unknown, opts?: {
5077
5416
  interrupt?: boolean;
5078
5417
  source?: string;
5418
+ queue?: boolean;
5419
+ force?: boolean;
5420
+ queueId?: string;
5079
5421
  }): Promise<void>;
5422
+ /** Cancel one not-yet-dispatched item in `SessionDescriptor.promptQueue`
5423
+ * by id — the composer's per-item "remove" action. Idempotent: an
5424
+ * unknown session or an id that's already gone (dispatched, already
5425
+ * removed, or never existed) resolves `{removed: false}` rather than
5426
+ * throwing, same shape as `interruptSession`'s no-op-is-not-an-error
5427
+ * contract. */
5428
+ removeQueuedPrompt(id: string, queueId: string): {
5429
+ removed: boolean;
5430
+ };
5080
5431
  /** Eagerly resume ONE dead-but-resumable agent-cli session IN PLACE,
5081
5432
  * WITHOUT a prompt — the boot-time counterpart to the lazy resume that
5082
5433
  * `sendPrompt`/`enqueuePrompt` trigger on the first prompt after a restart
@@ -5220,11 +5571,17 @@ interface SessionsRegistry {
5220
5571
  * ephemeral `watchers` counter surfaced on the descriptor at read time.
5221
5572
  * Called by `monitorSessionWait` when a `/sessions/:id/wait` long-poll or
5222
5573
  * `session_monitor` subscription actually blocks. A no-op for an unknown id
5223
- * is fine (the wait may outlive the row). */
5224
- incWatchers(id: string): void;
5574
+ * is fine (the wait may outlive the row). `detail`, when passed, is held
5575
+ * (by reference) alongside the count and surfaced as
5576
+ * `SessionDescriptor.watcherDetails` — pass the SAME object reference to
5577
+ * the matching {@link decWatchers} call so removal is exact. */
5578
+ incWatchers(id: string, detail?: SessionWatcherInfo): void;
5225
5579
  /** Balance an {@link incWatchers} when the waiter resolves or times out.
5226
- * Clamps at 0 and drops the map entry at zero so the counter can't leak. */
5227
- decWatchers(id: string): void;
5580
+ * Clamps at 0 and drops the map entry at zero so the counter can't leak.
5581
+ * Pass the same `detail` reference given to `incWatchers` to remove it from
5582
+ * `watcherDetails`; omitted/mismatched detail leaves the count balanced but
5583
+ * the detail list untouched (defensive — should not happen in practice). */
5584
+ decWatchers(id: string, detail?: SessionWatcherInfo): void;
5228
5585
  /** Archive a TERMINAL-status session (exited/killed/error) — sets
5229
5586
  * `archived: true` and persists. Pure housekeeping: hides the row from
5230
5587
  * `list()`'s default view, nothing else. Refuses (throws) a still-alive
@@ -5274,6 +5631,45 @@ interface SessionsRegistry {
5274
5631
  * policy state — never touches the live agent. Throws when the id is
5275
5632
  * unknown. */
5276
5633
  setKeepAlive(id: string, keepAlive: boolean): SessionDescriptor;
5634
+ /** Set or clear a session's list-visibility pin (the `session_set_pinned`
5635
+ * MCP verb / `POST /sessions/:id/pin`). `true` flips
5636
+ * `SessionDescriptor.pinned` on — pure sort/display state for the CLI
5637
+ * table and the VS Code webview's list, which sort a pinned session to
5638
+ * the top. `false` clears it. Persists via the same `schedulePersist`
5639
+ * every descriptor mutation uses and emits `session:pinned-changed` so a
5640
+ * live UI resorts without waiting for its next snapshot poll. NEVER
5641
+ * touches `keepAlive`, reaper eligibility, or any notification path —
5642
+ * pin is quiet, structural state only. Throws when the id is unknown. */
5643
+ setPinned(id: string, pinned: boolean): SessionDescriptor;
5644
+ /**
5645
+ * Manually override `awaitingInput`/`awaitingQuestion` (the
5646
+ * `session_flag_status` MCP verb) — the ONE write path for this pair
5647
+ * besides the internal heuristic (`deriveHeuristicQuestion`) and a
5648
+ * driver-reported `agent-prompt`, both of which only ever run inside a
5649
+ * live turn. Lets a human, another agent, or the session watchdog correct
5650
+ * a missed real question (`awaitingInput:true`, optionally attaching
5651
+ * `question`) or clear a false positive (`awaitingInput:false`).
5652
+ * `awaitingInput:false` ALWAYS clears `awaitingQuestion` too, regardless
5653
+ * of what `question` was passed — a question cannot outlive its
5654
+ * awaiting-input flag. When `question` is given alongside `true`, it's
5655
+ * stored as `{ text: question, source: "structured" }` (an explicit
5656
+ * override is at least as authoritative as a driver-reported prompt).
5657
+ * Guard mirrors the INVERSE of `archiveSession`'s: only a LIVE session
5658
+ * (running/starting) may be flagged — a terminal session has no turn left
5659
+ * to be "awaiting" anything, so correcting it there would be fiction with
5660
+ * nothing downstream (`session_monitor`, the webhook notifier) to observe
5661
+ * it. Persists via `schedulePersist` and emits
5662
+ * `session:awaiting-input-flagged` (carrying the required `reason`) so
5663
+ * the correction is visible via `session_events_poll` same as every other
5664
+ * lifecycle event. Cleared automatically like any other awaiting-input
5665
+ * signal on the session's next prompt/turn start. Throws when the id is
5666
+ * unknown or the session is terminal.
5667
+ */
5668
+ flagAwaitingInput(id: string, patch: {
5669
+ awaitingInput: boolean;
5670
+ question?: string;
5671
+ reason: string;
5672
+ }): SessionDescriptor;
5277
5673
  /** Subscribe to a session's output. Returns an unsubscribe fn.
5278
5674
  * Initial backfill: synchronously invokes `onLine` once for each
5279
5675
  * line currently in the ring buffer so attaches show context. */
@@ -5524,6 +5920,14 @@ interface SpawnAgentInput {
5524
5920
  nativeTerminalResume?: boolean;
5525
5921
  /** Canonical harness slug — recorded on the descriptor; defaults to adapterSlug. */
5526
5922
  harness?: string;
5923
+ /** Manifest-declared `routeSelection` (AIP-45) — recorded verbatim onto
5924
+ * {@link SessionDescriptor.routeSelection} so live `setModel` can apply
5925
+ * the same wire normalization as spawn. */
5926
+ routeSelection?: "free" | "derived-from-model";
5927
+ /** Manifest-declared provider (`authDescriptor.provider`) — recorded onto
5928
+ * {@link SessionDescriptor.adapterProvider} so live `setModel` knows when
5929
+ * to bare a direct `vendor/product` ref; ignored for derived adapters. */
5930
+ adapterProvider?: string;
5527
5931
  /** Optional initial prompt to dispatch immediately. The promise
5528
5932
  * the registry returns resolves AFTER the spawn — the prompt
5529
5933
  * runs in the background, projecting events into the ring
@@ -5541,6 +5945,12 @@ interface SpawnAgentInput {
5541
5945
  * the resume/re-spawn path can re-mount the same toolset (orchestrator
5542
5946
  * WP1). */
5543
5947
  mcpServers?: AcpMcpServer[];
5948
+ /** Persistent isolated-config dir this spawn passed to
5949
+ * `startSession({ configDir })` — recorded verbatim onto
5950
+ * {@link SessionDescriptor.adapterConfigDir} so restart/lazy-resume can
5951
+ * point the respawned adapter back at the SAME dir (where the provider's
5952
+ * conversation store lives). See that field's doc. */
5953
+ adapterConfigDir?: string;
5544
5954
  /** Spawning orchestrator's session id — set when the spawn arrived
5545
5955
  * through the scoped sub-gateway (orchestrator WP4). Recorded on the
5546
5956
  * descriptor for subtree scoping + quota accounting. */
@@ -6120,6 +6530,212 @@ interface InboundWatcher {
6120
6530
  shutdown(): void;
6121
6531
  }
6122
6532
 
6533
+ /**
6534
+ * Runtime-side glue for the per-workspace brain: a shared registry of
6535
+ * {@link BrainManager}s (one per workspace bucket) plus the two bridges that
6536
+ * connect the pure `@agentproto/workspace-brain` engine to this daemon's real
6537
+ * conversation stores:
6538
+ *
6539
+ * - `readSessionForBrain` — a session id → exported transcript, via the same
6540
+ * ladder as `conversation-read.ts`: the provider-native store first
6541
+ * (`CONVERSATION_STORES`), then the universal `events.jsonl` capture
6542
+ * (`exportDaemonEventsSession`). `null` when neither has anything.
6543
+ * - `resolveWorkspace` — a session id → the workspace bucket it was recorded
6544
+ * under (via the persisted `conversations.jsonl` index).
6545
+ *
6546
+ * The registry itself is keyed by bucket slug and creates each `BrainManager`
6547
+ * lazily, so a workspace that never produces a session pays nothing until its
6548
+ * first exit does.
6549
+ *
6550
+ * A workspace's knowledge backends are configured per-workspace by a
6551
+ * `knowledge.json` file at `<bucket>/knowledge.json` (see
6552
+ * {@link loadKnowledgeConfigForWorkspace}). No file → the brain's default
6553
+ * single `files` provider (identical to pre-config behavior); an invalid
6554
+ * file → warn + fall back to that default; never throws either way.
6555
+ */
6556
+
6557
+ /** The shared registry handed to both the subscriber and the MCP tools. */
6558
+ interface WorkspaceBrains {
6559
+ /** Get (creating lazily) the brain manager for a workspace bucket slug. */
6560
+ getBrain(workspace: string): BrainManager;
6561
+ /** Map a session id to the workspace bucket it was recorded under. */
6562
+ resolveWorkspace(sessionId: string): Promise<string | undefined>;
6563
+ /** Resolve an explicit workspace slug (or caller slug) to a safe bucket
6564
+ * slug — "default" when unregistered/absent (membership rule). */
6565
+ resolveWorkspaceSlug(workspace?: string, callerSlug?: string): string;
6566
+ }
6567
+ /** Resolve a session id to its exported transcript, native first then daemon
6568
+ * events — `null` (never throws) when neither store has anything readable. */
6569
+ declare function readSessionForBrain(sessionId: string): Promise<ExportedSessionLike | null>;
6570
+ declare function createWorkspaceBrains(): WorkspaceBrains;
6571
+
6572
+ /**
6573
+ * MCP tools that expose the per-workspace brain to agents.
6574
+ *
6575
+ * Three tools over the shared {@link WorkspaceBrains} registry:
6576
+ *
6577
+ * - `workspace_brain_query` — BM25 recall over a workspace's ingested
6578
+ * conversations (dispatch to the provider).
6579
+ * - `workspace_brain_status` — how many sessions a workspace has ingested.
6580
+ * - `workspace_brain_ingest` — manually trigger ingestion (a session, or
6581
+ * every known-but-uningested session).
6582
+ *
6583
+ * Every tool resolves its target workspace the same way: an explicit
6584
+ * `workspace` argument wins; otherwise the calling session's own workspace is
6585
+ * used (from its descriptor's `workspaceSlug`). Resolution applies the bucket
6586
+ * membership rule, so an unregistered slug degrades to `default` rather than
6587
+ * pointing a brain at an arbitrary path.
6588
+ */
6589
+
6590
+ interface RegisterBrainToolsOptions {
6591
+ /** The shared per-workspace brain registry. */
6592
+ brains: WorkspaceBrains;
6593
+ /** Registry used to resolve the calling session's own workspace. */
6594
+ registry: SessionsRegistry;
6595
+ /** The calling agent session id (from `?callerSessionId=` on `/mcp`). */
6596
+ callerSessionId?: string;
6597
+ }
6598
+ declare function registerBrainTools(server: McpServer, opts: RegisterBrainToolsOptions): void;
6599
+
6600
+ /**
6601
+ * Workshop-brain subscriber — auto-ingest a workspace's conversations when its
6602
+ * sessions exit.
6603
+ *
6604
+ * Subscribes to `session:exited` on the {@link SessionEventBus} and, after a
6605
+ * short debounce, fire-and-forgets an ingestion of each freshly-exited session
6606
+ * into its workspace's brain. The debounce batches a flurry of exits (e.g. an
6607
+ * orchestrator tearing down N children at once) into one pass instead of N
6608
+ * index rebuilds.
6609
+ *
6610
+ * Mirrors `webhook-notifier.ts`'s containment discipline: the handler never
6611
+ * throws into the bus's hot path — every error is swallowed and logged, so a
6612
+ * brain hiccup can never take down an exit event.
6613
+ */
6614
+
6615
+ interface WorkspaceBrainSubscriberOptions {
6616
+ readonly bus: SessionEventBus;
6617
+ /** The shared brain registry. */
6618
+ readonly brains: WorkspaceBrains;
6619
+ /** Debounce window for batching consecutive exits. Default 5000ms. */
6620
+ debounceMs?: number;
6621
+ }
6622
+ interface WorkspaceBrainSubscriber {
6623
+ /** Wire the handler onto the bus (idempotent). */
6624
+ start(): void;
6625
+ /** Unsubscribe (idempotent). */
6626
+ stop(): void;
6627
+ /** Flush any pending (not-yet-debounced) exits now. */
6628
+ flush(): void;
6629
+ }
6630
+ declare function createWorkspaceBrainSubscriber(opts: WorkspaceBrainSubscriberOptions): WorkspaceBrainSubscriber;
6631
+
6632
+ /**
6633
+ * `~/.agentproto/harness-presets.json` — the persisted harness→profile binding
6634
+ * (mode 0600). A {@link HarnessPreset} names, per adapter harness, WHICH auth
6635
+ * profile and default model a fresh spawn should bill through, so the operator
6636
+ * no longer re-picks the profile every time (today that link lives only
6637
+ * ephemerally per-session `setSessionAccessProfile` or per-spawn in the
6638
+ * Configuration Lab picker).
6639
+ *
6640
+ * This is a POINTER store, like `auth-profiles.json` and
6641
+ * `llm-endpoint-links.json`, not a secret store: an entry holds a `profileRef`
6642
+ * (an {@link AuthProfile} id) and a `defaultModel` string, never a credential —
6643
+ * so it needs no encryption. It reuses the exact persistence primitives the
6644
+ * sibling stores established (a versioned JSON file under `~/.agentproto/`,
6645
+ * `node:fs/promises`, mode 0600, whole-file write) — see
6646
+ * `user-presets.ts` / `profile-store.ts` / `llm-endpoint-links-store.ts`.
6647
+ *
6648
+ * Invariants enforced on write (validated once, at this boundary, for every
6649
+ * CLI/MCP/editor caller):
6650
+ * • at most one `isDefault: true` per `harnessSlug` — the spawn path reads
6651
+ * exactly one default per harness (see `getDefaultHarnessPreset`);
6652
+ * • `profileRef` must reference an EXISTING, ENABLED auth profile — a dangling
6653
+ * or disabled profile can never become the silent default a spawn bills;
6654
+ * • `defaultModel` must be serviceable by that profile's curation allowlist
6655
+ * (a `mode: "allow"` profile only bills the models it lists).
6656
+ * The profile lookup is injected ({@link HarnessPresetValidationDeps}) so the
6657
+ * store is testable without touching the real auth-profile store; it defaults
6658
+ * to `@agentproto/auth`'s `getAuthProfile`.
6659
+ */
6660
+
6661
+ /**
6662
+ * A persisted harness→profile binding: for one adapter harness, which auth
6663
+ * profile + default model a fresh spawn bills through when the caller pins
6664
+ * neither explicitly.
6665
+ */
6666
+ interface HarnessPreset {
6667
+ /** Stable, machine-local id — unique across all presets (e.g. `hm-cheap`). */
6668
+ id: string;
6669
+ /** Adapter harness slug this preset binds (e.g. `hermes`). Matched against a
6670
+ * spawn's `harness ?? adapter`. */
6671
+ harnessSlug: string;
6672
+ /** Human-readable display name (e.g. `Cheap`). */
6673
+ name: string;
6674
+ /** The {@link AuthProfile} id this preset bills through — must exist and be
6675
+ * enabled at write time. */
6676
+ profileRef: string;
6677
+ /** Model id applied at spawn when the caller named none (e.g. `z-ai/glm-5.2`). */
6678
+ defaultModel: string;
6679
+ /** Whether this is THE default preset for its `harnessSlug`. At most one per
6680
+ * harness — enforced on write. */
6681
+ isDefault: boolean;
6682
+ }
6683
+ declare const harnessPresetsFileSchema: z.ZodObject<{
6684
+ version: z.ZodLiteral<1>;
6685
+ presets: z.ZodArray<z.ZodObject<{
6686
+ id: z.ZodString;
6687
+ harnessSlug: z.ZodString;
6688
+ name: z.ZodString;
6689
+ profileRef: z.ZodString;
6690
+ defaultModel: z.ZodString;
6691
+ isDefault: z.ZodBoolean;
6692
+ }, z.core.$strip>>;
6693
+ }, z.core.$strip>;
6694
+ type HarnessPresetsFile = z.infer<typeof harnessPresetsFileSchema>;
6695
+ /** Thrown when a create/update violates a store invariant (unknown/disabled
6696
+ * profile, a model the profile can't service, …). A validation failure, not
6697
+ * an I/O failure — callers surface it as a rejected request, not a crash. */
6698
+ declare class HarnessPresetValidationError extends Error {
6699
+ constructor(message: string);
6700
+ }
6701
+ /** Injected profile lookup — lets the store validate `profileRef` without a
6702
+ * hard dependency on the real auth-profile file (tests stub it). */
6703
+ interface HarnessPresetValidationDeps {
6704
+ getProfile: (id: string) => Promise<AuthProfile | undefined>;
6705
+ }
6706
+ declare function harnessPresetsPath(): string;
6707
+ /** Missing or malformed config is treated as empty — a bad preset file must
6708
+ * never prevent the daemon from spawning. Writes always restore valid JSON. */
6709
+ declare function loadHarnessPresets(): Promise<HarnessPresetsFile>;
6710
+ /** List all presets, optionally filtered to one harness slug. */
6711
+ declare function listHarnessPresets(harnessSlug?: string): Promise<HarnessPreset[]>;
6712
+ /** Look up a single preset by id, or undefined if none exists. */
6713
+ declare function getHarnessPreset(id: string): Promise<HarnessPreset | undefined>;
6714
+ /** The default preset for `harnessSlug`, or undefined when none is marked. The
6715
+ * spawn path reads this to fill an unpinned `access.profileRef` + model. */
6716
+ declare function getDefaultHarnessPreset(harnessSlug: string): Promise<HarnessPreset | undefined>;
6717
+ /**
6718
+ * Add or replace a preset by id. Validates the profile binding, then upserts.
6719
+ * When the incoming preset is `isDefault`, every OTHER preset for the same
6720
+ * `harnessSlug` is demoted first, preserving the one-default-per-harness
6721
+ * invariant even across a replace that flips an id's harness or default flag.
6722
+ */
6723
+ declare function addHarnessPreset(preset: HarnessPreset, deps?: HarnessPresetValidationDeps): Promise<HarnessPreset>;
6724
+ /** Partial update of an existing preset. Re-validates the resulting profile
6725
+ * binding and re-applies the one-default invariant. Returns the updated
6726
+ * preset, or undefined when `id` doesn't exist. */
6727
+ declare function updateHarnessPreset(id: string, patch: Partial<Omit<HarnessPreset, "id">>, deps?: HarnessPresetValidationDeps): Promise<HarnessPreset | undefined>;
6728
+ /** Remove a preset by id. Returns true if it existed. */
6729
+ declare function removeHarnessPreset(id: string): Promise<boolean>;
6730
+ /**
6731
+ * Mark `presetId` as THE default for its harness, demoting every other preset
6732
+ * that shares its `harnessSlug`. Idempotent. Throws
6733
+ * {@link HarnessPresetValidationError} when `presetId` doesn't exist or when the
6734
+ * caller-supplied `harnessSlug` disagrees with the preset's own — the latter
6735
+ * guards against defaulting a preset under the wrong harness by a stale id.
6736
+ */
6737
+ declare function setDefaultPreset(harnessSlug: string, presetId: string): Promise<HarnessPreset>;
6738
+
6123
6739
  /**
6124
6740
  * Built-in custom-route registration (PR-5).
6125
6741
  *
@@ -6153,7 +6769,9 @@ interface InboundWatcher {
6153
6769
  * external, must `await` the returned promise or operator-route overrides
6154
6770
  * will silently not apply.
6155
6771
  */
6156
- declare function registerBuiltinRoutes(): Promise<void>;
6772
+ declare function registerBuiltinRoutes(opts?: {
6773
+ llmEndpoint?: boolean;
6774
+ }): Promise<void>;
6157
6775
 
6158
6776
  /**
6159
6777
  * Read-only per-provider model enumeration (AIP-45 launch-menu "+" picker,
@@ -7603,6 +8221,16 @@ declare function monitorSessionWait(opts: {
7603
8221
  event?: SessionWaitEvent;
7604
8222
  timeoutMs?: number;
7605
8223
  since?: number;
8224
+ /**
8225
+ * The calling orchestrator's scope, when this wait was initiated by an
8226
+ * agent session (the scoped orchestrator sub-gateway stamps
8227
+ * `ownerSessionId`). Used ONLY to attribute the watcher attach/detach bus
8228
+ * events this wait emits while blocked — an anonymous CLI/HTTP waiter
8229
+ * leaves it absent. Never changes the wait's own semantics.
8230
+ */
8231
+ callerScope?: {
8232
+ ownerSessionId?: string;
8233
+ };
7606
8234
  }): Promise<SessionWaitResult>;
7607
8235
  /**
7608
8236
  * Block until the named policy's status transitions out of the active
@@ -7927,6 +8555,11 @@ interface CreateGatewayOptions {
7927
8555
  * returns) so the injected `serve` can capture the finished gateway.
7928
8556
  */
7929
8557
  pairingRegistry?: PairingRegistry;
8558
+ /** Enable the local LLM Endpoint proxy sidecar (route registration,
8559
+ * MCP tools, child-process lifecycle). Default false — the endpoint is
8560
+ * an opt-in feature; when off, the `llm-endpoint` custom route is not
8561
+ * registered and the `llm_endpoint_*` MCP tools are not exposed. */
8562
+ llmEndpoint?: boolean;
7930
8563
  }
7931
8564
  interface GatewayHandle {
7932
8565
  url: string;
@@ -7985,4 +8618,4 @@ interface GatewayHandle {
7985
8618
  */
7986
8619
  declare function createGateway(opts: CreateGatewayOptions): Promise<GatewayHandle>;
7987
8620
 
7988
- export { type ActivityKind, type ActivityListFilter, type ActivityPolicyLister, type ActivityProjector, type ActivityProjectorRegistry, type ActivityProjectorSession, type ActivityRecord, type ActivitySource, type ActivityState, type ActivityWaitingOn, type ActivityWorkflowLister, AdapterAuthDescriptor, type AdapterCapabilitiesLister, type AdapterInstallResult, type AdapterListEntry, type AgentAdapterInstaller, type AgentAdapterLister, type AgentAdapterResolver, type AgentSessionLike, type AgentStreamEvent, type AnthropicReaderConfig, AnthropicRemainingQuotaReader, type AttachPolicyInput, type AttachSandboxOpts, type AttachSandboxResult, AuthMethod, BUCKETS_ROOT, type BrowserAdapterHandle, type BrowserAdapterInfo, type BrowserAdapterLister, type BrowserAdapterResolver, BuildHeartbeatAgent, CanonicalPosture, type CatalogModelsLister, CatalogModelsQuery, CatalogModelsResponse, type CatalogProviderModel, type CatalogProviderModelsQuery, type CatalogProviderModelsResponse, type CatalogProviderPricing, type ClaudeNativeRef, type CommitSpec, type CompletionPolicySupervisor, ContextProfile, type ConversationIndexRecord, type ConversationNativeRef, type CostBudgetDecision, type CrashDetectSummary, type CrashReaperRegistry, type CreateGatewayOptions, type CreateOfferInput, type CreatedOffer, DEFAULT_BUCKET, DEFAULT_ORCHESTRATOR_TOOLS, DEFAULT_WORKTREE_ISOLATION, DeclaredAdapterOption, type DeclaredAdapterPreset, type EagerResumeFailReason, type EagerResumeOutcome, type EagerResumeSkipReason, type EagerResumeSummary, EffortLevel, type GateSpec, type GatewayHandle, type HermesNativeRef, INBOUND_PROVIDERS, type IdleReapSummary, type IdleReaperRegistry, type InboundEndpoint, type InboundEndpointStore, type InboundEndpointStoreOptions, type InboundEnqueuePrompt, type InboundIsSessionAlive, type InboundMessage, type InboundProvider, type InboundRestartSession, type InboundRouteMode, type InboundRouterDeps, type InboundRouterLog, type InboundSpawnForContact, type InboundWatcher, type JudgeGateSpec, LEGACY_SESSIONS_FILE, type LocatedConversation, type LocatedConversationByPath, type McpCredentialDeps, type MigrationMarker, type NormalizeInboundResult, type OnFailSpec, type OpenPrResolver, type OrchestratorGatewayDeps, type OrchestratorInjection, type OrchestratorInjector, type OrchestratorInjectorDeps, type OrchestratorMcpServerFactory, type OrchestratorScope, type OrphanReaperRegistry, PAIRINGS_VERSION, POSTURE_NATIVE_ALIASES, POSTURE_PREAMBLES, type PairingChannelContext, type PairingChannelHandle, type PairingChannelMode, type PairingRecord, type PairingRegistry, type PairingRegistryDeps, type PendingPermission, type PermissionRespondInput, type PermissionRespondResult, type PolicyRunState, type PolicyRunStatus, Posture, type PostureResolution, type PrResolvedState, type PrStateResolver, type PresetInfo, type PricingResolver, type QuotaReadableProfile, type QuotaStoreFile, type QuotaStoreOptions, type ReconnectLogGate, type RegisterBrowserInput, type RegisterPairingToolsOptions, type RegisterSessionInput, type RemainingQuota, type RemainingQuotaReader, type ResolveNativeLinkInput, ResolvedAuthSpec, ResumeDisabledError, type RouteAwareLaunchConfig, type RouteAwareLaunchConfigInput, RouteSpec, type RuntimeMeta, SESSION_ID_ENV, type SandboxAdapterInfo, type SandboxConnectionDescriptor, type SandboxProviderCapabilities, type SandboxProviderHandle, type SandboxProviderLister, type SandboxProviderResolver, type ScopeTokenRegistry, SessionConfig, type SessionDescriptor, type SessionKind, type SessionObserver, type SessionSnapshots, type SessionStatus, type SessionUsage, type SessionWaitEvent, type SessionWaitResult, type SessionsRegistry, type ShellGateSpec, type SpawnAgentInput, type SpawnSessionInput, type StallWatchdogRegistry, type StallWatchdogSummary, type StoredProfileQuota, TASK_STATUSES, type TaskCaller, type TaskChangedEvent, type TaskClaimInput, type TaskCreateInput, type TaskGateOutcome, type TaskGateRunner, type TaskLedger, type TaskLedgerRegistry, type TaskLedgerSessionSlice, type TaskListFilter, type TaskRecord, type TaskStatus, type TaskUpdateInput, type TaskVerification, type TaskVerifySupervisor, type TaskWriteResult, type TokenPricing, type TransmitterBinding, type TransmitterBindingStore, type TunnelDescriptor, type TunnelProvider, type TunnelStatus, type UsageBucket, type UsageComputeInput, type UsageRollup, type UsageSnapshotRecord, type UsageSource, WORKSPACE_SLUG_ENV, WORKTREE_ISOLATION_ENV, type WatcherDescriptor, type WatcherStartInput, WorkspaceFs, type WorktreeDecision, type WorktreeField, type WorktreeGcClass, type WorktreeGcOutcomeView, type WorktreeGcPlanEntryView, type WorktreeGcReclaimReason, type WorktreeGcResult, type WorktreeGcRunInput, type WorktreeGcRunner, WorktreeIsolationMode, type WorktreeProvisionOutcome, type WorktreeProvisionRequest, type WorktreeProvisioner, type WorktreeRequest, type WorktreeStatusLister, type WorktreeStatusView, activityCounts, appendConversationRecord, attachSandbox, bucketDir, bucketSessionsFile, bucketTranscriptDir, buildCatalogProviderModels, buildMcpConfigSnippet, buildRouteAwareLaunchConfig, canonicalForModeId, claudeProjectSlug, composeSessionObservers, conversationIndexPath, createActivityProjector, createFileStepCache, createGateway, createInboundEndpointStore, createOrchestratorInjector, createOrchestratorMcpServerFactory, createPairingRegistry, createPrProvenanceReconciler, createReconnectLogGate, createScopeTokenRegistry, createSupervisorTaskGateRunner, createTaskLedger, daemonRegistryDir, decideWorktreeIsolation, declaredPresetToProviderPreset, deriveSessionUsage, enrichRollupWithProviderQuota, enrichWithRemainingQuota, evaluateCostBudget, filterActivities, findConversationRecord, findNativeMode, formatToolCall, formatToolResult, getMcpCredentialDeps, isAgentCliAuthConfigured, isClosedTaskStatus, isSafeBucketSlug, isTerminalActivityState, listBuckets, listPresets, loadQuotaStore, loadWorktreeIsolation, locateConversationByNativePath, locateConversationBySessionId, makeBrowserAdapterLister, migrateLegacySessionsFile, migrationMarkerPath, monitorPolicyWait, monitorSessionWait, narrowOrchestratorTools, normalizeInbound, normalizeModeId, normalizeWorktreeField, parseAnthropicRateLimitHeaders, parseTaskStatus, parseWindow, parseWorktreeIsolationMode, policyToActivities, policyWatchesSession, prToActivities, projectSessionUsage, readConversationIndex, readDaemonRegistry, readProfileQuota, readRegisteredSlugs, readRuntimeMeta, readUsageSnapshots, reapOrphanedDescendants, recordProfileQuota, registerBuiltinRoutes, registerPairingTools, registerSandboxAttachTool, resolveBucketSlug, resolveNativeLink, resolvePosture, rollupUsage, runCrashDetectPass, runEagerResumePass, runIdleReapPass, runStallWatchdogPass, setMcpCredentialDeps, sweepStaleDaemonRegistry, sweepStaleRuntimeMetas, toWorktreeStatusView, turnToActivities, unlinkDaemonRegistryEntry, unlinkRuntimeMeta, verifyInboundSignature, workflowToActivities, writeDaemonRegistryEntry };
8621
+ export { type ActivityKind, type ActivityListFilter, type ActivityPolicyLister, type ActivityProjector, type ActivityProjectorRegistry, type ActivityProjectorSession, type ActivityRecord, type ActivitySource, type ActivityState, type ActivityWaitingOn, type ActivityWorkflowLister, AdapterAuthDescriptor, type AdapterCapabilitiesLister, type AdapterInstallResult, type AdapterListEntry, type AgentAdapterInstaller, type AgentAdapterLister, type AgentAdapterResolver, type AgentSessionLike, type AgentStreamEvent, type AnthropicReaderConfig, AnthropicRemainingQuotaReader, type AttachPolicyInput, type AttachSandboxOpts, type AttachSandboxResult, AuthMethod, BUCKETS_ROOT, type BrowserAdapterHandle, type BrowserAdapterInfo, type BrowserAdapterLister, type BrowserAdapterResolver, BuildHeartbeatAgent, CanonicalPosture, type CatalogModelsLister, CatalogModelsQuery, CatalogModelsResponse, type CatalogProviderModel, type CatalogProviderModelsQuery, type CatalogProviderModelsResponse, type CatalogProviderPricing, type ClaudeNativeRef, type CommitSpec, type CompletionPolicySupervisor, ContextProfile, type ConversationIndexRecord, type ConversationNativeRef, type CostBudgetDecision, type CrashDetectSummary, type CrashReaperRegistry, type CreateGatewayOptions, type CreateOfferInput, type CreatedOffer, DEFAULT_BUCKET, DEFAULT_ORCHESTRATOR_TOOLS, DEFAULT_WORKTREE_ISOLATION, DeclaredAdapterOption, type DeclaredAdapterPreset, type EagerResumeFailReason, type EagerResumeOutcome, type EagerResumeSkipReason, type EagerResumeSummary, EffortLevel, type GateSpec, type GatewayHandle, type HarnessPreset, type HarnessPresetValidationDeps, HarnessPresetValidationError, type HarnessPresetsFile, type HermesNativeRef, INBOUND_PROVIDERS, type IdleReapSummary, type IdleReaperRegistry, type InboundEndpoint, type InboundEndpointStore, type InboundEndpointStoreOptions, type InboundEnqueuePrompt, type InboundIsSessionAlive, type InboundMessage, type InboundProvider, type InboundRestartSession, type InboundRouteMode, type InboundRouterDeps, type InboundRouterLog, type InboundSpawnForContact, type InboundWatcher, type JudgeGateSpec, LEGACY_SESSIONS_FILE, type LocatedConversation, type LocatedConversationByPath, type McpCredentialDeps, type MigrationMarker, type NormalizeInboundResult, type OnFailSpec, type OpenPrResolver, type OrchestratorGatewayDeps, type OrchestratorInjection, type OrchestratorInjector, type OrchestratorInjectorDeps, type OrchestratorMcpServerFactory, type OrchestratorScope, type OrphanReaperRegistry, PAIRINGS_VERSION, POSTURE_NATIVE_ALIASES, POSTURE_PREAMBLES, type PairingChannelContext, type PairingChannelHandle, type PairingChannelMode, type PairingRecord, type PairingRegistry, type PairingRegistryDeps, type PendingPermission, type PermissionRespondInput, type PermissionRespondResult, type PolicyRunState, type PolicyRunStatus, Posture, type PostureResolution, type PrResolvedState, type PrStateResolver, type PresetInfo, type PricingResolver, type QuotaReadableProfile, type QuotaStoreFile, type QuotaStoreOptions, type ReconnectLogGate, type RegisterBrainToolsOptions, type RegisterBrowserInput, type RegisterPairingToolsOptions, type RegisterSessionInput, type RemainingQuota, type RemainingQuotaReader, type ResolveNativeLinkInput, ResolvedAuthSpec, ResumeDisabledError, type RouteAwareLaunchConfig, type RouteAwareLaunchConfigInput, RouteSpec, type RuntimeMeta, SESSION_ID_ENV, type SandboxAdapterInfo, type SandboxConnectionDescriptor, type SandboxProviderCapabilities, type SandboxProviderHandle, type SandboxProviderLister, type SandboxProviderResolver, type ScopeTokenRegistry, SessionConfig, type SessionCurrentPhase, type SessionDescriptor, type SessionKind, type SessionObserver, type SessionSnapshots, type SessionStatus, type SessionUsage, type SessionWaitEvent, type SessionWaitResult, type SessionsRegistry, type ShellGateSpec, type SpawnAgentInput, type SpawnSessionInput, type StallWatchdogRegistry, type StallWatchdogSummary, type StoredProfileQuota, TASK_STATUSES, type TaskCaller, type TaskChangedEvent, type TaskClaimInput, type TaskCreateInput, type TaskGateOutcome, type TaskGateRunner, type TaskLedger, type TaskLedgerRegistry, type TaskLedgerSessionSlice, type TaskListFilter, type TaskRecord, type TaskStatus, type TaskUpdateInput, type TaskVerification, type TaskVerifySupervisor, type TaskWriteResult, type TokenPricing, type TransmitterBinding, type TransmitterBindingStore, type TunnelDescriptor, type TunnelProvider, type TunnelStatus, type UsageBucket, type UsageComputeInput, type UsageRollup, type UsageSnapshotRecord, type UsageSource, WORKSPACE_SLUG_ENV, WORKTREE_ISOLATION_ENV, type WatcherDescriptor, type WatcherStartInput, type WorkspaceBrainSubscriber, type WorkspaceBrainSubscriberOptions, type WorkspaceBrains, WorkspaceFs, type WorktreeDecision, type WorktreeField, type WorktreeGcClass, type WorktreeGcOutcomeView, type WorktreeGcPlanEntryView, type WorktreeGcReclaimReason, type WorktreeGcResult, type WorktreeGcRunInput, type WorktreeGcRunner, WorktreeIsolationMode, type WorktreeProvisionOutcome, type WorktreeProvisionRequest, type WorktreeProvisioner, type WorktreeRequest, type WorktreeStatusLister, type WorktreeStatusView, activityCounts, addHarnessPreset, appendConversationRecord, attachSandbox, bucketDir, bucketSessionsFile, bucketTranscriptDir, buildCatalogProviderModels, buildMcpConfigSnippet, buildRouteAwareLaunchConfig, canonicalForModeId, claudeProjectSlug, composeSessionObservers, conversationIndexPath, createActivityProjector, createFileStepCache, createGateway, createInboundEndpointStore, createOrchestratorInjector, createOrchestratorMcpServerFactory, createPairingRegistry, createPrProvenanceReconciler, createReconnectLogGate, createScopeTokenRegistry, createSupervisorTaskGateRunner, createTaskLedger, createWorkspaceBrainSubscriber, createWorkspaceBrains, daemonRegistryDir, decideWorktreeIsolation, declaredPresetToProviderPreset, deriveSessionUsage, enrichRollupWithProviderQuota, enrichWithRemainingQuota, evaluateCostBudget, filterActivities, findConversationRecord, findNativeMode, formatToolCall, formatToolResult, getDefaultHarnessPreset, getHarnessPreset, getMcpCredentialDeps, harnessPresetsPath, isAgentCliAuthConfigured, isClosedTaskStatus, isSafeBucketSlug, isTerminalActivityState, listBuckets, listHarnessPresets, listPresets, loadHarnessPresets, loadQuotaStore, loadWorktreeIsolation, locateConversationByNativePath, locateConversationBySessionId, makeBrowserAdapterLister, migrateLegacySessionsFile, migrationMarkerPath, monitorPolicyWait, monitorSessionWait, narrowOrchestratorTools, normalizeInbound, normalizeModeId, normalizeWorktreeField, parseAnthropicRateLimitHeaders, parseTaskStatus, parseWindow, parseWorktreeIsolationMode, policyToActivities, policyWatchesSession, prToActivities, projectSessionUsage, readConversationIndex, readDaemonRegistry, readProfileQuota, readRegisteredSlugs, readRuntimeMeta, readSessionForBrain, readUsageSnapshots, reapOrphanedDescendants, recordProfileQuota, registerBrainTools, registerBuiltinRoutes, registerPairingTools, registerSandboxAttachTool, removeHarnessPreset, resolveBucketSlug, resolveNativeLink, resolvePosture, rollupUsage, runCrashDetectPass, runEagerResumePass, runIdleReapPass, runStallWatchdogPass, setDefaultPreset, setMcpCredentialDeps, sweepStaleDaemonRegistry, sweepStaleRuntimeMetas, toWorktreeStatusView, turnToActivities, unlinkDaemonRegistryEntry, unlinkRuntimeMeta, updateHarnessPreset, verifyInboundSignature, workflowToActivities, writeDaemonRegistryEntry };