@deepseek-ai/dsh-subagent-claude-code 0.1.2-rc.1 → 0.1.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/subagent/subagent-claude-code/README.md
5
- README.md: 7ec86fc2092f22fc82665d9660edb42a01a3d99c
6
- README.zh.md: 2ef2e957b19f56b664f79e429b067a59557373f8
5
+ README.md: 6f63a0338ba0e7f6223ca12c8b0739b21d8a44fa
6
+ README.zh.md: f097d14427bb28deaca9bbc3c259ac7d83755fe9
package/README.md CHANGED
@@ -47,7 +47,7 @@ Removing the package withdraws the provider and its private runtime closure on t
47
47
  | `model` | native Claude settings | Optional non-empty model name fixed for every run from this provider instance; omission sends no SDK override |
48
48
  | `env` | `{}` | Explicit SDK/CLI environment layered over the credential-scrubbed parent environment |
49
49
  | `permissionMode` | `dontAsk` | Native non-interactive permission policy fixed for every run from this provider instance |
50
- | `disposeGraceMs` | `3000` | Grace between the shared process-tree owner's termination tiers |
50
+ | `disposeGraceMs` | `3000` | Grace between the shared managed-range owner's termination tiers |
51
51
 
52
52
  | `permissionMode` value | Native behavior |
53
53
  |---|---|
@@ -109,7 +109,7 @@ This section explains how the provider drives a real Claude Code CLI and where t
109
109
  |---|---|
110
110
  | [`src/index.ts`](src/index.ts) | Plugin entry: config schema, provider registration |
111
111
  | [`src/run.ts`](src/run.ts) | The SDK query lifecycle, result acceptance, and permission handling |
112
- | [`src/process.ts`](src/process.ts) | Process-tree termination escalation on disposal |
112
+ | [`src/process.ts`](src/process.ts) | Managed-range termination escalation on disposal |
113
113
  | [`cordis.patch.yml`](cordis.patch.yml) | The Profile patch layer that registers the dormant provider |
114
114
 
115
115
  ### Run flow
@@ -194,4 +194,4 @@ This Dev Note is working context for maintainers: open questions and undecided d
194
194
 
195
195
  </details>
196
196
 
197
- **Runtime invariant:** No companion is published. Lifecycle pairing belongs to the shared subagent service and process-tree ownership belongs to the subprocess service.
197
+ **Runtime invariant:** No companion is published. Lifecycle pairing belongs to the shared subagent service, and managed-range ownership belongs to the subprocess service.
package/README.zh.md CHANGED
@@ -47,7 +47,7 @@ dsh --profile <name>
47
47
  | `model` | Claude 原生设置 | 为本提供方实例的每次运行固定的可选非空模型名称;省略时不发送 SDK 覆盖 |
48
48
  | `env` | `{}` | 叠加在已清理凭据的父环境之上的显式 SDK/CLI 环境 |
49
49
  | `permissionMode` | `dontAsk` | 为本提供方实例的每次运行固定的原生非交互权限策略 |
50
- | `disposeGraceMs` | `3000` | 共享进程树责任方各终止层级之间的宽限 |
50
+ | `disposeGraceMs` | `3000` | 共享 managed-range owner 各终止层级之间的宽限 |
51
51
 
52
52
  | `permissionMode` 值 | 原生行为 |
53
53
  |---|---|
@@ -109,7 +109,7 @@ dsh --profile <name>
109
109
  |---|---|
110
110
  | [`src/index.ts`](src/index.ts) | 插件入口:config schema、提供方注册 |
111
111
  | [`src/run.ts`](src/run.ts) | SDK query 生命周期、结果接受与权限处理 |
112
- | [`src/process.ts`](src/process.ts) | dispose 时的进程树逐级终止 |
112
+ | [`src/process.ts`](src/process.ts) | dispose 时的 managed-range 逐级终止 |
113
113
  | [`cordis.patch.yml`](cordis.patch.yml) | 注册休眠提供方的 Profile patch 层 |
114
114
 
115
115
  ### 运行流程
