@agentproto/runtime 2.4.0 → 2.6.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
@@ -13,13 +13,15 @@ export { CostBudget, CostBudgetScope } from '@agentproto/auth';
13
13
  import { R as ResolvedContextContinuityPolicy } from './context-continuity-B9n0t0v-.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-CYJoeHeO.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-CYJoeHeO.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: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" | "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
@@ -1847,6 +1849,93 @@ interface SessionStallClearedEvent {
1847
1849
  label?: string;
1848
1850
  ts: string;
1849
1851
  }
1852
+ /**
1853
+ * Emitted by the wait long-poll helper (`monitorSessionWait`) the moment a
1854
+ * blocking wait actually SUBSCRIBES to this session — a `/sessions/:id/wait`
1855
+ * long-poll or a `session_monitor` call that has to park. This is the bus
1856
+ * twin of the ephemeral `watchers` descriptor counter (`incWatchers`,
1857
+ * #session-visibility): where the counter lets `session_list` surface "N
1858
+ * supervisors are blocked on this session", the event lets a LIVE consumer
1859
+ * (the transcript panel inside the WATCHED session) react the instant a
1860
+ * watcher appears rather than on its next descriptor poll. Detection +
1861
+ * signal ONLY — nothing here changes the wait's own semantics. `watchers`
1862
+ * is the counter AFTER the attach (read back from the registry, so a
1863
+ * concurrent waiter is already reflected). `watcherSessionId` names the
1864
+ * supervising session when the wait was initiated by one (the scoped
1865
+ * orchestrator's `callerScope.ownerSessionId`); absent for an anonymous
1866
+ * CLI/HTTP waiter. Same bus distribution as every other lifecycle event
1867
+ * (`session_events_poll`, the webhook notifier, the routine engine,
1868
+ * `session_monitor`). Paired with `session:watcher-detached` when the wait
1869
+ * resolves or times out.
1870
+ */
1871
+ interface SessionWatcherAttachedEvent {
1872
+ type: "session:watcher-attached";
1873
+ sessionId: string;
1874
+ watchers: number;
1875
+ watcherSessionId?: string;
1876
+ label?: string;
1877
+ ts: string;
1878
+ }
1879
+ /**
1880
+ * Emitted when a blocking wait on this session releases its watcher — the
1881
+ * wait resolved (a matching lifecycle event landed) or timed out; see
1882
+ * {@link SessionWatcherAttachedEvent}. `watchers` is the counter AFTER the
1883
+ * detach, so a consumer can tell "the last watcher left" (`0`) from "one of
1884
+ * several left". Detection + signal only — a zero count does NOT imply the
1885
+ * session is unsupervised in every sense (a completion policy watches via
1886
+ * its own mechanism, not this counter); it only means no `monitorSessionWait`
1887
+ * long-poll is currently parked on it. Same bus distribution as every other
1888
+ * lifecycle event.
1889
+ */
1890
+ interface SessionWatcherDetachedEvent {
1891
+ type: "session:watcher-detached";
1892
+ sessionId: string;
1893
+ watchers: number;
1894
+ watcherSessionId?: string;
1895
+ label?: string;
1896
+ ts: string;
1897
+ }
1898
+ /**
1899
+ * Emitted at turn-end when the turn that just finished started one or more
1900
+ * BACKGROUND tool calls (a tool-call whose `arguments` object carries
1901
+ * `run_in_background: true` — how Claude Code's Bash announces a
1902
+ * `run_in_background` task; matched generically on the property, not the
1903
+ * tool name) AND the session is NOT `awaitingInput`. The target failure
1904
+ * mode is the turn-END twin of `session:stalled`: the harness's own
1905
+ * task-completion notification does NOT trigger a new turn, so the session
1906
+ * sits `busy:false`, `awaitingInput:false`, background tasks pending — a
1907
+ * silent dead end that looks exactly like a session idle and waiting to be
1908
+ * re-prompted. Detection + signal ONLY: nothing here re-prompts or wakes
1909
+ * the session (no auto-wake — a wake-up path would have to decide what to
1910
+ * say, and that policy belongs to the supervisor, not the daemon). `count`
1911
+ * is how many background tool starts the turn observed. Same bus
1912
+ * distribution as every other lifecycle event (`session_events_poll`, the
1913
+ * webhook notifier, the routine engine, `session_monitor`). Paired with
1914
+ * `session:bg-tasks-cleared` when the flag is later cleared.
1915
+ */
1916
+ interface SessionBgTasksParkedEvent {
1917
+ type: "session:bg-tasks-parked";
1918
+ sessionId: string;
1919
+ count: number;
1920
+ label?: string;
1921
+ ts: string;
1922
+ }
1923
+ /**
1924
+ * Emitted when a session's `pendingBgTasks` flag (see {@link
1925
+ * SessionBgTasksParkedEvent}) is cleared — by the next turn starting (the
1926
+ * session was re-prompted, so it is no longer parked: its new turn will see
1927
+ * whatever the background tasks produced) or by the session exiting (a dead
1928
+ * row carries no live flag). Does NOT imply the background tasks finished
1929
+ * or their output was consumed — only that the "ended its turn with
1930
+ * background work pending and no wake-up path" condition no longer holds.
1931
+ * Same bus distribution as every other lifecycle event.
1932
+ */
1933
+ interface SessionBgTasksClearedEvent {
1934
+ type: "session:bg-tasks-cleared";
1935
+ sessionId: string;
1936
+ label?: string;
1937
+ ts: string;
1938
+ }
1850
1939
  /**
1851
1940
  * Emitted when a dead agent-cli row is brought back IN PLACE — same session
1852
1941
  * id, same descriptor — by the lazy resume-on-prompt path (`maybeResumeAgent`)
@@ -2097,7 +2186,7 @@ interface TaskChangedEvent {
2097
2186
  sessionId?: string;
2098
2187
  ts: string;
2099
2188
  }
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;
2189
+ type SessionEvent = SessionTurnEndEvent | SessionAwaitingInputEvent | SessionPermissionRequestEvent | SessionPermissionResolvedEvent | SessionExitedEvent | SessionReapedEvent | SessionStalledEvent | SessionStallClearedEvent | SessionWatcherAttachedEvent | SessionWatcherDetachedEvent | SessionBgTasksParkedEvent | SessionBgTasksClearedEvent | SessionResumedEvent | SessionSpawnedEvent | SessionCommandDoneEvent | SessionModelChangedEvent | SessionConfigChangedEvent | SessionRenamedEvent | PolicyPassedEvent | PolicyFailedEvent | PolicyCommitReadyEvent | PolicyCommittedEvent | CronFiredEvent | CronSucceededEvent | CronFailedEvent | ActivityChangedEvent | TaskChangedEvent;
2101
2190
  interface SessionEventBus {
2102
2191
  emit(ev: SessionEvent): void;
2103
2192
  /** Subscribe to a specific event type. Returns an unsubscribe fn. */
