Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/memos-local-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions apps/memos-local-plugin/adapters/deepseek-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: "<name>" }` 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions apps/memos-local-plugin/adapters/deepseek-harness/host-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions apps/memos-local-plugin/adapters/deepseek-harness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
createDeepSeekHarnessBridge,
DEEPSEEK_HARNESS_AGENT,
DEEPSEEK_HARNESS_PLUGIN,
DEEPSEEK_HARNESS_SOURCE_KIND,
type DshPreStepDecisionLike,
type DshPreStepPayloadLike,
type DshSessionEventLike,
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions apps/memos-local-plugin/adapters/deepseek-harness/source-kind.ts
Original file line number Diff line number Diff line change
@@ -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:<name>`, 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;
}
}
14 changes: 13 additions & 1 deletion apps/memos-local-plugin/adapters/deepseek-harness/tools.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down
Loading
Loading