@adhdev/mesh-shared 1.0.82-rc.1 → 1.0.82-rc.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/assistant-protocol.d.ts +163 -6
  2. package/dist/decision-push-relay.d.ts +20 -0
  3. package/dist/index.d.ts +13 -0
  4. package/dist/index.js +1683 -120
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1540 -120
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/launch-defaults.d.ts +196 -0
  9. package/dist/light-task.d.ts +96 -0
  10. package/dist/mesh-tool-names.d.ts +2 -2
  11. package/dist/mesh-vocabulary.d.ts +13 -4
  12. package/dist/mission-git-state.d.ts +83 -0
  13. package/dist/mission-items.d.ts +202 -0
  14. package/dist/node-facts.d.ts +75 -1
  15. package/dist/outbound-message.d.ts +9 -2
  16. package/dist/path-ownership.d.ts +1 -1
  17. package/dist/protocol/daemon-server.d.ts +42 -2
  18. package/dist/protocol/dashboard-daemon-p2p.d.ts +1 -1
  19. package/dist/protocol/dashboard-server.d.ts +20 -2
  20. package/dist/provider-approval.d.ts +36 -0
  21. package/dist/provider-question.d.ts +19 -0
  22. package/dist/quota-freshness.d.ts +65 -0
  23. package/dist/relay-reprobe.d.ts +52 -0
  24. package/dist/release.d.ts +90 -0
  25. package/dist/role-launch.d.ts +11 -0
  26. package/dist/session-launch.d.ts +10 -22
  27. package/dist/slot-proposal.d.ts +14 -0
  28. package/dist/task-source-phase.d.ts +83 -0
  29. package/dist/task-stages.d.ts +208 -0
  30. package/dist/turn-evidence.d.ts +43 -13
  31. package/dist/turn-ipc-mission.d.ts +72 -1
  32. package/dist/turn-ipc-queue.d.ts +30 -0
  33. package/dist/turn-ipc.d.ts +2 -2
  34. package/dist/types.d.ts +1 -0
  35. package/dist/worker-protocol.d.ts +41 -1
  36. package/package.json +1 -1
  37. package/src/assistant-protocol.ts +306 -6
  38. package/src/daemon-normalize.ts +7 -5
  39. package/src/decision-push-relay.ts +23 -0
  40. package/src/index.ts +14 -0
  41. package/src/keyed-doc-delta.ts +9 -1
  42. package/src/launch-defaults.ts +170 -0
  43. package/src/light-task.ts +116 -0
  44. package/src/mesh-tool-names.ts +22 -0
  45. package/src/mesh-vocabulary.ts +12 -2
  46. package/src/mission-git-state.ts +112 -0
  47. package/src/mission-items.ts +421 -0
  48. package/src/node-facts.ts +70 -1
  49. package/src/outbound-message.ts +19 -0
  50. package/src/path-ownership.ts +4 -6
  51. package/src/protocol/daemon-server.ts +37 -2
  52. package/src/protocol/dashboard-server.ts +13 -2
  53. package/src/provider-approval.ts +59 -0
  54. package/src/provider-question.ts +31 -0
  55. package/src/quota-freshness.ts +139 -0
  56. package/src/relay-reprobe.ts +117 -0
  57. package/src/release.ts +121 -0
  58. package/src/role-launch.ts +51 -0
  59. package/src/session-launch.ts +17 -1
  60. package/src/slot-proposal.ts +61 -2
  61. package/src/task-source-phase.ts +70 -0
  62. package/src/task-stages.ts +457 -0
  63. package/src/turn-evidence.ts +56 -20
  64. package/src/turn-ipc-mission.ts +127 -11
  65. package/src/turn-ipc-queue.ts +45 -2
  66. package/src/turn-ipc-turn.ts +1 -1
  67. package/src/turn-ipc.ts +1 -0
  68. package/src/types.ts +1 -0
  69. package/src/worker-protocol.ts +94 -0
package/dist/index.mjs CHANGED
@@ -194,15 +194,15 @@ function pickBestTransitGitStatus(node, options) {
194
194
  }
195
195
 
196
196
  // src/session-normalize.ts
