@genesislcap/foundation-ai 15.90.4 → 15.92.0-HT-305.1

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 (35) hide show
  1. package/README.md +26 -103
  2. package/dist/dts/ai-provider.d.ts +5 -3
  3. package/dist/dts/ai-provider.d.ts.map +1 -1
  4. package/dist/dts/index.d.ts +7 -4
  5. package/dist/dts/index.d.ts.map +1 -1
  6. package/dist/dts/providers/openai-provider.d.ts +8 -7
  7. package/dist/dts/providers/openai-provider.d.ts.map +1 -1
  8. package/dist/dts/transports/budget-exhausted-error.d.ts +5 -7
  9. package/dist/dts/transports/budget-exhausted-error.d.ts.map +1 -1
  10. package/dist/dts/transports/context-overflow-error.d.ts.map +1 -1
  11. package/dist/dts/transports/openai-transport.d.ts +119 -0
  12. package/dist/dts/transports/openai-transport.d.ts.map +1 -0
  13. package/dist/dts/types/chat.types.d.ts +12 -0
  14. package/dist/dts/types/chat.types.d.ts.map +1 -1
  15. package/dist/dts/types/config.types.d.ts +44 -16
  16. package/dist/dts/types/config.types.d.ts.map +1 -1
  17. package/dist/dts/utils/token-cost.d.ts +65 -1
  18. package/dist/dts/utils/token-cost.d.ts.map +1 -1
  19. package/dist/dts/utils/tool-schema.d.ts +38 -0
  20. package/dist/dts/utils/tool-schema.d.ts.map +1 -1
  21. package/dist/esm/ai-provider.js +21 -14
  22. package/dist/esm/index.js +4 -2
  23. package/dist/esm/providers/openai-provider.js +15 -9
  24. package/dist/esm/transports/budget-exhausted-error.js +6 -7
  25. package/dist/esm/transports/context-overflow-error.js +2 -0
  26. package/dist/esm/transports/openai-transport.js +752 -0
  27. package/dist/esm/types/config.types.js +12 -1
  28. package/dist/esm/utils/token-cost.js +89 -0
  29. package/dist/esm/utils/tool-schema.js +108 -0
  30. package/dist/foundation-ai.api.json +1745 -137
  31. package/dist/foundation-ai.d.ts +270 -28
  32. package/package.json +9 -9
  33. package/dist/dts/transports/server-openai-transport.d.ts +0 -23
  34. package/dist/dts/transports/server-openai-transport.d.ts.map +0 -1
  35. package/dist/esm/transports/server-openai-transport.js +0 -94
@@ -20,11 +20,26 @@ export declare const SUPPORTED_GEMINI_MODEL_IDS: readonly GeminiModelId[];
20
20
  export type AnthropicModelId = 'claude-fable-5' | 'claude-opus-4-8' | 'claude-opus-4-7' | 'claude-sonnet-5' | 'claude-sonnet-4-6' | 'claude-haiku-4-5-20251001';
21
21
  /** @beta */
22
22
  export declare const SUPPORTED_ANTHROPIC_MODEL_IDS: readonly AnthropicModelId[];
