@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,172 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { WebExtensionCatalogImpl } from './web-extension-catalog';
|
|
6
|
-
import { WebExtensionUtil } from './web-extension-util';
|
|
7
|
-
|
|
8
|
-
const WEB = 'export default function (pi) { pi.ui.setWidget("hello", () => "hi"); }\n';
|
|
9
|
-
|
|
10
|
-
function write(file: string, content: string) {
|
|
11
|
-
mkdirSync(join(file, '..'), { recursive: true });
|
|
12
|
-
writeFileSync(file, content);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe('WebExtensionUtil', () => {
|
|
16
|
-
let root: string;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
root = mkdtempSync(join(tmpdir(), 'ta-web-ext-'));
|
|
19
|
-
});
|
|
20
|
-
afterEach(() => rmSync(root, { recursive: true, force: true }));
|
|
21
|
-
|
|
22
|
-
it('reads pi.web of package.json, and only modules inside the package', () => {
|
|
23
|
-
write(
|
|
24
|
-
join(root, 'package.json'),
|
|
25
|
-
JSON.stringify({ name: 'notes', version: '1.0.0', pi: { web: ['./web.js', '../outside.js', 'missing.js', 'style.css'] } }),
|
|
26
|
-
);
|
|
27
|
-
write(join(root, 'web.js'), WEB);
|
|
28
|
-
write(join(root, 'style.css'), '');
|
|
29
|
-
const [info, ...rest] = WebExtensionUtil.describe({ root, scope: 'user', origin: 'directory', source: root });
|
|
30
|
-
expect(rest).toEqual([]);
|
|
31
|
-
expect(info).toMatchObject({ name: 'notes', version: '1.0.0', entry: 'web.js', scope: 'user', hash: WebExtensionUtil.hash(WEB) });
|
|
32
|
-
expect(() => WebExtensionUtil.read({ root, scope: 'user', origin: 'directory', source: root }, '../outside.js')).toThrow('outside its package');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('takes the modules of web/ when package.json does not say', () => {
|
|
36
|
-
write(join(root, 'package.json'), JSON.stringify({ pi: { extensions: ['./index.ts'] } }));
|
|
37
|
-
write(join(root, 'web/b.mjs'), WEB);
|
|
38
|
-
write(join(root, 'web/a.js'), WEB);
|
|
39
|
-
write(join(root, 'web/notes.md'), '');
|
|
40
|
-
expect(WebExtensionUtil.describe({ root, scope: 'user', origin: 'directory', source: root }).map(info => info.entry)).toEqual([
|
|
41
|
-
'web/a.js',
|
|
42
|
-
'web/b.mjs',
|
|
43
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('keeps the id when the file changes and changes the hash', () => {
|
|
47
|
-
const pkg = { root, scope: 'user' as const, origin: 'directory' as const, source: root };
|
|
48
|
-
write(join(root, 'package.json'), JSON.stringify({ pi: { web: ['web.js'] } }));
|
|
49
|
-
write(join(root, 'web.js'), WEB);
|
|
50
|
-
const before = WebExtensionUtil.describe(pkg)[0];
|
|
51
|
-
write(join(root, 'web.js'), `${WEB}// changed\n`);
|
|
52
|
-
const after = WebExtensionUtil.describe(pkg)[0];
|
|
53
|
-
expect(after.id).toBe(before.id);
|
|
54
|
-
expect(after.hash).not.toBe(before.hash);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('WebExtensionCatalogImpl', () => {
|
|
59
|
-
let home: string;
|
|
60
|
-
let cwd: string;
|
|
61
|
-
let catalog: WebExtensionCatalogImpl;
|
|
62
|
-
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
home = mkdtempSync(join(tmpdir(), 'ta-web-cat-'));
|
|
65
|
-
// The packages that come with ta, as its build lays them out.
|
|
66
|
-
process.env.PI_PACKAGE_DIR = join(home, 'pi');
|
|
67
|
-
mkdirSync(join(home, 'pi/packages'), { recursive: true });
|
|
68
|
-
cwd = join(home, 'project');
|
|
69
|
-
mkdirSync(cwd);
|
|
70
|
-
const agentDir = join(home, 'agent');
|
|
71
|
-
catalog = new WebExtensionCatalogImpl();
|
|
72
|
-
Object.assign(catalog, { codingAgentOptions: { agentDir }, directories: { toPi: (location: string) => location, fromPi: (dir: string) => dir } });
|
|
73
|
-
// A directory in extensions/, and a package of the packages setting elsewhere.
|
|
74
|
-
write(join(agentDir, 'extensions/notes/package.json'), JSON.stringify({ name: 'notes', pi: { web: ['web.js'] } }));
|
|
75
|
-
write(join(agentDir, 'extensions/notes/web.js'), WEB);
|
|
76
|
-
write(join(agentDir, 'extensions/cli-only/package.json'), JSON.stringify({ name: 'cli-only', pi: { extensions: ['index.ts'] } }));
|
|
77
|
-
write(join(home, 'pomodoro/package.json'), JSON.stringify({ name: 'pomodoro', pi: { web: ['web.js'] } }));
|
|
78
|
-
write(join(home, 'pomodoro/web.js'), WEB);
|
|
79
|
-
write(join(agentDir, 'settings.json'), JSON.stringify({ packages: [join(home, 'pomodoro')] }));
|
|
80
|
-
});
|
|
81
|
-
afterEach(() => {
|
|
82
|
-
rmSync(home, { recursive: true, force: true });
|
|
83
|
-
if (packageDir === undefined) {
|
|
84
|
-
delete process.env.PI_PACKAGE_DIR;
|
|
85
|
-
} else {
|
|
86
|
-
process.env.PI_PACKAGE_DIR = packageDir;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('lists the web extensions of packages and extension directories', async () => {
|
|
91
|
-
const list = await catalog.list(cwd);
|
|
92
|
-
expect(list.map(info => [info.name, info.origin]).sort()).toEqual([
|
|
93
|
-
['notes', 'directory'],
|
|
94
|
-
['pomodoro', 'package'],
|
|
95
|
-
]);
|
|
96
|
-
const notes = list.find(info => info.name === 'notes')!;
|
|
97
|
-
expect(await catalog.read(cwd, notes.id)).toEqual({ id: notes.id, hash: notes.hash, code: WEB });
|
|
98
|
-
await expect(catalog.read(cwd, 'nope')).rejects.toThrow('No package has the web extension nope');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('removes a package from the setting, and a directory from extensions/', async () => {
|
|
102
|
-
const list = await catalog.list(cwd);
|
|
103
|
-
await catalog.remove(cwd, list.find(info => info.name === 'pomodoro')!.id);
|
|
104
|
-
await catalog.remove(cwd, list.find(info => info.name === 'notes')!.id);
|
|
105
|
-
expect(await catalog.list(cwd)).toEqual([]);
|
|
106
|
-
expect(existsSync(join(home, 'pomodoro/web.js'))).toBe(true);
|
|
107
|
-
expect(existsSync(join(home, 'agent/extensions/notes'))).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('lists built-in packages, turns them off and on, and does not remove them', async () => {
|
|
111
|
-
write(join(home, 'pi/packages/ta-channels/package.json'), JSON.stringify({ name: '@celljs/ta-channels', pi: { web: ['web/index.js'] } }));
|
|
112
|
-
write(join(home, 'pi/packages/ta-channels/web/index.js'), WEB);
|
|
113
|
-
const builtin = () => catalog.list(cwd).then(list => list.find(info => info.origin === 'builtin')!);
|
|
114
|
-
expect(await builtin()).toMatchObject({ name: '@celljs/ta-channels', scope: 'user', enabled: true });
|
|
115
|
-
await catalog.setEnabled(cwd, '@celljs/ta-channels', false);
|
|
116
|
-
expect(await builtin()).toMatchObject({ enabled: false });
|
|
117
|
-
expect(JSON.parse(readFileSync(join(home, 'agent/ta.json'), 'utf8'))).toEqual({ disabledPackages: ['@celljs/ta-channels'] });
|
|
118
|
-
await catalog.setEnabled(cwd, '@celljs/ta-channels', true);
|
|
119
|
-
expect(await builtin()).toMatchObject({ enabled: true });
|
|
120
|
-
await expect(catalog.remove(cwd, (await builtin()).id)).rejects.toThrow('cannot be removed');
|
|
121
|
-
await expect(catalog.setEnabled(cwd, 'notes', false)).rejects.toThrow('neither a package that comes with Ta nor the id');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('lists every package, with what it holds, also those without a web extension', async () => {
|
|
125
|
-
const list = await catalog.packages(cwd);
|
|
126
|
-
const cliOnly = list.find(info => info.name === 'cli-only')!;
|
|
127
|
-
expect(cliOnly).toMatchObject({ origin: 'directory', scope: 'user', resources: ['extensions'], root: join(home, 'agent/extensions/cli-only') });
|
|
128
|
-
expect(list.find(info => info.name === 'notes')).toMatchObject({ resources: ['web'] });
|
|
129
|
-
expect(list.find(info => info.name === 'pomodoro')).toMatchObject({ origin: 'package', source: join(home, 'pomodoro') });
|
|
130
|
-
await catalog.removePackage(cwd, cliOnly.id);
|
|
131
|
-
expect(existsSync(join(home, 'agent/extensions/cli-only'))).toBe(false);
|
|
132
|
-
await expect(catalog.removePackage(cwd, 'nope')).rejects.toThrow('No package has the id nope');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('installs a package as ta install does, for the user', async () => {
|
|
136
|
-
write(join(home, 'timer/package.json'), JSON.stringify({ name: 'timer', pi: { extensions: ['index.ts'] } }));
|
|
137
|
-
await catalog.install(cwd, join(home, 'timer'), 'user');
|
|
138
|
-
expect(JSON.parse(readFileSync(join(home, 'agent/settings.json'), 'utf8')).packages).toHaveLength(2);
|
|
139
|
-
expect((await catalog.packages(cwd)).map(info => info.name)).toContain('timer');
|
|
140
|
-
await expect(catalog.install(cwd, ' ', 'user')).rejects.toThrow('source of one line');
|
|
141
|
-
await expect(catalog.install(cwd, 'npm:a\nb', 'user')).rejects.toThrow('source of one line');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('turns the other packages off and on as pi config does, and those with only a web extension in ta.json', async () => {
|
|
145
|
-
write(join(home, 'agent/extensions/cli-only/index.ts'), 'export default function () {}\n');
|
|
146
|
-
write(join(home, 'pomodoro/index.ts'), 'export default function () {}\n');
|
|
147
|
-
write(join(home, 'pomodoro/package.json'), JSON.stringify({ name: 'pomodoro', pi: { web: ['web.js'], extensions: ['index.ts'] } }));
|
|
148
|
-
const byName = async (name: string) => (await catalog.packages(cwd)).find(info => info.name === name)!;
|
|
149
|
-
const settings = () => JSON.parse(readFileSync(join(home, 'agent/settings.json'), 'utf8'));
|
|
150
|
-
expect((await byName('cli-only')).enabled).toBe(true);
|
|
151
|
-
|
|
152
|
-
// In extensions/: a pattern in the extensions list of the settings.
|
|
153
|
-
await catalog.setEnabled(cwd, (await byName('cli-only')).id, false);
|
|
154
|
-
expect(settings().extensions).toEqual(['-extensions/cli-only/index.ts']);
|
|
155
|
-
expect((await byName('cli-only')).enabled).toBe(false);
|
|
156
|
-
await catalog.setEnabled(cwd, (await byName('cli-only')).id, true);
|
|
157
|
-
expect(settings().extensions).toEqual(['+extensions/cli-only/index.ts']);
|
|
158
|
-
expect((await byName('cli-only')).enabled).toBe(true);
|
|
159
|
-
|
|
160
|
-
// A package of the setting: a filter of its entry; its web extension follows.
|
|
161
|
-
await catalog.setEnabled(cwd, (await byName('pomodoro')).id, false);
|
|
162
|
-
expect(settings().packages).toEqual([{ source: join(home, 'pomodoro'), extensions: ['-index.ts'] }]);
|
|
163
|
-
expect((await catalog.list(cwd)).find(info => info.name === 'pomodoro')).toMatchObject({ enabled: false });
|
|
164
|
-
|
|
165
|
-
// Only a web extension: ta.json.
|
|
166
|
-
await catalog.setEnabled(cwd, (await byName('notes')).id, false);
|
|
167
|
-
expect(JSON.parse(readFileSync(join(home, 'agent/ta.json'), 'utf8')).disabledWeb).toEqual([join(home, 'agent/extensions/notes')]);
|
|
168
|
-
expect((await catalog.list(cwd)).find(info => info.name === 'notes')).toMatchObject({ enabled: false });
|
|
169
|
-
await catalog.setEnabled(cwd, (await byName('notes')).id, true);
|
|
170
|
-
expect((await byName('notes')).enabled).toBe(true);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { CODING_AGENT_OPTIONS, type CodingAgentOptions, type PiSdk, PiSdkUtil } from '@celljs/ai-coding-agent';
|
|
4
|
-
import { Autowired, Component, Value } from '@celljs/core';
|
|
5
|
-
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
6
|
-
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
7
|
-
import type { TaPackageInfo, TaSettingsScope, TaWebExtensionInfo, TaWebExtensionSource } from '@celljs/ta-protocol';
|
|
8
|
-
import { WebExtensionCatalog } from './host-protocol';
|
|
9
|
-
import { PackageSwitch } from './package-switch';
|
|
10
|
-
import { PiDirectories } from './remote/remote-protocol';
|
|
11
|
-
import { TaErrors } from './ta-errors';
|
|
12
|
-
import { type WebExtensionPackage, WebExtensionUtil } from './web-extension-util';
|
|
13
|
-
|
|
14
|
-
type PackageManager = InstanceType<PiSdk['DefaultPackageManager']>;
|
|
15
|
-
type SettingsManager = ReturnType<PiSdk['SettingsManager']['create']>;
|
|
16
|
-
|
|
17
|
-
interface Loaded {
|
|
18
|
-
packages: WebExtensionPackage[];
|
|
19
|
-
manager: PackageManager;
|
|
20
|
-
settings: SettingsManager;
|
|
21
|
-
trusted: boolean;
|
|
22
|
-
projectDir: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Finds packages, and their web extensions, where pi finds extensions: in the packages that come with ta, in the packages of
|
|
27
|
-
* its `packages` setting, and in the package directories of `extensions/`, of the user and, in a trusted
|
|
28
|
-
* project, of the project.
|
|
29
|
-
*/
|
|
30
|
-
@Component(WebExtensionCatalog)
|
|
31
|
-
export class WebExtensionCatalogImpl implements WebExtensionCatalog {
|
|
32
|
-
@Value(CODING_AGENT_OPTIONS)
|
|
33
|
-
protected readonly codingAgentOptions?: CodingAgentOptions;
|
|
34
|
-
|
|
35
|
-
@Autowired(PiDirectories)
|
|
36
|
-
protected readonly directories: PiDirectories;
|
|
37
|
-
|
|
38
|
-
async packages(cwd: string): Promise<TaPackageInfo[]> {
|
|
39
|
-
const { packages } = await this.load(cwd);
|
|
40
|
-
return packages.map(pkg => WebExtensionUtil.describePackage(pkg));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async install(cwd: string, source: string, scope: TaSettingsScope): Promise<void> {
|
|
44
|
-
const trimmed = typeof source === 'string' ? source.trim() : '';
|
|
45
|
-
if (!trimmed || /[\r\n]/.test(trimmed)) {
|
|
46
|
-
throw TaErrors.invalidArgument('A package needs a source of one line.', 'Pass npm:<name>, git:<repository>, a URL of a repository or a path.');
|
|
47
|
-
}
|
|
48
|
-
const { manager, trusted } = await this.load(cwd);
|
|
49
|
-
if (scope === 'project' && !trusted) {
|
|
50
|
-
throw TaErrors.invalidArgument(`The project ${cwd} is not trusted.`, 'Trust it first, or install the package for the user.');
|
|
51
|
-
}
|
|
52
|
-
await manager.installAndPersist(trimmed, { local: scope === 'project' });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async removePackage(cwd: string, id: string): Promise<void> {
|
|
56
|
-
const { packages, manager } = await this.load(cwd);
|
|
57
|
-
const pkg = packages.find(candidate => WebExtensionUtil.describePackage(candidate).id === id);
|
|
58
|
-
if (!pkg) {
|
|
59
|
-
throw TaErrors.invalidArgument(`No package has the id ${id}.`, 'listPackages lists the ones there are; the package may have moved or gone.');
|
|
60
|
-
}
|
|
61
|
-
await this.removeRoot(pkg, manager);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async list(cwd: string): Promise<TaWebExtensionInfo[]> {
|
|
65
|
-
const { packages } = await this.load(cwd);
|
|
66
|
-
return packages.flatMap(pkg => WebExtensionUtil.describe(pkg));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async read(cwd: string, id: string): Promise<TaWebExtensionSource> {
|
|
70
|
-
const { pkg, info } = await this.find(cwd, id);
|
|
71
|
-
const code = WebExtensionUtil.read(pkg, info.entry);
|
|
72
|
-
return { id, hash: WebExtensionUtil.hash(code), code };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async remove(cwd: string, id: string): Promise<void> {
|
|
76
|
-
const { pkg } = await this.find(cwd, id);
|
|
77
|
-
await this.removeRoot(pkg, (await this.load(cwd)).manager);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async setEnabled(cwd: string, nameOrId: string, enabled: boolean): Promise<void> {
|
|
81
|
-
if (TaPackages.builtins().some(pkg => pkg.name === nameOrId)) {
|
|
82
|
-
TaPackages.setEnabled(this.agentDir(), nameOrId, enabled);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const loaded = await this.load(cwd);
|
|
86
|
-
const pkg = loaded.packages.find(candidate => candidate.origin !== 'builtin' && WebExtensionUtil.describePackage(candidate).id === nameOrId);
|
|
87
|
-
if (!pkg) {
|
|
88
|
-
throw TaErrors.invalidArgument(
|
|
89
|
-
`${nameOrId} is neither a package that comes with Ta nor the id of a package.`,
|
|
90
|
-
'Pass the name of a built-in package, or an id of listPackages.',
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
const resources = PackageSwitch.resourcesOf(await this.resolve(loaded.manager), pkg.root);
|
|
94
|
-
if (resources.length === 0) {
|
|
95
|
-
// Only a web extension: pi has nothing of it to turn off.
|
|
96
|
-
TaPackages.setWebEnabled(this.agentDir(), pkg.root, enabled);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
PackageSwitch.set(loaded.settings, resources, enabled, { agentDir: this.agentDir(), projectDir: loaded.projectDir });
|
|
100
|
-
await loaded.settings.flush();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
protected async removeRoot(pkg: WebExtensionPackage, manager: PackageManager): Promise<void> {
|
|
104
|
-
if (pkg.origin === 'builtin') {
|
|
105
|
-
const { name } = WebExtensionUtil.describePackage(pkg);
|
|
106
|
-
throw TaErrors.invalidArgument(`${name} comes with Ta and cannot be removed.`, 'Turn it off with setPackageEnabled instead.');
|
|
107
|
-
}
|
|
108
|
-
if (pkg.origin === 'directory') {
|
|
109
|
-
rmSync(pkg.root, { recursive: true, force: true });
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
await manager.removeAndPersist(pkg.source, { local: pkg.scope === 'project' });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
protected agentDir(): string {
|
|
116
|
-
return this.codingAgentOptions?.agentDir ?? TaBrand.agentDir();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
protected async find(cwd: string, id: string): Promise<{ pkg: WebExtensionPackage; info: TaWebExtensionInfo }> {
|
|
120
|
-
const { packages } = await this.load(cwd);
|
|
121
|
-
for (const pkg of packages) {
|
|
122
|
-
const info = WebExtensionUtil.describe(pkg).find(candidate => candidate.id === id);
|
|
123
|
-
if (info) {
|
|
124
|
-
return { pkg, info };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
throw TaErrors.invalidArgument(
|
|
128
|
-
`No package has the web extension ${id}.`,
|
|
129
|
-
'listWebExtensions lists the ones there are; the package may have moved or gone.',
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** What pi loads now; a package not installed yet is left out, not installed. */
|
|
134
|
-
protected resolve(manager: PackageManager) {
|
|
135
|
-
return manager.resolve(async () => 'skip');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
protected async load(location: string): Promise<Loaded> {
|
|
139
|
-
const cwd = this.directories.toPi(location);
|
|
140
|
-
const sdk = await PiSdkUtil.load();
|
|
141
|
-
const agentDir = this.codingAgentOptions?.agentDir ?? sdk.getAgentDir();
|
|
142
|
-
const trusted = new sdk.ProjectTrustStore(agentDir).get(cwd) ?? !sdk.hasTrustRequiringProjectResources(cwd);
|
|
143
|
-
const settingsManager = sdk.SettingsManager.create(cwd, agentDir, { projectTrusted: trusted });
|
|
144
|
-
const manager = new sdk.DefaultPackageManager({ cwd, agentDir, settingsManager });
|
|
145
|
-
const found = new Map<string, WebExtensionPackage>();
|
|
146
|
-
const off = TaPackages.disabled(agentDir);
|
|
147
|
-
for (const pkg of TaPackages.builtins()) {
|
|
148
|
-
found.set(pkg.root, { root: pkg.root, scope: 'user', origin: 'builtin', source: pkg.root, enabled: !off.has(pkg.name) });
|
|
149
|
-
}
|
|
150
|
-
for (const pkg of manager.listConfiguredPackages()) {
|
|
151
|
-
if (pkg.installedPath && (pkg.scope === 'user' || trusted) && !found.has(pkg.installedPath)) {
|
|
152
|
-
found.set(pkg.installedPath, { root: pkg.installedPath, scope: pkg.scope, origin: 'package', source: pkg.source });
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
const directories: [string, WebExtensionPackage['scope']][] = [[join(agentDir, 'extensions'), 'user']];
|
|
156
|
-
if (trusted) {
|
|
157
|
-
directories.push([join(cwd, sdk.CONFIG_DIR_NAME, 'extensions'), 'project']);
|
|
158
|
-
}
|
|
159
|
-
for (const [directory, scope] of directories) {
|
|
160
|
-
for (const root of WebExtensionUtil.packageDirectories(directory)) {
|
|
161
|
-
if (!found.has(root)) {
|
|
162
|
-
found.set(root, { root, scope, origin: 'directory', source: root });
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
// The others are on while pi loads any of theirs, or, with only a web extension, unless turned off in ta.json.
|
|
167
|
-
const resolved = await this.resolve(manager);
|
|
168
|
-
const webOff = TaPackages.disabledWeb(agentDir);
|
|
169
|
-
for (const pkg of found.values()) {
|
|
170
|
-
if (pkg.origin !== 'builtin') {
|
|
171
|
-
const resources = PackageSwitch.resourcesOf(resolved, pkg.root);
|
|
172
|
-
pkg.enabled = resources.length > 0 ? PackageSwitch.isEnabled(resources) : !webOff.has(pkg.root);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return { packages: [...found.values()], manager, settings: settingsManager, trusted, projectDir: join(cwd, sdk.CONFIG_DIR_NAME) };
|
|
176
|
-
}
|
|
177
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
-
import { basename, extname, join, relative, resolve, sep } from 'node:path';
|
|
4
|
-
import type { TaPackageInfo, TaPackageResource, TaWebExtensionInfo } from '@celljs/ta-protocol';
|
|
5
|
-
|
|
6
|
-
/** The largest web extension the server sends: one module, without its dependencies. */
|
|
7
|
-
const MAX_BYTES = 2 * 1024 * 1024;
|
|
8
|
-
const MODULE = new Set(['.js', '.mjs']);
|
|
9
|
-
|
|
10
|
-
/** Where a package is and how pi came to load it. */
|
|
11
|
-
export interface WebExtensionPackage {
|
|
12
|
-
root: string;
|
|
13
|
-
scope: TaWebExtensionInfo['scope'];
|
|
14
|
-
origin: TaWebExtensionInfo['origin'];
|
|
15
|
-
source: string;
|
|
16
|
-
/** False for a built-in package that is turned off; default true. */
|
|
17
|
-
enabled?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface PackageJson {
|
|
21
|
-
name?: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
version?: string;
|
|
24
|
-
pi?: Partial<Record<TaPackageResource, unknown>>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** What pi loads besides web extensions, in the order a list shows them. */
|
|
28
|
-
const PI_RESOURCES: readonly Exclude<TaPackageResource, 'web'>[] = ['extensions', 'skills', 'prompts', 'themes'];
|
|
29
|
-
|
|
30
|
-
/** Reads the web extensions of packages: `pi.web` of their `package.json`, else the modules in `web/`. */
|
|
31
|
-
export namespace WebExtensionUtil {
|
|
32
|
-
export function describe(pkg: WebExtensionPackage): TaWebExtensionInfo[] {
|
|
33
|
-
const manifest = readManifest(pkg.root);
|
|
34
|
-
return entries(pkg.root, manifest).map(entry => ({
|
|
35
|
-
id: id(pkg, entry),
|
|
36
|
-
name: manifest?.name ?? basename(pkg.root),
|
|
37
|
-
description: manifest?.description,
|
|
38
|
-
version: manifest?.version,
|
|
39
|
-
scope: pkg.scope,
|
|
40
|
-
origin: pkg.origin,
|
|
41
|
-
enabled: pkg.enabled ?? true,
|
|
42
|
-
source: pkg.source,
|
|
43
|
-
entry,
|
|
44
|
-
hash: hash(readFileSync(join(pkg.root, entry), 'utf8')),
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** The package itself, whatever it holds. */
|
|
49
|
-
export function describePackage(pkg: WebExtensionPackage): TaPackageInfo {
|
|
50
|
-
const manifest = readManifest(pkg.root);
|
|
51
|
-
const resources: TaPackageResource[] = PI_RESOURCES.filter(type => holds(pkg.root, manifest, type));
|
|
52
|
-
if (entries(pkg.root, manifest).length > 0) {
|
|
53
|
-
resources.splice(1, 0, 'web');
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
id: createHash('sha256').update(`${pkg.scope}\0${pkg.root}`).digest('hex').slice(0, 16),
|
|
57
|
-
name: manifest?.name ?? basename(pkg.root),
|
|
58
|
-
description: manifest?.description,
|
|
59
|
-
version: manifest?.version,
|
|
60
|
-
scope: pkg.scope,
|
|
61
|
-
origin: pkg.origin,
|
|
62
|
-
enabled: pkg.enabled ?? true,
|
|
63
|
-
source: pkg.source,
|
|
64
|
-
root: pkg.root,
|
|
65
|
-
resources,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** The file of the extension: a module in the package no larger than 2 MB. */
|
|
70
|
-
export function read(pkg: WebExtensionPackage, entry: string): string {
|
|
71
|
-
const file = resolve(pkg.root, entry);
|
|
72
|
-
if (!inside(pkg.root, file)) {
|
|
73
|
-
throw new Error(`The web extension ${entry} is outside its package ${pkg.root}.`);
|
|
74
|
-
}
|
|
75
|
-
if (statSync(file).size > MAX_BYTES) {
|
|
76
|
-
throw new Error(`The web extension ${file} is larger than 2 MB; it is one module that the web client loads whole.`);
|
|
77
|
-
}
|
|
78
|
-
return readFileSync(file, 'utf8');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function hash(code: string): string {
|
|
82
|
-
return createHash('sha256').update(code).digest('hex').slice(0, 16);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** The subdirectories of an `extensions/` directory that are packages, as pi finds them there. */
|
|
86
|
-
export function packageDirectories(directory: string): string[] {
|
|
87
|
-
if (!existsSync(directory)) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
return readdirSync(directory, { withFileTypes: true })
|
|
91
|
-
.filter(entry => entry.isDirectory() && !entry.name.startsWith('.') && existsSync(join(directory, entry.name, 'package.json')))
|
|
92
|
-
.map(entry => join(directory, entry.name));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Stable for a package where it is: the scope, the directory and the file, not the content. */
|
|
96
|
-
function id(pkg: WebExtensionPackage, entry: string): string {
|
|
97
|
-
return createHash('sha256').update(`${pkg.scope}\0${pkg.root}\0${entry}`).digest('hex').slice(0, 16);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function readManifest(root: string): PackageJson | undefined {
|
|
101
|
-
try {
|
|
102
|
-
return JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as PackageJson;
|
|
103
|
-
} catch {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** As pi finds them: what `pi` of package.json declares, else the directory of that name. */
|
|
109
|
-
function holds(root: string, manifest: PackageJson | undefined, type: Exclude<TaPackageResource, 'web'>): boolean {
|
|
110
|
-
if (manifest?.pi) {
|
|
111
|
-
const declared = manifest.pi[type];
|
|
112
|
-
return Array.isArray(declared) ? declared.length > 0 : typeof declared === 'string' && declared !== '';
|
|
113
|
-
}
|
|
114
|
-
const directory = join(root, type);
|
|
115
|
-
return existsSync(directory) && statSync(directory).isDirectory() && readdirSync(directory).length > 0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function entries(root: string, manifest?: PackageJson): string[] {
|
|
119
|
-
const declared = manifest?.pi?.web;
|
|
120
|
-
const files = Array.isArray(declared) ? declared.filter((entry): entry is string => typeof entry === 'string') : conventional(root);
|
|
121
|
-
return files
|
|
122
|
-
.map(entry => relative(root, resolve(root, entry)).split(sep).join('/'))
|
|
123
|
-
.filter(entry => {
|
|
124
|
-
const file = join(root, entry);
|
|
125
|
-
return inside(root, file) && MODULE.has(extname(file)) && existsSync(file) && statSync(file).isFile();
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function conventional(root: string): string[] {
|
|
130
|
-
const directory = join(root, 'web');
|
|
131
|
-
if (!existsSync(directory)) {
|
|
132
|
-
return [];
|
|
133
|
-
}
|
|
134
|
-
return readdirSync(directory)
|
|
135
|
-
.filter(file => MODULE.has(extname(file)))
|
|
136
|
-
.sort()
|
|
137
|
-
.map(file => `web/${file}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function inside(root: string, file: string): boolean {
|
|
141
|
-
const path = relative(resolve(root), file);
|
|
142
|
-
return path !== '' && !path.startsWith('..') && !path.startsWith(sep) && !/^[a-zA-Z]:/.test(path);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { Component } from '@celljs/core';
|
|
4
|
-
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
5
|
-
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
6
|
-
|
|
7
|
-
export const TaWorkingDirectory = Symbol('TaWorkingDirectory');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The working directory the user chose for ta serve (TaServer.setWorkingDirectory), and the hosts of the
|
|
11
|
-
* remote directories opened lately (TaRemoteServer), kept across restarts.
|
|
12
|
-
*/
|
|
13
|
-
export interface TaWorkingDirectory {
|
|
14
|
-
get(): string | undefined;
|
|
15
|
-
set(cwd: string): void;
|
|
16
|
-
/** The latest first. */
|
|
17
|
-
recentHosts(): string[];
|
|
18
|
-
addRecentHost(host: string): void;
|
|
19
|
-
removeRecentHost(host: string): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Hosts kept in recentHosts. */
|
|
23
|
-
const RECENT_HOSTS = 10;
|
|
24
|
-
|
|
25
|
-
/** In ta.json of the agent directory, beside Ta's other settings of its own; the file keeps its other keys. */
|
|
26
|
-
@Component(TaWorkingDirectory)
|
|
27
|
-
export class TaWorkingDirectoryImpl implements TaWorkingDirectory {
|
|
28
|
-
protected readonly file = join(TaBrand.agentDir(), TaPackages.SETTINGS_FILE);
|
|
29
|
-
|
|
30
|
-
get(): string | undefined {
|
|
31
|
-
const { workingDirectory } = this.read();
|
|
32
|
-
return typeof workingDirectory === 'string' && workingDirectory ? workingDirectory : undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
set(cwd: string): void {
|
|
36
|
-
this.write({ workingDirectory: cwd });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
recentHosts(): string[] {
|
|
40
|
-
const { remoteHosts } = this.read();
|
|
41
|
-
return Array.isArray(remoteHosts) ? remoteHosts.filter((host): host is string => typeof host === 'string') : [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
addRecentHost(host: string): void {
|
|
45
|
-
const hosts = this.recentHosts();
|
|
46
|
-
if (hosts[0] !== host) {
|
|
47
|
-
this.write({ remoteHosts: [host, ...hosts.filter(other => other !== host)].slice(0, RECENT_HOSTS) });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
removeRecentHost(host: string): void {
|
|
52
|
-
const hosts = this.recentHosts();
|
|
53
|
-
if (hosts.includes(host)) {
|
|
54
|
-
this.write({ remoteHosts: hosts.filter(other => other !== host) });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected write(changes: Record<string, unknown>): void {
|
|
59
|
-
writeFileSync(`${this.file}.tmp`, `${JSON.stringify({ ...this.read(), ...changes }, null, 2)}\n`);
|
|
60
|
-
renameSync(`${this.file}.tmp`, this.file);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
protected read(): Record<string, unknown> {
|
|
64
|
-
try {
|
|
65
|
-
const data = JSON.parse(readFileSync(this.file, 'utf8'));
|
|
66
|
-
return data && typeof data === 'object' && !Array.isArray(data) ? data : {};
|
|
67
|
-
} catch {
|
|
68
|
-
return {};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|