From 1263b2290bc42059844f0b4670b270a0a35d671b Mon Sep 17 00:00:00 2001 From: MemOS Autodev Date: Fri, 23 Oct 2026 22:25:31 +0800 Subject: [PATCH] fix(plugin): write DSH V4 producer-owned message sources DSH session format V4 validates runtime writes, not just migrations, and rejects any message whose source.kind is the retired V3 wrapper "plugin". The DeepSeek Harness adapter still wrote that shape on both message paths, so the recall injected before every turn failed agent/pre-step and each turn surfaced as UNKNOWN. Both writers now emit "plugin:memos-local-memory" through a shared constant, declared in DSH's MessageSourceMap extension point. That is the same kind DSH's own V3->V4 migration derives, so live and migrated messages stay indistinguishable. The optional DSH peer range also stopped at <0.2.0, which silently skips the bundle on current hosts. It now enumerates each V4 preview line that was actually compiled and tested. JsonValue, moved out of dsh-tools after 0.2, is declared locally so the adapter builds against both lines. Verified: full plugin suite 1601 passed / 2 skipped; adapter suite 68 tests green on DSH 0.1.0-rc.6, 0.1.7-rc.2, 0.2.0-rc.2 and 0.2.1-rc.2; shipped dist accepted by the real V4 admission validator. --- apps/memos-local-plugin/CHANGELOG.md | 10 +- .../adapters/deepseek-harness/README.md | 26 +- .../adapters/deepseek-harness/bridge.ts | 2 +- .../adapters/deepseek-harness/host-llm.ts | 4 +- .../adapters/deepseek-harness/index.ts | 4 +- .../adapters/deepseek-harness/source-kind.ts | 32 ++ .../adapters/deepseek-harness/tools.ts | 14 +- apps/memos-local-plugin/package-lock.json | 277 +++++++++--------- apps/memos-local-plugin/package.json | 26 +- .../adapters/deepseek-harness-bridge.test.ts | 20 +- .../deepseek-harness-host-llm.test.ts | 2 +- .../deepseek-harness-source-kind.test.ts | 60 ++++ 12 files changed, 297 insertions(+), 180 deletions(-) create mode 100644 apps/memos-local-plugin/adapters/deepseek-harness/source-kind.ts create mode 100644 apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-source-kind.test.ts diff --git a/apps/memos-local-plugin/CHANGELOG.md b/apps/memos-local-plugin/CHANGELOG.md index 7700dd6f5..a1e4a7cb6 100644 --- a/apps/memos-local-plugin/CHANGELOG.md +++ b/apps/memos-local-plugin/CHANGELOG.md @@ -5,7 +5,15 @@ for the full per-commit history use `git log` or the GitHub releases page. ## Index -- `2.0.16` (unreleased) — Add the out-of-tree DeepSeek Harness Cordis +- `2.0.16` (unreleased) — **Fix:** DSH session format V4 rejected every turn + with "format v4 message requires a producer-owned source kind" because the + adapter still wrote the retired V3 source wrapper `kind: "plugin"` on both + runtime message paths. Recall messages and host-LLM user messages now carry + the producer-owned `kind: "plugin:memos-local-memory"` (the same value DSH's + own V3→V4 migration derives) and the optional DSH peer range now admits the + V4 preview lines (`0.1.7-rc.x`, `0.2.0-rc.x`, `0.2.1-rc.x`), so `dsh plugin` + no longer needs `allow-version` on current hosts. + Add the out-of-tree DeepSeek Harness Cordis bundle with capture, six memory tools, DSH profile-aware storage, and one automatic recall for every accepted, non-empty direct-user turn. Same-turn re-entry is de-duplicated, while greetings and restored-session turns receive diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/README.md b/apps/memos-local-plugin/adapters/deepseek-harness/README.md index 5c18bc682..9fd74d77d 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/README.md +++ b/apps/memos-local-plugin/adapters/deepseek-harness/README.md @@ -8,10 +8,11 @@ modifying the DSH repository. > [!IMPORTANT] > DeepSeek Harness is currently a developer preview. The initial compatibility -> target for this adapter is DSH `0.1.0-rc.5`; record the exact DSH version in +> target for this adapter was DSH `0.1.0-rc.5`; record the exact DSH version in > every release's validation because later preview releases may require adapter -> changes. Unit compilation and contract tests currently use the published DSH -> `0.1.0-rc.6` packages; the end-to-end host below is the rc.5 source checkout. +> changes. Unit compilation and contract tests currently run against the +> published DSH `0.2.1-rc.2` packages and are re-checked against +> `0.1.0-rc.6`; the end-to-end host below is the rc.5 source checkout. ## How it works @@ -569,11 +570,11 @@ errors and are not fail-open. ## Known limitations -1. **Developer-preview compatibility.** The initial compatibility target is - DSH `0.1.0-rc.5`; verify the packaged artifact against that exact host - before publishing results. Its optional DSH peer range is - `>=0.1.0-rc.5 <0.2.0`, but that range is not a guarantee across preview - breaking changes. +1. **Developer-preview compatibility.** The initial compatibility target was + DSH `0.1.0-rc.5`; verify the packaged artifact against the exact host + before publishing results. Its optional DSH peer range now also admits the + V4 session-format preview lines (`0.1.7-rc.x`, `0.2.0-rc.x`, `0.2.1-rc.x`), + but that range is not a guarantee across preview breaking changes. 2. **Eventual consistency and abrupt-crash replay gap.** Per-turn foreground recall never waits for prior capture, relation, or intent work. A completed background result is visible to later automatic recalls and explicit tool @@ -609,7 +610,14 @@ errors and are not fail-open. is `user` triggers one automatic recall, including greetings. Re-entry in the same logical turn is de-duplicated; plugin and tool messages cannot trigger it. -7. **Background recovery has no owning route.** In opt-in full-memory mode, +7. **Producer-owned message sources.** Session format V4 rejects the retired V3 + wrapper `source: { kind: "plugin", plugin: "" }` and admits only a + producer-owned kind. Both runtime writers therefore emit + `source: { kind: "plugin:memos-local-memory" }`, which is the same value + DSH's V3→V4 migration derives for historical sessions. The recall message + additionally keeps `form: "recall"`; host-LLM messages omit `form` because + they are auxiliary MemOS calls, not DSH conversation context. +8. **Background recovery has no owning route.** In opt-in full-memory mode, startup stale/dirty recovery and the 10-minute dirty-episode rescore run outside any DSH request scope. When the effective MemOS provider is `host`, the adapter disables those autonomous jobs instead of borrowing an diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts b/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts index a2ea43b38..8d237ee9b 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/bridge.ts @@ -18,7 +18,7 @@ import type { DeepSeekHarnessLlmRoute } from "./host-llm.js"; import { waitForDeepSeekHarnessDeadline } from "./deadline.js"; export const DEEPSEEK_HARNESS_AGENT = "deepseek-harness"; -export const DEEPSEEK_HARNESS_PLUGIN = "memos-local-memory"; +export { DEEPSEEK_HARNESS_PLUGIN, DEEPSEEK_HARNESS_SOURCE_KIND } from "./source-kind.js"; export interface DshContentBlockLike { readonly type: string; diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts b/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts index a755efb98..b67a72687 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts @@ -24,10 +24,10 @@ import type { HostLlmCompletion, } from "../../core/llm/host-bridge.js"; import type { LlmMessage, LlmUsage } from "../../core/llm/types.js"; +import { DEEPSEEK_HARNESS_SOURCE_KIND } from "./source-kind.js"; const HOST_LLM_BRIDGE_ID = "deepseek-harness.host.v1"; const HOST_LLM_TIMEOUT_CODE = "MEMOS_DSH_HOST_LLM_TIMEOUT"; -const HOST_LLM_MESSAGE_SOURCE = "memos-local-memory"; const NO_REASONING_EFFORT = ReasoningEffortId("off"); const UNSUPPORTED_REASONING_EFFORT = "UNSUPPORTED_REASONING_EFFORT"; const MODEL_CAPABILITY_TTL_MS = 10 * 60 * 1_000; @@ -366,7 +366,7 @@ function toDshMessage( if (message.role === "user") { return createUserMessage({ content, - source: { kind: "plugin", plugin: HOST_LLM_MESSAGE_SOURCE }, + source: { kind: DEEPSEEK_HARNESS_SOURCE_KIND }, }); } return createAssistantMessage({ diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/index.ts b/apps/memos-local-plugin/adapters/deepseek-harness/index.ts index bc63ba5d6..a793ce824 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/index.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/index.ts @@ -27,6 +27,7 @@ import { createDeepSeekHarnessBridge, DEEPSEEK_HARNESS_AGENT, DEEPSEEK_HARNESS_PLUGIN, + DEEPSEEK_HARNESS_SOURCE_KIND, type DshPreStepDecisionLike, type DshPreStepPayloadLike, type DshSessionEventLike, @@ -387,8 +388,7 @@ export async function apply( createRecallMessage: (text) => createUserMessage({ content: [{ type: "text", text }], source: { - kind: "plugin", - plugin: DEEPSEEK_HARNESS_PLUGIN, + kind: DEEPSEEK_HARNESS_SOURCE_KIND, form: "recall", }, }) as unknown as DshUserMessageLike, diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/source-kind.ts b/apps/memos-local-plugin/adapters/deepseek-harness/source-kind.ts new file mode 100644 index 000000000..4aee27bbb --- /dev/null +++ b/apps/memos-local-plugin/adapters/deepseek-harness/source-kind.ts @@ -0,0 +1,32 @@ +/** + * Producer-owned message source identity for DeepSeek Harness. + * + * DSH session format V4 retired the V3 plugin wrapper (`kind: "plugin"` plus a + * sibling `plugin` field) and admits only producer-owned kinds: a nonempty + * string that is not the literal `"plugin"`. Runtime writes are validated + * before persistence, so a V3-shaped source fails every turn with + * "format v4 message requires a producer-owned source kind" rather than only + * being rewritten on migration. + * + * The harness maps an unknown V3 plugin name to `plugin:`, which is the + * same form this adapter must write directly and the form historical sessions + * are lifted into. Declaring the kind through `MessageSourceMap` follows the + * harness's documented extension point, so the adapter compiles against both + * pre-V4 and V4 type surfaces. + */ + +import type { ContextFormed } from "@deepseek-ai/dsh-llm"; + +/** Plugin name as DSH knows it (Cordis row id, manifest name, log prefix). */ +export const DEEPSEEK_HARNESS_PLUGIN = "memos-local-memory"; + +/** Producer-owned source kind accepted by DSH session format V4. */ +export const DEEPSEEK_HARNESS_SOURCE_KIND = `plugin:${DEEPSEEK_HARNESS_PLUGIN}`; + +declare module "@deepseek-ai/dsh-llm" { + interface MessageSourceMap { + "plugin:memos-local-memory": { + kind: "plugin:memos-local-memory"; + } & ContextFormed; + } +} diff --git a/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts b/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts index 20f2fd518..17e997711 100644 --- a/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts +++ b/apps/memos-local-plugin/adapters/deepseek-harness/tools.ts @@ -1,7 +1,7 @@ /** Read-oriented MemOS tools exposed through DeepSeek Harness. */ import type { Context } from "@deepseek-ai/cordis"; -import { defineTool, type JsonValue } from "@deepseek-ai/dsh-tools"; +import { defineTool } from "@deepseek-ai/dsh-tools"; import type { RetrievalQueryDTO, @@ -25,6 +25,18 @@ import { waitForDeepSeekHarnessDeadline, } from "./deadline.js"; +/** + * Canonical lossless JSON value accepted by DSH tool output. + * + * DSH moved this type between packages across preview releases + * (`dsh-session` re-export through `dsh-tools` before 0.2, `dsh-util-values` + * after). Declaring the shape locally keeps the adapter compiling against + * both without pinning the plugin to one preview line. + */ +type JsonValue = null | boolean | number | string | JsonValue[] | { + [key: string]: JsonValue; +}; + export interface DeepSeekHarnessToolsOptions { core: MemoryCore; profileId: string; diff --git a/apps/memos-local-plugin/package-lock.json b/apps/memos-local-plugin/package-lock.json index fb4d188f0..0d624b10d 100644 --- a/apps/memos-local-plugin/package-lock.json +++ b/apps/memos-local-plugin/package-lock.json @@ -21,12 +21,14 @@ }, "devDependencies": { "@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/dsh-system-prompt": "0.1.0-rc.6", - "@deepseek-ai/dsh-timeout": "0.1.0-rc.6", - "@deepseek-ai/dsh-tools": "0.1.0-rc.6", + "@deepseek-ai/dsh-agent": "0.2.1-rc.2", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-sandbox": "0.2.1-rc.2", + "@deepseek-ai/dsh-scope": "0.2.1-rc.2", + "@deepseek-ai/dsh-session": "0.2.1-rc.2", + "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2", + "@deepseek-ai/dsh-timeout": "0.2.1-rc.2", + "@deepseek-ai/dsh-tools": "0.2.1-rc.2", "@deepseek-ai/schemastery": "^3.18.1", "@preact/preset-vite": "^2.10.5", "@types/better-sqlite3": "^7.6.12", @@ -41,12 +43,12 @@ }, "peerDependencies": { "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-agent": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-llm": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-session": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-timeout": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-tools": ">=0.1.0-rc.5 <0.2.0", + "@deepseek-ai/dsh-agent": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-llm": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-session": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-timeout": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-tools": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", "@deepseek-ai/schemastery": "^3.18.1" }, "peerDependenciesMeta": { @@ -438,212 +440,197 @@ } }, "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.8.6", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cosmokit/-/cosmokit-1.8.6.tgz", + "integrity": "sha512-ZSD/fN52L498LBIOYwjIOlaLv5veY6ZEwI2yzvZUKQtctn0QAPqu8tKdJ+OF5+Tv6NBq1U+wJWH+QI6OGy5EvQ==", "dev": true, "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.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-agent/-/dsh-agent-0.2.1-rc.2.tgz", + "integrity": "sha512-e96Tnq8g/RNCDDUW7kAypY/4cho5QxjLHMhk86BGGIEu9b31XEkSFqwqQIwtYXQez3cDR5z7LZpAM8Uqx9Y8KA==", "dev": true, "license": "MIT", "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" - } - }, - "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==", - "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.0.5", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-scope": "0.2.1-rc.2", + "@deepseek-ai/dsh-session": "0.2.1-rc.2", + "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2", + "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.1-rc.2", + "@deepseek-ai/dsh-workspace": "0.2.1-rc.2" + }, + "peerDependenciesMeta": { + "@deepseek-ai/dsh-workspace": { + "optional": true + } } }, "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==", - "dev": true, - "license": "MIT", - "peer": true, - "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" - } - }, - "node_modules/@deepseek-ai/dsh-code-runtime": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-code-runtime/-/dsh-code-runtime-0.1.0-rc.6.tgz", - "integrity": "sha512-aw8D4IOeMo11A3uxQeE4LFoW3bvaQnVkGFqqtS+lsINDARrOCJHXLUgecoKpys+Lc5erZZ4UQDnymJmL4OCcKA==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-brand/-/dsh-brand-0.2.1-rc.2.tgz", + "integrity": "sha512-T2kcygikRS8rv8cKjgho2x381EgGprv5yQmvHl4/iYbuHE19OW+SLGtHWbV27PGdSHz5U8CJxasYzFosKW4e2A==", "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.0.5" } }, - "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-llm": { + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-llm/-/dsh-llm-0.2.1-rc.2.tgz", + "integrity": "sha512-3xfoMDHEpUJGcH2Lu+lNXUJYRBclYfBkdCG9Au02VzIjYAm9BrFmc/MNuaVTg0vwgvPpTsd6Fx1IeGtfmQFvlg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "@deepseek-ai/dsh-brand": "0.2.1-rc.2", + "@deepseek-ai/dsh-timeout": "0.2.1-rc.2", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2", + "@deepseek-ai/dsh-util-crypto": "0.2.1-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.1-rc.2", + "@deepseek-ai/schemastery": "~3.18.5", + "zod": "4.4.3" }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1" + "@deepseek-ai/cordis": "~4.0.5" } }, - "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-sandbox": { + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-sandbox/-/dsh-sandbox-0.2.1-rc.2.tgz", + "integrity": "sha512-nnxNIkgi4A4tkPrTV8sbVMse3c32OT0U+mwYhLqDz/+cIm5tUGufQD+Ax0zqVeClyzXsxZo0/pVtcqDJrsp+7w==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "@deepseek-ai/dsh-util-values": "0.2.1-rc.2" }, "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.0.5", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-session": "0.2.1-rc.2" } }, "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==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-scope/-/dsh-scope-0.2.1-rc.2.tgz", + "integrity": "sha512-CVGPI4lzmUy7O3zg8X1LavUSmD3JKFkUdykfHN7VkyWXG5oAXSvig9s5PLnIb+sxRItmSpiqPXGnT/48X1T1qg==", "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.0.5" } }, "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==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session/-/dsh-session-0.2.1-rc.2.tgz", + "integrity": "sha512-WDA4lIrXtG5nf1dn2wrA4UzEr7D6e8T3AdPpVSZ7eY4N4ICMDZ0RYuD4GkM+iSb7WkLojdO8ljr0etiIMEbqJg==", "dev": true, "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-rc.2", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.1-rc.2" + }, "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.0.5", + "@deepseek-ai/dsh-scope": "0.2.1-rc.2" } }, "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==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.2.1-rc.2.tgz", + "integrity": "sha512-X1WG2FMyfZapAkcCYyTl0UO5vVqDcCsA9wECJY7eeDTLHJDsqrilQJg2DRgHQzM+2/7T01QyzFZhKd7hfALJxg==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "@deepseek-ai/schemastery": "~3.18.5" }, "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.0.5", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-scope": "0.2.1-rc.2" } }, "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==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-timeout/-/dsh-timeout-0.2.1-rc.2.tgz", + "integrity": "sha512-R75r+GkYP+ZhtIsIfn8MMuRXPkugJr0OyQ1Y+rauoTae2sdVfnE8v5zvQORRCHdh7MiOcmh10dQN70KjHh7qhQ==", "dev": true, "license": "MIT", "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.0.5" } }, "node_modules/@deepseek-ai/dsh-tools": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-tools/-/dsh-tools-0.1.0-rc.6.tgz", - "integrity": "sha512-Tu08EPK3JyK0iNjH4FGzu/1uADynNSS6SmwOLdfytUN0YNqwNuKFSt2OJUg19famNlTgy992DcHfDu0T+gLXFg==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-tools/-/dsh-tools-0.2.1-rc.2.tgz", + "integrity": "sha512-K3gET3VPbtxM66pkeRsEGrZ+bQKiBqrTbNXiIreBKu0hP+qPvlSwhiSI5MTnFp2tMFK5rpuYMZosRIdbfrbJ/g==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" + "@deepseek-ai/dsh-brand": "0.2.1-rc.2", + "@deepseek-ai/dsh-util-values": "0.2.1-rc.2", + "@deepseek-ai/schemastery": "~3.18.5" }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-agent": "^0.1.0-rc.6", - "@deepseek-ai/dsh-code-runtime": "^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-session": "^0.1.0-rc.6", - "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6", - "@deepseek-ai/dsh-user-approval": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.0.5", + "@deepseek-ai/dsh-agent": "0.2.1-rc.2", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-ptc-runtime": "0.2.1-rc.2", + "@deepseek-ai/dsh-sandbox": "0.2.1-rc.2", + "@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.2", + "@deepseek-ai/dsh-scope": "0.2.1-rc.2", + "@deepseek-ai/dsh-session": "0.2.1-rc.2", + "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2", + "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2", + "@deepseek-ai/dsh-working-directory": "0.2.1-rc.2" } }, "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==", + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-typert-protocol/-/dsh-typert-protocol-0.2.1-rc.2.tgz", + "integrity": "sha512-rtsHJHGE9SWX+zOgtDbPUqz3h7r+qFm3h1WASzRJxDnULqo7JaBdIiGshNTFPmetsX+r1T69CKFdTZAJmHwMug==", "dev": true, "license": "MIT", - "peer": true, + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-rc.2", + "zod": "^4.4.3" + }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6" + "@deepseek-ai/cordis": "~4.0.5" } }, - "node_modules/@deepseek-ai/dsh-user-approval": { - "version": "0.1.0-rc.6", - "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-user-approval/-/dsh-user-approval-0.1.0-rc.6.tgz", - "integrity": "sha512-9rnkSDGOpu2XUeGwbPeTzVUTFWTND1PMPM5L/ZQPptV5yyZlQiNxM2rCC6OdL+ZVerwxEqrRhZIQn/KVtQfKag==", + "node_modules/@deepseek-ai/dsh-util-crypto": { + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-crypto/-/dsh-util-crypto-0.2.1-rc.2.tgz", + "integrity": "sha512-V4SxvXL4ZbY5RYJckVtmo3qz4YsA52pYKvDF13+8hsDCEmQIv9YfmLRMA61pjK/i05pGMe3p1pPhAB6L+NOIEA==", "dev": true, "license": "MIT", - "peer": true, - "dependencies": { - "@deepseek-ai/schemastery": "^3.18.1" - }, "peerDependencies": { - "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-agent": "^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-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/cordis": "~4.0.5" + } + }, + "node_modules/@deepseek-ai/dsh-util-values": { + "version": "0.2.1-rc.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-values/-/dsh-util-values-0.2.1-rc.2.tgz", + "integrity": "sha512-mgnByPadOgZtoBxbwMI184li494O6sNn66/NvdqN0RIrzAJmFGpFxpjFkQtQN/yetwWhlx7Ic17+6p7eKl8DNg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5" } }, "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.18.5", + "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.5.tgz", + "integrity": "sha512-Mnobvqf9rHsZYv4g5edj5ddxS1oF1kIdSlz0DunUgnY3LWG5F26MqvH3YOOsSaodCgyzJ16OMN9O99/s5Crtdw==", "dev": true, "license": "MIT", "dependencies": { - "@deepseek-ai/cosmokit": "^1.8.2", + "@deepseek-ai/cosmokit": "~1.8.6", "@standard-schema/spec": "^1.1.0" } }, @@ -4646,6 +4633,16 @@ "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==", "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/apps/memos-local-plugin/package.json b/apps/memos-local-plugin/package.json index d9d5e3099..c6d638ff9 100644 --- a/apps/memos-local-plugin/package.json +++ b/apps/memos-local-plugin/package.json @@ -100,12 +100,12 @@ }, "peerDependencies": { "@deepseek-ai/cordis": "^4.0.1", - "@deepseek-ai/dsh-agent": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-llm": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-session": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-timeout": ">=0.1.0-rc.5 <0.2.0", - "@deepseek-ai/dsh-tools": ">=0.1.0-rc.5 <0.2.0", + "@deepseek-ai/dsh-agent": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-llm": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-session": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-timeout": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", + "@deepseek-ai/dsh-tools": ">=0.1.0-rc.5 <0.2.0 || >=0.1.7-rc.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-rc.1 <0.3.0", "@deepseek-ai/schemastery": "^3.18.1" }, "peerDependenciesMeta": { @@ -136,12 +136,14 @@ }, "devDependencies": { "@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/dsh-system-prompt": "0.1.0-rc.6", - "@deepseek-ai/dsh-timeout": "0.1.0-rc.6", - "@deepseek-ai/dsh-tools": "0.1.0-rc.6", + "@deepseek-ai/dsh-agent": "0.2.1-rc.2", + "@deepseek-ai/dsh-llm": "0.2.1-rc.2", + "@deepseek-ai/dsh-sandbox": "0.2.1-rc.2", + "@deepseek-ai/dsh-scope": "0.2.1-rc.2", + "@deepseek-ai/dsh-session": "0.2.1-rc.2", + "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2", + "@deepseek-ai/dsh-timeout": "0.2.1-rc.2", + "@deepseek-ai/dsh-tools": "0.2.1-rc.2", "@deepseek-ai/schemastery": "^3.18.1", "@preact/preset-vite": "^2.10.5", "@types/better-sqlite3": "^7.6.12", diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts index 4c5404365..b2740e935 100644 --- a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-bridge.test.ts @@ -24,8 +24,7 @@ function recallMessage(text: string): DshUserMessageLike { role: "user", content: [{ type: "text", text }], source: { - kind: "plugin", - plugin: "memos-local-memory", + kind: "plugin:memos-local-memory", form: "recall", }, }; @@ -539,8 +538,7 @@ describe("DeepSeek Harness bridge", () => { expect(first.messages[1]).toMatchObject({ role: "user", source: { - kind: "plugin", - plugin: "memos-local-memory", + kind: "plugin:memos-local-memory", form: "recall", }, content: [{ @@ -553,7 +551,7 @@ describe("DeepSeek Harness bridge", () => { expect(followUp).toMatchObject({ kind: "enter", messages: [followUpPrompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); }); @@ -590,7 +588,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [prompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(1); @@ -637,7 +635,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [prompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); }); @@ -682,7 +680,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [prompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(1); @@ -836,7 +834,7 @@ describe("DeepSeek Harness bridge", () => { expect(result).toMatchObject({ kind: "enter", messages: [retry, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); @@ -959,7 +957,7 @@ describe("DeepSeek Harness bridge", () => { await expect(nextStep).resolves.toMatchObject({ kind: "enter", messages: [secondPrompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(2); @@ -1037,7 +1035,7 @@ describe("DeepSeek Harness bridge", () => { await expect(nextStep).resolves.toMatchObject({ kind: "enter", messages: [secondPrompt, expect.objectContaining({ - source: expect.objectContaining({ plugin: "memos-local-memory" }), + source: expect.objectContaining({ kind: "plugin:memos-local-memory" }), })], }); expect(core.searchMemory).toHaveBeenCalledTimes(2); diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts index 493fba9e7..ef1f37c26 100644 --- a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-host-llm.test.ts @@ -176,7 +176,7 @@ describe("DeepSeek Harness host LLM bridge", () => { { role: "user", content: [{ type: "text", text: "Question" }], - source: { kind: "plugin", plugin: "memos-local-memory" }, + source: { kind: "plugin:memos-local-memory" }, }, { role: "assistant", diff --git a/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-source-kind.test.ts b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-source-kind.test.ts new file mode 100644 index 000000000..26f830748 --- /dev/null +++ b/apps/memos-local-plugin/tests/unit/adapters/deepseek-harness-source-kind.test.ts @@ -0,0 +1,60 @@ +/** + * Regression guard for DSH session format V4 message-source admission. + * + * V4 rejects any runtime-written message whose `source.kind` is the retired V3 + * wrapper `"plugin"` and requires the producer-owned `plugin:` form + * instead. Writing the V3 shape fails every turn at `agent/pre-step`, before + * persistence, so the adapter must never construct it again. + */ + +import { readdir, readFile } from "node:fs/promises"; +import { join, resolve } from "node:path"; + +import { describe, expect, it } from "vitest"; + +import { + DEEPSEEK_HARNESS_PLUGIN, + DEEPSEEK_HARNESS_SOURCE_KIND, +} from "../../../adapters/deepseek-harness/source-kind.js"; + +const adapterDir = resolve(import.meta.dirname, "../../../adapters/deepseek-harness"); + +async function adapterSources(): Promise> { + const names = (await readdir(adapterDir)).filter((name) => name.endsWith(".ts")); + return Promise.all(names.map(async (name) => [ + name, + await readFile(join(adapterDir, name), "utf8"), + ] as [string, string])); +} + +describe("DeepSeek Harness V4 message source", () => { + it("derives the producer-owned kind from the harness plugin name", () => { + expect(DEEPSEEK_HARNESS_PLUGIN).toBe("memos-local-memory"); + expect(DEEPSEEK_HARNESS_SOURCE_KIND).toBe("plugin:memos-local-memory"); + }); + + it("never writes the retired V3 plugin wrapper in adapter sources", async () => { + const offenders: string[] = []; + for (const [name, source] of await adapterSources()) { + source.split("\n").forEach((line, index) => { + // Prose may describe the retired shape; only emitted code matters. + const code = line.replace(/\/\/.*$/, "").replace(/^\s*\*.*$/, ""); + // The V3 wrapper is `kind: "plugin"`; producer-owned kinds are + // `plugin:` and therefore never match this exact literal. + if (/kind:\s*["']plugin["']/.test(code)) { + offenders.push(`${name}:${index + 1}: ${line.trim()}`); + } + }); + } + expect(offenders).toEqual([]); + }); + + it("emits producer-owned kinds from both runtime message writers", async () => { + const recall = await readFile(join(adapterDir, "index.ts"), "utf8"); + const hostLlm = await readFile(join(adapterDir, "host-llm.ts"), "utf8"); + + expect(recall).toContain("kind: DEEPSEEK_HARNESS_SOURCE_KIND"); + expect(recall).toContain('form: "recall"'); + expect(hostLlm).toContain("kind: DEEPSEEK_HARNESS_SOURCE_KIND"); + }); +});