23
+ /**
24
+ * OpenAI Responses API model ids supported by {@link OpenAITransport}.
25
+ *
26
+ * @remarks
27
+ * The GPT-6 family only: on gpt-6-astra, gpt-6.1-sol and gpt-6.1-terra, tool calling is available
28
+ * on the Responses API alone, and the transport is built on it. Older ids are not listed because
29
+ * nothing here prices or tests them — see {@link SUPPORTED_ANTHROPIC_MODEL_IDS} for why an unlisted
30
+ * model must be a decision rather than a fall-through.
31
+ *
32
+ * @beta
33
+ */
34
+ export type OpenAIModelId = 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6.1-terra' | 'gpt-6-sol' | 'gpt-6-luna';
35
+ /** @beta */
36
+ export declare const SUPPORTED_OPENAI_MODEL_IDS: readonly OpenAIModelId[];
23
37
  /**
24
38
  * Which vendor a model id belongs to, or `undefined` when no supported provider claims it.
25
39
  *
26
40
  * @remarks
27
- * Derived from {@link SUPPORTED_ANTHROPIC_MODEL_IDS} and {@link SUPPORTED_GEMINI_MODEL_IDS},
41
+ * Derived from {@link SUPPORTED_ANTHROPIC_MODEL_IDS}, {@link SUPPORTED_GEMINI_MODEL_IDS} and
42
+ * {@link SUPPORTED_OPENAI_MODEL_IDS},
28
43
  * so it cannot drift from them the way a hand-maintained map does — adding a model to an
29
44
  * allowlist is enough to teach this too.
30
45
  *
@@ -68,20 +83,6 @@ export interface AIProviderConfig {
68
83
  /** Optional override for criteria interpretation capability. */
69
84
  criteriaInstructions?: string;
70
85
  }
71
- /** Server-proxy providers only (API keys stay on server). */
72
- export type ServerAIProviderType = Extract<AIProviderType, 'openai'>;
73
- /**
74
- * Server-proxy AI configuration (client calls your server; server calls the provider).
75
- *
76
- * @remarks
77
- * API key stays on the server. URL is derived from API_HOST at /ai-service/chat-completions.
78
- * Use provider to select backend (openai, anthropic, etc.).
79
- *
80
- * @beta
81
- */
82
- export interface ServerAIConfig extends AIProviderConfig {
83
- provider: ServerAIProviderType;
84
- }
85
86
  /**
86
87
  * Chrome built-in AI (Prompt API / Gemini Nano) configuration.
87
88
  *
@@ -133,11 +134,38 @@ export interface AnthropicAIConfig extends AIProviderConfig {
133
134
  */
134
135
  maxTokens?: number;
135
136
  }
137
+ /**
138
+ * OpenAI server-proxy AI configuration (client calls your server; server calls OpenAI's Responses
139
+ * API).
140
+ *
141
+ * @remarks
142
+ * API key stays on the server: set `serverEndpoint` to the proxy route (Create's ai-service mounts
143
+ * it at `/api/openai/chat`, e.g. `/gwf/ai-service/api/openai/chat`). There is no default, and with
144
+ * neither `serverEndpoint` nor `apiKey` the transport throws. When `apiKey` is provided the
145
+ * transport calls `api.openai.com/v1/responses` directly — only use this in trusted contexts.
146
+ *
147
+ * @beta
148
+ */
149
+ export interface OpenAIAIConfig extends AIProviderConfig {
150
+ providerType: 'openai';
151
+ /** Defaults to `gpt-6-luna`. Only {@link SUPPORTED_OPENAI_MODEL_IDS} are accepted at runtime. */
152
+ model?: OpenAIModelId;
153
+ serverEndpoint?: string;
154
+ apiKey?: string;
155
+ /** Per-response output ceiling (`max_output_tokens`). Omitted when unset. */
156
+ maxTokens?: number;
157
+ /**
158
+ * Ask for reasoning summaries (`reasoning.summary`) so a thinking turn has something to show.
159
+ * Off by default: OpenAI may require organisation verification before it returns them, and an
160
+ * unverified organisation would otherwise see every reasoning turn rejected.
161
+ */
162
+ reasoningSummary?: 'auto' | 'concise' | 'detailed';
163
+ }
136
164
  /**
137
165
  * Union type for provider-specific configs.
138
166
  * Extend when adding new providers.
139
167
  *
140
168
  * @beta
141
169
  */
142
- export type AIConfig = ServerAIConfig | ChromeAIConfig | GeminiAIConfig | AnthropicAIConfig;
170
+ export type AIConfig = ChromeAIConfig | GeminiAIConfig | AnthropicAIConfig | OpenAIAIConfig;
143
171
  //# sourceMappingURL=config.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/types/config.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;AAEnF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,uBAAuB,GACvB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,uBAAuB,GAEvB,wBAAwB,CAAC;AAE7B,YAAY;AACZ,eAAO,MAAM,0BAA0B,EAAE,SAAS,aAAa,EASrD,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,2BAA2B,CAAC;AAEhC,YAAY;AACZ,eAAO,MAAM,6BAA6B,EAAE,SAAS,gBAAgB,EAO3D,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAIzE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE,QAA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gBAAgB;IACzD,YAAY,EAAE,WAAW,CAAC;IAC1B,mHAAmH;IACnH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,YAAY,EAAE,QAAQ,CAAC;IACvB,iGAAiG;IACjG,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;CACpD;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,iBAAiB,GAAG,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { AnthropicModelId, GeminiModelId } from '../types';
1
+ import type { AnthropicModelId, GeminiModelId, OpenAIModelId } from '../types';
2
2
  /**
3
3
  * USD per million tokens, split by direction. `prompt` covers input/prompt tokens,
4
4
  * `candidate` covers generated output (including any reasoning tokens the provider
@@ -223,4 +223,68 @@ export interface GeminiUsageRecord {
223
223
  * @beta
224
224
  */
225
225
  export declare function geminiTokenCost(model: GeminiModelId, usage: GeminiUsageRecord, at?: Date): TokenCost;
226
+ /**
227
+ * Above this many input tokens the WHOLE request bills at the long-context tier — input and cached
228
+ * input at {@link OPENAI_LONG_CONTEXT_INPUT_MULTIPLIER}, output at
229
+ * {@link OPENAI_LONG_CONTEXT_OUTPUT_MULTIPLIER}. Like Gemini's tier it is a property of the request,
230
+ * not a marginal rate, and it is chosen on the whole prompt: uncached, cached and written tokens.
231
+ *
232
+ * @beta
233
+ */
234
+ export declare const OPENAI_LONG_CONTEXT_THRESHOLD = 272000;
235
+ /** @beta */
236
+ export declare const OPENAI_LONG_CONTEXT_INPUT_MULTIPLIER = 2;
237
+ /** @beta */
238
+ export declare const OPENAI_LONG_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
239
+ /**
240
+ * Cache-write multipliers on the base input rate, by TTL —
241
+ * https://developers.openai.com/api/docs/guides/prompt-caching. These are the WHOLE rate for a
242
+ * written token, not a premium added to it, which is the same shape as Anthropic's.
243
+ *
244
+ * @beta
245
+ */
246
+ export declare const OPENAI_CACHE_WRITE_30M_MULTIPLIER = 1.25;
247
+ /** @beta */
248
+ export declare const OPENAI_CACHE_WRITE_12H_MULTIPLIER = 2.5;
249
+ /**
250
+ * The rates a request on `model` with `promptTokens` of input is billed at. `promptTokens` is the
251
+ * whole prompt; pass 0 when only the standard tier is wanted.
252
+ *
253
+ * @beta
254
+ */
255
+ export declare function openaiRatesFor(model: OpenAIModelId, promptTokens: number): TokenRates & {
256
+ cachedPerMillion: number;
257
+ };
258
+ /**
259
+ * Token counts from an OpenAI Responses `usage` block.
260
+ *
261
+ * @remarks
262
+ * Gemini's input semantics, not Anthropic's: `input_tokens` is the **whole** prompt and both cache
263
+ * buckets sit inside it, so the uncached remainder is a subtraction. Reasoning tokens need no field
264
+ * of their own — `output_tokens` already includes `output_tokens_details.reasoning_tokens`.
265
+ *
266
+ * @beta
267
+ */
268
+ export interface OpenAIUsageRecord {
269
+ /** `usage.input_tokens` — the whole prompt, cached reads AND writes included. */
270
+ inputTokens: number;
271
+ /** `usage.output_tokens`. Includes reasoning tokens, which bill as output. */
272
+ outputTokens: number;
273
+ /** `usage.input_tokens_details.cached_tokens` — cache reads. */
274
+ cacheReadTokens: number;
275
+ /** `usage.input_tokens_details.cache_write_tokens` — the total across both TTLs. */
276
+ cacheWriteTokens: number;
277
+ /**
278
+ * `usage.input_tokens_details.cache_write_tokens_details.ttl_12h_tokens` — the 12-hour
279
+ * portion of {@link OpenAIUsageRecord.cacheWriteTokens}; the remainder is costed at the 30-minute
280
+ * rate.
281
+ */
282
+ cacheWrite12hTokens: number;
283
+ }
284
+ /**
285
+ * Cost one OpenAI request.
286
+ *
287
+ * @beta
288
+ */
289
+ export declare function openaiTokenCost(model: OpenAIModelId, usage: OpenAIUsageRecord): TokenCost;
226
290
  //# sourceMappingURL=token-cost.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-cost.d.ts","sourceRoot":"","sources":["../../../src/utils/token-cost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAkDhE;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;CACtB;AAiCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,CAErE;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,MAAM,CAAC;AACnD,YAAY;AACZ,eAAO,MAAM,mCAAmC,OAAO,CAAC;AACxD,YAAY;AACZ,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,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AAC;IACpB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,eAAe,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAiCzF"}
