@nexface/tools 0.1.20-alpha.1 → 0.1.21
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/react.d.ts +4 -21
- package/dist/react.js +0 -14
- package/dist/runtime.d.ts +0 -5
- package/dist/runtime.js +0 -17
- package/package.json +1 -1
- package/dist/shared/tool-presentation.d.ts +0 -17
- package/dist/shared/tool-presentation.js +0 -5
package/dist/react.d.ts
CHANGED
|
@@ -22,13 +22,7 @@ export interface AgentToolPageConfirmationConfig {
|
|
|
22
22
|
title?: string;
|
|
23
23
|
description?: string;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
[K in keyof T]: ToolResultData<T[K]>;
|
|
27
|
-
} : T extends (...args: never[]) => unknown ? never : T extends object ? {
|
|
28
|
-
[K in keyof T]: ToolResultData<T[K]>;
|
|
29
|
-
} : never;
|
|
30
|
-
type ToolRenderResult<T> = unknown extends T ? unknown : [T] extends [void] ? null : [T] extends [ToolResultData<T>] ? T : unknown;
|
|
31
|
-
export interface UseAgentToolDefaultOptions<TInput = unknown, TResult = unknown> {
|
|
25
|
+
export interface UseAgentToolDefaultOptions<TInput = unknown> {
|
|
32
26
|
confirm?: (context: {
|
|
33
27
|
input: TInput;
|
|
34
28
|
signal: AbortSignal;
|
|
@@ -37,17 +31,6 @@ export interface UseAgentToolDefaultOptions<TInput = unknown, TResult = unknown>
|
|
|
37
31
|
} | Promise<boolean | {
|
|
38
32
|
message: string;
|
|
39
33
|
}>;
|
|
40
|
-
/**
|
|
41
|
-
* @experimental
|
|
42
|
-
* @warning Experimental API. Its signature and behavior may change.
|
|
43
|
-
* @remarks JSON-compatible results retain their types. Other results are unknown after serialization; void results are null.
|
|
44
|
-
* @beta
|
|
45
|
-
*/
|
|
46
|
-
_render?: (context: {
|
|
47
|
-
input: TInput;
|
|
48
|
-
status: "running" | "success" | "error" | "cancelled";
|
|
49
|
-
result?: ToolRenderResult<TResult>;
|
|
50
|
-
}) => ReactNode;
|
|
51
34
|
/**
|
|
52
35
|
* @experimental Enables human-in-the-loop Chat confirmation.
|
|
53
36
|
* @beta
|
|
@@ -58,7 +41,7 @@ export interface UseAgentToolDefaultOptions<TInput = unknown, TResult = unknown>
|
|
|
58
41
|
* @experimental Enables human-in-the-loop Page confirmation.
|
|
59
42
|
* @beta
|
|
60
43
|
*/
|
|
61
|
-
export interface UseAgentToolPageConfirmationOptions
|
|
44
|
+
export interface UseAgentToolPageConfirmationOptions {
|
|
62
45
|
confirm?: never;
|
|
63
46
|
requiresConfirmation: AgentToolPageConfirmationConfig;
|
|
64
47
|
}
|
|
@@ -79,8 +62,8 @@ export declare function getAgentToolBindingInternals(binding: AgentToolBinding):
|
|
|
79
62
|
* @experimental The Page confirmation overload is experimental.
|
|
80
63
|
* @beta
|
|
81
64
|
*/
|
|
82
|
-
export declare function useAgentTool<TInput, TResult, TElement extends HTMLElement = HTMLElement
|
|
83
|
-
export declare function useAgentTool<TInput, TResult, TElement extends HTMLElement = HTMLElement
|
|
65
|
+
export declare function useAgentTool<TInput, TResult, TElement extends HTMLElement = HTMLElement>(definition: AgentToolDefinition<TInput, TResult>, execute: AgentToolExecutor<TInput, TResult>, options: UseAgentToolPageConfirmationOptions): AgentToolBinding<TInput, TElement>;
|
|
66
|
+
export declare function useAgentTool<TInput, TResult, TElement extends HTMLElement = HTMLElement>(definition: AgentToolDefinition<TInput, TResult>, execute: AgentToolExecutor<TInput, TResult>, options?: UseAgentToolDefaultOptions<TInput>): AgentToolBinding<TInput, TElement>;
|
|
84
67
|
export declare function useAgentNavigation<TNavigation extends AgentNavigation, const TExecutors extends AgentNavigationExecutors<TNavigation>>(navigation: TNavigation, executors: TExecutors & Record<Exclude<keyof TExecutors, keyof AgentNavigationExecutors<TNavigation>>, never>): void;
|
|
85
68
|
export declare function ToolsProvider({ children, toolRuntime, webMcp, }: {
|
|
86
69
|
children: ReactNode;
|
package/dist/react.js
CHANGED
|
@@ -55,19 +55,6 @@ function createAgentToolBinding(toolName) {
|
|
|
55
55
|
function useAgentBinding(definition, execute, options) {
|
|
56
56
|
const runtime = useInternalToolRuntime();
|
|
57
57
|
const confirmation = options.requiresConfirmation;
|
|
58
|
-
const confirmationProtocol = Boolean(options.confirm);
|
|
59
|
-
const presentation = useMemo(() => options._render
|
|
60
|
-
? {
|
|
61
|
-
definition,
|
|
62
|
-
...(confirmationProtocol ? { confirmationProtocol: true } : {}),
|
|
63
|
-
render: options._render,
|
|
64
|
-
}
|
|
65
|
-
: undefined, [definition, options._render, confirmationProtocol]);
|
|
66
|
-
const presentationRef = useRef(presentation);
|
|
67
|
-
useLayoutEffect(() => {
|
|
68
|
-
presentationRef.current = presentation;
|
|
69
|
-
runtime.notifyToolPresentationChange();
|
|
70
|
-
}, [runtime, presentation]);
|
|
71
58
|
if (confirmation !== undefined &&
|
|
72
59
|
(!confirmation ||
|
|
73
60
|
typeof confirmation !== "object" ||
|
|
@@ -95,7 +82,6 @@ function useAgentBinding(definition, execute, options) {
|
|
|
95
82
|
runtime.bindTool(definition, (input, context) => executeRef.current(input, context), {
|
|
96
83
|
signal: controller.signal,
|
|
97
84
|
getConfirmation: () => confirmationRef.current,
|
|
98
|
-
getPresentation: () => presentationRef.current,
|
|
99
85
|
...(mode === "callback"
|
|
100
86
|
? {
|
|
101
87
|
getCallbacks: () => ({
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ConfirmationCallback } from "./confirmation.js";
|
|
2
|
-
import { type ToolPresentation } from "./shared/tool-presentation.js";
|
|
3
2
|
import { type InternalExecutionOptions } from "./shared/runtime-execution.js";
|
|
4
3
|
import type { PageActionFeedback } from "./browser/feedback.js";
|
|
5
4
|
import { type TaskProgress } from "./shared/runtime-controller.js";
|
|
@@ -126,7 +125,6 @@ export declare class AgentContextError extends Error {
|
|
|
126
125
|
constructor(code: AgentContextErrorCode, message: string);
|
|
127
126
|
}
|
|
128
127
|
export interface InternalToolRuntime extends ToolRuntime, EventTarget {
|
|
129
|
-
notifyToolPresentationChange(): void;
|
|
130
128
|
usesConfirmationProtocol(tool: RuntimeAgentTool): boolean;
|
|
131
129
|
beginInternalOperation(options?: {
|
|
132
130
|
signal?: AbortSignal;
|
|
@@ -146,7 +144,6 @@ export interface InternalToolRuntime extends ToolRuntime, EventTarget {
|
|
|
146
144
|
bindTool<TInput, TResult>(definition: AgentToolDefinition<TInput, TResult>, execute: AgentToolExecutor<TInput, TResult>, options?: {
|
|
147
145
|
signal?: AbortSignal;
|
|
148
146
|
getConfirmation?: () => AgentToolConfirmationConfig | undefined;
|
|
149
|
-
getPresentation?: () => ToolPresentation | undefined;
|
|
150
147
|
getCallbacks?: () => {
|
|
151
148
|
execute: AgentToolExecutor<any, any>;
|
|
152
149
|
confirm: ConfirmationCallback<any>;
|
|
@@ -182,7 +179,6 @@ export declare class ToolRuntimeImplementation extends EventTarget implements To
|
|
|
182
179
|
requestOperationCancel(id: string): void;
|
|
183
180
|
setPageActionFeedback(listener: (event: AgentToolExecutionEvent, feedback: PageActionFeedback, signal?: AbortSignal) => void | Promise<void>): () => void;
|
|
184
181
|
constructor(options?: ToolRuntimeOptions);
|
|
185
|
-
notifyToolPresentationChange(): void;
|
|
186
182
|
on(eventName: "toolchange", listener: (event: ToolRuntimeToolChangeEvent) => void): () => void;
|
|
187
183
|
on(eventName: "toolexecution", listener: (event: AgentToolExecutionEvent) => void): () => void;
|
|
188
184
|
register<TInput, TResult>(definition: AgentToolDefinition<TInput, TResult>, options: {
|
|
@@ -193,7 +189,6 @@ export declare class ToolRuntimeImplementation extends EventTarget implements To
|
|
|
193
189
|
bindTool<TInput, TResult>(definition: AgentToolDefinition<TInput, TResult>, execute: AgentToolExecutor<TInput, TResult>, options?: {
|
|
194
190
|
signal?: AbortSignal;
|
|
195
191
|
getConfirmation?: () => AgentToolConfirmationConfig | undefined;
|
|
196
|
-
getPresentation?: () => ToolPresentation | undefined;
|
|
197
192
|
getCallbacks?: () => {
|
|
198
193
|
execute: AgentToolExecutor<any, any>;
|
|
199
194
|
confirm: ConfirmationCallback<any>;
|
package/dist/runtime.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { confirmationDefinition, createConfirmationHandler } from "./confirmation-protocol.js";
|
|
2
2
|
import { searchNavigationTools, searchToolDefinition } from "./tool-search.js";
|
|
3
|
-
import { toolPresentationSymbol, } from "./shared/tool-presentation.js";
|
|
4
3
|
import { pageDecisionSymbol } from "./shared/runtime-execution.js";
|
|
5
4
|
import { PageCommandError } from "./browser/locator.js";
|
|
6
5
|
import { measurePagePhase } from "./browser/diagnostics.js";
|
|
@@ -205,21 +204,6 @@ export class ToolRuntimeImplementation extends EventTarget {
|
|
|
205
204
|
getRegisteredTools: () => this.getRegisteredTools(),
|
|
206
205
|
});
|
|
207
206
|
Object.defineProperty(this, runtimeControllerSymbol, { value: controller });
|
|
208
|
-
const presentations = {
|
|
209
|
-
get: (name) => this.#bindings.get(name)?.getPresentation?.(),
|
|
210
|
-
subscribe: (listener) => {
|
|
211
|
-
this.addEventListener("toolchange", listener);
|
|
212
|
-
this.addEventListener("toolpresentationchange", listener);
|
|
213
|
-
return () => {
|
|
214
|
-
this.removeEventListener("toolchange", listener);
|
|
215
|
-
this.removeEventListener("toolpresentationchange", listener);
|
|
216
|
-
};
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
Object.defineProperty(this, toolPresentationSymbol, { value: Object.freeze(presentations) });
|
|
220
|
-
}
|
|
221
|
-
notifyToolPresentationChange() {
|
|
222
|
-
this.dispatchEvent(new Event("toolpresentationchange"));
|
|
223
207
|
}
|
|
224
208
|
on(eventName, listener) {
|
|
225
209
|
const handleEvent = (event) => {
|
|
@@ -291,7 +275,6 @@ export class ToolRuntimeImplementation extends EventTarget {
|
|
|
291
275
|
lifecycleSignal: lifecycleController.signal,
|
|
292
276
|
});
|
|
293
277
|
const binding = {
|
|
294
|
-
...(options.getPresentation ? { getPresentation: options.getPresentation } : {}),
|
|
295
278
|
...(options.resolveTarget
|
|
296
279
|
? {
|
|
297
280
|
resolveTarget: (input) => options.resolveTarget(confirmationHandler ? confirmationHandler.resolveInput(input) : input),
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ToolRuntime } from "../runtime.js";
|
|
2
|
-
export interface ToolRenderContext<TInput = unknown, TResult = unknown> {
|
|
3
|
-
input: TInput;
|
|
4
|
-
status: "running" | "success" | "error" | "cancelled";
|
|
5
|
-
result?: TResult;
|
|
6
|
-
}
|
|
7
|
-
export interface ToolPresentation {
|
|
8
|
-
definition: ReturnType<ToolRuntime["getTools"]>[number]["definition"];
|
|
9
|
-
confirmationProtocol?: true;
|
|
10
|
-
render(context: ToolRenderContext): unknown;
|
|
11
|
-
}
|
|
12
|
-
export interface ToolPresentationController {
|
|
13
|
-
get(name: string): ToolPresentation | undefined;
|
|
14
|
-
subscribe(listener: () => void): () => void;
|
|
15
|
-
}
|
|
16
|
-
export declare const toolPresentationSymbol: unique symbol;
|
|
17
|
-
export declare function getToolPresentationController(runtime: ToolRuntime): ToolPresentationController | undefined;
|