@jini-ai/agent-runtime 0.2.1 → 0.3.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.
Files changed (163) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-protocol/acp/session.d.ts +206 -1
  3. package/dist/agent-protocol/acp/session.d.ts.map +1 -1
  4. package/dist/agent-protocol/acp/session.js +505 -350
  5. package/dist/agent-protocol/acp/session.js.map +1 -1
  6. package/dist/agent-protocol/core/json-line-stream.d.ts +53 -0
  7. package/dist/agent-protocol/core/json-line-stream.d.ts.map +1 -1
  8. package/dist/agent-protocol/core/json-line-stream.js +307 -255
  9. package/dist/agent-protocol/core/json-line-stream.js.map +1 -1
  10. package/dist/agent-protocol/pi-rpc/events.d.ts +22 -1
  11. package/dist/agent-protocol/pi-rpc/events.d.ts.map +1 -1
  12. package/dist/agent-protocol/pi-rpc/events.js +189 -153
  13. package/dist/agent-protocol/pi-rpc/events.js.map +1 -1
  14. package/dist/agent-protocol/pi-rpc/session.d.ts +39 -0
  15. package/dist/agent-protocol/pi-rpc/session.d.ts.map +1 -1
  16. package/dist/agent-protocol/pi-rpc/session.js +143 -107
  17. package/dist/agent-protocol/pi-rpc/session.js.map +1 -1
  18. package/dist/claude-stream.d.ts +64 -1
  19. package/dist/claude-stream.d.ts.map +1 -1
  20. package/dist/claude-stream.js +568 -441
  21. package/dist/claude-stream.js.map +1 -1
  22. package/dist/defs/aider.d.ts.map +1 -1
  23. package/dist/defs/aider.js +13 -1
  24. package/dist/defs/aider.js.map +1 -1
  25. package/dist/defs/amp.d.ts.map +1 -1
  26. package/dist/defs/amp.js +16 -1
  27. package/dist/defs/amp.js.map +1 -1
  28. package/dist/defs/amr.d.ts +2 -1
  29. package/dist/defs/amr.d.ts.map +1 -1
  30. package/dist/defs/amr.js +12 -1
  31. package/dist/defs/amr.js.map +1 -1
  32. package/dist/defs/antigravity.d.ts +41 -2
  33. package/dist/defs/antigravity.d.ts.map +1 -1
  34. package/dist/defs/antigravity.js +201 -22
  35. package/dist/defs/antigravity.js.map +1 -1
  36. package/dist/defs/claude.d.ts +2 -0
  37. package/dist/defs/claude.d.ts.map +1 -1
  38. package/dist/defs/claude.js +58 -3
  39. package/dist/defs/claude.js.map +1 -1
  40. package/dist/defs/codebuddy.d.ts.map +1 -1
  41. package/dist/defs/codebuddy.js +9 -1
  42. package/dist/defs/codebuddy.js.map +1 -1
  43. package/dist/defs/codex.d.ts +1 -0
  44. package/dist/defs/codex.d.ts.map +1 -1
  45. package/dist/defs/codex.js +34 -0
  46. package/dist/defs/codex.js.map +1 -1
  47. package/dist/defs/copilot.d.ts.map +1 -1
  48. package/dist/defs/copilot.js +15 -1
  49. package/dist/defs/copilot.js.map +1 -1
  50. package/dist/defs/cursor-agent.d.ts.map +1 -1
  51. package/dist/defs/cursor-agent.js +24 -2
  52. package/dist/defs/cursor-agent.js.map +1 -1
  53. package/dist/defs/deepseek.d.ts.map +1 -1
  54. package/dist/defs/deepseek.js +12 -0
  55. package/dist/defs/deepseek.js.map +1 -1
  56. package/dist/defs/devin.d.ts +2 -1
  57. package/dist/defs/devin.d.ts.map +1 -1
  58. package/dist/defs/devin.js +12 -7
  59. package/dist/defs/devin.js.map +1 -1
  60. package/dist/defs/grok-build.d.ts.map +1 -1
  61. package/dist/defs/grok-build.js +10 -0
  62. package/dist/defs/grok-build.js.map +1 -1
  63. package/dist/defs/hermes.d.ts +1 -0
  64. package/dist/defs/hermes.d.ts.map +1 -1
  65. package/dist/defs/hermes.js +3 -0
  66. package/dist/defs/hermes.js.map +1 -1
  67. package/dist/defs/kilo.d.ts +1 -0
  68. package/dist/defs/kilo.d.ts.map +1 -1
  69. package/dist/defs/kilo.js +3 -0
  70. package/dist/defs/kilo.js.map +1 -1
  71. package/dist/defs/kimi.d.ts +1 -0
  72. package/dist/defs/kimi.d.ts.map +1 -1
  73. package/dist/defs/kimi.js +3 -0
  74. package/dist/defs/kimi.js.map +1 -1
  75. package/dist/defs/kiro.d.ts +1 -0
  76. package/dist/defs/kiro.d.ts.map +1 -1
  77. package/dist/defs/kiro.js +3 -0
  78. package/dist/defs/kiro.js.map +1 -1
  79. package/dist/defs/pi.d.ts +1 -1
  80. package/dist/defs/pi.d.ts.map +1 -1
  81. package/dist/defs/pi.js +6 -1
  82. package/dist/defs/pi.js.map +1 -1
  83. package/dist/defs/qoder.d.ts +1 -0
  84. package/dist/defs/qoder.d.ts.map +1 -1
  85. package/dist/defs/qoder.js +15 -0
  86. package/dist/defs/qoder.js.map +1 -1
  87. package/dist/defs/qwen.d.ts.map +1 -1
  88. package/dist/defs/qwen.js +9 -0
  89. package/dist/defs/qwen.js.map +1 -1
  90. package/dist/defs/reasonix.d.ts +1 -0
  91. package/dist/defs/reasonix.d.ts.map +1 -1
  92. package/dist/defs/reasonix.js +3 -0
  93. package/dist/defs/reasonix.js.map +1 -1
  94. package/dist/defs/shared.d.ts +31 -1
  95. package/dist/defs/shared.d.ts.map +1 -1
  96. package/dist/defs/shared.js +35 -0
  97. package/dist/defs/shared.js.map +1 -1
  98. package/dist/defs/trae-cli.d.ts +1 -0
  99. package/dist/defs/trae-cli.d.ts.map +1 -1
  100. package/dist/defs/trae-cli.js +3 -0
  101. package/dist/defs/trae-cli.js.map +1 -1
  102. package/dist/defs/vibe.d.ts +1 -0
  103. package/dist/defs/vibe.d.ts.map +1 -1
  104. package/dist/defs/vibe.js +3 -0
  105. package/dist/defs/vibe.js.map +1 -1
  106. package/dist/detection.d.ts +1 -1
  107. package/dist/detection.d.ts.map +1 -1
  108. package/dist/detection.js +7 -2
  109. package/dist/detection.js.map +1 -1
  110. package/dist/index.d.ts +2 -1
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +2 -1
  113. package/dist/index.js.map +1 -1
  114. package/dist/log-file.d.ts +23 -0
  115. package/dist/log-file.d.ts.map +1 -0
  116. package/dist/log-file.js +56 -0
  117. package/dist/log-file.js.map +1 -0
  118. package/dist/model-registry.d.ts +7 -45
  119. package/dist/model-registry.d.ts.map +1 -1
  120. package/dist/model-registry.js.map +1 -1
  121. package/dist/providers/anthropic-messages.d.ts +198 -6
  122. package/dist/providers/anthropic-messages.d.ts.map +1 -1
  123. package/dist/providers/anthropic-messages.js +317 -140
  124. package/dist/providers/anthropic-messages.js.map +1 -1
  125. package/dist/providers/azure-chat.d.ts +113 -3
  126. package/dist/providers/azure-chat.d.ts.map +1 -1
  127. package/dist/providers/azure-chat.js +114 -21
  128. package/dist/providers/azure-chat.js.map +1 -1
  129. package/dist/providers/connection-guard.d.ts +121 -1
  130. package/dist/providers/connection-guard.d.ts.map +1 -1
  131. package/dist/providers/connection-guard.js +205 -3
  132. package/dist/providers/connection-guard.js.map +1 -1
  133. package/dist/providers/connection-test.d.ts +62 -0
  134. package/dist/providers/connection-test.d.ts.map +1 -0
  135. package/dist/providers/connection-test.js +404 -0
  136. package/dist/providers/connection-test.js.map +1 -0
  137. package/dist/providers/elevenlabs.d.ts.map +1 -1
  138. package/dist/providers/elevenlabs.js +3 -2
  139. package/dist/providers/elevenlabs.js.map +1 -1
  140. package/dist/providers/google-messages.d.ts +208 -7
  141. package/dist/providers/google-messages.d.ts.map +1 -1
  142. package/dist/providers/google-messages.js +331 -105
  143. package/dist/providers/google-messages.js.map +1 -1
  144. package/dist/providers/index.d.ts +1 -0
  145. package/dist/providers/index.d.ts.map +1 -1
  146. package/dist/providers/index.js +1 -0
  147. package/dist/providers/index.js.map +1 -1
  148. package/dist/providers/model-catalog.d.ts.map +1 -1
  149. package/dist/providers/model-catalog.js +21 -0
  150. package/dist/providers/model-catalog.js.map +1 -1
  151. package/dist/providers/ollama-chat.d.ts +190 -1
  152. package/dist/providers/ollama-chat.d.ts.map +1 -1
  153. package/dist/providers/ollama-chat.js +319 -110
  154. package/dist/providers/ollama-chat.js.map +1 -1
  155. package/dist/providers/openai-chat.d.ts +222 -14
  156. package/dist/providers/openai-chat.d.ts.map +1 -1
  157. package/dist/providers/openai-chat.js +377 -128
  158. package/dist/providers/openai-chat.js.map +1 -1
  159. package/dist/providers/sse-decode.d.ts +2 -2
  160. package/dist/providers/sse-decode.js +2 -2
  161. package/dist/types.d.ts +169 -87
  162. package/dist/types.d.ts.map +1 -1
  163. package/package.json +6 -4
