@nexface/chat 0.1.1-alpha.5 → 0.1.1-alpha.7

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.
@@ -0,0 +1,2 @@
1
+ export { createChatClient } from "./client.js";
2
+ export type { ChatClient, ChatClientOptions, ChatClientStatus, RunHandler, Message, ProtocolEvent, ToolApprovalInterruptDescriptor } from "./client.js";
@@ -0,0 +1,2 @@
1
+ export { createChatClient } from "./client.js";
2
+ //# sourceMappingURL=client-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-entry.js","sourceRoot":"","sources":["../src/client-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,88 @@
1
+ import { type Agent, type AgentInputContent, type AgentMessage, type AgentRunResult, type RunAgentInput, type AgentModelConfig } from "@nexface/agent";
2
+ import type { ToolRuntime } from "@nexface/tools";
3
+ import { type Message } from "@ag-ui/core";
4
+ import { type ProtocolEvent } from "./protocol-messages.js";
5
+ import { type NexfaceAgentConfig } from "./config.js";
6
+ import { type UIMessage } from "./messages.js";
7
+ export type { Message } from "@ag-ui/core";
8
+ export type { ProtocolEvent } from "./protocol-messages.js";
9
+ export type { ToolApprovalInterruptDescriptor } from "@nexface/agent";
10
+ import type { ToolApprovalInterruptDescriptor } from "@nexface/agent";
11
+ export type ChatClientStatus = "idle" | "running" | "waiting" | "error";
12
+ export type RunHandler = (input: RunAgentInput, options: {
13
+ signal: AbortSignal;
14
+ }) => Promise<Response>;
15
+ export type ChatClientOptions = {
16
+ toolRuntime: ToolRuntime;
17
+ } & ({
18
+ agent: NexfaceAgentConfig;
19
+ run?: never;
20
+ } | {
21
+ run: RunHandler;
22
+ agent?: never;
23
+ });
24
+ export interface ChatClient {
25
+ getMessages(): readonly Message[];
26
+ subscribeEvents(listener: (event: ProtocolEvent) => void): () => void;
27
+ getStatus(): ChatClientStatus;
28
+ getApproval(): ToolApprovalInterruptDescriptor | undefined;
29
+ getError(): Error | undefined;
30
+ /**
31
+ * @experimental State subscriptions may change in future releases.
32
+ * @beta
33
+ */
34
+ subscribe(listener: () => void): () => void;
35
+ sendMessage(content: string | readonly AgentInputContent[]): Promise<Extract<AgentRunResult, {
36
+ outcome: {
37
+ type: "success";
38
+ };
39
+ }>>;
40
+ respondToApproval(id: string, response: {
41
+ approved: boolean;
42
+ }): Promise<void>;
43
+ cancel(): void;
44
+ dispose(): void;
45
+ }
46
+ export declare class ClientError extends Error {
47
+ readonly code: string;
48
+ readonly type: "chat_error";
49
+ constructor(code: string, message: string);
50
+ }
51
+ export declare function createChatClient(options: ChatClientOptions): ChatClient;
52
+ export declare function getClientController(client: ChatClient): ChatClientImplementation;
53
+ declare class ChatClientImplementation implements ChatClient {
54
+ #private;
55
+ id: string;
56
+ readonly agent: Agent | undefined;
57
+ readonly runtime: ToolRuntime;
58
+ constructor(options: ChatClientOptions);
59
+ getMessages: () => readonly Message[];
60
+ getStatus: () => ChatClientStatus;
61
+ getApproval: () => ToolApprovalInterruptDescriptor | undefined;
62
+ getError: () => Error | undefined;
63
+ subscribe: (listener: () => void) => (() => void);
64
+ subscribeEvents: (listener: (event: ProtocolEvent) => void) => (() => void);
65
+ get cancelling(): boolean;
66
+ get busy(): boolean;
67
+ setPageResolver(resolver: (name: string) => boolean): void;
68
+ restore(messages: UIMessage[], conversation: readonly AgentMessage[]): void;
69
+ switchModel(model: AgentModelConfig): Promise<void>;
70
+ sendMessage: (content: string | readonly AgentInputContent[]) => Promise<{
71
+ readonly outcome: Extract<NonNullable<import("@ag-ui/core").RunFinishedEvent["outcome"]>, {
72
+ type: "success";
73
+ }>;
74
+ readonly output: string;
75
+ }>;
76
+ send(content: string | readonly AgentInputContent[], userMessage?: UIMessage): Promise<Extract<AgentRunResult, {
77
+ outcome: {
78
+ type: "success";
79
+ };
80
+ }>>;
81
+ respondToApproval: (id: string, response: {
82
+ approved: boolean;
83
+ }) => Promise<void>;
84
+ confirmPage(): Promise<void> | undefined;
85
+ invalidate(message: string): void;
86
+ cancel: () => void;
87
+ dispose: () => void;
88
+ }