@@ -194,4 +194,4 @@ Claude Code 子级会在一个全新的 SDK query 中接收独立文本任务。
194
194
 
195
195
  </details>
196
196
 
197
- **运行时不变式:** 不发布伴生入口。生命周期配对属于共享 subagent service,process-tree 所有权属于 subprocess service。
197
+ **运行时不变式:** 不发布伴生入口。生命周期配对属于共享 subagent service,受管范围的所有权属于 subprocess service。
package/lib/index.js CHANGED
@@ -30,7 +30,7 @@ function sdkEnvironmentOverlay(env) {
30
30
  /**
31
31
  * Translate one official SDK spawn request to the shared process owner.
32
32
  * @param options - command, arguments, workspace, environment, and forwarded signal from the SDK.
33
- * @param graceMs - process-tree termination grace.
33
+ * @param graceMs - managed-range termination grace.
34
34
  * @returns the fully explicit shared subprocess request.
35
35
  */
36
36
  function claudeSpawnSpec(options, graceMs) {
@@ -61,7 +61,7 @@ var ManagedClaudeCodeProcess = class {
61
61
  killRequested = false;
62
62
  /**
63
63
  * Project a managed process with piped stdin and stdout.
64
- * @param child - shared handle that remains the process-tree authority.
64
+ * @param child - shared handle that remains the managed-range authority.
65
65
  */
66
66
  constructor(child) {
67
67
  this.child = child;
@@ -75,7 +75,7 @@ var ManagedClaudeCodeProcess = class {
75
75
  this.events.emit("error", thrown$1(error));
76
76
  });
77
77
  }
78
- /** Whether the SDK has requested managed tree termination. */
78
+ /** Whether the SDK has requested managed-range termination. */
79
79
  get killed() {
80
80
  return this.killRequested;
81
81
  }
@@ -92,7 +92,7 @@ var ManagedClaudeCodeProcess = class {
92
92
  return this.outcomeValue;
93
93
  }
94
94
  /**
95
- * Route the SDK's termination request to the tree-scoped process owner.
95
+ * Route the SDK's termination request to the managed-range process owner.
96
96
  * @param _signal - SDK-selected signal; the shared seam owns its escalation ladder.
97
97
  * @returns false only after exit or a previous termination request.
98
98
  */
@@ -120,7 +120,7 @@ var ManagedClaudeCodeProcess = class {
120
120
  /**
121
121
  * One-shot Claude Code lifecycle: invoke the official Agent SDK, place its
122
122
  * real CLI process under the shared subprocess owner, map only strict SDK
123
- * success to completion, and dispose to whole-tree quiescence.
123
+ * success to completion, and dispose to whole-range quiescence.
124
124
  *
125
125
  * @module @deepseek-ai/dsh-subagent-claude-code/run
126
126
  */
@@ -255,14 +255,18 @@ async function consumeClaudeQuery(query, onPermissionDenied, onResult) {
255
255
  };
256
256
  }
257
257
  /**
258
- * Close the official query, terminate the managed process tree, and wait for
259
- * the subprocess owner to prove it is gone.
258
+ * Close the official query, terminate the managed range, and wait for the
259
+ * subprocess owner to prove it is quiescent.
260
260
  * @param query - official SDK query, when creation reached that point.
261
- * @param child - live shared-service handle that owns the CLI process tree;
262
- * spawn-failed handles settle at the startup boundary instead.
261
+ * @param child - shared-service handle that owns the CLI managed range, including
262
+ * a published handle whose direct result later rejects.
263
263
  */
264
264
  async function disposeClaudeCodeChild(query, child) {
265
265
  const failures = [];
266
+ let outcome;
267
+ child.done.then((value) => {
268
+ outcome = value;
269
+ }, () => {});
266
270
  try {
267
271
  query?.close();
268
272
  } catch (error) {
@@ -274,13 +278,13 @@ async function disposeClaudeCodeChild(query, child) {
274
278
  } catch (error) {
275
279
  failures.push(thrown(error));
276
280
  }
277
- const outcome = await child.done;
278
281
  const firstFailure = failures[0];
279
282
  if (firstFailure !== void 0) throw new ClaudeCodeFailure({
280
283
  stage: "teardown",
281
284
  category: "unknown",
282
285
  outcome
283
286
  }, failures.length === 1 ? firstFailure : new AggregateError(failures, "Claude Code teardown failures"));
287
+ await child.done.catch(() => {});
284
288
  }
285
289
  /**
286
290
  * Build the fixed official SDK options for one one-shot provider run.
@@ -330,7 +334,7 @@ function claudeQueryOptions(spec, controller, capture, captureDiagnostic) {
330
334
  * Start one official Claude Agent SDK query and publish its one-shot run.
331
335
  * @param request - resolved shared subagent request.
332
336
  * @param spec - Workspace, environment, process service, and diagnostic policy.
333
- * @returns the published run after both Query and real CLI handle exist.
337
+ * @returns the published run after both Query and the real CLI handle exist.
334
338
  */
335
339
  async function startClaudeCodeRun(request, spec) {
336
340
  const prompt = textTask(request.prompt);
@@ -349,6 +353,8 @@ async function startClaudeCodeRun(request, spec) {
349
353
  } catch {}
350
354
  };
351
355
  let child;
356
+ let childFailure;
357
+ let childProcessFailure;
352
358
  let query$1;
353
359
  let managedProcess;
354
360
  let diagnostic;
@@ -362,14 +368,19 @@ async function startClaudeCodeRun(request, spec) {
362
368
  const captureChild = (captured, process) => {
363
369
  child = captured;
364
370
  managedProcess = process;
371
+ childProcessFailure = captured.done.then(() => new Promise(() => {}), (error) => {
372
+ childFailure = thrown(error);
373
+ throw childFailure;
374
+ });
375
+ childProcessFailure.catch(() => {});
365
376
  };
366
377
  try {
367
378
  query$1 = query({
368
379
  prompt,
369
380
  options: claudeQueryOptions(spec, controller, captureChild, capturePermissionDiagnostic)
370
381
  });
371
- if (child === void 0 || child.pid <= 0) throw new Error("subagent-claude-code: official SDK did not publish a controllable Claude Code process");
372
- if (controller.signal.aborted) throw new Error("subagent-claude-code: request was aborted before SDK startup");
382
+ if (child === void 0 || childProcessFailure === void 0) throw new Error("subagent-claude-code: official SDK did not publish a controllable Claude Code process");
383
+ if (isAborted(controller.signal)) throw new Error("subagent-claude-code: request was aborted before SDK startup");
373
384
  } catch (error) {
374
385
  request.signal.removeEventListener("abort", onAbort);
375
386
  const cancelledBeforeCleanup = controller.signal.aborted;
@@ -379,46 +390,23 @@ async function startClaudeCodeRun(request, spec) {
379
390
  category: "unknown",
380
391
  outcome: managedProcess?.outcome
381
392
  };
382
- const startupFailure = (cause = error) => new ClaudeCodeFailure(startupFacts, thrown(cause));
393
+ const startupFailure = (cause = childFailure ?? error) => new ClaudeCodeFailure(startupFacts, thrown(cause));
383
394
  requestCancel();
384
- if (child !== void 0 && child.pid <= 0) {
385
- let closeError;
395
+ if (child !== void 0) {
386
396
  try {
387
- query$1?.close();
397
+ await disposeClaudeCodeChild(query$1, child);
388
398
  } catch (disposeError) {
389
- closeError = thrown(disposeError);
390
- }
391
- let spawnError = thrown(error);
392
- try {
393
- await child.done;
394
- } catch (childError) {
395
- spawnError = thrown(childError);
396
- }
397
- if (closeError !== void 0) {
398
- const failure = startupFailure(spawnError);
399
- const cleanupFailure = new ClaudeCodeFailure({
400
- stage: "teardown",
401
- category: "unknown"
402
- }, closeError);
399
+ const failure = startupFailure();
400
+ const cleanupFailure = thrown(disposeError);
403
401
  const aggregate = new AggregateError([failure, cleanupFailure], `${failure.message}; ${cleanupFailure.message}`);
404
402
  reportFailure(aggregate);
405
403
  throw aggregate;
406
404
  }
407
405
  if (cancelledBeforeCleanup || isAborted(request.signal)) throw new Error("subagent-claude-code: request was aborted before SDK startup");
408
- const failure = startupFailure(spawnError);
406
+ const failure = startupFailure();
409
407
  reportFailure(failure);
410
408
  throw failure;
411
- }
412
- if (child !== void 0) try {
413
- await disposeClaudeCodeChild(query$1, child);
414
- } catch (disposeError) {
415
- const failure = startupFailure();
416
- const cleanupFailure = thrown(disposeError);
417
- const aggregate = new AggregateError([failure, cleanupFailure], `${failure.message}; ${cleanupFailure.message}`);
418
- reportFailure(aggregate);
419
- throw aggregate;
420
- }
421
- else if (query$1 !== void 0) try {
409
+ } else if (query$1 !== void 0) try {
422
410
  query$1.close();
423
411
  } catch (disposeError) {
424
412
  const failure = startupFailure();
@@ -437,15 +425,16 @@ async function startClaudeCodeRun(request, spec) {
437
425
  }
438
426
  const publishedQuery = query$1;
439
427
  const publishedChild = child;
428
+ const publishedProcessFailure = childProcessFailure;
440
429
  let receivedResult = false;
441
430
  const result = settleRunResult({
442
431
  attempt: async () => {
443
432
  try {
444
- return await consumeClaudeQuery(publishedQuery, () => {
433
+ return await Promise.race([consumeClaudeQuery(publishedQuery, () => {
445
434
  capturePermissionDiagnostic(unattendedDiagnostic(spec.permissionMode, "tool permission", "denied", "Claude Code denied the request before an interactive prompt"));
446
435
  }, () => {
447
436
  receivedResult = true;
448
- });
437
+ }), publishedProcessFailure]);
449
438
  } catch (error) {
450
439
  const processOutcome = managedProcess?.outcome;
451
440
  let facts;
@@ -28,7 +28,7 @@ export interface Config {
28
28
  * `bypassPermissions` explicitly skips permission checks.
29
29
  */
30
30
  permissionMode?: ClaudeCodePermissionMode;
31
- /** Grace in milliseconds for Claude Code process-tree termination. */
31
+ /** Grace in milliseconds between Claude Code managed-range termination tiers. */
32
32
  disposeGraceMs?: number;
33
33
  }
34
34
  export declare const Config: z<Config>;
@@ -15,7 +15,7 @@ export declare function sdkEnvironmentOverlay(env: SpawnOptions['env']): NodeJS.
15
15
  /**
16
16
  * Translate one official SDK spawn request to the shared process owner.
17
17
  * @param options - command, arguments, workspace, environment, and forwarded signal from the SDK.
18
- * @param graceMs - process-tree termination grace.
18
+ * @param graceMs - managed-range termination grace.
19
19
  * @returns the fully explicit shared subprocess request.
20
20
  */
21
21
  export declare function claudeSpawnSpec(options: SpawnOptions, graceMs: number): SubprocessSpawnSpec;
@@ -32,10 +32,10 @@ export declare class ManagedClaudeCodeProcess implements SpawnedProcess {
32
32
  private killRequested;
33
33
  /**
34
34
  * Project a managed process with piped stdin and stdout.
35
- * @param child - shared handle that remains the process-tree authority.
35
+ * @param child - shared handle that remains the managed-range authority.
36
36
  */
37
37
  constructor(child: SubprocessHandle);
38
- /** Whether the SDK has requested managed tree termination. */
38
+ /** Whether the SDK has requested managed-range termination. */
39
39
  get killed(): boolean;
40
40
  /** Direct-child exit code, or null while running or after signal exit. */
41
41
  get exitCode(): number | null;
@@ -44,7 +44,7 @@ export declare class ManagedClaudeCodeProcess implements SpawnedProcess {
44
44
  /** Exact managed-process outcome after exit, or undefined while running. */
45
45
  get outcome(): SubprocessOutcome | undefined;
46
46
  /**
47
- * Route the SDK's termination request to the tree-scoped process owner.
47
+ * Route the SDK's termination request to the managed-range process owner.
48
48
  * @param _signal - SDK-selected signal; the shared seam owns its escalation ladder.
49
49
  * @returns false only after exit or a previous termination request.
50
50
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * One-shot Claude Code lifecycle: invoke the official Agent SDK, place its
3
3
  * real CLI process under the shared subprocess owner, map only strict SDK
4
- * success to completion, and dispose to whole-tree quiescence.
4
+ * success to completion, and dispose to whole-range quiescence.
5
5
  *
6
6
  * @module @deepseek-ai/dsh-subagent-claude-code/run
7
7
  */
@@ -34,7 +34,7 @@ export interface ClaudeCodeRunSpec {
34
34
  readonly permissionMode: ClaudeCodePermissionMode;
35
35
  /** Explicit deployment/test environment layered after shared scrubbing. */
36
36
  readonly env: Record<string, string>;
37
- /** Subprocess termination grace passed to the shared process-tree owner. */
37
+ /** Subprocess termination grace passed to the shared managed-range owner. */
38
38
  readonly disposeGraceMs: number;
39
39
  /** Shared subprocess service spawn operation. */
40
40
  readonly spawn: (spec: SubprocessSpawnSpec) => SubprocessHandle;
@@ -63,11 +63,11 @@ export declare function successfulResult(message: SDKResultMessage): string;
63
63
  */
64
64
  export declare function consumeClaudeQuery(query: AsyncIterable<SDKMessage>, onPermissionDenied?: () => void, onResult?: () => void): Promise<SubagentResult>;
65
65
  /**
66
- * Close the official query, terminate the managed process tree, and wait for
67
- * the subprocess owner to prove it is gone.
66
+ * Close the official query, terminate the managed range, and wait for the
67
+ * subprocess owner to prove it is quiescent.
68
68
  * @param query - official SDK query, when creation reached that point.
69
- * @param child - live shared-service handle that owns the CLI process tree;
70
- * spawn-failed handles settle at the startup boundary instead.
69
+ * @param child - shared-service handle that owns the CLI managed range, including
70
+ * a published handle whose direct result later rejects.
71
71
  */
72
72
  export declare function disposeClaudeCodeChild(query: Pick<Query, 'close'> | undefined, child: SubprocessHandle): Promise<void>;
73
73
  /**
@@ -83,7 +83,7 @@ export declare function claudeQueryOptions(spec: ClaudeCodeRunSpec, controller:
83
83
  * Start one official Claude Agent SDK query and publish its one-shot run.
84
84
  * @param request - resolved shared subagent request.
85
85
  * @param spec - Workspace, environment, process service, and diagnostic policy.
86
- * @returns the published run after both Query and real CLI handle exist.
86
+ * @returns the published run after both Query and the real CLI handle exist.
87
87
  */
88
88
  export declare function startClaudeCodeRun(request: SubagentStartRequest, spec: ClaudeCodeRunSpec): Promise<SubagentRun>;
89
89
  //# sourceMappingURL=run.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-subagent-claude-code",
3
3
  "description": "One-shot Claude Code subagent provider over the official Agent SDK",
4
- "version": "0.1.2-rc.1",
4
+ "version": "0.1.3-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -34,37 +34,37 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@deepseek-ai/cordis": "^4.0.2",
37
- "@deepseek-ai/dsh-llm": "^0.1.2-rc.1",
38
- "@deepseek-ai/dsh-session": "^0.1.2-rc.1",
39
- "@deepseek-ai/dsh-subagent": "^0.1.2-rc.1",
40
- "@deepseek-ai/dsh-subprocess": "^0.1.2-rc.1",
41
- "@deepseek-ai/dsh-timeout": "^0.1.2-rc.1"
37
+ "@deepseek-ai/dsh-llm": "^0.1.3-alpha.2",
38
+ "@deepseek-ai/dsh-subagent": "^0.1.3-alpha.2",
39
+ "@deepseek-ai/dsh-subprocess": "^0.1.3-alpha.2",
40
+ "@deepseek-ai/dsh-timeout": "^0.1.3-alpha.2",
41
+ "@deepseek-ai/dsh-session": "^0.1.3-alpha.2"
42
42
  },
43
43
  "dependencies": {
44
44
  "@anthropic-ai/claude-agent-sdk": "0.3.241",
45
45
  "@anthropic-ai/sdk": "0.93.0",
46
46
  "@modelcontextprotocol/sdk": "^1.29.0",
47
47
  "zod": "^4.4.3",
48
- "@deepseek-ai/schemastery": "^3.18.2",
49
- "@deepseek-ai/dsh-brand": "^0.1.2-rc.1"
48
+ "@deepseek-ai/dsh-brand": "^0.1.3-alpha.2",
49
+ "@deepseek-ai/schemastery": "^3.18.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@deepseek-ai/cordis": "^4.0.2",
53
- "@deepseek-ai/dsh-agent": "^0.1.2-rc.1",
54
- "@deepseek-ai/dsh-app-boot": "^0.1.2-rc.1",
55
- "@deepseek-ai/dsh-llm": "^0.1.2-rc.1",
56
- "@deepseek-ai/dsh-loader-smoke": "^0.1.2-rc.1",
57
- "@deepseek-ai/dsh-session": "^0.1.2-rc.1",
58
- "@deepseek-ai/dsh-session-checkpoint-policy": "^0.1.2-rc.1",
59
- "@deepseek-ai/dsh-session-projection": "^0.1.2-rc.1",
60
- "@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.2-rc.1",
61
- "@deepseek-ai/dsh-subagent": "^0.1.2-rc.1",
62
- "@deepseek-ai/dsh-subagent-codex": "^0.1.2-rc.1",
63
- "@deepseek-ai/dsh-subprocess-local": "^0.1.2-rc.1",
64
- "@deepseek-ai/dsh-subprocess": "^0.1.2-rc.1",
65
- "@deepseek-ai/dsh-timeout": "^0.1.2-rc.1",
66
- "@deepseek-ai/dsh-tool-jobs": "^0.1.2-rc.1",
67
- "@deepseek-ai/dsh-tools": "^0.1.2-rc.1",
68
- "@deepseek-ai/dsh-tool-subagent": "^0.1.2-rc.1"
53
+ "@deepseek-ai/dsh-agent": "^0.1.3-alpha.2",
54
+ "@deepseek-ai/dsh-app-boot": "^0.1.3-alpha.2",
55
+ "@deepseek-ai/dsh-llm": "^0.1.3-alpha.2",
56
+ "@deepseek-ai/dsh-session": "^0.1.3-alpha.2",
57
+ "@deepseek-ai/dsh-session-checkpoint-policy": "^0.1.3-alpha.2",
58
+ "@deepseek-ai/dsh-loader-smoke": "^0.1.3-alpha.2",
59
+ "@deepseek-ai/dsh-session-projection": "^0.1.3-alpha.2",
60
+ "@deepseek-ai/dsh-subagent": "^0.1.3-alpha.2",
61
+ "@deepseek-ai/dsh-subprocess": "^0.1.3-alpha.2",
62
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.3-alpha.2",
63
+ "@deepseek-ai/dsh-timeout": "^0.1.3-alpha.2",
64
+ "@deepseek-ai/dsh-tool-jobs": "^0.1.3-alpha.2",
65
+ "@deepseek-ai/dsh-tools": "^0.1.3-alpha.2",
66
+ "@deepseek-ai/dsh-tool-subagent": "^0.1.3-alpha.2",
67
+ "@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.3-alpha.2",
68
+ "@deepseek-ai/dsh-subagent-codex": "^0.1.3-alpha.2"
69
69
  }
70
70
  }