197
- function deriveSyntheticSessionId(record) {
197
+ function deriveSyntheticSessionId(record2) {
198
198
  const parts = [
199
- readString(record.workspace),
200
- readString(record.providerType, record.provider),
201
- readString(record.role),
202
- readString(record.state, record.status),
203
- readString(record.title),
204
- readString(record.createdAt, record.created_at),
205
- readString(record.startedAt, record.started_at)
199
+ readString(record2.workspace),
200
+ readString(record2.providerType, record2.provider),
201
+ readString(record2.role),
202
+ readString(record2.state, record2.status),
203
+ readString(record2.title),
204
+ readString(record2.createdAt, record2.created_at),
205
+ readString(record2.startedAt, record2.started_at)
206
206
  ].filter((part) => Boolean(part));
207
207
  if (parts.length === 0) return void 0;
208
208
  return `synthetic:${parts.join("|")}`;
@@ -214,33 +214,33 @@ function sessionIdsEquivalent(a, b) {
214
214
  return idA === idB;
215
215
  }
216
216
  function normalizeMeshSessionRecord(entry) {
217
- const record = readRecord(entry);
218
- const sessionId = readString(record.sessionId, record.session_id, record.id) ?? deriveSyntheticSessionId(record);
217
+ const record2 = readRecord(entry);
218
+ const sessionId = readString(record2.sessionId, record2.session_id, record2.id) ?? deriveSyntheticSessionId(record2);
219
219
  if (!sessionId) return null;
220
220
  return {
221
221
  sessionId,
222
- ...readString(record.providerType, record.provider) ? { providerType: readString(record.providerType, record.provider) } : {},
223
- ...readString(record.state, record.status) ? { state: readString(record.state, record.status) } : {},
224
- ...readString(record.chatStatus, record.chat_status) ? { chatStatus: readString(record.chatStatus, record.chat_status) } : {},
225
- ...readString(record.lifecycle) ? { lifecycle: readString(record.lifecycle) } : {},
226
- ...readString(record.surfaceKind, record.surface_kind) ? { surfaceKind: readString(record.surfaceKind, record.surface_kind) } : {},
227
- ...readString(record.recoveryState, record.recovery_state) ? { recoveryState: readString(record.recoveryState, record.recovery_state) } : {},
228
- ...readString(record.workspace) ? { workspace: readString(record.workspace) } : {},
229
- ...readString(record.title) ? { title: readString(record.title) } : {},
230
- ...readString(record.role) ? { role: readString(record.role) } : {},
231
- ...readBoolean(record.isSelfCoordinator, record.is_self_coordinator) !== void 0 ? { isSelfCoordinator: readBoolean(record.isSelfCoordinator, record.is_self_coordinator) } : {},
232
- ...readString(record.statusNote, record.status_note) ? { statusNote: readString(record.statusNote, record.status_note) } : {},
233
- ...readString(record.createdAt, record.created_at) ? { createdAt: readString(record.createdAt, record.created_at) } : {},
234
- ...readString(record.startedAt, record.started_at) ? { startedAt: readString(record.startedAt, record.started_at) } : {},
235
- ...readString(record.lastActivityAt, record.last_activity_at) ? { lastActivityAt: readString(record.lastActivityAt, record.last_activity_at) } : {},
236
- ...readBoolean(record.isCached, record.is_cached) !== void 0 ? { isCached: readBoolean(record.isCached, record.is_cached) } : {}
222
+ ...readString(record2.providerType, record2.provider) ? { providerType: readString(record2.providerType, record2.provider) } : {},
223
+ ...readString(record2.state, record2.status) ? { state: readString(record2.state, record2.status) } : {},
224
+ ...readString(record2.chatStatus, record2.chat_status) ? { chatStatus: readString(record2.chatStatus, record2.chat_status) } : {},
225
+ ...readString(record2.lifecycle) ? { lifecycle: readString(record2.lifecycle) } : {},
226
+ ...readString(record2.surfaceKind, record2.surface_kind) ? { surfaceKind: readString(record2.surfaceKind, record2.surface_kind) } : {},
227
+ ...readString(record2.recoveryState, record2.recovery_state) ? { recoveryState: readString(record2.recoveryState, record2.recovery_state) } : {},
228
+ ...readString(record2.workspace) ? { workspace: readString(record2.workspace) } : {},
229
+ ...readString(record2.title) ? { title: readString(record2.title) } : {},
230
+ ...readString(record2.role) ? { role: readString(record2.role) } : {},
231
+ ...readBoolean(record2.isSelfCoordinator, record2.is_self_coordinator) !== void 0 ? { isSelfCoordinator: readBoolean(record2.isSelfCoordinator, record2.is_self_coordinator) } : {},
232
+ ...readString(record2.statusNote, record2.status_note) ? { statusNote: readString(record2.statusNote, record2.status_note) } : {},
233
+ ...readString(record2.createdAt, record2.created_at) ? { createdAt: readString(record2.createdAt, record2.created_at) } : {},
234
+ ...readString(record2.startedAt, record2.started_at) ? { startedAt: readString(record2.startedAt, record2.started_at) } : {},
235
+ ...readString(record2.lastActivityAt, record2.last_activity_at) ? { lastActivityAt: readString(record2.lastActivityAt, record2.last_activity_at) } : {},
236
+ ...readBoolean(record2.isCached, record2.is_cached) !== void 0 ? { isCached: readBoolean(record2.isCached, record2.is_cached) } : {}
237
237
  };
238
238
  }
239
239
 
240
240
  // src/node-normalize.ts
241
241
  function normalizeMeshNodeId(node) {
242
- const record = node && typeof node === "object" ? node : {};
243
- return readString(record.id, record.nodeId, record.node_id);
242
+ const record2 = node && typeof node === "object" ? node : {};
243
+ return readString(record2.id, record2.nodeId, record2.node_id);
244
244
  }
245
245
  function meshNodeIdMatches(node, candidateId) {
246
246
  if (!candidateId) return false;
@@ -252,12 +252,12 @@ function meshNodeIdMatches(node, candidateId) {
252
252
  // src/node-facts.ts
253
253
  function normalizeMeshNodeFacts(raw) {
254
254
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
255
- const record = raw;
256
- const schemaVersion = Number(record.schemaVersion);
257
- const reportedAt = Number(record.reportedAt);
255
+ const record2 = raw;
256
+ const schemaVersion = Number(record2.schemaVersion);
257
+ const reportedAt = Number(record2.reportedAt);
258
258
  if (!Number.isFinite(schemaVersion) || schemaVersion < 1) return void 0;
259
259
  if (!Number.isFinite(reportedAt) || reportedAt <= 0) return void 0;
260
- return { ...record, schemaVersion, reportedAt };
260
+ return { ...record2, schemaVersion, reportedAt };
261
261
  }
262
262
  var QUOTA_SUPPORTED_PROVIDERS = [
263
263
  "antigravity-cli",
@@ -300,6 +300,52 @@ function defaultProviderPriorityFromNodeFacts(facts) {
300
300
  return orderProvidersByBuiltinPreference(detected.length ? detected : enabled);
301
301
  }
302
302
 
303
+ // src/quota-freshness.ts
304
+ var QUOTA_RETRY_INFLIGHT_GRACE_MS = 6e4;
305
+ var QUOTA_BACKFILL_HORIZON_MS = 60 * 60 * 1e3;
306
+ function hasUsableWindow(window) {
307
+ return !!window && typeof window.usedPercent === "number" && Number.isFinite(window.usedPercent);
308
+ }
309
+ function hasReading(quota) {
310
+ if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly) || hasUsableWindow(quota.monthly)) return true;
311
+ return Array.isArray(quota.buckets) && quota.buckets.some((b) => !!b && typeof b.usedPercent === "number" && Number.isFinite(b.usedPercent));
312
+ }
313
+ function finiteMs(value) {
314
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
315
+ }
316
+ function backfillCheckAt(quota, now) {
317
+ const dataDue = finiteMs(quota.updatedAt);
318
+ const attempted = finiteMs(quota.metadata?.fetchedAt);
319
+ const dueAt = Math.max(
320
+ dataDue === void 0 ? Number.NEGATIVE_INFINITY : dataDue + QUOTA_BACKFILL_HORIZON_MS,
321
+ attempted === void 0 ? Number.NEGATIVE_INFINITY : attempted + QUOTA_BACKFILL_HORIZON_MS
322
+ );
323
+ return Number.isFinite(dueAt) && dueAt > now ? dueAt : void 0;
324
+ }
325
+ function assessQuotaFreshness(quota, now = Date.now()) {
326
+ const meta = quota.metadata;
327
+ const kind = meta?.failureKind;
328
+ const userMustAct = kind === "no-data" && quota.provider !== "codex-cli";
329
+ const awaitsCliUse = kind === "expired-token" && ["grok-cli", "kimi", "antigravity-cli"].includes(quota.provider);
330
+ if (userMustAct) return hasReading(quota) ? { cue: "stale", userMustAct: true } : { userMustAct: true };
331
+ if (awaitsCliUse) return hasReading(quota) ? { cue: "stale", userMustAct: false } : { userMustAct: false };
332
+ if (meta?.lastGoodWindows !== true) {
333
+ const measuredAt = finiteMs(quota.updatedAt);
334
+ if (hasReading(quota) && (measuredAt === void 0 || now - measuredAt >= QUOTA_BACKFILL_HORIZON_MS)) {
335
+ return { cue: "stale", userMustAct };
336
+ }
337
+ return { userMustAct };
338
+ }
339
+ const retryAtMs = finiteMs(meta?.retryAtMs);
340
+ const retryStopped = meta?.retryExhausted === true || retryAtMs !== void 0 && retryAtMs + QUOTA_RETRY_INFLIGHT_GRACE_MS < now;
341
+ if (kind !== "no-data" && !retryStopped) return { cue: "refreshing", userMustAct: false };
342
+ const nextCheckAt = backfillCheckAt(quota, now);
343
+ return nextCheckAt === void 0 ? { cue: "stale", userMustAct: false } : { cue: "stale", userMustAct: false, nextCheckAt };
344
+ }
345
+ function minutesUntilQuotaCheck(nextCheckAt, now = Date.now()) {
346
+ return Math.max(1, Math.round((nextCheckAt - now) / 6e4));
347
+ }
348
+
303
349
  // src/workspace-normalize.ts
304
350
  function normalizeMeshWorkspaceForCompare(dir) {
305
351
  if (typeof dir !== "string") return "";
@@ -329,19 +375,21 @@ function isPhantomDaemonEntry(entry) {
329
375
  function machineCoreFromDaemonId(id2) {
330
376
  const trimmed = readString(id2);
331
377
  if (!trimmed) return void 0;
378
+ const lower = trimmed.toLowerCase();
332
379
  for (const prefix of DAEMON_ID_PREFIXES) {
333
- if (trimmed.startsWith(prefix)) {
380
+ if (lower.startsWith(prefix)) {
334
381
  const core = trimmed.slice(prefix.length).trim();
335
- return core || void 0;
382
+ if (!core) return void 0;
383
+ return /^mach_/i.test(core) ? `mach_${core.slice(5)}` : core;
336
384
  }
337
385
  }
338
- return trimmed;
386
+ return /^mach_/i.test(trimmed) ? `mach_${trimmed.slice(5)}` : trimmed;
339
387
  }
340
388
  function canonicalDaemonId(id2) {
341
389
  const core = machineCoreFromDaemonId(id2);
342
390
  if (!core) return void 0;
343
- if (!core.startsWith("mach_")) return core;
344
- return `daemon_${core}`;
391
+ if (!/^mach_/i.test(core)) return core;
392
+ return `daemon_mach_${core.slice(5)}`;
345
393
  }
346
394
  function daemonIdsEquivalent(a, b) {
347
395
  const coreA = machineCoreFromDaemonId(a);
@@ -370,9 +418,9 @@ function expandDaemonIdForms(ids) {
370
418
 
371
419
  // src/git-summarize.ts
372
420
  function summarizeGitShape(status) {
373
- const record = readRecord(status);
374
- if (!Object.keys(record).length) return null;
375
- const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
421
+ const record2 = readRecord(status);
422
+ if (!Object.keys(record2).length) return null;
423
+ const submodules = Array.isArray(record2.submodules) ? record2.submodules.map((entry) => {
376
424
  const sub = readRecord(entry);
377
425
  return {
378
426
  path: readString(sub.path) ?? null,
@@ -382,23 +430,23 @@ function summarizeGitShape(status) {
382
430
  };
383
431
  }) : [];
384
432
  return {
385
- isGitRepo: readBoolean(record.isGitRepo),
386
- workspace: readString(record.workspace) ?? null,
387
- repoRoot: readString(record.repoRoot, record.repo_root) ?? null,
388
- branch: readString(record.branch) ?? null,
389
- upstream: readString(record.upstream) ?? null,
390
- upstreamStatus: readString(record.upstreamStatus, record.upstream_status) ?? null,
391
- headCommit: readString(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
392
- ahead: readNumber(record.ahead) ?? null,
393
- behind: readNumber(record.behind) ?? null,
433
+ isGitRepo: readBoolean(record2.isGitRepo),
434
+ workspace: readString(record2.workspace) ?? null,
435
+ repoRoot: readString(record2.repoRoot, record2.repo_root) ?? null,
436
+ branch: readString(record2.branch) ?? null,
437
+ upstream: readString(record2.upstream) ?? null,
438
+ upstreamStatus: readString(record2.upstreamStatus, record2.upstream_status) ?? null,
439
+ headCommit: readString(record2.headCommit, record2.head_commit)?.slice(0, 12) ?? null,
440
+ ahead: readNumber(record2.ahead) ?? null,
441
+ behind: readNumber(record2.behind) ?? null,
394
442
  dirtyCounts: {
395
- staged: readNumber(record.staged) ?? 0,
396
- modified: readNumber(record.modified) ?? 0,
397
- untracked: readNumber(record.untracked) ?? 0,
398
- deleted: readNumber(record.deleted) ?? 0,
399
- renamed: readNumber(record.renamed) ?? 0
443
+ staged: readNumber(record2.staged) ?? 0,
444
+ modified: readNumber(record2.modified) ?? 0,
445
+ untracked: readNumber(record2.untracked) ?? 0,
446
+ deleted: readNumber(record2.deleted) ?? 0,
447
+ renamed: readNumber(record2.renamed) ?? 0
400
448
  },
401
- lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
449
+ lastCheckedAt: readNumber(record2.lastCheckedAt, record2.last_checked_at) ?? null,
402
450
  submoduleCount: submodules.length,
403
451
  submodules
404
452
  };
@@ -564,10 +612,25 @@ var CLI_SLOT_RECIPES = Object.freeze({
564
612
  ],
565
613
  "antigravity-cli": [
566
614
  {
567
- model: "Gemini 3.1 Pro (High)",
615
+ model: "Gemini 3.8 Flash (High)",
616
+ modelCandidates: ["Gemini 3.8 Flash (High)", "Gemini 4 Argon (Low)", "Gemini 3.7 Flash (High)", "Gemini 3.1 Pro (High)"],
568
617
  difficulty: ["easy"],
569
618
  maxParallel: 2,
570
619
  rationale: "Cheap capacity for easy tasks."
620
+ },
621
+ {
622
+ model: "Gemini 4 Argon (Medium)",
623
+ modelCandidates: ["Gemini 4 Argon (Medium)", "Gemini 3.8 Flash (High)", "Gemini 3.7 Flash (High)", "Gemini 3.1 Pro (High)"],
624
+ difficulty: ["medium"],
625
+ maxParallel: 2,
626
+ rationale: "Balanced Argon tier for medium tasks."
627
+ },
628
+ {
629
+ model: "Gemini 4 Argon (High)",
630
+ modelCandidates: ["Gemini 4 Argon (High)", "Gemini 3.8 Flash (High)", "Gemini 3.1 Pro (High)"],
631
+ difficulty: ["difficult"],
632
+ maxParallel: 1,
633
+ rationale: "Reserved for hard tasks; capped at 1 to bound cost."
571
634
  }
572
635
  ],
573
636
  "cursor-cli": [
@@ -606,6 +669,24 @@ function dedupeDetected(detected) {
606
669
  }
607
670
  return out;
608
671
  }
672
+ function resolveRecipeModel(recipe, modelOptions) {
673
+ if (!Array.isArray(modelOptions) || modelOptions.length === 0) {
674
+ return recipe.model;
675
+ }
676
+ const available = new Set(
677
+ modelOptions.filter((m) => typeof m === "string" && m.trim().length > 0).map((m) => m.trim())
678
+ );
679
+ if (available.size === 0) return recipe.model;
680
+ const candidates = [
681
+ ...recipe.model ? [recipe.model] : [],
682
+ ...recipe.modelCandidates ?? []
683
+ ];
684
+ for (const candidate of candidates) {
685
+ const trimmed = typeof candidate === "string" ? candidate.trim() : "";
686
+ if (trimmed && available.has(trimmed)) return trimmed;
687
+ }
688
+ return recipe.model;
689
+ }
609
690
  function buildSlotProposal(detected, currentSlots = []) {
610
691
  const providers = dedupeDetected(detected ?? []);
611
692
  const proposedSlots = [];
@@ -621,7 +702,7 @@ function buildSlotProposal(detected, currentSlots = []) {
621
702
  for (const recipe of recipes) {
622
703
  const slot = normalizeNodeCapabilitySlot({
623
704
  provider: provider.type,
624
- model: recipe.model,
705
+ model: resolveRecipeModel(recipe, provider.modelOptions),
625
706
  thinkingLevel: recipe.thinkingLevel,
626
707
  difficulty: recipe.difficulty,
627
708
  maxParallel: recipe.maxParallel
@@ -674,7 +755,12 @@ var CANONICAL_MESH_TOOL_NAMES = [
674
755
  "mesh_enqueue_task",
675
756
  "mesh_view_queue",
676
757
  "mesh_queue_cancel",
758
+ "mesh_task_stage_decide",
759
+ "mesh_direct_cancel",
677
760
  "mesh_queue_requeue",
761
+ "mesh_queue_revise",
762
+ "mesh_light_land",
763
+ "mesh_light_discard",
678
764
  "mesh_send_task",
679
765
  "mesh_read_chat",
680
766
  "mesh_read_debug",
@@ -691,8 +777,13 @@ var CANONICAL_MESH_TOOL_NAMES = [
691
777
  "mesh_list_pending_approvals",
692
778
  "mesh_create",
693
779
  "mesh_add_node",
780
+ "mesh_reattach_source_parent",
781
+ "mesh_attach_remote",
782
+ "mesh_host_pairing",
694
783
  "mesh_clone_node",
695
784
  "mesh_remove_node",
785
+ "mesh_retry_node_bootstrap",
786
+ "mesh_recover_node_identity",
696
787
  "mesh_cleanup_worktree_nodes",
697
788
  "mesh_refine_node",
698
789
  "mesh_refine_batch",
@@ -709,8 +800,20 @@ var CANONICAL_MESH_TOOL_NAMES = [
709
800
  "mesh_reconcile_ledger",
710
801
  "mesh_mission_upsert",
711
802
  "mesh_mission_list",
803
+ "mesh_mission_git_eval",
804
+ "mesh_release_upsert",
805
+ "mesh_release_scope",
806
+ "mesh_release_list",
807
+ "mesh_release_record_deploy",
808
+ "mesh_release_changelog_draft",
809
+ "mesh_file_transfer",
712
810
  "mesh_review_inbox",
713
- "mesh_node_slots"
811
+ "mesh_node_slots",
812
+ "driver_list",
813
+ "driver_describe",
814
+ "artifact_list",
815
+ "artifact_read",
816
+ "artifact_register"
714
817
  ];
715
818
  var CANONICAL_MESH_TOOL_COUNT = CANONICAL_MESH_TOOL_NAMES.length;
716
819
  var RETIRED_MESH_TOOLS = {
@@ -1020,9 +1123,15 @@ var DAEMON_STATUS_EVENT_NAMES = [
1020
1123
  "agent:waiting_choice",
1021
1124
  "agent:generating_completed",
1022
1125
  "agent:stopped",
1023
- "monitor:no_progress"
1126
+ "monitor:no_progress",
1127
+ // An owner decision (structured missions) needs the owner. Server-bound for the push only;
1128
+ // the dashboard learns about decisions over P2P (`mission_decisions_list`).
1129
+ "agent:decision_needed"
1024
1130
  ];
1025
1131
  var isDaemonStatusEventName = makeTypeGuard(DAEMON_STATUS_EVENT_NAMES);
1132
+ var DECISION_PUSH_QUESTION_MAX = 80;
1133
+ var DECISION_PUSH_OPTION_LABEL_MAX = 24;
1134
+ var DECISION_PUSH_OPTIONS_MAX = 3;
1026
1135
  var RELEASE_CHANNELS = ["stable", "preview"];
1027
1136
  var NPM_UPDATE_TAGS = ["latest", "next"];
1028
1137
  var VERSION_UPDATE_REASONS = ["force_update_below", "major_minor_mismatch", "patch_mismatch", "daemon_ahead"];
@@ -1385,21 +1494,22 @@ function isTerminalSessionRecordStatus(raw) {
1385
1494
  return typeof raw === "string" && TERMINAL_SESSION_RECORD_STATUSES.includes(raw.trim().toLowerCase());
1386
1495
  }
1387
1496
  function isIdleSessionState(state) {
1388
- const record = state && typeof state === "object" ? state : {};
1389
- const status = typeof record.status === "string" ? record.status.trim().toLowerCase() : "";
1497
+ const record2 = state && typeof state === "object" ? state : {};
1498
+ const status = typeof record2.status === "string" ? record2.status.trim().toLowerCase() : "";
1390
1499
  if (isTerminalSessionRecordStatus(status) || isDeadStatus(status)) return false;
1391
- return isReadyStatus(status) || record.activeChat?.status === "waiting_input";
1500
+ return isReadyStatus(status) || record2.activeChat?.status === "waiting_input";
1392
1501
  }
1393
1502
 
1394
1503
  // src/mesh-vocabulary.ts
1395
- var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
1396
- var MESH_TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled"];
1504
+ var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "blocked", "failed", "cancelled"];
1505
+ var MESH_TERMINAL_TASK_STATUSES = ["completed", "blocked", "failed", "cancelled"];
1397
1506
  var MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
1398
1507
  var MESH_TASK_PRIORITIES = ["low", "normal", "high"];
1399
1508
  var MESH_THINKING_LEVELS = ["low", "medium", "high"];
1400
1509
  var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
1401
1510
  var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
1402
1511
  var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
1512
+ var WORKER_REPORT_SUMMARY_MAX_CHARS = 8e3;
1403
1513
  var WORKER_BRANCH_STATES = [
1404
1514
  "merged_to_main",
1405
1515
  "pushed_feature_branch_needs_merge",
@@ -1466,6 +1576,7 @@ var SEND_REFUSAL_REASONS = [
1466
1576
  "no_target",
1467
1577
  "bootstrap_pending",
1468
1578
  "duplicate_dispatch",
1579
+ "new_work_held",
1469
1580
  "internal_error"
1470
1581
  ];
1471
1582
  function isSendRefusal(value) {
@@ -1497,6 +1608,14 @@ function isOutboundMessage(value) {
1497
1608
  const candidate = value;
1498
1609
  return isMessageId(candidate.messageId) && typeof candidate.sessionId === "string" && candidate.sessionId.length > 0 && isInputEnvelopeWire(candidate.input) && isOutboundMessageOrigin(candidate.origin) && isSendPolicy(candidate.policy) && typeof candidate.createdAt === "number";
1499
1610
  }
1611
+ var PASTED_OPEN_RE = /^\s*<pasted_content(?:\s+id="[^"]*")?\s*>\s*$/;
1612
+ var PASTED_CLOSE_RE = /^\s*<\/pasted_content(?:\s+id="[^"]*")?\s*>\s*$/;
1613
+ function unwrapPastedContent(text) {
1614
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
1615
+ const first = lines.findIndex((line) => line.trim());
1616
+ if (first < 0 || !PASTED_OPEN_RE.test(lines[first])) return text;
1617
+ return lines.filter((line) => !PASTED_OPEN_RE.test(line) && !PASTED_CLOSE_RE.test(line)).join("\n");
1618
+ }
1500
1619
 
1501
1620
  // src/mission-brief.ts
1502
1621
  var GOAL_MAX = 500;
@@ -1582,13 +1701,39 @@ var WORKER_TOOLS = [
1582
1701
  "peer_context_pull",
1583
1702
  "git_status",
1584
1703
  "git_log",
1585
- "git_diff"
1704
+ "git_diff",
1705
+ "driver_list",
1706
+ "driver_describe",
1707
+ "driver_invoke",
1708
+ "driver_scaffold",
1709
+ "driver_validate",
1710
+ "driver_export",
1711
+ "driver_install",
1712
+ "artifact_register",
1713
+ "artifact_list",
1714
+ "artifact_read",
1715
+ // Contract versioning (Cut A): exact pinned-unit reads (E2), the explicit
1716
+ // read claim (C1) and the authoritative head/notice pull.
1717
+ "contract_read",
1718
+ "contract_observe",
1719
+ "contract_current"
1586
1720
  ];
1587
1721
  var WORKER_TOOL_SET = new Set(WORKER_TOOLS);
1588
1722
  function isWorkerTool(value) {
1589
1723
  return typeof value === "string" && WORKER_TOOL_SET.has(value);
1590
1724
  }
1591
1725
  var WORKER_PROTOCOL_FOOTER_MARKER = "--- adhdev worker protocol ---";
1726
+ function renderLightWorkspaceRules(light) {
1727
+ const base = light.ossBaseSha ? `${light.baseSha} (oss ${light.ossBaseSha})` : light.baseSha;
1728
+ return [
1729
+ `You are working in a temporary light workspace at \`${light.workspace}\` based on \`${base}\`. Work only inside it. Commit your change there (the branch is already set up); do not push.`,
1730
+ "Do not run `npm install`/`npm ci`/`npm rebuild`/`node-gyp`, do not change package.json or lockfiles \u2014 if the fix needs a dependency change, stop and report `blocked`.",
1731
+ "Do not start long-running servers on fixed ports. Run the narrowest tests that cover your change and list them in `report_completion.testsRun`.",
1732
+ light.ownedPaths.length ? `Stay inside \`owned_paths\` (${light.ownedPaths.join(", ")}); if you must touch more, say why in the summary.` : "Stay inside the paths the task names; if you must touch more, say why in the summary."
1733
+ ];
1734
+ }
1735
+ var WORKER_CURRENT_BRANCH_RULE = "Commit your change on the branch that is currently checked out in this workspace. Do not create or switch branches (no `git checkout -b` / `git switch`) unless the task explicitly says to; report the branch you committed on.";
1736
+ var WORKER_SHELL_LITERAL_PATHS_RULE = "In shell commands, write file and directory paths literally (absolute, or relative to your workspace) instead of through shell variables (`N=dir; cat $N/x`) or `$(...)` substitutions, and keep to one simple command per call, so the command can be checked before it runs. This does not change what you are allowed to run or read.";
1592
1737
  function hasWorkerProtocolFooter(body) {
1593
1738
  return typeof body === "string" && body.includes(WORKER_PROTOCOL_FOOTER_MARKER);
1594
1739
  }
@@ -1610,6 +1755,9 @@ function renderWorkerProtocolFooter(input = {}) {
1610
1755
  if (input.readonly) scope.push("read-only");
1611
1756
  if (scope.length) lines.push(`You are a delegated worker (${scope.join(", ")}).`);
1612
1757
  else lines.push("You are a delegated worker.");
1758
+ if (input.light) lines.push(...renderLightWorkspaceRules(input.light));
1759
+ else if (input.commitOnCurrentBranch && input.stage?.role !== "review") lines.push(WORKER_CURRENT_BRANCH_RULE);
1760
+ lines.push(WORKER_SHELL_LITERAL_PATHS_RULE);
1613
1761
  if (input.workerMcp === false) {
1614
1762
  lines.push(
1615
1763
  "This session has NO adhdev worker tools (`report_completion`, `progress_update`, `peer_context_pull`, `git_*`) \u2014 do not look for them. When your work is finished, blocked, or has failed, end your turn with a plain final summary: what you did, what you found, which files you changed, and where you left the branch. That final message is what the coordinator receives.",
@@ -1629,15 +1777,30 @@ function renderWorkerProtocolFooter(input = {}) {
1629
1777
  "Memos from the coordinator arrive appended to the response of whichever worker tool you call next; read them and follow them.",
1630
1778
  "You have no coordinator tools (no `mesh_*`) by design: do not enqueue, dispatch, or restart anything. If you need a decision from the coordinator, finish with `report_completion` and outcome `blocked`, listing what you need in `blockers`.",
1631
1779
  "On a code-changing task, `report_completion` with outcome `completed` requires `touched_files` \u2014 send `[]` if you changed nothing, omitting the field is what gets refused. `blocked`/`failed` never need it, and a read-only task should omit it or send `[]`.",
1632
- "If `report_completion` is refused, the response carries `validationErrors` (or a `hint`) naming exactly what to fix \u2014 correct that field and call it again; a refusal records nothing."
1780
+ "If `report_completion` is refused, the response carries `validationErrors` (or a `hint`) naming exactly what to fix \u2014 correct that field and call it again; a refusal records nothing.",
1781
+ "Put substantial findings (a diagnosis, evidence, repro steps, review findings) in a workspace file and register it with `artifact_register`, then cite the returned ids in `report_completion` `artifact_ids`. The next task in this mission inherits them as input artifacts instead of re-investigating \u2014 keep each artifact self-contained and factual.",
1782
+ "`driver_invoke` results that carry an image or a large body arrive already registered: take `artifacts[].artifactId` from the result and cite it in `artifact_ids` \u2014 do not paste the body."
1633
1783
  );
1634
1784
  if (input.enclosedHandoffNotes && input.enclosedHandoffNotes > 0) {
1635
1785
  lines.push(
1636
1786
  `The ${input.enclosedHandoffNotes} handoff note(s) above were written by agents who touched this code before you; honour their conflict guidance and add your own in \`handoff_notes\` when you report.`
1637
1787
  );
1638
1788
  }
1789
+ if (input.stage) lines.push(...renderStageProtocolLines(input.stage));
1639
1790
  return lines.join("\n");
1640
1791
  }
1792
+ function renderStageProtocolLines(stage) {
1793
+ if (stage.role === "review") {
1794
+ return [
1795
+ `STAGE: you are the independent reviewer (round ${stage.round} of at most ${stage.maxRevisions + 1}). Read the input artifacts first (diff, self-check log, previous verdict).` + (stage.workspace ? ` Your workspace ${stage.workspace} is pinned to the round head \u2014 you may run tests, but nothing you change lands; do not fix, record findings instead.` : " Do not modify the workspace: read it, and record findings instead of fixing.") + " Do not write any file for the review, not even a report: a new or changed file in the reviewed checkout fails the review as reviewer_mutated_source, and `artifact_register` refuses files outside the workspace. Put every finding in the `review` field of `report_completion` \u2014 that is the review record.",
1796
+ "Your `report_completion` MUST carry `review`: {verdict: approve | approve_with_nits | changes_requested | reject_approach, findings[{id, severity, category, claim, evidence, suggested_fix?}], checked[], not_checked[], tests_run?[]}. `changes_requested` needs at least one blocking/major finding; `approve` allows none. From round 2 also give `prior_findings[{id, status}]` for every earlier blocking/major finding. `reject_approach` is only for a wrong approach, not for fixable defects."
1797
+ ];
1798
+ }
1799
+ return [
1800
+ `STAGE: your \`report_completion\` is a stage report (${stage.role}, round ${stage.round}). An independent reviewer reads your diff next, so commit your work and leave the workspace clean before you report. When your change is committed, report outcome \`completed\` \u2014 the review starts only after that report, so never report \`blocked\` because the review has not run yet. You may receive review findings as a follow-up memo in this same session.`,
1801
+ ...stage.role === "revise" ? ["For every open blocking/major finding in the memo, fill `finding_responses[{id, response: fixed | disputed, note}]` \u2014 `disputed` needs your reasoning; the reviewer judges it next round."] : []
1802
+ ];
1803
+ }
1641
1804
  function stripWorkerProtocolFooter(body) {
1642
1805
  if (typeof body !== "string") return body;
1643
1806
  const at = body.indexOf(WORKER_PROTOCOL_FOOTER_MARKER);
@@ -1667,15 +1830,30 @@ function renderCoordinatorWorkerSection() {
1667
1830
  // src/assistant-protocol.ts
1668
1831
  var ASSISTANT_TOOLS = [
1669
1832
  "projects",
1833
+ "environment",
1834
+ "assistant_action",
1835
+ "project_watch",
1670
1836
  "project_status",
1671
1837
  "project_send",
1672
1838
  "project_read",
1673
1839
  "project_add",
1840
+ "project_attach_remote",
1674
1841
  "discover_repos",
1675
1842
  "memory",
1843
+ "memory_search",
1676
1844
  "skill_view",
1677
1845
  "skill_manage",
1678
- "project_note"
1846
+ "project_note",
1847
+ "launch_defaults",
1848
+ "launch_defaults_set",
1849
+ "driver_list",
1850
+ "driver_describe",
1851
+ "artifact_list",
1852
+ "artifact_read",
1853
+ "decision_answer",
1854
+ "decision_request",
1855
+ "session_control",
1856
+ "file_transfer"
1679
1857
  ];
1680
1858
  var ASSISTANT_TOOL_SET = new Set(ASSISTANT_TOOLS);
1681
1859
  function isAssistantTool(value) {
@@ -1683,50 +1861,170 @@ function isAssistantTool(value) {
1683
1861
  }
1684
1862
  var ASSISTANT_VERB = {
1685
1863
  // tool verbs
1864
+ driverList: "driver_list",
1865
+ driverDescribe: "driver_describe",
1686
1866
  projects: "assistant_projects",
1867
+ environment: "assistant_environment",
1868
+ action: "assistant_action",
1869
+ watch: "assistant_project_watch",
1870
+ executionState: "assistant_execution_state",
1871
+ executionSettings: "assistant_execution_settings",
1687
1872
  projectStatus: "assistant_project_status",
1688
1873
  projectSend: "assistant_project_send",
1689
1874
  projectRead: "assistant_project_read",
1690
1875
  projectAdd: "assistant_project_add",
1876
+ projectAttachRemote: "assistant_project_attach_remote",
1691
1877
  discoverRepos: "assistant_discover_repos",
1692
1878
  memory: "assistant_memory",
1879
+ /** Pull-only FTS search over the archive tier (memory design 2026-11-01 §3.4). */
1880
+ memorySearch: "assistant_memory_search",
1693
1881
  skillView: "assistant_skill_view",
1694
1882
  skillManage: "assistant_skill_manage",
1695
1883
  projectNote: "assistant_project_note",
1884
+ launchDefaults: "assistant_launch_defaults",
1885
+ launchDefaultsSet: "assistant_launch_defaults_set",
1886
+ artifactList: "assistant_artifact_list",
1887
+ artifactRead: "assistant_artifact_read",
1888
+ /** Owner-decision inbox (structured-missions design 2026-10-28 §6.3): the owner's words recorded as answers. */
1889
+ decisionAnswer: "assistant_decision_answer",
1890
+ /** Register a plain-text question a coordinator put to the owner as a decision item (§5.2). */
1891
+ decisionRequest: "assistant_decision_request",
1892
+ /** Stop / restart / switch the provider of a coordinator, worker or the assistant session (handoff design 2026-11-01 §4). */
1893
+ sessionControl: "assistant_session_control",
1894
+ /** Request / status / cancel the assistant's own project file transfers (owner approves in the dashboard; file-transfer design section 6). */
1895
+ fileTransfer: "assistant_file_transfer",
1696
1896
  // assistant-side daemon verbs without a tool of the same name
1697
1897
  launch: "launch_assistant",
1698
1898
  pendingRelays: "assistant_pending_relays",
1699
1899
  // owner verbs (dashboard only)
1700
1900
  stagedResolve: "assistant_staged_resolve",
1701
1901
  storeAdmin: "assistant_store_admin",
1702
- importSkills: "assistant_import_skills"
1902
+ importSkills: "assistant_import_skills",
1903
+ /** Owner skill list (attach/view counts, save proposals, recent skill metrics); reads move no counter. */
1904
+ skillsList: "assistant_skills_list",
1905
+ /** Owner: what the assistant remembered recently, with undo handles (memory design §3.2). */
1906
+ memoryDigest: "assistant_memory_digest",
1907
+ /** Owner: reverse one remembered write or one batch (memory design §3.2). Never an assistant tool. */
1908
+ memoryUndo: "assistant_memory_undo",
1909
+ /** Projects the assistant is following (open relay threads) — list / stop following. */
1910
+ threads: "assistant_threads",
1911
+ threadClose: "assistant_thread_close"
1703
1912
  };
1704
1913
  var ASSISTANT_TOOL_VERBS = {
1914
+ driver_list: ASSISTANT_VERB.driverList,
1915
+ driver_describe: ASSISTANT_VERB.driverDescribe,
1705
1916
  projects: ASSISTANT_VERB.projects,
1917
+ environment: ASSISTANT_VERB.environment,
1918
+ assistant_action: ASSISTANT_VERB.action,
1919
+ project_watch: ASSISTANT_VERB.watch,
1706
1920
  project_status: ASSISTANT_VERB.projectStatus,
1707
1921
  project_send: ASSISTANT_VERB.projectSend,
1708
1922
  project_read: ASSISTANT_VERB.projectRead,
1709
1923
  project_add: ASSISTANT_VERB.projectAdd,
1924
+ project_attach_remote: ASSISTANT_VERB.projectAttachRemote,
1710
1925
  discover_repos: ASSISTANT_VERB.discoverRepos,
1711
1926
  memory: ASSISTANT_VERB.memory,
1927
+ memory_search: ASSISTANT_VERB.memorySearch,
1712
1928
  skill_view: ASSISTANT_VERB.skillView,
1713
1929
  skill_manage: ASSISTANT_VERB.skillManage,
1714
- project_note: ASSISTANT_VERB.projectNote
1930
+ project_note: ASSISTANT_VERB.projectNote,
1931
+ launch_defaults: ASSISTANT_VERB.launchDefaults,
1932
+ launch_defaults_set: ASSISTANT_VERB.launchDefaultsSet,
1933
+ artifact_list: ASSISTANT_VERB.artifactList,
1934
+ artifact_read: ASSISTANT_VERB.artifactRead,
1935
+ decision_answer: ASSISTANT_VERB.decisionAnswer,
1936
+ decision_request: ASSISTANT_VERB.decisionRequest,
1937
+ session_control: ASSISTANT_VERB.sessionControl,
1938
+ file_transfer: ASSISTANT_VERB.fileTransfer
1715
1939
  };
1716
- var ASSISTANT_WRITE_TOOLS = ["memory", "skill_manage", "project_note", "project_send", "project_add"];
1940
+ var ASSISTANT_WRITE_TOOLS = ["project_watch", "assistant_action", "memory", "skill_manage", "project_note", "project_send", "project_add", "project_attach_remote", "launch_defaults_set", "decision_answer", "decision_request", "session_control", "file_transfer"];
1717
1941
  var ASSISTANT_OWNER_VERBS = [
1942
+ ASSISTANT_VERB.executionSettings,
1718
1943
  ASSISTANT_VERB.stagedResolve,
1719
1944
  ASSISTANT_VERB.storeAdmin,
1720
- ASSISTANT_VERB.importSkills
1945
+ ASSISTANT_VERB.importSkills,
1946
+ ASSISTANT_VERB.skillsList,
1947
+ ASSISTANT_VERB.memoryDigest,
1948
+ ASSISTANT_VERB.memoryUndo,
1949
+ ASSISTANT_VERB.threadClose
1721
1950
  ];
1722
1951
  var ASSISTANT_REVIEW_TURN_VERBS = [
1723
1952
  ASSISTANT_VERB.memory,
1953
+ ASSISTANT_VERB.memorySearch,
1724
1954
  ASSISTANT_VERB.skillView,
1725
1955
  ASSISTANT_VERB.skillManage,
1726
1956
  ASSISTANT_VERB.projectNote
1727
1957
  ];
1728
1958
  var ASSISTANT_SESSION_ID_ENV = "ADHDEV_ASSISTANT_SESSION_ID";
1729
1959
  var ASSISTANT_SESSION_ID_ARG = "assistantSessionId";
1960
+ var ASSISTANT_ACCOUNT_SLOT = "personal";
1961
+ var ASSISTANT_REMOTE_PROJECT_COMMAND = "assistant_remote_project";
1962
+ var ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND = "assistant_remote_project_catalog";
1963
+ var ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND = "assistant_remote_project_access";
1964
+ var ASSISTANT_REMOTE_FOLLOW_COMMAND = "assistant_remote_follow";
1965
+ var ASSISTANT_FOLLOWER_ALLOWED_OPS = ["status", "read", "poll", "report", "send", "artifact_list", "artifact_read", "decision_list", "decision_answer", "decision_request"];
1966
+ var ASSISTANT_FOLLOWER_ALLOWED_OP_SET = new Set(ASSISTANT_FOLLOWER_ALLOWED_OPS);
1967
+ function isAssistantFollowerAllowedOp(value) {
1968
+ return typeof value === "string" && ASSISTANT_FOLLOWER_ALLOWED_OP_SET.has(value);
1969
+ }
1970
+ var DECISION_OP_IMPLIED_BY = {
1971
+ decision_list: "status",
1972
+ decision_answer: "send",
1973
+ decision_request: "send"
1974
+ };
1975
+ function followerOpPermitted(op, allowedOps) {
1976
+ if (!isAssistantFollowerAllowedOp(op)) return false;
1977
+ if (allowedOps.includes(op)) return true;
1978
+ const implied = DECISION_OP_IMPLIED_BY[op];
1979
+ return implied !== void 0 && allowedOps.includes(implied);
1980
+ }
1981
+ function followedRemoteProjectKey(hostDaemonId, meshId) {
1982
+ const canonHost = canonicalDaemonId(hostDaemonId) ?? hostDaemonId.trim();
1983
+ return `${canonHost}::${meshId.trim()}`;
1984
+ }
1985
+ function sanitizeRemoteRepoIdentity(raw) {
1986
+ if (typeof raw !== "string") return null;
1987
+ const trimmed = raw.trim();
1988
+ if (!trimmed) return null;
1989
+ if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("~/") || trimmed.startsWith("\\") || /^[a-zA-Z]:[\\/]/.test(trimmed) || /^file:/i.test(trimmed)) {
1990
+ return null;
1991
+ }
1992
+ const withoutQuery = trimmed.replace(/[?#].*$/, "").replace(/\/+$/, "");
1993
+ if (!withoutQuery) return null;
1994
+ let host = "";
1995
+ let repoPath = "";
1996
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(withoutQuery)) {
1997
+ try {
1998
+ const url = new URL(withoutQuery);
1999
+ if (url.protocol === "file:") return null;
2000
+ host = url.hostname.toLowerCase();
2001
+ repoPath = decodeURIComponent(url.pathname).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
2002
+ } catch {
2003
+ return null;
2004
+ }
2005
+ } else {
2006
+ const scpMatch = withoutQuery.match(/^(?:[^@/:]+@)?(\[[^\]]+\]|[^/:]+):(.+)$/);
2007
+ if (scpMatch) {
2008
+ host = scpMatch[1].replace(/^\[|\]$/g, "").toLowerCase();
2009
+ repoPath = scpMatch[2].replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
2010
+ } else {
2011
+ const slash = withoutQuery.indexOf("/");
2012
+ if (slash > 0) {
2013
+ const rawHost = withoutQuery.slice(0, slash);
2014
+ const atIdx = rawHost.lastIndexOf("@");
2015
+ host = (atIdx >= 0 ? rawHost.slice(atIdx + 1) : rawHost).toLowerCase();
2016
+ repoPath = withoutQuery.slice(slash + 1).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
2017
+ }
2018
+ }
2019
+ }
2020
+ if (!host || !repoPath) return null;
2021
+ if (!host.includes(".") && host !== "localhost") return null;
2022
+ if (/[\s@:\\]/.test(host)) return null;
2023
+ const segments = repoPath.split("/").filter(Boolean);
2024
+ if (segments.length === 0) return null;
2025
+ if (segments.some((seg) => seg === "." || seg === ".." || /[\s@:\\]/.test(seg))) return null;
2026
+ return `${host}/${segments.join("/")}`.slice(0, 200);
2027
+ }
1730
2028
 
1731
2029
  // src/turn-evidence.ts
1732
2030
  var MESH_TOPIC_PROTOCOL_VERSION = 2;
@@ -1762,18 +2060,29 @@ var TURN_SCOPES = ["mesh_queue", "mesh_direct", "plain"];
1762
2060
  var RECLAIMING_SEND_REFUSALS = ["session_exited", "no_target", "unsupported_input"];
1763
2061
  var DELIVERY_OUTCOMES = ["delivered", "queued"];
1764
2062
  var DELIVERY_VIAS = ["local", "p2p"];
1765
- var DISPATCH_FAILURE_REASONS = ["worker_absent", "transport_error", "spawn_failed", "rejected_by_worker", "timeout"];
2063
+ var DISPATCH_FAILURE_REASONS = ["worker_absent", "transport_error", "spawn_failed", "rejected_by_worker", "timeout", "submit_unconfirmed"];
1766
2064
  function sanitizeRefusalCode(value) {
1767
2065
  if (typeof value !== "string") return void 0;
1768
2066
  const normalized = value.trim().toLowerCase().replace(/[^a-z_]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
1769
2067
  if (!normalized) return void 0;
1770
2068
  return normalized.slice(0, 64);
1771
2069
  }
2070
+ var DISPATCH_REFUSAL_DETAIL_MAX = 200;
2071
+ function sanitizeDispatchRefusalDetail(code, message) {
2072
+ const cleanCode = sanitizeRefusalCode(code);
2073
+ let cleanMessage;
2074
+ if (typeof message === "string") {
2075
+ const line = message.replace(/(?:[A-Za-z]:)?[\\/](?:Users|home)[\\/][^\s\\/]+/g, "~").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
2076
+ if (line) cleanMessage = line.length > DISPATCH_REFUSAL_DETAIL_MAX ? `${line.slice(0, DISPATCH_REFUSAL_DETAIL_MAX - 1)}\u2026` : line;
2077
+ }
2078
+ if (!cleanCode && !cleanMessage) return void 0;
2079
+ return { ...cleanCode ? { code: cleanCode } : {}, ...cleanMessage ? { message: cleanMessage } : {} };
2080
+ }
1772
2081
  var CONSUME_PROFILES = ["default", "native_source"];
1773
2082
  var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
1774
2083
  var SUSPENSION_MODALS = ["approval", "choice"];
1775
- var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
1776
- var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer"];
2084
+ var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered", "dismissed"];
2085
+ var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer", "modal_disappeared"];
1777
2086
  var TURN_END_STRENGTHS = ["genuine", "weak"];
1778
2087
  var TURN_END_BLOCK_REASONS = [
1779
2088
  "missing_final_assistant",
@@ -1781,9 +2090,9 @@ var TURN_END_BLOCK_REASONS = [
1781
2090
  "terminal_block_hard_cap",
1782
2091
  "decoupled_completion"
1783
2092
  ];
1784
- var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
2093
+ var NATIVE_TURN_OUTCOMES = ["completed", "aborted", "failed"];
1785
2094
  var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
1786
- var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
2095
+ var PROVIDER_FAILURES = ["auth_failed", "billing_failed", "usage_limit_exceeded", "server_overloaded", "provider_error"];
1787
2096
  var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
1788
2097
  var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
1789
2098
  var OPERATOR_STATUSES = ["completed", "failed"];
@@ -1810,9 +2119,10 @@ var HOLD_REASONS = [
1810
2119
  // — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
1811
2120
  // a session whose FSM never shows the idle edge again does not wait for
1812
2121
  // liveness / hard_ceiling.
1813
- "await_end"
2122
+ "await_end",
2123
+ "report_correction"
1814
2124
  ];
1815
- var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
2125
+ var TURN_OUTCOMES = ["completed", "blocked", "failed", "cancelled"];
1816
2126
  var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
1817
2127
  var TURN_REASONS = [
1818
2128
  // commits
@@ -1821,9 +2131,15 @@ var TURN_REASONS = [
1821
2131
  "transcript_final",
1822
2132
  "worker_reported",
1823
2133
  "finalization_timeout_no_response",
2134
+ "weak_end_liveness_unconfirmed",
2135
+ "weak_end_probe_unobserved",
2136
+ "report_correction_expired",
1824
2137
  "session_error",
1825
2138
  "provider_auth_failed",
1826
2139
  "provider_billing_failed",
2140
+ "provider_usage_limit_exceeded",
2141
+ "provider_server_overloaded",
2142
+ "provider_error",
1827
2143
  "operator_cancel",
1828
2144
  "intentional_cleanup",
1829
2145
  "task_removed",
@@ -1836,6 +2152,8 @@ var TURN_REASONS = [
1836
2152
  "reclaim_budget_exhausted",
1837
2153
  "hollow_max_retries",
1838
2154
  "migration_orphan",
2155
+ // a stopping attempt whose writer node stayed unreachable (or was removed) past the bound
2156
+ "writer_unreachable",
1839
2157
  // reclaims (generation + 1)
1840
2158
  "dispatch_refused_session_exited",
1841
2159
  "dispatch_refused_no_target",
@@ -1851,6 +2169,7 @@ var TURN_REASONS = [
1851
2169
  ];
1852
2170
  var NOTIFY_KINDS = [
1853
2171
  "completed",
2172
+ "blocked",
1854
2173
  "failed",
1855
2174
  "cancelled",
1856
2175
  "stopped",
@@ -1900,8 +2219,8 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1900
2219
  duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
1901
2220
  session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
1902
2221
  turn_started: { retro: bool },
1903
- suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
1904
- suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
2222
+ suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt, providerSetup: boolOpt, clockUnknown: boolOpt },
2223
+ suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS), modalKey: idOpt },
1905
2224
  turn_end: {
1906
2225
  strength: en(TURN_END_STRENGTHS),
1907
2226
  afterFinalizationTimeout: boolOpt,
@@ -1911,6 +2230,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1911
2230
  releasedByHardCap: boolOpt,
1912
2231
  nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
1913
2232
  live: { t: "live", optional: true },
2233
+ nativeMarker: { t: "native_marker", optional: true },
1914
2234
  reportExpected: boolOpt,
1915
2235
  providerFailure: enOpt(PROVIDER_FAILURES)
1916
2236
  },
@@ -1924,7 +2244,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1924
2244
  },
1925
2245
  transcript_activity: { newestActivityAt: ms },
1926
2246
  no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
1927
- liveness: { result: en(LIVENESS_RESULTS) },
2247
+ liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
1928
2248
  process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
1929
2249
  session_error: { reason: en(SESSION_ERROR_REASONS) },
1930
2250
  worker_report: {
@@ -1934,6 +2254,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1934
2254
  branchState: enOpt(WORKER_BRANCH_STATES),
1935
2255
  touchedFileCount: intOpt
1936
2256
  },
2257
+ worker_report_correction_requested: { deliveryId: { t: "id", optional: true } },
1937
2258
  worker_progress: { note: { t: "summary_ref", optional: true } },
1938
2259
  git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
1939
2260
  cancel: { reason: en(CANCEL_REASONS) },
@@ -1981,7 +2302,7 @@ function isLiveTurnPending(value) {
1981
2302
  return isRecord2(value) && hasOnlyKeys(value, ["modal", "adapterPending", "trailingTool", "newestActivityAt"]) && typeof value.modal === "boolean" && typeof value.adapterPending === "boolean" && typeof value.trailingTool === "boolean" && (value.newestActivityAt === void 0 || isFiniteNumber2(value.newestActivityAt));
1982
2303
  }
1983
2304
  function isNativeMarkerRef(value) {
1984
- return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId));
2305
+ return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId", "receivedAt", "startedAt", "errorAt"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId)) && ["receivedAt", "startedAt", "errorAt"].every((key) => value[key] === void 0 || isFiniteNumber2(value[key]));
1985
2306
  }
1986
2307
  function isCoordinatorIdentity(value) {
1987
2308
  return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
@@ -2104,17 +2425,89 @@ function projectTurnEvidenceEntry(evidence, attempt) {
2104
2425
  };
2105
2426
  }
2106
2427
 
2428
+ // src/launch-defaults.ts
2429
+ var LAUNCH_DEFAULT_ROLES = ["assistant", "coordinator"];
2430
+ var LAUNCH_DEFAULT_SOURCES = ["user", "stored_default", "project_default", "provider_default"];
2431
+ var LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE = "Applies to the next launch; running sessions are unchanged.";
2432
+ function isLaunchDefaultRole(value) {
2433
+ return typeof value === "string" && LAUNCH_DEFAULT_ROLES.includes(value);
2434
+ }
2435
+ function isLaunchDefaultSource(value) {
2436
+ return typeof value === "string" && LAUNCH_DEFAULT_SOURCES.includes(value);
2437
+ }
2438
+ var LAUNCH_DEFAULT_ERROR_CODES = [
2439
+ "invalid_args",
2440
+ "launch_default_required",
2441
+ "launch_default_unavailable",
2442
+ "launch_selection_invalid",
2443
+ "launch_default_invalid",
2444
+ "revision_conflict",
2445
+ "store_unavailable",
2446
+ "store_busy",
2447
+ "persistence_failed",
2448
+ "project_not_found",
2449
+ "project_ambiguous",
2450
+ "project_not_hosted",
2451
+ "project_storage_unavailable",
2452
+ "staging_unavailable",
2453
+ "staging_failed",
2454
+ "review_turn_tool_denied"
2455
+ ];
2456
+
2457
+ // src/role-launch.ts
2458
+ function record(value) {
2459
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
2460
+ }
2461
+ function ref(value) {
2462
+ const r = record(value);
2463
+ if (!r || !isLaunchDefaultRole(r.role) || r.scope !== "global" && r.scope !== "project" || !Number.isSafeInteger(r.revision) || r.revision < 1 || r.scope === "project" && (typeof r.projectId !== "string" || !r.projectId)) return void 0;
2464
+ return {
2465
+ role: r.role,
2466
+ scope: r.scope,
2467
+ revision: r.revision,
2468
+ ...r.scope === "project" ? { projectId: r.projectId } : {}
2469
+ };
2470
+ }
2471
+ function axis(value) {
2472
+ const a = record(value);
2473
+ if (!a || !isLaunchDefaultSource(a.source) || a.value !== null && typeof a.value !== "string") return void 0;
2474
+ const defaultRef = ref(a.defaultRef);
2475
+ if (a.source === "stored_default" && defaultRef?.scope !== "global" || a.source === "project_default" && defaultRef?.scope !== "project" || (a.source === "user" || a.source === "provider_default") && a.defaultRef !== void 0) return void 0;
2476
+ return { value: a.value, source: a.source, ...defaultRef ? { defaultRef } : {} };
2477
+ }
2478
+ function parseRoleLaunchSelection(value) {
2479
+ const r = record(value), s = record(r?.selection), a = record(r?.applied);
2480
+ if (!r || !isLaunchDefaultRole(r.role) || !s || typeof s.provider !== "string" || !s.provider || !Number.isSafeInteger(r.documentRevision) || r.documentRevision < 1 || s.model !== void 0 && typeof s.model !== "string" || s.thinkingLevel !== void 0 && typeof s.thinkingLevel !== "string") return void 0;
2481
+ const provider = axis(a?.provider), model = axis(a?.model), thinkingLevel = axis(a?.thinkingLevel);
2482
+ if (!provider || !model || !thinkingLevel || [provider, model, thinkingLevel].some((axis2) => axis2.defaultRef && (axis2.defaultRef.role !== r.role || axis2.defaultRef.scope === "global" && axis2.defaultRef.revision > r.documentRevision)) || provider.value !== s.provider || model.value !== (s.model ?? null) || thinkingLevel.value !== (s.thinkingLevel ?? null)) return void 0;
2483
+ const defaultRef = ref(r.defaultRef);
2484
+ return {
2485
+ role: r.role,
2486
+ selection: {
2487
+ provider: s.provider,
2488
+ ...typeof s.model === "string" ? { model: s.model } : {},
2489
+ ...typeof s.thinkingLevel === "string" ? { thinkingLevel: s.thinkingLevel } : {}
2490
+ },
2491
+ applied: { provider, model, thinkingLevel },
2492
+ ...defaultRef ? { defaultRef } : {},
2493
+ documentRevision: r.documentRevision
2494
+ };
2495
+ }
2496
+
2107
2497
  // src/session-launch.ts
2108
2498
  var MODEL_AXIS_SOURCES = [
2109
2499
  /** Picked explicitly for this launch (dashboard dropdown, coordinator dialog). */
2110
2500
  "user",
2111
2501
  /** The dashboard dialog restored it from the last launch (browser-local memory). */
2112
2502
  "remembered",
2503
+ /** The authoritative daemon role default or host project override. */
2504
+ "stored_default",
2505
+ "project_default",
2113
2506
  /** A mesh capability slot supplied it (or a difficulty preset the slot outranked). */
2114
2507
  "mesh_slot",
2115
2508
  /** An explicit per-task model / thinking level on a mesh queue task. */
2116
2509
  "task_override",
2117
- /** Nothing was requested; the provider's default is known (discovery / manifest). */
2510
+ /** Nothing requested: the provider chooses; resolvedDefault records it when known. */
2118
2511
  "provider_default",
2119
2512
  /** A value was requested without saying where it came from, or nothing is known. */
2120
2513
  "unspecified"
@@ -2158,10 +2551,10 @@ function readFiniteNumber(value) {
2158
2551
  }
2159
2552
  function parseModelSelection(raw) {
2160
2553
  if (!raw || typeof raw !== "object") return void 0;
2161
- const record = raw;
2554
+ const record2 = raw;
2162
2555
  const history = [];
2163
- if (Array.isArray(record.history)) {
2164
- for (const entry of record.history) {
2556
+ if (Array.isArray(record2.history)) {
2557
+ for (const entry of record2.history) {
2165
2558
  if (!entry || typeof entry !== "object") continue;
2166
2559
  const e = entry;
2167
2560
  const value = readString(e.value);
@@ -2170,41 +2563,45 @@ function parseModelSelection(raw) {
2170
2563
  if (value && at !== void 0 && via) history.push({ at, value, via });
2171
2564
  }
2172
2565
  }
2173
- const requested = readString(record.requested);
2174
- const launchValue = readString(record.launchValue);
2175
- const resolvedDefault = readString(record.resolvedDefault);
2176
- const current = readString(record.current);
2177
- const observed = readString(record.observed);
2178
- const observedAt = readFiniteNumber(record.observedAt);
2566
+ const requested = readString(record2.requested);
2567
+ const launchValue = readString(record2.launchValue);
2568
+ const resolvedDefault = readString(record2.resolvedDefault);
2569
+ const current = readString(record2.current);
2570
+ const observed = readString(record2.observed);
2571
+ const observedAt = readFiniteNumber(record2.observedAt);
2572
+ const fallback = record2.fallback === true;
2179
2573
  return {
2180
- source: isModelAxisSource(record.source) ? record.source : "unspecified",
2574
+ source: isModelAxisSource(record2.source) ? record2.source : "unspecified",
2181
2575
  ...requested ? { requested } : {},
2182
2576
  ...launchValue ? { launchValue } : {},
2183
2577
  ...resolvedDefault ? { resolvedDefault } : {},
2184
2578
  ...current ? { current } : {},
2185
2579
  ...observed ? { observed } : {},
2186
2580
  ...observedAt !== void 0 ? { observedAt } : {},
2581
+ ...fallback ? { fallback } : {},
2187
2582
  history: history.slice(-MODEL_SELECTION_HISTORY_LIMIT)
2188
2583
  };
2189
2584
  }
2190
2585
  function parseSessionLaunchRecord(raw) {
2191
2586
  if (!raw || typeof raw !== "object") return void 0;
2192
- const record = raw;
2193
- const sessionId = readString(record.sessionId);
2194
- const providerType = readString(record.providerType);
2195
- const launchedAt = readFiniteNumber(record.launchedAt);
2196
- const model = parseModelSelection(record.model);
2197
- const thinkingLevel = parseModelSelection(record.thinkingLevel);
2587
+ const record2 = raw;
2588
+ const sessionId = readString(record2.sessionId);
2589
+ const providerType = readString(record2.providerType);
2590
+ const launchedAt = readFiniteNumber(record2.launchedAt);
2591
+ const model = parseModelSelection(record2.model);
2592
+ const thinkingLevel = parseModelSelection(record2.thinkingLevel);
2198
2593
  if (!sessionId || !providerType || launchedAt === void 0 || !model || !thinkingLevel) return void 0;
2199
- const providerVersion = readString(record.providerVersion);
2200
- const workspace = readString(record.workspace);
2201
- const autoApproveModeId = readString(record.autoApproveModeId);
2594
+ const providerVersion = readString(record2.providerVersion);
2595
+ const workspace = readString(record2.workspace);
2596
+ const autoApproveModeId = readString(record2.autoApproveModeId);
2597
+ const roleLaunch = parseRoleLaunchSelection(record2.roleLaunch);
2202
2598
  return {
2599
+ ...roleLaunch ? { roleLaunch } : {},
2203
2600
  sessionId,
2204
2601
  providerType,
2205
2602
  ...providerVersion ? { providerVersion } : {},
2206
- ...record.providerChannel === "stable" || record.providerChannel === "preview" ? { providerChannel: record.providerChannel } : {},
2207
- launchedBy: isSessionLaunchedBy(record.launchedBy) ? record.launchedBy : "api",
2603
+ ...record2.providerChannel === "stable" || record2.providerChannel === "preview" ? { providerChannel: record2.providerChannel } : {},
2604
+ launchedBy: isSessionLaunchedBy(record2.launchedBy) ? record2.launchedBy : "api",
2208
2605
  launchedAt,
2209
2606
  ...workspace ? { workspace } : {},
2210
2607
  model,
@@ -2268,7 +2665,7 @@ function isTurnAttemptRefValue(value) {
2268
2665
  function isTurnObserveResponse(value) {
2269
2666
  return isRecord(value) && hasOnlyKeys2(value, ["verdict", "attemptRef", "outcome"]) && isTurnObserveVerdict(value.verdict) && isTurnAttemptRefValue(value.attemptRef) && (value.outcome === void 0 || isTurnOutcomeValue(value.outcome));
2270
2667
  }
2271
- var TURN_OUTCOMES_LOCAL = ["completed", "failed", "cancelled"];
2668
+ var TURN_OUTCOMES_LOCAL = ["completed", "blocked", "failed", "cancelled"];
2272
2669
  function isTurnOutcomeValue(value) {
2273
2670
  return typeof value === "string" && TURN_OUTCOMES_LOCAL.includes(value);
2274
2671
  }
@@ -2494,8 +2891,23 @@ function isMissionBriefWire(value) {
2494
2891
  }
2495
2892
  return true;
2496
2893
  }
2894
+ var STRUCTURED_MISSION_KEYS = ["summary", "releaseNote", "outcome", "outcomeReason", "version", "carryOver", "openItems"];
2895
+ function isOpenItemCountsWire(value) {
2896
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["remaining", "live_check", "decision", "evidence"])) return false;
2897
+ return ["remaining", "live_check", "decision", "evidence"].every((k) => isNonNegativeInt(value[k]));
2898
+ }
2899
+ function isStructuredMissionFields(value) {
2900
+ for (const k of ["summary", "releaseNote", "outcome", "outcomeReason"]) {
2901
+ if (value[k] !== void 0 && typeof value[k] !== "string") return false;
2902
+ }
2903
+ if (value.version !== void 0 && !isNonNegativeInt(value.version)) return false;
2904
+ if (value.carryOver !== void 0 && typeof value.carryOver !== "boolean") return false;
2905
+ if (value.openItems !== void 0 && !isOpenItemCountsWire(value.openItems)) return false;
2906
+ return true;
2907
+ }
2497
2908
  function isMeshMissionRecordWire(value) {
2498
- if (!isRecord(value) || !hasOnlyKeys2(value, ["id", "meshId", "title", "goal", "status", "brief"])) return false;
2909
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["id", "meshId", "title", "goal", "status", "brief", ...STRUCTURED_MISSION_KEYS])) return false;
2910
+ if (!isStructuredMissionFields(value)) return false;
2499
2911
  if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
2500
2912
  if (typeof value.title !== "string" || typeof value.goal !== "string") return false;
2501
2913
  if (!isMeshMissionStatusValue(value.status)) return false;
@@ -2503,11 +2915,22 @@ function isMeshMissionRecordWire(value) {
2503
2915
  return true;
2504
2916
  }
2505
2917
  function isMissionUpsertRequest(value) {
2506
- if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "id", "title", "goal", "status", "brief"])) return false;
2918
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "id", "title", "goal", "status", "brief", "structured", "summary", "releaseNote", "outcome", "outcomeReason", "carryOverTo", "toCarryOver", "itemsAdd", "itemsUpdate"])) return false;
2507
2919
  if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2508
2920
  if (!isEvidenceIdentifier(value.meshId)) return false;
2509
2921
  if (value.id !== void 0 && !isEvidenceIdentifier(value.id)) return false;
2510
- if (typeof value.title !== "string" || value.title.trim().length === 0) return false;
2922
+ if (typeof value.title !== "string") return false;
2923
+ if (value.title.trim().length === 0 && value.toCarryOver !== true && value.id === void 0) return false;
2924
+ if (value.structured !== void 0 && typeof value.structured !== "boolean") return false;
2925
+ if (value.toCarryOver !== void 0 && typeof value.toCarryOver !== "boolean") return false;
2926
+ for (const k of ["summary", "releaseNote", "outcome", "outcomeReason"]) {
2927
+ if (value[k] !== void 0 && typeof value[k] !== "string") return false;
2928
+ }
2929
+ if (value.carryOverTo !== void 0 && !isEvidenceIdentifier(value.carryOverTo)) return false;
2930
+ for (const k of ["itemsAdd", "itemsUpdate"]) {
2931
+ const list = value[k];
2932
+ if (list !== void 0 && (!Array.isArray(list) || list.length > 500 || !list.every(isRecord))) return false;
2933
+ }
2511
2934
  if (value.goal !== void 0 && typeof value.goal !== "string") return false;
2512
2935
  if (value.status !== void 0 && !isMeshMissionStatusValue(value.status)) return false;
2513
2936
  if (value.brief !== void 0 && value.brief !== null && !isMissionBriefWire(value.brief)) return false;
@@ -2517,7 +2940,7 @@ function decodeMissionUpsertRequest(value) {
2517
2940
  return isMissionUpsertRequest(value) ? value : null;
2518
2941
  }
2519
2942
  function isMissionUpsertResponse(value) {
2520
- return isRecord(value) && hasOnlyKeys2(value, ["mission"]) && isMeshMissionRecordWire(value.mission);
2943
+ return isRecord(value) && hasOnlyKeys2(value, ["mission", "result"]) && isMeshMissionRecordWire(value.mission) && (value.result === void 0 || isRecord(value.result));
2521
2944
  }
2522
2945
  function decodeMissionUpsertResponse(value) {
2523
2946
  return isMissionUpsertResponse(value) ? value : null;
@@ -2543,7 +2966,10 @@ function decodeMissionQueryResponse(value) {
2543
2966
  return isMissionQueryResponse(value) ? value : null;
2544
2967
  }
2545
2968
  function isMissionListQueryRequest(value) {
2546
- if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "verbose", "withStats", "limit", "historyIdLimit", "meshStatusView"])) return false;
2969
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "verbose", "withStats", "limit", "historyIdLimit", "meshStatusView", "structured", "items", "history"])) return false;
2970
+ for (const k of ["structured", "items", "history"]) {
2971
+ if (value[k] !== void 0 && typeof value[k] !== "boolean") return false;
2972
+ }
2547
2973
  if (value.meshStatusView !== void 0 && value.meshStatusView !== "compact" && value.meshStatusView !== "verbose") return false;
2548
2974
  if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2549
2975
  if (!isEvidenceIdentifier(value.meshId)) return false;
@@ -2569,12 +2995,13 @@ function isMeshMissionTaskAggregateWire(value) {
2569
2995
  return value.lastActivityAt === null || typeof value.lastActivityAt === "string";
2570
2996
  }
2571
2997
  function isMeshMissionStatsWire(value) {
2572
- const keys = ["missionId", "taskCount", "completed", "failed", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2998
+ const keys = ["missionId", "taskCount", "completed", "failed", "blocked", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2573
2999
  if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2574
3000
  if (!isEvidenceIdentifier(value.missionId)) return false;
2575
3001
  for (const k of ["taskCount", "completed", "failed", "totalDurationMs", "retries"]) {
2576
3002
  if (!isNonNegativeInt(value[k])) return false;
2577
3003
  }
3004
+ if (value.blocked !== void 0 && !isNonNegativeInt(value.blocked)) return false;
2578
3005
  if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false;
2579
3006
  if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false;
2580
3007
  return true;
@@ -2584,7 +3011,7 @@ function isMissionListSummaryWire(value) {
2584
3011
  const hasGoal = "goal" in value;
2585
3012
  const hasPreview = "goalPreview" in value && "goalTruncated" in value;
2586
3013
  if (hasGoal === hasPreview) return false;
2587
- const baseKeys = ["id", "meshId", "title", "status", "tasks", "stats", "brief", "createdAt", "updatedAt", "closeCandidateEmittedAt"];
3014
+ const baseKeys = ["id", "meshId", "title", "status", "tasks", "stats", "brief", "createdAt", "updatedAt", "closeCandidateEmittedAt", ...STRUCTURED_MISSION_KEYS, "items", "history"];
2588
3015
  const allowed = hasGoal ? [...baseKeys, "goal"] : [...baseKeys, "goalPreview", "goalTruncated"];
2589
3016
  if (!hasOnlyKeys2(value, allowed)) return false;
2590
3017
  if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
@@ -2598,6 +3025,10 @@ function isMissionListSummaryWire(value) {
2598
3025
  if (value.createdAt !== void 0 && typeof value.createdAt !== "string") return false;
2599
3026
  if (value.updatedAt !== void 0 && typeof value.updatedAt !== "string") return false;
2600
3027
  if (value.closeCandidateEmittedAt !== void 0 && value.closeCandidateEmittedAt !== null && typeof value.closeCandidateEmittedAt !== "string") return false;
3028
+ if (!isStructuredMissionFields(value)) return false;
3029
+ for (const k of ["items", "history"]) {
3030
+ if (value[k] !== void 0 && (!Array.isArray(value[k]) || !value[k].every(isRecord))) return false;
3031
+ }
2601
3032
  return true;
2602
3033
  }
2603
3034
  function isMeshMissionHistoryFoldWire(value) {
@@ -2696,12 +3127,15 @@ function isLedgerQueryEntryWire(value) {
2696
3127
  return true;
2697
3128
  }
2698
3129
  function isLedgerQuerySummaryWire(value) {
2699
- const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures"];
3130
+ const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskBlocked", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures", "taskBlocked", "refineFailed", "recentRefineFailures"];
2700
3131
  if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2701
3132
  if (!isEvidenceIdentifier(value.meshId)) return false;
2702
3133
  for (const k of ["totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "recentFailures"]) {
2703
3134
  if (!isNonNegativeInt(value[k])) return false;
2704
3135
  }
3136
+ if (value.taskBlocked !== void 0 && !isNonNegativeInt(value.taskBlocked)) return false;
3137
+ if (value.refineFailed !== void 0 && !isNonNegativeInt(value.refineFailed)) return false;
3138
+ if (value.recentRefineFailures !== void 0 && !isNonNegativeInt(value.recentRefineFailures)) return false;
2705
3139
  if (value.lastActivityAt !== null && typeof value.lastActivityAt !== "string") return false;
2706
3140
  return true;
2707
3141
  }
@@ -2745,9 +3179,10 @@ function isQueueDependencyHeadWire(value) {
2745
3179
  return isRecord(value) && hasOnlyKeys2(value, ["id", "status", "cancelReason"]) && typeof value.id === "string" && typeof value.status === "string" && (value.cancelReason === void 0 || typeof value.cancelReason === "string");
2746
3180
  }
2747
3181
  function isQueueQueryResponse(value) {
2748
- if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "counts", "oldHistoricalCount", "dependencyHeads"])) return false;
3182
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "counts", "oldHistoricalCount", "legacyReportedBlockedCount", "dependencyHeads"])) return false;
2749
3183
  if (!Array.isArray(value.entries) || !value.entries.every(isQueueEntryWire)) return false;
2750
3184
  if (value.counts !== void 0 && (!isRecord(value.counts) || !Object.values(value.counts).every(isNonNegativeInt))) return false;
3185
+ if (value.legacyReportedBlockedCount !== void 0 && !isNonNegativeInt(value.legacyReportedBlockedCount)) return false;
2751
3186
  if (value.oldHistoricalCount !== void 0 && !isNonNegativeInt(value.oldHistoricalCount)) return false;
2752
3187
  if (value.dependencyHeads !== void 0 && (!Array.isArray(value.dependencyHeads) || !value.dependencyHeads.every(isQueueDependencyHeadWire))) return false;
2753
3188
  return true;
@@ -2805,7 +3240,7 @@ function decodeQueueRequeueRequest(value) {
2805
3240
  return isQueueRequeueRequest(value) ? value : null;
2806
3241
  }
2807
3242
  function isQueueRequeueResponse(value) {
2808
- return isRecord(value) && hasOnlyKeys2(value, ["task"]) && (value.task === null || isQueueEntryWire(value.task));
3243
+ return isRecord(value) && hasOnlyKeys2(value, ["task", "quotaOverrideRequested"]) && (value.task === null || isQueueEntryWire(value.task)) && (value.quotaOverrideRequested === void 0 || isRecord(value.quotaOverrideRequested) && typeof value.quotaOverrideRequested.decisionId === "string");
2809
3244
  }
2810
3245
  function decodeQueueRequeueResponse(value) {
2811
3246
  return isQueueRequeueResponse(value) ? value : null;
@@ -2869,6 +3304,24 @@ function isRecoveryContextQueryResponse(value) {
2869
3304
  function decodeRecoveryContextQueryResponse(value) {
2870
3305
  return isRecoveryContextQueryResponse(value) ? value : null;
2871
3306
  }
3307
+ function decodeQueueReviseRequest(value) {
3308
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "taskId", "expectedRevision", "patch", "dryRun", "deferScheduling"]) || value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.taskId) || !Number.isSafeInteger(value.expectedRevision) || value.expectedRevision < 0 || !isRecord(value.patch) || !Object.keys(value.patch).length || !hasOnlyKeys2(value.patch, ["message", "ownedPaths", "phase", "dependsOn", "routingPreferences", "review", "difficulty", "requestQuotaOverride", "attestActiveOwnership"])) return null;
3309
+ if (value.dryRun !== void 0 && typeof value.dryRun !== "boolean") return null;
3310
+ if (value.deferScheduling !== void 0 && typeof value.deferScheduling !== "boolean") return null;
3311
+ const p = value.patch;
3312
+ if (p.requestQuotaOverride && (value.dryRun !== void 0 || value.deferScheduling !== void 0)) return null;
3313
+ if (p.requestQuotaOverride !== void 0 && (p.requestQuotaOverride !== true || Object.keys(p).length !== 1)) return null;
3314
+ if (p.attestActiveOwnership && value.deferScheduling !== void 0) return null;
3315
+ if (p.attestActiveOwnership !== void 0 && (p.attestActiveOwnership !== true || Object.keys(p).length !== 1)) return null;
3316
+ if (p.message !== void 0 && (typeof p.message !== "string" || !p.message.trim())) return null;
3317
+ if (p.phase !== void 0 && p.phase !== "source" && p.phase !== "integration") return null;
3318
+ if (p.difficulty !== void 0 && p.difficulty !== "easy" && p.difficulty !== "medium" && p.difficulty !== "difficult" && p.difficulty !== "freeform") return null;
3319
+ for (const key of ["ownedPaths", "dependsOn"]) {
3320
+ if (p[key] !== void 0 && (!Array.isArray(p[key]) || !p[key].every((x) => typeof x === "string" && !!x.trim()))) return null;
3321
+ }
3322
+ return value;
3323
+ }
3324
+ var decodeQueueReviseResponse = decodeQueueRequeueResponse;
2872
3325
 
2873
3326
  // src/turn-ipc-stats.ts
2874
3327
  function isTaskStatsQueryRequest(value) {
@@ -2967,6 +3420,7 @@ var TURN_IPC_COMMANDS = [
2967
3420
  "queue_enqueue_batch",
2968
3421
  "queue_cancel",
2969
3422
  "queue_requeue",
3423
+ "queue_revise",
2970
3424
  "direct_dispatch_record",
2971
3425
  "active_work_query",
2972
3426
  "recovery_context_query",
@@ -3050,14 +3504,11 @@ function normalizeOwnedPaths(input) {
3050
3504
  }
3051
3505
  function entryContains(base, path) {
3052
3506
  if (path === base.path) return true;
3053
- if (base.subtree && (path === base.path || path.startsWith(`${base.path}/`))) return true;
3507
+ if (base.subtree && (base.path === "" || path.startsWith(`${base.path}/`))) return true;
3054
3508
  return false;
3055
3509
  }
3056
3510
  function entriesOverlap(a, b) {
3057
- if (a.path === b.path) return true;
3058
- if (a.subtree && (b.path === a.path || b.path.startsWith(`${a.path}/`))) return true;
3059
- if (b.subtree && (a.path === b.path || a.path.startsWith(`${b.path}/`))) return true;
3060
- return false;
3511
+ return entryContains(a, b.path) || entryContains(b, a.path);
3061
3512
  }
3062
3513
  function pathsOverlap(a, b) {
3063
3514
  if (a.paths.length === 0 || b.paths.length === 0) return false;
@@ -3109,6 +3560,357 @@ function touchedFilesOutsideOwnership(touched, owned) {
3109
3560
  return { undeclaredTouched, unusedDeclarations };
3110
3561
  }
3111
3562
 
3563
+ // src/mission-items.ts
3564
+ var MISSION_ITEM_KINDS = ["remaining", "live_check", "decision", "evidence"];
3565
+ var MISSION_ITEM_STATES = ["open", "done", "failed", "dropped", "moved", "answered", "expired", "withdrawn", "superseded"];
3566
+ var COORDINATOR_SETTABLE_ITEM_STATES = {
3567
+ remaining: ["open", "done", "dropped"],
3568
+ live_check: ["open", "done", "dropped"],
3569
+ evidence: ["open", "done", "dropped"],
3570
+ decision: ["open", "withdrawn", "superseded"]
3571
+ };
3572
+ var MISSION_OUTCOMES = ["merged", "verified_live", "superseded", "not_needed", "owner_abandoned", "unspecified"];
3573
+ function isMissionOutcome(value) {
3574
+ return typeof value === "string" && MISSION_OUTCOMES.includes(value);
3575
+ }
3576
+ var MISSION_REF_KINDS = ["commit", "branch", "pr", "task", "artifact", "mission", "url"];
3577
+ var MISSION_LIMITS = {
3578
+ summary: 300,
3579
+ outcomeReason: 500,
3580
+ itemText: 300,
3581
+ machine: 80,
3582
+ refs: 8,
3583
+ refValue: 300,
3584
+ refRepo: 120,
3585
+ refNote: 200,
3586
+ dedupeKey: 400,
3587
+ question: 300,
3588
+ context: 600,
3589
+ options: 5,
3590
+ optionLabel: 60,
3591
+ optionDetail: 200,
3592
+ /** Open items per mission before the oldest `remaining` fold into a "N more" summary item. */
3593
+ openItemsPerMission: 200,
3594
+ /** One event payload (serialized). */
3595
+ eventPayloadBytes: 16 * 1024,
3596
+ /** items_add / items_update entries honoured per call (extra entries are reported, not applied). */
3597
+ itemsPerCall: 50
3598
+ };
3599
+ var MISSION_DECISION_OPTION_IDS = ["a", "b", "c", "d", "e"];
3600
+ var MISSION_DECISION_URGENCIES = ["normal", "blocking"];
3601
+ var MISSION_DECISION_ON_DUE = ["remind", "apply_recommended"];
3602
+ function truncateMissionText(value, max) {
3603
+ if (value.length <= max) return value;
3604
+ return `${value.slice(0, max - 1).trimEnd()}\u2026`;
3605
+ }
3606
+ function str(value) {
3607
+ return typeof value === "string" ? value.trim() : "";
3608
+ }
3609
+ function collapse(value) {
3610
+ return value.replace(/\s+/g, " ").trim();
3611
+ }
3612
+ function normalizeMissionSummary(value) {
3613
+ if (typeof value !== "string") return null;
3614
+ const text = collapse(value);
3615
+ return { value: truncateMissionText(text, MISSION_LIMITS.summary), truncated: text.length > MISSION_LIMITS.summary };
3616
+ }
3617
+ function normalizeOutcomeReason(value) {
3618
+ if (typeof value !== "string") return null;
3619
+ const text = value.trim();
3620
+ return { value: truncateMissionText(text, MISSION_LIMITS.outcomeReason), truncated: text.length > MISSION_LIMITS.outcomeReason };
3621
+ }
3622
+ function normalizeMissionRefs(value) {
3623
+ if (!Array.isArray(value)) return { refs: [], truncated: false };
3624
+ const refs = [];
3625
+ let truncated = false;
3626
+ for (const raw of value) {
3627
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
3628
+ const r = raw;
3629
+ const kind = str(r.kind);
3630
+ const refValue = str(r.value);
3631
+ if (!MISSION_REF_KINDS.includes(kind) || !refValue) continue;
3632
+ if (refs.length >= MISSION_LIMITS.refs) {
3633
+ truncated = true;
3634
+ break;
3635
+ }
3636
+ const repo = str(r.repo);
3637
+ const note = str(r.note);
3638
+ refs.push({
3639
+ kind,
3640
+ ...repo ? { repo: truncateMissionText(repo, MISSION_LIMITS.refRepo) } : {},
3641
+ value: truncateMissionText(refValue, MISSION_LIMITS.refValue),
3642
+ ...note ? { note: truncateMissionText(note, MISSION_LIMITS.refNote) } : {}
3643
+ });
3644
+ }
3645
+ return { refs, truncated };
3646
+ }
3647
+ function normalizeOptions(value, truncated) {
3648
+ if (!Array.isArray(value)) return [];
3649
+ const out = [];
3650
+ for (const raw of value) {
3651
+ if (typeof raw === "string" && raw.trim()) {
3652
+ if (out.length >= MISSION_LIMITS.options) {
3653
+ truncated.push("options");
3654
+ break;
3655
+ }
3656
+ out.push({ id: MISSION_DECISION_OPTION_IDS[out.length], label: truncateMissionText(raw.trim(), MISSION_LIMITS.optionLabel) });
3657
+ continue;
3658
+ }
3659
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
3660
+ const o = raw;
3661
+ const label = collapse(str(o.label));
3662
+ if (!label) continue;
3663
+ if (out.length >= MISSION_LIMITS.options) {
3664
+ truncated.push("options");
3665
+ break;
3666
+ }
3667
+ const detail = str(o.detail);
3668
+ out.push({
3669
+ id: MISSION_DECISION_OPTION_IDS[out.length],
3670
+ label: truncateMissionText(label, MISSION_LIMITS.optionLabel),
3671
+ ...detail ? { detail: truncateMissionText(detail, MISSION_LIMITS.optionDetail) } : {}
3672
+ });
3673
+ }
3674
+ return out;
3675
+ }
3676
+ function normalizeDueAt(value) {
3677
+ if (typeof value !== "string" || !value.trim()) return void 0;
3678
+ const ms2 = Date.parse(value);
3679
+ return Number.isNaN(ms2) ? void 0 : new Date(ms2).toISOString();
3680
+ }
3681
+ function normalizeDecisionInput(raw, truncated) {
3682
+ const questionSource = collapse(str(raw.question) || str(raw.text));
3683
+ if (!questionSource) return null;
3684
+ if (questionSource.length > MISSION_LIMITS.question) truncated.push("question");
3685
+ const question = truncateMissionText(questionSource, MISSION_LIMITS.question);
3686
+ const contextSource = str(raw.context);
3687
+ if (contextSource.length > MISSION_LIMITS.context) truncated.push("context");
3688
+ const options = normalizeOptions(raw.options, truncated);
3689
+ const recommendedRaw = str(raw.recommended);
3690
+ const recommended = recommendedRaw && options.some((o) => o.id === recommendedRaw) ? recommendedRaw : options.find((o) => recommendedRaw && o.label.toLowerCase() === recommendedRaw.toLowerCase())?.id;
3691
+ const dueAt = normalizeDueAt(raw.dueAt ?? raw.due_at);
3692
+ const onDueRaw = str(raw.onDue ?? raw.on_due);
3693
+ const urgencyRaw = str(raw.urgency);
3694
+ const allowFreeTextRaw = raw.allowFreeText ?? raw.allow_free_text;
3695
+ return {
3696
+ question,
3697
+ ...contextSource ? { context: truncateMissionText(contextSource, MISSION_LIMITS.context) } : {},
3698
+ options,
3699
+ ...recommended ? { recommended } : {},
3700
+ allowFreeText: typeof allowFreeTextRaw === "boolean" ? allowFreeTextRaw : true,
3701
+ ...dueAt ? { dueAt } : {},
3702
+ // apply_recommended without a recommended option has nothing to apply — fall back to remind.
3703
+ onDue: onDueRaw === "apply_recommended" && recommended ? "apply_recommended" : "remind",
3704
+ urgency: urgencyRaw === "blocking" ? "blocking" : "normal"
3705
+ };
3706
+ }
3707
+ function normalizeForDedupe(text) {
3708
+ return collapse(text).toLowerCase().replace(/[\s.!?。]+$/u, "");
3709
+ }
3710
+ function deriveItemDedupeKey(kind, parts) {
3711
+ const explicit = str(parts.explicit);
3712
+ if (explicit) return truncateMissionText(`k:${explicit}`, MISSION_LIMITS.dedupeKey);
3713
+ if (kind === "decision") return truncateMissionText(`decision:${normalizeForDedupe(parts.question ?? parts.text ?? "")}`, MISSION_LIMITS.dedupeKey);
3714
+ if (kind === "evidence") {
3715
+ const ref2 = parts.refs?.[0];
3716
+ if (ref2) return truncateMissionText(`evidence:${ref2.kind}:${ref2.repo ?? ""}:${ref2.value}`, MISSION_LIMITS.dedupeKey);
3717
+ }
3718
+ const machine = parts.machine ? `@${normalizeForDedupe(parts.machine)}` : "";
3719
+ return truncateMissionText(`${kind}${machine}:${normalizeForDedupe(parts.text ?? "")}`, MISSION_LIMITS.dedupeKey);
3720
+ }
3721
+ function normalizeMissionItemInput(raw) {
3722
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { error: "item must be an object" };
3723
+ const r = raw;
3724
+ const kind = str(r.kind) || "remaining";
3725
+ if (!MISSION_ITEM_KINDS.includes(kind)) {
3726
+ return { error: `invalid kind '${kind}' (valid: ${MISSION_ITEM_KINDS.join(", ")})` };
3727
+ }
3728
+ const truncated = [];
3729
+ const { refs, truncated: refsTruncated } = normalizeMissionRefs(r.refs);
3730
+ if (refsTruncated) truncated.push("refs");
3731
+ const machineRaw = collapse(str(r.machine));
3732
+ const machine = machineRaw ? truncateMissionText(machineRaw, MISSION_LIMITS.machine) : void 0;
3733
+ const explicitKey = str(r.dedupe_key ?? r.dedupeKey);
3734
+ if (kind === "decision") {
3735
+ const decisionRaw = r.decision && typeof r.decision === "object" && !Array.isArray(r.decision) ? r.decision : r;
3736
+ const decision = normalizeDecisionInput({ ...decisionRaw, question: decisionRaw.question ?? r.question ?? r.text }, truncated);
3737
+ if (!decision) return { error: "decision item needs a question" };
3738
+ return {
3739
+ item: {
3740
+ kind,
3741
+ text: decision.question,
3742
+ ...machine ? { machine } : {},
3743
+ refs,
3744
+ decision,
3745
+ dedupeKey: deriveItemDedupeKey("decision", { question: decision.question, explicit: explicitKey }),
3746
+ truncated
3747
+ }
3748
+ };
3749
+ }
3750
+ const textSource = collapse(str(r.text));
3751
+ if (!textSource && !(kind === "evidence" && refs.length > 0)) return { error: `${kind} item needs text` };
3752
+ if (textSource.length > MISSION_LIMITS.itemText) truncated.push("text");
3753
+ const text = truncateMissionText(textSource || `${refs[0].kind}: ${refs[0].value}`, MISSION_LIMITS.itemText);
3754
+ return {
3755
+ item: {
3756
+ kind,
3757
+ text,
3758
+ ...machine ? { machine } : {},
3759
+ refs,
3760
+ dedupeKey: deriveItemDedupeKey(kind, { text, machine, refs, explicit: explicitKey }),
3761
+ truncated
3762
+ }
3763
+ };
3764
+ }
3765
+ function normalizeMissionItemUpdate(raw) {
3766
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { error: "update must be an object" };
3767
+ const r = raw;
3768
+ const id2 = str(r.id ?? r.item_id ?? r.itemId);
3769
+ if (!id2) return { error: "update needs an item id" };
3770
+ const truncated = [];
3771
+ const update = { id: id2 };
3772
+ if (r.state !== void 0) {
3773
+ const state = str(r.state);
3774
+ if (!MISSION_ITEM_STATES.includes(state)) return { error: `invalid state '${state}'` };
3775
+ update.state = state;
3776
+ }
3777
+ if (typeof r.text === "string") {
3778
+ const text = collapse(r.text);
3779
+ if (text.length > MISSION_LIMITS.itemText) truncated.push("text");
3780
+ if (text) update.text = truncateMissionText(text, MISSION_LIMITS.itemText);
3781
+ }
3782
+ if (r.machine === null) update.machine = null;
3783
+ else if (typeof r.machine === "string") {
3784
+ const machine = collapse(r.machine);
3785
+ update.machine = machine ? truncateMissionText(machine, MISSION_LIMITS.machine) : null;
3786
+ }
3787
+ if (r.refs !== void 0) {
3788
+ const { refs, truncated: t } = normalizeMissionRefs(r.refs);
3789
+ if (t) truncated.push("refs");
3790
+ update.refs = refs;
3791
+ }
3792
+ return { update, truncated };
3793
+ }
3794
+ function boundEventPayload(payload) {
3795
+ let json = JSON.stringify(payload);
3796
+ if (json.length <= MISSION_LIMITS.eventPayloadBytes) return json;
3797
+ const shrunk = {};
3798
+ for (const [k, v] of Object.entries(payload)) {
3799
+ shrunk[k] = typeof v === "string" && v.length > 4e3 ? `${v.slice(0, 4e3)}\u2026` : v;
3800
+ }
3801
+ shrunk.payloadTruncated = true;
3802
+ json = JSON.stringify(shrunk);
3803
+ if (json.length <= MISSION_LIMITS.eventPayloadBytes) return json;
3804
+ return JSON.stringify({ payloadTruncated: true, keys: Object.keys(payload).slice(0, 20) });
3805
+ }
3806
+ var CARRY_OVER_MISSION_TITLE = "Carry-over \u2014 open items from closed missions";
3807
+ var LEGACY_CARRY_OVER_MISSION_TITLE = "\uC774\uC6D4 \u2014 \uB2EB\uD78C \uBBF8\uC158\uC5D0\uC11C \uB118\uC5B4\uC628 \uD56D\uBAA9";
3808
+ var CARRY_OVER_MISSION_GOAL = "Open items carried over from closed missions, and decisions requested without a mission. Managed automatically \u2014 do not close.";
3809
+ function isCarryOverMissionRecord(m) {
3810
+ return !!m && (m.isCarryOver === true || isCarryOverMissionTitle(m.title));
3811
+ }
3812
+ function isCarryOverMissionTitle(title) {
3813
+ if (typeof title !== "string") return false;
3814
+ const t = title.trim();
3815
+ return t === CARRY_OVER_MISSION_TITLE || t === LEGACY_CARRY_OVER_MISSION_TITLE;
3816
+ }
3817
+ var OWNER_ABANDON_CONFIRM_KEY_PREFIX = "owner-abandon-confirm:";
3818
+ var OWNER_ABANDON_CONFIRM_QUESTION = "The coordinator closed this as 'owner abandoned' \u2014 correct?";
3819
+ var OWNER_ABANDON_CONFIRM_OPTIONS = ["Correct", "Reopen"];
3820
+ var WORKER_DECISIONS_NEEDED_MAX = 3;
3821
+ var WORKER_COMMITS_MAX = 20;
3822
+ var SHA_RE = /^[0-9a-f]{7,64}$/i;
3823
+ function normalizeReportCommits(value) {
3824
+ if (!Array.isArray(value)) return null;
3825
+ const out = [];
3826
+ for (const v of value) {
3827
+ if (typeof v !== "string") return null;
3828
+ const sha = v.trim();
3829
+ if (!SHA_RE.test(sha)) return null;
3830
+ if (!out.includes(sha.toLowerCase())) out.push(sha.toLowerCase());
3831
+ }
3832
+ return out;
3833
+ }
3834
+
3835
+ // src/mission-git-state.ts
3836
+ var MISSION_REF_GIT_STATUSES = ["contained_ancestor", "contained_patch_equivalent", "not_contained", "unknown"];
3837
+ var MISSION_REF_GIT_METHODS = ["ancestry", "cherry", "residual_patch"];
3838
+ var MISSION_GIT_STATES = ["no_refs", "landed", "partial", "not_landed", "unknown"];
3839
+ function isMissionRefContained(status) {
3840
+ return status === "contained_ancestor" || status === "contained_patch_equivalent";
3841
+ }
3842
+ function aggregateMissionGitState(statuses) {
3843
+ const total = statuses.length;
3844
+ const contained = statuses.filter(isMissionRefContained).length;
3845
+ const notContained = statuses.filter((s) => s === "not_contained").length;
3846
+ const unknown = statuses.filter((s) => s === "unknown").length;
3847
+ const counts = { total, contained, notContained, unknown };
3848
+ if (total === 0) return { state: "no_refs", partialUnknown: false, counts };
3849
+ if (contained === total) return { state: "landed", partialUnknown: false, counts };
3850
+ if (contained > 0) return { state: "partial", partialUnknown: unknown > 0, counts };
3851
+ if (notContained === total) return { state: "not_landed", partialUnknown: false, counts };
3852
+ return { state: "unknown", partialUnknown: false, counts };
3853
+ }
3854
+
3855
+ // src/release.ts
3856
+ var MESH_RELEASE_CHANNELS = ["preview", "stable"];
3857
+ function isMeshReleaseChannel(value) {
3858
+ return typeof value === "string" && MESH_RELEASE_CHANNELS.includes(value);
3859
+ }
3860
+ var MESH_RELEASE_STATUSES = ["planned", "frozen", "deployed", "verified", "superseded", "cancelled"];
3861
+ function isReleaseStatus(value) {
3862
+ return typeof value === "string" && MESH_RELEASE_STATUSES.includes(value);
3863
+ }
3864
+ var RELEASE_MEMBER_STATES = ["member", "moved_out", "removed"];
3865
+ var RELEASE_ACTORS = ["coordinator", "owner", "assistant", "script"];
3866
+ var RELEASE_EVENT_TYPES = [
3867
+ "created",
3868
+ "status_changed",
3869
+ "scope_added",
3870
+ "scope_moved",
3871
+ "scope_removed",
3872
+ "deploy_recorded",
3873
+ "changelog_drafted",
3874
+ "changelog_applied"
3875
+ ];
3876
+ var MISSION_RELEASE_EVENT_TYPES = ["release_attached", "release_moved", "release_detached"];
3877
+ var RELEASE_LIMITS = {
3878
+ name: 80,
3879
+ note: 500,
3880
+ /** `mesh_missions.release_note`: one user/operator-visible sentence. */
3881
+ releaseNote: 400,
3882
+ missionsPerCall: 100,
3883
+ changelogEntries: 300
3884
+ };
3885
+ var CHANGELOG_SECTIONS = ["Added", "Fixed", "Changed"];
3886
+ var NEEDS_WORDING_MARKER = "[needs user-facing wording]";
3887
+ function changelogMissionMarker(missionId) {
3888
+ return `<!-- m:${missionId.slice(0, 8)} -->`;
3889
+ }
3890
+ function classifyChangelogSection(text, hint) {
3891
+ const m = /^\s*\[(added|fixed|changed)\]\s*/i.exec(text);
3892
+ if (m) {
3893
+ const key = m[1].toLowerCase();
3894
+ return { section: key === "added" ? "Added" : key === "fixed" ? "Fixed" : "Changed", text: text.slice(m[0].length).trim() };
3895
+ }
3896
+ const probe = `${hint ?? ""} ${text}`.toLowerCase();
3897
+ if (/\b(fix|fixes|fixed|bug|regression|crash|error)\b|오류|결함|버그|수정/.test(probe)) return { section: "Fixed", text };
3898
+ if (/\b(add|adds|added|new|introduc\w*|support\w*)\b|신규|추가/.test(probe)) return { section: "Added", text };
3899
+ return { section: "Changed", text };
3900
+ }
3901
+ function lintChangelogText(text) {
3902
+ const out = [];
3903
+ if (/\bwave[\s-]*\d+/i.test(text) || /웨이브\s*\d+/.test(text)) out.push("mentions an internal wave number");
3904
+ if (/\brc[.\s-]?\d+\b/i.test(text)) out.push("mentions an internal rc number");
3905
+ if (/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i.test(text) || /\bmi_[0-9a-f]{12}\b/.test(text) || /\brel_[0-9a-f]{12}\b/.test(text)) out.push("contains an internal id");
3906
+ if (/\bmission\b/i.test(text)) out.push('mentions "mission" (internal vocabulary)');
3907
+ return out;
3908
+ }
3909
+
3910
+ // src/decision-push-relay.ts
3911
+ var DECISION_PUSH_RELAY_COMMAND = "mission_decision_push_relay_answer";
3912
+ var DECISION_PUSH_RELAY_SOURCE = "push_relay";
3913
+
3112
3914
  // src/keyed-doc-delta.ts
3113
3915
  function sig(value) {
3114
3916
  if (value === void 0) return void 0;
@@ -3329,7 +4131,15 @@ function foldKeyedDoc(held, delta, spec) {
3329
4131
  const heldList = heldCollections.get(path);
3330
4132
  if (change?.absent) {
3331
4133
  const [head2, tail2] = splitPath(path);
3332
- if (!tail2) delete next[head2];
4134
+ if (!tail2) {
4135
+ delete next[head2];
4136
+ continue;
4137
+ }
4138
+ const parent2 = next[head2];
4139
+ if (!isRecord3(parent2) || !(tail2 in parent2)) continue;
4140
+ const copy = { ...parent2 };
4141
+ delete copy[tail2];
4142
+ next[head2] = copy;
3333
4143
  continue;
3334
4144
  }
3335
4145
  if (!change && heldList === void 0) continue;
@@ -3393,8 +4203,481 @@ function stableMeshNodeRow(row) {
3393
4203
  }
3394
4204
  return out;
3395
4205
  }
4206
+
4207
+ // src/provider-approval.ts
4208
+ function isActionableProviderApproval(approval) {
4209
+ return !!approval && approval.source === "provider_modal" && approval.type === "tool_permission" && approval.lifecycle === "pending" && approval.evidence === "live" && approval.actionable && !!approval.modalKey && Array.isArray(approval.buttons) && approval.buttons.some((button) => typeof button === "string" && !!button.trim());
4210
+ }
4211
+ function readProviderDecision(approval, waiting, hasModal = false) {
4212
+ if (approval !== void 0) return approval && ["provider_modal", "legacy_provider", "status_only", "ledger_approval"].includes(approval.source) ? approval : null;
4213
+ if (!waiting) return null;
4214
+ return {
4215
+ source: hasModal ? "legacy_provider" : "status_only",
4216
+ type: "unknown",
4217
+ compatibility: hasModal ? "session_only" : "unknown",
4218
+ evidence: "unavailable",
4219
+ lifecycle: "pending",
4220
+ modalKey: null,
4221
+ createdAt: null,
4222
+ resolvedAt: null,
4223
+ description: "",
4224
+ buttons: [],
4225
+ actionable: false
4226
+ };
4227
+ }
4228
+ function providerApprovalSnapshot(approval) {
4229
+ if (!approval) return null;
4230
+ const {
4231
+ source,
4232
+ type,
4233
+ lifecycle,
4234
+ modalKey,
4235
+ createdAt,
4236
+ resolvedAt,
4237
+ providerType,
4238
+ sessionId,
4239
+ nodeId,
4240
+ meshId,
4241
+ taskId,
4242
+ attemptId,
4243
+ generation
4244
+ } = approval;
4245
+ return {
4246
+ source,
4247
+ type,
4248
+ lifecycle,
4249
+ modalKey,
4250
+ createdAt,
4251
+ resolvedAt,
4252
+ providerType,
4253
+ sessionId,
4254
+ nodeId,
4255
+ meshId,
4256
+ taskId,
4257
+ attemptId,
4258
+ generation,
4259
+ evidence: "cached",
4260
+ actionable: false,
4261
+ description: "",
4262
+ buttons: []
4263
+ };
4264
+ }
4265
+
4266
+ // src/provider-question.ts
4267
+ function isProviderQuestionBinding(value) {
4268
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
4269
+ const b = value;
4270
+ if (b.transport !== "codex_rpc" && b.transport !== "codex_async") return false;
4271
+ const keys = ["transport", "sessionId", "generation", "threadId", "turnId", "itemId", ...b.transport === "codex_rpc" ? ["requestId"] : []];
4272
+ if (Reflect.ownKeys(b).some((key) => typeof key !== "string" || !keys.includes(key))) return false;
4273
+ if (["sessionId", "generation", "threadId", "turnId", "itemId"].some((key) => typeof b[key] !== "string" || !b[key].trim())) return false;
4274
+ return b.transport === "codex_async" ? b.requestId === void 0 : typeof b.requestId === "string" && !!b.requestId.trim() || typeof b.requestId === "number" && Number.isFinite(b.requestId);
4275
+ }
4276
+
4277
+ // src/task-source-phase.ts
4278
+ function reviewIndependenceOf(review) {
4279
+ return review.independence ?? "different_provider";
4280
+ }
4281
+
4282
+ // src/light-task.ts
4283
+ var LIGHT_REJECT = {
4284
+ REQUIRES_LOCAL_BASE: "light_requires_local_base",
4285
+ NOT_CONFIGURED: "light_workspace_not_configured",
4286
+ REQUIRES_OWNED_PATHS: "light_requires_owned_paths",
4287
+ MODE_CONFLICT: "light_mode_conflict"
4288
+ };
4289
+ var LIGHT_HOLD = {
4290
+ PREPARE_FAILED: "light_workspace_prepare_failed",
4291
+ LIMIT: "light_workspace_limit",
4292
+ DISK_LOW: "light_workspace_disk_low",
4293
+ CAP: "max_light_parallel_tasks_reached"
4294
+ };
4295
+ var LIGHT_BLOCK_REASONS = [
4296
+ "light_uncommitted_changes",
4297
+ "light_dependency_change",
4298
+ "light_lineage_unproven",
4299
+ "shared_checkout_mutated"
4300
+ ];
4301
+ var LIGHT_WARNINGS = ["shared_checkout_changed_during_task", "light_base_dirty_overlap"];
4302
+ var LIGHT_LAND_MODES = ["refine", "apply_to_checkout"];
4303
+ var LIGHT_TESTS_RUN_MAX = 20;
4304
+ function isLightWorkerSession(session) {
4305
+ const s = session;
4306
+ if (!s || typeof s !== "object") return false;
4307
+ const has = (o) => !!o && typeof o === "object" && typeof o.lightWorkspaceId === "string" && o.lightWorkspaceId.trim() !== "";
4308
+ return has(s.settings) || has(s.launchRecord?.settings) || has(s);
4309
+ }
4310
+
4311
+ // src/relay-reprobe.ts
4312
+ var RELAY_REPROBE_BASE_DELAY_MS = 6e4;
4313
+ var RELAY_REPROBE_MAX_DELAY_MS = 5 * 6e4;
4314
+ var RELAY_REPROBE_JITTER_RATIO = 0.2;
4315
+ function computeRelayReprobeDelay(failures, random, timing = {}) {
4316
+ const base = timing.baseDelayMs ?? RELAY_REPROBE_BASE_DELAY_MS;
4317
+ const max = timing.maxDelayMs ?? RELAY_REPROBE_MAX_DELAY_MS;
4318
+ const jitter = timing.jitterRatio ?? RELAY_REPROBE_JITTER_RATIO;
4319
+ const grown = Math.min(max, base * 2 ** Math.max(0, failures));
4320
+ const factor = 1 + jitter * (Math.min(1, Math.max(0, random())) * 2 - 1);
4321
+ return Math.round(grown * factor);
4322
+ }
4323
+ var RelayReprobeScheduler = class {
4324
+ constructor(options) {
4325
+ this.options = options;
4326
+ }
4327
+ handle = null;
4328
+ running = false;
4329
+ inFlight = false;
4330
+ failureCount = 0;
4331
+ generation = 0;
4332
+ get isRunning() {
4333
+ return this.running;
4334
+ }
4335
+ get failures() {
4336
+ return this.failureCount;
4337
+ }
4338
+ get probing() {
4339
+ return this.inFlight;
4340
+ }
4341
+ /** Begin probing (idempotent). Call when a connection is selected as relay. */
4342
+ start() {
4343
+ if (this.running) return;
4344
+ this.running = true;
4345
+ this.failureCount = 0;
4346
+ this.generation++;
4347
+ this.schedule();
4348
+ }
4349
+ /** Stop for good (direct path found, connection closed, auth epoch changed). */
4350
+ stop() {
4351
+ this.running = false;
4352
+ this.generation++;
4353
+ if (this.handle !== null) {
4354
+ this.options.clearTimer(this.handle);
4355
+ this.handle = null;
4356
+ }
4357
+ }
4358
+ schedule() {
4359
+ if (!this.running) return;
4360
+ const generation = this.generation;
4361
+ const delay = computeRelayReprobeDelay(this.failureCount, this.options.random, this.options);
4362
+ this.handle = this.options.setTimer(() => {
4363
+ this.handle = null;
4364
+ void this.tick(generation);
4365
+ }, delay);
4366
+ }
4367
+ async tick(generation) {
4368
+ if (!this.running || generation !== this.generation) return;
4369
+ if (this.inFlight || !this.options.shouldProbe()) {
4370
+ this.schedule();
4371
+ return;
4372
+ }
4373
+ this.inFlight = true;
4374
+ let outcome;
4375
+ try {
4376
+ outcome = await this.options.probe();
4377
+ } catch {
4378
+ outcome = "failed";
4379
+ }
4380
+ this.inFlight = false;
4381
+ if (!this.running || generation !== this.generation) return;
4382
+ if (outcome === "direct") {
4383
+ this.stop();
4384
+ return;
4385
+ }
4386
+ if (outcome !== "skipped") this.failureCount++;
4387
+ this.schedule();
4388
+ }
4389
+ };
4390
+
4391
+ // src/task-stages.ts
4392
+ var REVIEW_VERDICTS = ["approve", "approve_with_nits", "changes_requested", "reject_approach"];
4393
+ var FINDING_SEVERITIES = ["blocking", "major", "minor", "nit"];
4394
+ var FINDING_CATEGORIES = ["correctness", "regression", "test_gap", "scope", "security", "performance", "maintainability"];
4395
+ var PRIOR_FINDING_STATUSES = ["resolved", "unresolved", "dispute_accepted", "dispute_rejected"];
4396
+ var FINDING_RESPONSE_KINDS = ["fixed", "disputed"];
4397
+ var STAGE_PHASES = ["implementing", "self_checking", "awaiting_review", "reviewing", "revising", "done"];
4398
+ var STAGE_PARKED_PHASES = ["self_checking", "awaiting_review", "reviewing"];
4399
+ var STAGE_INDEPENDENCE_MODES = ["different_provider", "fresh_session_ok"];
4400
+ var STAGE_ROLES = ["implement", "revise", "review"];
4401
+ var STAGE_BLOCKED_REASONS = [
4402
+ "review_unresolved",
4403
+ "review_rejected_approach",
4404
+ "review_unavailable",
4405
+ "self_check_failed",
4406
+ "stage_pipeline_ceiling",
4407
+ "reviewer_mutated_source",
4408
+ // The read-lease checkout could not be fingerprinted (start or end): the review's integrity cannot be verified.
4409
+ "reviewer_integrity_unverifiable"
4410
+ ];
4411
+ var STAGE_DECIDE_ACTIONS = ["accept", "revise_once", "rereview", "abandon"];
4412
+ var STAGE_MAX_REVISIONS_LIMIT = 3;
4413
+ var STAGE_DEFAULT_MAX_REVISIONS = 2;
4414
+ var STAGE_SELF_CHECK_MAX_BOUNCES = 2;
4415
+ var STAGE_INDEPENDENCE_FALLBACK_MS = 10 * 60 * 1e3;
4416
+ var STAGE_PIPELINE_CEILING_DEFAULT_MS = 4 * 60 * 60 * 1e3;
4417
+ var REVIEW_FINDINGS_MAX = 30;
4418
+ var REVIEW_CLAIM_MAX_CHARS = 500;
4419
+ var REVIEW_EVIDENCE_MAX_CHARS = 1e3;
4420
+ var REVIEW_FIX_MAX_CHARS = 500;
4421
+ var REVIEW_FINDING_ID_MAX_CHARS = 40;
4422
+ var REVIEW_CHECKED_MAX = 20;
4423
+ var REVIEW_NOTE_MAX_CHARS = 500;
4424
+ var REVIEW_TESTS_RUN_MAX = 20;
4425
+ var FINDING_RESPONSES_MAX = 30;
4426
+ function makeGuard4(values) {
4427
+ const set = new Set(values);
4428
+ return (value) => typeof value === "string" && set.has(value);
4429
+ }
4430
+ var isReviewVerdict = makeGuard4(REVIEW_VERDICTS);
4431
+ var isFindingSeverity = makeGuard4(FINDING_SEVERITIES);
4432
+ var isFindingCategory = makeGuard4(FINDING_CATEGORIES);
4433
+ var isPriorFindingStatus = makeGuard4(PRIOR_FINDING_STATUSES);
4434
+ var isFindingResponseKind = makeGuard4(FINDING_RESPONSE_KINDS);
4435
+ var isStageBlockedReason = makeGuard4(STAGE_BLOCKED_REASONS);
4436
+ var isRecord4 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
4437
+ function isBlockingSeverity(severity) {
4438
+ return severity === "blocking" || severity === "major";
4439
+ }
4440
+ function resolveStagePlan(raw, task, opts = {}) {
4441
+ const eligible = isStageEligibleTask(task);
4442
+ if (raw === void 0 || raw === null) return (opts.defaultOn ?? true) && defaultsOnFor(task) ? defaultStagePlan() : null;
4443
+ if (raw === false) return null;
4444
+ if (raw === true) {
4445
+ if (!eligible) throw new Error(`invalid_review_option: review requires a non-readonly code_change task (got taskMode=${task.taskMode ?? "unset"}${task.readonly ? ", readonly" : ""})`);
4446
+ return defaultStagePlan();
4447
+ }
4448
+ if (!isRecord4(raw)) throw new Error("invalid_review_option: review must be true, false or {max_revisions?, independence?}");
4449
+ const allowed = /* @__PURE__ */ new Set(["max_revisions", "maxRevisions", "independence"]);
4450
+ for (const key of Object.keys(raw)) {
4451
+ if (!allowed.has(key)) throw new Error(`invalid_review_option: unknown review key '${key}' (expected max_revisions, independence)`);
4452
+ }
4453
+ if (!eligible) throw new Error(`invalid_review_option: review requires a non-readonly code_change task (got taskMode=${task.taskMode ?? "unset"}${task.readonly ? ", readonly" : ""})`);
4454
+ const rawMax = raw.max_revisions ?? raw.maxRevisions;
4455
+ let maxRevisions = STAGE_DEFAULT_MAX_REVISIONS;
4456
+ if (rawMax !== void 0) {
4457
+ if (typeof rawMax !== "number" || !Number.isInteger(rawMax) || rawMax < 0 || rawMax > STAGE_MAX_REVISIONS_LIMIT) {
4458
+ throw new Error(`invalid_review_option: max_revisions must be an integer 0..${STAGE_MAX_REVISIONS_LIMIT}`);
4459
+ }
4460
+ maxRevisions = rawMax;
4461
+ }
4462
+ let independence = "fresh_session_ok";
4463
+ if (raw.independence !== void 0) {
4464
+ if (!STAGE_INDEPENDENCE_MODES.includes(raw.independence)) {
4465
+ throw new Error(`invalid_review_option: independence must be one of ${STAGE_INDEPENDENCE_MODES.join(" | ")}`);
4466
+ }
4467
+ independence = raw.independence;
4468
+ }
4469
+ return { review: true, maxRevisions, independence };
4470
+ }
4471
+ function defaultStagePlan() {
4472
+ return { review: true, maxRevisions: STAGE_DEFAULT_MAX_REVISIONS, independence: "fresh_session_ok" };
4473
+ }
4474
+ function isStageEligibleTask(task) {
4475
+ if (task.readonly) return false;
4476
+ return (task.taskMode ?? "code_change") === "code_change";
4477
+ }
4478
+ function defaultsOnFor(task) {
4479
+ return isStageEligibleTask(task) && (task.difficulty === "medium" || task.difficulty === "difficult");
4480
+ }
4481
+ function str2(value) {
4482
+ return typeof value === "string" ? value.trim() : "";
4483
+ }
4484
+ function validateStringList(value, field, max, maxChars, errors, minItems = 0) {
4485
+ if (!Array.isArray(value)) {
4486
+ errors.push({ field, message: `${field} must be an array of strings` });
4487
+ return [];
4488
+ }
4489
+ if (value.length > max) errors.push({ field, message: `${field} has ${value.length} entries, over the ${max} limit` });
4490
+ const out = [];
4491
+ for (const item of value) {
4492
+ const text = str2(item);
4493
+ if (!text) continue;
4494
+ if (text.length > maxChars) {
4495
+ errors.push({ field, message: `${field} contains an entry over ${maxChars} chars` });
4496
+ continue;
4497
+ }
4498
+ out.push(text);
4499
+ }
4500
+ if (out.length < minItems) errors.push({ field, message: `${field} needs at least ${minItems} entry \u2014 an empty ${field} list is a review with no recorded scope` });
4501
+ return out;
4502
+ }
4503
+ function validateReviewReport(raw, ctx) {
4504
+ const errors = [];
4505
+ if (!isRecord4(raw)) return { errors: [{ field: "review", message: "review must be an object {verdict, findings, checked, notChecked, ...}" }] };
4506
+ const KNOWN = /* @__PURE__ */ new Set(["verdict", "findings", "priorFindings", "checked", "notChecked", "testsRun"]);
4507
+ for (const key of Object.keys(raw)) if (!KNOWN.has(key)) errors.push({ field: `review.${key}`, message: `unknown field '${key}' (expected one of: ${[...KNOWN].join(", ")})` });
4508
+ const verdict = raw.verdict;
4509
+ if (!isReviewVerdict(verdict)) errors.push({ field: "review.verdict", message: `verdict must be one of ${REVIEW_VERDICTS.join(" | ")}` });
4510
+ const findings = [];
4511
+ if (!Array.isArray(raw.findings)) errors.push({ field: "review.findings", message: "findings must be an array (use [] when there are none)" });
4512
+ else {
4513
+ if (raw.findings.length > REVIEW_FINDINGS_MAX) errors.push({ field: "review.findings", message: `findings has ${raw.findings.length} entries, over the ${REVIEW_FINDINGS_MAX} limit \u2014 keep the most important` });
4514
+ const seen = /* @__PURE__ */ new Set();
4515
+ raw.findings.forEach((f, i) => {
4516
+ const at = `review.findings[${i}]`;
4517
+ if (!isRecord4(f)) {
4518
+ errors.push({ field: at, message: "each finding must be an object" });
4519
+ return;
4520
+ }
4521
+ const FK = /* @__PURE__ */ new Set(["id", "severity", "category", "file", "line", "claim", "evidence", "suggestedFix"]);
4522
+ for (const key of Object.keys(f)) if (!FK.has(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
4523
+ const id2 = str2(f.id);
4524
+ if (!id2 || id2.length > REVIEW_FINDING_ID_MAX_CHARS) errors.push({ field: `${at}.id`, message: `id is required (\u2264 ${REVIEW_FINDING_ID_MAX_CHARS} chars)` });
4525
+ else if (seen.has(id2)) errors.push({ field: `${at}.id`, message: `duplicate finding id '${id2}'` });
4526
+ else seen.add(id2);
4527
+ if (!isFindingSeverity(f.severity)) errors.push({ field: `${at}.severity`, message: `severity must be one of ${FINDING_SEVERITIES.join(" | ")}` });
4528
+ if (!isFindingCategory(f.category)) errors.push({ field: `${at}.category`, message: `category must be one of ${FINDING_CATEGORIES.join(" | ")}` });
4529
+ const claim = str2(f.claim);
4530
+ if (!claim) errors.push({ field: `${at}.claim`, message: "claim is required" });
4531
+ else if (claim.length > REVIEW_CLAIM_MAX_CHARS) errors.push({ field: `${at}.claim`, message: `claim is over ${REVIEW_CLAIM_MAX_CHARS} chars` });
4532
+ const evidence = str2(f.evidence);
4533
+ if (!evidence) errors.push({ field: `${at}.evidence`, message: "evidence is required \u2014 what did you read or run to know this" });
4534
+ else if (evidence.length > REVIEW_EVIDENCE_MAX_CHARS) errors.push({ field: `${at}.evidence`, message: `evidence is over ${REVIEW_EVIDENCE_MAX_CHARS} chars` });
4535
+ const fix = f.suggestedFix === void 0 ? void 0 : str2(f.suggestedFix);
4536
+ if (fix !== void 0 && fix.length > REVIEW_FIX_MAX_CHARS) errors.push({ field: `${at}.suggestedFix`, message: `suggestedFix is over ${REVIEW_FIX_MAX_CHARS} chars` });
4537
+ if (f.file !== void 0 && typeof f.file !== "string") errors.push({ field: `${at}.file`, message: "file must be a string" });
4538
+ if (f.line !== void 0 && (typeof f.line !== "number" || !Number.isInteger(f.line) || f.line < 1)) errors.push({ field: `${at}.line`, message: "line must be a positive integer" });
4539
+ if (id2 && isFindingSeverity(f.severity) && isFindingCategory(f.category) && claim && evidence) {
4540
+ findings.push({
4541
+ id: id2,
4542
+ severity: f.severity,
4543
+ category: f.category,
4544
+ ...typeof f.file === "string" && f.file.trim() ? { file: f.file.trim() } : {},
4545
+ ...typeof f.line === "number" ? { line: f.line } : {},
4546
+ claim,
4547
+ evidence,
4548
+ ...fix ? { suggestedFix: fix } : {}
4549
+ });
4550
+ }
4551
+ });
4552
+ }
4553
+ const checked = validateStringList(raw.checked, "review.checked", REVIEW_CHECKED_MAX, REVIEW_CLAIM_MAX_CHARS, errors, 1);
4554
+ const notChecked = validateStringList(raw.notChecked, "review.notChecked", REVIEW_CHECKED_MAX, REVIEW_CLAIM_MAX_CHARS, errors, 1);
4555
+ let priorFindings;
4556
+ if (raw.priorFindings !== void 0) {
4557
+ if (!Array.isArray(raw.priorFindings)) errors.push({ field: "review.priorFindings", message: "priorFindings must be an array" });
4558
+ else {
4559
+ priorFindings = [];
4560
+ raw.priorFindings.forEach((p, i) => {
4561
+ const at = `review.priorFindings[${i}]`;
4562
+ if (!isRecord4(p)) {
4563
+ errors.push({ field: at, message: "each entry must be an object {id, status, note?}" });
4564
+ return;
4565
+ }
4566
+ for (const key of Object.keys(p)) if (!["id", "status", "note"].includes(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
4567
+ const id2 = str2(p.id);
4568
+ if (!id2) errors.push({ field: `${at}.id`, message: "id is required" });
4569
+ if (!isPriorFindingStatus(p.status)) errors.push({ field: `${at}.status`, message: `status must be one of ${PRIOR_FINDING_STATUSES.join(" | ")}` });
4570
+ const note = p.note === void 0 ? void 0 : str2(p.note);
4571
+ if (note !== void 0 && note.length > REVIEW_NOTE_MAX_CHARS) errors.push({ field: `${at}.note`, message: `note is over ${REVIEW_NOTE_MAX_CHARS} chars` });
4572
+ if (id2 && isPriorFindingStatus(p.status)) priorFindings.push({ id: id2, status: p.status, ...note ? { note } : {} });
4573
+ });
4574
+ }
4575
+ }
4576
+ const testsRun = raw.testsRun === void 0 ? void 0 : validateTestsRun(raw.testsRun, "review.testsRun", errors);
4577
+ if (isReviewVerdict(verdict)) {
4578
+ const blocking = findings.filter((f) => isBlockingSeverity(f.severity));
4579
+ if (verdict === "changes_requested" && blocking.length === 0 && Array.isArray(raw.findings) && errors.length === 0) {
4580
+ errors.push({ field: "review.verdict", message: "changes_requested needs at least one blocking or major finding \u2014 nits alone are approve_with_nits" });
4581
+ }
4582
+ if (verdict === "approve" && blocking.length > 0) {
4583
+ errors.push({ field: "review.verdict", message: "approve cannot carry blocking or major findings" });
4584
+ }
4585
+ if (verdict === "approve_with_nits" && blocking.length > 0) {
4586
+ errors.push({ field: "review.verdict", message: "approve_with_nits cannot carry blocking or major findings \u2014 use changes_requested" });
4587
+ }
4588
+ }
4589
+ if (ctx.round >= 2 && ctx.priorOpenBlockingIds?.length) {
4590
+ const answered = new Set((priorFindings ?? []).map((p) => p.id));
4591
+ const missing = ctx.priorOpenBlockingIds.filter((id2) => !answered.has(id2));
4592
+ if (missing.length) errors.push({ field: "review.priorFindings", message: `round ${ctx.round} must give a status for every prior blocking/major finding; missing: ${missing.join(", ")}` });
4593
+ }
4594
+ if (errors.length) return { errors };
4595
+ return {
4596
+ report: {
4597
+ verdict,
4598
+ findings,
4599
+ ...priorFindings?.length ? { priorFindings } : {},
4600
+ checked,
4601
+ notChecked,
4602
+ ...testsRun?.length ? { testsRun } : {}
4603
+ },
4604
+ errors: []
4605
+ };
4606
+ }
4607
+ function validateTestsRun(raw, field, errors) {
4608
+ if (!Array.isArray(raw)) {
4609
+ errors.push({ field, message: `${field} must be an array of {command, exit, passed?, failed?, note?}` });
4610
+ return [];
4611
+ }
4612
+ if (raw.length > REVIEW_TESTS_RUN_MAX) errors.push({ field, message: `${field} has ${raw.length} entries, over the ${REVIEW_TESTS_RUN_MAX} limit` });
4613
+ const out = [];
4614
+ raw.forEach((t, i) => {
4615
+ const at = `${field}[${i}]`;
4616
+ if (!isRecord4(t)) {
4617
+ errors.push({ field: at, message: "each entry must be an object" });
4618
+ return;
4619
+ }
4620
+ for (const key of Object.keys(t)) if (!["command", "exit", "passed", "failed", "note"].includes(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
4621
+ const command = str2(t.command);
4622
+ if (!command || command.length > REVIEW_CLAIM_MAX_CHARS) errors.push({ field: `${at}.command`, message: `command is required (\u2264 ${REVIEW_CLAIM_MAX_CHARS} chars)` });
4623
+ if (typeof t.exit !== "number" || !Number.isInteger(t.exit)) errors.push({ field: `${at}.exit`, message: "exit must be an integer" });
4624
+ for (const k of ["passed", "failed"]) {
4625
+ if (t[k] !== void 0 && (typeof t[k] !== "number" || !Number.isInteger(t[k]) || t[k] < 0)) errors.push({ field: `${at}.${k}`, message: `${k} must be a non-negative integer` });
4626
+ }
4627
+ const note = t.note === void 0 ? void 0 : str2(t.note);
4628
+ if (note !== void 0 && note.length > REVIEW_NOTE_MAX_CHARS) errors.push({ field: `${at}.note`, message: `note is over ${REVIEW_NOTE_MAX_CHARS} chars` });
4629
+ if (command && typeof t.exit === "number") {
4630
+ out.push({
4631
+ command,
4632
+ exit: t.exit,
4633
+ ...typeof t.passed === "number" ? { passed: t.passed } : {},
4634
+ ...typeof t.failed === "number" ? { failed: t.failed } : {},
4635
+ ...note ? { note } : {}
4636
+ });
4637
+ }
4638
+ });
4639
+ return out;
4640
+ }
4641
+ function validateFindingResponses(raw, field = "findingResponses") {
4642
+ const errors = [];
4643
+ if (!Array.isArray(raw)) return { errors: [{ field, message: `${field} must be an array of {id, response, note}` }] };
4644
+ if (raw.length > FINDING_RESPONSES_MAX) errors.push({ field, message: `${field} has ${raw.length} entries, over the ${FINDING_RESPONSES_MAX} limit` });
4645
+ const out = [];
4646
+ raw.forEach((r, i) => {
4647
+ const at = `${field}[${i}]`;
4648
+ if (!isRecord4(r)) {
4649
+ errors.push({ field: at, message: "each entry must be an object {id, response, note}" });
4650
+ return;
4651
+ }
4652
+ for (const key of Object.keys(r)) if (!["id", "response", "note"].includes(key)) errors.push({ field: `${at}.${key}`, message: `unknown field '${key}'` });
4653
+ const id2 = str2(r.id);
4654
+ if (!id2) errors.push({ field: `${at}.id`, message: "id is required" });
4655
+ if (!isFindingResponseKind(r.response)) errors.push({ field: `${at}.response`, message: `response must be one of ${FINDING_RESPONSE_KINDS.join(" | ")}` });
4656
+ const note = str2(r.note);
4657
+ if (!note) errors.push({ field: `${at}.note`, message: "note is required \u2014 say what changed, or why you dispute it" });
4658
+ else if (note.length > REVIEW_NOTE_MAX_CHARS) errors.push({ field: `${at}.note`, message: `note is over ${REVIEW_NOTE_MAX_CHARS} chars` });
4659
+ if (id2 && isFindingResponseKind(r.response) && note && note.length <= REVIEW_NOTE_MAX_CHARS) out.push({ id: id2, response: r.response, note });
4660
+ });
4661
+ return errors.length ? { errors } : { responses: out, errors: [] };
4662
+ }
4663
+ function formatStageVerdictLine(input) {
4664
+ const parts = [`review: ${input.verdict}`];
4665
+ if (input.verdict === "skipped_no_diff") return parts[0];
4666
+ parts.push(`${input.rounds} round${input.rounds === 1 ? "" : "s"}`);
4667
+ if (input.reviewerProvider) parts.push(`reviewer ${input.reviewerProvider} (${input.independenceUsed ?? "different_provider"})`);
4668
+ const tail = [];
4669
+ if (input.fixed) tail.push(`${input.fixed} finding${input.fixed === 1 ? "" : "s"} fixed`);
4670
+ if (input.openNits) tail.push(`${input.openNits} nit${input.openNits === 1 ? "" : "s"} open`);
4671
+ return tail.length ? `${parts.join(" \xB7 ")} \xB7 ${tail.join(", ")}` : parts.join(" \xB7 ");
4672
+ }
3396
4673
  export {
4674
+ ASSISTANT_ACCOUNT_SLOT,
4675
+ ASSISTANT_FOLLOWER_ALLOWED_OPS,
3397
4676
  ASSISTANT_OWNER_VERBS,
4677
+ ASSISTANT_REMOTE_FOLLOW_COMMAND,
4678
+ ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND,
4679
+ ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND,
4680
+ ASSISTANT_REMOTE_PROJECT_COMMAND,
3398
4681
  ASSISTANT_REVIEW_TURN_VERBS,
3399
4682
  ASSISTANT_SESSION_ID_ARG,
3400
4683
  ASSISTANT_SESSION_ID_ENV,
@@ -3406,12 +4689,16 @@ export {
3406
4689
  CANCEL_REASONS,
3407
4690
  CANONICAL_MESH_TOOL_COUNT,
3408
4691
  CANONICAL_MESH_TOOL_NAMES,
4692
+ CARRY_OVER_MISSION_GOAL,
4693
+ CARRY_OVER_MISSION_TITLE,
4694
+ CHANGELOG_SECTIONS,
3409
4695
  CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX,
3410
4696
  CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX,
3411
4697
  CLI_SLOT_RECIPES,
3412
4698
  COMMIT_STRENGTHS,
3413
4699
  CONSUME_PROFILES,
3414
4700
  COORDINATOR_ACK_OUTCOMES,
4701
+ COORDINATOR_SETTABLE_ITEM_STATES,
3415
4702
  DAEMON_METADATA_DOC_SPEC,
3416
4703
  DAEMON_P2P_SIGNAL_TYPES,
3417
4704
  DAEMON_STATUS_EVENT_NAMES,
@@ -3424,13 +4711,34 @@ export {
3424
4711
  DASHBOARD_TO_DAEMON_P2P_TYPES,
3425
4712
  DASHBOARD_TO_USER_SESSION_TYPES,
3426
4713
  DASHBOARD_WIRE_VERSION,
4714
+ DECISION_PUSH_OPTIONS_MAX,
4715
+ DECISION_PUSH_OPTION_LABEL_MAX,
4716
+ DECISION_PUSH_QUESTION_MAX,
4717
+ DECISION_PUSH_RELAY_COMMAND,
4718
+ DECISION_PUSH_RELAY_SOURCE,
3427
4719
  DEFAULT_DIFFICULTY_BRAINS,
3428
4720
  DELIVERY_OUTCOMES,
3429
4721
  DELIVERY_VIAS,
3430
4722
  DISPATCH_FAILURE_REASONS,
4723
+ DISPATCH_REFUSAL_DETAIL_MAX,
3431
4724
  EVIDENCE_ENVELOPE_FIELD_SPECS,
3432
4725
  EVIDENCE_SOURCE_IDS,
4726
+ FINDING_CATEGORIES,
4727
+ FINDING_RESPONSES_MAX,
4728
+ FINDING_RESPONSE_KINDS,
4729
+ FINDING_SEVERITIES,
3433
4730
  HOLD_REASONS,
4731
+ LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE,
4732
+ LAUNCH_DEFAULT_ERROR_CODES,
4733
+ LAUNCH_DEFAULT_ROLES,
4734
+ LAUNCH_DEFAULT_SOURCES,
4735
+ LEGACY_CARRY_OVER_MISSION_TITLE,
4736
+ LIGHT_BLOCK_REASONS,
4737
+ LIGHT_HOLD,
4738
+ LIGHT_LAND_MODES,
4739
+ LIGHT_REJECT,
4740
+ LIGHT_TESTS_RUN_MAX,
4741
+ LIGHT_WARNINGS,
3434
4742
  LIVENESS_RESULTS,
3435
4743
  MAX_MESH_RECORD_STRING,
3436
4744
  MAX_OWNED_PATHS,
@@ -3445,6 +4753,8 @@ export {
3445
4753
  MESH_MISSION_STATUSES,
3446
4754
  MESH_P2P_SIGNAL_TYPES,
3447
4755
  MESH_RECORD_PAYLOAD_KEYS,
4756
+ MESH_RELEASE_CHANNELS,
4757
+ MESH_RELEASE_STATUSES,
3448
4758
  MESH_SESSION_CLEANUP_MODES,
3449
4759
  MESH_STATUS_DOC_SPEC,
3450
4760
  MESH_TASK_DIFFICULTIES,
@@ -3456,10 +4766,23 @@ export {
3456
4766
  MESH_TOPIC_ENTRY_KINDS,
3457
4767
  MESH_TOPIC_PROTOCOL_VERSION,
3458
4768
  MISSION_BRIEF_RENDER_MAX_CHARS,
4769
+ MISSION_DECISION_ON_DUE,
4770
+ MISSION_DECISION_OPTION_IDS,
4771
+ MISSION_DECISION_URGENCIES,
4772
+ MISSION_GIT_STATES,
4773
+ MISSION_ITEM_KINDS,
4774
+ MISSION_ITEM_STATES,
4775
+ MISSION_LIMITS,
4776
+ MISSION_OUTCOMES,
4777
+ MISSION_REF_GIT_METHODS,
4778
+ MISSION_REF_GIT_STATUSES,
4779
+ MISSION_REF_KINDS,
4780
+ MISSION_RELEASE_EVENT_TYPES,
3459
4781
  MODEL_AXIS_SOURCES,
3460
4782
  MODEL_SELECTION_HISTORY_LIMIT,
3461
4783
  MeshChunkAssembler,
3462
4784
  NATIVE_TURN_OUTCOMES,
4785
+ NEEDS_WORDING_MARKER,
3463
4786
  NOTIFY_KINDS,
3464
4787
  NO_PROGRESS_OBSERVED_STATUSES,
3465
4788
  NPM_UPDATE_TAGS,
@@ -3469,14 +4792,37 @@ export {
3469
4792
  OPERATOR_STATUS_REASON_VALUES,
3470
4793
  OPERATOR_STATUS_VALUES,
3471
4794
  OUTBOUND_MESSAGE_ORIGINS,
4795
+ OWNER_ABANDON_CONFIRM_KEY_PREFIX,
4796
+ OWNER_ABANDON_CONFIRM_OPTIONS,
4797
+ OWNER_ABANDON_CONFIRM_QUESTION,
3472
4798
  P2P_SIGNAL_TYPES,
4799
+ PRIOR_FINDING_STATUSES,
3473
4800
  PROVIDER_FAILURES,
4801
+ QUOTA_BACKFILL_HORIZON_MS,
4802
+ QUOTA_RETRY_INFLIGHT_GRACE_MS,
3474
4803
  QUOTA_SUPPORTED_PROVIDERS,
3475
4804
  RECENT_SESSION_BUCKETS,
3476
4805
  RECLAIMING_SEND_REFUSALS,
4806
+ RELAY_REPROBE_BASE_DELAY_MS,
4807
+ RELAY_REPROBE_JITTER_RATIO,
4808
+ RELAY_REPROBE_MAX_DELAY_MS,
4809
+ RELEASE_ACTORS,
3477
4810
  RELEASE_CHANNELS,
4811
+ RELEASE_EVENT_TYPES,
4812
+ RELEASE_LIMITS,
4813
+ RELEASE_MEMBER_STATES,
3478
4814
  REMOVED_MESH_TOOLS,
3479
4815
  RETIRED_MESH_TOOLS,
4816
+ REVIEW_CHECKED_MAX,
4817
+ REVIEW_CLAIM_MAX_CHARS,
4818
+ REVIEW_EVIDENCE_MAX_CHARS,
4819
+ REVIEW_FINDINGS_MAX,
4820
+ REVIEW_FINDING_ID_MAX_CHARS,
4821
+ REVIEW_FIX_MAX_CHARS,
4822
+ REVIEW_NOTE_MAX_CHARS,
4823
+ REVIEW_TESTS_RUN_MAX,
4824
+ REVIEW_VERDICTS,
4825
+ RelayReprobeScheduler,
3480
4826
  SEND_POLICY_MODES,
3481
4827
  SEND_REFUSAL_REASONS,
3482
4828
  SERVER_STATUS_EVENT_NAMES,
@@ -3489,6 +4835,17 @@ export {
3489
4835
  SESSION_STATUS_ALIASES,
3490
4836
  SESSION_STATUS_CLASS,
3491
4837
  SHARED_SESSION_TO_VIEWER_TYPES,
4838
+ STAGE_BLOCKED_REASONS,
4839
+ STAGE_DECIDE_ACTIONS,
4840
+ STAGE_DEFAULT_MAX_REVISIONS,
4841
+ STAGE_INDEPENDENCE_FALLBACK_MS,
4842
+ STAGE_INDEPENDENCE_MODES,
4843
+ STAGE_MAX_REVISIONS_LIMIT,
4844
+ STAGE_PARKED_PHASES,
4845
+ STAGE_PHASES,
4846
+ STAGE_PIPELINE_CEILING_DEFAULT_MS,
4847
+ STAGE_ROLES,
4848
+ STAGE_SELF_CHECK_MAX_BOUNCES,
3492
4849
  STATUS_PROBE_ARG_KEY,
3493
4850
  SUSPENSION_MODALS,
3494
4851
  SUSPENSION_RESOLUTIONS,
@@ -3514,16 +4871,27 @@ export {
3514
4871
  VERSION_UPDATE_REASONS,
3515
4872
  VIEWER_TO_SHARED_SESSION_TYPES,
3516
4873
  WORKER_BRANCH_STATES,
4874
+ WORKER_COMMITS_MAX,
4875
+ WORKER_CURRENT_BRANCH_RULE,
4876
+ WORKER_DECISIONS_NEEDED_MAX,
3517
4877
  WORKER_PROTOCOL_FOOTER_MARKER,
3518
4878
  WORKER_REPORT_OUTCOMES,
4879
+ WORKER_REPORT_SUMMARY_MAX_CHARS,
4880
+ WORKER_SHELL_LITERAL_PATHS_RULE,
3519
4881
  WORKER_TOOLS,
4882
+ aggregateMissionGitState,
3520
4883
  appendWorkerProtocolFooter,
3521
4884
  argsCarryStatusProbeMarker,
4885
+ assessQuotaFreshness,
4886
+ boundEventPayload,
3522
4887
  buildSlotProposal,
3523
4888
  canonicalDaemonId,
4889
+ changelogMissionMarker,
4890
+ classifyChangelogSection,
3524
4891
  classifySessionStatus,
3525
4892
  compareDashboardWireVersion,
3526
4893
  compareSemver,
4894
+ computeRelayReprobeDelay,
3527
4895
  daemonIdsEquivalent,
3528
4896
  decodeActiveWorkQueryRequest,
3529
4897
  decodeActiveWorkQueryResponse,
@@ -3566,6 +4934,8 @@ export {
3566
4934
  decodeQueueQueryResponse,
3567
4935
  decodeQueueRequeueRequest,
3568
4936
  decodeQueueRequeueResponse,
4937
+ decodeQueueReviseRequest,
4938
+ decodeQueueReviseResponse,
3569
4939
  decodeRecordLocalRequest,
3570
4940
  decodeRecordLocalResponse,
3571
4941
  decodeRecoveryContextQueryRequest,
@@ -3585,6 +4955,8 @@ export {
3585
4955
  decodeUserSessionToDashboard,
3586
4956
  decodeViewerToSharedSession,
3587
4957
  defaultProviderPriorityFromNodeFacts,
4958
+ defaultStagePlan,
4959
+ deriveItemDedupeKey,
3588
4960
  deriveProviderPriorityFromSlots,
3589
4961
  deriveSlotsFromLegacy,
3590
4962
  describeModelSelection,
@@ -3595,13 +4967,21 @@ export {
3595
4967
  expandDaemonIdForms,
3596
4968
  findOwnershipConflicts,
3597
4969
  foldKeyedDoc,
4970
+ followedRemoteProjectKey,
4971
+ followerOpPermitted,
3598
4972
  formatQuotaAccount,
4973
+ formatStageVerdictLine,
3599
4974
  hasGitStatusEvidence,
3600
4975
  hasWorkerProtocolFooter,
3601
4976
  interpolateString,
4977
+ isActionableProviderApproval,
4978
+ isAssistantFollowerAllowedOp,
3602
4979
  isAssistantTool,
3603
4980
  isBlockedStatus,
4981
+ isBlockingSeverity,
3604
4982
  isBusyStatus,
4983
+ isCarryOverMissionRecord,
4984
+ isCarryOverMissionTitle,
3605
4985
  isChunkType,
3606
4986
  isCommitStrength,
3607
4987
  isDaemonDirectCommandType,
@@ -3617,14 +4997,21 @@ export {
3617
4997
  isDeadStatus,
3618
4998
  isDowngrade,
3619
4999
  isEvidenceIdentifier,
5000
+ isFindingCategory,
5001
+ isFindingResponseKind,
5002
+ isFindingSeverity,
3620
5003
  isFiniteNumber,
3621
5004
  isIdleSessionState,
3622
5005
  isInputEnvelopeWire,
5006
+ isLaunchDefaultRole,
5007
+ isLaunchDefaultSource,
5008
+ isLightWorkerSession,
3623
5009
  isMeshDeliveryMode,
3624
5010
  isMeshIndexQueryResponse,
3625
5011
  isMeshMissionStatusValue,
3626
5012
  isMeshP2PSignalType,
3627
5013
  isMeshRecordPayload,
5014
+ isMeshReleaseChannel,
3628
5015
  isMeshTaskDifficulty,
3629
5016
  isMeshTaskMode,
3630
5017
  isMeshTaskPriority,
@@ -3632,17 +5019,24 @@ export {
3632
5019
  isMeshTerminalTaskStatus,
3633
5020
  isMeshTopicEntry,
3634
5021
  isMessageId,
5022
+ isMissionOutcome,
5023
+ isMissionRefContained,
3635
5024
  isMissionUpsertResponse,
3636
5025
  isModelAxisSource,
5026
+ isNativeMarkerRef,
3637
5027
  isNonEmptyString,
3638
5028
  isNotifyKind,
3639
5029
  isOutboundMessage,
3640
5030
  isOutboundMessageOrigin,
3641
5031
  isP2PSignalType,
3642
5032
  isPhantomDaemonEntry,
5033
+ isPriorFindingStatus,
5034
+ isProviderQuestionBinding,
3643
5035
  isRawDaemonDoId,
3644
5036
  isReadyStatus,
3645
5037
  isRecord,
5038
+ isReleaseStatus,
5039
+ isReviewVerdict,
3646
5040
  isSendPolicy,
3647
5041
  isSendPolicyMode,
3648
5042
  isSendRefusal,
@@ -3651,6 +5045,8 @@ export {
3651
5045
  isSessionLaunchedBy,
3652
5046
  isSessionStatus,
3653
5047
  isSharedSessionToViewerType,
5048
+ isStageBlockedReason,
5049
+ isStageEligibleTask,
3654
5050
  isSubmitOutcome,
3655
5051
  isSummaryRef,
3656
5052
  isTerminalSessionRecordStatus,
@@ -3669,6 +5065,7 @@ export {
3669
5065
  isWorkingStatus,
3670
5066
  joinRepoPath,
3671
5067
  launchModelSelectionValue,
5068
+ lintChangelogText,
3672
5069
  machineCoreFromDaemonId,
3673
5070
  makeTypeGuard,
3674
5071
  measureWorstCaseChunkEnvelopeBytes,
@@ -3677,43 +5074,61 @@ export {
3677
5074
  meshUtf8ByteLength,
3678
5075
  meshWorkspacesEquivalent,
3679
5076
  mintMessageId,
5077
+ minutesUntilQuotaCheck,
3680
5078
  normalizeAuthOkLimits,
3681
5079
  normalizeBrainSlot,
5080
+ normalizeDecisionInput,
3682
5081
  normalizeDifficultyBrainMap,
5082
+ normalizeForDedupe,
3683
5083
  normalizeGitStatus,
3684
5084
  normalizeMeshNodeFacts,
3685
5085
  normalizeMeshNodeId,
3686
5086
  normalizeMeshSessionRecord,
3687
5087
  normalizeMeshWorkspaceForCompare,
3688
5088
  normalizeMissionBrief,
5089
+ normalizeMissionItemInput,
5090
+ normalizeMissionItemUpdate,
5091
+ normalizeMissionRefs,
5092
+ normalizeMissionSummary,
3689
5093
  normalizeNodeCapabilitySlot,
3690
5094
  normalizeNodeCapabilitySlots,
5095
+ normalizeOutcomeReason,
3691
5096
  normalizeOwnedPaths,
5097
+ normalizeReportCommits,
3692
5098
  normalizeSessionStatus,
3693
5099
  normalizeThinkingLevel,
3694
5100
  orderProvidersByBuiltinPreference,
3695
5101
  parseJsonRecord,
5102
+ parseRoleLaunchSelection,
3696
5103
  parseSemver,
3697
5104
  parseSessionLaunchRecord,
3698
5105
  pathsOverlap,
3699
5106
  pickBestTransitGitStatus,
3700
5107
  projectFileDiffRow,
3701
5108
  projectTurnEvidenceEntry,
5109
+ providerApprovalSnapshot,
3702
5110
  readBoolean,
3703
5111
  readEnvelopeFields,
3704
5112
  readGitSubmodules,
3705
5113
  readNumber,
3706
5114
  readOptionalRecord,
5115
+ readProviderDecision,
3707
5116
  readRecord,
3708
5117
  readString,
3709
5118
  readStringArray,
3710
5119
  readText,
3711
5120
  renderCoordinatorWorkerSection,
5121
+ renderLightWorkspaceRules,
3712
5122
  renderMissionBriefBlock,
5123
+ renderStageProtocolLines,
3713
5124
  renderWorkerProtocolFooter,
5125
+ resolveStagePlan,
3714
5126
  retiredMeshToolError,
5127
+ reviewIndependenceOf,
5128
+ sanitizeDispatchRefusalDetail,
3715
5129
  sanitizeModelIdentifier,
3716
5130
  sanitizeRefusalCode,
5131
+ sanitizeRemoteRepoIdentity,
3717
5132
  scoreGitStatusCandidate,
3718
5133
  scoreGitUpstreamFreshness,
3719
5134
  sessionIdsEquivalent,
@@ -3724,6 +5139,11 @@ export {
3724
5139
  summarizeGitShape,
3725
5140
  supportsQuota,
3726
5141
  touchedFilesOutsideOwnership,
5142
+ truncateMissionText,
5143
+ unwrapPastedContent,
5144
+ validateFindingResponses,
5145
+ validateReviewReport,
5146
+ validateTestsRun,
3727
5147
  withStatusProbeMarker
3728
5148
  };
3729
5149
  //# sourceMappingURL=index.mjs.map