@integrity-labs/agt-cli 0.28.353 → 0.28.354

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.
@@ -100,7 +100,7 @@ async function spawnPairSession(session) {
100
100
  return { ok: true };
101
101
  } catch {
102
102
  }
103
- const { resolveClaudeBinary } = await import("./persistent-session-WMQO3QKU.js");
103
+ const { resolveClaudeBinary } = await import("./persistent-session-SZ5VHS4C.js");
104
104
  const claudeBin = resolveClaudeBinary();
105
105
  const pairEnv = {
106
106
  ...process.env,
@@ -373,4 +373,4 @@ export {
373
373
  startClaudePair,
374
374
  submitClaudePairCode
375
375
  };
376
- //# sourceMappingURL=claude-pair-runtime-KO2HWC7E.js.map
376
+ //# sourceMappingURL=claude-pair-runtime-LLUV4KX6.js.map
@@ -30,6 +30,7 @@ import {
30
30
  getHostId,
31
31
  givenUpMcpServerKeys,
32
32
  liveProxyExtraHeaderVars,
33
+ parseOpencodeModelRef,
33
34
  pinAllowsUrgent,
34
35
  provision,
35
36
  provisionAutoKanbanProgressHook,
@@ -47,7 +48,7 @@ import {
47
48
  safeWriteJsonAtomic,
48
49
  setConfigHash,
49
50
  toOpencodeModel
50
- } from "../chunk-5MZMXKVD.js";
51
+ } from "../chunk-4ITNBU3K.js";
51
52
  import {
52
53
  getProjectDir as getProjectDir2,
53
54
  getReadyTasks,
@@ -138,16 +139,16 @@ import {
138
139
  takeZombieDetection,
139
140
  transcriptActivityAgeSeconds,
140
141
  writeEgressAllowlist
141
- } from "../chunk-ZALWFOHO.js";
142
+ } from "../chunk-LDIKBFDR.js";
142
143
  import {
143
144
  reapOrphanChannelMcps
144
145
  } from "../chunk-XWVM4KPK.js";
145
146
 
146
147
  // src/lib/manager-worker.ts
147
148
  import { createHash as createHash14 } from "crypto";
148
- import { readFileSync as readFileSync19, writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, existsSync as existsSync13, rmSync as rmSync5, readdirSync as readdirSync5, statSync as statSync4, copyFileSync } from "fs";
149
+ import { readFileSync as readFileSync19, writeFileSync as writeFileSync12, mkdirSync as mkdirSync10, existsSync as existsSync13, rmSync as rmSync5, readdirSync as readdirSync5, statSync as statSync4, copyFileSync } from "fs";
149
150
  import { execFileSync as syncExecFile } from "child_process";
150
- import { join as join23, dirname as dirname6, delimiter as pathDelimiter } from "path";
151
+ import { join as join23, dirname as dirname7, delimiter as pathDelimiter } from "path";
151
152
  import { homedir as homedir12 } from "os";
152
153
  import { fileURLToPath } from "url";
153
154
 
@@ -5636,9 +5637,9 @@ async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData
5636
5637
  import { spawn, execSync } from "child_process";
5637
5638
  import { createServer } from "net";
5638
5639
  import { randomBytes } from "crypto";
5639
- import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync16 } from "fs";
5640
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync16, writeFileSync as writeFileSync9 } from "fs";
5640
5641
  import { homedir as homedir10, userInfo } from "os";
5641
- import { join as join20 } from "path";
5642
+ import { join as join20, dirname as dirname6 } from "path";
5642
5643
  var OPENCODE_BIN = process.env["AGT_OPENCODE_BIN"]?.trim() || "opencode";
5643
5644
  var sessions = /* @__PURE__ */ new Map();
5644
5645
  var bridges = /* @__PURE__ */ new Map();
@@ -5649,14 +5650,43 @@ function opencodePaneLogPath(codeName) {
5649
5650
  return join20(homedir10(), ".augmented", codeName, "opencode-serve.log");
5650
5651
  }
5651
5652
  function readProvisionedOpencodeModel(agentDir) {
5653
+ return readOpencodeModelString(join20(agentDir, "provision", "opencode.json"));
5654
+ }
5655
+ function readOpencodeModelString(configPath) {
5652
5656
  try {
5653
- const raw = readFileSync16(join20(agentDir, "provision", "opencode.json"), "utf-8");
5654
- const parsed = JSON.parse(raw);
5657
+ const parsed = JSON.parse(readFileSync16(configPath, "utf-8"));
5655
5658
  return typeof parsed.model === "string" ? parsed.model : null;
5656
5659
  } catch {
5657
5660
  return null;
5658
5661
  }
5659
5662
  }
5663
+ function readOpencodeModelFromConfigDir(configDir) {
5664
+ return parseOpencodeModelRef(readOpencodeModelString(join20(configDir, "opencode.json")));
5665
+ }
5666
+ function materializeEnvPlaceholders(raw, env) {
5667
+ return raw.replace(/\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, (whole, name) => {
5668
+ const v = env[name];
5669
+ return typeof v === "string" && v.length > 0 ? v : whole;
5670
+ });
5671
+ }
5672
+ function deliverOpencodeConfigToXdg(codeName, projectDir, serveEnv, log2) {
5673
+ let raw;
5674
+ try {
5675
+ raw = readFileSync16(join20(projectDir, "opencode.json"), "utf-8");
5676
+ } catch {
5677
+ return null;
5678
+ }
5679
+ const materialized = materializeEnvPlaceholders(raw, serveEnv);
5680
+ const xdgConfigHome = join20(dirname6(projectDir), "opencode-xdg");
5681
+ try {
5682
+ mkdirSync7(join20(xdgConfigHome, "opencode"), { recursive: true });
5683
+ writeFileSync9(join20(xdgConfigHome, "opencode", "opencode.json"), materialized, { mode: 384 });
5684
+ return xdgConfigHome;
5685
+ } catch (err) {
5686
+ log2(`[opencode-session] failed to deliver opencode config to XDG for '${codeName}': ${err.message}`);
5687
+ return null;
5688
+ }
5689
+ }
5660
5690
  function baseUrlFor(port) {
5661
5691
  return `http://127.0.0.1:${port}`;
5662
5692
  }
@@ -5695,7 +5725,8 @@ async function startOpencodeSession(config2) {
5695
5725
  status: "crashed",
5696
5726
  port: null,
5697
5727
  password: null,
5698
- lastFailureTail: "opencode isolation not implemented (ADR-0047)"
5728
+ lastFailureTail: "opencode isolation not implemented (ADR-0047)",
5729
+ model: null
5699
5730
  };
5700
5731
  sessions.set(codeName, blocked);
5701
5732
  return blocked;
@@ -5707,7 +5738,11 @@ async function startOpencodeSession(config2) {
5707
5738
  status: "starting",
5708
5739
  port: null,
5709
5740
  password: null,
5710
- lastFailureTail: existing?.lastFailureTail ?? null
5741
+ lastFailureTail: existing?.lastFailureTail ?? null,
5742
+ // ENG-7931: parse the resolved model from the provisioned opencode.json
5743
+ // (config.projectDir IS the provision dir the serve reads) so the bridge can
5744
+ // pass it explicitly on session-create + prompt.
5745
+ model: readOpencodeModelFromConfigDir(config2.projectDir)
5711
5746
  };
5712
5747
  sessions.set(codeName, session);
