@caupulican/pi-adaptative 0.91.4 → 0.93.0

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 (208) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/cli/args.d.ts +2 -0
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +24 -0
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli.js +6 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/agent-session-contracts.d.ts +1 -0
  9. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  10. package/dist/core/agent-session-contracts.js.map +1 -1
  11. package/dist/core/agent-session-services.d.ts +1 -0
  12. package/dist/core/agent-session-services.d.ts.map +1 -1
  13. package/dist/core/agent-session-services.js +1 -0
  14. package/dist/core/agent-session-services.js.map +1 -1
  15. package/dist/core/agent-session.d.ts +1 -6
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +15 -13
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  20. package/dist/core/autonomy/lane-tool-surface.js +7 -1
  21. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  22. package/dist/core/background-lane-controller.d.ts +2 -4
  23. package/dist/core/background-lane-controller.d.ts.map +1 -1
  24. package/dist/core/background-lane-controller.js +0 -1
  25. package/dist/core/background-lane-controller.js.map +1 -1
  26. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  27. package/dist/core/bash-execution-controller.js +1 -0
  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 +13 -4
  32. package/dist/core/bash-executor.js.map +1 -1
  33. package/dist/core/compaction-controller.d.ts.map +1 -1
  34. package/dist/core/compaction-controller.js +2 -1
  35. package/dist/core/compaction-controller.js.map +1 -1
  36. package/dist/core/context/context-composition.d.ts +1 -1
  37. package/dist/core/context/context-composition.d.ts.map +1 -1
  38. package/dist/core/context/context-composition.js +1 -1
  39. package/dist/core/context/context-composition.js.map +1 -1
  40. package/dist/core/default-tool-surface.d.ts +0 -10
  41. package/dist/core/default-tool-surface.d.ts.map +1 -1
  42. package/dist/core/default-tool-surface.js +3 -1
  43. package/dist/core/default-tool-surface.js.map +1 -1
  44. package/dist/core/extensions/bundled-virtual-modules.js +8 -0
  45. package/dist/core/extensions/bundled-virtual-modules.js.map +1 -1
  46. package/dist/core/extensions/runner.d.ts +1 -1
  47. package/dist/core/extensions/runner.d.ts.map +1 -1
  48. package/dist/core/extensions/runner.js +1 -1
  49. package/dist/core/extensions/runner.js.map +1 -1
  50. package/dist/core/extensions/virtual-modules.d.ts +4 -0
  51. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  52. package/dist/core/extensions/virtual-modules.js +4 -0
  53. package/dist/core/extensions/virtual-modules.js.map +1 -1
  54. package/dist/core/goal-loop-controller.d.ts +6 -2
  55. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  56. package/dist/core/goal-loop-controller.js +15 -4
  57. package/dist/core/goal-loop-controller.js.map +1 -1
  58. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  59. package/dist/core/goals/compact-goal-context.js +10 -14
  60. package/dist/core/goals/compact-goal-context.js.map +1 -1
  61. package/dist/core/goals/goal-auto-continue-controller.d.ts +0 -2
  62. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  63. package/dist/core/goals/goal-auto-continue-controller.js +0 -2
  64. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  65. package/dist/core/goals/goal-session-controller.d.ts +7 -7
  66. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  67. package/dist/core/goals/goal-session-controller.js +27 -5
  68. package/dist/core/goals/goal-session-controller.js.map +1 -1
  69. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  70. package/dist/core/goals/goal-tool-core.js +7 -0
  71. package/dist/core/goals/goal-tool-core.js.map +1 -1
  72. package/dist/core/goals/goal-tool-names.d.ts +7 -0
  73. package/dist/core/goals/goal-tool-names.d.ts.map +1 -0
  74. package/dist/core/goals/goal-tool-names.js +8 -0
  75. package/dist/core/goals/goal-tool-names.js.map +1 -0
  76. package/dist/core/model-capability.d.ts +1 -1
  77. package/dist/core/model-capability.d.ts.map +1 -1
  78. package/dist/core/model-capability.js +3 -1
  79. package/dist/core/model-capability.js.map +1 -1
  80. package/dist/core/models/perf-profile.d.ts +2 -1
  81. package/dist/core/models/perf-profile.d.ts.map +1 -1
  82. package/dist/core/models/perf-profile.js +1 -1
  83. package/dist/core/models/perf-profile.js.map +1 -1
  84. package/dist/core/provider-request-context-controller.d.ts.map +1 -1
  85. package/dist/core/provider-request-context-controller.js +6 -5
  86. package/dist/core/provider-request-context-controller.js.map +1 -1
  87. package/dist/core/provider-request-runtime-controller.d.ts.map +1 -1
  88. package/dist/core/provider-request-runtime-controller.js +3 -2
  89. package/dist/core/provider-request-runtime-controller.js.map +1 -1
  90. package/dist/core/runtime-builder.d.ts.map +1 -1
  91. package/dist/core/runtime-builder.js +13 -4
  92. package/dist/core/runtime-builder.js.map +1 -1
  93. package/dist/core/sdk.d.ts +3 -1
  94. package/dist/core/sdk.d.ts.map +1 -1
  95. package/dist/core/sdk.js +3 -1
  96. package/dist/core/sdk.js.map +1 -1
  97. package/dist/core/session-analytics.d.ts +2 -2
  98. package/dist/core/session-analytics.d.ts.map +1 -1
  99. package/dist/core/session-analytics.js +3 -2
  100. package/dist/core/session-analytics.js.map +1 -1
  101. package/dist/core/session-manager-factory.d.ts +1 -1
  102. package/dist/core/session-manager-factory.d.ts.map +1 -1
  103. package/dist/core/session-manager-factory.js +1 -1
  104. package/dist/core/session-manager-factory.js.map +1 -1
  105. package/dist/core/session-role.d.ts.map +1 -1
  106. package/dist/core/session-role.js +2 -0
  107. package/dist/core/session-role.js.map +1 -1
  108. package/dist/core/session-tree-navigator.d.ts +2 -2
  109. package/dist/core/session-tree-navigator.d.ts.map +1 -1
  110. package/dist/core/session-tree-navigator.js +1 -1
  111. package/dist/core/session-tree-navigator.js.map +1 -1
  112. package/dist/core/skill-vault.d.ts +6 -7
  113. package/dist/core/skill-vault.d.ts.map +1 -1
  114. package/dist/core/skill-vault.js +12 -12
  115. package/dist/core/skill-vault.js.map +1 -1
  116. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  117. package/dist/core/tool-capability-policy.js +2 -1
  118. package/dist/core/tool-capability-policy.js.map +1 -1
  119. package/dist/core/tools/bash.d.ts +2 -0
  120. package/dist/core/tools/bash.d.ts.map +1 -1
  121. package/dist/core/tools/bash.js +27 -12
  122. package/dist/core/tools/bash.js.map +1 -1
  123. package/dist/core/tools/early-powershell-session.d.ts +21 -0
  124. package/dist/core/tools/early-powershell-session.d.ts.map +1 -0
  125. package/dist/core/tools/early-powershell-session.js +137 -0
  126. package/dist/core/tools/early-powershell-session.js.map +1 -0
  127. package/dist/core/tools/edit.d.ts +1 -1
  128. package/dist/core/tools/edit.d.ts.map +1 -1
  129. package/dist/core/tools/edit.js +1 -1
  130. package/dist/core/tools/edit.js.map +1 -1
  131. package/dist/core/tools/file-failure-recovery.d.ts +1 -1
  132. package/dist/core/tools/file-failure-recovery.d.ts.map +1 -1
  133. package/dist/core/tools/file-failure-recovery.js +1 -1
  134. package/dist/core/tools/file-failure-recovery.js.map +1 -1
  135. package/dist/core/tools/goal.d.ts +9 -2
  136. package/dist/core/tools/goal.d.ts.map +1 -1
  137. package/dist/core/tools/goal.js +64 -1
  138. package/dist/core/tools/goal.js.map +1 -1
  139. package/dist/core/tools/grep.d.ts +2 -2
  140. package/dist/core/tools/grep.d.ts.map +1 -1
  141. package/dist/core/tools/grep.js +1 -1
  142. package/dist/core/tools/grep.js.map +1 -1
  143. package/dist/core/tools/output-accumulator.d.ts +2 -0
  144. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  145. package/dist/core/tools/output-accumulator.js +2 -1
  146. package/dist/core/tools/output-accumulator.js.map +1 -1
  147. package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -1
  148. package/dist/core/tools/persistent-process-coordinator.js +2 -11
  149. package/dist/core/tools/persistent-process-coordinator.js.map +1 -1
  150. package/dist/core/tools/read.d.ts +2 -2
  151. package/dist/core/tools/read.d.ts.map +1 -1
  152. package/dist/core/tools/read.js +1 -1
  153. package/dist/core/tools/read.js.map +1 -1
  154. package/dist/core/tools/render-utils.d.ts +1 -0
  155. package/dist/core/tools/render-utils.d.ts.map +1 -1
  156. package/dist/core/tools/render-utils.js +11 -9
  157. package/dist/core/tools/render-utils.js.map +1 -1
  158. package/dist/core/tools/shell-output-decoder.d.ts +7 -0
  159. package/dist/core/tools/shell-output-decoder.d.ts.map +1 -0
  160. package/dist/core/tools/shell-output-decoder.js +135 -0
  161. package/dist/core/tools/shell-output-decoder.js.map +1 -0
  162. package/dist/core/tools/shell-session.d.ts +23 -6
  163. package/dist/core/tools/shell-session.d.ts.map +1 -1
  164. package/dist/core/tools/shell-session.js +275 -88
  165. package/dist/core/tools/shell-session.js.map +1 -1
  166. package/dist/core/tools/skill.js +2 -2
  167. package/dist/core/tools/skill.js.map +1 -1
  168. package/dist/core/tools/write.d.ts +1 -1
  169. package/dist/core/tools/write.d.ts.map +1 -1
  170. package/dist/core/tools/write.js +1 -1
  171. package/dist/core/tools/write.js.map +1 -1
  172. package/dist/index.d.ts +1 -1
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +1 -1
  175. package/dist/index.js.map +1 -1
  176. package/dist/main.d.ts.map +1 -1
  177. package/dist/main.js +2 -0
  178. package/dist/main.js.map +1 -1
  179. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  180. package/dist/modes/interactive/components/bash-execution.js +4 -33
  181. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  182. package/dist/modes/interactive/components/tool-execution.d.ts +3 -0
  183. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  184. package/dist/modes/interactive/components/tool-execution.js +63 -27
  185. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  186. package/dist/utils/child-process-ref.d.ts +4 -0
  187. package/dist/utils/child-process-ref.d.ts.map +1 -0
  188. package/dist/utils/child-process-ref.js +15 -0
  189. package/dist/utils/child-process-ref.js.map +1 -0
  190. package/dist/utils/powershell-session-protocol.d.ts +16 -0
  191. package/dist/utils/powershell-session-protocol.d.ts.map +1 -0
  192. package/dist/utils/powershell-session-protocol.js +63 -0
  193. package/dist/utils/powershell-session-protocol.js.map +1 -0
  194. package/dist/utils/shell.d.ts +7 -4
  195. package/dist/utils/shell.d.ts.map +1 -1
  196. package/dist/utils/shell.js +38 -23
  197. package/dist/utils/shell.js.map +1 -1
  198. package/docs/settings.md +2 -2
  199. package/docs/windows.md +9 -8
  200. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  201. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  202. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  203. package/examples/extensions/sandbox/package-lock.json +2 -2
  204. package/examples/extensions/sandbox/package.json +2 -2
  205. package/examples/extensions/with-deps/package-lock.json +2 -2
  206. package/examples/extensions/with-deps/package.json +1 -1
  207. package/npm-shrinkwrap.json +318 -332
  208. package/package.json +4 -4
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,aAAa;AACb,OAAO,EAIN,mBAAmB,EAInB,uBAAuB,EAIvB,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EAGd,YAAY,EACZ,kBAAkB,EAElB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EAExB,qBAAqB,EAErB,mBAAmB,EACnB,oBAAoB,EAOpB,cAAc,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AAe,EACf,OAAO,EACP,OAAO,EACP,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EAEtB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EAGxB,yBAAyB,EACzB,2BAA2B,EAC3B,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EAInB,sBAAsB,EAEtB,kBAAkB,EAIlB,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,GAE5B,MAAM,yCAAyC,CAAC;AACjD,kDAAkD;AAClD,OAAO,EACN,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,KAAK,GAEL,MAAM,oCAAoC,CAAC;AAC5C,sBAAsB;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAqB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9F,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEN,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAGf,MAAM,2BAA2B,CAAC","sourcesContent":["// Core session management\n\nexport { convertToLlm } from \"@caupulican/pi-agent-core\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryEntry,\n\ttype BranchSummaryResult,\n\tbuildSessionContext,\n\ttype CollectEntriesResult,\n\ttype CompactionEntry,\n\ttype CompactionResult,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileEntry,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\tprepareBranchEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\tserializeConversation,\n\tshouldCompact,\n\ttype ThinkingLevelChangeEntry,\n} from \"@caupulican/pi-agent-core/node\";\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextEventResult,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionStorage,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tExtensionWorkRunOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageEndEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionMode,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tdefineTool,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\nexport { createExtensionRuntime, discoverAndLoadExtensions } from \"./core/extensions/loader.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport {\n\tappendRunRecord,\n\ttype ConfidenceMode,\n\ttype ConfidenceResult,\n\tcleanupImprovementSandbox,\n\tcompareMetric,\n\tcomputeMadConfidence,\n\tcreateImprovementDecisionTool,\n\tcreateImprovementLoopTool,\n\tcreateImprovementSandbox,\n\tdecideImprovement,\n\texportImprovementSandboxPatch,\n\ttype GitStatusEntry,\n\ttype ImprovementDecision,\n\ttype ImprovementDecisionInput,\n\ttype ImprovementDecisionReason,\n\ttype ImprovementDecisionResult,\n\ttype ImprovementLoopConfig,\n\ttype ImprovementLoopExec,\n\ttype ImprovementLoopInitInput,\n\ttype ImprovementLoopPaths,\n\ttype ImprovementLoopRecordInput,\n\ttype ImprovementLoopState,\n\ttype ImprovementLoopStatusInput,\n\ttype ImprovementLoopToolAction,\n\ttype ImprovementLoopToolDetails,\n\ttype ImprovementMeasurementCommandResult,\n\ttype ImprovementMeasurementResult,\n\ttype ImprovementRunRecord,\n\ttype ImprovementSandboxCleanupInput,\n\ttype ImprovementSandboxCreateInput,\n\ttype ImprovementSandboxExportInput,\n\ttype ImprovementSandboxRecord,\n\timprovementLoopPaths,\n\tinitImprovementLoop,\n\ttype LowConfidenceAction,\n\ttype MetricComparison,\n\ttype MetricDirection,\n\tmedian,\n\tmedianAbsoluteDeviation,\n\tmetricMapFromOutput,\n\ttype OwnedDiscardPlan,\n\ttype OwnedDiscardPlanInput,\n\tparseGitPorcelainStatus,\n\tparseMetricLines,\n\tplanOwnedDiscard,\n\treadImprovementLoopState,\n\treadRunRecords,\n\trecordImprovementRun,\n\trunImprovementMeasurement,\n\tselectPrimaryMetric,\n\tserializeRunRecord,\n} from \"./core/improvement-loop.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport * from \"./core/orchestration/capability-gateway.ts\";\nexport * from \"./core/orchestration/contracts.ts\";\nexport * from \"./core/orchestration/event-store.ts\";\nexport * from \"./core/orchestration/model-binding.ts\";\nexport * from \"./core/orchestration/policy-compiler.ts\";\nexport * from \"./core/orchestration/profile-registry.ts\";\nexport * from \"./core/orchestration/profile-store.ts\";\nexport * from \"./core/orchestration/task-runtime.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport { PI_ORCHESTRATION_AGENT_ID_ENV } from \"./core/process-identity.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tgetReloadCoordinationDir,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionRuntimeResource,\n\ttype AgentSessionServices,\n\ttype AgentSessionSwitchOptions,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n\tSessionReplacementCallbackError,\n\tSessionReplacementRuntimeError,\n} from \"./core/sdk.ts\";\nexport {\n\tBitwardenCredentialStorage,\n\tBitwardenCredentialStorageError,\n\ttype BitwardenCredentialStorageErrorCode,\n\ttype BitwardenCredentialStorageOptions,\n} from \"./core/secrets/bitwarden-credential-storage.ts\";\nexport {\n\ttype CredentialActivationResult,\n\ttype CredentialConnectionStatus,\n\tCredentialManager,\n\tCredentialManagerError,\n\ttype CredentialManagerErrorCode,\n\ttype CredentialManagerOptions,\n\ttype CredentialMutationResult,\n\ttype CredentialProfileRecord,\n\ttype CredentialProfileStorage,\n\ttype CredentialProfileSummary,\n\ttype CredentialProjectIdentity,\n\ttype CredentialProjectResolver,\n\tCredentialStorageError,\n\ttype CredentialStorageErrorCode,\n\ttype CredentialVariable,\n\ttype StoredCredentialProfileSummary,\n} from \"./core/secrets/credential-manager.ts\";\nexport {\n\ttype CredentialMigrationSource,\n\tCredentialMigrationSourceError,\n\ttype CredentialMigrationSourceErrorCode,\n\ttype CredentialMigrationSourceResolver,\n\tresolveCredentialMigrationSources,\n} from \"./core/secrets/credential-migration-source.ts\";\nexport { createPortableGitProjectKey, resolveCredentialProject } from \"./core/secrets/credential-project.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\nexport {\n\tACTIVE_SKILL_CONTEXT_CUSTOM_TYPE,\n\tDEFAULT_SKILL_IDLE_TIMEOUT_MS,\n\tMAX_ACTIVE_SKILL_BODY_BYTES,\n\tMIN_ACTIVE_SKILL_BODY_BYTES,\n\tresolveActiveSkillBodyByteLimit,\n\ttype SkillLoadResult,\n\ttype SkillSearchResult,\n\tSkillVaultController,\n\ttype SkillVaultControllerOptions,\n\ttype SkillVaultStatus,\n} from \"./core/skill-vault.ts\";\n// Skills\nexport {\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\tMAX_SKILL_FRONTMATTER_BYTES,\n\treadSkillFrontmatterFile,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\nexport {\n\ttype AskQuestion,\n\ttype AskQuestionAnswer,\n\tAskQuestionDialog,\n\ttype AskQuestionStopReason,\n\ttype AskQuestionToolDetails,\n\ttype AskQuestionToolInput,\n\ttype AskQuestionToolOptions,\n\tcreateAskQuestionToolDefinition,\n} from \"./core/tools/ask-question.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFileFailureRecoveryAuthority,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateSecretStoreToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FileContentReference,\n\ttype FileFailureRecoveryAuthority,\n\tFileMutationIntentController,\n\ttype FileMutationIntentControllerOptions,\n\ttype FileMutationIntentOperations,\n\ttype FileMutationKind,\n\ttype FileMutationLease,\n\ttype FileMutationPayloadReference,\n\tFileMutationPreflightError,\n\ttype FileMutationPreflightFailureReason,\n\ttype FilePathIdentity,\n\ttype FilePathInspection,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatMiddleOmissionMarker,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype SecretStoreStatus,\n\ttype SecretStoreToolDetails,\n\ttype SecretStoreToolInput,\n\ttype SecretStoreToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateKnownHeadTail,\n\ttruncateLine,\n\ttruncateMiddle,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport {\n\tcreateSkillVaultToolDefinition,\n\ttype SkillToolDetails,\n\ttype SkillToolInput,\n} from \"./core/tools/skill.ts\";\n// Skill-audit primitives — exported so extensions (e.g. continuous-learning) can reuse the native\n// Jaccard overlap audit via `import { runSkillAudit } from \"@caupulican/pi-adaptative\"` instead of\n// carrying a duplicate copy.\nexport {\n\tjaccard,\n\trunSkillAudit,\n\ttype SkillAuditReport,\n\ttype SkillSummary,\n\ttokenize,\n} from \"./core/tools/skill-audit.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\nexport {\n\ttype AcquireWorkRunOptions,\n\tacquireWorkRun,\n\tassertPortablePathSegment,\n\tboundedWorkRetention,\n\tcreateWorkRunId,\n\tgetProcessWorkRun,\n\tgetWorkRoot,\n\tgetWorkRunDir,\n\tgetWorkTenantDir,\n\tPI_WORK_ROOT_ENV,\n\tpruneWorkTenant,\n\ttype WorkRetentionOptions,\n\ttype WorkRunLease,\n} from \"./utils/work-directory.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,aAAa;AACb,OAAO,EAIN,mBAAmB,EAInB,uBAAuB,EAIvB,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EAGd,YAAY,EACZ,kBAAkB,EAElB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EAExB,qBAAqB,EAErB,mBAAmB,EACnB,oBAAoB,EAOpB,cAAc,EAEd,qBAAqB,EACrB,aAAa,GAEb,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAa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V,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EAGxB,yBAAyB,EACzB,2BAA2B,EAC3B,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EAInB,sBAAsB,EAEtB,kBAAkB,EAIlB,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,GAE5B,MAAM,yCAAyC,CAAC;AACjD,kDAAkD;AAClD,OAAO,EACN,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,KAAK,GAEL,MAAM,oCAAoC,CAAC;AAC5C,sBAAsB;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAqB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9F,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEN,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAGf,MAAM,2BAA2B,CAAC","sourcesContent":["// Core session management\n\nexport { convertToLlm } from \"@caupulican/pi-agent-core\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryEntry,\n\ttype BranchSummaryResult,\n\tbuildSessionContext,\n\ttype CollectEntriesResult,\n\ttype CompactionEntry,\n\ttype CompactionResult,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileEntry,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\tprepareBranchEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\tserializeConversation,\n\tshouldCompact,\n\ttype ThinkingLevelChangeEntry,\n} from \"@caupulican/pi-agent-core/node\";\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextEventResult,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionStorage,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tExtensionWorkRunOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageEndEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionMode,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tdefineTool,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\nexport { createExtensionRuntime, discoverAndLoadExtensions } from \"./core/extensions/loader.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport {\n\tappendRunRecord,\n\ttype ConfidenceMode,\n\ttype ConfidenceResult,\n\tcleanupImprovementSandbox,\n\tcompareMetric,\n\tcomputeMadConfidence,\n\tcreateImprovementDecisionTool,\n\tcreateImprovementLoopTool,\n\tcreateImprovementSandbox,\n\tdecideImprovement,\n\texportImprovementSandboxPatch,\n\ttype GitStatusEntry,\n\ttype ImprovementDecision,\n\ttype ImprovementDecisionInput,\n\ttype ImprovementDecisionReason,\n\ttype ImprovementDecisionResult,\n\ttype ImprovementLoopConfig,\n\ttype ImprovementLoopExec,\n\ttype ImprovementLoopInitInput,\n\ttype ImprovementLoopPaths,\n\ttype ImprovementLoopRecordInput,\n\ttype ImprovementLoopState,\n\ttype ImprovementLoopStatusInput,\n\ttype ImprovementLoopToolAction,\n\ttype ImprovementLoopToolDetails,\n\ttype ImprovementMeasurementCommandResult,\n\ttype ImprovementMeasurementResult,\n\ttype ImprovementRunRecord,\n\ttype ImprovementSandboxCleanupInput,\n\ttype ImprovementSandboxCreateInput,\n\ttype ImprovementSandboxExportInput,\n\ttype ImprovementSandboxRecord,\n\timprovementLoopPaths,\n\tinitImprovementLoop,\n\ttype LowConfidenceAction,\n\ttype MetricComparison,\n\ttype MetricDirection,\n\tmedian,\n\tmedianAbsoluteDeviation,\n\tmetricMapFromOutput,\n\ttype OwnedDiscardPlan,\n\ttype OwnedDiscardPlanInput,\n\tparseGitPorcelainStatus,\n\tparseMetricLines,\n\tplanOwnedDiscard,\n\treadImprovementLoopState,\n\treadRunRecords,\n\trecordImprovementRun,\n\trunImprovementMeasurement,\n\tselectPrimaryMetric,\n\tserializeRunRecord,\n} from \"./core/improvement-loop.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport * from \"./core/orchestration/capability-gateway.ts\";\nexport * from \"./core/orchestration/contracts.ts\";\nexport * from \"./core/orchestration/event-store.ts\";\nexport * from \"./core/orchestration/model-binding.ts\";\nexport * from \"./core/orchestration/policy-compiler.ts\";\nexport * from \"./core/orchestration/profile-registry.ts\";\nexport * from \"./core/orchestration/profile-store.ts\";\nexport * from \"./core/orchestration/task-runtime.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport { PI_ORCHESTRATION_AGENT_ID_ENV } from \"./core/process-identity.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tgetReloadCoordinationDir,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionRuntimeResource,\n\ttype AgentSessionServices,\n\ttype AgentSessionSwitchOptions,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n\tSessionReplacementCallbackError,\n\tSessionReplacementRuntimeError,\n} from \"./core/sdk.ts\";\nexport {\n\tBitwardenCredentialStorage,\n\tBitwardenCredentialStorageError,\n\ttype BitwardenCredentialStorageErrorCode,\n\ttype BitwardenCredentialStorageOptions,\n} from \"./core/secrets/bitwarden-credential-storage.ts\";\nexport {\n\ttype CredentialActivationResult,\n\ttype CredentialConnectionStatus,\n\tCredentialManager,\n\tCredentialManagerError,\n\ttype CredentialManagerErrorCode,\n\ttype CredentialManagerOptions,\n\ttype CredentialMutationResult,\n\ttype CredentialProfileRecord,\n\ttype CredentialProfileStorage,\n\ttype CredentialProfileSummary,\n\ttype CredentialProjectIdentity,\n\ttype CredentialProjectResolver,\n\tCredentialStorageError,\n\ttype CredentialStorageErrorCode,\n\ttype CredentialVariable,\n\ttype StoredCredentialProfileSummary,\n} from \"./core/secrets/credential-manager.ts\";\nexport {\n\ttype CredentialMigrationSource,\n\tCredentialMigrationSourceError,\n\ttype CredentialMigrationSourceErrorCode,\n\ttype CredentialMigrationSourceResolver,\n\tresolveCredentialMigrationSources,\n} from \"./core/secrets/credential-migration-source.ts\";\nexport { createPortableGitProjectKey, resolveCredentialProject } from \"./core/secrets/credential-project.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\nexport {\n\tDEFAULT_SKILL_IDLE_TIMEOUT_MS,\n\tMAX_ACTIVE_SKILL_BODY_BYTES,\n\tMIN_ACTIVE_SKILL_BODY_BYTES,\n\tresolveActiveSkillBodyByteLimit,\n\ttype SkillLoadResult,\n\ttype SkillSearchResult,\n\tSkillVaultController,\n\ttype SkillVaultControllerOptions,\n\ttype SkillVaultStatus,\n} from \"./core/skill-vault.ts\";\n// Skills\nexport {\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\tMAX_SKILL_FRONTMATTER_BYTES,\n\treadSkillFrontmatterFile,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\nexport {\n\ttype AskQuestion,\n\ttype AskQuestionAnswer,\n\tAskQuestionDialog,\n\ttype AskQuestionStopReason,\n\ttype AskQuestionToolDetails,\n\ttype AskQuestionToolInput,\n\ttype AskQuestionToolOptions,\n\tcreateAskQuestionToolDefinition,\n} from \"./core/tools/ask-question.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFileFailureRecoveryAuthority,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateSecretStoreToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FileContentReference,\n\ttype FileFailureRecoveryAuthority,\n\tFileMutationIntentController,\n\ttype FileMutationIntentControllerOptions,\n\ttype FileMutationIntentOperations,\n\ttype FileMutationKind,\n\ttype FileMutationLease,\n\ttype FileMutationPayloadReference,\n\tFileMutationPreflightError,\n\ttype FileMutationPreflightFailureReason,\n\ttype FilePathIdentity,\n\ttype FilePathInspection,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatMiddleOmissionMarker,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype SecretStoreStatus,\n\ttype SecretStoreToolDetails,\n\ttype SecretStoreToolInput,\n\ttype SecretStoreToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateKnownHeadTail,\n\ttruncateLine,\n\ttruncateMiddle,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport {\n\tcreateSkillVaultToolDefinition,\n\ttype SkillToolDetails,\n\ttype SkillToolInput,\n} from \"./core/tools/skill.ts\";\n// Skill-audit primitives — exported so extensions (e.g. continuous-learning) can reuse the native\n// Jaccard overlap audit via `import { runSkillAudit } from \"@caupulican/pi-adaptative\"` instead of\n// carrying a duplicate copy.\nexport {\n\tjaccard,\n\trunSkillAudit,\n\ttype SkillAuditReport,\n\ttype SkillSummary,\n\ttokenize,\n} from \"./core/tools/skill-audit.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\nexport {\n\ttype AcquireWorkRunOptions,\n\tacquireWorkRun,\n\tassertPortablePathSegment,\n\tboundedWorkRetention,\n\tcreateWorkRunId,\n\tgetProcessWorkRun,\n\tgetWorkRoot,\n\tgetWorkRunDir,\n\tgetWorkTenantDir,\n\tPI_WORK_ROOT_ENV,\n\tpruneWorkTenant,\n\ttype WorkRetentionOptions,\n\ttype WorkRunLease,\n} from \"./utils/work-directory.ts\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,iCAAiC,CAAC;AAUzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAgGnE,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,EAC7C,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAmC,GACzD,OAAO,CAAC,IAAI,CAAC,CAMf;AAgGD,4GAA4G;AAC5G,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBrE;AAqYD,MAAM,WAAW,WAAW;IAC3B,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACxC;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,iBAiiB/D"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,iCAAiC,CAAC;AAUzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAgGnE,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,EAC7C,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAmC,GACzD,OAAO,CAAC,IAAI,CAAC,CAMf;AAgGD,4GAA4G;AAC5G,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBrE;AAsYD,MAAM,WAAW,WAAW;IAC3B,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACxC;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,iBAkiB/D"}
package/dist/main.js CHANGED
@@ -386,6 +386,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
386
386
  if (parsed.thinking) {
387
387
  options.thinkingLevel = parsed.thinking;
388
388
  }
