@caupulican/pi-adaptative 0.93.12 → 0.93.13

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 (139) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/core/agent-paths.d.ts +6 -0
  3. package/dist/core/agent-paths.d.ts.map +1 -1
  4. package/dist/core/agent-paths.js +15 -0
  5. package/dist/core/agent-paths.js.map +1 -1
  6. package/dist/core/agent-session.d.ts.map +1 -1
  7. package/dist/core/agent-session.js +2 -0
  8. package/dist/core/agent-session.js.map +1 -1
  9. package/dist/core/background-lane-controller.d.ts +2 -0
  10. package/dist/core/background-lane-controller.d.ts.map +1 -1
  11. package/dist/core/background-lane-controller.js +3 -0
  12. package/dist/core/background-lane-controller.js.map +1 -1
  13. package/dist/core/background-tool-task-controller.d.ts +4 -0
  14. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  15. package/dist/core/background-tool-task-controller.js +22 -19
  16. package/dist/core/background-tool-task-controller.js.map +1 -1
  17. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +3 -1
  18. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  19. package/dist/core/delegation/worker-agent-control-coordinator.js +8 -0
  20. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  21. package/dist/core/delegation/worker-attempt-executor.d.ts +2 -1
  22. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  23. package/dist/core/delegation/worker-attempt-executor.js +14 -1
  24. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  25. package/dist/core/delegation/worker-claim.d.ts +4 -1
  26. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  27. package/dist/core/delegation/worker-claim.js +20 -2
  28. package/dist/core/delegation/worker-claim.js.map +1 -1
  29. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  30. package/dist/core/delegation/worker-delegation-controller.js +2 -0
  31. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  32. package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
  33. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  34. package/dist/core/delegation/worker-lifecycle.js +3 -0
  35. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  36. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  37. package/dist/core/delegation/worker-runner.js +15 -9
  38. package/dist/core/delegation/worker-runner.js.map +1 -1
  39. package/dist/core/delegation/worker-terminal-output-artifact.d.ts +14 -0
  40. package/dist/core/delegation/worker-terminal-output-artifact.d.ts.map +1 -0
  41. package/dist/core/delegation/worker-terminal-output-artifact.js +49 -0
  42. package/dist/core/delegation/worker-terminal-output-artifact.js.map +1 -0
  43. package/dist/core/foreground-terminal-handoff-controller.d.ts +3 -0
  44. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  45. package/dist/core/foreground-terminal-handoff-controller.js +6 -0
  46. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  47. package/dist/core/goals/goal-session-controller.d.ts +2 -2
  48. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  49. package/dist/core/goals/goal-session-controller.js +2 -11
  50. package/dist/core/goals/goal-session-controller.js.map +1 -1
  51. package/dist/core/orchestration/contracts.d.ts +2 -0
  52. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  53. package/dist/core/orchestration/contracts.js +3 -0
  54. package/dist/core/orchestration/contracts.js.map +1 -1
  55. package/dist/core/orchestration/task-runtime-codecs.d.ts.map +1 -1
  56. package/dist/core/orchestration/task-runtime-codecs.js +11 -2
  57. package/dist/core/orchestration/task-runtime-codecs.js.map +1 -1
  58. package/dist/core/orchestration/worker-result-adapter.d.ts +2 -1
  59. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
  60. package/dist/core/orchestration/worker-result-adapter.js +41 -7
  61. package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
  62. package/dist/core/runtime-builder.d.ts +5 -2
  63. package/dist/core/runtime-builder.d.ts.map +1 -1
  64. package/dist/core/runtime-builder.js +26 -8
  65. package/dist/core/runtime-builder.js.map +1 -1
  66. package/dist/core/secrets/bitwarden-credential-storage-router.d.ts +22 -0
  67. package/dist/core/secrets/bitwarden-credential-storage-router.d.ts.map +1 -0
  68. package/dist/core/secrets/bitwarden-credential-storage-router.js +59 -0
  69. package/dist/core/secrets/bitwarden-credential-storage-router.js.map +1 -0
  70. package/dist/core/secrets/bitwarden-credential-storage.d.ts +2 -8
  71. package/dist/core/secrets/bitwarden-credential-storage.d.ts.map +1 -1
  72. package/dist/core/secrets/bitwarden-credential-storage.js +23 -134
  73. package/dist/core/secrets/bitwarden-credential-storage.js.map +1 -1
  74. package/dist/core/secrets/bitwarden-secrets-manager-storage.d.ts +46 -0
  75. package/dist/core/secrets/bitwarden-secrets-manager-storage.d.ts.map +1 -0
  76. package/dist/core/secrets/bitwarden-secrets-manager-storage.js +379 -0
  77. package/dist/core/secrets/bitwarden-secrets-manager-storage.js.map +1 -0
  78. package/dist/core/secrets/credential-cli-command.d.ts +22 -0
  79. package/dist/core/secrets/credential-cli-command.d.ts.map +1 -0
  80. package/dist/core/secrets/credential-cli-command.js +82 -0
  81. package/dist/core/secrets/credential-cli-command.js.map +1 -0
  82. package/dist/core/secrets/credential-exposure-guard.d.ts +1 -1
  83. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  84. package/dist/core/secrets/credential-exposure-guard.js +5 -1
  85. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  86. package/dist/core/secrets/credential-machine-session.d.ts +13 -0
  87. package/dist/core/secrets/credential-machine-session.d.ts.map +1 -0
  88. package/dist/core/secrets/credential-machine-session.js +139 -0
  89. package/dist/core/secrets/credential-machine-session.js.map +1 -0
  90. package/dist/core/secrets/credential-manager.d.ts +11 -1
  91. package/dist/core/secrets/credential-manager.d.ts.map +1 -1
  92. package/dist/core/secrets/credential-manager.js +44 -9
  93. package/dist/core/secrets/credential-manager.js.map +1 -1
  94. package/dist/core/secrets/credential-profile-envelope.d.ts +10 -0
  95. package/dist/core/secrets/credential-profile-envelope.d.ts.map +1 -0
  96. package/dist/core/secrets/credential-profile-envelope.js +78 -0
  97. package/dist/core/secrets/credential-profile-envelope.js.map +1 -0
  98. package/dist/core/secrets/credential-session-connection.d.ts.map +1 -1
  99. package/dist/core/secrets/credential-session-connection.js +2 -1
  100. package/dist/core/secrets/credential-session-connection.js.map +1 -1
  101. package/dist/core/secrets/credential-source-discovery.d.ts +7 -3
  102. package/dist/core/secrets/credential-source-discovery.d.ts.map +1 -1
  103. package/dist/core/secrets/credential-source-discovery.js +48 -9
  104. package/dist/core/secrets/credential-source-discovery.js.map +1 -1
  105. package/dist/core/tools/delegate-status.d.ts +4 -0
  106. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  107. package/dist/core/tools/delegate-status.js +20 -4
  108. package/dist/core/tools/delegate-status.js.map +1 -1
  109. package/dist/core/tools/goal.d.ts +2 -2
  110. package/dist/core/tools/goal.d.ts.map +1 -1
  111. package/dist/core/tools/goal.js +30 -11
  112. package/dist/core/tools/goal.js.map +1 -1
  113. package/dist/core/tools/secret-store.d.ts.map +1 -1
  114. package/dist/core/tools/secret-store.js +6 -15
  115. package/dist/core/tools/secret-store.js.map +1 -1
  116. package/dist/core/tools/tool-task.d.ts.map +1 -1
  117. package/dist/core/tools/tool-task.js +6 -3
  118. package/dist/core/tools/tool-task.js.map +1 -1
  119. package/dist/core/util/bounded-value.d.ts +2 -0
  120. package/dist/core/util/bounded-value.d.ts.map +1 -1
  121. package/dist/core/util/bounded-value.js +13 -0
  122. package/dist/core/util/bounded-value.js.map +1 -1
  123. package/dist/index.d.ts +3 -1
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +2 -0
  126. package/dist/index.js.map +1 -1
  127. package/dist/utils/tools-manager.d.ts +2 -1
  128. package/dist/utils/tools-manager.d.ts.map +1 -1
  129. package/dist/utils/tools-manager.js +29 -0
  130. package/dist/utils/tools-manager.js.map +1 -1
  131. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  132. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  133. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  134. package/examples/extensions/sandbox/package-lock.json +2 -2
  135. package/examples/extensions/sandbox/package.json +1 -1
  136. package/examples/extensions/with-deps/package-lock.json +2 -2
  137. package/examples/extensions/with-deps/package.json +1 -1
  138. package/npm-shrinkwrap.json +12 -12
  139. package/package.json +4 -4
@@ -1,4 +1,5 @@
1
1
  import { WORKER_COMPLETION_ERROR_CAVEMAN_GUIDANCE } from "../delegation/worker-terminal-handoff-coordinator.js";
2
+ import { workerTerminalOutputArtifact } from "../delegation/worker-terminal-output-artifact.js";
2
3
  const MAX_WORKER_CONTROL_ID_CHARS = 512;
3
4
  export const WORKER_QUEUED_CAVEMAN_GUIDANCE = "CAVEMAN MODE - MANDATORY: queued is admitted durable nonterminal state, not stall or harness failure. Host starts it event-driven when dependencies, capacity, or safety reservations clear. Never poll, interrupt, or cancel a healthy running worker to force the queue. For genuine parallel read-only work, start a fresh worker whose authority.toolNames omits write and edit; write-capable workers may serialize. If you start a fresh narrower replacement, cancel this queued agent after the replacement starts; otherwise both tasks will run.";
4
5
  export const DELEGATE_STATUS_ACTIONS = ["status", "review"];
@@ -17,7 +18,7 @@ function formattedRecordStatus(record) {
17
18
  }
18
19
  return `${record.status}${record.reasonCode ? ` (${record.reasonCode})` : ""}`;
19
20
  }
