@adhdev/mesh-shared 1.0.82-rc.9 → 1.0.82-rc.91

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 +12 -0
  4. package/dist/index.js +1641 -124
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1502 -124
  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 +61 -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 +4 -4
  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 +13 -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 +56 -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 +29 -13
  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 +92 -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",
@@ -307,7 +307,7 @@ function hasUsableWindow(window) {
307
307
  return !!window && typeof window.usedPercent === "number" && Number.isFinite(window.usedPercent);
308
308
  }
309
309
  function hasReading(quota) {
310
- if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly)) return true;
310
+ if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly) || hasUsableWindow(quota.monthly)) return true;
311
311
  return Array.isArray(quota.buckets) && quota.buckets.some((b) => !!b && typeof b.usedPercent === "number" && Number.isFinite(b.usedPercent));
312
312
  }
313
313
  function finiteMs(value) {
@@ -325,9 +325,17 @@ function backfillCheckAt(quota, now) {
325
325
  function assessQuotaFreshness(quota, now = Date.now()) {
326
326
  const meta = quota.metadata;
327
327
  const kind = meta?.failureKind;
328
- const userMustAct = kind === "no-data" && quota.provider !== "codex-cli" || kind === "expired-token" && quota.provider === "antigravity-cli";
329
- if (userMustAct && hasReading(quota)) return { cue: "stale", userMustAct: true };
330
- if (meta?.lastGoodWindows !== true) return { userMustAct };
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
+ }
331
339
  const retryAtMs = finiteMs(meta?.retryAtMs);
332
340
  const retryStopped = meta?.retryExhausted === true || retryAtMs !== void 0 && retryAtMs + QUOTA_RETRY_INFLIGHT_GRACE_MS < now;
333
341
  if (kind !== "no-data" && !retryStopped) return { cue: "refreshing", userMustAct: false };
@@ -367,19 +375,21 @@ function isPhantomDaemonEntry(entry) {
367
375
  function machineCoreFromDaemonId(id2) {
368
376
  const trimmed = readString(id2);
369
377
  if (!trimmed) return void 0;
378
+ const lower = trimmed.toLowerCase();
370
379
  for (const prefix of DAEMON_ID_PREFIXES) {
371
- if (trimmed.startsWith(prefix)) {
380
+ if (lower.startsWith(prefix)) {
372
381
  const core = trimmed.slice(prefix.length).trim();
373
- return core || void 0;
382
+ if (!core) return void 0;
383
+ return /^mach_/i.test(core) ? `mach_${core.slice(5)}` : core;
374
384
  }
375
385
  }
376
- return trimmed;
386
+ return /^mach_/i.test(trimmed) ? `mach_${trimmed.slice(5)}` : trimmed;
377
387
  }
378
388
  function canonicalDaemonId(id2) {
379
389
  const core = machineCoreFromDaemonId(id2);
380
390
  if (!core) return void 0;
381
- if (!core.startsWith("mach_")) return core;
382
- return `daemon_${core}`;
391
+ if (!/^mach_/i.test(core)) return core;
392
+ return `daemon_mach_${core.slice(5)}`;
383
393
  }
384
394
  function daemonIdsEquivalent(a, b) {
385
395
  const coreA = machineCoreFromDaemonId(a);
@@ -408,9 +418,9 @@ function expandDaemonIdForms(ids) {
408
418
 
409
419
  // src/git-summarize.ts
410
420
  function summarizeGitShape(status) {
411
- const record = readRecord(status);
412
- if (!Object.keys(record).length) return null;
413
- 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) => {
414
424
  const sub = readRecord(entry);
415
425
  return {
416
426
  path: readString(sub.path) ?? null,
@@ -420,23 +430,23 @@ function summarizeGitShape(status) {
420
430
  };
421
431
  }) : [];
422
432
  return {
423
- isGitRepo: readBoolean(record.isGitRepo),
424
- workspace: readString(record.workspace) ?? null,
425
- repoRoot: readString(record.repoRoot, record.repo_root) ?? null,
426
- branch: readString(record.branch) ?? null,
427
- upstream: readString(record.upstream) ?? null,
428
- upstreamStatus: readString(record.upstreamStatus, record.upstream_status) ?? null,
429
- headCommit: readString(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
430
- ahead: readNumber(record.ahead) ?? null,
431
- 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,
432
442
  dirtyCounts: {
433
- staged: readNumber(record.staged) ?? 0,
434
- modified: readNumber(record.modified) ?? 0,
435
- untracked: readNumber(record.untracked) ?? 0,
436
- deleted: readNumber(record.deleted) ?? 0,
437
- 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
438
448
  },
439
- lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
449
+ lastCheckedAt: readNumber(record2.lastCheckedAt, record2.last_checked_at) ?? null,
440
450
  submoduleCount: submodules.length,
441
451
  submodules
442
452
  };
@@ -602,10 +612,25 @@ var CLI_SLOT_RECIPES = Object.freeze({
602
612
  ],
603
613
  "antigravity-cli": [
604
614
  {
605
- 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)"],
606
617
  difficulty: ["easy"],
607
618
  maxParallel: 2,
608
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."
609
634
  }
610
635
  ],
611
636
  "cursor-cli": [
@@ -644,6 +669,24 @@ function dedupeDetected(detected) {
644
669
  }
645
670
  return out;
646
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
+ }
647
690
  function buildSlotProposal(detected, currentSlots = []) {
648
691
  const providers = dedupeDetected(detected ?? []);
649
692
  const proposedSlots = [];
@@ -659,7 +702,7 @@ function buildSlotProposal(detected, currentSlots = []) {
659
702
  for (const recipe of recipes) {
660
703
  const slot = normalizeNodeCapabilitySlot({
661
704
  provider: provider.type,
662
- model: recipe.model,
705
+ model: resolveRecipeModel(recipe, provider.modelOptions),
663
706
  thinkingLevel: recipe.thinkingLevel,
664
707
  difficulty: recipe.difficulty,
665
708
  maxParallel: recipe.maxParallel
@@ -712,7 +755,12 @@ var CANONICAL_MESH_TOOL_NAMES = [
712
755
  "mesh_enqueue_task",
713
756
  "mesh_view_queue",
714
757
  "mesh_queue_cancel",
758
+ "mesh_task_stage_decide",
759
+ "mesh_direct_cancel",
715
760
  "mesh_queue_requeue",
761
+ "mesh_queue_revise",
762
+ "mesh_light_land",
763
+ "mesh_light_discard",
716
764
  "mesh_send_task",
717
765
  "mesh_read_chat",
718
766
  "mesh_read_debug",
@@ -729,8 +777,13 @@ var CANONICAL_MESH_TOOL_NAMES = [
729
777
  "mesh_list_pending_approvals",
730
778
  "mesh_create",
731
779
  "mesh_add_node",
780
+ "mesh_reattach_source_parent",
781
+ "mesh_attach_remote",
782
+ "mesh_host_pairing",
732
783
  "mesh_clone_node",
733
784
  "mesh_remove_node",
785
+ "mesh_retry_node_bootstrap",
786
+ "mesh_recover_node_identity",
734
787
  "mesh_cleanup_worktree_nodes",
735
788
  "mesh_refine_node",
736
789
  "mesh_refine_batch",
@@ -747,8 +800,20 @@ var CANONICAL_MESH_TOOL_NAMES = [
747
800
  "mesh_reconcile_ledger",
748
801
  "mesh_mission_upsert",
749
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",
750
810
  "mesh_review_inbox",
751
- "mesh_node_slots"
811
+ "mesh_node_slots",
812
+ "driver_list",
813
+ "driver_describe",
814
+ "artifact_list",
815
+ "artifact_read",
816
+ "artifact_register"
752
817
  ];
753
818
  var CANONICAL_MESH_TOOL_COUNT = CANONICAL_MESH_TOOL_NAMES.length;
754
819
  var RETIRED_MESH_TOOLS = {
@@ -1058,9 +1123,15 @@ var DAEMON_STATUS_EVENT_NAMES = [
1058
1123
  "agent:waiting_choice",
1059
1124
  "agent:generating_completed",
1060
1125
  "agent:stopped",
1061
- "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"
1062
1130
  ];
1063
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;
1064
1135
  var RELEASE_CHANNELS = ["stable", "preview"];
1065
1136
  var NPM_UPDATE_TAGS = ["latest", "next"];
1066
1137
  var VERSION_UPDATE_REASONS = ["force_update_below", "major_minor_mismatch", "patch_mismatch", "daemon_ahead"];
@@ -1423,21 +1494,22 @@ function isTerminalSessionRecordStatus(raw) {
1423
1494
  return typeof raw === "string" && TERMINAL_SESSION_RECORD_STATUSES.includes(raw.trim().toLowerCase());
1424
1495
  }
1425
1496
  function isIdleSessionState(state) {
1426
- const record = state && typeof state === "object" ? state : {};
1427
- 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() : "";
1428
1499
  if (isTerminalSessionRecordStatus(status) || isDeadStatus(status)) return false;
1429
- return isReadyStatus(status) || record.activeChat?.status === "waiting_input";
1500
+ return isReadyStatus(status) || record2.activeChat?.status === "waiting_input";
1430
1501
  }
1431
1502
 
1432
1503
  // src/mesh-vocabulary.ts
1433
- var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
1434
- 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"];
1435
1506
  var MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
1436
1507
  var MESH_TASK_PRIORITIES = ["low", "normal", "high"];
1437
1508
  var MESH_THINKING_LEVELS = ["low", "medium", "high"];
1438
1509
  var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
1439
1510
  var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
1440
1511
  var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
1512
+ var WORKER_REPORT_SUMMARY_MAX_CHARS = 8e3;
1441
1513
  var WORKER_BRANCH_STATES = [
1442
1514
  "merged_to_main",
1443
1515
  "pushed_feature_branch_needs_merge",
@@ -1504,6 +1576,7 @@ var SEND_REFUSAL_REASONS = [
1504
1576
  "no_target",
1505
1577
  "bootstrap_pending",
1506
1578
  "duplicate_dispatch",
1579
+ "new_work_held",
1507
1580
  "internal_error"
1508
1581
  ];
1509
1582
  function isSendRefusal(value) {
@@ -1535,6 +1608,14 @@ function isOutboundMessage(value) {
1535
1608
  const candidate = value;
1536
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";
1537
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
+ }
1538
1619
 
1539
1620
  // src/mission-brief.ts
1540
1621
  var GOAL_MAX = 500;
@@ -1620,13 +1701,39 @@ var WORKER_TOOLS = [
1620
1701
  "peer_context_pull",
1621
1702
  "git_status",
1622
1703
  "git_log",
1623
- "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"
1624
1720
  ];
1625
1721
  var WORKER_TOOL_SET = new Set(WORKER_TOOLS);
1626
1722
  function isWorkerTool(value) {
1627
1723
  return typeof value === "string" && WORKER_TOOL_SET.has(value);
1628
1724
  }
1629
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.";
1630
1737
  function hasWorkerProtocolFooter(body) {
1631
1738
  return typeof body === "string" && body.includes(WORKER_PROTOCOL_FOOTER_MARKER);
1632
1739
  }
@@ -1648,6 +1755,9 @@ function renderWorkerProtocolFooter(input = {}) {
1648
1755
  if (input.readonly) scope.push("read-only");
1649
1756
  if (scope.length) lines.push(`You are a delegated worker (${scope.join(", ")}).`);
1650
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);
1651
1761
  if (input.workerMcp === false) {
1652
1762
  lines.push(
1653
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.",
@@ -1667,15 +1777,30 @@ function renderWorkerProtocolFooter(input = {}) {
1667
1777
  "Memos from the coordinator arrive appended to the response of whichever worker tool you call next; read them and follow them.",
1668
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`.",
1669
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 `[]`.",
1670
- "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."
1671
1783
  );
1672
1784
  if (input.enclosedHandoffNotes && input.enclosedHandoffNotes > 0) {
1673
1785
  lines.push(
1674
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.`
1675
1787
  );
1676
1788
  }
1789
+ if (input.stage) lines.push(...renderStageProtocolLines(input.stage));
1677
1790
  return lines.join("\n");
1678
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."),
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. 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
+ }
1679
1804
  function stripWorkerProtocolFooter(body) {
1680
1805
  if (typeof body !== "string") return body;
1681
1806
  const at = body.indexOf(WORKER_PROTOCOL_FOOTER_MARKER);
@@ -1705,15 +1830,30 @@ function renderCoordinatorWorkerSection() {
1705
1830
  // src/assistant-protocol.ts
1706
1831
  var ASSISTANT_TOOLS = [
1707
1832
  "projects",
1833
+ "environment",
1834
+ "assistant_action",
1835
+ "project_watch",
1708
1836
  "project_status",
1709
1837
  "project_send",
1710
1838
  "project_read",
1711
1839
  "project_add",
1840
+ "project_attach_remote",
1712
1841
  "discover_repos",
1713
1842
  "memory",
1843
+ "memory_search",
1714
1844
  "skill_view",
1715
1845
  "skill_manage",
1716
- "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"
1717
1857
  ];
1718
1858
  var ASSISTANT_TOOL_SET = new Set(ASSISTANT_TOOLS);
1719
1859
  function isAssistantTool(value) {
@@ -1721,50 +1861,170 @@ function isAssistantTool(value) {
1721
1861
  }
1722
1862
  var ASSISTANT_VERB = {
1723
1863
  // tool verbs
1864
+ driverList: "driver_list",
1865
+ driverDescribe: "driver_describe",
1724
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",
1725
1872
  projectStatus: "assistant_project_status",
1726
1873
  projectSend: "assistant_project_send",
1727
1874
  projectRead: "assistant_project_read",
1728
1875
  projectAdd: "assistant_project_add",
1876
+ projectAttachRemote: "assistant_project_attach_remote",
1729
1877
  discoverRepos: "assistant_discover_repos",
1730
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",
1731
1881
  skillView: "assistant_skill_view",
1732
1882
  skillManage: "assistant_skill_manage",
1733
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",
1734
1896
  // assistant-side daemon verbs without a tool of the same name
1735
1897
  launch: "launch_assistant",
1736
1898
  pendingRelays: "assistant_pending_relays",
1737
1899
  // owner verbs (dashboard only)
1738
1900
  stagedResolve: "assistant_staged_resolve",
1739
1901
  storeAdmin: "assistant_store_admin",
1740
- 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"
1741
1912
  };
1742
1913
  var ASSISTANT_TOOL_VERBS = {
1914
+ driver_list: ASSISTANT_VERB.driverList,
1915
+ driver_describe: ASSISTANT_VERB.driverDescribe,
1743
1916
  projects: ASSISTANT_VERB.projects,
1917
+ environment: ASSISTANT_VERB.environment,
1918
+ assistant_action: ASSISTANT_VERB.action,
1919
+ project_watch: ASSISTANT_VERB.watch,
1744
1920
  project_status: ASSISTANT_VERB.projectStatus,
1745
1921
  project_send: ASSISTANT_VERB.projectSend,
1746
1922
  project_read: ASSISTANT_VERB.projectRead,
1747
1923
  project_add: ASSISTANT_VERB.projectAdd,
1924
+ project_attach_remote: ASSISTANT_VERB.projectAttachRemote,
1748
1925
  discover_repos: ASSISTANT_VERB.discoverRepos,
1749
1926
  memory: ASSISTANT_VERB.memory,
1927
+ memory_search: ASSISTANT_VERB.memorySearch,
1750
1928
  skill_view: ASSISTANT_VERB.skillView,
1751
1929
  skill_manage: ASSISTANT_VERB.skillManage,
1752
- 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
1753
1939
  };
1754
- 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"];
1755
1941
  var ASSISTANT_OWNER_VERBS = [
1942
+ ASSISTANT_VERB.executionSettings,
1756
1943
  ASSISTANT_VERB.stagedResolve,
1757
1944
  ASSISTANT_VERB.storeAdmin,
1758
- ASSISTANT_VERB.importSkills
1945
+ ASSISTANT_VERB.importSkills,
1946
+ ASSISTANT_VERB.skillsList,
1947
+ ASSISTANT_VERB.memoryDigest,
1948
+ ASSISTANT_VERB.memoryUndo,
1949
+ ASSISTANT_VERB.threadClose
1759
1950
  ];
1760
1951
  var ASSISTANT_REVIEW_TURN_VERBS = [
1761
1952
  ASSISTANT_VERB.memory,
1953
+ ASSISTANT_VERB.memorySearch,
1762
1954
  ASSISTANT_VERB.skillView,
1763
1955
  ASSISTANT_VERB.skillManage,
1764
1956
  ASSISTANT_VERB.projectNote
1765
1957
  ];
1766
1958
  var ASSISTANT_SESSION_ID_ENV = "ADHDEV_ASSISTANT_SESSION_ID";
1767
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
+ }
1768
2028
 
1769
2029
  // src/turn-evidence.ts
1770
2030
  var MESH_TOPIC_PROTOCOL_VERSION = 2;
@@ -1800,18 +2060,29 @@ var TURN_SCOPES = ["mesh_queue", "mesh_direct", "plain"];
1800
2060
  var RECLAIMING_SEND_REFUSALS = ["session_exited", "no_target", "unsupported_input"];
1801
2061
  var DELIVERY_OUTCOMES = ["delivered", "queued"];
1802
2062
  var DELIVERY_VIAS = ["local", "p2p"];
1803
- 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"];
1804
2064
  function sanitizeRefusalCode(value) {
1805
2065
  if (typeof value !== "string") return void 0;
1806
2066
  const normalized = value.trim().toLowerCase().replace(/[^a-z_]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
1807
2067
  if (!normalized) return void 0;
1808
2068
  return normalized.slice(0, 64);
1809
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
+ }
1810
2081
  var CONSUME_PROFILES = ["default", "native_source"];
1811
2082
  var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
1812
2083
  var SUSPENSION_MODALS = ["approval", "choice"];
1813
- var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
1814
- 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"];
1815
2086
  var TURN_END_STRENGTHS = ["genuine", "weak"];
1816
2087
  var TURN_END_BLOCK_REASONS = [
1817
2088
  "missing_final_assistant",
@@ -1819,9 +2090,9 @@ var TURN_END_BLOCK_REASONS = [
1819
2090
  "terminal_block_hard_cap",
1820
2091
  "decoupled_completion"
1821
2092
  ];
1822
- var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
2093
+ var NATIVE_TURN_OUTCOMES = ["completed", "aborted", "failed"];
1823
2094
  var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
1824
- var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
2095
+ var PROVIDER_FAILURES = ["auth_failed", "billing_failed", "usage_limit_exceeded", "server_overloaded", "provider_error"];
1825
2096
  var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
1826
2097
  var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
1827
2098
  var OPERATOR_STATUSES = ["completed", "failed"];
@@ -1848,9 +2119,10 @@ var HOLD_REASONS = [
1848
2119
  // — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
1849
2120
  // a session whose FSM never shows the idle edge again does not wait for
1850
2121
  // liveness / hard_ceiling.
1851
- "await_end"
2122
+ "await_end",
2123
+ "report_correction"
1852
2124
  ];
1853
- var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
2125
+ var TURN_OUTCOMES = ["completed", "blocked", "failed", "cancelled"];
1854
2126
  var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
1855
2127
  var TURN_REASONS = [
1856
2128
  // commits
@@ -1859,9 +2131,15 @@ var TURN_REASONS = [
1859
2131
  "transcript_final",
1860
2132
  "worker_reported",
1861
2133
  "finalization_timeout_no_response",
2134
+ "weak_end_liveness_unconfirmed",
2135
+ "weak_end_probe_unobserved",
2136
+ "report_correction_expired",
1862
2137
  "session_error",
1863
2138
  "provider_auth_failed",
1864
2139
  "provider_billing_failed",
2140
+ "provider_usage_limit_exceeded",
2141
+ "provider_server_overloaded",
2142
+ "provider_error",
1865
2143
  "operator_cancel",
1866
2144
  "intentional_cleanup",
1867
2145
  "task_removed",
@@ -1874,6 +2152,8 @@ var TURN_REASONS = [
1874
2152
  "reclaim_budget_exhausted",
1875
2153
  "hollow_max_retries",
1876
2154
  "migration_orphan",
2155
+ // a stopping attempt whose writer node stayed unreachable (or was removed) past the bound
2156
+ "writer_unreachable",
1877
2157
  // reclaims (generation + 1)
1878
2158
  "dispatch_refused_session_exited",
1879
2159
  "dispatch_refused_no_target",
@@ -1889,6 +2169,7 @@ var TURN_REASONS = [
1889
2169
  ];
1890
2170
  var NOTIFY_KINDS = [
1891
2171
  "completed",
2172
+ "blocked",
1892
2173
  "failed",
1893
2174
  "cancelled",
1894
2175
  "stopped",
@@ -1938,8 +2219,8 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1938
2219
  duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
1939
2220
  session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
1940
2221
  turn_started: { retro: bool },
1941
- suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
1942
- 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 },
1943
2224
  turn_end: {
1944
2225
  strength: en(TURN_END_STRENGTHS),
1945
2226
  afterFinalizationTimeout: boolOpt,
@@ -1949,6 +2230,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1949
2230
  releasedByHardCap: boolOpt,
1950
2231
  nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
1951
2232
  live: { t: "live", optional: true },
2233
+ nativeMarker: { t: "native_marker", optional: true },
1952
2234
  reportExpected: boolOpt,
1953
2235
  providerFailure: enOpt(PROVIDER_FAILURES)
1954
2236
  },
@@ -1962,7 +2244,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1962
2244
  },
1963
2245
  transcript_activity: { newestActivityAt: ms },
1964
2246
  no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
1965
- liveness: { result: en(LIVENESS_RESULTS) },
2247
+ liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
1966
2248
  process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
1967
2249
  session_error: { reason: en(SESSION_ERROR_REASONS) },
1968
2250
  worker_report: {
@@ -1972,6 +2254,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1972
2254
  branchState: enOpt(WORKER_BRANCH_STATES),
1973
2255
  touchedFileCount: intOpt
1974
2256
  },
2257
+ worker_report_correction_requested: { deliveryId: { t: "id", optional: true } },
1975
2258
  worker_progress: { note: { t: "summary_ref", optional: true } },
1976
2259
  git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
1977
2260
  cancel: { reason: en(CANCEL_REASONS) },
@@ -2019,7 +2302,7 @@ function isLiveTurnPending(value) {
2019
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));
2020
2303
  }
2021
2304
  function isNativeMarkerRef(value) {
2022
- 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]));
2023
2306
  }
2024
2307
  function isCoordinatorIdentity(value) {
2025
2308
  return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
@@ -2142,17 +2425,89 @@ function projectTurnEvidenceEntry(evidence, attempt) {
2142
2425
  };
2143
2426
  }
2144
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
+
2145
2497
  // src/session-launch.ts
2146
2498
  var MODEL_AXIS_SOURCES = [
2147
2499
  /** Picked explicitly for this launch (dashboard dropdown, coordinator dialog). */
2148
2500
  "user",
2149
2501
  /** The dashboard dialog restored it from the last launch (browser-local memory). */
2150
2502
  "remembered",
2503
+ /** The authoritative daemon role default or host project override. */
2504
+ "stored_default",
2505
+ "project_default",
2151
2506
  /** A mesh capability slot supplied it (or a difficulty preset the slot outranked). */
2152
2507
  "mesh_slot",
2153
2508
  /** An explicit per-task model / thinking level on a mesh queue task. */
2154
2509
  "task_override",
2155
- /** Nothing was requested; the provider's default is known (discovery / manifest). */
2510
+ /** Nothing requested: the provider chooses; resolvedDefault records it when known. */
2156
2511
  "provider_default",
2157
2512
  /** A value was requested without saying where it came from, or nothing is known. */
2158
2513
  "unspecified"
@@ -2196,10 +2551,10 @@ function readFiniteNumber(value) {
2196
2551
  }
2197
2552
  function parseModelSelection(raw) {
2198
2553
  if (!raw || typeof raw !== "object") return void 0;
2199
- const record = raw;
2554
+ const record2 = raw;
2200
2555
  const history = [];
2201
- if (Array.isArray(record.history)) {
2202
- for (const entry of record.history) {
2556
+ if (Array.isArray(record2.history)) {
2557
+ for (const entry of record2.history) {
2203
2558
  if (!entry || typeof entry !== "object") continue;
2204
2559
  const e = entry;
2205
2560
  const value = readString(e.value);
@@ -2208,41 +2563,45 @@ function parseModelSelection(raw) {
2208
2563
  if (value && at !== void 0 && via) history.push({ at, value, via });
2209
2564
  }
2210
2565
  }
2211
- const requested = readString(record.requested);
2212
- const launchValue = readString(record.launchValue);
2213
- const resolvedDefault = readString(record.resolvedDefault);
2214
- const current = readString(record.current);
2215
- const observed = readString(record.observed);
2216
- 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;
2217
2573
  return {
2218
- source: isModelAxisSource(record.source) ? record.source : "unspecified",
2574
+ source: isModelAxisSource(record2.source) ? record2.source : "unspecified",
2219
2575
  ...requested ? { requested } : {},
2220
2576
  ...launchValue ? { launchValue } : {},
2221
2577
  ...resolvedDefault ? { resolvedDefault } : {},
2222
2578
  ...current ? { current } : {},
2223
2579
  ...observed ? { observed } : {},
2224
2580
  ...observedAt !== void 0 ? { observedAt } : {},
2581
+ ...fallback ? { fallback } : {},
2225
2582
  history: history.slice(-MODEL_SELECTION_HISTORY_LIMIT)
2226
2583
  };
2227
2584
  }
2228
2585
  function parseSessionLaunchRecord(raw) {
2229
2586
  if (!raw || typeof raw !== "object") return void 0;
2230
- const record = raw;
2231
- const sessionId = readString(record.sessionId);
2232
- const providerType = readString(record.providerType);
2233
- const launchedAt = readFiniteNumber(record.launchedAt);
2234
- const model = parseModelSelection(record.model);
2235
- 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);
2236
2593
  if (!sessionId || !providerType || launchedAt === void 0 || !model || !thinkingLevel) return void 0;
2237
- const providerVersion = readString(record.providerVersion);
2238
- const workspace = readString(record.workspace);
2239
- 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);
2240
2598
  return {
2599
+ ...roleLaunch ? { roleLaunch } : {},
2241
2600
  sessionId,
2242
2601
  providerType,
2243
2602
  ...providerVersion ? { providerVersion } : {},
2244
- ...record.providerChannel === "stable" || record.providerChannel === "preview" ? { providerChannel: record.providerChannel } : {},
2245
- 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",
2246
2605
  launchedAt,
2247
2606
  ...workspace ? { workspace } : {},
2248
2607
  model,
@@ -2306,7 +2665,7 @@ function isTurnAttemptRefValue(value) {
2306
2665
  function isTurnObserveResponse(value) {
2307
2666
  return isRecord(value) && hasOnlyKeys2(value, ["verdict", "attemptRef", "outcome"]) && isTurnObserveVerdict(value.verdict) && isTurnAttemptRefValue(value.attemptRef) && (value.outcome === void 0 || isTurnOutcomeValue(value.outcome));
2308
2667
  }
2309
- var TURN_OUTCOMES_LOCAL = ["completed", "failed", "cancelled"];
2668
+ var TURN_OUTCOMES_LOCAL = ["completed", "blocked", "failed", "cancelled"];
2310
2669
  function isTurnOutcomeValue(value) {
2311
2670
  return typeof value === "string" && TURN_OUTCOMES_LOCAL.includes(value);
2312
2671
  }
@@ -2532,8 +2891,23 @@ function isMissionBriefWire(value) {
2532
2891
  }
2533
2892
  return true;
2534
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
+ }
2535
2908
  function isMeshMissionRecordWire(value) {
2536
- 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;
2537
2911
  if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
2538
2912
  if (typeof value.title !== "string" || typeof value.goal !== "string") return false;
2539
2913
  if (!isMeshMissionStatusValue(value.status)) return false;
@@ -2541,11 +2915,22 @@ function isMeshMissionRecordWire(value) {
2541
2915
  return true;
2542
2916
  }
2543
2917
  function isMissionUpsertRequest(value) {
2544
- 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;
2545
2919
  if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2546
2920
  if (!isEvidenceIdentifier(value.meshId)) return false;
2547
2921
  if (value.id !== void 0 && !isEvidenceIdentifier(value.id)) return false;
2548
- 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
+ }
2549
2934
  if (value.goal !== void 0 && typeof value.goal !== "string") return false;
2550
2935
  if (value.status !== void 0 && !isMeshMissionStatusValue(value.status)) return false;
2551
2936
  if (value.brief !== void 0 && value.brief !== null && !isMissionBriefWire(value.brief)) return false;
@@ -2555,7 +2940,7 @@ function decodeMissionUpsertRequest(value) {
2555
2940
  return isMissionUpsertRequest(value) ? value : null;
2556
2941
  }
2557
2942
  function isMissionUpsertResponse(value) {
2558
- 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));
2559
2944
  }
2560
2945
  function decodeMissionUpsertResponse(value) {
2561
2946
  return isMissionUpsertResponse(value) ? value : null;
@@ -2581,7 +2966,10 @@ function decodeMissionQueryResponse(value) {
2581
2966
  return isMissionQueryResponse(value) ? value : null;
2582
2967
  }
2583
2968
  function isMissionListQueryRequest(value) {
2584
- 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
+ }
2585
2973
  if (value.meshStatusView !== void 0 && value.meshStatusView !== "compact" && value.meshStatusView !== "verbose") return false;
2586
2974
  if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2587
2975
  if (!isEvidenceIdentifier(value.meshId)) return false;
@@ -2607,12 +2995,13 @@ function isMeshMissionTaskAggregateWire(value) {
2607
2995
  return value.lastActivityAt === null || typeof value.lastActivityAt === "string";
2608
2996
  }
2609
2997
  function isMeshMissionStatsWire(value) {
2610
- const keys = ["missionId", "taskCount", "completed", "failed", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2998
+ const keys = ["missionId", "taskCount", "completed", "failed", "blocked", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2611
2999
  if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2612
3000
  if (!isEvidenceIdentifier(value.missionId)) return false;
2613
3001
  for (const k of ["taskCount", "completed", "failed", "totalDurationMs", "retries"]) {
2614
3002
  if (!isNonNegativeInt(value[k])) return false;
2615
3003
  }
3004
+ if (value.blocked !== void 0 && !isNonNegativeInt(value.blocked)) return false;
2616
3005
  if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false;
2617
3006
  if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false;
2618
3007
  return true;
@@ -2622,7 +3011,7 @@ function isMissionListSummaryWire(value) {
2622
3011
  const hasGoal = "goal" in value;
2623
3012
  const hasPreview = "goalPreview" in value && "goalTruncated" in value;
2624
3013
  if (hasGoal === hasPreview) return false;
2625
- 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"];
2626
3015
  const allowed = hasGoal ? [...baseKeys, "goal"] : [...baseKeys, "goalPreview", "goalTruncated"];
2627
3016
  if (!hasOnlyKeys2(value, allowed)) return false;
2628
3017
  if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
@@ -2636,6 +3025,10 @@ function isMissionListSummaryWire(value) {
2636
3025
  if (value.createdAt !== void 0 && typeof value.createdAt !== "string") return false;
2637
3026
  if (value.updatedAt !== void 0 && typeof value.updatedAt !== "string") return false;
2638
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
+ }
2639
3032
  return true;
2640
3033
  }
2641
3034
  function isMeshMissionHistoryFoldWire(value) {
@@ -2734,12 +3127,15 @@ function isLedgerQueryEntryWire(value) {
2734
3127
  return true;
2735
3128
  }
2736
3129
  function isLedgerQuerySummaryWire(value) {
2737
- 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"];
2738
3131
  if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2739
3132
  if (!isEvidenceIdentifier(value.meshId)) return false;
2740
3133
  for (const k of ["totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "recentFailures"]) {
2741
3134
  if (!isNonNegativeInt(value[k])) return false;
2742
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;
2743
3139
  if (value.lastActivityAt !== null && typeof value.lastActivityAt !== "string") return false;
2744
3140
  return true;
2745
3141
  }
@@ -2783,9 +3179,10 @@ function isQueueDependencyHeadWire(value) {
2783
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");
2784
3180
  }
2785
3181
  function isQueueQueryResponse(value) {
2786
- if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "counts", "oldHistoricalCount", "dependencyHeads"])) return false;
3182
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "counts", "oldHistoricalCount", "legacyReportedBlockedCount", "dependencyHeads"])) return false;
2787
3183
  if (!Array.isArray(value.entries) || !value.entries.every(isQueueEntryWire)) return false;
2788
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;
2789
3186
  if (value.oldHistoricalCount !== void 0 && !isNonNegativeInt(value.oldHistoricalCount)) return false;
2790
3187
  if (value.dependencyHeads !== void 0 && (!Array.isArray(value.dependencyHeads) || !value.dependencyHeads.every(isQueueDependencyHeadWire))) return false;
2791
3188
  return true;
@@ -2843,7 +3240,7 @@ function decodeQueueRequeueRequest(value) {
2843
3240
  return isQueueRequeueRequest(value) ? value : null;
2844
3241
  }
2845
3242
  function isQueueRequeueResponse(value) {
2846
- 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");
2847
3244
  }
2848
3245
  function decodeQueueRequeueResponse(value) {
2849
3246
  return isQueueRequeueResponse(value) ? value : null;
@@ -2907,6 +3304,24 @@ function isRecoveryContextQueryResponse(value) {
2907
3304
  function decodeRecoveryContextQueryResponse(value) {
2908
3305
  return isRecoveryContextQueryResponse(value) ? value : null;
2909
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;
2910
3325
 
2911
3326
  // src/turn-ipc-stats.ts
2912
3327
  function isTaskStatsQueryRequest(value) {
@@ -3005,6 +3420,7 @@ var TURN_IPC_COMMANDS = [
3005
3420
  "queue_enqueue_batch",
3006
3421
  "queue_cancel",
3007
3422
  "queue_requeue",
3423
+ "queue_revise",
3008
3424
  "direct_dispatch_record",
3009
3425
  "active_work_query",
3010
3426
  "recovery_context_query",
@@ -3088,14 +3504,11 @@ function normalizeOwnedPaths(input) {
3088
3504
  }
3089
3505
  function entryContains(base, path) {
3090
3506
  if (path === base.path) return true;
3091
- if (base.subtree && (path === base.path || path.startsWith(`${base.path}/`))) return true;
3507
+ if (base.subtree && (base.path === "" || path.startsWith(`${base.path}/`))) return true;
3092
3508
  return false;
3093
3509
  }
3094
3510
  function entriesOverlap(a, b) {
3095
- if (a.path === b.path) return true;
3096
- if (a.subtree && (b.path === a.path || b.path.startsWith(`${a.path}/`))) return true;
3097
- if (b.subtree && (a.path === b.path || a.path.startsWith(`${b.path}/`))) return true;
3098
- return false;
3511
+ return entryContains(a, b.path) || entryContains(b, a.path);
3099
3512
  }
3100
3513
  function pathsOverlap(a, b) {
3101
3514
  if (a.paths.length === 0 || b.paths.length === 0) return false;
@@ -3147,6 +3560,357 @@ function touchedFilesOutsideOwnership(touched, owned) {
3147
3560
  return { undeclaredTouched, unusedDeclarations };
3148
3561
  }
3149
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
+
3150
3914
  // src/keyed-doc-delta.ts
3151
3915
  function sig(value) {
3152
3916
  if (value === void 0) return void 0;
@@ -3367,7 +4131,15 @@ function foldKeyedDoc(held, delta, spec) {
3367
4131
  const heldList = heldCollections.get(path);
3368
4132
  if (change?.absent) {
3369
4133
  const [head2, tail2] = splitPath(path);
3370
- 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;
3371
4143
  continue;
3372
4144
  }
3373
4145
  if (!change && heldList === void 0) continue;
@@ -3431,8 +4203,481 @@ function stableMeshNodeRow(row) {
3431
4203
  }
3432
4204
  return out;
3433
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
+ }
3434
4673
  export {
4674
+ ASSISTANT_ACCOUNT_SLOT,
4675
+ ASSISTANT_FOLLOWER_ALLOWED_OPS,
3435
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,
3436
4681
  ASSISTANT_REVIEW_TURN_VERBS,
3437
4682
  ASSISTANT_SESSION_ID_ARG,
3438
4683
  ASSISTANT_SESSION_ID_ENV,
@@ -3444,12 +4689,16 @@ export {
3444
4689
  CANCEL_REASONS,
3445
4690
  CANONICAL_MESH_TOOL_COUNT,
3446
4691
  CANONICAL_MESH_TOOL_NAMES,
4692
+ CARRY_OVER_MISSION_GOAL,
4693
+ CARRY_OVER_MISSION_TITLE,
4694
+ CHANGELOG_SECTIONS,
3447
4695
  CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX,
3448
4696
  CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX,
3449
4697
  CLI_SLOT_RECIPES,
3450
4698
  COMMIT_STRENGTHS,
3451
4699
  CONSUME_PROFILES,
3452
4700
  COORDINATOR_ACK_OUTCOMES,
4701
+ COORDINATOR_SETTABLE_ITEM_STATES,
3453
4702
  DAEMON_METADATA_DOC_SPEC,
3454
4703
  DAEMON_P2P_SIGNAL_TYPES,
3455
4704
  DAEMON_STATUS_EVENT_NAMES,
@@ -3462,13 +4711,34 @@ export {
3462
4711
  DASHBOARD_TO_DAEMON_P2P_TYPES,
3463
4712
  DASHBOARD_TO_USER_SESSION_TYPES,
3464
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,
3465
4719
  DEFAULT_DIFFICULTY_BRAINS,
3466
4720
  DELIVERY_OUTCOMES,
3467
4721
  DELIVERY_VIAS,
3468
4722
  DISPATCH_FAILURE_REASONS,
4723
+ DISPATCH_REFUSAL_DETAIL_MAX,
3469
4724
  EVIDENCE_ENVELOPE_FIELD_SPECS,
3470
4725
  EVIDENCE_SOURCE_IDS,
4726
+ FINDING_CATEGORIES,
4727
+ FINDING_RESPONSES_MAX,
4728
+ FINDING_RESPONSE_KINDS,
4729
+ FINDING_SEVERITIES,
3471
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,
3472
4742
  LIVENESS_RESULTS,
3473
4743
  MAX_MESH_RECORD_STRING,
3474
4744
  MAX_OWNED_PATHS,
@@ -3483,6 +4753,8 @@ export {
3483
4753
  MESH_MISSION_STATUSES,
3484
4754
  MESH_P2P_SIGNAL_TYPES,
3485
4755
  MESH_RECORD_PAYLOAD_KEYS,
4756
+ MESH_RELEASE_CHANNELS,
4757
+ MESH_RELEASE_STATUSES,
3486
4758
  MESH_SESSION_CLEANUP_MODES,
3487
4759
  MESH_STATUS_DOC_SPEC,
3488
4760
  MESH_TASK_DIFFICULTIES,
@@ -3494,10 +4766,23 @@ export {
3494
4766
  MESH_TOPIC_ENTRY_KINDS,
3495
4767
  MESH_TOPIC_PROTOCOL_VERSION,
3496
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,
3497
4781
  MODEL_AXIS_SOURCES,
3498
4782
  MODEL_SELECTION_HISTORY_LIMIT,
3499
4783
  MeshChunkAssembler,
3500
4784
  NATIVE_TURN_OUTCOMES,
4785
+ NEEDS_WORDING_MARKER,
3501
4786
  NOTIFY_KINDS,
3502
4787
  NO_PROGRESS_OBSERVED_STATUSES,
3503
4788
  NPM_UPDATE_TAGS,
@@ -3507,16 +4792,37 @@ export {
3507
4792
  OPERATOR_STATUS_REASON_VALUES,
3508
4793
  OPERATOR_STATUS_VALUES,
3509
4794
  OUTBOUND_MESSAGE_ORIGINS,
4795
+ OWNER_ABANDON_CONFIRM_KEY_PREFIX,
4796
+ OWNER_ABANDON_CONFIRM_OPTIONS,
4797
+ OWNER_ABANDON_CONFIRM_QUESTION,
3510
4798
  P2P_SIGNAL_TYPES,
4799
+ PRIOR_FINDING_STATUSES,
3511
4800
  PROVIDER_FAILURES,
3512
4801
  QUOTA_BACKFILL_HORIZON_MS,
3513
4802
  QUOTA_RETRY_INFLIGHT_GRACE_MS,
3514
4803
  QUOTA_SUPPORTED_PROVIDERS,
3515
4804
  RECENT_SESSION_BUCKETS,
3516
4805
  RECLAIMING_SEND_REFUSALS,
4806
+ RELAY_REPROBE_BASE_DELAY_MS,
4807
+ RELAY_REPROBE_JITTER_RATIO,
4808
+ RELAY_REPROBE_MAX_DELAY_MS,
4809
+ RELEASE_ACTORS,
3517
4810
  RELEASE_CHANNELS,
4811
+ RELEASE_EVENT_TYPES,
4812
+ RELEASE_LIMITS,
4813
+ RELEASE_MEMBER_STATES,
3518
4814
  REMOVED_MESH_TOOLS,
3519
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,
3520
4826
  SEND_POLICY_MODES,
3521
4827
  SEND_REFUSAL_REASONS,
3522
4828
  SERVER_STATUS_EVENT_NAMES,
@@ -3529,6 +4835,17 @@ export {
3529
4835
  SESSION_STATUS_ALIASES,
3530
4836
  SESSION_STATUS_CLASS,
3531
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,
3532
4849
  STATUS_PROBE_ARG_KEY,
3533
4850
  SUSPENSION_MODALS,
3534
4851
  SUSPENSION_RESOLUTIONS,
@@ -3554,17 +4871,27 @@ export {
3554
4871
  VERSION_UPDATE_REASONS,
3555
4872
  VIEWER_TO_SHARED_SESSION_TYPES,
3556
4873
  WORKER_BRANCH_STATES,
4874
+ WORKER_COMMITS_MAX,
4875
+ WORKER_CURRENT_BRANCH_RULE,
4876
+ WORKER_DECISIONS_NEEDED_MAX,
3557
4877
  WORKER_PROTOCOL_FOOTER_MARKER,
3558
4878
  WORKER_REPORT_OUTCOMES,
4879
+ WORKER_REPORT_SUMMARY_MAX_CHARS,
4880
+ WORKER_SHELL_LITERAL_PATHS_RULE,
3559
4881
  WORKER_TOOLS,
4882
+ aggregateMissionGitState,
3560
4883
  appendWorkerProtocolFooter,
3561
4884
  argsCarryStatusProbeMarker,
3562
4885
  assessQuotaFreshness,
4886
+ boundEventPayload,
3563
4887
  buildSlotProposal,
3564
4888
  canonicalDaemonId,
4889
+ changelogMissionMarker,
4890
+ classifyChangelogSection,
3565
4891
  classifySessionStatus,
3566
4892
  compareDashboardWireVersion,
3567
4893
  compareSemver,
4894
+ computeRelayReprobeDelay,
3568
4895
  daemonIdsEquivalent,
3569
4896
  decodeActiveWorkQueryRequest,
3570
4897
  decodeActiveWorkQueryResponse,
@@ -3607,6 +4934,8 @@ export {
3607
4934
  decodeQueueQueryResponse,
3608
4935
  decodeQueueRequeueRequest,
3609
4936
  decodeQueueRequeueResponse,
4937
+ decodeQueueReviseRequest,
4938
+ decodeQueueReviseResponse,
3610
4939
  decodeRecordLocalRequest,
3611
4940
  decodeRecordLocalResponse,
3612
4941
  decodeRecoveryContextQueryRequest,
@@ -3626,6 +4955,8 @@ export {
3626
4955
  decodeUserSessionToDashboard,
3627
4956
  decodeViewerToSharedSession,
3628
4957
  defaultProviderPriorityFromNodeFacts,
4958
+ defaultStagePlan,
4959
+ deriveItemDedupeKey,
3629
4960
  deriveProviderPriorityFromSlots,
3630
4961
  deriveSlotsFromLegacy,
3631
4962
  describeModelSelection,
@@ -3636,13 +4967,21 @@ export {
3636
4967
  expandDaemonIdForms,
3637
4968
  findOwnershipConflicts,
3638
4969
  foldKeyedDoc,
4970
+ followedRemoteProjectKey,
4971
+ followerOpPermitted,
3639
4972
  formatQuotaAccount,
4973
+ formatStageVerdictLine,
3640
4974
  hasGitStatusEvidence,
3641
4975
  hasWorkerProtocolFooter,
3642
4976
  interpolateString,
4977
+ isActionableProviderApproval,
4978
+ isAssistantFollowerAllowedOp,
3643
4979
  isAssistantTool,
3644
4980
  isBlockedStatus,
4981
+ isBlockingSeverity,
3645
4982
  isBusyStatus,
4983
+ isCarryOverMissionRecord,
4984
+ isCarryOverMissionTitle,
3646
4985
  isChunkType,
3647
4986
  isCommitStrength,
3648
4987
  isDaemonDirectCommandType,
@@ -3658,14 +4997,21 @@ export {
3658
4997
  isDeadStatus,
3659
4998
  isDowngrade,
3660
4999
  isEvidenceIdentifier,
5000
+ isFindingCategory,
5001
+ isFindingResponseKind,
5002
+ isFindingSeverity,
3661
5003
  isFiniteNumber,
3662
5004
  isIdleSessionState,
3663
5005
  isInputEnvelopeWire,
5006
+ isLaunchDefaultRole,
5007
+ isLaunchDefaultSource,
5008
+ isLightWorkerSession,
3664
5009
  isMeshDeliveryMode,
3665
5010
  isMeshIndexQueryResponse,
3666
5011
  isMeshMissionStatusValue,
3667
5012
  isMeshP2PSignalType,
3668
5013
  isMeshRecordPayload,
5014
+ isMeshReleaseChannel,
3669
5015
  isMeshTaskDifficulty,
3670
5016
  isMeshTaskMode,
3671
5017
  isMeshTaskPriority,
@@ -3673,17 +5019,24 @@ export {
3673
5019
  isMeshTerminalTaskStatus,
3674
5020
  isMeshTopicEntry,
3675
5021
  isMessageId,
5022
+ isMissionOutcome,
5023
+ isMissionRefContained,
3676
5024
  isMissionUpsertResponse,
3677
5025
  isModelAxisSource,
5026
+ isNativeMarkerRef,
3678
5027
  isNonEmptyString,
3679
5028
  isNotifyKind,
3680
5029
  isOutboundMessage,
3681
5030
  isOutboundMessageOrigin,
3682
5031
  isP2PSignalType,
3683
5032
  isPhantomDaemonEntry,
5033
+ isPriorFindingStatus,
5034
+ isProviderQuestionBinding,
3684
5035
  isRawDaemonDoId,
3685
5036
  isReadyStatus,
3686
5037
  isRecord,
5038
+ isReleaseStatus,
5039
+ isReviewVerdict,
3687
5040
  isSendPolicy,
3688
5041
  isSendPolicyMode,
3689
5042
  isSendRefusal,
@@ -3692,6 +5045,8 @@ export {
3692
5045
  isSessionLaunchedBy,
3693
5046
  isSessionStatus,
3694
5047
  isSharedSessionToViewerType,
5048
+ isStageBlockedReason,
5049
+ isStageEligibleTask,
3695
5050
  isSubmitOutcome,
3696
5051
  isSummaryRef,
3697
5052
  isTerminalSessionRecordStatus,
@@ -3710,6 +5065,7 @@ export {
3710
5065
  isWorkingStatus,
3711
5066
  joinRepoPath,
3712
5067
  launchModelSelectionValue,
5068
+ lintChangelogText,
3713
5069
  machineCoreFromDaemonId,
3714
5070
  makeTypeGuard,
3715
5071
  measureWorstCaseChunkEnvelopeBytes,
@@ -3721,41 +5077,58 @@ export {
3721
5077
  minutesUntilQuotaCheck,
3722
5078
  normalizeAuthOkLimits,
3723
5079
  normalizeBrainSlot,
5080
+ normalizeDecisionInput,
3724
5081
  normalizeDifficultyBrainMap,
5082
+ normalizeForDedupe,
3725
5083
  normalizeGitStatus,
3726
5084
  normalizeMeshNodeFacts,
3727
5085
  normalizeMeshNodeId,
3728
5086
  normalizeMeshSessionRecord,
3729
5087
  normalizeMeshWorkspaceForCompare,
3730
5088
  normalizeMissionBrief,
5089
+ normalizeMissionItemInput,
5090
+ normalizeMissionItemUpdate,
5091
+ normalizeMissionRefs,
5092
+ normalizeMissionSummary,
3731
5093
  normalizeNodeCapabilitySlot,
3732
5094
  normalizeNodeCapabilitySlots,
5095
+ normalizeOutcomeReason,
3733
5096
  normalizeOwnedPaths,
5097
+ normalizeReportCommits,
3734
5098
  normalizeSessionStatus,
3735
5099
  normalizeThinkingLevel,
3736
5100
  orderProvidersByBuiltinPreference,
3737
5101
  parseJsonRecord,
5102
+ parseRoleLaunchSelection,
3738
5103
  parseSemver,
3739
5104
  parseSessionLaunchRecord,
3740
5105
  pathsOverlap,
3741
5106
  pickBestTransitGitStatus,
3742
5107
  projectFileDiffRow,
3743
5108
  projectTurnEvidenceEntry,
5109
+ providerApprovalSnapshot,
3744
5110
  readBoolean,
3745
5111
  readEnvelopeFields,
3746
5112
  readGitSubmodules,
3747
5113
  readNumber,
3748
5114
  readOptionalRecord,
5115
+ readProviderDecision,
3749
5116
  readRecord,
3750
5117
  readString,
3751
5118
  readStringArray,
3752
5119
  readText,
3753
5120
  renderCoordinatorWorkerSection,
5121
+ renderLightWorkspaceRules,
3754
5122
  renderMissionBriefBlock,
5123
+ renderStageProtocolLines,
3755
5124
  renderWorkerProtocolFooter,
5125
+ resolveStagePlan,
3756
5126
  retiredMeshToolError,
5127
+ reviewIndependenceOf,
5128
+ sanitizeDispatchRefusalDetail,
3757
5129
  sanitizeModelIdentifier,
3758
5130
  sanitizeRefusalCode,
5131
+ sanitizeRemoteRepoIdentity,
3759
5132
  scoreGitStatusCandidate,
3760
5133
  scoreGitUpstreamFreshness,
3761
5134
  sessionIdsEquivalent,
@@ -3766,6 +5139,11 @@ export {
3766
5139
  summarizeGitShape,
3767
5140
  supportsQuota,
3768
5141
  touchedFilesOutsideOwnership,
5142
+ truncateMissionText,
5143
+ unwrapPastedContent,
5144
+ validateFindingResponses,
5145
+ validateReviewReport,
5146
+ validateTestsRun,
3769
5147
  withStatusProbeMarker
3770
5148
  };
3771
5149
  //# sourceMappingURL=index.mjs.map