@northflare/runner 0.0.16 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/package.json +16 -17
  2. package/{lib/codex-sdk/tsup.config.ts → tsup.config.ts} +2 -2
  3. package/lib/codex-sdk/.prettierignore +0 -3
  4. package/lib/codex-sdk/.prettierrc +0 -5
  5. package/lib/codex-sdk/README.md +0 -133
  6. package/lib/codex-sdk/dist/index.d.ts +0 -260
  7. package/lib/codex-sdk/dist/index.js +0 -426
  8. package/lib/codex-sdk/dist/samples/basic_streaming.d.ts +0 -3
  9. package/lib/codex-sdk/dist/samples/basic_streaming.d.ts.map +0 -1
  10. package/lib/codex-sdk/dist/samples/basic_streaming.js +0 -81
  11. package/lib/codex-sdk/dist/samples/basic_streaming.js.map +0 -1
  12. package/lib/codex-sdk/dist/samples/helpers.d.ts +0 -2
  13. package/lib/codex-sdk/dist/samples/helpers.d.ts.map +0 -1
  14. package/lib/codex-sdk/dist/samples/helpers.js +0 -6
  15. package/lib/codex-sdk/dist/samples/helpers.js.map +0 -1
  16. package/lib/codex-sdk/dist/samples/structured_output.d.ts +0 -3
  17. package/lib/codex-sdk/dist/samples/structured_output.d.ts.map +0 -1
  18. package/lib/codex-sdk/dist/samples/structured_output.js +0 -17
  19. package/lib/codex-sdk/dist/samples/structured_output.js.map +0 -1
  20. package/lib/codex-sdk/dist/samples/structured_output_zod.d.ts +0 -3
  21. package/lib/codex-sdk/dist/samples/structured_output_zod.d.ts.map +0 -1
  22. package/lib/codex-sdk/dist/samples/structured_output_zod.js +0 -16
  23. package/lib/codex-sdk/dist/samples/structured_output_zod.js.map +0 -1
  24. package/lib/codex-sdk/dist/tsup.config.d.ts +0 -3
  25. package/lib/codex-sdk/dist/tsup.config.js +0 -12
  26. package/lib/codex-sdk/eslint.config.js +0 -21
  27. package/lib/codex-sdk/jest.config.cjs +0 -31
  28. package/lib/codex-sdk/package.json +0 -65
  29. package/lib/codex-sdk/samples/basic_streaming.ts +0 -90
  30. package/lib/codex-sdk/samples/helpers.ts +0 -8
  31. package/lib/codex-sdk/samples/structured_output.ts +0 -22
  32. package/lib/codex-sdk/samples/structured_output_zod.ts +0 -19
