forked from nexu-io/open-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeepseek-harness.ts
More file actions
80 lines (74 loc) · 2.59 KB
/
Copy pathdeepseek-harness.ts
File metadata and controls
80 lines (74 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { existsSync } from 'node:fs';
import { homedir } from 'node:os';
import path from 'node:path';
import { DEFAULT_MODEL_OPTION } from './shared.js';
import type { RuntimeAgentDef } from '../types.js';
import {
parseDshProfileModelsOutput,
parseDshProfileProbeOutput,
} from '../../agent-protocol/dsh-profile/index.js';
function parseModels(stdout: string) {
const catalog = parseDshProfileModelsOutput(stdout);
if (!catalog) return null;
return [
DEFAULT_MODEL_OPTION,
...catalog.map((model) => ({
id: `${model.provider}/${model.id}`,
label: `${model.name} · ${model.provider_name}`,
...(model.reasoning_options?.length
? {
reasoningOptions: model.reasoning_options.map((effort) => ({
id: effort.id,
label: effort.name,
...(effort.default === true ? { default: true } : {}),
})),
}
: {}),
})),
];
}
export function hasOpenDesignProfile(env: NodeJS.ProcessEnv): boolean {
return existsSync(path.join(resolveOpenDesignProfileDir(env), 'package.json'));
}
export function resolveOpenDesignProfileDir(env: NodeJS.ProcessEnv): string {
const configuredHome = env.DSH_HOME?.trim();
const dshHome = configuredHome
? path.resolve(configuredHome)
: path.join(homedir(), '.dsh');
return path.join(dshHome, 'profiles', 'open-design');
}
const DSH_VERSION_RE = /^v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/u;
export function parseDeepSeekHarnessVersion(raw: string): string | null {
return DSH_VERSION_RE.exec(raw.trim())?.[1] ?? null;
}
export const deepseekHarnessAgentDef = {
id: 'deepseek-harness',
name: 'DeepSeek Harness',
bin: 'dsh',
versionArgs: ['--version'],
versionPolicy: {
supportedVersions: ['0.1.0-rc.6'],
requireVersion: true,
parse: parseDeepSeekHarnessVersion,
},
compatibilityProbe: {
args: ['--profile', 'open-design', '--probe'],
timeoutMs: 10_000,
// rc.6 auto-initializes a missing profile before booting it, so avoid
// invoking --probe until the user-installed profile already exists.
preflight: hasOpenDesignProfile,
parse: (stdout) => parseDshProfileProbeOutput(stdout).plugin_version,
},
listModels: {
args: ['--profile', 'open-design', '--models'],
parse: parseModels,
timeoutMs: 10_000,
},
fallbackModels: [DEFAULT_MODEL_OPTION],
buildArgs: () => ['--profile', 'open-design', '--stdio'],
promptViaStdin: true,
streamFormat: 'dsh-profile-jsonl',
resumesSessionViaProfileStdio: true,
capturesSessionIdFromStream: true,
supportsCustomModel: false,
} satisfies RuntimeAgentDef;