@nexface/inspector 0.1.14 → 0.1.15-alpha.0

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/dist/bootstrap.js CHANGED
@@ -20,7 +20,9 @@ function installNexfaceDevtoolsBootstrap() {
20
20
  const originalCommit = existing.onCommitFiberRoot;
21
21
  const originalUnmount = existing.onCommitFiberUnmount;
22
22
  existing.inject = function inject(renderer) {
23
- const id = originalInject ? originalInject.call(this, renderer) : ++fallbackRendererId;
23
+ const id = originalInject
24
+ ? originalInject.call(this, renderer)
25
+ : ++fallbackRendererId;
24
26
  store.publishRenderer(id, renderer);
25
27
  return id;
26
28
  };
@@ -63,3 +65,4 @@ function installNexfaceDevtoolsBootstrap() {
63
65
  if (process.env.NODE_ENV !== "production") {
64
66
  installNexfaceDevtoolsBootstrap();
65
67
  }
68
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,2BAA2B,CAAC;AAgBnC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AAC7E,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAE3B,SAAS,+BAA+B;IACtC,MAAM,MAAM,GAAG,UAAwC,CAAC;IACxD,MAAM,KAAK,GAAG,uBAAuB,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,8BAA8B,CAAC;IAEvD,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;YACtD,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC3B,KAAK,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AC,CAAC;QACF,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;QACpC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,GAAiB;QACzB,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,QAAQ;QACnB,MAAM,CAAC,QAAQ;YACb,MAAM,EAAE,GAAG,EAAE,kBAAkB,CAAC;YAChC,KAAK,CAAC,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YACpC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,iBAAiB,CAAC,EAAE,EAAE,IAAI;YACxB,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,KAAK,CAAC,WAAW,CAAC,EAAE,EAAE,IAAyB,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,oBAAoB;YAClB,KAAK,CAAC,cAAc,EAAE,CAAC;QACzB,CAAC;QACD,qBAAqB,KAAI,CAAC;KAC3B,CAAC;IACF,MAAM,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAC5C,IAAoD,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAChF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IAC1C,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n getNexfaceDevtoolsStore,\n type ReactDevtoolsRenderer,\n type ReactDevtoolsRoot,\n} from \"./react-devtools-store.js\";\n\ntype DevtoolsHook = {\n renderers?: Map<unknown, ReactDevtoolsRenderer>;\n getFiberRoots?: (rendererId: unknown) => Set<ReactDevtoolsRoot>;\n inject?: (renderer: ReactDevtoolsRenderer) => unknown;\n onCommitFiberRoot?: (...args: unknown[]) => void;\n onCommitFiberUnmount?: (...args: unknown[]) => void;\n onPostCommitFiberRoot?: (...args: unknown[]) => void;\n supportsFiber?: boolean;\n};\n\ntype BootstrapGlobal = {\n __REACT_DEVTOOLS_GLOBAL_HOOK__?: DevtoolsHook;\n};\n\nconst wrappedHookSymbol = Symbol.for(\"@nexface/react-devtools-hook-wrapped\");\nlet fallbackRendererId = 0;\n\nfunction installNexfaceDevtoolsBootstrap(): Map<unknown, ReactDevtoolsRenderer> {\n const target = globalThis as unknown as BootstrapGlobal;\n const store = getNexfaceDevtoolsStore();\n const registry = store.renderers;\n const existing = target.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n\n if (existing) {\n for (const [id, renderer] of existing.renderers ?? []) {\n registry.set(id, renderer);\n for (const root of existing.getFiberRoots?.(id) ?? []) {\n store.publishRoot(id, root);\n }\n }\n const hookState = existing as DevtoolsHook & Record<PropertyKey, unknown>;\n if (hookState[wrappedHookSymbol]) return registry;\n const originalInject = existing.inject;\n const originalCommit = existing.onCommitFiberRoot;\n const originalUnmount = existing.onCommitFiberUnmount;\n existing.inject = function inject(renderer) {\n const id = originalInject\n ? originalInject.call(this, renderer)\n : ++fallbackRendererId;\n store.publishRenderer(id, renderer);\n return id;\n };\n existing.onCommitFiberRoot = function onCommitFiberRoot(...args) {\n originalCommit?.apply(this, args);\n const [id, root] = args;\n if (root && typeof root === \"object\") {\n store.publishRoot(id, root as ReactDevtoolsRoot);\n }\n };\n existing.onCommitFiberUnmount = function onCommitFiberUnmount(...args) {\n originalUnmount?.apply(this, args);\n store.publishUnmount();\n };\n hookState[wrappedHookSymbol] = true;\n return registry;\n }\n\n const hook: DevtoolsHook = {\n supportsFiber: true,\n renderers: registry,\n inject(renderer) {\n const id = ++fallbackRendererId;\n store.publishRenderer(id, renderer);\n return id;\n },\n onCommitFiberRoot(id, root) {\n if (root && typeof root === \"object\") {\n store.publishRoot(id, root as ReactDevtoolsRoot);\n }\n },\n onCommitFiberUnmount() {\n store.publishUnmount();\n },\n onPostCommitFiberRoot() {},\n };\n target.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;\n (hook as DevtoolsHook & Record<PropertyKey, unknown>)[wrappedHookSymbol] = true;\n return registry;\n}\n\nif (process.env.NODE_ENV !== \"production\") {\n installNexfaceDevtoolsBootstrap();\n}\n"]}
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { AgentInspectorPanel as AgentInspector, } from "./panel.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,IAAI,cAAc,GAEtC,MAAM,YAAY,CAAC","sourcesContent":["export {\n AgentInspectorPanel as AgentInspector,\n type AgentInspectorProps,\n} from \"./panel.js\";\n"]}
package/dist/panel.js CHANGED
@@ -1,4 +1,3 @@
1
- import { getRuntimeController } from "./shared/runtime-controller.js";
2
1
  import * as React from "react";
3
2
  import { useEffect, useMemo, useRef, useState, } from "react";
4
3
  import { createPortal } from "react-dom";
@@ -7,11 +6,10 @@ import { collectRuntimeToolSnapshot, reactDevtoolsRoots, runtimeToolRegionRects,
7
6
  import { useExecutionHistory } from "./use-execution-history.js";
8
7
  const pageToolNames = new Set(["nxf_getSnapshot", "nxf_executeAction", "nxf_applyAction"]);
9
8
  function applicationTools(runtime) {
10
- return getRuntimeController(runtime)
11
- .getRegisteredTools()
9
+ return runtime.getTools()
12
10
  .map((tool) => tool.definition)
13
11
  .filter((tool) => !pageToolNames.has(tool.name))
14
- .sort((left, right) => (left.name < right.name ? -1 : left.name > right.name ? 1 : 0));
12
+ .sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
15
13
  }
16
14
  const styles = `
17
15
  :host { all: initial; }
@@ -71,15 +69,9 @@ textarea { width: 100%; min-height: 96px; margin-top: 9px; padding: 9px; border:
71
69
  @media (max-width: 620px) { .layout { grid-template-columns: 1fr; } .list { max-height: 190px; border-right: 0; border-bottom: 1px solid #e6e9ef; } }
72
70
  `;
73
71
  function executionStatus(record) {
74
- return record.status === "running"
75
- ? "执行中"
76
- : record.status === "success"
77
- ? "成功"
78
- : record.cancelled
79
- ? "已取消"
80
- : "失败";
72
+ return record.status === "running" ? "执行中" : record.status === "success" ? "成功" : record.cancelled ? "已取消" : "失败";
81
73
  }
82
- function ExecutionValue({ title, snapshot, }) {
74
+ function ExecutionValue({ title, snapshot }) {
83
75
  const [feedback, setFeedback] = useState("");
84
76
  const copy = async () => {
85
77
  try {
@@ -94,7 +86,7 @@ function ExecutionValue({ title, snapshot, }) {
94
86
  React.createElement("div", { className: "record-heading" },
95
87
  React.createElement("span", { className: "section-title" }, title),
96
88
  React.createElement("button", { className: "copy", "aria-label": `复制${title}`, onClick: () => void copy() }, "\u590D\u5236")),
97
- snapshot.truncated ? (React.createElement("div", { className: "description" }, "\u5185\u5BB9\u5DF2\u622A\u65AD\uFF0C\u590D\u5236\u4EC5\u5305\u542B\u5DF2\u4FDD\u5B58\u7684\u6587\u672C\u3002")) : null,
89
+ snapshot.truncated ? React.createElement("div", { className: "description" }, "\u5185\u5BB9\u5DF2\u622A\u65AD\uFF0C\u590D\u5236\u4EC5\u5305\u542B\u5DF2\u4FDD\u5B58\u7684\u6587\u672C\u3002") : null,
98
90
  feedback ? React.createElement("div", { role: "status" }, feedback) : null,
99
91
  React.createElement("pre", null, snapshot.text)));
100
92
  }
@@ -147,27 +139,24 @@ function unionRect(rects) {
147
139
  return new DOMRect(left, top, right - left, bottom - top);
148
140
  }
149
141
  function sameRect(left, right) {
150
- return (left.left === right.left &&
151
- left.top === right.top &&
152
- left.width === right.width &&
153
- left.height === right.height);
142
+ return left.left === right.left && left.top === right.top &&
143
+ left.width === right.width && left.height === right.height;
154
144
  }
155
145
  function sameRegions(left, right) {
156
- return (left.length === right.length &&
157
- left.every((region, index) => {
158
- const candidate = right[index];
159
- return (candidate?.id === region.id &&
160
- candidate.ownerIds.length === region.ownerIds.length &&
161
- candidate.ownerIds.every((id, ownerIndex) => id === region.ownerIds[ownerIndex]) &&
162
- candidate.componentNames.length === region.componentNames.length &&
163
- candidate.componentNames.every((name, nameIndex) => name === region.componentNames[nameIndex]) &&
164
- candidate.toolNames.length === region.toolNames.length &&
165
- candidate.toolNames.every((name, nameIndex) => name === region.toolNames[nameIndex]) &&
166
- candidate.elements.length === region.elements.length &&
167
- candidate.elements.every((element, elementIndex) => element === region.elements[elementIndex]) &&
168
- candidate.rects.length === region.rects.length &&
169
- candidate.rects.every((rect, rectIndex) => sameRect(rect, region.rects[rectIndex])));
170
- }));
146
+ return left.length === right.length && left.every((region, index) => {
147
+ const candidate = right[index];
148
+ return candidate?.id === region.id &&
149
+ candidate.ownerIds.length === region.ownerIds.length &&
150
+ candidate.ownerIds.every((id, ownerIndex) => id === region.ownerIds[ownerIndex]) &&
151
+ candidate.componentNames.length === region.componentNames.length &&
152
+ candidate.componentNames.every((name, nameIndex) => name === region.componentNames[nameIndex]) &&
153
+ candidate.toolNames.length === region.toolNames.length &&
154
+ candidate.toolNames.every((name, nameIndex) => name === region.toolNames[nameIndex]) &&
155
+ candidate.elements.length === region.elements.length &&
156
+ candidate.elements.every((element, elementIndex) => element === region.elements[elementIndex]) &&
157
+ candidate.rects.length === region.rects.length &&
158
+ candidate.rects.every((rect, rectIndex) => sameRect(rect, region.rects[rectIndex]));
159
+ });
171
160
  }
172
161
  const emptyComponentSnapshot = {
173
162
  owners: [],
@@ -175,23 +164,20 @@ const emptyComponentSnapshot = {
175
164
  };
176
165
  const dragThreshold = 6;
177
166
  function sameOwners(left, right) {
178
- return (left.length === right.length &&
179
- left.every((owner, index) => {
180
- const candidate = right[index];
181
- return (candidate?.id === owner.id &&
182
- candidate.name === owner.name &&
183
- candidate.parentId === owner.parentId &&
184
- candidate.renderless === owner.renderless &&
185
- candidate.children.length === owner.children.length &&
186
- candidate.children.every((id, childIndex) => id === owner.children[childIndex]) &&
187
- candidate.toolNames.length === owner.toolNames.length &&
188
- candidate.toolNames.every((name, toolIndex) => name === owner.toolNames[toolIndex]));
189
- }));
167
+ return left.length === right.length && left.every((owner, index) => {
168
+ const candidate = right[index];
169
+ return candidate?.id === owner.id && candidate.name === owner.name &&
170
+ candidate.parentId === owner.parentId && candidate.renderless === owner.renderless &&
171
+ candidate.children.length === owner.children.length &&
172
+ candidate.children.every((id, childIndex) => id === owner.children[childIndex]) &&
173
+ candidate.toolNames.length === owner.toolNames.length &&
174
+ candidate.toolNames.every((name, toolIndex) => name === owner.toolNames[toolIndex]);
175
+ });
190
176
  }
191
177
  function sameComponentSnapshots(left, right) {
192
- return (left.rootIds.length === right.rootIds.length &&
178
+ return left.rootIds.length === right.rootIds.length &&
193
179
  left.rootIds.every((id, index) => id === right.rootIds[index]) &&
194
- sameOwners(left.owners, right.owners));
180
+ sameOwners(left.owners, right.owners);
195
181
  }
196
182
  function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHost, }) {
197
183
  const [open, setOpen] = useState(defaultOpen);
@@ -240,7 +226,8 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
240
226
  }
241
227
  }, [selectedName, tools]);
