@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.
- package/package.json +16 -17
- 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/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
|
@@ -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);
|