feat(provider): add DeepSeek Harness over ACP #12073
Closedac0rdj(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/12073/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- @@ -0,0 +286,21 @@286+ new ProviderAdapterValidationError({287+ provider: PROVIDER,288+ operation: "session",289+ issue: `No active DeepSeek Harness session for thread '${threadId}'.`,290+ }),291+ );292+ }293+ return Effect.succeed(ctx);294+ };295+296+ const signalTurnLiveness = (ctx: DshSessionContext, turnId: TurnId) =>297+ Queue.offer(ctx.livenessSignals, { turnId }).pipe(Effect.asVoid);298+299+ const beginTurnLiveness = (ctx: DshSessionContext, turnId: TurnId) =>300+ Effect.sync(() => {301+ ctx.livenessTurnId = turnId;302+ // Do not start a deadline until ACP has made observable progress.303+ ctx.lastTurnActivityAtNanos = undefined;304+ ctx.activeToolCallIds.clear();305+ ctx.livenessUpdatesInFlight = 0;306+ });@@ -0,0 +827,21 @@827+ activeTurnId: turnId,828+ status: "running",829+ updatedAt: yield* nowIso,830+ };831+ yield* beginTurnLiveness(ctx, turnId);832+833+ if (isLastPrompt) {834+ yield* offerRuntimeEvent({835+ type: "turn.started",836+ ...(yield* makeEventStamp()),837+ provider: PROVIDER,838+ threadId: input.threadId,839+ turnId,840+ payload: { model: ctx.model },841+ });842+ }843+844+ // DSH advertises no image prompt capability, so attachments reach the845+ // agent through the path line ProviderService puts in the prompt.846+ const rawPrompt = input.input?.trim() ?? "";847+ if (rawPrompt.length === 0) {@@ -101,3 +101,5 @@101101 ],102102 },103103 ],104+ [ProviderDriverKind.make("dsh")]: [105+ { id: "reasoningEffort", label: "Reasoning", type: "select", choices: EFFORT_CHOICES },@@ -0,0 +647,21 @@647+ stopped: false,648+ livenessSignals: yield* Queue.unbounded<DshTurnLivenessSignal>(),649+ livenessTurnId: undefined,650+ lastTurnActivityAtNanos: undefined,651+ activeToolCallIds: new Set(),652+ livenessUpdatesInFlight: 0,653+ };654+655+ const nf = yield* Stream.runDrain(656+ Stream.mapEffect(acp.getEvents(), (event) =>657+ Effect.gen(function* () {658+ switch (event._tag) {659+ case "EventStreamBarrier":660+ yield* Deferred.succeed(event.acknowledge, undefined).pipe(Effect.ignore);661+ return;662+ case "ConnectionTerminated":663+ yield* Effect.logWarning("DeepSeek Harness ACP connection terminated.", {664+ threadId: ctx.threadId,665+ detail: event.error.message,666+ });667+ return;@@ -0,0 +797,21 @@797+ const isLastPrompt = steeringTurnId === undefined;798+ ctx.promptsInFlight += 1;799+800+ const turnModelSelection =801+ input.modelSelection?.instanceId === boundInstanceId ? input.modelSelection : undefined;802+ if (turnModelSelection) {803+ yield* applyDshAcpModelSelection({804+ runtime: ctx.acp,805+ model: turnModelSelection.model,806+ reasoningEffort: getModelSelectionStringOptionValue(807+ turnModelSelection,808+ DSH_REASONING_EFFORT_OPTION_ID,809+ ),810+ mapError: (cause, configId) =>811+ new ProviderAdapterValidationError({812+ provider: PROVIDER,813+ operation: "session/set_config_option",814+ issue: `Failed to apply '${configId}': ${cause.message}`,815+ }),816+ });817+ ctx.model = turnModelSelection.model;@@ -0,0 +110,21 @@110+111+/** Models DSH advertised, with capabilities attached from the same snapshot. */112+export function buildDshModelsFromSessionConfigOptions(113+ configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption> | null | undefined,114+): ReadonlyArray<ServerProviderModel> {115+ const capabilities = buildDshModelCapabilities(configOptions);116+ return buildDshModelsFromConfigOptions(configOptions).map((model) => ({117+ slug: model.slug,118+ name: model.name,119+ isCustom: false,120+ ...(model.isDefault ? { isDefault: true } : {}),121+ capabilities,122+ }));123+}124+125+function dshModelsFromSettings(126+ customModels: ReadonlyArray<CustomModelSetting> | undefined,127+ builtInModels: ReadonlyArray<ServerProviderModel> = DSH_BUILT_IN_MODELS,128+): ReadonlyArray<ServerProviderModel> {129+ return providerModelsFromSettings(builtInModels, customModels ?? [], EMPTY_CAPABILITIES);130+}
- @@ -0,0 +391,21 @@391+ const requestedWireValue = requestedPair392+ ? encodeDshModelWireValue(requestedPair.provider, requestedPair.model)393+ : undefined;394+ if (395+ requestedWireValue !== undefined &&396+ advertisedWireValues.has(requestedWireValue) &&397+ requestedWireValue !== selectOptionCurrentValue(modelConfig)398+ ) {399+ yield* input.runtime.setConfigOption(DSH_MODEL_CONFIG_ID, requestedWireValue).pipe(400+ Effect.mapError((cause): E => input.mapError(cause, DSH_MODEL_CONFIG_ID)),401+ Effect.asVoid,402+ );403+ }404+405+ const effortConfig = findDshConfigOption(configOptions, DSH_REASONING_EFFORT_CONFIG_ID);406+ const reasoningEffort = input.reasoningEffort?.trim();407+ if (reasoningEffort) {408+ const advertisedEffort = flattenDshSelectOptions(effortConfig).some(409+ (option) => option.value === reasoningEffort,410+ );411+ if (advertisedEffort && reasoningEffort !== selectOptionCurrentValue(effortConfig)) {@@ -0,0 +834,21 @@834+ yield* offerRuntimeEvent({835+ type: "turn.started",836+ ...(yield* makeEventStamp()),837+ provider: PROVIDER,838+ threadId: input.threadId,839+ turnId,840+ payload: { model: ctx.model },841+ });842+ }843+844+ // DSH advertises no image prompt capability, so attachments reach the845+ // agent through the path line ProviderService puts in the prompt.846+ const rawPrompt = input.input?.trim() ?? "";847+ if (rawPrompt.length === 0) {848+ ctx.promptsInFlight = Math.max(0, ctx.promptsInFlight - 1);849+ return yield* new ProviderAdapterValidationError({850+ provider: PROVIDER,851+ operation: "sendTurn",852+ issue: "Turn requires non-empty text.",853+ });854+ }@@ -101,3 +101,6 @@101101 ],102102 },103103 ],104+ [ProviderDriverKind.make("dsh")]: [105+ { id: "reasoningEffort", label: "Reasoning", type: "select", choices: EFFORT_CHOICES },106+ ],@@ -71,3 +71,12 @@7171 train, so the registry stays authoritative for them.7272 See the [resolver](../../apps/server/src/provider/providerMaintenance.ts).737374+## A provider without an approval primitive75+76+DeepSeek Harness runs tools in the workspace without asking the client, so no ACP77+`session/request_permission` handler is registered for it. An unhandled ACP request fails with78+"method not found", which fails closed rather than allowing silently, so the adapter stays correct if79+a future harness build starts asking. Because there is nothing to answer, its presentation hides the80+interaction-mode toggle and carries a badge instead of offering modes that cannot be enforced.81+See [the adapter](../../apps/server/src/provider/Layers/DshAdapter.ts).82+@@ -106,11 +106,12 @@106106 to that environment's machine, even when you connect from a phone or another107107 computer.108108109-| Provider | Install and authenticate |110-| ----------- | -------------------------------------------------------------------------------------------- |111-| Codex | Install [Codex CLI](https://developers.openai.com/codex/cli), then run `codex login`. |112-| Claude | Install [Claude Code](https://claude.com/product/claude-code), then run `claude auth login`. |113-| Cursor | Install [Cursor CLI](https://cursor.com/cli), then run `agent login`. |114-| Grok Build | Install [Grok Build CLI](https://x.ai/cli), then run `grok login`. |115-| OpenCode | Install [OpenCode](https://opencode.ai), then run `opencode auth login`. |116-| Antigravity | Install and sign in with Google from T3 Code's provider settings. |109+| Provider | Install and authenticate |110+| ---------------- | -------------------------------------------------------------------------------------------- |111+| Codex | Install [Codex CLI](https://developers.openai.com/codex/cli), then run `codex login`. |112+| Claude | Install [Claude Code](https://claude.com/product/claude-code), then run `claude auth login`. |113+| Cursor | Install [Cursor CLI](https://cursor.com/cli), then run `agent login`. |114+| Grok Build | Install [Grok Build CLI](https://x.ai/cli), then run `grok login`. |115+| OpenCode | Install [OpenCode](https://opencode.ai), then run `opencode auth login`. |116+| Antigravity | Install and sign in with Google from T3 Code's provider settings. |117+| DeepSeek Harness | Install `@deepseek-ai/dsh`, then store a DeepSeek API key. |
- @@ -103,4 +103,9 @@103103 const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean => {104104 const isAntigravity = provider.driver === ProviderDriverKind.make("antigravity");105105 const isCodex = provider.driver === ProviderDriverKind.make("codex");106- if (!isAntigravity && !isCodex && provider.driver !== ProviderDriverKind.make("opencode")) {106+ const isOpenCode = provider.driver === ProviderDriverKind.make("opencode");107+ // DeepSeek Harness advertises its whole catalog on every successful check, so a108+ // missing model is a retired one. Retaining them would also strand a model id109+ // from an older build, which is how one model ends up listed twice.110+ const isDsh = provider.driver === ProviderDriverKind.make("dsh");111+ if (!isAntigravity && !isCodex && !isOpenCode && !isDsh) {
- @@ -749,0 +808,21 @@808+ checkedAt: "2026-07-17T00:00:00.000Z",809+ version: "0.1.5",810+ models: [811+ {812+ slug: "deepseek-v4-flash",813+ name: "DeepSeek-V4-Flash",814+ isCustom: false,815+ capabilities: null,816+ },817+ {818+ slug: "deepseek-v4-pro",819+ name: "DeepSeek-V4-Pro",820+ isCustom: false,821+ capabilities: null,822+ },823+ ],824+ slashCommands: [],825+ skills: [],826+ } as const satisfies ServerProvider;827+ const degradedProvider = {828+ ...previousProvider,
- @@ -0,0 +9,21 @@9+ *10+ * Not covered here: interrupting a prompt in flight. The runtime's default11+ * cancel behaviour interrupts the prompt fiber rather than letting the harness12+ * answer a cancel, and the cases tried against the peer stalled the session13+ * instead of settling it. The settlement invariant that path depends on — one14+ * terminal event, no double settle — is pinned in `Layers/DshAdapter.test.ts`.15+ */16+import * as NodeServices from "@effect/platform-node/NodeServices";17+import { ProviderDriverKind, ProviderInstanceId, ThreadId } from "@t3tools/contracts";18+import { expect, it } from "@effect/vitest";19+import * as Effect from "effect/Effect";20+import * as Layer from "effect/Layer";21+import * as Ref from "effect/Ref";22+import * as Stream from "effect/Stream";23+24+import { makeDshAdapter } from "../src/provider/Layers/DshAdapter.ts";25+26+const PROVIDER: ProviderDriverKind = "dsh" as ProviderDriverKind;27+const INSTANCE = ProviderInstanceId.make("dsh");28+const PEER = new URL("./fixtures/dsh-acp-peer.mjs", import.meta.url).pathname;29+const SETTINGS = { enabled: true, binaryPath: PEER, homePath: "" };@@ -0,0 +147,21 @@147+ }),148+ httpClient: HttpClient.make(() => Effect.die("latest version is supplied")),149+ });150+151+ const advisory = publishedSnapshots.at(-1)?.versionAdvisory;152+ expect(advisory?.status).toBe("behind_latest");153+ expect(advisory?.canUpdate).toBe(true);154+ }),155+ );156+});157+158+describe("DeepSeek Harness live install resolution", () => {159+ it.effect("resolves the npm-owned install the environment actually has", () =>160+ Effect.gen(function* () {161+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(162+ makePackageManagedProviderMaintenanceResolver({163+ provider: "dsh" as never,164+ npmPackageName: "@deepseek-ai/dsh",165+ nativeUpdate: null,166+ }),167+ { binaryPath: "/tmp/dshnpm/bin/dsh", env: process.env },@@ -0,0 +271,21 @@271+ });272+ }273+274+ if (Option.isNone(versionResult.success)) {275+ return buildServerProvider({276+ presentation: DSH_PRESENTATION,277+ enabled: dshSettings.enabled,278+ checkedAt,279+ models: fallbackModels,280+ probe: {281+ installed: true,282+ version: null,283+ status: "error",284+ auth: { status: "unknown" },285+ message: "DeepSeek Harness is installed but timed out while running `dsh --version`.",286+ },287+ });288+ }289+290+ const versionOutput = versionResult.success.value;291+ const version = parseGenericCliVersion(`${versionOutput.stdout}\n${versionOutput.stderr}`);@@ -0,0 +330,21 @@330+ : "Timeout",331+ });332+ }333+334+ const discoveredModels = buildDshModelsFromSessionConfigOptions(configOptions);335+ const models = discoveredModels.length > 0 ? dshModels(discoveredModels) : fallbackModels;336+337+ return buildServerProvider({338+ presentation: DSH_PRESENTATION,339+ enabled: dshSettings.enabled,340+ checkedAt,341+ models,342+ // DSH mounts `dsh-command-compact` and runs `/compact` when the prompt is the343+ // command, but it never advertises `available_commands`, so the command is344+ // not discoverable from the protocol. T3 lists it explicitly.345+ slashCommands: [COMPACT_SLASH_COMMAND],346+ probe: {347+ installed: true,348+ version,349+ // A failed catalog probe degrades the model picker; it does not make chats fail.350+ status: discoveryFailed ? "warning" : "ready",
- @@ -0,0 +28,21 @@28+29+import { makeDshAdapter } from "../src/provider/Layers/DshAdapter.ts";30+31+const PROVIDER: ProviderDriverKind = "dsh" as ProviderDriverKind;32+const INSTANCE = ProviderInstanceId.make("dsh");33+const PEER_DIR = new URL("./fixtures/", import.meta.url).pathname;34+35+/**36+ * The adapter spawns a bare command. On macOS and Linux the repository's own37+ * fixture convention is a `#!/bin/sh` shim, which a shebang makes executable. On38+ * Windows a shebang is not honoured, so the running Node binary runs the peer's39+ * Node entry directly.40+ */41+/**42+ * The adapter spawns a bare command. On macOS and Linux the repository's own43+ * fixture convention is a `#!/bin/sh` shim, which a shebang makes executable. On44+ * Windows a shebang is not honoured, so the running Node binary runs the peer's45+ * Node entry directly.46+ */47+const makePeerCommand = (platform: string): string => {48+ if (platform === "win32") return process.execPath;
juliusmarminge closed this
Sign in to join this conversation.






macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed