@northflare/runner 0.0.17 → 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.
- package/package.json +3 -3
- package/{lib/codex-sdk/tsup.config.ts → tsup.config.ts} +2 -2
- package/lib/codex-sdk/.prettierignore +0 -3
- package/lib/codex-sdk/.prettierrc +0 -5
- package/lib/codex-sdk/README.md +0 -133
- package/lib/codex-sdk/dist/index.d.ts +0 -260
- package/lib/codex-sdk/dist/index.js +0 -426
- package/lib/codex-sdk/dist/samples/basic_streaming.d.ts +0 -3
- package/lib/codex-sdk/dist/samples/basic_streaming.d.ts.map +0 -1
- package/lib/codex-sdk/dist/samples/basic_streaming.js +0 -81
- package/lib/codex-sdk/dist/samples/basic_streaming.js.map +0 -1
- package/lib/codex-sdk/dist/samples/helpers.d.ts +0 -2
- package/lib/codex-sdk/dist/samples/helpers.d.ts.map +0 -1
- package/lib/codex-sdk/dist/samples/helpers.js +0 -6
- package/lib/codex-sdk/dist/samples/helpers.js.map +0 -1
- package/lib/codex-sdk/dist/samples/structured_output.d.ts +0 -3
- package/lib/codex-sdk/dist/samples/structured_output.d.ts.map +0 -1
- package/lib/codex-sdk/dist/samples/structured_output.js +0 -17
- package/lib/codex-sdk/dist/samples/structured_output.js.map +0 -1
- package/lib/codex-sdk/dist/samples/structured_output_zod.d.ts +0 -3
- package/lib/codex-sdk/dist/samples/structured_output_zod.d.ts.map +0 -1
- package/lib/codex-sdk/dist/samples/structured_output_zod.js +0 -16
- package/lib/codex-sdk/dist/samples/structured_output_zod.js.map +0 -1
- package/lib/codex-sdk/dist/src/codex.d.ts +0 -27
- package/lib/codex-sdk/dist/src/codex.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/codex.js +0 -33
- package/lib/codex-sdk/dist/src/codex.js.map +0 -1
- package/lib/codex-sdk/dist/src/codexOptions.d.ts +0 -11
- package/lib/codex-sdk/dist/src/codexOptions.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/codexOptions.js +0 -2
- package/lib/codex-sdk/dist/src/codexOptions.js.map +0 -1
- package/lib/codex-sdk/dist/src/events.d.ts +0 -60
- package/lib/codex-sdk/dist/src/events.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/events.js +0 -3
- package/lib/codex-sdk/dist/src/events.js.map +0 -1
- package/lib/codex-sdk/dist/src/exec.d.ts +0 -27
- package/lib/codex-sdk/dist/src/exec.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/exec.js +0 -264
- package/lib/codex-sdk/dist/src/exec.js.map +0 -1
- package/lib/codex-sdk/dist/src/index.d.ts +0 -9
- package/lib/codex-sdk/dist/src/index.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/index.js +0 -3
- package/lib/codex-sdk/dist/src/index.js.map +0 -1
- package/lib/codex-sdk/dist/src/items.d.ts +0 -103
- package/lib/codex-sdk/dist/src/items.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/items.js +0 -3
- package/lib/codex-sdk/dist/src/items.js.map +0 -1
- package/lib/codex-sdk/dist/src/outputSchemaFile.d.ts +0 -6
- package/lib/codex-sdk/dist/src/outputSchemaFile.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/outputSchemaFile.js +0 -33
- package/lib/codex-sdk/dist/src/outputSchemaFile.js.map +0 -1
- package/lib/codex-sdk/dist/src/thread.d.ts +0 -41
- package/lib/codex-sdk/dist/src/thread.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/thread.js +0 -109
- package/lib/codex-sdk/dist/src/thread.js.map +0 -1
- package/lib/codex-sdk/dist/src/threadOptions.d.ts +0 -16
- package/lib/codex-sdk/dist/src/threadOptions.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/threadOptions.js +0 -2
- package/lib/codex-sdk/dist/src/threadOptions.js.map +0 -1
- package/lib/codex-sdk/dist/src/turnOptions.d.ts +0 -7
- package/lib/codex-sdk/dist/src/turnOptions.d.ts.map +0 -1
- package/lib/codex-sdk/dist/src/turnOptions.js +0 -2
- package/lib/codex-sdk/dist/src/turnOptions.js.map +0 -1
- package/lib/codex-sdk/dist/tests/abort.test.d.ts +0 -2
- package/lib/codex-sdk/dist/tests/abort.test.d.ts.map +0 -1
- package/lib/codex-sdk/dist/tests/abort.test.js +0 -130
- package/lib/codex-sdk/dist/tests/abort.test.js.map +0 -1
- package/lib/codex-sdk/dist/tests/codexExecSpy.d.ts +0 -6
- package/lib/codex-sdk/dist/tests/codexExecSpy.d.ts.map +0 -1
- package/lib/codex-sdk/dist/tests/codexExecSpy.js +0 -28
- package/lib/codex-sdk/dist/tests/codexExecSpy.js.map +0 -1
- package/lib/codex-sdk/dist/tests/responsesProxy.d.ts +0 -56
- package/lib/codex-sdk/dist/tests/responsesProxy.d.ts.map +0 -1
- package/lib/codex-sdk/dist/tests/responsesProxy.js +0 -155
- package/lib/codex-sdk/dist/tests/responsesProxy.js.map +0 -1
- package/lib/codex-sdk/dist/tests/run.test.d.ts +0 -2
- package/lib/codex-sdk/dist/tests/run.test.d.ts.map +0 -1
- package/lib/codex-sdk/dist/tests/run.test.js +0 -524
- package/lib/codex-sdk/dist/tests/run.test.js.map +0 -1
- package/lib/codex-sdk/dist/tests/runStreamed.test.d.ts +0 -2
- package/lib/codex-sdk/dist/tests/runStreamed.test.d.ts.map +0 -1
- package/lib/codex-sdk/dist/tests/runStreamed.test.js +0 -153
- package/lib/codex-sdk/dist/tests/runStreamed.test.js.map +0 -1
- package/lib/codex-sdk/dist/tsup.config.d.ts +0 -3
- package/lib/codex-sdk/dist/tsup.config.js +0 -12
- package/lib/codex-sdk/eslint.config.js +0 -21
- package/lib/codex-sdk/jest.config.cjs +0 -31
- package/lib/codex-sdk/package.json +0 -65
- package/lib/codex-sdk/samples/basic_streaming.ts +0 -90
- package/lib/codex-sdk/samples/helpers.ts +0 -8
- package/lib/codex-sdk/samples/structured_output.ts +0 -22
- package/lib/codex-sdk/samples/structured_output_zod.ts +0 -19
- package/lib/codex-sdk/src/codex.ts +0 -38
- package/lib/codex-sdk/src/codexOptions.ts +0 -10
- package/lib/codex-sdk/src/events.ts +0 -80
- package/lib/codex-sdk/src/exec.ts +0 -336
- package/lib/codex-sdk/src/index.ts +0 -39
- package/lib/codex-sdk/src/items.ts +0 -127
- package/lib/codex-sdk/src/outputSchemaFile.ts +0 -40
- package/lib/codex-sdk/src/thread.ts +0 -155
- package/lib/codex-sdk/src/threadOptions.ts +0 -18
- package/lib/codex-sdk/src/turnOptions.ts +0 -6
- package/lib/codex-sdk/tests/abort.test.ts +0 -165
- package/lib/codex-sdk/tests/codexExecSpy.ts +0 -37
- package/lib/codex-sdk/tests/responsesProxy.ts +0 -225
- package/lib/codex-sdk/tests/run.test.ts +0 -687
- package/lib/codex-sdk/tests/runStreamed.test.ts +0 -211
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { describe, expect, it } from "@jest/globals";
|
|
3
|
-
import { Codex } from "../src/codex";
|
|
4
|
-
import { assistantMessage, responseCompleted, responseStarted, sse, startResponsesTestProxy, } from "./responsesProxy";
|
|
5
|
-
const codexExecPath = path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
|
|
6
|
-
describe("Codex", () => {
|
|
7
|
-
it("returns thread events", async () => {
|
|
8
|
-
const { url, close } = await startResponsesTestProxy({
|
|
9
|
-
statusCode: 200,
|
|
10
|
-
responseBodies: [sse(responseStarted(), assistantMessage("Hi!"), responseCompleted())],
|
|
11
|
-
});
|
|
12
|
-
try {
|
|
13
|
-
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
|
|
14
|
-
const thread = client.startThread();
|
|
15
|
-
const result = await thread.runStreamed("Hello, world!");
|
|
16
|
-
const events = [];
|
|
17
|
-
for await (const event of result.events) {
|
|
18
|
-
events.push(event);
|
|
19
|
-
}
|
|
20
|
-
expect(events).toEqual([
|
|
21
|
-
{
|
|
22
|
-
type: "thread.started",
|
|
23
|
-
thread_id: expect.any(String),
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: "turn.started",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
type: "item.completed",
|
|
30
|
-
item: {
|
|
31
|
-
id: "item_0",
|
|
32
|
-
type: "agent_message",
|
|
33
|
-
text: "Hi!",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: "turn.completed",
|
|
38
|
-
usage: {
|
|
39
|
-
cached_input_tokens: 12,
|
|
40
|
-
input_tokens: 42,
|
|
41
|
-
output_tokens: 5,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
expect(thread.id).toEqual(expect.any(String));
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
await close();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
it("sends previous items when runStreamed is called twice", async () => {
|
|
52
|
-
const { url, close, requests } = await startResponsesTestProxy({
|
|
53
|
-
statusCode: 200,
|
|
54
|
-
responseBodies: [
|
|
55
|
-
sse(responseStarted("response_1"), assistantMessage("First response", "item_1"), responseCompleted("response_1")),
|
|
56
|
-
sse(responseStarted("response_2"), assistantMessage("Second response", "item_2"), responseCompleted("response_2")),
|
|
57
|
-
],
|
|
58
|
-
});
|
|
59
|
-
try {
|
|
60
|
-
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
|
|
61
|
-
const thread = client.startThread();
|
|
62
|
-
const first = await thread.runStreamed("first input");
|
|
63
|
-
await drainEvents(first.events);
|
|
64
|
-
const second = await thread.runStreamed("second input");
|
|
65
|
-
await drainEvents(second.events);
|
|
66
|
-
// Check second request continues the same thread
|
|
67
|
-
expect(requests.length).toBeGreaterThanOrEqual(2);
|
|
68
|
-
const secondRequest = requests[1];
|
|
69
|
-
expect(secondRequest).toBeDefined();
|
|
70
|
-
const payload = secondRequest.json;
|
|
71
|
-
const assistantEntry = payload.input.find((entry) => entry.role === "assistant");
|
|
72
|
-
expect(assistantEntry).toBeDefined();
|
|
73
|
-
const assistantText = assistantEntry?.content?.find((item) => item.type === "output_text")?.text;
|
|
74
|
-
expect(assistantText).toBe("First response");
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
await close();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
it("resumes thread by id when streaming", async () => {
|
|
81
|
-
const { url, close, requests } = await startResponsesTestProxy({
|
|
82
|
-
statusCode: 200,
|
|
83
|
-
responseBodies: [
|
|
84
|
-
sse(responseStarted("response_1"), assistantMessage("First response", "item_1"), responseCompleted("response_1")),
|
|
85
|
-
sse(responseStarted("response_2"), assistantMessage("Second response", "item_2"), responseCompleted("response_2")),
|
|
86
|
-
],
|
|
87
|
-
});
|
|
88
|
-
try {
|
|
89
|
-
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
|
|
90
|
-
const originalThread = client.startThread();
|
|
91
|
-
const first = await originalThread.runStreamed("first input");
|
|
92
|
-
await drainEvents(first.events);
|
|
93
|
-
const resumedThread = client.resumeThread(originalThread.id);
|
|
94
|
-
const second = await resumedThread.runStreamed("second input");
|
|
95
|
-
await drainEvents(second.events);
|
|
96
|
-
expect(resumedThread.id).toBe(originalThread.id);
|
|
97
|
-
expect(requests.length).toBeGreaterThanOrEqual(2);
|
|
98
|
-
const secondRequest = requests[1];
|
|
99
|
-
expect(secondRequest).toBeDefined();
|
|
100
|
-
const payload = secondRequest.json;
|
|
101
|
-
const assistantEntry = payload.input.find((entry) => entry.role === "assistant");
|
|
102
|
-
expect(assistantEntry).toBeDefined();
|
|
103
|
-
const assistantText = assistantEntry?.content?.find((item) => item.type === "output_text")?.text;
|
|
104
|
-
expect(assistantText).toBe("First response");
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
await close();
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
it("applies output schema turn options when streaming", async () => {
|
|
111
|
-
const { url, close, requests } = await startResponsesTestProxy({
|
|
112
|
-
statusCode: 200,
|
|
113
|
-
responseBodies: [
|
|
114
|
-
sse(responseStarted("response_1"), assistantMessage("Structured response", "item_1"), responseCompleted("response_1")),
|
|
115
|
-
],
|
|
116
|
-
});
|
|
117
|
-
const schema = {
|
|
118
|
-
type: "object",
|
|
119
|
-
properties: {
|
|
120
|
-
answer: { type: "string" },
|
|
121
|
-
},
|
|
122
|
-
required: ["answer"],
|
|
123
|
-
additionalProperties: false,
|
|
124
|
-
};
|
|
125
|
-
try {
|
|
126
|
-
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
|
|
127
|
-
const thread = client.startThread();
|
|
128
|
-
const streamed = await thread.runStreamed("structured", { outputSchema: schema });
|
|
129
|
-
await drainEvents(streamed.events);
|
|
130
|
-
expect(requests.length).toBeGreaterThanOrEqual(1);
|
|
131
|
-
const payload = requests[0];
|
|
132
|
-
expect(payload).toBeDefined();
|
|
133
|
-
const text = payload.json.text;
|
|
134
|
-
expect(text).toBeDefined();
|
|
135
|
-
expect(text?.format).toEqual({
|
|
136
|
-
name: "codex_output_schema",
|
|
137
|
-
type: "json_schema",
|
|
138
|
-
strict: true,
|
|
139
|
-
schema,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
await close();
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
async function drainEvents(events) {
|
|
148
|
-
let done = false;
|
|
149
|
-
do {
|
|
150
|
-
done = (await events.next()).done ?? false;
|
|
151
|
-
} while (!done);
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=runStreamed.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runStreamed.test.js","sourceRoot":"","sources":["../../tests/runStreamed.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,KAAK,EA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,sBAAsB,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,OAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC;gBAC3B,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,IAAI;gBACZ,MAAM;aACP,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,WAAW,CAAC,MAAmC;IAC5D,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,GAAG,CAAC;QACF,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC;IAC7C,CAAC,QAAQ,CAAC,IAAI,EAAE;AAClB,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
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@northflare/codex-sdk",
|
|
3
|
-
"version": "0.0.0-dev",
|
|
4
|
-
"description": "TypeScript SDK for Codex APIs.",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/openai/codex.git",
|
|
8
|
-
"directory": "sdk/typescript"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"openai",
|
|
12
|
-
"codex",
|
|
13
|
-
"sdk",
|
|
14
|
-
"typescript",
|
|
15
|
-
"api"
|
|
16
|
-
],
|
|
17
|
-
"license": "Apache-2.0",
|
|
18
|
-
"type": "module",
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=18"
|
|
21
|
-
},
|
|
22
|
-
"module": "./dist/index.js",
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
|
-
"exports": {
|
|
25
|
-
".": {
|
|
26
|
-
"import": "./dist/index.js",
|
|
27
|
-
"types": "./dist/index.d.ts"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist"
|
|
32
|
-
],
|
|
33
|
-
"sideEffects": false,
|
|
34
|
-
"scripts": {
|
|
35
|
-
"clean": "rm -rf dist",
|
|
36
|
-
"build": "tsup",
|
|
37
|
-
"build:watch": "tsup --watch",
|
|
38
|
-
"lint": "pnpm eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
39
|
-
"lint:fix": "pnpm eslint --fix \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
40
|
-
"test": "jest",
|
|
41
|
-
"test:watch": "jest --watch",
|
|
42
|
-
"coverage": "jest --coverage",
|
|
43
|
-
"format": "prettier --check .",
|
|
44
|
-
"format:fix": "prettier --write ."
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@modelcontextprotocol/sdk": "^1.20.2",
|
|
48
|
-
"@types/jest": "^29.5.14",
|
|
49
|
-
"@types/node": "^20.19.18",
|
|
50
|
-
"eslint": "^9.36.0",
|
|
51
|
-
"eslint-config-prettier": "^9.1.2",
|
|
52
|
-
"eslint-plugin-jest": "^29.0.1",
|
|
53
|
-
"eslint-plugin-node-import": "^1.0.5",
|
|
54
|
-
"jest": "^29.7.0",
|
|
55
|
-
"prettier": "^3.6.2",
|
|
56
|
-
"ts-jest": "^29.3.4",
|
|
57
|
-
"ts-jest-mock-import-meta": "^1.3.1",
|
|
58
|
-
"ts-node": "^10.9.2",
|
|
59
|
-
"tsup": "^8.5.0",
|
|
60
|
-
"typescript": "^5.9.2",
|
|
61
|
-
"typescript-eslint": "^8.45.0",
|
|
62
|
-
"zod": "^3.24.2",
|
|
63
|
-
"zod-to-json-schema": "^3.24.6"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
|
|
2
|
-
|
|
3
|
-
import { createInterface } from "node:readline/promises";
|
|
4
|
-
import { stdin as input, stdout as output } from "node:process";
|
|
5
|
-
|
|
6
|
-
import { Codex } from "@openai/codex-sdk";
|
|
7
|
-
import type { ThreadEvent, ThreadItem } from "@openai/codex-sdk";
|
|
8
|
-
import { codexPathOverride } from "./helpers.ts";
|
|
9
|
-
|
|
10
|
-
const codex = new Codex({ codexPathOverride: codexPathOverride() });
|
|
11
|
-
const thread = codex.startThread();
|
|
12
|
-
const rl = createInterface({ input, output });
|
|
13
|
-
|
|
14
|
-
const handleItemCompleted = (item: ThreadItem): void => {
|
|
15
|
-
switch (item.type) {
|
|
16
|
-
case "agent_message":
|
|
17
|
-
console.log(`Assistant: ${item.text}`);
|
|
18
|
-
break;
|
|
19
|
-
case "reasoning":
|
|
20
|
-
console.log(`Reasoning: ${item.text}`);
|
|
21
|
-
break;
|
|
22
|
-
case "command_execution": {
|
|
23
|
-
const exitText = item.exit_code !== undefined ? ` Exit code ${item.exit_code}.` : "";
|
|
24
|
-
console.log(`Command ${item.command} ${item.status}.${exitText}`);
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
case "file_change": {
|
|
28
|
-
for (const change of item.changes) {
|
|
29
|
-
console.log(`File ${change.kind} ${change.path}`);
|
|
30
|
-
}
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const handleItemUpdated = (item: ThreadItem): void => {
|
|
37
|
-
switch (item.type) {
|
|
38
|
-
case "todo_list": {
|
|
39
|
-
console.log(`Todo:`);
|
|
40
|
-
for (const todo of item.items) {
|
|
41
|
-
console.log(`\t ${todo.completed ? "x" : " "} ${todo.text}`);
|
|
42
|
-
}
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const handleEvent = (event: ThreadEvent): void => {
|
|
49
|
-
switch (event.type) {
|
|
50
|
-
case "item.completed":
|
|
51
|
-
handleItemCompleted(event.item);
|
|
52
|
-
break;
|
|
53
|
-
case "item.updated":
|
|
54
|
-
case "item.started":
|
|
55
|
-
handleItemUpdated(event.item);
|
|
56
|
-
break;
|
|
57
|
-
case "turn.completed":
|
|
58
|
-
console.log(
|
|
59
|
-
`Used ${event.usage.input_tokens} input tokens, ${event.usage.cached_input_tokens} cached input tokens, ${event.usage.output_tokens} output tokens.`,
|
|
60
|
-
);
|
|
61
|
-
break;
|
|
62
|
-
case "turn.failed":
|
|
63
|
-
console.error(`Turn failed: ${event.error.message}`);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const main = async (): Promise<void> => {
|
|
69
|
-
try {
|
|
70
|
-
while (true) {
|
|
71
|
-
const inputText = await rl.question(">");
|
|
72
|
-
const trimmed = inputText.trim();
|
|
73
|
-
if (trimmed.length === 0) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const { events } = await thread.runStreamed(inputText);
|
|
77
|
-
for await (const event of events) {
|
|
78
|
-
handleEvent(event);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} finally {
|
|
82
|
-
rl.close();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
main().catch((err) => {
|
|
87
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
88
|
-
console.error(`Unexpected error: ${message}`);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
|
|
2
|
-
|
|
3
|
-
import { Codex } from "@openai/codex-sdk";
|
|
4
|
-
|
|
5
|
-
import { codexPathOverride } from "./helpers.ts";
|
|
6
|
-
|
|
7
|
-
const codex = new Codex({ codexPathOverride: codexPathOverride() });
|
|
8
|
-
|
|
9
|
-
const thread = codex.startThread();
|
|
10
|
-
|
|
11
|
-
const schema = {
|
|
12
|
-
type: "object",
|
|
13
|
-
properties: {
|
|
14
|
-
summary: { type: "string" },
|
|
15
|
-
status: { type: "string", enum: ["ok", "action_required"] },
|
|
16
|
-
},
|
|
17
|
-
required: ["summary", "status"],
|
|
18
|
-
additionalProperties: false,
|
|
19
|
-
} as const;
|
|
20
|
-
|
|
21
|
-
const turn = await thread.run("Summarize repository status", { outputSchema: schema });
|
|
22
|
-
console.log(turn.finalResponse);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
|
|
2
|
-
|
|
3
|
-
import { Codex } from "@openai/codex-sdk";
|
|
4
|
-
import { codexPathOverride } from "./helpers.ts";
|
|
5
|
-
import z from "zod";
|
|
6
|
-
import zodToJsonSchema from "zod-to-json-schema";
|
|
7
|
-
|
|
8
|
-
const codex = new Codex({ codexPathOverride: codexPathOverride() });
|
|
9
|
-
const thread = codex.startThread();
|
|
10
|
-
|
|
11
|
-
const schema = z.object({
|
|
12
|
-
summary: z.string(),
|
|
13
|
-
status: z.enum(["ok", "action_required"]),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const turn = await thread.run("Summarize repository status", {
|
|
17
|
-
outputSchema: zodToJsonSchema(schema, { target: "openAi" }),
|
|
18
|
-
});
|
|
19
|
-
console.log(turn.finalResponse);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { CodexOptions } from "./codexOptions";
|
|
2
|
-
import { CodexExec } from "./exec";
|
|
3
|
-
import { Thread } from "./thread";
|
|
4
|
-
import { ThreadOptions } from "./threadOptions";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Codex is the main class for interacting with the Codex agent.
|
|
8
|
-
*
|
|
9
|
-
* Use the `startThread()` method to start a new thread or `resumeThread()` to resume a previously started thread.
|
|
10
|
-
*/
|
|
11
|
-
export class Codex {
|
|
12
|
-
private exec: CodexExec;
|
|
13
|
-
private options: CodexOptions;
|
|
14
|
-
|
|
15
|
-
constructor(options: CodexOptions = {}) {
|
|
16
|
-
this.exec = new CodexExec(options.codexPathOverride, options.env);
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Starts a new conversation with an agent.
|
|
22
|
-
* @returns A new thread instance.
|
|
23
|
-
*/
|
|
24
|
-
startThread(options: ThreadOptions = {}): Thread {
|
|
25
|
-
return new Thread(this.exec, this.options, options);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Resumes a conversation with an agent based on the thread id.
|
|
30
|
-
* Threads are persisted in ~/.codex/sessions.
|
|
31
|
-
*
|
|
32
|
-
* @param id The id of the thread to resume.
|
|
33
|
-
* @returns A new thread instance.
|
|
34
|
-
*/
|
|
35
|
-
resumeThread(id: string, options: ThreadOptions = {}): Thread {
|
|
36
|
-
return new Thread(this.exec, this.options, options, id);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type CodexOptions = {
|
|
2
|
-
codexPathOverride?: string;
|
|
3
|
-
baseUrl?: string;
|
|
4
|
-
apiKey?: string;
|
|
5
|
-
/**
|
|
6
|
-
* Environment variables passed to the Codex CLI process. When provided, the SDK
|
|
7
|
-
* will not inherit variables from `process.env`.
|
|
8
|
-
*/
|
|
9
|
-
env?: Record<string, string>;
|
|
10
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// based on event types from codex-rs/exec/src/exec_events.rs
|
|
2
|
-
|
|
3
|
-
import type { ThreadItem } from "./items";
|
|
4
|
-
|
|
5
|
-
/** Emitted when a new thread is started as the first event. */
|
|
6
|
-
export type ThreadStartedEvent = {
|
|
7
|
-
type: "thread.started";
|
|
8
|
-
/** The identifier of the new thread. Can be used to resume the thread later. */
|
|
9
|
-
thread_id: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Emitted when a turn is started by sending a new prompt to the model.
|
|
14
|
-
* A turn encompasses all events that happen while the agent is processing the prompt.
|
|
15
|
-
*/
|
|
16
|
-
export type TurnStartedEvent = {
|
|
17
|
-
type: "turn.started";
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** Describes the usage of tokens during a turn. */
|
|
21
|
-
export type Usage = {
|
|
22
|
-
/** The number of input tokens used during the turn. */
|
|
23
|
-
input_tokens: number;
|
|
24
|
-
/** The number of cached input tokens used during the turn. */
|
|
25
|
-
cached_input_tokens: number;
|
|
26
|
-
/** The number of output tokens used during the turn. */
|
|
27
|
-
output_tokens: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/** Emitted when a turn is completed. Typically right after the assistant's response. */
|
|
31
|
-
export type TurnCompletedEvent = {
|
|
32
|
-
type: "turn.completed";
|
|
33
|
-
usage: Usage;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** Indicates that a turn failed with an error. */
|
|
37
|
-
export type TurnFailedEvent = {
|
|
38
|
-
type: "turn.failed";
|
|
39
|
-
error: ThreadError;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** Emitted when a new item is added to the thread. Typically the item is initially "in progress". */
|
|
43
|
-
export type ItemStartedEvent = {
|
|
44
|
-
type: "item.started";
|
|
45
|
-
item: ThreadItem;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** Emitted when an item is updated. */
|
|
49
|
-
export type ItemUpdatedEvent = {
|
|
50
|
-
type: "item.updated";
|
|
51
|
-
item: ThreadItem;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/** Signals that an item has reached a terminal state—either success or failure. */
|
|
55
|
-
export type ItemCompletedEvent = {
|
|
56
|
-
type: "item.completed";
|
|
57
|
-
item: ThreadItem;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/** Fatal error emitted by the stream. */
|
|
61
|
-
export type ThreadError = {
|
|
62
|
-
message: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/** Represents an unrecoverable error emitted directly by the event stream. */
|
|
66
|
-
export type ThreadErrorEvent = {
|
|
67
|
-
type: "error";
|
|
68
|
-
message: string;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/** Top-level JSONL events emitted by codex exec. */
|
|
72
|
-
export type ThreadEvent =
|
|
73
|
-
| ThreadStartedEvent
|
|
74
|
-
| TurnStartedEvent
|
|
75
|
-
| TurnCompletedEvent
|
|
76
|
-
| TurnFailedEvent
|
|
77
|
-
| ItemStartedEvent
|
|
78
|
-
| ItemUpdatedEvent
|
|
79
|
-
| ItemCompletedEvent
|
|
80
|
-
| ThreadErrorEvent;
|