@crowdedkingdoms/crowdy-dsh 0.2.0-dev.1 → 0.2.0-dev.2
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/THIRD_PARTY_NOTICES.md +226 -0
- package/dist/dsh-web/BUILD.json +3 -3
- package/dist/dsh-web/preview/vfs-image.tar.gz +0 -0
- package/lib/attachments/crowdy-attachment-store.js +200 -0
- package/lib/attachments/crowdy-attachment-store.js.map +1 -0
- package/lib/bridge/client.js +161 -0
- package/lib/bridge/client.js.map +1 -0
- package/lib/bridge/index.js +155 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/protocol.js +30 -0
- package/lib/bridge/protocol.js.map +1 -0
- package/lib/crowdy/client.js +247 -0
- package/lib/crowdy/client.js.map +1 -0
- package/lib/crowdy/config.js +95 -0
- package/lib/crowdy/config.js.map +1 -0
- package/lib/crowdy/github-layout.js +97 -0
- package/lib/crowdy/github-layout.js.map +1 -0
- package/lib/crowdy/paths.js +145 -0
- package/lib/crowdy/paths.js.map +1 -0
- package/lib/crowdy/project-store.js +223 -0
- package/lib/crowdy/project-store.js.map +1 -0
- package/lib/fs/crowdy-file-system.js +621 -0
- package/lib/fs/crowdy-file-system.js.map +1 -0
- package/lib/fs/scratch-store.js +61 -0
- package/lib/fs/scratch-store.js.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/persist/index.js +199 -0
- package/lib/persist/index.js.map +1 -0
- package/lib/scripts/probe.js +59 -0
- package/lib/scripts/probe.js.map +1 -0
- package/lib/sdk-index/catalog.js +237 -0
- package/lib/sdk-index/catalog.js.map +1 -0
- package/lib/sdk-index/index.js +10 -0
- package/lib/sdk-index/index.js.map +1 -0
- package/lib/sdk-index/parse-sdk.js +131 -0
- package/lib/sdk-index/parse-sdk.js.map +1 -0
- package/lib/sdk-index/plugin.js +90 -0
- package/lib/sdk-index/plugin.js.map +1 -0
- package/lib/sdk-index/snapshot.js +215 -0
- package/lib/sdk-index/snapshot.js.map +1 -0
- package/lib/search/glob-match.js +114 -0
- package/lib/search/glob-match.js.map +1 -0
- package/lib/search/search-tools.js +414 -0
- package/lib/search/search-tools.js.map +1 -0
- package/lib/tools/index.js +344 -0
- package/lib/tools/index.js.map +1 -0
- package/lib/types/attachments/crowdy-attachment-store.d.ts +45 -0
- package/lib/types/attachments/crowdy-attachment-store.d.ts.map +1 -0
- package/lib/types/attachments/crowdy-attachment-store.test.d.ts.map +1 -0
- package/lib/types/bridge/client.d.ts +57 -0
- package/lib/types/bridge/client.d.ts.map +1 -0
- package/lib/types/bridge/client.test.d.ts.map +1 -0
- package/lib/types/bridge/index.d.ts +66 -0
- package/lib/types/bridge/index.d.ts.map +1 -0
- package/lib/types/bridge/protocol.d.ts +242 -0
- package/lib/types/bridge/protocol.d.ts.map +1 -0
- package/lib/types/crowdy/client.d.ts +126 -0
- package/lib/types/crowdy/client.d.ts.map +1 -0
- package/lib/types/crowdy/client.test.d.ts.map +1 -0
- package/lib/types/crowdy/config.d.ts +60 -0
- package/lib/types/crowdy/config.d.ts.map +1 -0
- package/lib/types/crowdy/github-layout.d.ts +36 -0
- package/lib/types/crowdy/github-layout.d.ts.map +1 -0
- package/lib/types/crowdy/paths.d.ts +89 -0
- package/lib/types/crowdy/paths.d.ts.map +1 -0
- package/lib/types/crowdy/project-store.d.ts +84 -0
- package/lib/types/crowdy/project-store.d.ts.map +1 -0
- package/lib/types/crowdy/project-store.test.d.ts.map +1 -0
- package/lib/types/fs/crowdy-file-system.d.ts +173 -0
- package/lib/types/fs/crowdy-file-system.d.ts.map +1 -0
- package/lib/types/fs/crowdy-file-system.test.d.ts.map +1 -0
- package/lib/types/fs/scratch-store.d.ts +31 -0
- package/lib/types/fs/scratch-store.d.ts.map +1 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/persist/index.d.ts +85 -0
- package/lib/types/persist/index.d.ts.map +1 -0
- package/lib/types/scripts/probe.d.ts +9 -0
- package/lib/types/scripts/probe.d.ts.map +1 -0
- package/lib/types/sdk-index/catalog.d.ts +39 -0
- package/lib/types/sdk-index/catalog.d.ts.map +1 -0
- package/lib/types/sdk-index/catalog.test.d.ts.map +1 -0
- package/lib/types/sdk-index/index.d.ts +13 -0
- package/lib/types/sdk-index/index.d.ts.map +1 -0
- package/lib/types/sdk-index/parse-sdk.d.ts +25 -0
- package/lib/types/sdk-index/parse-sdk.d.ts.map +1 -0
- package/lib/types/sdk-index/plugin.d.ts +26 -0
- package/lib/types/sdk-index/plugin.d.ts.map +1 -0
- package/lib/types/sdk-index/snapshot.d.ts +11 -0
- package/lib/types/sdk-index/snapshot.d.ts.map +1 -0
- package/lib/types/search/glob-match.d.ts +31 -0
- package/lib/types/search/glob-match.d.ts.map +1 -0
- package/lib/types/search/glob-match.test.d.ts.map +1 -0
- package/lib/types/search/search-tools.d.ts +81 -0
- package/lib/types/search/search-tools.d.ts.map +1 -0
- package/lib/types/search/search-tools.test.d.ts.map +1 -0
- package/lib/types/tools/index.d.ts +27 -0
- package/lib/types/tools/index.d.ts.map +1 -0
- package/lib/types/vendor/crowdyjs-sdk.d.ts +17 -0
- package/lib/types/vendor/crowdyjs-sdk.d.ts.map +1 -0
- package/lib/vendor/crowdyjs-sdk.js +18338 -0
- package/lib/vendor/crowdyjs-sdk.js.map +1 -0
- package/lib/vendor/crowdyjs-sdk.version.json +5 -0
- package/package.json +151 -38
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<!-- Generated by scripts/gen-third-party-notices.ts — do not edit by hand.
|
|
2
|
+
Run `pnpm run gen-third-party-notices` to regenerate. -->
|
|
3
|
+
|
|
4
|
+
# Third-Party Notices
|
|
5
|
+
|
|
6
|
+
DeepSeek Harness is licensed under [MIT](LICENSE). It depends on the third-party software listed below. Each project remains under its own license; nothing in this file changes those terms.
|
|
7
|
+
|
|
8
|
+
This file lists **direct** dependencies declared by the workspace and the explicitly disclosed official Claude Code platform payload closure. It is generated from the workspace manifests by `scripts/gen-third-party-notices.ts`: a pre-commit hook regenerates it whenever a staged file changes one of its inputs, and `scripts/gen-third-party-notices.spec.ts` asserts in the test lane that the committed bytes match. Deleting a manifest runs no hook, so that case is caught by the assertion instead. Run `pnpm run verify-third-party-notices` for the standalone check.
|
|
9
|
+
|
|
10
|
+
The complete npm transitive closure, including the Landlock launcher workspace, is recorded with exact pinned versions in [`pnpm-lock.yaml`](pnpm-lock.yaml) — inspect it with `pnpm licenses list`. The Python closure is recorded separately in [`python/sdk/uv.lock`](python/sdk/uv.lock).
|
|
11
|
+
|
|
12
|
+
## Vendored source (`vendor/`)
|
|
13
|
+
|
|
14
|
+
The Cordis framework and its foundation libraries are source-vendored into this repository rather than consumed from npm, and republished under the `@deepseek-ai` scope. All are MIT-licensed; each directory preserves its upstream `LICENSE` file. Exact upstream commits and local modifications are recorded in [`vendor/README.md`](vendor/README.md).
|
|
15
|
+
|
|
16
|
+
| Package | Upstream name | Upstream | License |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `@deepseek-ai/cosmokit` | `cosmokit` | [github.com/deepseek-harness/cosmokit](https://github.com/deepseek-harness/cosmokit) | MIT |
|
|
19
|
+
| `@deepseek-ai/schemastery` | `schemastery` | [github.com/deepseek-harness/schemastery](https://github.com/deepseek-harness/schemastery) | MIT |
|
|
20
|
+
| `@deepseek-ai/cordis` | `cordis` | [github.com/cordiverse/cordis](https://github.com/cordiverse/cordis) | MIT |
|
|
21
|
+
| `@deepseek-ai/cordis-plugin-loader` | `@cordisjs/plugin-loader` | [github.com/cordiverse/cordis](https://github.com/cordiverse/cordis) | MIT |
|
|
22
|
+
| `@deepseek-ai/cordis-plugin-include` | `@cordisjs/plugin-include` | [github.com/deepseek-harness/cordis](https://github.com/deepseek-harness/cordis) | MIT |
|
|
23
|
+
| `@deepseek-ai/cordis-plugin-group` | `@cordisjs/plugin-group` | [github.com/deepseek-harness/cordis](https://github.com/deepseek-harness/cordis) | MIT |
|
|
24
|
+
| `@deepseek-ai/cordis-plugin-timer` | `@cordisjs/plugin-timer` | [github.com/deepseek-harness/cordis](https://github.com/deepseek-harness/cordis) | MIT |
|
|
25
|
+
| `@deepseek-ai/cordis-plugin-hmr` | `@cordisjs/plugin-hmr` | [github.com/deepseek-harness/cordis](https://github.com/deepseek-harness/cordis) | MIT |
|
|
26
|
+
| `@deepseek-ai/cordis-plugin-logger-console` | `@cordisjs/plugin-logger-console` | [github.com/deepseek-harness/cordis](https://github.com/deepseek-harness/cordis) | MIT |
|
|
27
|
+
|
|
28
|
+
## Runtime npm dependencies
|
|
29
|
+
|
|
30
|
+
External packages installed for runtime use or distributed inside the prebuilt browser artifacts. Browser inputs are resolved through the shipping tsdown and Vite configurations, independently of npm dependency sections. The tier covers every plugin a user can mount from `cordis.yml` — not only what the `dsh` CLI, Web UI, and Python SDK runtime load by default.
|
|
31
|
+
|
|
32
|
+
| Package | License |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| [`@agentclientprotocol/sdk`](https://github.com/agentclientprotocol/typescript-sdk) | Apache-2.0 |
|
|
35
|
+
| [`@anthropic-ai/claude-agent-sdk`](https://github.com/anthropics/claude-agent-sdk-typescript) | SEE LICENSE IN README.md |
|
|
36
|
+
| [`@anthropic-ai/sdk`](https://github.com/anthropics/anthropic-sdk-typescript) | MIT |
|
|
37
|
+
| [`@babel/code-frame`](https://github.com/babel/babel) | MIT |
|
|
38
|
+
| [`@earendil-works/pi-ai`](https://github.com/earendil-works/pi) | MIT |
|
|
39
|
+
| [`@joplin/turndown-plugin-gfm`](https://github.com/laurent22/joplin-turndown-plugin-gfm) | MIT |
|
|
40
|
+
| [`@jridgewell/gen-mapping`](https://github.com/jridgewell/sourcemaps) | MIT |
|
|
41
|
+
| [`@lexical/history`](https://github.com/facebook/lexical) | MIT |
|
|
42
|
+
| [`@lexical/plain-text`](https://github.com/facebook/lexical) | MIT |
|
|
43
|
+
| [`@lexical/text`](https://github.com/facebook/lexical) | MIT |
|
|
44
|
+
| [`@lexical/utils`](https://github.com/facebook/lexical) | MIT |
|
|
45
|
+
| [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk) | MIT |
|
|
46
|
+
| [`@noble/hashes`](https://github.com/paulmillr/noble-hashes) | MIT |
|
|
47
|
+
| [`@octokit/webhooks`](https://github.com/octokit/webhooks.js) | MIT |
|
|
48
|
+
| [`@openai/codex`](https://github.com/openai/codex) | Apache-2.0 |
|
|
49
|
+
| [`@opentelemetry/api`](https://github.com/open-telemetry/opentelemetry-js) | Apache-2.0 |
|
|
50
|
+
| [`@opentelemetry/api-logs`](https://github.com/open-telemetry/opentelemetry-js) | Apache-2.0 |
|
|
51
|
+
| [`@opentelemetry/exporter-logs-otlp-http`](https://github.com/open-telemetry/opentelemetry-js) | Apache-2.0 |
|
|
52
|
+
| [`@opentelemetry/otlp-exporter-base`](https://github.com/open-telemetry/opentelemetry-js) | Apache-2.0 |
|
|
53
|
+
| [`@opentelemetry/resources`](https://github.com/open-telemetry/opentelemetry-js) | Apache-2.0 |
|
|
54
|
+
| [`@opentelemetry/sdk-logs`](https://github.com/open-telemetry/opentelemetry-js) | Apache-2.0 |
|
|
55
|
+
| [`@shikijs/langs`](https://github.com/shikijs/shiki) | MIT |
|
|
56
|
+
| [`@standard-schema/spec`](https://github.com/standard-schema/standard-schema) | MIT |
|
|
57
|
+
| [`@tanstack/react-virtual`](https://github.com/TanStack/virtual) | MIT |
|
|
58
|
+
| [`@vscode/ripgrep`](https://github.com/microsoft/vscode-ripgrep) | MIT |
|
|
59
|
+
| [`@xterm/headless`](https://github.com/xtermjs/xterm.js) | MIT |
|
|
60
|
+
| [`@yarnpkg/parsers`](https://github.com/yarnpkg/berry) | BSD-2-Clause |
|
|
61
|
+
| [`acorn`](https://github.com/acornjs/acorn) | MIT |
|
|
62
|
+
| [`anser`](https://github.com/IonicaBizau/anser) | MIT |
|
|
63
|
+
| [`buffer`](https://github.com/feross/buffer) | MIT |
|
|
64
|
+
| [`chokidar`](https://github.com/paulmillr/chokidar) | MIT |
|
|
65
|
+
| [`clsx`](https://github.com/lukeed/clsx) | MIT |
|
|
66
|
+
| [`commander`](https://github.com/tj/commander.js) | MIT |
|
|
67
|
+
| [`compression`](https://github.com/expressjs/compression) | MIT |
|
|
68
|
+
| [`diff`](https://github.com/kpdecker/jsdiff) | BSD-3-Clause |
|
|
69
|
+
| [`e2b`](https://github.com/e2b-dev/e2b) | MIT |
|
|
70
|
+
| [`electron-updater`](https://github.com/electron-userland/electron-builder) | MIT |
|
|
71
|
+
| [`eventsource-parser`](https://github.com/rexxars/eventsource-parser) | MIT |
|
|
72
|
+
| [`fflate`](https://github.com/101arrowz/fflate) | MIT |
|
|
73
|
+
| [`immer`](https://github.com/immerjs/immer) | MIT |
|
|
74
|
+
| [`ipaddr.js`](https://github.com/whitequark/ipaddr.js) | MIT |
|
|
75
|
+
| [`js-yaml`](https://github.com/nodeca/js-yaml) | MIT |
|
|
76
|
+
| [`katex`](https://github.com/KaTeX/KaTeX) | MIT |
|
|
77
|
+
| [`koffi`](https://github.com/Koromix/koffi) | MIT |
|
|
78
|
+
| [`lexical`](https://github.com/facebook/lexical) | MIT |
|
|
79
|
+
| [`mdast-util-from-markdown`](https://github.com/syntax-tree/mdast-util-from-markdown) | MIT |
|
|
80
|
+
| [`mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm) | MIT |
|
|
81
|
+
| [`mdast-util-math`](https://github.com/syntax-tree/mdast-util-math) | MIT |
|
|
82
|
+
| [`micromark-core-commonmark`](https://github.com/micromark/micromark/tree/main/packages/micromark-core-commonmark) | MIT |
|
|
83
|
+
| [`micromark-extension-gfm`](https://github.com/micromark/micromark-extension-gfm) | MIT |
|
|
84
|
+
| [`micromark-extension-math`](https://github.com/micromark/micromark-extension-math) | MIT |
|
|
85
|
+
| [`micromark-factory-space`](https://github.com/micromark/micromark/tree/main/packages/micromark-factory-space) | MIT |
|
|
86
|
+
| [`micromark-util-character`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-character) | MIT |
|
|
87
|
+
| [`micromark-util-classify-character`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-classify-character) | MIT |
|
|
88
|
+
| [`micromark-util-sanitize-uri`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-sanitize-uri) | MIT |
|
|
89
|
+
| [`micromark-util-symbol`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-symbol) | MIT |
|
|
90
|
+
| [`mime-types`](https://github.com/jshttp/mime-types) | MIT |
|
|
91
|
+
| [`negotiator`](https://github.com/jshttp/negotiator) | MIT |
|
|
92
|
+
| [`node-addon-require-builtin`](https://www.npmjs.com/package/node-addon-require-builtin) | MIT |
|
|
93
|
+
| [`node-pty`](https://github.com/microsoft/node-pty) | MIT |
|
|
94
|
+
| [`open`](https://github.com/sindresorhus/open) | MIT |
|
|
95
|
+
| [`pdfjs-dist`](https://github.com/mozilla/pdf.js) | Apache-2.0 |
|
|
96
|
+
| [`picomatch`](https://github.com/micromatch/picomatch) | MIT |
|
|
97
|
+
| [`react`](https://github.com/facebook/react) | MIT |
|
|
98
|
+
| [`react-dom`](https://github.com/facebook/react) | MIT |
|
|
99
|
+
| [`readable-stream`](https://github.com/nodejs/readable-stream) | MIT |
|
|
100
|
+
| [`resolve.exports`](https://github.com/lukeed/resolve.exports) | MIT |
|
|
101
|
+
| [`semver`](https://github.com/npm/node-semver) | ISC |
|
|
102
|
+
| [`sharp`](https://github.com/lovell/sharp) | Apache-2.0 |
|
|
103
|
+
| [`shiki`](https://github.com/shikijs/shiki) | MIT |
|
|
104
|
+
| [`supports-color`](https://github.com/chalk/supports-color) | MIT |
|
|
105
|
+
| [`tsx`](https://github.com/privatenumber/tsx) | MIT |
|
|
106
|
+
| [`turndown`](https://github.com/mixmark-io/turndown) | MIT |
|
|
107
|
+
| [`typescript`](https://github.com/microsoft/TypeScript) | Apache-2.0 |
|
|
108
|
+
| [`undici`](https://github.com/nodejs/undici) | MIT |
|
|
109
|
+
| [`use-sync-external-store`](https://github.com/facebook/react) | MIT |
|
|
110
|
+
| [`ws`](https://github.com/websockets/ws) | MIT |
|
|
111
|
+
| [`yaml`](https://github.com/eemeli/yaml) | ISC |
|
|
112
|
+
| [`zod`](https://github.com/colinhacks/zod) | MIT |
|
|
113
|
+
| [`zustand`](https://github.com/pmndrs/zustand) | MIT |
|
|
114
|
+
|
|
115
|
+
pnpm applies local patches to the following packages at install time, so shipped artifacts carry modified copies; each patch file is the complete record of the modification:
|
|
116
|
+
|
|
117
|
+
- `@yao-pkg/pkg@6.21.0` — [`patches/@yao-pkg__pkg@6.21.0.patch`](patches/@yao-pkg__pkg@6.21.0.patch)
|
|
118
|
+
- `node-pty@1.2.0-beta.15` — [`patches/node-pty@1.2.0-beta.15.patch`](patches/node-pty@1.2.0-beta.15.patch)
|
|
119
|
+
|
|
120
|
+
## Official Claude Code platform payloads
|
|
121
|
+
|
|
122
|
+
The project owner authorizes distribution of every version of the official `@anthropic-ai/claude-agent-sdk` package and the official Claude Code CLI/platform payloads that each version declares through `optionalDependencies`. This identity-scoped authorization does not classify their declared terms as permissive and does not cover any unrelated runtime package; version, declared-license, and payload-set changes still require the ordinary dependency, lockfile, compatibility, terms, and notices review.
|
|
123
|
+
|
|
124
|
+
The installed SDK 0.3.263 declares the following optional platform packages. Each carries the official Claude Code 2.1.263 executable; the package identities and versions come from the SDK manifest, while the declared license field is verified against the platform payload installed for the current host.
|
|
125
|
+
|
|
126
|
+
| Optional platform package | Version | Declared license |
|
|
127
|
+
| --- | --- | --- |
|
|
128
|
+
| [`@anthropic-ai/claude-agent-sdk-darwin-arm64`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-darwin-arm64) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
129
|
+
| [`@anthropic-ai/claude-agent-sdk-darwin-x64`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-darwin-x64) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
130
|
+
| [`@anthropic-ai/claude-agent-sdk-linux-arm64`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-linux-arm64) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
131
|
+
| [`@anthropic-ai/claude-agent-sdk-linux-arm64-musl`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-linux-arm64-musl) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
132
|
+
| [`@anthropic-ai/claude-agent-sdk-linux-x64`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-linux-x64) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
133
|
+
| [`@anthropic-ai/claude-agent-sdk-linux-x64-musl`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-linux-x64-musl) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
134
|
+
| [`@anthropic-ai/claude-agent-sdk-win32-arm64`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-win32-arm64) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
135
|
+
| [`@anthropic-ai/claude-agent-sdk-win32-x64`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk-win32-x64) | 0.3.263 | SEE LICENSE IN LICENSE.md |
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## Development-only npm dependencies
|
|
139
|
+
|
|
140
|
+
External packages **directly declared** for development, tests, types, or tooling, without a runtime installation or browser-build relationship. A package here may still be pulled in transitively by a runtime dependency — `pnpm-lock.yaml` is the authority on that full closure.
|
|
141
|
+
|
|
142
|
+
| Package | License |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| [`@aws-sdk/client-s3`](https://github.com/aws/aws-sdk-js-v3) | Apache-2.0 |
|
|
145
|
+
| [`@braintree/sanitize-url`](https://github.com/braintree/sanitize-url) | MIT |
|
|
146
|
+
| [`@electron/notarize`](https://github.com/electron/notarize) | MIT |
|
|
147
|
+
| [`@lexical/headless`](https://github.com/facebook/lexical) | MIT |
|
|
148
|
+
| [`@modelcontextprotocol/server-everything`](https://github.com/modelcontextprotocol/servers) | MIT / Apache-2.0 |
|
|
149
|
+
| [`@modelcontextprotocol/server-filesystem`](https://github.com/modelcontextprotocol/servers) | MIT / Apache-2.0 |
|
|
150
|
+
| [`@stylistic/eslint-plugin`](https://github.com/eslint-stylistic/eslint-stylistic) | MIT |
|
|
151
|
+
| [`@testing-library/dom`](https://github.com/testing-library/dom-testing-library) | MIT |
|
|
152
|
+
| [`@testing-library/react`](https://github.com/testing-library/react-testing-library) | MIT |
|
|
153
|
+
| [`@types/babel__code-frame`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
154
|
+
| [`@types/compression`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
155
|
+
| [`@types/js-yaml`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
156
|
+
| [`@types/jsdom`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
157
|
+
| [`@types/mdast`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
158
|
+
| [`@types/mime-types`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
159
|
+
| [`@types/negotiator`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
160
|
+
| [`@types/node`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
161
|
+
| [`@types/picomatch`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
162
|
+
| [`@types/react`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
163
|
+
| [`@types/react-dom`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
164
|
+
| [`@types/readable-stream`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
165
|
+
| [`@types/semver`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
166
|
+
| [`@types/spdx-expression-parse`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
167
|
+
| [`@types/turndown`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
168
|
+
| [`@types/use-sync-external-store`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
169
|
+
| [`@types/ws`](https://github.com/DefinitelyTyped/DefinitelyTyped) | MIT |
|
|
170
|
+
| [`@vitejs/plugin-react`](https://github.com/vitejs/vite-plugin-react) | MIT |
|
|
171
|
+
| [`@vitest/coverage-v8`](https://github.com/vitest-dev/vitest) | MIT |
|
|
172
|
+
| [`@yao-pkg/pkg`](https://github.com/yao-pkg/pkg) | MIT |
|
|
173
|
+
| [`@yarnpkg/cli-dist`](https://github.com/yarnpkg/berry) | BSD-2-Clause |
|
|
174
|
+
| [`app-builder-lib`](https://github.com/electron-userland/electron-builder) | MIT |
|
|
175
|
+
| [`cytoscape`](https://github.com/cytoscape/cytoscape.js) | MIT |
|
|
176
|
+
| [`cytoscape-cose-bilkent`](https://github.com/cytoscape/cytoscape.js-cose-bilkent) | MIT |
|
|
177
|
+
| [`dayjs`](https://github.com/iamkun/dayjs) | MIT |
|
|
178
|
+
| [`debug`](https://github.com/debug-js/debug) | MIT |
|
|
179
|
+
| [`electron`](https://github.com/electron/electron) | MIT |
|
|
180
|
+
| [`electron-builder`](https://github.com/electron-userland/electron-builder) | MIT |
|
|
181
|
+
| [`esbuild`](https://github.com/evanw/esbuild) | MIT |
|
|
182
|
+
| [`eslint-plugin-sonarjs`](https://github.com/SonarSource/SonarJS) | LGPL-3.0-only |
|
|
183
|
+
| [`execa`](https://github.com/sindresorhus/execa) | MIT |
|
|
184
|
+
| [`extract-zip`](https://github.com/maxogden/extract-zip) | BSD-2-Clause |
|
|
185
|
+
| [`fast-check`](https://github.com/dubzzz/fast-check) | MIT |
|
|
186
|
+
| [`http-server`](https://github.com/http-party/http-server) | MIT |
|
|
187
|
+
| [`istanbul-lib-report`](https://github.com/istanbuljs/istanbuljs) | BSD-3-Clause |
|
|
188
|
+
| [`jscpd`](https://github.com/kucherenko/jscpd) | MIT |
|
|
189
|
+
| [`jsdom`](https://github.com/jsdom/jsdom) | MIT |
|
|
190
|
+
| [`lefthook`](https://github.com/evilmartians/lefthook) | MIT |
|
|
191
|
+
| [`lightningcss`](https://github.com/parcel-bundler/lightningcss) | MPL-2.0 |
|
|
192
|
+
| [`mermaid`](https://github.com/mermaid-js/mermaid) | MIT |
|
|
193
|
+
| [`micromark-util-types`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-types) | MIT |
|
|
194
|
+
| [`msgpackr`](http://github.com/kriszyp/msgpackr) | MIT |
|
|
195
|
+
| [`oxlint`](https://github.com/oxc-project/oxc) | MIT |
|
|
196
|
+
| [`oxlint-tsgolint`](https://github.com/oxc-project/tsgolint) | MIT |
|
|
197
|
+
| [`playwright`](https://github.com/microsoft/playwright) | Apache-2.0 |
|
|
198
|
+
| [`pnpm`](https://github.com/pnpm/pnpm) | MIT |
|
|
199
|
+
| [`publint`](https://github.com/publint/publint) | MIT |
|
|
200
|
+
| [`smol-toml`](https://github.com/squirrelchat/smol-toml) | BSD-3-Clause |
|
|
201
|
+
| [`spdx-expression-parse`](https://github.com/jslicense/spdx-expression-parse.js) | MIT |
|
|
202
|
+
| [`tar`](https://github.com/isaacs/node-tar) | BlueOak-1.0.0 |
|
|
203
|
+
| [`tsdown`](https://github.com/rolldown/tsdown) | MIT |
|
|
204
|
+
| [`typescript-language-server`](https://github.com/typescript-language-server/typescript-language-server) | Apache-2.0 |
|
|
205
|
+
| [`vite`](https://github.com/vitejs/vite) | MIT |
|
|
206
|
+
| [`vite-tsconfig-paths`](https://github.com/aleclarson/vite-tsconfig-paths) | MIT |
|
|
207
|
+
| [`vitepress`](https://github.com/vuejs/vitepress) | MIT |
|
|
208
|
+
| [`vitepress-plugin-mermaid`](https://github.com/emersonbottero/vitepress-plugin-mermaid) | MIT |
|
|
209
|
+
| [`vitest`](https://github.com/vitest-dev/vitest) | MIT |
|
|
210
|
+
|
|
211
|
+
`eslint-plugin-sonarjs` (LGPL-3.0-only) and `lightningcss` (MPL-2.0) run only as development tooling; their code is not linked into or distributed with any DeepSeek Harness artifact.
|
|
212
|
+
|
|
213
|
+
## Python SDK dependencies (`python/`)
|
|
214
|
+
|
|
215
|
+
Direct dependencies of the `pyproject.toml` manifests, plus `uv` as the development workflow tool.
|
|
216
|
+
|
|
217
|
+
| Package | License | Role |
|
|
218
|
+
| --- | --- | --- |
|
|
219
|
+
| [`hatchling`](https://github.com/pypa/hatch) | MIT | build backend |
|
|
220
|
+
| [`pydantic`](https://github.com/pydantic/pydantic) | MIT | runtime dependency of `deepseek-harness-sdk` |
|
|
221
|
+
| [`pytest`](https://github.com/pytest-dev/pytest) | MIT | test-only |
|
|
222
|
+
| [`uv`](https://github.com/astral-sh/uv) | MIT / Apache-2.0 | development workflow tool |
|
|
223
|
+
|
|
224
|
+
## First-party native packages
|
|
225
|
+
|
|
226
|
+
`@deepseek-ai/node-addon-system` (and its platform packages) is built and released from this repository under BSD 3-Clause. It is listed here for completeness; it is first-party, not third-party.
|
package/dist/dsh-web/BUILD.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@crowdedkingdoms/crowdy-dsh",
|
|
3
3
|
"version": "0.2.0",
|
|
4
|
-
"builtAt": "2026-09-
|
|
4
|
+
"builtAt": "2026-09-12T13:23:51.176Z",
|
|
5
5
|
"source": {
|
|
6
6
|
"repository": "CrowdedKingdoms/crowdy-dsh",
|
|
7
|
-
"commit": "
|
|
7
|
+
"commit": "23fefb0c400681249d0cd5d8189eac7ff5594cef",
|
|
8
8
|
"dirty": false
|
|
9
9
|
},
|
|
10
10
|
"upstream": {
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"manifest.webmanifest": "sha256:9b54d57eea00f2fdd1affe6e7999a4209a515755f12ac1a3299da2d55e178d4c",
|
|
113
113
|
"preview/bootstrap-CYECZNXt.js": "sha256:9f303a0485c0badfdd19fad0c357ef050c5b9a343744ab5bf0c70015e7d95092",
|
|
114
114
|
"preview/crowdy-boot-D0e56jZN.js": "sha256:b08fc35fb3a549662388c88fa99dd0dbbc7e553e6d6cccac74c50a6967af88ef",
|
|
115
|
-
"preview/vfs-image.tar.gz": "sha256:
|
|
115
|
+
"preview/vfs-image.tar.gz": "sha256:bc394dccb9c0a0ab0ea47fe1566fd3692fd025cf5874ed5def3efad5b985a7e9",
|
|
116
116
|
"preview/worker-C8-_ANaz.js": "sha256:81099e5732dfe0c32bacd5897316b7956c5a0a22da01b4a0c6e21d0a3b9d9aa1"
|
|
117
117
|
}
|
|
118
118
|
}
|
|
Binary file
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory `ctx.attachments` provider for the browser worker.
|
|
3
|
+
*
|
|
4
|
+
* The stock `@deepseek-ai/dsh-attachment-local` decodes and normalizes images
|
|
5
|
+
* with `sharp`, a native module the browser worker replaces with a stub that
|
|
6
|
+
* refuses every call — so in the worker neither `read_image` nor a pasted
|
|
7
|
+
* screenshot could ever produce an image block. This store keeps the bytes it
|
|
8
|
+
* is handed, reads intrinsic dimensions from the container header (PNG, JPEG,
|
|
9
|
+
* WebP, GIF), and serves model requests verbatim. The Studio page already
|
|
10
|
+
* downscales captures before sharing them, and the byte caps here bound what a
|
|
11
|
+
* pasted image can cost.
|
|
12
|
+
*
|
|
13
|
+
* Attachments live for the life of the harness only: reloading the page drops
|
|
14
|
+
* the bytes, and a replayed session shows the image envelope without pixels.
|
|
15
|
+
*
|
|
16
|
+
* @module @crowdedkingdoms/crowdy-dsh/attachments
|
|
17
|
+
*/
|
|
18
|
+
import z from '@deepseek-ai/schemastery';
|
|
19
|
+
import { AttachmentError, AttachmentId, AttachmentStore, ImageVariantId, } from '@deepseek-ai/dsh-attachment';
|
|
20
|
+
const MEDIA_TYPES = ['image/png', 'image/jpeg', 'image/webp', 'image/gif'];
|
|
21
|
+
/** Intrinsic dimensions read from the container header, or undefined when the bytes are not that format. */
|
|
22
|
+
export function imageDimensions(data, mediaType) {
|
|
23
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
24
|
+
switch (mediaType) {
|
|
25
|
+
case 'image/png': {
|
|
26
|
+
if (data.byteLength < 24)
|
|
27
|
+
return undefined;
|
|
28
|
+
const signature = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
29
|
+
if (!signature.every((byte, index) => data[index] === byte))
|
|
30
|
+
return undefined;
|
|
31
|
+
return { width: view.getUint32(16), height: view.getUint32(20) };
|
|
32
|
+
}
|
|
33
|
+
case 'image/gif': {
|
|
34
|
+
if (data.byteLength < 10 || data[0] !== 0x47 || data[1] !== 0x49 || data[2] !== 0x46)
|
|
35
|
+
return undefined;
|
|
36
|
+
return { width: view.getUint16(6, true), height: view.getUint16(8, true) };
|
|
37
|
+
}
|
|
38
|
+
case 'image/webp': {
|
|
39
|
+
if (data.byteLength < 30)
|
|
40
|
+
return undefined;
|
|
41
|
+
if (String.fromCharCode(...data.subarray(0, 4)) !== 'RIFF')
|
|
42
|
+
return undefined;
|
|
43
|
+
if (String.fromCharCode(...data.subarray(8, 12)) !== 'WEBP')
|
|
44
|
+
return undefined;
|
|
45
|
+
const chunk = String.fromCharCode(...data.subarray(12, 16));
|
|
46
|
+
if (chunk === 'VP8 ') {
|
|
47
|
+
return { width: view.getUint16(26, true) & 0x3fff, height: view.getUint16(28, true) & 0x3fff };
|
|
48
|
+
}
|
|
49
|
+
if (chunk === 'VP8L') {
|
|
50
|
+
const bits = view.getUint32(21, true);
|
|
51
|
+
return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 };
|
|
52
|
+
}
|
|
53
|
+
if (chunk === 'VP8X') {
|
|
54
|
+
const width = 1 + (data[24] | (data[25] << 8) | (data[26] << 16));
|
|
55
|
+
const height = 1 + (data[27] | (data[28] << 8) | (data[29] << 16));
|
|
56
|
+
return { width, height };
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
case 'image/jpeg': {
|
|
61
|
+
if (data.byteLength < 4 || data[0] !== 0xff || data[1] !== 0xd8)
|
|
62
|
+
return undefined;
|
|
63
|
+
let offset = 2;
|
|
64
|
+
while (offset + 9 < data.byteLength) {
|
|
65
|
+
if (data[offset] !== 0xff) {
|
|
66
|
+
offset += 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const marker = data[offset + 1];
|
|
70
|
+
if (marker === 0xd8 || (marker >= 0xd0 && marker <= 0xd7) || marker === 0x01) {
|
|
71
|
+
offset += 2;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const length = view.getUint16(offset + 2);
|
|
75
|
+
const isSof = (marker >= 0xc0 && marker <= 0xc3) ||
|
|
76
|
+
(marker >= 0xc5 && marker <= 0xc7) ||
|
|
77
|
+
(marker >= 0xc9 && marker <= 0xcb) ||
|
|
78
|
+
(marker >= 0xcd && marker <= 0xcf);
|
|
79
|
+
if (isSof) {
|
|
80
|
+
return { height: view.getUint16(offset + 5), width: view.getUint16(offset + 7) };
|
|
81
|
+
}
|
|
82
|
+
offset += 2 + length;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function digest(data) {
|
|
91
|
+
// FNV-1a over the bytes, two lanes; content addressing only needs to make
|
|
92
|
+
// identical captures share one id, not resist an adversary.
|
|
93
|
+
let h1 = 0x811c9dc5;
|
|
94
|
+
let h2 = 0x9747b28c;
|
|
95
|
+
for (let index = 0; index < data.byteLength; index += 1) {
|
|
96
|
+
h1 = Math.imul(h1 ^ data[index], 0x01000193) >>> 0;
|
|
97
|
+
h2 = Math.imul(h2 ^ data[index], 0x85ebca6b) >>> 0;
|
|
98
|
+
}
|
|
99
|
+
return `${h1.toString(16).padStart(8, '0')}${h2.toString(16).padStart(8, '0')}${data.byteLength.toString(16)}`;
|
|
100
|
+
}
|
|
101
|
+
function sanitizeName(name) {
|
|
102
|
+
if (!name)
|
|
103
|
+
return undefined;
|
|
104
|
+
const leaf = name.split(/[\\/]/).pop() ?? '';
|
|
105
|
+
const cleaned = leaf.replace(/[^\w.\- ]+/g, '_').slice(0, 120);
|
|
106
|
+
return cleaned || undefined;
|
|
107
|
+
}
|
|
108
|
+
export class CrowdyAttachmentStore extends AttachmentStore {
|
|
109
|
+
static Config = z.object({
|
|
110
|
+
maxImageBytes: z.number().default(4 * 1024 * 1024),
|
|
111
|
+
maxImageDimension: z.number().default(8192),
|
|
112
|
+
});
|
|
113
|
+
imageLimits;
|
|
114
|
+
images = new Map();
|
|
115
|
+
constructor(ctx, config = {}) {
|
|
116
|
+
super(ctx);
|
|
117
|
+
const maxImageBytes = config.maxImageBytes ?? 4 * 1024 * 1024;
|
|
118
|
+
const maxImageDimension = config.maxImageDimension ?? 8192;
|
|
119
|
+
this.imageLimits = {
|
|
120
|
+
maxImageBytes,
|
|
121
|
+
maxImagesPerMessage: 6,
|
|
122
|
+
maxMessageImageBytes: maxImageBytes * 3,
|
|
123
|
+
maxImagePixels: maxImageDimension * maxImageDimension,
|
|
124
|
+
maxImageDimension,
|
|
125
|
+
mediaTypes: MEDIA_TYPES,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
inspect(input) {
|
|
129
|
+
if (!MEDIA_TYPES.includes(input.mediaType)) {
|
|
130
|
+
throw new AttachmentError(`Unsupported image media type ${input.mediaType}.`, 'UNSUPPORTED_IMAGE_TYPE');
|
|
131
|
+
}
|
|
132
|
+
if (input.data.byteLength > this.imageLimits.maxImageBytes) {
|
|
133
|
+
throw new AttachmentError(`The image is ${input.data.byteLength} bytes; the limit is ${this.imageLimits.maxImageBytes}.`, 'IMAGE_TOO_LARGE');
|
|
134
|
+
}
|
|
135
|
+
const dimensions = imageDimensions(input.data, input.mediaType);
|
|
136
|
+
if (!dimensions) {
|
|
137
|
+
// Declared type and bytes disagree, or the header is unreadable.
|
|
138
|
+
const sniffed = MEDIA_TYPES.find((type) => imageDimensions(input.data, type));
|
|
139
|
+
throw new AttachmentError(sniffed
|
|
140
|
+
? `The bytes are ${sniffed}, not ${input.mediaType}.`
|
|
141
|
+
: 'The bytes are not a PNG, JPEG, WebP or GIF image.', sniffed ? 'IMAGE_TYPE_MISMATCH' : 'INVALID_IMAGE');
|
|
142
|
+
}
|
|
143
|
+
if (dimensions.width > this.imageLimits.maxImageDimension || dimensions.height > this.imageLimits.maxImageDimension) {
|
|
144
|
+
throw new AttachmentError(`The image is ${dimensions.width}x${dimensions.height}; each side may be at most ${this.imageLimits.maxImageDimension} px.`, 'IMAGE_DIMENSION_TOO_LARGE');
|
|
145
|
+
}
|
|
146
|
+
if (dimensions.width * dimensions.height > this.imageLimits.maxImagePixels) {
|
|
147
|
+
throw new AttachmentError('The image has too many pixels.', 'IMAGE_TOO_MANY_PIXELS');
|
|
148
|
+
}
|
|
149
|
+
return dimensions;
|
|
150
|
+
}
|
|
151
|
+
async validateImage(input) {
|
|
152
|
+
this.inspect(input);
|
|
153
|
+
}
|
|
154
|
+
async saveImage(input) {
|
|
155
|
+
const { width, height } = this.inspect(input);
|
|
156
|
+
const id = `img-${digest(input.data)}`;
|
|
157
|
+
const name = sanitizeName(input.name);
|
|
158
|
+
const ref = {
|
|
159
|
+
attachmentId: AttachmentId(id),
|
|
160
|
+
mediaType: input.mediaType,
|
|
161
|
+
bytes: input.data.byteLength,
|
|
162
|
+
width,
|
|
163
|
+
height,
|
|
164
|
+
...(name === undefined ? {} : { name }),
|
|
165
|
+
};
|
|
166
|
+
if (!this.images.has(id))
|
|
167
|
+
this.images.set(id, { ref, data: input.data.slice() });
|
|
168
|
+
return ref;
|
|
169
|
+
}
|
|
170
|
+
async readImage(ref, signal) {
|
|
171
|
+
signal?.throwIfAborted();
|
|
172
|
+
const stored = this.images.get(String(ref.attachmentId));
|
|
173
|
+
if (!stored) {
|
|
174
|
+
throw new AttachmentError(`Attachment ${String(ref.attachmentId)} is not in memory (the page was reloaded since it was captured).`, 'ATTACHMENT_NOT_FOUND');
|
|
175
|
+
}
|
|
176
|
+
return { ref: { ...stored.ref }, data: stored.data };
|
|
177
|
+
}
|
|
178
|
+
async readImageRequest(ref, policy, signal) {
|
|
179
|
+
const stored = await this.readImage(ref, signal);
|
|
180
|
+
if (stored.data.byteLength > policy.maxBytes * 4) {
|
|
181
|
+
// No encoder here: an image far above the route's byte target would be
|
|
182
|
+
// rejected by the provider, so refuse with the reason instead.
|
|
183
|
+
throw new AttachmentError(`The image (${stored.data.byteLength} bytes) is too large for this model route; capture a smaller screenshot.`, 'IMAGE_TOO_LARGE');
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
variantId: ImageVariantId(`${String(ref.attachmentId)}:${policy.maxPixels}:${policy.maxBytes}:verbatim`),
|
|
187
|
+
attachment: { ...stored.ref },
|
|
188
|
+
data: stored.data,
|
|
189
|
+
mediaType: stored.ref.mediaType,
|
|
190
|
+
bytes: stored.data.byteLength,
|
|
191
|
+
width: stored.ref.width,
|
|
192
|
+
height: stored.ref.height,
|
|
193
|
+
depth: 'uchar',
|
|
194
|
+
space: 'srgb',
|
|
195
|
+
hasAlpha: stored.ref.mediaType === 'image/png' || stored.ref.mediaType === 'image/webp' || stored.ref.mediaType === 'image/gif',
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export default CrowdyAttachmentStore;
|
|
200
|
+
//# sourceMappingURL=crowdy-attachment-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crowdy-attachment-store.js","sourceRoot":"","sources":["../../src/attachments/crowdy-attachment-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,6BAA6B,CAAA;AAkBpC,MAAM,WAAW,GAA8B,CAAC,W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AC;;AAGH,eAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker-side half of the page bridge: a request/response and event layer
|
|
3
|
+
* over one `BroadcastChannel`.
|
|
4
|
+
*
|
|
5
|
+
* `BroadcastChannel` is the one same-origin primitive a dedicated worker, the
|
|
6
|
+
* iframe that spawned it, and the embedding Studio page all share without the
|
|
7
|
+
* worker knowing its own port topology. The harness's own tunnel to the iframe
|
|
8
|
+
* is untouched; this channel is separate and ignores frames it did not define.
|
|
9
|
+
*
|
|
10
|
+
* @module @crowdedkingdoms/crowdy-dsh/bridge/client
|
|
11
|
+
*/
|
|
12
|
+
import { BRIDGE_ERROR_CODES, CROWDY_BRIDGE_PROTOCOL_VERSION, isBridgeFrame, } from './protocol.js';
|
|
13
|
+
export class BridgeError extends Error {
|
|
14
|
+
code;
|
|
15
|
+
constructor(message, code) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.name = 'BridgeError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function defaultChannelFactory() {
|
|
22
|
+
const scope = globalThis;
|
|
23
|
+
if (typeof scope.BroadcastChannel !== 'function')
|
|
24
|
+
return undefined;
|
|
25
|
+
const ctor = scope.BroadcastChannel;
|
|
26
|
+
return (name) => new ctor(name);
|
|
27
|
+
}
|
|
28
|
+
export class BridgeClient {
|
|
29
|
+
channel;
|
|
30
|
+
pending = new Map();
|
|
31
|
+
listeners = new Map();
|
|
32
|
+
timeoutMs;
|
|
33
|
+
nonce;
|
|
34
|
+
sequence = 0;
|
|
35
|
+
/** Whether a page has said hello since the channel opened. */
|
|
36
|
+
pagePresent = false;
|
|
37
|
+
constructor(options = {}) {
|
|
38
|
+
this.timeoutMs = options.timeoutMs ?? 15_000;
|
|
39
|
+
this.nonce = options.nonce ?? '';
|
|
40
|
+
const factory = options.channelFactory ?? defaultChannelFactory();
|
|
41
|
+
if (options.channel && !options.nonce) {
|
|
42
|
+
console.warn('crowdy bridge: a channel without a boot nonce; refusing to join (the page must send crowdy.json with bridgeNonce)');
|
|
43
|
+
}
|
|
44
|
+
if (options.channel && options.nonce && factory) {
|
|
45
|
+
this.channel = factory(options.channel);
|
|
46
|
+
this.channel.addEventListener('message', (event) => {
|
|
47
|
+
this.handle(event.data);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** True when a channel exists (a page may or may not be listening yet). */
|
|
52
|
+
get available() {
|
|
53
|
+
return this.channel !== undefined;
|
|
54
|
+
}
|
|
55
|
+
on(event, listener) {
|
|
56
|
+
let set = this.listeners.get(event);
|
|
57
|
+
if (!set) {
|
|
58
|
+
set = new Set();
|
|
59
|
+
this.listeners.set(event, set);
|
|
60
|
+
}
|
|
61
|
+
set.add(listener);
|
|
62
|
+
return () => {
|
|
63
|
+
set?.delete(listener);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
emit(event, payload) {
|
|
67
|
+
if (!this.channel)
|
|
68
|
+
return;
|
|
69
|
+
const frame = { v: CROWDY_BRIDGE_PROTOCOL_VERSION, n: this.nonce, from: 'worker', t: 'event', event, payload };
|
|
70
|
+
this.channel.postMessage(frame);
|
|
71
|
+
}
|
|
72
|
+
async request(method, params, options = {}) {
|
|
73
|
+
if (!this.channel) {
|
|
74
|
+
throw new BridgeError('This action needs the Crowdy Studio page, which is not connected to the harness (developer cockpit).', BRIDGE_ERROR_CODES.unavailable);
|
|
75
|
+
}
|
|
76
|
+
if (!this.pagePresent) {
|
|
77
|
+
throw new BridgeError('Crowdy Studio has not connected to the agent yet. Keep the Studio panel open and retry in a moment.', BRIDGE_ERROR_CODES.unavailable);
|
|
78
|
+
}
|
|
79
|
+
options.signal?.throwIfAborted();
|
|
80
|
+
this.sequence += 1;
|
|
81
|
+
const id = `w${this.sequence}-${Date.now().toString(36)}`;
|
|
82
|
+
const frame = { v: CROWDY_BRIDGE_PROTOCOL_VERSION, n: this.nonce, from: 'worker', t: 'req', id, method, params };
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const timeout = options.timeoutMs ?? this.timeoutMs;
|
|
85
|
+
const timer = setTimeout(() => {
|
|
86
|
+
this.pending.delete(id);
|
|
87
|
+
reject(new BridgeError(`Crowdy Studio did not answer ${method} within ${Math.round(timeout / 1000)}s.`, BRIDGE_ERROR_CODES.timeout));
|
|
88
|
+
}, timeout);
|
|
89
|
+
const onAbort = () => {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
this.pending.delete(id);
|
|
92
|
+
reject(new BridgeError(`${method} was cancelled.`, BRIDGE_ERROR_CODES.refused));
|
|
93
|
+
};
|
|
94
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
95
|
+
this.pending.set(id, {
|
|
96
|
+
resolve: (value) => {
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
99
|
+
resolve(value);
|
|
100
|
+
},
|
|
101
|
+
reject: (error) => {
|
|
102
|
+
clearTimeout(timer);
|
|
103
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
104
|
+
reject(error);
|
|
105
|
+
},
|
|
106
|
+
timer,
|
|
107
|
+
});
|
|
108
|
+
this.channel.postMessage(frame);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
close() {
|
|
112
|
+
for (const entry of this.pending.values()) {
|
|
113
|
+
entry.reject(new BridgeError('The bridge closed.', BRIDGE_ERROR_CODES.unavailable));
|
|
114
|
+
}
|
|
115
|
+
this.pending.clear();
|
|
116
|
+
this.channel?.close();
|
|
117
|
+
}
|
|
118
|
+
handle(data) {
|
|
119
|
+
if (!isBridgeFrame(data, this.nonce) || data.from !== 'page')
|
|
120
|
+
return;
|
|
121
|
+
switch (data.t) {
|
|
122
|
+
case 'res': {
|
|
123
|
+
const entry = this.pending.get(data.id);
|
|
124
|
+
if (!entry)
|
|
125
|
+
return;
|
|
126
|
+
this.pending.delete(data.id);
|
|
127
|
+
entry.resolve(data.result);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
case 'err': {
|
|
131
|
+
const entry = this.pending.get(data.id);
|
|
132
|
+
if (!entry)
|
|
133
|
+
return;
|
|
134
|
+
this.pending.delete(data.id);
|
|
135
|
+
entry.reject(new BridgeError(data.message, data.code || BRIDGE_ERROR_CODES.pageError));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
case 'event': {
|
|
139
|
+
if (data.event === 'page.hello')
|
|
140
|
+
this.pagePresent = true;
|
|
141
|
+
if (data.event === 'page.bye')
|
|
142
|
+
this.pagePresent = false;
|
|
143
|
+
const set = this.listeners.get(data.event);
|
|
144
|
+
if (!set)
|
|
145
|
+
return;
|
|
146
|
+
for (const listener of set) {
|
|
147
|
+
try {
|
|
148
|
+
listener(data.payload);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.warn(`crowdy bridge: listener for ${data.event} threw`, error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
default:
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=client.js.map
|