5713
5748
  try {
@@ -5743,6 +5778,8 @@ async function spawnServe(config2, session) {
5743
5778
  };
5744
5779
  if (config2.runId) serveEnv["AGT_RUN_ID"] = config2.runId;
5745
5780
  if (config2.agentTimezone) serveEnv["TZ"] = config2.agentTimezone;
5781
+ const xdgConfigHome = deliverOpencodeConfigToXdg(codeName, projectDir, serveEnv, log2);
5782
+ if (xdgConfigHome) serveEnv["XDG_CONFIG_HOME"] = xdgConfigHome;
5746
5783
  const serveCmd = `${OPENCODE_BIN} serve --hostname 127.0.0.1 --port ${port} --print-logs`;
5747
5784
  log2(`[opencode-session] starting '${tmuxSession}' for '${codeName}' on 127.0.0.1:${port}`);
5748
5785
  const child = spawn(
@@ -5813,7 +5850,11 @@ function getBridge(codeName, port, password) {
5813
5850
  const cached = bridges.get(codeName);
5814
5851
  if (cached && cached.port === port && cached.password === password) return cached.bridge;
5815
5852
  const client2 = new HttpOpencodeClient({ baseUrl: baseUrlFor(port), password });
5816
- const bridge = new OpencodeInboundBridge({ client: client2 });
5853
+ const model = sessions.get(codeName)?.model ?? null;
5854
+ const bridge = new OpencodeInboundBridge({
5855
+ client: client2,
5856
+ sessionDefaults: model ? { model } : void 0
5857
+ });
5817
5858
  bridges.set(codeName, { port, password, bridge });
5818
5859
  return bridge;
5819
5860
  }
@@ -6972,7 +7013,7 @@ async function fireOpencodeScheduledTask(agent, task) {
6972
7013
 
6973
7014
  // src/lib/opencode-telegram-ingest.ts
6974
7015
  import { createHash as createHash13 } from "crypto";
6975
- import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync17, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync9 } from "fs";
7016
+ import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync17, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync10 } from "fs";
6976
7017
  import { randomUUID } from "crypto";
6977
7018
  import { join as join21 } from "path";
6978
7019
 
@@ -7550,7 +7591,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
7550
7591
  const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
7551
7592
  try {
7552
7593
  mkdirSync8(dir, { recursive: true, mode: 448 });
7553
- writeFileSync9(
7594
+ writeFileSync10(
7554
7595
  tmpPath,
7555
7596
  JSON.stringify({
7556
7597
  offset,
@@ -7781,7 +7822,7 @@ function partitionActionableByPoison(actionable, states, config2) {
7781
7822
  }
7782
7823
 
7783
7824
  // src/lib/restart-flags.ts
7784
- import { existsSync as existsSync12, mkdirSync as mkdirSync9, readdirSync as readdirSync4, readFileSync as readFileSync18, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync10 } from "fs";
7825
+ import { existsSync as existsSync12, mkdirSync as mkdirSync9, readdirSync as readdirSync4, readFileSync as readFileSync18, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "fs";
7785
7826
  import { homedir as homedir11 } from "os";
7786
7827
  import { join as join22 } from "path";
7787
7828
  import { randomUUID as randomUUID2 } from "crypto";
@@ -9411,7 +9452,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
9411
9452
  var lastVersionCheckAt = 0;
9412
9453
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
9413
9454
  var lastResponsivenessProbeAt = 0;
9414
- var agtCliVersion = true ? "0.28.353" : "dev";
9455
+ var agtCliVersion = true ? "0.28.354" : "dev";
9415
9456
  function resolveBrewPath(execFileSync2) {
9416
9457
  try {
9417
9458
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -9506,7 +9547,7 @@ async function ensureToolkitCli(toolkitSlug) {
9506
9547
  toolkitCliEnsured.add(toolkitSlug);
9507
9548
  return;
9508
9549
  }
9509
- brewBinDir = dirname6(brewPath);
9550
+ brewBinDir = dirname7(brewPath);
9510
9551
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
9511
9552
  log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
9512
9553
  if (isRoot) {
@@ -9606,8 +9647,8 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
9606
9647
  }
9607
9648
  if (settings.channelsEnabled === true) return "ok";
9608
9649
  settings.channelsEnabled = true;
9609
- mkdirSync10(dirname6(path), { recursive: true });
9610
- writeFileSync11(path, `${JSON.stringify(settings, null, 2)}
9650
+ mkdirSync10(dirname7(path), { recursive: true });
9651
+ writeFileSync12(path, `${JSON.stringify(settings, null, 2)}
9611
9652
  `);
9612
9653
  log(`[managed-settings] set channelsEnabled:true in ${path} (ENG-5786 \u2014 unblocks Claude Code channels)`);
9613
9654
  return "ok";
@@ -9702,7 +9743,7 @@ async function ensureFrameworkBinary(frameworkId) {
9702
9743
  log(`Claude Code install failed: ${err.message}`);
9703
9744
  return;
9704
9745
  }
9705
- const brewBinDir = dirname6(brewPath);
9746
+ const brewBinDir = dirname7(brewPath);
9706
9747
  if (!process.env.PATH?.split(":").includes(brewBinDir)) {
9707
9748
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
9708
9749
  }
@@ -10140,7 +10181,7 @@ function ensureEvalEmptyMcpConfig() {
10140
10181
  } catch {
10141
10182
  }
10142
10183
  const p = join23(dir, ".eval-empty-mcp.json");
10143
- writeFileSync11(p, JSON.stringify({ mcpServers: {} }));
10184
+ writeFileSync12(p, JSON.stringify({ mcpServers: {} }));
10144
10185
  evalEmptyMcpConfigPath = p;
10145
10186
  return p;
10146
10187
  }
@@ -10361,7 +10402,7 @@ function parseSkillFrontmatter(content) {
10361
10402
  return out;
10362
10403
  }
10363
10404
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
10364
- const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync12 } = await import("fs");
10405
+ const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync13 } = await import("fs");
10365
10406
  const skillsDir = join23(configDir, codeName, "project", ".claude", "skills");
10366
10407
  const claudeMdPath = join23(configDir, codeName, "project", "CLAUDE.md");
10367
10408
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
@@ -10409,7 +10450,7 @@ ${SKILLS_INDEX_END}`;
10409
10450
  next = current.trimEnd() + "\n\n" + section + "\n";
10410
10451
  }
10411
10452
  if (next !== current) {
10412
- writeFileSync12(claudeMdPath, next, "utf-8");
10453
+ writeFileSync13(claudeMdPath, next, "utf-8");
10413
10454
  log2(`Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)`);
10414
10455
  }
10415
10456
  }
@@ -10430,7 +10471,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
10430
10471
  if (codeNames.length === 0) return;
10431
10472
  void (async () => {
10432
10473
  try {
10433
- const { collectDiagnostics } = await import("../persistent-session-WMQO3QKU.js");
10474
+ const { collectDiagnostics } = await import("../persistent-session-SZ5VHS4C.js");
10434
10475
  await api.post("/host/heartbeat", {
10435
10476
  host_id: hostId,
10436
10477
  agent_diagnostics: collectDiagnostics(codeNames)
@@ -10529,7 +10570,7 @@ async function pollCycle() {
10529
10570
  }
10530
10571
  try {
10531
10572
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
10532
- const { collectDiagnostics } = await import("../persistent-session-WMQO3QKU.js");
10573
+ const { collectDiagnostics } = await import("../persistent-session-SZ5VHS4C.js");
10533
10574
  const diagCodeNames = [...agentState.persistentSessionAgents];
10534
10575
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
10535
10576
  let tailscaleHostname;
@@ -10684,7 +10725,7 @@ async function pollCycle() {
10684
10725
  const {
10685
10726
  collectResponsivenessProbes,
10686
10727
  getResponsivenessIntervalMs
10687
- } = await import("../responsiveness-probe-TCTSHDH3.js");
10728
+ } = await import("../responsiveness-probe-2D64EQAU.js");
10688
10729
  const probeIntervalMs = getResponsivenessIntervalMs();
10689
10730
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
10690
10731
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -10716,7 +10757,7 @@ async function pollCycle() {
10716
10757
  collectResponsivenessProbes,
10717
10758
  livePendingInboundOldestAgeSeconds,
10718
10759
  parkPendingInbound
10719
- } = await import("../responsiveness-probe-TCTSHDH3.js");
10760
+ } = await import("../responsiveness-probe-2D64EQAU.js");
10720
10761
  const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-HYOOQV4A.js");
10721
10762
  const wedgeNow = /* @__PURE__ */ new Date();
10722
10763
  const liveAgents = agentState.persistentSessionAgents;
@@ -11586,11 +11627,11 @@ async function processAgent(agent, agentStates) {
11586
11627
  log(`${verb} '${agent.code_name}': ${fileNames}`);
11587
11628
  for (const file of changedFiles) {
11588
11629
  const filePath = join23(agentDir, file.relativePath);
11589
- mkdirSync10(dirname6(filePath), { recursive: true });
11630
+ mkdirSync10(dirname7(filePath), { recursive: true });
11590
11631
  if (file.relativePath === ".mcp.json") {
11591
11632
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
11592
11633
  } else {
11593
- writeFileSync11(filePath, file.content);
11634
+ writeFileSync12(filePath, file.content);
11594
11635
  }
11595
11636
  }
11596
11637
  try {
@@ -13871,7 +13912,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
13871
13912
  void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
13872
13913
  void (async () => {
13873
13914
  try {
13874
- const { collectDiagnostics } = await import("../persistent-session-WMQO3QKU.js");
13915
+ const { collectDiagnostics } = await import("../persistent-session-SZ5VHS4C.js");
13875
13916
  await api.post("/host/heartbeat", {
13876
13917
  host_id: hostId,
13877
13918
  agent_diagnostics: collectDiagnostics([codeName])
@@ -13921,7 +13962,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
13921
13962
  }
13922
13963
  try {
13923
13964
  const hostId = await getHostId();
13924
- const { collectDiagnostics } = await import("../persistent-session-WMQO3QKU.js");
13965
+ const { collectDiagnostics } = await import("../persistent-session-SZ5VHS4C.js");
13925
13966
  await api.post("/host/heartbeat", {
13926
13967
  host_id: hostId,
13927
13968
  agent_diagnostics: collectDiagnostics([codeName])
@@ -14207,8 +14248,8 @@ async function processDirectChatMessage(agent, msg) {
14207
14248
  if (useDoorbell) {
14208
14249
  try {
14209
14250
  const doorbell = directChatDoorbellPath(agent.agentId, homedir12());
14210
- mkdirSync10(dirname6(doorbell), { recursive: true });
14211
- writeFileSync11(doorbell, String(Date.now()));
14251
+ mkdirSync10(dirname7(doorbell), { recursive: true });
14252
+ writeFileSync12(doorbell, String(Date.now()));
14212
14253
  log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
14213
14254
  return;
14214
14255
  } catch (err) {
@@ -14317,8 +14358,8 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
14317
14358
  if (run_id) openInjectedRunByCode.set(codeName, run_id);
14318
14359
  try {
14319
14360
  const doorbell = directChatDoorbellPath(agentId, homedir12());
14320
- mkdirSync10(dirname6(doorbell), { recursive: true });
14321
- writeFileSync11(doorbell, String(Date.now()));
14361
+ mkdirSync10(dirname7(doorbell), { recursive: true });
14362
+ writeFileSync12(doorbell, String(Date.now()));
14322
14363
  } catch (err) {
14323
14364
  log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
14324
14365
  }
@@ -14419,7 +14460,7 @@ async function processClaudePairSessions(agents) {
14419
14460
  killPairSession,
14420
14461
  pairTmuxSession,
14421
14462
  finalizeClaudePairOnboarding
14422
- } = await import("../claude-pair-runtime-KO2HWC7E.js");
14463
+ } = await import("../claude-pair-runtime-LLUV4KX6.js");
14423
14464
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
14424
14465
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
14425
14466
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -14764,10 +14805,10 @@ ${mem.content}
14764
14805
  } catch {
14765
14806
  }
14766
14807
  if (existing === desired) continue;
14767
- writeFileSync11(filePath, desired);
14808
+ writeFileSync12(filePath, desired);
14768
14809
  overwritten++;
14769
14810
  } else {
14770
- writeFileSync11(filePath, desired);
14811
+ writeFileSync12(filePath, desired);
14771
14812
  written++;
14772
14813
  }
14773
14814
  }
@@ -15169,7 +15210,7 @@ function restartRunningChannelMcps(basenames) {
15169
15210
  function deployMcpAssets() {
15170
15211
  const targetDir = join23(homedir12(), ".augmented", "_mcp");
15171
15212
  mkdirSync10(targetDir, { recursive: true });
15172
- const moduleDir = dirname6(fileURLToPath(import.meta.url));
15213
+ const moduleDir = dirname7(fileURLToPath(import.meta.url));
15173
15214
  let mcpSourceDir = "";
15174
15215
  let dir = moduleDir;
15175
15216
  for (let i = 0; i < 6; i++) {
@@ -15178,7 +15219,7 @@ function deployMcpAssets() {
15178
15219
  mcpSourceDir = candidate;
15179
15220
  break;
15180
15221
  }
15181
- const parent = dirname6(dir);
15222
+ const parent = dirname7(dir);
15182
15223
  if (parent === dir) break;
15183
15224
  dir = parent;
15184
15225
  }
@@ -15289,7 +15330,7 @@ function deployMcpAssets() {
15289
15330
  if (!augServer) continue;
15290
15331
  augServer.command = "node";
15291
15332
  augServer.args = [localMcpPath];
15292
- writeFileSync11(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
15333
+ writeFileSync12(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
15293
15334
  log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
15294
15335
  } catch {
15295
15336
  }