@linxin666/dsh-liangshen 0.4.20 → 0.4.22

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-liangshen",
3
3
  "description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The host half declares the bundled preset to the harness's agent-preset registry at activation (declare = enabled), so the preset is selectable for new sessions without writing anything into the harness home; the preset keeps a minimal persona with standing working discipline while the harness's own user-role agent-instructions injection delivers the workspace instructions (the optional `instructionSource: system-prompt` mode lifts them into the prompt instead), and declares one tool presentation for the session's whole lifetime: `ptc` by default (the wire collapses to `run_code` and every other tool is reached through the generated SDK), with `native` as the explicit assembled-roster option. High-fan-out tool families (default `['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']`, while every host builtin stays resident; customizable via `pagedToolPatterns`) stay paged out of the wire and generated SDK until the preset's own `tool_activate` tool loads their namespace (LRU cap three, state replayed from the durable session event stream), and the tool catalog — exactly the reachable tools plus paged-out namespace summaries — and a one-line working-context projection travel as durable user messages republished only on change. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
4
- "version": "0.4.20",
4
+ "version": "0.4.22",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
8
- "node": ">=24.9.0"
8
+ "node": "^24.22.3 || >=26.13.1"
9
9
  },
10
10
  "main": "lib/index.js",
11
11
  "types": "lib/types/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dsh": {
27
27
  "engines": {
28
- "dsh": ">=0.2.2-rc.3"
28
+ "dsh": ">=0.2.3-alpha.2"
29
29
  },
30
30
  "bundle": {
31
31
  "patch": "./cordis.patch.yml"
@@ -42,25 +42,25 @@
42
42
  }
43
43
  },
44
44
  "peerDependencies": {
45
- "@deepseek-ai/dsh": ">=0.2.2-rc.3"
45
+ "@deepseek-ai/dsh": ">=0.2.3-alpha.2"
46
46
  },