@@ -76,5 +76,43 @@ export declare function enforceAnthropicToolSchema(parameters: SchemaNode, toolN
76
76
  * than us silently picking a branch.
77
77
  */
78
78
  export declare function toGeminiSchema(parameters: SchemaNode): SchemaNode;
79
+ /** The outcome of adapting a schema for OpenAI strict mode. */
80
+ export interface OpenAIStrictSchema {
81
+ /** The adapted schema — safe to send with `strict: true`. Always a fresh object. */
82
+ schema: SchemaNode;
83
+ /**
84
+ * JSON Pointers of properties that were OPTIONAL and are now required-but-nullable. Strict mode
85
+ * has no optional properties: the model must emit every key, sending `null` for an absent value.
86
+ * A tool handler that branches on `key in args` must branch on `args[key] == null` instead.
87
+ */
88
+ madeNullable: string[];
89
+ /** JSON Pointers of `additionalProperties` values other than `false` that were closed. */
90
+ overridden: string[];
91
+ /** JSON Pointers of keywords strict mode cannot express, left in place. */
92
+ undroppable: string[];
93
+ }
94
+ /**
95
+ * Adapt a JSON Schema for OpenAI strict mode (`strict: true` on a function tool, or a
96
+ * `text.format` json_schema).
97
+ *
98
+ * Strict mode needs three things the canonical dialect does not:
99
+ *
100
+ * 1. **Every property listed in `required`.** A property the caller left optional is made
101
+ * required-but-nullable, which is the documented way to express "may be absent" — so the
102
+ * meaning survives, but the SHAPE of the arguments changes (absent becomes `null`), and that is
103
+ * reported in {@link OpenAIStrictSchema.madeNullable}.
104
+ * 2. **`additionalProperties: false` on every object**, as with Anthropic enforcement.
105
+ * 3. **No `allOf` / `not` / conditionals**, which are left in place so the request is rejected
106
+ * rather than silently enforcing a weaker schema.
107
+ *
108
+ * Numeric bounds, `pattern`, `format`, `minItems`/`maxItems`, `anyOf`, `$defs`/`$ref` are all
109
+ * supported by strict mode and pass through untouched.
110
+ */
111
+ export declare function toOpenAIStrictSchema(parameters: SchemaNode): OpenAIStrictSchema;
112
+ /**
113
+ * {@link toOpenAIStrictSchema} for transport use: logs what changed and returns only the schema. A
114
+ * verb, for the same reason as {@link enforceAnthropicToolSchema}.
115
+ */
116
+ export declare function enforceOpenAIToolSchema(parameters: SchemaNode, toolName: string): SchemaNode;
79
117
  export {};
80
118
  //# sourceMappingURL=tool-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/tool-schema.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAwH1C,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAC;IACnB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oFAAoF;IACpF,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,CA6ChF;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAuB/F;AA0ED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAsDjE"}
1
+ {"version":3,"file":"tool-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/tool-schema.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAwH1C,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAC;IACnB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oFAAoF;IACpF,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,CA6ChF;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAuB/F;AA0ED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAsDjE;AAaD,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC,oFAAoF;IACpF,MAAM,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,0FAA0F;IAC1F,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAwBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,kBAAkB,CAoC/E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAsB5F"}
@@ -7,8 +7,8 @@ import { OpenAIProvider } from './providers/openai-provider';
7
7
  import { AnthropicTransport } from './transports/anthropic-transport';
8
8
  import { ChromePromptTransport } from './transports/chrome-prompt-transport';
9
9
  import { GeminiTransport } from './transports/gemini-transport';
10
- import { ServerOpenAITransport } from './transports/server-openai-transport';
11
- import { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS, } from './types';
10
+ import { OpenAITransport } from './transports/openai-transport';
11
+ import { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS, SUPPORTED_OPENAI_MODEL_IDS, } from './types';
12
12
  import { logger } from './utils';
13
13
  import { isAIFeatureEnabled } from './utils/feature-flags';
14
14
  function isChromeConfig(config) {
@@ -20,13 +20,13 @@ function isGeminiConfig(config) {
20
20
  function isAnthropicConfig(config) {
21
21
  return 'providerType' in config && config.providerType === 'anthropic';
22
22
  }
23
- function isServerAIConfig(config) {
24
- return !!config.provider;
23
+ function isOpenAIConfig(config) {
24
+ return 'providerType' in config && config.providerType === 'openai';
25
25
  }
26
26
  /**
27
27
  * Creates an AIProvider from config.
28
28
  * Uses ChromeProvider when providerType is 'chrome'.
29
- * Uses OpenAIProvider with ServerOpenAITransport when provider is set (server-only).
29
+ * Uses GeminiProvider, AnthropicProvider or OpenAIProvider for their `providerType`.
30
30
  * Otherwise returns DefaultAIProvider.
31
31
  * When the AI feature flag is disabled (?feature.ai), always returns DefaultAIProvider.
32
32
  *
@@ -64,15 +64,16 @@ export function createAIProvider(config) {
64
64
  });
65
65
  return new AnthropicProvider({ criteriaInstructions: config.criteriaInstructions }, transport);
66
66
  }
67
- if (config && isServerAIConfig(config)) {
68
- if (config.provider !== 'openai') {
69
- logger.warn('createAIProvider: only openai server provider supported for now, using default');
70
- return new DefaultAIProvider();
71
- }
72
- logger.debug('createAIProvider: using OpenAIProvider (server proxy)');
73
- const transport = new ServerOpenAITransport({
67
+ if (config && isOpenAIConfig(config)) {
68
+ logger.debug('createAIProvider: using OpenAIProvider (Responses)');
69
+ const transport = new OpenAITransport({
74
70
  model: config.model,
75
71
  timeout: config.timeout,
72
+ stallTimeout: config.stallTimeout,
73
+ serverEndpoint: config.serverEndpoint,
74
+ apiKey: config.apiKey,
75
+ maxTokens: config.maxTokens,
76
+ reasoningSummary: config.reasoningSummary,
76
77
  });
77
78
  return new OpenAIProvider({ criteriaInstructions: config.criteriaInstructions }, transport);
78
79
  }
@@ -81,7 +82,9 @@ export function createAIProvider(config) {
81
82
  }
82
83
  /**
83
84
  * Resolves AI config, optionally preferring Chrome when available.
84
- * Use before registering AIProvider. Server URL is derived from API_HOST.
85
+ * Use before registering AIProvider. The cloud configs it returns carry no endpoint: add
86
+ * `serverEndpoint` (a server proxy) or `apiKey` (direct, trusted contexts only) before
87
+ * `createAIProvider`.
85
88
  * Returns null when the AI feature flag is disabled (?feature.ai).
86
89
  *
87
90
  * @beta
@@ -117,7 +120,11 @@ export function resolveAIConfig() {
117
120
  }
118
121
  return { providerType: 'anthropic', model: anthropicModel };
119
122
  }
120
- return { provider, model: model !== null && model !== void 0 ? model : 'gpt-4o-mini' };
123
+ const openaiModel = model !== null && model !== void 0 ? model : 'gpt-6-luna';
124
+ if (!SUPPORTED_OPENAI_MODEL_IDS.includes(openaiModel)) {
125
+ throw new Error(`resolveAIConfig: unsupported OpenAI model "${openaiModel}". Use one of: ${SUPPORTED_OPENAI_MODEL_IDS.join(', ')}.`);
126
+ }
127
+ return { providerType: 'openai', model: openaiModel };
121
128
  });
122
129
  }
123
130
  /**
package/dist/esm/index.js CHANGED
@@ -9,6 +9,8 @@ export { GeminiProvider } from './providers/gemini-provider';
9
9
  export { AnthropicTransport, ResponseTruncatedError } from './transports/anthropic-transport';
10
10
  export { BUDGETED_VENDORS, BudgetExhaustedError, DEFAULT_BUDGET_EXHAUSTED_MESSAGE, isBudgetedVendor, VENDOR_LABELS, vendorTypeOfLabel, } from './transports/budget-exhausted-error';
11
11
  export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
12
+ export { OpenAITransport } from './transports/openai-transport';
13
+ export { OpenAIProvider } from './providers/openai-provider';
12
14
  // The PROVIDER wall (GENC-1506) — the upstream vendor refusing this account, as distinct from our own
13
15
  // spend budget above. The message constant is exported so ai-service's generation surfaces send the
14
16
  // SAME sentence as the browser driver: the copy is provisional and a second copy would drift on the
@@ -34,10 +36,10 @@ export { ChatTemperature } from './utils/temperature';
34
36
  // provider usage rather than `ChatMessage`, because Anthropic's per-TTL cache-write split exists
35
37
  // only in the provider response and the path that needs to compute a cost is the one where no
36
38
  // transport stamped one. See the module header for why re-pricing a stamped message is wrong.
37
- export { ANTHROPIC_CACHE_READ_MULTIPLIER, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER, anthropicRatesFor, anthropicTokenCost, GEMINI_CACHED_INPUT_MULTIPLIER, GEMINI_LONG_CONTEXT_THRESHOLD, geminiRatesFor, geminiTokenCost, } from './utils/token-cost';
39
+ export { ANTHROPIC_CACHE_READ_MULTIPLIER, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER, anthropicRatesFor, anthropicTokenCost, GEMINI_CACHED_INPUT_MULTIPLIER, GEMINI_LONG_CONTEXT_THRESHOLD, geminiRatesFor, geminiTokenCost, OPENAI_CACHE_WRITE_12H_MULTIPLIER, OPENAI_CACHE_WRITE_30M_MULTIPLIER, OPENAI_LONG_CONTEXT_INPUT_MULTIPLIER, OPENAI_LONG_CONTEXT_OUTPUT_MULTIPLIER, OPENAI_LONG_CONTEXT_THRESHOLD, openaiRatesFor, openaiTokenCost, } from './utils/token-cost';
38
40
  // `vendorOfModel` sits with the allowlists it is derived from, so it cannot drift from them.
39
41
  // Exported for the pricing above: a caller holding a model id needs it to choose between the
40
42
  // two vendor cost functions, and without it writes its own model→vendor map.
41
- export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS, vendorOfModel } from './types';
43
+ export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS, SUPPORTED_OPENAI_MODEL_IDS, vendorOfModel, } from './types';
42
44
  export { isChatToolCallUnknown } from './types/chat.types';
43
45
  export { isSpeechRecognitionAvailable, startSpeechRecognition } from './utils/speech-to-text';
@@ -1,13 +1,9 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { buildCriteriaSystemPrompt, buildCriteriaUserPrompt, CRITERIA_JSON_SCHEMA, parseCriteriaResponse, } from '../interactions';
3
- import { ServerOpenAITransport } from '../transports/server-openai-transport';
4
3
  import { logger } from '../utils';
5
4
  /**
6
- * General OpenAI provider. Uses an injectable transport (ServerOpenAITransport).
7
- * Exposes interpretCriteria and future capabilities (e.g. summarize).
8
- *
9
- * @remarks
10
- * Configure via createAIProvider with ServerAIConfig (provider, model).
5
+ * General OpenAI provider, on `OpenAITransport` (the Responses API, direct or via a server proxy):
6
+ * criteria, prompt and chat — the same shape as its Gemini and Anthropic twins.
11
7
  *
12
8
  * @beta
13
9
  */
@@ -18,9 +14,7 @@ export class OpenAIProvider {
18
14
  }
19
15
  getStatus() {
20
16
  return __awaiter(this, void 0, void 0, function* () {
21
- const config = this.transport instanceof ServerOpenAITransport
22
- ? this.transport.getConfig()
23
- : { provider: 'openai', model: 'gpt-4o-mini', contextLimit: undefined };
17
+ const config = this.transport.getConfig();
24
18
  return { provider: 'openai', model: config.model, contextLimit: config.contextLimit };
25
19
  });
26
20
  }
@@ -40,7 +34,19 @@ export class OpenAIProvider {
40
34
  }
41
35
  catch (e) {
42
36
  logger.error('OpenAIProvider interpretCriteria failed:', e);
37
+ return null;
43
38
  }
44
39
  });
45
40
  }
41
+ prompt(message, options) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const response = yield this.transport.sendChatMessage([], message, options);
44
+ return response.content;
45
+ });
46
+ }
47
+ chat(history, userMessage, options) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ return this.transport.sendChatMessage(history, userMessage, options);
50
+ });
51
+ }
46
52
  }
