@linxin666/dsh-liangshen 0.4.6 → 0.4.7

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.
@@ -6,11 +6,9 @@
6
6
  * PRESENTATION: the `presentation` config picks how this session's tools sit
7
7
  * on the wire, matching the SDK's ToolPresentationMode:
8
8
  * - `native`: the assembled native roster, no code transport;
9
- * - `ptc`: the wire collapses to the single `run_code` transport and every
10
- * other tool is reached from inside the program through the generated SDK;
11
- * - `both` (default): the full native roster plus the `run_code` transport
12
- * co-resident on the wire — native calls carry ordinary work, `run_code`
13
- * covers programmatic batch computation and overlapped fan-out.
9
+ * - `ptc` (default): the wire collapses to the single `run_code` transport
10
+ * and every other tool is reached from inside the program through the
11
+ * generated SDK.
14
12
  *
15
13
  * The declaration happens once per agent scope (agent.ctx.tools.presentAs) as
16
14
  * early as the scope exists — there is no turn-boundary staging: the retired
@@ -45,15 +43,8 @@
45
43
  *
46
44
  * WHICH PRESENTATION PAGES WHAT: the registry restriction is installed for
47
45
  * `ptc` alone, because a collapsed wire is the one presentation where the
48
- * scope's registry IS the whole reachable surface. `both` deliberately leaves
49
- * the registry unrestricted: its wire carries the full native roster beside
50
- * `run_code`, so a paged namespace is off the direct-call surface while the
51
- * SDK inside a program still reaches it. That reachability is the native wire's
52
- * own — the wire carries every registered tool and nothing removes the paged
53
- * ones from the scope's registry — rather than an exemption paging grants, and
54
- * it is why the paged-out summary states each presentation's reachability
55
- * instead of describing both with one sentence. `native` carries no program at
56
- * all, so the wire partition is the whole of paging there.
46
+ * scope's registry IS the whole reachable surface. `native` carries no
47
+ * program at all, so the wire partition is the whole of paging there.
57
48
  *
58
49
  * TIMING: that restriction is installed from OUTSIDE the assembly waterfall.
59
50
  * `SystemPrompt.assemble()` collects the tool providers and calls every
@@ -68,9 +59,13 @@
68
59
  * CATALOG: the durable user message appended after the user's own message
69
60
  * names exactly the tools the current request's wire carries (each tool's
70
61
  * argument signature plus a one-line summary), then summarizes the paged-out
71
- * namespaces with their activation pointer. Under 'both' the catalog lists
72
- * `run_code` like any other tool and notes the programmatic-escape hatch; the
73
- * 'ptc' program contract only ships when the wire actually collapsed to it.
62
+ * namespaces with their activation pointer. The 'ptc' program contract ships
63
+ * when the wire actually collapsed to the transport. A tool the catalog
64
+ * curates renders the hand-written line from
65
+ * {@link CURATED_TOOL_SUMMARIES}; only an uncurated tool falls back to the
66
+ * mechanical `descriptionMaxLength` truncation of its own schema description,
67
+ * because a character-count cut can slice off exactly the sentence that says
68
+ * what the tool is for.
74
69
  * The catalog republishes only when its content changes or the published copy
75
70
  * left the visible surface (compaction, resume).
76
71
  *
@@ -105,7 +100,7 @@ export const inject = ['systemPrompt']
105
100
  const DEFAULT_DESCRIPTION_MAX_LENGTH = 200
106
101
 
107
102
  /** The presentation modes the SDK's ToolPresentationMode supports. */
108
- export const PRESENTATION_MODES = ['native', 'ptc', 'both']
103
+ export const PRESENTATION_MODES = ['native', 'ptc']
109
104
 
110
105
  /**
111
106
  * The default presentation: the wire collapses to the single \`run_code\` transport
@@ -114,7 +109,7 @@ export const PRESENTATION_MODES = ['native', 'ptc', 'both']
114
109
  *
115
110
  * This is a deliberate trade, not a measured win. Collapsing the wire removes the
116
111
  * native roster's schema payload from every request, which is the cheapest static
117
- * context of the three modes; the official published scaffold comparison, however,
112
+ * context of the two modes; the official published scaffold comparison, however,
118
113
  * places this presentation BELOW the natively presented surface on both code-agent
119
114
  * benchmarks (DeepSWE v1.1: 67.6 against 72.6; Terminal-Bench 2.1: 85.8 against
120
115
  * 90.6). The default is chosen for its static-context cost on long sessions and is
@@ -187,13 +182,23 @@ function optionalBoolean(value, field, fallback) {
187
182
  }
188
183
 
189
184
  /**
190
- * Resolve the presentation config: the explicit `presentation` enum wins; the
191
- * legacy boolean `ptcPresentation` maps onto it (true -> 'ptc', false ->
192
- * 'native') with a one-time deprecation warning; neither means the default.
185
+ * Resolve the presentation config: the explicit `presentation` enum wins (with
186
+ * the pre-0.2.1 `'both'` default mapped to `'ptc'` with a one-time deprecation
187
+ * warning so older profiles keep booting); the legacy boolean `ptcPresentation`
188
+ * maps onto it (true -> 'ptc', false -> 'native') with a one-time deprecation
189
+ * warning; neither means the default.
193
190
  */
