@enlitt/protocol 0.0.0-stage → 0.1.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 (48) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +15 -2
  4. package/dist/admin.d.cts +353 -0
  5. package/dist/admin.d.ts +354 -0
  6. package/dist/admin.d.ts.map +1 -0
  7. package/dist/authentication.d.cts +8 -0
  8. package/dist/authentication.d.ts +9 -0
  9. package/dist/authentication.d.ts.map +1 -0
  10. package/dist/canonical-integer.d.cts +48 -0
  11. package/dist/canonical-integer.d.ts +49 -0
  12. package/dist/canonical-integer.d.ts.map +1 -0
  13. package/dist/compatibility.d.cts +23 -0
  14. package/dist/compatibility.d.ts +24 -0
  15. package/dist/compatibility.d.ts.map +1 -0
  16. package/dist/contract.d.cts +67 -0
  17. package/dist/contract.d.ts +68 -0
  18. package/dist/contract.d.ts.map +1 -0
  19. package/dist/dashboard.d.cts +1030 -0
  20. package/dist/dashboard.d.ts +1031 -0
  21. package/dist/dashboard.d.ts.map +1 -0
  22. package/dist/errors.d.cts +112 -0
  23. package/dist/errors.d.ts +113 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/idempotency.d.cts +79 -0
  26. package/dist/idempotency.d.ts +80 -0
  27. package/dist/idempotency.d.ts.map +1 -0
  28. package/dist/index.cjs +4806 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +31 -0
  31. package/dist/index.d.ts +32 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +4624 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/premium-operations.d.cts +84 -0
  36. package/dist/premium-operations.d.ts +85 -0
  37. package/dist/premium-operations.d.ts.map +1 -0
  38. package/dist/response-stream.d.cts +246 -0
  39. package/dist/response-stream.d.ts +247 -0
  40. package/dist/response-stream.d.ts.map +1 -0
  41. package/dist/responses.d.cts +233 -0
  42. package/dist/responses.d.ts +234 -0
  43. package/dist/responses.d.ts.map +1 -0
  44. package/dist/usage.d.cts +11 -0
  45. package/dist/usage.d.ts +12 -0
  46. package/dist/usage.d.ts.map +1 -0
  47. package/generated/contract.json +482 -0
  48. package/package.json +51 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-stream.d.ts","sourceRoot":"","sources":["../src/response-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc7B,CAAC;AAEZ,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,2BAA2B,CAAC;AAE/E,eAAO,MAAM,gCAAgC,2YAE5C,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAE1F;AAED,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAExF;AAED,uDAAuD;AACvD,MAAM,MAAM,+BAA+B,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,iBAAiB,CAAC;AAI/G,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,eAAe,EACf,eAAe,GAAG,uBAAuB,GAAG,mBAAmB,CAChE,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAA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2L;AAC3L,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,MAAM,uBAAuB,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAExE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,mBAAmB,EAAE,GACrC,mBAAmB,CA0BrB"}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * The stateless `POST /v1/responses` wire contract: request body, response
