@caupulican/pi-adaptative 0.86.2 → 0.86.5
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.
- package/CHANGELOG.md +40 -0
- package/dist/core/agent-paths.d.ts +13 -0
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +23 -0
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +7 -0
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +12 -4
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +2 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +6 -3
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +25 -2
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +67 -0
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/delegation/replay-safe-mailbox-bounds.d.ts +4 -0
- package/dist/core/delegation/replay-safe-mailbox-bounds.d.ts.map +1 -0
- package/dist/core/delegation/replay-safe-mailbox-bounds.js +20 -0
- package/dist/core/delegation/replay-safe-mailbox-bounds.js.map +1 -0
- package/dist/core/delegation/sanitized-context-fork.d.ts +25 -0
- package/dist/core/delegation/sanitized-context-fork.d.ts.map +1 -0
- package/dist/core/delegation/sanitized-context-fork.js +299 -0
- package/dist/core/delegation/sanitized-context-fork.js.map +1 -0
- package/dist/core/delegation/session-root-mailbox.d.ts +75 -0
- package/dist/core/delegation/session-root-mailbox.d.ts.map +1 -0
- package/dist/core/delegation/session-root-mailbox.js +627 -0
- package/dist/core/delegation/session-root-mailbox.js.map +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +102 -9
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +1307 -125
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +183 -8
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +778 -48
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +9 -0
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +479 -214
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +9 -0
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +22 -14
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-context-fork-store.d.ts +71 -0
- package/dist/core/delegation/worker-context-fork-store.d.ts.map +1 -0
- package/dist/core/delegation/worker-context-fork-store.js +437 -0
- package/dist/core/delegation/worker-context-fork-store.js.map +1 -0
- package/dist/core/delegation/worker-context-inheritance-policy.d.ts +18 -0
- package/dist/core/delegation/worker-context-inheritance-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-context-inheritance-policy.js +28 -0
- package/dist/core/delegation/worker-context-inheritance-policy.js.map +1 -0
- package/dist/core/delegation/worker-conversation-revision.d.ts +31 -0
- package/dist/core/delegation/worker-conversation-revision.d.ts.map +1 -0
- package/dist/core/delegation/worker-conversation-revision.js +203 -0
- package/dist/core/delegation/worker-conversation-revision.js.map +1 -0
- package/dist/core/delegation/worker-conversation-store.d.ts +130 -18
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +1263 -79
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +29 -2
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +625 -111
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +2 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +20 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +210 -37
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +38 -0
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -0
- package/dist/core/delegation/worker-fleet-limits.js +113 -0
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js +6 -2
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts +20 -3
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +42 -18
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts +4 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +45 -4
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-provider-turn-protocol.d.ts +50 -0
- package/dist/core/delegation/worker-provider-turn-protocol.d.ts.map +1 -0
- package/dist/core/delegation/worker-provider-turn-protocol.js +185 -0
- package/dist/core/delegation/worker-provider-turn-protocol.js.map +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.d.ts +45 -4
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +223 -17
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-retry-policy.d.ts +36 -0
- package/dist/core/delegation/worker-retry-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-retry-policy.js +41 -0
- package/dist/core/delegation/worker-retry-policy.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +3 -1
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +4 -2
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-view.d.ts +43 -0
- package/dist/core/delegation/worker-task-view.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-view.js +194 -0
- package/dist/core/delegation/worker-task-view.js.map +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +55 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js +179 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +2 -2
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.js +12 -46
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
- package/dist/core/keybindings.d.ts +10 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/orchestration/attempt-ordering.d.ts +9 -0
- package/dist/core/orchestration/attempt-ordering.d.ts.map +1 -0
- package/dist/core/orchestration/attempt-ordering.js +29 -0
- package/dist/core/orchestration/attempt-ordering.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +19 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +19 -2
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +43 -3
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +24 -0
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts +8 -3
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +148 -55
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts +6 -3
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +228 -30
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/task-runtime-codecs.d.ts +31 -0
- package/dist/core/orchestration/task-runtime-codecs.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-codecs.js +1471 -0
- package/dist/core/orchestration/task-runtime-codecs.js.map +1 -0
- package/dist/core/orchestration/task-runtime-projection.d.ts +30 -0
- package/dist/core/orchestration/task-runtime-projection.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-projection.js +340 -0
- package/dist/core/orchestration/task-runtime-projection.js.map +1 -0
- package/dist/core/orchestration/task-runtime-reducer.d.ts +38 -0
- package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-reducer.js +1270 -0
- package/dist/core/orchestration/task-runtime-reducer.js.map +1 -0
- package/dist/core/orchestration/task-runtime-state.d.ts +142 -0
- package/dist/core/orchestration/task-runtime-state.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-state.js +14 -0
- package/dist/core/orchestration/task-runtime-state.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +44 -98
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +357 -1113
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/worker-context-fork-reference.d.ts +20 -0
- package/dist/core/orchestration/worker-context-fork-reference.d.ts.map +1 -0
- package/dist/core/orchestration/worker-context-fork-reference.js +53 -0
- package/dist/core/orchestration/worker-context-fork-reference.js.map +1 -0
- package/dist/core/research/research-runner.d.ts +2 -0
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +1 -0
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +8 -0
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/secrets/credential-project.d.ts.map +1 -1
- package/dist/core/secrets/credential-project.js +24 -2
- package/dist/core/secrets/credential-project.js.map +1 -1
- package/dist/core/security/secret-text.d.ts +3 -0
- package/dist/core/security/secret-text.d.ts.map +1 -1
- package/dist/core/security/secret-text.js +15 -0
- package/dist/core/security/secret-text.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +160 -8
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +31 -4
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +751 -98
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +5 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +133 -49
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/agents-overlay.d.ts +40 -0
- package/dist/modes/interactive/components/agents-overlay.d.ts.map +1 -0
- package/dist/modes/interactive/components/agents-overlay.js +153 -0
- package/dist/modes/interactive/components/agents-overlay.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +18 -13
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +6 -3
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +51 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts +1 -0
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -0
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/docs/harness-architecture.md +61 -17
- package/docs/settings.md +17 -9
- package/docs/worker-profiles.md +6 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
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,M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C,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;YAC7E,CAAC;YACD,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\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\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,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,C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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\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"]}
|
|
@@ -10,6 +10,8 @@ export interface ActivityLaneItem {
|
|
|
10
10
|
kind: ActivityLaneKind;
|
|
11
11
|
label: string;
|
|
12
12
|
status: ActivityLaneStatus;
|
|
13
|
+
/** Short aggregation key (e.g. "bash", "python", "agent") for the concurrency slot. */
|
|
14
|
+
tag?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface ActivityLaneCanonicalSnapshot {
|
|
15
17
|
goalState?: GoalState;
|
|
@@ -20,6 +22,9 @@ export interface ActivityLaneProjection {
|
|
|
20
22
|
active: ActivityLaneItem[];
|
|
21
23
|
terminal: ActivityLaneItem[];
|
|
22
24
|
}
|
|
25
|
+
export declare const BACKGROUND_TOOL_ACTIVITY_ID_PREFIX = "background-tool:";
|
|
26
|
+
export declare function backgroundToolActivityId(taskId: string): string;
|
|
27
|
+
export declare function isBackgroundToolActivityItem(item: Pick<ActivityLaneItem, "id" | "kind">): boolean;
|
|
23
28
|
export declare function projectActivityLane(snapshot: ActivityLaneCanonicalSnapshot): ActivityLaneProjection;
|
|
24
29
|
export declare function renderActivityLaneLine(theme: Theme, items: readonly ActivityLaneItem[], width: number): string[];
|
|
25
30
|
export declare class ActivityLaneComponent implements Component {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-lane.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/activity-lane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAA0B,MAAM,mCAAmC,CAAC;AAC3F,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AACpG,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1F,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"activity-lane.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/activity-lane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,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