@caupulican/pi-adaptative 0.81.35 → 0.81.38

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 (169) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +10 -8
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/agent-session.d.ts +5 -0
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +17 -0
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  11. package/dist/core/autonomy/approval-gate.js +2 -0
  12. package/dist/core/autonomy/approval-gate.js.map +1 -1
  13. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  14. package/dist/core/autonomy/foreground-envelope.js +2 -0
  15. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  16. package/dist/core/autonomy/gates.d.ts.map +1 -1
  17. package/dist/core/autonomy/gates.js +9 -2
  18. package/dist/core/autonomy/gates.js.map +1 -1
  19. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  20. package/dist/core/autonomy/risk-assessment.js +2 -0
  21. package/dist/core/autonomy/risk-assessment.js.map +1 -1
  22. package/dist/core/background-lane-controller.d.ts.map +1 -1
  23. package/dist/core/background-lane-controller.js +1 -1
  24. package/dist/core/background-lane-controller.js.map +1 -1
  25. package/dist/core/bash-execution-controller.d.ts +9 -4
  26. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  27. package/dist/core/bash-execution-controller.js +7 -6
  28. package/dist/core/bash-execution-controller.js.map +1 -1
  29. package/dist/core/bash-executor.d.ts +2 -0
  30. package/dist/core/bash-executor.d.ts.map +1 -1
  31. package/dist/core/bash-executor.js +3 -2
  32. package/dist/core/bash-executor.js.map +1 -1
  33. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  34. package/dist/core/context/sqlite-runtime-index.js +13 -7
  35. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  36. package/dist/core/default-tool-surface.d.ts +7 -0
  37. package/dist/core/default-tool-surface.d.ts.map +1 -1
  38. package/dist/core/default-tool-surface.js +29 -10
  39. package/dist/core/default-tool-surface.js.map +1 -1
  40. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  41. package/dist/core/delegation/worker-actions.js +1 -1
  42. package/dist/core/delegation/worker-actions.js.map +1 -1
  43. package/dist/core/doctor.d.ts +10 -10
  44. package/dist/core/doctor.d.ts.map +1 -1
  45. package/dist/core/doctor.js +30 -20
  46. package/dist/core/doctor.js.map +1 -1
  47. package/dist/core/exec.d.ts +2 -0
  48. package/dist/core/exec.d.ts.map +1 -1
  49. package/dist/core/exec.js +1 -0
  50. package/dist/core/exec.js.map +1 -1
  51. package/dist/core/extensions/loader.d.ts.map +1 -1
  52. package/dist/core/extensions/loader.js +3 -7
  53. package/dist/core/extensions/loader.js.map +1 -1
  54. package/dist/core/extensions/types.d.ts +13 -3
  55. package/dist/core/extensions/types.d.ts.map +1 -1
  56. package/dist/core/extensions/types.js +3 -0
  57. package/dist/core/extensions/types.js.map +1 -1
  58. package/dist/core/memory/memory-manager.d.ts.map +1 -1
  59. package/dist/core/memory/memory-manager.js +1 -0
  60. package/dist/core/memory/memory-manager.js.map +1 -1
  61. package/dist/core/model-capability.d.ts.map +1 -1
  62. package/dist/core/model-capability.js +2 -0
  63. package/dist/core/model-capability.js.map +1 -1
  64. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  65. package/dist/core/model-router/tool-escalation.js +17 -3
  66. package/dist/core/model-router/tool-escalation.js.map +1 -1
  67. package/dist/core/models/local-runtime.d.ts.map +1 -1
  68. package/dist/core/models/local-runtime.js +4 -3
  69. package/dist/core/models/local-runtime.js.map +1 -1
  70. package/dist/core/python-runtime.d.ts +46 -0
  71. package/dist/core/python-runtime.d.ts.map +1 -0
  72. package/dist/core/python-runtime.js +157 -0
  73. package/dist/core/python-runtime.js.map +1 -0
  74. package/dist/core/runtime-builder.d.ts +4 -0
  75. package/dist/core/runtime-builder.d.ts.map +1 -1
  76. package/dist/core/runtime-builder.js +31 -9
  77. package/dist/core/runtime-builder.js.map +1 -1
  78. package/dist/core/security/untrusted-boundary.d.ts +2 -2
  79. package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
  80. package/dist/core/security/untrusted-boundary.js +4 -3
  81. package/dist/core/security/untrusted-boundary.js.map +1 -1
  82. package/dist/core/settings-manager.d.ts.map +1 -1
  83. package/dist/core/settings-manager.js +2 -0
  84. package/dist/core/settings-manager.js.map +1 -1
  85. package/dist/core/slash-commands.d.ts.map +1 -1
  86. package/dist/core/slash-commands.js +8 -0
  87. package/dist/core/slash-commands.js.map +1 -1
  88. package/dist/core/system-prompt.d.ts.map +1 -1
  89. package/dist/core/system-prompt.js +13 -2
  90. package/dist/core/system-prompt.js.map +1 -1
  91. package/dist/core/tasks/session-task-state.d.ts +10 -0
  92. package/dist/core/tasks/session-task-state.d.ts.map +1 -0
  93. package/dist/core/tasks/session-task-state.js +29 -0
  94. package/dist/core/tasks/session-task-state.js.map +1 -0
  95. package/dist/core/tasks/task-command.d.ts +30 -0
  96. package/dist/core/tasks/task-command.d.ts.map +1 -0
  97. package/dist/core/tasks/task-command.js +79 -0
  98. package/dist/core/tasks/task-command.js.map +1 -0
  99. package/dist/core/tasks/task-state.d.ts +71 -0
  100. package/dist/core/tasks/task-state.d.ts.map +1 -0
  101. package/dist/core/tasks/task-state.js +372 -0
  102. package/dist/core/tasks/task-state.js.map +1 -0
  103. package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
  104. package/dist/core/tool-selection/tool-selection-controller.js +1 -1
  105. package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
  106. package/dist/core/tools/bash.d.ts +20 -2
  107. package/dist/core/tools/bash.d.ts.map +1 -1
  108. package/dist/core/tools/bash.js +124 -199
  109. package/dist/core/tools/bash.js.map +1 -1
  110. package/dist/core/tools/find.d.ts.map +1 -1
  111. package/dist/core/tools/find.js +55 -44
  112. package/dist/core/tools/find.js.map +1 -1
  113. package/dist/core/tools/grep.d.ts.map +1 -1
  114. package/dist/core/tools/grep.js +8 -4
  115. package/dist/core/tools/grep.js.map +1 -1
  116. package/dist/core/tools/index.d.ts +9 -6
  117. package/dist/core/tools/index.d.ts.map +1 -1
  118. package/dist/core/tools/index.js +24 -9
  119. package/dist/core/tools/index.js.map +1 -1
  120. package/dist/core/tools/python.d.ts +64 -0
  121. package/dist/core/tools/python.d.ts.map +1 -0
  122. package/dist/core/tools/python.js +241 -0
  123. package/dist/core/tools/python.js.map +1 -0
  124. package/dist/core/tools/render-utils.d.ts.map +1 -1
  125. package/dist/core/tools/render-utils.js +1 -1
  126. package/dist/core/tools/render-utils.js.map +1 -1
  127. package/dist/core/tools/shell-contract-router.d.ts +13 -0
  128. package/dist/core/tools/shell-contract-router.d.ts.map +1 -0
  129. package/dist/core/tools/shell-contract-router.js +330 -0
  130. package/dist/core/tools/shell-contract-router.js.map +1 -0
  131. package/dist/core/tools/task-steps.d.ts +46 -0
  132. package/dist/core/tools/task-steps.d.ts.map +1 -0
  133. package/dist/core/tools/task-steps.js +160 -0
  134. package/dist/core/tools/task-steps.js.map +1 -0
  135. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  136. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  137. package/dist/modes/interactive/interactive-mode.js +12 -0
  138. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  139. package/dist/modes/interactive/session-flow-commands.d.ts +10 -0
  140. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  141. package/dist/modes/interactive/session-flow-commands.js +43 -0
  142. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  143. package/dist/utils/shell.d.ts +6 -8
  144. package/dist/utils/shell.d.ts.map +1 -1
  145. package/dist/utils/shell.js +75 -69
  146. package/dist/utils/shell.js.map +1 -1
  147. package/dist/utils/tools-manager.d.ts +23 -3
  148. package/dist/utils/tools-manager.d.ts.map +1 -1
  149. package/dist/utils/tools-manager.js +94 -11
  150. package/dist/utils/tools-manager.js.map +1 -1
  151. package/docs/development.md +2 -0
  152. package/docs/index.md +2 -0
  153. package/docs/packages.md +1 -1
  154. package/docs/python.md +43 -0
  155. package/docs/settings.md +9 -5
  156. package/docs/task-steps.md +90 -0
  157. package/docs/termux.md +7 -0
  158. package/docs/usage.md +5 -6
  159. package/docs/windows.md +15 -12
  160. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  161. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  162. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  163. package/examples/extensions/sandbox/package-lock.json +2 -2
  164. package/examples/extensions/sandbox/package.json +1 -1
  165. package/examples/extensions/with-deps/package-lock.json +2 -2
  166. package/examples/extensions/with-deps/package.json +1 -1
  167. package/npm-shrinkwrap.json +32 -37
  168. package/package.json +9 -7
  169. package/scripts/postinstall-python-runtime.mjs +20 -0
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../../src/core/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAcpD,OAAO,EAEN,eAAe,EACf,oCAAoC,EACpC,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EAEf,cAAc,EACd,sBAAsB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAKN,sBAAsB,EACtB,OAAO,EACP,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EAEjB,aAAa,GACb,MAAM,gCAAgC,CAAC;AAmBxC,OAAO,EACN,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,0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IAAI,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAAA,CAC9D;IAED,4BAA4B,GAA2B;QACtD,MAAM,OAAO,GAAG,MAAM,CAAC,gBAAgB,CACtC,EAAE,EACF,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,CACpD,CAAC;QAC5B,OAAO,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrF,OAAO,CAAC,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACvF,OAAO,OAAO,CAAC;IAAA,CACf;IAED;;OAEG;IACH,oBAAoB,CAAC,SAAiB,EAAW;QAChD,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAAA,CACpD;IAED;;OAEG;IACH,IAAI,eAAe,GAAoB;QACtC,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAAA,CAC7B;CACD;AAED,SAAS,wBAAwB,CAAC,QAAwB,EAAgC;IACzF,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAClC,OAAO,OAAO,CAAC;QAChB,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAAA,CACjB","sourcesContent":["import { readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\nimport type {\n\tAgent,\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tClassifiedError,\n\tStreamFn,\n\tStreamIdleOptions,\n\tThinkingLevel,\n} from \"@caupulican/pi-agent-core\";\nimport {\n\ttype CustomMessage,\n\tclassifyFailure,\n\tcompactToolResultDetailsForRetention,\n\tcomputeRetryDelayMs,\n\tcreateCustomMessage,\n\tDEFAULT_RETRY_POLICY,\n\tDEFAULT_STREAM_IDLE,\n\tRetryController,\n\ttype RetryPolicy,\n\tsleepAbortable,\n\twithStreamIdleWatchdog,\n} from \"@caupulican/pi-agent-core\";\nimport {\n\ttype BranchSummaryEntry,\n\ttype CompactionEntry,\n\ttype CompactionResult,\n\ttype CompactionSettings,\n\tcalculateContextTokens,\n\tcompact,\n\tcreateDeterministicCompaction,\n\testimateContextTokens,\n\tgetLatestCompactionEntry,\n\tprepareCompaction,\n\trunCompactionLoop,\n\ttype SessionManager,\n\tshouldCompact,\n} from \"@caupulican/pi-agent-core/node\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tCacheRetention,\n\tContext,\n\tImageContent,\n\tMessage,\n\tModel,\n\tSimpleStreamOptions,\n\tStopReason,\n\tTextContent,\n\tTextToolProtocolParseEvent,\n\tTextToolProtocolVariant,\n\tTool,\n\tToolArgumentValidationTelemetryEvent,\n\tToolRepairModeName,\n\tUsage,\n} from \"@caupulican/pi-ai\";\nimport {\n\tcleanupSessionResources,\n\tformatToolRepairStandingRule,\n\tgenerateTextToolProtocolPrimer,\n\tgetSupportedThinkingLevels,\n\tisContextOverflow,\n\tmodelsAreEqual,\n\tparseTextToolCalls,\n\tstreamSimple,\n} from \"@caupulican/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getAgentDir } from \"../config.ts\";\nimport { stripFrontmatter } from \"../utils/frontmatter.ts\";\nimport { getProcessWorkRun } from \"../utils/work-directory.ts\";\nimport { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from \"./auth-guidance.ts\";\nimport type {\n\tCapabilityEnvelope,\n\tEvidenceBundle,\n\tGateOutcome,\n\tLearningDecision,\n\tRouteDecision,\n\tWorkerRequest,\n\tWorkerResult,\n} from \"./autonomy/contracts.ts\";\nimport { buildForegroundEnvelope, formatForegroundEnvelopeObservation } from \"./autonomy/foreground-envelope.ts\";\nimport { evaluateToolGate } from \"./autonomy/gates.ts\";\nimport type { LaneRecord, LaneTerminalStatus } from \"./autonomy/lane-tracker.ts\";\nimport type { AutonomyDiagnosticSnapshot, AutonomyStatusSnapshot, GateOutcomeHistoryEntry } from \"./autonomy/status.ts\";\nimport type { AutonomyTelemetryEvent } from \"./autonomy/telemetry-events.ts\";\nimport { AutonomyTelemetry } from \"./autonomy-telemetry.ts\";\nimport { BackgroundLaneController } from \"./background-lane-controller.ts\";\nimport { BashExecutionController } from \"./bash-execution-controller.ts\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport { BillingFailoverController, ExhaustedProviderRegistry } from \"./billing-failover-controller.ts\";\nimport { CompactionSupport } from \"./compaction-support.ts\";\n// (module-scope helper for curation goal extraction defined below the imports)\nimport type { CurationTelemetrySnapshot } from \"./context/brain-curator.ts\";\nimport type { ArtifactStore } from \"./context/context-artifacts.ts\";\nimport type { ContextAuditReport } from \"./context/context-audit.ts\";\nimport {\n\tbuildContextCompositionReport,\n\ttype ContextCompositionReport,\n\tformatContextCompositionDashboard,\n} from \"./context/context-composition.ts\";\nimport type { PromptEnforcementReport } from \"./context/context-prompt-enforcement.ts\";\nimport type { PromptPolicyGcCorrelationReport, PromptPolicyShadowReport } from \"./context/context-prompt-policy.ts\";\nimport type { MemoryPromptInclusionReport } from \"./context/memory-diagnostics.ts\";\nimport type { MemoryProvider as ContextMemoryProvider } from \"./context/memory-provider-contract.ts\";\nimport type { MemoryRetrievalReport } from \"./context/memory-retrieval.ts\";\nimport type { ContextGcReport } from \"./context-gc.ts\";\nimport { ContextPipeline } from \"./context-pipeline.ts\";\nimport type { SessionCostSummary } from \"./cost/cost-summary.ts\";\nimport type { DailyUsageTotals } from \"./cost/daily-usage.ts\";\nimport { type CostGuardDecision, downgradeReasoning, estimateTurnCostUsd, evaluateCostGuard } from \"./cost-guard.ts\";\nimport { appendWorkerResultSnapshot, getWorkerResultSnapshots } from \"./delegation/session-worker-result.ts\";\nimport type { WorkerRunOutcome } from \"./delegation/worker-runner.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionErrorListener,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tInputSource,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tReplacedSessionContext,\n\tSessionBeforeCompactResult,\n\tSessionStartEvent,\n\tShutdownHandler,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tTurnEndEvent,\n\tTurnStartEvent,\n} from \"./extensions/index.ts\";\nimport { FailureCorpusRecorder } from \"./failure-corpus.ts\";\nimport { type ChannelProvider, GatewayRegistry, type JobSchedulerProvider } from \"./gateways/channel-provider.ts\";\nimport { GoalLoopController } from \"./goal-loop-controller.ts\";\nimport type { GoalContinuationPrompt, GoalContinuationPromptLimits } from \"./goals/goal-continuation-prompt.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goals/goal-runtime-snapshot.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport { appendGoalStateSnapshot, getLatestGoalStateSnapshot } from \"./goals/session-goal-state.ts\";\nimport { constrainStreamIdleToHttpTimeout } from \"./http-dispatcher.ts\";\nimport type { LearningAuditRecord } from \"./learning/learning-audit.ts\";\nimport type { DemandSignals, ReflectionResult } from \"./learning/reflection-engine.ts\";\nimport { appendLearningDecisionSnapshot, getLearningDecisionSnapshots } from \"./learning/session-learning-decision.ts\";\nimport { type CurationProposals, isPromotedFrontmatter, SkillCurator } from \"./learning/skill-curator.ts\";\nimport { LocalRuntimeController } from \"./local-runtime-controller.ts\";\nimport type { MemoryProvider } from \"./memory/memory-provider.ts\";\nimport { MemoryController } from \"./memory-controller.ts\";\nimport {\n\tderiveModelCapabilityProfile,\n\tfilterToolNamesForCapability,\n\ttype ModelCapabilityProfile,\n} from \"./model-capability.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport { formatModelRouterModel, ModelRouterController } from \"./model-router-controller.ts\";\nimport { ModelSelectionController } from \"./model-selection-controller.ts\";\nimport { ModelAdaptationStore, type ModelToolProbe, type NativeToolProbeGrade } from \"./models/adaptation-store.ts\";\nimport type { StoredFitnessReport } from \"./models/fitness-store.ts\";\nimport { HF_TRANSFORMERS_PROVIDER, OLLAMA_PROVIDER } from \"./models/local-registration.ts\";\nimport type { LocalRuntimeDeps, OllamaRuntime, TransformersRuntime } from \"./models/local-runtime.ts\";\nimport {\n\tDEFAULT_ADAPTIVE_STREAM_IDLE_CEILING_MS,\n\testimateContextPromptTokens,\n\tresolveAdaptiveStreamIdleOptions,\n\twithModelPerfProfile,\n} from \"./models/perf-profile.ts\";\nimport { ProfileFilterController } from \"./profile-filter-controller.ts\";\nimport { expandPromptTemplate, type PromptTemplate } from \"./prompt-templates.ts\";\nimport { ReflectionController } from \"./reflection-controller.ts\";\nimport type { ModelFitnessReport } from \"./research/model-fitness.ts\";\nimport type { ResearchRunResult } from \"./research/research-runner.ts\";\nimport {\n\tappendEvidenceBundleSnapshot,\n\tgetEvidenceBundleSnapshots,\n\tgetLatestEvidenceBundleSnapshot,\n} from \"./research/session-evidence-bundle.ts\";\nimport { collectWorkspaceSources } from \"./research/workspace-collector.ts\";\nimport type { ResourceExtensionPaths, ResourceLoader } from \"./resource-loader.ts\";\nimport { stripResourceProfileBlocks } from \"./resource-profile-blocks.ts\";\nimport { RuntimeBuilder } from \"./runtime-builder.ts\";\nimport { SessionAnalytics, type ToolArgumentValidationStats } from \"./session-analytics.ts\";\nimport { SessionTreeNavigator } from \"./session-tree-navigator.ts\";\nimport type { ResourceProfileFilterSettings, SettingsManager } from \"./settings-manager.ts\";\nimport type { SlashCommandInfo } from \"./slash-commands.ts\";\nimport { SystemPromptBuilder } from \"./system-prompt-builder.ts\";\nimport { ToolGateController } from \"./tool-gate-controller.ts\";\nimport { TOOL_RECOVERY_EVENT_LOG_FILE } from \"./tool-recovery-log-records.ts\";\nimport { ToolRecoveryLogger } from \"./tool-recovery-logger.ts\";\nimport { formatToolRepairHealthReport } from \"./tool-repair-health.ts\";\nimport { resolveCurrentToolRepairSettings } from \"./tool-repair-settings.ts\";\nimport { ToolPerformanceStore } from \"./tool-selection/tool-performance-store.ts\";\nimport { ToolSelectionController } from \"./tool-selection/tool-selection-controller.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\n\n// ============================================================================\n// Stream-idle watchdog wiring\n// ============================================================================\n\n/**\n * Marks a watchdog-wrapped stream fn whose inner base was the raw `streamSimple`.\n *\n * The session tests `streamFn === streamSimple` in three places to decide whether it must\n * inject request auth explicitly (the raw-provider path used in tests and no-key setups).\n * Wrapping the fn with the idle watchdog breaks that identity, so the wrapper carries this\n * marker and those checks go through `_isRawStreamSimple` instead. `Symbol.for` keeps the\n * key stable regardless of how many times this module is evaluated.\n */\nconst RAW_STREAM_MARKER = Symbol.for(\"pi.rawStreamSimple\");\nconst MODEL_ADAPTATION_REPAIR_THRESHOLD = 3;\nconst TEXT_TOOL_PROTOCOL_VERSION = 1;\nconst TEXT_TOOL_PROTOCOL_TRIALS_PER_VARIANT = 2;\nconst TEXT_TOOL_PROTOCOL_PARSE_FAILURE_THRESHOLD = 3;\nconst TEXT_TOOL_PROTOCOL_VARIANTS: readonly TextToolProtocolVariant[] = [\n\t\"tool-tag\",\n\t\"tool-call\",\n\t\"fenced-json\",\n\t\"function-xml\",\n];\nconst TEXT_TOOL_PROTOCOL_ECHO_TOOL = {\n\tname: \"echo\",\n\tdescription: \"Echo calibration data\",\n\tparameters: Type.Object({ data: Type.String() }),\n} satisfies Tool;\nconst NATIVE_TOOL_PROBE_READ_TOOL = {\n\tname: \"read\",\n\tdescription: \"Read file contents\",\n\tparameters: Type.Object({ path: Type.String() }),\n} satisfies Tool;\n\n/** Test-only override of the stream-idle bounds. Read per-request by the wiring's resolver. */\nlet streamIdleOptionsOverride: Partial<StreamIdleOptions> | undefined;\n\n/**\n * Test hook: override the stream-idle bounds so a stall can be provoked in-suite without a\n * multi-minute wait. Pass `undefined` to restore the user-locked defaults (connect 120s /\n * active 180s / quiet 600s, or the user's retry.stall settings). Applies per request — it\n * may be set or changed at any time before the request that should observe it.\n */\nexport function setStreamIdleOptionsForTests(opts: Partial<StreamIdleOptions> | undefined): void {\n\tstreamIdleOptionsOverride = opts;\n}\n\n/**\n * Tag a watchdog-wrapped stream fn with whether its inner base was the raw `streamSimple`,\n * so `_isRawStreamSimple` can see the raw-provider path through the wrapper.\n */\nfunction tagRawness(wrapped: StreamFn, innerIsRawStreamSimple: boolean): StreamFn {\n\tObject.defineProperty(wrapped, RAW_STREAM_MARKER, { value: innerIsRawStreamSimple });\n\treturn wrapped;\n}\n\n// ============================================================================\n// Skill Block Parsing\n// ============================================================================\n\n/** Parsed skill block from a user message */\nexport interface ParsedSkillBlock {\n\tname: string;\n\tlocation: string;\n\tcontent: string;\n\tuserMessage: string | undefined;\n}\n\n/**\n * Parse a skill block from message text.\n * Returns null if the text doesn't contain a skill block.\n */\nexport function parseSkillBlock(text: string): ParsedSkillBlock | null {\n\tconst match = text.match(/^<skill name=\"([^\"]+)\" location=\"([^\"]+)\">\\n([\\s\\S]*?)\\n<\\/skill>(?:\\n\\n([\\s\\S]+))?$/);\n\tif (!match) return null;\n\treturn {\n\t\tname: match[1],\n\t\tlocation: match[2],\n\t\tcontent: match[3],\n\t\tuserMessage: match[4]?.trim() || undefined,\n\t};\n}\n\n/** Session-specific events that extend the core AgentEvent */\nexport type AgentSessionEvent =\n\t| Exclude<AgentEvent, { type: \"agent_end\" }>\n\t| {\n\t\t\ttype: \"agent_end\";\n\t\t\tmessages: AgentMessage[];\n\t\t\twillRetry: boolean;\n\t }\n\t| {\n\t\t\ttype: \"queue_update\";\n\t\t\tsteering: readonly string[];\n\t\t\tfollowUp: readonly string[];\n\t\t\tcommands: readonly string[];\n\t }\n\t| { type: \"compaction_start\"; reason: \"manual\" | \"threshold\" | \"overflow\" }\n\t| { type: \"session_info_changed\"; name: string | undefined }\n\t| { type: \"thinking_level_changed\"; level: ThinkingLevel }\n\t| { type: \"warning\"; message: string }\n\t| {\n\t\t\ttype: \"compaction_end\";\n\t\t\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t\t\tresult: CompactionResult | undefined;\n\t\t\taborted: boolean;\n\t\t\twillRetry: boolean;\n\t\t\terrorMessage?: string;\n\t\t\t/**\n\t\t\t * Benign no-op explanation for auto-compaction (e.g. \"nothing to compact yet\"). Auto\n\t\t\t * bails must never be silent: without a result, either errorMessage (real failure) or\n\t\t\t * skipReason (harmless skip) is set so the UI can show why nothing changed.\n\t\t\t */\n\t\t\tskipReason?: string;\n\t }\n\t| { type: \"auto_retry_start\"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }\n\t| { type: \"auto_retry_end\"; success: boolean; attempt: number; finalError?: string }\n\t// Brackets the routing/prep phase of a turn (judge + model/auth checks + compaction, etc.) — the\n\t// gap between the user's prompt painting and the turn actually starting to stream, which today\n\t// has no visible feedback. UI-only: no persistence, no bearing on the turn itself. Always paired\n\t// exactly once per _promptUnserialized attempt that reaches past the early-return paths (queued\n\t// steer/followUp, extension commands, input-transform) — never emitted for those.\n\t| { type: \"routing_start\" }\n\t| { type: \"routing_end\" }\n\t| {\n\t\t\ttype: \"delegate_workers\";\n\t\t\tactive: number;\n\t\t\tqueued: number;\n\t\t\trunning: number;\n\t\t\tcompletedSinceFlush: number;\n\t\t\tfailedSinceFlush: number;\n\t\t\tterminalSinceFlush: Array<{\n\t\t\t\tlaneId: string;\n\t\t\t\tstatus: LaneTerminalStatus;\n\t\t\t\treasonCode?: string;\n\t\t\t}>;\n\t };\n\n/** Listener function for agent session events */\nexport type AgentSessionEventListener = (event: AgentSessionEvent) => void;\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface AgentSessionConfig {\n\tagent: Agent;\n\tsessionManager: SessionManager;\n\tsettingsManager: SettingsManager;\n\tcwd: string;\n\t/** User-level agent state directory for generated runtime artifacts. */\n\tagentDir?: string;\n\t/** Models to cycle through with Ctrl+P (from --models flag) */\n\tscopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\t/** Resource loader for skills, prompts, themes, context files, system prompt */\n\tresourceLoader: ResourceLoader;\n\t/** SDK custom tools registered outside extensions */\n\tcustomTools?: ToolDefinition[];\n\t/** Model registry for API key resolution and model discovery */\n\tmodelRegistry: ModelRegistry;\n\t/** Initial active built-in tool names. Default: [read, bash, edit, write, context_audit, goal] */\n\tinitialActiveToolNames?: string[];\n\t/** Optional allowlist of tool names. When provided, only these tool names are exposed. */\n\tallowedToolNames?: string[];\n\t/** Optional denylist of tool names. When provided, these tool names are not exposed. */\n\texcludedToolNames?: string[];\n\t/** Optional resource-profile allow/block filters for tool names. */\n\ttoolProfileFilter?: ResourceProfileFilterSettings;\n\t/**\n\t * Whether the model/thinking level came from an explicit launch flag. When false, the active\n\t * profile's model/thinking is re-applied on reload() so live profile edits take effect; when\n\t * true, the explicit launch-time choice is preserved.\n\t */\n\tisExplicitModel?: boolean;\n\tisExplicitThinking?: boolean;\n\t/** True when this session is a spawned subagent/child — gates durable memory writes. */\n\tisChildSession?: boolean;\n\t/**\n\t * Override base tools (useful for custom runtimes).\n\t *\n\t * These are synthesized into minimal ToolDefinitions internally so AgentSession can keep\n\t * a definition-first registry even when callers provide plain AgentTool instances.\n\t */\n\tbaseToolsOverride?: Record<string, AgentTool>;\n\t/** Mutable ref used by Agent to access the current ExtensionRunner */\n\textensionRunnerRef?: { current?: ExtensionRunner };\n\t/** Session start event metadata emitted when extensions bind to this runtime. */\n\tsessionStartEvent?: SessionStartEvent;\n\t/**\n\t * Pointer-first workspace source collector for the autonomous research lane. Injected in unit\n\t * tests so they don't spawn a real ripgrep child (which would escape fake timers); production\n\t * defaults to the real, best-effort collector.\n\t */\n\tcollectWorkspaceSources?: typeof collectWorkspaceSources;\n\t/**\n\t * Injected fetch/spawn/exists for the local (Ollama) runtime health-check + boot used by the\n\t * model router before a turn routed to a local model (see LocalRuntimeController.ensureLocalModelReady).\n\t * Unit tests inject fakes so they never hit a real network/process; production defaults to the real ones.\n\t */\n\tlocalRuntimeDeps?: LocalRuntimeDeps;\n}\n\nexport interface ExtensionBindings {\n\tuiContext?: ExtensionUIContext;\n\tmode?: ExtensionContext[\"mode\"];\n\tcommandContextActions?: ExtensionCommandContextActions;\n\tabortHandler?: () => void;\n\tshutdownHandler?: ShutdownHandler;\n\tonError?: ExtensionErrorListener;\n}\n\n/** Options for AgentSession.prompt() */\nexport interface PromptOptions {\n\t/** Whether to expand file-based prompt templates and skills (default: true). */\n\texpandPromptTemplates?: boolean;\n\t/** Whether slash commands should be handled before sending to the model. Defaults to expandPromptTemplates. */\n\tprocessSlashCommands?: boolean;\n\t/** Image attachments */\n\timages?: ImageContent[];\n\t/** When streaming, how to queue the message: \"steer\" (interrupt) or \"followUp\" (wait). Required if streaming. */\n\tstreamingBehavior?: \"steer\" | \"followUp\";\n\t/** Source of input for extension input event handlers. Defaults to \"interactive\". */\n\tsource?: InputSource;\n\t/** Internal hook used by RPC mode to observe prompt preflight acceptance or rejection. */\n\tpreflightResult?: (success: boolean) => void;\n\t/** Whether an idle active goal should auto-inject bounded continuation prompts after this prompt settles. Default: true. */\n\tautoContinueGoal?: boolean;\n}\n\nexport type ToolProbeVerdict = \"native\" | \"text-protocol\" | \"none\";\n\nexport interface ToolProbeResult {\n\tmodel: string;\n\tverdict: ToolProbeVerdict;\n\tvariant?: TextToolProtocolVariant;\n\tnativeGrade?: NativeToolProbeGrade;\n\tdiagnostic?: string;\n}\n\nexport interface ToolProbeReport {\n\tresults: ToolProbeResult[];\n\ttable: string;\n}\n\n/** Result from cycleModel() */\nexport interface ModelCycleResult {\n\tmodel: Model<any>;\n\tthinkingLevel: ThinkingLevel;\n\t/** Whether cycling through scoped models (--models flag) or all available */\n\tisScoped: boolean;\n}\n\n/** Session statistics for /session command */\nexport interface CompactionGateStats {\n\tgateFailures: number;\n\tdeterministicGapFills: number;\n\tcompactionsWithGateFailures: number;\n}\n\nexport interface SessionStats {\n\tsessionFile: string | undefined;\n\tsessionId: string;\n\tuserMessages: number;\n\tassistantMessages: number;\n\ttoolCalls: number;\n\ttoolResults: number;\n\ttotalMessages: number;\n\ttokens: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n\tcost: number;\n\tcontextUsage?: ContextUsage;\n\ttoolArgumentValidation: ToolArgumentValidationStats;\n\tcompactionGates: CompactionGateStats;\n}\n\n/** customType for spawned-usage roll-up entries (Cost Aggregation, Model A). */\nexport const SPAWNED_USAGE_CUSTOM_TYPE = \"spawned_usage\";\n\n/**\n * A single spawned/subagent usage report, persisted as a `CustomEntry`\n * (`customType: \"spawned_usage\"`). Persistence-only — does NOT enter LLM context.\n *\n * Single-hop invariant: each report MUST already include the reporter's own usage AND its\n * accumulated sub-usage. A child rolls up its grandchildren, then reports once to its direct\n * parent. Only the direct parent records the report — never a grandparent — so cost cannot be\n * double-counted across levels.\n */\nexport interface SpawnedUsageReport {\n\t/** Cumulative usage attributed to the spawned session (own + its own sub-usage). */\n\tusage: Usage;\n\t/** Human-readable source label for diagnostics (e.g. subagent name). */\n\tlabel?: string;\n\t/** Session id of the reporting child, if known. */\n\tsourceSessionId?: string;\n\t/** Stable id used to de-duplicate re-reports (retries, double agent_end). */\n\treportId?: string;\n}\n\n/** Aggregated spawned-usage totals derived from `spawned_usage` custom entries. */\nexport interface SpawnedUsageTotals {\n\t/** Summed `usage.cost.total` across all recorded reports. */\n\tcost: number;\n\t/** Number of distinct reports recorded. */\n\treports: number;\n}\n\n/**\n * Options for {@link AgentSession.runIsolatedCompletion} — an LLM call fully isolated from the main\n * session. With no tools it is one-shot (reflection); lane callers may supply a bounded child loop.\n */\nexport interface IsolatedCompletionOptions {\n\t/** System prompt for the isolated call. */\n\tsystemPrompt: string;\n\t/** The isolated conversation (e.g. the reflection prompt). NOT the main session history. */\n\tmessages: Message[];\n\t/** Model to use. Defaults to the session model; callers should pass a cheap model. */\n\tmodel?: Model<any>;\n\t/** Thinking level. Defaults to \"off\" to keep the call cheap. */\n\tthinkingLevel?: ThinkingLevel;\n\t/** Output token cap. */\n\tmaxTokens?: number;\n\t/** Fresh tools owned by the isolated child. Omitted/empty preserves one-shot behavior. */\n\ttools?: AgentTool[];\n\t/** Maximum assistant turns for a tool-enabled child loop. Ignored by one-shot calls. */\n\tmaxTurns?: number;\n\t/**\n\t * Optional tool-free finalization prompt. When the bounded child loop exhausts its turns on an\n\t * assistant tool-call message with no text, one final provider call receives the gathered transcript\n\t * plus this prompt so useful work is not discarded solely for lacking a terminal summary.\n\t */\n\tfinalTextPrompt?: string;\n\t/** Child-only capability/path gate. Never inherited from the foreground session. */\n\tbeforeToolCall?: AgentLoopConfig[\"beforeToolCall\"];\n\t/** Child-only result observer (for example, successful scoped-write accounting). */\n\tafterToolCall?: AgentLoopConfig[\"afterToolCall\"];\n\t/** Abort signal. */\n\tsignal?: AbortSignal;\n\t/**\n\t * Prompt-cache retention for this isolated call. Defaults to `\"none\"` (no caching — preserves full\n\t * isolation). Callers whose `systemPrompt` is STATIC across calls (e.g. reflection, #33) can pass\n\t * `\"short\"`/`\"long\"` so the provider reuses the cached prefix and bills only the variable tail.\n\t */\n\tcacheRetention?: CacheRetention;\n}\n\n/** Result of an isolated completion: the text, the usage spent, and the stop reason. */\nexport interface IsolatedCompletionResult {\n\ttext: string;\n\tusage: Usage;\n\tstopReason: StopReason;\n}\n\nexport interface ResearchLaneRunOutcome {\n\t/** False when the pass was skipped before starting (see skipReason). */\n\tstarted: boolean;\n\tskipReason?: string;\n\t/** Terminal lane record when the pass ran. */\n\trecord?: LaneRecord;\n\tresult?: ResearchRunResult;\n}\n\nexport interface WorkerDelegationRunOutcome {\n\t/** False when the delegation was skipped before starting (see skipReason). */\n\tstarted: boolean;\n\tskipReason?: string;\n\t/** Terminal lane record when the delegation ran. */\n\trecord?: LaneRecord;\n\toutcome?: WorkerRunOutcome;\n}\n\nexport interface GoalContinuationOnceOptions {\n\tmaxStallTurns: number;\n\tpromptLimits?: GoalContinuationPromptLimits;\n}\n\nexport interface GoalContinuationOnceResult {\n\tsubmitted: boolean;\n\tsnapshot: GoalRuntimeSnapshot;\n\tprompt?: GoalContinuationPrompt;\n}\n\nexport type GoalContinuationLoopStopReason =\n\t| \"continuation_not_allowed\"\n\t| \"max_turns_reached\"\n\t| \"wall_clock_budget_reached\"\n\t| \"goal_state_not_advanced\";\n\nexport interface GoalContinuationLoopOptions extends GoalContinuationOnceOptions {\n\tmaxTurns: number;\n\t/** 0 or undefined disables wall-clock budget. */\n\tmaxWallClockMinutes?: number;\n\t/** Test seam for wall-clock budget enforcement. Defaults to Date.now. */\n\tnow?: () => number;\n}\n\nexport interface GoalContinuationLoopResult {\n\tturnsSubmitted: number;\n\tstopReason: GoalContinuationLoopStopReason;\n\tfinalSnapshot: GoalRuntimeSnapshot;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n// ============================================================================\n// AgentSession Class\n// ============================================================================\n\nexport class AgentSession {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\tpublic capabilityEnvelope?: CapabilityEnvelope;\n\n\tprivate _scopedModels: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\n\t// Event subscription state\n\tprivate _unsubscribeAgent?: () => void;\n\tprivate _eventListeners: AgentSessionEventListener[] = [];\n\tprivate _extensionsChangedListeners: Array<() => void> = [];\n\n\tprivate _steeringMessages: string[] = [];\n\tprivate _followUpMessages: string[] = [];\n\tprivate _queuedExtensionCommands: string[] = [];\n\tprivate _pendingNextTurnMessages: CustomMessage[] = [];\n\tprivate _streamingPromptSubmissionTail: Promise<void> = Promise.resolve();\n\t/**\n\t * The last tool set requested via setActiveToolsByName BEFORE model-capability filtering, so\n\t * switching from a small-window model back to a large one restores the full requested set.\n\t */\n\tprivate _requestedActiveToolNames: string[] | undefined;\n\n\tprivate _compactionAbortController: AbortController | undefined = undefined;\n\tprivate _autoCompactionAbortController: AbortController | undefined = undefined;\n\tprivate _overflowRecoveryAttempted = false;\n\tprivate _unboundToolGrantWarnings: string[] = [];\n\n\tprivate _branchSummaryAbortController: AbortController | undefined = undefined;\n\n\tprivate _retryController!: RetryController;\n\n\tprivate readonly _modelSelection: ModelSelectionController;\n\tprivate readonly _bash: BashExecutionController;\n\tprivate readonly _profileFilter: ProfileFilterController;\n\tprivate readonly _toolGate: ToolGateController;\n\tprivate readonly _toolSelection: ToolSelectionController;\n\n\tprivate _extensionRunner!: ExtensionRunner;\n\tprivate _turnIndex = 0;\n\tprivate _currentForegroundEnvelope?: CapabilityEnvelope;\n\n\tprivate _resourceLoader: ResourceLoader;\n\tprivate _customTools: ToolDefinition[];\n\tprivate _cwd: string;\n\tprivate _agentDir: string;\n\tprivate _collectWorkspaceSources: typeof collectWorkspaceSources;\n\tprivate readonly _localRuntimeController: LocalRuntimeController;\n\tprivate readonly _modelAdaptationStore: ModelAdaptationStore;\n\tprivate _prefixWarmer:\n\t\t| { modelKey: string; controller: AbortController; timer: NodeJS.Timeout | undefined }\n\t\t| undefined;\n\tprivate readonly _completedPrefixWarms = new Set<string>();\n\tprivate readonly _repairModeSessionCounts = new Map<string, number>();\n\tprivate readonly _textProtocolParseFailures = new Map<string, { signature: string; repeats: number }>();\n\tprivate _textProtocolParseObservedThisTurn = false;\n\tprivate _textProtocolValidationOutcomeThisTurn: TextToolProtocolParseEvent | undefined;\n\t/** Assembles the session's base system prompt from live session state (see\n\t * system-prompt-builder.ts); owns the paired _baseSystemPromptOptions. */\n\tprivate readonly _systemPromptBuilder: SystemPromptBuilder;\n\t/** G3/G8 autonomy telemetry sink + status/diagnostic snapshots (see autonomy-telemetry.ts); owns\n\t * the latest gate outcome and the bounded gate-outcome history. */\n\tprivate readonly _autonomyTelemetry: AutonomyTelemetry;\n\t/** Goal auto-continue + research lane + scout-worker delegation + model-fitness probe (see\n\t * background-lane-controller.ts); owns the lane timers/guards, the last research-lane skip\n\t * reason, the live LaneTracker, and the in-flight research/worker abort controllers. */\n\tprivate readonly _backgroundLanes: BackgroundLaneController;\n\t/** Plug-and-play memory subsystem (see memory-controller.ts); owns the OKF retrieval provider, the\n\t * latest retrieval/prompt-inclusion reports, the reload-safe MemoryManager, the recall\n\t * effectiveness tracker, and the extension-contributed pending providers. */\n\tprivate readonly _memory: MemoryController;\n\tprivate readonly _compactionSupport: CompactionSupport;\n\t/** Per-turn context-shaping subsystem (see context-pipeline.ts); owns the latest\n\t * audit/policy/correlation/enforcement/gc reports, the brain-curation sidecar + its skip reasons,\n\t * and the tool-output artifact store. Invoked stage-by-stage from the context transform. */\n\tprivate readonly _pipeline: ContextPipeline;\n\tprivate _extensionRunnerRef?: { current?: ExtensionRunner };\n\tprivate _initialActiveToolNames?: string[];\n\tprivate _allowedToolNames?: Set<string>;\n\tprivate _excludedToolNames?: Set<string>;\n\tprivate _toolProfileFilter?: Required<ResourceProfileFilterSettings>;\n\tprivate readonly _isExplicitModel: boolean;\n\tprivate readonly _isExplicitThinking: boolean;\n\tprivate readonly _gatewayRegistry = new GatewayRegistry();\n\t/** Usage/cost/stats accounting, /context estimate, and session export (see session-analytics.ts);\n\t * owns the spawned-usage and daily-usage memo caches. */\n\tprivate readonly _analytics: SessionAnalytics;\n\tprivate readonly _treeNavigator: SessionTreeNavigator;\n\tprivate _lastCostGuardDecision?: CostGuardDecision;\n\t/** Per-turn model-router subsystem (see model-router-controller.ts); owns the transient route/intent,\n\t * the cheap-turn session buffer, the escalation/retry flags, and the sticky last-decision/skip-reason\n\t * used by the status report. Its parallel routed drive path delegates every turn back to\n\t * {@link _runAgentPrompt} so the drive loop stays host-side. */\n\tprivate readonly _modelRouter: ModelRouterController;\n\tprivate readonly _billingFailover: BillingFailoverController;\n\tprivate readonly _failureCorpus: FailureCorpusRecorder;\n\tprivate readonly _toolRecoveryLogger: ToolRecoveryLogger;\n\tprivate readonly _toolRecoveryEventLogPath: string;\n\tprivate _skillCuratorInstance?: SkillCurator;\n\tprivate _disposed = false;\n\tprivate readonly _reflectionAbort = new AbortController();\n\t/** Native reflection engine + learning-apply/rollback path (see reflection-controller.ts); owns no\n\t * session state, applies durable writes through the bundled memory tool and the session log. */\n\tprivate readonly _reflection: ReflectionController;\n\t/** Bounded goal auto-continuation loop (see goal-loop-controller.ts); reads goal state fresh\n\t * each pass and re-enters the session's own prompt path. */\n\tprivate readonly _goalContinuation: GoalLoopController;\n\tprivate readonly _isChildSession: boolean;\n\tprivate _baseToolsOverride?: Record<string, AgentTool>;\n\tprivate _sessionStartEvent: SessionStartEvent;\n\tprivate _extensionUIContext?: ExtensionUIContext;\n\tprivate _extensionMode: ExtensionContext[\"mode\"] = \"print\";\n\tprivate _extensionCommandContextActions?: ExtensionCommandContextActions;\n\tprivate _extensionAbortHandler?: () => void;\n\tprivate _extensionShutdownHandler?: ShutdownHandler;\n\tprivate _extensionErrorListener?: ExtensionErrorListener;\n\tprivate _extensionErrorUnsubscriber?: () => void;\n\n\tprivate _modelRegistry: ModelRegistry;\n\n\t/** Tool-registry assembly + the self-modification-safe extension reload (see runtime-builder.ts);\n\t * owns the base/wrapped tool definitions, the live tool registry, and the per-tool prompt\n\t * snippet/guideline maps. The reload snapshot spans host/agent state reached through its deps. */\n\tprivate readonly _runtimeBuilder: RuntimeBuilder;\n\n\t// Base system prompt (without extension appends) - used to apply fresh appends each turn.\n\t// The paired _baseSystemPromptOptions and their construction live in SystemPromptBuilder.\n\tprivate _baseSystemPrompt = \"\";\n\n\tconstructor(config: AgentSessionConfig) {\n\t\tthis.agent = config.agent;\n\t\t// Bound every provider stream this session starts against a silently dead connection: a\n\t\t// stall aborts the inner request and surfaces as a retryable \"stream stalled\" error, which\n\t\t// _isRetryableError routes into the existing auto-retry path. Wrapped exactly once, here.\n\t\t// The wrapper reports the stall immediately and aborts the inner request; releasing the\n\t\t// inner pump relies on the provider ending its stream after abort (real providers do — see\n\t\t// withStreamIdleWatchdog's contract), so no extra drain is added at this wiring site.\n\t\t// Wrapping also breaks the `streamFn === streamSimple` identity the auth-injection checks\n\t\t// use, so the wrapper carries a rawness marker that _isRawStreamSimple reads.\n\t\tconst agentDir = config.agentDir ?? getAgentDir();\n\t\tconst modelAdaptationStore = ModelAdaptationStore.forAgentDir(agentDir);\n\t\tconst baseStreamFn = this.agent.streamFn;\n\t\tconst previousResolveRequestReasoning = this.agent.resolveRequestReasoning?.bind(this.agent);\n\t\tthis.agent.resolveRequestReasoning = (reasoning, request) => {\n\t\t\tconst resolvedReasoning = previousResolveRequestReasoning\n\t\t\t\t? previousResolveRequestReasoning(reasoning, request)\n\t\t\t\t: reasoning;\n\t\t\treturn this._resolveCostGuardRequestReasoning(\n\t\t\t\trequest.model,\n\t\t\t\trequest.context,\n\t\t\t\tresolvedReasoning,\n\t\t\t\trequest.maxTokens,\n\t\t\t);\n\t\t};\n\t\tconst profiledStreamFn = withModelPerfProfile(baseStreamFn, {\n\t\t\tmodelKey: (model) => formatModelRouterModel(model),\n\t\t\trecordSample: (modelKey, sample) => {\n\t\t\t\tmodelAdaptationStore.recordPerfSample(modelKey, sample);\n\t\t\t},\n\t\t});\n\t\t// `this.settingsManager` is assigned below; the resolver closes over the config reference\n\t\t// because the wrapper must be installed before that assignment runs.\n\t\tconst stallSettingsSource = config.settingsManager;\n\t\tthis.agent.streamFn = tagRawness(\n\t\t\twithStreamIdleWatchdog(profiledStreamFn, (model, context) => {\n\t\t\t\tconst configured = {\n\t\t\t\t\t...stallSettingsSource.getStreamStallSettings(),\n\t\t\t\t\t...streamIdleOptionsOverride,\n\t\t\t\t};\n\t\t\t\tconst httpIdleTimeoutMs = stallSettingsSource.getHttpIdleTimeoutMs();\n\t\t\t\tconst httpBounded = constrainStreamIdleToHttpTimeout(\n\t\t\t\t\t{ ...DEFAULT_STREAM_IDLE, ...configured },\n\t\t\t\t\thttpIdleTimeoutMs,\n\t\t\t\t);\n\t\t\t\tconst profile = modelAdaptationStore.get(formatModelRouterModel(model)).perf;\n\t\t\t\tconst adaptive = resolveAdaptiveStreamIdleOptions({\n\t\t\t\t\tbase: httpBounded.options,\n\t\t\t\t\tprofile,\n\t\t\t\t\tpromptTokens: estimateContextPromptTokens(context),\n\t\t\t\t\tlocalClass: this._isWarmableLocalModel(model),\n\t\t\t\t\tceilingMs: httpBounded.adaptiveCeilingMs ?? DEFAULT_ADAPTIVE_STREAM_IDLE_CEILING_MS,\n\t\t\t\t});\n\t\t\t\treturn { ...httpBounded.options, ...adaptive };\n\t\t\t}),\n\t\t\tbaseStreamFn === streamSimple,\n\t\t);\n\t\tthis.sessionManager = config.sessionManager;\n\t\tthis.settingsManager = config.settingsManager;\n\t\t// Auto-retry rides the reliability kernel: the controller owns the attempt counter and the\n\t\t// abortable backoff. This session maps its retry settings onto a RetryPolicy, bridges the\n\t\t// controller's events onto the session event stream, and supplies the live context window so\n\t\t// the overflow-aware classifier can route overflow to compaction instead of a pointless retry.\n\t\tthis._retryController = new RetryController(\n\t\t\tthis.agent,\n\t\t\t() => {\n\t\t\t\tconst retry = this.settingsManager.getRetrySettings();\n\t\t\t\treturn {\n\t\t\t\t\tenabled: retry.enabled,\n\t\t\t\t\tmaxAttempts: retry.maxRetries,\n\t\t\t\t\tbaseDelayMs: retry.baseDelayMs,\n\t\t\t\t\tmaxDelayMs: DEFAULT_RETRY_POLICY.maxDelayMs,\n\t\t\t\t\tjitterRatio: 0,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{\n\t\t\t\tonRetryStart: (info) => this._emit({ type: \"auto_retry_start\", ...info }),\n\t\t\t\tonRetryEnd: (info) => this._emit({ type: \"auto_retry_end\", ...info }),\n\t\t\t},\n\t\t\t() => this.model?.contextWindow ?? 0,\n\t\t);\n\t\tthis._scopedModels = config.scopedModels ?? [];\n\t\tthis._resourceLoader = config.resourceLoader;\n\t\tthis._customTools = config.customTools ?? [];\n\t\tthis._cwd = config.cwd;\n\t\tthis._agentDir = agentDir;\n\t\tthis._modelAdaptationStore = modelAdaptationStore;\n\t\tthis.agent.onTextToolProtocolParse = (event) => this._handleTextToolProtocolParse(event);\n\t\tthis._applyToolRepairLayerSettings();\n\t\tthis._collectWorkspaceSources = config.collectWorkspaceSources ?? collectWorkspaceSources;\n\t\tthis._localRuntimeController = new LocalRuntimeController({\n\t\t\tagentDir: this._agentDir,\n\t\t\tlocalRuntimeDeps: config.localRuntimeDeps,\n\t\t\tgetLastAssistantMessage: () => this._findLastAssistantMessage(),\n\t\t\tgetUIContext: () => this._extensionUIContext,\n\t\t\temit: (event) => this._emit(event),\n\t\t\tresolveConfiguredTierModel: (tier) => this._modelRouter.resolveConfiguredTierModel(tier),\n\t\t\tformatModel: (model) => formatModelRouterModel(model),\n\t\t});\n\t\tthis._systemPromptBuilder = new SystemPromptBuilder({\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetResourceLoader: () => this._resourceLoader,\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\thasTool: (name) => this._runtimeBuilder.hasTool(name),\n\t\t\tgetToolPromptSnippet: (name) => this._runtimeBuilder.getToolPromptSnippet(name),\n\t\t\tgetToolPromptGuidelines: (name) => this._runtimeBuilder.getToolPromptGuidelines(name),\n\t\t\tgetModelAdaptationRules: () => this._getModelAdaptationRulesForPrompt(),\n\t\t\tgetActiveExtensions: () => this._extensionRunner.activeExtensions,\n\t\t\tgetContextWindow: () => this.model?.contextWindow,\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t});\n\t\tthis._autonomyTelemetry = new AutonomyTelemetry({\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetLastModelRouterDecision: () => this._modelRouter.getLastDecision(),\n\t\t\tgetLastResearchLaneSkipReason: () => this._backgroundLanes.getLastResearchLaneSkipReason(),\n\t\t\tgetCostSummary: () => this.getCostSummary(),\n\t\t\tgetGoalStateSnapshot: () => this.getGoalStateSnapshot(),\n\t\t\tgetActiveLaneCount: () => this._backgroundLanes.getActiveLaneCount(),\n\t\t\tgetEvidenceBundleSnapshots: () => this.getEvidenceBundleSnapshots(),\n\t\t\tgetWorkerResultSnapshots: () => this.getWorkerResultSnapshots(),\n\t\t\tgetLearningDecisionSnapshots: () => this.getLearningDecisionSnapshots(),\n\t\t\tgetLearningAuditRecords: () => this.getLearningAuditRecords(),\n\t\t});\n\t\tthis._modelRegistry = config.modelRegistry;\n\t\tthis._backgroundLanes = new BackgroundLaneController({\n\t\t\tisDisposed: () => this._disposed,\n\t\t\tisChildSession: () => this._isChildSession,\n\t\t\tgetSessionId: () => this.sessionId,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisModelExhausted: (model) => this._billingFailover.isExhausted(`${model.provider}/${model.id}`),\n\t\t\tgetModel: () => this.model ?? undefined,\n\t\t\tisDelegateToolActive: () => this.getActiveToolNames().includes(\"delegate\"),\n\t\t\tgetCapabilityEnvelope: () => this.capabilityEnvelope,\n\t\t\tgetModelCapabilityProfile: () => this.getModelCapabilityProfile(),\n\t\t\temit: (event) => this._emit(event),\n\t\t\tnotifyWorkerTerminalHandoff: (records) => this._notifyWorkerTerminalHandoff(records),\n\t\t\temitAutonomyTelemetry: (event) => this._emitAutonomyTelemetry(event),\n\t\t\tgetGoalStateSnapshot: () => this.getGoalStateSnapshot(),\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getGoalRuntimeSnapshot(settings),\n\t\t\tgetEvidenceBundleSnapshot: () => this.getEvidenceBundleSnapshot(),\n\t\t\tsaveEvidenceBundleSnapshot: (bundle) => this.saveEvidenceBundleSnapshot(bundle),\n\t\t\tsaveWorkerResultSnapshot: (result, request) => this.saveWorkerResultSnapshot(result, request),\n\t\t\treadMemoryForLane: (query) => this._memory.readMemoryForLane(query),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t\tcontinueGoalLoop: (options) => this.continueGoalLoop(options),\n\t\t\tcollectWorkspaceSources: (args) => this._collectWorkspaceSources(args),\n\t\t});\n\t\tthis._memory = new MemoryController({\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetTurnIndex: () => this._turnIndex,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetSessionId: () => this.sessionManager.getSessionId(),\n\t\t\tisChildSession: () => this._isChildSession,\n\t\t\trefreshToolRegistry: () => this._refreshToolRegistry(),\n\t\t\tgetContextWindow: () => this.model?.contextWindow,\n\t\t\tgetGoalState: () => this.getGoalStateSnapshot(),\n\t\t});\n\t\tthis._compactionSupport = new CompactionSupport({\n\t\t\tgetModel: () => this.model,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisRawStream: () => this._isRawStreamSimple(this.agent.streamFn),\n\t\t\tgetRequiredRequestAuth: (model) => this._getRequiredRequestAuth(model),\n\t\t\tisModelExhausted: (ref) => this._billingFailover.isExhausted(ref),\n\t\t\tgetStoredFitnessReport: (ref) => this.getStoredFitnessReports().find((entry) => entry.model === ref)?.report,\n\t\t\t// Live context is an over-estimate of the span to summarize (includes the kept tail) —\n\t\t\t// conservative in the safe direction for the summarizer capacity check.\n\t\t\testimateSummarizationInputTokens: () => this._pipeline.estimateCurrentContextTokens(this.agent.state.messages),\n\t\t\temitWarning: (message) => this._emit({ type: \"warning\", message }),\n\t\t});\n\t\tthis._pipeline = new ContextPipeline({\n\t\t\tgetTurnIndex: () => this._turnIndex,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetActiveToolNames: () => this.getActiveToolNames(),\n\t\t\tisDisposed: () => this._disposed,\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t});\n\t\tconst failureCorpusPath = join(this._agentDir, \"state\", \"failure-corpus.jsonl\");\n\t\tthis._toolRecoveryEventLogPath = join(this._agentDir, \"state\", TOOL_RECOVERY_EVENT_LOG_FILE);\n\t\tconst toolRepairSettings = this._toolRepairSettings();\n\t\tthis._failureCorpus = new FailureCorpusRecorder({\n\t\t\tfilePath: failureCorpusPath,\n\t\t});\n\t\tthis._toolRecoveryLogger = new ToolRecoveryLogger({\n\t\t\tenabled: toolRepairSettings.logging,\n\t\t\tsessionId: this.sessionManager.getSessionId(),\n\t\t\teventLogPath: this._toolRecoveryEventLogPath,\n\t\t\tfailureCorpusPath,\n\t\t});\n\t\tthis._billingFailover = new BillingFailoverController({\n\t\t\tagent: this.agent,\n\t\t\tmodelRegistry: this._modelRegistry,\n\t\t\texhausted: new ExhaustedProviderRegistry(),\n\t\t\tsubscriptionHop: this.settingsManager.getFailoverSettings().subscriptionHop,\n\t\t\temit: (event) => this._emit(event),\n\t\t\trecordFailure: (args) => this._failureCorpus.record(args),\n\t\t});\n\t\tthis._modelRouter = new ModelRouterController({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetModel: () => this.model ?? undefined,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisModelExhausted: (model) => this._billingFailover.isExhausted(`${model.provider}/${model.id}`),\n\t\t\tgetFailoverStatus: () => ({ ...this._billingFailover.getStatus(), failureStats: this._failureCorpus.stats() }),\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetReflectionSignal: () => this._reflectionAbort.signal,\n\t\t\tgetBaseSystemPrompt: () => this._baseSystemPrompt,\n\t\t\trunAgentPrompt: (messages) => this._runAgentPrompt(messages),\n\t\t\tbuildSystemPromptForToolNames: (toolNames) => this._buildSystemPromptForToolNames(toolNames),\n\t\t\trefreshCurrentModelFromRegistry: () => this._refreshCurrentModelFromRegistry(),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\temit: (event) => this._emit(event),\n\t\t\temitAutonomyTelemetry: (event) => this._emitAutonomyTelemetry(event),\n\t\t\tresolveLaneModel: (pattern) => this._backgroundLanes.resolveLaneModel(pattern),\n\t\t\tresolveCurationModelIfFit: () => this._resolveCurationModelIfFit(),\n\t\t});\n\t\tthis._reflection = new ReflectionController({\n\t\t\tgetModel: () => this.model,\n\t\t\tgetAgent: () => this.agent,\n\t\t\tisRawStreamSimple: () => this._isRawStreamSimple(this.agent.streamFn),\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tisChildSession: () => this._isChildSession,\n\t\t\tisDisposed: () => this._disposed,\n\t\t\tgetReflectionSignal: () => this._reflectionAbort.signal,\n\t\t\tresolveTextToolCallProtocol: (model) => this._textProtocolFlag(model),\n\t\t\tarchivePromotedSkill: (name) => this.archivePromotedSkill(name),\n\t\t\temitAutonomyTelemetry: (event) => this._emitAutonomyTelemetry(event),\n\t\t\tensureModelReady: (model) => this._localRuntimeController.ensureIsolatedModelReady(model),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\tsaveLearningDecisionSnapshot: (decision) => this.saveLearningDecisionSnapshot(decision),\n\t\t});\n\t\tthis._goalContinuation = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getGoalRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.prompt(text, options),\n\t\t});\n\t\tthis._extensionRunnerRef = config.extensionRunnerRef;\n\t\tthis._initialActiveToolNames = config.initialActiveToolNames;\n\t\tthis._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;\n\t\tthis._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;\n\t\tthis._toolProfileFilter = config.toolProfileFilter\n\t\t\t? { allow: config.toolProfileFilter.allow ?? [], block: config.toolProfileFilter.block ?? [] }\n\t\t\t: undefined;\n\t\tthis._isExplicitModel = config.isExplicitModel ?? false;\n\t\tthis._isExplicitThinking = config.isExplicitThinking ?? false;\n\t\tthis._isChildSession = config.isChildSession ?? process.env.PI_CHILD_SESSION === \"1\";\n\t\tthis._baseToolsOverride = config.baseToolsOverride;\n\t\tthis._sessionStartEvent = config.sessionStartEvent ?? { type: \"session_start\", reason: \"startup\" };\n\t\tthis._runtimeBuilder = new RuntimeBuilder({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisModelExhausted: (model) => this._billingFailover.isExhausted(`${model.provider}/${model.id}`),\n\t\t\tgetResourceLoader: () => this._resourceLoader,\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tsetExtensionRunner: (runner) => {\n\t\t\t\tthis._extensionRunner = runner;\n\t\t\t\tif (this._extensionRunnerRef) {\n\t\t\t\t\tthis._extensionRunnerRef.current = runner;\n\t\t\t\t}\n\t\t\t},\n\t\t\tgetBaseSystemPrompt: () => this._baseSystemPrompt,\n\t\t\tsetBaseSystemPrompt: (prompt) => {\n\t\t\t\tthis._baseSystemPrompt = prompt;\n\t\t\t},\n\t\t\tgetCustomTools: () => this._customTools,\n\t\t\tgetBaseToolsOverride: () => this._baseToolsOverride,\n\t\t\tgetRequestedActiveToolNames: () => this._requestedActiveToolNames,\n\t\t\tsetRequestedActiveToolNames: (names) => {\n\t\t\t\tthis._requestedActiveToolNames = names;\n\t\t\t},\n\t\t\tgetToolProfileFilter: () => this._toolProfileFilter,\n\t\t\tsetToolProfileFilter: (filter) => {\n\t\t\t\tthis._toolProfileFilter = filter;\n\t\t\t},\n\t\t\tgetAllowedToolNames: () => this._allowedToolNames,\n\t\t\tgetExcludedToolNames: () => this._excludedToolNames,\n\t\t\tderiveToolProfileFilter: () => this._profileFilter.deriveToolProfileFilter(),\n\t\t\tisToolOrCommandAllowedByProfile: (name) => this._profileFilter.isToolOrCommandAllowedByProfile(name),\n\t\t\tfilterExtensionsForRuntime: (extensions) => this._profileFilter.filterExtensionsForRuntime(extensions),\n\t\t\tsetUnboundToolGrantWarnings: (warnings) => {\n\t\t\t\tthis._unboundToolGrantWarnings = warnings;\n\t\t\t},\n\t\t\tgetUnboundToolGrantWarnings: () => this._unboundToolGrantWarnings,\n\t\t\tcreateProfileFilterReloadSnapshot: () => this._profileFilter.createReloadSnapshot(),\n\t\t\trestoreProfileFilterReloadSnapshot: (snapshot) => this._profileFilter.restoreReloadSnapshot(snapshot),\n\t\t\tgetActiveToolNames: () => this.getActiveToolNames(),\n\t\t\tsetActiveToolsByName: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\tnormalizePromptSnippet: (text) => this._normalizePromptSnippet(text),\n\t\t\tnormalizePromptGuidelines: (guidelines) => this._normalizePromptGuidelines(guidelines),\n\t\t\tbindExtensionCore: (runner) => this._bindExtensionCore(runner),\n\t\t\tapplyExtensionBindings: (runner) => this._applyExtensionBindings(runner),\n\t\t\textendResourcesFromExtensions: (reason) => this.extendResourcesFromExtensions(reason),\n\t\t\treapplyActiveProfileModelSettings: () => this._profileFilter.reapplyActiveProfileModelSettings(),\n\t\t\tnotifyExtensionsChanged: () => this._notifyExtensionsChanged(),\n\t\t\tgetToolArtifactStore: () => this._getToolArtifactStore(),\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\tgetMemoryAuditDiagnostics: () => this._memory.getMemoryAuditDiagnostics(),\n\t\t\tclearPendingMemoryProviders: () => this._memory.clearPendingProviders(),\n\t\t\tcreateMemoryReloadSnapshot: () => this._memory.createReloadSnapshot(),\n\t\t\trestoreMemoryReloadSnapshot: (snapshot) => this._memory.restoreReloadSnapshot(snapshot),\n\t\t\tinitializeMemory: () => this._memory.initialize(),\n\t\t\tgetGoalStateSnapshot: () => this.getGoalStateSnapshot(),\n\t\t\tsaveGoalStateSnapshot: (state) => this.saveGoalStateSnapshot(state),\n\t\t\tgetContextGcReport: (messages) => this.getContextGcReport(messages),\n\t\t\tstartWorkerDelegation: (request) => this._backgroundLanes.startWorkerDelegation(request),\n\t\t\tgetWorkerLaneRecords: () => this._backgroundLanes.getLaneRecords(),\n\t\t\tgetWorkerResultSnapshots: () => this.getWorkerResultSnapshots(),\n\t\t\trunWorkerDelegationOnce: (request) => this.runWorkerDelegationOnce(request),\n\t\t\trunModelFitness: (args) => this.runModelFitness(args),\n\t\t\tresolveCurationModelIfFit: () => this._resolveCurationModelIfFit(),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\tcreateAgentContextSnapshot: () => this._createAgentContextSnapshot(),\n\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\tisStreaming: () => this.isStreaming,\n\t\t\tisCompacting: () => this.isCompacting,\n\t\t\tgetExtensionUIContext: () => this._extensionUIContext,\n\t\t\tgetExtensionCommandContextActions: () => this._extensionCommandContextActions,\n\t\t\tgetExtensionShutdownHandler: () => this._extensionShutdownHandler,\n\t\t\tgetExtensionErrorListener: () => this._extensionErrorListener,\n\t\t});\n\t\tthis._analytics = new SessionAnalytics({\n\t\t\tgetState: () => this.state,\n\t\t\tgetMessages: () => this.messages,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetToolDefinition: (name) => this.getToolDefinition(name),\n\t\t\tgetToolRecoveryEventLogPath: () => this._toolRecoveryEventLogPath,\n\t\t});\n\t\tconst previousToolArgumentValidation = this.agent.onToolArgumentValidation;\n\t\tthis.agent.onToolArgumentValidation = (event) => {\n\t\t\tconst taggedEvent = this._tagModelAdaptationRuleTeaching(event);\n\t\t\tif (taggedEvent.outcome === \"repaired\" || taggedEvent.outcome === \"bounced\") {\n\t\t\t\tthis._toolSelection.recordValidation(taggedEvent.tool, taggedEvent.outcome);\n\t\t\t}\n\t\t\tpreviousToolArgumentValidation?.(taggedEvent);\n\t\t\tconst logRecord = this._toolRecoveryLogger.recordToolArgumentValidation(taggedEvent);\n\t\t\tif (!logRecord) return;\n\t\t\tthis._analytics.recordToolArgumentValidation(logRecord);\n\t\t\tthis._handleTextToolProtocolValidationOutcome(taggedEvent);\n\t\t\tthis._handleModelAdaptationTelemetry(taggedEvent);\n\t\t};\n\t\tthis._treeNavigator = new SessionTreeNavigator({\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tgetRequiredRequestAuth: (model) => this._getRequiredRequestAuth(model),\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetAgent: () => this.agent,\n\t\t\tsetBranchSummaryAbort: (controller) => {\n\t\t\t\tthis._branchSummaryAbortController = controller;\n\t\t\t},\n\t\t});\n\t\tthis._modelSelection = new ModelSelectionController({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetScopedModels: () => this._scopedModels,\n\t\t\tgetRequestedActiveToolNames: () => this._requestedActiveToolNames,\n\t\t\tgetActiveToolNames: () => this.getActiveToolNames(),\n\t\t\tsetActiveToolsByName: (names) => this.setActiveToolsByName(names),\n\t\t\tgetModelCapabilityProfile: () => this.getModelCapabilityProfile(),\n\t\t\trefreshBaseSystemPrompt: () => this._refreshBaseSystemPrompt(),\n\t\t\temit: (event) => this._emit(event),\n\t\t\tcheckContextWindowUsageWarning: () => this._checkContextWindowUsageWarning(),\n\t\t\tderiveOllamaServerUrl: (baseUrl) => this._deriveOllamaServerUrl(baseUrl),\n\t\t\tgetLocalRuntime: (serverUrl) => this.getLocalRuntime(serverUrl),\n\t\t});\n\t\tthis._bash = new BashExecutionController({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tisStreaming: () => this.isStreaming,\n\t\t});\n\t\tthis._profileFilter = new ProfileFilterController({\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetResourceLoader: () => this._resourceLoader,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetAllowedToolNames: () => this._allowedToolNames,\n\t\t\tgetExcludedToolNames: () => this._excludedToolNames,\n\t\t\tgetToolProfileFilter: () => this._toolProfileFilter,\n\t\t\tisExplicitModel: () => this._isExplicitModel,\n\t\t\tisExplicitThinking: () => this._isExplicitThinking,\n\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level, { persistSettings: false }),\n\t\t});\n\t\tthis._toolSelection = new ToolSelectionController({\n\t\t\tstore: ToolPerformanceStore.forAgentDir(this._agentDir),\n\t\t\tgetModelRef: () => {\n\t\t\t\tconst model = this.model;\n\t\t\t\treturn model ? formatModelRouterModel(model) : \"unknown\";\n\t\t\t},\n\t\t\tgetActiveTools: () => {\n\t\t\t\tconst activeNames = new Set(this.getActiveToolNames());\n\t\t\t\treturn this.getAllTools()\n\t\t\t\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t\t\t\t.map((tool) => ({\n\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\t}));\n\t\t\t},\n\t\t\tisCandidateAllowed: (toolName) => {\n\t\t\t\tconst envelope = this.capabilityEnvelope;\n\t\t\t\tif (!envelope) return true;\n\t\t\t\treturn (\n\t\t\t\t\tevaluateToolGate({\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\targs: {},\n\t\t\t\t\t\tcwd: this._cwd,\n\t\t\t\t\t\tenvelope,\n\t\t\t\t\t}).outcome === \"allow\"\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\t\tthis._toolGate = new ToolGateController({\n\t\t\tmaybeEscalateToolCall: (toolName, args) => this._modelRouter.maybeEscalateToolCall(toolName, args),\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetCapabilityEnvelope: () => this.capabilityEnvelope,\n\t\t\trecordGateOutcome: (outcome) => this._recordGateOutcome(outcome),\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tgetToolSelectionController: () => this._toolSelection,\n\t\t});\n\n\t\t// Always subscribe to agent events for internal handling\n\t\t// (session persistence, extensions, auto-compaction, retry logic)\n\t\tthis._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);\n\t\tthis._installAgentToolHooks();\n\t\tthis._installAgentContextTransform();\n\t\tthis._installAgentTurnRefresh();\n\n\t\tthis._runtimeBuilder.buildRuntime({\n\t\t\tactiveToolNames: this._initialActiveToolNames,\n\t\t\tincludeAllExtensionTools: true,\n\t\t});\n\t\tthis._scheduleLocalPrefixWarm(this.agent.state.model, \"session-start\");\n\t}\n\n\t/** Model registry for API key resolution and model discovery */\n\tget modelRegistry(): ModelRegistry {\n\t\treturn this._modelRegistry;\n\t}\n\n\tprivate _scheduleLocalPrefixWarm(model: Model<any> | undefined, _reason: \"session-start\" | \"selection\"): void {\n\t\tif (!model || !this._isWarmableLocalModel(model)) return;\n\t\tconst modelKey = formatModelRouterModel(model);\n\t\tif (this._completedPrefixWarms.has(modelKey) || this._prefixWarmer?.modelKey === modelKey) return;\n\t\tthis._cancelPrefixWarm();\n\t\tconst controller = new AbortController();\n\t\tconst timer = setTimeout(() => {\n\t\t\tconst warmer = this._prefixWarmer;\n\t\t\tif (!warmer || warmer.controller !== controller || controller.signal.aborted) return;\n\t\t\twarmer.timer = undefined;\n\t\t\tvoid this._runLocalPrefixWarm(model, modelKey, controller);\n\t\t}, 0);\n\t\ttimer.unref?.();\n\t\tthis._prefixWarmer = { modelKey, controller, timer };\n\t}\n\n\tprivate _cancelPrefixWarm(): void {\n\t\tconst warmer = this._prefixWarmer;\n\t\tif (!warmer) return;\n\t\tif (warmer.timer) clearTimeout(warmer.timer);\n\t\twarmer.controller.abort(new Error(\"prefix warmer preempted\"));\n\t\tthis._prefixWarmer = undefined;\n\t}\n\n\tprivate async _runLocalPrefixWarm(model: Model<any>, modelKey: string, controller: AbortController): Promise<void> {\n\t\ttry {\n\t\t\tconst options: SimpleStreamOptions = {\n\t\t\t\tmaxTokens: 1,\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tonPayload: this.agent.onPayload,\n\t\t\t\tonResponse: this.agent.onResponse,\n\t\t\t};\n\t\t\tif (this._isRawStreamSimple(this.agent.streamFn)) {\n\t\t\t\tconst auth = await this._getRequiredRequestAuth(model);\n\t\t\t\toptions.apiKey = auth.apiKey;\n\t\t\t\toptions.headers = auth.headers;\n\t\t\t}\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tif (model.provider === OLLAMA_PROVIDER || model.provider === HF_TRANSFORMERS_PROVIDER) {\n\t\t\t\tawait this._localRuntimeController.ensureIsolatedModelReady(model);\n\t\t\t}\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tconst stream = await this.agent.streamFn(\n\t\t\t\tmodel,\n\t\t\t\t{\n\t\t\t\t\tsystemPrompt: this._baseSystemPrompt,\n\t\t\t\t\ttools: this.agent.state.tools,\n\t\t\t\t\tmessages: [],\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tawait stream.result();\n\t\t\tif (!controller.signal.aborted) this._completedPrefixWarms.add(modelKey);\n\t\t} catch {\n\t\t\t// Best-effort cache warm only; a miss must never affect the real turn.\n\t\t} finally {\n\t\t\tif (this._prefixWarmer?.controller === controller) this._prefixWarmer = undefined;\n\t\t}\n\t}\n\n\tprivate _isWarmableLocalModel(model: Model<any>): boolean {\n\t\tif (model.api !== \"openai-completions\") return false;\n\t\ttry {\n\t\t\tconst hostname = new URL(model.baseUrl).hostname.toLowerCase();\n\t\t\treturn hostname === \"localhost\" || hostname === \"127.0.0.1\" || hostname === \"::1\" || hostname === \"[::1]\";\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * True when the session's stream fn is the raw `streamSimple` provider entry (directly, or as the\n\t * base wrapped by the idle watchdog at construction). Callers use this to decide whether request\n\t * auth must be injected explicitly — see {@link RAW_STREAM_MARKER}.\n\t */\n\tprivate _isRawStreamSimple(fn: StreamFn): boolean {\n\t\treturn fn === streamSimple || (fn as { [RAW_STREAM_MARKER]?: boolean })[RAW_STREAM_MARKER] === true;\n\t}\n\n\tprivate async _getRequiredRequestAuth(model: Model<any>): Promise<{\n\t\tapiKey: string;\n\t\theaders?: Record<string, string>;\n\t}> {\n\t\tconst result = await this._modelRegistry.getApiKeyAndHeaders(model);\n\t\tif (!result.ok) {\n\t\t\tif (result.error.startsWith(\"No API key found\")) {\n\t\t\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t\t\t}\n\t\t\tthrow new Error(result.error);\n\t\t}\n\t\tif (result.apiKey) {\n\t\t\treturn { apiKey: result.apiKey, headers: result.headers };\n\t\t}\n\n\t\tconst isOAuth = this._modelRegistry.isUsingOAuth(model);\n\t\tif (isOAuth) {\n\t\t\tthrow new Error(\n\t\t\t\t`Authentication failed for \"${model.provider}\". ` +\n\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t`Run '/login ${model.provider}' to re-authenticate.`,\n\t\t\t);\n\t\t}\n\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t}\n\n\t// Summarizer model/thinking selection, request auth (with session-model fallback), and\n\t// window-adapted settings live in CompactionSupport (see compaction-support.ts).\n\tprivate _getCompactionRequestAuth(model: Model<any>): Promise<{\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string>;\n\t}> {\n\t\treturn this._compactionSupport.getRequestAuth(model);\n\t}\n\n\tprivate _resolveCompactionModelAndAuth(\n\t\tcompactionModel: Model<any>,\n\t\tsessionModel: Model<any>,\n\t): Promise<{ model: Model<any>; apiKey?: string; headers?: Record<string, string>; failure?: string }> {\n\t\treturn this._compactionSupport.resolveModelAndAuth(compactionModel, sessionModel);\n\t}\n\n\tprivate _resolveCompactionModel(sessionModel: Model<any>): Model<any> {\n\t\treturn this._compactionSupport.resolveModel(sessionModel);\n\t}\n\n\t/**\n\t * One bounded diagnostic clause for compaction retry warnings: which summarizer selection won\n\t * (and why) plus the input-size estimate the capacity check consumed — the two facts every\n\t * gate-failure post-mortem has needed (2026-07-06 field incidents).\n\t */\n\tprivate _describeCompactionSummarizer(): string {\n\t\tconst reason = this._compactionSupport.getLastSelectionReason() ?? \"unresolved\";\n\t\tconst estimate = this._pipeline.estimateCurrentContextTokens(this.agent.state.messages);\n\t\treturn `summarizer: ${reason}, ~${Math.ceil(estimate / 1000)}k est input`;\n\t}\n\n\tprivate _getLastCompactionSelectionReason(): string | undefined {\n\t\treturn this._compactionSupport.getLastSelectionReason();\n\t}\n\n\tprivate _resolveCompactionThinkingLevel(\n\t\tcompactionModel: Model<any>,\n\t\tsessionModel: Model<any>,\n\t): ThinkingLevel | undefined {\n\t\treturn this._compactionSupport.resolveThinkingLevel(this.thinkingLevel, compactionModel, sessionModel);\n\t}\n\n\t/**\n\t * Install tool hooks once on the Agent instance.\n\t *\n\t * The callbacks read `this._extensionRunner` at execution time, so extension reload swaps in the\n\t * new runner without reinstalling hooks. Extension-specific tool wrappers are still used to adapt\n\t * registered tool execution to the extension context. Tool call and tool result interception now\n\t * happens here instead of in wrappers.\n\t */\n\tprivate _installAgentContextTransform(): void {\n\t\tconst previousTransformContext = this.agent.transformContext?.bind(this.agent);\n\t\tthis.agent.transformContext = async (messages, signal) => {\n\t\t\tconst transformed = previousTransformContext ? await previousTransformContext(messages, signal) : messages;\n\t\t\tconst authoritativeMessages = this.agent.state.messages.length > 0 ? this.agent.state.messages : transformed;\n\t\t\tlet currentMessages = authoritativeMessages;\n\t\t\ttry {\n\t\t\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\t\t\tconst contextWindow = this.model?.contextWindow ?? 0;\n\t\t\t\tif (settings.enabled && contextWindow > 0 && !this.isCompacting) {\n\t\t\t\t\tconst contextTokens = this._estimateCurrentContextTokens(authoritativeMessages);\n\t\t\t\t\tif (shouldCompact(contextTokens, contextWindow, settings, this.model?.autoCompactionTriggerTokens)) {\n\t\t\t\t\t\tconst latestBefore = getLatestCompactionEntry(this.sessionManager.getBranch())?.id;\n\t\t\t\t\t\tawait this._runAutoCompaction(\"threshold\", false);\n\t\t\t\t\t\tconst latestAfter = getLatestCompactionEntry(this.sessionManager.getBranch())?.id;\n\t\t\t\t\t\tif (latestAfter && latestAfter !== latestBefore) {\n\t\t\t\t\t\t\tcurrentMessages = this.agent.state.messages.slice();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tcurrentMessages = authoritativeMessages;\n\t\t\t}\n\n\t\t\tlet finalMessages = currentMessages;\n\t\t\tif (this._extensionRunner.hasHandlers(\"context\")) {\n\t\t\t\tfinalMessages = await this._extensionRunner.emitContext(currentMessages);\n\t\t\t}\n\t\t\tconst auditReport = this._runContextAudit(finalMessages);\n\t\t\tconst shadowReport = this._runPromptPolicyPlanning(auditReport);\n\t\t\tconst memoryReport = await this._runMemoryRetrieval(finalMessages);\n\t\t\tconst gcResult = this._applyContextGc(finalMessages, true);\n\t\t\tthis._correlatePromptPolicyWithContextGc(gcResult.report);\n\t\t\tconst enforcementResult = this._runPromptEnforcement(gcResult.messages, shadowReport);\n\t\t\tthis._enqueueRelevanceCuration(gcResult.messages, shadowReport);\n\t\t\t// Fire-and-forget: the local curator overlaps the frontier call; it never blocks a turn.\n\t\t\tthis._maybeDrainBrainCuration();\n\t\t\t// Appended LAST, after gc and enforcement, so the bounded evidence block is\n\t\t\t// never packed/stubbed/reshaped by either pass and always reflects this turn's\n\t\t\t// fresh retrieval. Because nothing downstream trims it, memory-prompt-block.ts's\n\t\t\t// character caps are the only budget protection for this block -- load-bearing,\n\t\t\t// not merely defensive.\n\t\t\tconst gcMessages = this._maybeAppendMemoryEvidenceBlock(enforcementResult.messages, memoryReport);\n\t\t\treturn gcMessages;\n\t\t};\n\t}\n\n\t/**\n\t * Resolve the foreground request's cost policy after routing/context conversion, when the actual\n\t * model, full system prompt, converted messages, and tool schemas are known. The guard is a\n\t * projection threshold rather than a hard output cap: warning mode never reduces capability, while\n\t * opt-in downgrade changes only this request's reasoning effort. Best-effort: never throws.\n\t */\n\tprivate _resolveCostGuardRequestReasoning(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\treasoning: SimpleStreamOptions[\"reasoning\"],\n\t\trequestMaxTokens: number | undefined,\n\t): SimpleStreamOptions[\"reasoning\"] {\n\t\ttry {\n\t\t\tconst guard = this.settingsManager.getCostGuardSettings();\n\t\t\tconst isChatGptSubscription = model.provider === \"openai-codex\" && this._modelRegistry.isUsingOAuth(model);\n\t\t\tif (guard.maxTurnUsd <= 0 || !model.cost || isChatGptSubscription) {\n\t\t\t\tthis._lastCostGuardDecision = undefined;\n\t\t\t\treturn reasoning;\n\t\t\t}\n\t\t\tconst inputTokens = estimateContextPromptTokens(context);\n\t\t\t// Use an explicit request cap when present; otherwise project against the session response\n\t\t\t// reserve instead of a frontier model's theoretical 128K output maximum.\n\t\t\tconst maxOutputTokens = Math.min(\n\t\t\t\tmodel.maxTokens ?? 4096,\n\t\t\t\trequestMaxTokens ?? this.settingsManager.getCompactionReserveTokens(),\n\t\t\t);\n\t\t\tconst estUsd = estimateTurnCostUsd({\n\t\t\t\tinputTokens,\n\t\t\t\tmaxOutputTokens,\n\t\t\t\tcost: model.cost,\n\t\t\t\tlongContextPricing: model.longContextPricing,\n\t\t\t});\n\t\t\tconst decision = evaluateCostGuard(estUsd, { maxTurnUsd: guard.maxTurnUsd, action: guard.action });\n\t\t\tthis._lastCostGuardDecision = decision;\n\t\t\tif (!decision.over || guard.action !== \"downgrade\" || reasoning === undefined) return reasoning;\n\t\t\tconst next = downgradeReasoning(reasoning, getSupportedThinkingLevels(model), model.thinkingLevelMap);\n\t\t\treturn next as NonNullable<SimpleStreamOptions[\"reasoning\"]>;\n\t\t} catch {\n\t\t\t// cost guard must never disrupt a turn\n\t\t\treturn reasoning;\n\t\t}\n\t}\n\n\t/** Latest cost-guard decision (for the host footer/UI to surface a warning). Undefined if disabled. */\n\tgetLastCostGuardDecision(): CostGuardDecision | undefined {\n\t\treturn this._lastCostGuardDecision;\n\t}\n\n\tprivate get _skillCurator(): SkillCurator {\n\t\tif (!this._skillCuratorInstance) {\n\t\t\tthis._skillCuratorInstance = new SkillCurator(join(this._agentDir, \"skills\"));\n\t\t}\n\t\treturn this._skillCuratorInstance;\n\t}\n\n\t/**\n\t * Skill curator (#32): PROPOSE (never auto-apply) archival of stale reflection-promoted skills and\n\t * consolidation of overlapping ones. The host surfaces these (e.g. a `/curate` command) for approval.\n\t */\n\tproposeSkillCuration(options?: { staleDays?: number; overlapThreshold?: number }): CurationProposals {\n\t\treturn this._skillCurator.proposeCuration(Date.now(), options);\n\t}\n\n\t/**\n\t * Session-start auto-curation (#32, default ON): archive stale reflection-promoted skills in one\n\t * locked batch and return the names archived so the host can ANNOUNCE it (never silent). Skipped in\n\t * child sessions and when `curator.autoArchive` is disabled. Restorable via `/curate restore`.\n\t */\n\tasync runStartupSkillCuration(): Promise<string[]> {\n\t\tif (this._isChildSession) return [];\n\t\tconst settings = this.settingsManager.getCuratorSettings();\n\t\tif (!settings.autoArchive) return [];\n\t\treturn this._skillCurator.autoArchiveStale(Date.now(), { staleDays: settings.staleDays });\n\t}\n\n\t/** Archive a promoted skill into `skills/.archive/` (restorable, non-destructive). Returns true if moved. */\n\tarchivePromotedSkill(name: string): boolean {\n\t\treturn this._skillCurator.archiveSkill(name);\n\t}\n\n\t/** Restore a previously-archived promoted skill. Returns true if moved back. */\n\trestorePromotedSkill(name: string): boolean {\n\t\treturn this._skillCurator.restoreSkill(name);\n\t}\n\n\tprivate _installAgentTurnRefresh(): void {\n\t\tconst previousPrepareNextTurn = this.agent.prepareNextTurn?.bind(this.agent);\n\t\tthis.agent.prepareNextTurn = async (signal) => {\n\t\t\tconst previous = previousPrepareNextTurn ? await previousPrepareNextTurn(signal) : undefined;\n\t\t\tconst snapshot = this._createAgentContextSnapshot();\n\t\t\treturn {\n\t\t\t\t...previous,\n\t\t\t\tcontext: {\n\t\t\t\t\t...(previous?.context ?? snapshot),\n\t\t\t\t\tsystemPrompt: snapshot.systemPrompt,\n\t\t\t\t\ttools: snapshot.tools,\n\t\t\t\t},\n\t\t\t\tmodel: previous?.model ?? this.agent.state.model,\n\t\t\t\tthinkingLevel: previous?.thinkingLevel ?? this.agent.state.thinkingLevel,\n\t\t\t};\n\t\t};\n\t}\n\n\tprivate _createAgentContextSnapshot(): AgentContext {\n\t\treturn {\n\t\t\tsystemPrompt: this.agent.state.systemPrompt,\n\t\t\tmessages: this.agent.state.messages.slice(),\n\t\t\ttools: this.agent.state.tools.slice(),\n\t\t};\n\t}\n\n\tprivate _modelAdaptationKeyFor(model: Model<Api> | undefined): string | undefined {\n\t\treturn model ? formatModelRouterModel(model) : undefined;\n\t}\n\n\tprivate _toolRepairSettings() {\n\t\treturn resolveCurrentToolRepairSettings(this.settingsManager.settings);\n\t}\n\n\tprivate _applyToolRepairLayerSettings(): void {\n\t\tconst settings = this._toolRepairSettings();\n\t\tthis.agent.toolArgumentTeachEnabled = settings.teach;\n\t}\n\n\tprivate _getModelAdaptationRulesForPrompt() {\n\t\tif (!this._toolRepairSettings().teach) return [];\n\t\tconst modelKey = this._modelAdaptationKeyFor(this.agent.state.model);\n\t\treturn modelKey ? this._modelAdaptationStore.get(modelKey).rules : [];\n\t}\n\n\tprivate _textProtocolFlag(model: Model<Api> | undefined): boolean {\n\t\t// Phase 7 gating hierarchy: PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED is resolved\n\t\t// in _toolRepairSettings() as the env kill switch, then settings.toolRepair.textProtocol\n\t\t// force-enables/disables globally, then Model.textToolCallProtocol opts in per model,\n\t\t// then a persisted /toolprobe text-protocol verdict opts in that exact model. The\n\t\t// calibration store is consulted after this flag; native provider tool calls still\n\t\t// win when emitted, and this only enables the text-protocol fallback lane.\n\t\tconst override = this._toolRepairSettings().textProtocol;\n\t\tif (override !== undefined) return override;\n\t\tif (model?.textToolCallProtocol === true) return true;\n\t\tconst modelKey = this._modelAdaptationKeyFor(model);\n\t\treturn !!modelKey && this._modelAdaptationStore.get(modelKey).toolProbe?.status === \"text-protocol\";\n\t}\n\n\tprivate async _streamForToolProbe(model: Model<Api>, context: Context, options: SimpleStreamOptions) {\n\t\tlet requestOptions = options;\n\t\tif (this._isRawStreamSimple(this.agent.streamFn)) {\n\t\t\tconst auth = await this._getRequiredRequestAuth(model);\n\t\t\trequestOptions = {\n\t\t\t\t...options,\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\theaders: auth.headers || options.headers ? { ...auth.headers, ...options.headers } : undefined,\n\t\t\t};\n\t\t}\n\t\treturn this.agent.streamFn(model, context, requestOptions);\n\t}\n\n\tprivate _textProtocolCalibrationContext(variant: TextToolProtocolVariant, token: string): Context {\n\t\tconst primer = generateTextToolProtocolPrimer([TEXT_TOOL_PROTOCOL_ECHO_TOOL], { variant });\n\t\tconst instruction = `Text tool protocol calibration trial. Using the protocol above, call echo with data exactly \"${token}\". Output only the tool-call envelope.`;\n\t\treturn {\n\t\t\tsystemPrompt: `${primer}\\n\\n${instruction}`,\n\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: instruction }], timestamp: Date.now() }],\n\t\t};\n\t}\n\n\tprivate _messageHasToolCallWithStringArgument(\n\t\tmessage: AssistantMessage,\n\t\ttoolName: string,\n\t\targName: string,\n\t\targValue: string,\n\t): boolean {\n\t\treturn message.content.some((block) => {\n\t\t\tif (block.type !== \"toolCall\" || block.name !== toolName) return false;\n\t\t\tconst args = block.arguments as unknown;\n\t\t\treturn (\n\t\t\t\ttypeof args === \"object\" &&\n\t\t\t\targs !== null &&\n\t\t\t\t!Array.isArray(args) &&\n\t\t\t\t(args as Record<string, unknown>)[argName] === argValue\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate _nativeToolProbeSystemPrompt(instruction: string): string {\n\t\tconst base = (this.agent.state.systemPrompt ?? \"\").trim();\n\t\treturn base ? `${base}\\n\\n${instruction}` : instruction;\n\t}\n\n\tprivate async _runNativeReadTaskProbeTrial(model: Model<Api>, path: string): Promise<boolean> {\n\t\tconst instruction =\n\t\t\t`Native tool-call capability probe: task-scale read. Use provider-native tool calling, not prose. ` +\n\t\t\t`Call read exactly once with path exactly \"${path}\".`;\n\t\tconst stream = await this._streamForToolProbe(\n\t\t\tmodel,\n\t\t\t{\n\t\t\t\tsystemPrompt: this._nativeToolProbeSystemPrompt(instruction),\n\t\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: instruction }], timestamp: Date.now() }],\n\t\t\t\ttools: [NATIVE_TOOL_PROBE_READ_TOOL],\n\t\t\t},\n\t\t\t{ textToolCallProtocol: false, maxRetries: 0, temperature: 0, maxTokens: 768 },\n\t\t);\n\t\treturn this._messageHasToolCallWithStringArgument(await stream.result(), \"read\", \"path\", path);\n\t}\n\n\tprivate async _runNativeEchoToolProbeTrial(model: Model<Api>, token: string): Promise<boolean> {\n\t\tconst instruction =\n\t\t\t`Native tool-call capability probe: echo-only. Use provider-native tool calling, not prose. ` +\n\t\t\t`Call echo with data exactly \"${token}\".`;\n\t\tconst stream = await this._streamForToolProbe(\n\t\t\tmodel,\n\t\t\t{\n\t\t\t\tsystemPrompt: this._nativeToolProbeSystemPrompt(instruction),\n\t\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: instruction }], timestamp: Date.now() }],\n\t\t\t\ttools: [TEXT_TOOL_PROTOCOL_ECHO_TOOL],\n\t\t\t},\n\t\t\t{ textToolCallProtocol: false, maxRetries: 0, temperature: 0, maxTokens: 256 },\n\t\t);\n\t\treturn this._messageHasToolCallWithStringArgument(await stream.result(), \"echo\", \"data\", token);\n\t}\n\n\tprivate async _gradeNativeToolCallingForModel(model: Model<Api>, token: string): Promise<NativeToolProbeGrade> {\n\t\tconst path = join(\n\t\t\tgetProcessWorkRun(this._agentDir, \"probes\", \"native-tools\").path,\n\t\t\t`pi-native-probe-${process.pid}-${Date.now()}.txt`,\n\t\t);\n\t\twriteFileSync(path, token, \"utf-8\");\n\t\ttry {\n\t\t\tconst taskPassed = await this._runNativeReadTaskProbeTrial(model, path);\n\t\t\tif (taskPassed) return \"task\";\n\t\t\tconst echoPassed = await this._runNativeEchoToolProbeTrial(model, token);\n\t\t\tif (echoPassed) return \"echo-only\";\n\t\t\treturn \"absent\";\n\t\t} finally {\n\t\t\trmSync(path, { force: true });\n\t\t}\n\t}\n\n\tprivate async _runTextProtocolTrial(\n\t\tmodel: Model<Api>,\n\t\tvariant: TextToolProtocolVariant,\n\t\ttoken: string,\n\t): Promise<boolean> {\n\t\tconst stream = await this._streamForToolProbe(model, this._textProtocolCalibrationContext(variant, token), {\n\t\t\ttextToolCallProtocol: false,\n\t\t\tmaxRetries: 0,\n\t\t\ttemperature: 0,\n\t\t\tmaxTokens: 256,\n\t\t});\n\t\tconst message = await stream.result();\n\t\tconst text = message.content\n\t\t\t.filter((block): block is TextContent => block.type === \"text\")\n\t\t\t.map((block) => block.text)\n\t\t\t.join(\"\\n\")\n\t\t\t.trim();\n\t\tif (!text) return false;\n\t\tconst parsed = parseTextToolCalls(text, [TEXT_TOOL_PROTOCOL_ECHO_TOOL]);\n\t\treturn parsed.calls.some((call) => call.name === \"echo\" && call.arguments.data === token);\n\t}\n\n\tprivate async _calibrateTextToolProtocolForModel(\n\t\tmodel: Model<Api>,\n\t\tmodelKey: string | undefined,\n\t\toptions: { persistFailure: boolean },\n\t): Promise<\n\t\t| { status: \"calibrated\"; variant: TextToolProtocolVariant; calibratedAt: string }\n\t\t| { status: \"failed\"; attemptedAt: string; variantsTried: string[] }\n\t> {\n\t\tconst variantsTried: string[] = [];\n\t\tfor (const variant of TEXT_TOOL_PROTOCOL_VARIANTS) {\n\t\t\tvariantsTried.push(variant);\n\t\t\tlet passed = true;\n\t\t\tfor (let trial = 0; trial < TEXT_TOOL_PROTOCOL_TRIALS_PER_VARIANT; trial++) {\n\t\t\t\tconst ok = await this._runTextProtocolTrial(model, variant, `pi-calibration-${trial + 1}`);\n\t\t\t\tif (!ok) {\n\t\t\t\t\tpassed = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (passed) {\n\t\t\t\tconst calibratedAt = new Date().toISOString();\n\t\t\t\tif (modelKey) {\n\t\t\t\t\tthis._modelAdaptationStore.setProtocol(\n\t\t\t\t\t\tmodelKey,\n\t\t\t\t\t\t{ version: TEXT_TOOL_PROTOCOL_VERSION, status: \"calibrated\", variant, calibratedAt },\n\t\t\t\t\t\tcalibratedAt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { status: \"calibrated\", variant, calibratedAt };\n\t\t\t}\n\t\t}\n\n\t\tconst attemptedAt = new Date().toISOString();\n\t\tif (modelKey && options.persistFailure) {\n\t\t\tthis._modelAdaptationStore.setProtocol(\n\t\t\t\tmodelKey,\n\t\t\t\t{ version: TEXT_TOOL_PROTOCOL_VERSION, status: \"failed\", attemptedAt, variantsTried },\n\t\t\t\tattemptedAt,\n\t\t\t);\n\t\t}\n\t\treturn { status: \"failed\", attemptedAt, variantsTried };\n\t}\n\n\tprivate async _ensureTextToolProtocolForActiveModel(): Promise<void> {\n\t\tconst model = this.agent.state.model;\n\t\tif (!this._textProtocolFlag(model)) {\n\t\t\tthis.agent.textToolCallProtocol = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst modelKey = this._modelAdaptationKeyFor(model);\n\t\tif (!modelKey) {\n\t\t\tthis.agent.textToolCallProtocol = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst profile = this._modelAdaptationStore.get(modelKey);\n\t\tif (profile.protocol?.version === TEXT_TOOL_PROTOCOL_VERSION) {\n\t\t\tif (profile.protocol.status === \"failed\") {\n\t\t\t\tthis.agent.textToolCallProtocol = undefined;\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Previous text tool protocol calibration failed for ${modelKey} at ${profile.protocol.attemptedAt}. ` +\n\t\t\t\t\t\t`Variants tried: ${profile.protocol.variantsTried.join(\", \")}. ` +\n\t\t\t\t\t\t`Run /toolhealth for details or /toolprotocol-reset ${modelKey} to retry calibration.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.agent.textToolCallProtocol = { variant: profile.protocol.variant as TextToolProtocolVariant };\n\t\t\treturn;\n\t\t}\n\n\t\tconst result = await this._calibrateTextToolProtocolForModel(model, modelKey, { persistFailure: true });\n\t\tif (result.status === \"calibrated\") {\n\t\t\tthis.agent.textToolCallProtocol = { variant: result.variant };\n\t\t\treturn;\n\t\t}\n\n\t\tthis.agent.textToolCallProtocol = undefined;\n\t\tthrow new Error(\n\t\t\t`Model ${modelKey} cannot follow the text tool protocol after calibration. ` +\n\t\t\t\t`Run /toolhealth for details or /toolprotocol-reset ${modelKey} to retry calibration.`,\n\t\t);\n\t}\n\n\tprivate _modelRef(model: Model<Api>): string {\n\t\treturn `${model.provider}/${model.id}`;\n\t}\n\n\tprivate _formatToolProbeReport(results: readonly ToolProbeResult[]): string {\n\t\tconst lines = [\n\t\t\t\"Tool probe results:\",\n\t\t\t\"Model | Verdict | Variant | Native grade | Diagnostic\",\n\t\t\t\"--- | --- | --- | --- | ---\",\n\t\t];\n\t\tfor (const result of results) {\n\t\t\tlines.push(\n\t\t\t\t[\n\t\t\t\t\tresult.model,\n\t\t\t\t\tresult.verdict,\n\t\t\t\t\tresult.variant ?? \"-\",\n\t\t\t\t\tresult.nativeGrade ?? \"-\",\n\t\t\t\t\tresult.diagnostic ? result.diagnostic.replace(/\\s+/g, \" \").slice(0, 160) : \"-\",\n\t\t\t\t].join(\" | \"),\n\t\t\t);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tprivate _storeToolProbe(modelKey: string, probe: ModelToolProbe): void {\n\t\tthis._modelAdaptationStore.setToolProbe(modelKey, probe, probe.probedAt);\n\t}\n\n\tprivate async _probeToolCallingForModel(model: Model<Api>): Promise<ToolProbeResult> {\n\t\tconst modelKey = this._modelRef(model);\n\t\tconst probedAt = new Date().toISOString();\n\t\tlet nativeGrade: NativeToolProbeGrade = \"absent\";\n\t\tlet diagnostic: string | undefined;\n\t\ttry {\n\t\t\tnativeGrade = await this._gradeNativeToolCallingForModel(model, \"pi-native-probe\");\n\t\t\tif (nativeGrade === \"task\") {\n\t\t\t\tthis._storeToolProbe(modelKey, {\n\t\t\t\t\tversion: TEXT_TOOL_PROTOCOL_VERSION,\n\t\t\t\t\tstatus: \"native\",\n\t\t\t\t\tprobedAt,\n\t\t\t\t\tnativeGrade,\n\t\t\t\t});\n\t\t\t\treturn { model: modelKey, verdict: \"native\", nativeGrade };\n\t\t\t}\n\t\t\tdiagnostic =\n\t\t\t\tnativeGrade === \"echo-only\"\n\t\t\t\t\t? \"Native echo probe passed but task-scale read probe failed.\"\n\t\t\t\t\t: \"Native task-scale read and echo probes did not produce provider-native tool calls.\";\n\t\t} catch (error) {\n\t\t\tdiagnostic = error instanceof Error ? error.message : String(error);\n\t\t}\n\n\t\ttry {\n\t\t\tconst calibrated = await this._calibrateTextToolProtocolForModel(model, modelKey, { persistFailure: false });\n\t\t\tif (calibrated.status === \"calibrated\") {\n\t\t\t\tthis._storeToolProbe(modelKey, {\n\t\t\t\t\tversion: TEXT_TOOL_PROTOCOL_VERSION,\n\t\t\t\t\tstatus: \"text-protocol\",\n\t\t\t\t\tprobedAt: calibrated.calibratedAt,\n\t\t\t\t\tvariant: calibrated.variant,\n\t\t\t\t\tnativeGrade,\n\t\t\t\t\tdiagnostic,\n\t\t\t\t});\n\t\t\t\treturn { model: modelKey, verdict: \"text-protocol\", variant: calibrated.variant, nativeGrade, diagnostic };\n\t\t\t}\n\t\t\tdiagnostic = `${diagnostic ? `${diagnostic} ` : \"\"}Text protocol variants failed: ${calibrated.variantsTried.join(\", \")}`;\n\t\t} catch (error) {\n\t\t\tdiagnostic = error instanceof Error ? error.message : String(error);\n\t\t}\n\n\t\tthis._storeToolProbe(modelKey, {\n\t\t\tversion: TEXT_TOOL_PROTOCOL_VERSION,\n\t\t\tstatus: \"none\",\n\t\t\tprobedAt,\n\t\t\tnativeGrade,\n\t\t\tdiagnostic,\n\t\t});\n\t\treturn { model: modelKey, verdict: \"none\", nativeGrade, diagnostic };\n\t}\n\n\tprivate async _resolveToolProbeModels(target?: string): Promise<Model<Api>[]> {\n\t\tconst trimmed = target?.trim();\n\t\tif (!trimmed) return this._modelRegistry.getAvailable();\n\t\tconst [provider, ...modelParts] = trimmed.split(\"/\");\n\t\tconst modelId = modelParts.join(\"/\");\n\t\tif (!provider || !modelId) throw new Error(\"Usage: /toolprobe [provider/model]\");\n\t\tconst exact = this._modelRegistry.find(provider, modelId);\n\t\tif (exact) return [exact];\n\t\tconst current = this.agent.state.model;\n\t\tif (current?.provider === provider && current.id === modelId) return [current];\n\t\tthrow new Error(`Model not found: ${trimmed}`);\n\t}\n\n\tasync probeToolCalling(target?: string): Promise<ToolProbeReport> {\n\t\tconst models = await this._resolveToolProbeModels(target);\n\t\tif (models.length === 0) throw new Error(\"No available models to probe.\");\n\t\tconst results: ToolProbeResult[] = [];\n\t\tfor (const model of models) {\n\t\t\tresults.push(await this._probeToolCallingForModel(model));\n\t\t}\n\t\treturn { results, table: this._formatToolProbeReport(results) };\n\t}\n\n\tprivate _handleTextToolProtocolParse(event: TextToolProtocolParseEvent): void {\n\t\tthis._textProtocolParseObservedThisTurn = true;\n\t\tconst modelKey = `${event.provider}/${event.model}`;\n\t\tif (event.status === \"parsed\") return;\n\t\tconst signature = `${event.variant}:${event.reason ?? \"failed\"}`;\n\t\tconst previous = this._textProtocolParseFailures.get(modelKey);\n\t\tconst repeats = previous?.signature === signature ? previous.repeats + 1 : 1;\n\t\tthis._textProtocolParseFailures.set(modelKey, { signature, repeats });\n\t\tif (repeats < TEXT_TOOL_PROTOCOL_PARSE_FAILURE_THRESHOLD) return;\n\n\t\tconst profile = this._modelAdaptationStore.get(modelKey);\n\t\tif (profile.protocol?.version === TEXT_TOOL_PROTOCOL_VERSION && profile.protocol.status !== \"failed\") {\n\t\t\tthis._modelAdaptationStore.removeProtocol(modelKey);\n\t\t\tthis.agent.textToolCallProtocol = undefined;\n\t\t}\n\t\tthis._textProtocolParseFailures.delete(modelKey);\n\t}\n\n\tprivate _handleTextToolProtocolValidationOutcome(event: ToolArgumentValidationTelemetryEvent): void {\n\t\tif (event.source !== \"text-protocol\") return;\n\t\tconst protocol = this.agent.textToolCallProtocol;\n\t\tconst variant = protocol === true ? \"tool-tag\" : protocol ? protocol.variant : undefined;\n\t\tif (!variant) return;\n\t\tconst status = event.outcome === \"bounced\" ? \"failed\" : \"parsed\";\n\t\tif (this._textProtocolValidationOutcomeThisTurn?.status === \"parsed\" && status === \"failed\") return;\n\t\tthis._textProtocolValidationOutcomeThisTurn = {\n\t\t\tprovider: event.provider ?? this.agent.state.model.provider,\n\t\t\tmodel: event.model ?? this.agent.state.model.id,\n\t\t\tvariant,\n\t\t\tstatus,\n\t\t\tcallCount: 1,\n\t\t\ttextLength: 0,\n\t\t\t...(status === \"failed\" && {\n\t\t\t\treason: event.errorKeywords?.includes(\"unknown_tool\") ? \"unknown-tool\" : \"validation-failed\",\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate _recordTextToolProtocolParseOutcomeFromLastAssistant(): void {\n\t\tconst validationOutcome = this._textProtocolValidationOutcomeThisTurn;\n\t\tthis._textProtocolValidationOutcomeThisTurn = undefined;\n\t\tif (validationOutcome?.status === \"parsed\") {\n\t\t\tthis._textProtocolParseObservedThisTurn = true;\n\t\t\tthis._textProtocolParseFailures.delete(`${validationOutcome.provider}/${validationOutcome.model}`);\n\t\t\treturn;\n\t\t}\n\t\tif (validationOutcome) {\n\t\t\tthis._handleTextToolProtocolParse(validationOutcome);\n\t\t\treturn;\n\t\t}\n\t\tif (this._textProtocolParseObservedThisTurn) return;\n\t\tconst protocol = this.agent.textToolCallProtocol;\n\t\tif (protocol === false || protocol === true || !protocol?.variant) return;\n\t\tconst response = this._findLastAssistantMessage();\n\t\tif (!response) return;\n\t\tconst responseText = response.content\n\t\t\t.filter((content): content is TextContent => content.type === \"text\")\n\t\t\t.map((content) => content.text)\n\t\t\t.join(\"\\n\");\n\t\tif (!responseText) return;\n\n\t\tconst parsed = parseTextToolCalls(responseText, this.agent.state.tools);\n\t\tconst attempted = parsed.attempted || this._looksLikeTextToolProtocolAttempt(responseText);\n\t\tif (!attempted) return;\n\t\tthis._handleTextToolProtocolParse({\n\t\t\tprovider: this.agent.state.model.provider,\n\t\t\tmodel: this.agent.state.model.id,\n\t\t\tvariant: protocol.variant,\n\t\t\tstatus: parsed.calls.length > 0 ? \"parsed\" : \"failed\",\n\t\t\treason: parsed.failure,\n\t\t\tcallCount: parsed.calls.length,\n\t\t\ttextLength: responseText.length,\n\t\t});\n\t}\n\n\tprivate _looksLikeTextToolProtocolAttempt(text: string): boolean {\n\t\treturn /<pi:call\\b|<tool_call\\b|```(?:tool|tool_call)[\\s\\S]*\"name\"\\s*:/i.test(text);\n\t}\n\n\tprivate _tagModelAdaptationRuleTeaching(\n\t\tevent: ToolArgumentValidationTelemetryEvent,\n\t): ToolArgumentValidationTelemetryEvent {\n\t\tif (!this._toolRepairSettings().teach || event.taught !== \"none\") return event;\n\t\tconst modelKey =\n\t\t\tevent.provider && event.model\n\t\t\t\t? `${event.provider}/${event.model}`\n\t\t\t\t: this._modelAdaptationKeyFor(this.agent.state.model);\n\t\tif (!modelKey) return event;\n\t\ttry {\n\t\t\tconst rules = this._modelAdaptationStore.get(modelKey).rules;\n\t\t\tconst modes = new Set([...event.failureModes, ...event.repairsApplied]);\n\t\t\tif (rules.some((rule) => modes.has(rule.mode as ToolRepairModeName))) {\n\t\t\t\treturn { ...event, taught: \"rule\" };\n\t\t\t}\n\t\t} catch {\n\t\t\t// Adaptation telemetry tagging is best-effort; leave the original event unchanged.\n\t\t}\n\t\treturn event;\n\t}\n\n\tprivate _repairSessionCount(modelKey: string, mode: ToolRepairModeName): number {\n\t\tconst key = `${modelKey}\\0${mode}`;\n\t\tconst count = (this._repairModeSessionCounts.get(key) ?? 0) + 1;\n\t\tthis._repairModeSessionCounts.set(key, count);\n\t\treturn count;\n\t}\n\n\tprivate _handleModelAdaptationTelemetry(event: ToolArgumentValidationTelemetryEvent): void {\n\t\tif (!this._toolRepairSettings().teach || event.outcome !== \"repaired\" || event.repairsApplied.length === 0)\n\t\t\treturn;\n\t\tconst modelKey =\n\t\t\tevent.provider && event.model\n\t\t\t\t? `${event.provider}/${event.model}`\n\t\t\t\t: this._modelAdaptationKeyFor(this.agent.state.model);\n\t\tif (!modelKey) return;\n\n\t\ttry {\n\t\t\tfor (const mode of [...new Set(event.repairsApplied)]) {\n\t\t\t\tconst profile = this._modelAdaptationStore.get(modelKey);\n\t\t\t\tconst stats = profile.teachStats[mode] ?? { taught: 0, recurrenceBefore: 0, recurrenceAfter: 0 };\n\t\t\t\tif (profile.rules.some((rule) => rule.mode === mode)) {\n\t\t\t\t\tthis._modelAdaptationStore.markRuleFired(modelKey, mode);\n\t\t\t\t\tthis._modelAdaptationStore.setTeachStats(modelKey, mode, {\n\t\t\t\t\t\t...stats,\n\t\t\t\t\t\trecurrenceAfter: stats.recurrenceAfter + 1,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst recurrenceBefore = stats.recurrenceBefore + 1;\n\t\t\t\tthis._modelAdaptationStore.setTeachStats(modelKey, mode, { ...stats, recurrenceBefore });\n\t\t\t\tconst sessionCount = this._repairSessionCount(modelKey, mode);\n\t\t\t\tif (\n\t\t\t\t\tsessionCount >= MODEL_ADAPTATION_REPAIR_THRESHOLD ||\n\t\t\t\t\trecurrenceBefore >= MODEL_ADAPTATION_REPAIR_THRESHOLD\n\t\t\t\t) {\n\t\t\t\t\tthis._modelAdaptationStore.addRule(modelKey, {\n\t\t\t\t\t\tmode,\n\t\t\t\t\t\ttext: formatToolRepairStandingRule(mode),\n\t\t\t\t\t});\n\t\t\t\t\tthis._modelAdaptationStore.setTeachStats(modelKey, mode, {\n\t\t\t\t\t\t...stats,\n\t\t\t\t\t\ttaught: stats.taught + 1,\n\t\t\t\t\t\trecurrenceBefore,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Model adaptation is best-effort; failed telemetry persistence must not affect the turn.\n\t\t}\n\t}\n\n\t/** Tool-build call-site delegation to {@link ContextPipeline.getToolArtifactStore}. */\n\tprivate _getToolArtifactStore(): ArtifactStore {\n\t\treturn this._pipeline.getToolArtifactStore();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.runContextAudit}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runContextAudit(messages: AgentMessage[]): ContextAuditReport {\n\t\treturn this._pipeline.runContextAudit(messages);\n\t}\n\n\t/** Read-only inspection of the context audit (delegates to {@link ContextPipeline.getContextAuditReport}). */\n\tgetContextAuditReport(messages?: AgentMessage[]): ContextAuditReport {\n\t\treturn this._pipeline.getContextAuditReport(messages);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.runPromptPolicyPlanning}. Kept as\n\t * a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runPromptPolicyPlanning(auditReport: ContextAuditReport): PromptPolicyShadowReport {\n\t\treturn this._pipeline.runPromptPolicyPlanning(auditReport);\n\t}\n\n\t/** Read-only inspection of the shadow policy plan (delegates to {@link ContextPipeline.getPromptPolicyReport}). */\n\tgetPromptPolicyReport(messages?: AgentMessage[]): PromptPolicyShadowReport {\n\t\treturn this._pipeline.getPromptPolicyReport(messages);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.correlatePromptPolicyWithContextGc}.\n\t * Kept as a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _correlatePromptPolicyWithContextGc(gcReport: ContextGcReport): void {\n\t\tthis._pipeline.correlatePromptPolicyWithContextGc(gcReport);\n\t}\n\n\t/** Read-only inspection of the latest shadow-plan/legacy-gc correlation, for tests/debugging. */\n\tgetPromptPolicyGcCorrelation(): PromptPolicyGcCorrelationReport {\n\t\treturn this._pipeline.getPromptPolicyGcCorrelation();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.runPromptEnforcement}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runPromptEnforcement(\n\t\tmessages: AgentMessage[],\n\t\tshadowReport: PromptPolicyShadowReport,\n\t): { messages: AgentMessage[]; report: PromptEnforcementReport } {\n\t\treturn this._pipeline.runPromptEnforcement(messages, shadowReport);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.enqueueRelevanceCuration}. Kept as\n\t * a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _enqueueRelevanceCuration(messages: AgentMessage[], shadowReport: PromptPolicyShadowReport): void {\n\t\tthis._pipeline.enqueueRelevanceCuration(messages, shadowReport);\n\t}\n\n\t/** Reflex/curation call-site delegation to {@link ContextPipeline.resolveCurationModelIfFit}. */\n\tprivate _resolveCurationModelIfFit(): Model<Api> | undefined {\n\t\treturn this._pipeline.resolveCurationModelIfFit();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.maybeDrainBrainCuration}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _maybeDrainBrainCuration(): void {\n\t\tthis._pipeline.maybeDrainBrainCuration();\n\t}\n\n\t/** Compaction call-site delegation to {@link ContextPipeline.buildCompactionPreDigest}. */\n\tprivate _buildCompactionPreDigest(): ((text: string, signal?: AbortSignal) => Promise<string>) | undefined {\n\t\treturn this._pipeline.buildCompactionPreDigest();\n\t}\n\n\t/** Drop provider-owned request/continuation caches whose prefix was invalidated by compaction. */\n\tprivate _refreshAfterCompaction(): void {\n\t\tthis.agent.state.messages = this.sessionManager.buildSessionContext().messages;\n\t\ttry {\n\t\t\tcleanupSessionResources(this.sessionId);\n\t\t} catch {\n\t\t\t// Provider cache cleanup is best-effort and must not turn an applied compaction into a failure.\n\t\t}\n\t}\n\n\t/**\n\t * Context composition dashboard data: decomposes the per-request payload (system prompt, tool\n\t * schemas, extension contributions, message classes incl. GC/policy stubs and recall pages)\n\t * plus background spend, so users can see exactly what their integrations cost per request.\n\t * Read-only: uses the GC report path (writePayloads=false), never mutates anything.\n\t */\n\tgetContextCompositionReport(): ContextCompositionReport {\n\t\tconst rawMessages = this.agent.state.messages.slice();\n\t\tconst gcResult = this._applyContextGc(rawMessages, false);\n\t\tconst activeNames = new Set(this.getActiveToolNames());\n\t\tconst extensions = this._resourceLoader.getExtensions().extensions;\n\t\tconst extensionToolNames = new Set(extensions.flatMap((extension) => [...extension.tools.keys()]));\n\t\tconst usage = this.getContextUsage();\n\t\tconst enforcementItems = this.getPromptEnforcementReport().items;\n\t\tconst curationStatus = this.getContextCurationStatus();\n\t\tconst spawned = this.getSpawnedUsage();\n\t\tconst promptInclusion = this.getMemoryPromptInclusionReport();\n\t\tconst memoryEvidenceTokens =\n\t\t\tpromptInclusion.status === \"included\" ? Math.ceil(promptInclusion.blockChars / 4) : 0;\n\t\t// Enforcement stubs are applied at SEND time (not persisted), so the message view here\n\t\t// still holds raw text for them; subtract what stubbing reclaims per request.\n\t\tconst enforcementSavedTokens = enforcementItems\n\t\t\t.filter((item) => item.enforced && typeof item.originalChars === \"number\")\n\t\t\t.reduce((sum, item) => sum + Math.max(0, Math.ceil((item.originalChars ?? 0) / 4) - 50), 0);\n\t\treturn buildContextCompositionReport({\n\t\t\tsystemPrompt: this.systemPrompt ?? \"\",\n\t\t\ttools: this.getAllTools()\n\t\t\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t\t\t.map((tool) => ({\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\tsource: extensionToolNames.has(tool.name) ? (\"extension\" as const) : (\"built-in\" as const),\n\t\t\t\t})),\n\t\t\textensions: extensions.map((extension) => ({\n\t\t\t\tname: basename(extension.path),\n\t\t\t\tpath: extension.path,\n\t\t\t\ttoolNames: [...extension.tools.keys()],\n\t\t\t\tcommandCount: extension.commands.size,\n\t\t\t})),\n\t\t\tmessages: gcResult.messages,\n\t\t\tproviderReportedTokens: usage?.tokens ?? null,\n\t\t\tcontextWindow: usage?.contextWindow ?? this.model?.contextWindow ?? null,\n\t\t\tgc: { packedCount: gcResult.report.packedCount, savedTokens: gcResult.report.savedTokens },\n\t\t\tenforcement: {\n\t\t\t\tenforcedCount: enforcementItems.filter((item) => item.enforced).length,\n\t\t\t\tadvisoryEvictions: enforcementItems.filter((item) => item.advisory === \"brain_irrelevant\").length,\n\t\t\t},\n\t\t\tcuration: {\n\t\t\t\tenabled: curationStatus.enabled,\n\t\t\t\ttelemetry: curationStatus.telemetry,\n\t\t\t\tlastSkipReason: curationStatus.lastSkipReason,\n\t\t\t},\n\t\t\tspawned: { cost: spawned.cost, reports: spawned.reports },\n\t\t\tadjustments: { memoryEvidenceTokens, enforcementSavedTokens },\n\t\t\textraObservations: [\n\t\t\t\t...this._resourceLoader.getAgentsDiagnostics().map((diagnostic) => diagnostic.message),\n\t\t\t\t...this._profileFilter.profileDeniedResourceObservations(),\n\t\t\t\t...this._profileFilter.getInertExtensionWarnings(),\n\t\t\t\t...this._unboundToolGrantWarnings,\n\t\t\t\t// G7: auto-built per-turn foreground envelope (observe-only; not enforced). Falls back to a\n\t\t\t\t// live preview when no turn has run yet so /context always shows the current scope.\n\t\t\t\tformatForegroundEnvelopeObservation(\n\t\t\t\t\tthis._currentForegroundEnvelope ?? this._buildForegroundEnvelopeFromState(),\n\t\t\t\t),\n\t\t\t\t// G14 (ratified): a user disable always beats a profile grant — surface the conflict.\n\t\t\t\t...([\"tools\", \"skills\", \"prompts\", \"extensions\"] as const).flatMap((kind) =>\n\t\t\t\t\tthis.settingsManager\n\t\t\t\t\t\t.getProfileGrantsOverriddenByUserDisable(kind)\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\t\t`profile grants ${kind} \"${entry}\" but your disable list overrides it (user disable wins; re-enable to use)`,\n\t\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\t/** Bounded plain-text rendering of {@link getContextCompositionReport} for the /context command. */\n\tformatContextCompositionDashboard(): string {\n\t\treturn formatContextCompositionDashboard(this.getContextCompositionReport());\n\t}\n\n\tformatToolRepairHealthReport(): string {\n\t\treturn formatToolRepairHealthReport(this._modelAdaptationStore, new Date(), this._toolRecoveryLogger.getStats());\n\t}\n\n\tasync flushToolRecoveryLogsForTests(timeoutMs = 1000): Promise<void> {\n\t\tawait this._toolRecoveryLogger.flush(timeoutMs);\n\t}\n\n\tremoveToolRepairRule(model: string, mode: string): boolean {\n\t\treturn this._modelAdaptationStore.removeRule(model, mode);\n\t}\n\n\tresetToolProtocolCalibration(model: string): boolean {\n\t\tconst removed = this._modelAdaptationStore.removeProtocol(model);\n\t\tthis._textProtocolParseFailures.delete(model);\n\t\treturn removed;\n\t}\n\n\t/** Curation status for diagnostics/dashboard: settings, live telemetry, last refusal reason. */\n\t/** Curation status for diagnostics/dashboard (delegates to {@link ContextPipeline.getContextCurationStatus}). */\n\tgetContextCurationStatus(): {\n\t\tenabled: boolean;\n\t\tmodel?: string;\n\t\ttelemetry: CurationTelemetrySnapshot;\n\t\tlastSkipReason?: string;\n\t\tlastPreDigestSkipReason?: string;\n\t} {\n\t\treturn this._pipeline.getContextCurationStatus();\n\t}\n\n\t/** Read-only inspection of the latest prompt-enforcement report, for tests/debugging. */\n\tgetPromptEnforcementReport(): PromptEnforcementReport {\n\t\treturn this._pipeline.getPromptEnforcementReport();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link MemoryController.runMemoryRetrieval}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runMemoryRetrieval(messages: AgentMessage[]): Promise<MemoryRetrievalReport> {\n\t\treturn this._memory.runMemoryRetrieval(messages);\n\t}\n\n\t/** Read-only inspection of the latest memory-retrieval report, for tests/debugging. */\n\tgetMemoryRetrievalReport(): MemoryRetrievalReport {\n\t\treturn this._memory.getMemoryRetrievalReport();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link MemoryController.maybeAppendMemoryEvidenceBlock}.\n\t * Kept as a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _maybeAppendMemoryEvidenceBlock(messages: AgentMessage[], report: MemoryRetrievalReport): AgentMessage[] {\n\t\treturn this._memory.maybeAppendMemoryEvidenceBlock(messages, report);\n\t}\n\n\t/** Read-only inspection of the latest memory-prompt-inclusion decision, for tests/debugging and context_audit. */\n\tgetMemoryPromptInclusionReport(): MemoryPromptInclusionReport {\n\t\treturn this._memory.getMemoryPromptInclusionReport();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.applyContextGc}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering;\n\t * also serves the composition dashboard and {@link getContextGcReport} read-only paths.\n\t */\n\tprivate _applyContextGc(\n\t\tmessages: AgentMessage[],\n\t\twritePayloads: boolean,\n\t): { messages: AgentMessage[]; report: ContextGcReport } {\n\t\treturn this._pipeline.applyContextGc(messages, writePayloads);\n\t}\n\n\t/** Read-only inspection of the latest context-gc report (delegates to {@link ContextPipeline.getContextGcReport}). */\n\tgetContextGcReport(messages?: AgentMessage[]): ContextGcReport {\n\t\treturn this._pipeline.getContextGcReport(messages);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.estimateCurrentContextTokens}. Kept\n\t * as a one-line method (not inlined) so the transform stays the single owner of the pass ordering;\n\t * also feeds the per-turn cost guard.\n\t */\n\tprivate _estimateCurrentContextTokens(messages: AgentMessage[]): number {\n\t\treturn this._pipeline.estimateCurrentContextTokens(messages);\n\t}\n\n\tprivate _installAgentToolHooks(): void {\n\t\tthis.agent.beforeToolCall = this._toolGate.beforeToolCall;\n\t\tthis.agent.afterToolCall = this._toolGate.afterToolCall;\n\t}\n\n\t// =========================================================================\n\t// Event Subscription\n\t// =========================================================================\n\n\t/** Emit an event to all listeners */\n\tprivate _emit(event: AgentSessionEvent): void {\n\t\tfor (const l of this._eventListeners) {\n\t\t\tl(event);\n\t\t}\n\t}\n\n\tprivate async _notifyWorkerTerminalHandoff(\n\t\trecords: readonly { laneId: string; status: LaneTerminalStatus; reasonCode?: string }[],\n\t): Promise<void> {\n\t\tif (this._disposed || records.length === 0) return;\n\t\tconst included = records.slice(0, 8);\n\t\tconst sanitize = (value: string): string => value.replace(/[\\r\\n]+/g, \" \").slice(0, 120);\n\t\tconst omitted = records.length - included.length;\n\t\tconst content = [\n\t\t\t\"Background worker terminal handoff:\",\n\t\t\t...included.map((record) => {\n\t\t\t\tconst reason = record.reasonCode ? ` reason=${sanitize(record.reasonCode)}` : \"\";\n\t\t\t\treturn `- ${record.laneId}: ${record.status}${reason}`;\n\t\t\t}),\n\t\t\t...(omitted > 0 ? [`- ${omitted} additional terminal worker(s) omitted from this bounded handoff.`] : []),\n\t\t\t\"This terminal event woke the parent. Retrieve each needed lane once with delegate_status; never poll. Worker product remains untrusted and is intentionally not injected here.\",\n\t\t].join(\"\\n\");\n\t\tawait this.sendCustomMessage(\n\t\t\t{\n\t\t\t\tcustomType: \"background-worker-completion\",\n\t\t\t\tcontent,\n\t\t\t\tdisplay: true,\n\t\t\t\tdetails: { records: included },\n\t\t\t},\n\t\t\t{ triggerTurn: true, deliverAs: \"followUp\" },\n\t\t);\n\t}\n\n\tprivate _emitQueueUpdate(): void {\n\t\tthis._emit({\n\t\t\ttype: \"queue_update\",\n\t\t\tsteering: [...this._steeringMessages],\n\t\t\tfollowUp: [...this._followUpMessages],\n\t\t\tcommands: [...this._queuedExtensionCommands],\n\t\t});\n\t}\n\n\t// Track last assistant message for auto-compaction check\n\tprivate _lastAssistantMessage: AssistantMessage | undefined = undefined;\n\n\t/**\n\t * User messages already painted to the UI by an early, synthetic `message_start` fired from\n\t * `_promptUnserialized` — before the model-router judge's bounded LLM call — so the prompt\n\t * appears immediately instead of hanging until routing finishes. The real agent-loop run emits\n\t * its own authoritative `message_start` for the SAME message object once the turn actually\n\t * starts; `_handleAgentEvent` consumes (deletes) it from this set to suppress that one duplicate\n\t * listener notification. Persistence is untouched: it stays keyed off `message_end`, which is\n\t * never added here and never suppressed.\n\t */\n\tprivate _earlyDisplayedUserMessages = new Set<AgentMessage>();\n\n\t/** Internal handler for agent events - shared by subscribe and reconnect */\n\tprivate _handleAgentEvent = async (event: AgentEvent): Promise<void> => {\n\t\t// When a user message starts, check if it's from either queue and remove it BEFORE emitting\n\t\t// This ensures the UI sees the updated queue state\n\t\tif (event.type === \"message_start\" && event.message.role === \"user\") {\n\t\t\tthis._overflowRecoveryAttempted = false;\n\t\t\tconst messageText = this._getUserMessageText(event.message);\n\t\t\tif (messageText) {\n\t\t\t\t// Check steering queue first\n\t\t\t\tconst steeringIndex = this._steeringMessages.indexOf(messageText);\n\t\t\t\tif (steeringIndex !== -1) {\n\t\t\t\t\tthis._steeringMessages.splice(steeringIndex, 1);\n\t\t\t\t\tthis._emitQueueUpdate();\n\t\t\t\t} else {\n\t\t\t\t\t// Check follow-up queue\n\t\t\t\t\tconst followUpIndex = this._followUpMessages.indexOf(messageText);\n\t\t\t\t\tif (followUpIndex !== -1) {\n\t\t\t\t\t\tthis._followUpMessages.splice(followUpIndex, 1);\n\t\t\t\t\t\tthis._emitQueueUpdate();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Emit to extensions first\n\t\tawait this._emitExtensionEvent(event);\n\n\t\tconst suppressRetryPromptEvent =\n\t\t\tthis._modelRouter.isRetryInFlight() &&\n\t\t\t(event.type === \"message_start\" || event.type === \"message_end\") &&\n\t\t\t(event.message.role === \"user\" || event.message.role === \"custom\");\n\n\t\t// This is the authoritative message_start for a user message already painted early (see\n\t\t// _promptUnserialized). Set#delete both tests and consumes membership in one step, so only\n\t\t// this one duplicate is suppressed and a later, unrelated user message is never affected.\n\t\tconst suppressAlreadyDisplayedUserMessage =\n\t\t\tevent.type === \"message_start\" &&\n\t\t\tevent.message.role === \"user\" &&\n\t\t\tthis._earlyDisplayedUserMessages.delete(event.message);\n\n\t\t// Notify all listeners\n\t\tif (!suppressRetryPromptEvent && !suppressAlreadyDisplayedUserMessage) {\n\t\t\tthis._emit(event.type === \"agent_end\" ? { ...event, willRetry: this._willRetryAfterAgentEnd(event) } : event);\n\t\t}\n\n\t\t// Handle session/context retention. Tool result details are UI/log metadata,\n\t\t// not provider-visible content, and large graph/search payloads can otherwise\n\t\t// accumulate until the interactive Node process hits the V8 heap limit.\n\t\tif (event.type === \"message_end\") {\n\t\t\tcompactToolResultDetailsForRetention(event.message);\n\t\t\tlet messagePersisted = false;\n\t\t\t// While a cheap routed turn is buffering, its messages are captured for later flush/discard\n\t\t\t// instead of persisted here (see ModelRouterController.captureSessionMessage).\n\t\t\tif (this._modelRouter.captureSessionMessage(event.message)) {\n\t\t\t\t// buffered by the router; persistence is deferred to the routed-turn flush\n\t\t\t}\n\t\t\t// Check if this is a custom message from extensions\n\t\t\telse if (event.message.role === \"custom\") {\n\t\t\t\t// Persist as CustomMessageEntry\n\t\t\t\tthis.sessionManager.appendCustomMessageEntry(\n\t\t\t\t\tevent.message.customType,\n\t\t\t\t\tevent.message.content,\n\t\t\t\t\tevent.message.display,\n\t\t\t\t\tevent.message.details,\n\t\t\t\t);\n\t\t\t\tmessagePersisted = true;\n\t\t\t} else if (\n\t\t\t\tevent.message.role === \"user\" ||\n\t\t\t\tevent.message.role === \"assistant\" ||\n\t\t\t\tevent.message.role === \"toolResult\"\n\t\t\t) {\n\t\t\t\t// Regular LLM message - persist as SessionMessageEntry\n\t\t\t\tthis.sessionManager.appendMessage(event.message);\n\t\t\t\tmessagePersisted = true;\n\t\t\t}\n\t\t\t// Other message types (bashExecution, compactionSummary, branchSummary) are persisted elsewhere\n\n\t\t\t// Track assistant message for auto-compaction (checked on agent_end)\n\t\t\tif (event.message.role === \"assistant\") {\n\t\t\t\tthis._lastAssistantMessage = event.message;\n\n\t\t\t\tconst assistantMsg = event.message as AssistantMessage;\n\t\t\t\tif (messagePersisted) {\n\t\t\t\t\tthis._pipeline.observeProviderUsage(this.agent.state.messages, assistantMsg);\n\t\t\t\t}\n\t\t\t\tif (assistantMsg.stopReason !== \"error\") {\n\t\t\t\t\tthis._overflowRecoveryAttempted = false;\n\t\t\t\t}\n\n\t\t\t\t// Reset retry counter immediately on successful assistant response\n\t\t\t\t// This prevents accumulation across multiple LLM calls within a turn\n\t\t\t\tif (assistantMsg.stopReason !== \"error\" && this._retryController.attempt > 0) {\n\t\t\t\t\tthis._emit({\n\t\t\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tattempt: this._retryController.attempt,\n\t\t\t\t\t});\n\t\t\t\t\tthis._retryController.reset();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate _willRetryAfterAgentEnd(event: Extract<AgentEvent, { type: \"agent_end\" }>): boolean {\n\t\tconst settings = this.settingsManager.getRetrySettings();\n\t\tif (!settings.enabled || this._retryController.attempt >= settings.maxRetries) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = event.messages.length - 1; i >= 0; i--) {\n\t\t\tconst message = event.messages[i];\n\t\t\tif (message.role === \"assistant\") {\n\t\t\t\treturn this._isRetryableError(message as AssistantMessage);\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Extract text content from a message */\n\tprivate _getUserMessageText(message: Message): string {\n\t\tif (message.role !== \"user\") return \"\";\n\t\tconst content = message.content;\n\t\tif (typeof content === \"string\") return content;\n\t\tconst textBlocks = content.filter((c) => c.type === \"text\");\n\t\treturn textBlocks.map((c) => (c as TextContent).text).join(\"\");\n\t}\n\n\t/** Find the last assistant message in agent state (including aborted ones) */\n\tprivate _findLastAssistantMessage(): AssistantMessage | undefined {\n\t\tconst messages = this.agent.state.messages;\n\t\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\t\tconst msg = messages[i];\n\t\t\tif (msg.role === \"assistant\") {\n\t\t\t\treturn msg as AssistantMessage;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate _replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void {\n\t\t// Agent-core stores the finalized message object in its state before emitting message_end.\n\t\t// SessionManager persistence happens later in _handleAgentEvent() with event.message.\n\t\t// Mutating this object in place keeps agent state, later turn/agent events, listeners,\n\t\t// and the eventual SessionManager.appendMessage(event.message) persistence in sync.\n\t\tif (target === replacement) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst targetRecord = target as unknown as Record<string, unknown>;\n\t\tfor (const key of Object.keys(targetRecord)) {\n\t\t\tdelete targetRecord[key];\n\t\t}\n\t\tObject.assign(targetRecord, replacement);\n\t}\n\n\t/** Emit extension events based on agent events */\n\tprivate async _emitExtensionEvent(event: AgentEvent): Promise<void> {\n\t\tif (event.type === \"agent_start\") {\n\t\t\tthis._turnIndex = 0;\n\t\t\tawait this._extensionRunner.emit({ type: \"agent_start\" });\n\t\t} else if (event.type === \"agent_end\") {\n\t\t\tawait this._extensionRunner.emit({ type: \"agent_end\", messages: event.messages });\n\t\t} else if (event.type === \"turn_start\") {\n\t\t\tthis._toolSelection.startTurn();\n\t\t\tthis._refreshForegroundEnvelope();\n\t\t\tconst extensionEvent: TurnStartEvent = {\n\t\t\t\ttype: \"turn_start\",\n\t\t\t\tturnIndex: this._turnIndex,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"turn_end\") {\n\t\t\tconst extensionEvent: TurnEndEvent = {\n\t\t\t\ttype: \"turn_end\",\n\t\t\t\tturnIndex: this._turnIndex,\n\t\t\t\tmessage: event.message,\n\t\t\t\ttoolResults: event.toolResults,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t\tthis._turnIndex++;\n\t\t} else if (event.type === \"message_start\") {\n\t\t\tconst extensionEvent: MessageStartEvent = {\n\t\t\t\ttype: \"message_start\",\n\t\t\t\tmessage: event.message,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"message_update\") {\n\t\t\tconst extensionEvent: MessageUpdateEvent = {\n\t\t\t\ttype: \"message_update\",\n\t\t\t\tmessage: event.message,\n\t\t\t\tassistantMessageEvent: event.assistantMessageEvent,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"message_end\") {\n\t\t\tconst extensionEvent: MessageEndEvent = {\n\t\t\t\ttype: \"message_end\",\n\t\t\t\tmessage: event.message,\n\t\t\t};\n\t\t\tconst replacement = await this._extensionRunner.emitMessageEnd(extensionEvent);\n\t\t\tif (replacement) {\n\t\t\t\tthis._replaceMessageInPlace(event.message, replacement);\n\t\t\t}\n\t\t} else if (event.type === \"tool_execution_start\") {\n\t\t\tconst extensionEvent: ToolExecutionStartEvent = {\n\t\t\t\ttype: \"tool_execution_start\",\n\t\t\t\ttoolCallId: event.toolCallId,\n\t\t\t\ttoolName: event.toolName,\n\t\t\t\targs: event.args,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"tool_execution_update\") {\n\t\t\tconst extensionEvent: ToolExecutionUpdateEvent = {\n\t\t\t\ttype: \"tool_execution_update\",\n\t\t\t\ttoolCallId: event.toolCallId,\n\t\t\t\ttoolName: event.toolName,\n\t\t\t\targs: event.args,\n\t\t\t\tpartialResult: event.partialResult,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"tool_execution_end\") {\n\t\t\tconst extensionEvent: ToolExecutionEndEvent = {\n\t\t\t\ttype: \"tool_execution_end\",\n\t\t\t\ttoolCallId: event.toolCallId,\n\t\t\t\ttoolName: event.toolName,\n\t\t\t\tresult: event.result,\n\t\t\t\tisError: event.isError,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t}\n\t}\n\n\t/**\n\t * Subscribe to agent events.\n\t * Session persistence is handled internally (saves messages on message_end).\n\t * Multiple listeners can be added. Returns unsubscribe function for this listener.\n\t */\n\tsubscribe(listener: AgentSessionEventListener): () => void {\n\t\tthis._eventListeners.push(listener);\n\n\t\t// Return unsubscribe function for this specific listener\n\t\treturn () => {\n\t\t\tconst index = this._eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis._eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Subscribe to extensions changed events (load/unload live).\n\t * Returns unsubscribe function for this listener.\n\t */\n\tonExtensionsChanged(cb: () => void): () => void {\n\t\tthis._extensionsChangedListeners.push(cb);\n\n\t\treturn () => {\n\t\t\tconst index = this._extensionsChangedListeners.indexOf(cb);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis._extensionsChangedListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Notify all extensions-changed listeners.\n\t * Called after successful load/unload operations.\n\t */\n\tprivate _notifyExtensionsChanged(): void {\n\t\tfor (const listener of this._extensionsChangedListeners) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// Suppress errors from listeners to avoid cascading failures\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Temporarily disconnect from agent events.\n\t * User listeners are preserved and will receive events again after resubscribe().\n\t * Used internally during operations that need to pause event processing.\n\t */\n\tprivate _disconnectFromAgent(): void {\n\t\tif (this._unsubscribeAgent) {\n\t\t\tthis._unsubscribeAgent();\n\t\t\tthis._unsubscribeAgent = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Reconnect to agent events after _disconnectFromAgent().\n\t * Preserves all existing listeners.\n\t */\n\tprivate _reconnectToAgent(): void {\n\t\tif (this._unsubscribeAgent) return; // Already connected\n\t\tthis._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);\n\t}\n\n\t/**\n\t * Remove all listeners and disconnect from agent.\n\t * Call this when completely done with the session.\n\t */\n\tdispose(): void {\n\t\ttry {\n\t\t\tthis._backgroundLanes.clearGoalAutoContinueTimer();\n\t\t\tthis._backgroundLanes.clearResearchLaneTimer();\n\t\t\tthis.abortRetry();\n\t\t\tthis.abortCompaction();\n\t\t\tthis.abortBranchSummary();\n\t\t\tthis.abortBash();\n\t\t\tthis._cancelPrefixWarm();\n\t\t\tthis.agent.abort();\n\t\t\t// R8: stop any deployment-registered gateway channels / schedulers.\n\t\t\tvoid this._gatewayRegistry.stop().catch(() => {});\n\t\t\t// Bug #21: abort any in-flight background reflection so it cannot keep spending tokens or\n\t\t\t// write memory/skills against this now-disposed session.\n\t\t\tthis._disposed = true;\n\t\t\tthis._reflectionAbort.abort();\n\t\t\t// Abort any in-flight research pass or delegated worker for the same reason: a disposed\n\t\t\t// session must not keep spending tokens or persist evidence against dead state.\n\t\t\tthis._backgroundLanes.abortInFlightLanes();\n\t\t\t// Bug #20: clear the hooks this session installed on the shared agent so their closures stop\n\t\t\t// pinning this (deactivated) session — and all its history/maps — in memory if the agent\n\t\t\t// instance outlives the session.\n\t\t\tthis.agent.afterToolCall = undefined;\n\t\t\tthis.agent.transformContext = undefined;\n\t\t} catch {\n\t\t\t// Dispose must succeed even if an abort hook throws.\n\t\t}\n\n\t\tthis._extensionRunner.invalidate(\n\t\t\t\"This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().\",\n\t\t);\n\t\tthis._disconnectFromAgent();\n\t\tthis._eventListeners = [];\n\t\t// Best-effort memory cleanup (release locks/handles). Write-side onSessionEnd is wired on a\n\t\t// true session-end hook (P3); file-store shutdown is a no-op.\n\t\tvoid this._memory\n\t\t\t.getMemoryManager()\n\t\t\t.shutdownAll()\n\t\t\t.catch(() => {});\n\t\tvoid this._toolRecoveryLogger.shutdown().catch(() => {});\n\t\tcleanupSessionResources(this.sessionId);\n\t\t// Best-effort final sweep for any grep/find artifact already released (reference\n\t\t// count zero) but not yet reclaimed -- e.g. a release whose cleanup() call failed\n\t\t// transiently. This is conservative: it never releases a still-referenced\n\t\t// artifact, so a session that ends before context-gc ever evicts a result (too\n\t\t// short to cross preserveRecentMessages) correctly leaves that artifact in place,\n\t\t// resolvable if the same session is resumed later. It does not sweep OTHER\n\t\t// sessions' artifact directories.\n\t\ttry {\n\t\t\tthis._pipeline.cleanupToolArtifactStoreOnDispose();\n\t\t} catch {\n\t\t\t// Best-effort; dispose must succeed regardless.\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Read-only State Access\n\t// =========================================================================\n\n\t/** Full agent state */\n\tget state(): AgentState {\n\t\treturn this.agent.state;\n\t}\n\n\t/** Current model (may be undefined if not yet selected) */\n\tget model(): Model<any> | undefined {\n\t\treturn this.agent.state.model;\n\t}\n\n\t/** Current thinking level */\n\tget thinkingLevel(): ThinkingLevel {\n\t\treturn this.agent.state.thinkingLevel;\n\t}\n\n\t/** Whether agent is currently streaming a response */\n\tget isStreaming(): boolean {\n\t\treturn this.agent.state.isStreaming;\n\t}\n\n\t/** Current effective system prompt (includes any per-turn extension modifications) */\n\tget systemPrompt(): string {\n\t\treturn this.agent.state.systemPrompt;\n\t}\n\n\t/** Current retry attempt (0 if not retrying) */\n\tget retryAttempt(): number {\n\t\treturn this._retryController.attempt;\n\t}\n\n\t/**\n\t * Get the names of currently active tools.\n\t * Returns the names of tools currently set on the agent.\n\t */\n\tgetActiveToolNames(): string[] {\n\t\treturn this.agent.state.tools.map((t) => t.name);\n\t}\n\n\t/** G7: build a foreground {@link CapabilityEnvelope} from the live session state (active tools, cwd, cost ceiling). */\n\tprivate _buildForegroundEnvelopeFromState(): CapabilityEnvelope {\n\t\treturn buildForegroundEnvelope({\n\t\t\tturnIndex: this._turnIndex,\n\t\t\tactiveToolNames: this.getActiveToolNames(),\n\t\t\tcwd: this._cwd,\n\t\t\tmaxTurnUsd: this.settingsManager.getCostGuardSettings().maxTurnUsd,\n\t\t});\n\t}\n\n\t/**\n\t * G7: (re)build the foreground envelope for the current turn. Visibility only -- the foreground\n\t * envelope is NOT enforced this round. Best-effort: never throws into the turn.\n\t */\n\tprivate _refreshForegroundEnvelope(): void {\n\t\ttry {\n\t\t\tthis._currentForegroundEnvelope = this._buildForegroundEnvelopeFromState();\n\t\t} catch {\n\t\t\t// Visibility only: a failure to build the envelope must never disturb the turn.\n\t\t}\n\t}\n\n\t/** G7: the auto-constructed foreground envelope for the current/most-recent turn (visibility only). */\n\tgetForegroundEnvelope(): CapabilityEnvelope | undefined {\n\t\treturn this._currentForegroundEnvelope;\n\t}\n\n\t/**\n\t * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.\n\t */\n\tgetAllTools(): ToolInfo[] {\n\t\treturn this._runtimeBuilder.getAllTools();\n\t}\n\n\tgetToolDefinition(name: string): ToolDefinition | undefined {\n\t\treturn this._runtimeBuilder.getToolDefinition(name);\n\t}\n\n\t/**\n\t * Set active tools by name.\n\t * Only tools in the registry can be enabled. Unknown tool names are ignored.\n\t * Also rebuilds the system prompt to reflect the new tool set.\n\t * Changes take effect on the next agent turn.\n\t *\n\t * artifact_retrieve is auto-activated as a companion whenever an artifact-producing tool\n\t * (grep, find, or run_toolkit_script) ends up in the resulting active set and artifact_retrieve\n\t * is registered (i.e. not excluded/\n\t * blocked/outside an allowlist -- the registry itself is built with that same filter,\n\t * so registry presence already tracks \"allowed\"). This is enforced here, not just in\n\t * the settings/profile refresh flow, because this method is a public, extension-\n\t * exposed activation path (`setActiveTools`) on its own: without this, grep/find could\n\t * end up active while still being handed an artifact store (gated on \"allowed\" in\n\t * `_buildRuntime`) with no active tool able to resolve the resulting\n\t * \"Full output: artifact tool-output:<id>\" handle.\n\t */\n\tsetActiveToolsByName(toolNames: string[]): void {\n\t\t// Model capability: small-window models get a reduced tool surface derived from the model's\n\t\t// own metadata. The unfiltered request is remembered so a later switch to a larger model\n\t\t// restores it (the filter is re-applied on every model change).\n\t\tthis._requestedActiveToolNames = [...toolNames];\n\t\tconst capabilityFiltered = filterToolNamesForCapability(toolNames, this.getModelCapabilityProfile());\n\n\t\tconst tools: AgentTool[] = [];\n\t\tconst validToolNames: string[] = [];\n\t\tconst seen = new Set<string>();\n\t\tconst addIfRegistered = (name: string): void => {\n\t\t\tif (seen.has(name)) return;\n\t\t\tconst tool = this._runtimeBuilder.getRegisteredTool(name);\n\t\t\tif (!tool) return;\n\t\t\tseen.add(name);\n\t\t\ttools.push(tool);\n\t\t\tvalidToolNames.push(name);\n\t\t};\n\n\t\tfor (const name of capabilityFiltered) {\n\t\t\taddIfRegistered(name);\n\t\t}\n\t\tif (\n\t\t\tvalidToolNames.includes(\"grep\") ||\n\t\t\tvalidToolNames.includes(\"find\") ||\n\t\t\tvalidToolNames.includes(\"run_toolkit_script\")\n\t\t) {\n\t\t\taddIfRegistered(\"artifact_retrieve\");\n\t\t}\n\t\tif (validToolNames.includes(\"delegate\")) {\n\t\t\taddIfRegistered(\"delegate_status\");\n\t\t}\n\n\t\tthis.agent.state.tools = tools;\n\n\t\t// Rebuild base system prompt with new tool set\n\t\tthis._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);\n\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\n\t\tthis._checkContextWindowUsageWarning();\n\t}\n\n\t/** Whether compaction or branch summarization is currently running */\n\tget isCompacting(): boolean {\n\t\treturn (\n\t\t\tthis._autoCompactionAbortController !== undefined ||\n\t\t\tthis._compactionAbortController !== undefined ||\n\t\t\tthis._branchSummaryAbortController !== undefined\n\t\t);\n\t}\n\n\t/** All messages including custom types like BashExecutionMessage */\n\tget messages(): AgentMessage[] {\n\t\treturn this.agent.state.messages;\n\t}\n\n\t/** Current steering mode */\n\tget steeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.agent.steeringMode;\n\t}\n\n\t/** Current follow-up mode */\n\tget followUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.agent.followUpMode;\n\t}\n\n\t/** Current session file path, or undefined if sessions are disabled */\n\tget sessionFile(): string | undefined {\n\t\treturn this.sessionManager.getSessionFile();\n\t}\n\n\t/** Current session ID */\n\tget sessionId(): string {\n\t\treturn this.sessionManager.getSessionId();\n\t}\n\n\t/** Current session display name, if set */\n\tget sessionName(): string | undefined {\n\t\treturn this.sessionManager.getSessionName();\n\t}\n\n\t/** Scoped models for cycling (from --models flag) */\n\tget scopedModels(): ReadonlyArray<{ model: Model<any>; thinkingLevel?: ThinkingLevel }> {\n\t\treturn this._scopedModels;\n\t}\n\n\t/** Update scoped models for cycling */\n\tsetScopedModels(scopedModels: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>): void {\n\t\tthis._scopedModels = scopedModels;\n\t}\n\n\t/** File-based prompt templates */\n\tget promptTemplates(): ReadonlyArray<PromptTemplate> {\n\t\treturn this._resourceLoader.getActivePrompts();\n\t}\n\n\t// System-prompt construction lives in SystemPromptBuilder (see system-prompt-builder.ts). These\n\t// stubs keep the god file's internal call surface stable while the assembly logic — situational\n\t// soul, self-modification/autonomy guardrails, per-tool snippet/guideline options — lives there.\n\tprivate _normalizePromptSnippet(text: string | undefined): string | undefined {\n\t\treturn this._systemPromptBuilder.normalizePromptSnippet(text);\n\t}\n\n\tprivate _normalizePromptGuidelines(guidelines: string[] | undefined): string[] {\n\t\treturn this._systemPromptBuilder.normalizePromptGuidelines(guidelines);\n\t}\n\n\tprivate _rebuildSystemPrompt(toolNames: string[]): string {\n\t\treturn this._systemPromptBuilder.rebuildSystemPrompt(toolNames);\n\t}\n\n\tprivate _refreshBaseSystemPrompt(): void {\n\t\tconst previousBaseSystemPrompt = this._baseSystemPrompt;\n\t\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\t\tif (this.agent.state.systemPrompt === previousBaseSystemPrompt) {\n\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t}\n\t}\n\n\t/**\n\t * Build a system prompt for a specific tool surface WITHOUT touching the session's base prompt\n\t * state (G4 router-swap; see {@link SystemPromptBuilder.buildSystemPromptForToolNames}).\n\t */\n\tprivate _buildSystemPromptForToolNames(toolNames: string[]): string {\n\t\treturn this._systemPromptBuilder.buildSystemPromptForToolNames(toolNames);\n\t}\n\n\t// =========================================================================\n\t// Prompting\n\t// =========================================================================\n\n\tprivate async _runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void> {\n\t\ttry {\n\t\t\tconst maxGoalLoopRounds = this.settingsManager.getAutonomySettings().maxStallTurns;\n\t\t\tthis.agent.maxStallTurns = maxGoalLoopRounds;\n\t\t\tawait this._ensureTextToolProtocolForActiveModel();\n\t\t\tlet goalLoopRounds = 1;\n\t\t\tawait this.agent.prompt(messages);\n\t\t\twhile ((maxGoalLoopRounds === 0 || goalLoopRounds < maxGoalLoopRounds) && (await this._handlePostAgentRun())) {\n\t\t\t\tawait this.agent.continue();\n\t\t\t\tgoalLoopRounds++;\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._flushPendingBashMessages();\n\t\t\tawait this._drainQueuedExtensionCommands();\n\t\t}\n\t}\n\n\t/**\n\t * Shared {@link OllamaRuntime} for a given server, lazily created and cached by baseUrl so every\n\t * caller — the router's readiness gate and any host UI's own model-lifecycle commands (e.g.\n\t * `/models`) — sees and can stop the SAME pi-managed process instead of each tracking its own\n\t * untracked child. Delegates to {@link LocalRuntimeController}.\n\t */\n\tgetLocalRuntime(baseUrl?: string): OllamaRuntime {\n\t\treturn this._localRuntimeController.getLocalRuntime(baseUrl);\n\t}\n\n\tgetTransformersRuntime(modelId: string, baseUrl?: string): TransformersRuntime {\n\t\treturn this._localRuntimeController.getTransformersRuntime(modelId, baseUrl);\n\t}\n\n\t/** models.json registers a local model's baseUrl as `<server>/v1` (OpenAI-compat); the runtime's\n\t * own health/boot endpoints are on the Ollama-native server root. Delegates to\n\t * {@link LocalRuntimeController}; kept here for `_warnIfManualModelChoiceIsRisky`'s own use. */\n\tprivate _deriveOllamaServerUrl(modelBaseUrl: string): string {\n\t\treturn this._localRuntimeController.deriveOllamaServerUrl(modelBaseUrl);\n\t}\n\n\t/**\n\t * Router-swap gate (#27): a turn routed to a local model must not dead-end the turn just because\n\t * ollama isn't up. Delegates to {@link LocalRuntimeController}; see there for the full\n\t * consent-then-escalate contract (which includes the local-model readiness check itself).\n\t */\n\tprivate async _ensureRouteModelReady(\n\t\tresolved: { decision: RouteDecision; model: Model<Api> } | undefined,\n\t): Promise<{ decision: RouteDecision; model: Model<Api> } | undefined> {\n\t\treturn this._localRuntimeController.ensureRouteModelReady(resolved);\n\t}\n\n\tgetModelRouterStatus(formatLabel?: (label: string) => string): string {\n\t\treturn this._modelRouter.getStatus(formatLabel);\n\t}\n\n\tprivate async _handlePostAgentRun(): Promise<boolean> {\n\t\tconst msg = this._lastAssistantMessage;\n\t\tthis._lastAssistantMessage = undefined;\n\t\tif (!msg) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst classified = this._classifyAssistantError(msg);\n\t\tif (classified) {\n\t\t\tthis._failureCorpus.record({\n\t\t\t\tprovider: msg.provider,\n\t\t\t\tmodelId: msg.model,\n\t\t\t\tmessage: msg.errorMessage ?? \"\",\n\t\t\t\tclassified,\n\t\t\t});\n\t\t}\n\t\tif (classified?.retryable && (await this._prepareRetry(msg))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (await this._billingFailover.handleAssistantError(msg, classified)) return false;\n\n\t\tif (msg.stopReason === \"error\" && this._retryController.attempt > 0) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\tsuccess: false,\n\t\t\t\tattempt: this._retryController.attempt,\n\t\t\t\tfinalError: msg.errorMessage,\n\t\t\t});\n\t\t\tthis._retryController.reset();\n\t\t}\n\n\t\tif (await this._checkCompaction(msg)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// The agent loop drains both queues before emitting agent_end. Any messages\n\t\t// here were queued by agent_end extension handlers and need a continuation.\n\t\treturn this.agent.hasQueuedMessages();\n\t}\n\n\t/**\n\t * Send a prompt to the agent.\n\t * - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming\n\t * - Expands file-based prompt templates by default\n\t * - During streaming, queues via steer() or followUp() based on streamingBehavior option\n\t * - Validates model and API key before sending (when not streaming)\n\t * @throws Error if streaming and no streamingBehavior specified\n\t * @throws Error if no model selected or no API key available (when not streaming)\n\t */\n\tasync prompt(text: string, options?: PromptOptions): Promise<void> {\n\t\tif (options?.autoContinueGoal !== false) {\n\t\t\tthis._backgroundLanes.clearGoalAutoContinueTimer();\n\t\t}\n\n\t\tif ((this.isStreaming || this.isRetrying) && options?.streamingBehavior) {\n\t\t\tconst run = this._streamingPromptSubmissionTail.then(\n\t\t\t\t() => this._promptUnserialized(text, options),\n\t\t\t\t() => this._promptUnserialized(text, options),\n\t\t\t);\n\t\t\tthis._streamingPromptSubmissionTail = run.catch(() => {});\n\t\t\treturn run;\n\t\t}\n\t\treturn this._promptUnserialized(text, options);\n\t}\n\n\tprivate async _promptUnserialized(text: string, options?: PromptOptions): Promise<void> {\n\t\tthis._applyToolRepairLayerSettings();\n\t\tthis._cancelPrefixWarm();\n\t\tconst expandPromptTemplates = options?.expandPromptTemplates ?? true;\n\t\tconst processSlashCommands = options?.processSlashCommands ?? expandPromptTemplates;\n\t\tconst preflightResult = options?.preflightResult;\n\t\tlet messages: AgentMessage[] | undefined;\n\t\tlet routedTurnModel: Model<Api> | undefined;\n\t\tlet routedTurnRouteDecision: RouteDecision | undefined;\n\t\t// Built and painted early (see below) so a later throw in this try block — e.g. no model\n\t\t// selected/authenticated — can un-register it from _earlyDisplayedUserMessages instead of\n\t\t// leaking the reference forever.\n\t\tlet userMessage: AgentMessage | undefined;\n\t\t// R4 effectiveness feedback: remember the recall page + the query so we can score, after the\n\t\t// response, whether the agent actually used the recalled context.\n\t\tlet injectedRecall = \"\";\n\t\tlet recallQuery = \"\";\n\n\t\ttry {\n\t\t\t// Handle extension commands first. Programmatic extension messages may opt\n\t\t\t// into command handling; if the agent is currently streaming, queue the\n\t\t\t// command for the end of the run instead of sending it to the model.\n\t\t\tif (processSlashCommands && text.startsWith(\"/\")) {\n\t\t\t\tif (this.isStreaming && options?.source === \"extension\" && options?.streamingBehavior) {\n\t\t\t\t\tconst commandName = this._parseCommandName(text);\n\t\t\t\t\tif (this._extensionRunner.getCommand(commandName)) {\n\t\t\t\t\t\tthis._queueExtensionCommand(text);\n\t\t\t\t\t\tpreflightResult?.(true);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst handled = await this._tryExecuteExtensionCommand(text);\n\t\t\t\tif (handled) {\n\t\t\t\t\t// Extension command executed, no prompt to send\n\t\t\t\t\tpreflightResult?.(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Emit input event for extension interception (before skill/template expansion)\n\t\t\tlet currentText = text;\n\t\t\tlet currentImages = options?.images;\n\t\t\tif (this._extensionRunner.hasHandlers(\"input\")) {\n\t\t\t\tconst inputResult = await this._extensionRunner.emitInput(\n\t\t\t\t\tcurrentText,\n\t\t\t\t\tcurrentImages,\n\t\t\t\t\toptions?.source ?? \"interactive\",\n\t\t\t\t\tthis.isStreaming ? options?.streamingBehavior : undefined,\n\t\t\t\t);\n\t\t\t\tif (inputResult.action === \"handled\") {\n\t\t\t\t\tpreflightResult?.(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (inputResult.action === \"transform\") {\n\t\t\t\t\tcurrentText = inputResult.text;\n\t\t\t\t\tcurrentImages = inputResult.images ?? currentImages;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Expand skill commands (/skill:name args) and prompt templates (/template args)\n\t\t\tlet expandedText = currentText;\n\t\t\tif (expandPromptTemplates) {\n\t\t\t\texpandedText = this._expandSkillCommand(expandedText);\n\t\t\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\t\t\t}\n\n\t\t\t// If streaming — or waiting out a retry backoff, which is still an active\n\t\t\t// operation — queue via steer() or followUp() instead of starting a\n\t\t\t// concurrent run that would race the pending retry continuation.\n\t\t\tif (this.isStreaming || this.isRetrying) {\n\t\t\t\tif (!options?.streamingBehavior) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (options.streamingBehavior === \"followUp\") {\n\t\t\t\t\tawait this._queueFollowUp(expandedText, currentImages);\n\t\t\t\t} else {\n\t\t\t\t\tawait this._queueSteer(expandedText, currentImages);\n\t\t\t\t}\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Flush any pending bash messages before the new prompt\n\t\t\tthis._flushPendingBashMessages();\n\n\t\t\t// Build the user message now — before the router judge — and paint it to the UI\n\t\t\t// immediately via a synthetic message_start. The judge is a real bounded LLM completion\n\t\t\t// (seconds), not a regex; awaiting it first made the prompt appear to hang. The\n\t\t\t// authoritative message_start emitted later for this SAME object is suppressed in\n\t\t\t// _handleAgentEvent (see _earlyDisplayedUserMessages) so it is still shown exactly once.\n\t\t\tconst userContent: (TextContent | ImageContent)[] = [{ type: \"text\", text: expandedText }];\n\t\t\tif (currentImages) {\n\t\t\t\tuserContent.push(...currentImages);\n\t\t\t}\n\t\t\tuserMessage = {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: userContent,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\t\t\tthis._earlyDisplayedUserMessages.add(userMessage);\n\t\t\tthis._emit({ type: \"message_start\", message: userMessage });\n\n\t\t\t// Bracket the routing/prep phase (judge, model/auth checks, compaction, ...) so the UI can\n\t\t\t// show general \"working\" feedback for it — otherwise the user stares at their own echoed\n\t\t\t// prompt with nothing happening for however long the judge takes. routing_end is emitted\n\t\t\t// exactly once below: either in the catch block (this phase failed) or right after the try\n\t\t\t// block (this phase succeeded, whether or not it produced a turn to run).\n\t\t\tthis._emit({ type: \"routing_start\" });\n\n\t\t\tconst resolvedRouteInfo = await this._modelRouter.resolveTurnRouteJudged(expandedText, {\n\t\t\t\t// Internally generated turns (goal continuation, lane follow-ups) never consult the judge:\n\t\t\t\t// the regex floor already classified them, and a 20-turn loop must not buy 20 judge calls.\n\t\t\t\tskipJudge: options?.autoContinueGoal === false,\n\t\t\t});\n\t\t\t// #27: a route landing on a local (ollama) model must not hard-fail the turn just because\n\t\t\t// the server isn't up yet — boot/reuse it here, or escalate to a non-local tier.\n\t\t\tconst readyRouteInfo = await this._ensureRouteModelReady(resolvedRouteInfo);\n\t\t\troutedTurnModel = readyRouteInfo?.model;\n\t\t\troutedTurnRouteDecision = readyRouteInfo?.decision;\n\t\t\tconst requestModel = routedTurnModel ?? this.model;\n\n\t\t\t// Validate model\n\t\t\tif (!requestModel) {\n\t\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t\t}\n\t\t\t// A manual/default local model has no RouteDecision, so the router readiness gate above is\n\t\t\t// intentionally a no-op. It still needs the same managed-runtime boot/residency guarantee.\n\t\t\tif (!resolvedRouteInfo) {\n\t\t\t\tawait this._localRuntimeController.ensureForegroundModelReady(requestModel);\n\t\t\t}\n\n\t\t\tif (!this._modelRegistry.hasConfiguredAuth(requestModel)) {\n\t\t\t\tconst isOAuth = this._modelRegistry.isUsingOAuth(requestModel);\n\t\t\t\tif (isOAuth) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Authentication failed for \"${requestModel.provider}\". ` +\n\t\t\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t\t\t`Run '/login ${requestModel.provider}' to re-authenticate.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new Error(formatNoApiKeyFoundMessage(requestModel.provider));\n\t\t\t}\n\n\t\t\tthis._checkContextWindowUsageWarning();\n\n\t\t\t// Check if we need to compact before sending (catches aborted responses).\n\t\t\t// Do not call agent.continue() here: the next model turn must include the\n\t\t\t// user's pending prompt, not an empty continuation after compaction.\n\t\t\tconst lastAssistant = this._findLastAssistantMessage();\n\t\t\tif (lastAssistant) {\n\t\t\t\tawait this._checkCompaction(lastAssistant, false);\n\t\t\t}\n\n\t\t\t// Build messages array (recall page, then custom message if any, then user message)\n\t\t\tmessages = [];\n\n\t\t\t// R3: cross-session similarity recall. For a substantive turn, ask the memory providers to\n\t\t\t// prefetch a relevant <memory_context> page from past sessions and prepend it as data ahead of\n\t\t\t// the user message. Best-effort and gated: trivial turns are skipped, and providers return \"\"\n\t\t\t// (no page) when nothing is relevant — so it stays net-negative and the GC packs stale pages.\n\t\t\tif (this._memory.shouldAttemptRecall(expandedText)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst recall = await this._memory.prefetchRecall(expandedText);\n\t\t\t\t\tif (recall) {\n\t\t\t\t\t\tinjectedRecall = recall;\n\t\t\t\t\t\trecallQuery = expandedText;\n\t\t\t\t\t\t// Inject as a GC-managed custom context message (role \"custom\", customType\n\t\t\t\t\t\t// \"memory_context\"), NOT a persisted user message: the semantic-memory context-GC packs\n\t\t\t\t\t\t// stale recall pages so they don't accumulate forever (Bug #7), and the transcript index\n\t\t\t\t\t\t// only re-reads user/assistant text so recalled snippets can't recirculate (Bug #10).\n\t\t\t\t\t\tmessages.push(\n\t\t\t\t\t\t\tcreateCustomMessage(\"memory_context\", recall, false, undefined, new Date().toISOString()),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// recall must never break a turn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add user message (built earlier, before the router judge, so it could be painted\n\t\t\t// immediately — see the early message_start emit above).\n\t\t\tmessages.push(userMessage);\n\n\t\t\t// Inject any pending \"nextTurn\" messages as context alongside the user message\n\t\t\tfor (const msg of this._pendingNextTurnMessages) {\n\t\t\t\tmessages.push(msg);\n\t\t\t}\n\t\t\tthis._pendingNextTurnMessages = [];\n\n\t\t\t// Emit before_agent_start extension event\n\t\t\tconst result = await this._extensionRunner.emitBeforeAgentStart(\n\t\t\t\texpandedText,\n\t\t\t\tcurrentImages,\n\t\t\t\tthis._baseSystemPrompt,\n\t\t\t\tthis._systemPromptBuilder.getBaseSystemPromptOptions(),\n\t\t\t);\n\t\t\t// Add all custom messages from extensions\n\t\t\tif (result?.messages) {\n\t\t\t\tfor (const msg of result.messages) {\n\t\t\t\t\tmessages.push({\n\t\t\t\t\t\trole: \"custom\",\n\t\t\t\t\t\tcustomType: msg.customType,\n\t\t\t\t\t\tcontent: msg.content,\n\t\t\t\t\t\tdisplay: msg.display,\n\t\t\t\t\t\tdetails: msg.details,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Apply extension-modified system prompt, or reset to base\n\t\t\tif (result?.systemPrompt) {\n\t\t\t\tthis.agent.state.systemPrompt = result.systemPrompt;\n\t\t\t} else {\n\t\t\t\t// Ensure we're using the base prompt (in case previous turn had modifications)\n\t\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The turn never reached _runAgentPrompt, so the authoritative message_start that would\n\t\t\t// normally consume this entry (see _handleAgentEvent) never fires — un-register it here\n\t\t\t// instead of leaking the reference.\n\t\t\tif (userMessage) {\n\t\t\t\tthis._earlyDisplayedUserMessages.delete(userMessage);\n\t\t\t}\n\t\t\t// The routing/prep phase (routing_start above) failed before ever reaching the turn — end\n\t\t\t// it here, or the UI's \"working\" indicator for it spins forever with nothing behind it.\n\t\t\tthis._emit({ type: \"routing_end\" });\n\t\t\tpreflightResult?.(false);\n\t\t\tthrow error;\n\t\t}\n\n\t\t// The routing/prep phase is over — either we're about to hand off into the turn (which emits\n\t\t// its own agent_start/streaming events right after), or messages is unexpectedly unset and we\n\t\t// bail below. Either way nothing is left \"routing\" past this point.\n\t\tthis._emit({ type: \"routing_end\" });\n\n\t\tif (!messages) {\n\t\t\treturn;\n\t\t}\n\n\t\tpreflightResult?.(true);\n\t\tthis._textProtocolParseObservedThisTurn = false;\n\t\tthis._textProtocolValidationOutcomeThisTurn = undefined;\n\t\tawait this._modelRouter.runRoutedTurn(messages, routedTurnModel, routedTurnRouteDecision);\n\t\tthis._recordTextToolProtocolParseOutcomeFromLastAssistant();\n\n\t\t// R4: score whether the agent actually used the recalled context, so the recall gate can adapt.\n\t\tif (injectedRecall) {\n\t\t\tconst response = this._findLastAssistantMessage();\n\t\t\tconst responseText = response\n\t\t\t\t? response.content\n\t\t\t\t\t\t.filter((c): c is TextContent => c.type === \"text\")\n\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t.join(\" \")\n\t\t\t\t: \"\";\n\t\t\tif (responseText) {\n\t\t\t\tthis._memory.recordRecallOutcome(injectedRecall, recallQuery, responseText);\n\t\t\t}\n\t\t}\n\n\t\tthis._backgroundLanes.drainQueuedWorkerDelegations();\n\t\tthis._backgroundLanes.scheduleGoalAutoContinueFromIdle(options);\n\t\tthis._backgroundLanes.scheduleResearchLaneFromIdle();\n\t}\n\n\t/**\n\t * Try to execute an extension command. Returns true if command was found and executed.\n\t */\n\tprivate _parseCommandName(text: string): string {\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\treturn spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\t}\n\n\tprivate async _tryExecuteExtensionCommand(text: string): Promise<boolean> {\n\t\t// Parse command name and args\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\tconst commandName = this._parseCommandName(text);\n\t\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\n\t\tconst command = this._extensionRunner.getCommand(commandName);\n\t\tif (!command) return false;\n\n\t\t// Get command context from extension runner (includes session control methods)\n\t\tconst ctx = this._extensionRunner.createCommandContext();\n\n\t\ttry {\n\t\t\tawait command.handler(args, ctx);\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\t// Emit error via extension runner\n\t\t\tthis._extensionRunner.emitError({\n\t\t\t\textensionPath: `command:${commandName}`,\n\t\t\t\tevent: \"command\",\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t});\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t/**\n\t * Expand skill commands (/skill:name args) to their full content.\n\t * Returns the expanded text, or the original text if not a skill command or skill not found.\n\t * Emits errors via extension runner if file read fails.\n\t */\n\tprivate _expandSkillCommand(text: string): string {\n\t\tif (!text.startsWith(\"/skill:\")) return text;\n\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\tconst skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n\t\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1).trim();\n\n\t\t// Resolve only against profile-active skills so a `/skill:` the active profile blocks cannot be\n\t\t// expanded/invoked — by the user OR the agent — even if it loaded before a runtime profile switch.\n\t\tconst skill = this.resourceLoader.getActiveSkills().find((s) => s.name === skillName);\n\t\tif (!skill) return text; // Unknown or profile-blocked skill, pass through unchanged\n\n\t\ttry {\n\t\t\tconst content = readFileSync(skill.filePath, \"utf-8\");\n\t\t\t// Curator (#32): record use of a reflection-PROMOTED skill so stale ones can later be proposed\n\t\t\t// for archival. Only promoted skills carry the marker, so hand-authored skills are untouched.\n\t\t\tif (isPromotedFrontmatter(content)) {\n\t\t\t\tthis._skillCurator.recordUse(skill.name, Date.now());\n\t\t\t}\n\t\t\tconst body = stripResourceProfileBlocks(stripFrontmatter(content)).trim();\n\t\t\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n\t\t\treturn args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n\t\t} catch (err) {\n\t\t\t// Emit error like extension commands do\n\t\t\tthis._extensionRunner.emitError({\n\t\t\t\textensionPath: skill.filePath,\n\t\t\t\tevent: \"skill_expansion\",\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t});\n\t\t\treturn text; // Return original on error\n\t\t}\n\t}\n\n\t/**\n\t * Queue a steering message while the agent is running.\n\t * Delivered after the current assistant turn finishes executing its tool calls,\n\t * before the next LLM call.\n\t * Expands skill commands and prompt templates. Errors on extension commands.\n\t * @param images Optional image attachments to include with the message\n\t * @throws Error if text is an extension command\n\t */\n\tasync steer(text: string, images?: ImageContent[]): Promise<void> {\n\t\t// Check for extension commands (cannot be queued)\n\t\tif (text.startsWith(\"/\")) {\n\t\t\tthis._throwIfExtensionCommand(text);\n\t\t}\n\n\t\t// Expand skill commands and prompt templates\n\t\tlet expandedText = this._expandSkillCommand(text);\n\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\t\tawait this._queueSteer(expandedText, images);\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t * Expands skill commands and prompt templates. Errors on extension commands.\n\t * @param images Optional image attachments to include with the message\n\t * @throws Error if text is an extension command\n\t */\n\tasync followUp(text: string, images?: ImageContent[]): Promise<void> {\n\t\t// Check for extension commands (cannot be queued)\n\t\tif (text.startsWith(\"/\")) {\n\t\t\tthis._throwIfExtensionCommand(text);\n\t\t}\n\n\t\t// Expand skill commands and prompt templates\n\t\tlet expandedText = this._expandSkillCommand(text);\n\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\t\tawait this._queueFollowUp(expandedText, images);\n\t}\n\n\t/**\n\t * Internal: Queue a steering message (already expanded, no extension command check).\n\t */\n\tprivate async _queueSteer(text: string, images?: ImageContent[]): Promise<void> {\n\t\tthis._steeringMessages.push(text);\n\t\tthis._emitQueueUpdate();\n\t\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\t\tif (images) {\n\t\t\tcontent.push(...images);\n\t\t}\n\t\tthis.agent.steer({\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\t}\n\n\t/**\n\t * Internal: Queue a follow-up message (already expanded, no extension command check).\n\t */\n\tprivate async _queueFollowUp(text: string, images?: ImageContent[]): Promise<void> {\n\t\tthis._followUpMessages.push(text);\n\t\tthis._emitQueueUpdate();\n\t\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\t\tif (images) {\n\t\t\tcontent.push(...images);\n\t\t}\n\t\tthis.agent.followUp({\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\t}\n\n\t/**\n\t * Internal: Queue an extension command to execute after the current agent run.\n\t */\n\tprivate _queueExtensionCommand(text: string): void {\n\t\tthis._queuedExtensionCommands.push(text);\n\t\tthis._emitQueueUpdate();\n\t}\n\n\tprivate async _drainQueuedExtensionCommands(): Promise<void> {\n\t\twhile (this._queuedExtensionCommands.length > 0 && !this.isStreaming) {\n\t\t\tconst commandText = this._queuedExtensionCommands.shift()!;\n\t\t\tthis._emitQueueUpdate();\n\t\t\tawait this._tryExecuteExtensionCommand(commandText);\n\t\t}\n\t}\n\n\t/**\n\t * Throw an error if the text is an extension command.\n\t */\n\tprivate _throwIfExtensionCommand(text: string): void {\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\t\tconst command = this._extensionRunner.getCommand(commandName);\n\n\t\tif (command) {\n\t\t\tthrow new Error(\n\t\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Send a custom message to the session. Creates a CustomMessageEntry.\n\t *\n\t * Handles three cases:\n\t * - Streaming: queues message, processed when loop pulls from queue\n\t * - Not streaming + triggerTurn: appends to state/session, starts new turn\n\t * - Not streaming + no trigger: appends to state/session, no turn\n\t *\n\t * @param message Custom message with customType, content, display, details\n\t * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n\t * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", or \"nextTurn\"\n\t */\n\tasync sendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void> {\n\t\tconst appMessage = {\n\t\t\trole: \"custom\" as const,\n\t\t\tcustomType: message.customType,\n\t\t\tcontent: message.content,\n\t\t\tdisplay: message.display,\n\t\t\tdetails: message.details,\n\t\t\ttimestamp: Date.now(),\n\t\t} satisfies CustomMessage<T>;\n\t\tif (options?.deliverAs === \"nextTurn\") {\n\t\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t\t} else if (this.isStreaming) {\n\t\t\tif (options?.deliverAs === \"followUp\") {\n\t\t\t\tthis.agent.followUp(appMessage);\n\t\t\t} else {\n\t\t\t\tthis.agent.steer(appMessage);\n\t\t\t}\n\t\t} else if (options?.triggerTurn) {\n\t\t\tawait this._runAgentPrompt(appMessage);\n\t\t} else {\n\t\t\tthis.agent.state.messages.push(appMessage);\n\t\t\tthis.sessionManager.appendCustomMessageEntry(\n\t\t\t\tmessage.customType,\n\t\t\t\tmessage.content,\n\t\t\t\tmessage.display,\n\t\t\t\tmessage.details,\n\t\t\t);\n\t\t\tthis._emit({ type: \"message_start\", message: appMessage });\n\t\t\tthis._emit({ type: \"message_end\", message: appMessage });\n\t\t}\n\t}\n\n\t/**\n\t * Send a user message to the agent. Always triggers a turn.\n\t * When the agent is streaming, use deliverAs to specify how to queue the message.\n\t *\n\t * @param content User message content (string or content array)\n\t * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n\t */\n\tasync sendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; processSlashCommands?: boolean },\n\t): Promise<void> {\n\t\t// Normalize content to text string + optional images\n\t\tlet text: string;\n\t\tlet images: ImageContent[] | undefined;\n\n\t\tif (typeof content === \"string\") {\n\t\t\ttext = content;\n\t\t} else {\n\t\t\tconst textParts: string[] = [];\n\t\t\timages = [];\n\t\t\tfor (const part of content) {\n\t\t\t\tif (part.type === \"text\") {\n\t\t\t\t\ttextParts.push(part.text);\n\t\t\t\t} else {\n\t\t\t\t\timages.push(part);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttext = textParts.join(\"\\n\");\n\t\t\tif (images.length === 0) images = undefined;\n\t\t}\n\n\t\t// Skip skill/template expansion by default. Extensions that intentionally\n\t\t// want slash commands to execute (for example self-maintenance reloads)\n\t\t// can opt in with processSlashCommands.\n\t\tawait this.prompt(text, {\n\t\t\texpandPromptTemplates: false,\n\t\t\tprocessSlashCommands: options?.processSlashCommands ?? false,\n\t\t\tstreamingBehavior: options?.deliverAs,\n\t\t\timages,\n\t\t\tsource: \"extension\",\n\t\t});\n\t}\n\n\t/**\n\t * Clear all queued messages and return them.\n\t * Useful for restoring to editor when user aborts.\n\t * @returns Object with steering, followUp, and queued extension command arrays\n\t */\n\tclearQueue(): { steering: string[]; followUp: string[]; commands: string[] } {\n\t\tconst steering = [...this._steeringMessages];\n\t\tconst followUp = [...this._followUpMessages];\n\t\tconst commands = [...this._queuedExtensionCommands];\n\t\tthis._steeringMessages = [];\n\t\tthis._followUpMessages = [];\n\t\tthis._queuedExtensionCommands = [];\n\t\tthis.agent.clearAllQueues();\n\t\tthis._emitQueueUpdate();\n\t\treturn { steering, followUp, commands };\n\t}\n\n\t/** Number of pending messages (includes steering, follow-up, and queued extension commands) */\n\tget pendingMessageCount(): number {\n\t\treturn this._steeringMessages.length + this._followUpMessages.length + this._queuedExtensionCommands.length;\n\t}\n\n\t/** Get pending steering messages (read-only) */\n\tgetSteeringMessages(): readonly string[] {\n\t\treturn this._steeringMessages;\n\t}\n\n\t/** Get pending follow-up messages (read-only) */\n\tgetFollowUpMessages(): readonly string[] {\n\t\treturn this._followUpMessages;\n\t}\n\n\t/** Get pending extension commands (read-only). */\n\tgetQueuedExtensionCommands(): readonly string[] {\n\t\treturn this._queuedExtensionCommands;\n\t}\n\n\tget resourceLoader(): ResourceLoader {\n\t\treturn this._resourceLoader;\n\t}\n\n\t/**\n\t * Abort current operation and wait for agent to become idle.\n\t */\n\tasync abort(): Promise<void> {\n\t\tthis.abortRetry();\n\t\tthis.agent.abort();\n\t\tawait this.agent.waitForIdle();\n\t}\n\n\t// =========================================================================\n\t// Model Management\n\t// =========================================================================\n\n\tasync setModel(model: Model<any>, options: { persistSettings?: boolean } = {}): Promise<void> {\n\t\tawait this._modelSelection.setModel(model, options);\n\t\tthis._scheduleLocalPrefixWarm(this.agent.state.model, \"selection\");\n\t}\n\n\t/** Re-resolve startup profile model/thinking after allowed extension providers are bound. */\n\tasync reapplyActiveProfileModelSettings(): Promise<void> {\n\t\tconst previousModel = this.model;\n\t\tawait this._profileFilter.reapplyActiveProfileModelSettings();\n\t\tconst activeToolNames = this._requestedActiveToolNames ?? this.getActiveToolNames();\n\t\tthis._refreshToolRegistry({ activeToolNames, includeAllExtensionTools: true });\n\t\tif (!modelsAreEqual(previousModel, this.model)) {\n\t\t\tthis._scheduleLocalPrefixWarm(this.model, \"selection\");\n\t\t}\n\t}\n\n\tasync cycleModel(direction: \"forward\" | \"backward\" = \"forward\"): Promise<ModelCycleResult | undefined> {\n\t\tconst result = await this._modelSelection.cycleModel(direction);\n\t\tthis._scheduleLocalPrefixWarm(result?.model, \"selection\");\n\t\treturn result;\n\t}\n\n\t// =========================================================================\n\t// Thinking Level Management\n\t// =========================================================================\n\n\tsetThinkingLevel(level: ThinkingLevel, options: { persistSettings?: boolean } = {}): void {\n\t\tthis._modelSelection.setThinkingLevel(level, options);\n\t}\n\n\tcycleThinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this._modelSelection.cycleThinkingLevel();\n\t}\n\n\tgetAvailableThinkingLevels(): ThinkingLevel[] {\n\t\treturn this._modelSelection.getAvailableThinkingLevels();\n\t}\n\n\tsupportsThinking(): boolean {\n\t\treturn this._modelSelection.supportsThinking();\n\t}\n\n\t// =========================================================================\n\t// Queue Mode Management\n\t// =========================================================================\n\n\t/**\n\t * Set steering message mode.\n\t * Saves to settings.\n\t */\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.agent.steeringMode = mode;\n\t\tthis.settingsManager.setSteeringMode(mode);\n\t}\n\n\t/**\n\t * Set follow-up message mode.\n\t * Saves to settings.\n\t */\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.agent.followUpMode = mode;\n\t\tthis.settingsManager.setFollowUpMode(mode);\n\t}\n\n\t// =========================================================================\n\t// Compaction\n\t// =========================================================================\n\n\t/**\n\t * Manually compact the session context.\n\t * Aborts current agent operation first.\n\t * @param customInstructions Optional instructions for the compaction summary\n\t */\n\tasync compact(customInstructions?: string): Promise<CompactionResult> {\n\t\tthis._disconnectFromAgent();\n\t\tawait this.abort();\n\t\tthis._compactionAbortController = new AbortController();\n\t\tthis._emit({ type: \"compaction_start\", reason: \"manual\" });\n\n\t\ttry {\n\t\t\tif (!this.model) {\n\t\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t\t}\n\n\t\t\tconst sessionModel = this.model;\n\t\t\tconst selectedCompactionModel = this._resolveCompactionModel(sessionModel);\n\t\t\tif (this._isRawStreamSimple(this.agent.streamFn)) {\n\t\t\t\tawait this._getCompactionRequestAuth(selectedCompactionModel);\n\t\t\t}\n\t\t\tconst selectionReason = this._getLastCompactionSelectionReason() ?? \"unknown\";\n\t\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\t\tconst initialBranch = this.sessionManager.getBranch();\n\t\t\tconst initialPreparation = prepareCompaction(initialBranch, settings);\n\t\t\tif (!initialPreparation) {\n\t\t\t\tconst lastEntry = initialBranch[initialBranch.length - 1];\n\t\t\t\tif (lastEntry?.type === \"compaction\") {\n\t\t\t\t\tthrow new Error(\"Already compacted\");\n\t\t\t\t}\n\t\t\t\tthrow new Error(\"Nothing to compact (session too small)\");\n\t\t\t}\n\n\t\t\tlet extensionCompaction: CompactionResult | undefined;\n\t\t\tlet fromExtension = false;\n\t\t\tif (this._extensionRunner.hasHandlers(\"session_before_compact\")) {\n\t\t\t\tconst result = (await this._extensionRunner.emit({\n\t\t\t\t\ttype: \"session_before_compact\",\n\t\t\t\t\tpreparation: initialPreparation,\n\t\t\t\t\tbranchEntries: initialBranch,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\tsignal: this._compactionAbortController.signal,\n\t\t\t\t})) as SessionBeforeCompactResult | undefined;\n\t\t\t\tif (result?.cancel) throw new Error(\"Compaction cancelled\");\n\t\t\t\tif (result?.compaction) {\n\t\t\t\t\textensionCompaction = result.compaction;\n\t\t\t\t\tfromExtension = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (extensionCompaction) {\n\t\t\t\tthis.sessionManager.appendCompaction(\n\t\t\t\t\textensionCompaction.summary,\n\t\t\t\t\textensionCompaction.firstKeptEntryId,\n\t\t\t\t\textensionCompaction.tokensBefore,\n\t\t\t\t\textensionCompaction.details,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\tthis._refreshAfterCompaction();\n\t\t\t\tconst savedCompactionEntry = this.sessionManager\n\t\t\t\t\t.getEntries()\n\t\t\t\t\t.find((entry) => entry.type === \"compaction\" && entry.summary === extensionCompaction.summary) as\n\t\t\t\t\t| CompactionEntry\n\t\t\t\t\t| undefined;\n\t\t\t\tif (this._extensionRunner && savedCompactionEntry) {\n\t\t\t\t\tawait this._extensionRunner.emit({\n\t\t\t\t\t\ttype: \"session_compact\",\n\t\t\t\t\t\tcompactionEntry: savedCompactionEntry,\n\t\t\t\t\t\tfromExtension: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason: \"manual\",\n\t\t\t\t\tresult: extensionCompaction,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t});\n\t\t\t\treturn extensionCompaction;\n\t\t\t}\n\n\t\t\tlet appliedResult: CompactionResult | undefined;\n\t\t\tconst signal = this._compactionAbortController.signal;\n\t\t\tconst outcome = await runCompactionLoop({\n\t\t\t\tmeasureLiveTokens: () => Math.max(this._estimateCurrentContextTokens(this.agent.state.messages), 1),\n\t\t\t\tshouldCompact: () => true,\n\t\t\t\tgetPostApplyMargin: () => 0,\n\t\t\t\tgetBranch: () => this.sessionManager.getBranch(),\n\t\t\t\tgetBaseKeepRecentTokens: () => settings.keepRecentTokens,\n\t\t\t\tresolveModelAndAuth: async (modelTier) => {\n\t\t\t\t\tconst model = modelTier === \"cheap\" ? selectedCompactionModel : sessionModel;\n\t\t\t\t\tconst { apiKey, headers } = await this._resolveCompactionModelAndAuth(model, sessionModel);\n\t\t\t\t\treturn { model, apiKey, headers };\n\t\t\t\t},\n\t\t\t\tsummarizeAndVerify: async (params, model, apiKey, headers, branch) => {\n\t\t\t\t\tconst preparation = prepareCompaction(\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...settings,\n\t\t\t\t\t\t\tkeepRecentTokens: params.keepRecentTokens,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ allowTrailingCompactionAsPrevious: true },\n\t\t\t\t\t);\n\t\t\t\t\tif (!preparation) throw new Error(\"Nothing to compact (session too small)\");\n\t\t\t\t\tif (extensionCompaction) return { result: extensionCompaction };\n\t\t\t\t\tconst compactionThinkingLevel = this._resolveCompactionThinkingLevel(model, sessionModel);\n\t\t\t\t\tconst result = await this._compactWithRetry(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tcompact(\n\t\t\t\t\t\t\t\tpreparation,\n\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\tapiKey,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tcustomInstructions,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\tcompactionThinkingLevel,\n\t\t\t\t\t\t\t\tthis.agent.streamFn,\n\t\t\t\t\t\t\t\tthis._buildCompactionPreDigest(),\n\t\t\t\t\t\t\t\t{ chunked: params.chunked },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tmodel.provider,\n\t\t\t\t\t);\n\t\t\t\t\treturn { result };\n\t\t\t\t},\n\t\t\t\tbuildDeterministicCheckpoint: () => ({ result: createDeterministicCompaction(initialPreparation) }),\n\t\t\t\tapply: async (result) => {\n\t\t\t\t\tif (signal.aborted) throw new Error(\"Compaction cancelled\");\n\t\t\t\t\tthis.sessionManager.appendCompaction(\n\t\t\t\t\t\tresult.summary,\n\t\t\t\t\t\tresult.firstKeptEntryId,\n\t\t\t\t\t\tresult.tokensBefore,\n\t\t\t\t\t\tresult.details,\n\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t);\n\t\t\t\t\tthis._refreshAfterCompaction();\n\t\t\t\t\tconst savedCompactionEntry = this.sessionManager\n\t\t\t\t\t\t.getEntries()\n\t\t\t\t\t\t.find((entry) => entry.type === \"compaction\" && entry.summary === result.summary) as\n\t\t\t\t\t\t| CompactionEntry\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (this._extensionRunner && savedCompactionEntry) {\n\t\t\t\t\t\tawait this._extensionRunner.emit({\n\t\t\t\t\t\t\ttype: \"session_compact\",\n\t\t\t\t\t\t\tcompactionEntry: savedCompactionEntry,\n\t\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tappliedResult = result;\n\t\t\t\t},\n\t\t\t\tverifyPostApplyEffect: () => false,\n\t\t\t\tonTransition: ({ cycle, cause, detail }) => {\n\t\t\t\t\tthis._emit({\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: `manual compaction cycle ${cycle}: ${cause}${detail ? ` (${detail})` : \"\"} — retrying from step 0 (${this._describeCompactionSummarizer()})`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\t\tif (outcome.kind === \"failed\") {\n\t\t\t\tif (outcome.reason === \"aborted\") throw new Error(\"Compaction cancelled\");\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`manual compaction failed after retry ladder using ${selectedCompactionModel.provider}/${selectedCompactionModel.id} (${selectionReason}); first failure: ${outcome.reason}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (outcome.kind === \"skip\" || !appliedResult)\n\t\t\t\tthrow new Error(outcome.kind === \"skip\" ? outcome.reason : \"Compaction failed\");\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"manual\",\n\t\t\t\tresult: appliedResult,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t});\n\t\t\treturn appliedResult;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst aborted = message === \"Compaction cancelled\" || (error instanceof Error && error.name === \"AbortError\");\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"manual\",\n\t\t\t\tresult: undefined,\n\t\t\t\taborted,\n\t\t\t\twillRetry: false,\n\t\t\t\terrorMessage: aborted ? undefined : `Compaction failed: ${message}`,\n\t\t\t});\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis._compactionAbortController = undefined;\n\t\t\tthis._reconnectToAgent();\n\t\t}\n\t}\n\n\t/**\n\t * Cancel in-progress compaction (manual or auto).\n\t */\n\tabortCompaction(): void {\n\t\tthis._compactionAbortController?.abort();\n\t\tthis._autoCompactionAbortController?.abort();\n\t}\n\n\t/**\n\t * Cancel in-progress branch summarization.\n\t */\n\tabortBranchSummary(): void {\n\t\tthis._branchSummaryAbortController?.abort();\n\t}\n\n\t/**\n\t * Check if compaction is needed and run it.\n\t * Called after agent_end and before prompt submission.\n\t *\n\t * Two cases:\n\t * 1. Overflow: LLM returned context overflow error, remove error message from agent state, compact, auto-retry\n\t * 2. Threshold: Context over threshold, compact, NO auto-retry (user continues manually)\n\t *\n\t * @param assistantMessage The assistant message to check\n\t * @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true\n\t */\n\tprivate _getAdaptedCompactionSettings(): CompactionSettings {\n\t\treturn this._compactionSupport.getAdaptedSettings();\n\t}\n\n\tprivate _checkContextWindowUsageWarning(): void {\n\t\tif (!this.model) return;\n\t\tconst contextWindow = this.model.contextWindow ?? 0;\n\t\tif (contextWindow <= 0) return;\n\n\t\tconst systemPromptTokens = Math.ceil((this.agent.state.systemPrompt ?? \"\").length / 4);\n\n\t\tlet toolsChars = 0;\n\t\tfor (const tool of this.agent.state.tools || []) {\n\t\t\ttoolsChars += tool.name.length;\n\t\t\ttoolsChars += tool.description?.length ?? 0;\n\t\t\tif (tool.parameters) {\n\t\t\t\ttoolsChars += JSON.stringify(tool.parameters).length;\n\t\t\t}\n\t\t}\n\t\tconst toolsTokens = Math.ceil(toolsChars / 4);\n\n\t\tconst baseTokens = systemPromptTokens + toolsTokens;\n\n\t\tif (baseTokens >= contextWindow) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `Base configuration (system prompt and active tools) consumes ${baseTokens} tokens, which exceeds the model's context window of ${contextWindow} tokens. The model cannot process any prompts in this state.`,\n\t\t\t});\n\t\t} else if (baseTokens >= contextWindow * 0.7) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `Base configuration (system prompt and active tools) consumes ${baseTokens} tokens (${Math.round((baseTokens / contextWindow) * 100)}% of the ${contextWindow} context window). This leaves very little room for conversation history and may cause immediate compaction or context overflow.`,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async _checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck = true): Promise<boolean> {\n\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\tif (!settings.enabled) return false;\n\n\t\t// Skip if message was aborted (user cancelled) - unless skipAbortedCheck is false\n\t\tif (skipAbortedCheck && assistantMessage.stopReason === \"aborted\") return false;\n\n\t\tconst contextWindow = this.model?.contextWindow ?? 0;\n\n\t\t// Skip overflow check if the message came from a different model.\n\t\t// This handles the case where user switched from a smaller-context model (e.g. opus)\n\t\t// to a larger-context model (e.g. codex) - the overflow error from the old model\n\t\t// shouldn't trigger compaction for the new model.\n\t\tconst sameModel =\n\t\t\tthis.model && assistantMessage.provider === this.model.provider && assistantMessage.model === this.model.id;\n\n\t\t// Skip compaction checks if this assistant message is older than the latest\n\t\t// compaction boundary. This prevents a stale pre-compaction usage/error\n\t\t// from retriggering compaction on the first prompt after compaction.\n\t\tconst compactionEntry = getLatestCompactionEntry(this.sessionManager.getBranch());\n\t\tconst assistantIsFromBeforeCompaction =\n\t\t\tcompactionEntry !== null && assistantMessage.timestamp <= new Date(compactionEntry.timestamp).getTime();\n\t\tif (assistantIsFromBeforeCompaction) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Case 1: Overflow - LLM returned context overflow error\n\t\tif (sameModel && isContextOverflow(assistantMessage, contextWindow)) {\n\t\t\tif (this._overflowRecoveryAttempted) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason: \"overflow\",\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.\",\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis._overflowRecoveryAttempted = true;\n\t\t\t// Remove the error message from agent state (it IS saved to session for history,\n\t\t\t// but we don't want it in context for the retry)\n\t\t\tconst messages = this.agent.state.messages;\n\t\t\tif (messages.length > 0 && messages[messages.length - 1].role === \"assistant\") {\n\t\t\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t\t\t}\n\t\t\treturn await this._runAutoCompaction(\"overflow\", true);\n\t\t}\n\n\t\t// Case 2: Threshold - context is getting large\n\t\t// For error messages (no usage data), estimate from last successful response.\n\t\t// This ensures sessions that hit persistent API errors (e.g. 529) can still compact.\n\t\tlet contextTokens: number;\n\t\tif (assistantMessage.stopReason === \"error\") {\n\t\t\tconst messages = this.agent.state.messages;\n\t\t\tconst estimate = estimateContextTokens(messages);\n\t\t\tif (estimate.lastUsageIndex === null) return false; // No usage data at all\n\t\t\t// Verify the usage source is post-compaction. Kept pre-compaction messages\n\t\t\t// have stale usage reflecting the old (larger) context and would falsely\n\t\t\t// trigger compaction right after one just finished.\n\t\t\tconst usageMsg = messages[estimate.lastUsageIndex];\n\t\t\tif (\n\t\t\t\tcompactionEntry &&\n\t\t\t\tusageMsg.role === \"assistant\" &&\n\t\t\t\t(usageMsg as AssistantMessage).timestamp <= new Date(compactionEntry.timestamp).getTime()\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontextTokens = estimate.tokens;\n\t\t} else {\n\t\t\tcontextTokens = calculateContextTokens(assistantMessage.usage);\n\t\t\tconst estimate = estimateContextTokens(this.agent.state.messages);\n\t\t\tif (estimate.lastUsageIndex !== null) {\n\t\t\t\tconst usageMsg = this.agent.state.messages[estimate.lastUsageIndex];\n\t\t\t\tconst usageIsPostCompaction = !(\n\t\t\t\t\tcompactionEntry &&\n\t\t\t\t\tusageMsg.role === \"assistant\" &&\n\t\t\t\t\t(usageMsg as AssistantMessage).timestamp <= new Date(compactionEntry.timestamp).getTime()\n\t\t\t\t);\n\t\t\t\tif (usageIsPostCompaction) {\n\t\t\t\t\tcontextTokens = Math.max(contextTokens, estimate.tokens);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (shouldCompact(contextTokens, contextWindow, settings, this.model?.autoCompactionTriggerTokens)) {\n\t\t\treturn await this._runAutoCompaction(\"threshold\", false);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate _measureLiveContextTokensForCompaction(): number {\n\t\tconst estimatedTokens = this._pipeline.estimateCurrentContextTokens(this.agent.state.messages);\n\t\tconst assistantMessage = findLastAssistantMessage(this.agent.state.messages);\n\t\tif (!assistantMessage || assistantMessage.stopReason === \"error\" || assistantMessage.stopReason === \"aborted\") {\n\t\t\treturn estimatedTokens;\n\t\t}\n\n\t\tconst compactionEntry = getLatestCompactionEntry(this.sessionManager.getBranch());\n\t\tif (compactionEntry && assistantMessage.timestamp <= new Date(compactionEntry.timestamp).getTime()) {\n\t\t\treturn estimatedTokens;\n\t\t}\n\n\t\treturn Math.max(calculateContextTokens(assistantMessage.usage), estimatedTokens);\n\t}\n\n\t/**\n\t * Internal: Run auto-compaction with events.\n\t */\n\tprivate async _runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<boolean> {\n\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\tconst model = this.model;\n\t\tthis._emit({ type: \"compaction_start\", reason });\n\t\tconst hadQueuedMessages = this.agent.hasQueuedMessages();\n\t\tthis._autoCompactionAbortController = new AbortController();\n\t\tconst signal = this._autoCompactionAbortController.signal;\n\t\tlet fromExtension = false;\n\t\tlet lastCompaction: CompactionResult | undefined;\n\t\tlet extensionCancelled = false;\n\t\ttry {\n\t\t\tif (!model) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason,\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\tskipReason: \"no model selected\",\n\t\t\t\t});\n\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t}\n\n\t\t\tconst contextWindow = model.contextWindow;\n\t\t\tconst margin = Math.max(0, Math.floor(0.01 * contextWindow));\n\t\t\tconst outcome = await runCompactionLoop({\n\t\t\t\tgetBranch: () => this.sessionManager.getBranch(),\n\t\t\t\tmeasureLiveTokens: () => this._measureLiveContextTokensForCompaction(),\n\t\t\t\tshouldCompact:\n\t\t\t\t\treason === \"overflow\"\n\t\t\t\t\t\t? () => true\n\t\t\t\t\t\t: (tokens) => shouldCompact(tokens, contextWindow, settings, model.autoCompactionTriggerTokens),\n\t\t\t\tgetPostApplyMargin: () => margin,\n\t\t\t\tgetBaseKeepRecentTokens: () => settings.keepRecentTokens,\n\t\t\t\tresolveModelAndAuth: async (modelTier) =>\n\t\t\t\t\tthis._resolveCompactionModelAndAuth(\n\t\t\t\t\t\tmodelTier === \"session\" ? model : this._resolveCompactionModel(model),\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t),\n\t\t\t\tsummarizeAndVerify: async (params, compactModel, apiKey, headers, branchEntries) => {\n\t\t\t\t\tfromExtension = false;\n\t\t\t\t\tconst adaptedSettings = { ...settings, keepRecentTokens: params.keepRecentTokens };\n\t\t\t\t\tconst preparation = prepareCompaction(branchEntries, adaptedSettings);\n\t\t\t\t\tif (!preparation) {\n\t\t\t\t\t\tthrow new Error(\"already compacted\");\n\t\t\t\t\t}\n\t\t\t\t\tconst compactionThinkingLevel = this._resolveCompactionThinkingLevel(compactModel, model);\n\n\t\t\t\t\tif (this._extensionRunner.hasHandlers(\"session_before_compact\")) {\n\t\t\t\t\t\tconst extensionResult = (await this._extensionRunner.emit({\n\t\t\t\t\t\t\ttype: \"session_before_compact\",\n\t\t\t\t\t\t\tpreparation,\n\t\t\t\t\t\t\tbranchEntries,\n\t\t\t\t\t\t\tcustomInstructions: undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})) as SessionBeforeCompactResult | undefined;\n\t\t\t\t\t\tif (extensionResult?.cancel) {\n\t\t\t\t\t\t\textensionCancelled = true;\n\t\t\t\t\t\t\tthrow new Error(\"auto-compaction-cancelled\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (extensionResult?.compaction) {\n\t\t\t\t\t\t\tfromExtension = true;\n\t\t\t\t\t\t\treturn { result: extensionResult.compaction };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compactResult = await this._compactWithRetry(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tcompact(\n\t\t\t\t\t\t\t\tpreparation,\n\t\t\t\t\t\t\t\tcompactModel,\n\t\t\t\t\t\t\t\tapiKey,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\tcompactionThinkingLevel,\n\t\t\t\t\t\t\t\tthis.agent.streamFn,\n\t\t\t\t\t\t\t\tthis._buildCompactionPreDigest(),\n\t\t\t\t\t\t\t\t{ chunked: params.chunked },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tcompactModel.provider,\n\t\t\t\t\t);\n\t\t\t\t\treturn { result: compactResult };\n\t\t\t\t},\n\t\t\t\tbuildDeterministicCheckpoint: async () => {\n\t\t\t\t\tconst branch = this.sessionManager.getBranch();\n\t\t\t\t\tconst preparation = prepareCompaction(branch, {\n\t\t\t\t\t\t...settings,\n\t\t\t\t\t});\n\t\t\t\t\tif (!preparation) {\n\t\t\t\t\t\tthrow new Error(\"already compacted\");\n\t\t\t\t\t}\n\t\t\t\t\tfromExtension = false;\n\t\t\t\t\treturn { result: createDeterministicCompaction(preparation) };\n\t\t\t\t},\n\t\t\t\tapply: async (result) => {\n\t\t\t\t\tlastCompaction = result;\n\t\t\t\t\tthis.sessionManager.appendCompaction(\n\t\t\t\t\t\tresult.summary,\n\t\t\t\t\t\tresult.firstKeptEntryId,\n\t\t\t\t\t\tresult.tokensBefore,\n\t\t\t\t\t\tresult.details,\n\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t);\n\t\t\t\t\tthis._refreshAfterCompaction();\n\t\t\t\t\tconst newEntries = this.sessionManager.getEntries();\n\t\t\t\t\tconst savedCompactionEntry = newEntries.find(\n\t\t\t\t\t\t(entry) => entry.type === \"compaction\" && entry.summary === result.summary,\n\t\t\t\t\t) as CompactionEntry | undefined;\n\t\t\t\t\tif (this._extensionRunner && savedCompactionEntry) {\n\t\t\t\t\t\tawait this._extensionRunner.emit({\n\t\t\t\t\t\t\ttype: \"session_compact\",\n\t\t\t\t\t\t\tcompactionEntry: savedCompactionEntry,\n\t\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tverifyPostApplyEffect: reason === \"overflow\" ? () => false : undefined,\n\t\t\t\tonTransition: ({ cycle, cause, detail }) => {\n\t\t\t\t\tthis._emit({\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: `auto-compaction cycle ${cycle}: ${cause}${detail ? ` (${detail})` : \"\"} — retrying from step 0 (${this._describeCompactionSummarizer()})`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\t\tif (outcome.kind === \"skip\") {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason,\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\tskipReason: outcome.reason,\n\t\t\t\t});\n\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t}\n\n\t\t\tif (outcome.kind === \"failed\") {\n\t\t\t\tif (outcome.reason === \"aborted\") {\n\t\t\t\t\tthis._emit({ type: \"compaction_end\", reason, result: undefined, aborted: true, willRetry: false });\n\t\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t\t}\n\t\t\t\tthrow new Error(outcome.reason);\n\t\t\t}\n\n\t\t\tif (extensionCancelled || signal.aborted) {\n\t\t\t\tthis._emit({ type: \"compaction_end\", reason, result: undefined, aborted: true, willRetry: false });\n\n\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t}\n\n\t\t\tconst result = outcome.kind === \"success\" ? outcome.result : lastCompaction;\n\t\t\tif (!result) {\n\t\t\t\tthrow new Error(\"Auto-compaction succeeded without a result\");\n\t\t\t}\n\t\t\tthis._emit({ type: \"compaction_end\", reason, result, aborted: false, willRetry });\n\n\t\t\tif (willRetry) {\n\t\t\t\tconst messages = this.agent.state.messages;\n\t\t\t\tconst lastMsg = messages[messages.length - 1];\n\t\t\t\tif (lastMsg?.role === \"assistant\" && (lastMsg as AssistantMessage).stopReason === \"error\") {\n\t\t\t\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : \"compaction failed\";\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason,\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\terrorMessage:\n\t\t\t\t\treason === \"overflow\"\n\t\t\t\t\t\t? `Context overflow recovery failed: ${errorMessage}`\n\t\t\t\t\t\t: `Auto-compaction failed: ${errorMessage}`,\n\t\t\t});\n\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t} finally {\n\t\t\tthis._autoCompactionAbortController = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Run one compaction attempt, retrying retryable provider failures (stream stalls,\n\t * 429/5xx, network drops) with the session's retry policy. The reliability kernel\n\t * classifies a stall as retryable by design (see withStreamIdleWatchdog); without this\n\t * loop a single transient killed the whole compaction while ordinary turns survived the\n\t * same failure via auto-retry. Caller aborts are never retried; sleepAbortable rejects\n\t * with the abort reason if the signal fires mid-backoff.\n\t */\n\tprivate async _compactWithRetry(\n\t\trun: () => Promise<CompactionResult>,\n\t\tsignal: AbortSignal,\n\t\tprovider?: string,\n\t): Promise<CompactionResult> {\n\t\tconst retrySettings = this.settingsManager.getRetrySettings();\n\t\tconst maxAttempts = retrySettings.enabled ? Math.max(1, retrySettings.maxRetries + 1) : 1;\n\t\tconst policy: RetryPolicy = {\n\t\t\tmaxAttempts,\n\t\t\tbaseDelayMs: retrySettings.baseDelayMs,\n\t\t\tmaxDelayMs: DEFAULT_RETRY_POLICY.maxDelayMs,\n\t\t\tjitterRatio: 0,\n\t\t};\n\t\tfor (let attempt = 1; ; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await run();\n\t\t\t} catch (error) {\n\t\t\t\tif (signal.aborted || attempt >= maxAttempts) throw error;\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconst classified = classifyFailure({ message, provider });\n\t\t\t\tthis._failureCorpus.record({ provider, message, classified });\n\t\t\t\tif (!classified.retryable) throw error;\n\t\t\t\tawait sleepAbortable(\n\t\t\t\t\tcomputeRetryDelayMs(policy, attempt, { retryAfterMs: classified.retryAfterMs }),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Toggle auto-compaction setting.\n\t */\n\tsetAutoCompactionEnabled(enabled: boolean): void {\n\t\tthis.settingsManager.setCompactionEnabled(enabled);\n\t}\n\n\t/** Whether auto-compaction is enabled */\n\tget autoCompactionEnabled(): boolean {\n\t\treturn this.settingsManager.getCompactionEnabled();\n\t}\n\n\tasync bindExtensions(bindings: ExtensionBindings): Promise<void> {\n\t\tif (bindings.uiContext !== undefined) {\n\t\t\tthis._extensionUIContext = bindings.uiContext;\n\t\t}\n\t\tif (bindings.mode !== undefined) {\n\t\t\tthis._extensionMode = bindings.mode;\n\t\t}\n\t\tif (bindings.commandContextActions !== undefined) {\n\t\t\tthis._extensionCommandContextActions = bindings.commandContextActions;\n\t\t}\n\t\tif (bindings.abortHandler !== undefined) {\n\t\t\tthis._extensionAbortHandler = bindings.abortHandler;\n\t\t}\n\t\tif (bindings.shutdownHandler !== undefined) {\n\t\t\tthis._extensionShutdownHandler = bindings.shutdownHandler;\n\t\t}\n\t\tif (bindings.onError !== undefined) {\n\t\t\tthis._extensionErrorListener = bindings.onError;\n\t\t}\n\n\t\tthis._applyExtensionBindings(this._extensionRunner);\n\t\tawait this._extensionRunner.emit(this._sessionStartEvent);\n\t\tawait this.extendResourcesFromExtensions(this._sessionStartEvent.reason === \"reload\" ? \"reload\" : \"startup\");\n\t\t// Initialize the memory subsystem after extensions have had a chance to register providers.\n\t\tawait this._memory.initialize();\n\t}\n\n\tprivate async extendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void> {\n\t\tif (!this._extensionRunner.hasHandlers(\"resources_discover\")) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(\n\t\t\tthis._cwd,\n\t\t\treason,\n\t\t);\n\n\t\tif (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst extensionPaths: ResourceExtensionPaths = {\n\t\t\tskillPaths: this.buildExtensionResourcePaths(skillPaths),\n\t\t\tpromptPaths: this.buildExtensionResourcePaths(promptPaths),\n\t\t\tthemePaths: this.buildExtensionResourcePaths(themePaths),\n\t\t};\n\n\t\tthis._resourceLoader.extendResources(extensionPaths);\n\t\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t}\n\n\tprivate buildExtensionResourcePaths(entries: Array<{ path: string; extensionPath: string }>): Array<{\n\t\tpath: string;\n\t\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n\t}> {\n\t\treturn entries.map((entry) => {\n\t\t\tconst source = this.getExtensionSourceLabel(entry.extensionPath);\n\t\t\tconst baseDir = entry.extensionPath.startsWith(\"<\") ? undefined : dirname(entry.extensionPath);\n\t\t\treturn {\n\t\t\t\tpath: entry.path,\n\t\t\t\tmetadata: {\n\t\t\t\t\tsource,\n\t\t\t\t\tscope: \"temporary\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t\tbaseDir,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate getExtensionSourceLabel(extensionPath: string): string {\n\t\tif (extensionPath.startsWith(\"<\")) {\n\t\t\treturn `extension:${extensionPath.replace(/[<>]/g, \"\")}`;\n\t\t}\n\t\tconst base = basename(extensionPath);\n\t\tconst name = base.replace(/\\.(ts|js)$/, \"\");\n\t\treturn `extension:${name}`;\n\t}\n\n\tprivate _applyExtensionBindings(runner: ExtensionRunner): void {\n\t\trunner.setUIContext(this._extensionUIContext);\n\t\trunner.setMode(this._extensionMode);\n\t\trunner.bindCommandContext(this._extensionCommandContextActions);\n\n\t\tthis._extensionErrorUnsubscriber?.();\n\t\tthis._extensionErrorUnsubscriber = this._extensionErrorListener\n\t\t\t? runner.onError(this._extensionErrorListener)\n\t\t\t: undefined;\n\t}\n\n\tprivate _refreshCurrentModelFromRegistry(): void {\n\t\tconst currentModel = this.model;\n\t\tif (!currentModel) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);\n\t\tif (!refreshedModel || refreshedModel === currentModel) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.agent.state.model = refreshedModel;\n\t}\n\n\tprivate _bindExtensionCore(runner: ExtensionRunner): void {\n\t\tconst getCommands = (): SlashCommandInfo[] => {\n\t\t\tconst extensionCommands: SlashCommandInfo[] = runner.getRegisteredCommands().map((command) => ({\n\t\t\t\tname: command.invocationName,\n\t\t\t\tdescription: command.description,\n\t\t\t\tsource: \"extension\",\n\t\t\t\tsourceInfo: command.sourceInfo,\n\t\t\t}));\n\n\t\t\tconst templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({\n\t\t\t\tname: template.name,\n\t\t\t\tdescription: template.description,\n\t\t\t\tsource: \"prompt\",\n\t\t\t\tsourceInfo: template.sourceInfo,\n\t\t\t}));\n\n\t\t\tconst skills: SlashCommandInfo[] = this._resourceLoader.getActiveSkills().map((skill) => ({\n\t\t\t\tname: `skill:${skill.name}`,\n\t\t\t\tdescription: skill.description,\n\t\t\t\tsource: \"skill\",\n\t\t\t\tsourceInfo: skill.sourceInfo,\n\t\t\t}));\n\n\t\t\treturn [...extensionCommands, ...templates, ...skills];\n\t\t};\n\n\t\trunner.bindCore(\n\t\t\t{\n\t\t\t\tsendMessage: (message, options) => {\n\t\t\t\t\tthis.sendCustomMessage(message, options).catch((err) => {\n\t\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\t\tevent: \"send_message\",\n\t\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsendUserMessage: (content, options) => {\n\t\t\t\t\tthis.sendUserMessage(content, options).catch((err) => {\n\t\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\t\tevent: \"send_user_message\",\n\t\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tappendEntry: (customType, data) => {\n\t\t\t\t\tthis.sessionManager.appendCustomEntry(customType, data);\n\t\t\t\t},\n\t\t\t\tsetSessionName: (name) => {\n\t\t\t\t\tthis.setSessionName(name);\n\t\t\t\t},\n\t\t\t\tgetSessionName: () => {\n\t\t\t\t\treturn this.sessionManager.getSessionName();\n\t\t\t\t},\n\t\t\t\tsetLabel: (entryId, label) => {\n\t\t\t\t\tthis.sessionManager.appendLabelChange(entryId, label);\n\t\t\t\t},\n\t\t\t\tgetActiveTools: () => this.getActiveToolNames(),\n\t\t\t\tgetAllTools: () => this.getAllTools(),\n\t\t\t\tsetActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\t\trefreshTools: () => this._refreshToolRegistry(),\n\t\t\t\tgetCommands,\n\t\t\t\tsetModel: async (model) => {\n\t\t\t\t\tif (!this.modelRegistry.hasConfiguredAuth(model)) return false;\n\t\t\t\t\tawait this.setModel(model);\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level),\n\t\t\t\tgetExternalResourceRoots: () => this.settingsManager.getEffectiveExternalResourceRoots(),\n\t\t\t\tregisterMemoryProvider: (provider) => this.registerMemoryProvider(provider),\n\t\t\t\tregisterContextMemoryProvider: (provider) => this.registerContextMemoryProvider(provider),\n\t\t\t\treportSpawnedUsage: (usage, opts) => {\n\t\t\t\t\tthis.addSpawnedUsage(usage, opts);\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tgetModel: () => this.model,\n\t\t\t\tisIdle: () => !this.isStreaming,\n\t\t\t\tgetSignal: () => this.agent.signal,\n\t\t\t\tabort: () => {\n\t\t\t\t\tif (this._extensionAbortHandler) {\n\t\t\t\t\t\tthis._extensionAbortHandler();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvoid this.abort();\n\t\t\t\t},\n\t\t\t\thasPendingMessages: () => this.pendingMessageCount > 0,\n\t\t\t\tshutdown: () => {\n\t\t\t\t\tthis._extensionShutdownHandler?.();\n\t\t\t\t},\n\t\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\t\tcompact: (options) => {\n\t\t\t\t\tvoid (async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await this.compact(options?.customInstructions);\n\t\t\t\t\t\t\toptions?.onComplete?.(result);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\t\toptions?.onError?.(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t\treload: () => {\n\t\t\t\t\tif (this.isStreaming) {\n\t\t\t\t\t\treturn Promise.reject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\"ctx.reload() cannot run while the agent is streaming or a tool call is active. Wait for ctx.isIdle(), queue a follow-up /reload, or use an idle command/event handler so hot reload cannot destabilize the UI.\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.isCompacting) {\n\t\t\t\t\t\treturn Promise.reject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\"ctx.reload() cannot run during context compaction or branch summarization. Let compaction finish before reloading so the session tree and UI remain stable.\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst actions = this._extensionCommandContextActions;\n\t\t\t\t\tif (!actions) {\n\t\t\t\t\t\treturn this.reload();\n\t\t\t\t\t}\n\t\t\t\t\treturn actions.reload();\n\t\t\t\t},\n\t\t\t\tgetSystemPrompt: () => this.systemPrompt,\n\t\t\t},\n\t\t\t{\n\t\t\t\tregisterProvider: (name, config) => {\n\t\t\t\t\tthis._modelRegistry.registerProvider(name, config);\n\t\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t\t},\n\t\t\t\tunregisterProvider: (name) => {\n\t\t\t\t\tthis._modelRegistry.unregisterProvider(name);\n\t\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Register a memory provider contributed by an extension; applied on the next memory (re)init. */\n\tregisterMemoryProvider(provider: MemoryProvider): void {\n\t\tthis._memory.registerMemoryProvider(provider);\n\t}\n\n\tregisterContextMemoryProvider(provider: ContextMemoryProvider): void {\n\t\tthis._memory.registerContextMemoryProvider(provider);\n\t}\n\n\t/** R8: the gateway/scheduler registry. A deployment runner registers providers and drives start/stop. */\n\tget gateways(): GatewayRegistry {\n\t\treturn this._gatewayRegistry;\n\t}\n\n\t/** R8: register a deployment-supplied transport channel (gateway). */\n\tregisterChannelProvider(provider: ChannelProvider): void {\n\t\tthis._gatewayRegistry.registerChannel(provider);\n\t}\n\n\t/** R8: register a deployment-supplied job scheduler (cron). */\n\tregisterJobScheduler(provider: JobSchedulerProvider): void {\n\t\tthis._gatewayRegistry.registerScheduler(provider);\n\t}\n\n\tprivate _refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void {\n\t\tthis._runtimeBuilder.refreshToolRegistry(options);\n\t}\n\n\tasync reload(): Promise<void> {\n\t\treturn this._runtimeBuilder.reload();\n\t}\n\n\t/**\n\t * Unload a single extension without full reload.\n\t * Runs the extension's session_shutdown lifecycle, unregisters its providers,\n\t * disposes its event subscriptions, and rebuilds the runtime.\n\t * Falls back to full reload on error.\n\t */\n\tasync unloadExtensionLive(extensionPath: string): Promise<void> {\n\t\treturn this._runtimeBuilder.unloadExtensionLive(extensionPath);\n\t}\n\n\t/**\n\t * Load a single extension without full reload.\n\t * Loads the extension with fresh import, rebuilds the runtime,\n\t * and runs the extension's session_start lifecycle.\n\t * Falls back to full reload on error.\n\t */\n\tasync loadExtensionLive(extensionPath: string): Promise<void> {\n\t\treturn this._runtimeBuilder.loadExtensionLive(extensionPath);\n\t}\n\n\t/**\n\t * Reconcile loaded extensions with the active profile.\n\t * Loads extensions that should be enabled but aren't, and unloads extensions that shouldn't be.\n\t * Falls back to full reload if any individual load/unload fails.\n\t */\n\tasync reconcileLoadedExtensions(): Promise<void> {\n\t\treturn this._runtimeBuilder.reconcileLoadedExtensions();\n\t}\n\n\t// =========================================================================\n\t// Auto-Retry\n\t// =========================================================================\n\n\t/**\n\t * Check if an error is retryable (transient provider/network failures). Billing/quota and auth\n\t * are terminal; context overflow is handled by compaction, not retry. The verdict comes from the\n\t * reliability kernel's classifier, fed the host-computed context-overflow flag.\n\t */\n\tprivate _classifyAssistantError(message: AssistantMessage): ClassifiedError | undefined {\n\t\tif (message.stopReason !== \"error\" || !message.errorMessage) return undefined;\n\t\tconst contextWindow = this.model?.contextWindow ?? 0;\n\t\treturn classifyFailure({\n\t\t\tmessage: message.errorMessage,\n\t\t\tcontextOverflow: isContextOverflow(message, contextWindow),\n\t\t\tprovider: message.provider,\n\t\t});\n\t}\n\n\tprivate _isRetryableError(message: AssistantMessage): boolean {\n\t\treturn this._classifyAssistantError(message)?.retryable ?? false;\n\t}\n\n\t/**\n\t * Prepare a retryable error for continuation with exponential backoff.\n\t * @returns true if the caller should continue the agent, false otherwise\n\t */\n\tprivate async _prepareRetry(message: AssistantMessage): Promise<boolean> {\n\t\treturn this._retryController.prepareRetry(message);\n\t}\n\n\t/**\n\t * Cancel in-progress retry.\n\t */\n\tabortRetry(): void {\n\t\tthis._retryController.abort();\n\t}\n\n\t/** Whether auto-retry is currently in progress */\n\tget isRetrying(): boolean {\n\t\treturn this._retryController.isRetrying;\n\t}\n\n\t/** Whether auto-retry is enabled */\n\tget autoRetryEnabled(): boolean {\n\t\treturn this.settingsManager.getRetryEnabled();\n\t}\n\n\t/**\n\t * Toggle auto-retry setting.\n\t */\n\tsetAutoRetryEnabled(enabled: boolean): void {\n\t\tthis.settingsManager.setRetryEnabled(enabled);\n\t}\n\n\t// =========================================================================\n\t// Bash Execution\n\t// =========================================================================\n\n\tasync executeBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; operations?: BashOperations },\n\t): Promise<BashResult> {\n\t\treturn this._bash.executeBash(command, onChunk, options);\n\t}\n\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void {\n\t\tthis._bash.recordBashResult(command, result, options);\n\t}\n\n\tabortBash(): void {\n\t\tthis._bash.abortBash();\n\t}\n\n\t/** Whether a bash command is currently running */\n\tget isBashRunning(): boolean {\n\t\treturn this._bash.isBashRunning;\n\t}\n\n\t/** Whether there are pending bash messages waiting to be flushed */\n\tget hasPendingBashMessages(): boolean {\n\t\treturn this._bash.hasPendingBashMessages;\n\t}\n\n\tprivate _flushPendingBashMessages(): void {\n\t\tthis._bash.flushPendingBashMessages();\n\t}\n\n\t// =========================================================================\n\t// Session Management\n\t// =========================================================================\n\n\t/**\n\t * Set a display name for the current session.\n\t */\n\tsetSessionName(name: string): void {\n\t\tthis.sessionManager.appendSessionInfo(name);\n\t\tthis._emit({ type: \"session_info_changed\", name: this.sessionManager.getSessionName() });\n\t}\n\n\t// =========================================================================\n\t// Tree Navigation\n\t// =========================================================================\n\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string } = {},\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }> {\n\t\treturn this._treeNavigator.navigateTree(targetId, options);\n\t}\n\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }> {\n\t\treturn this._treeNavigator.getUserMessagesForForking();\n\t}\n\n\tgetSessionStats(): SessionStats {\n\t\treturn this._analytics.getSessionStats();\n\t}\n\n\tgetCumulativeUsage(): Usage {\n\t\treturn this._analytics.getCumulativeUsage();\n\t}\n\n\taddSpawnedUsage(\n\t\tusage: Usage,\n\t\topts?: { label?: string; sourceSessionId?: string; reportId?: string },\n\t): string | undefined {\n\t\treturn this._analytics.addSpawnedUsage(usage, opts);\n\t}\n\n\tgetSpawnedUsage(): SpawnedUsageTotals {\n\t\treturn this._analytics.getSpawnedUsage();\n\t}\n\n\tgetDailyUsageTotals(now = new Date()): DailyUsageTotals {\n\t\treturn this._analytics.getDailyUsageTotals(now);\n\t}\n\n\tgetCostSummary(now = new Date()): SessionCostSummary {\n\t\treturn this._analytics.getCostSummary(now);\n\t}\n\n\tgetDailyUsageBreakdown(formatLabel?: (label: string) => string, now = new Date()): string {\n\t\treturn this._analytics.getDailyUsageBreakdown(formatLabel, now);\n\t}\n\n\t/**\n\t * Save a snapshot of the goal state to the session log.\n\t *\n\t * @returns the id of the appended custom entry\n\t */\n\tsaveGoalStateSnapshot(state: GoalState): string {\n\t\treturn appendGoalStateSnapshot(this.sessionManager, state);\n\t}\n\n\t/**\n\t * Retrieve the latest valid goal state snapshot from the session log.\n\t */\n\tgetGoalStateSnapshot(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.sessionManager.getEntries());\n\t}\n\n\t/**\n\t * Save a snapshot of the evidence bundle to the session log.\n\t *\n\t * @returns the id of the appended custom entry\n\t */\n\tsaveEvidenceBundleSnapshot(bundle: EvidenceBundle): string {\n\t\treturn appendEvidenceBundleSnapshot(this.sessionManager, bundle);\n\t}\n\n\t/**\n\t * Retrieve the latest valid evidence bundle snapshot from the session log.\n\t */\n\tgetEvidenceBundleSnapshot(): EvidenceBundle | undefined {\n\t\treturn getLatestEvidenceBundleSnapshot(this.sessionManager.getEntries());\n\t}\n\n\tgetEvidenceBundleSnapshots(): EvidenceBundle[] {\n\t\treturn getEvidenceBundleSnapshots(this.sessionManager.getEntries());\n\t}\n\n\t/** Live lane records tracked by this process (running and terminal). */\n\tgetLaneRecords(): LaneRecord[] {\n\t\treturn this._backgroundLanes.getLaneRecords();\n\t}\n\n\t// G3/G8 autonomy telemetry + gate-outcome history live in AutonomyTelemetry (see\n\t// autonomy-telemetry.ts). These stubs keep the god file's internal call surface stable while the\n\t// sink logic and the owned gate-outcome fields live there.\n\tprivate _emitAutonomyTelemetry(event: AutonomyTelemetryEvent): void {\n\t\tthis._autonomyTelemetry.emitTelemetry(event);\n\t}\n\n\tprivate _recordGateOutcome(outcome: GateOutcome): void {\n\t\tthis._autonomyTelemetry.recordGateOutcome(outcome);\n\t}\n\n\t/** G8: copies of the bounded gate-outcome history, oldest first, latest last. */\n\tgetGateOutcomeHistory(): GateOutcomeHistoryEntry[] {\n\t\treturn this._autonomyTelemetry.getGateOutcomeHistory();\n\t}\n\n\tsaveWorkerResultSnapshot(result: WorkerResult, request?: WorkerRequest): string {\n\t\treturn appendWorkerResultSnapshot(this.sessionManager, result, request);\n\t}\n\n\tgetWorkerResultSnapshots(): WorkerResult[] {\n\t\treturn getWorkerResultSnapshots(this.sessionManager.getEntries());\n\t}\n\n\tsaveLearningDecisionSnapshot(decision: LearningDecision): string {\n\t\treturn appendLearningDecisionSnapshot(this.sessionManager, decision);\n\t}\n\n\tgetLearningDecisionSnapshots(): LearningDecision[] {\n\t\treturn getLearningDecisionSnapshots(this.sessionManager.getEntries());\n\t}\n\n\tgetGoalRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tentries: this.sessionManager.getEntries(),\n\t\t\tsettings,\n\t\t});\n\t}\n\n\t/**\n\t * Capability profile derived from the CURRENT session model's own metadata (context window),\n\t * honoring the modelCapability.mode setting (\"off\" disables, a class name forces).\n\t */\n\tgetModelCapabilityProfile(): ModelCapabilityProfile {\n\t\treturn deriveModelCapabilityProfile({\n\t\t\tcontextWindow: this.model?.contextWindow,\n\t\t\tmode: this.settingsManager.getModelCapabilitySettings().mode,\n\t\t});\n\t}\n\n\t/**\n\t * Run one bounded, read-only research pass and persist its results. Delegates to\n\t * {@link BackgroundLaneController}; see there for the full gating/budget/dedupe contract.\n\t */\n\tasync runResearchLaneOnce(request?: {\n\t\tquery?: string;\n\t\tcontext?: string;\n\t\tgoalId?: string;\n\t}): Promise<ResearchLaneRunOutcome> {\n\t\treturn this._backgroundLanes.runResearchLaneOnce(request);\n\t}\n\n\t/**\n\t * Run one bounded scout-worker delegation. Delegates to {@link BackgroundLaneController};\n\t * consumed by the `delegate` tool.\n\t */\n\tasync runWorkerDelegationOnce(request: {\n\t\tinstructions: string;\n\t\tsystemPrompt?: string;\n\t\tmemoryRead?: boolean;\n\t}): Promise<WorkerDelegationRunOutcome> {\n\t\treturn this._backgroundLanes.runWorkerDelegationOnce(request);\n\t}\n\n\t/**\n\t * Probe a candidate model against the subagent contracts. Delegates to\n\t * {@link BackgroundLaneController}; probe spend is reported through spawned-usage accounting.\n\t */\n\tasync runModelFitness(args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t}): Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }> {\n\t\treturn this._backgroundLanes.runModelFitness(args);\n\t}\n\n\t/** Fitness reports persisted for THIS host (measured evidence for architect/profile decisions). */\n\tgetStoredFitnessReports(): StoredFitnessReport[] {\n\t\treturn this._backgroundLanes.getStoredFitnessReports();\n\t}\n\n\tasync continueGoalOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this._goalContinuation.continueGoalOnce(options);\n\t}\n\n\tasync continueGoalLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this._goalContinuation.continueGoalLoop(options);\n\t}\n\n\t/**\n\t * Run a one-shot LLM completion fully ISOLATED from the main session — the load-bearing primitive\n\t * for native reflection (see reflection-controller.ts for the isolation invariants).\n\t */\n\tasync runIsolatedCompletion(opts: IsolatedCompletionOptions): Promise<IsolatedCompletionResult> {\n\t\treturn this._reflection.runIsolatedCompletion(opts);\n\t}\n\n\t/**\n\t * Native end-of-loop reflection pass (R2). Delegates to {@link ReflectionController}; returns null\n\t * when the demand gate skips or in a child session.\n\t */\n\tasync runReflectionPass(input: {\n\t\tsignals: DemandSignals;\n\t\trecentTurnText: string;\n\t\tmodel?: Model<any>;\n\t\tthinkingLevel?: ThinkingLevel;\n\t\tsignal?: AbortSignal;\n\t\t/** Stable id so a duplicate scheduling/retry of the same pass can't double-count its cost. */\n\t\treportId?: string;\n\t}): Promise<ReflectionResult | null> {\n\t\treturn this._reflection.runReflectionPass(input);\n\t}\n\n\tgetLearningAuditRecords(): LearningAuditRecord[] {\n\t\treturn this._reflection.getLearningAuditRecords();\n\t}\n\n\t/** Roll back one applied durable learning change. Delegates to {@link ReflectionController}. */\n\tasync rollbackLearningWrite(auditId: string): Promise<{ ok: boolean; reason: string }> {\n\t\treturn this._reflection.rollbackLearningWrite(auditId);\n\t}\n\n\tgetContextUsage(): ContextUsage | undefined {\n\t\treturn this._analytics.getContextUsage();\n\t}\n\n\tasync exportToHtml(outputPath?: string): Promise<string> {\n\t\treturn this._analytics.exportToHtml(outputPath);\n\t}\n\n\texportToJsonl(outputPath?: string): string {\n\t\treturn this._analytics.exportToJsonl(outputPath);\n\t}\n\n\t// =========================================================================\n\t// Utilities\n\t// =========================================================================\n\n\tgetLastAssistantText(): string | undefined {\n\t\treturn this._analytics.getLastAssistantText();\n\t}\n\n\t// =========================================================================\n\t// Extension System\n\t// =========================================================================\n\n\tpublic getAutonomyStatusSnapshot(): AutonomyStatusSnapshot {\n\t\treturn this._autonomyTelemetry.getStatusSnapshot();\n\t}\n\n\t/**\n\t * Aggregate an effectiveness/autonomy dashboard: what Pi has actually been doing (recent\n\t * route choices, latest gate outcome, cost, and any research/delegation/learning/goal\n\t * activity). Read-only — combines existing session-log getters, never mutates state or\n\t * recomputes a route/gate decision.\n\t */\n\tpublic getAutonomyDiagnosticSnapshot(options?: { maxEntriesPerFamily?: number }): AutonomyDiagnosticSnapshot {\n\t\treturn this._autonomyTelemetry.getDiagnosticSnapshot(options);\n\t}\n\n\tcreateReplacedSessionContext(): ReplacedSessionContext {\n\t\tconst context = Object.defineProperties(\n\t\t\t{},\n\t\t\tObject.getOwnPropertyDescriptors(this._extensionRunner.createCommandContext()),\n\t\t) as ReplacedSessionContext;\n\t\tcontext.sendMessage = (message, options) => this.sendCustomMessage(message, options);\n\t\tcontext.sendUserMessage = (content, options) => this.sendUserMessage(content, options);\n\t\treturn context;\n\t}\n\n\t/**\n\t * Check if extensions have handlers for a specific event type.\n\t */\n\thasExtensionHandlers(eventType: string): boolean {\n\t\treturn this._extensionRunner.hasHandlers(eventType);\n\t}\n\n\t/**\n\t * Get the extension runner (for setting UI context and error handlers).\n\t */\n\tget extensionRunner(): ExtensionRunner {\n\t\treturn this._extensionRunner;\n\t}\n}\n\nfunction findLastAssistantMessage(messages: AgentMessage[]): AssistantMessage | undefined {\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst message = messages[i];\n\t\tif (message.role === \"assistant\") {\n\t\t\treturn message;\n\t\t}\n\t}\n\treturn undefined;\n}\n"]}
1
+ {"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../../src/core/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAA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FileSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\nimport type {\n\tAgent,\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tClassifiedError,\n\tStreamFn,\n\tStreamIdleOptions,\n\tThinkingLevel,\n} from \"@caupulican/pi-agent-core\";\nimport {\n\ttype CustomMessage,\n\tclassifyFailure,\n\tcompactToolResultDetailsForRetention,\n\tcomputeRetryDelayMs,\n\tcreateCustomMessage,\n\tDEFAULT_RETRY_POLICY,\n\tDEFAULT_STREAM_IDLE,\n\tRetryController,\n\ttype RetryPolicy,\n\tsleepAbortable,\n\twithStreamIdleWatchdog,\n} from \"@caupulican/pi-agent-core\";\nimport {\n\ttype BranchSummaryEntry,\n\ttype CompactionEntry,\n\ttype CompactionResult,\n\ttype CompactionSettings,\n\tcalculateContextTokens,\n\tcompact,\n\tcreateDeterministicCompaction,\n\testimateContextTokens,\n\tgetLatestCompactionEntry,\n\tprepareCompaction,\n\trunCompactionLoop,\n\ttype SessionManager,\n\tshouldCompact,\n} from \"@caupulican/pi-agent-core/node\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tCacheRetention,\n\tContext,\n\tImageContent,\n\tMessage,\n\tModel,\n\tSimpleStreamOptions,\n\tStopReason,\n\tTextContent,\n\tTextToolProtocolParseEvent,\n\tTextToolProtocolVariant,\n\tTool,\n\tToolArgumentValidationTelemetryEvent,\n\tToolRepairModeName,\n\tUsage,\n} from \"@caupulican/pi-ai\";\nimport {\n\tcleanupSessionResources,\n\tformatToolRepairStandingRule,\n\tgenerateTextToolProtocolPrimer,\n\tgetSupportedThinkingLevels,\n\tisContextOverflow,\n\tmodelsAreEqual,\n\tparseTextToolCalls,\n\tstreamSimple,\n} from \"@caupulican/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getAgentDir } from \"../config.ts\";\nimport { stripFrontmatter } from \"../utils/frontmatter.ts\";\nimport { getProcessWorkRun } from \"../utils/work-directory.ts\";\nimport { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from \"./auth-guidance.ts\";\nimport type {\n\tCapabilityEnvelope,\n\tEvidenceBundle,\n\tGateOutcome,\n\tLearningDecision,\n\tRouteDecision,\n\tWorkerRequest,\n\tWorkerResult,\n} from \"./autonomy/contracts.ts\";\nimport { buildForegroundEnvelope, formatForegroundEnvelopeObservation } from \"./autonomy/foreground-envelope.ts\";\nimport { evaluateToolGate } from \"./autonomy/gates.ts\";\nimport type { LaneRecord, LaneTerminalStatus } from \"./autonomy/lane-tracker.ts\";\nimport type { AutonomyDiagnosticSnapshot, AutonomyStatusSnapshot, GateOutcomeHistoryEntry } from \"./autonomy/status.ts\";\nimport type { AutonomyTelemetryEvent } from \"./autonomy/telemetry-events.ts\";\nimport { AutonomyTelemetry } from \"./autonomy-telemetry.ts\";\nimport { BackgroundLaneController } from \"./background-lane-controller.ts\";\nimport { BashExecutionController } from \"./bash-execution-controller.ts\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport { BillingFailoverController, ExhaustedProviderRegistry } from \"./billing-failover-controller.ts\";\nimport { CompactionSupport } from \"./compaction-support.ts\";\n// (module-scope helper for curation goal extraction defined below the imports)\nimport type { CurationTelemetrySnapshot } from \"./context/brain-curator.ts\";\nimport type { ArtifactStore } from \"./context/context-artifacts.ts\";\nimport type { ContextAuditReport } from \"./context/context-audit.ts\";\nimport {\n\tbuildContextCompositionReport,\n\ttype ContextCompositionReport,\n\tformatContextCompositionDashboard,\n} from \"./context/context-composition.ts\";\nimport type { PromptEnforcementReport } from \"./context/context-prompt-enforcement.ts\";\nimport type { PromptPolicyGcCorrelationReport, PromptPolicyShadowReport } from \"./context/context-prompt-policy.ts\";\nimport type { MemoryPromptInclusionReport } from \"./context/memory-diagnostics.ts\";\nimport type { MemoryProvider as ContextMemoryProvider } from \"./context/memory-provider-contract.ts\";\nimport type { MemoryRetrievalReport } from \"./context/memory-retrieval.ts\";\nimport type { ContextGcReport } from \"./context-gc.ts\";\nimport { ContextPipeline } from \"./context-pipeline.ts\";\nimport type { SessionCostSummary } from \"./cost/cost-summary.ts\";\nimport type { DailyUsageTotals } from \"./cost/daily-usage.ts\";\nimport { type CostGuardDecision, downgradeReasoning, estimateTurnCostUsd, evaluateCostGuard } from \"./cost-guard.ts\";\nimport { appendWorkerResultSnapshot, getWorkerResultSnapshots } from \"./delegation/session-worker-result.ts\";\nimport type { WorkerRunOutcome } from \"./delegation/worker-runner.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionErrorListener,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tInputSource,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tReplacedSessionContext,\n\tSessionBeforeCompactResult,\n\tSessionStartEvent,\n\tShutdownHandler,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tTurnEndEvent,\n\tTurnStartEvent,\n} from \"./extensions/index.ts\";\nimport { FailureCorpusRecorder } from \"./failure-corpus.ts\";\nimport { type ChannelProvider, GatewayRegistry, type JobSchedulerProvider } from \"./gateways/channel-provider.ts\";\nimport { GoalLoopController } from \"./goal-loop-controller.ts\";\nimport type { GoalContinuationPrompt, GoalContinuationPromptLimits } from \"./goals/goal-continuation-prompt.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goals/goal-runtime-snapshot.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport { appendGoalStateSnapshot, getLatestGoalStateSnapshot } from \"./goals/session-goal-state.ts\";\nimport { constrainStreamIdleToHttpTimeout } from \"./http-dispatcher.ts\";\nimport type { LearningAuditRecord } from \"./learning/learning-audit.ts\";\nimport type { DemandSignals, ReflectionResult } from \"./learning/reflection-engine.ts\";\nimport { appendLearningDecisionSnapshot, getLearningDecisionSnapshots } from \"./learning/session-learning-decision.ts\";\nimport { type CurationProposals, isPromotedFrontmatter, SkillCurator } from \"./learning/skill-curator.ts\";\nimport { LocalRuntimeController } from \"./local-runtime-controller.ts\";\nimport type { MemoryProvider } from \"./memory/memory-provider.ts\";\nimport { MemoryController } from \"./memory-controller.ts\";\nimport {\n\tderiveModelCapabilityProfile,\n\tfilterToolNamesForCapability,\n\ttype ModelCapabilityProfile,\n} from \"./model-capability.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport { formatModelRouterModel, ModelRouterController } from \"./model-router-controller.ts\";\nimport { ModelSelectionController } from \"./model-selection-controller.ts\";\nimport { ModelAdaptationStore, type ModelToolProbe, type NativeToolProbeGrade } from \"./models/adaptation-store.ts\";\nimport type { StoredFitnessReport } from \"./models/fitness-store.ts\";\nimport { HF_TRANSFORMERS_PROVIDER, OLLAMA_PROVIDER } from \"./models/local-registration.ts\";\nimport type { LocalRuntimeDeps, OllamaRuntime, TransformersRuntime } from \"./models/local-runtime.ts\";\nimport {\n\tDEFAULT_ADAPTIVE_STREAM_IDLE_CEILING_MS,\n\testimateContextPromptTokens,\n\tresolveAdaptiveStreamIdleOptions,\n\twithModelPerfProfile,\n} from \"./models/perf-profile.ts\";\nimport { ProfileFilterController } from \"./profile-filter-controller.ts\";\nimport { expandPromptTemplate, type PromptTemplate } from \"./prompt-templates.ts\";\nimport { ReflectionController } from \"./reflection-controller.ts\";\nimport type { ModelFitnessReport } from \"./research/model-fitness.ts\";\nimport type { ResearchRunResult } from \"./research/research-runner.ts\";\nimport {\n\tappendEvidenceBundleSnapshot,\n\tgetEvidenceBundleSnapshots,\n\tgetLatestEvidenceBundleSnapshot,\n} from \"./research/session-evidence-bundle.ts\";\nimport { collectWorkspaceSources } from \"./research/workspace-collector.ts\";\nimport type { ResourceExtensionPaths, ResourceLoader } from \"./resource-loader.ts\";\nimport { stripResourceProfileBlocks } from \"./resource-profile-blocks.ts\";\nimport { RuntimeBuilder } from \"./runtime-builder.ts\";\nimport { SessionAnalytics, type ToolArgumentValidationStats } from \"./session-analytics.ts\";\nimport { SessionTreeNavigator } from \"./session-tree-navigator.ts\";\nimport type { ResourceProfileFilterSettings, SettingsManager } from \"./settings-manager.ts\";\nimport type { SlashCommandInfo } from \"./slash-commands.ts\";\nimport { SystemPromptBuilder } from \"./system-prompt-builder.ts\";\nimport { appendTaskStepsStateSnapshot, getLatestTaskStepsStateSnapshot } from \"./tasks/session-task-state.ts\";\nimport { formatTaskStepsContext, type TaskStepsState } from \"./tasks/task-state.ts\";\nimport { ToolGateController } from \"./tool-gate-controller.ts\";\nimport { TOOL_RECOVERY_EVENT_LOG_FILE } from \"./tool-recovery-log-records.ts\";\nimport { ToolRecoveryLogger } from \"./tool-recovery-logger.ts\";\nimport { formatToolRepairHealthReport } from \"./tool-repair-health.ts\";\nimport { resolveCurrentToolRepairSettings } from \"./tool-repair-settings.ts\";\nimport { ToolPerformanceStore } from \"./tool-selection/tool-performance-store.ts\";\nimport { ToolSelectionController } from \"./tool-selection/tool-selection-controller.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\n\n// ============================================================================\n// Stream-idle watchdog wiring\n// ============================================================================\n\n/**\n * Marks a watchdog-wrapped stream fn whose inner base was the raw `streamSimple`.\n *\n * The session tests `streamFn === streamSimple` in three places to decide whether it must\n * inject request auth explicitly (the raw-provider path used in tests and no-key setups).\n * Wrapping the fn with the idle watchdog breaks that identity, so the wrapper carries this\n * marker and those checks go through `_isRawStreamSimple` instead. `Symbol.for` keeps the\n * key stable regardless of how many times this module is evaluated.\n */\nconst RAW_STREAM_MARKER = Symbol.for(\"pi.rawStreamSimple\");\nconst MODEL_ADAPTATION_REPAIR_THRESHOLD = 3;\nconst TEXT_TOOL_PROTOCOL_VERSION = 1;\nconst TEXT_TOOL_PROTOCOL_TRIALS_PER_VARIANT = 2;\nconst TEXT_TOOL_PROTOCOL_PARSE_FAILURE_THRESHOLD = 3;\nconst TEXT_TOOL_PROTOCOL_VARIANTS: readonly TextToolProtocolVariant[] = [\n\t\"tool-tag\",\n\t\"tool-call\",\n\t\"fenced-json\",\n\t\"function-xml\",\n];\nconst TEXT_TOOL_PROTOCOL_ECHO_TOOL = {\n\tname: \"echo\",\n\tdescription: \"Echo calibration data\",\n\tparameters: Type.Object({ data: Type.String() }),\n} satisfies Tool;\nconst NATIVE_TOOL_PROBE_READ_TOOL = {\n\tname: \"read\",\n\tdescription: \"Read file contents\",\n\tparameters: Type.Object({ path: Type.String() }),\n} satisfies Tool;\n\n/** Test-only override of the stream-idle bounds. Read per-request by the wiring's resolver. */\nlet streamIdleOptionsOverride: Partial<StreamIdleOptions> | undefined;\n\n/**\n * Test hook: override the stream-idle bounds so a stall can be provoked in-suite without a\n * multi-minute wait. Pass `undefined` to restore the user-locked defaults (connect 120s /\n * active 180s / quiet 600s, or the user's retry.stall settings). Applies per request — it\n * may be set or changed at any time before the request that should observe it.\n */\nexport function setStreamIdleOptionsForTests(opts: Partial<StreamIdleOptions> | undefined): void {\n\tstreamIdleOptionsOverride = opts;\n}\n\n/**\n * Tag a watchdog-wrapped stream fn with whether its inner base was the raw `streamSimple`,\n * so `_isRawStreamSimple` can see the raw-provider path through the wrapper.\n */\nfunction tagRawness(wrapped: StreamFn, innerIsRawStreamSimple: boolean): StreamFn {\n\tObject.defineProperty(wrapped, RAW_STREAM_MARKER, { value: innerIsRawStreamSimple });\n\treturn wrapped;\n}\n\n// ============================================================================\n// Skill Block Parsing\n// ============================================================================\n\n/** Parsed skill block from a user message */\nexport interface ParsedSkillBlock {\n\tname: string;\n\tlocation: string;\n\tcontent: string;\n\tuserMessage: string | undefined;\n}\n\n/**\n * Parse a skill block from message text.\n * Returns null if the text doesn't contain a skill block.\n */\nexport function parseSkillBlock(text: string): ParsedSkillBlock | null {\n\tconst match = text.match(/^<skill name=\"([^\"]+)\" location=\"([^\"]+)\">\\n([\\s\\S]*?)\\n<\\/skill>(?:\\n\\n([\\s\\S]+))?$/);\n\tif (!match) return null;\n\treturn {\n\t\tname: match[1],\n\t\tlocation: match[2],\n\t\tcontent: match[3],\n\t\tuserMessage: match[4]?.trim() || undefined,\n\t};\n}\n\n/** Session-specific events that extend the core AgentEvent */\nexport type AgentSessionEvent =\n\t| Exclude<AgentEvent, { type: \"agent_end\" }>\n\t| {\n\t\t\ttype: \"agent_end\";\n\t\t\tmessages: AgentMessage[];\n\t\t\twillRetry: boolean;\n\t }\n\t| {\n\t\t\ttype: \"queue_update\";\n\t\t\tsteering: readonly string[];\n\t\t\tfollowUp: readonly string[];\n\t\t\tcommands: readonly string[];\n\t }\n\t| { type: \"compaction_start\"; reason: \"manual\" | \"threshold\" | \"overflow\" }\n\t| { type: \"session_info_changed\"; name: string | undefined }\n\t| { type: \"thinking_level_changed\"; level: ThinkingLevel }\n\t| { type: \"warning\"; message: string }\n\t| {\n\t\t\ttype: \"compaction_end\";\n\t\t\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t\t\tresult: CompactionResult | undefined;\n\t\t\taborted: boolean;\n\t\t\twillRetry: boolean;\n\t\t\terrorMessage?: string;\n\t\t\t/**\n\t\t\t * Benign no-op explanation for auto-compaction (e.g. \"nothing to compact yet\"). Auto\n\t\t\t * bails must never be silent: without a result, either errorMessage (real failure) or\n\t\t\t * skipReason (harmless skip) is set so the UI can show why nothing changed.\n\t\t\t */\n\t\t\tskipReason?: string;\n\t }\n\t| { type: \"auto_retry_start\"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }\n\t| { type: \"auto_retry_end\"; success: boolean; attempt: number; finalError?: string }\n\t// Brackets the routing/prep phase of a turn (judge + model/auth checks + compaction, etc.) — the\n\t// gap between the user's prompt painting and the turn actually starting to stream, which today\n\t// has no visible feedback. UI-only: no persistence, no bearing on the turn itself. Always paired\n\t// exactly once per _promptUnserialized attempt that reaches past the early-return paths (queued\n\t// steer/followUp, extension commands, input-transform) — never emitted for those.\n\t| { type: \"routing_start\" }\n\t| { type: \"routing_end\" }\n\t| {\n\t\t\ttype: \"delegate_workers\";\n\t\t\tactive: number;\n\t\t\tqueued: number;\n\t\t\trunning: number;\n\t\t\tcompletedSinceFlush: number;\n\t\t\tfailedSinceFlush: number;\n\t\t\tterminalSinceFlush: Array<{\n\t\t\t\tlaneId: string;\n\t\t\t\tstatus: LaneTerminalStatus;\n\t\t\t\treasonCode?: string;\n\t\t\t}>;\n\t };\n\n/** Listener function for agent session events */\nexport type AgentSessionEventListener = (event: AgentSessionEvent) => void;\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface AgentSessionConfig {\n\tagent: Agent;\n\tsessionManager: SessionManager;\n\tsettingsManager: SettingsManager;\n\tcwd: string;\n\t/** User-level agent state directory for generated runtime artifacts. */\n\tagentDir?: string;\n\t/** Models to cycle through with Ctrl+P (from --models flag) */\n\tscopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\t/** Resource loader for skills, prompts, themes, context files, system prompt */\n\tresourceLoader: ResourceLoader;\n\t/** SDK custom tools registered outside extensions */\n\tcustomTools?: ToolDefinition[];\n\t/** Model registry for API key resolution and model discovery */\n\tmodelRegistry: ModelRegistry;\n\t/** Initial active built-in tool names. Default: [read, bash, edit, write, context_audit, goal] */\n\tinitialActiveToolNames?: string[];\n\t/** Optional allowlist of tool names. When provided, only these tool names are exposed. */\n\tallowedToolNames?: string[];\n\t/** Optional denylist of tool names. When provided, these tool names are not exposed. */\n\texcludedToolNames?: string[];\n\t/** Optional resource-profile allow/block filters for tool names. */\n\ttoolProfileFilter?: ResourceProfileFilterSettings;\n\t/**\n\t * Whether the model/thinking level came from an explicit launch flag. When false, the active\n\t * profile's model/thinking is re-applied on reload() so live profile edits take effect; when\n\t * true, the explicit launch-time choice is preserved.\n\t */\n\tisExplicitModel?: boolean;\n\tisExplicitThinking?: boolean;\n\t/** True when this session is a spawned subagent/child — gates durable memory writes. */\n\tisChildSession?: boolean;\n\t/**\n\t * Override base tools (useful for custom runtimes).\n\t *\n\t * These are synthesized into minimal ToolDefinitions internally so AgentSession can keep\n\t * a definition-first registry even when callers provide plain AgentTool instances.\n\t */\n\tbaseToolsOverride?: Record<string, AgentTool>;\n\t/** Mutable ref used by Agent to access the current ExtensionRunner */\n\textensionRunnerRef?: { current?: ExtensionRunner };\n\t/** Session start event metadata emitted when extensions bind to this runtime. */\n\tsessionStartEvent?: SessionStartEvent;\n\t/**\n\t * Pointer-first workspace source collector for the autonomous research lane. Injected in unit\n\t * tests so they don't spawn a real ripgrep child (which would escape fake timers); production\n\t * defaults to the real, best-effort collector.\n\t */\n\tcollectWorkspaceSources?: typeof collectWorkspaceSources;\n\t/**\n\t * Injected fetch/spawn/exists for the local (Ollama) runtime health-check + boot used by the\n\t * model router before a turn routed to a local model (see LocalRuntimeController.ensureLocalModelReady).\n\t * Unit tests inject fakes so they never hit a real network/process; production defaults to the real ones.\n\t */\n\tlocalRuntimeDeps?: LocalRuntimeDeps;\n}\n\nexport interface ExtensionBindings {\n\tuiContext?: ExtensionUIContext;\n\tmode?: ExtensionContext[\"mode\"];\n\tcommandContextActions?: ExtensionCommandContextActions;\n\tabortHandler?: () => void;\n\tshutdownHandler?: ShutdownHandler;\n\tonError?: ExtensionErrorListener;\n}\n\n/** Options for AgentSession.prompt() */\nexport interface PromptOptions {\n\t/** Whether to expand file-based prompt templates and skills (default: true). */\n\texpandPromptTemplates?: boolean;\n\t/** Whether slash commands should be handled before sending to the model. Defaults to expandPromptTemplates. */\n\tprocessSlashCommands?: boolean;\n\t/** Image attachments */\n\timages?: ImageContent[];\n\t/** When streaming, how to queue the message: \"steer\" (interrupt) or \"followUp\" (wait). Required if streaming. */\n\tstreamingBehavior?: \"steer\" | \"followUp\";\n\t/** Source of input for extension input event handlers. Defaults to \"interactive\". */\n\tsource?: InputSource;\n\t/** Internal hook used by RPC mode to observe prompt preflight acceptance or rejection. */\n\tpreflightResult?: (success: boolean) => void;\n\t/** Whether an idle active goal should auto-inject bounded continuation prompts after this prompt settles. Default: true. */\n\tautoContinueGoal?: boolean;\n}\n\nexport type ToolProbeVerdict = \"native\" | \"text-protocol\" | \"none\";\n\nexport interface ToolProbeResult {\n\tmodel: string;\n\tverdict: ToolProbeVerdict;\n\tvariant?: TextToolProtocolVariant;\n\tnativeGrade?: NativeToolProbeGrade;\n\tdiagnostic?: string;\n}\n\nexport interface ToolProbeReport {\n\tresults: ToolProbeResult[];\n\ttable: string;\n}\n\n/** Result from cycleModel() */\nexport interface ModelCycleResult {\n\tmodel: Model<any>;\n\tthinkingLevel: ThinkingLevel;\n\t/** Whether cycling through scoped models (--models flag) or all available */\n\tisScoped: boolean;\n}\n\n/** Session statistics for /session command */\nexport interface CompactionGateStats {\n\tgateFailures: number;\n\tdeterministicGapFills: number;\n\tcompactionsWithGateFailures: number;\n}\n\nexport interface SessionStats {\n\tsessionFile: string | undefined;\n\tsessionId: string;\n\tuserMessages: number;\n\tassistantMessages: number;\n\ttoolCalls: number;\n\ttoolResults: number;\n\ttotalMessages: number;\n\ttokens: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n\tcost: number;\n\tcontextUsage?: ContextUsage;\n\ttoolArgumentValidation: ToolArgumentValidationStats;\n\tcompactionGates: CompactionGateStats;\n}\n\n/** customType for spawned-usage roll-up entries (Cost Aggregation, Model A). */\nexport const SPAWNED_USAGE_CUSTOM_TYPE = \"spawned_usage\";\n\n/**\n * A single spawned/subagent usage report, persisted as a `CustomEntry`\n * (`customType: \"spawned_usage\"`). Persistence-only — does NOT enter LLM context.\n *\n * Single-hop invariant: each report MUST already include the reporter's own usage AND its\n * accumulated sub-usage. A child rolls up its grandchildren, then reports once to its direct\n * parent. Only the direct parent records the report — never a grandparent — so cost cannot be\n * double-counted across levels.\n */\nexport interface SpawnedUsageReport {\n\t/** Cumulative usage attributed to the spawned session (own + its own sub-usage). */\n\tusage: Usage;\n\t/** Human-readable source label for diagnostics (e.g. subagent name). */\n\tlabel?: string;\n\t/** Session id of the reporting child, if known. */\n\tsourceSessionId?: string;\n\t/** Stable id used to de-duplicate re-reports (retries, double agent_end). */\n\treportId?: string;\n}\n\n/** Aggregated spawned-usage totals derived from `spawned_usage` custom entries. */\nexport interface SpawnedUsageTotals {\n\t/** Summed `usage.cost.total` across all recorded reports. */\n\tcost: number;\n\t/** Number of distinct reports recorded. */\n\treports: number;\n}\n\n/**\n * Options for {@link AgentSession.runIsolatedCompletion} — an LLM call fully isolated from the main\n * session. With no tools it is one-shot (reflection); lane callers may supply a bounded child loop.\n */\nexport interface IsolatedCompletionOptions {\n\t/** System prompt for the isolated call. */\n\tsystemPrompt: string;\n\t/** The isolated conversation (e.g. the reflection prompt). NOT the main session history. */\n\tmessages: Message[];\n\t/** Model to use. Defaults to the session model; callers should pass a cheap model. */\n\tmodel?: Model<any>;\n\t/** Thinking level. Defaults to \"off\" to keep the call cheap. */\n\tthinkingLevel?: ThinkingLevel;\n\t/** Output token cap. */\n\tmaxTokens?: number;\n\t/** Fresh tools owned by the isolated child. Omitted/empty preserves one-shot behavior. */\n\ttools?: AgentTool[];\n\t/** Maximum assistant turns for a tool-enabled child loop. Ignored by one-shot calls. */\n\tmaxTurns?: number;\n\t/**\n\t * Optional tool-free finalization prompt. When the bounded child loop exhausts its turns on an\n\t * assistant tool-call message with no text, one final provider call receives the gathered transcript\n\t * plus this prompt so useful work is not discarded solely for lacking a terminal summary.\n\t */\n\tfinalTextPrompt?: string;\n\t/** Child-only capability/path gate. Never inherited from the foreground session. */\n\tbeforeToolCall?: AgentLoopConfig[\"beforeToolCall\"];\n\t/** Child-only result observer (for example, successful scoped-write accounting). */\n\tafterToolCall?: AgentLoopConfig[\"afterToolCall\"];\n\t/** Abort signal. */\n\tsignal?: AbortSignal;\n\t/**\n\t * Prompt-cache retention for this isolated call. Defaults to `\"none\"` (no caching — preserves full\n\t * isolation). Callers whose `systemPrompt` is STATIC across calls (e.g. reflection, #33) can pass\n\t * `\"short\"`/`\"long\"` so the provider reuses the cached prefix and bills only the variable tail.\n\t */\n\tcacheRetention?: CacheRetention;\n}\n\n/** Result of an isolated completion: the text, the usage spent, and the stop reason. */\nexport interface IsolatedCompletionResult {\n\ttext: string;\n\tusage: Usage;\n\tstopReason: StopReason;\n}\n\nexport interface ResearchLaneRunOutcome {\n\t/** False when the pass was skipped before starting (see skipReason). */\n\tstarted: boolean;\n\tskipReason?: string;\n\t/** Terminal lane record when the pass ran. */\n\trecord?: LaneRecord;\n\tresult?: ResearchRunResult;\n}\n\nexport interface WorkerDelegationRunOutcome {\n\t/** False when the delegation was skipped before starting (see skipReason). */\n\tstarted: boolean;\n\tskipReason?: string;\n\t/** Terminal lane record when the delegation ran. */\n\trecord?: LaneRecord;\n\toutcome?: WorkerRunOutcome;\n}\n\nexport interface GoalContinuationOnceOptions {\n\tmaxStallTurns: number;\n\tpromptLimits?: GoalContinuationPromptLimits;\n}\n\nexport interface GoalContinuationOnceResult {\n\tsubmitted: boolean;\n\tsnapshot: GoalRuntimeSnapshot;\n\tprompt?: GoalContinuationPrompt;\n}\n\nexport type GoalContinuationLoopStopReason =\n\t| \"continuation_not_allowed\"\n\t| \"max_turns_reached\"\n\t| \"wall_clock_budget_reached\"\n\t| \"goal_state_not_advanced\";\n\nexport interface GoalContinuationLoopOptions extends GoalContinuationOnceOptions {\n\tmaxTurns: number;\n\t/** 0 or undefined disables wall-clock budget. */\n\tmaxWallClockMinutes?: number;\n\t/** Test seam for wall-clock budget enforcement. Defaults to Date.now. */\n\tnow?: () => number;\n}\n\nexport interface GoalContinuationLoopResult {\n\tturnsSubmitted: number;\n\tstopReason: GoalContinuationLoopStopReason;\n\tfinalSnapshot: GoalRuntimeSnapshot;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n// ============================================================================\n// AgentSession Class\n// ============================================================================\n\nexport class AgentSession {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\tpublic capabilityEnvelope?: CapabilityEnvelope;\n\n\tprivate _scopedModels: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\n\t// Event subscription state\n\tprivate _unsubscribeAgent?: () => void;\n\tprivate _eventListeners: AgentSessionEventListener[] = [];\n\tprivate _extensionsChangedListeners: Array<() => void> = [];\n\n\tprivate _steeringMessages: string[] = [];\n\tprivate _followUpMessages: string[] = [];\n\tprivate _queuedExtensionCommands: string[] = [];\n\tprivate _pendingNextTurnMessages: CustomMessage[] = [];\n\tprivate _streamingPromptSubmissionTail: Promise<void> = Promise.resolve();\n\t/**\n\t * The last tool set requested via setActiveToolsByName BEFORE model-capability filtering, so\n\t * switching from a small-window model back to a large one restores the full requested set.\n\t */\n\tprivate _requestedActiveToolNames: string[] | undefined;\n\n\tprivate _compactionAbortController: AbortController | undefined = undefined;\n\tprivate _autoCompactionAbortController: AbortController | undefined = undefined;\n\tprivate _overflowRecoveryAttempted = false;\n\tprivate _unboundToolGrantWarnings: string[] = [];\n\n\tprivate _branchSummaryAbortController: AbortController | undefined = undefined;\n\n\tprivate _retryController!: RetryController;\n\n\tprivate readonly _modelSelection: ModelSelectionController;\n\tprivate readonly _bash: BashExecutionController;\n\tprivate readonly _profileFilter: ProfileFilterController;\n\tprivate readonly _toolGate: ToolGateController;\n\tprivate readonly _toolSelection: ToolSelectionController;\n\n\tprivate _extensionRunner!: ExtensionRunner;\n\tprivate _turnIndex = 0;\n\tprivate _currentForegroundEnvelope?: CapabilityEnvelope;\n\n\tprivate _resourceLoader: ResourceLoader;\n\tprivate _customTools: ToolDefinition[];\n\tprivate _cwd: string;\n\tprivate _agentDir: string;\n\tprivate _collectWorkspaceSources: typeof collectWorkspaceSources;\n\tprivate readonly _localRuntimeController: LocalRuntimeController;\n\tprivate readonly _modelAdaptationStore: ModelAdaptationStore;\n\tprivate _prefixWarmer:\n\t\t| { modelKey: string; controller: AbortController; timer: NodeJS.Timeout | undefined }\n\t\t| undefined;\n\tprivate readonly _completedPrefixWarms = new Set<string>();\n\tprivate readonly _repairModeSessionCounts = new Map<string, number>();\n\tprivate readonly _textProtocolParseFailures = new Map<string, { signature: string; repeats: number }>();\n\tprivate _textProtocolParseObservedThisTurn = false;\n\tprivate _textProtocolValidationOutcomeThisTurn: TextToolProtocolParseEvent | undefined;\n\t/** Assembles the session's base system prompt from live session state (see\n\t * system-prompt-builder.ts); owns the paired _baseSystemPromptOptions. */\n\tprivate readonly _systemPromptBuilder: SystemPromptBuilder;\n\t/** G3/G8 autonomy telemetry sink + status/diagnostic snapshots (see autonomy-telemetry.ts); owns\n\t * the latest gate outcome and the bounded gate-outcome history. */\n\tprivate readonly _autonomyTelemetry: AutonomyTelemetry;\n\t/** Goal auto-continue + research lane + scout-worker delegation + model-fitness probe (see\n\t * background-lane-controller.ts); owns the lane timers/guards, the last research-lane skip\n\t * reason, the live LaneTracker, and the in-flight research/worker abort controllers. */\n\tprivate readonly _backgroundLanes: BackgroundLaneController;\n\t/** Plug-and-play memory subsystem (see memory-controller.ts); owns the OKF retrieval provider, the\n\t * latest retrieval/prompt-inclusion reports, the reload-safe MemoryManager, the recall\n\t * effectiveness tracker, and the extension-contributed pending providers. */\n\tprivate readonly _memory: MemoryController;\n\tprivate readonly _compactionSupport: CompactionSupport;\n\t/** Per-turn context-shaping subsystem (see context-pipeline.ts); owns the latest\n\t * audit/policy/correlation/enforcement/gc reports, the brain-curation sidecar + its skip reasons,\n\t * and the tool-output artifact store. Invoked stage-by-stage from the context transform. */\n\tprivate readonly _pipeline: ContextPipeline;\n\tprivate _extensionRunnerRef?: { current?: ExtensionRunner };\n\tprivate _initialActiveToolNames?: string[];\n\tprivate _allowedToolNames?: Set<string>;\n\tprivate _excludedToolNames?: Set<string>;\n\tprivate _toolProfileFilter?: Required<ResourceProfileFilterSettings>;\n\tprivate readonly _isExplicitModel: boolean;\n\tprivate readonly _isExplicitThinking: boolean;\n\tprivate readonly _gatewayRegistry = new GatewayRegistry();\n\t/** Usage/cost/stats accounting, /context estimate, and session export (see session-analytics.ts);\n\t * owns the spawned-usage and daily-usage memo caches. */\n\tprivate readonly _analytics: SessionAnalytics;\n\tprivate readonly _treeNavigator: SessionTreeNavigator;\n\tprivate _lastCostGuardDecision?: CostGuardDecision;\n\t/** Per-turn model-router subsystem (see model-router-controller.ts); owns the transient route/intent,\n\t * the cheap-turn session buffer, the escalation/retry flags, and the sticky last-decision/skip-reason\n\t * used by the status report. Its parallel routed drive path delegates every turn back to\n\t * {@link _runAgentPrompt} so the drive loop stays host-side. */\n\tprivate readonly _modelRouter: ModelRouterController;\n\tprivate readonly _billingFailover: BillingFailoverController;\n\tprivate readonly _failureCorpus: FailureCorpusRecorder;\n\tprivate readonly _toolRecoveryLogger: ToolRecoveryLogger;\n\tprivate readonly _toolRecoveryEventLogPath: string;\n\tprivate _skillCuratorInstance?: SkillCurator;\n\tprivate _disposed = false;\n\tprivate readonly _reflectionAbort = new AbortController();\n\t/** Native reflection engine + learning-apply/rollback path (see reflection-controller.ts); owns no\n\t * session state, applies durable writes through the bundled memory tool and the session log. */\n\tprivate readonly _reflection: ReflectionController;\n\t/** Bounded goal auto-continuation loop (see goal-loop-controller.ts); reads goal state fresh\n\t * each pass and re-enters the session's own prompt path. */\n\tprivate readonly _goalContinuation: GoalLoopController;\n\tprivate readonly _isChildSession: boolean;\n\tprivate _baseToolsOverride?: Record<string, AgentTool>;\n\tprivate _sessionStartEvent: SessionStartEvent;\n\tprivate _extensionUIContext?: ExtensionUIContext;\n\tprivate _extensionMode: ExtensionContext[\"mode\"] = \"print\";\n\tprivate _extensionCommandContextActions?: ExtensionCommandContextActions;\n\tprivate _extensionAbortHandler?: () => void;\n\tprivate _extensionShutdownHandler?: ShutdownHandler;\n\tprivate _extensionErrorListener?: ExtensionErrorListener;\n\tprivate _extensionErrorUnsubscriber?: () => void;\n\n\tprivate _modelRegistry: ModelRegistry;\n\n\t/** Tool-registry assembly + the self-modification-safe extension reload (see runtime-builder.ts);\n\t * owns the base/wrapped tool definitions, the live tool registry, and the per-tool prompt\n\t * snippet/guideline maps. The reload snapshot spans host/agent state reached through its deps. */\n\tprivate readonly _runtimeBuilder: RuntimeBuilder;\n\n\t// Base system prompt (without extension appends) - used to apply fresh appends each turn.\n\t// The paired _baseSystemPromptOptions and their construction live in SystemPromptBuilder.\n\tprivate _baseSystemPrompt = \"\";\n\n\tconstructor(config: AgentSessionConfig) {\n\t\tthis.agent = config.agent;\n\t\t// Bound every provider stream this session starts against a silently dead connection: a\n\t\t// stall aborts the inner request and surfaces as a retryable \"stream stalled\" error, which\n\t\t// _isRetryableError routes into the existing auto-retry path. Wrapped exactly once, here.\n\t\t// The wrapper reports the stall immediately and aborts the inner request; releasing the\n\t\t// inner pump relies on the provider ending its stream after abort (real providers do — see\n\t\t// withStreamIdleWatchdog's contract), so no extra drain is added at this wiring site.\n\t\t// Wrapping also breaks the `streamFn === streamSimple` identity the auth-injection checks\n\t\t// use, so the wrapper carries a rawness marker that _isRawStreamSimple reads.\n\t\tconst agentDir = config.agentDir ?? getAgentDir();\n\t\tconst modelAdaptationStore = ModelAdaptationStore.forAgentDir(agentDir);\n\t\tconst baseStreamFn = this.agent.streamFn;\n\t\tconst previousResolveRequestReasoning = this.agent.resolveRequestReasoning?.bind(this.agent);\n\t\tthis.agent.resolveRequestReasoning = (reasoning, request) => {\n\t\t\tconst resolvedReasoning = previousResolveRequestReasoning\n\t\t\t\t? previousResolveRequestReasoning(reasoning, request)\n\t\t\t\t: reasoning;\n\t\t\treturn this._resolveCostGuardRequestReasoning(\n\t\t\t\trequest.model,\n\t\t\t\trequest.context,\n\t\t\t\tresolvedReasoning,\n\t\t\t\trequest.maxTokens,\n\t\t\t);\n\t\t};\n\t\tconst profiledStreamFn = withModelPerfProfile(baseStreamFn, {\n\t\t\tmodelKey: (model) => formatModelRouterModel(model),\n\t\t\trecordSample: (modelKey, sample) => {\n\t\t\t\tmodelAdaptationStore.recordPerfSample(modelKey, sample);\n\t\t\t},\n\t\t});\n\t\t// `this.settingsManager` is assigned below; the resolver closes over the config reference\n\t\t// because the wrapper must be installed before that assignment runs.\n\t\tconst stallSettingsSource = config.settingsManager;\n\t\tthis.agent.streamFn = tagRawness(\n\t\t\twithStreamIdleWatchdog(profiledStreamFn, (model, context) => {\n\t\t\t\tconst configured = {\n\t\t\t\t\t...stallSettingsSource.getStreamStallSettings(),\n\t\t\t\t\t...streamIdleOptionsOverride,\n\t\t\t\t};\n\t\t\t\tconst httpIdleTimeoutMs = stallSettingsSource.getHttpIdleTimeoutMs();\n\t\t\t\tconst httpBounded = constrainStreamIdleToHttpTimeout(\n\t\t\t\t\t{ ...DEFAULT_STREAM_IDLE, ...configured },\n\t\t\t\t\thttpIdleTimeoutMs,\n\t\t\t\t);\n\t\t\t\tconst profile = modelAdaptationStore.get(formatModelRouterModel(model)).perf;\n\t\t\t\tconst adaptive = resolveAdaptiveStreamIdleOptions({\n\t\t\t\t\tbase: httpBounded.options,\n\t\t\t\t\tprofile,\n\t\t\t\t\tpromptTokens: estimateContextPromptTokens(context),\n\t\t\t\t\tlocalClass: this._isWarmableLocalModel(model),\n\t\t\t\t\tceilingMs: httpBounded.adaptiveCeilingMs ?? DEFAULT_ADAPTIVE_STREAM_IDLE_CEILING_MS,\n\t\t\t\t});\n\t\t\t\treturn { ...httpBounded.options, ...adaptive };\n\t\t\t}),\n\t\t\tbaseStreamFn === streamSimple,\n\t\t);\n\t\tthis.sessionManager = config.sessionManager;\n\t\tthis.settingsManager = config.settingsManager;\n\t\t// Auto-retry rides the reliability kernel: the controller owns the attempt counter and the\n\t\t// abortable backoff. This session maps its retry settings onto a RetryPolicy, bridges the\n\t\t// controller's events onto the session event stream, and supplies the live context window so\n\t\t// the overflow-aware classifier can route overflow to compaction instead of a pointless retry.\n\t\tthis._retryController = new RetryController(\n\t\t\tthis.agent,\n\t\t\t() => {\n\t\t\t\tconst retry = this.settingsManager.getRetrySettings();\n\t\t\t\treturn {\n\t\t\t\t\tenabled: retry.enabled,\n\t\t\t\t\tmaxAttempts: retry.maxRetries,\n\t\t\t\t\tbaseDelayMs: retry.baseDelayMs,\n\t\t\t\t\tmaxDelayMs: DEFAULT_RETRY_POLICY.maxDelayMs,\n\t\t\t\t\tjitterRatio: 0,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{\n\t\t\t\tonRetryStart: (info) => this._emit({ type: \"auto_retry_start\", ...info }),\n\t\t\t\tonRetryEnd: (info) => this._emit({ type: \"auto_retry_end\", ...info }),\n\t\t\t},\n\t\t\t() => this.model?.contextWindow ?? 0,\n\t\t);\n\t\tthis._scopedModels = config.scopedModels ?? [];\n\t\tthis._resourceLoader = config.resourceLoader;\n\t\tthis._customTools = config.customTools ?? [];\n\t\tthis._cwd = config.cwd;\n\t\tthis._agentDir = agentDir;\n\t\tthis._modelAdaptationStore = modelAdaptationStore;\n\t\tthis.agent.onTextToolProtocolParse = (event) => this._handleTextToolProtocolParse(event);\n\t\tthis._applyToolRepairLayerSettings();\n\t\tthis._collectWorkspaceSources = config.collectWorkspaceSources ?? collectWorkspaceSources;\n\t\tthis._localRuntimeController = new LocalRuntimeController({\n\t\t\tagentDir: this._agentDir,\n\t\t\tlocalRuntimeDeps: config.localRuntimeDeps,\n\t\t\tgetLastAssistantMessage: () => this._findLastAssistantMessage(),\n\t\t\tgetUIContext: () => this._extensionUIContext,\n\t\t\temit: (event) => this._emit(event),\n\t\t\tresolveConfiguredTierModel: (tier) => this._modelRouter.resolveConfiguredTierModel(tier),\n\t\t\tformatModel: (model) => formatModelRouterModel(model),\n\t\t});\n\t\tthis._systemPromptBuilder = new SystemPromptBuilder({\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetResourceLoader: () => this._resourceLoader,\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\thasTool: (name) => this._runtimeBuilder.hasTool(name),\n\t\t\tgetToolPromptSnippet: (name) => this._runtimeBuilder.getToolPromptSnippet(name),\n\t\t\tgetToolPromptGuidelines: (name) => this._runtimeBuilder.getToolPromptGuidelines(name),\n\t\t\tgetModelAdaptationRules: () => this._getModelAdaptationRulesForPrompt(),\n\t\t\tgetActiveExtensions: () => this._extensionRunner.activeExtensions,\n\t\t\tgetContextWindow: () => this.model?.contextWindow,\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t});\n\t\tthis._autonomyTelemetry = new AutonomyTelemetry({\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetLastModelRouterDecision: () => this._modelRouter.getLastDecision(),\n\t\t\tgetLastResearchLaneSkipReason: () => this._backgroundLanes.getLastResearchLaneSkipReason(),\n\t\t\tgetCostSummary: () => this.getCostSummary(),\n\t\t\tgetGoalStateSnapshot: () => this.getGoalStateSnapshot(),\n\t\t\tgetActiveLaneCount: () => this._backgroundLanes.getActiveLaneCount(),\n\t\t\tgetEvidenceBundleSnapshots: () => this.getEvidenceBundleSnapshots(),\n\t\t\tgetWorkerResultSnapshots: () => this.getWorkerResultSnapshots(),\n\t\t\tgetLearningDecisionSnapshots: () => this.getLearningDecisionSnapshots(),\n\t\t\tgetLearningAuditRecords: () => this.getLearningAuditRecords(),\n\t\t});\n\t\tthis._modelRegistry = config.modelRegistry;\n\t\tthis._backgroundLanes = new BackgroundLaneController({\n\t\t\tisDisposed: () => this._disposed,\n\t\t\tisChildSession: () => this._isChildSession,\n\t\t\tgetSessionId: () => this.sessionId,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisModelExhausted: (model) => this._billingFailover.isExhausted(`${model.provider}/${model.id}`),\n\t\t\tgetModel: () => this.model ?? undefined,\n\t\t\tisDelegateToolActive: () => this.getActiveToolNames().includes(\"delegate\"),\n\t\t\tgetCapabilityEnvelope: () => this.capabilityEnvelope,\n\t\t\tgetModelCapabilityProfile: () => this.getModelCapabilityProfile(),\n\t\t\temit: (event) => this._emit(event),\n\t\t\tnotifyWorkerTerminalHandoff: (records) => this._notifyWorkerTerminalHandoff(records),\n\t\t\temitAutonomyTelemetry: (event) => this._emitAutonomyTelemetry(event),\n\t\t\tgetGoalStateSnapshot: () => this.getGoalStateSnapshot(),\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getGoalRuntimeSnapshot(settings),\n\t\t\tgetEvidenceBundleSnapshot: () => this.getEvidenceBundleSnapshot(),\n\t\t\tsaveEvidenceBundleSnapshot: (bundle) => this.saveEvidenceBundleSnapshot(bundle),\n\t\t\tsaveWorkerResultSnapshot: (result, request) => this.saveWorkerResultSnapshot(result, request),\n\t\t\treadMemoryForLane: (query) => this._memory.readMemoryForLane(query),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t\tcontinueGoalLoop: (options) => this.continueGoalLoop(options),\n\t\t\tcollectWorkspaceSources: (args) => this._collectWorkspaceSources(args),\n\t\t});\n\t\tthis._memory = new MemoryController({\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetTurnIndex: () => this._turnIndex,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetSessionId: () => this.sessionManager.getSessionId(),\n\t\t\tisChildSession: () => this._isChildSession,\n\t\t\trefreshToolRegistry: () => this._refreshToolRegistry(),\n\t\t\tgetContextWindow: () => this.model?.contextWindow,\n\t\t\tgetGoalState: () => this.getGoalStateSnapshot(),\n\t\t});\n\t\tthis._compactionSupport = new CompactionSupport({\n\t\t\tgetModel: () => this.model,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisRawStream: () => this._isRawStreamSimple(this.agent.streamFn),\n\t\t\tgetRequiredRequestAuth: (model) => this._getRequiredRequestAuth(model),\n\t\t\tisModelExhausted: (ref) => this._billingFailover.isExhausted(ref),\n\t\t\tgetStoredFitnessReport: (ref) => this.getStoredFitnessReports().find((entry) => entry.model === ref)?.report,\n\t\t\t// Live context is an over-estimate of the span to summarize (includes the kept tail) —\n\t\t\t// conservative in the safe direction for the summarizer capacity check.\n\t\t\testimateSummarizationInputTokens: () => this._pipeline.estimateCurrentContextTokens(this.agent.state.messages),\n\t\t\temitWarning: (message) => this._emit({ type: \"warning\", message }),\n\t\t});\n\t\tthis._pipeline = new ContextPipeline({\n\t\t\tgetTurnIndex: () => this._turnIndex,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetActiveToolNames: () => this.getActiveToolNames(),\n\t\t\tisDisposed: () => this._disposed,\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t});\n\t\tconst failureCorpusPath = join(this._agentDir, \"state\", \"failure-corpus.jsonl\");\n\t\tthis._toolRecoveryEventLogPath = join(this._agentDir, \"state\", TOOL_RECOVERY_EVENT_LOG_FILE);\n\t\tconst toolRepairSettings = this._toolRepairSettings();\n\t\tthis._failureCorpus = new FailureCorpusRecorder({\n\t\t\tfilePath: failureCorpusPath,\n\t\t});\n\t\tthis._toolRecoveryLogger = new ToolRecoveryLogger({\n\t\t\tenabled: toolRepairSettings.logging,\n\t\t\tsessionId: this.sessionManager.getSessionId(),\n\t\t\teventLogPath: this._toolRecoveryEventLogPath,\n\t\t\tfailureCorpusPath,\n\t\t});\n\t\tthis._billingFailover = new BillingFailoverController({\n\t\t\tagent: this.agent,\n\t\t\tmodelRegistry: this._modelRegistry,\n\t\t\texhausted: new ExhaustedProviderRegistry(),\n\t\t\tsubscriptionHop: this.settingsManager.getFailoverSettings().subscriptionHop,\n\t\t\temit: (event) => this._emit(event),\n\t\t\trecordFailure: (args) => this._failureCorpus.record(args),\n\t\t});\n\t\tthis._modelRouter = new ModelRouterController({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetModel: () => this.model ?? undefined,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisModelExhausted: (model) => this._billingFailover.isExhausted(`${model.provider}/${model.id}`),\n\t\t\tgetFailoverStatus: () => ({ ...this._billingFailover.getStatus(), failureStats: this._failureCorpus.stats() }),\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetReflectionSignal: () => this._reflectionAbort.signal,\n\t\t\tgetBaseSystemPrompt: () => this._baseSystemPrompt,\n\t\t\trunAgentPrompt: (messages) => this._runAgentPrompt(messages),\n\t\t\tbuildSystemPromptForToolNames: (toolNames) => this._buildSystemPromptForToolNames(toolNames),\n\t\t\trefreshCurrentModelFromRegistry: () => this._refreshCurrentModelFromRegistry(),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\temit: (event) => this._emit(event),\n\t\t\temitAutonomyTelemetry: (event) => this._emitAutonomyTelemetry(event),\n\t\t\tresolveLaneModel: (pattern) => this._backgroundLanes.resolveLaneModel(pattern),\n\t\t\tresolveCurationModelIfFit: () => this._resolveCurationModelIfFit(),\n\t\t});\n\t\tthis._reflection = new ReflectionController({\n\t\t\tgetModel: () => this.model,\n\t\t\tgetAgent: () => this.agent,\n\t\t\tisRawStreamSimple: () => this._isRawStreamSimple(this.agent.streamFn),\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tisChildSession: () => this._isChildSession,\n\t\t\tisDisposed: () => this._disposed,\n\t\t\tgetReflectionSignal: () => this._reflectionAbort.signal,\n\t\t\tresolveTextToolCallProtocol: (model) => this._textProtocolFlag(model),\n\t\t\tarchivePromotedSkill: (name) => this.archivePromotedSkill(name),\n\t\t\temitAutonomyTelemetry: (event) => this._emitAutonomyTelemetry(event),\n\t\t\tensureModelReady: (model) => this._localRuntimeController.ensureIsolatedModelReady(model),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\tsaveLearningDecisionSnapshot: (decision) => this.saveLearningDecisionSnapshot(decision),\n\t\t});\n\t\tthis._goalContinuation = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getGoalRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.prompt(text, options),\n\t\t});\n\t\tthis._extensionRunnerRef = config.extensionRunnerRef;\n\t\tthis._initialActiveToolNames = config.initialActiveToolNames;\n\t\tthis._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;\n\t\tthis._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;\n\t\tthis._toolProfileFilter = config.toolProfileFilter\n\t\t\t? { allow: config.toolProfileFilter.allow ?? [], block: config.toolProfileFilter.block ?? [] }\n\t\t\t: undefined;\n\t\tthis._isExplicitModel = config.isExplicitModel ?? false;\n\t\tthis._isExplicitThinking = config.isExplicitThinking ?? false;\n\t\tthis._isChildSession = config.isChildSession ?? process.env.PI_CHILD_SESSION === \"1\";\n\t\tthis._baseToolsOverride = config.baseToolsOverride;\n\t\tthis._sessionStartEvent = config.sessionStartEvent ?? { type: \"session_start\", reason: \"startup\" };\n\t\tthis._runtimeBuilder = new RuntimeBuilder({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tisModelExhausted: (model) => this._billingFailover.isExhausted(`${model.provider}/${model.id}`),\n\t\t\tgetResourceLoader: () => this._resourceLoader,\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tsetExtensionRunner: (runner) => {\n\t\t\t\tthis._extensionRunner = runner;\n\t\t\t\tif (this._extensionRunnerRef) {\n\t\t\t\t\tthis._extensionRunnerRef.current = runner;\n\t\t\t\t}\n\t\t\t},\n\t\t\tgetBaseSystemPrompt: () => this._baseSystemPrompt,\n\t\t\tsetBaseSystemPrompt: (prompt) => {\n\t\t\t\tthis._baseSystemPrompt = prompt;\n\t\t\t},\n\t\t\tgetCustomTools: () => this._customTools,\n\t\t\tgetBaseToolsOverride: () => this._baseToolsOverride,\n\t\t\tgetRequestedActiveToolNames: () => this._requestedActiveToolNames,\n\t\t\tsetRequestedActiveToolNames: (names) => {\n\t\t\t\tthis._requestedActiveToolNames = names;\n\t\t\t},\n\t\t\tgetToolProfileFilter: () => this._toolProfileFilter,\n\t\t\tsetToolProfileFilter: (filter) => {\n\t\t\t\tthis._toolProfileFilter = filter;\n\t\t\t},\n\t\t\tgetAllowedToolNames: () => this._allowedToolNames,\n\t\t\tgetExcludedToolNames: () => this._excludedToolNames,\n\t\t\tderiveToolProfileFilter: () => this._profileFilter.deriveToolProfileFilter(),\n\t\t\tisToolOrCommandAllowedByProfile: (name) => this._profileFilter.isToolOrCommandAllowedByProfile(name),\n\t\t\tfilterExtensionsForRuntime: (extensions) => this._profileFilter.filterExtensionsForRuntime(extensions),\n\t\t\tsetUnboundToolGrantWarnings: (warnings) => {\n\t\t\t\tthis._unboundToolGrantWarnings = warnings;\n\t\t\t},\n\t\t\tgetUnboundToolGrantWarnings: () => this._unboundToolGrantWarnings,\n\t\t\tcreateProfileFilterReloadSnapshot: () => this._profileFilter.createReloadSnapshot(),\n\t\t\trestoreProfileFilterReloadSnapshot: (snapshot) => this._profileFilter.restoreReloadSnapshot(snapshot),\n\t\t\tgetActiveToolNames: () => this.getActiveToolNames(),\n\t\t\tsetActiveToolsByName: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\tnormalizePromptSnippet: (text) => this._normalizePromptSnippet(text),\n\t\t\tnormalizePromptGuidelines: (guidelines) => this._normalizePromptGuidelines(guidelines),\n\t\t\tbindExtensionCore: (runner) => this._bindExtensionCore(runner),\n\t\t\tapplyExtensionBindings: (runner) => this._applyExtensionBindings(runner),\n\t\t\textendResourcesFromExtensions: (reason) => this.extendResourcesFromExtensions(reason),\n\t\t\treapplyActiveProfileModelSettings: () => this._profileFilter.reapplyActiveProfileModelSettings(),\n\t\t\tnotifyExtensionsChanged: () => this._notifyExtensionsChanged(),\n\t\t\tgetToolArtifactStore: () => this._getToolArtifactStore(),\n\t\t\tgetMemoryManager: () => this._memory.getMemoryManager(),\n\t\t\tgetMemoryAuditDiagnostics: () => this._memory.getMemoryAuditDiagnostics(),\n\t\t\tclearPendingMemoryProviders: () => this._memory.clearPendingProviders(),\n\t\t\tcreateMemoryReloadSnapshot: () => this._memory.createReloadSnapshot(),\n\t\t\trestoreMemoryReloadSnapshot: (snapshot) => this._memory.restoreReloadSnapshot(snapshot),\n\t\t\tinitializeMemory: () => this._memory.initialize(),\n\t\t\tgetGoalStateSnapshot: () => this.getGoalStateSnapshot(),\n\t\t\tsaveGoalStateSnapshot: (state) => this.saveGoalStateSnapshot(state),\n\t\t\tgetTaskStepsStateSnapshot: () => this.getTaskStepsStateSnapshot(),\n\t\t\tsaveTaskStepsStateSnapshot: (state) => this.saveTaskStepsStateSnapshot(state),\n\t\t\tgetContextGcReport: (messages) => this.getContextGcReport(messages),\n\t\t\tstartWorkerDelegation: (request) => this._backgroundLanes.startWorkerDelegation(request),\n\t\t\tgetWorkerLaneRecords: () => this._backgroundLanes.getLaneRecords(),\n\t\t\tgetWorkerResultSnapshots: () => this.getWorkerResultSnapshots(),\n\t\t\trunWorkerDelegationOnce: (request) => this.runWorkerDelegationOnce(request),\n\t\t\trunModelFitness: (args) => this.runModelFitness(args),\n\t\t\tresolveCurationModelIfFit: () => this._resolveCurationModelIfFit(),\n\t\t\trunIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),\n\t\t\taddSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),\n\t\t\tcreateAgentContextSnapshot: () => this._createAgentContextSnapshot(),\n\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\tisStreaming: () => this.isStreaming,\n\t\t\tisCompacting: () => this.isCompacting,\n\t\t\tgetExtensionUIContext: () => this._extensionUIContext,\n\t\t\tgetExtensionCommandContextActions: () => this._extensionCommandContextActions,\n\t\t\tgetExtensionShutdownHandler: () => this._extensionShutdownHandler,\n\t\t\tgetExtensionErrorListener: () => this._extensionErrorListener,\n\t\t});\n\t\tthis._analytics = new SessionAnalytics({\n\t\t\tgetState: () => this.state,\n\t\t\tgetMessages: () => this.messages,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetToolDefinition: (name) => this.getToolDefinition(name),\n\t\t\tgetToolRecoveryEventLogPath: () => this._toolRecoveryEventLogPath,\n\t\t});\n\t\tconst previousToolArgumentValidation = this.agent.onToolArgumentValidation;\n\t\tthis.agent.onToolArgumentValidation = (event) => {\n\t\t\tconst taggedEvent = this._tagModelAdaptationRuleTeaching(event);\n\t\t\tif (taggedEvent.outcome === \"repaired\" || taggedEvent.outcome === \"bounced\") {\n\t\t\t\tthis._toolSelection.recordValidation(taggedEvent.tool, taggedEvent.outcome);\n\t\t\t}\n\t\t\tpreviousToolArgumentValidation?.(taggedEvent);\n\t\t\tconst logRecord = this._toolRecoveryLogger.recordToolArgumentValidation(taggedEvent);\n\t\t\tif (!logRecord) return;\n\t\t\tthis._analytics.recordToolArgumentValidation(logRecord);\n\t\t\tthis._handleTextToolProtocolValidationOutcome(taggedEvent);\n\t\t\tthis._handleModelAdaptationTelemetry(taggedEvent);\n\t\t};\n\t\tthis._treeNavigator = new SessionTreeNavigator({\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tgetRequiredRequestAuth: (model) => this._getRequiredRequestAuth(model),\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetAgent: () => this.agent,\n\t\t\tsetBranchSummaryAbort: (controller) => {\n\t\t\t\tthis._branchSummaryAbortController = controller;\n\t\t\t},\n\t\t});\n\t\tthis._modelSelection = new ModelSelectionController({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetModel: () => this.model,\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tgetAgentDir: () => this._agentDir,\n\t\t\tgetScopedModels: () => this._scopedModels,\n\t\t\tgetRequestedActiveToolNames: () => this._requestedActiveToolNames,\n\t\t\tgetActiveToolNames: () => this.getActiveToolNames(),\n\t\t\tsetActiveToolsByName: (names) => this.setActiveToolsByName(names),\n\t\t\tgetModelCapabilityProfile: () => this.getModelCapabilityProfile(),\n\t\t\trefreshBaseSystemPrompt: () => this._refreshBaseSystemPrompt(),\n\t\t\temit: (event) => this._emit(event),\n\t\t\tcheckContextWindowUsageWarning: () => this._checkContextWindowUsageWarning(),\n\t\t\tderiveOllamaServerUrl: (baseUrl) => this._deriveOllamaServerUrl(baseUrl),\n\t\t\tgetLocalRuntime: (serverUrl) => this.getLocalRuntime(serverUrl),\n\t\t});\n\t\tthis._bash = new BashExecutionController({\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tisStreaming: () => this.isStreaming,\n\t\t});\n\t\tthis._profileFilter = new ProfileFilterController({\n\t\t\tgetSettingsManager: () => this.settingsManager,\n\t\t\tgetResourceLoader: () => this._resourceLoader,\n\t\t\tgetModelRegistry: () => this._modelRegistry,\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetAgent: () => this.agent,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetAllowedToolNames: () => this._allowedToolNames,\n\t\t\tgetExcludedToolNames: () => this._excludedToolNames,\n\t\t\tgetToolProfileFilter: () => this._toolProfileFilter,\n\t\t\tisExplicitModel: () => this._isExplicitModel,\n\t\t\tisExplicitThinking: () => this._isExplicitThinking,\n\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level, { persistSettings: false }),\n\t\t});\n\t\tthis._toolSelection = new ToolSelectionController({\n\t\t\tstore: ToolPerformanceStore.forAgentDir(this._agentDir),\n\t\t\tgetModelRef: () => {\n\t\t\t\tconst model = this.model;\n\t\t\t\treturn model ? formatModelRouterModel(model) : \"unknown\";\n\t\t\t},\n\t\t\tgetActiveTools: () => {\n\t\t\t\tconst activeNames = new Set(this.getActiveToolNames());\n\t\t\t\treturn this.getAllTools()\n\t\t\t\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t\t\t\t.map((tool) => ({\n\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\t}));\n\t\t\t},\n\t\t\tisCandidateAllowed: (toolName) => {\n\t\t\t\tconst envelope = this.capabilityEnvelope;\n\t\t\t\tif (!envelope) return true;\n\t\t\t\treturn (\n\t\t\t\t\tevaluateToolGate({\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\targs: {},\n\t\t\t\t\t\tcwd: this._cwd,\n\t\t\t\t\t\tenvelope,\n\t\t\t\t\t}).outcome === \"allow\"\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\t\tthis._toolGate = new ToolGateController({\n\t\t\tmaybeEscalateToolCall: (toolName, args) => this._modelRouter.maybeEscalateToolCall(toolName, args),\n\t\t\tgetCwd: () => this._cwd,\n\t\t\tgetCapabilityEnvelope: () => this.capabilityEnvelope,\n\t\t\trecordGateOutcome: (outcome) => this._recordGateOutcome(outcome),\n\t\t\tgetExtensionRunner: () => this._extensionRunner,\n\t\t\tgetToolSelectionController: () => this._toolSelection,\n\t\t});\n\n\t\t// Always subscribe to agent events for internal handling\n\t\t// (session persistence, extensions, auto-compaction, retry logic)\n\t\tthis._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);\n\t\tthis._installAgentToolHooks();\n\t\tthis._installAgentContextTransform();\n\t\tthis._installAgentTurnRefresh();\n\n\t\tthis._runtimeBuilder.buildRuntime({\n\t\t\tactiveToolNames: this._initialActiveToolNames,\n\t\t\tincludeAllExtensionTools: true,\n\t\t});\n\t\tthis._scheduleLocalPrefixWarm(this.agent.state.model, \"session-start\");\n\t}\n\n\t/** Model registry for API key resolution and model discovery */\n\tget modelRegistry(): ModelRegistry {\n\t\treturn this._modelRegistry;\n\t}\n\n\tprivate _scheduleLocalPrefixWarm(model: Model<any> | undefined, _reason: \"session-start\" | \"selection\"): void {\n\t\tif (!model || !this._isWarmableLocalModel(model)) return;\n\t\tconst modelKey = formatModelRouterModel(model);\n\t\tif (this._completedPrefixWarms.has(modelKey) || this._prefixWarmer?.modelKey === modelKey) return;\n\t\tthis._cancelPrefixWarm();\n\t\tconst controller = new AbortController();\n\t\tconst timer = setTimeout(() => {\n\t\t\tconst warmer = this._prefixWarmer;\n\t\t\tif (!warmer || warmer.controller !== controller || controller.signal.aborted) return;\n\t\t\twarmer.timer = undefined;\n\t\t\tvoid this._runLocalPrefixWarm(model, modelKey, controller);\n\t\t}, 0);\n\t\ttimer.unref?.();\n\t\tthis._prefixWarmer = { modelKey, controller, timer };\n\t}\n\n\tprivate _cancelPrefixWarm(): void {\n\t\tconst warmer = this._prefixWarmer;\n\t\tif (!warmer) return;\n\t\tif (warmer.timer) clearTimeout(warmer.timer);\n\t\twarmer.controller.abort(new Error(\"prefix warmer preempted\"));\n\t\tthis._prefixWarmer = undefined;\n\t}\n\n\tprivate async _runLocalPrefixWarm(model: Model<any>, modelKey: string, controller: AbortController): Promise<void> {\n\t\ttry {\n\t\t\tconst options: SimpleStreamOptions = {\n\t\t\t\tmaxTokens: 1,\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tonPayload: this.agent.onPayload,\n\t\t\t\tonResponse: this.agent.onResponse,\n\t\t\t};\n\t\t\tif (this._isRawStreamSimple(this.agent.streamFn)) {\n\t\t\t\tconst auth = await this._getRequiredRequestAuth(model);\n\t\t\t\toptions.apiKey = auth.apiKey;\n\t\t\t\toptions.headers = auth.headers;\n\t\t\t}\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tif (model.provider === OLLAMA_PROVIDER || model.provider === HF_TRANSFORMERS_PROVIDER) {\n\t\t\t\tawait this._localRuntimeController.ensureIsolatedModelReady(model);\n\t\t\t}\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tconst stream = await this.agent.streamFn(\n\t\t\t\tmodel,\n\t\t\t\t{\n\t\t\t\t\tsystemPrompt: this._baseSystemPrompt,\n\t\t\t\t\ttools: this.agent.state.tools,\n\t\t\t\t\tmessages: [],\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tawait stream.result();\n\t\t\tif (!controller.signal.aborted) this._completedPrefixWarms.add(modelKey);\n\t\t} catch {\n\t\t\t// Best-effort cache warm only; a miss must never affect the real turn.\n\t\t} finally {\n\t\t\tif (this._prefixWarmer?.controller === controller) this._prefixWarmer = undefined;\n\t\t}\n\t}\n\n\tprivate _isWarmableLocalModel(model: Model<any>): boolean {\n\t\tif (model.api !== \"openai-completions\") return false;\n\t\ttry {\n\t\t\tconst hostname = new URL(model.baseUrl).hostname.toLowerCase();\n\t\t\treturn hostname === \"localhost\" || hostname === \"127.0.0.1\" || hostname === \"::1\" || hostname === \"[::1]\";\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * True when the session's stream fn is the raw `streamSimple` provider entry (directly, or as the\n\t * base wrapped by the idle watchdog at construction). Callers use this to decide whether request\n\t * auth must be injected explicitly — see {@link RAW_STREAM_MARKER}.\n\t */\n\tprivate _isRawStreamSimple(fn: StreamFn): boolean {\n\t\treturn fn === streamSimple || (fn as { [RAW_STREAM_MARKER]?: boolean })[RAW_STREAM_MARKER] === true;\n\t}\n\n\tprivate async _getRequiredRequestAuth(model: Model<any>): Promise<{\n\t\tapiKey: string;\n\t\theaders?: Record<string, string>;\n\t}> {\n\t\tconst result = await this._modelRegistry.getApiKeyAndHeaders(model);\n\t\tif (!result.ok) {\n\t\t\tif (result.error.startsWith(\"No API key found\")) {\n\t\t\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t\t\t}\n\t\t\tthrow new Error(result.error);\n\t\t}\n\t\tif (result.apiKey) {\n\t\t\treturn { apiKey: result.apiKey, headers: result.headers };\n\t\t}\n\n\t\tconst isOAuth = this._modelRegistry.isUsingOAuth(model);\n\t\tif (isOAuth) {\n\t\t\tthrow new Error(\n\t\t\t\t`Authentication failed for \"${model.provider}\". ` +\n\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t`Run '/login ${model.provider}' to re-authenticate.`,\n\t\t\t);\n\t\t}\n\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t}\n\n\t// Summarizer model/thinking selection, request auth (with session-model fallback), and\n\t// window-adapted settings live in CompactionSupport (see compaction-support.ts).\n\tprivate _getCompactionRequestAuth(model: Model<any>): Promise<{\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string>;\n\t}> {\n\t\treturn this._compactionSupport.getRequestAuth(model);\n\t}\n\n\tprivate _resolveCompactionModelAndAuth(\n\t\tcompactionModel: Model<any>,\n\t\tsessionModel: Model<any>,\n\t): Promise<{ model: Model<any>; apiKey?: string; headers?: Record<string, string>; failure?: string }> {\n\t\treturn this._compactionSupport.resolveModelAndAuth(compactionModel, sessionModel);\n\t}\n\n\tprivate _resolveCompactionModel(sessionModel: Model<any>): Model<any> {\n\t\treturn this._compactionSupport.resolveModel(sessionModel);\n\t}\n\n\t/**\n\t * One bounded diagnostic clause for compaction retry warnings: which summarizer selection won\n\t * (and why) plus the input-size estimate the capacity check consumed — the two facts every\n\t * gate-failure post-mortem has needed (2026-07-06 field incidents).\n\t */\n\tprivate _describeCompactionSummarizer(): string {\n\t\tconst reason = this._compactionSupport.getLastSelectionReason() ?? \"unresolved\";\n\t\tconst estimate = this._pipeline.estimateCurrentContextTokens(this.agent.state.messages);\n\t\treturn `summarizer: ${reason}, ~${Math.ceil(estimate / 1000)}k est input`;\n\t}\n\n\tprivate _getLastCompactionSelectionReason(): string | undefined {\n\t\treturn this._compactionSupport.getLastSelectionReason();\n\t}\n\n\tprivate _resolveCompactionThinkingLevel(\n\t\tcompactionModel: Model<any>,\n\t\tsessionModel: Model<any>,\n\t): ThinkingLevel | undefined {\n\t\treturn this._compactionSupport.resolveThinkingLevel(this.thinkingLevel, compactionModel, sessionModel);\n\t}\n\n\t/**\n\t * Install tool hooks once on the Agent instance.\n\t *\n\t * The callbacks read `this._extensionRunner` at execution time, so extension reload swaps in the\n\t * new runner without reinstalling hooks. Extension-specific tool wrappers are still used to adapt\n\t * registered tool execution to the extension context. Tool call and tool result interception now\n\t * happens here instead of in wrappers.\n\t */\n\tprivate _installAgentContextTransform(): void {\n\t\tconst previousTransformContext = this.agent.transformContext?.bind(this.agent);\n\t\tthis.agent.transformContext = async (messages, signal) => {\n\t\t\tconst transformed = previousTransformContext ? await previousTransformContext(messages, signal) : messages;\n\t\t\tconst authoritativeMessages = this.agent.state.messages.length > 0 ? this.agent.state.messages : transformed;\n\t\t\tlet currentMessages = authoritativeMessages;\n\t\t\ttry {\n\t\t\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\t\t\tconst contextWindow = this.model?.contextWindow ?? 0;\n\t\t\t\tif (settings.enabled && contextWindow > 0 && !this.isCompacting) {\n\t\t\t\t\tconst contextTokens = this._estimateCurrentContextTokens(authoritativeMessages);\n\t\t\t\t\tif (shouldCompact(contextTokens, contextWindow, settings, this.model?.autoCompactionTriggerTokens)) {\n\t\t\t\t\t\tconst latestBefore = getLatestCompactionEntry(this.sessionManager.getBranch())?.id;\n\t\t\t\t\t\tawait this._runAutoCompaction(\"threshold\", false);\n\t\t\t\t\t\tconst latestAfter = getLatestCompactionEntry(this.sessionManager.getBranch())?.id;\n\t\t\t\t\t\tif (latestAfter && latestAfter !== latestBefore) {\n\t\t\t\t\t\t\tcurrentMessages = this.agent.state.messages.slice();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tcurrentMessages = authoritativeMessages;\n\t\t\t}\n\n\t\t\tlet finalMessages = currentMessages;\n\t\t\tif (this._extensionRunner.hasHandlers(\"context\")) {\n\t\t\t\tfinalMessages = await this._extensionRunner.emitContext(currentMessages);\n\t\t\t}\n\t\t\tconst auditReport = this._runContextAudit(finalMessages);\n\t\t\tconst shadowReport = this._runPromptPolicyPlanning(auditReport);\n\t\t\tconst memoryReport = await this._runMemoryRetrieval(finalMessages);\n\t\t\tconst gcResult = this._applyContextGc(finalMessages, true);\n\t\t\tthis._correlatePromptPolicyWithContextGc(gcResult.report);\n\t\t\tconst enforcementResult = this._runPromptEnforcement(gcResult.messages, shadowReport);\n\t\t\tthis._enqueueRelevanceCuration(gcResult.messages, shadowReport);\n\t\t\t// Fire-and-forget: the local curator overlaps the frontier call; it never blocks a turn.\n\t\t\tthis._maybeDrainBrainCuration();\n\t\t\t// Appended LAST, after gc and enforcement, so the bounded evidence block is\n\t\t\t// never packed/stubbed/reshaped by either pass and always reflects this turn's\n\t\t\t// fresh retrieval. Because nothing downstream trims it, memory-prompt-block.ts's\n\t\t\t// character caps are the only budget protection for this block -- load-bearing,\n\t\t\t// not merely defensive.\n\t\t\tconst gcMessages = this._maybeAppendMemoryEvidenceBlock(enforcementResult.messages, memoryReport);\n\t\t\treturn gcMessages;\n\t\t};\n\t}\n\n\t/**\n\t * Resolve the foreground request's cost policy after routing/context conversion, when the actual\n\t * model, full system prompt, converted messages, and tool schemas are known. The guard is a\n\t * projection threshold rather than a hard output cap: warning mode never reduces capability, while\n\t * opt-in downgrade changes only this request's reasoning effort. Best-effort: never throws.\n\t */\n\tprivate _resolveCostGuardRequestReasoning(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\treasoning: SimpleStreamOptions[\"reasoning\"],\n\t\trequestMaxTokens: number | undefined,\n\t): SimpleStreamOptions[\"reasoning\"] {\n\t\ttry {\n\t\t\tconst guard = this.settingsManager.getCostGuardSettings();\n\t\t\tconst isChatGptSubscription = model.provider === \"openai-codex\" && this._modelRegistry.isUsingOAuth(model);\n\t\t\tif (guard.maxTurnUsd <= 0 || !model.cost || isChatGptSubscription) {\n\t\t\t\tthis._lastCostGuardDecision = undefined;\n\t\t\t\treturn reasoning;\n\t\t\t}\n\t\t\tconst inputTokens = estimateContextPromptTokens(context);\n\t\t\t// Use an explicit request cap when present; otherwise project against the session response\n\t\t\t// reserve instead of a frontier model's theoretical 128K output maximum.\n\t\t\tconst maxOutputTokens = Math.min(\n\t\t\t\tmodel.maxTokens ?? 4096,\n\t\t\t\trequestMaxTokens ?? this.settingsManager.getCompactionReserveTokens(),\n\t\t\t);\n\t\t\tconst estUsd = estimateTurnCostUsd({\n\t\t\t\tinputTokens,\n\t\t\t\tmaxOutputTokens,\n\t\t\t\tcost: model.cost,\n\t\t\t\tlongContextPricing: model.longContextPricing,\n\t\t\t});\n\t\t\tconst decision = evaluateCostGuard(estUsd, { maxTurnUsd: guard.maxTurnUsd, action: guard.action });\n\t\t\tthis._lastCostGuardDecision = decision;\n\t\t\tif (!decision.over || guard.action !== \"downgrade\" || reasoning === undefined) return reasoning;\n\t\t\tconst next = downgradeReasoning(reasoning, getSupportedThinkingLevels(model), model.thinkingLevelMap);\n\t\t\treturn next as NonNullable<SimpleStreamOptions[\"reasoning\"]>;\n\t\t} catch {\n\t\t\t// cost guard must never disrupt a turn\n\t\t\treturn reasoning;\n\t\t}\n\t}\n\n\t/** Latest cost-guard decision (for the host footer/UI to surface a warning). Undefined if disabled. */\n\tgetLastCostGuardDecision(): CostGuardDecision | undefined {\n\t\treturn this._lastCostGuardDecision;\n\t}\n\n\tprivate get _skillCurator(): SkillCurator {\n\t\tif (!this._skillCuratorInstance) {\n\t\t\tthis._skillCuratorInstance = new SkillCurator(join(this._agentDir, \"skills\"));\n\t\t}\n\t\treturn this._skillCuratorInstance;\n\t}\n\n\t/**\n\t * Skill curator (#32): PROPOSE (never auto-apply) archival of stale reflection-promoted skills and\n\t * consolidation of overlapping ones. The host surfaces these (e.g. a `/curate` command) for approval.\n\t */\n\tproposeSkillCuration(options?: { staleDays?: number; overlapThreshold?: number }): CurationProposals {\n\t\treturn this._skillCurator.proposeCuration(Date.now(), options);\n\t}\n\n\t/**\n\t * Session-start auto-curation (#32, default ON): archive stale reflection-promoted skills in one\n\t * locked batch and return the names archived so the host can ANNOUNCE it (never silent). Skipped in\n\t * child sessions and when `curator.autoArchive` is disabled. Restorable via `/curate restore`.\n\t */\n\tasync runStartupSkillCuration(): Promise<string[]> {\n\t\tif (this._isChildSession) return [];\n\t\tconst settings = this.settingsManager.getCuratorSettings();\n\t\tif (!settings.autoArchive) return [];\n\t\treturn this._skillCurator.autoArchiveStale(Date.now(), { staleDays: settings.staleDays });\n\t}\n\n\t/** Archive a promoted skill into `skills/.archive/` (restorable, non-destructive). Returns true if moved. */\n\tarchivePromotedSkill(name: string): boolean {\n\t\treturn this._skillCurator.archiveSkill(name);\n\t}\n\n\t/** Restore a previously-archived promoted skill. Returns true if moved back. */\n\trestorePromotedSkill(name: string): boolean {\n\t\treturn this._skillCurator.restoreSkill(name);\n\t}\n\n\tprivate _installAgentTurnRefresh(): void {\n\t\tconst previousPrepareNextTurn = this.agent.prepareNextTurn?.bind(this.agent);\n\t\tthis.agent.prepareNextTurn = async (signal) => {\n\t\t\tconst previous = previousPrepareNextTurn ? await previousPrepareNextTurn(signal) : undefined;\n\t\t\tconst snapshot = this._createAgentContextSnapshot();\n\t\t\treturn {\n\t\t\t\t...previous,\n\t\t\t\tcontext: {\n\t\t\t\t\t...(previous?.context ?? snapshot),\n\t\t\t\t\tsystemPrompt: snapshot.systemPrompt,\n\t\t\t\t\ttools: snapshot.tools,\n\t\t\t\t},\n\t\t\t\tmodel: previous?.model ?? this.agent.state.model,\n\t\t\t\tthinkingLevel: previous?.thinkingLevel ?? this.agent.state.thinkingLevel,\n\t\t\t};\n\t\t};\n\t}\n\n\tprivate _createAgentContextSnapshot(): AgentContext {\n\t\treturn {\n\t\t\tsystemPrompt: this.agent.state.systemPrompt,\n\t\t\tmessages: this.agent.state.messages.slice(),\n\t\t\ttools: this.agent.state.tools.slice(),\n\t\t};\n\t}\n\n\tprivate _modelAdaptationKeyFor(model: Model<Api> | undefined): string | undefined {\n\t\treturn model ? formatModelRouterModel(model) : undefined;\n\t}\n\n\tprivate _toolRepairSettings() {\n\t\treturn resolveCurrentToolRepairSettings(this.settingsManager.settings);\n\t}\n\n\tprivate _applyToolRepairLayerSettings(): void {\n\t\tconst settings = this._toolRepairSettings();\n\t\tthis.agent.toolArgumentTeachEnabled = settings.teach;\n\t}\n\n\tprivate _getModelAdaptationRulesForPrompt() {\n\t\tif (!this._toolRepairSettings().teach) return [];\n\t\tconst modelKey = this._modelAdaptationKeyFor(this.agent.state.model);\n\t\treturn modelKey ? this._modelAdaptationStore.get(modelKey).rules : [];\n\t}\n\n\tprivate _textProtocolFlag(model: Model<Api> | undefined): boolean {\n\t\t// Phase 7 gating hierarchy: PI_TEXT_TOOL_CALL_PROTOCOL_DISABLED is resolved\n\t\t// in _toolRepairSettings() as the env kill switch, then settings.toolRepair.textProtocol\n\t\t// force-enables/disables globally, then Model.textToolCallProtocol opts in per model,\n\t\t// then a persisted /toolprobe text-protocol verdict opts in that exact model. The\n\t\t// calibration store is consulted after this flag; native provider tool calls still\n\t\t// win when emitted, and this only enables the text-protocol fallback lane.\n\t\tconst override = this._toolRepairSettings().textProtocol;\n\t\tif (override !== undefined) return override;\n\t\tif (model?.textToolCallProtocol === true) return true;\n\t\tconst modelKey = this._modelAdaptationKeyFor(model);\n\t\treturn !!modelKey && this._modelAdaptationStore.get(modelKey).toolProbe?.status === \"text-protocol\";\n\t}\n\n\tprivate async _streamForToolProbe(model: Model<Api>, context: Context, options: SimpleStreamOptions) {\n\t\tlet requestOptions = options;\n\t\tif (this._isRawStreamSimple(this.agent.streamFn)) {\n\t\t\tconst auth = await this._getRequiredRequestAuth(model);\n\t\t\trequestOptions = {\n\t\t\t\t...options,\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\theaders: auth.headers || options.headers ? { ...auth.headers, ...options.headers } : undefined,\n\t\t\t};\n\t\t}\n\t\treturn this.agent.streamFn(model, context, requestOptions);\n\t}\n\n\tprivate _textProtocolCalibrationContext(variant: TextToolProtocolVariant, token: string): Context {\n\t\tconst primer = generateTextToolProtocolPrimer([TEXT_TOOL_PROTOCOL_ECHO_TOOL], { variant });\n\t\tconst instruction = `Text tool protocol calibration trial. Using the protocol above, call echo with data exactly \"${token}\". Output only the tool-call envelope.`;\n\t\treturn {\n\t\t\tsystemPrompt: `${primer}\\n\\n${instruction}`,\n\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: instruction }], timestamp: Date.now() }],\n\t\t};\n\t}\n\n\tprivate _messageHasToolCallWithStringArgument(\n\t\tmessage: AssistantMessage,\n\t\ttoolName: string,\n\t\targName: string,\n\t\targValue: string,\n\t): boolean {\n\t\treturn message.content.some((block) => {\n\t\t\tif (block.type !== \"toolCall\" || block.name !== toolName) return false;\n\t\t\tconst args = block.arguments as unknown;\n\t\t\treturn (\n\t\t\t\ttypeof args === \"object\" &&\n\t\t\t\targs !== null &&\n\t\t\t\t!Array.isArray(args) &&\n\t\t\t\t(args as Record<string, unknown>)[argName] === argValue\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate _nativeToolProbeSystemPrompt(instruction: string): string {\n\t\tconst base = (this.agent.state.systemPrompt ?? \"\").trim();\n\t\treturn base ? `${base}\\n\\n${instruction}` : instruction;\n\t}\n\n\tprivate async _runNativeReadTaskProbeTrial(model: Model<Api>, path: string): Promise<boolean> {\n\t\tconst instruction =\n\t\t\t`Native tool-call capability probe: task-scale read. Use provider-native tool calling, not prose. ` +\n\t\t\t`Call read exactly once with path exactly \"${path}\".`;\n\t\tconst stream = await this._streamForToolProbe(\n\t\t\tmodel,\n\t\t\t{\n\t\t\t\tsystemPrompt: this._nativeToolProbeSystemPrompt(instruction),\n\t\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: instruction }], timestamp: Date.now() }],\n\t\t\t\ttools: [NATIVE_TOOL_PROBE_READ_TOOL],\n\t\t\t},\n\t\t\t{ textToolCallProtocol: false, maxRetries: 0, temperature: 0, maxTokens: 768 },\n\t\t);\n\t\treturn this._messageHasToolCallWithStringArgument(await stream.result(), \"read\", \"path\", path);\n\t}\n\n\tprivate async _runNativeEchoToolProbeTrial(model: Model<Api>, token: string): Promise<boolean> {\n\t\tconst instruction =\n\t\t\t`Native tool-call capability probe: echo-only. Use provider-native tool calling, not prose. ` +\n\t\t\t`Call echo with data exactly \"${token}\".`;\n\t\tconst stream = await this._streamForToolProbe(\n\t\t\tmodel,\n\t\t\t{\n\t\t\t\tsystemPrompt: this._nativeToolProbeSystemPrompt(instruction),\n\t\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: instruction }], timestamp: Date.now() }],\n\t\t\t\ttools: [TEXT_TOOL_PROTOCOL_ECHO_TOOL],\n\t\t\t},\n\t\t\t{ textToolCallProtocol: false, maxRetries: 0, temperature: 0, maxTokens: 256 },\n\t\t);\n\t\treturn this._messageHasToolCallWithStringArgument(await stream.result(), \"echo\", \"data\", token);\n\t}\n\n\tprivate async _gradeNativeToolCallingForModel(model: Model<Api>, token: string): Promise<NativeToolProbeGrade> {\n\t\tconst path = join(\n\t\t\tgetProcessWorkRun(this._agentDir, \"probes\", \"native-tools\").path,\n\t\t\t`pi-native-probe-${process.pid}-${Date.now()}.txt`,\n\t\t);\n\t\twriteFileSync(path, token, \"utf-8\");\n\t\ttry {\n\t\t\tconst taskPassed = await this._runNativeReadTaskProbeTrial(model, path);\n\t\t\tif (taskPassed) return \"task\";\n\t\t\tconst echoPassed = await this._runNativeEchoToolProbeTrial(model, token);\n\t\t\tif (echoPassed) return \"echo-only\";\n\t\t\treturn \"absent\";\n\t\t} finally {\n\t\t\trmSync(path, { force: true });\n\t\t}\n\t}\n\n\tprivate async _runTextProtocolTrial(\n\t\tmodel: Model<Api>,\n\t\tvariant: TextToolProtocolVariant,\n\t\ttoken: string,\n\t): Promise<boolean> {\n\t\tconst stream = await this._streamForToolProbe(model, this._textProtocolCalibrationContext(variant, token), {\n\t\t\ttextToolCallProtocol: false,\n\t\t\tmaxRetries: 0,\n\t\t\ttemperature: 0,\n\t\t\tmaxTokens: 256,\n\t\t});\n\t\tconst message = await stream.result();\n\t\tconst text = message.content\n\t\t\t.filter((block): block is TextContent => block.type === \"text\")\n\t\t\t.map((block) => block.text)\n\t\t\t.join(\"\\n\")\n\t\t\t.trim();\n\t\tif (!text) return false;\n\t\tconst parsed = parseTextToolCalls(text, [TEXT_TOOL_PROTOCOL_ECHO_TOOL]);\n\t\treturn parsed.calls.some((call) => call.name === \"echo\" && call.arguments.data === token);\n\t}\n\n\tprivate async _calibrateTextToolProtocolForModel(\n\t\tmodel: Model<Api>,\n\t\tmodelKey: string | undefined,\n\t\toptions: { persistFailure: boolean },\n\t): Promise<\n\t\t| { status: \"calibrated\"; variant: TextToolProtocolVariant; calibratedAt: string }\n\t\t| { status: \"failed\"; attemptedAt: string; variantsTried: string[] }\n\t> {\n\t\tconst variantsTried: string[] = [];\n\t\tfor (const variant of TEXT_TOOL_PROTOCOL_VARIANTS) {\n\t\t\tvariantsTried.push(variant);\n\t\t\tlet passed = true;\n\t\t\tfor (let trial = 0; trial < TEXT_TOOL_PROTOCOL_TRIALS_PER_VARIANT; trial++) {\n\t\t\t\tconst ok = await this._runTextProtocolTrial(model, variant, `pi-calibration-${trial + 1}`);\n\t\t\t\tif (!ok) {\n\t\t\t\t\tpassed = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (passed) {\n\t\t\t\tconst calibratedAt = new Date().toISOString();\n\t\t\t\tif (modelKey) {\n\t\t\t\t\tthis._modelAdaptationStore.setProtocol(\n\t\t\t\t\t\tmodelKey,\n\t\t\t\t\t\t{ version: TEXT_TOOL_PROTOCOL_VERSION, status: \"calibrated\", variant, calibratedAt },\n\t\t\t\t\t\tcalibratedAt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { status: \"calibrated\", variant, calibratedAt };\n\t\t\t}\n\t\t}\n\n\t\tconst attemptedAt = new Date().toISOString();\n\t\tif (modelKey && options.persistFailure) {\n\t\t\tthis._modelAdaptationStore.setProtocol(\n\t\t\t\tmodelKey,\n\t\t\t\t{ version: TEXT_TOOL_PROTOCOL_VERSION, status: \"failed\", attemptedAt, variantsTried },\n\t\t\t\tattemptedAt,\n\t\t\t);\n\t\t}\n\t\treturn { status: \"failed\", attemptedAt, variantsTried };\n\t}\n\n\tprivate async _ensureTextToolProtocolForActiveModel(): Promise<void> {\n\t\tconst model = this.agent.state.model;\n\t\tif (!this._textProtocolFlag(model)) {\n\t\t\tthis.agent.textToolCallProtocol = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst modelKey = this._modelAdaptationKeyFor(model);\n\t\tif (!modelKey) {\n\t\t\tthis.agent.textToolCallProtocol = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst profile = this._modelAdaptationStore.get(modelKey);\n\t\tif (profile.protocol?.version === TEXT_TOOL_PROTOCOL_VERSION) {\n\t\t\tif (profile.protocol.status === \"failed\") {\n\t\t\t\tthis.agent.textToolCallProtocol = undefined;\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Previous text tool protocol calibration failed for ${modelKey} at ${profile.protocol.attemptedAt}. ` +\n\t\t\t\t\t\t`Variants tried: ${profile.protocol.variantsTried.join(\", \")}. ` +\n\t\t\t\t\t\t`Run /toolhealth for details or /toolprotocol-reset ${modelKey} to retry calibration.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.agent.textToolCallProtocol = { variant: profile.protocol.variant as TextToolProtocolVariant };\n\t\t\treturn;\n\t\t}\n\n\t\tconst result = await this._calibrateTextToolProtocolForModel(model, modelKey, { persistFailure: true });\n\t\tif (result.status === \"calibrated\") {\n\t\t\tthis.agent.textToolCallProtocol = { variant: result.variant };\n\t\t\treturn;\n\t\t}\n\n\t\tthis.agent.textToolCallProtocol = undefined;\n\t\tthrow new Error(\n\t\t\t`Model ${modelKey} cannot follow the text tool protocol after calibration. ` +\n\t\t\t\t`Run /toolhealth for details or /toolprotocol-reset ${modelKey} to retry calibration.`,\n\t\t);\n\t}\n\n\tprivate _modelRef(model: Model<Api>): string {\n\t\treturn `${model.provider}/${model.id}`;\n\t}\n\n\tprivate _formatToolProbeReport(results: readonly ToolProbeResult[]): string {\n\t\tconst lines = [\n\t\t\t\"Tool probe results:\",\n\t\t\t\"Model | Verdict | Variant | Native grade | Diagnostic\",\n\t\t\t\"--- | --- | --- | --- | ---\",\n\t\t];\n\t\tfor (const result of results) {\n\t\t\tlines.push(\n\t\t\t\t[\n\t\t\t\t\tresult.model,\n\t\t\t\t\tresult.verdict,\n\t\t\t\t\tresult.variant ?? \"-\",\n\t\t\t\t\tresult.nativeGrade ?? \"-\",\n\t\t\t\t\tresult.diagnostic ? result.diagnostic.replace(/\\s+/g, \" \").slice(0, 160) : \"-\",\n\t\t\t\t].join(\" | \"),\n\t\t\t);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tprivate _storeToolProbe(modelKey: string, probe: ModelToolProbe): void {\n\t\tthis._modelAdaptationStore.setToolProbe(modelKey, probe, probe.probedAt);\n\t}\n\n\tprivate async _probeToolCallingForModel(model: Model<Api>): Promise<ToolProbeResult> {\n\t\tconst modelKey = this._modelRef(model);\n\t\tconst probedAt = new Date().toISOString();\n\t\tlet nativeGrade: NativeToolProbeGrade = \"absent\";\n\t\tlet diagnostic: string | undefined;\n\t\ttry {\n\t\t\tnativeGrade = await this._gradeNativeToolCallingForModel(model, \"pi-native-probe\");\n\t\t\tif (nativeGrade === \"task\") {\n\t\t\t\tthis._storeToolProbe(modelKey, {\n\t\t\t\t\tversion: TEXT_TOOL_PROTOCOL_VERSION,\n\t\t\t\t\tstatus: \"native\",\n\t\t\t\t\tprobedAt,\n\t\t\t\t\tnativeGrade,\n\t\t\t\t});\n\t\t\t\treturn { model: modelKey, verdict: \"native\", nativeGrade };\n\t\t\t}\n\t\t\tdiagnostic =\n\t\t\t\tnativeGrade === \"echo-only\"\n\t\t\t\t\t? \"Native echo probe passed but task-scale read probe failed.\"\n\t\t\t\t\t: \"Native task-scale read and echo probes did not produce provider-native tool calls.\";\n\t\t} catch (error) {\n\t\t\tdiagnostic = error instanceof Error ? error.message : String(error);\n\t\t}\n\n\t\ttry {\n\t\t\tconst calibrated = await this._calibrateTextToolProtocolForModel(model, modelKey, { persistFailure: false });\n\t\t\tif (calibrated.status === \"calibrated\") {\n\t\t\t\tthis._storeToolProbe(modelKey, {\n\t\t\t\t\tversion: TEXT_TOOL_PROTOCOL_VERSION,\n\t\t\t\t\tstatus: \"text-protocol\",\n\t\t\t\t\tprobedAt: calibrated.calibratedAt,\n\t\t\t\t\tvariant: calibrated.variant,\n\t\t\t\t\tnativeGrade,\n\t\t\t\t\tdiagnostic,\n\t\t\t\t});\n\t\t\t\treturn { model: modelKey, verdict: \"text-protocol\", variant: calibrated.variant, nativeGrade, diagnostic };\n\t\t\t}\n\t\t\tdiagnostic = `${diagnostic ? `${diagnostic} ` : \"\"}Text protocol variants failed: ${calibrated.variantsTried.join(\", \")}`;\n\t\t} catch (error) {\n\t\t\tdiagnostic = error instanceof Error ? error.message : String(error);\n\t\t}\n\n\t\tthis._storeToolProbe(modelKey, {\n\t\t\tversion: TEXT_TOOL_PROTOCOL_VERSION,\n\t\t\tstatus: \"none\",\n\t\t\tprobedAt,\n\t\t\tnativeGrade,\n\t\t\tdiagnostic,\n\t\t});\n\t\treturn { model: modelKey, verdict: \"none\", nativeGrade, diagnostic };\n\t}\n\n\tprivate async _resolveToolProbeModels(target?: string): Promise<Model<Api>[]> {\n\t\tconst trimmed = target?.trim();\n\t\tif (!trimmed) return this._modelRegistry.getAvailable();\n\t\tconst [provider, ...modelParts] = trimmed.split(\"/\");\n\t\tconst modelId = modelParts.join(\"/\");\n\t\tif (!provider || !modelId) throw new Error(\"Usage: /toolprobe [provider/model]\");\n\t\tconst exact = this._modelRegistry.find(provider, modelId);\n\t\tif (exact) return [exact];\n\t\tconst current = this.agent.state.model;\n\t\tif (current?.provider === provider && current.id === modelId) return [current];\n\t\tthrow new Error(`Model not found: ${trimmed}`);\n\t}\n\n\tasync probeToolCalling(target?: string): Promise<ToolProbeReport> {\n\t\tconst models = await this._resolveToolProbeModels(target);\n\t\tif (models.length === 0) throw new Error(\"No available models to probe.\");\n\t\tconst results: ToolProbeResult[] = [];\n\t\tfor (const model of models) {\n\t\t\tresults.push(await this._probeToolCallingForModel(model));\n\t\t}\n\t\treturn { results, table: this._formatToolProbeReport(results) };\n\t}\n\n\tprivate _handleTextToolProtocolParse(event: TextToolProtocolParseEvent): void {\n\t\tthis._textProtocolParseObservedThisTurn = true;\n\t\tconst modelKey = `${event.provider}/${event.model}`;\n\t\tif (event.status === \"parsed\") return;\n\t\tconst signature = `${event.variant}:${event.reason ?? \"failed\"}`;\n\t\tconst previous = this._textProtocolParseFailures.get(modelKey);\n\t\tconst repeats = previous?.signature === signature ? previous.repeats + 1 : 1;\n\t\tthis._textProtocolParseFailures.set(modelKey, { signature, repeats });\n\t\tif (repeats < TEXT_TOOL_PROTOCOL_PARSE_FAILURE_THRESHOLD) return;\n\n\t\tconst profile = this._modelAdaptationStore.get(modelKey);\n\t\tif (profile.protocol?.version === TEXT_TOOL_PROTOCOL_VERSION && profile.protocol.status !== \"failed\") {\n\t\t\tthis._modelAdaptationStore.removeProtocol(modelKey);\n\t\t\tthis.agent.textToolCallProtocol = undefined;\n\t\t}\n\t\tthis._textProtocolParseFailures.delete(modelKey);\n\t}\n\n\tprivate _handleTextToolProtocolValidationOutcome(event: ToolArgumentValidationTelemetryEvent): void {\n\t\tif (event.source !== \"text-protocol\") return;\n\t\tconst protocol = this.agent.textToolCallProtocol;\n\t\tconst variant = protocol === true ? \"tool-tag\" : protocol ? protocol.variant : undefined;\n\t\tif (!variant) return;\n\t\tconst status = event.outcome === \"bounced\" ? \"failed\" : \"parsed\";\n\t\tif (this._textProtocolValidationOutcomeThisTurn?.status === \"parsed\" && status === \"failed\") return;\n\t\tthis._textProtocolValidationOutcomeThisTurn = {\n\t\t\tprovider: event.provider ?? this.agent.state.model.provider,\n\t\t\tmodel: event.model ?? this.agent.state.model.id,\n\t\t\tvariant,\n\t\t\tstatus,\n\t\t\tcallCount: 1,\n\t\t\ttextLength: 0,\n\t\t\t...(status === \"failed\" && {\n\t\t\t\treason: event.errorKeywords?.includes(\"unknown_tool\") ? \"unknown-tool\" : \"validation-failed\",\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate _recordTextToolProtocolParseOutcomeFromLastAssistant(): void {\n\t\tconst validationOutcome = this._textProtocolValidationOutcomeThisTurn;\n\t\tthis._textProtocolValidationOutcomeThisTurn = undefined;\n\t\tif (validationOutcome?.status === \"parsed\") {\n\t\t\tthis._textProtocolParseObservedThisTurn = true;\n\t\t\tthis._textProtocolParseFailures.delete(`${validationOutcome.provider}/${validationOutcome.model}`);\n\t\t\treturn;\n\t\t}\n\t\tif (validationOutcome) {\n\t\t\tthis._handleTextToolProtocolParse(validationOutcome);\n\t\t\treturn;\n\t\t}\n\t\tif (this._textProtocolParseObservedThisTurn) return;\n\t\tconst protocol = this.agent.textToolCallProtocol;\n\t\tif (protocol === false || protocol === true || !protocol?.variant) return;\n\t\tconst response = this._findLastAssistantMessage();\n\t\tif (!response) return;\n\t\tconst responseText = response.content\n\t\t\t.filter((content): content is TextContent => content.type === \"text\")\n\t\t\t.map((content) => content.text)\n\t\t\t.join(\"\\n\");\n\t\tif (!responseText) return;\n\n\t\tconst parsed = parseTextToolCalls(responseText, this.agent.state.tools);\n\t\tconst attempted = parsed.attempted || this._looksLikeTextToolProtocolAttempt(responseText);\n\t\tif (!attempted) return;\n\t\tthis._handleTextToolProtocolParse({\n\t\t\tprovider: this.agent.state.model.provider,\n\t\t\tmodel: this.agent.state.model.id,\n\t\t\tvariant: protocol.variant,\n\t\t\tstatus: parsed.calls.length > 0 ? \"parsed\" : \"failed\",\n\t\t\treason: parsed.failure,\n\t\t\tcallCount: parsed.calls.length,\n\t\t\ttextLength: responseText.length,\n\t\t});\n\t}\n\n\tprivate _looksLikeTextToolProtocolAttempt(text: string): boolean {\n\t\treturn /<pi:call\\b|<tool_call\\b|```(?:tool|tool_call)[\\s\\S]*\"name\"\\s*:/i.test(text);\n\t}\n\n\tprivate _tagModelAdaptationRuleTeaching(\n\t\tevent: ToolArgumentValidationTelemetryEvent,\n\t): ToolArgumentValidationTelemetryEvent {\n\t\tif (!this._toolRepairSettings().teach || event.taught !== \"none\") return event;\n\t\tconst modelKey =\n\t\t\tevent.provider && event.model\n\t\t\t\t? `${event.provider}/${event.model}`\n\t\t\t\t: this._modelAdaptationKeyFor(this.agent.state.model);\n\t\tif (!modelKey) return event;\n\t\ttry {\n\t\t\tconst rules = this._modelAdaptationStore.get(modelKey).rules;\n\t\t\tconst modes = new Set([...event.failureModes, ...event.repairsApplied]);\n\t\t\tif (rules.some((rule) => modes.has(rule.mode as ToolRepairModeName))) {\n\t\t\t\treturn { ...event, taught: \"rule\" };\n\t\t\t}\n\t\t} catch {\n\t\t\t// Adaptation telemetry tagging is best-effort; leave the original event unchanged.\n\t\t}\n\t\treturn event;\n\t}\n\n\tprivate _repairSessionCount(modelKey: string, mode: ToolRepairModeName): number {\n\t\tconst key = `${modelKey}\\0${mode}`;\n\t\tconst count = (this._repairModeSessionCounts.get(key) ?? 0) + 1;\n\t\tthis._repairModeSessionCounts.set(key, count);\n\t\treturn count;\n\t}\n\n\tprivate _handleModelAdaptationTelemetry(event: ToolArgumentValidationTelemetryEvent): void {\n\t\tif (!this._toolRepairSettings().teach || event.outcome !== \"repaired\" || event.repairsApplied.length === 0)\n\t\t\treturn;\n\t\tconst modelKey =\n\t\t\tevent.provider && event.model\n\t\t\t\t? `${event.provider}/${event.model}`\n\t\t\t\t: this._modelAdaptationKeyFor(this.agent.state.model);\n\t\tif (!modelKey) return;\n\n\t\ttry {\n\t\t\tfor (const mode of [...new Set(event.repairsApplied)]) {\n\t\t\t\tconst profile = this._modelAdaptationStore.get(modelKey);\n\t\t\t\tconst stats = profile.teachStats[mode] ?? { taught: 0, recurrenceBefore: 0, recurrenceAfter: 0 };\n\t\t\t\tif (profile.rules.some((rule) => rule.mode === mode)) {\n\t\t\t\t\tthis._modelAdaptationStore.markRuleFired(modelKey, mode);\n\t\t\t\t\tthis._modelAdaptationStore.setTeachStats(modelKey, mode, {\n\t\t\t\t\t\t...stats,\n\t\t\t\t\t\trecurrenceAfter: stats.recurrenceAfter + 1,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst recurrenceBefore = stats.recurrenceBefore + 1;\n\t\t\t\tthis._modelAdaptationStore.setTeachStats(modelKey, mode, { ...stats, recurrenceBefore });\n\t\t\t\tconst sessionCount = this._repairSessionCount(modelKey, mode);\n\t\t\t\tif (\n\t\t\t\t\tsessionCount >= MODEL_ADAPTATION_REPAIR_THRESHOLD ||\n\t\t\t\t\trecurrenceBefore >= MODEL_ADAPTATION_REPAIR_THRESHOLD\n\t\t\t\t) {\n\t\t\t\t\tthis._modelAdaptationStore.addRule(modelKey, {\n\t\t\t\t\t\tmode,\n\t\t\t\t\t\ttext: formatToolRepairStandingRule(mode),\n\t\t\t\t\t});\n\t\t\t\t\tthis._modelAdaptationStore.setTeachStats(modelKey, mode, {\n\t\t\t\t\t\t...stats,\n\t\t\t\t\t\ttaught: stats.taught + 1,\n\t\t\t\t\t\trecurrenceBefore,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Model adaptation is best-effort; failed telemetry persistence must not affect the turn.\n\t\t}\n\t}\n\n\t/** Tool-build call-site delegation to {@link ContextPipeline.getToolArtifactStore}. */\n\tprivate _getToolArtifactStore(): ArtifactStore {\n\t\treturn this._pipeline.getToolArtifactStore();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.runContextAudit}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runContextAudit(messages: AgentMessage[]): ContextAuditReport {\n\t\treturn this._pipeline.runContextAudit(messages);\n\t}\n\n\t/** Read-only inspection of the context audit (delegates to {@link ContextPipeline.getContextAuditReport}). */\n\tgetContextAuditReport(messages?: AgentMessage[]): ContextAuditReport {\n\t\treturn this._pipeline.getContextAuditReport(messages);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.runPromptPolicyPlanning}. Kept as\n\t * a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runPromptPolicyPlanning(auditReport: ContextAuditReport): PromptPolicyShadowReport {\n\t\treturn this._pipeline.runPromptPolicyPlanning(auditReport);\n\t}\n\n\t/** Read-only inspection of the shadow policy plan (delegates to {@link ContextPipeline.getPromptPolicyReport}). */\n\tgetPromptPolicyReport(messages?: AgentMessage[]): PromptPolicyShadowReport {\n\t\treturn this._pipeline.getPromptPolicyReport(messages);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.correlatePromptPolicyWithContextGc}.\n\t * Kept as a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _correlatePromptPolicyWithContextGc(gcReport: ContextGcReport): void {\n\t\tthis._pipeline.correlatePromptPolicyWithContextGc(gcReport);\n\t}\n\n\t/** Read-only inspection of the latest shadow-plan/legacy-gc correlation, for tests/debugging. */\n\tgetPromptPolicyGcCorrelation(): PromptPolicyGcCorrelationReport {\n\t\treturn this._pipeline.getPromptPolicyGcCorrelation();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.runPromptEnforcement}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runPromptEnforcement(\n\t\tmessages: AgentMessage[],\n\t\tshadowReport: PromptPolicyShadowReport,\n\t): { messages: AgentMessage[]; report: PromptEnforcementReport } {\n\t\treturn this._pipeline.runPromptEnforcement(messages, shadowReport);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.enqueueRelevanceCuration}. Kept as\n\t * a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _enqueueRelevanceCuration(messages: AgentMessage[], shadowReport: PromptPolicyShadowReport): void {\n\t\tthis._pipeline.enqueueRelevanceCuration(messages, shadowReport);\n\t}\n\n\t/** Reflex/curation call-site delegation to {@link ContextPipeline.resolveCurationModelIfFit}. */\n\tprivate _resolveCurationModelIfFit(): Model<Api> | undefined {\n\t\treturn this._pipeline.resolveCurationModelIfFit();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.maybeDrainBrainCuration}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _maybeDrainBrainCuration(): void {\n\t\tthis._pipeline.maybeDrainBrainCuration();\n\t}\n\n\t/** Compaction call-site delegation to {@link ContextPipeline.buildCompactionPreDigest}. */\n\tprivate _buildCompactionPreDigest(): ((text: string, signal?: AbortSignal) => Promise<string>) | undefined {\n\t\treturn this._pipeline.buildCompactionPreDigest();\n\t}\n\n\t/** Drop provider-owned request/continuation caches whose prefix was invalidated by compaction. */\n\tprivate _refreshAfterCompaction(): void {\n\t\tthis.agent.state.messages = this.sessionManager.buildSessionContext().messages;\n\t\ttry {\n\t\t\tcleanupSessionResources(this.sessionId);\n\t\t} catch {\n\t\t\t// Provider cache cleanup is best-effort and must not turn an applied compaction into a failure.\n\t\t}\n\t}\n\n\t/**\n\t * Context composition dashboard data: decomposes the per-request payload (system prompt, tool\n\t * schemas, extension contributions, message classes incl. GC/policy stubs and recall pages)\n\t * plus background spend, so users can see exactly what their integrations cost per request.\n\t * Read-only: uses the GC report path (writePayloads=false), never mutates anything.\n\t */\n\tgetContextCompositionReport(): ContextCompositionReport {\n\t\tconst rawMessages = this.agent.state.messages.slice();\n\t\tconst gcResult = this._applyContextGc(rawMessages, false);\n\t\tconst activeNames = new Set(this.getActiveToolNames());\n\t\tconst extensions = this._resourceLoader.getExtensions().extensions;\n\t\tconst extensionToolNames = new Set(extensions.flatMap((extension) => [...extension.tools.keys()]));\n\t\tconst usage = this.getContextUsage();\n\t\tconst enforcementItems = this.getPromptEnforcementReport().items;\n\t\tconst curationStatus = this.getContextCurationStatus();\n\t\tconst spawned = this.getSpawnedUsage();\n\t\tconst promptInclusion = this.getMemoryPromptInclusionReport();\n\t\tconst memoryEvidenceTokens =\n\t\t\tpromptInclusion.status === \"included\" ? Math.ceil(promptInclusion.blockChars / 4) : 0;\n\t\t// Enforcement stubs are applied at SEND time (not persisted), so the message view here\n\t\t// still holds raw text for them; subtract what stubbing reclaims per request.\n\t\tconst enforcementSavedTokens = enforcementItems\n\t\t\t.filter((item) => item.enforced && typeof item.originalChars === \"number\")\n\t\t\t.reduce((sum, item) => sum + Math.max(0, Math.ceil((item.originalChars ?? 0) / 4) - 50), 0);\n\t\treturn buildContextCompositionReport({\n\t\t\tsystemPrompt: this.systemPrompt ?? \"\",\n\t\t\ttools: this.getAllTools()\n\t\t\t\t.filter((tool) => activeNames.has(tool.name))\n\t\t\t\t.map((tool) => ({\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\tsource: extensionToolNames.has(tool.name) ? (\"extension\" as const) : (\"built-in\" as const),\n\t\t\t\t})),\n\t\t\textensions: extensions.map((extension) => ({\n\t\t\t\tname: basename(extension.path),\n\t\t\t\tpath: extension.path,\n\t\t\t\ttoolNames: [...extension.tools.keys()],\n\t\t\t\tcommandCount: extension.commands.size,\n\t\t\t})),\n\t\t\tmessages: gcResult.messages,\n\t\t\tproviderReportedTokens: usage?.tokens ?? null,\n\t\t\tcontextWindow: usage?.contextWindow ?? this.model?.contextWindow ?? null,\n\t\t\tgc: { packedCount: gcResult.report.packedCount, savedTokens: gcResult.report.savedTokens },\n\t\t\tenforcement: {\n\t\t\t\tenforcedCount: enforcementItems.filter((item) => item.enforced).length,\n\t\t\t\tadvisoryEvictions: enforcementItems.filter((item) => item.advisory === \"brain_irrelevant\").length,\n\t\t\t},\n\t\t\tcuration: {\n\t\t\t\tenabled: curationStatus.enabled,\n\t\t\t\ttelemetry: curationStatus.telemetry,\n\t\t\t\tlastSkipReason: curationStatus.lastSkipReason,\n\t\t\t},\n\t\t\tspawned: { cost: spawned.cost, reports: spawned.reports },\n\t\t\tadjustments: { memoryEvidenceTokens, enforcementSavedTokens },\n\t\t\textraObservations: [\n\t\t\t\t...this._resourceLoader.getAgentsDiagnostics().map((diagnostic) => diagnostic.message),\n\t\t\t\t...this._profileFilter.profileDeniedResourceObservations(),\n\t\t\t\t...this._profileFilter.getInertExtensionWarnings(),\n\t\t\t\t...this._unboundToolGrantWarnings,\n\t\t\t\t// G7: auto-built per-turn foreground envelope (observe-only; not enforced). Falls back to a\n\t\t\t\t// live preview when no turn has run yet so /context always shows the current scope.\n\t\t\t\tformatForegroundEnvelopeObservation(\n\t\t\t\t\tthis._currentForegroundEnvelope ?? this._buildForegroundEnvelopeFromState(),\n\t\t\t\t),\n\t\t\t\t// G14 (ratified): a user disable always beats a profile grant — surface the conflict.\n\t\t\t\t...([\"tools\", \"skills\", \"prompts\", \"extensions\"] as const).flatMap((kind) =>\n\t\t\t\t\tthis.settingsManager\n\t\t\t\t\t\t.getProfileGrantsOverriddenByUserDisable(kind)\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\t\t`profile grants ${kind} \"${entry}\" but your disable list overrides it (user disable wins; re-enable to use)`,\n\t\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\t/** Bounded plain-text rendering of {@link getContextCompositionReport} for the /context command. */\n\tformatContextCompositionDashboard(): string {\n\t\treturn formatContextCompositionDashboard(this.getContextCompositionReport());\n\t}\n\n\tformatToolRepairHealthReport(): string {\n\t\treturn formatToolRepairHealthReport(this._modelAdaptationStore, new Date(), this._toolRecoveryLogger.getStats());\n\t}\n\n\tasync flushToolRecoveryLogsForTests(timeoutMs = 1000): Promise<void> {\n\t\tawait this._toolRecoveryLogger.flush(timeoutMs);\n\t}\n\n\tremoveToolRepairRule(model: string, mode: string): boolean {\n\t\treturn this._modelAdaptationStore.removeRule(model, mode);\n\t}\n\n\tresetToolProtocolCalibration(model: string): boolean {\n\t\tconst removed = this._modelAdaptationStore.removeProtocol(model);\n\t\tthis._textProtocolParseFailures.delete(model);\n\t\treturn removed;\n\t}\n\n\t/** Curation status for diagnostics/dashboard: settings, live telemetry, last refusal reason. */\n\t/** Curation status for diagnostics/dashboard (delegates to {@link ContextPipeline.getContextCurationStatus}). */\n\tgetContextCurationStatus(): {\n\t\tenabled: boolean;\n\t\tmodel?: string;\n\t\ttelemetry: CurationTelemetrySnapshot;\n\t\tlastSkipReason?: string;\n\t\tlastPreDigestSkipReason?: string;\n\t} {\n\t\treturn this._pipeline.getContextCurationStatus();\n\t}\n\n\t/** Read-only inspection of the latest prompt-enforcement report, for tests/debugging. */\n\tgetPromptEnforcementReport(): PromptEnforcementReport {\n\t\treturn this._pipeline.getPromptEnforcementReport();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link MemoryController.runMemoryRetrieval}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _runMemoryRetrieval(messages: AgentMessage[]): Promise<MemoryRetrievalReport> {\n\t\treturn this._memory.runMemoryRetrieval(messages);\n\t}\n\n\t/** Read-only inspection of the latest memory-retrieval report, for tests/debugging. */\n\tgetMemoryRetrievalReport(): MemoryRetrievalReport {\n\t\treturn this._memory.getMemoryRetrievalReport();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link MemoryController.maybeAppendMemoryEvidenceBlock}.\n\t * Kept as a one-line method (not inlined) so the transform stays the single owner of the pass ordering.\n\t */\n\tprivate _maybeAppendMemoryEvidenceBlock(messages: AgentMessage[], report: MemoryRetrievalReport): AgentMessage[] {\n\t\treturn this._memory.maybeAppendMemoryEvidenceBlock(messages, report);\n\t}\n\n\t/** Read-only inspection of the latest memory-prompt-inclusion decision, for tests/debugging and context_audit. */\n\tgetMemoryPromptInclusionReport(): MemoryPromptInclusionReport {\n\t\treturn this._memory.getMemoryPromptInclusionReport();\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.applyContextGc}. Kept as a\n\t * one-line method (not inlined) so the transform stays the single owner of the pass ordering;\n\t * also serves the composition dashboard and {@link getContextGcReport} read-only paths.\n\t */\n\tprivate _applyContextGc(\n\t\tmessages: AgentMessage[],\n\t\twritePayloads: boolean,\n\t): { messages: AgentMessage[]; report: ContextGcReport } {\n\t\treturn this._pipeline.applyContextGc(messages, writePayloads);\n\t}\n\n\t/** Read-only inspection of the latest context-gc report (delegates to {@link ContextPipeline.getContextGcReport}). */\n\tgetContextGcReport(messages?: AgentMessage[]): ContextGcReport {\n\t\treturn this._pipeline.getContextGcReport(messages);\n\t}\n\n\t/**\n\t * Context-transform hot-path delegation to {@link ContextPipeline.estimateCurrentContextTokens}. Kept\n\t * as a one-line method (not inlined) so the transform stays the single owner of the pass ordering;\n\t * also feeds the per-turn cost guard.\n\t */\n\tprivate _estimateCurrentContextTokens(messages: AgentMessage[]): number {\n\t\treturn this._pipeline.estimateCurrentContextTokens(messages);\n\t}\n\n\tprivate _installAgentToolHooks(): void {\n\t\tthis.agent.beforeToolCall = this._toolGate.beforeToolCall;\n\t\tthis.agent.afterToolCall = this._toolGate.afterToolCall;\n\t}\n\n\t// =========================================================================\n\t// Event Subscription\n\t// =========================================================================\n\n\t/** Emit an event to all listeners */\n\tprivate _emit(event: AgentSessionEvent): void {\n\t\tfor (const l of this._eventListeners) {\n\t\t\tl(event);\n\t\t}\n\t}\n\n\tprivate async _notifyWorkerTerminalHandoff(\n\t\trecords: readonly { laneId: string; status: LaneTerminalStatus; reasonCode?: string }[],\n\t): Promise<void> {\n\t\tif (this._disposed || records.length === 0) return;\n\t\tconst included = records.slice(0, 8);\n\t\tconst sanitize = (value: string): string => value.replace(/[\\r\\n]+/g, \" \").slice(0, 120);\n\t\tconst omitted = records.length - included.length;\n\t\tconst content = [\n\t\t\t\"Background worker terminal handoff:\",\n\t\t\t...included.map((record) => {\n\t\t\t\tconst reason = record.reasonCode ? ` reason=${sanitize(record.reasonCode)}` : \"\";\n\t\t\t\treturn `- ${record.laneId}: ${record.status}${reason}`;\n\t\t\t}),\n\t\t\t...(omitted > 0 ? [`- ${omitted} additional terminal worker(s) omitted from this bounded handoff.`] : []),\n\t\t\t\"This terminal event woke the parent. Retrieve each needed lane once with delegate_status; never poll. Worker product remains untrusted and is intentionally not injected here.\",\n\t\t].join(\"\\n\");\n\t\tawait this.sendCustomMessage(\n\t\t\t{\n\t\t\t\tcustomType: \"background-worker-completion\",\n\t\t\t\tcontent,\n\t\t\t\tdisplay: true,\n\t\t\t\tdetails: { records: included },\n\t\t\t},\n\t\t\t{ triggerTurn: true, deliverAs: \"followUp\" },\n\t\t);\n\t}\n\n\tprivate _emitQueueUpdate(): void {\n\t\tthis._emit({\n\t\t\ttype: \"queue_update\",\n\t\t\tsteering: [...this._steeringMessages],\n\t\t\tfollowUp: [...this._followUpMessages],\n\t\t\tcommands: [...this._queuedExtensionCommands],\n\t\t});\n\t}\n\n\t// Track last assistant message for auto-compaction check\n\tprivate _lastAssistantMessage: AssistantMessage | undefined = undefined;\n\n\t/**\n\t * User messages already painted to the UI by an early, synthetic `message_start` fired from\n\t * `_promptUnserialized` — before the model-router judge's bounded LLM call — so the prompt\n\t * appears immediately instead of hanging until routing finishes. The real agent-loop run emits\n\t * its own authoritative `message_start` for the SAME message object once the turn actually\n\t * starts; `_handleAgentEvent` consumes (deletes) it from this set to suppress that one duplicate\n\t * listener notification. Persistence is untouched: it stays keyed off `message_end`, which is\n\t * never added here and never suppressed.\n\t */\n\tprivate _earlyDisplayedUserMessages = new Set<AgentMessage>();\n\n\t/** Internal handler for agent events - shared by subscribe and reconnect */\n\tprivate _handleAgentEvent = async (event: AgentEvent): Promise<void> => {\n\t\t// When a user message starts, check if it's from either queue and remove it BEFORE emitting\n\t\t// This ensures the UI sees the updated queue state\n\t\tif (event.type === \"message_start\" && event.message.role === \"user\") {\n\t\t\tthis._overflowRecoveryAttempted = false;\n\t\t\tconst messageText = this._getUserMessageText(event.message);\n\t\t\tif (messageText) {\n\t\t\t\t// Check steering queue first\n\t\t\t\tconst steeringIndex = this._steeringMessages.indexOf(messageText);\n\t\t\t\tif (steeringIndex !== -1) {\n\t\t\t\t\tthis._steeringMessages.splice(steeringIndex, 1);\n\t\t\t\t\tthis._emitQueueUpdate();\n\t\t\t\t} else {\n\t\t\t\t\t// Check follow-up queue\n\t\t\t\t\tconst followUpIndex = this._followUpMessages.indexOf(messageText);\n\t\t\t\t\tif (followUpIndex !== -1) {\n\t\t\t\t\t\tthis._followUpMessages.splice(followUpIndex, 1);\n\t\t\t\t\t\tthis._emitQueueUpdate();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Emit to extensions first\n\t\tawait this._emitExtensionEvent(event);\n\n\t\tconst suppressRetryPromptEvent =\n\t\t\tthis._modelRouter.isRetryInFlight() &&\n\t\t\t(event.type === \"message_start\" || event.type === \"message_end\") &&\n\t\t\t(event.message.role === \"user\" || event.message.role === \"custom\");\n\n\t\t// This is the authoritative message_start for a user message already painted early (see\n\t\t// _promptUnserialized). Set#delete both tests and consumes membership in one step, so only\n\t\t// this one duplicate is suppressed and a later, unrelated user message is never affected.\n\t\tconst suppressAlreadyDisplayedUserMessage =\n\t\t\tevent.type === \"message_start\" &&\n\t\t\tevent.message.role === \"user\" &&\n\t\t\tthis._earlyDisplayedUserMessages.delete(event.message);\n\n\t\t// Notify all listeners\n\t\tif (!suppressRetryPromptEvent && !suppressAlreadyDisplayedUserMessage) {\n\t\t\tthis._emit(event.type === \"agent_end\" ? { ...event, willRetry: this._willRetryAfterAgentEnd(event) } : event);\n\t\t}\n\n\t\t// Handle session/context retention. Tool result details are UI/log metadata,\n\t\t// not provider-visible content, and large graph/search payloads can otherwise\n\t\t// accumulate until the interactive Node process hits the V8 heap limit.\n\t\tif (event.type === \"message_end\") {\n\t\t\tcompactToolResultDetailsForRetention(event.message);\n\t\t\tlet messagePersisted = false;\n\t\t\t// While a cheap routed turn is buffering, its messages are captured for later flush/discard\n\t\t\t// instead of persisted here (see ModelRouterController.captureSessionMessage).\n\t\t\tif (this._modelRouter.captureSessionMessage(event.message)) {\n\t\t\t\t// buffered by the router; persistence is deferred to the routed-turn flush\n\t\t\t}\n\t\t\t// Check if this is a custom message from extensions\n\t\t\telse if (event.message.role === \"custom\") {\n\t\t\t\t// Persist as CustomMessageEntry\n\t\t\t\tthis.sessionManager.appendCustomMessageEntry(\n\t\t\t\t\tevent.message.customType,\n\t\t\t\t\tevent.message.content,\n\t\t\t\t\tevent.message.display,\n\t\t\t\t\tevent.message.details,\n\t\t\t\t);\n\t\t\t\tmessagePersisted = true;\n\t\t\t} else if (\n\t\t\t\tevent.message.role === \"user\" ||\n\t\t\t\tevent.message.role === \"assistant\" ||\n\t\t\t\tevent.message.role === \"toolResult\"\n\t\t\t) {\n\t\t\t\t// Regular LLM message - persist as SessionMessageEntry\n\t\t\t\tthis.sessionManager.appendMessage(event.message);\n\t\t\t\tmessagePersisted = true;\n\t\t\t}\n\t\t\t// Other message types (bashExecution, compactionSummary, branchSummary) are persisted elsewhere\n\n\t\t\t// Track assistant message for auto-compaction (checked on agent_end)\n\t\t\tif (event.message.role === \"assistant\") {\n\t\t\t\tthis._lastAssistantMessage = event.message;\n\n\t\t\t\tconst assistantMsg = event.message as AssistantMessage;\n\t\t\t\tif (messagePersisted) {\n\t\t\t\t\tthis._pipeline.observeProviderUsage(this.agent.state.messages, assistantMsg);\n\t\t\t\t}\n\t\t\t\tif (assistantMsg.stopReason !== \"error\") {\n\t\t\t\t\tthis._overflowRecoveryAttempted = false;\n\t\t\t\t}\n\n\t\t\t\t// Reset retry counter immediately on successful assistant response\n\t\t\t\t// This prevents accumulation across multiple LLM calls within a turn\n\t\t\t\tif (assistantMsg.stopReason !== \"error\" && this._retryController.attempt > 0) {\n\t\t\t\t\tthis._emit({\n\t\t\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tattempt: this._retryController.attempt,\n\t\t\t\t\t});\n\t\t\t\t\tthis._retryController.reset();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate _willRetryAfterAgentEnd(event: Extract<AgentEvent, { type: \"agent_end\" }>): boolean {\n\t\tconst settings = this.settingsManager.getRetrySettings();\n\t\tif (!settings.enabled || this._retryController.attempt >= settings.maxRetries) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = event.messages.length - 1; i >= 0; i--) {\n\t\t\tconst message = event.messages[i];\n\t\t\tif (message.role === \"assistant\") {\n\t\t\t\treturn this._isRetryableError(message as AssistantMessage);\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Extract text content from a message */\n\tprivate _getUserMessageText(message: Message): string {\n\t\tif (message.role !== \"user\") return \"\";\n\t\tconst content = message.content;\n\t\tif (typeof content === \"string\") return content;\n\t\tconst textBlocks = content.filter((c) => c.type === \"text\");\n\t\treturn textBlocks.map((c) => (c as TextContent).text).join(\"\");\n\t}\n\n\t/** Find the last assistant message in agent state (including aborted ones) */\n\tprivate _findLastAssistantMessage(): AssistantMessage | undefined {\n\t\tconst messages = this.agent.state.messages;\n\t\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\t\tconst msg = messages[i];\n\t\t\tif (msg.role === \"assistant\") {\n\t\t\t\treturn msg as AssistantMessage;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate _replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void {\n\t\t// Agent-core stores the finalized message object in its state before emitting message_end.\n\t\t// SessionManager persistence happens later in _handleAgentEvent() with event.message.\n\t\t// Mutating this object in place keeps agent state, later turn/agent events, listeners,\n\t\t// and the eventual SessionManager.appendMessage(event.message) persistence in sync.\n\t\tif (target === replacement) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst targetRecord = target as unknown as Record<string, unknown>;\n\t\tfor (const key of Object.keys(targetRecord)) {\n\t\t\tdelete targetRecord[key];\n\t\t}\n\t\tObject.assign(targetRecord, replacement);\n\t}\n\n\t/** Emit extension events based on agent events */\n\tprivate async _emitExtensionEvent(event: AgentEvent): Promise<void> {\n\t\tif (event.type === \"agent_start\") {\n\t\t\tthis._turnIndex = 0;\n\t\t\tawait this._extensionRunner.emit({ type: \"agent_start\" });\n\t\t} else if (event.type === \"agent_end\") {\n\t\t\tawait this._extensionRunner.emit({ type: \"agent_end\", messages: event.messages });\n\t\t} else if (event.type === \"turn_start\") {\n\t\t\tthis._toolSelection.startTurn();\n\t\t\tthis._refreshForegroundEnvelope();\n\t\t\tconst extensionEvent: TurnStartEvent = {\n\t\t\t\ttype: \"turn_start\",\n\t\t\t\tturnIndex: this._turnIndex,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"turn_end\") {\n\t\t\tconst extensionEvent: TurnEndEvent = {\n\t\t\t\ttype: \"turn_end\",\n\t\t\t\tturnIndex: this._turnIndex,\n\t\t\t\tmessage: event.message,\n\t\t\t\ttoolResults: event.toolResults,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t\tthis._turnIndex++;\n\t\t} else if (event.type === \"message_start\") {\n\t\t\tconst extensionEvent: MessageStartEvent = {\n\t\t\t\ttype: \"message_start\",\n\t\t\t\tmessage: event.message,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"message_update\") {\n\t\t\tconst extensionEvent: MessageUpdateEvent = {\n\t\t\t\ttype: \"message_update\",\n\t\t\t\tmessage: event.message,\n\t\t\t\tassistantMessageEvent: event.assistantMessageEvent,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"message_end\") {\n\t\t\tconst extensionEvent: MessageEndEvent = {\n\t\t\t\ttype: \"message_end\",\n\t\t\t\tmessage: event.message,\n\t\t\t};\n\t\t\tconst replacement = await this._extensionRunner.emitMessageEnd(extensionEvent);\n\t\t\tif (replacement) {\n\t\t\t\tthis._replaceMessageInPlace(event.message, replacement);\n\t\t\t}\n\t\t} else if (event.type === \"tool_execution_start\") {\n\t\t\tconst extensionEvent: ToolExecutionStartEvent = {\n\t\t\t\ttype: \"tool_execution_start\",\n\t\t\t\ttoolCallId: event.toolCallId,\n\t\t\t\ttoolName: event.toolName,\n\t\t\t\targs: event.args,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"tool_execution_update\") {\n\t\t\tconst extensionEvent: ToolExecutionUpdateEvent = {\n\t\t\t\ttype: \"tool_execution_update\",\n\t\t\t\ttoolCallId: event.toolCallId,\n\t\t\t\ttoolName: event.toolName,\n\t\t\t\targs: event.args,\n\t\t\t\tpartialResult: event.partialResult,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t} else if (event.type === \"tool_execution_end\") {\n\t\t\tconst extensionEvent: ToolExecutionEndEvent = {\n\t\t\t\ttype: \"tool_execution_end\",\n\t\t\t\ttoolCallId: event.toolCallId,\n\t\t\t\ttoolName: event.toolName,\n\t\t\t\tresult: event.result,\n\t\t\t\tisError: event.isError,\n\t\t\t};\n\t\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\t}\n\t}\n\n\t/**\n\t * Subscribe to agent events.\n\t * Session persistence is handled internally (saves messages on message_end).\n\t * Multiple listeners can be added. Returns unsubscribe function for this listener.\n\t */\n\tsubscribe(listener: AgentSessionEventListener): () => void {\n\t\tthis._eventListeners.push(listener);\n\n\t\t// Return unsubscribe function for this specific listener\n\t\treturn () => {\n\t\t\tconst index = this._eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis._eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Subscribe to extensions changed events (load/unload live).\n\t * Returns unsubscribe function for this listener.\n\t */\n\tonExtensionsChanged(cb: () => void): () => void {\n\t\tthis._extensionsChangedListeners.push(cb);\n\n\t\treturn () => {\n\t\t\tconst index = this._extensionsChangedListeners.indexOf(cb);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis._extensionsChangedListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Notify all extensions-changed listeners.\n\t * Called after successful load/unload operations.\n\t */\n\tprivate _notifyExtensionsChanged(): void {\n\t\tfor (const listener of this._extensionsChangedListeners) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// Suppress errors from listeners to avoid cascading failures\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Temporarily disconnect from agent events.\n\t * User listeners are preserved and will receive events again after resubscribe().\n\t * Used internally during operations that need to pause event processing.\n\t */\n\tprivate _disconnectFromAgent(): void {\n\t\tif (this._unsubscribeAgent) {\n\t\t\tthis._unsubscribeAgent();\n\t\t\tthis._unsubscribeAgent = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Reconnect to agent events after _disconnectFromAgent().\n\t * Preserves all existing listeners.\n\t */\n\tprivate _reconnectToAgent(): void {\n\t\tif (this._unsubscribeAgent) return; // Already connected\n\t\tthis._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);\n\t}\n\n\t/**\n\t * Remove all listeners and disconnect from agent.\n\t * Call this when completely done with the session.\n\t */\n\tdispose(): void {\n\t\ttry {\n\t\t\tthis._backgroundLanes.clearGoalAutoContinueTimer();\n\t\t\tthis._backgroundLanes.clearResearchLaneTimer();\n\t\t\tthis.abortRetry();\n\t\t\tthis.abortCompaction();\n\t\t\tthis.abortBranchSummary();\n\t\t\tthis.abortBash();\n\t\t\tthis._cancelPrefixWarm();\n\t\t\tthis.agent.abort();\n\t\t\t// R8: stop any deployment-registered gateway channels / schedulers.\n\t\t\tvoid this._gatewayRegistry.stop().catch(() => {});\n\t\t\t// Bug #21: abort any in-flight background reflection so it cannot keep spending tokens or\n\t\t\t// write memory/skills against this now-disposed session.\n\t\t\tthis._disposed = true;\n\t\t\tthis._reflectionAbort.abort();\n\t\t\t// Abort any in-flight research pass or delegated worker for the same reason: a disposed\n\t\t\t// session must not keep spending tokens or persist evidence against dead state.\n\t\t\tthis._backgroundLanes.abortInFlightLanes();\n\t\t\t// Bug #20: clear the hooks this session installed on the shared agent so their closures stop\n\t\t\t// pinning this (deactivated) session — and all its history/maps — in memory if the agent\n\t\t\t// instance outlives the session.\n\t\t\tthis.agent.afterToolCall = undefined;\n\t\t\tthis.agent.transformContext = undefined;\n\t\t} catch {\n\t\t\t// Dispose must succeed even if an abort hook throws.\n\t\t}\n\n\t\tthis._extensionRunner.invalidate(\n\t\t\t\"This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().\",\n\t\t);\n\t\tthis._disconnectFromAgent();\n\t\tthis._eventListeners = [];\n\t\t// Best-effort memory cleanup (release locks/handles). Write-side onSessionEnd is wired on a\n\t\t// true session-end hook (P3); file-store shutdown is a no-op.\n\t\tvoid this._memory\n\t\t\t.getMemoryManager()\n\t\t\t.shutdownAll()\n\t\t\t.catch(() => {});\n\t\tvoid this._toolRecoveryLogger.shutdown().catch(() => {});\n\t\tcleanupSessionResources(this.sessionId);\n\t\t// Best-effort final sweep for any grep/find artifact already released (reference\n\t\t// count zero) but not yet reclaimed -- e.g. a release whose cleanup() call failed\n\t\t// transiently. This is conservative: it never releases a still-referenced\n\t\t// artifact, so a session that ends before context-gc ever evicts a result (too\n\t\t// short to cross preserveRecentMessages) correctly leaves that artifact in place,\n\t\t// resolvable if the same session is resumed later. It does not sweep OTHER\n\t\t// sessions' artifact directories.\n\t\ttry {\n\t\t\tthis._pipeline.cleanupToolArtifactStoreOnDispose();\n\t\t} catch {\n\t\t\t// Best-effort; dispose must succeed regardless.\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Read-only State Access\n\t// =========================================================================\n\n\t/** Full agent state */\n\tget state(): AgentState {\n\t\treturn this.agent.state;\n\t}\n\n\t/** Current model (may be undefined if not yet selected) */\n\tget model(): Model<any> | undefined {\n\t\treturn this.agent.state.model;\n\t}\n\n\t/** Current thinking level */\n\tget thinkingLevel(): ThinkingLevel {\n\t\treturn this.agent.state.thinkingLevel;\n\t}\n\n\t/** Whether agent is currently streaming a response */\n\tget isStreaming(): boolean {\n\t\treturn this.agent.state.isStreaming;\n\t}\n\n\t/** Current effective system prompt (includes any per-turn extension modifications) */\n\tget systemPrompt(): string {\n\t\treturn this.agent.state.systemPrompt;\n\t}\n\n\t/** Current retry attempt (0 if not retrying) */\n\tget retryAttempt(): number {\n\t\treturn this._retryController.attempt;\n\t}\n\n\t/**\n\t * Get the names of currently active tools.\n\t * Returns the names of tools currently set on the agent.\n\t */\n\tgetActiveToolNames(): string[] {\n\t\treturn this.agent.state.tools.map((t) => t.name);\n\t}\n\n\t/** G7: build a foreground {@link CapabilityEnvelope} from the live session state (active tools, cwd, cost ceiling). */\n\tprivate _buildForegroundEnvelopeFromState(): CapabilityEnvelope {\n\t\treturn buildForegroundEnvelope({\n\t\t\tturnIndex: this._turnIndex,\n\t\t\tactiveToolNames: this.getActiveToolNames(),\n\t\t\tcwd: this._cwd,\n\t\t\tmaxTurnUsd: this.settingsManager.getCostGuardSettings().maxTurnUsd,\n\t\t});\n\t}\n\n\t/**\n\t * G7: (re)build the foreground envelope for the current turn. Visibility only -- the foreground\n\t * envelope is NOT enforced this round. Best-effort: never throws into the turn.\n\t */\n\tprivate _refreshForegroundEnvelope(): void {\n\t\ttry {\n\t\t\tthis._currentForegroundEnvelope = this._buildForegroundEnvelopeFromState();\n\t\t} catch {\n\t\t\t// Visibility only: a failure to build the envelope must never disturb the turn.\n\t\t}\n\t}\n\n\t/** G7: the auto-constructed foreground envelope for the current/most-recent turn (visibility only). */\n\tgetForegroundEnvelope(): CapabilityEnvelope | undefined {\n\t\treturn this._currentForegroundEnvelope;\n\t}\n\n\t/**\n\t * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.\n\t */\n\tgetAllTools(): ToolInfo[] {\n\t\treturn this._runtimeBuilder.getAllTools();\n\t}\n\n\tgetToolDefinition(name: string): ToolDefinition | undefined {\n\t\treturn this._runtimeBuilder.getToolDefinition(name);\n\t}\n\n\t/**\n\t * Set active tools by name.\n\t * Only tools in the registry can be enabled. Unknown tool names are ignored.\n\t * Also rebuilds the system prompt to reflect the new tool set.\n\t * Changes take effect on the next agent turn.\n\t *\n\t * artifact_retrieve is auto-activated as a companion whenever an artifact-producing tool\n\t * (grep, find, or run_toolkit_script) ends up in the resulting active set and artifact_retrieve\n\t * is registered (i.e. not excluded/\n\t * blocked/outside an allowlist -- the registry itself is built with that same filter,\n\t * so registry presence already tracks \"allowed\"). This is enforced here, not just in\n\t * the settings/profile refresh flow, because this method is a public, extension-\n\t * exposed activation path (`setActiveTools`) on its own: without this, grep/find could\n\t * end up active while still being handed an artifact store (gated on \"allowed\" in\n\t * `_buildRuntime`) with no active tool able to resolve the resulting\n\t * \"Full output: artifact tool-output:<id>\" handle.\n\t */\n\tsetActiveToolsByName(toolNames: string[]): void {\n\t\t// Model capability: small-window models get a reduced tool surface derived from the model's\n\t\t// own metadata. The unfiltered request is remembered so a later switch to a larger model\n\t\t// restores it (the filter is re-applied on every model change).\n\t\tthis._requestedActiveToolNames = [...toolNames];\n\t\tconst capabilityFiltered = filterToolNamesForCapability(toolNames, this.getModelCapabilityProfile());\n\n\t\tconst tools: AgentTool[] = [];\n\t\tconst validToolNames: string[] = [];\n\t\tconst seen = new Set<string>();\n\t\tconst addIfRegistered = (name: string): void => {\n\t\t\tif (seen.has(name)) return;\n\t\t\tconst tool = this._runtimeBuilder.getRegisteredTool(name);\n\t\t\tif (!tool) return;\n\t\t\tseen.add(name);\n\t\t\ttools.push(tool);\n\t\t\tvalidToolNames.push(name);\n\t\t};\n\n\t\tfor (const name of capabilityFiltered) {\n\t\t\taddIfRegistered(name);\n\t\t}\n\t\tif (\n\t\t\tvalidToolNames.includes(\"grep\") ||\n\t\t\tvalidToolNames.includes(\"find\") ||\n\t\t\tvalidToolNames.includes(\"run_toolkit_script\")\n\t\t) {\n\t\t\taddIfRegistered(\"artifact_retrieve\");\n\t\t}\n\t\tif (validToolNames.includes(\"delegate\")) {\n\t\t\taddIfRegistered(\"delegate_status\");\n\t\t}\n\n\t\tthis.agent.state.tools = tools;\n\n\t\t// Rebuild base system prompt with new tool set\n\t\tthis._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);\n\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\n\t\tthis._checkContextWindowUsageWarning();\n\t}\n\n\t/** Whether compaction or branch summarization is currently running */\n\tget isCompacting(): boolean {\n\t\treturn (\n\t\t\tthis._autoCompactionAbortController !== undefined ||\n\t\t\tthis._compactionAbortController !== undefined ||\n\t\t\tthis._branchSummaryAbortController !== undefined\n\t\t);\n\t}\n\n\t/** All messages including custom types like BashExecutionMessage */\n\tget messages(): AgentMessage[] {\n\t\treturn this.agent.state.messages;\n\t}\n\n\t/** Current steering mode */\n\tget steeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.agent.steeringMode;\n\t}\n\n\t/** Current follow-up mode */\n\tget followUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.agent.followUpMode;\n\t}\n\n\t/** Current session file path, or undefined if sessions are disabled */\n\tget sessionFile(): string | undefined {\n\t\treturn this.sessionManager.getSessionFile();\n\t}\n\n\t/** Current session ID */\n\tget sessionId(): string {\n\t\treturn this.sessionManager.getSessionId();\n\t}\n\n\t/** Current session display name, if set */\n\tget sessionName(): string | undefined {\n\t\treturn this.sessionManager.getSessionName();\n\t}\n\n\t/** Scoped models for cycling (from --models flag) */\n\tget scopedModels(): ReadonlyArray<{ model: Model<any>; thinkingLevel?: ThinkingLevel }> {\n\t\treturn this._scopedModels;\n\t}\n\n\t/** Update scoped models for cycling */\n\tsetScopedModels(scopedModels: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>): void {\n\t\tthis._scopedModels = scopedModels;\n\t}\n\n\t/** File-based prompt templates */\n\tget promptTemplates(): ReadonlyArray<PromptTemplate> {\n\t\treturn this._resourceLoader.getActivePrompts();\n\t}\n\n\t// System-prompt construction lives in SystemPromptBuilder (see system-prompt-builder.ts). These\n\t// stubs keep the god file's internal call surface stable while the assembly logic — situational\n\t// soul, self-modification/autonomy guardrails, per-tool snippet/guideline options — lives there.\n\tprivate _normalizePromptSnippet(text: string | undefined): string | undefined {\n\t\treturn this._systemPromptBuilder.normalizePromptSnippet(text);\n\t}\n\n\tprivate _normalizePromptGuidelines(guidelines: string[] | undefined): string[] {\n\t\treturn this._systemPromptBuilder.normalizePromptGuidelines(guidelines);\n\t}\n\n\tprivate _rebuildSystemPrompt(toolNames: string[]): string {\n\t\treturn this._systemPromptBuilder.rebuildSystemPrompt(toolNames);\n\t}\n\n\tprivate _refreshBaseSystemPrompt(): void {\n\t\tconst previousBaseSystemPrompt = this._baseSystemPrompt;\n\t\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\t\tif (this.agent.state.systemPrompt === previousBaseSystemPrompt) {\n\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t}\n\t}\n\n\t/**\n\t * Build a system prompt for a specific tool surface WITHOUT touching the session's base prompt\n\t * state (G4 router-swap; see {@link SystemPromptBuilder.buildSystemPromptForToolNames}).\n\t */\n\tprivate _buildSystemPromptForToolNames(toolNames: string[]): string {\n\t\treturn this._systemPromptBuilder.buildSystemPromptForToolNames(toolNames);\n\t}\n\n\t// =========================================================================\n\t// Prompting\n\t// =========================================================================\n\n\tprivate async _runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void> {\n\t\ttry {\n\t\t\tconst maxGoalLoopRounds = this.settingsManager.getAutonomySettings().maxStallTurns;\n\t\t\tthis.agent.maxStallTurns = maxGoalLoopRounds;\n\t\t\tawait this._ensureTextToolProtocolForActiveModel();\n\t\t\tlet goalLoopRounds = 1;\n\t\t\tawait this.agent.prompt(messages);\n\t\t\twhile ((maxGoalLoopRounds === 0 || goalLoopRounds < maxGoalLoopRounds) && (await this._handlePostAgentRun())) {\n\t\t\t\tawait this.agent.continue();\n\t\t\t\tgoalLoopRounds++;\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._flushPendingBashMessages();\n\t\t\tawait this._drainQueuedExtensionCommands();\n\t\t}\n\t}\n\n\t/**\n\t * Shared {@link OllamaRuntime} for a given server, lazily created and cached by baseUrl so every\n\t * caller — the router's readiness gate and any host UI's own model-lifecycle commands (e.g.\n\t * `/models`) — sees and can stop the SAME pi-managed process instead of each tracking its own\n\t * untracked child. Delegates to {@link LocalRuntimeController}.\n\t */\n\tgetLocalRuntime(baseUrl?: string): OllamaRuntime {\n\t\treturn this._localRuntimeController.getLocalRuntime(baseUrl);\n\t}\n\n\tgetTransformersRuntime(modelId: string, baseUrl?: string): TransformersRuntime {\n\t\treturn this._localRuntimeController.getTransformersRuntime(modelId, baseUrl);\n\t}\n\n\t/** models.json registers a local model's baseUrl as `<server>/v1` (OpenAI-compat); the runtime's\n\t * own health/boot endpoints are on the Ollama-native server root. Delegates to\n\t * {@link LocalRuntimeController}; kept here for `_warnIfManualModelChoiceIsRisky`'s own use. */\n\tprivate _deriveOllamaServerUrl(modelBaseUrl: string): string {\n\t\treturn this._localRuntimeController.deriveOllamaServerUrl(modelBaseUrl);\n\t}\n\n\t/**\n\t * Router-swap gate (#27): a turn routed to a local model must not dead-end the turn just because\n\t * ollama isn't up. Delegates to {@link LocalRuntimeController}; see there for the full\n\t * consent-then-escalate contract (which includes the local-model readiness check itself).\n\t */\n\tprivate async _ensureRouteModelReady(\n\t\tresolved: { decision: RouteDecision; model: Model<Api> } | undefined,\n\t): Promise<{ decision: RouteDecision; model: Model<Api> } | undefined> {\n\t\treturn this._localRuntimeController.ensureRouteModelReady(resolved);\n\t}\n\n\tgetModelRouterStatus(formatLabel?: (label: string) => string): string {\n\t\treturn this._modelRouter.getStatus(formatLabel);\n\t}\n\n\tprivate async _handlePostAgentRun(): Promise<boolean> {\n\t\tconst msg = this._lastAssistantMessage;\n\t\tthis._lastAssistantMessage = undefined;\n\t\tif (!msg) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst classified = this._classifyAssistantError(msg);\n\t\tif (classified) {\n\t\t\tthis._failureCorpus.record({\n\t\t\t\tprovider: msg.provider,\n\t\t\t\tmodelId: msg.model,\n\t\t\t\tmessage: msg.errorMessage ?? \"\",\n\t\t\t\tclassified,\n\t\t\t});\n\t\t}\n\t\tif (classified?.retryable && (await this._prepareRetry(msg))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (await this._billingFailover.handleAssistantError(msg, classified)) return false;\n\n\t\tif (msg.stopReason === \"error\" && this._retryController.attempt > 0) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\tsuccess: false,\n\t\t\t\tattempt: this._retryController.attempt,\n\t\t\t\tfinalError: msg.errorMessage,\n\t\t\t});\n\t\t\tthis._retryController.reset();\n\t\t}\n\n\t\tif (await this._checkCompaction(msg)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// The agent loop drains both queues before emitting agent_end. Any messages\n\t\t// here were queued by agent_end extension handlers and need a continuation.\n\t\treturn this.agent.hasQueuedMessages();\n\t}\n\n\t/**\n\t * Send a prompt to the agent.\n\t * - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming\n\t * - Expands file-based prompt templates by default\n\t * - During streaming, queues via steer() or followUp() based on streamingBehavior option\n\t * - Validates model and API key before sending (when not streaming)\n\t * @throws Error if streaming and no streamingBehavior specified\n\t * @throws Error if no model selected or no API key available (when not streaming)\n\t */\n\tasync prompt(text: string, options?: PromptOptions): Promise<void> {\n\t\tif (options?.autoContinueGoal !== false) {\n\t\t\tthis._backgroundLanes.clearGoalAutoContinueTimer();\n\t\t}\n\n\t\tif ((this.isStreaming || this.isRetrying) && options?.streamingBehavior) {\n\t\t\tconst run = this._streamingPromptSubmissionTail.then(\n\t\t\t\t() => this._promptUnserialized(text, options),\n\t\t\t\t() => this._promptUnserialized(text, options),\n\t\t\t);\n\t\t\tthis._streamingPromptSubmissionTail = run.catch(() => {});\n\t\t\treturn run;\n\t\t}\n\t\treturn this._promptUnserialized(text, options);\n\t}\n\n\tprivate async _promptUnserialized(text: string, options?: PromptOptions): Promise<void> {\n\t\tthis._applyToolRepairLayerSettings();\n\t\tthis._cancelPrefixWarm();\n\t\tconst expandPromptTemplates = options?.expandPromptTemplates ?? true;\n\t\tconst processSlashCommands = options?.processSlashCommands ?? expandPromptTemplates;\n\t\tconst preflightResult = options?.preflightResult;\n\t\tlet messages: AgentMessage[] | undefined;\n\t\tlet routedTurnModel: Model<Api> | undefined;\n\t\tlet routedTurnRouteDecision: RouteDecision | undefined;\n\t\t// Built and painted early (see below) so a later throw in this try block — e.g. no model\n\t\t// selected/authenticated — can un-register it from _earlyDisplayedUserMessages instead of\n\t\t// leaking the reference forever.\n\t\tlet userMessage: AgentMessage | undefined;\n\t\t// R4 effectiveness feedback: remember the recall page + the query so we can score, after the\n\t\t// response, whether the agent actually used the recalled context.\n\t\tlet injectedRecall = \"\";\n\t\tlet recallQuery = \"\";\n\n\t\ttry {\n\t\t\t// Handle extension commands first. Programmatic extension messages may opt\n\t\t\t// into command handling; if the agent is currently streaming, queue the\n\t\t\t// command for the end of the run instead of sending it to the model.\n\t\t\tif (processSlashCommands && text.startsWith(\"/\")) {\n\t\t\t\tif (this.isStreaming && options?.source === \"extension\" && options?.streamingBehavior) {\n\t\t\t\t\tconst commandName = this._parseCommandName(text);\n\t\t\t\t\tif (this._extensionRunner.getCommand(commandName)) {\n\t\t\t\t\t\tthis._queueExtensionCommand(text);\n\t\t\t\t\t\tpreflightResult?.(true);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst handled = await this._tryExecuteExtensionCommand(text);\n\t\t\t\tif (handled) {\n\t\t\t\t\t// Extension command executed, no prompt to send\n\t\t\t\t\tpreflightResult?.(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Emit input event for extension interception (before skill/template expansion)\n\t\t\tlet currentText = text;\n\t\t\tlet currentImages = options?.images;\n\t\t\tif (this._extensionRunner.hasHandlers(\"input\")) {\n\t\t\t\tconst inputResult = await this._extensionRunner.emitInput(\n\t\t\t\t\tcurrentText,\n\t\t\t\t\tcurrentImages,\n\t\t\t\t\toptions?.source ?? \"interactive\",\n\t\t\t\t\tthis.isStreaming ? options?.streamingBehavior : undefined,\n\t\t\t\t);\n\t\t\t\tif (inputResult.action === \"handled\") {\n\t\t\t\t\tpreflightResult?.(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (inputResult.action === \"transform\") {\n\t\t\t\t\tcurrentText = inputResult.text;\n\t\t\t\t\tcurrentImages = inputResult.images ?? currentImages;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Expand skill commands (/skill:name args) and prompt templates (/template args)\n\t\t\tlet expandedText = currentText;\n\t\t\tif (expandPromptTemplates) {\n\t\t\t\texpandedText = this._expandSkillCommand(expandedText);\n\t\t\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\t\t\t}\n\n\t\t\t// If streaming — or waiting out a retry backoff, which is still an active\n\t\t\t// operation — queue via steer() or followUp() instead of starting a\n\t\t\t// concurrent run that would race the pending retry continuation.\n\t\t\tif (this.isStreaming || this.isRetrying) {\n\t\t\t\tif (!options?.streamingBehavior) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (options.streamingBehavior === \"followUp\") {\n\t\t\t\t\tawait this._queueFollowUp(expandedText, currentImages);\n\t\t\t\t} else {\n\t\t\t\t\tawait this._queueSteer(expandedText, currentImages);\n\t\t\t\t}\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Flush any pending bash messages before the new prompt\n\t\t\tthis._flushPendingBashMessages();\n\n\t\t\t// Build the user message now — before the router judge — and paint it to the UI\n\t\t\t// immediately via a synthetic message_start. The judge is a real bounded LLM completion\n\t\t\t// (seconds), not a regex; awaiting it first made the prompt appear to hang. The\n\t\t\t// authoritative message_start emitted later for this SAME object is suppressed in\n\t\t\t// _handleAgentEvent (see _earlyDisplayedUserMessages) so it is still shown exactly once.\n\t\t\tconst userContent: (TextContent | ImageContent)[] = [{ type: \"text\", text: expandedText }];\n\t\t\tif (currentImages) {\n\t\t\t\tuserContent.push(...currentImages);\n\t\t\t}\n\t\t\tuserMessage = {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: userContent,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\t\t\tthis._earlyDisplayedUserMessages.add(userMessage);\n\t\t\tthis._emit({ type: \"message_start\", message: userMessage });\n\n\t\t\t// Bracket the routing/prep phase (judge, model/auth checks, compaction, ...) so the UI can\n\t\t\t// show general \"working\" feedback for it — otherwise the user stares at their own echoed\n\t\t\t// prompt with nothing happening for however long the judge takes. routing_end is emitted\n\t\t\t// exactly once below: either in the catch block (this phase failed) or right after the try\n\t\t\t// block (this phase succeeded, whether or not it produced a turn to run).\n\t\t\tthis._emit({ type: \"routing_start\" });\n\n\t\t\tconst resolvedRouteInfo = await this._modelRouter.resolveTurnRouteJudged(expandedText, {\n\t\t\t\t// Internally generated turns (goal continuation, lane follow-ups) never consult the judge:\n\t\t\t\t// the regex floor already classified them, and a 20-turn loop must not buy 20 judge calls.\n\t\t\t\tskipJudge: options?.autoContinueGoal === false,\n\t\t\t});\n\t\t\t// #27: a route landing on a local (ollama) model must not hard-fail the turn just because\n\t\t\t// the server isn't up yet — boot/reuse it here, or escalate to a non-local tier.\n\t\t\tconst readyRouteInfo = await this._ensureRouteModelReady(resolvedRouteInfo);\n\t\t\troutedTurnModel = readyRouteInfo?.model;\n\t\t\troutedTurnRouteDecision = readyRouteInfo?.decision;\n\t\t\tconst requestModel = routedTurnModel ?? this.model;\n\n\t\t\t// Validate model\n\t\t\tif (!requestModel) {\n\t\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t\t}\n\t\t\t// A manual/default local model has no RouteDecision, so the router readiness gate above is\n\t\t\t// intentionally a no-op. It still needs the same managed-runtime boot/residency guarantee.\n\t\t\tif (!resolvedRouteInfo) {\n\t\t\t\tawait this._localRuntimeController.ensureForegroundModelReady(requestModel);\n\t\t\t}\n\n\t\t\tif (!this._modelRegistry.hasConfiguredAuth(requestModel)) {\n\t\t\t\tconst isOAuth = this._modelRegistry.isUsingOAuth(requestModel);\n\t\t\t\tif (isOAuth) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Authentication failed for \"${requestModel.provider}\". ` +\n\t\t\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t\t\t`Run '/login ${requestModel.provider}' to re-authenticate.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new Error(formatNoApiKeyFoundMessage(requestModel.provider));\n\t\t\t}\n\n\t\t\tthis._checkContextWindowUsageWarning();\n\n\t\t\t// Check if we need to compact before sending (catches aborted responses).\n\t\t\t// Do not call agent.continue() here: the next model turn must include the\n\t\t\t// user's pending prompt, not an empty continuation after compaction.\n\t\t\tconst lastAssistant = this._findLastAssistantMessage();\n\t\t\tif (lastAssistant) {\n\t\t\t\tawait this._checkCompaction(lastAssistant, false);\n\t\t\t}\n\n\t\t\t// Build messages array (recall page, then custom message if any, then user message)\n\t\t\tmessages = [];\n\n\t\t\t// R3: cross-session similarity recall. For a substantive turn, ask the memory providers to\n\t\t\t// prefetch a relevant <memory_context> page from past sessions and prepend it as data ahead of\n\t\t\t// the user message. Best-effort and gated: trivial turns are skipped, and providers return \"\"\n\t\t\t// (no page) when nothing is relevant — so it stays net-negative and the GC packs stale pages.\n\t\t\tif (this._memory.shouldAttemptRecall(expandedText)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst recall = await this._memory.prefetchRecall(expandedText);\n\t\t\t\t\tif (recall) {\n\t\t\t\t\t\tinjectedRecall = recall;\n\t\t\t\t\t\trecallQuery = expandedText;\n\t\t\t\t\t\t// Inject as a GC-managed custom context message (role \"custom\", customType\n\t\t\t\t\t\t// \"memory_context\"), NOT a persisted user message: the semantic-memory context-GC packs\n\t\t\t\t\t\t// stale recall pages so they don't accumulate forever (Bug #7), and the transcript index\n\t\t\t\t\t\t// only re-reads user/assistant text so recalled snippets can't recirculate (Bug #10).\n\t\t\t\t\t\tmessages.push(\n\t\t\t\t\t\t\tcreateCustomMessage(\"memory_context\", recall, false, undefined, new Date().toISOString()),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// recall must never break a turn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add user message (built earlier, before the router judge, so it could be painted\n\t\t\t// immediately — see the early message_start emit above).\n\t\t\tmessages.push(userMessage);\n\n\t\t\t// Inject any pending \"nextTurn\" messages as context alongside the user message\n\t\t\tfor (const msg of this._pendingNextTurnMessages) {\n\t\t\t\tmessages.push(msg);\n\t\t\t}\n\t\t\tthis._pendingNextTurnMessages = [];\n\n\t\t\tconst taskStepsState = this.getTaskStepsStateSnapshot();\n\t\t\tconst taskStepsContext = taskStepsState ? formatTaskStepsContext(taskStepsState) : undefined;\n\t\t\tif (taskStepsState && taskStepsContext) {\n\t\t\t\tmessages.push(\n\t\t\t\t\tcreateCustomMessage(\n\t\t\t\t\t\t\"task_steps_context\",\n\t\t\t\t\t\ttaskStepsContext,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t{ revision: taskStepsState.revision },\n\t\t\t\t\t\tnew Date().toISOString(),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Emit before_agent_start extension event\n\t\t\tconst result = await this._extensionRunner.emitBeforeAgentStart(\n\t\t\t\texpandedText,\n\t\t\t\tcurrentImages,\n\t\t\t\tthis._baseSystemPrompt,\n\t\t\t\tthis._systemPromptBuilder.getBaseSystemPromptOptions(),\n\t\t\t);\n\t\t\t// Add all custom messages from extensions\n\t\t\tif (result?.messages) {\n\t\t\t\tfor (const msg of result.messages) {\n\t\t\t\t\tmessages.push({\n\t\t\t\t\t\trole: \"custom\",\n\t\t\t\t\t\tcustomType: msg.customType,\n\t\t\t\t\t\tcontent: msg.content,\n\t\t\t\t\t\tdisplay: msg.display,\n\t\t\t\t\t\tdetails: msg.details,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Apply extension-modified system prompt, or reset to base\n\t\t\tif (result?.systemPrompt) {\n\t\t\t\tthis.agent.state.systemPrompt = result.systemPrompt;\n\t\t\t} else {\n\t\t\t\t// Ensure we're using the base prompt (in case previous turn had modifications)\n\t\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The turn never reached _runAgentPrompt, so the authoritative message_start that would\n\t\t\t// normally consume this entry (see _handleAgentEvent) never fires — un-register it here\n\t\t\t// instead of leaking the reference.\n\t\t\tif (userMessage) {\n\t\t\t\tthis._earlyDisplayedUserMessages.delete(userMessage);\n\t\t\t}\n\t\t\t// The routing/prep phase (routing_start above) failed before ever reaching the turn — end\n\t\t\t// it here, or the UI's \"working\" indicator for it spins forever with nothing behind it.\n\t\t\tthis._emit({ type: \"routing_end\" });\n\t\t\tpreflightResult?.(false);\n\t\t\tthrow error;\n\t\t}\n\n\t\t// The routing/prep phase is over — either we're about to hand off into the turn (which emits\n\t\t// its own agent_start/streaming events right after), or messages is unexpectedly unset and we\n\t\t// bail below. Either way nothing is left \"routing\" past this point.\n\t\tthis._emit({ type: \"routing_end\" });\n\n\t\tif (!messages) {\n\t\t\treturn;\n\t\t}\n\n\t\tpreflightResult?.(true);\n\t\tthis._textProtocolParseObservedThisTurn = false;\n\t\tthis._textProtocolValidationOutcomeThisTurn = undefined;\n\t\tawait this._modelRouter.runRoutedTurn(messages, routedTurnModel, routedTurnRouteDecision);\n\t\tthis._recordTextToolProtocolParseOutcomeFromLastAssistant();\n\n\t\t// R4: score whether the agent actually used the recalled context, so the recall gate can adapt.\n\t\tif (injectedRecall) {\n\t\t\tconst response = this._findLastAssistantMessage();\n\t\t\tconst responseText = response\n\t\t\t\t? response.content\n\t\t\t\t\t\t.filter((c): c is TextContent => c.type === \"text\")\n\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t.join(\" \")\n\t\t\t\t: \"\";\n\t\t\tif (responseText) {\n\t\t\t\tthis._memory.recordRecallOutcome(injectedRecall, recallQuery, responseText);\n\t\t\t}\n\t\t}\n\n\t\tthis._backgroundLanes.drainQueuedWorkerDelegations();\n\t\tthis._backgroundLanes.scheduleGoalAutoContinueFromIdle(options);\n\t\tthis._backgroundLanes.scheduleResearchLaneFromIdle();\n\t}\n\n\t/**\n\t * Try to execute an extension command. Returns true if command was found and executed.\n\t */\n\tprivate _parseCommandName(text: string): string {\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\treturn spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\t}\n\n\tprivate async _tryExecuteExtensionCommand(text: string): Promise<boolean> {\n\t\t// Parse command name and args\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\tconst commandName = this._parseCommandName(text);\n\t\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\n\t\tconst command = this._extensionRunner.getCommand(commandName);\n\t\tif (!command) return false;\n\n\t\t// Get command context from extension runner (includes session control methods)\n\t\tconst ctx = this._extensionRunner.createCommandContext();\n\n\t\ttry {\n\t\t\tawait command.handler(args, ctx);\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\t// Emit error via extension runner\n\t\t\tthis._extensionRunner.emitError({\n\t\t\t\textensionPath: `command:${commandName}`,\n\t\t\t\tevent: \"command\",\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t});\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t/**\n\t * Expand skill commands (/skill:name args) to their full content.\n\t * Returns the expanded text, or the original text if not a skill command or skill not found.\n\t * Emits errors via extension runner if file read fails.\n\t */\n\tprivate _expandSkillCommand(text: string): string {\n\t\tif (!text.startsWith(\"/skill:\")) return text;\n\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\tconst skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n\t\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1).trim();\n\n\t\t// Resolve only against profile-active skills so a `/skill:` the active profile blocks cannot be\n\t\t// expanded/invoked — by the user OR the agent — even if it loaded before a runtime profile switch.\n\t\tconst skill = this.resourceLoader.getActiveSkills().find((s) => s.name === skillName);\n\t\tif (!skill) return text; // Unknown or profile-blocked skill, pass through unchanged\n\n\t\ttry {\n\t\t\tconst content = readFileSync(skill.filePath, \"utf-8\");\n\t\t\t// Curator (#32): record use of a reflection-PROMOTED skill so stale ones can later be proposed\n\t\t\t// for archival. Only promoted skills carry the marker, so hand-authored skills are untouched.\n\t\t\tif (isPromotedFrontmatter(content)) {\n\t\t\t\tthis._skillCurator.recordUse(skill.name, Date.now());\n\t\t\t}\n\t\t\tconst body = stripResourceProfileBlocks(stripFrontmatter(content)).trim();\n\t\t\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n\t\t\treturn args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n\t\t} catch (err) {\n\t\t\t// Emit error like extension commands do\n\t\t\tthis._extensionRunner.emitError({\n\t\t\t\textensionPath: skill.filePath,\n\t\t\t\tevent: \"skill_expansion\",\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t});\n\t\t\treturn text; // Return original on error\n\t\t}\n\t}\n\n\t/**\n\t * Queue a steering message while the agent is running.\n\t * Delivered after the current assistant turn finishes executing its tool calls,\n\t * before the next LLM call.\n\t * Expands skill commands and prompt templates. Errors on extension commands.\n\t * @param images Optional image attachments to include with the message\n\t * @throws Error if text is an extension command\n\t */\n\tasync steer(text: string, images?: ImageContent[]): Promise<void> {\n\t\t// Check for extension commands (cannot be queued)\n\t\tif (text.startsWith(\"/\")) {\n\t\t\tthis._throwIfExtensionCommand(text);\n\t\t}\n\n\t\t// Expand skill commands and prompt templates\n\t\tlet expandedText = this._expandSkillCommand(text);\n\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\t\tawait this._queueSteer(expandedText, images);\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t * Expands skill commands and prompt templates. Errors on extension commands.\n\t * @param images Optional image attachments to include with the message\n\t * @throws Error if text is an extension command\n\t */\n\tasync followUp(text: string, images?: ImageContent[]): Promise<void> {\n\t\t// Check for extension commands (cannot be queued)\n\t\tif (text.startsWith(\"/\")) {\n\t\t\tthis._throwIfExtensionCommand(text);\n\t\t}\n\n\t\t// Expand skill commands and prompt templates\n\t\tlet expandedText = this._expandSkillCommand(text);\n\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\t\tawait this._queueFollowUp(expandedText, images);\n\t}\n\n\t/**\n\t * Internal: Queue a steering message (already expanded, no extension command check).\n\t */\n\tprivate async _queueSteer(text: string, images?: ImageContent[]): Promise<void> {\n\t\tthis._steeringMessages.push(text);\n\t\tthis._emitQueueUpdate();\n\t\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\t\tif (images) {\n\t\t\tcontent.push(...images);\n\t\t}\n\t\tthis.agent.steer({\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\t}\n\n\t/**\n\t * Internal: Queue a follow-up message (already expanded, no extension command check).\n\t */\n\tprivate async _queueFollowUp(text: string, images?: ImageContent[]): Promise<void> {\n\t\tthis._followUpMessages.push(text);\n\t\tthis._emitQueueUpdate();\n\t\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\t\tif (images) {\n\t\t\tcontent.push(...images);\n\t\t}\n\t\tthis.agent.followUp({\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\t}\n\n\t/**\n\t * Internal: Queue an extension command to execute after the current agent run.\n\t */\n\tprivate _queueExtensionCommand(text: string): void {\n\t\tthis._queuedExtensionCommands.push(text);\n\t\tthis._emitQueueUpdate();\n\t}\n\n\tprivate async _drainQueuedExtensionCommands(): Promise<void> {\n\t\twhile (this._queuedExtensionCommands.length > 0 && !this.isStreaming) {\n\t\t\tconst commandText = this._queuedExtensionCommands.shift()!;\n\t\t\tthis._emitQueueUpdate();\n\t\t\tawait this._tryExecuteExtensionCommand(commandText);\n\t\t}\n\t}\n\n\t/**\n\t * Throw an error if the text is an extension command.\n\t */\n\tprivate _throwIfExtensionCommand(text: string): void {\n\t\tconst spaceIndex = text.indexOf(\" \");\n\t\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\t\tconst command = this._extensionRunner.getCommand(commandName);\n\n\t\tif (command) {\n\t\t\tthrow new Error(\n\t\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Send a custom message to the session. Creates a CustomMessageEntry.\n\t *\n\t * Handles three cases:\n\t * - Streaming: queues message, processed when loop pulls from queue\n\t * - Not streaming + triggerTurn: appends to state/session, starts new turn\n\t * - Not streaming + no trigger: appends to state/session, no turn\n\t *\n\t * @param message Custom message with customType, content, display, details\n\t * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n\t * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", or \"nextTurn\"\n\t */\n\tasync sendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void> {\n\t\tconst appMessage = {\n\t\t\trole: \"custom\" as const,\n\t\t\tcustomType: message.customType,\n\t\t\tcontent: message.content,\n\t\t\tdisplay: message.display,\n\t\t\tdetails: message.details,\n\t\t\ttimestamp: Date.now(),\n\t\t} satisfies CustomMessage<T>;\n\t\tif (options?.deliverAs === \"nextTurn\") {\n\t\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t\t} else if (this.isStreaming) {\n\t\t\tif (options?.deliverAs === \"followUp\") {\n\t\t\t\tthis.agent.followUp(appMessage);\n\t\t\t} else {\n\t\t\t\tthis.agent.steer(appMessage);\n\t\t\t}\n\t\t} else if (options?.triggerTurn) {\n\t\t\tawait this._runAgentPrompt(appMessage);\n\t\t} else {\n\t\t\tthis.agent.state.messages.push(appMessage);\n\t\t\tthis.sessionManager.appendCustomMessageEntry(\n\t\t\t\tmessage.customType,\n\t\t\t\tmessage.content,\n\t\t\t\tmessage.display,\n\t\t\t\tmessage.details,\n\t\t\t);\n\t\t\tthis._emit({ type: \"message_start\", message: appMessage });\n\t\t\tthis._emit({ type: \"message_end\", message: appMessage });\n\t\t}\n\t}\n\n\t/**\n\t * Send a user message to the agent. Always triggers a turn.\n\t * When the agent is streaming, use deliverAs to specify how to queue the message.\n\t *\n\t * @param content User message content (string or content array)\n\t * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n\t */\n\tasync sendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; processSlashCommands?: boolean },\n\t): Promise<void> {\n\t\t// Normalize content to text string + optional images\n\t\tlet text: string;\n\t\tlet images: ImageContent[] | undefined;\n\n\t\tif (typeof content === \"string\") {\n\t\t\ttext = content;\n\t\t} else {\n\t\t\tconst textParts: string[] = [];\n\t\t\timages = [];\n\t\t\tfor (const part of content) {\n\t\t\t\tif (part.type === \"text\") {\n\t\t\t\t\ttextParts.push(part.text);\n\t\t\t\t} else {\n\t\t\t\t\timages.push(part);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttext = textParts.join(\"\\n\");\n\t\t\tif (images.length === 0) images = undefined;\n\t\t}\n\n\t\t// Skip skill/template expansion by default. Extensions that intentionally\n\t\t// want slash commands to execute (for example self-maintenance reloads)\n\t\t// can opt in with processSlashCommands.\n\t\tawait this.prompt(text, {\n\t\t\texpandPromptTemplates: false,\n\t\t\tprocessSlashCommands: options?.processSlashCommands ?? false,\n\t\t\tstreamingBehavior: options?.deliverAs,\n\t\t\timages,\n\t\t\tsource: \"extension\",\n\t\t});\n\t}\n\n\t/**\n\t * Clear all queued messages and return them.\n\t * Useful for restoring to editor when user aborts.\n\t * @returns Object with steering, followUp, and queued extension command arrays\n\t */\n\tclearQueue(): { steering: string[]; followUp: string[]; commands: string[] } {\n\t\tconst steering = [...this._steeringMessages];\n\t\tconst followUp = [...this._followUpMessages];\n\t\tconst commands = [...this._queuedExtensionCommands];\n\t\tthis._steeringMessages = [];\n\t\tthis._followUpMessages = [];\n\t\tthis._queuedExtensionCommands = [];\n\t\tthis.agent.clearAllQueues();\n\t\tthis._emitQueueUpdate();\n\t\treturn { steering, followUp, commands };\n\t}\n\n\t/** Number of pending messages (includes steering, follow-up, and queued extension commands) */\n\tget pendingMessageCount(): number {\n\t\treturn this._steeringMessages.length + this._followUpMessages.length + this._queuedExtensionCommands.length;\n\t}\n\n\t/** Get pending steering messages (read-only) */\n\tgetSteeringMessages(): readonly string[] {\n\t\treturn this._steeringMessages;\n\t}\n\n\t/** Get pending follow-up messages (read-only) */\n\tgetFollowUpMessages(): readonly string[] {\n\t\treturn this._followUpMessages;\n\t}\n\n\t/** Get pending extension commands (read-only). */\n\tgetQueuedExtensionCommands(): readonly string[] {\n\t\treturn this._queuedExtensionCommands;\n\t}\n\n\tget resourceLoader(): ResourceLoader {\n\t\treturn this._resourceLoader;\n\t}\n\n\t/**\n\t * Abort current operation and wait for agent to become idle.\n\t */\n\tasync abort(): Promise<void> {\n\t\tthis.abortRetry();\n\t\tthis.agent.abort();\n\t\tawait this.agent.waitForIdle();\n\t}\n\n\t// =========================================================================\n\t// Model Management\n\t// =========================================================================\n\n\tasync setModel(model: Model<any>, options: { persistSettings?: boolean } = {}): Promise<void> {\n\t\tawait this._modelSelection.setModel(model, options);\n\t\tthis._scheduleLocalPrefixWarm(this.agent.state.model, \"selection\");\n\t}\n\n\t/** Re-resolve startup profile model/thinking after allowed extension providers are bound. */\n\tasync reapplyActiveProfileModelSettings(): Promise<void> {\n\t\tconst previousModel = this.model;\n\t\tawait this._profileFilter.reapplyActiveProfileModelSettings();\n\t\tconst activeToolNames = this._requestedActiveToolNames ?? this.getActiveToolNames();\n\t\tthis._refreshToolRegistry({ activeToolNames, includeAllExtensionTools: true });\n\t\tif (!modelsAreEqual(previousModel, this.model)) {\n\t\t\tthis._scheduleLocalPrefixWarm(this.model, \"selection\");\n\t\t}\n\t}\n\n\tasync cycleModel(direction: \"forward\" | \"backward\" = \"forward\"): Promise<ModelCycleResult | undefined> {\n\t\tconst result = await this._modelSelection.cycleModel(direction);\n\t\tthis._scheduleLocalPrefixWarm(result?.model, \"selection\");\n\t\treturn result;\n\t}\n\n\t// =========================================================================\n\t// Thinking Level Management\n\t// =========================================================================\n\n\tsetThinkingLevel(level: ThinkingLevel, options: { persistSettings?: boolean } = {}): void {\n\t\tthis._modelSelection.setThinkingLevel(level, options);\n\t}\n\n\tcycleThinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this._modelSelection.cycleThinkingLevel();\n\t}\n\n\tgetAvailableThinkingLevels(): ThinkingLevel[] {\n\t\treturn this._modelSelection.getAvailableThinkingLevels();\n\t}\n\n\tsupportsThinking(): boolean {\n\t\treturn this._modelSelection.supportsThinking();\n\t}\n\n\t// =========================================================================\n\t// Queue Mode Management\n\t// =========================================================================\n\n\t/**\n\t * Set steering message mode.\n\t * Saves to settings.\n\t */\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.agent.steeringMode = mode;\n\t\tthis.settingsManager.setSteeringMode(mode);\n\t}\n\n\t/**\n\t * Set follow-up message mode.\n\t * Saves to settings.\n\t */\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.agent.followUpMode = mode;\n\t\tthis.settingsManager.setFollowUpMode(mode);\n\t}\n\n\t// =========================================================================\n\t// Compaction\n\t// =========================================================================\n\n\t/**\n\t * Manually compact the session context.\n\t * Aborts current agent operation first.\n\t * @param customInstructions Optional instructions for the compaction summary\n\t */\n\tasync compact(customInstructions?: string): Promise<CompactionResult> {\n\t\tthis._disconnectFromAgent();\n\t\tawait this.abort();\n\t\tthis._compactionAbortController = new AbortController();\n\t\tthis._emit({ type: \"compaction_start\", reason: \"manual\" });\n\n\t\ttry {\n\t\t\tif (!this.model) {\n\t\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t\t}\n\n\t\t\tconst sessionModel = this.model;\n\t\t\tconst selectedCompactionModel = this._resolveCompactionModel(sessionModel);\n\t\t\tif (this._isRawStreamSimple(this.agent.streamFn)) {\n\t\t\t\tawait this._getCompactionRequestAuth(selectedCompactionModel);\n\t\t\t}\n\t\t\tconst selectionReason = this._getLastCompactionSelectionReason() ?? \"unknown\";\n\t\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\t\tconst initialBranch = this.sessionManager.getBranch();\n\t\t\tconst initialPreparation = prepareCompaction(initialBranch, settings);\n\t\t\tif (!initialPreparation) {\n\t\t\t\tconst lastEntry = initialBranch[initialBranch.length - 1];\n\t\t\t\tif (lastEntry?.type === \"compaction\") {\n\t\t\t\t\tthrow new Error(\"Already compacted\");\n\t\t\t\t}\n\t\t\t\tthrow new Error(\"Nothing to compact (session too small)\");\n\t\t\t}\n\n\t\t\tlet extensionCompaction: CompactionResult | undefined;\n\t\t\tlet fromExtension = false;\n\t\t\tif (this._extensionRunner.hasHandlers(\"session_before_compact\")) {\n\t\t\t\tconst result = (await this._extensionRunner.emit({\n\t\t\t\t\ttype: \"session_before_compact\",\n\t\t\t\t\tpreparation: initialPreparation,\n\t\t\t\t\tbranchEntries: initialBranch,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\tsignal: this._compactionAbortController.signal,\n\t\t\t\t})) as SessionBeforeCompactResult | undefined;\n\t\t\t\tif (result?.cancel) throw new Error(\"Compaction cancelled\");\n\t\t\t\tif (result?.compaction) {\n\t\t\t\t\textensionCompaction = result.compaction;\n\t\t\t\t\tfromExtension = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (extensionCompaction) {\n\t\t\t\tthis.sessionManager.appendCompaction(\n\t\t\t\t\textensionCompaction.summary,\n\t\t\t\t\textensionCompaction.firstKeptEntryId,\n\t\t\t\t\textensionCompaction.tokensBefore,\n\t\t\t\t\textensionCompaction.details,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\tthis._refreshAfterCompaction();\n\t\t\t\tconst savedCompactionEntry = this.sessionManager\n\t\t\t\t\t.getEntries()\n\t\t\t\t\t.find((entry) => entry.type === \"compaction\" && entry.summary === extensionCompaction.summary) as\n\t\t\t\t\t| CompactionEntry\n\t\t\t\t\t| undefined;\n\t\t\t\tif (this._extensionRunner && savedCompactionEntry) {\n\t\t\t\t\tawait this._extensionRunner.emit({\n\t\t\t\t\t\ttype: \"session_compact\",\n\t\t\t\t\t\tcompactionEntry: savedCompactionEntry,\n\t\t\t\t\t\tfromExtension: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason: \"manual\",\n\t\t\t\t\tresult: extensionCompaction,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t});\n\t\t\t\treturn extensionCompaction;\n\t\t\t}\n\n\t\t\tlet appliedResult: CompactionResult | undefined;\n\t\t\tconst signal = this._compactionAbortController.signal;\n\t\t\tconst outcome = await runCompactionLoop({\n\t\t\t\tmeasureLiveTokens: () => Math.max(this._estimateCurrentContextTokens(this.agent.state.messages), 1),\n\t\t\t\tshouldCompact: () => true,\n\t\t\t\tgetPostApplyMargin: () => 0,\n\t\t\t\tgetBranch: () => this.sessionManager.getBranch(),\n\t\t\t\tgetBaseKeepRecentTokens: () => settings.keepRecentTokens,\n\t\t\t\tresolveModelAndAuth: async (modelTier) => {\n\t\t\t\t\tconst model = modelTier === \"cheap\" ? selectedCompactionModel : sessionModel;\n\t\t\t\t\tconst { apiKey, headers } = await this._resolveCompactionModelAndAuth(model, sessionModel);\n\t\t\t\t\treturn { model, apiKey, headers };\n\t\t\t\t},\n\t\t\t\tsummarizeAndVerify: async (params, model, apiKey, headers, branch) => {\n\t\t\t\t\tconst preparation = prepareCompaction(\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...settings,\n\t\t\t\t\t\t\tkeepRecentTokens: params.keepRecentTokens,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ allowTrailingCompactionAsPrevious: true },\n\t\t\t\t\t);\n\t\t\t\t\tif (!preparation) throw new Error(\"Nothing to compact (session too small)\");\n\t\t\t\t\tif (extensionCompaction) return { result: extensionCompaction };\n\t\t\t\t\tconst compactionThinkingLevel = this._resolveCompactionThinkingLevel(model, sessionModel);\n\t\t\t\t\tconst result = await this._compactWithRetry(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tcompact(\n\t\t\t\t\t\t\t\tpreparation,\n\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\tapiKey,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tcustomInstructions,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\tcompactionThinkingLevel,\n\t\t\t\t\t\t\t\tthis.agent.streamFn,\n\t\t\t\t\t\t\t\tthis._buildCompactionPreDigest(),\n\t\t\t\t\t\t\t\t{ chunked: params.chunked },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tmodel.provider,\n\t\t\t\t\t);\n\t\t\t\t\treturn { result };\n\t\t\t\t},\n\t\t\t\tbuildDeterministicCheckpoint: () => ({ result: createDeterministicCompaction(initialPreparation) }),\n\t\t\t\tapply: async (result) => {\n\t\t\t\t\tif (signal.aborted) throw new Error(\"Compaction cancelled\");\n\t\t\t\t\tthis.sessionManager.appendCompaction(\n\t\t\t\t\t\tresult.summary,\n\t\t\t\t\t\tresult.firstKeptEntryId,\n\t\t\t\t\t\tresult.tokensBefore,\n\t\t\t\t\t\tresult.details,\n\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t);\n\t\t\t\t\tthis._refreshAfterCompaction();\n\t\t\t\t\tconst savedCompactionEntry = this.sessionManager\n\t\t\t\t\t\t.getEntries()\n\t\t\t\t\t\t.find((entry) => entry.type === \"compaction\" && entry.summary === result.summary) as\n\t\t\t\t\t\t| CompactionEntry\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (this._extensionRunner && savedCompactionEntry) {\n\t\t\t\t\t\tawait this._extensionRunner.emit({\n\t\t\t\t\t\t\ttype: \"session_compact\",\n\t\t\t\t\t\t\tcompactionEntry: savedCompactionEntry,\n\t\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tappliedResult = result;\n\t\t\t\t},\n\t\t\t\tverifyPostApplyEffect: () => false,\n\t\t\t\tonTransition: ({ cycle, cause, detail }) => {\n\t\t\t\t\tthis._emit({\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: `manual compaction cycle ${cycle}: ${cause}${detail ? ` (${detail})` : \"\"} — retrying from step 0 (${this._describeCompactionSummarizer()})`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\t\tif (outcome.kind === \"failed\") {\n\t\t\t\tif (outcome.reason === \"aborted\") throw new Error(\"Compaction cancelled\");\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`manual compaction failed after retry ladder using ${selectedCompactionModel.provider}/${selectedCompactionModel.id} (${selectionReason}); first failure: ${outcome.reason}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (outcome.kind === \"skip\" || !appliedResult)\n\t\t\t\tthrow new Error(outcome.kind === \"skip\" ? outcome.reason : \"Compaction failed\");\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"manual\",\n\t\t\t\tresult: appliedResult,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t});\n\t\t\treturn appliedResult;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst aborted = message === \"Compaction cancelled\" || (error instanceof Error && error.name === \"AbortError\");\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"manual\",\n\t\t\t\tresult: undefined,\n\t\t\t\taborted,\n\t\t\t\twillRetry: false,\n\t\t\t\terrorMessage: aborted ? undefined : `Compaction failed: ${message}`,\n\t\t\t});\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis._compactionAbortController = undefined;\n\t\t\tthis._reconnectToAgent();\n\t\t}\n\t}\n\n\t/**\n\t * Cancel in-progress compaction (manual or auto).\n\t */\n\tabortCompaction(): void {\n\t\tthis._compactionAbortController?.abort();\n\t\tthis._autoCompactionAbortController?.abort();\n\t}\n\n\t/**\n\t * Cancel in-progress branch summarization.\n\t */\n\tabortBranchSummary(): void {\n\t\tthis._branchSummaryAbortController?.abort();\n\t}\n\n\t/**\n\t * Check if compaction is needed and run it.\n\t * Called after agent_end and before prompt submission.\n\t *\n\t * Two cases:\n\t * 1. Overflow: LLM returned context overflow error, remove error message from agent state, compact, auto-retry\n\t * 2. Threshold: Context over threshold, compact, NO auto-retry (user continues manually)\n\t *\n\t * @param assistantMessage The assistant message to check\n\t * @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true\n\t */\n\tprivate _getAdaptedCompactionSettings(): CompactionSettings {\n\t\treturn this._compactionSupport.getAdaptedSettings();\n\t}\n\n\tprivate _checkContextWindowUsageWarning(): void {\n\t\tif (!this.model) return;\n\t\tconst contextWindow = this.model.contextWindow ?? 0;\n\t\tif (contextWindow <= 0) return;\n\n\t\tconst systemPromptTokens = Math.ceil((this.agent.state.systemPrompt ?? \"\").length / 4);\n\n\t\tlet toolsChars = 0;\n\t\tfor (const tool of this.agent.state.tools || []) {\n\t\t\ttoolsChars += tool.name.length;\n\t\t\ttoolsChars += tool.description?.length ?? 0;\n\t\t\tif (tool.parameters) {\n\t\t\t\ttoolsChars += JSON.stringify(tool.parameters).length;\n\t\t\t}\n\t\t}\n\t\tconst toolsTokens = Math.ceil(toolsChars / 4);\n\n\t\tconst baseTokens = systemPromptTokens + toolsTokens;\n\n\t\tif (baseTokens >= contextWindow) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `Base configuration (system prompt and active tools) consumes ${baseTokens} tokens, which exceeds the model's context window of ${contextWindow} tokens. The model cannot process any prompts in this state.`,\n\t\t\t});\n\t\t} else if (baseTokens >= contextWindow * 0.7) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `Base configuration (system prompt and active tools) consumes ${baseTokens} tokens (${Math.round((baseTokens / contextWindow) * 100)}% of the ${contextWindow} context window). This leaves very little room for conversation history and may cause immediate compaction or context overflow.`,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async _checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck = true): Promise<boolean> {\n\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\tif (!settings.enabled) return false;\n\n\t\t// Skip if message was aborted (user cancelled) - unless skipAbortedCheck is false\n\t\tif (skipAbortedCheck && assistantMessage.stopReason === \"aborted\") return false;\n\n\t\tconst contextWindow = this.model?.contextWindow ?? 0;\n\n\t\t// Skip overflow check if the message came from a different model.\n\t\t// This handles the case where user switched from a smaller-context model (e.g. opus)\n\t\t// to a larger-context model (e.g. codex) - the overflow error from the old model\n\t\t// shouldn't trigger compaction for the new model.\n\t\tconst sameModel =\n\t\t\tthis.model && assistantMessage.provider === this.model.provider && assistantMessage.model === this.model.id;\n\n\t\t// Skip compaction checks if this assistant message is older than the latest\n\t\t// compaction boundary. This prevents a stale pre-compaction usage/error\n\t\t// from retriggering compaction on the first prompt after compaction.\n\t\tconst compactionEntry = getLatestCompactionEntry(this.sessionManager.getBranch());\n\t\tconst assistantIsFromBeforeCompaction =\n\t\t\tcompactionEntry !== null && assistantMessage.timestamp <= new Date(compactionEntry.timestamp).getTime();\n\t\tif (assistantIsFromBeforeCompaction) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Case 1: Overflow - LLM returned context overflow error\n\t\tif (sameModel && isContextOverflow(assistantMessage, contextWindow)) {\n\t\t\tif (this._overflowRecoveryAttempted) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason: \"overflow\",\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.\",\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis._overflowRecoveryAttempted = true;\n\t\t\t// Remove the error message from agent state (it IS saved to session for history,\n\t\t\t// but we don't want it in context for the retry)\n\t\t\tconst messages = this.agent.state.messages;\n\t\t\tif (messages.length > 0 && messages[messages.length - 1].role === \"assistant\") {\n\t\t\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t\t\t}\n\t\t\treturn await this._runAutoCompaction(\"overflow\", true);\n\t\t}\n\n\t\t// Case 2: Threshold - context is getting large\n\t\t// For error messages (no usage data), estimate from last successful response.\n\t\t// This ensures sessions that hit persistent API errors (e.g. 529) can still compact.\n\t\tlet contextTokens: number;\n\t\tif (assistantMessage.stopReason === \"error\") {\n\t\t\tconst messages = this.agent.state.messages;\n\t\t\tconst estimate = estimateContextTokens(messages);\n\t\t\tif (estimate.lastUsageIndex === null) return false; // No usage data at all\n\t\t\t// Verify the usage source is post-compaction. Kept pre-compaction messages\n\t\t\t// have stale usage reflecting the old (larger) context and would falsely\n\t\t\t// trigger compaction right after one just finished.\n\t\t\tconst usageMsg = messages[estimate.lastUsageIndex];\n\t\t\tif (\n\t\t\t\tcompactionEntry &&\n\t\t\t\tusageMsg.role === \"assistant\" &&\n\t\t\t\t(usageMsg as AssistantMessage).timestamp <= new Date(compactionEntry.timestamp).getTime()\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontextTokens = estimate.tokens;\n\t\t} else {\n\t\t\tcontextTokens = calculateContextTokens(assistantMessage.usage);\n\t\t\tconst estimate = estimateContextTokens(this.agent.state.messages);\n\t\t\tif (estimate.lastUsageIndex !== null) {\n\t\t\t\tconst usageMsg = this.agent.state.messages[estimate.lastUsageIndex];\n\t\t\t\tconst usageIsPostCompaction = !(\n\t\t\t\t\tcompactionEntry &&\n\t\t\t\t\tusageMsg.role === \"assistant\" &&\n\t\t\t\t\t(usageMsg as AssistantMessage).timestamp <= new Date(compactionEntry.timestamp).getTime()\n\t\t\t\t);\n\t\t\t\tif (usageIsPostCompaction) {\n\t\t\t\t\tcontextTokens = Math.max(contextTokens, estimate.tokens);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (shouldCompact(contextTokens, contextWindow, settings, this.model?.autoCompactionTriggerTokens)) {\n\t\t\treturn await this._runAutoCompaction(\"threshold\", false);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate _measureLiveContextTokensForCompaction(): number {\n\t\tconst estimatedTokens = this._pipeline.estimateCurrentContextTokens(this.agent.state.messages);\n\t\tconst assistantMessage = findLastAssistantMessage(this.agent.state.messages);\n\t\tif (!assistantMessage || assistantMessage.stopReason === \"error\" || assistantMessage.stopReason === \"aborted\") {\n\t\t\treturn estimatedTokens;\n\t\t}\n\n\t\tconst compactionEntry = getLatestCompactionEntry(this.sessionManager.getBranch());\n\t\tif (compactionEntry && assistantMessage.timestamp <= new Date(compactionEntry.timestamp).getTime()) {\n\t\t\treturn estimatedTokens;\n\t\t}\n\n\t\treturn Math.max(calculateContextTokens(assistantMessage.usage), estimatedTokens);\n\t}\n\n\t/**\n\t * Internal: Run auto-compaction with events.\n\t */\n\tprivate async _runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<boolean> {\n\t\tconst settings = this._getAdaptedCompactionSettings();\n\t\tconst model = this.model;\n\t\tthis._emit({ type: \"compaction_start\", reason });\n\t\tconst hadQueuedMessages = this.agent.hasQueuedMessages();\n\t\tthis._autoCompactionAbortController = new AbortController();\n\t\tconst signal = this._autoCompactionAbortController.signal;\n\t\tlet fromExtension = false;\n\t\tlet lastCompaction: CompactionResult | undefined;\n\t\tlet extensionCancelled = false;\n\t\ttry {\n\t\t\tif (!model) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason,\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\tskipReason: \"no model selected\",\n\t\t\t\t});\n\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t}\n\n\t\t\tconst contextWindow = model.contextWindow;\n\t\t\tconst margin = Math.max(0, Math.floor(0.01 * contextWindow));\n\t\t\tconst outcome = await runCompactionLoop({\n\t\t\t\tgetBranch: () => this.sessionManager.getBranch(),\n\t\t\t\tmeasureLiveTokens: () => this._measureLiveContextTokensForCompaction(),\n\t\t\t\tshouldCompact:\n\t\t\t\t\treason === \"overflow\"\n\t\t\t\t\t\t? () => true\n\t\t\t\t\t\t: (tokens) => shouldCompact(tokens, contextWindow, settings, model.autoCompactionTriggerTokens),\n\t\t\t\tgetPostApplyMargin: () => margin,\n\t\t\t\tgetBaseKeepRecentTokens: () => settings.keepRecentTokens,\n\t\t\t\tresolveModelAndAuth: async (modelTier) =>\n\t\t\t\t\tthis._resolveCompactionModelAndAuth(\n\t\t\t\t\t\tmodelTier === \"session\" ? model : this._resolveCompactionModel(model),\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t),\n\t\t\t\tsummarizeAndVerify: async (params, compactModel, apiKey, headers, branchEntries) => {\n\t\t\t\t\tfromExtension = false;\n\t\t\t\t\tconst adaptedSettings = { ...settings, keepRecentTokens: params.keepRecentTokens };\n\t\t\t\t\tconst preparation = prepareCompaction(branchEntries, adaptedSettings);\n\t\t\t\t\tif (!preparation) {\n\t\t\t\t\t\tthrow new Error(\"already compacted\");\n\t\t\t\t\t}\n\t\t\t\t\tconst compactionThinkingLevel = this._resolveCompactionThinkingLevel(compactModel, model);\n\n\t\t\t\t\tif (this._extensionRunner.hasHandlers(\"session_before_compact\")) {\n\t\t\t\t\t\tconst extensionResult = (await this._extensionRunner.emit({\n\t\t\t\t\t\t\ttype: \"session_before_compact\",\n\t\t\t\t\t\t\tpreparation,\n\t\t\t\t\t\t\tbranchEntries,\n\t\t\t\t\t\t\tcustomInstructions: undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})) as SessionBeforeCompactResult | undefined;\n\t\t\t\t\t\tif (extensionResult?.cancel) {\n\t\t\t\t\t\t\textensionCancelled = true;\n\t\t\t\t\t\t\tthrow new Error(\"auto-compaction-cancelled\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (extensionResult?.compaction) {\n\t\t\t\t\t\t\tfromExtension = true;\n\t\t\t\t\t\t\treturn { result: extensionResult.compaction };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compactResult = await this._compactWithRetry(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tcompact(\n\t\t\t\t\t\t\t\tpreparation,\n\t\t\t\t\t\t\t\tcompactModel,\n\t\t\t\t\t\t\t\tapiKey,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\tcompactionThinkingLevel,\n\t\t\t\t\t\t\t\tthis.agent.streamFn,\n\t\t\t\t\t\t\t\tthis._buildCompactionPreDigest(),\n\t\t\t\t\t\t\t\t{ chunked: params.chunked },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tcompactModel.provider,\n\t\t\t\t\t);\n\t\t\t\t\treturn { result: compactResult };\n\t\t\t\t},\n\t\t\t\tbuildDeterministicCheckpoint: async () => {\n\t\t\t\t\tconst branch = this.sessionManager.getBranch();\n\t\t\t\t\tconst preparation = prepareCompaction(branch, {\n\t\t\t\t\t\t...settings,\n\t\t\t\t\t});\n\t\t\t\t\tif (!preparation) {\n\t\t\t\t\t\tthrow new Error(\"already compacted\");\n\t\t\t\t\t}\n\t\t\t\t\tfromExtension = false;\n\t\t\t\t\treturn { result: createDeterministicCompaction(preparation) };\n\t\t\t\t},\n\t\t\t\tapply: async (result) => {\n\t\t\t\t\tlastCompaction = result;\n\t\t\t\t\tthis.sessionManager.appendCompaction(\n\t\t\t\t\t\tresult.summary,\n\t\t\t\t\t\tresult.firstKeptEntryId,\n\t\t\t\t\t\tresult.tokensBefore,\n\t\t\t\t\t\tresult.details,\n\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t);\n\t\t\t\t\tthis._refreshAfterCompaction();\n\t\t\t\t\tconst newEntries = this.sessionManager.getEntries();\n\t\t\t\t\tconst savedCompactionEntry = newEntries.find(\n\t\t\t\t\t\t(entry) => entry.type === \"compaction\" && entry.summary === result.summary,\n\t\t\t\t\t) as CompactionEntry | undefined;\n\t\t\t\t\tif (this._extensionRunner && savedCompactionEntry) {\n\t\t\t\t\t\tawait this._extensionRunner.emit({\n\t\t\t\t\t\t\ttype: \"session_compact\",\n\t\t\t\t\t\t\tcompactionEntry: savedCompactionEntry,\n\t\t\t\t\t\t\tfromExtension,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tverifyPostApplyEffect: reason === \"overflow\" ? () => false : undefined,\n\t\t\t\tonTransition: ({ cycle, cause, detail }) => {\n\t\t\t\t\tthis._emit({\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: `auto-compaction cycle ${cycle}: ${cause}${detail ? ` (${detail})` : \"\"} — retrying from step 0 (${this._describeCompactionSummarizer()})`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\t\tif (outcome.kind === \"skip\") {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason,\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\tskipReason: outcome.reason,\n\t\t\t\t});\n\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t}\n\n\t\t\tif (outcome.kind === \"failed\") {\n\t\t\t\tif (outcome.reason === \"aborted\") {\n\t\t\t\t\tthis._emit({ type: \"compaction_end\", reason, result: undefined, aborted: true, willRetry: false });\n\t\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t\t}\n\t\t\t\tthrow new Error(outcome.reason);\n\t\t\t}\n\n\t\t\tif (extensionCancelled || signal.aborted) {\n\t\t\t\tthis._emit({ type: \"compaction_end\", reason, result: undefined, aborted: true, willRetry: false });\n\n\t\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t\t}\n\n\t\t\tconst result = outcome.kind === \"success\" ? outcome.result : lastCompaction;\n\t\t\tif (!result) {\n\t\t\t\tthrow new Error(\"Auto-compaction succeeded without a result\");\n\t\t\t}\n\t\t\tthis._emit({ type: \"compaction_end\", reason, result, aborted: false, willRetry });\n\n\t\t\tif (willRetry) {\n\t\t\t\tconst messages = this.agent.state.messages;\n\t\t\t\tconst lastMsg = messages[messages.length - 1];\n\t\t\t\tif (lastMsg?.role === \"assistant\" && (lastMsg as AssistantMessage).stopReason === \"error\") {\n\t\t\t\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : \"compaction failed\";\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason,\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\terrorMessage:\n\t\t\t\t\treason === \"overflow\"\n\t\t\t\t\t\t? `Context overflow recovery failed: ${errorMessage}`\n\t\t\t\t\t\t: `Auto-compaction failed: ${errorMessage}`,\n\t\t\t});\n\t\t\treturn hadQueuedMessages || this.agent.hasQueuedMessages();\n\t\t} finally {\n\t\t\tthis._autoCompactionAbortController = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Run one compaction attempt, retrying retryable provider failures (stream stalls,\n\t * 429/5xx, network drops) with the session's retry policy. The reliability kernel\n\t * classifies a stall as retryable by design (see withStreamIdleWatchdog); without this\n\t * loop a single transient killed the whole compaction while ordinary turns survived the\n\t * same failure via auto-retry. Caller aborts are never retried; sleepAbortable rejects\n\t * with the abort reason if the signal fires mid-backoff.\n\t */\n\tprivate async _compactWithRetry(\n\t\trun: () => Promise<CompactionResult>,\n\t\tsignal: AbortSignal,\n\t\tprovider?: string,\n\t): Promise<CompactionResult> {\n\t\tconst retrySettings = this.settingsManager.getRetrySettings();\n\t\tconst maxAttempts = retrySettings.enabled ? Math.max(1, retrySettings.maxRetries + 1) : 1;\n\t\tconst policy: RetryPolicy = {\n\t\t\tmaxAttempts,\n\t\t\tbaseDelayMs: retrySettings.baseDelayMs,\n\t\t\tmaxDelayMs: DEFAULT_RETRY_POLICY.maxDelayMs,\n\t\t\tjitterRatio: 0,\n\t\t};\n\t\tfor (let attempt = 1; ; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await run();\n\t\t\t} catch (error) {\n\t\t\t\tif (signal.aborted || attempt >= maxAttempts) throw error;\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconst classified = classifyFailure({ message, provider });\n\t\t\t\tthis._failureCorpus.record({ provider, message, classified });\n\t\t\t\tif (!classified.retryable) throw error;\n\t\t\t\tawait sleepAbortable(\n\t\t\t\t\tcomputeRetryDelayMs(policy, attempt, { retryAfterMs: classified.retryAfterMs }),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Toggle auto-compaction setting.\n\t */\n\tsetAutoCompactionEnabled(enabled: boolean): void {\n\t\tthis.settingsManager.setCompactionEnabled(enabled);\n\t}\n\n\t/** Whether auto-compaction is enabled */\n\tget autoCompactionEnabled(): boolean {\n\t\treturn this.settingsManager.getCompactionEnabled();\n\t}\n\n\tasync bindExtensions(bindings: ExtensionBindings): Promise<void> {\n\t\tif (bindings.uiContext !== undefined) {\n\t\t\tthis._extensionUIContext = bindings.uiContext;\n\t\t}\n\t\tif (bindings.mode !== undefined) {\n\t\t\tthis._extensionMode = bindings.mode;\n\t\t}\n\t\tif (bindings.commandContextActions !== undefined) {\n\t\t\tthis._extensionCommandContextActions = bindings.commandContextActions;\n\t\t}\n\t\tif (bindings.abortHandler !== undefined) {\n\t\t\tthis._extensionAbortHandler = bindings.abortHandler;\n\t\t}\n\t\tif (bindings.shutdownHandler !== undefined) {\n\t\t\tthis._extensionShutdownHandler = bindings.shutdownHandler;\n\t\t}\n\t\tif (bindings.onError !== undefined) {\n\t\t\tthis._extensionErrorListener = bindings.onError;\n\t\t}\n\n\t\tthis._applyExtensionBindings(this._extensionRunner);\n\t\tawait this._extensionRunner.emit(this._sessionStartEvent);\n\t\tawait this.extendResourcesFromExtensions(this._sessionStartEvent.reason === \"reload\" ? \"reload\" : \"startup\");\n\t\t// Initialize the memory subsystem after extensions have had a chance to register providers.\n\t\tawait this._memory.initialize();\n\t}\n\n\tprivate async extendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void> {\n\t\tif (!this._extensionRunner.hasHandlers(\"resources_discover\")) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(\n\t\t\tthis._cwd,\n\t\t\treason,\n\t\t);\n\n\t\tif (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst extensionPaths: ResourceExtensionPaths = {\n\t\t\tskillPaths: this.buildExtensionResourcePaths(skillPaths),\n\t\t\tpromptPaths: this.buildExtensionResourcePaths(promptPaths),\n\t\t\tthemePaths: this.buildExtensionResourcePaths(themePaths),\n\t\t};\n\n\t\tthis._resourceLoader.extendResources(extensionPaths);\n\t\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t}\n\n\tprivate buildExtensionResourcePaths(entries: Array<{ path: string; extensionPath: string }>): Array<{\n\t\tpath: string;\n\t\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n\t}> {\n\t\treturn entries.map((entry) => {\n\t\t\tconst source = this.getExtensionSourceLabel(entry.extensionPath);\n\t\t\tconst baseDir = entry.extensionPath.startsWith(\"<\") ? undefined : dirname(entry.extensionPath);\n\t\t\treturn {\n\t\t\t\tpath: entry.path,\n\t\t\t\tmetadata: {\n\t\t\t\t\tsource,\n\t\t\t\t\tscope: \"temporary\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t\tbaseDir,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate getExtensionSourceLabel(extensionPath: string): string {\n\t\tif (extensionPath.startsWith(\"<\")) {\n\t\t\treturn `extension:${extensionPath.replace(/[<>]/g, \"\")}`;\n\t\t}\n\t\tconst base = basename(extensionPath);\n\t\tconst name = base.replace(/\\.(ts|js)$/, \"\");\n\t\treturn `extension:${name}`;\n\t}\n\n\tprivate _applyExtensionBindings(runner: ExtensionRunner): void {\n\t\trunner.setUIContext(this._extensionUIContext);\n\t\trunner.setMode(this._extensionMode);\n\t\trunner.bindCommandContext(this._extensionCommandContextActions);\n\n\t\tthis._extensionErrorUnsubscriber?.();\n\t\tthis._extensionErrorUnsubscriber = this._extensionErrorListener\n\t\t\t? runner.onError(this._extensionErrorListener)\n\t\t\t: undefined;\n\t}\n\n\tprivate _refreshCurrentModelFromRegistry(): void {\n\t\tconst currentModel = this.model;\n\t\tif (!currentModel) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);\n\t\tif (!refreshedModel || refreshedModel === currentModel) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.agent.state.model = refreshedModel;\n\t}\n\n\tprivate _bindExtensionCore(runner: ExtensionRunner): void {\n\t\tconst getCommands = (): SlashCommandInfo[] => {\n\t\t\tconst extensionCommands: SlashCommandInfo[] = runner.getRegisteredCommands().map((command) => ({\n\t\t\t\tname: command.invocationName,\n\t\t\t\tdescription: command.description,\n\t\t\t\tsource: \"extension\",\n\t\t\t\tsourceInfo: command.sourceInfo,\n\t\t\t}));\n\n\t\t\tconst templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({\n\t\t\t\tname: template.name,\n\t\t\t\tdescription: template.description,\n\t\t\t\tsource: \"prompt\",\n\t\t\t\tsourceInfo: template.sourceInfo,\n\t\t\t}));\n\n\t\t\tconst skills: SlashCommandInfo[] = this._resourceLoader.getActiveSkills().map((skill) => ({\n\t\t\t\tname: `skill:${skill.name}`,\n\t\t\t\tdescription: skill.description,\n\t\t\t\tsource: \"skill\",\n\t\t\t\tsourceInfo: skill.sourceInfo,\n\t\t\t}));\n\n\t\t\treturn [...extensionCommands, ...templates, ...skills];\n\t\t};\n\n\t\trunner.bindCore(\n\t\t\t{\n\t\t\t\tsendMessage: (message, options) => {\n\t\t\t\t\tthis.sendCustomMessage(message, options).catch((err) => {\n\t\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\t\tevent: \"send_message\",\n\t\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsendUserMessage: (content, options) => {\n\t\t\t\t\tthis.sendUserMessage(content, options).catch((err) => {\n\t\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\t\tevent: \"send_user_message\",\n\t\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tappendEntry: (customType, data) => {\n\t\t\t\t\tthis.sessionManager.appendCustomEntry(customType, data);\n\t\t\t\t},\n\t\t\t\tsetSessionName: (name) => {\n\t\t\t\t\tthis.setSessionName(name);\n\t\t\t\t},\n\t\t\t\tgetSessionName: () => {\n\t\t\t\t\treturn this.sessionManager.getSessionName();\n\t\t\t\t},\n\t\t\t\tsetLabel: (entryId, label) => {\n\t\t\t\t\tthis.sessionManager.appendLabelChange(entryId, label);\n\t\t\t\t},\n\t\t\t\tgetActiveTools: () => this.getActiveToolNames(),\n\t\t\t\tgetAllTools: () => this.getAllTools(),\n\t\t\t\tsetActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\t\trefreshTools: () => this._refreshToolRegistry(),\n\t\t\t\tgetCommands,\n\t\t\t\tsetModel: async (model) => {\n\t\t\t\t\tif (!this.modelRegistry.hasConfiguredAuth(model)) return false;\n\t\t\t\t\tawait this.setModel(model);\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level),\n\t\t\t\tgetExternalResourceRoots: () => this.settingsManager.getEffectiveExternalResourceRoots(),\n\t\t\t\tregisterMemoryProvider: (provider) => this.registerMemoryProvider(provider),\n\t\t\t\tregisterContextMemoryProvider: (provider) => this.registerContextMemoryProvider(provider),\n\t\t\t\treportSpawnedUsage: (usage, opts) => {\n\t\t\t\t\tthis.addSpawnedUsage(usage, opts);\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tgetModel: () => this.model,\n\t\t\t\tisIdle: () => !this.isStreaming,\n\t\t\t\tgetSignal: () => this.agent.signal,\n\t\t\t\tabort: () => {\n\t\t\t\t\tif (this._extensionAbortHandler) {\n\t\t\t\t\t\tthis._extensionAbortHandler();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvoid this.abort();\n\t\t\t\t},\n\t\t\t\thasPendingMessages: () => this.pendingMessageCount > 0,\n\t\t\t\tshutdown: () => {\n\t\t\t\t\tthis._extensionShutdownHandler?.();\n\t\t\t\t},\n\t\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\t\tcompact: (options) => {\n\t\t\t\t\tvoid (async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await this.compact(options?.customInstructions);\n\t\t\t\t\t\t\toptions?.onComplete?.(result);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\t\toptions?.onError?.(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t\treload: () => {\n\t\t\t\t\tif (this.isStreaming) {\n\t\t\t\t\t\treturn Promise.reject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\"ctx.reload() cannot run while the agent is streaming or a tool call is active. Wait for ctx.isIdle(), queue a follow-up /reload, or use an idle command/event handler so hot reload cannot destabilize the UI.\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.isCompacting) {\n\t\t\t\t\t\treturn Promise.reject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\"ctx.reload() cannot run during context compaction or branch summarization. Let compaction finish before reloading so the session tree and UI remain stable.\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst actions = this._extensionCommandContextActions;\n\t\t\t\t\tif (!actions) {\n\t\t\t\t\t\treturn this.reload();\n\t\t\t\t\t}\n\t\t\t\t\treturn actions.reload();\n\t\t\t\t},\n\t\t\t\tgetSystemPrompt: () => this.systemPrompt,\n\t\t\t},\n\t\t\t{\n\t\t\t\tregisterProvider: (name, config) => {\n\t\t\t\t\tthis._modelRegistry.registerProvider(name, config);\n\t\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t\t},\n\t\t\t\tunregisterProvider: (name) => {\n\t\t\t\t\tthis._modelRegistry.unregisterProvider(name);\n\t\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Register a memory provider contributed by an extension; applied on the next memory (re)init. */\n\tregisterMemoryProvider(provider: MemoryProvider): void {\n\t\tthis._memory.registerMemoryProvider(provider);\n\t}\n\n\tregisterContextMemoryProvider(provider: ContextMemoryProvider): void {\n\t\tthis._memory.registerContextMemoryProvider(provider);\n\t}\n\n\t/** R8: the gateway/scheduler registry. A deployment runner registers providers and drives start/stop. */\n\tget gateways(): GatewayRegistry {\n\t\treturn this._gatewayRegistry;\n\t}\n\n\t/** R8: register a deployment-supplied transport channel (gateway). */\n\tregisterChannelProvider(provider: ChannelProvider): void {\n\t\tthis._gatewayRegistry.registerChannel(provider);\n\t}\n\n\t/** R8: register a deployment-supplied job scheduler (cron). */\n\tregisterJobScheduler(provider: JobSchedulerProvider): void {\n\t\tthis._gatewayRegistry.registerScheduler(provider);\n\t}\n\n\tprivate _refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void {\n\t\tthis._runtimeBuilder.refreshToolRegistry(options);\n\t}\n\n\tasync reload(): Promise<void> {\n\t\treturn this._runtimeBuilder.reload();\n\t}\n\n\t/**\n\t * Unload a single extension without full reload.\n\t * Runs the extension's session_shutdown lifecycle, unregisters its providers,\n\t * disposes its event subscriptions, and rebuilds the runtime.\n\t * Falls back to full reload on error.\n\t */\n\tasync unloadExtensionLive(extensionPath: string): Promise<void> {\n\t\treturn this._runtimeBuilder.unloadExtensionLive(extensionPath);\n\t}\n\n\t/**\n\t * Load a single extension without full reload.\n\t * Loads the extension with fresh import, rebuilds the runtime,\n\t * and runs the extension's session_start lifecycle.\n\t * Falls back to full reload on error.\n\t */\n\tasync loadExtensionLive(extensionPath: string): Promise<void> {\n\t\treturn this._runtimeBuilder.loadExtensionLive(extensionPath);\n\t}\n\n\t/**\n\t * Reconcile loaded extensions with the active profile.\n\t * Loads extensions that should be enabled but aren't, and unloads extensions that shouldn't be.\n\t * Falls back to full reload if any individual load/unload fails.\n\t */\n\tasync reconcileLoadedExtensions(): Promise<void> {\n\t\treturn this._runtimeBuilder.reconcileLoadedExtensions();\n\t}\n\n\t// =========================================================================\n\t// Auto-Retry\n\t// =========================================================================\n\n\t/**\n\t * Check if an error is retryable (transient provider/network failures). Billing/quota and auth\n\t * are terminal; context overflow is handled by compaction, not retry. The verdict comes from the\n\t * reliability kernel's classifier, fed the host-computed context-overflow flag.\n\t */\n\tprivate _classifyAssistantError(message: AssistantMessage): ClassifiedError | undefined {\n\t\tif (message.stopReason !== \"error\" || !message.errorMessage) return undefined;\n\t\tconst contextWindow = this.model?.contextWindow ?? 0;\n\t\treturn classifyFailure({\n\t\t\tmessage: message.errorMessage,\n\t\t\tcontextOverflow: isContextOverflow(message, contextWindow),\n\t\t\tprovider: message.provider,\n\t\t});\n\t}\n\n\tprivate _isRetryableError(message: AssistantMessage): boolean {\n\t\treturn this._classifyAssistantError(message)?.retryable ?? false;\n\t}\n\n\t/**\n\t * Prepare a retryable error for continuation with exponential backoff.\n\t * @returns true if the caller should continue the agent, false otherwise\n\t */\n\tprivate async _prepareRetry(message: AssistantMessage): Promise<boolean> {\n\t\treturn this._retryController.prepareRetry(message);\n\t}\n\n\t/**\n\t * Cancel in-progress retry.\n\t */\n\tabortRetry(): void {\n\t\tthis._retryController.abort();\n\t}\n\n\t/** Whether auto-retry is currently in progress */\n\tget isRetrying(): boolean {\n\t\treturn this._retryController.isRetrying;\n\t}\n\n\t/** Whether auto-retry is enabled */\n\tget autoRetryEnabled(): boolean {\n\t\treturn this.settingsManager.getRetryEnabled();\n\t}\n\n\t/**\n\t * Toggle auto-retry setting.\n\t */\n\tsetAutoRetryEnabled(enabled: boolean): void {\n\t\tthis.settingsManager.setRetryEnabled(enabled);\n\t}\n\n\t// =========================================================================\n\t// Bash Execution\n\t// =========================================================================\n\n\tasync executeBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; operations?: BashOperations },\n\t): Promise<BashResult> {\n\t\treturn this._bash.executeBash(command, onChunk, options);\n\t}\n\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void {\n\t\tthis._bash.recordBashResult(command, result, options);\n\t}\n\n\tabortBash(): void {\n\t\tthis._bash.abortBash();\n\t}\n\n\t/** Whether a bash command is currently running */\n\tget isBashRunning(): boolean {\n\t\treturn this._bash.isBashRunning;\n\t}\n\n\t/** Whether there are pending bash messages waiting to be flushed */\n\tget hasPendingBashMessages(): boolean {\n\t\treturn this._bash.hasPendingBashMessages;\n\t}\n\n\tprivate _flushPendingBashMessages(): void {\n\t\tthis._bash.flushPendingBashMessages();\n\t}\n\n\t// =========================================================================\n\t// Session Management\n\t// =========================================================================\n\n\t/**\n\t * Set a display name for the current session.\n\t */\n\tsetSessionName(name: string): void {\n\t\tthis.sessionManager.appendSessionInfo(name);\n\t\tthis._emit({ type: \"session_info_changed\", name: this.sessionManager.getSessionName() });\n\t}\n\n\t// =========================================================================\n\t// Tree Navigation\n\t// =========================================================================\n\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string } = {},\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }> {\n\t\treturn this._treeNavigator.navigateTree(targetId, options);\n\t}\n\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }> {\n\t\treturn this._treeNavigator.getUserMessagesForForking();\n\t}\n\n\tgetSessionStats(): SessionStats {\n\t\treturn this._analytics.getSessionStats();\n\t}\n\n\tgetCumulativeUsage(): Usage {\n\t\treturn this._analytics.getCumulativeUsage();\n\t}\n\n\taddSpawnedUsage(\n\t\tusage: Usage,\n\t\topts?: { label?: string; sourceSessionId?: string; reportId?: string },\n\t): string | undefined {\n\t\treturn this._analytics.addSpawnedUsage(usage, opts);\n\t}\n\n\tgetSpawnedUsage(): SpawnedUsageTotals {\n\t\treturn this._analytics.getSpawnedUsage();\n\t}\n\n\tgetDailyUsageTotals(now = new Date()): DailyUsageTotals {\n\t\treturn this._analytics.getDailyUsageTotals(now);\n\t}\n\n\tgetCostSummary(now = new Date()): SessionCostSummary {\n\t\treturn this._analytics.getCostSummary(now);\n\t}\n\n\tgetDailyUsageBreakdown(formatLabel?: (label: string) => string, now = new Date()): string {\n\t\treturn this._analytics.getDailyUsageBreakdown(formatLabel, now);\n\t}\n\n\t/**\n\t * Save a snapshot of the goal state to the session log.\n\t *\n\t * @returns the id of the appended custom entry\n\t */\n\tsaveGoalStateSnapshot(state: GoalState): string {\n\t\treturn appendGoalStateSnapshot(this.sessionManager, state);\n\t}\n\n\t/**\n\t * Retrieve the latest valid goal state snapshot from the session log.\n\t */\n\tgetGoalStateSnapshot(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.sessionManager.getEntries());\n\t}\n\n\t/** Save native task-step state to the active session log. */\n\tsaveTaskStepsStateSnapshot(state: TaskStepsState): string {\n\t\treturn appendTaskStepsStateSnapshot(this.sessionManager, state);\n\t}\n\n\t/** Retrieve the latest valid native task-step state from the active session log. */\n\tgetTaskStepsStateSnapshot(): TaskStepsState | undefined {\n\t\treturn getLatestTaskStepsStateSnapshot(this.sessionManager.getEntries());\n\t}\n\n\t/**\n\t * Save a snapshot of the evidence bundle to the session log.\n\t *\n\t * @returns the id of the appended custom entry\n\t */\n\tsaveEvidenceBundleSnapshot(bundle: EvidenceBundle): string {\n\t\treturn appendEvidenceBundleSnapshot(this.sessionManager, bundle);\n\t}\n\n\t/**\n\t * Retrieve the latest valid evidence bundle snapshot from the session log.\n\t */\n\tgetEvidenceBundleSnapshot(): EvidenceBundle | undefined {\n\t\treturn getLatestEvidenceBundleSnapshot(this.sessionManager.getEntries());\n\t}\n\n\tgetEvidenceBundleSnapshots(): EvidenceBundle[] {\n\t\treturn getEvidenceBundleSnapshots(this.sessionManager.getEntries());\n\t}\n\n\t/** Live lane records tracked by this process (running and terminal). */\n\tgetLaneRecords(): LaneRecord[] {\n\t\treturn this._backgroundLanes.getLaneRecords();\n\t}\n\n\t// G3/G8 autonomy telemetry + gate-outcome history live in AutonomyTelemetry (see\n\t// autonomy-telemetry.ts). These stubs keep the god file's internal call surface stable while the\n\t// sink logic and the owned gate-outcome fields live there.\n\tprivate _emitAutonomyTelemetry(event: AutonomyTelemetryEvent): void {\n\t\tthis._autonomyTelemetry.emitTelemetry(event);\n\t}\n\n\tprivate _recordGateOutcome(outcome: GateOutcome): void {\n\t\tthis._autonomyTelemetry.recordGateOutcome(outcome);\n\t}\n\n\t/** G8: copies of the bounded gate-outcome history, oldest first, latest last. */\n\tgetGateOutcomeHistory(): GateOutcomeHistoryEntry[] {\n\t\treturn this._autonomyTelemetry.getGateOutcomeHistory();\n\t}\n\n\tsaveWorkerResultSnapshot(result: WorkerResult, request?: WorkerRequest): string {\n\t\treturn appendWorkerResultSnapshot(this.sessionManager, result, request);\n\t}\n\n\tgetWorkerResultSnapshots(): WorkerResult[] {\n\t\treturn getWorkerResultSnapshots(this.sessionManager.getEntries());\n\t}\n\n\tsaveLearningDecisionSnapshot(decision: LearningDecision): string {\n\t\treturn appendLearningDecisionSnapshot(this.sessionManager, decision);\n\t}\n\n\tgetLearningDecisionSnapshots(): LearningDecision[] {\n\t\treturn getLearningDecisionSnapshots(this.sessionManager.getEntries());\n\t}\n\n\tgetGoalRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tentries: this.sessionManager.getEntries(),\n\t\t\tsettings,\n\t\t});\n\t}\n\n\t/**\n\t * Capability profile derived from the CURRENT session model's own metadata (context window),\n\t * honoring the modelCapability.mode setting (\"off\" disables, a class name forces).\n\t */\n\tgetModelCapabilityProfile(): ModelCapabilityProfile {\n\t\treturn deriveModelCapabilityProfile({\n\t\t\tcontextWindow: this.model?.contextWindow,\n\t\t\tmode: this.settingsManager.getModelCapabilitySettings().mode,\n\t\t});\n\t}\n\n\t/**\n\t * Run one bounded, read-only research pass and persist its results. Delegates to\n\t * {@link BackgroundLaneController}; see there for the full gating/budget/dedupe contract.\n\t */\n\tasync runResearchLaneOnce(request?: {\n\t\tquery?: string;\n\t\tcontext?: string;\n\t\tgoalId?: string;\n\t}): Promise<ResearchLaneRunOutcome> {\n\t\treturn this._backgroundLanes.runResearchLaneOnce(request);\n\t}\n\n\t/**\n\t * Run one bounded scout-worker delegation. Delegates to {@link BackgroundLaneController};\n\t * consumed by the `delegate` tool.\n\t */\n\tasync runWorkerDelegationOnce(request: {\n\t\tinstructions: string;\n\t\tsystemPrompt?: string;\n\t\tmemoryRead?: boolean;\n\t}): Promise<WorkerDelegationRunOutcome> {\n\t\treturn this._backgroundLanes.runWorkerDelegationOnce(request);\n\t}\n\n\t/**\n\t * Probe a candidate model against the subagent contracts. Delegates to\n\t * {@link BackgroundLaneController}; probe spend is reported through spawned-usage accounting.\n\t */\n\tasync runModelFitness(args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t}): Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }> {\n\t\treturn this._backgroundLanes.runModelFitness(args);\n\t}\n\n\t/** Fitness reports persisted for THIS host (measured evidence for architect/profile decisions). */\n\tgetStoredFitnessReports(): StoredFitnessReport[] {\n\t\treturn this._backgroundLanes.getStoredFitnessReports();\n\t}\n\n\tasync continueGoalOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this._goalContinuation.continueGoalOnce(options);\n\t}\n\n\tasync continueGoalLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this._goalContinuation.continueGoalLoop(options);\n\t}\n\n\t/**\n\t * Run a one-shot LLM completion fully ISOLATED from the main session — the load-bearing primitive\n\t * for native reflection (see reflection-controller.ts for the isolation invariants).\n\t */\n\tasync runIsolatedCompletion(opts: IsolatedCompletionOptions): Promise<IsolatedCompletionResult> {\n\t\treturn this._reflection.runIsolatedCompletion(opts);\n\t}\n\n\t/**\n\t * Native end-of-loop reflection pass (R2). Delegates to {@link ReflectionController}; returns null\n\t * when the demand gate skips or in a child session.\n\t */\n\tasync runReflectionPass(input: {\n\t\tsignals: DemandSignals;\n\t\trecentTurnText: string;\n\t\tmodel?: Model<any>;\n\t\tthinkingLevel?: ThinkingLevel;\n\t\tsignal?: AbortSignal;\n\t\t/** Stable id so a duplicate scheduling/retry of the same pass can't double-count its cost. */\n\t\treportId?: string;\n\t}): Promise<ReflectionResult | null> {\n\t\treturn this._reflection.runReflectionPass(input);\n\t}\n\n\tgetLearningAuditRecords(): LearningAuditRecord[] {\n\t\treturn this._reflection.getLearningAuditRecords();\n\t}\n\n\t/** Roll back one applied durable learning change. Delegates to {@link ReflectionController}. */\n\tasync rollbackLearningWrite(auditId: string): Promise<{ ok: boolean; reason: string }> {\n\t\treturn this._reflection.rollbackLearningWrite(auditId);\n\t}\n\n\tgetContextUsage(): ContextUsage | undefined {\n\t\treturn this._analytics.getContextUsage();\n\t}\n\n\tasync exportToHtml(outputPath?: string): Promise<string> {\n\t\treturn this._analytics.exportToHtml(outputPath);\n\t}\n\n\texportToJsonl(outputPath?: string): string {\n\t\treturn this._analytics.exportToJsonl(outputPath);\n\t}\n\n\t// =========================================================================\n\t// Utilities\n\t// =========================================================================\n\n\tgetLastAssistantText(): string | undefined {\n\t\treturn this._analytics.getLastAssistantText();\n\t}\n\n\t// =========================================================================\n\t// Extension System\n\t// =========================================================================\n\n\tpublic getAutonomyStatusSnapshot(): AutonomyStatusSnapshot {\n\t\treturn this._autonomyTelemetry.getStatusSnapshot();\n\t}\n\n\t/**\n\t * Aggregate an effectiveness/autonomy dashboard: what Pi has actually been doing (recent\n\t * route choices, latest gate outcome, cost, and any research/delegation/learning/goal\n\t * activity). Read-only — combines existing session-log getters, never mutates state or\n\t * recomputes a route/gate decision.\n\t */\n\tpublic getAutonomyDiagnosticSnapshot(options?: { maxEntriesPerFamily?: number }): AutonomyDiagnosticSnapshot {\n\t\treturn this._autonomyTelemetry.getDiagnosticSnapshot(options);\n\t}\n\n\tcreateReplacedSessionContext(): ReplacedSessionContext {\n\t\tconst context = Object.defineProperties(\n\t\t\t{},\n\t\t\tObject.getOwnPropertyDescriptors(this._extensionRunner.createCommandContext()),\n\t\t) as ReplacedSessionContext;\n\t\tcontext.sendMessage = (message, options) => this.sendCustomMessage(message, options);\n\t\tcontext.sendUserMessage = (content, options) => this.sendUserMessage(content, options);\n\t\treturn context;\n\t}\n\n\t/**\n\t * Check if extensions have handlers for a specific event type.\n\t */\n\thasExtensionHandlers(eventType: string): boolean {\n\t\treturn this._extensionRunner.hasHandlers(eventType);\n\t}\n\n\t/**\n\t * Get the extension runner (for setting UI context and error handlers).\n\t */\n\tget extensionRunner(): ExtensionRunner {\n\t\treturn this._extensionRunner;\n\t}\n}\n\nfunction findLastAssistantMessage(messages: AgentMessage[]): AssistantMessage | undefined {\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst message = messages[i];\n\t\tif (message.role === \"assistant\") {\n\t\t\treturn message;\n\t\t}\n\t}\n\treturn undefined;\n}\n"]}