@ashx-j/lunr 0.2.15 → 0.2.17

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 (39) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
  3. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +6 -2
  4. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
  5. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  6. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +6 -2
  7. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  8. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts +10 -0
  9. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts.map +1 -0
  10. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js +38 -0
  11. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js.map +1 -0
  12. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  13. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +3 -16
  14. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  15. package/dist/core/agent-session.d.ts +3 -0
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +50 -4
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/compaction/compaction.d.ts.map +1 -1
  20. package/dist/core/compaction/compaction.js +10 -5
  21. package/dist/core/compaction/compaction.js.map +1 -1
  22. package/dist/core/extensions/types.d.ts +2 -2
  23. package/dist/core/extensions/types.d.ts.map +1 -1
  24. package/dist/core/extensions/types.js.map +1 -1
  25. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  26. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  27. package/dist/modes/interactive/interactive-mode.js +19 -4
  28. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  29. package/docs/compaction.md +5 -3
  30. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  31. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  32. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  33. package/examples/extensions/gondolin/package-lock.json +2 -2
  34. package/examples/extensions/gondolin/package.json +1 -1
  35. package/examples/extensions/sandbox/package-lock.json +2 -2
  36. package/examples/extensions/sandbox/package.json +1 -1
  37. package/examples/extensions/with-deps/package-lock.json +2 -2
  38. package/examples/extensions/with-deps/package.json +1 -1
  39. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../../src/builtin-extensions/narumiruna-pi-goal/src/goal.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,iFAA+E;AAC/E,sEAAsE;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAmB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAEN,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EACzB,WAAW,EACX,YAAY,EACZ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AAC;YACzB,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,iCAAiC,OAAO,iCAAiC,EACzE,SAAS,CACT,CAAC;YACF,OAAO;QACR,CAAC;QACD,IAAI,MAAM,KAAK,eAAe,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,8BAA8B,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACtH,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,qBAAqB,OAAO,IAAI,IAAI,mHAAmH,EACvJ,SAAS,CACT,CAAC;YACF,OAAO;QACR,CAAC;QACD,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,iCAAiC,OAAO,qDAAqD,EAC7F,SAAS,CACT,CAAC;IAAA,CACF;AAAA,CACD;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAgB,EAAE,OAAO,GAAgB,EAAE,EAAE;IACzE,mBAAmB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAAA,CACjC;AAED,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,cAAc,EACd,gBAAgB,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EACN,yBAAyB,EACzB,YAAY,EACZ,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,GAC9B,MAAM,cAAc,CAAC","sourcesContent":["// @ts-nocheck\n// lunr: defineTool imported from the concrete module, NOT the package barrel —\n// the barrel re-exports main.ts which imports this extension (cycle).\nimport { defineTool } from \"../../../core/extensions/types.js\";\nimport { isCronFire } from \"../../../core/cron/fire-guard.js\";\nimport type { ExtensionAPI } from \"@ashx-j/lunr\";\nimport { Type } from \"typebox\";\nimport { Container, Markdown, Text } from \"@ashx-j/lunr-tui\";\nimport { currentTokenTotal } from \"./accounting.js\";\nimport { completeGoalArguments, parseCommand } from \"./command.js\";\nimport { GoalCommandController } from \"./commands.js\";\nimport { type ActiveGoal, loadGoalStateFromSession } from \"./persistence.js\";\nimport { buildGoalPrompt, buildGoalSystemPrompt } from \"./prompts.js\";\nimport { activateQueuedGoal } from \"./queue.js\";\nimport {\n\ttype AssistantMessageLike,\n\tabortCurrentTurn,\n\tblocksStaleGoalToolCalls,\n\tfindFinalAssistantMessage,\n\tformatError,\n\tformatStatus,\n\tGOAL_BLOCKED_TOOL,\n\tGOAL_COMPLETE_TOOL,\n\tGoalRuntime,\n\tgoalIdRejectionReason,\n\tincrementGoal,\n\tisContradictoryCompletionSummary,\n\tisGoalContextOverflow,\n\tisRetryableGoalInterruption,\n\tisUsageLimitedGoalInterruption,\n\tparseUsageResetTimeMs,\n\tSTATUS_KEY,\n\ttype StatusContext,\n\ttransitionGoal,\n\ttruncateNotification,\n} from \"./runtime.js\";\nimport { DEFAULT_GOAL_SETTINGS, readGoalSettings } from \"./settings.js\";\n\n// goal.ts is the Pi-facing composition root: it keeps tool contracts and event\n// ordering together. Per-session mechanisms live in runtime.ts, while user command\n// transitions live in commands.ts. Each factory constructs isolated instances.\n\ninterface GoalCompleteDetails {\n\tgoal: string;\n\tgoal_id: string;\n\tsummary: string;\n}\n\ninterface GoalBlockedDetails {\n\tgoal: string;\n\tgoal_id: string;\n\treason: string;\n\tevidence: string;\n\trepeated_turns: number;\n}\n\ninterface GoalOptions {\n\tsettingsPath?: string;\n}\n\nconst GOAL_COMPLETE_MESSAGE_TYPE = \"goal-complete\";\nconst EXPERIMENTAL_GOALS_WARNING =\n\t\"Experimental ordered goals are enabled for pi-goal. Queue behavior and persisted state may change.\";\nconst MAX_BLOCKER_REASON_LENGTH = 1_000;\nconst MAX_BLOCKER_EVIDENCE_LENGTH = 4_000;\n\nfunction registerGoalRuntime(pi: ExtensionAPI, options: GoalOptions = {}) {\n\tconst runtime = new GoalRuntime(pi);\n\tconst commands = new GoalCommandController(runtime);\n\n\t// Bind per-factory runtime operations once so event orchestration stays concise\n\t// without reintroducing module-global mutable state.\n\tconst clearCompletionStatusTimer = runtime.clearCompletionStatusTimer.bind(runtime);\n\t// lunr: footer refresh timer cleanup\n\tconst clearStatusRefreshTimer = runtime.clearStatusRefreshTimer.bind(runtime);\n\tconst clearContinuationTracking = runtime.clearContinuationTracking.bind(runtime);\n\tconst clearPendingGoalPrompts = runtime.clearPendingGoalPrompts.bind(runtime);\n\tconst clearGoalRecovery = runtime.clearGoalRecovery.bind(runtime);\n\tconst clearBudgetWrapUp = runtime.clearBudgetWrapUp.bind(runtime);\n\tconst clearStaleGoalToolCallBlock = runtime.clearStaleGoalToolCallBlock.bind(runtime);\n\tconst persistGoal = runtime.persistGoal.bind(runtime);\n\tconst updateGoalUsage = runtime.recordGoalUsage.bind(runtime);\n\tconst updateStatus = runtime.updateStatus.bind(runtime);\n\tconst limitActiveGoalForBudget = runtime.limitActiveGoalForBudget.bind(runtime);\n\tconst hideGoalToolsIfLocked = runtime.hideGoalToolsIfLocked.bind(runtime);\n\tconst goalToolsAvailable = runtime.goalToolsAvailable.bind(runtime);\n\tconst pauseGoalForUnavailableTools = runtime.pauseGoalForUnavailableTools.bind(runtime);\n\tconst isPiOwnedCompactionRetry = runtime.isPiOwnedCompactionRetry.bind(runtime);\n\tconst requestContinuation = runtime.requestContinuation.bind(runtime);\n\tconst dispatchContinuationIfSettled = runtime.dispatchContinuationIfSettled.bind(runtime);\n\tconst isGoalToolName = runtime.isGoalToolName.bind(runtime);\n\tconst queueBudgetWrapUp = runtime.queueBudgetWrapUp.bind(runtime);\n\tconst clearGoalRecoveryForGoal = runtime.clearGoalRecoveryForGoal.bind(runtime);\n\tconst blockStaleGoalToolCalls = runtime.blockStaleGoalToolCalls.bind(runtime);\n\tconst cancelContinuationWork = runtime.cancelContinuationWork.bind(runtime);\n\tconst consumeCancelledContinuationPrompt =\n\t\truntime.consumeCancelledContinuationPrompt.bind(runtime);\n\tconst consumeStaleOwnedGoalPrompt = runtime.consumeStaleOwnedGoalPrompt.bind(runtime);\n\tconst consumePendingGoalPrompt = runtime.consumeOwnedGoalPrompt.bind(runtime);\n\tconst markContinuationStarted = runtime.markContinuationStarted.bind(runtime);\n\tconst hasContinuationWorkForGoal = runtime.hasContinuationWorkForGoal.bind(runtime);\n\tconst clearActiveGoal = runtime.clearActiveGoal.bind(runtime);\n\tconst showCompletionStatus = runtime.showCompletionStatus.bind(runtime);\n\tconst restoreGoalToolsHiddenByPolicy = runtime.restoreGoalToolsHiddenByPolicy.bind(runtime);\n\tconst sendOwnedGoalPrompt = (\n\t\t_pi: ExtensionAPI,\n\t\tctx: StatusContext,\n\t\tgoalId: string,\n\t\tprompt: string,\n\t) => runtime.sendOwnedGoalPrompt(ctx, goalId, prompt);\n\tconst dispatchPendingQueueActionIfSettled =\n\t\tcommands.dispatchPendingQueueActionIfSettled.bind(commands);\n\n\tconst emitGoalCompleteMessage = (summary: string) => {\n\t\tconst text = summary.startsWith(\"Goal complete\") ? summary : summary;\n\t\tpi.sendMessage({\n\t\t\tcustomType: GOAL_COMPLETE_MESSAGE_TYPE,\n\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\tdisplay: true,\n\t\t});\n\t};\n\n\tpi.registerMessageRenderer(GOAL_COMPLETE_MESSAGE_TYPE, (message, _options, theme) => {\n\t\tconst raw =\n\t\t\ttypeof message.content === \"string\"\n\t\t\t\t? message.content\n\t\t\t\t: message.content\n\t\t\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t\t\t.map((block) => (\"text\" in block ? block.text : \"\"))\n\t\t\t\t\t\t.join(\"\\n\");\n\t\tconst c = new Container();\n\t\tc.addChild(new Markdown(`● ${raw}`, 1, 0, undefined, {\n\t\t\tcolor: (content) => theme.fg(\"text\", content),\n\t\t}));\n\t\treturn c;\n\t});\n\n\tconst goalCompleteTool = defineTool({\n\t\tname: GOAL_COMPLETE_TOOL,\n\t\tlabel: \"Goal Complete\",\n\t\tdescription:\n\t\t\t\"Mark the active /goal as complete after all required work is done and verified, using the current goal_id stale-turn guard. Do not use for partial progress, blockers, failing, or unverified work.\",\n\t\tpromptSnippet:\n\t\t\t\"Mark the active /goal as complete after fully finishing and verifying it, with the current goal_id\",\n\t\tpromptGuidelines: [\n\t\t\t\"When a /goal is active, keep working until the goal is complete; do not stop with only a plan or partial progress.\",\n\t\t\t\"Before calling goal_complete, audit the active goal requirement by requirement against the current files, command output, tests, or external state.\",\n\t\t\t\"Pass the exact goal_id shown in the current /goal prompt; never reuse a goal_id from an older, stopped, replaced, or cleared turn.\",\n\t\t\t\"Call goal_complete only after the requested goal is fully implemented, verified, and no known required work remains; otherwise keep working.\",\n\t\t],\n\t\tparameters: Type.Object({\n\t\t\tgoal_id: Type.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"The exact goal_id shown in the current active /goal prompt. Used only to reject stale completion calls from older turns.\",\n\t\t\t}),\n\t\t\tsummary: Type.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"State what was completed and what evidence verified it. Do not use this tool to report partial progress, blockers, failures, or remaining work.\",\n\t\t\t}),\n\t\t}),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst completedGoal = runtime.activeGoal;\n\t\t\tconst goal = completedGoal?.text ?? \"unknown goal\";\n\t\t\tconst requestedGoalId = typeof params.goal_id === \"string\" ? params.goal_id.trim() : \"\";\n\t\t\tconst summary = typeof params.summary === \"string\" ? params.summary.trim() : \"\";\n\n\t\t\tif (!completedGoal) {\n\t\t\t\tconst rejection = \"Goal completion rejected: no active goal.\";\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst completingDuringBudgetWrapUp = runtime.hasActiveBudgetWrapUp();\n\t\t\tif (!runtime.canRecordGoalUsage() && !completingDuringBudgetWrapUp) {\n\t\t\t\tconst rejection = \"Goal completion rejected: current run does not own the active goal.\";\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (hasPendingSkipForGoal(completedGoal.id)) {\n\t\t\t\tupdateGoalUsage(completedGoal, ctx);\n\t\t\t\tpersistGoal(completedGoal);\n\t\t\t\tupdateStatus(ctx, completedGoal);\n\t\t\t\tclearBudgetWrapUp();\n\t\t\t\tconst rejection = \"Goal completion rejected: goal is queued to be skipped.\";\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst staleGoalRejection = goalIdRejectionReason(completedGoal, requestedGoalId);\n\t\t\tif (staleGoalRejection) {\n\t\t\t\tconst rejection = `Goal completion rejected: ${staleGoalRejection}.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\tif (completingDuringBudgetWrapUp) {\n\t\t\t\t\tupdateGoalUsage(completedGoal, ctx);\n\t\t\t\t\tpersistGoal(completedGoal);\n\t\t\t\t\tupdateStatus(ctx, completedGoal);\n\t\t\t\t\tclearBudgetWrapUp();\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: completingDuringBudgetWrapUp || undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (completedGoal.status !== \"active\" && !completingDuringBudgetWrapUp) {\n\t\t\t\tconst rejection = `Goal completion rejected: goal is ${completedGoal.status}, not active.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rejectionReason = !summary\n\t\t\t\t? \"summary is empty\"\n\t\t\t\t: isContradictoryCompletionSummary(summary)\n\t\t\t\t\t? \"summary says the goal is not complete\"\n\t\t\t\t\t: undefined;\n\t\t\tif (rejectionReason) {\n\t\t\t\tupdateGoalUsage(completedGoal, ctx);\n\t\t\t\tpersistGoal(completedGoal);\n\t\t\t\tupdateStatus(ctx, completedGoal);\n\t\t\t\tconst rejection = `Goal completion rejected: ${rejectionReason}.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\tif (completingDuringBudgetWrapUp) clearBudgetWrapUp();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: rejection,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: completingDuringBudgetWrapUp || undefined,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\truntime.activeGoal = transitionGoal(completedGoal, \"complete\");\n\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\tif (runtime.pendingQueueAction?.kind === \"prioritize\") {\n\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\tctx.ui.setStatus(STATUS_KEY, \"complete\");\n\t\t\t\temitGoalCompleteMessage(summary);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Goal complete: ${summary}` }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tgoal,\n\t\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t} satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (runtime.queuedGoals.length > 0) {\n\t\t\t\truntime.pendingQueueAction = {\n\t\t\t\t\tkind: \"advance\",\n\t\t\t\t\tgoalId: runtime.activeGoal.id,\n\t\t\t\t\treason: \"complete\",\n\t\t\t\t\tcompletedText: goal,\n\t\t\t\t};\n\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\tctx.ui.setStatus(STATUS_KEY, \"complete\");\n\t\t\t\temitGoalCompleteMessage(summary);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Goal complete: ${summary}\\nNext goal queued: ${runtime.queuedGoals[0]?.text}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tgoal,\n\t\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t} satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tpersistGoal(runtime.activeGoal);\n\n\t\t\tctx.ui.setStatus(STATUS_KEY, formatStatus(runtime.activeGoal));\n\t\t\tclearActiveGoal(ctx);\n\t\t\tshowCompletionStatus(ctx);\n\t\t\temitGoalCompleteMessage(summary);\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `Goal complete: ${summary}` }],\n\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\tterminate: true,\n\t\t\t};\n\t\t},\n\t\trenderResult(_result, { isPartial }, theme) {\n\t\t\tif (isPartial) return new Text(theme.fg(\"warning\", \"Completing goal...\"), 0, 0);\n\t\t\treturn { render: () => [], invalidate() {} };\n\t\t},\n\t});\n\n\tconst goalBlockedTool = defineTool({\n\t\tname: GOAL_BLOCKED_TOOL,\n\t\tlabel: \"Goal Blocked\",\n\t\tdescription:\n\t\t\t\"Stop the active /goal only at a true impasse after the same blocker recurs for at least three consecutive goal turns, with the current goal_id and concrete evidence that user or external action is required. Do not use for ordinary clarification, uncertainty, or recoverable failures.\",\n\t\tpromptSnippet:\n\t\t\t\"Mark the active /goal blocked only after the same blocker recurs for three consecutive goal turns\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use goal_blocked only for a true impasse after the same blocker recurs for at least three consecutive goal turns and concrete evidence shows user or external action is required.\",\n\t\t\t\"After a blocked goal is resumed, start a fresh three-turn blocker audit before using goal_blocked again.\",\n\t\t\t\"Do not use goal_blocked for ordinary clarification, incomplete work, uncertainty, difficult tasks, or recoverable tool/provider failures.\",\n\t\t\t\"Pass goal_blocked the exact current goal_id; never reuse a goal_id from an older, stopped, replaced, or cleared goal turn.\",\n\t\t],\n\t\tparameters: Type.Object({\n\t\t\tgoal_id: Type.String({\n\t\t\t\tdescription: \"The exact goal_id shown in the current active /goal prompt.\",\n\t\t\t}),\n\t\t\treason: Type.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_BLOCKER_REASON_LENGTH,\n\t\t\t\tdescription: \"The specific user or external action required to unblock the goal.\",\n\t\t\t}),\n\t\t\tevidence: Type.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_BLOCKER_EVIDENCE_LENGTH,\n\t\t\t\tdescription: \"Concrete evidence from the repeated attempts that proves the impasse.\",\n\t\t\t}),\n\t\t\trepeated_turns: Type.Integer({\n\t\t\t\tminimum: 3,\n\t\t\t\tdescription: \"Number of separate turns spent trying to resolve this same blocker.\",\n\t\t\t}),\n\t\t}),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst blockedGoal = runtime.activeGoal;\n\t\t\tconst goal = blockedGoal?.text ?? \"unknown goal\";\n\t\t\tconst requestedGoalId = typeof params.goal_id === \"string\" ? params.goal_id.trim() : \"\";\n\t\t\tconst reason = typeof params.reason === \"string\" ? params.reason.trim() : \"\";\n\t\t\tconst evidence = typeof params.evidence === \"string\" ? params.evidence.trim() : \"\";\n\t\t\tconst repeatedTurns =\n\t\t\t\ttypeof params.repeated_turns === \"number\" ? params.repeated_turns : Number.NaN;\n\t\t\tconst reject = (rejectionReason: string, terminate = false) => {\n\t\t\t\tconst rejection = `goal_blocked rejected: ${rejectionReason}.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: rejection }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tgoal,\n\t\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\t\treason: reason.slice(0, MAX_BLOCKER_REASON_LENGTH),\n\t\t\t\t\t\tevidence: evidence.slice(0, MAX_BLOCKER_EVIDENCE_LENGTH),\n\t\t\t\t\t\trepeated_turns: Number.isFinite(repeatedTurns) ? repeatedTurns : 0,\n\t\t\t\t\t} satisfies GoalBlockedDetails,\n\t\t\t\t\t...(terminate ? { terminate: true as const } : {}),\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tif (!blockedGoal) return reject(\"no active goal\");\n\t\t\tif (!runtime.canRecordGoalUsage()) {\n\t\t\t\treturn reject(\"current run does not own the active goal\");\n\t\t\t}\n\t\t\tif (hasPendingSkipForGoal(blockedGoal.id)) {\n\t\t\t\tupdateGoalUsage(blockedGoal, ctx);\n\t\t\t\tpersistGoal(blockedGoal);\n\t\t\t\tupdateStatus(ctx, blockedGoal);\n\t\t\t\tclearBudgetWrapUp();\n\t\t\t\treturn reject(\"goal is queued to be skipped\", true);\n\t\t\t}\n\t\t\tconst staleGoalRejection = goalIdRejectionReason(blockedGoal, requestedGoalId);\n\t\t\tif (staleGoalRejection) return reject(staleGoalRejection);\n\t\t\tif (blockedGoal.status !== \"active\") {\n\t\t\t\treturn reject(`goal is ${blockedGoal.status}, not active`);\n\t\t\t}\n\t\t\tif (!reason) return reject(\"reason is empty\");\n\t\t\tif (reason.length > MAX_BLOCKER_REASON_LENGTH) return reject(\"reason is too long\");\n\t\t\tif (!evidence) return reject(\"evidence is empty\");\n\t\t\tif (evidence.length > MAX_BLOCKER_EVIDENCE_LENGTH) return reject(\"evidence is too long\");\n\t\t\tif (!Number.isInteger(repeatedTurns)) return reject(\"repeated_turns must be a whole number\");\n\t\t\tif (repeatedTurns < 3) return reject(\"repeated_turns must be at least 3\");\n\n\t\t\tupdateGoalUsage(blockedGoal, ctx);\n\t\t\tcancelContinuationWork();\n\t\t\tclearBudgetWrapUp();\n\t\t\tclearGoalRecoveryForGoal(blockedGoal.id);\n\t\t\tblockStaleGoalToolCalls();\n\t\t\truntime.activeGoal = transitionGoal(blockedGoal, \"blocked\");\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\tctx.ui.notify(`Goal blocked: ${truncateNotification(reason)}`, \"warning\");\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `Goal blocked: ${reason}` }],\n\t\t\t\tdetails: {\n\t\t\t\t\tgoal,\n\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\treason,\n\t\t\t\t\tevidence,\n\t\t\t\t\trepeated_turns: repeatedTurns,\n\t\t\t\t} satisfies GoalBlockedDetails,\n\t\t\t\tterminate: true,\n\t\t\t};\n\t\t},\n\t});\n\n\tpi.registerTool(goalCompleteTool);\n\tpi.registerTool(goalBlockedTool);\n\t// Do not touch the active tool set during factory registration: ExtensionAPI\n\t// actions are unbound until the session binds the runtime. session_start applies\n\t// baseline visibility once actions work; later hooks only enforce goal safety.\n\n\tpi.registerCommand(\"goal\", {\n\t\tdescription: \"Run a goal to completion: /goal [--tokens 100k] <goal_to_complete>\",\n\t\tgetArgumentCompletions: (prefix) =>\n\t\t\tcompleteGoalArguments(prefix, {\n\t\t\t\texperimentalGoals: runtime.settings.experimental.goals,\n\t\t\t}),\n\t\thandler: async (args, ctx) => {\n\t\t\tconst result = parseCommand(args, {\n\t\t\t\texperimentalGoals: runtime.settings.experimental.goals,\n\t\t\t});\n\t\t\tif (typeof result === \"string\") {\n\t\t\t\tctx.ui.notify(result, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (runtime.queueFrozen) {\n\t\t\t\tif (result.kind === \"show\") commands.showGoal(ctx);\n\t\t\t\telse if (result.kind === \"clear\") commands.clearGoal(ctx);\n\t\t\t\telse commands.notifyFrozenQueue(ctx);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (runtime.pendingQueueAction && result.kind !== \"show\" && result.kind !== \"clear\") {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\"A queued goal change is waiting for Pi to settle. Retry after it finishes.\",\n\t\t\t\t\t\"warning\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tswitch (result.kind) {\n\t\t\t\tcase \"show\":\n\t\t\t\t\tcommands.showGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"pause\":\n\t\t\t\t\tcommands.pauseGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"resume\":\n\t\t\t\t\tawait commands.resumeGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"clear\":\n\t\t\t\t\tcommands.clearGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"edit\":\n\t\t\t\t\tawait commands.editGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"add\":\n\t\t\t\t\tawait commands.addGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"prioritize\":\n\t\t\t\t\tawait commands.prioritizeGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"drop-last\":\n\t\t\t\t\tcommands.dropLastGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"skip\":\n\t\t\t\t\tawait commands.skipGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"start\":\n\t\t\t\t\tawait commands.startGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tclearCompletionStatusTimer();\n\t\tclearStatusRefreshTimer(); // lunr\n\t\tclearContinuationTracking();\n\t\tclearPendingGoalPrompts();\n\t\truntime.agentRunGoalId = undefined;\n\t\tclearGoalRecovery();\n\t\tclearBudgetWrapUp();\n\t\tclearStaleGoalToolCallBlock();\n\t\truntime.queuedGoals = [];\n\t\truntime.pendingQueueAction = undefined;\n\t\truntime.queueFrozen = false;\n\t\tconst previousToolVisibility = runtime.settings.toolVisibility;\n\t\tconst settingsResult = readGoalSettings(options.settingsPath);\n\t\truntime.settings =\n\t\t\tsettingsResult.kind === \"loaded\" ? settingsResult.settings : DEFAULT_GOAL_SETTINGS;\n\t\tif (settingsResult.kind === \"invalid\") {\n\t\t\tctx.ui.notify(\n\t\t\t\t`pi-goal settings ignored: ${settingsResult.reason}. Using default settings.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t}\n\t\tif (runtime.settings.experimental.goals) {\n\t\t\tctx.ui.notify(EXPERIMENTAL_GOALS_WARNING, \"warning\");\n\t\t}\n\t\tif (\n\t\t\truntime.settings.toolVisibility === \"after-first-goal\" &&\n\t\t\tpreviousToolVisibility === \"always\"\n\t\t) {\n\t\t\truntime.goalToolsUnlocked = false;\n\t\t}\n\t\tif (runtime.settings.toolVisibility === \"always\") {\n\t\t\tif (runtime.goalToolsHiddenByPolicy.size > 0) {\n\t\t\t\ttry {\n\t\t\t\t\trestoreGoalToolsHiddenByPolicy();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t`Could not restore always-visible goal tools: ${formatError(error)}`,\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\truntime.goalToolsUnlocked = true;\n\t\t}\n\n\t\tconst loaded = loadGoalStateFromSession(ctx);\n\t\truntime.activeGoal = loaded.goal;\n\t\truntime.queuedGoals = loaded.queue;\n\t\truntime.pendingQueueAction = loaded.pendingAction;\n\t\truntime.queueFrozen = loaded.hasExperimentalQueueState && !runtime.settings.experimental.goals;\n\t\tif (runtime.queueFrozen) {\n\t\t\tif (runtime.activeGoal) persistGoal(runtime.activeGoal);\n\t\t\tctx.ui.setStatus(STATUS_KEY, \"queue off\");\n\t\t\tctx.ui.notify(\n\t\t\t\t\"An experimental goal queue is frozen because experimental.goals is disabled. Re-enable it and run /reload to continue, or use /goal clear.\",\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tlet startRestoredQueuedGoal = false;\n\t\tif (runtime.activeGoal?.status === \"queued\" && !runtime.pendingQueueAction) {\n\t\t\truntime.activeGoal = activateQueuedGoal(runtime.activeGoal, currentTokenTotal(ctx));\n\t\t\tstartRestoredQueuedGoal = runtime.activeGoal.status === \"active\";\n\t\t}\n\t\tif (runtime.pendingQueueAction) await dispatchPendingQueueActionIfSettled(ctx);\n\t\tif (runtime.activeGoal) {\n\t\t\tif (runtime.activeGoal.status === \"active\") {\n\t\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\t\t\t}\n\t\t\tif (runtime.settings.toolVisibility === \"after-first-goal\") {\n\t\t\t\t// Registered tools are already active on an unrestricted fresh runtime.\n\t\t\t\t// If an earlier session_start handler removed them, that restrictive\n\t\t\t\t// policy wins: mark lazy visibility unlocked without widening its set.\n\t\t\t\truntime.goalToolsUnlocked = true;\n\t\t\t\truntime.goalToolsHiddenByPolicy.clear();\n\t\t\t}\n\t\t\tif (runtime.activeGoal.status === \"active\" && !goalToolsAvailable()) {\n\t\t\t\tpauseGoalForUnavailableTools(ctx, false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\tif (startRestoredQueuedGoal) {\n\t\t\t\tconst restoredGoal = runtime.activeGoal;\n\t\t\t\tconst sent = await sendOwnedGoalPrompt(\n\t\t\t\t\truntime.pi,\n\t\t\t\t\tctx,\n\t\t\t\t\trestoredGoal.id,\n\t\t\t\t\tbuildGoalPrompt(restoredGoal),\n\t\t\t\t);\n\t\t\t\tif (!sent && runtime.activeGoal?.id === restoredGoal.id) {\n\t\t\t\t\truntime.activeGoal = transitionGoal(restoredGoal, \"paused\");\n\t\t\t\t\tblockStaleGoalToolCalls();\n\t\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (runtime.settings.toolVisibility === \"after-first-goal\" && !runtime.goalToolsUnlocked) {\n\t\t\t\thideGoalToolsIfLocked();\n\t\t\t}\n\t\t\tctx.ui.setStatus(STATUS_KEY, undefined);\n\t\t}\n\t});\n\n\tpi.on(\"session_shutdown\", (_event, ctx) => {\n\t\tif (runtime.activeGoal) {\n\t\t\tif (!runtime.queueFrozen && runtime.activeGoal.status === \"active\") {\n\t\t\t\tupdateGoalUsage(runtime.activeGoal, ctx, false);\n\t\t\t}\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t}\n\t\tclearContinuationTracking();\n\t\tclearPendingGoalPrompts();\n\t\truntime.agentRunGoalId = undefined;\n\t\tclearGoalRecovery();\n\t\tclearBudgetWrapUp();\n\t\tclearStaleGoalToolCallBlock();\n\t\truntime.activeGoal = undefined;\n\t\truntime.queuedGoals = [];\n\t\truntime.pendingQueueAction = undefined;\n\t\truntime.queueFrozen = false;\n\t\tctx.ui.setStatus(STATUS_KEY, undefined);\n\t\tclearCompletionStatusTimer();\n\t\tclearStatusRefreshTimer(); // lunr\n\t});\n\n\tpi.on(\"session_before_compact\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (runtime.activeGoal?.status === \"budget_limited\") {\n\t\t\tif ((event as { willRetry?: boolean }).willRetry === true) return { cancel: true as const };\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal?.status !== \"active\") return;\n\t\tif (!updateGoalUsage(runtime.activeGoal, ctx)) return;\n\t\tcancelContinuationWork();\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\tif (runtime.pendingQueueAction) return;\n\t\tif (limitActiveGoalForBudget(ctx, false)) return { cancel: true as const };\n\t});\n\n\tpi.on(\"session_compact\", async (event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (runtime.activeGoal?.status !== \"active\") {\n\t\t\tclearGoalRecovery();\n\t\t\tif (runtime.pendingQueueAction) await dispatchPendingQueueActionIfSettled(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tconst restoredState = loadGoalStateFromSession(ctx);\n\t\tif (restoredState.goal?.id === runtime.activeGoal.id) {\n\t\t\truntime.activeGoal = restoredState.goal;\n\t\t\truntime.queuedGoals = restoredState.queue;\n\t\t\truntime.pendingQueueAction = restoredState.pendingAction;\n\t\t}\n\t\tconst usageRecorded = updateGoalUsage(runtime.activeGoal, ctx);\n\t\tif (usageRecorded) {\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t}\n\t\tif (runtime.pendingQueueAction) {\n\t\t\tawait dispatchPendingQueueActionIfSettled(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (!usageRecorded) return;\n\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\n\t\tconst wasPiRetry = isPiOwnedCompactionRetry(event, runtime.activeGoal.id);\n\t\tclearGoalRecoveryForGoal(runtime.activeGoal.id);\n\t\tif (wasPiRetry) return;\n\t\trequestContinuation(runtime.activeGoal);\n\t\t// Manual compaction does not emit agent_settled. This common dispatcher is\n\t\t// therefore the narrow fallback; threshold compaction leaves the intent for\n\t\t// agent_settled when Pi is still busy.\n\t\tdispatchContinuationIfSettled(ctx);\n\t});\n\n\tpi.on(\"input\", (event) => {\n\t\tif (event.source === \"extension\") {\n\t\t\tif (\n\t\t\t\tconsumeCancelledContinuationPrompt(event.text) ||\n\t\t\t\tconsumeStaleOwnedGoalPrompt(event.text)\n\t\t\t) {\n\t\t\t\treturn { action: \"handled\" as const };\n\t\t\t}\n\t\t\tif (runtime.queueFrozen) return;\n\t\t\tclearGoalRecovery();\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.queueFrozen) return;\n\t\tif (/^\\/goal(?:\\s|$)/u.test(event.text.trimStart())) return;\n\t\tclearGoalRecovery();\n\t\tclearBudgetWrapUp();\n\t\tclearStaleGoalToolCallBlock();\n\t});\n\n\t// lunr: the previous context-event filter dropped superseded budget\n\t// wrap-up messages from request context. That breaks Anthropic prefix\n\t// continuity (full cache miss from the cut). The wrap-up custom message\n\t// is small; keeping history unfiltered is cheaper than a cache rewrite.\n\t// keepBudgetWrapUpMessage remains on the runtime if a future token-saving\n\t// path can prove the wrap-up was never sent.\n\n\tpi.on(\"tool_call\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) {\n\t\t\tif (!isGoalToolName(event.toolName)) return;\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason:\n\t\t\t\t\t\"The experimental goal queue is frozen. Re-enable experimental.goals and run /reload, or use /goal clear.\",\n\t\t\t};\n\t\t}\n\t\t// lunr: mask locked goal tools instead of removing them from the active\n\t\t// list (setActiveTools churn busts the tools+system cache prefix).\n\t\tif (isGoalToolName(event.toolName) && runtime.areGoalToolsLocked()) {\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: \"Goal tools are locked until a /goal is activated.\",\n\t\t\t};\n\t\t}\n\t\tif (\n\t\t\truntime.activeGoal?.status === \"budget_limited\" &&\n\t\t\truntime.budgetWrapUp?.goalId === runtime.activeGoal.id &&\n\t\t\tevent.toolName !== \"goal_complete\"\n\t\t) {\n\t\t\t// A blocked tool result would normally trigger another model call. Abort the\n\t\t\t// wrap-up instead so a tool-seeking model cannot create an unbounded loop.\n\t\t\tabortCurrentTurn(ctx);\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: \"Goal token budget is exhausted; only goal_complete is allowed during wrap-up.\",\n\t\t\t};\n\t\t}\n\t\tif (!runtime.staleGoalToolCallsBlocked) return;\n\t\tif (!runtime.activeGoal || !blocksStaleGoalToolCalls(runtime.activeGoal.status)) {\n\t\t\tclearStaleGoalToolCallBlock();\n\t\t\treturn;\n\t\t}\n\t\treturn {\n\t\t\tblock: true,\n\t\t\treason: \"Blocked stale /goal tool call after the goal stopped or was interrupted.\",\n\t\t};\n\t});\n\n\tpi.on(\"tool_execution_end\", (_event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (\n\t\t\truntime.activeGoal?.status === \"budget_limited\" &&\n\t\t\truntime.budgetWrapUp?.goalId === runtime.activeGoal.id &&\n\t\t\t!runtime.budgetWrapUp.delivered\n\t\t) {\n\t\t\tqueueBudgetWrapUp(ctx, runtime.activeGoal);\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal?.status !== \"active\") return;\n\n\t\t// AgentSession persists assistant message_end before tool execution events,\n\t\t// so the completed assistant call's usage is authoritative at this boundary.\n\t\tif (!updateGoalUsage(runtime.activeGoal, ctx)) return;\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\tif (limitActiveGoalForBudget(ctx, true)) return;\n\t\tif (!goalToolsAvailable()) pauseGoalForUnavailableTools(ctx);\n\t});\n\n\tpi.on(\"before_agent_start\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) {\n\t\t\truntime.agentRunGoalId = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst goalPromptGoalId = consumePendingGoalPrompt(event.prompt);\n\t\tconst continuationGoalId = goalPromptGoalId ? undefined : markContinuationStarted(event.prompt);\n\t\tconst ownedPromptGoalId = goalPromptGoalId ?? continuationGoalId;\n\t\tconst activeBudgetWrapUp = runtime.hasActiveBudgetWrapUp();\n\t\tconst activeGoalRecovery = runtime.hasActiveGoalRecovery();\n\t\t// lunr: auto-resume a usage_limited goal on a wake-up turn. Two triggers:\n\t\t// - resumeAfter was parsed from the provider error and has elapsed (any turn\n\t\t// resumes — the reset time is known, so the goal should not stay parked);\n\t\t// - no reset time was parseable: only a cron-fired turn resumes (the user\n\t\t// scheduled the wake-up explicitly; ordinary manual turns don't hijack —\n\t\t// /goal resume stays the manual path).\n\t\t// Gateway cron fires are headless and cannot see this session's goal.\n\t\tconst resumeAfter = runtime.activeGoal?.resumeAfter;\n\t\tconst resumeDue = resumeAfter !== undefined && Date.now() >= resumeAfter;\n\t\tconst cronWakeUp = resumeAfter === undefined && isCronFire();\n\t\tif (\n\t\t\truntime.activeGoal?.status === \"usage_limited\" &&\n\t\t\t(resumeDue || cronWakeUp) &&\n\t\t\t!ownedPromptGoalId &&\n\t\t\t!activeBudgetWrapUp &&\n\t\t\t!activeGoalRecovery\n\t\t) {\n\t\t\tconst resumed = runtime.reactivateGoalForResume(ctx);\n\t\t\tif (resumed) {\n\t\t\t\truntime.agentRunGoalId = resumed.id;\n\t\t\t\tif (!goalToolsAvailable()) {\n\t\t\t\t\tpauseGoalForUnavailableTools(ctx, false);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsystemPrompt: event.systemPrompt + \"\\n\\n\" + buildGoalSystemPrompt(runtime.activeGoal),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\truntime.pendingQueueAction?.kind === \"prioritize\" &&\n\t\t\t!activeBudgetWrapUp &&\n\t\t\t!activeGoalRecovery\n\t\t) {\n\t\t\t// A turn that starts after priority intent is committed belongs to neither\n\t\t\t// the displaced goal nor the not-yet-activated urgent goal. Persist the\n\t\t\t// displaced goal's final accounting boundary so reload cannot absorb this run.\n\t\t\tif (!runtime.pendingQueueAction.displacedUsageFinalized) {\n\t\t\t\tif (runtime.activeGoal?.status === \"active\") {\n\t\t\t\t\tupdateGoalUsage(runtime.activeGoal, ctx, false);\n\t\t\t\t}\n\t\t\t\truntime.pendingQueueAction.displacedUsageFinalized = true;\n\t\t\t\tif (runtime.activeGoal) {\n\t\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\t\t}\n\t\t\t}\n\t\t\truntime.agentRunGoalId = null;\n\t\t\tif (ownedPromptGoalId) abortCurrentTurn(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (activeBudgetWrapUp && runtime.activeGoal) {\n\t\t\truntime.agentRunGoalId = runtime.activeGoal.id;\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\truntime.pendingQueueAction?.kind === \"advance\" &&\n\t\t\truntime.pendingQueueAction.goalId === runtime.activeGoal?.id\n\t\t) {\n\t\t\truntime.agentRunGoalId = ownedPromptGoalId ?? runtime.activeGoal.id;\n\t\t\tif (ownedPromptGoalId) abortCurrentTurn(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (ownedPromptGoalId && ownedPromptGoalId !== runtime.activeGoal?.id) {\n\t\t\truntime.agentRunGoalId = ownedPromptGoalId;\n\t\t\tif (runtime.activeGoal?.status === \"active\" && !goalToolsAvailable()) {\n\t\t\t\tpauseGoalForUnavailableTools(ctx, false);\n\t\t\t}\n\t\t\tabortCurrentTurn(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal?.status !== \"active\") {\n\t\t\truntime.agentRunGoalId = undefined;\n\t\t\treturn;\n\t\t}\n\t\truntime.agentRunGoalId = runtime.activeGoal.id;\n\t\tif (!goalToolsAvailable()) {\n\t\t\tpauseGoalForUnavailableTools(ctx, ownedPromptGoalId !== undefined);\n\t\t\treturn;\n\t\t}\n\n\t\treturn {\n\t\t\tsystemPrompt: `${event.systemPrompt}\\n\\n${buildGoalSystemPrompt(runtime.activeGoal)}`,\n\t\t};\n\t});\n\n\tpi.on(\"agent_end\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tconst agentRunGoalId = runtime.agentRunGoalId;\n\t\truntime.agentRunGoalId = undefined;\n\t\tif (\n\t\t\tagentRunGoalId === null ||\n\t\t\t(!runtime.canRecordGoalUsage() && !runtime.hasActiveBudgetWrapUp())\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (agentRunGoalId && agentRunGoalId !== runtime.activeGoal?.id) return;\n\t\tif (!runtime.activeGoal) return;\n\t\tif (\n\t\t\truntime.activeGoal.status === \"budget_limited\" &&\n\t\t\truntime.budgetWrapUp?.goalId === runtime.activeGoal.id\n\t\t) {\n\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\tclearBudgetWrapUp();\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal.status !== \"active\") return;\n\t\tif (\n\t\t\truntime.pendingQueueAction?.kind === \"advance\" &&\n\t\t\truntime.pendingQueueAction.goalId === runtime.activeGoal.id\n\t\t) {\n\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\treturn;\n\t\t}\n\n\t\tconst goalId = runtime.activeGoal.id;\n\t\tconst alreadyAwaitingContinuation = hasContinuationWorkForGoal(goalId);\n\t\tconst finalAssistant = findFinalAssistantMessage(event.messages);\n\n\t\tif (!alreadyAwaitingContinuation) runtime.activeGoal = incrementGoal(runtime.activeGoal);\n\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\n\t\tif (finalAssistant?.stopReason === \"aborted\") {\n\t\t\tclearGoalRecoveryForGoal(goalId);\n\t\t\tstopGoalAfterAgentEnd(ctx, runtime.activeGoal, finalAssistant, \"paused\");\n\t\t\treturn;\n\t\t}\n\n\t\tif (finalAssistant?.stopReason === \"error\") {\n\t\t\tif (isRetryableGoalInterruption(finalAssistant)) {\n\t\t\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\t\t\t\tif (!goalToolsAvailable()) {\n\t\t\t\t\tpauseGoalForUnavailableTools(ctx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\truntime.goalRecovery = {\n\t\t\t\t\tgoalId,\n\t\t\t\t\tkind: isGoalContextOverflow(finalAssistant) ? \"compaction_retry\" : \"provider_retry\",\n\t\t\t\t};\n\t\t\t\tcancelContinuationWork();\n\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tclearGoalRecoveryForGoal(goalId);\n\t\t\tstopGoalAfterAgentEnd(\n\t\t\t\tctx,\n\t\t\t\truntime.activeGoal,\n\t\t\t\tfinalAssistant,\n\t\t\t\tisUsageLimitedGoalInterruption(finalAssistant) ? \"usage_limited\" : \"blocked\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tclearGoalRecoveryForGoal(goalId);\n\n\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\t\tif (!goalToolsAvailable()) {\n\t\t\tpauseGoalForUnavailableTools(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\n\t\tconst currentGoal = runtime.activeGoal;\n\t\tif (!currentGoal || currentGoal.id !== goalId || currentGoal.status !== \"active\") return;\n\t\tif (runtime.pendingQueueAction?.kind === \"prioritize\") return;\n\t\trequestContinuation(currentGoal);\n\t});\n\n\tpi.on(\"agent_settled\", (_event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (!runtime.pendingQueueAction) {\n\t\t\tdispatchContinuationIfSettled(ctx);\n\t\t\treturn;\n\t\t}\n\t\treturn dispatchPendingQueueActionIfSettled(ctx).then((dispatched) => {\n\t\t\tif (!dispatched) dispatchContinuationIfSettled(ctx);\n\t\t});\n\t});\n\n\tfunction hasPendingSkipForGoal(goalId: string) {\n\t\treturn (\n\t\t\truntime.pendingQueueAction?.kind === \"advance\" &&\n\t\t\truntime.pendingQueueAction.reason === \"skip\" &&\n\t\t\truntime.pendingQueueAction.goalId === goalId\n\t\t);\n\t}\n\n\tfunction stopGoalAfterAgentEnd(\n\t\tctx: StatusContext,\n\t\tgoal: ActiveGoal,\n\t\tassistant: AssistantMessageLike,\n\t\tstatus: \"paused\" | \"blocked\" | \"usage_limited\",\n\t) {\n\t\tcancelContinuationWork();\n\t\tclearBudgetWrapUp();\n\t\tblockStaleGoalToolCalls();\n\t\tabortCurrentTurn(ctx);\n\t\t// lunr: if the provider error carries a reset time, pre-fill resumeAfter so a\n\t\t// one-shot /cron wake-up auto-resumes the goal without a manual /goal resume.\n\t\tconst resumeAfter = status === \"usage_limited\" ? parseUsageResetTimeMs(assistant.errorMessage) : undefined;\n\t\tconst goalWithResume = resumeAfter !== undefined ? { ...goal, resumeAfter } : goal;\n\t\truntime.activeGoal = transitionGoal(goalWithResume, status);\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\n\t\tconst details = assistant.errorMessage\n\t\t\t? ` (${truncateNotification(assistant.errorMessage)})`\n\t\t\t: \"\";\n\t\tif (status === \"paused\") {\n\t\t\tctx.ui.notify(\n\t\t\t\t`Goal paused after interruption${details}. Run /goal resume to continue.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (status === \"usage_limited\") {\n\t\t\tconst when = resumeAfter !== undefined ? ` Auto-resume scheduled for ${new Date(resumeAfter).toLocaleString()}.` : \"\";\n\t\t\tctx.ui.notify(\n\t\t\t\t`Goal usage-limited${details}.${when} Run /goal resume when usage resets, or schedule a one-shot /cron firing \"continue\" into this session to wake it.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tctx.ui.notify(\n\t\t\t`Goal blocked after agent error${details}. Resolve the blocker or run /goal resume to retry.`,\n\t\t\t\"warning\",\n\t\t);\n\t}\n}\n\nexport default function goal(pi: ExtensionAPI, options: GoalOptions = {}) {\n\tregisterGoalRuntime(pi, options);\n}\n\nexport {\n\tassistantUsageTokens,\n\tcumulativeAssistantTokens,\n\tformatDuration,\n\tformatTokenCount,\n} from \"./accounting.js\";\n\nexport {\n\tcompleteGoalArguments,\n\tparseCommand,\n\tparseTokenBudget,\n\tvalidateObjective,\n} from \"./command.js\";\n\nexport { buildGoalSystemPrompt } from \"./prompts.js\";\n\nexport {\n\tfindFinalAssistantMessage,\n\tformatStatus,\n\tisContradictoryCompletionSummary,\n\tisRetryableGoalInterruption,\n\tisUsageLimitedGoalInterruption,\n} from \"./runtime.js\";\n"]}
