{"version":3,"file":"aicc-67851c41.mjs","sources":["../src/xllm/core/errors.ts","../src/xllm/core/rust_text.ts","../src/xllm/core/json.ts","../src/xllm/core/messages.ts","../src/xllm/providers/aicc.ts"],"sourcesContent":["import type { CheckpointStage, ErrorSource, LLMComputeError, ProviderFailure, RunStatus } from './types'\n\n// ------------------------------------------------------------ LLMComputeError\n\n/** A rejected `LlmClient.infer` (or any waist dependency) carries its `LLMComputeError`. */\nexport class LLMComputeException extends Error {\n  readonly error: LLMComputeError\n\n  constructor(error: LLMComputeError) {\n    super(computeErrorMessage(error))\n    this.name = 'LLMComputeException'\n    this.error = error\n  }\n}\n\nexport function providerError(failure: ProviderFailure, message: string): LLMComputeException {\n  return new LLMComputeException({ kind: 'provider', failure, message })\n}\n\n/** What a dependency rejected with, as an `LLMComputeError`. A foreign error is a provider failure of unknown class. */\nexport function asComputeError(error: unknown): LLMComputeError {\n  if (error instanceof LLMComputeException) return error.error\n  const message = error instanceof Error ? error.message : String(error)\n  return { kind: 'provider', failure: 'unknown', message }\n}\n\nfunction failureDebug(failure: ProviderFailure): string {\n  if (typeof failure === 'object') return `Refused { code: ${JSON.stringify(failure.refused.code)} }`\n  return { transient: 'Transient', permanent: 'Permanent', unknown: 'Unknown', context_limit: 'ContextLimit' }[failure]\n}\n\nfunction stageDebug(stage: CheckpointStage): string {\n  return { before_inference: 'BeforeInference', before_tool_call: 'BeforeToolCall', outcome_boundary: 'OutcomeBoundary' }[stage]\n}\n\n/** Same text as Rust's `Display for LLMComputeError` (run.json `last_error.message`). */\nexport function computeErrorMessage(e: LLMComputeError): string {\n  switch (e.kind) {\n    case 'timeout': return 'llm timeout'\n    case 'cancelled': return 'llm cancelled'\n    case 'provider': return `llm provider failed (${failureDebug(e.failure)}): ${e.message}`\n    case 'output_parse': return `llm output parse failed: ${e.message}`\n    case 'policy_rejected': return `policy rejected: ${e.message}`\n    case 'tool_failed': return `tool \\`${e.tool}\\` failed: ${e.message}`\n    case 'tool_runtime': return `tool \\`${e.tool}\\` dispatch failed (effect_unknown=${e.effect_unknown}): ${e.message}`\n    case 'checkpoint': return `checkpoint ${stageDebug(e.stage)} failed: ${e.message}`\n    case 'snapshot_corrupted': return `snapshot corrupted: ${e.message}`\n    case 'internal': return `internal: ${e.message}`\n  }\n}\n\nexport function errorSource(e: LLMComputeError): ErrorSource {\n  switch (e.kind) {\n    case 'timeout': case 'cancelled': case 'provider': return 'provider'\n    case 'output_parse': return 'llm_output'\n    case 'policy_rejected': case 'tool_failed': return 'tool'\n    case 'tool_runtime': case 'checkpoint': return 'runtime'\n    case 'snapshot_corrupted': return 'snapshot'\n    case 'internal': return 'internal'\n  }\n}\n\n/** Feeding the error back to the model is a meaningful recovery; everything else ends the run. */\nexport function llmCorrectable(e: LLMComputeError): boolean {\n  return e.kind === 'output_parse' || e.kind === 'policy_rejected' || e.kind === 'tool_failed'\n}\n\nexport function infraRetrySafe(e: LLMComputeError): boolean {\n  switch (e.kind) {\n    case 'timeout': case 'checkpoint': return true\n    case 'provider': return e.failure === 'transient'\n    case 'tool_runtime': return !e.effect_unknown\n    default: return false\n  }\n}\n\nexport function refusedCode(failure: ProviderFailure): string | undefined {\n  return typeof failure === 'object' ? failure.refused.code : undefined\n}\n\n// ------------------------------------------------------------------ XllmError\n\n/** Pre-run errors of the SDK (`XllmError` in Rust): once a run exists, results come back as a `RunOutcome`. */\nexport type XllmErrorDetail =\n  | { kind: 'config'; file: string; field: string; reason: string }\n  | { kind: 'input'; message: string }\n  | { kind: 'capability'; message: string }\n  | { kind: 'runtime_mismatch'; message: string }\n  | { kind: 'recovery_blocked'; message: string }\n  | { kind: 'tools'; message: string }\n  | { kind: 'template'; origin: string; reason: string }\n  | { kind: 'run_not_found'; run_id: string; runs_dir: string }\n  | { kind: 'run_busy'; run_id: string }\n  | { kind: 'workdir_busy'; workdir: string; run_id: string }\n  | { kind: 'run_terminal'; run_id: string; status: RunStatus; hint: string }\n  | { kind: 'not_resumable'; run_id: string; reason: string }\n  | { kind: 'corrupted_run'; run_id: string; reason: string }\n  | { kind: 'storage'; message: string }\n  | { kind: 'extract'; message: string }\n  | { kind: 'compressor'; message: string }\n  | { kind: 'other'; message: string }\n\nexport type XllmErrorKind = XllmErrorDetail['kind']\n\nfunction xllmErrorMessage(d: XllmErrorDetail): string {\n  switch (d.kind) {\n    case 'config': return `config error: ${d.file}: ${d.field}: ${d.reason}`\n    case 'input': return `input error: ${d.message}`\n    case 'capability': return `capability error: ${d.message}`\n    case 'runtime_mismatch': return `runtime mismatch: ${d.message}`\n    case 'recovery_blocked': return `RecoveryBlocked: ${d.message}`\n    case 'tools': return `tools error: ${d.message}`\n    case 'template': return `template error in ${d.origin}: ${d.reason}`\n    case 'run_not_found': return `run \\`${d.run_id}\\` not found under ${d.runs_dir}`\n    case 'run_busy': return `run \\`${d.run_id}\\` is being executed by another process`\n    case 'workdir_busy':\n      return `working directory ${d.workdir} already has a tool-enabled run \\`${d.run_id}\\` executing; wait for it or use another directory`\n    case 'run_terminal': return `run \\`${d.run_id}\\` is terminal (${d.status}); ${d.hint}`\n    case 'not_resumable': return `run \\`${d.run_id}\\` cannot be resumed: ${d.reason}`\n    case 'corrupted_run': return `run \\`${d.run_id}\\` record is corrupted: ${d.reason}`\n    case 'storage': return `storage error: ${d.message}`\n    case 'extract': return `result extraction failed: ${d.message}`\n    case 'compressor': return `context compaction failed: ${d.message}`\n    case 'other': return d.message\n  }\n}\n\nexport class XllmError extends Error {\n  readonly detail: XllmErrorDetail\n\n  constructor(detail: XllmErrorDetail) {\n    super(xllmErrorMessage(detail))\n    this.name = 'XllmError'\n    this.detail = detail\n  }\n\n  get kind(): XllmErrorKind {\n    return this.detail.kind\n  }\n\n  static config(file: string, field: string, reason: string): XllmError {\n    return new XllmError({ kind: 'config', file, field, reason })\n  }\n\n  static input(message: string): XllmError {\n    return new XllmError({ kind: 'input', message })\n  }\n\n  static capability(message: string): XllmError {\n    return new XllmError({ kind: 'capability', message })\n  }\n\n  static runtimeMismatch(message: string): XllmError {\n    return new XllmError({ kind: 'runtime_mismatch', message })\n  }\n\n  static tools(message: string): XllmError {\n    return new XllmError({ kind: 'tools', message })\n  }\n\n  static template(origin: string, reason: string): XllmError {\n    return new XllmError({ kind: 'template', origin, reason })\n  }\n\n  static notResumable(runId: string, reason: string): XllmError {\n    return new XllmError({ kind: 'not_resumable', run_id: runId, reason })\n  }\n\n  static storage(message: string): XllmError {\n    return new XllmError({ kind: 'storage', message })\n  }\n\n  static other(message: string): XllmError {\n    return new XllmError({ kind: 'other', message })\n  }\n}\n","// Rust string and JSON semantics for text the model sees: trimming with\n// Rust's whitespace set (`char::is_whitespace` differs from JS `trim` in\n// U+0085 and U+FEFF), lengths in Unicode scalar values, JSON written the way\n// serde_json writes it (keys in code point order, serde's number layout).\n\nimport type { AiMessage, JsonValue } from './types'\n\n/** `char::is_whitespace` (Unicode White_Space); every such char is a single UTF-16 unit. */\nfunction isRustWhitespace(c: number): boolean {\n  return (c >= 0x09 && c <= 0x0d) || c === 0x20 || c === 0x85 || c === 0xa0 || c === 0x1680 || (c >= 0x2000 && c <= 0x200a) ||\n    c === 0x2028 || c === 0x2029 || c === 0x202f || c === 0x205f || c === 0x3000\n}\n\n/** `str::trim_start`. */\nexport function rustTrimStart(s: string): string {\n  let i = 0\n  while (i < s.length && isRustWhitespace(s.charCodeAt(i))) i++\n  return i === 0 ? s : s.slice(i)\n}\n\n/** `str::trim_end`. */\nexport function rustTrimEnd(s: string): string {\n  let j = s.length\n  while (j > 0 && isRustWhitespace(s.charCodeAt(j - 1))) j--\n  return j === s.length ? s : s.slice(0, j)\n}\n\n/** `str::trim`. */\nexport function rustTrim(s: string): string {\n  return rustTrimStart(rustTrimEnd(s))\n}\n\n/** `s.split_whitespace().collect::<Vec<_>>().join(\" \")`. */\nexport function collapseWhitespace(s: string): string {\n  const words: string[] = []\n  let start = -1\n  for (let i = 0; i < s.length; i++) {\n    if (isRustWhitespace(s.charCodeAt(i))) {\n      if (start >= 0) words.push(s.slice(start, i))\n      start = -1\n    } else if (start < 0) {\n      start = i\n    }\n  }\n  if (start >= 0) words.push(s.slice(start))\n  return words.join(' ')\n}\n\nfunction isPairAt(s: string, i: number): boolean {\n  const c = s.charCodeAt(i)\n  return c >= 0xd800 && c <= 0xdbff && i + 1 < s.length && (s.charCodeAt(i + 1) & 0xfc00) === 0xdc00\n}\n\n/** UTF-16 offset after the first `n` chars (Unicode scalar values) of `s`; `s.length` when it has fewer. */\nexport function charOffset(s: string, n: number): number {\n  let i = 0\n  for (let k = 0; k < n && i < s.length; k++) i += isPairAt(s, i) ? 2 : 1\n  return i\n}\n\n/** `str::chars().count()`. */\nexport function charCount(s: string): number {\n  let n = 0\n  for (let i = 0; i < s.length; i += isPairAt(s, i) ? 2 : 1) n++\n  return n\n}\n\n/** `AiMessage::text_content`: text blocks joined by `\\n`, a separator only once something was written. */\nexport function rustTextContent(message: AiMessage): string {\n  let out = ''\n  for (const b of message.content) {\n    if (b.type !== 'text') continue\n    if (out !== '') out += '\\n'\n    out += b.text\n  }\n  return out\n}\n\n/** Order of Rust `String` (UTF-8 bytes, i.e. code points). */\nexport function compareCodePoints(a: string, b: string): number {\n  let i = 0\n  let j = 0\n  while (i < a.length && j < b.length) {\n    const x = a.codePointAt(i) as number\n    const y = b.codePointAt(j) as number\n    if (x !== y) return x - y\n    i += x > 0xffff ? 2 : 1\n    j += y > 0xffff ? 2 : 1\n  }\n  return (a.length - i) - (b.length - j)\n}\n\n/**\n * A number as serde_json writes the value it parsed from this number's JSON\n * text: an integer in the i64 / u64 range as is, anything else as an f64 in\n * the layout of serde_json's formatter (zmij): fixed notation for decimal\n * exponents -5..=15 (`0.00001`, `3.0`), else `1e+21` / `2.5e-7`.\n */\nfunction serdeNumber(n: number): string {\n  if (!Number.isFinite(n)) return 'null'\n  // -2^63 itself prints as -9223372036854776000, below i64::MIN: serde reads an f64.\n  if (Number.isInteger(n) && n > -(2 ** 63) && n < 2 ** 64) return String(n)\n  const [mantissa, exponent] = Math.abs(n).toExponential().split('e')\n  const digits = mantissa.replace('.', '')\n  const length = digits.length\n  const e = Number(exponent)\n  let s: string\n  if (e >= -5 && e <= 15) {\n    if (length - 1 <= e) s = `${digits}${'0'.repeat(e + 1 - length)}.0`\n    else if (e >= 0) s = `${digits.slice(0, e + 1)}.${digits.slice(e + 1)}`\n    else s = `0.${'0'.repeat(-e - 1)}${digits}`\n  } else {\n    s = `${length > 1 ? `${digits[0]}.${digits.slice(1)}` : digits}e${e < 0 ? '-' : '+'}${Math.abs(e)}`\n  }\n  return n < 0 ? `-${s}` : s\n}\n\nfunction writeJson(v: JsonValue | undefined, indent: string | undefined): string {\n  if (v === null || v === undefined) return 'null'\n  if (typeof v === 'string') return JSON.stringify(v)\n  if (typeof v === 'number') return serdeNumber(v)\n  if (typeof v === 'boolean') return v ? 'true' : 'false'\n  const inner = indent === undefined ? undefined : `${indent}  `\n  if (Array.isArray(v)) {\n    if (v.length === 0) return '[]'\n    const items = v.map(x => writeJson(x, inner))\n    return inner === undefined ? `[${items.join(',')}]` : `[${inner}${items.join(`,${inner}`)}${indent}]`\n  }\n  const keys = Object.keys(v).filter(k => v[k] !== undefined).sort(compareCodePoints)\n  if (keys.length === 0) return '{}'\n  const items = keys.map(k => `${JSON.stringify(k)}:${inner === undefined ? '' : ' '}${writeJson(v[k], inner)}`)\n  return inner === undefined ? `{${items.join(',')}}` : `{${inner}${items.join(`,${inner}`)}${indent}}`\n}\n\n/** `serde_json::to_string` (or `to_string_pretty`) of a `Value`: keys in Rust's order, numbers as serde prints them. */\nexport function serdeJson(value: JsonValue, pretty = false): string {\n  return writeJson(value, pretty ? '\\n' : undefined)\n}\n\n","// JSON helpers. serde_json (without `preserve_order`) writes object keys in\n// code point order; `canonicalJson` writes JSON exactly as serde_json does,\n// so lengths, comparisons and model-visible text match the Rust side.\n\nimport type { JsonValue } from './types'\nimport { serdeJson } from './rust_text'\n\n/** `serde_json::to_string` of the value (after a JSON round trip, so `toJSON` and `undefined` behave as in JSON). */\nexport function canonicalJson(value: unknown): string {\n  if (value === undefined) return 'null'\n  return serdeJson(JSON.parse(JSON.stringify(value)) as JsonValue)\n}\n\n/** Deep copy of a JSON value (drops `undefined` members like serialization does). */\nexport function cloneJson<T>(value: T): T {\n  return value === undefined ? value : JSON.parse(JSON.stringify(value))\n}\n\n/** Structural equality of two JSON values, `undefined` members ignored. */\nexport function jsonEqual(a: unknown, b: unknown): boolean {\n  return canonicalJson(a) === canonicalJson(b)\n}\n\nexport function isObject(v: unknown): v is { [key: string]: JsonValue } {\n  return typeof v === 'object' && v !== null && !Array.isArray(v)\n}\n","import type { AiCost, AiMessage, AiRole } from '../../aicc_client'\nimport type { AiResponse, AiToolCall, AiUsage, JsonValue, Observation } from './types'\nimport { canonicalJson } from './json'\nimport { rustTextContent, rustTrim } from './rust_text'\n\nexport function nowMs(): number {\n  return Date.now()\n}\n\nexport function textMessage(role: AiRole, text: string): AiMessage {\n  return { role, content: [{ type: 'text', text }] }\n}\n\n/** All text blocks joined by `\\n` (`AiMessage::text_content`). */\nexport function textContent(message: AiMessage): string {\n  return rustTextContent(message)\n}\n\n/** Tool-use blocks as calls, in message order (`AiMessage::tool_calls`). */\nexport function toolCalls(message: AiMessage): AiToolCall[] {\n  const out: AiToolCall[] = []\n  for (const b of message.content) {\n    if (b.type === 'tool_use') out.push({ name: b.name, args: b.args ?? {}, call_id: b.call_id })\n  }\n  return out\n}\n\n/** `AiResponse::validate`: an assistant message with blocks allowed for the role and tool calls with ids. */\nexport function validateResponse(response: AiResponse): string | undefined {\n  const m = response.message\n  if (!m || m.role !== 'assistant') return `invalid block response_message for role ${m?.role}`\n  for (const b of m.content ?? []) {\n    if (!['text', 'image', 'document', 'tool_use', 'thinking', 'provider_state'].includes(b.type)) {\n      return `invalid block ${b.type} for role assistant`\n    }\n    if (b.type === 'tool_use' && !rustTrim(b.call_id ?? '')) return 'tool call without call_id'\n  }\n  return undefined\n}\n\n/** The tool-role message carrying one observation back to the model. */\nexport function toolObservationMessage(callId: string, observation: Observation): AiMessage {\n  let text: string\n  let isError: boolean\n  switch (observation.kind) {\n    case 'success':\n      text = typeof observation.content === 'string' ? observation.content : canonicalJson(observation.content)\n      isError = false\n      break\n    case 'error':\n      text = observation.message\n      isError = true\n      break\n    case 'cancelled':\n      if (observation.effect_unknown) {\n        text = `[cancelled, result unknown] ${observation.reason}`\n        isError = true\n      } else {\n        text = `[cancelled] ${observation.reason}`\n        isError = false\n      }\n      break\n    case 'unresolved':\n      text = observation.effect_unknown ? `[unresolved: result unknown] ${observation.reason}` : `[not executed] ${observation.reason}`\n      isError = true\n      break\n  }\n  const block: AiMessage['content'][number] = isError\n    ? { type: 'tool_result', call_id: callId, content: [{ type: 'text', text }], is_error: true }\n    : { type: 'tool_result', call_id: callId, content: [{ type: 'text', text }] }\n  return { role: 'tool', content: [block] }\n}\n\nconst USAGE_COUNTERS: (keyof AiUsage)[] = [\n  'input_tokens', 'output_tokens', 'total_tokens', 'cache_read_input_tokens', 'cache_write_input_tokens',\n  'cache_write_1h_input_tokens', 'reasoning_tokens', 'image_units', 'audio_seconds', 'video_seconds', 'reference_images',\n  'request_units', 'characters', 'audio_input_tokens', 'image_input_tokens', 'audio_output_tokens', 'image_output_tokens',\n]\n\n/** Sum of two usages (`merge_usage`): counters add, `cost` adds per currency, `reported_cost` is dropped. */\nexport function mergeUsage(left: AiUsage, right: AiUsage): AiUsage {\n  const out: AiUsage = {}\n  for (const k of USAGE_COUNTERS) {\n    const a = left[k] as number | undefined\n    const b = right[k] as number | undefined\n    if (a !== undefined || b !== undefined) (out as Record<string, number>)[k] = (a ?? 0) + (b ?? 0)\n  }\n  const cost = addCost(left.cost, right.cost)\n  if (cost) out.cost = cost\n  return out\n}\n\nfunction addCost(a?: AiCost, b?: AiCost): AiCost | undefined {\n  if (a && b) return a.currency === b.currency ? { amount: a.amount + b.amount, currency: a.currency } : undefined\n  return a ?? b\n}\n\n/** `add_usage` of the run record: input / output / total tokens and request units. */\nexport function addRecordUsage(base: AiUsage | undefined, extra: AiUsage): AiUsage {\n  const cur: AiUsage = { ...(base ?? {}) }\n  for (const k of ['input_tokens', 'output_tokens', 'total_tokens', 'request_units'] as const) {\n    if (extra[k] !== undefined) cur[k] = (cur[k] ?? 0) + (extra[k] as number)\n  }\n  return cur\n}\n\nexport function argsOf(args: Record<string, JsonValue> | undefined): Record<string, JsonValue> {\n  return args ?? {}\n}\n","// AICC as an `LlmClient` (Rust `AiccLlmClient`). The client is the page's own\n// `AiccClient` (`getAiccClient()`): calls run under the page's session; xllm\n// never touches it.\n//\n// Error table (same order as Rust `aicc_provider_failure` /\n// `provider_error_from_rpc`, no matching on message text):\n//   quota_exhausted / quota_budget_exceeded / resource_not_permitted /\n//     attribution_unavailable              → refused { code }\n//   quota_unavailable                       → transient\n//   context_length_exceeded, http_status 413 → context_limit\n//   timeout, retriable                      → transient\n//   kRPC http_error: 413 → context_limit, 408 / 504 → transient,\n//     401 / 403 → refused { credentials }, other → unknown\n//   transport failure                       → transient\n//   anything else                           → unknown\n\nimport type {\n  AiccClient, AiccError, AiToolSpec, HelperModelRequirement, LlmChatHelperRequest, LlmChatInvokeRequest,\n  LlmChatInvokeResponse, LlmResponseFormat, ModelDisable,\n} from '../../aicc_client'\nimport { RPC_HTTP_ERROR_CODE, RPC_TRANSPORT_ERROR_CODE } from '../../krpc_client'\nimport type { RPCError } from '../../krpc_client'\nimport type { AiResponse, JsonValue, LlmClient, LlmInferenceRequest, ProviderFailure } from '../core/types'\nimport { LLMComputeException, providerError } from '../core/errors'\nimport { isObject } from '../core/json'\n\nexport const REFUSED_QUOTA_EXHAUSTED = 'quota_exhausted'\nexport const REFUSED_QUOTA_BUDGET_EXCEEDED = 'quota_budget_exceeded'\nexport const REFUSED_RESOURCE_NOT_PERMITTED = 'resource_not_permitted'\nexport const REFUSED_ATTRIBUTION_UNAVAILABLE = 'attribution_unavailable'\n/** The service refused the caller's credentials: sign in again, then resume. */\nexport const REFUSED_CREDENTIALS = 'credentials'\n\nconst REFUSAL_CODES = [REFUSED_QUOTA_EXHAUSTED, REFUSED_QUOTA_BUDGET_EXCEEDED, REFUSED_RESOURCE_NOT_PERMITTED, REFUSED_ATTRIBUTION_UNAVAILABLE]\n\n/** `force_json` without a schema: any JSON object (a bare `{\"type\":\"object\"}` gets `{}` from Gemini). */\nexport function anyJsonObjectSchema(): JsonValue {\n  return { type: 'object', additionalProperties: true }\n}\n\nfunction refused(code: string): ProviderFailure {\n  return { refused: { code } }\n}\n\n/** Failure class of an AICC error, `undefined` when the error does not say. */\nexport function aiccProviderFailure(error: Partial<AiccError>): ProviderFailure | undefined {\n  const code = error.code as string | undefined\n  if (code && REFUSAL_CODES.includes(code)) return refused(code)\n  if (code === 'quota_unavailable') return 'transient'\n  const httpStatus = isObject(error.details) ? error.details.http_status : undefined\n  if (code === 'context_length_exceeded' || httpStatus === 413) return 'context_limit'\n  if (code === 'timeout' || error.retriable === true) return 'transient'\n  return undefined\n}\n\n/** A failed AICC call (a rejected kRPC call) as a provider error. */\nexport function providerErrorFromRpc(context: string, err: unknown): LLMComputeException {\n  const message = err instanceof Error ? err.message : String(err)\n  const text = `${context}: ${message}`\n  // Read the structured fields of an `RPCError` without `instanceof`: the\n  // page's AICC client may come from another bundle of this SDK.\n  const code = typeof err === 'object' && err !== null ? (err as Partial<RPCError>).code : undefined\n  if (typeof code !== 'string' || !code) return providerError('unknown', text)\n  const rawData = (err as Partial<RPCError>).data\n  const data = isObject(rawData) ? rawData : undefined\n  const fromAicc = aiccProviderFailure({ ...(data as Partial<AiccError> | undefined), code: code as AiccError['code'] })\n  if (fromAicc) return providerError(fromAicc, text)\n  if (code === RPC_HTTP_ERROR_CODE) {\n    const status = typeof data?.status === 'number' ? data.status : undefined\n    if (status === 413) return providerError('context_limit', text)\n    if (status === 408 || status === 504) return providerError('transient', text)\n    if (status === 401 || status === 403) return providerError(refused(REFUSED_CREDENTIALS), text)\n    return providerError('unknown', text)\n  }\n  if (code === RPC_TRANSPORT_ERROR_CODE) return providerError('transient', text)\n  return providerError('unknown', text)\n}\n\nconst DISABLE_FEATURES: Record<string, keyof ModelDisable> = {\n  tool_call: 'tool_call', json_schema: 'json_schema', web_search: 'web_search', vision: 'vision',\n  image_generation: 'image_generation', streaming: 'streaming',\n}\n\nfunction aiccErrorText(e: AiccError | undefined): string {\n  return e ? ` (${e.code}: ${e.message})` : ''\n}\n\n/** `LlmClient` over the page's AICC client. */\nexport class AiccLlmClient implements LlmClient {\n  constructor(private readonly client: AiccClient) {}\n\n  async infer(req: LlmInferenceRequest): Promise<AiResponse> {\n    const tools: AiToolSpec[] = req.allow_tool_calls\n      ? req.tool_specs.map(s => ({ type: 'function', name: s.name, description: s.description, args_json_schema: s.args_schema }))\n      : []\n    const disable: ModelDisable = {}\n    for (const f of req.disable_capabilities) {\n      const key = DISABLE_FEATURES[f]\n      if (key) (disable as Record<string, boolean>)[key] = true\n    }\n    let responseFormat: LlmResponseFormat | undefined\n    if (req.force_json) {\n      responseFormat = req.json_schema !== undefined\n        ? { type: 'json_schema', json_schema: { name: 'llm_response', schema: req.json_schema } }\n        : { type: 'json_schema', json_schema: { name: 'llm_response', schema: anyJsonObjectSchema(), strict: false } }\n    }\n    const common = {\n      messages: req.messages,\n      ...(tools.length ? { tools } : {}),\n      ...(responseFormat ? { response_format: responseFormat } : {}),\n      ...(req.temperature !== undefined ? { temperature: req.temperature } : {}),\n      ...(req.max_completion_tokens !== undefined ? { max_output_tokens: req.max_completion_tokens } : {}),\n      ...(req.trace_id ? { trace_id: req.trace_id } : {}),\n      execution_mode: 'immediate' as const,\n    }\n    const exact = req.model_alias.includes('@')\n    const method = exact ? 'chat.completions.create' : 'helper.llm_chat'\n    let response: LlmChatInvokeResponse\n    try {\n      if (exact) {\n        const r: LlmChatInvokeRequest = { exact_model: req.model_alias, ...common }\n        response = await this.client.chatCompletionsCreate(r)\n      } else {\n        const requirements: HelperModelRequirement = {}\n        if (req.allow_tool_calls && tools.length > 0) requirements.tool_call = true\n        if (req.force_json) requirements.json_schema = true\n        const r: LlmChatHelperRequest = {\n          logical_model: req.model_alias, ...common,\n          ...(Object.keys(requirements).length ? { requirements } : {}),\n          ...(Object.keys(disable).length ? { disable } : {}),\n        }\n        response = await this.client.helperLlmChat(r)\n      }\n    } catch (e) {\n      if (e instanceof LLMComputeException) throw e\n      throw providerErrorFromRpc(`aicc ${method} failed`, e)\n    }\n    if (response.status === 'succeeded') {\n      if (!response.message) throw providerError('unknown', `aicc ${method} succeeded but message is empty`)\n      const out: AiResponse = { message: response.message }\n      if (response.usage) out.usage = response.usage\n      if (response.cost) out.cost = response.cost\n      if (response.finish_reason) out.finish_reason = response.finish_reason\n      if (response.provider_task_ref) out.provider_task_ref = response.provider_task_ref\n      const model = response.route_trace?.final_model\n      if (model) out.extra = { model }\n      return out\n    }\n    if (response.status === 'failed') {\n      const failure = (response.error && aiccProviderFailure(response.error)) ?? 'unknown'\n      throw providerError(failure,\n        `aicc ${method} failed${aiccErrorText(response.error)}: task_id=${response.task_id}, event_ref=${response.event_ref ?? ''}`)\n    }\n    throw providerError('permanent',\n      `aicc ${method} returned async task \\`${response.task_id}\\`; xllm does not poll async tasks — use a synchronous-capable model`)\n  }\n}\n"],"names":["items"],"mappings":";AAKO,MAAM,4BAA4B,MAAM;AAAA,EAG7C,YAAY,OAAwB;AAC5B,UAAA,oBAAoB,KAAK,CAAC;AAChC,SAAK,OAAO;AACZ,SAAK,QAAQ;AAAA,EACf;AACF;AAEgB,SAAA,cAAc,SAA0B,SAAsC;AAC5F,SAAO,IAAI,oBAAoB,EAAE,MAAM,YAAY,SAAS,SAAS;AACvE;AAGO,SAAS,eAAe,OAAiC;AAC9D,MAAI,iBAAiB;AAAqB,WAAO,MAAM;AACvD,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,SAAO,EAAE,MAAM,YAAY,SAAS,WAAW,QAAQ;AACzD;AAEA,SAAS,aAAa,SAAkC;AACtD,MAAI,OAAO,YAAY;AAAU,WAAO,mBAAmB,KAAK,UAAU,QA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