@@ -3748,7 +3837,7 @@ type AdapterCapabilitiesLister = (opts?: {
3748
3837
  interface AdapterInstallResult {
3749
3838
  slug: string;
3750
3839
  ok: boolean;
3751
- method: "npm-global" | "agentproto-install" | "already-installed" | "unsupported";
3840
+ method: "npm-global" | "shell-hint" | "agentproto-install" | "already-installed" | "unsupported";
3752
3841
  /** Human-readable one-liner: what ran, and how it ended. */
3753
3842
  message: string;
3754
3843
  /** The shell command that was run, for surfacing in logs / errors.
@@ -4022,6 +4111,8 @@ interface AgentStreamEvent {
4022
4111
  * @agentproto/acp's `StreamEvent`'s `agent-prompt` kind. Harness-shaped
4023
4112
  * and untyped; don't assume a stable schema across adapters. */
4024
4113
  rawInput?: unknown;
4114
+ /** "plan" event title — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
4115
+ title?: string;
4025
4116
  /** "plan" event entries — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
4026
4117
  entries?: Array<{
4027
4118
  content: string;
@@ -4089,6 +4180,7 @@ declare const SESSION_ID_ENV = "AGENTPROTO_SESSION_ID";
4089
4180
  declare const WORKSPACE_SLUG_ENV = "AGENTPROTO_WORKSPACE_SLUG";
4090
4181
  type SessionKind = "terminal" | "agent-cli" | "command" | "browser";
4091
4182
  type SessionStatus = "starting" | "running" | "exited" | "killed" | "error";
4183
+ type SessionCurrentPhase = "thinking" | `tool-call:${string}` | "awaiting-input" | "awaiting-permission" | "idle" | "completed" | "killed";
4092
4184
  /**
4093
4185
  * The billing-auth resolver's OBSERVABLE echo, recorded on a session
4094
4186
  * descriptor. `mode` + `fingerprint` are always present when recorded (a
@@ -4184,6 +4276,18 @@ interface SessionDescriptor {
4184
4276
  * `lastOutputAt` goes stale. Updated on incoming session/update
4185
4277
  * notifications AND on outbound RPC calls. ISO 8601. */
4186
4278
  lastActivityAt?: string;
4279
+ /** Read-time projection of what the session is doing now. Tool-call phases
4280
+ * carry the adapter-reported tool name (for example
4281
+ * `tool-call:file_read`). Ephemeral: recomputed by list()/get() and never
4282
+ * persisted. */
4283
+ currentPhase?: SessionCurrentPhase;
4284
+ /** Whole seconds since `lastActivityAt`, computed at read time. Absent until
4285
+ * the adapter has reported activity; never persisted. */
4286
+ secondsSinceLastActivity?: number;
4287
+ /** Number of distinct tool calls observed in the current (or most recently
4288
+ * completed) turn. Reset when the next turn starts. Tool-call enrichment
4289
+ * events sharing an id count only once. Ephemeral and never persisted. */
4290
+ toolCallsThisTurn?: number;
4187
4291
  /** Whether the underlying OS process is still alive. Computed via
4188
4292
  * `process.kill(pid, 0)` at read time (list()/get()) — cheap,
4189
4293
  * zero-overhead, standard POSIX check. Absent when `pid` is null
@@ -4234,6 +4338,20 @@ interface SessionDescriptor {
4234
4338
  * stalled. Detection + signal only — nothing here kills or restarts the
4235
4339
  * session. */
4236
4340
  stalledSinceMs?: number;
4341
+ /** Counted background tool starts in the last turn; the session ended its
4342
+ * turn without a wake-up path — likely parked. Stamped at turn-end when
4343
+ * the turn observed one or more tool-calls whose `arguments` object
4344
+ * carries `run_in_background: true` (how Claude Code's Bash announces a
4345
+ * background task — matched generically on the property, not the tool
4346
+ * name) AND the session is not `awaitingInput`. The harness's own
4347
+ * task-completion notification does NOT trigger a new turn, so the
4348
+ * session sits `busy:false`, `awaitingInput:false`, background tasks
4349
+ * pending — a silent dead end. Detection + signal ONLY (same doctrine
4350
+ * as `stalledSinceMs`): nothing here re-prompts or wakes the session.
4351
+ * Cleared (deleted, never a stale value) on the next turn start and on
4352
+ * session exit. Emits `session:bg-tasks-parked` /
4353
+ * `session:bg-tasks-cleared`. */
4354
+ pendingBgTasks?: number;
4237
4355
  /** DERIVED, read-time only (never persisted — stripped by `snapshotRows`,
4238
4356
  * stamped by `stampInterrupted` in list()/get()/findByIdOrName). True when
4239
4357
  * this session died with a turn in flight under a daemon restart —
@@ -4431,6 +4549,23 @@ interface SessionDescriptor {
4431
4549
  * `adapterSlug`, recorded under the canonical axis name. Falls back to
4432
4550
  * `adapterSlug` when not explicitly set. Undefined for pty/command kinds. */
4433
4551
  harness?: string;
4552
+ /**
4553
+ * How this adapter's spawn ROUTE relates to the chosen model (AIP-45
4554
+ * launch-menu drill-down). `"derived-from-model"` means the endpoint falls
4555
+ * out of the model id's own vendor prefix; `"free"`/omitted means the route
4556
+ * is an independent choice. Recorded at spawn time so a live `setModel` can
4557
+ * apply the same wire normalization the spawn path used.
4558
+ */
4559
+ routeSelection?: "free" | "derived-from-model";
4560
+ /**
4561
+ * The adapter manifest's provider (`authDescriptor.provider`) — e.g.
4562
+ * `"anthropic"` for claude-code, `"openai"` for codex. Recorded at spawn
4563
+ * time so a live `setModel` knows when it can safely bare a
4564
+ * `vendor/product` direct ref; ignored for derived-from-model adapters.
4565
+ * Distinct from `auth.provider`, which is the resolved billing wallet and
4566
+ * may name a gateway route.
4567
+ */
4568
+ adapterProvider?: string;
4434
4569
  /**
4435
4570
  * AIP-45 mode the session was spawned with (`AgentCliStartOptions.config.
4436
4571
  * mode` — e.g. claude-code's `plan`/`accept-edits`, a gateway preset mode
@@ -4742,6 +4877,9 @@ interface SessionSummary {
4742
4877
  killedMidTurn?: boolean;
4743
4878
  lastOutputAt?: string;
4744
4879
  lastActivityAt?: string;
4880
+ currentPhase?: SessionCurrentPhase;
4881
+ secondsSinceLastActivity?: number;
4882
+ toolCallsThisTurn?: number;
4745
4883
  processAlive?: boolean;
4746
4884
  /** Live supervisor waiter count (#session-visibility) — see
4747
4885
  * `SessionDescriptor.watchers`. Ephemeral, stamped at read time. */
@@ -4777,6 +4915,10 @@ interface SessionSummary {
4777
4915
  busy?: boolean;
4778
4916
  blockedOn?: "subagent" | "command";
4779
4917
  stalledSinceMs?: number;
4918
+ /** Parked-with-background-tasks marker — see
4919
+ * `SessionDescriptor.pendingBgTasks`. Stamped at turn-end, cleared on the
4920
+ * next turn start / exit. */
4921
+ pendingBgTasks?: number;
4780
4922
  origin?: string;
4781
4923
  parentSessionId?: string;
4782
4924
  depth?: number;
@@ -5524,6 +5666,14 @@ interface SpawnAgentInput {
5524
5666
  nativeTerminalResume?: boolean;
5525
5667
  /** Canonical harness slug — recorded on the descriptor; defaults to adapterSlug. */
5526
5668
  harness?: string;
5669
+ /** Manifest-declared `routeSelection` (AIP-45) — recorded verbatim onto
5670
+ * {@link SessionDescriptor.routeSelection} so live `setModel` can apply
5671
+ * the same wire normalization as spawn. */
5672
+ routeSelection?: "free" | "derived-from-model";
5673
+ /** Manifest-declared provider (`authDescriptor.provider`) — recorded onto
5674
+ * {@link SessionDescriptor.adapterProvider} so live `setModel` knows when
5675
+ * to bare a direct `vendor/product` ref; ignored for derived adapters. */
5676
+ adapterProvider?: string;
5527
5677
  /** Optional initial prompt to dispatch immediately. The promise
5528
5678
  * the registry returns resolves AFTER the spawn — the prompt
5529
5679
  * runs in the background, projecting events into the ring
@@ -6120,6 +6270,212 @@ interface InboundWatcher {
6120
6270
  shutdown(): void;
6121
6271
  }
6122
6272
 
6273
+ /**
6274
+ * Runtime-side glue for the per-workspace brain: a shared registry of
6275
+ * {@link BrainManager}s (one per workspace bucket) plus the two bridges that
6276
+ * connect the pure `@agentproto/workspace-brain` engine to this daemon's real
6277
+ * conversation stores:
6278
+ *
6279
+ * - `readSessionForBrain` — a session id → exported transcript, via the same
6280
+ * ladder as `conversation-read.ts`: the provider-native store first
6281
+ * (`CONVERSATION_STORES`), then the universal `events.jsonl` capture
6282
+ * (`exportDaemonEventsSession`). `null` when neither has anything.
6283
+ * - `resolveWorkspace` — a session id → the workspace bucket it was recorded
6284
+ * under (via the persisted `conversations.jsonl` index).
6285
+ *
6286
+ * The registry itself is keyed by bucket slug and creates each `BrainManager`
6287
+ * lazily, so a workspace that never produces a session pays nothing until its
6288
+ * first exit does.
6289
+ *
6290
+ * A workspace's knowledge backends are configured per-workspace by a
6291
+ * `knowledge.json` file at `<bucket>/knowledge.json` (see
6292
+ * {@link loadKnowledgeConfigForWorkspace}). No file → the brain's default
6293
+ * single `files` provider (identical to pre-config behavior); an invalid
6294
+ * file → warn + fall back to that default; never throws either way.
6295
+ */
6296
+
6297
+ /** The shared registry handed to both the subscriber and the MCP tools. */
6298
+ interface WorkspaceBrains {
6299
+ /** Get (creating lazily) the brain manager for a workspace bucket slug. */
6300
+ getBrain(workspace: string): BrainManager;
6301
+ /** Map a session id to the workspace bucket it was recorded under. */
6302
+ resolveWorkspace(sessionId: string): Promise<string | undefined>;
6303
+ /** Resolve an explicit workspace slug (or caller slug) to a safe bucket
6304
+ * slug — "default" when unregistered/absent (membership rule). */
6305
+ resolveWorkspaceSlug(workspace?: string, callerSlug?: string): string;
6306
+ }
6307
+ /** Resolve a session id to its exported transcript, native first then daemon
6308
+ * events — `null` (never throws) when neither store has anything readable. */
6309
+ declare function readSessionForBrain(sessionId: string): Promise<ExportedSessionLike | null>;
6310
+ declare function createWorkspaceBrains(): WorkspaceBrains;
6311
+
6312
+ /**
6313
+ * MCP tools that expose the per-workspace brain to agents.
6314
+ *
6315
+ * Three tools over the shared {@link WorkspaceBrains} registry:
6316
+ *
6317
+ * - `workspace_brain_query` — BM25 recall over a workspace's ingested
6318
+ * conversations (dispatch to the provider).
6319
+ * - `workspace_brain_status` — how many sessions a workspace has ingested.
6320
+ * - `workspace_brain_ingest` — manually trigger ingestion (a session, or
6321
+ * every known-but-uningested session).
6322
+ *
6323
+ * Every tool resolves its target workspace the same way: an explicit
6324
+ * `workspace` argument wins; otherwise the calling session's own workspace is
6325
+ * used (from its descriptor's `workspaceSlug`). Resolution applies the bucket
6326
+ * membership rule, so an unregistered slug degrades to `default` rather than
6327
+ * pointing a brain at an arbitrary path.
6328
+ */
6329
+
6330
+ interface RegisterBrainToolsOptions {
6331
+ /** The shared per-workspace brain registry. */
6332
+ brains: WorkspaceBrains;
6333
+ /** Registry used to resolve the calling session's own workspace. */
6334
+ registry: SessionsRegistry;
6335
+ /** The calling agent session id (from `?callerSessionId=` on `/mcp`). */
6336
+ callerSessionId?: string;
6337
+ }
6338
+ declare function registerBrainTools(server: McpServer, opts: RegisterBrainToolsOptions): void;
6339
+
6340
+ /**
6341
+ * Workshop-brain subscriber — auto-ingest a workspace's conversations when its
6342
+ * sessions exit.
6343
+ *
6344
+ * Subscribes to `session:exited` on the {@link SessionEventBus} and, after a
6345
+ * short debounce, fire-and-forgets an ingestion of each freshly-exited session
6346
+ * into its workspace's brain. The debounce batches a flurry of exits (e.g. an
6347
+ * orchestrator tearing down N children at once) into one pass instead of N
6348
+ * index rebuilds.
6349
+ *
6350
+ * Mirrors `webhook-notifier.ts`'s containment discipline: the handler never
6351
+ * throws into the bus's hot path — every error is swallowed and logged, so a
6352
+ * brain hiccup can never take down an exit event.
6353
+ */
6354
+
6355
+ interface WorkspaceBrainSubscriberOptions {
6356
+ readonly bus: SessionEventBus;
6357
+ /** The shared brain registry. */
6358
+ readonly brains: WorkspaceBrains;
6359
+ /** Debounce window for batching consecutive exits. Default 5000ms. */
6360
+ debounceMs?: number;
6361
+ }
6362
+ interface WorkspaceBrainSubscriber {
6363
+ /** Wire the handler onto the bus (idempotent). */
6364
+ start(): void;
6365
+ /** Unsubscribe (idempotent). */
6366
+ stop(): void;
6367
+ /** Flush any pending (not-yet-debounced) exits now. */
6368
+ flush(): void;
6369
+ }
6370
+ declare function createWorkspaceBrainSubscriber(opts: WorkspaceBrainSubscriberOptions): WorkspaceBrainSubscriber;
6371
+
6372
+ /**
6373
+ * `~/.agentproto/harness-presets.json` — the persisted harness→profile binding
6374
+ * (mode 0600). A {@link HarnessPreset} names, per adapter harness, WHICH auth
6375
+ * profile and default model a fresh spawn should bill through, so the operator
6376
+ * no longer re-picks the profile every time (today that link lives only
6377
+ * ephemerally per-session `setSessionAccessProfile` or per-spawn in the
6378
+ * Configuration Lab picker).
6379
+ *
6380
+ * This is a POINTER store, like `auth-profiles.json` and
6381
+ * `llm-endpoint-links.json`, not a secret store: an entry holds a `profileRef`
6382
+ * (an {@link AuthProfile} id) and a `defaultModel` string, never a credential —
6383
+ * so it needs no encryption. It reuses the exact persistence primitives the
6384
+ * sibling stores established (a versioned JSON file under `~/.agentproto/`,
6385
+ * `node:fs/promises`, mode 0600, whole-file write) — see
6386
+ * `user-presets.ts` / `profile-store.ts` / `llm-endpoint-links-store.ts`.
6387
+ *
6388
+ * Invariants enforced on write (validated once, at this boundary, for every
6389
+ * CLI/MCP/editor caller):
6390
+ * • at most one `isDefault: true` per `harnessSlug` — the spawn path reads
6391
+ * exactly one default per harness (see `getDefaultHarnessPreset`);
6392
+ * • `profileRef` must reference an EXISTING, ENABLED auth profile — a dangling
6393
+ * or disabled profile can never become the silent default a spawn bills;
6394
+ * • `defaultModel` must be serviceable by that profile's curation allowlist
6395
+ * (a `mode: "allow"` profile only bills the models it lists).
6396
+ * The profile lookup is injected ({@link HarnessPresetValidationDeps}) so the
6397
+ * store is testable without touching the real auth-profile store; it defaults
6398
+ * to `@agentproto/auth`'s `getAuthProfile`.
6399
+ */
6400
+
6401
+ /**
6402
+ * A persisted harness→profile binding: for one adapter harness, which auth
6403
+ * profile + default model a fresh spawn bills through when the caller pins
6404
+ * neither explicitly.
6405
+ */
6406
+ interface HarnessPreset {
6407
+ /** Stable, machine-local id — unique across all presets (e.g. `hm-cheap`). */
6408
+ id: string;
6409
+ /** Adapter harness slug this preset binds (e.g. `hermes`). Matched against a
6410
+ * spawn's `harness ?? adapter`. */
6411
+ harnessSlug: string;
6412
+ /** Human-readable display name (e.g. `Cheap`). */
6413
+ name: string;
6414
+ /** The {@link AuthProfile} id this preset bills through — must exist and be
6415
+ * enabled at write time. */
6416
+ profileRef: string;
6417
+ /** Model id applied at spawn when the caller named none (e.g. `z-ai/glm-5.2`). */
6418
+ defaultModel: string;
6419
+ /** Whether this is THE default preset for its `harnessSlug`. At most one per
6420
+ * harness — enforced on write. */
6421
+ isDefault: boolean;
6422
+ }
6423
+ declare const harnessPresetsFileSchema: z.ZodObject<{
6424
+ version: z.ZodLiteral<1>;
6425
+ presets: z.ZodArray<z.ZodObject<{
6426
+ id: z.ZodString;
6427
+ harnessSlug: z.ZodString;
6428
+ name: z.ZodString;
6429
+ profileRef: z.ZodString;
6430
+ defaultModel: z.ZodString;
6431
+ isDefault: z.ZodBoolean;
6432
+ }, z.core.$strip>>;
6433
+ }, z.core.$strip>;
6434
+ type HarnessPresetsFile = z.infer<typeof harnessPresetsFileSchema>;
6435
+ /** Thrown when a create/update violates a store invariant (unknown/disabled
6436
+ * profile, a model the profile can't service, …). A validation failure, not
6437
+ * an I/O failure — callers surface it as a rejected request, not a crash. */
6438
+ declare class HarnessPresetValidationError extends Error {
6439
+ constructor(message: string);
6440
+ }
6441
+ /** Injected profile lookup — lets the store validate `profileRef` without a
6442
+ * hard dependency on the real auth-profile file (tests stub it). */
6443
+ interface HarnessPresetValidationDeps {
6444
+ getProfile: (id: string) => Promise<AuthProfile | undefined>;
6445
+ }
6446
+ declare function harnessPresetsPath(): string;
6447
+ /** Missing or malformed config is treated as empty — a bad preset file must
6448
+ * never prevent the daemon from spawning. Writes always restore valid JSON. */
6449
+ declare function loadHarnessPresets(): Promise<HarnessPresetsFile>;
6450
+ /** List all presets, optionally filtered to one harness slug. */
6451
+ declare function listHarnessPresets(harnessSlug?: string): Promise<HarnessPreset[]>;
6452
+ /** Look up a single preset by id, or undefined if none exists. */
6453
+ declare function getHarnessPreset(id: string): Promise<HarnessPreset | undefined>;
6454
+ /** The default preset for `harnessSlug`, or undefined when none is marked. The
6455
+ * spawn path reads this to fill an unpinned `access.profileRef` + model. */
6456
+ declare function getDefaultHarnessPreset(harnessSlug: string): Promise<HarnessPreset | undefined>;
6457
+ /**
6458
+ * Add or replace a preset by id. Validates the profile binding, then upserts.
6459
+ * When the incoming preset is `isDefault`, every OTHER preset for the same
6460
+ * `harnessSlug` is demoted first, preserving the one-default-per-harness
6461
+ * invariant even across a replace that flips an id's harness or default flag.
6462
+ */
6463
+ declare function addHarnessPreset(preset: HarnessPreset, deps?: HarnessPresetValidationDeps): Promise<HarnessPreset>;
6464
+ /** Partial update of an existing preset. Re-validates the resulting profile
6465
+ * binding and re-applies the one-default invariant. Returns the updated
6466
+ * preset, or undefined when `id` doesn't exist. */
6467
+ declare function updateHarnessPreset(id: string, patch: Partial<Omit<HarnessPreset, "id">>, deps?: HarnessPresetValidationDeps): Promise<HarnessPreset | undefined>;
6468
+ /** Remove a preset by id. Returns true if it existed. */
6469
+ declare function removeHarnessPreset(id: string): Promise<boolean>;
6470
+ /**
6471
+ * Mark `presetId` as THE default for its harness, demoting every other preset
6472
+ * that shares its `harnessSlug`. Idempotent. Throws
6473
+ * {@link HarnessPresetValidationError} when `presetId` doesn't exist or when the
6474
+ * caller-supplied `harnessSlug` disagrees with the preset's own — the latter
6475
+ * guards against defaulting a preset under the wrong harness by a stale id.
6476
+ */
6477
+ declare function setDefaultPreset(harnessSlug: string, presetId: string): Promise<HarnessPreset>;
6478
+
6123
6479
  /**
6124
6480
  * Built-in custom-route registration (PR-5).
6125
6481
  *
@@ -6153,7 +6509,9 @@ interface InboundWatcher {
6153
6509
  * external, must `await` the returned promise or operator-route overrides
6154
6510
  * will silently not apply.
6155
6511
  */
6156
- declare function registerBuiltinRoutes(): Promise<void>;
6512
+ declare function registerBuiltinRoutes(opts?: {
6513
+ llmEndpoint?: boolean;
6514
+ }): Promise<void>;
6157
6515
 
6158
6516
  /**
6159
6517
  * Read-only per-provider model enumeration (AIP-45 launch-menu "+" picker,
@@ -7603,6 +7961,16 @@ declare function monitorSessionWait(opts: {
7603
7961
  event?: SessionWaitEvent;
7604
7962
  timeoutMs?: number;
7605
7963
  since?: number;
7964
+ /**
7965
+ * The calling orchestrator's scope, when this wait was initiated by an
7966
+ * agent session (the scoped orchestrator sub-gateway stamps
7967
+ * `ownerSessionId`). Used ONLY to attribute the watcher attach/detach bus
7968
+ * events this wait emits while blocked — an anonymous CLI/HTTP waiter
7969
+ * leaves it absent. Never changes the wait's own semantics.
7970
+ */
7971
+ callerScope?: {
7972
+ ownerSessionId?: string;
7973
+ };
7606
7974
  }): Promise<SessionWaitResult>;
7607
7975
  /**
7608
7976
  * Block until the named policy's status transitions out of the active
@@ -7927,6 +8295,11 @@ interface CreateGatewayOptions {
7927
8295
  * returns) so the injected `serve` can capture the finished gateway.
7928
8296
  */
7929
8297
  pairingRegistry?: PairingRegistry;
8298
+ /** Enable the local LLM Endpoint proxy sidecar (route registration,
8299
+ * MCP tools, child-process lifecycle). Default false — the endpoint is
8300
+ * an opt-in feature; when off, the `llm-endpoint` custom route is not
8301
+ * registered and the `llm_endpoint_*` MCP tools are not exposed. */
8302
+ llmEndpoint?: boolean;
7930
8303
  }
7931
8304
  interface GatewayHandle {
7932
8305
  url: string;
@@ -7985,4 +8358,4 @@ interface GatewayHandle {
7985
8358
  */
7986
8359
  declare function createGateway(opts: CreateGatewayOptions): Promise<GatewayHandle>;
7987
8360
 
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 };
8361
+ 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 };