1
+ {"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../../src/builtin-extensions/narumiruna-pi-goal/src/goal.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,iFAA+E;AAC/E,sEAAsE;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAmB,wBAAwB,EAAE,MAAM,kBAAkB,CAA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CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EACN,yBAAyB,EACzB,YAAY,EACZ,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,GAC9B,MAAM,cAAc,CAAC","sourcesContent":["// @ts-nocheck\n// lunr: defineTool imported from the concrete module, NOT the package barrel —\n// the barrel re-exports main.ts which imports this extension (cycle).\nimport { defineTool } from \"../../../core/extensions/types.js\";\nimport { isCronFire } from \"../../../core/cron/fire-guard.js\";\nimport type { ExtensionAPI } from \"@ashx-j/lunr\";\nimport { Type } from \"typebox\";\nimport { Container, Markdown, Text } from \"@ashx-j/lunr-tui\";\nimport { currentTokenTotal } from \"./accounting.js\";\nimport { completeGoalArguments, parseCommand } from \"./command.js\";\nimport { GoalCommandController } from \"./commands.js\";\nimport { type ActiveGoal, loadGoalStateFromSession } from \"./persistence.js\";\nimport { buildGoalPrompt, buildGoalSystemPrompt } from \"./prompts.js\";\nimport { activateQueuedGoal } from \"./queue.js\";\nimport {\n\ttype AssistantMessageLike,\n\tabortCurrentTurn,\n\tblocksStaleGoalToolCalls,\n\tfindFinalAssistantMessage,\n\tformatError,\n\tformatStatus,\n\tGOAL_BLOCKED_TOOL,\n\tGOAL_COMPLETE_TOOL,\n\tGoalRuntime,\n\tgoalIdRejectionReason,\n\tincrementGoal,\n\tisContradictoryCompletionSummary,\n\tisGoalContextOverflow,\n\tisRetryableGoalInterruption,\n\tisUsageLimitedGoalInterruption,\n\tparseUsageResetTimeMs,\n\tSTATUS_KEY,\n\ttype StatusContext,\n\ttransitionGoal,\n\ttruncateNotification,\n} from \"./runtime.js\";\nimport { DEFAULT_GOAL_SETTINGS, readGoalSettings } from \"./settings.js\";\n\n// goal.ts is the Pi-facing composition root: it keeps tool contracts and event\n// ordering together. Per-session mechanisms live in runtime.ts, while user command\n// transitions live in commands.ts. Each factory constructs isolated instances.\n\ninterface GoalCompleteDetails {\n\tgoal: string;\n\tgoal_id: string;\n\tsummary: string;\n}\n\ninterface GoalBlockedDetails {\n\tgoal: string;\n\tgoal_id: string;\n\treason: string;\n\tevidence: string;\n\trepeated_turns: number;\n}\n\ninterface GoalOptions {\n\tsettingsPath?: string;\n}\n\nconst GOAL_COMPLETE_MESSAGE_TYPE = \"goal-complete\";\nconst EXPERIMENTAL_GOALS_WARNING =\n\t\"Experimental ordered goals are enabled for pi-goal. Queue behavior and persisted state may change.\";\nconst MAX_BLOCKER_REASON_LENGTH = 1_000;\nconst MAX_BLOCKER_EVIDENCE_LENGTH = 4_000;\n\nfunction registerGoalRuntime(pi: ExtensionAPI, options: GoalOptions = {}) {\n\tconst runtime = new GoalRuntime(pi);\n\tconst commands = new GoalCommandController(runtime);\n\n\t// Bind per-factory runtime operations once so event orchestration stays concise\n\t// without reintroducing module-global mutable state.\n\tconst clearCompletionStatusTimer = runtime.clearCompletionStatusTimer.bind(runtime);\n\t// lunr: footer refresh timer cleanup\n\tconst clearStatusRefreshTimer = runtime.clearStatusRefreshTimer.bind(runtime);\n\tconst clearContinuationTracking = runtime.clearContinuationTracking.bind(runtime);\n\tconst clearPendingGoalPrompts = runtime.clearPendingGoalPrompts.bind(runtime);\n\tconst clearGoalRecovery = runtime.clearGoalRecovery.bind(runtime);\n\tconst clearBudgetWrapUp = runtime.clearBudgetWrapUp.bind(runtime);\n\tconst clearStaleGoalToolCallBlock = runtime.clearStaleGoalToolCallBlock.bind(runtime);\n\tconst persistGoal = runtime.persistGoal.bind(runtime);\n\tconst updateGoalUsage = runtime.recordGoalUsage.bind(runtime);\n\tconst updateStatus = runtime.updateStatus.bind(runtime);\n\tconst limitActiveGoalForBudget = runtime.limitActiveGoalForBudget.bind(runtime);\n\tconst hideGoalToolsIfLocked = runtime.hideGoalToolsIfLocked.bind(runtime);\n\tconst goalToolsAvailable = runtime.goalToolsAvailable.bind(runtime);\n\tconst pauseGoalForUnavailableTools = runtime.pauseGoalForUnavailableTools.bind(runtime);\n\tconst isPiOwnedCompactionRetry = runtime.isPiOwnedCompactionRetry.bind(runtime);\n\tconst requestContinuation = runtime.requestContinuation.bind(runtime);\n\tconst dispatchContinuationIfSettled = runtime.dispatchContinuationIfSettled.bind(runtime);\n\tconst isGoalToolName = runtime.isGoalToolName.bind(runtime);\n\tconst queueBudgetWrapUp = runtime.queueBudgetWrapUp.bind(runtime);\n\tconst clearGoalRecoveryForGoal = runtime.clearGoalRecoveryForGoal.bind(runtime);\n\tconst blockStaleGoalToolCalls = runtime.blockStaleGoalToolCalls.bind(runtime);\n\tconst cancelContinuationWork = runtime.cancelContinuationWork.bind(runtime);\n\tconst consumeCancelledContinuationPrompt =\n\t\truntime.consumeCancelledContinuationPrompt.bind(runtime);\n\tconst consumeStaleOwnedGoalPrompt = runtime.consumeStaleOwnedGoalPrompt.bind(runtime);\n\tconst consumePendingGoalPrompt = runtime.consumeOwnedGoalPrompt.bind(runtime);\n\tconst markContinuationStarted = runtime.markContinuationStarted.bind(runtime);\n\tconst hasContinuationWorkForGoal = runtime.hasContinuationWorkForGoal.bind(runtime);\n\tconst clearActiveGoal = runtime.clearActiveGoal.bind(runtime);\n\tconst showCompletionStatus = runtime.showCompletionStatus.bind(runtime);\n\tconst restoreGoalToolsHiddenByPolicy = runtime.restoreGoalToolsHiddenByPolicy.bind(runtime);\n\tconst sendOwnedGoalPrompt = (\n\t\t_pi: ExtensionAPI,\n\t\tctx: StatusContext,\n\t\tgoalId: string,\n\t\tprompt: string,\n\t) => runtime.sendOwnedGoalPrompt(ctx, goalId, prompt);\n\tconst dispatchPendingQueueActionIfSettled =\n\t\tcommands.dispatchPendingQueueActionIfSettled.bind(commands);\n\n\tconst emitGoalCompleteMessage = (summary: string) => {\n\t\tconst text = summary.startsWith(\"Goal complete\") ? summary : summary;\n\t\tpi.sendMessage({\n\t\t\tcustomType: GOAL_COMPLETE_MESSAGE_TYPE,\n\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\tdisplay: true,\n\t\t});\n\t};\n\n\tpi.registerMessageRenderer(GOAL_COMPLETE_MESSAGE_TYPE, (message, _options, theme) => {\n\t\tconst raw =\n\t\t\ttypeof message.content === \"string\"\n\t\t\t\t? message.content\n\t\t\t\t: message.content\n\t\t\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t\t\t.map((block) => (\"text\" in block ? block.text : \"\"))\n\t\t\t\t\t\t.join(\"\\n\");\n\t\tconst c = new Container();\n\t\tc.addChild(new Markdown(`● ${raw}`, 1, 0, undefined, {\n\t\t\tcolor: (content) => theme.fg(\"text\", content),\n\t\t}));\n\t\treturn c;\n\t});\n\n\tconst goalCompleteTool = defineTool({\n\t\tname: GOAL_COMPLETE_TOOL,\n\t\tlabel: \"Goal Complete\",\n\t\tdescription:\n\t\t\t\"Mark the active /goal as complete after all required work is done and verified, using the current goal_id stale-turn guard. Do not use for partial progress, blockers, failing, or unverified work.\",\n\t\tpromptSnippet:\n\t\t\t\"Mark the active /goal as complete after fully finishing and verifying it, with the current goal_id\",\n\t\tpromptGuidelines: [\n\t\t\t\"When a /goal is active, keep working until the goal is complete; do not stop with only a plan or partial progress.\",\n\t\t\t\"Before calling goal_complete, audit the active goal requirement by requirement against the current files, command output, tests, or external state.\",\n\t\t\t\"Pass the exact goal_id shown in the current /goal prompt; never reuse a goal_id from an older, stopped, replaced, or cleared turn.\",\n\t\t\t\"Call goal_complete only after the requested goal is fully implemented, verified, and no known required work remains; otherwise keep working.\",\n\t\t],\n\t\tparameters: Type.Object({\n\t\t\tgoal_id: Type.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"The exact goal_id shown in the current active /goal prompt. Used only to reject stale completion calls from older turns.\",\n\t\t\t}),\n\t\t\tsummary: Type.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"State what was completed and what evidence verified it. Do not use this tool to report partial progress, blockers, failures, or remaining work.\",\n\t\t\t}),\n\t\t}),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst completedGoal = runtime.activeGoal;\n\t\t\tconst goal = completedGoal?.text ?? \"unknown goal\";\n\t\t\tconst requestedGoalId = typeof params.goal_id === \"string\" ? params.goal_id.trim() : \"\";\n\t\t\tconst summary = typeof params.summary === \"string\" ? params.summary.trim() : \"\";\n\n\t\t\tif (!completedGoal) {\n\t\t\t\tconst rejection = \"Goal completion rejected: no active goal.\";\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst completingDuringBudgetWrapUp = runtime.hasActiveBudgetWrapUp();\n\t\t\tif (!runtime.canRecordGoalUsage() && !completingDuringBudgetWrapUp) {\n\t\t\t\tconst rejection = \"Goal completion rejected: current run does not own the active goal.\";\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (hasPendingSkipForGoal(completedGoal.id)) {\n\t\t\t\tupdateGoalUsage(completedGoal, ctx);\n\t\t\t\tpersistGoal(completedGoal);\n\t\t\t\tupdateStatus(ctx, completedGoal);\n\t\t\t\tclearBudgetWrapUp();\n\t\t\t\tconst rejection = \"Goal completion rejected: goal is queued to be skipped.\";\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst staleGoalRejection = goalIdRejectionReason(completedGoal, requestedGoalId);\n\t\t\tif (staleGoalRejection) {\n\t\t\t\tconst rejection = `Goal completion rejected: ${staleGoalRejection}.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\tif (completingDuringBudgetWrapUp) {\n\t\t\t\t\tupdateGoalUsage(completedGoal, ctx);\n\t\t\t\t\tpersistGoal(completedGoal);\n\t\t\t\t\tupdateStatus(ctx, completedGoal);\n\t\t\t\t\tclearBudgetWrapUp();\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: completingDuringBudgetWrapUp || undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (completedGoal.status !== \"active\" && !completingDuringBudgetWrapUp) {\n\t\t\t\tconst rejection = `Goal completion rejected: goal is ${completedGoal.status}, not active.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: rejection }],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rejectionReason = !summary\n\t\t\t\t? \"summary is empty\"\n\t\t\t\t: isContradictoryCompletionSummary(summary)\n\t\t\t\t\t? \"summary says the goal is not complete\"\n\t\t\t\t\t: undefined;\n\t\t\tif (rejectionReason) {\n\t\t\t\tupdateGoalUsage(completedGoal, ctx);\n\t\t\t\tpersistGoal(completedGoal);\n\t\t\t\tupdateStatus(ctx, completedGoal);\n\t\t\t\tconst rejection = `Goal completion rejected: ${rejectionReason}.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\tif (completingDuringBudgetWrapUp) clearBudgetWrapUp();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: rejection,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: completingDuringBudgetWrapUp || undefined,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\truntime.activeGoal = transitionGoal(completedGoal, \"complete\");\n\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\tif (runtime.pendingQueueAction?.kind === \"prioritize\") {\n\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\tctx.ui.setStatus(STATUS_KEY, \"complete\");\n\t\t\t\temitGoalCompleteMessage(summary);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Goal complete: ${summary}` }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tgoal,\n\t\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t} satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (runtime.queuedGoals.length > 0) {\n\t\t\t\truntime.pendingQueueAction = {\n\t\t\t\t\tkind: \"advance\",\n\t\t\t\t\tgoalId: runtime.activeGoal.id,\n\t\t\t\t\treason: \"complete\",\n\t\t\t\t\tcompletedText: goal,\n\t\t\t\t};\n\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\tctx.ui.setStatus(STATUS_KEY, \"complete\");\n\t\t\t\temitGoalCompleteMessage(summary);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Goal complete: ${summary}\\nNext goal queued: ${runtime.queuedGoals[0]?.text}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tgoal,\n\t\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t} satisfies GoalCompleteDetails,\n\t\t\t\t\tterminate: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tpersistGoal(runtime.activeGoal);\n\n\t\t\tctx.ui.setStatus(STATUS_KEY, formatStatus(runtime.activeGoal));\n\t\t\tclearActiveGoal(ctx);\n\t\t\tshowCompletionStatus(ctx);\n\t\t\temitGoalCompleteMessage(summary);\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `Goal complete: ${summary}` }],\n\t\t\t\tdetails: { goal, goal_id: requestedGoalId, summary } satisfies GoalCompleteDetails,\n\t\t\t\tterminate: true,\n\t\t\t};\n\t\t},\n\t\trenderResult(_result, { isPartial }, theme) {\n\t\t\tif (isPartial) return new Text(theme.fg(\"warning\", \"Completing goal...\"), 0, 0);\n\t\t\treturn { render: () => [], invalidate() {} };\n\t\t},\n\t});\n\n\tconst goalBlockedTool = defineTool({\n\t\tname: GOAL_BLOCKED_TOOL,\n\t\tlabel: \"Goal Blocked\",\n\t\tdescription:\n\t\t\t\"Stop the active /goal only at a true impasse after the same blocker recurs for at least three consecutive goal turns, with the current goal_id and concrete evidence that user or external action is required. Do not use for ordinary clarification, uncertainty, or recoverable failures.\",\n\t\tpromptSnippet:\n\t\t\t\"Mark the active /goal blocked only after the same blocker recurs for three consecutive goal turns\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use goal_blocked only for a true impasse after the same blocker recurs for at least three consecutive goal turns and concrete evidence shows user or external action is required.\",\n\t\t\t\"After a blocked goal is resumed, start a fresh three-turn blocker audit before using goal_blocked again.\",\n\t\t\t\"Do not use goal_blocked for ordinary clarification, incomplete work, uncertainty, difficult tasks, or recoverable tool/provider failures.\",\n\t\t\t\"Pass goal_blocked the exact current goal_id; never reuse a goal_id from an older, stopped, replaced, or cleared goal turn.\",\n\t\t],\n\t\tparameters: Type.Object({\n\t\t\tgoal_id: Type.String({\n\t\t\t\tdescription: \"The exact goal_id shown in the current active /goal prompt.\",\n\t\t\t}),\n\t\t\treason: Type.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_BLOCKER_REASON_LENGTH,\n\t\t\t\tdescription: \"The specific user or external action required to unblock the goal.\",\n\t\t\t}),\n\t\t\tevidence: Type.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_BLOCKER_EVIDENCE_LENGTH,\n\t\t\t\tdescription: \"Concrete evidence from the repeated attempts that proves the impasse.\",\n\t\t\t}),\n\t\t\trepeated_turns: Type.Integer({\n\t\t\t\tminimum: 3,\n\t\t\t\tdescription: \"Number of separate turns spent trying to resolve this same blocker.\",\n\t\t\t}),\n\t\t}),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst blockedGoal = runtime.activeGoal;\n\t\t\tconst goal = blockedGoal?.text ?? \"unknown goal\";\n\t\t\tconst requestedGoalId = typeof params.goal_id === \"string\" ? params.goal_id.trim() : \"\";\n\t\t\tconst reason = typeof params.reason === \"string\" ? params.reason.trim() : \"\";\n\t\t\tconst evidence = typeof params.evidence === \"string\" ? params.evidence.trim() : \"\";\n\t\t\tconst repeatedTurns =\n\t\t\t\ttypeof params.repeated_turns === \"number\" ? params.repeated_turns : Number.NaN;\n\t\t\tconst reject = (rejectionReason: string, terminate = false) => {\n\t\t\t\tconst rejection = `goal_blocked rejected: ${rejectionReason}.`;\n\t\t\t\tctx.ui.notify(rejection, \"warning\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: rejection }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tgoal,\n\t\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\t\treason: reason.slice(0, MAX_BLOCKER_REASON_LENGTH),\n\t\t\t\t\t\tevidence: evidence.slice(0, MAX_BLOCKER_EVIDENCE_LENGTH),\n\t\t\t\t\t\trepeated_turns: Number.isFinite(repeatedTurns) ? repeatedTurns : 0,\n\t\t\t\t\t} satisfies GoalBlockedDetails,\n\t\t\t\t\t...(terminate ? { terminate: true as const } : {}),\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tif (!blockedGoal) return reject(\"no active goal\");\n\t\t\tif (!runtime.canRecordGoalUsage()) {\n\t\t\t\treturn reject(\"current run does not own the active goal\");\n\t\t\t}\n\t\t\tif (hasPendingSkipForGoal(blockedGoal.id)) {\n\t\t\t\tupdateGoalUsage(blockedGoal, ctx);\n\t\t\t\tpersistGoal(blockedGoal);\n\t\t\t\tupdateStatus(ctx, blockedGoal);\n\t\t\t\tclearBudgetWrapUp();\n\t\t\t\treturn reject(\"goal is queued to be skipped\", true);\n\t\t\t}\n\t\t\tconst staleGoalRejection = goalIdRejectionReason(blockedGoal, requestedGoalId);\n\t\t\tif (staleGoalRejection) return reject(staleGoalRejection);\n\t\t\tif (blockedGoal.status !== \"active\") {\n\t\t\t\treturn reject(`goal is ${blockedGoal.status}, not active`);\n\t\t\t}\n\t\t\tif (!reason) return reject(\"reason is empty\");\n\t\t\tif (reason.length > MAX_BLOCKER_REASON_LENGTH) return reject(\"reason is too long\");\n\t\t\tif (!evidence) return reject(\"evidence is empty\");\n\t\t\tif (evidence.length > MAX_BLOCKER_EVIDENCE_LENGTH) return reject(\"evidence is too long\");\n\t\t\tif (!Number.isInteger(repeatedTurns)) return reject(\"repeated_turns must be a whole number\");\n\t\t\tif (repeatedTurns < 3) return reject(\"repeated_turns must be at least 3\");\n\n\t\t\tupdateGoalUsage(blockedGoal, ctx);\n\t\t\tcancelContinuationWork();\n\t\t\tclearBudgetWrapUp();\n\t\t\tclearGoalRecoveryForGoal(blockedGoal.id);\n\t\t\tblockStaleGoalToolCalls();\n\t\t\truntime.activeGoal = transitionGoal(blockedGoal, \"blocked\");\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\tctx.ui.notify(`Goal blocked: ${truncateNotification(reason)}`, \"warning\");\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `Goal blocked: ${reason}` }],\n\t\t\t\tdetails: {\n\t\t\t\t\tgoal,\n\t\t\t\t\tgoal_id: requestedGoalId,\n\t\t\t\t\treason,\n\t\t\t\t\tevidence,\n\t\t\t\t\trepeated_turns: repeatedTurns,\n\t\t\t\t} satisfies GoalBlockedDetails,\n\t\t\t\tterminate: true,\n\t\t\t};\n\t\t},\n\t});\n\n\tpi.registerTool(goalCompleteTool);\n\tpi.registerTool(goalBlockedTool);\n\t// Do not touch the active tool set during factory registration: ExtensionAPI\n\t// actions are unbound until the session binds the runtime. session_start applies\n\t// baseline visibility once actions work; later hooks only enforce goal safety.\n\n\tpi.registerCommand(\"goal\", {\n\t\tdescription: \"Run a goal to completion: /goal [--tokens 100k] <goal_to_complete>\",\n\t\tgetArgumentCompletions: (prefix) =>\n\t\t\tcompleteGoalArguments(prefix, {\n\t\t\t\texperimentalGoals: runtime.settings.experimental.goals,\n\t\t\t}),\n\t\thandler: async (args, ctx) => {\n\t\t\tconst result = parseCommand(args, {\n\t\t\t\texperimentalGoals: runtime.settings.experimental.goals,\n\t\t\t});\n\t\t\tif (typeof result === \"string\") {\n\t\t\t\tctx.ui.notify(result, \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (runtime.queueFrozen) {\n\t\t\t\tif (result.kind === \"show\") commands.showGoal(ctx);\n\t\t\t\telse if (result.kind === \"clear\") commands.clearGoal(ctx);\n\t\t\t\telse commands.notifyFrozenQueue(ctx);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (runtime.pendingQueueAction && result.kind !== \"show\" && result.kind !== \"clear\") {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\"A queued goal change is waiting for Pi to settle. Retry after it finishes.\",\n\t\t\t\t\t\"warning\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tswitch (result.kind) {\n\t\t\t\tcase \"show\":\n\t\t\t\t\tcommands.showGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"pause\":\n\t\t\t\t\tcommands.pauseGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"resume\":\n\t\t\t\t\tawait commands.resumeGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"clear\":\n\t\t\t\t\tcommands.clearGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"edit\":\n\t\t\t\t\tawait commands.editGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"add\":\n\t\t\t\t\tawait commands.addGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"prioritize\":\n\t\t\t\t\tawait commands.prioritizeGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"drop-last\":\n\t\t\t\t\tcommands.dropLastGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"skip\":\n\t\t\t\t\tawait commands.skipGoal(ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase \"start\":\n\t\t\t\t\tawait commands.startGoal(result.objective ?? \"\", result.tokenBudget, ctx);\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tclearCompletionStatusTimer();\n\t\tclearStatusRefreshTimer(); // lunr\n\t\tclearContinuationTracking();\n\t\tclearPendingGoalPrompts();\n\t\truntime.agentRunGoalId = undefined;\n\t\tclearGoalRecovery();\n\t\tclearBudgetWrapUp();\n\t\tclearStaleGoalToolCallBlock();\n\t\truntime.queuedGoals = [];\n\t\truntime.pendingQueueAction = undefined;\n\t\truntime.queueFrozen = false;\n\t\tconst previousToolVisibility = runtime.settings.toolVisibility;\n\t\tconst settingsResult = readGoalSettings(options.settingsPath);\n\t\truntime.settings =\n\t\t\tsettingsResult.kind === \"loaded\" ? settingsResult.settings : DEFAULT_GOAL_SETTINGS;\n\t\tif (settingsResult.kind === \"invalid\") {\n\t\t\tctx.ui.notify(\n\t\t\t\t`pi-goal settings ignored: ${settingsResult.reason}. Using default settings.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t}\n\t\tif (runtime.settings.experimental.goals) {\n\t\t\tctx.ui.notify(EXPERIMENTAL_GOALS_WARNING, \"warning\");\n\t\t}\n\t\tif (\n\t\t\truntime.settings.toolVisibility === \"after-first-goal\" &&\n\t\t\tpreviousToolVisibility === \"always\"\n\t\t) {\n\t\t\truntime.goalToolsUnlocked = false;\n\t\t}\n\t\tif (runtime.settings.toolVisibility === \"always\") {\n\t\t\tif (runtime.goalToolsHiddenByPolicy.size > 0) {\n\t\t\t\ttry {\n\t\t\t\t\trestoreGoalToolsHiddenByPolicy();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t`Could not restore always-visible goal tools: ${formatError(error)}`,\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\truntime.goalToolsUnlocked = true;\n\t\t}\n\n\t\tconst loaded = loadGoalStateFromSession(ctx);\n\t\truntime.activeGoal = loaded.goal;\n\t\truntime.queuedGoals = loaded.queue;\n\t\truntime.pendingQueueAction = loaded.pendingAction;\n\t\truntime.queueFrozen = loaded.hasExperimentalQueueState && !runtime.settings.experimental.goals;\n\t\tif (runtime.queueFrozen) {\n\t\t\tif (runtime.activeGoal) persistGoal(runtime.activeGoal);\n\t\t\tctx.ui.setStatus(STATUS_KEY, \"queue off\");\n\t\t\tctx.ui.notify(\n\t\t\t\t\"An experimental goal queue is frozen because experimental.goals is disabled. Re-enable it and run /reload to continue, or use /goal clear.\",\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tlet startRestoredQueuedGoal = false;\n\t\tif (runtime.activeGoal?.status === \"queued\" && !runtime.pendingQueueAction) {\n\t\t\truntime.activeGoal = activateQueuedGoal(runtime.activeGoal, currentTokenTotal(ctx));\n\t\t\tstartRestoredQueuedGoal = runtime.activeGoal.status === \"active\";\n\t\t}\n\t\tif (runtime.pendingQueueAction) await dispatchPendingQueueActionIfSettled(ctx);\n\t\tif (runtime.activeGoal) {\n\t\t\tif (runtime.activeGoal.status === \"active\") {\n\t\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\t\t\t}\n\t\t\tif (runtime.settings.toolVisibility === \"after-first-goal\") {\n\t\t\t\t// Registered tools are already active on an unrestricted fresh runtime.\n\t\t\t\t// If an earlier session_start handler removed them, that restrictive\n\t\t\t\t// policy wins: mark lazy visibility unlocked without widening its set.\n\t\t\t\truntime.goalToolsUnlocked = true;\n\t\t\t\truntime.goalToolsHiddenByPolicy.clear();\n\t\t\t}\n\t\t\tif (runtime.activeGoal.status === \"active\" && !goalToolsAvailable()) {\n\t\t\t\tpauseGoalForUnavailableTools(ctx, false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\tif (startRestoredQueuedGoal) {\n\t\t\t\tconst restoredGoal = runtime.activeGoal;\n\t\t\t\tconst sent = await sendOwnedGoalPrompt(\n\t\t\t\t\truntime.pi,\n\t\t\t\t\tctx,\n\t\t\t\t\trestoredGoal.id,\n\t\t\t\t\tbuildGoalPrompt(restoredGoal),\n\t\t\t\t);\n\t\t\t\tif (!sent && runtime.activeGoal?.id === restoredGoal.id) {\n\t\t\t\t\truntime.activeGoal = transitionGoal(restoredGoal, \"paused\");\n\t\t\t\t\tblockStaleGoalToolCalls();\n\t\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (runtime.settings.toolVisibility === \"after-first-goal\" && !runtime.goalToolsUnlocked) {\n\t\t\t\thideGoalToolsIfLocked();\n\t\t\t}\n\t\t\tctx.ui.setStatus(STATUS_KEY, undefined);\n\t\t}\n\t});\n\n\tpi.on(\"session_shutdown\", (_event, ctx) => {\n\t\tif (runtime.activeGoal) {\n\t\t\tif (!runtime.queueFrozen && runtime.activeGoal.status === \"active\") {\n\t\t\t\tupdateGoalUsage(runtime.activeGoal, ctx, false);\n\t\t\t}\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t}\n\t\tclearContinuationTracking();\n\t\tclearPendingGoalPrompts();\n\t\truntime.agentRunGoalId = undefined;\n\t\tclearGoalRecovery();\n\t\tclearBudgetWrapUp();\n\t\tclearStaleGoalToolCallBlock();\n\t\truntime.activeGoal = undefined;\n\t\truntime.queuedGoals = [];\n\t\truntime.pendingQueueAction = undefined;\n\t\truntime.queueFrozen = false;\n\t\tctx.ui.setStatus(STATUS_KEY, undefined);\n\t\tclearCompletionStatusTimer();\n\t\tclearStatusRefreshTimer(); // lunr\n\t});\n\n\tpi.on(\"session_before_compact\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (runtime.activeGoal?.status === \"budget_limited\") {\n\t\t\tif (event.reason === \"overflow\" && (event as { willRetry?: boolean }).willRetry === true) {\n\t\t\t\treturn { cancel: true as const };\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal?.status !== \"active\") return;\n\t\tif (!updateGoalUsage(runtime.activeGoal, ctx)) return;\n\t\tcancelContinuationWork();\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\tif (runtime.pendingQueueAction) return;\n\t\tif (limitActiveGoalForBudget(ctx, false)) {\n\t\t\tif (event.reason === \"threshold\" && (event as { willRetry?: boolean }).willRetry === true) return;\n\t\t\treturn { cancel: true as const };\n\t\t}\n\t});\n\n\tpi.on(\"session_compact\", async (event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (runtime.activeGoal?.status !== \"active\") {\n\t\t\tclearGoalRecovery();\n\t\t\tif (runtime.pendingQueueAction) await dispatchPendingQueueActionIfSettled(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tconst restoredState = loadGoalStateFromSession(ctx);\n\t\tif (restoredState.goal?.id === runtime.activeGoal.id) {\n\t\t\truntime.activeGoal = restoredState.goal;\n\t\t\truntime.queuedGoals = restoredState.queue;\n\t\t\truntime.pendingQueueAction = restoredState.pendingAction;\n\t\t}\n\t\tconst usageRecorded = updateGoalUsage(runtime.activeGoal, ctx);\n\t\tif (usageRecorded) {\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t}\n\t\tif (runtime.pendingQueueAction) {\n\t\t\tawait dispatchPendingQueueActionIfSettled(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (!usageRecorded) return;\n\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\n\t\tconst wasPiRetry = isPiOwnedCompactionRetry(event, runtime.activeGoal.id);\n\t\tclearGoalRecoveryForGoal(runtime.activeGoal.id);\n\t\tif (wasPiRetry) return;\n\t\trequestContinuation(runtime.activeGoal);\n\t\t// Manual compaction does not emit agent_settled. This common dispatcher is\n\t\t// therefore the narrow fallback; threshold compaction leaves the intent for\n\t\t// agent_settled when Pi is still busy.\n\t\tdispatchContinuationIfSettled(ctx);\n\t});\n\n\tpi.on(\"input\", (event) => {\n\t\tif (event.source === \"extension\") {\n\t\t\tif (\n\t\t\t\tconsumeCancelledContinuationPrompt(event.text) ||\n\t\t\t\tconsumeStaleOwnedGoalPrompt(event.text)\n\t\t\t) {\n\t\t\t\treturn { action: \"handled\" as const };\n\t\t\t}\n\t\t\tif (runtime.queueFrozen) return;\n\t\t\tclearGoalRecovery();\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.queueFrozen) return;\n\t\tif (/^\\/goal(?:\\s|$)/u.test(event.text.trimStart())) return;\n\t\tclearGoalRecovery();\n\t\tclearBudgetWrapUp();\n\t\tclearStaleGoalToolCallBlock();\n\t});\n\n\t// lunr: the previous context-event filter dropped superseded budget\n\t// wrap-up messages from request context. That breaks Anthropic prefix\n\t// continuity (full cache miss from the cut). The wrap-up custom message\n\t// is small; keeping history unfiltered is cheaper than a cache rewrite.\n\t// keepBudgetWrapUpMessage remains on the runtime if a future token-saving\n\t// path can prove the wrap-up was never sent.\n\n\tpi.on(\"tool_call\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) {\n\t\t\tif (!isGoalToolName(event.toolName)) return;\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason:\n\t\t\t\t\t\"The experimental goal queue is frozen. Re-enable experimental.goals and run /reload, or use /goal clear.\",\n\t\t\t};\n\t\t}\n\t\t// lunr: mask locked goal tools instead of removing them from the active\n\t\t// list (setActiveTools churn busts the tools+system cache prefix).\n\t\tif (isGoalToolName(event.toolName) && runtime.areGoalToolsLocked()) {\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: \"Goal tools are locked until a /goal is activated.\",\n\t\t\t};\n\t\t}\n\t\tif (\n\t\t\truntime.activeGoal?.status === \"budget_limited\" &&\n\t\t\truntime.budgetWrapUp?.goalId === runtime.activeGoal.id &&\n\t\t\tevent.toolName !== \"goal_complete\"\n\t\t) {\n\t\t\t// A blocked tool result would normally trigger another model call. Abort the\n\t\t\t// wrap-up instead so a tool-seeking model cannot create an unbounded loop.\n\t\t\tabortCurrentTurn(ctx);\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: \"Goal token budget is exhausted; only goal_complete is allowed during wrap-up.\",\n\t\t\t};\n\t\t}\n\t\tif (!runtime.staleGoalToolCallsBlocked) return;\n\t\tif (!runtime.activeGoal || !blocksStaleGoalToolCalls(runtime.activeGoal.status)) {\n\t\t\tclearStaleGoalToolCallBlock();\n\t\t\treturn;\n\t\t}\n\t\treturn {\n\t\t\tblock: true,\n\t\t\treason: \"Blocked stale /goal tool call after the goal stopped or was interrupted.\",\n\t\t};\n\t});\n\n\tpi.on(\"tool_execution_end\", (_event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (\n\t\t\truntime.activeGoal?.status === \"budget_limited\" &&\n\t\t\truntime.budgetWrapUp?.goalId === runtime.activeGoal.id &&\n\t\t\t!runtime.budgetWrapUp.delivered\n\t\t) {\n\t\t\tqueueBudgetWrapUp(ctx, runtime.activeGoal);\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal?.status !== \"active\") return;\n\n\t\t// AgentSession persists assistant message_end before tool execution events,\n\t\t// so the completed assistant call's usage is authoritative at this boundary.\n\t\tif (!updateGoalUsage(runtime.activeGoal, ctx)) return;\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\tif (limitActiveGoalForBudget(ctx, true)) return;\n\t\tif (!goalToolsAvailable()) pauseGoalForUnavailableTools(ctx);\n\t});\n\n\tpi.on(\"before_agent_start\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) {\n\t\t\truntime.agentRunGoalId = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst goalPromptGoalId = consumePendingGoalPrompt(event.prompt);\n\t\tconst continuationGoalId = goalPromptGoalId ? undefined : markContinuationStarted(event.prompt);\n\t\tconst ownedPromptGoalId = goalPromptGoalId ?? continuationGoalId;\n\t\tconst activeBudgetWrapUp = runtime.hasActiveBudgetWrapUp();\n\t\tconst activeGoalRecovery = runtime.hasActiveGoalRecovery();\n\t\t// lunr: auto-resume a usage_limited goal on a wake-up turn. Two triggers:\n\t\t// - resumeAfter was parsed from the provider error and has elapsed (any turn\n\t\t// resumes — the reset time is known, so the goal should not stay parked);\n\t\t// - no reset time was parseable: only a cron-fired turn resumes (the user\n\t\t// scheduled the wake-up explicitly; ordinary manual turns don't hijack —\n\t\t// /goal resume stays the manual path).\n\t\t// Gateway cron fires are headless and cannot see this session's goal.\n\t\tconst resumeAfter = runtime.activeGoal?.resumeAfter;\n\t\tconst resumeDue = resumeAfter !== undefined && Date.now() >= resumeAfter;\n\t\tconst cronWakeUp = resumeAfter === undefined && isCronFire();\n\t\tif (\n\t\t\truntime.activeGoal?.status === \"usage_limited\" &&\n\t\t\t(resumeDue || cronWakeUp) &&\n\t\t\t!ownedPromptGoalId &&\n\t\t\t!activeBudgetWrapUp &&\n\t\t\t!activeGoalRecovery\n\t\t) {\n\t\t\tconst resumed = runtime.reactivateGoalForResume(ctx);\n\t\t\tif (resumed) {\n\t\t\t\truntime.agentRunGoalId = resumed.id;\n\t\t\t\tif (!goalToolsAvailable()) {\n\t\t\t\t\tpauseGoalForUnavailableTools(ctx, false);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsystemPrompt: event.systemPrompt + \"\\n\\n\" + buildGoalSystemPrompt(runtime.activeGoal),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\truntime.pendingQueueAction?.kind === \"prioritize\" &&\n\t\t\t!activeBudgetWrapUp &&\n\t\t\t!activeGoalRecovery\n\t\t) {\n\t\t\t// A turn that starts after priority intent is committed belongs to neither\n\t\t\t// the displaced goal nor the not-yet-activated urgent goal. Persist the\n\t\t\t// displaced goal's final accounting boundary so reload cannot absorb this run.\n\t\t\tif (!runtime.pendingQueueAction.displacedUsageFinalized) {\n\t\t\t\tif (runtime.activeGoal?.status === \"active\") {\n\t\t\t\t\tupdateGoalUsage(runtime.activeGoal, ctx, false);\n\t\t\t\t}\n\t\t\t\truntime.pendingQueueAction.displacedUsageFinalized = true;\n\t\t\t\tif (runtime.activeGoal) {\n\t\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\t\t}\n\t\t\t}\n\t\t\truntime.agentRunGoalId = null;\n\t\t\tif (ownedPromptGoalId) abortCurrentTurn(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (activeBudgetWrapUp && runtime.activeGoal) {\n\t\t\truntime.agentRunGoalId = runtime.activeGoal.id;\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\truntime.pendingQueueAction?.kind === \"advance\" &&\n\t\t\truntime.pendingQueueAction.goalId === runtime.activeGoal?.id\n\t\t) {\n\t\t\truntime.agentRunGoalId = ownedPromptGoalId ?? runtime.activeGoal.id;\n\t\t\tif (ownedPromptGoalId) abortCurrentTurn(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (ownedPromptGoalId && ownedPromptGoalId !== runtime.activeGoal?.id) {\n\t\t\truntime.agentRunGoalId = ownedPromptGoalId;\n\t\t\tif (runtime.activeGoal?.status === \"active\" && !goalToolsAvailable()) {\n\t\t\t\tpauseGoalForUnavailableTools(ctx, false);\n\t\t\t}\n\t\t\tabortCurrentTurn(ctx);\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal?.status !== \"active\") {\n\t\t\truntime.agentRunGoalId = undefined;\n\t\t\treturn;\n\t\t}\n\t\truntime.agentRunGoalId = runtime.activeGoal.id;\n\t\tif (!goalToolsAvailable()) {\n\t\t\tpauseGoalForUnavailableTools(ctx, ownedPromptGoalId !== undefined);\n\t\t\treturn;\n\t\t}\n\n\t\treturn {\n\t\t\tsystemPrompt: `${event.systemPrompt}\\n\\n${buildGoalSystemPrompt(runtime.activeGoal)}`,\n\t\t};\n\t});\n\n\tpi.on(\"agent_end\", (event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tconst agentRunGoalId = runtime.agentRunGoalId;\n\t\truntime.agentRunGoalId = undefined;\n\t\tif (\n\t\t\tagentRunGoalId === null ||\n\t\t\t(!runtime.canRecordGoalUsage() && !runtime.hasActiveBudgetWrapUp())\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (agentRunGoalId && agentRunGoalId !== runtime.activeGoal?.id) return;\n\t\tif (!runtime.activeGoal) return;\n\t\tif (\n\t\t\truntime.activeGoal.status === \"budget_limited\" &&\n\t\t\truntime.budgetWrapUp?.goalId === runtime.activeGoal.id\n\t\t) {\n\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\tclearBudgetWrapUp();\n\t\t\treturn;\n\t\t}\n\t\tif (runtime.activeGoal.status !== \"active\") return;\n\t\tif (\n\t\t\truntime.pendingQueueAction?.kind === \"advance\" &&\n\t\t\truntime.pendingQueueAction.goalId === runtime.activeGoal.id\n\t\t) {\n\t\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\treturn;\n\t\t}\n\n\t\tconst goalId = runtime.activeGoal.id;\n\t\tconst alreadyAwaitingContinuation = hasContinuationWorkForGoal(goalId);\n\t\tconst finalAssistant = findFinalAssistantMessage(event.messages);\n\n\t\tif (!alreadyAwaitingContinuation) runtime.activeGoal = incrementGoal(runtime.activeGoal);\n\t\tupdateGoalUsage(runtime.activeGoal, ctx);\n\n\t\tif (finalAssistant?.stopReason === \"aborted\") {\n\t\t\tclearGoalRecoveryForGoal(goalId);\n\t\t\tstopGoalAfterAgentEnd(ctx, runtime.activeGoal, finalAssistant, \"paused\");\n\t\t\treturn;\n\t\t}\n\n\t\tif (finalAssistant?.stopReason === \"error\") {\n\t\t\tif (isRetryableGoalInterruption(finalAssistant)) {\n\t\t\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\t\t\t\tif (!goalToolsAvailable()) {\n\t\t\t\t\tpauseGoalForUnavailableTools(ctx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\truntime.goalRecovery = {\n\t\t\t\t\tgoalId,\n\t\t\t\t\tkind: isGoalContextOverflow(finalAssistant) ? \"compaction_retry\" : \"provider_retry\",\n\t\t\t\t};\n\t\t\t\tcancelContinuationWork();\n\t\t\t\tpersistGoal(runtime.activeGoal);\n\t\t\t\tupdateStatus(ctx, runtime.activeGoal);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tclearGoalRecoveryForGoal(goalId);\n\t\t\tstopGoalAfterAgentEnd(\n\t\t\t\tctx,\n\t\t\t\truntime.activeGoal,\n\t\t\t\tfinalAssistant,\n\t\t\t\tisUsageLimitedGoalInterruption(finalAssistant) ? \"usage_limited\" : \"blocked\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tclearGoalRecoveryForGoal(goalId);\n\n\t\tif (limitActiveGoalForBudget(ctx, false)) return;\n\t\tif (!goalToolsAvailable()) {\n\t\t\tpauseGoalForUnavailableTools(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\n\t\tconst currentGoal = runtime.activeGoal;\n\t\tif (!currentGoal || currentGoal.id !== goalId || currentGoal.status !== \"active\") return;\n\t\tif (runtime.pendingQueueAction?.kind === \"prioritize\") return;\n\t\trequestContinuation(currentGoal);\n\t});\n\n\tpi.on(\"agent_settled\", (_event, ctx) => {\n\t\tif (runtime.queueFrozen) return;\n\t\tif (!runtime.pendingQueueAction) {\n\t\t\tdispatchContinuationIfSettled(ctx);\n\t\t\treturn;\n\t\t}\n\t\treturn dispatchPendingQueueActionIfSettled(ctx).then((dispatched) => {\n\t\t\tif (!dispatched) dispatchContinuationIfSettled(ctx);\n\t\t});\n\t});\n\n\tfunction hasPendingSkipForGoal(goalId: string) {\n\t\treturn (\n\t\t\truntime.pendingQueueAction?.kind === \"advance\" &&\n\t\t\truntime.pendingQueueAction.reason === \"skip\" &&\n\t\t\truntime.pendingQueueAction.goalId === goalId\n\t\t);\n\t}\n\n\tfunction stopGoalAfterAgentEnd(\n\t\tctx: StatusContext,\n\t\tgoal: ActiveGoal,\n\t\tassistant: AssistantMessageLike,\n\t\tstatus: \"paused\" | \"blocked\" | \"usage_limited\",\n\t) {\n\t\tcancelContinuationWork();\n\t\tclearBudgetWrapUp();\n\t\tblockStaleGoalToolCalls();\n\t\tabortCurrentTurn(ctx);\n\t\t// lunr: if the provider error carries a reset time, pre-fill resumeAfter so a\n\t\t// one-shot /cron wake-up auto-resumes the goal without a manual /goal resume.\n\t\tconst resumeAfter = status === \"usage_limited\" ? parseUsageResetTimeMs(assistant.errorMessage) : undefined;\n\t\tconst goalWithResume = resumeAfter !== undefined ? { ...goal, resumeAfter } : goal;\n\t\truntime.activeGoal = transitionGoal(goalWithResume, status);\n\t\tpersistGoal(runtime.activeGoal);\n\t\tupdateStatus(ctx, runtime.activeGoal);\n\n\t\tconst details = assistant.errorMessage\n\t\t\t? ` (${truncateNotification(assistant.errorMessage)})`\n\t\t\t: \"\";\n\t\tif (status === \"paused\") {\n\t\t\tctx.ui.notify(\n\t\t\t\t`Goal paused after interruption${details}. Run /goal resume to continue.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (status === \"usage_limited\") {\n\t\t\tconst when = resumeAfter !== undefined ? ` Auto-resume scheduled for ${new Date(resumeAfter).toLocaleString()}.` : \"\";\n\t\t\tctx.ui.notify(\n\t\t\t\t`Goal usage-limited${details}.${when} Run /goal resume when usage resets, or schedule a one-shot /cron firing \"continue\" into this session to wake it.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tctx.ui.notify(\n\t\t\t`Goal blocked after agent error${details}. Resolve the blocker or run /goal resume to retry.`,\n\t\t\t\"warning\",\n\t\t);\n\t}\n}\n\nexport default function goal(pi: ExtensionAPI, options: GoalOptions = {}) {\n\tregisterGoalRuntime(pi, options);\n}\n\nexport {\n\tassistantUsageTokens,\n\tcumulativeAssistantTokens,\n\tformatDuration,\n\tformatTokenCount,\n} from \"./accounting.js\";\n\nexport {\n\tcompleteGoalArguments,\n\tparseCommand,\n\tparseTokenBudget,\n\tvalidateObjective,\n} from \"./command.js\";\n\nexport { buildGoalSystemPrompt } from \"./prompts.js\";\n\nexport {\n\tfindFinalAssistantMessage,\n\tformatStatus,\n\tisContradictoryCompletionSummary,\n\tisRetryableGoalInterruption,\n\tisUsageLimitedGoalInterruption,\n} from \"./runtime.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/extension/schemas.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AA4H/B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;EAkB7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;EASG,CAAC;AAEpC,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;EAoBP,CAAC;AAEpC,eAAO,MAAM,oBAAoB;;;EAGE,CAAC;AAGpC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCpB,CAAC;AAwFH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA0D,CAAC;AAetF,eAAO,MAAM,kBAAkB;;;;EAA8D,CAAC","sourcesContent":["// @ts-nocheck\n/**\n * TypeBox schemas for subagent tool parameters\n */\n\nimport { Type } from \"typebox\";\n\nfunction keepTopLevelParameterDescriptions<T>(schema: T): T {\n\treturn pruneNestedDescriptions(schema, []) as T;\n}\n\nfunction pruneNestedDescriptions(value: unknown, path: string[]): unknown {\n\tif (!value || typeof value !== \"object\") return value;\n\n\tconst result = Array.isArray(value) ? [] : Object.create(Object.getPrototypeOf(value));\n\tfor (const key of Reflect.ownKeys(value)) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(value, key);\n\t\tif (!descriptor) continue;\n\t\tif (key === \"description\" && !isTopLevelParameterDescription(path)) continue;\n\t\tif (\"value\" in descriptor) {\n\t\t\tconst nextPath = typeof key === \"string\" ? [...path, key] : path;\n\t\t\tdescriptor.value = pruneNestedDescriptions(descriptor.value, nextPath);\n\t\t}\n\t\tObject.defineProperty(result, key, descriptor);\n\t}\n\treturn result;\n}\n\nfunction isTopLevelParameterDescription(path: string[]): boolean {\n\treturn path.length === 2 && path[0] === \"properties\";\n}\n\nconst SkillOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"array\", items: { type: \"string\" } },\n\t\t{ type: \"boolean\", enum: [false] },\n\t\t{ type: \"string\" },\n\t],\n\tdescription: \"Skill name(s) to make available (comma-separated), array of strings, or false to disable\",\n});\n\nconst OutputOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"string\" },\n\t\t{ type: \"boolean\", enum: [false] },\n\t],\n\tdescription: \"Output filename/path (string), or false to disable file output\",\n});\n\nconst OutputModeOverride = Type.String({\n\tenum: [\"inline\", \"file-only\"],\n\tdescription: \"Return saved output inline (default) or only a concise file reference. file-only requires output to be a path.\",\n});\n\n// lunr: required 3-tier subagent routing, resolved through the @lunr/model-tiers bridge.\nconst TierOverride = Type.String({\n\tenum: [\"light\", \"standard\", \"heavy\"],\n\tdescription: \"Required model tier: 'light' for simple/fast work, 'standard' for typical coding, or 'heavy' for complex reasoning. The configured tier model must be available and authenticated.\",\n});\n\nconst ReadsOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"array\", items: { type: \"string\" } },\n\t\t{ type: \"boolean\", enum: [false] },\n\t],\n\tdescription: \"Files to read before running (array of filenames), or false to disable\",\n});\n\nconst JsonSchemaObject = Type.Unsafe({\n\ttype: \"object\",\n\tadditionalProperties: true,\n\tdescription: \"JSON Schema object for strict structured output. Non-object roots are rejected.\",\n});\n\nconst AcceptanceOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"string\", enum: [\"auto\", \"attested\", \"checked\", \"verified\", \"reviewed\"] },\n\t\t{ type: \"boolean\", enum: [false] },\n\t\t{ type: \"object\", additionalProperties: true },\n\t],\n\tdescription: \"Optional acceptance policy. Omitted means auto-inferred; verified requires configured runtime commands. Reviewed is inferred-only because explicit runs cannot supply an independent reviewer result. Bare \\\"none\\\" requires { level: \\\"none\\\", reason: \\\"...\\\" }, while false is deprecated.\",\n});\n\nconst TurnBudgetOverride = Type.Object({\n\tmaxTurns: Type.Integer({ minimum: 1 }),\n\tgraceTurns: Type.Optional(Type.Integer({ minimum: 0 })),\n}, { additionalProperties: false, description: \"Optional assistant-turn budget. At maxTurns the child is asked to wrap up; after graceTurns additional assistant turns it is aborted and partial output is returned.\" });\n\nconst ToolBudgetBlock = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"array\", minItems: 1, items: { type: \"string\", minLength: 1 } },\n\t\t{ type: \"string\", enum: [\"*\"] },\n\t],\n});\n\nconst ToolBudgetOverride = Type.Object({\n\tsoft: Type.Optional(Type.Integer({ minimum: 1 })),\n\thard: Type.Integer({ minimum: 1 }),\n\tblock: Type.Optional(ToolBudgetBlock),\n}, { additionalProperties: false, description: \"Optional child tool-call budget. soft nudges the child; after hard, block tools (default read/grep/find/ls, or '*' for all tools) are blocked so the child can finalize.\" });\n\nconst DescriptionField = Type.String({\n\tminLength: 1,\n\tmaxLength: 80,\n\tdescription: \"Required concise single-line UI label (max 80 characters). Presentation metadata only; not used as an identifier.\",\n});\n\nconst PermissionsField = Type.Optional(Type.String({\n\tenum: [\"full\", \"read-only\"],\n\tdescription: \"Child permission level. Omit or 'full' for coding tools (read/search/shell/edit/write/web/LSP/MCP). 'read-only' inspects without edit/write. Plan-mode parents must pass 'read-only'.\",\n}));\n\nconst TaskItem = Type.Object({\n\ttask: Type.String({ description: \"Complete model-authored prompt sent to the child.\" }),\n\tdescription: DescriptionField,\n\tpermissions: PermissionsField,\n\tcwd: Type.Optional(Type.String()),\n\tcount: Type.Optional(Type.Integer({ minimum: 1, description: \"Repeat this parallel task N times with the same settings.\" })),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking for this task\" })),\n\ttier: TierOverride,\n\tskill: Type.Optional(SkillOverride),\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n});\n\n// Parallel task item (within a parallel step)\nexport const ParallelTaskSchema = Type.Object({\n\ttask: Type.Optional(Type.String({ description: \"Task template with {task}, {previous}, {chain_dir} variables. Defaults to {previous}.\" })),\n\tdescription: DescriptionField,\n\tpermissions: PermissionsField,\n\tphase: Type.Optional(Type.String({ description: \"Optional phase/group label for status and graph rendering.\" })),\n\tlabel: Type.Optional(Type.String({ description: \"Optional user-facing label for this parallel task.\" })),\n\tas: Type.Optional(Type.String({ description: \"Optional safe identifier used as {outputs.name} in later chain steps.\" })),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n\tcwd: Type.Optional(Type.String()),\n\tcount: Type.Optional(Type.Integer({ minimum: 1, description: \"Repeat this parallel task N times with the same settings.\" })),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking in {chain_dir}\" })),\n\tskill: Type.Optional(SkillOverride),\n\ttier: TierOverride,\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n});\n\nexport const DynamicExpandSchema = Type.Object({\n\tfrom: Type.Object({\n\t\toutput: Type.String({ description: \"Prior named structured output to expand from.\" }),\n\t\tpath: Type.String({ description: \"JSON Pointer into the structured output, e.g. /items.\" }),\n\t}, { additionalProperties: false }),\n\titem: Type.Optional(Type.String({ description: \"Template variable name for each item. Defaults to item.\" })),\n\tkey: Type.Optional(Type.String({ description: \"JSON Pointer relative to each item for stable child ids.\" })),\n\tmaxItems: Type.Optional(Type.Integer({ minimum: 0, description: \"Required fanout bound unless configured globally.\" })),\n\tonEmpty: Type.Optional(Type.String({ enum: [\"skip\", \"fail\"], description: \"Empty input behavior. Defaults to skip.\" })),\n}, { additionalProperties: false });\n\nexport const DynamicParallelTemplateSchema = Type.Object({\n\ttask: Type.Optional(Type.String({ description: \"Task template with {item}, {item.path}, {task}, {previous}, {chain_dir}, and {outputs.name} variables.\" })),\n\tdescription: Type.String({\n\t\tminLength: 1,\n\t\tmaxLength: 80,\n\t\tdescription: \"Required concise single-line UI label. May use the same template variables as task. Maximum 80 characters.\",\n\t}),\n\tpermissions: PermissionsField,\n\tphase: Type.Optional(Type.String({ description: \"Optional phase/group label for status and graph rendering.\" })),\n\tlabel: Type.Optional(Type.String({ description: \"Optional user-facing label; item templates are supported.\" })),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n\tcwd: Type.Optional(Type.String()),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking in {chain_dir}\" })),\n\tskill: Type.Optional(SkillOverride),\n\ttier: TierOverride,\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n}, { additionalProperties: false });\n\nexport const DynamicCollectSchema = Type.Object({\n\tas: Type.String({ description: \"Safe output name for the ordered collected result array.\" }),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n}, { additionalProperties: false });\n\n// Flattened so chain steps do not need an object-shape anyOf/oneOf union.\nexport const ChainItem = Type.Object({\n\ttask: Type.Optional(Type.String({\n\t\tdescription: \"Task template with variables: {task}=original request, {previous}=prior step's text response, {chain_dir}=shared folder, {outputs.name}=prior named output. Required for first sequential step, defaults to '{previous}' for subsequent steps.\"\n\t})),\n\tdescription: Type.Optional(DescriptionField),\n\tpermissions: PermissionsField,\n\tphase: Type.Optional(Type.String({ description: \"Optional phase/group label for status and graph rendering.\" })),\n\tlabel: Type.Optional(Type.String({ description: \"Optional user-facing label for this chain step.\" })),\n\tas: Type.Optional(Type.String({ description: \"Optional safe identifier used as {outputs.name} in later chain steps.\" })),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n\tcwd: Type.Optional(Type.String()),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking in {chain_dir}\" })),\n\tskill: Type.Optional(SkillOverride),\n\ttier: TierOverride,\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n\tparallel: Type.Optional(Type.Unsafe({\n\t\tanyOf: [\n\t\t\tType.Array(ParallelTaskSchema, { minItems: 1, description: \"Tasks to run in parallel\" }),\n\t\t\tDynamicParallelTemplateSchema,\n\t\t],\n\t\tdescription: \"Static parallel tasks array, or a single dynamic fanout child template when expand/collect are present.\",\n\t})),\n\texpand: Type.Optional(DynamicExpandSchema),\n\tcollect: Type.Optional(DynamicCollectSchema),\n\tconcurrency: Type.Optional(Type.Number({ description: \"Max concurrent tasks (default: unlimited)\" })),\n\tfailFast: Type.Optional(Type.Boolean({ description: \"Stop on first failure (default: false)\" })),\n\tworktree: Type.Optional(Type.Boolean({\n\t\tdescription: \"Create isolated git worktrees for each parallel task.\"\n\t})),\n}, {\n\tdescription: \"Chain step: use {task, description, tier, permissions?} for sequential, {parallel: [...]} for static concurrent execution, or {expand, parallel: {...}, collect} for dynamic fanout. Every executable child requires tier.\",\n\tadditionalProperties: false,\n});\n\nconst ControlOverrides = Type.Object({\n\tenabled: Type.Optional(Type.Boolean({ description: \"Enable/disable subagent control attention tracking for this run\" })),\n\tneedsAttentionAfterMs: Type.Optional(Type.Integer({ minimum: 1, description: \"No-observed-activity window before a run needs attention\" })),\n\tactiveNoticeAfterMs: Type.Optional(Type.Integer({ minimum: 1, description: \"Active-long-running notice threshold by elapsed ms (default: 240000)\" })),\n\tactiveNoticeAfterTurns: Type.Optional(Type.Integer({ minimum: 1, description: \"Optional active-long-running notice threshold by assistant turns (disabled by default)\" })),\n\tactiveNoticeAfterTokens: Type.Optional(Type.Integer({ minimum: 1, description: \"Optional active-long-running notice threshold by total tokens (disabled by default)\" })),\n\tfailedToolAttemptsBeforeAttention: Type.Optional(Type.Integer({ minimum: 1, description: \"Consecutive mutating-tool failures before escalating to needs_attention (default: 3)\" })),\n\tnotifyOn: Type.Optional(Type.Array(Type.String({ enum: [\"active_long_running\", \"needs_attention\"] }), {\n\t\tdescription: \"Control event types that should notify the parent/orchestrator. Defaults to active_long_running and needs_attention.\",\n\t})),\n\tnotifyChannels: Type.Optional(Type.Array(Type.String({ enum: [\"event\", \"async\", \"intercom\"] }), {\n\t\tdescription: \"Notification channels to use when available. Defaults to event, async, and intercom.\",\n\t})),\n});\n\nconst SubagentParamsSchema = Type.Object({\n\ttask: Type.Optional(Type.String({ description: \"Complete model-authored prompt sent to the child (SINGLE mode).\" })),\n\tdescription: Type.Optional(DescriptionField),\n\tpermissions: PermissionsField,\n\t// Control action (when present, tool operates in control mode rather than execution)\n\taction: Type.Optional(Type.String({\n\t\tdescription: \"Control action only. Must be omitted for execution mode (single, parallel, or chain). Runtime: status, interrupt, stop, resume, steer, append-step, doctor, watchdog.*, schedule*.\",\n\t})),\n\tid: Type.Optional(Type.String({\n\t\tdescription: \"Run id or prefix for action='status', action='interrupt', action='stop', action='resume', action='steer', or action='append-step'.\"\n\t})),\n\trunId: Type.Optional(Type.String({\n\t\tdescription: \"Target run ID for action='interrupt', action='stop', action='resume', action='steer', or action='append-step'. Prefer id for new calls.\"\n\t})),\n\tdir: Type.Optional(Type.String({\n\t\tdescription: \"Async run directory for action='status', action='stop', action='resume', or action='steer'.\"\n\t})),\n\tindex: Type.Optional(Type.Integer({ minimum: 0, description: \"Zero-based child index for actions that target a specific child or transcript.\" })),\n\tview: Type.Optional(Type.String({\n\t\tenum: [\"fleet\", \"transcript\"],\n\t\tdescription: \"Optional status view. Use view='fleet' for a read-only active foreground/async fleet surface, or view='transcript' with id/dir (and optional index) to tail a run transcript.\",\n\t})),\n\tlines: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: \"Maximum transcript lines for action='status', view='transcript'. Defaults to 80.\" })),\n\tmessage: Type.Optional(Type.String({ description: \"Follow-up message for action='resume' or non-terminal guidance for action='steer'. Use index to choose a child from multi-child runs.\" })),\n\tscope: Type.Optional(Type.String({ enum: [\"session\", \"user\", \"project\"], description: \"Scope for action='watchdog.configure'. Defaults to session to avoid persistent settings writes unless user/project is explicit.\" })),\n\ttarget: Type.Optional(Type.String({ enum: [\"main\", \"children\"], description: \"Target for action='watchdog.configure'. Defaults to main.\" })),\n\tthinking: Type.Optional(Type.Unsafe({ anyOf: [{ type: \"string\" }, { type: \"boolean\", enum: [false] }], description: \"Thinking level for action='watchdog.configure' (off/minimal/low/medium/high/xhigh/max, inherit, or false for off).\" })),\n\tschedule: Type.Optional(Type.String({ description: \"Explicit one-shot schedule for action='schedule'. Only honored when scheduledRuns.enabled is true. Use '+10m' or a future ISO timestamp with timezone; scheduled runs always launch async with fresh context.\" })),\n\tscheduleName: Type.Optional(Type.String({ description: \"Optional display name for action='schedule'.\" })),\n\ttasks: Type.Optional(Type.Array(TaskItem, { description: \"PARALLEL mode: [{task, description, tier, permissions?, count?, output?, outputMode?, reads?, progress?}, ...]\" })),\n\tconcurrency: Type.Optional(Type.Integer({ minimum: 1, description: \"Top-level PARALLEL mode only: max concurrent tasks. Defaults to config.parallel.concurrency or unlimited.\" })),\n\tworktree: Type.Optional(Type.Boolean({\n\t\tdescription: \"Create isolated git worktrees for parallel tasks; requires clean git state.\"\n\t})),\n\tchain: Type.Optional(Type.Array(ChainItem, { description: \"CHAIN mode: sequential steps; each result becomes {previous}. append-step takes one tail step and may use {chain_dir}/{outputs.name}.\" })),\n\tcontext: Type.Optional(Type.String({\n\t\tenum: [\"fresh\"],\n\t\tdescription: \"Children always start with a fresh session. Fork context is not available.\",\n\t})),\n\tchainDir: Type.Optional(Type.String({ description: \"Persistent chain artifact directory; defaults to user-scoped temp storage.\" })),\n\tasync: Type.Optional(Type.Boolean({ description: \"Run in background (default: false, or per config)\" })),\n\ttimeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: \"Optional run-level timeout in ms for foreground and async/background runs. Alias of maxRuntimeMs.\" })),\n\tmaxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: \"Alias of timeoutMs for optional run-level timeout in foreground and async/background runs.\" })),\n\tturnBudget: Type.Optional(TurnBudgetOverride),\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tcwd: Type.Optional(Type.String()),\n\tartifacts: Type.Optional(Type.Boolean({ description: \"Write debug artifacts (default: true)\" })),\n\tincludeProgress: Type.Optional(Type.Boolean({ description: \"Include full progress in result (default: false)\" })),\n\tshare: Type.Optional(Type.Boolean({ description: \"Upload session to GitHub Gist for sharing (default: false)\" })),\n\tsessionDir: Type.Optional(\n\t\tType.String({ description: \"Directory to store session logs (default: temp; enables sessions even if share=false)\" }),\n\t),\n\t// Clarification TUI\n\tclarify: Type.Optional(Type.Boolean({ description: \"Show TUI to preview/edit before execution. Explicit clarify: true keeps the run foreground for the clarify UI; omitted clarify can still run in the background when async: true is set.\" })),\n\tcontrol: Type.Optional(ControlOverrides),\n\toutput: Type.Optional(Type.Unsafe({\n\t\tanyOf: [\n\t\t\t{ type: \"string\" },\n\t\t\t{ type: \"boolean\", enum: [false] },\n\t\t],\n\t\tdescription: \"Output file for a single child (string), or false to disable. Relative paths resolve against cwd.\",\n\t})),\n\toutputMode: Type.Optional(OutputModeOverride),\n\tskill: Type.Optional(SkillOverride),\n\ttier: Type.Optional(Type.String({\n\t\tenum: [\"light\", \"standard\", \"heavy\"],\n\t\tdescription: \"Required for SINGLE execution. Omit for control actions; PARALLEL and CHAIN children carry their own required tier.\",\n\t})),\n\tacceptance: Type.Optional(AcceptanceOverride),\n});\n\nexport const SubagentParams = keepTopLevelParameterDescriptions(SubagentParamsSchema);\n\nconst SubagentWaitParamsSchema = Type.Object({\n\tid: Type.Optional(Type.String({\n\t\tdescription: \"Async run or remembered detached foreground run id/prefix to wait for one specific run. Omit to wait across every active async run started in this session.\",\n\t})),\n\tall: Type.Optional(Type.Boolean({\n\t\tdescription: \"Wait for ALL active runs to finish. Default false: return as soon as the first run finishes, so a fleet manager can spawn a replacement and wait again. Ignored when id targets a single run.\",\n\t})),\n\ttimeoutMs: Type.Optional(Type.Integer({\n\t\tminimum: 1,\n\t\tdescription: \"Give up waiting after this many milliseconds (the runs keep going regardless). Defaults to 1800000 (30 minutes).\",\n\t})),\n});\n\nexport const SubagentWaitParams = keepTopLevelParameterDescriptions(SubagentWaitParamsSchema);\n"]}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/extension/schemas.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAiI/B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;EAkB7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;EASG,CAAC;AAEpC,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;EAoBP,CAAC;AAEpC,eAAO,MAAM,oBAAoB;;;EAGE,CAAC;AAGpC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCpB,CAAC;AAwFH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA0D,CAAC;AAetF,eAAO,MAAM,kBAAkB;;;;EAA8D,CAAC","sourcesContent":["// @ts-nocheck\n/**\n * TypeBox schemas for subagent tool parameters\n */\n\nimport { Type } from \"typebox\";\n\nfunction keepTopLevelParameterDescriptions<T>(schema: T): T {\n\treturn pruneNestedDescriptions(schema, []) as T;\n}\n\nfunction pruneNestedDescriptions(value: unknown, path: string[]): unknown {\n\tif (!value || typeof value !== \"object\") return value;\n\n\tconst result = Array.isArray(value) ? [] : Object.create(Object.getPrototypeOf(value));\n\tfor (const key of Reflect.ownKeys(value)) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(value, key);\n\t\tif (!descriptor) continue;\n\t\t// `description` is both JSON Schema help text and the child UI-label parameter.\n\t\tif (key === \"description\" && !isPropertiesMap(path) && !isTopLevelParameterHelpText(path)) continue;\n\t\tif (\"value\" in descriptor) {\n\t\t\tconst nextPath = typeof key === \"string\" ? [...path, key] : path;\n\t\t\tdescriptor.value = pruneNestedDescriptions(descriptor.value, nextPath);\n\t\t}\n\t\tObject.defineProperty(result, key, descriptor);\n\t}\n\treturn result;\n}\n\nfunction isPropertiesMap(path: string[]): boolean {\n\treturn path[path.length - 1] === \"properties\";\n}\n\nfunction isTopLevelParameterHelpText(path: string[]): boolean {\n\treturn path.length === 2 && path[0] === \"properties\";\n}\n\nconst SkillOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"array\", items: { type: \"string\" } },\n\t\t{ type: \"boolean\", enum: [false] },\n\t\t{ type: \"string\" },\n\t],\n\tdescription: \"Skill name(s) to make available (comma-separated), array of strings, or false to disable\",\n});\n\nconst OutputOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"string\" },\n\t\t{ type: \"boolean\", enum: [false] },\n\t],\n\tdescription: \"Output filename/path (string), or false to disable file output\",\n});\n\nconst OutputModeOverride = Type.String({\n\tenum: [\"inline\", \"file-only\"],\n\tdescription: \"Return saved output inline (default) or only a concise file reference. file-only requires output to be a path.\",\n});\n\n// lunr: required 3-tier subagent routing, resolved through the @lunr/model-tiers bridge.\nconst TierOverride = Type.String({\n\tenum: [\"light\", \"standard\", \"heavy\"],\n\tdescription: \"Required model tier: 'light' for simple/fast work, 'standard' for typical coding, or 'heavy' for complex reasoning. The configured tier model must be available and authenticated.\",\n});\n\nconst ReadsOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"array\", items: { type: \"string\" } },\n\t\t{ type: \"boolean\", enum: [false] },\n\t],\n\tdescription: \"Files to read before running (array of filenames), or false to disable\",\n});\n\nconst JsonSchemaObject = Type.Unsafe({\n\ttype: \"object\",\n\tadditionalProperties: true,\n\tdescription: \"JSON Schema object for strict structured output. Non-object roots are rejected.\",\n});\n\nconst AcceptanceOverride = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"string\", enum: [\"auto\", \"attested\", \"checked\", \"verified\", \"reviewed\"] },\n\t\t{ type: \"boolean\", enum: [false] },\n\t\t{ type: \"object\", additionalProperties: true },\n\t],\n\tdescription: \"Optional acceptance policy. Omitted means auto-inferred; verified requires configured runtime commands. Reviewed is inferred-only because explicit runs cannot supply an independent reviewer result. Bare \\\"none\\\" requires { level: \\\"none\\\", reason: \\\"...\\\" }, while false is deprecated.\",\n});\n\nconst TurnBudgetOverride = Type.Object({\n\tmaxTurns: Type.Integer({ minimum: 1 }),\n\tgraceTurns: Type.Optional(Type.Integer({ minimum: 0 })),\n}, { additionalProperties: false, description: \"Optional assistant-turn budget. At maxTurns the child is asked to wrap up; after graceTurns additional assistant turns it is aborted and partial output is returned.\" });\n\nconst ToolBudgetBlock = Type.Unsafe({\n\tanyOf: [\n\t\t{ type: \"array\", minItems: 1, items: { type: \"string\", minLength: 1 } },\n\t\t{ type: \"string\", enum: [\"*\"] },\n\t],\n});\n\nconst ToolBudgetOverride = Type.Object({\n\tsoft: Type.Optional(Type.Integer({ minimum: 1 })),\n\thard: Type.Integer({ minimum: 1 }),\n\tblock: Type.Optional(ToolBudgetBlock),\n}, { additionalProperties: false, description: \"Optional child tool-call budget. soft nudges the child; after hard, block tools (default read/grep/find/ls, or '*' for all tools) are blocked so the child can finalize.\" });\n\nconst DescriptionField = Type.String({\n\tminLength: 1,\n\tmaxLength: 80,\n\tdescription: \"Required concise single-line UI label (max 80 characters). Presentation metadata only; not used as an identifier.\",\n});\n\nconst PermissionsField = Type.Optional(Type.String({\n\tenum: [\"full\", \"read-only\"],\n\tdescription: \"Child permission level. Omit or 'full' for coding tools (read/search/shell/edit/write/web/LSP/MCP). 'read-only' inspects without edit/write. Plan-mode parents must pass 'read-only'.\",\n}));\n\nconst TaskItem = Type.Object({\n\ttask: Type.String({ description: \"Complete model-authored prompt sent to the child.\" }),\n\tdescription: DescriptionField,\n\tpermissions: PermissionsField,\n\tcwd: Type.Optional(Type.String()),\n\tcount: Type.Optional(Type.Integer({ minimum: 1, description: \"Repeat this parallel task N times with the same settings.\" })),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking for this task\" })),\n\ttier: TierOverride,\n\tskill: Type.Optional(SkillOverride),\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n});\n\n// Parallel task item (within a parallel step)\nexport const ParallelTaskSchema = Type.Object({\n\ttask: Type.Optional(Type.String({ description: \"Task template with {task}, {previous}, {chain_dir} variables. Defaults to {previous}.\" })),\n\tdescription: DescriptionField,\n\tpermissions: PermissionsField,\n\tphase: Type.Optional(Type.String({ description: \"Optional phase/group label for status and graph rendering.\" })),\n\tlabel: Type.Optional(Type.String({ description: \"Optional user-facing label for this parallel task.\" })),\n\tas: Type.Optional(Type.String({ description: \"Optional safe identifier used as {outputs.name} in later chain steps.\" })),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n\tcwd: Type.Optional(Type.String()),\n\tcount: Type.Optional(Type.Integer({ minimum: 1, description: \"Repeat this parallel task N times with the same settings.\" })),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking in {chain_dir}\" })),\n\tskill: Type.Optional(SkillOverride),\n\ttier: TierOverride,\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n});\n\nexport const DynamicExpandSchema = Type.Object({\n\tfrom: Type.Object({\n\t\toutput: Type.String({ description: \"Prior named structured output to expand from.\" }),\n\t\tpath: Type.String({ description: \"JSON Pointer into the structured output, e.g. /items.\" }),\n\t}, { additionalProperties: false }),\n\titem: Type.Optional(Type.String({ description: \"Template variable name for each item. Defaults to item.\" })),\n\tkey: Type.Optional(Type.String({ description: \"JSON Pointer relative to each item for stable child ids.\" })),\n\tmaxItems: Type.Optional(Type.Integer({ minimum: 0, description: \"Required fanout bound unless configured globally.\" })),\n\tonEmpty: Type.Optional(Type.String({ enum: [\"skip\", \"fail\"], description: \"Empty input behavior. Defaults to skip.\" })),\n}, { additionalProperties: false });\n\nexport const DynamicParallelTemplateSchema = Type.Object({\n\ttask: Type.Optional(Type.String({ description: \"Task template with {item}, {item.path}, {task}, {previous}, {chain_dir}, and {outputs.name} variables.\" })),\n\tdescription: Type.String({\n\t\tminLength: 1,\n\t\tmaxLength: 80,\n\t\tdescription: \"Required concise single-line UI label. May use the same template variables as task. Maximum 80 characters.\",\n\t}),\n\tpermissions: PermissionsField,\n\tphase: Type.Optional(Type.String({ description: \"Optional phase/group label for status and graph rendering.\" })),\n\tlabel: Type.Optional(Type.String({ description: \"Optional user-facing label; item templates are supported.\" })),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n\tcwd: Type.Optional(Type.String()),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking in {chain_dir}\" })),\n\tskill: Type.Optional(SkillOverride),\n\ttier: TierOverride,\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n}, { additionalProperties: false });\n\nexport const DynamicCollectSchema = Type.Object({\n\tas: Type.String({ description: \"Safe output name for the ordered collected result array.\" }),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n}, { additionalProperties: false });\n\n// Flattened so chain steps do not need an object-shape anyOf/oneOf union.\nexport const ChainItem = Type.Object({\n\ttask: Type.Optional(Type.String({\n\t\tdescription: \"Task template with variables: {task}=original request, {previous}=prior step's text response, {chain_dir}=shared folder, {outputs.name}=prior named output. Required for first sequential step, defaults to '{previous}' for subsequent steps.\"\n\t})),\n\tdescription: Type.Optional(DescriptionField),\n\tpermissions: PermissionsField,\n\tphase: Type.Optional(Type.String({ description: \"Optional phase/group label for status and graph rendering.\" })),\n\tlabel: Type.Optional(Type.String({ description: \"Optional user-facing label for this chain step.\" })),\n\tas: Type.Optional(Type.String({ description: \"Optional safe identifier used as {outputs.name} in later chain steps.\" })),\n\toutputSchema: Type.Optional(JsonSchemaObject),\n\tcwd: Type.Optional(Type.String()),\n\toutput: Type.Optional(OutputOverride),\n\toutputMode: Type.Optional(OutputModeOverride),\n\treads: Type.Optional(ReadsOverride),\n\tprogress: Type.Optional(Type.Boolean({ description: \"Enable progress.md tracking in {chain_dir}\" })),\n\tskill: Type.Optional(SkillOverride),\n\ttier: TierOverride,\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tacceptance: Type.Optional(AcceptanceOverride),\n\tparallel: Type.Optional(Type.Unsafe({\n\t\tanyOf: [\n\t\t\tType.Array(ParallelTaskSchema, { minItems: 1, description: \"Tasks to run in parallel\" }),\n\t\t\tDynamicParallelTemplateSchema,\n\t\t],\n\t\tdescription: \"Static parallel tasks array, or a single dynamic fanout child template when expand/collect are present.\",\n\t})),\n\texpand: Type.Optional(DynamicExpandSchema),\n\tcollect: Type.Optional(DynamicCollectSchema),\n\tconcurrency: Type.Optional(Type.Number({ description: \"Max concurrent tasks (default: unlimited)\" })),\n\tfailFast: Type.Optional(Type.Boolean({ description: \"Stop on first failure (default: false)\" })),\n\tworktree: Type.Optional(Type.Boolean({\n\t\tdescription: \"Create isolated git worktrees for each parallel task.\"\n\t})),\n}, {\n\tdescription: \"Chain step: use {task, description, tier, permissions?} for sequential, {parallel: [...]} for static concurrent execution, or {expand, parallel: {...}, collect} for dynamic fanout. Every executable child requires tier.\",\n\tadditionalProperties: false,\n});\n\nconst ControlOverrides = Type.Object({\n\tenabled: Type.Optional(Type.Boolean({ description: \"Enable/disable subagent control attention tracking for this run\" })),\n\tneedsAttentionAfterMs: Type.Optional(Type.Integer({ minimum: 1, description: \"No-observed-activity window before a run needs attention\" })),\n\tactiveNoticeAfterMs: Type.Optional(Type.Integer({ minimum: 1, description: \"Active-long-running notice threshold by elapsed ms (default: 240000)\" })),\n\tactiveNoticeAfterTurns: Type.Optional(Type.Integer({ minimum: 1, description: \"Optional active-long-running notice threshold by assistant turns (disabled by default)\" })),\n\tactiveNoticeAfterTokens: Type.Optional(Type.Integer({ minimum: 1, description: \"Optional active-long-running notice threshold by total tokens (disabled by default)\" })),\n\tfailedToolAttemptsBeforeAttention: Type.Optional(Type.Integer({ minimum: 1, description: \"Consecutive mutating-tool failures before escalating to needs_attention (default: 3)\" })),\n\tnotifyOn: Type.Optional(Type.Array(Type.String({ enum: [\"active_long_running\", \"needs_attention\"] }), {\n\t\tdescription: \"Control event types that should notify the parent/orchestrator. Defaults to active_long_running and needs_attention.\",\n\t})),\n\tnotifyChannels: Type.Optional(Type.Array(Type.String({ enum: [\"event\", \"async\", \"intercom\"] }), {\n\t\tdescription: \"Notification channels to use when available. Defaults to event, async, and intercom.\",\n\t})),\n});\n\nconst SubagentParamsSchema = Type.Object({\n\ttask: Type.Optional(Type.String({ description: \"Complete model-authored prompt sent to the child (SINGLE mode).\" })),\n\tdescription: Type.Optional(DescriptionField),\n\tpermissions: PermissionsField,\n\t// Control action (when present, tool operates in control mode rather than execution)\n\taction: Type.Optional(Type.String({\n\t\tdescription: \"Control action only. Must be omitted for execution mode (single, parallel, or chain). Runtime: status, interrupt, stop, resume, steer, append-step, doctor, watchdog.*, schedule*.\",\n\t})),\n\tid: Type.Optional(Type.String({\n\t\tdescription: \"Run id or prefix for action='status', action='interrupt', action='stop', action='resume', action='steer', or action='append-step'.\"\n\t})),\n\trunId: Type.Optional(Type.String({\n\t\tdescription: \"Target run ID for action='interrupt', action='stop', action='resume', action='steer', or action='append-step'. Prefer id for new calls.\"\n\t})),\n\tdir: Type.Optional(Type.String({\n\t\tdescription: \"Async run directory for action='status', action='stop', action='resume', or action='steer'.\"\n\t})),\n\tindex: Type.Optional(Type.Integer({ minimum: 0, description: \"Zero-based child index for actions that target a specific child or transcript.\" })),\n\tview: Type.Optional(Type.String({\n\t\tenum: [\"fleet\", \"transcript\"],\n\t\tdescription: \"Optional status view. Use view='fleet' for a read-only active foreground/async fleet surface, or view='transcript' with id/dir (and optional index) to tail a run transcript.\",\n\t})),\n\tlines: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: \"Maximum transcript lines for action='status', view='transcript'. Defaults to 80.\" })),\n\tmessage: Type.Optional(Type.String({ description: \"Follow-up message for action='resume' or non-terminal guidance for action='steer'. Use index to choose a child from multi-child runs.\" })),\n\tscope: Type.Optional(Type.String({ enum: [\"session\", \"user\", \"project\"], description: \"Scope for action='watchdog.configure'. Defaults to session to avoid persistent settings writes unless user/project is explicit.\" })),\n\ttarget: Type.Optional(Type.String({ enum: [\"main\", \"children\"], description: \"Target for action='watchdog.configure'. Defaults to main.\" })),\n\tthinking: Type.Optional(Type.Unsafe({ anyOf: [{ type: \"string\" }, { type: \"boolean\", enum: [false] }], description: \"Thinking level for action='watchdog.configure' (off/minimal/low/medium/high/xhigh/max, inherit, or false for off).\" })),\n\tschedule: Type.Optional(Type.String({ description: \"Explicit one-shot schedule for action='schedule'. Only honored when scheduledRuns.enabled is true. Use '+10m' or a future ISO timestamp with timezone; scheduled runs always launch async with fresh context.\" })),\n\tscheduleName: Type.Optional(Type.String({ description: \"Optional display name for action='schedule'.\" })),\n\ttasks: Type.Optional(Type.Array(TaskItem, { description: \"PARALLEL mode: [{task, description, tier, permissions?, count?, output?, outputMode?, reads?, progress?}, ...]\" })),\n\tconcurrency: Type.Optional(Type.Integer({ minimum: 1, description: \"Top-level PARALLEL mode only: max concurrent tasks. Defaults to config.parallel.concurrency or unlimited.\" })),\n\tworktree: Type.Optional(Type.Boolean({\n\t\tdescription: \"Create isolated git worktrees for parallel tasks; requires clean git state.\"\n\t})),\n\tchain: Type.Optional(Type.Array(ChainItem, { description: \"CHAIN mode: sequential steps; each result becomes {previous}. append-step takes one tail step and may use {chain_dir}/{outputs.name}.\" })),\n\tcontext: Type.Optional(Type.String({\n\t\tenum: [\"fresh\"],\n\t\tdescription: \"Children always start with a fresh session. Fork context is not available.\",\n\t})),\n\tchainDir: Type.Optional(Type.String({ description: \"Persistent chain artifact directory; defaults to user-scoped temp storage.\" })),\n\tasync: Type.Optional(Type.Boolean({ description: \"Run in background (default: false, or per config)\" })),\n\ttimeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: \"Optional run-level timeout in ms for foreground and async/background runs. Alias of maxRuntimeMs.\" })),\n\tmaxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: \"Alias of timeoutMs for optional run-level timeout in foreground and async/background runs.\" })),\n\tturnBudget: Type.Optional(TurnBudgetOverride),\n\ttoolBudget: Type.Optional(ToolBudgetOverride),\n\tcwd: Type.Optional(Type.String()),\n\tartifacts: Type.Optional(Type.Boolean({ description: \"Write debug artifacts (default: true)\" })),\n\tincludeProgress: Type.Optional(Type.Boolean({ description: \"Include full progress in result (default: false)\" })),\n\tshare: Type.Optional(Type.Boolean({ description: \"Upload session to GitHub Gist for sharing (default: false)\" })),\n\tsessionDir: Type.Optional(\n\t\tType.String({ description: \"Directory to store session logs (default: temp; enables sessions even if share=false)\" }),\n\t),\n\t// Clarification TUI\n\tclarify: Type.Optional(Type.Boolean({ description: \"Show TUI to preview/edit before execution. Explicit clarify: true keeps the run foreground for the clarify UI; omitted clarify can still run in the background when async: true is set.\" })),\n\tcontrol: Type.Optional(ControlOverrides),\n\toutput: Type.Optional(Type.Unsafe({\n\t\tanyOf: [\n\t\t\t{ type: \"string\" },\n\t\t\t{ type: \"boolean\", enum: [false] },\n\t\t],\n\t\tdescription: \"Output file for a single child (string), or false to disable. Relative paths resolve against cwd.\",\n\t})),\n\toutputMode: Type.Optional(OutputModeOverride),\n\tskill: Type.Optional(SkillOverride),\n\ttier: Type.Optional(Type.String({\n\t\tenum: [\"light\", \"standard\", \"heavy\"],\n\t\tdescription: \"Required for SINGLE execution. Omit for control actions; PARALLEL and CHAIN children carry their own required tier.\",\n\t})),\n\tacceptance: Type.Optional(AcceptanceOverride),\n});\n\nexport const SubagentParams = keepTopLevelParameterDescriptions(SubagentParamsSchema);\n\nconst SubagentWaitParamsSchema = Type.Object({\n\tid: Type.Optional(Type.String({\n\t\tdescription: \"Async run or remembered detached foreground run id/prefix to wait for one specific run. Omit to wait across every active async run started in this session.\",\n\t})),\n\tall: Type.Optional(Type.Boolean({\n\t\tdescription: \"Wait for ALL active runs to finish. Default false: return as soon as the first run finishes, so a fleet manager can spawn a replacement and wait again. Ignored when id targets a single run.\",\n\t})),\n\ttimeoutMs: Type.Optional(Type.Integer({\n\t\tminimum: 1,\n\t\tdescription: \"Give up waiting after this many milliseconds (the runs keep going regardless). Defaults to 1800000 (30 minutes).\",\n\t})),\n});\n\nexport const SubagentWaitParams = keepTopLevelParameterDescriptions(SubagentWaitParamsSchema);\n"]}
@@ -14,7 +14,8 @@ function pruneNestedDescriptions(value, path) {
14
14
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
15
15
  if (!descriptor)
16
16
  continue;
17
- if (key === "description" && !isTopLevelParameterDescription(path))
17
+ // `description` is both JSON Schema help text and the child UI-label parameter.
18
+ if (key === "description" && !isPropertiesMap(path) && !isTopLevelParameterHelpText(path))
18
19
  continue;
19
20
  if ("value" in descriptor) {
20
21
  const nextPath = typeof key === "string" ? [...path, key] : path;
@@ -24,7 +25,10 @@ function pruneNestedDescriptions(value, path) {
24
25
  }
25
26
  return result;
26
27
  }
27
- function isTopLevelParameterDescription(path) {
28
+ function isPropertiesMap(path) {
29
+ return path[path.length - 1] === "properties";
30
+ }
31
+ function isTopLevelParameterHelpText(path) {
28
32
  return path.length === 2 && path[0] === "properties";
29
33
  }
30
34
  const SkillOverride = Type.Unsafe({