@rulvar/openai 1.0.0 → 1.2.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.d.ts +10 -10
- package/dist/index.js +14 -15
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { CanonicalId, ChatEvent, ChatRequest, Effort, ModelCaps, ProviderAdapter
|
|
|
4
4
|
interface OpenAiModelInfo {
|
|
5
5
|
caps: ModelCaps;
|
|
6
6
|
api: "responses" | "chat";
|
|
7
|
-
/** Reasoning models reject non-default sampling parameters
|
|
7
|
+
/** Reasoning models reject non-default sampling parameters. */
|
|
8
8
|
reasoning: boolean;
|
|
9
9
|
}
|
|
10
|
-
/** Static seed table
|
|
10
|
+
/** Static seed table of the current model set. */
|
|
11
11
|
declare const OPENAI_MODELS: Record<string, OpenAiModelInfo>;
|
|
12
12
|
/** Unknown OpenAI models are assumed current-generation Responses models. */
|
|
13
13
|
declare function openAiModelInfo(model: string): OpenAiModelInfo;
|
|
@@ -40,8 +40,8 @@ declare function openai(options?: OpenAiAdapterOptions): ProviderAdapter;
|
|
|
40
40
|
//#region src/compatible.d.ts
|
|
41
41
|
/**
|
|
42
42
|
* Gateways cannot be introspected reliably: when caps are not supplied
|
|
43
|
-
* the factory assumes the most conservative capability set
|
|
44
|
-
*
|
|
43
|
+
* the factory assumes the most conservative capability set. Callers
|
|
44
|
+
* SHOULD supply caps for anything beyond it; the
|
|
45
45
|
* window and output floors here are deliberately small so an unprobed
|
|
46
46
|
* endpoint is never overcommitted. Absent pricing is legitimate for
|
|
47
47
|
* local models: they surface as unpriced in CostReport.
|
|
@@ -61,7 +61,7 @@ interface OpenAiCompatibleConfig {
|
|
|
61
61
|
declare function openaiCompatible(cfg: OpenAiCompatibleConfig): ProviderAdapter;
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/wire.d.ts
|
|
64
|
-
/** Bijective canonical-to-wire (call_*) id map
|
|
64
|
+
/** Bijective canonical-to-wire (call_*) id map. */
|
|
65
65
|
declare class OpenAiIdMap {
|
|
66
66
|
private readonly toWire;
|
|
67
67
|
private readonly toCanonical;
|
|
@@ -71,7 +71,7 @@ declare class OpenAiIdMap {
|
|
|
71
71
|
wireFor(canonicalId: CanonicalId): string;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
* Canonical-to-wire effort
|
|
74
|
+
* Canonical-to-wire effort: low through
|
|
75
75
|
* xhigh pass through; canonical max downmaps to xhigh (documented lossy;
|
|
76
76
|
* recorded in providerMetadata); provider 'none' is reachable only via
|
|
77
77
|
* providerOptions.openai.reasoningEffort.
|
|
@@ -84,7 +84,7 @@ declare function mapOpenAiEffort(effort: Effort): {
|
|
|
84
84
|
* Builds Responses API params. Manual item replay ONLY: store: false plus
|
|
85
85
|
* include reasoning.encrypted_content; previous_response_id and the
|
|
86
86
|
* Conversations API place state server-side, break replay identity, and
|
|
87
|
-
* are REJECTED as a typed ConfigError
|
|
87
|
+
* are REJECTED as a typed ConfigError. Role
|
|
88
88
|
* 'system' messages project into top-level instructions on every request.
|
|
89
89
|
*/
|
|
90
90
|
declare function buildResponsesParams(req: ChatRequest, ids: OpenAiIdMap): {
|
|
@@ -98,8 +98,8 @@ type ResponsesStreamEvent = Record<string, unknown> & {
|
|
|
98
98
|
/** Normalizes Responses usage: input_tokens already includes cached reads. */
|
|
99
99
|
declare function normalizeOpenAiUsage(raw: Record<string, unknown> | undefined): Usage;
|
|
100
100
|
/**
|
|
101
|
-
* Maps the typed Responses SSE stream to ChatEvents
|
|
102
|
-
*
|
|
101
|
+
* Maps the typed Responses SSE stream to ChatEvents.
|
|
102
|
+
* Canonical parts come from the typed output array,
|
|
103
103
|
* never the output_text aggregate. Raw output items ride
|
|
104
104
|
* finish.providerMetadata.openai.outputItems so the runtime can retain
|
|
105
105
|
* reasoning items as provider-raw parts.
|
|
@@ -110,7 +110,7 @@ declare function mapResponsesStream(stream: AsyncIterable<ResponsesStreamEvent>,
|
|
|
110
110
|
/** Projects SDK/API errors into the retryable WireError vocabulary. */
|
|
111
111
|
declare function openAiErrorToWire(error: unknown): WireError;
|
|
112
112
|
/**
|
|
113
|
-
* The Chat Completions degraded path
|
|
113
|
+
* The Chat Completions degraded path: delta-patched
|
|
114
114
|
* chunk assembly instead of typed SSE, nested function tools with explicit
|
|
115
115
|
* strict where supported, response_format instead of text.format, no
|
|
116
116
|
* reasoning item replay. Selected by caps (api: 'chat'), visible in
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function responses(contextWindow, maxOutputTokens, pricing) {
|
|
|
26
26
|
reasoning: true
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
/** Static seed table
|
|
29
|
+
/** Static seed table of the current model set. */
|
|
30
30
|
const OPENAI_MODELS = {
|
|
31
31
|
"gpt-5.5": responses(4e5, 128e3, {
|
|
32
32
|
in: 10,
|
|
@@ -70,10 +70,10 @@ function openAiModelInfo(model) {
|
|
|
70
70
|
* mapped to ChatEvent, effort mapping with the documented lossy max
|
|
71
71
|
* downmap, and usage normalization.
|
|
72
72
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
73
|
+
* Full contract: https://docs.rulvar.com/guide/providers
|
|
74
|
+
* Pure functions; adapter.ts owns the SDK client.
|
|
75
75
|
*/
|
|
76
|
-
/** Bijective canonical-to-wire (call_*) id map
|
|
76
|
+
/** Bijective canonical-to-wire (call_*) id map. */
|
|
77
77
|
var OpenAiIdMap = class {
|
|
78
78
|
toWire = /* @__PURE__ */ new Map();
|
|
79
79
|
toCanonical = /* @__PURE__ */ new Map();
|
|
@@ -99,7 +99,7 @@ var OpenAiIdMap = class {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
/**
|
|
102
|
-
* Canonical-to-wire effort
|
|
102
|
+
* Canonical-to-wire effort: low through
|
|
103
103
|
* xhigh pass through; canonical max downmaps to xhigh (documented lossy;
|
|
104
104
|
* recorded in providerMetadata); provider 'none' is reachable only via
|
|
105
105
|
* providerOptions.openai.reasoningEffort.
|
|
@@ -118,7 +118,7 @@ function mapOpenAiEffort(effort) {
|
|
|
118
118
|
* Builds Responses API params. Manual item replay ONLY: store: false plus
|
|
119
119
|
* include reasoning.encrypted_content; previous_response_id and the
|
|
120
120
|
* Conversations API place state server-side, break replay identity, and
|
|
121
|
-
* are REJECTED as a typed ConfigError
|
|
121
|
+
* are REJECTED as a typed ConfigError. Role
|
|
122
122
|
* 'system' messages project into top-level instructions on every request.
|
|
123
123
|
*/
|
|
124
124
|
function buildResponsesParams(req, ids) {
|
|
@@ -244,8 +244,8 @@ function normalizeOpenAiUsage(raw) {
|
|
|
244
244
|
return usage;
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
|
-
* Maps the typed Responses SSE stream to ChatEvents
|
|
248
|
-
*
|
|
247
|
+
* Maps the typed Responses SSE stream to ChatEvents.
|
|
248
|
+
* Canonical parts come from the typed output array,
|
|
249
249
|
* never the output_text aggregate. Raw output items ride
|
|
250
250
|
* finish.providerMetadata.openai.outputItems so the runtime can retain
|
|
251
251
|
* reasoning items as provider-raw parts.
|
|
@@ -405,7 +405,7 @@ function openAiErrorToWire(error) {
|
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
407
|
/**
|
|
408
|
-
* The Chat Completions degraded path
|
|
408
|
+
* The Chat Completions degraded path: delta-patched
|
|
409
409
|
* chunk assembly instead of typed SSE, nested function tools with explicit
|
|
410
410
|
* strict where supported, response_format instead of text.format, no
|
|
411
411
|
* reasoning item replay. Selected by caps (api: 'chat'), visible in
|
|
@@ -575,8 +575,8 @@ async function mapChatCompletionsStream(stream, ids, emit) {
|
|
|
575
575
|
* Completions as the caps-selected degraded path, SDK autoretries
|
|
576
576
|
* disabled.
|
|
577
577
|
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
578
|
+
* Docs: https://docs.rulvar.com/guide/providers
|
|
579
|
+
* The openaiCompatible factory ships in M3.
|
|
580
580
|
*/
|
|
581
581
|
/** Creates the first-class OpenAI adapter (id 'openai'); maxRetries 0. */
|
|
582
582
|
function openai(options = {}) {
|
|
@@ -633,13 +633,12 @@ function openai(options = {}) {
|
|
|
633
633
|
* engine; a duplicate adapterId at createEngine is a typed ConfigError
|
|
634
634
|
* raised by the adapter registry.
|
|
635
635
|
*
|
|
636
|
-
*
|
|
637
|
-
* factory".
|
|
636
|
+
* Guide: https://docs.rulvar.com/guide/providers
|
|
638
637
|
*/
|
|
639
638
|
/**
|
|
640
639
|
* Gateways cannot be introspected reliably: when caps are not supplied
|
|
641
|
-
* the factory assumes the most conservative capability set
|
|
642
|
-
*
|
|
640
|
+
* the factory assumes the most conservative capability set. Callers
|
|
641
|
+
* SHOULD supply caps for anything beyond it; the
|
|
643
642
|
* window and output floors here are deliberately small so an unprobed
|
|
644
643
|
* endpoint is never overcommitted. Absent pricing is legitimate for
|
|
645
644
|
* local models: they surface as unpriced in CostReport.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/openai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "rulvar first-class provider adapter for the OpenAI Responses API, plus the openaiCompatible factory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"openai": "^6.45.0",
|
|
26
|
-
"@rulvar/core": "1.
|
|
26
|
+
"@rulvar/core": "1.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.20.0",
|