@celljs/ta-host 4.5.1 → 4.6.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.md +31 -8
- package/cell.schema.json +18 -0
- package/cell.yml +4 -0
- package/esm/node/auth-server-impl.d.ts +61 -0
- package/esm/node/auth-server-impl.js +247 -0
- package/esm/node/auth-server-impl.js.map +1 -0
- package/esm/node/client-tool-broker.d.ts +35 -0
- package/esm/node/client-tool-broker.js +82 -0
- package/esm/node/client-tool-broker.js.map +1 -0
- package/esm/node/exec-environment-factory.d.ts +17 -0
- package/esm/node/exec-environment-factory.js +58 -0
- package/esm/node/exec-environment-factory.js.map +1 -0
- package/esm/node/extension-data-notifier.d.ts +41 -0
- package/esm/node/extension-data-notifier.js +119 -0
- package/esm/node/extension-data-notifier.js.map +1 -0
- package/esm/node/extension-data.d.ts +45 -0
- package/esm/node/extension-data.js +181 -0
- package/esm/node/extension-data.js.map +1 -0
- package/esm/node/host-protocol.d.ts +29 -1
- package/esm/node/host-protocol.js +2 -0
- package/esm/node/host-protocol.js.map +1 -1
- package/esm/node/index.d.ts +24 -1
- package/esm/node/index.js +24 -1
- package/esm/node/index.js.map +1 -1
- package/esm/node/package-host-extension.d.ts +9 -0
- package/esm/node/package-host-extension.js +18 -0
- package/esm/node/package-host-extension.js.map +1 -0
- package/esm/node/package-hosts.d.ts +44 -0
- package/esm/node/package-hosts.js +167 -0
- package/esm/node/package-hosts.js.map +1 -0
- package/esm/node/package-server-impl.d.ts +25 -0
- package/esm/node/package-server-impl.js +94 -0
- package/esm/node/package-server-impl.js.map +1 -0
- package/esm/node/package-switch.d.ts +29 -0
- package/esm/node/package-switch.js +68 -0
- package/esm/node/package-switch.js.map +1 -0
- package/esm/node/relay-bridge.d.ts +34 -0
- package/esm/node/relay-bridge.js +105 -0
- package/esm/node/relay-bridge.js.map +1 -0
- package/esm/node/session-info-util.d.ts +16 -0
- package/esm/node/session-info-util.js +49 -0
- package/esm/node/session-info-util.js.map +1 -0
- package/esm/node/session-storage/file-session-storage.d.ts +27 -0
- package/esm/node/session-storage/file-session-storage.js +139 -0
- package/esm/node/session-storage/file-session-storage.js.map +1 -0
- package/esm/node/session-storage/index.d.ts +3 -0
- package/esm/node/session-storage/index.js +4 -0
- package/esm/node/session-storage/index.js.map +1 -0
- package/esm/node/session-storage/session-storage-protocol.d.ts +57 -0
- package/esm/node/session-storage/session-storage-protocol.js +40 -0
- package/esm/node/session-storage/session-storage-protocol.js.map +1 -0
- package/esm/node/session-storage/stored-session.d.ts +46 -0
- package/esm/node/session-storage/stored-session.js +116 -0
- package/esm/node/session-storage/stored-session.js.map +1 -0
- package/esm/node/settings-server-impl.d.ts +11 -0
- package/esm/node/settings-server-impl.js +45 -0
- package/esm/node/settings-server-impl.js.map +1 -0
- package/esm/node/settings-store.d.ts +56 -0
- package/esm/node/settings-store.js +306 -0
- package/esm/node/settings-store.js.map +1 -0
- package/esm/node/ta-access.d.ts +19 -2
- package/esm/node/ta-access.js +64 -7
- package/esm/node/ta-access.js.map +1 -1
- package/esm/node/ta-errors.d.ts +3 -1
- package/esm/node/ta-errors.js +17 -1
- package/esm/node/ta-errors.js.map +1 -1
- package/esm/node/ta-server-impl.d.ts +17 -5
- package/esm/node/ta-server-impl.js +70 -13
- package/esm/node/ta-server-impl.js.map +1 -1
- package/esm/node/ta-session-factory.d.ts +2 -0
- package/esm/node/ta-session-factory.js +25 -11
- package/esm/node/ta-session-factory.js.map +1 -1
- package/esm/node/ta-session.d.ts +9 -1
- package/esm/node/ta-session.js +26 -2
- package/esm/node/ta-session.js.map +1 -1
- package/esm/node/terminal-protocol.d.ts +18 -0
- package/esm/node/terminal-protocol.js +2 -0
- package/esm/node/terminal-protocol.js.map +1 -0
- package/esm/node/terminal-service.d.ts +59 -0
- package/esm/node/terminal-service.js +240 -0
- package/esm/node/terminal-service.js.map +1 -0
- package/esm/node/terminal-util.d.ts +62 -0
- package/esm/node/terminal-util.js +153 -0
- package/esm/node/terminal-util.js.map +1 -0
- package/esm/node/web-extension-catalog.d.ts +38 -0
- package/esm/node/web-extension-catalog.js +160 -0
- package/esm/node/web-extension-catalog.js.map +1 -0
- package/esm/node/web-extension-util.d.ts +21 -0
- package/esm/node/web-extension-util.js +123 -0
- package/esm/node/web-extension-util.js.map +1 -0
- package/esm/node/working-directory.d.ts +13 -0
- package/esm/node/working-directory.js +40 -0
- package/esm/node/working-directory.js.map +1 -0
- package/esm/node/workspace-files.d.ts +47 -0
- package/esm/node/workspace-files.js +265 -0
- package/esm/node/workspace-files.js.map +1 -0
- package/esm/node/workspace-protocol.d.ts +20 -0
- package/esm/node/workspace-protocol.js +3 -0
- package/esm/node/workspace-protocol.js.map +1 -0
- package/esm/node/workspace-server-impl.d.ts +27 -0
- package/esm/node/workspace-server-impl.js +88 -0
- package/esm/node/workspace-server-impl.js.map +1 -0
- package/esm/node/workspace-service.d.ts +31 -0
- package/esm/node/workspace-service.js +209 -0
- package/esm/node/workspace-service.js.map +1 -0
- package/esm/node/workspace-util.d.ts +29 -0
- package/esm/node/workspace-util.js +104 -0
- package/esm/node/workspace-util.js.map +1 -0
- package/lib/node/auth-server-impl.d.ts +62 -0
- package/lib/node/auth-server-impl.d.ts.map +1 -0
- package/lib/node/auth-server-impl.js +250 -0
- package/lib/node/auth-server-impl.js.map +1 -0
- package/lib/node/auth-server-impl.spec.d.ts +2 -0
- package/lib/node/auth-server-impl.spec.d.ts.map +1 -0
- package/lib/node/auth-server-impl.spec.js +47 -0
- package/lib/node/auth-server-impl.spec.js.map +1 -0
- package/lib/node/client-tool-broker.d.ts +36 -0
- package/lib/node/client-tool-broker.d.ts.map +1 -0
- package/lib/node/client-tool-broker.js +86 -0
- package/lib/node/client-tool-broker.js.map +1 -0
- package/lib/node/client-tool-broker.spec.d.ts +2 -0
- package/lib/node/client-tool-broker.spec.d.ts.map +1 -0
- package/lib/node/client-tool-broker.spec.js +49 -0
- package/lib/node/client-tool-broker.spec.js.map +1 -0
- package/lib/node/exec-environment-factory.d.ts +18 -0
- package/lib/node/exec-environment-factory.d.ts.map +1 -0
- package/lib/node/exec-environment-factory.js +61 -0
- package/lib/node/exec-environment-factory.js.map +1 -0
- package/lib/node/extension-data-notifier.d.ts +42 -0
- package/lib/node/extension-data-notifier.d.ts.map +1 -0
- package/lib/node/extension-data-notifier.js +123 -0
- package/lib/node/extension-data-notifier.js.map +1 -0
- package/lib/node/extension-data-notifier.spec.d.ts +2 -0
- package/lib/node/extension-data-notifier.spec.d.ts.map +1 -0
- package/lib/node/extension-data-notifier.spec.js +35 -0
- package/lib/node/extension-data-notifier.spec.js.map +1 -0
- package/lib/node/extension-data.d.ts +46 -0
- package/lib/node/extension-data.d.ts.map +1 -0
- package/lib/node/extension-data.js +184 -0
- package/lib/node/extension-data.js.map +1 -0
- package/lib/node/extension-data.spec.d.ts +2 -0
- package/lib/node/extension-data.spec.d.ts.map +1 -0
- package/lib/node/extension-data.spec.js +99 -0
- package/lib/node/extension-data.spec.js.map +1 -0
- package/lib/node/host-protocol.d.ts +29 -1
- package/lib/node/host-protocol.d.ts.map +1 -1
- package/lib/node/host-protocol.js +3 -1
- package/lib/node/host-protocol.js.map +1 -1
- package/lib/node/index.d.ts +24 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +24 -1
- package/lib/node/index.js.map +1 -1
- package/lib/node/package-host-extension.d.ts +10 -0
- package/lib/node/package-host-extension.d.ts.map +1 -0
- package/lib/node/package-host-extension.js +22 -0
- package/lib/node/package-host-extension.js.map +1 -0
- package/lib/node/package-hosts.d.ts +45 -0
- package/lib/node/package-hosts.d.ts.map +1 -0
- package/lib/node/package-hosts.js +170 -0
- package/lib/node/package-hosts.js.map +1 -0
- package/lib/node/package-hosts.spec.d.ts +2 -0
- package/lib/node/package-hosts.spec.d.ts.map +1 -0
- package/lib/node/package-hosts.spec.js +53 -0
- package/lib/node/package-hosts.spec.js.map +1 -0
- package/lib/node/package-server-impl.d.ts +26 -0
- package/lib/node/package-server-impl.d.ts.map +1 -0
- package/lib/node/package-server-impl.js +97 -0
- package/lib/node/package-server-impl.js.map +1 -0
- package/lib/node/package-switch.d.ts +30 -0
- package/lib/node/package-switch.d.ts.map +1 -0
- package/lib/node/package-switch.js +71 -0
- package/lib/node/package-switch.js.map +1 -0
- package/lib/node/relay-bridge.d.ts +35 -0
- package/lib/node/relay-bridge.d.ts.map +1 -0
- package/lib/node/relay-bridge.js +108 -0
- package/lib/node/relay-bridge.js.map +1 -0
- package/lib/node/session-info-util.d.ts +17 -0
- package/lib/node/session-info-util.d.ts.map +1 -0
- package/lib/node/session-info-util.js +52 -0
- package/lib/node/session-info-util.js.map +1 -0
- package/lib/node/session-info-util.spec.d.ts +2 -0
- package/lib/node/session-info-util.spec.d.ts.map +1 -0
- package/lib/node/session-info-util.spec.js +22 -0
- package/lib/node/session-info-util.spec.js.map +1 -0
- package/lib/node/session-storage/file-session-storage.d.ts +28 -0
- package/lib/node/session-storage/file-session-storage.d.ts.map +1 -0
- package/lib/node/session-storage/file-session-storage.js +143 -0
- package/lib/node/session-storage/file-session-storage.js.map +1 -0
- package/lib/node/session-storage/file-session-storage.spec.d.ts +2 -0
- package/lib/node/session-storage/file-session-storage.spec.d.ts.map +1 -0
- package/lib/node/session-storage/file-session-storage.spec.js +70 -0
- package/lib/node/session-storage/file-session-storage.spec.js.map +1 -0
- package/lib/node/session-storage/index.d.ts +4 -0
- package/lib/node/session-storage/index.d.ts.map +1 -0
- package/lib/node/session-storage/index.js +20 -0
- package/lib/node/session-storage/index.js.map +1 -0
- package/lib/node/session-storage/session-storage-protocol.d.ts +58 -0
- package/lib/node/session-storage/session-storage-protocol.d.ts.map +1 -0
- package/lib/node/session-storage/session-storage-protocol.js +45 -0
- package/lib/node/session-storage/session-storage-protocol.js.map +1 -0
- package/lib/node/session-storage/stored-session.d.ts +47 -0
- package/lib/node/session-storage/stored-session.d.ts.map +1 -0
- package/lib/node/session-storage/stored-session.js +120 -0
- package/lib/node/session-storage/stored-session.js.map +1 -0
- package/lib/node/session-storage/stored-session.spec.d.ts +2 -0
- package/lib/node/session-storage/stored-session.spec.d.ts.map +1 -0
- package/lib/node/session-storage/stored-session.spec.js +73 -0
- package/lib/node/session-storage/stored-session.spec.js.map +1 -0
- package/lib/node/settings-server-impl.d.ts +12 -0
- package/lib/node/settings-server-impl.d.ts.map +1 -0
- package/lib/node/settings-server-impl.js +48 -0
- package/lib/node/settings-server-impl.js.map +1 -0
- package/lib/node/settings-store.d.ts +57 -0
- package/lib/node/settings-store.d.ts.map +1 -0
- package/lib/node/settings-store.js +309 -0
- package/lib/node/settings-store.js.map +1 -0
- package/lib/node/settings-store.spec.d.ts +2 -0
- package/lib/node/settings-store.spec.d.ts.map +1 -0
- package/lib/node/settings-store.spec.js +145 -0
- package/lib/node/settings-store.spec.js.map +1 -0
- package/lib/node/ta-access.d.ts +19 -2
- package/lib/node/ta-access.d.ts.map +1 -1
- package/lib/node/ta-access.js +66 -9
- package/lib/node/ta-access.js.map +1 -1
- package/lib/node/ta-access.spec.js +8 -0
- package/lib/node/ta-access.spec.js.map +1 -1
- package/lib/node/ta-errors.d.ts +3 -1
- package/lib/node/ta-errors.d.ts.map +1 -1
- package/lib/node/ta-errors.js +17 -1
- package/lib/node/ta-errors.js.map +1 -1
- package/lib/node/ta-errors.spec.d.ts +2 -0
- package/lib/node/ta-errors.spec.d.ts.map +1 -0
- package/lib/node/ta-errors.spec.js +25 -0
- package/lib/node/ta-errors.spec.js.map +1 -0
- package/lib/node/ta-server-impl.d.ts +17 -5
- package/lib/node/ta-server-impl.d.ts.map +1 -1
- package/lib/node/ta-server-impl.js +70 -13
- package/lib/node/ta-server-impl.js.map +1 -1
- package/lib/node/ta-session-factory.d.ts +2 -0
- package/lib/node/ta-session-factory.d.ts.map +1 -1
- package/lib/node/ta-session-factory.js +24 -10
- package/lib/node/ta-session-factory.js.map +1 -1
- package/lib/node/ta-session.d.ts +9 -1
- package/lib/node/ta-session.d.ts.map +1 -1
- package/lib/node/ta-session.js +26 -2
- package/lib/node/ta-session.js.map +1 -1
- package/lib/node/terminal-protocol.d.ts +19 -0
- package/lib/node/terminal-protocol.d.ts.map +1 -0
- package/lib/node/terminal-protocol.js +5 -0
- package/lib/node/terminal-protocol.js.map +1 -0
- package/lib/node/terminal-service.d.ts +60 -0
- package/lib/node/terminal-service.d.ts.map +1 -0
- package/lib/node/terminal-service.js +241 -0
- package/lib/node/terminal-service.js.map +1 -0
- package/lib/node/terminal-service.spec.d.ts +2 -0
- package/lib/node/terminal-service.spec.d.ts.map +1 -0
- package/lib/node/terminal-service.spec.js +79 -0
- package/lib/node/terminal-service.spec.js.map +1 -0
- package/lib/node/terminal-util.d.ts +63 -0
- package/lib/node/terminal-util.d.ts.map +1 -0
- package/lib/node/terminal-util.js +158 -0
- package/lib/node/terminal-util.js.map +1 -0
- package/lib/node/terminal-util.spec.d.ts +2 -0
- package/lib/node/terminal-util.spec.d.ts.map +1 -0
- package/lib/node/terminal-util.spec.js +71 -0
- package/lib/node/terminal-util.spec.js.map +1 -0
- package/lib/node/web-extension-catalog.d.ts +39 -0
- package/lib/node/web-extension-catalog.d.ts.map +1 -0
- package/lib/node/web-extension-catalog.js +163 -0
- package/lib/node/web-extension-catalog.js.map +1 -0
- package/lib/node/web-extension-catalog.spec.d.ts +2 -0
- package/lib/node/web-extension-catalog.spec.d.ts.map +1 -0
- package/lib/node/web-extension-catalog.spec.js +157 -0
- package/lib/node/web-extension-catalog.spec.js.map +1 -0
- package/lib/node/web-extension-util.d.ts +22 -0
- package/lib/node/web-extension-util.d.ts.map +1 -0
- package/lib/node/web-extension-util.js +126 -0
- package/lib/node/web-extension-util.js.map +1 -0
- package/lib/node/working-directory.d.ts +14 -0
- package/lib/node/working-directory.d.ts.map +1 -0
- package/lib/node/working-directory.js +43 -0
- package/lib/node/working-directory.js.map +1 -0
- package/lib/node/workspace-files.d.ts +48 -0
- package/lib/node/workspace-files.d.ts.map +1 -0
- package/lib/node/workspace-files.js +268 -0
- package/lib/node/workspace-files.js.map +1 -0
- package/lib/node/workspace-files.spec.d.ts +2 -0
- package/lib/node/workspace-files.spec.d.ts.map +1 -0
- package/lib/node/workspace-files.spec.js +133 -0
- package/lib/node/workspace-files.spec.js.map +1 -0
- package/lib/node/workspace-protocol.d.ts +21 -0
- package/lib/node/workspace-protocol.d.ts.map +1 -0
- package/lib/node/workspace-protocol.js +6 -0
- package/lib/node/workspace-protocol.js.map +1 -0
- package/lib/node/workspace-server-impl.d.ts +28 -0
- package/lib/node/workspace-server-impl.d.ts.map +1 -0
- package/lib/node/workspace-server-impl.js +91 -0
- package/lib/node/workspace-server-impl.js.map +1 -0
- package/lib/node/workspace-service.d.ts +32 -0
- package/lib/node/workspace-service.d.ts.map +1 -0
- package/lib/node/workspace-service.js +212 -0
- package/lib/node/workspace-service.js.map +1 -0
- package/lib/node/workspace-service.spec.d.ts +2 -0
- package/lib/node/workspace-service.spec.d.ts.map +1 -0
- package/lib/node/workspace-service.spec.js +104 -0
- package/lib/node/workspace-service.spec.js.map +1 -0
- package/lib/node/workspace-util.d.ts +30 -0
- package/lib/node/workspace-util.d.ts.map +1 -0
- package/lib/node/workspace-util.js +107 -0
- package/lib/node/workspace-util.js.map +1 -0
- package/lib/node/workspace-util.spec.d.ts +2 -0
- package/lib/node/workspace-util.spec.d.ts.map +1 -0
- package/lib/node/workspace-util.spec.js +44 -0
- package/lib/node/workspace-util.spec.js.map +1 -0
- package/package.json +14 -9
- package/src/node/auth-server-impl.spec.ts +49 -0
- package/src/node/auth-server-impl.ts +252 -0
- package/src/node/client-tool-broker.spec.ts +53 -0
- package/src/node/client-tool-broker.ts +106 -0
- package/src/node/exec-environment-factory.ts +46 -0
- package/src/node/extension-data-notifier.spec.ts +34 -0
- package/src/node/extension-data-notifier.ts +124 -0
- package/src/node/extension-data.spec.ts +105 -0
- package/src/node/extension-data.ts +180 -0
- package/src/node/host-protocol.ts +31 -1
- package/src/node/index.ts +24 -1
- package/src/node/package-host-extension.ts +20 -0
- package/src/node/package-hosts.spec.ts +54 -0
- package/src/node/package-hosts.ts +174 -0
- package/src/node/package-server-impl.ts +87 -0
- package/src/node/package-switch.ts +80 -0
- package/src/node/relay-bridge.ts +94 -0
- package/src/node/session-info-util.spec.ts +23 -0
- package/src/node/session-info-util.ts +55 -0
- package/src/node/session-storage/file-session-storage.spec.ts +72 -0
- package/src/node/session-storage/file-session-storage.ts +145 -0
- package/src/node/session-storage/index.ts +3 -0
- package/src/node/session-storage/session-storage-protocol.ts +81 -0
- package/src/node/session-storage/stored-session.spec.ts +80 -0
- package/src/node/session-storage/stored-session.ts +149 -0
- package/src/node/settings-server-impl.ts +33 -0
- package/src/node/settings-store.spec.ts +155 -0
- package/src/node/settings-store.ts +308 -0
- package/src/node/ta-access.spec.ts +9 -0
- package/src/node/ta-access.ts +65 -7
- package/src/node/ta-errors.spec.ts +25 -0
- package/src/node/ta-errors.ts +21 -1
- package/src/node/ta-server-impl.ts +75 -12
- package/src/node/ta-session-factory.ts +21 -7
- package/src/node/ta-session.ts +43 -3
- package/src/node/terminal-protocol.ts +18 -0
- package/src/node/terminal-service.spec.ts +84 -0
- package/src/node/terminal-service.ts +259 -0
- package/src/node/terminal-util.spec.ts +78 -0
- package/src/node/terminal-util.ts +166 -0
- package/src/node/web-extension-catalog.spec.ts +172 -0
- package/src/node/web-extension-catalog.ts +172 -0
- package/src/node/web-extension-util.ts +144 -0
- package/src/node/working-directory.ts +38 -0
- package/src/node/workspace-files.spec.ts +145 -0
- package/src/node/workspace-files.ts +256 -0
- package/src/node/workspace-protocol.ts +22 -0
- package/src/node/workspace-server-impl.ts +90 -0
- package/src/node/workspace-service.spec.ts +113 -0
- package/src/node/workspace-service.ts +223 -0
- package/src/node/workspace-util.spec.ts +47 -0
- package/src/node/workspace-util.ts +103 -0
- package/esm/node/local-exec-environment-factory.d.ts +0 -4
- package/esm/node/local-exec-environment-factory.js +0 -18
- package/esm/node/local-exec-environment-factory.js.map +0 -1
- package/lib/node/local-exec-environment-factory.d.ts +0 -5
- package/lib/node/local-exec-environment-factory.d.ts.map +0 -1
- package/lib/node/local-exec-environment-factory.js +0 -21
- package/lib/node/local-exec-environment-factory.js.map +0 -1
- package/src/node/local-exec-environment-factory.ts +0 -9
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TaPackageServerImpl = void 0;
|
|
13
|
+
const core_1 = require("@celljs/core");
|
|
14
|
+
const rpc_1 = require("@celljs/rpc");
|
|
15
|
+
const node_1 = require("@celljs/rpc/lib/node");
|
|
16
|
+
const ta_exec_1 = require("@celljs/ta-exec");
|
|
17
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
18
|
+
const extension_data_1 = require("./extension-data");
|
|
19
|
+
const extension_data_notifier_1 = require("./extension-data-notifier");
|
|
20
|
+
const host_protocol_1 = require("./host-protocol");
|
|
21
|
+
const package_hosts_1 = require("./package-hosts");
|
|
22
|
+
const ta_errors_1 = require("./ta-errors");
|
|
23
|
+
/** The packages pi loads and the data they keep; `cwd` defaults to the server's directory. */
|
|
24
|
+
let TaPackageServerImpl = class TaPackageServerImpl {
|
|
25
|
+
listWebExtensions(cwd) {
|
|
26
|
+
return ta_errors_1.TaErrors.guard(async () => this.webExtensions.list(await this.cwd(cwd)));
|
|
27
|
+
}
|
|
28
|
+
readWebExtension(id, cwd) {
|
|
29
|
+
return ta_errors_1.TaErrors.guard(async () => this.webExtensions.read(await this.cwd(cwd), id));
|
|
30
|
+
}
|
|
31
|
+
removeWebExtension(id, cwd) {
|
|
32
|
+
return ta_errors_1.TaErrors.guard(async () => this.webExtensions.remove(await this.cwd(cwd), id));
|
|
33
|
+
}
|
|
34
|
+
setPackageEnabled(nameOrId, enabled, cwd) {
|
|
35
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
36
|
+
await this.webExtensions.setEnabled(await this.cwd(cwd), nameOrId, enabled);
|
|
37
|
+
await this.packageHosts.sync();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
listPackages(cwd) {
|
|
41
|
+
return ta_errors_1.TaErrors.guard(async () => this.webExtensions.packages(await this.cwd(cwd)));
|
|
42
|
+
}
|
|
43
|
+
installPackage(source, scope, cwd) {
|
|
44
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
45
|
+
if (scope !== 'user' && scope !== 'project') {
|
|
46
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${String(scope)} is not where packages are installed.`, 'Pass user or project.');
|
|
47
|
+
}
|
|
48
|
+
await this.webExtensions.install(await this.cwd(cwd), source, scope);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
removePackage(id, cwd) {
|
|
52
|
+
return ta_errors_1.TaErrors.guard(async () => this.webExtensions.removePackage(await this.cwd(cwd), id));
|
|
53
|
+
}
|
|
54
|
+
callPackageHost(name, method, params) {
|
|
55
|
+
return ta_errors_1.TaErrors.guard(() => this.packageHosts.call(name, method, params !== null && params !== void 0 ? params : []));
|
|
56
|
+
}
|
|
57
|
+
getExtensionData(name, key, cwd) {
|
|
58
|
+
return ta_errors_1.TaErrors.guard(() => {
|
|
59
|
+
const connection = node_1.RpcContext.connection();
|
|
60
|
+
if (connection) {
|
|
61
|
+
this.extensionDataNotifier.watch(connection, name, extension_data_1.ExtensionDataUtil.checkCwd(cwd));
|
|
62
|
+
}
|
|
63
|
+
return this.extensionData.get(name, key, cwd);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
setExtensionData(name, key, value, cwd) {
|
|
67
|
+
return ta_errors_1.TaErrors.guard(() => this.extensionData.set(name, key, value, cwd));
|
|
68
|
+
}
|
|
69
|
+
async cwd(cwd) {
|
|
70
|
+
return cwd || (await this.environments.defaultCwd());
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.TaPackageServerImpl = TaPackageServerImpl;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, core_1.Autowired)(ta_exec_1.ExecEnvironmentFactory),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], TaPackageServerImpl.prototype, "environments", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, core_1.Autowired)(host_protocol_1.WebExtensionCatalog),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], TaPackageServerImpl.prototype, "webExtensions", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, core_1.Autowired)(extension_data_1.ExtensionDataStore),
|
|
84
|
+
__metadata("design:type", Object)
|
|
85
|
+
], TaPackageServerImpl.prototype, "extensionData", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, core_1.Autowired)(extension_data_notifier_1.ExtensionDataNotifier),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], TaPackageServerImpl.prototype, "extensionDataNotifier", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, core_1.Autowired)(package_hosts_1.PackageHosts),
|
|
92
|
+
__metadata("design:type", Object)
|
|
93
|
+
], TaPackageServerImpl.prototype, "packageHosts", void 0);
|
|
94
|
+
exports.TaPackageServerImpl = TaPackageServerImpl = __decorate([
|
|
95
|
+
(0, rpc_1.Rpc)(ta_protocol_1.TaPackageServer)
|
|
96
|
+
], TaPackageServerImpl);
|
|
97
|
+
//# sourceMappingURL=package-server-impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-server-impl.js","sourceRoot":"","sources":["../../src/node/package-server-impl.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyC;AACzC,qCAAkC;AAClC,+CAAkD;AAClD,6CAAyD;AACzD,qDAAoJ;AACpJ,qDAAyE;AACzE,uEAAkE;AAClE,mDAAsD;AACtD,mDAA+C;AAC/C,2CAAuC;AAEvC,8FAA8F;AAEvF,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAgB5B,iBAAiB,CAAC,GAAY;QAC1B,OAAO,oBAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,gBAAgB,CAAC,EAAU,EAAE,GAAY;QACrC,OAAO,oBAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,kBAAkB,CAAC,EAAU,EAAE,GAAY;QACvC,OAAO,oBAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,iBAAiB,CAAC,QAAgB,EAAE,OAAgB,EAAE,GAAY;QAC9D,OAAO,oBAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;YAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CA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ai-coding-agent';
|
|
2
|
+
type SettingsManager = ReturnType<PiSdk['SettingsManager']['create']>;
|
|
3
|
+
type ResolvedPaths = Awaited<ReturnType<InstanceType<PiSdk['DefaultPackageManager']>['resolve']>>;
|
|
4
|
+
type ResolvedResource = ResolvedPaths['extensions'][number];
|
|
5
|
+
/** What pi loads, by the key of its settings. */
|
|
6
|
+
export declare const PI_RESOURCE_TYPES: readonly ['extensions', 'skills', 'prompts', 'themes'];
|
|
7
|
+
export type PiResourceType = (typeof PI_RESOURCE_TYPES)[number];
|
|
8
|
+
/** A resource pi resolved, with its kind. */
|
|
9
|
+
export interface PiResource {
|
|
10
|
+
type: PiResourceType;
|
|
11
|
+
resource: ResolvedResource;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A package on or off as `pi config` turns each of its resources on or off: `+path` or `-path` in the
|
|
15
|
+
* resource list of the settings for a resource of `extensions/`, in the filters of its entry of
|
|
16
|
+
* `packages` for one of a package. Ta's switch of a package is that of all its resources at once, so
|
|
17
|
+
* `ta config` and `ta` in the terminal see the same.
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace PackageSwitch {
|
|
20
|
+
/** The resources of the package in `root`. */
|
|
21
|
+
function resourcesOf(resolved: ResolvedPaths, root: string): PiResource[];
|
|
22
|
+
/** On while any of its resources loads. */
|
|
23
|
+
function isEnabled(resources: readonly PiResource[]): boolean;
|
|
24
|
+
function set(settings: SettingsManager, resources: readonly PiResource[], enabled: boolean, dirs: {
|
|
25
|
+
agentDir: string;
|
|
26
|
+
projectDir: string;
|
|
27
|
+
}): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=package-switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-switch.d.ts","sourceRoot":"","sources":["../../src/node/package-switch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,KAAK,eAAe,GAAG,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtE,KAAK,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAClG,KAAK,gBAAgB,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAG5D,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,YAAI,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AACxF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;GAKG;AACH,yBAAiB,aAAa,CAAC;IAC3B,8CAA8C;IAC9C,SAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAG/E;IAED,2CAA2C;IAC3C,SAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAEnE;IAED,SAAgB,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CA6BvJ;CAcJ"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageSwitch = exports.PI_RESOURCE_TYPES = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
/** What pi loads, by the key of its settings. */
|
|
6
|
+
exports.PI_RESOURCE_TYPES = ['extensions', 'skills', 'prompts', 'themes'];
|
|
7
|
+
/**
|
|
8
|
+
* A package on or off as `pi config` turns each of its resources on or off: `+path` or `-path` in the
|
|
9
|
+
* resource list of the settings for a resource of `extensions/`, in the filters of its entry of
|
|
10
|
+
* `packages` for one of a package. Ta's switch of a package is that of all its resources at once, so
|
|
11
|
+
* `ta config` and `ta` in the terminal see the same.
|
|
12
|
+
*/
|
|
13
|
+
var PackageSwitch;
|
|
14
|
+
(function (PackageSwitch) {
|
|
15
|
+
/** The resources of the package in `root`. */
|
|
16
|
+
function resourcesOf(resolved, root) {
|
|
17
|
+
const inside = (path) => path === root || path.startsWith(`${root}${node_path_1.sep}`);
|
|
18
|
+
return exports.PI_RESOURCE_TYPES.flatMap(type => resolved[type].filter(resource => inside(resource.path)).map(resource => ({ type, resource })));
|
|
19
|
+
}
|
|
20
|
+
PackageSwitch.resourcesOf = resourcesOf;
|
|
21
|
+
/** On while any of its resources loads. */
|
|
22
|
+
function isEnabled(resources) {
|
|
23
|
+
return resources.some(({ resource }) => resource.enabled);
|
|
24
|
+
}
|
|
25
|
+
PackageSwitch.isEnabled = isEnabled;
|
|
26
|
+
function set(settings, resources, enabled, dirs) {
|
|
27
|
+
var _a, _b, _c, _d, _e;
|
|
28
|
+
for (const { type, resource } of resources) {
|
|
29
|
+
const { metadata } = resource;
|
|
30
|
+
const project = metadata.scope === 'project';
|
|
31
|
+
if (metadata.origin === 'top-level') {
|
|
32
|
+
const base = (_a = metadata.baseDir) !== null && _a !== void 0 ? _a : (project ? dirs.projectDir : dirs.agentDir);
|
|
33
|
+
const file = project ? settings.getProjectSettings() : settings.getGlobalSettings();
|
|
34
|
+
const updated = mark((_b = file[type]) !== null && _b !== void 0 ? _b : [], (0, node_path_1.relative)(base, resource.path), enabled);
|
|
35
|
+
SETTERS[type](settings, project)(updated);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const file = project ? settings.getProjectSettings() : settings.getGlobalSettings();
|
|
39
|
+
const packages = [...((_c = file.packages) !== null && _c !== void 0 ? _c : [])];
|
|
40
|
+
const index = packages.findIndex(pkg => (typeof pkg === 'string' ? pkg : pkg.source) === metadata.source);
|
|
41
|
+
if (index < 0) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const entry = packages[index];
|
|
45
|
+
const pkg = typeof entry === 'string' ? { source: entry } : { ...entry };
|
|
46
|
+
const pattern = (0, node_path_1.relative)((_d = metadata.baseDir) !== null && _d !== void 0 ? _d : (0, node_path_1.dirname)(resource.path), resource.path);
|
|
47
|
+
const filters = mark((_e = pkg[type]) !== null && _e !== void 0 ? _e : [], pattern, enabled);
|
|
48
|
+
pkg[type] = filters.length > 0 ? filters : undefined;
|
|
49
|
+
packages[index] = exports.PI_RESOURCE_TYPES.some(key => pkg[key] !== undefined) ? pkg : pkg.source;
|
|
50
|
+
if (project) {
|
|
51
|
+
settings.setProjectPackages(packages);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
settings.setPackages(packages);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
PackageSwitch.set = set;
|
|
59
|
+
/** The list without the entries of `pattern`, and `+pattern` or `-pattern` at its end, as `pi config` writes it. */
|
|
60
|
+
function mark(list, pattern, enabled) {
|
|
61
|
+
const target = (entry) => (/^[!+-]/.test(entry) ? entry.slice(1) : entry);
|
|
62
|
+
return [...list.filter(entry => target(entry) !== pattern), `${enabled ? '+' : '-'}${pattern}`];
|
|
63
|
+
}
|
|
64
|
+
const SETTERS = {
|
|
65
|
+
extensions: (s, project) => paths => (project ? s.setProjectExtensionPaths(paths) : s.setExtensionPaths(paths)),
|
|
66
|
+
skills: (s, project) => paths => (project ? s.setProjectSkillPaths(paths) : s.setSkillPaths(paths)),
|
|
67
|
+
prompts: (s, project) => paths => (project ? s.setProjectPromptTemplatePaths(paths) : s.setPromptTemplatePaths(paths)),
|
|
68
|
+
themes: (s, project) => paths => (project ? s.setProjectThemePaths(paths) : s.setThemePaths(paths)),
|
|
69
|
+
};
|
|
70
|
+
})(PackageSwitch || (exports.PackageSwitch = PackageSwitch = {}));
|
|
71
|
+
//# sourceMappingURL=package-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-switch.js","sourceRoot":"","sources":["../../src/node/package-switch.ts"],"names":[],"mappings":";;;AAAA,yCAAmD;AAQnD,iDAAiD;AACpC,QAAA,iBAAiB,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AASxF;;;;;GAKG;AACH,IAAiB,aAAa,CAuD7B;AAvDD,WAAiB,aAAa;IAC1B,8CAA8C;IAC9C,SAAgB,WAAW,CAAC,QAAuB,EAAE,IAAY;QAC7D,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,eAAG,EAAE,CAAC,CAAC;QACnF,OAAO,QAAA,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7I,CAAC;IAHe,cAAA,WAAW,cAG1B,CAAA;IAED,2CAA2C;IAC3C,SAAgB,SAAS,CAAC,SAAgC;QACtD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAFe,cAAA,SAAS,YAExB,CAAA;IAED,SAAgB,GAAG,CAAC,QAAyB,EAAE,SAAgC,EAAE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C;KACtG,CAAC;AACN,CAAC,EAvDgB,aAAa,aAAb,aAAa,GAAb,aAAa,QAuD7B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
2
|
+
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
|
+
import { type TaRelayDevice, type TaRelayInfo, TaRelayServer } from '@celljs/ta-protocol';
|
|
4
|
+
import { RelayHost, RelayStore } from '@celljs/ta-relay/lib/node';
|
|
5
|
+
import { ServerAware } from '@celljs/web/lib/node';
|
|
6
|
+
import { type TaAccess } from './ta-access';
|
|
7
|
+
/** The id of {@link RelayBridge}, for TaRelayServerImpl. */
|
|
8
|
+
export declare const RELAY_BRIDGE: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* Paired devices reach this server through a relay (@celljs/ta-relay): with a device in relay.json, it
|
|
11
|
+
* keeps a connection out to the relay and gives each device a connection of its own to this server.
|
|
12
|
+
* Without one it does nothing.
|
|
13
|
+
*/
|
|
14
|
+
export declare class RelayBridge implements ServerAware, ApplicationLifecycle<Application> {
|
|
15
|
+
protected readonly access: TaAccess;
|
|
16
|
+
readonly store: RelayStore;
|
|
17
|
+
protected host?: RelayHost;
|
|
18
|
+
get online(): boolean;
|
|
19
|
+
/** relay.json changed here: no need to wait for the watch. */
|
|
20
|
+
refresh(): void;
|
|
21
|
+
setServer(server: Server): Promise<void>;
|
|
22
|
+
onStop(): Promise<void>;
|
|
23
|
+
protected start(server: Server): void;
|
|
24
|
+
}
|
|
25
|
+
/** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
|
|
26
|
+
export declare class TaRelayServerImpl implements TaRelayServer {
|
|
27
|
+
protected readonly bridge: RelayBridge;
|
|
28
|
+
getRelay(): Promise<TaRelayInfo>;
|
|
29
|
+
pair(relay: string, name: string): Promise<{
|
|
30
|
+
link: string;
|
|
31
|
+
device: TaRelayDevice;
|
|
32
|
+
}>;
|
|
33
|
+
unpair(deviceId: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IAAI,OAAO,CAAC,WAAW,CAAC,CAGrC;IAED,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAWlF;IAEK,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5C;CACJ"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TaRelayServerImpl = exports.RelayBridge = exports.RELAY_BRIDGE = void 0;
|
|
13
|
+
const node_fs_1 = require("node:fs");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const rpc_1 = require("@celljs/rpc");
|
|
16
|
+
const ta_brand_1 = require("@celljs/ta-harness/lib/node/ta-brand");
|
|
17
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
18
|
+
const node_1 = require("@celljs/ta-relay/lib/node");
|
|
19
|
+
const node_2 = require("@celljs/web/lib/node");
|
|
20
|
+
const ta_access_1 = require("./ta-access");
|
|
21
|
+
const ta_errors_1 = require("./ta-errors");
|
|
22
|
+
/** The id of {@link RelayBridge}, for TaRelayServerImpl. */
|
|
23
|
+
exports.RELAY_BRIDGE = Symbol('RelayBridge');
|
|
24
|
+
/** How often relay.json is looked at, for devices that `ta pair` adds or removes while the server runs. */
|
|
25
|
+
const WATCH_INTERVAL_MS = 2000;
|
|
26
|
+
/**
|
|
27
|
+
* Paired devices reach this server through a relay (@celljs/ta-relay): with a device in relay.json, it
|
|
28
|
+
* keeps a connection out to the relay and gives each device a connection of its own to this server.
|
|
29
|
+
* Without one it does nothing.
|
|
30
|
+
*/
|
|
31
|
+
let RelayBridge = class RelayBridge {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.store = new node_1.RelayStore(ta_brand_1.TaBrand.agentDir());
|
|
34
|
+
}
|
|
35
|
+
get online() {
|
|
36
|
+
var _a;
|
|
37
|
+
var _b;
|
|
38
|
+
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.online) !== null && _b !== void 0 ? _b : false;
|
|
39
|
+
}
|
|
40
|
+
/** relay.json changed here: no need to wait for the watch. */
|
|
41
|
+
refresh() {
|
|
42
|
+
var _a;
|
|
43
|
+
(_a = this.host) === null || _a === void 0 ? void 0 : _a.refresh();
|
|
44
|
+
}
|
|
45
|
+
async setServer(server) {
|
|
46
|
+
const start = () => this.start(server);
|
|
47
|
+
if (server.listening) {
|
|
48
|
+
start();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
server.once('listening', start);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async onStop() {
|
|
55
|
+
var _a;
|
|
56
|
+
(0, node_fs_1.unwatchFile)(this.store.file);
|
|
57
|
+
(_a = this.host) === null || _a === void 0 ? void 0 : _a.stop();
|
|
58
|
+
}
|
|
59
|
+
start(server) {
|
|
60
|
+
const { port } = server.address();
|
|
61
|
+
const localUrl = `ws://127.0.0.1:${port}${ta_protocol_1.TA_WEBSOCKET_PATH}?token=${encodeURIComponent(this.access.token)}`;
|
|
62
|
+
const host = new node_1.RelayHost({ store: this.store, localUrl });
|
|
63
|
+
this.host = host;
|
|
64
|
+
host.start();
|
|
65
|
+
(0, node_fs_1.watchFile)(this.store.file, { interval: WATCH_INTERVAL_MS }, () => host.refresh());
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.RelayBridge = RelayBridge;
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, core_1.Autowired)(ta_access_1.TA_ACCESS),
|
|
71
|
+
__metadata("design:type", Function)
|
|
72
|
+
], RelayBridge.prototype, "access", void 0);
|
|
73
|
+
exports.RelayBridge = RelayBridge = __decorate([
|
|
74
|
+
(0, core_1.Component)([exports.RELAY_BRIDGE, node_2.ServerAware, core_1.ApplicationLifecycle])
|
|
75
|
+
], RelayBridge);
|
|
76
|
+
const device = ({ id, name, createdAt }) => ({ id, name, createdAt });
|
|
77
|
+
/** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
|
|
78
|
+
let TaRelayServerImpl = class TaRelayServerImpl {
|
|
79
|
+
async getRelay() {
|
|
80
|
+
const { url, devices } = this.bridge.store.read();
|
|
81
|
+
return { relay: url, defaultRelay: node_1.RELAY_DEFAULT_URL, online: this.bridge.online, devices: devices.map(device) };
|
|
82
|
+
}
|
|
83
|
+
pair(relay, name) {
|
|
84
|
+
return ta_errors_1.TaErrors.guard(() => {
|
|
85
|
+
const url = typeof relay === 'string' ? relay.trim().replace(/\/+$/, '') : '';
|
|
86
|
+
if (!/^https?:\/\/[^/\s]+$/.test(url)) {
|
|
87
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${relay} is not the address of a relay.`, 'Pass https://<host> of a relay, such as the default one.');
|
|
88
|
+
}
|
|
89
|
+
const pairing = this.bridge.store.pair(url, (typeof name === 'string' && name.trim()) || 'device');
|
|
90
|
+
this.bridge.refresh();
|
|
91
|
+
const created = this.bridge.store.device(pairing.device);
|
|
92
|
+
return { link: node_1.RelayPairingUtil.link(pairing), device: device(created !== null && created !== void 0 ? created : { id: pairing.device, name, createdAt: Date.now(), key: '' }) };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async unpair(deviceId) {
|
|
96
|
+
this.bridge.store.remove(deviceId);
|
|
97
|
+
this.bridge.refresh();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.TaRelayServerImpl = TaRelayServerImpl;
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, core_1.Autowired)(exports.RELAY_BRIDGE),
|
|
103
|
+
__metadata("design:type", RelayBridge)
|
|
104
|
+
], TaRelayServerImpl.prototype, "bridge", void 0);
|
|
105
|
+
exports.TaRelayServerImpl = TaRelayServerImpl = __decorate([
|
|
106
|
+
(0, rpc_1.Rpc)(ta_protocol_1.TaRelayServer)
|
|
107
|
+
], TaRelayServerImpl);
|
|
108
|
+
//# sourceMappingURL=relay-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-bridge.js","sourceRoot":"","sources":["../../src/node/relay-bridge.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiD;AAGjD,uCAA4F;AAC5F,qCAAkC;AAClC,mEAA+D;AAC/D,qDAA6G;AAC7G,oDAAuG;AACvG,+CAAmD;AACnD,2CAAuD;AACvD,2CAAuC;AAEvC,4DAA4D;AAC/C,QAAA,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAElD,2GAA2G;AAC3G,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;;;GAIG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAAjB;QAIM,UAAK,GAAG,IAAI,iBAAU,CAAC,kBAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAkCxD,CAAC;IA/BG,IAAI,MAAM;;;QACN,aAAO,MAAA,IAAI,CAAC,IAAI,0CAAE,MAAM,mCAAI,KAAK,CAAC;IACtC,CAAC;IAED,8DAA8D;IAC9D,OAAO;;QACH,M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AAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACzD,OAAO,EAAE,IAAI,EAAE,uBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QAC7I,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAgB;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACJ,CAAA;;AAxBsB;IADlB,IAAA,gBAAS,EAAC,QAAA,YAAY,CAAC;8BACG,WAAW;iDAAC;4BAF9B,iBAAiB;IAD7B,IAAA,SAAG,EAAC,2BAAa,CAAC;GACN,iBAAiB,CA0B7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** What these functions read of pi's messages. */
|
|
2
|
+
interface MessageLike {
|
|
3
|
+
role: string;
|
|
4
|
+
content?: unknown;
|
|
5
|
+
timestamp?: number;
|
|
6
|
+
}
|
|
7
|
+
/** What a list of conversations shows of one: its first message, as pi's session list does, and when it last changed. */
|
|
8
|
+
export declare namespace SessionInfoUtil {
|
|
9
|
+
/** The first line of the first message of the user that has text, without its context, cut to a title's length. */
|
|
10
|
+
function firstMessage(messages: readonly MessageLike[]): string | undefined;
|
|
11
|
+
/** The time of the last message that has one, else `fallback`. */
|
|
12
|
+
function updatedAt(messages: readonly MessageLike[], fallback: number): number;
|
|
13
|
+
/** The text of the content of a message. */
|
|
14
|
+
function text(content: unknown): string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=session-info-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-info-util.d.ts","sourceRoot":"","sources":["../../src/node/session-info-util.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,UAAU,WAAW;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,yHAAyH;AACzH,yBAAiB,eAAe,CAAC;IAG7B,mHAAmH;IACnH,SAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,GAAG,SAAS,CAcjF;IAED,kEAAkE;IAClE,SAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQpF;IAED,4CAA4C;IAC5C,SAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAW7C;CACJ"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionInfoUtil = void 0;
|
|
4
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
5
|
+
/** What a list of conversations shows of one: its first message, as pi's session list does, and when it last changed. */
|
|
6
|
+
var SessionInfoUtil;
|
|
7
|
+
(function (SessionInfoUtil) {
|
|
8
|
+
const LENGTH = 120;
|
|
9
|
+
/** The first line of the first message of the user that has text, without its context, cut to a title's length. */
|
|
10
|
+
function firstMessage(messages) {
|
|
11
|
+
for (const message of messages) {
|
|
12
|
+
if (message.role !== 'user') {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const line = ta_protocol_1.TaMessageContext.strip(text(message.content))
|
|
16
|
+
.split('\n')
|
|
17
|
+
.map(part => part.trim())
|
|
18
|
+
.find(Boolean);
|
|
19
|
+
if (line) {
|
|
20
|
+
return line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
SessionInfoUtil.firstMessage = firstMessage;
|
|
26
|
+
/** The time of the last message that has one, else `fallback`. */
|
|
27
|
+
function updatedAt(messages, fallback) {
|
|
28
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
29
|
+
const { timestamp } = messages[i];
|
|
30
|
+
if (typeof timestamp === 'number') {
|
|
31
|
+
return timestamp;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return fallback;
|
|
35
|
+
}
|
|
36
|
+
SessionInfoUtil.updatedAt = updatedAt;
|
|
37
|
+
/** The text of the content of a message. */
|
|
38
|
+
function text(content) {
|
|
39
|
+
if (typeof content === 'string') {
|
|
40
|
+
return content;
|
|
41
|
+
}
|
|
42
|
+
if (!Array.isArray(content)) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
return content
|
|
46
|
+
.filter((part) => (part === null || part === void 0 ? void 0 : part.type) === 'text' && typeof part.text === 'string')
|
|
47
|
+
.map(part => part.text)
|
|
48
|
+
.join('\n');
|
|
49
|
+
}
|
|
50
|
+
SessionInfoUtil.text = text;
|
|
51
|
+
})(SessionInfoUtil || (exports.SessionInfoUtil = SessionInfoUtil = {}));
|
|
52
|
+
//# sourceMappingURL=session-info-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-info-util.js","sourceRoot":"","sources":["../../src/node/session-info-util.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AASvD,yHAAyH;AACzH,IAAiB,eAAe,CA4C/B;AA5CD,WAAiB,eAAe;IAC5B,MAAM,MAAM,GAAG,GAAG,CAAC;IAEnB,mHAAmH;IACnH,SAAgB,YAAY,CAAC,QAAgC;QACzD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,OAAO,CAAC,IAAI,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,CAAC,CAAC,IAAI,EAA0C,EAAE,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;aAChH,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;aACtB,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAXe,gBAAA,IAAI,OAWnB,CAAA;AACL,CAAC,EA5CgB,eAAe,aAAf,eAAe,GAAf,eAAe,QA4C/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-info-util.spec.d.ts","sourceRoot":"","sources":["../../src/node/session-info-util.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
|
+
const session_info_util_1 = require("./session-info-util");
|
|
5
|
+
(0, bun_test_1.describe)('SessionInfoUtil', () => {
|
|
6
|
+
(0, bun_test_1.it)('takes the first line with text of the first message of the user', () => {
|
|
7
|
+
(0, bun_test_1.expect)(session_info_util_1.SessionInfoUtil.firstMessage([
|
|
8
|
+
{ role: 'custom', content: 'not the user' },
|
|
9
|
+
{ role: 'user', content: [{ type: 'image' }] },
|
|
10
|
+
{ role: 'user', content: [{ type: 'image' }, { type: 'text', text: '\n Fix the login page \nand its tests' }] },
|
|
11
|
+
{ role: 'user', content: 'later' },
|
|
12
|
+
])).toBe('Fix the login page');
|
|
13
|
+
(0, bun_test_1.expect)(session_info_util_1.SessionInfoUtil.firstMessage([{ role: 'user', content: 'x'.repeat(200) }])).toHaveLength(120);
|
|
14
|
+
(0, bun_test_1.expect)(session_info_util_1.SessionInfoUtil.firstMessage([{ role: 'assistant', content: 'hi' }])).toBeUndefined();
|
|
15
|
+
(0, bun_test_1.expect)(session_info_util_1.SessionInfoUtil.firstMessage([{ role: 'user', content: '<context>\n[#web]\n</context>\n@dev hi' }])).toBe('@dev hi');
|
|
16
|
+
});
|
|
17
|
+
(0, bun_test_1.it)('dates a conversation by its last message, or when it was opened', () => {
|
|
18
|
+
(0, bun_test_1.expect)(session_info_util_1.SessionInfoUtil.updatedAt([{ role: 'user', timestamp: 5 }, { role: 'assistant', timestamp: 9 }, { role: 'custom' }], 7)).toBe(9);
|
|
19
|
+
(0, bun_test_1.expect)(session_info_util_1.SessionInfoUtil.updatedAt([], 7)).toBe(7);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=session-info-util.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-info-util.spec.js","sourceRoot":"","sources":["../../src/node/session-info-util.spec.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,2DAAsD;AAEtD,IAAA,mBAAQ,EAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,IAAA,aAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACvE,IAAA,iBAAM,EACF,mCAAe,CAAC,YAAY,CAAC;YACzB,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE;YAC3C,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE;YAC9C,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yCAAyC,EAAE,CAAC,EAAE;YACjH,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;SACrC,CAAC,CACL,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC7B,IAAA,iBAAM,EAAC,mCAAe,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACrG,IAAA,iBAAM,EAAC,mCAAe,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QAC7F,IAAA,iBAAM,EAAC,mCAAe,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChI,CAAC,CAAC,CAAC;IAEH,IAAA,aAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACvE,IAAA,iBAAM,EAAC,mCAAe,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxI,IAAA,iBAAM,EAAC,mCAAe,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type SessionLease, type StoredEntry, type TaSessionStorage } from './session-storage-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Sessions in a directory, which processes of this machine or of a shared file system can share:
|
|
4
|
+
* `<id>.jsonl` (pi's format) and `<id>.lease.json`. A lock directory makes each operation atomic; a
|
|
5
|
+
* cloud implementation does the same with conditional writes.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FileSessionStorage implements TaSessionStorage {
|
|
8
|
+
protected readonly dir: string;
|
|
9
|
+
constructor(dir: string);
|
|
10
|
+
acquire(sessionId: string, holder: string, ttlMs: number, options?: {
|
|
11
|
+
takeOver?: boolean;
|
|
12
|
+
}): Promise<SessionLease>;
|
|
13
|
+
renew(lease: SessionLease, ttlMs: number): Promise<SessionLease>;
|
|
14
|
+
release(lease: SessionLease): Promise<void>;
|
|
15
|
+
read(sessionId: string): Promise<StoredEntry[] | undefined>;
|
|
16
|
+
write(lease: SessionLease, entries: StoredEntry[], options?: {
|
|
17
|
+
replace?: boolean;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
protected check(lease: SessionLease): void;
|
|
20
|
+
protected lease(sessionId: string): SessionLease | undefined;
|
|
21
|
+
protected writeLease(lease: SessionLease): void;
|
|
22
|
+
protected replaceFile(file: string, text: string): void;
|
|
23
|
+
protected file(sessionId: string, extension: string): string;
|
|
24
|
+
/** Runs `action` holding `<id>.lock`, a directory: creating one is atomic on every file system. */
|
|
25
|
+
protected locked<T>(sessionId: string, action: () => T): Promise<T>;
|
|
26
|
+
protected isStale(lock: string): boolean;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=file-session-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-session-storage.d.ts","sourceRoot":"","sources":["../../../src/node/session-storage/file-session-storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqC,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAQ3I;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,gBAAgB;IAC3C,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IAA1C,YAA+B,GAAG,EAAE,MAAM,EAEzC;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,QAAQ,CAAC,EA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