@caupulican/pi-adaptative 0.81.39 → 0.81.41
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 +77 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +3 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +4 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +31 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +25 -2
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +79 -4
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +293 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +400 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +74 -518
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +370 -1432
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +20 -12
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +48 -9
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +14 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +38 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +56 -236
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +141 -1273
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +13 -17
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +10 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +16 -37
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +2 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +52 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +78 -21
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +53 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +27 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +28 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +90 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +52 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +43 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +102 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +10 -8
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +46 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +91 -24
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +9 -10
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +60 -75
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +20 -12
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +133 -33
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +17 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +17 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +38 -25
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +5 -5
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +4 -6
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +95 -83
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +2 -12
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +84 -57
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +200 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +14 -3
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/codes.js.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +37 -22
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +399 -76
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts +5 -2
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js +123 -14
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts +10 -7
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js +45 -14
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +6 -8
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +5 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +5 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +6 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +23 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +233 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +41 -23
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +365 -253
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +68 -25
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +67 -70
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +11 -4
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +24 -5
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +81 -29
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +2 -4
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +10 -28
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +4 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -11
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +86 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +89 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +2 -3
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +9 -35
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +97 -138
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +31 -3
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +148 -29
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +106 -23
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +10 -8
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +106 -28
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +40 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +124 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +2 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +99 -0
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +3 -5
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +4 -4
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +4 -6
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +3 -3
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js +10 -5
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +4 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +186 -28
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -6
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +77 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +22 -24
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +245 -595
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +27 -8
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +150 -64
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +38 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +28 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +59 -26
- package/docs/providers.md +9 -1
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +125 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +10 -3
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +14 -0
- package/docs/ui-reference/orchestration-before.txt +13 -0
- package/docs/ui-reference/orchestration-reference.txt +16 -0
- package/docs/usage.md +22 -2
- package/docs/work-directory.md +19 -8
- 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/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- 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 +13 -13
- package/package.json +4 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -46
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -113
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
|
@@ -10,13 +10,17 @@ import type { AgentMessage } from "@caupulican/pi-agent-core";
|
|
|
10
10
|
import type { Message } from "@caupulican/pi-ai";
|
|
11
11
|
export declare const TUI_HISTORY_RELOAD_MAX_LINES = 1000;
|
|
12
12
|
export declare const TUI_HISTORY_RELOAD_WRAP_WIDTH = 100;
|
|
13
|
+
export interface TuiHistoryReloadOptions {
|
|
14
|
+
/** Read tool-result content while sizing history. False when tool output is collapsed. */
|
|
15
|
+
includeToolResultContent?: boolean;
|
|
16
|
+
}
|
|
13
17
|
export declare function getContentText(content: unknown): string;
|
|
14
18
|
export declare function getUserMessageText(message: Message): string;
|
|
15
19
|
export declare function getTuiHistoryMessageText(message: AgentMessage): string;
|
|
16
|
-
export declare function estimateTuiHistoryLines(message: AgentMessage): number;
|
|
20
|
+
export declare function estimateTuiHistoryLines(message: AgentMessage, options?: TuiHistoryReloadOptions): number;
|
|
17
21
|
export declare function trimTextToTuiHistoryTail(text: string, maxEstimatedLines: number): string;
|
|
18
22
|
export declare function trimMessageToTuiHistoryTail(message: AgentMessage, maxEstimatedLines: number): AgentMessage;
|
|
19
|
-
export declare function messagesForTuiHistoryReload(messages: AgentMessage[]): {
|
|
23
|
+
export declare function messagesForTuiHistoryReload(messages: AgentMessage[], options?: TuiHistoryReloadOptions): {
|
|
20
24
|
messages: AgentMessage[];
|
|
21
25
|
omittedMessages: number;
|
|
22
26
|
estimatedLines: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-reload-math.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/history-reload-math.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAWvD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAO3D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAoBtE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"history-reload-math.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/history-reload-math.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACvC,0FAA0F;IAC1F,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAWvD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAO3D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAoBtE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAY5G;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAaxF;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,GAAG,YAAY,CAgB1G;AAED,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,YAAY,EAAE,EACxB,OAAO,GAAE,uBAA4B,GACnC;IACF,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACvB,CA6BA","sourcesContent":["/**\n * Pure math for capping the TUI transcript that is re-rendered on reload/resume.\n *\n * These functions estimate wrapped line counts for agent messages and select the\n * tail of a message list that fits within the reload budget, trimming an oversized\n * head message when needed. They read only their arguments and hold no UI or session\n * state, so they live outside interactive-mode and are unit-testable in isolation.\n */\n\nimport type { AgentMessage } from \"@caupulican/pi-agent-core\";\nimport type { Message } from \"@caupulican/pi-ai\";\n\nexport const TUI_HISTORY_RELOAD_MAX_LINES = 1000;\nexport const TUI_HISTORY_RELOAD_WRAP_WIDTH = 100;\n\nexport interface TuiHistoryReloadOptions {\n\t/** Read tool-result content while sizing history. False when tool output is collapsed. */\n\tincludeToolResultContent?: boolean;\n}\n\nexport function getContentText(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (Array.isArray(content)) {\n\t\treturn content\n\t\t\t.map((part) => {\n\t\t\t\tconst maybeText = (part as { text?: unknown }).text;\n\t\t\t\treturn typeof maybeText === \"string\" ? maybeText : \"\";\n\t\t\t})\n\t\t\t.join(\"\");\n\t}\n\treturn \"\";\n}\n\nexport function getUserMessageText(message: Message): string {\n\tif (message.role !== \"user\") return \"\";\n\tconst textBlocks =\n\t\ttypeof message.content === \"string\"\n\t\t\t? [{ type: \"text\", text: message.content }]\n\t\t\t: message.content.filter((c: { type: string }) => c.type === \"text\");\n\treturn textBlocks.map((c) => (c as { text: string }).text).join(\"\");\n}\n\nexport function getTuiHistoryMessageText(message: AgentMessage): string {\n\tswitch (message.role) {\n\t\tcase \"bashExecution\":\n\t\t\treturn [message.command, message.output ?? \"\"].filter(Boolean).join(\"\\n\");\n\t\tcase \"user\":\n\t\t\treturn getUserMessageText(message);\n\t\tcase \"assistant\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"toolResult\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"custom\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"compactionSummary\":\n\t\tcase \"branchSummary\":\n\t\t\treturn message.summary;\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = message;\n\t\t\treturn JSON.stringify(_exhaustive);\n\t\t}\n\t}\n}\n\nexport function estimateTuiHistoryLines(message: AgentMessage, options: TuiHistoryReloadOptions = {}): number {\n\tif (message.role === \"toolResult\" && options.includeToolResultContent === false) {\n\t\t// Tool results render inside their matching tool-call component, not as a separate row.\n\t\t// Retain a one-line accounting floor so orphaned results cannot bypass the reload bound.\n\t\treturn 1;\n\t}\n\tconst text = getTuiHistoryMessageText(message);\n\tconst hardLines = text.length > 0 ? text.split(/\\r\\n|\\r|\\n/).length : 1;\n\tconst wrappedLines = Math.ceil(text.length / TUI_HISTORY_RELOAD_WRAP_WIDTH);\n\t// Add one line for role/tool chrome or spacing. Tool-call-only assistant messages\n\t// have little text but still render a component.\n\treturn Math.max(1, hardLines, wrappedLines) + 1;\n}\n\nexport function trimTextToTuiHistoryTail(text: string, maxEstimatedLines: number): string {\n\tconst maxLines = Math.max(1, maxEstimatedLines);\n\tconst lines = text.split(/\\r\\n|\\r|\\n/);\n\tif (lines.length > maxLines) {\n\t\tconst omitted = lines.length - maxLines;\n\t\treturn `[Earlier ${omitted} line${omitted === 1 ? \"\" : \"s\"} omitted from TUI reload history; full session remains available to the model.]\\n${lines.slice(-maxLines).join(\"\\n\")}`;\n\t}\n\tconst maxChars = Math.max(TUI_HISTORY_RELOAD_WRAP_WIDTH, maxLines * TUI_HISTORY_RELOAD_WRAP_WIDTH);\n\tif (text.length > maxChars) {\n\t\tconst omitted = text.length - maxChars;\n\t\treturn `[Earlier ${omitted} character${omitted === 1 ? \"\" : \"s\"} omitted from TUI reload history; full session remains available to the model.]\\n${text.slice(-maxChars)}`;\n\t}\n\treturn text;\n}\n\nexport function trimMessageToTuiHistoryTail(message: AgentMessage, maxEstimatedLines: number): AgentMessage {\n\tconst text = getTuiHistoryMessageText(message);\n\tconst trimmedText = trimTextToTuiHistoryTail(text, maxEstimatedLines);\n\tif (trimmedText === text) return message;\n\tconst clone = JSON.parse(JSON.stringify(message)) as AgentMessage;\n\tconst mutable = clone as unknown as { role?: string; content?: unknown; output?: unknown };\n\tif (mutable.role === \"bashExecution\" && typeof mutable.output === \"string\") {\n\t\tmutable.output = trimmedText;\n\t} else if (mutable.role === \"compactionSummary\" || mutable.role === \"branchSummary\") {\n\t\t(mutable as { summary?: string }).summary = trimmedText;\n\t} else if (typeof mutable.content === \"string\") {\n\t\tmutable.content = trimmedText;\n\t} else {\n\t\tmutable.content = [{ type: \"text\", text: trimmedText }];\n\t}\n\treturn clone;\n}\n\nexport function messagesForTuiHistoryReload(\n\tmessages: AgentMessage[],\n\toptions: TuiHistoryReloadOptions = {},\n): {\n\tmessages: AgentMessage[];\n\tomittedMessages: number;\n\testimatedLines: number;\n} {\n\tlet estimatedLines = 0;\n\tlet start = messages.length;\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst nextLines = estimateTuiHistoryLines(messages[i], options);\n\t\tif (start < messages.length && estimatedLines + nextLines > TUI_HISTORY_RELOAD_MAX_LINES) break;\n\t\testimatedLines += nextLines;\n\t\tstart = i;\n\t\tif (estimatedLines >= TUI_HISTORY_RELOAD_MAX_LINES) break;\n\t}\n\tconst selected = messages.slice(start);\n\tif (selected.length > 0 && estimatedLines > TUI_HISTORY_RELOAD_MAX_LINES) {\n\t\tconst tailLines = selected.slice(1).reduce((sum, message) => sum + estimateTuiHistoryLines(message, options), 0);\n\t\tconst firstAllowance = TUI_HISTORY_RELOAD_MAX_LINES - tailLines;\n\t\tif (firstAllowance <= 4) {\n\t\t\tselected.shift();\n\t\t\tstart += 1;\n\t\t\testimatedLines = tailLines;\n\t\t} else {\n\t\t\t// Reserve room for truncation marker, role chrome, and wrap variance.\n\t\t\tselected[0] = trimMessageToTuiHistoryTail(selected[0], firstAllowance - 4);\n\t\t\testimatedLines = tailLines + estimateTuiHistoryLines(selected[0], options);\n\t\t}\n\t}\n\treturn {\n\t\tmessages: selected,\n\t\tomittedMessages: start,\n\t\testimatedLines,\n\t};\n}\n"]}
|
|
@@ -50,7 +50,12 @@ export function getTuiHistoryMessageText(message) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
export function estimateTuiHistoryLines(message) {
|
|
53
|
+
export function estimateTuiHistoryLines(message, options = {}) {
|
|
54
|
+
if (message.role === "toolResult" && options.includeToolResultContent === false) {
|
|
55
|
+
// Tool results render inside their matching tool-call component, not as a separate row.
|
|
56
|
+
// Retain a one-line accounting floor so orphaned results cannot bypass the reload bound.
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
54
59
|
const text = getTuiHistoryMessageText(message);
|
|
55
60
|
const hardLines = text.length > 0 ? text.split(/\r\n|\r|\n/).length : 1;
|
|
56
61
|
const wrappedLines = Math.ceil(text.length / TUI_HISTORY_RELOAD_WRAP_WIDTH);
|
|
@@ -93,11 +98,11 @@ export function trimMessageToTuiHistoryTail(message, maxEstimatedLines) {
|
|
|
93
98
|
}
|
|
94
99
|
return clone;
|
|
95
100
|
}
|
|
96
|
-
export function messagesForTuiHistoryReload(messages) {
|
|
101
|
+
export function messagesForTuiHistoryReload(messages, options = {}) {
|
|
97
102
|
let estimatedLines = 0;
|
|
98
103
|
let start = messages.length;
|
|
99
104
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
100
|
-
const nextLines = estimateTuiHistoryLines(messages[i]);
|
|
105
|
+
const nextLines = estimateTuiHistoryLines(messages[i], options);
|
|
101
106
|
if (start < messages.length && estimatedLines + nextLines > TUI_HISTORY_RELOAD_MAX_LINES)
|
|
102
107
|
break;
|
|
103
108
|
estimatedLines += nextLines;
|
|
@@ -107,7 +112,7 @@ export function messagesForTuiHistoryReload(messages) {
|
|
|
107
112
|
}
|
|
108
113
|
const selected = messages.slice(start);
|
|
109
114
|
if (selected.length > 0 && estimatedLines > TUI_HISTORY_RELOAD_MAX_LINES) {
|
|
110
|
-
const tailLines = selected.slice(1).reduce((sum, message) => sum + estimateTuiHistoryLines(message), 0);
|
|
115
|
+
const tailLines = selected.slice(1).reduce((sum, message) => sum + estimateTuiHistoryLines(message, options), 0);
|
|
111
116
|
const firstAllowance = TUI_HISTORY_RELOAD_MAX_LINES - tailLines;
|
|
112
117
|
if (firstAllowance <= 4) {
|
|
113
118
|
selected.shift();
|
|
@@ -117,7 +122,7 @@ export function messagesForTuiHistoryReload(messages) {
|
|
|
117
122
|
else {
|
|
118
123
|
// Reserve room for truncation marker, role chrome, and wrap variance.
|
|
119
124
|
selected[0] = trimMessageToTuiHistoryTail(selected[0], firstAllowance - 4);
|
|
120
|
-
estimatedLines = tailLines + estimateTuiHistoryLines(selected[0]);
|
|
125
|
+
estimatedLines = tailLines + estimateTuiHistoryLines(selected[0], options);
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-reload-math.js","sourceRoot":"","sources":["../../../src/modes/interactive/history-reload-math.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,CAAC,MA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GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,GAAG,uBAAuB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QACxG,MAAM,cAAc,GAAG,4BAA4B,GAAG,SAAS,CAAC;QAChE,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;YACzB,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,CAAC;YACX,cAAc,GAAG,SAAS,CAAC;QAC5B,CAAC;aAAM,CAAC;YACP,sEAAsE;YACtE,QAAQ,CAAC,CAAC,CAAC,GAAG,2BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;YAC3E,cAAc,GAAG,SAAS,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;IACF,CAAC;IACD,OAAO;QACN,QAAQ,EAAE,QAAQ;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc;KACd,CAAC;AAAA,CACF","sourcesContent":["/**\n * Pure math for capping the TUI transcript that is re-rendered on reload/resume.\n *\n * These functions estimate wrapped line counts for agent messages and select the\n * tail of a message list that fits within the reload budget, trimming an oversized\n * head message when needed. They read only their arguments and hold no UI or session\n * state, so they live outside interactive-mode and are unit-testable in isolation.\n */\n\nimport type { AgentMessage } from \"@caupulican/pi-agent-core\";\nimport type { Message } from \"@caupulican/pi-ai\";\n\nexport const TUI_HISTORY_RELOAD_MAX_LINES = 1000;\nexport const TUI_HISTORY_RELOAD_WRAP_WIDTH = 100;\n\nexport function getContentText(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (Array.isArray(content)) {\n\t\treturn content\n\t\t\t.map((part) => {\n\t\t\t\tconst maybeText = (part as { text?: unknown }).text;\n\t\t\t\treturn typeof maybeText === \"string\" ? maybeText : \"\";\n\t\t\t})\n\t\t\t.join(\"\");\n\t}\n\treturn \"\";\n}\n\nexport function getUserMessageText(message: Message): string {\n\tif (message.role !== \"user\") return \"\";\n\tconst textBlocks =\n\t\ttypeof message.content === \"string\"\n\t\t\t? [{ type: \"text\", text: message.content }]\n\t\t\t: message.content.filter((c: { type: string }) => c.type === \"text\");\n\treturn textBlocks.map((c) => (c as { text: string }).text).join(\"\");\n}\n\nexport function getTuiHistoryMessageText(message: AgentMessage): string {\n\tswitch (message.role) {\n\t\tcase \"bashExecution\":\n\t\t\treturn [message.command, message.output ?? \"\"].filter(Boolean).join(\"\\n\");\n\t\tcase \"user\":\n\t\t\treturn getUserMessageText(message);\n\t\tcase \"assistant\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"toolResult\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"custom\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"compactionSummary\":\n\t\tcase \"branchSummary\":\n\t\t\treturn message.summary;\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = message;\n\t\t\treturn JSON.stringify(_exhaustive);\n\t\t}\n\t}\n}\n\nexport function estimateTuiHistoryLines(message: AgentMessage): number {\n\tconst text = getTuiHistoryMessageText(message);\n\tconst hardLines = text.length > 0 ? text.split(/\\r\\n|\\r|\\n/).length : 1;\n\tconst wrappedLines = Math.ceil(text.length / TUI_HISTORY_RELOAD_WRAP_WIDTH);\n\t// Add one line for role/tool chrome or spacing. Tool-call-only assistant messages\n\t// have little text but still render a component.\n\treturn Math.max(1, hardLines, wrappedLines) + 1;\n}\n\nexport function trimTextToTuiHistoryTail(text: string, maxEstimatedLines: number): string {\n\tconst maxLines = Math.max(1, maxEstimatedLines);\n\tconst lines = text.split(/\\r\\n|\\r|\\n/);\n\tif (lines.length > maxLines) {\n\t\tconst omitted = lines.length - maxLines;\n\t\treturn `[Earlier ${omitted} line${omitted === 1 ? \"\" : \"s\"} omitted from TUI reload history; full session remains available to the model.]\\n${lines.slice(-maxLines).join(\"\\n\")}`;\n\t}\n\tconst maxChars = Math.max(TUI_HISTORY_RELOAD_WRAP_WIDTH, maxLines * TUI_HISTORY_RELOAD_WRAP_WIDTH);\n\tif (text.length > maxChars) {\n\t\tconst omitted = text.length - maxChars;\n\t\treturn `[Earlier ${omitted} character${omitted === 1 ? \"\" : \"s\"} omitted from TUI reload history; full session remains available to the model.]\\n${text.slice(-maxChars)}`;\n\t}\n\treturn text;\n}\n\nexport function trimMessageToTuiHistoryTail(message: AgentMessage, maxEstimatedLines: number): AgentMessage {\n\tconst text = getTuiHistoryMessageText(message);\n\tconst trimmedText = trimTextToTuiHistoryTail(text, maxEstimatedLines);\n\tif (trimmedText === text) return message;\n\tconst clone = JSON.parse(JSON.stringify(message)) as AgentMessage;\n\tconst mutable = clone as unknown as { role?: string; content?: unknown; output?: unknown };\n\tif (mutable.role === \"bashExecution\" && typeof mutable.output === \"string\") {\n\t\tmutable.output = trimmedText;\n\t} else if (mutable.role === \"compactionSummary\" || mutable.role === \"branchSummary\") {\n\t\t(mutable as { summary?: string }).summary = trimmedText;\n\t} else if (typeof mutable.content === \"string\") {\n\t\tmutable.content = trimmedText;\n\t} else {\n\t\tmutable.content = [{ type: \"text\", text: trimmedText }];\n\t}\n\treturn clone;\n}\n\nexport function messagesForTuiHistoryReload(messages: AgentMessage[]): {\n\tmessages: AgentMessage[];\n\tomittedMessages: number;\n\testimatedLines: number;\n} {\n\tlet estimatedLines = 0;\n\tlet start = messages.length;\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst nextLines = estimateTuiHistoryLines(messages[i]);\n\t\tif (start < messages.length && estimatedLines + nextLines > TUI_HISTORY_RELOAD_MAX_LINES) break;\n\t\testimatedLines += nextLines;\n\t\tstart = i;\n\t\tif (estimatedLines >= TUI_HISTORY_RELOAD_MAX_LINES) break;\n\t}\n\tconst selected = messages.slice(start);\n\tif (selected.length > 0 && estimatedLines > TUI_HISTORY_RELOAD_MAX_LINES) {\n\t\tconst tailLines = selected.slice(1).reduce((sum, message) => sum + estimateTuiHistoryLines(message), 0);\n\t\tconst firstAllowance = TUI_HISTORY_RELOAD_MAX_LINES - tailLines;\n\t\tif (firstAllowance <= 4) {\n\t\t\tselected.shift();\n\t\t\tstart += 1;\n\t\t\testimatedLines = tailLines;\n\t\t} else {\n\t\t\t// Reserve room for truncation marker, role chrome, and wrap variance.\n\t\t\tselected[0] = trimMessageToTuiHistoryTail(selected[0], firstAllowance - 4);\n\t\t\testimatedLines = tailLines + estimateTuiHistoryLines(selected[0]);\n\t\t}\n\t}\n\treturn {\n\t\tmessages: selected,\n\t\tomittedMessages: start,\n\t\testimatedLines,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"history-reload-math.js","sourceRoot":"","sources":["../../../src/modes/interactive/history-reload-math.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAOjD,MAAM,UAAU,cAAc,CAAC,OAAgB,EAAU;IACxD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO;aACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACd,MAAM,SAAS,GAAI,IAA2B,CAAC,IAAI,CAAC;YACpD,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAAA,CACtD,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,EAAE,CAAC;AAAA,CACV;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAU;IAC5D,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,UAAU,GACf,OAAO,OAAO,CAAC,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AE,cAAc,GAAG,CAAC,CAAC,CAAC;YAC3E,cAAc,GAAG,SAAS,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC5E,CAAC;IACF,CAAC;IACD,OAAO;QACN,QAAQ,EAAE,QAAQ;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc;KACd,CAAC;AAAA,CACF","sourcesContent":["/**\n * Pure math for capping the TUI transcript that is re-rendered on reload/resume.\n *\n * These functions estimate wrapped line counts for agent messages and select the\n * tail of a message list that fits within the reload budget, trimming an oversized\n * head message when needed. They read only their arguments and hold no UI or session\n * state, so they live outside interactive-mode and are unit-testable in isolation.\n */\n\nimport type { AgentMessage } from \"@caupulican/pi-agent-core\";\nimport type { Message } from \"@caupulican/pi-ai\";\n\nexport const TUI_HISTORY_RELOAD_MAX_LINES = 1000;\nexport const TUI_HISTORY_RELOAD_WRAP_WIDTH = 100;\n\nexport interface TuiHistoryReloadOptions {\n\t/** Read tool-result content while sizing history. False when tool output is collapsed. */\n\tincludeToolResultContent?: boolean;\n}\n\nexport function getContentText(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (Array.isArray(content)) {\n\t\treturn content\n\t\t\t.map((part) => {\n\t\t\t\tconst maybeText = (part as { text?: unknown }).text;\n\t\t\t\treturn typeof maybeText === \"string\" ? maybeText : \"\";\n\t\t\t})\n\t\t\t.join(\"\");\n\t}\n\treturn \"\";\n}\n\nexport function getUserMessageText(message: Message): string {\n\tif (message.role !== \"user\") return \"\";\n\tconst textBlocks =\n\t\ttypeof message.content === \"string\"\n\t\t\t? [{ type: \"text\", text: message.content }]\n\t\t\t: message.content.filter((c: { type: string }) => c.type === \"text\");\n\treturn textBlocks.map((c) => (c as { text: string }).text).join(\"\");\n}\n\nexport function getTuiHistoryMessageText(message: AgentMessage): string {\n\tswitch (message.role) {\n\t\tcase \"bashExecution\":\n\t\t\treturn [message.command, message.output ?? \"\"].filter(Boolean).join(\"\\n\");\n\t\tcase \"user\":\n\t\t\treturn getUserMessageText(message);\n\t\tcase \"assistant\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"toolResult\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"custom\":\n\t\t\treturn getContentText(message.content);\n\t\tcase \"compactionSummary\":\n\t\tcase \"branchSummary\":\n\t\t\treturn message.summary;\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = message;\n\t\t\treturn JSON.stringify(_exhaustive);\n\t\t}\n\t}\n}\n\nexport function estimateTuiHistoryLines(message: AgentMessage, options: TuiHistoryReloadOptions = {}): number {\n\tif (message.role === \"toolResult\" && options.includeToolResultContent === false) {\n\t\t// Tool results render inside their matching tool-call component, not as a separate row.\n\t\t// Retain a one-line accounting floor so orphaned results cannot bypass the reload bound.\n\t\treturn 1;\n\t}\n\tconst text = getTuiHistoryMessageText(message);\n\tconst hardLines = text.length > 0 ? text.split(/\\r\\n|\\r|\\n/).length : 1;\n\tconst wrappedLines = Math.ceil(text.length / TUI_HISTORY_RELOAD_WRAP_WIDTH);\n\t// Add one line for role/tool chrome or spacing. Tool-call-only assistant messages\n\t// have little text but still render a component.\n\treturn Math.max(1, hardLines, wrappedLines) + 1;\n}\n\nexport function trimTextToTuiHistoryTail(text: string, maxEstimatedLines: number): string {\n\tconst maxLines = Math.max(1, maxEstimatedLines);\n\tconst lines = text.split(/\\r\\n|\\r|\\n/);\n\tif (lines.length > maxLines) {\n\t\tconst omitted = lines.length - maxLines;\n\t\treturn `[Earlier ${omitted} line${omitted === 1 ? \"\" : \"s\"} omitted from TUI reload history; full session remains available to the model.]\\n${lines.slice(-maxLines).join(\"\\n\")}`;\n\t}\n\tconst maxChars = Math.max(TUI_HISTORY_RELOAD_WRAP_WIDTH, maxLines * TUI_HISTORY_RELOAD_WRAP_WIDTH);\n\tif (text.length > maxChars) {\n\t\tconst omitted = text.length - maxChars;\n\t\treturn `[Earlier ${omitted} character${omitted === 1 ? \"\" : \"s\"} omitted from TUI reload history; full session remains available to the model.]\\n${text.slice(-maxChars)}`;\n\t}\n\treturn text;\n}\n\nexport function trimMessageToTuiHistoryTail(message: AgentMessage, maxEstimatedLines: number): AgentMessage {\n\tconst text = getTuiHistoryMessageText(message);\n\tconst trimmedText = trimTextToTuiHistoryTail(text, maxEstimatedLines);\n\tif (trimmedText === text) return message;\n\tconst clone = JSON.parse(JSON.stringify(message)) as AgentMessage;\n\tconst mutable = clone as unknown as { role?: string; content?: unknown; output?: unknown };\n\tif (mutable.role === \"bashExecution\" && typeof mutable.output === \"string\") {\n\t\tmutable.output = trimmedText;\n\t} else if (mutable.role === \"compactionSummary\" || mutable.role === \"branchSummary\") {\n\t\t(mutable as { summary?: string }).summary = trimmedText;\n\t} else if (typeof mutable.content === \"string\") {\n\t\tmutable.content = trimmedText;\n\t} else {\n\t\tmutable.content = [{ type: \"text\", text: trimmedText }];\n\t}\n\treturn clone;\n}\n\nexport function messagesForTuiHistoryReload(\n\tmessages: AgentMessage[],\n\toptions: TuiHistoryReloadOptions = {},\n): {\n\tmessages: AgentMessage[];\n\tomittedMessages: number;\n\testimatedLines: number;\n} {\n\tlet estimatedLines = 0;\n\tlet start = messages.length;\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst nextLines = estimateTuiHistoryLines(messages[i], options);\n\t\tif (start < messages.length && estimatedLines + nextLines > TUI_HISTORY_RELOAD_MAX_LINES) break;\n\t\testimatedLines += nextLines;\n\t\tstart = i;\n\t\tif (estimatedLines >= TUI_HISTORY_RELOAD_MAX_LINES) break;\n\t}\n\tconst selected = messages.slice(start);\n\tif (selected.length > 0 && estimatedLines > TUI_HISTORY_RELOAD_MAX_LINES) {\n\t\tconst tailLines = selected.slice(1).reduce((sum, message) => sum + estimateTuiHistoryLines(message, options), 0);\n\t\tconst firstAllowance = TUI_HISTORY_RELOAD_MAX_LINES - tailLines;\n\t\tif (firstAllowance <= 4) {\n\t\t\tselected.shift();\n\t\t\tstart += 1;\n\t\t\testimatedLines = tailLines;\n\t\t} else {\n\t\t\t// Reserve room for truncation marker, role chrome, and wrap variance.\n\t\t\tselected[0] = trimMessageToTuiHistoryTail(selected[0], firstAllowance - 4);\n\t\t\testimatedLines = tailLines + estimateTuiHistoryLines(selected[0], options);\n\t\t}\n\t}\n\treturn {\n\t\tmessages: selected,\n\t\tomittedMessages: start,\n\t\testimatedLines,\n\t};\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AgentMessage, ToolCallRepairInfo } from "@caupulican/pi-agent-core";
|
|
2
|
+
import type { AssistantMessage } from "@caupulican/pi-ai";
|
|
3
|
+
import { type Container, type Loader, type LoaderIndicatorOptions, type MarkdownTheme, type TUI } from "@caupulican/pi-tui";
|
|
4
|
+
import type { AgentSession } from "../../core/agent-session.ts";
|
|
5
|
+
import type { AgentSessionEvent } from "../../core/agent-session-contracts.ts";
|
|
6
|
+
import type { FooterDataProvider } from "../../core/footer-data-provider.ts";
|
|
7
|
+
import type { SettingsManager } from "../../core/settings-manager.ts";
|
|
8
|
+
import type { ActivityLaneComponent, ActivityLaneKind } from "./components/activity-lane.ts";
|
|
9
|
+
import { AssistantMessageComponent } from "./components/assistant-message.ts";
|
|
10
|
+
import { CountdownTimer } from "./components/countdown-timer.ts";
|
|
11
|
+
import type { CustomEditor } from "./components/custom-editor.ts";
|
|
12
|
+
import type { FooterComponent } from "./components/footer.ts";
|
|
13
|
+
import type { ToolExecutionComponent } from "./components/tool-execution.ts";
|
|
14
|
+
import { type ToolPanelRegistry, type ToolPanelTenantScope } from "./components/tool-panel-registry.ts";
|
|
15
|
+
/** Structural host consumed by the event owner. InteractiveMode deliberately remains a thin facade. */
|
|
16
|
+
export interface InteractiveEventHost {
|
|
17
|
+
isInitialized: boolean;
|
|
18
|
+
session: AgentSession;
|
|
19
|
+
settingsManager: SettingsManager;
|
|
20
|
+
footer: FooterComponent;
|
|
21
|
+
footerDataProvider: FooterDataProvider;
|
|
22
|
+
ui: TUI;
|
|
23
|
+
defaultEditor: CustomEditor;
|
|
24
|
+
statusContainer: Container;
|
|
25
|
+
chatContainer: Container;
|
|
26
|
+
activityLane: ActivityLaneComponent | undefined;
|
|
27
|
+
loadingAnimation: Loader | undefined;
|
|
28
|
+
workingVisible: boolean;
|
|
29
|
+
workingIndicatorOptions: LoaderIndicatorOptions | undefined;
|
|
30
|
+
retryEscapeHandler: (() => void) | undefined;
|
|
31
|
+
retryCountdown: CountdownTimer | undefined;
|
|
32
|
+
autoCompactionEscapeHandler: (() => void) | undefined;
|
|
33
|
+
streamingComponent: AssistantMessageComponent | undefined;
|
|
34
|
+
streamingMessage: AssistantMessage | undefined;
|
|
35
|
+
hideThinkingBlock: boolean;
|
|
36
|
+
hiddenThinkingLabel: string;
|
|
37
|
+
lastStreamingUiUpdateAt: number;
|
|
38
|
+
toolPanels: ToolPanelRegistry;
|
|
39
|
+
init(): Promise<void>;
|
|
40
|
+
createWorkingLoader(): Loader;
|
|
41
|
+
stopWorkingLoader(): void;
|
|
42
|
+
clearActiveToolCalls(): void;
|
|
43
|
+
getWorkingLoaderMessage(): string;
|
|
44
|
+
updatePendingMessagesDisplay(): void;
|
|
45
|
+
updateTerminalTitle(): void;
|
|
46
|
+
refreshActivityLane(): void;
|
|
47
|
+
updateEditorBorderColor(): void;
|
|
48
|
+
showWarning(message: string): void;
|
|
49
|
+
showError(message: string): void;
|
|
50
|
+
addMessageToChat(message: AgentMessage): void;
|
|
51
|
+
clearPendingStreamingUiUpdate(): void;
|
|
52
|
+
getMarkdownThemeWithSettings(): MarkdownTheme;
|
|
53
|
+
applyStreamingMessageUpdate(message: AssistantMessage, options?: {
|
|
54
|
+
force?: boolean;
|
|
55
|
+
}): void;
|
|
56
|
+
trimLiveTuiHistory(): void;
|
|
57
|
+
attachToolExecutionComponent(toolName: string, toolCallId: string, args: unknown, repair?: ToolCallRepairInfo): ToolExecutionComponent;
|
|
58
|
+
toolActivityKind(toolName: string): ActivityLaneKind;
|
|
59
|
+
toolActivityLabel(toolName: string): string;
|
|
60
|
+
toolActivityTerminalStatus(isError: boolean, details: unknown): "success" | "failure" | "neutral";
|
|
61
|
+
getToolPanelScope(): ToolPanelTenantScope;
|
|
62
|
+
isNativeReflectionEnabled(): boolean;
|
|
63
|
+
maybeRunNativeReflection(messages: AgentMessage[]): void;
|
|
64
|
+
maybeStartAutoLearn(): boolean;
|
|
65
|
+
maybeStartAutonomyReview(messages: AgentMessage[]): boolean;
|
|
66
|
+
checkShutdownRequested(): Promise<void>;
|
|
67
|
+
rebuildChatFromMessages(): Promise<void>;
|
|
68
|
+
flushCompactionQueue(options?: {
|
|
69
|
+
willRetry?: boolean;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/** Single owner for AgentSessionEvent -> terminal UI state transitions. */
|
|
73
|
+
export declare function handleInteractiveEvent(host: InteractiveEventHost, event: AgentSessionEvent): Promise<void>;
|
|
74
|
+
//# sourceMappingURL=interactive-event-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive-event-controller.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-event-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAElF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACN,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAGlB,KAAK,GAAG,EACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EA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EAAE,GAAG,IAAI,CAAC;IACzD,mBAAmB,IAAI,OAAO,CAAC;IAC/B,wBAAwB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAC5D,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,oBAAoB,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,2EAA2E;AAC3E,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkVhH","sourcesContent":["import type { AgentMessage, ToolCallRepairInfo } from \"@caupulican/pi-agent-core\";\nimport { createCompactionSummaryMessage } from \"@caupulican/pi-agent-core\";\nimport type { AssistantMessage } from \"@caupulican/pi-ai\";\nimport {\n\ttype Container,\n\ttype Loader,\n\ttype LoaderIndicatorOptions,\n\ttype MarkdownTheme,\n\tSpacer,\n\tText,\n\ttype TUI,\n} from \"@caupulican/pi-tui\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AgentSessionEvent } from \"../../core/agent-session-contracts.ts\";\nimport type { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport type { ActivityLaneComponent, ActivityLaneKind } from \"./components/activity-lane.ts\";\nimport { AssistantMessageComponent } from \"./components/assistant-message.ts\";\nimport { CountdownTimer } from \"./components/countdown-timer.ts\";\nimport type { CustomEditor } from \"./components/custom-editor.ts\";\nimport type { FooterComponent } from \"./components/footer.ts\";\nimport { keyText } from \"./components/keybinding-hints.ts\";\nimport type { ToolExecutionComponent } from \"./components/tool-execution.ts\";\nimport {\n\tgetToolPanelResultActionKeys,\n\ttype ToolPanelRegistry,\n\ttype ToolPanelTenantScope,\n} from \"./components/tool-panel-registry.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/** Structural host consumed by the event owner. InteractiveMode deliberately remains a thin facade. */\nexport interface InteractiveEventHost {\n\tisInitialized: boolean;\n\tsession: AgentSession;\n\tsettingsManager: SettingsManager;\n\tfooter: FooterComponent;\n\tfooterDataProvider: FooterDataProvider;\n\tui: TUI;\n\tdefaultEditor: CustomEditor;\n\tstatusContainer: Container;\n\tchatContainer: Container;\n\tactivityLane: ActivityLaneComponent | undefined;\n\tloadingAnimation: Loader | undefined;\n\tworkingVisible: boolean;\n\tworkingIndicatorOptions: LoaderIndicatorOptions | undefined;\n\tretryEscapeHandler: (() => void) | undefined;\n\tretryCountdown: CountdownTimer | undefined;\n\tautoCompactionEscapeHandler: (() => void) | undefined;\n\tstreamingComponent: AssistantMessageComponent | undefined;\n\tstreamingMessage: AssistantMessage | undefined;\n\thideThinkingBlock: boolean;\n\thiddenThinkingLabel: string;\n\tlastStreamingUiUpdateAt: number;\n\ttoolPanels: ToolPanelRegistry;\n\tinit(): Promise<void>;\n\tcreateWorkingLoader(): Loader;\n\tstopWorkingLoader(): void;\n\tclearActiveToolCalls(): void;\n\tgetWorkingLoaderMessage(): string;\n\tupdatePendingMessagesDisplay(): void;\n\tupdateTerminalTitle(): void;\n\trefreshActivityLane(): void;\n\tupdateEditorBorderColor(): void;\n\tshowWarning(message: string): void;\n\tshowError(message: string): void;\n\taddMessageToChat(message: AgentMessage): void;\n\tclearPendingStreamingUiUpdate(): void;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tapplyStreamingMessageUpdate(message: AssistantMessage, options?: { force?: boolean }): void;\n\ttrimLiveTuiHistory(): void;\n\tattachToolExecutionComponent(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\trepair?: ToolCallRepairInfo,\n\t): ToolExecutionComponent;\n\ttoolActivityKind(toolName: string): ActivityLaneKind;\n\ttoolActivityLabel(toolName: string): string;\n\ttoolActivityTerminalStatus(isError: boolean, details: unknown): \"success\" | \"failure\" | \"neutral\";\n\tgetToolPanelScope(): ToolPanelTenantScope;\n\tisNativeReflectionEnabled(): boolean;\n\tmaybeRunNativeReflection(messages: AgentMessage[]): void;\n\tmaybeStartAutoLearn(): boolean;\n\tmaybeStartAutonomyReview(messages: AgentMessage[]): boolean;\n\tcheckShutdownRequested(): Promise<void>;\n\trebuildChatFromMessages(): Promise<void>;\n\tflushCompactionQueue(options?: { willRetry?: boolean }): Promise<void>;\n}\n\n/** Single owner for AgentSessionEvent -> terminal UI state transitions. */\nexport async function handleInteractiveEvent(host: InteractiveEventHost, event: AgentSessionEvent): Promise<void> {\n\tif (!host.isInitialized) await host.init();\n\thost.footer.invalidate();\n\n\tswitch (event.type) {\n\t\tcase \"routing_start\":\n\t\t\tif (!host.session.isStreaming && !host.loadingAnimation && host.workingVisible) {\n\t\t\t\tif (host.workingIndicatorOptions) {\n\t\t\t\t\thost.loadingAnimation = host.createWorkingLoader();\n\t\t\t\t\thost.statusContainer.addChild(host.loadingAnimation);\n\t\t\t\t} else {\n\t\t\t\t\thost.activityLane?.start({ id: \"runtime:routing\", kind: \"runtime\", label: \"Routing\" });\n\t\t\t\t}\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"routing_end\":\n\t\t\thost.stopWorkingLoader();\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"agent_start\":\n\t\t\thost.clearActiveToolCalls();\n\t\t\tif (host.settingsManager.getShowTerminalProgress()) host.ui.terminal.setProgress(true);\n\t\t\tif (host.retryEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.retryEscapeHandler;\n\t\t\t\thost.retryEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.retryCountdown) {\n\t\t\t\thost.retryCountdown.dispose();\n\t\t\t\thost.retryCountdown = undefined;\n\t\t\t}\n\t\t\thost.activityLane?.remove(\"runtime:retry\");\n\t\t\thost.stopWorkingLoader();\n\t\t\tif (host.workingVisible) {\n\t\t\t\tif (host.workingIndicatorOptions) {\n\t\t\t\t\thost.loadingAnimation = host.createWorkingLoader();\n\t\t\t\t\thost.statusContainer.addChild(host.loadingAnimation);\n\t\t\t\t} else {\n\t\t\t\t\thost.activityLane?.start({\n\t\t\t\t\t\tid: \"runtime:turn\",\n\t\t\t\t\t\tkind: \"runtime\",\n\t\t\t\t\t\tlabel: host.getWorkingLoaderMessage(),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"queue_update\":\n\t\t\thost.updatePendingMessagesDisplay();\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"session_info_changed\":\n\t\t\thost.updateTerminalTitle();\n\t\t\thost.refreshActivityLane();\n\t\t\thost.footer.invalidate();\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"thinking_level_changed\":\n\t\t\thost.footer.invalidate();\n\t\t\thost.updateEditorBorderColor();\n\t\t\tbreak;\n\n\t\tcase \"warning\":\n\t\t\thost.showWarning(event.message);\n\t\t\tbreak;\n\n\t\tcase \"delegate_workers\":\n\t\t\thost.footerDataProvider.setExtensionStatus(\"delegate\", undefined);\n\t\t\thost.refreshActivityLane();\n\t\t\thost.footer.invalidate();\n\t\t\tbreak;\n\n\t\tcase \"message_start\":\n\t\t\tif (event.message.role === \"custom\") {\n\t\t\t\thost.addMessageToChat(event.message);\n\t\t\t\thost.ui.requestRender();\n\t\t\t} else if (event.message.role === \"user\") {\n\t\t\t\thost.addMessageToChat(event.message);\n\t\t\t\thost.updatePendingMessagesDisplay();\n\t\t\t\thost.ui.requestRender();\n\t\t\t} else if (event.message.role === \"assistant\") {\n\t\t\t\thost.clearPendingStreamingUiUpdate();\n\t\t\t\thost.lastStreamingUiUpdateAt = 0;\n\t\t\t\thost.streamingComponent = new AssistantMessageComponent(\n\t\t\t\t\tundefined,\n\t\t\t\t\thost.hideThinkingBlock,\n\t\t\t\t\thost.getMarkdownThemeWithSettings(),\n\t\t\t\t\thost.hiddenThinkingLabel,\n\t\t\t\t);\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\thost.chatContainer.addChild(host.streamingComponent);\n\t\t\t\thost.applyStreamingMessageUpdate(host.streamingMessage, { force: true });\n\t\t\t\thost.trimLiveTuiHistory();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"message_update\":\n\t\t\tif (host.streamingComponent && event.message.role === \"assistant\") {\n\t\t\t\thost.applyStreamingMessageUpdate(event.message);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"message_end\":\n\t\t\tif (event.message.role === \"user\") break;\n\t\t\tif (host.streamingComponent && event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\tlet errorMessage: string | undefined;\n\t\t\t\tif (host.streamingMessage.stopReason === \"aborted\") {\n\t\t\t\t\tconst retryAttempt = host.session.retryAttempt;\n\t\t\t\t\terrorMessage =\n\t\t\t\t\t\tretryAttempt > 0\n\t\t\t\t\t\t\t? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? \"s\" : \"\"}`\n\t\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\t\thost.streamingMessage.errorMessage = errorMessage;\n\t\t\t\t}\n\t\t\t\thost.applyStreamingMessageUpdate(host.streamingMessage, { force: true });\n\t\t\t\tif (host.streamingMessage.stopReason === \"aborted\" || host.streamingMessage.stopReason === \"error\") {\n\t\t\t\t\terrorMessage ??= host.streamingMessage.errorMessage || \"Error\";\n\t\t\t\t\tfor (const [, component] of host.toolPanels.activeEntries()) {\n\t\t\t\t\t\tcomponent.updateResult({ content: [{ type: \"text\", text: errorMessage }], isError: true });\n\t\t\t\t\t}\n\t\t\t\t\thost.clearActiveToolCalls();\n\t\t\t\t} else {\n\t\t\t\t\tfor (const [, component] of host.toolPanels.activeEntries()) component.setArgsComplete();\n\t\t\t\t}\n\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\thost.streamingMessage = undefined;\n\t\t\t\thost.footer.invalidate();\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"tool_execution_start\": {\n\t\t\thost.activityLane?.start({\n\t\t\t\tid: `tool:${event.toolCallId}`,\n\t\t\t\tkind: host.toolActivityKind(event.toolName),\n\t\t\t\tlabel: host.toolActivityLabel(event.toolName),\n\t\t\t});\n\t\t\tlet component = host.toolPanels.getActive(event.toolCallId);\n\t\t\tif (!component) {\n\t\t\t\tcomponent = host.attachToolExecutionComponent(event.toolName, event.toolCallId, event.args, event.repair);\n\t\t\t} else {\n\t\t\t\tcomponent.updateArgs(event.args, event.repair);\n\t\t\t}\n\t\t\tcomponent.markExecutionStarted(event.repair);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"tool_execution_update\": {\n\t\t\tconst component = host.toolPanels.getActive(event.toolCallId);\n\t\t\tif (component) {\n\t\t\t\tcomponent.updateArgs(event.args, event.repair);\n\t\t\t\tcomponent.updateResult({ ...event.partialResult, isError: false }, true);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"tool_execution_end\": {\n\t\t\tconst toolActivityId = `tool:${event.toolCallId}`;\n\t\t\tif (host.activityLane) {\n\t\t\t\tconst toolKind = host.toolActivityKind(event.toolName);\n\t\t\t\tconst terminalStatus = host.toolActivityTerminalStatus(event.isError, event.result.details);\n\t\t\t\tif (toolKind === \"tool\" || terminalStatus !== \"success\") {\n\t\t\t\t\thost.activityLane.finish(toolActivityId, terminalStatus, {\n\t\t\t\t\t\tid: toolActivityId,\n\t\t\t\t\t\tkind: toolKind,\n\t\t\t\t\t\tlabel: host.toolActivityLabel(event.toolName),\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\thost.activityLane.remove(toolActivityId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst component = host.toolPanels.getActive(event.toolCallId);\n\t\t\tif (component) {\n\t\t\t\tcomponent.updateResult({ ...event.result, isError: event.isError });\n\t\t\t\thost.toolPanels.registerAliases(\n\t\t\t\t\tcomponent,\n\t\t\t\t\tgetToolPanelResultActionKeys(host.getToolPanelScope(), event.toolName, event.result),\n\t\t\t\t);\n\t\t\t\thost.toolPanels.finish(event.toolCallId);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tif ([\"task_steps\", \"goal\", \"delegate\", \"delegate_status\"].includes(event.toolName)) {\n\t\t\t\thost.refreshActivityLane();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"agent_end\": {\n\t\t\tif (host.isNativeReflectionEnabled()) host.maybeRunNativeReflection(event.messages);\n\t\t\telse if (!host.maybeStartAutoLearn()) host.maybeStartAutonomyReview(event.messages);\n\t\t\tif (host.settingsManager.getShowTerminalProgress()) host.ui.terminal.setProgress(false);\n\t\t\tif (event.willRetry) {\n\t\t\t\thost.activityLane?.remove(\"runtime:turn\");\n\t\t\t} else {\n\t\t\t\tconst finalAssistant = event.messages.findLast(\n\t\t\t\t\t(message): message is AssistantMessage => message.role === \"assistant\",\n\t\t\t\t);\n\t\t\t\tconst failed = finalAssistant?.stopReason === \"error\" || finalAssistant?.stopReason === \"aborted\";\n\t\t\t\thost.activityLane?.finish(\"runtime:turn\", failed ? \"failure\" : \"success\", {\n\t\t\t\t\tid: \"runtime:turn\",\n\t\t\t\t\tkind: \"runtime\",\n\t\t\t\t\tlabel: failed ? \"Turn failed\" : \"Done\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (host.loadingAnimation) {\n\t\t\t\thost.loadingAnimation.stop();\n\t\t\t\thost.loadingAnimation = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (host.streamingComponent) {\n\t\t\t\thost.chatContainer.removeChild(host.streamingComponent);\n\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\thost.streamingMessage = undefined;\n\t\t\t}\n\t\t\thost.clearActiveToolCalls();\n\t\t\thost.activityLane?.removeByPrefix(\"tool:\");\n\t\t\tawait host.checkShutdownRequested();\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"compaction_start\": {\n\t\t\tif (host.settingsManager.getShowTerminalProgress()) host.ui.terminal.setProgress(true);\n\t\t\thost.autoCompactionEscapeHandler = host.defaultEditor.onEscape;\n\t\t\thost.defaultEditor.onEscape = () => host.session.abortCompaction();\n\t\t\thost.stopWorkingLoader();\n\t\t\tconst cancelHint = `(${keyText(\"app.interrupt\")} to cancel)`;\n\t\t\tconst label =\n\t\t\t\tevent.reason === \"manual\"\n\t\t\t\t\t? `Compacting context ${cancelHint}`\n\t\t\t\t\t: `${event.reason === \"overflow\" ? \"Context overflow · \" : \"\"}Auto-compacting ${cancelHint}`;\n\t\t\thost.activityLane?.start({ id: \"runtime:compaction\", kind: \"runtime\", label });\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"compaction_end\": {\n\t\t\tif (host.settingsManager.getShowTerminalProgress()) host.ui.terminal.setProgress(false);\n\t\t\tif (host.autoCompactionEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.autoCompactionEscapeHandler;\n\t\t\t\thost.autoCompactionEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (event.aborted) {\n\t\t\t\thost.activityLane?.finish(\"runtime:compaction\", \"neutral\", {\n\t\t\t\t\tid: \"runtime:compaction\",\n\t\t\t\t\tkind: \"runtime\",\n\t\t\t\t\tlabel: \"Compaction cancelled\",\n\t\t\t\t});\n\t\t\t\tif (event.reason === \"manual\") host.showError(\"Compaction cancelled\");\n\t\t\t} else if (event.result) {\n\t\t\t\thost.activityLane?.finish(\"runtime:compaction\", \"success\", {\n\t\t\t\t\tid: \"runtime:compaction\",\n\t\t\t\t\tkind: \"runtime\",\n\t\t\t\t\tlabel: \"Context compacted\",\n\t\t\t\t});\n\t\t\t\tawait host.rebuildChatFromMessages();\n\t\t\t\thost.addMessageToChat(\n\t\t\t\t\tcreateCompactionSummaryMessage(\n\t\t\t\t\t\tevent.result.summary,\n\t\t\t\t\t\tevent.result.tokensBefore,\n\t\t\t\t\t\tnew Date().toISOString(),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\thost.footer.invalidate();\n\t\t\t} else if (event.errorMessage) {\n\t\t\t\thost.activityLane?.finish(\"runtime:compaction\", \"failure\", {\n\t\t\t\t\tid: \"runtime:compaction\",\n\t\t\t\t\tkind: \"runtime\",\n\t\t\t\t\tlabel: \"Compaction failed\",\n\t\t\t\t});\n\t\t\t\tif (event.reason === \"manual\") host.showError(event.errorMessage);\n\t\t\t\telse {\n\t\t\t\t\thost.chatContainer.addChild(new Spacer(1));\n\t\t\t\t\thost.chatContainer.addChild(new Text(theme.fg(\"error\", event.errorMessage), 1, 0));\n\t\t\t\t}\n\t\t\t} else if (event.skipReason) {\n\t\t\t\thost.activityLane?.finish(\"runtime:compaction\", \"neutral\", {\n\t\t\t\t\tid: \"runtime:compaction\",\n\t\t\t\t\tkind: \"runtime\",\n\t\t\t\t\tlabel: `Compaction skipped · ${event.skipReason}`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tvoid host.flushCompactionQueue({ willRetry: event.willRetry });\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"auto_retry_start\": {\n\t\t\thost.retryEscapeHandler = host.defaultEditor.onEscape;\n\t\t\thost.defaultEditor.onEscape = () => host.session.abortRetry();\n\t\t\thost.retryCountdown?.dispose();\n\t\t\tconst retryMessage = (seconds: number) =>\n\t\t\t\t`Retry ${event.attempt}/${event.maxAttempts} in ${seconds}s · ${keyText(\"app.interrupt\")} cancel`;\n\t\t\thost.activityLane?.wait({\n\t\t\t\tid: \"runtime:retry\",\n\t\t\t\tkind: \"runtime\",\n\t\t\t\tlabel: retryMessage(Math.ceil(event.delayMs / 1000)),\n\t\t\t});\n\t\t\thost.retryCountdown = new CountdownTimer(\n\t\t\t\tevent.delayMs,\n\t\t\t\thost.ui,\n\t\t\t\t(seconds) => host.activityLane?.update(\"runtime:retry\", retryMessage(seconds)),\n\t\t\t\t() => {\n\t\t\t\t\thost.retryCountdown = undefined;\n\t\t\t\t},\n\t\t\t);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"auto_retry_end\":\n\t\t\tif (host.retryEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.retryEscapeHandler;\n\t\t\t\thost.retryEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.retryCountdown) {\n\t\t\t\thost.retryCountdown.dispose();\n\t\t\t\thost.retryCountdown = undefined;\n\t\t\t}\n\t\t\thost.activityLane?.finish(\"runtime:retry\", event.success ? \"success\" : \"failure\", {\n\t\t\t\tid: \"runtime:retry\",\n\t\t\t\tkind: \"runtime\",\n\t\t\t\tlabel: event.success ? \"Retry resumed\" : \"Retry failed\",\n\t\t\t});\n\t\t\tif (!event.success) {\n\t\t\t\thost.showError(`Retry failed after ${event.attempt} attempts: ${event.finalError || \"Unknown error\"}`);\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { createCompactionSummaryMessage } from "@caupulican/pi-agent-core";
|
|
2
|
+
import { Spacer, Text, } from "@caupulican/pi-tui";
|
|
3
|
+
import { AssistantMessageComponent } from "./components/assistant-message.js";
|
|
4
|
+
import { CountdownTimer } from "./components/countdown-timer.js";
|
|
5
|
+
import { keyText } from "./components/keybinding-hints.js";
|
|
6
|
+
import { getToolPanelResultActionKeys, } from "./components/tool-panel-registry.js";
|
|
7
|
+
import { theme } from "./theme/theme.js";
|
|
8
|
+
/** Single owner for AgentSessionEvent -> terminal UI state transitions. */
|
|
9
|
+
export async function handleInteractiveEvent(host, event) {
|
|
10
|
+
if (!host.isInitialized)
|
|
11
|
+
await host.init();
|
|
12
|
+
host.footer.invalidate();
|
|
13
|
+
switch (event.type) {
|
|
14
|
+
case "routing_start":
|
|
15
|
+
if (!host.session.isStreaming && !host.loadingAnimation && host.workingVisible) {
|
|
16
|
+
if (host.workingIndicatorOptions) {
|
|
17
|
+
host.loadingAnimation = host.createWorkingLoader();
|
|
18
|
+
host.statusContainer.addChild(host.loadingAnimation);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
host.activityLane?.start({ id: "runtime:routing", kind: "runtime", label: "Routing" });
|
|
22
|
+
}
|
|
23
|
+
host.ui.requestRender();
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
case "routing_end":
|
|
27
|
+
host.stopWorkingLoader();
|
|
28
|
+
host.ui.requestRender();
|
|
29
|
+
break;
|
|
30
|
+
case "agent_start":
|
|
31
|
+
host.clearActiveToolCalls();
|
|
32
|
+
if (host.settingsManager.getShowTerminalProgress())
|
|
33
|
+
host.ui.terminal.setProgress(true);
|
|
34
|
+
if (host.retryEscapeHandler) {
|
|
35
|
+
host.defaultEditor.onEscape = host.retryEscapeHandler;
|
|
36
|
+
host.retryEscapeHandler = undefined;
|
|
37
|
+
}
|
|
38
|
+
if (host.retryCountdown) {
|
|
39
|
+
host.retryCountdown.dispose();
|
|
40
|
+
host.retryCountdown = undefined;
|
|
41
|
+
}
|
|
42
|
+
host.activityLane?.remove("runtime:retry");
|
|
43
|
+
host.stopWorkingLoader();
|
|
44
|
+
if (host.workingVisible) {
|
|
45
|
+
if (host.workingIndicatorOptions) {
|
|
46
|
+
host.loadingAnimation = host.createWorkingLoader();
|
|
47
|
+
host.statusContainer.addChild(host.loadingAnimation);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
host.activityLane?.start({
|
|
51
|
+
id: "runtime:turn",
|
|
52
|
+
kind: "runtime",
|
|
53
|
+
label: host.getWorkingLoaderMessage(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
host.ui.requestRender();
|
|
58
|
+
break;
|
|
59
|
+
case "queue_update":
|
|
60
|
+
host.updatePendingMessagesDisplay();
|
|
61
|
+
host.ui.requestRender();
|
|
62
|
+
break;
|
|
63
|
+
case "session_info_changed":
|
|
64
|
+
host.updateTerminalTitle();
|
|
65
|
+
host.refreshActivityLane();
|
|
66
|
+
host.footer.invalidate();
|
|
67
|
+
host.ui.requestRender();
|
|
68
|
+
break;
|
|
69
|
+
case "thinking_level_changed":
|
|
70
|
+
host.footer.invalidate();
|
|
71
|
+
host.updateEditorBorderColor();
|
|
72
|
+
break;
|
|
73
|
+
case "warning":
|
|
74
|
+
host.showWarning(event.message);
|
|
75
|
+
break;
|
|
76
|
+
case "delegate_workers":
|
|
77
|
+
host.footerDataProvider.setExtensionStatus("delegate", undefined);
|
|
78
|
+
host.refreshActivityLane();
|
|
79
|
+
host.footer.invalidate();
|
|
80
|
+
break;
|
|
81
|
+
case "message_start":
|
|
82
|
+
if (event.message.role === "custom") {
|
|
83
|
+
host.addMessageToChat(event.message);
|
|
84
|
+
host.ui.requestRender();
|
|
85
|
+
}
|
|
86
|
+
else if (event.message.role === "user") {
|
|
87
|
+
host.addMessageToChat(event.message);
|
|
88
|
+
host.updatePendingMessagesDisplay();
|
|
89
|
+
host.ui.requestRender();
|
|
90
|
+
}
|
|
91
|
+
else if (event.message.role === "assistant") {
|
|
92
|
+
host.clearPendingStreamingUiUpdate();
|
|
93
|
+
host.lastStreamingUiUpdateAt = 0;
|
|
94
|
+
host.streamingComponent = new AssistantMessageComponent(undefined, host.hideThinkingBlock, host.getMarkdownThemeWithSettings(), host.hiddenThinkingLabel);
|
|
95
|
+
host.streamingMessage = event.message;
|
|
96
|
+
host.chatContainer.addChild(host.streamingComponent);
|
|
97
|
+
host.applyStreamingMessageUpdate(host.streamingMessage, { force: true });
|
|
98
|
+
host.trimLiveTuiHistory();
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case "message_update":
|
|
102
|
+
if (host.streamingComponent && event.message.role === "assistant") {
|
|
103
|
+
host.applyStreamingMessageUpdate(event.message);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case "message_end":
|
|
107
|
+
if (event.message.role === "user")
|
|
108
|
+
break;
|
|
109
|
+
if (host.streamingComponent && event.message.role === "assistant") {
|
|
110
|
+
host.streamingMessage = event.message;
|
|
111
|
+
let errorMessage;
|
|
112
|
+
if (host.streamingMessage.stopReason === "aborted") {
|
|
113
|
+
const retryAttempt = host.session.retryAttempt;
|
|
114
|
+
errorMessage =
|
|
115
|
+
retryAttempt > 0
|
|
116
|
+
? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
|
|
117
|
+
: "Operation aborted";
|
|
118
|
+
host.streamingMessage.errorMessage = errorMessage;
|
|
119
|
+
}
|
|
120
|
+
host.applyStreamingMessageUpdate(host.streamingMessage, { force: true });
|
|
121
|
+
if (host.streamingMessage.stopReason === "aborted" || host.streamingMessage.stopReason === "error") {
|
|
122
|
+
errorMessage ??= host.streamingMessage.errorMessage || "Error";
|
|
123
|
+
for (const [, component] of host.toolPanels.activeEntries()) {
|
|
124
|
+
component.updateResult({ content: [{ type: "text", text: errorMessage }], isError: true });
|
|
125
|
+
}
|
|
126
|
+
host.clearActiveToolCalls();
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
for (const [, component] of host.toolPanels.activeEntries())
|
|
130
|
+
component.setArgsComplete();
|
|
131
|
+
}
|
|
132
|
+
host.streamingComponent = undefined;
|
|
133
|
+
host.streamingMessage = undefined;
|
|
134
|
+
host.footer.invalidate();
|
|
135
|
+
}
|
|
136
|
+
host.ui.requestRender();
|
|
137
|
+
break;
|
|
138
|
+
case "tool_execution_start": {
|
|
139
|
+
host.activityLane?.start({
|
|
140
|
+
id: `tool:${event.toolCallId}`,
|
|
141
|
+
kind: host.toolActivityKind(event.toolName),
|
|
142
|
+
label: host.toolActivityLabel(event.toolName),
|
|
143
|
+
});
|
|
144
|
+
let component = host.toolPanels.getActive(event.toolCallId);
|
|
145
|
+
if (!component) {
|
|
146
|
+
component = host.attachToolExecutionComponent(event.toolName, event.toolCallId, event.args, event.repair);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
component.updateArgs(event.args, event.repair);
|
|
150
|
+
}
|
|
151
|
+
component.markExecutionStarted(event.repair);
|
|
152
|
+
host.ui.requestRender();
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case "tool_execution_update": {
|
|
156
|
+
const component = host.toolPanels.getActive(event.toolCallId);
|
|
157
|
+
if (component) {
|
|
158
|
+
component.updateArgs(event.args, event.repair);
|
|
159
|
+
component.updateResult({ ...event.partialResult, isError: false }, true);
|
|
160
|
+
host.ui.requestRender();
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case "tool_execution_end": {
|
|
165
|
+
const toolActivityId = `tool:${event.toolCallId}`;
|
|
166
|
+
if (host.activityLane) {
|
|
167
|
+
const toolKind = host.toolActivityKind(event.toolName);
|
|
168
|
+
const terminalStatus = host.toolActivityTerminalStatus(event.isError, event.result.details);
|
|
169
|
+
if (toolKind === "tool" || terminalStatus !== "success") {
|
|
170
|
+
host.activityLane.finish(toolActivityId, terminalStatus, {
|
|
171
|
+
id: toolActivityId,
|
|
172
|
+
kind: toolKind,
|
|
173
|
+
label: host.toolActivityLabel(event.toolName),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
host.activityLane.remove(toolActivityId);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const component = host.toolPanels.getActive(event.toolCallId);
|
|
181
|
+
if (component) {
|
|
182
|
+
component.updateResult({ ...event.result, isError: event.isError });
|
|
183
|
+
host.toolPanels.registerAliases(component, getToolPanelResultActionKeys(host.getToolPanelScope(), event.toolName, event.result));
|
|
184
|
+
host.toolPanels.finish(event.toolCallId);
|
|
185
|
+
host.ui.requestRender();
|
|
186
|
+
}
|
|
187
|
+
if (["task_steps", "goal", "delegate", "delegate_status"].includes(event.toolName)) {
|
|
188
|
+
host.refreshActivityLane();
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case "agent_end": {
|
|
193
|
+
if (host.isNativeReflectionEnabled())
|
|
194
|
+
host.maybeRunNativeReflection(event.messages);
|
|
195
|
+
else if (!host.maybeStartAutoLearn())
|
|
196
|
+
host.maybeStartAutonomyReview(event.messages);
|
|
197
|
+
if (host.settingsManager.getShowTerminalProgress())
|
|
198
|
+
host.ui.terminal.setProgress(false);
|
|
199
|
+
if (event.willRetry) {
|
|
200
|
+
host.activityLane?.remove("runtime:turn");
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const finalAssistant = event.messages.findLast((message) => message.role === "assistant");
|
|
204
|
+
const failed = finalAssistant?.stopReason === "error" || finalAssistant?.stopReason === "aborted";
|
|
205
|
+
host.activityLane?.finish("runtime:turn", failed ? "failure" : "success", {
|
|
206
|
+
id: "runtime:turn",
|
|
207
|
+
kind: "runtime",
|
|
208
|
+
label: failed ? "Turn failed" : "Done",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (host.loadingAnimation) {
|
|
212
|
+
host.loadingAnimation.stop();
|
|
213
|
+
host.loadingAnimation = undefined;
|
|
214
|
+
host.statusContainer.clear();
|
|
215
|
+
}
|
|
216
|
+
if (host.streamingComponent) {
|
|
217
|
+
host.chatContainer.removeChild(host.streamingComponent);
|
|
218
|
+
host.streamingComponent = undefined;
|
|
219
|
+
host.streamingMessage = undefined;
|
|
220
|
+
}
|
|
221
|
+
host.clearActiveToolCalls();
|
|
222
|
+
host.activityLane?.removeByPrefix("tool:");
|
|
223
|
+
await host.checkShutdownRequested();
|
|
224
|
+
host.ui.requestRender();
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case "compaction_start": {
|
|
228
|
+
if (host.settingsManager.getShowTerminalProgress())
|
|
229
|
+
host.ui.terminal.setProgress(true);
|
|
230
|
+
host.autoCompactionEscapeHandler = host.defaultEditor.onEscape;
|
|
231
|
+
host.defaultEditor.onEscape = () => host.session.abortCompaction();
|
|
232
|
+
host.stopWorkingLoader();
|
|
233
|
+
const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
|
|
234
|
+
const label = event.reason === "manual"
|
|
235
|
+
? `Compacting context ${cancelHint}`
|
|
236
|
+
: `${event.reason === "overflow" ? "Context overflow · " : ""}Auto-compacting ${cancelHint}`;
|
|
237
|
+
host.activityLane?.start({ id: "runtime:compaction", kind: "runtime", label });
|
|
238
|
+
host.ui.requestRender();
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
case "compaction_end": {
|
|
242
|
+
if (host.settingsManager.getShowTerminalProgress())
|
|
243
|
+
host.ui.terminal.setProgress(false);
|
|
244
|
+
if (host.autoCompactionEscapeHandler) {
|
|
245
|
+
host.defaultEditor.onEscape = host.autoCompactionEscapeHandler;
|
|
246
|
+
host.autoCompactionEscapeHandler = undefined;
|
|
247
|
+
}
|
|
248
|
+
if (event.aborted) {
|
|
249
|
+
host.activityLane?.finish("runtime:compaction", "neutral", {
|
|
250
|
+
id: "runtime:compaction",
|
|
251
|
+
kind: "runtime",
|
|
252
|
+
label: "Compaction cancelled",
|
|
253
|
+
});
|
|
254
|
+
if (event.reason === "manual")
|
|
255
|
+
host.showError("Compaction cancelled");
|
|
256
|
+
}
|
|
257
|
+
else if (event.result) {
|
|
258
|
+
host.activityLane?.finish("runtime:compaction", "success", {
|
|
259
|
+
id: "runtime:compaction",
|
|
260
|
+
kind: "runtime",
|
|
261
|
+
label: "Context compacted",
|
|
262
|
+
});
|
|
263
|
+
await host.rebuildChatFromMessages();
|
|
264
|
+
host.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
|
|
265
|
+
host.footer.invalidate();
|
|
266
|
+
}
|
|
267
|
+
else if (event.errorMessage) {
|
|
268
|
+
host.activityLane?.finish("runtime:compaction", "failure", {
|
|
269
|
+
id: "runtime:compaction",
|
|
270
|
+
kind: "runtime",
|
|
271
|
+
label: "Compaction failed",
|
|
272
|
+
});
|
|
273
|
+
if (event.reason === "manual")
|
|
274
|
+
host.showError(event.errorMessage);
|
|
275
|
+
else {
|
|
276
|
+
host.chatContainer.addChild(new Spacer(1));
|
|
277
|
+
host.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else if (event.skipReason) {
|
|
281
|
+
host.activityLane?.finish("runtime:compaction", "neutral", {
|
|
282
|
+
id: "runtime:compaction",
|
|
283
|
+
kind: "runtime",
|
|
284
|
+
label: `Compaction skipped · ${event.skipReason}`,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
void host.flushCompactionQueue({ willRetry: event.willRetry });
|
|
288
|
+
host.ui.requestRender();
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
case "auto_retry_start": {
|
|
292
|
+
host.retryEscapeHandler = host.defaultEditor.onEscape;
|
|
293
|
+
host.defaultEditor.onEscape = () => host.session.abortRetry();
|
|
294
|
+
host.retryCountdown?.dispose();
|
|
295
|
+
const retryMessage = (seconds) => `Retry ${event.attempt}/${event.maxAttempts} in ${seconds}s · ${keyText("app.interrupt")} cancel`;
|
|
296
|
+
host.activityLane?.wait({
|
|
297
|
+
id: "runtime:retry",
|
|
298
|
+
kind: "runtime",
|
|
299
|
+
label: retryMessage(Math.ceil(event.delayMs / 1000)),
|
|
300
|
+
});
|
|
301
|
+
host.retryCountdown = new CountdownTimer(event.delayMs, host.ui, (seconds) => host.activityLane?.update("runtime:retry", retryMessage(seconds)), () => {
|
|
302
|
+
host.retryCountdown = undefined;
|
|
303
|
+
});
|
|
304
|
+
host.ui.requestRender();
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
case "auto_retry_end":
|
|
308
|
+
if (host.retryEscapeHandler) {
|
|
309
|
+
host.defaultEditor.onEscape = host.retryEscapeHandler;
|
|
310
|
+
host.retryEscapeHandler = undefined;
|
|
311
|
+
}
|
|
312
|
+
if (host.retryCountdown) {
|
|
313
|
+
host.retryCountdown.dispose();
|
|
314
|
+
host.retryCountdown = undefined;
|
|
315
|
+
}
|
|
316
|
+
host.activityLane?.finish("runtime:retry", event.success ? "success" : "failure", {
|
|
317
|
+
id: "runtime:retry",
|
|
318
|
+
kind: "runtime",
|
|
319
|
+
label: event.success ? "Retry resumed" : "Retry failed",
|
|
320
|
+
});
|
|
321
|
+
if (!event.success) {
|
|
322
|
+
host.showError(`Retry failed after ${event.attempt} attempts: ${event.finalError || "Unknown error"}`);
|
|
323
|
+
}
|
|
324
|
+
host.ui.requestRender();
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=interactive-event-controller.js.map
|