agentschat-mcp 0.36.13 → 0.36.16

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.
@@ -40,23 +40,23 @@ function prepareRuntimeHome(stateDir, source = process.env.CODEX_HOME || join(ho
40
40
  if (mode !== "linked" && mode !== "isolated" && mode !== "auth-only")
41
41
  throw new Error("Invalid Codex home mode");
42
42
  if (mode === "isolated") {
43
- const home = join(stateDir, "codex-home-isolated");
44
- mkdirSync(home, { recursive: true, mode: 448 });
45
- assertIndependentTree(home, undefined, executablePath(codexBin));
46
- return { home: realpathSync(home) };
43
+ const home2 = join(stateDir, "codex-home-isolated");
44
+ mkdirSync(home2, { recursive: true, mode: 448 });
45
+ assertIndependentTree(home2, undefined, executablePath(codexBin));
46
+ return { home: realpathSync(home2) };
47
47
  }
48
48
  if (mode === "auth-only") {
49
- const legacyHome = realpathSync(source);
50
- const origin = join(legacyHome, "auth.json");
49
+ const legacyHome2 = realpathSync(source);
50
+ const origin = join(legacyHome2, "auth.json");
51
51
  if (!lstatSync(origin).isFile())
52
52
  throw new Error("auth-only requires an existing regular auth.json; authorize its use explicitly");
53
- const home = join(stateDir, "codex-home-auth-only");
54
- mkdirSync(home, { recursive: true, mode: 448 });
55
- if (lstatSync(home).isSymbolicLink() || realpathSync(home) === legacyHome)
53
+ const home2 = join(stateDir, "codex-home-auth-only");
54
+ mkdirSync(home2, { recursive: true, mode: 448 });
55
+ if (lstatSync(home2).isSymbolicLink() || realpathSync(home2) === legacyHome2)
56
56
  throw new Error("auth-only home must be independent");
57
57
  for (const name of ["config.toml", "AGENTS.md", "rules", "plugins", "hooks.json"]) {
58
58
  try {
59
- lstatSync(join(home, name));
59
+ lstatSync(join(home2, name));
60
60
  } catch (e) {
61
61
  if (e.code === "ENOENT")
62
62
  continue;
@@ -64,21 +64,21 @@ function prepareRuntimeHome(stateDir, source = process.env.CODEX_HOME || join(ho
64
64
  }
65
65
  throw new Error("auth-only home contains unexpected configuration; use a fresh state root");
66
66
  }
67
- const skills = join(home, "skills");
67
+ const skills = join(home2, "skills");
68
68
  if (existsSync(skills) && (!lstatSync(skills).isDirectory() || readdirSync(skills).some((name) => name !== ".system")))
69
69
  throw new Error("auth-only home contains unexpected custom skills");
70
- assertIndependentTree(home, origin, executablePath(codexBin));
71
- const target = join(home, "auth.json");
70
+ assertIndependentTree(home2, origin, executablePath(codexBin));
71
+ const target = join(home2, "auth.json");
72
72
  try {
73
- if (!lstatSync(target).isSymbolicLink() || resolve(home, readlinkSync(target)) !== origin)
73
+ if (!lstatSync(target).isSymbolicLink() || resolve(home2, readlinkSync(target)) !== origin)
74
74
  throw new Error("Unexpected auth-only login binding");
75
75
  } catch (e) {
76
76
  if (e.code !== "ENOENT")
77
77
  throw e;
78
78
  symlinkSync(origin, target);
79
79
  }
80
- assertIndependentTree(home, origin, executablePath(codexBin));
81
- return { home: realpathSync(home) };
80
+ assertIndependentTree(home2, origin, executablePath(codexBin));
81
+ return { home: realpathSync(home2) };
82
82
  }
83
83
  const legacyHome = existsSync(source) ? realpathSync(source) : resolve(source);
84
84
  const home = join(stateDir, "codex-home");
@@ -171,7 +171,7 @@ async function getOnboardingStatus(base, agentId, token, request = fetch) {
171
171
  return result;
172
172
  result.authentication = "ok";
173
173
  result.claimed = data.claimed;
174
- result.next_step = data.claimed ? "verify_reply" : "claim_agent";
174
+ result.next_step = data.claimed ? "verify_reply" : "join_public_chat";
175
175
  } catch {}
176
176
  return result;
177
177
  }
@@ -292,9 +292,9 @@ ${text}`,
292
292
  }
293
293
 
294
294
  // codex/run.ts
295
- import { readFileSync as readFileSync8 } from "node:fs";
295
+ import { readFileSync as readFileSync9 } from "node:fs";
296
296
  import { homedir as homedir4 } from "node:os";
297
- import { join as join9 } from "node:path";
297
+ import { join as join10 } from "node:path";
298
298
 
299
299
  // codex/bots-config.ts
300
300
  import { readFileSync as readFileSync3, realpathSync as realpathSync3, mkdirSync as mkdirSync3 } from "node:fs";
@@ -824,8 +824,8 @@ function parseDate(ctx, c, endChr) {
824
824
  if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
825
825
  TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
826
826
  if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
827
- let t = ctx.s.slice(startPtr, ctx.p);
828
- return readDate(ctx, t, 3, false, startPtr);
827
+ let t2 = ctx.s.slice(startPtr, ctx.p);
828
+ return readDate(ctx, t2, 3, false, startPtr);
829
829
  }
830
830
  if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
831
831
  TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
@@ -836,12 +836,12 @@ function parseDate(ctx, c, endChr) {
836
836
  ;
837
837
  if (c = ctx.s.charCodeAt(ctx.p)) {
838
838
  if (c === 90 || c === 122) {
839
- let t = ctx.s.slice(startPtr, ++ctx.p);
840
- return readDate(ctx, t, 1, unsafeSeparator, startPtr, "[+00:00]");
839
+ let t2 = ctx.s.slice(startPtr, ++ctx.p);
840
+ return readDate(ctx, t2, 1, unsafeSeparator, startPtr, "[+00:00]");
841
841
  }
842
842
  if (c === 43 || c === 45) {
843
- let t = ctx.s.slice(startPtr, ctx.p += 6);
844
- return readDate(ctx, t, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
843
+ let t2 = ctx.s.slice(startPtr, ctx.p += 6);
844
+ return readDate(ctx, t2, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
845
845
  }
846
846
  }
847
847
  let t = ctx.s.slice(startPtr, ctx.p);
@@ -1530,6 +1530,8 @@ class AppServer {
1530
1530
  }
1531
1531
  async start() {
1532
1532
  const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^AGENTS?CHAT_|^RELAY_/.test(k)));
1533
+ env.AGENTSCHAT_LOCK_OWNER_PID = String(process.pid);
1534
+ env.AGENTSCHAT_TOOL_ONLY = "1";
1533
1535
  if (this.runtime) {
1534
1536
  env.CODEX_HOME = this.runtime.home;
1535
1537
  env.CODEX_SQLITE_HOME = this.runtime.home;
@@ -1577,9 +1579,9 @@ class AppServer {
1577
1579
  `);
1578
1580
  }
1579
1581
  request(method, params) {
1580
- return new Promise((resolve, reject) => {
1582
+ return new Promise((resolve4, reject) => {
1581
1583
  const id = ++this.nextId;
1582
- this.pending.set(id, { method, resolve, reject });
1584
+ this.pending.set(id, { method, resolve: resolve4, reject });
1583
1585
  try {
1584
1586
  this.write({ id, method, params });
1585
1587
  } catch (e) {
@@ -1682,8 +1684,8 @@ class AppServer {
1682
1684
  const permissions = this.threadPermissions.get(thread);
1683
1685
  if (!permissions)
1684
1686
  throw new Error("Thread permissions have not been configured");
1685
- const completed = new Promise((resolve, reject) => {
1686
- this.active = { thread, items: new Map, early: [], resolve, reject };
1687
+ const completed = new Promise((resolve4, reject) => {
1688
+ this.active = { thread, items: new Map, early: [], resolve: resolve4, reject };
1687
1689
  });
1688
1690
  completed.catch(() => {});
1689
1691
  try {
@@ -1737,8 +1739,8 @@ function isTeamLeadSkillInvocation(prompt) {
1737
1739
  }
1738
1740
 
1739
1741
  // codex/bridge.ts
1740
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync3, openSync, closeSync, unlinkSync } from "node:fs";
1741
- import { join as join7 } from "node:path";
1742
+ import { existsSync as existsSync5, mkdirSync as mkdirSync6, readFileSync as readFileSync7, renameSync as renameSync4, writeFileSync as writeFileSync4, openSync, closeSync, unlinkSync as unlinkSync3 } from "node:fs";
1743
+ import { join as join8 } from "node:path";
1742
1744
 
1743
1745
  // codex/thread-history.ts
1744
1746
  import { createHash as createHash2 } from "node:crypto";
@@ -1873,6 +1875,124 @@ async function verifyLoopTick(raw, config, owner, list) {
1873
1875
  return current && current.owner_id === owner ? current : null;
1874
1876
  }
1875
1877
 
1878
+ // src/session-bind.ts
1879
+ import { createHash as createHash3 } from "node:crypto";
1880
+ import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync6, unlinkSync as unlinkSync2 } from "node:fs";
1881
+ import { tmpdir } from "node:os";
1882
+ import { join as join7 } from "node:path";
1883
+
1884
+ // src/profile-store.ts
1885
+ import { existsSync as existsSync3, writeFileSync as writeFileSync3, renameSync as renameSync3, chmodSync, unlinkSync, statSync as statSync2 } from "fs";
1886
+ var defaultWarn = (m) => process.stderr.write(m);
1887
+ function safeWriteProfile(path, data, warn = defaultWarn) {
1888
+ const tmp = path + ".tmp";
1889
+ try {
1890
+ if (existsSync3(tmp))
1891
+ unlinkSync(tmp);
1892
+ } catch (e) {
1893
+ warn(`[agentchat] WARNING: stale ${tmp} could not be removed: ${e}
1894
+ `);
1895
+ }
1896
+ writeFileSync3(tmp, JSON.stringify(data, null, 2), { mode: 384 });
1897
+ renameSync3(tmp, path);
1898
+ try {
1899
+ chmodSync(path, 384);
1900
+ } catch (e) {
1901
+ warn(`[agentchat] WARNING: could not chmod ${path} to 0600: ${e}
1902
+ `);
1903
+ }
1904
+ try {
1905
+ const mode = statSync2(path).mode & 511;
1906
+ if (mode !== 384) {
1907
+ warn(`[agentchat] WARNING: ${path} is mode ${mode.toString(8)}, expected 600 — it holds your agent key. Fix: chmod 600 ${path}
1908
+ `);
1909
+ }
1910
+ } catch (e) {
1911
+ warn(`[agentchat] WARNING: could not verify permissions of ${path}: ${e}
1912
+ `);
1913
+ }
1914
+ }
1915
+
1916
+ // src/session-bind.ts
1917
+ function isPidAlive(pid) {
1918
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0)
1919
+ return false;
1920
+ try {
1921
+ process.kill(pid, 0);
1922
+ return true;
1923
+ } catch (e) {
1924
+ if (e && typeof e === "object" && e.code === "EPERM")
1925
+ return true;
1926
+ return false;
1927
+ }
1928
+ }
1929
+ function resolveLockDir(homeDir, env = process.env) {
1930
+ const explicit = env.AGENTSCHAT_LOCK_DIR?.trim();
1931
+ if (explicit)
1932
+ return explicit;
1933
+ const hash = createHash3("sha256").update(homeDir || ".").digest("hex").slice(0, 12);
1934
+ const baseTmp = process.platform === "win32" ? tmpdir() : "/tmp";
1935
+ return join7(baseTmp, `agentschat-locks-${hash}`);
1936
+ }
1937
+ function lockFilePath(lockDir, agentId) {
1938
+ const safe = String(agentId || "").trim().replace(/[^a-zA-Z0-9_-]/g, "_");
1939
+ return join7(lockDir, `${safe}.lock`);
1940
+ }
1941
+ function readAgentLock(lockDir, agentId) {
1942
+ if (!agentId)
1943
+ return null;
1944
+ const file = lockFilePath(lockDir, agentId);
1945
+ if (!existsSync4(file))
1946
+ return null;
1947
+ try {
1948
+ const raw = JSON.parse(readFileSync6(file, "utf8"));
1949
+ if (!raw || typeof raw !== "object" || typeof raw.pid !== "number" || typeof raw.agentId !== "string") {
1950
+ return null;
1951
+ }
1952
+ return raw;
1953
+ } catch {
1954
+ return null;
1955
+ }
1956
+ }
1957
+ function acquireAgentLock(opts) {
1958
+ if (!opts.agentId)
1959
+ return null;
1960
+ const record = {
1961
+ pid: opts.currentPid ?? process.pid,
1962
+ agentId: opts.agentId,
1963
+ profileName: opts.profileName ?? null,
1964
+ sessionId: opts.sessionId ?? null,
1965
+ runtime: opts.runtime ?? "mcp",
1966
+ updatedAt: new Date().toISOString()
1967
+ };
1968
+ try {
1969
+ mkdirSync5(opts.lockDir, { recursive: true, mode: 448 });
1970
+ safeWriteProfile(lockFilePath(opts.lockDir, opts.agentId), record);
1971
+ return record;
1972
+ } catch {
1973
+ return null;
1974
+ }
1975
+ }
1976
+ function releaseAgentLock(opts) {
1977
+ if (!opts.agentId)
1978
+ return false;
1979
+ const currentPid = opts.currentPid ?? process.pid;
1980
+ const existing = readAgentLock(opts.lockDir, opts.agentId);
1981
+ if (!existing)
1982
+ return false;
1983
+ const samePid = existing.pid === currentPid;
1984
+ const sameSession = Boolean(opts.currentSessionId && existing.sessionId && opts.currentSessionId === existing.sessionId);
1985
+ const dead = !isPidAlive(existing.pid);
1986
+ if (!samePid && !sameSession && !dead)
1987
+ return false;
1988
+ try {
1989
+ unlinkSync2(lockFilePath(opts.lockDir, opts.agentId));
1990
+ return true;
1991
+ } catch {
1992
+ return false;
1993
+ }
1994
+ }
1995
+
1876
1996
  // codex/bridge.ts
1877
1997
  function permitted(m, c) {
1878
1998
  if (m.meta?.kind === "loop_tick")
@@ -1919,18 +2039,31 @@ class Bridge {
1919
2039
  this.activity = activity;
1920
2040
  this.owner = owner;
1921
2041
  this.loops = loops;
1922
- mkdirSync5(config.stateDir, { recursive: true, mode: 448 });
1923
- this.file = join7(config.stateDir, "state.json");
1924
- this.lock = join7(config.stateDir, "bridge.lock");
2042
+ mkdirSync6(config.stateDir, { recursive: true, mode: 448 });
2043
+ this.file = join8(config.stateDir, "state.json");
2044
+ this.lock = join8(config.stateDir, "bridge.lock");
2045
+ if (existsSync5(this.lock)) {
2046
+ try {
2047
+ const holderPid = Number(readFileSync7(this.lock, "utf8").trim());
2048
+ if (holderPid > 0 && !isPidAlive(holderPid))
2049
+ unlinkSync3(this.lock);
2050
+ } catch {}
2051
+ }
1925
2052
  try {
1926
2053
  const fd = openSync(this.lock, "wx", 384);
1927
- writeFileSync3(fd, String(process.pid));
2054
+ writeFileSync4(fd, String(process.pid));
1928
2055
  closeSync(fd);
1929
2056
  } catch {
1930
2057
  throw new Error(`Bridge already locked: ${this.lock}. If its process has exited, remove that lock manually.`);
1931
2058
  }
2059
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
2060
+ acquireAgentLock({
2061
+ lockDir: resolveLockDir(homeDir, process.env),
2062
+ agentId: config.agentId,
2063
+ runtime: "codex-bridge"
2064
+ });
1932
2065
  try {
1933
- this.state = existsSync3(this.file) ? JSON.parse(readFileSync6(this.file, "utf8")) : { version: 1, threads: {}, entries: [] };
2066
+ this.state = existsSync5(this.file) ? JSON.parse(readFileSync7(this.file, "utf8")) : { version: 1, threads: {}, entries: [] };
1934
2067
  if (this.state.version !== 1 || !this.state.threads || !Array.isArray(this.state.entries))
1935
2068
  throw new Error("Invalid bridge state");
1936
2069
  for (const e of this.state.entries) {
@@ -1941,14 +2074,14 @@ class Bridge {
1941
2074
  }
1942
2075
  this.save();
1943
2076
  } catch {
1944
- unlinkSync(this.lock);
2077
+ unlinkSync3(this.lock);
1945
2078
  throw new Error("Cannot load bridge state; refusing to discard history");
1946
2079
  }
1947
2080
  }
1948
2081
  save() {
1949
2082
  const tmp = this.file + ".tmp";
1950
- writeFileSync3(tmp, JSON.stringify(this.state), { mode: 384 });
1951
- renameSync3(tmp, this.file);
2083
+ writeFileSync4(tmp, JSON.stringify(this.state), { mode: 384 });
2084
+ renameSync4(tmp, this.file);
1952
2085
  }
1953
2086
  accept(raw) {
1954
2087
  if (this.stopped || !addressed(raw, this.config))
@@ -2036,7 +2169,7 @@ class Bridge {
2036
2169
  }
2037
2170
  async run() {
2038
2171
  while (!this.stopped) {
2039
- const e = this.state.entries.find((e) => e.status === "pending" || e.status === "ready");
2172
+ const e = this.state.entries.find((e2) => e2.status === "pending" || e2.status === "ready");
2040
2173
  if (!e)
2041
2174
  return;
2042
2175
  if (!permitted(e.message, this.config)) {
@@ -2067,7 +2200,7 @@ This scheduled skill run supports ${TEAM_LEAD_NO_UPDATE}; return it alone only w
2067
2200
  Authorized task:
2068
2201
  ${authorizedTask}` : `You are the online AgentsChat bot ${this.config.agentId}, running through Codex App Server in ${this.config.cwd}. This message was delivered to you live. If asked whether you are online, confirm your own availability.
2069
2202
  Use this channel's shared conversation and configured tools to carry out the request.
2070
- Recurring-task setup, only when requested: create the server loop as this bot in this same channel. Then verify its record with list_loops and confirm this bot is claimed with whoami and obtain its owner_account_id with my_entitlements. Maintain the private file ${join7(this.config.stateDir, "loop-grants.json")} (mode 0600): {"version":1,"grants":[{"loop_id":"server loop ID","channel_id":"this channel ID","agent_id":"this bot ID","owner_id":"verified owner ID","interval_ms":60000,"prompt":"exact server prompt"}]}. Use the actual server interval, preserve other grants, and confirm setup only after both server registration and the matching local grant exist. Stopping a loop also removes its grant. Do not change unrelated loops.
2203
+ Recurring-task setup, only when requested: create the server loop as this bot in this same channel. Then verify its record with list_loops and confirm this bot is claimed with whoami and obtain its owner_account_id with my_entitlements. Maintain the private file ${join8(this.config.stateDir, "loop-grants.json")} (mode 0600): {"version":1,"grants":[{"loop_id":"server loop ID","channel_id":"this channel ID","agent_id":"this bot ID","owner_id":"verified owner ID","interval_ms":60000,"prompt":"exact server prompt"}]}. Use the actual server interval, preserve other grants, and confirm setup only after both server registration and the matching local grant exist. Stopping a loop also removes its grant. Do not change unrelated loops.
2071
2204
  AgentsChat message:
2072
2205
  ` + JSON.stringify(e.message);
2073
2206
  e.answer = this.redact(await this.codex.generate(channel.thread, (channel.bootstrap ?? "") + prompt));
@@ -2125,8 +2258,10 @@ AgentsChat message:
2125
2258
  async stop() {
2126
2259
  this.pause();
2127
2260
  await this.draining;
2128
- if (existsSync3(this.lock))
2129
- unlinkSync(this.lock);
2261
+ if (existsSync5(this.lock))
2262
+ unlinkSync3(this.lock);
2263
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
2264
+ releaseAgentLock({ lockDir: resolveLockDir(homeDir, process.env), agentId: this.config.agentId });
2130
2265
  }
2131
2266
  }
2132
2267
 
@@ -2207,8 +2342,8 @@ class HeartbeatMonitor {
2207
2342
  }
2208
2343
 
2209
2344
  // codex/inbox-sync.ts
2210
- import { existsSync as existsSync4, mkdirSync as mkdirSync6, readFileSync as readFileSync7, renameSync as renameSync4, writeFileSync as writeFileSync4 } from "node:fs";
2211
- import { join as join8 } from "node:path";
2345
+ import { existsSync as existsSync6, mkdirSync as mkdirSync7, readFileSync as readFileSync8, renameSync as renameSync5, writeFileSync as writeFileSync5 } from "node:fs";
2346
+ import { join as join9 } from "node:path";
2212
2347
 
2213
2348
  // src/timestamps.ts
2214
2349
  function normalizeTimestampForCursor(ts, mode) {
@@ -2250,9 +2385,9 @@ class InboxSync {
2250
2385
  this.receive = receive;
2251
2386
  this.active = active;
2252
2387
  this.log = log;
2253
- mkdirSync6(stateDir, { recursive: true, mode: 448 });
2254
- this.file = join8(stateDir, "inbound-cursors.json");
2255
- this.state = existsSync4(this.file) ? JSON.parse(readFileSync7(this.file, "utf8")) : { version: 1, channels: {} };
2388
+ mkdirSync7(stateDir, { recursive: true, mode: 448 });
2389
+ this.file = join9(stateDir, "inbound-cursors.json");
2390
+ this.state = existsSync6(this.file) ? JSON.parse(readFileSync8(this.file, "utf8")) : { version: 1, channels: {} };
2256
2391
  if (this.state.version !== 1 || !this.state.channels || typeof this.state.channels !== "object" || Array.isArray(this.state.channels))
2257
2392
  throw new Error("Invalid inbound cursors; refusing to discard checkpoint");
2258
2393
  for (const value of Object.values(this.state.channels))
@@ -2260,8 +2395,8 @@ class InboxSync {
2260
2395
  this.state.channels = Object.assign(Object.create(null), this.state.channels);
2261
2396
  }
2262
2397
  save() {
2263
- writeFileSync4(this.file + ".tmp", JSON.stringify(this.state), { mode: 384 });
2264
- renameSync4(this.file + ".tmp", this.file);
2398
+ writeFileSync5(this.file + ".tmp", JSON.stringify(this.state), { mode: 384 });
2399
+ renameSync5(this.file + ".tmp", this.file);
2265
2400
  }
2266
2401
  watch(channel) {
2267
2402
  this.channels.add(channel);
@@ -2403,12 +2538,12 @@ class AgentsChatTransport {
2403
2538
  async send(channel, text) {
2404
2539
  if (this.authenticated && this.socket?.readyState === WebSocket.OPEN) {
2405
2540
  const id = randomUUID2();
2406
- await new Promise((resolve, reject) => {
2541
+ await new Promise((resolve4, reject) => {
2407
2542
  const timer = setTimeout(() => {
2408
2543
  this.pending.delete(id);
2409
2544
  reject(new Error("AgentsChat acknowledgement timed out"));
2410
2545
  }, 15000);
2411
- this.pending.set(id, { resolve, reject, timer });
2546
+ this.pending.set(id, { resolve: resolve4, reject, timer });
2412
2547
  this.socket.send(JSON.stringify({
2413
2548
  type: "message",
2414
2549
  id,
@@ -2443,7 +2578,7 @@ class AgentsChatTransport {
2443
2578
  if (current() && socket.readyState === WebSocket.OPEN)
2444
2579
  socket.send(JSON.stringify(value));
2445
2580
  };
2446
- const join = (channel) => {
2581
+ const join10 = (channel) => {
2447
2582
  if (!this.config.channels.length || this.config.channels.includes(channel)) {
2448
2583
  this.inboxSync?.watch(channel);
2449
2584
  send({ type: "join_channel", channel_id: channel, agent_id: this.config.agentId });
@@ -2483,7 +2618,7 @@ class AgentsChatTransport {
2483
2618
  const ids = channels.map((c) => c.id ?? c.channel_id).filter((id) => typeof id === "string" && (!this.config.channels.length || this.config.channels.includes(id)));
2484
2619
  this.inboxSync?.memberships(ids);
2485
2620
  for (const id of ids)
2486
- join(id);
2621
+ join10(id);
2487
2622
  this.inboxSync?.sync();
2488
2623
  }).catch(() => {
2489
2624
  if (current()) {
@@ -2499,7 +2634,7 @@ class AgentsChatTransport {
2499
2634
  pending.resolve();
2500
2635
  }
2501
2636
  } else if (data.type === "channel_created" && typeof data.channel_id === "string")
2502
- join(data.channel_id);
2637
+ join10(data.channel_id);
2503
2638
  else if (["message", "thread_reply"].includes(data.type))
2504
2639
  this.receive(data);
2505
2640
  else if (data.type === "shard_moved" || data.type === "please_reconnect")
@@ -2588,20 +2723,20 @@ async function main() {
2588
2723
  return;
2589
2724
  }
2590
2725
  if (values["gui-thread"] || values["gui-message-file"] || values["gui-status"]) {
2591
- const channel = new GuiChannel(join9(homedir4(), ".agentschat/codex-gui-outbox"), values["gui-thread"] ? [values["gui-thread"]] : []);
2726
+ const channel = new GuiChannel(join10(homedir4(), ".agentschat/codex-gui-outbox"), values["gui-thread"] ? [values["gui-thread"]] : []);
2592
2727
  if (values["gui-status"]) {
2593
- console.log(JSON.stringify(channel.list().map(({ prompt, ...receipt }) => receipt)));
2728
+ console.log(JSON.stringify(channel.list().map(({ prompt: prompt2, ...receipt2 }) => receipt2)));
2594
2729
  return;
2595
2730
  }
2596
2731
  if (!values["gui-thread"] || !values["gui-message-file"])
2597
2732
  throw new Error("GUI submission requires --gui-thread and --gui-message-file");
2598
- const { prompt, ...receipt } = channel.enqueue(values["gui-thread"], readFileSync8(values["gui-message-file"], "utf8"));
2733
+ const { prompt, ...receipt } = channel.enqueue(values["gui-thread"], readFileSync9(values["gui-message-file"], "utf8"));
2599
2734
  console.log(JSON.stringify(receipt));
2600
2735
  return;
2601
2736
  }
2602
2737
  if ((values.bot || values["managed-worker"]) && (values["state-root"] || values["codex-home-mode"]))
2603
2738
  throw new Error("For managed bots, configure state_root/codex_home_mode in the bot registry");
2604
- const snapshot = values["managed-worker"] ? await new Promise((resolve, reject) => {
2739
+ const snapshot = values["managed-worker"] ? await new Promise((resolve4, reject) => {
2605
2740
  if (!process.connected) {
2606
2741
  reject(new Error("Managed worker needs parent IPC"));
2607
2742
  return;
@@ -2609,7 +2744,7 @@ async function main() {
2609
2744
  const timer = setTimeout(() => reject(new Error("Parent configuration missing")), 1e4);
2610
2745
  process.once("message", (config) => {
2611
2746
  clearTimeout(timer);
2612
- resolve(config);
2747
+ resolve4(config);
2613
2748
  });
2614
2749
  }) : undefined;
2615
2750
  const c = snapshot ?? (values.bot ? loadBots(values.registry).find((b) => b.name === values.bot) : resolveConfig({ cwd: values.cwd, profile: values.profile, codexBin: values["codex-bin"], stateRoot: values["state-root"], codexHomeMode: values["codex-home-mode"] }));
@@ -2631,10 +2766,10 @@ async function main() {
2631
2766
  const runtime = prepareRuntimeHome(c.stateDir, undefined, c.codexHomeMode, c.codexBin);
2632
2767
  codex = new AppServer(c.codexBin, undefined, undefined, c.permissions, runtime, c.effort, c.model);
2633
2768
  if (values.conversations || values["read-conversation"]) {
2634
- const state = JSON.parse(readFileSync8(join9(c.stateDir, "state.json"), "utf8"));
2769
+ const state = JSON.parse(readFileSync9(join10(c.stateDir, "state.json"), "utf8"));
2635
2770
  const channels = state.channels ?? {};
2636
2771
  if (values.conversations) {
2637
- console.log(JSON.stringify(Object.entries(channels).map(([channel, data]) => ({ channel, thread: data.thread, isolated: data.namespace === runtime.home }))));
2772
+ console.log(JSON.stringify(Object.entries(channels).map(([channel2, data]) => ({ channel: channel2, thread: data.thread, isolated: data.namespace === runtime.home }))));
2638
2773
  return;
2639
2774
  }
2640
2775
  const channel = channels[values["read-conversation"]];
package/dist/connector.js CHANGED
@@ -118,7 +118,7 @@ function matchesLiveLoop(msg, agentId, response) {
118
118
  const rows = response?.loops;
119
119
  if (!Array.isArray(rows))
120
120
  return false;
121
- const matches = rows.filter((row) => row?.loop_id === tick.loop_id);
121
+ const matches = rows.filter((row2) => row2?.loop_id === tick.loop_id);
122
122
  if (matches.length !== 1)
123
123
  return false;
124
124
  const row = matches[0];
@@ -194,7 +194,7 @@ class IdentityTable {
194
194
  }
195
195
  }
196
196
  function requireIdentity(identities, botId) {
197
- const id = identities.find((id) => id.botId === botId);
197
+ const id = identities.find((id2) => id2.botId === botId);
198
198
  if (!id)
199
199
  throw new Error(`unknown identity: ${botId}`);
200
200
  return id;
@@ -761,13 +761,13 @@ function parseIdentitiesJson(raw, source) {
761
761
  function loadIdentities() {
762
762
  const file = (process.env.RELAY_IDENTITIES_FILE || "").trim();
763
763
  if (file) {
764
- let raw;
764
+ let raw2;
765
765
  try {
766
- raw = readFileSync2(file, "utf8");
766
+ raw2 = readFileSync2(file, "utf8");
767
767
  } catch {
768
768
  throw new Error("RELAY_IDENTITIES_FILE could not be read");
769
769
  }
770
- return parseIdentitiesJson(raw, "RELAY_IDENTITIES_FILE");
770
+ return parseIdentitiesJson(raw2, "RELAY_IDENTITIES_FILE");
771
771
  }
772
772
  const raw = (process.env.RELAY_IDENTITIES || "").trim();
773
773
  if (raw) {