47
47
  "dependencies": {
48
- "@deepseek-ai/schemastery": "^3.19.0"
48
+ "@deepseek-ai/schemastery": "~3.20.0-alpha.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@deepseek-ai/cordis": "^4.1.0",
52
- "@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.3",
53
- "@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.3",
54
- "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.3",
55
- "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.3",
56
- "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.3",
57
- "@deepseek-ai/dsh-client-store": "^0.2.2-rc.3",
58
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.3",
59
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.3",
60
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.3",
61
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.3",
62
- "@deepseek-ai/dsh-settings": "^0.2.2-rc.3",
63
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.3",
51
+ "@deepseek-ai/cordis": "~4.2.0-alpha.1",
52
+ "@deepseek-ai/dsh-agent-preset-registry": "^0.2.3-alpha.2",
53
+ "@deepseek-ai/dsh-api-remotes": "^0.2.3-alpha.2",
54
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.3-alpha.2",
55
+ "@deepseek-ai/dsh-client-connection": "^0.2.3-alpha.2",
56
+ "@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.2",
57
+ "@deepseek-ai/dsh-client-store": "^0.2.3-alpha.2",
58
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.3-alpha.2",
59
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.3-alpha.2",
60
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.3-alpha.2",
61
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.2",
62
+ "@deepseek-ai/dsh-settings": "^0.2.3-alpha.2",
63
+ "@deepseek-ai/dsh-system-prompt": "^0.2.3-alpha.2",
64
64
  "@testing-library/react": "^16.1.0",
65
65
  "@types/node": "^22.20.0",
66
66
  "@types/react": "~18.3.1",
@@ -266,16 +266,18 @@
266
266
  - id: fact-ledger
267
267
  name: ./fact-ledger.mjs
268
268
 
269
- # The child-route guard. The harness records a Session's authorized child
270
- # routes as a durable `subagent/model-selection-policy` event, but its own
269
+ # The child-route guard. The harness exposes a live `subagentModelSelection`
270
+ # service (`allowedRoutes()`) starting in 0.2.3-alpha.2 (and on older cohorts
271
+ # records `subagent/model-selection-policy` Session events), while its own
271
272
  # delegation tool only rejects an EXPLICIT route outside that list: a call that
272
273
  # names no `provider`/`model` inherits the parent route unchecked, and an
273
274
  # inherit-only tool such as `subagent_fork` cannot name one at all. This row
274
- # closes that gap on the preset plane — an allowlist-carrying Session must
275
- # resolve every policed delegation to an authorized route, and a refusal names
276
- # the routes that would work. It fails open on every fact it cannot read (no
277
- # policy event, no session registry, no registry probe), so a Host that cannot
278
- # answer keeps the harness's own delegation behavior.
275
+ # closes that gap on the preset plane — whenever an allowlist is active, every
276
+ # policed delegation must resolve to an authorized route, and a refusal names the
277
+ # routes that would work. It fails open on every fact it cannot read (no live
278
+ # service / policy event, invalid settings error, no session registry, no
279
+ # registry probe), so a Host that cannot answer keeps the harness's own
280
+ # delegation behavior.
279
281
  - id: subagent-routes
280
282
  name: ./subagent-routes.mjs
281
283
 
@@ -11,9 +11,11 @@
11
11
  * nobody named one — or, for `subagent_fork`, because the tool cannot name one
12
12
  * at all.
13
13
  *
14
- * This row closes that gap from the preset plane. Whenever the calling Session
15
- * (or the nearest ancestor that recorded one) carries an allowlist, every
16
- * delegation the row polices must resolve to an authorized route:
14
+ * This row closes that gap from the preset plane. Starting in 0.2.3-alpha.2,
15
+ * the live `subagentModelSelection` service exposes `allowedRoutes()` directly;
16
+ * on older Hosts without that service it falls back to the recorded
17
+ * `subagent/model-selection-policy` Session event. Whenever an allowlist is in
18
+ * force, every delegation the row polices must resolve to an authorized route:
17
19
  *
18
20
  * - `explicit` tools publish `provider`/`model`; the call must name a complete
19
21
  * pair, and that pair must be on the list;
@@ -140,6 +142,46 @@ export function policyRoutesOf(session) {
140
142
  return undefined
141
143
  }
142
144
 
145
+ /**
146
+ * Normalize a raw route array returned by a live `subagentModelSelection` service.
147
+ * @param entries - Raw route entries.
148
+ * @returns normalized routes, or undefined when invalid.
149
+ */
150
+ function normalizeRoutes(entries) {
151
+ if (!Array.isArray(entries)) return undefined
152
+ const routes = []
153
+ for (const entry of entries) {
154
+ const route = asRecord(entry)
155
+ const provider = asString(route?.['provider'])
156
+ const model = asString(route?.['model'])
157
+ if (provider === undefined || model === undefined) return undefined
158
+ routes.push({ provider, model })
159
+ }
160
+ return routes
161
+ }
162
+
163
+ /**
164
+ * Resolve authorized routes when the optional live `subagentModelSelection`
165
+ * service is mounted; when mounted, it is authoritative (returning `undefined`
166
+ * or throwing fails open without consulting stale session events).
167
+ * @param service - Optional `ctx.get('subagentModelSelection')` service instance.
168
+ * @returns `{ handled: true, routes }` when the live service is mounted, or
169
+ * `{ handled: false, routes: undefined }` when absent.
170
+ */
171
+ export function liveServiceRoutes(service) {
172
+ if (typeof service?.allowedRoutes !== 'function') {
173
+ return { handled: false, routes: undefined }
174
+ }
175
+ let raw
176
+ try {
177
+ raw = service.allowedRoutes()
178
+ } catch {
179
+ return { handled: true, routes: undefined }
180
+ }
181
+ if (raw === undefined) return { handled: true, routes: undefined }
182
+ return { handled: true, routes: normalizeRoutes(raw) }
183
+ }
184
+
143
185
  /**
144
186
  * Resolve the allowlist a delegation from this agent must respect: the agent's
145
187
  * own recorded policy, else the nearest ancestor Session that recorded one.
@@ -306,13 +348,17 @@ export function unauthorizedReason(toolName, provider, model, allowed) {
306
348
  export function delegationDenialReason(input) {
307
349
  const {
308
350
  agent, toolName, args, sessions,
351
+ modelSelection,
352
+ getModelSelection,
309
353
  explicitToolNames = DEFAULT_EXPLICIT_TOOLS,
310
354
  inheritToolNames = DEFAULT_INHERIT_TOOLS,
311
355
  probe,
312
356
  } = input ?? {}
313
357
  const mode = delegationModeOf(toolName, explicitToolNames, inheritToolNames)
314
358
  if (mode === undefined) return undefined
315
- const allowed = authorizedRoutesFor(agent, sessions)
359
+ const liveService = typeof getModelSelection === 'function' ? getModelSelection() : modelSelection
360
+ const live = liveServiceRoutes(liveService)
361
+ const allowed = live.handled ? live.routes : authorizedRoutesFor(agent, sessions)
316
362
  if (allowed === undefined) return undefined
317
363
  const named = namedRouteOf(args)
318
364
  const complete = named.provider !== undefined && named.model !== undefined
@@ -358,11 +404,13 @@ export function installSubagentRoutes(ctx, config = {}) {
358
404
  const explicitToolNames = Array.isArray(config.explicitTools) ? config.explicitTools : DEFAULT_EXPLICIT_TOOLS
359
405
  const inheritToolNames = Array.isArray(config.inheritTools) ? config.inheritTools : DEFAULT_INHERIT_TOOLS
360
406
  const sessions = typeof ctx?.get === 'function' ? ctx.get('sessions') : undefined
407
+ const getModelSelection = typeof ctx?.get === 'function' ? () => ctx.get('subagentModelSelection') : undefined
361
408
  return tools.guard(execution => delegationDenialReason({
362
409
  agent: execution?.agent,
363
410
  toolName: execution?.name,
364
411
  args: execution?.arguments,
365
412
  sessions,
413
+ getModelSelection,
366
414
  explicitToolNames,
367
415
  inheritToolNames,
368
416
  probe: (agent, toolName) => routeParameterProbe(tools, agent, toolName),