@agentchatme/codex 0.5.1 → 0.5.3

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.
@@ -46,8 +46,8 @@ var require_windows = __commonJS({
46
46
  "use strict";
47
47
  module.exports = isexe;
48
48
  isexe.sync = sync;
49
- var fs8 = __require("fs");
50
- function checkPathExt(path12, options) {
49
+ var fs9 = __require("fs");
50
+ function checkPathExt(path13, options) {
51
51
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
52
52
  if (!pathext) {
53
53
  return true;
@@ -58,25 +58,25 @@ var require_windows = __commonJS({
58
58
  }
59
59
  for (var i = 0; i < pathext.length; i++) {
60
60
  var p = pathext[i].toLowerCase();
61
- if (p && path12.substr(-p.length).toLowerCase() === p) {
61
+ if (p && path13.substr(-p.length).toLowerCase() === p) {
62
62
  return true;
63
63
  }
64
64
  }
65
65
  return false;
66
66
  }
67
- function checkStat(stat, path12, options) {
67
+ function checkStat(stat, path13, options) {
68
68
  if (!stat.isSymbolicLink() && !stat.isFile()) {
69
69
  return false;
70
70
  }
71
- return checkPathExt(path12, options);
71
+ return checkPathExt(path13, options);
72
72
  }
73
- function isexe(path12, options, cb) {
74
- fs8.stat(path12, function(er, stat) {
75
- cb(er, er ? false : checkStat(stat, path12, options));
73
+ function isexe(path13, options, cb) {
74
+ fs9.stat(path13, function(er, stat) {
75
+ cb(er, er ? false : checkStat(stat, path13, options));
76
76
  });
77
77
  }
78
- function sync(path12, options) {
79
- return checkStat(fs8.statSync(path12), path12, options);
78
+ function sync(path13, options) {
79
+ return checkStat(fs9.statSync(path13), path13, options);
80
80
  }
81
81
  }
82
82
  });
@@ -87,14 +87,14 @@ var require_mode = __commonJS({
87
87
  "use strict";
88
88
  module.exports = isexe;
89
89
  isexe.sync = sync;
90
- var fs8 = __require("fs");
91
- function isexe(path12, options, cb) {
92
- fs8.stat(path12, function(er, stat) {
90
+ var fs9 = __require("fs");
91
+ function isexe(path13, options, cb) {
92
+ fs9.stat(path13, function(er, stat) {
93
93
  cb(er, er ? false : checkStat(stat, options));
94
94
  });
95
95
  }
96
- function sync(path12, options) {
97
- return checkStat(fs8.statSync(path12), options);
96
+ function sync(path13, options) {
97
+ return checkStat(fs9.statSync(path13), options);
98
98
  }
99
99
  function checkStat(stat, options) {
100
100
  return stat.isFile() && checkMode(stat, options);
@@ -119,7 +119,7 @@ var require_mode = __commonJS({
119
119
  var require_isexe = __commonJS({
120
120
  "node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
121
121
  "use strict";
122
- var fs8 = __require("fs");
122
+ var fs9 = __require("fs");
123
123
  var core;
124
124
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
125
125
  core = require_windows();
@@ -128,7 +128,7 @@ var require_isexe = __commonJS({
128
128
  }
129
129
  module.exports = isexe;
130
130
  isexe.sync = sync;
131
- function isexe(path12, options, cb) {
131
+ function isexe(path13, options, cb) {
132
132
  if (typeof options === "function") {
133
133
  cb = options;
134
134
  options = {};
@@ -137,17 +137,17 @@ var require_isexe = __commonJS({
137
137
  if (typeof Promise !== "function") {
138
138
  throw new TypeError("callback not provided");
139
139
  }
140
- return new Promise(function(resolve10, reject) {
141
- isexe(path12, options || {}, function(er, is) {
140
+ return new Promise(function(resolve11, reject) {
141
+ isexe(path13, options || {}, function(er, is) {
142
142
  if (er) {
143
143
  reject(er);
144
144
  } else {
145
- resolve10(is);
145
+ resolve11(is);
146
146
  }
147
147
  });
148
148
  });
149
149
  }
150
- core(path12, options || {}, function(er, is) {
150
+ core(path13, options || {}, function(er, is) {
151
151
  if (er) {
152
152
  if (er.code === "EACCES" || options && options.ignoreErrors) {
153
153
  er = null;
@@ -157,9 +157,9 @@ var require_isexe = __commonJS({
157
157
  cb(er, is);
158
158
  });
159
159
  }
160
- function sync(path12, options) {
160
+ function sync(path13, options) {
161
161
  try {
162
- return core.sync(path12, options || {});
162
+ return core.sync(path13, options || {});
163
163
  } catch (er) {
164
164
  if (options && options.ignoreErrors || er.code === "EACCES") {
165
165
  return false;
@@ -176,7 +176,7 @@ var require_which = __commonJS({
176
176
  "node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
177
177
  "use strict";
178
178
  var isWindows2 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
179
- var path12 = __require("path");
179
+ var path13 = __require("path");
180
180
  var COLON = isWindows2 ? ";" : ":";
181
181
  var isexe = require_isexe();
182
182
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -209,27 +209,27 @@ var require_which = __commonJS({
209
209
  opt = {};
210
210
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
211
211
  const found = [];
212
- const step = (i) => new Promise((resolve10, reject) => {
212
+ const step = (i) => new Promise((resolve11, reject) => {
213
213
  if (i === pathEnv.length)
214
- return opt.all && found.length ? resolve10(found) : reject(getNotFoundError(cmd));
214
+ return opt.all && found.length ? resolve11(found) : reject(getNotFoundError(cmd));
215
215
  const ppRaw = pathEnv[i];
216
216
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
217
- const pCmd = path12.join(pathPart, cmd);
217
+ const pCmd = path13.join(pathPart, cmd);
218
218
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
219
- resolve10(subStep(p, i, 0));
219
+ resolve11(subStep(p, i, 0));
220
220
  });
221
- const subStep = (p, i, ii) => new Promise((resolve10, reject) => {
221
+ const subStep = (p, i, ii) => new Promise((resolve11, reject) => {
222
222
  if (ii === pathExt.length)
223
- return resolve10(step(i + 1));
223
+ return resolve11(step(i + 1));
224
224
  const ext = pathExt[ii];
225
225
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
226
226
  if (!er && is) {
227
227
  if (opt.all)
228
228
  found.push(p + ext);
229
229
  else
230
- return resolve10(p + ext);
230
+ return resolve11(p + ext);
231
231
  }
232
- return resolve10(subStep(p, i, ii + 1));
232
+ return resolve11(subStep(p, i, ii + 1));
233
233
  });
234
234
  });
235
235
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -241,7 +241,7 @@ var require_which = __commonJS({
241
241
  for (let i = 0; i < pathEnv.length; i++) {
242
242
  const ppRaw = pathEnv[i];
243
243
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
244
- const pCmd = path12.join(pathPart, cmd);
244
+ const pCmd = path13.join(pathPart, cmd);
245
245
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
246
246
  for (let j = 0; j < pathExt.length; j++) {
247
247
  const cur = p + pathExt[j];
@@ -289,7 +289,7 @@ var require_path_key = __commonJS({
289
289
  var require_resolveCommand = __commonJS({
290
290
  "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
291
291
  "use strict";
292
- var path12 = __require("path");
292
+ var path13 = __require("path");
293
293
  var which = require_which();
294
294
  var getPathKey = require_path_key();
295
295
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -307,7 +307,7 @@ var require_resolveCommand = __commonJS({
307
307
  try {
308
308
  resolved = which.sync(parsed.command, {
309
309
  path: env[getPathKey({ env })],
310
- pathExt: withoutPathExt ? path12.delimiter : void 0
310
+ pathExt: withoutPathExt ? path13.delimiter : void 0
311
311
  });
312
312
  } catch (e) {
313
313
  } finally {
@@ -316,7 +316,7 @@ var require_resolveCommand = __commonJS({
316
316
  }
317
317
  }
318
318
  if (resolved) {
319
- resolved = path12.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
319
+ resolved = path13.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
320
320
  }
321
321
  return resolved;
322
322
  }
@@ -370,8 +370,8 @@ var require_shebang_command = __commonJS({
370
370
  if (!match) {
371
371
  return null;
372
372
  }
373
- const [path12, argument] = match[0].replace(/#! ?/, "").split(" ");
374
- const binary = path12.split("/").pop();
373
+ const [path13, argument] = match[0].replace(/#! ?/, "").split(" ");
374
+ const binary = path13.split("/").pop();
375
375
  if (binary === "env") {
376
376
  return argument;
377
377
  }
@@ -384,16 +384,16 @@ var require_shebang_command = __commonJS({
384
384
  var require_readShebang = __commonJS({
385
385
  "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
386
386
  "use strict";
387
- var fs8 = __require("fs");
387
+ var fs9 = __require("fs");
388
388
  var shebangCommand = require_shebang_command();
389
389
  function readShebang(command) {
390
390
  const size = 150;
391
391
  const buffer = Buffer.alloc(size);
392
392
  let fd;
393
393
  try {
394
- fd = fs8.openSync(command, "r");
395
- fs8.readSync(fd, buffer, 0, size, 0);
396
- fs8.closeSync(fd);
394
+ fd = fs9.openSync(command, "r");
395
+ fs9.readSync(fd, buffer, 0, size, 0);
396
+ fs9.closeSync(fd);
397
397
  } catch (e) {
398
398
  }
399
399
  return shebangCommand(buffer.toString());
@@ -406,7 +406,7 @@ var require_readShebang = __commonJS({
406
406
  var require_parse = __commonJS({
407
407
  "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
408
408
  "use strict";
409
- var path12 = __require("path");
409
+ var path13 = __require("path");
410
410
  var resolveCommand = require_resolveCommand();
411
411
  var escape = require_escape();
412
412
  var readShebang = require_readShebang();
@@ -431,7 +431,7 @@ var require_parse = __commonJS({
431
431
  const needsShell = !isExecutableRegExp.test(commandFile);
432
432
  if (parsed.options.forceShell || needsShell) {
433
433
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
434
- parsed.command = path12.normalize(parsed.command);
434
+ parsed.command = path13.normalize(parsed.command);
435
435
  parsed.command = escape.command(parsed.command);
436
436
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
437
437
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -4242,9 +4242,9 @@ var init_wrapper = __esm({
4242
4242
 
4243
4243
  // src/daemon-main.ts
4244
4244
  import { parseArgs } from "util";
4245
- import * as path11 from "path";
4245
+ import * as path12 from "path";
4246
4246
 
4247
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/chunk-AFDD53DD.js
4247
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/chunk-3OUDKIQV.js
4248
4248
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
4249
4249
  import { randomBytes } from "crypto";
4250
4250
  import * as fs from "fs";
@@ -4326,24 +4326,6 @@ function readJsonFile(filePath) {
4326
4326
  return null;
4327
4327
  }
4328
4328
  }
4329
- var LEVELS = ["silent", "error", "warn", "info", "debug"];
4330
- function activeLevel() {
4331
- const raw = (process.env["AGENTCHAT_LOG_LEVEL"] ?? "warn").toLowerCase();
4332
- const idx = LEVELS.indexOf(raw);
4333
- return idx === -1 ? LEVELS.indexOf("warn") : idx;
4334
- }
4335
- function emit(level, msg) {
4336
- if (LEVELS.indexOf(level) <= activeLevel() && level !== "silent") {
4337
- process.stderr.write(`[agentchat:${level}] ${msg}
4338
- `);
4339
- }
4340
- }
4341
- var log = {
4342
- error: (msg) => emit("error", msg),
4343
- warn: (msg) => emit("warn", msg),
4344
- info: (msg) => emit("info", msg),
4345
- debug: (msg) => emit("debug", msg)
4346
- };
4347
4329
  var RUN_PROFILES = ["answer", "work", "full"];
4348
4330
  function identityOf(dir) {
4349
4331
  try {
@@ -4409,6 +4391,24 @@ function resolveRunBudgetMs(env = process.env) {
4409
4391
  if (!Number.isFinite(parsed) || parsed < 1e3) return DEFAULT_RUN_BUDGET_MS;
4410
4392
  return Math.min(parsed, MAX_RUN_BUDGET_MS);
4411
4393
  }
4394
+ var LEVELS = ["silent", "error", "warn", "info", "debug"];
4395
+ function activeLevel() {
4396
+ const raw = (process.env["AGENTCHAT_LOG_LEVEL"] ?? "warn").toLowerCase();
4397
+ const idx = LEVELS.indexOf(raw);
4398
+ return idx === -1 ? LEVELS.indexOf("warn") : idx;
4399
+ }
4400
+ function emit(level, msg) {
4401
+ if (LEVELS.indexOf(level) <= activeLevel() && level !== "silent") {
4402
+ process.stderr.write(`[agentchat:${level}] ${msg}
4403
+ `);
4404
+ }
4405
+ }
4406
+ var log = {
4407
+ error: (msg) => emit("error", msg),
4408
+ warn: (msg) => emit("warn", msg),
4409
+ info: (msg) => emit("info", msg),
4410
+ debug: (msg) => emit("debug", msg)
4411
+ };
4412
4412
  var spawnCommand = import_cross_spawn.default;
4413
4413
  var spawnCommandSync = import_cross_spawn.default.sync;
4414
4414
  var DEFAULT_GRACE_MS = 5e3;
@@ -4679,7 +4679,7 @@ function spawnRun(spec) {
4679
4679
  });
4680
4680
  }
4681
4681
 
4682
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/chunk-CDJASQ3X.js
4682
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/chunk-CQSL6X4D.js
4683
4683
  import * as path3 from "path";
4684
4684
 
4685
4685
  // node_modules/.pnpm/agentchatme@1.4.0_ws@8.21.1/node_modules/agentchatme/dist/index.js
@@ -5037,8 +5037,8 @@ var HttpTransport = class {
5037
5037
  }
5038
5038
  this.fetchFn = f.bind(globalThis);
5039
5039
  }
5040
- async request(method, path12, opts = {}) {
5041
- const url = `${this.baseUrl}${path12}`;
5040
+ async request(method, path13, opts = {}) {
5041
+ const url = `${this.baseUrl}${path13}`;
5042
5042
  const policy = resolveRetryPolicy(opts.retry, this.retry);
5043
5043
  const canRetry = isRetryEligible(method, opts.idempotencyKey, opts.retry);
5044
5044
  const maxAttempts = canRetry ? policy.maxRetries + 1 : 1;
@@ -5272,10 +5272,10 @@ function statusToCode(status) {
5272
5272
  }
5273
5273
  async function sleep(ms, signal) {
5274
5274
  if (ms <= 0) return;
5275
- await new Promise((resolve10, reject) => {
5275
+ await new Promise((resolve11, reject) => {
5276
5276
  const timer = setTimeout(() => {
5277
5277
  if (signal) signal.removeEventListener("abort", onAbort);
5278
- resolve10();
5278
+ resolve11();
5279
5279
  }, ms);
5280
5280
  const onAbort = () => {
5281
5281
  clearTimeout(timer);
@@ -5507,31 +5507,31 @@ var AgentChatClient = class _AgentChatClient {
5507
5507
  return this.get(`/v1/texts?${params.toString()}`, options);
5508
5508
  }
5509
5509
  // ─── Internal request helpers ─────────────────────────────────────────────
5510
- async get(path12, opts) {
5511
- const res = await this.http.request("GET", path12, this.toRequestOpts(opts));
5510
+ async get(path13, opts) {
5511
+ const res = await this.http.request("GET", path13, this.toRequestOpts(opts));
5512
5512
  return res.data;
5513
5513
  }
5514
- async del(path12, opts) {
5515
- const res = await this.http.request("DELETE", path12, this.toRequestOpts(opts));
5514
+ async del(path13, opts) {
5515
+ const res = await this.http.request("DELETE", path13, this.toRequestOpts(opts));
5516
5516
  return res.data;
5517
5517
  }
5518
- async post(path12, body, opts) {
5519
- const res = await this.http.request("POST", path12, {
5518
+ async post(path13, body, opts) {
5519
+ const res = await this.http.request("POST", path13, {
5520
5520
  ...this.toRequestOpts(opts, { idempotent: false }),
5521
5521
  body
5522
5522
  });
5523
5523
  return res.data;
5524
5524
  }
5525
- async patch(path12, body, opts) {
5526
- const res = await this.http.request("PATCH", path12, {
5525
+ async patch(path13, body, opts) {
5526
+ const res = await this.http.request("PATCH", path13, {
5527
5527
  ...this.toRequestOpts(opts, { idempotent: false }),
5528
5528
  body
5529
5529
  });
5530
5530
  return res.data;
5531
5531
  }
5532
- async put(path12, body, opts) {
5532
+ async put(path13, body, opts) {
5533
5533
  const headers = opts?.contentType ? { "Content-Type": opts.contentType } : void 0;
5534
- const res = await this.http.request("PUT", path12, {
5534
+ const res = await this.http.request("PUT", path13, {
5535
5535
  ...this.toRequestOpts(opts),
5536
5536
  body,
5537
5537
  rawBody: opts?.rawBody,
@@ -7504,17 +7504,17 @@ var RealtimeClient = class {
7504
7504
  */
7505
7505
  heldAtMost(run3) {
7506
7506
  const ms = this.options.inFlightAdoptMs;
7507
- return new Promise((resolve10) => {
7508
- const timer = setTimeout(resolve10, ms);
7507
+ return new Promise((resolve11) => {
7508
+ const timer = setTimeout(resolve11, ms);
7509
7509
  unref(timer);
7510
7510
  run3.then(
7511
7511
  () => {
7512
7512
  clearTimeout(timer);
7513
- resolve10();
7513
+ resolve11();
7514
7514
  },
7515
7515
  () => {
7516
7516
  clearTimeout(timer);
7517
- resolve10();
7517
+ resolve11();
7518
7518
  }
7519
7519
  );
7520
7520
  });
@@ -8682,9 +8682,9 @@ var TurnTracker = class {
8682
8682
  */
8683
8683
  async confirmedEnd(handle, done) {
8684
8684
  if (!this.holds(handle)) return null;
8685
- const released = new Promise((resolve10) => {
8685
+ const released = new Promise((resolve11) => {
8686
8686
  const list = this.waiters.get(handle.key) ?? [];
8687
- list.push(() => resolve10(null));
8687
+ list.push(() => resolve11(null));
8688
8688
  this.waiters.set(handle.key, list);
8689
8689
  });
8690
8690
  let report = done;
@@ -8761,9 +8761,9 @@ function nodeModules() {
8761
8761
  /* @vite-ignore */
8762
8762
  PATH_MODULE
8763
8763
  )
8764
- ]).then(([fs8, path12]) => ({
8765
- fs: fs8.default ?? fs8,
8766
- path: path12.default ?? path12
8764
+ ]).then(([fs9, path13]) => ({
8765
+ fs: fs9.default ?? fs9,
8766
+ path: path13.default ?? path13
8767
8767
  }));
8768
8768
  return modules;
8769
8769
  }
@@ -8781,8 +8781,8 @@ function randomSuffix() {
8781
8781
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
8782
8782
  }
8783
8783
  async function renameWithRetry2(from, to, options = {}) {
8784
- const { fs: fs8 } = await nodeModules();
8785
- const rename = options.rename ?? ((a, b) => fs8.rename(a, b));
8784
+ const { fs: fs9 } = await nodeModules();
8785
+ const rename = options.rename ?? ((a, b) => fs9.rename(a, b));
8786
8786
  const attempts = options.retry ?? isWindows() ? RENAME_ATTEMPTS2 : 1;
8787
8787
  for (let attempt = 1; ; attempt++) {
8788
8788
  try {
@@ -8791,16 +8791,16 @@ async function renameWithRetry2(from, to, options = {}) {
8791
8791
  } catch (err) {
8792
8792
  const code = err.code;
8793
8793
  if (attempt >= attempts || code === void 0 || !RENAME_RETRY_CODES2.has(code)) throw err;
8794
- await new Promise((resolve10) => setTimeout(resolve10, RENAME_DELAY_MS2));
8794
+ await new Promise((resolve11) => setTimeout(resolve11, RENAME_DELAY_MS2));
8795
8795
  }
8796
8796
  }
8797
8797
  }
8798
8798
  async function writeAtomic(file, data, options = {}) {
8799
- const { fs: fs8, path: path12 } = await nodeModules();
8800
- await fs8.mkdir(path12.dirname(file), { recursive: true, mode: 448 });
8801
- const tmp = path12.join(path12.dirname(file), `.${path12.basename(file)}.${randomSuffix()}.tmp`);
8799
+ const { fs: fs9, path: path13 } = await nodeModules();
8800
+ await fs9.mkdir(path13.dirname(file), { recursive: true, mode: 448 });
8801
+ const tmp = path13.join(path13.dirname(file), `.${path13.basename(file)}.${randomSuffix()}.tmp`);
8802
8802
  try {
8803
- const handle = await fs8.open(tmp, "wx", options.mode ?? 438);
8803
+ const handle = await fs9.open(tmp, "wx", options.mode ?? 438);
8804
8804
  try {
8805
8805
  if (options.mode !== void 0) await handle.chmod(options.mode);
8806
8806
  await handle.writeFile(data);
@@ -8810,14 +8810,14 @@ async function writeAtomic(file, data, options = {}) {
8810
8810
  }
8811
8811
  await renameWithRetry2(tmp, file, options);
8812
8812
  } catch (err) {
8813
- await fs8.rm(tmp, { force: true }).catch(() => void 0);
8813
+ await fs9.rm(tmp, { force: true }).catch(() => void 0);
8814
8814
  throw err;
8815
8815
  }
8816
8816
  }
8817
8817
  async function readBytes(file) {
8818
- const { fs: fs8 } = await nodeModules();
8818
+ const { fs: fs9 } = await nodeModules();
8819
8819
  try {
8820
- return new Uint8Array(await fs8.readFile(file));
8820
+ return new Uint8Array(await fs9.readFile(file));
8821
8821
  } catch {
8822
8822
  return null;
8823
8823
  }
@@ -9751,7 +9751,7 @@ var ReceiveLoop = class {
9751
9751
  if (!run3.abandoned()) this.finishCycle(summary);
9752
9752
  })();
9753
9753
  let timer = null;
9754
- const overdue = new Promise((resolve10) => {
9754
+ const overdue = new Promise((resolve11) => {
9755
9755
  if (!Number.isFinite(this.cycleTimeoutMs)) return;
9756
9756
  const check = () => {
9757
9757
  timer = null;
@@ -9759,7 +9759,7 @@ var ReceiveLoop = class {
9759
9759
  const excluded = excludedMs + (excludedSince !== null ? now2 - excludedSince : 0);
9760
9760
  const active = now2 - startedAt - excluded;
9761
9761
  if (active >= this.cycleTimeoutMs) {
9762
- resolve10("overdue");
9762
+ resolve11("overdue");
9763
9763
  return;
9764
9764
  }
9765
9765
  timer = this._setTimeout(check, Math.max(1, this.cycleTimeoutMs - active));
@@ -9822,7 +9822,7 @@ var ReceiveLoop = class {
9822
9822
  return (prompt, options) => run3.exclude(() => call2(prompt, options));
9823
9823
  }
9824
9824
  deadlineModelCall(run3) {
9825
- return (prompt) => new Promise((resolve10, reject) => {
9825
+ return (prompt) => new Promise((resolve11, reject) => {
9826
9826
  const controller = new AbortController();
9827
9827
  const abort = () => {
9828
9828
  controller.abort();
@@ -9849,7 +9849,7 @@ var ReceiveLoop = class {
9849
9849
  (text2) => {
9850
9850
  if (timer !== null) this._clearTimeout(timer);
9851
9851
  run3.signal.removeEventListener("abort", abort);
9852
- resolve10(text2);
9852
+ resolve11(text2);
9853
9853
  },
9854
9854
  (err) => {
9855
9855
  if (timer !== null) this._clearTimeout(timer);
@@ -10526,9 +10526,9 @@ function transport(options, apiKey) {
10526
10526
  ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {}
10527
10527
  });
10528
10528
  }
10529
- async function call(options, method, path12, body, apiKey) {
10529
+ async function call(options, method, path13, body, apiKey) {
10530
10530
  try {
10531
- const res = await transport(options, apiKey).request(method, path12, {
10531
+ const res = await transport(options, apiKey).request(method, path13, {
10532
10532
  ...body !== void 0 ? { body } : {},
10533
10533
  retry: "never",
10534
10534
  ...options.signal ? { signal: options.signal } : {},
@@ -10687,14 +10687,14 @@ async function checkKey(apiKey, options) {
10687
10687
  return { ok: true, handle };
10688
10688
  }
10689
10689
  function defaultSleep(signal) {
10690
- return (ms) => new Promise((resolve10, reject) => {
10690
+ return (ms) => new Promise((resolve11, reject) => {
10691
10691
  if (signal?.aborted) {
10692
10692
  reject(abortError());
10693
10693
  return;
10694
10694
  }
10695
10695
  const timer = setTimeout(() => {
10696
10696
  signal?.removeEventListener("abort", onAbort);
10697
- resolve10();
10697
+ resolve11();
10698
10698
  }, ms);
10699
10699
  const onAbort = () => {
10700
10700
  clearTimeout(timer);
@@ -10888,7 +10888,7 @@ var HOUR = 60 * MIN;
10888
10888
  var DAY = 24 * HOUR;
10889
10889
  var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
10890
10890
 
10891
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/chunk-CDJASQ3X.js
10891
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/chunk-CQSL6X4D.js
10892
10892
  import * as path22 from "path";
10893
10893
  import * as path32 from "path";
10894
10894
  import * as fs4 from "fs";
@@ -14951,19 +14951,6 @@ function resolveIdentity(home, options = {}) {
14951
14951
  const envKey = options.envKey === false ? void 0 : process.env["AGENTCHAT_API_KEY"];
14952
14952
  const envBase = process.env["AGENTCHAT_API_BASE"];
14953
14953
  const file = readCredentials(home);
14954
- if (envKey && envKey.trim().length >= 20) {
14955
- return {
14956
- apiKey: envKey.trim(),
14957
- apiBase: envBase?.trim() || file?.api_base || DEFAULT_API_BASE2,
14958
- handle: file?.handle ?? null,
14959
- source: "env"
14960
- };
14961
- }
14962
- if (envKey && envKey.trim().length > 0 && file) {
14963
- log.warn(
14964
- "AGENTCHAT_API_KEY is set but malformed (under 20 chars); using the credentials-file identity instead"
14965
- );
14966
- }
14967
14954
  if (file) {
14968
14955
  return {
14969
14956
  apiKey: file.api_key,
@@ -14972,8 +14959,23 @@ function resolveIdentity(home, options = {}) {
14972
14959
  source: "file"
14973
14960
  };
14974
14961
  }
14962
+ if (envKey && envKey.trim().length >= 20) {
14963
+ return {
14964
+ apiKey: envKey.trim(),
14965
+ apiBase: envBase?.trim() || DEFAULT_API_BASE2,
14966
+ handle: null,
14967
+ source: "env"
14968
+ };
14969
+ }
14975
14970
  return null;
14976
14971
  }
14972
+ function envKeyConflict(home, env = process.env) {
14973
+ const exported = env["AGENTCHAT_API_KEY"]?.trim();
14974
+ if (exported === void 0 || exported.length === 0) return null;
14975
+ const stored = readCredentials(home);
14976
+ if (stored === null || stored.api_key === exported) return null;
14977
+ return `AGENTCHAT_API_KEY is exported and is not the key ${credentialsPath(home)} holds (it is another agent's key, or an old one); commands for this agent act only with that file's key`;
14978
+ }
14977
14979
  var PendingSchema = external_exports.object({
14978
14980
  // 'register' creates a new agent; 'recover' re-keys an existing one. The
14979
14981
  // kind guard stops `register --code` completing a recovery (and vice versa).
@@ -15502,8 +15504,8 @@ function standbyWaiting(lockFile, home, now2 = Date.now()) {
15502
15504
  return false;
15503
15505
  }
15504
15506
 
15505
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/chunk-3ERPUP4M.js
15506
- var VERSION2 = "0.5.1";
15507
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/chunk-JL2L4WRG.js
15508
+ var VERSION2 = "0.5.3";
15507
15509
  var HOSTED_MCP_PATH2 = integration_exports.HOSTED_MCP_PATH;
15508
15510
  function hostedMcpUrl2(apiBase) {
15509
15511
  return integration_exports.hostedMcpUrl(apiBase);
@@ -15511,7 +15513,7 @@ function hostedMcpUrl2(apiBase) {
15511
15513
  var PROBE_KILL_WAIT_MS = 5e3;
15512
15514
  var MAX_OUTPUT = 64 * 1024;
15513
15515
  function runProbe(command, args, options) {
15514
- return new Promise((resolve10) => {
15516
+ return new Promise((resolve11) => {
15515
15517
  let child;
15516
15518
  try {
15517
15519
  child = spawnCommand(command, [...args], {
@@ -15523,7 +15525,7 @@ function runProbe(command, args, options) {
15523
15525
  windowsHide: true
15524
15526
  });
15525
15527
  } catch (err) {
15526
- resolve10({ error: err instanceof Error ? err : new Error(String(err)), status: null, stdout: "", stderr: "", timedOut: false });
15528
+ resolve11({ error: err instanceof Error ? err : new Error(String(err)), status: null, stdout: "", stderr: "", timedOut: false });
15527
15529
  return;
15528
15530
  }
15529
15531
  const proc = child;
@@ -15538,7 +15540,7 @@ function runProbe(command, args, options) {
15538
15540
  finished = true;
15539
15541
  clearTimeout(timer);
15540
15542
  if (giveUp !== null) clearTimeout(giveUp);
15541
- resolve10(result);
15543
+ resolve11(result);
15542
15544
  };
15543
15545
  proc.stdout?.on("data", (chunk) => {
15544
15546
  if (stdout.length < MAX_OUTPUT) stdout += chunk.toString("utf-8");
@@ -15570,7 +15572,7 @@ function runProbe(command, args, options) {
15570
15572
  });
15571
15573
  }
15572
15574
 
15573
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/index.js
15575
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/index.js
15574
15576
  var StateSchema = external_exports.object({
15575
15577
  // Set when the user has said "not now" to setting up a handle. PERMANENT
15576
15578
  // until they change their mind, because the prompt that needs suppressing
@@ -15589,7 +15591,7 @@ var MARKER_LINES = /* @__PURE__ */ new Set([
15589
15591
  var UTF8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
15590
15592
  var NO_TEXTS = Object.freeze({ identityLine: null, identityLineTemplate: null, manual: null });
15591
15593
 
15592
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/daemon-entry.js
15594
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/daemon-entry.js
15593
15595
  import * as path23 from "path";
15594
15596
  import * as fs3 from "fs";
15595
15597
  import * as path8 from "path";
@@ -16164,6 +16166,8 @@ async function runIntegration(opts) {
16164
16166
  });
16165
16167
  const envKey = opts.credentialsFromHomeOnly !== true;
16166
16168
  const identityOf2 = () => resolveIdentity(home, { envKey });
16169
+ const split = envKeyConflict(home, process.env);
16170
+ if (split !== null) log.warn(`${split}; this daemon serves the agent of ${credentialsPath(home)} \u2014 unset AGENTCHAT_API_KEY where it runs`);
16167
16171
  const disabledBy = integrationDisabledBy(env);
16168
16172
  const disabled = disabledBy !== null;
16169
16173
  let live = null;
@@ -16449,7 +16453,7 @@ import * as os3 from "os";
16449
16453
  import * as path9 from "path";
16450
16454
 
16451
16455
  // src/version.ts
16452
- var VERSION3 = "0.5.1";
16456
+ var VERSION3 = "0.5.3";
16453
16457
 
16454
16458
  // src/host.ts
16455
16459
  function codexHome() {
@@ -16477,9 +16481,10 @@ function resolveRunWorkdir(home, env = process.env) {
16477
16481
  return cwd !== void 0 && cwd.length > 0 ? path9.resolve(cwd) : runWorkdirFor(home);
16478
16482
  }
16479
16483
  var CLIENT = { runtime: "codex", version: VERSION3 };
16484
+ var MCP_SERVER_NAME = "agentchat";
16480
16485
  var API_KEY_ENV = "AGENTCHAT_API_KEY";
16481
16486
 
16482
- // node_modules/.pnpm/@agentchatme+agent-core@0.5.1/node_modules/@agentchatme/agent-core/dist/presets.js
16487
+ // node_modules/.pnpm/@agentchatme+agent-core@0.5.3/node_modules/@agentchatme/agent-core/dist/presets.js
16483
16488
  import * as fs7 from "fs";
16484
16489
  import * as os4 from "os";
16485
16490
  import * as path10 from "path";
@@ -17496,11 +17501,78 @@ var PRESETS = Object.freeze({
17496
17501
  [codexPreset.name]: codexPreset
17497
17502
  });
17498
17503
 
17504
+ // src/headers-helper.ts
17505
+ import * as fs8 from "fs";
17506
+ import * as path11 from "path";
17507
+ function headersHelperPathFor(identityHome2) {
17508
+ return path11.join(identityHome2, "bin", "mcp-headers.mjs");
17509
+ }
17510
+ var HEADERS_HELPER_SOURCE = [
17511
+ "// Written by @agentchatme/codex. Codex runs this on each connection to the MCP server",
17512
+ '// "agentchat" (its http_headers_helper) and sends what it prints as headers: the',
17513
+ "// Authorization header for the key in the credentials file of this identity home, or",
17514
+ "// nothing when there is none. It reads no environment variable. Do not edit: install",
17515
+ "// and doctor --fix rewrite it.",
17516
+ "import { readFileSync } from 'node:fs'",
17517
+ "let headers = {}",
17518
+ "try {",
17519
+ " const creds = JSON.parse(readFileSync(new URL('../credentials', import.meta.url), 'utf8'))",
17520
+ " const key = creds !== null && typeof creds.api_key === 'string' ? creds.api_key.trim() : ''",
17521
+ " if (key.length >= 20 && !/\\s/.test(key)) headers = { Authorization: `Bearer ${key}` }",
17522
+ "} catch {}",
17523
+ "process.stdout.write(JSON.stringify(headers))",
17524
+ ""
17525
+ ].join("\n");
17526
+ function headersHelperCommand(script, node = process.execPath, platform = process.platform) {
17527
+ const paths = [node, script];
17528
+ if (paths.some((p) => /[\r\n]/.test(p))) return null;
17529
+ if (platform === "win32") return paths.some((p) => /["%$`]/.test(p)) ? null : paths.map((p) => `"${p}"`).join(" ");
17530
+ return paths.map((p) => `'${p.replace(/'/g, `'\\''`)}'`).join(" ");
17531
+ }
17532
+ function sourceCurrent(script) {
17533
+ try {
17534
+ return fs8.readFileSync(script, "utf-8") === HEADERS_HELPER_SOURCE;
17535
+ } catch {
17536
+ return false;
17537
+ }
17538
+ }
17539
+ function writeHeadersHelper(identityHome2) {
17540
+ const script = headersHelperPathFor(identityHome2);
17541
+ if (sourceCurrent(script)) return;
17542
+ atomicWriteFile(script, HEADERS_HELPER_SOURCE, 384);
17543
+ }
17544
+
17499
17545
  // src/runner.ts
17500
17546
  var CodexRunner2 = class extends CodexRunner {
17547
+ identityHome;
17548
+ helper;
17501
17549
  constructor(options) {
17502
17550
  const { identityHome: identityHome2, ...rest } = options;
17503
- super({ ...rest, apiKey: () => resolveIdentity(identityHome2)?.apiKey ?? null, keyEnv: API_KEY_ENV });
17551
+ super({ ...rest, apiKey: () => null, keyEnv: API_KEY_ENV });
17552
+ this.identityHome = identityHome2;
17553
+ this.helper = headersHelperCommand(headersHelperPathFor(identityHome2));
17554
+ }
17555
+ /** The preset's argv with the identity home's helper pinned before the prompt (which stays last). */
17556
+ args() {
17557
+ const args = super.args();
17558
+ if (this.helper === null) return args;
17559
+ return [...args.slice(0, -1), "-c", `mcp_servers.${MCP_SERVER_NAME}.http_headers_helper=${JSON.stringify(this.helper)}`, args[args.length - 1]];
17560
+ }
17561
+ /** The preset's environment without any `AGENTCHAT_API_KEY`: the key reaches a run through the helper only. */
17562
+ env() {
17563
+ const env = super.env();
17564
+ delete env[API_KEY_ENV];
17565
+ return env;
17566
+ }
17567
+ /** The helper is there (written when missing or not this release's) before the preset's own gate. */
17568
+ async preflight(options = {}) {
17569
+ if (this.helper === null) return { ok: false, detail: `the path of Node (${process.execPath}) or of ${headersHelperPathFor(this.identityHome)} holds a character a shell command cannot carry quoted` };
17570
+ try {
17571
+ writeHeadersHelper(this.identityHome);
17572
+ } catch (err) {
17573
+ return { ok: false, detail: `could not write the headers helper ${headersHelperPathFor(this.identityHome)}: ${String(err)}` };
17574
+ }
17575
+ return super.preflight(options);
17504
17576
  }
17505
17577
  };
17506
17578
  function runPointer(profile, skill) {
@@ -17522,8 +17594,8 @@ async function main(argv = process.argv.slice(2)) {
17522
17594
  console.error("Usage: agentchat-daemon [--home <dir>] [--workdir <dir>]");
17523
17595
  return 1;
17524
17596
  }
17525
- const home = values.home !== void 0 ? path11.resolve(values.home) : identityHome();
17526
- const workdir = values.workdir !== void 0 ? path11.resolve(values.workdir) : resolveRunWorkdir(home);
17597
+ const home = values.home !== void 0 ? path12.resolve(values.home) : identityHome();
17598
+ const workdir = values.workdir !== void 0 ? path12.resolve(values.workdir) : resolveRunWorkdir(home);
17527
17599
  const profile = resolveRunProfile();
17528
17600
  const runner = {
17529
17601
  // The runner's own name (`CodexRunner.name`), for status before any identity is known.