@agents24/ai-sdk 0.2.18 → 0.2.19

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/index.js CHANGED
@@ -249,6 +249,7 @@ function createInMemoryAgents24ChatStateStore() {
249
249
  import { Agents24ClientError } from "@agents24/client";
250
250
 
251
251
  // src/request-policy.ts
252
+ import { ATTACHMENT_RUNTIME_LIMITS } from "@agents24/client";
252
253
  var RESERVED_KEYS = /* @__PURE__ */ new Set([
253
254
  "agent",
254
255
  "agentid",
@@ -360,6 +361,9 @@ function prepareAgents24Request(options, policy) {
360
361
  const attachmentIds = body.attachmentIds === void 0 ? [] : Array.isArray(body.attachmentIds) && body.attachmentIds.every((item) => typeof item === "string" && item.length > 0) ? body.attachmentIds : (() => {
361
362
  throw requestError("INVALID_ATTACHMENT_IDS", "Agents24 attachmentIds must be a string array.");
362
363
  })();
364
+ if (attachmentIds.length > ATTACHMENT_RUNTIME_LIMITS.max_attachments_per_turn) {
365
+ throw requestError("TOO_MANY_ATTACHMENTS", "Too many Agents24 attachment IDs.");
366
+ }
363
367
  const requestedModelId = body.requestedModelId === void 0 ? void 0 : typeof body.requestedModelId === "string" && body.requestedModelId.length > 0 ? body.requestedModelId : (() => {
364
368
  throw requestError("INVALID_MODEL_ID", "Agents24 requestedModelId must be a non-empty string.");
365
369
  })();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/event-mapper.ts","../src/state-store.ts","../src/transport.ts","../src/request-policy.ts"],"sourcesContent":["export type Agents24AiSdkErrorKind = \"capability\" | \"request\" | \"state\" | \"unsupported\";\n\nexport class Agents24AiSdkError extends Error {\n readonly code: string;\n readonly kind: Agents24AiSdkErrorKind;\n\n constructor(message: string, options: { code: string; kind: Agents24AiSdkErrorKind }) {\n super(message);\n this.name = \"Agents24AiSdkError\";\n this.code = options.code;\n this.kind = options.kind;\n }\n}\n\nexport function requestError(code: string, message: string): Agents24AiSdkError {\n return new Agents24AiSdkError(message, { code, kind: \"request\" });\n}\n","import type { RuntimeEvent } from \"@agents24/client\";\nimport type { UIMessageChunk } from \"ai\";\nimport type { Agents24MessageMetadata } from \"./types.js\";\n\nconst record = (value: unknown): Record<string, unknown> | null =>\n value && typeof value === \"object\" && !Array.isArray(value) ? value as Record<string, unknown> : null;\nconst text = (value: unknown): string | null => typeof value === \"string\" && value.length > 0 ? value : null;\n\nfunction safeWebUrl(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n try {\n const parsed = new URL(value);\n return parsed.protocol === \"https:\" || parsed.protocol === \"http:\" ? parsed.toString() : null;\n } catch {\n return null;\n }\n}\n\nfunction dataChunk(name: string, data: unknown, id?: string): UIMessageChunk {\n return {\n type: `data-agents24-${name}`,\n data,\n ...(id ? { id } : {}),\n } as UIMessageChunk;\n}\n\nexport class Agents24EventMapper {\n private cursor: number | null = null;\n private finished = false;\n private responseCompletion?: import(\"@agents24/client/protocol\").ResponseCompletion;\n private reasoningOpen = false;\n private runId: string | null = null;\n private started = false;\n private textOpen = false;\n private threadId: string | null;\n private readonly toolCalls = new Set<string>();\n private readonly toolOutputs = new Set<string>();\n private status: string | undefined;\n\n constructor(\n private readonly messageId: string,\n threadId?: string | null,\n ) {\n this.threadId = threadId ?? null;\n }\n\n get state(): Agents24MessageMetadata {\n return {\n responseCompletion: this.responseCompletion,\n cursor: this.cursor,\n runId: this.runId,\n threadId: this.threadId,\n ...(this.status ? { status: this.status } : {}),\n };\n }\n\n private ensureStarted(): UIMessageChunk[] {\n if (this.started) return [];\n this.started = true;\n return [\n { type: \"start\", messageId: this.messageId, messageMetadata: this.state },\n { type: \"start-step\" },\n ];\n }\n\n private text(value: string, id: string): UIMessageChunk[] {\n const chunks: UIMessageChunk[] = [];\n if (!this.textOpen) {\n this.textOpen = true;\n chunks.push({ type: \"text-start\", id });\n }\n if (value) chunks.push({ type: \"text-delta\", id, delta: value });\n return chunks;\n }\n\n private reasoning(value: string, id: string): UIMessageChunk[] {\n const chunks: UIMessageChunk[] = [];\n if (!this.reasoningOpen) {\n this.reasoningOpen = true;\n chunks.push({ type: \"reasoning-start\", id });\n }\n if (value) chunks.push({ type: \"reasoning-delta\", id, delta: value });\n return chunks;\n }\n\n private toolInput(block: Record<string, unknown>, fallbackId: string): UIMessageChunk[] {\n const tool = record(block.tool) || block;\n const toolCallId = text(tool.toolCallId) || text(tool.tool_call_id) || fallbackId;\n const toolName = text(tool.action) || text(tool.title) || text(block.display_name) || \"tool\";\n if (this.toolCalls.has(toolCallId)) return [];\n this.toolCalls.add(toolCallId);\n return [{\n type: \"tool-input-available\",\n toolCallId,\n toolName,\n input: tool.input ?? block.input ?? {},\n providerExecuted: true,\n dynamic: true,\n ...(text(tool.title) || text(block.display_name) ? { title: text(tool.title) || text(block.display_name) || undefined } : {}),\n }];\n }\n\n private toolOutput(block: Record<string, unknown>, fallbackId: string): UIMessageChunk[] {\n const tool = record(block.tool) || block;\n const toolCallId = text(tool.toolCallId) || text(tool.tool_call_id) || fallbackId;\n const chunks = this.toolInput(block, fallbackId);\n if (this.toolOutputs.has(toolCallId)) return chunks;\n this.toolOutputs.add(toolCallId);\n const failed = [\"failed\", \"error\"].includes(String(block.status || \"\").toLocaleLowerCase());\n chunks.push(failed\n ? { type: \"tool-output-error\", toolCallId, errorText: text(tool.error) || text(block.error) || \"Tool execution failed.\", providerExecuted: true, dynamic: true }\n : { type: \"tool-output-available\", toolCallId, output: tool.output ?? block.output ?? block, providerExecuted: true, dynamic: true });\n return chunks;\n }\n\n private mapBlock(block: Record<string, unknown>, fallbackId: string): UIMessageChunk[] {\n const kind = String(block.kind || \"unsupported\");\n const id = text(block.id) || fallbackId;\n const chunks: UIMessageChunk[] = [dataChunk(\"response-block\", block, id)];\n if (kind === \"assistant_text\" && !this.textOpen && !this.responseCompletion) {\n chunks.push(...this.text(text(block.text) || \"\", `${this.runId || \"run\"}-text`));\n } else if (kind === \"reasoning_note\" && !this.reasoningOpen) {\n chunks.push(...this.reasoning(text(block.description) || text(block.label) || \"\", `${this.runId || \"run\"}-reasoning`));\n } else if (kind === \"tool_call\") {\n chunks.push(...this.toolOutput(block, id));\n } else if (kind === \"source\") {\n const url = safeWebUrl(block.url);\n if (url) chunks.push({ type: \"source-url\", sourceId: id, url, ...(text(block.title) ? { title: text(block.title) || undefined } : {}) });\n } else if (kind === \"citation\") {\n chunks.push(dataChunk(\"citation\", block, id));\n } else if (kind === \"ui_blocks\") {\n chunks.push(dataChunk(\"ui-blocks\", block, id));\n } else if (kind === \"hitl_request\") {\n chunks.push(dataChunk(\"hitl\", block, id));\n } else if (kind === \"mcp_authorization\") {\n chunks.push(dataChunk(\"mcp\", block, id));\n } else if (kind === \"attachment\") {\n chunks.push(dataChunk(\"attachment\", block, id));\n } else if (kind === \"error\") {\n chunks.push({ type: \"error\", errorText: text(record(block.error)?.message) || text(block.text) || \"The run failed.\" });\n } else if (kind === \"user_message\") {\n chunks.push(dataChunk(\"unsupported\", { feature: \"terminal-user-message-block\", block }, id));\n }\n return chunks;\n }\n\n private terminal(finishReason: \"error\" | \"other\" | \"stop\", metadata: Agents24MessageMetadata): UIMessageChunk[] {\n if (this.finished) return [];\n this.finished = true;\n this.status = metadata.status;\n const chunks: UIMessageChunk[] = [];\n if (this.textOpen) chunks.push({ type: \"text-end\", id: `${this.runId || \"run\"}-text` });\n if (this.reasoningOpen) chunks.push({ type: \"reasoning-end\", id: `${this.runId || \"run\"}-reasoning` });\n chunks.push({ type: \"finish-step\" });\n chunks.push({ type: \"finish\", finishReason, messageMetadata: metadata });\n return chunks;\n }\n\n map(event: RuntimeEvent): UIMessageChunk[] {\n this.runId = event.run_id;\n this.cursor = event.seq;\n const payload = event.payload;\n if (event.event === \"run.snapshot\" || event.event === \"run.accepted\") {\n const status = text(payload.status);\n if ([\"queued\", \"running\", \"waiting\", \"interrupted\", \"paused\", \"cancelling\", \"completed\", \"failed\", \"cancelled\"].includes(status || \"\")) this.status = status!;\n }\n this.threadId = text(payload.thread_id) || this.threadId;\n const chunks = this.ensureStarted();\n const completion = event.event === \"assistant.completed\" ? payload : payload.response_completion;\n chunks.push(dataChunk(\"event\", event, `${event.run_id}:${event.seq}`));\n chunks.push({ type: \"message-metadata\", messageMetadata: { ...this.state,\n ...(completion ? { responseCompletion: completion as import(\"@agents24/client/protocol\").ResponseCompletion } : {}) } });\n\n if (event.event === \"assistant.delta\" && !this.responseCompletion) {\n chunks.push(...this.text(text(payload.content) || \"\", `${event.run_id}-text`));\n } else if (event.event === \"reasoning.update\") {\n chunks.push(...this.reasoning(text(payload.delta) || text(payload.description) || text(payload.label) || \"\", `${event.run_id}-reasoning`));\n } else if (event.event === \"tool.started\") {\n chunks.push(...this.toolInput(payload, text(payload.tool_call_id) || `${event.run_id}:tool:${event.seq}`));\n } else if (event.event === \"tool.completed\" || event.event === \"tool.failed\" || event.event === \"tool.cancelled\") {\n chunks.push(...this.toolOutput({ ...payload, status: event.event.split(\".\")[1] }, text(payload.tool_call_id) || `${event.run_id}:tool:${event.seq}`));\n } else if (event.event === \"source.added\") {\n const source = record(payload.source) || payload;\n const sourceId = text(source.id) || `${event.run_id}:source:${event.seq}`;\n const url = safeWebUrl(source.url);\n if (url) chunks.push({ type: \"source-url\", sourceId, url, ...(text(source.title) ? { title: text(source.title) || undefined } : {}) });\n } else if (event.event === \"citation.added\") {\n chunks.push(dataChunk(\"citation\", record(payload.source) || payload, `${event.run_id}:citation:${event.seq}`));\n } else if (event.event === \"ui_blocks.updated\") {\n chunks.push(dataChunk(\"ui-blocks\", payload, `${event.run_id}:ui:${event.seq}`));\n } else if (event.event === \"context_window.updated\" || event.event === \"context.compression.updated\" || event.event === \"run_usage.updated\") {\n chunks.push(dataChunk(\"context\", payload, `${event.run_id}:context:${event.seq}`));\n } else if (event.event === \"hitl.requested\" || event.event === \"hitl.resolved\") {\n chunks.push(dataChunk(\"hitl\", payload, `${event.run_id}:hitl:${event.seq}`));\n } else if (event.event.startsWith(\"mcp.authorization.\")) {\n chunks.push(dataChunk(\"mcp\", payload, `${event.run_id}:mcp:${event.seq}`));\n } else if (event.event.startsWith(\"attachment.\")) {\n chunks.push(dataChunk(\"attachment\", payload, `${event.run_id}:attachment:${event.seq}`));\n }\n\n const blocks = Array.isArray(payload.response_blocks) ? payload.response_blocks : [];\n blocks.forEach((value, index) => {\n const block = record(value);\n if (block) chunks.push(...this.mapBlock(block, `${event.run_id}:block:${event.seq}:${index}`));\n });\n\n if (completion && typeof completion === \"object\" && \"completed_at\" in completion) {\n this.responseCompletion = completion as import(\"@agents24/client/protocol\").ResponseCompletion;\n if (this.textOpen) {\n chunks.push({ type: \"text-end\", id: `${this.runId || \"run\"}-text` });\n this.textOpen = false;\n }\n }\n if (event.event === \"run.completed\") chunks.push(...this.terminal(\"stop\", { ...this.state, status: \"completed\" }));\n if (event.event === \"run.failed\") chunks.push(...this.terminal(\"error\", { ...this.state, status: \"failed\" }));\n if (event.event === \"run.cancelled\") chunks.push(...this.terminal(\"other\", { ...this.state, status: \"cancelled\" }));\n if (event.event === \"run.waiting\" || event.event === \"run.interrupted\") chunks.push(...this.terminal(\"other\", { ...this.state, status: event.event.slice(4) }));\n if (event.event === \"run.paused\") chunks.push(...this.terminal(\"other\", { ...this.state, status: \"paused\" }));\n return chunks;\n }\n\n finalize(input: { aborted?: boolean; detached?: boolean; error?: string }): UIMessageChunk[] {\n const chunks = this.ensureStarted();\n if (input.aborted) {\n if (!this.finished) {\n this.finished = true;\n chunks.push({ type: \"abort\", reason: \"The local stream was stopped.\" });\n }\n return chunks;\n }\n if (input.error) {\n chunks.push({ type: \"error\", errorText: input.error });\n chunks.push(...this.terminal(\"error\", { ...this.state, status: \"failed\" }));\n return chunks;\n }\n chunks.push(...this.terminal(\"other\", { ...this.state, detached: Boolean(input.detached), status: this.status || \"detached\" }));\n return chunks;\n }\n}\n","import type { Agents24ChatStateStore, Agents24PersistedChatState } from \"./types.js\";\n\nexport function createInMemoryAgents24ChatStateStore(): Agents24ChatStateStore {\n const states = new Map<string, Agents24PersistedChatState>();\n return {\n async load(chatId) {\n const state = states.get(chatId);\n return state ? { ...state } : null;\n },\n async save(chatId, state) {\n states.set(chatId, { ...state });\n },\n };\n}\n","import { Agents24ClientError } from \"@agents24/client\";\nimport type { StreamResult } from \"@agents24/client\";\nimport type { ChatRequestOptions, UIMessageChunk } from \"ai\";\nimport { Agents24AiSdkError } from \"./errors.js\";\nimport { Agents24EventMapper } from \"./event-mapper.js\";\nimport { prepareAgents24Request, promptForRequest } from \"./request-policy.js\";\nimport { createInMemoryAgents24ChatStateStore } from \"./state-store.js\";\nimport type {\n Agents24AdapterTelemetryEvent,\n Agents24ChatTransport,\n Agents24MessageMetadata,\n Agents24PersistedChatState,\n CreateAgents24ChatTransportOptions,\n} from \"./types.js\";\n\nfunction defaultId(): string {\n const crypto = (globalThis as unknown as { crypto?: { randomUUID?: () => string } }).crypto;\n if (!crypto?.randomUUID) {\n throw new Agents24AiSdkError(\"A secure ID capability must be injected for this runtime.\", {\n code: \"MISSING_ID_CAPABILITY\",\n kind: \"capability\",\n });\n }\n return crypto.randomUUID();\n}\n\nfunction checkedId(createId: () => string): string {\n const value = createId();\n if (!value || /[\\r\\n\\0]/.test(value)) {\n throw new Agents24AiSdkError(\"The ID provider returned an invalid identifier.\", {\n code: \"INVALID_ID\",\n kind: \"capability\",\n });\n }\n return value;\n}\n\nfunction safeStreamError(error: unknown): string {\n if (error instanceof Agents24ClientError || error instanceof Agents24AiSdkError) return error.message;\n return \"The Agents24 stream failed.\";\n}\n\nfunction persistedState(\n messageId: string,\n metadata: Agents24MessageMetadata,\n status: Agents24PersistedChatState[\"status\"],\n): Agents24PersistedChatState {\n return {\n ...(metadata.responseCompletion ? { responseCompletion: metadata.responseCompletion } : {}),\n cursor: metadata.cursor ?? null,\n messageId,\n runId: metadata.runId ?? null,\n status,\n threadId: metadata.threadId ?? null,\n };\n}\n\nfunction terminalStatus(\n metadata: Agents24MessageMetadata,\n result: StreamResult,\n): Agents24PersistedChatState[\"status\"] {\n if (result.detached) return \"detached\";\n if (metadata.status === \"failed\") return \"failed\";\n if (metadata.status === \"cancelled\") return \"cancelled\";\n if (metadata.status === \"paused\") return \"paused\";\n if (metadata.status === \"waiting\" || metadata.status === \"interrupted\" || metadata.status === \"completed\") return metadata.status;\n return \"detached\";\n}\n\nfunction validState(value: Agents24PersistedChatState): boolean {\n return (\n typeof value.messageId === \"string\" &&\n value.messageId.length > 0 &&\n (value.runId === null || typeof value.runId === \"string\") &&\n (value.threadId === null || typeof value.threadId === \"string\") &&\n (value.cursor === null || Number.isSafeInteger(value.cursor)) &&\n [\"active\", \"cancelled\", \"completed\", \"detached\", \"failed\", \"paused\", \"waiting\", \"interrupted\"].includes(value.status)\n );\n}\n\nexport function createAgents24ChatTransport(\n options: CreateAgents24ChatTransportOptions,\n): Agents24ChatTransport {\n const createId = options.createId ?? defaultId;\n const stateStore = options.stateStore ?? createInMemoryAgents24ChatStateStore();\n\n const emit = async (event: Agents24AdapterTelemetryEvent): Promise<void> => {\n try {\n await options.telemetry?.emit(event);\n } catch {\n // Adapter telemetry never receives credentials and cannot affect the stream.\n }\n };\n\n const stream = (input: {\n chatId: string;\n initialThreadId?: string | null;\n messageId: string;\n operation: \"reconnect\" | \"submit\";\n abortSignal?: AbortSignal;\n content?: Agents24AdapterTelemetryEvent[\"content\"];\n execute(onEvent: Parameters<CreateAgents24ChatTransportOptions[\"client\"][\"chat\"][\"stream\"]>[1]): Promise<StreamResult>;\n }): ReadableStream<UIMessageChunk> => {\n const mapper = new Agents24EventMapper(input.messageId, input.initialThreadId);\n return new ReadableStream<UIMessageChunk>({\n async start(controller) {\n await emit({\n chatId: input.chatId,\n operation: input.operation,\n status: \"started\",\n ...(input.content ? { content: input.content } : {}),\n });\n try {\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, \"active\"),\n );\n const result = await input.execute(async (event) => {\n for (const chunk of mapper.map(event)) controller.enqueue(chunk);\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, [\"waiting\", \"interrupted\", \"paused\"].includes(mapper.state.status || \"\")\n ? mapper.state.status as Agents24PersistedChatState[\"status\"] : \"active\"),\n );\n });\n const status = terminalStatus(mapper.state, result);\n for (const chunk of mapper.finalize({\n aborted: input.abortSignal?.aborted,\n detached: result.detached,\n })) controller.enqueue(chunk);\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, status),\n );\n await emit({\n chatId: input.chatId,\n cursor: mapper.state.cursor,\n operation: input.operation,\n runId: mapper.state.runId,\n status: \"completed\",\n });\n } catch (error) {\n const aborted = input.abortSignal?.aborted ?? false;\n for (const chunk of mapper.finalize({\n aborted,\n ...(aborted ? {} : { error: safeStreamError(error) }),\n })) controller.enqueue(chunk);\n try {\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, aborted ? \"detached\" : \"failed\"),\n );\n } catch {\n // A failed state store is already represented by the safe stream error.\n }\n await emit({\n chatId: input.chatId,\n cursor: mapper.state.cursor,\n operation: input.operation,\n runId: mapper.state.runId,\n status: aborted ? \"completed\" : \"failed\",\n });\n } finally {\n controller.close();\n }\n },\n });\n };\n\n return {\n listThreadMessages(input) {\n return options.client.threads.messages.list(input);\n },\n queueMessage(input) {\n return options.client.threads.messages.submit({ ...input, mode: \"queue\" });\n },\n steerMessage(input) {\n if (!input.input.trim()) throw new Agents24AiSdkError(\"Steering requires text.\", { code: \"INVALID_STEER\", kind: \"state\" });\n return options.client.threads.messages.submit({ ...input, mode: \"steer\" });\n },\n editPendingMessage(input) {\n return options.client.threads.messages.edit(input);\n },\n async removePendingMessage(input) {\n await options.client.threads.messages.remove(input);\n },\n resumeQueue(input) {\n return options.client.threads.resumeQueue(input);\n },\n async sendMessages(input) {\n if (input.trigger === \"regenerate-message\") {\n throw new Agents24AiSdkError(\n \"Agents24 V0 does not support regenerate because the frozen client-runtime routes have no regenerate operation.\",\n { code: \"REGENERATE_UNSUPPORTED\", kind: \"unsupported\" },\n );\n }\n const prepared = prepareAgents24Request(input, options.requestPolicy);\n const prompt = promptForRequest(input.messages);\n const previous = await stateStore.load(input.chatId);\n if (previous && !validState(previous)) {\n throw new Agents24AiSdkError(\"Stored Agents24 chat state is invalid.\", {\n code: \"INVALID_CHAT_STATE\",\n kind: \"state\",\n });\n }\n if (!previous?.threadId && input.messages.length > 1) {\n throw new Agents24AiSdkError(\n \"Conversation history requires persisted Agents24 thread state; client history is never replayed as forged runtime history.\",\n { code: \"CHAT_STATE_REQUIRED\", kind: \"state\" },\n );\n }\n const responseMessageId = checkedId(createId);\n const clientSubmissionId = checkedId(createId);\n const idempotencyKey = checkedId(createId);\n const content = options.requestPolicy?.includePromptAndToolContentInTelemetry\n ? { prompt, toolInputs: prepared.toolInputs }\n : undefined;\n return stream({\n chatId: input.chatId,\n ...(previous?.threadId ? { initialThreadId: previous.threadId } : {}),\n messageId: responseMessageId,\n operation: \"submit\",\n ...(input.abortSignal ? { abortSignal: input.abortSignal } : {}),\n ...(content ? { content } : {}),\n execute: (onEvent) => options.client.chat.stream({\n clientSubmissionId,\n input: prompt,\n attachmentIds: prepared.attachmentIds,\n headers: prepared.headers,\n idempotencyKey,\n metadata: prepared.metadata,\n ...(previous?.threadId ? { threadId: previous.threadId } : {}),\n ...(prepared.requestedModelId ? { requestedModelId: prepared.requestedModelId } : {}),\n toolInputs: prepared.toolInputs,\n ...(input.abortSignal ? { signal: input.abortSignal } : {}),\n }, onEvent),\n });\n },\n\n async reconnectToStream(input) {\n const prepared = prepareAgents24Request(input, options.requestPolicy);\n if (\n prepared.attachmentIds.length ||\n Object.keys(prepared.metadata).length ||\n prepared.requestedModelId ||\n Object.keys(prepared.toolInputs).length\n ) {\n throw new Agents24AiSdkError(\n \"Reconnect accepts allowlisted headers only; run input is immutable after submission.\",\n { code: \"RECONNECT_OPTIONS_UNSUPPORTED\", kind: \"unsupported\" },\n );\n }\n const previous = await stateStore.load(input.chatId);\n if (!previous) return null;\n if (!validState(previous)) {\n throw new Agents24AiSdkError(\"Stored Agents24 chat state is invalid.\", {\n code: \"INVALID_CHAT_STATE\",\n kind: \"state\",\n });\n }\n if (\n !previous.runId\n || previous.status === \"completed\"\n || previous.status === \"failed\"\n || previous.status === \"cancelled\"\n || previous.status === \"paused\"\n ) {\n return null;\n }\n return stream({\n chatId: input.chatId,\n initialThreadId: previous.threadId,\n messageId: previous.messageId,\n operation: \"reconnect\",\n execute: (onEvent) => options.client.runs.attach({\n runId: previous.runId as string,\n ...(previous.cursor === null ? {} : { cursor: previous.cursor }),\n headers: prepared.headers,\n }, onEvent),\n });\n },\n };\n}\n","import type { ChatRequestOptions } from \"ai\";\nimport { requestError } from \"./errors.js\";\nimport type { Agents24RequestPolicy, Agents24UIMessage } from \"./types.js\";\n\nconst RESERVED_KEYS = new Set([\n \"agent\", \"agentid\", \"agentversion\", \"agentversionid\", \"authorization\", \"clientid\",\n \"cursor\", \"deployment\", \"deploymentid\", \"dpop\", \"identity\", \"origin\", \"refreshgrant\",\n \"runid\", \"session\", \"sessionid\", \"tenant\", \"tenantid\", \"token\", \"userid\", \"version\",\n]);\nconst RESERVED_HEADERS = new Set([\n \"authorization\", \"cookie\", \"dpop\", \"host\", \"origin\", \"proxy-authorization\",\n \"sec-fetch-site\", \"x-agent-id\", \"x-agent-version\", \"x-agents24-deployment-id\",\n \"x-client-id\", \"x-deployment-id\", \"x-forwarded-host\", \"x-refresh-grant\", \"x-run-id\", \"x-session-id\",\n]);\n\nfunction normalizedKey(value: string): string {\n return value.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n}\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction assertNoReservedFields(value: unknown, path: string): void {\n const object = record(value);\n if (!object) return;\n for (const [key, child] of Object.entries(object)) {\n if (RESERVED_KEYS.has(normalizedKey(key))) {\n throw requestError(\n \"RESERVED_REQUEST_FIELD\",\n `Agents24 reserved request field cannot be overridden: ${path}${key}`,\n );\n }\n assertNoReservedFields(child, `${path}${key}.`);\n }\n}\n\nfunction allowedRecord(value: unknown, allowed: ReadonlySet<string>, label: string): Record<string, unknown> {\n const input = record(value);\n if (!input) {\n if (value === undefined) return {};\n throw requestError(\"INVALID_REQUEST_OPTIONS\", `Agents24 ${label} must be an object.`);\n }\n assertNoReservedFields(input, `${label}.`);\n const output: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(input)) {\n if (!allowed.has(key)) {\n throw requestError(\n \"REQUEST_FIELD_NOT_ALLOWLISTED\",\n `Agents24 ${label} field is not allowlisted: ${key}`,\n );\n }\n output[key] = child;\n }\n return output;\n}\n\nfunction headerEntries(headers: ChatRequestOptions[\"headers\"]): Array<[string, string]> {\n if (!headers) return [];\n if (typeof (headers as Headers).forEach === \"function\") {\n const output: Array<[string, string]> = [];\n (headers as Headers).forEach((value, key) => output.push([key, value]));\n return output;\n }\n return Object.entries(headers as Record<string, string>);\n}\n\nexport type PreparedAgents24Request = {\n attachmentIds: string[];\n headers: Readonly<Record<string, string>>;\n metadata: Readonly<Record<string, unknown>>;\n requestedModelId?: string;\n toolInputs: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n};\n\nexport function prepareAgents24Request(\n options: ChatRequestOptions,\n policy: Agents24RequestPolicy | undefined,\n): PreparedAgents24Request {\n const allowedBody = new Set(policy?.allowedBodyFields ?? [\"attachmentIds\", \"requestedModelId\", \"toolInputs\"]);\n const allowedHeaders = new Set((policy?.allowedHeaders ?? []).map((name) => name.toLowerCase()));\n const allowedMetadata = new Set(policy?.allowedMetadataFields ?? []);\n const body = allowedRecord(options.body, allowedBody, \"body\");\n const metadata = allowedRecord(options.metadata, allowedMetadata, \"metadata\");\n const headers: Record<string, string> = {};\n for (const [rawName, value] of headerEntries(options.headers)) {\n const name = rawName.toLowerCase();\n if (RESERVED_HEADERS.has(name)) {\n throw requestError(\"RESERVED_REQUEST_HEADER\", `Agents24 reserved header cannot be overridden: ${rawName}`);\n }\n if (!allowedHeaders.has(name)) {\n throw requestError(\"REQUEST_HEADER_NOT_ALLOWLISTED\", `Agents24 header is not allowlisted: ${rawName}`);\n }\n if (/[\\r\\n\\0]/.test(value)) {\n throw requestError(\"INVALID_REQUEST_HEADER\", `Agents24 header contains invalid characters: ${rawName}`);\n }\n headers[name] = value;\n }\n const attachmentIds = body.attachmentIds === undefined\n ? []\n : Array.isArray(body.attachmentIds) && body.attachmentIds.every((item) => typeof item === \"string\" && item.length > 0)\n ? body.attachmentIds\n : (() => { throw requestError(\"INVALID_ATTACHMENT_IDS\", \"Agents24 attachmentIds must be a string array.\"); })();\n const requestedModelId = body.requestedModelId === undefined\n ? undefined\n : typeof body.requestedModelId === \"string\" && body.requestedModelId.length > 0\n ? body.requestedModelId\n : (() => { throw requestError(\"INVALID_MODEL_ID\", \"Agents24 requestedModelId must be a non-empty string.\"); })();\n const toolInputs = body.toolInputs === undefined\n ? {}\n : allowedRecord(body.toolInputs, new Set(Object.keys(record(body.toolInputs) ?? {})), \"toolInputs\");\n return {\n attachmentIds,\n headers,\n metadata,\n ...(requestedModelId ? { requestedModelId } : {}),\n toolInputs: toolInputs as Readonly<Record<string, Readonly<Record<string, unknown>>>>,\n };\n}\n\nexport function promptForRequest(messages: Agents24UIMessage[]): string {\n const message = messages.at(-1);\n if (!message || message.role !== \"user\") {\n throw requestError(\n \"UNSUPPORTED_SUBMIT_SHAPE\",\n \"Agents24 submit requires the latest message to be a user message.\",\n );\n }\n const unsupported = message.parts.find((part) => part.type !== \"text\");\n if (unsupported) {\n throw requestError(\n \"UNSUPPORTED_MESSAGE_PART\",\n `Agents24 does not accept AI SDK user part type: ${unsupported.type}`,\n );\n }\n const value = message.parts\n .map((part) => part.type === \"text\" ? part.text : \"\")\n .join(\"\\n\")\n .trim();\n if (!value) {\n throw requestError(\"EMPTY_USER_MESSAGE\", \"Agents24 requires a non-empty user text message.\");\n }\n return value;\n}\n"],"mappings":";AAEO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EAET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AE,MAAM,iCAAiC,MAAM,cAAc;AAAA,QAC/D;AAAA,MACF;AACA,YAAM,WAAW,MAAM,WAAW,KAAK,MAAM,MAAM;AACnD,UAAI,CAAC,SAAU,QAAO;AACtB,UAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,cAAM,IAAI,mBAAmB,0CAA0C;AAAA,UACrE,MAAM;AAAA,UACN,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AACA,UACE,CAAC,SAAS,SACP,SAAS,WAAW,eACpB,SAAS,WAAW,YACpB,SAAS,WAAW,eACpB,SAAS,WAAW,UACvB;AACA,eAAO;AAAA,MACT;AACA,aAAO,OAAO;AAAA,QACZ,QAAQ,MAAM;AAAA,QACd,iBAAiB,SAAS;AAAA,QAC1B,WAAW,SAAS;AAAA,QACpB,WAAW;AAAA,QACX,SAAS,CAAC,YAAY,QAAQ,OAAO,KAAK,OAAO;AAAA,UAC/C,OAAO,SAAS;AAAA,UAChB,GAAI,SAAS,WAAW,OAAO,CAAC,IAAI,EAAE,QAAQ,SAAS,OAAO;AAAA,UAC9D,SAAS,SAAS;AAAA,QACpB,GAAG,OAAO;AAAA,MACZ,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["record"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/event-mapper.ts","../src/state-store.ts","../src/transport.ts","../src/request-policy.ts"],"sourcesContent":["export type Agents24AiSdkErrorKind = \"capability\" | \"request\" | \"state\" | \"unsupported\";\n\nexport class Agents24AiSdkError extends Error {\n readonly code: string;\n readonly kind: Agents24AiSdkErrorKind;\n\n constructor(message: string, options: { code: string; kind: Agents24AiSdkErrorKind }) {\n super(message);\n this.name = \"Agents24AiSdkError\";\n this.code = options.code;\n this.kind = options.kind;\n }\n}\n\nexport function requestError(code: string, message: string): Agents24AiSdkError {\n return new Agents24AiSdkError(message, { code, kind: \"request\" });\n}\n","import type { RuntimeEvent } from \"@agents24/client\";\nimport type { UIMessageChunk } from \"ai\";\nimport type { Agents24MessageMetadata } from \"./types.js\";\n\nconst record = (value: unknown): Record<string, unknown> | null =>\n value && typeof value === \"object\" && !Array.isArray(value) ? value as Record<string, unknown> : null;\nconst text = (value: unknown): string | null => typeof value === \"string\" && value.length > 0 ? value : null;\n\nfunction safeWebUrl(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n try {\n const parsed = new URL(value);\n return parsed.protocol === \"https:\" || parsed.protocol === \"http:\" ? parsed.toString() : null;\n } catch {\n return null;\n }\n}\n\nfunction dataChunk(name: string, data: unknown, id?: string): UIMessageChunk {\n return {\n type: `data-agents24-${name}`,\n data,\n ...(id ? { id } : {}),\n } as UIMessageChunk;\n}\n\nexport class Agents24EventMapper {\n private cursor: number | null = null;\n private finished = false;\n private responseCompletion?: import(\"@agents24/client/protocol\").ResponseCompletion;\n private reasoningOpen = false;\n private runId: string | null = null;\n private started = false;\n private textOpen = false;\n private threadId: string | null;\n private readonly toolCalls = new Set<string>();\n private readonly toolOutputs = new Set<string>();\n private status: string | undefined;\n\n constructor(\n private readonly messageId: string,\n threadId?: string | null,\n ) {\n this.threadId = threadId ?? null;\n }\n\n get state(): Agents24MessageMetadata {\n return {\n responseCompletion: this.responseCompletion,\n cursor: this.cursor,\n runId: this.runId,\n threadId: this.threadId,\n ...(this.status ? { status: this.status } : {}),\n };\n }\n\n private ensureStarted(): UIMessageChunk[] {\n if (this.started) return [];\n this.started = true;\n return [\n { type: \"start\", messageId: this.messageId, messageMetadata: this.state },\n { type: \"start-step\" },\n ];\n }\n\n private text(value: string, id: string): UIMessageChunk[] {\n const chunks: UIMessageChunk[] = [];\n if (!this.textOpen) {\n this.textOpen = true;\n chunks.push({ type: \"text-start\", id });\n }\n if (value) chunks.push({ type: \"text-delta\", id, delta: value });\n return chunks;\n }\n\n private reasoning(value: string, id: string): UIMessageChunk[] {\n const chunks: UIMessageChunk[] = [];\n if (!this.reasoningOpen) {\n this.reasoningOpen = true;\n chunks.push({ type: \"reasoning-start\", id });\n }\n if (value) chunks.push({ type: \"reasoning-delta\", id, delta: value });\n return chunks;\n }\n\n private toolInput(block: Record<string, unknown>, fallbackId: string): UIMessageChunk[] {\n const tool = record(block.tool) || block;\n const toolCallId = text(tool.toolCallId) || text(tool.tool_call_id) || fallbackId;\n const toolName = text(tool.action) || text(tool.title) || text(block.display_name) || \"tool\";\n if (this.toolCalls.has(toolCallId)) return [];\n this.toolCalls.add(toolCallId);\n return [{\n type: \"tool-input-available\",\n toolCallId,\n toolName,\n input: tool.input ?? block.input ?? {},\n providerExecuted: true,\n dynamic: true,\n ...(text(tool.title) || text(block.display_name) ? { title: text(tool.title) || text(block.display_name) || undefined } : {}),\n }];\n }\n\n private toolOutput(block: Record<string, unknown>, fallbackId: string): UIMessageChunk[] {\n const tool = record(block.tool) || block;\n const toolCallId = text(tool.toolCallId) || text(tool.tool_call_id) || fallbackId;\n const chunks = this.toolInput(block, fallbackId);\n if (this.toolOutputs.has(toolCallId)) return chunks;\n this.toolOutputs.add(toolCallId);\n const failed = [\"failed\", \"error\"].includes(String(block.status || \"\").toLocaleLowerCase());\n chunks.push(failed\n ? { type: \"tool-output-error\", toolCallId, errorText: text(tool.error) || text(block.error) || \"Tool execution failed.\", providerExecuted: true, dynamic: true }\n : { type: \"tool-output-available\", toolCallId, output: tool.output ?? block.output ?? block, providerExecuted: true, dynamic: true });\n return chunks;\n }\n\n private mapBlock(block: Record<string, unknown>, fallbackId: string): UIMessageChunk[] {\n const kind = String(block.kind || \"unsupported\");\n const id = text(block.id) || fallbackId;\n const chunks: UIMessageChunk[] = [dataChunk(\"response-block\", block, id)];\n if (kind === \"assistant_text\" && !this.textOpen && !this.responseCompletion) {\n chunks.push(...this.text(text(block.text) || \"\", `${this.runId || \"run\"}-text`));\n } else if (kind === \"reasoning_note\" && !this.reasoningOpen) {\n chunks.push(...this.reasoning(text(block.description) || text(block.label) || \"\", `${this.runId || \"run\"}-reasoning`));\n } else if (kind === \"tool_call\") {\n chunks.push(...this.toolOutput(block, id));\n } else if (kind === \"source\") {\n const url = safeWebUrl(block.url);\n if (url) chunks.push({ type: \"source-url\", sourceId: id, url, ...(text(block.title) ? { title: text(block.title) || undefined } : {}) });\n } else if (kind === \"citation\") {\n chunks.push(dataChunk(\"citation\", block, id));\n } else if (kind === \"ui_blocks\") {\n chunks.push(dataChunk(\"ui-blocks\", block, id));\n } else if (kind === \"hitl_request\") {\n chunks.push(dataChunk(\"hitl\", block, id));\n } else if (kind === \"mcp_authorization\") {\n chunks.push(dataChunk(\"mcp\", block, id));\n } else if (kind === \"attachment\") {\n chunks.push(dataChunk(\"attachment\", block, id));\n } else if (kind === \"error\") {\n chunks.push({ type: \"error\", errorText: text(record(block.error)?.message) || text(block.text) || \"The run failed.\" });\n } else if (kind === \"user_message\") {\n chunks.push(dataChunk(\"unsupported\", { feature: \"terminal-user-message-block\", block }, id));\n }\n return chunks;\n }\n\n private terminal(finishReason: \"error\" | \"other\" | \"stop\", metadata: Agents24MessageMetadata): UIMessageChunk[] {\n if (this.finished) return [];\n this.finished = true;\n this.status = metadata.status;\n const chunks: UIMessageChunk[] = [];\n if (this.textOpen) chunks.push({ type: \"text-end\", id: `${this.runId || \"run\"}-text` });\n if (this.reasoningOpen) chunks.push({ type: \"reasoning-end\", id: `${this.runId || \"run\"}-reasoning` });\n chunks.push({ type: \"finish-step\" });\n chunks.push({ type: \"finish\", finishReason, messageMetadata: metadata });\n return chunks;\n }\n\n map(event: RuntimeEvent): UIMessageChunk[] {\n this.runId = event.run_id;\n this.cursor = event.seq;\n const payload = event.payload;\n if (event.event === \"run.snapshot\" || event.event === \"run.accepted\") {\n const status = text(payload.status);\n if ([\"queued\", \"running\", \"waiting\", \"interrupted\", \"paused\", \"cancelling\", \"completed\", \"failed\", \"cancelled\"].includes(status || \"\")) this.status = status!;\n }\n this.threadId = text(payload.thread_id) || this.threadId;\n const chunks = this.ensureStarted();\n const completion = event.event === \"assistant.completed\" ? payload : payload.response_completion;\n chunks.push(dataChunk(\"event\", event, `${event.run_id}:${event.seq}`));\n chunks.push({ type: \"message-metadata\", messageMetadata: { ...this.state,\n ...(completion ? { responseCompletion: completion as import(\"@agents24/client/protocol\").ResponseCompletion } : {}) } });\n\n if (event.event === \"assistant.delta\" && !this.responseCompletion) {\n chunks.push(...this.text(text(payload.content) || \"\", `${event.run_id}-text`));\n } else if (event.event === \"reasoning.update\") {\n chunks.push(...this.reasoning(text(payload.delta) || text(payload.description) || text(payload.label) || \"\", `${event.run_id}-reasoning`));\n } else if (event.event === \"tool.started\") {\n chunks.push(...this.toolInput(payload, text(payload.tool_call_id) || `${event.run_id}:tool:${event.seq}`));\n } else if (event.event === \"tool.completed\" || event.event === \"tool.failed\" || event.event === \"tool.cancelled\") {\n chunks.push(...this.toolOutput({ ...payload, status: event.event.split(\".\")[1] }, text(payload.tool_call_id) || `${event.run_id}:tool:${event.seq}`));\n } else if (event.event === \"source.added\") {\n const source = record(payload.source) || payload;\n const sourceId = text(source.id) || `${event.run_id}:source:${event.seq}`;\n const url = safeWebUrl(source.url);\n if (url) chunks.push({ type: \"source-url\", sourceId, url, ...(text(source.title) ? { title: text(source.title) || undefined } : {}) });\n } else if (event.event === \"citation.added\") {\n chunks.push(dataChunk(\"citation\", record(payload.source) || payload, `${event.run_id}:citation:${event.seq}`));\n } else if (event.event === \"ui_blocks.updated\") {\n chunks.push(dataChunk(\"ui-blocks\", payload, `${event.run_id}:ui:${event.seq}`));\n } else if (event.event === \"context_window.updated\" || event.event === \"context.compression.updated\" || event.event === \"run_usage.updated\") {\n chunks.push(dataChunk(\"context\", payload, `${event.run_id}:context:${event.seq}`));\n } else if (event.event === \"hitl.requested\" || event.event === \"hitl.resolved\") {\n chunks.push(dataChunk(\"hitl\", payload, `${event.run_id}:hitl:${event.seq}`));\n } else if (event.event.startsWith(\"mcp.authorization.\")) {\n chunks.push(dataChunk(\"mcp\", payload, `${event.run_id}:mcp:${event.seq}`));\n } else if (event.event.startsWith(\"attachment.\")) {\n chunks.push(dataChunk(\"attachment\", payload, `${event.run_id}:attachment:${event.seq}`));\n }\n\n const blocks = Array.isArray(payload.response_blocks) ? payload.response_blocks : [];\n blocks.forEach((value, index) => {\n const block = record(value);\n if (block) chunks.push(...this.mapBlock(block, `${event.run_id}:block:${event.seq}:${index}`));\n });\n\n if (completion && typeof completion === \"object\" && \"completed_at\" in completion) {\n this.responseCompletion = completion as import(\"@agents24/client/protocol\").ResponseCompletion;\n if (this.textOpen) {\n chunks.push({ type: \"text-end\", id: `${this.runId || \"run\"}-text` });\n this.textOpen = false;\n }\n }\n if (event.event === \"run.completed\") chunks.push(...this.terminal(\"stop\", { ...this.state, status: \"completed\" }));\n if (event.event === \"run.failed\") chunks.push(...this.terminal(\"error\", { ...this.state, status: \"failed\" }));\n if (event.event === \"run.cancelled\") chunks.push(...this.terminal(\"other\", { ...this.state, status: \"cancelled\" }));\n if (event.event === \"run.waiting\" || event.event === \"run.interrupted\") chunks.push(...this.terminal(\"other\", { ...this.state, status: event.event.slice(4) }));\n if (event.event === \"run.paused\") chunks.push(...this.terminal(\"other\", { ...this.state, status: \"paused\" }));\n return chunks;\n }\n\n finalize(input: { aborted?: boolean; detached?: boolean; error?: string }): UIMessageChunk[] {\n const chunks = this.ensureStarted();\n if (input.aborted) {\n if (!this.finished) {\n this.finished = true;\n chunks.push({ type: \"abort\", reason: \"The local stream was stopped.\" });\n }\n return chunks;\n }\n if (input.error) {\n chunks.push({ type: \"error\", errorText: input.error });\n chunks.push(...this.terminal(\"error\", { ...this.state, status: \"failed\" }));\n return chunks;\n }\n chunks.push(...this.terminal(\"other\", { ...this.state, detached: Boolean(input.detached), status: this.status || \"detached\" }));\n return chunks;\n }\n}\n","import type { Agents24ChatStateStore, Agents24PersistedChatState } from \"./types.js\";\n\nexport function createInMemoryAgents24ChatStateStore(): Agents24ChatStateStore {\n const states = new Map<string, Agents24PersistedChatState>();\n return {\n async load(chatId) {\n const state = states.get(chatId);\n return state ? { ...state } : null;\n },\n async save(chatId, state) {\n states.set(chatId, { ...state });\n },\n };\n}\n","import { Agents24ClientError } from \"@agents24/client\";\nimport type { StreamResult } from \"@agents24/client\";\nimport type { ChatRequestOptions, UIMessageChunk } from \"ai\";\nimport { Agents24AiSdkError } from \"./errors.js\";\nimport { Agents24EventMapper } from \"./event-mapper.js\";\nimport { prepareAgents24Request, promptForRequest } from \"./request-policy.js\";\nimport { createInMemoryAgents24ChatStateStore } from \"./state-store.js\";\nimport type {\n Agents24AdapterTelemetryEvent,\n Agents24ChatTransport,\n Agents24MessageMetadata,\n Agents24PersistedChatState,\n CreateAgents24ChatTransportOptions,\n} from \"./types.js\";\n\nfunction defaultId(): string {\n const crypto = (globalThis as unknown as { crypto?: { randomUUID?: () => string } }).crypto;\n if (!crypto?.randomUUID) {\n throw new Agents24AiSdkError(\"A secure ID capability must be injected for this runtime.\", {\n code: \"MISSING_ID_CAPABILITY\",\n kind: \"capability\",\n });\n }\n return crypto.randomUUID();\n}\n\nfunction checkedId(createId: () => string): string {\n const value = createId();\n if (!value || /[\\r\\n\\0]/.test(value)) {\n throw new Agents24AiSdkError(\"The ID provider returned an invalid identifier.\", {\n code: \"INVALID_ID\",\n kind: \"capability\",\n });\n }\n return value;\n}\n\nfunction safeStreamError(error: unknown): string {\n if (error instanceof Agents24ClientError || error instanceof Agents24AiSdkError) return error.message;\n return \"The Agents24 stream failed.\";\n}\n\nfunction persistedState(\n messageId: string,\n metadata: Agents24MessageMetadata,\n status: Agents24PersistedChatState[\"status\"],\n): Agents24PersistedChatState {\n return {\n ...(metadata.responseCompletion ? { responseCompletion: metadata.responseCompletion } : {}),\n cursor: metadata.cursor ?? null,\n messageId,\n runId: metadata.runId ?? null,\n status,\n threadId: metadata.threadId ?? null,\n };\n}\n\nfunction terminalStatus(\n metadata: Agents24MessageMetadata,\n result: StreamResult,\n): Agents24PersistedChatState[\"status\"] {\n if (result.detached) return \"detached\";\n if (metadata.status === \"failed\") return \"failed\";\n if (metadata.status === \"cancelled\") return \"cancelled\";\n if (metadata.status === \"paused\") return \"paused\";\n if (metadata.status === \"waiting\" || metadata.status === \"interrupted\" || metadata.status === \"completed\") return metadata.status;\n return \"detached\";\n}\n\nfunction validState(value: Agents24PersistedChatState): boolean {\n return (\n typeof value.messageId === \"string\" &&\n value.messageId.length > 0 &&\n (value.runId === null || typeof value.runId === \"string\") &&\n (value.threadId === null || typeof value.threadId === \"string\") &&\n (value.cursor === null || Number.isSafeInteger(value.cursor)) &&\n [\"active\", \"cancelled\", \"completed\", \"detached\", \"failed\", \"paused\", \"waiting\", \"interrupted\"].includes(value.status)\n );\n}\n\nexport function createAgents24ChatTransport(\n options: CreateAgents24ChatTransportOptions,\n): Agents24ChatTransport {\n const createId = options.createId ?? defaultId;\n const stateStore = options.stateStore ?? createInMemoryAgents24ChatStateStore();\n\n const emit = async (event: Agents24AdapterTelemetryEvent): Promise<void> => {\n try {\n await options.telemetry?.emit(event);\n } catch {\n // Adapter telemetry never receives credentials and cannot affect the stream.\n }\n };\n\n const stream = (input: {\n chatId: string;\n initialThreadId?: string | null;\n messageId: string;\n operation: \"reconnect\" | \"submit\";\n abortSignal?: AbortSignal;\n content?: Agents24AdapterTelemetryEvent[\"content\"];\n execute(onEvent: Parameters<CreateAgents24ChatTransportOptions[\"client\"][\"chat\"][\"stream\"]>[1]): Promise<StreamResult>;\n }): ReadableStream<UIMessageChunk> => {\n const mapper = new Agents24EventMapper(input.messageId, input.initialThreadId);\n return new ReadableStream<UIMessageChunk>({\n async start(controller) {\n await emit({\n chatId: input.chatId,\n operation: input.operation,\n status: \"started\",\n ...(input.content ? { content: input.content } : {}),\n });\n try {\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, \"active\"),\n );\n const result = await input.execute(async (event) => {\n for (const chunk of mapper.map(event)) controller.enqueue(chunk);\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, [\"waiting\", \"interrupted\", \"paused\"].includes(mapper.state.status || \"\")\n ? mapper.state.status as Agents24PersistedChatState[\"status\"] : \"active\"),\n );\n });\n const status = terminalStatus(mapper.state, result);\n for (const chunk of mapper.finalize({\n aborted: input.abortSignal?.aborted,\n detached: result.detached,\n })) controller.enqueue(chunk);\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, status),\n );\n await emit({\n chatId: input.chatId,\n cursor: mapper.state.cursor,\n operation: input.operation,\n runId: mapper.state.runId,\n status: \"completed\",\n });\n } catch (error) {\n const aborted = input.abortSignal?.aborted ?? false;\n for (const chunk of mapper.finalize({\n aborted,\n ...(aborted ? {} : { error: safeStreamError(error) }),\n })) controller.enqueue(chunk);\n try {\n await stateStore.save(\n input.chatId,\n persistedState(input.messageId, mapper.state, aborted ? \"detached\" : \"failed\"),\n );\n } catch {\n // A failed state store is already represented by the safe stream error.\n }\n await emit({\n chatId: input.chatId,\n cursor: mapper.state.cursor,\n operation: input.operation,\n runId: mapper.state.runId,\n status: aborted ? \"completed\" : \"failed\",\n });\n } finally {\n controller.close();\n }\n },\n });\n };\n\n return {\n listThreadMessages(input) {\n return options.client.threads.messages.list(input);\n },\n queueMessage(input) {\n return options.client.threads.messages.submit({ ...input, mode: \"queue\" });\n },\n steerMessage(input) {\n if (!input.input.trim()) throw new Agents24AiSdkError(\"Steering requires text.\", { code: \"INVALID_STEER\", kind: \"state\" });\n return options.client.threads.messages.submit({ ...input, mode: \"steer\" });\n },\n editPendingMessage(input) {\n return options.client.threads.messages.edit(input);\n },\n async removePendingMessage(input) {\n await options.client.threads.messages.remove(input);\n },\n resumeQueue(input) {\n return options.client.threads.resumeQueue(input);\n },\n async sendMessages(input) {\n if (input.trigger === \"regenerate-message\") {\n throw new Agents24AiSdkError(\n \"Agents24 V0 does not support regenerate because the frozen client-runtime routes have no regenerate operation.\",\n { code: \"REGENERATE_UNSUPPORTED\", kind: \"unsupported\" },\n );\n }\n const prepared = prepareAgents24Request(input, options.requestPolicy);\n const prompt = promptForRequest(input.messages);\n const previous = await stateStore.load(input.chatId);\n if (previous && !validState(previous)) {\n throw new Agents24AiSdkError(\"Stored Agents24 chat state is invalid.\", {\n code: \"INVALID_CHAT_STATE\",\n kind: \"state\",\n });\n }\n if (!previous?.threadId && input.messages.length > 1) {\n throw new Agents24AiSdkError(\n \"Conversation history requires persisted Agents24 thread state; client history is never replayed as forged runtime history.\",\n { code: \"CHAT_STATE_REQUIRED\", kind: \"state\" },\n );\n }\n const responseMessageId = checkedId(createId);\n const clientSubmissionId = checkedId(createId);\n const idempotencyKey = checkedId(createId);\n const content = options.requestPolicy?.includePromptAndToolContentInTelemetry\n ? { prompt, toolInputs: prepared.toolInputs }\n : undefined;\n return stream({\n chatId: input.chatId,\n ...(previous?.threadId ? { initialThreadId: previous.threadId } : {}),\n messageId: responseMessageId,\n operation: \"submit\",\n ...(input.abortSignal ? { abortSignal: input.abortSignal } : {}),\n ...(content ? { content } : {}),\n execute: (onEvent) => options.client.chat.stream({\n clientSubmissionId,\n input: prompt,\n attachmentIds: prepared.attachmentIds,\n headers: prepared.headers,\n idempotencyKey,\n metadata: prepared.metadata,\n ...(previous?.threadId ? { threadId: previous.threadId } : {}),\n ...(prepared.requestedModelId ? { requestedModelId: prepared.requestedModelId } : {}),\n toolInputs: prepared.toolInputs,\n ...(input.abortSignal ? { signal: input.abortSignal } : {}),\n }, onEvent),\n });\n },\n\n async reconnectToStream(input) {\n const prepared = prepareAgents24Request(input, options.requestPolicy);\n if (\n prepared.attachmentIds.length ||\n Object.keys(prepared.metadata).length ||\n prepared.requestedModelId ||\n Object.keys(prepared.toolInputs).length\n ) {\n throw new Agents24AiSdkError(\n \"Reconnect accepts allowlisted headers only; run input is immutable after submission.\",\n { code: \"RECONNECT_OPTIONS_UNSUPPORTED\", kind: \"unsupported\" },\n );\n }\n const previous = await stateStore.load(input.chatId);\n if (!previous) return null;\n if (!validState(previous)) {\n throw new Agents24AiSdkError(\"Stored Agents24 chat state is invalid.\", {\n code: \"INVALID_CHAT_STATE\",\n kind: \"state\",\n });\n }\n if (\n !previous.runId\n || previous.status === \"completed\"\n || previous.status === \"failed\"\n || previous.status === \"cancelled\"\n || previous.status === \"paused\"\n ) {\n return null;\n }\n return stream({\n chatId: input.chatId,\n initialThreadId: previous.threadId,\n messageId: previous.messageId,\n operation: \"reconnect\",\n execute: (onEvent) => options.client.runs.attach({\n runId: previous.runId as string,\n ...(previous.cursor === null ? {} : { cursor: previous.cursor }),\n headers: prepared.headers,\n }, onEvent),\n });\n },\n };\n}\n","import { ATTACHMENT_RUNTIME_LIMITS } from \"@agents24/client\";\nimport type { ChatRequestOptions } from \"ai\";\nimport { requestError } from \"./errors.js\";\nimport type { Agents24RequestPolicy, Agents24UIMessage } from \"./types.js\";\n\nconst RESERVED_KEYS = new Set([\n \"agent\", \"agentid\", \"agentversion\", \"agentversionid\", \"authorization\", \"clientid\",\n \"cursor\", \"deployment\", \"deploymentid\", \"dpop\", \"identity\", \"origin\", \"refreshgrant\",\n \"runid\", \"session\", \"sessionid\", \"tenant\", \"tenantid\", \"token\", \"userid\", \"version\",\n]);\nconst RESERVED_HEADERS = new Set([\n \"authorization\", \"cookie\", \"dpop\", \"host\", \"origin\", \"proxy-authorization\",\n \"sec-fetch-site\", \"x-agent-id\", \"x-agent-version\", \"x-agents24-deployment-id\",\n \"x-client-id\", \"x-deployment-id\", \"x-forwarded-host\", \"x-refresh-grant\", \"x-run-id\", \"x-session-id\",\n]);\n\nfunction normalizedKey(value: string): string {\n return value.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n}\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction assertNoReservedFields(value: unknown, path: string): void {\n const object = record(value);\n if (!object) return;\n for (const [key, child] of Object.entries(object)) {\n if (RESERVED_KEYS.has(normalizedKey(key))) {\n throw requestError(\n \"RESERVED_REQUEST_FIELD\",\n `Agents24 reserved request field cannot be overridden: ${path}${key}`,\n );\n }\n assertNoReservedFields(child, `${path}${key}.`);\n }\n}\n\nfunction allowedRecord(value: unknown, allowed: ReadonlySet<string>, label: string): Record<string, unknown> {\n const input = record(value);\n if (!input) {\n if (value === undefined) return {};\n throw requestError(\"INVALID_REQUEST_OPTIONS\", `Agents24 ${label} must be an object.`);\n }\n assertNoReservedFields(input, `${label}.`);\n const output: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(input)) {\n if (!allowed.has(key)) {\n throw requestError(\n \"REQUEST_FIELD_NOT_ALLOWLISTED\",\n `Agents24 ${label} field is not allowlisted: ${key}`,\n );\n }\n output[key] = child;\n }\n return output;\n}\n\nfunction headerEntries(headers: ChatRequestOptions[\"headers\"]): Array<[string, string]> {\n if (!headers) return [];\n if (typeof (headers as Headers).forEach === \"function\") {\n const output: Array<[string, string]> = [];\n (headers as Headers).forEach((value, key) => output.push([key, value]));\n return output;\n }\n return Object.entries(headers as Record<string, string>);\n}\n\nexport type PreparedAgents24Request = {\n attachmentIds: string[];\n headers: Readonly<Record<string, string>>;\n metadata: Readonly<Record<string, unknown>>;\n requestedModelId?: string;\n toolInputs: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n};\n\nexport function prepareAgents24Request(\n options: ChatRequestOptions,\n policy: Agents24RequestPolicy | undefined,\n): PreparedAgents24Request {\n const allowedBody = new Set(policy?.allowedBodyFields ?? [\"attachmentIds\", \"requestedModelId\", \"toolInputs\"]);\n const allowedHeaders = new Set((policy?.allowedHeaders ?? []).map((name) => name.toLowerCase()));\n const allowedMetadata = new Set(policy?.allowedMetadataFields ?? []);\n const body = allowedRecord(options.body, allowedBody, \"body\");\n const metadata = allowedRecord(options.metadata, allowedMetadata, \"metadata\");\n const headers: Record<string, string> = {};\n for (const [rawName, value] of headerEntries(options.headers)) {\n const name = rawName.toLowerCase();\n if (RESERVED_HEADERS.has(name)) {\n throw requestError(\"RESERVED_REQUEST_HEADER\", `Agents24 reserved header cannot be overridden: ${rawName}`);\n }\n if (!allowedHeaders.has(name)) {\n throw requestError(\"REQUEST_HEADER_NOT_ALLOWLISTED\", `Agents24 header is not allowlisted: ${rawName}`);\n }\n if (/[\\r\\n\\0]/.test(value)) {\n throw requestError(\"INVALID_REQUEST_HEADER\", `Agents24 header contains invalid characters: ${rawName}`);\n }\n headers[name] = value;\n }\n const attachmentIds = body.attachmentIds === undefined\n ? []\n : Array.isArray(body.attachmentIds) && body.attachmentIds.every((item) => typeof item === \"string\" && item.length > 0)\n ? body.attachmentIds\n : (() => { throw requestError(\"INVALID_ATTACHMENT_IDS\", \"Agents24 attachmentIds must be a string array.\"); })();\n if (attachmentIds.length > ATTACHMENT_RUNTIME_LIMITS.max_attachments_per_turn) {\n throw requestError(\"TOO_MANY_ATTACHMENTS\", \"Too many Agents24 attachment IDs.\");\n }\n const requestedModelId = body.requestedModelId === undefined\n ? undefined\n : typeof body.requestedModelId === \"string\" && body.requestedModelId.length > 0\n ? body.requestedModelId\n : (() => { throw requestError(\"INVALID_MODEL_ID\", \"Agents24 requestedModelId must be a non-empty string.\"); })();\n const toolInputs = body.toolInputs === undefined\n ? {}\n : allowedRecord(body.toolInputs, new Set(Object.keys(record(body.toolInputs) ?? {})), \"toolInputs\");\n return {\n attachmentIds,\n headers,\n metadata,\n ...(requestedModelId ? { requestedModelId } : {}),\n toolInputs: toolInputs as Readonly<Record<string, Readonly<Record<string, unknown>>>>,\n };\n}\n\nexport function promptForRequest(messages: Agents24UIMessage[]): string {\n const message = messages.at(-1);\n if (!message || message.role !== \"user\") {\n throw requestError(\n \"UNSUPPORTED_SUBMIT_SHAPE\",\n \"Agents24 submit requires the latest message to be a user message.\",\n );\n }\n const unsupported = message.parts.find((part) => part.type !== \"text\");\n if (unsupported) {\n throw requestError(\n \"UNSUPPORTED_MESSAGE_PART\",\n `Agents24 does not accept AI SDK user part type: ${unsupported.type}`,\n );\n }\n const value = message.parts\n .map((part) => part.type === \"text\" ? part.text : \"\")\n .join(\"\\n\")\n .trim();\n if (!value) {\n throw requestError(\"EMPTY_USER_MESSAGE\", \"Agents24 requires a non-empty user text message.\");\n }\n return value;\n}\n"],"mappings":";AAEO,IAAM,qBAAN,cAAiC,MAA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AS,cAAc,UACvB,OAAO,KAAK,SAAS,QAAQ,EAAE,UAC/B,SAAS,oBACT,OAAO,KAAK,SAAS,UAAU,EAAE,QACjC;AACA,cAAM,IAAI;AAAA,UACR;AAAA,UACA,EAAE,MAAM,iCAAiC,MAAM,cAAc;AAAA,QAC/D;AAAA,MACF;AACA,YAAM,WAAW,MAAM,WAAW,KAAK,MAAM,MAAM;AACnD,UAAI,CAAC,SAAU,QAAO;AACtB,UAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,cAAM,IAAI,mBAAmB,0CAA0C;AAAA,UACrE,MAAM;AAAA,UACN,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AACA,UACE,CAAC,SAAS,SACP,SAAS,WAAW,eACpB,SAAS,WAAW,YACpB,SAAS,WAAW,eACpB,SAAS,WAAW,UACvB;AACA,eAAO;AAAA,MACT;AACA,aAAO,OAAO;AAAA,QACZ,QAAQ,MAAM;AAAA,QACd,iBAAiB,SAAS;AAAA,QAC1B,WAAW,SAAS;AAAA,QACpB,WAAW;AAAA,QACX,SAAS,CAAC,YAAY,QAAQ,OAAO,KAAK,OAAO;AAAA,UAC/C,OAAO,SAAS;AAAA,UAChB,GAAI,SAAS,WAAW,OAAO,CAAC,IAAI,EAAE,QAAQ,SAAS,OAAO;AAAA,UAC9D,SAAS,SAAS;AAAA,QACpB,GAAG,OAAO;AAAA,MACZ,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["record"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agents24/ai-sdk",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "Vercel AI SDK v7 ChatTransport adapter for Agents24 client runtimes.",
5
5
  "keywords": [
6
6
  "agents24",
@@ -46,7 +46,7 @@
46
46
  "prepack": "pnpm run build && pnpm run check:boundaries"
47
47
  },
48
48
  "dependencies": {
49
- "@agents24/client": "0.2.18"
49
+ "@agents24/client": "0.2.19"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "ai": ">=7.0.0 <8.0.0"