@adhdev/mesh-shared 1.0.82-rc.3 → 1.0.82-rc.30

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 (55) hide show
  1. package/dist/assistant-protocol.d.ts +140 -6
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.js +529 -110
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +500 -110
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/launch-defaults.d.ts +194 -0
  8. package/dist/mesh-tool-names.d.ts +2 -2
  9. package/dist/mesh-vocabulary.d.ts +13 -4
  10. package/dist/node-facts.d.ts +41 -1
  11. package/dist/outbound-message.d.ts +7 -0
  12. package/dist/path-ownership.d.ts +1 -1
  13. package/dist/protocol/daemon-server.d.ts +9 -0
  14. package/dist/protocol/dashboard-daemon-p2p.d.ts +1 -1
  15. package/dist/protocol/dashboard-server.d.ts +10 -0
  16. package/dist/provider-approval.d.ts +36 -0
  17. package/dist/provider-question.d.ts +19 -0
  18. package/dist/quota-freshness.d.ts +65 -0
  19. package/dist/role-launch.d.ts +11 -0
  20. package/dist/session-launch.d.ts +3 -22
  21. package/dist/slot-proposal.d.ts +14 -0
  22. package/dist/task-source-phase.d.ts +75 -0
  23. package/dist/turn-evidence.d.ts +24 -12
  24. package/dist/turn-ipc-mission.d.ts +4 -0
  25. package/dist/turn-ipc-queue.d.ts +19 -0
  26. package/dist/turn-ipc.d.ts +2 -2
  27. package/dist/types.d.ts +1 -0
  28. package/dist/worker-protocol.d.ts +1 -1
  29. package/package.json +1 -1
  30. package/src/assistant-protocol.ts +247 -6
  31. package/src/daemon-normalize.ts +7 -5
  32. package/src/index.ts +7 -0
  33. package/src/keyed-doc-delta.ts +9 -1
  34. package/src/launch-defaults.ts +168 -0
  35. package/src/mesh-tool-names.ts +5 -0
  36. package/src/mesh-vocabulary.ts +12 -2
  37. package/src/node-facts.ts +36 -1
  38. package/src/outbound-message.ts +17 -0
  39. package/src/path-ownership.ts +4 -6
  40. package/src/protocol/daemon-server.ts +7 -2
  41. package/src/protocol/dashboard-server.ts +8 -2
  42. package/src/provider-approval.ts +59 -0
  43. package/src/provider-question.ts +31 -0
  44. package/src/quota-freshness.ts +139 -0
  45. package/src/role-launch.ts +51 -0
  46. package/src/session-launch.ts +8 -1
  47. package/src/slot-proposal.ts +61 -2
  48. package/src/task-source-phase.ts +61 -0
  49. package/src/turn-evidence.ts +22 -19
  50. package/src/turn-ipc-mission.ts +8 -2
  51. package/src/turn-ipc-queue.ts +29 -1
  52. package/src/turn-ipc-turn.ts +1 -1
  53. package/src/turn-ipc.ts +1 -0
  54. package/src/types.ts +1 -0
  55. package/src/worker-protocol.ts +4 -0
package/dist/index.mjs CHANGED
@@ -194,15 +194,15 @@ function pickBestTransitGitStatus(node, options) {
194
194
  }
195
195
 
196
196
  // src/session-normalize.ts