194
191
  function resolvePresentation(config, warn) {
195
192
  const explicit = config?.presentation
196
193
  if (explicit !== undefined) {
194
+ if (explicit === 'both') {
195
+ if (config?.ptcPresentation !== undefined) {
196
+ optionalBoolean(config.ptcPresentation, 'ptcPresentation', true)
197
+ warn('the ptcPresentation key is deprecated — presentation takes precedence over it')
198
+ }
199
+ warn("the 'both' presentation was removed in 0.2.1; mapping 'both' -> 'ptc'")
200
+ return 'ptc'
201
+ }
197
202
  if (!PRESENTATION_MODES.includes(explicit)) {
198
203
  throw new TypeError(`${name}: presentation must be one of ${JSON.stringify(PRESENTATION_MODES)}`)
199
204
  }
@@ -224,6 +229,94 @@ function validateRetiredAnchorTools(value) {
224
229
  }
225
230
  }
226
231
 
232
+ /**
233
+ * Curated one-line summaries, one per host builtin tool this preset can put on
234
+ * a wire. Each line says what the tool is FOR and names the arguments that
235
+ * decide how it is called, kept well inside {@link DEFAULT_DESCRIPTION_MAX_LENGTH}.
236
+ *
237
+ * PRECEDENCE: a tool named here renders THIS line; every other tool keeps the
238
+ * mechanical cap — its own schema description, whitespace collapsed and cut to
239
+ * `descriptionMaxLength`. Curation therefore wins over truncation and never
240
+ * replaces it: a tool the table does not name (a paged MCP namespace's tool, a
241
+ * plugin-registered tool, a tool the harness adds later) still reaches the
242
+ * model, just at whatever the cap leaves of its own description. A character
243
+ * count is a poor editor — it slices off the sentence that says what the tool
244
+ * is for — so the tools this session mounts on every request get a hand-written
245
+ * line instead.
246
+ *
247
+ * SCOPE: exactly the host builtins the preset's own `agent.cordis.yml` rows
248
+ * mount for a session, which is the surface the paging wildcard leaves resident
249
+ * (`pagedToolPatterns` defaults to `mcp__*`, so no host builtin is ever paged
250
+ * out):
251
+ * - the shell (one of bash / pwsh per platform), the filesystem and discovery
252
+ * tools, the background-job controls, and the editor;
253
+ * - the prompt/skill surface, the todo list, the user question tool, and
254
+ * `web_search` (the preset's own `tool-web` row configures `fetch: false`,
255
+ * so the session opens the search tool alone);
256
+ * - the preset's own `tool_activate` and `fact_register`;
257
+ * - the READ-ONLY MCP resource tools, which the base composition mounts and
258
+ * which are reachable whenever the deployment registers an MCP server — even
259
+ * though a configured `mcp__*` server's tools are the ones paging withholds.
260
+ *
261
+ * Three names a reader might expect are deliberately ABSENT, because this
262
+ * composition mounts no row that registers them and curating them would write a
263
+ * catalog line for a tool surface the request never opens — exactly the claim
264
+ * the declare-exactly-what-the-request-opens contract forbids:
265
+ * - `present`: only the builtin Standard / PTC / Cordis compositions mount the
266
+ * `@deepseek-ai/dsh-tool-present` row, and the web app disables the host one;
267
+ * - `web_fetch`: the per-session `tool-web` row below sets `fetch: false`,
268
+ * so this session opens `web_search` alone;
269
+ * - `workflow`: the delegation group ships that row `disabled: true` so no
270
+ * second model-authored orchestration surface sits beside `run_code`.
271
+ * The goal tools and `exit_plan_mode` ARE here, because the `tool-goal` and
272
+ * `plan-mode` rows below mount them.
273
+ *
274
+ * `run_code` is also absent: it is the transport the harness adds for a code
275
+ * presentation, not a row-mounted builtin, and the catalog never lists it as
276
+ * an entry — under `ptc` the program contract describes it, under `native` the
277
+ * request does not carry it.
278
+ *
279
+ * Adding a tool the preset mounts is the one edit an entry needs, and no test
280
+ * pins the exact text of any line: an operator reword is not a behavior change.
281
+ * That is why the table is exported — a test can prove every key is a tool name
282
+ * and every value is a single bounded line, without freezing the prose.
283
+ */
284
+
285
+ export const CURATED_TOOL_SUMMARIES = new Map([
286
+ ['bash', 'Run a command in a fresh bash shell (`command`, optional `timeoutMs`, `workdir`, `run_in_background`).'],
287
+ ['pwsh', 'Run a command in a fresh PowerShell process (`command`, optional `timeoutMs`, `workdir`, `run_in_background`); native Windows paths and `$env:NAME` variables.'],
288
+ ['read', 'Read one UTF-8 text file as line-numbered content (`file_path`, optional `offset` and `limit`).'],
289
+ ['read_image', 'Read a PNG/JPEG/WebP/GIF image file and return the image itself (`file_path`); large images are downscaled automatically.'],
290
+ ['write', 'Create or fully replace one UTF-8 text file (`file_path`, `content`).'],
291
+ ['edit', 'Replace literal text in one existing file (`file_path`, `old_string`, `new_string`, optional `replace_all`).'],
292
+ ['str_replace_editor', 'View, create, and edit files through one command tool (`command`, `path`, plus `file_text`, `old_str` / `new_str`, `insert_line`, `view_range`).'],
293
+ ['glob', 'Find files whose paths match a glob pattern (`pattern`, optional `path`); up to 100 paths in modification-time order.'],
294
+ ['grep', 'Search file contents with a ripgrep expression (`pattern`, optional `path`, optional `include`); matching lines with line numbers.'],
295
+ ['job_output', 'Read a background job: output since the previous read, or the finished result (`job_id`, optional `wait`, `timeout_ms`).'],
296
+ ['job_list', 'List the background jobs started by this session with their ids, kinds, and statuses.'],
297
+ ['job_kill', 'Request cancellation of a running background job (`job_id`, optional `reason`).'],
298
+ ['todo_write', 'Record and update the plan as one todo per concrete step (`todos`: content and status); skip it for trivial single-step work.'],
299
+ ['create_goal', 'Create a persisted goal that keeps this session working across automatic continuation rounds (`objective`, optional `max_goal_rounds`).'],
300
+ ['get_goal', 'Read the current session goal, including the id and revision that update_goal requires.'],
301
+ ['update_goal', 'Change one goal: edit, pause, resume, complete or blocked (`goal_id`, `revision`, `action`, plus `objective`, `max_goal_rounds`, `blocked_reason`).'],
302
+ ['exit_plan_mode', 'Present the completed plan for user review (`plan`, markdown starting with a title); approval is the only way out of plan mode.'],
303
+ ['subagent', 'Delegate a self-contained task to a subagent that works in its own context and returns its result, not its steps (`description`, `prompt`, optional `provider` / `model` / `reasoning_effort`).'],
304
+ ['subagent_fork', 'Delegate a task to a subagent seeded with this conversation (`description`, `prompt`); it inherits the parent route, so route fields are not accepted.'],
305
+ ['list_subagent_models', 'Discover the subagent routes this session authorizes (`provider`, optional `model`); the returned ids feed the delegation tools.'],
306
+ ['send_message', 'Send a message to a subagent started from this session (`agent_id`, `message`); the call confirms delivery, not the answer.'],
307
+ ['list_agents', 'List the subagents started from this session with their ids, labels, and status (`scope`).'],
308
+ ['interrupt_agent', 'Ask a subagent to stop its current work (`agent_id`); the call returns without waiting for it to settle.'],
309
+ ['ask_user_question', 'Ask the user a concise question and wait for the answer (`questions`: id, question, optional header, options, and custom input).'],
310
+ ['web_search', 'Search the web for current information (one to four `queries`); returns a merged summary and its source URLs.'],
311
+ ['skill', 'Load the full instructions of one session skill (`name`); call it before acting on a task that names or matches a skill.'],
312
+ ['tool_activate', 'Load one paged tool namespace back onto the wire and into the generated SDK (`namespace`, exactly as the catalog names it).'],
313
+ ['fact_register', 'Pin one key fact into the working context (`fact`, optional `tag`), or unpin with `revoke`; at most twelve short facts stay pinned.'],
314
+ ['ralph', 'Run a foreground fresh-agent Ralph loop toward one immutable objective (`objective`, optional `maxRounds`); only when the human explicitly asks for it.'],
315
+ ['list_mcp_resources', 'List the resources an MCP server exposes (`server`, optional `cursor`).'],
316
+ ['list_mcp_resource_templates', 'List the parameterized resource URI templates of one MCP server (`server`, optional `cursor`).'],
317
+ ['read_mcp_resource', 'Read one MCP resource by URI from the named server (`server`, `uri`).'],
318
+ ])
319
+
227
320
  /**
228
321
  * One-line model-facing summary of a tool description: whitespace collapsed,
229
322
  * truncated with an ellipsis when maxLength is specified.
@@ -234,6 +327,23 @@ export function catalogDescription(value, maxLength) {
234
327
  return `${normalized.slice(0, maxLength - 3)}...`
235
328
  }
236
329
 
330
+ /**
331
+ * The one-line summary one entry renders for a tool: the curated line when the
332
+ * table names it, otherwise the mechanically capped schema description. The
333
+ * order is the whole point — curation first, truncation only as the fallback
334
+ * for a tool nobody has written a line for yet.
335
+ * @param {{ name?: unknown, description?: unknown }} schema - one tool definition.
336
+ * @param {number} maxLength - the schema-description cap, in characters.
337
+ * @returns the summary text for the catalog entry.
338
+ */
339
+ export function toolSummary(schema, maxLength) {
340
+ const name = schema?.name
341
+ if (typeof name === 'string' && CURATED_TOOL_SUMMARIES.has(name)) {
342
+ return CURATED_TOOL_SUMMARIES.get(name)
343
+ }
344
+ return catalogDescription(schema?.description, maxLength)
345
+ }
346
+
237
347
  /** One scalar literal as TypeScript-ish text; non-JSON scalars degrade to the broad type. */
238
348
  function renderLiteral(value) {
239
349
  const json = JSON.stringify(value)
@@ -291,17 +401,19 @@ export function renderSignature(parameters) {
291
401
  /**
292
402
  * Catalog entries for one tool surface, sorted by name so an unchanged surface
293
403
  * renders byte-identical text across assemblies. Nameless definitions are
294
- * skipped; the `run_code` transport is listed only when the presentation puts
295
- * it on the wire beside the native tools ('both').
404
+ * skipped; the `run_code` transport never renders as an entry — under `ptc`
405
+ * the program contract describes it, under `native` the request does not
406
+ * carry it. Each entry's summary is resolved by {@link toolSummary}: the
407
+ * curated line where the table has one, the capped schema description
408
+ * otherwise.
296
409
  */
297
410
  export function catalogEntries(schemas, maxLength, options) {
298
- const includeRunCode = options?.includeRunCode === true
299
411
  const patterns = Array.isArray(options?.patterns) ? options.patterns : []
300
412
  const entries = []
301
413
  for (const schema of Array.isArray(schemas) ? schemas : []) {
302
414
  const toolName = schema?.name
303
415
  if (typeof toolName !== 'string' || toolName === '') continue
304
- if (toolName === 'run_code' && !includeRunCode) continue
416
+ if (toolName === 'run_code') continue
305
417
  // A tool from a paged family carries its namespace so the catalog can group
306
418
  // it the way the model calls it, instead of scattering one server's tools
307
419
  // through an alphabetical list.
@@ -309,7 +421,7 @@ export function catalogEntries(schemas, maxLength, options) {
309
421
  entries.push({
310
422
  name: toolName,
311
423
  signature: renderSignature(schema.parameters),
312
- description: catalogDescription(schema.description, maxLength),
424
+ description: toolSummary(schema, maxLength),
313
425
  ...(namespace === undefined ? {} : { namespace }),
314
426
  })
315
427
  }
@@ -333,29 +445,10 @@ const PTC_PROGRAM_LINES = [
333
445
  'A namespace this session has not activated with `tool_activate({ namespace: "..." })` is not listed above and cannot be reached from inside a program either: the page is a page on the whole surface, not only on the wire, and the paged-out list below names exactly what is withheld. Activating one puts its tools back into this list and back into a program from the next request on.',
334
446
  ]
335
447
 
336
- /**
337
- * The short note the catalog carries when `run_code` sits on the wire beside
338
- * the native roster ('both'): native calls are the primary surface, and the
339
- * transport covers programmatic batch work. The trigger is countable, because a
340
- * shape rule alone leaves the boundary to the model's judgement. Paged-out
341
- * namespaces stay reachable through the SDK inside a program even before
342
- * activation — the native wire carries every registered tool and 'both' leaves
343
- * the scope's registry unrestricted, so nothing removed them from the program's
344
- * own surface.
345
- */
346
- const BOTH_PROGRAM_LINES = [
347
- 'Prefer calling the tools above directly by name: ordinary single-step work (read, edit, bash, one search) goes through the native call, never through `run_code`. Reserve `run_code` for what a direct call cannot do — an async TypeScript body (`code`, with a short `description`) that reaches tools as `await tools.<name>({ ... })`, overlaps independent read-only calls under `Promise.all`, and catches `ToolCallError` to continue: programmatic batch computation, wide fan-out, or multi-step data shaping.',
348
- '',
349
- 'The trigger is countable: one intent with three or more independent targets, or intermediate results that do not belong in the conversation. Below that, call the tools directly. Every call inside a program must handle its own failure with `try/catch`, so the error chain a program produces is longer than a direct call — wrapping one-step work in a program to save a call pays that cost for nothing.',
350
- '',
351
- 'Paged-out namespaces stay off the NATIVE direct-call surface but stay reachable through the SDK inside a program even before activation — the native wire carries every registered tool and nothing removes the paged ones from the scope registry, so this is the reachability the wire itself carries rather than an exemption paging grants — and activating one also puts its tools back on the direct surface.',
352
- ]
353
-
354
448
  /**
355
449
  * Model-facing catalog text.
356
- * - Native presentation: the on-wire tool list plus the paged-out namespace summary.
357
- * - 'both': the on-wire list INCLUDING `run_code`, the namespace summary with
358
- * its direct-call-only reachability, and the short programmatic-escape note.
450
+ * - Native presentation: the on-wire tool list plus the paged-out namespace
451
+ * summary with its wire-only reachability.
359
452
  * - 'ptc' (wire collapsed to `run_code`): the SDK-reachable list plus the full
360
453
  * program contract naming `run_code` the one direct transport, and a
361
454
  * namespace summary whose page covers the whole surface.
@@ -389,13 +482,10 @@ export function renderCatalogText(entries, presentation = 'native', inactive = [
389
482
  // The paged-out summary states its own reachability per presentation, because
390
483
  // the presentations differ on exactly the fact a reader would otherwise have
391
484
  // to infer from the program contract further down: 'ptc' pages the whole
392
- // surface, 'both' pages the direct-call surface only while a program still
393
- // reaches what it withholds, and 'native' carries no program at all.
485
+ // surface, and 'native' carries no program at all.
394
486
  const inactiveReachability = presentation === 'ptc'
395
487
  ? 'The page covers the whole surface here, not the wire alone: these namespaces are unreachable from inside a program too until they are activated.'
396
- : presentation === 'both'
397
- ? 'Only the direct-call surface is paged here: a program still reaches these namespaces before activation, and activating one returns its tools to the direct-call surface as well.'
398
- : 'This presentation carries no program transport, so the wire is the only surface these namespaces can be reached through.'
488
+ : 'This presentation carries no program transport, so the wire is the only surface these namespaces can be reached through.'
399
489
  const inactiveBlock = inactive.length === 0 ? [] : [
400
490
  '',
401
491
  'These tool namespaces are registered but currently paged out of the wire:',
@@ -406,9 +496,7 @@ export function renderCatalogText(entries, presentation = 'native', inactive = [
406
496
  ]
407
497
  const presentationLines = presentation === 'ptc'
408
498
  ? ['', ...PTC_PROGRAM_LINES]
409
- : presentation === 'both'
410
- ? ['', ...BOTH_PROGRAM_LINES]
411
- : []
499
+ : []
412
500
  return [
413
501
  '<system-reminder>',
414
502
  'The following tools are available in this session:',
@@ -567,7 +655,7 @@ export function apply(ctx, config) {
567
655
  if (config?.anchorTools !== undefined) {
568
656
  warnOnce('anchor', 'anchor-turn staging is retired — the anchorTools key is accepted but no longer narrows the wire')
569
657
  }
570
- const presentation = resolvePresentation(config, detail => warnOnce('ptcPresentation', detail))
658
+ const presentation = resolvePresentation(config, detail => warnOnce(`presentation:${detail}`, detail))
571
659
 
572
660
  // Per-agent fresh state evaluated on every assembly (never stale across steps/turns)
573
661
  const agentCatalogState = new WeakMap()
@@ -668,10 +756,8 @@ export function apply(ctx, config) {
668
756
  * GATED ON THE WIRE ACTUALLY COLLAPSING, not on the configuration asking for
669
757
  * it. Both halves of that gate matter, and each covers a deployment where
670
758
  * paging at the registry would be wrong:
671
- * - `presentation === 'ptc'` is what the operator configured, and it excludes
672
- * `both`, whose documented contract is that a paged-out namespace stays
673
- * reachable through the SDK inside a program before activation. Installing
674
- * the restriction there would break that contract for the first request;
759
+ * - `presentation === 'ptc'` is what the operator configured, and it is the
760
+ * only presentation whose registry is the whole reachable surface;
675
761
  * - `agentDeclared.has(agent)` is the scope's own declaration actually
676
762
  * landing, which is NOT the same as `transportReady()`. A deployment with
677
763
  * no mounted code runtime (and one whose host declines the declaration)
@@ -874,8 +960,7 @@ export function apply(ctx, config) {
874
960
  // transport and lists the tools from their SDK projection. Where no
875
961
  // projection can be read at all, declaring would collapse the executor and
876
962
  // then have to undo it, losing the native wire on the way out. Stay native
877
- // instead. Under 'both' the native roster stays on the wire either way, so
878
- // the declaration needs no projection guard.
963
+ // instead.
879
964
  const projectable = publicSchemas(agent)
880
965
  if (presentation === 'ptc' && (projectable === undefined || projectable.length === 0)) {
881
966
  warnOnce('runtime', 'no tool schema projection available — keeping the native tool surface')
@@ -931,17 +1016,14 @@ export function apply(ctx, config) {
931
1016
 
932
1017
  // Under a collapsed `ptc` wire the registry is the ONLY surface a tool can
933
1018
  // be reached through, so the page is expressed as a registry restriction.
934
- // Every other wire still carries paging by itself on the assembled array,
935
- // and `both` deliberately stays unrestricted: that is what keeps its
936
- // documented "paged namespaces stay reachable through the SDK inside a
937
- // program" behavior intact. A wire that carries the native roster again (a
938
- // reverted declaration) must also drop a page left over from a collapsed
939
- // assembly, or the filter would keep hiding tools that wire just handed
940
- // back.
1019
+ // The native wire carries paging by itself on the assembled array. A wire
1020
+ // that carries the native roster again (a reverted declaration) must also
1021
+ // drop a page left over from a collapsed assembly, or the filter would keep
1022
+ // hiding tools that wire just handed back.
941
1023
  let surface = agent !== undefined ? publicSchemas(agent) : undefined
942
1024
  // The wire partition replays the durable log itself: `pagingState` exists
943
- // only where a restriction was installed (the collapsed ptc wire), and
944
- // native/both still page the assembled array from the same event stream.
1025
+ // only where a restriction was installed (the collapsed ptc wire), and the
1026
+ // native wire still pages the assembled array from the same event stream.
945
1027
  const activeNamespaces = new Set(
946
1028
  replayActivations(sessionEvents(agent?.session), maxActiveNamespaces, pagedToolPatterns).active,
947
1029
  )
@@ -961,13 +1043,12 @@ export function apply(ctx, config) {
961
1043
  }
962
1044
 
963
1045
  const effectiveWire = correctedWire ?? assembledTools
964
- const effectiveHasRunCode = (effectiveWire ?? []).some(t => t?.name === 'run_code')
965
1046
  const effectiveOnlyRunCode = effectiveWire !== undefined && effectiveWire.length > 0 && effectiveWire.every(t => t?.name === 'run_code')
966
1047
 
967
1048
  // The catalog describes the transport this request actually carries, never
968
- // the configuration's intent: a collapsed wire is 'ptc', run_code beside the
969
- // native roster is 'both', and anything else is native.
970
- const effectivePresentation = effectiveOnlyRunCode ? 'ptc' : (effectiveHasRunCode ? 'both' : 'native')
1049
+ // the configuration's intent: a collapsed wire is 'ptc', and anything else
1050
+ // is native.
1051
+ const effectivePresentation = effectiveOnlyRunCode ? 'ptc' : 'native'
971
1052
 
972
1053
  // Gentle paging: the active namespaces were replayed from the durable event
973
1054
  // stream above; here the paged-but-inactive tools come off the wire itself.
@@ -992,8 +1073,7 @@ export function apply(ctx, config) {
992
1073
  // The catalog describes this request's ACTUAL surface: with a live page it
993
1074
  // summarizes exactly the namespaces that page withholds (the same fact the
994
1075
  // restriction was built from), and otherwise the namespaces the WIRE
995
- // partition found — which under `both` stay reachable through the SDK
996
- // inside a program, as the programmatic-escape note below states.
1076
+ // partition found.
997
1077
  const catalogInactive = summarizeInactive(
998
1078
  pagingState?.inactive ?? inactive,
999
1079
  describe => catalogDescription(describe, descriptionMaxLength),
@@ -1006,10 +1086,7 @@ export function apply(ctx, config) {
1006
1086
  entries = catalogEntries(surface ?? [], descriptionMaxLength, { patterns: pagedToolPatterns })
1007
1087
  } else {
1008
1088
  const merged = mergeProjectedSchemas(resident, surface)
1009
- entries = catalogEntries(merged, descriptionMaxLength, {
1010
- includeRunCode: effectivePresentation === 'both',
1011
- patterns: pagedToolPatterns,
1012
- })
1089
+ entries = catalogEntries(merged, descriptionMaxLength, { patterns: pagedToolPatterns })
1013
1090
  }
1014
1091
  const inactiveSummary = catalogInactive
1015
1092
 
@@ -195,19 +195,12 @@ describe('dsh-liangshen preset declaration', () => {
195
195
  })
196
196
 
197
197
  it('operator gets the committed settings applied to the rows they shape', async () => {
198
- // Given committed presentation and guard settings, When the operator
199
- // activates the plugin, Then the declared rows carry those values.
200
- const { host } = await mount({ presentation: 'ptc', guardEnabled: false, guardEchoFailures: 5 })
198
+ // Given a committed presentation, When the operator activates the plugin,
199
+ // Then the declared tool-catalog row carries it.
200
+ const { host } = await mount({ presentation: 'native' })
201
201
  const rows = host.declarations[0]!.definition.plugins as readonly { id?: string, config?: Record<string, unknown> }[]
202
- expect(rows.find(row => row.id === 'tool-catalog')?.config?.['presentation']).toBe('ptc')
203
- // The echo override the operator committed is written; the two overrides
204
- // nobody set stay out of the row entirely, so the guard resolves them from
205
- // the session's reasoning effort and the sensitivity preset.
206
- expect(rows.find(row => row.id === 'guard')?.config).toEqual({
207
- enabled: false,
208
- sensitivity: 'balanced',
209
- echoFailures: 5,
210
- })
202
+ expect(rows.find(row => row.id === 'tool-catalog')?.config?.['presentation']).toBe('native')
203
+ expect(rows.find(row => row.id === 'guard')).toBeUndefined()
211
204
  })
212
205
 
213
206
  it('operator keeps the roster and the prompt untouched while the master switch is off', async () => {
@@ -224,7 +217,7 @@ describe('dsh-liangshen preset declaration', () => {
224
217
  // Then the preset is declared again and the previous declaration released.
225
218
  vi.resetModules()
226
219
  const mod = await import('../src/index.ts')
227
- let presentation = 'both'
220
+ let presentation = 'ptc'
228
221
  let announceToAgent = false
229
222
  const host = makeHost()
230
223
  mounted.push(host)
@@ -252,7 +245,7 @@ describe('dsh-liangshen preset declaration', () => {
252
245
  // last value and every predecessor is released.
253
246
  vi.resetModules()
254
247
  const mod = await import('../src/index.ts')
255
- let presentation = 'both'
248
+ let presentation = 'ptc'
256
249
  const host = makeHost()
257
250
  mounted.push(host)
258
251
  mod.apply(host.ctx, { presentation: { get: () => presentation } as never })
@@ -14,14 +14,11 @@ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-cli
14
14
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
15
15
  import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client'
16
16
  import { LiangShenMark } from './LiangShenMark.tsx'
17
- import { BooleanField, ChoiceField, PluginSettingsCard, ValueField } from './PluginSettingsCard.tsx'
18
- import { CardForm, booleanField, choiceField, numberField, type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts'
17
+ import { BooleanField, ChoiceField, PluginSettingsCard } from './PluginSettingsCard.tsx'
18
+ import { CardForm, booleanField, choiceField, type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts'
19
19
 
20
20
  /** Wire presentations the tool catalog accepts (mirrors the Host schema). */
21
- export const PRESENTATION_CHOICES = ['ptc', 'native', 'both'] as const
22
-
23
- /** Sensitivity presets for the circuit breaker (mirrors the Host schema). */
24
- export const SENSITIVITY_CHOICES = ['conservative', 'balanced', 'aggressive'] as const
21
+ export const PRESENTATION_CHOICES = ['ptc', 'native'] as const
25
22
 
26
23
  /** The LiangShen fields this card edits (the namespace's full schema). */
27
24
  export interface LiangShenSettings {
@@ -33,16 +30,6 @@ export interface LiangShenSettings {
33
30
  presentation?: string
34
31
  /** Whether the preset appends the dispatcher rules section after the persona. */
35
32
  dispatcher?: boolean
36
- /** Master switch for the runtime degeneration circuit breaker. */
37
- guardEnabled?: boolean
38
- /** Sensitivity preset scaling the breaker's adaptive thresholds. */
39
- guardSensitivity?: string
40
- /** Per-step reasoning-character floor for the breaker's runaway ladder. */
41
- guardStallReasoningChars?: number
42
- /** Consecutive output-free reasoning steps for the breaker's slow-burn ladder. */
43
- guardGlobalStallCap?: number
44
- /** Identical-argument tool failures for the breaker's echo ladder. */
45
- guardEchoFailures?: number
46
33
  }
47
34
 
48
35
  /** What the LiangShen card renders. */
@@ -51,11 +38,6 @@ export interface LiangShenSettingsCardState extends CardShell {
51
38
  announceToAgent: CardFieldState
52
39
  presentation: CardFieldState
53
40
  dispatcher: CardFieldState
54
- guardEnabled: CardFieldState
55
- guardSensitivity: CardFieldState
56
- guardStallReasoningChars: CardFieldState
57
- guardGlobalStallCap: CardFieldState
58
- guardEchoFailures: CardFieldState
59
41
  }
60
42
 
61
43
  /** The registration-side face the card's slot entry injects. */
@@ -78,11 +60,6 @@ export class LiangShenSettingsCardController {
78
60
  booleanField('announceToAgent'),
79
61
  choiceField('presentation', PRESENTATION_CHOICES),
80
62
  booleanField('dispatcher'),
81
- booleanField('guardEnabled'),
82
- choiceField('guardSensitivity', SENSITIVITY_CHOICES),
83
- numberField('guardStallReasoningChars', { integer: true, min: 200 }),
84
- numberField('guardGlobalStallCap', { integer: true, min: 2 }),
85
- numberField('guardEchoFailures', { integer: true, min: 2 }),
86
63
  ])
87
64
  this.store = this.form.bind(() => this.projection())
88
65
  }
@@ -94,11 +71,6 @@ export class LiangShenSettingsCardController {
94
71
  announceToAgent: this.form.field('announceToAgent'),
95
72
  presentation: this.form.field('presentation'),
96
73
  dispatcher: this.form.field('dispatcher'),
97
- guardEnabled: this.form.field('guardEnabled'),
98
- guardSensitivity: this.form.field('guardSensitivity'),
99
- guardStallReasoningChars: this.form.field('guardStallReasoningChars'),
100
- guardGlobalStallCap: this.form.field('guardGlobalStallCap'),
101
- guardEchoFailures: this.form.field('guardEchoFailures'),
102
74
  }
103
75
  }
104
76
 
@@ -193,60 +165,6 @@ export function LiangShenSettingsCard(props: LiangShenSettingsCardProps) {
193
165
  onEdit={(text) => { props.edit('dispatcher', text) }}
194
166
  onReset={() => { props.resetField('dispatcher') }}
195
167
  />
196
- <BooleanField
197
- id="settings-liangshen-guard-enabled"
198
- label={t('settings.guardEnabled')}
199
- hint={t('settings.guardEnabledHint')}
200
- onLabel={t('settings.on')}
201
- offLabel={t('settings.off')}
202
- {...fieldProps}
203
- {...state.guardEnabled}
204
- onEdit={(text) => { props.edit('guardEnabled', text) }}
205
- onReset={() => { props.resetField('guardEnabled') }}
206
- />
207
- <ChoiceField
208
- id="settings-liangshen-guard-sensitivity"
209
- label={t('settings.guardSensitivity')}
210
- hint={t('settings.guardSensitivityHint')}
211
- choices={SENSITIVITY_CHOICES.map(choice => ({ value: choice, label: t(`sensitivity.${choice}`) }))}
212
- {...fieldProps}
213
- {...state.guardSensitivity}
214
- onEdit={(text) => { props.edit('guardSensitivity', text) }}
215
- onReset={() => { props.resetField('guardSensitivity') }}
216
- />
217
- <ValueField
218
- id="settings-liangshen-guard-stall-chars"
219
- numeric
220
- label={t('settings.guardStallChars')}
221
- hint={t('settings.guardStallCharsHint')}
222
- placeholder={t('settings.guardAdaptive')}
223
- {...fieldProps}
224
- {...state.guardStallReasoningChars}
225
- onEdit={(text) => { props.edit('guardStallReasoningChars', text) }}
226
- onReset={() => { props.resetField('guardStallReasoningChars') }}
227
- />
228
- <ValueField
229
- id="settings-liangshen-guard-global-cap"
230
- numeric
231
- label={t('settings.guardGlobalCap')}
232
- hint={t('settings.guardGlobalCapHint')}
233
- placeholder={t('settings.guardAdaptive')}
234
- {...fieldProps}
235
- {...state.guardGlobalStallCap}
236
- onEdit={(text) => { props.edit('guardGlobalStallCap', text) }}
237
- onReset={() => { props.resetField('guardGlobalStallCap') }}
238
- />
239
- <ValueField
240
- id="settings-liangshen-guard-echo"
241
- numeric
242
- label={t('settings.guardEchoFailures')}
243
- hint={t('settings.guardEchoFailuresHint')}
244
- placeholder={t('settings.guardAdaptive')}
245
- {...fieldProps}
246
- {...state.guardEchoFailures}
247
- onEdit={(text) => { props.edit('guardEchoFailures', text) }}
248
- onReset={() => { props.resetField('guardEchoFailures') }}
249
- />
250
168
  </PluginSettingsCard>
251
169
  )
252
170
  }