389
+ options.serviceTier = parsed.serviceTier;
389
390
  // Scoped models for Ctrl+P cycling
390
391
  // Keep thinking level undefined when not explicitly set in the model pattern.
391
392
  // Undefined means "inherit current session thinking level" during cycling.
@@ -765,6 +766,7 @@ export async function main(args, options) {
765
766
  sessionStartEvent,
766
767
  model: sessionOptions.model,
767
768
  thinkingLevel: sessionOptions.thinkingLevel,
769
+ serviceTier: sessionOptions.serviceTier,
768
770
  isExplicitModel: sessionOptions.isExplicitModel,
769
771
  isExplicitThinking: sessionOptions.isExplicitThinking,
770
772
  scopedModels: sessionOptions.scopedModels,
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAqB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EAGN,yBAAyB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEN,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,uB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ding agent CLI.\n *\n * This file handles CLI argument parsing and translates them into\n * createAgentSession() options. The SDK does the heavy lifting.\n */\n\nimport { createInterface } from \"node:readline\";\nimport { assertValidSessionId, SessionManager } from \"@caupulican/pi-agent-core/session\";\nimport { type ImageContent, modelsAreEqual } from \"@caupulican/pi-ai\";\nimport { ProcessTerminal, setKeybindings, TUI } from \"@caupulican/pi-tui\";\nimport chalk from \"chalk\";\nimport { type Args, type Mode, parseArgs, printHelp } from \"./cli/args.ts\";\nimport { processFileArguments } from \"./cli/file-processor.ts\";\nimport { buildInitialMessage } from \"./cli/initial-message.ts\";\nimport { listModels } from \"./cli/list-models.ts\";\nimport { readPipedInput } from \"./cli/piped-stdin.ts\";\nimport { selectSession } from \"./cli/session-picker.ts\";\nimport { ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir, VERSION } from \"./config.ts\";\nimport {\n\ttype AgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\tcreateAgentSessionRuntime,\n} from \"./core/agent-session-runtime.ts\";\nimport {\n\ttype AgentSessionRuntimeDiagnostic,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./core/agent-session-services.ts\";\nimport { formatNoModelsAvailableMessage } from \"./core/auth-guidance.ts\";\nimport { AuthStorage } from \"./core/auth-storage.ts\";\nimport { formatDoctorReport, runDoctor, runUpdatePreflight } from \"./core/doctor.ts\";\nimport { exportFromFile } from \"./core/export-html/index.ts\";\nimport type { ExtensionFactory } from \"./core/extensions/types.ts\";\nimport { configureHttpDispatcher } from \"./core/http-dispatcher.ts\";\nimport { KeybindingsManager } from \"./core/keybindings.ts\";\nimport { formatLaneWorkerRefusal } from \"./core/model-capability.ts\";\nimport type { ModelRegistry } from \"./core/model-registry.ts\";\nimport {\n\tresolveCliModel,\n\tresolveCliProviderDefault,\n\tresolveModelScope,\n\tresolveProfileModelSettings,\n\ttype ScopedModel,\n} from \"./core/model-resolver.ts\";\nimport { collectModelRouterConfigDiagnostics } from \"./core/model-router/config-diagnostics.ts\";\nimport type { OrchestrationProfile } from \"./core/orchestration/contracts.ts\";\nimport { resolveConfiguredOrchestrationModel } from \"./core/orchestration/model-binding.ts\";\nimport { OrchestrationProfileStore } from \"./core/orchestration/profile-store.ts\";\nimport { restoreStdout, takeOverStdout } from \"./core/output-guard.ts\";\nimport type { ResumablePayload } from \"./core/process-matrix/codes.ts\";\nimport { launchResumablePiAgent } from \"./core/process-matrix/resume-launcher.ts\";\nimport {\n\tPI_PARENT_PID_ENV,\n\tPI_PARENT_SESSION_ENV,\n\tPI_TASK_REF_ENV,\n\ttype ResumeWorkerLaunchOutcome,\n} from \"./core/process-matrix/runtime.ts\";\nimport { isReloadSessionProcessAlive } from \"./core/reload-blockers.ts\";\nimport { parseResourceProfileInput } from \"./core/resource-profile-blocks.ts\";\nimport type { CreateAgentSessionOptions } from \"./core/sdk.ts\";\nimport {\n\tformatMissingSessionCwdPrompt,\n\tgetMissingSessionCwdIssue,\n\tMissingSessionCwdError,\n\ttype SessionCwdIssue,\n} from \"./core/session-cwd.ts\";\nimport {\n\tcontinueRecentSession,\n\tcreateSession,\n\tforkSession,\n\tlistAllSessions,\n\tlistSessions,\n\topenSession,\n} from \"./core/session-manager-factory.ts\";\nimport { getSessionRole, setTerminalSessionMode } from \"./core/session-role.ts\";\nimport { SessionSupervisionRuntime } from \"./core/session-supervision-runtime.ts\";\nimport { SettingsManager } from \"./core/settings-manager.ts\";\nimport { printTimings, resetTimings, time } from \"./core/timings.ts\";\nimport { hasProjectTrustInputs, ProjectTrustStore } from \"./core/trust-manager.ts\";\nimport { getBoundWorktreeLaneKey, PI_WORKTREE_LANE_ENV } from \"./core/worktree-sync/runtime.ts\";\nimport { runMigrations, showDeprecationWarnings } from \"./migrations.ts\";\n\nimport { handleConfigCommand, handlePackageCommand } from \"./package-manager-cli.ts\";\nimport { isLocalPath, normalizePath, resolvePath } from \"./utils/paths.ts\";\nimport { cleanupWindowsSelfUpdateQuarantine } from \"./utils/windows-self-update.ts\";\nimport { getProcessWorkRun, getWorkRoot, PI_WORK_ROOT_ENV } from \"./utils/work-directory.ts\";\n\nfunction getSelfLaunchTarget(): { executable: string; argsPrefix: string[] } | undefined {\n\tconst executableName = process.execPath.split(/[\\\\/]/).at(-1)?.toLowerCase();\n\tconst isScriptRuntime = [\"node\", \"node.exe\", \"bun\", \"bun.exe\"].includes(executableName ?? \"\");\n\tif (!isScriptRuntime) return { executable: process.execPath, argsPrefix: [] };\n\tconst cliPath = process.argv[1];\n\treturn cliPath && !cliPath.startsWith(\"-\") ? { executable: process.execPath, argsPrefix: [cliPath] } : undefined;\n}\n\nasync function launchResumableWorker(\n\tpayload: ResumablePayload,\n\tparentSessionId: string,\n): Promise<ResumeWorkerLaunchOutcome> {\n\tconst target = getSelfLaunchTarget();\n\tif (!target) return { started: false, reason: \"The current Pi executable cannot be resolved.\" };\n\treturn launchResumablePiAgent({\n\t\tpayload,\n\t\ttarget,\n\t\tparentPid: process.pid,\n\t\tparentSessionId,\n\t\tenvironment: process.env,\n\t});\n}\n\nfunction collectSettingsDiagnostics(\n\tsettingsManager: SettingsManager,\n\tcontext: string,\n): AgentSessionRuntimeDiagnostic[] {\n\treturn settingsManager.drainErrors().map(({ scope, error }) => ({\n\t\ttype: \"warning\",\n\t\tmessage: `(${context}, ${scope} settings) ${error.message}`,\n\t}));\n}\n\nfunction reportDiagnostics(diagnostics: readonly AgentSessionRuntimeDiagnostic[]): void {\n\tfor (const diagnostic of diagnostics) {\n\t\tconst color = diagnostic.type === \"error\" ? chalk.red : diagnostic.type === \"warning\" ? chalk.yellow : chalk.dim;\n\t\tconst prefix = diagnostic.type === \"error\" ? \"Error: \" : diagnostic.type === \"warning\" ? \"Warning: \" : \"\";\n\t\tconsole.error(color(`${prefix}${diagnostic.message}`));\n\t}\n}\n\nexport async function disposeRuntimeAndExit(\n\truntime: Pick<AgentSessionRuntime, \"dispose\">,\n\texitCode: number,\n\texit: (code: number) => void = (code) => process.exit(code),\n): Promise<void> {\n\ttry {\n\t\tawait runtime.dispose();\n\t} finally {\n\t\texit(exitCode);\n\t}\n}\n\nfunction isTruthyEnvFlag(value: string | undefined): boolean {\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ntype AppMode = \"interactive\" | \"print\" | \"json\" | \"rpc\";\n\nfunction resolveAppMode(parsed: Args, stdinIsTTY: boolean): AppMode {\n\tif (parsed.mode === \"rpc\") {\n\t\treturn \"rpc\";\n\t}\n\tif (parsed.mode === \"json\") {\n\t\treturn \"json\";\n\t}\n\tif (parsed.print || !stdinIsTTY) {\n\t\treturn \"print\";\n\t}\n\treturn \"interactive\";\n}\n\nfunction toPrintOutputMode(appMode: AppMode): Exclude<Mode, \"rpc\"> {\n\treturn appMode === \"json\" ? \"json\" : \"text\";\n}\n\nasync function prepareInitialMessage(\n\tparsed: Args,\n\tautoResizeImages: boolean,\n\tstdinContent?: string,\n): Promise<{\n\tinitialMessage?: string;\n\tinitialImages?: ImageContent[];\n}> {\n\tif (parsed.fileArgs.length === 0) {\n\t\treturn buildInitialMessage({ parsed, stdinContent });\n\t}\n\n\tconst { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });\n\treturn buildInitialMessage({\n\t\tparsed,\n\t\tfileText: text,\n\t\tfileImages: images,\n\t\tstdinContent,\n\t});\n}\n\n/** Result from resolving a session argument */\ntype ResolvedSession =\n\t| { type: \"path\"; path: string } // Direct file path\n\t| { type: \"local\"; path: string } // Found in current project\n\t| { type: \"global\"; path: string; cwd: string } // Found in different project\n\t| { type: \"not_found\"; arg: string }; // Not found anywhere\n\n/**\n * Resolve a session argument to a file path.\n * If it looks like a path, use as-is. Otherwise try to match as session ID prefix.\n */\nasync function findLocalSessionByExactId(\n\tsessionId: string,\n\tcwd: string,\n\tsessionDir?: string,\n): Promise<{ type: \"local\"; path: string } | undefined> {\n\tconst localSessions = await listSessions(cwd, sessionDir);\n\tconst localMatch = localSessions.find((s) => s.id === sessionId);\n\treturn localMatch ? { type: \"local\", path: localMatch.path } : undefined;\n}\n\nasync function resolveSessionPath(sessionArg: string, cwd: string, sessionDir?: string): Promise<ResolvedSession> {\n\t// If it looks like a file path, resolve it before handing it to the session manager.\n\tif (sessionArg.includes(\"/\") || sessionArg.includes(\"\\\\\") || sessionArg.endsWith(\".jsonl\")) {\n\t\treturn { type: \"path\", path: resolvePath(sessionArg, cwd) };\n\t}\n\n\t// Try to match as session ID in current project first\n\tconst localSessions = await listSessions(cwd, sessionDir);\n\tconst localMatch =\n\t\tlocalSessions.find((s) => s.id === sessionArg) ?? localSessions.find((s) => s.id.startsWith(sessionArg));\n\n\tif (localMatch) {\n\t\treturn { type: \"local\", path: localMatch.path };\n\t}\n\n\t// Try global search across all projects\n\tconst allSessions = await listAllSessions(sessionDir);\n\tconst globalMatch =\n\t\tallSessions.find((s) => s.id === sessionArg) ?? allSessions.find((s) => s.id.startsWith(sessionArg));\n\n\tif (globalMatch) {\n\t\treturn { type: \"global\", path: globalMatch.path, cwd: globalMatch.cwd };\n\t}\n\n\t// Not found anywhere\n\treturn { type: \"not_found\", arg: sessionArg };\n}\n\n/** Prompt user for yes/no confirmation. Non-interactive callers fail closed instead of waiting on stdin. */\nexport async function promptConfirm(message: string): Promise<boolean> {\n\tif (!process.stdin.isTTY || !process.stdout.isTTY) return false;\n\treturn new Promise((resolve) => {\n\t\tconst rl = createInterface({\n\t\t\tinput: process.stdin,\n\t\t\toutput: process.stdout,\n\t\t});\n\t\tlet settled = false;\n\t\tconst finish = (confirmed: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\trl.removeListener(\"close\", onClose);\n\t\t\trl.close();\n\t\t\tresolve(confirmed);\n\t\t};\n\t\tconst onClose = () => finish(false);\n\t\trl.once(\"close\", onClose);\n\t\trl.question(`${message} [y/N] `, (answer) => {\n\t\t\tconst normalized = answer.trim().toLowerCase();\n\t\t\tfinish(normalized === \"y\" || normalized === \"yes\");\n\t\t});\n\t});\n}\n\nfunction collectSessionModeConflicts(parsed: Args): string[] {\n\treturn [\n\t\tparsed.session ? \"--session\" : undefined,\n\t\tparsed.continue ? \"--continue\" : undefined,\n\t\tparsed.resume ? \"--resume\" : undefined,\n\t\tparsed.noSession ? \"--no-session\" : undefined,\n\t].filter((flag): flag is string => flag !== undefined);\n}\n\nfunction validateForkFlags(parsed: Args): void {\n\tif (!parsed.fork) return;\n\n\tconst conflictingFlags = collectSessionModeConflicts(parsed);\n\tif (conflictingFlags.length > 0) {\n\t\tconsole.error(chalk.red(`Error: --fork cannot be combined with ${conflictingFlags.join(\", \")}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nfunction validateSessionIdFlags(parsed: Args): void {\n\tif (parsed.sessionId === undefined) return;\n\n\tconst conflictingFlags = collectSessionModeConflicts(parsed);\n\tif (conflictingFlags.length > 0) {\n\t\tconsole.error(chalk.red(`Error: --session-id cannot be combined with ${conflictingFlags.join(\", \")}`));\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\tassertValidSessionId(parsed.sessionId);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nfunction forkSessionOrExit(sourcePath: string, cwd: string, sessionDir?: string, sessionId?: string): SessionManager {\n\ttry {\n\t\treturn forkSession(sourcePath, cwd, sessionDir, { id: sessionId });\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nasync function createSessionManager(\n\tparsed: Args,\n\tcwd: string,\n\tsessionDir: string | undefined,\n\tsettingsManager: SettingsManager,\n\thasHumanUI: boolean,\n): Promise<SessionManager> {\n\tif (parsed.noSession || parsed.help || parsed.listModels !== undefined) {\n\t\treturn SessionManager.inMemory(cwd);\n\t}\n\n\tif (parsed.fork) {\n\t\tif (parsed.sessionId) {\n\t\t\tconst existingTarget = await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir);\n\t\t\tif (existingTarget) {\n\t\t\t\tconsole.error(chalk.red(`Session already exists with id '${parsed.sessionId}'`));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\n\t\tconst resolved = await resolveSessionPath(parsed.fork, cwd, sessionDir);\n\n\t\tswitch (resolved.type) {\n\t\t\tcase \"path\":\n\t\t\tcase \"local\":\n\t\t\tcase \"global\":\n\t\t\t\treturn forkSessionOrExit(resolved.path, cwd, sessionDir, parsed.sessionId);\n\n\t\t\tcase \"not_found\":\n\t\t\t\tconsole.error(chalk.red(`No session found matching '${resolved.arg}'`));\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tif (parsed.session) {\n\t\tconst resolved = await resolveSessionPath(parsed.session, cwd, sessionDir);\n\n\t\tswitch (resolved.type) {\n\t\t\tcase \"path\":\n\t\t\tcase \"local\":\n\t\t\t\treturn openSession(resolved.path, sessionDir);\n\n\t\t\tcase \"global\": {\n\t\t\t\tif (!hasHumanUI) {\n\t\t\t\t\tconsole.error(chalk.red(\"Cannot open a cross-project session without a user approval UI.\"));\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tconsole.log(chalk.yellow(`Session found in different project: ${resolved.cwd}`));\n\t\t\t\tconst shouldFork = await promptConfirm(\"Fork this session into current directory?\");\n\t\t\t\tif (!shouldFork) {\n\t\t\t\t\tconsole.log(chalk.dim(\"Aborted.\"));\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t\treturn forkSessionOrExit(resolved.path, cwd, sessionDir);\n\t\t\t}\n\n\t\t\tcase \"not_found\":\n\t\t\t\tconsole.error(chalk.red(`No session found matching '${resolved.arg}'`));\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tif (parsed.resume) {\n\t\tif (!hasHumanUI) {\n\t\t\tconsole.error(chalk.red(\"Error: --resume requires --session-mode user; use --session <id> for workers.\"));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconst { initTheme, stopThemeWatcher } = await import(\"./modes/interactive/theme/theme.ts\");\n\t\tinitTheme(settingsManager.getTheme(), true);\n\t\ttry {\n\t\t\tconst selectedPath = await selectSession(\n\t\t\t\t(onProgress) => listSessions(cwd, sessionDir, onProgress),\n\t\t\t\t(onProgress) => listAllSessions(sessionDir, onProgress),\n\t\t\t);\n\t\t\tif (!selectedPath) {\n\t\t\t\tconsole.log(chalk.dim(\"No session selected\"));\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t\treturn openSession(selectedPath, sessionDir);\n\t\t} finally {\n\t\t\tstopThemeWatcher();\n\t\t}\n\t}\n\n\tif (parsed.continue) {\n\t\treturn continueRecentSession(cwd, sessionDir);\n\t}\n\n\tif (parsed.sessionId) {\n\t\tconst existingSession = await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir);\n\t\tif (existingSession) {\n\t\t\treturn openSession(existingSession.path, sessionDir);\n\t\t}\n\t}\n\n\treturn createSession(cwd, sessionDir, { id: parsed.sessionId });\n}\n\nfunction buildSessionOptions(\n\tparsed: Args,\n\tscopedModels: ScopedModel[],\n\thasExistingSession: boolean,\n\tmodelRegistry: ModelRegistry,\n\tsettingsManager: SettingsManager,\n\tcwd: string,\n): {\n\toptions: CreateAgentSessionOptions;\n\tcliThinkingFromModel: boolean;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n} {\n\tconst options: CreateAgentSessionOptions = {};\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tlet cliThinkingFromModel = false;\n\n\t// Model from CLI\n\t// - supports --provider <name> --model <pattern>\n\t// - supports --provider <name> to select that provider's default model\n\t// - supports --model <provider>/<pattern>\n\tif (parsed.model || parsed.provider) {\n\t\tconst resolved = parsed.model\n\t\t\t? resolveCliModel({\n\t\t\t\t\tcliProvider: parsed.provider,\n\t\t\t\t\tcliModel: parsed.model,\n\t\t\t\t\tmodelRegistry,\n\t\t\t\t})\n\t\t\t: resolveCliProviderDefault({\n\t\t\t\t\tcliProvider: parsed.provider,\n\t\t\t\t\tmodelRegistry,\n\t\t\t\t});\n\t\tif (resolved.warning) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: resolved.warning });\n\t\t}\n\t\tif (resolved.error) {\n\t\t\tdiagnostics.push({ type: \"error\", message: resolved.error });\n\t\t}\n\t\tif (resolved.model) {\n\t\t\toptions.model = resolved.model;\n\t\t\t// Allow \"--model <pattern>:<thinking>\" as a shorthand.\n\t\t\t// Explicit --thinking still takes precedence (applied later).\n\t\t\tif (parsed.model && !parsed.thinking && resolved.thinkingLevel) {\n\t\t\t\toptions.thinkingLevel = resolved.thinkingLevel;\n\t\t\t\tcliThinkingFromModel = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Record whether model/thinking came from an explicit CLI flag (before the profile fills them\n\t// in below), so AgentSession can re-apply profile model/thinking on reload without clobbering\n\t// an explicit --model/--thinking.\n\toptions.isExplicitModel = !!parsed.model;\n\toptions.isExplicitThinking = !!parsed.thinking || cliThinkingFromModel;\n\n\t// Model/Thinking from active profiles if not explicitly set via CLI flags\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tif (activeProfileNames.length > 0) {\n\t\tconst profileSettings = resolveProfileModelSettings({\n\t\t\tactiveProfileNames,\n\t\t\tregistry: settingsManager.getProfileRegistry(),\n\t\t\tmodelRegistry,\n\t\t\tcwd,\n\t\t});\n\t\tif (profileSettings.warning) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: profileSettings.warning });\n\t\t}\n\t\tif (profileSettings.error) {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `Active profile model resolution error: ${profileSettings.error}`,\n\t\t\t});\n\t\t}\n\t\tif (!options.model && profileSettings.model) {\n\t\t\toptions.model = profileSettings.model;\n\t\t}\n\t\tif (!parsed.thinking && profileSettings.thinkingLevel) {\n\t\t\toptions.thinkingLevel = profileSettings.thinkingLevel;\n\t\t}\n\t}\n\n\tif (!options.model && scopedModels.length > 0 && !hasExistingSession) {\n\t\t// Check if saved default is in scoped models - use it if so, otherwise first scoped model\n\t\tconst savedProvider = settingsManager.getDefaultProvider();\n\t\tconst savedModelId = settingsManager.getDefaultModel();\n\t\tconst savedModel = savedProvider && savedModelId ? modelRegistry.find(savedProvider, savedModelId) : undefined;\n\t\tconst savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : undefined;\n\n\t\tif (savedInScope) {\n\t\t\toptions.model = savedInScope.model;\n\t\t\t// Use thinking level from scoped model config if explicitly set\n\t\t\tif (!parsed.thinking && savedInScope.thinkingLevel) {\n\t\t\t\toptions.thinkingLevel = savedInScope.thinkingLevel;\n\t\t\t}\n\t\t} else {\n\t\t\toptions.model = scopedModels[0].model;\n\t\t\t// Use thinking level from first scoped model if explicitly set\n\t\t\tif (!parsed.thinking && scopedModels[0].thinkingLevel) {\n\t\t\t\toptions.thinkingLevel = scopedModels[0].thinkingLevel;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Thinking level from CLI (takes precedence over scoped model thinking levels set above)\n\tif (parsed.thinking) {\n\t\toptions.thinkingLevel = parsed.thinking;\n\t}\n\n\t// Scoped models for Ctrl+P cycling\n\t// Keep thinking level undefined when not explicitly set in the model pattern.\n\t// Undefined means \"inherit current session thinking level\" during cycling.\n\tif (scopedModels.length > 0) {\n\t\toptions.scopedModels = scopedModels.map((sm) => ({\n\t\t\tmodel: sm.model,\n\t\t\tthinkingLevel: sm.thinkingLevel,\n\t\t}));\n\t}\n\n\t// API key from CLI - set in authStorage\n\t// (handled by caller before createAgentSession)\n\n\t// Tools\n\tif (parsed.noTools) {\n\t\toptions.noTools = \"all\";\n\t} else if (parsed.noBuiltinTools) {\n\t\toptions.noTools = \"builtin\";\n\t}\n\tif (parsed.tools) {\n\t\toptions.tools = [...parsed.tools];\n\t}\n\tif (parsed.excludeTools) {\n\t\toptions.excludeTools = [...parsed.excludeTools];\n\t}\n\n\treturn { options, cliThinkingFromModel, diagnostics };\n}\n\nfunction resolveCliPaths(cwd: string, paths: string[] | undefined): string[] | undefined {\n\treturn paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));\n}\n\nasync function showStartupSelector<T>(\n\tsettingsManager: SettingsManager,\n\ttitle: string,\n\toptions: Array<{ label: string; value: T }>,\n): Promise<T | undefined> {\n\tconst [{ ExtensionSelectorComponent }, { initTheme }] = await Promise.all([\n\t\timport(\"./modes/interactive/components/extension-selector.ts\"),\n\t\timport(\"./modes/interactive/theme/theme.ts\"),\n\t]);\n\tinitTheme(settingsManager.getTheme());\n\tsetKeybindings(KeybindingsManager.create());\n\n\treturn new Promise((resolve) => {\n\t\tconst ui = new TUI(new ProcessTerminal(), settingsManager.getShowHardwareCursor());\n\t\tui.setClearOnShrink(settingsManager.getClearOnShrink());\n\n\t\tlet settled = false;\n\t\tconst finish = (result: T | undefined) => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\tui.stop();\n\t\t\tresolve(result);\n\t\t};\n\n\t\tconst selector = new ExtensionSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions.map((option) => option.label),\n\t\t\t(option) => finish(options.find((entry) => entry.label === option)?.value),\n\t\t\t() => finish(undefined),\n\t\t\t{ tui: ui },\n\t\t);\n\t\tui.addChild(selector);\n\t\tui.setFocus(selector);\n\t\tui.start();\n\t});\n}\n\nasync function promptForMissingSessionCwd(\n\tissue: SessionCwdIssue,\n\tsettingsManager: SettingsManager,\n): Promise<string | undefined> {\n\treturn showStartupSelector(settingsManager, formatMissingSessionCwdPrompt(issue), [\n\t\t{ label: \"Continue\", value: issue.fallbackCwd },\n\t\t{ label: \"Cancel\", value: undefined },\n\t]);\n}\n\ninterface ProjectTrustPromptResult {\n\ttrusted: boolean;\n\tremember: boolean;\n}\n\nasync function promptForProjectTrust(\n\tcwd: string,\n\tsettingsManager: SettingsManager,\n): Promise<ProjectTrustPromptResult | undefined> {\n\treturn showStartupSelector(\n\t\tsettingsManager,\n\t\t`Trust project folder?\\n${cwd}\\n\\nThis allows pi to read project instructions (AGENTS.md/CLAUDE.md/GEMINI.md), load .pi settings and resources, install missing project packages, and execute project extensions.`,\n\t\t[\n\t\t\t{ label: \"Trust\", value: { trusted: true, remember: true } },\n\t\t\t{ label: \"Trust (this session only)\", value: { trusted: true, remember: false } },\n\t\t\t{ label: \"Do not trust\", value: { trusted: false, remember: true } },\n\t\t\t{ label: \"Do not trust (this session only)\", value: { trusted: false, remember: false } },\n\t\t],\n\t);\n}\n\nasync function resolveProjectTrusted(options: {\n\tcwd: string;\n\ttrustStore: ProjectTrustStore;\n\ttrustOverride?: boolean;\n\tappMode: AppMode;\n\tsettingsManagerForPrompt: SettingsManager;\n}): Promise<boolean> {\n\tif (options.trustOverride !== undefined) {\n\t\treturn options.trustOverride;\n\t}\n\tif (!hasProjectTrustInputs(options.cwd)) {\n\t\treturn true;\n\t}\n\n\tconst decision = options.trustStore.get(options.cwd);\n\tif (decision !== null) {\n\t\treturn decision;\n\t}\n\tif (options.appMode !== \"interactive\") {\n\t\treturn false;\n\t}\n\n\tconst selected = await promptForProjectTrust(options.cwd, options.settingsManagerForPrompt);\n\tif (selected !== undefined) {\n\t\tif (selected.remember) {\n\t\t\toptions.trustStore.set(options.cwd, selected.trusted);\n\t\t}\n\t\treturn selected.trusted;\n\t}\n\treturn false;\n}\n\nexport interface MainOptions {\n\textensionFactories?: ExtensionFactory[];\n}\n\nexport async function main(args: string[], options?: MainOptions) {\n\tresetTimings();\n\tconst workAgentDir = getAgentDir();\n\tprocess.env[PI_WORK_ROOT_ENV] = getWorkRoot(workAgentDir);\n\tif (process.env.PI_TUI_DEBUG === \"1\") {\n\t\tprocess.env.PI_TUI_WORK_DIR = getProcessWorkRun(workAgentDir, \"debug\", \"tui\").path;\n\t}\n\tconst offlineMode = args.includes(\"--offline\") || isTruthyEnvFlag(process.env.PI_OFFLINE);\n\tif (offlineMode) {\n\t\tprocess.env.PI_OFFLINE = \"1\";\n\t\tprocess.env.PI_SKIP_VERSION_CHECK = \"1\";\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\tcleanupWindowsSelfUpdateQuarantine(getPackageDir());\n\t}\n\n\tif (args[0] === \"doctor\") {\n\t\t// Interactive command: show fff-node install progress rather than a\n\t\t// silent multi-second gap (runUpdatePreflight's background run stays\n\t\t// quiet -- see the `{ silent: true }` default on runDoctor).\n\t\tconst report = await runDoctor(undefined, { silent: false });\n\t\tconsole.log(formatDoctorReport(report));\n\t\tprocess.exitCode = report.checks.some((check) => !check.present) ? 1 : 0;\n\t\treturn;\n\t}\n\n\tif (await handlePackageCommand(args)) {\n\t\t// Verify + provision required tooling right after an update, instead of\n\t\t// leaving it to lazy first-use (see doctor.ts's module doc). Best-effort\n\t\t// and non-fatal: runUpdatePreflight() never throws, so a broken\n\t\t// environment check can't turn a successful update into a failed one.\n\t\tif (args[0] === \"update\" && process.exitCode !== 1) {\n\t\t\tawait runUpdatePreflight();\n\t\t}\n\t\treturn;\n\t}\n\n\tif (await handleConfigCommand(args)) {\n\t\treturn;\n\t}\n\n\tconst parsed = parseArgs(args);\n\tif (parsed.diagnostics.length > 0) {\n\t\tfor (const d of parsed.diagnostics) {\n\t\t\tconst color = d.type === \"error\" ? chalk.red : chalk.yellow;\n\t\t\tconsole.error(color(`${d.type === \"error\" ? \"Error\" : \"Warning\"}: ${d.message}`));\n\t\t}\n\t\tif (parsed.diagnostics.some((d) => d.type === \"error\")) {\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\ttime(\"parseArgs\");\n\t// --worktree-lane is sugar over the cross-process env contract: setting the env here (before\n\t// any session/tool construction) makes the flag and a launcher-provided env byte-identical\n\t// downstream (RuntimeBuilder's lane gate, the epoch watcher, child processes).\n\tif (parsed.worktreeLane) {\n\t\tprocess.env[PI_WORKTREE_LANE_ENV] = parsed.worktreeLane;\n\t}\n\t// --parent-pid/--parent-session are the same CLI-sugar-over-env pattern as --worktree-lane:\n\t// setting the env here (before any session/tool construction) makes the flag and a\n\t// launcher-provided env byte-identical downstream (the process-matrix runtime's worker branch).\n\tif (parsed.parentPid !== undefined) {\n\t\tprocess.env[PI_PARENT_PID_ENV] = String(parsed.parentPid);\n\t}\n\tif (parsed.parentSession) {\n\t\tprocess.env[PI_PARENT_SESSION_ENV] = parsed.parentSession;\n\t}\n\tif (parsed.taskRef) {\n\t\tprocess.env[PI_TASK_REF_ENV] = parsed.taskRef;\n\t}\n\tif (parsed.sessionMode) {\n\t\tsetTerminalSessionMode(parsed.sessionMode);\n\t}\n\tlet appMode = resolveAppMode(parsed, process.stdin.isTTY);\n\tlet hasHumanUI = appMode === \"interactive\" && getSessionRole() === \"main\";\n\tconst shouldTakeOverStdout = appMode !== \"interactive\";\n\tif (shouldTakeOverStdout) {\n\t\ttakeOverStdout();\n\t}\n\n\tif (parsed.version) {\n\t\tconsole.log(VERSION);\n\t\tprocess.exit(0);\n\t}\n\n\tif (parsed.export) {\n\t\tlet result: string;\n\t\ttry {\n\t\t\tconst outputPath = parsed.messages.length > 0 ? parsed.messages[0] : undefined;\n\t\t\tresult = await exportFromFile(parsed.export, outputPath);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : \"Failed to export session\";\n\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconsole.log(`Exported to: ${result}`);\n\t\tprocess.exit(0);\n\t}\n\n\tif (parsed.mode === \"rpc\" && parsed.fileArgs.length > 0) {\n\t\tconsole.error(chalk.red(\"Error: @file arguments are not supported in RPC mode\"));\n\t\tprocess.exit(1);\n\t}\n\n\tvalidateForkFlags(parsed);\n\tvalidateSessionIdFlags(parsed);\n\n\t// Run migrations (pass cwd for project-local migrations)\n\tconst { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(process.cwd());\n\ttime(\"runMigrations\");\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\tconst startupProjectTrusted =\n\t\tparsed.projectTrustOverride ?? (!hasProjectTrustInputs(cwd) || trustStore.get(cwd) === true);\n\tconst startupSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: startupProjectTrusted });\n\treportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, \"startup session lookup\"));\n\n\t// Decide the final runtime cwd before creating cwd-bound runtime services.\n\t// --session and --resume may select a session from another project, so project-local\n\t// settings, resources, provider registrations, and models must be resolved only after\n\t// the target session cwd is known. The startup-cwd settings manager is used only for\n\t// sessionDir lookup during session selection.\n\tconst envSessionDir = process.env[ENV_SESSION_DIR];\n\tconst sessionDir =\n\t\t(parsed.sessionDir ? normalizePath(parsed.sessionDir) : undefined) ??\n\t\t(envSessionDir ? expandTildePath(envSessionDir) : undefined) ??\n\t\tstartupSettingsManager.getSessionDir();\n\tlet sessionManager = await createSessionManager(parsed, cwd, sessionDir, startupSettingsManager, hasHumanUI);\n\tconst missingSessionCwdIssue = getMissingSessionCwdIssue(sessionManager, cwd);\n\tif (missingSessionCwdIssue) {\n\t\tif (hasHumanUI) {\n\t\t\tconst selectedCwd = await promptForMissingSessionCwd(missingSessionCwdIssue, startupSettingsManager);\n\t\t\tif (!selectedCwd) {\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t\tsessionManager = openSession(missingSessionCwdIssue.sessionFile!, sessionDir, selectedCwd);\n\t\t} else {\n\t\t\tconsole.error(chalk.red(new MissingSessionCwdError(missingSessionCwdIssue).message));\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\tif (parsed.name !== undefined) {\n\t\tconst name = parsed.name.trim();\n\t\tif (!name) {\n\t\t\tconsole.error(chalk.red(\"Error: --name requires a non-empty value\"));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tsessionManager.appendSessionInfo(name);\n\t}\n\ttime(\"createSessionManager\");\n\n\tconst trustPromptMode: AppMode = parsed.help || parsed.listModels !== undefined || !hasHumanUI ? \"print\" : appMode;\n\tconst projectTrustedForSession = await resolveProjectTrusted({\n\t\tcwd: sessionManager.getCwd(),\n\t\ttrustStore,\n\t\ttrustOverride: parsed.projectTrustOverride,\n\t\tappMode: trustPromptMode,\n\t\tsettingsManagerForPrompt: startupSettingsManager,\n\t});\n\n\tconst resolvedExtensionPaths = resolveCliPaths(cwd, parsed.extensions);\n\tconst resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills);\n\tconst resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates);\n\tconst resolvedThemePaths = resolveCliPaths(cwd, parsed.themes);\n\tconst authStorage = AuthStorage.create();\n\tconst createRuntime: CreateAgentSessionRuntimeFactory = async ({\n\t\tcwd,\n\t\tagentDir,\n\t\tsessionManager,\n\t\tsessionStartEvent,\n\t}) => {\n\t\tconst projectTrusted =\n\t\t\tcwd === sessionManager.getCwd()\n\t\t\t\t? projectTrustedForSession\n\t\t\t\t: (parsed.projectTrustOverride ?? (!hasProjectTrustInputs(cwd) || trustStore.get(cwd) === true));\n\t\tconst runtimeSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted });\n\t\tconst orchestrationDiagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\t\tconst orchestrationProfileId =\n\t\t\tparsed.orchestrationProfile?.trim() || runtimeSettingsManager.getActiveOrchestrationProfile();\n\t\tlet orchestrationProfile: OrchestrationProfile | undefined;\n\t\tif (orchestrationProfileId) {\n\t\t\tconst loaded = new OrchestrationProfileStore({ agentDir, cwd, projectTrusted }).load();\n\t\t\torchestrationDiagnostics.push(\n\t\t\t\t...loaded.diagnostics.map((diagnostic) => ({\n\t\t\t\t\ttype: \"warning\" as const,\n\t\t\t\t\tmessage: `Orchestration profile ignored (${diagnostic.path}): ${diagnostic.message}`,\n\t\t\t\t})),\n\t\t\t);\n\t\t\torchestrationProfile = loaded.registry.get(orchestrationProfileId);\n\t\t\tif (!orchestrationProfile) {\n\t\t\t\torchestrationDiagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Orchestration profile '${orchestrationProfileId}' was not found.`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\truntimeSettingsManager.setRuntimeResourceProfiles([...orchestrationProfile.resourceProfileNames]);\n\t\t\t\tconst conflictingFlags = [\n\t\t\t\t\t...(parsed.model || parsed.provider ? [\"--model/--provider\"] : []),\n\t\t\t\t\t...(parsed.models ? [\"--models\"] : []),\n\t\t\t\t\t...(parsed.thinking ? [\"--thinking\"] : []),\n\t\t\t\t\t...(parsed.tools || parsed.excludeTools || parsed.noTools || parsed.noBuiltinTools\n\t\t\t\t\t\t? [\"--tools/--exclude-tools/--no-tools\"]\n\t\t\t\t\t\t: []),\n\t\t\t\t\t...(parsed.resourceProfiles ? [\"--resource-profile\"] : []),\n\t\t\t\t];\n\t\t\t\tif (conflictingFlags.length > 0) {\n\t\t\t\t\torchestrationDiagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Orchestration profile '${orchestrationProfile.profileId}' owns model, thinking, tools, and resources; remove conflicting ${conflictingFlags.join(\", \")}.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (parsed.resourceProfileJson) {\n\t\t\tfor (const profileInput of parsed.resourceProfileJson) {\n\t\t\t\tconst { profiles, errors } = parseResourceProfileInput(profileInput);\n\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\treportDiagnostics(\n\t\t\t\t\t\terrors.map((message) => ({\n\t\t\t\t\t\t\ttype: \"warning\" as const,\n\t\t\t\t\t\t\tmessage: `--resource-profile-json ignored entry: ${message}`,\n\t\t\t\t\t\t})),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\truntimeSettingsManager.addInlineResourceProfileDefinitions(profiles);\n\t\t\t}\n\t\t}\n\t\tif (!orchestrationProfile && parsed.resourceProfiles && parsed.resourceProfiles.length > 0) {\n\t\t\truntimeSettingsManager.setRuntimeResourceProfiles(parsed.resourceProfiles);\n\t\t}\n\t\tconst services = await createAgentSessionServices({\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tauthStorage,\n\t\t\tsettingsManager: runtimeSettingsManager,\n\t\t\textensionFlagValues: parsed.unknownFlags,\n\t\t\tresourceLoaderOptions: {\n\t\t\t\tadditionalExtensionPaths: resolvedExtensionPaths,\n\t\t\t\tadditionalSkillPaths: resolvedSkillPaths,\n\t\t\t\tadditionalPromptTemplatePaths: resolvedPromptTemplatePaths,\n\t\t\t\tadditionalThemePaths: resolvedThemePaths,\n\t\t\t\tnoExtensions: parsed.noExtensions,\n\t\t\t\tnoSkills: parsed.noSkills,\n\t\t\t\tnoPromptTemplates: parsed.noPromptTemplates,\n\t\t\t\tnoThemes: parsed.noThemes,\n\t\t\t\tnoContextFiles: parsed.noContextFiles,\n\t\t\t\tsystemPrompt: parsed.systemPrompt,\n\t\t\t\tappendSystemPrompt: parsed.appendSystemPrompt,\n\t\t\t\textensionFactories: options?.extensionFactories,\n\t\t\t},\n\t\t});\n\t\tconst { settingsManager, modelRegistry, resourceLoader } = services;\n\t\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [\n\t\t\t...services.diagnostics,\n\t\t\t...orchestrationDiagnostics,\n\t\t\t...collectSettingsDiagnostics(settingsManager, \"runtime creation\"),\n\t\t\t...resourceLoader.getExtensions().errors.map(({ path, error }) => ({\n\t\t\t\ttype: \"warning\" as const,\n\t\t\t\tmessage: `Failed to load extension \"${path}\": ${error}`,\n\t\t\t})),\n\t\t];\n\n\t\tdiagnostics.push(\n\t\t\t...collectModelRouterConfigDiagnostics(settingsManager.getModelRouterSettings(), modelRegistry, agentDir).map(\n\t\t\t\t(message) => ({\n\t\t\t\t\ttype: \"warning\" as const,\n\t\t\t\t\tmessage,\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\n\t\tconst modelPatterns = parsed.models ?? settingsManager.getEnabledModels();\n\t\tconst scopedModels =\n\t\t\tmodelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRegistry) : [];\n\t\tconst {\n\t\t\toptions: sessionOptions,\n\t\t\tcliThinkingFromModel,\n\t\t\tdiagnostics: sessionOptionDiagnostics,\n\t\t} = buildSessionOptions(\n\t\t\tparsed,\n\t\t\tscopedModels,\n\t\t\tsessionManager.buildSessionContext().messages.length > 0,\n\t\t\tmodelRegistry,\n\t\t\tsettingsManager,\n\t\t\tcwd,\n\t\t);\n\t\tdiagnostics.push(...sessionOptionDiagnostics);\n\t\tlet orchestrationModel: ReturnType<typeof resolveConfiguredOrchestrationModel>;\n\t\tif (orchestrationProfile) {\n\t\t\torchestrationModel = resolveConfiguredOrchestrationModel(orchestrationProfile, modelRegistry);\n\t\t\tif (!orchestrationModel) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Orchestration profile '${orchestrationProfile.profileId}' has no configured, authenticated model that supports its exact thinking level.`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tsessionOptions.model = orchestrationModel.model;\n\t\t\t\tsessionOptions.thinkingLevel = orchestrationModel.binding.thinkingLevel;\n\t\t\t\tsessionOptions.isExplicitModel = true;\n\t\t\t\tsessionOptions.isExplicitThinking = true;\n\t\t\t\tsessionOptions.scopedModels = [\n\t\t\t\t\t{ model: orchestrationModel.model, thinkingLevel: orchestrationModel.binding.thinkingLevel },\n\t\t\t\t];\n\t\t\t\tsessionOptions.tools = [...orchestrationProfile.toolNames];\n\t\t\t\tsessionOptions.excludeTools = undefined;\n\t\t\t\tsessionOptions.noTools = undefined;\n\t\t\t\tsessionOptions.orchestrationProfile = orchestrationProfile;\n\t\t\t}\n\t\t}\n\n\t\tif (parsed.apiKey) {\n\t\t\tif (!sessionOptions.model) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: \"--api-key requires a model to be specified via --model, --provider/--model, or --models\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tauthStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);\n\t\t\t}\n\t\t}\n\n\t\tconst created = await createAgentSessionFromServices({\n\t\t\tservices,\n\t\t\tsessionManager,\n\t\t\tsessionStartEvent,\n\t\t\tmodel: sessionOptions.model,\n\t\t\tthinkingLevel: sessionOptions.thinkingLevel,\n\t\t\tisExplicitModel: sessionOptions.isExplicitModel,\n\t\t\tisExplicitThinking: sessionOptions.isExplicitThinking,\n\t\t\tscopedModels: sessionOptions.scopedModels,\n\t\t\ttools: sessionOptions.tools,\n\t\t\texcludeTools: sessionOptions.excludeTools,\n\t\t\tnoTools: sessionOptions.noTools,\n\t\t\ttoolProfileFilter: settingsManager.getResourceProfileFilter(\"tools\"),\n\t\t\tcustomTools: sessionOptions.customTools,\n\t\t\torchestrationProfile: sessionOptions.orchestrationProfile,\n\t\t});\n\t\tconst cliThinkingOverride = parsed.thinking !== undefined || cliThinkingFromModel;\n\t\tif (created.session.model && cliThinkingOverride) {\n\t\t\tcreated.session.setThinkingLevel(created.session.thinkingLevel);\n\t\t}\n\t\tif (orchestrationProfile && orchestrationModel) {\n\t\t\tconst capabilities = [...orchestrationProfile.capabilityCeiling];\n\t\t\tcreated.session.capabilityEnvelope = {\n\t\t\t\tid: `orchestration-profile:${orchestrationProfile.profileId}`,\n\t\t\t\tprofileId: orchestrationProfile.profileId,\n\t\t\t\tcapabilities,\n\t\t\t\tallowedTools: [...orchestrationProfile.toolNames],\n\t\t\t\t...(capabilities.some(\n\t\t\t\t\t(capability) =>\n\t\t\t\t\t\tcapability === \"filesystem.read\" ||\n\t\t\t\t\t\tcapability === \"filesystem.write\" ||\n\t\t\t\t\t\tcapability === \"worktree.read\" ||\n\t\t\t\t\t\tcapability === \"worktree.mutate\",\n\t\t\t\t)\n\t\t\t\t\t? { allowedPaths: [cwd] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(orchestrationProfile.budget.maxCostUsd !== undefined\n\t\t\t\t\t? { maxEstimatedUsd: orchestrationProfile.budget.maxCostUsd }\n\t\t\t\t\t: {}),\n\t\t\t\tcreatedAt: new Date().toISOString(),\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\t...created,\n\t\t\tservices,\n\t\t\tdiagnostics,\n\t\t};\n\t};\n\ttime(\"createRuntime\");\n\tconst runtime = await createAgentSessionRuntime(createRuntime, {\n\t\tcwd: sessionManager.getCwd(),\n\t\tagentDir,\n\t\tsessionManager,\n\t});\n\ttime(\"createAgentSessionRuntime\");\n\tconst { services, session, modelFallbackMessage } = runtime;\n\tconst { settingsManager, modelRegistry, resourceLoader } = services;\n\tconfigureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());\n\tif (parsed.resume || parsed.continue || parsed.session !== undefined) {\n\t\t// Restoring a session must not mutate owner intent. Active goals may resume their runtime;\n\t\t// paused/blocked/limited goals remain stopped until an explicit owner action.\n\t\tsession.restoreGoalRuntimeAfterResume();\n\t}\n\n\t// A lane-bound session refuses AUTHORITATIVELY at its own startup when its model cannot reliably\n\t// drive the lane-gate/recovery surface unattended (full capability class, a declared context\n\t// window, an advertised native tool-call path, no graded /toolprobe demotion -- see\n\t// model-capability.ts's evaluateLaneWorkerRefusal). This is the authoritative check regardless of\n\t// how the lane binding arrived (--worktree-lane, PI_WORKTREE_LANE, or a launcher-set env): the\n\t// goal->tmux dispatch's own pre-check (tools/tmux-dispatch.ts) is the parent's best-effort guess\n\t// only and can race a model swap between dispatch and child startup. No silent unbinding -- an\n\t// ineligible model exits before the lane gate or epoch watcher ever start.\n\tconst boundWorktreeLaneKey = getBoundWorktreeLaneKey();\n\tif (boundWorktreeLaneKey) {\n\t\tconst laneWorkerRefusal = session.getLaneWorkerRefusal();\n\t\tif (laneWorkerRefusal) {\n\t\t\tconsole.error(chalk.red(formatLaneWorkerRefusal(laneWorkerRefusal, boundWorktreeLaneKey)));\n\t\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// A read-only command (--help, --list-models) uses an in-memory session and has nothing to\n\t// supervise. Do not start either runtime: even an awaited startup would create needless state\n\t// and violate the read-only zero-write contract.\n\tconst isReadOnlyCommand = parsed.help || parsed.listModels !== undefined;\n\n\t// Session-owned supervision is replaced with /new, /resume, and /fork. This keeps notices,\n\t// process identity, orphan recovery, and worktree watchers bound to the active session instead\n\t// of retaining the initial session after it has been disposed.\n\tif (!isReadOnlyCommand) {\n\t\tconst supervision = new SessionSupervisionRuntime({\n\t\t\tagentDir,\n\t\t\thasUI: hasHumanUI,\n\t\t\torchestrationProfileId: parsed.orchestrationProfile?.trim() || undefined,\n\t\t\tisProcessAlive: isReloadSessionProcessAlive,\n\t\t\tpromptConfirm,\n\t\t\tresumeWorker: launchResumableWorker,\n\t\t\tonDiagnostic: (message) => {\n\t\t\t\tconsole.error(chalk.yellow(`Warning: ${message}`));\n\t\t\t},\n\t\t\trequestExit: () => disposeRuntimeAndExit(runtime, 0),\n\t\t});\n\t\truntime.registerSessionResource(supervision);\n\t\tawait supervision.start(session);\n\t}\n\n\tif (parsed.help) {\n\t\tconst extensionFlags = resourceLoader\n\t\t\t.getExtensions()\n\t\t\t.extensions.flatMap((extension) => Array.from(extension.flags.values()));\n\t\tprintHelp(extensionFlags);\n\t\tawait disposeRuntimeAndExit(runtime, 0);\n\t\treturn;\n\t}\n\n\tif (parsed.listModels !== undefined) {\n\t\tconst searchPattern = typeof parsed.listModels === \"string\" ? parsed.listModels : undefined;\n\t\tawait listModels(modelRegistry, searchPattern);\n\t\tawait disposeRuntimeAndExit(runtime, 0);\n\t\treturn;\n\t}\n\n\t// Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC\n\tlet stdinContent: string | undefined;\n\tif (appMode !== \"rpc\") {\n\t\tstdinContent = await readPipedInput(process.stdin, process.stdin.isTTY);\n\t\tif (stdinContent !== undefined && appMode === \"interactive\") {\n\t\t\tappMode = \"print\";\n\t\t\thasHumanUI = false;\n\t\t}\n\t}\n\ttime(\"readPipedStdin\");\n\n\tconst { initialMessage, initialImages } = await prepareInitialMessage(\n\t\tparsed,\n\t\tsettingsManager.getImageAutoResize(),\n\t\tstdinContent,\n\t);\n\ttime(\"prepareInitialMessage\");\n\tconst { initTheme, stopThemeWatcher } = await import(\"./modes/interactive/theme/theme.ts\");\n\tinitTheme(settingsManager.getTheme(), hasHumanUI);\n\ttime(\"initTheme\");\n\n\t// Show deprecation warnings in interactive mode\n\tif (hasHumanUI && deprecationWarnings.length > 0) {\n\t\tawait showDeprecationWarnings(deprecationWarnings);\n\t}\n\n\ttime(\"resolveModelScope\");\n\treportDiagnostics(runtime.diagnostics);\n\tif (runtime.diagnostics.some((diagnostic) => diagnostic.type === \"error\")) {\n\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\treturn;\n\t}\n\ttime(\"createAgentSession\");\n\n\tif (appMode !== \"interactive\" && !session.model) {\n\t\tconsole.error(chalk.red(formatNoModelsAvailableMessage()));\n\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\treturn;\n\t}\n\n\tconst startupBenchmark = isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK);\n\tif (startupBenchmark && appMode !== \"interactive\") {\n\t\tconsole.error(chalk.red(\"Error: PI_STARTUP_BENCHMARK only supports interactive mode\"));\n\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\treturn;\n\t}\n\n\tif (appMode === \"rpc\") {\n\t\tprintTimings();\n\t\tconst { runRpcMode } = await import(\"./modes/rpc/rpc-mode.ts\");\n\t\tawait runRpcMode(runtime);\n\t} else if (appMode === \"interactive\") {\n\t\tconst { InteractiveMode } = await import(\"./modes/interactive/interactive-mode.ts\");\n\t\tconst interactiveMode = new InteractiveMode(runtime, {\n\t\t\tmigratedProviders,\n\t\t\tmodelFallbackMessage,\n\t\t\tinitialMessage,\n\t\t\tinitialImages,\n\t\t\tinitialMessages: parsed.messages,\n\t\t\tverbose: parsed.verbose,\n\t\t\thasHumanAudience: hasHumanUI,\n\t\t});\n\t\tif (startupBenchmark) {\n\t\t\tawait interactiveMode.init();\n\t\t\ttime(\"interactiveMode.init\");\n\t\t\tprintTimings();\n\t\t\tinteractiveMode.stop();\n\t\t\tstopThemeWatcher();\n\t\t\tif (process.stdout.writableLength > 0) {\n\t\t\t\tawait new Promise<void>((resolve) => process.stdout.once(\"drain\", resolve));\n\t\t\t}\n\t\t\tif (process.stderr.writableLength > 0) {\n\t\t\t\tawait new Promise<void>((resolve) => process.stderr.once(\"drain\", resolve));\n\t\t\t}\n\t\t\tawait disposeRuntimeAndExit(runtime, 0);\n\t\t\treturn;\n\t\t}\n\n\t\tprintTimings();\n\t\tawait interactiveMode.run();\n\t} else {\n\t\tprintTimings();\n\t\tconst { runPrintMode } = await import(\"./modes/print-mode.ts\");\n\t\tconst exitCode = await runPrintMode(runtime, {\n\t\t\tmode: toPrintOutputMode(appMode),\n\t\t\tmessages: parsed.messages,\n\t\t\tinitialMessage,\n\t\t\tinitialImages,\n\t\t\tprintUsage: parsed.printUsage,\n\t\t});\n\t\tstopThemeWatcher();\n\t\trestoreStdout();\n\t\tif (exitCode !== 0) {\n\t\t\tprocess.exitCode = exitCode;\n\t\t}\n\t\treturn;\n\t}\n}\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAqB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0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EAAE,OAAO,CAAC,CAAC,CAAC;YAC7E,CAAC;YACD,MAAM,qBAAqB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACxC,OAAO;QACR,CAAC;QAED,YAAY,EAAE,CAAC;QACf,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;SAAM,CAAC;QACP,YAAY,EAAE,CAAC;QACf,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE;YAC5C,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;YAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,cAAc;YACd,aAAa;YACb,UAAU,EAAE,MAAM,CAAC,UAAU;SAC7B,CAAC,CAAC;QACH,gBAAgB,EAAE,CAAC;QACnB,aAAa,EAAE,CAAC;QAChB,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC7B,CAAC;QACD,OAAO;IACR,CAAC;AACF,CAAC","sourcesContent":["/**\n * Main entry point for the coding agent CLI.\n *\n * This file handles CLI argument parsing and translates them into\n * createAgentSession() options. The SDK does the heavy lifting.\n */\n\nimport { createInterface } from \"node:readline\";\nimport { assertValidSessionId, SessionManager } from \"@caupulican/pi-agent-core/session\";\nimport { type ImageContent, modelsAreEqual } from \"@caupulican/pi-ai\";\nimport { ProcessTerminal, setKeybindings, TUI } from \"@caupulican/pi-tui\";\nimport chalk from \"chalk\";\nimport { type Args, type Mode, parseArgs, printHelp } from \"./cli/args.ts\";\nimport { processFileArguments } from \"./cli/file-processor.ts\";\nimport { buildInitialMessage } from \"./cli/initial-message.ts\";\nimport { listModels } from \"./cli/list-models.ts\";\nimport { readPipedInput } from \"./cli/piped-stdin.ts\";\nimport { selectSession } from \"./cli/session-picker.ts\";\nimport { ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir, VERSION } from \"./config.ts\";\nimport {\n\ttype AgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\tcreateAgentSessionRuntime,\n} from \"./core/agent-session-runtime.ts\";\nimport {\n\ttype AgentSessionRuntimeDiagnostic,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./core/agent-session-services.ts\";\nimport { formatNoModelsAvailableMessage } from \"./core/auth-guidance.ts\";\nimport { AuthStorage } from \"./core/auth-storage.ts\";\nimport { formatDoctorReport, runDoctor, runUpdatePreflight } from \"./core/doctor.ts\";\nimport { exportFromFile } from \"./core/export-html/index.ts\";\nimport type { ExtensionFactory } from \"./core/extensions/types.ts\";\nimport { configureHttpDispatcher } from \"./core/http-dispatcher.ts\";\nimport { KeybindingsManager } from \"./core/keybindings.ts\";\nimport { formatLaneWorkerRefusal } from \"./core/model-capability.ts\";\nimport type { ModelRegistry } from \"./core/model-registry.ts\";\nimport {\n\tresolveCliModel,\n\tresolveCliProviderDefault,\n\tresolveModelScope,\n\tresolveProfileModelSettings,\n\ttype ScopedModel,\n} from \"./core/model-resolver.ts\";\nimport { collectModelRouterConfigDiagnostics } from \"./core/model-router/config-diagnostics.ts\";\nimport type { OrchestrationProfile } from \"./core/orchestration/contracts.ts\";\nimport { resolveConfiguredOrchestrationModel } from \"./core/orchestration/model-binding.ts\";\nimport { OrchestrationProfileStore } from \"./core/orchestration/profile-store.ts\";\nimport { restoreStdout, takeOverStdout } from \"./core/output-guard.ts\";\nimport type { ResumablePayload } from \"./core/process-matrix/codes.ts\";\nimport { launchResumablePiAgent } from \"./core/process-matrix/resume-launcher.ts\";\nimport {\n\tPI_PARENT_PID_ENV,\n\tPI_PARENT_SESSION_ENV,\n\tPI_TASK_REF_ENV,\n\ttype ResumeWorkerLaunchOutcome,\n} from \"./core/process-matrix/runtime.ts\";\nimport { isReloadSessionProcessAlive } from \"./core/reload-blockers.ts\";\nimport { parseResourceProfileInput } from \"./core/resource-profile-blocks.ts\";\nimport type { CreateAgentSessionOptions } from \"./core/sdk.ts\";\nimport {\n\tformatMissingSessionCwdPrompt,\n\tgetMissingSessionCwdIssue,\n\tMissingSessionCwdError,\n\ttype SessionCwdIssue,\n} from \"./core/session-cwd.ts\";\nimport {\n\tcontinueRecentSession,\n\tcreateSession,\n\tforkSession,\n\tlistAllSessions,\n\tlistSessions,\n\topenSession,\n} from \"./core/session-manager-factory.ts\";\nimport { getSessionRole, setTerminalSessionMode } from \"./core/session-role.ts\";\nimport { SessionSupervisionRuntime } from \"./core/session-supervision-runtime.ts\";\nimport { SettingsManager } from \"./core/settings-manager.ts\";\nimport { printTimings, resetTimings, time } from \"./core/timings.ts\";\nimport { hasProjectTrustInputs, ProjectTrustStore } from \"./core/trust-manager.ts\";\nimport { getBoundWorktreeLaneKey, PI_WORKTREE_LANE_ENV } from \"./core/worktree-sync/runtime.ts\";\nimport { runMigrations, showDeprecationWarnings } from \"./migrations.ts\";\n\nimport { handleConfigCommand, handlePackageCommand } from \"./package-manager-cli.ts\";\nimport { isLocalPath, normalizePath, resolvePath } from \"./utils/paths.ts\";\nimport { cleanupWindowsSelfUpdateQuarantine } from \"./utils/windows-self-update.ts\";\nimport { getProcessWorkRun, getWorkRoot, PI_WORK_ROOT_ENV } from \"./utils/work-directory.ts\";\n\nfunction getSelfLaunchTarget(): { executable: string; argsPrefix: string[] } | undefined {\n\tconst executableName = process.execPath.split(/[\\\\/]/).at(-1)?.toLowerCase();\n\tconst isScriptRuntime = [\"node\", \"node.exe\", \"bun\", \"bun.exe\"].includes(executableName ?? \"\");\n\tif (!isScriptRuntime) return { executable: process.execPath, argsPrefix: [] };\n\tconst cliPath = process.argv[1];\n\treturn cliPath && !cliPath.startsWith(\"-\") ? { executable: process.execPath, argsPrefix: [cliPath] } : undefined;\n}\n\nasync function launchResumableWorker(\n\tpayload: ResumablePayload,\n\tparentSessionId: string,\n): Promise<ResumeWorkerLaunchOutcome> {\n\tconst target = getSelfLaunchTarget();\n\tif (!target) return { started: false, reason: \"The current Pi executable cannot be resolved.\" };\n\treturn launchResumablePiAgent({\n\t\tpayload,\n\t\ttarget,\n\t\tparentPid: process.pid,\n\t\tparentSessionId,\n\t\tenvironment: process.env,\n\t});\n}\n\nfunction collectSettingsDiagnostics(\n\tsettingsManager: SettingsManager,\n\tcontext: string,\n): AgentSessionRuntimeDiagnostic[] {\n\treturn settingsManager.drainErrors().map(({ scope, error }) => ({\n\t\ttype: \"warning\",\n\t\tmessage: `(${context}, ${scope} settings) ${error.message}`,\n\t}));\n}\n\nfunction reportDiagnostics(diagnostics: readonly AgentSessionRuntimeDiagnostic[]): void {\n\tfor (const diagnostic of diagnostics) {\n\t\tconst color = diagnostic.type === \"error\" ? chalk.red : diagnostic.type === \"warning\" ? chalk.yellow : chalk.dim;\n\t\tconst prefix = diagnostic.type === \"error\" ? \"Error: \" : diagnostic.type === \"warning\" ? \"Warning: \" : \"\";\n\t\tconsole.error(color(`${prefix}${diagnostic.message}`));\n\t}\n}\n\nexport async function disposeRuntimeAndExit(\n\truntime: Pick<AgentSessionRuntime, \"dispose\">,\n\texitCode: number,\n\texit: (code: number) => void = (code) => process.exit(code),\n): Promise<void> {\n\ttry {\n\t\tawait runtime.dispose();\n\t} finally {\n\t\texit(exitCode);\n\t}\n}\n\nfunction isTruthyEnvFlag(value: string | undefined): boolean {\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ntype AppMode = \"interactive\" | \"print\" | \"json\" | \"rpc\";\n\nfunction resolveAppMode(parsed: Args, stdinIsTTY: boolean): AppMode {\n\tif (parsed.mode === \"rpc\") {\n\t\treturn \"rpc\";\n\t}\n\tif (parsed.mode === \"json\") {\n\t\treturn \"json\";\n\t}\n\tif (parsed.print || !stdinIsTTY) {\n\t\treturn \"print\";\n\t}\n\treturn \"interactive\";\n}\n\nfunction toPrintOutputMode(appMode: AppMode): Exclude<Mode, \"rpc\"> {\n\treturn appMode === \"json\" ? \"json\" : \"text\";\n}\n\nasync function prepareInitialMessage(\n\tparsed: Args,\n\tautoResizeImages: boolean,\n\tstdinContent?: string,\n): Promise<{\n\tinitialMessage?: string;\n\tinitialImages?: ImageContent[];\n}> {\n\tif (parsed.fileArgs.length === 0) {\n\t\treturn buildInitialMessage({ parsed, stdinContent });\n\t}\n\n\tconst { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });\n\treturn buildInitialMessage({\n\t\tparsed,\n\t\tfileText: text,\n\t\tfileImages: images,\n\t\tstdinContent,\n\t});\n}\n\n/** Result from resolving a session argument */\ntype ResolvedSession =\n\t| { type: \"path\"; path: string } // Direct file path\n\t| { type: \"local\"; path: string } // Found in current project\n\t| { type: \"global\"; path: string; cwd: string } // Found in different project\n\t| { type: \"not_found\"; arg: string }; // Not found anywhere\n\n/**\n * Resolve a session argument to a file path.\n * If it looks like a path, use as-is. Otherwise try to match as session ID prefix.\n */\nasync function findLocalSessionByExactId(\n\tsessionId: string,\n\tcwd: string,\n\tsessionDir?: string,\n): Promise<{ type: \"local\"; path: string } | undefined> {\n\tconst localSessions = await listSessions(cwd, sessionDir);\n\tconst localMatch = localSessions.find((s) => s.id === sessionId);\n\treturn localMatch ? { type: \"local\", path: localMatch.path } : undefined;\n}\n\nasync function resolveSessionPath(sessionArg: string, cwd: string, sessionDir?: string): Promise<ResolvedSession> {\n\t// If it looks like a file path, resolve it before handing it to the session manager.\n\tif (sessionArg.includes(\"/\") || sessionArg.includes(\"\\\\\") || sessionArg.endsWith(\".jsonl\")) {\n\t\treturn { type: \"path\", path: resolvePath(sessionArg, cwd) };\n\t}\n\n\t// Try to match as session ID in current project first\n\tconst localSessions = await listSessions(cwd, sessionDir);\n\tconst localMatch =\n\t\tlocalSessions.find((s) => s.id === sessionArg) ?? localSessions.find((s) => s.id.startsWith(sessionArg));\n\n\tif (localMatch) {\n\t\treturn { type: \"local\", path: localMatch.path };\n\t}\n\n\t// Try global search across all projects\n\tconst allSessions = await listAllSessions(sessionDir);\n\tconst globalMatch =\n\t\tallSessions.find((s) => s.id === sessionArg) ?? allSessions.find((s) => s.id.startsWith(sessionArg));\n\n\tif (globalMatch) {\n\t\treturn { type: \"global\", path: globalMatch.path, cwd: globalMatch.cwd };\n\t}\n\n\t// Not found anywhere\n\treturn { type: \"not_found\", arg: sessionArg };\n}\n\n/** Prompt user for yes/no confirmation. Non-interactive callers fail closed instead of waiting on stdin. */\nexport async function promptConfirm(message: string): Promise<boolean> {\n\tif (!process.stdin.isTTY || !process.stdout.isTTY) return false;\n\treturn new Promise((resolve) => {\n\t\tconst rl = createInterface({\n\t\t\tinput: process.stdin,\n\t\t\toutput: process.stdout,\n\t\t});\n\t\tlet settled = false;\n\t\tconst finish = (confirmed: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\trl.removeListener(\"close\", onClose);\n\t\t\trl.close();\n\t\t\tresolve(confirmed);\n\t\t};\n\t\tconst onClose = () => finish(false);\n\t\trl.once(\"close\", onClose);\n\t\trl.question(`${message} [y/N] `, (answer) => {\n\t\t\tconst normalized = answer.trim().toLowerCase();\n\t\t\tfinish(normalized === \"y\" || normalized === \"yes\");\n\t\t});\n\t});\n}\n\nfunction collectSessionModeConflicts(parsed: Args): string[] {\n\treturn [\n\t\tparsed.session ? \"--session\" : undefined,\n\t\tparsed.continue ? \"--continue\" : undefined,\n\t\tparsed.resume ? \"--resume\" : undefined,\n\t\tparsed.noSession ? \"--no-session\" : undefined,\n\t].filter((flag): flag is string => flag !== undefined);\n}\n\nfunction validateForkFlags(parsed: Args): void {\n\tif (!parsed.fork) return;\n\n\tconst conflictingFlags = collectSessionModeConflicts(parsed);\n\tif (conflictingFlags.length > 0) {\n\t\tconsole.error(chalk.red(`Error: --fork cannot be combined with ${conflictingFlags.join(\", \")}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nfunction validateSessionIdFlags(parsed: Args): void {\n\tif (parsed.sessionId === undefined) return;\n\n\tconst conflictingFlags = collectSessionModeConflicts(parsed);\n\tif (conflictingFlags.length > 0) {\n\t\tconsole.error(chalk.red(`Error: --session-id cannot be combined with ${conflictingFlags.join(\", \")}`));\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\tassertValidSessionId(parsed.sessionId);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nfunction forkSessionOrExit(sourcePath: string, cwd: string, sessionDir?: string, sessionId?: string): SessionManager {\n\ttry {\n\t\treturn forkSession(sourcePath, cwd, sessionDir, { id: sessionId });\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nasync function createSessionManager(\n\tparsed: Args,\n\tcwd: string,\n\tsessionDir: string | undefined,\n\tsettingsManager: SettingsManager,\n\thasHumanUI: boolean,\n): Promise<SessionManager> {\n\tif (parsed.noSession || parsed.help || parsed.listModels !== undefined) {\n\t\treturn SessionManager.inMemory(cwd);\n\t}\n\n\tif (parsed.fork) {\n\t\tif (parsed.sessionId) {\n\t\t\tconst existingTarget = await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir);\n\t\t\tif (existingTarget) {\n\t\t\t\tconsole.error(chalk.red(`Session already exists with id '${parsed.sessionId}'`));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\n\t\tconst resolved = await resolveSessionPath(parsed.fork, cwd, sessionDir);\n\n\t\tswitch (resolved.type) {\n\t\t\tcase \"path\":\n\t\t\tcase \"local\":\n\t\t\tcase \"global\":\n\t\t\t\treturn forkSessionOrExit(resolved.path, cwd, sessionDir, parsed.sessionId);\n\n\t\t\tcase \"not_found\":\n\t\t\t\tconsole.error(chalk.red(`No session found matching '${resolved.arg}'`));\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tif (parsed.session) {\n\t\tconst resolved = await resolveSessionPath(parsed.session, cwd, sessionDir);\n\n\t\tswitch (resolved.type) {\n\t\t\tcase \"path\":\n\t\t\tcase \"local\":\n\t\t\t\treturn openSession(resolved.path, sessionDir);\n\n\t\t\tcase \"global\": {\n\t\t\t\tif (!hasHumanUI) {\n\t\t\t\t\tconsole.error(chalk.red(\"Cannot open a cross-project session without a user approval UI.\"));\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t\tconsole.log(chalk.yellow(`Session found in different project: ${resolved.cwd}`));\n\t\t\t\tconst shouldFork = await promptConfirm(\"Fork this session into current directory?\");\n\t\t\t\tif (!shouldFork) {\n\t\t\t\t\tconsole.log(chalk.dim(\"Aborted.\"));\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t\treturn forkSessionOrExit(resolved.path, cwd, sessionDir);\n\t\t\t}\n\n\t\t\tcase \"not_found\":\n\t\t\t\tconsole.error(chalk.red(`No session found matching '${resolved.arg}'`));\n\t\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tif (parsed.resume) {\n\t\tif (!hasHumanUI) {\n\t\t\tconsole.error(chalk.red(\"Error: --resume requires --session-mode user; use --session <id> for workers.\"));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconst { initTheme, stopThemeWatcher } = await import(\"./modes/interactive/theme/theme.ts\");\n\t\tinitTheme(settingsManager.getTheme(), true);\n\t\ttry {\n\t\t\tconst selectedPath = await selectSession(\n\t\t\t\t(onProgress) => listSessions(cwd, sessionDir, onProgress),\n\t\t\t\t(onProgress) => listAllSessions(sessionDir, onProgress),\n\t\t\t);\n\t\t\tif (!selectedPath) {\n\t\t\t\tconsole.log(chalk.dim(\"No session selected\"));\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t\treturn openSession(selectedPath, sessionDir);\n\t\t} finally {\n\t\t\tstopThemeWatcher();\n\t\t}\n\t}\n\n\tif (parsed.continue) {\n\t\treturn continueRecentSession(cwd, sessionDir);\n\t}\n\n\tif (parsed.sessionId) {\n\t\tconst existingSession = await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir);\n\t\tif (existingSession) {\n\t\t\treturn openSession(existingSession.path, sessionDir);\n\t\t}\n\t}\n\n\treturn createSession(cwd, sessionDir, { id: parsed.sessionId });\n}\n\nfunction buildSessionOptions(\n\tparsed: Args,\n\tscopedModels: ScopedModel[],\n\thasExistingSession: boolean,\n\tmodelRegistry: ModelRegistry,\n\tsettingsManager: SettingsManager,\n\tcwd: string,\n): {\n\toptions: CreateAgentSessionOptions;\n\tcliThinkingFromModel: boolean;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n} {\n\tconst options: CreateAgentSessionOptions = {};\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tlet cliThinkingFromModel = false;\n\n\t// Model from CLI\n\t// - supports --provider <name> --model <pattern>\n\t// - supports --provider <name> to select that provider's default model\n\t// - supports --model <provider>/<pattern>\n\tif (parsed.model || parsed.provider) {\n\t\tconst resolved = parsed.model\n\t\t\t? resolveCliModel({\n\t\t\t\t\tcliProvider: parsed.provider,\n\t\t\t\t\tcliModel: parsed.model,\n\t\t\t\t\tmodelRegistry,\n\t\t\t\t})\n\t\t\t: resolveCliProviderDefault({\n\t\t\t\t\tcliProvider: parsed.provider,\n\t\t\t\t\tmodelRegistry,\n\t\t\t\t});\n\t\tif (resolved.warning) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: resolved.warning });\n\t\t}\n\t\tif (resolved.error) {\n\t\t\tdiagnostics.push({ type: \"error\", message: resolved.error });\n\t\t}\n\t\tif (resolved.model) {\n\t\t\toptions.model = resolved.model;\n\t\t\t// Allow \"--model <pattern>:<thinking>\" as a shorthand.\n\t\t\t// Explicit --thinking still takes precedence (applied later).\n\t\t\tif (parsed.model && !parsed.thinking && resolved.thinkingLevel) {\n\t\t\t\toptions.thinkingLevel = resolved.thinkingLevel;\n\t\t\t\tcliThinkingFromModel = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Record whether model/thinking came from an explicit CLI flag (before the profile fills them\n\t// in below), so AgentSession can re-apply profile model/thinking on reload without clobbering\n\t// an explicit --model/--thinking.\n\toptions.isExplicitModel = !!parsed.model;\n\toptions.isExplicitThinking = !!parsed.thinking || cliThinkingFromModel;\n\n\t// Model/Thinking from active profiles if not explicitly set via CLI flags\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tif (activeProfileNames.length > 0) {\n\t\tconst profileSettings = resolveProfileModelSettings({\n\t\t\tactiveProfileNames,\n\t\t\tregistry: settingsManager.getProfileRegistry(),\n\t\t\tmodelRegistry,\n\t\t\tcwd,\n\t\t});\n\t\tif (profileSettings.warning) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: profileSettings.warning });\n\t\t}\n\t\tif (profileSettings.error) {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `Active profile model resolution error: ${profileSettings.error}`,\n\t\t\t});\n\t\t}\n\t\tif (!options.model && profileSettings.model) {\n\t\t\toptions.model = profileSettings.model;\n\t\t}\n\t\tif (!parsed.thinking && profileSettings.thinkingLevel) {\n\t\t\toptions.thinkingLevel = profileSettings.thinkingLevel;\n\t\t}\n\t}\n\n\tif (!options.model && scopedModels.length > 0 && !hasExistingSession) {\n\t\t// Check if saved default is in scoped models - use it if so, otherwise first scoped model\n\t\tconst savedProvider = settingsManager.getDefaultProvider();\n\t\tconst savedModelId = settingsManager.getDefaultModel();\n\t\tconst savedModel = savedProvider && savedModelId ? modelRegistry.find(savedProvider, savedModelId) : undefined;\n\t\tconst savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : undefined;\n\n\t\tif (savedInScope) {\n\t\t\toptions.model = savedInScope.model;\n\t\t\t// Use thinking level from scoped model config if explicitly set\n\t\t\tif (!parsed.thinking && savedInScope.thinkingLevel) {\n\t\t\t\toptions.thinkingLevel = savedInScope.thinkingLevel;\n\t\t\t}\n\t\t} else {\n\t\t\toptions.model = scopedModels[0].model;\n\t\t\t// Use thinking level from first scoped model if explicitly set\n\t\t\tif (!parsed.thinking && scopedModels[0].thinkingLevel) {\n\t\t\t\toptions.thinkingLevel = scopedModels[0].thinkingLevel;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Thinking level from CLI (takes precedence over scoped model thinking levels set above)\n\tif (parsed.thinking) {\n\t\toptions.thinkingLevel = parsed.thinking;\n\t}\n\toptions.serviceTier = parsed.serviceTier;\n\n\t// Scoped models for Ctrl+P cycling\n\t// Keep thinking level undefined when not explicitly set in the model pattern.\n\t// Undefined means \"inherit current session thinking level\" during cycling.\n\tif (scopedModels.length > 0) {\n\t\toptions.scopedModels = scopedModels.map((sm) => ({\n\t\t\tmodel: sm.model,\n\t\t\tthinkingLevel: sm.thinkingLevel,\n\t\t}));\n\t}\n\n\t// API key from CLI - set in authStorage\n\t// (handled by caller before createAgentSession)\n\n\t// Tools\n\tif (parsed.noTools) {\n\t\toptions.noTools = \"all\";\n\t} else if (parsed.noBuiltinTools) {\n\t\toptions.noTools = \"builtin\";\n\t}\n\tif (parsed.tools) {\n\t\toptions.tools = [...parsed.tools];\n\t}\n\tif (parsed.excludeTools) {\n\t\toptions.excludeTools = [...parsed.excludeTools];\n\t}\n\n\treturn { options, cliThinkingFromModel, diagnostics };\n}\n\nfunction resolveCliPaths(cwd: string, paths: string[] | undefined): string[] | undefined {\n\treturn paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));\n}\n\nasync function showStartupSelector<T>(\n\tsettingsManager: SettingsManager,\n\ttitle: string,\n\toptions: Array<{ label: string; value: T }>,\n): Promise<T | undefined> {\n\tconst [{ ExtensionSelectorComponent }, { initTheme }] = await Promise.all([\n\t\timport(\"./modes/interactive/components/extension-selector.ts\"),\n\t\timport(\"./modes/interactive/theme/theme.ts\"),\n\t]);\n\tinitTheme(settingsManager.getTheme());\n\tsetKeybindings(KeybindingsManager.create());\n\n\treturn new Promise((resolve) => {\n\t\tconst ui = new TUI(new ProcessTerminal(), settingsManager.getShowHardwareCursor());\n\t\tui.setClearOnShrink(settingsManager.getClearOnShrink());\n\n\t\tlet settled = false;\n\t\tconst finish = (result: T | undefined) => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\tui.stop();\n\t\t\tresolve(result);\n\t\t};\n\n\t\tconst selector = new ExtensionSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions.map((option) => option.label),\n\t\t\t(option) => finish(options.find((entry) => entry.label === option)?.value),\n\t\t\t() => finish(undefined),\n\t\t\t{ tui: ui },\n\t\t);\n\t\tui.addChild(selector);\n\t\tui.setFocus(selector);\n\t\tui.start();\n\t});\n}\n\nasync function promptForMissingSessionCwd(\n\tissue: SessionCwdIssue,\n\tsettingsManager: SettingsManager,\n): Promise<string | undefined> {\n\treturn showStartupSelector(settingsManager, formatMissingSessionCwdPrompt(issue), [\n\t\t{ label: \"Continue\", value: issue.fallbackCwd },\n\t\t{ label: \"Cancel\", value: undefined },\n\t]);\n}\n\ninterface ProjectTrustPromptResult {\n\ttrusted: boolean;\n\tremember: boolean;\n}\n\nasync function promptForProjectTrust(\n\tcwd: string,\n\tsettingsManager: SettingsManager,\n): Promise<ProjectTrustPromptResult | undefined> {\n\treturn showStartupSelector(\n\t\tsettingsManager,\n\t\t`Trust project folder?\\n${cwd}\\n\\nThis allows pi to read project instructions (AGENTS.md/CLAUDE.md/GEMINI.md), load .pi settings and resources, install missing project packages, and execute project extensions.`,\n\t\t[\n\t\t\t{ label: \"Trust\", value: { trusted: true, remember: true } },\n\t\t\t{ label: \"Trust (this session only)\", value: { trusted: true, remember: false } },\n\t\t\t{ label: \"Do not trust\", value: { trusted: false, remember: true } },\n\t\t\t{ label: \"Do not trust (this session only)\", value: { trusted: false, remember: false } },\n\t\t],\n\t);\n}\n\nasync function resolveProjectTrusted(options: {\n\tcwd: string;\n\ttrustStore: ProjectTrustStore;\n\ttrustOverride?: boolean;\n\tappMode: AppMode;\n\tsettingsManagerForPrompt: SettingsManager;\n}): Promise<boolean> {\n\tif (options.trustOverride !== undefined) {\n\t\treturn options.trustOverride;\n\t}\n\tif (!hasProjectTrustInputs(options.cwd)) {\n\t\treturn true;\n\t}\n\n\tconst decision = options.trustStore.get(options.cwd);\n\tif (decision !== null) {\n\t\treturn decision;\n\t}\n\tif (options.appMode !== \"interactive\") {\n\t\treturn false;\n\t}\n\n\tconst selected = await promptForProjectTrust(options.cwd, options.settingsManagerForPrompt);\n\tif (selected !== undefined) {\n\t\tif (selected.remember) {\n\t\t\toptions.trustStore.set(options.cwd, selected.trusted);\n\t\t}\n\t\treturn selected.trusted;\n\t}\n\treturn false;\n}\n\nexport interface MainOptions {\n\textensionFactories?: ExtensionFactory[];\n}\n\nexport async function main(args: string[], options?: MainOptions) {\n\tresetTimings();\n\tconst workAgentDir = getAgentDir();\n\tprocess.env[PI_WORK_ROOT_ENV] = getWorkRoot(workAgentDir);\n\tif (process.env.PI_TUI_DEBUG === \"1\") {\n\t\tprocess.env.PI_TUI_WORK_DIR = getProcessWorkRun(workAgentDir, \"debug\", \"tui\").path;\n\t}\n\tconst offlineMode = args.includes(\"--offline\") || isTruthyEnvFlag(process.env.PI_OFFLINE);\n\tif (offlineMode) {\n\t\tprocess.env.PI_OFFLINE = \"1\";\n\t\tprocess.env.PI_SKIP_VERSION_CHECK = \"1\";\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\tcleanupWindowsSelfUpdateQuarantine(getPackageDir());\n\t}\n\n\tif (args[0] === \"doctor\") {\n\t\t// Interactive command: show fff-node install progress rather than a\n\t\t// silent multi-second gap (runUpdatePreflight's background run stays\n\t\t// quiet -- see the `{ silent: true }` default on runDoctor).\n\t\tconst report = await runDoctor(undefined, { silent: false });\n\t\tconsole.log(formatDoctorReport(report));\n\t\tprocess.exitCode = report.checks.some((check) => !check.present) ? 1 : 0;\n\t\treturn;\n\t}\n\n\tif (await handlePackageCommand(args)) {\n\t\t// Verify + provision required tooling right after an update, instead of\n\t\t// leaving it to lazy first-use (see doctor.ts's module doc). Best-effort\n\t\t// and non-fatal: runUpdatePreflight() never throws, so a broken\n\t\t// environment check can't turn a successful update into a failed one.\n\t\tif (args[0] === \"update\" && process.exitCode !== 1) {\n\t\t\tawait runUpdatePreflight();\n\t\t}\n\t\treturn;\n\t}\n\n\tif (await handleConfigCommand(args)) {\n\t\treturn;\n\t}\n\n\tconst parsed = parseArgs(args);\n\tif (parsed.diagnostics.length > 0) {\n\t\tfor (const d of parsed.diagnostics) {\n\t\t\tconst color = d.type === \"error\" ? chalk.red : chalk.yellow;\n\t\t\tconsole.error(color(`${d.type === \"error\" ? \"Error\" : \"Warning\"}: ${d.message}`));\n\t\t}\n\t\tif (parsed.diagnostics.some((d) => d.type === \"error\")) {\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\ttime(\"parseArgs\");\n\t// --worktree-lane is sugar over the cross-process env contract: setting the env here (before\n\t// any session/tool construction) makes the flag and a launcher-provided env byte-identical\n\t// downstream (RuntimeBuilder's lane gate, the epoch watcher, child processes).\n\tif (parsed.worktreeLane) {\n\t\tprocess.env[PI_WORKTREE_LANE_ENV] = parsed.worktreeLane;\n\t}\n\t// --parent-pid/--parent-session are the same CLI-sugar-over-env pattern as --worktree-lane:\n\t// setting the env here (before any session/tool construction) makes the flag and a\n\t// launcher-provided env byte-identical downstream (the process-matrix runtime's worker branch).\n\tif (parsed.parentPid !== undefined) {\n\t\tprocess.env[PI_PARENT_PID_ENV] = String(parsed.parentPid);\n\t}\n\tif (parsed.parentSession) {\n\t\tprocess.env[PI_PARENT_SESSION_ENV] = parsed.parentSession;\n\t}\n\tif (parsed.taskRef) {\n\t\tprocess.env[PI_TASK_REF_ENV] = parsed.taskRef;\n\t}\n\tif (parsed.sessionMode) {\n\t\tsetTerminalSessionMode(parsed.sessionMode);\n\t}\n\tlet appMode = resolveAppMode(parsed, process.stdin.isTTY);\n\tlet hasHumanUI = appMode === \"interactive\" && getSessionRole() === \"main\";\n\tconst shouldTakeOverStdout = appMode !== \"interactive\";\n\tif (shouldTakeOverStdout) {\n\t\ttakeOverStdout();\n\t}\n\n\tif (parsed.version) {\n\t\tconsole.log(VERSION);\n\t\tprocess.exit(0);\n\t}\n\n\tif (parsed.export) {\n\t\tlet result: string;\n\t\ttry {\n\t\t\tconst outputPath = parsed.messages.length > 0 ? parsed.messages[0] : undefined;\n\t\t\tresult = await exportFromFile(parsed.export, outputPath);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : \"Failed to export session\";\n\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconsole.log(`Exported to: ${result}`);\n\t\tprocess.exit(0);\n\t}\n\n\tif (parsed.mode === \"rpc\" && parsed.fileArgs.length > 0) {\n\t\tconsole.error(chalk.red(\"Error: @file arguments are not supported in RPC mode\"));\n\t\tprocess.exit(1);\n\t}\n\n\tvalidateForkFlags(parsed);\n\tvalidateSessionIdFlags(parsed);\n\n\t// Run migrations (pass cwd for project-local migrations)\n\tconst { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(process.cwd());\n\ttime(\"runMigrations\");\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\tconst startupProjectTrusted =\n\t\tparsed.projectTrustOverride ?? (!hasProjectTrustInputs(cwd) || trustStore.get(cwd) === true);\n\tconst startupSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: startupProjectTrusted });\n\treportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, \"startup session lookup\"));\n\n\t// Decide the final runtime cwd before creating cwd-bound runtime services.\n\t// --session and --resume may select a session from another project, so project-local\n\t// settings, resources, provider registrations, and models must be resolved only after\n\t// the target session cwd is known. The startup-cwd settings manager is used only for\n\t// sessionDir lookup during session selection.\n\tconst envSessionDir = process.env[ENV_SESSION_DIR];\n\tconst sessionDir =\n\t\t(parsed.sessionDir ? normalizePath(parsed.sessionDir) : undefined) ??\n\t\t(envSessionDir ? expandTildePath(envSessionDir) : undefined) ??\n\t\tstartupSettingsManager.getSessionDir();\n\tlet sessionManager = await createSessionManager(parsed, cwd, sessionDir, startupSettingsManager, hasHumanUI);\n\tconst missingSessionCwdIssue = getMissingSessionCwdIssue(sessionManager, cwd);\n\tif (missingSessionCwdIssue) {\n\t\tif (hasHumanUI) {\n\t\t\tconst selectedCwd = await promptForMissingSessionCwd(missingSessionCwdIssue, startupSettingsManager);\n\t\t\tif (!selectedCwd) {\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t\tsessionManager = openSession(missingSessionCwdIssue.sessionFile!, sessionDir, selectedCwd);\n\t\t} else {\n\t\t\tconsole.error(chalk.red(new MissingSessionCwdError(missingSessionCwdIssue).message));\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\tif (parsed.name !== undefined) {\n\t\tconst name = parsed.name.trim();\n\t\tif (!name) {\n\t\t\tconsole.error(chalk.red(\"Error: --name requires a non-empty value\"));\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tsessionManager.appendSessionInfo(name);\n\t}\n\ttime(\"createSessionManager\");\n\n\tconst trustPromptMode: AppMode = parsed.help || parsed.listModels !== undefined || !hasHumanUI ? \"print\" : appMode;\n\tconst projectTrustedForSession = await resolveProjectTrusted({\n\t\tcwd: sessionManager.getCwd(),\n\t\ttrustStore,\n\t\ttrustOverride: parsed.projectTrustOverride,\n\t\tappMode: trustPromptMode,\n\t\tsettingsManagerForPrompt: startupSettingsManager,\n\t});\n\n\tconst resolvedExtensionPaths = resolveCliPaths(cwd, parsed.extensions);\n\tconst resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills);\n\tconst resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates);\n\tconst resolvedThemePaths = resolveCliPaths(cwd, parsed.themes);\n\tconst authStorage = AuthStorage.create();\n\tconst createRuntime: CreateAgentSessionRuntimeFactory = async ({\n\t\tcwd,\n\t\tagentDir,\n\t\tsessionManager,\n\t\tsessionStartEvent,\n\t}) => {\n\t\tconst projectTrusted =\n\t\t\tcwd === sessionManager.getCwd()\n\t\t\t\t? projectTrustedForSession\n\t\t\t\t: (parsed.projectTrustOverride ?? (!hasProjectTrustInputs(cwd) || trustStore.get(cwd) === true));\n\t\tconst runtimeSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted });\n\t\tconst orchestrationDiagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\t\tconst orchestrationProfileId =\n\t\t\tparsed.orchestrationProfile?.trim() || runtimeSettingsManager.getActiveOrchestrationProfile();\n\t\tlet orchestrationProfile: OrchestrationProfile | undefined;\n\t\tif (orchestrationProfileId) {\n\t\t\tconst loaded = new OrchestrationProfileStore({ agentDir, cwd, projectTrusted }).load();\n\t\t\torchestrationDiagnostics.push(\n\t\t\t\t...loaded.diagnostics.map((diagnostic) => ({\n\t\t\t\t\ttype: \"warning\" as const,\n\t\t\t\t\tmessage: `Orchestration profile ignored (${diagnostic.path}): ${diagnostic.message}`,\n\t\t\t\t})),\n\t\t\t);\n\t\t\torchestrationProfile = loaded.registry.get(orchestrationProfileId);\n\t\t\tif (!orchestrationProfile) {\n\t\t\t\torchestrationDiagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Orchestration profile '${orchestrationProfileId}' was not found.`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\truntimeSettingsManager.setRuntimeResourceProfiles([...orchestrationProfile.resourceProfileNames]);\n\t\t\t\tconst conflictingFlags = [\n\t\t\t\t\t...(parsed.model || parsed.provider ? [\"--model/--provider\"] : []),\n\t\t\t\t\t...(parsed.models ? [\"--models\"] : []),\n\t\t\t\t\t...(parsed.thinking ? [\"--thinking\"] : []),\n\t\t\t\t\t...(parsed.tools || parsed.excludeTools || parsed.noTools || parsed.noBuiltinTools\n\t\t\t\t\t\t? [\"--tools/--exclude-tools/--no-tools\"]\n\t\t\t\t\t\t: []),\n\t\t\t\t\t...(parsed.resourceProfiles ? [\"--resource-profile\"] : []),\n\t\t\t\t];\n\t\t\t\tif (conflictingFlags.length > 0) {\n\t\t\t\t\torchestrationDiagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Orchestration profile '${orchestrationProfile.profileId}' owns model, thinking, tools, and resources; remove conflicting ${conflictingFlags.join(\", \")}.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (parsed.resourceProfileJson) {\n\t\t\tfor (const profileInput of parsed.resourceProfileJson) {\n\t\t\t\tconst { profiles, errors } = parseResourceProfileInput(profileInput);\n\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\treportDiagnostics(\n\t\t\t\t\t\terrors.map((message) => ({\n\t\t\t\t\t\t\ttype: \"warning\" as const,\n\t\t\t\t\t\t\tmessage: `--resource-profile-json ignored entry: ${message}`,\n\t\t\t\t\t\t})),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\truntimeSettingsManager.addInlineResourceProfileDefinitions(profiles);\n\t\t\t}\n\t\t}\n\t\tif (!orchestrationProfile && parsed.resourceProfiles && parsed.resourceProfiles.length > 0) {\n\t\t\truntimeSettingsManager.setRuntimeResourceProfiles(parsed.resourceProfiles);\n\t\t}\n\t\tconst services = await createAgentSessionServices({\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tauthStorage,\n\t\t\tsettingsManager: runtimeSettingsManager,\n\t\t\textensionFlagValues: parsed.unknownFlags,\n\t\t\tresourceLoaderOptions: {\n\t\t\t\tadditionalExtensionPaths: resolvedExtensionPaths,\n\t\t\t\tadditionalSkillPaths: resolvedSkillPaths,\n\t\t\t\tadditionalPromptTemplatePaths: resolvedPromptTemplatePaths,\n\t\t\t\tadditionalThemePaths: resolvedThemePaths,\n\t\t\t\tnoExtensions: parsed.noExtensions,\n\t\t\t\tnoSkills: parsed.noSkills,\n\t\t\t\tnoPromptTemplates: parsed.noPromptTemplates,\n\t\t\t\tnoThemes: parsed.noThemes,\n\t\t\t\tnoContextFiles: parsed.noContextFiles,\n\t\t\t\tsystemPrompt: parsed.systemPrompt,\n\t\t\t\tappendSystemPrompt: parsed.appendSystemPrompt,\n\t\t\t\textensionFactories: options?.extensionFactories,\n\t\t\t},\n\t\t});\n\t\tconst { settingsManager, modelRegistry, resourceLoader } = services;\n\t\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [\n\t\t\t...services.diagnostics,\n\t\t\t...orchestrationDiagnostics,\n\t\t\t...collectSettingsDiagnostics(settingsManager, \"runtime creation\"),\n\t\t\t...resourceLoader.getExtensions().errors.map(({ path, error }) => ({\n\t\t\t\ttype: \"warning\" as const,\n\t\t\t\tmessage: `Failed to load extension \"${path}\": ${error}`,\n\t\t\t})),\n\t\t];\n\n\t\tdiagnostics.push(\n\t\t\t...collectModelRouterConfigDiagnostics(settingsManager.getModelRouterSettings(), modelRegistry, agentDir).map(\n\t\t\t\t(message) => ({\n\t\t\t\t\ttype: \"warning\" as const,\n\t\t\t\t\tmessage,\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\n\t\tconst modelPatterns = parsed.models ?? settingsManager.getEnabledModels();\n\t\tconst scopedModels =\n\t\t\tmodelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRegistry) : [];\n\t\tconst {\n\t\t\toptions: sessionOptions,\n\t\t\tcliThinkingFromModel,\n\t\t\tdiagnostics: sessionOptionDiagnostics,\n\t\t} = buildSessionOptions(\n\t\t\tparsed,\n\t\t\tscopedModels,\n\t\t\tsessionManager.buildSessionContext().messages.length > 0,\n\t\t\tmodelRegistry,\n\t\t\tsettingsManager,\n\t\t\tcwd,\n\t\t);\n\t\tdiagnostics.push(...sessionOptionDiagnostics);\n\t\tlet orchestrationModel: ReturnType<typeof resolveConfiguredOrchestrationModel>;\n\t\tif (orchestrationProfile) {\n\t\t\torchestrationModel = resolveConfiguredOrchestrationModel(orchestrationProfile, modelRegistry);\n\t\t\tif (!orchestrationModel) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Orchestration profile '${orchestrationProfile.profileId}' has no configured, authenticated model that supports its exact thinking level.`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tsessionOptions.model = orchestrationModel.model;\n\t\t\t\tsessionOptions.thinkingLevel = orchestrationModel.binding.thinkingLevel;\n\t\t\t\tsessionOptions.isExplicitModel = true;\n\t\t\t\tsessionOptions.isExplicitThinking = true;\n\t\t\t\tsessionOptions.scopedModels = [\n\t\t\t\t\t{ model: orchestrationModel.model, thinkingLevel: orchestrationModel.binding.thinkingLevel },\n\t\t\t\t];\n\t\t\t\tsessionOptions.tools = [...orchestrationProfile.toolNames];\n\t\t\t\tsessionOptions.excludeTools = undefined;\n\t\t\t\tsessionOptions.noTools = undefined;\n\t\t\t\tsessionOptions.orchestrationProfile = orchestrationProfile;\n\t\t\t}\n\t\t}\n\n\t\tif (parsed.apiKey) {\n\t\t\tif (!sessionOptions.model) {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: \"--api-key requires a model to be specified via --model, --provider/--model, or --models\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tauthStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);\n\t\t\t}\n\t\t}\n\n\t\tconst created = await createAgentSessionFromServices({\n\t\t\tservices,\n\t\t\tsessionManager,\n\t\t\tsessionStartEvent,\n\t\t\tmodel: sessionOptions.model,\n\t\t\tthinkingLevel: sessionOptions.thinkingLevel,\n\t\t\tserviceTier: sessionOptions.serviceTier,\n\t\t\tisExplicitModel: sessionOptions.isExplicitModel,\n\t\t\tisExplicitThinking: sessionOptions.isExplicitThinking,\n\t\t\tscopedModels: sessionOptions.scopedModels,\n\t\t\ttools: sessionOptions.tools,\n\t\t\texcludeTools: sessionOptions.excludeTools,\n\t\t\tnoTools: sessionOptions.noTools,\n\t\t\ttoolProfileFilter: settingsManager.getResourceProfileFilter(\"tools\"),\n\t\t\tcustomTools: sessionOptions.customTools,\n\t\t\torchestrationProfile: sessionOptions.orchestrationProfile,\n\t\t});\n\t\tconst cliThinkingOverride = parsed.thinking !== undefined || cliThinkingFromModel;\n\t\tif (created.session.model && cliThinkingOverride) {\n\t\t\tcreated.session.setThinkingLevel(created.session.thinkingLevel);\n\t\t}\n\t\tif (orchestrationProfile && orchestrationModel) {\n\t\t\tconst capabilities = [...orchestrationProfile.capabilityCeiling];\n\t\t\tcreated.session.capabilityEnvelope = {\n\t\t\t\tid: `orchestration-profile:${orchestrationProfile.profileId}`,\n\t\t\t\tprofileId: orchestrationProfile.profileId,\n\t\t\t\tcapabilities,\n\t\t\t\tallowedTools: [...orchestrationProfile.toolNames],\n\t\t\t\t...(capabilities.some(\n\t\t\t\t\t(capability) =>\n\t\t\t\t\t\tcapability === \"filesystem.read\" ||\n\t\t\t\t\t\tcapability === \"filesystem.write\" ||\n\t\t\t\t\t\tcapability === \"worktree.read\" ||\n\t\t\t\t\t\tcapability === \"worktree.mutate\",\n\t\t\t\t)\n\t\t\t\t\t? { allowedPaths: [cwd] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(orchestrationProfile.budget.maxCostUsd !== undefined\n\t\t\t\t\t? { maxEstimatedUsd: orchestrationProfile.budget.maxCostUsd }\n\t\t\t\t\t: {}),\n\t\t\t\tcreatedAt: new Date().toISOString(),\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\t...created,\n\t\t\tservices,\n\t\t\tdiagnostics,\n\t\t};\n\t};\n\ttime(\"createRuntime\");\n\tconst runtime = await createAgentSessionRuntime(createRuntime, {\n\t\tcwd: sessionManager.getCwd(),\n\t\tagentDir,\n\t\tsessionManager,\n\t});\n\ttime(\"createAgentSessionRuntime\");\n\tconst { services, session, modelFallbackMessage } = runtime;\n\tconst { settingsManager, modelRegistry, resourceLoader } = services;\n\tconfigureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());\n\tif (parsed.resume || parsed.continue || parsed.session !== undefined) {\n\t\t// Restoring a session must not mutate owner intent. Active goals may resume their runtime;\n\t\t// paused/blocked/limited goals remain stopped until an explicit owner action.\n\t\tsession.restoreGoalRuntimeAfterResume();\n\t}\n\n\t// A lane-bound session refuses AUTHORITATIVELY at its own startup when its model cannot reliably\n\t// drive the lane-gate/recovery surface unattended (full capability class, a declared context\n\t// window, an advertised native tool-call path, no graded /toolprobe demotion -- see\n\t// model-capability.ts's evaluateLaneWorkerRefusal). This is the authoritative check regardless of\n\t// how the lane binding arrived (--worktree-lane, PI_WORKTREE_LANE, or a launcher-set env): the\n\t// goal->tmux dispatch's own pre-check (tools/tmux-dispatch.ts) is the parent's best-effort guess\n\t// only and can race a model swap between dispatch and child startup. No silent unbinding -- an\n\t// ineligible model exits before the lane gate or epoch watcher ever start.\n\tconst boundWorktreeLaneKey = getBoundWorktreeLaneKey();\n\tif (boundWorktreeLaneKey) {\n\t\tconst laneWorkerRefusal = session.getLaneWorkerRefusal();\n\t\tif (laneWorkerRefusal) {\n\t\t\tconsole.error(chalk.red(formatLaneWorkerRefusal(laneWorkerRefusal, boundWorktreeLaneKey)));\n\t\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// A read-only command (--help, --list-models) uses an in-memory session and has nothing to\n\t// supervise. Do not start either runtime: even an awaited startup would create needless state\n\t// and violate the read-only zero-write contract.\n\tconst isReadOnlyCommand = parsed.help || parsed.listModels !== undefined;\n\n\t// Session-owned supervision is replaced with /new, /resume, and /fork. This keeps notices,\n\t// process identity, orphan recovery, and worktree watchers bound to the active session instead\n\t// of retaining the initial session after it has been disposed.\n\tif (!isReadOnlyCommand) {\n\t\tconst supervision = new SessionSupervisionRuntime({\n\t\t\tagentDir,\n\t\t\thasUI: hasHumanUI,\n\t\t\torchestrationProfileId: parsed.orchestrationProfile?.trim() || undefined,\n\t\t\tisProcessAlive: isReloadSessionProcessAlive,\n\t\t\tpromptConfirm,\n\t\t\tresumeWorker: launchResumableWorker,\n\t\t\tonDiagnostic: (message) => {\n\t\t\t\tconsole.error(chalk.yellow(`Warning: ${message}`));\n\t\t\t},\n\t\t\trequestExit: () => disposeRuntimeAndExit(runtime, 0),\n\t\t});\n\t\truntime.registerSessionResource(supervision);\n\t\tawait supervision.start(session);\n\t}\n\n\tif (parsed.help) {\n\t\tconst extensionFlags = resourceLoader\n\t\t\t.getExtensions()\n\t\t\t.extensions.flatMap((extension) => Array.from(extension.flags.values()));\n\t\tprintHelp(extensionFlags);\n\t\tawait disposeRuntimeAndExit(runtime, 0);\n\t\treturn;\n\t}\n\n\tif (parsed.listModels !== undefined) {\n\t\tconst searchPattern = typeof parsed.listModels === \"string\" ? parsed.listModels : undefined;\n\t\tawait listModels(modelRegistry, searchPattern);\n\t\tawait disposeRuntimeAndExit(runtime, 0);\n\t\treturn;\n\t}\n\n\t// Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC\n\tlet stdinContent: string | undefined;\n\tif (appMode !== \"rpc\") {\n\t\tstdinContent = await readPipedInput(process.stdin, process.stdin.isTTY);\n\t\tif (stdinContent !== undefined && appMode === \"interactive\") {\n\t\t\tappMode = \"print\";\n\t\t\thasHumanUI = false;\n\t\t}\n\t}\n\ttime(\"readPipedStdin\");\n\n\tconst { initialMessage, initialImages } = await prepareInitialMessage(\n\t\tparsed,\n\t\tsettingsManager.getImageAutoResize(),\n\t\tstdinContent,\n\t);\n\ttime(\"prepareInitialMessage\");\n\tconst { initTheme, stopThemeWatcher } = await import(\"./modes/interactive/theme/theme.ts\");\n\tinitTheme(settingsManager.getTheme(), hasHumanUI);\n\ttime(\"initTheme\");\n\n\t// Show deprecation warnings in interactive mode\n\tif (hasHumanUI && deprecationWarnings.length > 0) {\n\t\tawait showDeprecationWarnings(deprecationWarnings);\n\t}\n\n\ttime(\"resolveModelScope\");\n\treportDiagnostics(runtime.diagnostics);\n\tif (runtime.diagnostics.some((diagnostic) => diagnostic.type === \"error\")) {\n\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\treturn;\n\t}\n\ttime(\"createAgentSession\");\n\n\tif (appMode !== \"interactive\" && !session.model) {\n\t\tconsole.error(chalk.red(formatNoModelsAvailableMessage()));\n\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\treturn;\n\t}\n\n\tconst startupBenchmark = isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK);\n\tif (startupBenchmark && appMode !== \"interactive\") {\n\t\tconsole.error(chalk.red(\"Error: PI_STARTUP_BENCHMARK only supports interactive mode\"));\n\t\tawait disposeRuntimeAndExit(runtime, 1);\n\t\treturn;\n\t}\n\n\tif (appMode === \"rpc\") {\n\t\tprintTimings();\n\t\tconst { runRpcMode } = await import(\"./modes/rpc/rpc-mode.ts\");\n\t\tawait runRpcMode(runtime);\n\t} else if (appMode === \"interactive\") {\n\t\tconst { InteractiveMode } = await import(\"./modes/interactive/interactive-mode.ts\");\n\t\tconst interactiveMode = new InteractiveMode(runtime, {\n\t\t\tmigratedProviders,\n\t\t\tmodelFallbackMessage,\n\t\t\tinitialMessage,\n\t\t\tinitialImages,\n\t\t\tinitialMessages: parsed.messages,\n\t\t\tverbose: parsed.verbose,\n\t\t\thasHumanAudience: hasHumanUI,\n\t\t});\n\t\tif (startupBenchmark) {\n\t\t\tawait interactiveMode.init();\n\t\t\ttime(\"interactiveMode.init\");\n\t\t\tprintTimings();\n\t\t\tinteractiveMode.stop();\n\t\t\tstopThemeWatcher();\n\t\t\tif (process.stdout.writableLength > 0) {\n\t\t\t\tawait new Promise<void>((resolve) => process.stdout.once(\"drain\", resolve));\n\t\t\t}\n\t\t\tif (process.stderr.writableLength > 0) {\n\t\t\t\tawait new Promise<void>((resolve) => process.stderr.once(\"drain\", resolve));\n\t\t\t}\n\t\t\tawait disposeRuntimeAndExit(runtime, 0);\n\t\t\treturn;\n\t\t}\n\n\t\tprintTimings();\n\t\tawait interactiveMode.run();\n\t} else {\n\t\tprintTimings();\n\t\tconst { runPrintMode } = await import(\"./modes/print-mode.ts\");\n\t\tconst exitCode = await runPrintMode(runtime, {\n\t\t\tmode: toPrintOutputMode(appMode),\n\t\t\tmessages: parsed.messages,\n\t\t\tinitialMessage,\n\t\t\tinitialImages,\n\t\t\tprintUsage: parsed.printUsage,\n\t\t});\n\t\tstopThemeWatcher();\n\t\trestoreStdout();\n\t\tif (exitCode !== 0) {\n\t\t\tprocess.exitCode = exitCode;\n\t\t}\n\t\treturn;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bash-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/bash-execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAwB,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAU/E,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,MAAM,CAA6D;IAC3E,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAY;IAEpC,YAAY,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,kBAAkB,UAAQ,EAiC/D;IAED;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CA2BhC;IAED,WAAW,CACV,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,OAAO,EAClB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,cAAc,CAAC,EAAE,MAAM,GACrB,IAAI,CAcN;IAED,OAAO,CAAC,aAAa;IAsFrB;;;OAGG;IACH,SAAS,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,UAAU,IAAI,MAAM,CAEnB;CACD"}
1
+ {"version":3,"file":"bash-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/bash-execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAwB,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAO/E,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,MAAM,CAA6D;IAC3E,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAY;IAEpC,YAAY,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,kBAAkB,UAAQ,EAiC/D;IAED;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CA2BhC;IAED,WAAW,CACV,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,OAAO,EAClB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,cAAc,CAAC,EAAE,MAAM,GACrB,IAAI,CAcN;IAED,OAAO,CAAC,aAAa;IAyDrB;;;OAGG;IACH,SAAS,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,UAAU,IAAI,MAAM,CAEnB;CACD"}