20
- function formatRecord(record, claim) {
21
+ function formatRecord(record, claim, result) {
21
22
  const lines = [`${record.laneId}: ${formattedRecordStatus(record)}`];
22
23
  if (record.modelRef) {
23
24
  lines.push(`effective model: ${record.modelRef}; thinking: ${record.thinkingLevel ?? "unknown"}`);
@@ -29,6 +30,10 @@ function formatRecord(record, claim) {
29
30
  }
30
31
  if (record.reasonCode === "completion_error")
31
32
  lines.push(WORKER_COMPLETION_ERROR_CAVEMAN_GUIDANCE);
33
+ const outputArtifact = workerTerminalOutputArtifact(result);
34
+ if (outputArtifact) {
35
+ lines.push(`full worker output: ${outputArtifact.uri}${outputArtifact.sizeBytes === undefined ? "" : ` (${outputArtifact.sizeBytes} bytes)`}`);
36
+ }
32
37
  if (!claim)
33
38
  return lines.join("\n");
34
39
  lines.push(`usageReportId: ${claim.usageReportId ?? "none"}`);
@@ -70,6 +75,7 @@ function lanePanelRow(view, details) {
70
75
  view.unreviewed ? "review required" : undefined,
71
76
  ].filter((value) => value !== undefined);
72
77
  const expandedDetails = [
78
+ details?.outputArtifactUri ? `full output: ${details.outputArtifactUri}` : undefined,
73
79
  details?.claimSummary ? `untrusted claim: ${details.claimSummary}` : undefined,
74
80
  details?.changedFiles?.length ? `changed: ${details.changedFiles.join(", ")}` : undefined,
75
81
  ...(details?.blockers ?? []).map((blocker) => `blocker: ${blocker}`),
@@ -186,8 +192,10 @@ export function executeDelegateStatusAction(action, input, deps) {
186
192
  };
187
193
  }
188
194
  const claim = claims.get(record.laneId);
195
+ const workerResult = deps.getWorkerResult?.(record.laneId);
196
+ const outputArtifact = workerTerminalOutputArtifact(workerResult);
189
197
  return {
190
- content: [{ type: "text", text: formatRecord(record, claim) }],
198
+ content: [{ type: "text", text: formatRecord(record, claim, workerResult) }],
191
199
  details: {
192
200
  started: true,
193
201
  action,
@@ -197,6 +205,14 @@ export function executeDelegateStatusAction(action, input, deps) {
197
205
  unreviewed: isUnreviewed(claim),
198
206
  lanes: [laneView(record, claim)],
199
207
  claimSummary: claim?.summary.slice(0, 8_000),
208
+ ...(outputArtifact
209
+ ? {
210
+ outputArtifactUri: outputArtifact.uri,
211
+ ...(outputArtifact.sizeBytes === undefined
212
+ ? {}
213
+ : { outputArtifactSizeBytes: outputArtifact.sizeBytes }),
214
+ }
215
+ : {}),
200
216
  changedFiles: claim?.changedFiles.slice(0, 64),
201
217
  blockers: claim?.blockers?.slice(0, 16),
202
218
  },
@@ -207,7 +223,7 @@ export function executeDelegateStatusAction(action, input, deps) {
207
223
  const queued = records.filter((record) => record.status === "queued").length;
208
224
  const running = records.filter((record) => record.status === "running").length;
209
225
  const terminal = records.length - queued - running;
210
- const recent = recentRecords.map((record) => formatRecord(record, claims.get(record.laneId)).slice(0, 2_048));
226
+ const recent = recentRecords.map((record) => formatRecord(record, claims.get(record.laneId), deps.getWorkerResult?.(record.laneId)).slice(0, 2_048));
211
227
  const olderUnreviewed = unreviewedRecords.filter((record) => !recentLaneIds.has(record.laneId));
212
228
  const displayedRecords = [...recentRecords, ...olderUnreviewed.slice(0, 10)].filter((record, index, all) => all.findIndex((candidate) => candidate.laneId === record.laneId) === index);
213
229
  const overviewLines = [`workers: ${running} running, ${queued} queued, ${terminal} terminal`];
@@ -219,7 +235,7 @@ export function executeDelegateStatusAction(action, input, deps) {
219
235
  const olderUnreviewedText = olderUnreviewed.length > 0
220
236
  ? `\n\nOlder unreviewed workers (outside the recent list):\n${olderUnreviewed
221
237
  .slice(0, 10)
222
- .map((record) => formatRecord(record, claims.get(record.laneId)).slice(0, 2_048))
238
+ .map((record) => formatRecord(record, claims.get(record.laneId), deps.getWorkerResult?.(record.laneId)).slice(0, 2_048))
223
239
  .join("\n\n")}`
224
240
  : "";
225
241
  const overview = overviewLines.join("\n");
@@ -1 +1 @@
1
- {"version":3,"file":"delegate-status.js","sourceRoot":"","sources":["../../../src/core/tools/delegate-status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wCAAwC,EAAE,MAAM,sDAAsD,CAAC;AAGhH,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAExC,MAAM,CAAC,MAAM,8BAA8B,GAC1C,4hBAA4hB,CAAC;AAE9hB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAoDrE,SAAS,YAAY,CAAC,KAA8B;IACnD,OAAO,KAAK,EAAE,oBAAoB,KAAK,IAAI,IAAI,KAAK,CAAC,gBAAgB,KAAK,SAAS,CAAC;AACrF,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAkB;IAChD,OA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GAAG,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,mBAAmB,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;oBACnF,CAAC,CAAC,kBAAkB;aACtB;SACD;QACD,OAAO,EAAE;YACR,OAAO,EAAE,IAAI;YACb,MAAM;YACN,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM;YACpB,MAAM;YACN,OAAO;YACP,QAAQ;YACR,eAAe,EAAE,iBAAiB,CAAC,MAAM;YACzC,iBAAiB,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;YAChF,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;SACpF;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { WORKER_COMPLETION_ERROR_CAVEMAN_GUIDANCE } from \"../delegation/worker-terminal-handoff-coordinator.ts\";\nimport type { OrchestrationPanelModel, OrchestrationPanelRow } from \"./orchestration-panel.ts\";\n\nconst MAX_WORKER_CONTROL_ID_CHARS = 512;\n\nexport const WORKER_QUEUED_CAVEMAN_GUIDANCE =\n\t\"CAVEMAN MODE - MANDATORY: queued is admitted durable nonterminal state, not stall or harness failure. Host starts it event-driven when dependencies, capacity, or safety reservations clear. Never poll, interrupt, or cancel a healthy running worker to force the queue. For genuine parallel read-only work, start a fresh worker whose authority.toolNames omits write and edit; write-capable workers may serialize. If you start a fresh narrower replacement, cancel this queued agent after the replacement starts; otherwise both tasks will run.\";\n\nexport const DELEGATE_STATUS_ACTIONS = [\"status\", \"review\"] as const;\n\nexport type DelegateStatusAction = (typeof DELEGATE_STATUS_ACTIONS)[number];\n\nexport interface DelegateStatusInput {\n\tlaneId?: string;\n}\n\nexport interface DelegateStatusLaneView {\n\tlaneId: string;\n\tlabel?: string;\n\tprofileId?: string;\n\tmodelRef?: string;\n\tthinkingLevel?: NonNullable<LaneRecord[\"thinkingLevel\"]>;\n\ttype: LaneRecord[\"type\"];\n\tstatus: LaneRecord[\"status\"];\n\treasonCode?: string;\n\tunreviewed: boolean;\n}\n\nexport interface DelegateStatusToolDetails {\n\tstarted: boolean;\n\taction: DelegateStatusAction;\n\tkind: \"overview\" | \"lane\" | \"review\" | \"error\";\n\tcount?: number;\n\tqueued?: number;\n\trunning?: number;\n\tterminal?: number;\n\tunreviewedCount?: number;\n\tunreviewedLaneIds?: readonly string[];\n\tlanes?: readonly DelegateStatusLaneView[];\n\tlaneId?: string;\n\tstatus?: LaneRecord[\"status\"];\n\tunreviewed?: boolean;\n\treviewed?: boolean;\n\treviewedAt?: string;\n\treason?: string;\n\tclaimSummary?: string;\n\tchangedFiles?: readonly string[];\n\tblockers?: readonly string[];\n}\n\nexport type AcknowledgeWorkerReviewResult =\n\t| { ok: true; requestId: string; reviewedAt: string }\n\t| { ok: false; reason: \"unknown_worker_claim\" | \"not_flagged\" | \"already_reviewed\" };\n\nexport interface DelegateStatusDependencies {\n\tgetLaneRecords(): LaneRecord[];\n\tgetWorkerClaimSnapshots(): WorkerClaim[];\n\tacknowledgeWorkerReview?(requestId: string): AcknowledgeWorkerReviewResult;\n}\n\nfunction isUnreviewed(claim: WorkerClaim | undefined): boolean {\n\treturn claim?.parentReviewRequired === true && claim.parentReviewedAt === undefined;\n}\n\nfunction isDelegatedWorkerLane(record: LaneRecord): boolean {\n\treturn record.type === \"worker\" || record.type === \"tmux-worker\";\n}\n\nfunction formattedRecordStatus(record: LaneRecord): string {\n\tconst retryReason =\n\t\trecord.status === \"running\" && record.reasonCode?.startsWith(\"retry_scheduled:\")\n\t\t\t? record.reasonCode.slice(\"retry_scheduled:\".length)\n\t\t\t: undefined;\n\tif (retryReason) {\n\t\treturn `retrying after transient ${retryReason} (nonterminal; durable state preserved; terminal handoff pending)`;\n\t}\n\treturn `${record.status}${record.reasonCode ? ` (${record.reasonCode})` : \"\"}`;\n}\n\nfunction formatRecord(record: LaneRecord, claim: WorkerClaim | undefined): string {\n\tconst lines = [`${record.laneId}: ${formattedRecordStatus(record)}`];\n\tif (record.modelRef) {\n\t\tlines.push(`effective model: ${record.modelRef}; thinking: ${record.thinkingLevel ?? \"unknown\"}`);\n\t}\n\tif (record.status === \"queued\") lines.push(WORKER_QUEUED_CAVEMAN_GUIDANCE);\n\tif (record.reasonCode === \"worker_blocked\") {\n\t\tlines.push(\n\t\t\t\"CAVEMAN MODE - MANDATORY: worker_blocked is a delivered task claim with blockers, not harness failure or lost state. Verify the claim, then continue or replan the parent task.\",\n\t\t);\n\t}\n\tif (record.reasonCode === \"completion_error\") lines.push(WORKER_COMPLETION_ERROR_CAVEMAN_GUIDANCE);\n\tif (!claim) return lines.join(\"\\n\");\n\tlines.push(`usageReportId: ${claim.usageReportId ?? \"none\"}`);\n\tif (isUnreviewed(claim)) {\n\t\tlines.push(\n\t\t\t`UNREVIEWED MUTATION - this worker's claim requires explicit parent review. Acknowledge with delegate { action: \"review\", laneId: \"${record.laneId}\" }.`,\n\t\t);\n\t} else if (claim.parentReviewRequired && claim.parentReviewedAt) {\n\t\tlines.push(`reviewed at ${claim.parentReviewedAt}`);\n\t}\n\tlines.push(\"UNTRUSTED worker output — verify before acting on it:\");\n\tlines.push(claim.summary.slice(0, 8_000));\n\tif (claim.changedFiles.length > 0) lines.push(`changed files: ${claim.changedFiles.join(\", \")}`);\n\tif (claim.blockers?.length) lines.push(`blockers: ${claim.blockers.join(\"; \")}`);\n\treturn lines.join(\"\\n\").slice(0, 16 * 1024);\n}\n\nfunction laneView(record: LaneRecord, claim: WorkerClaim | undefined): DelegateStatusLaneView {\n\treturn {\n\t\tlaneId: record.laneId,\n\t\t...(record.label ? { label: record.label } : {}),\n\t\t...(record.profileId ? { profileId: record.profileId } : {}),\n\t\t...(record.modelRef ? { modelRef: record.modelRef } : {}),\n\t\t...(record.thinkingLevel ? { thinkingLevel: record.thinkingLevel } : {}),\n\t\ttype: record.type,\n\t\tstatus: record.status,\n\t\t...(record.reasonCode ? { reasonCode: record.reasonCode } : {}),\n\t\tunreviewed: isUnreviewed(claim),\n\t};\n}\n\nfunction lanePanelRow(view: DelegateStatusLaneView, details?: DelegateStatusToolDetails): OrchestrationPanelRow {\n\tconst meta = [\n\t\tview.label ? view.laneId : undefined,\n\t\tview.profileId ? `profile ${view.profileId}` : undefined,\n\t\tview.modelRef ? `model ${view.modelRef}` : undefined,\n\t\tview.thinkingLevel ? `thinking ${view.thinkingLevel}` : undefined,\n\t\tview.type === \"tmux-worker\" ? \"tmux\" : undefined,\n\t\tview.reasonCode,\n\t\tview.unreviewed ? \"review required\" : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst expandedDetails = [\n\t\tdetails?.claimSummary ? `untrusted claim: ${details.claimSummary}` : undefined,\n\t\tdetails?.changedFiles?.length ? `changed: ${details.changedFiles.join(\", \")}` : undefined,\n\t\t...(details?.blockers ?? []).map((blocker) => `blocker: ${blocker}`),\n\t].filter((value): value is string => value !== undefined);\n\treturn {\n\t\tstatus: view.status,\n\t\tlabel: view.label ?? view.laneId,\n\t\tmeta,\n\t\tdetails: expandedDetails,\n\t};\n}\n\nexport function delegateStatusPanelModel(details: DelegateStatusToolDetails): OrchestrationPanelModel {\n\tif (details.kind === \"error\") {\n\t\treturn {\n\t\t\tlabel: \"workers\",\n\t\t\taction: \"status\",\n\t\t\tstatus: \"error\",\n\t\t\temptyText: details.reason ?? \"Worker status is unavailable.\",\n\t\t};\n\t}\n\tif (details.kind === \"review\") {\n\t\treturn {\n\t\t\tlabel: \"workers\",\n\t\t\taction: details.reviewed ? \"reviewed\" : \"review required\",\n\t\t\tstatus: details.reviewed ? \"success\" : \"warning\",\n\t\t\trows: details.laneId\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: details.reviewed ? \"reviewed\" : \"blocked\",\n\t\t\t\t\t\t\tlabel: details.laneId,\n\t\t\t\t\t\t\tmeta: details.reviewedAt ? [`reviewed ${details.reviewedAt}`] : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: undefined,\n\t\t\temptyText: details.reason,\n\t\t};\n\t}\n\tconst lanes = details.lanes ?? [];\n\tconst rows = lanes.map((view) => lanePanelRow(view, details.kind === \"lane\" ? details : undefined));\n\tconst running = details.running ?? lanes.filter((lane) => lane.status === \"running\").length;\n\tconst queued = details.queued ?? lanes.filter((lane) => lane.status === \"queued\").length;\n\tconst terminal = details.terminal ?? lanes.length - running - queued;\n\tconst unreviewed = details.unreviewedCount ?? lanes.filter((lane) => lane.unreviewed).length;\n\treturn {\n\t\tlabel: \"workers\",\n\t\taction: details.kind === \"lane\" ? \"lane\" : \"status\",\n\t\tstatus: unreviewed > 0 ? \"warning\" : running + queued > 0 ? \"running\" : lanes.length > 0 ? \"success\" : \"idle\",\n\t\tsummary: [\n\t\t\trunning ? `${running} running` : undefined,\n\t\t\tqueued ? `${queued} queued` : undefined,\n\t\t\tterminal ? `${terminal} terminal` : undefined,\n\t\t].filter((value): value is string => value !== undefined),\n\t\trows,\n\t\temptyText: \"No worker lanes.\",\n\t\tnotices:\n\t\t\tunreviewed > 0\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: \"warning\",\n\t\t\t\t\t\t\ttext: `${unreviewed} worker mutation${unreviewed === 1 ? \"\" : \"s\"} awaiting parent review.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: undefined,\n\t};\n}\n\nexport function executeDelegateStatusAction(\n\taction: DelegateStatusAction,\n\tinput: DelegateStatusInput,\n\tdeps: DelegateStatusDependencies,\n): { content: Array<{ type: \"text\"; text: string }>; details: DelegateStatusToolDetails } {\n\tif (action === \"review\") {\n\t\tif (!input.laneId?.trim()) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"delegate review requires laneId\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", reviewed: false, reason: \"missing_lane_id\" },\n\t\t\t};\n\t\t}\n\t\tif (input.laneId.length > MAX_WORKER_CONTROL_ID_CHARS) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"delegate review laneId is invalid\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", reviewed: false, reason: \"invalid_lane_id\" },\n\t\t\t};\n\t\t}\n\t\tconst laneId = input.laneId.trim();\n\t\tif (!deps.acknowledgeWorkerReview) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"review acknowledgement is not available in this session\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", reviewed: false, reason: \"review_unsupported\" },\n\t\t\t};\n\t\t}\n\t\tconst outcome = deps.acknowledgeWorkerReview(laneId);\n\t\tif (!outcome.ok) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `review not acknowledged (${laneId}): ${outcome.reason}` }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", laneId, reviewed: false, reason: outcome.reason },\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: `reviewed ${laneId} at ${outcome.reviewedAt} — notice cleared` }],\n\t\t\tdetails: { started: true, action, kind: \"review\", laneId, reviewed: true, reviewedAt: outcome.reviewedAt },\n\t\t};\n\t}\n\n\tconst records = deps.getLaneRecords().filter(isDelegatedWorkerLane);\n\tconst claims = new Map(deps.getWorkerClaimSnapshots().map((claim) => [claim.requestId, claim]));\n\tconst unreviewedRecords = records.filter((record) => isUnreviewed(claims.get(record.laneId)));\n\n\tif (input.laneId !== undefined) {\n\t\tif (input.laneId.length > MAX_WORKER_CONTROL_ID_CHARS || !input.laneId.trim()) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"worker lane id is invalid\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"error\", reason: \"invalid_lane_id\" },\n\t\t\t};\n\t\t}\n\t\tconst laneId = input.laneId.trim();\n\t\tconst record = records.find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"unknown_worker_lane\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"error\", reason: \"unknown_worker_lane\" },\n\t\t\t};\n\t\t}\n\t\tconst claim = claims.get(record.laneId);\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: formatRecord(record, claim) }],\n\t\t\tdetails: {\n\t\t\t\tstarted: true,\n\t\t\t\taction,\n\t\t\t\tkind: \"lane\",\n\t\t\t\tlaneId: record.laneId,\n\t\t\t\tstatus: record.status,\n\t\t\t\tunreviewed: isUnreviewed(claim),\n\t\t\t\tlanes: [laneView(record, claim)],\n\t\t\t\tclaimSummary: claim?.summary.slice(0, 8_000),\n\t\t\t\tchangedFiles: claim?.changedFiles.slice(0, 64),\n\t\t\t\tblockers: claim?.blockers?.slice(0, 16),\n\t\t\t},\n\t\t};\n\t}\n\n\tconst recentRecords = records.slice(-10);\n\tconst recentLaneIds = new Set(recentRecords.map((record) => record.laneId));\n\tconst queued = records.filter((record) => record.status === \"queued\").length;\n\tconst running = records.filter((record) => record.status === \"running\").length;\n\tconst terminal = records.length - queued - running;\n\tconst recent = recentRecords.map((record) => formatRecord(record, claims.get(record.laneId)).slice(0, 2_048));\n\tconst olderUnreviewed = unreviewedRecords.filter((record) => !recentLaneIds.has(record.laneId));\n\tconst displayedRecords = [...recentRecords, ...olderUnreviewed.slice(0, 10)].filter(\n\t\t(record, index, all) => all.findIndex((candidate) => candidate.laneId === record.laneId) === index,\n\t);\n\tconst overviewLines = [`workers: ${running} running, ${queued} queued, ${terminal} terminal`];\n\tif (unreviewedRecords.length > 0) {\n\t\tconst visibleUnreviewedIds = unreviewedRecords.slice(0, 64).map((record) => record.laneId);\n\t\tconst omitted = unreviewedRecords.length - visibleUnreviewedIds.length;\n\t\toverviewLines.push(\n\t\t\t`${unreviewedRecords.length} unreviewed worker mutation${unreviewedRecords.length === 1 ? \"\" : \"s\"} pending review: ${visibleUnreviewedIds.join(\", \")}${omitted > 0 ? `, and ${omitted} more` : \"\"}. Acknowledge each with delegate { action: \"review\", laneId }.`,\n\t\t);\n\t}\n\tconst olderUnreviewedText =\n\t\tolderUnreviewed.length > 0\n\t\t\t? `\\n\\nOlder unreviewed workers (outside the recent list):\\n${olderUnreviewed\n\t\t\t\t\t.slice(0, 10)\n\t\t\t\t\t.map((record) => formatRecord(record, claims.get(record.laneId)).slice(0, 2_048))\n\t\t\t\t\t.join(\"\\n\\n\")}`\n\t\t\t: \"\";\n\tconst overview = overviewLines.join(\"\\n\");\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext:\n\t\t\t\t\trecent.length > 0\n\t\t\t\t\t\t? `${overview}\\n\\n${recent.join(\"\\n\\n\")}${olderUnreviewedText}`.slice(0, 16 * 1024)\n\t\t\t\t\t\t: \"No worker lanes.\",\n\t\t\t},\n\t\t],\n\t\tdetails: {\n\t\t\tstarted: true,\n\t\t\taction,\n\t\t\tkind: \"overview\",\n\t\t\tcount: recent.length,\n\t\t\tqueued,\n\t\t\trunning,\n\t\t\tterminal,\n\t\t\tunreviewedCount: unreviewedRecords.length,\n\t\t\tunreviewedLaneIds: unreviewedRecords.slice(0, 64).map((record) => record.laneId),\n\t\t\tlanes: displayedRecords.map((record) => laneView(record, claims.get(record.laneId))),\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"delegate-status.js","sourceRoot":"","sources":["../../../src/core/tools/delegate-status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wCAAwC,EAAE,MAAM,sDAAsD,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAAE,MAAM,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Z,IAAI,EACH,MAAM,CAAC,MAAM,GAAG,CAAC;oBAChB,CAAC,CAAC,GAAG,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,mBAAmB,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;oBACnF,CAAC,CAAC,kBAAkB;aACtB;SACD;QACD,OAAO,EAAE;YACR,OAAO,EAAE,IAAI;YACb,MAAM;YACN,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM;YACpB,MAAM;YACN,OAAO;YACP,QAAQ;YACR,eAAe,EAAE,iBAAiB,CAAC,MAAM;YACzC,iBAAiB,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;YAChF,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;SACpF;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { WORKER_COMPLETION_ERROR_CAVEMAN_GUIDANCE } from \"../delegation/worker-terminal-handoff-coordinator.ts\";\nimport { workerTerminalOutputArtifact } from \"../delegation/worker-terminal-output-artifact.ts\";\nimport type { WorkerResultContract } from \"../orchestration/contracts.ts\";\nimport type { OrchestrationPanelModel, OrchestrationPanelRow } from \"./orchestration-panel.ts\";\n\nconst MAX_WORKER_CONTROL_ID_CHARS = 512;\n\nexport const WORKER_QUEUED_CAVEMAN_GUIDANCE =\n\t\"CAVEMAN MODE - MANDATORY: queued is admitted durable nonterminal state, not stall or harness failure. Host starts it event-driven when dependencies, capacity, or safety reservations clear. Never poll, interrupt, or cancel a healthy running worker to force the queue. For genuine parallel read-only work, start a fresh worker whose authority.toolNames omits write and edit; write-capable workers may serialize. If you start a fresh narrower replacement, cancel this queued agent after the replacement starts; otherwise both tasks will run.\";\n\nexport const DELEGATE_STATUS_ACTIONS = [\"status\", \"review\"] as const;\n\nexport type DelegateStatusAction = (typeof DELEGATE_STATUS_ACTIONS)[number];\n\nexport interface DelegateStatusInput {\n\tlaneId?: string;\n}\n\nexport interface DelegateStatusLaneView {\n\tlaneId: string;\n\tlabel?: string;\n\tprofileId?: string;\n\tmodelRef?: string;\n\tthinkingLevel?: NonNullable<LaneRecord[\"thinkingLevel\"]>;\n\ttype: LaneRecord[\"type\"];\n\tstatus: LaneRecord[\"status\"];\n\treasonCode?: string;\n\tunreviewed: boolean;\n}\n\nexport interface DelegateStatusToolDetails {\n\tstarted: boolean;\n\taction: DelegateStatusAction;\n\tkind: \"overview\" | \"lane\" | \"review\" | \"error\";\n\tcount?: number;\n\tqueued?: number;\n\trunning?: number;\n\tterminal?: number;\n\tunreviewedCount?: number;\n\tunreviewedLaneIds?: readonly string[];\n\tlanes?: readonly DelegateStatusLaneView[];\n\tlaneId?: string;\n\tstatus?: LaneRecord[\"status\"];\n\tunreviewed?: boolean;\n\treviewed?: boolean;\n\treviewedAt?: string;\n\treason?: string;\n\tclaimSummary?: string;\n\toutputArtifactUri?: string;\n\toutputArtifactSizeBytes?: number;\n\tchangedFiles?: readonly string[];\n\tblockers?: readonly string[];\n}\n\nexport type AcknowledgeWorkerReviewResult =\n\t| { ok: true; requestId: string; reviewedAt: string }\n\t| { ok: false; reason: \"unknown_worker_claim\" | \"not_flagged\" | \"already_reviewed\" };\n\nexport interface DelegateStatusDependencies {\n\tgetLaneRecords(): LaneRecord[];\n\tgetWorkerClaimSnapshots(): WorkerClaim[];\n\tgetWorkerResult?(laneId: string): Pick<WorkerResultContract, \"artifacts\"> | undefined;\n\tacknowledgeWorkerReview?(requestId: string): AcknowledgeWorkerReviewResult;\n}\n\nfunction isUnreviewed(claim: WorkerClaim | undefined): boolean {\n\treturn claim?.parentReviewRequired === true && claim.parentReviewedAt === undefined;\n}\n\nfunction isDelegatedWorkerLane(record: LaneRecord): boolean {\n\treturn record.type === \"worker\" || record.type === \"tmux-worker\";\n}\n\nfunction formattedRecordStatus(record: LaneRecord): string {\n\tconst retryReason =\n\t\trecord.status === \"running\" && record.reasonCode?.startsWith(\"retry_scheduled:\")\n\t\t\t? record.reasonCode.slice(\"retry_scheduled:\".length)\n\t\t\t: undefined;\n\tif (retryReason) {\n\t\treturn `retrying after transient ${retryReason} (nonterminal; durable state preserved; terminal handoff pending)`;\n\t}\n\treturn `${record.status}${record.reasonCode ? ` (${record.reasonCode})` : \"\"}`;\n}\n\nfunction formatRecord(\n\trecord: LaneRecord,\n\tclaim: WorkerClaim | undefined,\n\tresult?: Pick<WorkerResultContract, \"artifacts\">,\n): string {\n\tconst lines = [`${record.laneId}: ${formattedRecordStatus(record)}`];\n\tif (record.modelRef) {\n\t\tlines.push(`effective model: ${record.modelRef}; thinking: ${record.thinkingLevel ?? \"unknown\"}`);\n\t}\n\tif (record.status === \"queued\") lines.push(WORKER_QUEUED_CAVEMAN_GUIDANCE);\n\tif (record.reasonCode === \"worker_blocked\") {\n\t\tlines.push(\n\t\t\t\"CAVEMAN MODE - MANDATORY: worker_blocked is a delivered task claim with blockers, not harness failure or lost state. Verify the claim, then continue or replan the parent task.\",\n\t\t);\n\t}\n\tif (record.reasonCode === \"completion_error\") lines.push(WORKER_COMPLETION_ERROR_CAVEMAN_GUIDANCE);\n\tconst outputArtifact = workerTerminalOutputArtifact(result);\n\tif (outputArtifact) {\n\t\tlines.push(\n\t\t\t`full worker output: ${outputArtifact.uri}${outputArtifact.sizeBytes === undefined ? \"\" : ` (${outputArtifact.sizeBytes} bytes)`}`,\n\t\t);\n\t}\n\tif (!claim) return lines.join(\"\\n\");\n\tlines.push(`usageReportId: ${claim.usageReportId ?? \"none\"}`);\n\tif (isUnreviewed(claim)) {\n\t\tlines.push(\n\t\t\t`UNREVIEWED MUTATION - this worker's claim requires explicit parent review. Acknowledge with delegate { action: \"review\", laneId: \"${record.laneId}\" }.`,\n\t\t);\n\t} else if (claim.parentReviewRequired && claim.parentReviewedAt) {\n\t\tlines.push(`reviewed at ${claim.parentReviewedAt}`);\n\t}\n\tlines.push(\"UNTRUSTED worker output — verify before acting on it:\");\n\tlines.push(claim.summary.slice(0, 8_000));\n\tif (claim.changedFiles.length > 0) lines.push(`changed files: ${claim.changedFiles.join(\", \")}`);\n\tif (claim.blockers?.length) lines.push(`blockers: ${claim.blockers.join(\"; \")}`);\n\treturn lines.join(\"\\n\").slice(0, 16 * 1024);\n}\n\nfunction laneView(record: LaneRecord, claim: WorkerClaim | undefined): DelegateStatusLaneView {\n\treturn {\n\t\tlaneId: record.laneId,\n\t\t...(record.label ? { label: record.label } : {}),\n\t\t...(record.profileId ? { profileId: record.profileId } : {}),\n\t\t...(record.modelRef ? { modelRef: record.modelRef } : {}),\n\t\t...(record.thinkingLevel ? { thinkingLevel: record.thinkingLevel } : {}),\n\t\ttype: record.type,\n\t\tstatus: record.status,\n\t\t...(record.reasonCode ? { reasonCode: record.reasonCode } : {}),\n\t\tunreviewed: isUnreviewed(claim),\n\t};\n}\n\nfunction lanePanelRow(view: DelegateStatusLaneView, details?: DelegateStatusToolDetails): OrchestrationPanelRow {\n\tconst meta = [\n\t\tview.label ? view.laneId : undefined,\n\t\tview.profileId ? `profile ${view.profileId}` : undefined,\n\t\tview.modelRef ? `model ${view.modelRef}` : undefined,\n\t\tview.thinkingLevel ? `thinking ${view.thinkingLevel}` : undefined,\n\t\tview.type === \"tmux-worker\" ? \"tmux\" : undefined,\n\t\tview.reasonCode,\n\t\tview.unreviewed ? \"review required\" : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst expandedDetails = [\n\t\tdetails?.outputArtifactUri ? `full output: ${details.outputArtifactUri}` : undefined,\n\t\tdetails?.claimSummary ? `untrusted claim: ${details.claimSummary}` : undefined,\n\t\tdetails?.changedFiles?.length ? `changed: ${details.changedFiles.join(\", \")}` : undefined,\n\t\t...(details?.blockers ?? []).map((blocker) => `blocker: ${blocker}`),\n\t].filter((value): value is string => value !== undefined);\n\treturn {\n\t\tstatus: view.status,\n\t\tlabel: view.label ?? view.laneId,\n\t\tmeta,\n\t\tdetails: expandedDetails,\n\t};\n}\n\nexport function delegateStatusPanelModel(details: DelegateStatusToolDetails): OrchestrationPanelModel {\n\tif (details.kind === \"error\") {\n\t\treturn {\n\t\t\tlabel: \"workers\",\n\t\t\taction: \"status\",\n\t\t\tstatus: \"error\",\n\t\t\temptyText: details.reason ?? \"Worker status is unavailable.\",\n\t\t};\n\t}\n\tif (details.kind === \"review\") {\n\t\treturn {\n\t\t\tlabel: \"workers\",\n\t\t\taction: details.reviewed ? \"reviewed\" : \"review required\",\n\t\t\tstatus: details.reviewed ? \"success\" : \"warning\",\n\t\t\trows: details.laneId\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: details.reviewed ? \"reviewed\" : \"blocked\",\n\t\t\t\t\t\t\tlabel: details.laneId,\n\t\t\t\t\t\t\tmeta: details.reviewedAt ? [`reviewed ${details.reviewedAt}`] : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: undefined,\n\t\t\temptyText: details.reason,\n\t\t};\n\t}\n\tconst lanes = details.lanes ?? [];\n\tconst rows = lanes.map((view) => lanePanelRow(view, details.kind === \"lane\" ? details : undefined));\n\tconst running = details.running ?? lanes.filter((lane) => lane.status === \"running\").length;\n\tconst queued = details.queued ?? lanes.filter((lane) => lane.status === \"queued\").length;\n\tconst terminal = details.terminal ?? lanes.length - running - queued;\n\tconst unreviewed = details.unreviewedCount ?? lanes.filter((lane) => lane.unreviewed).length;\n\treturn {\n\t\tlabel: \"workers\",\n\t\taction: details.kind === \"lane\" ? \"lane\" : \"status\",\n\t\tstatus: unreviewed > 0 ? \"warning\" : running + queued > 0 ? \"running\" : lanes.length > 0 ? \"success\" : \"idle\",\n\t\tsummary: [\n\t\t\trunning ? `${running} running` : undefined,\n\t\t\tqueued ? `${queued} queued` : undefined,\n\t\t\tterminal ? `${terminal} terminal` : undefined,\n\t\t].filter((value): value is string => value !== undefined),\n\t\trows,\n\t\temptyText: \"No worker lanes.\",\n\t\tnotices:\n\t\t\tunreviewed > 0\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: \"warning\",\n\t\t\t\t\t\t\ttext: `${unreviewed} worker mutation${unreviewed === 1 ? \"\" : \"s\"} awaiting parent review.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: undefined,\n\t};\n}\n\nexport function executeDelegateStatusAction(\n\taction: DelegateStatusAction,\n\tinput: DelegateStatusInput,\n\tdeps: DelegateStatusDependencies,\n): { content: Array<{ type: \"text\"; text: string }>; details: DelegateStatusToolDetails } {\n\tif (action === \"review\") {\n\t\tif (!input.laneId?.trim()) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"delegate review requires laneId\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", reviewed: false, reason: \"missing_lane_id\" },\n\t\t\t};\n\t\t}\n\t\tif (input.laneId.length > MAX_WORKER_CONTROL_ID_CHARS) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"delegate review laneId is invalid\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", reviewed: false, reason: \"invalid_lane_id\" },\n\t\t\t};\n\t\t}\n\t\tconst laneId = input.laneId.trim();\n\t\tif (!deps.acknowledgeWorkerReview) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"review acknowledgement is not available in this session\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", reviewed: false, reason: \"review_unsupported\" },\n\t\t\t};\n\t\t}\n\t\tconst outcome = deps.acknowledgeWorkerReview(laneId);\n\t\tif (!outcome.ok) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `review not acknowledged (${laneId}): ${outcome.reason}` }],\n\t\t\t\tdetails: { started: false, action, kind: \"review\", laneId, reviewed: false, reason: outcome.reason },\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: `reviewed ${laneId} at ${outcome.reviewedAt} — notice cleared` }],\n\t\t\tdetails: { started: true, action, kind: \"review\", laneId, reviewed: true, reviewedAt: outcome.reviewedAt },\n\t\t};\n\t}\n\n\tconst records = deps.getLaneRecords().filter(isDelegatedWorkerLane);\n\tconst claims = new Map(deps.getWorkerClaimSnapshots().map((claim) => [claim.requestId, claim]));\n\tconst unreviewedRecords = records.filter((record) => isUnreviewed(claims.get(record.laneId)));\n\n\tif (input.laneId !== undefined) {\n\t\tif (input.laneId.length > MAX_WORKER_CONTROL_ID_CHARS || !input.laneId.trim()) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"worker lane id is invalid\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"error\", reason: \"invalid_lane_id\" },\n\t\t\t};\n\t\t}\n\t\tconst laneId = input.laneId.trim();\n\t\tconst record = records.find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: \"unknown_worker_lane\" }],\n\t\t\t\tdetails: { started: false, action, kind: \"error\", reason: \"unknown_worker_lane\" },\n\t\t\t};\n\t\t}\n\t\tconst claim = claims.get(record.laneId);\n\t\tconst workerResult = deps.getWorkerResult?.(record.laneId);\n\t\tconst outputArtifact = workerTerminalOutputArtifact(workerResult);\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: formatRecord(record, claim, workerResult) }],\n\t\t\tdetails: {\n\t\t\t\tstarted: true,\n\t\t\t\taction,\n\t\t\t\tkind: \"lane\",\n\t\t\t\tlaneId: record.laneId,\n\t\t\t\tstatus: record.status,\n\t\t\t\tunreviewed: isUnreviewed(claim),\n\t\t\t\tlanes: [laneView(record, claim)],\n\t\t\t\tclaimSummary: claim?.summary.slice(0, 8_000),\n\t\t\t\t...(outputArtifact\n\t\t\t\t\t? {\n\t\t\t\t\t\t\toutputArtifactUri: outputArtifact.uri,\n\t\t\t\t\t\t\t...(outputArtifact.sizeBytes === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { outputArtifactSizeBytes: outputArtifact.sizeBytes }),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tchangedFiles: claim?.changedFiles.slice(0, 64),\n\t\t\t\tblockers: claim?.blockers?.slice(0, 16),\n\t\t\t},\n\t\t};\n\t}\n\n\tconst recentRecords = records.slice(-10);\n\tconst recentLaneIds = new Set(recentRecords.map((record) => record.laneId));\n\tconst queued = records.filter((record) => record.status === \"queued\").length;\n\tconst running = records.filter((record) => record.status === \"running\").length;\n\tconst terminal = records.length - queued - running;\n\tconst recent = recentRecords.map((record) =>\n\t\tformatRecord(record, claims.get(record.laneId), deps.getWorkerResult?.(record.laneId)).slice(0, 2_048),\n\t);\n\tconst olderUnreviewed = unreviewedRecords.filter((record) => !recentLaneIds.has(record.laneId));\n\tconst displayedRecords = [...recentRecords, ...olderUnreviewed.slice(0, 10)].filter(\n\t\t(record, index, all) => all.findIndex((candidate) => candidate.laneId === record.laneId) === index,\n\t);\n\tconst overviewLines = [`workers: ${running} running, ${queued} queued, ${terminal} terminal`];\n\tif (unreviewedRecords.length > 0) {\n\t\tconst visibleUnreviewedIds = unreviewedRecords.slice(0, 64).map((record) => record.laneId);\n\t\tconst omitted = unreviewedRecords.length - visibleUnreviewedIds.length;\n\t\toverviewLines.push(\n\t\t\t`${unreviewedRecords.length} unreviewed worker mutation${unreviewedRecords.length === 1 ? \"\" : \"s\"} pending review: ${visibleUnreviewedIds.join(\", \")}${omitted > 0 ? `, and ${omitted} more` : \"\"}. Acknowledge each with delegate { action: \"review\", laneId }.`,\n\t\t);\n\t}\n\tconst olderUnreviewedText =\n\t\tolderUnreviewed.length > 0\n\t\t\t? `\\n\\nOlder unreviewed workers (outside the recent list):\\n${olderUnreviewed\n\t\t\t\t\t.slice(0, 10)\n\t\t\t\t\t.map((record) =>\n\t\t\t\t\t\tformatRecord(record, claims.get(record.laneId), deps.getWorkerResult?.(record.laneId)).slice(\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t2_048,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\\n\\n\")}`\n\t\t\t: \"\";\n\tconst overview = overviewLines.join(\"\\n\");\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext:\n\t\t\t\t\trecent.length > 0\n\t\t\t\t\t\t? `${overview}\\n\\n${recent.join(\"\\n\\n\")}${olderUnreviewedText}`.slice(0, 16 * 1024)\n\t\t\t\t\t\t: \"No worker lanes.\",\n\t\t\t},\n\t\t],\n\t\tdetails: {\n\t\t\tstarted: true,\n\t\t\taction,\n\t\t\tkind: \"overview\",\n\t\t\tcount: recent.length,\n\t\t\tqueued,\n\t\t\trunning,\n\t\t\tterminal,\n\t\t\tunreviewedCount: unreviewedRecords.length,\n\t\t\tunreviewedLaneIds: unreviewedRecords.slice(0, 64).map((record) => record.laneId),\n\t\t\tlanes: displayedRecords.map((record) => laneView(record, claims.get(record.laneId))),\n\t\t},\n\t};\n}\n"]}
@@ -134,8 +134,8 @@ export interface GoalToolDependencies {
134
134
  goalId?: string;
135
135
  status: string;
136
136
  } | undefined;
137
- /** Model-facing start authority for the current foreground turn. Omitted by direct owner/test callers. */
138
- authorizeStart?: (input: Pick<GoalToolInput, "userGoal" | "tokenBudget">) => string | undefined;
137
+ /** Model-facing budget normalization for the current foreground turn. Omitted by direct owner/test callers. */
138
+ authorizeStart?: (input: Pick<GoalToolInput, "userGoal" | "tokenBudget">) => string | number | null | undefined;
139
139
  /**
140
140
  * Live tool-evidence check. When wired, kind:"tool" uses this instead of {@link hasToolCallId}
141
141
  * so a still-running background handoff cannot verify as done.
@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,EAAE,MAAM,OAAO,CAAC;IACrD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,SAAS,eAAe,EAAE,CAAC;IACpD,6FAA6F;IAC7F,sBAAsB,CAAC,EAAE,MAAM,SAAS,qBAAqB,EAAE,CAAC;IAChE,+DAA+D;IAC/D,iBAAiB,CAAC,EAAE,MAAM;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC/G,+GAA+G;IAC/G,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,aAAa,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChH;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC/C;AAuLD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,kBAAkB,CA8NvF;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,kBAAkB,iJAuD9E"}
@@ -1,4 +1,4 @@
1
- import { randomUUID } from "node:crypto";
1
+ import { createHash, randomUUID } from "node:crypto";
2
2
  import { stat as fsStat } from "node:fs/promises";
3
3
  import { Type } from "typebox";
4
4
  import { getGoalStateRevision } from "../goals/goal-lifecycle.js";
@@ -27,14 +27,14 @@ const goalSchema = Type.Object({
27
27
  userGoal: Type.Optional(Type.String({ description: "The goal statement. Required for action 'start'." })),
28
28
  tokenBudget: Type.Optional(Type.Integer({ minimum: 1, description: "Optional positive token budget for action 'start'." })),
29
29
  requirementId: Type.Optional(Type.String({
30
- description: "Requirement id for requirement actions.",
30
+ description: "Requirement id for requirement actions. Omit on add_requirement for a stable host id.",
31
31
  })),
32
32
  text: Type.Optional(Type.String({ description: "Requirement text. Required for add_requirement." })),
33
33
  dependencies: Type.Optional(Type.Array(Type.String(), {
34
34
  description: "Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.",
35
35
  })),
36
36
  instructions: Type.Optional(Type.String({ description: "Worker instructions. Required for dispatch_worker." })),
37
- evidenceId: Type.Optional(Type.String({ description: "Evidence id. Required for add_evidence." })),
37
+ evidenceId: Type.Optional(Type.String({ description: "Evidence id. Omit on add_evidence for a stable host id." })),
38
38
  evidenceIds: Type.Optional(Type.Array(Type.String(), {
39
39
  description: "Existing evidence ids for satisfy_requirement.",
40
40
  })),
@@ -112,6 +112,9 @@ async function resolveEvidenceVerified(kind, uri, deps) {
112
112
  }
113
113
  return undefined;
114
114
  }
115
+ function generatedGoalRecordId(prefix, value) {
116
+ return `${prefix}-${createHash("sha256").update(JSON.stringify(value)).digest("hex").slice(0, 16)}`;
117
+ }
115
118
  function toGoalAction(input) {
116
119
  switch (input.action) {
117
120
  case "start":
@@ -124,7 +127,11 @@ function toGoalAction(input) {
124
127
  case "add_requirement":
125
128
  return {
126
129
  action: "add_requirement",
127
- requirementId: input.requirementId ?? "",
130
+ requirementId: input.requirementId ??
131
+ generatedGoalRecordId("req", {
132
+ text: input.text?.trim() ?? "",
133
+ dependencies: [...(input.dependencies ?? [])].map((value) => value.trim()).sort(),
134
+ }),
128
135
  text: input.text ?? "",
129
136
  dependencies: input.dependencies,
130
137
  };
@@ -155,7 +162,12 @@ function toGoalAction(input) {
155
162
  const kind = input.kind;
156
163
  return {
157
164
  action: "add_evidence",
158
- evidenceId: input.evidenceId ?? "",
165
+ evidenceId: input.evidenceId ??
166
+ generatedGoalRecordId("ev", {
167
+ kind,
168
+ summary: input.summary?.trim() ?? "",
169
+ uri: input.uri?.trim() ?? "",
170
+ }),
159
171
  kind,
160
172
  summary: input.summary ?? "",
161
173
  uri: input.uri,
@@ -269,17 +281,24 @@ export function createGoalToolDefinition(deps) {
269
281
  details: { action: "get", applied: false, state },
270
282
  };
271
283
  }
272
- if (input.action === "start" && input.tokenBudget !== undefined && deps.authorizeStart) {
273
- const error = deps.authorizeStart(input);
274
- if (error) {
284
+ let normalizedInput = input;
285
+ if (input.action === "start" && deps.authorizeStart) {
286
+ const authority = deps.authorizeStart(input);
287
+ if (typeof authority === "string") {
275
288
  return {
276
- content: [{ type: "text", text: `goal start failed: ${error}` }],
277
- details: { action: "start", applied: false, error },
289
+ content: [{ type: "text", text: `goal start failed: ${authority}` }],
290
+ details: { action: "start", applied: false, error: authority },
278
291
  isError: true,
279
292
  };
280
293
  }
294
+ normalizedInput = {
295
+ ...input,
296
+ ...(typeof authority === "number" ? { tokenBudget: authority } : {}),
297
+ };
298
+ if (authority === null)
299
+ delete normalizedInput.tokenBudget;
281
300
  }
282
- const mapped = toGoalAction(input);
301
+ const mapped = toGoalAction(normalizedInput);
283
302
  if ("error" in mapped) {
284
303
  return {
285
304
  content: [{ type: "text", text: `goal ${input.action} failed: ${mapped.error}` }],
@@ -1 +1 @@
1
- {"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAA0D,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACvH,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EACN,sBAAsB,EAEtB,6BAA6B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MA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C;QACnC,WAAW,EACV,6hBAA6hB;QAC9hB,aAAa,EAAE,iDAAiD;QAChE,UAAU,EAAE,gBAAgB;QAC5B,OAAO,CAAC,UAAU,EAAE,KAAsC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;YACpF,MAAM,mBAAmB,GAAe,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;YACjG,MAAM,MAAM,GAAkB,qBAAqB,CAAC,mBAAmB,CAAC;gBACvE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE;gBACxB,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU;oBAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE;oBACxB,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACzD,OAAO,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACD,CAAC;IAEF,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AACnD,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { BackgroundToolTaskRef } from \"../background-tool-task-controller.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport { type GoalEvidenceKind, type GoalState, type GoalStatus, isGoalExecutionActive } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport { GOAL_LIFECYCLE_TOOL_NAMES, LEGACY_GOAL_TOOL_NAME } from \"../goals/goal-tool-names.ts\";\nimport {\n\temptyOrchestrationCall,\n\ttype OrchestrationPanelModel,\n\trenderOrchestrationToolResult,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"increment\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Requirement id for requirement actions.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tdependencies: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Existing evidence ids for satisfy_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Optional file/URL, toolCallId, or laneId evidence locator.\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy target. Native is default; use tmux only for an owner-requested persistent pane.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst createGoalSchema = Type.Object(\n\t{\n\t\tobjective: Type.String({ description: \"Required. The concrete objective to start pursuing.\" }),\n\t\ttoken_budget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Positive token budget. Omit unless explicitly requested.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst getGoalSchema = Type.Object({}, { additionalProperties: false });\n\nconst updateGoalSchema = Type.Object(\n\t{\n\t\tstatus: Type.Union([Type.Literal(\"active\"), Type.Literal(\"complete\"), Type.Literal(\"blocked\")], {\n\t\t\tdescription:\n\t\t\t\t\"Set active after concrete progress, complete after an evidence audit, or blocked after the same blocker persists for three turns.\",\n\t\t}),\n\t\treason: Type.Optional(\n\t\t\tType.String({ minLength: 1, description: \"Required for blocked: the recurring external blocker.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\nexport type GoalToolDefinition = ToolDefinition;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n\t/** Live background tool_task records for kind:\"tool\" evidence and complete-time re-check. */\n\tgetBackgroundToolTasks?: () => readonly BackgroundToolTaskRef[];\n\t/** Active ICM pipeline run for the complete/increment join. */\n\tgetActivePipeline?: () => { runId: string; pipelineName: string; goalId?: string; status: string } | undefined;\n\t/** Model-facing start authority for the current foreground turn. Omitted by direct owner/test callers. */\n\tauthorizeStart?: (input: Pick<GoalToolInput, \"userGoal\" | \"tokenBudget\">) => string | undefined;\n\t/**\n\t * Live tool-evidence check. When wired, kind:\"tool\" uses this instead of {@link hasToolCallId}\n\t * so a still-running background handoff cannot verify as done.\n\t */\n\tresolveToolEvidence?: (uri: string) => boolean;\n}\n\nfunction allowsNativeTmuxFallback(reason: string | undefined): boolean {\n\treturn reason === \"tmux_unavailable\" || reason === \"tmux_extension_not_loaded\";\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\tif (deps.resolveToolEvidence) return deps.resolveToolEvidence(trimmedUri);\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"add_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\ttext: input.text ?? \"\",\n\t\t\t\tdependencies: input.dependencies,\n\t\t\t};\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"increment\":\n\t\t\treturn { action: \"increment\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): GoalToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: LEGACY_GOAL_TOOL_NAME,\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the durable goal for work that benefits from persistent autonomous continuation. The agent may start one at its discretion or on explicit user/system request; only the owner or system may set a token budget.\",\n\t\tpromptSnippet: \"Read or update the durable goal.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Start when persistent continuation materially benefits current work or the user/system requests it. Skip routine one-turn tasks; get if uncertain; never replace unfinished goal; tokenBudget only if requested.\",\n\t\t\t\"Plans: task_steps. Workers: delegate. Background tools: tool_task wait once; cite taskId as kind=tool evidence.\",\n\t\t\t\"increment satisfies the current open requirement from unused evidence, or completes when none remain.\",\n\t\t\t\"complete needs current authoritative evidence, no remaining work, no linked open task_steps, no running tool_task, no active pipeline. block_goal needs same real impasse for 3 goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tconst details = result.details as GoalToolDetails | undefined;\n\t\t\treturn renderOrchestrationToolResult(theme, goalPanelModel(details), {\n\t\t\t\tisPartial,\n\t\t\t\tcollapse: !expanded && details?.applied === true,\n\t\t\t\texpanded: true,\n\t\t\t});\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t\tisError?: boolean;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (input.action === \"start\" && input.tokenBudget !== undefined && deps.authorizeStart) {\n\t\t\t\tconst error = deps.authorizeStart(input);\n\t\t\t\tif (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: `goal start failed: ${error}` }],\n\t\t\t\t\t\tdetails: { action: \"start\", applied: false, error },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst tmuxRequested = input.dispatchTarget === \"tmux\";\n\t\t\t\tlet useTmux = tmuxRequested && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tlet tmuxFallbackReason: string | undefined;\n\t\t\t\tlet dispatched: { laneId?: string; skipReason?: string } | undefined;\n\t\t\t\tif (useTmux) {\n\t\t\t\t\tdispatched = await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t\tif (\n\t\t\t\t\t\t!dispatched?.laneId &&\n\t\t\t\t\t\tallowsNativeTmuxFallback(dispatched?.skipReason) &&\n\t\t\t\t\t\tdeps.startWorkerDelegation\n\t\t\t\t\t) {\n\t\t\t\t\t\ttmuxFallbackReason = dispatched?.skipReason;\n\t\t\t\t\t\tuseTmux = false;\n\t\t\t\t\t\tdispatched = deps.startWorkerDelegation({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (tmuxRequested) tmuxFallbackReason = \"tmux_extension_not_loaded\";\n\t\t\t\t\tdispatched = deps.startWorkerDelegation?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = tmuxFallbackReason\n\t\t\t\t\t\t? `Tmux route returned ${tmuxFallbackReason}; dispatched native fallback worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: useTmux\n\t\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (native default).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `${tmuxFallbackReason ? `Tmux route returned ${tmuxFallbackReason}; ` : \"\"}No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tlet activePipeline: ReturnType<NonNullable<GoalToolDependencies[\"getActivePipeline\"]>>;\n\t\t\t\tif (\n\t\t\t\t\tcurrent &&\n\t\t\t\t\tisGoalExecutionActive(current.status) &&\n\t\t\t\t\t(action.action === \"complete\" || action.action === \"increment\")\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tactivePipeline = deps.getActivePipeline?.();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = `Cannot verify active pipeline state: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${message}` }],\n\t\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: message, state: current },\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t\topenTaskSteps: deps.getOpenTaskSteps?.(),\n\t\t\t\t\tbackgroundToolTasks: deps.getBackgroundToolTasks?.(),\n\t\t\t\t\tactivePipeline,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Build the compact Codex-compatible lifecycle surface as adapters over the authoritative legacy\n * goal executor. The wrappers own no state and duplicate no validation, persistence, accounting,\n * completion gate, or start-authority rule.\n */\nexport function createGoalLifecycleToolDefinitions(goalTool: GoalToolDefinition) {\n\tconst createGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tdescription:\n\t\t\t\"Create a durable goal when persistent autonomous continuation materially benefits the current work, or when the user/system explicitly requests one. Use agent discretion; skip routine short tasks. Set token_budget only when explicitly requested. Fails if an unfinished goal exists.\",\n\t\tpromptSnippet: \"Start durable goal.\",\n\t\tparameters: createGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof createGoalSchema>, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{\n\t\t\t\t\taction: \"start\",\n\t\t\t\t\tgoalId: `goal-${randomUUID()}`,\n\t\t\t\t\tuserGoal: input.objective,\n\t\t\t\t\ttokenBudget: input.token_budget,\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t\tcontext,\n\t\t\t);\n\t\t},\n\t};\n\n\tconst getGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tdescription:\n\t\t\t\"Get the current goal for this session, including status, budget, token and elapsed-time usage, requirements, evidence, and progress.\",\n\t\tpromptSnippet: \"Inspect durable goal.\",\n\t\tparameters: getGoalSchema,\n\t\texecute(toolCallId, _input, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(toolCallId, { action: \"get\" }, signal, onUpdate, context);\n\t\t},\n\t};\n\n\tconst updateGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tdescription:\n\t\t\t\"Update the existing goal. Set active only after concrete, verifiable progress in the current turn. Mark complete only when current evidence proves the full objective is achieved and no required work remains. Mark blocked only after the same blocking condition has recurred for at least three consecutive goal turns and no meaningful progress is possible without user input or external change; include that condition in reason. Never use blocked merely because work is hard, slow, uncertain, incomplete, or would benefit from clarification.\",\n\t\tpromptSnippet: \"Update goal; complete/block only with evidence.\",\n\t\tparameters: updateGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof updateGoalSchema>, signal, onUpdate, context) {\n\t\t\tconst requestedGoalStatus: GoalStatus = input.status === \"complete\" ? \"completed\" : input.status;\n\t\t\tconst action: GoalToolInput = isGoalExecutionActive(requestedGoalStatus)\n\t\t\t\t? { action: \"progress\" }\n\t\t\t\t: input.status === \"complete\"\n\t\t\t\t\t? { action: \"complete\" }\n\t\t\t\t\t: { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\t\treturn goalTool.execute(toolCallId, action, signal, onUpdate, context);\n\t\t},\n\t};\n\n\treturn [createGoal, getGoal, updateGoal] as const;\n}\n"]}
1
+ {"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAA0D,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACvH,OAAO,EACN,eAAe,EAIf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AE,yBAAyB,CAAC,CAAC,CAAC;QACnC,WAAW,EACV,6hBAA6hB;QAC9hB,aAAa,EAAE,iDAAiD;QAChE,UAAU,EAAE,gBAAgB;QAC5B,OAAO,CAAC,UAAU,EAAE,KAAsC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;YACpF,MAAM,mBAAmB,GAAe,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;YACjG,MAAM,MAAM,GAAkB,qBAAqB,CAAC,mBAAmB,CAAC;gBACvE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE;gBACxB,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU;oBAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE;oBACxB,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACzD,OAAO,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACD,CAAC;IAEF,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AACnD,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { BackgroundToolTaskRef } from \"../background-tool-task-controller.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport { type GoalEvidenceKind, type GoalState, type GoalStatus, isGoalExecutionActive } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport { GOAL_LIFECYCLE_TOOL_NAMES, LEGACY_GOAL_TOOL_NAME } from \"../goals/goal-tool-names.ts\";\nimport {\n\temptyOrchestrationCall,\n\ttype OrchestrationPanelModel,\n\trenderOrchestrationToolResult,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"increment\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Requirement id for requirement actions. Omit on add_requirement for a stable host id.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tdependencies: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(\n\t\t\tType.String({ description: \"Evidence id. Omit on add_evidence for a stable host id.\" }),\n\t\t),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Existing evidence ids for satisfy_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Optional file/URL, toolCallId, or laneId evidence locator.\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy target. Native is default; use tmux only for an owner-requested persistent pane.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst createGoalSchema = Type.Object(\n\t{\n\t\tobjective: Type.String({ description: \"Required. The concrete objective to start pursuing.\" }),\n\t\ttoken_budget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Positive token budget. Omit unless explicitly requested.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst getGoalSchema = Type.Object({}, { additionalProperties: false });\n\nconst updateGoalSchema = Type.Object(\n\t{\n\t\tstatus: Type.Union([Type.Literal(\"active\"), Type.Literal(\"complete\"), Type.Literal(\"blocked\")], {\n\t\t\tdescription:\n\t\t\t\t\"Set active after concrete progress, complete after an evidence audit, or blocked after the same blocker persists for three turns.\",\n\t\t}),\n\t\treason: Type.Optional(\n\t\t\tType.String({ minLength: 1, description: \"Required for blocked: the recurring external blocker.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\nexport type GoalToolDefinition = ToolDefinition;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n\t/** Live background tool_task records for kind:\"tool\" evidence and complete-time re-check. */\n\tgetBackgroundToolTasks?: () => readonly BackgroundToolTaskRef[];\n\t/** Active ICM pipeline run for the complete/increment join. */\n\tgetActivePipeline?: () => { runId: string; pipelineName: string; goalId?: string; status: string } | undefined;\n\t/** Model-facing budget normalization for the current foreground turn. Omitted by direct owner/test callers. */\n\tauthorizeStart?: (input: Pick<GoalToolInput, \"userGoal\" | \"tokenBudget\">) => string | number | null | undefined;\n\t/**\n\t * Live tool-evidence check. When wired, kind:\"tool\" uses this instead of {@link hasToolCallId}\n\t * so a still-running background handoff cannot verify as done.\n\t */\n\tresolveToolEvidence?: (uri: string) => boolean;\n}\n\nfunction allowsNativeTmuxFallback(reason: string | undefined): boolean {\n\treturn reason === \"tmux_unavailable\" || reason === \"tmux_extension_not_loaded\";\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\tif (deps.resolveToolEvidence) return deps.resolveToolEvidence(trimmedUri);\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction generatedGoalRecordId(prefix: \"req\" | \"ev\", value: unknown): string {\n\treturn `${prefix}-${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\").slice(0, 16)}`;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"add_requirement\",\n\t\t\t\trequirementId:\n\t\t\t\t\tinput.requirementId ??\n\t\t\t\t\tgeneratedGoalRecordId(\"req\", {\n\t\t\t\t\t\ttext: input.text?.trim() ?? \"\",\n\t\t\t\t\t\tdependencies: [...(input.dependencies ?? [])].map((value) => value.trim()).sort(),\n\t\t\t\t\t}),\n\t\t\t\ttext: input.text ?? \"\",\n\t\t\t\tdependencies: input.dependencies,\n\t\t\t};\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId:\n\t\t\t\t\tinput.evidenceId ??\n\t\t\t\t\tgeneratedGoalRecordId(\"ev\", {\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tsummary: input.summary?.trim() ?? \"\",\n\t\t\t\t\t\turi: input.uri?.trim() ?? \"\",\n\t\t\t\t\t}),\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"increment\":\n\t\t\treturn { action: \"increment\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): GoalToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: LEGACY_GOAL_TOOL_NAME,\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the durable goal for work that benefits from persistent autonomous continuation. The agent may start one at its discretion or on explicit user/system request; only the owner or system may set a token budget.\",\n\t\tpromptSnippet: \"Read or update the durable goal.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Start when persistent continuation materially benefits current work or the user/system requests it. Skip routine one-turn tasks; get if uncertain; never replace unfinished goal; tokenBudget only if requested.\",\n\t\t\t\"Plans: task_steps. Workers: delegate. Background tools: tool_task wait once; cite taskId as kind=tool evidence.\",\n\t\t\t\"increment satisfies the current open requirement from unused evidence, or completes when none remain.\",\n\t\t\t\"complete needs current authoritative evidence, no remaining work, no linked open task_steps, no running tool_task, no active pipeline. block_goal needs same real impasse for 3 goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tconst details = result.details as GoalToolDetails | undefined;\n\t\t\treturn renderOrchestrationToolResult(theme, goalPanelModel(details), {\n\t\t\t\tisPartial,\n\t\t\t\tcollapse: !expanded && details?.applied === true,\n\t\t\t\texpanded: true,\n\t\t\t});\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t\tisError?: boolean;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tlet normalizedInput = input;\n\t\t\tif (input.action === \"start\" && deps.authorizeStart) {\n\t\t\t\tconst authority = deps.authorizeStart(input);\n\t\t\t\tif (typeof authority === \"string\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: `goal start failed: ${authority}` }],\n\t\t\t\t\t\tdetails: { action: \"start\", applied: false, error: authority },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tnormalizedInput = {\n\t\t\t\t\t...input,\n\t\t\t\t\t...(typeof authority === \"number\" ? { tokenBudget: authority } : {}),\n\t\t\t\t};\n\t\t\t\tif (authority === null) delete normalizedInput.tokenBudget;\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(normalizedInput);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst tmuxRequested = input.dispatchTarget === \"tmux\";\n\t\t\t\tlet useTmux = tmuxRequested && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tlet tmuxFallbackReason: string | undefined;\n\t\t\t\tlet dispatched: { laneId?: string; skipReason?: string } | undefined;\n\t\t\t\tif (useTmux) {\n\t\t\t\t\tdispatched = await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t\tif (\n\t\t\t\t\t\t!dispatched?.laneId &&\n\t\t\t\t\t\tallowsNativeTmuxFallback(dispatched?.skipReason) &&\n\t\t\t\t\t\tdeps.startWorkerDelegation\n\t\t\t\t\t) {\n\t\t\t\t\t\ttmuxFallbackReason = dispatched?.skipReason;\n\t\t\t\t\t\tuseTmux = false;\n\t\t\t\t\t\tdispatched = deps.startWorkerDelegation({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (tmuxRequested) tmuxFallbackReason = \"tmux_extension_not_loaded\";\n\t\t\t\t\tdispatched = deps.startWorkerDelegation?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = tmuxFallbackReason\n\t\t\t\t\t\t? `Tmux route returned ${tmuxFallbackReason}; dispatched native fallback worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: useTmux\n\t\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (native default).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `${tmuxFallbackReason ? `Tmux route returned ${tmuxFallbackReason}; ` : \"\"}No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tlet activePipeline: ReturnType<NonNullable<GoalToolDependencies[\"getActivePipeline\"]>>;\n\t\t\t\tif (\n\t\t\t\t\tcurrent &&\n\t\t\t\t\tisGoalExecutionActive(current.status) &&\n\t\t\t\t\t(action.action === \"complete\" || action.action === \"increment\")\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tactivePipeline = deps.getActivePipeline?.();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = `Cannot verify active pipeline state: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${message}` }],\n\t\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: message, state: current },\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t\topenTaskSteps: deps.getOpenTaskSteps?.(),\n\t\t\t\t\tbackgroundToolTasks: deps.getBackgroundToolTasks?.(),\n\t\t\t\t\tactivePipeline,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Build the compact Codex-compatible lifecycle surface as adapters over the authoritative legacy\n * goal executor. The wrappers own no state and duplicate no validation, persistence, accounting,\n * completion gate, or start-authority rule.\n */\nexport function createGoalLifecycleToolDefinitions(goalTool: GoalToolDefinition) {\n\tconst createGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tdescription:\n\t\t\t\"Create a durable goal when persistent autonomous continuation materially benefits the current work, or when the user/system explicitly requests one. Use agent discretion; skip routine short tasks. Set token_budget only when explicitly requested. Fails if an unfinished goal exists.\",\n\t\tpromptSnippet: \"Start durable goal.\",\n\t\tparameters: createGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof createGoalSchema>, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{\n\t\t\t\t\taction: \"start\",\n\t\t\t\t\tgoalId: `goal-${randomUUID()}`,\n\t\t\t\t\tuserGoal: input.objective,\n\t\t\t\t\ttokenBudget: input.token_budget,\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t\tcontext,\n\t\t\t);\n\t\t},\n\t};\n\n\tconst getGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tdescription:\n\t\t\t\"Get the current goal for this session, including status, budget, token and elapsed-time usage, requirements, evidence, and progress.\",\n\t\tpromptSnippet: \"Inspect durable goal.\",\n\t\tparameters: getGoalSchema,\n\t\texecute(toolCallId, _input, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(toolCallId, { action: \"get\" }, signal, onUpdate, context);\n\t\t},\n\t};\n\n\tconst updateGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tdescription:\n\t\t\t\"Update the existing goal. Set active only after concrete, verifiable progress in the current turn. Mark complete only when current evidence proves the full objective is achieved and no required work remains. Mark blocked only after the same blocking condition has recurred for at least three consecutive goal turns and no meaningful progress is possible without user input or external change; include that condition in reason. Never use blocked merely because work is hard, slow, uncertain, incomplete, or would benefit from clarification.\",\n\t\tpromptSnippet: \"Update goal; complete/block only with evidence.\",\n\t\tparameters: updateGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof updateGoalSchema>, signal, onUpdate, context) {\n\t\t\tconst requestedGoalStatus: GoalStatus = input.status === \"complete\" ? \"completed\" : input.status;\n\t\t\tconst action: GoalToolInput = isGoalExecutionActive(requestedGoalStatus)\n\t\t\t\t? { action: \"progress\" }\n\t\t\t\t: input.status === \"complete\"\n\t\t\t\t\t? { action: \"complete\" }\n\t\t\t\t\t: { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\t\treturn goalTool.execute(toolCallId, action, signal, onUpdate, context);\n\t\t},\n\t};\n\n\treturn [createGoal, getGoal, updateGoal] as const;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"secret-store.d.ts","sourceRoot":"","sources":["../../../src/core/tools/secret-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAE7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEN,KAAK,iCAAiC,EAEtC,MAAM,2CAA2C,CAAC;AAKnD,OAAO,EAEN,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EAExC,MAAM,2CAA2C,CAAC;AA8BnD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;EAmCtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAC1B,WAAW,GACX,WAAW,GACX,WAAW,GACX,YAAY,GACZ,OAAO,GACP,QAAQ,GACR,UAAU,GACV,aAAa,CAAC;AAEjB,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,MAA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