@shuind/dsh-codex-harness 0.2.21 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +185 -0
- package/README.md +38 -50
- package/RELEASE.md +61 -0
- package/assets/codex.svg +5 -0
- package/cordis.patch.yml +181 -6
- package/docs/preset-library.md +33 -23
- package/docs/tool-policy-benchmark.json +310 -0
- package/docs/tool-policy.md +148 -0
- package/lib/client.js +4774 -2416
- package/lib/compact-command.js +416 -0
- package/lib/compaction.js +141 -12
- package/lib/hybrid-executor.js +1196 -0
- package/lib/index.js +3658 -2334
- package/lib/preferences.js +117 -0
- package/lib/tool-policy.js +2422 -0
- package/lib/typert.js +86 -79
- package/lib/types/client/activity.d.ts +33 -9
- package/lib/types/client/activity.js +4 -3
- package/lib/types/client/desktop.d.ts +67 -0
- package/lib/types/client/desktop.js +229 -0
- package/lib/types/client/index.d.ts +207 -110
- package/lib/types/client/index.js +99 -492
- package/lib/types/client/policy-drafts.d.ts +25 -0
- package/lib/types/client/policy-drafts.js +47 -0
- package/lib/types/client/policy-locale.d.ts +260 -0
- package/lib/types/client/policy-locale.js +357 -0
- package/lib/types/client/preset-manager.d.ts +38 -10
- package/lib/types/client/preset-manager.js +235 -185
- package/lib/types/client/preset-requests.d.ts +12 -0
- package/lib/types/client/preset-requests.js +101 -0
- package/lib/types/client/tool-policy.d.ts +33 -0
- package/lib/types/client/tool-policy.js +336 -0
- package/lib/types/contracts/preset-editor-schema.d.ts +78 -0
- package/lib/types/contracts/preset-editor-schema.js +95 -0
- package/lib/types/{prompt.js → contracts/prompt.js} +13 -7
- package/lib/types/{settings.d.ts → contracts/settings.d.ts} +11 -4
- package/lib/types/{settings.js → contracts/settings.js} +22 -6
- package/lib/types/contracts/tool-policy-contract.d.ts +63 -0
- package/lib/types/contracts/tool-policy-contract.js +33 -0
- package/lib/types/contracts/ui-contracts.d.ts +92 -0
- package/lib/types/contracts/ui-contracts.js +83 -0
- package/lib/types/entries/client.d.ts +10 -0
- package/lib/types/entries/client.js +10 -0
- package/lib/types/{compact-command.d.ts → entries/compact-command.d.ts} +2 -0
- package/lib/types/entries/compact-command.js +176 -0
- package/lib/types/{compaction.d.ts → entries/compaction.d.ts} +15 -3
- package/lib/types/{compaction.js → entries/compaction.js} +47 -11
- package/lib/types/entries/hybrid-executor.d.ts +19 -0
- package/lib/types/entries/hybrid-executor.js +57 -0
- package/lib/types/entries/index.d.ts +66 -0
- package/lib/types/entries/index.js +192 -0
- package/lib/types/entries/preferences.d.ts +11 -0
- package/lib/types/entries/preferences.js +16 -0
- package/lib/types/entries/tool-policy.d.ts +97 -0
- package/lib/types/entries/tool-policy.js +158 -0
- package/lib/types/entries/typert.host.d.ts +23 -0
- package/lib/types/entries/typert.host.js +24 -0
- package/lib/types/hybrid/codex-hybrid-executor.d.ts +44 -0
- package/lib/types/hybrid/codex-hybrid-executor.js +257 -0
- package/lib/types/hybrid/hybrid-sdk.d.ts +13 -0
- package/lib/types/hybrid/hybrid-sdk.js +196 -0
- package/lib/types/hybrid/program-calls.d.ts +28 -0
- package/lib/types/hybrid/program-calls.js +193 -0
- package/lib/types/hybrid/subcall-scheduler.d.ts +90 -0
- package/lib/types/hybrid/subcall-scheduler.js +343 -0
- package/lib/types/policy/deferred-tools.d.ts +42 -0
- package/lib/types/policy/deferred-tools.js +264 -0
- package/lib/types/policy/overlay-installer.d.ts +12 -0
- package/lib/types/policy/overlay-installer.js +179 -0
- package/lib/types/policy/rule-resolver.d.ts +94 -0
- package/lib/types/policy/rule-resolver.js +114 -0
- package/lib/types/policy/tool-capabilities.d.ts +33 -0
- package/lib/types/policy/tool-capabilities.js +46 -0
- package/lib/types/{activity.d.ts → presets/activity.d.ts} +3 -5
- package/lib/types/{activity.js → presets/activity.js} +51 -27
- package/lib/types/presets/desktop-preset.d.ts +22 -0
- package/lib/types/presets/desktop-preset.js +43 -0
- package/lib/types/presets/preset-editor.d.ts +47 -0
- package/lib/types/presets/preset-editor.js +81 -0
- package/lib/types/presets/preset-prompt-catalog.d.ts +23 -0
- package/lib/types/presets/preset-prompt-catalog.js +215 -0
- package/lib/types/presets/preset-tool-catalog.d.ts +5 -0
- package/lib/types/presets/preset-tool-catalog.js +58 -0
- package/lib/types/presets/runtime-enhancements.d.ts +45 -0
- package/lib/types/presets/runtime-enhancements.js +349 -0
- package/lib/types/presets/small-window-compaction.d.ts +15 -0
- package/lib/types/presets/small-window-compaction.js +121 -0
- package/lib/types/responses/compact-checkpoint.d.ts +27 -0
- package/lib/types/responses/compact-checkpoint.js +257 -0
- package/lib/types/responses/fetch-transport.d.ts +16 -0
- package/lib/types/responses/fetch-transport.js +257 -0
- package/lib/types/responses/remote-compact.d.ts +13 -0
- package/lib/types/responses/remote-compact.js +319 -0
- package/lib/types/responses/sse-diagnostics.d.ts +9 -0
- package/lib/types/responses/sse-diagnostics.js +157 -0
- package/lib/types/responses/wire-rewrite.d.ts +35 -0
- package/lib/types/responses/wire-rewrite.js +237 -0
- package/lib/types/tools/exec-output.d.ts +58 -0
- package/lib/types/tools/exec-output.js +173 -0
- package/lib/types/tools/exec-plan-tools.d.ts +37 -0
- package/lib/types/tools/exec-plan-tools.js +265 -0
- package/lib/types/tools/exec-runner.d.ts +21 -0
- package/lib/types/tools/exec-runner.js +385 -0
- package/lib/types/tools/patch-tool.d.ts +16 -0
- package/lib/types/tools/patch-tool.js +258 -0
- package/lib/types/{patch.d.ts → tools/patch.d.ts} +1 -1
- package/lib/types/{patch.js → tools/patch.js} +96 -21
- package/locale/en.json +6 -0
- package/locale/hybrid-executor/en.json +6 -0
- package/locale/hybrid-executor/zh.json +6 -0
- package/locale/tool-policy/en.json +6 -0
- package/locale/tool-policy/zh.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +297 -299
- package/presets/{codex-collaboration → codex-hybrid}/agent.cordis.yml +45 -48
- package/presets/codex-hybrid/preset.yml +3 -0
- package/scripts/benchmark-tool-policy.mjs +186 -0
- package/scripts/build-preset.mjs +19 -0
- package/scripts/clean-build.mjs +11 -0
- package/src/client/activity.ts +83 -0
- package/src/client/desktop.tsx +276 -0
- package/src/client/index.tsx +391 -0
- package/src/client/policy-drafts.ts +56 -0
- package/src/client/policy-locale.ts +362 -0
- package/src/client/preset-manager.tsx +376 -0
- package/src/client/preset-requests.ts +113 -0
- package/src/client/tool-policy.tsx +402 -0
- package/src/contracts/preset-editor-schema.ts +110 -0
- package/src/contracts/prompt.ts +66 -0
- package/src/contracts/settings.ts +103 -0
- package/src/contracts/tool-policy-contract.ts +93 -0
- package/src/contracts/ui-contracts.ts +173 -0
- package/src/entries/client.tsx +14 -0
- package/src/entries/compact-command.ts +256 -0
- package/src/entries/compaction.ts +218 -0
- package/src/entries/hybrid-executor.ts +76 -0
- package/src/entries/index.ts +298 -0
- package/src/entries/preferences.ts +17 -0
- package/src/entries/tool-policy.ts +162 -0
- package/src/entries/typert.host.ts +29 -0
- package/src/hybrid/codex-hybrid-executor.ts +310 -0
- package/src/hybrid/hybrid-sdk.ts +217 -0
- package/src/hybrid/program-calls.ts +202 -0
- package/src/hybrid/subcall-scheduler.ts +446 -0
- package/src/policy/deferred-tools.ts +331 -0
- package/src/policy/overlay-installer.ts +191 -0
- package/src/policy/rule-resolver.ts +128 -0
- package/src/policy/tool-capabilities.ts +88 -0
- package/src/presets/activity.ts +146 -0
- package/src/presets/desktop-preset.ts +60 -0
- package/src/presets/preset-editor.ts +101 -0
- package/src/presets/preset-prompt-catalog.ts +221 -0
- package/src/presets/preset-tool-catalog.ts +58 -0
- package/src/presets/runtime-enhancements.ts +415 -0
- package/src/presets/small-window-compaction.ts +166 -0
- package/src/responses/compact-checkpoint.ts +264 -0
- package/src/responses/fetch-transport.ts +290 -0
- package/src/responses/remote-compact.ts +393 -0
- package/src/responses/sse-diagnostics.ts +156 -0
- package/src/responses/wire-rewrite.ts +261 -0
- package/src/tools/exec-output.ts +211 -0
- package/src/tools/exec-plan-tools.ts +307 -0
- package/src/tools/exec-runner.ts +445 -0
- package/src/tools/patch-tool.ts +331 -0
- package/src/tools/patch.ts +328 -0
- package/tsconfig.json +29 -0
- package/tsdown.config.ts +110 -0
- package/lib/installer.js +0 -237
- package/lib/invariant.js +0 -23
- package/lib/types/activity-types.d.ts +0 -6
- package/lib/types/activity-types.js +0 -3
- package/lib/types/client/preset-copy.d.ts +0 -42
- package/lib/types/client/preset-copy.js +0 -81
- package/lib/types/compact-command.js +0 -79
- package/lib/types/context.d.ts +0 -8
- package/lib/types/context.js +0 -14
- package/lib/types/exec.d.ts +0 -46
- package/lib/types/exec.js +0 -365
- package/lib/types/index.d.ts +0 -95
- package/lib/types/index.js +0 -738
- package/lib/types/installer.d.ts +0 -27
- package/lib/types/installer.js +0 -146
- package/lib/types/invariant.d.ts +0 -16
- package/lib/types/invariant.js +0 -22
- package/lib/types/preset-contract.d.ts +0 -69
- package/lib/types/preset-contract.js +0 -22
- package/lib/types/preset-editor-remote.d.ts +0 -30
- package/lib/types/preset-editor-remote.js +0 -37
- package/lib/types/preset-editor.d.ts +0 -69
- package/lib/types/preset-editor.js +0 -557
- package/lib/types/preset-templates.d.ts +0 -36
- package/lib/types/preset-templates.js +0 -12
- package/lib/types/prompt-sections.d.ts +0 -15
- package/lib/types/prompt-sections.js +0 -23
- package/lib/types/remote.d.ts +0 -40
- package/lib/types/remote.js +0 -683
- package/lib/types/typert.host.d.ts +0 -47
- package/lib/types/typert.host.js +0 -99
- package/presets/codex-collaboration/preset.yml +0 -3
- /package/lib/types/{prompt.d.ts → contracts/prompt.d.ts} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import z from "@deepseek-ai/schemastery";
|
|
3
|
+
//#region lib/types/contracts/ui-contracts.js
|
|
4
|
+
const CODEX_CONTEXT_MAX = 1e6;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region lib/types/contracts/prompt.js
|
|
7
|
+
/** Default plugin-owned Codex operating prompt. */
|
|
8
|
+
const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
|
|
9
|
+
|
|
10
|
+
- Follow the current tool catalog, not assumptions from another Codex client. For unknown paths, use the available list/search tools instead of guessing and reuse the returned paths. If only shell search is available, prefer rg or rg --files.
|
|
11
|
+
|
|
12
|
+
## Editing constraints
|
|
13
|
+
|
|
14
|
+
- Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
|
|
15
|
+
- Prefer apply_patch (or dedicated file tools when present) over shell heredocs or redirection for file edits; do not re-read a file immediately after apply_patch succeeds unless checking external changes.
|
|
16
|
+
- Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
|
|
17
|
+
- You may be in a dirty git worktree. Never revert existing changes you did not make unless the user explicitly requests it, never amend commits unless asked, and avoid interactive git commands such as git rebase -i or git add -p. If unrelated files are changed, leave them alone.
|
|
18
|
+
|
|
19
|
+
## Planning
|
|
20
|
+
|
|
21
|
+
- Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
|
|
22
|
+
- Do not use a plan for a trivial one-step request.
|
|
23
|
+
|
|
24
|
+
## dsh session
|
|
25
|
+
|
|
26
|
+
- The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
|
|
27
|
+
- For Harness APIs, first load the relevant Harness skill. When Inspect tools are available, start with cordis_inspect_list, then query the provider's directory before an exact Service contract. Reuse returned names; Inspect is read-only.
|
|
28
|
+
- A not-found path or unknown Service is a discovery error: check the file list or Service directory before retrying. Preserve actual failures; do not hide them or bypass permission denials.
|
|
29
|
+
|
|
30
|
+
## Task execution
|
|
31
|
+
|
|
32
|
+
- Parallelize independent read, search, and check calls. Do not sleep-poll background jobs or subagents; they wake on completion.
|
|
33
|
+
- When delegating parallel edits, assign disjoint write scopes. Record key paths and facts as you go since older large tool outputs may be pruned.
|
|
34
|
+
- Never claim unrun checks passed, and keep the user informed with concise progress updates.
|
|
35
|
+
|
|
36
|
+
## Presenting your work
|
|
37
|
+
|
|
38
|
+
- Be concise, direct, friendly, and actionable, and lead with the result.
|
|
39
|
+
- For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
|
|
40
|
+
- For code reviews, lead with concrete findings ordered by severity with file and line references before any brief summary, or state explicitly if no issues were found.
|
|
41
|
+
- Do not dump large files into the conversation; refer to their paths.
|
|
42
|
+
- Use plain text with short sections only when they improve scanability.
|
|
43
|
+
|
|
44
|
+
## Working principles
|
|
45
|
+
|
|
46
|
+
- Actively establish the user's current context from the repository rather than relying on stale assumptions. Execute tasks directly through implementation and verification using the clearest, most effective path; ask the user only when a user-owned choice or external/destructive action cannot be resolved by inspection.
|
|
47
|
+
- Keep only the essential logic and core actions. Don't explain or test what was removed or why something wasn't done, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
|
|
48
|
+
- Solve problems by thinking from first principles and at a higher level.
|
|
49
|
+
`;
|
|
50
|
+
/** Default deployment Persona template used by the Codex preset. */
|
|
51
|
+
const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model.`;
|
|
52
|
+
/** Default DSH Core source-checkout guidance template. */
|
|
53
|
+
const DEFAULT_DSH_CORE_SOURCE_PROMPT = String.raw`The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself. If the supplied path is inside app.asar, treat it as a packaged runtime rather than a source checkout. Discover the installed packageDir via Inspect and read its README and package.json exports; do not assume src or individual lib/types filenames exist. Use Host file-read tools for app.asar; native shell search and glob cannot traverse it.`;
|
|
54
|
+
/** Default DSH Web runtime guidance template. */
|
|
55
|
+
const DEFAULT_DSH_CORE_WEB_PROMPT = [
|
|
56
|
+
"You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
|
|
57
|
+
"When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
|
|
58
|
+
"The browser provides no implicit DOM, route, or screenshot context.",
|
|
59
|
+
"The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates.",
|
|
60
|
+
"Every other change - the apps/web shell and plain packages - requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh.",
|
|
61
|
+
"Starting another server does not update this GUI.",
|
|
62
|
+
"The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
|
|
63
|
+
"Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
|
|
64
|
+
].join(" ");
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region lib/types/contracts/settings.js
|
|
67
|
+
/** Shared host-side Codex settings contract, Host reader, and GPT route matcher. */
|
|
68
|
+
/** Default settings exposed even before a Codex session is opened. */
|
|
69
|
+
const CODEX_SETTINGS_ENTRY = {
|
|
70
|
+
fast: false,
|
|
71
|
+
fastModeControlEnabled: true,
|
|
72
|
+
contextWindowControlEnabled: true,
|
|
73
|
+
persona: DEFAULT_CODEX_PERSONA,
|
|
74
|
+
harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
75
|
+
webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
|
|
76
|
+
systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT,
|
|
77
|
+
promptEnabled: true,
|
|
78
|
+
terminalToolsEnabled: true,
|
|
79
|
+
patchToolEnabled: true,
|
|
80
|
+
planToolEnabled: true,
|
|
81
|
+
hostedWebSearchEnabled: true,
|
|
82
|
+
remoteCompactionEnabled: true,
|
|
83
|
+
activityIndicatorEnabled: true
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region lib/types/entries/preferences.js
|
|
87
|
+
/** Profile-backed live preferences on DSH 0.2; legacy hosts keep settings.yaml. */
|
|
88
|
+
const Config = z.object({
|
|
89
|
+
fast: z.boolean().default(false),
|
|
90
|
+
fastModeControlEnabled: z.boolean().default(true),
|
|
91
|
+
contextWindowControlEnabled: z.boolean().default(true),
|
|
92
|
+
contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX).hidden(),
|
|
93
|
+
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
94
|
+
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
95
|
+
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
96
|
+
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
97
|
+
promptEnabled: z.boolean().default(true),
|
|
98
|
+
terminalToolsEnabled: z.boolean().default(true).hidden(),
|
|
99
|
+
patchToolEnabled: z.boolean().default(true).hidden(),
|
|
100
|
+
planToolEnabled: z.boolean().default(true).hidden(),
|
|
101
|
+
hostedWebSearchEnabled: z.boolean().default(true),
|
|
102
|
+
remoteCompactionEnabled: z.boolean().default(true),
|
|
103
|
+
activityIndicatorEnabled: z.boolean().default(true)
|
|
104
|
+
}).default(CODEX_SETTINGS_ENTRY).volatile();
|
|
105
|
+
var CodexPreferences = class extends Service {
|
|
106
|
+
value;
|
|
107
|
+
static Config = Config;
|
|
108
|
+
constructor(ctx, value) {
|
|
109
|
+
super(ctx, "codexPreferences");
|
|
110
|
+
this.value = value;
|
|
111
|
+
}
|
|
112
|
+
current() {
|
|
113
|
+
return this.value.get() ?? CODEX_SETTINGS_ENTRY;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { Config, CodexPreferences as default };
|