rhachet-brains-openai 0.1.9 → 0.2.1
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
|
@@ -39,61 +39,807 @@ module.exports = __toCommonJS(index_exports);
|
|
|
39
39
|
|
|
40
40
|
// src/domain.operations/atoms/genBrainAtom.ts
|
|
41
41
|
var import_openai = __toESM(require("openai"));
|
|
42
|
-
var
|
|
42
|
+
var import_brains = require("rhachet/brains");
|
|
43
43
|
var import_zod = require("zod");
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
// src/domain.objects/BrainAtom.config.ts
|
|
46
|
+
var import_iso_price = require("iso-price");
|
|
47
|
+
var CONFIG_BY_ATOM_SLUG = {
|
|
48
|
+
// =========================================================================
|
|
49
|
+
// gpt-4 family
|
|
50
|
+
// =========================================================================
|
|
51
|
+
"openai/gpt/4o": {
|
|
46
52
|
model: "gpt-4o",
|
|
47
|
-
description: "gpt-4o - multimodal model for
|
|
53
|
+
description: "gpt-4o - multimodal model for reason and vision",
|
|
54
|
+
spec: {
|
|
55
|
+
cost: {
|
|
56
|
+
time: {
|
|
57
|
+
speed: { tokens: 100, per: { seconds: 1 } },
|
|
58
|
+
latency: { milliseconds: 500 }
|
|
59
|
+
},
|
|
60
|
+
cash: {
|
|
61
|
+
per: "token",
|
|
62
|
+
cache: {
|
|
63
|
+
get: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 }),
|
|
64
|
+
set: (0, import_iso_price.dividePrice)({ of: "$2.50", by: 1e6 })
|
|
65
|
+
},
|
|
66
|
+
input: (0, import_iso_price.dividePrice)({ of: "$2.50", by: 1e6 }),
|
|
67
|
+
output: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
gain: {
|
|
71
|
+
size: { context: { tokens: 128e3 } },
|
|
72
|
+
grades: { swe: 33.2, mmlu: 88.7, humaneval: 90.2 },
|
|
73
|
+
cutoff: "2023-10-01",
|
|
74
|
+
domain: "ALL",
|
|
75
|
+
skills: { tooluse: true, vision: true }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
48
78
|
},
|
|
49
|
-
"openai/gpt
|
|
79
|
+
"openai/gpt/4o-mini": {
|
|
50
80
|
model: "gpt-4o-mini",
|
|
51
|
-
description: "gpt-4o-mini - fast and cost-effective multimodal model"
|
|
81
|
+
description: "gpt-4o-mini - fast and cost-effective multimodal model",
|
|
82
|
+
spec: {
|
|
83
|
+
cost: {
|
|
84
|
+
time: {
|
|
85
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
86
|
+
latency: { milliseconds: 300 }
|
|
87
|
+
},
|
|
88
|
+
cash: {
|
|
89
|
+
per: "token",
|
|
90
|
+
cache: {
|
|
91
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.075", by: 1e6 }),
|
|
92
|
+
set: (0, import_iso_price.dividePrice)({ of: "$0.15", by: 1e6 })
|
|
93
|
+
},
|
|
94
|
+
input: (0, import_iso_price.dividePrice)({ of: "$0.15", by: 1e6 }),
|
|
95
|
+
output: (0, import_iso_price.dividePrice)({ of: "$0.60", by: 1e6 })
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
gain: {
|
|
99
|
+
size: { context: { tokens: 128e3 } },
|
|
100
|
+
grades: { mmlu: 82, humaneval: 87 },
|
|
101
|
+
cutoff: "2023-10-01",
|
|
102
|
+
domain: "ALL",
|
|
103
|
+
skills: { tooluse: true, vision: true }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
52
106
|
},
|
|
53
|
-
"openai/gpt
|
|
107
|
+
"openai/gpt/4-turbo": {
|
|
54
108
|
model: "gpt-4-turbo",
|
|
55
|
-
description: "gpt-4-turbo - high capability with vision support"
|
|
109
|
+
description: "gpt-4-turbo - high capability with vision support",
|
|
110
|
+
spec: {
|
|
111
|
+
cost: {
|
|
112
|
+
time: {
|
|
113
|
+
speed: { tokens: 80, per: { seconds: 1 } },
|
|
114
|
+
latency: { milliseconds: 600 }
|
|
115
|
+
},
|
|
116
|
+
cash: {
|
|
117
|
+
per: "token",
|
|
118
|
+
cache: {
|
|
119
|
+
get: (0, import_iso_price.dividePrice)({ of: "$5.00", by: 1e6 }),
|
|
120
|
+
set: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
121
|
+
},
|
|
122
|
+
input: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 }),
|
|
123
|
+
output: (0, import_iso_price.dividePrice)({ of: "$30.00", by: 1e6 })
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
gain: {
|
|
127
|
+
size: { context: { tokens: 128e3 } },
|
|
128
|
+
grades: { mmlu: 86.4, humaneval: 87.1 },
|
|
129
|
+
cutoff: "2023-12-01",
|
|
130
|
+
domain: "ALL",
|
|
131
|
+
skills: { tooluse: true, vision: true }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
// =========================================================================
|
|
136
|
+
// gpt-4.1 family (april 2025)
|
|
137
|
+
// =========================================================================
|
|
138
|
+
"openai/gpt/4.1": {
|
|
139
|
+
model: "gpt-4.1",
|
|
140
|
+
description: "gpt-4.1 - 1M context with improved instruction follow",
|
|
141
|
+
spec: {
|
|
142
|
+
cost: {
|
|
143
|
+
time: {
|
|
144
|
+
speed: { tokens: 100, per: { seconds: 1 } },
|
|
145
|
+
latency: { milliseconds: 400 }
|
|
146
|
+
},
|
|
147
|
+
cash: {
|
|
148
|
+
per: "token",
|
|
149
|
+
cache: {
|
|
150
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.50", by: 1e6 }),
|
|
151
|
+
set: (0, import_iso_price.dividePrice)({ of: "$2.00", by: 1e6 })
|
|
152
|
+
},
|
|
153
|
+
input: (0, import_iso_price.dividePrice)({ of: "$2.00", by: 1e6 }),
|
|
154
|
+
output: (0, import_iso_price.dividePrice)({ of: "$8.00", by: 1e6 })
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
gain: {
|
|
158
|
+
size: { context: { tokens: 1e6 } },
|
|
159
|
+
grades: {},
|
|
160
|
+
cutoff: "2024-06-01",
|
|
161
|
+
domain: "ALL",
|
|
162
|
+
skills: { tooluse: true, vision: true }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"openai/gpt/4.1-mini": {
|
|
167
|
+
model: "gpt-4.1-mini",
|
|
168
|
+
description: "gpt-4.1-mini - fast and cost-effective",
|
|
169
|
+
spec: {
|
|
170
|
+
cost: {
|
|
171
|
+
time: {
|
|
172
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
173
|
+
latency: { milliseconds: 250 }
|
|
174
|
+
},
|
|
175
|
+
cash: {
|
|
176
|
+
per: "token",
|
|
177
|
+
cache: {
|
|
178
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.10", by: 1e6 }),
|
|
179
|
+
set: (0, import_iso_price.dividePrice)({ of: "$0.40", by: 1e6 })
|
|
180
|
+
},
|
|
181
|
+
input: (0, import_iso_price.dividePrice)({ of: "$0.40", by: 1e6 }),
|
|
182
|
+
output: (0, import_iso_price.dividePrice)({ of: "$1.60", by: 1e6 })
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
gain: {
|
|
186
|
+
size: { context: { tokens: 128e3 } },
|
|
187
|
+
grades: {},
|
|
188
|
+
cutoff: "2024-06-01",
|
|
189
|
+
domain: "ALL",
|
|
190
|
+
skills: { tooluse: true, vision: true }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
56
193
|
},
|
|
57
|
-
"openai/
|
|
194
|
+
"openai/gpt/4.1-nano": {
|
|
195
|
+
model: "gpt-4.1-nano",
|
|
196
|
+
description: "gpt-4.1-nano - ultra low cost for simple tasks",
|
|
197
|
+
spec: {
|
|
198
|
+
cost: {
|
|
199
|
+
time: {
|
|
200
|
+
speed: { tokens: 200, per: { seconds: 1 } },
|
|
201
|
+
latency: { milliseconds: 150 }
|
|
202
|
+
},
|
|
203
|
+
cash: {
|
|
204
|
+
per: "token",
|
|
205
|
+
cache: {
|
|
206
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.025", by: 1e6 }),
|
|
207
|
+
set: (0, import_iso_price.dividePrice)({ of: "$0.10", by: 1e6 })
|
|
208
|
+
},
|
|
209
|
+
input: (0, import_iso_price.dividePrice)({ of: "$0.10", by: 1e6 }),
|
|
210
|
+
output: (0, import_iso_price.dividePrice)({ of: "$0.40", by: 1e6 })
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
gain: {
|
|
214
|
+
size: { context: { tokens: 1e6 } },
|
|
215
|
+
grades: {},
|
|
216
|
+
cutoff: "2024-06-01",
|
|
217
|
+
domain: "ALL",
|
|
218
|
+
skills: { tooluse: true }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
// =========================================================================
|
|
223
|
+
// o1 family
|
|
224
|
+
// =========================================================================
|
|
225
|
+
"openai/o/1": {
|
|
58
226
|
model: "o1",
|
|
59
|
-
description: "o1 - advanced
|
|
227
|
+
description: "o1 - advanced reason model for complex problems",
|
|
228
|
+
spec: {
|
|
229
|
+
cost: {
|
|
230
|
+
time: {
|
|
231
|
+
speed: { tokens: 50, per: { seconds: 1 } },
|
|
232
|
+
latency: { seconds: 2 }
|
|
233
|
+
},
|
|
234
|
+
cash: {
|
|
235
|
+
per: "token",
|
|
236
|
+
cache: {
|
|
237
|
+
get: (0, import_iso_price.dividePrice)({ of: "$7.50", by: 1e6 }),
|
|
238
|
+
set: (0, import_iso_price.dividePrice)({ of: "$15.00", by: 1e6 })
|
|
239
|
+
},
|
|
240
|
+
input: (0, import_iso_price.dividePrice)({ of: "$15.00", by: 1e6 }),
|
|
241
|
+
output: (0, import_iso_price.dividePrice)({ of: "$60.00", by: 1e6 })
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
gain: {
|
|
245
|
+
size: { context: { tokens: 2e5 } },
|
|
246
|
+
grades: { swe: 48.9, mmlu: 92.3, humaneval: 94.8 },
|
|
247
|
+
cutoff: "2023-10-01",
|
|
248
|
+
domain: "ALL",
|
|
249
|
+
skills: { tooluse: true, vision: true }
|
|
250
|
+
}
|
|
251
|
+
}
|
|
60
252
|
},
|
|
61
|
-
"openai/
|
|
253
|
+
"openai/o/1-mini": {
|
|
62
254
|
model: "o1-mini",
|
|
63
|
-
description: "o1-mini - fast
|
|
255
|
+
description: "o1-mini - fast reason model for code and math",
|
|
256
|
+
spec: {
|
|
257
|
+
cost: {
|
|
258
|
+
time: {
|
|
259
|
+
speed: { tokens: 80, per: { seconds: 1 } },
|
|
260
|
+
latency: { seconds: 1 }
|
|
261
|
+
},
|
|
262
|
+
cash: {
|
|
263
|
+
per: "token",
|
|
264
|
+
cache: {
|
|
265
|
+
get: (0, import_iso_price.dividePrice)({ of: "$1.50", by: 1e6 }),
|
|
266
|
+
set: (0, import_iso_price.dividePrice)({ of: "$3.00", by: 1e6 })
|
|
267
|
+
},
|
|
268
|
+
input: (0, import_iso_price.dividePrice)({ of: "$3.00", by: 1e6 }),
|
|
269
|
+
output: (0, import_iso_price.dividePrice)({ of: "$12.00", by: 1e6 })
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
gain: {
|
|
273
|
+
size: { context: { tokens: 128e3 } },
|
|
274
|
+
grades: { humaneval: 92.4 },
|
|
275
|
+
cutoff: "2023-10-01",
|
|
276
|
+
domain: "ALL",
|
|
277
|
+
skills: { tooluse: true }
|
|
278
|
+
}
|
|
279
|
+
}
|
|
64
280
|
},
|
|
65
|
-
"openai/
|
|
281
|
+
"openai/o/1-preview": {
|
|
66
282
|
model: "o1-preview",
|
|
67
|
-
description: "o1-preview - preview of advanced
|
|
283
|
+
description: "o1-preview - preview of advanced reason capabilities",
|
|
284
|
+
spec: {
|
|
285
|
+
cost: {
|
|
286
|
+
time: {
|
|
287
|
+
speed: { tokens: 40, per: { seconds: 1 } },
|
|
288
|
+
latency: { seconds: 3 }
|
|
289
|
+
},
|
|
290
|
+
cash: {
|
|
291
|
+
per: "token",
|
|
292
|
+
cache: {
|
|
293
|
+
get: (0, import_iso_price.dividePrice)({ of: "$7.50", by: 1e6 }),
|
|
294
|
+
set: (0, import_iso_price.dividePrice)({ of: "$15.00", by: 1e6 })
|
|
295
|
+
},
|
|
296
|
+
input: (0, import_iso_price.dividePrice)({ of: "$15.00", by: 1e6 }),
|
|
297
|
+
output: (0, import_iso_price.dividePrice)({ of: "$60.00", by: 1e6 })
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
gain: {
|
|
301
|
+
size: { context: { tokens: 128e3 } },
|
|
302
|
+
grades: { mmlu: 90.8 },
|
|
303
|
+
cutoff: "2023-10-01",
|
|
304
|
+
domain: "ALL",
|
|
305
|
+
skills: { tooluse: true }
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
// =========================================================================
|
|
310
|
+
// o3 family (april 2025)
|
|
311
|
+
// =========================================================================
|
|
312
|
+
"openai/o/3": {
|
|
313
|
+
model: "o3",
|
|
314
|
+
description: "o3 - frontier reason model for code, math, science",
|
|
315
|
+
spec: {
|
|
316
|
+
cost: {
|
|
317
|
+
time: {
|
|
318
|
+
speed: { tokens: 60, per: { seconds: 1 } },
|
|
319
|
+
latency: { seconds: 2 }
|
|
320
|
+
},
|
|
321
|
+
cash: {
|
|
322
|
+
per: "token",
|
|
323
|
+
cache: {
|
|
324
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.10", by: 1e6 }),
|
|
325
|
+
set: (0, import_iso_price.dividePrice)({ of: "$0.40", by: 1e6 })
|
|
326
|
+
},
|
|
327
|
+
input: (0, import_iso_price.dividePrice)({ of: "$0.40", by: 1e6 }),
|
|
328
|
+
output: (0, import_iso_price.dividePrice)({ of: "$1.60", by: 1e6 })
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
gain: {
|
|
332
|
+
size: { context: { tokens: 2e5 } },
|
|
333
|
+
grades: {},
|
|
334
|
+
cutoff: "2024-06-01",
|
|
335
|
+
domain: "ALL",
|
|
336
|
+
skills: { tooluse: true, vision: true }
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
"openai/o/3-mini": {
|
|
341
|
+
model: "o3-mini",
|
|
342
|
+
description: "o3-mini - fast reason for code and math",
|
|
343
|
+
spec: {
|
|
344
|
+
cost: {
|
|
345
|
+
time: {
|
|
346
|
+
speed: { tokens: 100, per: { seconds: 1 } },
|
|
347
|
+
latency: { seconds: 1 }
|
|
348
|
+
},
|
|
349
|
+
cash: {
|
|
350
|
+
per: "token",
|
|
351
|
+
cache: {
|
|
352
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.275", by: 1e6 }),
|
|
353
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.10", by: 1e6 })
|
|
354
|
+
},
|
|
355
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.10", by: 1e6 }),
|
|
356
|
+
output: (0, import_iso_price.dividePrice)({ of: "$4.40", by: 1e6 })
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
gain: {
|
|
360
|
+
size: { context: { tokens: 2e5 } },
|
|
361
|
+
grades: {},
|
|
362
|
+
cutoff: "2024-06-01",
|
|
363
|
+
domain: "ALL",
|
|
364
|
+
skills: { tooluse: true }
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"openai/o/3-pro": {
|
|
369
|
+
model: "o3-pro",
|
|
370
|
+
description: "o3-pro - highest tier with extended compute",
|
|
371
|
+
spec: {
|
|
372
|
+
cost: {
|
|
373
|
+
time: {
|
|
374
|
+
speed: { tokens: 30, per: { seconds: 1 } },
|
|
375
|
+
latency: { seconds: 5 }
|
|
376
|
+
},
|
|
377
|
+
cash: {
|
|
378
|
+
per: "token",
|
|
379
|
+
cache: {
|
|
380
|
+
get: (0, import_iso_price.dividePrice)({ of: "$5.00", by: 1e6 }),
|
|
381
|
+
set: (0, import_iso_price.dividePrice)({ of: "$20.00", by: 1e6 })
|
|
382
|
+
},
|
|
383
|
+
input: (0, import_iso_price.dividePrice)({ of: "$20.00", by: 1e6 }),
|
|
384
|
+
output: (0, import_iso_price.dividePrice)({ of: "$80.00", by: 1e6 })
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
gain: {
|
|
388
|
+
size: { context: { tokens: 2e5 } },
|
|
389
|
+
grades: {},
|
|
390
|
+
cutoff: "2024-06-01",
|
|
391
|
+
domain: "ALL",
|
|
392
|
+
skills: { tooluse: true, vision: true }
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
// =========================================================================
|
|
397
|
+
// o4 family (april 2025)
|
|
398
|
+
// =========================================================================
|
|
399
|
+
"openai/o/4-mini": {
|
|
400
|
+
model: "o4-mini",
|
|
401
|
+
description: "o4-mini - fast efficient reason model",
|
|
402
|
+
spec: {
|
|
403
|
+
cost: {
|
|
404
|
+
time: {
|
|
405
|
+
speed: { tokens: 100, per: { seconds: 1 } },
|
|
406
|
+
latency: { seconds: 1 }
|
|
407
|
+
},
|
|
408
|
+
cash: {
|
|
409
|
+
per: "token",
|
|
410
|
+
cache: {
|
|
411
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.275", by: 1e6 }),
|
|
412
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.10", by: 1e6 })
|
|
413
|
+
},
|
|
414
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.10", by: 1e6 }),
|
|
415
|
+
output: (0, import_iso_price.dividePrice)({ of: "$4.40", by: 1e6 })
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
gain: {
|
|
419
|
+
size: { context: { tokens: 2e5 } },
|
|
420
|
+
grades: {},
|
|
421
|
+
cutoff: "2024-06-01",
|
|
422
|
+
domain: "ALL",
|
|
423
|
+
skills: { tooluse: true, vision: true }
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
// =========================================================================
|
|
428
|
+
// gpt-5 family (august 2025)
|
|
429
|
+
// =========================================================================
|
|
430
|
+
"openai/gpt/5": {
|
|
431
|
+
model: "gpt-5",
|
|
432
|
+
description: "gpt-5 - frontier multimodal model",
|
|
433
|
+
spec: {
|
|
434
|
+
cost: {
|
|
435
|
+
time: {
|
|
436
|
+
speed: { tokens: 120, per: { seconds: 1 } },
|
|
437
|
+
latency: { milliseconds: 400 }
|
|
438
|
+
},
|
|
439
|
+
cash: {
|
|
440
|
+
per: "token",
|
|
441
|
+
cache: {
|
|
442
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.125", by: 1e6 }),
|
|
443
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 })
|
|
444
|
+
},
|
|
445
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 }),
|
|
446
|
+
output: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
gain: {
|
|
450
|
+
size: { context: { tokens: 4e5 } },
|
|
451
|
+
grades: {},
|
|
452
|
+
cutoff: "2024-09-01",
|
|
453
|
+
domain: "ALL",
|
|
454
|
+
skills: { tooluse: true, vision: true }
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
"openai/gpt/5-mini": {
|
|
459
|
+
model: "gpt-5-mini",
|
|
460
|
+
description: "gpt-5-mini - fast and cost-effective",
|
|
461
|
+
spec: {
|
|
462
|
+
cost: {
|
|
463
|
+
time: {
|
|
464
|
+
speed: { tokens: 180, per: { seconds: 1 } },
|
|
465
|
+
latency: { milliseconds: 200 }
|
|
466
|
+
},
|
|
467
|
+
cash: {
|
|
468
|
+
per: "token",
|
|
469
|
+
cache: {
|
|
470
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.025", by: 1e6 }),
|
|
471
|
+
set: (0, import_iso_price.dividePrice)({ of: "$0.25", by: 1e6 })
|
|
472
|
+
},
|
|
473
|
+
input: (0, import_iso_price.dividePrice)({ of: "$0.25", by: 1e6 }),
|
|
474
|
+
output: (0, import_iso_price.dividePrice)({ of: "$2.00", by: 1e6 })
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
gain: {
|
|
478
|
+
size: { context: { tokens: 4e5 } },
|
|
479
|
+
grades: {},
|
|
480
|
+
cutoff: "2024-05-01",
|
|
481
|
+
domain: "ALL",
|
|
482
|
+
skills: { tooluse: true, vision: true }
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
"openai/gpt/5-pro": {
|
|
487
|
+
model: "gpt-5-pro",
|
|
488
|
+
description: "gpt-5-pro - highest tier with xhigh reason support",
|
|
489
|
+
spec: {
|
|
490
|
+
cost: {
|
|
491
|
+
time: {
|
|
492
|
+
speed: { tokens: 40, per: { seconds: 1 } },
|
|
493
|
+
latency: { seconds: 3 }
|
|
494
|
+
},
|
|
495
|
+
cash: {
|
|
496
|
+
per: "token",
|
|
497
|
+
cache: {
|
|
498
|
+
get: (0, import_iso_price.dividePrice)({ of: "$1.50", by: 1e6 }),
|
|
499
|
+
set: (0, import_iso_price.dividePrice)({ of: "$15.00", by: 1e6 })
|
|
500
|
+
},
|
|
501
|
+
input: (0, import_iso_price.dividePrice)({ of: "$15.00", by: 1e6 }),
|
|
502
|
+
output: (0, import_iso_price.dividePrice)({ of: "$120.00", by: 1e6 })
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
gain: {
|
|
506
|
+
size: { context: { tokens: 272e3 } },
|
|
507
|
+
grades: {},
|
|
508
|
+
cutoff: "2024-09-01",
|
|
509
|
+
domain: "ALL",
|
|
510
|
+
skills: { tooluse: true, vision: true }
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
"openai/gpt/5-thoughtful": {
|
|
515
|
+
model: "gpt-5-thinking",
|
|
516
|
+
description: "gpt-5-thinking - deep reason for complex problems",
|
|
517
|
+
spec: {
|
|
518
|
+
cost: {
|
|
519
|
+
time: {
|
|
520
|
+
speed: { tokens: 60, per: { seconds: 1 } },
|
|
521
|
+
latency: { seconds: 2 }
|
|
522
|
+
},
|
|
523
|
+
cash: {
|
|
524
|
+
per: "token",
|
|
525
|
+
cache: {
|
|
526
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.125", by: 1e6 }),
|
|
527
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 })
|
|
528
|
+
},
|
|
529
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 }),
|
|
530
|
+
output: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
gain: {
|
|
534
|
+
size: { context: { tokens: 4e5 } },
|
|
535
|
+
grades: {},
|
|
536
|
+
cutoff: "2024-09-01",
|
|
537
|
+
domain: "ALL",
|
|
538
|
+
skills: { tooluse: true, vision: true }
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
"openai/gpt/5-thoughtful-mini": {
|
|
543
|
+
model: "gpt-5-thinking-mini",
|
|
544
|
+
description: "gpt-5-thinking-mini - fast reason model",
|
|
545
|
+
spec: {
|
|
546
|
+
cost: {
|
|
547
|
+
time: {
|
|
548
|
+
speed: { tokens: 100, per: { seconds: 1 } },
|
|
549
|
+
latency: { seconds: 1 }
|
|
550
|
+
},
|
|
551
|
+
cash: {
|
|
552
|
+
per: "token",
|
|
553
|
+
cache: {
|
|
554
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.025", by: 1e6 }),
|
|
555
|
+
set: (0, import_iso_price.dividePrice)({ of: "$0.25", by: 1e6 })
|
|
556
|
+
},
|
|
557
|
+
input: (0, import_iso_price.dividePrice)({ of: "$0.25", by: 1e6 }),
|
|
558
|
+
output: (0, import_iso_price.dividePrice)({ of: "$2.00", by: 1e6 })
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
gain: {
|
|
562
|
+
size: { context: { tokens: 4e5 } },
|
|
563
|
+
grades: {},
|
|
564
|
+
cutoff: "2024-09-01",
|
|
565
|
+
domain: "ALL",
|
|
566
|
+
skills: { tooluse: true }
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
// =========================================================================
|
|
571
|
+
// gpt-5.1 family (november 2025)
|
|
572
|
+
// =========================================================================
|
|
573
|
+
"openai/gpt/5.1-instant": {
|
|
574
|
+
model: "gpt-5.1-chat-latest",
|
|
575
|
+
description: "gpt-5.1-instant - fast model for everyday tasks",
|
|
576
|
+
spec: {
|
|
577
|
+
cost: {
|
|
578
|
+
time: {
|
|
579
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
580
|
+
latency: { milliseconds: 300 }
|
|
581
|
+
},
|
|
582
|
+
cash: {
|
|
583
|
+
per: "token",
|
|
584
|
+
cache: {
|
|
585
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.125", by: 1e6 }),
|
|
586
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 })
|
|
587
|
+
},
|
|
588
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 }),
|
|
589
|
+
output: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
gain: {
|
|
593
|
+
size: { context: { tokens: 4e5 } },
|
|
594
|
+
grades: {},
|
|
595
|
+
cutoff: "2024-09-01",
|
|
596
|
+
domain: "ALL",
|
|
597
|
+
skills: { tooluse: true, vision: true }
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
"openai/gpt/5.1-thoughtful": {
|
|
602
|
+
model: "gpt-5.1",
|
|
603
|
+
description: "gpt-5.1 - deep reason with adaptive thought",
|
|
604
|
+
spec: {
|
|
605
|
+
cost: {
|
|
606
|
+
time: {
|
|
607
|
+
speed: { tokens: 80, per: { seconds: 1 } },
|
|
608
|
+
latency: { seconds: 1 }
|
|
609
|
+
},
|
|
610
|
+
cash: {
|
|
611
|
+
per: "token",
|
|
612
|
+
cache: {
|
|
613
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.125", by: 1e6 }),
|
|
614
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 })
|
|
615
|
+
},
|
|
616
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.25", by: 1e6 }),
|
|
617
|
+
output: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
gain: {
|
|
621
|
+
size: { context: { tokens: 4e5 } },
|
|
622
|
+
grades: {},
|
|
623
|
+
cutoff: "2024-09-01",
|
|
624
|
+
domain: "ALL",
|
|
625
|
+
skills: { tooluse: true, vision: true }
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
// =========================================================================
|
|
630
|
+
// gpt-5.2 family (december 2025)
|
|
631
|
+
// =========================================================================
|
|
632
|
+
"openai/gpt/5.2-instant": {
|
|
633
|
+
model: "gpt-5.2-instant",
|
|
634
|
+
description: "gpt-5.2-instant - low latency for daily tasks",
|
|
635
|
+
spec: {
|
|
636
|
+
cost: {
|
|
637
|
+
time: {
|
|
638
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
639
|
+
latency: { milliseconds: 300 }
|
|
640
|
+
},
|
|
641
|
+
cash: {
|
|
642
|
+
per: "token",
|
|
643
|
+
cache: {
|
|
644
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.175", by: 1e6 }),
|
|
645
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.75", by: 1e6 })
|
|
646
|
+
},
|
|
647
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.75", by: 1e6 }),
|
|
648
|
+
output: (0, import_iso_price.dividePrice)({ of: "$14.00", by: 1e6 })
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
gain: {
|
|
652
|
+
size: { context: { tokens: 4e5 } },
|
|
653
|
+
grades: {},
|
|
654
|
+
cutoff: "2025-08-01",
|
|
655
|
+
domain: "ALL",
|
|
656
|
+
skills: { tooluse: true, vision: true }
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
"openai/gpt/5.2-pro": {
|
|
661
|
+
model: "gpt-5.2-pro",
|
|
662
|
+
description: "gpt-5.2-pro - highest tier with xhigh reason support",
|
|
663
|
+
spec: {
|
|
664
|
+
cost: {
|
|
665
|
+
time: {
|
|
666
|
+
speed: { tokens: 40, per: { seconds: 1 } },
|
|
667
|
+
latency: { seconds: 3 }
|
|
668
|
+
},
|
|
669
|
+
cash: {
|
|
670
|
+
per: "token",
|
|
671
|
+
cache: {
|
|
672
|
+
get: (0, import_iso_price.dividePrice)({ of: "$2.10", by: 1e6 }),
|
|
673
|
+
set: (0, import_iso_price.dividePrice)({ of: "$21.00", by: 1e6 })
|
|
674
|
+
},
|
|
675
|
+
input: (0, import_iso_price.dividePrice)({ of: "$21.00", by: 1e6 }),
|
|
676
|
+
output: (0, import_iso_price.dividePrice)({ of: "$168.00", by: 1e6 })
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
gain: {
|
|
680
|
+
size: { context: { tokens: 4e5 } },
|
|
681
|
+
grades: {},
|
|
682
|
+
cutoff: "2025-08-01",
|
|
683
|
+
domain: "ALL",
|
|
684
|
+
skills: { tooluse: true, vision: true }
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
"openai/gpt/5.2-thoughtful": {
|
|
689
|
+
model: "gpt-5.2",
|
|
690
|
+
description: "gpt-5.2 - most advanced frontier model for deep reason",
|
|
691
|
+
spec: {
|
|
692
|
+
cost: {
|
|
693
|
+
time: {
|
|
694
|
+
speed: { tokens: 60, per: { seconds: 1 } },
|
|
695
|
+
latency: { seconds: 2 }
|
|
696
|
+
},
|
|
697
|
+
cash: {
|
|
698
|
+
per: "token",
|
|
699
|
+
cache: {
|
|
700
|
+
get: (0, import_iso_price.dividePrice)({ of: "$0.175", by: 1e6 }),
|
|
701
|
+
set: (0, import_iso_price.dividePrice)({ of: "$1.75", by: 1e6 })
|
|
702
|
+
},
|
|
703
|
+
input: (0, import_iso_price.dividePrice)({ of: "$1.75", by: 1e6 }),
|
|
704
|
+
output: (0, import_iso_price.dividePrice)({ of: "$14.00", by: 1e6 })
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
gain: {
|
|
708
|
+
size: { context: { tokens: 4e5 } },
|
|
709
|
+
grades: {},
|
|
710
|
+
cutoff: "2025-08-01",
|
|
711
|
+
domain: "ALL",
|
|
712
|
+
skills: { tooluse: true, vision: true }
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
// =========================================================================
|
|
717
|
+
// codex family (agentic code via codex sdk)
|
|
718
|
+
// =========================================================================
|
|
719
|
+
"openai/gpt/codex/5.1-max": {
|
|
720
|
+
model: "gpt-5.1-codex-max",
|
|
721
|
+
description: "gpt-5.1-codex-max - optimized for long-horizon agentic code",
|
|
722
|
+
spec: {
|
|
723
|
+
cost: {
|
|
724
|
+
time: {
|
|
725
|
+
speed: { tokens: 80, per: { seconds: 1 } },
|
|
726
|
+
latency: { seconds: 2 }
|
|
727
|
+
},
|
|
728
|
+
cash: {
|
|
729
|
+
per: "token",
|
|
730
|
+
cache: {
|
|
731
|
+
get: (0, import_iso_price.dividePrice)({ of: "$3.75", by: 1e6 }),
|
|
732
|
+
set: (0, import_iso_price.dividePrice)({ of: "$7.50", by: 1e6 })
|
|
733
|
+
},
|
|
734
|
+
input: (0, import_iso_price.dividePrice)({ of: "$7.50", by: 1e6 }),
|
|
735
|
+
output: (0, import_iso_price.dividePrice)({ of: "$30.00", by: 1e6 })
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
gain: {
|
|
739
|
+
size: { context: { tokens: 4e5 } },
|
|
740
|
+
grades: { swe: 72 },
|
|
741
|
+
cutoff: "2024-09-01",
|
|
742
|
+
domain: "SOFTWARE",
|
|
743
|
+
skills: { tooluse: true }
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
"openai/gpt/codex/5.1-mini": {
|
|
748
|
+
model: "gpt-5.1-codex-mini",
|
|
749
|
+
description: "gpt-5.1-codex-mini - fast and cost-effective",
|
|
750
|
+
spec: {
|
|
751
|
+
cost: {
|
|
752
|
+
time: {
|
|
753
|
+
speed: { tokens: 120, per: { seconds: 1 } },
|
|
754
|
+
latency: { seconds: 1 }
|
|
755
|
+
},
|
|
756
|
+
cash: {
|
|
757
|
+
per: "token",
|
|
758
|
+
cache: {
|
|
759
|
+
get: (0, import_iso_price.dividePrice)({ of: "$1.50", by: 1e6 }),
|
|
760
|
+
set: (0, import_iso_price.dividePrice)({ of: "$3.00", by: 1e6 })
|
|
761
|
+
},
|
|
762
|
+
input: (0, import_iso_price.dividePrice)({ of: "$3.00", by: 1e6 }),
|
|
763
|
+
output: (0, import_iso_price.dividePrice)({ of: "$12.00", by: 1e6 })
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
gain: {
|
|
767
|
+
size: { context: { tokens: 4e5 } },
|
|
768
|
+
grades: { swe: 55 },
|
|
769
|
+
cutoff: "2024-09-01",
|
|
770
|
+
domain: "SOFTWARE",
|
|
771
|
+
skills: { tooluse: true }
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
"openai/gpt/codex/5.2": {
|
|
776
|
+
model: "gpt-5.2-codex",
|
|
777
|
+
description: "gpt-5.2-codex - most advanced agentic code model",
|
|
778
|
+
spec: {
|
|
779
|
+
cost: {
|
|
780
|
+
time: {
|
|
781
|
+
speed: { tokens: 60, per: { seconds: 1 } },
|
|
782
|
+
latency: { seconds: 3 }
|
|
783
|
+
},
|
|
784
|
+
cash: {
|
|
785
|
+
per: "token",
|
|
786
|
+
cache: {
|
|
787
|
+
get: (0, import_iso_price.dividePrice)({ of: "$5.00", by: 1e6 }),
|
|
788
|
+
set: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 })
|
|
789
|
+
},
|
|
790
|
+
input: (0, import_iso_price.dividePrice)({ of: "$10.00", by: 1e6 }),
|
|
791
|
+
output: (0, import_iso_price.dividePrice)({ of: "$40.00", by: 1e6 })
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
gain: {
|
|
795
|
+
size: { context: { tokens: 4e5 } },
|
|
796
|
+
grades: { swe: 78 },
|
|
797
|
+
cutoff: "2025-08-01",
|
|
798
|
+
domain: "SOFTWARE",
|
|
799
|
+
skills: { tooluse: true }
|
|
800
|
+
}
|
|
801
|
+
}
|
|
68
802
|
}
|
|
69
803
|
};
|
|
804
|
+
|
|
805
|
+
// src/domain.operations/atoms/genBrainAtom.ts
|
|
70
806
|
var genBrainAtom = (input) => {
|
|
71
|
-
const config =
|
|
72
|
-
return new
|
|
807
|
+
const config = CONFIG_BY_ATOM_SLUG[input.slug];
|
|
808
|
+
return new import_brains.BrainAtom({
|
|
73
809
|
repo: "openai",
|
|
74
810
|
slug: input.slug,
|
|
75
811
|
description: config.description,
|
|
812
|
+
spec: config.spec,
|
|
76
813
|
/**
|
|
77
814
|
* .what = stateless inference (no tool use)
|
|
78
|
-
* .why = provides direct model access for
|
|
815
|
+
* .why = provides direct model access for reason tasks
|
|
79
816
|
*/
|
|
80
817
|
ask: async (askInput, context) => {
|
|
81
|
-
const
|
|
818
|
+
const startTime = Date.now();
|
|
819
|
+
const systemPrompt = askInput.role.briefs ? await (0, import_brains.castBriefsToPrompt)({ briefs: askInput.role.briefs }) : void 0;
|
|
82
820
|
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
821
|
const jsonSchema = import_zod.z.toJSONSchema(askInput.schema.output);
|
|
89
822
|
const isObjectSchema = typeof jsonSchema === "object" && jsonSchema !== null && "type" in jsonSchema && jsonSchema.type === "object";
|
|
90
|
-
const
|
|
823
|
+
const fullPrompt = systemPrompt ? `${systemPrompt}
|
|
824
|
+
|
|
825
|
+
---
|
|
826
|
+
|
|
827
|
+
${askInput.prompt}` : askInput.prompt;
|
|
828
|
+
const priorMessages = askInput.on?.episode?.exchanges.flatMap((exchange) => [
|
|
829
|
+
{ role: "user", content: exchange.input },
|
|
830
|
+
{ role: "assistant", content: exchange.output }
|
|
831
|
+
]) ?? [];
|
|
832
|
+
const inputMessages = [
|
|
833
|
+
...priorMessages,
|
|
834
|
+
{ role: "user", content: fullPrompt }
|
|
835
|
+
];
|
|
836
|
+
const response = await openai.responses.create({
|
|
91
837
|
model: config.model,
|
|
92
|
-
|
|
838
|
+
input: inputMessages,
|
|
93
839
|
...isObjectSchema && {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
840
|
+
text: {
|
|
841
|
+
format: {
|
|
842
|
+
type: "json_schema",
|
|
97
843
|
name: "response",
|
|
98
844
|
strict: true,
|
|
99
845
|
schema: jsonSchema
|
|
@@ -101,12 +847,61 @@ var genBrainAtom = (input) => {
|
|
|
101
847
|
}
|
|
102
848
|
}
|
|
103
849
|
});
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
850
|
+
const outputItem = response.output.find(
|
|
851
|
+
(item) => item.type === "message"
|
|
852
|
+
);
|
|
853
|
+
const textContent = outputItem?.type === "message" ? outputItem.content.find((c) => c.type === "output_text") : void 0;
|
|
854
|
+
const content = textContent?.type === "output_text" ? textContent.text : "";
|
|
855
|
+
const tokensInput = response.usage?.input_tokens ?? 0;
|
|
856
|
+
const tokensOutput = response.usage?.output_tokens ?? 0;
|
|
857
|
+
const tokensCacheGet = response.usage?.input_tokens_details?.cached_tokens ?? 0;
|
|
858
|
+
const elapsedMs = Date.now() - startTime;
|
|
859
|
+
const charsInput = fullPrompt.length;
|
|
860
|
+
const charsOutput = content.length;
|
|
861
|
+
const size = {
|
|
862
|
+
tokens: {
|
|
863
|
+
input: tokensInput,
|
|
864
|
+
output: tokensOutput,
|
|
865
|
+
cache: { get: tokensCacheGet, set: 0 }
|
|
866
|
+
},
|
|
867
|
+
chars: {
|
|
868
|
+
input: charsInput,
|
|
869
|
+
output: charsOutput,
|
|
870
|
+
cache: { get: 0, set: 0 }
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
const { cash } = (0, import_brains.calcBrainOutputCost)({
|
|
874
|
+
for: { tokens: size.tokens },
|
|
875
|
+
with: { cost: { cash: config.spec.cost.cash } }
|
|
876
|
+
});
|
|
877
|
+
const metrics = new import_brains.BrainOutputMetrics({
|
|
878
|
+
size,
|
|
879
|
+
cost: {
|
|
880
|
+
time: { milliseconds: elapsedMs },
|
|
881
|
+
cash
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
const output = isObjectSchema ? askInput.schema.output.parse(JSON.parse(content)) : askInput.schema.output.parse(content);
|
|
885
|
+
const continuables = await (0, import_brains.genBrainContinuables)({
|
|
886
|
+
for: { grain: "atom" },
|
|
887
|
+
on: {
|
|
888
|
+
episode: askInput.on?.episode ?? null,
|
|
889
|
+
series: null
|
|
890
|
+
},
|
|
891
|
+
with: {
|
|
892
|
+
exchange: {
|
|
893
|
+
input: askInput.prompt,
|
|
894
|
+
output: content,
|
|
895
|
+
exid: response.id
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
return new import_brains.BrainOutput({
|
|
900
|
+
output,
|
|
901
|
+
metrics,
|
|
902
|
+
episode: continuables.episode,
|
|
903
|
+
series: continuables.series
|
|
904
|
+
});
|
|
110
905
|
}
|
|
111
906
|
});
|
|
112
907
|
};
|
|
@@ -466,7 +1261,8 @@ var Codex = class {
|
|
|
466
1261
|
};
|
|
467
1262
|
|
|
468
1263
|
// src/domain.operations/repls/genBrainRepl.ts
|
|
469
|
-
var
|
|
1264
|
+
var import_helpful_errors = require("helpful-errors");
|
|
1265
|
+
var import_brains2 = require("rhachet/brains");
|
|
470
1266
|
var import_wrapper_fns = require("wrapper-fns");
|
|
471
1267
|
|
|
472
1268
|
// src/infra/schema/asJsonSchema.ts
|
|
@@ -476,24 +1272,18 @@ var asJsonSchema = (input) => {
|
|
|
476
1272
|
};
|
|
477
1273
|
|
|
478
1274
|
// src/domain.operations/repls/genBrainRepl.ts
|
|
479
|
-
var
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
"openai/codex/mini":
|
|
490
|
-
|
|
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
|
-
}
|
|
1275
|
+
var CONFIG_BY_REPL_SLUG = {
|
|
1276
|
+
// default
|
|
1277
|
+
"openai/codex": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.1-max"],
|
|
1278
|
+
// version only (defaults to max tier)
|
|
1279
|
+
"openai/codex/5.1": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.1-max"],
|
|
1280
|
+
"openai/codex/5.2": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.2"],
|
|
1281
|
+
// capability tier (defaults to 5.1)
|
|
1282
|
+
"openai/codex/mini": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.1-mini"],
|
|
1283
|
+
"openai/codex/max": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.1-max"],
|
|
1284
|
+
// explicit 5.1 versions
|
|
1285
|
+
"openai/codex/mini/5.1": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.1-mini"],
|
|
1286
|
+
"openai/codex/max/5.1": CONFIG_BY_ATOM_SLUG["openai/gpt/codex/5.1-max"]
|
|
497
1287
|
};
|
|
498
1288
|
var composePromptWithSystem = (userPrompt, systemPrompt) => {
|
|
499
1289
|
if (!systemPrompt) return userPrompt;
|
|
@@ -503,8 +1293,17 @@ var composePromptWithSystem = (userPrompt, systemPrompt) => {
|
|
|
503
1293
|
|
|
504
1294
|
${userPrompt}`;
|
|
505
1295
|
};
|
|
1296
|
+
var EXID_PREFIX = "openai/codex";
|
|
1297
|
+
var encodeExid = (threadId) => `${EXID_PREFIX}/${threadId}`;
|
|
1298
|
+
var decodeExid = (exid) => {
|
|
1299
|
+
if (!exid.startsWith(`${EXID_PREFIX}/`)) return { valid: false };
|
|
1300
|
+
const threadId = exid.slice(`${EXID_PREFIX}/`.length);
|
|
1301
|
+
if (!threadId) return { valid: false };
|
|
1302
|
+
return { valid: true, threadId };
|
|
1303
|
+
};
|
|
506
1304
|
var invokeCodex = async (input) => {
|
|
507
|
-
const
|
|
1305
|
+
const startTime = Date.now();
|
|
1306
|
+
const systemPrompt = input.role.briefs ? await (0, import_brains2.castBriefsToPrompt)({ briefs: input.role.briefs }) : void 0;
|
|
508
1307
|
const outputSchema = asJsonSchema({
|
|
509
1308
|
schema: input.schema.output
|
|
510
1309
|
});
|
|
@@ -512,41 +1311,125 @@ var invokeCodex = async (input) => {
|
|
|
512
1311
|
apiKey: process.env.OPENAI_API_KEY
|
|
513
1312
|
});
|
|
514
1313
|
const sandboxMode = input.mode === "ask" ? "read-only" : "workspace-write";
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
1314
|
+
const threadOptions = { model: input.model, sandboxMode };
|
|
1315
|
+
const priorExid = input.on?.episode?.exid ?? null;
|
|
1316
|
+
const thread = (() => {
|
|
1317
|
+
if (!priorExid) return codex.startThread(threadOptions);
|
|
1318
|
+
const decoded = decodeExid(priorExid);
|
|
1319
|
+
if (!decoded.valid)
|
|
1320
|
+
throw new import_helpful_errors.BadRequestError(
|
|
1321
|
+
"episode continuation failed: exid is not from openai/codex. cross-supplier continuation is not supported.",
|
|
1322
|
+
{ priorExid }
|
|
1323
|
+
);
|
|
1324
|
+
return codex.resumeThread(decoded.threadId, threadOptions);
|
|
1325
|
+
})();
|
|
519
1326
|
const fullPrompt = composePromptWithSystem(input.prompt, systemPrompt);
|
|
520
1327
|
const response = await (0, import_wrapper_fns.withRetry)(
|
|
521
1328
|
(0, import_wrapper_fns.withTimeout)(async () => thread.run(fullPrompt, { outputSchema }), {
|
|
522
1329
|
threshold: { seconds: 60 }
|
|
523
1330
|
})
|
|
524
1331
|
)();
|
|
525
|
-
|
|
1332
|
+
const elapsedMs = Date.now() - startTime;
|
|
1333
|
+
const content = response.finalResponse;
|
|
1334
|
+
const output = input.schema.output.parse(JSON.parse(content));
|
|
1335
|
+
const usage = response.usage ?? {
|
|
1336
|
+
input_tokens: 0,
|
|
1337
|
+
output_tokens: 0,
|
|
1338
|
+
cached_input_tokens: 0
|
|
1339
|
+
};
|
|
1340
|
+
const tokensInput = usage.input_tokens ?? 0;
|
|
1341
|
+
const tokensOutput = usage.output_tokens ?? 0;
|
|
1342
|
+
const tokensCacheGet = usage.cached_input_tokens ?? 0;
|
|
1343
|
+
const tokensCacheSet = 0;
|
|
1344
|
+
const charsInput = (systemPrompt?.length ?? 0) + input.prompt.length;
|
|
1345
|
+
const charsOutput = content.length;
|
|
1346
|
+
const size = {
|
|
1347
|
+
tokens: {
|
|
1348
|
+
input: tokensInput,
|
|
1349
|
+
output: tokensOutput,
|
|
1350
|
+
cache: { get: tokensCacheGet, set: tokensCacheSet }
|
|
1351
|
+
},
|
|
1352
|
+
chars: {
|
|
1353
|
+
input: charsInput,
|
|
1354
|
+
output: charsOutput,
|
|
1355
|
+
cache: { get: 0, set: 0 }
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
const { cash } = (0, import_brains2.calcBrainOutputCost)({
|
|
1359
|
+
for: { tokens: size.tokens },
|
|
1360
|
+
with: { cost: { cash: input.spec.cost.cash } }
|
|
1361
|
+
});
|
|
1362
|
+
const metrics = new import_brains2.BrainOutputMetrics({
|
|
1363
|
+
size,
|
|
1364
|
+
cost: {
|
|
1365
|
+
time: { milliseconds: elapsedMs },
|
|
1366
|
+
cash
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
const threadExid = thread.id ? encodeExid(thread.id) : null;
|
|
1370
|
+
const continuables = await (0, import_brains2.genBrainContinuables)({
|
|
1371
|
+
for: { grain: "repl" },
|
|
1372
|
+
on: {
|
|
1373
|
+
episode: input.on?.episode ?? null,
|
|
1374
|
+
series: input.on?.series ?? null
|
|
1375
|
+
},
|
|
1376
|
+
with: {
|
|
1377
|
+
exchange: {
|
|
1378
|
+
input: input.prompt,
|
|
1379
|
+
output: content,
|
|
1380
|
+
exid: thread.id
|
|
1381
|
+
},
|
|
1382
|
+
episode: { exid: threadExid }
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
return new import_brains2.BrainOutput({
|
|
1386
|
+
output,
|
|
1387
|
+
metrics,
|
|
1388
|
+
episode: continuables.episode,
|
|
1389
|
+
series: continuables.series
|
|
1390
|
+
});
|
|
526
1391
|
};
|
|
527
1392
|
var genBrainRepl = (input) => {
|
|
528
|
-
const config =
|
|
529
|
-
|
|
530
|
-
return new import_rhachet2.BrainRepl({
|
|
1393
|
+
const config = CONFIG_BY_REPL_SLUG[input.slug];
|
|
1394
|
+
return new import_brains2.BrainRepl({
|
|
531
1395
|
repo: "openai",
|
|
532
|
-
slug:
|
|
1396
|
+
slug: input.slug,
|
|
533
1397
|
description: config.description,
|
|
1398
|
+
spec: config.spec,
|
|
534
1399
|
/**
|
|
535
1400
|
* .what = readonly analysis (research, queries, code review)
|
|
536
|
-
* .why = provides safe, non-
|
|
1401
|
+
* .why = provides safe, non-mutate agent interactions via read-only sandbox
|
|
537
1402
|
*/
|
|
538
|
-
ask: async (askInput, _context) => invokeCodex({
|
|
1403
|
+
ask: async (askInput, _context) => invokeCodex({
|
|
1404
|
+
mode: "ask",
|
|
1405
|
+
model: config.model,
|
|
1406
|
+
spec: config.spec,
|
|
1407
|
+
on: askInput.on,
|
|
1408
|
+
plugs: askInput.plugs,
|
|
1409
|
+
role: askInput.role,
|
|
1410
|
+
prompt: askInput.prompt,
|
|
1411
|
+
schema: askInput.schema
|
|
1412
|
+
}),
|
|
539
1413
|
/**
|
|
540
1414
|
* .what = read+write actions (code changes, file edits)
|
|
541
1415
|
* .why = provides full agentic capabilities via workspace-write sandbox
|
|
542
1416
|
*/
|
|
543
|
-
act: async (actInput, _context) => invokeCodex({
|
|
1417
|
+
act: async (actInput, _context) => invokeCodex({
|
|
1418
|
+
mode: "act",
|
|
1419
|
+
model: config.model,
|
|
1420
|
+
spec: config.spec,
|
|
1421
|
+
on: actInput.on,
|
|
1422
|
+
plugs: actInput.plugs,
|
|
1423
|
+
role: actInput.role,
|
|
1424
|
+
prompt: actInput.prompt,
|
|
1425
|
+
schema: actInput.schema
|
|
1426
|
+
})
|
|
544
1427
|
});
|
|
545
1428
|
};
|
|
546
1429
|
|
|
547
1430
|
// src/contract/sdk/index.ts
|
|
548
1431
|
var getBrainAtomsByOpenAI = () => {
|
|
549
|
-
return [genBrainAtom({ slug: "openai/gpt
|
|
1432
|
+
return [genBrainAtom({ slug: "openai/gpt/4o" })];
|
|
550
1433
|
};
|
|
551
1434
|
var getBrainReplsByOpenAI = () => {
|
|
552
1435
|
return [genBrainRepl({ slug: "openai/codex" })];
|