@@ -60,19 +60,18 @@ export const VENDOR_LABELS = Object.freeze({
60
60
  * and if it is reachable, `blocked` then derives true and locks a composer with
61
61
  * headroom left.
62
62
  *
63
- * Two vendors are excluded for that reason:
64
- * - `chrome` runs on-device — no pot to exhaust, and free.
65
- * - `openai` is **not budgeted by the proxy**. ai-service rejects it up front
66
- * with `400 UNSUPPORTED_PROVIDER` (`SUPPORTED_PROVIDERS` in `aiVendor.js`), no
67
- * `MODEL_PRICING` row names it, and `otherVendorAvailable` is computed over
68
- * Anthropic and Gemini alone. So it can never raise a 402, and a 402 is never
69
- * a statement about it.
63
+ * `chrome` is excluded for that reason: it runs on-device — no pot to exhaust, and free.
64
+ *
65
+ * `openai` is metered (GENC-1829): ai-service budgets it on its own `SpentUsdOpenai` counter and
66
+ * proxies it on `/api/openai/chat`. The proxy computes `otherVendorAvailable` over the vendors it
67
+ * OFFERS, so with OpenAI switched off there a 402 still says nothing about it.
70
68
  *
71
69
  * @beta
72
70
  */
73
71
  export const BUDGETED_VENDORS = Object.freeze([
74
72
  'anthropic',
75
73
  'gemini',
74
+ 'openai',
76
75
  ]);
77
76
  /**
78
77
  * Whether this vendor's spend is metered by the proxy — see
@@ -51,6 +51,8 @@ const CONTEXT_OVERFLOW_PHRASES = Object.freeze([
51
51
  /input token count .* exceeds/i,
52
52
  /maximum context length/i,
53
53
  /context[_ ]length[_ ]exceeded/i,
54
+ // OpenAI Responses: `Your input exceeds the context window of this model.`
55
+ /exceeds the context window/i,
54
56
  /too many (input )?tokens/i,
55
57
  ]);
56
58
  /**