Repository navigation
feat(adapters): add DeepSeek Harness as deepseek_local #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
soyboyscout
wants to merge
10
commits into
master
Choose a base branch
from
feat/deepseek-harness-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
10e2842
Record DeepSeek Harness adapter Phase 0 spike and session watchdog.
soyboyscout e3ac65d
Add DeepSeek Harness adapter package and register deepseek_local.
soyboyscout ba0d88b
Add DeepSeek transcript parser, skills, models, and adapter docs.
soyboyscout b8fe638
Align DeepSeek parser and skills sync with official harness wire types.
soyboyscout 782672c
Add DeepSeek remote/SSH/sandbox execution via a one-shot JSON-RPC bri…
soyboyscout b4d775f
Preserve DeepSeek remoteExecution in the session codec.
soyboyscout 5aba0e7
Copy DeepSeek remote session files back and pair tool-result names.
soyboyscout 6566d35
Merge remote-tracking branch 'origin/master' into feat/deepseek-harne…
soyboyscout 225c0f5
Align DeepSeek adapter with master after merge.
soyboyscout 9eb0adc
Merge remote-tracking branch 'origin/master' into feat/deepseek-harne…
soyboyscout File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| --- | ||
| title: DeepSeek Harness | ||
| summary: DeepSeek Harness JSON-RPC adapter setup and configuration | ||
| --- | ||
|
|
||
| The `deepseek_local` adapter runs [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) as a Paperclip coding agent. Heartbeats talk to `dsh-jsonrpc-agent` over NDJSON JSON-RPC (`initialize`, `session/prompt`, `shutdown`) and resume the same `sessionId`. Compatible with DeepSeek Harness `0.1.1-rc.2`. | ||
|
|
||
| This adapter does **not** use `dsh --profile headless` or `dsh-acp`. ACP cannot resume sessions and keeps tools off the wire. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| A working runtime is three pieces, not `npm i -g @deepseek-ai/dsh-sdk-jsonrpc-demo` alone: | ||
|
|
||
| 1. `dsh-jsonrpc-agent` on `PATH`, or `adapterConfig.command` | ||
| 2. A DeepSeek Harness install (`adapterConfig.harnessRoot` or `DSH_HARNESS_ROOT`) so `NODE_PATH=<harnessRoot>/node_modules` can load `@deepseek-ai/dsh-*` plugins | ||
| 3. Paperclip's shipped `paperclip.cordis.yml` (or `cordisConfigPath`) | ||
|
|
||
| Closed alternative: the Python `deepseek-harness-runtime-bin` executable. | ||
|
|
||
| Stdout is the protocol. Do not add a stdout logger to the Cordis composition. | ||
|
|
||
| ## Auth | ||
|
|
||
| - `DEEPSEEK_API_KEY` (required) | ||
| - `DEEPSEEK_BASE_URL` (optional OpenAI-compatible proxy) | ||
|
|
||
| There is no Claude `setup-token` login. | ||
|
|
||
| ## Configuration fields | ||
|
|
||
| | Field | Type | Default | Description | | ||
| |-------|------|---------|-------------| | ||
| | `model` | string | `deepseek-v4-flash` | JSON-RPC `initialize.model` | | ||
| | `provider` | string | `deepseek-official` | JSON-RPC `initialize.provider` | | ||
| | `harnessRoot` | string | — | Harness install used for plugin `NODE_PATH` | | ||
| | `command` | string | `dsh-jsonrpc-agent` | JSON-RPC stdio binary | | ||
| | `cordisConfigPath` | string | shipped composition | Override `DSH_CORDIS_CONFIG` | | ||
| | `cwd` | string | workspace cwd | Absolute fallback working directory | | ||
| | `persistSession` | boolean | true | Reuse `sessionId` across heartbeats | | ||
| | `timeoutSec` | number | 0 | Wall-clock timeout; 0 disables | | ||
| | `graceSec` | number | 15 | SIGTERM grace | | ||
| | `maxTokens` | number | — | Optional `initialize.maxTokens` | | ||
| | `instructionsFilePath` | string | — | Injected as `DSH_SYSTEM_PROMPT` | | ||
| | `env` | object | {} | Secret refs allowed | | ||
|
|
||
| Cheap model profile: `deepseek-v4-flash`. | ||
|
|
||
| ## Sessions | ||
|
|
||
| Paperclip generates a `sessionId` and sends it on every `session/prompt`. Session files live under `$PAPERCLIP_HOME/adapter-state/<company>/<agent>/deepseek/sessions` (`DSH_SESSION_ROOT`), not `~/.dsh`. A cwd or session-root mismatch starts a fresh session. | ||
|
|
||
| ## Skills | ||
|
|
||
| Desired Paperclip skills are copied into `$PAPERCLIP_HOME/adapter-state/<company>/<agent>/deepseek/skills` and passed as `dsh-skill-filesystem` `customSkillDirs` via `DSH_BUNDLED_SKILL_DIR`. `~/.dsh/skills` and `~/.agents/skills` remain visible as read-only external roots. | ||
|
|
||
| ## Remote / sandbox | ||
|
|
||
| `deepseek_local` is a remote-managed adapter (local, SSH, and sandbox). Execution targets only accept one-shot stdin, so Paperclip uploads a one-shot JSON-RPC bridge plus the shipped Cordis file, skill root, and session root. The bridge owns the duplex `initialize` / `session/prompt` / idle interval on the target and prints `paperclipDeepseek` JSONL plus a final `bridge-result`. | ||
|
|
||
| `getRuntimeCommandSpec.installCommand` is `null`. The remote host must already have `dsh-jsonrpc-agent` (or `adapterConfig.command`) and a harness install that can resolve `@deepseek-ai/dsh-*` plugins. Workspace restore runs in `finally` and never `git push`. After each remote turn the bridge writes `.paperclip-session-export.json` so Paperclip can copy session files back onto the host `DSH_SESSION_ROOT`. | ||
|
|
||
| Local Linux hosts can also set `filesystemScope=workspace` and/or `networkScope=deny|allowlist` to wrap the JSON-RPC runtime with the same `bwrap` confinement other local adapters use. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # @paperclipai/adapter-deepseek-harness | ||
|
|
||
| Paperclip adapter for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`deepseek_local`). | ||
|
|
||
| Heartbeat execute talks to `dsh-jsonrpc-agent` over NDJSON JSON-RPC (`initialize`, `session/prompt`, `shutdown`). Compatible with DeepSeek Harness `0.1.1-rc.2`. | ||
|
|
||
| ## This is not `npm i -g @deepseek-ai/dsh-sdk-jsonrpc-demo` | ||
|
|
||
| That package only ships the JSON-RPC bin. The bin boots `$DSH_CORDIS_CONFIG` (required) and resolves bare `@deepseek-ai/dsh-*` plugins from the **configuration project** / `NODE_PATH`. A working runtime is: | ||
|
|
||
| 1. `dsh-jsonrpc-agent` on `PATH`, or `adapterConfig.command` | ||
| 2. A DeepSeek Harness install (`adapterConfig.harnessRoot` or `DSH_HARNESS_ROOT`) so `NODE_PATH=<harnessRoot>/node_modules` can load plugins | ||
| 3. Paperclip's shipped `paperclip.cordis.yml` (or `adapterConfig.cordisConfigPath`) | ||
|
|
||
| Closed alternative: the Python `deepseek-harness-runtime-bin` executable. | ||
|
|
||
| Do not add a stdout logger to the Cordis composition. Stdout is the protocol. | ||
|
|
||
| ## Auth | ||
|
|
||
| - `DEEPSEEK_API_KEY` (required) | ||
| - `DEEPSEEK_BASE_URL` (optional) | ||
|
|
||
| There is no Claude `setup-token` login. ACP is not advertised: dsh ACP is fresh-session-only and keeps tools off the wire. | ||
|
|
||
| ## Sessions | ||
|
|
||
| Paperclip generates a `sessionId` and reuses it on `session/prompt`. Session files live under `$PAPERCLIP_HOME/adapter-state/<company>/<agent>/deepseek/sessions` (`DSH_SESSION_ROOT`), not `~/.dsh`. | ||
|
|
||
| ## Remote / sandbox | ||
|
|
||
| SSH and sandbox runs upload a one-shot JSON-RPC bridge (`remote-bridge.mjs`), the shipped Cordis file, and the session/skill roots. The remote host must already have `dsh-jsonrpc-agent` and harness plugins; `installCommand` is `null`. Workspace restore runs in `finally` and never `git push`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| { | ||
| "name": "@paperclipai/adapter-deepseek-harness", | ||
| "version": "0.3.1", | ||
| "license": "MIT", | ||
| "homepage": "https://github.com/paperclipai/paperclip", | ||
| "bugs": { | ||
| "url": "https://github.com/paperclipai/paperclip/issues" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/paperclipai/paperclip", | ||
| "directory": "packages/adapters/deepseek-harness" | ||
| }, | ||
| "description": "Paperclip adapter for DeepSeek Harness over JSON-RPC stdio", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": "./src/index.ts", | ||
| "./server": "./src/server/index.ts", | ||
| "./ui": "./src/ui/index.ts", | ||
| "./cli": "./src/cli/index.ts", | ||
| "./ui-parser": "./src/ui-parser.ts" | ||
| }, | ||
| "paperclip": { | ||
| "adapterUiParser": "1.0.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js" | ||
| }, | ||
| "./server": { | ||
| "types": "./dist/server/index.d.ts", | ||
| "import": "./dist/server/index.js" | ||
| }, | ||
| "./ui": { | ||
| "types": "./dist/ui/index.d.ts", | ||
| "import": "./dist/ui/index.js" | ||
| }, | ||
| "./cli": { | ||
| "types": "./dist/cli/index.d.ts", | ||
| "import": "./dist/cli/index.js" | ||
| }, | ||
| "./ui-parser": "./dist/ui-parser.js" | ||
| }, | ||
| "main": "./dist/index.js", | ||
| "types": "./dist/index.d.ts" | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "README.md" | ||
| ], | ||
| "scripts": { | ||
| "build": "tsc && cp src/server/paperclip.cordis.yml dist/server/paperclip.cordis.yml && cp src/server/remote-bridge.mjs dist/server/remote-bridge.mjs", | ||
| "clean": "rm -rf dist", | ||
| "typecheck": "tsc --noEmit", | ||
| "test": "vitest run" | ||
| }, | ||
| "dependencies": { | ||
| "@paperclipai/adapter-utils": "workspace:*", | ||
| "@paperclipai/shared": "workspace:*", | ||
| "picocolors": "^1.1.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^24.0.0", | ||
| "typescript": "^5.7.3", | ||
| "vitest": "^4.1.10" | ||
| }, | ||
| "engines": { | ||
| "node": ">=24.11.0" | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
packages/adapters/deepseek-harness/src/cli/format-event.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import pc from "picocolors"; | ||
| import { parseStdoutLine } from "../ui-parser.js"; | ||
|
|
||
| export function printDeepseekStreamEvent(raw: string, _debug: boolean): void { | ||
| const line = raw.trim(); | ||
| if (!line) return; | ||
| const entries = parseStdoutLine(line, new Date().toISOString()); | ||
| if (entries.length === 0) return; | ||
| for (const entry of entries) { | ||
| const kind = typeof entry.kind === "string" ? entry.kind : "stdout"; | ||
| if (kind === "assistant") { | ||
| console.log(pc.green(String(entry.text ?? ""))); | ||
| continue; | ||
| } | ||
| if (kind === "thinking") { | ||
| console.log(pc.magenta(String(entry.text ?? ""))); | ||
| continue; | ||
| } | ||
| if (kind === "tool_call") { | ||
| console.log(pc.yellow(`tool ${String(entry.name ?? "tool")}`)); | ||
| continue; | ||
| } | ||
| if (kind === "tool_result") { | ||
| const printer = entry.isError ? pc.red : pc.gray; | ||
| console.log(printer(String(entry.content ?? ""))); | ||
| continue; | ||
| } | ||
| if (kind === "stderr") { | ||
| console.log(pc.red(String(entry.text ?? ""))); | ||
| continue; | ||
| } | ||
| if (kind === "system" || kind === "result") { | ||
| console.log(pc.cyan(String(entry.text ?? kind))); | ||
| continue; | ||
| } | ||
| if (typeof entry.text === "string" && entry.text) console.log(entry.text); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { printDeepseekStreamEvent } from "./format-event.js"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { createServerAdapter, type, label } from "./index.js"; | ||
|
|
||
| describe("createServerAdapter", () => { | ||
| it("exports a hireable deepseek_local module", () => { | ||
| const adapter = createServerAdapter(); | ||
| expect(type).toBe("deepseek_local"); | ||
| expect(label).toBe("DeepSeek Harness"); | ||
| expect(adapter.type).toBe("deepseek_local"); | ||
| expect(adapter.supportsLocalAgentJwt).toBe(true); | ||
| expect(adapter.requiresMaterializedRuntimeSkills).toBe(true); | ||
| expect(adapter.sessionCodec).toBeDefined(); | ||
| expect(adapter.getRuntimeCommandSpec?.({})?.installCommand).toBeNull(); | ||
| expect(adapter.runtimeToolDelivery).toBe("environment"); | ||
| expect(adapter.loginCapability).toBeUndefined(); | ||
| expect(adapter.acp).toBeUndefined(); | ||
| expect(adapter.listSkills).toBeTypeOf("function"); | ||
| expect(adapter.detectModel).toBeTypeOf("function"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: CodeCraftersLLC/paperclip
Length of output: 11125
🏁 Script executed:
Repository: CodeCraftersLLC/paperclip
Length of output: 15626
🏁 Script executed:
Repository: CodeCraftersLLC/paperclip
Length of output: 19043
Preserve parser state for each CLI execution stream.
printDeepseekStreamEventcallsparseStdoutLine, which creates a new parser for every line. This discardsstreamedText,streamedThinking, and usage state. A laterassistant/messagecan be printed again, andsession.statuscan report zero usage.Use one
createStdoutParser()instance per execution stream and reset it when the stream ends. Add sequential streamed-message and completion-event tests.🤖 Prompt for AI Agents