mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
committed by
GitHub
Unverified
parent
a90a58f7a1
commit
90fe5e4a7e
@@ -5,13 +5,9 @@ import { stdin as input, stdout as output } from "node:process";
|
||||
|
||||
import { Codex } from "@openai/codex-sdk";
|
||||
import type { ThreadEvent, ThreadItem } from "@openai/codex-sdk";
|
||||
import path from "node:path";
|
||||
import { codexPathOverride } from "./helpers.ts";
|
||||
|
||||
const codexPathOverride =
|
||||
process.env.CODEX_EXECUTABLE ??
|
||||
path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
|
||||
|
||||
const codex = new Codex({ codexPathOverride });
|
||||
const codex = new Codex({ codexPathOverride: codexPathOverride() });
|
||||
const thread = codex.startThread();
|
||||
const rl = createInterface({ input, output });
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import path from "node:path";
|
||||
|
||||
export function codexPathOverride() {
|
||||
return process.env.CODEX_EXECUTABLE ??
|
||||
path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
|
||||
|
||||
import { Codex } from "@openai/codex-sdk";
|
||||
|
||||
import { codexPathOverride } from "./helpers.ts";
|
||||
|
||||
const codex = new Codex({ codexPathOverride: codexPathOverride() });
|
||||
|
||||
const thread = codex.startThread();
|
||||
|
||||
const schema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
summary: { type: "string" },
|
||||
status: { type: "string", enum: ["ok", "action_required"] },
|
||||
},
|
||||
required: ["summary", "status"],
|
||||
additionalProperties: false,
|
||||
} as const;
|
||||
|
||||
const turn = await thread.run("Summarize repository status", { outputSchema: schema });
|
||||
console.log(turn.finalResponse);
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
|
||||
|
||||
import { Codex } from "@openai/codex-sdk";
|
||||
import { codexPathOverride } from "./helpers.ts";
|
||||
import z from "zod";
|
||||
import zodToJsonSchema from "zod-to-json-schema";
|
||||
|
||||
const codex = new Codex({ codexPathOverride: codexPathOverride() });
|
||||
const thread = codex.startThread();
|
||||
|
||||
const schema = z.object({
|
||||
summary: z.string(),
|
||||
status: z.enum(["ok", "action_required"]),
|
||||
});
|
||||
|
||||
const turn = await thread.run("Summarize repository status", {
|
||||
outputSchema: zodToJsonSchema(schema, { target: "openAi" }),
|
||||
});
|
||||
console.log(turn.finalResponse);
|
||||
Reference in New Issue
Block a user