242
228
  useEffect(() => {
243
- if (selectedOwnerId && !componentSnapshot.owners.some(({ id }) => id === selectedOwnerId)) {
229
+ if (selectedOwnerId &&
230
+ !componentSnapshot.owners.some(({ id }) => id === selectedOwnerId)) {
244
231
  setSelectedOwnerId(undefined);
245
232
  }
246
233
  }, [componentSnapshot.owners, selectedOwnerId]);
@@ -292,11 +279,13 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
292
279
  }
293
280
  let scheduled;
294
281
  let usesAnimationFrame = false;
295
- const resizeObserver = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(() => refreshRects());
282
+ const resizeObserver = typeof ResizeObserver === "undefined"
283
+ ? undefined
284
+ : new ResizeObserver(() => refreshRects());
296
285
  const rebuild = () => {
297
286
  scheduled = undefined;
298
287
  const next = collectRuntimeToolSnapshot(reactDevtoolsRoots(), tools, overlayHost);
299
- setRegions((current) => (sameRegions(current, next.regions) ? current : next.regions));
288
+ setRegions((current) => sameRegions(current, next.regions) ? current : next.regions);
300
289
  setComponentSnapshot((current) => {
301
290
  const components = { owners: next.owners, rootIds: next.rootIds };
302
291
  return sameComponentSnapshots(current, components) ? current : components;
@@ -396,9 +385,7 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
396
385
  setRunning(true);
397
386
  setResult(undefined);
398
387
  try {
399
- const currentTool = getRuntimeController(runtime)
400
- .getRegisteredTools()
401
- .find((candidate) => candidate.definition === tool && !pageToolNames.has(candidate.definition.name));
388
+ const currentTool = runtime.getTools().find((candidate) => candidate.definition === tool && !pageToolNames.has(candidate.definition.name));
402
389
  if (!currentTool)
403
390
  throw new Error(`Tool "${tool.name}" is no longer registered.`);
404
391
  const nextResult = await runtime.execute(currentTool, parsedInput.value, {
@@ -540,12 +527,10 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
540
527
  : region.toolNames.includes(selectedName ?? "");
541
528
  const color = selectedRegion ? "#1769e0" : "#52a832";
542
529
  const label = `${region.componentNames.join(", ")} · ${region.toolNames.join(", ")}`;
543
- const title = region.toolNames
544
- .map((name) => {
530
+ const title = region.toolNames.map((name) => {
545
531
  const tool = tools.find((candidate) => candidate.name === name);
546
532
  return tool ? `${name}: ${tool.description}` : name;
547
- })
548
- .join("\n");
533
+ }).join("\n");
549
534
  return (React.createElement("button", { "aria-label": `Inspect ${region.componentNames.join(", ")}`, className: `region${selectedRegion ? " selected" : ""}`, "data-tool-overlay": region.toolNames.join(" "), key: region.id, title: title, style: {
550
535
  "--color": color,
551
536
  height: rect.height,
@@ -584,7 +569,7 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
584
569
  tools.map((tool) => (React.createElement("button", { className: `tool${selectedName === tool.name ? " selected" : ""}`, key: tool.name, onClick: () => selectTool(tool.name) },
585
570
  React.createElement("span", { className: "tool-name" }, tool.name),
586
571
  React.createElement("div", { className: "tool-description" }, tool.description)))),
587
- tools.length === 0 ? React.createElement("div", { className: "empty" }, "\u5F53\u524D\u9875\u9762\u6CA1\u6709\u5DF2\u6CE8\u518C\u80FD\u529B") : null),
572
+ tools.length === 0 ? (React.createElement("div", { className: "empty" }, "\u5F53\u524D\u9875\u9762\u6CA1\u6709\u5DF2\u6CE8\u518C\u80FD\u529B")) : null),
588
573
  React.createElement("div", { className: "detail" }, selected ? (React.createElement(React.Fragment, null,
589
574
  React.createElement("h2", null, selected.name),
590
575
  React.createElement("p", { className: "description" }, selected.description),
@@ -605,7 +590,7 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
605
590
  React.createElement("div", { className: "actions" },
606
591
  running ? (React.createElement("button", { className: "cancel", onClick: () => controllerRef.current?.abort() }, "Cancel")) : null,
607
592
  React.createElement("button", { className: "run", disabled: running || !("value" in parsedInput), onClick: () => void run(selected) }, "Run Tool")),
608
- result !== undefined ? React.createElement("pre", null, pretty(result)) : null))) : (React.createElement("div", { className: "empty" }, "Select a capability to inspect it."))))) : activeTab === "executions" ? (React.createElement("div", { className: "layout" },
593
+ result !== undefined ? React.createElement("pre", null, pretty(result)) : null))) : React.createElement("div", { className: "empty" }, "Select a capability to inspect it.")))) : activeTab === "executions" ? (React.createElement("div", { className: "layout" },
609
594
  React.createElement("div", { className: "list" },
610
595
  React.createElement("div", { className: "record-heading" },
611
596
  React.createElement("span", { className: "section-title" }, "\u8C03\u7528\u8BB0\u5F55"),
@@ -614,25 +599,19 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
614
599
  React.createElement("span", { className: "tool-name" }, record.name),
615
600
  React.createElement("div", { className: "tool-description" },
616
601
  new Date(record.startedAt).toLocaleTimeString(),
617
- " \u00B7",
618
- " ",
602
+ " \u00B7 ",
619
603
  executionStatus(record),
620
- record.finishedAt !== undefined
621
- ? ` · ${Math.max(0, record.finishedAt - record.startedAt)}ms`
622
- : "")))),
604
+ record.finishedAt !== undefined ? ` · ${Math.max(0, record.finishedAt - record.startedAt)}ms` : "")))),
623
605
  history.records.length === 0 ? (React.createElement("div", { className: "empty" }, "\u6682\u65E0\u6267\u884C\u8BB0\u5F55\u3002Inspector \u6302\u8F7D\u540E\uFF0C\u7ECF\u8FC7\u672C\u5730 Runtime \u7684 Tool \u8C03\u7528\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002")) : null),
624
606
  React.createElement("div", { className: "detail" }, history.selected ? (React.createElement(React.Fragment, null,
625
607
  React.createElement("h2", null, history.selected.name),
626
608
  React.createElement("p", { className: "description" },
627
609
  executionStatus(history.selected),
628
- " \u00B7",
629
- " ",
610
+ " \u00B7 ",
630
611
  new Date(history.selected.startedAt).toLocaleTimeString(),
631
- history.selected.finishedAt !== undefined
632
- ? ` · ${Math.max(0, history.selected.finishedAt - history.selected.startedAt)}ms`
633
- : ""),
612
+ history.selected.finishedAt !== undefined ? ` · ${Math.max(0, history.selected.finishedAt - history.selected.startedAt)}ms` : ""),
634
613
  React.createElement(ExecutionValue, { key: `${history.selected.id}:input`, title: "\u5165\u53C2", snapshot: history.selected.input }),
635
- history.selected.output ? (React.createElement(ExecutionValue, { key: `${history.selected.id}:output`, title: history.selected.status === "success" ? "返回值" : "错误", snapshot: history.selected.output })) : null)) : (React.createElement("div", { className: "empty" }, "\u9009\u62E9\u4E00\u6761\u8C03\u7528\u67E5\u770B\u8BE6\u60C5\u3002"))))) : (React.createElement("div", { className: "layout" },
614
+ history.selected.output ? (React.createElement(ExecutionValue, { key: `${history.selected.id}:output`, title: history.selected.status === "success" ? "返回值" : "错误", snapshot: history.selected.output })) : null)) : React.createElement("div", { className: "empty" }, "\u9009\u62E9\u4E00\u6761\u8C03\u7528\u67E5\u770B\u8BE6\u60C5\u3002")))) : (React.createElement("div", { className: "layout" },
636
615
  React.createElement("div", { className: "component-tree" },
637
616
  componentSnapshot.rootIds.map((id) => renderOwner(id)),
638
617
  componentSnapshot.rootIds.length === 0 ? (React.createElement("div", { className: "empty" }, "\u5F53\u524D\u9875\u9762\u6CA1\u6709 Agent Components")) : null),
@@ -650,7 +629,7 @@ function RuntimeInspector({ toolRuntime: runtime, defaultOpen, offset, overlayHo
650
629
  } },
651
630
  React.createElement("span", { className: "tool-name" }, name),
652
631
  tool ? (React.createElement("div", { className: "tool-description" }, tool.description)) : null));
653
- }))))) : (React.createElement("div", { className: "empty" }, "Select an Agent Component to inspect it.")))))))) : null));
632
+ }))))) : React.createElement("div", { className: "empty" }, "Select an Agent Component to inspect it."))))))) : null));
654
633
  }
