@nexface/chat 0.1.21-alpha.3 → 0.1.21-alpha.4
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/BUNDLED_DEPENDENCIES.json +0 -12
- package/dist/BUNDLED_LICENSES.txt +0 -50
- package/dist/assistant-components.d.ts +2 -1
- package/dist/assistant-components.js +9 -12
- package/dist/assistant-runtime.d.ts +4 -1
- package/dist/assistant-runtime.js +5 -1
- package/dist/client.js +17 -3
- package/dist/default-chat.js +1404 -8030
- package/dist/messages.d.ts +3 -0
- package/dist/protocol-messages.d.ts +3 -2
- package/dist/protocol-messages.js +144 -20
- package/dist/protocol-response.js +2 -2
- package/dist/react.js +1 -1
- package/dist/shared/text-only-reply.d.ts +6 -0
- package/dist/shared/text-only-reply.js +10 -0
- package/dist/shared/tool-result-markdown.d.ts +15 -0
- package/dist/shared/tool-result-markdown.js +55 -0
- package/dist/shared/tool-result-reference.d.ts +2 -0
- package/dist/shared/tool-result-reference.js +5 -0
- package/dist/styles.css +8 -0
- package/dist/tool-presentation.d.ts +5 -5
- package/dist/tool-presentation.js +57 -77
- package/dist/ui/home-demo/action-bar.js +13 -2
- package/dist/ui/markdown-text.d.ts +6 -1
- package/dist/ui/markdown-text.js +39 -2
- package/package.json +4 -3
|
@@ -571,12 +571,6 @@
|
|
|
571
571
|
"license": "MIT",
|
|
572
572
|
"purl": "pkg:npm/mdast-util-find-and-replace@3.0.2"
|
|
573
573
|
},
|
|
574
|
-
{
|
|
575
|
-
"name": "mdast-util-from-markdown",
|
|
576
|
-
"version": "2.0.3",
|
|
577
|
-
"license": "MIT",
|
|
578
|
-
"purl": "pkg:npm/mdast-util-from-markdown@2.0.3"
|
|
579
|
-
},
|
|
580
574
|
{
|
|
581
575
|
"name": "mdast-util-gfm",
|
|
582
576
|
"version": "3.1.0",
|
|
@@ -637,12 +631,6 @@
|
|
|
637
631
|
"license": "MIT",
|
|
638
632
|
"purl": "pkg:npm/mdast-util-to-string@4.0.0"
|
|
639
633
|
},
|
|
640
|
-
{
|
|
641
|
-
"name": "micromark",
|
|
642
|
-
"version": "4.0.2",
|
|
643
|
-
"license": "MIT",
|
|
644
|
-
"purl": "pkg:npm/micromark@4.0.2"
|
|
645
|
-
},
|
|
646
634
|
{
|
|
647
635
|
"name": "micromark-core-commonmark",
|
|
648
636
|
"version": "2.0.3",
|
|
@@ -2398,31 +2398,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
2398
2398
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2399
2399
|
|
|
2400
2400
|
|
|
2401
|
-
mdast-util-from-markdown@2.0.3 (MIT)
|
|
2402
|
-
(The MIT License)
|
|
2403
|
-
|
|
2404
|
-
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
2405
|
-
|
|
2406
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
2407
|
-
a copy of this software and associated documentation files (the
|
|
2408
|
-
'Software'), to deal in the Software without restriction, including
|
|
2409
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
2410
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
2411
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
2412
|
-
the following conditions:
|
|
2413
|
-
|
|
2414
|
-
The above copyright notice and this permission notice shall be
|
|
2415
|
-
included in all copies or substantial portions of the Software.
|
|
2416
|
-
|
|
2417
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
2418
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2419
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
2420
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
2421
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
2422
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
2423
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
2401
|
mdast-util-gfm-autolink-literal@2.0.1 (MIT)
|
|
2427
2402
|
(The MIT License)
|
|
2428
2403
|
|
|
@@ -3299,31 +3274,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
3299
3274
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3300
3275
|
|
|
3301
3276
|
|
|
3302
|
-
micromark@4.0.2 (MIT)
|
|
3303
|
-
(The MIT License)
|
|
3304
|
-
|
|
3305
|
-
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
3306
|
-
|
|
3307
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
3308
|
-
a copy of this software and associated documentation files (the
|
|
3309
|
-
'Software'), to deal in the Software without restriction, including
|
|
3310
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
3311
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
3312
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
3313
|
-
the following conditions:
|
|
3314
|
-
|
|
3315
|
-
The above copyright notice and this permission notice shall be
|
|
3316
|
-
included in all copies or substantial portions of the Software.
|
|
3317
|
-
|
|
3318
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
3319
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
3320
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
3321
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
3322
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
3323
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
3324
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
3277
|
nanoid@6.0.1 (MIT)
|
|
3328
3278
|
The MIT License (MIT)
|
|
3329
3279
|
|
|
@@ -15,7 +15,8 @@ export declare function AssistantComposer({ binding, options, placeholder, sugge
|
|
|
15
15
|
recoveryUnavailable: boolean;
|
|
16
16
|
cancel(): void;
|
|
17
17
|
}): import("react").JSX.Element;
|
|
18
|
-
export declare function AssistantParts({ showDetails, tools, }: {
|
|
18
|
+
export declare function AssistantParts({ showDetails, tools, toolReplyIndex, }: {
|
|
19
19
|
showDetails: boolean;
|
|
20
20
|
tools?: readonly UIMessagePart[];
|
|
21
|
+
toolReplyIndex?: number | undefined;
|
|
21
22
|
}): import("react").JSX.Element;
|
|
@@ -11,12 +11,10 @@ import { TooltipIconButton } from "./ui/tooltip-icon-button.js";
|
|
|
11
11
|
import { Button } from "./ui/button.js";
|
|
12
12
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip.js";
|
|
13
13
|
import { ToolGroupRoot, ToolGroupContent } from "./ui/tool-group.aui.js";
|
|
14
|
-
import { DisclosureTrigger, disclosureContentClass } from "./ui/home-demo/trace.js";
|
|
14
|
+
import { ToolCall, DisclosureTrigger, disclosureContentClass } from "./ui/home-demo/trace.js";
|
|
15
15
|
import { Reasoning, ReasoningRoot, ReasoningContent, ReasoningText } from "./ui/reasoning.aui.js";
|
|
16
16
|
import { TraceLine } from "./ui/home-demo/trace-line.js";
|
|
17
17
|
import { attachmentAccept } from "./attachments.js";
|
|
18
|
-
import { useToolPresentations } from "./react.js";
|
|
19
|
-
import { ToolPresentationUI } from "./tool-presentation.js";
|
|
20
18
|
export function AttachmentTile({ binding, savedPreview, }) {
|
|
21
19
|
const attachment = useAuiState((s) => s.attachment);
|
|
22
20
|
const preview = binding?.attachments.preview(attachment.id) ??
|
|
@@ -111,16 +109,13 @@ const groupAssistantParts = groupPartByType({
|
|
|
111
109
|
"tool-call": ["group-chainOfThought", "group-tool"],
|
|
112
110
|
"standalone-tool-call": [],
|
|
113
111
|
});
|
|
114
|
-
export function AssistantParts({ showDetails, tools = [], }) {
|
|
115
|
-
|
|
116
|
-
return (_jsx(_Fragment, { children: _jsx(GroupedParts, { groupBy: (part, context) => part.type === "tool-call" && registry?.controller?.get(part.toolName)
|
|
117
|
-
? []
|
|
118
|
-
: groupAssistantParts(part, context), children: ({ part, children }) => {
|
|
112
|
+
export function AssistantParts({ showDetails, tools = [], toolReplyIndex, }) {
|
|
113
|
+
return (_jsx(_Fragment, { children: _jsx(GroupedParts, { groupBy: groupAssistantParts, children: ({ part, children }) => {
|
|
119
114
|
switch (part.type) {
|
|
120
115
|
case "group-chainOfThought":
|
|
121
116
|
return _jsx("div", { className: cn("mb-3"), children: children });
|
|
122
117
|
case "group-tool":
|
|
123
|
-
return part.indices.length === 1 ? (
|
|
118
|
+
return part.indices.length === 1 ? (children) : (_jsx(ToolGroup, { tools: tools.filter((_, index) => part.indices.includes(index)), running: part.status.type === "running", count: part.indices.length, children: children }));
|
|
124
119
|
case "group-reasoning":
|
|
125
120
|
return (_jsxs(ReasoningRoot, { variant: "ghost", streaming: part.status.type === "running", className: cn("my-1"), children: [_jsx(DisclosureTrigger, { live: part.status.type === "running", label: part.status.type === "running" ? "thinking" : "reasoning" }), _jsx(ReasoningContent, { "aria-busy": part.status.type === "running", className: cn(disclosureContentClass), children: _jsx(ReasoningText, { className: cn("ps-0"), children: children }) })] }));
|
|
126
121
|
case "reasoning":
|
|
@@ -131,9 +126,11 @@ export function AssistantParts({ showDetails, tools = [], }) {
|
|
|
131
126
|
case "data":
|
|
132
127
|
return part.dataRendererUI;
|
|
133
128
|
case "text":
|
|
134
|
-
return part.text === "" && part.status?.type === "running" ? (_jsx(TraceLine, { live: true, label: "thinking" })) : (_jsx(MarkdownText, {}));
|
|
135
|
-
case "tool-call":
|
|
136
|
-
|
|
129
|
+
return part.text === "" && part.status?.type === "running" ? (_jsx(TraceLine, { live: true, label: "thinking" })) : (_jsx(MarkdownText, { assistant: true, replyIndex: toolReplyIndex, replyParts: tools }));
|
|
130
|
+
case "tool-call": {
|
|
131
|
+
const presentation = tools.find((tool) => tool.type === "tool" && tool.toolCallId === part.toolCallId);
|
|
132
|
+
return (_jsxs(_Fragment, { children: [_jsx(ToolCall, { ...part, showDetails: showDetails, presentation: presentation }), part.toolUI] }));
|
|
133
|
+
}
|
|
137
134
|
case "indicator":
|
|
138
135
|
return _jsx(TraceLine, { live: true, label: "thinking" });
|
|
139
136
|
default:
|
|
@@ -3,6 +3,7 @@ import { type AssistantRuntime, type ThreadMessageLike } from "@assistant-ui/rea
|
|
|
3
3
|
import { AssistantAttachments } from "./assistant-attachments.js";
|
|
4
4
|
import { type useChat, type UIMessage } from "./react.js";
|
|
5
5
|
import type { ChatProps } from "./types.js";
|
|
6
|
+
import type { PresentedMessage } from "./messages.js";
|
|
6
7
|
import { type VoiceComposerState } from "./voice/use-voice.js";
|
|
7
8
|
type ChatState = ReturnType<typeof useChat>;
|
|
8
9
|
export type AssistantBinding = {
|
|
@@ -15,7 +16,9 @@ export type AssistantBinding = {
|
|
|
15
16
|
send(): Promise<void>;
|
|
16
17
|
};
|
|
17
18
|
export declare function convertMessage(message: UIMessage): ThreadMessageLike;
|
|
18
|
-
export declare function projectMessages(messages: readonly
|
|
19
|
+
export declare function projectMessages(messages: readonly PresentedMessage[]): (UIMessage & {
|
|
20
|
+
toolReplyIndex?: number;
|
|
21
|
+
})[];
|
|
19
22
|
export declare function SessionRuntime({ id, chat, options, dictation, open, blocked, active, onEdit, children, }: {
|
|
20
23
|
id: string;
|
|
21
24
|
chat: ChatState;
|
|
@@ -52,16 +52,20 @@ export function projectMessages(messages) {
|
|
|
52
52
|
const projected = [];
|
|
53
53
|
for (const message of messages) {
|
|
54
54
|
const previous = projected.at(-1);
|
|
55
|
+
const replyIndex = message.finalToolReply
|
|
56
|
+
? message.parts.findIndex(({ type }) => type === "text")
|
|
57
|
+
: -1;
|
|
55
58
|
if (message.role === "assistant" && previous?.role === "assistant") {
|
|
56
59
|
projected[projected.length - 1] = {
|
|
57
60
|
...previous,
|
|
58
61
|
parts: [...previous.parts, ...message.parts],
|
|
62
|
+
...(replyIndex >= 0 ? { toolReplyIndex: previous.parts.length + replyIndex } : {}),
|
|
59
63
|
...(message.state ? { state: message.state } : {}),
|
|
60
64
|
...(message.error ? { error: message.error } : {}),
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
67
|
else
|
|
64
|
-
projected.push(message);
|
|
68
|
+
projected.push(replyIndex >= 0 ? { ...message, toolReplyIndex: replyIndex } : message);
|
|
65
69
|
}
|
|
66
70
|
return projected;
|
|
67
71
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { getToolPresentationController } from "./shared/tool-presentation.js";
|
|
2
|
+
import { stripToolResultBlocks } from "./shared/tool-result-markdown.js";
|
|
3
|
+
import { requestsTextOnlyReply } from "./shared/text-only-reply.js";
|
|
1
4
|
import { decodeToolProxy } from "./shared/tool-proxy.js";
|
|
2
5
|
import { pageDecisionSymbol } from "./shared/runtime-execution.js";
|
|
3
6
|
import { createAgent, } from "@nexface/agent";
|
|
@@ -7,7 +10,7 @@ import { getRuntimeController } from "./shared/runtime-controller.js";
|
|
|
7
10
|
import { validateAgentToolInput } from "./shared/schema.js";
|
|
8
11
|
import { EventType, EventSchemas, RunAgentInputSchema, TextInputContentSchema, ImageInputContentSchema, } from "@ag-ui/core";
|
|
9
12
|
import { conversationFromMessages } from "./storage.js";
|
|
10
|
-
import { createMessageUpdater, restoreMessages, settleApproval, projectMessages, } from "./protocol-messages.js";
|
|
13
|
+
import { completeToolReply, createMessageUpdater, restoreMessages, settleApproval, projectMessages, } from "./protocol-messages.js";
|
|
11
14
|
import { resolveModelConfig } from "./config.js";
|
|
12
15
|
import { markErrorPresented, reportError, runError, toolError, } from "./errors.js";
|
|
13
16
|
const controllerSymbol = Symbol.for("@nexface/agent/chat-controller");
|
|
@@ -419,8 +422,13 @@ class ChatClientImplementation {
|
|
|
419
422
|
if (this.#cancelled)
|
|
420
423
|
controller.abort(abortError());
|
|
421
424
|
controller.signal.throwIfAborted();
|
|
425
|
+
const output = stripToolResultBlocks(result.output);
|
|
426
|
+
if (requestsTextOnlyReply(content) && result.output.trim() && !output.trim()) {
|
|
427
|
+
throw new ClientError("INVALID_MODEL_RESPONSE", "The text-only reply contains no text.");
|
|
428
|
+
}
|
|
429
|
+
this.#messages = completeToolReply(this.#messages);
|
|
422
430
|
succeeded = true;
|
|
423
|
-
return result;
|
|
431
|
+
return output === result.output ? result : { ...result, output };
|
|
424
432
|
}
|
|
425
433
|
catch (failure) {
|
|
426
434
|
unsubscribe();
|
|
@@ -688,6 +696,9 @@ class ChatClientImplementation {
|
|
|
688
696
|
const contexts = await this.runtime.getContexts({ signal });
|
|
689
697
|
const runId = id();
|
|
690
698
|
this.#runId = runId;
|
|
699
|
+
const renderers = new Set(catalog
|
|
700
|
+
.filter(({ definition }) => getToolPresentationController(this.runtime)?.get(definition.name))
|
|
701
|
+
.map(({ definition }) => definition.name));
|
|
691
702
|
const input = {
|
|
692
703
|
threadId: this.id,
|
|
693
704
|
runId,
|
|
@@ -708,7 +719,10 @@ class ChatClientImplementation {
|
|
|
708
719
|
version: 3,
|
|
709
720
|
toolMetadata: Object.fromEntries(catalog.map(({ definition }) => [
|
|
710
721
|
definition.name,
|
|
711
|
-
{
|
|
722
|
+
{
|
|
723
|
+
...(definition.effect ? { effect: definition.effect } : {}),
|
|
724
|
+
...(renderers.has(definition.name) ? { hasRenderer: true } : {}),
|
|
725
|
+
},
|
|
712
726
|
])),
|
|
713
727
|
},
|
|
714
728
|
},
|