@@ -1,3 +1,74 @@
1
+ /**
2
+ * @module providers/openai-chat
3
+ *
4
+ * OpenAI Chat Completions API wire adapter + tool-loop turn-runner. Built
5
+ * fresh against OpenAI's real, current public API docs/reference
6
+ * (`developers.openai.com/api/docs/guides/function-calling` for the
7
+ * `tools`/`tool_calls`/tool-result-message shapes; the streaming delta
8
+ * accumulation shape below matches the long-stable, widely-documented
9
+ * `chat.completion.chunk` SSE format every OpenAI-compatible gateway this
10
+ * package's `providers/model-catalog.ts` already targets — `openai`/
11
+ * `senseaudio`/`aihubmix` protocols — implements identically), per this
12
+ * repo's "verify against real API docs, don't guess from memory"
13
+ * convention. Only the *shape* (a turn-runner with a tool-execution loop)
14
+ * is modeled on OD's `apps/daemon/src/routes/chat.ts`'s `runTurn` per
15
+ * `ADS-memory/reports/proposals/PROP-http-route-packs-chat-model-proxy-
16
+ * 2026-07-21.md` — this task did not have direct access to that file.
17
+ * Sibling of `anthropic-messages.ts`; see that module's header for the
18
+ * shared design rationale (package placement, `extraHeaders` fix for the
19
+ * confirmed OpenRouter product-identity leak, the `turn-end-guard.ts` fix
20
+ * for the confirmed duplicate-`end`-event bug — both apply identically
21
+ * here).
22
+ *
23
+ * **Token-limit fix**: an earlier version of this module sent no
24
+ * `max_tokens`/`max_completion_tokens` field at all — a live comparison
25
+ * against a running Open Design daemon found OD always sends one (defaulting
26
+ * to 8192), model-aware between the legacy and newer field name. This
27
+ * module now wires in `./token-params.js#buildOpenAIChatTokenParam` — that
28
+ * module already existed, itself a verbatim port of OD's real
29
+ * `apps/daemon/src/integrations/openai-chat-token-params.ts`, but was never
30
+ * actually called from here until this fix. `azure-chat.ts` reuses the same
31
+ * module's `buildLegacyMaxTokensParam` (always the legacy `max_tokens`
32
+ * field, not model-aware) — matching OD's own azure handler, which never
33
+ * uses the model-aware picker (Azure deployment names are caller-defined
34
+ * strings, not necessarily matching OpenAI's own model-naming scheme).
35
+ *
36
+ * **Image support**: verified against `developers.openai.com/api/docs/api-reference/chat/create`
37
+ * (the Chat Completions endpoint specifically — a redirect from the older
38
+ * `platform.openai.com/docs/guides/vision` URL now leads to a *different*, newer Responses API
39
+ * guide that uses `input_text`/`input_image` part names; those do not apply here and are not
40
+ * modeled). A user/system/assistant message's `content` may be an array mixing `{type:'text'}` and
41
+ * `{type:'image_url', image_url:{url, detail?}}` parts; `url` is either an `https://` URL (OpenAI's
42
+ * servers fetch it — see `invalidOpenAiContentPartReason`'s doc for why this module does not size-
43
+ * check that case) or a `data:<mime>;base64,<data>` URI. Supported formats per the same reference:
44
+ * PNG/JPEG/WEBP/non-animated GIF; documented limits are a 512 MB total request payload and 1500
45
+ * images per request (this module also applies its own conservative single-image guard — see
46
+ * `MAX_IMAGE_DATA_URI_BASE64_CHARS`'s doc).
47
+ *
48
+ * **Tool messages cannot carry an image** — confirmed against the same API reference: a `role:
49
+ * 'tool'` message's `content` is documented as `string | ChatCompletionContentPartText[]` only
50
+ * ("For tool messages, only type text is supported"). So a vision self-check whose tool result
51
+ * includes a screenshot cannot put that image on the `tool` message itself. `runOpenAiToolTurn`
52
+ * instead keeps the `tool` message text-only (see `splitOpenAiToolResultContent`) and appends one
53
+ * synthetic `role: 'user'` message carrying every image from the batch, built up while iterating
54
+ * every `tool_call` in the batch but appended exactly once, after every one of that batch's `tool`
55
+ * messages — never interleaved between them or emitted per-call, since OpenAI requires every `tool`
56
+ * message answering a batch of parallel `tool_calls` to directly follow the assistant message with
57
+ * nothing else in between. This is a real 400 if violated, not a style concern — see
58
+ * `runOpenAiToolTurn`'s tool-loop body and its test file's multi-tool-call image test.
59
+ *
60
+ * **This synthetic follow-up message is a workaround for the OpenAI wire protocol's own text-only
61
+ * `tool` message, not structure this module invented.** Anthropic's `tool_result` content block can
62
+ * carry an image directly (see `anthropic-messages.ts`) and needs no such split. Each image (or run
63
+ * of images) in the follow-up is preceded by a plain-text label naming the tool call it answers
64
+ * (name + `tool_call_id`) — an unlabeled image sitting alone in a `user` message is indistinguishable
65
+ * from a human having just pasted a screenshot, which in a vision self-check loop risks the model
66
+ * treating its own tool's output as a brand-new user request instead of a continuation of its own
67
+ * reasoning.
68
+ */
69
+ import { createRoleMarkerGuard } from '../role-marker-guard.js';
70
+ import { type DnsLookupAddress, type DnsLookupFn, type PinnedFetch } from './connection-guard.js';
71
+ import { type DecodedSseEvent } from './sse-decode.js';
1
72
  import { type TurnEndReason } from './turn-end-guard.js';
