AI-native design editor. Open-source Figma alternative.
Add ACP client support for using external coding agents
Danila Poyarkov30430433c664
diff --git a/bun.lock b/bun.lockindex dbad51bef..9be4e145c 100644--- a/bun.lock+++ b/bun.lock@@ -19,6 +19,7 @@"@tauri-apps/plugin-dialog": "^2.6.0","@tauri-apps/plugin-fs": "^2.4.5","@tauri-apps/plugin-opener": "^2",+ "@tauri-apps/plugin-shell": "^2.3.5","@unhead/vue": "^2.1.10","@vueuse/core": "^14.2.1","ai": "^6.0.105",@@ -1004,6 +1005,8 @@"@tauri-apps/plugin-opener": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-CCcUltXMOfUEArbf3db3kCE7Ggy1ExBEBl51Ko2ODJ6GDYHRp1nSNlQm5uNCFY5k7/ufaK5Ib3Du/Zir19IYQQ=="],+ "@tauri-apps/plugin-shell": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.10.1" } }, "sha512-jewtULhiQ7lI7+owCKAjc8tYLJr92U16bPOeAa472LHJdgaibLP83NcfAF2e+wkEcA53FxKQAZ7byDzs2eeizg=="],+"@tybys/wasm-util": ["@tybys/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg=="],"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.3.9" } }, "sha512-KQ571yULOdWJiMH+RIWIOZ7B2RXQGpL1YQrBtLIV3FqDcCu6FsbFUBwhdKUlCKUpS3PJDsHlJ1QKlpxoVR+xtw=="],diff --git a/desktop/Cargo.toml b/desktop/Cargo.tomlindex 51d706622..225d30200 100644--- a/desktop/Cargo.toml+++ b/desktop/Cargo.toml@@ -25,6 +25,7 @@ serde = { version = "1", features = ["derive"] }serde_json = "1"tauri-plugin-dialog = "2.6.0"tauri-plugin-fs = { version = "2.4.5", features = ["watch"] }+tauri-plugin-shell = "2"zstd = "0.13"zip = { version = "2", default-features = false }font-kit = "0.14.3"diff --git a/desktop/capabilities/default.json b/desktop/capabilities/default.jsonindex bc5841b81..949e62c61 100644--- a/desktop/capabilities/default.json+++ b/desktop/capabilities/default.json@@ -18,6 +18,9 @@"allow": [{ "path": "**" }]},"fs:allow-watch",- "fs:allow-unwatch"+ "fs:allow-unwatch",+ "shell:allow-spawn",+ "shell:allow-stdin-write",+ "shell:allow-kill"]}diff --git a/desktop/src/lib.rs b/desktop/src/lib.rsindex 19abbd8b5..cf860ddf0 100644--- a/desktop/src/lib.rs+++ b/desktop/src/lib.rs@@ -224,6 +224,7 @@ pub fn run() {.plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_fs::init())+ .plugin(tauri_plugin_shell::init()).on_menu_event(|app, event| {#[cfg(debug_assertions)]if event.id().0.as_str() == "dev-tools" {diff --git a/package.json b/package.jsonindex 630bffa33..39fc2a2e1 100644--- a/package.json+++ b/package.json@@ -43,6 +43,7 @@"@tauri-apps/plugin-dialog": "^2.6.0","@tauri-apps/plugin-fs": "^2.4.5","@tauri-apps/plugin-opener": "^2",+ "@tauri-apps/plugin-shell": "^2.3.5","@unhead/vue": "^2.1.10","@vueuse/core": "^14.2.1","ai": "^6.0.105",diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.tsindex 7d8ccdaf8..f820e7b0d 100644--- a/packages/core/src/constants.ts+++ b/packages/core/src/constants.ts@@ -89,6 +89,21 @@ export const TEXT_SELECTION_COLOR = { r: 0.26, g: 0.52, b: 0.96, a: 0.3 }export const TEXT_CARET_COLOR = BLACKexport const TEXT_CARET_WIDTH = 1+export type ACPAgentID = 'claude-code' | 'codex' | 'gemini-cli'++export interface ACPAgentDef {+ id: ACPAgentID+ name: string+ command: string+ args: string[]+}++export const ACP_AGENTS: ACPAgentDef[] = [+ { id: 'claude-code', name: 'Claude Code', command: 'claude', args: ['code', '--acp'] },+ { id: 'codex', name: 'Codex', command: 'codex', args: ['--acp'] },+ { id: 'gemini-cli', name: 'Gemini CLI', command: 'gemini', args: ['--acp'] }+]+export type AIProviderID =| 'openrouter'| 'anthropic'@@ -98,6 +113,7 @@ export type AIProviderID =| 'zai'| 'minimax'| 'anthropic-compatible'+ | `acp:${ACPAgentID}`export interface ModelOption {id: stringdiff --git a/src/ai/acp-transport.ts b/src/ai/acp-transport.tsnew file mode 100644index 000000000..94b66cfb0--- /dev/null+++ b/src/ai/acp-transport.ts@@ -0,0 +1,314 @@+import {+ ClientSideConnection,+ ndJsonStream,+ PROTOCOL_VERSION+} from '@agentclientprotocol/sdk'+import { Command } from '@tauri-apps/plugin-shell'++import type {+ Client,+ Agent,+ SessionNotification,+ RequestPermissionRequest,+ RequestPermissionResponse,+ SessionUpdate+} from '@agentclientprotocol/sdk'+import type { ChatTransport, UIMessage, UIMessageChunk } from 'ai'+import type { ACPAgentDef } from '@open-pencil/core'++interface ACPSession {+ connection: ClientSideConnection+ sessionId: string+ child: Awaited<ReturnType<Command<Uint8Array>['spawn']>>+ onUpdate: ((params: SessionNotification) => void) | null+}++export class ACPChatTransport implements ChatTransport<UIMessage> {+ private session: ACPSession | null = null+ private agentDef: ACPAgentDef+ private cwd: string++ constructor(options: { agentDef: ACPAgentDef; cwd?: string }) {+ this.agentDef = options.agentDef+ this.cwd = options.cwd ?? '.'+ }++ async sendMessages({+ messages,+ abortSignal+ }: Parameters<ChatTransport<UIMessage>['sendMessages']>[0]): Promise<+ ReadableStream<UIMessageChunk>+ > {+ const lastUserMessage = [...messages]+ .reverse()+ .find((m) => m.role === 'user')+ const text =+ lastUserMessage?.parts+ .filter((p): p is { type: 'text'; text: string } => p.type === 'text')+ .map((p) => p.text)+ .join('\n') ?? ''++ if (!this.session) {+ this.session = await this.spawnAgent()+ }++ const { connection, sessionId } = this.session+ const session = this.session++ return new ReadableStream<UIMessageChunk>({+ start: (controller) => {+ const textId = `text-${Date.now()}`+ let textStarted = false++ session.onUpdate = (params) => {+ const result = mapUpdate(+ params.update,+ textId,+ textStarted+ )+ for (const chunk of result.chunks) {+ controller.enqueue(chunk)+ }+ textStarted = result.textStarted+ }++ abortSignal?.addEventListener('abort', () => {+ connection.cancel({ sessionId }).catch(() => {})+ })++ controller.enqueue({ type: 'start' })+ controller.enqueue({ type: 'start-step' })++ connection+ .prompt({+ sessionId,+ prompt: [{ type: 'text', text }]+ })+ .then((result) => {+ if (textStarted) {+ controller.enqueue({ type: 'text-end', id: textId })+ }+ controller.enqueue({ type: 'finish-step' })+ controller.enqueue({+ type: 'finish',+ finishReason:+ result.stopReason === 'end_turn' ? 'stop' : 'other'+ })+ })+ .catch((e) => {+ const msg = e instanceof Error ? e.message : String(e)+ controller.enqueue({ type: 'error', errorText: msg })+ controller.enqueue({ type: 'finish', finishReason: 'error' })+ })+ .finally(() => {+ session.onUpdate = null+ controller.close()+ })+ }+ })+ }++ async reconnectToStream(): Promise<ReadableStream<UIMessageChunk> | null> {+ return null+ }++ async destroy(): Promise<void> {+ if (this.session) {+ await this.session.child.kill()+ this.session = null+ }+ }++ private async spawnAgent(): Promise<ACPSession> {+ const command = Command.create(this.agentDef.command, this.agentDef.args, {+ encoding: 'raw'+ })++ const stdoutChunks: Uint8Array[] = []+ let stdoutResolver: ((chunk: Uint8Array) => void) | null = null++ command.stdout.on('data', (data: Uint8Array) => {+ if (stdoutResolver) {+ const resolve = stdoutResolver+ stdoutResolver = null+ resolve(data)+ } else {+ stdoutChunks.push(data)+ }+ })++ command.stderr.on('data', (data: Uint8Array) => {+ const text =+ typeof data === 'string' ? data : new TextDecoder().decode(data)+ console.error(`[ACP ${this.agentDef.id}]`, text)+ })++ const child = await command.spawn()++ const output = new ReadableStream<Uint8Array>({+ pull(controller) {+ const buffered = stdoutChunks.shift()+ if (buffered) {+ controller.enqueue(buffered)+ return+ }+ return new Promise<void>((resolve) => {+ stdoutResolver = (chunk) => {+ controller.enqueue(chunk)+ resolve()+ }+ })+ }+ })++ const input = new WritableStream<Uint8Array>({+ async write(chunk) {+ await child.write(Array.from(chunk))+ }+ })++ const stream = ndJsonStream(input, output)+ const session: ACPSession = {+ connection: null!,+ sessionId: '',+ child,+ onUpdate: null+ }++ const clientImpl: Client = {+ async requestPermission(+ params: RequestPermissionRequest+ ): Promise<RequestPermissionResponse> {+ return {+ outcome: {+ outcome: 'selected',+ optionId: params.options[0]?.optionId ?? ''+ }+ }+ },++ async sessionUpdate(params: SessionNotification): Promise<void> {+ session.onUpdate?.(params)+ }+ }++ const connection = new ClientSideConnection(+ (_agent: Agent) => clientImpl,+ stream+ )++ await connection.initialize({+ protocolVersion: PROTOCOL_VERSION,+ clientCapabilities: {}+ })++ const sessionResult = await connection.newSession({+ cwd: this.cwd,+ mcpServers: []+ })++ session.connection = connection+ session.sessionId = sessionResult.sessionId++ return session+ }+}++interface MapResult {+ chunks: UIMessageChunk[]+ textStarted: boolean+}++function mapUpdate(+ update: SessionUpdate,+ textId: string,+ textStarted: boolean+): MapResult {+ const chunks: UIMessageChunk[] = []++ switch (update.sessionUpdate) {+ case 'agent_message_chunk': {+ if (!textStarted) {+ chunks.push({ type: 'text-start', id: textId })+ textStarted = true+ }+ if (update.content.type === 'text') {+ chunks.push({+ type: 'text-delta',+ id: textId,+ delta: update.content.text+ })+ }+ break+ }+ case 'agent_thought_chunk': {+ if (update.content.type === 'text') {+ const rid = `reasoning-${textId}`+ chunks.push({ type: 'reasoning-start', id: rid })+ chunks.push({+ type: 'reasoning-delta',+ id: rid,+ delta: update.content.text+ })+ chunks.push({ type: 'reasoning-end', id: rid })+ }+ break+ }+ case 'tool_call': {+ chunks.push({+ type: 'tool-input-start',+ toolCallId: update.toolCallId,+ toolName: update.title ?? 'unknown',+ providerExecuted: true,+ title: update.title+ })+ if (update.rawInput) {+ chunks.push({+ type: 'tool-input-available',+ toolCallId: update.toolCallId,+ toolName: update.title ?? 'unknown',+ input: update.rawInput,+ providerExecuted: true,+ title: update.title+ })+ }+ break+ }+ case 'tool_call_update': {+ if (update.status === 'completed') {+ chunks.push({+ type: 'tool-output-available',+ toolCallId: update.toolCallId,+ output: update.rawOutput ?? textFromContent(update.content ?? undefined),+ providerExecuted: true+ })+ } else if (update.status === 'failed') {+ chunks.push({+ type: 'tool-output-error',+ toolCallId: update.toolCallId,+ errorText: textFromContent(update.content ?? undefined) ?? 'Tool call failed',+ providerExecuted: true+ })+ }+ break+ }+ }++ return { chunks, textStarted }+}++// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ACP content blocks have dynamic shape+function textFromContent(content: any[] | undefined): string | undefined {+ if (!content) return undefined+ return content+ .filter(+ (c: Record<string, unknown>) =>+ c.type === 'content' &&+ (c.content as Record<string, unknown> | undefined)?.type === 'text'+ )+ .map(+ (c: Record<string, unknown>) =>+ (c.content as Record<string, string>).text+ )+ .join('\n')+}diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vueindex 619fac0a1..057f88d00 100644--- a/src/components/ChatPanel.vue+++ b/src/components/ChatPanel.vue@@ -16,8 +16,11 @@ const IS_DEV = import.meta.env.DEVconst { isConfigured, ensureChat, resetChat } = useAIChat()-const existing = ensureChat()-const chat = ref<Chat<UIMessage> | null>(existing ? markRaw(existing) : null)+const chat = ref<Chat<UIMessage> | null>(null)++ensureChat().then((c) => {+ if (c) chat.value = markRaw(c)+})const messagesEnd = ref<HTMLDivElement>()const debugCopied = ref(false)@@ -53,9 +56,9 @@ function scrollToBottom() {watch(messages, scrollToBottom, { deep: true })-function handleSubmit(text: string) {+async function handleSubmit(text: string) {if (status.value === 'streaming' || status.value === 'submitted') return- const c = ensureChat()+ const c = await ensureChat()if (c) chat.value = markRaw(c)chat.value?.sendMessage({ text }).catch(() => {/* user-facing error handled by UI */diff --git a/src/components/chat/ProviderSelect.vue b/src/components/chat/ProviderSelect.vueindex ef0ef5bde..77382cccc 100644--- a/src/components/chat/ProviderSelect.vue+++ b/src/components/chat/ProviderSelect.vue@@ -1,19 +1,32 @@<script setup lang="ts">import {SelectContent,+ SelectGroup,SelectItem,SelectItemText,+ SelectLabel,SelectPortal,SelectRoot,+ SelectSeparator,SelectTrigger,SelectViewport} from 'reka-ui'+import { computed } from 'vue'import { selectContent, selectItem, selectTrigger } from '@/components/ui/select'-import { AI_PROVIDERS } from '@open-pencil/core'+import { ACP_AGENTS, AI_PROVIDERS, IS_TAURI } from '@open-pencil/core'import { useAIChat } from '@/composables/use-chat'const { providerID, providerDef } = useAIChat()+const acpAgents = IS_TAURI ? ACP_AGENTS : []++const displayName = computed(() => {+ if (providerID.value.startsWith('acp:')) {+ const agentId = providerID.value.replace('acp:', '')+ return acpAgents.find((a) => a.id === agentId)?.name ?? providerID.value+ }+ return providerDef.value.name+})const { triggerClass, itemClass, testId } = defineProps<{triggerClass?: string@@ -34,7 +47,7 @@ const { triggerClass, itemClass, testId } = defineProps<{})">- {{ providerDef.name }}+ {{ displayName }}<icon-lucide-chevron-down class="size-2.5 shrink-0 text-muted" /></SelectTrigger><SelectPortal>@@ -44,14 +57,33 @@ const { triggerClass, itemClass, testId } = defineProps<{:class="selectContent({ radius: 'lg', padding: 'md', class: 'isolate z-[52]' })"><SelectViewport>- <SelectItem- v-for="provider in AI_PROVIDERS"- :key="provider.id"- :value="provider.id"- :class="selectItem({ class: itemClass ?? 'rounded px-2 py-1 text-[11px]' })"- >- <SelectItemText>{{ provider.name }}</SelectItemText>- </SelectItem>+ <template v-if="acpAgents.length">+ <SelectGroup>+ <SelectLabel class="px-2 py-1 text-[10px] text-muted">Your agents</SelectLabel>+ <SelectItem+ v-for="agent in acpAgents"+ :key="agent.id"+ :value="`acp:${agent.id}`"+ :class="selectItem({ class: itemClass ?? 'rounded px-2 py-1 text-[11px]' })"+ >+ <SelectItemText>{{ agent.name }}</SelectItemText>+ </SelectItem>+ </SelectGroup>+ <SelectSeparator class="mx-1 my-1 h-px bg-border" />+ </template>+ <SelectGroup>+ <SelectLabel v-if="acpAgents.length" class="px-2 py-1 text-[10px] text-muted">+ API key+ </SelectLabel>+ <SelectItem+ v-for="provider in AI_PROVIDERS"+ :key="provider.id"+ :value="provider.id"+ :class="selectItem({ class: itemClass ?? 'rounded px-2 py-1 text-[11px]' })"+ >+ <SelectItemText>{{ provider.name }}</SelectItemText>+ </SelectItem>+ </SelectGroup></SelectViewport></SelectContent></SelectPortal>diff --git a/src/components/chat/ProviderSettings.vue b/src/components/chat/ProviderSettings.vueindex 7cdb04810..32bb69596 100644--- a/src/components/chat/ProviderSettings.vue+++ b/src/components/chat/ProviderSettings.vue@@ -10,7 +10,7 @@ import {TabsRoot,TabsTrigger} from 'reka-ui'-import { ref, watch } from 'vue'+import { computed, ref, watch } from 'vue'import ProviderSelect from '@/components/chat/ProviderSelect.vue'import { uiInput } from '@/components/ui/input'@@ -29,6 +29,8 @@ const {unsplashAccessKey} = useAIChat()+const isACP = computed(() => providerID.value.startsWith('acp:'))+const keyInput = ref('')const pexelsKeyInput = ref('')const unsplashKeyInput = ref('')@@ -122,6 +124,7 @@ function clearUnsplashKey() {<ProviderSelect test-id="provider-settings-provider" />+ <template v-if="!isACP"><!-- Base URL (OpenAI-compatible only) --><div v-if="providerDef.supportsCustomBaseURL" class="flex flex-col gap-1"><label class="text-[10px] text-muted">Base URL</label>@@ -295,6 +298,7 @@ function clearUnsplashKey() {Get API key →</a></div>+ </template><PopoverCloseclass="mt-1 w-full rounded bg-accent px-2 py-1 text-center text-[11px] font-medium text-white hover:bg-accent/90"diff --git a/src/components/chat/ProviderSetup.vue b/src/components/chat/ProviderSetup.vueindex 0086af8cd..19b4d521d 100644--- a/src/components/chat/ProviderSetup.vue+++ b/src/components/chat/ProviderSetup.vue@@ -1,12 +1,20 @@<script setup lang="ts">-import { ref } from 'vue'+import { computed, ref } from 'vue'import ProviderSelect from '@/components/chat/ProviderSelect.vue'import { uiInput } from '@/components/ui/input'import { useAIChat } from '@/composables/use-chat'+import { ACP_AGENTS } from '@open-pencil/core'const { providerID, providerDef, setAPIKey, customBaseURL, customModelID } = useAIChat()+const isACP = computed(() => providerID.value.startsWith('acp:'))+const acpAgent = computed(() => {+ if (!isACP.value) return null+ const id = providerID.value.replace('acp:', '')+ return ACP_AGENTS.find((a) => a.id === id) ?? null+})+const keyInput = ref('')const baseURLInput = ref(customBaseURL.value)const customModelInput = ref(customModelID.value)@@ -30,7 +38,7 @@ function save() {<icon-lucide-sparkles class="mb-3 size-7 text-muted" /><p class="mb-5 text-center text-xs text-muted">Connect an AI provider to start chatting.</p>- <form class="flex w-full flex-col gap-2" @submit.prevent="save">+ <form v-if="!isACP" class="flex w-full flex-col gap-2" @submit.prevent="save"><ProviderSelecttest-id="provider-selector"trigger-class="w-full justify-between rounded border border-border bg-input px-2.5 py-1.5 text-xs text-surface"@@ -75,8 +83,23 @@ function save() {</button></form>+ <!-- ACP agent — no API key needed -->+ <div v-else class="flex w-full flex-col gap-2">+ <ProviderSelect+ test-id="provider-selector"+ trigger-class="w-full justify-between rounded border border-border bg-input px-2.5 py-1.5 text-xs text-surface"+ item-class="rounded px-2 py-1.5 text-[11px]"+ />++ <p class="text-center text-[10px] leading-relaxed text-muted">+ Uses your existing {{ acpAgent?.name }} subscription. Make sure+ <code class="rounded bg-input px-1 py-0.5 font-mono text-[9px]">{{ acpAgent?.command }}</code>+ is installed and authenticated.+ </p>+ </div>+<a- v-if="providerDef.keyURL"+ v-if="!isACP && providerDef.keyURL":href="providerDef.keyURL"target="_blank"data-test-id="api-key-get-link"diff --git a/src/composables/use-chat.ts b/src/composables/use-chat.tsindex 8afc1532c..fc16f20d6 100644--- a/src/composables/use-chat.ts+++ b/src/composables/use-chat.ts@@ -11,14 +11,16 @@ import SYSTEM_PROMPT from '@/ai/system-prompt.md?raw'import { MAX_AGENT_STEPS, createAITools, recordStepUsage, resetRunSteps } from '@/ai/tools'import { useEditorStore } from '@/stores/editor'import {+ ACP_AGENTS,AI_PROVIDERS,DEFAULT_AI_MODEL,DEFAULT_AI_PROVIDER,+ IS_TAURI,setPexelsApiKey,setUnsplashAccessKey} from '@open-pencil/core'-import type { AIProviderID } from '@open-pencil/core'+import type { ACPAgentID, AIProviderID } from '@open-pencil/core'import type { LanguageModel, UIMessage } from 'ai'const STORAGE_PREFIX = 'open-pencil:'@@ -63,7 +65,10 @@ const providerDef = computed(() => AI_PROVIDERS.find((p) => p.id === providerID.value) ?? AI_PROVIDERS[0])+const isACPProvider = computed(() => providerID.value.startsWith('acp:'))+const isConfigured = computed(() => {+ if (isACPProvider.value) return IS_TAURIif (!apiKey.value) return falseconst needsBaseURL =providerID.value === 'openai-compatible' || providerID.value === 'anthropic-compatible'@@ -171,8 +176,10 @@ function createModel(): LanguageModel {return custom(effectiveModelID)}default: {- const _exhaustive: never = providerID.value- throw new Error(`Unknown provider: ${String(_exhaustive)}`)+ if (providerID.value.startsWith('acp:')) {+ throw new Error('ACP providers do not use direct API models')+ }+ throw new Error(`Unknown provider: ${providerID.value}`)}}}@@ -194,9 +201,26 @@ function supportsAnthropicCaching(): boolean {)}+let acpTransportInstance: { destroy(): Promise<void> } | null = null++async function createACPTransport() {+ const agentId = providerID.value.replace('acp:', '') as ACPAgentID+ const agentDef = ACP_AGENTS.find((a) => a.id === agentId)+ if (!agentDef) throw new Error(`Unknown ACP agent: ${agentId}`)++ const { ACPChatTransport } = await import('@/ai/acp-transport')+ await acpTransportInstance?.destroy()+ const transport = new ACPChatTransport({ agentDef })+ acpTransportInstance = transport+ return transport+}+function createTransport() {if (overrideTransport) return overrideTransport()+ acpTransportInstance?.destroy()+ acpTransportInstance = null+const tools = createAITools(useEditorStore())const cacheProviderOptions = supportsAnthropicCaching() ? ANTHROPIC_CACHE_CONTROL : undefined@@ -229,14 +253,14 @@ function createTransport() {return new DirectChatTransport({ agent })}-function ensureChat(): Chat<UIMessage> | null {+async function ensureChat(): Promise<Chat<UIMessage> | null> {if (!isConfigured.value) return null- if (!chat) {- chat = new Chat<UIMessage>({ transport: createTransport() })- transportDirty = false- } else if (transportDirty) {- const messages = chat.messages- chat = new Chat<UIMessage>({ transport: createTransport(), messages })+ if (!chat || transportDirty) {+ const messages = chat?.messages+ const transport = isACPProvider.value+ ? await createACPTransport()+ : createTransport()+ chat = new Chat<UIMessage>({ transport, messages })transportDirty = false}return chat