@nexface/chat 0.1.19 → 0.1.20-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/assistant-components.js +8 -3
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +573 -299
- package/dist/fonts/Inter-OFL.txt +93 -0
- package/dist/fonts/inter-medium.ttf +0 -0
- package/dist/protocol-messages.js +1 -6
- package/dist/react.d.ts +5 -0
- package/dist/react.js +26 -6
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +2 -0
- package/dist/shared/tool-presentation.d.ts +17 -0
- package/dist/shared/tool-presentation.js +5 -0
- package/dist/styles.css +1481 -676
- package/dist/tool-presentation.d.ts +6 -0
- package/dist/tool-presentation.js +132 -0
- package/dist/tool-result.d.ts +5 -0
- package/dist/tool-result.js +31 -0
- package/dist/types.d.ts +3 -1
- package/dist/ui/home-demo/greeting.d.ts +3 -1
- package/dist/ui/home-demo/greeting.js +2 -2
- package/dist/ui/home-demo/suggestions.d.ts +2 -4
- package/dist/ui/home-demo/suggestions.js +4 -4
- package/dist/ui/home-demo/trace.js +2 -3
- package/package.json +3 -3
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -413,12 +413,7 @@ export function projectMessages(messages) {
|
|
|
413
413
|
arguments: args,
|
|
414
414
|
...(result?.role === "tool"
|
|
415
415
|
? {
|
|
416
|
-
result: result.content
|
|
417
|
-
? JSON.stringify({
|
|
418
|
-
contentOmitted: true,
|
|
419
|
-
preview: result.content.slice(0, 4000),
|
|
420
|
-
})
|
|
421
|
-
: result.content,
|
|
416
|
+
result: result.content,
|
|
422
417
|
isError,
|
|
423
418
|
}
|
|
424
419
|
: {}),
|
package/dist/react.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { NexfaceAgentConfig } from "./config.js";
|
|
|
8
8
|
import type { ChatRunResult } from "./types.js";
|
|
9
9
|
import { type Attachment } from "./attachments.js";
|
|
10
10
|
import type { UIMessage } from "./messages.js";
|
|
11
|
+
import { type ToolPresentationController } from "./shared/tool-presentation.js";
|
|
11
12
|
export type { UIMessage, UIMessagePart } from "./messages.js";
|
|
12
13
|
export type ChatCommandErrorCode = "CHAT_MODEL_SWITCH_BLOCKED" | "CHAT_RUNTIME_CHANGED" | "CHAT_RUN_ACTIVE" | "CHAT_SESSION_CREATE_BLOCKED" | "CHAT_SESSION_SWITCH_BLOCKED" | "INVALID_INPUT" | "UNKNOWN_SESSION";
|
|
13
14
|
export interface ChatError {
|
|
@@ -61,5 +62,9 @@ export type NexfaceProviderProps = {
|
|
|
61
62
|
agent?: never;
|
|
62
63
|
});
|
|
63
64
|
export declare function assertChatSendable(chat: UseChatResult, sessionId: string): void;
|
|
65
|
+
export declare function useToolPresentations(): {
|
|
66
|
+
controller: ToolPresentationController | undefined;
|
|
67
|
+
report(cause: unknown, sessionId: string, toolCallId: string): void;
|
|
68
|
+
} | null;
|
|
64
69
|
export declare function NexfaceProvider(props: NexfaceProviderProps): ReactElement;
|
|
65
70
|
export declare function useChat(): UseChatResult;
|
package/dist/react.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createChatClient, getClientController, ClientError, } from "./client.js
|
|
|
7
7
|
import { attachmentContent } from "./attachments.js";
|
|
8
8
|
import { projectMessages } from "./protocol-messages.js";
|
|
9
9
|
import { chatStorageKey, readChatStorage, writeChatStorage } from "./storage.js";
|
|
10
|
+
import { getToolPresentationController, } from "./shared/tool-presentation.js";
|
|
10
11
|
export function isChatError(error) {
|
|
11
12
|
const value = error;
|
|
12
13
|
return (!!value &&
|
|
@@ -20,6 +21,20 @@ export function assertChatSendable(chat, sessionId) {
|
|
|
20
21
|
sendGuards.get(chat.sendMessage)?.(sessionId);
|
|
21
22
|
}
|
|
22
23
|
const ChatContext = createContext(null);
|
|
24
|
+
const ToolPresentationContext = createContext(null);
|
|
25
|
+
function ToolPresentationProvider({ controller, report, children, }) {
|
|
26
|
+
const [, changed] = useReducer((revision) => revision + 1, 0);
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
const unsubscribe = controller?.subscribe(changed);
|
|
29
|
+
// Child bindings may have registered before this provider's layout effect.
|
|
30
|
+
changed();
|
|
31
|
+
return unsubscribe;
|
|
32
|
+
}, [controller]);
|
|
33
|
+
return (_jsx(ToolPresentationContext.Provider, { value: { controller, report }, children: children }));
|
|
34
|
+
}
|
|
35
|
+
export function useToolPresentations() {
|
|
36
|
+
return useContext(ToolPresentationContext);
|
|
37
|
+
}
|
|
23
38
|
const createId = () => globalThis.crypto.randomUUID();
|
|
24
39
|
const textOf = (message) => message.parts
|
|
25
40
|
.filter((part) => part.type === "text")
|
|
@@ -356,12 +371,17 @@ export function NexfaceProvider(props) {
|
|
|
356
371
|
}
|
|
357
372
|
},
|
|
358
373
|
};
|
|
359
|
-
return (_jsx(ChatContext.Provider, { value: value, children: _jsx(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
374
|
+
return (_jsx(ChatContext.Provider, { value: value, children: _jsx(ToolPresentationProvider, { controller: getToolPresentationController(toolRuntime), report: (cause, sessionId, toolCallId) => reportError({
|
|
375
|
+
cause,
|
|
376
|
+
sessionId,
|
|
377
|
+
toolCallId,
|
|
378
|
+
code: "CHAT_TOOL_RENDER_FAILED",
|
|
379
|
+
}, onError.current), children: _jsx(ToolsProvider, { toolRuntime: toolRuntime, webMcp: webMcp, children: _jsx(PageConfirmationProvider, { interrupt: approval, onConfirm: () => getClientController(active().client).confirmPage(), onBindingRemoved: () => getClientController(active().client).invalidate("Page confirmation entry was removed."), onBindingRegistration: (name, registered) => {
|
|
380
|
+
if (registered)
|
|
381
|
+
pageTools.current.add(name);
|
|
382
|
+
else
|
|
383
|
+
pageTools.current.delete(name);
|
|
384
|
+
}, children: children }) }) }) }));
|
|
365
385
|
}
|
|
366
386
|
export function useChat() {
|
|
367
387
|
const chat = useContext(ChatContext);
|
package/dist/shared/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const TOOL_ERROR_CODES: readonly ["EXECUTION_OUTCOME_UNKNOWN", "ACTION_IN_FLIGHT", "ACTION_NOT_HANDLED", "ACTION_TARGET_UNAVAILABLE", "BROWSER_EXECUTION_FAILED", "BROWSER_SNAPSHOT_REQUIRED", "BROWSER_TOOLS_UNAVAILABLE", "CONTRACT_MISMATCH", "DUPLICATE_BINDING", "INVALID_INPUT", "INVALID_TOOL_RUNTIME", "OPERATION_BUSY", "TOOL_CANCELLED", "TOOL_CONFIRMATION_INVALIDATED", "TOOL_CONFIRMATION_REJECTED", "TOOL_ERROR", "TOOL_REGISTRATION_TIMEOUT", "TOOL_SKIPPED", "TOOL_UNAVAILABLE", "UNKNOWN_TOOL"];
|
|
1
|
+
export declare const TOOL_ERROR_CODES: readonly ["EXECUTION_OUTCOME_UNKNOWN", "ACTION_IN_FLIGHT", "ACTION_NOT_HANDLED", "ACTION_TARGET_UNAVAILABLE", "BROWSER_EXECUTION_FAILED", "BROWSER_SNAPSHOT_REQUIRED", "BROWSER_TOOLS_UNAVAILABLE", "CONTRACT_MISMATCH", "DUPLICATE_BINDING", "INVALID_INPUT", "INVALID_CONFIRMATION_RESULT", "TOOL_CONFIRMATION_LIMIT", "INVALID_TOOL_RUNTIME", "OPERATION_BUSY", "TOOL_CANCELLED", "TOOL_CONFIRMATION_INVALIDATED", "TOOL_CONFIRMATION_REJECTED", "TOOL_ERROR", "TOOL_REGISTRATION_TIMEOUT", "TOOL_SKIPPED", "TOOL_UNAVAILABLE", "UNKNOWN_TOOL"];
|
|
2
2
|
type AgentToolErrorCode = (typeof TOOL_ERROR_CODES)[number];
|
|
3
3
|
export declare class AgentToolError extends Error {
|
|
4
4
|
readonly code: AgentToolErrorCode;
|
package/dist/shared/errors.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ToolRuntime } from "@nexface/tools";
|
|
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;
|