@celljs/ta-host 4.8.0 → 4.9.1
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.en.md +33 -5
- package/README.md +33 -5
- package/cell.schema.json +4 -0
- package/cell.yml +2 -0
- package/esm/node/client-tool-broker.d.ts +11 -3
- package/esm/node/client-tool-broker.js +23 -3
- package/esm/node/host-protocol.d.ts +22 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +4 -0
- package/esm/node/index.js +4 -0
- package/esm/node/live-run.d.ts +22 -0
- package/esm/node/live-run.js +58 -0
- package/esm/node/message-page.d.ts +17 -0
- package/esm/node/message-page.js +71 -0
- package/esm/node/package-server-impl.d.ts +9 -1
- package/esm/node/package-server-impl.js +16 -1
- package/esm/node/relay-bridge.d.ts +9 -1
- package/esm/node/relay-bridge.js +44 -4
- package/esm/node/session-catalog.d.ts +69 -0
- package/esm/node/session-catalog.js +213 -0
- package/esm/node/session-info-util.d.ts +4 -1
- package/esm/node/session-info-util.js +8 -3
- package/esm/node/settings-store.d.ts +1 -4
- package/esm/node/settings-store.js +11 -3
- package/esm/node/sign-in/access-server-impl.d.ts +19 -0
- package/esm/node/sign-in/access-server-impl.js +82 -0
- package/esm/node/sign-in/access-store.d.ts +65 -0
- package/esm/node/sign-in/access-store.js +175 -0
- package/esm/node/sign-in/index.d.ts +7 -0
- package/esm/node/sign-in/index.js +8 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +58 -0
- package/esm/node/sign-in/sign-in-flow.js +104 -0
- package/esm/node/sign-in/sign-in-middleware.d.ts +10 -0
- package/esm/node/sign-in/sign-in-middleware.js +48 -0
- package/esm/node/sign-in/sign-in-pages.d.ts +31 -0
- package/esm/node/sign-in/sign-in-pages.js +124 -0
- package/esm/node/sign-in/sign-in-provider.d.ts +135 -0
- package/esm/node/sign-in/sign-in-provider.js +225 -0
- package/esm/node/sign-in/ta-sign-in.d.ts +10 -0
- package/esm/node/sign-in/ta-sign-in.js +32 -0
- package/esm/node/ta-access.d.ts +7 -0
- package/esm/node/ta-access.js +30 -1
- package/esm/node/ta-server-impl.d.ts +8 -3
- package/esm/node/ta-server-impl.js +25 -6
- package/esm/node/ta-session-factory.d.ts +1 -1
- package/esm/node/ta-session-factory.js +14 -4
- package/esm/node/ta-session-registry.d.ts +2 -0
- package/esm/node/ta-session-registry.js +23 -3
- package/esm/node/ta-session.d.ts +24 -2
- package/esm/node/ta-session.js +83 -6
- package/esm/node/temporary-packages.d.ts +46 -0
- package/esm/node/temporary-packages.js +114 -0
- package/esm/node/temporary-purge.d.ts +13 -0
- package/esm/node/temporary-purge.js +51 -0
- package/esm/node/web-extension-catalog.d.ts +28 -1
- package/esm/node/web-extension-catalog.js +173 -5
- package/esm/node/web-extension-util.d.ts +5 -1
- package/esm/node/web-extension-util.js +36 -5
- package/esm/node/workspace-service.js +1 -1
- package/lib/node/client-tool-broker.d.ts +11 -3
- package/lib/node/client-tool-broker.js +23 -3
- package/lib/node/host-protocol.d.ts +22 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.js +4 -0
- package/lib/node/live-run.d.ts +23 -0
- package/lib/node/live-run.js +62 -0
- package/lib/node/message-page.d.ts +18 -0
- package/lib/node/message-page.js +74 -0
- package/lib/node/package-server-impl.d.ts +9 -1
- package/lib/node/package-server-impl.js +15 -0
- package/lib/node/relay-bridge.d.ts +9 -1
- package/lib/node/relay-bridge.js +43 -3
- package/lib/node/session-catalog.d.ts +70 -0
- package/lib/node/session-catalog.js +216 -0
- package/lib/node/session-info-util.d.ts +4 -1
- package/lib/node/session-info-util.js +7 -2
- package/lib/node/settings-store.d.ts +1 -4
- package/lib/node/settings-store.js +11 -3
- package/lib/node/sign-in/access-server-impl.d.ts +20 -0
- package/lib/node/sign-in/access-server-impl.js +85 -0
- package/lib/node/sign-in/access-store.d.ts +66 -0
- package/lib/node/sign-in/access-store.js +179 -0
- package/lib/node/sign-in/index.d.ts +8 -0
- package/lib/node/sign-in/index.js +24 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +59 -0
- package/lib/node/sign-in/sign-in-flow.js +108 -0
- package/lib/node/sign-in/sign-in-middleware.d.ts +11 -0
- package/lib/node/sign-in/sign-in-middleware.js +51 -0
- package/lib/node/sign-in/sign-in-pages.d.ts +32 -0
- package/lib/node/sign-in/sign-in-pages.js +127 -0
- package/lib/node/sign-in/sign-in-provider.d.ts +136 -0
- package/lib/node/sign-in/sign-in-provider.js +232 -0
- package/lib/node/sign-in/ta-sign-in.d.ts +11 -0
- package/lib/node/sign-in/ta-sign-in.js +35 -0
- package/lib/node/ta-access.d.ts +7 -0
- package/lib/node/ta-access.js +30 -1
- package/lib/node/ta-server-impl.d.ts +8 -3
- package/lib/node/ta-server-impl.js +24 -5
- package/lib/node/ta-session-factory.d.ts +1 -1
- package/lib/node/ta-session-factory.js +14 -4
- package/lib/node/ta-session-registry.d.ts +2 -0
- package/lib/node/ta-session-registry.js +23 -3
- package/lib/node/ta-session.d.ts +24 -2
- package/lib/node/ta-session.js +83 -6
- package/lib/node/temporary-packages.d.ts +47 -0
- package/lib/node/temporary-packages.js +118 -0
- package/lib/node/temporary-purge.d.ts +14 -0
- package/lib/node/temporary-purge.js +54 -0
- package/lib/node/web-extension-catalog.d.ts +28 -1
- package/lib/node/web-extension-catalog.js +172 -4
- package/lib/node/web-extension-util.d.ts +5 -1
- package/lib/node/web-extension-util.js +36 -5
- package/lib/node/workspace-service.js +1 -1
- package/package.json +17 -12
- package/esm/node/auth-server-impl.js.map +0 -1
- package/esm/node/client-channel.js.map +0 -1
- package/esm/node/client-tool-broker.js.map +0 -1
- package/esm/node/event-log.js.map +0 -1
- package/esm/node/exec-environment-factory.js.map +0 -1
- package/esm/node/extension-data-notifier.js.map +0 -1
- package/esm/node/extension-data.js.map +0 -1
- package/esm/node/extension-providers.js.map +0 -1
- package/esm/node/host-protocol.js.map +0 -1
- package/esm/node/index.js.map +0 -1
- package/esm/node/module.js.map +0 -1
- package/esm/node/package-host-extension.js.map +0 -1
- package/esm/node/package-hosts.js.map +0 -1
- package/esm/node/package-server-impl.js.map +0 -1
- package/esm/node/package-switch.js.map +0 -1
- package/esm/node/receipt-book.js.map +0 -1
- package/esm/node/relay-bridge.js.map +0 -1
- package/esm/node/remote/index.js.map +0 -1
- package/esm/node/remote/pi-directories.js.map +0 -1
- package/esm/node/remote/port-forwards.js.map +0 -1
- package/esm/node/remote/remote-hosts.js.map +0 -1
- package/esm/node/remote/remote-protocol.js.map +0 -1
- package/esm/node/remote/remote-server-impl.js.map +0 -1
- package/esm/node/remote-ui-context.js.map +0 -1
- package/esm/node/session-files.js.map +0 -1
- package/esm/node/session-info-util.js.map +0 -1
- package/esm/node/session-storage/file-session-storage.js.map +0 -1
- package/esm/node/session-storage/index.js.map +0 -1
- package/esm/node/session-storage/session-storage-protocol.js.map +0 -1
- package/esm/node/session-storage/stored-session.js.map +0 -1
- package/esm/node/settings-server-impl.js.map +0 -1
- package/esm/node/settings-store.js.map +0 -1
- package/esm/node/ta-access.js.map +0 -1
- package/esm/node/ta-errors.js.map +0 -1
- package/esm/node/ta-event-util.js.map +0 -1
- package/esm/node/ta-server-impl.js.map +0 -1
- package/esm/node/ta-session-factory.js.map +0 -1
- package/esm/node/ta-session-registry.js.map +0 -1
- package/esm/node/ta-session.js.map +0 -1
- package/esm/node/terminal-protocol.js.map +0 -1
- package/esm/node/terminal-service.js.map +0 -1
- package/esm/node/terminal-util.js.map +0 -1
- package/esm/node/web-extension-catalog.js.map +0 -1
- package/esm/node/web-extension-util.js.map +0 -1
- package/esm/node/working-directory.js.map +0 -1
- package/esm/node/workspace-files.js.map +0 -1
- package/esm/node/workspace-protocol.js.map +0 -1
- package/esm/node/workspace-server-impl.js.map +0 -1
- package/esm/node/workspace-service.js.map +0 -1
- package/esm/node/workspace-util.js.map +0 -1
- package/lib/node/auth-server-impl.d.ts.map +0 -1
- package/lib/node/auth-server-impl.js.map +0 -1
- package/lib/node/auth-server-impl.spec.d.ts +0 -2
- package/lib/node/auth-server-impl.spec.d.ts.map +0 -1
- package/lib/node/auth-server-impl.spec.js +0 -47
- package/lib/node/auth-server-impl.spec.js.map +0 -1
- package/lib/node/client-channel.d.ts.map +0 -1
- package/lib/node/client-channel.js.map +0 -1
- package/lib/node/client-channel.spec.d.ts +0 -2
- package/lib/node/client-channel.spec.d.ts.map +0 -1
- package/lib/node/client-channel.spec.js +0 -106
- package/lib/node/client-channel.spec.js.map +0 -1
- package/lib/node/client-tool-broker.d.ts.map +0 -1
- package/lib/node/client-tool-broker.js.map +0 -1
- package/lib/node/client-tool-broker.spec.d.ts +0 -2
- package/lib/node/client-tool-broker.spec.d.ts.map +0 -1
- package/lib/node/client-tool-broker.spec.js +0 -49
- package/lib/node/client-tool-broker.spec.js.map +0 -1
- package/lib/node/event-log.d.ts.map +0 -1
- package/lib/node/event-log.js.map +0 -1
- package/lib/node/event-log.spec.d.ts +0 -2
- package/lib/node/event-log.spec.d.ts.map +0 -1
- package/lib/node/event-log.spec.js +0 -48
- package/lib/node/event-log.spec.js.map +0 -1
- package/lib/node/exec-environment-factory.d.ts.map +0 -1
- package/lib/node/exec-environment-factory.js.map +0 -1
- package/lib/node/extension-data-notifier.d.ts.map +0 -1
- package/lib/node/extension-data-notifier.js.map +0 -1
- package/lib/node/extension-data-notifier.spec.d.ts +0 -2
- package/lib/node/extension-data-notifier.spec.d.ts.map +0 -1
- package/lib/node/extension-data-notifier.spec.js +0 -35
- package/lib/node/extension-data-notifier.spec.js.map +0 -1
- package/lib/node/extension-data.d.ts.map +0 -1
- package/lib/node/extension-data.js.map +0 -1
- package/lib/node/extension-data.spec.d.ts +0 -2
- package/lib/node/extension-data.spec.d.ts.map +0 -1
- package/lib/node/extension-data.spec.js +0 -99
- package/lib/node/extension-data.spec.js.map +0 -1
- package/lib/node/extension-providers.d.ts.map +0 -1
- package/lib/node/extension-providers.js.map +0 -1
- package/lib/node/host-protocol.d.ts.map +0 -1
- package/lib/node/host-protocol.js.map +0 -1
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/index.js.map +0 -1
- package/lib/node/module.d.ts.map +0 -1
- package/lib/node/module.js.map +0 -1
- package/lib/node/package-host-extension.d.ts.map +0 -1
- package/lib/node/package-host-extension.js.map +0 -1
- package/lib/node/package-hosts.d.ts.map +0 -1
- package/lib/node/package-hosts.js.map +0 -1
- package/lib/node/package-hosts.spec.d.ts +0 -2
- package/lib/node/package-hosts.spec.d.ts.map +0 -1
- package/lib/node/package-hosts.spec.js +0 -53
- package/lib/node/package-hosts.spec.js.map +0 -1
- package/lib/node/package-server-impl.d.ts.map +0 -1
- package/lib/node/package-server-impl.js.map +0 -1
- package/lib/node/package-switch.d.ts.map +0 -1
- package/lib/node/package-switch.js.map +0 -1
- package/lib/node/receipt-book.d.ts.map +0 -1
- package/lib/node/receipt-book.js.map +0 -1
- package/lib/node/receipt-book.spec.d.ts +0 -2
- package/lib/node/receipt-book.spec.d.ts.map +0 -1
- package/lib/node/receipt-book.spec.js +0 -39
- package/lib/node/receipt-book.spec.js.map +0 -1
- package/lib/node/relay-bridge.d.ts.map +0 -1
- package/lib/node/relay-bridge.js.map +0 -1
- package/lib/node/remote/index.d.ts.map +0 -1
- package/lib/node/remote/index.js.map +0 -1
- package/lib/node/remote/pi-directories.d.ts.map +0 -1
- package/lib/node/remote/pi-directories.js.map +0 -1
- package/lib/node/remote/port-forwards.d.ts.map +0 -1
- package/lib/node/remote/port-forwards.js.map +0 -1
- package/lib/node/remote/remote-hosts.d.ts.map +0 -1
- package/lib/node/remote/remote-hosts.js.map +0 -1
- package/lib/node/remote/remote-protocol.d.ts.map +0 -1
- package/lib/node/remote/remote-protocol.js.map +0 -1
- package/lib/node/remote/remote-server-impl.d.ts.map +0 -1
- package/lib/node/remote/remote-server-impl.js.map +0 -1
- package/lib/node/remote/remote.spec.d.ts +0 -2
- package/lib/node/remote/remote.spec.d.ts.map +0 -1
- package/lib/node/remote/remote.spec.js +0 -130
- package/lib/node/remote/remote.spec.js.map +0 -1
- package/lib/node/remote-ui-context.d.ts.map +0 -1
- package/lib/node/remote-ui-context.js.map +0 -1
- package/lib/node/remote-ui-context.spec.d.ts +0 -2
- package/lib/node/remote-ui-context.spec.d.ts.map +0 -1
- package/lib/node/remote-ui-context.spec.js +0 -85
- package/lib/node/remote-ui-context.spec.js.map +0 -1
- package/lib/node/session-files.d.ts.map +0 -1
- package/lib/node/session-files.js.map +0 -1
- package/lib/node/session-files.spec.d.ts +0 -2
- package/lib/node/session-files.spec.d.ts.map +0 -1
- package/lib/node/session-files.spec.js +0 -51
- package/lib/node/session-files.spec.js.map +0 -1
- package/lib/node/session-info-util.d.ts.map +0 -1
- package/lib/node/session-info-util.js.map +0 -1
- package/lib/node/session-info-util.spec.d.ts +0 -2
- package/lib/node/session-info-util.spec.d.ts.map +0 -1
- package/lib/node/session-info-util.spec.js +0 -22
- package/lib/node/session-info-util.spec.js.map +0 -1
- package/lib/node/session-storage/file-session-storage.d.ts.map +0 -1
- package/lib/node/session-storage/file-session-storage.js.map +0 -1
- package/lib/node/session-storage/file-session-storage.spec.d.ts +0 -2
- package/lib/node/session-storage/file-session-storage.spec.d.ts.map +0 -1
- package/lib/node/session-storage/file-session-storage.spec.js +0 -70
- package/lib/node/session-storage/file-session-storage.spec.js.map +0 -1
- package/lib/node/session-storage/index.d.ts.map +0 -1
- package/lib/node/session-storage/index.js.map +0 -1
- package/lib/node/session-storage/session-storage-protocol.d.ts.map +0 -1
- package/lib/node/session-storage/session-storage-protocol.js.map +0 -1
- package/lib/node/session-storage/stored-session.d.ts.map +0 -1
- package/lib/node/session-storage/stored-session.js.map +0 -1
- package/lib/node/session-storage/stored-session.spec.d.ts +0 -2
- package/lib/node/session-storage/stored-session.spec.d.ts.map +0 -1
- package/lib/node/session-storage/stored-session.spec.js +0 -73
- package/lib/node/session-storage/stored-session.spec.js.map +0 -1
- package/lib/node/settings-server-impl.d.ts.map +0 -1
- package/lib/node/settings-server-impl.js.map +0 -1
- package/lib/node/settings-store.d.ts.map +0 -1
- package/lib/node/settings-store.js.map +0 -1
- package/lib/node/settings-store.spec.d.ts +0 -2
- package/lib/node/settings-store.spec.d.ts.map +0 -1
- package/lib/node/settings-store.spec.js +0 -148
- package/lib/node/settings-store.spec.js.map +0 -1
- package/lib/node/ta-access.d.ts.map +0 -1
- package/lib/node/ta-access.js.map +0 -1
- package/lib/node/ta-access.spec.d.ts +0 -2
- package/lib/node/ta-access.spec.d.ts.map +0 -1
- package/lib/node/ta-access.spec.js +0 -33
- package/lib/node/ta-access.spec.js.map +0 -1
- package/lib/node/ta-errors.d.ts.map +0 -1
- package/lib/node/ta-errors.js.map +0 -1
- package/lib/node/ta-errors.spec.d.ts +0 -2
- package/lib/node/ta-errors.spec.d.ts.map +0 -1
- package/lib/node/ta-errors.spec.js +0 -25
- package/lib/node/ta-errors.spec.js.map +0 -1
- package/lib/node/ta-event-util.d.ts.map +0 -1
- package/lib/node/ta-event-util.js.map +0 -1
- package/lib/node/ta-event-util.spec.d.ts +0 -2
- package/lib/node/ta-event-util.spec.d.ts.map +0 -1
- package/lib/node/ta-event-util.spec.js +0 -28
- package/lib/node/ta-event-util.spec.js.map +0 -1
- package/lib/node/ta-server-impl.d.ts.map +0 -1
- package/lib/node/ta-server-impl.js.map +0 -1
- package/lib/node/ta-session-factory.d.ts.map +0 -1
- package/lib/node/ta-session-factory.js.map +0 -1
- package/lib/node/ta-session-registry.d.ts.map +0 -1
- package/lib/node/ta-session-registry.js.map +0 -1
- package/lib/node/ta-session.d.ts.map +0 -1
- package/lib/node/ta-session.js.map +0 -1
- package/lib/node/terminal-protocol.d.ts.map +0 -1
- package/lib/node/terminal-protocol.js.map +0 -1
- package/lib/node/terminal-service.d.ts.map +0 -1
- package/lib/node/terminal-service.js.map +0 -1
- package/lib/node/terminal-service.spec.d.ts +0 -2
- package/lib/node/terminal-service.spec.d.ts.map +0 -1
- package/lib/node/terminal-service.spec.js +0 -110
- package/lib/node/terminal-service.spec.js.map +0 -1
- package/lib/node/terminal-util.d.ts.map +0 -1
- package/lib/node/terminal-util.js.map +0 -1
- package/lib/node/terminal-util.spec.d.ts +0 -2
- package/lib/node/terminal-util.spec.d.ts.map +0 -1
- package/lib/node/terminal-util.spec.js +0 -95
- package/lib/node/terminal-util.spec.js.map +0 -1
- package/lib/node/web-extension-catalog.d.ts.map +0 -1
- package/lib/node/web-extension-catalog.js.map +0 -1
- package/lib/node/web-extension-catalog.spec.d.ts +0 -2
- package/lib/node/web-extension-catalog.spec.d.ts.map +0 -1
- package/lib/node/web-extension-catalog.spec.js +0 -157
- package/lib/node/web-extension-catalog.spec.js.map +0 -1
- package/lib/node/web-extension-util.d.ts.map +0 -1
- package/lib/node/web-extension-util.js.map +0 -1
- package/lib/node/working-directory.d.ts.map +0 -1
- package/lib/node/working-directory.js.map +0 -1
- package/lib/node/workspace-files.d.ts.map +0 -1
- package/lib/node/workspace-files.js.map +0 -1
- package/lib/node/workspace-files.spec.d.ts +0 -2
- package/lib/node/workspace-files.spec.d.ts.map +0 -1
- package/lib/node/workspace-files.spec.js +0 -133
- package/lib/node/workspace-files.spec.js.map +0 -1
- package/lib/node/workspace-protocol.d.ts.map +0 -1
- package/lib/node/workspace-protocol.js.map +0 -1
- package/lib/node/workspace-server-impl.d.ts.map +0 -1
- package/lib/node/workspace-server-impl.js.map +0 -1
- package/lib/node/workspace-service.d.ts.map +0 -1
- package/lib/node/workspace-service.js.map +0 -1
- package/lib/node/workspace-service.spec.d.ts +0 -2
- package/lib/node/workspace-service.spec.d.ts.map +0 -1
- package/lib/node/workspace-service.spec.js +0 -113
- package/lib/node/workspace-service.spec.js.map +0 -1
- package/lib/node/workspace-util.d.ts.map +0 -1
- package/lib/node/workspace-util.js.map +0 -1
- package/lib/node/workspace-util.spec.d.ts +0 -2
- package/lib/node/workspace-util.spec.d.ts.map +0 -1
- package/lib/node/workspace-util.spec.js +0 -44
- package/lib/node/workspace-util.spec.js.map +0 -1
- package/src/node/auth-server-impl.spec.ts +0 -49
- package/src/node/auth-server-impl.ts +0 -258
- package/src/node/client-channel.spec.ts +0 -117
- package/src/node/client-channel.ts +0 -94
- package/src/node/client-tool-broker.spec.ts +0 -53
- package/src/node/client-tool-broker.ts +0 -106
- package/src/node/event-log.spec.ts +0 -52
- package/src/node/event-log.ts +0 -59
- package/src/node/exec-environment-factory.ts +0 -66
- package/src/node/extension-data-notifier.spec.ts +0 -34
- package/src/node/extension-data-notifier.ts +0 -124
- package/src/node/extension-data.spec.ts +0 -105
- package/src/node/extension-data.ts +0 -180
- package/src/node/extension-providers.ts +0 -49
- package/src/node/host-protocol.ts +0 -62
- package/src/node/index.ts +0 -39
- package/src/node/module.ts +0 -4
- package/src/node/package-host-extension.ts +0 -23
- package/src/node/package-hosts.spec.ts +0 -54
- package/src/node/package-hosts.ts +0 -204
- package/src/node/package-server-impl.ts +0 -87
- package/src/node/package-switch.ts +0 -80
- package/src/node/receipt-book.spec.ts +0 -41
- package/src/node/receipt-book.ts +0 -40
- package/src/node/relay-bridge.ts +0 -94
- package/src/node/remote/index.ts +0 -5
- package/src/node/remote/pi-directories.ts +0 -49
- package/src/node/remote/port-forwards.ts +0 -148
- package/src/node/remote/remote-hosts.ts +0 -170
- package/src/node/remote/remote-protocol.ts +0 -57
- package/src/node/remote/remote-server-impl.ts +0 -60
- package/src/node/remote/remote.spec.ts +0 -142
- package/src/node/remote-ui-context.spec.ts +0 -93
- package/src/node/remote-ui-context.ts +0 -197
- package/src/node/session-files.spec.ts +0 -52
- package/src/node/session-files.ts +0 -41
- package/src/node/session-info-util.spec.ts +0 -23
- package/src/node/session-info-util.ts +0 -55
- package/src/node/session-storage/file-session-storage.spec.ts +0 -72
- package/src/node/session-storage/file-session-storage.ts +0 -145
- package/src/node/session-storage/index.ts +0 -3
- package/src/node/session-storage/session-storage-protocol.ts +0 -81
- package/src/node/session-storage/stored-session.spec.ts +0 -80
- package/src/node/session-storage/stored-session.ts +0 -149
- package/src/node/settings-server-impl.ts +0 -42
- package/src/node/settings-store.spec.ts +0 -158
- package/src/node/settings-store.ts +0 -327
- package/src/node/ta-access.spec.ts +0 -36
- package/src/node/ta-access.ts +0 -156
- package/src/node/ta-errors.spec.ts +0 -25
- package/src/node/ta-errors.ts +0 -75
- package/src/node/ta-event-util.spec.ts +0 -29
- package/src/node/ta-event-util.ts +0 -23
- package/src/node/ta-server-impl.ts +0 -341
- package/src/node/ta-session-factory.ts +0 -216
- package/src/node/ta-session-registry.ts +0 -75
- package/src/node/ta-session.ts +0 -241
- package/src/node/terminal-protocol.ts +0 -18
- package/src/node/terminal-service.spec.ts +0 -119
- package/src/node/terminal-service.ts +0 -291
- package/src/node/terminal-util.spec.ts +0 -109
- package/src/node/terminal-util.ts +0 -197
- package/src/node/web-extension-catalog.spec.ts +0 -172
- package/src/node/web-extension-catalog.ts +0 -177
- package/src/node/web-extension-util.ts +0 -144
- package/src/node/working-directory.ts +0 -71
- package/src/node/workspace-files.spec.ts +0 -145
- package/src/node/workspace-files.ts +0 -256
- package/src/node/workspace-protocol.ts +0 -24
- package/src/node/workspace-server-impl.ts +0 -108
- package/src/node/workspace-service.spec.ts +0 -123
- package/src/node/workspace-service.ts +0 -235
- package/src/node/workspace-util.spec.ts +0 -47
- package/src/node/workspace-util.ts +0 -103
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { resolve, sep } from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
AgentExtension,
|
|
4
|
-
AgentTool,
|
|
5
|
-
AgentToolUtil,
|
|
6
|
-
CODING_AGENT_OPTIONS,
|
|
7
|
-
type CodingAgentOptions,
|
|
8
|
-
ModelRuntimeProvider,
|
|
9
|
-
type PiSdk,
|
|
10
|
-
PiSdkUtil,
|
|
11
|
-
} from '@celljs/ai-coding-agent';
|
|
12
|
-
import { Autowired, Component, Optional, Value } from '@celljs/core';
|
|
13
|
-
import { type ExecEnvironment, ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
14
|
-
import {
|
|
15
|
-
BrandExtension,
|
|
16
|
-
type ContextFile,
|
|
17
|
-
ExecExtension,
|
|
18
|
-
ExecMcpTransport,
|
|
19
|
-
type InlineExtension,
|
|
20
|
-
type McpServerEntry,
|
|
21
|
-
RemoteContextFiles,
|
|
22
|
-
SessionLock,
|
|
23
|
-
SessionLockExtension,
|
|
24
|
-
TaExtensionUtil,
|
|
25
|
-
TaPackages,
|
|
26
|
-
} from '@celljs/ta-harness';
|
|
27
|
-
import type { TaOpenSessionOptions } from '@celljs/ta-protocol';
|
|
28
|
-
import { ClientToolBroker } from './client-tool-broker';
|
|
29
|
-
import { ExtensionProviders } from './extension-providers';
|
|
30
|
-
import { TA_HOST_OPTIONS, type TaHostOptions, TaSessionFactory } from './host-protocol';
|
|
31
|
-
import { PackageHostExtension } from './package-host-extension';
|
|
32
|
-
import { PackageHosts } from './package-hosts';
|
|
33
|
-
import { PiDirectories } from './remote/remote-protocol';
|
|
34
|
-
import { ExecSessionFiles } from './session-files';
|
|
35
|
-
import { TaErrors } from './ta-errors';
|
|
36
|
-
import { TaSession } from './ta-session';
|
|
37
|
-
|
|
38
|
-
type AgentsFilesOverride = (base: { agentsFiles: ContextFile[] }) => { agentsFiles: ContextFile[] };
|
|
39
|
-
type ModelRuntime = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' }}).ModelRuntime;
|
|
40
|
-
type SessionManager = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' }}).SessionManager;
|
|
41
|
-
type Model = NonNullable<import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' }}).AgentSession['model']>;
|
|
42
|
-
|
|
43
|
-
/** Sets up pi for each session the way its command does, with one model runtime for all of them. */
|
|
44
|
-
@Component(TaSessionFactory)
|
|
45
|
-
export class DefaultTaSessionFactory implements TaSessionFactory {
|
|
46
|
-
@Value(TA_HOST_OPTIONS)
|
|
47
|
-
protected readonly options: TaHostOptions;
|
|
48
|
-
|
|
49
|
-
@Value(CODING_AGENT_OPTIONS)
|
|
50
|
-
protected readonly codingAgentOptions?: CodingAgentOptions;
|
|
51
|
-
|
|
52
|
-
@Autowired(ModelRuntimeProvider)
|
|
53
|
-
protected readonly modelRuntimeProvider: ModelRuntimeProvider;
|
|
54
|
-
|
|
55
|
-
@Autowired(ExecEnvironmentFactory)
|
|
56
|
-
protected readonly environments: ExecEnvironmentFactory;
|
|
57
|
-
|
|
58
|
-
@Autowired(AgentExtension)
|
|
59
|
-
@Optional()
|
|
60
|
-
protected readonly extensions: AgentExtension[] = [];
|
|
61
|
-
|
|
62
|
-
@Autowired(AgentTool)
|
|
63
|
-
@Optional()
|
|
64
|
-
protected readonly tools: AgentTool[] = [];
|
|
65
|
-
|
|
66
|
-
@Autowired(PackageHosts)
|
|
67
|
-
protected readonly packageHosts: PackageHosts;
|
|
68
|
-
|
|
69
|
-
@Autowired(PiDirectories)
|
|
70
|
-
protected readonly directories: PiDirectories;
|
|
71
|
-
|
|
72
|
-
@Autowired(ExtensionProviders)
|
|
73
|
-
protected readonly extensionProviders: ExtensionProviders;
|
|
74
|
-
|
|
75
|
-
async create(options: TaOpenSessionOptions, requestClose: (session: TaSession) => void): Promise<TaSession> {
|
|
76
|
-
const clientTools = new ClientToolBroker(options.clientTools);
|
|
77
|
-
const sdk = await PiSdkUtil.load();
|
|
78
|
-
const agentDir = this.codingAgentOptions?.agentDir ?? sdk.getAgentDir();
|
|
79
|
-
const modelRuntime = await this.modelRuntimeProvider.provide();
|
|
80
|
-
// `options.cwd` is a location; pi works in a directory of this machine (PiDirectories). A session
|
|
81
|
-
// file works where its header says, as pi's `--session` does, whatever `cwd` the caller gave.
|
|
82
|
-
const sessionManager = this.openSessionManager(sdk, { ...options, cwd: this.directories.toPi(options.cwd) });
|
|
83
|
-
const piCwd = options.sessionFile ? sessionManager.getCwd() : this.directories.toPi(options.cwd);
|
|
84
|
-
const lock = new SessionLock();
|
|
85
|
-
const sessionFile = sessionManager.getSessionFile();
|
|
86
|
-
if (sessionFile && !lock.acquire(sessionFile)) {
|
|
87
|
-
throw TaErrors.sessionLocked(sessionFile);
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
if (options.model && !this.findModel(modelRuntime, options.model)) {
|
|
91
|
-
// A model of a pi package, whose provider is there once the package loaded.
|
|
92
|
-
await this.extensionProviders.ensure();
|
|
93
|
-
}
|
|
94
|
-
const model = options.model ? this.resolveModel(modelRuntime, options.model) : undefined;
|
|
95
|
-
const runtime = await sdk.createAgentSessionRuntime(
|
|
96
|
-
async ({ cwd, agentDir: dir, sessionManager: manager, sessionStartEvent }) => {
|
|
97
|
-
const environment = this.environments.create(this.directories.fromPi(cwd));
|
|
98
|
-
const settingsManager = sdk.SettingsManager.create(cwd, dir, { projectTrusted: this.isTrusted(sdk, cwd, dir) });
|
|
99
|
-
const services = await sdk.createAgentSessionServices({
|
|
100
|
-
cwd,
|
|
101
|
-
agentDir: dir,
|
|
102
|
-
settingsManager,
|
|
103
|
-
modelRuntime,
|
|
104
|
-
resourceLoaderOptions: {
|
|
105
|
-
...TaPackages.loaderOptions(dir),
|
|
106
|
-
...(await this.contextFiles(environment, dir)),
|
|
107
|
-
extensionFactories: this.extensionFactories(sdk, environment, cwd, lock),
|
|
108
|
-
appendSystemPrompt: options.appendSystemPrompt ? [options.appendSystemPrompt] : undefined,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
const created = await sdk.createAgentSessionFromServices({
|
|
112
|
-
services,
|
|
113
|
-
sessionManager: manager,
|
|
114
|
-
sessionStartEvent,
|
|
115
|
-
model,
|
|
116
|
-
thinkingLevel: options.thinkingLevel,
|
|
117
|
-
customTools: [...(this.tools ?? []).map(AgentToolUtil.toToolDefinition), ...clientTools.tools()],
|
|
118
|
-
});
|
|
119
|
-
return { ...created, services, diagnostics: services.diagnostics };
|
|
120
|
-
},
|
|
121
|
-
{ cwd: piCwd, agentDir, sessionManager },
|
|
122
|
-
);
|
|
123
|
-
const session = new TaSession({
|
|
124
|
-
runtime,
|
|
125
|
-
lock,
|
|
126
|
-
clientTools,
|
|
127
|
-
options: this.options,
|
|
128
|
-
requestClose,
|
|
129
|
-
group: options.group,
|
|
130
|
-
locate: cwd => this.directories.fromPi(cwd),
|
|
131
|
-
});
|
|
132
|
-
await session.start();
|
|
133
|
-
return session;
|
|
134
|
-
} catch (error) {
|
|
135
|
-
lock.releaseAll();
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
protected openSessionManager(sdk: PiSdk, options: TaOpenSessionOptions): SessionManager {
|
|
141
|
-
if (!options.sessionFile) {
|
|
142
|
-
return sdk.SessionManager.create(options.cwd);
|
|
143
|
-
}
|
|
144
|
-
try {
|
|
145
|
-
return sdk.SessionManager.open(options.sessionFile);
|
|
146
|
-
} catch (error) {
|
|
147
|
-
throw TaErrors.invalidArgument(
|
|
148
|
-
`Cannot open the session ${options.sessionFile}: ${(error as Error).message}`,
|
|
149
|
-
'Pass a session file that exists; listSessions shows the open ones.',
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* For another machine, its context files (AGENTS.md...) instead of those pi finds above the directory
|
|
156
|
-
* of this machine it works in; the user's own, in the agent directory, stay.
|
|
157
|
-
*/
|
|
158
|
-
protected async contextFiles(environment: ExecEnvironment, agentDir: string): Promise<{ agentsFilesOverride?: AgentsFilesOverride }> {
|
|
159
|
-
if (environment.local) {
|
|
160
|
-
return {};
|
|
161
|
-
}
|
|
162
|
-
const remote = await RemoteContextFiles.load(environment).catch(() => []);
|
|
163
|
-
const own = resolve(agentDir) + sep;
|
|
164
|
-
return { agentsFilesOverride: ({ agentsFiles }) => ({ agentsFiles: [...agentsFiles.filter(file => resolve(file.path).startsWith(own)), ...remote] }) };
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
protected extensionFactories(sdk: PiSdk, environment: ExecEnvironment, piCwd: string, lock: SessionLock): InlineExtension[] {
|
|
168
|
-
const builtIn = [
|
|
169
|
-
new SessionLockExtension(lock),
|
|
170
|
-
new PackageHostExtension(this.packageHosts, new ExecSessionFiles(environment, piCwd)),
|
|
171
|
-
new BrandExtension(sdk),
|
|
172
|
-
...(environment.local ? [] : [new ExecExtension(environment, sdk, piCwd)]),
|
|
173
|
-
];
|
|
174
|
-
return [
|
|
175
|
-
...this.piExtensions(sdk, environment),
|
|
176
|
-
TaExtensionUtil.bundle(builtIn),
|
|
177
|
-
...(this.extensions ?? []).map(extension => ({
|
|
178
|
-
name: extension.name ?? extension.constructor.name,
|
|
179
|
-
factory: (pi: Parameters<AgentExtension['register']>[0]) => extension.register(pi),
|
|
180
|
-
})),
|
|
181
|
-
];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The built-in extensions pi's command loads (codemode, tool search, MCP), which its SDK leaves to
|
|
186
|
-
* the host. Flagged as pi flags them: an installed extension that registers the same tool or
|
|
187
|
-
* command replaces them. pi does not export its llama.cpp extension. MCP servers over stdio start
|
|
188
|
-
* in the execution environment, where the session's tools run.
|
|
189
|
-
*/
|
|
190
|
-
protected piExtensions(sdk: PiSdk, environment: ExecEnvironment): InlineExtension[] {
|
|
191
|
-
const createTransport = environment.local ? undefined : (entry: McpServerEntry) => new ExecMcpTransport(environment, entry);
|
|
192
|
-
return [
|
|
193
|
-
{ name: 'codemode', factory: sdk.createCodemodeExtension(), replaceable: true, builtin: true },
|
|
194
|
-
{ name: 'tool-search', factory: sdk.createToolSearchExtension(), replaceable: true, builtin: true },
|
|
195
|
-
{ name: 'mcp', factory: sdk.createMcpExtension({ createTransport }), replaceable: true, builtin: true },
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Project resources load only in a project the user has trusted, or one without any. */
|
|
200
|
-
protected isTrusted(sdk: PiSdk, cwd: string, agentDir: string): boolean {
|
|
201
|
-
return new sdk.ProjectTrustStore(agentDir).get(cwd) ?? !sdk.hasTrustRequiringProjectResources(cwd);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
protected findModel(modelRuntime: ModelRuntime, ref: string): Model | undefined {
|
|
205
|
-
const index = ref.indexOf('/');
|
|
206
|
-
return index > 0 ? modelRuntime.getModel(ref.slice(0, index), ref.slice(index + 1)) : undefined;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
protected resolveModel(modelRuntime: ModelRuntime, ref: string): Model {
|
|
210
|
-
const model = this.findModel(modelRuntime, ref);
|
|
211
|
-
if (!model) {
|
|
212
|
-
throw TaErrors.modelNotFound(ref);
|
|
213
|
-
}
|
|
214
|
-
return model;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Autowired, Component, Value } from '@celljs/core';
|
|
2
|
-
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
3
|
-
import type { TaOpenSessionOptions } from '@celljs/ta-protocol';
|
|
4
|
-
import { ClientChannel } from './client-channel';
|
|
5
|
-
import { TA_HOST_OPTIONS, type TaHostOptions, TaSessionFactory, TaSessionRegistry } from './host-protocol';
|
|
6
|
-
import { TaErrors } from './ta-errors';
|
|
7
|
-
import type { TaSession } from './ta-session';
|
|
8
|
-
|
|
9
|
-
@Component(TaSessionRegistry)
|
|
10
|
-
export class DefaultTaSessionRegistry implements TaSessionRegistry {
|
|
11
|
-
@Value(TA_HOST_OPTIONS)
|
|
12
|
-
protected readonly options: TaHostOptions;
|
|
13
|
-
|
|
14
|
-
@Autowired(TaSessionFactory)
|
|
15
|
-
protected readonly factory: TaSessionFactory;
|
|
16
|
-
|
|
17
|
-
protected readonly sessions = new Map<string, TaSession>();
|
|
18
|
-
protected readonly channels = new WeakMap<RpcConnection, ClientChannel>();
|
|
19
|
-
/** Sessions being created count against the limit too. */
|
|
20
|
-
protected opening = 0;
|
|
21
|
-
|
|
22
|
-
async open(options: TaOpenSessionOptions): Promise<TaSession> {
|
|
23
|
-
if (this.sessions.size + this.opening >= this.options.maxSessions) {
|
|
24
|
-
throw TaErrors.tooManySessions(this.options.maxSessions);
|
|
25
|
-
}
|
|
26
|
-
this.opening++;
|
|
27
|
-
try {
|
|
28
|
-
const session = await this.factory.create(options, ended => void this.close(ended.id));
|
|
29
|
-
this.sessions.set(session.id, session);
|
|
30
|
-
return session;
|
|
31
|
-
} finally {
|
|
32
|
-
this.opening--;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
require(sessionId: string): TaSession {
|
|
37
|
-
const session = this.sessions.get(sessionId);
|
|
38
|
-
if (!session) {
|
|
39
|
-
throw TaErrors.sessionNotFound(sessionId);
|
|
40
|
-
}
|
|
41
|
-
return session;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
list(): TaSession[] {
|
|
45
|
-
return [...this.sessions.values()];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async close(sessionId: string): Promise<void> {
|
|
49
|
-
const session = this.sessions.get(sessionId);
|
|
50
|
-
if (session) {
|
|
51
|
-
this.sessions.delete(sessionId);
|
|
52
|
-
await session.close();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async closeAll(): Promise<void> {
|
|
57
|
-
await Promise.all([...this.sessions.keys()].map(id => this.close(id)));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** The one channel of a connection; it leaves every session when the connection ends. */
|
|
61
|
-
channel(connection: RpcConnection): ClientChannel {
|
|
62
|
-
let channel = this.channels.get(connection);
|
|
63
|
-
if (!channel) {
|
|
64
|
-
const created = new ClientChannel(connection, this.options.clientBacklogBytes);
|
|
65
|
-
this.channels.set(connection, created);
|
|
66
|
-
connection.onClose(() => {
|
|
67
|
-
for (const session of this.list()) {
|
|
68
|
-
session.detach(created);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
channel = created;
|
|
72
|
-
}
|
|
73
|
-
return channel;
|
|
74
|
-
}
|
|
75
|
-
}
|
package/src/node/ta-session.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import type { SessionLock } from '@celljs/ta-harness';
|
|
3
|
-
import type {
|
|
4
|
-
RpcExtensionUIResponse,
|
|
5
|
-
TaAttachResult,
|
|
6
|
-
TaClientToolResult,
|
|
7
|
-
TaEvent,
|
|
8
|
-
TaNavigateResult,
|
|
9
|
-
TaPromptInput,
|
|
10
|
-
TaPromptReceipt,
|
|
11
|
-
TaSessionInfo,
|
|
12
|
-
} from '@celljs/ta-protocol';
|
|
13
|
-
import type { ClientChannel } from './client-channel';
|
|
14
|
-
import type { ClientToolBroker } from './client-tool-broker';
|
|
15
|
-
import { EventLog } from './event-log';
|
|
16
|
-
import type { TaHostOptions } from './host-protocol';
|
|
17
|
-
import { ReceiptBook } from './receipt-book';
|
|
18
|
-
import { RemoteUiContext } from './remote-ui-context';
|
|
19
|
-
import { SessionInfoUtil } from './session-info-util';
|
|
20
|
-
import { TaEventUtil } from './ta-event-util';
|
|
21
|
-
|
|
22
|
-
type AgentSessionRuntime = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' }}).AgentSessionRuntime;
|
|
23
|
-
type AgentSession = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' }}).AgentSession;
|
|
24
|
-
type PromptDisposition = 'started' | 'queued' | 'handled';
|
|
25
|
-
|
|
26
|
-
export interface TaSessionContext {
|
|
27
|
-
runtime: AgentSessionRuntime;
|
|
28
|
-
lock: SessionLock;
|
|
29
|
-
/** The tools of the session that its clients run. */
|
|
30
|
-
clientTools: ClientToolBroker;
|
|
31
|
-
options: TaHostOptions;
|
|
32
|
-
/** The session should end: it has been idle, or an extension asked. */
|
|
33
|
-
requestClose(session: TaSession): void;
|
|
34
|
-
/** TaOpenSessionOptions.group. */
|
|
35
|
-
group?: string;
|
|
36
|
-
/** The location of the directory pi works in (PiDirectories.fromPi); default: that directory. */
|
|
37
|
-
locate?(cwd: string): string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* One open session of `ta serve`: pi's runtime, its event log, and the clients attached to it. Its id
|
|
42
|
-
* stays the same while the runtime moves between conversations.
|
|
43
|
-
*/
|
|
44
|
-
export class TaSession {
|
|
45
|
-
readonly id = randomUUID();
|
|
46
|
-
readonly createdAt = Date.now();
|
|
47
|
-
readonly ui: RemoteUiContext;
|
|
48
|
-
readonly runtime: AgentSessionRuntime;
|
|
49
|
-
protected readonly log: EventLog;
|
|
50
|
-
protected readonly receipts = new ReceiptBook();
|
|
51
|
-
protected readonly channels = new Set<ClientChannel>();
|
|
52
|
-
protected unsubscribe?: () => void;
|
|
53
|
-
protected idleTimer?: ReturnType<typeof setTimeout>;
|
|
54
|
-
protected started = false;
|
|
55
|
-
|
|
56
|
-
constructor(protected readonly context: TaSessionContext) {
|
|
57
|
-
this.runtime = context.runtime;
|
|
58
|
-
this.log = new EventLog(this.id, context.options.eventBufferBytes);
|
|
59
|
-
this.ui = new RemoteUiContext(event => this.publish(event));
|
|
60
|
-
context.clientTools.connect(event => this.publish(event));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get pi(): AgentSession {
|
|
64
|
-
return this.runtime.session;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Where the session works, as clients name it: a path, or an `ssh://` location. */
|
|
68
|
-
get cwd(): string {
|
|
69
|
-
return this.context.locate ? this.context.locate(this.runtime.cwd) : this.runtime.cwd;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async start(): Promise<void> {
|
|
73
|
-
this.runtime.setRebindSession(() => this.bind());
|
|
74
|
-
await this.bind();
|
|
75
|
-
this.started = true;
|
|
76
|
-
this.watchIdle();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
info(): TaSessionInfo {
|
|
80
|
-
const { pi } = this;
|
|
81
|
-
// Without a model pi's agent holds a placeholder that no runtime knows.
|
|
82
|
-
const model = pi.model && pi.modelRuntime.getModel(pi.model.provider, pi.model.id);
|
|
83
|
-
return {
|
|
84
|
-
sessionId: this.id,
|
|
85
|
-
piSessionId: pi.sessionId,
|
|
86
|
-
cwd: this.cwd,
|
|
87
|
-
sessionFile: pi.sessionFile,
|
|
88
|
-
sessionName: pi.sessionName,
|
|
89
|
-
firstMessage: SessionInfoUtil.firstMessage(pi.messages),
|
|
90
|
-
model: model ? `${model.provider}/${model.id}` : undefined,
|
|
91
|
-
isStreaming: pi.isStreaming,
|
|
92
|
-
messageCount: pi.messages.length,
|
|
93
|
-
attached: this.channels.size,
|
|
94
|
-
createdAt: this.createdAt,
|
|
95
|
-
updatedAt: SessionInfoUtil.updatedAt(pi.messages, this.createdAt),
|
|
96
|
-
group: this.context.group,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
attach(channel: ClientChannel, afterSeq?: number): TaAttachResult {
|
|
101
|
-
this.channels.add(channel);
|
|
102
|
-
this.watchIdle();
|
|
103
|
-
const { events, gap } = afterSeq === undefined ? { events: [], gap: false } : this.log.since(afterSeq);
|
|
104
|
-
return {
|
|
105
|
-
info: this.info(),
|
|
106
|
-
events,
|
|
107
|
-
pendingUi: this.ui.pendingRequests,
|
|
108
|
-
shownUi: this.ui.shownRequests,
|
|
109
|
-
pendingClientTools: this.context.clientTools.pendingRequests,
|
|
110
|
-
lastSeq: this.log.lastSeq,
|
|
111
|
-
gap,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
detach(channel: ClientChannel): void {
|
|
116
|
-
if (this.channels.delete(channel)) {
|
|
117
|
-
this.watchIdle();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
respondUi(response: RpcExtensionUIResponse): boolean {
|
|
122
|
-
return this.ui.respond(response);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
respondClientTool(result: TaClientToolResult): boolean {
|
|
126
|
-
return this.context.clientTools.respond(result);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
prompt(input: TaPromptInput): Promise<TaPromptReceipt> {
|
|
130
|
-
return this.accept(
|
|
131
|
-
input,
|
|
132
|
-
() =>
|
|
133
|
-
new Promise<PromptDisposition>((resolve, reject) => {
|
|
134
|
-
this.pi
|
|
135
|
-
.prompt(input.message, {
|
|
136
|
-
images: input.images,
|
|
137
|
-
streamingBehavior: input.streamingBehavior ?? 'followUp',
|
|
138
|
-
source: 'rpc',
|
|
139
|
-
preflightResult: resolve,
|
|
140
|
-
})
|
|
141
|
-
// After the preflight, failures of the run reach the clients as events.
|
|
142
|
-
.then(() => resolve('handled'), reject);
|
|
143
|
-
}),
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
steer(input: TaPromptInput): Promise<TaPromptReceipt> {
|
|
148
|
-
return this.accept(input, () => this.pi.steer(input.message, input.images, { source: 'rpc' }));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
followUp(input: TaPromptInput): Promise<TaPromptReceipt> {
|
|
152
|
-
return this.accept(input, () => this.pi.followUp(input.message, input.images, { source: 'rpc' }));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** pi's runtime says nothing of a move in the tree: the clients are told to read the conversation again. */
|
|
156
|
-
async navigateTree(targetId: string, options?: Parameters<AgentSession['navigateTree']>[1]): Promise<TaNavigateResult> {
|
|
157
|
-
const { cancelled, editorText } = await this.pi.navigateTree(targetId, options);
|
|
158
|
-
if (!cancelled) {
|
|
159
|
-
this.publish({ type: 'session_replaced', info: this.info() });
|
|
160
|
-
}
|
|
161
|
-
return { cancelled, editorText };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async close(): Promise<void> {
|
|
165
|
-
clearTimeout(this.idleTimer);
|
|
166
|
-
this.ui.cancelAll();
|
|
167
|
-
this.context.clientTools.cancelAll();
|
|
168
|
-
this.publish({ type: 'session_closed' });
|
|
169
|
-
this.channels.clear();
|
|
170
|
-
this.unsubscribe?.();
|
|
171
|
-
if (this.pi.isStreaming) {
|
|
172
|
-
await this.pi.abort();
|
|
173
|
-
}
|
|
174
|
-
await this.runtime.dispose();
|
|
175
|
-
this.context.lock.releaseAll();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
protected async accept(input: TaPromptInput, run: () => Promise<PromptDisposition>): Promise<TaPromptReceipt> {
|
|
179
|
-
const duplicate = this.receipts.take(input);
|
|
180
|
-
if (duplicate) {
|
|
181
|
-
return duplicate;
|
|
182
|
-
}
|
|
183
|
-
try {
|
|
184
|
-
const disposition = await run();
|
|
185
|
-
return { clientMessageId: input.clientMessageId, status: disposition === 'queued' ? 'queued' : 'accepted' };
|
|
186
|
-
} catch (error) {
|
|
187
|
-
this.receipts.forget(input.clientMessageId);
|
|
188
|
-
throw error;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/** Connects this object to the session the runtime has now: at the start and after each replacement. */
|
|
193
|
-
protected async bind(): Promise<void> {
|
|
194
|
-
this.unsubscribe?.();
|
|
195
|
-
const { pi, runtime } = this;
|
|
196
|
-
await pi.bindExtensions({
|
|
197
|
-
uiContext: this.ui,
|
|
198
|
-
mode: 'rpc',
|
|
199
|
-
commandContextActions: {
|
|
200
|
-
waitForIdle: () => pi.waitForIdle(),
|
|
201
|
-
newSession: options => runtime.newSession(options),
|
|
202
|
-
fork: async (entryId, options) => ({ cancelled: (await runtime.fork(entryId, options)).cancelled }),
|
|
203
|
-
navigateTree: async (targetId, options) => ({ cancelled: (await this.navigateTree(targetId, options)).cancelled }),
|
|
204
|
-
switchSession: (sessionPath, options) => runtime.switchSession(sessionPath, options),
|
|
205
|
-
reload: () => pi.reload(),
|
|
206
|
-
},
|
|
207
|
-
shutdownHandler: () => this.context.requestClose(this),
|
|
208
|
-
onError: error => this.publish({ type: 'extension_error', extensionPath: error.extensionPath, event: error.event, error: error.error }),
|
|
209
|
-
});
|
|
210
|
-
this.unsubscribe = pi.subscribe(event => {
|
|
211
|
-
this.publish(TaEventUtil.toWire(event));
|
|
212
|
-
if (event.type === 'agent_settled') {
|
|
213
|
-
this.watchIdle();
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
if (this.started) {
|
|
217
|
-
this.publish({ type: 'session_replaced', info: this.info() });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
protected publish(event: TaEvent): void {
|
|
222
|
-
const logged = this.log.append(event);
|
|
223
|
-
for (const channel of this.channels) {
|
|
224
|
-
channel.send(logged);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
protected isIdle(): boolean {
|
|
229
|
-
return this.channels.size === 0 && !this.pi.isStreaming && this.ui.pendingRequests.length === 0;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/** One timer per session, armed only when nothing is attached: an idle server does no work. */
|
|
233
|
-
protected watchIdle(): void {
|
|
234
|
-
clearTimeout(this.idleTimer);
|
|
235
|
-
this.idleTimer = undefined;
|
|
236
|
-
if (this.isIdle()) {
|
|
237
|
-
this.idleTimer = setTimeout(() => this.isIdle() && this.context.requestClose(this), this.context.options.idleTimeoutMs);
|
|
238
|
-
this.idleTimer.unref();
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
2
|
-
import type { TaOpenTerminalOptions, TaTerminalInfo } from '@celljs/ta-protocol';
|
|
3
|
-
|
|
4
|
-
export const TaTerminals = Symbol('TaTerminals');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The shells of the web client's terminal. Each belongs to the connection that opened it and sends it
|
|
8
|
-
* its output (TaClient.onTerminalData). When that connection drops, the shell waits 30 s for another
|
|
9
|
-
* to take it (listTerminals, writeTerminal or resizeTerminal) and keeps its output meanwhile; then it ends.
|
|
10
|
-
*/
|
|
11
|
-
export interface TaTerminals {
|
|
12
|
-
open(connection: RpcConnection, options: TaOpenTerminalOptions & { cwd: string }): Promise<TaTerminalInfo>;
|
|
13
|
-
write(connection: RpcConnection, terminalId: string, data: string): void;
|
|
14
|
-
resize(connection: RpcConnection, terminalId: string, cols: number, rows: number): Promise<void>;
|
|
15
|
-
close(connection: RpcConnection, terminalId: string): Promise<void>;
|
|
16
|
-
list(connection: RpcConnection): TaTerminalInfo[];
|
|
17
|
-
closeAll(): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from 'bun:test';
|
|
2
|
-
import { realpathSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
5
|
-
import { LocalExecEnvironment } from '@celljs/ta-exec';
|
|
6
|
-
import { DefaultTaTerminals } from './terminal-service';
|
|
7
|
-
|
|
8
|
-
/** A connection that keeps what the shells sent it. */
|
|
9
|
-
class FakeConnection {
|
|
10
|
-
readonly id = String(Math.random());
|
|
11
|
-
closed = false;
|
|
12
|
-
output = '';
|
|
13
|
-
exitCode?: number;
|
|
14
|
-
protected readonly closeListeners: (() => void)[] = [];
|
|
15
|
-
|
|
16
|
-
client() {
|
|
17
|
-
return {
|
|
18
|
-
onTerminalData: async (_terminalId: string, data: string, exitCode?: number) => {
|
|
19
|
-
this.output += data;
|
|
20
|
-
this.exitCode ??= exitCode;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
onClose(listener: () => void) {
|
|
26
|
-
this.closeListeners.push(listener);
|
|
27
|
-
return { dispose: () => undefined };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
close() {
|
|
31
|
-
this.closed = true;
|
|
32
|
-
for (const listener of this.closeListeners) {
|
|
33
|
-
listener();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function until(check: () => boolean, what: string): Promise<void> {
|
|
39
|
-
for (let i = 0; i < 500 && !check(); i++) {
|
|
40
|
-
await Bun.sleep(10);
|
|
41
|
-
}
|
|
42
|
-
if (!check()) {
|
|
43
|
-
throw new Error(`Timed out waiting until ${what}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
describe('DefaultTaTerminals', () => {
|
|
48
|
-
const cwd = realpathSync(tmpdir());
|
|
49
|
-
const terminals = new DefaultTaTerminals();
|
|
50
|
-
Object.assign(terminals, { environments: { create: (dir: string) => new LocalExecEnvironment(dir), defaultCwd: async () => cwd } });
|
|
51
|
-
const as = (connection: FakeConnection) => connection as unknown as RpcConnection;
|
|
52
|
-
|
|
53
|
-
afterEach(() => terminals.closeAll());
|
|
54
|
-
|
|
55
|
-
it('runs a shell and sends its output to the connection that opened it', async () => {
|
|
56
|
-
const connection = new FakeConnection();
|
|
57
|
-
const info = await terminals.open(as(connection), { cwd, cols: 80, rows: 24 });
|
|
58
|
-
expect(info.cwd).toBe(cwd);
|
|
59
|
-
expect(info.terminalId).toBeString();
|
|
60
|
-
terminals.write(as(connection), info.terminalId, 'echo ta-$((40+2))\r');
|
|
61
|
-
await until(() => connection.output.includes('ta-42'), 'the shell answered');
|
|
62
|
-
expect(connection.output).not.toContain('ta-tty=');
|
|
63
|
-
expect(terminals.list(as(connection))).toEqual([info]);
|
|
64
|
-
await terminals.resize(as(connection), info.terminalId, 100, 30);
|
|
65
|
-
terminals.write(as(connection), info.terminalId, 'exit\r');
|
|
66
|
-
await until(() => connection.exitCode !== undefined, 'the shell ended');
|
|
67
|
-
expect(terminals.list(as(connection))).toEqual([]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('sizes the shell as its view asked, even before the shell named its terminal', async () => {
|
|
71
|
-
const connection = new FakeConnection();
|
|
72
|
-
const info = await terminals.open(as(connection), { cwd, cols: 80, rows: 24 });
|
|
73
|
-
if (!info.pty) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
await terminals.resize(as(connection), info.terminalId, 101, 31);
|
|
77
|
-
await Bun.sleep(300);
|
|
78
|
-
terminals.write(as(connection), info.terminalId, 'stty size\r');
|
|
79
|
-
await until(() => connection.output.includes('31 101'), 'the shell has the size of its view');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('asks each machine for its own shell and system', async () => {
|
|
83
|
-
const asked: string[] = [];
|
|
84
|
-
const service = new DefaultTaTerminals();
|
|
85
|
-
const detect = (service as unknown as { detect(env: { exec: unknown; local: boolean }, machine: string): Promise<{ system: string }> }).detect.bind(
|
|
86
|
-
service,
|
|
87
|
-
);
|
|
88
|
-
const env = (system: string) => ({
|
|
89
|
-
local: false,
|
|
90
|
-
exec: async (_command: string, options: { onData(data: Uint8Array): void }) => {
|
|
91
|
-
asked.push(system);
|
|
92
|
-
options.onData(new TextEncoder().encode(`${system}\n/usr/bin/script\n/bin/zsh`));
|
|
93
|
-
return { exitCode: 0 };
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
expect((await detect(env('Linux'), 'box')).system).toBe('Linux');
|
|
97
|
-
expect((await detect(env('Darwin'), '')).system).toBe('Darwin');
|
|
98
|
-
expect((await detect(env('Darwin'), 'box')).system).toBe('Linux');
|
|
99
|
-
expect(asked).toEqual(['Linux', 'Darwin']);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('keeps a shell for another connection after its own dropped', async () => {
|
|
103
|
-
const first = new FakeConnection();
|
|
104
|
-
const info = await terminals.open(as(first), { cwd, cols: 80, rows: 24 });
|
|
105
|
-
const stranger = new FakeConnection();
|
|
106
|
-
expect(terminals.list(as(stranger))).toEqual([]);
|
|
107
|
-
expect(() => terminals.write(as(stranger), info.terminalId, 'x')).toThrow('No terminal');
|
|
108
|
-
terminals.write(as(first), info.terminalId, 'echo first-$((1+2))\r');
|
|
109
|
-
await until(() => first.output.includes('first-3'), 'the first connection got the output');
|
|
110
|
-
first.close();
|
|
111
|
-
const second = new FakeConnection();
|
|
112
|
-
expect(terminals.list(as(second))).toEqual([info]);
|
|
113
|
-
await until(() => second.output.startsWith('\x1bc') && second.output.includes('first-3'), 'the second connection got what the shell showed before');
|
|
114
|
-
terminals.write(as(second), info.terminalId, 'echo back-$((1+1))\r');
|
|
115
|
-
await until(() => second.output.includes('back-2'), 'the second connection got the output');
|
|
116
|
-
await terminals.close(as(second), info.terminalId);
|
|
117
|
-
expect(terminals.list(as(second))).toEqual([]);
|
|
118
|
-
});
|
|
119
|
-
});
|