@dsh-workbench/shared 1.5.4-beta.0 → 1.5.4-beta.1

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.
@@ -7,6 +7,7 @@ interface ToolCallRoot {
7
7
  readonly name?: string;
8
8
  readonly phase?: string;
9
9
  readonly argsRaw?: string;
10
+ readonly subCalls?: readonly ToolCallRoot[];
10
11
  }
11
12
  interface ChatSnapshot {
12
13
  readonly nodes?: {
@@ -3,14 +3,28 @@ import { CodeBlock } from '@deepseek-ai/dsh-client-ui-primitives';
3
3
  import { ApprovalPlan } from './ApprovalPlan.js';
4
4
  import { CardBoundary } from './CardBoundary.js';
5
5
  import './ApprovalDetail.css';
6
+ const MAX_CALL_DEPTH = 64;
7
+ function findCall(root, callId, depth) {
8
+ if (root === undefined || depth > MAX_CALL_DEPTH)
9
+ return undefined;
10
+ if (root.callId === callId && root.phase === 'start')
11
+ return root;
12
+ for (const child of root.subCalls ?? []) {
13
+ const found = findCall(child, callId, depth + 1);
14
+ if (found !== undefined)
15
+ return found;
16
+ }
17
+ return undefined;
18
+ }
6
19
  function callOf(snapshot, callId) {
7
20
  if (callId === undefined)
8
21
  return undefined;
9
22
  for (const node of snapshot.nodes?.values() ?? []) {
10
23
  const root = node.kind === 'tool-call' ? node.data?.root : undefined;
11
- if (root?.callId !== callId || root.phase !== 'start')
24
+ const call = findCall(root, callId, 0);
25
+ if (call === undefined)
12
26
  continue;
13
- return { ...(root.name === undefined ? {} : { name: root.name }), argsRaw: root.argsRaw ?? '' };
27
+ return { ...(call.name === undefined ? {} : { name: call.name }), argsRaw: call.argsRaw ?? '' };
14
28
  }
15
29
  return undefined;
16
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/shared",
3
- "version": "1.5.4-beta.0",
3
+ "version": "1.5.4-beta.1",
4
4
  "description": "工作台与模块共享的纯代码与契约类型:类型、纯逻辑、哑组件、平台解析。宿主侧的东西从 /host 进(不影响浏览器产物)。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,8 +11,11 @@ interface ToolCallRoot {
11
11
  readonly name?: string;
12
12
  readonly phase?: string;
13
13
  readonly argsRaw?: string;
14
+ readonly subCalls?: readonly ToolCallRoot[];
14
15
  }
15
16
 
17
+ const MAX_CALL_DEPTH = 64;
18
+
16
19
  interface ChatSnapshot {
17
20
  readonly nodes?: { values(): Iterable<{ readonly kind?: string; readonly data?: { readonly root?: ToolCallRoot } }> };
18
21
  }
@@ -30,12 +33,23 @@ export interface ApprovalDetailProps {
30
33
  readonly renderShell?: ((input: ApprovalInput, t: Translate) => ReactNode) | undefined;
31
34
  }
32
35
 
36
+ function findCall(root: ToolCallRoot | undefined, callId: string, depth: number): ToolCallRoot | undefined {
37
+ if (root === undefined || depth > MAX_CALL_DEPTH) return undefined;
38
+ if (root.callId === callId && root.phase === 'start') return root;
39
+ for (const child of root.subCalls ?? []) {
40
+ const found = findCall(child, callId, depth + 1);
41
+ if (found !== undefined) return found;
42
+ }
43
+ return undefined;
44
+ }
45
+
33
46
  function callOf(snapshot: ChatSnapshot, callId: string | undefined): { name?: string; argsRaw: string } | undefined {
34
47
  if (callId === undefined) return undefined;
35
48
  for (const node of snapshot.nodes?.values() ?? []) {
36
49
  const root = node.kind === 'tool-call' ? node.data?.root : undefined;
37
- if (root?.callId !== callId || root.phase !== 'start') continue;
38
- return { ...(root.name === undefined ? {} : { name: root.name }), argsRaw: root.argsRaw ?? '' };
50
+ const call = findCall(root, callId, 0);
51
+ if (call === undefined) continue;
52
+ return { ...(call.name === undefined ? {} : { name: call.name }), argsRaw: call.argsRaw ?? '' };
39
53
  }
40
54
  return undefined;
41
55
  }