aura-llm 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -386,19 +386,32 @@ async function safeJson(res) {
386
386
 
387
387
  // src/models.ts
388
388
  var KnownModels = {
389
- // OpenAI
389
+ // OpenAI (September 2026 line first)
390
+ GPT_6_ASTRA: "gpt-6-astra",
391
+ GPT_5_6_SOL: "gpt-5.6-sol",
392
+ GPT_5_6_TERRA: "gpt-5.6-terra",
393
+ GPT_5_6_LUNA: "gpt-5.6-luna",
394
+ GPT_5_5: "gpt-5.5",
390
395
  GPT_5_4: "gpt-5.4",
391
396
  GPT_5_4_MINI: "gpt-5.4-mini",
392
397
  GPT_5_4_NANO: "gpt-5.4-nano",
393
398
  GPT_4O: "gpt-4o",
394
399
  GPT_4O_MINI: "gpt-4o-mini",
395
- // Anthropic
400
+ // Anthropic (Claude 5-generation ids carry no date suffix)
401
+ CLAUDE_FABLE_5_1: "claude-fable-5-1",
402
+ CLAUDE_OPUS_5: "claude-opus-5",
403
+ CLAUDE_SONNET_5: "claude-sonnet-5",
404
+ CLAUDE_OPUS_4_8: "claude-opus-4-8",
396
405
  CLAUDE_OPUS_4_7: "claude-opus-4-7",
397
406
  CLAUDE_SONNET_4_6: "claude-sonnet-4-6",
398
407
  CLAUDE_HAIKU_4_5: "claude-haiku-4-5-20251001",
399
408
  // Google
400
- GEMINI_3_PRO: "gemini-3-pro-preview",
409
+ GEMINI_3_8_FLASH: "gemini-3.8-flash",
410
+ GEMINI_3_7_FLASH: "gemini-3.7-flash",
411
+ GEMINI_3_6_FLASH: "gemini-3.6-flash",
401
412
  GEMINI_3_5_FLASH: "gemini-3.5-flash",
413
+ GEMINI_3_5_FLASH_LITE: "gemini-3.5-flash-lite",
414
+ GEMINI_3_PRO: "gemini-3-pro-preview",
402
415
  // Fireworks AI — serverless open-weight catalog (see gateway issue #209).
403
416
  // IDs are namespaced as accounts/fireworks/models/<slug>.
404
417
  FIREWORKS_GLM_5P2: "accounts/fireworks/models/glm-5p2",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/types.ts","../src/streaming.ts","../src/client.ts","../src/models.ts"],"names":[],"mappings":";;;AAyBO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA;AAAA,EAE1B,IAAA;AAAA;AAAA,EAEA,KAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,YAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,OAAA,GAA4B,EAAC,EAAG;AAC3D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,KAAK,WAAA,CAAY,IAAA;AAC7B,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,QAAQ,OAAA,CAAQ,KAAA;AACrB,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AACzB,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAE5B,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAGO,IAAM,QAAA,GAAN,cAAuB,SAAA,CAAU;AAAC;AAGlC,IAAM,mBAAA,GAAN,cAAkC,QAAA,CAAS;AAAA,EAChD,WAAA,CAAY,OAAA,GAAU,4BAAA,EAA8B,OAAA,GAA4B,EAAC,EAAG;AAClF,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,IAAA,EAAM,sBAAA,EAAwB,QAAQ,GAAA,EAAK,GAAG,SAAS,CAAA;AAAA,EAC1E;AACF;AAGO,IAAM,eAAA,GAAN,cAA8B,QAAA,CAAS;AAAA,EAC5C,WAAA,CAAY,OAAA,EAAiB,OAAA,GAA4B,EA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AwB,wCAAA;AAAA,EACxB,qBAAA,EAAuB;AACzB","file":"index.cjs","sourcesContent":["/**\n * Aura SDK error hierarchy.\n *\n * Mirrors the Python SDK's `exceptions.py`:\n * AuraError\n * ├── APIError (errors returned by the gateway)\n * │ ├── AuthenticationError (401)\n * │ ├── BadRequestError (400)\n * │ ├── NotFoundError (404)\n * │ └── RateLimitError (429, carries retryAfter)\n * ├── APIConnectionError (network failure)\n * └── APITimeoutError (exceeded the configured timeout)\n *\n * Use `instanceof` to branch on error class.\n */\n\nexport interface AuraErrorOptions {\n code?: string\n param?: string\n status?: number\n requestId?: string\n responseBody?: unknown\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class AuraError extends Error {\n /** Gateway error code (e.g. `invalid_model`), when present. */\n readonly code?: string\n /** Offending request parameter, when the gateway reports one. */\n readonly param?: string\n /** HTTP status code, when the error originated from a response. */\n readonly status?: number\n /** Gateway request id for support/correlation, when present. */\n readonly requestId?: string\n /** Raw parsed response body, for debugging. */\n readonly responseBody?: unknown\n\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message)\n this.name = this.constructor.name\n this.code = options.code\n this.param = options.param\n this.status = options.status\n this.requestId = options.requestId\n this.responseBody = options.responseBody\n // Restore prototype chain for `instanceof` across transpile targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** An error returned by the Aura API (any non-2xx with a parseable body). */\nexport class APIError extends AuraError {}\n\n/** 401 — invalid or missing API key. */\nexport class AuthenticationError extends APIError {\n constructor(message = 'Invalid or missing API key', options: AuraErrorOptions = {}) {\n super(message, { code: 'authentication_error', status: 401, ...options })\n }\n}\n\n/** 400 — the request was malformed or invalid. */\nexport class BadRequestError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'invalid_request', status: 400, ...options })\n }\n}\n\n/** 404 — resource not found (e.g. an unknown model). */\nexport class NotFoundError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'not_found', status: 404, ...options })\n }\n}\n\n/** 429 — rate limit exceeded. */\nexport class RateLimitError extends APIError {\n /** Seconds to wait before retrying, from the `Retry-After` header. */\n readonly retryAfter?: number\n\n constructor(\n message = 'Rate limit exceeded',\n options: AuraErrorOptions & { retryAfter?: number } = {},\n ) {\n const { retryAfter, ...rest } = options\n super(message, { code: 'rate_limit_exceeded', status: 429, ...rest })\n this.retryAfter = retryAfter\n }\n}\n\n/** Failed to connect to the gateway (DNS, refused, reset, …). */\nexport class APIConnectionError extends AuraError {\n constructor(message = 'Failed to connect to Aura API', options: AuraErrorOptions = {}) {\n super(message, { code: 'connection_error', ...options })\n }\n}\n\n/** The request exceeded the configured `timeout`. */\nexport class APITimeoutError extends AuraError {\n constructor(message = 'Request timed out', options: AuraErrorOptions = {}) {\n super(message, { code: 'timeout', ...options })\n }\n}\n\n/**\n * Map an HTTP status + parsed error body to the right error class.\n * Used by the request layer.\n */\nexport function errorFromResponse(\n status: number,\n body: unknown,\n headers: Headers,\n): AuraError {\n let code = 'unknown_error'\n let message = `HTTP ${status}`\n let param: string | undefined\n if (body && typeof body === 'object') {\n const err = (body as { error?: Record<string, unknown> }).error\n if (err && typeof err === 'object') {\n if (typeof err.code === 'string') code = err.code\n if (typeof err.message === 'string') message = err.message\n if (typeof err.param === 'string') param = err.param\n }\n }\n const requestId =\n headers.get('x-request-id') ?? headers.get('x-aura-request-id') ?? undefined\n const base: AuraErrorOptions = { code, param, status, requestId, responseBody: body }\n\n switch (status) {\n case 401:\n return new AuthenticationError(message, base)\n case 400:\n return new BadRequestError(message, base)\n case 404:\n return new NotFoundError(message, base)\n case 429: {\n const ra = headers.get('retry-after')\n return new RateLimitError(message, {\n ...base,\n retryAfter: ra ? Number.parseInt(ra, 10) : undefined,\n })\n }\n default:\n return new APIError(message, base)\n }\n}\n","/**\n * Open Responses API types, ported from the Python SDK's `types.py`.\n *\n * These are plain TypeScript interfaces/unions (the gateway returns JSON; we\n * don't validate at runtime beyond shape-narrowing on `type`). Helper\n * functions (`outputText`, `toolCalls`) replace the Python `@property`\n * accessors, since interfaces can't carry methods.\n */\n\n// ── Enums (as string-literal unions) ───────────────────────────────────────\n\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'failed'\n | 'incomplete'\n | 'cancelled'\n\nexport type ItemType =\n | 'message'\n | 'function_call'\n | 'function_call_output'\n | 'reasoning'\n\nexport type Role = 'user' | 'assistant' | 'system'\n\n// ── Content ────────────────────────────────────────────────────────────────\n\nexport interface TextContent {\n type: 'text'\n text: string\n}\n\nexport interface ImageContent {\n type: 'image'\n url?: string\n base64?: string\n media_type?: string\n}\n\nexport type Content = TextContent | ImageContent\n\n// ── Items ────────────────────────────────────────────────────────────────\n\nexport interface MessageItem {\n type: 'message'\n id?: string\n role: Role\n content: Content[]\n status?: string\n}\n\nexport interface FunctionCallItem {\n type: 'function_call'\n id?: string\n call_id: string\n name: string\n arguments: string\n status?: string\n}\n\nexport interface FunctionCallOutputItem {\n type: 'function_call_output'\n id?: string\n call_id: string\n output: string\n}\n\nexport interface ReasoningItem {\n type: 'reasoning'\n id?: string\n content: TextContent[]\n status?: string\n}\n\nexport type Item =\n | MessageItem\n | FunctionCallItem\n | FunctionCallOutputItem\n | ReasoningItem\n\n// ── Tools ────────────────────────────────────────────────────────────────\n\nexport interface FunctionDefinition {\n name: string\n description?: string\n parameters?: Record<string, unknown>\n}\n\nexport interface Tool {\n type: 'function'\n function: FunctionDefinition\n}\n\n/** Convenience builder for a function tool (mirrors Tool.function_tool). */\nexport function functionTool(\n name: string,\n description?: string,\n parameters?: Record<string, unknown>,\n): Tool {\n return {\n type: 'function',\n function: { name, ...(description ? { description } : {}), ...(parameters ? { parameters } : {}) },\n }\n}\n\n// ── Usage ────────────────────────────────────────────────────────────────\n\nexport interface Usage {\n input_tokens: number\n output_tokens: number\n total_tokens: number\n input_tokens_details?: Record<string, number>\n output_tokens_details?: Record<string, number>\n cost_usd?: number\n}\n\n// ── Response ─────────────────────────────────────────────────────────────\n\nexport interface ResponseError {\n code: string\n message: string\n param?: string\n}\n\nexport interface AuraMetadata {\n request_id?: string\n model?: string\n provider?: string\n gateway_version?: string\n latency_ms?: number\n agentic?: Record<string, unknown>\n}\n\nexport interface ResponseMetadata {\n aura?: AuraMetadata\n}\n\nexport interface Response {\n id: string\n object: 'response'\n created_at: number\n status: ResponseStatus\n model: string\n output: Item[]\n usage?: Usage\n error?: ResponseError\n metadata?: ResponseMetadata\n previous_response_id?: string\n conversation_id?: string\n}\n\n// ── Response helpers (replace Python @property accessors) ───────────────────\n\n/** Text from the first assistant message output item ('' if none). */\nexport function outputText(response: Response): string {\n for (const item of response.output) {\n if (item.type === 'message' && item.role === 'assistant') {\n return item.content\n .filter((c): c is TextContent => c.type === 'text')\n .map((c) => c.text)\n .join('')\n }\n }\n return ''\n}\n\n/** All function-call items in the output. */\nexport function toolCalls(response: Response): FunctionCallItem[] {\n return response.output.filter(\n (item): item is FunctionCallItem => item.type === 'function_call',\n )\n}\n\nexport const hasToolCalls = (r: Response): boolean => toolCalls(r).length > 0\nexport const isComplete = (r: Response): boolean => r.status === 'completed'\nexport const isFailed = (r: Response): boolean => r.status === 'failed'\n\n// ── Stream events ──────────────────────────────────────────────────────────\n\ninterface StreamEventBase {\n type: string\n sequence?: number\n}\n\nexport interface ResponseCreatedEvent extends StreamEventBase {\n type: 'response.created'\n response: Response\n}\nexport interface ResponseInProgressEvent extends StreamEventBase {\n type: 'response.in_progress'\n response: Response\n}\nexport interface ResponseCompletedEvent extends StreamEventBase {\n type: 'response.completed'\n response: Response\n}\nexport interface ResponseFailedEvent extends StreamEventBase {\n type: 'response.failed'\n response: Response\n}\nexport interface OutputItemAddedEvent extends StreamEventBase {\n type: 'response.output_item.added'\n item: Item\n output_index: number\n}\nexport interface OutputItemDoneEvent extends StreamEventBase {\n type: 'response.output_item.done'\n item: Item\n output_index: number\n}\nexport interface TextDeltaEvent extends StreamEventBase {\n type: 'response.output_text.delta'\n delta: string\n output_index: number\n content_index: number\n}\nexport interface TextDoneEvent extends StreamEventBase {\n type: 'response.output_text.done'\n text: string\n output_index: number\n content_index: number\n}\nexport interface FunctionCallDeltaEvent extends StreamEventBase {\n type: 'response.function_call.delta'\n delta: string\n output_index: number\n call_id: string\n}\nexport interface FunctionCallDoneEvent extends StreamEventBase {\n type: 'response.function_call.done'\n item: FunctionCallItem\n output_index: number\n}\nexport interface ErrorEvent extends StreamEventBase {\n type: 'error'\n error: ResponseError\n}\n\nexport type StreamEvent =\n | ResponseCreatedEvent\n | ResponseInProgressEvent\n | ResponseCompletedEvent\n | ResponseFailedEvent\n | OutputItemAddedEvent\n | OutputItemDoneEvent\n | TextDeltaEvent\n | TextDoneEvent\n | FunctionCallDeltaEvent\n | FunctionCallDoneEvent\n | ErrorEvent\n\n/** All recognized stream event type strings. */\nexport const STREAM_EVENT_TYPES = new Set<string>([\n 'response.created',\n 'response.in_progress',\n 'response.completed',\n 'response.failed',\n 'response.output_item.added',\n 'response.output_item.done',\n 'response.output_text.delta',\n 'response.output_text.done',\n 'response.function_call.delta',\n 'response.function_call.done',\n 'error',\n])\n\n// ── Input types ────────────────────────────────────────────────────────────\n\nexport interface InputMessage {\n role: Role\n content: string | Content[]\n}\n\nexport const userMessage = (content: string): InputMessage => ({ role: 'user', content })\nexport const assistantMessage = (content: string): InputMessage => ({\n role: 'assistant',\n content,\n})\nexport const systemMessage = (content: string): InputMessage => ({\n role: 'system',\n content,\n})\n\n// ── Config blocks (compression / validation / consistency) ──────────────────\n\nexport interface CompressionConfig {\n strategy?: string\n auto_select?: boolean\n [key: string]: unknown\n}\nexport interface ValidationConfig {\n strategy?: string\n n?: number\n min_confidence?: number\n [key: string]: unknown\n}\nexport interface ConsistencyConfig {\n style_profile?: string\n [key: string]: unknown\n}\n","/**\n * Server-Sent Events parsing for the streaming Responses API.\n *\n * Consumes a `ReadableStream<Uint8Array>` (from `fetch` `response.body`) and\n * yields typed `StreamEvent`s as an AsyncIterable — the idiomatic TS shape for\n * `for await (const event of stream)`. Mirrors the Python SDK's\n * `_parse_sse_stream` / `_parse_sse_event` / `_parse_event_data`.\n */\n\nimport { STREAM_EVENT_TYPES, type StreamEvent } from './types.js'\n\n/** Parse one SSE block (\"event:\" / \"data:\" lines) into a StreamEvent. */\nexport function parseSSEChunk(chunk: string): StreamEvent | null {\n let eventType: string | null = null\n const dataLines: string[] = []\n\n for (const line of chunk.split('\\n')) {\n if (line.startsWith('event:')) {\n eventType = line.slice(6).trim()\n } else if (line.startsWith('data:')) {\n dataLines.push(line.slice(5).trim())\n }\n // ':' comment lines and blanks are ignored.\n }\n\n if (dataLines.length === 0) return null\n const dataStr = dataLines.join('\\n')\n if (dataStr === '[DONE]') return null\n\n let data: unknown\n try {\n data = JSON.parse(dataStr)\n } catch {\n return null\n }\n\n const type =\n eventType ?? (typeof (data as { type?: unknown })?.type === 'string'\n ? (data as { type: string }).type\n : null)\n if (!type || !STREAM_EVENT_TYPES.has(type)) return null\n\n // The gateway sends a discriminated payload; trust the `type` discriminant.\n return data as StreamEvent\n}\n\n/**\n * Turn a byte stream of SSE into an AsyncIterable of events.\n * Splits on the SSE record separator (\"\\n\\n\") and decodes incrementally,\n * giving the caller full back-pressure (we only read as fast as consumed).\n */\nexport async function* parseSSE(\n body: ReadableStream<Uint8Array>,\n): AsyncGenerator<StreamEvent, void, unknown> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let idx: number\n while ((idx = buffer.indexOf('\\n\\n')) !== -1) {\n const chunk = buffer.slice(0, idx)\n buffer = buffer.slice(idx + 2)\n const event = parseSSEChunk(chunk)\n if (event) yield event\n }\n }\n // Flush any trailing event without a final separator.\n const tail = (buffer + decoder.decode()).trim()\n if (tail) {\n const event = parseSSEChunk(tail)\n if (event) yield event\n }\n } finally {\n reader.releaseLock()\n }\n}\n","/**\n * AuraClient — the TypeScript client for the Aura LLM Gateway.\n *\n * Single client (no sync/async split — JS is async by default). Everything\n * returns a Promise; `create({ stream: true })` returns an AsyncIterable of\n * `StreamEvent`. Universal: uses global `fetch` + Web Streams, so it runs on\n * Node 20+, browsers, Deno, Bun, and edge runtimes with no Node-only deps.\n */\n\nimport {\n APIConnectionError,\n APITimeoutError,\n errorFromResponse,\n type AuraError,\n} from './errors.js'\nimport { parseSSE } from './streaming.js'\nimport type {\n CompressionConfig,\n ConsistencyConfig,\n InputMessage,\n Response,\n StreamEvent,\n Tool,\n ValidationConfig,\n} from './types.js'\n\nexport const DEFAULT_BASE_URL = 'http://localhost:8080'\nexport const DEFAULT_TIMEOUT = 60_000\nexport const DEFAULT_MAX_RETRIES = 2\nconst SDK_VERSION = '0.1.0'\n\n/** Status codes worth retrying (plus network errors, handled separately). */\nconst RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504])\n\ntype FetchFn = typeof fetch\n\nexport interface AuraClientOptions {\n /** API key. Falls back to `AURA_API_KEY` env var (Node/Deno/Bun). */\n apiKey?: string\n /** Gateway base URL. Falls back to `AURA_BASE_URL`, then localhost:8080. */\n baseUrl?: string\n /** Per-request timeout in milliseconds (default 60000). */\n timeout?: number\n /** Max retries for retryable failures (default 2; 0 disables). */\n maxRetries?: number\n /** Extra headers merged into every request. */\n headers?: Record<string, string>\n /** Custom fetch implementation (injection for edge runtimes / tests). */\n fetch?: FetchFn\n /** Lifecycle hooks. */\n onRequest?: (req: { method: string; url: string; headers: Headers }) => void\n onResponse?: (res: { status: number; url: string }, durationMs: number) => void\n onError?: (err: AuraError) => void\n}\n\nexport interface ResponseCreateParams {\n model: string\n input: string | InputMessage[] | Array<Record<string, unknown>>\n instructions?: string\n tools?: Tool[]\n tool_choice?: string\n temperature?: number\n max_tokens?: number\n top_p?: number\n previous_response_id?: string\n /** End-user identifier for multi-tenant cost tracking. */\n user?: string\n compression?: CompressionConfig\n validation?: ValidationConfig\n consistency?: ConsistencyConfig\n /** Escape hatch for params not yet typed. */\n [key: string]: unknown\n}\n\nfunction readEnv(name: string): string | undefined {\n // Read process.env via globalThis so this compiles without @types/node and\n // stays safe in browsers/edge runtimes where `process` is undefined.\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process\n return proc?.env?.[name]\n}\n\nconst sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/** Responses API resource. */\nexport class Responses {\n constructor(private readonly client: AuraClient) {}\n\n /** Create a non-streaming response. */\n create(params: ResponseCreateParams & { stream?: false }): Promise<Response>\n /** Create a streaming response (AsyncIterable of events). */\n create(\n params: ResponseCreateParams & { stream: true },\n ): Promise<AsyncIterable<StreamEvent>>\n create(\n params: ResponseCreateParams & { stream?: boolean },\n ): Promise<Response | AsyncIterable<StreamEvent>> {\n const { stream = false } = params\n const payload = this.buildPayload(params)\n if (stream) {\n return this.client._stream('/v1/responses', payload)\n }\n return this.client._request<Response>('POST', '/v1/responses', payload)\n }\n\n private buildPayload(params: ResponseCreateParams): Record<string, unknown> {\n const { input, stream = false, ...rest } = params\n let inputItems: unknown\n if (typeof input === 'string') {\n inputItems = [{ role: 'user', content: input }]\n } else {\n inputItems = input\n }\n const payload: Record<string, unknown> = { ...rest, input: inputItems, stream }\n // Drop undefined keys so we don't send `\"temperature\": null`.\n for (const k of Object.keys(payload)) {\n if (payload[k] === undefined) delete payload[k]\n }\n return payload\n }\n}\n\nexport class AuraClient {\n readonly baseUrl: string\n readonly timeout: number\n readonly maxRetries: number\n readonly responses: Responses\n\n private readonly apiKey: string | undefined\n private readonly headers: Record<string, string>\n private readonly fetchFn: FetchFn\n private readonly opts: AuraClientOptions\n\n constructor(options: AuraClientOptions = {}) {\n this.apiKey = options.apiKey ?? readEnv('AURA_API_KEY')\n this.baseUrl = (options.baseUrl ?? readEnv('AURA_BASE_URL') ?? DEFAULT_BASE_URL).replace(\n /\\/+$/,\n '',\n )\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES\n this.opts = options\n\n const fetchImpl = options.fetch ?? globalThis.fetch\n if (!fetchImpl) {\n throw new Error(\n 'No global fetch available. Pass a `fetch` implementation in AuraClientOptions.',\n )\n }\n this.fetchFn = fetchImpl\n\n this.headers = {\n 'Content-Type': 'application/json',\n 'User-Agent': `aura-typescript/${SDK_VERSION}`,\n ...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),\n ...(options.headers ?? {}),\n }\n\n this.responses = new Responses(this)\n }\n\n /** Build an absolute URL + Headers for a request. */\n private prepare(path: string): { url: string; headers: Headers } {\n return { url: `${this.baseUrl}${path}`, headers: new Headers(this.headers) }\n }\n\n /** Exponential backoff with jitter, capped at 30s; honors Retry-After. */\n private backoffMs(attempt: number, retryAfter?: number): number {\n if (retryAfter && Number.isFinite(retryAfter)) return retryAfter * 1000\n return Math.min(2 ** attempt * 1000 + Math.random() * 1000, 30_000)\n }\n\n /** Non-streaming JSON request with retry + typed error mapping. */\n async _request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const { url, headers } = this.prepare(path)\n let lastError: AuraError | undefined\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method, url, headers })\n try {\n const res = await this.fetchFn(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n })\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (res.ok) {\n return (await res.json()) as T\n }\n\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n if (RETRYABLE_STATUS.has(res.status) && attempt < this.maxRetries) {\n lastError = err\n const retryAfter =\n 'retryAfter' in err ? (err as { retryAfter?: number }).retryAfter : undefined\n await sleep(this.backoffMs(attempt, retryAfter))\n continue\n }\n this.opts.onError?.(err)\n throw err\n } catch (e) {\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n if (attempt < this.maxRetries) {\n lastError = mapped\n await sleep(this.backoffMs(attempt))\n continue\n }\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e // already an AuraError thrown above\n } finally {\n clearTimeout(timer)\n }\n }\n // Exhausted retries.\n throw lastError ?? new APIConnectionError('Request failed after retries')\n }\n\n /**\n * Streaming request → AsyncIterable<StreamEvent>. Streams are NOT retried\n * (re-issuing a partial stream would replay events); errors before the\n * first byte still surface as typed errors.\n */\n async _stream(\n path: string,\n body: unknown,\n ): Promise<AsyncIterable<StreamEvent>> {\n const { url, headers } = this.prepare(path)\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method: 'POST', url, headers })\n\n let res: globalThis.Response\n try {\n res = await this.fetchFn(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: controller.signal,\n })\n } catch (e) {\n clearTimeout(timer)\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e\n }\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (!res.ok) {\n clearTimeout(timer)\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n this.opts.onError?.(err)\n throw err\n }\n if (!res.body) {\n clearTimeout(timer)\n throw new APIConnectionError('Streaming response had no body')\n }\n\n // Clear the timeout once streaming starts — the timeout guards\n // time-to-first-byte, not the (potentially long) stream lifetime.\n clearTimeout(timer)\n return parseSSE(res.body)\n }\n\n /** Map a thrown fetch error to a typed AuraError, or null if not ours. */\n private mapNetworkError(e: unknown): AuraError | null {\n if (e instanceof Error) {\n if (e.name === 'AbortError') return new APITimeoutError(`Request timed out: ${e.message}`)\n if (e.name === 'TypeError' || /fetch failed|network|ECONN|ENOTFOUND/i.test(e.message)) {\n return new APIConnectionError(`Failed to connect: ${e.message}`)\n }\n }\n return null\n }\n}\n\nasync function safeJson(res: globalThis.Response): Promise<unknown> {\n try {\n return await res.json()\n } catch {\n try {\n return { error: { message: await res.text() } }\n } catch {\n return undefined\n }\n }\n}\n","/**\n * A curated catalog of well-known model IDs the Aura gateway routes to.\n *\n * These are *not* an exhaustive or authoritative list — the gateway decides\n * which models are actually available based on the providers it's configured\n * with. They exist for ergonomics: editor autocomplete, fewer typos in model\n * slugs, and discoverability of newer providers (e.g. Fireworks' open-weight\n * catalog). Pass any string you like to `responses.create` — these constants\n * are a convenience, not a constraint.\n *\n * @example\n * ```ts\n * import { AuraClient, KnownModels } from 'aura-llm'\n * const client = new AuraClient({ apiKey: process.env.AURA_API_KEY })\n * await client.responses.create({ model: KnownModels.FIREWORKS_GLM_5P2, input: 'Hi' })\n * ```\n */\nexport const KnownModels = {\n // OpenAI\n GPT_5_4: 'gpt-5.4',\n GPT_5_4_MINI: 'gpt-5.4-mini',\n GPT_5_4_NANO: 'gpt-5.4-nano',\n GPT_4O: 'gpt-4o',\n GPT_4O_MINI: 'gpt-4o-mini',\n\n // Anthropic\n CLAUDE_OPUS_4_7: 'claude-opus-4-7',\n CLAUDE_SONNET_4_6: 'claude-sonnet-4-6',\n CLAUDE_HAIKU_4_5: 'claude-haiku-4-5-20251001',\n\n // Google\n GEMINI_3_PRO: 'gemini-3-pro-preview',\n GEMINI_3_5_FLASH: 'gemini-3.5-flash',\n\n // Fireworks AI — serverless open-weight catalog (see gateway issue #209).\n // IDs are namespaced as accounts/fireworks/models/<slug>.\n FIREWORKS_GLM_5P2: 'accounts/fireworks/models/glm-5p2',\n FIREWORKS_KIMI_K2P6: 'accounts/fireworks/models/kimi-k2p6',\n FIREWORKS_DEEPSEEK_V4_PRO: 'accounts/fireworks/models/deepseek-v4-pro',\n FIREWORKS_QWEN3P6_PLUS: 'accounts/fireworks/models/qwen3p6-plus',\n FIREWORKS_GPT_OSS_120B: 'accounts/fireworks/models/gpt-oss-120b',\n FIREWORKS_GPT_OSS_20B: 'accounts/fireworks/models/gpt-oss-20b',\n} as const\n\n/** A known model slug. Any `string` is still accepted by the API. */\nexport type KnownModel = (typeof KnownModels)[keyof typeof KnownModels]\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/types.ts","../src/streaming.ts","../src/client.ts","../src/models.ts"],"names":[],"mappings":";;;AAyBO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA;AAAA,EAE1B,IAAA;AAAA;AAAA,EAEA,KAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,YAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,OAAA,GAA4B,EAAC,EAAG;AAC3D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,KAAK,WAAA,CAAY,IAAA;AAC7B,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,QAAQ,OAAA,CAAQ,KAAA;AACrB,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AACzB,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAE5B,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAGO,IAAM,QAAA,GAAN,cAAuB,SAAA,CAAU;AAAC;AAGlC,IAAM,mBAAA,GAAN,cAAkC,QAAA,CAAS;AAAA,EAChD,WAAA,CAAY,OAAA,GAAU,4BAAA,EAA8B,OAAA,GAA4B,EAAC,EAAG;AAClF,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,IAAA,EAAM,sBAAA,EAAwB,QAAQ,GAAA,EAAK,GAAG,SAAS,CAAA;AAAA,EAC1E;AACF;AAGO,IAAM,eAAA,GAAN,cAA8B,QAAA,CAAS;AAAA,EAC5C,WAAA,CAAY,OAAA,EAAiB,OAAA,GAA4B,EAAC,EAAG;AAC3D,IAAA,KAAA,CAAM,O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AAAA,EAGlB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,YAAA,EAAc,sBAAA;AAAA;AAAA;AAAA,EAId,iBAAA,EAAmB,mCAAA;AAAA,EACnB,mBAAA,EAAqB,qCAAA;AAAA,EACrB,yBAAA,EAA2B,2CAAA;AAAA,EAC3B,sBAAA,EAAwB,wCAAA;AAAA,EACxB,sBAAA,EAAwB,wCAAA;AAAA,EACxB,qBAAA,EAAuB;AACzB","file":"index.cjs","sourcesContent":["/**\n * Aura SDK error hierarchy.\n *\n * Mirrors the Python SDK's `exceptions.py`:\n * AuraError\n * ├── APIError (errors returned by the gateway)\n * │ ├── AuthenticationError (401)\n * │ ├── BadRequestError (400)\n * │ ├── NotFoundError (404)\n * │ └── RateLimitError (429, carries retryAfter)\n * ├── APIConnectionError (network failure)\n * └── APITimeoutError (exceeded the configured timeout)\n *\n * Use `instanceof` to branch on error class.\n */\n\nexport interface AuraErrorOptions {\n code?: string\n param?: string\n status?: number\n requestId?: string\n responseBody?: unknown\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class AuraError extends Error {\n /** Gateway error code (e.g. `invalid_model`), when present. */\n readonly code?: string\n /** Offending request parameter, when the gateway reports one. */\n readonly param?: string\n /** HTTP status code, when the error originated from a response. */\n readonly status?: number\n /** Gateway request id for support/correlation, when present. */\n readonly requestId?: string\n /** Raw parsed response body, for debugging. */\n readonly responseBody?: unknown\n\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message)\n this.name = this.constructor.name\n this.code = options.code\n this.param = options.param\n this.status = options.status\n this.requestId = options.requestId\n this.responseBody = options.responseBody\n // Restore prototype chain for `instanceof` across transpile targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** An error returned by the Aura API (any non-2xx with a parseable body). */\nexport class APIError extends AuraError {}\n\n/** 401 — invalid or missing API key. */\nexport class AuthenticationError extends APIError {\n constructor(message = 'Invalid or missing API key', options: AuraErrorOptions = {}) {\n super(message, { code: 'authentication_error', status: 401, ...options })\n }\n}\n\n/** 400 — the request was malformed or invalid. */\nexport class BadRequestError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'invalid_request', status: 400, ...options })\n }\n}\n\n/** 404 — resource not found (e.g. an unknown model). */\nexport class NotFoundError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'not_found', status: 404, ...options })\n }\n}\n\n/** 429 — rate limit exceeded. */\nexport class RateLimitError extends APIError {\n /** Seconds to wait before retrying, from the `Retry-After` header. */\n readonly retryAfter?: number\n\n constructor(\n message = 'Rate limit exceeded',\n options: AuraErrorOptions & { retryAfter?: number } = {},\n ) {\n const { retryAfter, ...rest } = options\n super(message, { code: 'rate_limit_exceeded', status: 429, ...rest })\n this.retryAfter = retryAfter\n }\n}\n\n/** Failed to connect to the gateway (DNS, refused, reset, …). */\nexport class APIConnectionError extends AuraError {\n constructor(message = 'Failed to connect to Aura API', options: AuraErrorOptions = {}) {\n super(message, { code: 'connection_error', ...options })\n }\n}\n\n/** The request exceeded the configured `timeout`. */\nexport class APITimeoutError extends AuraError {\n constructor(message = 'Request timed out', options: AuraErrorOptions = {}) {\n super(message, { code: 'timeout', ...options })\n }\n}\n\n/**\n * Map an HTTP status + parsed error body to the right error class.\n * Used by the request layer.\n */\nexport function errorFromResponse(\n status: number,\n body: unknown,\n headers: Headers,\n): AuraError {\n let code = 'unknown_error'\n let message = `HTTP ${status}`\n let param: string | undefined\n if (body && typeof body === 'object') {\n const err = (body as { error?: Record<string, unknown> }).error\n if (err && typeof err === 'object') {\n if (typeof err.code === 'string') code = err.code\n if (typeof err.message === 'string') message = err.message\n if (typeof err.param === 'string') param = err.param\n }\n }\n const requestId =\n headers.get('x-request-id') ?? headers.get('x-aura-request-id') ?? undefined\n const base: AuraErrorOptions = { code, param, status, requestId, responseBody: body }\n\n switch (status) {\n case 401:\n return new AuthenticationError(message, base)\n case 400:\n return new BadRequestError(message, base)\n case 404:\n return new NotFoundError(message, base)\n case 429: {\n const ra = headers.get('retry-after')\n return new RateLimitError(message, {\n ...base,\n retryAfter: ra ? Number.parseInt(ra, 10) : undefined,\n })\n }\n default:\n return new APIError(message, base)\n }\n}\n","/**\n * Open Responses API types, ported from the Python SDK's `types.py`.\n *\n * These are plain TypeScript interfaces/unions (the gateway returns JSON; we\n * don't validate at runtime beyond shape-narrowing on `type`). Helper\n * functions (`outputText`, `toolCalls`) replace the Python `@property`\n * accessors, since interfaces can't carry methods.\n */\n\n// ── Enums (as string-literal unions) ───────────────────────────────────────\n\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'failed'\n | 'incomplete'\n | 'cancelled'\n\nexport type ItemType =\n | 'message'\n | 'function_call'\n | 'function_call_output'\n | 'reasoning'\n\nexport type Role = 'user' | 'assistant' | 'system'\n\n// ── Content ────────────────────────────────────────────────────────────────\n\nexport interface TextContent {\n type: 'text'\n text: string\n}\n\nexport interface ImageContent {\n type: 'image'\n url?: string\n base64?: string\n media_type?: string\n}\n\nexport type Content = TextContent | ImageContent\n\n// ── Items ────────────────────────────────────────────────────────────────\n\nexport interface MessageItem {\n type: 'message'\n id?: string\n role: Role\n content: Content[]\n status?: string\n}\n\nexport interface FunctionCallItem {\n type: 'function_call'\n id?: string\n call_id: string\n name: string\n arguments: string\n status?: string\n}\n\nexport interface FunctionCallOutputItem {\n type: 'function_call_output'\n id?: string\n call_id: string\n output: string\n}\n\nexport interface ReasoningItem {\n type: 'reasoning'\n id?: string\n content: TextContent[]\n status?: string\n}\n\nexport type Item =\n | MessageItem\n | FunctionCallItem\n | FunctionCallOutputItem\n | ReasoningItem\n\n// ── Tools ────────────────────────────────────────────────────────────────\n\nexport interface FunctionDefinition {\n name: string\n description?: string\n parameters?: Record<string, unknown>\n}\n\nexport interface Tool {\n type: 'function'\n function: FunctionDefinition\n}\n\n/** Convenience builder for a function tool (mirrors Tool.function_tool). */\nexport function functionTool(\n name: string,\n description?: string,\n parameters?: Record<string, unknown>,\n): Tool {\n return {\n type: 'function',\n function: { name, ...(description ? { description } : {}), ...(parameters ? { parameters } : {}) },\n }\n}\n\n// ── Usage ────────────────────────────────────────────────────────────────\n\nexport interface Usage {\n input_tokens: number\n output_tokens: number\n total_tokens: number\n input_tokens_details?: Record<string, number>\n output_tokens_details?: Record<string, number>\n cost_usd?: number\n}\n\n// ── Response ─────────────────────────────────────────────────────────────\n\nexport interface ResponseError {\n code: string\n message: string\n param?: string\n}\n\nexport interface AuraMetadata {\n request_id?: string\n model?: string\n provider?: string\n gateway_version?: string\n latency_ms?: number\n agentic?: Record<string, unknown>\n}\n\nexport interface ResponseMetadata {\n aura?: AuraMetadata\n}\n\nexport interface Response {\n id: string\n object: 'response'\n created_at: number\n status: ResponseStatus\n model: string\n output: Item[]\n usage?: Usage\n error?: ResponseError\n metadata?: ResponseMetadata\n previous_response_id?: string\n conversation_id?: string\n}\n\n// ── Response helpers (replace Python @property accessors) ───────────────────\n\n/** Text from the first assistant message output item ('' if none). */\nexport function outputText(response: Response): string {\n for (const item of response.output) {\n if (item.type === 'message' && item.role === 'assistant') {\n return item.content\n .filter((c): c is TextContent => c.type === 'text')\n .map((c) => c.text)\n .join('')\n }\n }\n return ''\n}\n\n/** All function-call items in the output. */\nexport function toolCalls(response: Response): FunctionCallItem[] {\n return response.output.filter(\n (item): item is FunctionCallItem => item.type === 'function_call',\n )\n}\n\nexport const hasToolCalls = (r: Response): boolean => toolCalls(r).length > 0\nexport const isComplete = (r: Response): boolean => r.status === 'completed'\nexport const isFailed = (r: Response): boolean => r.status === 'failed'\n\n// ── Stream events ──────────────────────────────────────────────────────────\n\ninterface StreamEventBase {\n type: string\n sequence?: number\n}\n\nexport interface ResponseCreatedEvent extends StreamEventBase {\n type: 'response.created'\n response: Response\n}\nexport interface ResponseInProgressEvent extends StreamEventBase {\n type: 'response.in_progress'\n response: Response\n}\nexport interface ResponseCompletedEvent extends StreamEventBase {\n type: 'response.completed'\n response: Response\n}\nexport interface ResponseFailedEvent extends StreamEventBase {\n type: 'response.failed'\n response: Response\n}\nexport interface OutputItemAddedEvent extends StreamEventBase {\n type: 'response.output_item.added'\n item: Item\n output_index: number\n}\nexport interface OutputItemDoneEvent extends StreamEventBase {\n type: 'response.output_item.done'\n item: Item\n output_index: number\n}\nexport interface TextDeltaEvent extends StreamEventBase {\n type: 'response.output_text.delta'\n delta: string\n output_index: number\n content_index: number\n}\nexport interface TextDoneEvent extends StreamEventBase {\n type: 'response.output_text.done'\n text: string\n output_index: number\n content_index: number\n}\nexport interface FunctionCallDeltaEvent extends StreamEventBase {\n type: 'response.function_call.delta'\n delta: string\n output_index: number\n call_id: string\n}\nexport interface FunctionCallDoneEvent extends StreamEventBase {\n type: 'response.function_call.done'\n item: FunctionCallItem\n output_index: number\n}\nexport interface ErrorEvent extends StreamEventBase {\n type: 'error'\n error: ResponseError\n}\n\nexport type StreamEvent =\n | ResponseCreatedEvent\n | ResponseInProgressEvent\n | ResponseCompletedEvent\n | ResponseFailedEvent\n | OutputItemAddedEvent\n | OutputItemDoneEvent\n | TextDeltaEvent\n | TextDoneEvent\n | FunctionCallDeltaEvent\n | FunctionCallDoneEvent\n | ErrorEvent\n\n/** All recognized stream event type strings. */\nexport const STREAM_EVENT_TYPES = new Set<string>([\n 'response.created',\n 'response.in_progress',\n 'response.completed',\n 'response.failed',\n 'response.output_item.added',\n 'response.output_item.done',\n 'response.output_text.delta',\n 'response.output_text.done',\n 'response.function_call.delta',\n 'response.function_call.done',\n 'error',\n])\n\n// ── Input types ────────────────────────────────────────────────────────────\n\nexport interface InputMessage {\n role: Role\n content: string | Content[]\n}\n\nexport const userMessage = (content: string): InputMessage => ({ role: 'user', content })\nexport const assistantMessage = (content: string): InputMessage => ({\n role: 'assistant',\n content,\n})\nexport const systemMessage = (content: string): InputMessage => ({\n role: 'system',\n content,\n})\n\n// ── Config blocks (compression / validation / consistency) ──────────────────\n\nexport interface CompressionConfig {\n strategy?: string\n auto_select?: boolean\n [key: string]: unknown\n}\nexport interface ValidationConfig {\n strategy?: string\n n?: number\n min_confidence?: number\n [key: string]: unknown\n}\nexport interface ConsistencyConfig {\n style_profile?: string\n [key: string]: unknown\n}\n","/**\n * Server-Sent Events parsing for the streaming Responses API.\n *\n * Consumes a `ReadableStream<Uint8Array>` (from `fetch` `response.body`) and\n * yields typed `StreamEvent`s as an AsyncIterable — the idiomatic TS shape for\n * `for await (const event of stream)`. Mirrors the Python SDK's\n * `_parse_sse_stream` / `_parse_sse_event` / `_parse_event_data`.\n */\n\nimport { STREAM_EVENT_TYPES, type StreamEvent } from './types.js'\n\n/** Parse one SSE block (\"event:\" / \"data:\" lines) into a StreamEvent. */\nexport function parseSSEChunk(chunk: string): StreamEvent | null {\n let eventType: string | null = null\n const dataLines: string[] = []\n\n for (const line of chunk.split('\\n')) {\n if (line.startsWith('event:')) {\n eventType = line.slice(6).trim()\n } else if (line.startsWith('data:')) {\n dataLines.push(line.slice(5).trim())\n }\n // ':' comment lines and blanks are ignored.\n }\n\n if (dataLines.length === 0) return null\n const dataStr = dataLines.join('\\n')\n if (dataStr === '[DONE]') return null\n\n let data: unknown\n try {\n data = JSON.parse(dataStr)\n } catch {\n return null\n }\n\n const type =\n eventType ?? (typeof (data as { type?: unknown })?.type === 'string'\n ? (data as { type: string }).type\n : null)\n if (!type || !STREAM_EVENT_TYPES.has(type)) return null\n\n // The gateway sends a discriminated payload; trust the `type` discriminant.\n return data as StreamEvent\n}\n\n/**\n * Turn a byte stream of SSE into an AsyncIterable of events.\n * Splits on the SSE record separator (\"\\n\\n\") and decodes incrementally,\n * giving the caller full back-pressure (we only read as fast as consumed).\n */\nexport async function* parseSSE(\n body: ReadableStream<Uint8Array>,\n): AsyncGenerator<StreamEvent, void, unknown> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let idx: number\n while ((idx = buffer.indexOf('\\n\\n')) !== -1) {\n const chunk = buffer.slice(0, idx)\n buffer = buffer.slice(idx + 2)\n const event = parseSSEChunk(chunk)\n if (event) yield event\n }\n }\n // Flush any trailing event without a final separator.\n const tail = (buffer + decoder.decode()).trim()\n if (tail) {\n const event = parseSSEChunk(tail)\n if (event) yield event\n }\n } finally {\n reader.releaseLock()\n }\n}\n","/**\n * AuraClient — the TypeScript client for the Aura LLM Gateway.\n *\n * Single client (no sync/async split — JS is async by default). Everything\n * returns a Promise; `create({ stream: true })` returns an AsyncIterable of\n * `StreamEvent`. Universal: uses global `fetch` + Web Streams, so it runs on\n * Node 20+, browsers, Deno, Bun, and edge runtimes with no Node-only deps.\n */\n\nimport {\n APIConnectionError,\n APITimeoutError,\n errorFromResponse,\n type AuraError,\n} from './errors.js'\nimport { parseSSE } from './streaming.js'\nimport type {\n CompressionConfig,\n ConsistencyConfig,\n InputMessage,\n Response,\n StreamEvent,\n Tool,\n ValidationConfig,\n} from './types.js'\n\nexport const DEFAULT_BASE_URL = 'http://localhost:8080'\nexport const DEFAULT_TIMEOUT = 60_000\nexport const DEFAULT_MAX_RETRIES = 2\nconst SDK_VERSION = '0.1.0'\n\n/** Status codes worth retrying (plus network errors, handled separately). */\nconst RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504])\n\ntype FetchFn = typeof fetch\n\nexport interface AuraClientOptions {\n /** API key. Falls back to `AURA_API_KEY` env var (Node/Deno/Bun). */\n apiKey?: string\n /** Gateway base URL. Falls back to `AURA_BASE_URL`, then localhost:8080. */\n baseUrl?: string\n /** Per-request timeout in milliseconds (default 60000). */\n timeout?: number\n /** Max retries for retryable failures (default 2; 0 disables). */\n maxRetries?: number\n /** Extra headers merged into every request. */\n headers?: Record<string, string>\n /** Custom fetch implementation (injection for edge runtimes / tests). */\n fetch?: FetchFn\n /** Lifecycle hooks. */\n onRequest?: (req: { method: string; url: string; headers: Headers }) => void\n onResponse?: (res: { status: number; url: string }, durationMs: number) => void\n onError?: (err: AuraError) => void\n}\n\nexport interface ResponseCreateParams {\n model: string\n input: string | InputMessage[] | Array<Record<string, unknown>>\n instructions?: string\n tools?: Tool[]\n tool_choice?: string\n temperature?: number\n max_tokens?: number\n top_p?: number\n previous_response_id?: string\n /** End-user identifier for multi-tenant cost tracking. */\n user?: string\n compression?: CompressionConfig\n validation?: ValidationConfig\n consistency?: ConsistencyConfig\n /** Escape hatch for params not yet typed. */\n [key: string]: unknown\n}\n\nfunction readEnv(name: string): string | undefined {\n // Read process.env via globalThis so this compiles without @types/node and\n // stays safe in browsers/edge runtimes where `process` is undefined.\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process\n return proc?.env?.[name]\n}\n\nconst sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/** Responses API resource. */\nexport class Responses {\n constructor(private readonly client: AuraClient) {}\n\n /** Create a non-streaming response. */\n create(params: ResponseCreateParams & { stream?: false }): Promise<Response>\n /** Create a streaming response (AsyncIterable of events). */\n create(\n params: ResponseCreateParams & { stream: true },\n ): Promise<AsyncIterable<StreamEvent>>\n create(\n params: ResponseCreateParams & { stream?: boolean },\n ): Promise<Response | AsyncIterable<StreamEvent>> {\n const { stream = false } = params\n const payload = this.buildPayload(params)\n if (stream) {\n return this.client._stream('/v1/responses', payload)\n }\n return this.client._request<Response>('POST', '/v1/responses', payload)\n }\n\n private buildPayload(params: ResponseCreateParams): Record<string, unknown> {\n const { input, stream = false, ...rest } = params\n let inputItems: unknown\n if (typeof input === 'string') {\n inputItems = [{ role: 'user', content: input }]\n } else {\n inputItems = input\n }\n const payload: Record<string, unknown> = { ...rest, input: inputItems, stream }\n // Drop undefined keys so we don't send `\"temperature\": null`.\n for (const k of Object.keys(payload)) {\n if (payload[k] === undefined) delete payload[k]\n }\n return payload\n }\n}\n\nexport class AuraClient {\n readonly baseUrl: string\n readonly timeout: number\n readonly maxRetries: number\n readonly responses: Responses\n\n private readonly apiKey: string | undefined\n private readonly headers: Record<string, string>\n private readonly fetchFn: FetchFn\n private readonly opts: AuraClientOptions\n\n constructor(options: AuraClientOptions = {}) {\n this.apiKey = options.apiKey ?? readEnv('AURA_API_KEY')\n this.baseUrl = (options.baseUrl ?? readEnv('AURA_BASE_URL') ?? DEFAULT_BASE_URL).replace(\n /\\/+$/,\n '',\n )\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES\n this.opts = options\n\n const fetchImpl = options.fetch ?? globalThis.fetch\n if (!fetchImpl) {\n throw new Error(\n 'No global fetch available. Pass a `fetch` implementation in AuraClientOptions.',\n )\n }\n this.fetchFn = fetchImpl\n\n this.headers = {\n 'Content-Type': 'application/json',\n 'User-Agent': `aura-typescript/${SDK_VERSION}`,\n ...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),\n ...(options.headers ?? {}),\n }\n\n this.responses = new Responses(this)\n }\n\n /** Build an absolute URL + Headers for a request. */\n private prepare(path: string): { url: string; headers: Headers } {\n return { url: `${this.baseUrl}${path}`, headers: new Headers(this.headers) }\n }\n\n /** Exponential backoff with jitter, capped at 30s; honors Retry-After. */\n private backoffMs(attempt: number, retryAfter?: number): number {\n if (retryAfter && Number.isFinite(retryAfter)) return retryAfter * 1000\n return Math.min(2 ** attempt * 1000 + Math.random() * 1000, 30_000)\n }\n\n /** Non-streaming JSON request with retry + typed error mapping. */\n async _request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const { url, headers } = this.prepare(path)\n let lastError: AuraError | undefined\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method, url, headers })\n try {\n const res = await this.fetchFn(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n })\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (res.ok) {\n return (await res.json()) as T\n }\n\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n if (RETRYABLE_STATUS.has(res.status) && attempt < this.maxRetries) {\n lastError = err\n const retryAfter =\n 'retryAfter' in err ? (err as { retryAfter?: number }).retryAfter : undefined\n await sleep(this.backoffMs(attempt, retryAfter))\n continue\n }\n this.opts.onError?.(err)\n throw err\n } catch (e) {\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n if (attempt < this.maxRetries) {\n lastError = mapped\n await sleep(this.backoffMs(attempt))\n continue\n }\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e // already an AuraError thrown above\n } finally {\n clearTimeout(timer)\n }\n }\n // Exhausted retries.\n throw lastError ?? new APIConnectionError('Request failed after retries')\n }\n\n /**\n * Streaming request → AsyncIterable<StreamEvent>. Streams are NOT retried\n * (re-issuing a partial stream would replay events); errors before the\n * first byte still surface as typed errors.\n */\n async _stream(\n path: string,\n body: unknown,\n ): Promise<AsyncIterable<StreamEvent>> {\n const { url, headers } = this.prepare(path)\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method: 'POST', url, headers })\n\n let res: globalThis.Response\n try {\n res = await this.fetchFn(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: controller.signal,\n })\n } catch (e) {\n clearTimeout(timer)\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e\n }\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (!res.ok) {\n clearTimeout(timer)\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n this.opts.onError?.(err)\n throw err\n }\n if (!res.body) {\n clearTimeout(timer)\n throw new APIConnectionError('Streaming response had no body')\n }\n\n // Clear the timeout once streaming starts — the timeout guards\n // time-to-first-byte, not the (potentially long) stream lifetime.\n clearTimeout(timer)\n return parseSSE(res.body)\n }\n\n /** Map a thrown fetch error to a typed AuraError, or null if not ours. */\n private mapNetworkError(e: unknown): AuraError | null {\n if (e instanceof Error) {\n if (e.name === 'AbortError') return new APITimeoutError(`Request timed out: ${e.message}`)\n if (e.name === 'TypeError' || /fetch failed|network|ECONN|ENOTFOUND/i.test(e.message)) {\n return new APIConnectionError(`Failed to connect: ${e.message}`)\n }\n }\n return null\n }\n}\n\nasync function safeJson(res: globalThis.Response): Promise<unknown> {\n try {\n return await res.json()\n } catch {\n try {\n return { error: { message: await res.text() } }\n } catch {\n return undefined\n }\n }\n}\n","/**\n * A curated catalog of well-known model IDs the Aura gateway routes to.\n *\n * These are *not* an exhaustive or authoritative list — the gateway decides\n * which models are actually available based on the providers it's configured\n * with. They exist for ergonomics: editor autocomplete, fewer typos in model\n * slugs, and discoverability of newer providers (e.g. Fireworks' open-weight\n * catalog). Pass any string you like to `responses.create` — these constants\n * are a convenience, not a constraint.\n *\n * @example\n * ```ts\n * import { AuraClient, KnownModels } from 'aura-llm'\n * const client = new AuraClient({ apiKey: process.env.AURA_API_KEY })\n * await client.responses.create({ model: KnownModels.FIREWORKS_GLM_5P2, input: 'Hi' })\n * ```\n */\nexport const KnownModels = {\n // OpenAI (September 2026 line first)\n GPT_6_ASTRA: 'gpt-6-astra',\n GPT_5_6_SOL: 'gpt-5.6-sol',\n GPT_5_6_TERRA: 'gpt-5.6-terra',\n GPT_5_6_LUNA: 'gpt-5.6-luna',\n GPT_5_5: 'gpt-5.5',\n GPT_5_4: 'gpt-5.4',\n GPT_5_4_MINI: 'gpt-5.4-mini',\n GPT_5_4_NANO: 'gpt-5.4-nano',\n GPT_4O: 'gpt-4o',\n GPT_4O_MINI: 'gpt-4o-mini',\n\n // Anthropic (Claude 5-generation ids carry no date suffix)\n CLAUDE_FABLE_5_1: 'claude-fable-5-1',\n CLAUDE_OPUS_5: 'claude-opus-5',\n CLAUDE_SONNET_5: 'claude-sonnet-5',\n CLAUDE_OPUS_4_8: 'claude-opus-4-8',\n CLAUDE_OPUS_4_7: 'claude-opus-4-7',\n CLAUDE_SONNET_4_6: 'claude-sonnet-4-6',\n CLAUDE_HAIKU_4_5: 'claude-haiku-4-5-20251001',\n\n // Google\n GEMINI_3_8_FLASH: 'gemini-3.8-flash',\n GEMINI_3_7_FLASH: 'gemini-3.7-flash',\n GEMINI_3_6_FLASH: 'gemini-3.6-flash',\n GEMINI_3_5_FLASH: 'gemini-3.5-flash',\n GEMINI_3_5_FLASH_LITE: 'gemini-3.5-flash-lite',\n GEMINI_3_PRO: 'gemini-3-pro-preview',\n\n // Fireworks AI — serverless open-weight catalog (see gateway issue #209).\n // IDs are namespaced as accounts/fireworks/models/<slug>.\n FIREWORKS_GLM_5P2: 'accounts/fireworks/models/glm-5p2',\n FIREWORKS_KIMI_K2P6: 'accounts/fireworks/models/kimi-k2p6',\n FIREWORKS_DEEPSEEK_V4_PRO: 'accounts/fireworks/models/deepseek-v4-pro',\n FIREWORKS_QWEN3P6_PLUS: 'accounts/fireworks/models/qwen3p6-plus',\n FIREWORKS_GPT_OSS_120B: 'accounts/fireworks/models/gpt-oss-120b',\n FIREWORKS_GPT_OSS_20B: 'accounts/fireworks/models/gpt-oss-20b',\n} as const\n\n/** A known model slug. Any `string` is still accepted by the API. */\nexport type KnownModel = (typeof KnownModels)[keyof typeof KnownModels]\n"]}
package/dist/index.d.cts CHANGED
@@ -386,16 +386,29 @@ declare function parseSSE(body: ReadableStream<Uint8Array>): AsyncGenerator<Stre
386
386
  * ```
387
387
  */
388
388
  declare const KnownModels: {
389
+ readonly GPT_6_ASTRA: "gpt-6-astra";
390
+ readonly GPT_5_6_SOL: "gpt-5.6-sol";
391
+ readonly GPT_5_6_TERRA: "gpt-5.6-terra";
392
+ readonly GPT_5_6_LUNA: "gpt-5.6-luna";
393
+ readonly GPT_5_5: "gpt-5.5";
389
394
  readonly GPT_5_4: "gpt-5.4";
390
395
  readonly GPT_5_4_MINI: "gpt-5.4-mini";
391
396
  readonly GPT_5_4_NANO: "gpt-5.4-nano";
392
397
  readonly GPT_4O: "gpt-4o";
393
398
  readonly GPT_4O_MINI: "gpt-4o-mini";
399
+ readonly CLAUDE_FABLE_5_1: "claude-fable-5-1";
400
+ readonly CLAUDE_OPUS_5: "claude-opus-5";
401
+ readonly CLAUDE_SONNET_5: "claude-sonnet-5";
402
+ readonly CLAUDE_OPUS_4_8: "claude-opus-4-8";
394
403
  readonly CLAUDE_OPUS_4_7: "claude-opus-4-7";
395
404
  readonly CLAUDE_SONNET_4_6: "claude-sonnet-4-6";
396
405
  readonly CLAUDE_HAIKU_4_5: "claude-haiku-4-5-20251001";
397
- readonly GEMINI_3_PRO: "gemini-3-pro-preview";
406
+ readonly GEMINI_3_8_FLASH: "gemini-3.8-flash";
407
+ readonly GEMINI_3_7_FLASH: "gemini-3.7-flash";
408
+ readonly GEMINI_3_6_FLASH: "gemini-3.6-flash";
398
409
  readonly GEMINI_3_5_FLASH: "gemini-3.5-flash";
410
+ readonly GEMINI_3_5_FLASH_LITE: "gemini-3.5-flash-lite";
411
+ readonly GEMINI_3_PRO: "gemini-3-pro-preview";
399
412
  readonly FIREWORKS_GLM_5P2: "accounts/fireworks/models/glm-5p2";
400
413
  readonly FIREWORKS_KIMI_K2P6: "accounts/fireworks/models/kimi-k2p6";
401
414
  readonly FIREWORKS_DEEPSEEK_V4_PRO: "accounts/fireworks/models/deepseek-v4-pro";
package/dist/index.d.ts CHANGED
@@ -386,16 +386,29 @@ declare function parseSSE(body: ReadableStream<Uint8Array>): AsyncGenerator<Stre
386
386
  * ```
387
387
  */
388
388
  declare const KnownModels: {
389
+ readonly GPT_6_ASTRA: "gpt-6-astra";
390
+ readonly GPT_5_6_SOL: "gpt-5.6-sol";
391
+ readonly GPT_5_6_TERRA: "gpt-5.6-terra";
392
+ readonly GPT_5_6_LUNA: "gpt-5.6-luna";
393
+ readonly GPT_5_5: "gpt-5.5";
389
394
  readonly GPT_5_4: "gpt-5.4";
390
395
  readonly GPT_5_4_MINI: "gpt-5.4-mini";
391
396
  readonly GPT_5_4_NANO: "gpt-5.4-nano";
392
397
  readonly GPT_4O: "gpt-4o";
393
398
  readonly GPT_4O_MINI: "gpt-4o-mini";
399
+ readonly CLAUDE_FABLE_5_1: "claude-fable-5-1";
400
+ readonly CLAUDE_OPUS_5: "claude-opus-5";
401
+ readonly CLAUDE_SONNET_5: "claude-sonnet-5";
402
+ readonly CLAUDE_OPUS_4_8: "claude-opus-4-8";
394
403
  readonly CLAUDE_OPUS_4_7: "claude-opus-4-7";
395
404
  readonly CLAUDE_SONNET_4_6: "claude-sonnet-4-6";
396
405
  readonly CLAUDE_HAIKU_4_5: "claude-haiku-4-5-20251001";
397
- readonly GEMINI_3_PRO: "gemini-3-pro-preview";
406
+ readonly GEMINI_3_8_FLASH: "gemini-3.8-flash";
407
+ readonly GEMINI_3_7_FLASH: "gemini-3.7-flash";
408
+ readonly GEMINI_3_6_FLASH: "gemini-3.6-flash";
398
409
  readonly GEMINI_3_5_FLASH: "gemini-3.5-flash";
410
+ readonly GEMINI_3_5_FLASH_LITE: "gemini-3.5-flash-lite";
411
+ readonly GEMINI_3_PRO: "gemini-3-pro-preview";
399
412
  readonly FIREWORKS_GLM_5P2: "accounts/fireworks/models/glm-5p2";
400
413
  readonly FIREWORKS_KIMI_K2P6: "accounts/fireworks/models/kimi-k2p6";
401
414
  readonly FIREWORKS_DEEPSEEK_V4_PRO: "accounts/fireworks/models/deepseek-v4-pro";
package/dist/index.js CHANGED
@@ -384,19 +384,32 @@ async function safeJson(res) {
384
384
 
385
385
  // src/models.ts
386
386
  var KnownModels = {
387
- // OpenAI
387
+ // OpenAI (September 2026 line first)
388
+ GPT_6_ASTRA: "gpt-6-astra",
389
+ GPT_5_6_SOL: "gpt-5.6-sol",
390
+ GPT_5_6_TERRA: "gpt-5.6-terra",
391
+ GPT_5_6_LUNA: "gpt-5.6-luna",
392
+ GPT_5_5: "gpt-5.5",
388
393
  GPT_5_4: "gpt-5.4",
389
394
  GPT_5_4_MINI: "gpt-5.4-mini",
390
395
  GPT_5_4_NANO: "gpt-5.4-nano",
391
396
  GPT_4O: "gpt-4o",
392
397
  GPT_4O_MINI: "gpt-4o-mini",
393
- // Anthropic
398
+ // Anthropic (Claude 5-generation ids carry no date suffix)
399
+ CLAUDE_FABLE_5_1: "claude-fable-5-1",
400
+ CLAUDE_OPUS_5: "claude-opus-5",
401
+ CLAUDE_SONNET_5: "claude-sonnet-5",
402
+ CLAUDE_OPUS_4_8: "claude-opus-4-8",
394
403
  CLAUDE_OPUS_4_7: "claude-opus-4-7",
395
404
  CLAUDE_SONNET_4_6: "claude-sonnet-4-6",
396
405
  CLAUDE_HAIKU_4_5: "claude-haiku-4-5-20251001",
397
406
  // Google
398
- GEMINI_3_PRO: "gemini-3-pro-preview",
407
+ GEMINI_3_8_FLASH: "gemini-3.8-flash",
408
+ GEMINI_3_7_FLASH: "gemini-3.7-flash",
409
+ GEMINI_3_6_FLASH: "gemini-3.6-flash",
399
410
  GEMINI_3_5_FLASH: "gemini-3.5-flash",
411
+ GEMINI_3_5_FLASH_LITE: "gemini-3.5-flash-lite",
412
+ GEMINI_3_PRO: "gemini-3-pro-preview",
400
413
  // Fireworks AI — serverless open-weight catalog (see gateway issue #209).
401
414
  // IDs are namespaced as accounts/fireworks/models/<slug>.
402
415
  FIREWORKS_GLM_5P2: "accounts/fireworks/models/glm-5p2",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/types.ts","../src/streaming.ts","../src/client.ts","../src/models.ts"],"names":[],"mappings":";AAyBO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA;AAAA,EAE1B,IAAA;AAAA;AAAA,EAEA,KAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,YAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,OAAA,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,OAAO,IAAA;AAAA,EACT;AACF;AAEA,eAAe,SAAS,GAAA,EAA4C;AAClE,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,IAAI,IAAA,EAAK;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,IAAI;AACF,MAAA,OAAO,EAAE,OAAO,EAAE,OAAA,EAAS,MAAM,GAAA,CAAI,IAAA,IAAO,EAAE;AAAA,IAChD,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF;AACF;;;AChSO,IAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,OAAA,EAAS,SAAA;AAAA,EACT,YAAA,EAAc,cAAA;AAAA,EACd,YAAA,EAAc,cAAA;AAAA,EACd,MAAA,EAAQ,QAAA;AAAA,EACR,WAAA,EAAa,aAAA;AAAA;AAAA,EAGb,eAAA,EAAiB,iBAAA;AAAA,EACjB,iBAAA,EAAmB,mBAAA;AAAA,EACnB,gBAAA,EAAkB,2BAAA;AAAA;AAAA,EAGlB,YAAA,EAAc,sBAAA;AAAA,EACd,gBAAA,EAAkB,kBAAA;AAAA;AAAA;AAAA,EAIlB,iBAAA,EAAmB,mCAAA;AAAA,EACnB,mBAAA,EAAqB,qCAAA;AAAA,EACrB,yBAAA,EAA2B,2CAAA;AAAA,EAC3B,sBAAA,EAAwB,wCAAA;AAAA,EACxB,sBAAA,EAAwB,wCAAA;AAAA,EACxB,qBAAA,EAAuB;AACzB","file":"index.js","sourcesContent":["/**\n * Aura SDK error hierarchy.\n *\n * Mirrors the Python SDK's `exceptions.py`:\n * AuraError\n * ├── APIError (errors returned by the gateway)\n * │ ├── AuthenticationError (401)\n * │ ├── BadRequestError (400)\n * │ ├── NotFoundError (404)\n * │ └── RateLimitError (429, carries retryAfter)\n * ├── APIConnectionError (network failure)\n * └── APITimeoutError (exceeded the configured timeout)\n *\n * Use `instanceof` to branch on error class.\n */\n\nexport interface AuraErrorOptions {\n code?: string\n param?: string\n status?: number\n requestId?: string\n responseBody?: unknown\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class AuraError extends Error {\n /** Gateway error code (e.g. `invalid_model`), when present. */\n readonly code?: string\n /** Offending request parameter, when the gateway reports one. */\n readonly param?: string\n /** HTTP status code, when the error originated from a response. */\n readonly status?: number\n /** Gateway request id for support/correlation, when present. */\n readonly requestId?: string\n /** Raw parsed response body, for debugging. */\n readonly responseBody?: unknown\n\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message)\n this.name = this.constructor.name\n this.code = options.code\n this.param = options.param\n this.status = options.status\n this.requestId = options.requestId\n this.responseBody = options.responseBody\n // Restore prototype chain for `instanceof` across transpile targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** An error returned by the Aura API (any non-2xx with a parseable body). */\nexport class APIError extends AuraError {}\n\n/** 401 — invalid or missing API key. */\nexport class AuthenticationError extends APIError {\n constructor(message = 'Invalid or missing API key', options: AuraErrorOptions = {}) {\n super(message, { code: 'authentication_error', status: 401, ...options })\n }\n}\n\n/** 400 — the request was malformed or invalid. */\nexport class BadRequestError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'invalid_request', status: 400, ...options })\n }\n}\n\n/** 404 — resource not found (e.g. an unknown model). */\nexport class NotFoundError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'not_found', status: 404, ...options })\n }\n}\n\n/** 429 — rate limit exceeded. */\nexport class RateLimitError extends APIError {\n /** Seconds to wait before retrying, from the `Retry-After` header. */\n readonly retryAfter?: number\n\n constructor(\n message = 'Rate limit exceeded',\n options: AuraErrorOptions & { retryAfter?: number } = {},\n ) {\n const { retryAfter, ...rest } = options\n super(message, { code: 'rate_limit_exceeded', status: 429, ...rest })\n this.retryAfter = retryAfter\n }\n}\n\n/** Failed to connect to the gateway (DNS, refused, reset, …). */\nexport class APIConnectionError extends AuraError {\n constructor(message = 'Failed to connect to Aura API', options: AuraErrorOptions = {}) {\n super(message, { code: 'connection_error', ...options })\n }\n}\n\n/** The request exceeded the configured `timeout`. */\nexport class APITimeoutError extends AuraError {\n constructor(message = 'Request timed out', options: AuraErrorOptions = {}) {\n super(message, { code: 'timeout', ...options })\n }\n}\n\n/**\n * Map an HTTP status + parsed error body to the right error class.\n * Used by the request layer.\n */\nexport function errorFromResponse(\n status: number,\n body: unknown,\n headers: Headers,\n): AuraError {\n let code = 'unknown_error'\n let message = `HTTP ${status}`\n let param: string | undefined\n if (body && typeof body === 'object') {\n const err = (body as { error?: Record<string, unknown> }).error\n if (err && typeof err === 'object') {\n if (typeof err.code === 'string') code = err.code\n if (typeof err.message === 'string') message = err.message\n if (typeof err.param === 'string') param = err.param\n }\n }\n const requestId =\n headers.get('x-request-id') ?? headers.get('x-aura-request-id') ?? undefined\n const base: AuraErrorOptions = { code, param, status, requestId, responseBody: body }\n\n switch (status) {\n case 401:\n return new AuthenticationError(message, base)\n case 400:\n return new BadRequestError(message, base)\n case 404:\n return new NotFoundError(message, base)\n case 429: {\n const ra = headers.get('retry-after')\n return new RateLimitError(message, {\n ...base,\n retryAfter: ra ? Number.parseInt(ra, 10) : undefined,\n })\n }\n default:\n return new APIError(message, base)\n }\n}\n","/**\n * Open Responses API types, ported from the Python SDK's `types.py`.\n *\n * These are plain TypeScript interfaces/unions (the gateway returns JSON; we\n * don't validate at runtime beyond shape-narrowing on `type`). Helper\n * functions (`outputText`, `toolCalls`) replace the Python `@property`\n * accessors, since interfaces can't carry methods.\n */\n\n// ── Enums (as string-literal unions) ───────────────────────────────────────\n\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'failed'\n | 'incomplete'\n | 'cancelled'\n\nexport type ItemType =\n | 'message'\n | 'function_call'\n | 'function_call_output'\n | 'reasoning'\n\nexport type Role = 'user' | 'assistant' | 'system'\n\n// ── Content ────────────────────────────────────────────────────────────────\n\nexport interface TextContent {\n type: 'text'\n text: string\n}\n\nexport interface ImageContent {\n type: 'image'\n url?: string\n base64?: string\n media_type?: string\n}\n\nexport type Content = TextContent | ImageContent\n\n// ── Items ────────────────────────────────────────────────────────────────\n\nexport interface MessageItem {\n type: 'message'\n id?: string\n role: Role\n content: Content[]\n status?: string\n}\n\nexport interface FunctionCallItem {\n type: 'function_call'\n id?: string\n call_id: string\n name: string\n arguments: string\n status?: string\n}\n\nexport interface FunctionCallOutputItem {\n type: 'function_call_output'\n id?: string\n call_id: string\n output: string\n}\n\nexport interface ReasoningItem {\n type: 'reasoning'\n id?: string\n content: TextContent[]\n status?: string\n}\n\nexport type Item =\n | MessageItem\n | FunctionCallItem\n | FunctionCallOutputItem\n | ReasoningItem\n\n// ── Tools ────────────────────────────────────────────────────────────────\n\nexport interface FunctionDefinition {\n name: string\n description?: string\n parameters?: Record<string, unknown>\n}\n\nexport interface Tool {\n type: 'function'\n function: FunctionDefinition\n}\n\n/** Convenience builder for a function tool (mirrors Tool.function_tool). */\nexport function functionTool(\n name: string,\n description?: string,\n parameters?: Record<string, unknown>,\n): Tool {\n return {\n type: 'function',\n function: { name, ...(description ? { description } : {}), ...(parameters ? { parameters } : {}) },\n }\n}\n\n// ── Usage ────────────────────────────────────────────────────────────────\n\nexport interface Usage {\n input_tokens: number\n output_tokens: number\n total_tokens: number\n input_tokens_details?: Record<string, number>\n output_tokens_details?: Record<string, number>\n cost_usd?: number\n}\n\n// ── Response ─────────────────────────────────────────────────────────────\n\nexport interface ResponseError {\n code: string\n message: string\n param?: string\n}\n\nexport interface AuraMetadata {\n request_id?: string\n model?: string\n provider?: string\n gateway_version?: string\n latency_ms?: number\n agentic?: Record<string, unknown>\n}\n\nexport interface ResponseMetadata {\n aura?: AuraMetadata\n}\n\nexport interface Response {\n id: string\n object: 'response'\n created_at: number\n status: ResponseStatus\n model: string\n output: Item[]\n usage?: Usage\n error?: ResponseError\n metadata?: ResponseMetadata\n previous_response_id?: string\n conversation_id?: string\n}\n\n// ── Response helpers (replace Python @property accessors) ───────────────────\n\n/** Text from the first assistant message output item ('' if none). */\nexport function outputText(response: Response): string {\n for (const item of response.output) {\n if (item.type === 'message' && item.role === 'assistant') {\n return item.content\n .filter((c): c is TextContent => c.type === 'text')\n .map((c) => c.text)\n .join('')\n }\n }\n return ''\n}\n\n/** All function-call items in the output. */\nexport function toolCalls(response: Response): FunctionCallItem[] {\n return response.output.filter(\n (item): item is FunctionCallItem => item.type === 'function_call',\n )\n}\n\nexport const hasToolCalls = (r: Response): boolean => toolCalls(r).length > 0\nexport const isComplete = (r: Response): boolean => r.status === 'completed'\nexport const isFailed = (r: Response): boolean => r.status === 'failed'\n\n// ── Stream events ──────────────────────────────────────────────────────────\n\ninterface StreamEventBase {\n type: string\n sequence?: number\n}\n\nexport interface ResponseCreatedEvent extends StreamEventBase {\n type: 'response.created'\n response: Response\n}\nexport interface ResponseInProgressEvent extends StreamEventBase {\n type: 'response.in_progress'\n response: Response\n}\nexport interface ResponseCompletedEvent extends StreamEventBase {\n type: 'response.completed'\n response: Response\n}\nexport interface ResponseFailedEvent extends StreamEventBase {\n type: 'response.failed'\n response: Response\n}\nexport interface OutputItemAddedEvent extends StreamEventBase {\n type: 'response.output_item.added'\n item: Item\n output_index: number\n}\nexport interface OutputItemDoneEvent extends StreamEventBase {\n type: 'response.output_item.done'\n item: Item\n output_index: number\n}\nexport interface TextDeltaEvent extends StreamEventBase {\n type: 'response.output_text.delta'\n delta: string\n output_index: number\n content_index: number\n}\nexport interface TextDoneEvent extends StreamEventBase {\n type: 'response.output_text.done'\n text: string\n output_index: number\n content_index: number\n}\nexport interface FunctionCallDeltaEvent extends StreamEventBase {\n type: 'response.function_call.delta'\n delta: string\n output_index: number\n call_id: string\n}\nexport interface FunctionCallDoneEvent extends StreamEventBase {\n type: 'response.function_call.done'\n item: FunctionCallItem\n output_index: number\n}\nexport interface ErrorEvent extends StreamEventBase {\n type: 'error'\n error: ResponseError\n}\n\nexport type StreamEvent =\n | ResponseCreatedEvent\n | ResponseInProgressEvent\n | ResponseCompletedEvent\n | ResponseFailedEvent\n | OutputItemAddedEvent\n | OutputItemDoneEvent\n | TextDeltaEvent\n | TextDoneEvent\n | FunctionCallDeltaEvent\n | FunctionCallDoneEvent\n | ErrorEvent\n\n/** All recognized stream event type strings. */\nexport const STREAM_EVENT_TYPES = new Set<string>([\n 'response.created',\n 'response.in_progress',\n 'response.completed',\n 'response.failed',\n 'response.output_item.added',\n 'response.output_item.done',\n 'response.output_text.delta',\n 'response.output_text.done',\n 'response.function_call.delta',\n 'response.function_call.done',\n 'error',\n])\n\n// ── Input types ────────────────────────────────────────────────────────────\n\nexport interface InputMessage {\n role: Role\n content: string | Content[]\n}\n\nexport const userMessage = (content: string): InputMessage => ({ role: 'user', content })\nexport const assistantMessage = (content: string): InputMessage => ({\n role: 'assistant',\n content,\n})\nexport const systemMessage = (content: string): InputMessage => ({\n role: 'system',\n content,\n})\n\n// ── Config blocks (compression / validation / consistency) ──────────────────\n\nexport interface CompressionConfig {\n strategy?: string\n auto_select?: boolean\n [key: string]: unknown\n}\nexport interface ValidationConfig {\n strategy?: string\n n?: number\n min_confidence?: number\n [key: string]: unknown\n}\nexport interface ConsistencyConfig {\n style_profile?: string\n [key: string]: unknown\n}\n","/**\n * Server-Sent Events parsing for the streaming Responses API.\n *\n * Consumes a `ReadableStream<Uint8Array>` (from `fetch` `response.body`) and\n * yields typed `StreamEvent`s as an AsyncIterable — the idiomatic TS shape for\n * `for await (const event of stream)`. Mirrors the Python SDK's\n * `_parse_sse_stream` / `_parse_sse_event` / `_parse_event_data`.\n */\n\nimport { STREAM_EVENT_TYPES, type StreamEvent } from './types.js'\n\n/** Parse one SSE block (\"event:\" / \"data:\" lines) into a StreamEvent. */\nexport function parseSSEChunk(chunk: string): StreamEvent | null {\n let eventType: string | null = null\n const dataLines: string[] = []\n\n for (const line of chunk.split('\\n')) {\n if (line.startsWith('event:')) {\n eventType = line.slice(6).trim()\n } else if (line.startsWith('data:')) {\n dataLines.push(line.slice(5).trim())\n }\n // ':' comment lines and blanks are ignored.\n }\n\n if (dataLines.length === 0) return null\n const dataStr = dataLines.join('\\n')\n if (dataStr === '[DONE]') return null\n\n let data: unknown\n try {\n data = JSON.parse(dataStr)\n } catch {\n return null\n }\n\n const type =\n eventType ?? (typeof (data as { type?: unknown })?.type === 'string'\n ? (data as { type: string }).type\n : null)\n if (!type || !STREAM_EVENT_TYPES.has(type)) return null\n\n // The gateway sends a discriminated payload; trust the `type` discriminant.\n return data as StreamEvent\n}\n\n/**\n * Turn a byte stream of SSE into an AsyncIterable of events.\n * Splits on the SSE record separator (\"\\n\\n\") and decodes incrementally,\n * giving the caller full back-pressure (we only read as fast as consumed).\n */\nexport async function* parseSSE(\n body: ReadableStream<Uint8Array>,\n): AsyncGenerator<StreamEvent, void, unknown> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let idx: number\n while ((idx = buffer.indexOf('\\n\\n')) !== -1) {\n const chunk = buffer.slice(0, idx)\n buffer = buffer.slice(idx + 2)\n const event = parseSSEChunk(chunk)\n if (event) yield event\n }\n }\n // Flush any trailing event without a final separator.\n const tail = (buffer + decoder.decode()).trim()\n if (tail) {\n const event = parseSSEChunk(tail)\n if (event) yield event\n }\n } finally {\n reader.releaseLock()\n }\n}\n","/**\n * AuraClient — the TypeScript client for the Aura LLM Gateway.\n *\n * Single client (no sync/async split — JS is async by default). Everything\n * returns a Promise; `create({ stream: true })` returns an AsyncIterable of\n * `StreamEvent`. Universal: uses global `fetch` + Web Streams, so it runs on\n * Node 20+, browsers, Deno, Bun, and edge runtimes with no Node-only deps.\n */\n\nimport {\n APIConnectionError,\n APITimeoutError,\n errorFromResponse,\n type AuraError,\n} from './errors.js'\nimport { parseSSE } from './streaming.js'\nimport type {\n CompressionConfig,\n ConsistencyConfig,\n InputMessage,\n Response,\n StreamEvent,\n Tool,\n ValidationConfig,\n} from './types.js'\n\nexport const DEFAULT_BASE_URL = 'http://localhost:8080'\nexport const DEFAULT_TIMEOUT = 60_000\nexport const DEFAULT_MAX_RETRIES = 2\nconst SDK_VERSION = '0.1.0'\n\n/** Status codes worth retrying (plus network errors, handled separately). */\nconst RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504])\n\ntype FetchFn = typeof fetch\n\nexport interface AuraClientOptions {\n /** API key. Falls back to `AURA_API_KEY` env var (Node/Deno/Bun). */\n apiKey?: string\n /** Gateway base URL. Falls back to `AURA_BASE_URL`, then localhost:8080. */\n baseUrl?: string\n /** Per-request timeout in milliseconds (default 60000). */\n timeout?: number\n /** Max retries for retryable failures (default 2; 0 disables). */\n maxRetries?: number\n /** Extra headers merged into every request. */\n headers?: Record<string, string>\n /** Custom fetch implementation (injection for edge runtimes / tests). */\n fetch?: FetchFn\n /** Lifecycle hooks. */\n onRequest?: (req: { method: string; url: string; headers: Headers }) => void\n onResponse?: (res: { status: number; url: string }, durationMs: number) => void\n onError?: (err: AuraError) => void\n}\n\nexport interface ResponseCreateParams {\n model: string\n input: string | InputMessage[] | Array<Record<string, unknown>>\n instructions?: string\n tools?: Tool[]\n tool_choice?: string\n temperature?: number\n max_tokens?: number\n top_p?: number\n previous_response_id?: string\n /** End-user identifier for multi-tenant cost tracking. */\n user?: string\n compression?: CompressionConfig\n validation?: ValidationConfig\n consistency?: ConsistencyConfig\n /** Escape hatch for params not yet typed. */\n [key: string]: unknown\n}\n\nfunction readEnv(name: string): string | undefined {\n // Read process.env via globalThis so this compiles without @types/node and\n // stays safe in browsers/edge runtimes where `process` is undefined.\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process\n return proc?.env?.[name]\n}\n\nconst sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/** Responses API resource. */\nexport class Responses {\n constructor(private readonly client: AuraClient) {}\n\n /** Create a non-streaming response. */\n create(params: ResponseCreateParams & { stream?: false }): Promise<Response>\n /** Create a streaming response (AsyncIterable of events). */\n create(\n params: ResponseCreateParams & { stream: true },\n ): Promise<AsyncIterable<StreamEvent>>\n create(\n params: ResponseCreateParams & { stream?: boolean },\n ): Promise<Response | AsyncIterable<StreamEvent>> {\n const { stream = false } = params\n const payload = this.buildPayload(params)\n if (stream) {\n return this.client._stream('/v1/responses', payload)\n }\n return this.client._request<Response>('POST', '/v1/responses', payload)\n }\n\n private buildPayload(params: ResponseCreateParams): Record<string, unknown> {\n const { input, stream = false, ...rest } = params\n let inputItems: unknown\n if (typeof input === 'string') {\n inputItems = [{ role: 'user', content: input }]\n } else {\n inputItems = input\n }\n const payload: Record<string, unknown> = { ...rest, input: inputItems, stream }\n // Drop undefined keys so we don't send `\"temperature\": null`.\n for (const k of Object.keys(payload)) {\n if (payload[k] === undefined) delete payload[k]\n }\n return payload\n }\n}\n\nexport class AuraClient {\n readonly baseUrl: string\n readonly timeout: number\n readonly maxRetries: number\n readonly responses: Responses\n\n private readonly apiKey: string | undefined\n private readonly headers: Record<string, string>\n private readonly fetchFn: FetchFn\n private readonly opts: AuraClientOptions\n\n constructor(options: AuraClientOptions = {}) {\n this.apiKey = options.apiKey ?? readEnv('AURA_API_KEY')\n this.baseUrl = (options.baseUrl ?? readEnv('AURA_BASE_URL') ?? DEFAULT_BASE_URL).replace(\n /\\/+$/,\n '',\n )\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES\n this.opts = options\n\n const fetchImpl = options.fetch ?? globalThis.fetch\n if (!fetchImpl) {\n throw new Error(\n 'No global fetch available. Pass a `fetch` implementation in AuraClientOptions.',\n )\n }\n this.fetchFn = fetchImpl\n\n this.headers = {\n 'Content-Type': 'application/json',\n 'User-Agent': `aura-typescript/${SDK_VERSION}`,\n ...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),\n ...(options.headers ?? {}),\n }\n\n this.responses = new Responses(this)\n }\n\n /** Build an absolute URL + Headers for a request. */\n private prepare(path: string): { url: string; headers: Headers } {\n return { url: `${this.baseUrl}${path}`, headers: new Headers(this.headers) }\n }\n\n /** Exponential backoff with jitter, capped at 30s; honors Retry-After. */\n private backoffMs(attempt: number, retryAfter?: number): number {\n if (retryAfter && Number.isFinite(retryAfter)) return retryAfter * 1000\n return Math.min(2 ** attempt * 1000 + Math.random() * 1000, 30_000)\n }\n\n /** Non-streaming JSON request with retry + typed error mapping. */\n async _request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const { url, headers } = this.prepare(path)\n let lastError: AuraError | undefined\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method, url, headers })\n try {\n const res = await this.fetchFn(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n })\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (res.ok) {\n return (await res.json()) as T\n }\n\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n if (RETRYABLE_STATUS.has(res.status) && attempt < this.maxRetries) {\n lastError = err\n const retryAfter =\n 'retryAfter' in err ? (err as { retryAfter?: number }).retryAfter : undefined\n await sleep(this.backoffMs(attempt, retryAfter))\n continue\n }\n this.opts.onError?.(err)\n throw err\n } catch (e) {\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n if (attempt < this.maxRetries) {\n lastError = mapped\n await sleep(this.backoffMs(attempt))\n continue\n }\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e // already an AuraError thrown above\n } finally {\n clearTimeout(timer)\n }\n }\n // Exhausted retries.\n throw lastError ?? new APIConnectionError('Request failed after retries')\n }\n\n /**\n * Streaming request → AsyncIterable<StreamEvent>. Streams are NOT retried\n * (re-issuing a partial stream would replay events); errors before the\n * first byte still surface as typed errors.\n */\n async _stream(\n path: string,\n body: unknown,\n ): Promise<AsyncIterable<StreamEvent>> {\n const { url, headers } = this.prepare(path)\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method: 'POST', url, headers })\n\n let res: globalThis.Response\n try {\n res = await this.fetchFn(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: controller.signal,\n })\n } catch (e) {\n clearTimeout(timer)\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e\n }\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (!res.ok) {\n clearTimeout(timer)\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n this.opts.onError?.(err)\n throw err\n }\n if (!res.body) {\n clearTimeout(timer)\n throw new APIConnectionError('Streaming response had no body')\n }\n\n // Clear the timeout once streaming starts — the timeout guards\n // time-to-first-byte, not the (potentially long) stream lifetime.\n clearTimeout(timer)\n return parseSSE(res.body)\n }\n\n /** Map a thrown fetch error to a typed AuraError, or null if not ours. */\n private mapNetworkError(e: unknown): AuraError | null {\n if (e instanceof Error) {\n if (e.name === 'AbortError') return new APITimeoutError(`Request timed out: ${e.message}`)\n if (e.name === 'TypeError' || /fetch failed|network|ECONN|ENOTFOUND/i.test(e.message)) {\n return new APIConnectionError(`Failed to connect: ${e.message}`)\n }\n }\n return null\n }\n}\n\nasync function safeJson(res: globalThis.Response): Promise<unknown> {\n try {\n return await res.json()\n } catch {\n try {\n return { error: { message: await res.text() } }\n } catch {\n return undefined\n }\n }\n}\n","/**\n * A curated catalog of well-known model IDs the Aura gateway routes to.\n *\n * These are *not* an exhaustive or authoritative list — the gateway decides\n * which models are actually available based on the providers it's configured\n * with. They exist for ergonomics: editor autocomplete, fewer typos in model\n * slugs, and discoverability of newer providers (e.g. Fireworks' open-weight\n * catalog). Pass any string you like to `responses.create` — these constants\n * are a convenience, not a constraint.\n *\n * @example\n * ```ts\n * import { AuraClient, KnownModels } from 'aura-llm'\n * const client = new AuraClient({ apiKey: process.env.AURA_API_KEY })\n * await client.responses.create({ model: KnownModels.FIREWORKS_GLM_5P2, input: 'Hi' })\n * ```\n */\nexport const KnownModels = {\n // OpenAI\n GPT_5_4: 'gpt-5.4',\n GPT_5_4_MINI: 'gpt-5.4-mini',\n GPT_5_4_NANO: 'gpt-5.4-nano',\n GPT_4O: 'gpt-4o',\n GPT_4O_MINI: 'gpt-4o-mini',\n\n // Anthropic\n CLAUDE_OPUS_4_7: 'claude-opus-4-7',\n CLAUDE_SONNET_4_6: 'claude-sonnet-4-6',\n CLAUDE_HAIKU_4_5: 'claude-haiku-4-5-20251001',\n\n // Google\n GEMINI_3_PRO: 'gemini-3-pro-preview',\n GEMINI_3_5_FLASH: 'gemini-3.5-flash',\n\n // Fireworks AI — serverless open-weight catalog (see gateway issue #209).\n // IDs are namespaced as accounts/fireworks/models/<slug>.\n FIREWORKS_GLM_5P2: 'accounts/fireworks/models/glm-5p2',\n FIREWORKS_KIMI_K2P6: 'accounts/fireworks/models/kimi-k2p6',\n FIREWORKS_DEEPSEEK_V4_PRO: 'accounts/fireworks/models/deepseek-v4-pro',\n FIREWORKS_QWEN3P6_PLUS: 'accounts/fireworks/models/qwen3p6-plus',\n FIREWORKS_GPT_OSS_120B: 'accounts/fireworks/models/gpt-oss-120b',\n FIREWORKS_GPT_OSS_20B: 'accounts/fireworks/models/gpt-oss-20b',\n} as const\n\n/** A known model slug. Any `string` is still accepted by the API. */\nexport type KnownModel = (typeof KnownModels)[keyof typeof KnownModels]\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/types.ts","../src/streaming.ts","../src/client.ts","../src/models.ts"],"names":[],"mappings":";AAyBO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA;AAAA,EAE1B,IAAA;AAAA;AAAA,EAEA,KAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,YAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,OAAA,GAA4B,EAAC,EAAG;AAC3D,IAAA,KAAA,CA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AA;AAAA,EACxB,qBAAA,EAAuB;AACzB","file":"index.js","sourcesContent":["/**\n * Aura SDK error hierarchy.\n *\n * Mirrors the Python SDK's `exceptions.py`:\n * AuraError\n * ├── APIError (errors returned by the gateway)\n * │ ├── AuthenticationError (401)\n * │ ├── BadRequestError (400)\n * │ ├── NotFoundError (404)\n * │ └── RateLimitError (429, carries retryAfter)\n * ├── APIConnectionError (network failure)\n * └── APITimeoutError (exceeded the configured timeout)\n *\n * Use `instanceof` to branch on error class.\n */\n\nexport interface AuraErrorOptions {\n code?: string\n param?: string\n status?: number\n requestId?: string\n responseBody?: unknown\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class AuraError extends Error {\n /** Gateway error code (e.g. `invalid_model`), when present. */\n readonly code?: string\n /** Offending request parameter, when the gateway reports one. */\n readonly param?: string\n /** HTTP status code, when the error originated from a response. */\n readonly status?: number\n /** Gateway request id for support/correlation, when present. */\n readonly requestId?: string\n /** Raw parsed response body, for debugging. */\n readonly responseBody?: unknown\n\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message)\n this.name = this.constructor.name\n this.code = options.code\n this.param = options.param\n this.status = options.status\n this.requestId = options.requestId\n this.responseBody = options.responseBody\n // Restore prototype chain for `instanceof` across transpile targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** An error returned by the Aura API (any non-2xx with a parseable body). */\nexport class APIError extends AuraError {}\n\n/** 401 — invalid or missing API key. */\nexport class AuthenticationError extends APIError {\n constructor(message = 'Invalid or missing API key', options: AuraErrorOptions = {}) {\n super(message, { code: 'authentication_error', status: 401, ...options })\n }\n}\n\n/** 400 — the request was malformed or invalid. */\nexport class BadRequestError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'invalid_request', status: 400, ...options })\n }\n}\n\n/** 404 — resource not found (e.g. an unknown model). */\nexport class NotFoundError extends APIError {\n constructor(message: string, options: AuraErrorOptions = {}) {\n super(message, { code: 'not_found', status: 404, ...options })\n }\n}\n\n/** 429 — rate limit exceeded. */\nexport class RateLimitError extends APIError {\n /** Seconds to wait before retrying, from the `Retry-After` header. */\n readonly retryAfter?: number\n\n constructor(\n message = 'Rate limit exceeded',\n options: AuraErrorOptions & { retryAfter?: number } = {},\n ) {\n const { retryAfter, ...rest } = options\n super(message, { code: 'rate_limit_exceeded', status: 429, ...rest })\n this.retryAfter = retryAfter\n }\n}\n\n/** Failed to connect to the gateway (DNS, refused, reset, …). */\nexport class APIConnectionError extends AuraError {\n constructor(message = 'Failed to connect to Aura API', options: AuraErrorOptions = {}) {\n super(message, { code: 'connection_error', ...options })\n }\n}\n\n/** The request exceeded the configured `timeout`. */\nexport class APITimeoutError extends AuraError {\n constructor(message = 'Request timed out', options: AuraErrorOptions = {}) {\n super(message, { code: 'timeout', ...options })\n }\n}\n\n/**\n * Map an HTTP status + parsed error body to the right error class.\n * Used by the request layer.\n */\nexport function errorFromResponse(\n status: number,\n body: unknown,\n headers: Headers,\n): AuraError {\n let code = 'unknown_error'\n let message = `HTTP ${status}`\n let param: string | undefined\n if (body && typeof body === 'object') {\n const err = (body as { error?: Record<string, unknown> }).error\n if (err && typeof err === 'object') {\n if (typeof err.code === 'string') code = err.code\n if (typeof err.message === 'string') message = err.message\n if (typeof err.param === 'string') param = err.param\n }\n }\n const requestId =\n headers.get('x-request-id') ?? headers.get('x-aura-request-id') ?? undefined\n const base: AuraErrorOptions = { code, param, status, requestId, responseBody: body }\n\n switch (status) {\n case 401:\n return new AuthenticationError(message, base)\n case 400:\n return new BadRequestError(message, base)\n case 404:\n return new NotFoundError(message, base)\n case 429: {\n const ra = headers.get('retry-after')\n return new RateLimitError(message, {\n ...base,\n retryAfter: ra ? Number.parseInt(ra, 10) : undefined,\n })\n }\n default:\n return new APIError(message, base)\n }\n}\n","/**\n * Open Responses API types, ported from the Python SDK's `types.py`.\n *\n * These are plain TypeScript interfaces/unions (the gateway returns JSON; we\n * don't validate at runtime beyond shape-narrowing on `type`). Helper\n * functions (`outputText`, `toolCalls`) replace the Python `@property`\n * accessors, since interfaces can't carry methods.\n */\n\n// ── Enums (as string-literal unions) ───────────────────────────────────────\n\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'failed'\n | 'incomplete'\n | 'cancelled'\n\nexport type ItemType =\n | 'message'\n | 'function_call'\n | 'function_call_output'\n | 'reasoning'\n\nexport type Role = 'user' | 'assistant' | 'system'\n\n// ── Content ────────────────────────────────────────────────────────────────\n\nexport interface TextContent {\n type: 'text'\n text: string\n}\n\nexport interface ImageContent {\n type: 'image'\n url?: string\n base64?: string\n media_type?: string\n}\n\nexport type Content = TextContent | ImageContent\n\n// ── Items ────────────────────────────────────────────────────────────────\n\nexport interface MessageItem {\n type: 'message'\n id?: string\n role: Role\n content: Content[]\n status?: string\n}\n\nexport interface FunctionCallItem {\n type: 'function_call'\n id?: string\n call_id: string\n name: string\n arguments: string\n status?: string\n}\n\nexport interface FunctionCallOutputItem {\n type: 'function_call_output'\n id?: string\n call_id: string\n output: string\n}\n\nexport interface ReasoningItem {\n type: 'reasoning'\n id?: string\n content: TextContent[]\n status?: string\n}\n\nexport type Item =\n | MessageItem\n | FunctionCallItem\n | FunctionCallOutputItem\n | ReasoningItem\n\n// ── Tools ────────────────────────────────────────────────────────────────\n\nexport interface FunctionDefinition {\n name: string\n description?: string\n parameters?: Record<string, unknown>\n}\n\nexport interface Tool {\n type: 'function'\n function: FunctionDefinition\n}\n\n/** Convenience builder for a function tool (mirrors Tool.function_tool). */\nexport function functionTool(\n name: string,\n description?: string,\n parameters?: Record<string, unknown>,\n): Tool {\n return {\n type: 'function',\n function: { name, ...(description ? { description } : {}), ...(parameters ? { parameters } : {}) },\n }\n}\n\n// ── Usage ────────────────────────────────────────────────────────────────\n\nexport interface Usage {\n input_tokens: number\n output_tokens: number\n total_tokens: number\n input_tokens_details?: Record<string, number>\n output_tokens_details?: Record<string, number>\n cost_usd?: number\n}\n\n// ── Response ─────────────────────────────────────────────────────────────\n\nexport interface ResponseError {\n code: string\n message: string\n param?: string\n}\n\nexport interface AuraMetadata {\n request_id?: string\n model?: string\n provider?: string\n gateway_version?: string\n latency_ms?: number\n agentic?: Record<string, unknown>\n}\n\nexport interface ResponseMetadata {\n aura?: AuraMetadata\n}\n\nexport interface Response {\n id: string\n object: 'response'\n created_at: number\n status: ResponseStatus\n model: string\n output: Item[]\n usage?: Usage\n error?: ResponseError\n metadata?: ResponseMetadata\n previous_response_id?: string\n conversation_id?: string\n}\n\n// ── Response helpers (replace Python @property accessors) ───────────────────\n\n/** Text from the first assistant message output item ('' if none). */\nexport function outputText(response: Response): string {\n for (const item of response.output) {\n if (item.type === 'message' && item.role === 'assistant') {\n return item.content\n .filter((c): c is TextContent => c.type === 'text')\n .map((c) => c.text)\n .join('')\n }\n }\n return ''\n}\n\n/** All function-call items in the output. */\nexport function toolCalls(response: Response): FunctionCallItem[] {\n return response.output.filter(\n (item): item is FunctionCallItem => item.type === 'function_call',\n )\n}\n\nexport const hasToolCalls = (r: Response): boolean => toolCalls(r).length > 0\nexport const isComplete = (r: Response): boolean => r.status === 'completed'\nexport const isFailed = (r: Response): boolean => r.status === 'failed'\n\n// ── Stream events ──────────────────────────────────────────────────────────\n\ninterface StreamEventBase {\n type: string\n sequence?: number\n}\n\nexport interface ResponseCreatedEvent extends StreamEventBase {\n type: 'response.created'\n response: Response\n}\nexport interface ResponseInProgressEvent extends StreamEventBase {\n type: 'response.in_progress'\n response: Response\n}\nexport interface ResponseCompletedEvent extends StreamEventBase {\n type: 'response.completed'\n response: Response\n}\nexport interface ResponseFailedEvent extends StreamEventBase {\n type: 'response.failed'\n response: Response\n}\nexport interface OutputItemAddedEvent extends StreamEventBase {\n type: 'response.output_item.added'\n item: Item\n output_index: number\n}\nexport interface OutputItemDoneEvent extends StreamEventBase {\n type: 'response.output_item.done'\n item: Item\n output_index: number\n}\nexport interface TextDeltaEvent extends StreamEventBase {\n type: 'response.output_text.delta'\n delta: string\n output_index: number\n content_index: number\n}\nexport interface TextDoneEvent extends StreamEventBase {\n type: 'response.output_text.done'\n text: string\n output_index: number\n content_index: number\n}\nexport interface FunctionCallDeltaEvent extends StreamEventBase {\n type: 'response.function_call.delta'\n delta: string\n output_index: number\n call_id: string\n}\nexport interface FunctionCallDoneEvent extends StreamEventBase {\n type: 'response.function_call.done'\n item: FunctionCallItem\n output_index: number\n}\nexport interface ErrorEvent extends StreamEventBase {\n type: 'error'\n error: ResponseError\n}\n\nexport type StreamEvent =\n | ResponseCreatedEvent\n | ResponseInProgressEvent\n | ResponseCompletedEvent\n | ResponseFailedEvent\n | OutputItemAddedEvent\n | OutputItemDoneEvent\n | TextDeltaEvent\n | TextDoneEvent\n | FunctionCallDeltaEvent\n | FunctionCallDoneEvent\n | ErrorEvent\n\n/** All recognized stream event type strings. */\nexport const STREAM_EVENT_TYPES = new Set<string>([\n 'response.created',\n 'response.in_progress',\n 'response.completed',\n 'response.failed',\n 'response.output_item.added',\n 'response.output_item.done',\n 'response.output_text.delta',\n 'response.output_text.done',\n 'response.function_call.delta',\n 'response.function_call.done',\n 'error',\n])\n\n// ── Input types ────────────────────────────────────────────────────────────\n\nexport interface InputMessage {\n role: Role\n content: string | Content[]\n}\n\nexport const userMessage = (content: string): InputMessage => ({ role: 'user', content })\nexport const assistantMessage = (content: string): InputMessage => ({\n role: 'assistant',\n content,\n})\nexport const systemMessage = (content: string): InputMessage => ({\n role: 'system',\n content,\n})\n\n// ── Config blocks (compression / validation / consistency) ──────────────────\n\nexport interface CompressionConfig {\n strategy?: string\n auto_select?: boolean\n [key: string]: unknown\n}\nexport interface ValidationConfig {\n strategy?: string\n n?: number\n min_confidence?: number\n [key: string]: unknown\n}\nexport interface ConsistencyConfig {\n style_profile?: string\n [key: string]: unknown\n}\n","/**\n * Server-Sent Events parsing for the streaming Responses API.\n *\n * Consumes a `ReadableStream<Uint8Array>` (from `fetch` `response.body`) and\n * yields typed `StreamEvent`s as an AsyncIterable — the idiomatic TS shape for\n * `for await (const event of stream)`. Mirrors the Python SDK's\n * `_parse_sse_stream` / `_parse_sse_event` / `_parse_event_data`.\n */\n\nimport { STREAM_EVENT_TYPES, type StreamEvent } from './types.js'\n\n/** Parse one SSE block (\"event:\" / \"data:\" lines) into a StreamEvent. */\nexport function parseSSEChunk(chunk: string): StreamEvent | null {\n let eventType: string | null = null\n const dataLines: string[] = []\n\n for (const line of chunk.split('\\n')) {\n if (line.startsWith('event:')) {\n eventType = line.slice(6).trim()\n } else if (line.startsWith('data:')) {\n dataLines.push(line.slice(5).trim())\n }\n // ':' comment lines and blanks are ignored.\n }\n\n if (dataLines.length === 0) return null\n const dataStr = dataLines.join('\\n')\n if (dataStr === '[DONE]') return null\n\n let data: unknown\n try {\n data = JSON.parse(dataStr)\n } catch {\n return null\n }\n\n const type =\n eventType ?? (typeof (data as { type?: unknown })?.type === 'string'\n ? (data as { type: string }).type\n : null)\n if (!type || !STREAM_EVENT_TYPES.has(type)) return null\n\n // The gateway sends a discriminated payload; trust the `type` discriminant.\n return data as StreamEvent\n}\n\n/**\n * Turn a byte stream of SSE into an AsyncIterable of events.\n * Splits on the SSE record separator (\"\\n\\n\") and decodes incrementally,\n * giving the caller full back-pressure (we only read as fast as consumed).\n */\nexport async function* parseSSE(\n body: ReadableStream<Uint8Array>,\n): AsyncGenerator<StreamEvent, void, unknown> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let idx: number\n while ((idx = buffer.indexOf('\\n\\n')) !== -1) {\n const chunk = buffer.slice(0, idx)\n buffer = buffer.slice(idx + 2)\n const event = parseSSEChunk(chunk)\n if (event) yield event\n }\n }\n // Flush any trailing event without a final separator.\n const tail = (buffer + decoder.decode()).trim()\n if (tail) {\n const event = parseSSEChunk(tail)\n if (event) yield event\n }\n } finally {\n reader.releaseLock()\n }\n}\n","/**\n * AuraClient — the TypeScript client for the Aura LLM Gateway.\n *\n * Single client (no sync/async split — JS is async by default). Everything\n * returns a Promise; `create({ stream: true })` returns an AsyncIterable of\n * `StreamEvent`. Universal: uses global `fetch` + Web Streams, so it runs on\n * Node 20+, browsers, Deno, Bun, and edge runtimes with no Node-only deps.\n */\n\nimport {\n APIConnectionError,\n APITimeoutError,\n errorFromResponse,\n type AuraError,\n} from './errors.js'\nimport { parseSSE } from './streaming.js'\nimport type {\n CompressionConfig,\n ConsistencyConfig,\n InputMessage,\n Response,\n StreamEvent,\n Tool,\n ValidationConfig,\n} from './types.js'\n\nexport const DEFAULT_BASE_URL = 'http://localhost:8080'\nexport const DEFAULT_TIMEOUT = 60_000\nexport const DEFAULT_MAX_RETRIES = 2\nconst SDK_VERSION = '0.1.0'\n\n/** Status codes worth retrying (plus network errors, handled separately). */\nconst RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504])\n\ntype FetchFn = typeof fetch\n\nexport interface AuraClientOptions {\n /** API key. Falls back to `AURA_API_KEY` env var (Node/Deno/Bun). */\n apiKey?: string\n /** Gateway base URL. Falls back to `AURA_BASE_URL`, then localhost:8080. */\n baseUrl?: string\n /** Per-request timeout in milliseconds (default 60000). */\n timeout?: number\n /** Max retries for retryable failures (default 2; 0 disables). */\n maxRetries?: number\n /** Extra headers merged into every request. */\n headers?: Record<string, string>\n /** Custom fetch implementation (injection for edge runtimes / tests). */\n fetch?: FetchFn\n /** Lifecycle hooks. */\n onRequest?: (req: { method: string; url: string; headers: Headers }) => void\n onResponse?: (res: { status: number; url: string }, durationMs: number) => void\n onError?: (err: AuraError) => void\n}\n\nexport interface ResponseCreateParams {\n model: string\n input: string | InputMessage[] | Array<Record<string, unknown>>\n instructions?: string\n tools?: Tool[]\n tool_choice?: string\n temperature?: number\n max_tokens?: number\n top_p?: number\n previous_response_id?: string\n /** End-user identifier for multi-tenant cost tracking. */\n user?: string\n compression?: CompressionConfig\n validation?: ValidationConfig\n consistency?: ConsistencyConfig\n /** Escape hatch for params not yet typed. */\n [key: string]: unknown\n}\n\nfunction readEnv(name: string): string | undefined {\n // Read process.env via globalThis so this compiles without @types/node and\n // stays safe in browsers/edge runtimes where `process` is undefined.\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process\n return proc?.env?.[name]\n}\n\nconst sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/** Responses API resource. */\nexport class Responses {\n constructor(private readonly client: AuraClient) {}\n\n /** Create a non-streaming response. */\n create(params: ResponseCreateParams & { stream?: false }): Promise<Response>\n /** Create a streaming response (AsyncIterable of events). */\n create(\n params: ResponseCreateParams & { stream: true },\n ): Promise<AsyncIterable<StreamEvent>>\n create(\n params: ResponseCreateParams & { stream?: boolean },\n ): Promise<Response | AsyncIterable<StreamEvent>> {\n const { stream = false } = params\n const payload = this.buildPayload(params)\n if (stream) {\n return this.client._stream('/v1/responses', payload)\n }\n return this.client._request<Response>('POST', '/v1/responses', payload)\n }\n\n private buildPayload(params: ResponseCreateParams): Record<string, unknown> {\n const { input, stream = false, ...rest } = params\n let inputItems: unknown\n if (typeof input === 'string') {\n inputItems = [{ role: 'user', content: input }]\n } else {\n inputItems = input\n }\n const payload: Record<string, unknown> = { ...rest, input: inputItems, stream }\n // Drop undefined keys so we don't send `\"temperature\": null`.\n for (const k of Object.keys(payload)) {\n if (payload[k] === undefined) delete payload[k]\n }\n return payload\n }\n}\n\nexport class AuraClient {\n readonly baseUrl: string\n readonly timeout: number\n readonly maxRetries: number\n readonly responses: Responses\n\n private readonly apiKey: string | undefined\n private readonly headers: Record<string, string>\n private readonly fetchFn: FetchFn\n private readonly opts: AuraClientOptions\n\n constructor(options: AuraClientOptions = {}) {\n this.apiKey = options.apiKey ?? readEnv('AURA_API_KEY')\n this.baseUrl = (options.baseUrl ?? readEnv('AURA_BASE_URL') ?? DEFAULT_BASE_URL).replace(\n /\\/+$/,\n '',\n )\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT\n this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES\n this.opts = options\n\n const fetchImpl = options.fetch ?? globalThis.fetch\n if (!fetchImpl) {\n throw new Error(\n 'No global fetch available. Pass a `fetch` implementation in AuraClientOptions.',\n )\n }\n this.fetchFn = fetchImpl\n\n this.headers = {\n 'Content-Type': 'application/json',\n 'User-Agent': `aura-typescript/${SDK_VERSION}`,\n ...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),\n ...(options.headers ?? {}),\n }\n\n this.responses = new Responses(this)\n }\n\n /** Build an absolute URL + Headers for a request. */\n private prepare(path: string): { url: string; headers: Headers } {\n return { url: `${this.baseUrl}${path}`, headers: new Headers(this.headers) }\n }\n\n /** Exponential backoff with jitter, capped at 30s; honors Retry-After. */\n private backoffMs(attempt: number, retryAfter?: number): number {\n if (retryAfter && Number.isFinite(retryAfter)) return retryAfter * 1000\n return Math.min(2 ** attempt * 1000 + Math.random() * 1000, 30_000)\n }\n\n /** Non-streaming JSON request with retry + typed error mapping. */\n async _request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const { url, headers } = this.prepare(path)\n let lastError: AuraError | undefined\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method, url, headers })\n try {\n const res = await this.fetchFn(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n })\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (res.ok) {\n return (await res.json()) as T\n }\n\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n if (RETRYABLE_STATUS.has(res.status) && attempt < this.maxRetries) {\n lastError = err\n const retryAfter =\n 'retryAfter' in err ? (err as { retryAfter?: number }).retryAfter : undefined\n await sleep(this.backoffMs(attempt, retryAfter))\n continue\n }\n this.opts.onError?.(err)\n throw err\n } catch (e) {\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n if (attempt < this.maxRetries) {\n lastError = mapped\n await sleep(this.backoffMs(attempt))\n continue\n }\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e // already an AuraError thrown above\n } finally {\n clearTimeout(timer)\n }\n }\n // Exhausted retries.\n throw lastError ?? new APIConnectionError('Request failed after retries')\n }\n\n /**\n * Streaming request → AsyncIterable<StreamEvent>. Streams are NOT retried\n * (re-issuing a partial stream would replay events); errors before the\n * first byte still surface as typed errors.\n */\n async _stream(\n path: string,\n body: unknown,\n ): Promise<AsyncIterable<StreamEvent>> {\n const { url, headers } = this.prepare(path)\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n const started = Date.now()\n this.opts.onRequest?.({ method: 'POST', url, headers })\n\n let res: globalThis.Response\n try {\n res = await this.fetchFn(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: controller.signal,\n })\n } catch (e) {\n clearTimeout(timer)\n const mapped = this.mapNetworkError(e)\n if (mapped) {\n this.opts.onError?.(mapped)\n throw mapped\n }\n throw e\n }\n this.opts.onResponse?.({ status: res.status, url }, Date.now() - started)\n\n if (!res.ok) {\n clearTimeout(timer)\n const parsed = await safeJson(res)\n const err = errorFromResponse(res.status, parsed, res.headers)\n this.opts.onError?.(err)\n throw err\n }\n if (!res.body) {\n clearTimeout(timer)\n throw new APIConnectionError('Streaming response had no body')\n }\n\n // Clear the timeout once streaming starts — the timeout guards\n // time-to-first-byte, not the (potentially long) stream lifetime.\n clearTimeout(timer)\n return parseSSE(res.body)\n }\n\n /** Map a thrown fetch error to a typed AuraError, or null if not ours. */\n private mapNetworkError(e: unknown): AuraError | null {\n if (e instanceof Error) {\n if (e.name === 'AbortError') return new APITimeoutError(`Request timed out: ${e.message}`)\n if (e.name === 'TypeError' || /fetch failed|network|ECONN|ENOTFOUND/i.test(e.message)) {\n return new APIConnectionError(`Failed to connect: ${e.message}`)\n }\n }\n return null\n }\n}\n\nasync function safeJson(res: globalThis.Response): Promise<unknown> {\n try {\n return await res.json()\n } catch {\n try {\n return { error: { message: await res.text() } }\n } catch {\n return undefined\n }\n }\n}\n","/**\n * A curated catalog of well-known model IDs the Aura gateway routes to.\n *\n * These are *not* an exhaustive or authoritative list — the gateway decides\n * which models are actually available based on the providers it's configured\n * with. They exist for ergonomics: editor autocomplete, fewer typos in model\n * slugs, and discoverability of newer providers (e.g. Fireworks' open-weight\n * catalog). Pass any string you like to `responses.create` — these constants\n * are a convenience, not a constraint.\n *\n * @example\n * ```ts\n * import { AuraClient, KnownModels } from 'aura-llm'\n * const client = new AuraClient({ apiKey: process.env.AURA_API_KEY })\n * await client.responses.create({ model: KnownModels.FIREWORKS_GLM_5P2, input: 'Hi' })\n * ```\n */\nexport const KnownModels = {\n // OpenAI (September 2026 line first)\n GPT_6_ASTRA: 'gpt-6-astra',\n GPT_5_6_SOL: 'gpt-5.6-sol',\n GPT_5_6_TERRA: 'gpt-5.6-terra',\n GPT_5_6_LUNA: 'gpt-5.6-luna',\n GPT_5_5: 'gpt-5.5',\n GPT_5_4: 'gpt-5.4',\n GPT_5_4_MINI: 'gpt-5.4-mini',\n GPT_5_4_NANO: 'gpt-5.4-nano',\n GPT_4O: 'gpt-4o',\n GPT_4O_MINI: 'gpt-4o-mini',\n\n // Anthropic (Claude 5-generation ids carry no date suffix)\n CLAUDE_FABLE_5_1: 'claude-fable-5-1',\n CLAUDE_OPUS_5: 'claude-opus-5',\n CLAUDE_SONNET_5: 'claude-sonnet-5',\n CLAUDE_OPUS_4_8: 'claude-opus-4-8',\n CLAUDE_OPUS_4_7: 'claude-opus-4-7',\n CLAUDE_SONNET_4_6: 'claude-sonnet-4-6',\n CLAUDE_HAIKU_4_5: 'claude-haiku-4-5-20251001',\n\n // Google\n GEMINI_3_8_FLASH: 'gemini-3.8-flash',\n GEMINI_3_7_FLASH: 'gemini-3.7-flash',\n GEMINI_3_6_FLASH: 'gemini-3.6-flash',\n GEMINI_3_5_FLASH: 'gemini-3.5-flash',\n GEMINI_3_5_FLASH_LITE: 'gemini-3.5-flash-lite',\n GEMINI_3_PRO: 'gemini-3-pro-preview',\n\n // Fireworks AI — serverless open-weight catalog (see gateway issue #209).\n // IDs are namespaced as accounts/fireworks/models/<slug>.\n FIREWORKS_GLM_5P2: 'accounts/fireworks/models/glm-5p2',\n FIREWORKS_KIMI_K2P6: 'accounts/fireworks/models/kimi-k2p6',\n FIREWORKS_DEEPSEEK_V4_PRO: 'accounts/fireworks/models/deepseek-v4-pro',\n FIREWORKS_QWEN3P6_PLUS: 'accounts/fireworks/models/qwen3p6-plus',\n FIREWORKS_GPT_OSS_120B: 'accounts/fireworks/models/gpt-oss-120b',\n FIREWORKS_GPT_OSS_20B: 'accounts/fireworks/models/gpt-oss-20b',\n} as const\n\n/** A known model slug. Any `string` is still accepted by the API. */\nexport type KnownModel = (typeof KnownModels)[keyof typeof KnownModels]\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aura-llm",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "TypeScript/JavaScript SDK for the Aura LLM Gateway (Open Responses API) — universal fetch, AsyncIterable streaming, typed errors.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",