@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
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { NATIVE_HOST_PROTOCOL_VERSION, assertNativeHostCommand, assertTerminalSessionLaunch, } from "../../contracts/workspace/index.js";
|
|
2
|
-
import { PRODUCT_IDENTITY } from "../../product-identity.js";
|
|
3
|
-
export const NATIVE_HOST_PROTOCOL_NAME = PRODUCT_IDENTITY.protocol.nativeHostSchema;
|
|
4
|
-
export const MAX_NATIVE_HOST_MESSAGE_BYTES = 1024 * 1024;
|
|
5
|
-
export function negotiateNativeHostHello(value) {
|
|
6
|
-
if (value.protocolVersion !== NATIVE_HOST_PROTOCOL_VERSION) {
|
|
7
|
-
return negotiation(false, [], `unsupported native-host protocol version ${value.protocolVersion}`);
|
|
8
|
-
}
|
|
9
|
-
if (!isText(value.hostInstanceId, 128) || !isText(value.buildId, 256)) {
|
|
10
|
-
return negotiation(false, [], "native host instance and build identities must be bounded non-empty values");
|
|
11
|
-
}
|
|
12
|
-
if (!["windows", "macos", "linux"].includes(value.platform)) {
|
|
13
|
-
return negotiation(false, [], `unsupported native-host platform ${String(value.platform)}`);
|
|
14
|
-
}
|
|
15
|
-
const required = ["exact-command", "revisioned-topology", "native-input", "native-rendering", "retained-terminal-state"];
|
|
16
|
-
const capabilities = new Set(value.capabilities);
|
|
17
|
-
const missing = required.filter(capability => !capabilities.has(capability));
|
|
18
|
-
if (missing.length > 0)
|
|
19
|
-
return negotiation(false, [...capabilities].sort(), `native host lacks required capabilities: ${missing.join(", ")}`);
|
|
20
|
-
return negotiation(true, [...capabilities].sort(), "native host handshake accepted");
|
|
21
|
-
}
|
|
22
|
-
export function createFixedTwoByTwoCommand(input) {
|
|
23
|
-
if (input.panes.length !== 4)
|
|
24
|
-
throw new RangeError("fixed 2x2 proof requires exactly four panes");
|
|
25
|
-
const paneIds = new Set();
|
|
26
|
-
const sessions = [];
|
|
27
|
-
for (const pane of input.panes) {
|
|
28
|
-
if (paneIds.has(pane.paneId))
|
|
29
|
-
throw new TypeError(`duplicate proof pane id: ${pane.paneId}`);
|
|
30
|
-
paneIds.add(pane.paneId);
|
|
31
|
-
assertTerminalSessionLaunch(pane.session);
|
|
32
|
-
sessions.push(pane.session);
|
|
33
|
-
}
|
|
34
|
-
const [topLeft, topRight, bottomLeft, bottomRight] = input.panes;
|
|
35
|
-
const topology = {
|
|
36
|
-
hostInstanceId: input.hostInstanceId,
|
|
37
|
-
revision: input.expectedRevision,
|
|
38
|
-
windows: [{
|
|
39
|
-
id: input.windowId,
|
|
40
|
-
activeTabId: input.tabId,
|
|
41
|
-
tabs: [{
|
|
42
|
-
id: input.tabId,
|
|
43
|
-
rootNodeId: "root",
|
|
44
|
-
focusedPaneId: topLeft.paneId,
|
|
45
|
-
panes: input.panes.map(pane => ({ id: pane.paneId, sessionId: pane.session.id })),
|
|
46
|
-
nodes: [
|
|
47
|
-
{ id: "root", kind: "split", axis: "horizontal", ratio: 0.5, first: "top", second: "bottom" },
|
|
48
|
-
{ id: "top", kind: "split", axis: "vertical", ratio: 0.5, first: "leaf-top-left", second: "leaf-top-right" },
|
|
49
|
-
{ id: "bottom", kind: "split", axis: "vertical", ratio: 0.5, first: "leaf-bottom-left", second: "leaf-bottom-right" },
|
|
50
|
-
{ id: "leaf-top-left", kind: "leaf", paneId: topLeft.paneId },
|
|
51
|
-
{ id: "leaf-top-right", kind: "leaf", paneId: topRight.paneId },
|
|
52
|
-
{ id: "leaf-bottom-left", kind: "leaf", paneId: bottomLeft.paneId },
|
|
53
|
-
{ id: "leaf-bottom-right", kind: "leaf", paneId: bottomRight.paneId },
|
|
54
|
-
],
|
|
55
|
-
}],
|
|
56
|
-
}],
|
|
57
|
-
sessions,
|
|
58
|
-
};
|
|
59
|
-
const command = {
|
|
60
|
-
type: "apply-topology",
|
|
61
|
-
correlationId: input.correlationId,
|
|
62
|
-
expectedRevision: input.expectedRevision,
|
|
63
|
-
topology,
|
|
64
|
-
};
|
|
65
|
-
assertNativeHostCommand(command);
|
|
66
|
-
return command;
|
|
67
|
-
}
|
|
68
|
-
export function nativeHostCommandResult(correlationId, revision) {
|
|
69
|
-
return { type: "command-result", correlationId, accepted: true, revision, failure: null };
|
|
70
|
-
}
|
|
71
|
-
export function nativeHostFailure(code, message, retryable = false) {
|
|
72
|
-
if (!isText(code, 128) || !isText(message, 4_096))
|
|
73
|
-
throw new TypeError("native-host failure outcome is invalid");
|
|
74
|
-
return Object.freeze({ code, message, retryable });
|
|
75
|
-
}
|
|
76
|
-
export function nativeHostTimedOut(deadlineAt, now) {
|
|
77
|
-
if (!Number.isSafeInteger(deadlineAt) || deadlineAt < 0 || !Number.isSafeInteger(now) || now < 0) {
|
|
78
|
-
throw new RangeError("native-host deadline and clock must be non-negative safe integers");
|
|
79
|
-
}
|
|
80
|
-
return now >= deadlineAt;
|
|
81
|
-
}
|
|
82
|
-
export function assertNativeHostProofMessage(message) {
|
|
83
|
-
switch (message.type) {
|
|
84
|
-
case "hello": {
|
|
85
|
-
const result = negotiateNativeHostHello(message.hello);
|
|
86
|
-
if (!result.accepted)
|
|
87
|
-
throw new TypeError(result.diagnostic);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
case "hello-result":
|
|
91
|
-
if (typeof message.accepted !== "boolean" || !Array.isArray(message.negotiatedCapabilities) || !isText(message.diagnostic, 4_096)) {
|
|
92
|
-
throw new TypeError("native-host hello result is invalid");
|
|
93
|
-
}
|
|
94
|
-
return;
|
|
95
|
-
case "command":
|
|
96
|
-
assertNativeHostCommand(message.command);
|
|
97
|
-
return;
|
|
98
|
-
case "command-result":
|
|
99
|
-
if (!isText(message.correlationId, 128) || typeof message.accepted !== "boolean")
|
|
100
|
-
throw new TypeError("native-host command result is invalid");
|
|
101
|
-
if (message.revision !== null && (!Number.isSafeInteger(message.revision) || message.revision < 0))
|
|
102
|
-
throw new RangeError("native-host result revision is invalid");
|
|
103
|
-
if (message.accepted && message.failure !== null)
|
|
104
|
-
throw new TypeError("accepted native-host result cannot carry a failure");
|
|
105
|
-
if (!message.accepted && message.failure === null)
|
|
106
|
-
throw new TypeError("rejected native-host result requires a failure");
|
|
107
|
-
if (message.failure !== null)
|
|
108
|
-
assertFailure(message.failure);
|
|
109
|
-
return;
|
|
110
|
-
case "event":
|
|
111
|
-
assertNativeHostEvent(message.event);
|
|
112
|
-
return;
|
|
113
|
-
case "error":
|
|
114
|
-
assertFailure(message.failure);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function assertNativeHostEvent(event) {
|
|
118
|
-
switch (event.type) {
|
|
119
|
-
case "topology-changed":
|
|
120
|
-
assertNativeHostCommand({ type: "apply-topology", correlationId: "topology-validation", expectedRevision: event.topology.revision, topology: event.topology });
|
|
121
|
-
return;
|
|
122
|
-
case "pane-ready":
|
|
123
|
-
if (!isText(event.paneId, 128) || !isText(event.sessionId, 128))
|
|
124
|
-
throw new TypeError("pane-ready event is invalid");
|
|
125
|
-
return;
|
|
126
|
-
case "process-exited":
|
|
127
|
-
if (!isText(event.paneId, 128) || !isText(event.sessionId, 128))
|
|
128
|
-
throw new TypeError("process-exited event is invalid");
|
|
129
|
-
if (event.exitCode !== null && (!Number.isSafeInteger(event.exitCode) || event.exitCode < 0))
|
|
130
|
-
throw new RangeError("process exit code is invalid");
|
|
131
|
-
if (event.signal !== null && !isText(event.signal, 64))
|
|
132
|
-
throw new TypeError("process exit signal is invalid");
|
|
133
|
-
return;
|
|
134
|
-
case "host-degraded":
|
|
135
|
-
if (!isText(event.code, 128) || !isText(event.message, 4_096))
|
|
136
|
-
throw new TypeError("host-degraded event is invalid");
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function assertFailure(failure) {
|
|
140
|
-
if (!isText(failure.code, 128) || !isText(failure.message, 4_096) || typeof failure.retryable !== "boolean") {
|
|
141
|
-
throw new TypeError("native-host failure outcome is invalid");
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function negotiation(accepted, negotiatedCapabilities, diagnostic) {
|
|
145
|
-
return Object.freeze({ accepted, negotiatedCapabilities: Object.freeze(negotiatedCapabilities), diagnostic });
|
|
146
|
-
}
|
|
147
|
-
function isText(value, maximum) {
|
|
148
|
-
return typeof value === "string" && value.length > 0 && value.length <= maximum && !value.includes("\0");
|
|
149
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type NativeSpikeEvidence } from "./evidence.js";
|
|
2
|
-
export declare const NATIVE_SPIKE_ACCEPTANCE_LIMITS: Readonly<{
|
|
3
|
-
inputToProcessP95Ms: 16;
|
|
4
|
-
outputToPresentP95Ms: 33;
|
|
5
|
-
missedFrames: 0;
|
|
6
|
-
resizePaintGaps: 0;
|
|
7
|
-
}>;
|
|
8
|
-
export interface NativeSpikeGateDecision {
|
|
9
|
-
readonly decision: "go" | "stop";
|
|
10
|
-
readonly integrationAllowed: boolean;
|
|
11
|
-
readonly reasons: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
export declare function evaluateNativeSpikeGate(evidence: NativeSpikeEvidence): NativeSpikeGateDecision;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { assertNativeSpikeEvidence } from "./evidence.js";
|
|
2
|
-
export const NATIVE_SPIKE_ACCEPTANCE_LIMITS = Object.freeze({
|
|
3
|
-
inputToProcessP95Ms: 16,
|
|
4
|
-
outputToPresentP95Ms: 33,
|
|
5
|
-
missedFrames: 0,
|
|
6
|
-
resizePaintGaps: 0,
|
|
7
|
-
});
|
|
8
|
-
export function evaluateNativeSpikeGate(evidence) {
|
|
9
|
-
assertNativeSpikeEvidence(evidence);
|
|
10
|
-
const reasons = [];
|
|
11
|
-
if (evidence.summary.technical !== "passed")
|
|
12
|
-
reasons.push(`technical proof is ${evidence.summary.technical}`);
|
|
13
|
-
if (evidence.physical.verdict !== "accepted")
|
|
14
|
-
reasons.push(`physical verdict is ${evidence.physical.verdict}`);
|
|
15
|
-
if (evidence.physical.method === "not-run")
|
|
16
|
-
reasons.push("manual or isolated-worker physical evidence has not run");
|
|
17
|
-
if (evidence.summary.overall !== "accepted")
|
|
18
|
-
reasons.push(`overall proof summary is ${evidence.summary.overall}`);
|
|
19
|
-
if (evidence.latency.inputToProcessMs.p95 > NATIVE_SPIKE_ACCEPTANCE_LIMITS.inputToProcessP95Ms) {
|
|
20
|
-
reasons.push(`input p95 exceeds ${NATIVE_SPIKE_ACCEPTANCE_LIMITS.inputToProcessP95Ms} ms`);
|
|
21
|
-
}
|
|
22
|
-
if (evidence.latency.outputToPresentMs.p95 > NATIVE_SPIKE_ACCEPTANCE_LIMITS.outputToPresentP95Ms) {
|
|
23
|
-
reasons.push(`output presentation p95 exceeds ${NATIVE_SPIKE_ACCEPTANCE_LIMITS.outputToPresentP95Ms} ms`);
|
|
24
|
-
}
|
|
25
|
-
if (evidence.paint.missedFrames > NATIVE_SPIKE_ACCEPTANCE_LIMITS.missedFrames)
|
|
26
|
-
reasons.push("missed frames are present");
|
|
27
|
-
if (evidence.paint.resizePaintGaps > NATIVE_SPIKE_ACCEPTANCE_LIMITS.resizePaintGaps)
|
|
28
|
-
reasons.push("resize paint gaps are present");
|
|
29
|
-
if (reasons.length > 0) {
|
|
30
|
-
return Object.freeze({ decision: "stop", integrationAllowed: false, reasons: Object.freeze(reasons) });
|
|
31
|
-
}
|
|
32
|
-
return Object.freeze({ decision: "go", integrationAllowed: true, reasons: Object.freeze(["technical and physical proof accepted"]) });
|
|
33
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type StructuredCapabilityContract } from "../../contracts/workspace/index.js";
|
|
2
|
-
export type StructuredBackpressureResource = "events" | "commands" | "snapshots" | "attachments" | "reconnect-replay";
|
|
3
|
-
export type StructuredBackpressureAction = "none" | "reject-payload" | "pause-adapter" | "reject-request" | "disconnect-adapter";
|
|
4
|
-
export interface StructuredResourceLease {
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly resource: StructuredBackpressureResource;
|
|
7
|
-
readonly units: number;
|
|
8
|
-
readonly bytes: number;
|
|
9
|
-
}
|
|
10
|
-
export interface StructuredResourceUsage {
|
|
11
|
-
readonly resource: StructuredBackpressureResource;
|
|
12
|
-
readonly units: number;
|
|
13
|
-
readonly bytes: number;
|
|
14
|
-
readonly unitLimit: number;
|
|
15
|
-
readonly byteLimit: number;
|
|
16
|
-
}
|
|
17
|
-
export type StructuredBackpressureAcquireResult = {
|
|
18
|
-
readonly kind: "accepted";
|
|
19
|
-
readonly lease: StructuredResourceLease;
|
|
20
|
-
readonly usage: StructuredResourceUsage;
|
|
21
|
-
} | {
|
|
22
|
-
readonly kind: "rejected";
|
|
23
|
-
readonly code: "invalid-request" | "payload-too-large" | "resource-exhausted" | "replay-exhausted";
|
|
24
|
-
readonly action: Exclude<StructuredBackpressureAction, "none">;
|
|
25
|
-
readonly usage: StructuredResourceUsage;
|
|
26
|
-
readonly diagnostic: string;
|
|
27
|
-
};
|
|
28
|
-
export type StructuredBackpressureReleaseResult = {
|
|
29
|
-
readonly kind: "released";
|
|
30
|
-
readonly usage: StructuredResourceUsage;
|
|
31
|
-
} | {
|
|
32
|
-
readonly kind: "rejected";
|
|
33
|
-
readonly code: "unknown-lease" | "invalid-request";
|
|
34
|
-
readonly diagnostic: string;
|
|
35
|
-
};
|
|
36
|
-
/** Issues bounded resource leases and selects the negotiated backpressure action on exhaustion. */
|
|
37
|
-
export declare class StructuredBackpressureController {
|
|
38
|
-
#private;
|
|
39
|
-
readonly adapterId: string;
|
|
40
|
-
constructor(adapterId: string, capability: StructuredCapabilityContract);
|
|
41
|
-
acquire(resource: StructuredBackpressureResource, units?: number, bytes?: number): StructuredBackpressureAcquireResult;
|
|
42
|
-
release(lease: StructuredResourceLease): StructuredBackpressureReleaseResult;
|
|
43
|
-
resetReconnectReplay(): void;
|
|
44
|
-
usage(resource: StructuredBackpressureResource): StructuredResourceUsage;
|
|
45
|
-
leaseCount(): number;
|
|
46
|
-
replayExhausted(): boolean;
|
|
47
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { assertStructuredCapability, } from "../../contracts/workspace/index.js";
|
|
2
|
-
/** Issues bounded resource leases and selects the negotiated backpressure action on exhaustion. */
|
|
3
|
-
export class StructuredBackpressureController {
|
|
4
|
-
adapterId;
|
|
5
|
-
#budgets;
|
|
6
|
-
#usage = {
|
|
7
|
-
events: { units: 0, bytes: 0 },
|
|
8
|
-
commands: { units: 0, bytes: 0 },
|
|
9
|
-
snapshots: { units: 0, bytes: 0 },
|
|
10
|
-
attachments: { units: 0, bytes: 0 },
|
|
11
|
-
"reconnect-replay": { units: 0, bytes: 0 },
|
|
12
|
-
};
|
|
13
|
-
#leases = new Map();
|
|
14
|
-
#nextLeaseSequence = 0;
|
|
15
|
-
#replayExhausted = false;
|
|
16
|
-
constructor(adapterId, capability) {
|
|
17
|
-
this.adapterId = adapterId;
|
|
18
|
-
assertStructuredCapability(capability);
|
|
19
|
-
if (!adapterId || adapterId !== capability.adapterId)
|
|
20
|
-
throw new TypeError("structured backpressure adapter identity is invalid");
|
|
21
|
-
this.#budgets = Object.freeze({
|
|
22
|
-
events: budget(capability.flow.maxQueuedEvents, capability.flow.maxQueuedEvents * capability.flow.maxEventBytes, capability.flow.maxEventBytes, "pause-adapter"),
|
|
23
|
-
commands: budget(capability.flow.maxConcurrentCommands, capability.flow.maxConcurrentCommands * capability.flow.maxEventBytes, capability.flow.maxEventBytes, "reject-request"),
|
|
24
|
-
snapshots: budget(1, capability.flow.maxSnapshotBytes, capability.flow.maxSnapshotBytes, "reject-request"),
|
|
25
|
-
attachments: budget(capability.flow.maxConcurrentCommands, capability.flow.maxAttachmentBytes, capability.flow.maxAttachmentBytes, "reject-request"),
|
|
26
|
-
"reconnect-replay": budget(capability.flow.maxReconnectEvents, capability.flow.maxReconnectEvents * capability.flow.maxEventBytes, capability.flow.maxEventBytes, "disconnect-adapter"),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
acquire(resource, units = 1, bytes = 0) {
|
|
30
|
-
const budget = this.#budget(resource);
|
|
31
|
-
if (!isPositiveSafeInteger(units) || !isSafeNonNegativeInteger(bytes)) {
|
|
32
|
-
return this.#reject(resource, "invalid-request", "reject-request", "resource units and bytes must be bounded safe integers");
|
|
33
|
-
}
|
|
34
|
-
if (bytes > budget.perPayloadByteLimit) {
|
|
35
|
-
return this.#reject(resource, "payload-too-large", "reject-payload", `${resource} payload exceeds its negotiated ${budget.perPayloadByteLimit} byte limit`);
|
|
36
|
-
}
|
|
37
|
-
if (resource === "reconnect-replay" && this.#replayExhausted) {
|
|
38
|
-
return this.#reject(resource, "replay-exhausted", "disconnect-adapter", "reconnect replay is already exhausted for this adapter");
|
|
39
|
-
}
|
|
40
|
-
const usage = this.#usage[resource];
|
|
41
|
-
if (usage.units + units > budget.unitLimit || usage.bytes + bytes > budget.byteLimit) {
|
|
42
|
-
if (resource === "reconnect-replay") {
|
|
43
|
-
this.#replayExhausted = true;
|
|
44
|
-
return this.#reject(resource, "replay-exhausted", "disconnect-adapter", "reconnect replay exceeded its negotiated event or byte window");
|
|
45
|
-
}
|
|
46
|
-
return this.#reject(resource, "resource-exhausted", budget.action, `${resource} exceeded its negotiated count or byte window`);
|
|
47
|
-
}
|
|
48
|
-
usage.units += units;
|
|
49
|
-
usage.bytes += bytes;
|
|
50
|
-
this.#nextLeaseSequence += 1;
|
|
51
|
-
const lease = Object.freeze({
|
|
52
|
-
id: `lease-${this.adapterId}-${this.#nextLeaseSequence}`,
|
|
53
|
-
resource,
|
|
54
|
-
units,
|
|
55
|
-
bytes,
|
|
56
|
-
});
|
|
57
|
-
this.#leases.set(lease.id, lease);
|
|
58
|
-
return { kind: "accepted", lease, usage: this.usage(resource) };
|
|
59
|
-
}
|
|
60
|
-
release(lease) {
|
|
61
|
-
if (!lease || typeof lease.id !== "string" || !isPositiveSafeInteger(lease.units) || !isSafeNonNegativeInteger(lease.bytes)) {
|
|
62
|
-
return { kind: "rejected", code: "invalid-request", diagnostic: "resource lease is malformed" };
|
|
63
|
-
}
|
|
64
|
-
const owned = this.#leases.get(lease.id);
|
|
65
|
-
if (!owned || owned.resource !== lease.resource || owned.units !== lease.units || owned.bytes !== lease.bytes) {
|
|
66
|
-
return { kind: "rejected", code: "unknown-lease", diagnostic: `resource lease is unknown: ${lease.id}` };
|
|
67
|
-
}
|
|
68
|
-
this.#leases.delete(lease.id);
|
|
69
|
-
const usage = this.#usage[lease.resource];
|
|
70
|
-
usage.units -= lease.units;
|
|
71
|
-
usage.bytes -= lease.bytes;
|
|
72
|
-
return { kind: "released", usage: this.usage(lease.resource) };
|
|
73
|
-
}
|
|
74
|
-
resetReconnectReplay() {
|
|
75
|
-
const usage = this.#usage["reconnect-replay"];
|
|
76
|
-
usage.units = 0;
|
|
77
|
-
usage.bytes = 0;
|
|
78
|
-
this.#replayExhausted = false;
|
|
79
|
-
for (const [id, lease] of this.#leases) {
|
|
80
|
-
if (lease.resource === "reconnect-replay")
|
|
81
|
-
this.#leases.delete(id);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
usage(resource) {
|
|
85
|
-
const usage = this.#usage[resource];
|
|
86
|
-
const budget = this.#budget(resource);
|
|
87
|
-
return Object.freeze({
|
|
88
|
-
resource,
|
|
89
|
-
units: usage.units,
|
|
90
|
-
bytes: usage.bytes,
|
|
91
|
-
unitLimit: budget.unitLimit,
|
|
92
|
-
byteLimit: budget.byteLimit,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
leaseCount() {
|
|
96
|
-
return this.#leases.size;
|
|
97
|
-
}
|
|
98
|
-
replayExhausted() {
|
|
99
|
-
return this.#replayExhausted;
|
|
100
|
-
}
|
|
101
|
-
#budget(resource) {
|
|
102
|
-
const budget = this.#budgets[resource];
|
|
103
|
-
if (!budget)
|
|
104
|
-
throw new TypeError(`unknown structured backpressure resource: ${String(resource)}`);
|
|
105
|
-
return budget;
|
|
106
|
-
}
|
|
107
|
-
#reject(resource, code, action, diagnostic) {
|
|
108
|
-
return { kind: "rejected", code, action, usage: this.usage(resource), diagnostic };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function budget(unitLimit, byteLimit, perPayloadByteLimit, action) {
|
|
112
|
-
return Object.freeze({ unitLimit, byteLimit, perPayloadByteLimit, action });
|
|
113
|
-
}
|
|
114
|
-
function isPositiveSafeInteger(value) {
|
|
115
|
-
return Number.isSafeInteger(value) && value > 0;
|
|
116
|
-
}
|
|
117
|
-
function isSafeNonNegativeInteger(value) {
|
|
118
|
-
return Number.isSafeInteger(value) && value >= 0;
|
|
119
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type StructuredCapabilityContract, type WorkspaceCommand } from "../../contracts/workspace/index.js";
|
|
2
|
-
export type StructuredCommandRequest = Extract<WorkspaceCommand, {
|
|
3
|
-
readonly type: "structured-command";
|
|
4
|
-
}>;
|
|
5
|
-
export type StructuredCancelRequest = Extract<WorkspaceCommand, {
|
|
6
|
-
readonly type: "cancel-structured-command";
|
|
7
|
-
}>;
|
|
8
|
-
export type StructuredCommandTerminalOutcome = "completed" | "failed" | "timed-out" | "cancelled";
|
|
9
|
-
export interface StructuredCommandRecord {
|
|
10
|
-
readonly agentId: string;
|
|
11
|
-
readonly correlationId: string;
|
|
12
|
-
readonly command: string;
|
|
13
|
-
readonly payload: unknown;
|
|
14
|
-
readonly startedAt: number;
|
|
15
|
-
readonly terminalAt: number | null;
|
|
16
|
-
readonly outcome: "active" | StructuredCommandTerminalOutcome;
|
|
17
|
-
readonly revision: number;
|
|
18
|
-
}
|
|
19
|
-
export type StructuredCommandStartResult = {
|
|
20
|
-
readonly kind: "accepted";
|
|
21
|
-
readonly record: StructuredCommandRecord;
|
|
22
|
-
readonly activeCount: number;
|
|
23
|
-
} | {
|
|
24
|
-
readonly kind: "outcome";
|
|
25
|
-
readonly record: StructuredCommandRecord;
|
|
26
|
-
readonly idempotent: true;
|
|
27
|
-
} | {
|
|
28
|
-
readonly kind: "rejected";
|
|
29
|
-
readonly code: string;
|
|
30
|
-
readonly diagnostic: string;
|
|
31
|
-
};
|
|
32
|
-
export type StructuredCommandOutcomeResult = {
|
|
33
|
-
readonly kind: "outcome";
|
|
34
|
-
readonly record: StructuredCommandRecord;
|
|
35
|
-
readonly idempotent: boolean;
|
|
36
|
-
} | {
|
|
37
|
-
readonly kind: "rejected";
|
|
38
|
-
readonly code: string;
|
|
39
|
-
readonly diagnostic: string;
|
|
40
|
-
};
|
|
41
|
-
/** Tracks structured commands by correlation identity through one idempotent terminal outcome. */
|
|
42
|
-
export declare class StructuredCommandTracker {
|
|
43
|
-
#private;
|
|
44
|
-
readonly agentId: string;
|
|
45
|
-
constructor(agentId: string, capability: StructuredCapabilityContract, commandTimeoutMs?: number);
|
|
46
|
-
start(command: StructuredCommandRequest, startedAt?: number): StructuredCommandStartResult;
|
|
47
|
-
complete(correlationId: string, outcome: "completed" | "failed", completedAt?: number): StructuredCommandOutcomeResult;
|
|
48
|
-
cancel(request: StructuredCancelRequest, cancelledAt?: number): StructuredCommandOutcomeResult;
|
|
49
|
-
expire(now: number): readonly StructuredCommandRecord[];
|
|
50
|
-
outcomeFor(correlationId: string): StructuredCommandRecord | null;
|
|
51
|
-
activeCount(): number;
|
|
52
|
-
terminalCount(): number;
|
|
53
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { assertStructuredCapability, assertWorkspaceCommand, } from "../../contracts/workspace/index.js";
|
|
2
|
-
/** Tracks structured commands by correlation identity through one idempotent terminal outcome. */
|
|
3
|
-
export class StructuredCommandTracker {
|
|
4
|
-
agentId;
|
|
5
|
-
#capability;
|
|
6
|
-
#commandTimeoutMs;
|
|
7
|
-
#records = new Map();
|
|
8
|
-
#terminalOrder = [];
|
|
9
|
-
constructor(agentId, capability, commandTimeoutMs = 30_000) {
|
|
10
|
-
this.agentId = agentId;
|
|
11
|
-
assertStructuredCapability(capability);
|
|
12
|
-
if (!agentId || agentId.includes("\0"))
|
|
13
|
-
throw new TypeError("structured command agent id is invalid");
|
|
14
|
-
if (!Number.isSafeInteger(commandTimeoutMs) || commandTimeoutMs <= 0)
|
|
15
|
-
throw new RangeError("structured command timeout must be positive");
|
|
16
|
-
this.#capability = capability;
|
|
17
|
-
this.#commandTimeoutMs = commandTimeoutMs;
|
|
18
|
-
}
|
|
19
|
-
start(command, startedAt = 0) {
|
|
20
|
-
try {
|
|
21
|
-
assertWorkspaceCommand(command);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
return rejected("malformed-command", error);
|
|
25
|
-
}
|
|
26
|
-
if (command.agentId !== this.agentId)
|
|
27
|
-
return rejected("agent-mismatch", new Error("structured command agent does not match the tracker identity"));
|
|
28
|
-
if (!this.#capability.commands.includes(command.command)) {
|
|
29
|
-
return rejected("unsupported-command", new Error(`structured command is not negotiated: ${command.command}`));
|
|
30
|
-
}
|
|
31
|
-
if (payloadBytes(command.payload) > this.#capability.flow.maxEventBytes) {
|
|
32
|
-
return rejected("command-too-large", new Error(`structured command exceeds the negotiated ${this.#capability.flow.maxEventBytes} byte payload limit`));
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
assertTime(startedAt, "command start time");
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
return rejected("invalid-time", error);
|
|
39
|
-
}
|
|
40
|
-
const existing = this.#records.get(command.correlationId);
|
|
41
|
-
if (existing) {
|
|
42
|
-
if (existing.outcome !== "active" && existing.command === command.command && stableJson(existing.payload) === stableJson(command.payload)) {
|
|
43
|
-
return { kind: "outcome", record: freezeRecord(existing), idempotent: true };
|
|
44
|
-
}
|
|
45
|
-
return rejected(existing.outcome === "active" ? "duplicate-correlation" : "correlation-conflict", new Error(`structured correlation id is already in use: ${command.correlationId}`));
|
|
46
|
-
}
|
|
47
|
-
if (this.activeCount() >= this.#capability.flow.maxConcurrentCommands) {
|
|
48
|
-
return rejected("concurrency-limit", new Error(`structured command concurrency exceeds the negotiated ${this.#capability.flow.maxConcurrentCommands} command limit`));
|
|
49
|
-
}
|
|
50
|
-
const record = {
|
|
51
|
-
agentId: command.agentId,
|
|
52
|
-
correlationId: command.correlationId,
|
|
53
|
-
command: command.command,
|
|
54
|
-
payload: command.payload,
|
|
55
|
-
startedAt,
|
|
56
|
-
terminalAt: null,
|
|
57
|
-
outcome: "active",
|
|
58
|
-
revision: 1,
|
|
59
|
-
};
|
|
60
|
-
this.#records.set(record.correlationId, record);
|
|
61
|
-
return { kind: "accepted", record: freezeRecord(record), activeCount: this.activeCount() };
|
|
62
|
-
}
|
|
63
|
-
complete(correlationId, outcome, completedAt = 0) {
|
|
64
|
-
if (outcome !== "completed" && outcome !== "failed")
|
|
65
|
-
return rejected("malformed-outcome", new Error("structured completion outcome is invalid"));
|
|
66
|
-
try {
|
|
67
|
-
assertTime(completedAt, "command completion time");
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
return rejected("invalid-time", error);
|
|
71
|
-
}
|
|
72
|
-
const record = this.#records.get(correlationId);
|
|
73
|
-
if (!record)
|
|
74
|
-
return rejected("unknown-correlation", new Error(`structured correlation id is unknown: ${correlationId}`));
|
|
75
|
-
return this.#settle(record, outcome, completedAt);
|
|
76
|
-
}
|
|
77
|
-
cancel(request, cancelledAt = 0) {
|
|
78
|
-
try {
|
|
79
|
-
assertWorkspaceCommand(request);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
return rejected("malformed-cancellation", error);
|
|
83
|
-
}
|
|
84
|
-
if (request.agentId !== this.agentId)
|
|
85
|
-
return rejected("agent-mismatch", new Error("structured cancellation agent does not match the tracker identity"));
|
|
86
|
-
if (this.#capability.cancellation !== "correlated")
|
|
87
|
-
return rejected("cancellation-unsupported", new Error("the negotiated adapter capability does not support correlated cancellation"));
|
|
88
|
-
try {
|
|
89
|
-
assertTime(cancelledAt, "command cancellation time");
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
return rejected("invalid-time", error);
|
|
93
|
-
}
|
|
94
|
-
const record = this.#records.get(request.targetCorrelationId);
|
|
95
|
-
if (!record)
|
|
96
|
-
return rejected("unknown-correlation", new Error(`structured correlation id is unknown: ${request.targetCorrelationId}`));
|
|
97
|
-
return this.#settle(record, "cancelled", cancelledAt);
|
|
98
|
-
}
|
|
99
|
-
expire(now) {
|
|
100
|
-
assertTime(now, "command timeout clock");
|
|
101
|
-
const expired = [];
|
|
102
|
-
for (const record of this.#records.values()) {
|
|
103
|
-
if (record.outcome === "active" && now - record.startedAt >= this.#commandTimeoutMs) {
|
|
104
|
-
const result = this.#settle(record, "timed-out", record.startedAt + this.#commandTimeoutMs);
|
|
105
|
-
if (result.kind === "outcome")
|
|
106
|
-
expired.push(result.record);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return Object.freeze(expired);
|
|
110
|
-
}
|
|
111
|
-
outcomeFor(correlationId) {
|
|
112
|
-
const record = this.#records.get(correlationId);
|
|
113
|
-
return record ? freezeRecord(record) : null;
|
|
114
|
-
}
|
|
115
|
-
activeCount() {
|
|
116
|
-
let count = 0;
|
|
117
|
-
for (const record of this.#records.values())
|
|
118
|
-
if (record.outcome === "active")
|
|
119
|
-
count += 1;
|
|
120
|
-
return count;
|
|
121
|
-
}
|
|
122
|
-
terminalCount() {
|
|
123
|
-
return this.#terminalOrder.length;
|
|
124
|
-
}
|
|
125
|
-
#settle(record, outcome, at) {
|
|
126
|
-
if (record.outcome !== "active")
|
|
127
|
-
return { kind: "outcome", record: freezeRecord(record), idempotent: true };
|
|
128
|
-
if (at < record.startedAt)
|
|
129
|
-
return rejected("invalid-time", new Error("structured command outcome cannot precede its start"));
|
|
130
|
-
record.outcome = outcome;
|
|
131
|
-
record.terminalAt = at;
|
|
132
|
-
record.revision += 1;
|
|
133
|
-
this.#terminalOrder.push(record.correlationId);
|
|
134
|
-
this.#boundTerminalOutcomes();
|
|
135
|
-
return { kind: "outcome", record: freezeRecord(record), idempotent: false };
|
|
136
|
-
}
|
|
137
|
-
#boundTerminalOutcomes() {
|
|
138
|
-
const retention = this.#capability.flow.maxQueuedEvents;
|
|
139
|
-
while (this.#terminalOrder.length > retention) {
|
|
140
|
-
const oldest = this.#terminalOrder.shift();
|
|
141
|
-
if (oldest === undefined)
|
|
142
|
-
return;
|
|
143
|
-
this.#records.delete(oldest);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function rejected(code, error) {
|
|
148
|
-
return { kind: "rejected", code, diagnostic: error instanceof Error ? error.message : String(error) };
|
|
149
|
-
}
|
|
150
|
-
function freezeRecord(record) {
|
|
151
|
-
return Object.freeze({ ...record });
|
|
152
|
-
}
|
|
153
|
-
function assertTime(value, name) {
|
|
154
|
-
if (!Number.isSafeInteger(value) || value < 0)
|
|
155
|
-
throw new RangeError(`${name} must be a non-negative safe integer`);
|
|
156
|
-
}
|
|
157
|
-
function payloadBytes(payload) {
|
|
158
|
-
return new TextEncoder().encode(stableJson(payload)).byteLength;
|
|
159
|
-
}
|
|
160
|
-
function stableJson(value) {
|
|
161
|
-
const encoded = JSON.stringify(value);
|
|
162
|
-
if (encoded === undefined)
|
|
163
|
-
throw new TypeError("structured payload must be JSON serializable");
|
|
164
|
-
return encoded;
|
|
165
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type AdapterId, type StructuredCapabilityContract, type StructuredFlowLimits } from "../../contracts/workspace/index.js";
|
|
2
|
-
export declare const STRUCTURED_ADAPTER_ENVELOPE: string;
|
|
3
|
-
export declare const STRUCTURED_ADAPTER_ENVELOPE_REVISION: 1;
|
|
4
|
-
export declare const REQUIRED_STRUCTURED_FEATURES: readonly ["identity.adapter.v1", "commands.correlated.v1", "events.typed.v1", "flow-control.limits.v1"];
|
|
5
|
-
export declare const OPTIONAL_STRUCTURED_FEATURES: readonly ["snapshots.authoritative.v1", "resume.position.v1", "resume.snapshot.v1", "commands.cancellable.v1", "attachments.typed.v1"];
|
|
6
|
-
export type StructuredProtocolFeature = typeof REQUIRED_STRUCTURED_FEATURES[number] | typeof OPTIONAL_STRUCTURED_FEATURES[number];
|
|
7
|
-
export declare const STRUCTURED_FLOW_LIMITS: StructuredFlowLimits;
|
|
8
|
-
export interface StructuredAdapterHello {
|
|
9
|
-
readonly envelope: typeof STRUCTURED_ADAPTER_ENVELOPE;
|
|
10
|
-
readonly envelopeRevision: typeof STRUCTURED_ADAPTER_ENVELOPE_REVISION;
|
|
11
|
-
readonly adapterId: AdapterId;
|
|
12
|
-
readonly buildId: string;
|
|
13
|
-
readonly requiredFeatures: readonly string[];
|
|
14
|
-
readonly optionalFeatures: readonly string[];
|
|
15
|
-
readonly capability: StructuredCapabilityContract;
|
|
16
|
-
}
|
|
17
|
-
export interface StructuredAdapterPeerHello {
|
|
18
|
-
readonly envelope: typeof STRUCTURED_ADAPTER_ENVELOPE;
|
|
19
|
-
readonly envelopeRevision: typeof STRUCTURED_ADAPTER_ENVELOPE_REVISION;
|
|
20
|
-
readonly requiredFeatures: readonly string[];
|
|
21
|
-
readonly optionalFeatures: readonly string[];
|
|
22
|
-
readonly flowLimits: StructuredFlowLimits;
|
|
23
|
-
}
|
|
24
|
-
export type StructuredHandshakeErrorCode = "invalid-message" | "unsupported-version" | "invalid-identity" | "invalid-capability" | "unsupported-feature" | "incompatible-features";
|
|
25
|
-
export interface StructuredHandshakeAccepted {
|
|
26
|
-
readonly accepted: true;
|
|
27
|
-
readonly adapterId: AdapterId;
|
|
28
|
-
readonly negotiatedFeatures: readonly string[];
|
|
29
|
-
readonly capability: StructuredCapabilityContract;
|
|
30
|
-
readonly diagnostic: string;
|
|
31
|
-
}
|
|
32
|
-
export interface StructuredHandshakeRejected {
|
|
33
|
-
readonly accepted: false;
|
|
34
|
-
readonly code: StructuredHandshakeErrorCode;
|
|
35
|
-
readonly missingFromAdapter: readonly string[];
|
|
36
|
-
readonly missingFromServer: readonly string[];
|
|
37
|
-
readonly diagnostic: string;
|
|
38
|
-
}
|
|
39
|
-
export type StructuredHandshakeResult = StructuredHandshakeAccepted | StructuredHandshakeRejected;
|
|
40
|
-
export declare function localStructuredAdapterHello(): StructuredAdapterPeerHello;
|
|
41
|
-
export declare function negotiateStructuredAdapter(value: unknown, server?: StructuredAdapterPeerHello): StructuredHandshakeResult;
|