@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,30 @@
|
|
|
1
|
+
import type { AgentSession, AgentSessionRuntime } from "../startup-public.js";
|
|
2
|
+
import { type OwnedUiModelInfo, type OwnedUiPromptSuggestionGeneratorPort, type OwnedUiPromptSuggestionReasoning, type OwnedUiPromptSuggestionRequest, type OwnedUiPromptSuggestionResult } from "../../../contracts/owned-ui/index.js";
|
|
3
|
+
/** The run position a suggestion request must still match to be answered. */
|
|
4
|
+
export interface PiPromptSuggestionIdentity {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly sessionGeneration: number;
|
|
7
|
+
readonly runSequence: number;
|
|
8
|
+
readonly responseSequence: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PiPromptSuggestionPorts {
|
|
11
|
+
session(): AgentSession | undefined;
|
|
12
|
+
runtime(): AgentSessionRuntime | undefined;
|
|
13
|
+
activeModel(): OwnedUiModelInfo | null;
|
|
14
|
+
/** The adapter's current position; a request for an earlier position is answered "unavailable". */
|
|
15
|
+
identity(): PiPromptSuggestionIdentity;
|
|
16
|
+
/** True while the adapter cannot serve: disposed, overloaded, or admission stopped. */
|
|
17
|
+
unavailable(): boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Contextual prompt suggestions generated against the bound session's own conversation prefix
|
|
21
|
+
* through pinned Pi's model runtime, so the provider serves the suggestion from the run's prompt
|
|
22
|
+
* cache. The adapter supplies the session, runtime, model, and run position through ports and
|
|
23
|
+
* remains the port the owned UI calls.
|
|
24
|
+
*/
|
|
25
|
+
export declare class PiPromptSuggestions implements OwnedUiPromptSuggestionGeneratorPort {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(ports: PiPromptSuggestionPorts);
|
|
28
|
+
reasoningPolicy(): OwnedUiPromptSuggestionReasoning;
|
|
29
|
+
generate(request: OwnedUiPromptSuggestionRequest): Promise<OwnedUiPromptSuggestionResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { isRecord, stringValue } from "./message-values.js";
|
|
2
|
+
import { CONTEXTUAL_PROMPT_SUGGESTION_INSTRUCTION, assertOwnedUiPromptSuggestionRequest, assertOwnedUiPromptSuggestionResult, normalizePromptSuggestionCandidate, } from "../../../contracts/owned-ui/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Contextual prompt suggestions generated against the bound session's own conversation prefix
|
|
5
|
+
* through pinned Pi's model runtime, so the provider serves the suggestion from the run's prompt
|
|
6
|
+
* cache. The adapter supplies the session, runtime, model, and run position through ports and
|
|
7
|
+
* remains the port the owned UI calls.
|
|
8
|
+
*/
|
|
9
|
+
export class PiPromptSuggestions {
|
|
10
|
+
#ports;
|
|
11
|
+
constructor(ports) {
|
|
12
|
+
this.#ports = ports;
|
|
13
|
+
}
|
|
14
|
+
reasoningPolicy() {
|
|
15
|
+
const session = this.#ports.session();
|
|
16
|
+
if (!session?.model)
|
|
17
|
+
return "unavailable";
|
|
18
|
+
if (!session.model.reasoning)
|
|
19
|
+
return "ordinary";
|
|
20
|
+
// Performance: the run's own level keeps the provider's thinking parameters, and the cached prefix, identical.
|
|
21
|
+
return readSuggestionReasoning(session.thinkingLevel);
|
|
22
|
+
}
|
|
23
|
+
async generate(request) {
|
|
24
|
+
assertOwnedUiPromptSuggestionRequest(request);
|
|
25
|
+
const identity = request.identity;
|
|
26
|
+
const session = this.#ports.session();
|
|
27
|
+
const runtime = this.#ports.runtime();
|
|
28
|
+
const activeModel = this.#ports.activeModel();
|
|
29
|
+
const current = this.#ports.identity();
|
|
30
|
+
if (this.#ports.unavailable() || session === undefined || runtime === undefined || request.signal.aborted
|
|
31
|
+
|| identity.sessionId !== current.sessionId
|
|
32
|
+
|| identity.sessionGeneration !== current.sessionGeneration
|
|
33
|
+
|| identity.runSequence !== current.runSequence
|
|
34
|
+
|| identity.responseSequence !== current.responseSequence
|
|
35
|
+
|| activeModel === null
|
|
36
|
+
|| identity.model.providerId !== activeModel.providerId
|
|
37
|
+
|| identity.model.modelId !== activeModel.modelId) {
|
|
38
|
+
return { identity, outcome: request.signal.aborted ? "cancelled" : "unavailable", text: null };
|
|
39
|
+
}
|
|
40
|
+
const model = session.model;
|
|
41
|
+
const agent = session.agent;
|
|
42
|
+
const agentState = agent.state;
|
|
43
|
+
const policy = this.reasoningPolicy();
|
|
44
|
+
if (model === undefined || policy === "unavailable" || typeof runtime.services.modelRuntime.completeSimple !== "function") {
|
|
45
|
+
return { identity, outcome: "unavailable", text: null };
|
|
46
|
+
}
|
|
47
|
+
// Performance: mirror the primary loop's request shape so the provider serves the conversation prefix
|
|
48
|
+
// from the run's prompt cache. `onResponse` stays out: extensions must not see a suggestion as a response.
|
|
49
|
+
const reasoning = policy === "ordinary" || policy === "off" ? undefined : policy;
|
|
50
|
+
let response;
|
|
51
|
+
try {
|
|
52
|
+
const transformed = typeof agent.transformContext === "function"
|
|
53
|
+
? await agent.transformContext(agentState.messages, request.signal)
|
|
54
|
+
: agentState.messages;
|
|
55
|
+
const messages = typeof agent.convertToLlm === "function"
|
|
56
|
+
? await agent.convertToLlm(transformed)
|
|
57
|
+
: transformed.filter(message => message.role === "user" || message.role === "assistant" || message.role === "toolResult");
|
|
58
|
+
response = await runtime.services.modelRuntime.completeSimple(model, {
|
|
59
|
+
systemPrompt: agentState.systemPrompt,
|
|
60
|
+
messages: [
|
|
61
|
+
...messages,
|
|
62
|
+
{ role: "user", content: CONTEXTUAL_PROMPT_SUGGESTION_INSTRUCTION, timestamp: Date.now() },
|
|
63
|
+
],
|
|
64
|
+
tools: agentState.tools,
|
|
65
|
+
}, {
|
|
66
|
+
signal: request.signal,
|
|
67
|
+
...(reasoning === undefined ? {} : { reasoning }),
|
|
68
|
+
...(agent.sessionId === undefined ? {} : { sessionId: agent.sessionId }),
|
|
69
|
+
...(agent.thinkingBudgets === undefined ? {} : { thinkingBudgets: agent.thinkingBudgets }),
|
|
70
|
+
...(agent.transport === undefined ? {} : { transport: agent.transport }),
|
|
71
|
+
...(agent.onPayload === undefined ? {} : { onPayload: agent.onPayload }),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return { identity, outcome: request.signal.aborted ? "cancelled" : "provider-failure", text: null };
|
|
76
|
+
}
|
|
77
|
+
if (request.signal.aborted || (isRecord(response) && response.stopReason === "aborted")) {
|
|
78
|
+
return { identity, outcome: "cancelled", text: null };
|
|
79
|
+
}
|
|
80
|
+
if (!isRecord(response) || stringValue(response.errorMessage) !== undefined || response.stopReason === "error") {
|
|
81
|
+
return { identity, outcome: "provider-failure", text: null };
|
|
82
|
+
}
|
|
83
|
+
const content = Array.isArray(response.content) ? response.content : [];
|
|
84
|
+
if (response.stopReason === "length" || content.some(block => isRecord(block) && block.type === "toolCall")) {
|
|
85
|
+
return { identity, outcome: "rejected", text: null };
|
|
86
|
+
}
|
|
87
|
+
// Security: validate all text, not just the first block of a multi-part response.
|
|
88
|
+
const rawText = content.filter(block => isRecord(block) && block.type === "text")
|
|
89
|
+
.map(block => stringValue(block.text) ?? "").join("\n");
|
|
90
|
+
const text = normalizePromptSuggestionCandidate(rawText);
|
|
91
|
+
const result = text === null
|
|
92
|
+
? { identity, outcome: rawText.trim() ? "rejected" : "empty", text: null }
|
|
93
|
+
: { identity, outcome: "candidate", text };
|
|
94
|
+
assertOwnedUiPromptSuggestionResult(result);
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function readSuggestionReasoning(value) {
|
|
99
|
+
return value === "minimal" || value === "low" || value === "medium" || value === "high" || value === "xhigh" || value === "max"
|
|
100
|
+
? value
|
|
101
|
+
: "off";
|
|
102
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type AgentSession, type AgentSessionRuntime } from "../startup-public.js";
|
|
2
|
+
import type { PiWorkflowContexts } from "./workflow-contexts.js";
|
|
3
|
+
import type { OwnedUiModelInfo } from "../../../contracts/owned-ui/index.js";
|
|
4
|
+
import type { PiWorkflowInteractionHost, PiWorkflowRequest, PiWorkflowResult } from "./workflows.js";
|
|
5
|
+
type PiSessionApi = AgentSession;
|
|
6
|
+
type PiRuntimeApi = AgentSessionRuntime;
|
|
7
|
+
export interface PiProviderAuthenticationPorts {
|
|
8
|
+
runtime(): PiRuntimeApi | undefined;
|
|
9
|
+
requireSession(): PiSessionApi;
|
|
10
|
+
disposed(): boolean;
|
|
11
|
+
sessionGeneration(): number;
|
|
12
|
+
interaction(): PiWorkflowInteractionHost;
|
|
13
|
+
setActiveModel(model: OwnedUiModelInfo): void;
|
|
14
|
+
reconcileActiveModelAvailability(): void;
|
|
15
|
+
emitView(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pinned Pi's provider login and logout: resolving a provider reference to an authentication
|
|
19
|
+
* method, driving the model runtime's login through the owned interaction host, selecting the
|
|
20
|
+
* provider's pinned default model when the session had none, and the deferred catalog refresh
|
|
21
|
+
* whose notices follow the saved-credential status. Wording follows pinned Pi exactly.
|
|
22
|
+
*/
|
|
23
|
+
export declare class PiProviderAuthentication {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(options: {
|
|
26
|
+
readonly agentDir: string;
|
|
27
|
+
readonly contexts: PiWorkflowContexts;
|
|
28
|
+
}, ports: PiProviderAuthenticationPorts);
|
|
29
|
+
/** Run pinned Pi's `/login` for a provider reference or an explicit `type:provider` selection. */
|
|
30
|
+
login(request: PiWorkflowRequest, session: PiSessionApi, runtime: PiRuntimeApi, argument: string, selection: string | undefined): Promise<PiWorkflowResult>;
|
|
31
|
+
/** Run pinned Pi's `/logout` for a `type:provider` selection. */
|
|
32
|
+
logout(request: PiWorkflowRequest, runtime: PiRuntimeApi, selection: string): Promise<PiWorkflowResult>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { isRecord, requireCapability, stringProperty } from "./message-values.js";
|
|
3
|
+
import { CredentialSynchronizationError } from "../startup-public.js";
|
|
4
|
+
import { AUTH_REFRESH_TIMEOUT_MS, isUnknownModel, PINNED_DEFAULT_MODEL_BY_PROVIDER, workflowLoginNotification, workflowResult } from "./workflow-support.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pinned Pi's provider login and logout: resolving a provider reference to an authentication
|
|
7
|
+
* method, driving the model runtime's login through the owned interaction host, selecting the
|
|
8
|
+
* provider's pinned default model when the session had none, and the deferred catalog refresh
|
|
9
|
+
* whose notices follow the saved-credential status. Wording follows pinned Pi exactly.
|
|
10
|
+
*/
|
|
11
|
+
export class PiProviderAuthentication {
|
|
12
|
+
#agentDir;
|
|
13
|
+
#contexts;
|
|
14
|
+
#ports;
|
|
15
|
+
constructor(options, ports) {
|
|
16
|
+
this.#agentDir = options.agentDir;
|
|
17
|
+
this.#contexts = options.contexts;
|
|
18
|
+
this.#ports = ports;
|
|
19
|
+
}
|
|
20
|
+
/** Run pinned Pi's `/login` for a provider reference or an explicit `type:provider` selection. */
|
|
21
|
+
async login(request, session, runtime, argument, selection) {
|
|
22
|
+
if (!selection && !argument)
|
|
23
|
+
return workflowResult(request.command, "failed", "Login requires the owned authentication controller");
|
|
24
|
+
const modelRuntime = runtime.services.modelRuntime;
|
|
25
|
+
let loginSelection = selection ?? argument;
|
|
26
|
+
if (!selection && argument && !argument.includes(":")) {
|
|
27
|
+
const normalized = argument.toLowerCase();
|
|
28
|
+
const providers = modelRuntime.getProviders?.();
|
|
29
|
+
const providerMatches = Array.isArray(providers) ? providers.filter(isRecord).filter(candidate => stringProperty(candidate, "id")?.toLowerCase() === normalized
|
|
30
|
+
|| stringProperty(candidate, "name")?.toLowerCase() === normalized) : [];
|
|
31
|
+
const providerReference = providerMatches.length === 1 ? stringProperty(providerMatches[0], "id") ?? argument : argument;
|
|
32
|
+
const matching = this.#contexts.loginOptions().filter(option => option.id.endsWith(`:${providerReference}`));
|
|
33
|
+
if (matching.length > 1) {
|
|
34
|
+
const provider = modelRuntime.getProvider?.(providerReference);
|
|
35
|
+
const providerName = stringProperty(provider, "name") ?? providerReference;
|
|
36
|
+
return workflowResult(request.command, "failed", `Authentication method for ${providerName} requires the owned authentication controller`);
|
|
37
|
+
}
|
|
38
|
+
if (matching[0])
|
|
39
|
+
loginSelection = matching[0].id;
|
|
40
|
+
}
|
|
41
|
+
const [authTypeValue = "oauth", providerId = loginSelection] = loginSelection.includes(":")
|
|
42
|
+
? loginSelection.split(":", 2)
|
|
43
|
+
: ["oauth", loginSelection];
|
|
44
|
+
const authType = authTypeValue === "api_key" ? "api_key" : "oauth";
|
|
45
|
+
const provider = modelRuntime.getProvider?.(providerId);
|
|
46
|
+
const providerName = stringProperty(provider, "name") ?? providerId;
|
|
47
|
+
const previousModel = session.model;
|
|
48
|
+
this.#ports.interaction().startLogin?.({ providerId, providerName, authType });
|
|
49
|
+
try {
|
|
50
|
+
await requireCapability(modelRuntime.login, "login").call(modelRuntime, providerId, authType, {
|
|
51
|
+
signal: AbortSignal.timeout(120_000),
|
|
52
|
+
prompt: async (prompt) => {
|
|
53
|
+
const promptType = stringProperty(prompt, "type");
|
|
54
|
+
const options = isRecord(prompt) && Array.isArray(prompt.options)
|
|
55
|
+
? prompt.options.filter(isRecord).flatMap(option => {
|
|
56
|
+
const id = stringProperty(option, "id");
|
|
57
|
+
const label = stringProperty(option, "label");
|
|
58
|
+
return id && label ? [{ id, label }] : [];
|
|
59
|
+
})
|
|
60
|
+
: [];
|
|
61
|
+
const response = await this.#ports.interaction().prompt({
|
|
62
|
+
type: promptType === "select"
|
|
63
|
+
? "select"
|
|
64
|
+
: promptType === "manual_code"
|
|
65
|
+
? "manual-code"
|
|
66
|
+
: authType === "api_key"
|
|
67
|
+
? "secret"
|
|
68
|
+
: "text",
|
|
69
|
+
message: stringProperty(prompt, "message") ?? `Authenticate ${providerName}`,
|
|
70
|
+
...(stringProperty(prompt, "placeholder") === undefined ? {} : { placeholder: stringProperty(prompt, "placeholder") }),
|
|
71
|
+
...(options.length === 0 ? {} : { options }),
|
|
72
|
+
});
|
|
73
|
+
if (response === null)
|
|
74
|
+
throw new Error("Login cancelled");
|
|
75
|
+
return response;
|
|
76
|
+
},
|
|
77
|
+
notify: (event) => {
|
|
78
|
+
const notification = workflowLoginNotification(event);
|
|
79
|
+
if (notification)
|
|
80
|
+
this.#ports.interaction().notify(notification);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof Error && error.message === "Login cancelled") {
|
|
86
|
+
return workflowResult(request.command, "cancelled", "Login cancelled", undefined, "silent");
|
|
87
|
+
}
|
|
88
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
89
|
+
const actionLabel = authType === "api_key" ? `Saved API key for ${providerName}` : `Logged in to ${providerName}`;
|
|
90
|
+
const message = error instanceof CredentialSynchronizationError
|
|
91
|
+
? `${actionLabel}, but local model state could not be synchronized: ${detail}`
|
|
92
|
+
: authType === "api_key"
|
|
93
|
+
? `Failed to save API key for ${providerName}: ${detail}`
|
|
94
|
+
: `Failed to login to ${providerName}: ${detail}`;
|
|
95
|
+
return workflowResult(request.command, "failed", message);
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
this.#ports.interaction().finishLogin?.();
|
|
99
|
+
}
|
|
100
|
+
return await this.#completeProviderAuthentication(providerId, providerName, authType, previousModel);
|
|
101
|
+
}
|
|
102
|
+
/** Run pinned Pi's `/logout` for a `type:provider` selection. */
|
|
103
|
+
async logout(request, runtime, selection) {
|
|
104
|
+
const [credentialType = "oauth", providerId = selection] = selection.includes(":") ? selection.split(":", 2) : ["oauth", selection];
|
|
105
|
+
const modelRuntime = runtime.services.modelRuntime;
|
|
106
|
+
const provider = modelRuntime.getProvider?.(providerId);
|
|
107
|
+
const providerName = stringProperty(provider, "name") ?? providerId;
|
|
108
|
+
try {
|
|
109
|
+
await requireCapability(modelRuntime.logout, "logout").call(modelRuntime, providerId, { signal: AbortSignal.timeout(15_000) });
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
113
|
+
const message = error instanceof CredentialSynchronizationError
|
|
114
|
+
? `Credentials removed for ${providerName}, but local model state could not be synchronized: ${detail}`
|
|
115
|
+
: `Logout failed: ${detail}`;
|
|
116
|
+
return workflowResult(request.command, "failed", message);
|
|
117
|
+
}
|
|
118
|
+
this.#ports.reconcileActiveModelAvailability();
|
|
119
|
+
this.#ports.emitView();
|
|
120
|
+
return workflowResult(request.command, "completed", credentialType === "api_key"
|
|
121
|
+
? `Removed stored API key for ${providerName}. Environment variables and models.json config are unchanged.`
|
|
122
|
+
: `Logged out of ${providerName}`);
|
|
123
|
+
}
|
|
124
|
+
async #completeProviderAuthentication(providerId, providerName, authType, previousModel) {
|
|
125
|
+
const session = this.#ports.requireSession();
|
|
126
|
+
const modelRuntime = this.#ports.runtime()?.services.modelRuntime;
|
|
127
|
+
if (!modelRuntime)
|
|
128
|
+
throw new Error("engine runtime is unavailable");
|
|
129
|
+
const actionLabel = authType === "oauth" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;
|
|
130
|
+
let selectedModelId;
|
|
131
|
+
let selectionError;
|
|
132
|
+
if (isUnknownModel(previousModel)) {
|
|
133
|
+
const available = modelRuntime.getAvailableSnapshot?.() ?? [];
|
|
134
|
+
const providerModels = available.filter(model => stringProperty(model, "provider") === providerId);
|
|
135
|
+
const defaultModelId = PINNED_DEFAULT_MODEL_BY_PROVIDER[providerId];
|
|
136
|
+
if (defaultModelId === undefined) {
|
|
137
|
+
selectionError = `${actionLabel}, but no default model is configured for provider "${providerId}". Use /model to select a model.`;
|
|
138
|
+
}
|
|
139
|
+
else if (providerModels.length === 0) {
|
|
140
|
+
selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const selectedModel = providerModels.find(model => stringProperty(model, "id") === defaultModelId);
|
|
144
|
+
if (selectedModel === undefined) {
|
|
145
|
+
selectionError = `${actionLabel}, but its default model "${defaultModelId}" is not available. Use /model to select a model.`;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
try {
|
|
149
|
+
await session.setModel(selectedModel);
|
|
150
|
+
selectedModelId = stringProperty(selectedModel, "id") ?? defaultModelId;
|
|
151
|
+
this.#ports.setActiveModel({
|
|
152
|
+
providerId,
|
|
153
|
+
modelId: selectedModelId,
|
|
154
|
+
displayName: stringProperty(selectedModel, "name") ?? selectedModelId,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
selectionError = `${actionLabel}, but selecting its default model failed: ${error instanceof Error ? error.message : String(error)}. Use /model to select a model.`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
this.#ports.reconcileActiveModelAvailability();
|
|
164
|
+
this.#ports.emitView();
|
|
165
|
+
const status = `${actionLabel}.${selectedModelId ? ` Selected ${selectedModelId}.` : ""} Credentials saved to ${join(this.#agentDir, "auth.json")}`;
|
|
166
|
+
const messages = [
|
|
167
|
+
{ kind: "status", message: status },
|
|
168
|
+
...(selectionError === undefined ? [] : [{ kind: "error", message: selectionError }]),
|
|
169
|
+
];
|
|
170
|
+
this.#scheduleAuthenticatedProviderRefresh(providerId, actionLabel);
|
|
171
|
+
return workflowResult("login", "completed", status, undefined, "status", messages);
|
|
172
|
+
}
|
|
173
|
+
#scheduleAuthenticatedProviderRefresh(providerId, actionLabel) {
|
|
174
|
+
const runtime = this.#ports.runtime();
|
|
175
|
+
const refresh = runtime?.services.modelRuntime.refresh;
|
|
176
|
+
if (!runtime || typeof refresh !== "function")
|
|
177
|
+
return;
|
|
178
|
+
const generation = this.#ports.sessionGeneration();
|
|
179
|
+
const publish = this.#ports.interaction().publish;
|
|
180
|
+
const controller = new AbortController();
|
|
181
|
+
const timeout = setTimeout(() => controller.abort(), AUTH_REFRESH_TIMEOUT_MS);
|
|
182
|
+
// Compatibility: post-authentication refresh starts on the next turn so its notices follow the saved-credential status.
|
|
183
|
+
void new Promise(resolve => setTimeout(resolve, 0))
|
|
184
|
+
.then(() => refresh.call(runtime.services.modelRuntime, { providers: [providerId], signal: controller.signal }))
|
|
185
|
+
.then(result => {
|
|
186
|
+
if (this.#ports.disposed() || this.#ports.sessionGeneration() !== generation)
|
|
187
|
+
return;
|
|
188
|
+
if (isRecord(result) && result.aborted === true) {
|
|
189
|
+
publish?.({ kind: "warning", message: `${actionLabel}, but its model catalog refresh timed out; using cached models.` });
|
|
190
|
+
}
|
|
191
|
+
else if (isRecord(result) && result.errors instanceof Map && result.errors.size > 0) {
|
|
192
|
+
publish?.({ kind: "warning", message: `${actionLabel}, but its model catalog could not be refreshed; using cached models.` });
|
|
193
|
+
}
|
|
194
|
+
this.#ports.reconcileActiveModelAvailability();
|
|
195
|
+
this.#ports.emitView();
|
|
196
|
+
})
|
|
197
|
+
.catch(error => {
|
|
198
|
+
if (this.#ports.disposed() || this.#ports.sessionGeneration() !== generation)
|
|
199
|
+
return;
|
|
200
|
+
publish?.({
|
|
201
|
+
kind: "warning",
|
|
202
|
+
message: controller.signal.aborted
|
|
203
|
+
? `${actionLabel}, but its model catalog refresh timed out; using cached models.`
|
|
204
|
+
: `${actionLabel}, but its model catalog could not be refreshed: ${error instanceof Error ? error.message : String(error)}`,
|
|
205
|
+
});
|
|
206
|
+
})
|
|
207
|
+
.finally(() => clearTimeout(timeout));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AgentSession, AgentSessionRuntime } from "../startup-public.js";
|
|
2
|
+
import type { PiWorkflowContexts } from "./workflow-contexts.js";
|
|
3
|
+
import { type PiWorkflowAutocompleteCommand } from "./workflows.js";
|
|
4
|
+
export interface OwnedPiResourceSummary {
|
|
5
|
+
readonly kind: "skill" | "prompt-template" | "agent-context" | "system-prompt" | "theme";
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly sourcePath: string | null;
|
|
9
|
+
readonly diagnostic: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface OwnedPiExtensionSourceSummary {
|
|
12
|
+
readonly source: string;
|
|
13
|
+
readonly scope: "user" | "project" | "temporary";
|
|
14
|
+
readonly origin: "package" | "top-level";
|
|
15
|
+
readonly baseDir: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface OwnedPiExtensionResourceSummary {
|
|
18
|
+
readonly kind: "extension";
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly sourcePath: string | null;
|
|
21
|
+
readonly resolvedPath: string | null;
|
|
22
|
+
readonly sourceInfo: OwnedPiExtensionSourceSummary | null;
|
|
23
|
+
readonly loaded: boolean;
|
|
24
|
+
readonly hidden: boolean;
|
|
25
|
+
readonly diagnostic: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface PiResourceCatalogPorts {
|
|
28
|
+
session(): AgentSession | undefined;
|
|
29
|
+
runtime(): AgentSessionRuntime | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The resources pinned Pi's loader discovered for the current runtime (skills, prompt templates,
|
|
33
|
+
* agent context files, system prompts, themes, extensions) and the slash-command autocomplete
|
|
34
|
+
* entries derived from them, shaped for the owned shell with the loader's diagnostics carried
|
|
35
|
+
* along instead of thrown. Reads only; the runtime and session are reached through ports.
|
|
36
|
+
*/
|
|
37
|
+
export declare class PiResourceCatalog {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(options: {
|
|
40
|
+
readonly contexts: PiWorkflowContexts;
|
|
41
|
+
}, ports: PiResourceCatalogPorts);
|
|
42
|
+
nonVisualResources(): readonly OwnedPiResourceSummary[];
|
|
43
|
+
extensionResources(): readonly OwnedPiExtensionResourceSummary[];
|
|
44
|
+
workflowAutocompleteCommands(): readonly PiWorkflowAutocompleteCommand[];
|
|
45
|
+
}
|
|
46
|
+
export declare function collectionResult(value: unknown, key: string): {
|
|
47
|
+
values: readonly unknown[];
|
|
48
|
+
diagnostics: readonly string[];
|
|
49
|
+
};
|