@deepseek-harness-tui/dsh-tui 0.7.1 → 0.7.2
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/README.md +6 -4
- package/bin/dsh-tui.js +37 -1
- package/cordis.patch.yml +10 -0
- package/lib/types/commands.js +1 -1
- package/lib/types/components/LoadedContextPanel.d.ts.map +1 -1
- package/lib/types/components/LoadedContextPanel.js +1 -1
- package/lib/types/components/design-system/ThemedText.d.ts +2 -2
- package/lib/types/components/design-system/ThemedText.d.ts.map +1 -1
- package/lib/types/components/design-system/ThemedText.js +1 -3
- package/lib/types/components/sessions/SessionListRow.d.ts +26 -0
- package/lib/types/components/sessions/SessionListRow.d.ts.map +1 -0
- package/lib/types/components/sessions/SessionListRow.js +35 -0
- package/lib/types/components/sessions/SessionPreview.d.ts +25 -0
- package/lib/types/components/sessions/SessionPreview.d.ts.map +1 -0
- package/lib/types/components/sessions/SessionPreview.js +60 -0
- package/lib/types/dsh-adapter/channel.d.ts +9 -4
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +31 -73
- package/lib/types/dsh-adapter/compat/index.d.ts +1 -1
- package/lib/types/dsh-adapter/compat/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/compat/index.js +1 -1
- package/lib/types/dsh-adapter/compat/sessionLog.d.ts +8 -0
- package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
- package/lib/types/dsh-adapter/compat/sessionLog.js +1 -1
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +10 -1
- package/lib/types/dsh-adapter/packaged-presets.d.ts +22 -0
- package/lib/types/dsh-adapter/packaged-presets.d.ts.map +1 -0
- package/lib/types/dsh-adapter/packaged-presets.js +90 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +46 -4
- package/lib/types/dsh-adapter/presets.d.ts +16 -0
- package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
- package/lib/types/dsh-adapter/presets.js +23 -0
- package/lib/types/dsh-adapter/sessions/digest.d.ts +29 -0
- package/lib/types/dsh-adapter/sessions/digest.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/digest.js +224 -0
- package/lib/types/dsh-adapter/sessions/frames.d.ts +100 -0
- package/lib/types/dsh-adapter/sessions/frames.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/frames.js +246 -0
- package/lib/types/dsh-adapter/sessions/header.d.ts +50 -0
- package/lib/types/dsh-adapter/sessions/header.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/header.js +62 -0
- package/lib/types/dsh-adapter/sessions/index.d.ts +17 -0
- package/lib/types/dsh-adapter/sessions/index.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/index.js +15 -0
- package/lib/types/dsh-adapter/sessions/list.d.ts +41 -0
- package/lib/types/dsh-adapter/sessions/list.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/list.js +213 -0
- package/lib/types/dsh-adapter/sessions/store.d.ts +48 -0
- package/lib/types/dsh-adapter/sessions/store.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/store.js +164 -0
- package/lib/types/dsh-adapter/sessions/types.d.ts +142 -0
- package/lib/types/dsh-adapter/sessions/types.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/types.js +14 -0
- package/lib/types/i18n.d.ts +118 -14
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +36 -6
- package/lib/types/screens/Chat.d.ts +3 -2
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +28 -144
- package/lib/types/screens/SessionBrowser.d.ts +37 -0
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -0
- package/lib/types/screens/SessionBrowser.js +437 -0
- package/lib/types/sessionHistory.d.ts +0 -8
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessions/format.d.ts +117 -0
- package/lib/types/sessions/format.d.ts.map +1 -0
- package/lib/types/sessions/format.js +244 -0
- package/lib/types/sessions/view.d.ts +125 -0
- package/lib/types/sessions/view.d.ts.map +1 -0
- package/lib/types/sessions/view.js +222 -0
- package/package.json +6 -2
- package/presets/liangshen/.dsh-tui-managed.json +5 -0
- package/presets/liangshen/agent.cordis.yml +389 -0
- package/presets/liangshen/compaction-epoch.mjs +81 -0
- package/presets/liangshen/custom-bash.mjs +126 -0
- package/presets/liangshen/instruction-hint.mjs +181 -0
- package/presets/liangshen/preset.yml +3 -0
- package/presets/liangshen/skill-search.mjs +142 -0
- package/presets/liangshen/tool-bootstrap.mjs +300 -0
- package/lib/types/components/ResumePicker.d.ts +0 -26
- package/lib/types/components/ResumePicker.d.ts.map +0 -1
- package/lib/types/components/ResumePicker.js +0 -50
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# The `anchored-standard` experimental preset: Standard capabilities with the
|
|
2
|
+
# Minimal mode system-prompt condition used by the V4 trajectory evaluation.
|
|
3
|
+
#
|
|
4
|
+
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
|
|
5
|
+
# standing scope; every session naming it joins by scope parentage, so the
|
|
6
|
+
# tools and prompt sections registered here cover each joined agent while a
|
|
7
|
+
# session's own state stays keyed per Session/Agent inside the plugins. The
|
|
8
|
+
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
|
|
9
|
+
# preset must not own: the registries themselves, the sandbox and approval
|
|
10
|
+
# stack, persistence, and the model route.
|
|
11
|
+
#
|
|
12
|
+
# A service row here MUST sit inside a group carrying an `isolate` realm.
|
|
13
|
+
# Without one it publishes into the root realm, where it is process-global —
|
|
14
|
+
# another preset publishing the same name collides, and a host reader would
|
|
15
|
+
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
|
|
16
|
+
# that at mount. `true` means an entry-local realm: this standing mount's own
|
|
17
|
+
# private instance, apart from every other preset's. (A shared label does NOT
|
|
18
|
+
# pool instances — `provide()` throws on the second registration under the
|
|
19
|
+
# same realm symbol; labels join REALMS, and are not what this file needs.)
|
|
20
|
+
|
|
21
|
+
# ── bootstrap (must stay FIRST) ─────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
# This row deliberately sits before every other row: dsh-agent-instructions and
|
|
24
|
+
# dsh-tool-skill inject workspace instructions and the skill catalog into the
|
|
25
|
+
# first request via the agent/pre-step waterfall, and waterfall after-next
|
|
26
|
+
# transforms apply in reverse registration order. Registering first (plus the
|
|
27
|
+
# plugin empty inject list and the listener's `prepend` flag) makes this filter
|
|
28
|
+
# strip the final transform, so request #1 stays Minimal-exact (see issue #6).
|
|
29
|
+
#
|
|
30
|
+
# V4 Pro conditions strongly on the API tool catalog AND the first request
|
|
31
|
+
# output budget. Bootstrap request #1 with the OFFICIAL Minimal preset's real
|
|
32
|
+
# tool pair — persistent `bash` + `str_replace_editor` — which anchors at the
|
|
33
|
+
# adapter-default maxTokens (256000) with no output cap needed (issue #11:
|
|
34
|
+
# 5/5 anchored vs 11/11 standard-like for every standard-family schema);
|
|
35
|
+
# after the session records its first durable tool call, later steps expose
|
|
36
|
+
# the complete assembled catalog in one promotion. A text-only reply does not
|
|
37
|
+
# consume the anchor. `bootstrapMaxTokens` is
|
|
38
|
+
# opt-in for standard-schema bootstraps; unset, the adapter default flows. See
|
|
39
|
+
# tool-bootstrap.mjs for the other triggers.
|
|
40
|
+
#
|
|
41
|
+
# The same phase gate suppresses AUTO-INJECTED context on request #1:
|
|
42
|
+
# `suppressedContextSources` lists the `agent/pre-step` message sources the
|
|
43
|
+
# bootstrap filter strips while the session is unpromoted. The defaults are the
|
|
44
|
+
# two automatic injections Standard adds over Minimal — the available-skills
|
|
45
|
+
# reminder (`skill-catalog`) and the workspace instruction digest
|
|
46
|
+
# (`agent-instructions`). User-initiated skill gestures are not filtered, and
|
|
47
|
+
# both injections return unchanged after the first tool-call promotion. Set
|
|
48
|
+
# the list to [] to disable the context filter while keeping the tool bootstrap.
|
|
49
|
+
#
|
|
50
|
+
# POST-PROMOTION: the first durable tool call unlocks the complete assembled
|
|
51
|
+
# catalog at once, matching the two-stage harness experiment. There is no
|
|
52
|
+
# intermediate resident/discovery phase.
|
|
53
|
+
#
|
|
54
|
+
# COMPACTION: after `compaction/end` the session falls back to the exact
|
|
55
|
+
# bootstrap pair until a NEW durable tool call exists past the boundary
|
|
56
|
+
# (epoch-aware, see compaction-epoch.mjs).
|
|
57
|
+
- id: tool-bootstrap
|
|
58
|
+
name: ./tool-bootstrap.mjs
|
|
59
|
+
config:
|
|
60
|
+
bootstrapTools: [bash, str_replace_editor]
|
|
61
|
+
promoteOn: tool-call
|
|
62
|
+
includeSubagents: true
|
|
63
|
+
suppressedContextSources: [agent-instructions, skill-catalog]
|
|
64
|
+
|
|
65
|
+
# ── identity ────────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
# Keep this text byte-identical to the Minimal preset. `complete` prevents the
|
|
68
|
+
# Harness identity and per-tool guidance from changing the system prompt, while
|
|
69
|
+
# runtime-context suppression leaves task and repository rules to user messages
|
|
70
|
+
# and explicit file reads. Tool schemas and their runtime enforcement remain.
|
|
71
|
+
- id: persona
|
|
72
|
+
name: '@deepseek-ai/dsh-persona'
|
|
73
|
+
config:
|
|
74
|
+
text: You are a helpful software engineer assistant.
|
|
75
|
+
complete: true
|
|
76
|
+
includeRuntimeContext: false
|
|
77
|
+
|
|
78
|
+
# Instruction FILES are NOT injected (replaces dsh-agent-instructions, local
|
|
79
|
+
# addition): the full AGENTS.md/CLAUDE.md digest is a large injected block
|
|
80
|
+
# that perturbs the trajectory even after promotion. Instead, after promotion
|
|
81
|
+
# ONE short hint is injected once per session — "these instruction files
|
|
82
|
+
# exist; read them before acting" — and the model reads the files itself via
|
|
83
|
+
# the filesystem tools when relevant.
|
|
84
|
+
- id: instruction-hint
|
|
85
|
+
name: ./instruction-hint.mjs
|
|
86
|
+
config:
|
|
87
|
+
promoteOn: tool-call
|
|
88
|
+
includeSubagents: true
|
|
89
|
+
|
|
90
|
+
# ── shell ───────────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
# `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
|
|
93
|
+
# publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
|
|
94
|
+
# the criterion for host-plane ownership — injection resolves before any session
|
|
95
|
+
# exists, so there is no agent to key by. Behind a preset realm those variables
|
|
96
|
+
# never reached the model's shell at all. Both shell tools consume the host
|
|
97
|
+
# registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
|
|
98
|
+
# host-plane too.
|
|
99
|
+
- id: tool-bash
|
|
100
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
101
|
+
# Disabled on EVERY platform, not just Windows: `dsh-tool-bash-persistent`
|
|
102
|
+
# below registers the same `bash` tool name into this same preset layer, and
|
|
103
|
+
# the tools registry rejects duplicates within one layer. The persistent
|
|
104
|
+
# shell (the Minimal preset's own shell) is the preset's bash; it consumes
|
|
105
|
+
# the host sandbox policy through the terminals realm.
|
|
106
|
+
disabled: true
|
|
107
|
+
|
|
108
|
+
- id: tool-pwsh
|
|
109
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
110
|
+
disabled: !!js process.platform !== 'win32'
|
|
111
|
+
|
|
112
|
+
# The Minimal preset's shell: a PTY-backed persistent bash, byte-identical in
|
|
113
|
+
# configuration to the official `minimal` preset's `persistent-shell` group so
|
|
114
|
+
# the first request exposes exactly Minimal's real `bash` schema. The PTY
|
|
115
|
+
# registry is an agent-owned service, so it lives in an entry-local realm; the
|
|
116
|
+
# backend still consumes the host sandbox policy and subprocess implementation,
|
|
117
|
+
# while the tool registers into this agent's scoped catalog.
|
|
118
|
+
#
|
|
119
|
+
# DISABLED ON WINDOWS: DSH's PTY backend is linux/darwin-only, so the
|
|
120
|
+
# persistent shell cannot serve win32. The `custom-bash` row below registers
|
|
121
|
+
# the same `bash` tool name there instead (platform-exclusive).
|
|
122
|
+
- id: persistent-shell
|
|
123
|
+
name: cordis:group
|
|
124
|
+
group: true
|
|
125
|
+
disabled: !!js process.platform === 'win32'
|
|
126
|
+
isolate:
|
|
127
|
+
terminals: true
|
|
128
|
+
config:
|
|
129
|
+
- id: pty
|
|
130
|
+
name: '@deepseek-ai/dsh-terminal'
|
|
131
|
+
|
|
132
|
+
- id: terminal-bash
|
|
133
|
+
name: '@deepseek-ai/dsh-terminal-bash'
|
|
134
|
+
config:
|
|
135
|
+
timeoutMs: 300000
|
|
136
|
+
|
|
137
|
+
- id: persistent-bash
|
|
138
|
+
name: '@deepseek-ai/dsh-tool-bash-persistent'
|
|
139
|
+
config:
|
|
140
|
+
timeoutMs: 300000
|
|
141
|
+
description: |-
|
|
142
|
+
Run commands in a bash shell
|
|
143
|
+
* When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.
|
|
144
|
+
* You don't have access to the internet via this tool.
|
|
145
|
+
* You do have access to a mirror of common linux and python packages via apt and pip.
|
|
146
|
+
* State is persistent across command calls and discussions with the user.
|
|
147
|
+
* To inspect a particular line range of a file, e.g. lines 10-25, try 'sed -n 10,25p /path/to/the/file'.
|
|
148
|
+
* Please avoid commands that may produce a very large amount of output.
|
|
149
|
+
* Please run long lived commands in the background, e.g. 'sleep 10 &' or start a server in the background.
|
|
150
|
+
|
|
151
|
+
# Windows-only `bash` tool (see custom-bash.mjs): registers the SAME
|
|
152
|
+
# tool name as the persistent shell with a Minimal-compatible description, but
|
|
153
|
+
# executes through the ordinary cross-platform subprocess seam (`bash -c`)
|
|
154
|
+
# instead of a PTY. `bashPath` defaults to `bash` on PATH; point it at Git
|
|
155
|
+
# Bash explicitly when the WSL shim would otherwise be picked up. No OS
|
|
156
|
+
# sandbox confinement on Windows (landlock is linux-only); the tool
|
|
157
|
+
# description says so.
|
|
158
|
+
- id: custom-bash
|
|
159
|
+
name: ./custom-bash.mjs
|
|
160
|
+
disabled: !!js process.platform !== 'win32'
|
|
161
|
+
config:
|
|
162
|
+
bashPath: 'C:\Program Files\Git\bin\bash.exe'
|
|
163
|
+
|
|
164
|
+
# ── filesystem ──────────────────────────────────────────────────────────────
|
|
165
|
+
|
|
166
|
+
# Both register into the host `tools` registry and provide nothing, so
|
|
167
|
+
# they need no realm. The `fs` service and its policy stay in the host.
|
|
168
|
+
- id: tool-fs
|
|
169
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
170
|
+
|
|
171
|
+
- id: tool-fs-search
|
|
172
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
173
|
+
config:
|
|
174
|
+
sampleOverCapGlobResults: false
|
|
175
|
+
|
|
176
|
+
# The Minimal preset's second tool: `str_replace_editor` over a bare local
|
|
177
|
+
# filesystem, byte-identical in configuration to the official `minimal`
|
|
178
|
+
# preset's `filesystem` group. The editor's own realm shadows the host's
|
|
179
|
+
# sandboxed `fs` provider only inside this group, so the standard `read`/
|
|
180
|
+
# `write`/`edit` tools keep the sandboxed fs while the bootstrap editor uses
|
|
181
|
+
# the local one.
|
|
182
|
+
- id: bootstrap-filesystem
|
|
183
|
+
name: cordis:group
|
|
184
|
+
group: true
|
|
185
|
+
isolate:
|
|
186
|
+
fs: true
|
|
187
|
+
config:
|
|
188
|
+
- id: fs-local
|
|
189
|
+
name: '@deepseek-ai/dsh-fs-local'
|
|
190
|
+
config:
|
|
191
|
+
cwd: !!js process.env.DSH_CWD ?? process.cwd()
|
|
192
|
+
|
|
193
|
+
- id: str-replace-editor
|
|
194
|
+
name: '@deepseek-ai/dsh-tool-str-replace-editor'
|
|
195
|
+
config:
|
|
196
|
+
maxOutputChars: 16000
|
|
197
|
+
|
|
198
|
+
# ── background jobs ────────────────────────────────────────────────────────
|
|
199
|
+
|
|
200
|
+
# Only the model-facing controls. The task REGISTRY stays on the host plane:
|
|
201
|
+
# its producers sit outside any realm this file could put it in — `tool-bash`
|
|
202
|
+
# above resolves it with `ctx.get`, and an entry-local realm here is invisible
|
|
203
|
+
# to every sibling row, so `run_in_background` would answer "background jobs
|
|
204
|
+
# unavailable" while these controls sat in the catalog. The registry is keyed by
|
|
205
|
+
# owning agent anyway, so one host instance serves every session. What a preset
|
|
206
|
+
# chooses is whether its agent can collect and stop background work at all.
|
|
207
|
+
- id: tool-jobs
|
|
208
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
209
|
+
|
|
210
|
+
# ── skills ──────────────────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
# The skill REGISTRY lives in the host composition and is layered per scope:
|
|
213
|
+
# these rows register into THIS preset's layer of it, so they need no realm.
|
|
214
|
+
# `skill-filesystem` contributes local-root discovery for agents on this
|
|
215
|
+
# preset. The full skill CATALOG injection (`dsh-tool-skill`, the ~9KB
|
|
216
|
+
# `<available_skills>` reminder) is REMOVED (local addition): it perturbs the
|
|
217
|
+
# trajectory (issue #6: 0/9 anchored with the catalog present vs ~81%
|
|
218
|
+
# without). Instead `skill-search` exposes two small on-demand tools —
|
|
219
|
+
# skill_search (list matching summaries) and skill_load (inject one skill's
|
|
220
|
+
# full instructions) — the tool-search pattern.
|
|
221
|
+
- id: skill-filesystem
|
|
222
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
223
|
+
|
|
224
|
+
- id: skill-search
|
|
225
|
+
name: ./skill-search.mjs
|
|
226
|
+
|
|
227
|
+
# ── goals ───────────────────────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
# Only the model-facing tool. The goal SERVICE, its session driver, and the
|
|
230
|
+
# `/goal` command stay on the host plane: the Gateway serves the goal domain as
|
|
231
|
+
# Remote endpoints whose receiver comes from a generated descriptor, so it
|
|
232
|
+
# resolves `goals` on the host and an entry-local realm here would hide it. The
|
|
233
|
+
# registry is keyed by session anyway, so one host instance serves every
|
|
234
|
+
# session. What a preset chooses is whether its agent can call the goal tool.
|
|
235
|
+
- id: tool-goal
|
|
236
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
237
|
+
|
|
238
|
+
# ── plan mode ───────────────────────────────────────────────────────────────
|
|
239
|
+
|
|
240
|
+
# Plan state is per-agent by nature, so an entry-local realm is not a
|
|
241
|
+
# workaround here — it is the correct lifetime.
|
|
242
|
+
- id: planning
|
|
243
|
+
name: cordis:group
|
|
244
|
+
group: true
|
|
245
|
+
isolate:
|
|
246
|
+
planMode: true
|
|
247
|
+
config:
|
|
248
|
+
- id: plan-mode
|
|
249
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
250
|
+
config:
|
|
251
|
+
section: |
|
|
252
|
+
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
253
|
+
|
|
254
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
255
|
+
|
|
256
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
257
|
+
|
|
258
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
259
|
+
|
|
260
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
261
|
+
|
|
262
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
263
|
+
|
|
264
|
+
# ── compaction ──────────────────────────────────────────────────────────────
|
|
265
|
+
|
|
266
|
+
# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
|
|
267
|
+
# share this realm rather than sit outside it.
|
|
268
|
+
#
|
|
269
|
+
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
|
|
270
|
+
# plane, and the rows here resolve that one instance. It takes no configuration,
|
|
271
|
+
# keys every fold by Session, and owns the context-meter projection units the
|
|
272
|
+
# browser reads for every session — behind a realm those units would come and go
|
|
273
|
+
# with whichever presets happen to be mounted. What a preset chooses is whether
|
|
274
|
+
# its agent compacts at all, which is `compaction-basic` below.
|
|
275
|
+
- id: compaction
|
|
276
|
+
name: cordis:group
|
|
277
|
+
group: true
|
|
278
|
+
isolate:
|
|
279
|
+
compaction: true
|
|
280
|
+
toolResultPruner: true
|
|
281
|
+
config:
|
|
282
|
+
- id: compaction-basic
|
|
283
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
284
|
+
|
|
285
|
+
- id: command-compact
|
|
286
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
287
|
+
|
|
288
|
+
- id: tool-result-pruner
|
|
289
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
290
|
+
config:
|
|
291
|
+
thresholdChars: 8192
|
|
292
|
+
headChars: 4096
|
|
293
|
+
tailChars: 1024
|
|
294
|
+
|
|
295
|
+
# ── delegation and workflows ────────────────────────────────────────────────
|
|
296
|
+
|
|
297
|
+
# The `subagents` registry and its spawn/fork backends live in the HOST
|
|
298
|
+
# composition: the registry is a process singleton whose cross-session queries
|
|
299
|
+
# the api-proxy serves to the browser, and a provider name may only be
|
|
300
|
+
# registered once. This preset contributes the delegation TOOLS, which resolve
|
|
301
|
+
# that host registry.
|
|
302
|
+
#
|
|
303
|
+
# `workflows` is different — nothing outside an agent reads it — so every row
|
|
304
|
+
# that reaches it shares one entry-local realm here, and a consumer left
|
|
305
|
+
# outside would resolve a host registry this preset does not populate.
|
|
306
|
+
#
|
|
307
|
+
# `tool-subagent-report` is host-plane for the same reason as the registry,
|
|
308
|
+
# not because a preset may not want it: it registers a CONTINUABLE SETUP on
|
|
309
|
+
# that singleton rather than a tool this agent calls, and the setup list is
|
|
310
|
+
# not scope-aware — one copy per mounted preset means every child gets
|
|
311
|
+
# `report` registered once per live session, which throws on the second.
|
|
312
|
+
- id: delegation
|
|
313
|
+
name: cordis:group
|
|
314
|
+
group: true
|
|
315
|
+
isolate:
|
|
316
|
+
workflowEngine: true
|
|
317
|
+
config:
|
|
318
|
+
- id: tool-subagent-control
|
|
319
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
320
|
+
|
|
321
|
+
- id: tool-subagent-list-agents
|
|
322
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
323
|
+
|
|
324
|
+
- id: tool-subagent
|
|
325
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
326
|
+
config:
|
|
327
|
+
provider: spawn
|
|
328
|
+
toolName: subagent
|
|
329
|
+
backgroundMode: continuable
|
|
330
|
+
|
|
331
|
+
- id: tool-subagent-fork
|
|
332
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
333
|
+
config:
|
|
334
|
+
provider: fork
|
|
335
|
+
toolName: subagent_fork
|
|
336
|
+
backgroundMode: continuable
|
|
337
|
+
|
|
338
|
+
# Product providers are host-plane singletons. Copy this preset, then
|
|
339
|
+
# remove `disabled` from either ordinary tool row to expose that product
|
|
340
|
+
# only to agents composed from the copy.
|
|
341
|
+
- id: tool-subagent-codex
|
|
342
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
343
|
+
disabled: true
|
|
344
|
+
config:
|
|
345
|
+
provider: codex
|
|
346
|
+
toolName: subagent_codex
|
|
347
|
+
enableRunInBackground: false
|
|
348
|
+
maxDepth: provider-managed
|
|
349
|
+
|
|
350
|
+
- id: tool-subagent-claude-code
|
|
351
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
352
|
+
disabled: true
|
|
353
|
+
config:
|
|
354
|
+
provider: claude-code
|
|
355
|
+
toolName: subagent_claude_code
|
|
356
|
+
enableRunInBackground: false
|
|
357
|
+
maxDepth: provider-managed
|
|
358
|
+
|
|
359
|
+
- id: workflow-worker-thread
|
|
360
|
+
name: '@deepseek-ai/dsh-workflow-worker-thread'
|
|
361
|
+
config:
|
|
362
|
+
provider: spawn
|
|
363
|
+
|
|
364
|
+
- id: tool-workflow
|
|
365
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
366
|
+
|
|
367
|
+
- id: tool-ralph
|
|
368
|
+
name: '@deepseek-ai/dsh-tool-ralph'
|
|
369
|
+
config:
|
|
370
|
+
subagentProvider: spawn
|
|
371
|
+
maxRounds: 64
|
|
372
|
+
|
|
373
|
+
# ── remaining model-facing rows ─────────────────────────────────────────────
|
|
374
|
+
|
|
375
|
+
- id: tool-ask-user
|
|
376
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
377
|
+
|
|
378
|
+
- id: tool-todo
|
|
379
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
380
|
+
config:
|
|
381
|
+
allowParallelInProgress: true
|
|
382
|
+
|
|
383
|
+
# The `web` service and its search provider stay in the host composition; only
|
|
384
|
+
# the model-facing tool is per-session.
|
|
385
|
+
- id: tool-web
|
|
386
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
387
|
+
config:
|
|
388
|
+
fetch: false
|
|
389
|
+
searchTimeoutMs: 60000
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Epoch-aware promotion tracker shared by the bootstrap and baseline-gate
|
|
3
|
+
* plugins of the anchored presets.
|
|
4
|
+
*
|
|
5
|
+
* A compaction rewrites the model-visible surface: the pre-compaction
|
|
6
|
+
* conversation collapses into one synthetic summary message, and the
|
|
7
|
+
* workspace-instruction baseline is re-injected from scratch. The first
|
|
8
|
+
* post-compaction request is therefore a "second first request" — the same
|
|
9
|
+
* first-token conditions the anchored presets exist to control. Promotion is
|
|
10
|
+
* epoch-aware: only a durable promotion signal (`tool/call` and/or
|
|
11
|
+
* `assistant/message`, per the caller's `promoteEvents`) recorded AFTER the
|
|
12
|
+
* last `compaction/end` boundary counts as promoted. Before any compaction
|
|
13
|
+
* the boundary is -1, which preserves the original one-shot semantics.
|
|
14
|
+
*
|
|
15
|
+
* State is memoized per session id and maintained incrementally through
|
|
16
|
+
* `observe()`; a cold session scans its durable log once (so resume and
|
|
17
|
+
* reload reconstruct the same phase), then O(1).
|
|
18
|
+
*
|
|
19
|
+
* By default subagents (`delegationDepth > 0`) are treated as already
|
|
20
|
+
* promoted so their first request can use tools. Set `includeSubagents: true`
|
|
21
|
+
* to make subagents follow the same bootstrap/anchor phase as top-level
|
|
22
|
+
* sessions.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Build one epoch-aware promotion tracker. */
|
|
26
|
+
export function createEpochPromotion(promoteEvents, options = {}) {
|
|
27
|
+
const includeSubagents = options.includeSubagents === true
|
|
28
|
+
const promote = new Set(promoteEvents)
|
|
29
|
+
/** sessionId -> { boundary, promoted } */
|
|
30
|
+
const state = new Map()
|
|
31
|
+
|
|
32
|
+
/** Scan a session's durable log from scratch (cold start / resume). */
|
|
33
|
+
const scan = (session) => {
|
|
34
|
+
let boundary = -1
|
|
35
|
+
let promoted = false
|
|
36
|
+
for (const event of session.events) {
|
|
37
|
+
const seq = event.seq ?? 0 // events without a seq are treated as post-boundary
|
|
38
|
+
if (event.type === 'compaction/end') {
|
|
39
|
+
boundary = seq
|
|
40
|
+
promoted = false
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
if (promote.has(event.type) && seq > boundary) promoted = true
|
|
44
|
+
}
|
|
45
|
+
const entry = { boundary, promoted }
|
|
46
|
+
state.set(session.id, entry)
|
|
47
|
+
return entry
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
/**
|
|
52
|
+
* Current phase of the agent's session.
|
|
53
|
+
* @param agent - the assembly/pre-step agent, or undefined outside an agent.
|
|
54
|
+
* @returns { boundary, promoted } — `boundary` is the last compaction/end
|
|
55
|
+
* seq (-1 before any compaction); `promoted` is true when a durable
|
|
56
|
+
* promotion signal exists after that boundary.
|
|
57
|
+
*/
|
|
58
|
+
status(agent) {
|
|
59
|
+
if (agent === undefined) return { boundary: -1, promoted: true }
|
|
60
|
+
const session = agent.session
|
|
61
|
+
if (session === undefined) return { boundary: -1, promoted: true }
|
|
62
|
+
// By default subagents keep the full catalog from their very first
|
|
63
|
+
// request; includeSubagents makes them follow the normal bootstrap phase.
|
|
64
|
+
if (!includeSubagents && (session.header?.delegationDepth ?? 0) > 0) return { boundary: -1, promoted: true }
|
|
65
|
+
return state.get(session.id) ?? scan(session)
|
|
66
|
+
},
|
|
67
|
+
/** Incremental feed: call on every `session/event`. */
|
|
68
|
+
observe(session, event) {
|
|
69
|
+
const entry = state.get(session.id)
|
|
70
|
+
if (entry === undefined) return
|
|
71
|
+
const seq = event.seq ?? 0
|
|
72
|
+
if (event.type === 'compaction/end') {
|
|
73
|
+
state.set(session.id, { boundary: seq, promoted: false })
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
if (promote.has(event.type) && seq > entry.boundary && !entry.promoted) {
|
|
77
|
+
state.set(session.id, { ...entry, promoted: true })
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* custom-bash — a Windows-capable `bash` tool that registers under the SAME
|
|
3
|
+
* name (`bash`) as the official persistent bash, with a Minimal-compatible
|
|
4
|
+
* description, but executes through `ctx.subprocess.spawn` instead of a PTY.
|
|
5
|
+
*
|
|
6
|
+
* WHY: DeepSeek's first-request trajectory anchor keys on the tool SCHEMA
|
|
7
|
+
* matching the RL training distribution (issue #11: persistent
|
|
8
|
+
* bash + str_replace_editor anchored 5/5 at maxTokens=256000, pwsh/read
|
|
9
|
+
* 8/8 standard-like). The official persistent bash uses a PTY, and DSH's PTY
|
|
10
|
+
* backend is linux/darwin-only — `subprocess-local` throws "terminal
|
|
11
|
+
* inspection is unsupported on platform win32". A custom tool that presents
|
|
12
|
+
* the same name and a Minimal-like description but spawns Git Bash through
|
|
13
|
+
* the ordinary (cross-platform) subprocess seam keeps the schema anchor
|
|
14
|
+
* without the PTY dependency.
|
|
15
|
+
*
|
|
16
|
+
* Executable resolution (config `bashPath`):
|
|
17
|
+
* - explicit absolute path (e.g. `C:\Program Files\Git\bin\bash.exe`), or
|
|
18
|
+
* - `bash` resolved through `ctx.subprocess.resolveExecutable` (PATH lookup).
|
|
19
|
+
*
|
|
20
|
+
* Semantics mirror the official bash tool: `bash -c <command>` in a fresh
|
|
21
|
+
* process, bounded output, non-zero exit reported not thrown. No sandbox
|
|
22
|
+
* confinement on Windows (the sandbox backend is linux-only); the tool
|
|
23
|
+
* description says so. The bootstrap catalog pairs this with
|
|
24
|
+
* `str_replace_editor` (Minimal's two tools).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
28
|
+
export const name = 'custom-bash'
|
|
29
|
+
|
|
30
|
+
/** The subprocess and tools services must exist before this tool can register. */
|
|
31
|
+
export const inject = ['subprocess', 'tools']
|
|
32
|
+
|
|
33
|
+
const DEFAULT_TIMEOUT_MS = 120000
|
|
34
|
+
const DEFAULT_MAX_OUTPUT_BYTES = 64000
|
|
35
|
+
|
|
36
|
+
/** Tool parameter schema for the model-facing command. */
|
|
37
|
+
const commandSchema = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
command: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'The bash command to execute (`bash -c` string domain).',
|
|
43
|
+
},
|
|
44
|
+
workdir: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Optional working directory; defaults to the session cwd.',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['command'],
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Register the model-facing `bash` tool. */
|
|
54
|
+
export function apply(ctx, config) {
|
|
55
|
+
const bashPath = typeof config?.bashPath === 'string' && config.bashPath.length > 0 ? config.bashPath : 'bash'
|
|
56
|
+
const timeoutMs = Number.isSafeInteger(config?.timeoutMs) && config.timeoutMs > 0 ? config.timeoutMs : DEFAULT_TIMEOUT_MS
|
|
57
|
+
const maxOutputBytes = Number.isSafeInteger(config?.maxOutputBytes) && config.maxOutputBytes > 0 ? config.maxOutputBytes : DEFAULT_MAX_OUTPUT_BYTES
|
|
58
|
+
|
|
59
|
+
ctx.tools.register({
|
|
60
|
+
name: 'bash',
|
|
61
|
+
description: [
|
|
62
|
+
'Run commands in a bash shell (Git Bash on Windows)',
|
|
63
|
+
'* When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.',
|
|
64
|
+
"* You don't have access to the internet via this tool.",
|
|
65
|
+
'* You do have access to a mirror of common linux and python packages via apt and pip.',
|
|
66
|
+
'* State does NOT persist across command calls: each call runs in a fresh shell.',
|
|
67
|
+
"* To inspect a particular line range of a file, e.g. lines 10-25, try 'sed -n 10,25p /path/to/the/file'.",
|
|
68
|
+
'* Please avoid commands that may produce a very large amount of output.',
|
|
69
|
+
'* NOTE: runs without OS sandbox confinement on Windows (no landlock); treat output as untrusted.',
|
|
70
|
+
].join('\n'),
|
|
71
|
+
parameters: commandSchema,
|
|
72
|
+
output: {
|
|
73
|
+
schema: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
additionalProperties: false,
|
|
76
|
+
properties: {
|
|
77
|
+
text: { type: 'string' },
|
|
78
|
+
},
|
|
79
|
+
required: ['text'],
|
|
80
|
+
},
|
|
81
|
+
render: (_args, value) => [{ type: 'text', text: value.text }],
|
|
82
|
+
},
|
|
83
|
+
async execute(args, exec) {
|
|
84
|
+
const shell = await ctx.subprocess.resolveExecutable(bashPath, undefined, exec?.signal)
|
|
85
|
+
const workdir = typeof args.workdir === 'string' && args.workdir.length > 0
|
|
86
|
+
? args.workdir
|
|
87
|
+
: exec?.agent?.session?.header?.cwd
|
|
88
|
+
const signal = exec?.signal
|
|
89
|
+
const handle = ctx.subprocess.spawn({
|
|
90
|
+
argv: [shell, '-c', args.command],
|
|
91
|
+
...workdir !== undefined ? { cwd: workdir } : {},
|
|
92
|
+
stdio: {
|
|
93
|
+
stdin: 'ignore',
|
|
94
|
+
stdout: { maxBytes: maxOutputBytes },
|
|
95
|
+
stderr: { maxBytes: maxOutputBytes },
|
|
96
|
+
},
|
|
97
|
+
...signal !== undefined ? { signal } : {},
|
|
98
|
+
graceMs: 3000,
|
|
99
|
+
})
|
|
100
|
+
let outcome
|
|
101
|
+
try {
|
|
102
|
+
outcome = await handle.done
|
|
103
|
+
} catch (error) {
|
|
104
|
+
// A spawn-level failure (bad executable, EPERM) surfaces as a throw,
|
|
105
|
+
// which the runtime turns into an isError result.
|
|
106
|
+
throw new Error(`bash spawn failed: ${String(error)}`)
|
|
107
|
+
}
|
|
108
|
+
let stdout = ''
|
|
109
|
+
let stderr = ''
|
|
110
|
+
try {
|
|
111
|
+
stdout = handle.collected.stdout.readFrom(0).text
|
|
112
|
+
stderr = handle.collected.stderr.readFrom(0).text
|
|
113
|
+
} catch {
|
|
114
|
+
// Collected readers may be unavailable on some backends; tolerate.
|
|
115
|
+
}
|
|
116
|
+
const text = [stdout, stderr].filter((part) => part.length > 0).join('\n')
|
|
117
|
+
const tail = text.length > 0 ? text : `exit code: ${outcome.exitCode} (no output)`
|
|
118
|
+
if (outcome.exitCode !== 0) {
|
|
119
|
+
// Non-zero exit is a reported failure, not a throw: the model sees the
|
|
120
|
+
// command output plus the exit code.
|
|
121
|
+
throw new Error(tail)
|
|
122
|
+
}
|
|
123
|
+
return { text: tail }
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
}
|