655
634
  export function AgentInspectorPanel({ toolRuntime, defaultOpen = false, offset = { right: 24, bottom: 88 }, }) {
656
635
  const [portal, setPortal] = useState();
@@ -671,3 +650,4 @@ export function AgentInspectorPanel({ toolRuntime, defaultOpen = false, offset =
671
650
  return null;
672
651
  return createPortal(React.createElement(RuntimeInspector, { toolRuntime: toolRuntime, defaultOpen: defaultOpen, offset: offset, overlayHost: portal.host }), portal.root);
673
652
  }
653
+ //# sourceMappingURL=panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.js","sourceRoot":"","sources":["../src/panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GAIvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAE3F,SAAS,gBAAgB,CAAC,OAAoB;IAC5C,OAAO,OAAO,CAAC,QAAQ,EAAE;SACtB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,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AG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,YAAY,CACjB,oBAAC,gBAAgB,IACf,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,CAAC,IAAI,GACxB,EACF,MAAM,CAAC,IAAI,CACZ,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport type { AgentToolDefinition, ToolRuntime } from \"@nexface/tools\";\n\nimport { getNexfaceDevtoolsStore } from \"./react-devtools-store.js\";\nimport {\n collectRuntimeToolSnapshot,\n reactDevtoolsRoots,\n runtimeToolRegionRects,\n type RuntimeToolComponentSnapshot,\n type RuntimeToolOwner,\n type RuntimeToolRegion,\n} from \"./react-tree.js\";\n\nimport { useExecutionHistory } from \"./use-execution-history.js\";\n\nconst pageToolNames = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\", \"nxf_applyAction\"]);\n\nfunction applicationTools(runtime: ToolRuntime): readonly AgentToolDefinition<unknown>[] {\n return runtime.getTools()\n .map((tool) => tool.definition)\n .filter((tool) => !pageToolNames.has(tool.name))\n .sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);\n}\n\nexport interface AgentInspectorProps {\n toolRuntime: ToolRuntime;\n defaultOpen?: boolean;\n offset?: { right: number; bottom: number };\n}\n\nconst styles = `\n:host { all: initial; }\n* { box-sizing: border-box; }\nbutton, textarea { font: inherit; }\n.root { color: #202124; font: 13px/1.45 -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif; }\n.region { position: fixed; z-index: 2147482998; padding: 0; border: 3px solid var(--color); border-radius: 8px; background: color-mix(in srgb, var(--color) 9%, transparent); box-shadow: 0 0 0 1px rgba(255,255,255,.85); cursor: pointer; }\n.region:hover, .region.selected { z-index: 2147483000; border-width: 4px; background: color-mix(in srgb, var(--color) 16%, transparent); }\n.region-tag { position: absolute; top: -27px; left: -3px; max-width: min(720px, calc(100vw - 32px)); padding: 3px 8px; border-radius: 6px 6px 6px 0; background: var(--color); color: #fff; font: 700 12px/19px ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.region-tag.inside { top: 3px; left: 3px; border-radius: 5px; }\n.trigger { position: fixed; z-index: 2147483002; max-width: calc(100vw - 32px); height: 42px; padding: 0 16px; transform: translate(-100%, -100%); overflow: hidden; border: 1px solid #d9dde5; border-radius: 22px; background: #fff; color: #1769e0; box-shadow: 0 8px 24px rgba(31,35,41,.18); cursor: grab; font-weight: 700; text-overflow: ellipsis; touch-action: none; user-select: none; white-space: nowrap; }\n.trigger:active { cursor: grabbing; }\n.panel { position: fixed; z-index: 2147483001; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #dfe3ea; border-radius: 14px; background: #fff; box-shadow: 0 18px 52px rgba(31,35,41,.25); }\n.header { display: flex; min-height: 56px; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid #e6e9ef; cursor: grab; user-select: none; touch-action: none; }\n.header:active { cursor: grabbing; }\n.header strong { font-size: 17px; }\n.close { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: #5f6673; cursor: pointer; font-size: 20px; }\n.close:hover { background: #f2f4f7; }\n.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid #e6e9ef; }\n.tab { position: relative; padding: 11px 9px 10px; border: 0; background: transparent; color: #646b78; cursor: pointer; font-weight: 700; }\n.tab.active { color: #1769e0; }\n.tab.active::after { position: absolute; right: 8px; bottom: -1px; left: 8px; height: 2px; background: #1769e0; content: \"\"; }\n.layout { display: grid; min-height: 0; flex: 1; grid-template-columns: 280px minmax(0, 1fr); }\n.list { min-height: 0; overflow: auto; padding: 14px; border-right: 1px solid #e6e9ef; }\n.tool { display: block; width: 100%; margin-bottom: 8px; padding: 11px; border: 1px solid #e2e6ed; border-radius: 9px; background: #fff; text-align: left; cursor: pointer; }\n.tool:hover, .tool.selected { border-color: #91b9f6; background: #f8fbff; }\n.tool-name { font: 700 13px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }\n.tool-description { margin-top: 5px; color: #646b78; }\n.detail { min-width: 0; overflow: auto; padding: 18px; }\n.detail h2 { margin: 0; font: 750 17px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }\n.description { margin: 8px 0 0; color: #646b78; }\n.owner-list { display: grid; gap: 7px; margin-top: 9px; }\n.owner-link { width: 100%; padding: 8px 10px; border: 1px solid #dfe4ec; border-radius: 8px; background: #fff; color: #1769e0; text-align: left; cursor: pointer; font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; }\n.owner-link:hover { border-color: #91b9f6; background: #f8fbff; }\n.component-tree { min-height: 0; overflow: auto; padding: 14px; border-right: 1px solid #e6e9ef; }\n.component-node { display: flex; width: 100%; min-height: 38px; align-items: center; gap: 7px; margin-bottom: 5px; padding: 7px 9px 7px calc(9px + var(--depth) * 18px); border: 0; border-radius: 7px; background: transparent; color: #202124; text-align: left; cursor: pointer; }\n.component-node:hover, .component-node.selected { background: #eef5ff; }\n.component-name { min-width: 0; flex: 1; overflow: hidden; font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }\n.component-count { flex: none; color: #737b88; font-size: 11px; }\n.component-tools { display: grid; gap: 8px; margin-top: 10px; }\n.component-tool { width: 100%; padding: 10px; border: 1px solid #e2e6ed; border-radius: 8px; background: #fff; text-align: left; cursor: pointer; }\n.component-tool:hover { border-color: #91b9f6; background: #f8fbff; }\n.renderless { margin-left: 8px; padding: 2px 7px; border-radius: 999px; background: #f1ebff; color: #6f42c1; font-size: 11px; font-weight: 700; }\n.section { margin-top: 18px; padding-top: 16px; border-top: 1px solid #eceef2; }\n.section-title { font-weight: 750; }\npre { max-height: 180px; margin: 9px 0 0; overflow: auto; padding: 10px; border-radius: 8px; background: #f6f7f9; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }\ntextarea { width: 100%; min-height: 96px; margin-top: 9px; padding: 9px; border: 1px solid #d9dde5; border-radius: 7px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }\n.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }\n.run, .cancel { min-width: 92px; height: 36px; border-radius: 8px; cursor: pointer; font-weight: 700; }\n.run { border: 0; background: #1769e0; color: #fff; }\n.run:disabled { background: #b6c9e8; cursor: not-allowed; }\n.cancel { border: 1px solid #d84a4a; background: #fff; color: #c62828; }\n.error { margin-top: 8px; color: #c62828; }\n.record-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }\n.copy { border: 1px solid #dfe4ec; border-radius: 6px; padding: 4px 8px; background: #fff; cursor: pointer; }\n.empty { display: grid; min-height: 120px; place-items: center; color: #8a919d; text-align: center; }\n@media (max-width: 620px) { .layout { grid-template-columns: 1fr; } .list { max-height: 190px; border-right: 0; border-bottom: 1px solid #e6e9ef; } }\n`;\n\nfunction executionStatus(record: { status: string; cancelled?: boolean | undefined }): string {\n return record.status === \"running\" ? \"执行中\" : record.status === \"success\" ? \"成功\" : record.cancelled ? \"已取消\" : \"失败\";\n}\n\nfunction ExecutionValue({ title, snapshot }: { title: string; snapshot: { text: string; truncated: boolean } }) {\n const [feedback, setFeedback] = useState(\"\");\n const copy = async () => {\n try {\n await navigator.clipboard.writeText(snapshot.text);\n setFeedback(\"已复制\");\n } catch {\n setFeedback(\"复制失败,请手动选择文本复制。\");\n }\n };\n return (\n <section className=\"section\">\n <div className=\"record-heading\">\n <span className=\"section-title\">{title}</span>\n <button className=\"copy\" aria-label={`复制${title}`} onClick={() => void copy()}>复制</button>\n </div>\n {snapshot.truncated ? <div className=\"description\">内容已截断,复制仅包含已保存的文本。</div> : null}\n {feedback ? <div role=\"status\">{feedback}</div> : null}\n <pre>{snapshot.text}</pre>\n </section>\n );\n}\n\nfunction pretty(value: unknown): string {\n if (value instanceof Error) {\n return JSON.stringify({\n name: value.name,\n message: value.message,\n ...(\"code\" in value ? { code: value.code } : {}),\n }, null, 2);\n }\n try {\n return JSON.stringify(value, null, 2) ?? String(value);\n } catch {\n return String(value);\n }\n}\n\nconst viewportMargin = 16;\n\nfunction panelSize() {\n return {\n width: Math.min(760, Math.max(0, window.innerWidth - viewportMargin * 2)),\n height: Math.min(620, Math.max(0, window.innerHeight - 112)),\n };\n}\n\nfunction clampPosition(position: { x: number; y: number }) {\n const { width, height } = panelSize();\n return {\n x: Math.min(\n Math.max(viewportMargin, position.x),\n Math.max(viewportMargin, window.innerWidth - width - viewportMargin),\n ),\n y: Math.min(\n Math.max(viewportMargin, position.y),\n Math.max(viewportMargin, window.innerHeight - height - viewportMargin),\n ),\n };\n}\n\nfunction initialAnchor(offset: { right: number; bottom: number }) {\n return {\n x: window.innerWidth - offset.right,\n y: window.innerHeight - offset.bottom,\n };\n}\n\nfunction clampTriggerAnchor(\n anchor: { x: number; y: number },\n size: { width: number; height: number },\n) {\n return {\n x: Math.min(\n Math.max(viewportMargin + size.width, anchor.x),\n Math.max(viewportMargin + size.width, window.innerWidth - viewportMargin),\n ),\n y: Math.min(\n Math.max(viewportMargin + size.height, anchor.y),\n Math.max(viewportMargin + size.height, window.innerHeight - viewportMargin),\n ),\n };\n}\n\nfunction unionRect(rects: readonly DOMRect[]): DOMRect {\n const left = Math.min(...rects.map((rect) => rect.left));\n const top = Math.min(...rects.map((rect) => rect.top));\n const right = Math.max(...rects.map((rect) => rect.right));\n const bottom = Math.max(...rects.map((rect) => rect.bottom));\n return new DOMRect(left, top, right - left, bottom - top);\n}\n\nfunction sameRect(left: DOMRect, right: DOMRect): boolean {\n return left.left === right.left && left.top === right.top &&\n left.width === right.width && left.height === right.height;\n}\n\nfunction sameRegions(\n left: readonly RuntimeToolRegion[],\n right: readonly RuntimeToolRegion[],\n): boolean {\n return left.length === right.length && left.every((region, index) => {\n const candidate = right[index];\n return candidate?.id === region.id &&\n candidate.ownerIds.length === region.ownerIds.length &&\n candidate.ownerIds.every((id, ownerIndex) => id === region.ownerIds[ownerIndex]) &&\n candidate.componentNames.length === region.componentNames.length &&\n candidate.componentNames.every(\n (name, nameIndex) => name === region.componentNames[nameIndex],\n ) &&\n candidate.toolNames.length === region.toolNames.length &&\n candidate.toolNames.every((name, nameIndex) => name === region.toolNames[nameIndex]) &&\n candidate.elements.length === region.elements.length &&\n candidate.elements.every((element, elementIndex) => element === region.elements[elementIndex]) &&\n candidate.rects.length === region.rects.length &&\n candidate.rects.every((rect, rectIndex) => sameRect(rect, region.rects[rectIndex]!));\n });\n}\n\nconst emptyComponentSnapshot: RuntimeToolComponentSnapshot = {\n owners: [],\n rootIds: [],\n};\n\nconst dragThreshold = 6;\n\nfunction sameOwners(left: readonly RuntimeToolOwner[], right: readonly RuntimeToolOwner[]) {\n return left.length === right.length && left.every((owner, index) => {\n const candidate = right[index];\n return candidate?.id === owner.id && candidate.name === owner.name &&\n candidate.parentId === owner.parentId && candidate.renderless === owner.renderless &&\n candidate.children.length === owner.children.length &&\n candidate.children.every((id, childIndex) => id === owner.children[childIndex]) &&\n candidate.toolNames.length === owner.toolNames.length &&\n candidate.toolNames.every((name, toolIndex) => name === owner.toolNames[toolIndex]);\n });\n}\n\nfunction sameComponentSnapshots(\n left: RuntimeToolComponentSnapshot,\n right: RuntimeToolComponentSnapshot,\n) {\n return left.rootIds.length === right.rootIds.length &&\n left.rootIds.every((id, index) => id === right.rootIds[index]) &&\n sameOwners(left.owners, right.owners);\n}\n\nfunction RuntimeInspector({\n toolRuntime: runtime,\n defaultOpen,\n offset,\n overlayHost,\n}: Required<AgentInspectorProps> & { overlayHost: HTMLElement }) {\n const [open, setOpen] = useState(defaultOpen);\n const [activeTab, setActiveTab] = useState<\"tools\" | \"components\" | \"executions\">(\"tools\");\n const [tools, setTools] = useState(() => applicationTools(runtime));\n const [selectedName, setSelectedName] = useState<string>();\n const [selectedOwnerId, setSelectedOwnerId] = useState<string>();\n const [input, setInput] = useState(\"{}\");\n const [result, setResult] = useState<unknown>();\n const [running, setRunning] = useState(false);\n const history = useExecutionHistory(runtime);\n const [regions, setRegions] = useState<RuntimeToolRegion[]>([]);\n const [componentSnapshot, setComponentSnapshot] = useState<RuntimeToolComponentSnapshot>(\n emptyComponentSnapshot,\n );\n const controllerRef = useRef<AbortController | undefined>(undefined);\n const runtimeRef = useRef(runtime);\n const [anchor, setAnchor] = useState(() => initialAnchor(offset));\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const triggerSizeRef = useRef({ width: 0, height: 42 });\n const dragRef = useRef<{\n pointerId: number;\n dx: number;\n dy: number;\n } | undefined>(undefined);\n const triggerDragRef = useRef<{\n pointerId: number;\n startX: number;\n startY: number;\n startAnchor: { x: number; y: number };\n triggerSize: { width: number; height: number };\n moved: boolean;\n } | undefined>(undefined);\n const suppressTriggerClickRef = useRef(false);\n const suppressTriggerClickTimerRef = useRef<number | undefined>(undefined);\n\n useEffect(() => {\n runtimeRef.current = runtime;\n controllerRef.current?.abort(new DOMException(\"Active Tool Runtime changed.\", \"AbortError\"));\n controllerRef.current = undefined;\n setTools(applicationTools(runtime));\n setSelectedName(undefined);\n setSelectedOwnerId(undefined);\n setInput(\"{}\");\n setResult(undefined);\n setRunning(false);\n setRegions([]);\n setComponentSnapshot(emptyComponentSnapshot);\n }, [runtime]);\n\n useEffect(() => {\n const update = () => setTools(applicationTools(runtime));\n update();\n return runtime.on(\"toolchange\", update);\n }, [runtime]);\n useEffect(() => {\n if (selectedName && !tools.some(({ name }) => name === selectedName)) {\n setSelectedName(undefined);\n setResult(undefined);\n controllerRef.current?.abort(new Error(\"Tool unregistered.\"));\n }\n }, [selectedName, tools]);\n useEffect(() => {\n if (\n selectedOwnerId &&\n !componentSnapshot.owners.some(({ id }) => id === selectedOwnerId)\n ) {\n setSelectedOwnerId(undefined);\n }\n }, [componentSnapshot.owners, selectedOwnerId]);\n useEffect(() => () => controllerRef.current?.abort(), []);\n useEffect(() => () => {\n if (suppressTriggerClickTimerRef.current !== undefined) {\n window.clearTimeout(suppressTriggerClickTimerRef.current);\n }\n }, []);\n useEffect(() => {\n const resize = () => {\n if (!open && triggerRef.current) {\n const { width, height } = triggerRef.current.getBoundingClientRect();\n if (width > 0 && height > 0) triggerSizeRef.current = { width, height };\n }\n setAnchor((current) => {\n if (!open) return clampTriggerAnchor(current, triggerSizeRef.current);\n const size = panelSize();\n const position = clampPosition({\n x: current.x - size.width,\n y: current.y - size.height,\n });\n return {\n x: position.x + size.width,\n y: position.y + size.height,\n };\n });\n };\n window.addEventListener(\"resize\", resize);\n return () => window.removeEventListener(\"resize\", resize);\n }, [open]);\n useEffect(() => {\n if (open || !triggerRef.current) return;\n const { width, height } = triggerRef.current.getBoundingClientRect();\n if (width <= 0 || height <= 0) return;\n const size = { width, height };\n triggerSizeRef.current = size;\n setAnchor((current) => clampTriggerAnchor(current, size));\n }, [open]);\n useEffect(() => {\n if (!open) {\n setRegions([]);\n setComponentSnapshot(emptyComponentSnapshot);\n return;\n }\n let scheduled: number | undefined;\n let usesAnimationFrame = false;\n const resizeObserver = typeof ResizeObserver === \"undefined\"\n ? undefined\n : new ResizeObserver(() => refreshRects());\n const rebuild = () => {\n scheduled = undefined;\n const next = collectRuntimeToolSnapshot(\n reactDevtoolsRoots(),\n tools,\n overlayHost,\n );\n setRegions((current) => sameRegions(current, next.regions) ? current : next.regions);\n setComponentSnapshot((current) => {\n const components = { owners: next.owners, rootIds: next.rootIds };\n return sameComponentSnapshots(current, components) ? current : components;\n });\n resizeObserver?.disconnect();\n for (const element of new Set(next.regions.flatMap(({ elements }) => elements))) {\n resizeObserver?.observe(element);\n }\n };\n const scheduleRebuild = () => {\n if (scheduled !== undefined) return;\n if (typeof window.requestAnimationFrame === \"function\") {\n usesAnimationFrame = true;\n scheduled = window.requestAnimationFrame(rebuild);\n } else {\n usesAnimationFrame = false;\n scheduled = window.setTimeout(rebuild, 0);\n }\n };\n const refreshRects = () => {\n setRegions((current) => {\n const next = current.map((region) => ({\n ...region,\n rects: runtimeToolRegionRects(region.elements),\n }));\n return sameRegions(current, next) ? current : next;\n });\n };\n const unsubscribe = getNexfaceDevtoolsStore().subscribe(scheduleRebuild);\n const mutationObserver = new MutationObserver(scheduleRebuild);\n mutationObserver.observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n });\n window.addEventListener(\"resize\", refreshRects);\n window.addEventListener(\"scroll\", refreshRects, true);\n scheduleRebuild();\n return () => {\n unsubscribe();\n mutationObserver.disconnect();\n resizeObserver?.disconnect();\n window.removeEventListener(\"resize\", refreshRects);\n window.removeEventListener(\"scroll\", refreshRects, true);\n if (scheduled !== undefined) {\n if (usesAnimationFrame) window.cancelAnimationFrame(scheduled);\n else window.clearTimeout(scheduled);\n }\n };\n }, [open, overlayHost, tools]);\n\n const selected = tools.find(({ name }) => name === selectedName);\n const ownersById = useMemo(\n () => new Map(componentSnapshot.owners.map((owner) => [owner.id, owner])),\n [componentSnapshot.owners],\n );\n const selectedOwners = selectedName\n ? componentSnapshot.owners.filter(({ toolNames }) => toolNames.includes(selectedName))\n : [];\n const selectedOwner = selectedOwnerId ? ownersById.get(selectedOwnerId) : undefined;\n const selectTool = (name: string) => {\n setSelectedName(name);\n setInput(\"{}\");\n setResult(undefined);\n };\n const selectOwner = (id: string) => {\n setSelectedOwnerId(id);\n setActiveTab(\"components\");\n };\n const renderOwner = (id: string, depth = 0): ReactNode => {\n const owner = ownersById.get(id);\n if (!owner) return null;\n return (\n <div key={owner.id}>\n <button\n aria-label={`Inspect component ${owner.name}`}\n className={`component-node${selectedOwnerId === owner.id ? \" selected\" : \"\"}`}\n data-agent-component={owner.name}\n style={{ \"--depth\": depth } as CSSProperties}\n onClick={() => setSelectedOwnerId(owner.id)}\n >\n <span className=\"component-name\">{owner.name}</span>\n <span className=\"component-count\">{owner.toolNames.length}</span>\n </button>\n {owner.children.map((childId) => renderOwner(childId, depth + 1))}\n </div>\n );\n };\n const parsedInput = useMemo(() => {\n try {\n const value = JSON.parse(input) as unknown;\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return { error: \"Tool input must be a JSON object.\" };\n }\n return { value };\n } catch (error) {\n return { error: error instanceof Error ? error.message : \"Invalid JSON.\" };\n }\n }, [input]);\n\n const run = async (tool: AgentToolDefinition<unknown>) => {\n if (!(\"value\" in parsedInput)) return;\n const controller = new AbortController();\n controllerRef.current = controller;\n setRunning(true);\n setResult(undefined);\n try {\n const currentTool = runtime.getTools().find((candidate) => candidate.definition === tool && !pageToolNames.has(candidate.definition.name));\n if (!currentTool) throw new Error(`Tool \"${tool.name}\" is no longer registered.`);\n const nextResult = await runtime.execute(currentTool, parsedInput.value, {\n signal: controller.signal,\n });\n if (controllerRef.current === controller && runtimeRef.current === runtime) {\n setResult(nextResult);\n }\n } catch (error) {\n if (controllerRef.current === controller && runtimeRef.current === runtime) {\n setResult(error);\n }\n } finally {\n if (controllerRef.current === controller && runtimeRef.current === runtime) {\n controllerRef.current = undefined;\n setRunning(false);\n }\n }\n };\n\n const size = panelSize();\n const panelPosition = clampPosition({\n x: anchor.x - size.width,\n y: anchor.y - size.height,\n });\n const startDrag = (event: ReactPointerEvent<HTMLElement>) => {\n if ((event.target as Element).closest(\"button\")) return;\n event.currentTarget.setPointerCapture?.(event.pointerId);\n dragRef.current = {\n pointerId: event.pointerId,\n dx: event.clientX - panelPosition.x,\n dy: event.clientY - panelPosition.y,\n };\n };\n const drag = (event: ReactPointerEvent<HTMLElement>) => {\n const state = dragRef.current;\n if (!state || state.pointerId !== event.pointerId) return;\n const position = clampPosition({\n x: event.clientX - state.dx,\n y: event.clientY - state.dy,\n });\n setAnchor({\n x: position.x + size.width,\n y: position.y + size.height,\n });\n };\n const startTriggerDrag = (event: ReactPointerEvent<HTMLButtonElement>) => {\n if (!event.isPrimary || event.button !== 0) return;\n event.currentTarget.setPointerCapture?.(event.pointerId);\n if (suppressTriggerClickTimerRef.current !== undefined) {\n window.clearTimeout(suppressTriggerClickTimerRef.current);\n suppressTriggerClickTimerRef.current = undefined;\n }\n suppressTriggerClickRef.current = false;\n const { width, height } = event.currentTarget.getBoundingClientRect();\n const triggerSize = {\n width: width > 0 ? width : triggerSizeRef.current.width,\n height: height > 0 ? height : triggerSizeRef.current.height,\n };\n triggerSizeRef.current = triggerSize;\n triggerDragRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n startAnchor: anchor,\n triggerSize,\n moved: false,\n };\n };\n const dragTrigger = (event: ReactPointerEvent<HTMLButtonElement>) => {\n const state = triggerDragRef.current;\n if (!state || state.pointerId !== event.pointerId) return;\n const dx = event.clientX - state.startX;\n const dy = event.clientY - state.startY;\n if (!state.moved && dx * dx + dy * dy < dragThreshold * dragThreshold) return;\n state.moved = true;\n setAnchor(clampTriggerAnchor({\n x: state.startAnchor.x + dx,\n y: state.startAnchor.y + dy,\n }, state.triggerSize));\n };\n const endTriggerDrag = (event: ReactPointerEvent<HTMLButtonElement>) => {\n const state = triggerDragRef.current;\n if (!state || state.pointerId !== event.pointerId) return;\n suppressTriggerClickRef.current = state.moved;\n triggerDragRef.current = undefined;\n if (state.moved) {\n suppressTriggerClickTimerRef.current = window.setTimeout(() => {\n suppressTriggerClickRef.current = false;\n suppressTriggerClickTimerRef.current = undefined;\n }, 0);\n }\n };\n const cancelTriggerDrag = () => {\n if (!triggerDragRef.current) return;\n triggerDragRef.current = undefined;\n suppressTriggerClickRef.current = false;\n };\n const loseTriggerPointerCapture = () => {\n const state = triggerDragRef.current;\n if (!state) return;\n triggerDragRef.current = undefined;\n suppressTriggerClickRef.current = state.moved;\n };\n\n return (\n <div className=\"root\">\n {!open ? (\n <button\n className=\"trigger\"\n ref={triggerRef}\n style={{\n left: anchor.x,\n top: anchor.y,\n }}\n onClick={(event) => {\n if (suppressTriggerClickRef.current && event.detail !== 0) {\n suppressTriggerClickRef.current = false;\n return;\n }\n suppressTriggerClickRef.current = false;\n setOpen(true);\n }}\n onPointerDown={startTriggerDrag}\n onPointerMove={dragTrigger}\n onPointerUp={endTriggerDrag}\n onPointerCancel={cancelTriggerDrag}\n onLostPointerCapture={loseTriggerPointerCapture}\n >\n Nexface Inspector\n </button>\n ) : null}\n {open ? (\n <>\n {regions\n .filter(({ rects }) => rects.length > 0)\n .slice()\n .sort((left, right) => {\n const leftRect = unionRect(left.rects);\n const rightRect = unionRect(right.rects);\n return rightRect.width * rightRect.height - leftRect.width * leftRect.height;\n })\n .map((region) => {\n const rect = unionRect(region.rects);\n const selectedRegion = activeTab === \"components\"\n ? region.ownerIds.includes(selectedOwnerId ?? \"\")\n : region.toolNames.includes(selectedName ?? \"\");\n const color = selectedRegion ? \"#1769e0\" : \"#52a832\";\n const label = `${region.componentNames.join(\", \")} · ${region.toolNames.join(\", \")}`;\n const title = region.toolNames.map((name) => {\n const tool = tools.find((candidate) => candidate.name === name);\n return tool ? `${name}: ${tool.description}` : name;\n }).join(\"\\n\");\n return (\n <button\n aria-label={`Inspect ${region.componentNames.join(\", \")}`}\n className={`region${selectedRegion ? \" selected\" : \"\"}`}\n data-tool-overlay={region.toolNames.join(\" \")}\n key={region.id}\n title={title}\n style={{\n \"--color\": color,\n height: rect.height,\n left: rect.left,\n top: rect.top,\n width: rect.width,\n } as CSSProperties}\n onClick={() => {\n const name = region.toolNames[0];\n if (name) selectTool(name);\n setActiveTab(\"tools\");\n }}\n >\n <span\n className={`region-tag${rect.top < 30 ? \" inside\" : \"\"}`}\n style={{\n maxWidth: Math.min(\n 720,\n window.innerWidth - rect.left - viewportMargin,\n ),\n }}\n >\n {label}\n </span>\n </button>\n );\n })}\n <aside\n aria-label=\"Nexface Inspector\"\n className=\"panel\"\n style={{\n height: size.height,\n left: panelPosition.x,\n top: panelPosition.y,\n width: size.width,\n }}\n >\n <header\n className=\"header\"\n onPointerDown={startDrag}\n onPointerMove={drag}\n onPointerUp={() => {\n dragRef.current = undefined;\n }}\n onPointerCancel={() => {\n dragRef.current = undefined;\n }}\n >\n <strong>Nexface Inspector</strong>\n <button\n aria-label=\"Close Inspector\"\n className=\"close\"\n onClick={() => setOpen(false)}\n >\n ×\n </button>\n </header>\n <nav aria-label=\"Inspector views\" className=\"tabs\">\n <button\n className={`tab${activeTab === \"tools\" ? \" active\" : \"\"}`}\n onClick={() => setActiveTab(\"tools\")}\n >\n Page Tools\n </button>\n <button\n className={`tab${activeTab === \"components\" ? \" active\" : \"\"}`}\n onClick={() => setActiveTab(\"components\")}\n >\n Agent Components\n </button>\n <button\n className={`tab${activeTab === \"executions\" ? \" active\" : \"\"}`}\n onClick={() => setActiveTab(\"executions\")}\n >\n 执行记录\n </button>\n </nav>\n {activeTab === \"tools\" ? (\n <div className=\"layout\">\n <div className=\"list\">\n {tools.map((tool) => (\n <button\n className={`tool${selectedName === tool.name ? \" selected\" : \"\"}`}\n key={tool.name}\n onClick={() => selectTool(tool.name)}\n >\n <span className=\"tool-name\">{tool.name}</span>\n <div className=\"tool-description\">{tool.description}</div>\n </button>\n ))}\n {tools.length === 0 ? (\n <div className=\"empty\">当前页面没有已注册能力</div>\n ) : null}\n </div>\n <div className=\"detail\">\n {selected ? (\n <>\n <h2>{selected.name}</h2>\n <p className=\"description\">{selected.description}</p>\n <section className=\"section\">\n <div className=\"section-title\">Registered by</div>\n <div className=\"owner-list\">\n {selectedOwners.map((owner) => (\n <button\n className=\"owner-link\"\n key={owner.id}\n onClick={() => selectOwner(owner.id)}\n >\n {owner.name}\n {owner.renderless ? \" · Renderless\" : \"\"}\n </button>\n ))}\n {selectedOwners.length === 0 ? (\n <div className=\"description\">Component owner is unavailable.</div>\n ) : null}\n </div>\n </section>\n <section className=\"section\">\n <div className=\"section-title\">Input schema</div>\n <pre>{pretty(selected.inputSchema)}</pre>\n </section>\n <section className=\"section\">\n <div className=\"section-title\">Run Tool</div>\n <textarea value={input} onChange={(event) => setInput(event.target.value)} />\n {parsedInput.error ? (\n <div className=\"error\">{parsedInput.error}</div>\n ) : null}\n <div className=\"actions\">\n {running ? (\n <button\n className=\"cancel\"\n onClick={() => controllerRef.current?.abort()}\n >\n Cancel\n </button>\n ) : null}\n <button\n className=\"run\"\n disabled={running || !(\"value\" in parsedInput)}\n onClick={() => void run(selected)}\n >\n Run Tool\n </button>\n </div>\n {result !== undefined ? <pre>{pretty(result)}</pre> : null}\n </section>\n\n </>\n ) : <div className=\"empty\">Select a capability to inspect it.</div>}\n </div>\n </div>\n ) : activeTab === \"executions\" ? (\n <div className=\"layout\">\n <div className=\"list\">\n <div className=\"record-heading\">\n <span className=\"section-title\">调用记录</span>\n <button className=\"copy\" onClick={history.clear}>清空</button>\n </div>\n {history.records.map((record) => (\n <button\n className={`tool${history.selected?.id === record.id ? \" selected\" : \"\"}`}\n key={record.id}\n aria-pressed={history.selected?.id === record.id}\n onClick={() => history.select(record.id)}\n >\n <span className=\"tool-name\">{record.name}</span>\n <div className=\"tool-description\">\n {new Date(record.startedAt).toLocaleTimeString()} · {executionStatus(record)}\n {record.finishedAt !== undefined ? ` · ${Math.max(0, record.finishedAt - record.startedAt)}ms` : \"\"}\n </div>\n </button>\n ))}\n {history.records.length === 0 ? (\n <div className=\"empty\">暂无执行记录。Inspector 挂载后,经过本地 Runtime 的 Tool 调用会显示在这里。</div>\n ) : null}\n </div>\n <div className=\"detail\">\n {history.selected ? (\n <>\n <h2>{history.selected.name}</h2>\n <p className=\"description\">\n {executionStatus(history.selected)} · {new Date(history.selected.startedAt).toLocaleTimeString()}\n {history.selected.finishedAt !== undefined ? ` · ${Math.max(0, history.selected.finishedAt - history.selected.startedAt)}ms` : \"\"}\n </p>\n <ExecutionValue key={`${history.selected.id}:input`} title=\"入参\" snapshot={history.selected.input} />\n {history.selected.output ? (\n <ExecutionValue key={`${history.selected.id}:output`} title={history.selected.status === \"success\" ? \"返回值\" : \"错误\"} snapshot={history.selected.output} />\n ) : null}\n </>\n ) : <div className=\"empty\">选择一条调用查看详情。</div>}\n </div>\n </div>\n ) : (\n <div className=\"layout\">\n <div className=\"component-tree\">\n {componentSnapshot.rootIds.map((id) => renderOwner(id))}\n {componentSnapshot.rootIds.length === 0 ? (\n <div className=\"empty\">当前页面没有 Agent Components</div>\n ) : null}\n </div>\n <div className=\"detail\">\n {selectedOwner ? (\n <>\n <div>\n <h2>{selectedOwner.name}</h2>\n {selectedOwner.renderless ? (\n <span className=\"renderless\">Renderless</span>\n ) : null}\n </div>\n <section className=\"section\">\n <div className=\"section-title\">Registered Tools</div>\n <div className=\"component-tools\">\n {selectedOwner.toolNames.map((name) => {\n const tool = tools.find((candidate) => candidate.name === name);\n return (\n <button\n className=\"component-tool\"\n key={name}\n onClick={() => {\n selectTool(name);\n setActiveTab(\"tools\");\n }}\n >\n <span className=\"tool-name\">{name}</span>\n {tool ? (\n <div className=\"tool-description\">{tool.description}</div>\n ) : null}\n </button>\n );\n })}\n </div>\n </section>\n </>\n ) : <div className=\"empty\">Select an Agent Component to inspect it.</div>}\n </div>\n </div>\n )}\n </aside>\n </>\n ) : null}\n </div>\n );\n}\n\nexport function AgentInspectorPanel({\n toolRuntime,\n defaultOpen = false,\n offset = { right: 24, bottom: 88 },\n}: AgentInspectorProps) {\n const [portal, setPortal] = useState<{\n host: HTMLDivElement;\n root: HTMLDivElement;\n }>();\n useEffect(() => {\n const host = document.createElement(\"div\");\n host.dataset.nexfaceInspector = \"true\";\n host.setAttribute(\"data-nexface-ignore\", \"\");\n const shadow = host.attachShadow({ mode: \"open\" });\n const style = document.createElement(\"style\");\n style.textContent = styles;\n const root = document.createElement(\"div\");\n shadow.append(style, root);\n document.body.append(host);\n setPortal({ host, root });\n return () => host.remove();\n }, []);\n if (!portal) return null;\n return createPortal(\n <RuntimeInspector\n toolRuntime={toolRuntime}\n defaultOpen={defaultOpen}\n offset={offset}\n overlayHost={portal.host}\n />,\n portal.root,\n );\n}\n"]}
@@ -42,3 +42,4 @@ export function getNexfaceDevtoolsStore() {
42
42
  target[reactDevtoolsStoreSymbol] = store;
43
43
  return store;
44
44
  }
45
+ //# sourceMappingURL=react-devtools-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-devtools-store.js","sourceRoot":"","sources":["../src/react-devtools-store.ts"],"names":[],"mappings":"AAmBA,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAI7E,MAAM,UAAU,uBAAuB;IACrC,MAAM,MAAM,GAAG,UAAoC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAClD,IAAI,QAAQ;QAAE,OAAO,QAA8B,CAAC;IAEpD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC5D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmC,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IACxC,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,KAAK,MAAM,QAAQ,IAAI,SAAS;YAAE,QAAQ,EAAE,CAAC;IAC/C,CAAC,CAAC;IACF,MAAM,KAAK,GAAuB;QAChC,SAAS;QACT,KAAK;QACL,eAAe,CAAC,EAAE,EAAE,QAAQ;YAC1B,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC5B,MAAM,EAAE,CAAC;QACX,CAAC;QACD,WAAW,CAAC,EAAE,EAAE,IAAI;YAClB,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,GAAG,EAAqB,CAAC;YACpE,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;gBACxB,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACxB,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC3B,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC;oBAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACjD,CAAC;YACD,MAAM,EAAE,CAAC;QACX,CAAC;QACD,cAAc;YACZ,MAAM,EAAE,CAAC;QACX,CAAC;QACD,SAAS,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;IACF,MAAM,CAAC,wBAAwB,CAAC,GAAG,KAAK,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["export type ReactDevtoolsRenderer = {\n findFiberByHostInstance?: (element: Element) => unknown;\n};\n\nexport type ReactDevtoolsRoot = {\n current?: {\n child?: unknown;\n };\n};\n\nexport type ReactDevtoolsStore = {\n renderers: Map<unknown, ReactDevtoolsRenderer>;\n roots: Map<unknown, Set<ReactDevtoolsRoot>>;\n publishRenderer(id: unknown, renderer: ReactDevtoolsRenderer): void;\n publishRoot(id: unknown, root: ReactDevtoolsRoot): void;\n publishUnmount(): void;\n subscribe(listener: () => void): () => void;\n};\n\nconst reactDevtoolsStoreSymbol = Symbol.for(\"@nexface/react-devtools-store\");\n\ntype StoreGlobal = Record<PropertyKey, unknown>;\n\nexport function getNexfaceDevtoolsStore(): ReactDevtoolsStore {\n const target = globalThis as unknown as StoreGlobal;\n const existing = target[reactDevtoolsStoreSymbol];\n if (existing) return existing as ReactDevtoolsStore;\n\n const renderers = new Map<unknown, ReactDevtoolsRenderer>();\n const roots = new Map<unknown, Set<ReactDevtoolsRoot>>();\n const listeners = new Set<() => void>();\n const notify = () => {\n for (const listener of listeners) listener();\n };\n const store: ReactDevtoolsStore = {\n renderers,\n roots,\n publishRenderer(id, renderer) {\n renderers.set(id, renderer);\n notify();\n },\n publishRoot(id, root) {\n const rendererRoots = roots.get(id) ?? new Set<ReactDevtoolsRoot>();\n if (root.current?.child) {\n rendererRoots.add(root);\n roots.set(id, rendererRoots);\n } else {\n rendererRoots.delete(root);\n if (rendererRoots.size === 0) roots.delete(id);\n }\n notify();\n },\n publishUnmount() {\n notify();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n target[reactDevtoolsStoreSymbol] = store;\n return store;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { getNexfaceDevtoolsStore } from "./react-devtools-store.js";
1
+ import { getNexfaceDevtoolsStore, } from "./react-devtools-store.js";
2
2
  const fiberIds = new WeakMap();
3
3
  let nextFiberId = 0;
4
4
  function fiberId(fiber) {
@@ -88,14 +88,11 @@ function sameElements(left, right) {
88
88
  return left.length === right.length && left.every((element, index) => element === right[index]);
89
89
  }
90
90
  function sameRects(left, right) {
91
- return (left.length === right.length &&
92
- left.every((rect, index) => {
93
- const candidate = right[index];
94
- return (candidate?.left === rect.left &&
95
- candidate.top === rect.top &&
96
- candidate.width === rect.width &&
97
- candidate.height === rect.height);
98
- }));
91
+ return left.length === right.length && left.every((rect, index) => {
92
+ const candidate = right[index];
93
+ return candidate?.left === rect.left && candidate.top === rect.top &&
94
+ candidate.width === rect.width && candidate.height === rect.height;
95
+ });
99
96
  }
100
97
  function sameBounds(left, right) {
101
98
  if (!left.length || !right.length)
@@ -108,10 +105,8 @@ function sameBounds(left, right) {
108
105
  });
109
106
  const leftBounds = bounds(left);
110
107
  const rightBounds = bounds(right);
111
- return (leftBounds.left === rightBounds.left &&
112
- leftBounds.top === rightBounds.top &&
113
- leftBounds.right === rightBounds.right &&
114
- leftBounds.bottom === rightBounds.bottom);
108
+ return leftBounds.left === rightBounds.left && leftBounds.top === rightBounds.top &&
109
+ leftBounds.right === rightBounds.right && leftBounds.bottom === rightBounds.bottom;
115
110
  }
116
111
  function visibleRect(element) {
117
112
  const style = getComputedStyle(element);
@@ -133,9 +128,7 @@ export function runtimeToolRegionRects(elements) {
133
128
  if (rect)
134
129
  visible.set(element, rect);
135
130
  }
136
- return [...visible]
137
- .filter(([element]) => ![...visible.keys()].some((candidate) => candidate !== element && candidate.contains(element)))
138
- .map(([, rect]) => rect);
131
+ return [...visible].filter(([element]) => ![...visible.keys()].some((candidate) => candidate !== element && candidate.contains(element))).map(([, rect]) => rect);
139
132
  }
140
133
  export function collectRuntimeToolSnapshot(roots, tools, overlayHost) {
141
134
  const toolsByDefinition = new Map(tools.map((tool) => [tool, tool.name]));
@@ -209,3 +202,4 @@ export function collectRuntimeToolSnapshot(roots, tools, overlayHost) {
209
202
  export function collectRuntimeToolRegions(roots, tools, overlayHost) {
210
203
  return collectRuntimeToolSnapshot(roots, tools, overlayHost).regions;
211
204
  }
205
+ //# sourceMappingURL=react-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-tree.js","sourceRoot":"","sources":["../src/react-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,GAExB,MAAM,2BAA2B,CAAC;AA8CnC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAkB,CAAC;AAC/C,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,SAAS,OAAO,CAAC,KAA0B;IACzC,IAAI,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAC9B,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,C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AAC,CAAC,CAAC;oBAC/E,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,IAAI,CAAC;4BACX,EAAE;4BACF,QAAQ,EAAE,CAAC,EAAE,CAAC;4BACd,cAAc,EAAE,CAAC,IAAI,CAAC;4BACtB,SAAS;4BACT,QAAQ,EAAE,MAAM,CAAC,QAAQ;4BACzB,KAAK,EAAE,MAAM,CAAC,KAAK;yBACpB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAwC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAkC,EAClC,KAA8C,EAC9C,WAAwB;IAExB,OAAO,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["import type { AgentToolDefinition } from \"@nexface/tools\";\n\nimport {\n getNexfaceDevtoolsStore,\n type ReactDevtoolsRoot,\n} from \"./react-devtools-store.js\";\n\ntype FiberEffect = {\n deps?: readonly unknown[] | null;\n next?: FiberEffect | null;\n};\n\nexport type InspectorReactFiber = {\n alternate?: InspectorReactFiber | null;\n child?: InspectorReactFiber | null;\n sibling?: InspectorReactFiber | null;\n return?: InspectorReactFiber | null;\n stateNode?: unknown;\n type?: unknown;\n updateQueue?: {\n lastEffect?: FiberEffect | null;\n } | null;\n};\n\nexport type RuntimeToolRegion = {\n id: string;\n ownerIds: string[];\n componentNames: string[];\n toolNames: string[];\n elements: Element[];\n rects: DOMRect[];\n};\n\nexport type RuntimeToolOwner = {\n id: string;\n name: string;\n parentId?: string;\n children: string[];\n toolNames: string[];\n renderless: boolean;\n};\n\nexport type RuntimeToolComponentSnapshot = {\n rootIds: string[];\n owners: RuntimeToolOwner[];\n};\n\nexport type RuntimeToolSnapshot = RuntimeToolComponentSnapshot & {\n regions: RuntimeToolRegion[];\n};\n\nconst fiberIds = new WeakMap<object, number>();\nlet nextFiberId = 0;\n\nfunction fiberId(fiber: InspectorReactFiber): string {\n let id = fiberIds.get(fiber) ?? (\n fiber.alternate ? fiberIds.get(fiber.alternate) : undefined\n );\n if (!id) id = ++nextFiberId;\n fiberIds.set(fiber, id);\n if (fiber.alternate) fiberIds.set(fiber.alternate, id);\n return `fiber:${id}`;\n}\n\nexport function reactDevtoolsRoots(): ReactDevtoolsRoot[] {\n return [...new Set(\n [...getNexfaceDevtoolsStore().roots.values()].flatMap((roots) => [...roots]),\n )];\n}\n\nfunction effectDependencies(\n fiber: InspectorReactFiber,\n): ReadonlyArray<readonly unknown[]> {\n const last = fiber.updateQueue?.lastEffect;\n const first = last?.next;\n if (!last || !first) return [];\n const dependencies: Array<readonly unknown[]> = [];\n let current: FiberEffect | null | undefined = first;\n do {\n if (current?.deps) dependencies.push(current.deps);\n current = current?.next;\n } while (current && current !== first);\n return dependencies;\n}\n\nfunction toolNamesForFiber(\n fiber: InspectorReactFiber,\n toolsByDefinition: Map<unknown, string>,\n): string[] {\n const names = new Set<string>();\n for (const dependencies of effectDependencies(fiber)) {\n for (const dependency of dependencies) {\n const name = toolsByDefinition.get(dependency);\n if (name) names.add(name);\n }\n }\n return [...names].sort();\n}\n\nfunction componentName(fiber: InspectorReactFiber): string {\n const seen = new Set<unknown>();\n let current = fiber.type;\n let fallback = \"Component\";\n while (\n (typeof current === \"function\" || (current && typeof current === \"object\")) &&\n !seen.has(current)\n ) {\n seen.add(current);\n const component = current as {\n displayName?: string;\n name?: string;\n render?: unknown;\n type?: unknown;\n };\n fallback = component.displayName || component.name || fallback;\n current = component.type ?? component.render;\n }\n return fallback;\n}\n\nfunction collectHostElements(\n fiber: InspectorReactFiber | null | undefined,\n overlayHost: HTMLElement,\n overlayRoot: ShadowRoot | null = overlayHost.shadowRoot,\n): Element[] {\n const elements: Element[] = [];\n for (let current = fiber; current; current = current.sibling) {\n const element = typeof current.type === \"string\" && current.stateNode instanceof Element\n ? current.stateNode\n : undefined;\n if (\n element &&\n element !== overlayHost &&\n element.getRootNode() !== overlayRoot &&\n !overlayHost.contains(element)\n ) {\n elements.push(element);\n }\n elements.push(...collectHostElements(current.child, overlayHost, overlayRoot));\n }\n return [...new Set(elements)];\n}\n\nfunction visualElements(\n owner: InspectorReactFiber,\n overlayHost: HTMLElement,\n): { elements: Element[]; rects: DOMRect[]; fallback: boolean } | undefined {\n const ownElements = collectHostElements(owner.child, overlayHost);\n const ownRects = runtimeToolRegionRects(ownElements);\n if (ownRects.length) return { elements: ownElements, rects: ownRects, fallback: false };\n if (owner.child) return undefined;\n\n let candidate: InspectorReactFiber | null | undefined = owner.return;\n while (candidate) {\n const elements = collectHostElements(candidate.child, overlayHost);\n const rects = runtimeToolRegionRects(elements);\n if (rects.length) return { elements, rects, fallback: true };\n candidate = candidate.return;\n }\n return undefined;\n}\n\nfunction sameElements(left: readonly Element[], right: readonly Element[]): boolean {\n return left.length === right.length && left.every((element, index) => element === right[index]);\n}\n\nfunction sameRects(left: readonly DOMRect[], right: readonly DOMRect[]): boolean {\n return left.length === right.length && left.every((rect, index) => {\n const candidate = right[index];\n return candidate?.left === rect.left && candidate.top === rect.top &&\n candidate.width === rect.width && candidate.height === rect.height;\n });\n}\n\nfunction sameBounds(left: readonly DOMRect[], right: readonly DOMRect[]): boolean {\n if (!left.length || !right.length) return false;\n const bounds = (rects: readonly DOMRect[]) => ({\n bottom: Math.max(...rects.map((rect) => rect.bottom)),\n left: Math.min(...rects.map((rect) => rect.left)),\n right: Math.max(...rects.map((rect) => rect.right)),\n top: Math.min(...rects.map((rect) => rect.top)),\n });\n const leftBounds = bounds(left);\n const rightBounds = bounds(right);\n return leftBounds.left === rightBounds.left && leftBounds.top === rightBounds.top &&\n leftBounds.right === rightBounds.right && leftBounds.bottom === rightBounds.bottom;\n}\n\nfunction visibleRect(element: Element): DOMRect | undefined {\n const style = getComputedStyle(element);\n if (style.display === \"none\" || style.visibility === \"hidden\") return undefined;\n const rect = element.getBoundingClientRect();\n const left = Math.max(0, rect.left);\n const top = Math.max(0, rect.top);\n const right = Math.min(window.innerWidth, rect.right);\n const bottom = Math.min(window.innerHeight, rect.bottom);\n if (right - left < 2 || bottom - top < 2) return undefined;\n return new DOMRect(left, top, right - left, bottom - top);\n}\n\nexport function runtimeToolRegionRects(elements: readonly Element[]): DOMRect[] {\n const visible = new Map<Element, DOMRect>();\n for (const element of elements) {\n const rect = visibleRect(element);\n if (rect) visible.set(element, rect);\n }\n return [...visible].filter(([element]) => ![...visible.keys()].some(\n (candidate) => candidate !== element && candidate.contains(element),\n )).map(([, rect]) => rect);\n}\n\nexport function collectRuntimeToolSnapshot(\n roots: Iterable<ReactDevtoolsRoot>,\n tools: readonly AgentToolDefinition<unknown>[],\n overlayHost: HTMLElement,\n): RuntimeToolSnapshot {\n const toolsByDefinition = new Map<unknown, string>(\n tools.map((tool) => [tool, tool.name]),\n );\n const owners: RuntimeToolOwner[] = [];\n const ownersById = new Map<string, RuntimeToolOwner>();\n const rootIds: string[] = [];\n const regions: RuntimeToolRegion[] = [];\n const visit = (\n fiber: InspectorReactFiber | null | undefined,\n parentOwnerId?: string,\n ) => {\n for (let current = fiber; current; current = current.sibling) {\n const toolNames = toolNamesForFiber(current, toolsByDefinition);\n let childParentId = parentOwnerId;\n if (toolNames.length) {\n const id = fiberId(current);\n const name = componentName(current);\n const visual = visualElements(current, overlayHost);\n let owner = ownersById.get(id);\n if (!owner) {\n owner = {\n id,\n name,\n ...(parentOwnerId ? { parentId: parentOwnerId } : {}),\n children: [],\n toolNames,\n renderless: visual?.fallback ?? current.child == null,\n };\n owners.push(owner);\n ownersById.set(id, owner);\n if (parentOwnerId) {\n const parent = ownersById.get(parentOwnerId);\n if (parent && !parent.children.includes(id)) parent.children.push(id);\n } else if (!rootIds.includes(id)) {\n rootIds.push(id);\n }\n } else {\n owner.toolNames = [...new Set([...owner.toolNames, ...toolNames])].sort();\n }\n childParentId = id;\n if (visual) {\n const existing = regions.find((region) =>\n sameElements(region.elements, visual.elements) ||\n sameRects(region.rects, visual.rects) ||\n sameBounds(region.rects, visual.rects)\n );\n if (existing) {\n existing.ownerIds = [...new Set([...existing.ownerIds, id])];\n existing.componentNames = [...new Set([...existing.componentNames, name])].sort();\n existing.toolNames = [...new Set([...existing.toolNames, ...toolNames])].sort();\n existing.elements = [...new Set([...existing.elements, ...visual.elements])];\n } else {\n regions.push({\n id,\n ownerIds: [id],\n componentNames: [name],\n toolNames,\n elements: visual.elements,\n rects: visual.rects,\n });\n }\n }\n }\n visit(current.child, childParentId);\n }\n };\n for (const root of new Set(roots)) {\n visit(root.current?.child as InspectorReactFiber | undefined);\n }\n return { owners, regions, rootIds };\n}\n\nexport function collectRuntimeToolRegions(\n roots: Iterable<ReactDevtoolsRoot>,\n tools: readonly AgentToolDefinition<unknown>[],\n overlayHost: HTMLElement,\n): RuntimeToolRegion[] {\n return collectRuntimeToolSnapshot(roots, tools, overlayHost).regions;\n}\n"]}
@@ -59,9 +59,7 @@ export function executionSnapshot(value) {
59
59
  return;
60
60
  }
61
61
  if (item instanceof Date) {
62
- quote(Number.isNaN(Date.prototype.getTime.call(item))
63
- ? "Invalid Date"
64
- : Date.prototype.toISOString.call(item));
62
+ quote(Number.isNaN(Date.prototype.getTime.call(item)) ? "Invalid Date" : Date.prototype.toISOString.call(item));
65
63
  return;
66
64
  }
67
65
  if (ancestors.has(item)) {
@@ -141,9 +139,7 @@ export function useExecutionHistory(runtime) {
141
139
  if (!active)
142
140
  return;
143
141
  const input = event.status === "running" ? executionSnapshot(event.input) : undefined;
144
- const output = event.status === "running"
145
- ? undefined
146
- : executionSnapshot(event.status === "success" ? event.result : event.error);
142
+ const output = event.status === "running" ? undefined : executionSnapshot(event.status === "success" ? event.result : event.error);
147
143
  setState((current) => {
148
144
  if (current.runtime !== runtime)
149
145
  return current;
@@ -152,32 +148,18 @@ export function useExecutionHistory(runtime) {
152
148
  return current;
153
149
  const previous = current.records[index];
154
150
  const record = {
155
- id: event.id,
156
- operationId: event.operationId,
157
- name: event.name,
158
- status: event.status,
159
- cancelled: event.cancelled,
160
- startedAt: event.startedAt,
161
- finishedAt: event.finishedAt,
162
- input: previous?.input ?? input,
163
- ...(output ? { output } : {}),
151
+ id: event.id, operationId: event.operationId, name: event.name,
152
+ status: event.status, cancelled: event.cancelled,
153
+ startedAt: event.startedAt, finishedAt: event.finishedAt,
154
+ input: previous?.input ?? input, ...(output ? { output } : {}),
164
155
  };
165
156
  const records = index < 0
166
157
  ? [record, ...current.records].slice(0, 100)
167
- : current.records.map((item, position) => (position === index ? record : item));
168
- return {
169
- runtime,
170
- records,
171
- selectedId: records.some(({ id }) => id === current.selectedId)
172
- ? current.selectedId
173
- : undefined,
174
- };
158
+ : current.records.map((item, position) => position === index ? record : item);
159
+ return { runtime, records, selectedId: records.some(({ id }) => id === current.selectedId) ? current.selectedId : undefined };
175
160
  });
176
161
  });
177
- return () => {
178
- active = false;
179
- unsubscribe();
180
- };
162
+ return () => { active = false; unsubscribe(); };
181
163
  }, [runtime]);
182
164
  const records = state.runtime === runtime ? state.records : [];
183
165
  return {
@@ -187,3 +169,4 @@ export function useExecutionHistory(runtime) {
187
169
  clear: () => setState({ runtime, records: [] }),
188
170
  };
189
171
  }
172
+ //# sourceMappingURL=use-execution-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-execution-history.js","sourceRoot":"","sources":["../src/use-execution-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAgB5C,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,UAAU,GAAG,WAAW,CAAC;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,EAAE,EAAE,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAChF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;YAChI,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC;QACzE,MAAM,EAAE,CAAC,UAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACnF,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { ToolRuntime } from \"@nexface/tools\";\n\ntype ExecutionEvent = Parameters<Parameters<ToolRuntime[\"on\"]>[1]>[0];\ntype Snapshot = { text: string; truncated: boolean };\ntype ExecutionRecord = {\n id: string;\n operationId: string | undefined;\n name: string;\n status: ExecutionEvent[\"status\"];\n cancelled: boolean | undefined;\n startedAt: number;\n finishedAt: number | undefined;\n input: Snapshot;\n output?: Snapshot;\n};\nconst MAX_BYTES = 32 * 1024;\nconst TRUNCATION = \"\\n[内容已截断]\";\n\nexport function executionSnapshot(value: unknown): Snapshot {\n const encoder = new TextEncoder();\n const parts: string[] = [];\n const ancestors = new Set<object>();\n let remaining = MAX_BYTES - encoder.encode(TRUNCATION).length;\n let truncated = false;\n let nodes = 0;\n const write = (text: string) => {\n if (remaining <= 0) { truncated = true; return; }\n const bounded = text.slice(0, MAX_BYTES);\n const bytes = encoder.encode(bounded);\n if (bytes.length <= remaining && bounded.length === text.length) {\n parts.push(bounded);\n remaining -= bytes.length;\n } else {\n let prefix = \"\";\n for (const character of bounded) {\n const size = encoder.encode(character).length;\n if (size > remaining) break;\n prefix += character;\n remaining -= size;\n }\n parts.push(prefix);\n remaining = 0;\n truncated = true;\n }\n };\n const quote = (text: string) => {\n if (text.length > MAX_BYTES) truncated = true;\n write(JSON.stringify(text.slice(0, MAX_BYTES)));\n };\n const visit = (item: unknown, depth: number): void => {\n if (remaining <= 0) return;\n if (++nodes > 1000 || depth > 8) {\n truncated = true;\n write('\"[内容已截断]\"');\n return;\n }\n if (typeof item === \"string\") { quote(item); return; }\n if (typeof item === \"function\") { write('\"[函数]\"'); return; }\n if (item === null || typeof item !== \"object\") {\n write(typeof item === \"bigint\" ? `${item}n` : String(item));\n return;\n }\n if (item instanceof Date) {\n quote(Number.isNaN(Date.prototype.getTime.call(item)) ? \"Invalid Date\" : Date.prototype.toISOString.call(item));\n return;\n }\n if (ancestors.has(item)) { write('\"[循环引用]\"'); return; }\n ancestors.add(item);\n let source = item;\n if (item instanceof Error) {\n source = Object.create(null) as object;\n for (const key of [\"name\", \"message\", \"code\", \"details\"]) {\n let owner: object | null = item;\n for (let level = 0; owner && level < 8; level++, owner = Object.getPrototypeOf(owner) as object | null) {\n const descriptor = Object.getOwnPropertyDescriptor(owner, key);\n if (descriptor) {\n Object.defineProperty(source, key, { ...descriptor, enumerable: true });\n break;\n }\n }\n }\n }\n const array = Array.isArray(source);\n write(array ? \"[\" : \"{\");\n let count = 0;\n let keys = 0;\n function* entries(): Generator<string> {\n if (Array.isArray(source)) {\n for (let index = 0; index < source.length; index++) yield String(index);\n } else {\n for (const key in source) yield key;\n }\n }\n for (const key of entries()) {\n if (++keys > 1000) { truncated = true; break; }\n if (!array && !Object.prototype.hasOwnProperty.call(source, key)) continue;\n if (remaining <= 0 || nodes >= 1000) { truncated = true; break; }\n write(`${count++ ? \",\" : \"\"}\\n${\" \".repeat(depth + 1)}`);\n if (!array) { quote(key); write(\": \"); }\n const descriptor = Object.getOwnPropertyDescriptor(source, key);\n if (descriptor && \"value\" in descriptor) visit(descriptor.value, depth + 1);\n else write(descriptor ? '\"[访问器]\"' : '\"[空位]\"');\n }\n if (count) write(`\\n${\" \".repeat(depth)}`);\n write(array ? \"]\" : \"}\");\n ancestors.delete(item);\n };\n try {\n visit(value, 0);\n return { text: parts.join(\"\") + (truncated ? TRUNCATION : \"\"), truncated };\n } catch {\n return { text: \"[无法展示此值]\", truncated: false };\n }\n}\n\nexport function useExecutionHistory(runtime: ToolRuntime) {\n const [state, setState] = useState<{ runtime: ToolRuntime; records: ExecutionRecord[]; selectedId?: string | undefined }>({ runtime, records: [] });\n useEffect(() => {\n let active = true;\n setState({ runtime, records: [] });\n const unsubscribe = runtime.on(\"toolexecution\", (event) => {\n if (!active) return;\n const input = event.status === \"running\" ? executionSnapshot(event.input) : undefined;\n const output = event.status === \"running\" ? undefined : executionSnapshot(event.status === \"success\" ? event.result : event.error);\n setState((current) => {\n if (current.runtime !== runtime) return current;\n const index = current.records.findIndex(({ id }) => id === event.id);\n if (index < 0 && !input) return current;\n const previous = current.records[index];\n const record: ExecutionRecord = {\n id: event.id, operationId: event.operationId, name: event.name,\n status: event.status, cancelled: event.cancelled,\n startedAt: event.startedAt, finishedAt: event.finishedAt,\n input: previous?.input ?? input!, ...(output ? { output } : {}),\n };\n const records = index < 0\n ? [record, ...current.records].slice(0, 100)\n : current.records.map((item, position) => position === index ? record : item);\n return { runtime, records, selectedId: records.some(({ id }) => id === current.selectedId) ? current.selectedId : undefined };\n });\n });\n return () => { active = false; unsubscribe(); };\n }, [runtime]);\n const records = state.runtime === runtime ? state.records : [];\n return {\n records,\n selected: records.find(({ id }) => id === state.selectedId) ?? records[0],\n select: (selectedId: string) => setState((current) => ({ ...current, selectedId })),\n clear: () => setState({ runtime, records: [] }),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexface/inspector",
3
- "version": "0.1.14",
3
+ "version": "0.1.15-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -13,15 +13,11 @@
13
13
  }
14
14
  },
15
15
  "peerDependencies": {
16
- "@nexface/tools": "0.1.14",
16
+ "@nexface/tools": "0.1.15-alpha.0",
17
17
  "react": ">=17",
18
18
  "react-dom": ">=17"
19
19
  },
20
20
  "files": [
21
21
  "dist"
22
- ],
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/fishear/nexface.git"
26
- }
22
+ ]
27
23
  }
