@khorsheed/dsh-local-agent-dsh 0.2.0 → 0.2.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.
@@ -21,11 +21,6 @@ export declare const zh: {
21
21
  'model.applied': string;
22
22
  'model.error': string;
23
23
  'auth.host': string;
24
- 'enable.title': string;
25
- 'enable.switch': string;
26
- 'enable.switch.aria': string;
27
- 'enable.on': string;
28
- 'enable.off': string;
29
24
  'live.title': string;
30
25
  'live.info.aria': string;
31
26
  'live.info': string;
@@ -61,11 +56,6 @@ export declare const en: {
61
56
  'model.applied': string;
62
57
  'model.error': string;
63
58
  'auth.host': string;
64
- 'enable.title': string;
65
- 'enable.switch': string;
66
- 'enable.switch.aria': string;
67
- 'enable.on': string;
68
- 'enable.off': string;
69
59
  'live.title': string;
70
60
  'live.info.aria': string;
71
61
  'live.info': string;
@@ -21,11 +21,6 @@ export const zh = {
21
21
  'model.applied': '已保存,下一轮委派生效;进行中的轮次不受影响',
22
22
  'model.error': '保存失败,请重试',
23
23
  'auth.host': 'dsh 凭据走宿主实例的凭证设置,无需单独登录。',
24
- 'enable.title': 'DeepSeek 委派',
25
- 'enable.switch': '启用',
26
- 'enable.switch.aria': 'DeepSeek 委派开关',
27
- 'enable.on': '已开启:模型可使用 subagent_dsh 委派给本机 dsh',
28
- 'enable.off': '已关闭:委派只走官方内置子代理工具',
29
24
  'live.title': '常驻模式(live)',
30
25
  'live.info.aria': '常驻模式说明',
31
26
  'live.info': '常驻模式 = 成员进程常驻:输出实时流入成员会话、取消不杀进程、崩溃后自动续上原会话;关闭则每轮独立进程,跑完一次性出结果。设置为全局偏好,对所有后续委派生效。',
@@ -53,11 +48,6 @@ export const en = {
53
48
  'model.applied': 'Saved — takes effect on the next delegation round; rounds in flight are unaffected',
54
49
  'model.error': 'Save failed, please retry',
55
50
  'auth.host': 'dsh authenticates through the host instance’s credential settings — no separate sign-in.',
56
- 'enable.title': 'DeepSeek delegation',
57
- 'enable.switch': 'Enabled',
58
- 'enable.switch.aria': 'DeepSeek delegation switch',
59
- 'enable.on': 'ON: the model can delegate to the local dsh via subagent_dsh',
60
- 'enable.off': 'OFF: delegation goes through the official in-process subagent tool only',
61
51
  'live.title': 'Resident mode (live)',
62
52
  'live.info.aria': 'About resident mode',
63
53
  'live.info': 'Resident mode keeps the member process alive: output streams into the member session in real time, cancelling does not kill the process, and a crash resumes the same session. Off means every round runs as an independent one-shot process. The setting is global and applies to every later delegation.',
@@ -26,7 +26,6 @@ import { dirname } from 'node:path';
26
26
  import { fileURLToPath } from 'node:url';
27
27
  import z from '@deepseek-ai/schemastery';
28
28
  import { settingsFace, vol } from '@khorsheed/dsh-local-agent';
29
- import { mountSubagentDelegationTool } from '@khorsheed/dsh-local-agent/tool-factory';
30
29
  import { CONTAINER_NODE_OPTIONS, DshCliProvider, dshCliVersion } from './dsh-cli-provider.js';
31
30
  import { DEFAULT_LIVE_IDLE_MS } from './live-driver.js';
32
31
  import { LiveDriverSwitch } from './live-switch.js';
@@ -57,7 +56,7 @@ export const inject = ['localAgent', 'subagents', 'subprocess', 'credentials', '
57
56
  */
58
57
  const SETTINGS_FIELDS = {
59
58
  enabled: z.boolean().default(false),
60
- live: z.boolean().default(false),
59
+ live: z.boolean().default(true),
61
60
  liveMirrorGranularity: z.union([z.const('event'), z.const('token')]).default('token'),
62
61
  // `model` deliberately carries NO default: an unset key must resolve to
63
62
  // undefined, which is what keeps the pre-key behavior byte-identical.
@@ -97,27 +96,6 @@ export const DSH_SETTINGS_NAMESPACE = 'local-agent-dsh';
97
96
  * the YAML config's deployment defaults through the composition base.
98
97
  */
99
98
  const DSH_SETTINGS_SCHEMA = z.object(SETTINGS_FIELDS);
100
- /** The delegation tool the toggle mounts while ON. */
101
- const DSH_TOOL_NAME = 'subagent_dsh';
102
- /**
103
- * This package's own name, passed to the family tool factory as the
104
- * tool-origin owner (AGENTS.md § Tool origin tagging — a shared factory never
105
- * hardcodes an owner), the same pattern the worktrees/room `./tool` entries
106
- * use.
107
- */
108
- const PACKAGE_NAME = '@khorsheed/dsh-local-agent-dsh';
109
- /**
110
- * The `subagent_dsh` mount, as a plugin object over the family factory: the
111
- * toggle owns its lifecycle, so it mounts dynamically through `ctx.plugin`
112
- * instead of shipping a `./tool` composition row like the CLI providers.
113
- */
114
- const dshSubagentTool = {
115
- name: 'local-agent-dsh-tool',
116
- inject: ['tools', 'subagents', 'localAgent'],
117
- apply: (toolCtx) => {
118
- mountSubagentDelegationTool(toolCtx, { provider: 'dsh-cli', toolName: DSH_TOOL_NAME }, PACKAGE_NAME);
119
- },
120
- };
121
99
  /**
122
100
  * Mount the toggle controller: register the settings namespace, then mirror
123
101
  * its value into harness/provider/tool registrations, live.
@@ -133,7 +111,7 @@ export function apply(ctx, config) {
133
111
  // card's writes without a reload.
134
112
  const readSettings = () => ({
135
113
  enabled: vol(config.enabled) ?? false,
136
- live: vol(config.live) ?? false,
114
+ live: vol(config.live) ?? true,
137
115
  liveMirrorGranularity: vol(config.liveMirrorGranularity) ?? 'token',
138
116
  model: vol(config.model),
139
117
  recentModels: vol(config.recentModels) ?? [],
@@ -146,6 +124,8 @@ export function apply(ctx, config) {
146
124
  }
147
125
  const face = settingsFace(ctx, {
148
126
  namespace: DSH_SETTINGS_NAMESPACE,
127
+ // Card writes live in the harness's own store (card-settings.ts), never the profile patch.
128
+ harness: 'dsh',
149
129
  legacySchema: DSH_SETTINGS_SCHEMA,
150
130
  legacyBase,
151
131
  read: readSettings,
@@ -326,7 +306,6 @@ export function apply(ctx, config) {
326
306
  return;
327
307
  currentEnabled = enabled;
328
308
  generation += 1;
329
- const gen = generation;
330
309
  for (const dispose of disposers.splice(0))
331
310
  dispose();
332
311
  if (!enabled)
@@ -353,20 +332,13 @@ export function apply(ctx, config) {
353
332
  currentLiveSwitch = undefined;
354
333
  liveSwitch.dispose();
355
334
  });
356
- // The family delegation tool is mounted dynamically so the toggle owns
357
- // its lifecycle — while OFF the model never sees `subagent_dsh`.
358
- void ctx.plugin(dshSubagentTool).then((fiber) => {
359
- if (gen !== generation) {
360
- void fiber.dispose();
361
- return;
362
- }
363
- disposers.push(() => { void fiber.dispose(); });
364
- }, (error) => {
365
- ctx.logger.warn(`local-agent-dsh: delegation tool mount failed: ${error instanceof Error ? error.message : String(error)}`);
366
- });
335
+ // The delegation tool is this package's `./tool` entry, granted per
336
+ // session by a preset (src/tool.ts) — never mounted at the profile root.
367
337
  };
368
- sync(face.get().enabled);
369
- const unwatch = face.watch((next) => { sync(next.enabled); });
338
+ // Always on: installing the plugin is the intent (the card's 启用 switch
339
+ // is gone); a preset still decides which sessions see `subagent_dsh`.
340
+ sync(true);
341
+ const unwatch = () => { };
370
342
  return () => {
371
343
  modelCatalog.dispose();
372
344
  unwatch();
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The session-granted `subagent_dsh` delegation tool — this package's
3
+ * `./tool` composition entry (the worktrees 0.3.0 / room 0.2.0 fold pattern)
4
+ * for agent-preset compositions. The row provides NO service (the
5
+ * preset-mount isolate-realm rule forbids service rows); it registers the
6
+ * model-facing tool into the host tools registry through the family factory
7
+ * (`@khorsheed/dsh-local-agent/tool-factory`), delegating to the `dsh-cli`
8
+ * provider this package's main row registers at the profile root — the
9
+ * official tool-row shape (the shipped `tool-bash` rows work the same way).
10
+ * Granting is therefore per-session: a preset names the row
11
+ * (`- id: tool-subagent-dsh / name: '@khorsheed/dsh-local-agent-dsh/tool'`),
12
+ * its sessions get the tool; every other preset's sessions do not.
13
+ *
14
+ * This row replaced the dsh package's own dynamic mount: the tool used to
15
+ * mount at the profile root while the card's 启用 switch was on, which granted
16
+ * every session. With the switch gone (the harness is always registered), the
17
+ * tool follows the other providers — a preset names the row to grant it.
18
+ *
19
+ * @module @khorsheed/dsh-local-agent-dsh/tool
20
+ */
21
+ import type { Context } from '@deepseek-ai/cordis';
22
+ import type z from '@deepseek-ai/schemastery';
23
+ /** Cordis plugin name used by loader diagnostics. */
24
+ export declare const name = "local-agent-dsh-tool";
25
+ /**
26
+ * The family core's `localAgent` service is a declared inject (the
27
+ * owning-family companion exception to the community-service probe rule): a
28
+ * preset's standing scope mounts at registry-activation time, BEFORE the
29
+ * profile's later bundle rows provide the core, so a one-shot ctx.get probe
30
+ * at apply saw ABSENT there and nothing re-ran the row (rc.1 boot order; the
31
+ * worktrees `./tool` entry documents the incident). The declared inject pends
32
+ * the row until the core provides, then the body applies.
33
+ */
34
+ export declare const inject: string[];
35
+ /** Config: every field optional, defaulting to THIS provider's own values. */
36
+ export interface Config {
37
+ /** The `ctx.subagents` provider name to delegate to (default `dsh-cli`). */
38
+ provider?: string;
39
+ /** Model-facing tool name (default `subagent_dsh`). */
40
+ toolName?: string;
41
+ }
42
+ export declare const Config: z;
43
+ /**
44
+ * Plugin body: mount the delegation tool through the family factory, stamped
45
+ * with THIS package as the tool-origin owner (AGENTS.md § Tool origin
46
+ * tagging — the shared factory never hardcodes an owner).
47
+ * @param ctx - Cordis context (the preset's agent-plane mount).
48
+ * @param config - row config (schema defaults already applied; the `??`
49
+ * fallbacks cover a direct ctx.plugin caller that bypassed validation).
50
+ */
51
+ export declare function apply(ctx: Context, config: Config): void;
52
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { mountSubagentDelegationTool, subagentToolConfigSchema } from '@khorsheed/dsh-local-agent/tool-factory';
2
+ const PACKAGE_NAME = '@khorsheed/dsh-local-agent-dsh';
3
+ /** This entry's own defaults: a preset row needs no config. */
4
+ const DEFAULT_PROVIDER = 'dsh-cli';
5
+ const DEFAULT_TOOL_NAME = 'subagent_dsh';
6
+ /** Cordis plugin name used by loader diagnostics. */
7
+ export const name = 'local-agent-dsh-tool';
8
+ /**
9
+ * The family core's `localAgent` service is a declared inject (the
10
+ * owning-family companion exception to the community-service probe rule): a
11
+ * preset's standing scope mounts at registry-activation time, BEFORE the
12
+ * profile's later bundle rows provide the core, so a one-shot ctx.get probe
13
+ * at apply saw ABSENT there and nothing re-ran the row (rc.1 boot order; the
14
+ * worktrees `./tool` entry documents the incident). The declared inject pends
15
+ * the row until the core provides, then the body applies.
16
+ */
17
+ export const inject = ['tools', 'subagents', 'localAgent'];
18
+ // Bare `z` annotation per the shared helper's variance note.
19
+ export const Config = subagentToolConfigSchema(DEFAULT_PROVIDER, DEFAULT_TOOL_NAME);
20
+ /**
21
+ * Plugin body: mount the delegation tool through the family factory, stamped
22
+ * with THIS package as the tool-origin owner (AGENTS.md § Tool origin
23
+ * tagging — the shared factory never hardcodes an owner).
24
+ * @param ctx - Cordis context (the preset's agent-plane mount).
25
+ * @param config - row config (schema defaults already applied; the `??`
26
+ * fallbacks cover a direct ctx.plugin caller that bypassed validation).
27
+ */
28
+ export function apply(ctx, config) {
29
+ const resolved = {
30
+ provider: config.provider ?? DEFAULT_PROVIDER,
31
+ toolName: config.toolName ?? DEFAULT_TOOL_NAME,
32
+ };
33
+ mountSubagentDelegationTool(ctx, resolved, PACKAGE_NAME);
34
+ }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "local-agent",
9
9
  "subagent"
10
10
  ],
11
- "version": "0.2.0",
11
+ "version": "0.2.2",
12
12
  "type": "module",
13
13
  "main": "lib/index.js",
14
14
  "types": "lib/types/index.d.ts",
@@ -29,6 +29,10 @@
29
29
  "types": "./lib/types/dsh-cli-provider.d.ts",
30
30
  "default": "./lib/dsh-cli-provider.js"
31
31
  },
32
+ "./tool": {
33
+ "types": "./lib/types/tool.d.ts",
34
+ "default": "./lib/tool.js"
35
+ },
32
36
  "./client": {
33
37
  "types": "./lib/types/client/index.d.ts",
34
38
  "default": "./lib/client.js"
@@ -36,7 +40,8 @@
36
40
  "./src/*": "./src/*",
37
41
  "./cordis.patch.yml": "./cordis.patch.yml",
38
42
  "./package.json": "./package.json",
39
- "./locale/*.json": "./locale/*.json"
43
+ "./locale/*.json": "./locale/*.json",
44
+ "./tool/locale/*.json": "./locale/*.json"
40
45
  },
41
46
  "dsh": {
42
47
  "references": [
@@ -75,8 +80,8 @@
75
80
  "dsh": ">=0.1.5-rc.1 <0.3.0-0"
76
81
  },
77
82
  "dependencies": {
78
- "@khorsheed/dsh-local-agent": "^0.2.0",
79
- "@khorsheed/dsh-local-agent-dsh-headless": "^0.2.0",
83
+ "@khorsheed/dsh-local-agent": "^0.2.2",
84
+ "@khorsheed/dsh-local-agent-dsh-headless": "^0.2.2",
80
85
  "js-yaml": "^4.3.1"
81
86
  },
82
87
  "peerDependencies": {