@nexface/chat 0.1.1-alpha.1 → 0.1.1-alpha.10
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/THIRD_PARTY_LICENSES.txt +44 -0
- package/dist/assistant-attachments.d.ts +31 -0
- package/dist/assistant-attachments.js +158 -0
- package/dist/assistant-attachments.js.map +1 -0
- package/dist/assistant-components.d.ts +19 -0
- package/dist/assistant-components.js +39 -0
- package/dist/assistant-components.js.map +1 -0
- package/dist/assistant-runtime.d.ts +24 -0
- package/dist/assistant-runtime.js +104 -0
- package/dist/assistant-runtime.js.map +1 -0
- package/dist/attachments.d.ts +3 -1
- package/dist/attachments.js +13 -0
- package/dist/attachments.js.map +1 -1
- package/dist/client.d.ts +89 -0
- package/dist/client.js +620 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js.map +1 -1
- package/dist/default-chat.d.ts +2 -1
- package/dist/default-chat.js +85 -115
- package/dist/default-chat.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +27 -0
- package/dist/messages.js +121 -0
- package/dist/messages.js.map +1 -0
- package/dist/page-confirmation.d.ts +2 -1
- package/dist/page-confirmation.js.map +1 -1
- package/dist/protocol-messages.d.ts +9 -0
- package/dist/protocol-messages.js +249 -0
- package/dist/protocol-messages.js.map +1 -0
- package/dist/protocol-response.d.ts +32 -0
- package/dist/protocol-response.js +62 -0
- package/dist/protocol-response.js.map +1 -0
- package/dist/react.d.ts +29 -41
- package/dist/react.js +225 -662
- package/dist/react.js.map +1 -1
- package/dist/storage.d.ts +19 -0
- package/dist/storage.js +111 -0
- package/dist/storage.js.map +1 -0
- package/dist/styles.css +2337 -95
- package/dist/tool-result.d.ts +1 -0
- package/dist/tool-result.js +12 -0
- package/dist/tool-result.js.map +1 -0
- package/dist/types.d.ts +40 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/attachment.aui.d.ts +7 -0
- package/dist/ui/attachment.aui.js +93 -0
- package/dist/ui/attachment.aui.js.map +1 -0
- package/dist/ui/avatar.d.ts +11 -0
- package/dist/ui/avatar.js +24 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/button.d.ts +13 -0
- package/dist/ui/button.js +38 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/dialog.d.ts +17 -0
- package/dist/ui/dialog.js +43 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/dropdown-menu.d.ts +25 -0
- package/dist/ui/dropdown-menu.js +60 -0
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +9 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/markdown-text.d.ts +7 -0
- package/dist/ui/markdown-text.js +73 -0
- package/dist/ui/markdown-text.js.map +1 -0
- package/dist/ui/skeleton.d.ts +2 -0
- package/dist/ui/skeleton.js +8 -0
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/ui/surface.d.ts +4 -0
- package/dist/ui/surface.js +53 -0
- package/dist/ui/surface.js.map +1 -0
- package/dist/ui/thread-list.aui.d.ts +9 -0
- package/dist/ui/thread-list.aui.js +19 -0
- package/dist/ui/thread-list.aui.js.map +1 -0
- package/dist/ui/thread.aui.d.ts +29 -0
- package/dist/ui/thread.aui.js +25 -0
- package/dist/ui/thread.aui.js.map +1 -0
- package/dist/ui/tooltip-icon-button.d.ts +7 -0
- package/dist/ui/tooltip-icon-button.js +12 -0
- package/dist/ui/tooltip-icon-button.js.map +1 -0
- package/dist/ui/tooltip.d.ts +7 -0
- package/dist/ui/tooltip.js +23 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/ui/use-attachment-src.d.ts +1 -0
- package/dist/ui/use-attachment-src.js +28 -0
- package/dist/ui/use-attachment-src.js.map +1 -0
- package/dist/ui/use-copy-to-clipboard.d.ts +7 -0
- package/dist/ui/use-copy-to-clipboard.js +16 -0
- package/dist/ui/use-copy-to-clipboard.js.map +1 -0
- package/dist/ui/utils.d.ts +2 -0
- package/dist/ui/utils.js +8 -0
- package/dist/ui/utils.js.map +1 -0
- package/package.json +25 -12
- package/dist/operation-surface.d.ts +0 -7
- package/dist/operation-surface.js +0 -79
- package/dist/operation-surface.js.map +0 -1
- package/dist/operation-types.d.ts +0 -17
- package/dist/operation-types.js +0 -2
- package/dist/operation-types.js.map +0 -1
- package/dist/operation-view.d.ts +0 -13
- package/dist/operation-view.js +0 -367
- package/dist/operation-view.js.map +0 -1
|
@@ -0,0 +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;AAE9G,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,uBAAuB,EAAgB,MAAM,aAAa,CAAC;AAC1I,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,cAAc,EAAsB,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,aAAa,CAAC;AAqC1E,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AACtE,MAAM,eAAe,GAAG,CAAC,KAAY,EAAE,EAAE,CAAE,KAAyD,CAAC,gBAAgB,CAAC,CAAC;AACvH,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;AAChD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;AACjF,MAAM,OAAO,WAAY,SAAQ,KAAK;IAEf;IADZ,IAAI,GAAG,YAAqB,CAAC;IACtC,YA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,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 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: 2,\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 ? 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/config.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type NexfaceModelConfig = (CompletionsOptions & {
|
|
|
12
12
|
}) | (GoogleOptions & {
|
|
13
13
|
protocol: "google-generative-ai";
|
|
14
14
|
});
|
|
15
|
-
export type NexfaceAgentConfig = Pick<Parameters<typeof createAgent>[0], "skills" | "maxSteps" | "maxRetries" | "applicationContext"> & {
|
|
15
|
+
export type NexfaceAgentConfig = Pick<Parameters<typeof createAgent>[0], "tools" | "skills" | "maxSteps" | "maxRetries" | "applicationContext"> & {
|
|
16
16
|
model: NexfaceModelConfig;
|
|
17
17
|
};
|
|
18
18
|
export declare function resolveModelConfig(config: NexfaceModelConfig): import("@nexface/agent").AgentModelConfig;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,IAAI,WAAW,EAAiD,MAAM,mCAAmC,CAAC;AACpI,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAA+C,MAAM,iCAAiC,CAAC;AAC9H,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAA+C,MAAM,mCAAmC,CAAC;AAChI,OAAO,EAAE,iBAAiB,IAAI,MAAM,EAA4C,MAAM,qCAAqC,CAAC;AAa5H,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3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QACf,KAAK,oBAAoB,CAAC,CAAC,CAAC;YAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;YACxC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QACD,KAAK,kBAAkB,CAAC,CAAC,CAAC;YACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;YACxC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,KAAK,oBAAoB,CAAC,CAAC,CAAC;YAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;YACxC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC;YAC5B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import type { createAgent } from \"@nexface/agent\";\nimport { createModelConfig as completions, type ModelConfigOptions as CompletionsOptions } from \"@nexface/agent/openai-completions\";\nimport { createModelConfig as responses, type ModelConfigOptions as ResponsesOptions } from \"@nexface/agent/openai-responses\";\nimport { createModelConfig as anthropic, type ModelConfigOptions as AnthropicOptions } from \"@nexface/agent/anthropic-messages\";\nimport { createModelConfig as google, type ModelConfigOptions as GoogleOptions } from \"@nexface/agent/google-generative-ai\";\n\nexport type NexfaceModelConfig =\n | (CompletionsOptions & { protocol?: \"openai-completions\" })\n | (ResponsesOptions & { protocol: \"openai-responses\" })\n | (AnthropicOptions & { protocol: \"anthropic-messages\" })\n | (GoogleOptions & { protocol: \"google-generative-ai\" });\n\nexport type NexfaceAgentConfig = Pick<\n Parameters<typeof createAgent>[0],\n \"tools\" | \"skills\" | \"maxSteps\" | \"maxRetries\" | \"applicationContext\"\n> & { model: NexfaceModelConfig };\n\nexport function resolveModelConfig(config: NexfaceModelConfig) {\n switch (config.protocol) {\n case undefined:\n case \"openai-completions\": {\n const { protocol, ...options } = config;\n return completions(options);\n }\n case \"openai-responses\": {\n const { protocol, ...options } = config;\n return responses(options);\n }\n case \"anthropic-messages\": {\n const { protocol, ...options } = config;\n return anthropic(options);\n }\n case \"google-generative-ai\": {\n const { protocol, ...options } = config;\n return google(options);\n }\n default:\n throw new Error(\"Unsupported Nexface model protocol.\");\n }\n}\n"]}
|
package/dist/default-chat.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { type JSX } from "react";
|
|
1
2
|
import type { ChatProps } from "./types.js";
|
|
2
|
-
export declare function Chat({ title, avatar, welcomeMessage, welcomeDescription, placeholder, layout, side, className, suggestions, attachments, showToolDetails, onFullscreenChange, onRunResult }: ChatProps):
|
|
3
|
+
export declare function Chat({ title, avatar, welcomeMessage, welcomeDescription, open, onOpenChange, placeholder, layout, side, className, style, suggestions, attachments, showToolDetails, onFullscreenChange, onRunResult }: ChatProps): JSX.Element | null;
|
package/dist/default-chat.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ThreadListRoot, ThreadListNew, ThreadListItem } from "./ui/thread-list.aui.js";
|
|
3
|
+
import { DropdownMenuItem } from "./ui/dropdown-menu.js";
|
|
4
|
+
import { Dialog as UiDialog, DialogContent, DialogTitle, DialogDescription, DialogFooter } from "./ui/dialog.js";
|
|
5
|
+
import { Input } from "./ui/input.js";
|
|
6
|
+
import { Thread, ThreadWelcome, ThreadSuggestion, UserMessage, AssistantMessage, editComposerClass } from "./ui/thread.aui.js";
|
|
7
|
+
import { ChatSurface } from "./ui/surface.js";
|
|
8
|
+
import { Button } from "./ui/button.js";
|
|
9
|
+
import { TooltipIconButton } from "./ui/tooltip-icon-button.js";
|
|
10
|
+
import { cn } from "./ui/utils.js";
|
|
11
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { ThreadPrimitive, MessagePrimitive, ThreadListPrimitive } from "@assistant-ui/react";
|
|
13
|
+
import { SessionRuntime } from "./assistant-runtime.js";
|
|
14
|
+
import { AssistantComposer, AttachmentTile, MarkdownText, ToolDetail, HiddenTool } from "./assistant-components.js";
|
|
6
15
|
import { PaperclipIcon as Paperclip } from "@phosphor-icons/react/Paperclip";
|
|
7
|
-
import { SidebarSimpleIcon as Sidebar } from "@phosphor-icons/react/SidebarSimple";
|
|
8
16
|
import { ClockCounterClockwiseIcon as History } from "@phosphor-icons/react/ClockCounterClockwise";
|
|
9
17
|
import { ArrowsOutIcon as Expand } from "@phosphor-icons/react/ArrowsOut";
|
|
10
18
|
import { ArrowsInIcon as Collapse } from "@phosphor-icons/react/ArrowsIn";
|
|
11
19
|
import { ArrowDownIcon as ArrowDown } from "@phosphor-icons/react/ArrowDown";
|
|
12
|
-
import { CopyIcon as Copy } from "@phosphor-icons/react/Copy";
|
|
13
20
|
import { PencilSimpleIcon as Edit } from "@phosphor-icons/react/PencilSimple";
|
|
14
|
-
import { ArrowClockwiseIcon as Retry } from "@phosphor-icons/react/ArrowClockwise";
|
|
15
21
|
import { PlusIcon as Plus } from "@phosphor-icons/react/Plus";
|
|
16
22
|
import { RobotIcon as Robot } from "@phosphor-icons/react/Robot";
|
|
17
23
|
import { XIcon as X } from "@phosphor-icons/react/X";
|
|
18
24
|
import { useChat } from "./react.js";
|
|
19
|
-
import { attachmentAccept, readAttachment } from "./attachments.js";
|
|
20
25
|
const textOf = (message) => message.parts.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
|
|
21
|
-
const empty = () => ({ text: "", files: [], pending: 0, error: "", generation: {} });
|
|
22
26
|
function Icon({ label, children, ...props }) {
|
|
23
|
-
return _jsx(
|
|
27
|
+
return _jsx(TooltipIconButton, { type: "button", "aria-label": label, tooltip: label, ...props, children: children });
|
|
24
28
|
}
|
|
25
29
|
function Resize({ label, width, onResize, side = "left", min, max }) {
|
|
26
30
|
const drag = useRef(null);
|
|
@@ -31,63 +35,60 @@ function Resize({ label, width, onResize, side = "left", min, max }) {
|
|
|
31
35
|
}
|
|
32
36
|
function Message({ message, showToolDetails }) {
|
|
33
37
|
const calls = message.parts.filter((part) => part.type === "tool");
|
|
34
|
-
return _jsxs(_Fragment, { children: [
|
|
35
|
-
: showToolDetails ? _jsxs("details", { className: "nexface-chat__tool", "data-error": part.isError || undefined, children: [_jsxs("summary", { children: ["\u64CD\u4F5C\u8BB0\u5F55 ", _jsx("span", { "aria-hidden": true, children: "\u203A" })] }), _jsx("strong", { children: part.name }), _jsx("small", { children: part.result === undefined ? "等待执行结果" : part.isError ? "未完成" : "已完成" }), _jsxs("div", { children: [_jsx("b", { children: "Input" }), _jsx("pre", { children: part.arguments })] }), part.result !== undefined ? _jsxs("div", { children: [_jsx("b", { children: part.isError ? "Error" : "Output" }), _jsx("pre", { children: part.result })] }) : null] }, part.toolCallId) : null)] });
|
|
38
|
+
return _jsxs(_Fragment, { children: [calls.length > 0 ? _jsx("div", { className: "nexface-chat__tool-summary", role: calls.some((call) => call.isError) ? "alert" : undefined, children: calls.some((call) => call.result === undefined) ? `正在处理 ${calls.length} 个操作` : calls.some((call) => call.isError) ? "部分操作未完成" : `✓ 已完成 ${calls.length} 个操作` }) : null, calls.filter((call) => call.isError && call.errorMessage).map((call) => _jsx("p", { children: call.errorMessage }, call.toolCallId)), _jsx(MessagePrimitive.Parts, { components: { Text: MarkdownText, tools: { Fallback: showToolDetails ? ToolDetail : HiddenTool } } })] });
|
|
36
39
|
}
|
|
37
|
-
export function Chat({ title = "Nexface", avatar, welcomeMessage = "今天想让我帮你做什么?", welcomeDescription, placeholder = "描述你的任务...", layout = "floating", side = "right", className, suggestions = [], attachments = {}, showToolDetails = false, onFullscreenChange, onRunResult }) {
|
|
40
|
+
export function Chat({ title = "Nexface", avatar, welcomeMessage = "今天想让我帮你做什么?", welcomeDescription, open = true, onOpenChange, placeholder = "描述你的任务...", layout = "floating", side = "right", className, style, suggestions = [], attachments = {}, showToolDetails = false, onFullscreenChange, onRunResult }) {
|
|
38
41
|
const chat = useChat();
|
|
39
42
|
const { activeSessionId: sessionId, messages, status, interrupt } = chat;
|
|
40
|
-
const busy = status !== "idle";
|
|
41
|
-
const
|
|
43
|
+
const busy = status !== "idle" && status !== "error";
|
|
44
|
+
const sessionBusy = busy && status !== "waiting";
|
|
42
45
|
const [fullscreen, setFullscreen] = useState(false);
|
|
43
46
|
const changeFullscreen = (next) => {
|
|
44
47
|
setFullscreen(next);
|
|
45
48
|
onFullscreenChange?.(next);
|
|
46
49
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
useLayoutEffect(() => {
|
|
51
|
+
if (!open && fullscreen) {
|
|
52
|
+
setFullscreen(false);
|
|
53
|
+
onFullscreenChange?.(false);
|
|
54
|
+
}
|
|
55
|
+
}, [open, fullscreen, onFullscreenChange]);
|
|
52
56
|
const [sidebar, setSidebar] = useState(false);
|
|
53
57
|
const [width, setWidth] = useState(546);
|
|
54
58
|
const [sidebarWidth, setSidebarWidth] = useState(240);
|
|
55
|
-
const [drafts, setDrafts] = useState({});
|
|
56
|
-
const draftsRef = useRef(drafts);
|
|
57
59
|
const mounted = useRef(true);
|
|
58
|
-
const submitting = useRef(
|
|
60
|
+
const submitting = useRef(undefined);
|
|
61
|
+
const [editing, setEditing] = useState();
|
|
59
62
|
const [notice, setNotice] = useState("");
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
const dialogReturnFocus = useRef(null);
|
|
64
|
+
const panel = useRef(null);
|
|
65
|
+
const [dialog, updateDialog] = useState();
|
|
66
|
+
const [rename, updateRename] = useState();
|
|
67
|
+
const setDialog = (next) => {
|
|
68
|
+
if (next)
|
|
69
|
+
dialogReturnFocus.current = document.activeElement;
|
|
70
|
+
updateDialog(next);
|
|
71
|
+
};
|
|
72
|
+
const setRename = (next) => {
|
|
73
|
+
if (next && !rename)
|
|
74
|
+
dialogReturnFocus.current = document.activeElement;
|
|
75
|
+
updateRename(next);
|
|
73
76
|
};
|
|
77
|
+
const backgroundInert = Boolean(dialog || rename);
|
|
78
|
+
const setBackgroundInert = useCallback((element) => {
|
|
79
|
+
if (element)
|
|
80
|
+
element.inert = backgroundInert;
|
|
81
|
+
}, [backgroundInert]);
|
|
82
|
+
const byId = useMemo(() => new Map(messages.map((message) => [message.id, message])), [messages]);
|
|
83
|
+
const visited = useRef(new Set());
|
|
84
|
+
visited.current.add(sessionId);
|
|
85
|
+
const latestUser = [...messages].reverse().find((message) => message.role === "user");
|
|
74
86
|
useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []);
|
|
75
|
-
const sessionIds = chat.sessions.map((session) => session.id).join(",");
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const ids = new Set(sessionIds.split(","));
|
|
78
|
-
const next = Object.fromEntries(Object.entries(draftsRef.current).filter(([id]) => ids.has(id)));
|
|
79
|
-
draftsRef.current = next;
|
|
80
|
-
setDrafts(next);
|
|
81
|
-
}, [sessionIds]);
|
|
82
87
|
useEffect(() => { if (chat.completed && chat.consumeCompletion(chat.completed.id))
|
|
83
88
|
onRunResult?.(chat.completed.result); }, [chat.completed, chat.consumeCompletion, onRunResult]);
|
|
84
|
-
|
|
85
|
-
useEffect(() => { if (
|
|
86
|
-
|
|
87
|
-
useEffect(() => { if (textarea.current) {
|
|
88
|
-
textarea.current.style.height = "auto";
|
|
89
|
-
textarea.current.style.height = `${Math.min(180, textarea.current.scrollHeight)}px`;
|
|
90
|
-
} }, [draft.text, open]);
|
|
89
|
+
useLayoutEffect(() => { setNotice(""); setDialog(undefined); setRename(undefined); setEditing(undefined); }, [sessionId]);
|
|
90
|
+
useEffect(() => { if (editing && !messages.some((message) => message.id === editing.id))
|
|
91
|
+
setEditing(undefined); }, [messages, editing]);
|
|
91
92
|
const safe = (action) => { try {
|
|
92
93
|
action();
|
|
93
94
|
}
|
|
@@ -95,86 +96,55 @@ export function Chat({ title = "Nexface", avatar, welcomeMessage = "今天想让
|
|
|
95
96
|
setNotice(error instanceof Error ? error.message : String(error));
|
|
96
97
|
} };
|
|
97
98
|
const execute = async (text, files = [], revisionOf) => {
|
|
98
|
-
if (
|
|
99
|
+
if (sessionBusy || (submitting.current && status !== "waiting") || (!text.trim() && !files.length))
|
|
99
100
|
return;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
followBottom.current = true;
|
|
101
|
+
const submission = Symbol();
|
|
102
|
+
submitting.current = submission;
|
|
103
103
|
try {
|
|
104
104
|
await chat.sendMessage(text, files, revisionOf);
|
|
105
|
+
if (revisionOf)
|
|
106
|
+
setEditing(undefined);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (revisionOf && mounted.current)
|
|
110
|
+
setNotice(error instanceof Error ? error.message : String(error));
|
|
105
111
|
}
|
|
106
|
-
catch { /* Provider retains the failed message and exposes retry. */ }
|
|
107
112
|
finally {
|
|
108
|
-
submitting.current
|
|
113
|
+
if (submitting.current === submission)
|
|
114
|
+
submitting.current = undefined;
|
|
109
115
|
}
|
|
110
116
|
};
|
|
111
117
|
const submit = (text, files, revisionOf) => {
|
|
112
118
|
const action = () => void execute(text, files, revisionOf);
|
|
113
|
-
const
|
|
119
|
+
const lastUserIndex = messages.findIndex((message) => message.id === revisionOf);
|
|
120
|
+
const hasOperations = messages.slice(lastUserIndex + 1).some((message) => message.parts.some((part) => part.type === "tool" && part.result !== undefined));
|
|
114
121
|
if (revisionOf && hasOperations)
|
|
115
|
-
setDialog({ title: "
|
|
122
|
+
setDialog({ title: "保存并重新发送?", description: "修改后将重新生成回答。此前已执行的业务操作不会撤销,重新发送可能重复执行。", action });
|
|
116
123
|
else
|
|
117
124
|
action();
|
|
118
125
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const current = draftsRef.current[id] ?? empty();
|
|
128
|
-
if (current.files.length + current.pending + files.length > (attachments.maxCount ?? 3)) {
|
|
129
|
-
update(id, (value) => ({ ...value, error: "附件数量超出限制。" }));
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
update(id, (value) => ({ ...value, pending: value.pending + files.length, error: "" }));
|
|
133
|
-
const generation = draftsRef.current[id].generation;
|
|
134
|
-
const outcomes = await Promise.allSettled(files.map((file) => readAttachment(file, attachments)));
|
|
135
|
-
if (!mounted.current || draftsRef.current[id]?.generation !== generation)
|
|
136
|
-
return;
|
|
137
|
-
update(id, (value) => ({ ...value, pending: Math.max(0, value.pending - files.length),
|
|
138
|
-
files: [...value.files, ...outcomes.flatMap((outcome) => outcome.status === "fulfilled" ? [outcome.value] : [])],
|
|
139
|
-
error: outcomes.flatMap((outcome) => outcome.status === "rejected" ? [String(outcome.reason.message ?? outcome.reason)] : []).join(";"),
|
|
140
|
-
}));
|
|
141
|
-
};
|
|
142
|
-
return _jsx("div", { className: `nexface-chat${className ? ` ${className}` : ""}`, "data-layout": layout, "data-side": side, "data-open": open || undefined, "data-fullscreen": fullscreen && open || undefined, "data-nexface-ignore": true, style: { "--nexface-chat-panel-width": `${width}px`, "--nexface-chat-sidebar-width": `${sidebarWidth}px` }, children: open ? _jsxs("section", { className: "nexface-chat__panel", "aria-label": `${title} chat`, children: [layout === "docked" && !fullscreen ? _jsx(Resize, { label: "\u8C03\u6574\u804A\u5929\u5BBD\u5EA6", width: width, onResize: setWidth, side: side, min: 320, max: 960 }) : null, _jsxs("header", { className: "nexface-chat__header", inert: Boolean(dialog || rename), children: [_jsxs("div", { className: "nexface-chat__brand", children: [_jsx("span", { className: "nexface-chat__avatar", children: avatar ? _jsx("img", { src: avatar, alt: "" }) : _jsx(Robot, { size: 24 }) }), _jsx("strong", { children: title }), _jsx("span", { className: "nexface-chat__muted", children: interrupt ? "等待确认" : busy ? "Agent 正在运行" : "已就绪" })] }), _jsxs("div", { className: "nexface-chat__header-actions", children: [_jsx(Icon, { label: sidebar ? "收起会话侧边栏" : "展开会话侧边栏", onClick: () => setSidebar(!sidebar), children: _jsx(Sidebar, {}) }), _jsx(Icon, { label: "\u67E5\u770B\u4F1A\u8BDD\u5386\u53F2", onClick: () => setSidebar(true), children: _jsx(History, {}) }), _jsx(Icon, { label: "\u65B0\u5EFA\u804A\u5929\u4F1A\u8BDD", disabled: busy, onClick: () => safe(() => chat.createSession()), children: _jsx(Plus, {}) }), _jsx(Icon, { label: fullscreen ? "退出全屏" : "全屏", onClick: () => changeFullscreen(!fullscreen), children: fullscreen ? _jsx(Collapse, {}) : _jsx(Expand, {}) }), _jsx(Icon, { label: "\u5173\u95ED Agent \u5BF9\u8BDD", onClick: close, children: _jsx(X, {}) })] })] }), _jsxs("div", { className: "nexface-chat__body", inert: Boolean(dialog || rename), children: [sidebar ? _jsxs("nav", { className: "nexface-chat__sidebar", "aria-label": "\u4F1A\u8BDD\u5386\u53F2", children: [_jsx(Resize, { label: "\u8C03\u6574\u4F1A\u8BDD\u5386\u53F2\u680F\u5BBD\u5EA6", width: sidebarWidth, onResize: setSidebarWidth, min: 180, max: 400 }), _jsx("button", { disabled: busy, onClick: () => safe(() => chat.createSession()), children: "\uFF0B \u65B0\u5EFA\u4F1A\u8BDD" }), _jsx("small", { children: "\u6700\u8FD1\u4F1A\u8BDD" }), chat.sessions.map((session) => _jsxs("div", { className: "nexface-chat__session", "data-active": session.id === sessionId || undefined, children: [_jsx("button", { disabled: busy, onClick: () => safe(() => chat.switchSession(session.id)), children: session.title }), _jsxs("details", { children: [_jsx("summary", { "aria-label": `管理 ${session.title}`, children: "\u00B7\u00B7\u00B7" }), _jsxs("div", { className: "nexface-chat__session-menu", children: [_jsx("button", { onClick: () => setRename({ id: session.id, title: session.title }), children: "\u91CD\u547D\u540D" }), _jsx("button", { className: "nexface-chat__danger", disabled: busy, onClick: () => setDialog({ title: "清空消息?", description: "该会话消息将被清除,业务操作不会回滚。", dangerous: true, action: () => chat.clearSession(session.id) }), children: "\u6E05\u7A7A\u6D88\u606F" }), _jsx("button", { className: "nexface-chat__danger", disabled: busy, onClick: () => setDialog({ title: "删除会话?", description: "聊天记录将被删除,此操作无法撤销。", dangerous: true, action: () => chat.deleteSession(session.id) }), children: "\u5220\u9664\u4F1A\u8BDD" })] })] })] }, session.id)), _jsx("button", { className: "nexface-chat__clear-all nexface-chat__danger", disabled: busy, onClick: () => setDialog({ title: "清空全部历史?", description: "所有聊天记录将被清除,业务操作不会回滚。", dangerous: true, action: chat.clearAllSessions }), children: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2" })] }) : null, _jsxs("div", { className: "nexface-chat__thread", children: [_jsxs("div", { className: "nexface-chat__messages", ref: scroll, role: "log", "aria-live": "polite", onScroll: () => { const el = scroll.current; const bottom = el.scrollHeight - el.scrollTop - el.clientHeight < 64; followBottom.current = bottom; setAway(!bottom); }, children: [!messages.length ? _jsxs("div", { className: "nexface-chat__welcome", children: [_jsx("h2", { children: welcomeMessage }), welcomeDescription ? _jsx("p", { children: welcomeDescription }) : null, _jsx("div", { className: "nexface-chat__suggestions", children: suggestions.map((suggestion) => _jsx("button", { disabled: busy, onClick: () => void execute(suggestion.prompt), children: suggestion.label }, suggestion.prompt)) })] }) : null, messages.map((message) => _jsxs("article", { className: `nexface-chat__message nexface-chat__message--${message.role}`, children: [_jsx("div", { className: "nexface-chat__bubble", "data-state": message.state, children: _jsx(Message, { message: message, showToolDetails: showToolDetails }) }), _jsxs("div", { className: "nexface-chat__message-actions", children: [_jsx(Icon, { label: "\u590D\u5236\u6D88\u606F", onClick: () => { if (!navigator.clipboard) {
|
|
143
|
-
setNotice("复制失败,请手动复制。");
|
|
144
|
-
return;
|
|
145
|
-
} void navigator.clipboard.writeText(textOf(message)).then(() => setNotice("已复制"), () => setNotice("复制失败,请手动复制。")); }, children: _jsx(Copy, {}) }), message.id === latestUser?.id ? _jsx(Icon, { label: "\u7F16\u8F91\u6D88\u606F", disabled: busy, onClick: () => { update(sessionId, () => ({ ...empty(), text: textOf(message), files: message.attachments ?? [], revisionOf: message.id })); textarea.current?.focus(); }, children: _jsx(Edit, {}) }) : null, message.role === "assistant" && message.id === messages.at(-1)?.id && latestUser ? _jsx(Icon, { label: message.state === "error" ? "重试" : "重新生成", disabled: busy, onClick: () => submit(textOf(latestUser), latestUser.attachments ?? [], latestUser.id), children: _jsx(Retry, {}) }) : null] })] }, message.id)), busy ? _jsx("div", { className: "nexface-chat__thinking", "aria-label": "\u6B63\u5728\u601D\u8003", children: "\u2022\u2022\u2022" }) : null, interrupt ? _jsxs("section", { className: "nexface-chat__confirmation", "data-mode": interrupt.mode, children: [_jsx("strong", { children: interrupt.title ?? `确认执行 ${interrupt.toolName}?` }), interrupt.description ? _jsx("p", { children: interrupt.description }) : null, interrupt.mode === "chat" ? _jsxs("div", { children: [_jsx("button", { className: "nexface-chat__primary", onClick: chat.confirmInterrupt, children: interrupt.confirmLabel ?? "确认" }), _jsx("button", { onClick: chat.rejectInterrupt, children: interrupt.rejectLabel ?? "拒绝" })] }) : _jsx("p", { children: "\u8BF7\u5728\u4E1A\u52A1\u9875\u9762\u5B8C\u6210\u786E\u8BA4\u3002" })] }) : null] }), _jsxs("div", { className: "nexface-chat__composer-area", children: [away ? _jsx(Icon, { label: "\u6EDA\u52A8\u5230\u5E95\u90E8", className: "nexface-chat__scroll-bottom", onClick: () => { followBottom.current = true; if (scroll.current)
|
|
146
|
-
scroll.current.scrollTop = scroll.current.scrollHeight; }, children: _jsx(ArrowDown, {}) }) : null, notice ? _jsxs("div", { role: "status", className: "nexface-chat__notice", children: [notice, _jsx("button", { onClick: () => setNotice(""), children: "\u00D7" })] }) : null, _jsxs("form", { className: "nexface-chat__composer", onSubmit: (event) => { event.preventDefault(); if (!draft.pending && !draft.error)
|
|
147
|
-
submit(draft.text, draft.files, draft.revisionOf); }, onDragOver: (event) => { if (attachments !== false)
|
|
148
|
-
event.preventDefault(); }, onDrop: (event) => { if (attachments !== false) {
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
void addFiles(Array.from(event.dataTransfer.files));
|
|
151
|
-
} }, children: [draft.revisionOf ? _jsxs("small", { children: ["\u4FEE\u8BA2\u6700\u540E\u4E00\u6761\u8BF7\u6C42 ", _jsx("button", { type: "button", onClick: () => update(sessionId, () => empty()), children: "\u53D6\u6D88\u7F16\u8F91" })] }) : null, _jsx("div", { className: "nexface-chat__attachments", children: draft.files.map((file) => _jsxs("div", { className: "nexface-chat__attachment", children: [file.preview ? _jsx("img", { src: file.preview, alt: file.name }) : _jsx(Paperclip, {}), _jsx("span", { children: file.name }), _jsx("button", { type: "button", "aria-label": `移除 ${file.name}`, onClick: () => update(sessionId, (value) => ({ ...value, files: value.files.filter((item) => item.id !== file.id) })), children: "\u00D7" })] }, file.id)) }), draft.pending ? _jsx("small", { children: "\u6B63\u5728\u8BFB\u53D6\u9644\u4EF6\u2026" }) : null, draft.error ? _jsxs("div", { role: "alert", children: [draft.error, _jsx("button", { type: "button", onClick: () => update(sessionId, (value) => ({ ...value, error: "" })), children: "\u5173\u95ED" })] }) : null, _jsx("textarea", { "aria-label": "\u8F93\u5165 Agent \u4EFB\u52A1", ref: textarea, rows: 1, value: draft.text, placeholder: placeholder, onChange: (event) => update(sessionId, (value) => ({ ...value, text: event.target.value })), onPaste: (event) => { if (attachments !== false && event.clipboardData.files.length) {
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
void addFiles(Array.from(event.clipboardData.files));
|
|
154
|
-
} }, onKeyDown: (event) => { if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
155
|
-
event.preventDefault();
|
|
156
|
-
event.currentTarget.form?.requestSubmit();
|
|
157
|
-
} } }), _jsxs("div", { className: "nexface-chat__composer-toolbar", children: [attachments !== false ? _jsxs(_Fragment, { children: [_jsx("input", { ref: inputFile, type: "file", multiple: true, accept: attachments.accept ?? attachmentAccept, hidden: true, onChange: (event) => { void addFiles(Array.from(event.target.files ?? [])); event.target.value = ""; } }), _jsx(Icon, { label: "\u6DFB\u52A0\u9644\u4EF6", onClick: () => inputFile.current?.click(), children: _jsx(Paperclip, {}) })] }) : null, _jsx("span", {}), busy || interrupt ? _jsx(Icon, { label: "\u53D6\u6D88\u4EFB\u52A1", className: "nexface-chat__primary nexface-chat__send", disabled: status === "cancelling", onClick: chat.cancel, children: _jsx("span", { className: "nexface-chat__stop" }) }) : null, !busy ? _jsx("button", { type: "submit", "aria-label": "\u53D1\u9001\u4EFB\u52A1", className: "nexface-chat__primary nexface-chat__send", disabled: (!draft.text.trim() && !draft.files.length) || draft.pending > 0 || Boolean(draft.error), children: _jsx(Send, { weight: "fill" }) }) : null] })] })] })] })] }), dialog || rename ? _jsx("div", { className: "nexface-chat__backdrop", children: _jsxs("section", { role: "dialog", "aria-modal": "true", "aria-label": dialog?.title ?? "重命名会话", className: "nexface-chat__dialog", onKeyDown: (event) => {
|
|
158
|
-
if (event.key === "Escape") {
|
|
126
|
+
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 || Boolean(editing), active: session.id === sessionId, children: (binding) => open ? _jsx(ChatSurface, { className: `nexface-chat${className ? ` ${className}` : ""}`, "data-layout": layout, "data-side": side, "data-open": open || undefined, "data-fullscreen": fullscreen && open || undefined, "data-nexface-ignore": true, style: { "--nexface-chat-panel-width": `${width}px`, "--nexface-chat-sidebar-width": `${sidebarWidth}px`, ...style, ...(fullscreen ? { border: 0, borderRadius: 0 } : {}) }, children: _jsxs("section", { ref: panel, className: "nexface-chat__panel", "aria-label": `${title} chat`, children: [layout === "docked" && !fullscreen ? _jsx(Resize, { label: "\u8C03\u6574\u804A\u5929\u5BBD\u5EA6", width: width, onResize: setWidth, side: side, min: 320, max: 960 }) : null, _jsxs("header", { className: "nexface-chat__header", ref: setBackgroundInert, children: [_jsxs("div", { className: "nexface-chat__brand", children: [_jsx("span", { className: "nexface-chat__avatar", children: avatar ? _jsx("img", { src: avatar, alt: "" }) : _jsx(Robot, { size: 24 }) }), _jsx("strong", { children: title }), _jsx("span", { className: "nexface-chat__muted", children: interrupt ? "等待确认" : busy ? "Agent 正在运行" : "已就绪" })] }), _jsxs("div", { className: "nexface-chat__header-actions", children: [_jsx(Icon, { label: sidebar ? "收起会话历史" : "查看会话历史", "aria-expanded": sidebar, onClick: () => setSidebar((value) => !value), children: _jsx(History, {}) }), _jsx(Icon, { label: "\u65B0\u5EFA\u804A\u5929\u4F1A\u8BDD", disabled: sessionBusy || binding.sending, onClick: () => safe(() => chat.createSession()), children: _jsx(Plus, {}) }), _jsx(Icon, { 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] })] }), _jsxs("div", { className: "nexface-chat__body", ref: setBackgroundInert, children: [sidebar ? _jsxs("nav", { className: "nexface-chat__sidebar", "aria-label": "\u4F1A\u8BDD\u5386\u53F2", children: [_jsx(Resize, { label: "\u8C03\u6574\u4F1A\u8BDD\u5386\u53F2\u680F\u5BBD\u5EA6", width: sidebarWidth, onResize: setSidebarWidth, min: 180, max: 400 }), _jsx(ThreadListNew, { disabled: sessionBusy || binding.sending, onClick: (event) => { event.preventDefault(); safe(() => chat.createSession()); } }), _jsx("small", { children: "\u6700\u8FD1\u4F1A\u8BDD" }), _jsx(ThreadListRoot, { children: _jsx(ThreadListPrimitive.Items, { children: ({ threadListItem: session }) => _jsx(ThreadListItem, { disabled: sessionBusy || binding.sending, menu: _jsxs(_Fragment, { children: [_jsx(DropdownMenuItem, { onSelect: () => setRename({ id: session.id, title: session.title ?? "" }), 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" })] }) }) }) }), _jsx(Button, { variant: "ghost", className: cn("mt-auto text-destructive"), disabled: busy || binding.sending, onClick: () => setDialog({ title: "清空全部历史?", description: "所有聊天记录将被清除,业务操作不会回滚。", dangerous: true, action: chat.clearAllSessions }), children: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2" })] }) : null, _jsxs(Thread, { empty: !messages.length, welcome: _jsx(ThreadWelcome, { title: welcomeMessage, description: welcomeDescription, suggestions: suggestions.map((suggestion) => _jsx(ThreadSuggestion, { disabled: busy || binding.sending, onClick: () => void execute(suggestion.prompt), children: suggestion.label }, suggestion.prompt)) }), footer: _jsxs(_Fragment, { children: [" ", _jsx(ThreadPrimitive.ScrollToBottom, { "aria-label": "\u6EDA\u52A8\u5230\u5E95\u90E8", className: cn("aui-thread-scroll-to-bottom border bg-background absolute -top-12 z-10 self-center rounded-full p-2 disabled:invisible"), children: _jsx(ArrowDown, {}) }), chat.storageWarning ? _jsx("div", { role: "alert", className: "nexface-chat__notice", children: chat.storageWarning }) : null, notice ? _jsxs("div", { role: "status", className: "nexface-chat__notice", children: [notice, _jsx("button", { onClick: () => setNotice(""), children: "\u00D7" })] }) : null, binding.notice ? _jsxs("div", { role: "alert", className: "nexface-chat__notice", 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 }), children: [_jsx(ThreadPrimitive.Messages, { children: ({ message: rendered }) => {
|
|
127
|
+
const message = byId.get(rendered.id);
|
|
128
|
+
return message ? _jsx(MessagePrimitive.Root, { asChild: true, children: _jsx("article", { className: `nexface-chat__message nexface-chat__message--${message.role}`, children: editing?.id === message.id ? _jsxs("form", { className: cn(editComposerClass), onSubmit: (event) => { event.preventDefault(); if (!busy && !binding.sending)
|
|
129
|
+
submit(editing.text, editing.files, editing.id); }, onKeyDown: (event) => { if (event.key === "Escape" && !event.nativeEvent.isComposing) {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
setEditing(undefined);
|
|
132
|
+
} }, children: [_jsx("textarea", { className: cn("aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none"), autoFocus: true, "aria-label": "\u7F16\u8F91\u6D88\u606F\u5185\u5BB9", value: editing.text, rows: 3, disabled: busy || binding.sending, onChange: (event) => setEditing({ ...editing, text: event.target.value }) }), 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)), _jsxs("div", { className: cn("aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end"), children: [_jsx(Button, { variant: "ghost", size: "sm", type: "button", onClick: () => setEditing(undefined), children: "\u53D6\u6D88" }), _jsx(Button, { size: "sm", type: "submit", disabled: busy || binding.sending || (!editing.text.trim() && !editing.files.length), children: "\u4FDD\u5B58\u5E76\u91CD\u65B0\u53D1\u9001" })] })] }) : _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(Icon, { label: "\u7F16\u8F91\u6D88\u606F", disabled: busy || binding.sending, onClick: () => setEditing({ id: message.id, text: textOf(message), files: message.attachments ?? [] }), children: _jsx(Edit, {}) }) : null, children: _jsx(Message, { message: message, showToolDetails: showToolDetails }) }) : _jsx(AssistantMessage, { children: _jsx(Message, { message: message, showToolDetails: showToolDetails }) }) }) }) }) : null;
|
|
133
|
+
} }), busy && status !== "waiting" ? _jsx("div", { className: "nexface-chat__thinking", "aria-label": "\u6B63\u5728\u601D\u8003", children: "\u2022\u2022\u2022" }) : null, interrupt ? _jsxs("section", { className: "nexface-chat__confirmation", "data-mode": interrupt.mode, children: [_jsx("strong", { children: interrupt.title ?? `确认执行 ${interrupt.toolName}?` }), interrupt.description ? _jsx("p", { children: interrupt.description }) : null, interrupt.mode === "chat" ? _jsxs("div", { children: [_jsx(Button, { onClick: chat.confirmInterrupt, children: interrupt.confirmLabel ?? "确认" }), _jsx(Button, { variant: "outline", onClick: chat.rejectInterrupt, children: interrupt.rejectLabel ?? "拒绝" })] }) : _jsx("p", { children: "\u8BF7\u5728\u4E1A\u52A1\u9875\u9762\u5B8C\u6210\u786E\u8BA4\u3002" })] }) : null] })] }), _jsx(UiDialog, { open: Boolean(dialog || rename), onOpenChange: (next) => { if (!next) {
|
|
159
134
|
setDialog(undefined);
|
|
160
135
|
setRename(undefined);
|
|
161
|
-
}
|
|
162
|
-
if (event.key === "Tab") {
|
|
163
|
-
const controls = Array.from(event.currentTarget.querySelectorAll("button:not(:disabled), input"));
|
|
164
|
-
const first = controls[0];
|
|
165
|
-
const last = controls.at(-1);
|
|
166
|
-
if (event.shiftKey && document.activeElement === first) {
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
last?.focus();
|
|
169
|
-
}
|
|
170
|
-
else if (!event.shiftKey && document.activeElement === last) {
|
|
136
|
+
} }, children: _jsxs(DialogContent, { showCloseButton: false, onCloseAutoFocus: (event) => {
|
|
171
137
|
event.preventDefault();
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
chat.renameSession(rename.id, rename.title);
|
|
138
|
+
queueMicrotask(() => {
|
|
139
|
+
const target = dialogReturnFocus.current;
|
|
140
|
+
if (target?.isConnected && !target.closest("[inert]"))
|
|
141
|
+
target.focus();
|
|
177
142
|
else
|
|
178
|
-
|
|
143
|
+
panel.current?.querySelector("header button:not(:disabled)")?.focus();
|
|
144
|
+
});
|
|
145
|
+
}, children: [_jsx(DialogTitle, { children: dialog?.title ?? "重命名会话" }), _jsx(DialogDescription, { children: dialog?.description ?? "输入新的会话名称。" }), rename ? _jsx(Input, { autoFocus: true, "aria-label": "\u4F1A\u8BDD\u540D\u79F0", maxLength: 80, value: rename.title, onChange: (event) => setRename({ ...rename, title: event.target.value }) }) : null, _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", autoFocus: !rename, onClick: () => { setDialog(undefined); setRename(undefined); }, children: "\u53D6\u6D88" }), _jsx(Button, { variant: dialog?.dangerous ? "destructive" : "default", disabled: busy || Boolean(rename && !rename.title.trim()), onClick: () => { safe(() => { if (rename)
|
|
146
|
+
chat.renameSession(rename.id, rename.title);
|
|
147
|
+
else
|
|
148
|
+
dialog?.action(); }); setDialog(undefined); setRename(undefined); }, children: "\u786E\u5B9A" })] })] }) })] }) }) : null }, session.id)) });
|
|
179
149
|
}
|
|
180
150
|
//# sourceMappingURL=default-chat.js.map
|