2
73
  export interface OpenAiFunctionToolDef {
3
74
  readonly type: 'function';
@@ -15,9 +86,23 @@ export interface OpenAiToolCallParam {
15
86
  readonly arguments: string;
16
87
  };
17
88
  }
89
+ export interface OpenAiTextPart {
90
+ readonly type: 'text';
91
+ readonly text: string;
92
+ }
93
+ /** `detail` defaults to `'auto'` server-side when omitted — never sent unless the caller supplies it. */
94
+ export interface OpenAiImageUrlPart {
95
+ readonly type: 'image_url';
96
+ readonly image_url: {
97
+ readonly url: string;
98
+ readonly detail?: 'auto' | 'low' | 'high';
99
+ };
100
+ }
101
+ /** A user/system/assistant message's `content` array item. Not legal inside a `role: 'tool'` message — see module doc's "Tool messages cannot carry an image" section. */
102
+ export type OpenAiContentPart = OpenAiTextPart | OpenAiImageUrlPart;
18
103
  export interface OpenAiMessageParam {
19
104
  readonly role: 'system' | 'user' | 'assistant' | 'tool';
20
- readonly content: string | null;
105
+ readonly content: string | null | readonly OpenAiContentPart[];
21
106
  readonly tool_calls?: readonly OpenAiToolCallParam[];
22
107
  readonly tool_call_id?: string;
23
108
  readonly name?: string;
@@ -27,8 +112,9 @@ export interface OpenAiToolCall {
27
112
  readonly name: string;
28
113
  readonly input: unknown;
29
114
  }
115
+ /** `content` may include `OpenAiImageUrlPart`s (e.g. a vision self-check's screenshot) even though the wire `tool` message can't carry them directly — `runOpenAiToolTurn` splits them onto a follow-up `user` message; see module doc. */
30
116
  export interface OpenAiToolResult {
31
- readonly content: string;
117
+ readonly content: string | readonly OpenAiContentPart[];
32
118
  }
33
119
  /** Host-owned tool execution — same "the collaborator is always supplied" convention as `anthropic-messages.ts#AnthropicToolExecutor`. */
34
120
  export type OpenAiToolExecutor = (call: OpenAiToolCall) => Promise<OpenAiToolResult>;
@@ -47,7 +133,7 @@ export type OpenAiTurnEvent = {
47
133
  } | {
48
134
  readonly type: 'tool_result';
49
135
  readonly toolUseId: string;
50
- readonly content: string;
136
+ readonly content: string | readonly OpenAiContentPart[];
51
137
  readonly isError: boolean;
52
138
  } | {
53
139
  readonly type: 'usage';
@@ -81,6 +167,10 @@ export interface OpenAiTurnOptions {
81
167
  readonly signal?: AbortSignal;
82
168
  /** Caller-supplied extra headers — see `anthropic-messages.ts#AnthropicTurnOptions.extraHeaders`'s doc for why this exists and what it fixes. */
83
169
  readonly extraHeaders?: Record<string, string>;
170
+ /** Injectable HTTP transport, defaulting to {@link pinnedFetch} (SSRF-guarded, DNS-pinned). See `anthropic-messages.ts#AnthropicTurnOptions.fetchImpl`'s doc for the seam this exists for and why production wiring must never override it. Forwarded to {@link runOpenAiCompatibleRequest} via `OpenAiCompatibleRequestInit.fetchImpl` — `azure-chat.ts`/`ollama-chat.ts` accept and forward their own copy of this field the same way. */
171
+ readonly fetchImpl?: PinnedFetch;
172
+ /** Injectable DNS resolver for {@link validateBaseUrlResolved}'s DNS-pinning check, defaulting to {@link defaultDnsLookup}. Same test-only override rationale as `fetchImpl`. */
173
+ readonly dnsLookup?: DnsLookupFn;
84
174
  }
85
175
  export interface OpenAiTurnResult {
86
176
  readonly finishReason: string | null;
@@ -88,6 +178,15 @@ export interface OpenAiTurnResult {
88
178
  }
89
179
  /** Matches OD's own default (`apps/daemon/src/routes/chat.ts`'s openai/azure handlers both fall back to this when the caller doesn't supply one) — a real, explicit bound is always sent, never an unbounded request. */
90
180
  export declare const DEFAULT_OPENAI_MAX_TOKENS = 8192;
181
+ export declare function openAiRequestUrl(baseUrl: string | undefined): string;
182
+ export declare function openAiHeaders(options: OpenAiTurnOptions): Record<string, string>;
183
+ export declare function openAiRequestBody(options: OpenAiTurnOptions, messages: readonly OpenAiMessageParam[]): Record<string, unknown>;
184
+ export declare function extractOpenAiErrorDetail(rawText: string): string;
185
+ export interface PendingToolCall {
186
+ id: string;
187
+ name: string;
188
+ argsJson: string;
189
+ }
91
190
  /** Shared return shape for one reduced OpenAI-compatible streaming request — exported so every OpenAI-compatible provider turn-runner (`azure-chat.ts`, `ollama-chat.ts`) can type its own internal single-request helper against it without re-declaring an identical interface. */
92
191
  export interface OpenAiCompatibleRequestOutcome {
93
192
  readonly finishReason: string | null;
@@ -99,6 +198,8 @@ export interface OpenAiCompatibleRequestInit {
99
198
  readonly url: string;
100
199
  readonly headers: Record<string, string>;
101
200
  readonly body: Record<string, unknown>;
201
+ /** The address `validateBaseUrlResolved` validated for `url`'s hostname, forwarded verbatim to `pinnedFetch` so the connection dials it directly instead of re-resolving DNS. `undefined` for the loopback-literal / IP-literal hosts that skip resolution — see `pinnedFetch`'s doc. */
202
+ readonly pinnedAddress?: DnsLookupAddress;
102
203
  readonly signal?: AbortSignal;
103
204
  /** Secrets to strip out of any error message surfaced to the caller (e.g. the request's API key) — forwarded verbatim to `redactSecrets`'s `exactSecrets` parameter. */
104
205
  readonly redactSecretsList: ReadonlyArray<string | undefined | null>;
@@ -120,23 +221,130 @@ export interface OpenAiCompatibleRequestInit {
120
221
  * cannot retry again.
121
222
  */
122
223
  readonly retryableBody?: (status: number, rawErrorText: string) => Record<string, unknown> | null | undefined;
224
+ /** Injectable HTTP transport, defaulting to {@link pinnedFetch} (SSRF-guarded, DNS-pinned) — forwarded verbatim from the calling provider's own `OpenAiTurnOptions.fetchImpl`/`AzureTurnOptions.fetchImpl`/`OllamaTurnOptions.fetchImpl`. See `anthropic-messages.ts#AnthropicTurnOptions.fetchImpl`'s doc for the seam this exists for. */
225
+ readonly fetchImpl?: PinnedFetch;
123
226
  }
227
+ /** Mutable reduction state threaded through one streaming request's SSE frame handlers (below). Grouped into one object so each handler takes a single parameter instead of several. Exported so a unit test can construct one directly (e.g. `{ guard: createRoleMarkerGuard('t'), toolCalls: new Map(), fullText: '', finishReason: null, usage: null }`) without going through a full `runOpenAiToolTurn` call. */
228
+ export interface OpenAiStreamState {
229
+ readonly guard: ReturnType<typeof createRoleMarkerGuard>;
230
+ readonly toolCalls: Map<number, PendingToolCall>;
231
+ fullText: string;
232
+ finishReason: string | null;
233
+ usage: Record<string, unknown> | null;
234
+ }
235
+ /** Parses one SSE frame's data as a JSON object, or `null` for a malformed/empty keep-alive frame or a non-object payload — both are tolerated by the caller as "nothing to do this frame". */
236
+ export declare function parseOpenAiSseData(raw: string): Record<string, unknown> | null;
237
+ export declare function applyOpenAiStreamUsage(state: OpenAiStreamState, data: Record<string, unknown>, onEvent: (event: OpenAiTurnEvent) => void): void;
238
+ /** The chunk's first (and, for Chat Completions, only) choice — `null` when the chunk carries no choice at all (e.g. a usage-only trailer chunk). */
239
+ export declare function firstOpenAiChoice(data: Record<string, unknown>): Record<string, unknown> | null;
240
+ /**
241
+ * Feeds one text delta through the role-marker guard and emits the safe portion. Returns
242
+ * `'break'` once the guard flags contamination (the caller ends the turn immediately), otherwise
243
+ * `'continue'` — same contract as `anthropic-messages.ts#handleAnthropicTextDelta`.
244
+ */
245
+ export declare function handleOpenAiTextContentDelta(state: OpenAiStreamState, content: string, onEvent: (event: OpenAiTurnEvent) => void): 'continue' | 'break';
246
+ /** Builds a fresh `PendingToolCall` from the streaming chunk that first mentions a given tool-call index — OpenAI sends `id`/`function.name` once, on that first chunk, then dribbles `function.arguments` in across subsequent chunks (accumulated separately by the caller). */
247
+ export declare function newPendingOpenAiToolCall(rawCall: Record<string, unknown>, index: number): PendingToolCall;
248
+ /** Accumulates one `delta.tool_calls[]` entry from a streaming chunk into its running `PendingToolCall`. */
249
+ export declare function accumulateOpenAiToolCallDelta(state: OpenAiStreamState, rawCall: unknown): void;
250
+ /** Reduces one chunk's `choices[0]` — `finish_reason`, text content, and tool-call deltas — into `state`. Returns `'break'` when the text-delta guard detects contamination. */
251
+ export declare function handleOpenAiChoiceDelta(state: OpenAiStreamState, choice: Record<string, unknown>, onEvent: (event: OpenAiTurnEvent) => void): 'continue' | 'break';
252
+ /** Parses one accumulated tool call's `argsJson`, falling back to `{}` for empty or malformed JSON — mirrors Anthropic's identical fallback for `input_json_delta` accumulation in `anthropic-messages.ts`. */
253
+ export declare function resolveOpenAiToolCalls(pending: ReadonlyMap<number, PendingToolCall>): OpenAiToolCall[];
254
+ export type OpenAiFrameResult = 'continue' | 'done' | 'contaminated';
255
+ /**
256
+ * Reduces one decoded SSE frame into `state`, reporting what the caller's loop should do next:
257
+ * `'done'` on the `[DONE]` sentinel, `'contaminated'` once the role-marker guard trips on this
258
+ * frame's text delta, otherwise `'continue'`. Pulling per-frame dispatch out of the loop body
259
+ * turns what would be four sequential, nesting-penalized `if`s into a single function call plus
260
+ * one outcome check — see `runOpenAiCompatibleRequest`'s loop below.
261
+ */
262
+ export declare function processOpenAiStreamFrame(state: OpenAiStreamState, frame: DecodedSseEvent, onEvent: (event: OpenAiTurnEvent) => void): OpenAiFrameResult;
124
263
  /**
125
264
  * Runs exactly one OpenAI-compatible (Chat Completions JSON wire format)
126
265
  * streaming HTTP request and reduces its SSE events into a single outcome.
127
- * Extracted so this ~150-line SSE-reduction loop has exactly one
128
- * implementation shared by every OpenAI-compatible provider turn-runner in
129
- * this package: `runOpenAiToolTurn` itself (below), plus
130
- * `azure-chat.ts#runAzureToolTurn` and `ollama-chat.ts#runOllamaToolTurn` —
131
- * both target byte-identical chat-completions JSON, differing only in URL
132
- * and auth. Callers own their own base-URL SSRF validation
133
- * (`validateBaseUrl`) and URL/header/body construction *before* calling
134
- * this function it only knows how to run *a* request against whatever
135
- * URL/headers/body it is handed, and has no opinion on any provider's
136
- * defaults. Mirrors `anthropic-messages.ts#runSingleAnthropicRequest`'s
137
- * `emitEnd` contract — see that function's doc.
266
+ * Extracted so this SSE-reduction loop has exactly one implementation
267
+ * shared by every OpenAI-compatible provider turn-runner in this package:
268
+ * `runOpenAiToolTurn` itself (below), plus `azure-chat.ts#runAzureToolTurn`
269
+ * and `ollama-chat.ts#runOllamaToolTurn` — both target byte-identical
270
+ * chat-completions JSON, differing only in URL and auth. Callers own their
271
+ * own base-URL SSRF validation (`validateBaseUrl`) and URL/header/body
272
+ * construction *before* calling this function — it only knows how to run
273
+ * *a* request against whatever URL/headers/body it is handed, and has no
274
+ * opinion on any provider's defaults. Mirrors
275
+ * `anthropic-messages.ts#runSingleAnthropicRequest`'s `emitEnd` contract —
276
+ * see that function's doc.
138
277
  */
139
278
  export declare function runOpenAiCompatibleRequest(init: OpenAiCompatibleRequestInit): Promise<OpenAiCompatibleRequestOutcome>;
279
+ /**
280
+ * Validates one content part against OpenAI's real format/size constraints. Returns the violation
281
+ * reason, or `null` when the part is legal to send.
282
+ *
283
+ * A plain `https://` `image_url` (not a `data:` URI) is intentionally not size-checked: OpenAI's
284
+ * servers fetch that URL, not this adapter, so there is no local payload to bound — same threat-
285
+ * model split as `anthropic-messages.ts`'s URL-sourced skip (`connection-guard.ts`'s SSRF guard
286
+ * protects this adapter's own outbound `baseUrl` request, a different thing; an `image_url` that
287
+ * points at attacker-chosen infrastructure is a request OpenAI's own servers make, not this one).
288
+ *
289
+ * @complexity O(1) — reads `data.length`, never decodes or parses the base64 payload.
290
+ */
291
+ export declare function invalidOpenAiContentPartReason(part: OpenAiContentPart): string | null;
292
+ export interface SanitizedOpenAiToolResult {
293
+ readonly content: string | readonly OpenAiContentPart[];
294
+ readonly isError: boolean;
295
+ }
296
+ /**
297
+ * Runtime guard applied to every `OpenAiToolExecutor` result before it is wired onto the outbound
298
+ * request or reported via `onEvent`. `OpenAiToolResult` is host-owned (see `OpenAiToolExecutor`'s
299
+ * "Host-owned tool execution" doc comment) — the TS content-part union only constrains a
300
+ * well-behaved host at compile time, not a buggy one at runtime, e.g. a screenshot helper that
301
+ * hands back an oversized PNG or a HEIC file mislabeled as `image/jpeg`. Rather than forwarding an
302
+ * invalid part and letting OpenAI reject the *entire* turn with an opaque upstream 400, this
303
+ * substitutes a plain-text `isError: true` result the model can see and react to — matching this
304
+ * package's existing security-conscious posture (`connection-guard.ts`'s SSRF guard,
305
+ * `role-marker-guard.ts`'s contamination guard, and `anthropic-messages.ts`'s identical guard).
306
+ *
307
+ * @complexity O(n) in the number of content parts; O(1) per part (see `invalidOpenAiContentPartReason`).
308
+ */
309
+ export declare function sanitizeOpenAiToolResult(result: OpenAiToolResult): SanitizedOpenAiToolResult;
310
+ export interface SplitOpenAiToolResultContent {
311
+ readonly toolMessageContent: string | readonly OpenAiTextPart[];
312
+ readonly imageParts: readonly OpenAiImageUrlPart[];
313
+ }
314
+ /**
315
+ * Splits one (already-sanitized) tool result's content into what can legally sit on the wire
316
+ * `role: 'tool'` message (text only — see module doc's "Tool messages cannot carry an image"
317
+ * section) and the `image_url` parts that must instead travel on a follow-up `user` message.
318
+ *
319
+ * A string `content` is left untouched (`imageParts: []`) — this is the pre-existing, unchanged
320
+ * path every current caller already exercises. For an array, text parts are kept in order for the
321
+ * `tool` message; if there is no text at all (an image-only result), a single placeholder text part
322
+ * is substituted so the `tool` message's content is never empty (OpenAI rejects empty content).
323
+ *
324
+ * @complexity O(n) in the number of content parts.
325
+ */
326
+ export declare function splitOpenAiToolResultContent(content: string | readonly OpenAiContentPart[]): SplitOpenAiToolResultContent;
327
+ /**
328
+ * Decides why the tool loop should stop after one request, or returns `null` when it should
329
+ * instead proceed to execute the pending tool calls — mirrors
330
+ * `anthropic-messages.ts#anthropicLoopExitReason`'s pure decision/effect split.
331
+ */
332
+ export declare function openAiLoopExitReason(outcome: OpenAiCompatibleRequestOutcome, toolTurns: number, maxToolTurns: number): OpenAiTurnEndReason | null;
333
+ export interface OpenAiToolExecutionOutcome {
334
+ readonly toolResultMessages: OpenAiMessageParam[];
335
+ readonly followUpParts: OpenAiContentPart[];
336
+ }
337
+ /**
338
+ * Runs every pending tool call in order, sanitizing and splitting each result into its `tool`
339
+ * message plus any labeled image parts for the batch's single follow-up `user` message — see
340
+ * module doc's "Tool messages cannot carry an image" section for why the split exists and why the
341
+ * follow-up is assembled once per batch rather than per call.
342
+ */
343
+ export declare function executeOpenAiToolCalls(executeTool: OpenAiToolExecutor, calls: readonly OpenAiToolCall[], onEvent: (event: OpenAiTurnEvent) => void): Promise<OpenAiToolExecutionOutcome>;
344
+ /** Builds the assistant turn that records the model's pending tool calls in `messages` history — `content` falls back to `null` (never `''`) per the wire schema. */
345
+ export declare function buildOpenAiAssistantToolCallMessage(text: string, toolCalls: readonly OpenAiToolCallParam[]): OpenAiMessageParam;
346
+ /** Appends the batch's `tool` messages plus, when present, the single labeled-image follow-up message — see module doc's "Tool messages cannot carry an image" section for why the follow-up is at most one message per batch. */
347
+ export declare function buildOpenAiToolExchangeMessages(toolResultMessages: readonly OpenAiMessageParam[], followUpParts: readonly OpenAiContentPart[]): OpenAiMessageParam[];
140
348
  /**
141
349
  * Runs a full OpenAI Chat Completions turn, including the tool-execution
142
350
  * loop when `options.executeTool` is supplied and the model requests a
@@ -1 +1 @@
1
- {"version":3,"file":"openai-chat.d.ts","sourceRoot":"","sources":["../../src/providers/openai-chat.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE7E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC9C,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB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