@timurproko/a1 0.1.8-dev.472 → 0.1.8-dev.508
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/bin/cli.js +4 -5
- package/bin/guardian.js +5 -1
- package/bin/module-identity.js +53 -98
- package/bin/module-resolver.js +138 -0
- package/bin/pinned-pi-public.js +25 -6
- package/bin/ui.js +7 -2
- package/bin/update-recovery.js +76 -7
- package/bin/warmup.js +3 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-diagnostics.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-image.js +1 -1
- package/dist/app/session-shell/helper-pool.d.ts +33 -0
- package/dist/app/session-shell/helper-pool.js +98 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation-client.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation-client.js +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation.js +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-source.js +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-worker.js +1 -1
- package/dist/app/session-shell/index.d.ts +7 -0
- package/dist/app/session-shell/index.js +4 -0
- package/dist/app/session-shell/paste-executor.d.ts +18 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-executor.js +50 -29
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-helper.js +1 -1
- package/dist/app/session-shell/paste-preparation-client.d.ts +31 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-preparation-client.js +19 -8
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-protocol.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-protocol.js +1 -1
- package/dist/app/session-shell/paste-text-preparation.d.ts +6 -0
- package/dist/{integrations/pi/session-ui/paste-text-preparation.d.ts → app/session-shell/paste-types.d.ts} +1 -4
- package/dist/{integrations/pi/session-ui → app/session-shell}/path-chip-presentation.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-chips.d.ts +5 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-chips.js +6 -2
- package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-history-controller.d.ts +2 -2
- package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-history-controller.js +2 -2
- package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-suggestion-controller.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-suggestion-controller.js +2 -2
- package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro.js +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-coordinator.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-coordinator.js +3 -5
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-helper.js +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-protocol.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-transport.d.ts +10 -2
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-transport.js +45 -19
- package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell-root.d.ts +75 -53
- package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell-root.js +30 -20
- package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell.d.ts +9 -8
- package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell.js +108 -67
- package/dist/{integrations/pi/session-ui → app/session-shell}/session-viewport-controller.d.ts +5 -5
- package/dist/{integrations/pi/session-ui → app/session-shell}/session-viewport-controller.js +5 -5
- package/dist/{integrations/pi/session-ui → app/session-shell}/system-clipboard.d.ts +1 -1
- package/dist/{integrations/pi/session-ui → app/session-shell}/system-clipboard.js +1 -1
- package/dist/cli/index.d.ts +8 -5
- package/dist/cli/index.js +4 -5
- package/dist/composition/index.d.ts +0 -1
- package/dist/composition/index.js +0 -1
- package/dist/composition/owned-ui.d.ts +2 -2
- package/dist/composition/owned-ui.js +35 -36
- package/dist/composition/settings-route-host.d.ts +2 -2
- package/dist/contracts/agent-engine/domain.d.ts +6 -1
- package/dist/contracts/agent-engine/index.d.ts +11 -8
- package/dist/contracts/agent-engine/index.js +6 -8
- package/dist/contracts/owned-ui/extension-ui.d.ts +8 -0
- package/dist/contracts/owned-ui/index.d.ts +12 -8
- package/dist/contracts/owned-ui/index.js +8 -8
- package/dist/features/launch/index.d.ts +12 -6
- package/dist/features/launch/index.js +6 -6
- package/dist/features/launch/intent.d.ts +5 -5
- package/dist/features/launch/intent.js +2 -2
- package/dist/features/owned-ui/index.d.ts +6 -6
- package/dist/features/owned-ui/index.js +4 -6
- package/dist/features/owned-ui/run.d.ts +2 -2
- package/dist/features/owned-ui/settings-app.d.ts +2 -2
- package/dist/features/owned-ui/settings-app.js +18 -5
- package/dist/features/prompt-history/service.d.ts +1 -1
- package/dist/features/prompt-history/service.js +1 -1
- package/dist/features/prompt-history/store.js +3 -7
- package/dist/features/prompt-suggestions/diagnostics.js +1 -1
- package/dist/features/prompt-suggestions/index.d.ts +2 -1
- package/dist/features/prompt-suggestions/index.js +1 -1
- package/dist/foundation/launch-guardian/index.d.ts +2 -1
- package/dist/foundation/launch-guardian/index.js +1 -1
- package/dist/foundation/lifecycle/index.d.ts +11 -6
- package/dist/foundation/lifecycle/index.js +5 -6
- package/dist/foundation/process-containment/index.d.ts +8 -6
- package/dist/foundation/process-containment/index.js +6 -6
- package/dist/foundation/process-containment/native-guardian-containment.js +3 -3
- package/dist/foundation/protocol/index.d.ts +3 -2
- package/dist/foundation/protocol/index.js +2 -2
- package/dist/foundation/release/bootstrap.d.ts +0 -4
- package/dist/foundation/release/bootstrap.js +1 -82
- package/dist/foundation/release/dependency-layer.d.ts +2 -5
- package/dist/foundation/release/endpoints.d.ts +4 -0
- package/dist/foundation/release/endpoints.js +86 -2
- package/dist/foundation/release/index.d.ts +30 -16
- package/dist/foundation/release/index.js +16 -16
- package/dist/foundation/release/release.d.ts +1 -1
- package/dist/foundation/release/types.d.ts +11 -0
- package/dist/foundation/release/types.js +1 -0
- package/dist/foundation/release/update-transaction.d.ts +1 -1
- package/dist/foundation/release/update.d.ts +2 -1
- package/dist/foundation/release/update.js +3 -18
- package/dist/foundation/startup/index.d.ts +4 -2
- package/dist/foundation/startup/index.js +2 -2
- package/dist/foundation/startup/startup-descriptor.js +2 -2
- package/dist/foundation/storage/control-store.d.ts +1 -45
- package/dist/foundation/storage/control-store.js +54 -277
- package/dist/foundation/storage/index.d.ts +1 -1
- package/dist/foundation/storage/index.js +1 -1
- package/dist/foundation/supervision/index.d.ts +2 -2
- package/dist/foundation/supervision/index.js +2 -2
- package/dist/foundation/supervision/server.d.ts +5 -10
- package/dist/foundation/supervision/server.js +7 -7
- package/dist/foundation/terminal-cleanup/index.d.ts +3 -2
- package/dist/foundation/terminal-cleanup/index.js +2 -2
- package/dist/integrations/pi/components/editor-interaction.d.ts +1 -1
- package/dist/integrations/pi/components/history-editor-loader.d.ts +1 -1
- package/dist/integrations/pi/components/index.d.ts +20 -13
- package/dist/integrations/pi/components/index.js +12 -13
- package/dist/integrations/pi/components/owned-editor-ux.js +5 -8
- package/dist/integrations/pi/components/resources/builtin-themes.d.ts +7 -5
- package/dist/integrations/pi/components/resources/builtin-themes.js +7 -5
- package/dist/integrations/pi/components/shell-editor-autocomplete.js +1 -1
- package/dist/integrations/pi/components/shell-extension-ui.js +2 -1
- package/dist/integrations/pi/components/shell-footer-status.js +1 -1
- package/dist/integrations/pi/components/shell-presenters-info.d.ts +1 -1
- package/dist/integrations/pi/components/shell-presenters-info.js +1 -1
- package/dist/integrations/pi/components/shell-presenters-transcript.js +1 -1
- package/dist/integrations/pi/components/shell-selectors-dialogs.d.ts +9 -3
- package/dist/integrations/pi/components/shell-selectors-dialogs.js +9 -6
- package/dist/integrations/pi/components/shell-shared-facade.d.ts +3 -1
- package/dist/integrations/pi/components/shell-shared-facade.js +4 -2
- package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +1 -1
- package/dist/integrations/pi/components/submitted-prompt-adapter.js +1 -1
- package/dist/integrations/pi/components/tool-image-presentation.d.ts +1 -1
- package/dist/integrations/pi/components/tool-image-presentation.js +4 -7
- package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +36 -22
- package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.js +43 -7
- package/dist/integrations/pi/components/upstream/assets/earendil-image.json +2 -2
- package/dist/integrations/pi/components/upstream/components/countdown-timer.d.ts +6 -3
- package/dist/integrations/pi/components/upstream/components/daxnuts.d.ts +8 -1
- package/dist/integrations/pi/components/upstream/components/daxnuts.js +7 -3
- package/dist/integrations/pi/components/upstream/components/earendil-announcement.d.ts +1 -1
- package/dist/integrations/pi/components/upstream/components/earendil-announcement.js +10 -4
- package/dist/integrations/pi/components/upstream/components/extension-editor.d.ts +7 -4
- package/dist/integrations/pi/components/upstream/components/extension-editor.js +7 -4
- package/dist/integrations/pi/components/upstream/components/mermaid.js +8 -4
- package/dist/integrations/pi/components/upstream/components/owned-editor.d.ts +9 -5
- package/dist/integrations/pi/components/upstream/components/owned-editor.js +10 -6
- package/dist/integrations/pi/components/upstream/components/scoped-models-selector.d.ts +8 -4
- package/dist/integrations/pi/components/upstream/components/scoped-models-selector.js +27 -25
- package/dist/integrations/pi/components/upstream/components/session-footer.d.ts +1 -1
- package/dist/integrations/pi/components/upstream/components/session-footer.js +8 -10
- package/dist/integrations/pi/components/upstream/components/session-selector-search.js +6 -4
- package/dist/integrations/pi/components/upstream/components/session-selector.d.ts +1 -1
- package/dist/integrations/pi/components/upstream/components/session-selector.js +8 -4
- package/dist/integrations/pi/components/upstream/components/skill-invocation-message.d.ts +7 -5
- package/dist/integrations/pi/components/upstream/components/skill-invocation-message.js +8 -6
- package/dist/integrations/pi/components/upstream/components/status-indicator.d.ts +9 -4
- package/dist/integrations/pi/components/upstream/components/status-indicator.js +15 -5
- package/dist/integrations/pi/components/upstream/components/tool-execution.d.ts +8 -2
- package/dist/integrations/pi/components/upstream/components/tool-execution.js +58 -37
- package/dist/integrations/pi/components/upstream/components/tree-selector.d.ts +7 -4
- package/dist/integrations/pi/components/upstream/components/tree-selector.js +7 -4
- package/dist/integrations/pi/components/upstream/components/trust-selector.d.ts +1 -1
- package/dist/integrations/pi/components/upstream/components/trust-selector.js +10 -5
- package/dist/integrations/pi/components/upstream/external-editor.js +8 -4
- package/dist/integrations/pi/components/upstream/history/editor-core.d.ts +13 -4
- package/dist/integrations/pi/components/upstream/history/editor-core.js +112 -30
- package/dist/integrations/pi/components/upstream/history/kill-ring.d.ts +6 -3
- package/dist/integrations/pi/components/upstream/history/kill-ring.js +6 -3
- package/dist/integrations/pi/components/upstream/history/printable-key.js +7 -4
- package/dist/integrations/pi/components/upstream/history/text-helpers.js +6 -3
- package/dist/integrations/pi/components/upstream/history/undo-stack.d.ts +6 -3
- package/dist/integrations/pi/components/upstream/history/undo-stack.js +6 -3
- package/dist/integrations/pi/components/upstream/history/word-navigation.js +6 -3
- package/dist/integrations/pi/components/upstream/model-search.d.ts +5 -2
- package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +8 -0
- package/dist/integrations/pi/components/upstream/theme/theme-controller.js +0 -3
- package/dist/integrations/pi/components/upstream/theme/theme.d.ts +2 -2
- package/dist/integrations/pi/components/upstream/theme/theme.js +17 -6
- package/dist/integrations/pi/engine/adapter.d.ts +39 -138
- package/dist/integrations/pi/engine/adapter.js +338 -3226
- package/dist/integrations/pi/engine/command-dispatch.d.ts +41 -0
- package/dist/integrations/pi/engine/command-dispatch.js +125 -0
- package/dist/integrations/pi/engine/event-delivery.d.ts +100 -0
- package/dist/integrations/pi/engine/event-delivery.js +184 -0
- package/dist/integrations/pi/engine/extension-ui-binding.d.ts +35 -0
- package/dist/integrations/pi/engine/extension-ui-binding.js +81 -0
- package/dist/integrations/pi/engine/index.d.ts +18 -14
- package/dist/integrations/pi/engine/index.js +10 -14
- package/dist/integrations/pi/engine/message-values.d.ts +29 -0
- package/dist/integrations/pi/engine/message-values.js +168 -0
- package/dist/integrations/pi/engine/pending-delivery.d.ts +2 -2
- package/dist/integrations/pi/engine/pending-delivery.js +2 -4
- package/dist/integrations/pi/engine/pi-settings-metadata.json +382 -371
- package/dist/integrations/pi/engine/prompt-suggestions.d.ts +30 -0
- package/dist/integrations/pi/engine/prompt-suggestions.js +102 -0
- package/dist/integrations/pi/engine/provider-authentication.d.ts +34 -0
- package/dist/integrations/pi/engine/provider-authentication.js +209 -0
- package/dist/integrations/pi/engine/resource-catalog.d.ts +49 -0
- package/dist/integrations/pi/engine/resource-catalog.js +289 -0
- package/dist/integrations/pi/engine/resources/changelog.json +4 -4
- package/dist/integrations/pi/engine/session-events.d.ts +48 -0
- package/dist/integrations/pi/engine/session-events.js +223 -0
- package/dist/integrations/pi/engine/session-integration.js +2 -4
- package/dist/integrations/pi/engine/session-runtime.d.ts +84 -0
- package/dist/integrations/pi/engine/session-runtime.js +249 -0
- package/dist/integrations/pi/engine/{settings-effects.d.ts → settings-bridge.d.ts} +57 -2
- package/dist/integrations/pi/engine/settings-bridge.js +514 -0
- package/dist/integrations/pi/engine/settings-metadata.d.ts +31 -0
- package/dist/integrations/pi/engine/settings-metadata.js +67 -0
- package/dist/integrations/pi/engine/settings-port.d.ts +42 -0
- package/dist/integrations/pi/engine/settings-port.js +353 -0
- package/dist/integrations/pi/engine/transcript-projection.d.ts +39 -0
- package/dist/integrations/pi/engine/transcript-projection.js +405 -0
- package/dist/integrations/pi/engine/usage-view.d.ts +4 -0
- package/dist/integrations/pi/engine/usage-view.js +56 -0
- package/dist/integrations/pi/engine/workflow-contexts.d.ts +59 -0
- package/dist/integrations/pi/engine/workflow-contexts.js +316 -0
- package/dist/integrations/pi/engine/workflow-runner.d.ts +60 -0
- package/dist/integrations/pi/engine/workflow-runner.js +509 -0
- package/dist/integrations/pi/engine/workflow-support.d.ts +33 -0
- package/dist/integrations/pi/engine/workflow-support.js +352 -0
- package/dist/integrations/pi/engine/workflows.d.ts +63 -2
- package/dist/integrations/pi/engine/workflows.js +5 -2
- package/dist/integrations/pi/startup-public.js +576 -554
- package/dist/integrations/pi/startup-public.manifest.json +1730 -984
- package/dist/integrations/pi/tui-runtime/adapter.js +10 -13
- package/dist/integrations/pi/tui-runtime/contracts.d.ts +11 -1
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +1 -1
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +4 -7
- package/dist/integrations/pi/tui-runtime/index.d.ts +8 -6
- package/dist/integrations/pi/tui-runtime/index.js +4 -6
- package/dist/integrations/pi/tui-runtime/mouse-report-input.js +2 -4
- package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +2 -2
- package/dist/integrations/pi/tui-runtime/overlay-geometry.js +4 -5
- package/dist/integrations/pi/tui-runtime/presentation-adapter.js +1 -1
- package/dist/native/darwin-arm64/manifest.json +1 -1
- package/dist/native/linux-x64/manifest.json +1 -1
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/native/win32-x64/process-guardian.exe +0 -0
- package/dist/runtime-payload-inventory.json +51320 -46509
- package/dist/ui/apps/index.d.ts +5 -3
- package/dist/ui/apps/index.js +3 -3
- package/dist/ui/components/index.d.ts +47 -25
- package/dist/ui/components/index.js +25 -25
- package/dist/ui/components/prompt-input.js +1 -4
- package/dist/ui/settings/declarations.d.ts +119 -0
- package/dist/ui/settings/declarations.js +20 -11
- package/dist/ui/settings/index.d.ts +10 -6
- package/dist/ui/settings/index.js +5 -6
- package/dist/ui/settings/manager.d.ts +54 -0
- package/dist/ui/settings/{session.js → manager.js} +101 -9
- package/dist/ui/settings/sections.d.ts +2 -7
- package/docs/architecture/boundaries.md +4 -4
- package/docs/architecture/history-editor-provenance.md +1 -1
- package/docs/architecture/project-structure.md +6 -6
- package/docs/architecture/prompt-suggestions.md +1 -1
- package/docs/architecture/terminal-host-proof-gate.md +1 -1
- package/docs/architecture/terminal-host-spike-evidence.md +1 -1
- package/docs/architecture/toolchain.md +8 -0
- package/docs/architecture/ui-reference-provenance.md +4 -4
- package/docs/ci-release-runbook.md +7 -1
- package/docs/features/modal-content-interaction.md +2 -2
- package/docs/local-worktree-cleanup.md +4 -2
- package/docs/validation.md +6 -4
- package/package.json +7 -11
- package/bin/pi-tui.d.ts +0 -6
- package/bin/pi-tui.js +0 -28
- package/bin/sync-pi-tui-proxy.js +0 -97
- package/dist/cli/version.d.ts +0 -2
- package/dist/cli/version.js +0 -23
- package/dist/composition/agent-engine-bridge.d.ts +0 -3
- package/dist/composition/agent-engine-bridge.js +0 -108
- package/dist/composition/process.d.ts +0 -16
- package/dist/composition/process.js +0 -45
- package/dist/contracts/workspace/index.d.ts +0 -2
- package/dist/contracts/workspace/index.js +0 -2
- package/dist/contracts/workspace/model.d.ts +0 -248
- package/dist/contracts/workspace/model.js +0 -2
- package/dist/contracts/workspace/validation.d.ts +0 -13
- package/dist/contracts/workspace/validation.js +0 -335
- package/dist/features/owned-ui/customization.d.ts +0 -40
- package/dist/features/owned-ui/customization.js +0 -110
- package/dist/features/owned-ui/diagnostics.d.ts +0 -34
- package/dist/features/owned-ui/diagnostics.js +0 -95
- package/dist/features/workspace/capabilities.d.ts +0 -31
- package/dist/features/workspace/capabilities.js +0 -75
- package/dist/features/workspace/index.d.ts +0 -6
- package/dist/features/workspace/index.js +0 -6
- package/dist/features/workspace/presentation.d.ts +0 -30
- package/dist/features/workspace/presentation.js +0 -70
- package/dist/features/workspace/reconciliation.d.ts +0 -15
- package/dist/features/workspace/reconciliation.js +0 -82
- package/dist/features/workspace/reducer.d.ts +0 -43
- package/dist/features/workspace/reducer.js +0 -214
- package/dist/features/workspace/router.d.ts +0 -32
- package/dist/features/workspace/router.js +0 -125
- package/dist/features/workspace/store.d.ts +0 -18
- package/dist/features/workspace/store.js +0 -55
- package/dist/foundation/native-host-protocol/codec.d.ts +0 -13
- package/dist/foundation/native-host-protocol/codec.js +0 -58
- package/dist/foundation/native-host-protocol/evidence.d.ts +0 -67
- package/dist/foundation/native-host-protocol/evidence.js +0 -141
- package/dist/foundation/native-host-protocol/index.d.ts +0 -4
- package/dist/foundation/native-host-protocol/index.js +0 -4
- package/dist/foundation/native-host-protocol/messages.d.ts +0 -56
- package/dist/foundation/native-host-protocol/messages.js +0 -149
- package/dist/foundation/native-host-protocol/proof-gate.d.ts +0 -13
- package/dist/foundation/native-host-protocol/proof-gate.js +0 -33
- package/dist/foundation/structured-agent-runtime/backpressure.d.ts +0 -47
- package/dist/foundation/structured-agent-runtime/backpressure.js +0 -119
- package/dist/foundation/structured-agent-runtime/commands.d.ts +0 -53
- package/dist/foundation/structured-agent-runtime/commands.js +0 -165
- package/dist/foundation/structured-agent-runtime/handshake.d.ts +0 -41
- package/dist/foundation/structured-agent-runtime/handshake.js +0 -151
- package/dist/foundation/structured-agent-runtime/index.d.ts +0 -5
- package/dist/foundation/structured-agent-runtime/index.js +0 -5
- package/dist/foundation/structured-agent-runtime/reconnection.d.ts +0 -38
- package/dist/foundation/structured-agent-runtime/reconnection.js +0 -130
- package/dist/foundation/structured-agent-runtime/state.d.ts +0 -57
- package/dist/foundation/structured-agent-runtime/state.js +0 -119
- package/dist/integrations/pi/components/upstream/components/custom-entry.d.ts +0 -17
- package/dist/integrations/pi/components/upstream/components/custom-entry.js +0 -51
- package/dist/integrations/pi/components/upstream/components/first-time-setup.d.ts +0 -24
- package/dist/integrations/pi/components/upstream/components/first-time-setup.js +0 -105
- package/dist/integrations/pi/components/upstream/components/markdown-transform.d.ts +0 -2
- package/dist/integrations/pi/components/upstream/components/markdown-transform.js +0 -18
- package/dist/integrations/pi/engine/model-auth-integration.d.ts +0 -31
- package/dist/integrations/pi/engine/model-auth-integration.js +0 -62
- package/dist/integrations/pi/engine/resource-extension-integration.d.ts +0 -32
- package/dist/integrations/pi/engine/resource-extension-integration.js +0 -81
- package/dist/integrations/pi/engine/settings-effects.js +0 -249
- package/dist/integrations/pi/engine/settings-integration.d.ts +0 -43
- package/dist/integrations/pi/engine/settings-integration.js +0 -227
- package/dist/integrations/pi/engine/workflow-controllers.d.ts +0 -21
- package/dist/integrations/pi/engine/workflow-controllers.js +0 -49
- package/dist/integrations/pi/session-ui/index.d.ts +0 -5
- package/dist/integrations/pi/session-ui/index.js +0 -5
- package/dist/integrations/pi/session-ui/paste-executor.d.ts +0 -10
- package/dist/integrations/pi/session-ui/paste-preparation-client.d.ts +0 -16
- package/dist/integrations/pi/session-ui/route-host.d.ts +0 -5
- package/dist/integrations/pi/tui-runtime/conformance.d.ts +0 -18
- package/dist/integrations/pi/tui-runtime/conformance.js +0 -145
- package/dist/ui/components/prompt-row.d.ts +0 -14
- package/dist/ui/components/prompt-row.js +0 -20
- package/dist/ui/settings/session.d.ts +0 -36
- package/dist/ui/settings/store.d.ts +0 -29
- package/dist/ui/settings/store.js +0 -91
- package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-diagnostics.js +2 -2
- package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-image.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/editor-hyperlink-budget.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/editor-hyperlink-budget.js +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-source.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/image-worker.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-helper.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-text-preparation.js +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-text-worker.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/paste-text-worker.js +0 -0
- package/dist/{integrations/pi/session-ui/response-copy-helper.d.ts → app/session-shell/paste-types.js} +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/path-chip-presentation.js +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro-effects.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro-effects.js +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro.d.ts +0 -0
- package/dist/{integrations/pi/session-ui/route-host.js → app/session-shell/response-copy-helper.d.ts} +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-protocol.js +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/stream-presentation-coalescer.d.ts +0 -0
- package/dist/{integrations/pi/session-ui → app/session-shell}/stream-presentation-coalescer.js +3 -3
- /package/dist/{integrations/pi/session-ui → app/session-shell}/text-paste.d.ts +0 -0
- /package/dist/{integrations/pi/session-ui → app/session-shell}/text-paste.js +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type OwnedUiModelInfo, type OwnedUiThinkingLevel, type OwnedUiTranscriptBlock } from "../../../contracts/owned-ui/index.js";
|
|
2
|
+
import type { PiEmittedEvent } from "./event-delivery.js";
|
|
3
|
+
import type { PiTranscriptProjection } from "./transcript-projection.js";
|
|
4
|
+
export interface PiSessionEventPorts {
|
|
5
|
+
sessionGeneration(): number;
|
|
6
|
+
/** The session-authoritative messages, read at settlement. */
|
|
7
|
+
sessionMessages(): readonly unknown[];
|
|
8
|
+
activeModel(): OwnedUiModelInfo | null;
|
|
9
|
+
/** Replace the projected transcript behind the delivery seal. */
|
|
10
|
+
replaceTranscript(blocks: OwnedUiTranscriptBlock[]): void;
|
|
11
|
+
emit(value: PiEmittedEvent): void;
|
|
12
|
+
emitView(): void;
|
|
13
|
+
/** The session became busy with the named work; the adapter publishes lifecycle and status. */
|
|
14
|
+
enterWork(message: string): void;
|
|
15
|
+
/** Every work state ended; the adapter publishes the ready lifecycle and a cleared status. */
|
|
16
|
+
leaveWork(): void;
|
|
17
|
+
/** Compaction progress for the status view, in whole percent. */
|
|
18
|
+
workProgress(percent: number): void;
|
|
19
|
+
/** The engine's queued steering and follow-up submissions changed. */
|
|
20
|
+
queueChanged(queuedSubmissions: readonly string[]): void;
|
|
21
|
+
thinkingLevelChanged(level: OwnedUiThinkingLevel): void;
|
|
22
|
+
/** Usage moved at a message or lifecycle boundary; the memoized usage view is stale. */
|
|
23
|
+
usageInvalidated(): void;
|
|
24
|
+
compactionStarted(): void;
|
|
25
|
+
compactionEnded(): void;
|
|
26
|
+
deliverQueuedAfterCompaction(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Translates pinned Pi's session events into transcript projection updates, run and response
|
|
30
|
+
* sequencing, work-state transitions, and the semantic owned UI events (run started, message
|
|
31
|
+
* completed, run settled). It owns the run counters and the current work-state kind; the adapter
|
|
32
|
+
* owns the lifecycle, status, editor, and model state the ports write.
|
|
33
|
+
*/
|
|
34
|
+
export declare class PiSessionEvents {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(projection: PiTranscriptProjection, ports: PiSessionEventPorts);
|
|
37
|
+
/** Increments at each agent start within the bound session. */
|
|
38
|
+
get runSequence(): number;
|
|
39
|
+
/** Increments at each completed assistant message within the bound session. */
|
|
40
|
+
get responseSequence(): number;
|
|
41
|
+
/** A new session was bound: no run is active and the counters restart. */
|
|
42
|
+
reset(): void;
|
|
43
|
+
/** The run was abandoned by overload recovery; the counters keep their values so stale suggestions stay stale. */
|
|
44
|
+
abandonRun(): void;
|
|
45
|
+
compactionProgress(percent: number): void;
|
|
46
|
+
/** Apply one pinned Pi session event; image assets no block references any more are released afterwards. */
|
|
47
|
+
handle(event: unknown): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { isRecord, readStringArray, readThinkingLevel, stringValue, textFromContent } from "./message-values.js";
|
|
2
|
+
import { transcriptToolState } from "../../../contracts/owned-ui/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Translates pinned Pi's session events into transcript projection updates, run and response
|
|
5
|
+
* sequencing, work-state transitions, and the semantic owned UI events (run started, message
|
|
6
|
+
* completed, run settled). It owns the run counters and the current work-state kind; the adapter
|
|
7
|
+
* owns the lifecycle, status, editor, and model state the ports write.
|
|
8
|
+
*/
|
|
9
|
+
export class PiSessionEvents {
|
|
10
|
+
#projection;
|
|
11
|
+
#ports;
|
|
12
|
+
#agentRunActive = false;
|
|
13
|
+
#agentRunSequence = 0;
|
|
14
|
+
#assistantResponseSequence = 0;
|
|
15
|
+
#statusKind = null;
|
|
16
|
+
constructor(projection, ports) {
|
|
17
|
+
this.#projection = projection;
|
|
18
|
+
this.#ports = ports;
|
|
19
|
+
}
|
|
20
|
+
/** Increments at each agent start within the bound session. */
|
|
21
|
+
get runSequence() {
|
|
22
|
+
return this.#agentRunSequence;
|
|
23
|
+
}
|
|
24
|
+
/** Increments at each completed assistant message within the bound session. */
|
|
25
|
+
get responseSequence() {
|
|
26
|
+
return this.#assistantResponseSequence;
|
|
27
|
+
}
|
|
28
|
+
/** A new session was bound: no run is active and the counters restart. */
|
|
29
|
+
reset() {
|
|
30
|
+
this.#agentRunActive = false;
|
|
31
|
+
this.#agentRunSequence = 0;
|
|
32
|
+
this.#assistantResponseSequence = 0;
|
|
33
|
+
this.#statusKind = null;
|
|
34
|
+
}
|
|
35
|
+
/** The run was abandoned by overload recovery; the counters keep their values so stale suggestions stay stale. */
|
|
36
|
+
abandonRun() {
|
|
37
|
+
this.#agentRunActive = false;
|
|
38
|
+
this.#statusKind = null;
|
|
39
|
+
}
|
|
40
|
+
// Invariant: the named work state is the only state a matching end may clear.
|
|
41
|
+
#enterWorkState(kind, message) {
|
|
42
|
+
this.#statusKind = kind;
|
|
43
|
+
this.#ports.enterWork(message);
|
|
44
|
+
}
|
|
45
|
+
// Invariant: ending retry or compaction cannot clear a different active work state.
|
|
46
|
+
#endWorkState(kind) {
|
|
47
|
+
if (this.#statusKind !== kind)
|
|
48
|
+
return;
|
|
49
|
+
if (this.#agentRunActive) {
|
|
50
|
+
this.#enterWorkState("working", "Working");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.#leaveWorkStates();
|
|
54
|
+
}
|
|
55
|
+
#leaveWorkStates() {
|
|
56
|
+
this.#statusKind = null;
|
|
57
|
+
this.#ports.leaveWork();
|
|
58
|
+
}
|
|
59
|
+
// Invariant: progress belongs to the compaction state only and is published when the integer changes.
|
|
60
|
+
compactionProgress(percent) {
|
|
61
|
+
if (this.#statusKind !== "compaction")
|
|
62
|
+
return;
|
|
63
|
+
this.#ports.workProgress(percent);
|
|
64
|
+
}
|
|
65
|
+
/** Apply one pinned Pi session event; image assets no block references any more are released afterwards. */
|
|
66
|
+
handle(event) {
|
|
67
|
+
try {
|
|
68
|
+
this.#applyPiEvent(event);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
this.#projection.assets.discardUnowned();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
#applyPiEvent(event) {
|
|
75
|
+
if (!isRecord(event) || typeof event.type !== "string")
|
|
76
|
+
return;
|
|
77
|
+
// Invariant: usage moves at message and lifecycle boundaries, not with stream chunks, so the
|
|
78
|
+
// two streaming event kinds keep the memo and everything else drops it.
|
|
79
|
+
if (event.type !== "message_update" && event.type !== "tool_execution_update")
|
|
80
|
+
this.#ports.usageInvalidated();
|
|
81
|
+
switch (event.type) {
|
|
82
|
+
case "agent_start":
|
|
83
|
+
this.#agentRunActive = true;
|
|
84
|
+
this.#agentRunSequence += 1;
|
|
85
|
+
this.#ports.emit({ type: "agent-run-started" });
|
|
86
|
+
this.#enterWorkState("working", "Working");
|
|
87
|
+
return;
|
|
88
|
+
case "message_start":
|
|
89
|
+
this.#projection.upsertMessage(event.message, "live");
|
|
90
|
+
return;
|
|
91
|
+
case "message_update": {
|
|
92
|
+
const delta = isRecord(event.assistantMessageEvent) && typeof event.assistantMessageEvent.delta === "string"
|
|
93
|
+
? event.assistantMessageEvent.delta
|
|
94
|
+
: undefined;
|
|
95
|
+
// Invariant: the delta is folded in before the block is stored, so a chunk is one update to
|
|
96
|
+
// one block rather than a store without the delta followed by a store with it.
|
|
97
|
+
const blocks = this.#projection.messageBlocks(event.message, "live", this.#projection.blocks.length);
|
|
98
|
+
for (const [index, block] of blocks.entries()) {
|
|
99
|
+
this.#projection.upsert(index === 0 && delta !== undefined && !block.text.endsWith(delta)
|
|
100
|
+
? { ...block, text: `${block.text}${delta}` }
|
|
101
|
+
: block);
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
case "message_end":
|
|
106
|
+
this.#projection.upsertMessage(event.message, "finalized");
|
|
107
|
+
this.#projection.settleFailedDeclarations(event.message);
|
|
108
|
+
// Compatibility: preserve the same semantic boundary v2 counted. Transcript block
|
|
109
|
+
// finalization is intentionally not a substitute: rebuilds, retries,
|
|
110
|
+
// thinking parts, and tool rows can all finalize independently.
|
|
111
|
+
if (isRecord(event.message) && event.message.role === "assistant") {
|
|
112
|
+
this.#assistantResponseSequence += 1;
|
|
113
|
+
const content = Array.isArray(event.message.content) ? event.message.content : [];
|
|
114
|
+
const stopReason = stringValue(event.message.stopReason) ?? null;
|
|
115
|
+
const toolContinuation = stopReason === "toolUse"
|
|
116
|
+
|| content.some(item => isRecord(item) && item.type === "toolCall");
|
|
117
|
+
const successful = stringValue(event.message.errorMessage) === undefined
|
|
118
|
+
&& stopReason !== "error"
|
|
119
|
+
&& stopReason !== "aborted"
|
|
120
|
+
&& textFromContent(content).trim().length > 0;
|
|
121
|
+
this.#ports.emit({
|
|
122
|
+
type: "assistant-message-completed",
|
|
123
|
+
sessionGeneration: this.#ports.sessionGeneration(),
|
|
124
|
+
runSequence: this.#agentRunSequence,
|
|
125
|
+
responseSequence: this.#assistantResponseSequence,
|
|
126
|
+
model: this.#ports.activeModel(),
|
|
127
|
+
assistantMessageCount: this.#projection.blocks.filter(block => block.kind === "assistant").length,
|
|
128
|
+
successful,
|
|
129
|
+
stopReason,
|
|
130
|
+
toolContinuation,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
case "turn_end":
|
|
135
|
+
this.#projection.upsertMessage(event.message, "finalized");
|
|
136
|
+
if (Array.isArray(event.toolResults)) {
|
|
137
|
+
for (const result of event.toolResults)
|
|
138
|
+
this.#projection.upsertMessage(result, "finalized");
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
case "tool_execution_start":
|
|
142
|
+
case "tool_execution_end": {
|
|
143
|
+
this.#projection.upsertToolExecution(event);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
case "tool_execution_update":
|
|
147
|
+
this.#projection.upsertToolExecution(event);
|
|
148
|
+
return;
|
|
149
|
+
case "agent_settled":
|
|
150
|
+
case "agent_end": {
|
|
151
|
+
if (event.type === "agent_end" && event.willRetry === true)
|
|
152
|
+
return;
|
|
153
|
+
// Protocol: agent_end is run-local; only settlement reads the complete session scope.
|
|
154
|
+
const finalMessages = event.type === "agent_settled"
|
|
155
|
+
? this.#ports.sessionMessages()
|
|
156
|
+
: Array.isArray(event.messages) ? event.messages : [];
|
|
157
|
+
if (event.type === "agent_end")
|
|
158
|
+
this.#projection.mergeRun(finalMessages, this.#ports.sessionMessages());
|
|
159
|
+
else if (finalMessages.length > 0)
|
|
160
|
+
this.#ports.replaceTranscript(this.#projection.rebuild(finalMessages, "finalized"));
|
|
161
|
+
// Invariant: missing final messages must not erase accumulated content or invent tool outcomes.
|
|
162
|
+
if (finalMessages.length === 0)
|
|
163
|
+
this.#ports.replaceTranscript(this.#projection.blocks.map(block => block.status === "live" && transcriptToolState(block) === undefined
|
|
164
|
+
? { ...block, status: "finalized", revision: block.revision + 1 } : block));
|
|
165
|
+
// Compatibility: ending a turn leaves the working state, as the recorded pinned baseline does, but
|
|
166
|
+
// it leaves only that state: a compaction or retry being shown outlives the turn
|
|
167
|
+
// that ended under it. Settlement ends the run, and with it every state — the
|
|
168
|
+
// engine ends a turn for each continuation it makes and settles once.
|
|
169
|
+
if (event.type === "agent_settled") {
|
|
170
|
+
this.#agentRunActive = false;
|
|
171
|
+
this.#leaveWorkStates();
|
|
172
|
+
}
|
|
173
|
+
else if (this.#statusKind === null || this.#statusKind === "working") {
|
|
174
|
+
this.#leaveWorkStates();
|
|
175
|
+
}
|
|
176
|
+
this.#ports.emitView();
|
|
177
|
+
if (event.type === "agent_settled") {
|
|
178
|
+
const assistants = finalMessages.filter(message => isRecord(message) && message.role === "assistant");
|
|
179
|
+
const lastAssistant = assistants.at(-1);
|
|
180
|
+
const successful = lastAssistant !== undefined
|
|
181
|
+
&& stringValue(lastAssistant.errorMessage) === undefined
|
|
182
|
+
&& stringValue(lastAssistant.stopReason) !== "error"
|
|
183
|
+
&& stringValue(lastAssistant.stopReason) !== "aborted";
|
|
184
|
+
this.#ports.emit({
|
|
185
|
+
type: "agent-run-settled",
|
|
186
|
+
sessionGeneration: this.#ports.sessionGeneration(),
|
|
187
|
+
runSequence: this.#agentRunSequence,
|
|
188
|
+
responseSequence: this.#assistantResponseSequence,
|
|
189
|
+
model: this.#ports.activeModel(),
|
|
190
|
+
assistantMessageCount: assistants.length,
|
|
191
|
+
successful,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
case "queue_update": {
|
|
197
|
+
this.#ports.queueChanged([...readStringArray(event.steering), ...readStringArray(event.followUp)]);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
case "auto_retry_start":
|
|
201
|
+
this.#enterWorkState("retry", "Retrying");
|
|
202
|
+
return;
|
|
203
|
+
case "auto_retry_end":
|
|
204
|
+
this.#endWorkState("retry");
|
|
205
|
+
return;
|
|
206
|
+
case "compaction_start":
|
|
207
|
+
this.#enterWorkState("compaction", "Compacting");
|
|
208
|
+
this.#ports.compactionStarted();
|
|
209
|
+
return;
|
|
210
|
+
case "compaction_end":
|
|
211
|
+
this.#ports.compactionEnded();
|
|
212
|
+
this.#endWorkState("compaction");
|
|
213
|
+
if (event.reason === "manual")
|
|
214
|
+
this.#ports.deliverQueuedAfterCompaction();
|
|
215
|
+
return;
|
|
216
|
+
case "thinking_level_changed":
|
|
217
|
+
this.#ports.thinkingLevelChanged(readThinkingLevel(event.level));
|
|
218
|
+
return;
|
|
219
|
+
default:
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { AGENT_ENGINE_CONTRACT_VERSION, } from "../../../contracts/agent-engine/index.js";
|
|
2
2
|
/** Routes neutral session commands to Pi while preserving Pi streaming and retry semantics. */
|
|
3
3
|
export class PiSessionCommandIntegration {
|
|
4
|
-
session;
|
|
5
4
|
#lastPrompt = null;
|
|
6
5
|
// Rationale: Pi's queue restore returns text only, so the attachments of messages queued
|
|
7
6
|
// during compaction are kept here until the queue is delivered or cleared.
|
|
8
7
|
#queuedImages = [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
session;
|
|
9
|
+
constructor(session) { this.session = session; }
|
|
12
10
|
async execute(command) {
|
|
13
11
|
switch (command.type) {
|
|
14
12
|
case "prompt":
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PiSessionCommandIntegration } from "./session-integration.js";
|
|
2
|
+
import { type AgentSession, type AgentSessionRuntime, type AgentSessionServices } from "../startup-public.js";
|
|
3
|
+
import type { PiProjectTrustPreflightPrompt } from "./project-trust-preflight.js";
|
|
4
|
+
import type { PiSessionForkPrompt, PiSessionSelection } from "./session-selection.js";
|
|
5
|
+
import type { OwnedUiDiagnostics } from "../../../contracts/owned-ui/index.js";
|
|
6
|
+
import type { PiSessionResumeMetadata, PiWorkflowHost } from "./workflows.js";
|
|
7
|
+
export interface PiEngineRuntimeFactoryInput {
|
|
8
|
+
readonly cwd: string;
|
|
9
|
+
readonly agentDir: string;
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
readonly sessionPath?: string;
|
|
12
|
+
readonly sessionSelection?: PiSessionSelection;
|
|
13
|
+
readonly sessionForkPrompt?: PiSessionForkPrompt;
|
|
14
|
+
readonly projectTrustPrompt?: PiProjectTrustPreflightPrompt;
|
|
15
|
+
}
|
|
16
|
+
export type PiEngineRuntimeFactory = (input: PiEngineRuntimeFactoryInput) => Promise<AgentSessionRuntime>;
|
|
17
|
+
export type PiEnginePackageUpdateProbe = (settingsManager: AgentSessionServices["settingsManager"]) => Promise<readonly string[]>;
|
|
18
|
+
export interface PiEngineRuntimeOptions {
|
|
19
|
+
readonly cwd: string;
|
|
20
|
+
readonly agentDir: string;
|
|
21
|
+
readonly sessionId: string;
|
|
22
|
+
readonly sessionPath: string | undefined;
|
|
23
|
+
readonly sessionSelection: PiSessionSelection | undefined;
|
|
24
|
+
readonly sessionForkPrompt: PiSessionForkPrompt | undefined;
|
|
25
|
+
readonly projectTrustPrompt: PiProjectTrustPreflightPrompt | undefined;
|
|
26
|
+
readonly createRuntime: PiEngineRuntimeFactory | undefined;
|
|
27
|
+
readonly checkPackageUpdates: PiEnginePackageUpdateProbe | undefined;
|
|
28
|
+
readonly host: PiWorkflowHost;
|
|
29
|
+
}
|
|
30
|
+
export interface PiEngineRuntimePorts {
|
|
31
|
+
disposed(): boolean;
|
|
32
|
+
/** The runtime exists and its cwd and git branch are known; nothing is bound yet. */
|
|
33
|
+
started(runtime: AgentSessionRuntime): void;
|
|
34
|
+
/** True while a runtime-initiated rebind must be ignored: delivery overload, stopped admission, or disposal. */
|
|
35
|
+
rebindBlocked(): boolean;
|
|
36
|
+
/** The current session is about to be replaced; admitted work that belongs to it is cancelled here. */
|
|
37
|
+
sessionReplacing(): void;
|
|
38
|
+
/** A session was bound and subscribed under a new generation; the adapter rebuilds the state it derives from one. */
|
|
39
|
+
sessionReplaced(session: AgentSession): void;
|
|
40
|
+
/** A runtime-initiated rebind completed; the adapter publishes the rebuilt view. */
|
|
41
|
+
rebound(): void;
|
|
42
|
+
/** A pinned Pi session event for the current generation. */
|
|
43
|
+
event(event: unknown): void;
|
|
44
|
+
compactionProgress(percent: number): void;
|
|
45
|
+
diagnostic(severity: OwnedUiDiagnostics["severity"], code: string, message: string, recoverable: boolean): void;
|
|
46
|
+
emitView(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The pinned Pi runtime and the session bound to it: creation through the runtime factory, the
|
|
50
|
+
* session generation that stamps and invalidates events, the subscription that forwards session
|
|
51
|
+
* events, compaction progress observation, the queued-input integration, and disposal order. The
|
|
52
|
+
* adapter derives its view state from the session it is handed and never touches these directly.
|
|
53
|
+
*/
|
|
54
|
+
export declare class PiEngineRuntime {
|
|
55
|
+
#private;
|
|
56
|
+
constructor(options: PiEngineRuntimeOptions, ports: PiEngineRuntimePorts);
|
|
57
|
+
get runtime(): AgentSessionRuntime | undefined;
|
|
58
|
+
get session(): AgentSession | undefined;
|
|
59
|
+
/** Bumped on every bind and on overload recovery; events from an earlier generation are invalid. */
|
|
60
|
+
get generation(): number;
|
|
61
|
+
/** Actual session replacements, excluding delivery-only invalidation of callbacks. */
|
|
62
|
+
get bindingGeneration(): number;
|
|
63
|
+
get cwd(): string;
|
|
64
|
+
get gitBranch(): string | null;
|
|
65
|
+
get sessionCommands(): PiSessionCommandIntegration | undefined;
|
|
66
|
+
get started(): boolean;
|
|
67
|
+
/** Create the runtime, bind its first session, and announce the changelog; startup failures propagate. */
|
|
68
|
+
start(): Promise<AgentSessionRuntime>;
|
|
69
|
+
/** Probe extension packages for updates after startup and report them as an informational diagnostic. */
|
|
70
|
+
announcePackageUpdates(): Promise<void>;
|
|
71
|
+
currentSessionFile(): string | null;
|
|
72
|
+
currentSessionResumeMetadata(): PiSessionResumeMetadata | null;
|
|
73
|
+
/** Replace the bound session under a new generation and subscribe to its events. */
|
|
74
|
+
bindSession(session: AgentSession): void;
|
|
75
|
+
/** Stop forwarding the current session's events and open a new generation; overload recovery resumes or abandons it. */
|
|
76
|
+
suspend(): void;
|
|
77
|
+
/** Forward the current session's events again under the current generation. */
|
|
78
|
+
resume(): void;
|
|
79
|
+
compactionStarted(): void;
|
|
80
|
+
compactionEnded(): void;
|
|
81
|
+
deliverQueuedAfterCompaction(): void;
|
|
82
|
+
/** Unsubscribe, stop observing compaction, and dispose the runtime; the session reference is kept for final reads. */
|
|
83
|
+
dispose(): Promise<void>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { PRODUCT_IDENTITY } from "../../../product-identity.js";
|
|
5
|
+
import { observeCompactionProgress } from "./compaction-progress.js";
|
|
6
|
+
import { createPiRuntimeIntegration } from "./runtime-integration.js";
|
|
7
|
+
import { PiSessionCommandIntegration } from "./session-integration.js";
|
|
8
|
+
import { DefaultPackageManager, VERSION } from "../startup-public.js";
|
|
9
|
+
const execFileAsync = promisify(execFile);
|
|
10
|
+
/**
|
|
11
|
+
* The pinned Pi runtime and the session bound to it: creation through the runtime factory, the
|
|
12
|
+
* session generation that stamps and invalidates events, the subscription that forwards session
|
|
13
|
+
* events, compaction progress observation, the queued-input integration, and disposal order. The
|
|
14
|
+
* adapter derives its view state from the session it is handed and never touches these directly.
|
|
15
|
+
*/
|
|
16
|
+
export class PiEngineRuntime {
|
|
17
|
+
#options;
|
|
18
|
+
#ports;
|
|
19
|
+
#runtimeFactory;
|
|
20
|
+
#checkPackageUpdates;
|
|
21
|
+
#cwd;
|
|
22
|
+
#runtime;
|
|
23
|
+
#session;
|
|
24
|
+
#unsubscribe;
|
|
25
|
+
#sessionGeneration = 0;
|
|
26
|
+
#sessionBindingGeneration = 0;
|
|
27
|
+
#sessionCommands;
|
|
28
|
+
#compactionProgress = null;
|
|
29
|
+
#gitBranch = null;
|
|
30
|
+
constructor(options, ports) {
|
|
31
|
+
this.#options = options;
|
|
32
|
+
this.#ports = ports;
|
|
33
|
+
this.#cwd = options.cwd;
|
|
34
|
+
this.#runtimeFactory = options.createRuntime ?? createDefaultPiRuntime;
|
|
35
|
+
this.#checkPackageUpdates = options.checkPackageUpdates
|
|
36
|
+
?? (options.createRuntime
|
|
37
|
+
? async () => []
|
|
38
|
+
: settingsManager => checkDefaultPiPackageUpdates(this.#cwd, options.agentDir, settingsManager));
|
|
39
|
+
}
|
|
40
|
+
get runtime() {
|
|
41
|
+
return this.#runtime;
|
|
42
|
+
}
|
|
43
|
+
get session() {
|
|
44
|
+
return this.#session;
|
|
45
|
+
}
|
|
46
|
+
/** Bumped on every bind and on overload recovery; events from an earlier generation are invalid. */
|
|
47
|
+
get generation() {
|
|
48
|
+
return this.#sessionGeneration;
|
|
49
|
+
}
|
|
50
|
+
/** Actual session replacements, excluding delivery-only invalidation of callbacks. */
|
|
51
|
+
get bindingGeneration() {
|
|
52
|
+
return this.#sessionBindingGeneration;
|
|
53
|
+
}
|
|
54
|
+
get cwd() {
|
|
55
|
+
return this.#runtime?.cwd ?? this.#cwd;
|
|
56
|
+
}
|
|
57
|
+
get gitBranch() {
|
|
58
|
+
return this.#gitBranch;
|
|
59
|
+
}
|
|
60
|
+
get sessionCommands() {
|
|
61
|
+
return this.#sessionCommands;
|
|
62
|
+
}
|
|
63
|
+
get started() {
|
|
64
|
+
return this.#runtime !== undefined;
|
|
65
|
+
}
|
|
66
|
+
/** Create the runtime, bind its first session, and announce the changelog; startup failures propagate. */
|
|
67
|
+
async start() {
|
|
68
|
+
const runtime = await this.#runtimeFactory({
|
|
69
|
+
cwd: this.#cwd,
|
|
70
|
+
agentDir: this.#options.agentDir,
|
|
71
|
+
sessionId: this.#options.sessionId,
|
|
72
|
+
...(this.#options.sessionPath === undefined ? {} : { sessionPath: this.#options.sessionPath }),
|
|
73
|
+
...(this.#options.sessionSelection === undefined ? {} : { sessionSelection: this.#options.sessionSelection }),
|
|
74
|
+
...(this.#options.sessionForkPrompt === undefined ? {} : { sessionForkPrompt: this.#options.sessionForkPrompt }),
|
|
75
|
+
...(this.#options.projectTrustPrompt === undefined ? {} : { projectTrustPrompt: this.#options.projectTrustPrompt }),
|
|
76
|
+
});
|
|
77
|
+
this.#runtime = runtime;
|
|
78
|
+
this.#cwd = runtime.cwd ?? this.#cwd;
|
|
79
|
+
this.#gitBranch = await readGitBranch(this.#cwd);
|
|
80
|
+
this.#ports.started(runtime);
|
|
81
|
+
runtime.setRebindSession(async (session) => {
|
|
82
|
+
if (this.#ports.rebindBlocked())
|
|
83
|
+
return;
|
|
84
|
+
this.bindSession(session);
|
|
85
|
+
this.#ports.rebound();
|
|
86
|
+
});
|
|
87
|
+
for (const diagnostic of [...runtime.diagnostics, ...runtime.services.diagnostics]) {
|
|
88
|
+
this.#ports.diagnostic(diagnostic.type === "error" ? "error" : diagnostic.type === "warning" ? "warning" : "info", "engine-startup", diagnostic.message, diagnostic.type !== "error");
|
|
89
|
+
}
|
|
90
|
+
this.bindSession(runtime.session);
|
|
91
|
+
await this.#announceChangelog(runtime.services.settingsManager);
|
|
92
|
+
return runtime;
|
|
93
|
+
}
|
|
94
|
+
/** Probe extension packages for updates after startup and report them as an informational diagnostic. */
|
|
95
|
+
async announcePackageUpdates() {
|
|
96
|
+
const runtime = this.#runtime;
|
|
97
|
+
if (process.env.PI_OFFLINE || runtime === undefined)
|
|
98
|
+
return;
|
|
99
|
+
let updates;
|
|
100
|
+
try {
|
|
101
|
+
updates = await this.#checkPackageUpdates(runtime.services.settingsManager);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this.#ports.disposed() || updates.length === 0)
|
|
107
|
+
return;
|
|
108
|
+
const packages = updates.map(name => `- ${name}`).join("\n");
|
|
109
|
+
this.#ports.diagnostic("info", "package-updates", `Package updates are available. Run ${PRODUCT_IDENTITY.commandName} pi update --extensions\nPackages:\n${packages}`, true);
|
|
110
|
+
this.#ports.emitView();
|
|
111
|
+
}
|
|
112
|
+
currentSessionFile() {
|
|
113
|
+
const value = this.#session?.sessionManager?.getSessionFile?.();
|
|
114
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
115
|
+
}
|
|
116
|
+
currentSessionResumeMetadata() {
|
|
117
|
+
const manager = this.#session?.sessionManager;
|
|
118
|
+
if (manager === undefined
|
|
119
|
+
|| typeof manager.isPersisted !== "function"
|
|
120
|
+
|| typeof manager.getSessionId !== "function"
|
|
121
|
+
|| typeof manager.getSessionDir !== "function"
|
|
122
|
+
|| typeof manager.usesDefaultSessionDir !== "function"
|
|
123
|
+
|| manager.isPersisted() !== true
|
|
124
|
+
|| !existsSync(this.currentSessionFile() ?? ""))
|
|
125
|
+
return null;
|
|
126
|
+
const sessionId = manager.getSessionId();
|
|
127
|
+
const sessionDir = manager.getSessionDir();
|
|
128
|
+
if (!sessionId || !sessionDir)
|
|
129
|
+
return null;
|
|
130
|
+
return { sessionId, sessionDir, usesDefaultSessionDir: manager.usesDefaultSessionDir() };
|
|
131
|
+
}
|
|
132
|
+
/** Replace the bound session under a new generation and subscribe to its events. */
|
|
133
|
+
bindSession(session) {
|
|
134
|
+
this.#unsubscribe?.();
|
|
135
|
+
this.#ports.sessionReplacing();
|
|
136
|
+
this.#sessionGeneration += 1;
|
|
137
|
+
this.#sessionBindingGeneration += 1;
|
|
138
|
+
this.#session = session;
|
|
139
|
+
this.#sessionCommands = new PiSessionCommandIntegration(session);
|
|
140
|
+
this.#compactionProgress?.dispose();
|
|
141
|
+
this.#compactionProgress = observeCompactionProgress(session, percent => {
|
|
142
|
+
if (this.#session === session && !this.#ports.disposed())
|
|
143
|
+
this.#ports.compactionProgress(percent);
|
|
144
|
+
});
|
|
145
|
+
// Invariant: the subscription is live before the adapter rebuilds its state so the extension
|
|
146
|
+
// rebind that finishes the rebuild cannot emit an event nobody is listening to.
|
|
147
|
+
this.#subscribe();
|
|
148
|
+
this.#ports.sessionReplaced(session);
|
|
149
|
+
}
|
|
150
|
+
/** Stop forwarding the current session's events and open a new generation; overload recovery resumes or abandons it. */
|
|
151
|
+
suspend() {
|
|
152
|
+
this.#unsubscribe?.();
|
|
153
|
+
this.#unsubscribe = undefined;
|
|
154
|
+
this.#compactionProgress?.dispose();
|
|
155
|
+
this.#compactionProgress = null;
|
|
156
|
+
++this.#sessionGeneration;
|
|
157
|
+
}
|
|
158
|
+
/** Forward the current session's events again under the current generation. */
|
|
159
|
+
resume() {
|
|
160
|
+
if (this.#session === undefined)
|
|
161
|
+
return;
|
|
162
|
+
this.#subscribe();
|
|
163
|
+
}
|
|
164
|
+
compactionStarted() {
|
|
165
|
+
this.#compactionProgress?.begin();
|
|
166
|
+
}
|
|
167
|
+
compactionEnded() {
|
|
168
|
+
this.#compactionProgress?.end();
|
|
169
|
+
}
|
|
170
|
+
// Rationale: a manual compaction ends with an idle session, so the engine would never consume
|
|
171
|
+
// the messages queued during it; automatic compaction returns to a run or a pending prompt.
|
|
172
|
+
deliverQueuedAfterCompaction() {
|
|
173
|
+
const commands = this.#sessionCommands;
|
|
174
|
+
const generation = this.#sessionGeneration;
|
|
175
|
+
if (commands === undefined)
|
|
176
|
+
return;
|
|
177
|
+
const report = (error) => {
|
|
178
|
+
if (generation !== this.#sessionGeneration || this.#ports.disposed())
|
|
179
|
+
return;
|
|
180
|
+
this.#ports.diagnostic("error", "engine-command", `Queued input could not be sent after compaction: ${error instanceof Error ? error.message : String(error)}`, true);
|
|
181
|
+
this.#ports.emitView();
|
|
182
|
+
};
|
|
183
|
+
commands.deliverQueuedAfterCompaction(report).catch(report);
|
|
184
|
+
}
|
|
185
|
+
/** Unsubscribe, stop observing compaction, and dispose the runtime; the session reference is kept for final reads. */
|
|
186
|
+
async dispose() {
|
|
187
|
+
this.#unsubscribe?.();
|
|
188
|
+
this.#unsubscribe = undefined;
|
|
189
|
+
this.#compactionProgress?.dispose();
|
|
190
|
+
this.#compactionProgress = null;
|
|
191
|
+
await this.#runtime?.dispose();
|
|
192
|
+
}
|
|
193
|
+
#subscribe() {
|
|
194
|
+
const session = this.#session;
|
|
195
|
+
if (session === undefined)
|
|
196
|
+
return;
|
|
197
|
+
const generation = this.#sessionGeneration;
|
|
198
|
+
this.#unsubscribe = session.subscribe(event => {
|
|
199
|
+
if (generation === this.#sessionGeneration && !this.#ports.disposed())
|
|
200
|
+
this.#ports.event(event);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async #announceChangelog(settingsManager) {
|
|
204
|
+
if (!settingsManager || typeof settingsManager.getLastChangelogVersion !== "function"
|
|
205
|
+
|| typeof settingsManager.setLastChangelogVersion !== "function")
|
|
206
|
+
return;
|
|
207
|
+
if ((this.#session?.messages.length ?? 0) > 0)
|
|
208
|
+
return;
|
|
209
|
+
const lastVersion = settingsManager.getLastChangelogVersion();
|
|
210
|
+
if (lastVersion === VERSION)
|
|
211
|
+
return;
|
|
212
|
+
if (!lastVersion) {
|
|
213
|
+
settingsManager.setLastChangelogVersion(VERSION);
|
|
214
|
+
await settingsManager.flush();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const markdown = await this.#options.host.readChangelog(lastVersion).catch(() => "");
|
|
218
|
+
if (markdown.trim().length > 0) {
|
|
219
|
+
this.#ports.diagnostic("info", settingsManager.getCollapseChangelog() ? "changelog-collapsed" : "changelog-expanded", markdown, true);
|
|
220
|
+
settingsManager.setLastChangelogVersion(VERSION);
|
|
221
|
+
await settingsManager.flush();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function createDefaultPiRuntime(input) {
|
|
226
|
+
return createPiRuntimeIntegration({
|
|
227
|
+
cwd: input.cwd,
|
|
228
|
+
agentDir: input.agentDir,
|
|
229
|
+
...(input.sessionPath === undefined ? {} : { sessionPath: input.sessionPath }),
|
|
230
|
+
...(input.sessionSelection === undefined ? {} : { sessionSelection: input.sessionSelection }),
|
|
231
|
+
...(input.sessionForkPrompt === undefined ? {} : { sessionForkPrompt: input.sessionForkPrompt }),
|
|
232
|
+
...(input.projectTrustPrompt === undefined ? {} : { projectTrustPrompt: input.projectTrustPrompt }),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
async function checkDefaultPiPackageUpdates(cwd, agentDir, settingsManager) {
|
|
236
|
+
const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
|
|
237
|
+
const updates = await packageManager.checkForAvailableUpdates();
|
|
238
|
+
return updates.map(update => update.displayName);
|
|
239
|
+
}
|
|
240
|
+
async function readGitBranch(cwd) {
|
|
241
|
+
try {
|
|
242
|
+
const { stdout } = await execFileAsync("git", ["branch", "--show-current"], { cwd, windowsHide: true });
|
|
243
|
+
const branch = stdout.trim();
|
|
244
|
+
return branch.length > 0 ? branch : null;
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|