@timurproko/a1 0.2.7-dev.1249 → 0.2.7-dev.1252
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/README.md +11 -36
- package/bin/cli.js +2 -17
- package/bin/ui.js +7 -48
- package/dist/app/session-shell/exit-notice.d.ts +2 -2
- package/dist/app/session-shell/exit-notice.js +10 -10
- package/dist/app/session-shell/prompt-submission.d.ts +2 -4
- package/dist/app/session-shell/prompt-submission.js +3 -23
- package/dist/app/session-shell/response-copy-transport.js +1 -2
- package/dist/app/session-shell/session-lifecycle.d.ts +1 -2
- package/dist/app/session-shell/session-lifecycle.js +2 -4
- package/dist/app/session-shell/session-shell-root.d.ts +0 -31
- package/dist/app/session-shell/session-shell-root.js +3 -4
- package/dist/app/session-shell/session-shell.js +6 -47
- package/dist/app/session-shell/session-viewport-controller.js +3 -6
- package/dist/app/session-shell/shell-host.js +2 -18
- package/dist/app/session-shell/transcript-document.d.ts +1 -2
- package/dist/app/session-shell/transcript-document.js +3 -28
- package/dist/app/session-shell/workflow-output.js +1 -1
- package/dist/app/session-shell/workflow-router.d.ts +1 -3
- package/dist/app/session-shell/workflow-router.js +1 -4
- package/dist/cli/dispatch.d.ts +1 -11
- package/dist/cli/dispatch.js +5 -92
- package/dist/cli/session-context.js +5 -7
- package/dist/cli/uninstall.d.ts +1 -5
- package/dist/cli/uninstall.js +6 -35
- package/dist/cli/version-stats.js +4 -7
- package/dist/composition/owned-settings.d.ts +0 -1
- package/dist/composition/owned-settings.js +0 -1
- package/dist/composition/owned-ui.d.ts +2 -24
- package/dist/composition/owned-ui.js +11 -87
- package/dist/composition/release-update-observation.d.ts +4 -4
- package/dist/composition/release-update-observation.js +17 -47
- package/dist/composition/session-backend.d.ts +0 -1
- package/dist/composition/session-runtime-registry.d.ts +3 -3
- package/dist/composition/settings-route-host.d.ts +0 -7
- package/dist/composition/settings-route-host.js +4 -10
- package/dist/composition/startup-route.d.ts +0 -1
- package/dist/composition/startup-route.js +0 -1
- package/dist/contracts/owned-ui/index.d.ts +1 -1
- package/dist/contracts/owned-ui/model.d.ts +0 -3
- package/dist/contracts/owned-ui/session-workflows.d.ts +1 -4
- package/dist/features/launch/development-launch.js +0 -1
- package/dist/features/launch/index.d.ts +1 -1
- package/dist/features/launch/intent.d.ts +1 -3
- package/dist/features/launch/intent.js +2 -4
- package/dist/features/launch/session-context.d.ts +2 -2
- package/dist/features/owned-ui/reference-screen-app.d.ts +0 -2
- package/dist/features/owned-ui/reference-screen-app.js +2 -9
- package/dist/features/owned-ui/settings-app.d.ts +0 -6
- package/dist/features/owned-ui/settings-app.js +5 -36
- package/dist/foundation/launch-context/index.d.ts +0 -12
- package/dist/foundation/launch-context/index.js +0 -26
- package/dist/foundation/lifecycle/claim-gate.d.ts +8 -0
- package/dist/foundation/lifecycle/claim-gate.js +37 -0
- package/dist/foundation/lifecycle/index.d.ts +5 -9
- package/dist/foundation/lifecycle/index.js +3 -4
- package/dist/foundation/lifecycle/model.d.ts +2 -59
- package/dist/foundation/lifecycle/model.js +0 -35
- package/dist/foundation/lifecycle/paths.d.ts +0 -24
- package/dist/foundation/lifecycle/paths.js +0 -40
- package/dist/foundation/lifecycle/process-liveness.d.ts +8 -0
- package/dist/foundation/lifecycle/process-liveness.js +18 -0
- package/dist/foundation/lifecycle/session-claim-lock.d.ts +1 -1
- package/dist/foundation/lifecycle/session-claim-lock.js +2 -2
- package/dist/foundation/lifecycle/session-repository-context.d.ts +6 -6
- package/dist/foundation/lifecycle/session-repository-context.js +2 -3
- package/dist/foundation/release/automatic-update.d.ts +1 -3
- package/dist/foundation/release/automatic-update.js +9 -30
- package/dist/foundation/release/bootstrap.d.ts +2 -25
- package/dist/foundation/release/bootstrap.js +33 -344
- package/dist/foundation/release/cohort-state.d.ts +21 -46
- package/dist/foundation/release/cohort-state.js +30 -62
- package/dist/foundation/release/dependency-certification.d.ts +1 -1
- package/dist/foundation/release/index.d.ts +10 -17
- package/dist/foundation/release/index.js +7 -11
- package/dist/foundation/release/latest-release.d.ts +1 -2
- package/dist/foundation/release/latest-release.js +1 -2
- package/dist/foundation/release/process-liveness.d.ts +2 -0
- package/dist/foundation/release/process-liveness.js +12 -0
- package/dist/foundation/release/release-gc.d.ts +12 -9
- package/dist/foundation/release/release-gc.js +34 -98
- package/dist/foundation/release/release-store.d.ts +2 -2
- package/dist/foundation/release/release-store.js +2 -2
- package/dist/foundation/release/restart-certification.js +1 -1
- package/dist/foundation/release/update-activation.d.ts +2 -9
- package/dist/foundation/release/update-activation.js +28 -43
- package/dist/foundation/release/update-execution-lease.js +1 -1
- package/dist/foundation/release/update-launch.d.ts +0 -2
- package/dist/foundation/release/update-launch.js +0 -7
- package/dist/foundation/release/update-recovery.js +1 -1
- package/dist/foundation/release/update-transaction.d.ts +1 -1
- package/dist/foundation/release/update-transaction.js +5 -2
- package/dist/foundation/release/update.d.ts +2 -10
- package/dist/foundation/release/update.js +23 -200
- package/dist/foundation/session-writer-lock/index.d.ts +14 -6
- package/dist/foundation/session-writer-lock/index.js +48 -103
- package/dist/foundation/startup/startup-runtime.d.ts +1 -1
- package/dist/foundation/terminal-cleanup/exit-notice.d.ts +6 -0
- package/dist/foundation/terminal-cleanup/exit-notice.js +36 -0
- package/dist/foundation/terminal-cleanup/index.d.ts +2 -1
- package/dist/foundation/terminal-cleanup/index.js +2 -1
- package/dist/foundation/terminal-cleanup/terminal-reset.d.ts +0 -5
- package/dist/foundation/terminal-cleanup/terminal-reset.js +0 -5
- package/dist/integrations/pi/components/index.d.ts +1 -1
- package/dist/integrations/pi/components/index.js +1 -1
- package/dist/integrations/pi/components/shell-editor-autocomplete.js +1 -4
- package/dist/integrations/pi/components/shell-footer-status.d.ts +1 -1
- package/dist/integrations/pi/components/shell-footer-status.js +2 -2
- package/dist/integrations/pi/components/shell-hotkey-sections.js +1 -1
- package/dist/integrations/pi/components/shell-presenters-info.d.ts +2 -5
- package/dist/integrations/pi/components/shell-presenters-info.js +4 -18
- package/dist/integrations/pi/components/shell-presenters-transcript.d.ts +1 -1
- package/dist/integrations/pi/components/shell-presenters-transcript.js +1 -1
- package/dist/integrations/pi/components/shell-shared-facade.d.ts +0 -2
- package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +2 -5
- package/dist/integrations/pi/components/submitted-prompt-adapter.js +2 -16
- package/dist/integrations/pi/components/upstream/components/session-footer.d.ts +1 -2
- package/dist/integrations/pi/components/upstream/components/session-footer.js +6 -8
- package/dist/integrations/pi/engine/adapter.d.ts +0 -1
- package/dist/integrations/pi/engine/adapter.js +1 -16
- package/dist/integrations/pi/engine/diagnostics-state.d.ts +0 -1
- package/dist/integrations/pi/engine/diagnostics-state.js +0 -14
- package/dist/integrations/pi/engine/prompt-suggestions.d.ts +0 -1
- package/dist/integrations/pi/engine/prompt-suggestions.js +0 -40
- package/dist/integrations/pi/engine/session-runtime.js +0 -2
- package/dist/integrations/pi/engine/workflow-runner.js +1 -1
- package/dist/integrations/pi/tui-runtime/adapter.d.ts +2 -2
- package/dist/integrations/pi/tui-runtime/adapter.js +2 -2
- package/dist/product-identity.d.ts +4 -6
- package/dist/product-identity.js +6 -11
- package/dist/product-identity.json +1 -40
- package/dist/runtime-payload-inventory.json +0 -3
- package/dist/ui/components/index.d.ts +2 -2
- package/dist/ui/components/index.js +1 -1
- package/dist/ui/components/submitted-prompt.d.ts +3 -13
- package/dist/ui/components/submitted-prompt.js +8 -41
- package/dist/ui/components/transcript-viewport.d.ts +1 -3
- package/dist/ui/components/transcript-viewport.js +1 -4
- package/dist/ui/settings/declarations.d.ts +3 -97
- package/dist/ui/settings/declarations.js +3 -78
- package/dist/ui/settings/migrations.js +18 -2
- package/docs/architecture/boundaries.md +22 -39
- package/docs/architecture/code-documentation.md +2 -2
- package/docs/architecture/internal-naming.md +9 -17
- package/docs/architecture/project-structure.md +9 -14
- package/docs/architecture/resource-and-data-policy.md +16 -31
- package/docs/architecture/toolchain.md +14 -19
- package/docs/architecture/ui-reference-provenance.md +2 -2
- package/docs/ci-release-runbook.md +5 -5
- package/docs/features/launch-profiles.md +11 -17
- package/docs/features/prompt-history.md +10 -11
- package/docs/local-worktree-cleanup.md +28 -1
- package/docs/manual-owned-ui-checkpoint.md +0 -1
- package/docs/validation.md +5 -11
- package/docs/worktree-link-recovery.md +6 -6
- package/package.json +7 -19
- package/bin/guardian.js +0 -42
- package/bin/supervisor.js +0 -7
- package/bin/tab-launch-context.d.ts +0 -27
- package/bin/tab-launch-context.js +0 -94
- package/dist/app/session-shell/resident-tab-coordinator.d.ts +0 -38
- package/dist/app/session-shell/resident-tab-coordinator.js +0 -77
- package/dist/cli/tabs-request.d.ts +0 -7
- package/dist/cli/tabs-request.js +0 -1
- package/dist/cli/tabs.d.ts +0 -14
- package/dist/cli/tabs.js +0 -151
- package/dist/composition/resident-tab-bridge.d.ts +0 -41
- package/dist/composition/resident-tab-bridge.js +0 -209
- package/dist/composition/utility-tab.d.ts +0 -28
- package/dist/composition/utility-tab.js +0 -244
- package/dist/features/owned-ui/plus-menu-dialog.d.ts +0 -28
- package/dist/features/owned-ui/plus-menu-dialog.js +0 -89
- package/dist/features/resident-tab/auto-name.d.ts +0 -11
- package/dist/features/resident-tab/auto-name.js +0 -44
- package/dist/features/resident-tab/index.d.ts +0 -5
- package/dist/features/resident-tab/index.js +0 -7
- package/dist/features/resident-tab/shortcut-bindings-file.d.ts +0 -8
- package/dist/features/resident-tab/shortcut-bindings-file.js +0 -40
- package/dist/features/resident-tab/shortcut-declarations.d.ts +0 -13
- package/dist/features/resident-tab/shortcut-declarations.js +0 -26
- package/dist/features/resident-tab/shortcut-projection.d.ts +0 -29
- package/dist/features/resident-tab/shortcut-projection.js +0 -64
- package/dist/features/resident-tab/status-deriver.d.ts +0 -10
- package/dist/features/resident-tab/status-deriver.js +0 -12
- package/dist/foundation/launch-guardian/exit-watcher.d.ts +0 -14
- package/dist/foundation/launch-guardian/exit-watcher.js +0 -103
- package/dist/foundation/launch-guardian/index.d.ts +0 -2
- package/dist/foundation/launch-guardian/index.js +0 -1
- package/dist/foundation/launch-guardian/main.d.ts +0 -39
- package/dist/foundation/launch-guardian/main.js +0 -232
- package/dist/foundation/lifecycle/commands.d.ts +0 -40
- package/dist/foundation/lifecycle/commands.js +0 -1
- package/dist/foundation/lifecycle/launch-instance.d.ts +0 -46
- package/dist/foundation/lifecycle/launch-instance.js +0 -134
- package/dist/foundation/lifecycle/native-claim-gate.d.ts +0 -5
- package/dist/foundation/lifecycle/native-claim-gate.js +0 -41
- package/dist/foundation/lifecycle/supervisor-startup.d.ts +0 -30
- package/dist/foundation/lifecycle/supervisor-startup.js +0 -106
- package/dist/foundation/process-containment/addon-containment.d.ts +0 -20
- package/dist/foundation/process-containment/addon-containment.js +0 -139
- package/dist/foundation/process-containment/addon-process-inspector.d.ts +0 -11
- package/dist/foundation/process-containment/addon-process-inspector.js +0 -36
- package/dist/foundation/process-containment/addon.d.ts +0 -47
- package/dist/foundation/process-containment/addon.js +0 -57
- package/dist/foundation/process-containment/artifact.d.ts +0 -1
- package/dist/foundation/process-containment/artifact.js +0 -35
- package/dist/foundation/process-containment/contracts.d.ts +0 -33
- package/dist/foundation/process-containment/contracts.js +0 -35
- package/dist/foundation/process-containment/index.d.ts +0 -9
- package/dist/foundation/process-containment/index.js +0 -7
- package/dist/foundation/process-containment/linux-process-inspector.d.ts +0 -7
- package/dist/foundation/process-containment/linux-process-inspector.js +0 -27
- package/dist/foundation/process-containment/native-process-inspector.d.ts +0 -4
- package/dist/foundation/process-containment/native-process-inspector.js +0 -21
- package/dist/foundation/protocol/client.d.ts +0 -18
- package/dist/foundation/protocol/client.js +0 -130
- package/dist/foundation/protocol/index.d.ts +0 -3
- package/dist/foundation/protocol/index.js +0 -2
- package/dist/foundation/protocol/messages.d.ts +0 -90
- package/dist/foundation/protocol/messages.js +0 -100
- package/dist/foundation/release/cohort-selection.d.ts +0 -33
- package/dist/foundation/release/cohort-selection.js +0 -67
- package/dist/foundation/release/endpoint-lock.d.ts +0 -2
- package/dist/foundation/release/endpoint-lock.js +0 -37
- package/dist/foundation/release/endpoint-recovery.d.ts +0 -10
- package/dist/foundation/release/endpoint-recovery.js +0 -45
- package/dist/foundation/release/endpoints.d.ts +0 -32
- package/dist/foundation/release/endpoints.js +0 -152
- package/dist/foundation/release/prepared-update-activation.d.ts +0 -3
- package/dist/foundation/release/prepared-update-activation.js +0 -27
- package/dist/foundation/release/process-cleanup.d.ts +0 -14
- package/dist/foundation/release/process-cleanup.js +0 -76
- package/dist/foundation/release/supervisor-identity.d.ts +0 -15
- package/dist/foundation/release/supervisor-identity.js +0 -63
- package/dist/foundation/resident-tabs/boot-identity.d.ts +0 -6
- package/dist/foundation/resident-tabs/boot-identity.js +0 -16
- package/dist/foundation/resident-tabs/bounded-host-command.d.ts +0 -20
- package/dist/foundation/resident-tabs/bounded-host-command.js +0 -62
- package/dist/foundation/resident-tabs/bridge-client.d.ts +0 -73
- package/dist/foundation/resident-tabs/bridge-client.js +0 -327
- package/dist/foundation/resident-tabs/continuity.d.ts +0 -12
- package/dist/foundation/resident-tabs/continuity.js +0 -63
- package/dist/foundation/resident-tabs/doctor.d.ts +0 -28
- package/dist/foundation/resident-tabs/doctor.js +0 -166
- package/dist/foundation/resident-tabs/draft-checkpoint.d.ts +0 -27
- package/dist/foundation/resident-tabs/draft-checkpoint.js +0 -145
- package/dist/foundation/resident-tabs/ensure-terminal-host.d.ts +0 -36
- package/dist/foundation/resident-tabs/ensure-terminal-host.js +0 -151
- package/dist/foundation/resident-tabs/fault-injection.d.ts +0 -8
- package/dist/foundation/resident-tabs/fault-injection.js +0 -26
- package/dist/foundation/resident-tabs/fixture-control.d.ts +0 -7
- package/dist/foundation/resident-tabs/fixture-control.js +0 -35
- package/dist/foundation/resident-tabs/host-entry.d.ts +0 -1
- package/dist/foundation/resident-tabs/host-entry.js +0 -17
- package/dist/foundation/resident-tabs/index.d.ts +0 -15
- package/dist/foundation/resident-tabs/index.js +0 -10
- package/dist/foundation/resident-tabs/maintenance.d.ts +0 -39
- package/dist/foundation/resident-tabs/maintenance.js +0 -75
- package/dist/foundation/resident-tabs/progress-observation-schema.d.ts +0 -34
- package/dist/foundation/resident-tabs/progress-observation-schema.js +0 -1
- package/dist/foundation/resident-tabs/progress-observation.d.ts +0 -4
- package/dist/foundation/resident-tabs/progress-observation.js +0 -150
- package/dist/foundation/resident-tabs/prompt-journal.d.ts +0 -63
- package/dist/foundation/resident-tabs/prompt-journal.js +0 -213
- package/dist/foundation/resident-tabs/protocol.d.ts +0 -12
- package/dist/foundation/resident-tabs/protocol.js +0 -195
- package/dist/foundation/resident-tabs/recovery.d.ts +0 -26
- package/dist/foundation/resident-tabs/recovery.js +0 -205
- package/dist/foundation/resident-tabs/release-holds.d.ts +0 -28
- package/dist/foundation/resident-tabs/release-holds.js +0 -78
- package/dist/foundation/resident-tabs/routes.d.ts +0 -5
- package/dist/foundation/resident-tabs/routes.js +0 -5
- package/dist/foundation/resident-tabs/routing.d.ts +0 -11
- package/dist/foundation/resident-tabs/routing.js +0 -10
- package/dist/foundation/resident-tabs/runtime-control.d.ts +0 -38
- package/dist/foundation/resident-tabs/runtime-control.js +0 -74
- package/dist/foundation/resident-tabs/session-sync.d.ts +0 -14
- package/dist/foundation/resident-tabs/session-sync.js +0 -37
- package/dist/foundation/resident-tabs/settings.d.ts +0 -16
- package/dist/foundation/resident-tabs/settings.js +0 -60
- package/dist/foundation/resident-tabs/terminal-host-artifact.d.ts +0 -14
- package/dist/foundation/resident-tabs/terminal-host-artifact.js +0 -78
- package/dist/foundation/resident-tabs/zip-archive.d.ts +0 -9
- package/dist/foundation/resident-tabs/zip-archive.js +0 -56
- package/dist/foundation/storage/control-store.d.ts +0 -20
- package/dist/foundation/storage/control-store.js +0 -331
- package/dist/foundation/storage/index.d.ts +0 -1
- package/dist/foundation/storage/index.js +0 -1
- package/dist/foundation/supervision/index.d.ts +0 -3
- package/dist/foundation/supervision/index.js +0 -3
- package/dist/foundation/supervision/main.d.ts +0 -1
- package/dist/foundation/supervision/main.js +0 -86
- package/dist/foundation/supervision/paths.d.ts +0 -1
- package/dist/foundation/supervision/paths.js +0 -1
- package/dist/foundation/supervision/server.d.ts +0 -46
- package/dist/foundation/supervision/server.js +0 -611
- package/dist/integrations/pi/engine/offline-settings-port.d.ts +0 -23
- package/dist/integrations/pi/engine/offline-settings-port.js +0 -54
- package/dist/native/darwin-arm64/manifest.json +0 -23
- package/dist/native/darwin-arm64/process-guardian.node +0 -0
- package/dist/native/darwin-arm64/terminal-host-THIRD-PARTY-NOTICES.txt +0 -10500
- package/dist/native/darwin-arm64/terminal-host.manifest.json +0 -46
- package/dist/native/darwin-arm64/terminal-host.node +0 -0
- package/dist/native/darwin-x64/manifest.json +0 -23
- package/dist/native/darwin-x64/process-guardian.node +0 -0
- package/dist/native/darwin-x64/terminal-host-THIRD-PARTY-NOTICES.txt +0 -10737
- package/dist/native/darwin-x64/terminal-host.manifest.json +0 -46
- package/dist/native/darwin-x64/terminal-host.node +0 -0
- package/dist/native/linux-x64/manifest.json +0 -23
- package/dist/native/linux-x64/process-guardian.node +0 -0
- package/dist/native/linux-x64/terminal-host-THIRD-PARTY-NOTICES.txt +0 -11226
- package/dist/native/linux-x64/terminal-host.manifest.json +0 -46
- package/dist/native/linux-x64/terminal-host.node +0 -0
- package/dist/native/win32-x64/manifest.json +0 -23
- package/dist/native/win32-x64/process-guardian.node +0 -0
- package/dist/native/win32-x64/terminal-host-THIRD-PARTY-NOTICES.txt +0 -10757
- package/dist/native/win32-x64/terminal-host.manifest.json +0 -46
- package/dist/native/win32-x64/terminal-host.node +0 -0
- package/docs/architecture/evidence/resident-tabs/linux-x64.md +0 -37
- package/docs/architecture/evidence/resident-tabs/macos-arm64.md +0 -36
- package/docs/architecture/evidence/resident-tabs/macos-x64.md +0 -35
- package/docs/architecture/evidence/resident-tabs/windows-x64.md +0 -36
- package/docs/architecture/evidence/terminal-host-spike/manual-one-pane-terminal-host.md +0 -70
- package/docs/architecture/evidence/terminal-host-spike/manual-two-by-two-basic-terminal-host.md +0 -32
- package/docs/architecture/evidence/terminal-host-spike/milestone-baseline.json +0 -115
- package/docs/architecture/evidence/terminal-host-spike/owned-ui-foundation-prerequisite.json +0 -48
- package/docs/architecture/evidence/terminal-host-spike/terminal-host-provenance.json +0 -125
- package/docs/architecture/evidence/terminal-host-spike/terminal-host-task-5-1.json +0 -56
- package/docs/architecture/evidence/terminal-host-spike/terminal-host-task-5-3.json +0 -174
- package/docs/architecture/evidence/terminal-host-spike/terminal-spike-acceptance-record.json +0 -18
- package/docs/architecture/native-fixture-isolation.md +0 -23
- package/docs/architecture/process-guardian-provenance.md +0 -36
- package/docs/architecture/resident-tabs-requirements.md +0 -18
- package/docs/architecture/resident-tabs.md +0 -668
- package/docs/architecture/terminal-host-proof-gate.md +0 -34
- package/docs/architecture/terminal-host-provenance.md +0 -81
- package/docs/architecture/terminal-host-spike-evidence.md +0 -39
- package/docs/launch-recovery.md +0 -23
- package/docs/manual-launch-instance-acceptance.md +0 -43
- package/docs/manual-resident-tabs-acceptance.md +0 -51
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The session presenter's side of a resident tab: recovered input, the idle status it reports to
|
|
3
|
-
* the strip, prompt admission and correlation through the recovery journal, draft checkpoints,
|
|
4
|
-
* detach on quit, and the graceful stop when the presenter is released. Outside a resident tab
|
|
5
|
-
* every operation is a no-op.
|
|
6
|
-
*/
|
|
7
|
-
export class ResidentTabCoordinator {
|
|
8
|
-
#options;
|
|
9
|
-
#ports;
|
|
10
|
-
constructor(options, ports) {
|
|
11
|
-
this.#options = options;
|
|
12
|
-
this.#ports = ports;
|
|
13
|
-
}
|
|
14
|
-
/** True inside a resident tab, where Settings and the session name live in the global strip. */
|
|
15
|
-
get active() {
|
|
16
|
-
return this.#options !== undefined;
|
|
17
|
-
}
|
|
18
|
-
checkpoint(text) {
|
|
19
|
-
this.#options?.checkpoint?.(text);
|
|
20
|
-
}
|
|
21
|
-
closeOwnedRoute(route) {
|
|
22
|
-
this.#options?.closeOwnedRoute?.(route);
|
|
23
|
-
}
|
|
24
|
-
/** Puts the prompts and draft a previous tab process left unfinished back into the editor. */
|
|
25
|
-
restoreInput(imageSidecar) {
|
|
26
|
-
const recovered = this.#options?.recovered;
|
|
27
|
-
if (recovered === undefined)
|
|
28
|
-
return;
|
|
29
|
-
const { root } = this.#ports;
|
|
30
|
-
const prompts = recovered.prompts
|
|
31
|
-
.map(prompt => root.rehydrateHistoryText(prompt.text, id => imageSidecar?.readAttachment(id) ?? null))
|
|
32
|
-
.filter(Boolean);
|
|
33
|
-
if (prompts.length > 0) {
|
|
34
|
-
root.editor.setText(prompts[0]);
|
|
35
|
-
if (recovered.draft)
|
|
36
|
-
root.editor.addToHistory(recovered.draft);
|
|
37
|
-
for (const additional of prompts.slice(1))
|
|
38
|
-
root.editor.addToHistory(additional);
|
|
39
|
-
root.appendWorkflowStatus(recovered.draft
|
|
40
|
-
? `Recovered an unfinished prompt; the prior draft and ${Math.max(0, prompts.length - 1)} additional prompt${prompts.length === 2 ? "" : "s"} are in editor history.`
|
|
41
|
-
: `Recovered an unfinished prompt${prompts.length > 1 ? `; ${prompts.length - 1} additional prompts are in editor history` : ""}.`);
|
|
42
|
-
}
|
|
43
|
-
else if (recovered.draft) {
|
|
44
|
-
root.editor.setText(recovered.draft);
|
|
45
|
-
root.appendWorkflowStatus("Recovered the editor draft from the previous tab process.");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/** Reports idle to the strip whenever the session leaves its busy lifecycle. */
|
|
49
|
-
observeLifecycle(event) {
|
|
50
|
-
if (event.type === "session-lifecycle" && event.lifecycle !== "busy")
|
|
51
|
-
this.#options?.reportStatus?.("idle");
|
|
52
|
-
}
|
|
53
|
-
/** Journals a prompt before it is sent; undefined outside a resident tab. Rejects when the journal cannot sync. */
|
|
54
|
-
admit(input) {
|
|
55
|
-
return this.#options?.admit?.(input) ?? Promise.resolve(undefined);
|
|
56
|
-
}
|
|
57
|
-
/** The admitted prompt reached the engine; its journal entry is correlated with the engine's entry. */
|
|
58
|
-
async dispatched(submissionId, entryId) {
|
|
59
|
-
this.#options?.dispatched?.();
|
|
60
|
-
await this.#options?.correlated?.(submissionId, entryId).catch(() => undefined);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Leaves the tab without stopping its engine. Returns undefined outside a resident tab, true when
|
|
64
|
-
* the client detached, or the notice to show when detaching is unavailable.
|
|
65
|
-
*/
|
|
66
|
-
async detach() {
|
|
67
|
-
const resident = this.#options;
|
|
68
|
-
if (resident === undefined)
|
|
69
|
-
return undefined;
|
|
70
|
-
const detached = await resident.requestDetach().catch(() => false);
|
|
71
|
-
return detached ? true : resident.unavailableNotice ?? "Press Ctrl+C twice to leave; this agent keeps running.";
|
|
72
|
-
}
|
|
73
|
-
gracefulStop(sessionFile) {
|
|
74
|
-
return this.#options?.gracefulStop?.(sessionFile) ?? Promise.resolve();
|
|
75
|
-
}
|
|
76
|
-
dispose() { }
|
|
77
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type TabsAction = "list" | "stop" | "stop-all" | "host-status" | "host-stop" | "doctor";
|
|
2
|
-
/** One parsed `a1 tabs` form. Parsing finishes before any host is contacted. */
|
|
3
|
-
export interface TabsRequest {
|
|
4
|
-
readonly action: TabsAction;
|
|
5
|
-
readonly tabId?: string;
|
|
6
|
-
readonly json: boolean;
|
|
7
|
-
}
|
package/dist/cli/tabs-request.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/cli/tabs.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { runTerminalHostMaintenance, writeDoctorBundle } from "../foundation/resident-tabs/index.js";
|
|
2
|
-
import type { TabsRequest } from "./tabs-request.js";
|
|
3
|
-
export type { TabsRequest } from "./tabs-request.js";
|
|
4
|
-
export interface TabsCommandOptions {
|
|
5
|
-
/** The invoking package, never a different active or retained release. */
|
|
6
|
-
readonly packageRoot?: string;
|
|
7
|
-
readonly environment?: NodeJS.ProcessEnv;
|
|
8
|
-
readonly stdout?: (message: string) => void;
|
|
9
|
-
readonly stderr?: (message: string) => void;
|
|
10
|
-
readonly maintenance?: typeof runTerminalHostMaintenance;
|
|
11
|
-
readonly doctor?: typeof writeDoctorBundle;
|
|
12
|
-
}
|
|
13
|
-
/** `a1 tabs`: inspect or stop resident tabs without attaching, and never start a host to report state. */
|
|
14
|
-
export declare function runTabsCommand(request: TabsRequest, options?: TabsCommandOptions): Promise<number>;
|
package/dist/cli/tabs.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { resolveProductPaths } from "../foundation/lifecycle/index.js";
|
|
2
|
-
import { materializeRelease } from "../foundation/release/index.js";
|
|
3
|
-
import { readResidentTabLaunchSettings, runTerminalHostMaintenance, writeDoctorBundle, } from "../foundation/resident-tabs/index.js";
|
|
4
|
-
import { PRODUCT_IDENTITY, PRODUCT_TEXT } from "../product-identity.js";
|
|
5
|
-
/** `a1 tabs`: inspect or stop resident tabs without attaching, and never start a host to report state. */
|
|
6
|
-
export async function runTabsCommand(request, options = {}) {
|
|
7
|
-
const environment = options.environment ?? process.env;
|
|
8
|
-
const stdout = options.stdout ?? (message => process.stdout.write(message));
|
|
9
|
-
const stderr = options.stderr ?? (message => process.stderr.write(message));
|
|
10
|
-
const paths = resolveProductPaths(environment);
|
|
11
|
-
const profileRoot = environment[PRODUCT_IDENTITY.environment.profileHome] ?? paths.configDir;
|
|
12
|
-
const releaseRoots = await invokingReleaseRoots(paths.dataDir, options.packageRoot, environment);
|
|
13
|
-
const maintenance = options.maintenance ?? runTerminalHostMaintenance;
|
|
14
|
-
const report = await maintenance({
|
|
15
|
-
action: request.action === "doctor" ? "host-status" : request.action,
|
|
16
|
-
...(request.tabId === undefined ? {} : { tabId: request.tabId }),
|
|
17
|
-
profileRoot,
|
|
18
|
-
dataDir: paths.dataDir,
|
|
19
|
-
runtimeDir: paths.runtimeDir,
|
|
20
|
-
releaseRoots,
|
|
21
|
-
environment,
|
|
22
|
-
});
|
|
23
|
-
if (request.action === "doctor") {
|
|
24
|
-
if (!report.stateDir) {
|
|
25
|
-
stderr(`${PRODUCT_TEXT.diagnostic(`tabs doctor could not locate resident state: ${report.message ?? report.host}`)}\n`);
|
|
26
|
-
return 1;
|
|
27
|
-
}
|
|
28
|
-
const settings = await readResidentTabLaunchSettings(environment.PI_CODING_AGENT_DIR ?? paths.configDir, PRODUCT_IDENTITY.commandName, paths.configDir, "a1");
|
|
29
|
-
const bundle = await (options.doctor ?? writeDoctorBundle)({
|
|
30
|
-
stateDir: report.stateDir,
|
|
31
|
-
hostStatus: report,
|
|
32
|
-
releaseRoots,
|
|
33
|
-
settings: { tabsAutoName: settings.tabsAutoName },
|
|
34
|
-
});
|
|
35
|
-
if (request.json)
|
|
36
|
-
stdout(`${JSON.stringify({ schema: "a1-tabs-doctor-v1", path: bundle.path, bytes: bundle.bytes, dropped: bundle.dropped })}\n`);
|
|
37
|
-
else
|
|
38
|
-
stdout(`Wrote ${bundle.path}\n`);
|
|
39
|
-
return 0;
|
|
40
|
-
}
|
|
41
|
-
if (request.json) {
|
|
42
|
-
const { exitCode: _exitCode, ...printed } = report;
|
|
43
|
-
stdout(`${JSON.stringify(printed)}\n`);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const text = describe(request, report);
|
|
47
|
-
if (report.exitCode === 0)
|
|
48
|
-
stdout(text);
|
|
49
|
-
else
|
|
50
|
-
stderr(text);
|
|
51
|
-
}
|
|
52
|
-
return report.exitCode === 0 ? 0 : 1;
|
|
53
|
-
}
|
|
54
|
-
async function invokingReleaseRoots(dataDir, packageRoot, environment) {
|
|
55
|
-
if (!packageRoot)
|
|
56
|
-
return [];
|
|
57
|
-
if (environment[PRODUCT_IDENTITY.environment.developmentInstanceId])
|
|
58
|
-
return [packageRoot];
|
|
59
|
-
try {
|
|
60
|
-
// Invariant: immutable materialization selects exact payload bytes without activating or starting a host.
|
|
61
|
-
return [(await materializeRelease(packageRoot, dataDir)).releaseRoot];
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const NO_TABS = "No resident tabs are running.\n";
|
|
68
|
-
function describe(request, report) {
|
|
69
|
-
const command = PRODUCT_TEXT.commandName;
|
|
70
|
-
if (report.host === "none")
|
|
71
|
-
return NO_TABS;
|
|
72
|
-
if (report.host === "unavailable")
|
|
73
|
-
return `${PRODUCT_TEXT.diagnostic(`tabs could not run maintenance: ${report.message ?? "terminal host unavailable"}`)}\n`;
|
|
74
|
-
if (report.host === "unresponsive") {
|
|
75
|
-
return `The resident host (pid ${report.pid ?? "unknown"}) is not responding. Run \`${command} tabs host stop\` to stop it.\n`;
|
|
76
|
-
}
|
|
77
|
-
if (report.host === "incompatible") {
|
|
78
|
-
return `${PRODUCT_TEXT.diagnostic(report.message ?? "running tabs use another version")} Run \`${command} tabs host stop\` from that version.\n`;
|
|
79
|
-
}
|
|
80
|
-
if (report.host === "unverifiable" || report.host === "refused") {
|
|
81
|
-
return `${PRODUCT_TEXT.diagnostic(report.message ?? "the resident host could not be verified; nothing was changed")}\n`;
|
|
82
|
-
}
|
|
83
|
-
const result = report.result ?? {};
|
|
84
|
-
if (request.action === "list")
|
|
85
|
-
return listing(result);
|
|
86
|
-
if (request.action === "host-status")
|
|
87
|
-
return status(result);
|
|
88
|
-
if (request.action === "host-stop") {
|
|
89
|
-
if (report.host === "stopped")
|
|
90
|
-
return "Stopped every tab and the resident host.\n";
|
|
91
|
-
return `Could not stop every tab: ${remaining(result)}. The host is still running.\n`;
|
|
92
|
-
}
|
|
93
|
-
if (result.accepted === false && typeof result.message === "string") {
|
|
94
|
-
return `${PRODUCT_TEXT.diagnostic(`tabs stop: ${result.message === "unknown tab" ? `no tab ${request.tabId ?? ""}` : result.message}`)}\n`;
|
|
95
|
-
}
|
|
96
|
-
const stopped = Array.isArray(result.stopped) ? result.stopped.length : 0;
|
|
97
|
-
if (result.accepted === false)
|
|
98
|
-
return `Could not stop: ${remaining(result)}.\n`;
|
|
99
|
-
if (request.action === "stop")
|
|
100
|
-
return `Stopped tab ${request.tabId ?? ""}; its session can be resumed.\n`;
|
|
101
|
-
return stopped === 0 ? NO_TABS : `Stopped ${stopped} tab${stopped === 1 ? "" : "s"}; their sessions can be resumed.\n`;
|
|
102
|
-
}
|
|
103
|
-
function remaining(result) {
|
|
104
|
-
return Array.isArray(result.remaining) && result.remaining.length > 0 ? result.remaining.join(", ") : "unknown tabs";
|
|
105
|
-
}
|
|
106
|
-
function listing(result) {
|
|
107
|
-
const tabs = Array.isArray(result.tabs) ? result.tabs : [];
|
|
108
|
-
if (tabs.length === 0)
|
|
109
|
-
return NO_TABS;
|
|
110
|
-
const rows = [
|
|
111
|
-
["ID", "NAME", "STATUS", "CWD", "RELEASE", "HOLDER"],
|
|
112
|
-
...tabs.map(tab => [tab.tabId, tab.name, tab.status, tab.cwd, tab.release, tab.holderPid ?? "-"].map(value => String(value ?? "-"))),
|
|
113
|
-
];
|
|
114
|
-
const widths = rows[0].map((_, column) => Math.max(...rows.map(row => row[column].length)));
|
|
115
|
-
return `${rows.map(row => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column])).join(" ")).join("\n")}\n`;
|
|
116
|
-
}
|
|
117
|
-
function status(result) {
|
|
118
|
-
const limits = (result.limits ?? {});
|
|
119
|
-
const counters = (result.counters ?? {});
|
|
120
|
-
const byStatus = (result.tabsByStatus ?? {});
|
|
121
|
-
const lines = [
|
|
122
|
-
`pid: ${String(result.pid ?? "-")}`,
|
|
123
|
-
`build: ${String(result.build ?? "-")}`,
|
|
124
|
-
`release: ${String(result.release ?? "-")}`,
|
|
125
|
-
`generation: ${String(result.generation ?? "-")}`,
|
|
126
|
-
`epoch: ${String(result.epoch ?? "-")}`,
|
|
127
|
-
`uptime: ${String(result.uptimeSeconds ?? "-")}s`,
|
|
128
|
-
`detachment: ${String(result.detachmentMode ?? "unknown")}${result.detachmentVerified === false ? " (not verified)" : ""}`,
|
|
129
|
-
`tabs: ${String(result.tabs ?? 0)}${Object.keys(byStatus).length > 0 ? ` (${Object.entries(byStatus).map(([key, value]) => `${key} ${String(value)}`).join(", ")})` : ""}`,
|
|
130
|
-
`clients: ${String(result.clients ?? 0)}`,
|
|
131
|
-
...startsAndLifecycle(result),
|
|
132
|
-
`limits: ${Object.entries(limits).map(([key, value]) => `${key} ${String(value)}`).join(", ")}`,
|
|
133
|
-
`counters: ${Object.entries(counters).map(([key, value]) => `${key} ${String(value)}`).join(", ")}`,
|
|
134
|
-
...(Array.isArray(result.logs) ? result.logs.map(path => `log: ${String(path)}`) : []),
|
|
135
|
-
];
|
|
136
|
-
return `${lines.join("\n")}\n`;
|
|
137
|
-
}
|
|
138
|
-
/** Lifecycle work running this long means a terminal's tab requests are stuck. */
|
|
139
|
-
const LIFECYCLE_STALL_MS = 10_000;
|
|
140
|
-
function startsAndLifecycle(result) {
|
|
141
|
-
const lines = [];
|
|
142
|
-
const starts = result.starts;
|
|
143
|
-
if (starts)
|
|
144
|
-
lines.push(`starts: active ${String(starts.active ?? 0)}, waiting ${String(starts.interactiveWaiting ?? 0)}, recovering ${String(starts.recoverySlots ?? 0)}`);
|
|
145
|
-
const lifecycle = result.lifecycle;
|
|
146
|
-
if (lifecycle) {
|
|
147
|
-
const oldest = typeof lifecycle.oldestMs === "number" ? lifecycle.oldestMs : 0;
|
|
148
|
-
lines.push(`lifecycle: pending ${String(lifecycle.pending ?? 0)}, oldest ${oldest}ms${oldest > LIFECYCLE_STALL_MS ? " (stalled)" : ""}`);
|
|
149
|
-
}
|
|
150
|
-
return lines;
|
|
151
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { OwnedUiReleaseUpdate } from "../contracts/owned-ui/index.js";
|
|
2
|
-
import type { TabBridgeClient } from "../foundation/resident-tabs/bridge-client.js";
|
|
3
|
-
import { type ResidentTabRoute } from "../foundation/resident-tabs/routes.js";
|
|
4
|
-
import type { ResidentTabRecovery } from "../foundation/resident-tabs/recovery.js";
|
|
5
|
-
import type { PiKeybindingsHost } from "../integrations/pi/components/shell-shared-facade.js";
|
|
6
|
-
import type { ComposedSessionBackend } from "./session-backend.js";
|
|
7
|
-
import type { OwnedRouteHostOptions } from "./settings-route-host.js";
|
|
8
|
-
/**
|
|
9
|
-
* The keybindings the shells borrow. Inside a resident tab the host dispatches and labels the tab
|
|
10
|
-
* shortcuts this child projects from its effective declarations, so the projection is published now
|
|
11
|
-
* and again after every customization reload.
|
|
12
|
-
*/
|
|
13
|
-
export declare function residentTabKeybindings(tabBridge: TabBridgeClient | null, agentDir: string, keybindingsHost: PiKeybindingsHost): PiKeybindingsHost;
|
|
14
|
-
/**
|
|
15
|
-
* How owned screens are presented in a resident tab: a Settings or Changelog tab's screen is the tab, and the Plus menu entry opens
|
|
16
|
-
* the tab bar's own Plus Menu dialog while this tab's controlling client can show it.
|
|
17
|
-
*/
|
|
18
|
-
export declare function residentRouteHostOptions(tabBridge: TabBridgeClient | null): OwnedRouteHostOptions;
|
|
19
|
-
/** Closes a utility tab when its own screen closes. Invariant: a utility tab's screen is the tab. */
|
|
20
|
-
export declare function closeResidentUtilityRoute(tabBridge: Pick<TabBridgeClient, "tabId" | "requestClose">, route: string): void;
|
|
21
|
-
export declare function bindResidentTabBridge(tabBridge: TabBridgeClient, backend: Pick<ComposedSessionBackend, "identity" | "session" | "workflows" | "generateResidentTabName">, recovery?: Pick<ResidentTabRecovery, "settled"> | null, options?: {
|
|
22
|
-
readonly autoName?: boolean;
|
|
23
|
-
readonly openRoute?: (route: ResidentTabRoute) => void;
|
|
24
|
-
readonly onClientVersion?: (version: string) => void;
|
|
25
|
-
}): Promise<() => void>;
|
|
26
|
-
export declare function createResidentClientIdentity(announce: (update: OwnedUiReleaseUpdate) => void): {
|
|
27
|
-
current: () => string | null;
|
|
28
|
-
onChange: (listener: () => void) => void;
|
|
29
|
-
observe: (next: string) => void;
|
|
30
|
-
};
|
|
31
|
-
/** Input ownership is established before the presenter starts, and released if bridge binding fails. */
|
|
32
|
-
export declare function bindResidentPresentation(bridge: TabBridgeClient | null, backend: Parameters<typeof bindResidentTabBridge>[1], recovery: Parameters<typeof bindResidentTabBridge>[2], options: Parameters<typeof bindResidentTabBridge>[3], input: {
|
|
33
|
-
addPreInputListener(listener: (data: string) => {
|
|
34
|
-
data: string;
|
|
35
|
-
}): () => void;
|
|
36
|
-
}): Promise<{
|
|
37
|
-
unsubscribeTabBridge: () => void;
|
|
38
|
-
removeControllerBoundaryInput: () => void;
|
|
39
|
-
}>;
|
|
40
|
-
export declare function correlateResidentTabSubmission(recovery: Pick<ResidentTabRecovery, "correlated" | "settled">, backend: Pick<ComposedSessionBackend, "identity" | "session">, submissionId: string, entryId: string): Promise<void>;
|
|
41
|
-
export declare function currentBackendSessionFile(backend: Pick<ComposedSessionBackend, "identity">): string | null;
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { residentUtilityRoute } from "../foundation/resident-tabs/routes.js";
|
|
2
|
-
import { deriveResidentTabStatus } from "../features/resident-tab/status-deriver.js";
|
|
3
|
-
import { projectResidentTabShortcuts } from "../features/resident-tab/shortcut-projection.js";
|
|
4
|
-
import { readShortcutBindingsFile } from "../features/resident-tab/shortcut-bindings-file.js";
|
|
5
|
-
/**
|
|
6
|
-
* The keybindings the shells borrow. Inside a resident tab the host dispatches and labels the tab
|
|
7
|
-
* shortcuts this child projects from its effective declarations, so the projection is published now
|
|
8
|
-
* and again after every customization reload.
|
|
9
|
-
*/
|
|
10
|
-
export function residentTabKeybindings(tabBridge, agentDir, keybindingsHost) {
|
|
11
|
-
if (tabBridge === null)
|
|
12
|
-
return keybindingsHost;
|
|
13
|
-
const publish = () => tabBridge.shortcuts(projectResidentTabShortcuts({
|
|
14
|
-
configured: readShortcutBindingsFile(agentDir),
|
|
15
|
-
reserved: keybindingsHost.manager.getEffectiveConfig(),
|
|
16
|
-
}).assignments);
|
|
17
|
-
publish();
|
|
18
|
-
return { ...keybindingsHost, reload: () => { keybindingsHost.reload(); publish(); } };
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* How owned screens are presented in a resident tab: a Settings or Changelog tab's screen is the tab, and the Plus menu entry opens
|
|
22
|
-
* the tab bar's own Plus Menu dialog while this tab's controlling client can show it.
|
|
23
|
-
*/
|
|
24
|
-
export function residentRouteHostOptions(tabBridge) {
|
|
25
|
-
return {
|
|
26
|
-
...(tabBridge === null ? {} : { tabRoute: residentUtilityRoute(tabBridge.tabId) }),
|
|
27
|
-
configurePlusMenu: () => {
|
|
28
|
-
if (tabBridge === null || !tabBridge.available || tabBridge.captureAttachment() === null)
|
|
29
|
-
return false;
|
|
30
|
-
void tabBridge.requestAction("configure-plus");
|
|
31
|
-
return true;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/** Closes a utility tab when its own screen closes. Invariant: a utility tab's screen is the tab. */
|
|
36
|
-
export function closeResidentUtilityRoute(tabBridge, route) {
|
|
37
|
-
if (residentUtilityRoute(tabBridge.tabId) === route)
|
|
38
|
-
void tabBridge.requestClose();
|
|
39
|
-
}
|
|
40
|
-
export async function bindResidentTabBridge(tabBridge, backend, recovery = null, options = {}) {
|
|
41
|
-
await tabBridge.start().catch(() => false);
|
|
42
|
-
tabBridge.status("starting");
|
|
43
|
-
const currentSessionFile = () => currentBackendSessionFile(backend);
|
|
44
|
-
let pendingAutoName = null;
|
|
45
|
-
// Invariant: while a generated name is being applied, the session name it produces is automatic
|
|
46
|
-
// even if the session normalizes it; reporting it as `user` would block the strip's title
|
|
47
|
-
// animation and every later automatic rename.
|
|
48
|
-
let applyingAutoName = false;
|
|
49
|
-
const isDefaultName = (name) => name == null || /^agent(?: \d+)?$/i.test(name);
|
|
50
|
-
const currentSessionName = () => backend.session.view().status.footer?.sessionName ?? null;
|
|
51
|
-
const announceSession = () => {
|
|
52
|
-
const name = currentSessionName();
|
|
53
|
-
// Invariant: the session may announce the applied name after the workflow resolves; the
|
|
54
|
-
// first non-default name announced for a pending auto-name is that automatic name.
|
|
55
|
-
if (applyingAutoName && !isDefaultName(name)) {
|
|
56
|
-
pendingAutoName = name;
|
|
57
|
-
applyingAutoName = false;
|
|
58
|
-
}
|
|
59
|
-
const automatic = name === pendingAutoName;
|
|
60
|
-
const nameSource = automatic ? "auto" : isDefaultName(name) ? "default" : "user";
|
|
61
|
-
tabBridge.session(currentSessionFile(), name, nameSource);
|
|
62
|
-
};
|
|
63
|
-
let working = false;
|
|
64
|
-
// Invariant: the last turn's settlement stays reported until the next turn starts.
|
|
65
|
-
let lastTurn;
|
|
66
|
-
let autoNameAttempted = false;
|
|
67
|
-
let autoNameArmed = false;
|
|
68
|
-
// Invariant: naming launches once per tab during an agent run, as soon as its prompt is projected,
|
|
69
|
-
// and runs beside the turn instead of waiting for it to settle.
|
|
70
|
-
const launchAutoName = () => {
|
|
71
|
-
if (!autoNameArmed || autoNameAttempted || options.autoName !== true || !isDefaultName(currentSessionName()))
|
|
72
|
-
return;
|
|
73
|
-
const prompt = backend.session.view().transcript.find(block => block.kind === "user")?.text.trim();
|
|
74
|
-
if (!prompt)
|
|
75
|
-
return;
|
|
76
|
-
autoNameAttempted = true;
|
|
77
|
-
void import("../features/resident-tab/index.js").then(({ generateAutoName }) => generateAutoName(prompt, request => backend.generateResidentTabName(request.prompt, request.maxTokens, request.signal))).then(async (name) => {
|
|
78
|
-
// Invariant: a manual rename made while generation was pending owns both the session and the tab.
|
|
79
|
-
if (!isDefaultName(currentSessionName()))
|
|
80
|
-
return;
|
|
81
|
-
pendingAutoName = name;
|
|
82
|
-
applyingAutoName = true;
|
|
83
|
-
const result = await backend.workflows.executeWorkflow({ command: "name", argument: name });
|
|
84
|
-
if (result.outcome !== "completed") {
|
|
85
|
-
applyingAutoName = false;
|
|
86
|
-
if (pendingAutoName === name)
|
|
87
|
-
pendingAutoName = null;
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const current = currentSessionName();
|
|
91
|
-
if (current !== null && !isDefaultName(current)) {
|
|
92
|
-
// Invariant: The session already holds the applied name; report it as automatic now.
|
|
93
|
-
pendingAutoName = current;
|
|
94
|
-
applyingAutoName = false;
|
|
95
|
-
tabBridge.session(currentSessionFile(), current, "auto");
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
// Invariant: The session announces later; show the generated name meanwhile, still automatic.
|
|
99
|
-
tabBridge.session(currentSessionFile(), name, "auto");
|
|
100
|
-
}
|
|
101
|
-
}).catch(() => { pendingAutoName = null; applyingAutoName = false; });
|
|
102
|
-
};
|
|
103
|
-
const reportStatus = (lifecycle) => {
|
|
104
|
-
const view = backend.session.view();
|
|
105
|
-
const pendingRequests = view.dialog == null ? 0 : 1;
|
|
106
|
-
const queuedInput = view.editor?.queuedSubmissions.length ?? 0;
|
|
107
|
-
tabBridge.status(deriveResidentTabStatus({
|
|
108
|
-
lifecycle: lifecycle ?? view.lifecycle,
|
|
109
|
-
pendingRequests,
|
|
110
|
-
queuedInput,
|
|
111
|
-
...(lastTurn === undefined ? {} : { lastTurn }),
|
|
112
|
-
}), false, pendingRequests, queuedInput);
|
|
113
|
-
};
|
|
114
|
-
announceSession();
|
|
115
|
-
const unsubscribeCommands = typeof tabBridge.onCommand === "function"
|
|
116
|
-
? tabBridge.onCommand(command => applyBridgeCommand(command, backend, options)) : () => { };
|
|
117
|
-
const unsubscribeEvents = backend.session.onEvent(event => {
|
|
118
|
-
if (event.type === "session-lifecycle") {
|
|
119
|
-
const wasWorking = working;
|
|
120
|
-
working = event.lifecycle === "busy";
|
|
121
|
-
if (working)
|
|
122
|
-
lastTurn = undefined;
|
|
123
|
-
reportStatus(event.lifecycle);
|
|
124
|
-
if (wasWorking && !working && recovery !== null) {
|
|
125
|
-
void recovery.settled(currentSessionFile()).catch(() => tabBridge.degraded(true));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (event.type === "agent-run-started") {
|
|
129
|
-
autoNameArmed = true;
|
|
130
|
-
launchAutoName();
|
|
131
|
-
}
|
|
132
|
-
// Rationale: Pi starts the run before it projects the user message, so the prompt may arrive later.
|
|
133
|
-
if (event.type === "transcript-block" || event.type === "session-view")
|
|
134
|
-
launchAutoName();
|
|
135
|
-
if (event.type === "agent-run-settled") {
|
|
136
|
-
launchAutoName();
|
|
137
|
-
autoNameArmed = false;
|
|
138
|
-
lastTurn = event.aborted ? "aborted" : event.successful ? "done" : "error";
|
|
139
|
-
tabBridge.prompt(event.aborted);
|
|
140
|
-
reportStatus();
|
|
141
|
-
}
|
|
142
|
-
if (event.type === "session-view") {
|
|
143
|
-
announceSession();
|
|
144
|
-
reportStatus();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return () => {
|
|
148
|
-
unsubscribeCommands();
|
|
149
|
-
unsubscribeEvents();
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function applyBridgeCommand(command, backend, options) {
|
|
153
|
-
// Invariant: visibility never pauses resident rendering or autonomous work.
|
|
154
|
-
if (command.type === "client")
|
|
155
|
-
options.onClientVersion?.(command.version);
|
|
156
|
-
else if (command.type === "rename")
|
|
157
|
-
void backend.workflows.executeWorkflow({ command: "name", argument: command.name }).catch(() => { });
|
|
158
|
-
else if (command.type === "route") {
|
|
159
|
-
if (options.openRoute !== undefined)
|
|
160
|
-
options.openRoute(command.route);
|
|
161
|
-
else
|
|
162
|
-
void backend.workflows.executeWorkflow({ command: command.route, argument: "" }).catch(() => { });
|
|
163
|
-
}
|
|
164
|
-
else if (command.type === "stop")
|
|
165
|
-
void backend.session.dispose().catch(() => { });
|
|
166
|
-
}
|
|
167
|
-
export function createResidentClientIdentity(announce) {
|
|
168
|
-
let version = null;
|
|
169
|
-
let changed;
|
|
170
|
-
return {
|
|
171
|
-
current: () => version,
|
|
172
|
-
onChange: (listener) => { changed = listener; },
|
|
173
|
-
observe: (next) => {
|
|
174
|
-
if (next === version)
|
|
175
|
-
return;
|
|
176
|
-
version = next;
|
|
177
|
-
announce({ status: "client-connected", version: next });
|
|
178
|
-
changed?.();
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
/** Input ownership is established before the presenter starts, and released if bridge binding fails. */
|
|
183
|
-
export async function bindResidentPresentation(bridge, backend, recovery, options, input) {
|
|
184
|
-
if (bridge === null)
|
|
185
|
-
return { unsubscribeTabBridge() { }, removeControllerBoundaryInput() { } };
|
|
186
|
-
const removeControllerBoundaryInput = input.addPreInputListener(data => ({ data: bridge.consumeControllerBoundaryInput(data) }));
|
|
187
|
-
try {
|
|
188
|
-
return { unsubscribeTabBridge: await bindResidentTabBridge(bridge, backend, recovery, options), removeControllerBoundaryInput };
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
removeControllerBoundaryInput();
|
|
192
|
-
throw error;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export async function correlateResidentTabSubmission(recovery, backend, submissionId, entryId) {
|
|
196
|
-
await recovery.correlated(submissionId, entryId);
|
|
197
|
-
// Concurrency: a normal prompt command can resolve after the ready transition already fired.
|
|
198
|
-
// Re-read lifecycle only after correlation is active; a concurrent ready observer and this path
|
|
199
|
-
// safely race because recovery consumes the active entry once and retirement is idempotent.
|
|
200
|
-
if (backend.session.view().lifecycle !== "busy")
|
|
201
|
-
await recovery.settled(currentBackendSessionFile(backend));
|
|
202
|
-
}
|
|
203
|
-
export function currentBackendSessionFile(backend) {
|
|
204
|
-
const direct = backend.identity.currentSessionFile?.();
|
|
205
|
-
if (direct !== undefined && direct !== null)
|
|
206
|
-
return direct;
|
|
207
|
-
const resume = backend.identity.currentSessionResumeMetadata();
|
|
208
|
-
return resume === null ? null : `${resume.sessionDir}/${resume.sessionId}`;
|
|
209
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { OwnedUiApplicationPort, PresentationTerminalPort } from "../contracts/presentation/index.js";
|
|
2
|
-
import type { TabBridgeClient } from "../foundation/resident-tabs/bridge-client.js";
|
|
3
|
-
import type { ResidentTabRoute } from "../foundation/resident-tabs/routes.js";
|
|
4
|
-
import type { ReleaseNoteCatalog } from "../features/owned-ui/release-notes.js";
|
|
5
|
-
import type { UiRouteHost } from "../ui/apps/contracts.js";
|
|
6
|
-
import type { OwnedSettingsManager } from "../ui/settings/manager.js";
|
|
7
|
-
import { terminateOwnedUiProcess } from "../features/owned-ui/run.js";
|
|
8
|
-
export { terminateOwnedUiProcess };
|
|
9
|
-
export interface UtilityTabOptions {
|
|
10
|
-
readonly route: ResidentTabRoute;
|
|
11
|
-
readonly bridge: TabBridgeClient;
|
|
12
|
-
readonly cwd?: string;
|
|
13
|
-
readonly profileId?: string;
|
|
14
|
-
readonly terminal?: PresentationTerminalPort;
|
|
15
|
-
readonly agentDir?: string;
|
|
16
|
-
readonly settings?: OwnedSettingsManager;
|
|
17
|
-
readonly routeHost?: UiRouteHost;
|
|
18
|
-
readonly releaseNotes?: ReleaseNoteCatalog;
|
|
19
|
-
readonly onApplication?: (application: OwnedUiApplicationPort) => void;
|
|
20
|
-
}
|
|
21
|
-
export interface UtilityTabComposition {
|
|
22
|
-
readonly application: OwnedUiApplicationPort;
|
|
23
|
-
readonly settings: OwnedSettingsManager;
|
|
24
|
-
}
|
|
25
|
-
/** Runs one pinned Settings or Changelog screen without constructing an Agent engine or session. */
|
|
26
|
-
export declare function runUtilityTab(options: UtilityTabOptions): Promise<number>;
|
|
27
|
-
export declare function composeUtilityTab(options: UtilityTabOptions): Promise<UtilityTabComposition>;
|
|
28
|
-
export declare function utilityAgentDir(environment?: NodeJS.ProcessEnv): string;
|