@@ -1,10 +0,0 @@
1
- export declare const TOOL_ERROR_CODES: readonly ["EXECUTION_OUTCOME_UNKNOWN", "ACTION_IN_FLIGHT", "ACTION_NOT_HANDLED", "ACTION_TARGET_UNAVAILABLE", "BROWSER_EXECUTION_FAILED", "BROWSER_SNAPSHOT_REQUIRED", "BROWSER_TOOLS_UNAVAILABLE", "CONTRACT_MISMATCH", "DUPLICATE_BINDING", "INVALID_INPUT", "INVALID_TOOL_RUNTIME", "OPERATION_BUSY", "TOOL_CANCELLED", "TOOL_CONFIRMATION_INVALIDATED", "TOOL_CONFIRMATION_REJECTED", "TOOL_ERROR", "TOOL_REGISTRATION_TIMEOUT", "TOOL_SKIPPED", "TOOL_UNAVAILABLE", "UNKNOWN_TOOL"];
2
- type AgentToolErrorCode = (typeof TOOL_ERROR_CODES)[number];
3
- export declare class AgentToolError extends Error {
4
- readonly code: AgentToolErrorCode;
5
- readonly details?: unknown | undefined;
6
- readonly type: "tool_runtime_error";
7
- readonly domain: "tool";
8
- constructor(code: AgentToolErrorCode, message: string, details?: unknown | undefined);
9
- }
10
- export {};
@@ -1,35 +0,0 @@
1
- // Generated from shared/errors.ts. Do not edit manually.
2
- export const TOOL_ERROR_CODES = [
3
- "EXECUTION_OUTCOME_UNKNOWN",
4
- "ACTION_IN_FLIGHT",
5
- "ACTION_NOT_HANDLED",
6
- "ACTION_TARGET_UNAVAILABLE",
7
- "BROWSER_EXECUTION_FAILED",
8
- "BROWSER_SNAPSHOT_REQUIRED",
9
- "BROWSER_TOOLS_UNAVAILABLE",
10
- "CONTRACT_MISMATCH",
11
- "DUPLICATE_BINDING",
12
- "INVALID_INPUT",
13
- "INVALID_TOOL_RUNTIME",
14
- "OPERATION_BUSY",
15
- "TOOL_CANCELLED",
16
- "TOOL_CONFIRMATION_INVALIDATED",
17
- "TOOL_CONFIRMATION_REJECTED",
18
- "TOOL_ERROR",
19
- "TOOL_REGISTRATION_TIMEOUT",
20
- "TOOL_SKIPPED",
21
- "TOOL_UNAVAILABLE",
22
- "UNKNOWN_TOOL",
23
- ];
24
- export class AgentToolError extends Error {
25
- code;
26
- details;
27
- type = "tool_runtime_error";
28
- domain = "tool";
29
- constructor(code, message, details) {
30
- super(message);
31
- this.code = code;
32
- this.details = details;
33
- this.name = "ToolRuntimeError";
34
- }
35
- }
@@ -1,29 +0,0 @@
1
- import type { ToolOperation, ToolRuntime } from "@nexface/tools";
2
- export type TaskProgress = {
3
- readonly phase: "processing";
4
- } | {
5
- readonly phase: "tool";
6
- readonly toolCallId: string;
7
- readonly progressLabel?: string;
8
- };
9
- interface OperationSnapshot {
10
- readonly id: string;
11
- readonly status: "running" | "waiting" | "cancelling" | "ending";
12
- readonly taskProgress?: TaskProgress;
13
- }
14
- export interface RuntimeController {
15
- getRegisteredTools(): ReturnType<ToolRuntime["getTools"]>;
16
- beginInternalOperation(options?: {
17
- signal?: AbortSignal;
18
- onCancel?: () => void;
19
- replaceWaiting?: ToolOperation;
20
- taskProgress?: TaskProgress;
21
- }): ToolOperation;
22
- setOperationWaiting(handle: ToolOperation, waiting: boolean): void;
23
- setTaskProgress(handle: ToolOperation, progress: TaskProgress): void;
24
- getOperationSnapshot(): OperationSnapshot | null;
25
- subscribeOperation(listener: () => void): () => void;
26
- }
27
- export declare const runtimeControllerSymbol: unique symbol;
28
- export declare function getRuntimeController(runtime: ToolRuntime): RuntimeController;
29
- export {};
@@ -1,10 +0,0 @@
1
- // Generated from shared/runtime-controller.ts. Do not edit manually.
2
- import { AgentToolError } from "./errors.js";
3
- export const runtimeControllerSymbol = Symbol.for("@nexface/tools/runtime-controller");
4
- export function getRuntimeController(runtime) {
5
- const controller = runtime[runtimeControllerSymbol];
6
- if (!controller) {
7
- throw new AgentToolError("INVALID_TOOL_RUNTIME", "ToolRuntime does not support internal task coordination. Use matching Nexface package versions.");
8
- }
9
- return controller;
10
- }