@nexface/chat 0.1.7 → 0.1.8
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.d.ts +3 -5
- package/dist/assistant-components.js +29 -17
- package/dist/assistant-components.js.map +1 -1
- package/dist/assistant-runtime.js +5 -3
- package/dist/assistant-runtime.js.map +1 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +99 -10
- package/dist/client.js.map +1 -1
- package/dist/default-chat.js +32 -26
- package/dist/default-chat.js.map +1 -1
- package/dist/errors.d.ts +30 -0
- package/dist/errors.js +61 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +5 -1
- package/dist/messages.js.map +1 -1
- package/dist/protocol-messages.js +30 -10
- package/dist/protocol-messages.js.map +1 -1
- package/dist/react.d.ts +2 -0
- package/dist/react.js +5 -2
- package/dist/react.js.map +1 -1
- package/dist/storage.js +29 -16
- package/dist/storage.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/ui/home-demo/messages.js +5 -2
- package/dist/ui/home-demo/messages.js.map +1 -1
- package/dist/ui/home-demo/trace.d.ts +3 -1
- package/dist/ui/home-demo/trace.js +9 -5
- package/dist/ui/home-demo/trace.js.map +1 -1
- package/package.json +3 -3
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwI,MAAM,gBAAgB,CAAC;AACnL,OAAO,EAAE,mBAAmB,EAAmD,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,sBAAsB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IAAI,CAAC,EAAE,CAAC;gBAChD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;gBAC9E,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/H,IAAI,IAAI,EAAE,CAAC;oBAAC,MAAM,CAAC,cAAc,EAAE,CAAC;oBAAC,MAAM,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAAC,CAAC;YACpF,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBAAC,MAAM,CAAC,cAAc,EAAE,CAAC;gBAAC,IAAI,MAAM,CAAC,IAAI,EAAE;oBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAAC,OAAO;YAAC,CAAC;QACjH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3C,sDAAsD;QACtD,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["import { createAgent, type Agent, type AgentInputContent, type AgentMessage, type AgentRun, type AgentRunResult, type RunAgentInput, type AgentModelConfig } from \"@nexface/agent\";\nimport { decodeAgentResponse, type BrowserToolResult, type AgentBrowserAction } from \"./protocol-response.js\";\nimport { isToolRuntimeError } from \"@nexface/tools\";\nimport type { RuntimeAgentTool, ToolOperation, ToolRuntime } from \"@nexface/tools\";\nimport { getInternalToolRuntime, validateAgentToolInput } from \"@nexface/tools/internal\";\nimport { EventType, EventSchemas, RunAgentInputSchema, TextInputContentSchema, ImageInputContentSchema, type Message } from \"@ag-ui/core\";\nimport { createMessageUpdater, restoreMessages, settleApproval, type ProtocolEvent } from \"./protocol-messages.js\";\nimport { resolveModelConfig, type NexfaceAgentConfig } from \"./config.js\";\nimport { type UIMessage } from \"./messages.js\";\n\nexport type { Message } from \"@ag-ui/core\";\nexport type { ProtocolEvent } from \"./protocol-messages.js\";\nexport type { ToolApprovalInterruptDescriptor } from \"@nexface/agent\";\nimport type { ToolApprovalInterruptDescriptor } from \"@nexface/agent\";\nexport type ChatClientStatus = \"idle\" | \"running\" | \"waiting\" | \"error\";\nexport type RunHandler = (input: RunAgentInput, options: { signal: AbortSignal }) => Promise<Response>;\nexport type ChatClientOptions = { toolRuntime: ToolRuntime } & (\n | { agent: NexfaceAgentConfig; run?: never }\n | { run: RunHandler; agent?: never }\n);\nexport interface ChatClient {\n getMessages(): readonly Message[];\n subscribeEvents(listener: (event: ProtocolEvent) => void): () => void;\n getStatus(): ChatClientStatus;\n getApproval(): ToolApprovalInterruptDescriptor | undefined;\n getError(): Error | undefined;\n /**\n * @experimental State subscriptions may change in future releases.\n * @beta\n */\n subscribe(listener: () => void): () => void;\n sendMessage(content: string | readonly AgentInputContent[]): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>>;\n respondToApproval(id: string, response: { approved: boolean }): Promise<void>;\n cancel(): void;\n dispose(): void;\n}\n\ninterface AgentController {\n conversationBefore(messageId: string): { messages: readonly AgentMessage[]; replay?: unknown };\n restoreConversation(messages: readonly AgentMessage[], replay?: unknown): void;\n settle(id: string, decision: { type: \"cancel\" } | { type: \"invalidate\"; message: string; reason: string }, receipts?: readonly Message[]): boolean;\n authorizePageResponse(response: object): void;\n setPageConfirmationResolver(resolver: (name: string) => boolean): void;\n}\nconst controllerSymbol = Symbol.for(\"@nexface/agent/chat-controller\");\nconst agentController = (agent: Agent) => (agent as Agent & { [controllerSymbol]: AgentController })[controllerSymbol];\nconst id = () => globalThis.crypto.randomUUID();\nconst abortError = () => new DOMException(\"Agent task cancelled.\", \"AbortError\");\nexport class ClientError extends Error {\n readonly type = \"chat_error\" as const;\n constructor(readonly code: string, message: string) { super(message); this.name = \"ChatError\"; }\n}\n\nclass SubscriptionError extends Error {\n constructor(readonly failure: unknown) {\n super(failure instanceof Error ? failure.message : String(failure));\n }\n}\n\nexport function createChatClient(options: ChatClientOptions): ChatClient {\n return new ChatClientImplementation(options);\n}\n\n// This controller is package-private; page confirmation remains Provider-owned.\nexport function getClientController(client: ChatClient): ChatClientImplementation {\n if (!(client instanceof ChatClientImplementation)) throw new TypeError(\"Invalid ChatClient.\");\n return client;\n}\n\nclass ChatClientImplementation implements ChatClient {\n id: string = id();\n readonly agent: Agent | undefined;\n readonly #options: ChatClientOptions;\n #model: AgentModelConfig | undefined;\n readonly runtime: ToolRuntime;\n readonly #runHandler: RunHandler | undefined;\n #messages: Message[] = [];\n #updateMessages = createMessageUpdater();\n #eventListeners = new Set<(event: ProtocolEvent) => void>();\n #status: ChatClientStatus = \"idle\";\n #error: Error | undefined;\n #listeners = new Set<() => void>();\n #controller: AbortController | undefined;\n #activeRun: AgentRun | undefined;\n #operation: ToolOperation | undefined;\n #disposed = false;\n #state: unknown;\n #stateBeforeLastMessage: unknown;\n #resumeBeforeLastMessage: RunAgentInput[\"resume\"];\n #recoveryUnavailable = false;\n #remoteInterruptId: string | undefined;\n #cancelledResume: RunAgentInput[\"resume\"];\n #task: Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> | undefined;\n #replacement: { cancelled: boolean } | undefined;\n #approval: ToolApprovalInterruptDescriptor | undefined;\n #pending: { resolve(approved: boolean): void; reject(error: Error): void; cleanup(): void } | undefined;\n #settled = new Map<string, () => void>();\n #hasPageHook = (_name: string) => false;\n #cancelled = false;\n #executingBrowserCall: string | undefined;\n\n constructor(options: ChatClientOptions, model?: AgentModelConfig) {\n if (!options?.toolRuntime || Boolean(options.agent) === Boolean(options.run)) throw new ClientError(\"INVALID_INPUT\", \"Provide exactly one agent config or run function and a ToolRuntime.\");\n this.#options = options;\n this.#model = options.agent ? model ?? resolveModelConfig(options.agent.model) : undefined;\n this.runtime = options.toolRuntime;\n this.#runHandler = options.run;\n this.agent = options.agent ? createAgent({ ...options.agent, model: this.#model!, toolRuntime: this.runtime }) : undefined;\n }\n getMessages = (): readonly Message[] => this.#messages;\n getStatus = (): ChatClientStatus => this.#status;\n getApproval = (): ToolApprovalInterruptDescriptor | undefined => this.#approval;\n getError = (): Error | undefined => this.#error;\n subscribe = (listener: () => void): (() => void) => { this.#listeners.add(listener); return () => { this.#listeners.delete(listener); }; };\n subscribeEvents = (listener: (event: ProtocolEvent) => void): (() => void) => { this.#eventListeners.add(listener); return () => { this.#eventListeners.delete(listener); }; };\n #publish(): void {\n for (const listener of this.#listeners) {\n try { listener(); }\n catch (error) { this.#listeners.delete(listener); throw new SubscriptionError(error); }\n }\n }\n get cancelling(): boolean { return Boolean(this.#controller?.signal.aborted); }\n get busy(): boolean { return Boolean(this.#controller); }\n setPageResolver(resolver: (name: string) => boolean): void {\n this.#hasPageHook = resolver;\n if (this.agent) agentController(this.agent).setPageConfirmationResolver(resolver);\n }\n restore(messages: UIMessage[], conversation: readonly AgentMessage[]): void {\n if (this.busy || this.#messages.length) throw new Error(\"Restore requires a new Client.\");\n this.#messages = restoreMessages(structuredClone(messages));\n if (this.agent) agentController(this.agent).restoreConversation(conversation);\n }\n recreateBefore(messageId: string): ChatClient {\n if (this.busy || this.#disposed) throw new ClientError(\"CHAT_RUN_ACTIVE\", \"Wait for the active task to finish.\");\n const index = this.#messages.findIndex((message) => message.role === \"user\" && message.id === messageId);\n if (index < 0 || this.#messages.slice(index + 1).some((message) => message.role === \"user\")) throw new ClientError(\"INVALID_INPUT\", \"Only the last user message can be edited.\");\n const client = new ChatClientImplementation(this.#options, this.#model);\n client.id = this.id;\n client.setPageResolver(this.#hasPageHook);\n client.#messages = structuredClone(this.#messages.slice(0, index));\n client.#state = this.#stateBeforeLastMessage;\n client.#cancelledResume = this.#resumeBeforeLastMessage;\n if (this.agent) {\n const retained = agentController(this.agent).conversationBefore(messageId);\n agentController(client.agent!).restoreConversation(retained.messages, retained.replay);\n }\n return client;\n }\n async switchModel(model: AgentModelConfig): Promise<void> {\n if (!this.agent || this.busy) throw new ClientError(\"CHAT_MODEL_SWITCH_BLOCKED\", \"Model switching is unavailable.\");\n await this.agent.switchModel(model);\n this.#model = model;\n this.#publish();\n }\n #event(event: ProtocolEvent): void {\n if (event.type === EventType.RUN_STARTED || event.type === EventType.RUN_FINISHED) event = { ...event, threadId: this.id };\n this.#messages = this.#updateMessages(this.#messages, event);\n if (event.type === EventType.TOOL_CALL_RESULT) { this.#settled.get(event.toolCallId)?.(); this.#settled.delete(event.toolCallId); }\n if (event.type === EventType.CUSTOM && event.name === \"nexface.tool-execution\" && this.#operation) {\n const value = event.value as { status: string; toolCallId: string; progressLabel?: string };\n const runtime = getInternalToolRuntime(this.runtime);\n const current = runtime.getActivitySnapshot().operation?.taskProgress;\n if (value.status === \"running\") runtime.setTaskProgress(this.#operation, { phase: \"tool\", toolCallId: value.toolCallId, ...(value.progressLabel ? { progressLabel: value.progressLabel } : {}) });\n else if (current?.phase === \"tool\" && current.toolCallId === value.toolCallId) runtime.setTaskProgress(this.#operation, { phase: \"processing\" });\n }\n this.#publish();\n for (const listener of this.#eventListeners) {\n try { listener(event); }\n catch (error) { this.#eventListeners.delete(listener); throw new SubscriptionError(error); }\n }\n }\n sendMessage = (content: string | readonly AgentInputContent[]) => this.send(content);\n async send(content: string | readonly AgentInputContent[], userMessage?: UIMessage): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n if (this.#disposed || this.#replacement) throw new ClientError(\"CHAT_RUN_ACTIVE\", \"The Client is disposed or already replacing a task.\");\n try {\n content = typeof content === \"string\" ? content.trim() : content.map((part) =>\n part.type === \"text\" ? TextInputContentSchema.parse(part) : ImageInputContentSchema.parse(part));\n if (!content.length) throw new Error(\"Chat message is required.\");\n } catch (error) { throw new ClientError(\"INVALID_INPUT\", error instanceof Error ? error.message : \"Invalid chat message.\"); }\n if (this.busy) {\n if (this.#status !== \"waiting\" || !this.#pending || !this.#task) throw new ClientError(\"CHAT_RUN_ACTIVE\", \"The Client is already running.\");\n const replacement = { cancelled: false };\n this.#replacement = replacement;\n try {\n let cancellationFailure: unknown;\n try { this.#cancelCurrent(); } catch (error) { cancellationFailure = error; }\n await this.#task.catch(() => undefined);\n if (cancellationFailure) throw cancellationFailure instanceof SubscriptionError ? cancellationFailure.failure : cancellationFailure;\n if (replacement.cancelled || this.#disposed) throw abortError();\n } finally { this.#replacement = undefined; }\n }\n if (this.#recoveryUnavailable) {\n this.#error = new ClientError(\"CHAT_RECOVERY_UNAVAILABLE\", \"The previous task has no complete recovery state. Start a new conversation to continue.\");\n this.#status = \"error\";\n this.#publish();\n throw this.#error;\n }\n const task = this.#send(content, userMessage);\n this.#task = task;\n const clear = () => { if (this.#task === task) this.#task = undefined; };\n void task.then(clear, clear);\n return task;\n }\n async #send(content: string | readonly AgentInputContent[], userMessage?: UIMessage): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n const controller = new AbortController();\n // Claim the Runtime before appending a user message.\n const userId = userMessage?.id ?? id();\n let initialRun: AgentRun | undefined;\n if (this.agent) initialRun = this.agent.run({ messages: [{ id: userId, role: \"user\", content: typeof content === \"string\" ? content : [...content] }] }, { signal: controller.signal });\n else {\n this.#operation = getInternalToolRuntime(this.runtime).beginInternalOperation({ signal: controller.signal, onCancel: () => this.cancel(), taskProgress: { phase: \"processing\" } });\n }\n this.#stateBeforeLastMessage = this.#state;\n this.#resumeBeforeLastMessage = this.#cancelledResume;\n this.#controller = controller;\n this.#cancelled = false;\n this.#executingBrowserCall = undefined;\n this.#status = \"running\";\n this.#error = undefined;\n this.#messages = [...this.#messages, { id: userId, role: \"user\", content: typeof content === \"string\" ? content : [...content], ...(userMessage ? { metadata: { nexface: { restoredParts: userMessage.parts, attachments: userMessage.attachments ?? [], revisionOf: userMessage.revisionOf } } } : {}) }];\n const runtime = getInternalToolRuntime(this.runtime);\n const operationId = runtime.getActivitySnapshot().operation?.id;\n const unsubscribe = runtime.subscribeActivity(() => {\n const operation = runtime.getActivitySnapshot().operation;\n if (operation && operation.id === operationId && operation.status === \"cancelling\" && !controller.signal.aborted) this.cancel();\n });\n let succeeded = false;\n try {\n this.#publish();\n const result = initialRun ? await this.#local(initialRun, controller.signal) : await this.#remote(controller.signal);\n controller.signal.throwIfAborted();\n succeeded = true;\n return result;\n } catch (failure) {\n unsubscribe();\n const failedRun = this.#activeRun ?? initialRun;\n if (failedRun) {\n failedRun.cancel();\n await failedRun.result.catch(() => undefined);\n }\n if (failure instanceof SubscriptionError) failure = failure.failure;\n const record = failure as { name?: unknown; message?: unknown; code?: unknown } | null;\n this.#error = failure instanceof Error ? failure : Object.assign(new Error(typeof record?.message === \"string\" ? record.message : String(failure)), { name: typeof record?.name === \"string\" ? record.name : \"Error\", ...(typeof record?.code === \"string\" ? { code: record.code } : {}) });\n const text = controller.signal.aborted ? \"任务已取消。\" : this.#error.message;\n this.#messages = [\n ...this.#messages.map((message): Message => message.metadata?.nexface?.state === \"running\" ? { ...message, metadata: { ...message.metadata, nexface: { ...message.metadata.nexface, state: \"error\" } } } : message),\n { id: id(), role: \"assistant\", content: text, metadata: { nexface: { state: \"error\" } } },\n ];\n throw this.#error;\n } finally {\n unsubscribe();\n this.#pending?.cleanup(); this.#pending = undefined; this.#approval = undefined;\n if (this.#operation) await this.#operation.end({ outcome: succeeded ? \"completed\" : controller.signal.aborted ? \"cancelled\" : \"failed\" });\n this.#operation = undefined; this.#activeRun = undefined; this.#controller = undefined;\n for (const settle of this.#settled.values()) settle(); this.#settled.clear();\n this.#status = succeeded || controller.signal.aborted ? \"idle\" : \"error\";\n this.#publish();\n }\n }\n async #consume(run: AgentRun): Promise<AgentRunResult> {\n this.#activeRun = run;\n const outcomes = await Promise.allSettled([run.result, (async () => {\n try { for await (const event of run) this.#event(event); }\n catch (error) { run.cancel(); throw error; }\n })()]);\n if (outcomes[1].status === \"rejected\") throw outcomes[1].reason;\n if (outcomes[0].status === \"rejected\") throw outcomes[0].reason;\n return outcomes[0].value;\n }\n async #local(run: AgentRun, signal: AbortSignal): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n for (;;) {\n const result = await this.#consume(run);\n if (result.outcome.type === \"success\") {\n if (typeof result.output !== \"string\") throw new Error(\"Missing completion output.\");\n return { ...result, outcome: result.outcome, output: result.output };\n }\n const interrupt = result.outcome.interrupts[0];\n const extension = interrupt?.metadata?.nexface;\n if (result.outcome.interrupts.length !== 1 || extension?.kind !== \"tool-approval\") throw new Error(\"Unexpected local interrupt.\");\n const approval = extension.approval as ToolApprovalInterruptDescriptor;\n const tool = this.runtime.getTools().find((item) => item.definition.name === approval.toolName);\n if (!tool) throw new ClientError(\"TOOL_CONFIRMATION_INVALIDATED\", \"Tool Binding was removed.\");\n const approved = await this.#wait(approval, tool, signal);\n if (signal.aborted) {\n this.#messages = settleApproval(this.#messages, approval, \"TOOL_CANCELLED\", \"The pending Tool confirmation was cancelled.\", \"interrupt_cancelled\");\n agentController(this.agent!).settle(approval.id, { type: \"cancel\" }, this.#messages);\n }\n signal.throwIfAborted();\n const response = { interruptId: interrupt!.id, status: \"resolved\" as const, payload: { approved } };\n if (approval.mode === \"page\") agentController(this.agent!).authorizePageResponse(response);\n run = this.agent!.run({ resume: [response] }, { signal });\n }\n }\n #wait(approval: ToolApprovalInterruptDescriptor, tool: RuntimeAgentTool, signal: AbortSignal): Promise<boolean> {\n signal.throwIfAborted();\n this.#approval = Object.freeze(approval);\n this.#status = \"waiting\";\n const waiting = new Promise<boolean>((resolve, reject) => {\n const abort = () => reject(signal.reason);\n const removed = () => this.invalidate(\"Tool Binding was removed.\");\n const cleanup = () => { signal.removeEventListener(\"abort\", abort); tool.lifecycleSignal.removeEventListener(\"abort\", removed); };\n this.#pending = { resolve, reject, cleanup };\n signal.addEventListener(\"abort\", abort, { once: true });\n tool.lifecycleSignal.addEventListener(\"abort\", removed, { once: true });\n if (tool.lifecycleSignal.aborted) removed();\n });\n this.#operation?.setWaitingForUser(true);\n this.#publish();\n return waiting;\n }\n async #respond(id: string, approved: boolean, source: \"chat\" | \"page\"): Promise<void> {\n const pending = this.#pending;\n if (!pending || this.#approval?.id !== id || this.#approval.mode !== source || typeof approved !== \"boolean\" || (source === \"page\" && !approved)) throw new ClientError(\"INVALID_INPUT\", \"Confirmation is no longer pending or has the wrong source.\");\n pending.cleanup(); this.#pending = undefined; this.#approval = undefined;\n this.#status = \"running\"; this.#operation?.setWaitingForUser(false);\n pending.resolve(approved); this.#publish();\n }\n respondToApproval = (id: string, response: { approved: boolean }): Promise<void> => this.#respond(id, response.approved, \"chat\");\n confirmPage(): Promise<void> | undefined {\n const approval = this.#approval;\n if (approval?.mode !== \"page\") return;\n const settled = new Promise<void>((resolve) => this.#settled.set(approval.toolCallId, resolve));\n void this.#respond(approval.id, true, \"page\").catch(() => { this.#settled.get(approval.toolCallId)?.(); this.#settled.delete(approval.toolCallId); });\n return settled;\n }\n invalidate(message: string): void {\n const approval = this.#approval;\n if (!approval) return;\n this.#messages = settleApproval(this.#messages, approval, \"TOOL_CONFIRMATION_INVALIDATED\", message, \"binding_changed\");\n if (this.agent) {\n agentController(this.agent).settle(approval.id, { type: \"invalidate\", message, reason: \"binding_changed\" }, this.#messages);\n }\n this.#queueRemoteCancellation();\n const pending = this.#pending;\n pending?.cleanup(); this.#pending = undefined; this.#approval = undefined;\n this.#status = \"running\"; this.#operation?.setWaitingForUser(false);\n pending?.reject(new ClientError(\"TOOL_CONFIRMATION_INVALIDATED\", message));\n this.#publish();\n }\n cancel = (): void => {\n if (this.#replacement) this.#replacement.cancelled = true;\n this.#cancelCurrent();\n };\n #queueRemoteCancellation(): void {\n if (this.#remoteInterruptId) this.#cancelledResume = [{ interruptId: this.#remoteInterruptId, status: \"cancelled\" }];\n }\n #cancelCurrent(): void {\n if (!this.#controller || this.#cancelled) return;\n this.#cancelled = true;\n if (this.#approval) {\n this.#messages = settleApproval(this.#messages, this.#approval, \"TOOL_CANCELLED\", \"The pending Tool confirmation was cancelled.\", \"interrupt_cancelled\");\n if (this.agent) agentController(this.agent).settle(this.#approval.id, { type: \"cancel\" }, this.#messages);\n this.#queueRemoteCancellation();\n }\n const pending = this.#pending;\n pending?.cleanup(); this.#pending = undefined; this.#approval = undefined;\n this.#controller.abort(abortError());\n pending?.reject(this.#controller.signal.reason);\n this.#activeRun?.cancel(); this.#publish();\n }\n dispose = (): void => { if (this.#disposed) return; this.#disposed = true; this.cancel(); this.#listeners.clear(); this.#eventListeners.clear(); };\n\n async #remote(signal: AbortSignal): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n let resume = this.#cancelledResume;\n let inFlight = false;\n let completedBrowserCall = false;\n try {\n for (;;) {\n signal.throwIfAborted();\n const catalog = [...this.runtime.getTools()];\n const contexts = await this.runtime.getContexts({ signal });\n const runId = id();\n const input: RunAgentInput = {\n threadId: this.id, runId, messages: this.#messages, state: this.#state ?? null,\n ...(resume ? { resume } : {}),\n tools: catalog.map(({ definition }) => ({ name: definition.name, description: definition.description, parameters: definition.inputSchema ?? { type: \"object\", properties: {} } })),\n context: contexts.map((context) => ({ description: context.description ?? context.name, value: JSON.stringify(context) })),\n forwardedProps: { nexface: { version: 3,\n toolMetadata: Object.fromEntries(catalog.map(({ definition }) => [definition.name, { ...(definition.effect ? { effect: definition.effect } : {}) }])),\n } },\n };\n RunAgentInputSchema.parse(input);\n inFlight = true;\n completedBrowserCall = false;\n this.#remoteInterruptId = undefined;\n const response = await abortable(this.#runHandler!(input, { signal }), signal);\n if (!response.ok || !response.body) throw new ClientError(\"CHAT_REQUEST_FAILED\", `Agent request failed (${response.status}).`);\n let terminal: AgentRunResult | undefined;\n let terminalEvent: Extract<ProtocolEvent, { type: EventType.RUN_FINISHED }> | undefined;\n let messageSnapshot: Extract<ProtocolEvent, { type: EventType.MESSAGES_SNAPSHOT }> | undefined;\n let stateSnapshot: Extract<ProtocolEvent, { type: EventType.STATE_SNAPSHOT }> | undefined;\n let started = false;\n for await (const event of readEvents(response, signal)) {\n if (event.type === EventType.RUN_ERROR) {\n this.#event(event);\n throw new ClientError(event.code ?? \"CHAT_RUN_ERROR\", event.message);\n }\n if (event.type === EventType.RUN_STARTED || event.type === EventType.RUN_FINISHED) {\n if (event.threadId !== this.id || event.runId !== runId) throw new Error(\"Agent response identity does not match its request.\");\n }\n if (event.type === EventType.RUN_STARTED) {\n if (started) throw new Error(\"Duplicate Agent start event.\");\n started = true;\n }\n if (event.type === EventType.MESSAGES_SNAPSHOT) {\n if (messageSnapshot || stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Invalid recovery snapshot order.\");\n messageSnapshot = event;\n continue;\n }\n if (event.type === EventType.STATE_SNAPSHOT) {\n if (!messageSnapshot || stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Invalid recovery snapshot order.\");\n stateSnapshot = event;\n continue;\n }\n if (event.type === EventType.RUN_FINISHED) {\n if (!started || !event.outcome || !messageSnapshot || !stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Agent terminal is missing its recovery snapshots or outcome.\");\n terminal = { ...event.result, outcome: event.outcome } as AgentRunResult;\n terminalEvent = event;\n break;\n }\n if (messageSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Unexpected event between recovery snapshots and terminal.\");\n this.#event(event);\n }\n if (!terminal || !terminalEvent || !messageSnapshot || !stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Agent stream ended without complete recovery snapshots.\");\n let decoded: ReturnType<typeof decodeAgentResponse>;\n try { decoded = decodeAgentResponse(messageSnapshot.messages, stateSnapshot.snapshot, terminalEvent); }\n catch (error) { throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", error instanceof Error ? error.message : \"Invalid Agent recovery response.\"); }\n const commit = () => {\n // Only a complete terminal commits the matching messages and state.\n this.#state = structuredClone(stateSnapshot.snapshot);\n this.#cancelledResume = undefined;\n inFlight = false;\n this.#event(messageSnapshot);\n this.#event(stateSnapshot);\n this.#event(terminalEvent);\n };\n if (decoded.type === \"success\") {\n commit();\n return decoded.result;\n }\n this.#remoteInterruptId = decoded.interruptId;\n commit();\n const toolResult = await this.#browserAction(decoded.action, catalog, signal);\n completedBrowserCall = true;\n const messageId = id();\n this.#event({ type: EventType.TOOL_CALL_RESULT, messageId, role: \"tool\", toolCallId: toolResult.toolCallId, content: JSON.stringify(toolResult.error ? { error: toolResult.error } : { result: toolResult.result ?? null }) });\n resume = [{ interruptId: decoded.interruptId, status: \"resolved\", payload: { toolResultMessageId: messageId, ...(toolResult.confirmed ? { confirmed: true } : {}) } }];\n }\n } catch (error) {\n const unknown = inFlight || completedBrowserCall || this.#executingBrowserCall !== undefined;\n if (unknown) this.#recoveryUnavailable = true;\n else this.#queueRemoteCancellation();\n const lastUser = this.#messages.reduce((last, message, index) => message.role === \"user\" ? index : last, -1);\n const current = this.#messages.slice(lastUser);\n for (const [index, message] of current.entries()) if (message.role === \"assistant\" && message.toolCalls?.length) {\n const following = current.slice(index + 1);\n const nextBatch = following.findIndex((item) => item.role === \"assistant\" && Boolean(item.toolCalls?.length));\n const receipts = nextBatch < 0 ? following : following.slice(0, nextBatch);\n for (const call of message.toolCalls) {\n if (receipts.some((item) => item.role === \"tool\" && item.toolCallId === call.id)) continue;\n const unknown = inFlight || this.#executingBrowserCall === call.id;\n this.#event({ type: EventType.TOOL_CALL_RESULT, messageId: id(), role: \"tool\", toolCallId: call.id, content: JSON.stringify({ error: { code: unknown ? \"EXECUTION_OUTCOME_UNKNOWN\" : \"TOOL_CANCELLED\", message: unknown ? \"The execution outcome is unknown; this call may have executed.\" : \"Task ended before execution.\" } }) });\n }\n }\n throw error;\n }\n }\n async #browserAction(action: AgentBrowserAction, catalog: RuntimeAgentTool[], signal: AbortSignal): Promise<BrowserToolResult> {\n let confirmed = false;\n this.#executingBrowserCall = undefined;\n try {\n if (!action || typeof action.toolCallId !== \"string\" || !action.definition) throw new Error(\"Invalid browser action.\");\n const tool = catalog.find((item) => JSON.stringify(item.definition) === JSON.stringify(action.definition));\n if (!tool || !this.runtime.getTools().includes(tool)) throw new ClientError(\"TOOL_CONFIRMATION_INVALIDATED\", \"The original Tool Binding is no longer available.\");\n const errors = validateAgentToolInput(tool.definition.inputSchema, action.input);\n if (errors.length) throw new ClientError(\"INVALID_INPUT\", errors.join(\" \"));\n const confirmation = tool.confirmation;\n if (confirmation) {\n if (confirmation.mode === \"page\" && !this.#hasPageHook(tool.definition.name)) throw new ClientError(\"TOOL_CONFIRMATION_UNAVAILABLE\", \"An active usePageConfirmation Hook is required.\");\n confirmed = true;\n const approval = { ...confirmation, type: \"tool-approval\" as const, id: id(), runId: this.id, toolCallId: action.toolCallId, toolName: tool.definition.name, input: structuredClone(action.input) };\n const approved = await this.#wait(approval, tool, signal);\n if (!approved) throw new ClientError(\"TOOL_CONFIRMATION_REJECTED\", \"The user rejected this tool call.\");\n }\n signal.throwIfAborted();\n this.#executingBrowserCall = action.toolCallId;\n const result = await getInternalToolRuntime(this.runtime).executeWithProgress(tool, action.input, { signal, ...(action.progressLabel ? { progressLabel: action.progressLabel } : {}) });\n return { toolCallId: action.toolCallId, result: result ?? null, ...(confirmed ? { confirmed } : {}) };\n } catch (error) {\n if (error instanceof SubscriptionError) throw error;\n signal.throwIfAborted();\n if (error instanceof ClientError && error.code === \"TOOL_CONFIRMATION_INVALIDATED\") throw error;\n return { toolCallId: action.toolCallId, error: { code: error instanceof ClientError || isToolRuntimeError(error) ? error.code : \"TOOL_ERROR\", message: error instanceof Error ? error.message : String(error) }, ...(confirmed ? { confirmed } : {}) };\n } finally {\n if (!signal.aborted) this.#executingBrowserCall = undefined;\n this.#settled.get(action.toolCallId)?.(); this.#settled.delete(action.toolCallId);\n }\n }\n}\n\nasync function abortable<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n signal.throwIfAborted();\n let abort!: () => void;\n try { return await Promise.race([promise, new Promise<never>((_resolve, reject) => { abort = () => reject(signal.reason); signal.addEventListener(\"abort\", abort, { once: true }); })]); }\n finally { signal.removeEventListener(\"abort\", abort); }\n}\n\nasync function* readEvents(response: Response, signal: AbortSignal): AsyncGenerator<ProtocolEvent> {\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n const abort = () => { void reader.cancel(signal.reason).catch(() => undefined); };\n signal.addEventListener(\"abort\", abort, { once: true });\n try {\n for (;;) {\n signal.throwIfAborted();\n const next = await reader.read();\n buffer = (buffer + decoder.decode(next.value, { stream: !next.done })).replace(/\\r\\n/g, \"\\n\");\n let boundary: number;\n while ((boundary = buffer.indexOf(\"\\n\\n\")) >= 0) {\n const packet = buffer.slice(0, boundary); buffer = buffer.slice(boundary + 2);\n const data = packet.split(\"\\n\").filter((line) => line.startsWith(\"data:\")).map((line) => line.slice(5).trimStart()).join(\"\\n\");\n if (data) { signal.throwIfAborted(); yield EventSchemas.parse(JSON.parse(data)); }\n }\n if (next.done) { signal.throwIfAborted(); if (buffer.trim()) throw new Error(\"Truncated SSE event.\"); return; }\n }\n } finally {\n signal.removeEventListener(\"abort\", abort);\n // Transport cleanup must not delay terminal delivery.\n void reader.cancel().catch(() => undefined);\n reader.releaseLock();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwI,MAAM,gBAAgB,CAAC;AACnL,OAAO,EAAE,mBAAmB,EAAmD,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EAAE,kBAA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AAC;QACjH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3C,sDAAsD;QACtD,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["import { createAgent, type Agent, type AgentInputContent, type AgentMessage, type AgentRun, type AgentRunResult, type RunAgentInput, type AgentModelConfig } from \"@nexface/agent\";\nimport { decodeAgentResponse, type BrowserToolResult, type AgentBrowserAction } from \"./protocol-response.js\";\nimport { isToolRuntimeError } from \"@nexface/tools\";\nimport type { RuntimeAgentTool, ToolOperation, ToolRuntime } from \"@nexface/tools\";\nimport { getInternalToolRuntime, validateAgentToolInput } from \"@nexface/tools/internal\";\nimport { EventType, EventSchemas, RunAgentInputSchema, TextInputContentSchema, ImageInputContentSchema, type Message } from \"@ag-ui/core\";\nimport { createMessageUpdater, restoreMessages, settleApproval, projectMessages, type ProtocolEvent } from \"./protocol-messages.js\";\nimport { resolveModelConfig, type NexfaceAgentConfig } from \"./config.js\";\nimport { markErrorPresented, runError, toolError, type NexfaceError, type NexfaceErrorEvent } from \"./errors.js\";\nimport { type UIMessage } from \"./messages.js\";\n\nexport type { Message } from \"@ag-ui/core\";\nexport type { ProtocolEvent } from \"./protocol-messages.js\";\nexport type { ToolApprovalInterruptDescriptor } from \"@nexface/agent\";\nimport type { ToolApprovalInterruptDescriptor } from \"@nexface/agent\";\nexport type ChatClientStatus = \"idle\" | \"running\" | \"waiting\" | \"error\";\nexport type RunHandler = (input: RunAgentInput, options: { signal: AbortSignal }) => Promise<Response>;\nexport type ChatClientOptions = { toolRuntime: ToolRuntime; onError?: (event: NexfaceErrorEvent) => void } & (\n | { agent: NexfaceAgentConfig; run?: never }\n | { run: RunHandler; agent?: never }\n);\nexport interface ChatClient {\n getMessages(): readonly Message[];\n subscribeEvents(listener: (event: ProtocolEvent) => void): () => void;\n getStatus(): ChatClientStatus;\n getApproval(): ToolApprovalInterruptDescriptor | undefined;\n getError(): Error | undefined;\n /**\n * @experimental State subscriptions may change in future releases.\n * @beta\n */\n subscribe(listener: () => void): () => void;\n sendMessage(content: string | readonly AgentInputContent[]): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>>;\n respondToApproval(id: string, response: { approved: boolean }): Promise<void>;\n cancel(): void;\n dispose(): void;\n}\n\ninterface AgentController {\n conversationBefore(messageId: string): { messages: readonly AgentMessage[]; replay?: unknown };\n restoreConversation(messages: readonly AgentMessage[], replay?: unknown): void;\n settle(id: string, decision: { type: \"cancel\" } | { type: \"invalidate\"; message: string; reason: string }, receipts?: readonly Message[]): boolean;\n authorizePageResponse(response: object): void;\n setPageConfirmationResolver(resolver: (name: string) => boolean): void;\n}\nconst controllerSymbol = Symbol.for(\"@nexface/agent/chat-controller\");\nconst agentController = (agent: Agent) => (agent as Agent & { [controllerSymbol]: AgentController })[controllerSymbol];\nconst id = () => globalThis.crypto.randomUUID();\nconst abortError = () => new DOMException(\"Agent task cancelled.\", \"AbortError\");\nexport class ClientError extends Error {\n readonly type = \"chat_error\" as const;\n constructor(readonly code: string, message: string) { super(message); this.name = \"ChatError\"; }\n}\n\nclass SubscriptionError extends Error {\n constructor(readonly failure: unknown) {\n super(failure instanceof Error ? failure.message : String(failure));\n }\n}\n\nexport function createChatClient(options: ChatClientOptions): ChatClient {\n return new ChatClientImplementation(options);\n}\n\n// This controller is package-private; page confirmation remains Provider-owned.\nexport function getClientController(client: ChatClient): ChatClientImplementation {\n if (!(client instanceof ChatClientImplementation)) throw new TypeError(\"Invalid ChatClient.\");\n return client;\n}\n\nclass ChatClientImplementation implements ChatClient {\n id: string = id();\n readonly agent: Agent | undefined;\n readonly #options: ChatClientOptions;\n #model: AgentModelConfig | undefined;\n readonly runtime: ToolRuntime;\n readonly #runHandler: RunHandler | undefined;\n #messages: Message[] = [];\n #updateMessages = createMessageUpdater();\n #eventListeners = new Set<(event: ProtocolEvent) => void>();\n #status: ChatClientStatus = \"idle\";\n #error: Error | undefined;\n #listeners = new Set<() => void>();\n #controller: AbortController | undefined;\n #activeRun: AgentRun | undefined;\n #operation: ToolOperation | undefined;\n #disposed = false;\n #state: unknown;\n #stateBeforeLastMessage: unknown;\n #resumeBeforeLastMessage: RunAgentInput[\"resume\"];\n #recoveryUnavailable = false;\n #remoteInterruptId: string | undefined;\n #cancelledResume: RunAgentInput[\"resume\"];\n #task: Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> | undefined;\n #replacement: { cancelled: boolean } | undefined;\n #approval: ToolApprovalInterruptDescriptor | undefined;\n #pending: { resolve(approved: boolean): void; reject(error: Error): void; cleanup(): void } | undefined;\n #settled = new Map<string, () => void>();\n #hasPageHook = (_name: string) => false;\n #cancelled = false;\n #executingBrowserCall: string | undefined;\n #runId: string | undefined;\n #failureId = \"\";\n #reported = new Set<string>();\n #toolCauses = new Map<string, unknown>();\n #runtimeCauses = new Map<string, unknown[]>();\n\n constructor(options: ChatClientOptions, model?: AgentModelConfig) {\n if (!options?.toolRuntime || Boolean(options.agent) === Boolean(options.run)) throw new ClientError(\"INVALID_INPUT\", \"Provide exactly one agent config or run function and a ToolRuntime.\");\n this.#options = options;\n this.#model = options.agent ? model ?? resolveModelConfig(options.agent.model) : undefined;\n this.runtime = options.toolRuntime;\n this.#runHandler = options.run;\n this.agent = options.agent ? createAgent({ ...options.agent, model: this.#model!, toolRuntime: this.runtime }) : undefined;\n }\n getMessages = (): readonly Message[] => this.#messages;\n getStatus = (): ChatClientStatus => this.#status;\n getApproval = (): ToolApprovalInterruptDescriptor | undefined => this.#approval;\n getError = (): Error | undefined => this.#error;\n assertRecoveryAvailable(): void {\n if (this.#recoveryUnavailable) throw new ClientError(\"CHAT_RECOVERY_UNAVAILABLE\", \"This chat cannot continue. Check the action results, then start a new chat.\");\n }\n subscribe = (listener: () => void): (() => void) => { this.#listeners.add(listener); return () => { this.#listeners.delete(listener); }; };\n subscribeEvents = (listener: (event: ProtocolEvent) => void): (() => void) => { this.#eventListeners.add(listener); return () => { this.#eventListeners.delete(listener); }; };\n #publish(): void {\n for (const listener of this.#listeners) {\n try { listener(); }\n catch (error) { this.#listeners.delete(listener); throw new SubscriptionError(error); }\n }\n }\n get cancelling(): boolean { return Boolean(this.#controller?.signal.aborted); }\n get busy(): boolean { return Boolean(this.#controller); }\n setPageResolver(resolver: (name: string) => boolean): void {\n this.#hasPageHook = resolver;\n if (this.agent) agentController(this.agent).setPageConfirmationResolver(resolver);\n }\n restore(messages: UIMessage[], conversation: readonly AgentMessage[]): void {\n if (this.busy || this.#messages.length) throw new Error(\"Restore requires a new Client.\");\n this.#messages = restoreMessages(structuredClone(messages));\n if (this.agent) agentController(this.agent).restoreConversation(conversation);\n }\n recreateBefore(messageId: string): ChatClient {\n if (this.busy || this.#disposed) throw new ClientError(\"CHAT_RUN_ACTIVE\", \"Wait for the active task to finish.\");\n const index = this.#messages.findIndex((message) => message.role === \"user\" && message.id === messageId);\n if (index < 0 || this.#messages.slice(index + 1).some((message) => message.role === \"user\")) throw new ClientError(\"INVALID_INPUT\", \"Only the last user message can be edited.\");\n const client = new ChatClientImplementation(this.#options, this.#model);\n client.id = this.id;\n client.setPageResolver(this.#hasPageHook);\n client.#messages = structuredClone(this.#messages.slice(0, index));\n client.#state = this.#stateBeforeLastMessage;\n client.#cancelledResume = this.#resumeBeforeLastMessage;\n if (this.agent) {\n const retained = agentController(this.agent).conversationBefore(messageId);\n agentController(client.agent!).restoreConversation(retained.messages, retained.replay);\n }\n return client;\n }\n async switchModel(model: AgentModelConfig): Promise<void> {\n if (!this.agent || this.busy) throw new ClientError(\"CHAT_MODEL_SWITCH_BLOCKED\", \"Model switching is unavailable.\");\n await this.agent.switchModel(model);\n this.#model = model;\n this.#publish();\n }\n #report(error: NexfaceError, cause: unknown): void {\n if (this.#reported.has(error.id)) return;\n this.#reported.add(error.id);\n try {\n const result = this.#options.onError?.({ cause, code: error.code, ...(error.scope === \"tool\" ? { toolCallId: error.toolCallId } : {}), sessionId: this.id, ...(this.#runId ? { runId: this.#runId } : {}) });\n // Also contain rejected promises from async diagnostic callbacks.\n void Promise.resolve(result).catch(() => undefined);\n } catch { /* Diagnostics must not affect task execution. */ }\n }\n #event(event: ProtocolEvent): void {\n if (event.type === EventType.RUN_STARTED) this.#runId = event.runId;\n if (event.type === EventType.TOOL_CALL_RESULT) {\n const owner = [...this.#messages].reverse().find((message) => message.role === \"assistant\" && message.toolCalls?.some((call) => call.id === event.toolCallId));\n const call = owner?.role === \"assistant\" ? owner.toolCalls?.find((call) => call.id === event.toolCallId) : undefined;\n let name = call?.function.name;\n if (name === \"nxf_callAppTool\") try { name = JSON.parse(call!.function.arguments).name; } catch { /* Incomplete calls have no local diagnostic. */ }\n const presentation = toolError(event.messageId, event.toolCallId, event.content, event.metadata?.nexface?.parentErrorId, false, name);\n const localCause = presentation.toolState && name ? this.#runtimeCauses.get(name)?.shift() : undefined;\n if (presentation.toolState === \"cancelled\" && localCause !== undefined) {\n // Cancellation after execution began cannot prove that effects were undone.\n event = { ...event, metadata: { ...event.metadata, nexface: { ...event.metadata?.nexface, executionUnknown: true, parentErrorId: this.#failureId } } };\n }\n if (presentation.error && !presentation.error.parentErrorId) this.#report(presentation.error, this.#toolCauses.get(event.toolCallId) ?? localCause ?? presentation.cause);\n this.#toolCauses.delete(event.toolCallId);\n }\n if (event.type === EventType.RUN_STARTED || event.type === EventType.RUN_FINISHED) event = { ...event, threadId: this.id };\n this.#messages = this.#updateMessages(this.#messages, event);\n if (event.type === EventType.MESSAGES_SNAPSHOT) {\n const receipts = new Map(event.messages.filter((message) => message.role === \"tool\").map((message) => [message.id, message]));\n for (const message of projectMessages(this.#messages)) for (const part of message.parts) {\n if (part.type !== \"tool\" || !part.error || part.error.parentErrorId || this.#reported.has(part.error.id)) continue;\n const receipt = receipts.get(part.error.id);\n if (!receipt) continue;\n const diagnostic = toolError(receipt.id, part.toolCallId, receipt.content, undefined, false, part.name).cause ?? receipt.error;\n this.#report(part.error, this.#toolCauses.get(part.toolCallId) ?? this.#runtimeCauses.get(part.name)?.shift() ?? diagnostic);\n this.#toolCauses.delete(part.toolCallId);\n }\n }\n if (event.type === EventType.TOOL_CALL_RESULT) { this.#settled.get(event.toolCallId)?.(); this.#settled.delete(event.toolCallId); }\n if (event.type === EventType.CUSTOM && event.name === \"nexface.tool-execution\" && this.#operation) {\n const value = event.value as { status: string; toolCallId: string; progressLabel?: string };\n const runtime = getInternalToolRuntime(this.runtime);\n const current = runtime.getActivitySnapshot().operation?.taskProgress;\n if (value.status === \"running\") runtime.setTaskProgress(this.#operation, { phase: \"tool\", toolCallId: value.toolCallId, ...(value.progressLabel ? { progressLabel: value.progressLabel } : {}) });\n else if (current?.phase === \"tool\" && current.toolCallId === value.toolCallId) runtime.setTaskProgress(this.#operation, { phase: \"processing\" });\n }\n this.#publish();\n for (const listener of this.#eventListeners) {\n try { listener(event); }\n catch (error) { this.#eventListeners.delete(listener); throw new SubscriptionError(error); }\n }\n }\n sendMessage = (content: string | readonly AgentInputContent[]) => this.send(content);\n async send(content: string | readonly AgentInputContent[], userMessage?: UIMessage): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n if (this.#disposed || this.#replacement) throw new ClientError(\"CHAT_RUN_ACTIVE\", \"The Client is disposed or already replacing a task.\");\n try {\n content = typeof content === \"string\" ? content.trim() : content.map((part) =>\n part.type === \"text\" ? TextInputContentSchema.parse(part) : ImageInputContentSchema.parse(part));\n if (!content.length) throw new Error(\"Chat message is required.\");\n } catch (error) { throw new ClientError(\"INVALID_INPUT\", error instanceof Error ? error.message : \"Invalid chat message.\"); }\n if (this.busy) {\n if (this.#status !== \"waiting\" || !this.#pending || !this.#task) throw new ClientError(\"CHAT_RUN_ACTIVE\", \"The Client is already running.\");\n const replacement = { cancelled: false };\n this.#replacement = replacement;\n try {\n let cancellationFailure: unknown;\n try { this.#cancelCurrent(); } catch (error) { cancellationFailure = error; }\n await this.#task.catch(() => undefined);\n if (cancellationFailure) throw cancellationFailure instanceof SubscriptionError ? cancellationFailure.failure : cancellationFailure;\n if (replacement.cancelled || this.#disposed) throw abortError();\n } finally { this.#replacement = undefined; }\n }\n if (this.#recoveryUnavailable) {\n this.#error = new ClientError(\"CHAT_RECOVERY_UNAVAILABLE\", \"The previous task has no complete recovery state. Start a new conversation to continue.\");\n this.#status = \"error\";\n this.#publish();\n throw this.#error;\n }\n const task = this.#send(content, userMessage);\n this.#task = task;\n const clear = () => { if (this.#task === task) this.#task = undefined; };\n void task.then(clear, clear);\n return task;\n }\n async #send(content: string | readonly AgentInputContent[], userMessage?: UIMessage): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n const controller = new AbortController();\n // Claim the Runtime before appending a user message.\n const userId = userMessage?.id ?? id();\n let initialRun: AgentRun | undefined;\n if (this.agent) initialRun = this.agent.run({ messages: [{ id: userId, role: \"user\", content: typeof content === \"string\" ? content : [...content] }] }, { signal: controller.signal });\n else {\n this.#operation = getInternalToolRuntime(this.runtime).beginInternalOperation({ signal: controller.signal, onCancel: () => this.cancel(), taskProgress: { phase: \"processing\" } });\n }\n this.#stateBeforeLastMessage = this.#state;\n this.#resumeBeforeLastMessage = this.#cancelledResume;\n this.#controller = controller;\n this.#cancelled = false;\n this.#executingBrowserCall = undefined;\n this.#status = \"running\";\n this.#error = undefined;\n this.#failureId = id();\n this.#runId = undefined;\n // Complete snapshots include older turns; they must not re-emit diagnostics.\n this.#reported = new Set(projectMessages(this.#messages).flatMap((message) => [\n ...(message.error ? [message.error.id] : []),\n ...message.parts.flatMap((part) => part.type === \"tool\" && part.error ? [part.error.id] : []),\n ]));\n this.#messages = [...this.#messages, { id: userId, role: \"user\", content: typeof content === \"string\" ? content : [...content], ...(userMessage ? { metadata: { nexface: { restoredParts: userMessage.parts, attachments: userMessage.attachments ?? [], revisionOf: userMessage.revisionOf } } } : {}) }];\n const runtime = getInternalToolRuntime(this.runtime);\n const operationId = runtime.getActivitySnapshot().operation?.id;\n const unsubscribe = runtime.subscribeActivity(() => {\n const operation = runtime.getActivitySnapshot().operation;\n if (operation && operation.id === operationId && operation.status === \"cancelling\" && !controller.signal.aborted) this.cancel();\n });\n const unsubscribeExecution = this.runtime.on(\"toolexecution\", (event) => {\n if (event.status !== \"error\") return;\n const causes = this.#runtimeCauses.get(event.name) ?? [];\n causes.push(event.error);\n this.#runtimeCauses.set(event.name, causes);\n });\n let succeeded = false;\n try {\n this.#publish();\n const result = initialRun ? await this.#local(initialRun, controller.signal) : await this.#remote(controller.signal);\n controller.signal.throwIfAborted();\n succeeded = true;\n return result;\n } catch (failure) {\n unsubscribe();\n const failedRun = this.#activeRun ?? initialRun;\n if (failedRun) {\n failedRun.cancel();\n await failedRun.result.catch(() => undefined);\n }\n if (failure instanceof SubscriptionError) failure = failure.failure;\n const record = failure as { name?: unknown; message?: unknown; code?: unknown } | null;\n this.#error = failure instanceof Error ? failure : Object.assign(new Error(typeof record?.message === \"string\" ? record.message : String(failure)), { name: typeof record?.name === \"string\" ? record.name : \"Error\", ...(typeof record?.code === \"string\" ? { code: record.code } : {}) });\n const cancelled = controller.signal.aborted;\n const lastUser = this.#messages.reduce((last, message, index) => message.role === \"user\" ? index : last, -1);\n const current = this.#messages.slice(lastUser + 1);\n const unknownTools = projectMessages(current).some((message) => message.parts.some((part) => part.type === \"tool\" && part.toolState === \"unknown\"));\n const error = cancelled ? undefined : runError(this.#failureId, failure, unknownTools);\n this.#messages = this.#messages.map((message, index): Message => index > lastUser && message.metadata?.nexface?.state === \"running\"\n ? { ...message, metadata: { ...message.metadata, nexface: { ...message.metadata.nexface, state: cancelled ? \"cancelled\" : \"error\" } } } : message);\n // A display-only row carries the terminal state without inventing model text.\n this.#messages.push({ id: id(), role: \"assistant\", content: \"\", metadata: { nexface: {\n displayOnly: true, state: cancelled ? \"cancelled\" : \"error\", ...(error ? { error } : {}),\n } } });\n const rejection = this.#error;\n markErrorPresented(rejection);\n if (cancelled) this.#error = undefined;\n else if (error) this.#report(error, failure);\n throw rejection;\n } finally {\n unsubscribeExecution();\n this.#toolCauses.clear();\n this.#runtimeCauses.clear();\n unsubscribe();\n this.#pending?.cleanup(); this.#pending = undefined; this.#approval = undefined;\n if (this.#operation) await this.#operation.end({ outcome: succeeded ? \"completed\" : controller.signal.aborted ? \"cancelled\" : \"failed\" });\n this.#operation = undefined; this.#activeRun = undefined; this.#controller = undefined;\n for (const settle of this.#settled.values()) settle(); this.#settled.clear();\n this.#status = succeeded || controller.signal.aborted ? \"idle\" : \"error\";\n this.#publish();\n }\n }\n async #consume(run: AgentRun): Promise<AgentRunResult> {\n this.#activeRun = run;\n const outcomes = await Promise.allSettled([run.result, (async () => {\n try { for await (const event of run) this.#event(event); }\n catch (error) { run.cancel(); throw error; }\n })()]);\n if (outcomes[1].status === \"rejected\") throw outcomes[1].reason;\n if (outcomes[0].status === \"rejected\") throw outcomes[0].reason;\n return outcomes[0].value;\n }\n async #local(run: AgentRun, signal: AbortSignal): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n for (;;) {\n const result = await this.#consume(run);\n if (result.outcome.type === \"success\") {\n if (typeof result.output !== \"string\") throw new Error(\"Missing completion output.\");\n return { ...result, outcome: result.outcome, output: result.output };\n }\n const interrupt = result.outcome.interrupts[0];\n const extension = interrupt?.metadata?.nexface;\n if (result.outcome.interrupts.length !== 1 || extension?.kind !== \"tool-approval\") throw new Error(\"Unexpected local interrupt.\");\n const approval = extension.approval as ToolApprovalInterruptDescriptor;\n const tool = this.runtime.getTools().find((item) => item.definition.name === approval.toolName);\n if (!tool) throw new ClientError(\"TOOL_CONFIRMATION_INVALIDATED\", \"Tool Binding was removed.\");\n const approved = await this.#wait(approval, tool, signal);\n if (signal.aborted) {\n this.#messages = settleApproval(this.#messages, approval, \"TOOL_CANCELLED\", \"The pending Tool confirmation was cancelled.\", \"interrupt_cancelled\");\n agentController(this.agent!).settle(approval.id, { type: \"cancel\" }, this.#messages);\n }\n signal.throwIfAborted();\n const response = { interruptId: interrupt!.id, status: \"resolved\" as const, payload: { approved } };\n if (approval.mode === \"page\") agentController(this.agent!).authorizePageResponse(response);\n run = this.agent!.run({ resume: [response] }, { signal });\n }\n }\n #wait(approval: ToolApprovalInterruptDescriptor, tool: RuntimeAgentTool, signal: AbortSignal): Promise<boolean> {\n signal.throwIfAborted();\n this.#approval = Object.freeze(approval);\n this.#status = \"waiting\";\n const waiting = new Promise<boolean>((resolve, reject) => {\n const abort = () => reject(signal.reason);\n const removed = () => this.invalidate(\"Tool Binding was removed.\");\n const cleanup = () => { signal.removeEventListener(\"abort\", abort); tool.lifecycleSignal.removeEventListener(\"abort\", removed); };\n this.#pending = { resolve, reject, cleanup };\n signal.addEventListener(\"abort\", abort, { once: true });\n tool.lifecycleSignal.addEventListener(\"abort\", removed, { once: true });\n if (tool.lifecycleSignal.aborted) removed();\n });\n this.#operation?.setWaitingForUser(true);\n this.#publish();\n return waiting;\n }\n async #respond(id: string, approved: boolean, source: \"chat\" | \"page\"): Promise<void> {\n const pending = this.#pending;\n if (!pending || this.#approval?.id !== id || this.#approval.mode !== source || typeof approved !== \"boolean\" || (source === \"page\" && !approved)) throw new ClientError(\"INVALID_INPUT\", \"Confirmation is no longer pending or has the wrong source.\");\n pending.cleanup(); this.#pending = undefined; this.#approval = undefined;\n this.#status = \"running\"; this.#operation?.setWaitingForUser(false);\n pending.resolve(approved); this.#publish();\n }\n respondToApproval = (id: string, response: { approved: boolean }): Promise<void> => this.#respond(id, response.approved, \"chat\");\n confirmPage(): Promise<void> | undefined {\n const approval = this.#approval;\n if (approval?.mode !== \"page\") return;\n const settled = new Promise<void>((resolve) => this.#settled.set(approval.toolCallId, resolve));\n void this.#respond(approval.id, true, \"page\").catch(() => { this.#settled.get(approval.toolCallId)?.(); this.#settled.delete(approval.toolCallId); });\n return settled;\n }\n invalidate(message: string): void {\n const approval = this.#approval;\n if (!approval) return;\n const previousIds = new Set(this.#messages.map((item) => item.id));\n this.#messages = settleApproval(this.#messages, approval, \"TOOL_CONFIRMATION_INVALIDATED\", message, \"binding_changed\")\n .map((item) => previousIds.has(item.id) ? item : { ...item, metadata: { ...item.metadata, nexface: { ...item.metadata?.nexface, parentErrorId: this.#failureId } } });\n if (this.agent) {\n agentController(this.agent).settle(approval.id, { type: \"invalidate\", message, reason: \"binding_changed\" }, this.#messages);\n }\n this.#queueRemoteCancellation();\n const pending = this.#pending;\n pending?.cleanup(); this.#pending = undefined; this.#approval = undefined;\n this.#status = \"running\"; this.#operation?.setWaitingForUser(false);\n pending?.reject(new ClientError(\"TOOL_CONFIRMATION_INVALIDATED\", message));\n this.#publish();\n }\n cancel = (): void => {\n if (this.#replacement) this.#replacement.cancelled = true;\n this.#cancelCurrent();\n };\n #queueRemoteCancellation(): void {\n if (this.#remoteInterruptId) this.#cancelledResume = [{ interruptId: this.#remoteInterruptId, status: \"cancelled\" }];\n }\n #cancelCurrent(): void {\n if (!this.#controller || this.#cancelled) return;\n this.#cancelled = true;\n if (this.#approval) {\n this.#messages = settleApproval(this.#messages, this.#approval, \"TOOL_CANCELLED\", \"The pending Tool confirmation was cancelled.\", \"interrupt_cancelled\");\n if (this.agent) agentController(this.agent).settle(this.#approval.id, { type: \"cancel\" }, this.#messages);\n this.#queueRemoteCancellation();\n }\n const pending = this.#pending;\n pending?.cleanup(); this.#pending = undefined; this.#approval = undefined;\n this.#controller.abort(abortError());\n pending?.reject(this.#controller.signal.reason);\n this.#activeRun?.cancel(); this.#publish();\n }\n dispose = (): void => { if (this.#disposed) return; this.#disposed = true; this.cancel(); this.#listeners.clear(); this.#eventListeners.clear(); };\n\n async #remote(signal: AbortSignal): Promise<Extract<AgentRunResult, { outcome: { type: \"success\" } }>> {\n let resume = this.#cancelledResume;\n let inFlight = false;\n let completedBrowserCall = false;\n try {\n for (;;) {\n signal.throwIfAborted();\n const catalog = [...this.runtime.getTools()];\n const contexts = await this.runtime.getContexts({ signal });\n const runId = id();\n this.#runId = runId;\n const input: RunAgentInput = {\n threadId: this.id, runId, messages: this.#messages.filter((message) => !message.metadata?.nexface?.displayOnly), state: this.#state ?? null,\n ...(resume ? { resume } : {}),\n tools: catalog.map(({ definition }) => ({ name: definition.name, description: definition.description, parameters: definition.inputSchema ?? { type: \"object\", properties: {} } })),\n context: contexts.map((context) => ({ description: context.description ?? context.name, value: JSON.stringify(context) })),\n forwardedProps: { nexface: { version: 3,\n toolMetadata: Object.fromEntries(catalog.map(({ definition }) => [definition.name, { ...(definition.effect ? { effect: definition.effect } : {}) }])),\n } },\n };\n RunAgentInputSchema.parse(input);\n inFlight = true;\n completedBrowserCall = false;\n this.#remoteInterruptId = undefined;\n const response = await abortable(this.#runHandler!(input, { signal }), signal);\n if (!response.ok || !response.body) throw new ClientError(\"CHAT_REQUEST_FAILED\", `Agent request failed (${response.status}).`);\n let terminal: AgentRunResult | undefined;\n let terminalEvent: Extract<ProtocolEvent, { type: EventType.RUN_FINISHED }> | undefined;\n let messageSnapshot: Extract<ProtocolEvent, { type: EventType.MESSAGES_SNAPSHOT }> | undefined;\n let stateSnapshot: Extract<ProtocolEvent, { type: EventType.STATE_SNAPSHOT }> | undefined;\n let started = false;\n for await (const event of readEvents(response, signal)) {\n if (event.type === EventType.RUN_ERROR) {\n this.#event(event);\n throw new ClientError(event.code ?? \"CHAT_RUN_ERROR\", event.message);\n }\n if (event.type === EventType.RUN_STARTED || event.type === EventType.RUN_FINISHED) {\n if (event.threadId !== this.id || event.runId !== runId) throw new Error(\"Agent response identity does not match its request.\");\n }\n if (event.type === EventType.RUN_STARTED) {\n if (started) throw new Error(\"Duplicate Agent start event.\");\n started = true;\n }\n if (event.type === EventType.MESSAGES_SNAPSHOT) {\n if (messageSnapshot || stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Invalid recovery snapshot order.\");\n messageSnapshot = event;\n continue;\n }\n if (event.type === EventType.STATE_SNAPSHOT) {\n if (!messageSnapshot || stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Invalid recovery snapshot order.\");\n stateSnapshot = event;\n continue;\n }\n if (event.type === EventType.RUN_FINISHED) {\n if (!started || !event.outcome || !messageSnapshot || !stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Agent terminal is missing its recovery snapshots or outcome.\");\n terminal = { ...event.result, outcome: event.outcome } as AgentRunResult;\n terminalEvent = event;\n break;\n }\n if (messageSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Unexpected event between recovery snapshots and terminal.\");\n this.#event(event);\n }\n if (!terminal || !terminalEvent || !messageSnapshot || !stateSnapshot) throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", \"Agent stream ended without complete recovery snapshots.\");\n let decoded: ReturnType<typeof decodeAgentResponse>;\n try { decoded = decodeAgentResponse(messageSnapshot.messages, stateSnapshot.snapshot, terminalEvent); }\n catch (error) { throw new ClientError(\"CHAT_STREAM_INCOMPLETE\", error instanceof Error ? error.message : \"Invalid Agent recovery response.\"); }\n const commit = () => {\n // Only a complete terminal commits the matching messages and state.\n this.#state = structuredClone(stateSnapshot.snapshot);\n this.#cancelledResume = undefined;\n inFlight = false;\n this.#event(messageSnapshot);\n this.#event(stateSnapshot);\n this.#event(terminalEvent);\n };\n if (decoded.type === \"success\") {\n commit();\n return decoded.result;\n }\n this.#remoteInterruptId = decoded.interruptId;\n commit();\n const toolResult = await this.#browserAction(decoded.action, catalog, signal);\n completedBrowserCall = true;\n const messageId = id();\n this.#event({ type: EventType.TOOL_CALL_RESULT, messageId, role: \"tool\", toolCallId: toolResult.toolCallId, content: JSON.stringify(toolResult.error ? { error: toolResult.error } : { result: toolResult.result ?? null }) });\n resume = [{ interruptId: decoded.interruptId, status: \"resolved\", payload: { toolResultMessageId: messageId, ...(toolResult.confirmed ? { confirmed: true } : {}) } }];\n }\n } catch (error) {\n const unknown = inFlight || completedBrowserCall || this.#executingBrowserCall !== undefined;\n if (unknown) this.#recoveryUnavailable = true;\n else this.#queueRemoteCancellation();\n const lastUser = this.#messages.reduce((last, message, index) => message.role === \"user\" ? index : last, -1);\n const current = this.#messages.slice(lastUser);\n for (const [index, message] of current.entries()) if (message.role === \"assistant\" && message.toolCalls?.length) {\n const following = current.slice(index + 1);\n const nextBatch = following.findIndex((item) => item.role === \"assistant\" && Boolean(item.toolCalls?.length));\n const receipts = nextBatch < 0 ? following : following.slice(0, nextBatch);\n for (const call of message.toolCalls) {\n if (receipts.some((item) => item.role === \"tool\" && item.toolCallId === call.id)) continue;\n const unknown = inFlight || this.#executingBrowserCall === call.id;\n this.#event({ type: EventType.TOOL_CALL_RESULT, messageId: id(), role: \"tool\", toolCallId: call.id, metadata: { nexface: { parentErrorId: this.#failureId } }, content: JSON.stringify({ error: { code: unknown ? \"EXECUTION_OUTCOME_UNKNOWN\" : \"TOOL_CANCELLED\", message: unknown ? \"The execution outcome is unknown; this call may have executed.\" : \"Task ended before execution.\" } }) });\n }\n }\n throw error;\n }\n }\n async #browserAction(action: AgentBrowserAction, catalog: RuntimeAgentTool[], signal: AbortSignal): Promise<BrowserToolResult> {\n let confirmed = false;\n this.#executingBrowserCall = undefined;\n try {\n if (!action || typeof action.toolCallId !== \"string\" || !action.definition) throw new Error(\"Invalid browser action.\");\n const tool = catalog.find((item) => JSON.stringify(item.definition) === JSON.stringify(action.definition));\n if (!tool || !this.runtime.getTools().includes(tool)) throw new ClientError(\"TOOL_CONFIRMATION_INVALIDATED\", \"The original Tool Binding is no longer available.\");\n const errors = validateAgentToolInput(tool.definition.inputSchema, action.input);\n if (errors.length) throw new ClientError(\"INVALID_INPUT\", errors.join(\" \"));\n const confirmation = tool.confirmation;\n if (confirmation) {\n if (confirmation.mode === \"page\" && !this.#hasPageHook(tool.definition.name)) throw new ClientError(\"TOOL_CONFIRMATION_UNAVAILABLE\", \"An active usePageConfirmation Hook is required.\");\n confirmed = true;\n const approval = { ...confirmation, type: \"tool-approval\" as const, id: id(), runId: this.id, toolCallId: action.toolCallId, toolName: tool.definition.name, input: structuredClone(action.input) };\n const approved = await this.#wait(approval, tool, signal);\n if (!approved) throw new ClientError(\"TOOL_CONFIRMATION_REJECTED\", \"The user rejected this tool call.\");\n }\n signal.throwIfAborted();\n this.#executingBrowserCall = action.toolCallId;\n const result = await getInternalToolRuntime(this.runtime).executeWithProgress(tool, action.input, { signal, ...(action.progressLabel ? { progressLabel: action.progressLabel } : {}) });\n return { toolCallId: action.toolCallId, result: result ?? null, ...(confirmed ? { confirmed } : {}) };\n } catch (error) {\n if (error instanceof SubscriptionError) throw error;\n signal.throwIfAborted();\n if (error instanceof ClientError && error.code === \"TOOL_CONFIRMATION_INVALIDATED\") throw error;\n this.#toolCauses.set(action.toolCallId, error);\n return { toolCallId: action.toolCallId, error: { code: error instanceof ClientError || isToolRuntimeError(error) ? error.code : \"TOOL_ERROR\", message: error instanceof Error ? error.message : String(error) }, ...(confirmed ? { confirmed } : {}) };\n } finally {\n if (!signal.aborted) this.#executingBrowserCall = undefined;\n this.#settled.get(action.toolCallId)?.(); this.#settled.delete(action.toolCallId);\n }\n }\n}\n\nasync function abortable<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n signal.throwIfAborted();\n let abort!: () => void;\n try { return await Promise.race([promise, new Promise<never>((_resolve, reject) => { abort = () => reject(signal.reason); signal.addEventListener(\"abort\", abort, { once: true }); })]); }\n finally { signal.removeEventListener(\"abort\", abort); }\n}\n\nasync function* readEvents(response: Response, signal: AbortSignal): AsyncGenerator<ProtocolEvent> {\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n const abort = () => { void reader.cancel(signal.reason).catch(() => undefined); };\n signal.addEventListener(\"abort\", abort, { once: true });\n try {\n for (;;) {\n signal.throwIfAborted();\n const next = await reader.read();\n buffer = (buffer + decoder.decode(next.value, { stream: !next.done })).replace(/\\r\\n/g, \"\\n\");\n let boundary: number;\n while ((boundary = buffer.indexOf(\"\\n\\n\")) >= 0) {\n const packet = buffer.slice(0, boundary); buffer = buffer.slice(boundary + 2);\n const data = packet.split(\"\\n\").filter((line) => line.startsWith(\"data:\")).map((line) => line.slice(5).trimStart()).join(\"\\n\");\n if (data) { signal.throwIfAborted(); yield EventSchemas.parse(JSON.parse(data)); }\n }\n if (next.done) { signal.throwIfAborted(); if (buffer.trim()) throw new Error(\"Truncated SSE event.\"); return; }\n }\n } finally {\n signal.removeEventListener(\"abort\", abort);\n // Transport cleanup must not delay terminal delivery.\n void reader.cancel().catch(() => undefined);\n reader.releaseLock();\n }\n}\n"]}
|
package/dist/default-chat.js
CHANGED
|
@@ -19,6 +19,7 @@ import { SessionRuntime, projectMessages } from "./assistant-runtime.js";
|
|
|
19
19
|
import { AssistantComposer, AttachmentTile, AssistantParts } from "./assistant-components.js";
|
|
20
20
|
import { Maximize2Icon as Expand, Minimize2Icon as Collapse, MoreHorizontalIcon, PanelLeftIcon, PaperclipIcon as Paperclip, PencilIcon as Edit, PlusIcon as Plus, BotIcon as Robot, XIcon as X } from "lucide-react";
|
|
21
21
|
import { useChat } from "./react.js";
|
|
22
|
+
import { sendErrorNotice } from "./errors.js";
|
|
22
23
|
const textOf = (message) => message.parts.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
|
|
23
24
|
const Icon = forwardRef(function Icon({ label, children, className, ...props }, ref) {
|
|
24
25
|
return _jsx("button", { ref: ref, type: "button", "aria-label": label, title: label, className: cn("text-muted-foreground hover:text-foreground rounded-control grid size-7 place-items-center transition-colors [&>svg]:size-4", className), ...props, children: children });
|
|
@@ -121,11 +122,12 @@ export function Chat({ title = "Nexface", avatar, welcomeMessage = "今天想让
|
|
|
121
122
|
return;
|
|
122
123
|
const submission = Symbol();
|
|
123
124
|
submitting.current = submission;
|
|
125
|
+
setNotice("");
|
|
124
126
|
try {
|
|
125
127
|
await chat.sendMessage(text);
|
|
126
128
|
}
|
|
127
129
|
catch (error) {
|
|
128
|
-
setNotice(
|
|
130
|
+
setNotice(sendErrorNotice(error));
|
|
129
131
|
}
|
|
130
132
|
finally {
|
|
131
133
|
if (submitting.current === submission)
|
|
@@ -135,8 +137,9 @@ export function Chat({ title = "Nexface", avatar, welcomeMessage = "今天想让
|
|
|
135
137
|
const editThroughRuntime = (sourceId, text) => new Promise((resolve, reject) => {
|
|
136
138
|
const files = editing?.id === sourceId ? editing.files : messages.find((message) => message.id === sourceId)?.attachments ?? [];
|
|
137
139
|
const perform = () => {
|
|
140
|
+
setNotice("");
|
|
138
141
|
void chat.sendMessage(text, files, sourceId).then(() => { setEditing(undefined); resolve(); }, (error) => {
|
|
139
|
-
setNotice(
|
|
142
|
+
setNotice(sendErrorNotice(error));
|
|
140
143
|
reject(error);
|
|
141
144
|
});
|
|
142
145
|
};
|
|
@@ -147,30 +150,33 @@ export function Chat({ title = "Nexface", avatar, welcomeMessage = "今天想让
|
|
|
147
150
|
else
|
|
148
151
|
perform();
|
|
149
152
|
});
|
|
150
|
-
return _jsx(_Fragment, { children: chat.sessions.filter((session) => visited.current.has(session.id)).map((session) => _jsx(SessionRuntime, { id: session.id, chat: chat, options: attachments, blocked: sessionBusy, active: session.id === sessionId, onEdit: editThroughRuntime, children: (binding) =>
|
|
151
|
-
|
|
153
|
+
return _jsx(_Fragment, { children: chat.sessions.filter((session) => visited.current.has(session.id)).map((session) => _jsx(SessionRuntime, { id: session.id, chat: chat, options: attachments, blocked: sessionBusy, active: session.id === sessionId, onEdit: editThroughRuntime, children: (binding) => {
|
|
154
|
+
const history = sidebarOpen ? (_jsxs("nav", { ref: sidebarNav, onKeyDown: (event) => {
|
|
155
|
+
if (event.key === "Escape" && !event.nativeEvent.isComposing && !event.target.closest('[data-slot="aui_thread-list-item-rename"]')) {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
setSidebar(false);
|
|
158
|
+
}
|
|
159
|
+
}, onClick: (event) => {
|
|
160
|
+
if (event.target.closest('[data-slot="aui_thread-list-item-trigger"], [data-slot="aui_thread-list-new"]'))
|
|
161
|
+
setSidebar(false);
|
|
162
|
+
}, "data-slot": "nexface_session-sidebar", "data-layout": sidebarLayout, className: cn("nexface-chat__session-sidebar absolute inset-y-0 z-5 flex flex-col overflow-auto border-r border-foreground/10 bg-background shadow-lg"), style: sidebarLayout === "overlay" && sidebarWidth !== undefined ? { width: sidebarWidth } : undefined, "aria-label": "\u4F1A\u8BDD\u5386\u53F2", children: [sidebarLayout === "overlay" ? _jsx(Resize, { label: "\u8C03\u6574\u4F1A\u8BDD\u5386\u53F2\u680F\u5BBD\u5EA6", width: sidebarWidth ?? 240, onResize: setSidebarWidth, edge: "right", min: 180, max: 400 }) : null, _jsxs("div", { className: cn("flex h-12 shrink-0 items-center gap-2 border-b border-foreground/10 px-4 md:px-5"), children: [sidebarLayout === "overlay" ? _jsx(Icon, { label: "\u6536\u8D77\u4F1A\u8BDD\u5386\u53F2", "aria-expanded": sidebarOpen, className: cn("size-7 shrink-0"), onClick: () => setSidebar(false), children: _jsx(PanelLeftIcon, { className: cn("size-4") }) }) : null, _jsxs(Avatar, { children: [avatar ? _jsx(AvatarImage, { src: avatar, alt: "" }) : null, _jsx(AvatarFallback, { children: _jsx(Robot, { size: 20 }) })] }), _jsx("strong", { className: cn("min-w-0 flex-1 truncate text-[13px] font-medium"), children: title })] }), _jsxs("div", { className: cn("flex min-h-0 flex-1 flex-col p-3"), children: [_jsx(ThreadListNew, { disabled: sessionBusy || binding.sending, onClick: (event) => { event.preventDefault(); safe(() => chat.createSession()); } }), _jsx(ThreadListSearch, { value: threadSearch, onValueChange: setThreadSearch }), _jsx("small", { className: cn("text-muted-foreground mt-5 mb-1 px-2 text-xs font-medium"), children: "\u6700\u8FD1\u4F1A\u8BDD" }), _jsx(ThreadListRoot, { children: _jsx(ThreadListPrimitive.Items, { children: ({ threadListItem: session }) => (session.title ?? "新会话").toLocaleLowerCase().includes(threadSearch.trim().toLocaleLowerCase()) ? _jsx(ThreadListItem, { disabled: sessionBusy || binding.sending, menu: (beginRename) => _jsxs(_Fragment, { children: [_jsx(DropdownMenuItem, { disabled: sessionBusy || binding.sending, onSelect: beginRename, children: "\u91CD\u547D\u540D" }), _jsx(DropdownMenuItem, { variant: "destructive", disabled: busy || binding.sending, onSelect: () => setDialog({ title: "清空消息?", description: "该会话消息将被清除,业务操作不会回滚。", dangerous: true, action: () => chat.clearSession(session.id) }), children: "\u6E05\u7A7A\u6D88\u606F" }), _jsx(DropdownMenuItem, { variant: "destructive", disabled: busy || binding.sending, onSelect: () => setDialog({ title: "删除会话?", description: "聊天记录将被删除,此操作无法撤销。", dangerous: true, action: () => chat.deleteSession(session.id) }), children: "\u5220\u9664\u4F1A\u8BDD" })] }) }) : null }) }), threadSearch.trim() && !chat.sessions.some((session) => session.title.toLocaleLowerCase().includes(threadSearch.trim().toLocaleLowerCase())) ? _jsx("div", { "data-slot": "aui_thread-list-empty", className: cn("text-muted-foreground px-2.5 py-4 text-sm"), children: "\u672A\u627E\u5230\u4F1A\u8BDD" }) : null] })] })) : null;
|
|
163
|
+
return open ? _jsxs(ChatSurface, { className: `nexface-chat${className ? ` ${className}` : ""}`, "data-layout": layout, "data-side": side, "data-open": open || undefined, "data-fullscreen": fullscreen && open || undefined, "data-session-sidebar-open": sidebarOpen || undefined, "data-nexface-ignore": true, style: { "--nexface-chat-panel-width": `${width}px`, ...style, ...(fullscreen ? { border: 0, borderRadius: 0 } : {}) }, children: [layout === "docked" && !fullscreen ? _jsx(Resize, { label: "\u8C03\u6574\u804A\u5929\u5BBD\u5EA6", width: width, onResize: setWidth, side: side, edge: side === "left" ? "right" : "left", min: 320, max: 960 }) : null, sidebarLayout === "outside" ? history : null, _jsxs("section", { ref: panel, className: cn("nexface-chat__panel relative flex h-full min-h-0 overflow-hidden rounded-[inherit]"), "aria-label": `${title} chat`, children: [sidebarOpen && sidebarLayout === "overlay" ? _jsxs(_Fragment, { children: [_jsx("button", { type: "button", tabIndex: -1, "aria-label": "\u5173\u95ED\u4F1A\u8BDD\u5386\u53F2\u6D6E\u5C42", className: cn("absolute inset-0 z-4 bg-black/10"), onClick: () => setSidebar(false) }), history] }) : null, _jsxs("div", { inert: sidebarOpen && sidebarLayout === "overlay", className: cn("flex min-h-0 min-w-0 flex-1 flex-col"), children: [_jsxs("header", { "data-slot": "nexface_chat_header", className: cn("border-foreground/10 flex h-12 shrink-0 min-w-0 items-center gap-2 border-b px-4 md:px-5"), children: [_jsxs("div", { className: cn("flex min-w-0 flex-1 items-center gap-2 whitespace-nowrap"), children: [sidebarEnabled && (sidebarLayout === "outside" || !sidebarOpen) ? _jsx(Icon, { ref: sidebarTrigger, label: sidebarOpen ? "收起会话历史" : "查看会话历史", "aria-expanded": sidebarOpen, className: cn("size-7 shrink-0"), onClick: () => setSidebar((value) => !value), children: _jsx(PanelLeftIcon, { className: cn("size-4") }) }) : null, _jsx("strong", { className: cn("truncate text-[13px] font-medium"), children: activeTitle })] }), _jsxs("div", { className: cn("-me-1.5 ml-auto flex shrink-0 items-center gap-1.5"), children: [_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Icon, { label: "\u66F4\u591A\u4F1A\u8BDD\u64CD\u4F5C", children: _jsx(MoreHorizontalIcon, {}) }) }), _jsx(DropdownMenuContent, { align: "end", children: _jsx(DropdownMenuItem, { variant: "destructive", disabled: busy || binding.sending, onSelect: () => setDialog({ title: "清空全部历史?", description: "所有聊天记录将被清除,业务操作不会回滚。", dangerous: true, action: chat.clearAllSessions }), children: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2" }) })] }), _jsx(Icon, { label: "\u65B0\u5EFA\u804A\u5929\u4F1A\u8BDD", disabled: sessionBusy || binding.sending, onClick: () => safe(() => chat.createSession()), children: _jsx(Plus, {}) }), _jsx(Icon, { ref: headerFocusButton, label: fullscreen ? "退出全屏" : "全屏", onClick: () => changeFullscreen(!fullscreen), children: fullscreen ? _jsx(Collapse, {}) : _jsx(Expand, {}) }), onOpenChange ? _jsx(Icon, { label: "\u5173\u95ED Agent \u5BF9\u8BDD", onClick: () => onOpenChange(false), children: _jsx(X, {}) }) : null] })] }), _jsx("div", { "data-slot": "nexface_chat_body", className: cn("relative flex min-h-0 flex-1"), children: _jsx(Thread, { empty: !messages.length, welcome: _jsx(Greeting, { title: welcomeMessage, description: welcomeDescription }), suggestions: _jsx(Suggestions, { suggestions: suggestions, disabled: busy || binding.sending, onSend: (prompt) => void execute(prompt) }), footer: _jsxs(_Fragment, { children: [_jsx(FollowUps, { disabled: busy || binding.sending, onSend: (prompt) => { binding.runtime.thread.composer.setText(prompt); void binding.send(); } }), chat.storageWarning ? _jsx("div", { role: "alert", className: cn("text-muted-foreground text-xs"), children: chat.storageWarning }) : null, notice ? _jsxs("div", { role: "status", className: cn("text-muted-foreground text-xs"), children: [notice, _jsx("button", { onClick: () => setNotice(""), children: "\u00D7" })] }) : null, binding.notice ? _jsxs("div", { role: "alert", className: cn("text-muted-foreground text-xs"), children: [binding.notice, _jsx("button", { onClick: () => binding.setNotice(""), children: "\u5173\u95ED" })] }) : null] }), composer: _jsx(AssistantComposer, { binding: binding, options: attachments, placeholder: placeholder, busy: busy || Boolean(interrupt), cancelling: status === "cancelling", cancel: chat.cancel }), renderMessage: ({ message: rendered }) => {
|
|
164
|
+
const message = byId.get(rendered.id);
|
|
165
|
+
return message ? _jsx(_Fragment, { children: editing?.id === message.id ? _jsx(EditComposer, { onKeyDown: (event) => { if (event.key === "Escape" && !event.nativeEvent.isComposing)
|
|
166
|
+
setEditing(undefined); }, inputProps: { "aria-label": "编辑消息内容", value: editing.text, disabled: busy || binding.sending, onChange: (event) => setEditing({ ...editing, text: event.target.value }) }, cancelProps: { type: "button", onClick: () => setEditing(undefined) }, sendProps: { type: "button", disabled: busy || binding.sending || (!editing.text.trim() && !editing.files.length) }, children: editing.files.map((file) => _jsxs("div", { className: cn("bg-muted flex min-w-0 items-center gap-2 rounded-md px-3 py-2 text-sm"), children: [_jsx(Paperclip, { className: cn("size-4 shrink-0") }), _jsx("span", { className: cn("min-w-0 flex-1 truncate"), children: file.name }), _jsx(TooltipIconButton, { tooltip: "\u79FB\u9664\u9644\u4EF6", type: "button", disabled: busy || binding.sending, "aria-label": `移除 ${file.name}`, onClick: () => setEditing({ ...editing, files: editing.files.filter((item) => item.id !== file.id) }), children: _jsx(X, {}) })] }, file.id)) }) : _jsx(_Fragment, { children: message.role === "user" ? _jsx(UserMessage, { attachments: _jsx("div", { className: cn("aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden"), children: _jsx(MessagePrimitive.Attachments, { children: ({ attachment }) => _jsx(AttachmentTile, { savedPreview: message.attachments?.find((file) => file.id === attachment.id)?.preview }) }) }), actions: message.id === latestUser?.id ? _jsx(ActionBarPrimitive.Edit, { asChild: true, children: _jsx("button", { type: "button", "aria-label": "\u7F16\u8F91\u6D88\u606F", className: cn(actionButtonClass), disabled: busy || binding.sending, onClick: () => setEditing({ id: message.id, text: textOf(message), files: message.attachments ?? [] }), children: _jsx(Edit, { className: cn("size-4") }) }) }) : null, children: _jsx(MessagePrimitive.Parts, {}) }) : _jsx(AssistantMessage, { children: _jsx(AssistantParts, { showDetails: showToolDetails, tools: message.parts }) }) }) }) : _jsx(AssistantMessage, { children: _jsx(AssistantParts, { showDetails: showToolDetails }) });
|
|
167
|
+
}, children: interrupt ? _jsxs("section", { "aria-label": interrupt.title ?? `确认执行 ${interrupt.toolName}?`, className: cn("rounded-lg bg-muted p-4"), "data-mode": interrupt.mode, children: [_jsx("strong", { children: interrupt.title ?? `确认执行 ${interrupt.toolName}?` }), interrupt.description ? _jsx("p", { className: cn("mt-1 text-muted-foreground"), children: interrupt.description }) : null, interrupt.mode === "chat" ? _jsxs("div", { className: cn("mt-3 flex gap-2"), children: [_jsx(Button, { onClick: chat.confirmInterrupt, children: interrupt.confirmLabel ?? "确认" }), _jsx(Button, { variant: "outline", onClick: chat.rejectInterrupt, children: interrupt.rejectLabel ?? "拒绝" })] }) : _jsx("p", { className: cn("mt-1 text-muted-foreground"), children: "\u8BF7\u5728\u4E1A\u52A1\u9875\u9762\u5B8C\u6210\u786E\u8BA4\u3002" })] }) : null }) })] }), _jsx(UiDialog, { open: Boolean(dialog), onOpenChange: (next) => { if (!next) {
|
|
168
|
+
dialog?.cancel?.();
|
|
169
|
+
setDialog(undefined);
|
|
170
|
+
} }, children: _jsxs(DialogContent, { showCloseButton: false, onCloseAutoFocus: (event) => {
|
|
152
171
|
event.preventDefault();
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}, children: interrupt ? _jsxs("section", { "aria-label": interrupt.title ?? `确认执行 ${interrupt.toolName}?`, className: cn("rounded-lg bg-muted p-4"), "data-mode": interrupt.mode, children: [_jsx("strong", { children: interrupt.title ?? `确认执行 ${interrupt.toolName}?` }), interrupt.description ? _jsx("p", { className: cn("mt-1 text-muted-foreground"), children: interrupt.description }) : null, interrupt.mode === "chat" ? _jsxs("div", { className: cn("mt-3 flex gap-2"), children: [_jsx(Button, { onClick: chat.confirmInterrupt, children: interrupt.confirmLabel ?? "确认" }), _jsx(Button, { variant: "outline", onClick: chat.rejectInterrupt, children: interrupt.rejectLabel ?? "拒绝" })] }) : _jsx("p", { className: cn("mt-1 text-muted-foreground"), children: "\u8BF7\u5728\u4E1A\u52A1\u9875\u9762\u5B8C\u6210\u786E\u8BA4\u3002" })] }) : null }) })] }), _jsx(UiDialog, { open: Boolean(dialog), onOpenChange: (next) => { if (!next) {
|
|
163
|
-
dialog?.cancel?.();
|
|
164
|
-
setDialog(undefined);
|
|
165
|
-
} }, children: _jsxs(DialogContent, { showCloseButton: false, onCloseAutoFocus: (event) => {
|
|
166
|
-
event.preventDefault();
|
|
167
|
-
queueMicrotask(() => {
|
|
168
|
-
const target = dialogReturnFocus.current;
|
|
169
|
-
if (target?.isConnected && !target.closest("[inert]"))
|
|
170
|
-
target.focus();
|
|
171
|
-
else
|
|
172
|
-
panel.current?.querySelector("header button:not(:disabled)")?.focus();
|
|
173
|
-
});
|
|
174
|
-
}, children: [_jsx(DialogTitle, { children: dialog?.title }), _jsx(DialogDescription, { children: dialog?.description }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", autoFocus: true, onClick: () => { dialog?.cancel?.(); setDialog(undefined); }, children: "\u53D6\u6D88" }), _jsx(Button, { variant: dialog?.dangerous ? "destructive" : "default", disabled: busy, onClick: () => { safe(() => dialog?.action()); setDialog(undefined); }, children: "\u786E\u5B9A" })] })] }) })] }) }) : null }, session.id)) });
|
|
172
|
+
queueMicrotask(() => {
|
|
173
|
+
const target = dialogReturnFocus.current;
|
|
174
|
+
if (target?.isConnected && !target.closest("[inert]"))
|
|
175
|
+
target.focus();
|
|
176
|
+
else
|
|
177
|
+
panel.current?.querySelector("header button:not(:disabled)")?.focus();
|
|
178
|
+
});
|
|
179
|
+
}, children: [_jsx(DialogTitle, { children: dialog?.title }), _jsx(DialogDescription, { children: dialog?.description }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", autoFocus: true, onClick: () => { dialog?.cancel?.(); setDialog(undefined); }, children: "\u53D6\u6D88" }), _jsx(Button, { variant: dialog?.dangerous ? "destructive" : "default", disabled: busy, onClick: () => { safe(() => dialog?.action()); setDialog(undefined); }, children: "\u786E\u5B9A" })] })] }) })] })] }) : null;
|
|
180
|
+
} }, session.id)) });
|
|
175
181
|
}
|
|
176
182
|
//# sourceMappingURL=default-chat.js.map
|