ADAPT-Chase commited on
Commit
77e3099
·
verified ·
1 Parent(s): 3bd7305

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/partial-json-parser/README.md +3 -0
  2. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/partial-json-parser/parser.ts +247 -0
  3. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/LICENSE +15 -0
  4. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/Options.ts +80 -0
  5. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/README.md +3 -0
  6. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/Refs.ts +47 -0
  7. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/errorMessages.ts +31 -0
  8. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/index.ts +37 -0
  9. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts +258 -0
  10. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/any.ts +5 -0
  11. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/array.ts +36 -0
  12. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/bigint.ts +60 -0
  13. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/boolean.ts +9 -0
  14. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/branded.ts +7 -0
  15. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/catch.ts +7 -0
  16. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/date.ts +83 -0
  17. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/default.ts +10 -0
  18. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/effects.ts +11 -0
  19. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/enum.ts +13 -0
  20. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/intersection.ts +64 -0
  21. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/literal.ts +37 -0
  22. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/map.ts +42 -0
  23. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts +27 -0
  24. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/never.ts +9 -0
  25. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/null.ts +16 -0
  26. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nullable.ts +49 -0
  27. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/number.ts +62 -0
  28. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts +76 -0
  29. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/optional.ts +28 -0
  30. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/pipeline.ts +28 -0
  31. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/promise.ts +7 -0
  32. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/readonly.ts +7 -0
  33. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/record.ts +73 -0
  34. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/set.ts +36 -0
  35. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/string.ts +400 -0
  36. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/tuple.ts +54 -0
  37. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/undefined.ts +9 -0
  38. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/union.ts +119 -0
  39. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/unknown.ts +5 -0
  40. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/util.ts +11 -0
  41. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts +120 -0
  42. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/index.ts +1 -0
  43. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/internal-base.ts +93 -0
  44. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/websocket.ts +143 -0
  45. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/ws.ts +96 -0
  46. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/decoders/line.ts +135 -0
  47. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/LICENSE.md +13 -0
  48. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/README.md +3 -0
  49. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/formats.ts +10 -0
  50. platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/index.ts +13 -0
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/partial-json-parser/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Partial JSON Parser
2
+
3
+ Vendored from https://www.npmjs.com/package/partial-json with some modifications
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/partial-json-parser/parser.ts ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const STR = 0b000000001;
2
+ const NUM = 0b000000010;
3
+ const ARR = 0b000000100;
4
+ const OBJ = 0b000001000;
5
+ const NULL = 0b000010000;
6
+ const BOOL = 0b000100000;
7
+ const NAN = 0b001000000;
8
+ const INFINITY = 0b010000000;
9
+ const MINUS_INFINITY = 0b100000000;
10
+
11
+ const INF = INFINITY | MINUS_INFINITY;
12
+ const SPECIAL = NULL | BOOL | INF | NAN;
13
+ const ATOM = STR | NUM | SPECIAL;
14
+ const COLLECTION = ARR | OBJ;
15
+ const ALL = ATOM | COLLECTION;
16
+
17
+ const Allow = {
18
+ STR,
19
+ NUM,
20
+ ARR,
21
+ OBJ,
22
+ NULL,
23
+ BOOL,
24
+ NAN,
25
+ INFINITY,
26
+ MINUS_INFINITY,
27
+ INF,
28
+ SPECIAL,
29
+ ATOM,
30
+ COLLECTION,
31
+ ALL,
32
+ };
33
+
34
+ // The JSON string segment was unable to be parsed completely
35
+ class PartialJSON extends Error {}
36
+
37
+ class MalformedJSON extends Error {}
38
+
39
+ /**
40
+ * Parse incomplete JSON
41
+ * @param {string} jsonString Partial JSON to be parsed
42
+ * @param {number} allowPartial Specify what types are allowed to be partial, see {@link Allow} for details
43
+ * @returns The parsed JSON
44
+ * @throws {PartialJSON} If the JSON is incomplete (related to the `allow` parameter)
45
+ * @throws {MalformedJSON} If the JSON is malformed
46
+ */
47
+ function parseJSON(jsonString: string, allowPartial: number = Allow.ALL): any {
48
+ if (typeof jsonString !== 'string') {
49
+ throw new TypeError(`expecting str, got ${typeof jsonString}`);
50
+ }
51
+ if (!jsonString.trim()) {
52
+ throw new Error(`${jsonString} is empty`);
53
+ }
54
+ return _parseJSON(jsonString.trim(), allowPartial);
55
+ }
56
+
57
+ const _parseJSON = (jsonString: string, allow: number) => {
58
+ const length = jsonString.length;
59
+ let index = 0;
60
+
61
+ const markPartialJSON = (msg: string) => {
62
+ throw new PartialJSON(`${msg} at position ${index}`);
63
+ };
64
+
65
+ const throwMalformedError = (msg: string) => {
66
+ throw new MalformedJSON(`${msg} at position ${index}`);
67
+ };
68
+
69
+ const parseAny: () => any = () => {
70
+ skipBlank();
71
+ if (index >= length) markPartialJSON('Unexpected end of input');
72
+ if (jsonString[index] === '"') return parseStr();
73
+ if (jsonString[index] === '{') return parseObj();
74
+ if (jsonString[index] === '[') return parseArr();
75
+ if (
76
+ jsonString.substring(index, index + 4) === 'null' ||
77
+ (Allow.NULL & allow && length - index < 4 && 'null'.startsWith(jsonString.substring(index)))
78
+ ) {
79
+ index += 4;
80
+ return null;
81
+ }
82
+ if (
83
+ jsonString.substring(index, index + 4) === 'true' ||
84
+ (Allow.BOOL & allow && length - index < 4 && 'true'.startsWith(jsonString.substring(index)))
85
+ ) {
86
+ index += 4;
87
+ return true;
88
+ }
89
+ if (
90
+ jsonString.substring(index, index + 5) === 'false' ||
91
+ (Allow.BOOL & allow && length - index < 5 && 'false'.startsWith(jsonString.substring(index)))
92
+ ) {
93
+ index += 5;
94
+ return false;
95
+ }
96
+ if (
97
+ jsonString.substring(index, index + 8) === 'Infinity' ||
98
+ (Allow.INFINITY & allow && length - index < 8 && 'Infinity'.startsWith(jsonString.substring(index)))
99
+ ) {
100
+ index += 8;
101
+ return Infinity;
102
+ }
103
+ if (
104
+ jsonString.substring(index, index + 9) === '-Infinity' ||
105
+ (Allow.MINUS_INFINITY & allow &&
106
+ 1 < length - index &&
107
+ length - index < 9 &&
108
+ '-Infinity'.startsWith(jsonString.substring(index)))
109
+ ) {
110
+ index += 9;
111
+ return -Infinity;
112
+ }
113
+ if (
114
+ jsonString.substring(index, index + 3) === 'NaN' ||
115
+ (Allow.NAN & allow && length - index < 3 && 'NaN'.startsWith(jsonString.substring(index)))
116
+ ) {
117
+ index += 3;
118
+ return NaN;
119
+ }
120
+ return parseNum();
121
+ };
122
+
123
+ const parseStr: () => string = () => {
124
+ const start = index;
125
+ let escape = false;
126
+ index++; // skip initial quote
127
+ while (index < length && (jsonString[index] !== '"' || (escape && jsonString[index - 1] === '\\'))) {
128
+ escape = jsonString[index] === '\\' ? !escape : false;
129
+ index++;
130
+ }
131
+ if (jsonString.charAt(index) == '"') {
132
+ try {
133
+ return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
134
+ } catch (e) {
135
+ throwMalformedError(String(e));
136
+ }
137
+ } else if (Allow.STR & allow) {
138
+ try {
139
+ return JSON.parse(jsonString.substring(start, index - Number(escape)) + '"');
140
+ } catch (e) {
141
+ // SyntaxError: Invalid escape sequence
142
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf('\\')) + '"');
143
+ }
144
+ }
145
+ markPartialJSON('Unterminated string literal');
146
+ };
147
+
148
+ const parseObj = () => {
149
+ index++; // skip initial brace
150
+ skipBlank();
151
+ const obj: Record<string, any> = {};
152
+ try {
153
+ while (jsonString[index] !== '}') {
154
+ skipBlank();
155
+ if (index >= length && Allow.OBJ & allow) return obj;
156
+ const key = parseStr();
157
+ skipBlank();
158
+ index++; // skip colon
159
+ try {
160
+ const value = parseAny();
161
+ Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });
162
+ } catch (e) {
163
+ if (Allow.OBJ & allow) return obj;
164
+ else throw e;
165
+ }
166
+ skipBlank();
167
+ if (jsonString[index] === ',') index++; // skip comma
168
+ }
169
+ } catch (e) {
170
+ if (Allow.OBJ & allow) return obj;
171
+ else markPartialJSON("Expected '}' at end of object");
172
+ }
173
+ index++; // skip final brace
174
+ return obj;
175
+ };
176
+
177
+ const parseArr = () => {
178
+ index++; // skip initial bracket
179
+ const arr = [];
180
+ try {
181
+ while (jsonString[index] !== ']') {
182
+ arr.push(parseAny());
183
+ skipBlank();
184
+ if (jsonString[index] === ',') {
185
+ index++; // skip comma
186
+ }
187
+ }
188
+ } catch (e) {
189
+ if (Allow.ARR & allow) {
190
+ return arr;
191
+ }
192
+ markPartialJSON("Expected ']' at end of array");
193
+ }
194
+ index++; // skip final bracket
195
+ return arr;
196
+ };
197
+
198
+ const parseNum = () => {
199
+ if (index === 0) {
200
+ if (jsonString === '-' && Allow.NUM & allow) markPartialJSON("Not sure what '-' is");
201
+ try {
202
+ return JSON.parse(jsonString);
203
+ } catch (e) {
204
+ if (Allow.NUM & allow) {
205
+ try {
206
+ if ('.' === jsonString[jsonString.length - 1])
207
+ return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf('.')));
208
+ return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf('e')));
209
+ } catch (e) {}
210
+ }
211
+ throwMalformedError(String(e));
212
+ }
213
+ }
214
+
215
+ const start = index;
216
+
217
+ if (jsonString[index] === '-') index++;
218
+ while (jsonString[index] && !',]}'.includes(jsonString[index]!)) index++;
219
+
220
+ if (index == length && !(Allow.NUM & allow)) markPartialJSON('Unterminated number literal');
221
+
222
+ try {
223
+ return JSON.parse(jsonString.substring(start, index));
224
+ } catch (e) {
225
+ if (jsonString.substring(start, index) === '-' && Allow.NUM & allow)
226
+ markPartialJSON("Not sure what '-' is");
227
+ try {
228
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf('e')));
229
+ } catch (e) {
230
+ throwMalformedError(String(e));
231
+ }
232
+ }
233
+ };
234
+
235
+ const skipBlank = () => {
236
+ while (index < length && ' \n\r\t'.includes(jsonString[index]!)) {
237
+ index++;
238
+ }
239
+ };
240
+
241
+ return parseAny();
242
+ };
243
+
244
+ // using this function with malformed JSON is undefined behavior
245
+ const partialParse = (input: string) => parseJSON(input, Allow.ALL ^ Allow.NUM);
246
+
247
+ export { partialParse, PartialJSON, MalformedJSON };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/LICENSE ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ISC License
2
+
3
+ Copyright (c) 2020, Stefan Terdell
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/Options.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodSchema, ZodTypeDef } from 'zod';
2
+ import { Refs, Seen } from './Refs';
3
+ import { JsonSchema7Type } from './parseDef';
4
+
5
+ export type Targets = 'jsonSchema7' | 'jsonSchema2019-09' | 'openApi3';
6
+
7
+ export type DateStrategy = 'format:date-time' | 'format:date' | 'string' | 'integer';
8
+
9
+ export const ignoreOverride = Symbol('Let zodToJsonSchema decide on which parser to use');
10
+
11
+ export type Options<Target extends Targets = 'jsonSchema7'> = {
12
+ name: string | undefined;
13
+ $refStrategy: 'root' | 'relative' | 'none' | 'seen' | 'extract-to-root';
14
+ basePath: string[];
15
+ effectStrategy: 'input' | 'any';
16
+ pipeStrategy: 'input' | 'output' | 'all';
17
+ dateStrategy: DateStrategy | DateStrategy[];
18
+ mapStrategy: 'entries' | 'record';
19
+ removeAdditionalStrategy: 'passthrough' | 'strict';
20
+ nullableStrategy: 'from-target' | 'property';
21
+ target: Target;
22
+ strictUnions: boolean;
23
+ definitionPath: string;
24
+ definitions: Record<string, ZodSchema | ZodTypeDef>;
25
+ errorMessages: boolean;
26
+ markdownDescription: boolean;
27
+ patternStrategy: 'escape' | 'preserve';
28
+ applyRegexFlags: boolean;
29
+ emailStrategy: 'format:email' | 'format:idn-email' | 'pattern:zod';
30
+ base64Strategy: 'format:binary' | 'contentEncoding:base64' | 'pattern:zod';
31
+ nameStrategy: 'ref' | 'duplicate-ref' | 'title';
32
+ override?: (
33
+ def: ZodTypeDef,
34
+ refs: Refs,
35
+ seen: Seen | undefined,
36
+ forceResolution?: boolean,
37
+ ) => JsonSchema7Type | undefined | typeof ignoreOverride;
38
+ openaiStrictMode?: boolean;
39
+ };
40
+
41
+ const defaultOptions: Omit<Options, 'definitions' | 'basePath'> = {
42
+ name: undefined,
43
+ $refStrategy: 'root',
44
+ effectStrategy: 'input',
45
+ pipeStrategy: 'all',
46
+ dateStrategy: 'format:date-time',
47
+ mapStrategy: 'entries',
48
+ nullableStrategy: 'from-target',
49
+ removeAdditionalStrategy: 'passthrough',
50
+ definitionPath: 'definitions',
51
+ target: 'jsonSchema7',
52
+ strictUnions: false,
53
+ errorMessages: false,
54
+ markdownDescription: false,
55
+ patternStrategy: 'escape',
56
+ applyRegexFlags: false,
57
+ emailStrategy: 'format:email',
58
+ base64Strategy: 'contentEncoding:base64',
59
+ nameStrategy: 'ref',
60
+ };
61
+
62
+ export const getDefaultOptions = <Target extends Targets>(
63
+ options: Partial<Options<Target>> | string | undefined,
64
+ ) => {
65
+ // We need to add `definitions` here as we may mutate it
66
+ return (
67
+ typeof options === 'string' ?
68
+ {
69
+ ...defaultOptions,
70
+ basePath: ['#'],
71
+ definitions: {},
72
+ name: options,
73
+ }
74
+ : {
75
+ ...defaultOptions,
76
+ basePath: ['#'],
77
+ definitions: {},
78
+ ...options,
79
+ }) as Options<Target>;
80
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Zod to Json Schema
2
+
3
+ Vendored version of https://github.com/StefanTerdell/zod-to-json-schema that has been updated to generate JSON Schemas that are compatible with OpenAI's [strict mode](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas)
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/Refs.ts ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ZodTypeDef } from 'zod';
2
+ import { getDefaultOptions, Options, Targets } from './Options';
3
+ import { JsonSchema7Type } from './parseDef';
4
+ import { zodDef } from './util';
5
+
6
+ export type Refs = {
7
+ seen: Map<ZodTypeDef, Seen>;
8
+ /**
9
+ * Set of all the `$ref`s we created, e.g. `Set(['#/$defs/ui'])`
10
+ * this notable does not include any `definitions` that were
11
+ * explicitly given as an option.
12
+ */
13
+ seenRefs: Set<string>;
14
+ currentPath: string[];
15
+ propertyPath: string[] | undefined;
16
+ } & Options<Targets>;
17
+
18
+ export type Seen = {
19
+ def: ZodTypeDef;
20
+ path: string[];
21
+ jsonSchema: JsonSchema7Type | undefined;
22
+ };
23
+
24
+ export const getRefs = (options?: string | Partial<Options<Targets>>): Refs => {
25
+ const _options = getDefaultOptions(options);
26
+ const currentPath =
27
+ _options.name !== undefined ?
28
+ [..._options.basePath, _options.definitionPath, _options.name]
29
+ : _options.basePath;
30
+ return {
31
+ ..._options,
32
+ currentPath: currentPath,
33
+ propertyPath: undefined,
34
+ seenRefs: new Set(),
35
+ seen: new Map(
36
+ Object.entries(_options.definitions).map(([name, def]) => [
37
+ zodDef(def),
38
+ {
39
+ def: zodDef(def),
40
+ path: [..._options.basePath, _options.definitionPath, name],
41
+ // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
42
+ jsonSchema: undefined,
43
+ },
44
+ ]),
45
+ ),
46
+ };
47
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/errorMessages.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { JsonSchema7TypeUnion } from './parseDef';
2
+ import { Refs } from './Refs';
3
+
4
+ export type ErrorMessages<T extends JsonSchema7TypeUnion, OmitProperties extends string = ''> = Partial<
5
+ Omit<{ [key in keyof T]: string }, OmitProperties | 'type' | 'errorMessages'>
6
+ >;
7
+
8
+ export function addErrorMessage<T extends { errorMessage?: ErrorMessages<any> }>(
9
+ res: T,
10
+ key: keyof T,
11
+ errorMessage: string | undefined,
12
+ refs: Refs,
13
+ ) {
14
+ if (!refs?.errorMessages) return;
15
+ if (errorMessage) {
16
+ res.errorMessage = {
17
+ ...res.errorMessage,
18
+ [key]: errorMessage,
19
+ };
20
+ }
21
+ }
22
+
23
+ export function setResponseValueAndErrors<
24
+ Json7Type extends JsonSchema7TypeUnion & {
25
+ errorMessage?: ErrorMessages<Json7Type>;
26
+ },
27
+ Key extends keyof Omit<Json7Type, 'errorMessage'>,
28
+ >(res: Json7Type, key: Key, value: Json7Type[Key], errorMessage: string | undefined, refs: Refs) {
29
+ res[key] = value;
30
+ addErrorMessage(res, key, errorMessage, refs);
31
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/index.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export * from './Options';
2
+ export * from './Refs';
3
+ export * from './errorMessages';
4
+ export * from './parseDef';
5
+ export * from './parsers/any';
6
+ export * from './parsers/array';
7
+ export * from './parsers/bigint';
8
+ export * from './parsers/boolean';
9
+ export * from './parsers/branded';
10
+ export * from './parsers/catch';
11
+ export * from './parsers/date';
12
+ export * from './parsers/default';
13
+ export * from './parsers/effects';
14
+ export * from './parsers/enum';
15
+ export * from './parsers/intersection';
16
+ export * from './parsers/literal';
17
+ export * from './parsers/map';
18
+ export * from './parsers/nativeEnum';
19
+ export * from './parsers/never';
20
+ export * from './parsers/null';
21
+ export * from './parsers/nullable';
22
+ export * from './parsers/number';
23
+ export * from './parsers/object';
24
+ export * from './parsers/optional';
25
+ export * from './parsers/pipeline';
26
+ export * from './parsers/promise';
27
+ export * from './parsers/readonly';
28
+ export * from './parsers/record';
29
+ export * from './parsers/set';
30
+ export * from './parsers/string';
31
+ export * from './parsers/tuple';
32
+ export * from './parsers/undefined';
33
+ export * from './parsers/union';
34
+ export * from './parsers/unknown';
35
+ export * from './zodToJsonSchema';
36
+ import { zodToJsonSchema } from './zodToJsonSchema';
37
+ export default zodToJsonSchema;
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodFirstPartyTypeKind, ZodTypeDef } from 'zod';
2
+ import { JsonSchema7AnyType, parseAnyDef } from './parsers/any';
3
+ import { JsonSchema7ArrayType, parseArrayDef } from './parsers/array';
4
+ import { JsonSchema7BigintType, parseBigintDef } from './parsers/bigint';
5
+ import { JsonSchema7BooleanType, parseBooleanDef } from './parsers/boolean';
6
+ import { parseBrandedDef } from './parsers/branded';
7
+ import { parseCatchDef } from './parsers/catch';
8
+ import { JsonSchema7DateType, parseDateDef } from './parsers/date';
9
+ import { parseDefaultDef } from './parsers/default';
10
+ import { parseEffectsDef } from './parsers/effects';
11
+ import { JsonSchema7EnumType, parseEnumDef } from './parsers/enum';
12
+ import { JsonSchema7AllOfType, parseIntersectionDef } from './parsers/intersection';
13
+ import { JsonSchema7LiteralType, parseLiteralDef } from './parsers/literal';
14
+ import { JsonSchema7MapType, parseMapDef } from './parsers/map';
15
+ import { JsonSchema7NativeEnumType, parseNativeEnumDef } from './parsers/nativeEnum';
16
+ import { JsonSchema7NeverType, parseNeverDef } from './parsers/never';
17
+ import { JsonSchema7NullType, parseNullDef } from './parsers/null';
18
+ import { JsonSchema7NullableType, parseNullableDef } from './parsers/nullable';
19
+ import { JsonSchema7NumberType, parseNumberDef } from './parsers/number';
20
+ import { JsonSchema7ObjectType, parseObjectDef } from './parsers/object';
21
+ import { parseOptionalDef } from './parsers/optional';
22
+ import { parsePipelineDef } from './parsers/pipeline';
23
+ import { parsePromiseDef } from './parsers/promise';
24
+ import { JsonSchema7RecordType, parseRecordDef } from './parsers/record';
25
+ import { JsonSchema7SetType, parseSetDef } from './parsers/set';
26
+ import { JsonSchema7StringType, parseStringDef } from './parsers/string';
27
+ import { JsonSchema7TupleType, parseTupleDef } from './parsers/tuple';
28
+ import { JsonSchema7UndefinedType, parseUndefinedDef } from './parsers/undefined';
29
+ import { JsonSchema7UnionType, parseUnionDef } from './parsers/union';
30
+ import { JsonSchema7UnknownType, parseUnknownDef } from './parsers/unknown';
31
+ import { Refs, Seen } from './Refs';
32
+ import { parseReadonlyDef } from './parsers/readonly';
33
+ import { ignoreOverride } from './Options';
34
+
35
+ type JsonSchema7RefType = { $ref: string };
36
+ type JsonSchema7Meta = {
37
+ title?: string;
38
+ default?: any;
39
+ description?: string;
40
+ markdownDescription?: string;
41
+ };
42
+
43
+ export type JsonSchema7TypeUnion =
44
+ | JsonSchema7StringType
45
+ | JsonSchema7ArrayType
46
+ | JsonSchema7NumberType
47
+ | JsonSchema7BigintType
48
+ | JsonSchema7BooleanType
49
+ | JsonSchema7DateType
50
+ | JsonSchema7EnumType
51
+ | JsonSchema7LiteralType
52
+ | JsonSchema7NativeEnumType
53
+ | JsonSchema7NullType
54
+ | JsonSchema7NumberType
55
+ | JsonSchema7ObjectType
56
+ | JsonSchema7RecordType
57
+ | JsonSchema7TupleType
58
+ | JsonSchema7UnionType
59
+ | JsonSchema7UndefinedType
60
+ | JsonSchema7RefType
61
+ | JsonSchema7NeverType
62
+ | JsonSchema7MapType
63
+ | JsonSchema7AnyType
64
+ | JsonSchema7NullableType
65
+ | JsonSchema7AllOfType
66
+ | JsonSchema7UnknownType
67
+ | JsonSchema7SetType;
68
+
69
+ export type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Meta;
70
+
71
+ export function parseDef(
72
+ def: ZodTypeDef,
73
+ refs: Refs,
74
+ forceResolution = false, // Forces a new schema to be instantiated even though its def has been seen. Used for improving refs in definitions. See https://github.com/StefanTerdell/zod-to-json-schema/pull/61.
75
+ ): JsonSchema7Type | undefined {
76
+ const seenItem = refs.seen.get(def);
77
+
78
+ if (refs.override) {
79
+ const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
80
+
81
+ if (overrideResult !== ignoreOverride) {
82
+ return overrideResult;
83
+ }
84
+ }
85
+
86
+ if (seenItem && !forceResolution) {
87
+ const seenSchema = get$ref(seenItem, refs);
88
+
89
+ if (seenSchema !== undefined) {
90
+ if ('$ref' in seenSchema) {
91
+ refs.seenRefs.add(seenSchema.$ref);
92
+ }
93
+
94
+ return seenSchema;
95
+ }
96
+ }
97
+
98
+ const newItem: Seen = { def, path: refs.currentPath, jsonSchema: undefined };
99
+
100
+ refs.seen.set(def, newItem);
101
+
102
+ const jsonSchema = selectParser(def, (def as any).typeName, refs, forceResolution);
103
+
104
+ if (jsonSchema) {
105
+ addMeta(def, refs, jsonSchema);
106
+ }
107
+
108
+ newItem.jsonSchema = jsonSchema;
109
+
110
+ return jsonSchema;
111
+ }
112
+
113
+ const get$ref = (
114
+ item: Seen,
115
+ refs: Refs,
116
+ ):
117
+ | {
118
+ $ref: string;
119
+ }
120
+ | {}
121
+ | undefined => {
122
+ switch (refs.$refStrategy) {
123
+ case 'root':
124
+ return { $ref: item.path.join('/') };
125
+ // this case is needed as OpenAI strict mode doesn't support top-level `$ref`s, i.e.
126
+ // the top-level schema *must* be `{"type": "object", "properties": {...}}` but if we ever
127
+ // need to define a `$ref`, relative `$ref`s aren't supported, so we need to extract
128
+ // the schema to `#/definitions/` and reference that.
129
+ //
130
+ // e.g. if we need to reference a schema at
131
+ // `["#","definitions","contactPerson","properties","person1","properties","name"]`
132
+ // then we'll extract it out to `contactPerson_properties_person1_properties_name`
133
+ case 'extract-to-root':
134
+ const name = item.path.slice(refs.basePath.length + 1).join('_');
135
+
136
+ // we don't need to extract the root schema in this case, as it's already
137
+ // been added to the definitions
138
+ if (name !== refs.name && refs.nameStrategy === 'duplicate-ref') {
139
+ refs.definitions[name] = item.def;
140
+ }
141
+
142
+ return { $ref: [...refs.basePath, refs.definitionPath, name].join('/') };
143
+ case 'relative':
144
+ return { $ref: getRelativePath(refs.currentPath, item.path) };
145
+ case 'none':
146
+ case 'seen': {
147
+ if (
148
+ item.path.length < refs.currentPath.length &&
149
+ item.path.every((value, index) => refs.currentPath[index] === value)
150
+ ) {
151
+ console.warn(`Recursive reference detected at ${refs.currentPath.join('/')}! Defaulting to any`);
152
+
153
+ return {};
154
+ }
155
+
156
+ return refs.$refStrategy === 'seen' ? {} : undefined;
157
+ }
158
+ }
159
+ };
160
+
161
+ const getRelativePath = (pathA: string[], pathB: string[]) => {
162
+ let i = 0;
163
+ for (; i < pathA.length && i < pathB.length; i++) {
164
+ if (pathA[i] !== pathB[i]) break;
165
+ }
166
+ return [(pathA.length - i).toString(), ...pathB.slice(i)].join('/');
167
+ };
168
+
169
+ const selectParser = (
170
+ def: any,
171
+ typeName: ZodFirstPartyTypeKind,
172
+ refs: Refs,
173
+ forceResolution: boolean,
174
+ ): JsonSchema7Type | undefined => {
175
+ switch (typeName) {
176
+ case ZodFirstPartyTypeKind.ZodString:
177
+ return parseStringDef(def, refs);
178
+ case ZodFirstPartyTypeKind.ZodNumber:
179
+ return parseNumberDef(def, refs);
180
+ case ZodFirstPartyTypeKind.ZodObject:
181
+ return parseObjectDef(def, refs);
182
+ case ZodFirstPartyTypeKind.ZodBigInt:
183
+ return parseBigintDef(def, refs);
184
+ case ZodFirstPartyTypeKind.ZodBoolean:
185
+ return parseBooleanDef();
186
+ case ZodFirstPartyTypeKind.ZodDate:
187
+ return parseDateDef(def, refs);
188
+ case ZodFirstPartyTypeKind.ZodUndefined:
189
+ return parseUndefinedDef();
190
+ case ZodFirstPartyTypeKind.ZodNull:
191
+ return parseNullDef(refs);
192
+ case ZodFirstPartyTypeKind.ZodArray:
193
+ return parseArrayDef(def, refs);
194
+ case ZodFirstPartyTypeKind.ZodUnion:
195
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
196
+ return parseUnionDef(def, refs);
197
+ case ZodFirstPartyTypeKind.ZodIntersection:
198
+ return parseIntersectionDef(def, refs);
199
+ case ZodFirstPartyTypeKind.ZodTuple:
200
+ return parseTupleDef(def, refs);
201
+ case ZodFirstPartyTypeKind.ZodRecord:
202
+ return parseRecordDef(def, refs);
203
+ case ZodFirstPartyTypeKind.ZodLiteral:
204
+ return parseLiteralDef(def, refs);
205
+ case ZodFirstPartyTypeKind.ZodEnum:
206
+ return parseEnumDef(def);
207
+ case ZodFirstPartyTypeKind.ZodNativeEnum:
208
+ return parseNativeEnumDef(def);
209
+ case ZodFirstPartyTypeKind.ZodNullable:
210
+ return parseNullableDef(def, refs);
211
+ case ZodFirstPartyTypeKind.ZodOptional:
212
+ return parseOptionalDef(def, refs);
213
+ case ZodFirstPartyTypeKind.ZodMap:
214
+ return parseMapDef(def, refs);
215
+ case ZodFirstPartyTypeKind.ZodSet:
216
+ return parseSetDef(def, refs);
217
+ case ZodFirstPartyTypeKind.ZodLazy:
218
+ return parseDef(def.getter()._def, refs);
219
+ case ZodFirstPartyTypeKind.ZodPromise:
220
+ return parsePromiseDef(def, refs);
221
+ case ZodFirstPartyTypeKind.ZodNaN:
222
+ case ZodFirstPartyTypeKind.ZodNever:
223
+ return parseNeverDef();
224
+ case ZodFirstPartyTypeKind.ZodEffects:
225
+ return parseEffectsDef(def, refs, forceResolution);
226
+ case ZodFirstPartyTypeKind.ZodAny:
227
+ return parseAnyDef();
228
+ case ZodFirstPartyTypeKind.ZodUnknown:
229
+ return parseUnknownDef();
230
+ case ZodFirstPartyTypeKind.ZodDefault:
231
+ return parseDefaultDef(def, refs);
232
+ case ZodFirstPartyTypeKind.ZodBranded:
233
+ return parseBrandedDef(def, refs);
234
+ case ZodFirstPartyTypeKind.ZodReadonly:
235
+ return parseReadonlyDef(def, refs);
236
+ case ZodFirstPartyTypeKind.ZodCatch:
237
+ return parseCatchDef(def, refs);
238
+ case ZodFirstPartyTypeKind.ZodPipeline:
239
+ return parsePipelineDef(def, refs);
240
+ case ZodFirstPartyTypeKind.ZodFunction:
241
+ case ZodFirstPartyTypeKind.ZodVoid:
242
+ case ZodFirstPartyTypeKind.ZodSymbol:
243
+ return undefined;
244
+ default:
245
+ return ((_: never) => undefined)(typeName);
246
+ }
247
+ };
248
+
249
+ const addMeta = (def: ZodTypeDef, refs: Refs, jsonSchema: JsonSchema7Type): JsonSchema7Type => {
250
+ if (def.description) {
251
+ jsonSchema.description = def.description;
252
+
253
+ if (refs.markdownDescription) {
254
+ jsonSchema.markdownDescription = def.description;
255
+ }
256
+ }
257
+ return jsonSchema;
258
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/any.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export type JsonSchema7AnyType = {};
2
+
3
+ export function parseAnyDef(): JsonSchema7AnyType {
4
+ return {};
5
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/array.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodArrayDef, ZodFirstPartyTypeKind } from 'zod';
2
+ import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
3
+ import { JsonSchema7Type, parseDef } from '../parseDef';
4
+ import { Refs } from '../Refs';
5
+
6
+ export type JsonSchema7ArrayType = {
7
+ type: 'array';
8
+ items?: JsonSchema7Type | undefined;
9
+ minItems?: number;
10
+ maxItems?: number;
11
+ errorMessages?: ErrorMessages<JsonSchema7ArrayType, 'items'>;
12
+ };
13
+
14
+ export function parseArrayDef(def: ZodArrayDef, refs: Refs) {
15
+ const res: JsonSchema7ArrayType = {
16
+ type: 'array',
17
+ };
18
+ if (def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
19
+ res.items = parseDef(def.type._def, {
20
+ ...refs,
21
+ currentPath: [...refs.currentPath, 'items'],
22
+ });
23
+ }
24
+
25
+ if (def.minLength) {
26
+ setResponseValueAndErrors(res, 'minItems', def.minLength.value, def.minLength.message, refs);
27
+ }
28
+ if (def.maxLength) {
29
+ setResponseValueAndErrors(res, 'maxItems', def.maxLength.value, def.maxLength.message, refs);
30
+ }
31
+ if (def.exactLength) {
32
+ setResponseValueAndErrors(res, 'minItems', def.exactLength.value, def.exactLength.message, refs);
33
+ setResponseValueAndErrors(res, 'maxItems', def.exactLength.value, def.exactLength.message, refs);
34
+ }
35
+ return res;
36
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/bigint.ts ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodBigIntDef } from 'zod';
2
+ import { Refs } from '../Refs';
3
+ import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
4
+
5
+ export type JsonSchema7BigintType = {
6
+ type: 'integer';
7
+ format: 'int64';
8
+ minimum?: BigInt;
9
+ exclusiveMinimum?: BigInt;
10
+ maximum?: BigInt;
11
+ exclusiveMaximum?: BigInt;
12
+ multipleOf?: BigInt;
13
+ errorMessage?: ErrorMessages<JsonSchema7BigintType>;
14
+ };
15
+
16
+ export function parseBigintDef(def: ZodBigIntDef, refs: Refs): JsonSchema7BigintType {
17
+ const res: JsonSchema7BigintType = {
18
+ type: 'integer',
19
+ format: 'int64',
20
+ };
21
+
22
+ if (!def.checks) return res;
23
+
24
+ for (const check of def.checks) {
25
+ switch (check.kind) {
26
+ case 'min':
27
+ if (refs.target === 'jsonSchema7') {
28
+ if (check.inclusive) {
29
+ setResponseValueAndErrors(res, 'minimum', check.value, check.message, refs);
30
+ } else {
31
+ setResponseValueAndErrors(res, 'exclusiveMinimum', check.value, check.message, refs);
32
+ }
33
+ } else {
34
+ if (!check.inclusive) {
35
+ res.exclusiveMinimum = true as any;
36
+ }
37
+ setResponseValueAndErrors(res, 'minimum', check.value, check.message, refs);
38
+ }
39
+ break;
40
+ case 'max':
41
+ if (refs.target === 'jsonSchema7') {
42
+ if (check.inclusive) {
43
+ setResponseValueAndErrors(res, 'maximum', check.value, check.message, refs);
44
+ } else {
45
+ setResponseValueAndErrors(res, 'exclusiveMaximum', check.value, check.message, refs);
46
+ }
47
+ } else {
48
+ if (!check.inclusive) {
49
+ res.exclusiveMaximum = true as any;
50
+ }
51
+ setResponseValueAndErrors(res, 'maximum', check.value, check.message, refs);
52
+ }
53
+ break;
54
+ case 'multipleOf':
55
+ setResponseValueAndErrors(res, 'multipleOf', check.value, check.message, refs);
56
+ break;
57
+ }
58
+ }
59
+ return res;
60
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/boolean.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ export type JsonSchema7BooleanType = {
2
+ type: 'boolean';
3
+ };
4
+
5
+ export function parseBooleanDef(): JsonSchema7BooleanType {
6
+ return {
7
+ type: 'boolean',
8
+ };
9
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/branded.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import { ZodBrandedDef } from 'zod';
2
+ import { parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export function parseBrandedDef(_def: ZodBrandedDef<any>, refs: Refs) {
6
+ return parseDef(_def.type._def, refs);
7
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/catch.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import { ZodCatchDef } from 'zod';
2
+ import { parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export const parseCatchDef = (def: ZodCatchDef<any>, refs: Refs) => {
6
+ return parseDef(def.innerType._def, refs);
7
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/date.ts ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodDateDef } from 'zod';
2
+ import { Refs } from '../Refs';
3
+ import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
4
+ import { JsonSchema7NumberType } from './number';
5
+ import { DateStrategy } from '../Options';
6
+
7
+ export type JsonSchema7DateType =
8
+ | {
9
+ type: 'integer' | 'string';
10
+ format: 'unix-time' | 'date-time' | 'date';
11
+ minimum?: number;
12
+ maximum?: number;
13
+ errorMessage?: ErrorMessages<JsonSchema7NumberType>;
14
+ }
15
+ | {
16
+ anyOf: JsonSchema7DateType[];
17
+ };
18
+
19
+ export function parseDateDef(
20
+ def: ZodDateDef,
21
+ refs: Refs,
22
+ overrideDateStrategy?: DateStrategy,
23
+ ): JsonSchema7DateType {
24
+ const strategy = overrideDateStrategy ?? refs.dateStrategy;
25
+
26
+ if (Array.isArray(strategy)) {
27
+ return {
28
+ anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)),
29
+ };
30
+ }
31
+
32
+ switch (strategy) {
33
+ case 'string':
34
+ case 'format:date-time':
35
+ return {
36
+ type: 'string',
37
+ format: 'date-time',
38
+ };
39
+ case 'format:date':
40
+ return {
41
+ type: 'string',
42
+ format: 'date',
43
+ };
44
+ case 'integer':
45
+ return integerDateParser(def, refs);
46
+ }
47
+ }
48
+
49
+ const integerDateParser = (def: ZodDateDef, refs: Refs) => {
50
+ const res: JsonSchema7DateType = {
51
+ type: 'integer',
52
+ format: 'unix-time',
53
+ };
54
+
55
+ if (refs.target === 'openApi3') {
56
+ return res;
57
+ }
58
+
59
+ for (const check of def.checks) {
60
+ switch (check.kind) {
61
+ case 'min':
62
+ setResponseValueAndErrors(
63
+ res,
64
+ 'minimum',
65
+ check.value, // This is in milliseconds
66
+ check.message,
67
+ refs,
68
+ );
69
+ break;
70
+ case 'max':
71
+ setResponseValueAndErrors(
72
+ res,
73
+ 'maximum',
74
+ check.value, // This is in milliseconds
75
+ check.message,
76
+ refs,
77
+ );
78
+ break;
79
+ }
80
+ }
81
+
82
+ return res;
83
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/default.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodDefaultDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export function parseDefaultDef(_def: ZodDefaultDef, refs: Refs): JsonSchema7Type & { default: any } {
6
+ return {
7
+ ...parseDef(_def.innerType._def, refs),
8
+ default: _def.defaultValue(),
9
+ };
10
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/effects.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodEffectsDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export function parseEffectsDef(
6
+ _def: ZodEffectsDef,
7
+ refs: Refs,
8
+ forceResolution: boolean,
9
+ ): JsonSchema7Type | undefined {
10
+ return refs.effectStrategy === 'input' ? parseDef(_def.schema._def, refs, forceResolution) : {};
11
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/enum.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodEnumDef } from 'zod';
2
+
3
+ export type JsonSchema7EnumType = {
4
+ type: 'string';
5
+ enum: string[];
6
+ };
7
+
8
+ export function parseEnumDef(def: ZodEnumDef): JsonSchema7EnumType {
9
+ return {
10
+ type: 'string',
11
+ enum: [...def.values],
12
+ };
13
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/intersection.ts ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodIntersectionDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+ import { JsonSchema7StringType } from './string';
5
+
6
+ export type JsonSchema7AllOfType = {
7
+ allOf: JsonSchema7Type[];
8
+ unevaluatedProperties?: boolean;
9
+ };
10
+
11
+ const isJsonSchema7AllOfType = (
12
+ type: JsonSchema7Type | JsonSchema7StringType,
13
+ ): type is JsonSchema7AllOfType => {
14
+ if ('type' in type && type.type === 'string') return false;
15
+ return 'allOf' in type;
16
+ };
17
+
18
+ export function parseIntersectionDef(
19
+ def: ZodIntersectionDef,
20
+ refs: Refs,
21
+ ): JsonSchema7AllOfType | JsonSchema7Type | undefined {
22
+ const allOf = [
23
+ parseDef(def.left._def, {
24
+ ...refs,
25
+ currentPath: [...refs.currentPath, 'allOf', '0'],
26
+ }),
27
+ parseDef(def.right._def, {
28
+ ...refs,
29
+ currentPath: [...refs.currentPath, 'allOf', '1'],
30
+ }),
31
+ ].filter((x): x is JsonSchema7Type => !!x);
32
+
33
+ let unevaluatedProperties: Pick<JsonSchema7AllOfType, 'unevaluatedProperties'> | undefined =
34
+ refs.target === 'jsonSchema2019-09' ? { unevaluatedProperties: false } : undefined;
35
+
36
+ const mergedAllOf: JsonSchema7Type[] = [];
37
+ // If either of the schemas is an allOf, merge them into a single allOf
38
+ allOf.forEach((schema) => {
39
+ if (isJsonSchema7AllOfType(schema)) {
40
+ mergedAllOf.push(...schema.allOf);
41
+ if (schema.unevaluatedProperties === undefined) {
42
+ // If one of the schemas has no unevaluatedProperties set,
43
+ // the merged schema should also have no unevaluatedProperties set
44
+ unevaluatedProperties = undefined;
45
+ }
46
+ } else {
47
+ let nestedSchema: JsonSchema7Type = schema;
48
+ if ('additionalProperties' in schema && schema.additionalProperties === false) {
49
+ const { additionalProperties, ...rest } = schema;
50
+ nestedSchema = rest;
51
+ } else {
52
+ // As soon as one of the schemas has additionalProperties set not to false, we allow unevaluatedProperties
53
+ unevaluatedProperties = undefined;
54
+ }
55
+ mergedAllOf.push(nestedSchema);
56
+ }
57
+ });
58
+ return mergedAllOf.length ?
59
+ {
60
+ allOf: mergedAllOf,
61
+ ...unevaluatedProperties,
62
+ }
63
+ : undefined;
64
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/literal.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodLiteralDef } from 'zod';
2
+ import { Refs } from '../Refs';
3
+
4
+ export type JsonSchema7LiteralType =
5
+ | {
6
+ type: 'string' | 'number' | 'integer' | 'boolean';
7
+ const: string | number | boolean;
8
+ }
9
+ | {
10
+ type: 'object' | 'array';
11
+ };
12
+
13
+ export function parseLiteralDef(def: ZodLiteralDef, refs: Refs): JsonSchema7LiteralType {
14
+ const parsedType = typeof def.value;
15
+ if (
16
+ parsedType !== 'bigint' &&
17
+ parsedType !== 'number' &&
18
+ parsedType !== 'boolean' &&
19
+ parsedType !== 'string'
20
+ ) {
21
+ return {
22
+ type: Array.isArray(def.value) ? 'array' : 'object',
23
+ };
24
+ }
25
+
26
+ if (refs.target === 'openApi3') {
27
+ return {
28
+ type: parsedType === 'bigint' ? 'integer' : parsedType,
29
+ enum: [def.value],
30
+ } as any;
31
+ }
32
+
33
+ return {
34
+ type: parsedType === 'bigint' ? 'integer' : parsedType,
35
+ const: def.value,
36
+ };
37
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/map.ts ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodMapDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+ import { JsonSchema7RecordType, parseRecordDef } from './record';
5
+
6
+ export type JsonSchema7MapType = {
7
+ type: 'array';
8
+ maxItems: 125;
9
+ items: {
10
+ type: 'array';
11
+ items: [JsonSchema7Type, JsonSchema7Type];
12
+ minItems: 2;
13
+ maxItems: 2;
14
+ };
15
+ };
16
+
17
+ export function parseMapDef(def: ZodMapDef, refs: Refs): JsonSchema7MapType | JsonSchema7RecordType {
18
+ if (refs.mapStrategy === 'record') {
19
+ return parseRecordDef(def, refs);
20
+ }
21
+
22
+ const keys =
23
+ parseDef(def.keyType._def, {
24
+ ...refs,
25
+ currentPath: [...refs.currentPath, 'items', 'items', '0'],
26
+ }) || {};
27
+ const values =
28
+ parseDef(def.valueType._def, {
29
+ ...refs,
30
+ currentPath: [...refs.currentPath, 'items', 'items', '1'],
31
+ }) || {};
32
+ return {
33
+ type: 'array',
34
+ maxItems: 125,
35
+ items: {
36
+ type: 'array',
37
+ items: [keys, values],
38
+ minItems: 2,
39
+ maxItems: 2,
40
+ },
41
+ };
42
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodNativeEnumDef } from 'zod';
2
+
3
+ export type JsonSchema7NativeEnumType = {
4
+ type: 'string' | 'number' | ['string', 'number'];
5
+ enum: (string | number)[];
6
+ };
7
+
8
+ export function parseNativeEnumDef(def: ZodNativeEnumDef): JsonSchema7NativeEnumType {
9
+ const object = def.values;
10
+ const actualKeys = Object.keys(def.values).filter((key: string) => {
11
+ return typeof object[object[key]!] !== 'number';
12
+ });
13
+
14
+ const actualValues = actualKeys.map((key: string) => object[key]!);
15
+
16
+ const parsedTypes = Array.from(new Set(actualValues.map((values: string | number) => typeof values)));
17
+
18
+ return {
19
+ type:
20
+ parsedTypes.length === 1 ?
21
+ parsedTypes[0] === 'string' ?
22
+ 'string'
23
+ : 'number'
24
+ : ['string', 'number'],
25
+ enum: actualValues,
26
+ };
27
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/never.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ export type JsonSchema7NeverType = {
2
+ not: {};
3
+ };
4
+
5
+ export function parseNeverDef(): JsonSchema7NeverType {
6
+ return {
7
+ not: {},
8
+ };
9
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/null.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Refs } from '../Refs';
2
+
3
+ export type JsonSchema7NullType = {
4
+ type: 'null';
5
+ };
6
+
7
+ export function parseNullDef(refs: Refs): JsonSchema7NullType {
8
+ return refs.target === 'openApi3' ?
9
+ ({
10
+ enum: ['null'],
11
+ nullable: true,
12
+ } as any)
13
+ : {
14
+ type: 'null',
15
+ };
16
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nullable.ts ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodNullableDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+ import { JsonSchema7NullType } from './null';
5
+ import { primitiveMappings } from './union';
6
+
7
+ export type JsonSchema7NullableType =
8
+ | {
9
+ anyOf: [JsonSchema7Type, JsonSchema7NullType];
10
+ }
11
+ | {
12
+ type: [string, 'null'];
13
+ };
14
+
15
+ export function parseNullableDef(def: ZodNullableDef, refs: Refs): JsonSchema7NullableType | undefined {
16
+ if (
17
+ ['ZodString', 'ZodNumber', 'ZodBigInt', 'ZodBoolean', 'ZodNull'].includes(def.innerType._def.typeName) &&
18
+ (!def.innerType._def.checks || !def.innerType._def.checks.length)
19
+ ) {
20
+ if (refs.target === 'openApi3' || refs.nullableStrategy === 'property') {
21
+ return {
22
+ type: primitiveMappings[def.innerType._def.typeName as keyof typeof primitiveMappings],
23
+ nullable: true,
24
+ } as any;
25
+ }
26
+
27
+ return {
28
+ type: [primitiveMappings[def.innerType._def.typeName as keyof typeof primitiveMappings], 'null'],
29
+ };
30
+ }
31
+
32
+ if (refs.target === 'openApi3') {
33
+ const base = parseDef(def.innerType._def, {
34
+ ...refs,
35
+ currentPath: [...refs.currentPath],
36
+ });
37
+
38
+ if (base && '$ref' in base) return { allOf: [base], nullable: true } as any;
39
+
40
+ return base && ({ ...base, nullable: true } as any);
41
+ }
42
+
43
+ const base = parseDef(def.innerType._def, {
44
+ ...refs,
45
+ currentPath: [...refs.currentPath, 'anyOf', '0'],
46
+ });
47
+
48
+ return base && { anyOf: [base, { type: 'null' }] };
49
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/number.ts ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodNumberDef } from 'zod';
2
+ import { addErrorMessage, ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
3
+ import { Refs } from '../Refs';
4
+
5
+ export type JsonSchema7NumberType = {
6
+ type: 'number' | 'integer';
7
+ minimum?: number;
8
+ exclusiveMinimum?: number;
9
+ maximum?: number;
10
+ exclusiveMaximum?: number;
11
+ multipleOf?: number;
12
+ errorMessage?: ErrorMessages<JsonSchema7NumberType>;
13
+ };
14
+
15
+ export function parseNumberDef(def: ZodNumberDef, refs: Refs): JsonSchema7NumberType {
16
+ const res: JsonSchema7NumberType = {
17
+ type: 'number',
18
+ };
19
+
20
+ if (!def.checks) return res;
21
+
22
+ for (const check of def.checks) {
23
+ switch (check.kind) {
24
+ case 'int':
25
+ res.type = 'integer';
26
+ addErrorMessage(res, 'type', check.message, refs);
27
+ break;
28
+ case 'min':
29
+ if (refs.target === 'jsonSchema7') {
30
+ if (check.inclusive) {
31
+ setResponseValueAndErrors(res, 'minimum', check.value, check.message, refs);
32
+ } else {
33
+ setResponseValueAndErrors(res, 'exclusiveMinimum', check.value, check.message, refs);
34
+ }
35
+ } else {
36
+ if (!check.inclusive) {
37
+ res.exclusiveMinimum = true as any;
38
+ }
39
+ setResponseValueAndErrors(res, 'minimum', check.value, check.message, refs);
40
+ }
41
+ break;
42
+ case 'max':
43
+ if (refs.target === 'jsonSchema7') {
44
+ if (check.inclusive) {
45
+ setResponseValueAndErrors(res, 'maximum', check.value, check.message, refs);
46
+ } else {
47
+ setResponseValueAndErrors(res, 'exclusiveMaximum', check.value, check.message, refs);
48
+ }
49
+ } else {
50
+ if (!check.inclusive) {
51
+ res.exclusiveMaximum = true as any;
52
+ }
53
+ setResponseValueAndErrors(res, 'maximum', check.value, check.message, refs);
54
+ }
55
+ break;
56
+ case 'multipleOf':
57
+ setResponseValueAndErrors(res, 'multipleOf', check.value, check.message, refs);
58
+ break;
59
+ }
60
+ }
61
+ return res;
62
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodObjectDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ function decideAdditionalProperties(def: ZodObjectDef, refs: Refs) {
6
+ if (refs.removeAdditionalStrategy === 'strict') {
7
+ return def.catchall._def.typeName === 'ZodNever' ?
8
+ def.unknownKeys !== 'strict'
9
+ : parseDef(def.catchall._def, {
10
+ ...refs,
11
+ currentPath: [...refs.currentPath, 'additionalProperties'],
12
+ }) ?? true;
13
+ } else {
14
+ return def.catchall._def.typeName === 'ZodNever' ?
15
+ def.unknownKeys === 'passthrough'
16
+ : parseDef(def.catchall._def, {
17
+ ...refs,
18
+ currentPath: [...refs.currentPath, 'additionalProperties'],
19
+ }) ?? true;
20
+ }
21
+ }
22
+
23
+ export type JsonSchema7ObjectType = {
24
+ type: 'object';
25
+ properties: Record<string, JsonSchema7Type>;
26
+ additionalProperties: boolean | JsonSchema7Type;
27
+ required?: string[];
28
+ };
29
+
30
+ export function parseObjectDef(def: ZodObjectDef, refs: Refs) {
31
+ const result: JsonSchema7ObjectType = {
32
+ type: 'object',
33
+ ...Object.entries(def.shape()).reduce(
34
+ (
35
+ acc: {
36
+ properties: Record<string, JsonSchema7Type>;
37
+ required: string[];
38
+ },
39
+ [propName, propDef],
40
+ ) => {
41
+ if (propDef === undefined || propDef._def === undefined) return acc;
42
+ const propertyPath = [...refs.currentPath, 'properties', propName];
43
+ const parsedDef = parseDef(propDef._def, {
44
+ ...refs,
45
+ currentPath: propertyPath,
46
+ propertyPath,
47
+ });
48
+ if (parsedDef === undefined) return acc;
49
+ if (
50
+ refs.openaiStrictMode &&
51
+ propDef.isOptional() &&
52
+ !propDef.isNullable() &&
53
+ typeof propDef._def?.defaultValue === 'undefined'
54
+ ) {
55
+ throw new Error(
56
+ `Zod field at \`${propertyPath.join(
57
+ '/',
58
+ )}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`,
59
+ );
60
+ }
61
+ return {
62
+ properties: {
63
+ ...acc.properties,
64
+ [propName]: parsedDef,
65
+ },
66
+ required:
67
+ propDef.isOptional() && !refs.openaiStrictMode ? acc.required : [...acc.required, propName],
68
+ };
69
+ },
70
+ { properties: {}, required: [] },
71
+ ),
72
+ additionalProperties: decideAdditionalProperties(def, refs),
73
+ };
74
+ if (!result.required!.length) delete result.required;
75
+ return result;
76
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/optional.ts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodOptionalDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export const parseOptionalDef = (def: ZodOptionalDef, refs: Refs): JsonSchema7Type | undefined => {
6
+ if (
7
+ refs.propertyPath &&
8
+ refs.currentPath.slice(0, refs.propertyPath.length).toString() === refs.propertyPath.toString()
9
+ ) {
10
+ return parseDef(def.innerType._def, { ...refs, currentPath: refs.currentPath });
11
+ }
12
+
13
+ const innerSchema = parseDef(def.innerType._def, {
14
+ ...refs,
15
+ currentPath: [...refs.currentPath, 'anyOf', '1'],
16
+ });
17
+
18
+ return innerSchema ?
19
+ {
20
+ anyOf: [
21
+ {
22
+ not: {},
23
+ },
24
+ innerSchema,
25
+ ],
26
+ }
27
+ : {};
28
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/pipeline.ts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodPipelineDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+ import { JsonSchema7AllOfType } from './intersection';
5
+
6
+ export const parsePipelineDef = (
7
+ def: ZodPipelineDef<any, any>,
8
+ refs: Refs,
9
+ ): JsonSchema7AllOfType | JsonSchema7Type | undefined => {
10
+ if (refs.pipeStrategy === 'input') {
11
+ return parseDef(def.in._def, refs);
12
+ } else if (refs.pipeStrategy === 'output') {
13
+ return parseDef(def.out._def, refs);
14
+ }
15
+
16
+ const a = parseDef(def.in._def, {
17
+ ...refs,
18
+ currentPath: [...refs.currentPath, 'allOf', '0'],
19
+ });
20
+ const b = parseDef(def.out._def, {
21
+ ...refs,
22
+ currentPath: [...refs.currentPath, 'allOf', a ? '1' : '0'],
23
+ });
24
+
25
+ return {
26
+ allOf: [a, b].filter((x): x is JsonSchema7Type => x !== undefined),
27
+ };
28
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/promise.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import { ZodPromiseDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export function parsePromiseDef(def: ZodPromiseDef, refs: Refs): JsonSchema7Type | undefined {
6
+ return parseDef(def.type._def, refs);
7
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/readonly.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import { ZodReadonlyDef } from 'zod';
2
+ import { parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export const parseReadonlyDef = (def: ZodReadonlyDef<any>, refs: Refs) => {
6
+ return parseDef(def.innerType._def, refs);
7
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/record.ts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodFirstPartyTypeKind, ZodMapDef, ZodRecordDef, ZodTypeAny } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+ import { JsonSchema7EnumType } from './enum';
5
+ import { JsonSchema7ObjectType } from './object';
6
+ import { JsonSchema7StringType, parseStringDef } from './string';
7
+
8
+ type JsonSchema7RecordPropertyNamesType =
9
+ | Omit<JsonSchema7StringType, 'type'>
10
+ | Omit<JsonSchema7EnumType, 'type'>;
11
+
12
+ export type JsonSchema7RecordType = {
13
+ type: 'object';
14
+ additionalProperties: JsonSchema7Type;
15
+ propertyNames?: JsonSchema7RecordPropertyNamesType;
16
+ };
17
+
18
+ export function parseRecordDef(
19
+ def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef,
20
+ refs: Refs,
21
+ ): JsonSchema7RecordType {
22
+ if (refs.target === 'openApi3' && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
23
+ return {
24
+ type: 'object',
25
+ required: def.keyType._def.values,
26
+ properties: def.keyType._def.values.reduce(
27
+ (acc: Record<string, JsonSchema7Type>, key: string) => ({
28
+ ...acc,
29
+ [key]:
30
+ parseDef(def.valueType._def, {
31
+ ...refs,
32
+ currentPath: [...refs.currentPath, 'properties', key],
33
+ }) ?? {},
34
+ }),
35
+ {},
36
+ ),
37
+ additionalProperties: false,
38
+ } satisfies JsonSchema7ObjectType as any;
39
+ }
40
+
41
+ const schema: JsonSchema7RecordType = {
42
+ type: 'object',
43
+ additionalProperties:
44
+ parseDef(def.valueType._def, {
45
+ ...refs,
46
+ currentPath: [...refs.currentPath, 'additionalProperties'],
47
+ }) ?? {},
48
+ };
49
+
50
+ if (refs.target === 'openApi3') {
51
+ return schema;
52
+ }
53
+
54
+ if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
55
+ const keyType: JsonSchema7RecordPropertyNamesType = Object.entries(
56
+ parseStringDef(def.keyType._def, refs),
57
+ ).reduce((acc, [key, value]) => (key === 'type' ? acc : { ...acc, [key]: value }), {});
58
+
59
+ return {
60
+ ...schema,
61
+ propertyNames: keyType,
62
+ };
63
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
64
+ return {
65
+ ...schema,
66
+ propertyNames: {
67
+ enum: def.keyType._def.values,
68
+ },
69
+ };
70
+ }
71
+
72
+ return schema;
73
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/set.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodSetDef } from 'zod';
2
+ import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
3
+ import { JsonSchema7Type, parseDef } from '../parseDef';
4
+ import { Refs } from '../Refs';
5
+
6
+ export type JsonSchema7SetType = {
7
+ type: 'array';
8
+ uniqueItems: true;
9
+ items?: JsonSchema7Type | undefined;
10
+ minItems?: number;
11
+ maxItems?: number;
12
+ errorMessage?: ErrorMessages<JsonSchema7SetType>;
13
+ };
14
+
15
+ export function parseSetDef(def: ZodSetDef, refs: Refs): JsonSchema7SetType {
16
+ const items = parseDef(def.valueType._def, {
17
+ ...refs,
18
+ currentPath: [...refs.currentPath, 'items'],
19
+ });
20
+
21
+ const schema: JsonSchema7SetType = {
22
+ type: 'array',
23
+ uniqueItems: true,
24
+ items,
25
+ };
26
+
27
+ if (def.minSize) {
28
+ setResponseValueAndErrors(schema, 'minItems', def.minSize.value, def.minSize.message, refs);
29
+ }
30
+
31
+ if (def.maxSize) {
32
+ setResponseValueAndErrors(schema, 'maxItems', def.maxSize.value, def.maxSize.message, refs);
33
+ }
34
+
35
+ return schema;
36
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/string.ts ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-nocheck
2
+ import { ZodStringDef } from 'zod';
3
+ import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
4
+ import { Refs } from '../Refs';
5
+
6
+ let emojiRegex: RegExp | undefined;
7
+
8
+ /**
9
+ * Generated from the regular expressions found here as of 2024-05-22:
10
+ * https://github.com/colinhacks/zod/blob/master/src/types.ts.
11
+ *
12
+ * Expressions with /i flag have been changed accordingly.
13
+ */
14
+ export const zodPatterns = {
15
+ /**
16
+ * `c` was changed to `[cC]` to replicate /i flag
17
+ */
18
+ cuid: /^[cC][^\s-]{8,}$/,
19
+ cuid2: /^[0-9a-z]+$/,
20
+ ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
21
+ /**
22
+ * `a-z` was added to replicate /i flag
23
+ */
24
+ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
25
+ /**
26
+ * Constructed a valid Unicode RegExp
27
+ *
28
+ * Lazily instantiate since this type of regex isn't supported
29
+ * in all envs (e.g. React Native).
30
+ *
31
+ * See:
32
+ * https://github.com/colinhacks/zod/issues/2433
33
+ * Fix in Zod:
34
+ * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
35
+ */
36
+ emoji: () => {
37
+ if (emojiRegex === undefined) {
38
+ emojiRegex = RegExp('^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$', 'u');
39
+ }
40
+ return emojiRegex;
41
+ },
42
+ /**
43
+ * Unused
44
+ */
45
+ uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
46
+ /**
47
+ * Unused
48
+ */
49
+ ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
50
+ /**
51
+ * Unused
52
+ */
53
+ ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
54
+ base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
55
+ nanoid: /^[a-zA-Z0-9_-]{21}$/,
56
+ } as const;
57
+
58
+ export type JsonSchema7StringType = {
59
+ type: 'string';
60
+ minLength?: number;
61
+ maxLength?: number;
62
+ format?:
63
+ | 'email'
64
+ | 'idn-email'
65
+ | 'uri'
66
+ | 'uuid'
67
+ | 'date-time'
68
+ | 'ipv4'
69
+ | 'ipv6'
70
+ | 'date'
71
+ | 'time'
72
+ | 'duration';
73
+ pattern?: string;
74
+ allOf?: {
75
+ pattern: string;
76
+ errorMessage?: ErrorMessages<{ pattern: string }>;
77
+ }[];
78
+ anyOf?: {
79
+ format: string;
80
+ errorMessage?: ErrorMessages<{ format: string }>;
81
+ }[];
82
+ errorMessage?: ErrorMessages<JsonSchema7StringType>;
83
+ contentEncoding?: string;
84
+ };
85
+
86
+ export function parseStringDef(def: ZodStringDef, refs: Refs): JsonSchema7StringType {
87
+ const res: JsonSchema7StringType = {
88
+ type: 'string',
89
+ };
90
+
91
+ function processPattern(value: string): string {
92
+ return refs.patternStrategy === 'escape' ? escapeNonAlphaNumeric(value) : value;
93
+ }
94
+
95
+ if (def.checks) {
96
+ for (const check of def.checks) {
97
+ switch (check.kind) {
98
+ case 'min':
99
+ setResponseValueAndErrors(
100
+ res,
101
+ 'minLength',
102
+ typeof res.minLength === 'number' ? Math.max(res.minLength, check.value) : check.value,
103
+ check.message,
104
+ refs,
105
+ );
106
+ break;
107
+ case 'max':
108
+ setResponseValueAndErrors(
109
+ res,
110
+ 'maxLength',
111
+ typeof res.maxLength === 'number' ? Math.min(res.maxLength, check.value) : check.value,
112
+ check.message,
113
+ refs,
114
+ );
115
+
116
+ break;
117
+ case 'email':
118
+ switch (refs.emailStrategy) {
119
+ case 'format:email':
120
+ addFormat(res, 'email', check.message, refs);
121
+ break;
122
+ case 'format:idn-email':
123
+ addFormat(res, 'idn-email', check.message, refs);
124
+ break;
125
+ case 'pattern:zod':
126
+ addPattern(res, zodPatterns.email, check.message, refs);
127
+ break;
128
+ }
129
+
130
+ break;
131
+ case 'url':
132
+ addFormat(res, 'uri', check.message, refs);
133
+ break;
134
+ case 'uuid':
135
+ addFormat(res, 'uuid', check.message, refs);
136
+ break;
137
+ case 'regex':
138
+ addPattern(res, check.regex, check.message, refs);
139
+ break;
140
+ case 'cuid':
141
+ addPattern(res, zodPatterns.cuid, check.message, refs);
142
+ break;
143
+ case 'cuid2':
144
+ addPattern(res, zodPatterns.cuid2, check.message, refs);
145
+ break;
146
+ case 'startsWith':
147
+ addPattern(res, RegExp(`^${processPattern(check.value)}`), check.message, refs);
148
+ break;
149
+ case 'endsWith':
150
+ addPattern(res, RegExp(`${processPattern(check.value)}$`), check.message, refs);
151
+ break;
152
+
153
+ case 'datetime':
154
+ addFormat(res, 'date-time', check.message, refs);
155
+ break;
156
+ case 'date':
157
+ addFormat(res, 'date', check.message, refs);
158
+ break;
159
+ case 'time':
160
+ addFormat(res, 'time', check.message, refs);
161
+ break;
162
+ case 'duration':
163
+ addFormat(res, 'duration', check.message, refs);
164
+ break;
165
+ case 'length':
166
+ setResponseValueAndErrors(
167
+ res,
168
+ 'minLength',
169
+ typeof res.minLength === 'number' ? Math.max(res.minLength, check.value) : check.value,
170
+ check.message,
171
+ refs,
172
+ );
173
+ setResponseValueAndErrors(
174
+ res,
175
+ 'maxLength',
176
+ typeof res.maxLength === 'number' ? Math.min(res.maxLength, check.value) : check.value,
177
+ check.message,
178
+ refs,
179
+ );
180
+ break;
181
+ case 'includes': {
182
+ addPattern(res, RegExp(processPattern(check.value)), check.message, refs);
183
+ break;
184
+ }
185
+ case 'ip': {
186
+ if (check.version !== 'v6') {
187
+ addFormat(res, 'ipv4', check.message, refs);
188
+ }
189
+ if (check.version !== 'v4') {
190
+ addFormat(res, 'ipv6', check.message, refs);
191
+ }
192
+ break;
193
+ }
194
+ case 'emoji':
195
+ addPattern(res, zodPatterns.emoji, check.message, refs);
196
+ break;
197
+ case 'ulid': {
198
+ addPattern(res, zodPatterns.ulid, check.message, refs);
199
+ break;
200
+ }
201
+ case 'base64': {
202
+ switch (refs.base64Strategy) {
203
+ case 'format:binary': {
204
+ addFormat(res, 'binary' as any, check.message, refs);
205
+ break;
206
+ }
207
+
208
+ case 'contentEncoding:base64': {
209
+ setResponseValueAndErrors(res, 'contentEncoding', 'base64', check.message, refs);
210
+ break;
211
+ }
212
+
213
+ case 'pattern:zod': {
214
+ addPattern(res, zodPatterns.base64, check.message, refs);
215
+ break;
216
+ }
217
+ }
218
+ break;
219
+ }
220
+ case 'nanoid': {
221
+ addPattern(res, zodPatterns.nanoid, check.message, refs);
222
+ }
223
+ case 'toLowerCase':
224
+ case 'toUpperCase':
225
+ case 'trim':
226
+ break;
227
+ default:
228
+ ((_: never) => {})(check);
229
+ }
230
+ }
231
+ }
232
+
233
+ return res;
234
+ }
235
+
236
+ const escapeNonAlphaNumeric = (value: string) =>
237
+ Array.from(value)
238
+ .map((c) => (/[a-zA-Z0-9]/.test(c) ? c : `\\${c}`))
239
+ .join('');
240
+
241
+ const addFormat = (
242
+ schema: JsonSchema7StringType,
243
+ value: Required<JsonSchema7StringType>['format'],
244
+ message: string | undefined,
245
+ refs: Refs,
246
+ ) => {
247
+ if (schema.format || schema.anyOf?.some((x) => x.format)) {
248
+ if (!schema.anyOf) {
249
+ schema.anyOf = [];
250
+ }
251
+
252
+ if (schema.format) {
253
+ schema.anyOf!.push({
254
+ format: schema.format,
255
+ ...(schema.errorMessage &&
256
+ refs.errorMessages && {
257
+ errorMessage: { format: schema.errorMessage.format },
258
+ }),
259
+ });
260
+ delete schema.format;
261
+ if (schema.errorMessage) {
262
+ delete schema.errorMessage.format;
263
+ if (Object.keys(schema.errorMessage).length === 0) {
264
+ delete schema.errorMessage;
265
+ }
266
+ }
267
+ }
268
+
269
+ schema.anyOf!.push({
270
+ format: value,
271
+ ...(message && refs.errorMessages && { errorMessage: { format: message } }),
272
+ });
273
+ } else {
274
+ setResponseValueAndErrors(schema, 'format', value, message, refs);
275
+ }
276
+ };
277
+
278
+ const addPattern = (
279
+ schema: JsonSchema7StringType,
280
+ regex: RegExp | (() => RegExp),
281
+ message: string | undefined,
282
+ refs: Refs,
283
+ ) => {
284
+ if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
285
+ if (!schema.allOf) {
286
+ schema.allOf = [];
287
+ }
288
+
289
+ if (schema.pattern) {
290
+ schema.allOf!.push({
291
+ pattern: schema.pattern,
292
+ ...(schema.errorMessage &&
293
+ refs.errorMessages && {
294
+ errorMessage: { pattern: schema.errorMessage.pattern },
295
+ }),
296
+ });
297
+ delete schema.pattern;
298
+ if (schema.errorMessage) {
299
+ delete schema.errorMessage.pattern;
300
+ if (Object.keys(schema.errorMessage).length === 0) {
301
+ delete schema.errorMessage;
302
+ }
303
+ }
304
+ }
305
+
306
+ schema.allOf!.push({
307
+ pattern: processRegExp(regex, refs),
308
+ ...(message && refs.errorMessages && { errorMessage: { pattern: message } }),
309
+ });
310
+ } else {
311
+ setResponseValueAndErrors(schema, 'pattern', processRegExp(regex, refs), message, refs);
312
+ }
313
+ };
314
+
315
+ // Mutate z.string.regex() in a best attempt to accommodate for regex flags when applyRegexFlags is true
316
+ const processRegExp = (regexOrFunction: RegExp | (() => RegExp), refs: Refs): string => {
317
+ const regex = typeof regexOrFunction === 'function' ? regexOrFunction() : regexOrFunction;
318
+ if (!refs.applyRegexFlags || !regex.flags) return regex.source;
319
+
320
+ // Currently handled flags
321
+ const flags = {
322
+ i: regex.flags.includes('i'), // Case-insensitive
323
+ m: regex.flags.includes('m'), // `^` and `$` matches adjacent to newline characters
324
+ s: regex.flags.includes('s'), // `.` matches newlines
325
+ };
326
+
327
+ // The general principle here is to step through each character, one at a time, applying mutations as flags require. We keep track when the current character is escaped, and when it's inside a group /like [this]/ or (also) a range like /[a-z]/. The following is fairly brittle imperative code; edit at your peril!
328
+
329
+ const source = flags.i ? regex.source.toLowerCase() : regex.source;
330
+ let pattern = '';
331
+ let isEscaped = false;
332
+ let inCharGroup = false;
333
+ let inCharRange = false;
334
+
335
+ for (let i = 0; i < source.length; i++) {
336
+ if (isEscaped) {
337
+ pattern += source[i];
338
+ isEscaped = false;
339
+ continue;
340
+ }
341
+
342
+ if (flags.i) {
343
+ if (inCharGroup) {
344
+ if (source[i].match(/[a-z]/)) {
345
+ if (inCharRange) {
346
+ pattern += source[i];
347
+ pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
348
+ inCharRange = false;
349
+ } else if (source[i + 1] === '-' && source[i + 2]?.match(/[a-z]/)) {
350
+ pattern += source[i];
351
+ inCharRange = true;
352
+ } else {
353
+ pattern += `${source[i]}${source[i].toUpperCase()}`;
354
+ }
355
+ continue;
356
+ }
357
+ } else if (source[i].match(/[a-z]/)) {
358
+ pattern += `[${source[i]}${source[i].toUpperCase()}]`;
359
+ continue;
360
+ }
361
+ }
362
+
363
+ if (flags.m) {
364
+ if (source[i] === '^') {
365
+ pattern += `(^|(?<=[\r\n]))`;
366
+ continue;
367
+ } else if (source[i] === '$') {
368
+ pattern += `($|(?=[\r\n]))`;
369
+ continue;
370
+ }
371
+ }
372
+
373
+ if (flags.s && source[i] === '.') {
374
+ pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
375
+ continue;
376
+ }
377
+
378
+ pattern += source[i];
379
+ if (source[i] === '\\') {
380
+ isEscaped = true;
381
+ } else if (inCharGroup && source[i] === ']') {
382
+ inCharGroup = false;
383
+ } else if (!inCharGroup && source[i] === '[') {
384
+ inCharGroup = true;
385
+ }
386
+ }
387
+
388
+ try {
389
+ const regexTest = new RegExp(pattern);
390
+ } catch {
391
+ console.warn(
392
+ `Could not convert regex pattern at ${refs.currentPath.join(
393
+ '/',
394
+ )} to a flag-independent form! Falling back to the flag-ignorant source`,
395
+ );
396
+ return regex.source;
397
+ }
398
+
399
+ return pattern;
400
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/tuple.ts ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodTupleDef, ZodTupleItems, ZodTypeAny } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export type JsonSchema7TupleType = {
6
+ type: 'array';
7
+ minItems: number;
8
+ items: JsonSchema7Type[];
9
+ } & (
10
+ | {
11
+ maxItems: number;
12
+ }
13
+ | {
14
+ additionalItems?: JsonSchema7Type | undefined;
15
+ }
16
+ );
17
+
18
+ export function parseTupleDef(
19
+ def: ZodTupleDef<ZodTupleItems | [], ZodTypeAny | null>,
20
+ refs: Refs,
21
+ ): JsonSchema7TupleType {
22
+ if (def.rest) {
23
+ return {
24
+ type: 'array',
25
+ minItems: def.items.length,
26
+ items: def.items
27
+ .map((x, i) =>
28
+ parseDef(x._def, {
29
+ ...refs,
30
+ currentPath: [...refs.currentPath, 'items', `${i}`],
31
+ }),
32
+ )
33
+ .reduce((acc: JsonSchema7Type[], x) => (x === undefined ? acc : [...acc, x]), []),
34
+ additionalItems: parseDef(def.rest._def, {
35
+ ...refs,
36
+ currentPath: [...refs.currentPath, 'additionalItems'],
37
+ }),
38
+ };
39
+ } else {
40
+ return {
41
+ type: 'array',
42
+ minItems: def.items.length,
43
+ maxItems: def.items.length,
44
+ items: def.items
45
+ .map((x, i) =>
46
+ parseDef(x._def, {
47
+ ...refs,
48
+ currentPath: [...refs.currentPath, 'items', `${i}`],
49
+ }),
50
+ )
51
+ .reduce((acc: JsonSchema7Type[], x) => (x === undefined ? acc : [...acc, x]), []),
52
+ };
53
+ }
54
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/undefined.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ export type JsonSchema7UndefinedType = {
2
+ not: {};
3
+ };
4
+
5
+ export function parseUndefinedDef(): JsonSchema7UndefinedType {
6
+ return {
7
+ not: {},
8
+ };
9
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/union.ts ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodDiscriminatedUnionDef, ZodLiteralDef, ZodTypeAny, ZodUnionDef } from 'zod';
2
+ import { JsonSchema7Type, parseDef } from '../parseDef';
3
+ import { Refs } from '../Refs';
4
+
5
+ export const primitiveMappings = {
6
+ ZodString: 'string',
7
+ ZodNumber: 'number',
8
+ ZodBigInt: 'integer',
9
+ ZodBoolean: 'boolean',
10
+ ZodNull: 'null',
11
+ } as const;
12
+ type ZodPrimitive = keyof typeof primitiveMappings;
13
+ type JsonSchema7Primitive = (typeof primitiveMappings)[keyof typeof primitiveMappings];
14
+
15
+ export type JsonSchema7UnionType = JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType;
16
+
17
+ type JsonSchema7PrimitiveUnionType =
18
+ | {
19
+ type: JsonSchema7Primitive | JsonSchema7Primitive[];
20
+ }
21
+ | {
22
+ type: JsonSchema7Primitive | JsonSchema7Primitive[];
23
+ enum: (string | number | bigint | boolean | null)[];
24
+ };
25
+
26
+ type JsonSchema7AnyOfType = {
27
+ anyOf: JsonSchema7Type[];
28
+ };
29
+
30
+ export function parseUnionDef(
31
+ def: ZodUnionDef | ZodDiscriminatedUnionDef<any, any>,
32
+ refs: Refs,
33
+ ): JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType | undefined {
34
+ if (refs.target === 'openApi3') return asAnyOf(def, refs);
35
+
36
+ const options: readonly ZodTypeAny[] =
37
+ def.options instanceof Map ? Array.from(def.options.values()) : def.options;
38
+
39
+ // This blocks tries to look ahead a bit to produce nicer looking schemas with type array instead of anyOf.
40
+ if (
41
+ options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))
42
+ ) {
43
+ // all types in union are primitive and lack checks, so might as well squash into {type: [...]}
44
+
45
+ const types = options.reduce((types: JsonSchema7Primitive[], x) => {
46
+ const type = primitiveMappings[x._def.typeName as ZodPrimitive]; //Can be safely casted due to row 43
47
+ return type && !types.includes(type) ? [...types, type] : types;
48
+ }, []);
49
+
50
+ return {
51
+ type: types.length > 1 ? types : types[0]!,
52
+ };
53
+ } else if (options.every((x) => x._def.typeName === 'ZodLiteral' && !x.description)) {
54
+ // all options literals
55
+
56
+ const types = options.reduce((acc: JsonSchema7Primitive[], x: { _def: ZodLiteralDef }) => {
57
+ const type = typeof x._def.value;
58
+ switch (type) {
59
+ case 'string':
60
+ case 'number':
61
+ case 'boolean':
62
+ return [...acc, type];
63
+ case 'bigint':
64
+ return [...acc, 'integer' as const];
65
+ case 'object':
66
+ if (x._def.value === null) return [...acc, 'null' as const];
67
+ case 'symbol':
68
+ case 'undefined':
69
+ case 'function':
70
+ default:
71
+ return acc;
72
+ }
73
+ }, []);
74
+
75
+ if (types.length === options.length) {
76
+ // all the literals are primitive, as far as null can be considered primitive
77
+
78
+ const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
79
+ return {
80
+ type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0]!,
81
+ enum: options.reduce(
82
+ (acc, x) => {
83
+ return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
84
+ },
85
+ [] as (string | number | bigint | boolean | null)[],
86
+ ),
87
+ };
88
+ }
89
+ } else if (options.every((x) => x._def.typeName === 'ZodEnum')) {
90
+ return {
91
+ type: 'string',
92
+ enum: options.reduce(
93
+ (acc: string[], x) => [...acc, ...x._def.values.filter((x: string) => !acc.includes(x))],
94
+ [],
95
+ ),
96
+ };
97
+ }
98
+
99
+ return asAnyOf(def, refs);
100
+ }
101
+
102
+ const asAnyOf = (
103
+ def: ZodUnionDef | ZodDiscriminatedUnionDef<any, any>,
104
+ refs: Refs,
105
+ ): JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType | undefined => {
106
+ const anyOf = ((def.options instanceof Map ? Array.from(def.options.values()) : def.options) as any[])
107
+ .map((x, i) =>
108
+ parseDef(x._def, {
109
+ ...refs,
110
+ currentPath: [...refs.currentPath, 'anyOf', `${i}`],
111
+ }),
112
+ )
113
+ .filter(
114
+ (x): x is JsonSchema7Type =>
115
+ !!x && (!refs.strictUnions || (typeof x === 'object' && Object.keys(x).length > 0)),
116
+ );
117
+
118
+ return anyOf.length ? { anyOf } : undefined;
119
+ };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/unknown.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export type JsonSchema7UnknownType = {};
2
+
3
+ export function parseUnknownDef(): JsonSchema7UnknownType {
4
+ return {};
5
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/util.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ZodSchema, ZodTypeDef } from 'zod';
2
+
3
+ export const zodDef = (zodSchema: ZodSchema | ZodTypeDef): ZodTypeDef => {
4
+ return '_def' in zodSchema ? zodSchema._def : zodSchema;
5
+ };
6
+
7
+ export function isEmptyObj(obj: Object | null | undefined): boolean {
8
+ if (!obj) return true;
9
+ for (const _k in obj) return false;
10
+ return true;
11
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ZodSchema } from 'zod';
2
+ import { Options, Targets } from './Options';
3
+ import { JsonSchema7Type, parseDef } from './parseDef';
4
+ import { getRefs } from './Refs';
5
+ import { zodDef, isEmptyObj } from './util';
6
+
7
+ const zodToJsonSchema = <Target extends Targets = 'jsonSchema7'>(
8
+ schema: ZodSchema<any>,
9
+ options?: Partial<Options<Target>> | string,
10
+ ): (Target extends 'jsonSchema7' ? JsonSchema7Type : object) & {
11
+ $schema?: string;
12
+ definitions?: {
13
+ [key: string]: Target extends 'jsonSchema7' ? JsonSchema7Type
14
+ : Target extends 'jsonSchema2019-09' ? JsonSchema7Type
15
+ : object;
16
+ };
17
+ } => {
18
+ const refs = getRefs(options);
19
+
20
+ const name =
21
+ typeof options === 'string' ? options
22
+ : options?.nameStrategy === 'title' ? undefined
23
+ : options?.name;
24
+
25
+ const main =
26
+ parseDef(
27
+ schema._def,
28
+ name === undefined ? refs : (
29
+ {
30
+ ...refs,
31
+ currentPath: [...refs.basePath, refs.definitionPath, name],
32
+ }
33
+ ),
34
+ false,
35
+ ) ?? {};
36
+
37
+ const title =
38
+ typeof options === 'object' && options.name !== undefined && options.nameStrategy === 'title' ?
39
+ options.name
40
+ : undefined;
41
+
42
+ if (title !== undefined) {
43
+ main.title = title;
44
+ }
45
+
46
+ const definitions = (() => {
47
+ if (isEmptyObj(refs.definitions)) {
48
+ return undefined;
49
+ }
50
+
51
+ const definitions: Record<string, any> = {};
52
+ const processedDefinitions = new Set();
53
+
54
+ // the call to `parseDef()` here might itself add more entries to `.definitions`
55
+ // so we need to continually evaluate definitions until we've resolved all of them
56
+ //
57
+ // we have a generous iteration limit here to avoid blowing up the stack if there
58
+ // are any bugs that would otherwise result in us iterating indefinitely
59
+ for (let i = 0; i < 500; i++) {
60
+ const newDefinitions = Object.entries(refs.definitions).filter(
61
+ ([key]) => !processedDefinitions.has(key),
62
+ );
63
+ if (newDefinitions.length === 0) break;
64
+
65
+ for (const [key, schema] of newDefinitions) {
66
+ definitions[key] =
67
+ parseDef(
68
+ zodDef(schema),
69
+ { ...refs, currentPath: [...refs.basePath, refs.definitionPath, key] },
70
+ true,
71
+ ) ?? {};
72
+ processedDefinitions.add(key);
73
+ }
74
+ }
75
+
76
+ return definitions;
77
+ })();
78
+
79
+ const combined: ReturnType<typeof zodToJsonSchema<Target>> =
80
+ name === undefined ?
81
+ definitions ?
82
+ {
83
+ ...main,
84
+ [refs.definitionPath]: definitions,
85
+ }
86
+ : main
87
+ : refs.nameStrategy === 'duplicate-ref' ?
88
+ {
89
+ ...main,
90
+ ...(definitions || refs.seenRefs.size ?
91
+ {
92
+ [refs.definitionPath]: {
93
+ ...definitions,
94
+ // only actually duplicate the schema definition if it was ever referenced
95
+ // otherwise the duplication is completely pointless
96
+ ...(refs.seenRefs.size ? { [name]: main } : undefined),
97
+ },
98
+ }
99
+ : undefined),
100
+ }
101
+ : {
102
+ $ref: [...(refs.$refStrategy === 'relative' ? [] : refs.basePath), refs.definitionPath, name].join(
103
+ '/',
104
+ ),
105
+ [refs.definitionPath]: {
106
+ ...definitions,
107
+ [name]: main,
108
+ },
109
+ };
110
+
111
+ if (refs.target === 'jsonSchema7') {
112
+ combined.$schema = 'http://json-schema.org/draft-07/schema#';
113
+ } else if (refs.target === 'jsonSchema2019-09') {
114
+ combined.$schema = 'https://json-schema.org/draft/2019-09/schema#';
115
+ }
116
+
117
+ return combined;
118
+ };
119
+
120
+ export { zodToJsonSchema };
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { OpenAIRealtimeError } from './internal-base';
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/internal-base.ts ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
2
+ import { EventEmitter } from '../../lib/EventEmitter';
3
+ import { OpenAIError } from '../../error';
4
+ import OpenAI, { AzureOpenAI } from '../../index';
5
+
6
+ export class OpenAIRealtimeError extends OpenAIError {
7
+ /**
8
+ * The error data that the API sent back in an `error` event.
9
+ */
10
+ error?: ErrorEvent.Error | undefined;
11
+
12
+ /**
13
+ * The unique ID of the server event.
14
+ */
15
+ event_id?: string | undefined;
16
+
17
+ constructor(message: string, event: ErrorEvent | null) {
18
+ super(message);
19
+
20
+ this.error = event?.error;
21
+ this.event_id = event?.event_id;
22
+ }
23
+ }
24
+
25
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
26
+
27
+ type RealtimeEvents = Simplify<
28
+ {
29
+ event: (event: RealtimeServerEvent) => void;
30
+ error: (error: OpenAIRealtimeError) => void;
31
+ } & {
32
+ [EventType in Exclude<RealtimeServerEvent['type'], 'error'>]: (
33
+ event: Extract<RealtimeServerEvent, { type: EventType }>,
34
+ ) => unknown;
35
+ }
36
+ >;
37
+
38
+ export abstract class OpenAIRealtimeEmitter extends EventEmitter<RealtimeEvents> {
39
+ /**
40
+ * Send an event to the API.
41
+ */
42
+ abstract send(event: RealtimeClientEvent): void;
43
+
44
+ /**
45
+ * Close the websocket connection.
46
+ */
47
+ abstract close(props?: { code: number; reason: string }): void;
48
+
49
+ protected _onError(event: null, message: string, cause: any): void;
50
+ protected _onError(event: ErrorEvent, message?: string | undefined): void;
51
+ protected _onError(event: ErrorEvent | null, message?: string | undefined, cause?: any): void {
52
+ message =
53
+ event?.error ?
54
+ `${event.error.message} code=${event.error.code} param=${event.error.param} type=${event.error.type} event_id=${event.error.event_id}`
55
+ : message ?? 'unknown error';
56
+
57
+ if (!this._hasListener('error')) {
58
+ const error = new OpenAIRealtimeError(
59
+ message +
60
+ `\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`rt.on('error', (error) => ...)\` `,
61
+ event,
62
+ );
63
+ // @ts-ignore
64
+ error.cause = cause;
65
+ Promise.reject(error);
66
+ return;
67
+ }
68
+
69
+ const error = new OpenAIRealtimeError(message, event);
70
+ // @ts-ignore
71
+ error.cause = cause;
72
+
73
+ this._emit('error', error);
74
+ }
75
+ }
76
+
77
+ export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
78
+ return client instanceof AzureOpenAI;
79
+ }
80
+
81
+ export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
82
+ const path = '/realtime';
83
+ const baseURL = client.baseURL;
84
+ const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
85
+ url.protocol = 'wss';
86
+ if (isAzure(client)) {
87
+ url.searchParams.set('api-version', client.apiVersion);
88
+ url.searchParams.set('deployment', model);
89
+ } else {
90
+ url.searchParams.set('model', model);
91
+ }
92
+ return url;
93
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/websocket.ts ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { AzureOpenAI, OpenAI } from '../../index';
2
+ import { OpenAIError } from '../../error';
3
+ import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
4
+ import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';
5
+ import { isRunningInBrowser } from '../../internal/detect-platform';
6
+
7
+ interface MessageEvent {
8
+ data: string;
9
+ }
10
+
11
+ type _WebSocket =
12
+ typeof globalThis extends (
13
+ {
14
+ WebSocket: infer ws extends abstract new (...args: any) => any;
15
+ }
16
+ ) ?
17
+ // @ts-ignore
18
+ InstanceType<ws>
19
+ : any;
20
+
21
+ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
22
+ url: URL;
23
+ socket: _WebSocket;
24
+
25
+ constructor(
26
+ props: {
27
+ model: string;
28
+ dangerouslyAllowBrowser?: boolean;
29
+ /**
30
+ * Callback to mutate the URL, needed for Azure.
31
+ * @internal
32
+ */
33
+ onURL?: (url: URL) => void;
34
+ },
35
+ client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
36
+ ) {
37
+ super();
38
+
39
+ const dangerouslyAllowBrowser =
40
+ props.dangerouslyAllowBrowser ??
41
+ (client as any)?._options?.dangerouslyAllowBrowser ??
42
+ (client?.apiKey.startsWith('ek_') ? true : null);
43
+
44
+ if (!dangerouslyAllowBrowser && isRunningInBrowser()) {
45
+ throw new OpenAIError(
46
+ "It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\n\nYou can avoid this error by creating an ephemeral session token:\nhttps://platform.openai.com/docs/api-reference/realtime-sessions\n",
47
+ );
48
+ }
49
+
50
+ client ??= new OpenAI({ dangerouslyAllowBrowser });
51
+
52
+ this.url = buildRealtimeURL(client, props.model);
53
+ props.onURL?.(this.url);
54
+
55
+ // @ts-ignore
56
+ this.socket = new WebSocket(this.url.toString(), [
57
+ 'realtime',
58
+ ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
59
+ 'openai-beta.realtime-v1',
60
+ ]);
61
+
62
+ this.socket.addEventListener('message', (websocketEvent: MessageEvent) => {
63
+ const event = (() => {
64
+ try {
65
+ return JSON.parse(websocketEvent.data.toString()) as RealtimeServerEvent;
66
+ } catch (err) {
67
+ this._onError(null, 'could not parse websocket event', err);
68
+ return null;
69
+ }
70
+ })();
71
+
72
+ if (event) {
73
+ this._emit('event', event);
74
+
75
+ if (event.type === 'error') {
76
+ this._onError(event);
77
+ } else {
78
+ // @ts-expect-error TS isn't smart enough to get the relationship right here
79
+ this._emit(event.type, event);
80
+ }
81
+ }
82
+ });
83
+
84
+ this.socket.addEventListener('error', (event: any) => {
85
+ this._onError(null, event.message, null);
86
+ });
87
+
88
+ if (isAzure(client)) {
89
+ if (this.url.searchParams.get('Authorization') !== null) {
90
+ this.url.searchParams.set('Authorization', '<REDACTED>');
91
+ } else {
92
+ this.url.searchParams.set('api-key', '<REDACTED>');
93
+ }
94
+ }
95
+ }
96
+
97
+ static async azure(
98
+ client: Pick<AzureOpenAI, '_getAzureADToken' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
99
+ options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
100
+ ): Promise<OpenAIRealtimeWebSocket> {
101
+ const token = await client._getAzureADToken();
102
+ function onURL(url: URL) {
103
+ if (client.apiKey !== '<Missing Key>') {
104
+ url.searchParams.set('api-key', client.apiKey);
105
+ } else {
106
+ if (token) {
107
+ url.searchParams.set('Authorization', `Bearer ${token}`);
108
+ } else {
109
+ throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
110
+ }
111
+ }
112
+ }
113
+ const deploymentName = options.deploymentName ?? client.deploymentName;
114
+ if (!deploymentName) {
115
+ throw new Error('No deployment name provided');
116
+ }
117
+ const { dangerouslyAllowBrowser } = options;
118
+ return new OpenAIRealtimeWebSocket(
119
+ {
120
+ model: deploymentName,
121
+ onURL,
122
+ ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
123
+ },
124
+ client,
125
+ );
126
+ }
127
+
128
+ send(event: RealtimeClientEvent) {
129
+ try {
130
+ this.socket.send(JSON.stringify(event));
131
+ } catch (err) {
132
+ this._onError(null, 'could not send data', err);
133
+ }
134
+ }
135
+
136
+ close(props?: { code: number; reason: string }) {
137
+ try {
138
+ this.socket.close(props?.code ?? 1000, props?.reason ?? 'OK');
139
+ } catch (err) {
140
+ this._onError(null, 'could not close the connection', err);
141
+ }
142
+ }
143
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/beta/realtime/ws.ts ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as WS from 'ws';
2
+ import { AzureOpenAI, OpenAI } from '../../index';
3
+ import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
4
+ import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';
5
+
6
+ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
7
+ url: URL;
8
+ socket: WS.WebSocket;
9
+
10
+ constructor(
11
+ props: { model: string; options?: WS.ClientOptions | undefined },
12
+ client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
13
+ ) {
14
+ super();
15
+ client ??= new OpenAI();
16
+
17
+ this.url = buildRealtimeURL(client, props.model);
18
+ this.socket = new WS.WebSocket(this.url, {
19
+ ...props.options,
20
+ headers: {
21
+ ...props.options?.headers,
22
+ ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
23
+ 'OpenAI-Beta': 'realtime=v1',
24
+ },
25
+ });
26
+
27
+ this.socket.on('message', (wsEvent) => {
28
+ const event = (() => {
29
+ try {
30
+ return JSON.parse(wsEvent.toString()) as RealtimeServerEvent;
31
+ } catch (err) {
32
+ this._onError(null, 'could not parse websocket event', err);
33
+ return null;
34
+ }
35
+ })();
36
+
37
+ if (event) {
38
+ this._emit('event', event);
39
+
40
+ if (event.type === 'error') {
41
+ this._onError(event);
42
+ } else {
43
+ // @ts-expect-error TS isn't smart enough to get the relationship right here
44
+ this._emit(event.type, event);
45
+ }
46
+ }
47
+ });
48
+
49
+ this.socket.on('error', (err) => {
50
+ this._onError(null, err.message, err);
51
+ });
52
+ }
53
+
54
+ static async azure(
55
+ client: Pick<AzureOpenAI, '_getAzureADToken' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
56
+ options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
57
+ ): Promise<OpenAIRealtimeWS> {
58
+ const deploymentName = options.deploymentName ?? client.deploymentName;
59
+ if (!deploymentName) {
60
+ throw new Error('No deployment name provided');
61
+ }
62
+ return new OpenAIRealtimeWS(
63
+ { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
64
+ client,
65
+ );
66
+ }
67
+
68
+ send(event: RealtimeClientEvent) {
69
+ try {
70
+ this.socket.send(JSON.stringify(event));
71
+ } catch (err) {
72
+ this._onError(null, 'could not send data', err);
73
+ }
74
+ }
75
+
76
+ close(props?: { code: number; reason: string }) {
77
+ try {
78
+ this.socket.close(props?.code ?? 1000, props?.reason ?? 'OK');
79
+ } catch (err) {
80
+ this._onError(null, 'could not close the connection', err);
81
+ }
82
+ }
83
+ }
84
+
85
+ async function getAzureHeaders(client: Pick<AzureOpenAI, '_getAzureADToken' | 'apiKey'>) {
86
+ if (client.apiKey !== '<Missing Key>') {
87
+ return { 'api-key': client.apiKey };
88
+ } else {
89
+ const token = await client._getAzureADToken();
90
+ if (token) {
91
+ return { Authorization: `Bearer ${token}` };
92
+ } else {
93
+ throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
94
+ }
95
+ }
96
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/decoders/line.ts ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { concatBytes, decodeUTF8, encodeUTF8 } from '../utils/bytes';
2
+
3
+ export type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
4
+
5
+ /**
6
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
7
+ * reading lines from text.
8
+ *
9
+ * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
10
+ */
11
+ export class LineDecoder {
12
+ // prettier-ignore
13
+ static NEWLINE_CHARS = new Set(['\n', '\r']);
14
+ static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
15
+
16
+ #buffer: Uint8Array;
17
+ #carriageReturnIndex: number | null;
18
+
19
+ constructor() {
20
+ this.#buffer = new Uint8Array();
21
+ this.#carriageReturnIndex = null;
22
+ }
23
+
24
+ decode(chunk: Bytes): string[] {
25
+ if (chunk == null) {
26
+ return [];
27
+ }
28
+
29
+ const binaryChunk =
30
+ chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
31
+ : typeof chunk === 'string' ? encodeUTF8(chunk)
32
+ : chunk;
33
+
34
+ this.#buffer = concatBytes([this.#buffer, binaryChunk]);
35
+
36
+ const lines: string[] = [];
37
+ let patternIndex;
38
+ while ((patternIndex = findNewlineIndex(this.#buffer, this.#carriageReturnIndex)) != null) {
39
+ if (patternIndex.carriage && this.#carriageReturnIndex == null) {
40
+ // skip until we either get a corresponding `\n`, a new `\r` or nothing
41
+ this.#carriageReturnIndex = patternIndex.index;
42
+ continue;
43
+ }
44
+
45
+ // we got double \r or \rtext\n
46
+ if (
47
+ this.#carriageReturnIndex != null &&
48
+ (patternIndex.index !== this.#carriageReturnIndex + 1 || patternIndex.carriage)
49
+ ) {
50
+ lines.push(decodeUTF8(this.#buffer.subarray(0, this.#carriageReturnIndex - 1)));
51
+ this.#buffer = this.#buffer.subarray(this.#carriageReturnIndex);
52
+ this.#carriageReturnIndex = null;
53
+ continue;
54
+ }
55
+
56
+ const endIndex =
57
+ this.#carriageReturnIndex !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
58
+
59
+ const line = decodeUTF8(this.#buffer.subarray(0, endIndex));
60
+ lines.push(line);
61
+
62
+ this.#buffer = this.#buffer.subarray(patternIndex.index);
63
+ this.#carriageReturnIndex = null;
64
+ }
65
+
66
+ return lines;
67
+ }
68
+
69
+ flush(): string[] {
70
+ if (!this.#buffer.length) {
71
+ return [];
72
+ }
73
+ return this.decode('\n');
74
+ }
75
+ }
76
+
77
+ /**
78
+ * This function searches the buffer for the end patterns, (\r or \n)
79
+ * and returns an object with the index preceding the matched newline and the
80
+ * index after the newline char. `null` is returned if no new line is found.
81
+ *
82
+ * ```ts
83
+ * findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
84
+ * ```
85
+ */
86
+ function findNewlineIndex(
87
+ buffer: Uint8Array,
88
+ startIndex: number | null,
89
+ ): { preceding: number; index: number; carriage: boolean } | null {
90
+ const newline = 0x0a; // \n
91
+ const carriage = 0x0d; // \r
92
+
93
+ for (let i = startIndex ?? 0; i < buffer.length; i++) {
94
+ if (buffer[i] === newline) {
95
+ return { preceding: i, index: i + 1, carriage: false };
96
+ }
97
+
98
+ if (buffer[i] === carriage) {
99
+ return { preceding: i, index: i + 1, carriage: true };
100
+ }
101
+ }
102
+
103
+ return null;
104
+ }
105
+
106
+ export function findDoubleNewlineIndex(buffer: Uint8Array): number {
107
+ // This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
108
+ // and returns the index right after the first occurrence of any pattern,
109
+ // or -1 if none of the patterns are found.
110
+ const newline = 0x0a; // \n
111
+ const carriage = 0x0d; // \r
112
+
113
+ for (let i = 0; i < buffer.length - 1; i++) {
114
+ if (buffer[i] === newline && buffer[i + 1] === newline) {
115
+ // \n\n
116
+ return i + 2;
117
+ }
118
+ if (buffer[i] === carriage && buffer[i + 1] === carriage) {
119
+ // \r\r
120
+ return i + 2;
121
+ }
122
+ if (
123
+ buffer[i] === carriage &&
124
+ buffer[i + 1] === newline &&
125
+ i + 3 < buffer.length &&
126
+ buffer[i + 2] === carriage &&
127
+ buffer[i + 3] === newline
128
+ ) {
129
+ // \r\n\r\n
130
+ return i + 4;
131
+ }
132
+ }
133
+
134
+ return -1;
135
+ }
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/LICENSE.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+
11
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # qs
2
+
3
+ This is a vendored version of [neoqs](https://github.com/PuruVJ/neoqs) which is a TypeScript rewrite of [qs](https://github.com/ljharb/qs), a query string library.
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/formats.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Format } from './types';
2
+
3
+ export const default_format: Format = 'RFC3986';
4
+ export const default_formatter = (v: PropertyKey) => String(v);
5
+ export const formatters: Record<Format, (str: PropertyKey) => string> = {
6
+ RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
7
+ RFC3986: default_formatter,
8
+ };
9
+ export const RFC1738 = 'RFC1738';
10
+ export const RFC3986 = 'RFC3986';
platform/aiml/elizabeth/e-1-first_session/claude-code-router/node_modules/openai/src/internal/qs/index.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { default_format, formatters, RFC1738, RFC3986 } from './formats';
2
+
3
+ const formats = {
4
+ formatters,
5
+ RFC1738,
6
+ RFC3986,
7
+ default: default_format,
8
+ };
9
+
10
+ export { stringify } from './stringify';
11
+ export { formats };
12
+
13
+ export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';