197
- function deriveSyntheticSessionId(record) {
197
+ function deriveSyntheticSessionId(record2) {
198
198
  const parts = [
199
- readString(record.workspace),
200
- readString(record.providerType, record.provider),
201
- readString(record.role),
202
- readString(record.state, record.status),
203
- readString(record.title),
204
- readString(record.createdAt, record.created_at),
205
- readString(record.startedAt, record.started_at)
199
+ readString(record2.workspace),
200
+ readString(record2.providerType, record2.provider),
201
+ readString(record2.role),
202
+ readString(record2.state, record2.status),
203
+ readString(record2.title),
204
+ readString(record2.createdAt, record2.created_at),
205
+ readString(record2.startedAt, record2.started_at)
206
206
  ].filter((part) => Boolean(part));
207
207
  if (parts.length === 0) return void 0;
208
208
  return `synthetic:${parts.join("|")}`;
@@ -214,33 +214,33 @@ function sessionIdsEquivalent(a, b) {
214
214
  return idA === idB;
215
215
  }
216
216
  function normalizeMeshSessionRecord(entry) {
217
- const record = readRecord(entry);
218
- const sessionId = readString(record.sessionId, record.session_id, record.id) ?? deriveSyntheticSessionId(record);
217
+ const record2 = readRecord(entry);
218
+ const sessionId = readString(record2.sessionId, record2.session_id, record2.id) ?? deriveSyntheticSessionId(record2);
219
219
  if (!sessionId) return null;
220
220
  return {
221
221
  sessionId,
222
- ...readString(record.providerType, record.provider) ? { providerType: readString(record.providerType, record.provider) } : {},
223
- ...readString(record.state, record.status) ? { state: readString(record.state, record.status) } : {},
224
- ...readString(record.chatStatus, record.chat_status) ? { chatStatus: readString(record.chatStatus, record.chat_status) } : {},
225
- ...readString(record.lifecycle) ? { lifecycle: readString(record.lifecycle) } : {},
226
- ...readString(record.surfaceKind, record.surface_kind) ? { surfaceKind: readString(record.surfaceKind, record.surface_kind) } : {},
227
- ...readString(record.recoveryState, record.recovery_state) ? { recoveryState: readString(record.recoveryState, record.recovery_state) } : {},
228
- ...readString(record.workspace) ? { workspace: readString(record.workspace) } : {},
229
- ...readString(record.title) ? { title: readString(record.title) } : {},
230
- ...readString(record.role) ? { role: readString(record.role) } : {},
231
- ...readBoolean(record.isSelfCoordinator, record.is_self_coordinator) !== void 0 ? { isSelfCoordinator: readBoolean(record.isSelfCoordinator, record.is_self_coordinator) } : {},
232
- ...readString(record.statusNote, record.status_note) ? { statusNote: readString(record.statusNote, record.status_note) } : {},
233
- ...readString(record.createdAt, record.created_at) ? { createdAt: readString(record.createdAt, record.created_at) } : {},
234
- ...readString(record.startedAt, record.started_at) ? { startedAt: readString(record.startedAt, record.started_at) } : {},
235
- ...readString(record.lastActivityAt, record.last_activity_at) ? { lastActivityAt: readString(record.lastActivityAt, record.last_activity_at) } : {},
236
- ...readBoolean(record.isCached, record.is_cached) !== void 0 ? { isCached: readBoolean(record.isCached, record.is_cached) } : {}
222
+ ...readString(record2.providerType, record2.provider) ? { providerType: readString(record2.providerType, record2.provider) } : {},
223
+ ...readString(record2.state, record2.status) ? { state: readString(record2.state, record2.status) } : {},
224
+ ...readString(record2.chatStatus, record2.chat_status) ? { chatStatus: readString(record2.chatStatus, record2.chat_status) } : {},
225
+ ...readString(record2.lifecycle) ? { lifecycle: readString(record2.lifecycle) } : {},
226
+ ...readString(record2.surfaceKind, record2.surface_kind) ? { surfaceKind: readString(record2.surfaceKind, record2.surface_kind) } : {},
227
+ ...readString(record2.recoveryState, record2.recovery_state) ? { recoveryState: readString(record2.recoveryState, record2.recovery_state) } : {},
228
+ ...readString(record2.workspace) ? { workspace: readString(record2.workspace) } : {},
229
+ ...readString(record2.title) ? { title: readString(record2.title) } : {},
230
+ ...readString(record2.role) ? { role: readString(record2.role) } : {},
231
+ ...readBoolean(record2.isSelfCoordinator, record2.is_self_coordinator) !== void 0 ? { isSelfCoordinator: readBoolean(record2.isSelfCoordinator, record2.is_self_coordinator) } : {},
232
+ ...readString(record2.statusNote, record2.status_note) ? { statusNote: readString(record2.statusNote, record2.status_note) } : {},
233
+ ...readString(record2.createdAt, record2.created_at) ? { createdAt: readString(record2.createdAt, record2.created_at) } : {},
234
+ ...readString(record2.startedAt, record2.started_at) ? { startedAt: readString(record2.startedAt, record2.started_at) } : {},
235
+ ...readString(record2.lastActivityAt, record2.last_activity_at) ? { lastActivityAt: readString(record2.lastActivityAt, record2.last_activity_at) } : {},
236
+ ...readBoolean(record2.isCached, record2.is_cached) !== void 0 ? { isCached: readBoolean(record2.isCached, record2.is_cached) } : {}
237
237
  };
238
238
  }
239
239
 
240
240
  // src/node-normalize.ts
241
241
  function normalizeMeshNodeId(node) {
242
- const record = node && typeof node === "object" ? node : {};
243
- return readString(record.id, record.nodeId, record.node_id);
242
+ const record2 = node && typeof node === "object" ? node : {};
243
+ return readString(record2.id, record2.nodeId, record2.node_id);
244
244
  }
245
245
  function meshNodeIdMatches(node, candidateId) {
246
246
  if (!candidateId) return false;
@@ -252,12 +252,12 @@ function meshNodeIdMatches(node, candidateId) {
252
252
  // src/node-facts.ts
253
253
  function normalizeMeshNodeFacts(raw) {
254
254
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
255
- const record = raw;
256
- const schemaVersion = Number(record.schemaVersion);
257
- const reportedAt = Number(record.reportedAt);
255
+ const record2 = raw;
256
+ const schemaVersion = Number(record2.schemaVersion);
257
+ const reportedAt = Number(record2.reportedAt);
258
258
  if (!Number.isFinite(schemaVersion) || schemaVersion < 1) return void 0;
259
259
  if (!Number.isFinite(reportedAt) || reportedAt <= 0) return void 0;
260
- return { ...record, schemaVersion, reportedAt };
260
+ return { ...record2, schemaVersion, reportedAt };
261
261
  }
262
262
  var QUOTA_SUPPORTED_PROVIDERS = [
263
263
  "antigravity-cli",
@@ -300,6 +300,52 @@ function defaultProviderPriorityFromNodeFacts(facts) {
300
300
  return orderProvidersByBuiltinPreference(detected.length ? detected : enabled);
301
301
  }
302
302
 
303
+ // src/quota-freshness.ts
304
+ var QUOTA_RETRY_INFLIGHT_GRACE_MS = 6e4;
305
+ var QUOTA_BACKFILL_HORIZON_MS = 60 * 60 * 1e3;
306
+ function hasUsableWindow(window) {
307
+ return !!window && typeof window.usedPercent === "number" && Number.isFinite(window.usedPercent);
308
+ }
309
+ function hasReading(quota) {
310
+ if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly) || hasUsableWindow(quota.monthly)) return true;
311
+ return Array.isArray(quota.buckets) && quota.buckets.some((b) => !!b && typeof b.usedPercent === "number" && Number.isFinite(b.usedPercent));
312
+ }
313
+ function finiteMs(value) {
314
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
315
+ }
316
+ function backfillCheckAt(quota, now) {
317
+ const dataDue = finiteMs(quota.updatedAt);
318
+ const attempted = finiteMs(quota.metadata?.fetchedAt);
319
+ const dueAt = Math.max(
320
+ dataDue === void 0 ? Number.NEGATIVE_INFINITY : dataDue + QUOTA_BACKFILL_HORIZON_MS,
321
+ attempted === void 0 ? Number.NEGATIVE_INFINITY : attempted + QUOTA_BACKFILL_HORIZON_MS
322
+ );
323
+ return Number.isFinite(dueAt) && dueAt > now ? dueAt : void 0;
324
+ }
325
+ function assessQuotaFreshness(quota, now = Date.now()) {
326
+ const meta = quota.metadata;
327
+ const kind = meta?.failureKind;
328
+ const userMustAct = kind === "no-data" && quota.provider !== "codex-cli";
329
+ const awaitsCliUse = kind === "expired-token" && ["grok-cli", "kimi", "antigravity-cli"].includes(quota.provider);
330
+ if (userMustAct) return hasReading(quota) ? { cue: "stale", userMustAct: true } : { userMustAct: true };
331
+ if (awaitsCliUse) return hasReading(quota) ? { cue: "stale", userMustAct: false } : { userMustAct: false };
332
+ if (meta?.lastGoodWindows !== true) {
333
+ const measuredAt = finiteMs(quota.updatedAt);
334
+ if (hasReading(quota) && (measuredAt === void 0 || now - measuredAt >= QUOTA_BACKFILL_HORIZON_MS)) {
335
+ return { cue: "stale", userMustAct };
336
+ }
337
+ return { userMustAct };
338
+ }
339
+ const retryAtMs = finiteMs(meta?.retryAtMs);
340
+ const retryStopped = meta?.retryExhausted === true || retryAtMs !== void 0 && retryAtMs + QUOTA_RETRY_INFLIGHT_GRACE_MS < now;
341
+ if (kind !== "no-data" && !retryStopped) return { cue: "refreshing", userMustAct: false };
342
+ const nextCheckAt = backfillCheckAt(quota, now);
343
+ return nextCheckAt === void 0 ? { cue: "stale", userMustAct: false } : { cue: "stale", userMustAct: false, nextCheckAt };
344
+ }
345
+ function minutesUntilQuotaCheck(nextCheckAt, now = Date.now()) {
346
+ return Math.max(1, Math.round((nextCheckAt - now) / 6e4));
347
+ }
348
+
303
349
  // src/workspace-normalize.ts
304
350
  function normalizeMeshWorkspaceForCompare(dir) {
305
351
  if (typeof dir !== "string") return "";
@@ -329,19 +375,21 @@ function isPhantomDaemonEntry(entry) {
329
375
  function machineCoreFromDaemonId(id2) {
330
376
  const trimmed = readString(id2);
331
377
  if (!trimmed) return void 0;
378
+ const lower = trimmed.toLowerCase();
332
379
  for (const prefix of DAEMON_ID_PREFIXES) {
333
- if (trimmed.startsWith(prefix)) {
380
+ if (lower.startsWith(prefix)) {
334
381
  const core = trimmed.slice(prefix.length).trim();
335
- return core || void 0;
382
+ if (!core) return void 0;
383
+ return /^mach_/i.test(core) ? `mach_${core.slice(5)}` : core;
336
384
  }
337
385
  }
338
- return trimmed;
386
+ return /^mach_/i.test(trimmed) ? `mach_${trimmed.slice(5)}` : trimmed;
339
387
  }
340
388
  function canonicalDaemonId(id2) {
341
389
  const core = machineCoreFromDaemonId(id2);
342
390
  if (!core) return void 0;
343
- if (!core.startsWith("mach_")) return core;
344
- return `daemon_${core}`;
391
+ if (!/^mach_/i.test(core)) return core;
392
+ return `daemon_mach_${core.slice(5)}`;
345
393
  }
346
394
  function daemonIdsEquivalent(a, b) {
347
395
  const coreA = machineCoreFromDaemonId(a);
@@ -370,9 +418,9 @@ function expandDaemonIdForms(ids) {
370
418
 
371
419
  // src/git-summarize.ts
372
420
  function summarizeGitShape(status) {
373
- const record = readRecord(status);
374
- if (!Object.keys(record).length) return null;
375
- const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
421
+ const record2 = readRecord(status);
422
+ if (!Object.keys(record2).length) return null;
423
+ const submodules = Array.isArray(record2.submodules) ? record2.submodules.map((entry) => {
376
424
  const sub = readRecord(entry);
377
425
  return {
378
426
  path: readString(sub.path) ?? null,
@@ -382,23 +430,23 @@ function summarizeGitShape(status) {
382
430
  };
383
431
  }) : [];
384
432
  return {
385
- isGitRepo: readBoolean(record.isGitRepo),
386
- workspace: readString(record.workspace) ?? null,
387
- repoRoot: readString(record.repoRoot, record.repo_root) ?? null,
388
- branch: readString(record.branch) ?? null,
389
- upstream: readString(record.upstream) ?? null,
390
- upstreamStatus: readString(record.upstreamStatus, record.upstream_status) ?? null,
391
- headCommit: readString(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
392
- ahead: readNumber(record.ahead) ?? null,
393
- behind: readNumber(record.behind) ?? null,
433
+ isGitRepo: readBoolean(record2.isGitRepo),
434
+ workspace: readString(record2.workspace) ?? null,
435
+ repoRoot: readString(record2.repoRoot, record2.repo_root) ?? null,
436
+ branch: readString(record2.branch) ?? null,
437
+ upstream: readString(record2.upstream) ?? null,
438
+ upstreamStatus: readString(record2.upstreamStatus, record2.upstream_status) ?? null,
439
+ headCommit: readString(record2.headCommit, record2.head_commit)?.slice(0, 12) ?? null,
440
+ ahead: readNumber(record2.ahead) ?? null,
441
+ behind: readNumber(record2.behind) ?? null,
394
442
  dirtyCounts: {
395
- staged: readNumber(record.staged) ?? 0,
396
- modified: readNumber(record.modified) ?? 0,
397
- untracked: readNumber(record.untracked) ?? 0,
398
- deleted: readNumber(record.deleted) ?? 0,
399
- renamed: readNumber(record.renamed) ?? 0
443
+ staged: readNumber(record2.staged) ?? 0,
444
+ modified: readNumber(record2.modified) ?? 0,
445
+ untracked: readNumber(record2.untracked) ?? 0,
446
+ deleted: readNumber(record2.deleted) ?? 0,
447
+ renamed: readNumber(record2.renamed) ?? 0
400
448
  },
401
- lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
449
+ lastCheckedAt: readNumber(record2.lastCheckedAt, record2.last_checked_at) ?? null,
402
450
  submoduleCount: submodules.length,
403
451
  submodules
404
452
  };
@@ -564,10 +612,25 @@ var CLI_SLOT_RECIPES = Object.freeze({
564
612
  ],
565
613
  "antigravity-cli": [
566
614
  {
567
- model: "Gemini 3.1 Pro (High)",
615
+ model: "Gemini 3.8 Flash (High)",
616
+ modelCandidates: ["Gemini 3.8 Flash (High)", "Gemini 4 Argon (Low)", "Gemini 3.7 Flash (High)", "Gemini 3.1 Pro (High)"],
568
617
  difficulty: ["easy"],
569
618
  maxParallel: 2,
570
619
  rationale: "Cheap capacity for easy tasks."
620
+ },
621
+ {
622
+ model: "Gemini 4 Argon (Medium)",
623
+ modelCandidates: ["Gemini 4 Argon (Medium)", "Gemini 3.8 Flash (High)", "Gemini 3.7 Flash (High)", "Gemini 3.1 Pro (High)"],
624
+ difficulty: ["medium"],
625
+ maxParallel: 2,
626
+ rationale: "Balanced Argon tier for medium tasks."
627
+ },
628
+ {
629
+ model: "Gemini 4 Argon (High)",
630
+ modelCandidates: ["Gemini 4 Argon (High)", "Gemini 3.8 Flash (High)", "Gemini 3.1 Pro (High)"],
631
+ difficulty: ["difficult"],
632
+ maxParallel: 1,
633
+ rationale: "Reserved for hard tasks; capped at 1 to bound cost."
571
634
  }
572
635
  ],
573
636
  "cursor-cli": [
@@ -606,6 +669,24 @@ function dedupeDetected(detected) {
606
669
  }
607
670
  return out;
608
671
  }
672
+ function resolveRecipeModel(recipe, modelOptions) {
673
+ if (!Array.isArray(modelOptions) || modelOptions.length === 0) {
674
+ return recipe.model;
675
+ }
676
+ const available = new Set(
677
+ modelOptions.filter((m) => typeof m === "string" && m.trim().length > 0).map((m) => m.trim())
678
+ );
679
+ if (available.size === 0) return recipe.model;
680
+ const candidates = [
681
+ ...recipe.model ? [recipe.model] : [],
682
+ ...recipe.modelCandidates ?? []
683
+ ];
684
+ for (const candidate of candidates) {
685
+ const trimmed = typeof candidate === "string" ? candidate.trim() : "";
686
+ if (trimmed && available.has(trimmed)) return trimmed;
687
+ }
688
+ return recipe.model;
689
+ }
609
690
  function buildSlotProposal(detected, currentSlots = []) {
610
691
  const providers = dedupeDetected(detected ?? []);
611
692
  const proposedSlots = [];
@@ -621,7 +702,7 @@ function buildSlotProposal(detected, currentSlots = []) {
621
702
  for (const recipe of recipes) {
622
703
  const slot = normalizeNodeCapabilitySlot({
623
704
  provider: provider.type,
624
- model: recipe.model,
705
+ model: resolveRecipeModel(recipe, provider.modelOptions),
625
706
  thinkingLevel: recipe.thinkingLevel,
626
707
  difficulty: recipe.difficulty,
627
708
  maxParallel: recipe.maxParallel
@@ -675,6 +756,7 @@ var CANONICAL_MESH_TOOL_NAMES = [
675
756
  "mesh_view_queue",
676
757
  "mesh_queue_cancel",
677
758
  "mesh_queue_requeue",
759
+ "mesh_queue_revise",
678
760
  "mesh_send_task",
679
761
  "mesh_read_chat",
680
762
  "mesh_read_debug",
@@ -691,6 +773,7 @@ var CANONICAL_MESH_TOOL_NAMES = [
691
773
  "mesh_list_pending_approvals",
692
774
  "mesh_create",
693
775
  "mesh_add_node",
776
+ "mesh_attach_remote",
694
777
  "mesh_clone_node",
695
778
  "mesh_remove_node",
696
779
  "mesh_cleanup_worktree_nodes",
@@ -710,7 +793,10 @@ var CANONICAL_MESH_TOOL_NAMES = [
710
793
  "mesh_mission_upsert",
711
794
  "mesh_mission_list",
712
795
  "mesh_review_inbox",
713
- "mesh_node_slots"
796
+ "mesh_node_slots",
797
+ "driver_list",
798
+ "driver_describe",
799
+ "artifact_list"
714
800
  ];
715
801
  var CANONICAL_MESH_TOOL_COUNT = CANONICAL_MESH_TOOL_NAMES.length;
716
802
  var RETIRED_MESH_TOOLS = {
@@ -1385,21 +1471,22 @@ function isTerminalSessionRecordStatus(raw) {
1385
1471
  return typeof raw === "string" && TERMINAL_SESSION_RECORD_STATUSES.includes(raw.trim().toLowerCase());
1386
1472
  }
1387
1473
  function isIdleSessionState(state) {
1388
- const record = state && typeof state === "object" ? state : {};
1389
- const status = typeof record.status === "string" ? record.status.trim().toLowerCase() : "";
1474
+ const record2 = state && typeof state === "object" ? state : {};
1475
+ const status = typeof record2.status === "string" ? record2.status.trim().toLowerCase() : "";
1390
1476
  if (isTerminalSessionRecordStatus(status) || isDeadStatus(status)) return false;
1391
- return isReadyStatus(status) || record.activeChat?.status === "waiting_input";
1477
+ return isReadyStatus(status) || record2.activeChat?.status === "waiting_input";
1392
1478
  }
1393
1479
 
1394
1480
  // src/mesh-vocabulary.ts
1395
- var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
1396
- var MESH_TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled"];
1481
+ var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "blocked", "failed", "cancelled"];
1482
+ var MESH_TERMINAL_TASK_STATUSES = ["completed", "blocked", "failed", "cancelled"];
1397
1483
  var MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
1398
1484
  var MESH_TASK_PRIORITIES = ["low", "normal", "high"];
1399
1485
  var MESH_THINKING_LEVELS = ["low", "medium", "high"];
1400
1486
  var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
1401
1487
  var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
1402
1488
  var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
1489
+ var WORKER_REPORT_SUMMARY_MAX_CHARS = 8e3;
1403
1490
  var WORKER_BRANCH_STATES = [
1404
1491
  "merged_to_main",
1405
1492
  "pushed_feature_branch_needs_merge",
@@ -1497,6 +1584,14 @@ function isOutboundMessage(value) {
1497
1584
  const candidate = value;
1498
1585
  return isMessageId(candidate.messageId) && typeof candidate.sessionId === "string" && candidate.sessionId.length > 0 && isInputEnvelopeWire(candidate.input) && isOutboundMessageOrigin(candidate.origin) && isSendPolicy(candidate.policy) && typeof candidate.createdAt === "number";
1499
1586
  }
1587
+ var PASTED_OPEN_RE = /^\s*<pasted_content(?:\s+id="[^"]*")?\s*>\s*$/;
1588
+ var PASTED_CLOSE_RE = /^\s*<\/pasted_content(?:\s+id="[^"]*")?\s*>\s*$/;
1589
+ function unwrapPastedContent(text) {
1590
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
1591
+ const first = lines.findIndex((line) => line.trim());
1592
+ if (first < 0 || !PASTED_OPEN_RE.test(lines[first])) return text;
1593
+ return lines.filter((line) => !PASTED_OPEN_RE.test(line) && !PASTED_CLOSE_RE.test(line)).join("\n");
1594
+ }
1500
1595
 
1501
1596
  // src/mission-brief.ts
1502
1597
  var GOAL_MAX = 500;
@@ -1582,7 +1677,11 @@ var WORKER_TOOLS = [
1582
1677
  "peer_context_pull",
1583
1678
  "git_status",
1584
1679
  "git_log",
1585
- "git_diff"
1680
+ "git_diff",
1681
+ "driver_list",
1682
+ "driver_describe",
1683
+ "driver_invoke",
1684
+ "artifact_register"
1586
1685
  ];
1587
1686
  var WORKER_TOOL_SET = new Set(WORKER_TOOLS);
1588
1687
  function isWorkerTool(value) {
@@ -1667,15 +1766,23 @@ function renderCoordinatorWorkerSection() {
1667
1766
  // src/assistant-protocol.ts
1668
1767
  var ASSISTANT_TOOLS = [
1669
1768
  "projects",
1769
+ "environment",
1770
+ "assistant_action",
1771
+ "project_watch",
1670
1772
  "project_status",
1671
1773
  "project_send",
1672
1774
  "project_read",
1673
1775
  "project_add",
1776
+ "project_attach_remote",
1674
1777
  "discover_repos",
1675
1778
  "memory",
1676
1779
  "skill_view",
1677
1780
  "skill_manage",
1678
- "project_note"
1781
+ "project_note",
1782
+ "launch_defaults",
1783
+ "launch_defaults_set",
1784
+ "driver_list",
1785
+ "driver_describe"
1679
1786
  ];
1680
1787
  var ASSISTANT_TOOL_SET = new Set(ASSISTANT_TOOLS);
1681
1788
  function isAssistantTool(value) {
@@ -1683,41 +1790,64 @@ function isAssistantTool(value) {
1683
1790
  }
1684
1791
  var ASSISTANT_VERB = {
1685
1792
  // tool verbs
1793
+ driverList: "driver_list",
1794
+ driverDescribe: "driver_describe",
1686
1795
  projects: "assistant_projects",
1796
+ environment: "assistant_environment",
1797
+ action: "assistant_action",
1798
+ watch: "assistant_project_watch",
1799
+ executionState: "assistant_execution_state",
1800
+ executionSettings: "assistant_execution_settings",
1687
1801
  projectStatus: "assistant_project_status",
1688
1802
  projectSend: "assistant_project_send",
1689
1803
  projectRead: "assistant_project_read",
1690
1804
  projectAdd: "assistant_project_add",
1805
+ projectAttachRemote: "assistant_project_attach_remote",
1691
1806
  discoverRepos: "assistant_discover_repos",
1692
1807
  memory: "assistant_memory",
1693
1808
  skillView: "assistant_skill_view",
1694
1809
  skillManage: "assistant_skill_manage",
1695
1810
  projectNote: "assistant_project_note",
1811
+ launchDefaults: "assistant_launch_defaults",
1812
+ launchDefaultsSet: "assistant_launch_defaults_set",
1696
1813
  // assistant-side daemon verbs without a tool of the same name
1697
1814
  launch: "launch_assistant",
1698
1815
  pendingRelays: "assistant_pending_relays",
1699
1816
  // owner verbs (dashboard only)
1700
1817
  stagedResolve: "assistant_staged_resolve",
1701
1818
  storeAdmin: "assistant_store_admin",
1702
- importSkills: "assistant_import_skills"
1819
+ importSkills: "assistant_import_skills",
1820
+ /** Projects the assistant is following (open relay threads) — list / stop following. */
1821
+ threads: "assistant_threads",
1822
+ threadClose: "assistant_thread_close"
1703
1823
  };
1704
1824
  var ASSISTANT_TOOL_VERBS = {
1825
+ driver_list: ASSISTANT_VERB.driverList,
1826
+ driver_describe: ASSISTANT_VERB.driverDescribe,
1705
1827
  projects: ASSISTANT_VERB.projects,
1828
+ environment: ASSISTANT_VERB.environment,
1829
+ assistant_action: ASSISTANT_VERB.action,
1830
+ project_watch: ASSISTANT_VERB.watch,
1706
1831
  project_status: ASSISTANT_VERB.projectStatus,
1707
1832
  project_send: ASSISTANT_VERB.projectSend,
1708
1833
  project_read: ASSISTANT_VERB.projectRead,
1709
1834
  project_add: ASSISTANT_VERB.projectAdd,
1835
+ project_attach_remote: ASSISTANT_VERB.projectAttachRemote,
1710
1836
  discover_repos: ASSISTANT_VERB.discoverRepos,
1711
1837
  memory: ASSISTANT_VERB.memory,
1712
1838
  skill_view: ASSISTANT_VERB.skillView,
1713
1839
  skill_manage: ASSISTANT_VERB.skillManage,
1714
- project_note: ASSISTANT_VERB.projectNote
1840
+ project_note: ASSISTANT_VERB.projectNote,
1841
+ launch_defaults: ASSISTANT_VERB.launchDefaults,
1842
+ launch_defaults_set: ASSISTANT_VERB.launchDefaultsSet
1715
1843
  };
1716
- var ASSISTANT_WRITE_TOOLS = ["memory", "skill_manage", "project_note", "project_send", "project_add"];
1844
+ var ASSISTANT_WRITE_TOOLS = ["project_watch", "assistant_action", "memory", "skill_manage", "project_note", "project_send", "project_add", "project_attach_remote", "launch_defaults_set"];
1717
1845
  var ASSISTANT_OWNER_VERBS = [
1846
+ ASSISTANT_VERB.executionSettings,
1718
1847
  ASSISTANT_VERB.stagedResolve,
1719
1848
  ASSISTANT_VERB.storeAdmin,
1720
- ASSISTANT_VERB.importSkills
1849
+ ASSISTANT_VERB.importSkills,
1850
+ ASSISTANT_VERB.threadClose
1721
1851
  ];
1722
1852
  var ASSISTANT_REVIEW_TURN_VERBS = [
1723
1853
  ASSISTANT_VERB.memory,
@@ -1727,6 +1857,63 @@ var ASSISTANT_REVIEW_TURN_VERBS = [
1727
1857
  ];
1728
1858
  var ASSISTANT_SESSION_ID_ENV = "ADHDEV_ASSISTANT_SESSION_ID";
1729
1859
  var ASSISTANT_SESSION_ID_ARG = "assistantSessionId";
1860
+ var ASSISTANT_ACCOUNT_SLOT = "personal";
1861
+ var ASSISTANT_REMOTE_PROJECT_COMMAND = "assistant_remote_project";
1862
+ var ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND = "assistant_remote_project_catalog";
1863
+ var ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND = "assistant_remote_project_access";
1864
+ var ASSISTANT_REMOTE_FOLLOW_COMMAND = "assistant_remote_follow";
1865
+ var ASSISTANT_FOLLOWER_ALLOWED_OPS = ["status", "read", "poll", "report", "send"];
1866
+ var ASSISTANT_FOLLOWER_ALLOWED_OP_SET = new Set(ASSISTANT_FOLLOWER_ALLOWED_OPS);
1867
+ function isAssistantFollowerAllowedOp(value) {
1868
+ return typeof value === "string" && ASSISTANT_FOLLOWER_ALLOWED_OP_SET.has(value);
1869
+ }
1870
+ function followedRemoteProjectKey(hostDaemonId, meshId) {
1871
+ const canonHost = canonicalDaemonId(hostDaemonId) ?? hostDaemonId.trim();
1872
+ return `${canonHost}::${meshId.trim()}`;
1873
+ }
1874
+ function sanitizeRemoteRepoIdentity(raw) {
1875
+ if (typeof raw !== "string") return null;
1876
+ const trimmed = raw.trim();
1877
+ if (!trimmed) return null;
1878
+ if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("~/") || trimmed.startsWith("\\") || /^[a-zA-Z]:[\\/]/.test(trimmed) || /^file:/i.test(trimmed)) {
1879
+ return null;
1880
+ }
1881
+ const withoutQuery = trimmed.replace(/[?#].*$/, "").replace(/\/+$/, "");
1882
+ if (!withoutQuery) return null;
1883
+ let host = "";
1884
+ let repoPath = "";
1885
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(withoutQuery)) {
1886
+ try {
1887
+ const url = new URL(withoutQuery);
1888
+ if (url.protocol === "file:") return null;
1889
+ host = url.hostname.toLowerCase();
1890
+ repoPath = decodeURIComponent(url.pathname).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
1891
+ } catch {
1892
+ return null;
1893
+ }
1894
+ } else {
1895
+ const scpMatch = withoutQuery.match(/^(?:[^@/:]+@)?(\[[^\]]+\]|[^/:]+):(.+)$/);
1896
+ if (scpMatch) {
1897
+ host = scpMatch[1].replace(/^\[|\]$/g, "").toLowerCase();
1898
+ repoPath = scpMatch[2].replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
1899
+ } else {
1900
+ const slash = withoutQuery.indexOf("/");
1901
+ if (slash > 0) {
1902
+ const rawHost = withoutQuery.slice(0, slash);
1903
+ const atIdx = rawHost.lastIndexOf("@");
1904
+ host = (atIdx >= 0 ? rawHost.slice(atIdx + 1) : rawHost).toLowerCase();
1905
+ repoPath = withoutQuery.slice(slash + 1).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
1906
+ }
1907
+ }
1908
+ }
1909
+ if (!host || !repoPath) return null;
1910
+ if (!host.includes(".") && host !== "localhost") return null;
1911
+ if (/[\s@:\\]/.test(host)) return null;
1912
+ const segments = repoPath.split("/").filter(Boolean);
1913
+ if (segments.length === 0) return null;
1914
+ if (segments.some((seg) => seg === "." || seg === ".." || /[\s@:\\]/.test(seg))) return null;
1915
+ return `${host}/${segments.join("/")}`.slice(0, 200);
1916
+ }
1730
1917
 
1731
1918
  // src/turn-evidence.ts
1732
1919
  var MESH_TOPIC_PROTOCOL_VERSION = 2;
@@ -1772,8 +1959,8 @@ function sanitizeRefusalCode(value) {
1772
1959
  var CONSUME_PROFILES = ["default", "native_source"];
1773
1960
  var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
1774
1961
  var SUSPENSION_MODALS = ["approval", "choice"];
1775
- var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
1776
- var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer"];
1962
+ var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered", "dismissed"];
1963
+ var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer", "modal_disappeared"];
1777
1964
  var TURN_END_STRENGTHS = ["genuine", "weak"];
1778
1965
  var TURN_END_BLOCK_REASONS = [
1779
1966
  "missing_final_assistant",
@@ -1781,9 +1968,9 @@ var TURN_END_BLOCK_REASONS = [
1781
1968
  "terminal_block_hard_cap",
1782
1969
  "decoupled_completion"
1783
1970
  ];
1784
- var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
1971
+ var NATIVE_TURN_OUTCOMES = ["completed", "aborted", "failed"];
1785
1972
  var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
1786
- var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
1973
+ var PROVIDER_FAILURES = ["auth_failed", "billing_failed", "usage_limit_exceeded", "server_overloaded", "provider_error"];
1787
1974
  var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
1788
1975
  var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
1789
1976
  var OPERATOR_STATUSES = ["completed", "failed"];
@@ -1810,9 +1997,10 @@ var HOLD_REASONS = [
1810
1997
  // — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
1811
1998
  // a session whose FSM never shows the idle edge again does not wait for
1812
1999
  // liveness / hard_ceiling.
1813
- "await_end"
2000
+ "await_end",
2001
+ "report_correction"
1814
2002
  ];
1815
- var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
2003
+ var TURN_OUTCOMES = ["completed", "blocked", "failed", "cancelled"];
1816
2004
  var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
1817
2005
  var TURN_REASONS = [
1818
2006
  // commits
@@ -1821,9 +2009,15 @@ var TURN_REASONS = [
1821
2009
  "transcript_final",
1822
2010
  "worker_reported",
1823
2011
  "finalization_timeout_no_response",
2012
+ "weak_end_liveness_unconfirmed",
2013
+ "weak_end_probe_unobserved",
2014
+ "report_correction_expired",
1824
2015
  "session_error",
1825
2016
  "provider_auth_failed",
1826
2017
  "provider_billing_failed",
2018
+ "provider_usage_limit_exceeded",
2019
+ "provider_server_overloaded",
2020
+ "provider_error",
1827
2021
  "operator_cancel",
1828
2022
  "intentional_cleanup",
1829
2023
  "task_removed",
@@ -1851,6 +2045,7 @@ var TURN_REASONS = [
1851
2045
  ];
1852
2046
  var NOTIFY_KINDS = [
1853
2047
  "completed",
2048
+ "blocked",
1854
2049
  "failed",
1855
2050
  "cancelled",
1856
2051
  "stopped",
@@ -1900,8 +2095,8 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1900
2095
  duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
1901
2096
  session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
1902
2097
  turn_started: { retro: bool },
1903
- suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
1904
- suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
2098
+ suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt, providerSetup: boolOpt, clockUnknown: boolOpt },
2099
+ suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS), modalKey: idOpt },
1905
2100
  turn_end: {
1906
2101
  strength: en(TURN_END_STRENGTHS),
1907
2102
  afterFinalizationTimeout: boolOpt,
@@ -1911,6 +2106,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1911
2106
  releasedByHardCap: boolOpt,
1912
2107
  nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
1913
2108
  live: { t: "live", optional: true },
2109
+ nativeMarker: { t: "native_marker", optional: true },
1914
2110
  reportExpected: boolOpt,
1915
2111
  providerFailure: enOpt(PROVIDER_FAILURES)
1916
2112
  },
@@ -1924,7 +2120,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1924
2120
  },
1925
2121
  transcript_activity: { newestActivityAt: ms },
1926
2122
  no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
1927
- liveness: { result: en(LIVENESS_RESULTS) },
2123
+ liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
1928
2124
  process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
1929
2125
  session_error: { reason: en(SESSION_ERROR_REASONS) },
1930
2126
  worker_report: {
@@ -1934,6 +2130,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
1934
2130
  branchState: enOpt(WORKER_BRANCH_STATES),
1935
2131
  touchedFileCount: intOpt
1936
2132
  },
2133
+ worker_report_correction_requested: { deliveryId: { t: "id", optional: true } },
1937
2134
  worker_progress: { note: { t: "summary_ref", optional: true } },
1938
2135
  git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
1939
2136
  cancel: { reason: en(CANCEL_REASONS) },
@@ -1981,7 +2178,7 @@ function isLiveTurnPending(value) {
1981
2178
  return isRecord2(value) && hasOnlyKeys(value, ["modal", "adapterPending", "trailingTool", "newestActivityAt"]) && typeof value.modal === "boolean" && typeof value.adapterPending === "boolean" && typeof value.trailingTool === "boolean" && (value.newestActivityAt === void 0 || isFiniteNumber2(value.newestActivityAt));
1982
2179
  }
1983
2180
  function isNativeMarkerRef(value) {
1984
- return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId));
2181
+ return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId", "receivedAt", "startedAt", "errorAt"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId)) && ["receivedAt", "startedAt", "errorAt"].every((key) => value[key] === void 0 || isFiniteNumber2(value[key]));
1985
2182
  }
1986
2183
  function isCoordinatorIdentity(value) {
1987
2184
  return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
@@ -2104,17 +2301,89 @@ function projectTurnEvidenceEntry(evidence, attempt) {
2104
2301
  };
2105
2302
  }
2106
2303
 
2304
+ // src/launch-defaults.ts
2305
+ var LAUNCH_DEFAULT_ROLES = ["assistant", "coordinator"];
2306
+ var LAUNCH_DEFAULT_SOURCES = ["user", "stored_default", "project_default", "provider_default"];
2307
+ var LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE = "Applies to the next launch; running sessions are unchanged.";
2308
+ function isLaunchDefaultRole(value) {
2309
+ return typeof value === "string" && LAUNCH_DEFAULT_ROLES.includes(value);
2310
+ }
2311
+ function isLaunchDefaultSource(value) {
2312
+ return typeof value === "string" && LAUNCH_DEFAULT_SOURCES.includes(value);
2313
+ }
2314
+ var LAUNCH_DEFAULT_ERROR_CODES = [
2315
+ "invalid_args",
2316
+ "launch_default_required",
2317
+ "launch_default_unavailable",
2318
+ "launch_selection_invalid",
2319
+ "launch_default_invalid",
2320
+ "revision_conflict",
2321
+ "store_unavailable",
2322
+ "store_busy",
2323
+ "persistence_failed",
2324
+ "project_not_found",
2325
+ "project_ambiguous",
2326
+ "project_not_hosted",
2327
+ "project_storage_unavailable",
2328
+ "staging_unavailable",
2329
+ "staging_failed",
2330
+ "review_turn_tool_denied"
2331
+ ];
2332
+
2333
+ // src/role-launch.ts
2334
+ function record(value) {
2335
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
2336
+ }
2337
+ function ref(value) {
2338
+ const r = record(value);
2339
+ 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;
2340
+ return {
2341
+ role: r.role,
2342
+ scope: r.scope,
2343
+ revision: r.revision,
2344
+ ...r.scope === "project" ? { projectId: r.projectId } : {}
2345
+ };
2346
+ }
2347
+ function axis(value) {
2348
+ const a = record(value);
2349
+ if (!a || !isLaunchDefaultSource(a.source) || a.value !== null && typeof a.value !== "string") return void 0;
2350
+ const defaultRef = ref(a.defaultRef);
2351
+ 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;
2352
+ return { value: a.value, source: a.source, ...defaultRef ? { defaultRef } : {} };
2353
+ }
2354
+ function parseRoleLaunchSelection(value) {
2355
+ const r = record(value), s = record(r?.selection), a = record(r?.applied);
2356
+ 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;
2357
+ const provider = axis(a?.provider), model = axis(a?.model), thinkingLevel = axis(a?.thinkingLevel);
2358
+ 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;
2359
+ const defaultRef = ref(r.defaultRef);
2360
+ return {
2361
+ role: r.role,
2362
+ selection: {
2363
+ provider: s.provider,
2364
+ ...typeof s.model === "string" ? { model: s.model } : {},
2365
+ ...typeof s.thinkingLevel === "string" ? { thinkingLevel: s.thinkingLevel } : {}
2366
+ },
2367
+ applied: { provider, model, thinkingLevel },
2368
+ ...defaultRef ? { defaultRef } : {},
2369
+ documentRevision: r.documentRevision
2370
+ };
2371
+ }
2372
+
2107
2373
  // src/session-launch.ts
2108
2374
  var MODEL_AXIS_SOURCES = [
2109
2375
  /** Picked explicitly for this launch (dashboard dropdown, coordinator dialog). */
2110
2376
  "user",
2111
2377
  /** The dashboard dialog restored it from the last launch (browser-local memory). */
2112
2378
  "remembered",
2379
+ /** The authoritative daemon role default or host project override. */
2380
+ "stored_default",
2381
+ "project_default",
2113
2382
  /** A mesh capability slot supplied it (or a difficulty preset the slot outranked). */
2114
2383
  "mesh_slot",
2115
2384
  /** An explicit per-task model / thinking level on a mesh queue task. */
2116
2385
  "task_override",
2117
- /** Nothing was requested; the provider's default is known (discovery / manifest). */
2386
+ /** Nothing requested: the provider chooses; resolvedDefault records it when known. */
2118
2387
  "provider_default",
2119
2388
  /** A value was requested without saying where it came from, or nothing is known. */
2120
2389
  "unspecified"
@@ -2158,10 +2427,10 @@ function readFiniteNumber(value) {
2158
2427
  }
2159
2428
  function parseModelSelection(raw) {
2160
2429
  if (!raw || typeof raw !== "object") return void 0;
2161
- const record = raw;
2430
+ const record2 = raw;
2162
2431
  const history = [];
2163
- if (Array.isArray(record.history)) {
2164
- for (const entry of record.history) {
2432
+ if (Array.isArray(record2.history)) {
2433
+ for (const entry of record2.history) {
2165
2434
  if (!entry || typeof entry !== "object") continue;
2166
2435
  const e = entry;
2167
2436
  const value = readString(e.value);
@@ -2170,14 +2439,14 @@ function parseModelSelection(raw) {
2170
2439
  if (value && at !== void 0 && via) history.push({ at, value, via });
2171
2440
  }
2172
2441
  }
2173
- const requested = readString(record.requested);
2174
- const launchValue = readString(record.launchValue);
2175
- const resolvedDefault = readString(record.resolvedDefault);
2176
- const current = readString(record.current);
2177
- const observed = readString(record.observed);
2178
- const observedAt = readFiniteNumber(record.observedAt);
2442
+ const requested = readString(record2.requested);
2443
+ const launchValue = readString(record2.launchValue);
2444
+ const resolvedDefault = readString(record2.resolvedDefault);
2445
+ const current = readString(record2.current);
2446
+ const observed = readString(record2.observed);
2447
+ const observedAt = readFiniteNumber(record2.observedAt);
2179
2448
  return {
2180
- source: isModelAxisSource(record.source) ? record.source : "unspecified",
2449
+ source: isModelAxisSource(record2.source) ? record2.source : "unspecified",
2181
2450
  ...requested ? { requested } : {},
2182
2451
  ...launchValue ? { launchValue } : {},
2183
2452
  ...resolvedDefault ? { resolvedDefault } : {},
@@ -2189,22 +2458,24 @@ function parseModelSelection(raw) {
2189
2458
  }
2190
2459
  function parseSessionLaunchRecord(raw) {
2191
2460
  if (!raw || typeof raw !== "object") return void 0;
2192
- const record = raw;
2193
- const sessionId = readString(record.sessionId);
2194
- const providerType = readString(record.providerType);
2195
- const launchedAt = readFiniteNumber(record.launchedAt);
2196
- const model = parseModelSelection(record.model);
2197
- const thinkingLevel = parseModelSelection(record.thinkingLevel);
2461
+ const record2 = raw;
2462
+ const sessionId = readString(record2.sessionId);
2463
+ const providerType = readString(record2.providerType);
2464
+ const launchedAt = readFiniteNumber(record2.launchedAt);
2465
+ const model = parseModelSelection(record2.model);
2466
+ const thinkingLevel = parseModelSelection(record2.thinkingLevel);
2198
2467
  if (!sessionId || !providerType || launchedAt === void 0 || !model || !thinkingLevel) return void 0;
2199
- const providerVersion = readString(record.providerVersion);
2200
- const workspace = readString(record.workspace);
2201
- const autoApproveModeId = readString(record.autoApproveModeId);
2468
+ const providerVersion = readString(record2.providerVersion);
2469
+ const workspace = readString(record2.workspace);
2470
+ const autoApproveModeId = readString(record2.autoApproveModeId);
2471
+ const roleLaunch = parseRoleLaunchSelection(record2.roleLaunch);
2202
2472
  return {
2473
+ ...roleLaunch ? { roleLaunch } : {},
2203
2474
  sessionId,
2204
2475
  providerType,
2205
2476
  ...providerVersion ? { providerVersion } : {},
2206
- ...record.providerChannel === "stable" || record.providerChannel === "preview" ? { providerChannel: record.providerChannel } : {},
2207
- launchedBy: isSessionLaunchedBy(record.launchedBy) ? record.launchedBy : "api",
2477
+ ...record2.providerChannel === "stable" || record2.providerChannel === "preview" ? { providerChannel: record2.providerChannel } : {},
2478
+ launchedBy: isSessionLaunchedBy(record2.launchedBy) ? record2.launchedBy : "api",
2208
2479
  launchedAt,
2209
2480
  ...workspace ? { workspace } : {},
2210
2481
  model,
@@ -2268,7 +2539,7 @@ function isTurnAttemptRefValue(value) {
2268
2539
  function isTurnObserveResponse(value) {
2269
2540
  return isRecord(value) && hasOnlyKeys2(value, ["verdict", "attemptRef", "outcome"]) && isTurnObserveVerdict(value.verdict) && isTurnAttemptRefValue(value.attemptRef) && (value.outcome === void 0 || isTurnOutcomeValue(value.outcome));
2270
2541
  }
2271
- var TURN_OUTCOMES_LOCAL = ["completed", "failed", "cancelled"];
2542
+ var TURN_OUTCOMES_LOCAL = ["completed", "blocked", "failed", "cancelled"];
2272
2543
  function isTurnOutcomeValue(value) {
2273
2544
  return typeof value === "string" && TURN_OUTCOMES_LOCAL.includes(value);
2274
2545
  }
@@ -2569,12 +2840,13 @@ function isMeshMissionTaskAggregateWire(value) {
2569
2840
  return value.lastActivityAt === null || typeof value.lastActivityAt === "string";
2570
2841
  }
2571
2842
  function isMeshMissionStatsWire(value) {
2572
- const keys = ["missionId", "taskCount", "completed", "failed", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2843
+ const keys = ["missionId", "taskCount", "completed", "failed", "blocked", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2573
2844
  if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2574
2845
  if (!isEvidenceIdentifier(value.missionId)) return false;
2575
2846
  for (const k of ["taskCount", "completed", "failed", "totalDurationMs", "retries"]) {
2576
2847
  if (!isNonNegativeInt(value[k])) return false;
2577
2848
  }
2849
+ if (value.blocked !== void 0 && !isNonNegativeInt(value.blocked)) return false;
2578
2850
  if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false;
2579
2851
  if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false;
2580
2852
  return true;
@@ -2696,12 +2968,13 @@ function isLedgerQueryEntryWire(value) {
2696
2968
  return true;
2697
2969
  }
2698
2970
  function isLedgerQuerySummaryWire(value) {
2699
- const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures"];
2971
+ const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskBlocked", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures"];
2700
2972
  if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2701
2973
  if (!isEvidenceIdentifier(value.meshId)) return false;
2702
2974
  for (const k of ["totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "recentFailures"]) {
2703
2975
  if (!isNonNegativeInt(value[k])) return false;
2704
2976
  }
2977
+ if (value.taskBlocked !== void 0 && !isNonNegativeInt(value.taskBlocked)) return false;
2705
2978
  if (value.lastActivityAt !== null && typeof value.lastActivityAt !== "string") return false;
2706
2979
  return true;
2707
2980
  }
@@ -2745,9 +3018,10 @@ function isQueueDependencyHeadWire(value) {
2745
3018
  return isRecord(value) && hasOnlyKeys2(value, ["id", "status", "cancelReason"]) && typeof value.id === "string" && typeof value.status === "string" && (value.cancelReason === void 0 || typeof value.cancelReason === "string");
2746
3019
  }
2747
3020
  function isQueueQueryResponse(value) {
2748
- if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "counts", "oldHistoricalCount", "dependencyHeads"])) return false;
3021
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "counts", "oldHistoricalCount", "legacyReportedBlockedCount", "dependencyHeads"])) return false;
2749
3022
  if (!Array.isArray(value.entries) || !value.entries.every(isQueueEntryWire)) return false;
2750
3023
  if (value.counts !== void 0 && (!isRecord(value.counts) || !Object.values(value.counts).every(isNonNegativeInt))) return false;
3024
+ if (value.legacyReportedBlockedCount !== void 0 && !isNonNegativeInt(value.legacyReportedBlockedCount)) return false;
2751
3025
  if (value.oldHistoricalCount !== void 0 && !isNonNegativeInt(value.oldHistoricalCount)) return false;
2752
3026
  if (value.dependencyHeads !== void 0 && (!Array.isArray(value.dependencyHeads) || !value.dependencyHeads.every(isQueueDependencyHeadWire))) return false;
2753
3027
  return true;
@@ -2869,6 +3143,17 @@ function isRecoveryContextQueryResponse(value) {
2869
3143
  function decodeRecoveryContextQueryResponse(value) {
2870
3144
  return isRecoveryContextQueryResponse(value) ? value : null;
2871
3145
  }
3146
+ function decodeQueueReviseRequest(value) {
3147
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "taskId", "expectedRevision", "patch"]) || 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"])) return null;
3148
+ const p = value.patch;
3149
+ if (p.message !== void 0 && (typeof p.message !== "string" || !p.message.trim())) return null;
3150
+ if (p.phase !== void 0 && p.phase !== "source" && p.phase !== "integration") return null;
3151
+ for (const key of ["ownedPaths", "dependsOn"]) {
3152
+ if (p[key] !== void 0 && (!Array.isArray(p[key]) || !p[key].every((x) => typeof x === "string" && !!x.trim()))) return null;
3153
+ }
3154
+ return value;
3155
+ }
3156
+ var decodeQueueReviseResponse = decodeQueueRequeueResponse;
2872
3157
 
2873
3158
  // src/turn-ipc-stats.ts
2874
3159
  function isTaskStatsQueryRequest(value) {
@@ -2967,6 +3252,7 @@ var TURN_IPC_COMMANDS = [
2967
3252
  "queue_enqueue_batch",
2968
3253
  "queue_cancel",
2969
3254
  "queue_requeue",
3255
+ "queue_revise",
2970
3256
  "direct_dispatch_record",
2971
3257
  "active_work_query",
2972
3258
  "recovery_context_query",
@@ -3050,14 +3336,11 @@ function normalizeOwnedPaths(input) {
3050
3336
  }
3051
3337
  function entryContains(base, path) {
3052
3338
  if (path === base.path) return true;
3053
- if (base.subtree && (path === base.path || path.startsWith(`${base.path}/`))) return true;
3339
+ if (base.subtree && (base.path === "" || path.startsWith(`${base.path}/`))) return true;
3054
3340
  return false;
3055
3341
  }
3056
3342
  function entriesOverlap(a, b) {
3057
- if (a.path === b.path) return true;
3058
- if (a.subtree && (b.path === a.path || b.path.startsWith(`${a.path}/`))) return true;
3059
- if (b.subtree && (a.path === b.path || a.path.startsWith(`${b.path}/`))) return true;
3060
- return false;
3343
+ return entryContains(a, b.path) || entryContains(b, a.path);
3061
3344
  }
3062
3345
  function pathsOverlap(a, b) {
3063
3346
  if (a.paths.length === 0 || b.paths.length === 0) return false;
@@ -3329,7 +3612,15 @@ function foldKeyedDoc(held, delta, spec) {
3329
3612
  const heldList = heldCollections.get(path);
3330
3613
  if (change?.absent) {
3331
3614
  const [head2, tail2] = splitPath(path);
3332
- if (!tail2) delete next[head2];
3615
+ if (!tail2) {
3616
+ delete next[head2];
3617
+ continue;
3618
+ }
3619
+ const parent2 = next[head2];
3620
+ if (!isRecord3(parent2) || !(tail2 in parent2)) continue;
3621
+ const copy = { ...parent2 };
3622
+ delete copy[tail2];
3623
+ next[head2] = copy;
3333
3624
  continue;
3334
3625
  }
3335
3626
  if (!change && heldList === void 0) continue;
@@ -3393,8 +3684,84 @@ function stableMeshNodeRow(row) {
3393
3684
  }
3394
3685
  return out;
3395
3686
  }
3687
+
3688
+ // src/provider-approval.ts
3689
+ function isActionableProviderApproval(approval) {
3690
+ 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());
3691
+ }
3692
+ function readProviderDecision(approval, waiting, hasModal = false) {
3693
+ if (approval !== void 0) return approval && ["provider_modal", "legacy_provider", "status_only", "ledger_approval"].includes(approval.source) ? approval : null;
3694
+ if (!waiting) return null;
3695
+ return {
3696
+ source: hasModal ? "legacy_provider" : "status_only",
3697
+ type: "unknown",
3698
+ compatibility: hasModal ? "session_only" : "unknown",
3699
+ evidence: "unavailable",
3700
+ lifecycle: "pending",
3701
+ modalKey: null,
3702
+ createdAt: null,
3703
+ resolvedAt: null,
3704
+ description: "",
3705
+ buttons: [],
3706
+ actionable: false
3707
+ };
3708
+ }
3709
+ function providerApprovalSnapshot(approval) {
3710
+ if (!approval) return null;
3711
+ const {
3712
+ source,
3713
+ type,
3714
+ lifecycle,
3715
+ modalKey,
3716
+ createdAt,
3717
+ resolvedAt,
3718
+ providerType,
3719
+ sessionId,
3720
+ nodeId,
3721
+ meshId,
3722
+ taskId,
3723
+ attemptId,
3724
+ generation
3725
+ } = approval;
3726
+ return {
3727
+ source,
3728
+ type,
3729
+ lifecycle,
3730
+ modalKey,
3731
+ createdAt,
3732
+ resolvedAt,
3733
+ providerType,
3734
+ sessionId,
3735
+ nodeId,
3736
+ meshId,
3737
+ taskId,
3738
+ attemptId,
3739
+ generation,
3740
+ evidence: "cached",
3741
+ actionable: false,
3742
+ description: "",
3743
+ buttons: []
3744
+ };
3745
+ }
3746
+
3747
+ // src/provider-question.ts
3748
+ function isProviderQuestionBinding(value) {
3749
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
3750
+ const b = value;
3751
+ if (b.transport !== "codex_rpc" && b.transport !== "codex_async") return false;
3752
+ const keys = ["transport", "sessionId", "generation", "threadId", "turnId", "itemId", ...b.transport === "codex_rpc" ? ["requestId"] : []];
3753
+ if (Reflect.ownKeys(b).some((key) => typeof key !== "string" || !keys.includes(key))) return false;
3754
+ if (["sessionId", "generation", "threadId", "turnId", "itemId"].some((key) => typeof b[key] !== "string" || !b[key].trim())) return false;
3755
+ return b.transport === "codex_async" ? b.requestId === void 0 : typeof b.requestId === "string" && !!b.requestId.trim() || typeof b.requestId === "number" && Number.isFinite(b.requestId);
3756
+ }
3396
3757
  export {
3758
+ ASSISTANT_ACCOUNT_SLOT,
3759
+ ASSISTANT_FOLLOWER_ALLOWED_OPS,
3397
3760
  ASSISTANT_OWNER_VERBS,
3761
+ ASSISTANT_REMOTE_FOLLOW_COMMAND,
3762
+ ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND,
3763
+ ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND,
3764
+ ASSISTANT_REMOTE_PROJECT_COMMAND,
3398
3765
  ASSISTANT_REVIEW_TURN_VERBS,
3399
3766
  ASSISTANT_SESSION_ID_ARG,
3400
3767
  ASSISTANT_SESSION_ID_ENV,
@@ -3431,6 +3798,10 @@ export {
3431
3798
  EVIDENCE_ENVELOPE_FIELD_SPECS,
3432
3799
  EVIDENCE_SOURCE_IDS,
3433
3800
  HOLD_REASONS,
3801
+ LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE,
3802
+ LAUNCH_DEFAULT_ERROR_CODES,
3803
+ LAUNCH_DEFAULT_ROLES,
3804
+ LAUNCH_DEFAULT_SOURCES,
3434
3805
  LIVENESS_RESULTS,
3435
3806
  MAX_MESH_RECORD_STRING,
3436
3807
  MAX_OWNED_PATHS,
@@ -3471,6 +3842,8 @@ export {
3471
3842
  OUTBOUND_MESSAGE_ORIGINS,
3472
3843
  P2P_SIGNAL_TYPES,
3473
3844
  PROVIDER_FAILURES,
3845
+ QUOTA_BACKFILL_HORIZON_MS,
3846
+ QUOTA_RETRY_INFLIGHT_GRACE_MS,
3474
3847
  QUOTA_SUPPORTED_PROVIDERS,
3475
3848
  RECENT_SESSION_BUCKETS,
3476
3849
  RECLAIMING_SEND_REFUSALS,
@@ -3516,9 +3889,11 @@ export {
3516
3889
  WORKER_BRANCH_STATES,
3517
3890
  WORKER_PROTOCOL_FOOTER_MARKER,
3518
3891
  WORKER_REPORT_OUTCOMES,
3892
+ WORKER_REPORT_SUMMARY_MAX_CHARS,
3519
3893
  WORKER_TOOLS,
3520
3894
  appendWorkerProtocolFooter,
3521
3895
  argsCarryStatusProbeMarker,
3896
+ assessQuotaFreshness,
3522
3897
  buildSlotProposal,
3523
3898
  canonicalDaemonId,
3524
3899
  classifySessionStatus,
@@ -3566,6 +3941,8 @@ export {
3566
3941
  decodeQueueQueryResponse,
3567
3942
  decodeQueueRequeueRequest,
3568
3943
  decodeQueueRequeueResponse,
3944
+ decodeQueueReviseRequest,
3945
+ decodeQueueReviseResponse,
3569
3946
  decodeRecordLocalRequest,
3570
3947
  decodeRecordLocalResponse,
3571
3948
  decodeRecoveryContextQueryRequest,
@@ -3595,10 +3972,13 @@ export {
3595
3972
  expandDaemonIdForms,
3596
3973
  findOwnershipConflicts,
3597
3974
  foldKeyedDoc,
3975
+ followedRemoteProjectKey,
3598
3976
  formatQuotaAccount,
3599
3977
  hasGitStatusEvidence,
3600
3978
  hasWorkerProtocolFooter,
3601
3979
  interpolateString,
3980
+ isActionableProviderApproval,
3981
+ isAssistantFollowerAllowedOp,
3602
3982
  isAssistantTool,
3603
3983
  isBlockedStatus,
3604
3984
  isBusyStatus,
@@ -3620,6 +4000,8 @@ export {
3620
4000
  isFiniteNumber,
3621
4001
  isIdleSessionState,
3622
4002
  isInputEnvelopeWire,
4003
+ isLaunchDefaultRole,
4004
+ isLaunchDefaultSource,
3623
4005
  isMeshDeliveryMode,
3624
4006
  isMeshIndexQueryResponse,
3625
4007
  isMeshMissionStatusValue,
@@ -3634,12 +4016,14 @@ export {
3634
4016
  isMessageId,
3635
4017
  isMissionUpsertResponse,
3636
4018
  isModelAxisSource,
4019
+ isNativeMarkerRef,
3637
4020
  isNonEmptyString,
3638
4021
  isNotifyKind,
3639
4022
  isOutboundMessage,
3640
4023
  isOutboundMessageOrigin,
3641
4024
  isP2PSignalType,
3642
4025
  isPhantomDaemonEntry,
4026
+ isProviderQuestionBinding,
3643
4027
  isRawDaemonDoId,
3644
4028
  isReadyStatus,
3645
4029
  isRecord,
@@ -3677,6 +4061,7 @@ export {
3677
4061
  meshUtf8ByteLength,
3678
4062
  meshWorkspacesEquivalent,
3679
4063
  mintMessageId,
4064
+ minutesUntilQuotaCheck,
3680
4065
  normalizeAuthOkLimits,
3681
4066
  normalizeBrainSlot,
3682
4067
  normalizeDifficultyBrainMap,
@@ -3693,17 +4078,20 @@ export {
3693
4078
  normalizeThinkingLevel,
3694
4079
  orderProvidersByBuiltinPreference,
3695
4080
  parseJsonRecord,
4081
+ parseRoleLaunchSelection,
3696
4082
  parseSemver,
3697
4083
  parseSessionLaunchRecord,
3698
4084
  pathsOverlap,
3699
4085
  pickBestTransitGitStatus,
3700
4086
  projectFileDiffRow,
3701
4087
  projectTurnEvidenceEntry,
4088
+ providerApprovalSnapshot,
3702
4089
  readBoolean,
3703
4090
  readEnvelopeFields,
3704
4091
  readGitSubmodules,
3705
4092
  readNumber,
3706
4093
  readOptionalRecord,
4094
+ readProviderDecision,
3707
4095
  readRecord,
3708
4096
  readString,
3709
4097
  readStringArray,
@@ -3714,6 +4102,7 @@ export {
3714
4102
  retiredMeshToolError,
3715
4103
  sanitizeModelIdentifier,
3716
4104
  sanitizeRefusalCode,
4105
+ sanitizeRemoteRepoIdentity,
3717
4106
  scoreGitStatusCandidate,
3718
4107
  scoreGitUpstreamFreshness,
3719
4108
  sessionIdsEquivalent,
@@ -3724,6 +4113,7 @@ export {
3724
4113
  summarizeGitShape,
3725
4114
  supportsQuota,
3726
4115
  touchedFilesOutsideOwnership,
4116
+ unwrapPastedContent,
3727
4117
  withStatusProbeMarker
3728
4118
  };
3729
4119
  //# sourceMappingURL=index.mjs.map