rhachet-brains-openai 0.1.6 → 0.1.8

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/index.js CHANGED
@@ -1,18 +1,560 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./contract/sdk"), exports);
18
- //# sourceMappingURL=index.js.map
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ genBrainAtom: () => genBrainAtom,
34
+ genBrainRepl: () => genBrainRepl,
35
+ getBrainAtomsByOpenAI: () => getBrainAtomsByOpenAI,
36
+ getBrainReplsByOpenAI: () => getBrainReplsByOpenAI
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/domain.operations/atoms/genBrainAtom.ts
41
+ var import_openai = __toESM(require("openai"));
42
+ var import_rhachet = require("rhachet");
43
+ var import_zod = require("zod");
44
+ var CONFIG_BY_SLUG = {
45
+ "openai/gpt-4o": {
46
+ model: "gpt-4o",
47
+ description: "gpt-4o - multimodal model for reasoning and vision"
48
+ },
49
+ "openai/gpt-4o-mini": {
50
+ model: "gpt-4o-mini",
51
+ description: "gpt-4o-mini - fast and cost-effective multimodal model"
52
+ },
53
+ "openai/gpt-4-turbo": {
54
+ model: "gpt-4-turbo",
55
+ description: "gpt-4-turbo - high capability with vision support"
56
+ },
57
+ "openai/o1": {
58
+ model: "o1",
59
+ description: "o1 - advanced reasoning model for complex problems"
60
+ },
61
+ "openai/o1-mini": {
62
+ model: "o1-mini",
63
+ description: "o1-mini - fast reasoning model for coding and math"
64
+ },
65
+ "openai/o1-preview": {
66
+ model: "o1-preview",
67
+ description: "o1-preview - preview of advanced reasoning capabilities"
68
+ }
69
+ };
70
+ var genBrainAtom = (input) => {
71
+ const config = CONFIG_BY_SLUG[input.slug];
72
+ return new import_rhachet.BrainAtom({
73
+ repo: "openai",
74
+ slug: input.slug,
75
+ description: config.description,
76
+ /**
77
+ * .what = stateless inference (no tool use)
78
+ * .why = provides direct model access for reasoning tasks
79
+ */
80
+ ask: async (askInput, context) => {
81
+ const systemPrompt = askInput.role.briefs ? await (0, import_rhachet.castBriefsToPrompt)({ briefs: askInput.role.briefs }) : void 0;
82
+ const openai = context?.openai ?? new import_openai.default({ apiKey: process.env.OPENAI_API_KEY });
83
+ const messages = [];
84
+ if (systemPrompt) {
85
+ messages.push({ role: "system", content: systemPrompt });
86
+ }
87
+ messages.push({ role: "user", content: askInput.prompt });
88
+ const jsonSchema = import_zod.z.toJSONSchema(askInput.schema.output);
89
+ const isObjectSchema = typeof jsonSchema === "object" && jsonSchema !== null && "type" in jsonSchema && jsonSchema.type === "object";
90
+ const response = await openai.chat.completions.create({
91
+ model: config.model,
92
+ messages,
93
+ ...isObjectSchema && {
94
+ response_format: {
95
+ type: "json_schema",
96
+ json_schema: {
97
+ name: "response",
98
+ strict: true,
99
+ schema: jsonSchema
100
+ }
101
+ }
102
+ }
103
+ });
104
+ const content = response.choices[0]?.message?.content ?? "";
105
+ if (isObjectSchema) {
106
+ const parsed = JSON.parse(content);
107
+ return askInput.schema.output.parse(parsed);
108
+ }
109
+ return askInput.schema.output.parse(content);
110
+ }
111
+ });
112
+ };
113
+
114
+ // node_modules/.pnpm/@openai+codex-sdk@0.77.0/node_modules/@openai/codex-sdk/dist/index.js
115
+ var import_fs = require("fs");
116
+ var import_os = __toESM(require("os"), 1);
117
+ var import_path = __toESM(require("path"), 1);
118
+ var import_child_process = require("child_process");
119
+ var import_path2 = __toESM(require("path"), 1);
120
+ var import_readline = __toESM(require("readline"), 1);
121
+ var import_url = require("url");
122
+ var import_meta = { get url() {
123
+ var path = require('path');
124
+ var fs = require('fs');
125
+ var dir = process.cwd();
126
+ while (dir !== path.dirname(dir)) {
127
+ var candidate = path.join(dir, 'node_modules', '@openai', 'codex-sdk', 'dist', 'index.js');
128
+ if (fs.existsSync(candidate)) return require('url').pathToFileURL(candidate).href;
129
+ dir = path.dirname(dir);
130
+ }
131
+ throw new Error('@openai/codex-sdk not found. Install it as a peer dependency.');
132
+ } };
133
+ async function createOutputSchemaFile(schema) {
134
+ if (schema === void 0) {
135
+ return { cleanup: async () => {
136
+ } };
137
+ }
138
+ if (!isJsonObject(schema)) {
139
+ throw new Error("outputSchema must be a plain JSON object");
140
+ }
141
+ const schemaDir = await import_fs.promises.mkdtemp(import_path.default.join(import_os.default.tmpdir(), "codex-output-schema-"));
142
+ const schemaPath = import_path.default.join(schemaDir, "schema.json");
143
+ const cleanup = async () => {
144
+ try {
145
+ await import_fs.promises.rm(schemaDir, { recursive: true, force: true });
146
+ } catch {
147
+ }
148
+ };
149
+ try {
150
+ await import_fs.promises.writeFile(schemaPath, JSON.stringify(schema), "utf8");
151
+ return { schemaPath, cleanup };
152
+ } catch (error) {
153
+ await cleanup();
154
+ throw error;
155
+ }
156
+ }
157
+ function isJsonObject(value) {
158
+ return typeof value === "object" && value !== null && !Array.isArray(value);
159
+ }
160
+ var Thread = class {
161
+ _exec;
162
+ _options;
163
+ _id;
164
+ _threadOptions;
165
+ /** Returns the ID of the thread. Populated after the first turn starts. */
166
+ get id() {
167
+ return this._id;
168
+ }
169
+ /* @internal */
170
+ constructor(exec, options, threadOptions, id = null) {
171
+ this._exec = exec;
172
+ this._options = options;
173
+ this._id = id;
174
+ this._threadOptions = threadOptions;
175
+ }
176
+ /** Provides the input to the agent and streams events as they are produced during the turn. */
177
+ async runStreamed(input, turnOptions = {}) {
178
+ return { events: this.runStreamedInternal(input, turnOptions) };
179
+ }
180
+ async *runStreamedInternal(input, turnOptions = {}) {
181
+ const { schemaPath, cleanup } = await createOutputSchemaFile(turnOptions.outputSchema);
182
+ const options = this._threadOptions;
183
+ const { prompt, images } = normalizeInput(input);
184
+ const generator = this._exec.run({
185
+ input: prompt,
186
+ baseUrl: this._options.baseUrl,
187
+ apiKey: this._options.apiKey,
188
+ threadId: this._id,
189
+ images,
190
+ model: options?.model,
191
+ sandboxMode: options?.sandboxMode,
192
+ workingDirectory: options?.workingDirectory,
193
+ skipGitRepoCheck: options?.skipGitRepoCheck,
194
+ outputSchemaFile: schemaPath,
195
+ modelReasoningEffort: options?.modelReasoningEffort,
196
+ signal: turnOptions.signal,
197
+ networkAccessEnabled: options?.networkAccessEnabled,
198
+ webSearchEnabled: options?.webSearchEnabled,
199
+ approvalPolicy: options?.approvalPolicy,
200
+ additionalDirectories: options?.additionalDirectories
201
+ });
202
+ try {
203
+ for await (const item of generator) {
204
+ let parsed;
205
+ try {
206
+ parsed = JSON.parse(item);
207
+ } catch (error) {
208
+ throw new Error(`Failed to parse item: ${item}`, { cause: error });
209
+ }
210
+ if (parsed.type === "thread.started") {
211
+ this._id = parsed.thread_id;
212
+ }
213
+ yield parsed;
214
+ }
215
+ } finally {
216
+ await cleanup();
217
+ }
218
+ }
219
+ /** Provides the input to the agent and returns the completed turn. */
220
+ async run(input, turnOptions = {}) {
221
+ const generator = this.runStreamedInternal(input, turnOptions);
222
+ const items = [];
223
+ let finalResponse = "";
224
+ let usage = null;
225
+ let turnFailure = null;
226
+ for await (const event of generator) {
227
+ if (event.type === "item.completed") {
228
+ if (event.item.type === "agent_message") {
229
+ finalResponse = event.item.text;
230
+ }
231
+ items.push(event.item);
232
+ } else if (event.type === "turn.completed") {
233
+ usage = event.usage;
234
+ } else if (event.type === "turn.failed") {
235
+ turnFailure = event.error;
236
+ break;
237
+ }
238
+ }
239
+ if (turnFailure) {
240
+ throw new Error(turnFailure.message);
241
+ }
242
+ return { items, finalResponse, usage };
243
+ }
244
+ };
245
+ function normalizeInput(input) {
246
+ if (typeof input === "string") {
247
+ return { prompt: input, images: [] };
248
+ }
249
+ const promptParts = [];
250
+ const images = [];
251
+ for (const item of input) {
252
+ if (item.type === "text") {
253
+ promptParts.push(item.text);
254
+ } else if (item.type === "local_image") {
255
+ images.push(item.path);
256
+ }
257
+ }
258
+ return { prompt: promptParts.join("\n\n"), images };
259
+ }
260
+ var INTERNAL_ORIGINATOR_ENV = "CODEX_INTERNAL_ORIGINATOR_OVERRIDE";
261
+ var TYPESCRIPT_SDK_ORIGINATOR = "codex_sdk_ts";
262
+ var CodexExec = class {
263
+ executablePath;
264
+ envOverride;
265
+ constructor(executablePath = null, env) {
266
+ this.executablePath = executablePath || findCodexPath();
267
+ this.envOverride = env;
268
+ }
269
+ async *run(args) {
270
+ const commandArgs = ["exec", "--experimental-json"];
271
+ if (args.model) {
272
+ commandArgs.push("--model", args.model);
273
+ }
274
+ if (args.sandboxMode) {
275
+ commandArgs.push("--sandbox", args.sandboxMode);
276
+ }
277
+ if (args.workingDirectory) {
278
+ commandArgs.push("--cd", args.workingDirectory);
279
+ }
280
+ if (args.additionalDirectories?.length) {
281
+ for (const dir of args.additionalDirectories) {
282
+ commandArgs.push("--add-dir", dir);
283
+ }
284
+ }
285
+ if (args.skipGitRepoCheck) {
286
+ commandArgs.push("--skip-git-repo-check");
287
+ }
288
+ if (args.outputSchemaFile) {
289
+ commandArgs.push("--output-schema", args.outputSchemaFile);
290
+ }
291
+ if (args.modelReasoningEffort) {
292
+ commandArgs.push("--config", `model_reasoning_effort="${args.modelReasoningEffort}"`);
293
+ }
294
+ if (args.networkAccessEnabled !== void 0) {
295
+ commandArgs.push(
296
+ "--config",
297
+ `sandbox_workspace_write.network_access=${args.networkAccessEnabled}`
298
+ );
299
+ }
300
+ if (args.webSearchEnabled !== void 0) {
301
+ commandArgs.push("--config", `features.web_search_request=${args.webSearchEnabled}`);
302
+ }
303
+ if (args.approvalPolicy) {
304
+ commandArgs.push("--config", `approval_policy="${args.approvalPolicy}"`);
305
+ }
306
+ if (args.images?.length) {
307
+ for (const image of args.images) {
308
+ commandArgs.push("--image", image);
309
+ }
310
+ }
311
+ if (args.threadId) {
312
+ commandArgs.push("resume", args.threadId);
313
+ }
314
+ const env = {};
315
+ if (this.envOverride) {
316
+ Object.assign(env, this.envOverride);
317
+ } else {
318
+ for (const [key, value] of Object.entries(process.env)) {
319
+ if (value !== void 0) {
320
+ env[key] = value;
321
+ }
322
+ }
323
+ }
324
+ if (!env[INTERNAL_ORIGINATOR_ENV]) {
325
+ env[INTERNAL_ORIGINATOR_ENV] = TYPESCRIPT_SDK_ORIGINATOR;
326
+ }
327
+ if (args.baseUrl) {
328
+ env.OPENAI_BASE_URL = args.baseUrl;
329
+ }
330
+ if (args.apiKey) {
331
+ env.CODEX_API_KEY = args.apiKey;
332
+ }
333
+ const child = (0, import_child_process.spawn)(this.executablePath, commandArgs, {
334
+ env,
335
+ signal: args.signal
336
+ });
337
+ let spawnError = null;
338
+ child.once("error", (err) => spawnError = err);
339
+ if (!child.stdin) {
340
+ child.kill();
341
+ throw new Error("Child process has no stdin");
342
+ }
343
+ child.stdin.write(args.input);
344
+ child.stdin.end();
345
+ if (!child.stdout) {
346
+ child.kill();
347
+ throw new Error("Child process has no stdout");
348
+ }
349
+ const stderrChunks = [];
350
+ if (child.stderr) {
351
+ child.stderr.on("data", (data) => {
352
+ stderrChunks.push(data);
353
+ });
354
+ }
355
+ const rl = import_readline.default.createInterface({
356
+ input: child.stdout,
357
+ crlfDelay: Infinity
358
+ });
359
+ try {
360
+ for await (const line of rl) {
361
+ yield line;
362
+ }
363
+ const exitCode = new Promise((resolve, reject) => {
364
+ child.once("exit", (code) => {
365
+ if (code === 0) {
366
+ resolve(code);
367
+ } else {
368
+ const stderrBuffer = Buffer.concat(stderrChunks);
369
+ reject(
370
+ new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString("utf8")}`)
371
+ );
372
+ }
373
+ });
374
+ });
375
+ if (spawnError) throw spawnError;
376
+ await exitCode;
377
+ } finally {
378
+ rl.close();
379
+ child.removeAllListeners();
380
+ try {
381
+ if (!child.killed) child.kill();
382
+ } catch {
383
+ }
384
+ }
385
+ }
386
+ };
387
+ var scriptFileName = (0, import_url.fileURLToPath)(import_meta.url);
388
+ var scriptDirName = import_path2.default.dirname(scriptFileName);
389
+ function findCodexPath() {
390
+ const { platform, arch } = process;
391
+ let targetTriple = null;
392
+ switch (platform) {
393
+ case "linux":
394
+ case "android":
395
+ switch (arch) {
396
+ case "x64":
397
+ targetTriple = "x86_64-unknown-linux-musl";
398
+ break;
399
+ case "arm64":
400
+ targetTriple = "aarch64-unknown-linux-musl";
401
+ break;
402
+ default:
403
+ break;
404
+ }
405
+ break;
406
+ case "darwin":
407
+ switch (arch) {
408
+ case "x64":
409
+ targetTriple = "x86_64-apple-darwin";
410
+ break;
411
+ case "arm64":
412
+ targetTriple = "aarch64-apple-darwin";
413
+ break;
414
+ default:
415
+ break;
416
+ }
417
+ break;
418
+ case "win32":
419
+ switch (arch) {
420
+ case "x64":
421
+ targetTriple = "x86_64-pc-windows-msvc";
422
+ break;
423
+ case "arm64":
424
+ targetTriple = "aarch64-pc-windows-msvc";
425
+ break;
426
+ default:
427
+ break;
428
+ }
429
+ break;
430
+ default:
431
+ break;
432
+ }
433
+ if (!targetTriple) {
434
+ throw new Error(`Unsupported platform: ${platform} (${arch})`);
435
+ }
436
+ const vendorRoot = import_path2.default.join(scriptDirName, "..", "vendor");
437
+ const archRoot = import_path2.default.join(vendorRoot, targetTriple);
438
+ const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
439
+ const binaryPath = import_path2.default.join(archRoot, "codex", codexBinaryName);
440
+ return binaryPath;
441
+ }
442
+ var Codex = class {
443
+ exec;
444
+ options;
445
+ constructor(options = {}) {
446
+ this.exec = new CodexExec(options.codexPathOverride, options.env);
447
+ this.options = options;
448
+ }
449
+ /**
450
+ * Starts a new conversation with an agent.
451
+ * @returns A new thread instance.
452
+ */
453
+ startThread(options = {}) {
454
+ return new Thread(this.exec, this.options, options);
455
+ }
456
+ /**
457
+ * Resumes a conversation with an agent based on the thread id.
458
+ * Threads are persisted in ~/.codex/sessions.
459
+ *
460
+ * @param id The id of the thread to resume.
461
+ * @returns A new thread instance.
462
+ */
463
+ resumeThread(id, options = {}) {
464
+ return new Thread(this.exec, this.options, options, id);
465
+ }
466
+ };
467
+
468
+ // src/domain.operations/repls/genBrainRepl.ts
469
+ var import_rhachet2 = require("rhachet");
470
+ var import_wrapper_fns = require("wrapper-fns");
471
+
472
+ // src/infra/schema/asJsonSchema.ts
473
+ var import_zod2 = require("zod");
474
+ var asJsonSchema = (input) => {
475
+ return import_zod2.z.toJSONSchema(input.schema, { target: "openAi" });
476
+ };
477
+
478
+ // src/domain.operations/repls/genBrainRepl.ts
479
+ var CONFIG_BY_SLUG2 = {
480
+ "openai/codex": {
481
+ model: void 0,
482
+ // use SDK default (gpt-5.1-codex-max)
483
+ description: "codex - agentic coding assistant (default model)"
484
+ },
485
+ "openai/codex/max": {
486
+ model: "gpt-5.1-codex-max",
487
+ description: "codex max - optimized for long-horizon agentic coding"
488
+ },
489
+ "openai/codex/mini": {
490
+ model: "gpt-5.1-codex-mini",
491
+ description: "codex mini - fast and cost-effective"
492
+ },
493
+ "openai/codex/5.2": {
494
+ model: "gpt-5.2-codex",
495
+ description: "codex 5.2 - most advanced agentic coding model"
496
+ }
497
+ };
498
+ var composePromptWithSystem = (userPrompt, systemPrompt) => {
499
+ if (!systemPrompt) return userPrompt;
500
+ return `${systemPrompt}
501
+
502
+ ---
503
+
504
+ ${userPrompt}`;
505
+ };
506
+ var invokeCodex = async (input) => {
507
+ const systemPrompt = input.role.briefs ? await (0, import_rhachet2.castBriefsToPrompt)({ briefs: input.role.briefs }) : void 0;
508
+ const outputSchema = asJsonSchema({
509
+ schema: input.schema.output
510
+ });
511
+ const codex = new Codex({
512
+ apiKey: process.env.OPENAI_API_KEY
513
+ });
514
+ const sandboxMode = input.mode === "ask" ? "read-only" : "workspace-write";
515
+ const thread = codex.startThread({
516
+ model: input.model,
517
+ sandboxMode
518
+ });
519
+ const fullPrompt = composePromptWithSystem(input.prompt, systemPrompt);
520
+ const response = await (0, import_wrapper_fns.withRetry)(
521
+ (0, import_wrapper_fns.withTimeout)(async () => thread.run(fullPrompt, { outputSchema }), {
522
+ threshold: { seconds: 60 }
523
+ })
524
+ )();
525
+ return input.schema.output.parse(JSON.parse(response.finalResponse));
526
+ };
527
+ var genBrainRepl = (input) => {
528
+ const config = CONFIG_BY_SLUG2[input.slug];
529
+ const modelSlug = input.slug.replace(/^openai\//, "");
530
+ return new import_rhachet2.BrainRepl({
531
+ repo: "openai",
532
+ slug: modelSlug,
533
+ description: config.description,
534
+ /**
535
+ * .what = readonly analysis (research, queries, code review)
536
+ * .why = provides safe, non-mutating agent interactions via read-only sandbox
537
+ */
538
+ ask: async (askInput, _context) => invokeCodex({ mode: "ask", model: config.model, ...askInput }),
539
+ /**
540
+ * .what = read+write actions (code changes, file edits)
541
+ * .why = provides full agentic capabilities via workspace-write sandbox
542
+ */
543
+ act: async (actInput, _context) => invokeCodex({ mode: "act", model: config.model, ...actInput })
544
+ });
545
+ };
546
+
547
+ // src/contract/sdk/index.ts
548
+ var getBrainAtomsByOpenAI = () => {
549
+ return [genBrainAtom({ slug: "openai/gpt-4o" })];
550
+ };
551
+ var getBrainReplsByOpenAI = () => {
552
+ return [genBrainRepl({ slug: "openai/codex" })];
553
+ };
554
+ // Annotate the CommonJS export names for ESM import in node:
555
+ 0 && (module.exports = {
556
+ genBrainAtom,
557
+ genBrainRepl,
558
+ getBrainAtomsByOpenAI,
559
+ getBrainReplsByOpenAI
560
+ });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "rhachet-brains-openai",
3
3
  "author": "ehmpathy",
4
4
  "description": "rhachet brain.atom and brain.repl adapter for openai",
5
- "version": "0.1.6",
5
+ "version": "0.1.8",
6
6
  "repository": "ehmpathy/rhachet-brains-openai",
7
7
  "homepage": "https://github.com/ehmpathy/rhachet-brains-openai",
8
8
  "keywords": [
@@ -34,8 +34,7 @@
34
34
  "build:clean:bun": "rm -f ./bin/*.bc",
35
35
  "build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
36
36
  "build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
37
- "build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
38
- "build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
37
+ "build:compile": "bash bin/compile.withshim.sh",
39
38
  "build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
40
39
  "test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
41
40
  "test:types": "tsc -p ./tsconfig.json --noEmit",
@@ -59,7 +58,6 @@
59
58
  "prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
60
59
  },
61
60
  "dependencies": {
62
- "@openai/codex-sdk": "0.77.0",
63
61
  "domain-objects": "0.31.9",
64
62
  "helpful-errors": "1.5.3",
65
63
  "openai": "5.8.2",
@@ -73,6 +71,7 @@
73
71
  "@biomejs/biome": "2.3.8",
74
72
  "@commitlint/cli": "19.5.0",
75
73
  "@commitlint/config-conventional": "19.5.0",
74
+ "@openai/codex-sdk": "0.77.0",
76
75
  "@swc/core": "1.15.3",
77
76
  "@swc/jest": "0.2.39",
78
77
  "@tsconfig/node20": "20.1.5",
@@ -85,6 +84,7 @@
85
84
  "declastruct": "1.7.3",
86
85
  "declastruct-github": "1.3.0",
87
86
  "depcheck": "1.4.3",
87
+ "esbuild": "0.27.2",
88
88
  "esbuild-register": "3.6.0",
89
89
  "husky": "8.0.3",
90
90
  "jest": "30.2.0",
@@ -99,6 +99,7 @@
99
99
  "yalc": "1.0.0-pre.53"
100
100
  },
101
101
  "peerDependencies": {
102
+ "@openai/codex-sdk": ">=0.77.0",
102
103
  "rhachet": ">=1.21.4"
103
104
  },
104
105
  "config": {
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genBrainRepl = exports.genBrainAtom = exports.getBrainReplsByOpenAI = exports.getBrainAtomsByOpenAI = void 0;
4
- const genBrainAtom_1 = require("../../domain.operations/atoms/genBrainAtom");
5
- const genBrainRepl_1 = require("../../domain.operations/repls/genBrainRepl");
6
- /**
7
- * .what = returns all brain atoms provided by openai
8
- * .why = enables consumers to register openai atoms with genContextBrain
9
- */
10
- const getBrainAtomsByOpenAI = () => {
11
- return [(0, genBrainAtom_1.genBrainAtom)({ slug: 'openai/gpt-4o' })];
12
- };
13
- exports.getBrainAtomsByOpenAI = getBrainAtomsByOpenAI;
14
- /**
15
- * .what = returns all brain repls provided by openai
16
- * .why = enables consumers to register openai repls with genContextBrain
17
- */
18
- const getBrainReplsByOpenAI = () => {
19
- return [(0, genBrainRepl_1.genBrainRepl)({ slug: 'openai/codex' })];
20
- };
21
- exports.getBrainReplsByOpenAI = getBrainReplsByOpenAI;
22
- // re-export factories for direct access
23
- var genBrainAtom_2 = require("../../domain.operations/atoms/genBrainAtom");
24
- Object.defineProperty(exports, "genBrainAtom", { enumerable: true, get: function () { return genBrainAtom_2.genBrainAtom; } });
25
- var genBrainRepl_2 = require("../../domain.operations/repls/genBrainRepl");
26
- Object.defineProperty(exports, "genBrainRepl", { enumerable: true, get: function () { return genBrainRepl_2.genBrainRepl; } });
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;AAEA,6EAA0E;AAC1E,6EAA0E;AAE1E;;;GAGG;AACI,MAAM,qBAAqB,GAAG,GAAgB,EAAE;IACrD,OAAO,CAAC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEF;;;GAGG;AACI,MAAM,qBAAqB,GAAG,GAAgB,EAAE;IACrD,OAAO,CAAC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEF,wCAAwC;AACxC,2EAA0E;AAAjE,4GAAA,YAAY,OAAA;AACrB,2EAA0E;AAAjE,4GAAA,YAAY,OAAA"}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.genBrainAtom = void 0;
7
- const openai_1 = __importDefault(require("openai"));
8
- const rhachet_1 = require("rhachet");
9
- const zod_1 = require("zod");
10
- /**
11
- * .what = model configuration by slug
12
- * .why = maps slugs to API model names and descriptions
13
- */
14
- const CONFIG_BY_SLUG = {
15
- 'openai/gpt-4o': {
16
- model: 'gpt-4o',
17
- description: 'gpt-4o - multimodal model for reasoning and vision',
18
- },
19
- 'openai/gpt-4o-mini': {
20
- model: 'gpt-4o-mini',
21
- description: 'gpt-4o-mini - fast and cost-effective multimodal model',
22
- },
23
- 'openai/gpt-4-turbo': {
24
- model: 'gpt-4-turbo',
25
- description: 'gpt-4-turbo - high capability with vision support',
26
- },
27
- 'openai/o1': {
28
- model: 'o1',
29
- description: 'o1 - advanced reasoning model for complex problems',
30
- },
31
- 'openai/o1-mini': {
32
- model: 'o1-mini',
33
- description: 'o1-mini - fast reasoning model for coding and math',
34
- },
35
- 'openai/o1-preview': {
36
- model: 'o1-preview',
37
- description: 'o1-preview - preview of advanced reasoning capabilities',
38
- },
39
- };
40
- /**
41
- * .what = factory to generate openai brain atom instances
42
- * .why = enables model variant selection via slug
43
- *
44
- * .example
45
- * genBrainAtom({ slug: 'openai/gpt-4o' })
46
- * genBrainAtom({ slug: 'openai/gpt-4o-mini' }) // fast + cheap
47
- * genBrainAtom({ slug: 'openai/o1' }) // advanced reasoning
48
- */
49
- const genBrainAtom = (input) => {
50
- const config = CONFIG_BY_SLUG[input.slug];
51
- return new rhachet_1.BrainAtom({
52
- repo: 'openai',
53
- slug: input.slug,
54
- description: config.description,
55
- /**
56
- * .what = stateless inference (no tool use)
57
- * .why = provides direct model access for reasoning tasks
58
- */
59
- ask: async (askInput, context) => {
60
- // compose system prompt from briefs
61
- const systemPrompt = askInput.role.briefs
62
- ? await (0, rhachet_1.castBriefsToPrompt)({ briefs: askInput.role.briefs })
63
- : undefined;
64
- // get openai client from context or create new one
65
- const openai = context?.openai ??
66
- new openai_1.default({ apiKey: process.env.OPENAI_API_KEY });
67
- // build messages array
68
- const messages = [];
69
- if (systemPrompt) {
70
- messages.push({ role: 'system', content: systemPrompt });
71
- }
72
- messages.push({ role: 'user', content: askInput.prompt });
73
- // convert zod schema to json schema for structured output
74
- const jsonSchema = zod_1.z.toJSONSchema(askInput.schema.output);
75
- // check if schema is an object type (openai only supports object schemas for response_format)
76
- const isObjectSchema = typeof jsonSchema === 'object' &&
77
- jsonSchema !== null &&
78
- 'type' in jsonSchema &&
79
- jsonSchema.type === 'object';
80
- // call openai api, with response_format only for object schemas
81
- const response = await openai.chat.completions.create({
82
- model: config.model,
83
- messages,
84
- ...(isObjectSchema && {
85
- response_format: {
86
- type: 'json_schema',
87
- json_schema: {
88
- name: 'response',
89
- strict: true,
90
- schema: jsonSchema,
91
- },
92
- },
93
- }),
94
- });
95
- // extract content from response
96
- const content = response.choices[0]?.message?.content ?? '';
97
- // parse response based on schema type
98
- if (isObjectSchema) {
99
- const parsed = JSON.parse(content);
100
- return askInput.schema.output.parse(parsed);
101
- }
102
- // for non-object schemas, validate the raw content directly
103
- return askInput.schema.output.parse(content);
104
- },
105
- });
106
- };
107
- exports.genBrainAtom = genBrainAtom;
108
- //# sourceMappingURL=genBrainAtom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atoms/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,qCAAwD;AAIxD,6BAAwB;AAcxB;;;GAGG;AACH,MAAM,cAAc,GAGhB;IACF,eAAe,EAAE;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,oDAAoD;KAClE;IACD,oBAAoB,EAAE;QACpB,KAAK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,gBA4EvB"}
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genBrainRepl = void 0;
4
- const codex_sdk_1 = require("@openai/codex-sdk");
5
- const rhachet_1 = require("rhachet");
6
- const wrapper_fns_1 = require("wrapper-fns");
7
- const asJsonSchema_1 = require("../../infra/schema/asJsonSchema");
8
- /**
9
- * .what = model configuration by slug
10
- * .why = maps slugs to API model names and descriptions
11
- */
12
- const CONFIG_BY_SLUG = {
13
- 'openai/codex': {
14
- model: undefined, // use SDK default (gpt-5.1-codex-max)
15
- description: 'codex - agentic coding assistant (default model)',
16
- },
17
- 'openai/codex/max': {
18
- model: 'gpt-5.1-codex-max',
19
- description: 'codex max - optimized for long-horizon agentic coding',
20
- },
21
- 'openai/codex/mini': {
22
- model: 'gpt-5.1-codex-mini',
23
- description: 'codex mini - fast and cost-effective',
24
- },
25
- 'openai/codex/5.2': {
26
- model: 'gpt-5.2-codex',
27
- description: 'codex 5.2 - most advanced agentic coding model',
28
- },
29
- };
30
- /**
31
- * .what = composes full prompt with optional system context
32
- * .why = codex-sdk ThreadOptions doesn't have systemPrompt, must prepend to user prompt
33
- */
34
- const composePromptWithSystem = (userPrompt, systemPrompt) => {
35
- if (!systemPrompt)
36
- return userPrompt;
37
- return `${systemPrompt}\n\n---\n\n${userPrompt}`;
38
- };
39
- /**
40
- * .what = invokes codex sdk with specified sandbox mode
41
- * .why = dedupes shared logic between ask (read-only) and act (workspace-write)
42
- */
43
- const invokeCodex = async (input) => {
44
- // compose system prompt from briefs
45
- const systemPrompt = input.role.briefs
46
- ? await (0, rhachet_1.castBriefsToPrompt)({ briefs: input.role.briefs })
47
- : undefined;
48
- // convert zod schema to json schema for native enforcement
49
- const outputSchema = (0, asJsonSchema_1.asJsonSchema)({
50
- schema: input.schema.output,
51
- });
52
- // create codex client
53
- const codex = new codex_sdk_1.Codex({
54
- apiKey: process.env.OPENAI_API_KEY,
55
- });
56
- // start thread with sandbox mode based on operation type
57
- const sandboxMode = input.mode === 'ask' ? 'read-only' : 'workspace-write';
58
- const thread = codex.startThread({
59
- model: input.model,
60
- sandboxMode,
61
- });
62
- // compose full prompt and run with timeout + retry for resilience
63
- const fullPrompt = composePromptWithSystem(input.prompt, systemPrompt);
64
- const response = await (0, wrapper_fns_1.withRetry)((0, wrapper_fns_1.withTimeout)(async () => thread.run(fullPrompt, { outputSchema }), {
65
- threshold: { seconds: 60 },
66
- }))();
67
- // parse output via schema for runtime validation
68
- return input.schema.output.parse(JSON.parse(response.finalResponse));
69
- };
70
- /**
71
- * .what = factory to generate openai codex brain repl instances
72
- * .why = enables model variant selection via slug
73
- *
74
- * .example
75
- * genBrainRepl({ slug: 'openai/codex' }) // default model
76
- * genBrainRepl({ slug: 'openai/codex/mini' }) // fast + cheap
77
- * genBrainRepl({ slug: 'openai/codex/5.2' }) // most advanced
78
- */
79
- const genBrainRepl = (input) => {
80
- const config = CONFIG_BY_SLUG[input.slug];
81
- // extract model slug without the repo prefix (e.g., 'openai/codex' -> 'codex')
82
- const modelSlug = input.slug.replace(/^openai\//, '');
83
- return new rhachet_1.BrainRepl({
84
- repo: 'openai',
85
- slug: modelSlug,
86
- description: config.description,
87
- /**
88
- * .what = readonly analysis (research, queries, code review)
89
- * .why = provides safe, non-mutating agent interactions via read-only sandbox
90
- */
91
- ask: async (askInput, _context) => invokeCodex({ mode: 'ask', model: config.model, ...askInput }),
92
- /**
93
- * .what = read+write actions (code changes, file edits)
94
- * .why = provides full agentic capabilities via workspace-write sandbox
95
- */
96
- act: async (actInput, _context) => invokeCodex({ mode: 'act', model: config.model, ...actInput }),
97
- });
98
- };
99
- exports.genBrainRepl = genBrainRepl;
100
- //# sourceMappingURL=genBrainRepl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"genBrainRepl.js","sourceRoot":"","sources":["../../../src/domain.operations/repls/genBrainRepl.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAC1C,qCAAwD;AAIxD,6CAAqD;AAG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AE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;KACjE,CAAC,CAAC;AACL,CAAC,CAAC;AAvCW,QAAA,YAAY,gBAuCvB"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asJsonSchema = void 0;
4
- const zod_1 = require("zod");
5
- /**
6
- * .what = convert a zod schema to JSON schema for native SDK enforcement
7
- * .why = enables native structured output support in SDKs, reducing
8
- * token waste on validation retries
9
- *
10
- * .note = different SDKs require different conversion options:
11
- * - claude-agent-sdk: { $refStrategy: 'root' }
12
- * - codex-sdk: { target: 'openAi' }
13
- */
14
- const asJsonSchema = (input) => {
15
- return zod_1.z.toJSONSchema(input.schema, { target: 'openAi' });
16
- };
17
- exports.asJsonSchema = asJsonSchema;
18
- //# sourceMappingURL=asJsonSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asJsonSchema.js","sourceRoot":"","sources":["../../../src/infra/schema/asJsonSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;;;;;;;GAQG;AACI,MAAM,YAAY,GAAG,CAAC,KAA8B,EAAU,EAAE;IACrE,OAAO,OAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}