@nexface/chat 0.1.20-alpha.0 → 0.1.20

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.
@@ -413,7 +413,12 @@ export function projectMessages(messages) {
413
413
  arguments: args,
414
414
  ...(result?.role === "tool"
415
415
  ? {
416
- result: result.content,
416
+ result: result.content.length > 4000
417
+ ? JSON.stringify({
418
+ contentOmitted: true,
419
+ preview: result.content.slice(0, 4000),
420
+ })
421
+ : result.content,
417
422
  isError,
418
423
  }
419
424
  : {}),
package/dist/react.d.ts CHANGED
@@ -8,7 +8,6 @@ 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";
12
11
  export type { UIMessage, UIMessagePart } from "./messages.js";
13
12
  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";
14
13
  export interface ChatError {
@@ -62,9 +61,5 @@ export type NexfaceProviderProps = {
62
61
  agent?: never;
63
62
  });
64
63
  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;
69
64
  export declare function NexfaceProvider(props: NexfaceProviderProps): ReactElement;
70
65
  export declare function useChat(): UseChatResult;
package/dist/react.js CHANGED
@@ -7,7 +7,6 @@ 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";
11
10
  export function isChatError(error) {
12
11
  const value = error;
13
12
  return (!!value &&
@@ -21,20 +20,6 @@ export function assertChatSendable(chat, sessionId) {
21
20
  sendGuards.get(chat.sendMessage)?.(sessionId);
22
21
  }
23
22
  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
- }
38
23
  const createId = () => globalThis.crypto.randomUUID();
39
24
  const textOf = (message) => message.parts
40
25
  .filter((part) => part.type === "text")
@@ -371,17 +356,12 @@ export function NexfaceProvider(props) {
371
356
  }
372
357
  },
373
358
  };
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 }) }) }) }));
359
+ return (_jsx(ChatContext.Provider, { value: value, 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) => {
360
+ if (registered)
361
+ pageTools.current.add(name);
362
+ else
363
+ pageTools.current.delete(name);
364
+ }, children: children }) }) }));
385
365
  }
386
366
  export function useChat() {
387
367
  const chat = useContext(ChatContext);