@nexface/chat 0.1.15-alpha.0 → 0.1.15-alpha.2
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/assistant-attachments.js +60 -17
- package/dist/assistant-components.d.ts +3 -3
- package/dist/assistant-components.js +77 -29
- package/dist/assistant-runtime.d.ts +1 -1
- package/dist/assistant-runtime.js +100 -43
- package/dist/attachments.js +36 -15
- package/dist/client.js +309 -77
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -5
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +2102 -728
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +69 -18
- package/dist/index.js +0 -1
- package/dist/messages.js +0 -1
- package/dist/page-confirmation.js +3 -4
- package/dist/protocol-messages.js +290 -66
- package/dist/protocol-response.js +38 -18
- package/dist/react.d.ts +1 -1
- package/dist/react.js +147 -50
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +0 -1
- package/dist/shared/runtime-controller.d.ts +1 -0
- package/dist/shared/runtime-controller.js +0 -1
- package/dist/shared/runtime-execution.js +0 -1
- package/dist/shared/schema.js +45 -19
- package/dist/storage.js +130 -53
- package/dist/styles.css +99 -20
- package/dist/tool-result.js +7 -3
- package/dist/types.js +0 -1
- package/dist/ui/attachment.aui.d.ts +1 -1
- package/dist/ui/attachment.aui.js +16 -20
- package/dist/ui/avatar.js +0 -1
- package/dist/ui/button.js +0 -1
- package/dist/ui/code-block.js +2 -3
- package/dist/ui/collapsible.js +2 -3
- package/dist/ui/composer-voice.js +3 -2
- package/dist/ui/dialog.d.ts +1 -1
- package/dist/ui/dialog.js +9 -4
- package/dist/ui/dropdown-menu.js +2 -3
- package/dist/ui/home-demo/action-bar.js +0 -1
- package/dist/ui/home-demo/composer.js +7 -4
- package/dist/ui/home-demo/greeting.d.ts +1 -1
- package/dist/ui/home-demo/greeting.js +1 -2
- package/dist/ui/home-demo/messages.d.ts +1 -1
- package/dist/ui/home-demo/messages.js +4 -5
- package/dist/ui/home-demo/styles.js +0 -1
- package/dist/ui/home-demo/suggestions.d.ts +1 -1
- package/dist/ui/home-demo/suggestions.js +5 -3
- package/dist/ui/home-demo/surfaces.js +3 -2
- package/dist/ui/home-demo/thread.d.ts +1 -1
- package/dist/ui/home-demo/thread.js +1 -2
- package/dist/ui/home-demo/trace-line.d.ts +1 -1
- package/dist/ui/home-demo/trace-line.js +2 -3
- package/dist/ui/home-demo/trace.d.ts +1 -1
- package/dist/ui/home-demo/trace.js +28 -9
- package/dist/ui/home-demo/type.js +0 -1
- package/dist/ui/input.js +0 -1
- package/dist/ui/markdown-text.js +2 -3
- package/dist/ui/reasoning.aui.js +2 -3
- package/dist/ui/reasoning.d.ts +1 -1
- package/dist/ui/reasoning.js +6 -9
- package/dist/ui/surface.js +27 -8
- package/dist/ui/thread-list.aui.d.ts +2 -2
- package/dist/ui/thread-list.aui.js +18 -12
- package/dist/ui/tool-group.aui.js +2 -3
- package/dist/ui/tooltip-icon-button.js +1 -2
- package/dist/ui/tooltip.js +0 -1
- package/dist/ui/use-attachment-src.js +1 -2
- package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
- package/dist/ui/use-copy-to-clipboard.js +1 -2
- package/dist/ui/utils.js +9 -3
- package/dist/use-next-message.js +7 -4
- package/dist/voice/types.js +0 -1
- package/dist/voice/use-voice.js +35 -13
- package/package.json +8 -4
- package/dist/assistant-attachments.js.map +0 -1
- package/dist/assistant-components.js.map +0 -1
- package/dist/assistant-runtime.js.map +0 -1
- package/dist/attachments.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/default-chat.js.map +0 -7
- package/dist/errors.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/messages.js.map +0 -1
- package/dist/page-confirmation.js.map +0 -1
- package/dist/protocol-messages.js.map +0 -1
- package/dist/protocol-response.js.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/shared/errors.js.map +0 -1
- package/dist/shared/runtime-controller.js.map +0 -1
- package/dist/shared/runtime-execution.js.map +0 -1
- package/dist/shared/schema.js.map +0 -1
- package/dist/storage.js.map +0 -1
- package/dist/tool-result.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/ui/attachment.aui.js.map +0 -1
- package/dist/ui/avatar.js.map +0 -1
- package/dist/ui/button.js.map +0 -1
- package/dist/ui/code-block.js.map +0 -1
- package/dist/ui/collapsible.js.map +0 -1
- package/dist/ui/composer-voice.js.map +0 -1
- package/dist/ui/dialog.js.map +0 -1
- package/dist/ui/dropdown-menu.js.map +0 -1
- package/dist/ui/home-demo/action-bar.js.map +0 -1
- package/dist/ui/home-demo/composer.js.map +0 -1
- package/dist/ui/home-demo/greeting.js.map +0 -1
- package/dist/ui/home-demo/messages.js.map +0 -1
- package/dist/ui/home-demo/styles.js.map +0 -1
- package/dist/ui/home-demo/suggestions.js.map +0 -1
- package/dist/ui/home-demo/surfaces.js.map +0 -1
- package/dist/ui/home-demo/thread.js.map +0 -1
- package/dist/ui/home-demo/trace-line.js.map +0 -1
- package/dist/ui/home-demo/trace.js.map +0 -1
- package/dist/ui/home-demo/type.js.map +0 -1
- package/dist/ui/input.js.map +0 -1
- package/dist/ui/markdown-text.js.map +0 -1
- package/dist/ui/reasoning.aui.js.map +0 -1
- package/dist/ui/reasoning.js.map +0 -1
- package/dist/ui/surface.js.map +0 -1
- package/dist/ui/thread-list.aui.js.map +0 -1
- package/dist/ui/tool-group.aui.js.map +0 -1
- package/dist/ui/tooltip-icon-button.js.map +0 -1
- package/dist/ui/tooltip.js.map +0 -1
- package/dist/ui/use-attachment-src.js.map +0 -1
- package/dist/ui/use-copy-to-clipboard.js.map +0 -1
- package/dist/ui/utils.js.map +0 -1
- package/dist/use-next-message.js.map +0 -1
- package/dist/voice/types.js.map +0 -1
- package/dist/voice/use-voice.js.map +0 -1
package/dist/errors.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface NexfaceErrorEvent {
|
|
|
18
18
|
/** Available local exception or serialized remote diagnostic; never persisted by Chat. */
|
|
19
19
|
readonly cause: unknown;
|
|
20
20
|
}
|
|
21
|
+
export declare function reportError(event: NexfaceErrorEvent, onError?: (event: NexfaceErrorEvent) => void): void;
|
|
21
22
|
export type ToolState = "failed" | "unknown" | "not_started" | "cancelled" | "rejected";
|
|
22
23
|
export declare function runError(id: string, cause: unknown, unknownTools?: boolean): NexfaceError;
|
|
23
24
|
export declare function toolError(id: string, toolCallId: string, content: string, parentErrorId?: string, outcomeUnknown?: boolean, toolName?: string): {
|
package/dist/errors.js
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
|
+
export function reportError(event, onError) {
|
|
2
|
+
try {
|
|
3
|
+
if (onError) {
|
|
4
|
+
// Also contain rejected promises from async diagnostic callbacks.
|
|
5
|
+
void Promise.resolve(onError(event)).catch(() => undefined);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
console.error("[Nexface]", event.cause, event);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
/* Diagnostics must not affect task execution. */
|
|
13
|
+
}
|
|
14
|
+
}
|
|
1
15
|
function errorCode(cause) {
|
|
2
|
-
return cause && typeof cause === "object" && "code" in cause && typeof cause.code === "string"
|
|
16
|
+
return cause && typeof cause === "object" && "code" in cause && typeof cause.code === "string"
|
|
17
|
+
? cause.code
|
|
18
|
+
: undefined;
|
|
3
19
|
}
|
|
4
20
|
export function runError(id, cause, unknownTools = false) {
|
|
5
21
|
const code = errorCode(cause) ?? "CHAT_RUN_ERROR";
|
|
6
|
-
const userMessage = unknownTools
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
const userMessage = unknownTools
|
|
23
|
+
? "Some results are missing. Check whether the actions completed."
|
|
24
|
+
: code === "CHAT_REQUEST_FAILED"
|
|
25
|
+
? "Request failed. Please try again later."
|
|
26
|
+
: code === "CHAT_STREAM_INCOMPLETE"
|
|
27
|
+
? "The response ended before it was complete."
|
|
28
|
+
: code === "CHAT_RECOVERY_UNAVAILABLE"
|
|
29
|
+
? "This chat cannot continue. Check the action results, then start a new chat."
|
|
10
30
|
: "Something went wrong.";
|
|
11
31
|
return { id, scope: "run", code, userMessage };
|
|
12
32
|
}
|
|
@@ -15,7 +35,10 @@ export function toolError(id, toolCallId, content, parentErrorId, outcomeUnknown
|
|
|
15
35
|
try {
|
|
16
36
|
const payload = JSON.parse(content);
|
|
17
37
|
cause = payload?.error;
|
|
18
|
-
if (!cause &&
|
|
38
|
+
if (!cause &&
|
|
39
|
+
toolName &&
|
|
40
|
+
["nxf_executeAction", "nxf_applyAction", "nxf_getSnapshot"].includes(toolName) &&
|
|
41
|
+
payload?.result?.ok === false)
|
|
19
42
|
cause = payload.result.error;
|
|
20
43
|
}
|
|
21
44
|
catch {
|
|
@@ -23,31 +46,60 @@ export function toolError(id, toolCallId, content, parentErrorId, outcomeUnknown
|
|
|
23
46
|
}
|
|
24
47
|
if (!cause)
|
|
25
48
|
return {};
|
|
26
|
-
const code = outcomeUnknown ? "EXECUTION_OUTCOME_UNKNOWN" : errorCode(cause) ?? "TOOL_ERROR";
|
|
49
|
+
const code = outcomeUnknown ? "EXECUTION_OUTCOME_UNKNOWN" : (errorCode(cause) ?? "TOOL_ERROR");
|
|
27
50
|
if (code === "TOOL_CONFIRMATION_REJECTED")
|
|
28
51
|
return { toolState: "rejected" };
|
|
29
52
|
if (code === "TOOL_SKIPPED")
|
|
30
53
|
return { toolState: "not_started" };
|
|
31
54
|
if (code === "TOOL_CANCELLED")
|
|
32
55
|
return { toolState: "cancelled" };
|
|
33
|
-
const execution = code === "EXECUTION_OUTCOME_UNKNOWN"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
const execution = code === "EXECUTION_OUTCOME_UNKNOWN"
|
|
57
|
+
? "unknown"
|
|
58
|
+
: [
|
|
59
|
+
"INVALID_INPUT",
|
|
60
|
+
"UNKNOWN_TOOL",
|
|
61
|
+
"TOOL_UNAVAILABLE",
|
|
62
|
+
"TOOL_CONFIRMATION_UNAVAILABLE",
|
|
63
|
+
"TOOL_CONFIRMATION_INVALIDATED",
|
|
64
|
+
"TOOL_REGISTRATION_TIMEOUT",
|
|
65
|
+
].includes(code)
|
|
66
|
+
? "not_started"
|
|
67
|
+
: "failed";
|
|
68
|
+
return {
|
|
69
|
+
toolState: execution,
|
|
70
|
+
cause,
|
|
71
|
+
error: {
|
|
72
|
+
id,
|
|
73
|
+
scope: "tool",
|
|
74
|
+
code,
|
|
75
|
+
toolCallId,
|
|
76
|
+
execution,
|
|
77
|
+
userMessage: execution === "unknown"
|
|
78
|
+
? "No result was received. Check whether the action completed."
|
|
79
|
+
: execution === "not_started"
|
|
80
|
+
? "The action could not start."
|
|
81
|
+
: "The action failed.",
|
|
38
82
|
...(parentErrorId ? { parentErrorId } : {}),
|
|
39
|
-
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
40
85
|
}
|
|
41
86
|
export function isNexfaceError(value) {
|
|
42
87
|
if (!value || typeof value !== "object")
|
|
43
88
|
return false;
|
|
44
89
|
const error = value;
|
|
45
|
-
return typeof error.id === "string" &&
|
|
46
|
-
|
|
47
|
-
|
|
90
|
+
return (typeof error.id === "string" &&
|
|
91
|
+
typeof error.code === "string" &&
|
|
92
|
+
typeof error.userMessage === "string" &&
|
|
93
|
+
(error.parentErrorId === undefined || typeof error.parentErrorId === "string") &&
|
|
94
|
+
(error.scope === "run" ||
|
|
95
|
+
(error.scope === "tool" &&
|
|
96
|
+
typeof error.toolCallId === "string" &&
|
|
97
|
+
["not_started", "failed", "unknown"].includes(String(error.execution)))));
|
|
48
98
|
}
|
|
49
99
|
const presentedFailures = new WeakSet();
|
|
50
|
-
export function markErrorPresented(error) {
|
|
100
|
+
export function markErrorPresented(error) {
|
|
101
|
+
presentedFailures.add(error);
|
|
102
|
+
}
|
|
51
103
|
export function sendErrorNotice(error) {
|
|
52
104
|
if (error instanceof Error && presentedFailures.has(error))
|
|
53
105
|
return "";
|
|
@@ -58,4 +110,3 @@ export function sendErrorNotice(error) {
|
|
|
58
110
|
return "Check your message and send it again.";
|
|
59
111
|
return runError("send", error).userMessage;
|
|
60
112
|
}
|
|
61
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/index.js
CHANGED
package/dist/messages.js
CHANGED
|
@@ -40,9 +40,9 @@ export function PageConfirmationProvider({ interrupt, onConfirm, onBindingRemove
|
|
|
40
40
|
if (resumingRef.current.has(binding))
|
|
41
41
|
return true;
|
|
42
42
|
const pending = interruptRef.current;
|
|
43
|
-
if (pending?.mode !== "page"
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (pending?.mode !== "page" ||
|
|
44
|
+
pending.toolName !== binding.toolName ||
|
|
45
|
+
bindingsRef.current.get(binding.toolName) !== binding) {
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
resumingRef.current.add(binding);
|
|
@@ -86,4 +86,3 @@ export function usePageConfirmation(binding, fallback) {
|
|
|
86
86
|
return fallbackRef.current(...args);
|
|
87
87
|
}, [binding, context]);
|
|
88
88
|
}
|
|
89
|
-
//# sourceMappingURL=page-confirmation.js.map
|