{"version":3,"sources":["../src/domain/model-context/model-context.ts","../src/domain/model-context/context-item/context-item.ts","../src/domain/model-context/context-item/item-content/item-content.ts","../src/domain/model-context/context-item/item-content/input-text.ts","../src/domain/model-context/context-item/client-item/user-message.ts","../src/domain/model-context/context-item/client-item/developer-message.ts","../src/domain/model-context/context-item/item-content/output-text.ts","../src/domain/model-context/context-item/model-item/model-message.ts","../src/domain/model-context/context-item/model-item/function-call.ts","../src/domain/model-context/context-item/model-item/reasoning.ts","../src/domain/generative-model/request-validation/structured-output.ts","../src/domain/model-context/context-item/client-item/function-call-output.ts","../src/domain/generative-model/token-usage.ts","../src/infrastructure/mcp/mcp-client.ts","../src/infrastructure/mcp/mcp-tool-registry.ts","../src/infrastructure/repository/in-memory-model-context-repository.ts","../src/domain/model-context/context-item/client-item/system-message.ts","../src/domain/agentic-environment/participant.ts","../src/domain/agentic-environment/errors/base-error.ts","../src/domain/agentic-environment/agentic-environment.ts","../src/domain/model-context/semantic-event/semantic-event.ts","../src/domain/agentic-environment/inference/response.ts","../src/application/services/inference-runner.ts","../src/application/use-cases/run-inference.ts","../src/application/use-cases/execute-function-call.ts","../src/application/services/function-call-runner.ts","../src/application/participants/participant.ts","../src/application/use-cases/send-message.ts","../src/infrastructure/providers/anthropic/endpoints/anthropic-messages-mapper.ts","../src/infrastructure/providers/anthropic/endpoints/anthropic-messages.ts","../src/infrastructure/providers/openai/endpoints/openai-responses.ts","../src/domain/model-context/context-item/item-content/summary-text.ts","../src/infrastructure/providers/openai/endpoints/openai-responses-mapper.ts","../src/infrastructure/providers/gemini/endpoints/gemini-generate-content.ts","../src/infrastructure/providers/gemini/endpoints/gemini-generate-content-mapper.ts","../src/infrastructure/providers/openai/endpoints/openai-chat-completions-mapper.ts","../src/infrastructure/providers/openai/endpoints/openai-chat-completions.ts","../src/infrastructure/providers/anthropic/models/claude-4-6-sonnet.ts","../src/infrastructure/providers/anthropic/models/claude-4-8-opus.ts","../src/infrastructure/providers/anthropic/models/claude-4-7-opus.ts","../src/infrastructure/providers/gemini/models/gemini-3-5-flash.ts","../src/infrastructure/providers/gemini/models/gemini-3-1-pro.ts","../src/infrastructure/providers/deepseek/models/deepseek-v4-flash.ts","../src/infrastructure/providers/deepseek/models/deepseek-v4-pro.ts","../src/infrastructure/providers/openai/models/gpt-5-4.ts","../src/infrastructure/providers/openai/models/gpt-5-4-mini.ts","../src/infrastructure/providers/openai/models/gpt-5-4-nano.ts","../src/infrastructure/providers/openai/models/gpt-5-5.ts","../src/infrastructure/providers/anthropic/models/claude-4-5-haiku.ts","../src/infrastructure/repository/generative-model-repository.ts","../src/domain/generative-model/request-validation/reasoning-effort.ts","../src/domain/generative-model/request-validation/tool-calling.ts","../src/domain/generative-model/request-validation/streaming.ts","../src/domain/generative-model/request-validation/context.ts","../src/domain/generative-model/request-validation/inference-request-validator.ts","../src/index.ts"],"sourcesContent":["import type { ContextItem } from \"@domain/model-context/context-item/context-item\"\n\nexport class ModelContext {\n\treadonly id: string\n\treadonly projectId: string\n\treadonly items: ContextItem[]\n\n\tconstructor(id: string, projectId: string, items: ContextItem[]) {\n\t\tthis.projectId = projectId\n\t\tthis.id = id\n\t\tthis.items = items\n\t}\n\n\taddContextItem(item: ContextItem): ModelContext {\n\t\tthis.items.push(item)\n\t\treturn this\n\t}\n\n\tapplyModelOutput(items: ContextItem[]): ModelContext {\n\t\tfor (const item of items) {\n\t\t\tconst itemType = item.getType()\n\t\t\tif (itemType !== \"function_call\" && itemType !== \"message\" && itemType !== \"reasoning\") {\n\t\t\t\tthrow new Error(`Invalid item type: ${itemType}`)\n\t\t\t}\n\t\t}\n\t\tthis.items.push(...items)\n\t\treturn this\n\t}\n\n\tgetItems(): ContextItem[] {\n\t\treturn this.items\n\t}\n\n\tgetLastItem(): ContextItem {\n\t\tif (this.items.length === 0) {\n\t\t\tthrow new Error(\"No items in context\")\n\t\t}\n\t\treturn this.items[this.items.length - 1]\n\t}\n\n\tstatic create(projectId: string): ModelContext {\n\t\tconst id = crypto.randomUUID()\n\t\treturn new ModelContext(id, projectId, [])\n\t}\n\n\tstatic rehydrate(data: { id: string; projectId: string; items: ContextItem[] }): ModelContext {\n\t\treturn new ModelContext(data.id, data.projectId, data.items)\n\t}\n}\n","export abstract class ContextItem {\n\tabstract readonly type: string\n\n\tgetType(): string {\n\t\treturn this.type\n\t}\n}\n","export abstract class ItemContent {\n\tabstract readonly type: string\n}\n","import { ItemContent } from \"@domain/model-context/context-item/item-content/item-content\"\n\nexport class InputText extends ItemContent {\n\treadonly type = \"input_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic create(text: string): InputText {\n\t\treturn new InputText(text)\n\t}\n\n\tstatic rehydrate(data: { text: string }): InputText {\n\t\treturn new InputText(data.text)\n\t}\n}\n","import { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\n\nexport class UserMessageItem extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"user\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): UserMessageItem {\n\t\tconst content = InputText.create(text)\n\t\treturn new UserMessageItem(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): UserMessageItem {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new UserMessageItem(content)\n\t}\n}\n","import { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\nimport { ContextItem } from \"@domain/model-context/context-item/context-item\"\n\nexport class DeveloperMessageItem extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"developer\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): DeveloperMessageItem {\n\t\tconst content = InputText.create(text)\n\t\treturn new DeveloperMessageItem(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): DeveloperMessageItem {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new DeveloperMessageItem(content)\n\t}\n}\n","import { ItemContent } from \"@domain/model-context/context-item/item-content/item-content\"\n\nexport class OutputText extends ItemContent {\n\treadonly type = \"output_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic rehydrate(data: { text: string }): OutputText {\n\t\treturn new OutputText(data.text)\n\t}\n}\n","import { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { OutputText } from \"@domain/model-context/context-item/item-content/output-text\"\n\nexport class ModelMessageItem extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"assistant\"\n\treadonly content: OutputText\n\n\tprivate constructor(content: OutputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic rehydrate(data: { text: string }): ModelMessageItem {\n\t\tconst content = OutputText.rehydrate(data)\n\t\treturn new ModelMessageItem(content)\n\t}\n}\n","import { ContextItem } from \"@domain/model-context/context-item/context-item\"\n\nexport class FunctionCallItem extends ContextItem {\n\treadonly type = \"function_call\"\n\treadonly callId: string\n\treadonly name: string\n\treadonly args: string\n\n\tprivate constructor(callId: string, name: string, args: string) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.name = name\n\t\tthis.args = args\n\t}\n\n\tstatic rehydrate(data: { callId: string; name: string; args: string }): FunctionCallItem {\n\t\treturn new FunctionCallItem(data.callId, data.name, data.args)\n\t}\n}\n","import type { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\nimport type { SummaryText } from \"@domain/model-context/context-item/item-content/summary-text\"\nimport { ContextItem } from \"@domain/model-context/context-item/context-item\"\n\nexport class ReasoningItem extends ContextItem {\n\treadonly type = \"reasoning\"\n\treadonly content: InputText | undefined\n\treadonly encryptedContent: string | undefined\n\treadonly summary: SummaryText[]\n\n\tprivate constructor(\n\t\tcontent: InputText | undefined,\n\t\tencryptedContent?: string | undefined,\n\t\tsummary: SummaryText[] = [],\n\t) {\n\t\tsuper()\n\t\tthis.content = content\n\t\tthis.encryptedContent = encryptedContent\n\t\tthis.summary = summary\n\t}\n\n\tstatic rehydrate(data: {\n\t\tcontent: InputText | undefined\n\t\tencryptedContent: string | undefined\n\t\tsummary: SummaryText[]\n\t}): ReasoningItem {\n\t\treturn new ReasoningItem(data.content, data.encryptedContent, data.summary)\n\t}\n}\n","import type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName, ModelSpecification } from \"../generative-model\"\nimport type { RequestValidationRule } from \"./rule\"\n\nexport type StructuredOutputFormat = {\n\tname?: string\n\tschema: Record<string, any>\n\tstrict?: boolean\n}\n\nexport class StructuredOutputValidation implements RequestValidationRule {\n\treadonly name = \"structured-output\"\n\n\tisValid(inferenceParams: InferenceParams<ModelName>, model: ModelSpecification): boolean {\n\t\tif (inferenceParams.structuredOutput === undefined) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn model.supportsStructuredOutput\n\t}\n}\n","import { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\n\nexport class FunctionCallOutputItem extends ContextItem {\n\treadonly type = \"function_call_output\"\n\treadonly callId: string\n\treadonly output: InputText\n\n\tprivate constructor(callId: string, output: InputText) {\n\t\tsuper()\n\t\tthis.callId = callId\n\t\tthis.output = output\n\t}\n\n\tstatic create(callId: string, output: string): FunctionCallOutputItem {\n\t\tconst outputText = InputText.create(output)\n\t\treturn new FunctionCallOutputItem(callId, outputText)\n\t}\n\n\tstatic rehydrate(data: { callId: string; output: InputText }): FunctionCallOutputItem {\n\t\treturn new FunctionCallOutputItem(data.callId, data.output)\n\t}\n}\n","export class InputTokenDetails {\n\treadonly cached_tokens: number\n\n\tconstructor(cached_tokens: number) {\n\t\tthis.cached_tokens = cached_tokens\n\t}\n}\n\nexport class OutputTokenDetails {\n\treadonly reasoning_tokens: number\n\n\tconstructor(reasoning_tokens: number) {\n\t\tthis.reasoning_tokens = reasoning_tokens\n\t}\n}\n\nexport class TokenUsage {\n\treadonly inputTokens: number\n\treadonly outputTokens: number\n\treadonly totalTokens: number\n\treadonly inputTokenDetails: InputTokenDetails\n\treadonly outputTokenDetails: OutputTokenDetails\n\n\tconstructor(\n\t\tinputTokens: number,\n\t\toutputTokens: number,\n\t\ttotalTokens: number,\n\t\tinputTokenDetails: InputTokenDetails,\n\t\toutputTokenDetails: OutputTokenDetails,\n\t) {\n\t\tthis.inputTokens = inputTokens\n\t\tthis.outputTokens = outputTokens\n\t\tthis.totalTokens = totalTokens\n\t\tthis.inputTokenDetails = inputTokenDetails\n\t\tthis.outputTokenDetails = outputTokenDetails\n\t}\n}\n","import { Client } from \"@modelcontextprotocol/sdk/client/index.js\"\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\"\n\nexport interface McpServerConfig {\n\t/** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */\n\turl: string\n\t/** Bearer token sent as `Authorization: Bearer <token>` (e.g. a GitHub token). */\n\tauthToken?: string\n\t/** Extra headers merged into every request (overridden by `authToken` for Authorization). */\n\theaders?: Record<string, string>\n\t/** Client name reported to the server (defaults to \"mozaik\"). */\n\tname?: string\n}\n\nexport interface McpToolSpec {\n\tname: string\n\tdescription: string\n\t/** JSON Schema for the tool's arguments (maps 1:1 to FunctionTool.parameters). */\n\tinputSchema: Record<string, any>\n}\n\n/**\n * A thin wrapper over the MCP TypeScript SDK using the Streamable HTTP transport — what\n * remote MCP servers (e.g. GitHub's `api.githubcopilot.com/mcp/`) speak. One client per\n * server; lazily connects on first use. Infrastructure-only: the domain never sees this.\n */\nexport class McpClient {\n\tprivate readonly client: Client\n\tprivate readonly transport: StreamableHTTPClientTransport\n\tprivate connected = false\n\n\tconstructor(private readonly config: McpServerConfig) {\n\t\tconst headers: Record<string, string> = { ...(config.headers ?? {}) }\n\t\tif (config.authToken) headers.Authorization = `Bearer ${config.authToken}`\n\t\tthis.transport = new StreamableHTTPClientTransport(\n\t\t\tnew URL(config.url),\n\t\t\tObject.keys(headers).length > 0 ? { requestInit: { headers } } : undefined,\n\t\t)\n\t\tthis.client = new Client({ name: config.name ?? \"mozaik\", version: \"1.0.0\" }, { capabilities: {} })\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.connected) return\n\t\tawait this.client.connect(this.transport)\n\t\tthis.connected = true\n\t}\n\n\t/** The tools this server exposes. */\n\tasync listTools(): Promise<McpToolSpec[]> {\n\t\tawait this.connect()\n\t\tconst res = await this.client.listTools()\n\t\treturn (res.tools ?? []).map((t) => ({\n\t\t\tname: t.name,\n\t\t\tdescription: t.description ?? \"\",\n\t\t\tinputSchema: (t.inputSchema as Record<string, any>) ?? { type: \"object\", properties: {} },\n\t\t}))\n\t}\n\n\t/** Call a tool by name; returns its text output. Throws if the server flags an error. */\n\tasync callTool(name: string, args: Record<string, any>): Promise<string> {\n\t\tawait this.connect()\n\t\tconst res = await this.client.callTool({ name, arguments: args ?? {} })\n\t\tconst text = extractText(res)\n\t\tif ((res as { isError?: boolean }).isError) {\n\t\t\tthrow new Error(`MCP tool \"${name}\" failed: ${text || \"unknown error\"}`)\n\t\t}\n\t\treturn text\n\t}\n\n\tasync close(): Promise<void> {\n\t\tif (!this.connected) return\n\t\ttry {\n\t\t\tawait this.client.close()\n\t\t} catch {\n\t\t\t// best-effort teardown — the transport may already be gone\n\t\t}\n\t\tthis.connected = false\n\t}\n}\n\n/** Concatenate the text blocks of an MCP tool result (ignores non-text content). */\nfunction extractText(res: unknown): string {\n\tconst content = (res as { content?: unknown }).content\n\tif (!Array.isArray(content)) return \"\"\n\treturn content\n\t\t.filter((c): c is { type: \"text\"; text: string } => (c as { type?: string })?.type === \"text\" && typeof (c as { text?: unknown }).text === \"string\")\n\t\t.map((c) => c.text)\n\t\t.join(\"\\n\")\n}\n","import type { FunctionTool } from \"@domain/generative-model/tool\"\nimport { McpClient, type McpServerConfig } from \"./mcp-client.js\"\n\n/** The slice of an MCP client the registry needs — lets tests inject a fake. */\nexport interface McpClientLike {\n\tlistTools(): Promise<Array<{ name: string; description: string; inputSchema: Record<string, any> }>>\n\tcallTool(name: string, args: Record<string, any>): Promise<string>\n\tclose(): Promise<void>\n}\n\n/**\n * Connects to one or more MCP servers and exposes their tools as mozaik `FunctionTool`s.\n * Each tool's `invoke()` proxies the call back to its MCP server. Because they are plain\n * FunctionTools, every provider mapper and the existing function-call loop handle them\n * with no changes — MCP support adds no new tool type and touches no provider code.\n *\n * `strict` is false: MCP servers publish arbitrary JSON Schemas that won't always satisfy\n * a provider's strict function-calling mode.\n */\nexport class McpToolRegistry {\n\tprivate readonly clients: McpClientLike[] = []\n\n\tconstructor(\n\t\tprivate readonly servers: McpServerConfig[],\n\t\tprivate readonly createClient: (config: McpServerConfig) => McpClientLike = (config) => new McpClient(config),\n\t) {}\n\n\t/** Discover every tool across the configured servers, as FunctionTools ready to pass to a model. */\n\tasync discoverTools(): Promise<FunctionTool[]> {\n\t\tconst tools: FunctionTool[] = []\n\t\tfor (const server of this.servers) {\n\t\t\tconst client = this.createClient(server)\n\t\t\tthis.clients.push(client)\n\t\t\tfor (const spec of await client.listTools()) {\n\t\t\t\ttools.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: spec.name,\n\t\t\t\t\tdescription: spec.description,\n\t\t\t\t\tparameters: spec.inputSchema,\n\t\t\t\t\tstrict: false,\n\t\t\t\t\tinvoke: (args: unknown) => client.callTool(spec.name, (args as Record<string, any>) ?? {}),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn tools\n\t}\n\n\t/** Close all underlying MCP connections. */\n\tasync close(): Promise<void> {\n\t\tawait Promise.all(this.clients.map((c) => c.close()))\n\t}\n}\n","import { ModelContext } from \"@domain/model-context/model-context\"\nimport type { ModelContextRepository } from \"@domain/model-context/model-context-repository\"\n\nexport class InMemoryModelContextRepository implements ModelContextRepository {\n\tprivate readonly store = new Map<string, ModelContext>()\n\tprivate readonly projectIndex = new Map<string, Set<string>>()\n\n\tasync save(context: ModelContext): Promise<void> {\n\t\tconst existing = this.store.get(context.id)\n\t\tif (existing && existing.projectId !== context.projectId) {\n\t\t\tconst prevSet = this.projectIndex.get(existing.projectId)\n\t\t\tprevSet?.delete(existing.id)\n\t\t\tif (prevSet && prevSet.size === 0) this.projectIndex.delete(existing.projectId)\n\t\t}\n\n\t\tthis.store.set(context.id, this.clone(context))\n\n\t\tlet set = this.projectIndex.get(context.projectId)\n\t\tif (!set) {\n\t\t\tset = new Set<string>()\n\t\t\tthis.projectIndex.set(context.projectId, set)\n\t\t}\n\t\tset.add(context.id)\n\t}\n\n\tasync get(id: string): Promise<ModelContext> {\n\t\tconst context = this.store.get(id)\n\t\tif (!context) {\n\t\t\tthrow new Error(`Context not found: ${id}`)\n\t\t}\n\t\treturn this.clone(context)\n\t}\n\n\tasync getByProjectId(projectId: string): Promise<ModelContext[]> {\n\t\tconst ids = this.projectIndex.get(projectId)\n\t\tif (!ids || ids.size === 0) return []\n\t\treturn [...ids]\n\t\t\t.map((id) => this.store.get(id))\n\t\t\t.filter((c): c is ModelContext => Boolean(c))\n\t\t\t.map((c) => this.clone(c))\n\t}\n\n\tprivate clone(context: ModelContext): ModelContext {\n\t\treturn ModelContext.rehydrate({\n\t\t\tid: context.id,\n\t\t\tprojectId: context.projectId,\n\t\t\titems: [...context.getItems()],\n\t\t})\n\t}\n}\n","import { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\nimport { ContextItem } from \"@domain/model-context/context-item/context-item\"\n\nexport class SystemMessageItem extends ContextItem {\n\treadonly type = \"message\"\n\treadonly role = \"system\"\n\treadonly content: InputText\n\n\tprivate constructor(content: InputText) {\n\t\tsuper()\n\t\tthis.content = content\n\t}\n\n\tstatic create(text: string): SystemMessageItem {\n\t\tconst content = InputText.create(text)\n\t\treturn new SystemMessageItem(content)\n\t}\n\n\tstatic rehydrate(data: { text: string }): SystemMessageItem {\n\t\tconst content = InputText.rehydrate(data)\n\t\treturn new SystemMessageItem(content)\n\t}\n}\n","import type { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport type { AgenticEnvironment } from \"./agentic-environment\"\nimport type { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport type { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport type { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport type { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport type { AgenticError } from \"./errors/base-error\"\n\ntype ParticipantClassConstructor = new (...args: any[]) => Participant\n\nexport abstract class Participant {\n\tprivate environments: AgenticEnvironment[] = []\n\tprotected listens: ParticipantClassConstructor[] = []\n\tprivate active: Map<AgenticEnvironment, boolean> = new Map()\n\n\tjoin(environment: AgenticEnvironment) {\n\t\tif (this.isJoinedTo(environment)) {\n\t\t\treturn\n\t\t}\n\t\tenvironment.subscribe(this)\n\t\tthis.environments.push(environment)\n\t\tthis.active.set(environment, true)\n\t}\n\n\tleave(environment: AgenticEnvironment) {\n\t\tif (!this.isJoinedTo(environment)) {\n\t\t\treturn\n\t\t}\n\t\tenvironment.unsubscribe(this)\n\t\tthis.environments = this.environments.filter((e) => e !== environment)\n\t\tthis.active.delete(environment)\n\t}\n\n\tisJoinedTo(environment: AgenticEnvironment): boolean {\n\t\treturn this.environments.includes(environment)\n\t}\n\n\tgetEnvironments(): AgenticEnvironment[] {\n\t\treturn this.environments\n\t}\n\n\tgetListeners(): ParticipantClassConstructor[] {\n\t\treturn this.listens\n\t}\n\n\tgetEnvironmentState(environment: AgenticEnvironment) {\n\t\treturn this.active.get(environment)\n\t}\n\n\tmarkInactive(environment: AgenticEnvironment) {\n\t\tif (this.active.has(environment)) {\n\t\t\tthis.active.set(environment, false)\n\t\t}\n\t}\n\n\tmarkActive(environment: AgenticEnvironment) {\n\t\tif (this.active.has(environment)) {\n\t\t\tthis.active.set(environment, true)\n\t\t}\n\t}\n\n\tabstract onParticipantJoined(participant: Participant): Promise<void> | void\n\n\tabstract onParticipantLeft(participant: Participant): Promise<void> | void\n\n\tabstract onJoined(): Promise<void> | void\n\n\tabstract onLeft(): Promise<void> | void\n\n\tabstract onFunctionCall(item: FunctionCallItem): Promise<void> | void\n\n\tabstract onExternalFunctionCall(source: Participant, item: FunctionCallItem): Promise<void> | void\n\n\tabstract onFunctionCallOutput(item: FunctionCallOutputItem): Promise<void> | void\n\n\tabstract onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): Promise<void> | void\n\n\tabstract onReasoning(item: ReasoningItem): Promise<void> | void\n\n\tabstract onExternalReasoning(source: Participant, item: ReasoningItem): Promise<void> | void\n\n\tabstract onModelMessage(item: ModelMessageItem): Promise<void> | void\n\n\tabstract onExternalModelMessage(source: Participant, item: ModelMessageItem): Promise<void> | void\n\n\tabstract onMessage(message: string): Promise<void> | void\n\n\tabstract onInternalEvent(item: SemanticEvent<unknown>): Promise<void> | void\n\n\tabstract onExternalEvent(source: Participant, item: SemanticEvent<unknown>): Promise<void> | void\n\n\tabstract onError(error: AgenticError): void\n\n\tabstract onParticipantError(source: Participant, error: AgenticError): void\n}\n","import type { AgenticEnvironment } from \"../agentic-environment\"\nimport type { Participant } from \"../participant\"\n\ninterface AgenticErrorOpts {\n\tmessage: string\n\tstack?: string\n\tsource?: Participant\n\tenviornment?: AgenticEnvironment\n}\n\nexport class AgenticError extends Error {\n\tprivate source?: Participant\n\tprivate environment?: AgenticEnvironment\n\n\tconstructor({ message, stack, source, enviornment }: AgenticErrorOpts) {\n\t\tsuper()\n\n\t\tthis.message = message\n\t\tthis.stack = stack\n\t\tthis.source = source\n\t\tthis.environment = enviornment\n\t}\n\n\tgetSource() {\n\t\treturn this.source\n\t}\n\n\tgetEnvironment() {\n\t\treturn this.environment\n\t}\n}\n","import type { Participant } from \"@domain/agentic-environment/participant\"\nimport type { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport type { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport type { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport type { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport type { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport { AgenticError } from \"./errors/base-error\"\n\nexport interface AgenticEnvironmentOptions {\n\tsilent?: boolean\n}\n\nexport class AgenticEnvironment {\n\tprotected subscribers: Participant[] = []\n\tprivate name?: string\n\tprivate options?: AgenticEnvironmentOptions\n\tprivate showLogs?: boolean\n\n\tconstructor(name?: string, opts?: AgenticEnvironmentOptions) {\n\t\tthis.name = name\n\t\tthis.options = opts\n\n\t\tthis.showLogs = this.options?.silent !== false\n\t}\n\n\tsubscribe(participant: Participant) {\n\t\tthis.subscribers.push(participant)\n\t\tfor (const subscriber of this.subscribers) {\n\t\t\tif (participant === subscriber) {\n\t\t\t\tparticipant.onJoined()\n\t\t\t} else {\n\t\t\t\tsubscriber.onParticipantJoined(participant)\n\t\t\t}\n\t\t}\n\t}\n\n\tunsubscribe(participant: Participant) {\n\t\tconst exists = this.subscribers.includes(participant)\n\n\t\tif (!exists) {\n\t\t\treturn\n\t\t}\n\n\t\tparticipant.onLeft()\n\n\t\tthis.subscribers = this.subscribers.filter((p) => p !== participant)\n\n\t\tfor (const subscriber of this.subscribers) {\n\t\t\tsubscriber.onParticipantLeft(participant)\n\t\t}\n\t}\n\n\tdeliverFunctionCall(source: Participant, item: FunctionCallItem): void {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\tinternal: (src) => src.onFunctionCall(item),\n\t\t\texternal: (sub) => sub.onExternalFunctionCall(source, item),\n\t\t})\n\t}\n\n\tdeliverModelMessage(source: Participant, item: ModelMessageItem): void {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\tinternal: (src) => src.onModelMessage(item),\n\t\t\texternal: (sub) => sub.onExternalModelMessage(source, item),\n\t\t})\n\t}\n\n\tdeliverReasoning(source: Participant, item: ReasoningItem): void {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\tinternal: (src) => src.onReasoning(item),\n\t\t\texternal: (sub) => sub.onExternalReasoning(source, item),\n\t\t})\n\t}\n\n\tdeliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\tinternal: (src) => src.onFunctionCallOutput(item),\n\t\t\texternal: (sub) => sub.onExternalFunctionCallOutput(source, item),\n\t\t})\n\t}\n\n\tdeliverMessage(source: Participant, message: string): void {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\texternal: (sub) => sub.onMessage(message),\n\t\t})\n\t}\n\n\tdeliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\tinternal: (src) => src.onInternalEvent(item),\n\t\t\texternal: (sub) => sub.onExternalEvent(source, item),\n\t\t})\n\t}\n\n\tdeliverError(source: Participant, error: AgenticError) {\n\t\tthis.deliverToSubscribers(source, {\n\t\t\tinternal: (src) => {\n\t\t\t\ttry {\n\t\t\t\t\tsrc.onError(error)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (this.showLogs) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`[AgenticEnvironment] Participant.onError() failed. Reason: ${error as Error}\\n ${JSON.stringify({ error }, null, 2)}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tsrc.markInactive(this)\n\t\t\t\t}\n\t\t\t},\n\t\t\texternal: (sub) => {\n\t\t\t\ttry {\n\t\t\t\t\tsub.onParticipantError(source, error)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (this.showLogs) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`[AgenticEnvironment] Participant.onError() failed. Reason: ${error as Error}\\n ${JSON.stringify({ error }, null, 2)}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n\n\tprivate getListeningParticipants(source: Participant) {\n\t\treturn this.subscribers.filter(\n\t\t\t(sub) =>\n\t\t\t\tsub !== source &&\n\t\t\t\t(sub.getListeners().length === 0 || sub.getListeners().some((listener) => source instanceof listener)),\n\t\t)\n\t}\n\n\tprivate deliverToSubscribers(\n\t\tsource: Participant,\n\t\thandlers: { internal?: (src: Participant) => void; external: (sub: Participant) => void },\n\t) {\n\t\tconst authorizedListeners = this.getListeningParticipants(source)\n\n\t\tfor (const subscriber of this.subscribers) {\n\t\t\tconst isActive = subscriber.getEnvironmentState(this)\n\n\t\t\tif (isActive) {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscriber === source) {\n\t\t\t\t\t\thandlers?.internal?.(subscriber)\n\t\t\t\t\t} else if (authorizedListeners.includes(subscriber)) {\n\t\t\t\t\t\thandlers?.external?.(subscriber)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.handleError(subscriber, error as Error)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleError(subscriber: Participant, error: Error) {\n\t\tif (error instanceof AgenticError) {\n\t\t\treturn this.deliverError(subscriber, error)\n\t\t}\n\n\t\tconst agenticError = new AgenticError({\n\t\t\tmessage: error.message,\n\t\t\tstack: error.stack,\n\t\t\tenviornment: this,\n\t\t\tsource: subscriber,\n\t\t})\n\n\t\treturn this.deliverError(subscriber, agenticError)\n\t}\n}\n","export class SemanticEvent<T> {\n\treadonly type: string\n\treadonly data: T\n\n\tconstructor(type: string, data: T) {\n\t\tthis.type = type\n\t\tthis.data = data\n\t}\n\n\tgetType(): string {\n\t\treturn this.type\n\t}\n}\n","import type { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport type { TokenUsage } from \"@domain/generative-model/token-usage\"\n\nexport class InferenceResponse {\n\treadonly contextItems: ContextItem[]\n\treadonly tokenUsage?: TokenUsage\n\n\tconstructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined) {\n\t\tthis.contextItems = contextItems\n\t\tthis.tokenUsage = tokenUsage\n\t}\n}\n","import type { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport type { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport type { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport type { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport type { Endpoint } from \"@domain/generative-model/endpoint\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\n\ntype InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>\n\nexport interface InferenceRunner {\n\trun(request: InferenceParams<ModelName>, endpoint: Endpoint): AsyncIterable<InferenceItem>\n}\n\nexport class StreamingInference implements InferenceRunner {\n\tasync *run(request: InferenceParams<ModelName>, endpoint: Endpoint): AsyncIterable<InferenceItem> {\n\t\tif (request.signal?.aborted) {\n\t\t\treturn\n\t\t}\n\t\tyield* endpoint.stream(request, request.signal)\n\t}\n}\n\nexport class NonStreamingInference implements InferenceRunner {\n\tasync *run(request: InferenceParams<ModelName>, endpoint: Endpoint): AsyncIterable<InferenceItem> {\n\t\tif (request.signal?.aborted) {\n\t\t\treturn\n\t\t}\n\t\tconst response = await endpoint.infer(request)\n\t\tfor (const item of response.contextItems) {\n\t\t\tif (request.signal?.aborted) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tyield item as InferenceItem\n\t\t}\n\t}\n}\n","import { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { RunInferenceUseCase } from \"@domain/agentic-environment/use-cases/run-inference\"\nimport type { InferenceRunner } from \"@app/services/inference-runner\"\nimport { NonStreamingInference, StreamingInference } from \"@app/services/inference-runner\"\nimport type { InferenceRequestValidator } from \"@domain/generative-model/request-validation/inference-request-validator\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { GenerativeModelRepository } from \"@domain/generative-model/generative-model-repository\"\n\nexport class RunInference implements RunInferenceUseCase<ModelName> {\n\tconstructor(\n\t\tprivate readonly generativeModelRepository: GenerativeModelRepository,\n\t\tprivate readonly requestValidator: InferenceRequestValidator,\n\t) {}\n\n\tasync execute(inferenceParams: InferenceParams<ModelName>): Promise<void> {\n\t\tconst { caller, environment, signal } = inferenceParams\n\n\t\tconst generativeModel = await this.generativeModelRepository.getByModelName(inferenceParams.model)\n\n\t\tthis.requestValidator.validate(inferenceParams, generativeModel.specification)\n\n\t\tconst resolvedParams: InferenceParams<ModelName> = {\n\t\t\t...inferenceParams,\n\t\t\tmaxOutputTokens: inferenceParams.maxOutputTokens ?? generativeModel.specification.maxOutputTokens,\n\t\t}\n\n\t\tconst inferenceRunner: InferenceRunner = inferenceParams.streaming\n\t\t\t? new StreamingInference()\n\t\t\t: new NonStreamingInference()\n\n\t\tconst result = inferenceRunner.run(resolvedParams, generativeModel.endpoint)\n\n\t\tfor await (const item of result) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (item instanceof ReasoningItem) {\n\t\t\t\tenvironment.deliverReasoning(caller, item)\n\t\t\t} else if (item instanceof FunctionCallItem) {\n\t\t\t\tenvironment.deliverFunctionCall(caller, item)\n\t\t\t} else if (item instanceof ModelMessageItem) {\n\t\t\t\tenvironment.deliverModelMessage(caller, item)\n\t\t\t} else if (item instanceof SemanticEvent) {\n\t\t\t\tenvironment.deliverSemanticEvent(caller, item)\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { FunctionCallRunner } from \"@app/services/function-call-runner\"\nimport type { AgenticEnvironment } from \"@domain/agentic-environment/agentic-environment\"\nimport type { Participant } from \"@domain/agentic-environment/participant\"\nimport type { ExecuteFunctionCallUseCase } from \"@domain/agentic-environment/use-cases/execute-function-call\"\nimport type { Tool } from \"@domain/generative-model/tool\"\nimport type { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\n\nexport class ExecuteFunctionCall implements ExecuteFunctionCallUseCase {\n\tconstructor(private readonly functionCallRunner: FunctionCallRunner) {}\n\n\tasync execute(\n\t\tenvironment: AgenticEnvironment,\n\t\tfunctionCallItem: FunctionCallItem,\n\t\ttool: Tool,\n\t\tcaller: Participant,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> {\n\t\tconst stream = this.functionCallRunner.run(functionCallItem, tool, signal)\n\n\t\tfor await (const item of stream) {\n\t\t\tenvironment.deliverFunctionCallOutput(caller, item)\n\t\t}\n\t}\n}\n","import type { Tool } from \"@domain/generative-model/tool\"\nimport { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport type { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\n\nexport class FunctionCallRunner {\n\tasync *run(call: FunctionCallItem, tool: Tool, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem> {\n\t\tif (signal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tif (!tool) throw new Error(`Unknown tool: ${call.name}`)\n\n\t\tconst result = await tool.invoke(JSON.parse(call.args))\n\t\tyield FunctionCallOutputItem.create(call.callId, JSON.stringify(result))\n\t}\n}\n","import type { AgenticError } from \"@domain/agentic-environment/errors/base-error\"\nimport { Participant } from \"@domain/agentic-environment/participant\"\nimport type { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport type { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport type { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport type { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport type { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\n\nexport class BaseParticipant extends Participant {\n\tonFunctionCall(_item: FunctionCallItem) {}\n\tonExternalFunctionCall(_source: Participant, _item: FunctionCallItem) {}\n\tonFunctionCallOutput(_item: FunctionCallOutputItem) {}\n\tonExternalFunctionCallOutput(_source: Participant, _item: FunctionCallOutputItem) {}\n\tonReasoning(_item: ReasoningItem) {}\n\tonExternalReasoning(_source: Participant, _item: ReasoningItem) {}\n\tonModelMessage(_item: ModelMessageItem) {}\n\tonExternalModelMessage(_source: Participant, _item: ModelMessageItem) {}\n\tonMessage(_message: string) {}\n\tonJoined() {}\n\tonLeft() {}\n\tonParticipantJoined(_participant: Participant) {}\n\tonParticipantLeft(_participant: Participant) {}\n\tonInternalEvent(_item: SemanticEvent<unknown>) {}\n\tonExternalEvent(_source: Participant, _item: SemanticEvent<unknown>) {}\n\tonError(_error: AgenticError): void {}\n\tonParticipantError(_source: Participant, _error: AgenticError): void {}\n}\n","import type { AgenticEnvironment } from \"@domain/agentic-environment/agentic-environment\"\nimport type { Participant } from \"@domain/agentic-environment/participant\"\nimport type { SendMessageUseCase } from \"@domain/agentic-environment/use-cases/send-message\"\n\nexport class SendMessage implements SendMessageUseCase {\n\tasync execute(environment: AgenticEnvironment, message: string, caller: Participant): Promise<void> {\n\t\tif (!caller.isJoinedTo(environment)) {\n\t\t\tthrow new Error(\"Not joined to environment\")\n\t\t}\n\n\t\tenvironment.deliverMessage(caller, message)\n\t}\n}\n","import type { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport { DeveloperMessageItem } from \"@domain/model-context/context-item/client-item/developer-message\"\nimport { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport { SystemMessageItem } from \"@domain/model-context/context-item/client-item/system-message\"\nimport { UserMessageItem } from \"@domain/model-context/context-item/client-item/user-message\"\nimport { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\nimport { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\nimport type { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { InputTokenDetails, OutputTokenDetails, TokenUsage } from \"@domain/generative-model/token-usage\"\nimport type Anthropic from \"@anthropic-ai/sdk\"\n\nexport class AnthropicMessagesMapper implements InferenceEndpointMapper {\n\ttoRequest(inferenceParams: InferenceParams<ModelName>) {\n\t\tconst { messages, system } = this.mapContextItems(inferenceParams)\n\t\tconst outputConfig: any = {}\n\n\t\tconst request: any = {\n\t\t\tmodel: inferenceParams.model,\n\t\t\tmessages,\n\t\t}\n\n\t\trequest.max_tokens = inferenceParams.maxOutputTokens!\n\n\t\tif (system) {\n\t\t\trequest.system = system\n\t\t}\n\n\t\tif (inferenceParams.tools && inferenceParams.tools.length > 0) {\n\t\t\trequest.tools = inferenceParams.tools.map((tool) => ({\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tinput_schema: tool.parameters,\n\t\t\t}))\n\t\t}\n\n\t\tif (inferenceParams.structuredOutput) {\n\t\t\toutputConfig.format = {\n\t\t\t\ttype: \"json_schema\",\n\t\t\t\tjson_schema: inferenceParams.structuredOutput.schema,\n\t\t\t}\n\t\t}\n\n\t\tif (inferenceParams.reasoningEffort) {\n\t\t\trequest.thinking = { type: \"adaptive\" }\n\t\t\toutputConfig.effort = inferenceParams.reasoningEffort\n\t\t}\n\n\t\tif (Object.keys(outputConfig).length > 0) {\n\t\t\trequest.output_config = outputConfig\n\t\t}\n\n\t\tif (inferenceParams.streaming) {\n\t\t\trequest.stream = inferenceParams.streaming\n\t\t}\n\n\t\treturn request\n\t}\n\n\ttoResponse(response: any): InferenceResponse {\n\t\tconst contextItems = this.extractContextItems(response)\n\t\tconst tokenUsage = this.extractTokenUsage(response)\n\t\treturn new InferenceResponse(contextItems, tokenUsage)\n\t}\n\n\tprivate addContentBlock(messages: any[], role: \"user\" | \"assistant\", block: any): void {\n\t\tconst lastMessage = messages[messages.length - 1]\n\t\tif (lastMessage?.role === role) {\n\t\t\tlastMessage.content.push(block)\n\t\t\treturn\n\t\t}\n\n\t\tmessages.push({\n\t\t\trole: role,\n\t\t\tcontent: [block],\n\t\t})\n\t}\n\n\tmapContextItems(inferenceParams: InferenceParams<ModelName>): { messages: any[]; system?: string } {\n\t\tconst context = inferenceParams.context\n\t\tconst messages: any[] = []\n\t\tconst system: string[] = []\n\n\t\tfor (const item of context.getItems()) {\n\t\t\tif (item instanceof DeveloperMessageItem || item instanceof SystemMessageItem) {\n\t\t\t\tsystem.push(item.content.text)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof UserMessageItem) {\n\t\t\t\tthis.addContentBlock(messages, \"user\", { type: \"text\", text: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof ModelMessageItem) {\n\t\t\t\tthis.addContentBlock(messages, \"assistant\", { type: \"text\", text: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof ReasoningItem) {\n\t\t\t\tthis.addContentBlock(messages, \"assistant\", {\n\t\t\t\t\ttype: \"thinking\",\n\t\t\t\t\tthinking: item.content?.text ?? \"\",\n\t\t\t\t\tsignature: item.encryptedContent ?? \"\",\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallItem) {\n\t\t\t\tlet input: any\n\t\t\t\ttry {\n\t\t\t\t\tinput = JSON.parse(item.args)\n\t\t\t\t} catch {\n\t\t\t\t\tinput = item.args\n\t\t\t\t}\n\t\t\t\tthis.addContentBlock(messages, \"assistant\", {\n\t\t\t\t\ttype: \"tool_use\",\n\t\t\t\t\tid: item.callId,\n\t\t\t\t\tname: item.name,\n\t\t\t\t\tinput: input,\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallOutputItem) {\n\t\t\t\tthis.addContentBlock(messages, \"user\", {\n\t\t\t\t\ttype: \"tool_result\",\n\t\t\t\t\ttool_use_id: item.callId,\n\t\t\t\t\tcontent: item.output.text,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tmessages: messages,\n\t\t\tsystem: system.length > 0 ? system.join(\"\\n\\n\") : undefined,\n\t\t}\n\t}\n\n\textractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined {\n\t\tif (!response.usage) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn new TokenUsage(\n\t\t\tresponse.usage.input_tokens,\n\t\t\tresponse.usage.output_tokens,\n\t\t\tresponse.usage.input_tokens + response.usage.output_tokens,\n\t\t\tnew InputTokenDetails(\n\t\t\t\t(response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0),\n\t\t\t),\n\t\t\tnew OutputTokenDetails(0),\n\t\t)\n\t}\n\n\textractContextItems(response: Anthropic.Messages.Message): ContextItem[] {\n\t\tconst items: ContextItem[] = []\n\n\t\tfor (const block of response.content as any[]) {\n\t\t\tif (block.type === \"text\") {\n\t\t\t\titems.push(ModelMessageItem.rehydrate({ text: block.text }))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (block.type === \"tool_use\") {\n\t\t\t\titems.push(\n\t\t\t\t\tFunctionCallItem.rehydrate({\n\t\t\t\t\t\tcallId: block.id,\n\t\t\t\t\t\tname: block.name,\n\t\t\t\t\t\targs: JSON.stringify(block.input ?? {}),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (block.type === \"thinking\") {\n\t\t\t\titems.push(\n\t\t\t\t\tReasoningItem.rehydrate({\n\t\t\t\t\t\tcontent: block.thinking ? InputText.rehydrate({ text: block.thinking }) : undefined,\n\t\t\t\t\t\tencryptedContent: block.signature,\n\t\t\t\t\t\tsummary: [],\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn items\n\t}\n}\n","import type { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport type { Endpoint } from \"@domain/generative-model/endpoint\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\nimport { AnthropicMessagesMapper } from \"./anthropic-messages-mapper\"\nimport Anthropic from \"@anthropic-ai/sdk\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\n\n/**\n * Native Anthropic adapter on the `@anthropic-ai/sdk` (`messages.create`).\n * Maps domain context to Anthropic's `messages`/`content` blocks shape,\n * system prompt, tools, adaptive thinking, and structured output config.\n */\nexport class AnthropicMessages implements Endpoint {\n\tendpointMapper: InferenceEndpointMapper\n\tprivate readonly client: Anthropic\n\n\tconstructor(endpointMapper: InferenceEndpointMapper = new AnthropicMessagesMapper()) {\n\t\tthis.endpointMapper = endpointMapper\n\t\tthis.client = new Anthropic()\n\t}\n\n\tasync infer(inferenceParams: InferenceParams<ModelName>): Promise<InferenceResponse> {\n\t\tconst inferenceRequest = this.endpointMapper.toRequest(inferenceParams)\n\t\tconst response = await this.client.messages.create(inferenceRequest)\n\n\t\treturn this.endpointMapper.toResponse(response)\n\t}\n\n\tasync *stream(\n\t\tinferenceParams: InferenceParams<ModelName>,\n\t\tsignal?: AbortSignal,\n\t): AsyncIterable<SemanticEvent<unknown>> {\n\t\tconst inferenceRequest = this.endpointMapper.toRequest(inferenceParams)\n\t\tconst stream: any = await this.client.messages.create(inferenceRequest)\n\n\t\tfor await (const event of stream) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tyield new SemanticEvent(event.type, event)\n\t\t}\n\t}\n}\n","import { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport type { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport type { Endpoint } from \"@domain/generative-model/endpoint\"\nimport OpenAI from \"openai\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport { OpenAIResponsesMapper } from \"./openai-responses-mapper\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\n\nexport class OpenAIResponses implements Endpoint {\n\tendpointMapper: InferenceEndpointMapper\n\tprivate readonly client: OpenAI\n\n\tconstructor(endpointMapper: InferenceEndpointMapper = new OpenAIResponsesMapper()) {\n\t\tthis.endpointMapper = endpointMapper\n\t\tthis.client = new OpenAI()\n\t}\n\n\tasync infer(inferenceParams: InferenceParams<ModelName>): Promise<InferenceResponse> {\n\t\tconst request = this.endpointMapper.toRequest(inferenceParams)\n\t\tconst response = await this.client.responses.create(request)\n\n\t\treturn this.endpointMapper.toResponse(response)\n\t}\n\n\tasync *stream(\n\t\tinferenceParams: InferenceParams<ModelName>,\n\t\tsignal?: AbortSignal,\n\t): AsyncIterable<SemanticEvent<unknown>> {\n\t\tconst request = this.endpointMapper.toRequest(inferenceParams)\n\t\tconst response: any = await this.client.responses.create(request)\n\n\t\tfor await (const event of response) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tyield new SemanticEvent(event.type, event)\n\t\t}\n\t}\n}\n","import { ItemContent } from \"@domain/model-context/context-item/item-content/item-content\"\n\nexport class SummaryText extends ItemContent {\n\treadonly type = \"summary_text\"\n\n\tprivate constructor(public readonly text: string) {\n\t\tsuper()\n\t}\n\n\tstatic rehydrate(data: { text: string }): SummaryText {\n\t\treturn new SummaryText(data.text)\n\t}\n}\n","import type { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\nimport { DeveloperMessageItem } from \"@domain/model-context/context-item/client-item/developer-message\"\nimport { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport { SystemMessageItem } from \"@domain/model-context/context-item/client-item/system-message\"\nimport { UserMessageItem } from \"@domain/model-context/context-item/client-item/user-message\"\nimport { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport { SummaryText } from \"@domain/model-context/context-item/item-content/summary-text\"\nimport { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport type { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { InputTokenDetails, OutputTokenDetails, TokenUsage } from \"@domain/generative-model/token-usage\"\nimport type OpenAI from \"openai\"\n\nexport class OpenAIResponsesMapper implements InferenceEndpointMapper {\n\ttoRequest(inferenceParams: InferenceParams<ModelName>): any {\n\t\tconst request: any = {\n\t\t\tmodel: inferenceParams.model,\n\t\t\tinput: this.mapContextItems(inferenceParams),\n\t\t}\n\n\t\tif (inferenceParams.tools && inferenceParams.tools.length > 0) {\n\t\t\trequest.tools = inferenceParams.tools.map((tool) => ({\n\t\t\t\ttype: tool.type,\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tparameters: tool.parameters,\n\t\t\t}))\n\t\t}\n\n\t\tif (inferenceParams.reasoningEffort) {\n\t\t\trequest.reasoning = {\n\t\t\t\teffort: inferenceParams.reasoningEffort,\n\t\t\t}\n\t\t}\n\n\t\tif (inferenceParams.structuredOutput) {\n\t\t\tconst format = inferenceParams.structuredOutput\n\t\t\trequest.text = {\n\t\t\t\tformat: {\n\t\t\t\t\ttype: \"json_schema\",\n\t\t\t\t\tname: format.name ?? \"response\",\n\t\t\t\t\tschema: format.schema,\n\t\t\t\t\tstrict: format.strict ?? true,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tif (inferenceParams.streaming) {\n\t\t\trequest.stream = inferenceParams.streaming\n\t\t}\n\n\t\treturn request\n\t}\n\n\ttoResponse(response: any): InferenceResponse {\n\t\tconst contextItems = this.extractContextItems(response)\n\t\tconst tokenUsage = this.extractTokenUsage(response)\n\t\treturn new InferenceResponse(contextItems, tokenUsage)\n\t}\n\n\tmapContextItems(inferenceParams: InferenceParams<ModelName>): any[] {\n\t\tconst input: any[] = []\n\n\t\tfor (const item of inferenceParams.context.getItems()) {\n\t\t\tif (\n\t\t\t\titem instanceof DeveloperMessageItem ||\n\t\t\t\titem instanceof SystemMessageItem ||\n\t\t\t\titem instanceof UserMessageItem\n\t\t\t) {\n\t\t\t\tinput.push({\n\t\t\t\t\ttype: item.type,\n\t\t\t\t\trole: item.role,\n\t\t\t\t\tcontent: [{ type: \"input_text\", text: item.content.text }],\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof ModelMessageItem) {\n\t\t\t\tinput.push({\n\t\t\t\t\ttype: item.type,\n\t\t\t\t\trole: item.role,\n\t\t\t\t\tcontent: [{ type: \"output_text\", text: item.content.text }],\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallItem) {\n\t\t\t\tinput.push({\n\t\t\t\t\ttype: item.type,\n\t\t\t\t\tcall_id: item.callId,\n\t\t\t\t\tname: item.name,\n\t\t\t\t\targuments: item.args,\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallOutputItem) {\n\t\t\t\tinput.push({\n\t\t\t\t\ttype: item.type,\n\t\t\t\t\tcall_id: item.callId,\n\t\t\t\t\toutput: [{ type: \"input_text\", text: item.output.text }],\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof ReasoningItem) {\n\t\t\t\tconst reasoningInput: Record<string, unknown> = {\n\t\t\t\t\ttype: item.type,\n\t\t\t\t\tsummary: item.summary.map((summary) => ({ type: \"summary_text\", text: summary.text })),\n\t\t\t\t}\n\t\t\t\tif (item.encryptedContent !== undefined) {\n\t\t\t\t\treasoningInput.encrypted_content = item.encryptedContent\n\t\t\t\t}\n\t\t\t\tinput.push(reasoningInput)\n\t\t\t}\n\t\t}\n\n\t\treturn input\n\t}\n\n\textractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined {\n\t\tif (!response.usage) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn new TokenUsage(\n\t\t\tresponse.usage.input_tokens,\n\t\t\tresponse.usage.output_tokens,\n\t\t\tresponse.usage.total_tokens,\n\t\t\tnew InputTokenDetails(response.usage.input_tokens_details?.cached_tokens ?? 0),\n\t\t\tnew OutputTokenDetails(response.usage.output_tokens_details?.reasoning_tokens ?? 0),\n\t\t)\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\tconst items: ContextItem[] = []\n\n\t\tfor (const item of response.output ?? []) {\n\t\t\tif (item.type === \"message\" && item.role === \"assistant\") {\n\t\t\t\tconst firstContent = item.content?.[0]\n\t\t\t\tif (firstContent) {\n\t\t\t\t\titems.push(ModelMessageItem.rehydrate(firstContent as { text: string }))\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (item.type === \"function_call\") {\n\t\t\t\titems.push(\n\t\t\t\t\tFunctionCallItem.rehydrate({\n\t\t\t\t\t\tcallId: item.call_id,\n\t\t\t\t\t\tname: item.name,\n\t\t\t\t\t\targs: item.arguments,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (item.type === \"reasoning\") {\n\t\t\t\titems.push(\n\t\t\t\t\tReasoningItem.rehydrate({\n\t\t\t\t\t\tcontent: undefined,\n\t\t\t\t\t\tencryptedContent: item.encrypted_content,\n\t\t\t\t\t\tsummary: (item.summary ?? []).map((summary: { text: string }) =>\n\t\t\t\t\t\t\tSummaryText.rehydrate({ text: summary.text }),\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn items\n\t}\n}\n","import type { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport { GoogleGenAI } from \"@google/genai\"\nimport type { Endpoint } from \"@domain/generative-model/endpoint\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\nimport { GeminiGenerateContentMapper } from \"./gemini-generate-content-mapper\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\n\n/**\n * Native Gemini adapter on the `@google/genai` SDK (`generateContent` /\n * `generateContentStream`). Unlike an OpenAI-compat shim this maps our\n * domain context to Gemini's native `contents`/`parts` shape, system\n * instruction, `functionDeclarations`, and `thinkingConfig`, and reads\n * thought parts + native usage metadata back out. Another `ModelRuntime`\n * — no runner or port changes.\n */\nexport class GeminiGenerateContent implements Endpoint {\n\tendpointMapper: InferenceEndpointMapper\n\tprivate readonly client: GoogleGenAI\n\n\tconstructor(endpointMapper: InferenceEndpointMapper = new GeminiGenerateContentMapper()) {\n\t\tthis.endpointMapper = endpointMapper\n\t\tthis.client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY })\n\t}\n\n\tasync infer(inferenceParams: InferenceParams<ModelName>): Promise<InferenceResponse> {\n\t\tconst inferenceRequest = this.endpointMapper.toRequest(inferenceParams)\n\t\tconst response = await this.client.models.generateContent(inferenceRequest)\n\n\t\treturn this.endpointMapper.toResponse(response)\n\t}\n\n\tasync *stream(\n\t\tinferenceParams: InferenceParams<ModelName>,\n\t\tsignal?: AbortSignal,\n\t): AsyncIterable<SemanticEvent<unknown>> {\n\t\tconst inferenceRequest = this.endpointMapper.toRequest(inferenceParams)\n\t\tconst stream = await this.client.models.generateContentStream(inferenceRequest)\n\n\t\tfor await (const chunk of stream) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tyield new SemanticEvent(\"generate_content_chunk\", chunk)\n\t\t}\n\t}\n}\n","import type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\nimport { InputTokenDetails, OutputTokenDetails, TokenUsage } from \"@domain/generative-model/token-usage\"\nimport { DeveloperMessageItem } from \"@domain/model-context/context-item/client-item/developer-message\"\nimport { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport { SystemMessageItem } from \"@domain/model-context/context-item/client-item/system-message\"\nimport { UserMessageItem } from \"@domain/model-context/context-item/client-item/user-message\"\nimport type { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\nimport { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\n\nexport class GeminiGenerateContentMapper implements InferenceEndpointMapper {\n\ttoRequest(inferenceParams: InferenceParams<ModelName>) {\n\t\tconst { contents, systemInstruction } = this.mapContextItems(inferenceParams)\n\t\tconst config: any = {}\n\n\t\tif (systemInstruction) {\n\t\t\tconfig.systemInstruction = systemInstruction\n\t\t}\n\n\t\tif (inferenceParams.tools && inferenceParams.tools.length > 0) {\n\t\t\tconfig.tools = [\n\t\t\t\t{\n\t\t\t\t\tfunctionDeclarations: inferenceParams.tools.map((tool) => ({\n\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\t\tparametersJsonSchema: tool.parameters,\n\t\t\t\t\t})),\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\tif (inferenceParams.structuredOutput) {\n\t\t\tconfig.responseMimeType = \"application/json\"\n\t\t\tconfig.responseSchema = inferenceParams.structuredOutput.schema\n\t\t}\n\n\t\tif (inferenceParams.reasoningEffort) {\n\t\t\tconfig.thinkingConfig = {\n\t\t\t\tthinkingLevel: inferenceParams.reasoningEffort,\n\t\t\t\tincludeThoughts: true,\n\t\t\t}\n\t\t}\n\n\t\tconst request: any = {\n\t\t\tmodel: inferenceParams.model,\n\t\t\tcontents,\n\t\t\tconfig,\n\t\t}\n\n\t\tif (inferenceParams.streaming) {\n\t\t\trequest.stream = inferenceParams.streaming\n\t\t}\n\n\t\treturn request\n\t}\n\n\ttoResponse(response: any): InferenceResponse {\n\t\tconst contextItems = this.extractContextItems(response)\n\t\tconst tokenUsage = this.extractTokenUsage(response)\n\t\treturn new InferenceResponse(contextItems, tokenUsage)\n\t}\n\n\tmapContextItems(inferenceParams: InferenceParams<ModelName>): { contents: any[]; systemInstruction?: string } {\n\t\tconst context = inferenceParams.context\n\t\tconst contents: any[] = []\n\t\tconst system: string[] = []\n\t\tconst callNames = new Map<string, string>()\n\n\t\tfor (const item of context.getItems()) {\n\t\t\tif (item instanceof DeveloperMessageItem || item instanceof SystemMessageItem) {\n\t\t\t\tsystem.push(item.content.text)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof UserMessageItem) {\n\t\t\t\tthis.addPart(contents, \"user\", { text: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof ModelMessageItem) {\n\t\t\t\tthis.addPart(contents, \"model\", { text: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallItem) {\n\t\t\t\tcallNames.set(item.callId, item.name)\n\t\t\t\tlet args: any\n\t\t\t\ttry {\n\t\t\t\t\targs = JSON.parse(item.args)\n\t\t\t\t} catch {\n\t\t\t\t\targs = {}\n\t\t\t\t}\n\t\t\t\tthis.addPart(contents, \"model\", { functionCall: { id: item.callId, name: item.name, args } })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallOutputItem) {\n\t\t\t\tthis.addPart(contents, \"user\", {\n\t\t\t\t\tfunctionResponse: {\n\t\t\t\t\t\tid: item.callId,\n\t\t\t\t\t\tname: callNames.get(item.callId) ?? \"\",\n\t\t\t\t\t\tresponse: this.parseResponse(item.output.text),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcontents,\n\t\t\tsystemInstruction: system.length > 0 ? system.join(\"\\n\\n\") : undefined,\n\t\t}\n\t}\n\n\tprivate addPart(contents: any[], role: \"user\" | \"model\", part: any): void {\n\t\tconst last = contents[contents.length - 1]\n\t\tif (last?.role === role) {\n\t\t\tlast.parts.push(part)\n\t\t\treturn\n\t\t}\n\n\t\tcontents.push({ role, parts: [part] })\n\t}\n\n\tprivate parseResponse(output: string): any {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(output)\n\t\t\treturn parsed && typeof parsed === \"object\" ? parsed : { output }\n\t\t} catch {\n\t\t\treturn { output }\n\t\t}\n\t}\n\n\textractTokenUsage(response: any): TokenUsage | undefined {\n\t\tconst usage = response.usageMetadata\n\t\tif (!usage) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn new TokenUsage(\n\t\t\tusage.promptTokenCount ?? 0,\n\t\t\tusage.candidatesTokenCount ?? 0,\n\t\t\tusage.totalTokenCount ?? 0,\n\t\t\tnew InputTokenDetails(usage.cachedContentTokenCount ?? 0),\n\t\t\tnew OutputTokenDetails(usage.thoughtsTokenCount ?? 0),\n\t\t)\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\tconst items: ContextItem[] = []\n\t\tconst parts = response.candidates?.[0]?.content?.parts ?? []\n\n\t\tfor (const part of parts) {\n\t\t\tif (part.thought && part.text) {\n\t\t\t\titems.push(\n\t\t\t\t\tReasoningItem.rehydrate({\n\t\t\t\t\t\tcontent: InputText.rehydrate({ text: part.text }),\n\t\t\t\t\t\tencryptedContent: undefined,\n\t\t\t\t\t\tsummary: [],\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (part.text) {\n\t\t\t\titems.push(ModelMessageItem.rehydrate({ text: part.text }))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (part.functionCall) {\n\t\t\t\titems.push(\n\t\t\t\t\tFunctionCallItem.rehydrate({\n\t\t\t\t\t\tcallId: part.functionCall.id ?? \"\",\n\t\t\t\t\t\tname: part.functionCall.name,\n\t\t\t\t\t\targs: JSON.stringify(part.functionCall.args ?? {}),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn items\n\t}\n}\n","import type { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\nimport { DeveloperMessageItem } from \"@domain/model-context/context-item/client-item/developer-message\"\nimport { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport { SystemMessageItem } from \"@domain/model-context/context-item/client-item/system-message\"\nimport { UserMessageItem } from \"@domain/model-context/context-item/client-item/user-message\"\nimport { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport { InputText } from \"@domain/model-context/context-item/item-content/input-text\"\nimport { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport type { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { InputTokenDetails, OutputTokenDetails, TokenUsage } from \"@domain/generative-model/token-usage\"\n\nexport class OpenAIChatCompletionsMapper implements InferenceEndpointMapper {\n\ttoRequest(inferenceParams: InferenceParams<ModelName>) {\n\t\tconst request: any = {\n\t\t\tmodel: inferenceParams.model,\n\t\t\tmessages: this.mapContextItems(inferenceParams),\n\t\t}\n\n\t\tif (inferenceParams.tools && inferenceParams.tools.length > 0) {\n\t\t\trequest.tools = inferenceParams.tools.map((tool) => ({\n\t\t\t\ttype: \"function\",\n\t\t\t\tfunction: {\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t},\n\t\t\t}))\n\t\t}\n\n\t\tif (inferenceParams.reasoningEffort) {\n\t\t\trequest.reasoning_effort = inferenceParams.reasoningEffort\n\t\t}\n\n\t\tif (inferenceParams.streaming) {\n\t\t\trequest.stream = inferenceParams.streaming\n\t\t}\n\n\t\treturn request\n\t}\n\n\ttoResponse(response: any): InferenceResponse {\n\t\tconst contextItems = this.extractContextItems(response)\n\t\tconst tokenUsage = this.extractTokenUsage(response)\n\t\treturn new InferenceResponse(contextItems, tokenUsage)\n\t}\n\n\tmapContextItems(inferenceParams: InferenceParams<ModelName>): any[] {\n\t\tconst messages: any[] = []\n\n\t\tfor (const item of inferenceParams.context.getItems()) {\n\t\t\tif (item instanceof DeveloperMessageItem || item instanceof SystemMessageItem) {\n\t\t\t\tmessages.push({ role: \"system\", content: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof UserMessageItem) {\n\t\t\t\tmessages.push({ role: \"user\", content: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof ModelMessageItem) {\n\t\t\t\tmessages.push({ role: \"assistant\", content: item.content.text })\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallItem) {\n\t\t\t\tconst toolCall = {\n\t\t\t\t\tid: item.callId,\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tfunction: { name: item.name, arguments: item.args },\n\t\t\t\t}\n\t\t\t\tconst last = messages[messages.length - 1]\n\t\t\t\tif (last?.role === \"assistant\") {\n\t\t\t\t\tlast.tool_calls = last.tool_calls ?? []\n\t\t\t\t\tlast.tool_calls.push(toolCall)\n\t\t\t\t} else {\n\t\t\t\t\tmessages.push({ role: \"assistant\", content: null, tool_calls: [toolCall] })\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (item instanceof FunctionCallOutputItem) {\n\t\t\t\tmessages.push({ role: \"tool\", tool_call_id: item.callId, content: item.output.text })\n\t\t\t}\n\t\t}\n\n\t\treturn messages\n\t}\n\n\textractTokenUsage(response: any): TokenUsage | undefined {\n\t\tif (!response.usage) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn new TokenUsage(\n\t\t\tresponse.usage.prompt_tokens,\n\t\t\tresponse.usage.completion_tokens,\n\t\t\tresponse.usage.total_tokens,\n\t\t\tnew InputTokenDetails(response.usage.prompt_tokens_details?.cached_tokens ?? 0),\n\t\t\tnew OutputTokenDetails(response.usage.completion_tokens_details?.reasoning_tokens ?? 0),\n\t\t)\n\t}\n\n\textractContextItems(response: any): ContextItem[] {\n\t\tconst items: ContextItem[] = []\n\t\tconst message = response.choices?.[0]?.message\n\t\tif (!message) {\n\t\t\treturn items\n\t\t}\n\n\t\tif (message.reasoning_content) {\n\t\t\titems.push(\n\t\t\t\tReasoningItem.rehydrate({\n\t\t\t\t\tcontent: InputText.rehydrate({ text: message.reasoning_content }),\n\t\t\t\t\tencryptedContent: undefined,\n\t\t\t\t\tsummary: [],\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\n\t\tif (message.content) {\n\t\t\titems.push(ModelMessageItem.rehydrate({ text: message.content }))\n\t\t}\n\n\t\tfor (const toolCall of message.tool_calls ?? []) {\n\t\t\titems.push(\n\t\t\t\tFunctionCallItem.rehydrate({\n\t\t\t\t\tcallId: toolCall.id,\n\t\t\t\t\tname: toolCall.function.name,\n\t\t\t\t\targs: toolCall.function.arguments,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\n\t\treturn items\n\t}\n}\n","import type { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport type { Endpoint } from \"@domain/generative-model/endpoint\"\nimport { OpenAIChatCompletionsMapper } from \"./openai-chat-completions-mapper\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\nimport OpenAI from \"openai\"\nimport type { InferenceEndpointMapper } from \"@domain/generative-model/inference-endpoint-mapper\"\n\n/**\n * Optional connection config. When omitted, the `openai` SDK reads\n * `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the\n * default-constructed runtime targets whatever `OPENAI_BASE_URL` points\n * at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an\n * explicit base URL + credential.\n */\nexport interface OpenAICompatibleConfig {\n\tbaseURL?: string\n\tapiKey?: string\n\t/**\n\t * Extra request-body fields merged into every `chat.completions`\n\t * call. This is how provider-specific quirks are handled **without\n\t * a per-provider subclass in mozaik** — the consumer supplies the\n\t * vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,\n\t * safety flags, routing hints). Standard fields the runtime already\n\t * sets (`model`, `messages`, `tools`, `reasoning_effort`) take\n\t * precedence and are not overwritten.\n\t */\n\textraBody?: Record<string, unknown>\n}\n\n/**\n * Generic adapter for any **OpenAI Chat Completions**-compatible\n * endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,\n * Ollama, etc. It speaks `/chat/completions` (not the Responses API),\n * which is the dialect third-party OpenAI-compatible providers expose.\n *\n * The base URL and credential are configurable; everything else (the\n * `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token\n * usage extraction) is provider-agnostic. Provider-specific request\n * shaping (e.g. DeepSeek's `thinking` field) is supplied by the\n * consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays\n * generic and gains no per-provider subclasses.\n *\n * Was `DeepSeekChatCompletions`; generalized so consumers can point it\n * at any OpenAI-compatible endpoint.\n */\nexport class OpenAIChatCompletions implements Endpoint {\n\tendpointMapper: InferenceEndpointMapper\n\tprivate readonly client: OpenAI\n\tprivate readonly extraBody: Record<string, unknown>\n\n\tconstructor(\n\t\tendpointMapper: InferenceEndpointMapper = new OpenAIChatCompletionsMapper(),\n\t\tconfig: OpenAICompatibleConfig = {},\n\t) {\n\t\tthis.endpointMapper = endpointMapper\n\t\t// Passing `undefined` for baseURL/apiKey lets the SDK fall back\n\t\t// to OPENAI_BASE_URL / OPENAI_API_KEY from the environment.\n\t\tthis.client = new OpenAI({\n\t\t\tbaseURL: config.baseURL,\n\t\t\tapiKey: config.apiKey,\n\t\t})\n\t\tthis.extraBody = config.extraBody ?? {}\n\t}\n\n\tprivate buildRequest(inferenceParams: InferenceParams<ModelName>): any {\n\t\treturn {\n\t\t\t...this.extraBody,\n\t\t\t...this.endpointMapper.toRequest(inferenceParams),\n\t\t}\n\t}\n\n\tasync infer(inferenceParams: InferenceParams<ModelName>): Promise<InferenceResponse> {\n\t\tconst response = await this.client.chat.completions.create(this.buildRequest(inferenceParams))\n\n\t\treturn this.endpointMapper.toResponse(response)\n\t}\n\n\tasync *stream(\n\t\tinferenceParams: InferenceParams<ModelName>,\n\t\tsignal?: AbortSignal,\n\t): AsyncIterable<SemanticEvent<unknown>> {\n\t\tconst stream: any = await this.client.chat.completions.create(this.buildRequest(inferenceParams))\n\n\t\tfor await (const event of stream) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tyield new SemanticEvent(event.object ?? \"chat.completion.chunk\", event)\n\t\t}\n\t}\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const claudeSonnet46Specification: ModelSpecification = {\n\tname: \"claude-sonnet-4-6\",\n\tprovider: \"anthropic\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"max\", \"high\", \"medium\", \"low\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 200_000,\n\tmaxOutputTokens: 64_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const claudeOpus48Specification: ModelSpecification = {\n\tname: \"claude-opus-4-8\",\n\tprovider: \"anthropic\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"max\", \"xhigh\", \"high\", \"medium\", \"low\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 200_000,\n\tmaxOutputTokens: 32_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const claudeOpus47Specification: ModelSpecification = {\n\tname: \"claude-opus-4-7\",\n\tprovider: \"anthropic\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"max\", \"xhigh\", \"high\", \"medium\", \"low\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 200_000,\n\tmaxOutputTokens: 32_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const gemini35FlashSpecification: ModelSpecification = {\n\tname: \"gemini-3.5-flash\",\n\tprovider: \"google\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"high\", \"medium\", \"low\", \"minimal\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 1_048_576,\n\tmaxOutputTokens: 64_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const gemini31ProSpecification: ModelSpecification = {\n\tname: \"gemini-3.1-pro-preview\",\n\tprovider: \"google\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"high\", \"medium\", \"low\", \"minimal\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 1_048_576,\n\tmaxOutputTokens: 64_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const deepSeekV4FlashSpecification: ModelSpecification = {\n\tname: \"deepseek-v4-flash\",\n\tprovider: \"deepseek\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"max\", \"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 1_000_000,\n\tmaxOutputTokens: 384_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: false,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const deepSeekV4ProSpecification: ModelSpecification = {\n\tname: \"deepseek-v4-pro\",\n\tprovider: \"deepseek\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"max\", \"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 1_000_000,\n\tmaxOutputTokens: 384_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: false,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const gpt54Specification: ModelSpecification = {\n\tname: \"gpt-5.4\",\n\tprovider: \"openai\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"xhigh\", \"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 1_050_000,\n\tmaxOutputTokens: 128_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const gpt54MiniSpecification: ModelSpecification = {\n\tname: \"gpt-5.4-mini\",\n\tprovider: \"openai\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"xhigh\", \"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 400_000,\n\tmaxOutputTokens: 128_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const gpt54NanoSpecification: ModelSpecification = {\n\tname: \"gpt-5.4-nano\",\n\tprovider: \"openai\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"xhigh\", \"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 400_000,\n\tmaxOutputTokens: 128_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const gpt55Specification: ModelSpecification = {\n\tname: \"gpt-5.5\",\n\tprovider: \"openai\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"xhigh\", \"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 1_050_000,\n\tmaxOutputTokens: 128_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\n\nexport const claudeHaiku45Specification: ModelSpecification = {\n\tname: \"claude-haiku-4-5\",\n\tprovider: \"anthropic\",\n\tsupportsReasoningEffort: true,\n\tsupportedReasoningEfforts: [\"high\", \"medium\", \"low\", \"none\"],\n\tsupportedContextItemTypes: [\n\t\t\"user_message\",\n\t\t\"system_message\",\n\t\t\"developer_message\",\n\t\t\"reasoning\",\n\t\t\"function_call\",\n\t\t\"function_call_output\",\n\t\t\"model_message\",\n\t],\n\tsupportsStreaming: true,\n\tcontextWindowSize: 200_000,\n\tmaxOutputTokens: 64_000,\n\tsupportsFunctionCalling: true,\n\tsupportsStructuredOutput: true,\n}\n","import { AnthropicMessages } from \"@infra/providers/anthropic/endpoints/anthropic-messages\"\nimport { OpenAIResponses } from \"@infra/providers/openai/endpoints/openai-responses\"\nimport { GeminiGenerateContent } from \"@infra/providers/gemini/endpoints/gemini-generate-content\"\nimport { OpenAIChatCompletions } from \"@infra/providers/openai/endpoints/openai-chat-completions\"\nimport { claudeSonnet46Specification } from \"@infra/providers/anthropic/models/claude-4-6-sonnet\"\nimport { claudeOpus48Specification } from \"@infra/providers/anthropic/models/claude-4-8-opus\"\nimport { claudeOpus47Specification } from \"@infra/providers/anthropic/models/claude-4-7-opus\"\nimport { gemini35FlashSpecification } from \"@infra/providers/gemini/models/gemini-3-5-flash\"\nimport { gemini31ProSpecification } from \"@infra/providers/gemini/models/gemini-3-1-pro\"\nimport { deepSeekV4FlashSpecification } from \"@infra/providers/deepseek/models/deepseek-v4-flash\"\nimport { deepSeekV4ProSpecification } from \"@infra/providers/deepseek/models/deepseek-v4-pro\"\nimport { gpt54Specification } from \"@infra/providers/openai/models/gpt-5-4\"\nimport { gpt54MiniSpecification } from \"@infra/providers/openai/models/gpt-5-4-mini\"\nimport { gpt54NanoSpecification } from \"@infra/providers/openai/models/gpt-5-4-nano\"\nimport { gpt55Specification } from \"@infra/providers/openai/models/gpt-5-5\"\nimport { claudeHaiku45Specification } from \"@infra/providers/anthropic/models/claude-4-5-haiku\"\nimport type { GenerativeModel, ModelName } from \"@domain/generative-model/generative-model\"\nimport type { GenerativeModelRepository } from \"@domain/generative-model/generative-model-repository\"\n\nexport class InMemoryGenerativeModelRepository implements GenerativeModelRepository {\n\tgetByModelName(modelName: ModelName): Promise<GenerativeModel> {\n\t\tlet generativeModel = undefined\n\t\tswitch (modelName) {\n\t\t\tcase \"gpt-5.4\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new OpenAIResponses(),\n\t\t\t\t\tspecification: gpt54Specification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"gpt-5.4-mini\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new OpenAIResponses(),\n\t\t\t\t\tspecification: gpt54MiniSpecification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"gpt-5.4-nano\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new OpenAIResponses(),\n\t\t\t\t\tspecification: gpt54NanoSpecification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"gpt-5.5\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new OpenAIResponses(),\n\t\t\t\t\tspecification: gpt55Specification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"claude-haiku-4-5\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new AnthropicMessages(),\n\t\t\t\t\tspecification: claudeHaiku45Specification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"claude-sonnet-4-6\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new AnthropicMessages(),\n\t\t\t\t\tspecification: claudeSonnet46Specification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"claude-opus-4-7\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new AnthropicMessages(),\n\t\t\t\t\tspecification: claudeOpus47Specification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"claude-opus-4-8\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new AnthropicMessages(),\n\t\t\t\t\tspecification: claudeOpus48Specification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"gemini-3.5-flash\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new GeminiGenerateContent(),\n\t\t\t\t\tspecification: gemini35FlashSpecification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"gemini-3.1-pro-preview\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new GeminiGenerateContent(),\n\t\t\t\t\tspecification: gemini31ProSpecification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"deepseek-v4-flash\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new OpenAIChatCompletions(),\n\t\t\t\t\tspecification: deepSeekV4FlashSpecification,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase \"deepseek-v4-pro\":\n\t\t\t\tgenerativeModel = {\n\t\t\t\t\tendpoint: new OpenAIChatCompletions(),\n\t\t\t\t\tspecification: deepSeekV4ProSpecification,\n\t\t\t\t}\n\t\t}\n\n\t\tif (!generativeModel) {\n\t\t\tthrow new Error(`Unsupported model: ${modelName}`)\n\t\t}\n\n\t\treturn Promise.resolve(generativeModel)\n\t}\n}\n","import type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { RequestValidationRule } from \"./rule\"\nimport type { ModelName, ModelSpecification } from \"../generative-model\"\n\nexport class ReasoningEffortValidation implements RequestValidationRule {\n\treadonly name = \"reasoning-effort\"\n\n\tisValid(inferenceParams: InferenceParams<ModelName>, model: ModelSpecification): boolean {\n\t\tif (inferenceParams.reasoningEffort === undefined) {\n\t\t\treturn true\n\t\t}\n\n\t\tif (!model.supportsReasoningEffort) {\n\t\t\treturn false\n\t\t}\n\n\t\treturn model.supportedReasoningEfforts.includes(inferenceParams.reasoningEffort)\n\t}\n}\n","import type { RequestValidationRule } from \"./rule\"\nimport type { ModelName, ModelSpecification } from \"../generative-model\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\n\nexport class ToolCallingValidation implements RequestValidationRule {\n\treadonly name = \"tool-calling\"\n\n\tisValid(inferenceParams: InferenceParams<ModelName>, model: ModelSpecification): boolean {\n\t\tif (inferenceParams.tools === undefined) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn model.supportsFunctionCalling\n\t}\n}\n","import type { ModelSpecification } from \"@domain/generative-model/generative-model\"\nimport type { RequestValidationRule } from \"./rule\"\nimport type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName } from \"@domain/generative-model/generative-model\"\n\nexport class StreamingValidation implements RequestValidationRule {\n\treadonly name = \"streaming\"\n\n\tisValid(inferenceParams: InferenceParams<ModelName>, model: ModelSpecification): boolean {\n\t\tif (!inferenceParams.streaming) {\n\t\t\treturn true\n\t\t}\n\n\t\treturn model.supportsStreaming\n\t}\n}\n","import type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { DeveloperMessageItem } from \"@domain/model-context/context-item/client-item/developer-message\"\nimport { SystemMessageItem } from \"@domain/model-context/context-item/client-item/system-message\"\nimport { UserMessageItem } from \"@domain/model-context/context-item/client-item/user-message\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport type { RequestValidationRule } from \"./rule\"\nimport type { ModelName, ModelSpecification } from \"../generative-model\"\n\nfunction getContextItemValidationKey(item: ContextItem): string {\n\tif (item instanceof UserMessageItem) {\n\t\treturn \"user_message\"\n\t}\n\tif (item instanceof SystemMessageItem) {\n\t\treturn \"system_message\"\n\t}\n\tif (item instanceof DeveloperMessageItem) {\n\t\treturn \"developer_message\"\n\t}\n\tif (item instanceof ModelMessageItem) {\n\t\treturn \"model_message\"\n\t}\n\treturn item.getType()\n}\n\nexport class ContextValidation implements RequestValidationRule {\n\treadonly name = \"context\"\n\n\tisValid(inferenceParams: InferenceParams<ModelName>, model: ModelSpecification): boolean {\n\t\treturn inferenceParams.context.items.every((item) =>\n\t\t\tmodel.supportedContextItemTypes.includes(getContextItemValidationKey(item)),\n\t\t)\n\t}\n}\n","import type { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport type { ModelName, ModelSpecification } from \"../generative-model\"\nimport type { RequestValidationRule } from \"./rule\"\nimport { ReasoningEffortValidation } from \"./reasoning-effort\"\nimport { ToolCallingValidation } from \"./tool-calling\"\nimport { StreamingValidation } from \"./streaming\"\nimport { StructuredOutputValidation } from \"./structured-output\"\nimport { ContextValidation } from \"./context\"\n\nexport const defaultRequestValidationRules: RequestValidationRule[] = [\n\tnew ReasoningEffortValidation(),\n\tnew ToolCallingValidation(),\n\tnew StreamingValidation(),\n\tnew StructuredOutputValidation(),\n\tnew ContextValidation(),\n]\n\nexport class InferenceRequestValidator {\n\tconstructor(private readonly rules: RequestValidationRule[] = defaultRequestValidationRules) {}\n\n\tvalidate(inferenceParams: InferenceParams<ModelName>, model: ModelSpecification): void {\n\t\tfor (const rule of this.rules) {\n\t\t\tif (!rule.isValid(inferenceParams, model)) {\n\t\t\t\tthrow new Error(`Request validation \"${rule.name}\" failed for model \"${model.name}\"`)\n\t\t\t}\n\t\t}\n\t}\n}\n","import { ModelContext } from \"@domain/model-context/model-context\"\nimport { ContextItem } from \"@domain/model-context/context-item/context-item\"\nimport { UserMessageItem } from \"@domain/model-context/context-item/client-item/user-message\"\nimport { DeveloperMessageItem } from \"@domain/model-context/context-item/client-item/developer-message\"\nimport { ModelMessageItem } from \"@domain/model-context/context-item/model-item/model-message\"\nimport { FunctionCallItem } from \"@domain/model-context/context-item/model-item/function-call\"\nimport { ReasoningItem } from \"@domain/model-context/context-item/model-item/reasoning\"\nimport { StructuredOutputFormat } from \"@domain/generative-model/request-validation/structured-output\"\nimport { FunctionCallOutputItem } from \"@domain/model-context/context-item/client-item/function-call-output\"\nimport { ModelContextRepository } from \"@domain/model-context/model-context-repository\"\nimport { InputTokenDetails, OutputTokenDetails, TokenUsage } from \"@domain/generative-model/token-usage\"\nimport { Tool } from \"@domain/generative-model/tool\"\nimport { McpClient, type McpServerConfig, type McpToolSpec } from \"@infra/mcp/mcp-client\"\nimport { McpToolRegistry } from \"@infra/mcp/mcp-tool-registry\"\nimport { InMemoryModelContextRepository } from \"@infra/repository/in-memory-model-context-repository\"\nimport { SystemMessageItem } from \"@domain/model-context/context-item/client-item/system-message\"\nimport { Participant } from \"@domain/agentic-environment/participant\"\nimport { AgenticEnvironment } from \"@domain/agentic-environment/agentic-environment\"\nimport { AgenticError } from \"@domain/agentic-environment/errors/base-error\"\nimport { SemanticEvent } from \"@domain/model-context/semantic-event/semantic-event\"\nimport { InferenceResponse } from \"@domain/agentic-environment/inference/response\"\nimport { Endpoint } from \"@domain/generative-model/endpoint\"\nimport { RunInference } from \"@app/use-cases/run-inference\"\nimport { InferenceParams } from \"@domain/agentic-environment/inference/params\"\nimport { ExecuteFunctionCall } from \"@app/use-cases/execute-function-call\"\nimport { FunctionCallRunner } from \"@app/services/function-call-runner\"\nimport { BaseParticipant } from \"@app/participants/participant\"\nimport { SendMessage } from \"@app/use-cases/send-message\"\nimport { ModelName } from \"@domain/generative-model/generative-model\"\nimport type { GenerativeModelRepository } from \"@domain/generative-model/generative-model-repository\"\nimport { InMemoryGenerativeModelRepository } from \"@infra/repository/generative-model-repository\"\nimport { InferenceRequestValidator } from \"@domain/generative-model/request-validation/inference-request-validator\"\n\nconst generativeModelRepository: GenerativeModelRepository = new InMemoryGenerativeModelRepository()\nconst inferenceRequestValidator = new InferenceRequestValidator()\nconst runInferenceUseCase = new RunInference(generativeModelRepository, inferenceRequestValidator)\nconst executeFunctionCallUseCase = new ExecuteFunctionCall(new FunctionCallRunner())\nconst sendMessageUseCase = new SendMessage()\n\nconst runInference = (inferenceParams: InferenceParams<ModelName>): void => {\n\trunInferenceUseCase.execute(inferenceParams)\n}\n\nconst executeFunctionCall = (\n\tenvironment: AgenticEnvironment,\n\tfunctionCallItem: FunctionCallItem,\n\ttool: Tool,\n\tcaller: Participant,\n): void => {\n\texecuteFunctionCallUseCase.execute(environment, functionCallItem, tool, caller)\n}\n\nconst sendMessage = (environment: AgenticEnvironment, message: string, caller: Participant): void => {\n\tsendMessageUseCase.execute(environment, message, caller)\n}\n\nexport {\n\tModelContext,\n\tModelContextRepository,\n\tModelName,\n\tInMemoryModelContextRepository,\n\tContextItem,\n\tSemanticEvent,\n\tUserMessageItem,\n\tDeveloperMessageItem,\n\tSystemMessageItem,\n\tModelMessageItem,\n\tFunctionCallItem,\n\tFunctionCallOutputItem,\n\tReasoningItem,\n\tStructuredOutputFormat,\n\tTokenUsage,\n\tInputTokenDetails,\n\tOutputTokenDetails,\n\tTool,\n\tMcpClient,\n\ttype McpServerConfig,\n\ttype McpToolSpec,\n\tMcpToolRegistry,\n\tEndpoint,\n\tAgenticEnvironment,\n\tParticipant,\n\tBaseParticipant,\n\tAgenticError,\n\tInferenceResponse,\n\tInferenceParams,\n\trunInference,\n\texecuteFunctionCall,\n\tsendMessage,\n}\n"],"mappings":";AAEO,IAAM,eAAN,MAAM,cAAa;AAAA,EAKzB,YAAY,IAAY,WAAmB,OAAsB;AAChE,SAAK,YAAY;AACjB,SAAK,KAAK;AACV,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,eAAe,MAAiC;AAC/C,SAAK,MAAM,KAAK,IAAI;AACpB,WAAO;AAAA,EACR;AAAA,EAEA,iBAAiB,OAAoC;AACpD,eAAW,QAAQ,OAAO;AACzB,YAAM,WAAW,KAAK,QAAQ;AAC9B,UAAI,aAAa,mBAAmB,aAAa,aAAa,aAAa,aAAa;AACvF,cAAM,IAAI,MAAM,sBAAsB,QAAQ,EAAE;AAAA,MACjD;AAAA,IACD;AACA,SAAK,MAAM,KAAK,GAAG,KAAK;AACxB,WAAO;AAAA,EACR;AAAA,EAEA,WAA0B;AACzB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,cAA2B;AAC1B,QAAI,KAAK,MAAM,WAAW,GAAG;AAC5B,YAAM,IAAI,MAAM,qBAAqB;AAAA,IACtC;AACA,WAAO,KAAK,MAAM,KAAK,MAAM,SAAS,CAAC;AAAA,EACxC;AAAA,EAEA,OAAO,OAAO,WAAiC;AAC9C,UAAM,KAAK,OAAO,WAAW;AAC7B,WAAO,IAAI,cAAa,IAAI,WAAW,CAAC,CAAC;AAAA,EAC1C;AAAA,EAEA,OAAO,UAAU,MAA6E;AAC7F,WAAO,IAAI,cAAa,KAAK,IAAI,KAAK,WAAW,KAAK,KAAK;AAAA,EAC5D;AACD;;;AChDO,IAAe,cAAf,MAA2B;AAAA,EAGjC,UAAkB;AACjB,WAAO,KAAK;AAAA,EACb;AACD;;;ACNO,IAAe,cAAf,MAA2B;AAElC;;;ACAO,IAAM,YAAN,MA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