@prismer/runtime 2.0.6 → 2.0.7

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.cts CHANGED
@@ -130,6 +130,15 @@ interface TaskDispatchRequestPayload {
130
130
  }>;
131
131
  /** Wave-8 W1: assets cloud wants daemon to fold into agent context. */
132
132
  assetRefs?: AssetRef[];
133
+ /**
134
+ * release201/09 Phase 2 — task project scope. NULL = workspace-level
135
+ * (`_unscoped` sentinel on disk). Daemon uses this together with
136
+ * `agentImUserId` / `profile.workspaceId` to compose the per-task
137
+ * scratch path: `workspaces/<wid>/projects/<pid|_unscoped>/tasks/<tid>/`.
138
+ * Also forwarded into the spawned agent process as `PRISMER_ACTIVE_PROJECT_ID`
139
+ * (when non-null) so built-in skill --project flag defaults work.
140
+ */
141
+ projectId?: string | null;
133
142
  }
134
143
  interface TaskDispatchProgressPayload {
135
144
  taskId: string;
@@ -155,6 +164,20 @@ interface AssetDispatchObservation {
155
164
  /** L5: end-to-end fetch duration in ms (DNS + connect + body read). */
156
165
  durationMs?: number;
157
166
  }
167
+ /**
168
+ * P1-2 (2026-05-25): per-file outbox rejection record. Surfaced when daemon's
169
+ * `outbox-watcher` rejects an artifact because its magic bytes don't match
170
+ * the file extension (e.g. agent wrote `report.pdf` with markdown content).
171
+ * Cloud persists these on `IMTask.metadata.outboxRejections` and prepends a
172
+ * warning section to the next dispatch prompt so the agent can self-correct.
173
+ */
174
+ interface OutboxRejectionRecord {
175
+ filename: string;
176
+ reason: string;
177
+ inferredMime: string;
178
+ detectedMime: string;
179
+ rejectedAt: string;
180
+ }
158
181
  interface TaskDispatchReplyPayload {
159
182
  taskId: string;
160
183
  ok: boolean;
@@ -170,6 +193,13 @@ interface TaskDispatchReplyPayload {
170
193
  };
171
194
  /** Wave-8 W1: per-asset handling report. */
172
195
  assetObservability?: AssetDispatchObservation[];
196
+ /**
197
+ * P1-2 (2026-05-25): files quarantined locally by outbox-watcher's
198
+ * magic-bytes check during this turn. Cloud writes them onto
199
+ * `IMTask.metadata.outboxRejections` so the next dispatch prompt can warn
200
+ * the agent.
201
+ */
202
+ outboxRejections?: OutboxRejectionRecord[];
173
203
  }
174
204
  interface TaskCancelPayload {
175
205
  taskId: string;
@@ -677,12 +707,6 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
677
707
  * native state key directly and records the exact bridge result on the task.
678
708
  */
679
709
  mirrorNativeGoals: z.ZodDefault<z.ZodBoolean>;
680
- /**
681
- * Optional checkout path for Hermes Agent source. Used only as a fallback
682
- * when the installed `hermes` binary is older than the native Kanban CLI
683
- * surface but the local source tree contains hermes_cli/kanban_db.py.
684
- */
685
- hermesSourceDir: z.ZodOptional<z.ZodString>;
686
710
  nativeMirrorTimeoutMs: z.ZodDefault<z.ZodNumber>;
687
711
  /** Task authority level: executor (default) or orchestrator. */
688
712
  taskAuthority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["executor", "orchestrator"]>>>;
@@ -782,7 +806,6 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
782
806
  hermesProfileName?: string | undefined;
783
807
  prismerMcpServerPath?: string | undefined;
784
808
  prismerProviderBaseUrl?: string | undefined;
785
- hermesSourceDir?: string | undefined;
786
809
  mcpAllowlist?: string[] | null | undefined;
787
810
  operatingPrinciples?: string | Record<string, string> | z.objectOutputType<{
788
811
  source: z.ZodString;
@@ -823,7 +846,6 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
823
846
  prismerApiKeyEnv?: string | undefined;
824
847
  mirrorNativeKanban?: boolean | undefined;
825
848
  mirrorNativeGoals?: boolean | undefined;
826
- hermesSourceDir?: string | undefined;
827
849
  nativeMirrorTimeoutMs?: number | undefined;
828
850
  taskAuthority?: "executor" | "orchestrator" | undefined;
829
851
  approvalPolicy?: "strict" | "auto-low-risk" | "autonomous" | undefined;
@@ -994,7 +1016,7 @@ type LocalDb = Database.Database;
994
1016
  declare function openLocalDb(path: string): LocalDb;
995
1017
  declare function runMigrations(db: LocalDb): void;
996
1018
  declare function currentSchemaVersion(db: LocalDb): number;
997
- declare const TARGET_SCHEMA_VERSION = 4;
1019
+ declare const TARGET_SCHEMA_VERSION = 5;
998
1020
 
999
1021
  type SyncResourceType = 'workspace' | 'agent' | 'agent_profile';
1000
1022
  type SyncOperation = 'create' | 'update' | 'delete';
@@ -1191,11 +1213,28 @@ interface ConfigPaths {
1191
1213
  cacheDir: string;
1192
1214
  logsDir: string;
1193
1215
  /**
1194
- * Per-task run scratch dirs. Each chat-mention dispatch creates
1195
- * `${runsDir}/${taskId}/_outbox/` for adapter-produced files; the
1196
- * OutboxWatcher uploads from there into IMAssets.
1216
+ * Legacy per-task run scratch dirs (pre-release201/09).
1217
+ *
1218
+ * Pre-09: `${runsDir}/${taskId}/_outbox|workdir/`.
1219
+ * 09 Phase 2: dispatch.ts now writes to
1220
+ * `${root}/workspaces/<wid>/projects/<pid|_unscoped>/tasks/<tid>/{result,workdir}`
1221
+ * via `resolveTaskWorkdir()`. `runsDir` is kept as a fallback for tests + a
1222
+ * once-off startup migration helper (`runs/<tid>/` → new path; symlink 兜底
1223
+ * 90 天兼容期, §9.3.1).
1197
1224
  */
1198
1225
  runsDir: string;
1226
+ /**
1227
+ * release201/09 Phase 2 root for workspace × project × task scoped scratch:
1228
+ * `${root}/workspaces/`. resolveTaskWorkdir() composes the per-task path
1229
+ * underneath. Cache GC + project archive scan this root.
1230
+ */
1231
+ workspacesDir: string;
1232
+ /**
1233
+ * release201/09 Phase 2 root for device × agent role layer:
1234
+ * `${root}/devices/`. v2.0.7 Phase 2 不主动创建,Phase 3 (agent transfer)
1235
+ * 才落盘 `profile.json` / `skills/<slug>/` 等内容,本 helper 只解析路径。
1236
+ */
1237
+ devicesDir: string;
1199
1238
  }
1200
1239
  /**
1201
1240
  * Resolve paths for the prismer home directory. Honors `PRISMER_HOME` env var;
@@ -1883,6 +1922,13 @@ interface DispatchDeps {
1883
1922
  outboxWatcher?: OutboxWatcher;
1884
1923
  /** Daemon paths — used to derive the per-task outbox dir. */
1885
1924
  paths?: ConfigPaths;
1925
+ /**
1926
+ * release201/09 §9.9 — Stable device identifier from `config.toml`. Surfaced
1927
+ * to the spawned agent process as `PRISMER_DAEMON_ID` env for metric-outbox
1928
+ * emission + transfer manifest authoring. Optional so existing tests can
1929
+ * omit it; production runner always provides.
1930
+ */
1931
+ daemonId?: string;
1886
1932
  /**
1887
1933
  * Multi-workspace asset metadata indexes for #filename resolution.
1888
1934
  * Keyed by workspaceId. If absent, #ref resolution is skipped entirely.
@@ -2085,6 +2131,40 @@ interface LocalServerOptions {
2085
2131
  * When set, /healthz reports `assetReady: true`.
2086
2132
  */
2087
2133
  attachAsset?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
2134
+ /**
2135
+ * Optional first-pass handler for `/v1/hooks/*` routes (v2.1 §9.5
2136
+ * daemon-as-hook-intake). Returns true if the request was handled
2137
+ * (response written); false to let the normal route table fall through.
2138
+ * Wired by the daemon runner from `attachHookServer()` in
2139
+ * `daemon/memory/hook-server.ts` whenever both memory + run-session
2140
+ * registry are available. When set, /healthz reports `hooksReady: true`.
2141
+ */
2142
+ attachHooks?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
2143
+ /**
2144
+ * Optional first-pass handler for `/v1/checkpoints/*` routes
2145
+ * (release201/09 §9.4a.7 task product self-check). Independent of
2146
+ * `attachHooks` — checkpoints fire on SDK status-transition only, while
2147
+ * hooks fire per LLM call. Wired by the runner from
2148
+ * `attachCheckpointServer()` in `daemon/checkpoint-server.ts`. When set,
2149
+ * /healthz reports `checkpointsReady: true`.
2150
+ */
2151
+ attachCheckpoints?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
2152
+ /**
2153
+ * Optional snapshot getter for the eval-session capability
2154
+ * (release201/08 §7.2). When provided, /healthz reports `evalSessions`
2155
+ * with the current active count + per-run summaries. The runner wires
2156
+ * this from `EvalSessionRunner.getState()`.
2157
+ */
2158
+ getEvalSessions?: () => {
2159
+ active: number;
2160
+ queued: number;
2161
+ maxConcurrent: number;
2162
+ runs: Array<{
2163
+ runId: string;
2164
+ skillId: string;
2165
+ startedAt: string;
2166
+ }>;
2167
+ };
2088
2168
  }
2089
2169
  interface AssetWriteHandlerResult {
2090
2170
  status: 200 | 400 | 502;
@@ -2299,6 +2379,7 @@ declare class Runner extends EventEmitter {
2299
2379
  private localServer?;
2300
2380
  private outboxWatcher?;
2301
2381
  private memoryWiring?;
2382
+ private runSessionRegistry?;
2302
2383
  private assetMetadataIndexes;
2303
2384
  private workspaceMirrors;
2304
2385
  private assetOriginOutbox?;
@@ -2321,10 +2402,21 @@ declare class Runner extends EventEmitter {
2321
2402
  private taskReaperTimer?;
2322
2403
  private skillResyncTimer?;
2323
2404
  private skillSyncInFlight;
2405
+ private resumeInFlightTimer?;
2406
+ private resumeInFlightDone;
2324
2407
  private pendingReplyCache;
2325
2408
  private pendingReplyRecoveryDone;
2326
2409
  constructor(opts?: RunnerOptions);
2327
2410
  start(): Promise<void>;
2411
+ /**
2412
+ * v2.1 §9.5 — build a ProfileResolver backed by the daemon's local
2413
+ * `agent_profiles` mirror. Used by the hook server to translate
2414
+ * `?profile=<name>` query into agentImUserId + workspaceId + role slug
2415
+ * when the run-session registry doesn't yet have the run mapping
2416
+ * (e.g. for the very first pre_llm_call of a session, before the
2417
+ * adapter has had a chance to call register()).
2418
+ */
2419
+ private buildProfileResolver;
2328
2420
  /**
2329
2421
  * F16 (2026-05-20) — enumerate every non-deleted local agent_profile and
2330
2422
  * fan-out `syncInstalledSkillsForDispatch` via `syncAllAgentSkills`.
@@ -2334,6 +2426,33 @@ declare class Runner extends EventEmitter {
2334
2426
  private syncAllSkillsBackground;
2335
2427
  /** F16 — read all live agent_profiles from local DB → AgentProfile[]. */
2336
2428
  private loadAllProfiles;
2429
+ /**
2430
+ * P0-2 (2026-05-25) — daemon cold-start sweep.
2431
+ *
2432
+ * Pulls `IMTaskRun.status='running'` rows where the bound daemon (via
2433
+ * `IMAgentBinding.boundDaemonId`) is this daemon, then re-enqueues each
2434
+ * via the same `onTaskDispatch` handler the ws path uses. Replaces the
2435
+ * slow (~5min) cloud-side `sweepTimedOut()` fallback for pod restarts.
2436
+ *
2437
+ * Idempotent on the daemon side: `onTaskDispatch` dedupes by taskId
2438
+ * against `runningTasks`, so any task that happened to be redispatched
2439
+ * from cloud immediately after our reconnect (via redispatchPending on
2440
+ * the agent.host.declare path) won't double-trigger here.
2441
+ *
2442
+ * Caveat: if the agent was mid-LLM-call when the daemon crashed, the
2443
+ * resumed dispatch starts the call from scratch — token cost duplicated.
2444
+ * We accept that vs the alternative (5min of silence + cloud marks the
2445
+ * run `failed` without any retry).
2446
+ */
2447
+ private resumeInFlightTasks;
2448
+ /**
2449
+ * Rebuild a `task.dispatch.request` payload from an in-flight IMTaskRun
2450
+ * row + its parent IMTask. Mirrors what cloud-side
2451
+ * v19x-helpers.buildTaskDispatchRequest does, with one extra field:
2452
+ * `metadata.resumed = true` so downstream prompt injection can note
2453
+ * this is a recovery dispatch.
2454
+ */
2455
+ private reconstructDispatchPayload;
2337
2456
  stop(): Promise<void>;
2338
2457
  isRunning(): boolean;
2339
2458
  /**
@@ -2552,13 +2671,13 @@ declare const CCConfigSchema: z.ZodObject<{
2552
2671
  args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2553
2672
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2554
2673
  }, "strip", z.ZodTypeAny, {
2555
- name: string;
2556
2674
  command: string;
2675
+ name: string;
2557
2676
  env?: Record<string, string> | undefined;
2558
2677
  args?: string[] | undefined;
2559
2678
  }, {
2560
- name: string;
2561
2679
  command: string;
2680
+ name: string;
2562
2681
  env?: Record<string, string> | undefined;
2563
2682
  args?: string[] | undefined;
2564
2683
  }>, "many">>;
@@ -2573,8 +2692,8 @@ declare const CCConfigSchema: z.ZodObject<{
2573
2692
  maxTurns: number;
2574
2693
  route: "default" | "prismer" | "omniroute";
2575
2694
  mcpServers?: {
2576
- name: string;
2577
2695
  command: string;
2696
+ name: string;
2578
2697
  env?: Record<string, string> | undefined;
2579
2698
  args?: string[] | undefined;
2580
2699
  }[] | undefined;
@@ -2587,8 +2706,8 @@ declare const CCConfigSchema: z.ZodObject<{
2587
2706
  cwd: string;
2588
2707
  model?: string | undefined;
2589
2708
  mcpServers?: {
2590
- name: string;
2591
2709
  command: string;
2710
+ name: string;
2592
2711
  env?: Record<string, string> | undefined;
2593
2712
  args?: string[] | undefined;
2594
2713
  }[] | undefined;
package/dist/index.d.ts CHANGED
@@ -130,6 +130,15 @@ interface TaskDispatchRequestPayload {
130
130
  }>;
131
131
  /** Wave-8 W1: assets cloud wants daemon to fold into agent context. */
132
132
  assetRefs?: AssetRef[];
133
+ /**
134
+ * release201/09 Phase 2 — task project scope. NULL = workspace-level
135
+ * (`_unscoped` sentinel on disk). Daemon uses this together with
136
+ * `agentImUserId` / `profile.workspaceId` to compose the per-task
137
+ * scratch path: `workspaces/<wid>/projects/<pid|_unscoped>/tasks/<tid>/`.
138
+ * Also forwarded into the spawned agent process as `PRISMER_ACTIVE_PROJECT_ID`
139
+ * (when non-null) so built-in skill --project flag defaults work.
140
+ */
141
+ projectId?: string | null;
133
142
  }
134
143
  interface TaskDispatchProgressPayload {
135
144
  taskId: string;
@@ -155,6 +164,20 @@ interface AssetDispatchObservation {
155
164
  /** L5: end-to-end fetch duration in ms (DNS + connect + body read). */
156
165
  durationMs?: number;
157
166
  }
167
+ /**
168
+ * P1-2 (2026-05-25): per-file outbox rejection record. Surfaced when daemon's
169
+ * `outbox-watcher` rejects an artifact because its magic bytes don't match
170
+ * the file extension (e.g. agent wrote `report.pdf` with markdown content).
171
+ * Cloud persists these on `IMTask.metadata.outboxRejections` and prepends a
172
+ * warning section to the next dispatch prompt so the agent can self-correct.
173
+ */
174
+ interface OutboxRejectionRecord {
175
+ filename: string;
176
+ reason: string;
177
+ inferredMime: string;
178
+ detectedMime: string;
179
+ rejectedAt: string;
180
+ }
158
181
  interface TaskDispatchReplyPayload {
159
182
  taskId: string;
160
183
  ok: boolean;
@@ -170,6 +193,13 @@ interface TaskDispatchReplyPayload {
170
193
  };
171
194
  /** Wave-8 W1: per-asset handling report. */
172
195
  assetObservability?: AssetDispatchObservation[];
196
+ /**
197
+ * P1-2 (2026-05-25): files quarantined locally by outbox-watcher's
198
+ * magic-bytes check during this turn. Cloud writes them onto
199
+ * `IMTask.metadata.outboxRejections` so the next dispatch prompt can warn
200
+ * the agent.
201
+ */
202
+ outboxRejections?: OutboxRejectionRecord[];
173
203
  }
174
204
  interface TaskCancelPayload {
175
205
  taskId: string;
@@ -677,12 +707,6 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
677
707
  * native state key directly and records the exact bridge result on the task.
678
708
  */
679
709
  mirrorNativeGoals: z.ZodDefault<z.ZodBoolean>;
680
- /**
681
- * Optional checkout path for Hermes Agent source. Used only as a fallback
682
- * when the installed `hermes` binary is older than the native Kanban CLI
683
- * surface but the local source tree contains hermes_cli/kanban_db.py.
684
- */
685
- hermesSourceDir: z.ZodOptional<z.ZodString>;
686
710
  nativeMirrorTimeoutMs: z.ZodDefault<z.ZodNumber>;
687
711
  /** Task authority level: executor (default) or orchestrator. */
688
712
  taskAuthority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["executor", "orchestrator"]>>>;
@@ -782,7 +806,6 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
782
806
  hermesProfileName?: string | undefined;
783
807
  prismerMcpServerPath?: string | undefined;
784
808
  prismerProviderBaseUrl?: string | undefined;
785
- hermesSourceDir?: string | undefined;
786
809
  mcpAllowlist?: string[] | null | undefined;
787
810
  operatingPrinciples?: string | Record<string, string> | z.objectOutputType<{
788
811
  source: z.ZodString;
@@ -823,7 +846,6 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
823
846
  prismerApiKeyEnv?: string | undefined;
824
847
  mirrorNativeKanban?: boolean | undefined;
825
848
  mirrorNativeGoals?: boolean | undefined;
826
- hermesSourceDir?: string | undefined;
827
849
  nativeMirrorTimeoutMs?: number | undefined;
828
850
  taskAuthority?: "executor" | "orchestrator" | undefined;
829
851
  approvalPolicy?: "strict" | "auto-low-risk" | "autonomous" | undefined;
@@ -994,7 +1016,7 @@ type LocalDb = Database.Database;
994
1016
  declare function openLocalDb(path: string): LocalDb;
995
1017
  declare function runMigrations(db: LocalDb): void;
996
1018
  declare function currentSchemaVersion(db: LocalDb): number;
997
- declare const TARGET_SCHEMA_VERSION = 4;
1019
+ declare const TARGET_SCHEMA_VERSION = 5;
998
1020
 
999
1021
  type SyncResourceType = 'workspace' | 'agent' | 'agent_profile';
1000
1022
  type SyncOperation = 'create' | 'update' | 'delete';
@@ -1191,11 +1213,28 @@ interface ConfigPaths {
1191
1213
  cacheDir: string;
1192
1214
  logsDir: string;
1193
1215
  /**
1194
- * Per-task run scratch dirs. Each chat-mention dispatch creates
1195
- * `${runsDir}/${taskId}/_outbox/` for adapter-produced files; the
1196
- * OutboxWatcher uploads from there into IMAssets.
1216
+ * Legacy per-task run scratch dirs (pre-release201/09).
1217
+ *
1218
+ * Pre-09: `${runsDir}/${taskId}/_outbox|workdir/`.
1219
+ * 09 Phase 2: dispatch.ts now writes to
1220
+ * `${root}/workspaces/<wid>/projects/<pid|_unscoped>/tasks/<tid>/{result,workdir}`
1221
+ * via `resolveTaskWorkdir()`. `runsDir` is kept as a fallback for tests + a
1222
+ * once-off startup migration helper (`runs/<tid>/` → new path; symlink 兜底
1223
+ * 90 天兼容期, §9.3.1).
1197
1224
  */
1198
1225
  runsDir: string;
1226
+ /**
1227
+ * release201/09 Phase 2 root for workspace × project × task scoped scratch:
1228
+ * `${root}/workspaces/`. resolveTaskWorkdir() composes the per-task path
1229
+ * underneath. Cache GC + project archive scan this root.
1230
+ */
1231
+ workspacesDir: string;
1232
+ /**
1233
+ * release201/09 Phase 2 root for device × agent role layer:
1234
+ * `${root}/devices/`. v2.0.7 Phase 2 不主动创建,Phase 3 (agent transfer)
1235
+ * 才落盘 `profile.json` / `skills/<slug>/` 等内容,本 helper 只解析路径。
1236
+ */
1237
+ devicesDir: string;
1199
1238
  }
1200
1239
  /**
1201
1240
  * Resolve paths for the prismer home directory. Honors `PRISMER_HOME` env var;
@@ -1883,6 +1922,13 @@ interface DispatchDeps {
1883
1922
  outboxWatcher?: OutboxWatcher;
1884
1923
  /** Daemon paths — used to derive the per-task outbox dir. */
1885
1924
  paths?: ConfigPaths;
1925
+ /**
1926
+ * release201/09 §9.9 — Stable device identifier from `config.toml`. Surfaced
1927
+ * to the spawned agent process as `PRISMER_DAEMON_ID` env for metric-outbox
1928
+ * emission + transfer manifest authoring. Optional so existing tests can
1929
+ * omit it; production runner always provides.
1930
+ */
1931
+ daemonId?: string;
1886
1932
  /**
1887
1933
  * Multi-workspace asset metadata indexes for #filename resolution.
1888
1934
  * Keyed by workspaceId. If absent, #ref resolution is skipped entirely.
@@ -2085,6 +2131,40 @@ interface LocalServerOptions {
2085
2131
  * When set, /healthz reports `assetReady: true`.
2086
2132
  */
2087
2133
  attachAsset?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
2134
+ /**
2135
+ * Optional first-pass handler for `/v1/hooks/*` routes (v2.1 §9.5
2136
+ * daemon-as-hook-intake). Returns true if the request was handled
2137
+ * (response written); false to let the normal route table fall through.
2138
+ * Wired by the daemon runner from `attachHookServer()` in
2139
+ * `daemon/memory/hook-server.ts` whenever both memory + run-session
2140
+ * registry are available. When set, /healthz reports `hooksReady: true`.
2141
+ */
2142
+ attachHooks?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
2143
+ /**
2144
+ * Optional first-pass handler for `/v1/checkpoints/*` routes
2145
+ * (release201/09 §9.4a.7 task product self-check). Independent of
2146
+ * `attachHooks` — checkpoints fire on SDK status-transition only, while
2147
+ * hooks fire per LLM call. Wired by the runner from
2148
+ * `attachCheckpointServer()` in `daemon/checkpoint-server.ts`. When set,
2149
+ * /healthz reports `checkpointsReady: true`.
2150
+ */
2151
+ attachCheckpoints?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
2152
+ /**
2153
+ * Optional snapshot getter for the eval-session capability
2154
+ * (release201/08 §7.2). When provided, /healthz reports `evalSessions`
2155
+ * with the current active count + per-run summaries. The runner wires
2156
+ * this from `EvalSessionRunner.getState()`.
2157
+ */
2158
+ getEvalSessions?: () => {
2159
+ active: number;
2160
+ queued: number;
2161
+ maxConcurrent: number;
2162
+ runs: Array<{
2163
+ runId: string;
2164
+ skillId: string;
2165
+ startedAt: string;
2166
+ }>;
2167
+ };
2088
2168
  }
2089
2169
  interface AssetWriteHandlerResult {
2090
2170
  status: 200 | 400 | 502;
@@ -2299,6 +2379,7 @@ declare class Runner extends EventEmitter {
2299
2379
  private localServer?;
2300
2380
  private outboxWatcher?;
2301
2381
  private memoryWiring?;
2382
+ private runSessionRegistry?;
2302
2383
  private assetMetadataIndexes;
2303
2384
  private workspaceMirrors;
2304
2385
  private assetOriginOutbox?;
@@ -2321,10 +2402,21 @@ declare class Runner extends EventEmitter {
2321
2402
  private taskReaperTimer?;
2322
2403
  private skillResyncTimer?;
2323
2404
  private skillSyncInFlight;
2405
+ private resumeInFlightTimer?;
2406
+ private resumeInFlightDone;
2324
2407
  private pendingReplyCache;
2325
2408
  private pendingReplyRecoveryDone;
2326
2409
  constructor(opts?: RunnerOptions);
2327
2410
  start(): Promise<void>;
2411
+ /**
2412
+ * v2.1 §9.5 — build a ProfileResolver backed by the daemon's local
2413
+ * `agent_profiles` mirror. Used by the hook server to translate
2414
+ * `?profile=<name>` query into agentImUserId + workspaceId + role slug
2415
+ * when the run-session registry doesn't yet have the run mapping
2416
+ * (e.g. for the very first pre_llm_call of a session, before the
2417
+ * adapter has had a chance to call register()).
2418
+ */
2419
+ private buildProfileResolver;
2328
2420
  /**
2329
2421
  * F16 (2026-05-20) — enumerate every non-deleted local agent_profile and
2330
2422
  * fan-out `syncInstalledSkillsForDispatch` via `syncAllAgentSkills`.
@@ -2334,6 +2426,33 @@ declare class Runner extends EventEmitter {
2334
2426
  private syncAllSkillsBackground;
2335
2427
  /** F16 — read all live agent_profiles from local DB → AgentProfile[]. */
2336
2428
  private loadAllProfiles;
2429
+ /**
2430
+ * P0-2 (2026-05-25) — daemon cold-start sweep.
2431
+ *
2432
+ * Pulls `IMTaskRun.status='running'` rows where the bound daemon (via
2433
+ * `IMAgentBinding.boundDaemonId`) is this daemon, then re-enqueues each
2434
+ * via the same `onTaskDispatch` handler the ws path uses. Replaces the
2435
+ * slow (~5min) cloud-side `sweepTimedOut()` fallback for pod restarts.
2436
+ *
2437
+ * Idempotent on the daemon side: `onTaskDispatch` dedupes by taskId
2438
+ * against `runningTasks`, so any task that happened to be redispatched
2439
+ * from cloud immediately after our reconnect (via redispatchPending on
2440
+ * the agent.host.declare path) won't double-trigger here.
2441
+ *
2442
+ * Caveat: if the agent was mid-LLM-call when the daemon crashed, the
2443
+ * resumed dispatch starts the call from scratch — token cost duplicated.
2444
+ * We accept that vs the alternative (5min of silence + cloud marks the
2445
+ * run `failed` without any retry).
2446
+ */
2447
+ private resumeInFlightTasks;
2448
+ /**
2449
+ * Rebuild a `task.dispatch.request` payload from an in-flight IMTaskRun
2450
+ * row + its parent IMTask. Mirrors what cloud-side
2451
+ * v19x-helpers.buildTaskDispatchRequest does, with one extra field:
2452
+ * `metadata.resumed = true` so downstream prompt injection can note
2453
+ * this is a recovery dispatch.
2454
+ */
2455
+ private reconstructDispatchPayload;
2337
2456
  stop(): Promise<void>;
2338
2457
  isRunning(): boolean;
2339
2458
  /**
@@ -2552,13 +2671,13 @@ declare const CCConfigSchema: z.ZodObject<{
2552
2671
  args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2553
2672
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2554
2673
  }, "strip", z.ZodTypeAny, {
2555
- name: string;
2556
2674
  command: string;
2675
+ name: string;
2557
2676
  env?: Record<string, string> | undefined;
2558
2677
  args?: string[] | undefined;
2559
2678
  }, {
2560
- name: string;
2561
2679
  command: string;
2680
+ name: string;
2562
2681
  env?: Record<string, string> | undefined;
2563
2682
  args?: string[] | undefined;
2564
2683
  }>, "many">>;
@@ -2573,8 +2692,8 @@ declare const CCConfigSchema: z.ZodObject<{
2573
2692
  maxTurns: number;
2574
2693
  route: "default" | "prismer" | "omniroute";
2575
2694
  mcpServers?: {
2576
- name: string;
2577
2695
  command: string;
2696
+ name: string;
2578
2697
  env?: Record<string, string> | undefined;
2579
2698
  args?: string[] | undefined;
2580
2699
  }[] | undefined;
@@ -2587,8 +2706,8 @@ declare const CCConfigSchema: z.ZodObject<{
2587
2706
  cwd: string;
2588
2707
  model?: string | undefined;
2589
2708
  mcpServers?: {
2590
- name: string;
2591
2709
  command: string;
2710
+ name: string;
2592
2711
  env?: Record<string, string> | undefined;
2593
2712
  args?: string[] | undefined;
2594
2713
  }[] | undefined;