@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
package/src/node/event-log.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { TaEvent, TaEventEnvelope } from '@celljs/ta-protocol';
|
|
2
|
-
|
|
3
|
-
export interface LoggedEvent {
|
|
4
|
-
envelope: TaEventEnvelope;
|
|
5
|
-
/** Approximate size in bytes. */
|
|
6
|
-
size: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The latest events of a session, by size, so that a client that reconnects can catch up. Only that:
|
|
11
|
-
* what happened is in the session file, and a client that fell further behind reads it again.
|
|
12
|
-
*/
|
|
13
|
-
export class EventLog {
|
|
14
|
-
protected entries: LoggedEvent[] = [];
|
|
15
|
-
protected head = 0;
|
|
16
|
-
protected bytes = 0;
|
|
17
|
-
protected seq = 0;
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
protected readonly sessionId: string,
|
|
21
|
-
protected readonly maxBytes: number,
|
|
22
|
-
) {}
|
|
23
|
-
|
|
24
|
-
get lastSeq(): number {
|
|
25
|
-
return this.seq;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
append(event: TaEvent): LoggedEvent {
|
|
29
|
-
const logged = { envelope: { sessionId: this.sessionId, seq: ++this.seq, event }, size: this.sizeOf(event) };
|
|
30
|
-
this.entries.push(logged);
|
|
31
|
-
this.bytes += logged.size;
|
|
32
|
-
while (this.bytes > this.maxBytes && this.entries.length - this.head > 1) {
|
|
33
|
-
this.bytes -= this.entries[this.head++].size;
|
|
34
|
-
}
|
|
35
|
-
if (this.head > 1024 && this.head * 2 > this.entries.length) {
|
|
36
|
-
this.entries = this.entries.slice(this.head);
|
|
37
|
-
this.head = 0;
|
|
38
|
-
}
|
|
39
|
-
return logged;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** The events after `afterSeq`; `gap` when some of them are gone. */
|
|
43
|
-
since(afterSeq: number): { events: TaEventEnvelope[]; gap: boolean } {
|
|
44
|
-
const oldest = this.head < this.entries.length ? this.entries[this.head].envelope.seq : this.seq + 1;
|
|
45
|
-
if (afterSeq + 1 < oldest || afterSeq > this.seq) {
|
|
46
|
-
return { events: [], gap: true };
|
|
47
|
-
}
|
|
48
|
-
return { events: this.entries.slice(this.head + afterSeq + 1 - oldest).map(entry => entry.envelope), gap: false };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Deltas are most of the events and their size is known; the others are rare enough to measure. */
|
|
52
|
-
protected sizeOf(event: TaEvent): number {
|
|
53
|
-
if (event.type === 'message_update') {
|
|
54
|
-
const delta = (event.assistantMessageEvent as { delta?: string }).delta;
|
|
55
|
-
return 256 + (delta?.length ?? 0);
|
|
56
|
-
}
|
|
57
|
-
return JSON.stringify(event).length;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Autowired, Component, Optional, Value } from '@celljs/core';
|
|
2
|
-
import { ExecClient, type ExecEnvironment, ExecEnvironmentFactory, LocalExecEnvironment, RemoteExecEnvironment } from '@celljs/ta-exec';
|
|
3
|
-
import { TaLocation } from '@celljs/ta-protocol';
|
|
4
|
-
import { TA_EXEC_OPTIONS, type TaExecOptions } from './host-protocol';
|
|
5
|
-
import { RemoteHosts } from './remote/remote-protocol';
|
|
6
|
-
import { TaErrors } from './ta-errors';
|
|
7
|
-
import { TaWorkingDirectory } from './working-directory';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Where a location runs. `ssh://<host>/<path>`: on that host, through ssh (RemoteHosts). A path: on this
|
|
11
|
-
* machine, or with `ta.exec.url` on the machine of a `ta exec-server`, all sessions on one connection.
|
|
12
|
-
* The agent loop stays here; commands and files are there. The default directory is the one the user
|
|
13
|
-
* chose (TaWorkingDirectory), if any.
|
|
14
|
-
*/
|
|
15
|
-
@Component(ExecEnvironmentFactory)
|
|
16
|
-
export class DefaultExecEnvironmentFactory implements ExecEnvironmentFactory {
|
|
17
|
-
@Value(TA_EXEC_OPTIONS)
|
|
18
|
-
protected readonly options?: TaExecOptions;
|
|
19
|
-
|
|
20
|
-
@Autowired(TaWorkingDirectory)
|
|
21
|
-
@Optional()
|
|
22
|
-
protected readonly workingDirectory?: TaWorkingDirectory;
|
|
23
|
-
|
|
24
|
-
@Autowired(RemoteHosts)
|
|
25
|
-
protected readonly remoteHosts: RemoteHosts;
|
|
26
|
-
|
|
27
|
-
protected client?: ExecClient;
|
|
28
|
-
|
|
29
|
-
/** Its `cwd` is the path there: the one to resolve paths against, not the location. */
|
|
30
|
-
create(location: string): ExecEnvironment {
|
|
31
|
-
let remote: TaLocation.Remote | undefined;
|
|
32
|
-
try {
|
|
33
|
-
remote = TaLocation.parse(location);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw TaErrors.invalidArgument((error as Error).message, 'Write ssh://<host>/<absolute path>.');
|
|
36
|
-
}
|
|
37
|
-
if (remote) {
|
|
38
|
-
if (!remote.path) {
|
|
39
|
-
throw TaErrors.invalidArgument(`${location} names no directory.`, 'Resolve it first (TaRemoteServer.resolveLocation), or write its path.');
|
|
40
|
-
}
|
|
41
|
-
return new RemoteExecEnvironment(this.remoteHosts.client(remote.host), remote.path);
|
|
42
|
-
}
|
|
43
|
-
const client = this.remote();
|
|
44
|
-
return client ? new RemoteExecEnvironment(client, location) : new LocalExecEnvironment(location);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** The working directory the user chose, else that of this process, or of the exec server. */
|
|
48
|
-
async defaultCwd(): Promise<string> {
|
|
49
|
-
const chosen = this.workingDirectory?.get();
|
|
50
|
-
if (chosen) {
|
|
51
|
-
return chosen;
|
|
52
|
-
}
|
|
53
|
-
const client = this.remote();
|
|
54
|
-
return client ? (await client.info()).cwd : process.cwd();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected remote(): ExecClient | undefined {
|
|
58
|
-
const { url, token = '', epoch } = this.options ?? {};
|
|
59
|
-
if (!url) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
// A host started later fences the ones before it.
|
|
63
|
-
this.client ??= new ExecClient({ connect: ExecClient.webSocket(url, token), epoch: epoch || Date.now() });
|
|
64
|
-
return this.client;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { ExtensionDataBatch, ExtensionDataScope } from './extension-data-notifier';
|
|
3
|
-
|
|
4
|
-
describe('ExtensionDataBatch', () => {
|
|
5
|
-
it('gathers the keys that changed, by package, once each', () => {
|
|
6
|
-
const batch = new ExtensionDataBatch();
|
|
7
|
-
expect(batch.empty).toBe(true);
|
|
8
|
-
batch.add('ta-channels', 'messages/b');
|
|
9
|
-
batch.add('notes', 'list');
|
|
10
|
-
batch.add('ta-channels', 'team');
|
|
11
|
-
batch.add('ta-channels', 'messages/b');
|
|
12
|
-
expect(batch.take()).toEqual([
|
|
13
|
-
['notes', ['list']],
|
|
14
|
-
['ta-channels', ['messages/b', 'team']],
|
|
15
|
-
]);
|
|
16
|
-
expect(batch.empty).toBe(true);
|
|
17
|
-
expect(batch.take()).toEqual([]);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('keeps the keys of a directory apart from those of the package', () => {
|
|
21
|
-
const batch = new ExtensionDataBatch();
|
|
22
|
-
batch.add('notes', 'open', '/work');
|
|
23
|
-
batch.add('notes', 'list');
|
|
24
|
-
batch.add('notes', 'open', '/work');
|
|
25
|
-
batch.add('notes', 'open', '/else');
|
|
26
|
-
expect(batch.take()).toEqual([
|
|
27
|
-
['notes', ['list']],
|
|
28
|
-
['notes', ['open'], '/else'],
|
|
29
|
-
['notes', ['open'], '/work'],
|
|
30
|
-
]);
|
|
31
|
-
expect(ExtensionDataScope.parse(ExtensionDataScope.of('notes', '/a\nb'))).toEqual(['notes', '/a\nb']);
|
|
32
|
-
expect(ExtensionDataScope.parse(ExtensionDataScope.of('notes'))).toEqual(['notes']);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Autowired, Component } from '@celljs/core';
|
|
2
|
-
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
3
|
-
import { TaClient } from '@celljs/ta-protocol';
|
|
4
|
-
import { ExtensionDataStore } from './extension-data';
|
|
5
|
-
|
|
6
|
-
export const ExtensionDataNotifier = Symbol('ExtensionDataNotifier');
|
|
7
|
-
|
|
8
|
-
/** At most one notice per connection in this time, with the keys that changed meanwhile. */
|
|
9
|
-
const NOTICE_MS = 250;
|
|
10
|
-
|
|
11
|
-
/** Tells the clients which keys of the data of packages changed (TaClient.onExtensionData). */
|
|
12
|
-
export interface ExtensionDataNotifier {
|
|
13
|
-
/** The connection reads the data of the package, of a directory with `cwd`: tell it when that changes. */
|
|
14
|
-
watch(connection: RpcConnection, name: string, cwd?: string): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** One package, or its data of one directory. */
|
|
18
|
-
export namespace ExtensionDataScope {
|
|
19
|
-
export function of(name: string, cwd?: string): string {
|
|
20
|
-
return cwd === undefined ? name : `${name}\n${cwd}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function parse(scope: string): [name: string, cwd?: string] {
|
|
24
|
-
const at = scope.indexOf('\n');
|
|
25
|
-
return at < 0 ? [scope] : [scope.slice(0, at), scope.slice(at + 1)];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The keys that changed for one connection, by package and directory, until they leave together: a
|
|
31
|
-
* channel where agents talk writes many times a second, a page draws once.
|
|
32
|
-
*/
|
|
33
|
-
export class ExtensionDataBatch {
|
|
34
|
-
protected readonly pending = new Map<string, Set<string>>();
|
|
35
|
-
|
|
36
|
-
add(name: string, key: string, cwd?: string): void {
|
|
37
|
-
const scope = ExtensionDataScope.of(name, cwd);
|
|
38
|
-
let keys = this.pending.get(scope);
|
|
39
|
-
if (!keys) {
|
|
40
|
-
keys = new Set();
|
|
41
|
-
this.pending.set(scope, keys);
|
|
42
|
-
}
|
|
43
|
-
keys.add(key);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get empty(): boolean {
|
|
47
|
-
return this.pending.size === 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** What changed, by package then directory, sorted; empties the batch. */
|
|
51
|
-
take(): [name: string, keys: string[], cwd?: string][] {
|
|
52
|
-
const taken = [...this.pending].sort(([a], [b]) => a.localeCompare(b));
|
|
53
|
-
this.pending.clear();
|
|
54
|
-
return taken.map(([scope, keys]) => {
|
|
55
|
-
const [name, cwd] = ExtensionDataScope.parse(scope);
|
|
56
|
-
return cwd === undefined ? [name, [...keys].sort()] : [name, [...keys].sort(), cwd];
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface Watcher {
|
|
62
|
-
/** By ExtensionDataScope. */
|
|
63
|
-
scopes: Set<string>;
|
|
64
|
-
batch: ExtensionDataBatch;
|
|
65
|
-
timer?: ReturnType<typeof setTimeout>;
|
|
66
|
-
lastAt: number;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@Component(ExtensionDataNotifier)
|
|
70
|
-
export class ExtensionDataNotifierImpl implements ExtensionDataNotifier {
|
|
71
|
-
@Autowired(ExtensionDataStore)
|
|
72
|
-
protected readonly store: ExtensionDataStore;
|
|
73
|
-
|
|
74
|
-
protected readonly watchers = new Map<RpcConnection, Watcher>();
|
|
75
|
-
protected unsubscribe?: () => void;
|
|
76
|
-
|
|
77
|
-
watch(connection: RpcConnection, name: string, cwd?: string): void {
|
|
78
|
-
let watcher = this.watchers.get(connection);
|
|
79
|
-
if (!watcher) {
|
|
80
|
-
const created: Watcher = { scopes: new Set(), batch: new ExtensionDataBatch(), lastAt: Number.NEGATIVE_INFINITY };
|
|
81
|
-
this.watchers.set(connection, created);
|
|
82
|
-
connection.onClose(() => {
|
|
83
|
-
clearTimeout(created.timer);
|
|
84
|
-
this.watchers.delete(connection);
|
|
85
|
-
if (this.watchers.size === 0) {
|
|
86
|
-
this.unsubscribe?.();
|
|
87
|
-
this.unsubscribe = undefined;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
watcher = created;
|
|
91
|
-
}
|
|
92
|
-
watcher.scopes.add(ExtensionDataScope.of(name, cwd));
|
|
93
|
-
this.unsubscribe ??= this.store.onChange((changed, key, directory) => this.changed(changed, key, directory));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
protected changed(name: string, key: string, cwd?: string): void {
|
|
97
|
-
const scope = ExtensionDataScope.of(name, cwd);
|
|
98
|
-
for (const [connection, watcher] of this.watchers) {
|
|
99
|
-
if (watcher.scopes.has(scope)) {
|
|
100
|
-
watcher.batch.add(name, key, cwd);
|
|
101
|
-
this.schedule(connection, watcher);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** The first change leaves at once; the next ones wait for the rest of the interval. */
|
|
107
|
-
protected schedule(connection: RpcConnection, watcher: Watcher): void {
|
|
108
|
-
if (watcher.timer !== undefined) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const wait = Math.max(0, watcher.lastAt + NOTICE_MS - performance.now());
|
|
112
|
-
watcher.timer = setTimeout(() => {
|
|
113
|
-
watcher.timer = undefined;
|
|
114
|
-
watcher.lastAt = performance.now();
|
|
115
|
-
if (connection.closed) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const client = connection.client<TaClient>(TaClient);
|
|
119
|
-
for (const [name, keys, cwd] of watcher.batch.take()) {
|
|
120
|
-
(cwd === undefined ? client.onExtensionData(name, keys) : client.onExtensionData(name, keys, cwd)).catch(() => undefined);
|
|
121
|
-
}
|
|
122
|
-
}, wait);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
|
|
2
|
-
import { mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { ExtensionDataStoreImpl, ExtensionDataUtil } from './extension-data';
|
|
6
|
-
|
|
7
|
-
describe('ExtensionDataUtil', () => {
|
|
8
|
-
it('keeps a package in its file, a scoped one in the directory of its scope', () => {
|
|
9
|
-
expect(ExtensionDataUtil.file('/a', 'notes')).toBe(join('/a', 'extension-data', 'notes.json'));
|
|
10
|
-
expect(ExtensionDataUtil.file('/a', '@celljs/ta-channels')).toBe(join('/a', 'extension-data', '@celljs', 'ta-channels.json'));
|
|
11
|
-
for (const name of ['../x', '@a/../b', 'a/b', '', '@a/', '/etc/passwd']) {
|
|
12
|
-
expect(() => ExtensionDataUtil.file('/a', name)).toThrow('is not the name of a package');
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('keeps the data of a directory apart, named by its last part and a hash of where it is', () => {
|
|
17
|
-
const id = ExtensionDataUtil.directoryId('/Users/me/my app');
|
|
18
|
-
expect(id).toMatch(/^my_app-[0-9a-f]{16}$/);
|
|
19
|
-
expect(ExtensionDataUtil.directoryId('/Users/me/my app')).toBe(id);
|
|
20
|
-
expect(ExtensionDataUtil.directoryId('/Users/you/my app')).not.toBe(id);
|
|
21
|
-
// The same path on another machine is another directory.
|
|
22
|
-
expect(ExtensionDataUtil.directoryId('/Users/me/my app', 'ws://box:7000')).not.toBe(id);
|
|
23
|
-
expect(ExtensionDataUtil.directoryId('/')).toMatch(/^[0-9a-f]{16}$/);
|
|
24
|
-
// Nothing of the name that could leave the directory of the data.
|
|
25
|
-
expect(ExtensionDataUtil.directoryId('C:\\work\\..')).toMatch(/^[0-9a-f]{16}$/);
|
|
26
|
-
expect(ExtensionDataUtil.file('/a', '@celljs/ta-web', id)).toBe(join('/a', 'extension-data', 'directories', id, '@celljs', 'ta-web.json'));
|
|
27
|
-
expect(ExtensionDataUtil.checkCwd(undefined)).toBeUndefined();
|
|
28
|
-
expect(ExtensionDataUtil.checkCwd(null)).toBeUndefined();
|
|
29
|
-
expect(() => ExtensionDataUtil.checkCwd('')).toThrow('1 to 4096');
|
|
30
|
-
expect(() => ExtensionDataUtil.checkCwd(1)).toThrow('1 to 4096');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('sets and removes a key, and refuses keys and files out of bounds', () => {
|
|
34
|
-
expect(JSON.parse(ExtensionDataUtil.update(undefined, 'a', { b: 1 }))).toEqual({ a: { b: 1 } });
|
|
35
|
-
expect(JSON.parse(ExtensionDataUtil.update('{"a":1,"b":2}', 'a', null))).toEqual({ b: 2 });
|
|
36
|
-
expect(ExtensionDataUtil.parse('not json')).toEqual({});
|
|
37
|
-
expect(() => ExtensionDataUtil.checkKey('')).toThrow('1 to 200');
|
|
38
|
-
expect(() => ExtensionDataUtil.update(undefined, 'big', 'x'.repeat(4 * 1024 * 1024))).toThrow('4 MB');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('ExtensionDataStoreImpl', () => {
|
|
43
|
-
let agentDir: string;
|
|
44
|
-
let store: ExtensionDataStoreImpl;
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
agentDir = mkdtempSync(join(tmpdir(), 'ta-ext-data-'));
|
|
47
|
-
store = new ExtensionDataStoreImpl();
|
|
48
|
-
Object.assign(store, { codingAgentOptions: { agentDir } });
|
|
49
|
-
});
|
|
50
|
-
afterEach(() => rmSync(agentDir, { recursive: true, force: true }));
|
|
51
|
-
|
|
52
|
-
it('keeps values across calls, one write after the other', async () => {
|
|
53
|
-
expect(await store.get('@celljs/ta-channels', 'team')).toBeUndefined();
|
|
54
|
-
await Promise.all(Array.from({ length: 20 }, (_, i) => store.set('@celljs/ta-channels', `k${i}`, i)));
|
|
55
|
-
expect(await store.get('@celljs/ta-channels', 'k7')).toBe(7);
|
|
56
|
-
const file = join(agentDir, 'extension-data/@celljs/ta-channels.json');
|
|
57
|
-
expect(Object.keys(JSON.parse(readFileSync(file, 'utf8')))).toHaveLength(20);
|
|
58
|
-
expect(statSync(file).mode & 0o777).toBe(0o600);
|
|
59
|
-
await store.set('@celljs/ta-channels', 'k7', undefined);
|
|
60
|
-
expect(await store.get('@celljs/ta-channels', 'k7')).toBeUndefined();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('keeps the values of each directory apart from those of the package and of other directories', async () => {
|
|
64
|
-
const heard: string[] = [];
|
|
65
|
-
store.onChange((name, key, cwd) => heard.push(`${name}/${key}@${cwd ?? ''}`));
|
|
66
|
-
await store.set('notes', 'open', ['a']);
|
|
67
|
-
await store.set('notes', 'open', ['b'], '/work/one');
|
|
68
|
-
await store.set('notes', 'open', ['c'], '/work/two');
|
|
69
|
-
expect(await store.get('notes', 'open')).toEqual(['a']);
|
|
70
|
-
expect(await store.get('notes', 'open', '/work/one')).toEqual(['b']);
|
|
71
|
-
expect(await store.get('notes', 'open', '/work/two')).toEqual(['c']);
|
|
72
|
-
expect(await store.get('notes', 'open', '/work/three')).toBeUndefined();
|
|
73
|
-
const file = ExtensionDataUtil.file(agentDir, 'notes', ExtensionDataUtil.directoryId('/work/one'));
|
|
74
|
-
expect(JSON.parse(readFileSync(file, 'utf8'))).toEqual({ open: ['b'] });
|
|
75
|
-
expect(heard).toEqual(['notes/open@', 'notes/open@/work/one', 'notes/open@/work/two']);
|
|
76
|
-
expect(() => store.set('notes', 'open', 1, '')).toThrow('1 to 4096');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('keeps the directories of a ta exec-server apart from those of this machine', async () => {
|
|
80
|
-
await store.set('notes', 'open', ['here'], '/work');
|
|
81
|
-
Object.assign(store, { execOptions: { url: 'ws://box:7000' } });
|
|
82
|
-
expect(await store.get('notes', 'open', '/work')).toBeUndefined();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('fails a write that is too large and keeps the ones after it', async () => {
|
|
86
|
-
const failed = store.set('notes', 'big', 'x'.repeat(4 * 1024 * 1024));
|
|
87
|
-
const next = store.set('notes', 'small', 1);
|
|
88
|
-
await expect(failed).rejects.toThrow('4 MB');
|
|
89
|
-
await next;
|
|
90
|
-
expect(await store.get('notes', 'small')).toBe(1);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('tells its listeners each key once written, and goes on when one of them throws', async () => {
|
|
94
|
-
const heard: string[] = [];
|
|
95
|
-
store.onChange(() => {
|
|
96
|
-
throw new Error('broken listener');
|
|
97
|
-
});
|
|
98
|
-
const stop = store.onChange((name, key) => heard.push(`${name}/${key}`));
|
|
99
|
-
await store.set('notes', 'list', [1]);
|
|
100
|
-
await store.set('notes', 'list', undefined);
|
|
101
|
-
stop();
|
|
102
|
-
await store.set('notes', 'other', 1);
|
|
103
|
-
expect(heard).toEqual(['notes/list', 'notes/list']);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { CODING_AGENT_OPTIONS, type CodingAgentOptions } from '@celljs/ai-coding-agent';
|
|
5
|
-
import { Component, Value } from '@celljs/core';
|
|
6
|
-
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
7
|
-
import { TA_EXEC_OPTIONS, type TaExecOptions } from './host-protocol';
|
|
8
|
-
import { TaErrors } from './ta-errors';
|
|
9
|
-
|
|
10
|
-
export const ExtensionDataStore = Symbol('ExtensionDataStore');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The values packages keep on the server (WebExtensionAPI.storage): one JSON file per package, and with
|
|
14
|
-
* `cwd`, one per package and directory, for what belongs to a directory (the folders open in an explorer).
|
|
15
|
-
*/
|
|
16
|
-
export interface ExtensionDataStore {
|
|
17
|
-
get(name: string, key: string, cwd?: string): Promise<unknown>;
|
|
18
|
-
/** `undefined` or `null` removes the key. */
|
|
19
|
-
set(name: string, key: string, value: unknown, cwd?: string): Promise<void>;
|
|
20
|
-
/** A key of a package was set, once it is written; `cwd` for a key of a directory. */
|
|
21
|
-
onChange(listener: (name: string, key: string, cwd?: string) => void): () => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** The largest file of a package: what a page keeps, not a database. */
|
|
25
|
-
const MAX_BYTES = 4 * 1024 * 1024;
|
|
26
|
-
const MAX_KEY = 200;
|
|
27
|
-
const MAX_CWD = 4096;
|
|
28
|
-
/** What of the name of a directory shows in the name of its data, for whoever looks there. */
|
|
29
|
-
const READABLE = 40;
|
|
30
|
-
/** A package name of npm, scoped or not: nothing that leaves the directory. */
|
|
31
|
-
const NAME = /^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/i;
|
|
32
|
-
|
|
33
|
-
export namespace ExtensionDataUtil {
|
|
34
|
-
/**
|
|
35
|
-
* `<agentDir>/extension-data/<name>.json`, and for a directory `<agentDir>/extension-data/directories/<id>/<name>.json`
|
|
36
|
-
* (see {@link directoryId}); a scoped name is a directory of its scope, as in node_modules.
|
|
37
|
-
*/
|
|
38
|
-
export function file(agentDir: string, name: string, directory?: string): string {
|
|
39
|
-
if (!NAME.test(name) || name.includes('..')) {
|
|
40
|
-
throw TaErrors.invalidArgument(`${JSON.stringify(name)} is not the name of a package.`, 'Pass the name of the package.json of the web extension.');
|
|
41
|
-
}
|
|
42
|
-
const root = join(agentDir, 'extension-data');
|
|
43
|
-
return directory === undefined ? join(root, `${name}.json`) : join(root, 'directories', directory, `${name}.json`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The name of the data of a directory: its last part, readable, and a hash of its path in its
|
|
48
|
-
* execution environment (`environment`, the URL of a ta exec-server or '' for this machine), so that
|
|
49
|
-
* the same path on two machines is two directories.
|
|
50
|
-
*/
|
|
51
|
-
export function directoryId(cwd: string, environment = ''): string {
|
|
52
|
-
const hash = createHash('sha256').update(`${environment}\n${cwd}`).digest('hex').slice(0, 16);
|
|
53
|
-
const name = (cwd.split(/[\\/]/).filter(Boolean).pop() ?? '')
|
|
54
|
-
.replace(/[^\w.-]/g, '_')
|
|
55
|
-
.replace(/^\.+/, '')
|
|
56
|
-
.slice(0, READABLE);
|
|
57
|
-
return name ? `${name}-${hash}` : hash;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function checkCwd(cwd: unknown): string | undefined {
|
|
61
|
-
if (cwd === undefined || cwd === null) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
if (typeof cwd !== 'string' || cwd.length === 0 || cwd.length > MAX_CWD) {
|
|
65
|
-
throw TaErrors.invalidArgument('A directory is a path of 1 to 4096 characters.', 'Pass the directory of the conversation (pi.ui.useCwd()).');
|
|
66
|
-
}
|
|
67
|
-
return cwd;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function checkKey(key: unknown): string {
|
|
71
|
-
if (typeof key !== 'string' || key.length === 0 || key.length > MAX_KEY) {
|
|
72
|
-
throw TaErrors.invalidArgument('A key is a string of 1 to 200 characters.', 'Use short keys, such as `settings` or `messages/<id>`.');
|
|
73
|
-
}
|
|
74
|
-
return key;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** The file with the value set; throws when it grows larger than 4 MB. */
|
|
78
|
-
export function update(text: string | undefined, key: string, value: unknown): string {
|
|
79
|
-
const data = parse(text);
|
|
80
|
-
if (value === undefined || value === null) {
|
|
81
|
-
delete data[key];
|
|
82
|
-
} else {
|
|
83
|
-
data[key] = value;
|
|
84
|
-
}
|
|
85
|
-
const next = JSON.stringify(data);
|
|
86
|
-
if (Buffer.byteLength(next) > MAX_BYTES) {
|
|
87
|
-
throw TaErrors.invalidArgument(
|
|
88
|
-
`The data of the package would grow past 4 MB with ${key}.`,
|
|
89
|
-
'Keep less: drop old entries, or keep large things in files.',
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return next;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function parse(text: string | undefined): Record<string, unknown> {
|
|
96
|
-
if (!text) {
|
|
97
|
-
return {};
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
const data = JSON.parse(text);
|
|
101
|
-
return data && typeof data === 'object' && !Array.isArray(data) ? data : {};
|
|
102
|
-
} catch {
|
|
103
|
-
return {};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@Component(ExtensionDataStore)
|
|
109
|
-
export class ExtensionDataStoreImpl implements ExtensionDataStore {
|
|
110
|
-
@Value(CODING_AGENT_OPTIONS)
|
|
111
|
-
protected readonly codingAgentOptions?: CodingAgentOptions;
|
|
112
|
-
|
|
113
|
-
@Value(TA_EXEC_OPTIONS)
|
|
114
|
-
protected readonly execOptions?: TaExecOptions;
|
|
115
|
-
|
|
116
|
-
/** One write at a time per file: each reads what the one before wrote. */
|
|
117
|
-
protected readonly writes = new Map<string, Promise<void>>();
|
|
118
|
-
protected readonly listeners = new Set<(name: string, key: string, cwd?: string) => void>();
|
|
119
|
-
|
|
120
|
-
onChange(listener: (name: string, key: string, cwd?: string) => void): () => void {
|
|
121
|
-
this.listeners.add(listener);
|
|
122
|
-
return () => this.listeners.delete(listener);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async get(name: string, key: string, cwd?: string): Promise<unknown> {
|
|
126
|
-
const file = this.file(name, cwd);
|
|
127
|
-
await this.writes.get(file)?.catch(() => undefined);
|
|
128
|
-
return ExtensionDataUtil.parse(await this.read(file))[ExtensionDataUtil.checkKey(key)];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
set(name: string, key: string, value: unknown, cwd?: string): Promise<void> {
|
|
132
|
-
const file = this.file(name, cwd);
|
|
133
|
-
ExtensionDataUtil.checkKey(key);
|
|
134
|
-
const directory = ExtensionDataUtil.checkCwd(cwd);
|
|
135
|
-
const next = (this.writes.get(file) ?? Promise.resolve())
|
|
136
|
-
.catch(() => undefined)
|
|
137
|
-
.then(async () => {
|
|
138
|
-
const text = ExtensionDataUtil.update(await this.read(file), key, value);
|
|
139
|
-
await mkdir(dirname(file), { recursive: true });
|
|
140
|
-
await writeFile(`${file}.tmp`, text, { mode: 0o600 });
|
|
141
|
-
await rename(`${file}.tmp`, file);
|
|
142
|
-
for (const listener of this.listeners) {
|
|
143
|
-
try {
|
|
144
|
-
listener(name, key, directory);
|
|
145
|
-
} catch {
|
|
146
|
-
// A listener of a package that failed: the others still hear.
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
this.writes.set(file, next);
|
|
151
|
-
const done = () => {
|
|
152
|
-
if (this.writes.get(file) === next) {
|
|
153
|
-
this.writes.delete(file);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
next.then(done, done);
|
|
157
|
-
return next;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
protected file(name: string, cwd: unknown): string {
|
|
161
|
-
const directory = ExtensionDataUtil.checkCwd(cwd);
|
|
162
|
-
return ExtensionDataUtil.file(
|
|
163
|
-
this.agentDir(),
|
|
164
|
-
name,
|
|
165
|
-
directory === undefined ? undefined : ExtensionDataUtil.directoryId(directory, this.execOptions?.url ?? ''),
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
protected agentDir(): string {
|
|
170
|
-
return this.codingAgentOptions?.agentDir ?? TaBrand.agentDir();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
protected async read(file: string): Promise<string | undefined> {
|
|
174
|
-
try {
|
|
175
|
-
return await readFile(file, 'utf8');
|
|
176
|
-
} catch {
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import { CODING_AGENT_OPTIONS, type CodingAgentOptions, ModelRuntimeProvider, PiSdkUtil } from '@celljs/ai-coding-agent';
|
|
3
|
-
import { Autowired, Component, Value } from '@celljs/core';
|
|
4
|
-
import { TaPackages } from '@celljs/ta-harness';
|
|
5
|
-
|
|
6
|
-
export const ExtensionProviders = Symbol('ExtensionProviders');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The model providers that pi packages register (`pi.registerProvider`), before any session: pi registers
|
|
10
|
-
* them in the model runtime that the sessions of ta serve share when it loads a session's extensions, so
|
|
11
|
-
* until a session opened, a client would see none of them (no sign-in, no model to pick).
|
|
12
|
-
*/
|
|
13
|
-
export interface ExtensionProviders {
|
|
14
|
-
/** Loads the extensions of the user once, for the providers they register; later calls wait for that. */
|
|
15
|
-
ensure(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Component(ExtensionProviders)
|
|
19
|
-
export class ExtensionProvidersImpl implements ExtensionProviders {
|
|
20
|
-
@Value(CODING_AGENT_OPTIONS)
|
|
21
|
-
protected readonly codingAgentOptions?: CodingAgentOptions;
|
|
22
|
-
|
|
23
|
-
@Autowired(ModelRuntimeProvider)
|
|
24
|
-
protected readonly modelRuntimeProvider: ModelRuntimeProvider;
|
|
25
|
-
|
|
26
|
-
protected loading?: Promise<void>;
|
|
27
|
-
|
|
28
|
-
ensure(): Promise<void> {
|
|
29
|
-
this.loading ??= this.load().catch(() => undefined);
|
|
30
|
-
return this.loading;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* pi's services of a directory without a project (the home directory, its project resources not
|
|
35
|
-
* trusted): the built-in packages and those of the user's settings, as a session loads them.
|
|
36
|
-
*/
|
|
37
|
-
protected async load(): Promise<void> {
|
|
38
|
-
const sdk = await PiSdkUtil.load();
|
|
39
|
-
const agentDir = this.codingAgentOptions?.agentDir ?? sdk.getAgentDir();
|
|
40
|
-
const cwd = homedir();
|
|
41
|
-
await sdk.createAgentSessionServices({
|
|
42
|
-
cwd,
|
|
43
|
-
agentDir,
|
|
44
|
-
settingsManager: sdk.SettingsManager.create(cwd, agentDir, { projectTrusted: false }),
|
|
45
|
-
modelRuntime: await this.modelRuntimeProvider.provide(),
|
|
46
|
-
resourceLoaderOptions: TaPackages.loaderOptions(agentDir),
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|