@@ -1,426 +0,0 @@
1
- // src/outputSchemaFile.ts
2
- import { promises as fs } from "fs";
3
- import os from "os";
4
- import path from "path";
5
- async function createOutputSchemaFile(schema) {
6
- if (schema === void 0) {
7
- return { cleanup: async () => {
8
- } };
9
- }
10
- if (!isJsonObject(schema)) {
11
- throw new Error("outputSchema must be a plain JSON object");
12
- }
13
- const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), "codex-output-schema-"));
14
- const schemaPath = path.join(schemaDir, "schema.json");
15
- const cleanup = async () => {
16
- try {
17
- await fs.rm(schemaDir, { recursive: true, force: true });
18
- } catch {
19
- }
20
- };
21
- try {
22
- await fs.writeFile(schemaPath, JSON.stringify(schema), "utf8");
23
- return { schemaPath, cleanup };
24
- } catch (error) {
25
- await cleanup();
26
- throw error;
27
- }
28
- }
29
- function isJsonObject(value) {
30
- return typeof value === "object" && value !== null && !Array.isArray(value);
31
- }
32
-
33
- // src/thread.ts
34
- var Thread = class {
35
- _exec;
36
- _options;
37
- _id;
38
- _threadOptions;
39
- /** Returns the ID of the thread. Populated after the first turn starts. */
40
- get id() {
41
- return this._id;
42
- }
43
- /* @internal */
44
- constructor(exec, options, threadOptions, id = null) {
45
- this._exec = exec;
46
- this._options = options;
47
- this._id = id;
48
- this._threadOptions = threadOptions;
49
- }
50
- /** Provides the input to the agent and streams events as they are produced during the turn. */
51
- async runStreamed(input, turnOptions = {}) {
52
- return { events: this.runStreamedInternal(input, turnOptions) };
53
- }
54
- async *runStreamedInternal(input, turnOptions = {}) {
55
- const { schemaPath, cleanup } = await createOutputSchemaFile(turnOptions.outputSchema);
56
- const options = this._threadOptions;
57
- const { prompt, images } = normalizeInput(input);
58
- const generator = this._exec.run({
59
- input: prompt,
60
- baseUrl: this._options.baseUrl,
61
- apiKey: this._options.apiKey,
62
- threadId: this._id,
63
- images,
64
- model: options?.model,
65
- sandboxMode: options?.sandboxMode,
66
- workingDirectory: options?.workingDirectory,
67
- skipGitRepoCheck: options?.skipGitRepoCheck,
68
- outputSchemaFile: schemaPath,
69
- modelReasoningEffort: options?.modelReasoningEffort,
70
- signal: turnOptions.signal,
71
- networkAccessEnabled: options?.networkAccessEnabled,
72
- webSearchEnabled: options?.webSearchEnabled,
73
- approvalPolicy: options?.approvalPolicy,
74
- additionalDirectories: options?.additionalDirectories,
75
- configOverrides: options?.configOverrides
76
- });
77
- try {
78
- for await (const item of generator) {
79
- let parsed;
80
- try {
81
- parsed = JSON.parse(item);
82
- } catch (error) {
83
- throw new Error(`Failed to parse item: ${item}`, { cause: error });
84
- }
85
- if (parsed.type === "thread.started") {
86
- this._id = parsed.thread_id;
87
- }
88
- yield parsed;
89
- }
90
- } finally {
91
- await cleanup();
92
- }
93
- }
94
- /** Provides the input to the agent and returns the completed turn. */
95
- async run(input, turnOptions = {}) {
96
- const generator = this.runStreamedInternal(input, turnOptions);
97
- const items = [];
98
- let finalResponse = "";
99
- let usage = null;
100
- let turnFailure = null;
101
- for await (const event of generator) {
102
- if (event.type === "item.completed") {
103
- if (event.item.type === "agent_message") {
104
- finalResponse = event.item.text;
105
- }
106
- items.push(event.item);
107
- } else if (event.type === "turn.completed") {
108
- usage = event.usage;
109
- } else if (event.type === "turn.failed") {
110
- turnFailure = event.error;
111
- break;
112
- }
113
- }
114
- if (turnFailure) {
115
- throw new Error(turnFailure.message);
116
- }
117
- return { items, finalResponse, usage };
118
- }
119
- };
120
- function normalizeInput(input) {
121
- if (typeof input === "string") {
122
- return { prompt: input, images: [] };
123
- }
124
- const promptParts = [];
125
- const images = [];
126
- for (const item of input) {
127
- if (item.type === "text") {
128
- promptParts.push(item.text);
129
- } else if (item.type === "local_image") {
130
- images.push(item.path);
131
- }
132
- }
133
- return { prompt: promptParts.join("\n\n"), images };
134
- }
135
-
136
- // src/exec.ts
137
- import { spawn } from "child_process";
138
- import { existsSync } from "fs";
139
- import path2 from "path";
140
- import readline from "readline";
141
- import { fileURLToPath } from "url";
142
- import { createRequire } from "module";
143
- var INTERNAL_ORIGINATOR_ENV = "CODEX_INTERNAL_ORIGINATOR_OVERRIDE";
144
- var TYPESCRIPT_SDK_ORIGINATOR = "codex_sdk_ts";
145
- var isDebugEnabled = process.env["DEBUG"] === "true";
146
- var CodexExec = class {
147
- executablePath;
148
- envOverride;
149
- constructor(executablePath = null, env) {
150
- this.executablePath = executablePath || findCodexPath();
151
- this.envOverride = env;
152
- }
153
- async *run(args) {
154
- const commandArgs = ["exec", "--experimental-json"];
155
- if (args.model) {
156
- commandArgs.push("--model", args.model);
157
- }
158
- if (args.sandboxMode) {
159
- commandArgs.push("--sandbox", args.sandboxMode);
160
- }
161
- if (args.workingDirectory) {
162
- commandArgs.push("--cd", args.workingDirectory);
163
- }
164
- if (args.additionalDirectories?.length) {
165
- for (const dir of args.additionalDirectories) {
166
- commandArgs.push("--add-dir", dir);
167
- }
168
- }
169
- if (args.skipGitRepoCheck) {
170
- commandArgs.push("--skip-git-repo-check");
171
- }
172
- if (args.outputSchemaFile) {
173
- commandArgs.push("--output-schema", args.outputSchemaFile);
174
- }
175
- if (args.modelReasoningEffort) {
176
- commandArgs.push("--config", `model_reasoning_effort="${args.modelReasoningEffort}"`);
177
- }
178
- if (args.networkAccessEnabled !== void 0) {
179
- commandArgs.push(
180
- "--config",
181
- `sandbox_workspace_write.network_access=${args.networkAccessEnabled}`
182
- );
183
- }
184
- if (args.webSearchEnabled !== void 0) {
185
- commandArgs.push("--config", `features.web_search_request=${args.webSearchEnabled}`);
186
- }
187
- if (args.approvalPolicy) {
188
- commandArgs.push("--config", `approval_policy="${args.approvalPolicy}"`);
189
- }
190
- if (args.configOverrides) {
191
- for (const [key, value] of Object.entries(args.configOverrides)) {
192
- const formatted = formatConfigValue(value);
193
- commandArgs.push("--config", `${key}=${formatted}`);
194
- }
195
- }
196
- if (args.images?.length) {
197
- for (const image of args.images) {
198
- commandArgs.push("--image", image);
199
- }
200
- }
201
- if (args.threadId) {
202
- commandArgs.push("resume", args.threadId);
203
- }
204
- if (isDebugEnabled) {
205
- console.log("[CodexExec] Executable path:", this.executablePath);
206
- console.log("[CodexExec] Command arguments:", commandArgs);
207
- }
208
- const env = {};
209
- if (this.envOverride) {
210
- Object.assign(env, this.envOverride);
211
- } else {
212
- for (const [key, value] of Object.entries(process.env)) {
213
- if (value !== void 0) {
214
- env[key] = value;
215
- }
216
- }
217
- }
218
- if (!env[INTERNAL_ORIGINATOR_ENV]) {
219
- env[INTERNAL_ORIGINATOR_ENV] = TYPESCRIPT_SDK_ORIGINATOR;
220
- }
221
- if (args.baseUrl) {
222
- env.OPENAI_BASE_URL = args.baseUrl;
223
- }
224
- if (args.apiKey) {
225
- env.CODEX_API_KEY = args.apiKey;
226
- }
227
- const child = spawn(this.executablePath, commandArgs, {
228
- env,
229
- signal: args.signal
230
- });
231
- let spawnError = null;
232
- child.once("error", (err) => spawnError = err);
233
- if (!child.stdin) {
234
- child.kill();
235
- throw new Error("Child process has no stdin");
236
- }
237
- child.stdin.write(args.input);
238
- child.stdin.end();
239
- if (!child.stdout) {
240
- child.kill();
241
- throw new Error("Child process has no stdout");
242
- }
243
- const stderrChunks = [];
244
- if (child.stderr) {
245
- child.stderr.on("data", (data) => {
246
- stderrChunks.push(data);
247
- });
248
- }
249
- const rl = readline.createInterface({
250
- input: child.stdout,
251
- crlfDelay: Infinity
252
- });
253
- try {
254
- for await (const line of rl) {
255
- yield line;
256
- }
257
- const exitCode = new Promise((resolve, reject) => {
258
- child.once("exit", (code) => {
259
- if (code === 0) {
260
- resolve(code);
261
- } else {
262
- const stderrBuffer = Buffer.concat(stderrChunks);
263
- reject(
264
- new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString("utf8")}`)
265
- );
266
- }
267
- });
268
- });
269
- if (spawnError) throw spawnError;
270
- await exitCode;
271
- } finally {
272
- rl.close();
273
- child.removeAllListeners();
274
- try {
275
- if (!child.killed) child.kill();
276
- } catch {
277
- }
278
- }
279
- }
280
- };
281
- var scriptFileName = fileURLToPath(import.meta.url);
282
- var scriptDirName = path2.dirname(scriptFileName);
283
- var require2 = createRequire(import.meta.url);
284
- function findCodexPath() {
285
- const { platform, arch } = process;
286
- let targetTriple = null;
287
- switch (platform) {
288
- case "linux":
289
- case "android":
290
- switch (arch) {
291
- case "x64":
292
- targetTriple = "x86_64-unknown-linux-musl";
293
- break;
294
- case "arm64":
295
- targetTriple = "aarch64-unknown-linux-musl";
296
- break;
297
- default:
298
- break;
299
- }
300
- break;
301
- case "darwin":
302
- switch (arch) {
303
- case "x64":
304
- targetTriple = "x86_64-apple-darwin";
305
- break;
306
- case "arm64":
307
- targetTriple = "aarch64-apple-darwin";
308
- break;
309
- default:
310
- break;
311
- }
312
- break;
313
- case "win32":
314
- switch (arch) {
315
- case "x64":
316
- targetTriple = "x86_64-pc-windows-msvc";
317
- break;
318
- case "arm64":
319
- targetTriple = "aarch64-pc-windows-msvc";
320
- break;
321
- default:
322
- break;
323
- }
324
- break;
325
- default:
326
- break;
327
- }
328
- if (!targetTriple) {
329
- throw new Error(`Unsupported platform: ${platform} (${arch})`);
330
- }
331
- const vendorResolution = resolveUpstreamVendorRoot();
332
- let vendorRoot;
333
- if (vendorResolution.path) {
334
- vendorRoot = vendorResolution.path;
335
- } else {
336
- vendorRoot = path2.join(scriptDirName, "..", "vendor");
337
- const reason = vendorResolution.reason ? `: ${vendorResolution.reason}` : "";
338
- console.warn(
339
- `[Codex SDK] Failed to resolve upstream vendor package${reason}, falling back to local vendor directory`
340
- );
341
- }
342
- const archRoot = path2.join(vendorRoot, targetTriple);
343
- const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
344
- const binaryPath = path2.join(archRoot, "codex", codexBinaryName);
345
- return binaryPath;
346
- }
347
- function resolveUpstreamVendorRoot() {
348
- let searchPaths = null;
349
- try {
350
- searchPaths = require2.resolve.paths("@openai/codex-sdk");
351
- } catch (error) {
352
- return { path: null, reason: error?.message || String(error) };
353
- }
354
- if (!searchPaths?.length) {
355
- return { path: null, reason: "no module search paths returned" };
356
- }
357
- let locatedPackageRoot = null;
358
- for (const basePath of searchPaths) {
359
- if (!basePath) continue;
360
- const packageRoot = path2.join(basePath, "@openai/codex-sdk");
361
- const packageJsonPath = path2.join(packageRoot, "package.json");
362
- if (!existsSync(packageJsonPath)) {
363
- continue;
364
- }
365
- locatedPackageRoot = packageRoot;
366
- const vendorPath = path2.join(packageRoot, "vendor");
367
- if (existsSync(vendorPath)) {
368
- return { path: vendorPath };
369
- }
370
- }
371
- if (locatedPackageRoot) {
372
- return { path: null, reason: `vendor directory missing in ${locatedPackageRoot}` };
373
- }
374
- return {
375
- path: null,
376
- reason: `@openai/codex-sdk not found in node_modules search paths (${searchPaths.join(", ")})`
377
- };
378
- }
379
- function formatConfigValue(value) {
380
- if (typeof value === "string") {
381
- return JSON.stringify(value);
382
- }
383
- if (typeof value === "number" || typeof value === "boolean") {
384
- return String(value);
385
- }
386
- if (value === null || value === void 0) {
387
- return "null";
388
- }
389
- try {
390
- return JSON.stringify(value);
391
- } catch {
392
- return JSON.stringify(String(value));
393
- }
394
- }
395
-
396
- // src/codex.ts
397
- var Codex = class {
398
- exec;
399
- options;
400
- constructor(options = {}) {
401
- this.exec = new CodexExec(options.codexPathOverride, options.env);
402
- this.options = options;
403
- }
404
- /**
405
- * Starts a new conversation with an agent.
406
- * @returns A new thread instance.
407
- */
408
- startThread(options = {}) {
409
- return new Thread(this.exec, this.options, options);
410
- }
411
- /**
412
- * Resumes a conversation with an agent based on the thread id.
413
- * Threads are persisted in ~/.codex/sessions.
414
- *
415
- * @param id The id of the thread to resume.
416
- * @returns A new thread instance.
417
- */
418
- resumeThread(id, options = {}) {
419
- return new Thread(this.exec, this.options, options, id);
420
- }
421
- };
422
- export {
423
- Codex,
424
- Thread
425
- };
426
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
2
- export {};
3
- //# sourceMappingURL=basic_streaming.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic_streaming.d.ts","sourceRoot":"","sources":["../../samples/basic_streaming.ts"],"names":[],"mappings":""}
@@ -1,81 +0,0 @@
1
- #!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
2
- import { createInterface } from "node:readline/promises";
3
- import { stdin as input, stdout as output } from "node:process";
4
- import { Codex } from "@openai/codex-sdk";
5
- import { codexPathOverride } from "./helpers.ts";
6
- const codex = new Codex({ codexPathOverride: codexPathOverride() });
7
- const thread = codex.startThread();
8
- const rl = createInterface({ input, output });
9
- const handleItemCompleted = (item) => {
10
- switch (item.type) {
11
- case "agent_message":
12
- console.log(`Assistant: ${item.text}`);
13
- break;
14
- case "reasoning":
15
- console.log(`Reasoning: ${item.text}`);
16
- break;
17
- case "command_execution": {
18
- const exitText = item.exit_code !== undefined ? ` Exit code ${item.exit_code}.` : "";
19
- console.log(`Command ${item.command} ${item.status}.${exitText}`);
20
- break;
21
- }
22
- case "file_change": {
23
- for (const change of item.changes) {
24
- console.log(`File ${change.kind} ${change.path}`);
25
- }
26
- break;
27
- }
28
- }
29
- };
30
- const handleItemUpdated = (item) => {
31
- switch (item.type) {
32
- case "todo_list": {
33
- console.log(`Todo:`);
34
- for (const todo of item.items) {
35
- console.log(`\t ${todo.completed ? "x" : " "} ${todo.text}`);
36
- }
37
- break;
38
- }
39
- }
40
- };
41
- const handleEvent = (event) => {
42
- switch (event.type) {
43
- case "item.completed":
44
- handleItemCompleted(event.item);
45
- break;
46
- case "item.updated":
47
- case "item.started":
48
- handleItemUpdated(event.item);
49
- break;
50
- case "turn.completed":
51
- console.log(`Used ${event.usage.input_tokens} input tokens, ${event.usage.cached_input_tokens} cached input tokens, ${event.usage.output_tokens} output tokens.`);
52
- break;
53
- case "turn.failed":
54
- console.error(`Turn failed: ${event.error.message}`);
55
- break;
56
- }
57
- };
58
- const main = async () => {
59
- try {
60
- while (true) {
61
- const inputText = await rl.question(">");
62
- const trimmed = inputText.trim();
63
- if (trimmed.length === 0) {
64
- continue;
65
- }
66
- const { events } = await thread.runStreamed(inputText);
67
- for await (const event of events) {
68
- handleEvent(event);
69
- }
70
- }
71
- }
72
- finally {
73
- rl.close();
74
- }
75
- };
76
- main().catch((err) => {
77
- const message = err instanceof Error ? err.message : String(err);
78
- console.error(`Unexpected error: ${message}`);
79
- process.exit(1);
80
- });
81
- //# sourceMappingURL=basic_streaming.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic_streaming.js","sourceRoot":"","sources":["../../samples/basic_streaming.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACpE,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;AACnC,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9C,MAAM,mBAAmB,GAAG,CAAC,IAAgB,EAAQ,EAAE;IACrD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,eAAe;YAClB,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACvC,MAAM;QACR,KAAK,WAAW;YACd,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACvC,MAAM;QACR,KAA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OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function codexPathOverride(): string;
2
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../samples/helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,WAKhC"}
@@ -1,6 +0,0 @@
1
- import path from "node:path";
2
- export function codexPathOverride() {
3
- return (process.env.CODEX_EXECUTABLE ??
4
- path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex"));
5
- }
6
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../samples/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,iBAAiB;IAC/B,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,gBAAgB;QAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAC7E,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
2
- export {};
3
- //# sourceMappingURL=structured_output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structured_output.d.ts","sourceRoot":"","sources":["../../samples/structured_output.ts"],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
2
- import { Codex } from "@openai/codex-sdk";
3
- import { codexPathOverride } from "./helpers.ts";
4
- const codex = new Codex({ codexPathOverride: codexPathOverride() });
5
- const thread = codex.startThread();
6
- const schema = {
7
- type: "object",
8
- properties: {
9
- summary: { type: "string" },
10
- status: { type: "string", enum: ["ok", "action_required"] },
11
- },
12
- required: ["summary", "status"],
13
- additionalProperties: false,
14
- };
15
- const turn = await thread.run("Summarize repository status", { outputSchema: schema });
16
- console.log(turn.finalResponse);
17
- //# sourceMappingURL=structured_output.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structured_output.js","sourceRoot":"","sources":["../../samples/structured_output.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAEpE,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;AAEnC,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAAE;KAC5D;IACD,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC/B,oBAAoB,EAAE,KAAK;CACnB,CAAC;AAEX,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;AACvF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
2
- export {};
3
- //# sourceMappingURL=structured_output_zod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structured_output_zod.d.ts","sourceRoot":"","sources":["../../samples/structured_output_zod.ts"],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
2
- import { Codex } from "@openai/codex-sdk";
3
- import { codexPathOverride } from "./helpers.ts";
4
- import z from "zod";
5
- import zodToJsonSchema from "zod-to-json-schema";
6
- const codex = new Codex({ codexPathOverride: codexPathOverride() });
7
- const thread = codex.startThread();
8
- const schema = z.object({
9
- summary: z.string(),
10
- status: z.enum(["ok", "action_required"]),
11
- });
12
- const turn = await thread.run("Summarize repository status", {
13
- outputSchema: zodToJsonSchema(schema, { target: "openAi" }),
14
- });
15
- console.log(turn.finalResponse);
16
- //# sourceMappingURL=structured_output_zod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structured_output_zod.js","sourceRoot":"","sources":["../../samples/structured_output_zod.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACpE,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;AAEnC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,6BAA6B,EAAE;IAC3D,YAAY,EAAE,eAAe,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;CAC5D,CAAC,CAAC;AACH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
2
- export default _default;
3
- //# sourceMappingURL=tsup.config.d.ts.map
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "tsup";
2
- export default defineConfig({
3
- entry: ["src/index.ts"],
4
- format: ["esm"],
5
- dts: true,
6
- sourcemap: true,
7
- clean: true,
8
- minify: false,
9
- target: "node18",
10
- shims: false,
11
- });
12
- //# sourceMappingURL=tsup.config.js.map
@@ -1,21 +0,0 @@
1
- import eslint from "@eslint/js";
2
- import { defineConfig } from "eslint/config";
3
- import tseslint from "typescript-eslint";
4
- import nodeImport from "eslint-plugin-node-import";
5
-
6
- export default defineConfig(eslint.configs.recommended, tseslint.configs.recommended, {
7
- plugins: {
8
- "node-import": nodeImport,
9
- },
10
-
11
- rules: {
12
- "node-import/prefer-node-protocol": 2,
13
- "@typescript-eslint/no-unused-vars": [
14
- "error",
15
- {
16
- argsIgnorePattern: "^_",
17
- varsIgnorePattern: "^_",
18
- },
19
- ],
20
- },
21
- });
@@ -1,31 +0,0 @@
1
- /** @type {import('jest').Config} */
2
- module.exports = {
3
- preset: "ts-jest/presets/default-esm",
4
- testEnvironment: "node",
5
- extensionsToTreatAsEsm: [".ts"],
6
- moduleNameMapper: {
7
- "^(\\.{1,2}/.*)\\.js$": "$1",
8
- },
9
- testMatch: ["**/tests/**/*.test.ts"],
10
- transform: {
11
- "^.+\\.tsx?$": [
12
- "ts-jest",
13
- {
14
- useESM: true,
15
- tsconfig: "tsconfig.json",
16
- diagnostics: {
17
- ignoreCodes: [1343],
18
- },
19
- astTransformers: {
20
- before: [
21
- {
22
- path: "ts-jest-mock-import-meta",
23
- // Workaround for meta.url not working in jest
24
- options: { metaObjectReplacement: { url: "file://" + __dirname + "/dist/index.js" } },
25
- },
26
- ],
27
- },
28
- },
29
- ],
30
- },
31
- };