@nexface/chat 0.1.20 → 0.1.21-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.
Files changed (44) hide show
  1. package/dist/assistant-components.d.ts +2 -1
  2. package/dist/assistant-components.js +22 -10
  3. package/dist/assistant-runtime.js +15 -4
  4. package/dist/client.d.ts +3 -1
  5. package/dist/client.js +136 -42
  6. package/dist/config.d.ts +1 -1
  7. package/dist/default-chat.d.ts +1 -1
  8. package/dist/default-chat.js +26411 -26047
  9. package/dist/fonts/Inter-OFL.txt +93 -0
  10. package/dist/fonts/inter-medium.ttf +0 -0
  11. package/dist/protocol-messages.js +15 -16
  12. package/dist/protocol-response.js +10 -3
  13. package/dist/react.d.ts +13 -1
  14. package/dist/react.js +609 -99
  15. package/dist/session-coordinator.d.ts +23 -0
  16. package/dist/session-coordinator.js +139 -0
  17. package/dist/session-history.d.ts +29 -0
  18. package/dist/session-history.js +282 -0
  19. package/dist/shared/errors.d.ts +1 -1
  20. package/dist/shared/errors.js +2 -0
  21. package/dist/shared/tool-presentation.d.ts +17 -0
  22. package/dist/shared/tool-presentation.js +5 -0
  23. package/dist/shared/tool-proxy.d.ts +6 -0
  24. package/dist/shared/tool-proxy.js +25 -0
  25. package/dist/storage.d.ts +4 -6
  26. package/dist/storage.js +52 -43
  27. package/dist/styles.css +1491 -676
  28. package/dist/tool-confirmation-card.d.ts +5 -0
  29. package/dist/tool-confirmation-card.js +33 -0
  30. package/dist/tool-confirmation.d.ts +23 -0
  31. package/dist/tool-confirmation.js +25 -0
  32. package/dist/tool-presentation.d.ts +6 -0
  33. package/dist/tool-presentation.js +132 -0
  34. package/dist/tool-result.d.ts +5 -0
  35. package/dist/tool-result.js +31 -0
  36. package/dist/types.d.ts +3 -1
  37. package/dist/ui/home-demo/greeting.d.ts +3 -1
  38. package/dist/ui/home-demo/greeting.js +2 -2
  39. package/dist/ui/home-demo/suggestions.d.ts +2 -4
  40. package/dist/ui/home-demo/suggestions.js +5 -4
  41. package/dist/ui/home-demo/trace.js +2 -3
  42. package/dist/ui/thread-list.aui.d.ts +2 -1
  43. package/dist/ui/thread-list.aui.js +2 -2
  44. 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
@@ -1,3 +1,4 @@
1
+ import { decodeToolProxy } from "./shared/tool-proxy.js";
1
2
  import { toolError, isNexfaceError } from "./errors.js";
2
3
  import { EventType, mergeMetadata } from "@ag-ui/core";
3
4
  import { getToolResultError } from "./tool-result.js";
