@northflare/runner 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/claude-sdk-manager.d.ts +1 -1
- package/dist/components/claude-sdk-manager.d.ts.map +1 -1
- package/dist/components/claude-sdk-manager.js +25 -12
- package/dist/components/claude-sdk-manager.js.map +1 -1
- package/dist/components/codex-sdk-manager.d.ts +58 -0
- package/dist/components/codex-sdk-manager.d.ts.map +1 -0
- package/dist/components/codex-sdk-manager.js +907 -0
- package/dist/components/codex-sdk-manager.js.map +1 -0
- package/dist/components/message-handler-sse.d.ts +3 -0
- package/dist/components/message-handler-sse.d.ts.map +1 -1
- package/dist/components/message-handler-sse.js +51 -7
- package/dist/components/message-handler-sse.js.map +1 -1
- package/dist/runner-sse.d.ts +4 -0
- package/dist/runner-sse.d.ts.map +1 -1
- package/dist/runner-sse.js +145 -15
- package/dist/runner-sse.js.map +1 -1
- package/dist/types/claude.d.ts +11 -1
- package/dist/types/claude.d.ts.map +1 -1
- package/dist/types/runner-interface.d.ts +2 -0
- package/dist/types/runner-interface.d.ts.map +1 -1
- package/dist/utils/model.d.ts +6 -0
- package/dist/utils/model.d.ts.map +1 -0
- package/dist/utils/model.js +23 -0
- package/dist/utils/model.js.map +1 -0
- package/dist/utils/status-line.d.ts +2 -2
- package/dist/utils/status-line.js +5 -5
- package/dist/utils/status-line.js.map +1 -1
- package/lib/codex-sdk/.prettierignore +3 -0
- package/lib/codex-sdk/.prettierrc +5 -0
- package/lib/codex-sdk/README.md +133 -0
- package/lib/codex-sdk/dist/index.d.ts +260 -0
- package/lib/codex-sdk/dist/index.js +426 -0
- package/lib/codex-sdk/eslint.config.js +21 -0
- package/lib/codex-sdk/jest.config.cjs +31 -0
- package/lib/codex-sdk/package.json +65 -0
- package/lib/codex-sdk/samples/basic_streaming.ts +90 -0
- package/lib/codex-sdk/samples/helpers.ts +8 -0
- package/lib/codex-sdk/samples/structured_output.ts +22 -0
- package/lib/codex-sdk/samples/structured_output_zod.ts +19 -0
- package/lib/codex-sdk/src/codex.ts +38 -0
- package/lib/codex-sdk/src/codexOptions.ts +10 -0
- package/lib/codex-sdk/src/events.ts +80 -0
- package/lib/codex-sdk/src/exec.ts +336 -0
- package/lib/codex-sdk/src/index.ts +39 -0
- package/lib/codex-sdk/src/items.ts +127 -0
- package/lib/codex-sdk/src/outputSchemaFile.ts +40 -0
- package/lib/codex-sdk/src/thread.ts +155 -0
- package/lib/codex-sdk/src/threadOptions.ts +18 -0
- package/lib/codex-sdk/src/turnOptions.ts +6 -0
- package/lib/codex-sdk/tests/abort.test.ts +165 -0
- package/lib/codex-sdk/tests/codexExecSpy.ts +37 -0
- package/lib/codex-sdk/tests/responsesProxy.ts +225 -0
- package/lib/codex-sdk/tests/run.test.ts +687 -0
- package/lib/codex-sdk/tests/runStreamed.test.ts +211 -0
- package/lib/codex-sdk/tsconfig.json +24 -0
- package/lib/codex-sdk/tsup.config.ts +12 -0
- package/package.json +3 -1
- package/rejections.log +2 -0
- package/src/components/claude-sdk-manager.ts +33 -13
- package/src/components/codex-sdk-manager.ts +1248 -0
- package/src/components/message-handler-sse.ts +79 -8
- package/src/runner-sse.ts +174 -15
- package/src/types/claude.ts +12 -1
- package/src/types/runner-interface.ts +3 -1
- package/src/utils/model.ts +29 -0
- package/src/utils/status-line.ts +6 -6
- package/src/utils/codex-sdk.js +0 -448
- package/src/utils/sdk-demo.js +0 -34
package/src/utils/codex-sdk.js
DELETED
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
/* Example usage:
|
|
2
|
-
query({
|
|
3
|
-
prompt: "Hello, how are you?",
|
|
4
|
-
options: {
|
|
5
|
-
pathToCodexExecutable: "./codex",
|
|
6
|
-
cwd: "/Users/joe/Documents/myproject/",
|
|
7
|
-
resume: "0199a99f-28aa-7872-96f6-24ce1e3a05fc", // Optional, resume from a previous session
|
|
8
|
-
configOverrides: {
|
|
9
|
-
model: "gpt-5-codex",
|
|
10
|
-
model_reasoning_effort: "high",
|
|
11
|
-
sandbox_mode: "danger-full-access",
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
Output:
|
|
17
|
-
sandbox_mode: "danger-full-access",
|
|
18
|
-
}
|
|
19
|
-
}})
|
|
20
|
-
|
|
21
|
-
Output:
|
|
22
|
-
|
|
23
|
-
[
|
|
24
|
-
{
|
|
25
|
-
id: '',
|
|
26
|
-
msg: {
|
|
27
|
-
type: 'session_configured',
|
|
28
|
-
session_id: '0199a9ce-1f38-7332-b46b-9711279899f1',
|
|
29
|
-
model: 'gpt-5-codex',
|
|
30
|
-
reasoning_effort: 'high',
|
|
31
|
-
history_log_id: 1399031533,
|
|
32
|
-
history_entry_count: 475,
|
|
33
|
-
rollout_path: '/Users/toby/.codex/sessions/2025/10/03/rollout-2025-10-03T13-21-21-0199a9ce-1f38-7332-b46b-9711279899f1.jsonl'
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: 'submission-1',
|
|
38
|
-
msg: { type: 'task_started', model_context_window: 272000 }
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: 'submission-1',
|
|
42
|
-
msg: { type: 'token_count', info: null, rate_limits: [Object] }
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'submission-1',
|
|
46
|
-
msg: { type: 'agent_reasoning_section_break' }
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: 'submission-1',
|
|
50
|
-
msg: { type: 'agent_reasoning_delta', delta: '**Preparing' }
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: 'submission-1',
|
|
54
|
-
msg: { type: 'agent_reasoning_delta', delta: ' a' }
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 'submission-1',
|
|
58
|
-
msg: { type: 'agent_reasoning_delta', delta: ' friendly' }
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: 'submission-1',
|
|
62
|
-
msg: { type: 'agent_reasoning_delta', delta: ' response' }
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: 'submission-1',
|
|
66
|
-
msg: { type: 'agent_reasoning_delta', delta: '**' }
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: 'submission-1',
|
|
70
|
-
msg: {
|
|
71
|
-
type: 'agent_reasoning',
|
|
72
|
-
text: '**Preparing a friendly response**'
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: 'submission-1',
|
|
77
|
-
msg: { type: 'agent_message_delta', delta: 'Hey' }
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: 'submission-1',
|
|
81
|
-
msg: { type: 'agent_message_delta', delta: ' there' }
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: 'submission-1',
|
|
85
|
-
msg: { type: 'agent_message_delta', delta: '!' }
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
id: 'submission-1',
|
|
89
|
-
msg: { type: 'agent_message_delta', delta: ' How' }
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: 'submission-1',
|
|
93
|
-
msg: { type: 'agent_message_delta', delta: ' can' }
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: 'submission-1',
|
|
97
|
-
msg: { type: 'agent_message_delta', delta: ' I' }
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: 'submission-1',
|
|
101
|
-
msg: { type: 'agent_message_delta', delta: ' help' }
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 'submission-1',
|
|
105
|
-
msg: { type: 'agent_message_delta', delta: ' today' }
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
id: 'submission-1',
|
|
109
|
-
msg: { type: 'agent_message_delta', delta: '?' }
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
id: 'submission-1',
|
|
113
|
-
msg: {
|
|
114
|
-
type: 'agent_message',
|
|
115
|
-
message: 'Hey there! How can I help today?'
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
id: 'submission-1',
|
|
120
|
-
msg: { type: 'token_count', info: [Object], rate_limits: [Object] }
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: 'submission-1',
|
|
124
|
-
msg: {
|
|
125
|
-
type: 'task_complete',
|
|
126
|
-
last_agent_message: 'Hey there! How can I help today?'
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
import { spawn } from "node:child_process";
|
|
133
|
-
import { createInterface } from "node:readline";
|
|
134
|
-
|
|
135
|
-
class ProcessTransport {
|
|
136
|
-
constructor(options = {}) {
|
|
137
|
-
const { command = "codex", args = [], cwd, env, onStderr } = options;
|
|
138
|
-
|
|
139
|
-
this.child = spawn(command, args, {
|
|
140
|
-
cwd,
|
|
141
|
-
env: { ...process.env, ...env },
|
|
142
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
if (!this.child.stdin || !this.child.stdout) {
|
|
146
|
-
throw new Error("Codex CLI requires piped stdin/stdout.");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (this.child.stderr) {
|
|
150
|
-
const stderrHandler = (data) => {
|
|
151
|
-
if (onStderr) {
|
|
152
|
-
onStderr(data.toString());
|
|
153
|
-
} else {
|
|
154
|
-
process.stderr.write(data);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
this.child.stderr.on("data", stderrHandler);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
this.stdin = this.child.stdin;
|
|
161
|
-
this.stdout = this.child.stdout;
|
|
162
|
-
this.closed = false;
|
|
163
|
-
|
|
164
|
-
this.exitPromise = new Promise((resolve, reject) => {
|
|
165
|
-
this.child.once("exit", (code, signal) => {
|
|
166
|
-
if (code === 0 || signal === "SIGTERM" || signal === null) {
|
|
167
|
-
resolve({ code, signal });
|
|
168
|
-
} else {
|
|
169
|
-
const exitReason = signal ? `signal ${signal}` : `exit code ${code}`;
|
|
170
|
-
const error = new Error(
|
|
171
|
-
`codex process terminated with ${exitReason}`
|
|
172
|
-
);
|
|
173
|
-
error.code = code;
|
|
174
|
-
error.signal = signal;
|
|
175
|
-
reject(error);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
this.child.once("error", (error) => {
|
|
179
|
-
reject(error);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async *readMessages() {
|
|
185
|
-
const rl = createInterface({ input: this.stdout });
|
|
186
|
-
try {
|
|
187
|
-
for await (const line of rl) {
|
|
188
|
-
const trimmed = line.trim();
|
|
189
|
-
if (!trimmed) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
let parsed;
|
|
193
|
-
try {
|
|
194
|
-
parsed = JSON.parse(trimmed);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
const parseError = new Error(
|
|
197
|
-
`Failed to parse Codex JSON output: ${error.message}\n${trimmed}`
|
|
198
|
-
);
|
|
199
|
-
parseError.cause = error;
|
|
200
|
-
throw parseError;
|
|
201
|
-
}
|
|
202
|
-
yield parsed;
|
|
203
|
-
}
|
|
204
|
-
await this.exitPromise;
|
|
205
|
-
} finally {
|
|
206
|
-
rl.close();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async write(payload) {
|
|
211
|
-
if (this.closed) {
|
|
212
|
-
throw new Error("Cannot write to closed Codex transport.");
|
|
213
|
-
}
|
|
214
|
-
if (!this.stdin || this.stdin.destroyed) {
|
|
215
|
-
throw new Error("Codex stdin is not available.");
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const serialized =
|
|
219
|
-
typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
220
|
-
const message = serialized.endsWith("\n") ? serialized : `${serialized}\n`;
|
|
221
|
-
const stream = this.stdin;
|
|
222
|
-
|
|
223
|
-
await new Promise((resolve, reject) => {
|
|
224
|
-
let settled = false;
|
|
225
|
-
const finish = () => {
|
|
226
|
-
if (settled) return;
|
|
227
|
-
settled = true;
|
|
228
|
-
stream.off("error", handleError);
|
|
229
|
-
resolve();
|
|
230
|
-
};
|
|
231
|
-
const handleError = (error) => {
|
|
232
|
-
if (settled) return;
|
|
233
|
-
settled = true;
|
|
234
|
-
stream.off("drain", finish);
|
|
235
|
-
stream.off("error", handleError);
|
|
236
|
-
reject(error);
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
stream.once("error", handleError);
|
|
240
|
-
const ok = stream.write(message, finish);
|
|
241
|
-
if (!ok) {
|
|
242
|
-
stream.once("drain", finish);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
async close() {
|
|
248
|
-
if (this.closed) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
this.closed = true;
|
|
252
|
-
|
|
253
|
-
if (this.stdin && !this.stdin.destroyed) {
|
|
254
|
-
this.stdin.end();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (this.child && !this.child.killed) {
|
|
258
|
-
this.child.kill("SIGTERM");
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
try {
|
|
262
|
-
await this.exitPromise;
|
|
263
|
-
} catch {
|
|
264
|
-
// Swallow shutdown errors when closing intentionally.
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interruptProcess() {
|
|
269
|
-
if (this.child && !this.child.killed) {
|
|
270
|
-
this.child.kill("SIGINT");
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
class Query {
|
|
276
|
-
constructor(transport) {
|
|
277
|
-
this.transport = transport;
|
|
278
|
-
this._nextSubmissionId = 0;
|
|
279
|
-
this._sessionId = null;
|
|
280
|
-
this._writeError = null;
|
|
281
|
-
this._finished = false;
|
|
282
|
-
this._messageIterator = this._iterateMessages();
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
_generateSubmissionId() {
|
|
286
|
-
this._nextSubmissionId += 1;
|
|
287
|
-
return `submission-${this._nextSubmissionId}`;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
_registerWrite(promise) {
|
|
291
|
-
promise.catch((error) => {
|
|
292
|
-
if (!this._writeError) {
|
|
293
|
-
this._writeError = error;
|
|
294
|
-
void this.transport.close();
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
async *_iterateMessages() {
|
|
300
|
-
try {
|
|
301
|
-
for await (const message of this.transport.readMessages()) {
|
|
302
|
-
if (this._writeError) {
|
|
303
|
-
throw this._writeError;
|
|
304
|
-
}
|
|
305
|
-
const msgType = message?.msg?.type;
|
|
306
|
-
if (!this._sessionId && msgType === "session_configured") {
|
|
307
|
-
this._sessionId = message.msg.session_id ?? null;
|
|
308
|
-
}
|
|
309
|
-
yield message;
|
|
310
|
-
}
|
|
311
|
-
if (this._writeError) {
|
|
312
|
-
throw this._writeError;
|
|
313
|
-
}
|
|
314
|
-
} finally {
|
|
315
|
-
this._finished = true;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
[Symbol.asyncIterator]() {
|
|
320
|
-
return this._messageIterator;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
next() {
|
|
324
|
-
if (this._writeError) {
|
|
325
|
-
return Promise.reject(this._writeError);
|
|
326
|
-
}
|
|
327
|
-
return this._messageIterator.next();
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
get sessionId() {
|
|
331
|
-
return this._sessionId;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async submit(op, id) {
|
|
335
|
-
if (!op || typeof op !== "object") {
|
|
336
|
-
throw new Error("submit expects a Codex op object.");
|
|
337
|
-
}
|
|
338
|
-
const submissionId = id ?? this._generateSubmissionId();
|
|
339
|
-
const submission = { id: submissionId, op };
|
|
340
|
-
await this.transport.write(submission);
|
|
341
|
-
return submissionId;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
async submitRaw(submission) {
|
|
345
|
-
if (!submission || typeof submission !== "object") {
|
|
346
|
-
throw new Error("submitRaw expects a submission object.");
|
|
347
|
-
}
|
|
348
|
-
if (!submission.id || !submission.op) {
|
|
349
|
-
throw new Error("Submission must include `id` and `op` fields.");
|
|
350
|
-
}
|
|
351
|
-
await this.transport.write(submission);
|
|
352
|
-
return submission.id;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
async submitUserMessage(text, { items, id } = {}) {
|
|
356
|
-
const messageItems = Array.isArray(items) ? [...items] : [];
|
|
357
|
-
if (typeof text === "string" && text.length > 0) {
|
|
358
|
-
messageItems.push({ type: "text", text });
|
|
359
|
-
}
|
|
360
|
-
if (messageItems.length === 0) {
|
|
361
|
-
throw new Error("submitUserMessage requires text or items.");
|
|
362
|
-
}
|
|
363
|
-
return this.submit({ type: "user_input", items: messageItems }, id);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
async interrupt(id) {
|
|
367
|
-
return this.submit({ type: "interrupt" }, id);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
async shutdown(id) {
|
|
371
|
-
return this.submit({ type: "shutdown" }, id);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
async close() {
|
|
375
|
-
await this.transport.close();
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
kill() {
|
|
379
|
-
this.transport.interruptProcess();
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function normalizeConfigOverrides(overrides) {
|
|
384
|
-
if (!overrides) {
|
|
385
|
-
return [];
|
|
386
|
-
}
|
|
387
|
-
if (Array.isArray(overrides)) {
|
|
388
|
-
return overrides;
|
|
389
|
-
}
|
|
390
|
-
if (typeof overrides === "object") {
|
|
391
|
-
return Object.entries(overrides).map(([key, value]) =>
|
|
392
|
-
value === undefined || value === null ? key : `${key}=${value}`
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
throw new Error("configOverrides must be an array or object.");
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
function buildSpawnConfig(options = {}) {
|
|
399
|
-
const {
|
|
400
|
-
pathToCodexExecutable,
|
|
401
|
-
resume,
|
|
402
|
-
configOverrides,
|
|
403
|
-
extraArgs,
|
|
404
|
-
cwd,
|
|
405
|
-
env,
|
|
406
|
-
stderr,
|
|
407
|
-
} = options;
|
|
408
|
-
|
|
409
|
-
const command = pathToCodexExecutable ?? "codex";
|
|
410
|
-
const args = ["proto"];
|
|
411
|
-
|
|
412
|
-
const overrides = normalizeConfigOverrides(configOverrides);
|
|
413
|
-
for (const override of overrides) {
|
|
414
|
-
args.push("-c", override);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if (resume) {
|
|
418
|
-
args.push("--resume", resume);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (Array.isArray(extraArgs)) {
|
|
422
|
-
args.push(...extraArgs);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
return {
|
|
426
|
-
command,
|
|
427
|
-
args,
|
|
428
|
-
cwd,
|
|
429
|
-
env,
|
|
430
|
-
onStderr: stderr,
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
export function query({ prompt, options = {} } = {}) {
|
|
435
|
-
const spawnConfig = buildSpawnConfig(options);
|
|
436
|
-
const transport = new ProcessTransport(spawnConfig);
|
|
437
|
-
const q = new Query(transport);
|
|
438
|
-
|
|
439
|
-
if (typeof prompt === "string" && prompt.trim().length > 0) {
|
|
440
|
-
q._registerWrite(q.submitUserMessage(prompt.trim()));
|
|
441
|
-
} else if (Array.isArray(prompt) && prompt.length > 0) {
|
|
442
|
-
q._registerWrite(q.submitUserMessage("", { items: prompt }));
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return q;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
export { Query };
|
package/src/utils/sdk-demo.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { query } from "./codex-sdk.js";
|
|
2
|
-
|
|
3
|
-
export default async function getAllOutput(prompt = "Hello!", options = {}) {
|
|
4
|
-
const defaultOptions = {
|
|
5
|
-
cwd: "/Users/toby/Code/hypervisual",
|
|
6
|
-
configOverrides: {
|
|
7
|
-
model: "gpt-5-codex",
|
|
8
|
-
model_reasoning_effort: "high",
|
|
9
|
-
sandbox_mode: "danger-full-access",
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const q = query({
|
|
14
|
-
prompt,
|
|
15
|
-
options: { ...defaultOptions, ...options },
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const messages = [];
|
|
19
|
-
for await (const message of q) {
|
|
20
|
-
messages.push(message);
|
|
21
|
-
console.log(message);
|
|
22
|
-
|
|
23
|
-
// Check if we've received a task completion
|
|
24
|
-
if (message.msg?.type === "task_complete") {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Send shutdown command and close
|
|
30
|
-
await q.shutdown();
|
|
31
|
-
await q.close();
|
|
32
|
-
|
|
33
|
-
return messages;
|
|
34
|
-
}
|