3
+ * body, and the hand-written runtime validators for both.
4
+ *
5
+ * `specs/PROTOCOLS.md` "Create model response" names an exact accepted field
6
+ * list, an exact rejected field list, and three failure classes a validator
7
+ * must distinguish so the backend can raise the right stable code and the SDK
8
+ * can classify it the same way from the same table. This module owns that
9
+ * classification once, the same way `errors.ts` owns the code table: the
10
+ * backend and the SDK both import it rather than each re-deriving which
11
+ * field belongs to which class.
12
+ *
13
+ * This package has zero runtime dependencies, so validation here is
14
+ * hand-written structural checking rather than a schema library. A validator
15
+ * never throws on ordinary bad input — it returns a result, because an
16
+ * `invalid_value` on request field 40 of 40 is routine traffic, not a bug in
17
+ * this process.
18
+ *
19
+ * Two shapes in `specs/PROTOCOLS.md` are gestured at but not enumerated in the
20
+ * "Create model response" section: `JsonSchema` is used as a type ("bounded
21
+ * ... schema depth, and encoded size") without the bound values being stated,
22
+ * and `ResponseOutputItem` is named without its member shapes being spelled
23
+ * out the way input items are. This module deliberately does not invent
24
+ * numeric bounds or output-item field shapes the spec does not give; see the
25
+ * doc comments on `JsonSchema`, `FunctionTool`, and `ResponseOutputItem` for
26
+ * exactly what is and is not enforced, and the implementation report for the
27
+ * ambiguity this leaves open.
28
+ */
29
+ import { type EnlittErrorCode } from "./errors.cjs";
30
+ import { type ParseOptions, type Readable, type UnknownVariant } from "./compatibility.cjs";
31
+ /**
32
+ * The only accepted value of the request's `model` field. A single accepted
33
+ * string is deliberate: the caller asks for the standard route and Enlitt
34
+ * alone decides which model actually serves it, so there is no override to
35
+ * validate the shape of.
36
+ */
37
+ export declare const ENLITT_STANDARD_MODEL = "enlitt-standard";
38
+ export type EnlittStandardModel = typeof ENLITT_STANDARD_MODEL;
39
+ /**
40
+ * The three failure classes `specs/PROTOCOLS.md` names for this surface,
41
+ * narrowed from the full stable-code union so a caller cannot construct a
42
+ * validation failure carrying a code this surface never raises. Codes are
43
+ * referenced through `ENLITT_ERROR_CODE`'s own keys rather than written as
44
+ * string literals, so a rename in `errors.ts` fails this file to compile
45
+ * instead of silently drifting.
46
+ */
47
+ export type ResponseRequestErrorCode = Extract<EnlittErrorCode, "invalid_value" | "unsupported_parameter" | "unsupported_value">;
48
+ /**
49
+ * A single validation failure. `param` names the offending field using the
50
+ * same dotted/bracketed path an OpenAI-shaped error already uses, so the
51
+ * value here can be copied directly into `EnlittErrorInput.param` at the call
52
+ * site without renaming anything.
53
+ */
54
+ export interface ResponseValidationFailure {
55
+ readonly code: ResponseRequestErrorCode;
56
+ readonly param: string;
57
+ readonly message: string;
58
+ }
59
+ /**
60
+ * The result shape every validator in this module returns. Ordinary
61
+ * validation failure is data, not an exception: a request body is untrusted
62
+ * input on the hottest path this package serves, and throwing for the
63
+ * expected case would force every caller to wrap every call in `try/catch`.
64
+ */
65
+ export type ResponseValidationResult<T> = {
66
+ readonly ok: true;
67
+ readonly value: T;
68
+ } | {
69
+ readonly ok: false;
70
+ readonly error: ResponseValidationFailure;
71
+ };
72
+ /** A JSON Schema object supplied to a function tool. */
73
+ export type JsonSchema = Readonly<Record<string, unknown>>;
74
+ export interface EnlittTextPart {
75
+ readonly type: "text";
76
+ readonly text: string;
77
+ }
78
+ export interface EnlittImageUrlSource {
79
+ readonly type: "url";
80
+ readonly url: string;
81
+ }
82
+ export interface EnlittImageBase64Source {
83
+ readonly type: "base64";
84
+ readonly media_type: "image/png" | "image/jpeg";
85
+ readonly data: string;
86
+ }
87
+ export interface EnlittImagePart {
88
+ readonly type: "image";
89
+ readonly source: EnlittImageUrlSource | EnlittImageBase64Source;
90
+ }
91
+ export type EnlittUserPart = EnlittTextPart | EnlittImagePart;
92
+ export interface EnlittSystemMessage {
93
+ readonly role: "system";
94
+ readonly content: string;
95
+ }
96
+ export interface EnlittUserMessage {
97
+ readonly role: "user";
98
+ readonly content: readonly EnlittUserPart[];
99
+ }
100
+ export interface EnlittToolCall {
101
+ readonly id: string;
102
+ readonly name: string;
103
+ readonly arguments: string;
104
+ }
105
+ export interface EnlittAssistantMessage {
106
+ readonly role: "assistant";
107
+ readonly content?: string;
108
+ readonly tool_calls?: readonly EnlittToolCall[];
109
+ }
110
+ export interface EnlittToolMessage {
111
+ readonly role: "tool";
112
+ readonly tool_call_id: string;
113
+ readonly content: string;
114
+ }
115
+ export type EnlittStandardMessage = EnlittSystemMessage | EnlittUserMessage | EnlittAssistantMessage | EnlittToolMessage;
116
+ export interface EnlittFunctionTool {
117
+ readonly name: string;
118
+ readonly description?: string;
119
+ readonly input_schema: JsonSchema;
120
+ }
121
+ /**
122
+ * The identical caller-metadata bound `specs/PROTOCOLS.md` states once and
123
+ * both the SDK and the premium path must apply without restating: at most 16
124
+ * entries, keys at most 64 characters, values at most 512, and no caller key
125
+ * beginning with `enlitt_` (that prefix is reserved for facts Enlitt adds to
126
+ * a response, such as `enlitt_operation_id`).
127
+ */
128
+ export declare const CALLER_METADATA_LIMITS: Readonly<{
129
+ maxEntries: 16;
130
+ maxKeyLength: 64;
131
+ maxValueLength: 512;
132
+ reservedKeyPrefix: "enlitt_";
133
+ }>;
134
+ export type ResponseMetadata = Readonly<Record<string, string>>;
135
+ /**
136
+ * Validate caller-supplied metadata against the one bound this surface, the
137
+ * premium path, and the SDK all share. Exported standalone — not folded into
138
+ * `validateEnlittStandardRequest` — precisely so a second copy of this
139
+ * rule never needs to be written next to a different endpoint's field list.
140
+ */
141
+ export declare function validateCallerMetadata(value: unknown, param?: string): ResponseValidationResult<ResponseMetadata>;
142
+ export interface EnlittStandardRequest {
143
+ readonly model: EnlittStandardModel;
144
+ readonly messages: readonly EnlittStandardMessage[];
145
+ readonly tools?: readonly EnlittFunctionTool[];
146
+ readonly max_output_tokens?: number;
147
+ readonly stream?: boolean;
148
+ readonly metadata?: ResponseMetadata;
149
+ }
150
+ export declare function validateEnlittStandardRequest(value: unknown): ResponseValidationResult<EnlittStandardRequest>;
151
+ export declare const RESPONSE_STATUSES: readonly ["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"];
152
+ export declare const RESPONSE_INCOMPLETE_REASONS: readonly ["max_output_tokens"];
153
+ export declare const RESPONSE_ITEM_STATUSES: readonly ["in_progress", "completed", "incomplete"];
154
+ export type ResponseStatusMember = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete";
155
+ export type ResponseStatus = Readable<ResponseStatusMember>;
156
+ export type ResponseIncompleteReason = Readable<(typeof RESPONSE_INCOMPLETE_REASONS)[number]>;
157
+ /**
158
+ * A member of `OpenAIResponse.output`.
159
+ *
160
+ * `specs/PROTOCOLS.md` names `ResponseOutputItem` but, in the section this
161
+ * module implements, does not enumerate its member shapes the way it
162
+ * enumerates input items. The two variants below are modeled on the pinned
163
+ * OpenAI Responses API subset this endpoint implements (the same subset the
164
+ * differential test harness drives) and on the streaming event names the
165
+ * spec does give — `response.output_item.*`, `response.content_part.*`,
166
+ * `response.output_text.*`, and `response.function_call_arguments.*` imply
167
+ * exactly a text-bearing message item and a function-call item and nothing
168
+ * else. This is the closest reading available from the read scope for this
169
+ * task; it is not a spec quotation, and it should be confirmed against
170
+ * wherever `ResponseOutputItem` is actually pinned down before another
171
+ * workspace depends on these exact field names.
172
+ */
173
+ export interface ResponseOutputTextPart {
174
+ readonly type: "output_text";
175
+ readonly text: string;
176
+ }
177
+ export type ResponseOutputContentPart = ResponseOutputTextPart | UnknownVariant;
178
+ export interface MessageOutputItem {
179
+ readonly type: "message";
180
+ readonly id: string;
181
+ readonly role: "assistant";
182
+ readonly status: Readable<(typeof RESPONSE_ITEM_STATUSES)[number]>;
183
+ readonly content: readonly ResponseOutputContentPart[];
184
+ }
185
+ export interface FunctionCallOutputItem {
186
+ readonly type: "function_call";
187
+ readonly id: string;
188
+ readonly call_id: string;
189
+ readonly name: string;
190
+ readonly arguments: string;
191
+ readonly status: Readable<(typeof RESPONSE_ITEM_STATUSES)[number]>;
192
+ }
193
+ export type ResponseOutputItem = MessageOutputItem | FunctionCallOutputItem | UnknownVariant;
194
+ export declare function validateOutputTextPart(value: unknown, param: string, options?: ParseOptions): ResponseValidationResult<ResponseOutputContentPart>;
195
+ export declare function validateResponseOutputItem(value: unknown, param: string, options?: ParseOptions): ResponseValidationResult<ResponseOutputItem>;
196
+ export interface ResponseUsage {
197
+ readonly input_tokens: number;
198
+ readonly input_tokens_details?: {
199
+ readonly cached_tokens?: number;
200
+ };
201
+ readonly output_tokens: number;
202
+ readonly output_tokens_details?: {
203
+ readonly reasoning_tokens?: number;
204
+ };
205
+ readonly total_tokens: number;
206
+ }
207
+ export interface OpenAIResponse {
208
+ readonly id: string;
209
+ readonly object: "response";
210
+ readonly created_at: number;
211
+ readonly completed_at?: number;
212
+ readonly status: ResponseStatus;
213
+ readonly error: {
214
+ readonly code: string;
215
+ readonly message: string;
216
+ } | null;
217
+ readonly incomplete_details: {
218
+ readonly reason: ResponseIncompleteReason;
219
+ } | null;
220
+ readonly model: EnlittStandardModel;
221
+ readonly output: readonly ResponseOutputItem[];
222
+ readonly output_text?: string;
223
+ readonly usage?: ResponseUsage;
224
+ readonly metadata: Readonly<Record<string, string>>;
225
+ }
226
+ /**
227
+ * Validate an `OpenAIResponse`. Unlike the request validator this is not on
228
+ * the untrusted-input boundary of a hostile caller — it validates what this
229
+ * system itself produced, or what a test fixture claims this system
230
+ * produced — so failures are reported with the same three-class shape for
231
+ * consistency but are expected to be rare in production.
232
+ */
233
+ export declare function validateOpenAIResponse(value: unknown, options?: ParseOptions): ResponseValidationResult<OpenAIResponse>;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * The stateless `POST /v1/responses` wire contract: request body, response
3
+ * body, and the hand-written runtime validators for both.
4
+ *
5
+ * `specs/PROTOCOLS.md` "Create model response" names an exact accepted field
6
+ * list, an exact rejected field list, and three failure classes a validator
7
+ * must distinguish so the backend can raise the right stable code and the SDK
8
+ * can classify it the same way from the same table. This module owns that
9
+ * classification once, the same way `errors.ts` owns the code table: the
10
+ * backend and the SDK both import it rather than each re-deriving which
11
+ * field belongs to which class.
12
+ *
13
+ * This package has zero runtime dependencies, so validation here is
14
+ * hand-written structural checking rather than a schema library. A validator
15
+ * never throws on ordinary bad input — it returns a result, because an
16
+ * `invalid_value` on request field 40 of 40 is routine traffic, not a bug in
17
+ * this process.
18
+ *
19
+ * Two shapes in `specs/PROTOCOLS.md` are gestured at but not enumerated in the
20
+ * "Create model response" section: `JsonSchema` is used as a type ("bounded
21
+ * ... schema depth, and encoded size") without the bound values being stated,
22
+ * and `ResponseOutputItem` is named without its member shapes being spelled
23
+ * out the way input items are. This module deliberately does not invent
24
+ * numeric bounds or output-item field shapes the spec does not give; see the
25
+ * doc comments on `JsonSchema`, `FunctionTool`, and `ResponseOutputItem` for
26
+ * exactly what is and is not enforced, and the implementation report for the
27
+ * ambiguity this leaves open.
28
+ */
29
+ import { type EnlittErrorCode } from "./errors.js";
30
+ import { type ParseOptions, type Readable, type UnknownVariant } from "./compatibility.js";
31
+ /**
32
+ * The only accepted value of the request's `model` field. A single accepted
33
+ * string is deliberate: the caller asks for the standard route and Enlitt
34
+ * alone decides which model actually serves it, so there is no override to
35
+ * validate the shape of.
36
+ */
37
+ export declare const ENLITT_STANDARD_MODEL = "enlitt-standard";
38
+ export type EnlittStandardModel = typeof ENLITT_STANDARD_MODEL;
39
+ /**
40
+ * The three failure classes `specs/PROTOCOLS.md` names for this surface,
41
+ * narrowed from the full stable-code union so a caller cannot construct a
42
+ * validation failure carrying a code this surface never raises. Codes are
43
+ * referenced through `ENLITT_ERROR_CODE`'s own keys rather than written as
44
+ * string literals, so a rename in `errors.ts` fails this file to compile
45
+ * instead of silently drifting.
46
+ */
47
+ export type ResponseRequestErrorCode = Extract<EnlittErrorCode, "invalid_value" | "unsupported_parameter" | "unsupported_value">;
48
+ /**
49
+ * A single validation failure. `param` names the offending field using the
50
+ * same dotted/bracketed path an OpenAI-shaped error already uses, so the
51
+ * value here can be copied directly into `EnlittErrorInput.param` at the call
52
+ * site without renaming anything.
53
+ */
54
+ export interface ResponseValidationFailure {
55
+ readonly code: ResponseRequestErrorCode;
56
+ readonly param: string;
57
+ readonly message: string;
58
+ }
59
+ /**
60
+ * The result shape every validator in this module returns. Ordinary
61
+ * validation failure is data, not an exception: a request body is untrusted
62
+ * input on the hottest path this package serves, and throwing for the
63
+ * expected case would force every caller to wrap every call in `try/catch`.
64
+ */
65
+ export type ResponseValidationResult<T> = {
66
+ readonly ok: true;
67
+ readonly value: T;
68
+ } | {
69
+ readonly ok: false;
70
+ readonly error: ResponseValidationFailure;
71
+ };
72
+ /** A JSON Schema object supplied to a function tool. */
73
+ export type JsonSchema = Readonly<Record<string, unknown>>;
74
+ export interface EnlittTextPart {
75
+ readonly type: "text";
76
+ readonly text: string;
77
+ }
78
+ export interface EnlittImageUrlSource {
79
+ readonly type: "url";
80
+ readonly url: string;
81
+ }
82
+ export interface EnlittImageBase64Source {
83
+ readonly type: "base64";
84
+ readonly media_type: "image/png" | "image/jpeg";
85
+ readonly data: string;
86
+ }
87
+ export interface EnlittImagePart {
88
+ readonly type: "image";
89
+ readonly source: EnlittImageUrlSource | EnlittImageBase64Source;
90
+ }
91
+ export type EnlittUserPart = EnlittTextPart | EnlittImagePart;
92
+ export interface EnlittSystemMessage {
93
+ readonly role: "system";
94
+ readonly content: string;
95
+ }
96
+ export interface EnlittUserMessage {
97
+ readonly role: "user";
98
+ readonly content: readonly EnlittUserPart[];
99
+ }
100
+ export interface EnlittToolCall {
101
+ readonly id: string;
102
+ readonly name: string;
103
+ readonly arguments: string;
104
+ }
105
+ export interface EnlittAssistantMessage {
106
+ readonly role: "assistant";
107
+ readonly content?: string;
108
+ readonly tool_calls?: readonly EnlittToolCall[];
109
+ }
110
+ export interface EnlittToolMessage {
111
+ readonly role: "tool";
112
+ readonly tool_call_id: string;
113
+ readonly content: string;
114
+ }
115
+ export type EnlittStandardMessage = EnlittSystemMessage | EnlittUserMessage | EnlittAssistantMessage | EnlittToolMessage;
116
+ export interface EnlittFunctionTool {
117
+ readonly name: string;
118
+ readonly description?: string;
119
+ readonly input_schema: JsonSchema;
120
+ }
121
+ /**
122
+ * The identical caller-metadata bound `specs/PROTOCOLS.md` states once and
123
+ * both the SDK and the premium path must apply without restating: at most 16
124
+ * entries, keys at most 64 characters, values at most 512, and no caller key
125
+ * beginning with `enlitt_` (that prefix is reserved for facts Enlitt adds to
126
+ * a response, such as `enlitt_operation_id`).
127
+ */
128
+ export declare const CALLER_METADATA_LIMITS: Readonly<{
129
+ maxEntries: 16;
130
+ maxKeyLength: 64;
131
+ maxValueLength: 512;
132
+ reservedKeyPrefix: "enlitt_";
133
+ }>;
134
+ export type ResponseMetadata = Readonly<Record<string, string>>;
135
+ /**
136
+ * Validate caller-supplied metadata against the one bound this surface, the
137
+ * premium path, and the SDK all share. Exported standalone — not folded into
138
+ * `validateEnlittStandardRequest` — precisely so a second copy of this
139
+ * rule never needs to be written next to a different endpoint's field list.
140
+ */
141
+ export declare function validateCallerMetadata(value: unknown, param?: string): ResponseValidationResult<ResponseMetadata>;
142
+ export interface EnlittStandardRequest {
143
+ readonly model: EnlittStandardModel;
144
+ readonly messages: readonly EnlittStandardMessage[];
145
+ readonly tools?: readonly EnlittFunctionTool[];
146
+ readonly max_output_tokens?: number;
147
+ readonly stream?: boolean;
148
+ readonly metadata?: ResponseMetadata;
149
+ }
150
+ export declare function validateEnlittStandardRequest(value: unknown): ResponseValidationResult<EnlittStandardRequest>;
151
+ export declare const RESPONSE_STATUSES: readonly ["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"];
152
+ export declare const RESPONSE_INCOMPLETE_REASONS: readonly ["max_output_tokens"];
153
+ export declare const RESPONSE_ITEM_STATUSES: readonly ["in_progress", "completed", "incomplete"];
154
+ export type ResponseStatusMember = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete";
155
+ export type ResponseStatus = Readable<ResponseStatusMember>;
156
+ export type ResponseIncompleteReason = Readable<(typeof RESPONSE_INCOMPLETE_REASONS)[number]>;
157
+ /**
158
+ * A member of `OpenAIResponse.output`.
159
+ *
160
+ * `specs/PROTOCOLS.md` names `ResponseOutputItem` but, in the section this
161
+ * module implements, does not enumerate its member shapes the way it
162
+ * enumerates input items. The two variants below are modeled on the pinned
163
+ * OpenAI Responses API subset this endpoint implements (the same subset the
164
+ * differential test harness drives) and on the streaming event names the
165
+ * spec does give — `response.output_item.*`, `response.content_part.*`,
166
+ * `response.output_text.*`, and `response.function_call_arguments.*` imply
167
+ * exactly a text-bearing message item and a function-call item and nothing
168
+ * else. This is the closest reading available from the read scope for this
169
+ * task; it is not a spec quotation, and it should be confirmed against
170
+ * wherever `ResponseOutputItem` is actually pinned down before another
171
+ * workspace depends on these exact field names.
172
+ */
173
+ export interface ResponseOutputTextPart {
174
+ readonly type: "output_text";
175
+ readonly text: string;
176
+ }
177
+ export type ResponseOutputContentPart = ResponseOutputTextPart | UnknownVariant;
178
+ export interface MessageOutputItem {
179
+ readonly type: "message";
180
+ readonly id: string;
181
+ readonly role: "assistant";
182
+ readonly status: Readable<(typeof RESPONSE_ITEM_STATUSES)[number]>;
183
+ readonly content: readonly ResponseOutputContentPart[];
184
+ }
185
+ export interface FunctionCallOutputItem {
186
+ readonly type: "function_call";
187
+ readonly id: string;
188
+ readonly call_id: string;
189
+ readonly name: string;
190
+ readonly arguments: string;
191
+ readonly status: Readable<(typeof RESPONSE_ITEM_STATUSES)[number]>;
192
+ }
193
+ export type ResponseOutputItem = MessageOutputItem | FunctionCallOutputItem | UnknownVariant;
194
+ export declare function validateOutputTextPart(value: unknown, param: string, options?: ParseOptions): ResponseValidationResult<ResponseOutputContentPart>;
195
+ export declare function validateResponseOutputItem(value: unknown, param: string, options?: ParseOptions): ResponseValidationResult<ResponseOutputItem>;
196
+ export interface ResponseUsage {
197
+ readonly input_tokens: number;
198
+ readonly input_tokens_details?: {
199
+ readonly cached_tokens?: number;
200
+ };
201
+ readonly output_tokens: number;
202
+ readonly output_tokens_details?: {
203
+ readonly reasoning_tokens?: number;
204
+ };
205
+ readonly total_tokens: number;
206
+ }
207
+ export interface OpenAIResponse {
208
+ readonly id: string;
209
+ readonly object: "response";
210
+ readonly created_at: number;
211
+ readonly completed_at?: number;
212
+ readonly status: ResponseStatus;
213
+ readonly error: {
214
+ readonly code: string;
215
+ readonly message: string;
216
+ } | null;
217
+ readonly incomplete_details: {
218
+ readonly reason: ResponseIncompleteReason;
219
+ } | null;
220
+ readonly model: EnlittStandardModel;
221
+ readonly output: readonly ResponseOutputItem[];
222
+ readonly output_text?: string;
223
+ readonly usage?: ResponseUsage;
224
+ readonly metadata: Readonly<Record<string, string>>;
225
+ }
226
+ /**
227
+ * Validate an `OpenAIResponse`. Unlike the request validator this is not on
228
+ * the untrusted-input boundary of a hostile caller — it validates what this
229
+ * system itself produced, or what a test fixture claims this system
230
+ * produced — so failures are reported with the same three-class shape for
231
+ * consistency but are expected to be rare in production.
232
+ */
233
+ export declare function validateOpenAIResponse(value: unknown, options?: ParseOptions): ResponseValidationResult<OpenAIResponse>;
234
+ //# sourceMappingURL=responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,MAAM,MAAM,mBAAmB,GAAG,OAAO,qBAAqB,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,eAAe,EACf,eAAe,GAAG,uBAAuB,GAAG,mBAAmB,CAChE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAClC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAA;CAAE,CAAC;AAsBtE,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAO3D,MAA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,EAAE,CAAC;IAC/C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,wBAAwB,CAAC,cAAc,CAAC,CAsIvH"}
@@ -0,0 +1,11 @@
1
+ import type { ParseOptions } from "./compatibility.cjs";
2
+ import type { ResponseValidationResult } from "./responses.cjs";
3
+ export interface UsageAvailability {
4
+ readonly remaining_percent: number;
5
+ readonly limit_cap_nano_usd: string;
6
+ }
7
+ export interface UsageResponse {
8
+ readonly standard: UsageAvailability;
9
+ readonly premium: UsageAvailability;
10
+ }
11
+ export declare function validateUsageResponse(value: unknown, options?: ParseOptions): ResponseValidationResult<UsageResponse>;
@@ -0,0 +1,12 @@
1
+ import type { ParseOptions } from "./compatibility.js";
2
+ import type { ResponseValidationResult } from "./responses.js";
3
+ export interface UsageAvailability {
4
+ readonly remaining_percent: number;
5
+ readonly limit_cap_nano_usd: string;
6
+ }
7
+ export interface UsageResponse {
8
+ readonly standard: UsageAvailability;
9
+ readonly premium: UsageAvailability;
10
+ }
11
+ export declare function validateUsageResponse(value: unknown, options?: ParseOptions): ResponseValidationResult<UsageResponse>;
12
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;CACrC;AAqCD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,wBAAwB,CAAC,aAAa,CAAC,CASrH"}