@nexface/chat 0.1.21-alpha.4 → 0.1.21-alpha.5
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/client.js
CHANGED
|
@@ -696,9 +696,9 @@ class ChatClientImplementation {
|
|
|
696
696
|
const contexts = await this.runtime.getContexts({ signal });
|
|
697
697
|
const runId = id();
|
|
698
698
|
this.#runId = runId;
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
.
|
|
699
|
+
const toolMetadata = new Map(catalog.map(({ definition: { name, effect } }) => [name, effect ? { effect } : {}]));
|
|
700
|
+
for (const name of getToolPresentationController(this.runtime)?.names() ?? [])
|
|
701
|
+
toolMetadata.set(name, { ...toolMetadata.get(name), hasRenderer: true });
|
|
702
702
|
const input = {
|
|
703
703
|
threadId: this.id,
|
|
704
704
|
runId,
|
|
@@ -717,13 +717,7 @@ class ChatClientImplementation {
|
|
|
717
717
|
forwardedProps: {
|
|
718
718
|
nexface: {
|
|
719
719
|
version: 3,
|
|
720
|
-
toolMetadata: Object.fromEntries(
|
|
721
|
-
definition.name,
|
|
722
|
-
{
|
|
723
|
-
...(definition.effect ? { effect: definition.effect } : {}),
|
|
724
|
-
...(renderers.has(definition.name) ? { hasRenderer: true } : {}),
|
|
725
|
-
},
|
|
726
|
-
])),
|
|
720
|
+
toolMetadata: Object.fromEntries(toolMetadata),
|
|
727
721
|
},
|
|
728
722
|
},
|
|
729
723
|
};
|
package/dist/default-chat.js
CHANGED
|
@@ -39269,15 +39269,16 @@ function ToolPresentationUI({ tool: tool2 }) {
|
|
|
39269
39269
|
const presentation = registry?.controller?.get(tool2.name);
|
|
39270
39270
|
const argsText = presentation?.confirmationProtocol ? confirmationArgumentsText(tool2.arguments, tool2.name, tool2, messages) : tool2.arguments;
|
|
39271
39271
|
const { result, isError, toolState, name: name3 } = tool2;
|
|
39272
|
+
const hasRenderer = presentation !== void 0;
|
|
39272
39273
|
const renderedResult = useMemo13(() => {
|
|
39273
|
-
if (result === void 0 || isError || toolState) return;
|
|
39274
|
+
if (!hasRenderer || result === void 0 || isError || toolState) return;
|
|
39274
39275
|
const { value, omitted } = decodeToolResult(result, name3);
|
|
39275
39276
|
if (!omitted) return JSON.stringify(value);
|
|
39276
|
-
}, [result, name3, isError, toolState]);
|
|
39277
|
-
const inputSchema = presentation?.definition
|
|
39277
|
+
}, [hasRenderer, result, name3, isError, toolState]);
|
|
39278
|
+
const inputSchema = presentation?.definition?.inputSchema;
|
|
39278
39279
|
const confirmation = presentation?.confirmationProtocol;
|
|
39279
39280
|
const context = useMemo13(() => {
|
|
39280
|
-
if (
|
|
39281
|
+
if (renderedResult === void 0 || argsText === void 0) return;
|
|
39281
39282
|
const value = JSON.parse(renderedResult);
|
|
39282
39283
|
if (confirmation && value && typeof value === "object" && "status" in value && (value.status === "confirmation_required" && "requestId" in value && "message" in value && "nextAction" in value && Object.keys(value).length === 4 || value.status === "rejected" && "toolExecuted" in value && value.toolExecuted === false && Object.keys(value).every((key) => ["status", "requestId", "toolExecuted"].includes(key))))
|
|
39283
39284
|
return;
|
|
@@ -39285,7 +39286,7 @@ function ToolPresentationUI({ tool: tool2 }) {
|
|
|
39285
39286
|
const wire = JSON.parse(argsText);
|
|
39286
39287
|
if (!wire || typeof wire !== "object" || Array.isArray(wire)) return;
|
|
39287
39288
|
const input = confirmation ? wire.input : wire;
|
|
39288
|
-
if (!validateAgentToolInput(inputSchema, input).length)
|
|
39289
|
+
if (!inputSchema || !validateAgentToolInput(inputSchema, input).length)
|
|
39289
39290
|
return { input, status: "success", result: value };
|
|
39290
39291
|
} catch {
|
|
39291
39292
|
}
|
|
@@ -5,12 +5,13 @@ export interface ToolRenderContext<TInput = unknown, TResult = unknown> {
|
|
|
5
5
|
result?: TResult;
|
|
6
6
|
}
|
|
7
7
|
export interface ToolPresentation {
|
|
8
|
-
definition
|
|
8
|
+
definition?: ReturnType<ToolRuntime["getTools"]>[number]["definition"];
|
|
9
9
|
confirmationProtocol?: true;
|
|
10
10
|
render(context: ToolRenderContext): unknown;
|
|
11
11
|
}
|
|
12
12
|
export interface ToolPresentationController {
|
|
13
13
|
get(name: string): ToolPresentation | undefined;
|
|
14
|
+
names(): readonly string[];
|
|
14
15
|
subscribe(listener: () => void): () => void;
|
|
15
16
|
}
|
|
16
17
|
export declare const toolPresentationSymbol: unique symbol;
|
|
@@ -64,19 +64,20 @@ export function ToolPresentationUI({ tool }) {
|
|
|
64
64
|
? confirmationArgumentsText(tool.arguments, tool.name, tool, messages)
|
|
65
65
|
: tool.arguments;
|
|
66
66
|
const { result, isError, toolState, name } = tool;
|
|
67
|
+
const hasRenderer = presentation !== undefined;
|
|
67
68
|
const renderedResult = useMemo(() => {
|
|
68
|
-
if (result === undefined || isError || toolState)
|
|
69
|
+
if (!hasRenderer || result === undefined || isError || toolState)
|
|
69
70
|
return;
|
|
70
71
|
const { value, omitted } = decodeToolResult(result, name);
|
|
71
72
|
// A completed snapshot can add a toolName envelope to the streamed receipt.
|
|
72
73
|
// Keep the renderer's props stable when the business result has not changed.
|
|
73
74
|
if (!omitted)
|
|
74
75
|
return JSON.stringify(value);
|
|
75
|
-
}, [result, name, isError, toolState]);
|
|
76
|
-
const inputSchema = presentation?.definition
|
|
76
|
+
}, [hasRenderer, result, name, isError, toolState]);
|
|
77
|
+
const inputSchema = presentation?.definition?.inputSchema;
|
|
77
78
|
const confirmation = presentation?.confirmationProtocol;
|
|
78
79
|
const context = useMemo(() => {
|
|
79
|
-
if (
|
|
80
|
+
if (renderedResult === undefined || argsText === undefined)
|
|
80
81
|
return;
|
|
81
82
|
const value = JSON.parse(renderedResult);
|
|
82
83
|
if (confirmation &&
|
|
@@ -98,7 +99,7 @@ export function ToolPresentationUI({ tool }) {
|
|
|
98
99
|
if (!wire || typeof wire !== "object" || Array.isArray(wire))
|
|
99
100
|
return;
|
|
100
101
|
const input = confirmation ? wire.input : wire;
|
|
101
|
-
if (!validateAgentToolInput(inputSchema, input).length)
|
|
102
|
+
if (!inputSchema || !validateAgentToolInput(inputSchema, input).length)
|
|
102
103
|
return { input, status: "success", result: value };
|
|
103
104
|
}
|
|
104
105
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexface/chat",
|
|
3
|
-
"version": "0.1.21-alpha.
|
|
3
|
+
"version": "0.1.21-alpha.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@ag-ui/core": "0.0.59",
|
|
22
|
-
"@nexface/agent": "0.1.21-alpha.
|
|
22
|
+
"@nexface/agent": "0.1.21-alpha.5",
|
|
23
23
|
"class-variance-authority": "0.7.1",
|
|
24
24
|
"clsx": "2.1.1",
|
|
25
25
|
"fast-json-patch": "3.1.1",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"use-sync-external-store": "1.7.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@nexface/tools": "0.1.21-alpha.
|
|
32
|
+
"@nexface/tools": "0.1.21-alpha.5",
|
|
33
33
|
"react": ">=17",
|
|
34
34
|
"react-dom": ">=17"
|
|
35
35
|
},
|