@@ -349,14 +350,16 @@ export function projectMessages(messages) {
349
350
  if (message.role === "reasoning" && assistantIds.has(metadata?.reasoningOwnerId))
350
351
  return [];
351
352
  const parts = [];
352
- const text = typeof metadata?.reasoningText === "string"
353
- ? metadata.reasoningText
354
- : typeof message.content === "string"
355
- ? message.content
356
- : (message.content ?? [])
357
- .filter((part) => part.type === "text")
358
- .map((part) => part.text)
359
- .join("");
353
+ const text = typeof metadata?.stoppedText === "string"
354
+ ? metadata.stoppedText
355
+ : typeof metadata?.reasoningText === "string"
356
+ ? metadata.reasoningText
357
+ : typeof message.content === "string"
358
+ ? message.content
359
+ : (message.content ?? [])
360
+ .filter((part) => part.type === "text")
361
+ .map((part) => part.text)
362
+ .join("");
360
363
  const reasoning = ownedReasoning.get(message.id) ?? [];
361
364
  let offset = 0;
362
365
  for (const entry of reasoning) {
@@ -376,6 +379,7 @@ export function projectMessages(messages) {
376
379
  if (message.role === "reasoning" && !text)
377
380
  return [];
378
381
  if (typeof metadata?.reasoningText === "string" &&
382
+ typeof metadata?.stoppedText !== "string" &&
379
383
  typeof message.content === "string" &&
380
384
  message.content !== text) {
381
385
  parts.push({ type: "text", text: message.content });
@@ -389,9 +393,9 @@ export function projectMessages(messages) {
389
393
  let name = call.function.name, args = call.function.arguments;
390
394
  if (name === "nxf_callAppTool")
391
395
  try {
392
- const parsed = JSON.parse(args);
396
+ const parsed = decodeToolProxy(JSON.parse(args));
393
397
  name = parsed.name;
394
- args = JSON.stringify(parsed.input);
398
+ args = JSON.stringify(parsed.arguments);
395
399
  }
396
400
  catch {
397
401
  /* Incomplete arguments remain visible. */
@@ -413,12 +417,7 @@ export function projectMessages(messages) {
413
417
  arguments: args,
414
418
  ...(result?.role === "tool"
415
419
  ? {
416
- result: result.content.length > 4000
417
- ? JSON.stringify({
418
- contentOmitted: true,
419
- preview: result.content.slice(0, 4000),
420
- })
421
- : result.content,
420
+ result: result.content,
422
421
  isError,
423
422
  }
424
423
  : {}),
@@ -1,3 +1,4 @@
1
+ import { decodeToolProxy } from "./shared/tool-proxy.js";
1
2
  export function decodeAgentResponse(messages, snapshot, terminal) {
2
3
  const state = snapshot;
3
4
  const continuation = state?.nexface;
@@ -68,10 +69,13 @@ export function decodeAgentResponse(messages, snapshot, terminal) {
68
69
  if (!args || typeof args !== "object" || Array.isArray(args))
69
70
  throw new Error("Invalid pending tool arguments.");
70
71
  const input = args;
71
- const name = call.name === "nxf_callAppTool" ? input.name : call.name;
72
+ const proxy = call.name === "nxf_callAppTool" ? decodeToolProxy(input) : undefined;
73
+ const name = proxy ? proxy.name : call.name;
72
74
  const toolInput = call.name === "nxf_callAppTool"
73
- ? input.input
74
- : Object.fromEntries(Object.entries(input).filter(([key]) => key !== "progressLabel"));
75
+ ? proxy.arguments
76
+ : actionIsNative(call.name)
77
+ ? Object.fromEntries(Object.entries(input).filter(([key]) => key !== "progressLabel"))
78
+ : input;
75
79
  if (extension.kind !== "client-tool-execution")
76
80
  throw new Error("Unsupported remote interrupt.");
77
81
  const action = extension.action;
@@ -87,3 +91,6 @@ export function decodeAgentResponse(messages, snapshot, terminal) {
87
91
  }
88
92
  return { type: "client-tool-execution", interruptId: interrupt.id, action };
89
93
  }
94
+ function actionIsNative(name) {
95
+ return ["nxf_getSnapshot", "nxf_executeAction", "nxf_applyAction"].includes(name);
96
+ }
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 {
@@ -25,7 +26,6 @@ interface UseChatResult {
25
26
  readonly activeSessionId: string;
26
27
  readonly messages: readonly UIMessage[];
27
28
  readonly status: ChatClientStatus | "cancelling" | "switching-model";
28
- readonly storageWarning?: string;
29
29
  readonly error?: ChatError;
30
30
  readonly model: AgentModelInfo;
31
31
  readonly interrupt?: ToolApprovalInterruptDescriptor;
@@ -60,6 +60,18 @@ export type NexfaceProviderProps = {
60
60
  }) => Promise<Response>;
61
61
  agent?: never;
62
62
  });
63
+ export declare function isChatHistoryReady(chat: UseChatResult): boolean;
64
+ export declare function isSessionOccupied(chat: UseChatResult, id: string): boolean;
65
+ export declare function isSessionOperationPending(chat: UseChatResult): boolean;
66
+ export declare function watchHistorySidebar(chat: UseChatResult): (() => void) | undefined;
67
+ export declare function historyNotice(chat: UseChatResult): string | undefined;
68
+ export declare function sessionCommandResult(chat: UseChatResult): Promise<void> | undefined;
69
+ export declare function isChatRecoveryUnavailable(chat: UseChatResult): boolean;
70
+ export declare function canEditChatSession(chat: UseChatResult, sessionId: string): boolean;
63
71
  export declare function assertChatSendable(chat: UseChatResult, sessionId: string): void;
72
+ export declare function useToolPresentations(): {
73
+ controller: ToolPresentationController | undefined;
74
+ report(cause: unknown, sessionId: string, toolCallId: string): void;
75
+ } | null;
64
76
  export declare function NexfaceProvider(props: NexfaceProviderProps): ReactElement;
65
77
  export declare function useChat(): UseChatResult;