From 0058ebc6aa8e6cc8f61ab4aa0d6e14c7f12eb77b Mon Sep 17 00:00:00 2001 From: zhanghui Date: Fri, 13 Nov 2026 13:43:41 +0800 Subject: [PATCH 1/2] fix(dsh): support DeepSeek Harness 0.1.2 through 0.2.x DSH changed what the plugin reads inside the 0.1.x line: 0.1.2 dropped `session.events` for `snapshotEvents()`, and 0.1.7 replaced the single `tool-result` content block with `ToolResultMessage.toolCallId` and removed the shared `plugin` message source kind. Published 0.1.0 has done nothing on any DSH from 0.1.2 on (no recall, no capture), while its peer range `<0.2.0-0` still admitted those hosts. DSH 0.2.x then refused it outright. - read the log through `snapshotEvents()`, falling back to `session.events` - accept both tool-result shapes - declare an `everos-memory` message source kind for recall - widen the DSH peers to `>=0.1.0-rc.6 <0.3.0-0`; version 0.2.0 The unit tests stayed green throughout because their Session is written by the tests, and scripts/e2e-everos.sh installs the `latest` dist-tag, still 0.1.0-rc.6 for dsh-agent. Two scripts close that gap: - scripts/host-matrix.sh runs the packed plugin on nine published DSH versions against a stub EverOS (free; added to CI) - scripts/e2e-dsh-headless.sh goes through the DSH CLI's own agent loop and a real EverOS: a fact stated in one session is answered in a fresh one, and not answered when recall is cut off Refs EverMind-AI/EverOS#551 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dsh.yml | 3 + dsh/README.md | 29 +++- dsh/package-lock.json | 228 +++++++++++++++++-------------- dsh/package.json | 16 +-- dsh/scripts/e2e-dsh-headless.sh | 124 +++++++++++++++++ dsh/scripts/host-check.mjs | 143 +++++++++++++++++++ dsh/scripts/host-matrix.sh | 43 ++++++ dsh/src/capture.ts | 31 +++-- dsh/src/recall.ts | 36 +++-- dsh/test/capture-runtime.test.ts | 25 ++-- dsh/test/recall.test.ts | 10 +- 11 files changed, 536 insertions(+), 152 deletions(-) create mode 100755 dsh/scripts/e2e-dsh-headless.sh create mode 100644 dsh/scripts/host-check.mjs create mode 100755 dsh/scripts/host-matrix.sh diff --git a/.github/workflows/dsh.yml b/.github/workflows/dsh.yml index 0d23e08..3a06e39 100644 --- a/.github/workflows/dsh.yml +++ b/.github/workflows/dsh.yml @@ -48,3 +48,6 @@ jobs: - name: Verify npm package contents run: npm pack --dry-run + + - name: Run the packed plugin on each supported DSH version + run: ./scripts/host-matrix.sh diff --git a/dsh/README.md b/dsh/README.md index 2b892a2..4e27e2c 100644 --- a/dsh/README.md +++ b/dsh/README.md @@ -20,7 +20,8 @@ turn. ## Requirements - Node.js `^22.19.0 || >=24.0.0` -- DeepSeek Harness `0.1.0-rc.6` or newer within the `0.1.x` line +- DeepSeek Harness `0.1.0-rc.6` through the `0.2.x` line (`scripts/host-matrix.sh` checks + 0.1.0-rc.6 to 0.2.2-rc.2) - EverOS installed and initialized ```bash @@ -217,14 +218,24 @@ authority. ```bash npm ci npm run ci # lint + typecheck + 20 unit tests + build +./scripts/host-matrix.sh # the PACKED artifact on each published DSH, stub EverOS ./scripts/e2e-everos.sh # the PACKED artifact against a REAL EverOS +./scripts/e2e-dsh-headless.sh # real DSH CLI agent loop + real EverOS, two sessions ``` `npm run ci` uses mocked HTTP and DSH-shaped event logs. It needs no credentials and starts no EverOS, but for the same reason it cannot tell you the plugin works against the real ones: both the fetch and the session are written by the tests themselves. -`scripts/e2e-everos.sh` answers that question instead. It starts its own EverOS on its +`scripts/host-matrix.sh` answers it for the DSH side. For each DSH version it installs +`@deepseek-ai/dsh-agent` at that version (npm resolves the rest), unpacks what `npm pack` +would ship next to it, and runs `scripts/host-check.mjs`: one turn on a real Session with +a recall, a tool call and result, and a seal, judged by what a stub EverOS received. It +needs no credentials and no EverOS. DSH has renamed what the plugin reads inside a minor +line before (0.1.2 dropped `session.events`; 0.1.7 replaced the tool-result block), so +run it against every new DSH release before widening the supported range. + +`scripts/e2e-everos.sh` answers the EverOS side. It starts its own EverOS on its own port under its own root, installs what `npm pack` would ship into a project holding DSH at its published versions, and drives the three lifecycle points through real cordis events on a real `@deepseek-ai/dsh-session` Session. Every check reads backend receipt — @@ -244,8 +255,16 @@ DSH_E2E_SOURCE_CONFIG=~/.everos/everos.toml ./scripts/e2e-everos.sh - The EverOS add API has no idempotency key. An ambiguous network failure followed by a later retry may produce at-least-once capture semantics. - Recall currently has no management UI or explicit remember/forget tools. -- `scripts/e2e-everos.sh` dispatches the agent events itself. That a real DSH turn emits - `agent/pre-step` at step 1 with the turn's user messages, and `agent/turn-stopping` once - per turn, is taken from the host's declared types rather than observed in a real run. +- `scripts/e2e-everos.sh` installs the DSH packages' `latest` dist-tag, which is still + `0.1.0-rc.6` for `dsh-agent`; DSH 0.2.x is covered by `scripts/host-matrix.sh` only. +- `host-matrix.sh` and `e2e-everos.sh` dispatch the agent events themselves. + `scripts/e2e-dsh-headless.sh` is the one that goes through DSH's own agent loop: it + installs the DSH CLI (0.2.2-rc.1 by default; needs Node >= 24.9 and `DEEPSEEK_API_KEY`), + adds the packed plugin to an isolated headless profile, states a fact in one session, + and passes only if a fresh session answers with it while the same question with recall + cut off does not. It spends real tokens. The Desktop and Web profiles are not covered. +- DSH bounds plugin shutdown: a headless run waits about 5 s for the seal's `/flush`, + then exits. EverOS has the request by then and finishes the extraction, but a flush + that runs longer gets no response and may not appear in EverOS's access log. - Every failure path fails open into `logger.warn`. Memory stopping is not otherwise visible to the user. diff --git a/dsh/package-lock.json b/dsh/package-lock.json index 4c8ac93..52f2236 100644 --- a/dsh/package-lock.json +++ b/dsh/package-lock.json @@ -1,22 +1,22 @@ { "name": "@everos-ai/dsh-plugin", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@everos-ai/dsh-plugin", - "version": "0.1.0", + "version": "0.2.0", "license": "Apache-2.0", "dependencies": { "@deepseek-ai/schemastery": "^3.18.1" }, "devDependencies": { "@biomejs/biome": "2.2.0", - "@deepseek-ai/cordis": "4.0.1", - "@deepseek-ai/dsh-agent": "0.1.0-rc.6", - "@deepseek-ai/dsh-llm": "0.1.0-rc.6", - "@deepseek-ai/dsh-session": "0.1.0-rc.6", + "@deepseek-ai/cordis": "4.1.0", + "@deepseek-ai/dsh-agent": "0.2.2-rc.1", + "@deepseek-ai/dsh-llm": "0.2.2-rc.1", + "@deepseek-ai/dsh-session": "0.2.2-rc.1", "@types/node": "^22.10.0", "tsx": "^4.20.0", "typescript": "^5.9.0" @@ -195,21 +195,21 @@ } }, "node_modules/@deepseek-ai/cordis": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis/-/cordis-4.0.1.tgz", - "integrity": "sha512-YBdskTU2Po1kru3GgcUWUbkTsPMA9LkSQDAY8rBkFJeajdgcQad3QPJZE26JyK99Xb6HaASvoXg2DSUTeN/0Nw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis/-/cordis-4.1.0.tgz", + "integrity": "sha512-CJrjNyBkKn1SfvBQUcgFYKFnLjS+uKrhdMsbHU60xabvi12d+xQ+IQSNlME5Z+B+4Zi6n4BDknKY94tEPeo47w==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/cosmokit": "^1.8.2", + "@deepseek-ai/cosmokit": "~1.9.0", "@standard-schema/spec": "^1.1.0" }, "bin": { "cordis": "bin.js" }, "peerDependencies": { - "@deepseek-ai/cordis-plugin-include": "^1.0.6", - "@deepseek-ai/cordis-plugin-loader": "^1.0.2" + "@deepseek-ai/cordis-plugin-include": "~1.1.0", + "@deepseek-ai/cordis-plugin-loader": "~1.1.0" }, "peerDependenciesMeta": { "@deepseek-ai/cordis-plugin-include": { @@ -221,158 +221,176 @@ } }, "node_modules/@deepseek-ai/cosmokit": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/@deepseek-ai/cosmokit/-/cosmokit-1.8.2.tgz", - "integrity": "sha512-muBOKtSrUKU5m/xpq8ZXWL6hQ/jgd4PhU2PqH97bcxIiLEJfNwZOGQEx4t/aS/GgxRAR+ra9pMHPMtTHU4sqqA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cosmokit/-/cosmokit-1.9.0.tgz", + "integrity": "sha512-5O1S53mZiJyZYcvxxD0Qv1EY7qFPSxbGyD8CbVK6gw7W9FvcXZj2YIX1ZkOqyQQ3Xt2rFkZDHJv0+V3Zmmp8CA==", "license": "MIT" }, "node_modules/@deepseek-ai/dsh-agent": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-agent/-/dsh-agent-0.1.0-rc.6.tgz", - "integrity": "sha512-vtqq2pWTrzn0dKfj5kREZRpP82AwtGjGx9V1lYnKvF+Uc/a8zyWbSvjDE7V1d3YQAQJzs2cWO31hURWDekDXIA==", + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-agent/-/dsh-agent-0.2.2-rc.1.tgz", + "integrity": "sha512-3zNf9+SRLKkzItWN83OAZtG1M2TO3fPB6vi3w/Z44jiXJioz1WoZJj6qFYHwP57i+8RmMUOWP7OBPpV9m/Sqlw==", "dev": true, "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.2-rc.1", + "zod": "4.4.3" + }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6", - "@deepseek-ai/dsh-llm": "^0.1.0-rc.6", - "@deepseek-ai/dsh-scope": "^0.1.0-rc.6", - "@deepseek-ai/dsh-session": "^0.1.0-rc.6", - "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6", - "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0", + "@deepseek-ai/dsh-llm": "0.2.2-rc.1", + "@deepseek-ai/dsh-scope": "0.2.2-rc.1", + "@deepseek-ai/dsh-session": "0.2.2-rc.1", + "@deepseek-ai/dsh-session-projection": "0.2.2-rc.1", + "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1", + "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1", + "@deepseek-ai/dsh-util-values": "0.2.2-rc.1", + "@deepseek-ai/dsh-workspace": "0.2.2-rc.1" + }, + "peerDependenciesMeta": { + "@deepseek-ai/dsh-workspace": { + "optional": true + } } }, - "node_modules/@deepseek-ai/dsh-attachment": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-attachment/-/dsh-attachment-0.1.0-rc.6.tgz", - "integrity": "sha512-3P6N17NQ8jqSQGzeCs+svCIqArU8oq0YmgEAo+axN9aVuUDferWU4DLRSX59UGpmyldX4LQn81toA+c+DqMcHg==", + "node_modules/@deepseek-ai/dsh-brand": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-brand/-/dsh-brand-0.2.2-rc.1.tgz", + "integrity": "sha512-ShGNEmNuEQA+bfkspWC2kGrdbrM4dFNhqlrNHIWsHO+PgVH1KoTKTLSraT1pt0A8YYk/moKE0gL2gY9dNBU+rw==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-brand": "^0.1.0-rc.6", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0" } }, - "node_modules/@deepseek-ai/dsh-brand": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-brand/-/dsh-brand-0.1.0-rc.6.tgz", - "integrity": "sha512-E8j9Nby24qP4rfrdcfc7bpt1CHpGT3tYmycOJJkEOH4ptIdT1m2ro9nmnSd5CWYukTr64A77vjm2WGqHRI92UA==", + "node_modules/@deepseek-ai/dsh-llm": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-llm/-/dsh-llm-0.2.2-rc.1.tgz", + "integrity": "sha512-XeEvH+6bpkjx0E2P1B5ZE+WWa+VHp4DimQaJDKNUZEFouqHMuN1B61TIz6IzUquRxa/6X4yJy+qXQ9WwAeMw5w==", "dev": true, "license": "MIT", - "peer": true, + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.2-rc.1", + "@deepseek-ai/dsh-timeout": "0.2.2-rc.1", + "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1", + "@deepseek-ai/dsh-util-crypto": "0.2.2-rc.1", + "@deepseek-ai/dsh-util-values": "0.2.2-rc.1", + "@deepseek-ai/schemastery": "~3.19.0", + "zod": "4.4.3" + }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0" } }, - "node_modules/@deepseek-ai/dsh-invariants": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-invariants/-/dsh-invariants-0.1.0-rc.6.tgz", - "integrity": "sha512-WfEfOi99a4cpOugRAHTBSTnesLieu3ist1q9PXDXFBHX++K1rAl9+sB7YrdnbB8LH0UOY532gS9xJUYU6w0SLw==", + "node_modules/@deepseek-ai/dsh-scope": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-scope/-/dsh-scope-0.2.2-rc.1.tgz", + "integrity": "sha512-FOJbXYvrskIcrb/4eVMMQfp0kaReTSBtIry2KsGNURb0OJfelqeSKaB1MsQQq/sOxbt3nPJIN9HY00SwmrTk3Q==", "dev": true, "license": "MIT", "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.1.0" + } + }, + "node_modules/@deepseek-ai/dsh-session": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session/-/dsh-session-0.2.2-rc.1.tgz", + "integrity": "sha512-e0zx9HFNn8EyqrymGQS85SjKOyr61//ChTgIVDlCBSZvBB723fuXyi9LiHIIuPTlkgmWJl3gm5J51ebEXew7PQ==", + "dev": true, + "license": "MIT", "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "@deepseek-ai/dsh-brand": "0.2.2-rc.1", + "@deepseek-ai/dsh-llm": "0.2.2-rc.1", + "@deepseek-ai/dsh-util-values": "0.2.2-rc.1" }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1" + "@deepseek-ai/cordis": "~4.1.0", + "@deepseek-ai/dsh-scope": "0.2.2-rc.1" } }, - "node_modules/@deepseek-ai/dsh-llm": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-llm/-/dsh-llm-0.1.0-rc.6.tgz", - "integrity": "sha512-kuFGC8bHlzGTwlRxQhXjf3CYWl8M4NzH+EYIkrW8rri4iMc9W53xrdvkil5No/DUlMm8g1u7GdeiWYFy0TMvtA==", + "node_modules/@deepseek-ai/dsh-session-projection": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-projection/-/dsh-session-projection-0.2.2-rc.1.tgz", + "integrity": "sha512-+wGhr1kVdhYv7E355HJUCq+foG1Dt40ehGULCdCxT46we6S1Ie2d1yUH18VvVCsEw0eM1ATe241mx3UCUMDYWQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "zod": "4.4.3" }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-attachment": "^0.1.0-rc.6", - "@deepseek-ai/dsh-brand": "^0.1.0-rc.6", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6", - "@deepseek-ai/dsh-timeout": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0", + "@deepseek-ai/dsh-session": "0.2.2-rc.1" } }, - "node_modules/@deepseek-ai/dsh-scope": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-scope/-/dsh-scope-0.1.0-rc.6.tgz", - "integrity": "sha512-UlDLV4syLoJinNg9imhXrSAHrdaTa5Ff8gg46rzjFJGPUOhAk3DZff0hryT5OhrBi0A5Tj92qVpg2pRVvxnUzQ==", + "node_modules/@deepseek-ai/dsh-system-prompt": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.2.2-rc.1.tgz", + "integrity": "sha512-1p9imdrenPnJTkLb6Coq+ELBDjngblM/YGP1Pa/xf1oisjLHcCoK2n9kkOUTIfgvoFtqWfxZJNZeKef71ZmlrA==", "dev": true, "license": "MIT", "peer": true, + "dependencies": { + "@deepseek-ai/schemastery": "~3.19.0" + }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0", + "@deepseek-ai/dsh-llm": "0.2.2-rc.1", + "@deepseek-ai/dsh-scope": "0.2.2-rc.1" } }, - "node_modules/@deepseek-ai/dsh-session": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session/-/dsh-session-0.1.0-rc.6.tgz", - "integrity": "sha512-8tu8I6VWC7050GAUXWhcEWQw4pakALQc8TlhKr52m7Y4+kIKeNt3FBgP86PaGPBtpK0p5zUPRQNkFpzZbBdxyw==", + "node_modules/@deepseek-ai/dsh-timeout": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-timeout/-/dsh-timeout-0.2.2-rc.1.tgz", + "integrity": "sha512-dn5eQbPjdQIH2WrVXyQjxgsxkB006+O8OhclMQZtIZnUjWaqxtBmot0wSdyrPxrULyXxiHmmdRCeLruZBO0n0Q==", "dev": true, "license": "MIT", "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-brand": "^0.1.0-rc.6", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6", - "@deepseek-ai/dsh-llm": "^0.1.0-rc.6", - "@deepseek-ai/dsh-scope": "^0.1.0-rc.6", - "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0" } }, - "node_modules/@deepseek-ai/dsh-system-prompt": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.1.0-rc.6.tgz", - "integrity": "sha512-E7g+XChh4q4/wX++v56z1pV4SA1Rtz42xkznLPPi9FlXrrzJxwHMOUzBZ9Rz3Y1kLhQ++HJG3ZatmNx3rjFilg==", + "node_modules/@deepseek-ai/dsh-typert-protocol": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-typert-protocol/-/dsh-typert-protocol-0.2.2-rc.1.tgz", + "integrity": "sha512-TrasPUFkoUafa9gAALMRYy2skAiM1nQ9qmmbgWF8FyHyIQsMTK4BTW8g4JcRnS0+y9YTIk2OytRT2ps9NGzI9A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "@deepseek-ai/dsh-brand": "0.2.2-rc.1", + "zod": "^4.4.3" }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6", - "@deepseek-ai/dsh-llm": "^0.1.0-rc.6", - "@deepseek-ai/dsh-scope": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0" } }, - "node_modules/@deepseek-ai/dsh-timeout": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-timeout/-/dsh-timeout-0.1.0-rc.6.tgz", - "integrity": "sha512-CUean0fAnfsJVszFEip7PsU/S26W+JfDFfsza2dCtlw8n6xlkbHA9Gjxdk2aTwqDGCgXEPkRW7mYkdJ0n6FR7w==", + "node_modules/@deepseek-ai/dsh-util-crypto": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-crypto/-/dsh-util-crypto-0.2.2-rc.1.tgz", + "integrity": "sha512-I9Nhh3/64HPzjdR/mUt0J534FYHgodMUe0coXtA91+kxGcJQcSHOYouewv4hf0NWw0BuLh5zihTdtldZtobOWA==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0" } }, - "node_modules/@deepseek-ai/dsh-typert-protocol": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-typert-protocol/-/dsh-typert-protocol-0.1.0-rc.6.tgz", - "integrity": "sha512-weWzN8r01YCkoDCAM7BsKw2YhRrD4zL8N2SAZu9hovYtXSq8xHXsP4Zh8RLYIlYcuotjyff/6hic+0TJPd14YA==", + "node_modules/@deepseek-ai/dsh-util-values": { + "version": "0.2.2-rc.1", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-values/-/dsh-util-values-0.2.2-rc.1.tgz", + "integrity": "sha512-UN4B/Fa9zAunYN3UuXDQ3QknxF/lMKNwTu2WxXKKEC+Ejz745po7I/JmsVFVa7+socfuwwTmVrfSsddRVU+lew==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.1.0" } }, "node_modules/@deepseek-ai/schemastery": { - "version": "3.18.1", - "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.1.tgz", - "integrity": "sha512-Qn0FCSwCQnpnj6SB31I6i2sIKgKWnkbJM8O0EU91Gv2UsYVvtZTl6IA0sCwk2e2MZf5S8w5hpq9QkeVvK9qwxg==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.19.0.tgz", + "integrity": "sha512-bDXoYQa7ghAhmdYD5VPlzKxEzJV/aKkz5l4V5h1u06z8GAPN1ROewSjvR9WiXhpa52E9fng8lpH5QdCRIQgnyQ==", "license": "MIT", "dependencies": { - "@deepseek-ai/cosmokit": "^1.8.2", + "@deepseek-ai/cosmokit": "~1.9.0", "@standard-schema/spec": "^1.1.0" } }, @@ -930,6 +948,16 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" + }, + "node_modules/zod": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", + "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/dsh/package.json b/dsh/package.json index fc6f834..93a7e4b 100644 --- a/dsh/package.json +++ b/dsh/package.json @@ -1,6 +1,6 @@ { "name": "@everos-ai/dsh-plugin", - "version": "0.1.0", + "version": "0.2.0", "description": "Automatic cross-session memory for DeepSeek Harness, backed by a local EverOS service.", "keywords": [ "deepseek-harness", @@ -61,16 +61,16 @@ }, "peerDependencies": { "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-agent": ">=0.1.0-rc.6 <0.2.0-0", - "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6 <0.2.0-0", - "@deepseek-ai/dsh-session": ">=0.1.0-rc.6 <0.2.0-0" + "@deepseek-ai/dsh-agent": ">=0.1.0-rc.6 <0.3.0-0", + "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6 <0.3.0-0", + "@deepseek-ai/dsh-session": ">=0.1.0-rc.6 <0.3.0-0" }, "devDependencies": { "@biomejs/biome": "2.2.0", - "@deepseek-ai/cordis": "4.0.1", - "@deepseek-ai/dsh-agent": "0.1.0-rc.6", - "@deepseek-ai/dsh-llm": "0.1.0-rc.6", - "@deepseek-ai/dsh-session": "0.1.0-rc.6", + "@deepseek-ai/cordis": "4.1.0", + "@deepseek-ai/dsh-agent": "0.2.2-rc.1", + "@deepseek-ai/dsh-llm": "0.2.2-rc.1", + "@deepseek-ai/dsh-session": "0.2.2-rc.1", "@types/node": "^22.10.0", "tsx": "^4.20.0", "typescript": "^5.9.0" diff --git a/dsh/scripts/e2e-dsh-headless.sh b/dsh/scripts/e2e-dsh-headless.sh new file mode 100755 index 0000000..2c0f6d0 --- /dev/null +++ b/dsh/scripts/e2e-dsh-headless.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash +# Acceptance through a REAL DSH agent loop and a REAL EverOS. +# +# scripts/host-matrix.sh and scripts/e2e-everos.sh dispatch the agent hooks +# themselves. This one installs the DSH CLI, adds the packed plugin to an isolated +# headless profile the way a user would (`dsh plugin --profile headless add`), and +# runs two real headless sessions on a real model: +# 1. a session states an unguessable fact; +# 2. a FRESH session asks for it back. +# It passes only if EverOS extracted the fact to markdown, session 2 answers with +# it, and a control session asking the same with recall cut off does not. +# +# DEEPSEEK_API_KEY=... ./scripts/e2e-dsh-headless.sh +# +# Spends real tokens: two short DSH turns on DeepSeek, and EverOS extraction with +# whatever LLM its config names. Needs: node >= 24.9 (DSH's engine; set +# DSH_E2E_NODE_BIN to a directory holding one), python3, curl, an EverOS checkout, +# and an EverOS config with working llm/embedding/rerank credentials. Everything +# lives under one temp dir (DSH_HOME included) and is removed on exit. +set -uo pipefail + +DSH_VERSION="${DSH_E2E_DSH_VERSION:-0.2.2-rc.1}" +NODE_BIN="${DSH_E2E_NODE_BIN:-}" +PORT="${DSH_E2E_PORT:-8894}" +BASE="http://127.0.0.1:$PORT" +EVEROS_BIN="${DSH_E2E_EVEROS_BIN:-$HOME/EverOS/.venv/bin/everos}" +SOURCE_CONFIG="${DSH_E2E_SOURCE_CONFIG:-$HOME/.everos/raven/everos.toml}" +PKG="$(cd "$(dirname "$0")/.." && pwd)" +WORK="$(mktemp -d -t dsh-headless-e2e)" +ROOT="$WORK/everos-root" +CODE="HERON-$RANDOM-$RANDOM" +SERVER_PID="" +PASS=0; FAIL=0 +[ -n "$NODE_BIN" ] && export PATH="$NODE_BIN:$PATH" + +ok() { printf ' \033[32mPASS\033[0m %s\n' "$1"; PASS=$((PASS+1)); } +bad() { printf ' \033[31mFAIL\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); } +step() { printf '\n\033[1m=== %s\033[0m\n' "$1"; } + +ALIVE="$WORK/.running"; : > "$ALIVE" +SELF=$$ +( sleep "${DSH_E2E_MAX_SECONDS:-1200}"; [ -e "$ALIVE" ] && kill -TERM $SELF 2>/dev/null ) >/dev/null 2>&1 /dev/null + [ -n "$SERVER_PID" ] && kill -TERM "$SERVER_PID" 2>/dev/null && sleep 2 && kill -9 "$SERVER_PID" 2>/dev/null + rm -rf "$WORK" # holds the copied EverOS config and its api keys + [ -d "$WORK" ] && printf '\033[31mWARNING: %s survived teardown, it holds copied api keys\033[0m\n' "$WORK" + exit $rc +} +trap teardown EXIT INT TERM + +dsh() { + (cd "$WORK/workspace" && DSH_HOME="$WORK/dsh-home" DSH_AGENTS_HOME="$WORK/agents-home" \ + EVEROS_DSH_BASE_URL="${RECALL_URL:-$BASE}" EVEROS_DSH_USER_ID=dsh_headless_e2e \ + node "$WORK/cli/node_modules/@deepseek-ai/dsh/lib/bin.js" "$@") +} + +step "0. Preflight" +[ -n "${DEEPSEEK_API_KEY:-}" ] || { bad "DEEPSEEK_API_KEY is not set"; exit 1; } +node -e 'const [a,b]=process.versions.node.split(".").map(Number); process.exit(a>24||(a===24&&b>=9)?0:1)' \ + || { bad "node $(node -v) is older than DSH's 24.9 (set DSH_E2E_NODE_BIN)"; exit 1; } +[ -x "$EVEROS_BIN" ] && [ -f "$SOURCE_CONFIG" ] || { bad "no EverOS binary or config"; exit 1; } +curl -fsS --max-time 2 "$BASE/health" -o /dev/null 2>/dev/null && { bad "port $PORT busy"; exit 1; } +mkdir -p "$WORK/cli" "$WORK/workspace" "$WORK/dsh-home" "$WORK/agents-home" "$ROOT" +ok "node $(node -v), port $PORT free, fact code $CODE" + +step "1. DSH $DSH_VERSION with the packed plugin in an isolated headless profile" +echo '{"private":true}' > "$WORK/cli/package.json" +(cd "$WORK/cli" && npm install --no-audit --no-fund "@deepseek-ai/dsh@$DSH_VERSION") >"$WORK/npm.log" 2>&1 \ + || { bad "installing DSH failed"; tail -5 "$WORK/npm.log"; exit 1; } +TARBALL="$WORK/$(cd "$PKG" && npm pack --silent --pack-destination "$WORK" | tail -1)" +dsh plugin --profile headless add "$TARBALL" >"$WORK/plugin-add.log" 2>&1 \ + || { bad "dsh plugin add failed"; tail -10 "$WORK/plugin-add.log"; exit 1; } +dsh headless --dump-config 2>/dev/null | grep -q "id: everos-memory" \ + && ok "DSH composed the everos-memory row (its version gate admitted the plugin)" \ + || { bad "the plugin is not in the composed profile"; exit 1; } + +step "2. An isolated EverOS" +cp "$SOURCE_CONFIG" "$ROOT/everos.toml" +[ -f "$(dirname "$SOURCE_CONFIG")/ome.toml" ] && cp "$(dirname "$SOURCE_CONFIG")/ome.toml" "$ROOT/ome.toml" +EVEROS_MEMORIZE__MODE=agent "$EVEROS_BIN" server start --root "$ROOT" --port "$PORT" >"$WORK/everos.log" 2>&1 & +SERVER_PID=$! +for _ in $(seq 1 45); do curl -fsS --max-time 2 "$BASE/health" -o /dev/null 2>/dev/null && break; sleep 2; done +curl -fsS --max-time 2 "$BASE/health" -o /dev/null 2>/dev/null && ok "EverOS on $PORT" \ + || { bad "EverOS did not come up"; tail -20 "$WORK/everos.log"; exit 1; } + +step "3. Session 1 states the fact" +dsh headless "Please remember for future sessions: the staging deploy key rotation codename is $CODE. Acknowledge in one sentence." \ + >"$WORK/s1.out" 2>"$WORK/s1.err" || bad "session 1 exited non-zero" +grep -c 'POST /api/v[12]/memory/add' "$WORK/everos.log" | grep -qv '^0$' \ + && ok "the finished turn reached EverOS /add" || bad "session 1 sent no /add" + +step "4. EverOS extracts it to markdown" +MD="" +for _ in $(seq 1 60); do + MD=$(grep -rl "$CODE" "$ROOT" --include='*.md' 2>/dev/null | head -1) + [ -n "$MD" ] && break + sleep 5 +done +[ -n "$MD" ] && ok "extracted into ${MD#"$ROOT"/}" || bad "no memory markdown mentions $CODE" + +step "5. A fresh session 2 asks, and a control session without recall" +ASK="What is the staging deploy key rotation codename? If you do not know it, reply exactly UNKNOWN." +final() { python3 -c 'import json,sys +for l in open(sys.argv[1]): + e = json.loads(l) if l.strip().startswith("{") else {} + if e.get("type") == "final": print(e.get("text", ""))' "$1"; } +dsh headless --json "$ASK" >"$WORK/s2.jsonl" 2>"$WORK/s2.err" || bad "session 2 exited non-zero" +A2=$(final "$WORK/s2.jsonl") +[[ "$A2" == *"$CODE"* ]] && ok "session 2 answered with the fact: ${A2:0:120}" \ + || bad "session 2 did not answer with the fact: ${A2:0:200}" +# The same question with recall cut off (nothing listens there; `false` stops the +# plugin from auto-starting an EverOS) must not know the random code: what session +# 2 knew came through the plugin. +RECALL_URL="http://127.0.0.1:$((PORT + 1))" EVEROS_DSH_START_COMMAND=false \ + dsh headless --json "$ASK" >"$WORK/s3.jsonl" 2>"$WORK/s3.err" || bad "control session exited non-zero" +A3=$(final "$WORK/s3.jsonl") +[[ -n "$A3" && "$A3" != *"$CODE"* ]] && ok "with recall cut off a fresh session does not know it: ${A3:0:80}" \ + || bad "the control session answered '${A3:0:120}': the fact did not depend on recall" + +step "Result" +printf ' %d passed, %d failed\n' "$PASS" "$FAIL" +[ "$FAIL" -eq 0 ] diff --git a/dsh/scripts/host-check.mjs b/dsh/scripts/host-check.mjs new file mode 100644 index 0000000..326012a --- /dev/null +++ b/dsh/scripts/host-check.mjs @@ -0,0 +1,143 @@ +// One real DSH turn against a fake EverOS, judged by what the fake received. +// +// The Session, SessionStore, AgentRegistry, and message factories are the +// installed DSH's own, so the host's shapes come from the host, not from this +// file. EverOS is a stub (no LLM, no storage): this checks only the DSH side of +// the plugin - hooks, Session reads, message shapes. scripts/host-matrix.sh runs +// it once per DSH version; scripts/e2e-everos.sh covers the EverOS side. +// +// node host-check.mjs -> prints PASS|FAIL and the received summary; exit 1 on FAIL +import http from 'node:http' +import { Context } from '@deepseek-ai/cordis' +import { AgentRegistry } from '@deepseek-ai/dsh-agent' +import * as llm from '@deepseek-ai/dsh-llm' +import { SessionId, SessionStore } from '@deepseek-ai/dsh-session' +import * as everosPlugin from '@everos-ai/dsh-plugin' + +const received = [] +const server = http.createServer((req, res) => { + let body = '' + req.on('data', (chunk) => { + body += chunk + }) + req.on('end', () => { + const json = body ? JSON.parse(body) : undefined + received.push({ path: req.url, body: json }) + res.setHeader('content-type', 'application/json') + if (req.url === '/health') return res.end(JSON.stringify({ status: 'ok' })) + const route = req.url.split('/').pop() + const data = + route === 'search' + ? { + episodes: [ + { id: 'e1', subject: 'deploy key', summary: 'Ops rotates it', episode: '', score: 1 }, + ], + profiles: [], + agent_cases: [], + agent_skills: [], + unprocessed_messages: [], + } + : route === 'add' + ? { message_count: json.messages.length, status: 'accumulated' } + : { status: 'no_extraction' } + res.end(JSON.stringify({ data })) + }) +}) +await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)) + +const ctx = new Context() +await ctx.plugin(SessionStore) +// DSH 0.2.x AgentRegistry injects `sessionProjections`; 0.1.x has no such package. +try { + const { SessionProjectionRegistry } = await import('@deepseek-ai/dsh-session-projection') + await ctx.plugin(SessionProjectionRegistry) +} catch {} +await ctx.plugin(AgentRegistry) +await ctx.plugin(everosPlugin, { + baseUrl: `http://127.0.0.1:${server.address().port}`, + userId: 'host_check_user', + autoStart: false, +}) +await new Promise((resolve) => setTimeout(resolve, 200)) +// cordis loads a plugin whose inject is unmet and silently never applies it. +if (!ctx.get('agents')) { + console.log('HARNESS: agents service missing; the plugin was never applied') + process.exit(2) +} + +const session = ctx.sessions.prepare(SessionId('host-check'), { meta: { cwd: '/work/host-check' } }) +const leave = ctx.sessions.enter(session) +ctx.sessions.announce(session) +const signal = new AbortController().signal +const agent = { id: session.id, session, ctx } + +const user = llm.createUserMessage({ + source: { kind: 'user' }, + content: [{ type: 'text', text: 'Who rotates the deploy key?' }], +}) +session.append('turn/start', { turn: 1 }) +session.append('user/message', user, { surfaceOp: 'append' }) +const decision = await ctx.events.waterfall( + 'agent/pre-step', + { agent, messages: [user], turn: 1, step: 1, signal }, + async () => ({ kind: 'enter', messages: [user] }), +) +const injected = decision.messages.slice(1) +// The loop appends what pre-step admitted, so Session judges the recall message. +let recallAccepted = true +try { + for (const message of injected) session.append('user/message', message, { surfaceOp: 'append' }) +} catch (error) { + recallAccepted = String(error) +} + +const callId = 'call-1' +const assistant = (step, content) => ({ + turn: 1, + step, + message: llm.createAssistantMessage({ source: { provider: 'stub', model: 'stub' }, content }), +}) +session.append( + 'assistant/message', + assistant(1, [{ type: 'tool-call', id: callId, name: 'read_file', arguments: '{}' }]), + { surfaceOp: 'append' }, +) +session.append('tool/call', { turn: 1, step: 1, callId, name: 'read_file', arguments: '{}' }) +const result = llm.createToolResultMessage({ + callId, + isError: false, + content: [{ type: 'text', text: 'Ops rotates the key every Tuesday' }], +}) +session.append('tool/result', { turn: 1, step: 1, message: result }, { surfaceOp: 'append' }) +session.append('assistant/message', assistant(2, [{ type: 'text', text: 'Ops does.' }]), { + surfaceOp: 'append', +}) +session.append('turn/end', { turn: 1, reason: 'completed' }) + +await ctx.events.serial('agent/turn-stopping', { agent, turn: 1, signal }) +leave() // disposes the announced session -> the plugin seals and flushes it +await new Promise((resolve) => setTimeout(resolve, 1500)) + +const ofRoute = (route) => received.filter((r) => r.path.endsWith(`/memory/${route}`)) +const added = ofRoute('add').flatMap((r) => r.body.messages) +const tool = added.find((m) => m.role === 'tool') +const summary = { + searches: ofRoute('search').length, + recallInjected: injected.length, + recallAccepted, + addedRoles: added.map((m) => m.role).join(','), + assistantToolCall: added.find((m) => m.tool_calls)?.tool_calls[0]?.id, + toolResult: tool && `${tool.tool_call_id}|${tool.sender_name}|${tool.content}`, + flushes: ofRoute('flush').length, +} +const pass = + summary.searches === 2 && + summary.recallInjected === 1 && + summary.recallAccepted === true && + summary.addedRoles === 'user,assistant,tool,assistant' && + summary.assistantToolCall === callId && + summary.toolResult === `${callId}|read_file|Ops rotates the key every Tuesday` && + summary.flushes === 1 +console.log(`${pass ? 'PASS' : 'FAIL'} ${JSON.stringify(summary)}`) +server.close() +process.exit(pass ? 0 : 1) diff --git a/dsh/scripts/host-matrix.sh b/dsh/scripts/host-matrix.sh new file mode 100755 index 0000000..ced8d6e --- /dev/null +++ b/dsh/scripts/host-matrix.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Run scripts/host-check.mjs against each published DSH version in turn. +# +# The unit tests hand the plugin a Session they wrote themselves, so they stay +# green when DSH renames what the plugin reads (0.1.2 dropped `session.events`, +# 0.1.7 replaced the tool-result block). This installs what `npm pack` would ship +# next to each real DSH and judges one turn by what a stub EverOS received. +# No credentials, no LLM, no EverOS. +# +# ./scripts/host-matrix.sh # the supported versions below +# ./scripts/host-matrix.sh 0.2.2-rc.2 ... # specific @deepseek-ai/dsh-agent versions +set -uo pipefail + +VERSIONS=("$@") +[ ${#VERSIONS[@]} -eq 0 ] && VERSIONS=( + 0.1.0-rc.6 0.1.2-rc.1 0.1.5-rc.3 0.1.7-rc.2 + 0.2.0-rc.2 0.2.1-rc.3 0.2.1-rc.5 0.2.2-rc.1 0.2.2-rc.2 +) +PKG="$(cd "$(dirname "$0")/.." && pwd)" +WORK="$(mktemp -d -t dsh-host-matrix)" +trap 'rm -rf "$WORK"' EXIT INT TERM + +TARBALL="$(cd "$PKG" && npm pack --silent --pack-destination "$WORK" | tail -1)" +FAIL=0 +for v in "${VERSIONS[@]}"; do + dir="$WORK/dsh-$v" + mkdir -p "$dir" + echo '{"name":"host-check","private":true,"type":"module"}' >"$dir/package.json" + # Only the agent is pinned: npm resolves its llm/session peers the way a user's + # install would (0.1.0-rc.6 pulls 0.1.0-rc.8 of both). + if ! (cd "$dir" && npm install --no-audit --no-fund \ + "@deepseek-ai/dsh-agent@$v" @deepseek-ai/schemastery) >"$dir/npm.log" 2>&1; then + printf 'FAIL %-12s npm install failed:\n' "$v"; tail -5 "$dir/npm.log"; FAIL=1; continue + fi + # Extract rather than `npm install` the tarball: its peer range is what is under test. + # After the install, which would prune a directory it did not create. + mkdir -p "$dir/node_modules/@everos-ai/dsh-plugin" + tar xzf "$WORK/$TARBALL" -C "$dir/node_modules/@everos-ai/dsh-plugin" --strip-components=1 + cp "$PKG/scripts/host-check.mjs" "$dir/" + printf '%-12s ' "$v" + (cd "$dir" && node host-check.mjs) || FAIL=1 +done +exit $FAIL diff --git a/dsh/src/capture.ts b/dsh/src/capture.ts index 1454540..65e7df1 100644 --- a/dsh/src/capture.ts +++ b/dsh/src/capture.ts @@ -1,10 +1,10 @@ /** Lossless-enough DSH event mapping for EverOS user and agent extraction. */ import type { ContentBlock } from '@deepseek-ai/dsh-llm' -import type { Session } from '@deepseek-ai/dsh-session' +import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' import { agentIdOf } from './identity.js' -import { blocksToText, isDirectUserMessage } from './recall.js' +import { blocksToText, isDirectUserMessage, sessionEvents } from './recall.js' import type { MessageItem, ToolCall } from './types.js' export interface CapturedMessage { @@ -12,6 +12,13 @@ export interface CapturedMessage { item: MessageItem } +interface LegacyToolResult { + type: 'tool-result' + toolCallId: string + content: readonly ContentBlock[] + isError?: boolean +} + export interface CaptureSlice { messages: CapturedMessage[] scannedThroughSeq: number @@ -48,9 +55,9 @@ function toolCalls(blocks: readonly ContentBlock[], maxChars: number): ToolCall[ return calls.length === 0 ? undefined : calls } -function toolNameIndex(session: Session): Map { +function toolNameIndex(events: readonly SessionEvent[]): Map { const names = new Map() - for (const event of session.events) { + for (const event of events) { if (event.type === 'tool/call') names.set(String(event.data.callId), event.data.name) } return names @@ -71,11 +78,12 @@ export function captureMessagesSince( maxChars: number, ): CaptureSlice { const agentId = agentIdOf(session, configuredAgentId) - const names = toolNameIndex(session) + const events = sessionEvents(session) + const names = toolNameIndex(events) const output: CapturedMessage[] = [] let scannedThroughSeq = afterSeq - for (const event of session.events) { + for (const event of events) { if (event.seq <= afterSeq) continue scannedThroughSeq = Math.max(scannedThroughSeq, event.seq) const timestamp = Number.isSafeInteger(event.time) && event.time > 0 ? event.time : Date.now() @@ -118,10 +126,13 @@ export function captureMessagesSince( case 'tool/result': { const message = event.data.message - const block = message.content[0] - const callId = String(block.toolCallId) - const resultText = blocksToText(block.content) - const status = block.isError || event.data.error ? '[tool error]\n' : '' + // DSH <=0.1.5 wrapped the result in a single `tool-result` block. + const legacy = (message.content as readonly unknown[])[0] as LegacyToolResult | undefined + const wrapped = legacy?.type === 'tool-result' ? legacy : undefined + const callId = String(wrapped?.toolCallId ?? message.toolCallId) + const resultText = blocksToText(wrapped?.content ?? message.content) + const status = + (wrapped?.isError ?? message.isError) || event.data.error ? '[tool error]\n' : '' const content = clipText(`${status}${resultText}`, maxChars).trim() || '[empty tool result]' output.push({ seq: event.seq, diff --git a/dsh/src/recall.ts b/dsh/src/recall.ts index 7d6302b..ff29484 100644 --- a/dsh/src/recall.ts +++ b/dsh/src/recall.ts @@ -1,8 +1,8 @@ /** Recall query construction and safe model-context rendering. */ -import type { ContentBlock, UserMessage } from '@deepseek-ai/dsh-llm' +import type { ContentBlock, ContextFormed, UserMessage } from '@deepseek-ai/dsh-llm' import { createUserMessage } from '@deepseek-ai/dsh-llm' -import type { Session } from '@deepseek-ai/dsh-session' +import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' import type { ResolvedConfig } from './config.js' import type { EverosClient } from './everos-client.js' @@ -27,7 +27,12 @@ function imageLabel(block: Extract): string { } /** Convert model-visible content to recall/capture text without exposing attachment paths. */ -export function blocksToText(blocks: readonly ContentBlock[], includeReasoning = false): string { +export function blocksToText( + blocks: readonly ContentBlock[] | string, + includeReasoning = false, +): string { + // Field report (EverOS #551): a DSH 0.2.1 tool result arrived as a bare string. + if (typeof blocks === 'string') return blocks.trim() const parts: string[] = [] for (const block of blocks) { switch (block.type) { @@ -40,11 +45,6 @@ export function blocksToText(blocks: readonly ContentBlock[], includeReasoning = case 'image': parts.push(imageLabel(block)) break - case 'tool-call': - break - case 'tool-result': - parts.push(blocksToText(block.content, includeReasoning)) - break default: break } @@ -60,8 +60,17 @@ function clipHead(text: string, maxChars: number): string { return text.length <= maxChars ? text : text.slice(0, maxChars) } +/** The session log on every supported DSH: 0.1.2 replaced `session.events` with `snapshotEvents()`. */ +export function sessionEvents(session: Session): readonly SessionEvent[] { + // ponytail: snapshotEvents() is marked deprecated (sync read) but is the only + // public reader from 0.1.2 through 0.2.x; move to a `session/event` listener + // if a later DSH removes it. + if (typeof session.snapshotEvents === 'function') return session.snapshotEvents() + return (session as unknown as { events?: readonly SessionEvent[] }).events ?? [] +} + function recentDirectUserMessages(session: Session): UserMessage[] { - return session.events.flatMap((event) => { + return sessionEvents(session).flatMap((event) => { if (event.type !== 'user/message' || !isDirectUserMessage(event.data)) return [] return [event.data] }) @@ -218,6 +227,13 @@ export async function recallMessage(options: RecallOptions): Promise session.events, + } + return session as unknown as Session & { events: unknown[] } } test('maps direct user, assistant tool call, and tool result without reasoning echoes', () => { @@ -220,7 +217,7 @@ test('runtime skips resumed seed history and splits the 500-message API limit', createdAt: 1, cwd: '/work/repository', }, - events, + snapshotEvents: () => events, } as unknown as Session await runtime.capture(session) diff --git a/dsh/test/recall.test.ts b/dsh/test/recall.test.ts index f86e4f1..c058123 100644 --- a/dsh/test/recall.test.ts +++ b/dsh/test/recall.test.ts @@ -15,18 +15,18 @@ function userMessage(id: string, text: string, source: UserMessage['source']): U role: 'user', content: [{ type: 'text', text }], source, - } as UserMessage + } as unknown as UserMessage } test('builds recall queries from direct users while excluding plugin context', () => { const previous = userMessage('m1', 'older requirement', { kind: 'user' }) const plugin = userMessage('m2', 'do not query this', { - kind: 'plugin', - plugin: 'test', + kind: 'everos-memory', + form: 'recall', }) const current = userMessage('m3', 'current task', { kind: 'user' }) const session = { - events: [ + snapshotEvents: () => [ { type: 'user/message', seq: 0, time: 1, data: previous }, { type: 'user/message', seq: 1, time: 2, data: plugin }, ], @@ -78,7 +78,7 @@ test('sends the configured retrieval method to both owner tracks', async () => { }, } as unknown as EverosClient const session = { - events: [], + snapshotEvents: () => [], header: { cwd: '/work/project', agentPreset: 'coding/default' }, } as unknown as Session From 9fdbd1299b3f2f702450ac8d09cbae478dfbd147 Mon Sep 17 00:00:00 2001 From: zhanghui Date: Fri, 13 Nov 2026 13:48:31 +0800 Subject: [PATCH 2/2] fix(dsh): make the host scripts' temp dir portable to GNU mktemp CI runs on Linux, where `mktemp -d -t prefix` needs XXXXXX in the template; the call failed, WORK was empty, and every path landed under /. The run still failed closed. Use an explicit template and stop if mktemp fails. Co-Authored-By: Claude Opus 5.5 --- dsh/scripts/e2e-dsh-headless.sh | 2 +- dsh/scripts/host-matrix.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dsh/scripts/e2e-dsh-headless.sh b/dsh/scripts/e2e-dsh-headless.sh index 2c0f6d0..6517120 100755 --- a/dsh/scripts/e2e-dsh-headless.sh +++ b/dsh/scripts/e2e-dsh-headless.sh @@ -26,7 +26,7 @@ BASE="http://127.0.0.1:$PORT" EVEROS_BIN="${DSH_E2E_EVEROS_BIN:-$HOME/EverOS/.venv/bin/everos}" SOURCE_CONFIG="${DSH_E2E_SOURCE_CONFIG:-$HOME/.everos/raven/everos.toml}" PKG="$(cd "$(dirname "$0")/.." && pwd)" -WORK="$(mktemp -d -t dsh-headless-e2e)" +WORK="$(mktemp -d "${TMPDIR:-/tmp}/dsh-headless-e2e.XXXXXX")" || exit 1 ROOT="$WORK/everos-root" CODE="HERON-$RANDOM-$RANDOM" SERVER_PID="" diff --git a/dsh/scripts/host-matrix.sh b/dsh/scripts/host-matrix.sh index ced8d6e..66b8d96 100755 --- a/dsh/scripts/host-matrix.sh +++ b/dsh/scripts/host-matrix.sh @@ -17,7 +17,8 @@ VERSIONS=("$@") 0.2.0-rc.2 0.2.1-rc.3 0.2.1-rc.5 0.2.2-rc.1 0.2.2-rc.2 ) PKG="$(cd "$(dirname "$0")/.." && pwd)" -WORK="$(mktemp -d -t dsh-host-matrix)" +# A template with XXXXXX: GNU mktemp rejects macOS-style `-t prefix`. +WORK="$(mktemp -d "${TMPDIR:-/tmp}/dsh-host-matrix.XXXXXX")" || exit 1 trap 'rm -rf "$WORK"' EXIT INT TERM TARBALL="$(cd "$PKG" && npm pack --silent --pack-destination "$WORK" | tail -1)"