@meetopenbot/codex 1.0.10

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/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # openbot-plugin-codex
2
+
3
+ Minimal Codex plugin scaffold for OpenBot.
4
+
5
+ ## What is included
6
+
7
+ - A plugin registry export (`plugin`) compatible with OpenBot
8
+ - One tool definition: `codex_run`
9
+ - One action handler: `action:codex_run`
10
+ - `@openai/codex-sdk` integration via `Codex` + `thread.run(...)`
11
+
12
+ ## Local usage
13
+
14
+ 1. Install dependencies:
15
+
16
+ `npm install`
17
+
18
+ 2. Build:
19
+
20
+ `npm run build`
21
+
22
+ 3. Load `dist/index.js` from your OpenBot plugin registry/runtime.
23
+
24
+ ## Runtime config
25
+
26
+ Set an API key using one of the following:
27
+
28
+ - `CODEX_API_KEY` environment variable
29
+ - `OPENAI_API_KEY` environment variable
30
+ - `apiKey` in plugin options
31
+
32
+ Optional plugin options:
33
+
34
+ - `model` (defaults to `gpt-5-codex`)
35
+ - `baseURL` (for custom OpenAI-compatible endpoints)
36
+ - `workingDirectory`, `skipGitRepoCheck`, `sandboxMode`, `approvalPolicy`
37
+ - `networkAccessEnabled`, `webSearchMode`, `threadId`
@@ -0,0 +1 @@
1
+ <svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Codex</title><path d="M19.503 0H4.496A4.496 4.496 0 000 4.496v15.007A4.496 4.496 0 004.496 24h15.007A4.496 4.496 0 0024 19.503V4.496A4.496 4.496 0 0019.503 0z" fill="#fff"></path><path d="M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z" fill="url(#lobe-icons-codex-_R_0_)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-codex-_R_0_" x1="12" x2="12" y1="3" y2="21"><stop stop-color="#B1A7FF"></stop><stop offset=".5" stop-color="#7A9DFF"></stop><stop offset="1" stop-color="#3941FF"></stop></linearGradient></defs></svg>
package/dist/index.js ADDED
@@ -0,0 +1,543 @@
1
+ // node_modules/.pnpm/@openai+codex-sdk@0.111.0/node_modules/@openai/codex-sdk/dist/index.js
2
+ import { promises as fs } from "fs";
3
+ import os from "os";
4
+ import path from "path";
5
+ import { spawn } from "child_process";
6
+ import path2 from "path";
7
+ import readline from "readline";
8
+ import { createRequire } from "module";
9
+ async function createOutputSchemaFile(schema) {
10
+ if (schema === void 0) {
11
+ return { cleanup: async () => {
12
+ } };
13
+ }
14
+ if (!isJsonObject(schema)) {
15
+ throw new Error("outputSchema must be a plain JSON object");
16
+ }
17
+ const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), "codex-output-schema-"));
18
+ const schemaPath = path.join(schemaDir, "schema.json");
19
+ const cleanup = async () => {
20
+ try {
21
+ await fs.rm(schemaDir, { recursive: true, force: true });
22
+ } catch {
23
+ }
24
+ };
25
+ try {
26
+ await fs.writeFile(schemaPath, JSON.stringify(schema), "utf8");
27
+ return { schemaPath, cleanup };
28
+ } catch (error) {
29
+ await cleanup();
30
+ throw error;
31
+ }
32
+ }
33
+ function isJsonObject(value) {
34
+ return typeof value === "object" && value !== null && !Array.isArray(value);
35
+ }
36
+ var Thread = class {
37
+ _exec;
38
+ _options;
39
+ _id;
40
+ _threadOptions;
41
+ /** Returns the ID of the thread. Populated after the first turn starts. */
42
+ get id() {
43
+ return this._id;
44
+ }
45
+ /* @internal */
46
+ constructor(exec, options, threadOptions, id = null) {
47
+ this._exec = exec;
48
+ this._options = options;
49
+ this._id = id;
50
+ this._threadOptions = threadOptions;
51
+ }
52
+ /** Provides the input to the agent and streams events as they are produced during the turn. */
53
+ async runStreamed(input, turnOptions = {}) {
54
+ return { events: this.runStreamedInternal(input, turnOptions) };
55
+ }
56
+ async *runStreamedInternal(input, turnOptions = {}) {
57
+ const { schemaPath, cleanup } = await createOutputSchemaFile(turnOptions.outputSchema);
58
+ const options = this._threadOptions;
59
+ const { prompt, images } = normalizeInput(input);
60
+ const generator = this._exec.run({
61
+ input: prompt,
62
+ baseUrl: this._options.baseUrl,
63
+ apiKey: this._options.apiKey,
64
+ threadId: this._id,
65
+ images,
66
+ model: options?.model,
67
+ sandboxMode: options?.sandboxMode,
68
+ workingDirectory: options?.workingDirectory,
69
+ skipGitRepoCheck: options?.skipGitRepoCheck,
70
+ outputSchemaFile: schemaPath,
71
+ modelReasoningEffort: options?.modelReasoningEffort,
72
+ signal: turnOptions.signal,
73
+ networkAccessEnabled: options?.networkAccessEnabled,
74
+ webSearchMode: options?.webSearchMode,
75
+ webSearchEnabled: options?.webSearchEnabled,
76
+ approvalPolicy: options?.approvalPolicy,
77
+ additionalDirectories: options?.additionalDirectories
78
+ });
79
+ try {
80
+ for await (const item of generator) {
81
+ let parsed;
82
+ try {
83
+ parsed = JSON.parse(item);
84
+ } catch (error) {
85
+ throw new Error(`Failed to parse item: ${item}`, { cause: error });
86
+ }
87
+ if (parsed.type === "thread.started") {
88
+ this._id = parsed.thread_id;
89
+ }
90
+ yield parsed;
91
+ }
92
+ } finally {
93
+ await cleanup();
94
+ }
95
+ }
96
+ /** Provides the input to the agent and returns the completed turn. */
97
+ async run(input, turnOptions = {}) {
98
+ const generator = this.runStreamedInternal(input, turnOptions);
99
+ const items = [];
100
+ let finalResponse = "";
101
+ let usage = null;
102
+ let turnFailure = null;
103
+ for await (const event of generator) {
104
+ if (event.type === "item.completed") {
105
+ if (event.item.type === "agent_message") {
106
+ finalResponse = event.item.text;
107
+ }
108
+ items.push(event.item);
109
+ } else if (event.type === "turn.completed") {
110
+ usage = event.usage;
111
+ } else if (event.type === "turn.failed") {
112
+ turnFailure = event.error;
113
+ break;
114
+ }
115
+ }
116
+ if (turnFailure) {
117
+ throw new Error(turnFailure.message);
118
+ }
119
+ return { items, finalResponse, usage };
120
+ }
121
+ };
122
+ function normalizeInput(input) {
123
+ if (typeof input === "string") {
124
+ return { prompt: input, images: [] };
125
+ }
126
+ const promptParts = [];
127
+ const images = [];
128
+ for (const item of input) {
129
+ if (item.type === "text") {
130
+ promptParts.push(item.text);
131
+ } else if (item.type === "local_image") {
132
+ images.push(item.path);
133
+ }
134
+ }
135
+ return { prompt: promptParts.join("\n\n"), images };
136
+ }
137
+ var INTERNAL_ORIGINATOR_ENV = "CODEX_INTERNAL_ORIGINATOR_OVERRIDE";
138
+ var TYPESCRIPT_SDK_ORIGINATOR = "codex_sdk_ts";
139
+ var CODEX_NPM_NAME = "@openai/codex";
140
+ var PLATFORM_PACKAGE_BY_TARGET = {
141
+ "x86_64-unknown-linux-musl": "@openai/codex-linux-x64",
142
+ "aarch64-unknown-linux-musl": "@openai/codex-linux-arm64",
143
+ "x86_64-apple-darwin": "@openai/codex-darwin-x64",
144
+ "aarch64-apple-darwin": "@openai/codex-darwin-arm64",
145
+ "x86_64-pc-windows-msvc": "@openai/codex-win32-x64",
146
+ "aarch64-pc-windows-msvc": "@openai/codex-win32-arm64"
147
+ };
148
+ var moduleRequire = createRequire(import.meta.url);
149
+ var CodexExec = class {
150
+ executablePath;
151
+ envOverride;
152
+ configOverrides;
153
+ constructor(executablePath = null, env, configOverrides) {
154
+ this.executablePath = executablePath || findCodexPath();
155
+ this.envOverride = env;
156
+ this.configOverrides = configOverrides;
157
+ }
158
+ async *run(args) {
159
+ const commandArgs = ["exec", "--experimental-json"];
160
+ if (this.configOverrides) {
161
+ for (const override of serializeConfigOverrides(this.configOverrides)) {
162
+ commandArgs.push("--config", override);
163
+ }
164
+ }
165
+ if (args.model) {
166
+ commandArgs.push("--model", args.model);
167
+ }
168
+ if (args.sandboxMode) {
169
+ commandArgs.push("--sandbox", args.sandboxMode);
170
+ }
171
+ if (args.workingDirectory) {
172
+ commandArgs.push("--cd", args.workingDirectory);
173
+ }
174
+ if (args.additionalDirectories?.length) {
175
+ for (const dir of args.additionalDirectories) {
176
+ commandArgs.push("--add-dir", dir);
177
+ }
178
+ }
179
+ if (args.skipGitRepoCheck) {
180
+ commandArgs.push("--skip-git-repo-check");
181
+ }
182
+ if (args.outputSchemaFile) {
183
+ commandArgs.push("--output-schema", args.outputSchemaFile);
184
+ }
185
+ if (args.modelReasoningEffort) {
186
+ commandArgs.push("--config", `model_reasoning_effort="${args.modelReasoningEffort}"`);
187
+ }
188
+ if (args.networkAccessEnabled !== void 0) {
189
+ commandArgs.push(
190
+ "--config",
191
+ `sandbox_workspace_write.network_access=${args.networkAccessEnabled}`
192
+ );
193
+ }
194
+ if (args.webSearchMode) {
195
+ commandArgs.push("--config", `web_search="${args.webSearchMode}"`);
196
+ } else if (args.webSearchEnabled === true) {
197
+ commandArgs.push("--config", `web_search="live"`);
198
+ } else if (args.webSearchEnabled === false) {
199
+ commandArgs.push("--config", `web_search="disabled"`);
200
+ }
201
+ if (args.approvalPolicy) {
202
+ commandArgs.push("--config", `approval_policy="${args.approvalPolicy}"`);
203
+ }
204
+ if (args.threadId) {
205
+ commandArgs.push("resume", args.threadId);
206
+ }
207
+ if (args.images?.length) {
208
+ for (const image of args.images) {
209
+ commandArgs.push("--image", image);
210
+ }
211
+ }
212
+ const env = {};
213
+ if (this.envOverride) {
214
+ Object.assign(env, this.envOverride);
215
+ } else {
216
+ for (const [key, value] of Object.entries(process.env)) {
217
+ if (value !== void 0) {
218
+ env[key] = value;
219
+ }
220
+ }
221
+ }
222
+ if (!env[INTERNAL_ORIGINATOR_ENV]) {
223
+ env[INTERNAL_ORIGINATOR_ENV] = TYPESCRIPT_SDK_ORIGINATOR;
224
+ }
225
+ if (args.baseUrl) {
226
+ env.OPENAI_BASE_URL = args.baseUrl;
227
+ }
228
+ if (args.apiKey) {
229
+ env.CODEX_API_KEY = args.apiKey;
230
+ }
231
+ const child = spawn(this.executablePath, commandArgs, {
232
+ env,
233
+ signal: args.signal
234
+ });
235
+ let spawnError = null;
236
+ child.once("error", (err) => spawnError = err);
237
+ if (!child.stdin) {
238
+ child.kill();
239
+ throw new Error("Child process has no stdin");
240
+ }
241
+ child.stdin.write(args.input);
242
+ child.stdin.end();
243
+ if (!child.stdout) {
244
+ child.kill();
245
+ throw new Error("Child process has no stdout");
246
+ }
247
+ const stderrChunks = [];
248
+ if (child.stderr) {
249
+ child.stderr.on("data", (data) => {
250
+ stderrChunks.push(data);
251
+ });
252
+ }
253
+ const exitPromise = new Promise(
254
+ (resolve) => {
255
+ child.once("exit", (code, signal) => {
256
+ resolve({ code, signal });
257
+ });
258
+ }
259
+ );
260
+ const rl = readline.createInterface({
261
+ input: child.stdout,
262
+ crlfDelay: Infinity
263
+ });
264
+ try {
265
+ for await (const line of rl) {
266
+ yield line;
267
+ }
268
+ if (spawnError) throw spawnError;
269
+ const { code, signal } = await exitPromise;
270
+ if (code !== 0 || signal) {
271
+ const stderrBuffer = Buffer.concat(stderrChunks);
272
+ const detail = signal ? `signal ${signal}` : `code ${code ?? 1}`;
273
+ throw new Error(`Codex Exec exited with ${detail}: ${stderrBuffer.toString("utf8")}`);
274
+ }
275
+ } finally {
276
+ rl.close();
277
+ child.removeAllListeners();
278
+ try {
279
+ if (!child.killed) child.kill();
280
+ } catch {
281
+ }
282
+ }
283
+ }
284
+ };
285
+ function serializeConfigOverrides(configOverrides) {
286
+ const overrides = [];
287
+ flattenConfigOverrides(configOverrides, "", overrides);
288
+ return overrides;
289
+ }
290
+ function flattenConfigOverrides(value, prefix, overrides) {
291
+ if (!isPlainObject(value)) {
292
+ if (prefix) {
293
+ overrides.push(`${prefix}=${toTomlValue(value, prefix)}`);
294
+ return;
295
+ } else {
296
+ throw new Error("Codex config overrides must be a plain object");
297
+ }
298
+ }
299
+ const entries = Object.entries(value);
300
+ if (!prefix && entries.length === 0) {
301
+ return;
302
+ }
303
+ if (prefix && entries.length === 0) {
304
+ overrides.push(`${prefix}={}`);
305
+ return;
306
+ }
307
+ for (const [key, child] of entries) {
308
+ if (!key) {
309
+ throw new Error("Codex config override keys must be non-empty strings");
310
+ }
311
+ if (child === void 0) {
312
+ continue;
313
+ }
314
+ const path3 = prefix ? `${prefix}.${key}` : key;
315
+ if (isPlainObject(child)) {
316
+ flattenConfigOverrides(child, path3, overrides);
317
+ } else {
318
+ overrides.push(`${path3}=${toTomlValue(child, path3)}`);
319
+ }
320
+ }
321
+ }
322
+ function toTomlValue(value, path3) {
323
+ if (typeof value === "string") {
324
+ return JSON.stringify(value);
325
+ } else if (typeof value === "number") {
326
+ if (!Number.isFinite(value)) {
327
+ throw new Error(`Codex config override at ${path3} must be a finite number`);
328
+ }
329
+ return `${value}`;
330
+ } else if (typeof value === "boolean") {
331
+ return value ? "true" : "false";
332
+ } else if (Array.isArray(value)) {
333
+ const rendered = value.map((item, index) => toTomlValue(item, `${path3}[${index}]`));
334
+ return `[${rendered.join(", ")}]`;
335
+ } else if (isPlainObject(value)) {
336
+ const parts = [];
337
+ for (const [key, child] of Object.entries(value)) {
338
+ if (!key) {
339
+ throw new Error("Codex config override keys must be non-empty strings");
340
+ }
341
+ if (child === void 0) {
342
+ continue;
343
+ }
344
+ parts.push(`${formatTomlKey(key)} = ${toTomlValue(child, `${path3}.${key}`)}`);
345
+ }
346
+ return `{${parts.join(", ")}}`;
347
+ } else if (value === null) {
348
+ throw new Error(`Codex config override at ${path3} cannot be null`);
349
+ } else {
350
+ const typeName = typeof value;
351
+ throw new Error(`Unsupported Codex config override value at ${path3}: ${typeName}`);
352
+ }
353
+ }
354
+ var TOML_BARE_KEY = /^[A-Za-z0-9_-]+$/;
355
+ function formatTomlKey(key) {
356
+ return TOML_BARE_KEY.test(key) ? key : JSON.stringify(key);
357
+ }
358
+ function isPlainObject(value) {
359
+ return typeof value === "object" && value !== null && !Array.isArray(value);
360
+ }
361
+ function findCodexPath() {
362
+ const { platform, arch } = process;
363
+ let targetTriple = null;
364
+ switch (platform) {
365
+ case "linux":
366
+ case "android":
367
+ switch (arch) {
368
+ case "x64":
369
+ targetTriple = "x86_64-unknown-linux-musl";
370
+ break;
371
+ case "arm64":
372
+ targetTriple = "aarch64-unknown-linux-musl";
373
+ break;
374
+ default:
375
+ break;
376
+ }
377
+ break;
378
+ case "darwin":
379
+ switch (arch) {
380
+ case "x64":
381
+ targetTriple = "x86_64-apple-darwin";
382
+ break;
383
+ case "arm64":
384
+ targetTriple = "aarch64-apple-darwin";
385
+ break;
386
+ default:
387
+ break;
388
+ }
389
+ break;
390
+ case "win32":
391
+ switch (arch) {
392
+ case "x64":
393
+ targetTriple = "x86_64-pc-windows-msvc";
394
+ break;
395
+ case "arm64":
396
+ targetTriple = "aarch64-pc-windows-msvc";
397
+ break;
398
+ default:
399
+ break;
400
+ }
401
+ break;
402
+ default:
403
+ break;
404
+ }
405
+ if (!targetTriple) {
406
+ throw new Error(`Unsupported platform: ${platform} (${arch})`);
407
+ }
408
+ const platformPackage = PLATFORM_PACKAGE_BY_TARGET[targetTriple];
409
+ if (!platformPackage) {
410
+ throw new Error(`Unsupported target triple: ${targetTriple}`);
411
+ }
412
+ let vendorRoot;
413
+ try {
414
+ const codexPackageJsonPath = moduleRequire.resolve(`${CODEX_NPM_NAME}/package.json`);
415
+ const codexRequire = createRequire(codexPackageJsonPath);
416
+ const platformPackageJsonPath = codexRequire.resolve(`${platformPackage}/package.json`);
417
+ vendorRoot = path2.join(path2.dirname(platformPackageJsonPath), "vendor");
418
+ } catch {
419
+ throw new Error(
420
+ `Unable to locate Codex CLI binaries. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies.`
421
+ );
422
+ }
423
+ const archRoot = path2.join(vendorRoot, targetTriple);
424
+ const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
425
+ const binaryPath = path2.join(archRoot, "codex", codexBinaryName);
426
+ return binaryPath;
427
+ }
428
+ var Codex = class {
429
+ exec;
430
+ options;
431
+ constructor(options = {}) {
432
+ const { codexPathOverride, env, config } = options;
433
+ this.exec = new CodexExec(codexPathOverride, env, config);
434
+ this.options = options;
435
+ }
436
+ /**
437
+ * Starts a new conversation with an agent.
438
+ * @returns A new thread instance.
439
+ */
440
+ startThread(options = {}) {
441
+ return new Thread(this.exec, this.options, options);
442
+ }
443
+ /**
444
+ * Resumes a conversation with an agent based on the thread id.
445
+ * Threads are persisted in ~/.codex/sessions.
446
+ *
447
+ * @param id The id of the thread to resume.
448
+ * @returns A new thread instance.
449
+ */
450
+ resumeThread(id, options = {}) {
451
+ return new Thread(this.exec, this.options, options, id);
452
+ }
453
+ };
454
+
455
+ // index.ts
456
+ var codexPlugin = (options = { model: "gpt-5-codex" }) => (builder) => {
457
+ const env = globalThis?.process?.env || {};
458
+ const apiKey = options.apiKey ?? env.CODEX_API_KEY ?? env.OPENAI_API_KEY;
459
+ const codexPathOverride = options.codexPathOverride ?? env.CODEX_PATH ?? env.CODEX_CLI_PATH;
460
+ const model = options.model?.split("/").pop() || "gpt-5-codex";
461
+ let client;
462
+ const getClient = () => {
463
+ if (!client) {
464
+ client = new Codex({
465
+ apiKey,
466
+ ...codexPathOverride && { codexPathOverride },
467
+ ...options.baseURL && { baseUrl: options.baseURL }
468
+ });
469
+ }
470
+ return client;
471
+ };
472
+ let thread = null;
473
+ const getThread = (state) => {
474
+ if (thread) return thread;
475
+ const workingDirectory = options.workingDirectory || state?.channelDetails?.cwd || globalThis?.process?.cwd() || "/tmp";
476
+ const threadOptions = {
477
+ model,
478
+ workingDirectory,
479
+ skipGitRepoCheck: options.skipGitRepoCheck ?? false,
480
+ sandboxMode: options.sandboxMode ?? "workspace-write",
481
+ ...options.approvalPolicy && { approvalPolicy: options.approvalPolicy },
482
+ ...typeof options.networkAccessEnabled === "boolean" && { networkAccessEnabled: options.networkAccessEnabled },
483
+ ...options.webSearchMode && { webSearchMode: options.webSearchMode }
484
+ };
485
+ const threadId = state?.threadId;
486
+ thread = threadId ? getClient().resumeThread(threadId, threadOptions) : getClient().startThread(threadOptions);
487
+ if (!threadId && state) {
488
+ state.threadId = thread.id;
489
+ }
490
+ return thread;
491
+ };
492
+ builder.on("agent:invoke", async function* (event, ctx) {
493
+ const { content } = event.data;
494
+ if (!content) {
495
+ yield { type: "agent:output", data: { content: "No content provided." } };
496
+ return;
497
+ }
498
+ try {
499
+ const turn = await getThread(ctx?.state).runStreamed(content);
500
+ for await (const chunk of turn.events) {
501
+ if (chunk.type === "item.completed") {
502
+ if (chunk.item.type === "agent_message") {
503
+ yield { type: "agent:output", data: { content: chunk.item.text } };
504
+ }
505
+ if (chunk.item.type === "reasoning") {
506
+ yield { type: "agent:output", data: { content: chunk.item.text } };
507
+ }
508
+ if (chunk.item.type === "command_execution") {
509
+ yield { type: "agent:output", data: { content: chunk.item.command } };
510
+ }
511
+ if (chunk.item.type === "file_change") {
512
+ yield { type: "agent:output", data: { content: chunk.item.changes.map((change) => `${change.path}: ${change.action}`).join("\n") } };
513
+ }
514
+ if (chunk.item.type === "error") {
515
+ yield { type: "agent:output", data: { content: `Error: ${chunk.item.message}` } };
516
+ }
517
+ if (chunk.item.type === "todo_list") {
518
+ yield { type: "agent:output", data: { content: chunk.item.items.map((item) => `- ${item.text} (${item.completed ? "completed" : "pending"})`).join("\n") } };
519
+ }
520
+ if (chunk.item.type === "web_search") {
521
+ yield { type: "agent:output", data: { content: `Query: ${chunk.item.query}` } };
522
+ }
523
+ }
524
+ }
525
+ } catch (error) {
526
+ yield {
527
+ type: "agent:output",
528
+ data: { content: `Error: ${error?.message || "Codex request failed."}` }
529
+ };
530
+ }
531
+ });
532
+ };
533
+ var plugin = {
534
+ id: "codex",
535
+ name: "Codex",
536
+ description: "Codex integration tools for OpenBot",
537
+ kind: "runtime",
538
+ factory: (options) => codexPlugin(options)
539
+ };
540
+ export {
541
+ codexPlugin,
542
+ plugin
543
+ };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@meetopenbot/codex",
3
+ "version": "1.0.10",
4
+ "type": "module",
5
+ "description": "Codex tools plugin for OpenBot",
6
+ "main": "./dist/index.js",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": "./dist/index.js"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "assets"
16
+ ],
17
+ "scripts": {
18
+ "build": "esbuild index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:ai --external:zod --external:melony --external:@melony/ui-kit",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "dependencies": {
22
+ "@openai/codex-sdk": "^0.111.0",
23
+ "melony": "^0.2.9"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^25.6.0",
27
+ "esbuild": "^0.21.0",
28
+ "zod": "^3.23.8"
29
+ }
30
+ }