dsh-plugin-prompt-tool 0.3.0 → 0.4.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/README.md +77 -85
- package/lib/client.js +96 -5
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +7 -3
- package/lib/index.mjs +58 -61
- package/lib/preset-core.d.mts +7 -3
- package/lib/preset-core.mjs +133 -29
- package/package.json +20 -20
- package/plan.md +22 -2
- package/preset/agent.cordis.yml +443 -0
- package/preset/compaction-epoch.mjs +81 -0
- package/preset/context-gate.mjs +165 -0
- package/preset/custom-bash.mjs +243 -0
- package/preset/instruction-hint.mjs +217 -0
- package/preset/near-anchor.mjs +6 -19
- package/preset/prompt-injector.mjs +111 -126
- package/preset/router-first-turn.mjs +73 -70
- package/preset/router-guide.mjs +14 -20
- package/preset/shared.mjs +83 -0
- package/preset/skill-search.mjs +142 -0
- package/preset/tool-bootstrap.mjs +282 -0
- package/upstream/dsh-anchored-standard/REVISION +1 -1
- package/upstream/dsh-anchored-standard/preset/agent.cordis.yml +22 -11
- package/upstream/dsh-anchored-standard/preset/custom-bash.mjs +98 -5
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
# prompt-tool owned agent.cordis.yml template.
|
|
2
|
+
# Derived from dsh-anchored-standard (upstream/dsh-anchored-standard/REVISION) with local edits:
|
|
3
|
+
# - context-gate: includeSubagents=false, allowKinds extended for near-anchor/router-guide
|
|
4
|
+
# - dev-tool-search row removed
|
|
5
|
+
# - usePtcMode / bootstrapMaxTokens / subagentFlash injected at build time by buildCordis
|
|
6
|
+
# The upstream file is kept only for attribution and sync review.
|
|
7
|
+
|
|
8
|
+
# The `anchored-standard` experimental preset: Standard capabilities with the
|
|
9
|
+
# Minimal mode system-prompt condition used by the V4 trajectory evaluation.
|
|
10
|
+
#
|
|
11
|
+
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
|
|
12
|
+
# standing scope; every session naming it joins by scope parentage, so the
|
|
13
|
+
# tools and prompt sections registered here cover each joined agent while a
|
|
14
|
+
# session's own state stays keyed per Session/Agent inside the plugins. The
|
|
15
|
+
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
|
|
16
|
+
# preset must not own: the registries themselves, the sandbox and approval
|
|
17
|
+
# stack, persistence, and the model route.
|
|
18
|
+
#
|
|
19
|
+
# A service row here MUST sit inside a group carrying an `isolate` realm.
|
|
20
|
+
# Without one it publishes into the root realm, where it is process-global —
|
|
21
|
+
# another preset publishing the same name collides, and a host reader would
|
|
22
|
+
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
|
|
23
|
+
# that at mount. `true` means an entry-local realm: this standing mount's own
|
|
24
|
+
# private instance, apart from every other preset's. (A shared label does NOT
|
|
25
|
+
# pool instances — `provide()` throws on the second registration under the
|
|
26
|
+
# same realm symbol; labels join REALMS, and are not what this file needs.)
|
|
27
|
+
|
|
28
|
+
# ── context gate (must stay FIRST) ──────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
# Unified injection control (shared/context-gate.mjs, reusable by any preset):
|
|
31
|
+
# while the session is unpromoted, BOTH unified injection paths are closed.
|
|
32
|
+
# The assembly's dynamic runtime-context contributions are blanked — the whole
|
|
33
|
+
# `SystemPrompt.context()` family (sandbox/approval policy snapshots and any
|
|
34
|
+
# third-party context provider) without enumerating them — and the pre-step
|
|
35
|
+
# waterfall keeps ONLY the claimed message batch plus the `allowKinds` entries
|
|
36
|
+
# (a user skill gesture survives; every automatic injection — skill catalog,
|
|
37
|
+
# AGENTS.md digest, time/tmux context, hooks, unknown third-party plugins — is
|
|
38
|
+
# stripped by default). After the first durable promotion signal (a tool call
|
|
39
|
+
# OR the first assistant message, `promoteOn: either`) the gate opens, and the
|
|
40
|
+
# loop's own snapshot projection diffs exactly ONE fresh runtime-context
|
|
41
|
+
# message into the next request: minimal first round, injections on the second
|
|
42
|
+
# round. A `compaction/end` boundary re-closes the gate the same way.
|
|
43
|
+
#
|
|
44
|
+
# This row deliberately sits before every other row: waterfall after-next
|
|
45
|
+
# transforms apply in reverse registration order, so registering first (plus
|
|
46
|
+
# the empty inject list and the pre-step listener's `prepend` flag) makes the
|
|
47
|
+
# gate the outermost transform — nothing registered later re-injects past it
|
|
48
|
+
# (see issue #6).
|
|
49
|
+
#
|
|
50
|
+
# `includeSubagents: false` here keeps the context gate out of subagent first
|
|
51
|
+
# requests (prompt-tool opts for catalog-level subagent pass-through); the
|
|
52
|
+
# tool-bootstrap row below still gates subagent tools via its own flag.
|
|
53
|
+
- id: context-gate
|
|
54
|
+
name: ./context-gate.mjs
|
|
55
|
+
config:
|
|
56
|
+
promoteOn: either
|
|
57
|
+
includeSubagents: false
|
|
58
|
+
allowKinds: [skill-invocation, near-anchor, router-guide]
|
|
59
|
+
|
|
60
|
+
# ── bootstrap ───────────────────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
# Tool catalog control (mode-owned tool-bootstrap.mjs). V4 Pro conditions
|
|
63
|
+
# strongly on the API tool catalog AND the first request output budget:
|
|
64
|
+
# request #1 exposes the OFFICIAL Minimal preset's real tool pair —
|
|
65
|
+
# persistent `bash` + `str_replace_editor` — which anchors at the
|
|
66
|
+
# adapter-default maxTokens (256000) with no output cap needed (issue #11:
|
|
67
|
+
# 5/5 anchored vs 11/11 standard-like for every standard-family schema);
|
|
68
|
+
# after the session records its first durable promotion signal (a tool call OR
|
|
69
|
+
# the first assistant message, default `promoteOn: either`), later steps keep
|
|
70
|
+
# the assembled catalog and usePtcMode optionally switches the wire to Code
|
|
71
|
+
# Mode (PTC). `bootstrapMaxTokens` is
|
|
72
|
+
# opt-in for standard-schema bootstraps; unset, the adapter default flows. See
|
|
73
|
+
# tool-bootstrap.mjs for the other triggers. Context stripping is NOT here —
|
|
74
|
+
# the context-gate row above owns it.
|
|
75
|
+
#
|
|
76
|
+
# POST-PROMOTION (prompt-tool local addition): both modes keep the assembled
|
|
77
|
+
# catalog after promotion. `usePtcMode` switches the wire presentation to Code
|
|
78
|
+
# Mode (PTC, a single run_code backed by the full registry SDK) instead of
|
|
79
|
+
# narrowing the resident set; the pre-promotion and post-compaction controlled
|
|
80
|
+
# phase below still stays on the bootstrap pair + `compactionTools`.
|
|
81
|
+
#
|
|
82
|
+
# COMPACTION (local addition): after `compaction/end` the session falls back
|
|
83
|
+
# to the controlled phase — bootstrap pair + `compactionTools` — until a NEW
|
|
84
|
+
# durable promotion signal exists past the boundary (epoch-aware, see
|
|
85
|
+
# compaction-epoch.mjs).
|
|
86
|
+
#
|
|
87
|
+
# `includeSubagents: true` keeps the subagent phase in sync with the
|
|
88
|
+
# context-gate row: a subagent's first request sees the bootstrap pair, then
|
|
89
|
+
# its own first reply or tool call promotes it to the assembled catalog.
|
|
90
|
+
- id: tool-bootstrap
|
|
91
|
+
name: ./tool-bootstrap.mjs
|
|
92
|
+
config:
|
|
93
|
+
bootstrapTools: [bash, str_replace_editor]
|
|
94
|
+
promoteOn: either
|
|
95
|
+
includeSubagents: true
|
|
96
|
+
# Post-compaction core work set: the model is mid-task and needs to keep
|
|
97
|
+
# working, but faces a small catalog instead of the full Standard set.
|
|
98
|
+
compactionTools: [read, write, edit, glob, grep, todo_write, ask_user_question]
|
|
99
|
+
|
|
100
|
+
# ── identity ────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
# Keep this text byte-identical to the Minimal preset. `complete` prevents the
|
|
103
|
+
# Harness identity and per-tool guidance from changing the system prompt, while
|
|
104
|
+
# runtime-context suppression leaves task and repository rules to user messages
|
|
105
|
+
# and explicit file reads. Tool schemas and their runtime enforcement remain.
|
|
106
|
+
- id: persona
|
|
107
|
+
name: '@deepseek-ai/dsh-persona'
|
|
108
|
+
config:
|
|
109
|
+
text: You are a helpful software engineer assistant.
|
|
110
|
+
complete: true
|
|
111
|
+
includeRuntimeContext: false
|
|
112
|
+
|
|
113
|
+
# Instruction FILES are NOT injected (replaces dsh-agent-instructions, local
|
|
114
|
+
# addition): the full AGENTS.md/CLAUDE.md digest is a large injected block
|
|
115
|
+
# that perturbs the trajectory even after promotion. Instead, after promotion
|
|
116
|
+
# ONE short hint is injected once per session — "these instruction files
|
|
117
|
+
# exist; read them before acting" — and the model reads the files itself via
|
|
118
|
+
# the filesystem tools when relevant. The once-per-session guard is DERIVED
|
|
119
|
+
# FROM DURABLE EVENTS (restart-safe): a process restart must never inject a
|
|
120
|
+
# second hint with the same deterministic message id — the duplicate id
|
|
121
|
+
# breaks history replay. `includeSubagents: true` makes a subagent's own
|
|
122
|
+
# first reply or tool call open its hint, keeping it out of the context
|
|
123
|
+
# gate's stripped first request.
|
|
124
|
+
- id: instruction-hint
|
|
125
|
+
name: ./instruction-hint.mjs
|
|
126
|
+
config:
|
|
127
|
+
promoteOn: either
|
|
128
|
+
includeSubagents: true
|
|
129
|
+
|
|
130
|
+
# ── shell ───────────────────────────────────────────────────────────────────
|
|
131
|
+
|
|
132
|
+
# `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
|
|
133
|
+
# publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
|
|
134
|
+
# the criterion for host-plane ownership — injection resolves before any session
|
|
135
|
+
# exists, so there is no agent to key by. Behind a preset realm those variables
|
|
136
|
+
# never reached the model's shell at all. Both shell tools consume the host
|
|
137
|
+
# registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
|
|
138
|
+
# host-plane too.
|
|
139
|
+
- id: tool-bash
|
|
140
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
141
|
+
# Disabled on EVERY platform, not just Windows: `dsh-tool-bash-persistent`
|
|
142
|
+
# below registers the same `bash` tool name into this same preset layer, and
|
|
143
|
+
# the tools registry rejects duplicates within one layer. The persistent
|
|
144
|
+
# shell (the Minimal preset's own shell) is the preset's bash; it consumes
|
|
145
|
+
# the host sandbox policy through the terminals realm.
|
|
146
|
+
disabled: true
|
|
147
|
+
|
|
148
|
+
- id: tool-pwsh
|
|
149
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
150
|
+
disabled: !!js process.platform !== 'win32'
|
|
151
|
+
|
|
152
|
+
# The Minimal preset's shell: a PTY-backed persistent bash, schema-identical
|
|
153
|
+
# to the official `minimal` preset's `persistent-shell` group so the first
|
|
154
|
+
# request exposes exactly Minimal's real `bash` schema. ONE deliberate config
|
|
155
|
+
# difference: an adaptive `shellPath` — the terminal-bash plugin default
|
|
156
|
+
# `/bin/bash` where that absolute path exists (every host that ships it keeps
|
|
157
|
+
# the previous behavior), otherwise a bare `bash` resolved through the same
|
|
158
|
+
# scrubbed PATH the other harness tools use. The fallback exists because
|
|
159
|
+
# `/bin/bash` does not exist on NixOS and other hosts that keep bash
|
|
160
|
+
# elsewhere; there `execvp("/bin/bash")` exits during PTY startup ("PTY shell
|
|
161
|
+
# exited during startup") and every bash call fails. The PTY registry is an
|
|
162
|
+
# agent-owned service, so it lives in an entry-local realm; the backend still
|
|
163
|
+
# consumes the host sandbox policy and subprocess implementation, while the
|
|
164
|
+
# tool registers into this agent's scoped catalog.
|
|
165
|
+
#
|
|
166
|
+
# DISABLED ON WINDOWS: DSH's PTY backend is linux/darwin-only, so the
|
|
167
|
+
# persistent shell cannot serve win32. The `custom-bash` row below registers
|
|
168
|
+
# the same `bash` tool name there instead (platform-exclusive).
|
|
169
|
+
- id: persistent-shell
|
|
170
|
+
name: cordis:group
|
|
171
|
+
group: true
|
|
172
|
+
disabled: !!js process.platform === 'win32'
|
|
173
|
+
isolate:
|
|
174
|
+
terminals: true
|
|
175
|
+
config:
|
|
176
|
+
- id: pty
|
|
177
|
+
name: '@deepseek-ai/dsh-terminal'
|
|
178
|
+
|
|
179
|
+
- id: terminal-bash
|
|
180
|
+
name: '@deepseek-ai/dsh-terminal-bash'
|
|
181
|
+
config:
|
|
182
|
+
shellPath: !!js "process.getBuiltinModule?.('node:fs')?.existsSync('/bin/bash') ? '/bin/bash' : 'bash'"
|
|
183
|
+
timeoutMs: 300000
|
|
184
|
+
|
|
185
|
+
- id: persistent-bash
|
|
186
|
+
name: '@deepseek-ai/dsh-tool-bash-persistent'
|
|
187
|
+
config:
|
|
188
|
+
timeoutMs: 300000
|
|
189
|
+
description: |-
|
|
190
|
+
Run commands in a bash shell
|
|
191
|
+
* When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.
|
|
192
|
+
* You don't have access to the internet via this tool.
|
|
193
|
+
* You do have access to a mirror of common linux and python packages via apt and pip.
|
|
194
|
+
* State is persistent across command calls and discussions with the user.
|
|
195
|
+
* To inspect a particular line range of a file, e.g. lines 10-25, try 'sed -n 10,25p /path/to/the/file'.
|
|
196
|
+
* Please avoid commands that may produce a very large amount of output.
|
|
197
|
+
* Please run long lived commands in the background, e.g. 'sleep 10 &' or start a server in the background.
|
|
198
|
+
|
|
199
|
+
# Windows-only `bash` tool (see custom-bash.mjs): registers the SAME
|
|
200
|
+
# tool name as the persistent shell with a Minimal-compatible description, but
|
|
201
|
+
# executes through the ordinary cross-platform subprocess seam (`bash -c`)
|
|
202
|
+
# instead of a PTY. The shell is resolved WITHOUT a hardcoded install path
|
|
203
|
+
# (issue #24): `bashPath` unset probes the `git` executable's install root,
|
|
204
|
+
# then the well-known Git-for-Windows roots (Program Files(/x86), per-user
|
|
205
|
+
# LOCALAPPDATA, scoop's `current` junction), then plain `bash` on PATH — set
|
|
206
|
+
# `bashPath` explicitly only to pin a shell that probing cannot find. No OS
|
|
207
|
+
# sandbox confinement on Windows (landlock is linux-only); the tool
|
|
208
|
+
# description says so. When no bash exists at all the tool errors with
|
|
209
|
+
# guidance instead of switching shells — pwsh stays its own tool in the
|
|
210
|
+
# promoted catalog.
|
|
211
|
+
- id: custom-bash
|
|
212
|
+
name: ./custom-bash.mjs
|
|
213
|
+
disabled: !!js process.platform !== 'win32'
|
|
214
|
+
config:
|
|
215
|
+
timeoutMs: 120000
|
|
216
|
+
maxOutputBytes: 64000
|
|
217
|
+
|
|
218
|
+
# ── filesystem ──────────────────────────────────────────────────────────────
|
|
219
|
+
|
|
220
|
+
# Both register into the host `tools` registry and provide nothing, so
|
|
221
|
+
# they need no realm. The `fs` service and its policy stay in the host.
|
|
222
|
+
- id: tool-fs
|
|
223
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
224
|
+
|
|
225
|
+
- id: tool-fs-search
|
|
226
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
227
|
+
config:
|
|
228
|
+
sampleOverCapGlobResults: false
|
|
229
|
+
|
|
230
|
+
# The Minimal preset's second tool: `str_replace_editor` over a bare local
|
|
231
|
+
# filesystem, byte-identical in configuration to the official `minimal`
|
|
232
|
+
# preset's `filesystem` group. The editor's own realm shadows the host's
|
|
233
|
+
# sandboxed `fs` provider only inside this group, so the standard `read`/
|
|
234
|
+
# `write`/`edit` tools keep the sandboxed fs while the bootstrap editor uses
|
|
235
|
+
# the local one.
|
|
236
|
+
- id: bootstrap-filesystem
|
|
237
|
+
name: cordis:group
|
|
238
|
+
group: true
|
|
239
|
+
isolate:
|
|
240
|
+
fs: true
|
|
241
|
+
config:
|
|
242
|
+
- id: fs-local
|
|
243
|
+
name: '@deepseek-ai/dsh-fs-local'
|
|
244
|
+
config:
|
|
245
|
+
cwd: !!js process.env.DSH_CWD ?? process.cwd()
|
|
246
|
+
|
|
247
|
+
- id: str-replace-editor
|
|
248
|
+
name: '@deepseek-ai/dsh-tool-str-replace-editor'
|
|
249
|
+
config:
|
|
250
|
+
maxOutputChars: 16000
|
|
251
|
+
|
|
252
|
+
# ── background jobs ────────────────────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
# Only the model-facing controls. The task REGISTRY stays on the host plane:
|
|
255
|
+
# its producers sit outside any realm this file could put it in — `tool-bash`
|
|
256
|
+
# above resolves it with `ctx.get`, and an entry-local realm here is invisible
|
|
257
|
+
# to every sibling row, so `run_in_background` would answer "background jobs
|
|
258
|
+
# unavailable" while these controls sat in the catalog. The registry is keyed by
|
|
259
|
+
# owning agent anyway, so one host instance serves every session. What a preset
|
|
260
|
+
# chooses is whether its agent can collect and stop background work at all.
|
|
261
|
+
- id: tool-jobs
|
|
262
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
263
|
+
|
|
264
|
+
# ── skills ──────────────────────────────────────────────────────────────────
|
|
265
|
+
|
|
266
|
+
# The skill REGISTRY lives in the host composition and is layered per scope:
|
|
267
|
+
# these rows register into THIS preset's layer of it, so they need no realm.
|
|
268
|
+
# `skill-filesystem` contributes local-root discovery for agents on this
|
|
269
|
+
# preset. The full skill CATALOG injection (`dsh-tool-skill`, the ~9KB
|
|
270
|
+
# `<available_skills>` reminder) is REMOVED (local addition): it perturbs the
|
|
271
|
+
# trajectory (issue #6: 0/9 anchored with the catalog present vs ~81%
|
|
272
|
+
# without). Instead `skill-search` exposes two small on-demand tools —
|
|
273
|
+
# skill_search (list matching summaries) and skill_load (inject one skill's
|
|
274
|
+
# full instructions) — the tool-search pattern.
|
|
275
|
+
- id: skill-filesystem
|
|
276
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
277
|
+
|
|
278
|
+
- id: skill-search
|
|
279
|
+
name: ./skill-search.mjs
|
|
280
|
+
|
|
281
|
+
# ── goals ───────────────────────────────────────────────────────────────────
|
|
282
|
+
|
|
283
|
+
# Only the model-facing tool. The goal SERVICE, its session driver, and the
|
|
284
|
+
# `/goal` command stay on the host plane: the Gateway serves the goal domain as
|
|
285
|
+
# Remote endpoints whose receiver comes from a generated descriptor, so it
|
|
286
|
+
# resolves `goals` on the host and an entry-local realm here would hide it. The
|
|
287
|
+
# registry is keyed by session anyway, so one host instance serves every
|
|
288
|
+
# session. What a preset chooses is whether its agent can call the goal tool.
|
|
289
|
+
- id: tool-goal
|
|
290
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
291
|
+
|
|
292
|
+
# ── plan mode ───────────────────────────────────────────────────────────────
|
|
293
|
+
|
|
294
|
+
# Plan state is per-agent by nature, so an entry-local realm is not a
|
|
295
|
+
# workaround here — it is the correct lifetime.
|
|
296
|
+
- id: planning
|
|
297
|
+
name: cordis:group
|
|
298
|
+
group: true
|
|
299
|
+
isolate:
|
|
300
|
+
planMode: true
|
|
301
|
+
config:
|
|
302
|
+
- id: plan-mode
|
|
303
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
304
|
+
config:
|
|
305
|
+
section: |
|
|
306
|
+
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.
|
|
307
|
+
|
|
308
|
+
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.
|
|
309
|
+
|
|
310
|
+
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.
|
|
311
|
+
|
|
312
|
+
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.
|
|
313
|
+
|
|
314
|
+
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.
|
|
315
|
+
|
|
316
|
+
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.
|
|
317
|
+
|
|
318
|
+
# ── compaction ──────────────────────────────────────────────────────────────
|
|
319
|
+
|
|
320
|
+
# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
|
|
321
|
+
# share this realm rather than sit outside it.
|
|
322
|
+
#
|
|
323
|
+
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
|
|
324
|
+
# plane, and the rows here resolve that one instance. It takes no configuration,
|
|
325
|
+
# keys every fold by Session, and owns the context-meter projection units the
|
|
326
|
+
# browser reads for every session — behind a realm those units would come and go
|
|
327
|
+
# with whichever presets happen to be mounted. What a preset chooses is whether
|
|
328
|
+
# its agent compacts at all, which is `compaction-basic` below.
|
|
329
|
+
- id: compaction
|
|
330
|
+
name: cordis:group
|
|
331
|
+
group: true
|
|
332
|
+
isolate:
|
|
333
|
+
compaction: true
|
|
334
|
+
toolResultPruner: true
|
|
335
|
+
config:
|
|
336
|
+
- id: compaction-basic
|
|
337
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
338
|
+
|
|
339
|
+
- id: command-compact
|
|
340
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
341
|
+
|
|
342
|
+
- id: tool-result-pruner
|
|
343
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
344
|
+
config:
|
|
345
|
+
thresholdChars: 8192
|
|
346
|
+
headChars: 4096
|
|
347
|
+
tailChars: 1024
|
|
348
|
+
|
|
349
|
+
# ── delegation and workflows ────────────────────────────────────────────────
|
|
350
|
+
|
|
351
|
+
# The `subagents` registry and its spawn/fork backends live in the HOST
|
|
352
|
+
# composition: the registry is a process singleton whose cross-session queries
|
|
353
|
+
# the api-proxy serves to the browser, and a provider name may only be
|
|
354
|
+
# registered once. This preset contributes the delegation TOOLS, which resolve
|
|
355
|
+
# that host registry.
|
|
356
|
+
#
|
|
357
|
+
# `workflows` is different — nothing outside an agent reads it — so every row
|
|
358
|
+
# that reaches it shares one entry-local realm here, and a consumer left
|
|
359
|
+
# outside would resolve a host registry this preset does not populate.
|
|
360
|
+
#
|
|
361
|
+
# `tool-subagent-report` is host-plane for the same reason as the registry,
|
|
362
|
+
# not because a preset may not want it: it registers a CONTINUABLE SETUP on
|
|
363
|
+
# that singleton rather than a tool this agent calls, and the setup list is
|
|
364
|
+
# not scope-aware — one copy per mounted preset means every child gets
|
|
365
|
+
# `report` registered once per live session, which throws on the second.
|
|
366
|
+
- id: delegation
|
|
367
|
+
name: cordis:group
|
|
368
|
+
group: true
|
|
369
|
+
isolate:
|
|
370
|
+
workflowEngine: true
|
|
371
|
+
config:
|
|
372
|
+
- id: tool-subagent-control
|
|
373
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
374
|
+
|
|
375
|
+
- id: tool-subagent-list-agents
|
|
376
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
377
|
+
|
|
378
|
+
- id: tool-subagent
|
|
379
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
380
|
+
config:
|
|
381
|
+
provider: spawn
|
|
382
|
+
toolName: subagent
|
|
383
|
+
backgroundMode: continuable
|
|
384
|
+
|
|
385
|
+
- id: tool-subagent-fork
|
|
386
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
387
|
+
config:
|
|
388
|
+
provider: fork
|
|
389
|
+
toolName: subagent_fork
|
|
390
|
+
backgroundMode: continuable
|
|
391
|
+
|
|
392
|
+
# Product providers are host-plane singletons. Copy this preset, then
|
|
393
|
+
# remove `disabled` from either ordinary tool row to expose that product
|
|
394
|
+
# only to agents composed from the copy.
|
|
395
|
+
- id: tool-subagent-codex
|
|
396
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
397
|
+
disabled: true
|
|
398
|
+
config:
|
|
399
|
+
provider: codex
|
|
400
|
+
toolName: subagent_codex
|
|
401
|
+
enableRunInBackground: false
|
|
402
|
+
maxDepth: provider-managed
|
|
403
|
+
|
|
404
|
+
- id: tool-subagent-claude-code
|
|
405
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
406
|
+
disabled: true
|
|
407
|
+
config:
|
|
408
|
+
provider: claude-code
|
|
409
|
+
toolName: subagent_claude_code
|
|
410
|
+
enableRunInBackground: false
|
|
411
|
+
maxDepth: provider-managed
|
|
412
|
+
|
|
413
|
+
- id: workflow-worker-thread
|
|
414
|
+
name: '@deepseek-ai/dsh-workflow-worker-thread'
|
|
415
|
+
config:
|
|
416
|
+
provider: spawn
|
|
417
|
+
|
|
418
|
+
- id: tool-workflow
|
|
419
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
420
|
+
|
|
421
|
+
- id: tool-ralph
|
|
422
|
+
name: '@deepseek-ai/dsh-tool-ralph'
|
|
423
|
+
config:
|
|
424
|
+
subagentProvider: spawn
|
|
425
|
+
maxRounds: 64
|
|
426
|
+
|
|
427
|
+
# ── remaining model-facing rows ─────────────────────────────────────────────
|
|
428
|
+
|
|
429
|
+
- id: tool-ask-user
|
|
430
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
431
|
+
|
|
432
|
+
- id: tool-todo
|
|
433
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
434
|
+
config:
|
|
435
|
+
allowParallelInProgress: true
|
|
436
|
+
|
|
437
|
+
# The `web` service and its search provider stay in the host composition; only
|
|
438
|
+
# the model-facing tool is per-session.
|
|
439
|
+
- id: tool-web
|
|
440
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
441
|
+
config:
|
|
442
|
+
fetch: false
|
|
443
|
+
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
|
+
}
|