@nexface/tools 0.1.9-alpha.0 → 0.1.9-alpha.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.
- package/dist/internal-react.d.ts +3 -2
- package/dist/internal-react.js +3 -3
- package/dist/internal-react.js.map +1 -1
- package/dist/operation-surface.d.ts +2 -2
- package/dist/operation-surface.js +7 -4
- package/dist/operation-surface.js.map +1 -1
- package/dist/operation-view.d.ts +2 -1
- package/dist/operation-view.js +59 -17
- package/dist/operation-view.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +4 -2
- package/dist/react.js.map +1 -1
- package/package.json +5 -4
package/dist/internal-react.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import { type ReactNode } from "react";
|
|
2
3
|
export type { PageConfirmableAgentToolBinding } from "./react.js";
|
|
3
4
|
import { type ToolRuntime, type InternalToolRuntime } from "./runtime.js";
|
|
4
5
|
export interface InternalToolRuntimeHostProps {
|
|
5
6
|
children: ReactNode;
|
|
6
7
|
}
|
|
7
|
-
export declare function InternalToolRuntimeHost({ children, }: InternalToolRuntimeHostProps):
|
|
8
|
+
export declare function InternalToolRuntimeHost({ children, }: InternalToolRuntimeHostProps): React.JSX.Element;
|
|
8
9
|
export declare function InternalToolRuntimeScope({ children, runtime, }: {
|
|
9
10
|
children: ReactNode;
|
|
10
11
|
runtime: ToolRuntime;
|
|
11
|
-
}):
|
|
12
|
+
}): React.JSX.Element;
|
|
12
13
|
export declare function useInternalToolRuntime(): InternalToolRuntime;
|
|
13
14
|
export declare function useOptionalInternalToolRuntime(): InternalToolRuntime | null;
|
package/dist/internal-react.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { createContext, useContext, useMemo, } from "react";
|
|
3
3
|
import { createToolRuntime, getInternalToolRuntime, } from "./runtime.js";
|
|
4
4
|
const InternalToolRuntimeContext = createContext(null);
|
|
5
5
|
export function InternalToolRuntimeHost({ children, }) {
|
|
6
6
|
const runtime = useMemo(() => createToolRuntime(), []);
|
|
7
|
-
return (
|
|
7
|
+
return (React.createElement(InternalToolRuntimeScope, { runtime: runtime }, children));
|
|
8
8
|
}
|
|
9
9
|
export function InternalToolRuntimeScope({ children, runtime, }) {
|
|
10
10
|
const internalRuntime = getInternalToolRuntime(runtime);
|
|
11
|
-
return (
|
|
11
|
+
return (React.createElement(InternalToolRuntimeContext.Provider, { value: internalRuntime }, children));
|
|
12
12
|
}
|
|
13
13
|
export function useInternalToolRuntime() {
|
|
14
14
|
const runtime = useContext(InternalToolRuntimeContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-react.js","sourceRoot":"","sources":["../src/internal-react.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal-react.js","sourceRoot":"","sources":["../src/internal-react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,UAAU,EACV,OAAO,GAER,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAGvB,MAAM,cAAc,CAAC;AAEtB,MAAM,0BAA0B,GAC9B,aAAa,CAA6B,IAAI,CAAC,CAAC;AAMlD,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,GACqB;IAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAC;IACvD,OAAO,CACL,oBAAC,wBAAwB,IAAC,OAAO,EAAE,OAAO,IACvC,QAAQ,CACgB,CAC5B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EACvC,QAAQ,EACR,OAAO,GAIR;IACC,MAAM,eAAe,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxD,OAAO,CACL,oBAAC,0BAA0B,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,IACxD,QAAQ,CAC2B,CACvC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,8BAA8B;IAG5C,OAAO,UAAU,CAAC,0BAA0B,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import * as React from \"react\";\nimport {\n createContext,\n useContext,\n useMemo,\n type ReactNode,\n} from \"react\";\nexport type { PageConfirmableAgentToolBinding } from \"./react.js\";\n\nimport {\n createToolRuntime,\n getInternalToolRuntime,\n type ToolRuntime,\n type InternalToolRuntime,\n} from \"./runtime.js\";\n\nconst InternalToolRuntimeContext =\n createContext<InternalToolRuntime | null>(null);\n\nexport interface InternalToolRuntimeHostProps {\n children: ReactNode;\n}\n\nexport function InternalToolRuntimeHost({\n children,\n}: InternalToolRuntimeHostProps) {\n const runtime = useMemo(() => createToolRuntime(), []);\n return (\n <InternalToolRuntimeScope runtime={runtime}>\n {children}\n </InternalToolRuntimeScope>\n );\n}\n\nexport function InternalToolRuntimeScope({\n children,\n runtime,\n}: {\n children: ReactNode;\n runtime: ToolRuntime;\n}) {\n const internalRuntime = getInternalToolRuntime(runtime);\n return (\n <InternalToolRuntimeContext.Provider value={internalRuntime}>\n {children}\n </InternalToolRuntimeContext.Provider>\n );\n}\n\nexport function useInternalToolRuntime(): InternalToolRuntime {\n const runtime = useContext(InternalToolRuntimeContext);\n if (!runtime) {\n throw new Error(\n \"Nexface components must be rendered inside ToolsProvider or NexfaceProvider.\",\n );\n }\n return runtime;\n}\n\nexport function useOptionalInternalToolRuntime():\n | InternalToolRuntime\n | null {\n return useContext(InternalToolRuntimeContext);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type JSX, type ReactNode } from "react";
|
|
2
2
|
import { type ToolRuntime } from "./runtime.js";
|
|
3
3
|
export interface AgentOperationSurfaceProps {
|
|
4
4
|
toolRuntime: ToolRuntime;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
|
-
export declare function AgentOperationSurface(props: AgentOperationSurfaceProps):
|
|
7
|
+
export declare function AgentOperationSurface(props: AgentOperationSurfaceProps): JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCallback, useLayoutEffect, useRef, useState
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
3
4
|
import { getInternalToolRuntime } from "./runtime.js";
|
|
4
5
|
import { isOperationSurfaceLocked } from "./operation-lock.js";
|
|
5
6
|
import { isAgentActivation } from "./browser/focus.js";
|
|
@@ -33,7 +34,9 @@ export function AgentOperationSurface(props) {
|
|
|
33
34
|
// surface listener. React's passive root listener cannot prevent scrolling.
|
|
34
35
|
event.isPropagationStopped = () => true;
|
|
35
36
|
}, []);
|
|
36
|
-
return
|
|
37
|
+
return React.createElement(React.Fragment, null,
|
|
38
|
+
React.createElement("div", { ref: element, className: "nexface-operation-surface", onClickCapture: blockUserInput, onDoubleClickCapture: blockUserInput, onAuxClickCapture: blockUserInput, onPointerDownCapture: blockUserInput, onPointerUpCapture: blockUserInput, onPointerMoveCapture: blockUserInput, onPointerOverCapture: blockUserInput, onPointerOutCapture: blockUserInput, onMouseDownCapture: blockUserInput, onMouseUpCapture: blockUserInput, onContextMenuCapture: blockUserInput, onMouseMoveCapture: blockUserInput, onMouseOverCapture: blockUserInput, onMouseOutCapture: blockUserInput, onWheelCapture: blockPassiveUserInput, onTouchStartCapture: blockPassiveUserInput, onTouchMoveCapture: blockPassiveUserInput, onTouchEndCapture: blockUserInput, onTouchCancelCapture: blockUserInput, onKeyDownCapture: blockUserInput, onKeyUpCapture: blockUserInput, onKeyPressCapture: blockUserInput, onBeforeInputCapture: blockUserInput, onPasteCapture: blockUserInput, onCutCapture: blockUserInput, onDropCapture: blockUserInput, onDragStartCapture: blockUserInput, onSubmitCapture: blockUserInput, onResetCapture: blockUserInput }, props.children),
|
|
39
|
+
React.createElement(OperationSurfaceContent, { ...props, element: element }));
|
|
37
40
|
}
|
|
38
41
|
function OperationSurfaceContent({ toolRuntime, element }) {
|
|
39
42
|
const runtime = getInternalToolRuntime(toolRuntime);
|
|
@@ -174,6 +177,6 @@ function OperationSurfaceContent({ toolRuntime, element }) {
|
|
|
174
177
|
status: running || waiting ? "running" : outcome?.id === history.scope ? outcome.status : "completed",
|
|
175
178
|
};
|
|
176
179
|
const entries = !cycle || history.scope === cycle.id ? history.entries : [];
|
|
177
|
-
return activated || executing || entries.length ?
|
|
180
|
+
return activated || executing || entries.length ? React.createElement(OperationOverlayView, { operation: operation, progressHistory: entries, running: running, feedbackActive: Boolean(currentVisual || serverExecuting) && running && !waiting && !stopping, humanHasControl: waiting, ...(cycle?.canCancel ? { onCancel: () => runtime.requestOperationCancel(cycle.id) } : {}), cancelling: cycle?.status === "cancelling" || cycle?.status === "ending", ...(currentVisual?.position ? { fallbackPosition: currentVisual.position } : {}), resolveSurface: resolveSurface, resolveTarget: resolveTarget, onPointerReady: onPointerReady }) : null;
|
|
178
181
|
}
|
|
179
182
|
//# sourceMappingURL=operation-surface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-surface.js","sourceRoot":"","sources":["../src/operation-surface.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAuD,MAAM,OAAO,CAAC;AAElJ,OAAO,EAAE,sBAAsB,EAAoB,MAAM,cAAc,CAAC;AACxE,OAAO,E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C5E,OAAO,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAC,oBAAoB,IACrE,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,OAAO,EACxB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,OAAO,CAAC,aAAa,IAAI,eAAe,CAAC,IAAI,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,EAC7F,eAAe,EAAE,OAAO,KACpB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC1F,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,IAAI,KAAK,EAAE,MAAM,KAAK,QAAQ,KACpE,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACjF,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC9B,CAAC,CAAC,CAAC,IAAI,CAAC;AACZ,CAAC","sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState, useSyncExternalStore, type ReactNode, type RefObject, type SyntheticEvent } from \"react\";\nimport type { AgentToolExecutionEvent } from \"./internal-types.js\";\nimport { getInternalToolRuntime, type ToolRuntime } from \"./runtime.js\";\nimport { isOperationSurfaceLocked } from \"./operation-lock.js\";\nimport { isAgentActivation } from \"./browser/focus.js\";\nimport { OperationOverlayView } from \"./operation-view.js\";\nimport type { AgentOperation, AgentOperationProgressEntry } from \"./operation-types.js\";\n\nconst CENTER_BROWSER_TOOL_NAMES = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\"]);\n\nexport interface AgentOperationSurfaceProps {\n toolRuntime: ToolRuntime;\n children: ReactNode;\n}\n\nconst surfaces = new WeakSet<ToolRuntime>();\n\nexport function AgentOperationSurface(props: AgentOperationSurfaceProps) {\n const element = useRef<HTMLDivElement>(null);\n const initial = useRef(props.toolRuntime);\n if (initial.current !== props.toolRuntime) {\n throw new Error(\"AgentOperationSurface requires a stable Runtime. Remount it to change Runtime.\");\n }\n useLayoutEffect(() => {\n if (surfaces.has(props.toolRuntime)) throw new Error(\"Only one AgentOperationSurface is supported per Runtime.\");\n surfaces.add(props.toolRuntime);\n return () => { surfaces.delete(props.toolRuntime); };\n }, [props.toolRuntime]);\n const blockUserInput = useCallback((event: SyntheticEvent) => {\n if ((event.type === \"submit\" || event.type === \"reset\") && isAgentActivation()) return;\n if (!element.current || !isOperationSurfaceLocked(element.current) || !event.nativeEvent.isTrusted) return;\n event.preventDefault();\n event.stopPropagation();\n }, []);\n const blockPassiveUserInput = useCallback((event: SyntheticEvent) => {\n if (!element.current || !isOperationSurfaceLocked(element.current) || !event.nativeEvent.isTrusted) return;\n // Stop React's capture dispatch, but let the native event reach our non-passive\n // surface listener. React's passive root listener cannot prevent scrolling.\n event.isPropagationStopped = () => true;\n }, []);\n return <>\n <div ref={element} className=\"nexface-operation-surface\"\n onClickCapture={blockUserInput} onDoubleClickCapture={blockUserInput} onAuxClickCapture={blockUserInput}\n onPointerDownCapture={blockUserInput} onPointerUpCapture={blockUserInput}\n onPointerMoveCapture={blockUserInput} onPointerOverCapture={blockUserInput} onPointerOutCapture={blockUserInput}\n onMouseDownCapture={blockUserInput} onMouseUpCapture={blockUserInput} onContextMenuCapture={blockUserInput}\n onMouseMoveCapture={blockUserInput} onMouseOverCapture={blockUserInput} onMouseOutCapture={blockUserInput}\n onWheelCapture={blockPassiveUserInput} onTouchStartCapture={blockPassiveUserInput} onTouchMoveCapture={blockPassiveUserInput}\n onTouchEndCapture={blockUserInput} onTouchCancelCapture={blockUserInput}\n onKeyDownCapture={blockUserInput} onKeyUpCapture={blockUserInput} onKeyPressCapture={blockUserInput}\n onBeforeInputCapture={blockUserInput} onPasteCapture={blockUserInput} onCutCapture={blockUserInput}\n onDropCapture={blockUserInput} onDragStartCapture={blockUserInput}\n onSubmitCapture={blockUserInput} onResetCapture={blockUserInput}\n >{props.children}</div>\n <OperationSurfaceContent {...props} element={element} />\n </>;\n}\n\nfunction OperationSurfaceContent({ toolRuntime, element }: AgentOperationSurfaceProps & { element: RefObject<HTMLDivElement | null> }) {\n const runtime = getInternalToolRuntime(toolRuntime);\n const activity = useSyncExternalStore(runtime.subscribeActivity, runtime.getActivitySnapshot, runtime.getActivitySnapshot);\n const cycle = activity.operation;\n const [outcome, setOutcome] = useState<{ id: string; status: \"completed\" | \"failed\" | \"cancelled\" }>();\n useLayoutEffect(() => runtime.subscribeActivity(() => {\n const current = runtime.getActivitySnapshot().operation;\n // Task progress does not replace page feedback. Only lifecycle boundaries clear it.\n setVisual((visual) => {\n if (current) return current.status === \"running\" && visual?.event.operationId === current.id ? visual : undefined;\n return visual && runtime.getActivitySnapshot().executions.some((event) => event.id === visual.event.id) ? visual : undefined;\n });\n if (current?.status === \"ending\" && current.outcome) setOutcome({ id: current.id, status: current.outcome });\n }), [runtime]);\n const [visual, setVisual] = useState<{ event: AgentToolExecutionEvent; target?: HTMLElement; position?: { left: number; top: number } }>();\n const pendingPresentation = useRef<{ id: string; finish(): void; interrupt(): void } | undefined>(undefined);\n useLayoutEffect(() => {\n const dispose = runtime.setPageActionPresentation((event, signal) => {\n const target = runtime.resolveTarget(event.tool, event.input);\n if (!target || !element.current?.contains(target)) return Promise.resolve();\n return new Promise<void>((resolve, reject) => {\n let finished = false;\n const settle = (error?: Error) => {\n if (finished) return;\n finished = true;\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", finish);\n if (pendingPresentation.current?.id === event.id) pendingPresentation.current = undefined;\n if (error) reject(error);\n else resolve();\n };\n const finish = () => settle();\n const timer = setTimeout(finish, 750);\n pendingPresentation.current = {\n id: event.id,\n finish,\n interrupt: () => settle(new Error(\"Page action presentation was interrupted.\")),\n };\n if (signal?.aborted) finish();\n else signal?.addEventListener(\"abort\", finish, { once: true });\n });\n });\n return () => { pendingPresentation.current?.interrupt(); dispose(); };\n }, [runtime, element]);\n const onPointerReady = useCallback((id: string) => {\n if (pendingPresentation.current?.id === id) pendingPresentation.current.finish();\n }, []);\n const [history, setHistory] = useState<{ scope: string; entries: AgentOperationProgressEntry[] }>({ scope: \"\", entries: [] });\n useLayoutEffect(() => {\n const onExecution = (event: AgentToolExecutionEvent) => {\n const scope = event.operationId ?? event.id;\n const operation = runtime.getActivitySnapshot().operation;\n const canDisplay = !event.operationId || (operation?.id === event.operationId && operation.status === \"running\");\n if (canDisplay && event.status === \"running\") {\n const target = event.tool.definition.effect === \"navigate\"\n ? element.current\n : runtime.resolveTarget(event.tool, event.input);\n if (target?.isConnected && element.current?.contains(target)) {\n const rect = target.getBoundingClientRect();\n setVisual({ event, target, position: { left: rect.left + rect.width / 2, top: rect.top + rect.height / 2 } });\n } else if (CENTER_BROWSER_TOOL_NAMES.has(event.name)) {\n setVisual({ event });\n } else if (event.name === \"nxf_applyAction\") {\n setVisual(undefined);\n }\n } else if (canDisplay) {\n setVisual((current) => current?.event.id === event.id && current.event.operationId === event.operationId\n ? { ...current, event: { ...current.event, ...event } }\n : current);\n }\n setHistory((current) => {\n if ((operation && event.operationId !== operation.id) || (event.status !== \"running\" && current.scope !== scope)) return current;\n const entries = current.scope === scope ? current.entries : [];\n const entry = {\n toolCallId: event.id,\n progressLabel: `${event.progressLabel || \"正在处理你的请求\"} · ${event.cancelled ? \"已取消\" : event.status === \"running\" ? \"执行中\" : event.status === \"success\" ? \"已完成\" : \"失败\"}`,\n };\n return { scope, entries: entries.some((item) => item.toolCallId === event.id)\n ? entries.map((item) => item.toolCallId === event.id ? entry : item)\n : [...entries, entry] };\n });\n };\n const unsubscribe = toolRuntime.on(\"toolexecution\", onExecution);\n for (const event of runtime.getActivitySnapshot().executions) onExecution(event);\n return unsubscribe;\n }, [runtime, toolRuntime, element]);\n const activated = Boolean(cycle && (cycle.source === \"webmcp\" || cycle.hasExecuted));\n const executing = activity.executions.length > 0;\n const waiting = cycle?.status === \"waiting\" && !executing;\n const running = executing || (activated && cycle?.status !== \"waiting\");\n const stopping = cycle?.status === \"cancelling\" || cycle?.status === \"ending\";\n useLayoutEffect(() => {\n if (!running || waiting) setVisual(undefined);\n }, [running, waiting]);\n const serverExecuting = cycle?.taskProgress?.phase === \"tool\";\n const currentVisual = !serverExecuting && !stopping && !waiting && visual && (cycle\n ? cycle.status === \"running\" && visual.event.operationId === cycle.id\n : activity.executions.some((event) => event.id === visual.event.id)) ? visual : undefined;\n const resolveSurface = useCallback(() => element.current ?? undefined, [element]);\n const resolveTarget = useCallback(() => {\n if (!currentVisual) return undefined;\n const target = currentVisual.target;\n if (target?.isConnected && element.current?.contains(target)\n && (currentVisual.event.tool.definition.effect === \"navigate\" || toolRuntime.getTools().includes(currentVisual.event.tool))) return { element: target };\n return undefined;\n }, [currentVisual, element, toolRuntime]);\n const operation: AgentOperation = currentVisual ? {\n toolCallId: currentVisual.event.id,\n name: currentVisual.event.name,\n input: currentVisual.event.input,\n effect: currentVisual.event.tool.definition.effect,\n progressLabel: currentVisual.event.progressLabel || \"正在处理你的请求\",\n status: currentVisual.event.status === \"running\" ? \"running\" : currentVisual.event.status === \"success\" ? \"completed\" : \"failed\",\n } : {\n toolCallId: cycle?.taskProgress?.phase === \"tool\" ? cycle.taskProgress.toolCallId : cycle?.id ?? history.scope,\n name: \"agent\",\n ...(serverExecuting ? { effect: \"read\" as const } : {}),\n progressLabel: waiting ? \"等待你完成操作\" : cycle?.status === \"cancelling\" ? \"正在终止\" : cycle?.taskProgress?.phase === \"tool\" ? cycle.taskProgress.progressLabel || \"正在执行工具\" : cycle?.taskProgress ? \"正在处理\" : \"正在处理你的请求\",\n status: running || waiting ? \"running\" : outcome?.id === history.scope ? outcome.status : \"completed\",\n };\n const entries = !cycle || history.scope === cycle.id ? history.entries : [];\n return activated || executing || entries.length ? <OperationOverlayView\n operation={operation}\n progressHistory={entries}\n running={running}\n feedbackActive={Boolean(currentVisual || serverExecuting) && running && !waiting && !stopping}\n humanHasControl={waiting}\n {...(cycle?.canCancel ? { onCancel: () => runtime.requestOperationCancel(cycle.id) } : {})}\n cancelling={cycle?.status === \"cancelling\" || cycle?.status === \"ending\"}\n {...(currentVisual?.position ? { fallbackPosition: currentVisual.position } : {})}\n resolveSurface={resolveSurface}\n resolveTarget={resolveTarget}\n onPointerReady={onPointerReady}\n /> : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation-surface.js","sourceRoot":"","sources":["../src/operation-surface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAiE,MAAM,OAAO,CAAC;AACtI,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAoB,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAOpF,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAe,CAAC;AAE5C,MAAM,UAAU,qBAAqB,CAAC,KAAiC;IACrE,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,C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AAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACjF,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC9B,CAAC,CAAC,CAAC,IAAI,CAAC;AACZ,CAAC","sourcesContent":["import * as React from \"react\";\nimport { useCallback, useLayoutEffect, useRef, useState, type JSX, type ReactNode, type RefObject, type SyntheticEvent } from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim\";\nimport type { AgentToolExecutionEvent } from \"./internal-types.js\";\nimport { getInternalToolRuntime, type ToolRuntime } from \"./runtime.js\";\nimport { isOperationSurfaceLocked } from \"./operation-lock.js\";\nimport { isAgentActivation } from \"./browser/focus.js\";\nimport { OperationOverlayView } from \"./operation-view.js\";\nimport type { AgentOperation, AgentOperationProgressEntry } from \"./operation-types.js\";\n\nconst CENTER_BROWSER_TOOL_NAMES = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\"]);\n\nexport interface AgentOperationSurfaceProps {\n toolRuntime: ToolRuntime;\n children: ReactNode;\n}\n\nconst surfaces = new WeakSet<ToolRuntime>();\n\nexport function AgentOperationSurface(props: AgentOperationSurfaceProps): JSX.Element {\n const element = useRef<HTMLDivElement>(null);\n const initial = useRef(props.toolRuntime);\n if (initial.current !== props.toolRuntime) {\n throw new Error(\"AgentOperationSurface requires a stable Runtime. Remount it to change Runtime.\");\n }\n useLayoutEffect(() => {\n if (surfaces.has(props.toolRuntime)) throw new Error(\"Only one AgentOperationSurface is supported per Runtime.\");\n surfaces.add(props.toolRuntime);\n return () => { surfaces.delete(props.toolRuntime); };\n }, [props.toolRuntime]);\n const blockUserInput = useCallback((event: SyntheticEvent) => {\n if ((event.type === \"submit\" || event.type === \"reset\") && isAgentActivation()) return;\n if (!element.current || !isOperationSurfaceLocked(element.current) || !event.nativeEvent.isTrusted) return;\n event.preventDefault();\n event.stopPropagation();\n }, []);\n const blockPassiveUserInput = useCallback((event: SyntheticEvent) => {\n if (!element.current || !isOperationSurfaceLocked(element.current) || !event.nativeEvent.isTrusted) return;\n // Stop React's capture dispatch, but let the native event reach our non-passive\n // surface listener. React's passive root listener cannot prevent scrolling.\n event.isPropagationStopped = () => true;\n }, []);\n return <>\n <div ref={element} className=\"nexface-operation-surface\"\n onClickCapture={blockUserInput} onDoubleClickCapture={blockUserInput} onAuxClickCapture={blockUserInput}\n onPointerDownCapture={blockUserInput} onPointerUpCapture={blockUserInput}\n onPointerMoveCapture={blockUserInput} onPointerOverCapture={blockUserInput} onPointerOutCapture={blockUserInput}\n onMouseDownCapture={blockUserInput} onMouseUpCapture={blockUserInput} onContextMenuCapture={blockUserInput}\n onMouseMoveCapture={blockUserInput} onMouseOverCapture={blockUserInput} onMouseOutCapture={blockUserInput}\n onWheelCapture={blockPassiveUserInput} onTouchStartCapture={blockPassiveUserInput} onTouchMoveCapture={blockPassiveUserInput}\n onTouchEndCapture={blockUserInput} onTouchCancelCapture={blockUserInput}\n onKeyDownCapture={blockUserInput} onKeyUpCapture={blockUserInput} onKeyPressCapture={blockUserInput}\n onBeforeInputCapture={blockUserInput} onPasteCapture={blockUserInput} onCutCapture={blockUserInput}\n onDropCapture={blockUserInput} onDragStartCapture={blockUserInput}\n onSubmitCapture={blockUserInput} onResetCapture={blockUserInput}\n >{props.children}</div>\n <OperationSurfaceContent {...props} element={element} />\n </>;\n}\n\nfunction OperationSurfaceContent({ toolRuntime, element }: AgentOperationSurfaceProps & { element: RefObject<HTMLDivElement | null> }) {\n const runtime = getInternalToolRuntime(toolRuntime);\n const activity = useSyncExternalStore(runtime.subscribeActivity, runtime.getActivitySnapshot, runtime.getActivitySnapshot);\n const cycle = activity.operation;\n const [outcome, setOutcome] = useState<{ id: string; status: \"completed\" | \"failed\" | \"cancelled\" }>();\n useLayoutEffect(() => runtime.subscribeActivity(() => {\n const current = runtime.getActivitySnapshot().operation;\n // Task progress does not replace page feedback. Only lifecycle boundaries clear it.\n setVisual((visual) => {\n if (current) return current.status === \"running\" && visual?.event.operationId === current.id ? visual : undefined;\n return visual && runtime.getActivitySnapshot().executions.some((event) => event.id === visual.event.id) ? visual : undefined;\n });\n if (current?.status === \"ending\" && current.outcome) setOutcome({ id: current.id, status: current.outcome });\n }), [runtime]);\n const [visual, setVisual] = useState<{ event: AgentToolExecutionEvent; target?: HTMLElement; position?: { left: number; top: number } }>();\n const pendingPresentation = useRef<{ id: string; finish(): void; interrupt(): void } | undefined>(undefined);\n useLayoutEffect(() => {\n const dispose = runtime.setPageActionPresentation((event, signal) => {\n const target = runtime.resolveTarget(event.tool, event.input);\n if (!target || !element.current?.contains(target)) return Promise.resolve();\n return new Promise<void>((resolve, reject) => {\n let finished = false;\n const settle = (error?: Error) => {\n if (finished) return;\n finished = true;\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", finish);\n if (pendingPresentation.current?.id === event.id) pendingPresentation.current = undefined;\n if (error) reject(error);\n else resolve();\n };\n const finish = () => settle();\n const timer = setTimeout(finish, 750);\n pendingPresentation.current = {\n id: event.id,\n finish,\n interrupt: () => settle(new Error(\"Page action presentation was interrupted.\")),\n };\n if (signal?.aborted) finish();\n else signal?.addEventListener(\"abort\", finish, { once: true });\n });\n });\n return () => { pendingPresentation.current?.interrupt(); dispose(); };\n }, [runtime, element]);\n const onPointerReady = useCallback((id: string) => {\n if (pendingPresentation.current?.id === id) pendingPresentation.current.finish();\n }, []);\n const [history, setHistory] = useState<{ scope: string; entries: AgentOperationProgressEntry[] }>({ scope: \"\", entries: [] });\n useLayoutEffect(() => {\n const onExecution = (event: AgentToolExecutionEvent) => {\n const scope = event.operationId ?? event.id;\n const operation = runtime.getActivitySnapshot().operation;\n const canDisplay = !event.operationId || (operation?.id === event.operationId && operation.status === \"running\");\n if (canDisplay && event.status === \"running\") {\n const target = event.tool.definition.effect === \"navigate\"\n ? element.current\n : runtime.resolveTarget(event.tool, event.input);\n if (target?.isConnected && element.current?.contains(target)) {\n const rect = target.getBoundingClientRect();\n setVisual({ event, target, position: { left: rect.left + rect.width / 2, top: rect.top + rect.height / 2 } });\n } else if (CENTER_BROWSER_TOOL_NAMES.has(event.name)) {\n setVisual({ event });\n } else if (event.name === \"nxf_applyAction\") {\n setVisual(undefined);\n }\n } else if (canDisplay) {\n setVisual((current) => current?.event.id === event.id && current.event.operationId === event.operationId\n ? { ...current, event: { ...current.event, ...event } }\n : current);\n }\n setHistory((current) => {\n if ((operation && event.operationId !== operation.id) || (event.status !== \"running\" && current.scope !== scope)) return current;\n const entries = current.scope === scope ? current.entries : [];\n const entry = {\n toolCallId: event.id,\n progressLabel: `${event.progressLabel || \"正在处理你的请求\"} · ${event.cancelled ? \"已取消\" : event.status === \"running\" ? \"执行中\" : event.status === \"success\" ? \"已完成\" : \"失败\"}`,\n };\n return { scope, entries: entries.some((item) => item.toolCallId === event.id)\n ? entries.map((item) => item.toolCallId === event.id ? entry : item)\n : [...entries, entry] };\n });\n };\n const unsubscribe = toolRuntime.on(\"toolexecution\", onExecution);\n for (const event of runtime.getActivitySnapshot().executions) onExecution(event);\n return unsubscribe;\n }, [runtime, toolRuntime, element]);\n const activated = Boolean(cycle && (cycle.source === \"webmcp\" || cycle.hasExecuted));\n const executing = activity.executions.length > 0;\n const waiting = cycle?.status === \"waiting\" && !executing;\n const running = executing || (activated && cycle?.status !== \"waiting\");\n const stopping = cycle?.status === \"cancelling\" || cycle?.status === \"ending\";\n useLayoutEffect(() => {\n if (!running || waiting) setVisual(undefined);\n }, [running, waiting]);\n const serverExecuting = cycle?.taskProgress?.phase === \"tool\";\n const currentVisual = !serverExecuting && !stopping && !waiting && visual && (cycle\n ? cycle.status === \"running\" && visual.event.operationId === cycle.id\n : activity.executions.some((event) => event.id === visual.event.id)) ? visual : undefined;\n const resolveSurface = useCallback(() => element.current ?? undefined, [element]);\n const resolveTarget = useCallback(() => {\n if (!currentVisual) return undefined;\n const target = currentVisual.target;\n if (target?.isConnected && element.current?.contains(target)\n && (currentVisual.event.tool.definition.effect === \"navigate\" || toolRuntime.getTools().includes(currentVisual.event.tool))) return { element: target };\n return undefined;\n }, [currentVisual, element, toolRuntime]);\n const operation: AgentOperation = currentVisual ? {\n toolCallId: currentVisual.event.id,\n name: currentVisual.event.name,\n input: currentVisual.event.input,\n effect: currentVisual.event.tool.definition.effect,\n progressLabel: currentVisual.event.progressLabel || \"正在处理你的请求\",\n status: currentVisual.event.status === \"running\" ? \"running\" : currentVisual.event.status === \"success\" ? \"completed\" : \"failed\",\n } : {\n toolCallId: cycle?.taskProgress?.phase === \"tool\" ? cycle.taskProgress.toolCallId : cycle?.id ?? history.scope,\n name: \"agent\",\n ...(serverExecuting ? { effect: \"read\" as const } : {}),\n progressLabel: waiting ? \"等待你完成操作\" : cycle?.status === \"cancelling\" ? \"正在终止\" : cycle?.taskProgress?.phase === \"tool\" ? cycle.taskProgress.progressLabel || \"正在执行工具\" : cycle?.taskProgress ? \"正在处理\" : \"正在处理你的请求\",\n status: running || waiting ? \"running\" : outcome?.id === history.scope ? outcome.status : \"completed\",\n };\n const entries = !cycle || history.scope === cycle.id ? history.entries : [];\n return activated || executing || entries.length ? <OperationOverlayView\n operation={operation}\n progressHistory={entries}\n running={running}\n feedbackActive={Boolean(currentVisual || serverExecuting) && running && !waiting && !stopping}\n humanHasControl={waiting}\n {...(cycle?.canCancel ? { onCancel: () => runtime.requestOperationCancel(cycle.id) } : {})}\n cancelling={cycle?.status === \"cancelling\" || cycle?.status === \"ending\"}\n {...(currentVisual?.position ? { fallbackPosition: currentVisual.position } : {})}\n resolveSurface={resolveSurface}\n resolveTarget={resolveTarget}\n onPointerReady={onPointerReady}\n /> : null;\n}\n"]}
|
package/dist/operation-view.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AgentOperation, AgentOperationProgressEntry, AgentOperationTarget } from "./operation-types.js";
|
|
2
3
|
interface PointerPosition {
|
|
3
4
|
left: number;
|
|
@@ -17,5 +18,5 @@ export interface OperationOverlayViewProps {
|
|
|
17
18
|
resolveTarget?(operation: AgentOperation): AgentOperationTarget | undefined;
|
|
18
19
|
onPointerReady?(toolCallId: string): void;
|
|
19
20
|
}
|
|
20
|
-
export declare function OperationOverlayView({ operation, progressHistory, running, feedbackActive, labelActive, humanHasControl, cancelling, onCancel, resolveSurface, resolveTarget, fallbackPosition, onPointerReady }: OperationOverlayViewProps):
|
|
21
|
+
export declare function OperationOverlayView({ operation, progressHistory, running, feedbackActive, labelActive, humanHasControl, cancelling, onCancel, resolveSurface, resolveTarget, fallbackPosition, onPointerReady }: OperationOverlayViewProps): React.ReactPortal | null;
|
|
21
22
|
export {};
|
package/dist/operation-view.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { CursorIcon as Cursor } from "@phosphor-icons/react/Cursor";
|
|
3
2
|
import { SparkleIcon as Sparkle } from "@phosphor-icons/react/Sparkle";
|
|
4
|
-
import
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useLayoutEffect, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { createPortal, flushSync } from "react-dom";
|
|
6
6
|
import { lockOperationSurface } from "./operation-lock.js";
|
|
7
7
|
const BROWSER_TOOL_NAMES = new Set(["nxf_getSnapshot", "nxf_executeAction", "nxf_applyAction"]);
|
|
@@ -226,7 +226,7 @@ function AgentPointer({ active, initialPosition, label, labelActive, operation,
|
|
|
226
226
|
const effect = operationEffect(operation);
|
|
227
227
|
const activeEffect = active ? effect : undefined;
|
|
228
228
|
const browserTool = CENTER_BROWSER_TOOL_NAMES.has(operation.name);
|
|
229
|
-
return (
|
|
229
|
+
return (React.createElement("div", { "aria-hidden": true, className: "agent-operation__pointer-effect", "data-active": active ? "true" : "false", "data-operation-effect": activeEffect, "data-phase": motion.phase, onTransitionEnd: (event) => {
|
|
230
230
|
if (event.currentTarget !== event.target
|
|
231
231
|
|| event.propertyName !== "transform"
|
|
232
232
|
|| motion.phase !== "moving"
|
|
@@ -237,8 +237,24 @@ function AgentPointer({ active, initialPosition, label, labelActive, operation,
|
|
|
237
237
|
"--agent-operation-pointer-duration": `${motion.durationMs}ms`,
|
|
238
238
|
"--agent-operation-pointer-x": `${motion.position.left}px`,
|
|
239
239
|
"--agent-operation-pointer-y": `${motion.position.top}px`,
|
|
240
|
-
}
|
|
241
|
-
|
|
240
|
+
} },
|
|
241
|
+
active && visible && motion.toolCallId === operation.toolCallId && browserTool && effect === "action" && motion.phase !== "hidden" ? (React.createElement(React.Fragment, null,
|
|
242
|
+
React.createElement("span", { className: "agent-operation__browser-halo" }),
|
|
243
|
+
labelActive ? React.createElement("span", { className: "agent-operation__browser-label", title: label }, label) : null)) : null,
|
|
244
|
+
active && visible && motion.toolCallId === operation.toolCallId && !browserTool && effect === "action" && motion.phase !== "hidden" ? (React.createElement(React.Fragment, null,
|
|
245
|
+
React.createElement("span", { className: "agent-operation__pointer-cursor" },
|
|
246
|
+
React.createElement(Cursor, { className: "agent-operation__pointer", size: 24, weight: "fill" })))) : null,
|
|
247
|
+
active && (!browserTool || (effect === "read" && visible && motion.toolCallId === operation.toolCallId))
|
|
248
|
+
&& motion.phase !== "hidden" && (labelActive || effect !== "action") ? (React.createElement("span", { className: labelActive ? "agent-operation__pointer-label" : "agent-operation__pointer-indicator", "data-browser-tool": browserTool ? "true" : undefined, "data-operation-effect": activeEffect, title: labelActive ? label : undefined },
|
|
249
|
+
activeEffect === "processing" ? React.createElement("span", { className: "agent-operation__pointer-processing" }) : null,
|
|
250
|
+
activeEffect === "read" ? (React.createElement("span", { className: "agent-operation__pointer-read-scan" },
|
|
251
|
+
React.createElement("i", null),
|
|
252
|
+
React.createElement("i", null),
|
|
253
|
+
React.createElement("i", null),
|
|
254
|
+
React.createElement("i", null),
|
|
255
|
+
React.createElement("i", null))) : null,
|
|
256
|
+
activeEffect === "navigate" ? React.createElement("span", { className: "agent-operation__pointer-navigation-trail" }) : null,
|
|
257
|
+
labelActive ? React.createElement("span", { className: "agent-operation__pointer-label-text" }, label) : null)) : null));
|
|
242
258
|
}
|
|
243
259
|
export function OperationOverlayView({ operation, progressHistory = [], running, feedbackActive = running, labelActive = feedbackActive, humanHasControl = false, cancelling = false, onCancel, resolveSurface, resolveTarget, fallbackPosition, onPointerReady }) {
|
|
244
260
|
const [, setGeometry] = useState("");
|
|
@@ -248,7 +264,7 @@ export function OperationOverlayView({ operation, progressHistory = [], running,
|
|
|
248
264
|
setGeometry([rect.left, rect.top, rect.width, rect.height].join(","));
|
|
249
265
|
}, [resolveSurface]);
|
|
250
266
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
251
|
-
const historyId =
|
|
267
|
+
const [historyId] = useState(() => `nexface-operation-history-${globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`}`);
|
|
252
268
|
const clearTimerRef = useRef(undefined);
|
|
253
269
|
const cancelButtonRef = useRef(null);
|
|
254
270
|
const controllerTimerRef = useRef(undefined);
|
|
@@ -356,16 +372,42 @@ export function OperationOverlayView({ operation, progressHistory = [], running,
|
|
|
356
372
|
const cancel = onCancel ? () => {
|
|
357
373
|
onCancel();
|
|
358
374
|
} : undefined;
|
|
359
|
-
return createPortal(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
375
|
+
return createPortal(React.createElement("div", { className: "agent-operation", "data-nexface-ignore": true, "data-feedback-active": operationFeedbackActive, "data-structured-target-lost": structuredTargetLost, "data-human-control": humanHasControl, "data-operation-effect": effect, "data-run-active": running, "data-status": visibleOperation.status },
|
|
376
|
+
agentControlsSurface && surfaceRect ? React.createElement("div", { "aria-hidden": true, className: "agent-operation__surface", style: {
|
|
377
|
+
...(highlightedRect ? {
|
|
378
|
+
"--agent-operation-cutout-height": `${highlightedRect.height}px`,
|
|
379
|
+
"--agent-operation-cutout-left": `${highlightedRect.left - surfaceRect.left}px`,
|
|
380
|
+
"--agent-operation-cutout-top": `${highlightedRect.top - surfaceRect.top}px`,
|
|
381
|
+
"--agent-operation-cutout-width": `${highlightedRect.width}px`,
|
|
382
|
+
} : {}),
|
|
383
|
+
height: surfaceRect.height, left: surfaceRect.left, top: surfaceRect.top, width: surfaceRect.width,
|
|
384
|
+
} }) : null,
|
|
385
|
+
operationFeedbackActive && highlightedRect ? React.createElement("div", { "aria-hidden": true, className: "agent-operation__target", "data-operation-effect": effect, style: { height: highlightedRect.height, left: highlightedRect.left, top: highlightedRect.top, width: highlightedRect.width } }) : null,
|
|
386
|
+
React.createElement(AgentPointer, { active: operationFeedbackActive, initialPosition: visibleOperation.name === "nxf_applyAction" && surfaceRect
|
|
387
|
+
? { left: surfaceRect.left + surfaceRect.width / 2, top: surfaceRect.top + surfaceRect.height / 2 }
|
|
388
|
+
: pointerPosition ?? fallbackPosition ?? (surfaceRect ? { left: surfaceRect.left + surfaceRect.width / 2, top: surfaceRect.top + surfaceRect.height / 2 } : undefined), label: pointerLabel, labelActive: labelActive, operation: visibleOperation, targetElement: target?.element, targetPosition: pointerPosition, visible: pointerVisible, ...(onPointerReady ? { onPointerReady } : {}) }),
|
|
389
|
+
controllerMounted ? React.createElement("section", { "aria-live": "polite", className: "agent-operation__controller", "data-visibility": controllerExiting ? "exiting" : "visible", style: surfaceRect ? { left: surfaceRect.left + surfaceRect.width / 2, right: "auto", "--agent-operation-controller-x": "-50%", maxWidth: Math.max(0, surfaceRect.width - 32) } : undefined },
|
|
390
|
+
historyOpen ? React.createElement("aside", { "aria-label": "\u672C\u6B21\u8FD0\u884C\u7684\u64CD\u4F5C\u8BB0\u5F55", className: "agent-operation__history", id: historyId },
|
|
391
|
+
React.createElement("header", null,
|
|
392
|
+
React.createElement("strong", null, "\u64CD\u4F5C\u8BB0\u5F55"),
|
|
393
|
+
React.createElement("span", null, progressHistory.length)),
|
|
394
|
+
React.createElement("ol", null, progressHistory.map(({ progressLabel: label, toolCallId }, index) => React.createElement("li", { key: toolCallId },
|
|
395
|
+
React.createElement("span", { "aria-hidden": true }, index + 1),
|
|
396
|
+
React.createElement("p", null, label))))) : null,
|
|
397
|
+
React.createElement("span", { "aria-hidden": true, className: "agent-operation__edge-flow" }),
|
|
398
|
+
React.createElement("span", { "aria-hidden": true, className: "agent-operation__pause-mark" },
|
|
399
|
+
React.createElement("i", null),
|
|
400
|
+
React.createElement("i", null)),
|
|
401
|
+
React.createElement("button", { "aria-controls": historyId, "aria-expanded": historyOpen, "aria-label": "\u67E5\u770B\u672C\u6B21\u8FD0\u884C\u7684\u64CD\u4F5C\u8BB0\u5F55", className: "agent-operation__activity", "data-open": historyOpen ? "true" : "false", disabled: progressHistory.length === 0, onClick: () => setHistoryOpen((current) => !current), title: progressHistory.length === 0 ? "暂无操作记录" : "查看本次运行的操作记录", type: "button" },
|
|
402
|
+
React.createElement(Sparkle, { className: "agent-operation__activity-icon", size: 16, weight: "fill" }),
|
|
403
|
+
React.createElement("i", null),
|
|
404
|
+
React.createElement("b", null, "\u2726")),
|
|
405
|
+
React.createElement("div", null,
|
|
406
|
+
React.createElement("span", { className: "agent-operation__heading" },
|
|
407
|
+
React.createElement("strong", null, controllerLabel)),
|
|
408
|
+
statusLabel ? React.createElement("small", { className: "agent-operation__description" },
|
|
409
|
+
React.createElement("span", { className: "agent-operation__status" }, statusLabel)) : null),
|
|
410
|
+
(running || humanHasControl) && visibleOperation.status !== "cancelled" ? React.createElement("span", { className: "agent-operation__compact-status", title: compactStatusLabel }, compactStatusLabel) : null,
|
|
411
|
+
cancel && (running || humanHasControl) && visibleOperation.status !== "cancelled" ? React.createElement("button", { ref: cancelButtonRef, className: "agent-operation__stop", type: "button", disabled: cancelling, onClick: cancel }, cancelling ? "正在终止" : "终止任务") : null) : null), document.body);
|
|
370
412
|
}
|
|
371
413
|
//# sourceMappingURL=operation-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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AQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAU,CAAC,CAAC,CAAC,IAAI,IAChP,CAAC,CAAC,CAAC,IAAI,IACb,EAAE,QAAQ,CAAC,IAAI,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { CursorIcon as Cursor } from \"@phosphor-icons/react/Cursor\";\nimport { SparkleIcon as Sparkle } from \"@phosphor-icons/react/Sparkle\";\nimport { useLayoutEffect, useEffect, useId, useRef, useState, type CSSProperties } from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport type { AgentOperation, AgentOperationProgressEntry, AgentOperationTarget } from \"./operation-types.js\";\n\nimport { lockOperationSurface } from \"./operation-lock.js\";\n\nconst BROWSER_TOOL_NAMES = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\", \"nxf_applyAction\"]);\nconst CENTER_BROWSER_TOOL_NAMES = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\"]);\nconst POINTER_EXIT_DURATION_MS = 120;\nconst CONTROLLER_EXIT_DURATION_MS = 300;\n\ninterface PointerPosition {\n left: number;\n top: number;\n}\n\ntype PointerPhase = \"hidden\" | \"resting\" | \"moving\";\n\ninterface PointerMotion {\n durationMs: number;\n phase: PointerPhase;\n position: PointerPosition;\n revision: number;\n toolCallId: string;\n}\n\nfunction operationProgressLabel(operation: AgentOperation): string {\n const progressLabel = operation.progressLabel?.trim().replace(/\\s+/g, \" \");\n if (progressLabel) return progressLabel.slice(0, 48);\n return BROWSER_TOOL_NAMES.has(operation.name)\n ? \"正在浏览网页\"\n : \"正在处理你的请求\";\n}\n\nfunction operationEffect(operation: AgentOperation): \"read\" | \"action\" | \"navigate\" | \"processing\" {\n return operation.effect ?? \"action\";\n}\n\nfunction normalizedLabel(label: string | undefined): string | undefined {\n const normalized = label?.trim().replace(/\\s+/g, \" \");\n return normalized || undefined;\n}\n\nfunction operationTargetLabel(\n operation: AgentOperation,\n target: AgentOperationTarget | undefined,\n): string | undefined {\n const label = target?.label;\n if (!label || label === operation.name) return undefined;\n const rawNamePrefix = `${operation.name} · `;\n return label.startsWith(rawNamePrefix) ? label.slice(rawNamePrefix.length) : label;\n}\n\nfunction pointerMoveDuration(from: PointerPosition, to: PointerPosition): number {\n const distance = Math.hypot(to.left - from.left, to.top - from.top);\n if (distance < 2) return 0;\n return Math.round(Math.min(360, Math.max(180, 180 + distance * 0.18)));\n}\n\nfunction pointerReachedTarget(element: HTMLElement, target: PointerPosition): boolean {\n const rect = element.getBoundingClientRect();\n return Math.hypot(rect.left - target.left, rect.top - target.top) < 2;\n}\n\ninterface AgentPointerProps {\n active: boolean;\n initialPosition: PointerPosition | undefined;\n label: string;\n labelActive: boolean;\n operation: AgentOperation;\n targetElement: HTMLElement | undefined;\n targetPosition: PointerPosition | undefined;\n visible: boolean;\n onPointerReady?(toolCallId: string): void;\n}\n\nfunction AgentPointer({ active, initialPosition, label, labelActive, operation, targetElement, targetPosition, visible, onPointerReady }: AgentPointerProps) {\n const pointerRef = useRef<HTMLDivElement>(null);\n const activeOperationRef = useRef<string | undefined>(undefined);\n const activeTargetRef = useRef<HTMLElement | undefined>(undefined);\n const exitTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const movementTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const motionRevisionRef = useRef(0);\n const latestActiveRef = useRef(active);\n const latestOperationRef = useRef(operation);\n const [motion, setMotion] = useState<PointerMotion>();\n latestActiveRef.current = active;\n latestOperationRef.current = operation;\n\n const clearExitTimer = () => {\n if (!exitTimerRef.current) return;\n clearTimeout(exitTimerRef.current);\n exitTimerRef.current = undefined;\n };\n const clearMovementTimer = () => {\n if (!movementTimerRef.current) return;\n clearTimeout(movementTimerRef.current);\n movementTimerRef.current = undefined;\n };\n const finishMovement = (revision: number, toolCallId: string) => {\n const latestOperation = latestOperationRef.current;\n if (!latestActiveRef.current\n || motionRevisionRef.current !== revision\n || latestOperation.toolCallId !== toolCallId) return;\n clearMovementTimer();\n const settle = () => setMotion((current) => current?.revision === revision ? { ...current, phase: \"resting\" } : current);\n if (latestOperation.name !== \"nxf_applyAction\" || !onPointerReady) {\n settle();\n return;\n }\n queueMicrotask(() => {\n if (!latestActiveRef.current || motionRevisionRef.current !== revision || latestOperationRef.current.toolCallId !== toolCallId) return;\n flushSync(settle);\n requestAnimationFrame(() => requestAnimationFrame(() => {\n if (latestActiveRef.current && motionRevisionRef.current === revision\n && latestOperationRef.current.toolCallId === toolCallId && activeTargetRef.current?.isConnected) onPointerReady(toolCallId);\n }));\n });\n };\n\n useEffect(() => () => {\n clearExitTimer();\n clearMovementTimer();\n }, []);\n\n useEffect(() => {\n if (!visible || !initialPosition) {\n if (!motion || motion.phase === \"hidden\") return;\n activeOperationRef.current = undefined;\n activeTargetRef.current = undefined;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n setMotion((current) => current\n ? { ...current, durationMs: POINTER_EXIT_DURATION_MS, phase: \"hidden\", revision }\n : current);\n clearExitTimer();\n exitTimerRef.current = setTimeout(() => {\n if (motionRevisionRef.current === revision) setMotion(undefined);\n }, POINTER_EXIT_DURATION_MS);\n return;\n }\n\n clearExitTimer();\n if (!motion) {\n activeOperationRef.current = operation.toolCallId;\n activeTargetRef.current = undefined;\n const revision = ++motionRevisionRef.current;\n setMotion({\n durationMs: 0,\n phase: \"resting\",\n position: initialPosition,\n revision,\n toolCallId: operation.toolCallId,\n });\n return;\n }\n\n if (!active) {\n activeOperationRef.current = undefined;\n activeTargetRef.current = undefined;\n clearMovementTimer();\n if (motion.phase !== \"resting\") {\n const revision = ++motionRevisionRef.current;\n setMotion((current) => current\n ? { ...current, phase: \"resting\", revision }\n : current);\n }\n return;\n }\n\n const operationChanged = activeOperationRef.current !== operation.toolCallId;\n if (operationChanged) {\n activeOperationRef.current = operation.toolCallId;\n activeTargetRef.current = undefined;\n clearMovementTimer();\n } else if (motion.phase === \"hidden\") {\n setMotion((current) => current\n ? { ...current, durationMs: 0, phase: \"resting\" }\n : current);\n }\n\n if (!targetElement || !targetPosition) {\n const positionChanged = CENTER_BROWSER_TOOL_NAMES.has(operation.name)\n && (motion.position.left !== initialPosition.left || motion.position.top !== initialPosition.top);\n if (operationChanged || activeTargetRef.current || positionChanged) {\n activeTargetRef.current = undefined;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n const pointerRect = pointerRef.current?.getBoundingClientRect();\n setMotion((current) => current\n ? {\n ...current,\n durationMs: 0,\n phase: \"resting\",\n position: operationChanged || positionChanged ? initialPosition : pointerRect\n ? { left: pointerRect.left, top: pointerRect.top }\n : current.position,\n revision,\n toolCallId: operation.toolCallId,\n }\n : current);\n }\n return;\n }\n const targetChanged = operationChanged || activeTargetRef.current !== targetElement;\n if (!targetChanged) {\n if (motion.position.left === targetPosition.left && motion.position.top === targetPosition.top) return;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n const durationMs = window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ? 0 : 180;\n setMotion((current) => current\n ? { ...current, durationMs, phase: \"moving\", position: targetPosition, revision }\n : current);\n if (durationMs === 0) finishMovement(revision, operation.toolCallId);\n else movementTimerRef.current = setTimeout(() => finishMovement(revision, operation.toolCallId), durationMs + 50);\n return;\n }\n\n activeTargetRef.current = targetElement;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n const pointerRect = pointerRef.current?.getBoundingClientRect();\n const currentPosition = pointerRect\n ? { left: pointerRect.left, top: pointerRect.top }\n : motion.position;\n const prefersReducedMotion = window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false;\n const durationMs = prefersReducedMotion ? 0 : pointerMoveDuration(currentPosition, targetPosition);\n setMotion((current) => current\n ? {\n ...current,\n durationMs,\n phase: \"moving\",\n position: targetPosition,\n revision,\n toolCallId: operation.toolCallId,\n }\n : current);\n if (durationMs === 0) finishMovement(revision, operation.toolCallId);\n else {\n // A first-frame position update may not dispatch transitionend.\n movementTimerRef.current = setTimeout(() => finishMovement(revision, operation.toolCallId), durationMs + 50);\n }\n }, [\n active,\n initialPosition?.left,\n initialPosition?.top,\n motion,\n operation.toolCallId,\n targetElement,\n targetPosition?.left,\n targetPosition?.top,\n visible,\n ]);\n\n if (!motion) return null;\n const effect = operationEffect(operation);\n const activeEffect = active ? effect : undefined;\n const browserTool = CENTER_BROWSER_TOOL_NAMES.has(operation.name);\n return (\n <div\n aria-hidden\n className=\"agent-operation__pointer-effect\"\n data-active={active ? \"true\" : \"false\"}\n data-operation-effect={activeEffect}\n data-phase={motion.phase}\n onTransitionEnd={(event) => {\n if (event.currentTarget !== event.target\n || event.propertyName !== \"transform\"\n || motion.phase !== \"moving\"\n || !pointerReachedTarget(event.currentTarget, motion.position)) return;\n finishMovement(motion.revision, motion.toolCallId);\n }}\n ref={pointerRef}\n style={{\n \"--agent-operation-pointer-duration\": `${motion.durationMs}ms`,\n \"--agent-operation-pointer-x\": `${motion.position.left}px`,\n \"--agent-operation-pointer-y\": `${motion.position.top}px`,\n } as CSSProperties}\n >\n {active && visible && motion.toolCallId === operation.toolCallId && browserTool && effect === \"action\" && motion.phase !== \"hidden\" ? (\n <>\n <span className=\"agent-operation__browser-halo\" />\n {labelActive ? <span className=\"agent-operation__browser-label\" title={label}>{label}</span> : null}\n </>\n ) : null}\n {active && visible && motion.toolCallId === operation.toolCallId && !browserTool && effect === \"action\" && motion.phase !== \"hidden\" ? (\n <>\n <span className=\"agent-operation__pointer-cursor\">\n <Cursor className=\"agent-operation__pointer\" size={24} weight=\"fill\" />\n </span>\n </>\n ) : null}\n {active && (!browserTool || (effect === \"read\" && visible && motion.toolCallId === operation.toolCallId))\n && motion.phase !== \"hidden\" && (labelActive || effect !== \"action\") ? (\n <span className={labelActive ? \"agent-operation__pointer-label\" : \"agent-operation__pointer-indicator\"} data-browser-tool={browserTool ? \"true\" : undefined} data-operation-effect={activeEffect} title={labelActive ? label : undefined}>\n {activeEffect === \"processing\" ? <span className=\"agent-operation__pointer-processing\" /> : null}\n {activeEffect === \"read\" ? (\n <span className=\"agent-operation__pointer-read-scan\">\n <i />\n <i />\n <i />\n <i />\n <i />\n </span>\n ) : null}\n {activeEffect === \"navigate\" ? <span className=\"agent-operation__pointer-navigation-trail\" /> : null}\n {labelActive ? <span className=\"agent-operation__pointer-label-text\">{label}</span> : null}\n </span>\n ) : null}\n </div>\n );\n}\n\nexport interface OperationOverlayViewProps {\n fallbackPosition?: PointerPosition;\n feedbackActive?: boolean;\n labelActive?: boolean;\n operation?: AgentOperation;\n progressHistory?: readonly AgentOperationProgressEntry[];\n running: boolean;\n humanHasControl?: boolean;\n cancelling?: boolean;\n onCancel?(): void;\n resolveSurface?(): HTMLElement | undefined;\n resolveTarget?(operation: AgentOperation): AgentOperationTarget | undefined;\n onPointerReady?(toolCallId: string): void;\n}\n\nexport function OperationOverlayView({ operation, progressHistory = [], running, feedbackActive = running, labelActive = feedbackActive, humanHasControl = false, cancelling = false, onCancel, resolveSurface, resolveTarget, fallbackPosition, onPointerReady }: OperationOverlayViewProps) {\n const [, setGeometry] = useState(\"\");\n useLayoutEffect(() => {\n const rect = resolveSurface?.()?.getBoundingClientRect();\n if (rect) setGeometry([rect.left, rect.top, rect.width, rect.height].join(\",\"));\n }, [resolveSurface]);\n const [historyOpen, setHistoryOpen] = useState(false);\n const historyId = useId();\n const clearTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const cancelButtonRef = useRef<HTMLButtonElement>(null);\n const controllerTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [visibleOperation, setVisibleOperation] = useState(operation);\n const [controllerMounted, setControllerMounted] = useState(Boolean(operation\n && operation.status !== \"cancelled\"\n && (running || humanHasControl || operation.status === \"failed\")));\n const [controllerExiting, setControllerExiting] = useState(false);\n useLayoutEffect(() => {\n if (clearTimerRef.current) clearTimeout(clearTimerRef.current);\n if (operation) setVisibleOperation(operation);\n if (operation?.status === \"cancelled\") {\n clearTimerRef.current = setTimeout(() => setVisibleOperation(undefined), 600);\n }\n return () => { if (clearTimerRef.current) clearTimeout(clearTimerRef.current); };\n }, [operation, running]);\n useEffect(() => {\n if ((!running && !feedbackActive && !humanHasControl) || !visibleOperation || visibleOperation.status === \"cancelled\") return;\n let frame = requestAnimationFrame(function update() {\n const surface = resolveSurface?.();\n const target = resolveTarget?.(visibleOperation)?.element;\n const geometry = [surface, target].map((element) => {\n if (!element?.isConnected) return \"\";\n const rect = element.getBoundingClientRect();\n return [rect.left, rect.top, rect.width, rect.height].join(\",\");\n }).join(\";\");\n setGeometry(geometry);\n frame = requestAnimationFrame(update);\n });\n return () => cancelAnimationFrame(frame);\n }, [visibleOperation?.toolCallId, visibleOperation?.status, running, feedbackActive, humanHasControl, resolveSurface, resolveTarget]);\n useEffect(() => {\n if (progressHistory.length === 0) setHistoryOpen(false);\n }, [progressHistory.length]);\n const controllerShouldBeVisible = Boolean(visibleOperation\n && visibleOperation.status !== \"cancelled\"\n && (running || humanHasControl || visibleOperation.status === \"failed\"));\n useEffect(() => {\n if (controllerTimerRef.current) clearTimeout(controllerTimerRef.current);\n if (controllerShouldBeVisible) {\n setControllerMounted(true);\n setControllerExiting(false);\n return;\n }\n if (!controllerMounted) {\n setControllerExiting(false);\n return;\n }\n setHistoryOpen(false);\n setControllerExiting(true);\n controllerTimerRef.current = setTimeout(() => {\n setControllerMounted(false);\n setControllerExiting(false);\n }, CONTROLLER_EXIT_DURATION_MS);\n return () => {\n if (controllerTimerRef.current) clearTimeout(controllerTimerRef.current);\n };\n }, [controllerMounted, controllerShouldBeVisible]);\n useLayoutEffect(() => {\n const surface = resolveSurface?.();\n if (!surface || !running || humanHasControl) return;\n return lockOperationSurface(surface, () => cancelButtonRef.current?.focus());\n }, [humanHasControl, resolveSurface, running]);\n if (!visibleOperation || typeof document === \"undefined\") return null;\n const resolvedTarget = resolveTarget?.(visibleOperation);\n const surfaceElement = resolveSurface?.();\n const target = resolvedTarget && (!surfaceElement || surfaceElement.contains(resolvedTarget.element))\n ? resolvedTarget\n : undefined;\n const structuredTargetLost = visibleOperation.name === \"nxf_applyAction\" && !target;\n const progressLabel = operationProgressLabel(visibleOperation);\n const effect = operationEffect(visibleOperation);\n const targetLabel = operationTargetLabel(visibleOperation, target);\n const pointerLabel = normalizedLabel(visibleOperation.progressLabel) ?? targetLabel ?? progressLabel;\n const controllerLabel = humanHasControl ? undefined : progressLabel;\n const statusLabel = humanHasControl ? \"等待你完成操作\" : {\n running: \"Agent 正在控制\",\n completed: running ? \"工具已完成,任务继续中\" : \"操作已完成\",\n failed: running ? \"Agent 正在处理错误\" : \"操作失败\",\n cancelled: \"任务已终止\",\n }[visibleOperation.status];\n const compactStatusLabel = humanHasControl\n ? \"等待你完成操作\"\n : progressLabel;\n const rect = target?.element.isConnected ? target.element.getBoundingClientRect() : undefined;\n const highlightedRect = effect === \"navigate\" ? undefined : rect;\n const surfaceRect = surfaceElement?.isConnected ? surfaceElement.getBoundingClientRect() : undefined;\n const agentControlsSurface = running && !humanHasControl;\n const operationFeedbackActive = feedbackActive && !structuredTargetLost && !humanHasControl && visibleOperation.status !== \"cancelled\";\n const pointerVisible = Boolean(surfaceRect) && operationFeedbackActive;\n const pointerPosition = rect ? {\n left: rect.left + rect.width / 2,\n top: rect.top + rect.height / 2,\n } : undefined;\n const cancel = onCancel ? () => {\n onCancel();\n } : undefined;\n return createPortal(\n <div className=\"agent-operation\" data-nexface-ignore data-feedback-active={operationFeedbackActive} data-structured-target-lost={structuredTargetLost} data-human-control={humanHasControl} data-operation-effect={effect} data-run-active={running} data-status={visibleOperation.status}>\n {agentControlsSurface && surfaceRect ? <div aria-hidden className=\"agent-operation__surface\" style={{\n ...(highlightedRect ? {\n \"--agent-operation-cutout-height\": `${highlightedRect.height}px`,\n \"--agent-operation-cutout-left\": `${highlightedRect.left - surfaceRect.left}px`,\n \"--agent-operation-cutout-top\": `${highlightedRect.top - surfaceRect.top}px`,\n \"--agent-operation-cutout-width\": `${highlightedRect.width}px`,\n } : {}),\n height: surfaceRect.height, left: surfaceRect.left, top: surfaceRect.top, width: surfaceRect.width,\n } as CSSProperties} /> : null}\n {operationFeedbackActive && highlightedRect ? <div aria-hidden className=\"agent-operation__target\" data-operation-effect={effect} style={{ height: highlightedRect.height, left: highlightedRect.left, top: highlightedRect.top, width: highlightedRect.width }} /> : null}\n <AgentPointer\n active={operationFeedbackActive}\n initialPosition={visibleOperation.name === \"nxf_applyAction\" && surfaceRect\n ? { left: surfaceRect.left + surfaceRect.width / 2, top: surfaceRect.top + surfaceRect.height / 2 }\n : pointerPosition ?? fallbackPosition ?? (surfaceRect ? { left: surfaceRect.left + surfaceRect.width / 2, top: surfaceRect.top + surfaceRect.height / 2 } : undefined)}\n label={pointerLabel}\n labelActive={labelActive}\n operation={visibleOperation}\n targetElement={target?.element}\n targetPosition={pointerPosition}\n visible={pointerVisible}\n {...(onPointerReady ? { onPointerReady } : {})}\n />\n {controllerMounted ? <section aria-live=\"polite\" className=\"agent-operation__controller\" data-visibility={controllerExiting ? \"exiting\" : \"visible\"} style={surfaceRect ? { left: surfaceRect.left + surfaceRect.width / 2, right: \"auto\", \"--agent-operation-controller-x\": \"-50%\", maxWidth: Math.max(0, surfaceRect.width - 32) } as CSSProperties : undefined}>\n {historyOpen ? <aside aria-label=\"本次运行的操作记录\" className=\"agent-operation__history\" id={historyId}>\n <header><strong>操作记录</strong><span>{progressHistory.length}</span></header>\n <ol>{progressHistory.map(({ progressLabel: label, toolCallId }, index) => <li key={toolCallId}>\n <span aria-hidden>{index + 1}</span><p>{label}</p>\n </li>)}</ol>\n </aside> : null}\n <span aria-hidden className=\"agent-operation__edge-flow\" /><span aria-hidden className=\"agent-operation__pause-mark\"><i /><i /></span><button\n aria-controls={historyId}\n aria-expanded={historyOpen}\n aria-label=\"查看本次运行的操作记录\"\n className=\"agent-operation__activity\"\n data-open={historyOpen ? \"true\" : \"false\"}\n disabled={progressHistory.length === 0}\n onClick={() => setHistoryOpen((current) => !current)}\n title={progressHistory.length === 0 ? \"暂无操作记录\" : \"查看本次运行的操作记录\"}\n type=\"button\"\n ><Sparkle className=\"agent-operation__activity-icon\" size={16} weight=\"fill\" /><i /><b>✦</b></button>\n <div><span className=\"agent-operation__heading\"><strong>{controllerLabel}</strong></span>{statusLabel ? <small className=\"agent-operation__description\"><span className=\"agent-operation__status\">{statusLabel}</span></small> : null}</div>\n {(running || humanHasControl) && visibleOperation.status !== \"cancelled\" ? <span className=\"agent-operation__compact-status\" title={compactStatusLabel}>{compactStatusLabel}</span> : null}\n {cancel && (running || humanHasControl) && visibleOperation.status !== \"cancelled\" ? <button ref={cancelButtonRef} className=\"agent-operation__stop\" type=\"button\" disabled={cancelling} onClick={cancel}>{cancelling ? \"正在终止\" : \"终止任务\"}</button> : null}\n </section> : null}\n </div>, document.body,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation-view.js","sourceRoot":"","sources":["../src/operation-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAChG,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,CAAC;AACpF,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAiBx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EAC9D,IAAI,EAAC,QAAQ;gBACd,oBAAC,OAAO,IAAC,SAAS,EAAC,gCAAgC,EAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,GAAG;gBAAA,8BAAK;gBAAA,wCAAQ,CAAS;YACrG;gBAAK,8BAAM,SAAS,EAAC,0BAA0B;oBAAC,oCAAS,eAAe,CAAU,CAAO;gBAAC,WAAW,CAAC,CAAC,CAAC,+BAAO,SAAS,EAAC,8BAA8B;oBAAC,8BAAM,SAAS,EAAC,yBAAyB,IAAE,WAAW,CAAQ,CAAQ,CAAC,CAAC,CAAC,IAAI,CAAO;YAC3O,CAAC,OAAO,IAAI,eAAe,CAAC,IAAI,gBAAgB,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,8BAAM,SAAS,EAAC,iCAAiC,EAAC,KAAK,EAAE,kBAAkB,IAAG,kBAAkB,CAAQ,CAAC,CAAC,CAAC,IAAI;YACzL,MAAM,IAAI,CAAC,OAAO,IAAI,eAAe,CAAC,IAAI,gBAAgB,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,gCAAQ,GAAG,EAAE,eAAe,EAAE,SAAS,EAAC,uBAAuB,EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,IAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAU,CAAC,CAAC,CAAC,IAAI,CAChP,CAAC,CAAC,CAAC,IAAI,CACb,EAAE,QAAQ,CAAC,IAAI,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { CursorIcon as Cursor } from \"@phosphor-icons/react/Cursor\";\nimport { SparkleIcon as Sparkle } from \"@phosphor-icons/react/Sparkle\";\nimport * as React from \"react\";\nimport { useLayoutEffect, useEffect, useRef, useState, type CSSProperties } from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport type { AgentOperation, AgentOperationProgressEntry, AgentOperationTarget } from \"./operation-types.js\";\n\nimport { lockOperationSurface } from \"./operation-lock.js\";\n\nconst BROWSER_TOOL_NAMES = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\", \"nxf_applyAction\"]);\nconst CENTER_BROWSER_TOOL_NAMES = new Set([\"nxf_getSnapshot\", \"nxf_executeAction\"]);\nconst POINTER_EXIT_DURATION_MS = 120;\nconst CONTROLLER_EXIT_DURATION_MS = 300;\n\ninterface PointerPosition {\n left: number;\n top: number;\n}\n\ntype PointerPhase = \"hidden\" | \"resting\" | \"moving\";\n\ninterface PointerMotion {\n durationMs: number;\n phase: PointerPhase;\n position: PointerPosition;\n revision: number;\n toolCallId: string;\n}\n\nfunction operationProgressLabel(operation: AgentOperation): string {\n const progressLabel = operation.progressLabel?.trim().replace(/\\s+/g, \" \");\n if (progressLabel) return progressLabel.slice(0, 48);\n return BROWSER_TOOL_NAMES.has(operation.name)\n ? \"正在浏览网页\"\n : \"正在处理你的请求\";\n}\n\nfunction operationEffect(operation: AgentOperation): \"read\" | \"action\" | \"navigate\" | \"processing\" {\n return operation.effect ?? \"action\";\n}\n\nfunction normalizedLabel(label: string | undefined): string | undefined {\n const normalized = label?.trim().replace(/\\s+/g, \" \");\n return normalized || undefined;\n}\n\nfunction operationTargetLabel(\n operation: AgentOperation,\n target: AgentOperationTarget | undefined,\n): string | undefined {\n const label = target?.label;\n if (!label || label === operation.name) return undefined;\n const rawNamePrefix = `${operation.name} · `;\n return label.startsWith(rawNamePrefix) ? label.slice(rawNamePrefix.length) : label;\n}\n\nfunction pointerMoveDuration(from: PointerPosition, to: PointerPosition): number {\n const distance = Math.hypot(to.left - from.left, to.top - from.top);\n if (distance < 2) return 0;\n return Math.round(Math.min(360, Math.max(180, 180 + distance * 0.18)));\n}\n\nfunction pointerReachedTarget(element: HTMLElement, target: PointerPosition): boolean {\n const rect = element.getBoundingClientRect();\n return Math.hypot(rect.left - target.left, rect.top - target.top) < 2;\n}\n\ninterface AgentPointerProps {\n active: boolean;\n initialPosition: PointerPosition | undefined;\n label: string;\n labelActive: boolean;\n operation: AgentOperation;\n targetElement: HTMLElement | undefined;\n targetPosition: PointerPosition | undefined;\n visible: boolean;\n onPointerReady?(toolCallId: string): void;\n}\n\nfunction AgentPointer({ active, initialPosition, label, labelActive, operation, targetElement, targetPosition, visible, onPointerReady }: AgentPointerProps) {\n const pointerRef = useRef<HTMLDivElement>(null);\n const activeOperationRef = useRef<string | undefined>(undefined);\n const activeTargetRef = useRef<HTMLElement | undefined>(undefined);\n const exitTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const movementTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const motionRevisionRef = useRef(0);\n const latestActiveRef = useRef(active);\n const latestOperationRef = useRef(operation);\n const [motion, setMotion] = useState<PointerMotion>();\n latestActiveRef.current = active;\n latestOperationRef.current = operation;\n\n const clearExitTimer = () => {\n if (!exitTimerRef.current) return;\n clearTimeout(exitTimerRef.current);\n exitTimerRef.current = undefined;\n };\n const clearMovementTimer = () => {\n if (!movementTimerRef.current) return;\n clearTimeout(movementTimerRef.current);\n movementTimerRef.current = undefined;\n };\n const finishMovement = (revision: number, toolCallId: string) => {\n const latestOperation = latestOperationRef.current;\n if (!latestActiveRef.current\n || motionRevisionRef.current !== revision\n || latestOperation.toolCallId !== toolCallId) return;\n clearMovementTimer();\n const settle = () => setMotion((current) => current?.revision === revision ? { ...current, phase: \"resting\" } : current);\n if (latestOperation.name !== \"nxf_applyAction\" || !onPointerReady) {\n settle();\n return;\n }\n queueMicrotask(() => {\n if (!latestActiveRef.current || motionRevisionRef.current !== revision || latestOperationRef.current.toolCallId !== toolCallId) return;\n flushSync(settle);\n requestAnimationFrame(() => requestAnimationFrame(() => {\n if (latestActiveRef.current && motionRevisionRef.current === revision\n && latestOperationRef.current.toolCallId === toolCallId && activeTargetRef.current?.isConnected) onPointerReady(toolCallId);\n }));\n });\n };\n\n useEffect(() => () => {\n clearExitTimer();\n clearMovementTimer();\n }, []);\n\n useEffect(() => {\n if (!visible || !initialPosition) {\n if (!motion || motion.phase === \"hidden\") return;\n activeOperationRef.current = undefined;\n activeTargetRef.current = undefined;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n setMotion((current) => current\n ? { ...current, durationMs: POINTER_EXIT_DURATION_MS, phase: \"hidden\", revision }\n : current);\n clearExitTimer();\n exitTimerRef.current = setTimeout(() => {\n if (motionRevisionRef.current === revision) setMotion(undefined);\n }, POINTER_EXIT_DURATION_MS);\n return;\n }\n\n clearExitTimer();\n if (!motion) {\n activeOperationRef.current = operation.toolCallId;\n activeTargetRef.current = undefined;\n const revision = ++motionRevisionRef.current;\n setMotion({\n durationMs: 0,\n phase: \"resting\",\n position: initialPosition,\n revision,\n toolCallId: operation.toolCallId,\n });\n return;\n }\n\n if (!active) {\n activeOperationRef.current = undefined;\n activeTargetRef.current = undefined;\n clearMovementTimer();\n if (motion.phase !== \"resting\") {\n const revision = ++motionRevisionRef.current;\n setMotion((current) => current\n ? { ...current, phase: \"resting\", revision }\n : current);\n }\n return;\n }\n\n const operationChanged = activeOperationRef.current !== operation.toolCallId;\n if (operationChanged) {\n activeOperationRef.current = operation.toolCallId;\n activeTargetRef.current = undefined;\n clearMovementTimer();\n } else if (motion.phase === \"hidden\") {\n setMotion((current) => current\n ? { ...current, durationMs: 0, phase: \"resting\" }\n : current);\n }\n\n if (!targetElement || !targetPosition) {\n const positionChanged = CENTER_BROWSER_TOOL_NAMES.has(operation.name)\n && (motion.position.left !== initialPosition.left || motion.position.top !== initialPosition.top);\n if (operationChanged || activeTargetRef.current || positionChanged) {\n activeTargetRef.current = undefined;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n const pointerRect = pointerRef.current?.getBoundingClientRect();\n setMotion((current) => current\n ? {\n ...current,\n durationMs: 0,\n phase: \"resting\",\n position: operationChanged || positionChanged ? initialPosition : pointerRect\n ? { left: pointerRect.left, top: pointerRect.top }\n : current.position,\n revision,\n toolCallId: operation.toolCallId,\n }\n : current);\n }\n return;\n }\n const targetChanged = operationChanged || activeTargetRef.current !== targetElement;\n if (!targetChanged) {\n if (motion.position.left === targetPosition.left && motion.position.top === targetPosition.top) return;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n const durationMs = window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ? 0 : 180;\n setMotion((current) => current\n ? { ...current, durationMs, phase: \"moving\", position: targetPosition, revision }\n : current);\n if (durationMs === 0) finishMovement(revision, operation.toolCallId);\n else movementTimerRef.current = setTimeout(() => finishMovement(revision, operation.toolCallId), durationMs + 50);\n return;\n }\n\n activeTargetRef.current = targetElement;\n clearMovementTimer();\n const revision = ++motionRevisionRef.current;\n const pointerRect = pointerRef.current?.getBoundingClientRect();\n const currentPosition = pointerRect\n ? { left: pointerRect.left, top: pointerRect.top }\n : motion.position;\n const prefersReducedMotion = window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false;\n const durationMs = prefersReducedMotion ? 0 : pointerMoveDuration(currentPosition, targetPosition);\n setMotion((current) => current\n ? {\n ...current,\n durationMs,\n phase: \"moving\",\n position: targetPosition,\n revision,\n toolCallId: operation.toolCallId,\n }\n : current);\n if (durationMs === 0) finishMovement(revision, operation.toolCallId);\n else {\n // A first-frame position update may not dispatch transitionend.\n movementTimerRef.current = setTimeout(() => finishMovement(revision, operation.toolCallId), durationMs + 50);\n }\n }, [\n active,\n initialPosition?.left,\n initialPosition?.top,\n motion,\n operation.toolCallId,\n targetElement,\n targetPosition?.left,\n targetPosition?.top,\n visible,\n ]);\n\n if (!motion) return null;\n const effect = operationEffect(operation);\n const activeEffect = active ? effect : undefined;\n const browserTool = CENTER_BROWSER_TOOL_NAMES.has(operation.name);\n return (\n <div\n aria-hidden\n className=\"agent-operation__pointer-effect\"\n data-active={active ? \"true\" : \"false\"}\n data-operation-effect={activeEffect}\n data-phase={motion.phase}\n onTransitionEnd={(event) => {\n if (event.currentTarget !== event.target\n || event.propertyName !== \"transform\"\n || motion.phase !== \"moving\"\n || !pointerReachedTarget(event.currentTarget, motion.position)) return;\n finishMovement(motion.revision, motion.toolCallId);\n }}\n ref={pointerRef}\n style={{\n \"--agent-operation-pointer-duration\": `${motion.durationMs}ms`,\n \"--agent-operation-pointer-x\": `${motion.position.left}px`,\n \"--agent-operation-pointer-y\": `${motion.position.top}px`,\n } as CSSProperties}\n >\n {active && visible && motion.toolCallId === operation.toolCallId && browserTool && effect === \"action\" && motion.phase !== \"hidden\" ? (\n <>\n <span className=\"agent-operation__browser-halo\" />\n {labelActive ? <span className=\"agent-operation__browser-label\" title={label}>{label}</span> : null}\n </>\n ) : null}\n {active && visible && motion.toolCallId === operation.toolCallId && !browserTool && effect === \"action\" && motion.phase !== \"hidden\" ? (\n <>\n <span className=\"agent-operation__pointer-cursor\">\n <Cursor className=\"agent-operation__pointer\" size={24} weight=\"fill\" />\n </span>\n </>\n ) : null}\n {active && (!browserTool || (effect === \"read\" && visible && motion.toolCallId === operation.toolCallId))\n && motion.phase !== \"hidden\" && (labelActive || effect !== \"action\") ? (\n <span className={labelActive ? \"agent-operation__pointer-label\" : \"agent-operation__pointer-indicator\"} data-browser-tool={browserTool ? \"true\" : undefined} data-operation-effect={activeEffect} title={labelActive ? label : undefined}>\n {activeEffect === \"processing\" ? <span className=\"agent-operation__pointer-processing\" /> : null}\n {activeEffect === \"read\" ? (\n <span className=\"agent-operation__pointer-read-scan\">\n <i />\n <i />\n <i />\n <i />\n <i />\n </span>\n ) : null}\n {activeEffect === \"navigate\" ? <span className=\"agent-operation__pointer-navigation-trail\" /> : null}\n {labelActive ? <span className=\"agent-operation__pointer-label-text\">{label}</span> : null}\n </span>\n ) : null}\n </div>\n );\n}\n\nexport interface OperationOverlayViewProps {\n fallbackPosition?: PointerPosition;\n feedbackActive?: boolean;\n labelActive?: boolean;\n operation?: AgentOperation;\n progressHistory?: readonly AgentOperationProgressEntry[];\n running: boolean;\n humanHasControl?: boolean;\n cancelling?: boolean;\n onCancel?(): void;\n resolveSurface?(): HTMLElement | undefined;\n resolveTarget?(operation: AgentOperation): AgentOperationTarget | undefined;\n onPointerReady?(toolCallId: string): void;\n}\n\nexport function OperationOverlayView({ operation, progressHistory = [], running, feedbackActive = running, labelActive = feedbackActive, humanHasControl = false, cancelling = false, onCancel, resolveSurface, resolveTarget, fallbackPosition, onPointerReady }: OperationOverlayViewProps) {\n const [, setGeometry] = useState(\"\");\n useLayoutEffect(() => {\n const rect = resolveSurface?.()?.getBoundingClientRect();\n if (rect) setGeometry([rect.left, rect.top, rect.width, rect.height].join(\",\"));\n }, [resolveSurface]);\n const [historyOpen, setHistoryOpen] = useState(false);\n const [historyId] = useState(() => `nexface-operation-history-${globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`}`);\n const clearTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const cancelButtonRef = useRef<HTMLButtonElement>(null);\n const controllerTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [visibleOperation, setVisibleOperation] = useState(operation);\n const [controllerMounted, setControllerMounted] = useState(Boolean(operation\n && operation.status !== \"cancelled\"\n && (running || humanHasControl || operation.status === \"failed\")));\n const [controllerExiting, setControllerExiting] = useState(false);\n useLayoutEffect(() => {\n if (clearTimerRef.current) clearTimeout(clearTimerRef.current);\n if (operation) setVisibleOperation(operation);\n if (operation?.status === \"cancelled\") {\n clearTimerRef.current = setTimeout(() => setVisibleOperation(undefined), 600);\n }\n return () => { if (clearTimerRef.current) clearTimeout(clearTimerRef.current); };\n }, [operation, running]);\n useEffect(() => {\n if ((!running && !feedbackActive && !humanHasControl) || !visibleOperation || visibleOperation.status === \"cancelled\") return;\n let frame = requestAnimationFrame(function update() {\n const surface = resolveSurface?.();\n const target = resolveTarget?.(visibleOperation)?.element;\n const geometry = [surface, target].map((element) => {\n if (!element?.isConnected) return \"\";\n const rect = element.getBoundingClientRect();\n return [rect.left, rect.top, rect.width, rect.height].join(\",\");\n }).join(\";\");\n setGeometry(geometry);\n frame = requestAnimationFrame(update);\n });\n return () => cancelAnimationFrame(frame);\n }, [visibleOperation?.toolCallId, visibleOperation?.status, running, feedbackActive, humanHasControl, resolveSurface, resolveTarget]);\n useEffect(() => {\n if (progressHistory.length === 0) setHistoryOpen(false);\n }, [progressHistory.length]);\n const controllerShouldBeVisible = Boolean(visibleOperation\n && visibleOperation.status !== \"cancelled\"\n && (running || humanHasControl || visibleOperation.status === \"failed\"));\n useEffect(() => {\n if (controllerTimerRef.current) clearTimeout(controllerTimerRef.current);\n if (controllerShouldBeVisible) {\n setControllerMounted(true);\n setControllerExiting(false);\n return;\n }\n if (!controllerMounted) {\n setControllerExiting(false);\n return;\n }\n setHistoryOpen(false);\n setControllerExiting(true);\n controllerTimerRef.current = setTimeout(() => {\n setControllerMounted(false);\n setControllerExiting(false);\n }, CONTROLLER_EXIT_DURATION_MS);\n return () => {\n if (controllerTimerRef.current) clearTimeout(controllerTimerRef.current);\n };\n }, [controllerMounted, controllerShouldBeVisible]);\n useLayoutEffect(() => {\n const surface = resolveSurface?.();\n if (!surface || !running || humanHasControl) return;\n return lockOperationSurface(surface, () => cancelButtonRef.current?.focus());\n }, [humanHasControl, resolveSurface, running]);\n if (!visibleOperation || typeof document === \"undefined\") return null;\n const resolvedTarget = resolveTarget?.(visibleOperation);\n const surfaceElement = resolveSurface?.();\n const target = resolvedTarget && (!surfaceElement || surfaceElement.contains(resolvedTarget.element))\n ? resolvedTarget\n : undefined;\n const structuredTargetLost = visibleOperation.name === \"nxf_applyAction\" && !target;\n const progressLabel = operationProgressLabel(visibleOperation);\n const effect = operationEffect(visibleOperation);\n const targetLabel = operationTargetLabel(visibleOperation, target);\n const pointerLabel = normalizedLabel(visibleOperation.progressLabel) ?? targetLabel ?? progressLabel;\n const controllerLabel = humanHasControl ? undefined : progressLabel;\n const statusLabel = humanHasControl ? \"等待你完成操作\" : {\n running: \"Agent 正在控制\",\n completed: running ? \"工具已完成,任务继续中\" : \"操作已完成\",\n failed: running ? \"Agent 正在处理错误\" : \"操作失败\",\n cancelled: \"任务已终止\",\n }[visibleOperation.status];\n const compactStatusLabel = humanHasControl\n ? \"等待你完成操作\"\n : progressLabel;\n const rect = target?.element.isConnected ? target.element.getBoundingClientRect() : undefined;\n const highlightedRect = effect === \"navigate\" ? undefined : rect;\n const surfaceRect = surfaceElement?.isConnected ? surfaceElement.getBoundingClientRect() : undefined;\n const agentControlsSurface = running && !humanHasControl;\n const operationFeedbackActive = feedbackActive && !structuredTargetLost && !humanHasControl && visibleOperation.status !== \"cancelled\";\n const pointerVisible = Boolean(surfaceRect) && operationFeedbackActive;\n const pointerPosition = rect ? {\n left: rect.left + rect.width / 2,\n top: rect.top + rect.height / 2,\n } : undefined;\n const cancel = onCancel ? () => {\n onCancel();\n } : undefined;\n return createPortal(\n <div className=\"agent-operation\" data-nexface-ignore data-feedback-active={operationFeedbackActive} data-structured-target-lost={structuredTargetLost} data-human-control={humanHasControl} data-operation-effect={effect} data-run-active={running} data-status={visibleOperation.status}>\n {agentControlsSurface && surfaceRect ? <div aria-hidden className=\"agent-operation__surface\" style={{\n ...(highlightedRect ? {\n \"--agent-operation-cutout-height\": `${highlightedRect.height}px`,\n \"--agent-operation-cutout-left\": `${highlightedRect.left - surfaceRect.left}px`,\n \"--agent-operation-cutout-top\": `${highlightedRect.top - surfaceRect.top}px`,\n \"--agent-operation-cutout-width\": `${highlightedRect.width}px`,\n } : {}),\n height: surfaceRect.height, left: surfaceRect.left, top: surfaceRect.top, width: surfaceRect.width,\n } as CSSProperties} /> : null}\n {operationFeedbackActive && highlightedRect ? <div aria-hidden className=\"agent-operation__target\" data-operation-effect={effect} style={{ height: highlightedRect.height, left: highlightedRect.left, top: highlightedRect.top, width: highlightedRect.width }} /> : null}\n <AgentPointer\n active={operationFeedbackActive}\n initialPosition={visibleOperation.name === \"nxf_applyAction\" && surfaceRect\n ? { left: surfaceRect.left + surfaceRect.width / 2, top: surfaceRect.top + surfaceRect.height / 2 }\n : pointerPosition ?? fallbackPosition ?? (surfaceRect ? { left: surfaceRect.left + surfaceRect.width / 2, top: surfaceRect.top + surfaceRect.height / 2 } : undefined)}\n label={pointerLabel}\n labelActive={labelActive}\n operation={visibleOperation}\n targetElement={target?.element}\n targetPosition={pointerPosition}\n visible={pointerVisible}\n {...(onPointerReady ? { onPointerReady } : {})}\n />\n {controllerMounted ? <section aria-live=\"polite\" className=\"agent-operation__controller\" data-visibility={controllerExiting ? \"exiting\" : \"visible\"} style={surfaceRect ? { left: surfaceRect.left + surfaceRect.width / 2, right: \"auto\", \"--agent-operation-controller-x\": \"-50%\", maxWidth: Math.max(0, surfaceRect.width - 32) } as CSSProperties : undefined}>\n {historyOpen ? <aside aria-label=\"本次运行的操作记录\" className=\"agent-operation__history\" id={historyId}>\n <header><strong>操作记录</strong><span>{progressHistory.length}</span></header>\n <ol>{progressHistory.map(({ progressLabel: label, toolCallId }, index) => <li key={toolCallId}>\n <span aria-hidden>{index + 1}</span><p>{label}</p>\n </li>)}</ol>\n </aside> : null}\n <span aria-hidden className=\"agent-operation__edge-flow\" /><span aria-hidden className=\"agent-operation__pause-mark\"><i /><i /></span><button\n aria-controls={historyId}\n aria-expanded={historyOpen}\n aria-label=\"查看本次运行的操作记录\"\n className=\"agent-operation__activity\"\n data-open={historyOpen ? \"true\" : \"false\"}\n disabled={progressHistory.length === 0}\n onClick={() => setHistoryOpen((current) => !current)}\n title={progressHistory.length === 0 ? \"暂无操作记录\" : \"查看本次运行的操作记录\"}\n type=\"button\"\n ><Sparkle className=\"agent-operation__activity-icon\" size={16} weight=\"fill\" /><i /><b>✦</b></button>\n <div><span className=\"agent-operation__heading\"><strong>{controllerLabel}</strong></span>{statusLabel ? <small className=\"agent-operation__description\"><span className=\"agent-operation__status\">{statusLabel}</span></small> : null}</div>\n {(running || humanHasControl) && visibleOperation.status !== \"cancelled\" ? <span className=\"agent-operation__compact-status\" title={compactStatusLabel}>{compactStatusLabel}</span> : null}\n {cancel && (running || humanHasControl) && visibleOperation.status !== \"cancelled\" ? <button ref={cancelButtonRef} className=\"agent-operation__stop\" type=\"button\" disabled={cancelling} onClick={cancel}>{cancelling ? \"正在终止\" : \"终止任务\"}</button> : null}\n </section> : null}\n </div>, document.body,\n );\n}\n"]}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MouseEvent, type ReactElement, type ReactNode, type RefCallback } from "react";
|
|
1
|
+
import { type MouseEvent, type JSX, type JSXElementConstructor, type ReactElement, type ReactNode, type RefCallback } from "react";
|
|
2
2
|
import { type AgentNavigation, type AgentNavigationExecutors } from "./navigation.js";
|
|
3
3
|
import type { ToolRuntime } from "./runtime.js";
|
|
4
4
|
import type { AgentContextEntry, AgentToolDefinition, AgentToolExecutor } from "./types.js";
|
|
@@ -69,7 +69,7 @@ export declare function ToolsProvider({ children, toolRuntime, webMcp, }: {
|
|
|
69
69
|
children: ReactNode;
|
|
70
70
|
toolRuntime: ToolRuntime;
|
|
71
71
|
webMcp?: boolean;
|
|
72
|
-
}):
|
|
72
|
+
}): JSX.Element;
|
|
73
73
|
export declare function useAgentContext(context: AgentContextEntry): void;
|
|
74
74
|
export declare function AgentContext(context: AgentContextEntry): null;
|
|
75
75
|
export type AgentUIActionEvent = "click";
|
|
@@ -84,5 +84,5 @@ export interface AgentUIActionProps<TResult = void> {
|
|
|
84
84
|
event?: AgentUIActionEvent;
|
|
85
85
|
children: ReactElement<AgentUIActionChildProps<TResult>>;
|
|
86
86
|
}
|
|
87
|
-
export declare function AgentUIAction<TResult = void>({ name, description, event, children, }: AgentUIActionProps<TResult>): ReactElement<AgentUIActionChildProps<TResult>, string |
|
|
87
|
+
export declare function AgentUIAction<TResult = void>({ name, description, event, children, }: AgentUIActionProps<TResult>): ReactElement<AgentUIActionChildProps<TResult>, string | JSXElementConstructor<any>>;
|
|
88
88
|
export type { AgentContextValue, AgentToolDefinition, AgentToolExecutor, } from "./types.js";
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { Children, Fragment, cloneElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { defineAgentTool } from "./definition.js";
|
|
4
4
|
import { getAgentNavigationEntries, } from "./navigation.js";
|
|
@@ -128,7 +128,9 @@ export function useAgentNavigation(navigation, executors) {
|
|
|
128
128
|
}
|
|
129
129
|
export function ToolsProvider({ children, toolRuntime, webMcp = true, }) {
|
|
130
130
|
const runtime = getInternalToolRuntime(toolRuntime);
|
|
131
|
-
return (
|
|
131
|
+
return (React.createElement(InternalToolRuntimeScope, { runtime: toolRuntime },
|
|
132
|
+
React.createElement(WebMcpRuntimeBridge, { enabled: webMcp, runtime: runtime }),
|
|
133
|
+
children));
|
|
132
134
|
}
|
|
133
135
|
function WebMcpRuntimeBridge({ enabled, runtime, }) {
|
|
134
136
|
useEffect(() => {
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAMT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,yBAAyB,GAI1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAuEzD,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,MAAM,UAAU,4BAA4B,CAC1C,OAAyB;IAEzB,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,OA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;QACH,CAAC,EACD,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAC9B,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,KAAK,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAElF,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IAC7B,OAAO,YAAY,CAAC,KAAK,EAAE;QACzB,OAAO,EAAE,aAAa;QACtB,GAAG,EAAE,SAAS;KACiD,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import {\n Children,\n Fragment,\n cloneElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type MouseEvent,\n type Ref,\n type ReactElement,\n type ReactNode,\n type RefCallback,\n} from \"react\";\n\nimport { defineAgentTool } from \"./definition.js\";\nimport {\n getAgentNavigationEntries,\n type AgentNavigation,\n type AgentNavigationExecutors,\n type AgentNavigationResult,\n} from \"./navigation.js\";\nimport { AgentToolError, getInternalToolRuntime } from \"./runtime.js\";\nimport {\n InternalToolRuntimeScope,\n useInternalToolRuntime,\n} from \"./internal-react.js\";\nimport type { ToolRuntime } from \"./runtime.js\";\nimport type {\n AgentContextEntry,\n AgentContextRegistration,\n AgentToolDefinition,\n AgentToolExecutor,\n} from \"./types.js\";\nimport type { AgentToolConfirmationConfig } from \"./runtime.js\";\nimport { connectToolRuntimeToWebMcp } from \"./webmcp.js\";\n\n/**\n * @experimental Human-in-the-loop Chat confirmation configuration.\n * @beta\n */\nexport interface AgentToolChatConfirmationConfig {\n mode: \"chat\";\n title?: string;\n description?: string;\n confirmLabel?: string;\n rejectLabel?: string;\n}\n\n/**\n * @experimental Human-in-the-loop Page confirmation configuration.\n * @beta\n */\nexport interface AgentToolPageConfirmationConfig {\n mode: \"page\";\n title?: string;\n description?: string;\n}\n\nexport interface UseAgentToolDefaultOptions {\n /**\n * @experimental Enables human-in-the-loop Chat confirmation.\n * @beta\n */\n requiresConfirmation?: AgentToolChatConfirmationConfig;\n}\n\n/**\n * @experimental Enables human-in-the-loop Page confirmation.\n * @beta\n */\nexport interface UseAgentToolPageConfirmationOptions {\n requiresConfirmation: AgentToolPageConfirmationConfig;\n}\n\nexport interface AgentToolBinding<\n TInput = unknown,\n TElement extends HTMLElement = HTMLElement,\n> {\n readonly toolName: string;\n readonly ref: RefCallback<TElement>;\n refWhen(match: (input: TInput) => boolean): RefCallback<TElement>;\n}\n\ndeclare const pageConfirmableAgentToolBindingBrand: unique symbol;\n\n/**\n * @experimental Binding for human-in-the-loop Page confirmation.\n * @beta\n */\nexport interface PageConfirmableAgentToolBinding<\n TInput = unknown,\n TElement extends HTMLElement = HTMLElement,\n> extends AgentToolBinding<TInput, TElement> {\n readonly [pageConfirmableAgentToolBindingBrand]: true;\n}\n\ntype BindingInternals = {\n resolveTarget(input: unknown): HTMLElement | undefined;\n pageConfirmable: boolean;\n getConditionalTargetRegistrations(): readonly {\n element: HTMLElement;\n match(input: unknown): boolean;\n }[];\n};\n\nconst bindingInternals = new WeakMap<object, BindingInternals>();\n\nexport function getAgentToolBindingInternals(\n binding: AgentToolBinding,\n): BindingInternals {\n const internals = bindingInternals.get(binding);\n if (!internals) throw new Error(\"Invalid Agent Tool Binding.\");\n return internals;\n}\n\nfunction createAgentToolBinding<TInput, TElement extends HTMLElement>(\n toolName: string,\n pageConfirmable: boolean,\n): AgentToolBinding<TInput, TElement> {\n let fixedElement: TElement | null = null;\n const conditionalElements = new Map<\n RefCallback<TElement>,\n { element: TElement; match: (input: TInput) => boolean }\n >();\n const ref: RefCallback<TElement> = (element) => {\n if (element && fixedElement && fixedElement !== element) {\n throw new Error(\"An Agent Tool Binding ref can only attach to one element.\");\n }\n fixedElement = element;\n };\n const binding: AgentToolBinding<TInput, TElement> = {\n toolName,\n ref,\n refWhen(match) {\n let callback: RefCallback<TElement>;\n callback = (element) => {\n if (element) {\n conditionalElements.set(callback, { element, match });\n } else {\n conditionalElements.delete(callback);\n }\n };\n return callback;\n },\n };\n bindingInternals.set(binding, {\n resolveTarget(input) {\n for (const entry of conditionalElements.values()) {\n if (entry.element.isConnected && entry.match(input as TInput)) return entry.element;\n }\n return fixedElement?.isConnected ? fixedElement : undefined;\n },\n pageConfirmable,\n getConditionalTargetRegistrations: () =>\n Array.from(conditionalElements.values(), ({ element, match }) => ({\n element,\n match: (input: unknown) => match(input as TInput),\n })),\n });\n return binding;\n}\n\nfunction useAgentBinding<\n TInput,\n TResult,\n TElement extends HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options: UseAgentToolDefaultOptions | UseAgentToolPageConfirmationOptions,\n): AgentToolBinding<TInput, TElement> {\n const runtime = useInternalToolRuntime();\n const confirmation = options.requiresConfirmation;\n if (\n confirmation !== undefined\n && (\n !confirmation\n || typeof confirmation !== \"object\"\n || (confirmation.mode !== \"chat\" && confirmation.mode !== \"page\")\n )\n ) {\n throw new Error(\n \"requiresConfirmation must explicitly use chat or page mode.\",\n );\n }\n const executeRef = useRef(execute);\n executeRef.current = execute;\n const confirmationRef = useRef<AgentToolConfirmationConfig | undefined>(\n confirmation,\n );\n confirmationRef.current = confirmation;\n const mode = confirmation?.mode;\n const binding = useMemo(\n () => createAgentToolBinding<TInput, TElement>(\n definition.name,\n mode === \"page\",\n ),\n [runtime, definition, mode],\n );\n useLayoutEffect(() => {\n const controller = new AbortController();\n runtime.register(\n definition,\n (input, context) => executeRef.current(input, context),\n {\n signal: controller.signal,\n getConfirmation: () => confirmationRef.current,\n resolveTarget: (input) => getAgentToolBindingInternals(binding).resolveTarget(input),\n },\n );\n return () => controller.abort();\n }, [runtime, definition, mode]);\n return binding;\n}\n\n/**\n * @experimental The Page confirmation overload is experimental.\n * @beta\n */\nexport function useAgentTool<\n TInput,\n TResult,\n TElement extends HTMLElement = HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options: UseAgentToolPageConfirmationOptions,\n): PageConfirmableAgentToolBinding<TInput, TElement>;\nexport function useAgentTool<\n TInput,\n TResult,\n TElement extends HTMLElement = HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options?: UseAgentToolDefaultOptions,\n): AgentToolBinding<TInput, TElement>;\nexport function useAgentTool<\n TInput,\n TResult,\n TElement extends HTMLElement = HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options: UseAgentToolDefaultOptions | UseAgentToolPageConfirmationOptions = {},\n): AgentToolBinding<TInput, TElement> {\n return useAgentBinding(definition, execute, options);\n}\n\nfunction getAgentNavigationExecutor(\n executors: unknown,\n key: string,\n): AgentToolExecutor<any, void> {\n if (\n !executors\n || typeof executors !== \"object\"\n || !Object.hasOwn(executors, key)\n ) {\n throw new Error(`Missing navigation executor: ${key}.`);\n }\n const executor = (executors as Record<string, unknown>)[key];\n if (typeof executor !== \"function\") {\n throw new Error(`Missing navigation executor: ${key}.`);\n }\n return executor as AgentToolExecutor<any, void>;\n}\n\nexport function useAgentNavigation<\n TNavigation extends AgentNavigation,\n const TExecutors extends AgentNavigationExecutors<TNavigation>,\n>(\n navigation: TNavigation,\n executors: TExecutors & Record<\n Exclude<\n keyof TExecutors,\n keyof AgentNavigationExecutors<TNavigation>\n >,\n never\n >,\n): void {\n const runtime = useInternalToolRuntime();\n const entries = getAgentNavigationEntries(navigation);\n for (const entry of entries) {\n getAgentNavigationExecutor(executors, entry.key);\n }\n const routeKeys = new Set(entries.map((entry) => entry.key));\n for (const key of Object.keys(executors)) {\n if (!routeKeys.has(key)) {\n throw new Error(`Unknown navigation executor: ${key}.`);\n }\n }\n const executorsRef = useRef(executors);\n executorsRef.current = executors;\n\n useLayoutEffect(() => {\n const controller = new AbortController();\n try {\n for (const entry of entries) {\n runtime.register(\n entry.definition,\n async (input, context): Promise<AgentNavigationResult> => {\n const executor = getAgentNavigationExecutor(\n executorsRef.current,\n entry.key,\n );\n await executor(input, context);\n return { status: \"navigated\" };\n },\n { signal: controller.signal },\n );\n }\n } catch (error) {\n controller.abort();\n throw error;\n }\n return () => controller.abort();\n }, [runtime, navigation]);\n}\n\nexport function ToolsProvider({\n children,\n toolRuntime,\n webMcp = true,\n}: {\n children: ReactNode;\n toolRuntime: ToolRuntime;\n webMcp?: boolean;\n}) {\n const runtime = getInternalToolRuntime(toolRuntime);\n return (\n <InternalToolRuntimeScope runtime={toolRuntime}>\n <WebMcpRuntimeBridge enabled={webMcp} runtime={runtime} />\n {children}\n </InternalToolRuntimeScope>\n );\n}\n\nfunction WebMcpRuntimeBridge({\n enabled,\n runtime,\n}: {\n enabled: boolean;\n runtime: ReturnType<typeof getInternalToolRuntime>;\n}) {\n useEffect(() => {\n if (!enabled) return undefined;\n return connectToolRuntimeToWebMcp(runtime);\n }, [enabled, runtime]);\n return null;\n}\n\nexport function useAgentContext(context: AgentContextEntry): void {\n const runtime = useInternalToolRuntime();\n const registrationRef = useRef<AgentContextRegistration | undefined>(undefined);\n useLayoutEffect(() => {\n const controller = new AbortController();\n const registration = runtime.registerContext(context, { signal: controller.signal });\n registrationRef.current = registration;\n return () => {\n if (registrationRef.current === registration) registrationRef.current = undefined;\n controller.abort();\n };\n }, [runtime, context.name]);\n useLayoutEffect(() => {\n registrationRef.current?.update(context);\n }, [runtime, context.name, context.description, context.value]);\n}\n\nexport function AgentContext(context: AgentContextEntry): null {\n useAgentContext(context);\n return null;\n}\n\nfunction waitForActionResult<TResult>(\n result: TResult | Promise<TResult>,\n signal: AbortSignal,\n): Promise<TResult> {\n if (signal.aborted) return Promise.reject(signal.reason);\n return new Promise((resolve, reject) => {\n const onAbort = () => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(signal.reason);\n };\n signal.addEventListener(\"abort\", onAbort, { once: true });\n Promise.resolve(result).then(\n (value) => {\n signal.removeEventListener(\"abort\", onAbort);\n resolve(value);\n },\n (error) => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(error);\n },\n );\n });\n}\n\nexport type AgentUIActionEvent = \"click\";\n\ntype Awaitable<TResult> = TResult | Promise<TResult>;\n\nexport interface AgentUIActionChildProps<TResult = void> {\n onClick: (event: MouseEvent<HTMLElement>) => Awaitable<TResult>;\n disabled?: boolean;\n}\n\nexport interface AgentUIActionProps<TResult = void> {\n name: string;\n description: string;\n event?: AgentUIActionEvent;\n children: ReactElement<AgentUIActionChildProps<TResult>>;\n}\n\ntype PendingInvocation<TResult> = {\n resolve: (value: TResult | PromiseLike<TResult>) => void;\n reject: (reason?: unknown) => void;\n};\n\nfunction setRefValue<T>(ref: Ref<T> | undefined, value: T | null): (() => void) | undefined {\n if (typeof ref === \"function\") {\n const cleanup = ref(value);\n return typeof cleanup === \"function\" ? cleanup : undefined;\n }\n if (ref) ref.current = value;\n}\n\nfunction getElementRef(element: ReactElement): Ref<HTMLElement> | undefined {\n const props = element.props as Record<string, unknown>;\n const refDescriptor = Object.getOwnPropertyDescriptor(element, \"ref\");\n if (refDescriptor && \"value\" in refDescriptor) {\n return refDescriptor.value as Ref<HTMLElement> | undefined;\n }\n return (props as { ref?: Ref<HTMLElement> }).ref;\n}\n\nfunction isHTMLElement(value: unknown): value is HTMLElement {\n if (!value || typeof value !== \"object\") return false;\n const ownerDocument = (value as { ownerDocument?: Document }).ownerDocument;\n const ElementConstructor =\n ownerDocument?.defaultView?.HTMLElement ??\n (typeof HTMLElement === \"undefined\" ? undefined : HTMLElement);\n return ElementConstructor !== undefined && value instanceof ElementConstructor;\n}\n\nfunction warnAgentUIAction(message: string): void {\n if (typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\") {\n console.warn(message);\n }\n}\n\nconst eventAdapters: Record<AgentUIActionEvent, { invoke(target: HTMLElement): void }> = {\n click: {\n invoke(target) {\n target.click();\n },\n },\n};\n\nexport function AgentUIAction<TResult = void>({\n name,\n description,\n event = \"click\",\n children,\n}: AgentUIActionProps<TResult>) {\n const runtime = useInternalToolRuntime();\n const child = Children.only(children) as ReactElement<AgentUIActionChildProps<TResult>>;\n const isFragment = child.type === Fragment;\n const handler = isFragment ? undefined : child.props.onClick;\n const childDisabled = isFragment ? false : Boolean(child.props.disabled);\n const childRef = isFragment ? undefined : getElementRef(child);\n const [target, setTarget] = useState<HTMLElement | null>(null);\n const targetRef = useRef<HTMLElement | null>(null);\n const handlerRef = useRef(handler);\n const disabledRef = useRef(childDisabled);\n const pendingInvocationRef = useRef<PendingInvocation<TResult> | null>(null);\n const invalidTargetRef = useRef(false);\n const warnedTargetRef = useRef(false);\n const warnedChildRef = useRef<\"fragment\" | \"handler\" | null>(null);\n const invokingRef = useRef(false);\n\n useLayoutEffect(() => {\n handlerRef.current = handler;\n disabledRef.current = childDisabled;\n });\n\n const mergedRef = useCallback(\n (value: unknown) => {\n const element = isHTMLElement(value) ? value : null;\n const cleanupChildRef = setRefValue(childRef as Ref<unknown> | undefined, value);\n invalidTargetRef.current = value !== null && !element;\n targetRef.current = element;\n setTarget(element);\n if (element) warnedTargetRef.current = false;\n if (cleanupChildRef) {\n return () => {\n cleanupChildRef();\n if (targetRef.current === element) {\n invalidTargetRef.current = false;\n targetRef.current = null;\n setTarget(null);\n }\n };\n }\n },\n [childRef],\n );\n\n const invokeHandler = useCallback((mouseEvent: MouseEvent<HTMLElement>) => {\n const currentHandler = handlerRef.current;\n const pending = pendingInvocationRef.current;\n if (pending) pendingInvocationRef.current = null;\n if (!currentHandler) {\n pending?.reject(\n new AgentToolError(\n \"ACTION_NOT_HANDLED\",\n `AgentUIAction \"${name}\" does not have an onClick handler.`,\n ),\n );\n return undefined as TResult;\n }\n try {\n const result = currentHandler(mouseEvent);\n if (pending) Promise.resolve(result).then(pending.resolve, pending.reject);\n return result;\n } catch (error) {\n if (pending) {\n pending.reject(error);\n return undefined as TResult;\n }\n throw error;\n }\n }, [name]);\n\n const definition = useMemo(\n () =>\n defineAgentTool<TResult>({\n name,\n description,\n }),\n [name, description],\n );\n\n useLayoutEffect(() => {\n if (isFragment || !handler) {\n const warningType = isFragment ? \"fragment\" : \"handler\";\n if (warnedChildRef.current !== warningType) {\n warnedChildRef.current = warningType;\n warnAgentUIAction(\n isFragment\n ? `AgentUIAction \"${name}\" does not support React.Fragment children.`\n : `AgentUIAction \"${name}\" needs a child with onClick.`,\n );\n }\n return;\n }\n warnedChildRef.current = null;\n if (!target) {\n if (!targetRef.current && !warnedTargetRef.current) {\n warnedTargetRef.current = true;\n warnAgentUIAction(\n invalidTargetRef.current\n ? `AgentUIAction \"${name}\" needs its child ref to resolve to an HTMLElement; the Tool is not registered.`\n : `AgentUIAction \"${name}\" needs its child to forward ref to an HTMLElement; the Tool is not registered.`,\n );\n }\n return;\n }\n\n const controller = new AbortController();\n runtime.register(\n definition,\n async (_input, context) => {\n if (invokingRef.current) {\n throw new AgentToolError(\n \"ACTION_IN_FLIGHT\",\n `AgentUIAction \"${name}\" is already being invoked.`,\n );\n }\n if (disabledRef.current) {\n throw new AgentToolError(\n \"TOOL_UNAVAILABLE\",\n `AgentUIAction \"${name}\" is disabled.`,\n );\n }\n const currentTarget = targetRef.current;\n if (!currentTarget || !currentTarget.isConnected) {\n throw new AgentToolError(\n \"ACTION_TARGET_UNAVAILABLE\",\n `AgentUIAction \"${name}\" target is not available.`,\n );\n }\n invokingRef.current = true;\n let resolveInvocation!: (value: TResult | PromiseLike<TResult>) => void;\n let rejectInvocation!: (reason?: unknown) => void;\n const actionPromise = new Promise<TResult>((resolve, reject) => {\n resolveInvocation = resolve;\n rejectInvocation = reject;\n });\n const pendingInvocation = {\n resolve: resolveInvocation,\n reject: rejectInvocation,\n };\n pendingInvocationRef.current = pendingInvocation;\n try {\n eventAdapters[event].invoke(currentTarget);\n } catch (error) {\n if (pendingInvocationRef.current === pendingInvocation) {\n pendingInvocationRef.current = null;\n }\n invokingRef.current = false;\n throw error;\n }\n if (pendingInvocationRef.current === pendingInvocation) {\n pendingInvocationRef.current = null;\n invokingRef.current = false;\n throw new AgentToolError(\n \"ACTION_NOT_HANDLED\",\n `AgentUIAction \"${name}\" click did not invoke its onClick handler.`,\n );\n }\n try {\n return await waitForActionResult(actionPromise, context.signal);\n } finally {\n if (context.signal.aborted) {\n void actionPromise.then(\n () => {\n invokingRef.current = false;\n },\n () => {\n invokingRef.current = false;\n },\n );\n } else {\n invokingRef.current = false;\n }\n }\n },\n { signal: controller.signal },\n );\n return () => controller.abort();\n }, [runtime, definition, event, handler !== undefined, isFragment, name, target]);\n\n if (isFragment) return child;\n return cloneElement(child, {\n onClick: invokeHandler,\n ref: mergedRef,\n } as AgentUIActionChildProps<TResult> & { ref: Ref<HTMLElement> });\n}\n\nexport type {\n AgentContextValue,\n AgentToolDefinition,\n AgentToolExecutor,\n} from \"./types.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAQT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,yBAAyB,GAI1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAuEzD,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,MAAM,UAAU,4BAA4B,CAC1C,OAAyB;IAEzB,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAA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C,EACD,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAC9B,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,KAAK,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAElF,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IAC7B,OAAO,YAAY,CAAC,KAAK,EAAE;QACzB,OAAO,EAAE,aAAa;QACtB,GAAG,EAAE,SAAS;KACiD,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import * as React from \"react\";\nimport {\n Children,\n Fragment,\n cloneElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type MouseEvent,\n type JSX,\n type JSXElementConstructor,\n type Ref,\n type ReactElement,\n type ReactNode,\n type RefCallback,\n} from \"react\";\n\nimport { defineAgentTool } from \"./definition.js\";\nimport {\n getAgentNavigationEntries,\n type AgentNavigation,\n type AgentNavigationExecutors,\n type AgentNavigationResult,\n} from \"./navigation.js\";\nimport { AgentToolError, getInternalToolRuntime } from \"./runtime.js\";\nimport {\n InternalToolRuntimeScope,\n useInternalToolRuntime,\n} from \"./internal-react.js\";\nimport type { ToolRuntime } from \"./runtime.js\";\nimport type {\n AgentContextEntry,\n AgentContextRegistration,\n AgentToolDefinition,\n AgentToolExecutor,\n} from \"./types.js\";\nimport type { AgentToolConfirmationConfig } from \"./runtime.js\";\nimport { connectToolRuntimeToWebMcp } from \"./webmcp.js\";\n\n/**\n * @experimental Human-in-the-loop Chat confirmation configuration.\n * @beta\n */\nexport interface AgentToolChatConfirmationConfig {\n mode: \"chat\";\n title?: string;\n description?: string;\n confirmLabel?: string;\n rejectLabel?: string;\n}\n\n/**\n * @experimental Human-in-the-loop Page confirmation configuration.\n * @beta\n */\nexport interface AgentToolPageConfirmationConfig {\n mode: \"page\";\n title?: string;\n description?: string;\n}\n\nexport interface UseAgentToolDefaultOptions {\n /**\n * @experimental Enables human-in-the-loop Chat confirmation.\n * @beta\n */\n requiresConfirmation?: AgentToolChatConfirmationConfig;\n}\n\n/**\n * @experimental Enables human-in-the-loop Page confirmation.\n * @beta\n */\nexport interface UseAgentToolPageConfirmationOptions {\n requiresConfirmation: AgentToolPageConfirmationConfig;\n}\n\nexport interface AgentToolBinding<\n TInput = unknown,\n TElement extends HTMLElement = HTMLElement,\n> {\n readonly toolName: string;\n readonly ref: RefCallback<TElement>;\n refWhen(match: (input: TInput) => boolean): RefCallback<TElement>;\n}\n\ndeclare const pageConfirmableAgentToolBindingBrand: unique symbol;\n\n/**\n * @experimental Binding for human-in-the-loop Page confirmation.\n * @beta\n */\nexport interface PageConfirmableAgentToolBinding<\n TInput = unknown,\n TElement extends HTMLElement = HTMLElement,\n> extends AgentToolBinding<TInput, TElement> {\n readonly [pageConfirmableAgentToolBindingBrand]: true;\n}\n\ntype BindingInternals = {\n resolveTarget(input: unknown): HTMLElement | undefined;\n pageConfirmable: boolean;\n getConditionalTargetRegistrations(): readonly {\n element: HTMLElement;\n match(input: unknown): boolean;\n }[];\n};\n\nconst bindingInternals = new WeakMap<object, BindingInternals>();\n\nexport function getAgentToolBindingInternals(\n binding: AgentToolBinding,\n): BindingInternals {\n const internals = bindingInternals.get(binding);\n if (!internals) throw new Error(\"Invalid Agent Tool Binding.\");\n return internals;\n}\n\nfunction createAgentToolBinding<TInput, TElement extends HTMLElement>(\n toolName: string,\n pageConfirmable: boolean,\n): AgentToolBinding<TInput, TElement> {\n let fixedElement: TElement | null = null;\n const conditionalElements = new Map<\n RefCallback<TElement>,\n { element: TElement; match: (input: TInput) => boolean }\n >();\n const ref: RefCallback<TElement> = (element) => {\n if (element && fixedElement && fixedElement !== element) {\n throw new Error(\"An Agent Tool Binding ref can only attach to one element.\");\n }\n fixedElement = element;\n };\n const binding: AgentToolBinding<TInput, TElement> = {\n toolName,\n ref,\n refWhen(match) {\n let callback: RefCallback<TElement>;\n callback = (element) => {\n if (element) {\n conditionalElements.set(callback, { element, match });\n } else {\n conditionalElements.delete(callback);\n }\n };\n return callback;\n },\n };\n bindingInternals.set(binding, {\n resolveTarget(input) {\n for (const entry of conditionalElements.values()) {\n if (entry.element.isConnected && entry.match(input as TInput)) return entry.element;\n }\n return fixedElement?.isConnected ? fixedElement : undefined;\n },\n pageConfirmable,\n getConditionalTargetRegistrations: () =>\n Array.from(conditionalElements.values(), ({ element, match }) => ({\n element,\n match: (input: unknown) => match(input as TInput),\n })),\n });\n return binding;\n}\n\nfunction useAgentBinding<\n TInput,\n TResult,\n TElement extends HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options: UseAgentToolDefaultOptions | UseAgentToolPageConfirmationOptions,\n): AgentToolBinding<TInput, TElement> {\n const runtime = useInternalToolRuntime();\n const confirmation = options.requiresConfirmation;\n if (\n confirmation !== undefined\n && (\n !confirmation\n || typeof confirmation !== \"object\"\n || (confirmation.mode !== \"chat\" && confirmation.mode !== \"page\")\n )\n ) {\n throw new Error(\n \"requiresConfirmation must explicitly use chat or page mode.\",\n );\n }\n const executeRef = useRef(execute);\n executeRef.current = execute;\n const confirmationRef = useRef<AgentToolConfirmationConfig | undefined>(\n confirmation,\n );\n confirmationRef.current = confirmation;\n const mode = confirmation?.mode;\n const binding = useMemo(\n () => createAgentToolBinding<TInput, TElement>(\n definition.name,\n mode === \"page\",\n ),\n [runtime, definition, mode],\n );\n useLayoutEffect(() => {\n const controller = new AbortController();\n runtime.register(\n definition,\n (input, context) => executeRef.current(input, context),\n {\n signal: controller.signal,\n getConfirmation: () => confirmationRef.current,\n resolveTarget: (input) => getAgentToolBindingInternals(binding).resolveTarget(input),\n },\n );\n return () => controller.abort();\n }, [runtime, definition, mode]);\n return binding;\n}\n\n/**\n * @experimental The Page confirmation overload is experimental.\n * @beta\n */\nexport function useAgentTool<\n TInput,\n TResult,\n TElement extends HTMLElement = HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options: UseAgentToolPageConfirmationOptions,\n): PageConfirmableAgentToolBinding<TInput, TElement>;\nexport function useAgentTool<\n TInput,\n TResult,\n TElement extends HTMLElement = HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options?: UseAgentToolDefaultOptions,\n): AgentToolBinding<TInput, TElement>;\nexport function useAgentTool<\n TInput,\n TResult,\n TElement extends HTMLElement = HTMLElement,\n>(\n definition: AgentToolDefinition<TInput, TResult>,\n execute: AgentToolExecutor<TInput, TResult>,\n options: UseAgentToolDefaultOptions | UseAgentToolPageConfirmationOptions = {},\n): AgentToolBinding<TInput, TElement> {\n return useAgentBinding(definition, execute, options);\n}\n\nfunction getAgentNavigationExecutor(\n executors: unknown,\n key: string,\n): AgentToolExecutor<any, void> {\n if (\n !executors\n || typeof executors !== \"object\"\n || !Object.hasOwn(executors, key)\n ) {\n throw new Error(`Missing navigation executor: ${key}.`);\n }\n const executor = (executors as Record<string, unknown>)[key];\n if (typeof executor !== \"function\") {\n throw new Error(`Missing navigation executor: ${key}.`);\n }\n return executor as AgentToolExecutor<any, void>;\n}\n\nexport function useAgentNavigation<\n TNavigation extends AgentNavigation,\n const TExecutors extends AgentNavigationExecutors<TNavigation>,\n>(\n navigation: TNavigation,\n executors: TExecutors & Record<\n Exclude<\n keyof TExecutors,\n keyof AgentNavigationExecutors<TNavigation>\n >,\n never\n >,\n): void {\n const runtime = useInternalToolRuntime();\n const entries = getAgentNavigationEntries(navigation);\n for (const entry of entries) {\n getAgentNavigationExecutor(executors, entry.key);\n }\n const routeKeys = new Set(entries.map((entry) => entry.key));\n for (const key of Object.keys(executors)) {\n if (!routeKeys.has(key)) {\n throw new Error(`Unknown navigation executor: ${key}.`);\n }\n }\n const executorsRef = useRef(executors);\n executorsRef.current = executors;\n\n useLayoutEffect(() => {\n const controller = new AbortController();\n try {\n for (const entry of entries) {\n runtime.register(\n entry.definition,\n async (input, context): Promise<AgentNavigationResult> => {\n const executor = getAgentNavigationExecutor(\n executorsRef.current,\n entry.key,\n );\n await executor(input, context);\n return { status: \"navigated\" };\n },\n { signal: controller.signal },\n );\n }\n } catch (error) {\n controller.abort();\n throw error;\n }\n return () => controller.abort();\n }, [runtime, navigation]);\n}\n\nexport function ToolsProvider({\n children,\n toolRuntime,\n webMcp = true,\n}: {\n children: ReactNode;\n toolRuntime: ToolRuntime;\n webMcp?: boolean;\n}): JSX.Element {\n const runtime = getInternalToolRuntime(toolRuntime);\n return (\n <InternalToolRuntimeScope runtime={toolRuntime}>\n <WebMcpRuntimeBridge enabled={webMcp} runtime={runtime} />\n {children}\n </InternalToolRuntimeScope>\n );\n}\n\nfunction WebMcpRuntimeBridge({\n enabled,\n runtime,\n}: {\n enabled: boolean;\n runtime: ReturnType<typeof getInternalToolRuntime>;\n}) {\n useEffect(() => {\n if (!enabled) return undefined;\n return connectToolRuntimeToWebMcp(runtime);\n }, [enabled, runtime]);\n return null;\n}\n\nexport function useAgentContext(context: AgentContextEntry): void {\n const runtime = useInternalToolRuntime();\n const registrationRef = useRef<AgentContextRegistration | undefined>(undefined);\n useLayoutEffect(() => {\n const controller = new AbortController();\n const registration = runtime.registerContext(context, { signal: controller.signal });\n registrationRef.current = registration;\n return () => {\n if (registrationRef.current === registration) registrationRef.current = undefined;\n controller.abort();\n };\n }, [runtime, context.name]);\n useLayoutEffect(() => {\n registrationRef.current?.update(context);\n }, [runtime, context.name, context.description, context.value]);\n}\n\nexport function AgentContext(context: AgentContextEntry): null {\n useAgentContext(context);\n return null;\n}\n\nfunction waitForActionResult<TResult>(\n result: TResult | Promise<TResult>,\n signal: AbortSignal,\n): Promise<TResult> {\n if (signal.aborted) return Promise.reject(signal.reason);\n return new Promise((resolve, reject) => {\n const onAbort = () => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(signal.reason);\n };\n signal.addEventListener(\"abort\", onAbort, { once: true });\n Promise.resolve(result).then(\n (value) => {\n signal.removeEventListener(\"abort\", onAbort);\n resolve(value);\n },\n (error) => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(error);\n },\n );\n });\n}\n\nexport type AgentUIActionEvent = \"click\";\n\ntype Awaitable<TResult> = TResult | Promise<TResult>;\n\nexport interface AgentUIActionChildProps<TResult = void> {\n onClick: (event: MouseEvent<HTMLElement>) => Awaitable<TResult>;\n disabled?: boolean;\n}\n\nexport interface AgentUIActionProps<TResult = void> {\n name: string;\n description: string;\n event?: AgentUIActionEvent;\n children: ReactElement<AgentUIActionChildProps<TResult>>;\n}\n\ntype PendingInvocation<TResult> = {\n resolve: (value: TResult | PromiseLike<TResult>) => void;\n reject: (reason?: unknown) => void;\n};\n\nfunction setRefValue<T>(ref: Ref<T> | undefined, value: T | null): (() => void) | undefined {\n if (typeof ref === \"function\") {\n const cleanup = ref(value);\n return typeof cleanup === \"function\" ? cleanup : undefined;\n }\n if (ref) (ref as { current: T | null }).current = value;\n}\n\nfunction getElementRef(element: ReactElement): Ref<HTMLElement> | undefined {\n const props = element.props as Record<string, unknown>;\n const refDescriptor = Object.getOwnPropertyDescriptor(element, \"ref\");\n if (refDescriptor && \"value\" in refDescriptor) {\n return refDescriptor.value as Ref<HTMLElement> | undefined;\n }\n return (props as { ref?: Ref<HTMLElement> }).ref;\n}\n\nfunction isHTMLElement(value: unknown): value is HTMLElement {\n if (!value || typeof value !== \"object\") return false;\n const ownerDocument = (value as { ownerDocument?: Document }).ownerDocument;\n const ElementConstructor =\n ownerDocument?.defaultView?.HTMLElement ??\n (typeof HTMLElement === \"undefined\" ? undefined : HTMLElement);\n return ElementConstructor !== undefined && value instanceof ElementConstructor;\n}\n\nfunction warnAgentUIAction(message: string): void {\n if (typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\") {\n console.warn(message);\n }\n}\n\nconst eventAdapters: Record<AgentUIActionEvent, { invoke(target: HTMLElement): void }> = {\n click: {\n invoke(target) {\n target.click();\n },\n },\n};\n\nexport function AgentUIAction<TResult = void>({\n name,\n description,\n event = \"click\",\n children,\n}: AgentUIActionProps<TResult>): ReactElement<AgentUIActionChildProps<TResult>, string | JSXElementConstructor<any>> {\n const runtime = useInternalToolRuntime();\n const child = Children.only(children) as ReactElement<AgentUIActionChildProps<TResult>>;\n const isFragment = child.type === Fragment;\n const handler = isFragment ? undefined : child.props.onClick;\n const childDisabled = isFragment ? false : Boolean(child.props.disabled);\n const childRef = isFragment ? undefined : getElementRef(child);\n const [target, setTarget] = useState<HTMLElement | null>(null);\n const targetRef = useRef<HTMLElement | null>(null);\n const handlerRef = useRef(handler);\n const disabledRef = useRef(childDisabled);\n const pendingInvocationRef = useRef<PendingInvocation<TResult> | null>(null);\n const invalidTargetRef = useRef(false);\n const warnedTargetRef = useRef(false);\n const warnedChildRef = useRef<\"fragment\" | \"handler\" | null>(null);\n const invokingRef = useRef(false);\n\n useLayoutEffect(() => {\n handlerRef.current = handler;\n disabledRef.current = childDisabled;\n });\n\n const mergedRef = useCallback(\n (value: unknown) => {\n const element = isHTMLElement(value) ? value : null;\n const cleanupChildRef = setRefValue(childRef as Ref<unknown> | undefined, value);\n invalidTargetRef.current = value !== null && !element;\n targetRef.current = element;\n setTarget(element);\n if (element) warnedTargetRef.current = false;\n if (cleanupChildRef) {\n return () => {\n cleanupChildRef();\n if (targetRef.current === element) {\n invalidTargetRef.current = false;\n targetRef.current = null;\n setTarget(null);\n }\n };\n }\n },\n [childRef],\n );\n\n const invokeHandler = useCallback((mouseEvent: MouseEvent<HTMLElement>) => {\n const currentHandler = handlerRef.current;\n const pending = pendingInvocationRef.current;\n if (pending) pendingInvocationRef.current = null;\n if (!currentHandler) {\n pending?.reject(\n new AgentToolError(\n \"ACTION_NOT_HANDLED\",\n `AgentUIAction \"${name}\" does not have an onClick handler.`,\n ),\n );\n return undefined as TResult;\n }\n try {\n const result = currentHandler(mouseEvent);\n if (pending) Promise.resolve(result).then(pending.resolve, pending.reject);\n return result;\n } catch (error) {\n if (pending) {\n pending.reject(error);\n return undefined as TResult;\n }\n throw error;\n }\n }, [name]);\n\n const definition = useMemo(\n () =>\n defineAgentTool<TResult>({\n name,\n description,\n }),\n [name, description],\n );\n\n useLayoutEffect(() => {\n if (isFragment || !handler) {\n const warningType = isFragment ? \"fragment\" : \"handler\";\n if (warnedChildRef.current !== warningType) {\n warnedChildRef.current = warningType;\n warnAgentUIAction(\n isFragment\n ? `AgentUIAction \"${name}\" does not support React.Fragment children.`\n : `AgentUIAction \"${name}\" needs a child with onClick.`,\n );\n }\n return;\n }\n warnedChildRef.current = null;\n if (!target) {\n if (!targetRef.current && !warnedTargetRef.current) {\n warnedTargetRef.current = true;\n warnAgentUIAction(\n invalidTargetRef.current\n ? `AgentUIAction \"${name}\" needs its child ref to resolve to an HTMLElement; the Tool is not registered.`\n : `AgentUIAction \"${name}\" needs its child to forward ref to an HTMLElement; the Tool is not registered.`,\n );\n }\n return;\n }\n\n const controller = new AbortController();\n runtime.register(\n definition,\n async (_input, context) => {\n if (invokingRef.current) {\n throw new AgentToolError(\n \"ACTION_IN_FLIGHT\",\n `AgentUIAction \"${name}\" is already being invoked.`,\n );\n }\n if (disabledRef.current) {\n throw new AgentToolError(\n \"TOOL_UNAVAILABLE\",\n `AgentUIAction \"${name}\" is disabled.`,\n );\n }\n const currentTarget = targetRef.current;\n if (!currentTarget || !currentTarget.isConnected) {\n throw new AgentToolError(\n \"ACTION_TARGET_UNAVAILABLE\",\n `AgentUIAction \"${name}\" target is not available.`,\n );\n }\n invokingRef.current = true;\n let resolveInvocation!: (value: TResult | PromiseLike<TResult>) => void;\n let rejectInvocation!: (reason?: unknown) => void;\n const actionPromise = new Promise<TResult>((resolve, reject) => {\n resolveInvocation = resolve;\n rejectInvocation = reject;\n });\n const pendingInvocation = {\n resolve: resolveInvocation,\n reject: rejectInvocation,\n };\n pendingInvocationRef.current = pendingInvocation;\n try {\n eventAdapters[event].invoke(currentTarget);\n } catch (error) {\n if (pendingInvocationRef.current === pendingInvocation) {\n pendingInvocationRef.current = null;\n }\n invokingRef.current = false;\n throw error;\n }\n if (pendingInvocationRef.current === pendingInvocation) {\n pendingInvocationRef.current = null;\n invokingRef.current = false;\n throw new AgentToolError(\n \"ACTION_NOT_HANDLED\",\n `AgentUIAction \"${name}\" click did not invoke its onClick handler.`,\n );\n }\n try {\n return await waitForActionResult(actionPromise, context.signal);\n } finally {\n if (context.signal.aborted) {\n void actionPromise.then(\n () => {\n invokingRef.current = false;\n },\n () => {\n invokingRef.current = false;\n },\n );\n } else {\n invokingRef.current = false;\n }\n }\n },\n { signal: controller.signal },\n );\n return () => controller.abort();\n }, [runtime, definition, event, handler !== undefined, isFragment, name, target]);\n\n if (isFragment) return child;\n return cloneElement(child, {\n onClick: invokeHandler,\n ref: mergedRef,\n } as AgentUIActionChildProps<TResult> & { ref: Ref<HTMLElement> });\n}\n\nexport type {\n AgentContextValue,\n AgentToolDefinition,\n AgentToolExecutor,\n} from \"./types.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexface/tools",
|
|
3
|
-
"version": "0.1.9-alpha.
|
|
3
|
+
"version": "0.1.9-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@phosphor-icons/react": "^2.1.10"
|
|
21
|
+
"@phosphor-icons/react": "^2.1.10",
|
|
22
|
+
"use-sync-external-store": "1.7.0"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
|
-
"react-dom": ">=
|
|
25
|
-
"react": ">=
|
|
25
|
+
"react-dom": ">=17",
|
|
26
|
+
"react": ">=17"
|
|
26
27
|
},
|
|
27
28
|
"peerDependenciesMeta": {
|
|
28
29
|
"react-dom": {
|