@mrrlin-dev/mcp 0.4.65 → 0.4.67

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.
Files changed (2) hide show
  1. package/dist/bin.cjs +993 -374
  2. package/package.json +3 -3
package/dist/bin.cjs CHANGED
@@ -20644,11 +20644,11 @@ var require_dist = __commonJS({
20644
20644
  });
20645
20645
 
20646
20646
  // src/bin.ts
20647
- var import_node_path37 = __toESM(require("node:path"), 1);
20648
- var import_node_child_process19 = require("node:child_process");
20647
+ var import_node_path38 = __toESM(require("node:path"), 1);
20648
+ var import_node_child_process21 = require("node:child_process");
20649
20649
  var import_node_fs24 = require("node:fs");
20650
20650
  var import_node_os19 = require("node:os");
20651
- var import_node_path38 = __toESM(require("node:path"), 1);
20651
+ var import_node_path39 = __toESM(require("node:path"), 1);
20652
20652
 
20653
20653
  // src/install-codex.ts
20654
20654
  var import_promises = __toESM(require("node:fs/promises"), 1);
@@ -21668,9 +21668,9 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
21668
21668
  var import_node_fs22 = __toESM(require("node:fs"), 1);
21669
21669
  var import_node_http = __toESM(require("node:http"), 1);
21670
21670
  var import_node_os15 = __toESM(require("node:os"), 1);
21671
- var import_node_path30 = __toESM(require("node:path"), 1);
21672
- var import_node_child_process16 = require("node:child_process");
21673
- var import_node_crypto11 = __toESM(require("node:crypto"), 1);
21671
+ var import_node_path31 = __toESM(require("node:path"), 1);
21672
+ var import_node_child_process18 = require("node:child_process");
21673
+ var import_node_crypto12 = __toESM(require("node:crypto"), 1);
21674
21674
 
21675
21675
  // src/turn-replay-buffer.ts
21676
21676
  var DEFAULT_MAX_EVENTS = 2e3;
@@ -37330,12 +37330,42 @@ var AGENT_CAPABILITIES = {
37330
37330
  poolProviderLabels: ["anthropic"]
37331
37331
  },
37332
37332
  agy: {
37333
- listsModels: false,
37333
+ listsModels: true,
37334
37334
  readsRateLimits: false,
37335
- models: [],
37336
- modelCatalog: [],
37337
- sandboxModes: ["workspace-write"],
37338
- poolProviderLabels: ["antigravity"]
37335
+ models: [
37336
+ "gemini-3.8-flash-high",
37337
+ "gemini-3.8-flash-medium",
37338
+ "gemini-3.8-flash-low",
37339
+ "gemini-3.7-flash-high",
37340
+ "gemini-3.7-flash-medium",
37341
+ "gemini-3.7-flash-low",
37342
+ "gemini-3.6-flash-high",
37343
+ "gemini-3.6-flash-medium",
37344
+ "gemini-3.6-flash-low",
37345
+ "gemini-3.1-pro-high",
37346
+ "gemini-3.1-pro-low",
37347
+ "claude-sonnet-4-6",
37348
+ "claude-opus-4-6-thinking",
37349
+ "gpt-oss-120b-medium"
37350
+ ],
37351
+ modelCatalog: [
37352
+ { id: "gemini-3.8-flash-high", displayName: "Gemini 3.8 Flash (High)", description: "gemini-3.8-flash-high" },
37353
+ { id: "gemini-3.8-flash-medium", displayName: "Gemini 3.8 Flash (Medium)", description: "gemini-3.8-flash-medium" },
37354
+ { id: "gemini-3.8-flash-low", displayName: "Gemini 3.8 Flash (Low)", description: "gemini-3.8-flash-low" },
37355
+ { id: "gemini-3.7-flash-high", displayName: "Gemini 3.7 Flash (High)", description: "gemini-3.7-flash-high" },
37356
+ { id: "gemini-3.7-flash-medium", displayName: "Gemini 3.7 Flash (Medium)", description: "gemini-3.7-flash-medium" },
37357
+ { id: "gemini-3.7-flash-low", displayName: "Gemini 3.7 Flash (Low)", description: "gemini-3.7-flash-low" },
37358
+ { id: "gemini-3.6-flash-high", displayName: "Gemini 3.6 Flash (High)", description: "gemini-3.6-flash-high" },
37359
+ { id: "gemini-3.6-flash-medium", displayName: "Gemini 3.6 Flash (Medium)", description: "gemini-3.6-flash-medium" },
37360
+ { id: "gemini-3.6-flash-low", displayName: "Gemini 3.6 Flash (Low)", description: "gemini-3.6-flash-low" },
37361
+ { id: "gemini-3.1-pro-high", displayName: "Gemini 3.1 Pro (High)", description: "gemini-3.1-pro-high" },
37362
+ { id: "gemini-3.1-pro-low", displayName: "Gemini 3.1 Pro (Low)", description: "gemini-3.1-pro-low" },
37363
+ { id: "claude-sonnet-4-6", displayName: "Claude Sonnet 4.6 (Thinking)", description: "claude-sonnet-4-6" },
37364
+ { id: "claude-opus-4-6-thinking", displayName: "Claude Opus 4.6 (Thinking)", description: "claude-opus-4-6-thinking" },
37365
+ { id: "gpt-oss-120b-medium", displayName: "GPT-OSS 120B (Medium)", description: "gpt-oss-120b-medium" }
37366
+ ],
37367
+ sandboxModes: ["read-only", "workspace-write", "danger-full-access"],
37368
+ poolProviderLabels: ["antigravity", "google"]
37339
37369
  }
37340
37370
  };
37341
37371
  var providerReadinessResultSchema = external_exports.object({
@@ -37351,7 +37381,7 @@ var providerReadinessResultSchema = external_exports.object({
37351
37381
  var providerReadinessSchema = external_exports.object({
37352
37382
  codex: providerReadinessResultSchema,
37353
37383
  claude: providerReadinessResultSchema,
37354
- agy: providerReadinessResultSchema
37384
+ agy: providerReadinessResultSchema.optional()
37355
37385
  });
37356
37386
  var providerReadinessResponseSchema = external_exports.object({
37357
37387
  data: external_exports.object({ readiness: providerReadinessSchema.nullable() })
@@ -40421,30 +40451,487 @@ var ClaudeAgentHandle = class {
40421
40451
  }
40422
40452
  };
40423
40453
 
40454
+ // ../../packages/agent-client/dist/providers/agy/process.js
40455
+ var import_node_child_process5 = require("node:child_process");
40456
+ var import_node_crypto2 = require("node:crypto");
40457
+ var import_node_events2 = require("node:events");
40458
+ var import_promises4 = require("node:timers/promises");
40459
+ var MODEL_ID_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,63}$/;
40460
+ var CONVERSATION_ID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
40461
+ var activeProcesses = /* @__PURE__ */ new Set();
40462
+ var globalCleanupInstalled = false;
40463
+ function installGlobalCleanupOnce() {
40464
+ if (globalCleanupInstalled)
40465
+ return;
40466
+ globalCleanupInstalled = true;
40467
+ process.once("exit", () => {
40468
+ for (const child of activeProcesses) {
40469
+ try {
40470
+ child.kill("SIGKILL");
40471
+ } catch {
40472
+ }
40473
+ }
40474
+ });
40475
+ const sigHandler = async () => {
40476
+ for (const child of activeProcesses) {
40477
+ try {
40478
+ child.kill("SIGTERM");
40479
+ } catch {
40480
+ }
40481
+ }
40482
+ await (0, import_promises4.setTimeout)(1e3);
40483
+ for (const child of activeProcesses) {
40484
+ try {
40485
+ child.kill("SIGKILL");
40486
+ } catch {
40487
+ }
40488
+ }
40489
+ process.exit(0);
40490
+ };
40491
+ process.once("SIGTERM", sigHandler);
40492
+ process.once("SIGINT", sigHandler);
40493
+ }
40494
+ installGlobalCleanupOnce();
40495
+ var AgyProcess = class _AgyProcess {
40496
+ options;
40497
+ sessionId;
40498
+ child;
40499
+ lineHandlers = /* @__PURE__ */ new Set();
40500
+ activityHandlers = /* @__PURE__ */ new Set();
40501
+ exitHandlers = /* @__PURE__ */ new Set();
40502
+ killGraceMs;
40503
+ leftover = "";
40504
+ static MAX_BUFFER = 1024 * 1024;
40505
+ // 1 MiB
40506
+ exited = false;
40507
+ constructor(options) {
40508
+ this.options = options;
40509
+ this.killGraceMs = options.killGraceMs ?? 2e3;
40510
+ const { mode } = options;
40511
+ if (mode.kind === "new") {
40512
+ this.sessionId = mode.sessionId ?? (0, import_node_crypto2.randomUUID)();
40513
+ } else {
40514
+ if (!CONVERSATION_ID_REGEX.test(mode.resumeId)) {
40515
+ throw new Error(`Invalid resume conversation ID: "${mode.resumeId}". Must match UUID pattern`);
40516
+ }
40517
+ this.sessionId = mode.resumeId;
40518
+ }
40519
+ if (options.model != null && options.model !== "") {
40520
+ if (!MODEL_ID_REGEX.test(options.model)) {
40521
+ throw new Error(`Invalid model identifier: "${options.model}". Must match ${MODEL_ID_REGEX}`);
40522
+ }
40523
+ }
40524
+ const args = [
40525
+ "--input-format",
40526
+ "stream-json",
40527
+ "--output-format",
40528
+ "stream-json"
40529
+ ];
40530
+ switch (options.permissionMode) {
40531
+ case "bypassPermissions":
40532
+ args.push("--dangerously-skip-permissions");
40533
+ break;
40534
+ case "plan":
40535
+ args.push("--mode", "plan");
40536
+ break;
40537
+ case "acceptEdits":
40538
+ args.push("--mode", "accept-edits");
40539
+ break;
40540
+ }
40541
+ if (options.model) {
40542
+ args.push("--model", options.model);
40543
+ }
40544
+ if (mode.kind === "resume") {
40545
+ args.push("--conversation", mode.resumeId);
40546
+ }
40547
+ const executable = options.agyExecutable?.trim() || "agy";
40548
+ const cwd = options.cwd?.trim() || void 0;
40549
+ this.child = (0, import_node_child_process5.spawn)(executable, args, {
40550
+ cwd,
40551
+ env: process.env,
40552
+ stdio: ["pipe", "pipe", "pipe"]
40553
+ });
40554
+ activeProcesses.add(this.child);
40555
+ this.child.stdout.setEncoding("utf8");
40556
+ this.child.stderr.setEncoding("utf8");
40557
+ this.child.stdout.on("data", (chunk) => this.handleStdoutChunk(chunk));
40558
+ this.child.stderr.on("data", () => this.emitActivity());
40559
+ this.child.on("exit", (code, signal) => {
40560
+ activeProcesses.delete(this.child);
40561
+ if (this.exited)
40562
+ return;
40563
+ this.exited = true;
40564
+ const info = { code, signal };
40565
+ for (const handler of this.exitHandlers)
40566
+ handler(info);
40567
+ });
40568
+ this.child.on("error", () => this.handleTerminalError());
40569
+ this.child.stdin.on("error", () => this.handleTerminalError());
40570
+ this.child.stdout.on("error", () => this.handleTerminalError());
40571
+ this.child.stderr.on("error", () => this.handleTerminalError());
40572
+ }
40573
+ handleTerminalError() {
40574
+ activeProcesses.delete(this.child);
40575
+ if (this.exited)
40576
+ return;
40577
+ this.exited = true;
40578
+ const info = { code: null, signal: null };
40579
+ for (const handler of this.exitHandlers)
40580
+ handler(info);
40581
+ }
40582
+ emitActivity() {
40583
+ for (const handler of this.activityHandlers)
40584
+ handler();
40585
+ }
40586
+ sendTurn(text) {
40587
+ if (this.exited) {
40588
+ throw new Error(`AgyProcess: cannot send turn to exited child process (session ${this.sessionId})`);
40589
+ }
40590
+ const payload = JSON.stringify({
40591
+ event: "user",
40592
+ message: { content: text }
40593
+ });
40594
+ this.child.stdin.write(`${payload}
40595
+ `);
40596
+ }
40597
+ onLine(handler) {
40598
+ this.lineHandlers.add(handler);
40599
+ return () => this.lineHandlers.delete(handler);
40600
+ }
40601
+ onActivity(handler) {
40602
+ this.activityHandlers.add(handler);
40603
+ return () => this.activityHandlers.delete(handler);
40604
+ }
40605
+ onExit(handler) {
40606
+ this.exitHandlers.add(handler);
40607
+ return () => this.exitHandlers.delete(handler);
40608
+ }
40609
+ async dispose() {
40610
+ if (this.exited || this.child.killed) {
40611
+ activeProcesses.delete(this.child);
40612
+ return;
40613
+ }
40614
+ this.child.kill("SIGTERM");
40615
+ try {
40616
+ await Promise.race([
40617
+ (0, import_node_events2.once)(this.child, "exit"),
40618
+ (0, import_promises4.setTimeout)(this.killGraceMs)
40619
+ ]);
40620
+ } catch {
40621
+ }
40622
+ if (!this.exited) {
40623
+ try {
40624
+ this.child.kill("SIGKILL");
40625
+ } catch {
40626
+ }
40627
+ }
40628
+ activeProcesses.delete(this.child);
40629
+ }
40630
+ handleStdoutChunk(chunk) {
40631
+ this.emitActivity();
40632
+ this.leftover += chunk;
40633
+ let newlineIdx;
40634
+ while ((newlineIdx = this.leftover.indexOf("\n")) !== -1) {
40635
+ const line = this.leftover.slice(0, newlineIdx).trim();
40636
+ this.leftover = this.leftover.slice(newlineIdx + 1);
40637
+ if (line.length === 0)
40638
+ continue;
40639
+ try {
40640
+ const parsed = JSON.parse(line);
40641
+ for (const handler of this.lineHandlers)
40642
+ handler(parsed);
40643
+ } catch {
40644
+ }
40645
+ }
40646
+ if (this.leftover.length > _AgyProcess.MAX_BUFFER) {
40647
+ console.error(`[agy-process] stdout line exceeded max buffer (${_AgyProcess.MAX_BUFFER} chars), discarding`);
40648
+ this.leftover = "";
40649
+ }
40650
+ }
40651
+ };
40652
+
40653
+ // ../../packages/agent-client/dist/providers/agy/event-mapper.js
40654
+ function normalizeContent(content) {
40655
+ if (typeof content === "string")
40656
+ return content;
40657
+ if (content === null || content === void 0)
40658
+ return "";
40659
+ try {
40660
+ return JSON.stringify(content);
40661
+ } catch {
40662
+ return String(content);
40663
+ }
40664
+ }
40665
+ var AgyBridgeEventMapper = class {
40666
+ emittedToolUses = /* @__PURE__ */ new Set();
40667
+ emittedToolResults = /* @__PURE__ */ new Set();
40668
+ reset() {
40669
+ this.emittedToolUses.clear();
40670
+ this.emittedToolResults.clear();
40671
+ }
40672
+ mapLine(parsed, _threadId) {
40673
+ if (typeof parsed !== "object" || parsed === null) {
40674
+ return [];
40675
+ }
40676
+ const data = parsed;
40677
+ if (data.event === "step_update") {
40678
+ const step = data.step_update;
40679
+ if (!step || typeof step !== "object") {
40680
+ return [];
40681
+ }
40682
+ if (step.step_type === "agent_response") {
40683
+ const text = typeof step.text_delta === "string" ? step.text_delta : typeof step.response === "string" ? step.response : "";
40684
+ return text ? [{ type: "assistant", content: text }] : [];
40685
+ }
40686
+ if (step.step_type === "tool_use" || step.tool_call) {
40687
+ const id = (typeof step.tool_use_id === "string" ? step.tool_use_id : typeof step.id === "string" ? step.id : "") || "";
40688
+ if (id && !this.emittedToolUses.has(id)) {
40689
+ this.emittedToolUses.add(id);
40690
+ const name = typeof step.tool_name === "string" ? step.tool_name : typeof step.tool === "string" ? step.tool : "tool_use";
40691
+ const input = step.input ?? {};
40692
+ return [{ type: "tool_use", tool: { name, id, input } }];
40693
+ }
40694
+ return [];
40695
+ }
40696
+ if (step.step_type === "tool_result") {
40697
+ const toolUseId = (typeof step.tool_use_id === "string" ? step.tool_use_id : typeof step.id === "string" ? step.id : "") || "";
40698
+ if (toolUseId && !this.emittedToolResults.has(toolUseId)) {
40699
+ this.emittedToolResults.add(toolUseId);
40700
+ const content = step.content ?? step.result ?? "";
40701
+ return [{ type: "tool_result", tool: { id: toolUseId }, content: normalizeContent(content) }];
40702
+ }
40703
+ return [];
40704
+ }
40705
+ if (step.step_type === "error_message") {
40706
+ const message = typeof step.error === "string" ? step.error : typeof step.message === "string" ? step.message : "AGY step error";
40707
+ return [{ type: "error", content: message }];
40708
+ }
40709
+ return [];
40710
+ }
40711
+ if (data.event === "result") {
40712
+ const res = data.result ?? {};
40713
+ const events = [];
40714
+ if (res.status === "ERROR") {
40715
+ events.push({
40716
+ type: "error",
40717
+ content: typeof res.error === "string" ? res.error : "AGY turn error"
40718
+ });
40719
+ } else {
40720
+ events.push({ type: "result", subtype: "success" });
40721
+ }
40722
+ if (res.usage && typeof res.usage === "object") {
40723
+ const usage = res.usage;
40724
+ events.push({
40725
+ type: "token_usage",
40726
+ usage: {
40727
+ inputTokens: typeof usage.input_tokens === "number" ? usage.input_tokens : typeof usage.inputTokens === "number" ? usage.inputTokens : null,
40728
+ cachedInputTokens: typeof usage.cache_read_input_tokens === "number" ? usage.cache_read_input_tokens : typeof usage.cachedInputTokens === "number" ? usage.cachedInputTokens : null,
40729
+ outputTokens: typeof usage.output_tokens === "number" ? usage.output_tokens : typeof usage.outputTokens === "number" ? usage.outputTokens : null
40730
+ }
40731
+ });
40732
+ }
40733
+ events.push({ type: "turn_completed" });
40734
+ return events;
40735
+ }
40736
+ return [];
40737
+ }
40738
+ };
40739
+
40740
+ // ../../packages/agent-client/dist/providers/agy/models.js
40741
+ var import_node_child_process6 = require("node:child_process");
40742
+ var import_node_util = require("node:util");
40743
+ var import_promises5 = require("node:fs/promises");
40744
+ var import_node_path6 = require("node:path");
40745
+ var execFileAsync = (0, import_node_util.promisify)(import_node_child_process6.execFile);
40746
+ var AGY_MODEL_CATALOG = [
40747
+ { id: "gemini-3.8-flash-high", displayName: "Gemini 3.8 Flash (High)", description: "gemini-3.8-flash-high" },
40748
+ { id: "gemini-3.8-flash-medium", displayName: "Gemini 3.8 Flash (Medium)", description: "gemini-3.8-flash-medium" },
40749
+ { id: "gemini-3.8-flash-low", displayName: "Gemini 3.8 Flash (Low)", description: "gemini-3.8-flash-low" },
40750
+ { id: "gemini-3.7-flash-high", displayName: "Gemini 3.7 Flash (High)", description: "gemini-3.7-flash-high" },
40751
+ { id: "gemini-3.7-flash-medium", displayName: "Gemini 3.7 Flash (Medium)", description: "gemini-3.7-flash-medium" },
40752
+ { id: "gemini-3.7-flash-low", displayName: "Gemini 3.7 Flash (Low)", description: "gemini-3.7-flash-low" },
40753
+ { id: "gemini-3.6-flash-high", displayName: "Gemini 3.6 Flash (High)", description: "gemini-3.6-flash-high" },
40754
+ { id: "gemini-3.6-flash-medium", displayName: "Gemini 3.6 Flash (Medium)", description: "gemini-3.6-flash-medium" },
40755
+ { id: "gemini-3.6-flash-low", displayName: "Gemini 3.6 Flash (Low)", description: "gemini-3.6-flash-low" },
40756
+ { id: "gemini-3.1-pro-high", displayName: "Gemini 3.1 Pro (High)", description: "gemini-3.1-pro-high" },
40757
+ { id: "gemini-3.1-pro-low", displayName: "Gemini 3.1 Pro (Low)", description: "gemini-3.1-pro-low" },
40758
+ { id: "claude-sonnet-4-6", displayName: "Claude Sonnet 4.6 (Thinking)", description: "claude-sonnet-4-6" },
40759
+ { id: "claude-opus-4-6-thinking", displayName: "Claude Opus 4.6 (Thinking)", description: "claude-opus-4-6-thinking" },
40760
+ { id: "gpt-oss-120b-medium", displayName: "GPT-OSS 120B (Medium)", description: "gpt-oss-120b-medium" }
40761
+ ];
40762
+ var AGY_MODELS = AGY_MODEL_CATALOG.map((entry) => entry.id);
40763
+ function agyModelCatalog() {
40764
+ return AGY_MODEL_CATALOG.map((entry) => ({
40765
+ id: entry.id,
40766
+ displayName: entry.displayName,
40767
+ description: entry.description,
40768
+ isDefault: entry.id === "gemini-3.1-pro-high"
40769
+ }));
40770
+ }
40771
+ var MODEL_ID_REGEX2 = /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,63}$/;
40772
+ function parseAgyModelsOutput(output3) {
40773
+ const lines2 = output3.split(/\r?\n/);
40774
+ const models = [];
40775
+ for (const raw of lines2) {
40776
+ const line = raw.trim();
40777
+ if (!line)
40778
+ continue;
40779
+ if (/^(Fetching|Warning|Error)/i.test(line))
40780
+ continue;
40781
+ const parts = line.split(/\t+|\s{2,}/).map((p) => p.trim()).filter(Boolean);
40782
+ if (parts.length < 1)
40783
+ continue;
40784
+ const id = parts[0];
40785
+ if (!MODEL_ID_REGEX2.test(id)) {
40786
+ console.warn(`[agy:models] skipping malformed model id: ${id}`);
40787
+ continue;
40788
+ }
40789
+ const displayName = parts[1] ?? id;
40790
+ const description = parts[2] ?? displayName;
40791
+ models.push({
40792
+ id,
40793
+ displayName,
40794
+ description,
40795
+ isDefault: id === "gemini-3.1-pro-high"
40796
+ });
40797
+ }
40798
+ return models;
40799
+ }
40800
+ var cachedModels = null;
40801
+ var CACHE_TTL_MS = 3e4;
40802
+ async function fetchAgyModels(opts) {
40803
+ const now = Date.now();
40804
+ if (!opts?.bypassCache && cachedModels && cachedModels.expiresAt > now) {
40805
+ return cachedModels.models;
40806
+ }
40807
+ let executable = "agy";
40808
+ const customPath = process.env.MRRLIN_AGY_PATH?.trim();
40809
+ if (customPath) {
40810
+ try {
40811
+ if ((0, import_node_path6.basename)(customPath) === "agy") {
40812
+ await (0, import_promises5.access)(customPath);
40813
+ executable = customPath;
40814
+ }
40815
+ } catch {
40816
+ }
40817
+ }
40818
+ try {
40819
+ const { stdout } = await execFileAsync(executable, ["models"], {
40820
+ timeout: 1e4,
40821
+ maxBuffer: 1024 * 1024
40822
+ });
40823
+ const parsed = parseAgyModelsOutput(stdout);
40824
+ if (parsed.length > 0) {
40825
+ cachedModels = { expiresAt: now + CACHE_TTL_MS, models: parsed };
40826
+ return parsed;
40827
+ }
40828
+ console.warn("[agy:models] fetchAgyModels succeeded but returned no models, falling back to static catalog");
40829
+ } catch (error51) {
40830
+ console.warn("[agy:models] fetchAgyModels failed, falling back to static catalog", error51);
40831
+ }
40832
+ const fallback = agyModelCatalog();
40833
+ cachedModels = { expiresAt: now + CACHE_TTL_MS, models: fallback };
40834
+ return fallback;
40835
+ }
40836
+
40424
40837
  // ../../packages/agent-client/dist/providers/agy/adapter.js
40425
40838
  var AgyProviderAdapter = class {
40426
40839
  id = "agy";
40427
40840
  capabilities() {
40428
40841
  return AGENT_CAPABILITIES.agy;
40429
40842
  }
40430
- // Stub adapter: real process spawning and JSONL stdio streaming will be implemented in agy-stdio-streaming
40431
40843
  async acquireWarm() {
40432
- return {
40433
- startThread: () => Promise.resolve({ threadId: "mock-thread-id" }),
40434
- resumeThread: () => Promise.resolve({ threadId: "mock-thread-id" }),
40435
- startTurn: () => Promise.resolve({ turnId: "mock-turn-id" }),
40436
- interruptTurn: () => Promise.resolve(),
40437
- onEvent: () => () => {
40438
- },
40439
- onActivity: () => () => {
40440
- },
40441
- listModels: () => Promise.resolve([]),
40442
- readRateLimits: () => Promise.resolve(null)
40443
- };
40844
+ return new AgyAgentHandle();
40444
40845
  }
40445
40846
  releaseWarm() {
40446
40847
  }
40447
40848
  };
40849
+ function permissionModeFor2(sandbox, approvalPolicy) {
40850
+ if (sandbox === "read-only") {
40851
+ return { permissionMode: "plan" };
40852
+ }
40853
+ if (sandbox === "workspace-write") {
40854
+ return { permissionMode: "acceptEdits" };
40855
+ }
40856
+ if (sandbox === "danger-full-access" || approvalPolicy === "never") {
40857
+ return { permissionMode: "bypassPermissions" };
40858
+ }
40859
+ return { permissionMode: "acceptEdits" };
40860
+ }
40861
+ var AgyAgentHandle = class {
40862
+ processes = /* @__PURE__ */ new Map();
40863
+ mappers = /* @__PURE__ */ new Map();
40864
+ async startThread(params) {
40865
+ const { permissionMode } = permissionModeFor2(params.sandbox, params.approvalPolicy);
40866
+ const child = new AgyProcess({
40867
+ mode: { kind: "new" },
40868
+ permissionMode,
40869
+ model: params.model,
40870
+ cwd: params.cwd
40871
+ });
40872
+ this.processes.set(child.sessionId, child);
40873
+ this.mappers.set(child.sessionId, new AgyBridgeEventMapper());
40874
+ return { threadId: child.sessionId };
40875
+ }
40876
+ async resumeThread(threadId, params) {
40877
+ const existing = this.processes.get(threadId);
40878
+ if (existing) {
40879
+ await existing.dispose().catch(() => {
40880
+ });
40881
+ }
40882
+ const { permissionMode } = permissionModeFor2(params.sandbox, params.approvalPolicy);
40883
+ const child = new AgyProcess({
40884
+ mode: { kind: "resume", resumeId: threadId },
40885
+ permissionMode,
40886
+ model: params.model,
40887
+ cwd: params.cwd
40888
+ });
40889
+ this.processes.set(threadId, child);
40890
+ this.mappers.set(threadId, new AgyBridgeEventMapper());
40891
+ return { threadId: child.sessionId };
40892
+ }
40893
+ async startTurn(threadId, input) {
40894
+ const child = this.requireProcess(threadId);
40895
+ const text = input.filter((block) => block.type === "text").map((block) => block.text).join("\n");
40896
+ child.sendTurn(text);
40897
+ return { turnId: void 0 };
40898
+ }
40899
+ async interruptTurn(threadId) {
40900
+ const child = this.processes.get(threadId);
40901
+ if (child) {
40902
+ await child.dispose().catch(() => {
40903
+ });
40904
+ this.processes.delete(threadId);
40905
+ this.mappers.delete(threadId);
40906
+ }
40907
+ }
40908
+ onEvent(threadId, handler) {
40909
+ const child = this.requireProcess(threadId);
40910
+ const mapper = this.mappers.get(threadId);
40911
+ if (!mapper)
40912
+ throw new Error(`AgyAgentHandle.onEvent: no mapper for thread ${threadId}`);
40913
+ return child.onLine((parsed) => {
40914
+ for (const event of mapper.mapLine(parsed, threadId))
40915
+ handler(event);
40916
+ });
40917
+ }
40918
+ onActivity(threadId, handler) {
40919
+ const child = this.requireProcess(threadId);
40920
+ return child.onActivity(handler);
40921
+ }
40922
+ async listModels() {
40923
+ return fetchAgyModels();
40924
+ }
40925
+ async readRateLimits() {
40926
+ return null;
40927
+ }
40928
+ requireProcess(threadId) {
40929
+ const child = this.processes.get(threadId);
40930
+ if (!child)
40931
+ throw new Error(`AgyAgentHandle: no active process for thread ${threadId}`);
40932
+ return child;
40933
+ }
40934
+ };
40448
40935
 
40449
40936
  // ../../packages/agent-client/dist/registry.js
40450
40937
  var KNOWN_PROVIDERS = { codex: true, claude: true, agy: true };
@@ -40475,7 +40962,7 @@ function resolveProvider(env, persisted) {
40475
40962
  }
40476
40963
 
40477
40964
  // ../../packages/agent-client/dist/providers/codex/exec.js
40478
- var import_node_child_process5 = require("node:child_process");
40965
+ var import_node_child_process7 = require("node:child_process");
40479
40966
 
40480
40967
  // ../../packages/agent-client/dist/exec-usage.js
40481
40968
  function readCount2(source, ...keys) {
@@ -40589,7 +41076,7 @@ function firstString(...values) {
40589
41076
  return null;
40590
41077
  }
40591
41078
  function runCodexExec(input, deps) {
40592
- const spawn4 = deps?.spawn ?? import_node_child_process5.spawn;
41079
+ const spawn5 = deps?.spawn ?? import_node_child_process7.spawn;
40593
41080
  const executable = input.codexExecutable ?? "codex";
40594
41081
  const sandbox = input.sandbox ?? "read-only";
40595
41082
  const fullPrompt = input.developerInstructions.trim() ? `${input.developerInstructions.trim()}
@@ -40626,7 +41113,7 @@ ${input.prompt}` : input.prompt;
40626
41113
  };
40627
41114
  let child;
40628
41115
  try {
40629
- child = spawn4(executable, args, options);
41116
+ child = spawn5(executable, args, options);
40630
41117
  } catch (err) {
40631
41118
  finish({ ok: false, error: `Failed to spawn codex exec: ${errMessage(err)}` });
40632
41119
  return;
@@ -40667,9 +41154,9 @@ function errMessage(err) {
40667
41154
  }
40668
41155
 
40669
41156
  // ../../packages/agent-client/dist/providers/claude/exec.js
40670
- var import_node_child_process6 = require("node:child_process");
41157
+ var import_node_child_process8 = require("node:child_process");
40671
41158
  function runClaudeExec(input, deps) {
40672
- const spawn4 = deps?.spawn ?? import_node_child_process6.spawn;
41159
+ const spawn5 = deps?.spawn ?? import_node_child_process8.spawn;
40673
41160
  const executable = input.codexExecutable ?? "claude";
40674
41161
  const args = ["--print", "--output-format", "json", "--strict-mcp-config"];
40675
41162
  if (input.sandbox === "read-only") {
@@ -40704,7 +41191,7 @@ function runClaudeExec(input, deps) {
40704
41191
  };
40705
41192
  let child;
40706
41193
  try {
40707
- child = spawn4(executable, args, options);
41194
+ child = spawn5(executable, args, options);
40708
41195
  } catch (err) {
40709
41196
  finish({ ok: false, error: `Failed to spawn ${executable} exec: ${errMessage2(err)}` });
40710
41197
  return;
@@ -40784,10 +41271,34 @@ function runAgentExec(input, deps, persistedProvider) {
40784
41271
  // ../../packages/agent-client/dist/resolved-seat.js
40785
41272
  var CODEX_STRONG_MODEL_CONSTANT = "gpt-5.6-terra";
40786
41273
  var CLAUDE_STRONG_MODEL_CONSTANT = "sonnet";
41274
+ var AGY_STRONG_MODEL_CONSTANT = "gemini-3.1-pro-high";
40787
41275
  var CODEX_WEAK_MODEL_CONSTANT = "codex-gpt-5.4-mini";
40788
41276
  var CLAUDE_WEAK_MODEL_CONSTANT = "haiku";
41277
+ var AGY_WEAK_MODEL_CONSTANT = "gemini-3.6-flash-low";
40789
41278
  var CODEX_STRONG_MODEL_ENV = "MRRLIN_CODEX_STRONG_MODEL";
40790
41279
  var CLAUDE_STRONG_MODEL_ENV = "MRRLIN_CLAUDE_STRONG_MODEL";
41280
+ var AGY_STRONG_MODEL_ENV = "MRRLIN_AGY_STRONG_MODEL";
41281
+ function strongConstantFor(providerId) {
41282
+ if (providerId === "codex")
41283
+ return CODEX_STRONG_MODEL_CONSTANT;
41284
+ if (providerId === "claude")
41285
+ return CLAUDE_STRONG_MODEL_CONSTANT;
41286
+ return AGY_STRONG_MODEL_CONSTANT;
41287
+ }
41288
+ function weakConstantFor(providerId) {
41289
+ if (providerId === "codex")
41290
+ return CODEX_WEAK_MODEL_CONSTANT;
41291
+ if (providerId === "claude")
41292
+ return CLAUDE_WEAK_MODEL_CONSTANT;
41293
+ return AGY_WEAK_MODEL_CONSTANT;
41294
+ }
41295
+ function strongEnvVarFor(providerId) {
41296
+ if (providerId === "codex")
41297
+ return CODEX_STRONG_MODEL_ENV;
41298
+ if (providerId === "claude")
41299
+ return CLAUDE_STRONG_MODEL_ENV;
41300
+ return AGY_STRONG_MODEL_ENV;
41301
+ }
40791
41302
  function logFallback(providerId, tier, source, value) {
40792
41303
  console.error(`[resolved-seat] provider=${providerId} ${tier}=${value} (source: ${source})`);
40793
41304
  }
@@ -40801,12 +41312,22 @@ function pickStrongModelFromList(models) {
40801
41312
  return models[0]?.id ?? null;
40802
41313
  }
40803
41314
  function pickWeakModelFromList(models, strongModel) {
40804
- const miniModel = models.find((m) => {
41315
+ const preferredWeak = models.find((m) => {
40805
41316
  const id = m.id.toLowerCase();
40806
- return id.includes("mini") || id.includes("weak") || id.includes("small");
41317
+ if (id === strongModel.toLowerCase())
41318
+ return false;
41319
+ return /(^|[-_])(mini|weak|small)([-_]|$)/i.test(id) || id.includes("flash-low") || /(^|[-_])flash([-_]|$)/i.test(id);
40807
41320
  });
40808
- if (miniModel && miniModel.id !== strongModel)
40809
- return miniModel.id;
41321
+ if (preferredWeak)
41322
+ return preferredWeak.id;
41323
+ const fallbackLow = models.find((m) => {
41324
+ const id = m.id.toLowerCase();
41325
+ if (id === strongModel.toLowerCase())
41326
+ return false;
41327
+ return /(^|[-_])low([-_]|$)/i.test(id);
41328
+ });
41329
+ if (fallbackLow)
41330
+ return fallbackLow.id;
40810
41331
  return null;
40811
41332
  }
40812
41333
  async function mintResolvedSeat(provider, opts) {
@@ -40814,7 +41335,10 @@ async function mintResolvedSeat(provider, opts) {
40814
41335
  const providerId = provider.id;
40815
41336
  let strongModel;
40816
41337
  let weakModel;
40817
- const strongEnvValue = process.env[providerId === "codex" ? CODEX_STRONG_MODEL_ENV : CLAUDE_STRONG_MODEL_ENV]?.trim();
41338
+ let pinRetired;
41339
+ let retiredPin;
41340
+ const strongEnvVar = strongEnvVarFor(providerId);
41341
+ const strongEnvValue = process.env[strongEnvVar]?.trim();
40818
41342
  if (opts?.handle && capabilities.listsModels) {
40819
41343
  try {
40820
41344
  const models = await opts.handle.listModels();
@@ -40827,6 +41351,8 @@ async function mintResolvedSeat(provider, opts) {
40827
41351
  strongModel = picked;
40828
41352
  if (strongEnvValue) {
40829
41353
  logFallback(providerId, "strong", "live-default (env pin retired)", strongModel);
41354
+ pinRetired = true;
41355
+ retiredPin = strongEnvValue;
40830
41356
  }
40831
41357
  } else {
40832
41358
  throw new Error("empty model list");
@@ -40837,7 +41363,7 @@ async function mintResolvedSeat(provider, opts) {
40837
41363
  strongModel = strongEnvValue;
40838
41364
  logFallback(providerId, "strong", "env", strongModel);
40839
41365
  } else {
40840
- strongModel = providerId === "codex" ? CODEX_STRONG_MODEL_CONSTANT : CLAUDE_STRONG_MODEL_CONSTANT;
41366
+ strongModel = strongConstantFor(providerId);
40841
41367
  logFallback(providerId, "strong", "constant", strongModel);
40842
41368
  }
40843
41369
  }
@@ -40845,7 +41371,7 @@ async function mintResolvedSeat(provider, opts) {
40845
41371
  strongModel = strongEnvValue;
40846
41372
  logFallback(providerId, "strong", "env", strongModel);
40847
41373
  } else {
40848
- strongModel = providerId === "codex" ? CODEX_STRONG_MODEL_CONSTANT : CLAUDE_STRONG_MODEL_CONSTANT;
41374
+ strongModel = strongConstantFor(providerId);
40849
41375
  logFallback(providerId, "strong", "constant", strongModel);
40850
41376
  }
40851
41377
  if (providerId === "claude") {
@@ -40863,18 +41389,19 @@ async function mintResolvedSeat(provider, opts) {
40863
41389
  logFallback(providerId, "weak", "degenerate (weak=strong)", weakModel);
40864
41390
  }
40865
41391
  } catch {
40866
- weakModel = CODEX_WEAK_MODEL_CONSTANT;
41392
+ weakModel = weakConstantFor(providerId);
40867
41393
  logFallback(providerId, "weak", "constant", weakModel);
40868
41394
  }
40869
41395
  } else {
40870
- weakModel = CODEX_WEAK_MODEL_CONSTANT;
41396
+ weakModel = weakConstantFor(providerId);
40871
41397
  logFallback(providerId, "weak", "constant", weakModel);
40872
41398
  }
40873
41399
  }
40874
41400
  return {
40875
41401
  id: providerId,
40876
41402
  capabilities,
40877
- models: { strong: strongModel, weak: weakModel }
41403
+ models: { strong: strongModel, weak: weakModel },
41404
+ ...pinRetired ? { pinRetired: true, retiredPin } : {}
40878
41405
  };
40879
41406
  }
40880
41407
 
@@ -42355,17 +42882,17 @@ function createTurnLock() {
42355
42882
  }
42356
42883
 
42357
42884
  // src/self-update.ts
42358
- var import_node_child_process8 = require("node:child_process");
42359
- var import_node_crypto2 = require("node:crypto");
42885
+ var import_node_child_process10 = require("node:child_process");
42886
+ var import_node_crypto3 = require("node:crypto");
42360
42887
  var import_node_fs4 = require("node:fs");
42361
- var import_node_path7 = __toESM(require("node:path"), 1);
42888
+ var import_node_path8 = __toESM(require("node:path"), 1);
42362
42889
  var import_semver3 = __toESM(require_semver2(), 1);
42363
42890
 
42364
42891
  // src/codex-auth-preflight.ts
42365
- var import_node_child_process7 = require("node:child_process");
42892
+ var import_node_child_process9 = require("node:child_process");
42366
42893
  var import_node_fs3 = require("node:fs");
42367
42894
  var import_node_os6 = __toESM(require("node:os"), 1);
42368
- var import_node_path6 = __toESM(require("node:path"), 1);
42895
+ var import_node_path7 = __toESM(require("node:path"), 1);
42369
42896
  var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
42370
42897
  var DEFAULT_CODEX_AUTH_SMOKE_TIMEOUT_MS = 2e4;
42371
42898
  var DEFAULT_CODEX_AUTH_SMOKE_MODEL = "gpt-5.4-mini";
@@ -42384,7 +42911,7 @@ function codexAuthSmokeTimeoutMs(env = process.env) {
42384
42911
  function resolveCodexAuthPath(opts = {}) {
42385
42912
  const env = opts.env ?? process.env;
42386
42913
  const codexHome = env.CODEX_HOME?.trim();
42387
- return import_node_path6.default.join(codexHome || import_node_path6.default.join(opts.homeDir ?? import_node_os6.default.homedir(), ".codex"), "auth.json");
42914
+ return import_node_path7.default.join(codexHome || import_node_path7.default.join(opts.homeDir ?? import_node_os6.default.homedir(), ".codex"), "auth.json");
42388
42915
  }
42389
42916
  function decodeJwtExpMs(token) {
42390
42917
  const parts = token.split(".");
@@ -42453,7 +42980,7 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
42453
42980
  CODEX_AUTH_SMOKE_PROMPT
42454
42981
  ];
42455
42982
  const command = commandForSmoke(executable, model);
42456
- const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process7.execFileSync;
42983
+ const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process9.execFileSync;
42457
42984
  try {
42458
42985
  execFileSync5(executable, args, {
42459
42986
  cwd,
@@ -42604,12 +43131,12 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
42604
43131
  var BIN_NAME = "mrrlin-mcp";
42605
43132
  var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
42606
43133
  function resolveBinPath(opts) {
42607
- if (opts.argv1 && import_node_path7.default.basename(opts.argv1).includes("mrrlin")) {
43134
+ if (opts.argv1 && import_node_path8.default.basename(opts.argv1).includes("mrrlin")) {
42608
43135
  return { path: opts.argv1, source: "argv" };
42609
43136
  }
42610
43137
  const whichSync = opts.whichSync ?? ((name) => {
42611
43138
  try {
42612
- return (0, import_node_child_process8.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
43139
+ return (0, import_node_child_process10.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
42613
43140
  } catch {
42614
43141
  return null;
42615
43142
  }
@@ -42620,9 +43147,9 @@ function resolveBinPath(opts) {
42620
43147
  return { path: resolved, source: "which" };
42621
43148
  }
42622
43149
  const envPath = (opts.env ?? process.env).PATH ?? "";
42623
- for (const dir of envPath.split(import_node_path7.default.delimiter)) {
43150
+ for (const dir of envPath.split(import_node_path8.default.delimiter)) {
42624
43151
  if (!dir) continue;
42625
- const candidate = import_node_path7.default.join(dir, BIN_NAME);
43152
+ const candidate = import_node_path8.default.join(dir, BIN_NAME);
42626
43153
  if (existsSync5(candidate)) {
42627
43154
  return { path: candidate, source: "path-walk" };
42628
43155
  }
@@ -42648,7 +43175,7 @@ function readIntervalEnv(name, fallback) {
42648
43175
  return Number.isFinite(n) && n > 0 ? n : fallback;
42649
43176
  }
42650
43177
  function sha256(buf) {
42651
- return (0, import_node_crypto2.createHash)("sha256").update(buf).digest("hex");
43178
+ return (0, import_node_crypto3.createHash)("sha256").update(buf).digest("hex");
42652
43179
  }
42653
43180
  function startSelfUpdate(deps) {
42654
43181
  const log = deps.log ?? (() => {
@@ -42940,17 +43467,17 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
42940
43467
  }
42941
43468
 
42942
43469
  // src/_generated/version.ts
42943
- var PKG_VERSION = "0.4.65";
43470
+ var PKG_VERSION = "0.4.67";
42944
43471
 
42945
43472
  // src/api-base-url-migrate.ts
42946
43473
  var import_node_fs5 = __toESM(require("node:fs"), 1);
42947
43474
  var import_node_os7 = __toESM(require("node:os"), 1);
42948
- var import_node_path9 = __toESM(require("node:path"), 1);
43475
+ var import_node_path10 = __toESM(require("node:path"), 1);
42949
43476
 
42950
43477
  // src/service-paths.ts
42951
- var import_node_path8 = __toESM(require("node:path"), 1);
43478
+ var import_node_path9 = __toESM(require("node:path"), 1);
42952
43479
  function isWorktreePath(p) {
42953
- const norm = import_node_path8.default.normalize(p).split(import_node_path8.default.sep).join("/");
43480
+ const norm = import_node_path9.default.normalize(p).split(import_node_path9.default.sep).join("/");
42954
43481
  return norm.includes("/.claude/worktrees/");
42955
43482
  }
42956
43483
  function resolveServiceCwd(opts) {
@@ -43008,7 +43535,7 @@ function defaultDeps(deps) {
43008
43535
  const home = deps.home ?? process.env.HOME ?? import_node_os7.default.homedir();
43009
43536
  return {
43010
43537
  home,
43011
- codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path9.default.join(home, ".codex"),
43538
+ codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path10.default.join(home, ".codex"),
43012
43539
  readFile: deps.readFile ?? ((p) => import_node_fs5.default.readFileSync(p, "utf8")),
43013
43540
  // Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
43014
43541
  // interleave partial writes into a config the next start has to parse. Note this normalizes the
@@ -43057,7 +43584,7 @@ function backupOnce(file2, text, deps) {
43057
43584
  }
43058
43585
  function migrateEcosystemConfig(deps = {}) {
43059
43586
  const d = defaultDeps(deps);
43060
- const file2 = import_node_path9.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
43587
+ const file2 = import_node_path10.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
43061
43588
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43062
43589
  const text = d.readFile(file2);
43063
43590
  if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
@@ -43207,7 +43734,7 @@ ${envLines}
43207
43734
  }
43208
43735
  function migrateCodexConfig(deps = {}) {
43209
43736
  const d = defaultDeps(deps);
43210
- const file2 = import_node_path9.default.join(d.codexHome, "config.toml");
43737
+ const file2 = import_node_path10.default.join(d.codexHome, "config.toml");
43211
43738
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43212
43739
  const text = d.readFile(file2);
43213
43740
  const host = findRetiredHost(text);
@@ -43293,7 +43820,7 @@ $1`
43293
43820
  }
43294
43821
  function migrateClaudeConfig(deps = {}) {
43295
43822
  const d = defaultDeps(deps);
43296
- const file2 = import_node_path9.default.join(d.home, ".claude.json");
43823
+ const file2 = import_node_path10.default.join(d.home, ".claude.json");
43297
43824
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43298
43825
  const text = d.readFile(file2);
43299
43826
  let parsed;
@@ -43343,9 +43870,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
43343
43870
  const d = defaultDeps(deps);
43344
43871
  const results = [];
43345
43872
  const steps = [
43346
- { run: migrateEcosystemConfig, file: import_node_path9.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
43347
- { run: migrateCodexConfig, file: import_node_path9.default.join(d.codexHome, "config.toml") },
43348
- { run: migrateClaudeConfig, file: import_node_path9.default.join(d.home, ".claude.json") }
43873
+ { run: migrateEcosystemConfig, file: import_node_path10.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
43874
+ { run: migrateCodexConfig, file: import_node_path10.default.join(d.codexHome, "config.toml") },
43875
+ { run: migrateClaudeConfig, file: import_node_path10.default.join(d.home, ".claude.json") }
43349
43876
  ];
43350
43877
  for (const step of steps) {
43351
43878
  try {
@@ -43372,7 +43899,7 @@ function migrateRetiredApiBaseUrls(deps = {}) {
43372
43899
 
43373
43900
  // src/bridge-health.ts
43374
43901
  var import_node_fs6 = require("node:fs");
43375
- var import_node_path10 = __toESM(require("node:path"), 1);
43902
+ var import_node_path11 = __toESM(require("node:path"), 1);
43376
43903
  var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
43377
43904
  var CRASH_WINDOW_MS = 60 * 60 * 1e3;
43378
43905
  var MAX_CRASHES_PER_WINDOW = 3;
@@ -43384,7 +43911,7 @@ function isCrashSentinel(value) {
43384
43911
  return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
43385
43912
  }
43386
43913
  async function readCrashSentinel(stateDir, now = Date.now) {
43387
- const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
43914
+ const sentinelPath = import_node_path11.default.join(stateDir, SENTINEL_FILE_NAME);
43388
43915
  try {
43389
43916
  const raw = await import_node_fs6.promises.readFile(sentinelPath, "utf8");
43390
43917
  const parsed = JSON.parse(raw);
@@ -43395,7 +43922,7 @@ async function readCrashSentinel(stateDir, now = Date.now) {
43395
43922
  }
43396
43923
  async function writeCrashSentinel(stateDir, sentinel) {
43397
43924
  await import_node_fs6.promises.mkdir(stateDir, { recursive: true });
43398
- const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
43925
+ const sentinelPath = import_node_path11.default.join(stateDir, SENTINEL_FILE_NAME);
43399
43926
  const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
43400
43927
  await import_node_fs6.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
43401
43928
  await import_node_fs6.promises.rename(tmpPath, sentinelPath);
@@ -43724,16 +44251,16 @@ function startSchedulerTickLoop(deps) {
43724
44251
  }
43725
44252
 
43726
44253
  // src/retention/pruner.ts
43727
- var import_promises4 = require("node:fs/promises");
43728
- var import_node_path11 = __toESM(require("node:path"), 1);
44254
+ var import_promises6 = require("node:fs/promises");
44255
+ var import_node_path12 = __toESM(require("node:path"), 1);
43729
44256
  function protectedDayFloor(protectedSinceMs) {
43730
44257
  return new Date(protectedSinceMs).toISOString().slice(0, 10);
43731
44258
  }
43732
44259
  async function prune(stateDir, bounds) {
43733
- const logsDir = import_node_path11.default.join(stateDir, "logs");
44260
+ const logsDir = import_node_path12.default.join(stateDir, "logs");
43734
44261
  let entries;
43735
44262
  try {
43736
- entries = await (0, import_promises4.readdir)(logsDir);
44263
+ entries = await (0, import_promises6.readdir)(logsDir);
43737
44264
  } catch (err) {
43738
44265
  if (err?.code === "ENOENT") {
43739
44266
  await emitPruneLog(stateDir, [], {}, 0, null);
@@ -43746,8 +44273,8 @@ async function prune(stateDir, bounds) {
43746
44273
  for (const entry of entries) {
43747
44274
  const m = bridgeRe.exec(entry);
43748
44275
  if (!m?.[1]) continue;
43749
- const fullPath = import_node_path11.default.join(logsDir, entry);
43750
- const s = await (0, import_promises4.stat)(fullPath);
44276
+ const fullPath = import_node_path12.default.join(logsDir, entry);
44277
+ const s = await (0, import_promises6.stat)(fullPath);
43751
44278
  files.push({ day: m[1], size: s.size, fullPath });
43752
44279
  }
43753
44280
  files.sort((a, b) => a.day < b.day ? -1 : a.day > b.day ? 1 : 0);
@@ -43755,10 +44282,10 @@ async function prune(stateDir, bounds) {
43755
44282
  const reasonByDay = {};
43756
44283
  let bytesRemoved = 0;
43757
44284
  async function isDaySafeToDelete(day) {
43758
- const telemetryDir = import_node_path11.default.join(stateDir, "telemetry");
44285
+ const telemetryDir = import_node_path12.default.join(stateDir, "telemetry");
43759
44286
  let telemetryEntries;
43760
44287
  try {
43761
- telemetryEntries = await (0, import_promises4.readdir)(telemetryDir);
44288
+ telemetryEntries = await (0, import_promises6.readdir)(telemetryDir);
43762
44289
  } catch (err) {
43763
44290
  if (err?.code === "ENOENT") return true;
43764
44291
  throw err;
@@ -43771,9 +44298,9 @@ async function prune(stateDir, bounds) {
43771
44298
  }
43772
44299
  if (projectSlugs.length === 0) return true;
43773
44300
  for (const slug of projectSlugs) {
43774
- const markerPath = import_node_path11.default.join(telemetryDir, `.processed-${slug}-${day}`);
44301
+ const markerPath = import_node_path12.default.join(telemetryDir, `.processed-${slug}-${day}`);
43775
44302
  try {
43776
- await (0, import_promises4.stat)(markerPath);
44303
+ await (0, import_promises6.stat)(markerPath);
43777
44304
  } catch (err) {
43778
44305
  if (err?.code === "ENOENT") return false;
43779
44306
  throw err;
@@ -43794,7 +44321,7 @@ async function prune(stateDir, bounds) {
43794
44321
  i += 1;
43795
44322
  continue;
43796
44323
  }
43797
- await (0, import_promises4.unlink)(candidate.fullPath);
44324
+ await (0, import_promises6.unlink)(candidate.fullPath);
43798
44325
  daysRemoved.push(candidate.day);
43799
44326
  reasonByDay[candidate.day] = "size";
43800
44327
  bytesRemoved += candidate.size;
@@ -43808,7 +44335,7 @@ async function prune(stateDir, bounds) {
43808
44335
  const fileDate = /* @__PURE__ */ new Date(`${info.day}T00:00:00Z`);
43809
44336
  const ageInDays = (now - fileDate.getTime()) / msPerDay;
43810
44337
  if (ageInDays > bounds.ageDays && !isProtected(info.day) && await isDaySafeToDelete(info.day)) {
43811
- await (0, import_promises4.unlink)(info.fullPath);
44338
+ await (0, import_promises6.unlink)(info.fullPath);
43812
44339
  daysRemoved.push(info.day);
43813
44340
  reasonByDay[info.day] = "age";
43814
44341
  bytesRemoved += info.size;
@@ -43821,11 +44348,11 @@ async function prune(stateDir, bounds) {
43821
44348
  const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
43822
44349
  await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
43823
44350
  if (daysRemoved.length > 0) {
43824
- const sessionsPath = import_node_path11.default.join(logsDir, ".sessions.json");
44351
+ const sessionsPath = import_node_path12.default.join(logsDir, ".sessions.json");
43825
44352
  let sessionsObj = {};
43826
44353
  let fileExists = true;
43827
44354
  try {
43828
- sessionsObj = JSON.parse(await (0, import_promises4.readFile)(sessionsPath, "utf8"));
44355
+ sessionsObj = JSON.parse(await (0, import_promises6.readFile)(sessionsPath, "utf8"));
43829
44356
  } catch (err) {
43830
44357
  if (err?.code === "ENOENT") {
43831
44358
  fileExists = false;
@@ -43836,25 +44363,25 @@ async function prune(stateDir, bounds) {
43836
44363
  if (fileExists) {
43837
44364
  for (const day of daysRemoved) Reflect.deleteProperty(sessionsObj, day);
43838
44365
  const tmpPath = `${sessionsPath}.tmp`;
43839
- await (0, import_promises4.writeFile)(tmpPath, JSON.stringify(sessionsObj));
43840
- await (0, import_promises4.rename)(tmpPath, sessionsPath);
44366
+ await (0, import_promises6.writeFile)(tmpPath, JSON.stringify(sessionsObj));
44367
+ await (0, import_promises6.rename)(tmpPath, sessionsPath);
43841
44368
  }
43842
44369
  }
43843
44370
  return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
43844
44371
  }
43845
44372
  async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining) {
43846
- const logsDir = import_node_path11.default.join(stateDir, "logs");
43847
- const logPath = import_node_path11.default.join(logsDir, ".pruned.jsonl");
43848
- await (0, import_promises4.mkdir)(logsDir, { recursive: true });
44373
+ const logsDir = import_node_path12.default.join(stateDir, "logs");
44374
+ const logPath = import_node_path12.default.join(logsDir, ".pruned.jsonl");
44375
+ await (0, import_promises6.mkdir)(logsDir, { recursive: true });
43849
44376
  const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
43850
- await (0, import_promises4.appendFile)(logPath, `${JSON.stringify(record2)}
44377
+ await (0, import_promises6.appendFile)(logPath, `${JSON.stringify(record2)}
43851
44378
  `);
43852
44379
  }
43853
44380
 
43854
44381
  // src/telemetry/turn-aggregator.ts
43855
- var import_node_crypto3 = require("node:crypto");
43856
- var import_promises5 = require("node:fs/promises");
43857
- var import_node_path12 = require("node:path");
44382
+ var import_node_crypto4 = require("node:crypto");
44383
+ var import_promises7 = require("node:fs/promises");
44384
+ var import_node_path13 = require("node:path");
43858
44385
  var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
43859
44386
  var PLUMBING_COUNTER_KEY = {
43860
44387
  socket_close: "socketCloses",
@@ -43883,10 +44410,10 @@ function inheritSlug(seeds, index) {
43883
44410
  return (preceding ?? following)?.slug;
43884
44411
  }
43885
44412
  async function foldClosedDays(stateDir, today) {
43886
- const logsDir = (0, import_node_path12.join)(stateDir, "logs");
44413
+ const logsDir = (0, import_node_path13.join)(stateDir, "logs");
43887
44414
  let entries;
43888
44415
  try {
43889
- entries = await (0, import_promises5.readdir)(logsDir);
44416
+ entries = await (0, import_promises7.readdir)(logsDir);
43890
44417
  } catch {
43891
44418
  return;
43892
44419
  }
@@ -43895,7 +44422,7 @@ async function foldClosedDays(stateDir, today) {
43895
44422
  if (!m) continue;
43896
44423
  const day = m[1];
43897
44424
  if (day === today) continue;
43898
- const raw = await (0, import_promises5.readFile)((0, import_node_path12.join)(logsDir, entry), "utf8");
44425
+ const raw = await (0, import_promises7.readFile)((0, import_node_path13.join)(logsDir, entry), "utf8");
43899
44426
  const groups = /* @__PURE__ */ new Map();
43900
44427
  let groupCounter = 0;
43901
44428
  for (const line of raw.split("\n")) {
@@ -44006,16 +44533,16 @@ async function foldClosedDays(stateDir, today) {
44006
44533
  rowsByProject.set(slug, rows);
44007
44534
  }
44008
44535
  if (rowsByProject.size === 0) continue;
44009
- const telemetryDir = (0, import_node_path12.join)(stateDir, "telemetry");
44010
- await (0, import_promises5.mkdir)(telemetryDir, { recursive: true });
44536
+ const telemetryDir = (0, import_node_path13.join)(stateDir, "telemetry");
44537
+ await (0, import_promises7.mkdir)(telemetryDir, { recursive: true });
44011
44538
  for (const [slug, rows] of rowsByProject) {
44012
- const finalPath = (0, import_node_path12.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
44013
- const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto3.randomBytes)(6).toString("hex")}`;
44539
+ const finalPath = (0, import_node_path13.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
44540
+ const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}`;
44014
44541
  try {
44015
- await (0, import_promises5.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
44016
- await (0, import_promises5.rename)(tmpPath, finalPath);
44542
+ await (0, import_promises7.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
44543
+ await (0, import_promises7.rename)(tmpPath, finalPath);
44017
44544
  } finally {
44018
- await (0, import_promises5.unlink)(tmpPath).catch(() => {
44545
+ await (0, import_promises7.unlink)(tmpPath).catch(() => {
44019
44546
  });
44020
44547
  }
44021
44548
  }
@@ -44023,23 +44550,23 @@ async function foldClosedDays(stateDir, today) {
44023
44550
  }
44024
44551
 
44025
44552
  // src/telemetry/daily-uploader.ts
44026
- var import_promises6 = require("node:fs/promises");
44027
- var import_node_path17 = require("node:path");
44553
+ var import_promises8 = require("node:fs/promises");
44554
+ var import_node_path18 = require("node:path");
44028
44555
 
44029
44556
  // src/consensus/wiring.ts
44030
- var import_node_crypto4 = __toESM(require("node:crypto"), 1);
44557
+ var import_node_crypto5 = __toESM(require("node:crypto"), 1);
44031
44558
  var import_node_fs9 = __toESM(require("node:fs"), 1);
44032
- var import_node_path15 = __toESM(require("node:path"), 1);
44559
+ var import_node_path16 = __toESM(require("node:path"), 1);
44033
44560
  var import_node_url2 = require("node:url");
44034
44561
 
44035
44562
  // src/consensus/gate-usage-log.ts
44036
44563
  var import_node_fs7 = require("node:fs");
44037
- var import_node_path13 = require("node:path");
44564
+ var import_node_path14 = require("node:path");
44038
44565
  function recordGateCall(stateDir, projectSlug, record2) {
44039
44566
  try {
44040
- const dir = (0, import_node_path13.join)(stateDir, "telemetry");
44567
+ const dir = (0, import_node_path14.join)(stateDir, "telemetry");
44041
44568
  (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
44042
- (0, import_node_fs7.appendFileSync)((0, import_node_path13.join)(dir, gateFileName(projectSlug, record2.day)), `${JSON.stringify(record2)}
44569
+ (0, import_node_fs7.appendFileSync)((0, import_node_path14.join)(dir, gateFileName(projectSlug, record2.day)), `${JSON.stringify(record2)}
44043
44570
  `, "utf8");
44044
44571
  } catch {
44045
44572
  }
@@ -44907,15 +45434,15 @@ ${issuesBlock}`,
44907
45434
  // src/consensus/sterile-cwd.ts
44908
45435
  var import_node_fs8 = require("node:fs");
44909
45436
  var import_node_os8 = require("node:os");
44910
- var import_node_path14 = require("node:path");
45437
+ var import_node_path15 = require("node:path");
44911
45438
  var sterileDir = null;
44912
45439
  function sterileCwd() {
44913
- sterileDir ??= (0, import_node_fs8.mkdtempSync)((0, import_node_path14.join)((0, import_node_os8.tmpdir)(), "mrrlin-gate-"));
45440
+ sterileDir ??= (0, import_node_fs8.mkdtempSync)((0, import_node_path15.join)((0, import_node_os8.tmpdir)(), "mrrlin-gate-"));
44914
45441
  return sterileDir;
44915
45442
  }
44916
45443
 
44917
45444
  // src/consensus/code-gate-git.ts
44918
- var import_node_child_process9 = require("node:child_process");
45445
+ var import_node_child_process11 = require("node:child_process");
44919
45446
  var DIFF_MAX_BYTES = 2e5;
44920
45447
  var FASTGATE_OUTPUT_MAX_BYTES = 16e3;
44921
45448
  var GIT_TIMEOUT_MS = 6e4;
@@ -44931,7 +45458,7 @@ var defaultRunCmd = (cmd, args, opts) => new Promise((resolve) => {
44931
45458
  };
44932
45459
  let child;
44933
45460
  try {
44934
- child = (0, import_node_child_process9.spawn)(cmd, args, {
45461
+ child = (0, import_node_child_process11.spawn)(cmd, args, {
44935
45462
  cwd: opts.cwd,
44936
45463
  env: process.env,
44937
45464
  shell: false,
@@ -45146,15 +45673,15 @@ ${res.stdout}${res.stderr}`);
45146
45673
  var import_meta2 = {};
45147
45674
  function getPersonasDir() {
45148
45675
  if (typeof __dirname !== "undefined") {
45149
- return import_node_path15.default.join(__dirname, "consensus", "personas");
45676
+ return import_node_path16.default.join(__dirname, "consensus", "personas");
45150
45677
  }
45151
- return import_node_path15.default.join(import_node_path15.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
45678
+ return import_node_path16.default.join(import_node_path16.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
45152
45679
  }
45153
45680
  var personaCache = /* @__PURE__ */ new Map();
45154
45681
  function loadPersona(name) {
45155
45682
  const cached2 = personaCache.get(name);
45156
45683
  if (cached2 !== void 0) return cached2;
45157
- const content = import_node_fs9.default.readFileSync(import_node_path15.default.join(getPersonasDir(), `${name}.md`), "utf8");
45684
+ const content = import_node_fs9.default.readFileSync(import_node_path16.default.join(getPersonasDir(), `${name}.md`), "utf8");
45158
45685
  personaCache.set(name, content);
45159
45686
  return content;
45160
45687
  }
@@ -45719,7 +46246,7 @@ You revise a deliverable to address the accepted issues so it satisfies the acce
45719
46246
  try {
45720
46247
  const diagnostics = Array.isArray(r["diagnostics"]) ? r["diagnostics"] : void 0;
45721
46248
  await client.appendExecutionArtifact(projectSlug, runId, {
45722
- id: `EA-${import_node_crypto4.default.randomUUID()}`,
46249
+ id: `EA-${import_node_crypto5.default.randomUUID()}`,
45723
46250
  kind: "verification",
45724
46251
  payload: {
45725
46252
  source: "deliverable-gate",
@@ -45821,23 +46348,23 @@ async function gate(artifact, prose, ctx) {
45821
46348
  }
45822
46349
 
45823
46350
  // src/telemetry/installation-id.ts
45824
- var import_node_crypto5 = require("node:crypto");
46351
+ var import_node_crypto6 = require("node:crypto");
45825
46352
  var import_node_fs10 = require("node:fs");
45826
- var import_node_path16 = require("node:path");
46353
+ var import_node_path17 = require("node:path");
45827
46354
  var FILE_NAME = "installation-id";
45828
46355
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
45829
46356
  var cache = /* @__PURE__ */ new Map();
45830
46357
  function resolveInstallationId(stateDir) {
45831
46358
  const cached2 = cache.get(stateDir);
45832
46359
  if (cached2 !== void 0) return cached2;
45833
- const path25 = (0, import_node_path16.join)(stateDir, FILE_NAME);
46360
+ const path25 = (0, import_node_path17.join)(stateDir, FILE_NAME);
45834
46361
  let id;
45835
46362
  try {
45836
46363
  id = (0, import_node_fs10.readFileSync)(path25, "utf8").trim();
45837
46364
  if (!UUID.test(id)) throw new Error("unusable");
45838
46365
  } catch {
45839
- id = (0, import_node_crypto5.randomUUID)();
45840
- (0, import_node_fs10.mkdirSync)((0, import_node_path16.dirname)(path25), { recursive: true });
46366
+ id = (0, import_node_crypto6.randomUUID)();
46367
+ (0, import_node_fs10.mkdirSync)((0, import_node_path17.dirname)(path25), { recursive: true });
45841
46368
  (0, import_node_fs10.writeFileSync)(path25, `${id}
45842
46369
  `, "utf8");
45843
46370
  }
@@ -45855,10 +46382,10 @@ function truncateCause(err) {
45855
46382
  return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
45856
46383
  }
45857
46384
  async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45858
- const telemetryDir = (0, import_node_path17.join)(stateDir, "telemetry");
46385
+ const telemetryDir = (0, import_node_path18.join)(stateDir, "telemetry");
45859
46386
  let files;
45860
46387
  try {
45861
- files = await (0, import_promises6.readdir)(telemetryDir);
46388
+ files = await (0, import_promises8.readdir)(telemetryDir);
45862
46389
  } catch (err) {
45863
46390
  if (err?.code === "ENOENT") return;
45864
46391
  throw err;
@@ -45871,24 +46398,24 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45871
46398
  const [, projectSlug, day] = match;
45872
46399
  const key = `${projectSlug}\0${day}`;
45873
46400
  const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
45874
- if (rowsMatch) entry.rowsPath = (0, import_node_path17.join)(telemetryDir, file2);
46401
+ if (rowsMatch) entry.rowsPath = (0, import_node_path18.join)(telemetryDir, file2);
45875
46402
  discovered.set(key, entry);
45876
46403
  }
45877
46404
  const today = telemetryDay();
45878
46405
  const pending = [];
45879
46406
  const deferred = [];
45880
46407
  for (const { projectSlug, day, rowsPath } of discovered.values()) {
45881
- const markerPath = (0, import_node_path17.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
46408
+ const markerPath = (0, import_node_path18.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
45882
46409
  if (rowsPath === null && day >= today) {
45883
46410
  try {
45884
- await (0, import_promises6.access)(markerPath);
46411
+ await (0, import_promises8.access)(markerPath);
45885
46412
  } catch {
45886
46413
  deferred.push({ projectSlug, day });
45887
46414
  }
45888
46415
  continue;
45889
46416
  }
45890
46417
  try {
45891
- await (0, import_promises6.access)(markerPath);
46418
+ await (0, import_promises8.access)(markerPath);
45892
46419
  } catch {
45893
46420
  pending.push({ projectSlug, day, rowsPath, markerPath });
45894
46421
  }
@@ -45898,10 +46425,10 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45898
46425
  const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
45899
46426
  pending.sort((a, b) => a.day.localeCompare(b.day));
45900
46427
  for (const cur of pending) {
45901
- const failurePath = (0, import_node_path17.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
46428
+ const failurePath = (0, import_node_path18.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
45902
46429
  let failureState = null;
45903
46430
  try {
45904
- const data = await (0, import_promises6.readFile)(failurePath, "utf8");
46431
+ const data = await (0, import_promises8.readFile)(failurePath, "utf8");
45905
46432
  failureState = JSON.parse(data);
45906
46433
  } catch {
45907
46434
  failureState = null;
@@ -45916,7 +46443,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45916
46443
  let raw = "";
45917
46444
  if (cur.rowsPath !== null) {
45918
46445
  try {
45919
- raw = await (0, import_promises6.readFile)(cur.rowsPath, "utf8");
46446
+ raw = await (0, import_promises8.readFile)(cur.rowsPath, "utf8");
45920
46447
  } catch (err) {
45921
46448
  console.error(`uploadPendingDays: failed to read ${cur.rowsPath}`, err);
45922
46449
  throw err;
@@ -45932,7 +46459,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45932
46459
  }
45933
46460
  const gateCalls = [];
45934
46461
  try {
45935
- const rawGate = await (0, import_promises6.readFile)((0, import_node_path17.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
46462
+ const rawGate = await (0, import_promises8.readFile)((0, import_node_path18.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
45936
46463
  for (const line of rawGate.split("\n")) {
45937
46464
  if (!line.trim()) continue;
45938
46465
  try {
@@ -45974,14 +46501,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45974
46501
  if (success2) {
45975
46502
  const tmpMarker = `${cur.markerPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
45976
46503
  try {
45977
- await (0, import_promises6.writeFile)(tmpMarker, "");
45978
- await (0, import_promises6.rename)(tmpMarker, cur.markerPath);
46504
+ await (0, import_promises8.writeFile)(tmpMarker, "");
46505
+ await (0, import_promises8.rename)(tmpMarker, cur.markerPath);
45979
46506
  } catch (err) {
45980
46507
  console.error(`uploadPendingDays: failed to write marker for ${cur.projectSlug}/${cur.day}`, err);
45981
46508
  }
45982
46509
  if (failureState) {
45983
46510
  try {
45984
- await (0, import_promises6.unlink)(failurePath);
46511
+ await (0, import_promises8.unlink)(failurePath);
45985
46512
  console.log(`uploadPendingDays: partition ${cur.projectSlug}/${cur.day} recovered after ${failureState.failureCount + 1} consecutive failures`);
45986
46513
  } catch (err) {
45987
46514
  console.error(`uploadPendingDays: failed to remove failure state for ${cur.projectSlug}/${cur.day}`, err);
@@ -46009,8 +46536,8 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
46009
46536
  };
46010
46537
  const tmpFailurePath = `${failurePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
46011
46538
  try {
46012
- await (0, import_promises6.writeFile)(tmpFailurePath, JSON.stringify(newFailureState));
46013
- await (0, import_promises6.rename)(tmpFailurePath, failurePath);
46539
+ await (0, import_promises8.writeFile)(tmpFailurePath, JSON.stringify(newFailureState));
46540
+ await (0, import_promises8.rename)(tmpFailurePath, failurePath);
46014
46541
  } catch (writeErr) {
46015
46542
  console.error(`uploadPendingDays: failed to write failure state for ${cur.projectSlug}/${cur.day}`, writeErr);
46016
46543
  }
@@ -46136,7 +46663,7 @@ async function collectAgentPoolSnapshot(deps) {
46136
46663
  }
46137
46664
 
46138
46665
  // src/external-agents-spawn.ts
46139
- var import_node_child_process10 = require("node:child_process");
46666
+ var import_node_child_process12 = require("node:child_process");
46140
46667
 
46141
46668
  // src/external-agents-bin.ts
46142
46669
  function resolveExternalAgentsCliInvocation(override) {
@@ -46182,7 +46709,7 @@ function runExternalAgentsCli(args, opts) {
46182
46709
  };
46183
46710
  let spawned;
46184
46711
  try {
46185
- spawned = (0, import_node_child_process10.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
46712
+ spawned = (0, import_node_child_process12.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
46186
46713
  } catch {
46187
46714
  done(1);
46188
46715
  return;
@@ -46294,14 +46821,14 @@ function startAgentPoolLoop(deps) {
46294
46821
  }
46295
46822
 
46296
46823
  // src/provider-readiness-loop.ts
46297
- var import_node_child_process11 = require("node:child_process");
46824
+ var import_node_child_process13 = require("node:child_process");
46298
46825
  var DEFAULT_INTERVAL_MS3 = 6e4;
46299
46826
  function providerReadinessLoopDisabled(env = process.env) {
46300
46827
  return env["MRRLIN_BRIDGE_PROVIDER_READINESS_DISABLE"] === "1";
46301
46828
  }
46302
46829
  function defaultRunnerFor(command) {
46303
46830
  return (args) => {
46304
- const r = (0, import_node_child_process11.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
46831
+ const r = (0, import_node_child_process13.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
46305
46832
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
46306
46833
  };
46307
46834
  }
@@ -46353,10 +46880,10 @@ function setSelectedProvider(value) {
46353
46880
  }
46354
46881
 
46355
46882
  // src/execution-consumer.ts
46356
- var import_node_child_process13 = require("node:child_process");
46357
- var import_node_crypto7 = __toESM(require("node:crypto"), 1);
46358
- var import_node_path20 = __toESM(require("node:path"), 1);
46359
- var import_node_util = require("node:util");
46883
+ var import_node_child_process15 = require("node:child_process");
46884
+ var import_node_crypto8 = __toESM(require("node:crypto"), 1);
46885
+ var import_node_path22 = __toESM(require("node:path"), 1);
46886
+ var import_node_util2 = require("node:util");
46360
46887
 
46361
46888
  // src/consensus/deliverable-gate-outcome.ts
46362
46889
  var MAX_DELIVERABLE_DIAGNOSTICS = 5;
@@ -46425,7 +46952,7 @@ function mapDeliverableGateResult(result) {
46425
46952
  }
46426
46953
 
46427
46954
  // src/async-tools/draft-spec.ts
46428
- var import_node_crypto6 = require("node:crypto");
46955
+ var import_node_crypto7 = require("node:crypto");
46429
46956
  var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
46430
46957
  var SPECS_FOLDER = "Specs";
46431
46958
  var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
@@ -46920,7 +47447,7 @@ function onComplete(outcome, input) {
46920
47447
  };
46921
47448
  }
46922
47449
  const summary = outcome.error;
46923
- const hash3 = (0, import_node_crypto6.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
47450
+ const hash3 = (0, import_node_crypto7.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
46924
47451
  return {
46925
47452
  kind: "info",
46926
47453
  id: `II-sched-draft-failed-${input.taskId}-${hash3}`,
@@ -47650,18 +48177,18 @@ async function awaitTurnWithDeadline(opts) {
47650
48177
  }
47651
48178
 
47652
48179
  // src/worktree.ts
47653
- var import_node_child_process12 = require("node:child_process");
48180
+ var import_node_child_process14 = require("node:child_process");
47654
48181
  var import_node_fs12 = require("node:fs");
47655
48182
  var import_node_os9 = require("node:os");
47656
- var import_node_path19 = require("node:path");
48183
+ var import_node_path20 = require("node:path");
47657
48184
 
47658
48185
  // src/checkout-lock.ts
47659
48186
  var import_node_fs11 = require("node:fs");
47660
- var import_node_path18 = require("node:path");
48187
+ var import_node_path19 = require("node:path");
47661
48188
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
47662
48189
  async function withCheckoutLock(locksDir, slug, fn) {
47663
48190
  (0, import_node_fs11.mkdirSync)(locksDir, { recursive: true });
47664
- const target = (0, import_node_path18.join)(locksDir, `${slug}.lock`);
48191
+ const target = (0, import_node_path19.join)(locksDir, `${slug}.lock`);
47665
48192
  if (!(0, import_node_fs11.existsSync)(target)) (0, import_node_fs11.writeFileSync)(target, "");
47666
48193
  const release = await import_proper_lockfile.default.lock(target, {
47667
48194
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
@@ -47678,16 +48205,16 @@ async function withCheckoutLock(locksDir, slug, fn) {
47678
48205
  function worktreeBranch(runId) {
47679
48206
  return `mrrlin/run-${runId}`;
47680
48207
  }
47681
- var defaultGitExec = (args, env) => (0, import_node_child_process12.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
48208
+ var defaultGitExec = (args, env) => (0, import_node_child_process14.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
47682
48209
  function git(checkout, args) {
47683
- return (0, import_node_child_process12.execFileSync)("git", ["-C", checkout, ...args], {
48210
+ return (0, import_node_child_process14.execFileSync)("git", ["-C", checkout, ...args], {
47684
48211
  encoding: "utf8",
47685
48212
  timeout: 3e4,
47686
48213
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
47687
48214
  });
47688
48215
  }
47689
48216
  async function createRunWorktree(opts) {
47690
- const worktreePath = (0, import_node_path19.join)(opts.worktreeRoot, opts.slug, opts.runId);
48217
+ const worktreePath = (0, import_node_path20.join)(opts.worktreeRoot, opts.slug, opts.runId);
47691
48218
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47692
48219
  (0, import_node_fs12.mkdirSync)(opts.worktreeRoot, { recursive: true });
47693
48220
  try {
@@ -47764,8 +48291,8 @@ async function doPushRunBranch(opts, execGit) {
47764
48291
  if (localConfig.trim()) {
47765
48292
  throw new Error(`push aborted: agent-controlled git config present in worktree: ${localConfig.trim().split("\n")[0]}`);
47766
48293
  }
47767
- const dir = (0, import_node_fs12.mkdtempSync)((0, import_node_path19.join)((0, import_node_os9.tmpdir)(), "mrrlin-push-"));
47768
- const askpass = (0, import_node_path19.join)(dir, "askpass");
48294
+ const dir = (0, import_node_fs12.mkdtempSync)((0, import_node_path20.join)((0, import_node_os9.tmpdir)(), "mrrlin-push-"));
48295
+ const askpass = (0, import_node_path20.join)(dir, "askpass");
47769
48296
  try {
47770
48297
  (0, import_node_fs12.writeFileSync)(
47771
48298
  askpass,
@@ -47802,7 +48329,7 @@ async function sweepOrphanWorktrees(opts) {
47802
48329
  } catch {
47803
48330
  return opts.worktreeRoot;
47804
48331
  }
47805
- })() + import_node_path19.sep + opts.slug + import_node_path19.sep;
48332
+ })() + import_node_path20.sep + opts.slug + import_node_path20.sep;
47806
48333
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47807
48334
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"]);
47808
48335
  for (const block of listing.split("\n\n")) {
@@ -47962,6 +48489,132 @@ function effortDisabled(env = process.env) {
47962
48489
  return (env.MRRLIN_EXEC_EFFORT_DISABLE ?? "").trim() === "1";
47963
48490
  }
47964
48491
 
48492
+ // src/operator-token.ts
48493
+ var import_node_fs13 = require("node:fs");
48494
+ var import_node_os10 = __toESM(require("node:os"), 1);
48495
+ var import_node_path21 = __toESM(require("node:path"), 1);
48496
+ function operatorDir() {
48497
+ const base = process.env.CODEX_HOME ? import_node_path21.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path21.default.join(import_node_os10.default.homedir(), ".mrrlin");
48498
+ return base;
48499
+ }
48500
+ function operatorTokenPath() {
48501
+ return import_node_path21.default.join(operatorDir(), "operator-token");
48502
+ }
48503
+ function readOperatorToken() {
48504
+ try {
48505
+ const token = (0, import_node_fs13.readFileSync)(operatorTokenPath(), "utf8").trim();
48506
+ return token.length > 0 ? token : null;
48507
+ } catch {
48508
+ return null;
48509
+ }
48510
+ }
48511
+ function persistOperatorToken(token) {
48512
+ const dir = operatorDir();
48513
+ (0, import_node_fs13.mkdirSync)(dir, { recursive: true, mode: 448 });
48514
+ (0, import_node_fs13.writeFileSync)(operatorTokenPath(), `${token.trim()}
48515
+ `, { encoding: "utf8", mode: 384 });
48516
+ }
48517
+ function agentCredentialPath() {
48518
+ return import_node_path21.default.join(operatorDir(), "agent-credential");
48519
+ }
48520
+ function persistAgentSecret(secret) {
48521
+ const dir = operatorDir();
48522
+ (0, import_node_fs13.mkdirSync)(dir, { recursive: true, mode: 448 });
48523
+ (0, import_node_fs13.writeFileSync)(agentCredentialPath(), `${secret.trim()}
48524
+ `, { encoding: "utf8", mode: 384 });
48525
+ }
48526
+ function readAgentSecret() {
48527
+ const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
48528
+ if (fromEnv) return fromEnv;
48529
+ try {
48530
+ const raw = (0, import_node_fs13.readFileSync)(agentCredentialPath(), "utf8").trim();
48531
+ return raw || void 0;
48532
+ } catch {
48533
+ return void 0;
48534
+ }
48535
+ }
48536
+
48537
+ // src/pin-retirement-notifier.ts
48538
+ var notifiedPins = /* @__PURE__ */ new Set();
48539
+ var inFlightPins = /* @__PURE__ */ new Set();
48540
+ function getDedupKey(providerId, pinnedModel) {
48541
+ return pinnedModel ? `${providerId}:${pinnedModel}` : providerId;
48542
+ }
48543
+ async function notifyPinRetirement(info, opts) {
48544
+ if (info.providerId === "claude") {
48545
+ return;
48546
+ }
48547
+ const dedupKey = getDedupKey(info.providerId, info.pinnedModel);
48548
+ if (notifiedPins.has(dedupKey) || inFlightPins.has(dedupKey)) {
48549
+ return;
48550
+ }
48551
+ inFlightPins.add(dedupKey);
48552
+ try {
48553
+ const apiBaseUrl = opts?.apiBaseUrl ?? process.env.MRRLIN_API_BASE_URL ?? "http://127.0.0.1:8787";
48554
+ const projectSlug = info.projectSlug ?? process.env.MRRLIN_REPORT_PROJECT_SLUG?.trim() ?? "mrrlin";
48555
+ const token = opts?.token !== void 0 ? opts.token : process.env.MRRLIN_API_TOKEN?.trim() || readOperatorToken();
48556
+ const fetchImpl = opts?.fetch ?? globalThis.fetch;
48557
+ const endpoint = `${apiBaseUrl.replace(/\/+$/, "")}/projects/${encodeURIComponent(
48558
+ projectSlug
48559
+ )}/tasks`;
48560
+ const headers = {
48561
+ "content-type": "application/json",
48562
+ "x-mrrlin-actor": "mrrlin-bridge",
48563
+ "x-mrrlin-director-session-id": "pin-retirement-signal"
48564
+ };
48565
+ if (token) {
48566
+ headers.authorization = `Bearer ${token}`;
48567
+ }
48568
+ const body = {
48569
+ title: `[Bug] Retired strong-model pin: ${info.providerId} (${info.pinnedModel})`,
48570
+ type: "bug",
48571
+ category: "bug",
48572
+ subcategory: "reported",
48573
+ domain: "code",
48574
+ impact: "medium",
48575
+ notes: `The pinned strong model "${info.pinnedModel}" for provider "${info.providerId}" was not found in the provider's live model list (retired by provider). Falling back to live default model "${info.fallbackModel}". Please update the operator pin in ~/.mrrlin/ecosystem.config.cjs or the corresponding environment variable (MRRLIN_${info.providerId.toUpperCase()}_STRONG_MODEL).`,
48576
+ operatorSeedRequest: `The pinned strong model "${info.pinnedModel}" for provider "${info.providerId}" has been retired. Fallback in use: "${info.fallbackModel}". Update the strong model pin.`,
48577
+ autonomyLevel: "human_review",
48578
+ autonomyReason: "Needs human review before automation."
48579
+ };
48580
+ const response = await fetchImpl(endpoint, {
48581
+ method: "POST",
48582
+ headers,
48583
+ body: JSON.stringify(body)
48584
+ });
48585
+ if (response.ok) {
48586
+ notifiedPins.add(dedupKey);
48587
+ } else {
48588
+ console.warn(
48589
+ `[pin-retirement-notifier] received non-2xx status (${response.status}) from ${endpoint}`
48590
+ );
48591
+ }
48592
+ } catch (err) {
48593
+ console.warn(
48594
+ `[pin-retirement-notifier] failed to report retirement for provider "${info.providerId}":`,
48595
+ err
48596
+ );
48597
+ } finally {
48598
+ inFlightPins.delete(dedupKey);
48599
+ }
48600
+ }
48601
+ async function notifyPinRetirementIfRetired(seat, opts) {
48602
+ if (!seat.pinRetired) {
48603
+ return;
48604
+ }
48605
+ const pinnedModel = seat.retiredPin ?? (seat.id === "codex" ? process.env.MRRLIN_CODEX_STRONG_MODEL : seat.id === "claude" ? process.env.MRRLIN_CLAUDE_STRONG_MODEL : void 0) ?? "unknown";
48606
+ const fallbackModel = seat.models?.strong ?? "unknown";
48607
+ await notifyPinRetirement(
48608
+ {
48609
+ providerId: seat.id,
48610
+ pinnedModel,
48611
+ fallbackModel,
48612
+ projectSlug: opts?.projectSlug
48613
+ },
48614
+ opts
48615
+ );
48616
+ }
48617
+
47965
48618
  // src/execution-consumer.ts
47966
48619
  var DEFAULT_STALE_SECONDS = 300;
47967
48620
  var DEFAULT_MAX_LEASE_RECLAIMS = 3;
@@ -48322,24 +48975,24 @@ function isBridgeGeneratedArtifact(artifact) {
48322
48975
  return typeof payload === "object" && payload !== null && "event" in payload;
48323
48976
  }
48324
48977
  function newArtifactId() {
48325
- return `EA-${import_node_crypto7.default.randomUUID()}`;
48978
+ return `EA-${import_node_crypto8.default.randomUUID()}`;
48326
48979
  }
48327
48980
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
48328
48981
  function isBlastRadiusFloorPath(path25) {
48329
48982
  return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path25));
48330
48983
  }
48331
- var execFileAsync = (0, import_node_util.promisify)(import_node_child_process13.execFile);
48984
+ var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process15.execFile);
48332
48985
  async function defaultListRunDiffPaths(opts) {
48333
48986
  const parse6 = (stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
48334
48987
  try {
48335
- const { stdout } = await execFileAsync(
48988
+ const { stdout } = await execFileAsync2(
48336
48989
  "git",
48337
48990
  ["-C", opts.worktreePath, "diff", "--name-only", `origin/${opts.defaultBranch}...HEAD`],
48338
48991
  { timeout: 3e4 }
48339
48992
  );
48340
48993
  return parse6(stdout);
48341
48994
  } catch {
48342
- const { stdout } = await execFileAsync(
48995
+ const { stdout } = await execFileAsync2(
48343
48996
  "git",
48344
48997
  ["-C", opts.worktreePath, "diff", "--name-only", `${opts.defaultBranch}...HEAD`],
48345
48998
  { timeout: 3e4 }
@@ -48564,7 +49217,7 @@ async function driveRun(deps, projectSlug, runId) {
48564
49217
  if (!claimed) return;
48565
49218
  if (!claimed.leaseId) {
48566
49219
  await deps.client.createInboxItem(projectSlug, {
48567
- id: `II-${import_node_crypto7.default.randomUUID()}`,
49220
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
48568
49221
  kind: "handoff",
48569
49222
  taskId: claimed.taskId,
48570
49223
  body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
@@ -48689,6 +49342,7 @@ async function driveRun(deps, projectSlug, runId) {
48689
49342
  resolvedProviderId = claimed.agentSeat;
48690
49343
  } else {
48691
49344
  const seat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
49345
+ void notifyPinRetirementIfRetired(seat, { projectSlug });
48692
49346
  resolvedProviderId = seat.id;
48693
49347
  await deps.client.updateExecutionRun(projectSlug, runId, { agentSeat: seat.id }).catch((err) => {
48694
49348
  console.warn(
@@ -49781,7 +50435,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
49781
50435
  }
49782
50436
  try {
49783
50437
  await deps.client.createInboxItem(projectSlug, {
49784
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50438
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49785
50439
  kind: "handoff",
49786
50440
  taskId: task.id,
49787
50441
  body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
@@ -49816,7 +50470,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
49816
50470
  }
49817
50471
  try {
49818
50472
  await deps.client.createInboxItem(projectSlug, {
49819
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50473
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49820
50474
  kind: "handoff",
49821
50475
  taskId: task.id,
49822
50476
  body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
@@ -49956,8 +50610,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
49956
50610
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
49957
50611
  if (!worktreeRoot) return true;
49958
50612
  if (!run3.worktreeId) return false;
49959
- const relative = import_node_path20.default.relative(import_node_path20.default.resolve(worktreeRoot), import_node_path20.default.resolve(run3.worktreeId));
49960
- return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path20.default.isAbsolute(relative);
50613
+ const relative = import_node_path22.default.relative(import_node_path22.default.resolve(worktreeRoot), import_node_path22.default.resolve(run3.worktreeId));
50614
+ return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path22.default.isAbsolute(relative);
49961
50615
  }
49962
50616
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
49963
50617
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -49975,7 +50629,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
49975
50629
  }).catch(() => {
49976
50630
  });
49977
50631
  await deps.client.createInboxItem(projectSlug, {
49978
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50632
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49979
50633
  kind: "handoff",
49980
50634
  taskId: task.id,
49981
50635
  body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
@@ -49994,7 +50648,7 @@ function maxLeaseReclaims() {
49994
50648
  }
49995
50649
 
49996
50650
  // src/async-job-consumer.ts
49997
- var import_node_crypto9 = __toESM(require("node:crypto"), 1);
50651
+ var import_node_crypto10 = __toESM(require("node:crypto"), 1);
49998
50652
 
49999
50653
  // src/async-tools/registry.ts
50000
50654
  var registry2 = /* @__PURE__ */ new Map();
@@ -50006,9 +50660,9 @@ function getAsyncToolDescriptor(toolName) {
50006
50660
  }
50007
50661
 
50008
50662
  // src/bridge-log.ts
50009
- var import_node_fs13 = require("node:fs");
50010
- var import_promises7 = require("node:fs/promises");
50011
- var import_node_path21 = require("node:path");
50663
+ var import_node_fs14 = require("node:fs");
50664
+ var import_promises9 = require("node:fs/promises");
50665
+ var import_node_path23 = require("node:path");
50012
50666
 
50013
50667
  // src/redact.ts
50014
50668
  var REDACTED = "[REDACTED]";
@@ -50033,7 +50687,7 @@ function redact(input) {
50033
50687
  }
50034
50688
 
50035
50689
  // src/telemetry/projector.ts
50036
- var import_node_crypto8 = require("node:crypto");
50690
+ var import_node_crypto9 = require("node:crypto");
50037
50691
  function isRecord3(x) {
50038
50692
  return typeof x === "object" && x !== null;
50039
50693
  }
@@ -50074,7 +50728,7 @@ function buildProjection(payload, type, ms, telemetry) {
50074
50728
  if (typeof exitCode === "number") proj.exitCode = exitCode;
50075
50729
  const status = tool.status;
50076
50730
  if (typeof status === "string" && status.trim() !== "") {
50077
- proj.statusHash = (0, import_node_crypto8.createHash)("sha256").update(status.trim().toLowerCase()).digest("hex").slice(0, 8);
50731
+ proj.statusHash = (0, import_node_crypto9.createHash)("sha256").update(status.trim().toLowerCase()).digest("hex").slice(0, 8);
50078
50732
  }
50079
50733
  return proj;
50080
50734
  }
@@ -50284,14 +50938,14 @@ function resolvePromptsEnabled(env = process.env) {
50284
50938
  }
50285
50939
  function createBridgeLogger(stateDir, env = process.env) {
50286
50940
  if (!resolveBridgeLogEnabled(env)) return NOOP_LOGGER;
50287
- const logsDir = (0, import_node_path21.join)(stateDir, "logs");
50941
+ const logsDir = (0, import_node_path23.join)(stateDir, "logs");
50288
50942
  try {
50289
- (0, import_node_fs13.mkdirSync)(logsDir, { recursive: true });
50943
+ (0, import_node_fs14.mkdirSync)(logsDir, { recursive: true });
50290
50944
  } catch {
50291
50945
  return NOOP_LOGGER;
50292
50946
  }
50293
50947
  const includePrompts = resolvePromptsEnabled(env);
50294
- const fileFor = () => (0, import_node_path21.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
50948
+ const fileFor = () => (0, import_node_path23.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
50295
50949
  const MAX_TRACKED_SESSIONS = 64;
50296
50950
  const contextSlugBySession = /* @__PURE__ */ new Map();
50297
50951
  const rememberContextSlug = (sessionId, payload) => {
@@ -50332,10 +50986,10 @@ function createBridgeLogger(stateDir, env = process.env) {
50332
50986
  return { isGap, isNewTurn };
50333
50987
  };
50334
50988
  const gainDay = (sessionId) => {
50335
- const sessionsPath = (0, import_node_path21.join)(logsDir, ".sessions.json");
50989
+ const sessionsPath = (0, import_node_path23.join)(logsDir, ".sessions.json");
50336
50990
  let sessionsObj = {};
50337
50991
  try {
50338
- const parsed = JSON.parse((0, import_node_fs13.readFileSync)(sessionsPath, "utf8"));
50992
+ const parsed = JSON.parse((0, import_node_fs14.readFileSync)(sessionsPath, "utf8"));
50339
50993
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) sessionsObj = parsed;
50340
50994
  } catch {
50341
50995
  sessionsObj = {};
@@ -50345,8 +50999,8 @@ function createBridgeLogger(stateDir, env = process.env) {
50345
50999
  if (idsToday.includes(sessionId)) return;
50346
51000
  sessionsObj[day] = [...idsToday, sessionId];
50347
51001
  const tmpPath = `${sessionsPath}.tmp`;
50348
- (0, import_node_fs13.writeFileSync)(tmpPath, JSON.stringify(sessionsObj));
50349
- (0, import_node_fs13.renameSync)(tmpPath, sessionsPath);
51002
+ (0, import_node_fs14.writeFileSync)(tmpPath, JSON.stringify(sessionsObj));
51003
+ (0, import_node_fs14.renameSync)(tmpPath, sessionsPath);
50350
51004
  };
50351
51005
  const write = (dir, rec) => {
50352
51006
  try {
@@ -50437,7 +51091,7 @@ function createBridgeLogger(stateDir, env = process.env) {
50437
51091
  ...recordingObligationUnresolved ? { recordingObligationUnresolved } : {},
50438
51092
  ...recordingObligationMultiResolve ? { recordingObligationMultiResolve } : {}
50439
51093
  }) + "\n";
50440
- (0, import_node_fs13.appendFileSync)(fileFor(), line);
51094
+ (0, import_node_fs14.appendFileSync)(fileFor(), line);
50441
51095
  if (rec.sessionId !== null) gainDay(rec.sessionId);
50442
51096
  } catch {
50443
51097
  }
@@ -50450,10 +51104,10 @@ function createBridgeLogger(stateDir, env = process.env) {
50450
51104
  };
50451
51105
  }
50452
51106
  async function findSessionDays(stateDir, sessionId) {
50453
- const sessionsPath = (0, import_node_path21.join)(stateDir, "logs", ".sessions.json");
51107
+ const sessionsPath = (0, import_node_path23.join)(stateDir, "logs", ".sessions.json");
50454
51108
  let sessionsObj;
50455
51109
  try {
50456
- const parsed = JSON.parse(await (0, import_promises7.readFile)(sessionsPath, "utf8"));
51110
+ const parsed = JSON.parse(await (0, import_promises9.readFile)(sessionsPath, "utf8"));
50457
51111
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return [];
50458
51112
  sessionsObj = parsed;
50459
51113
  } catch {
@@ -50582,7 +51236,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
50582
51236
  const delivery = descriptor2.onComplete(outcome, input);
50583
51237
  if (!delivery.suppressInbox) {
50584
51238
  await deps.client.createInboxItem(projectSlug, {
50585
- id: delivery.id ?? `II-${import_node_crypto9.default.randomUUID()}`,
51239
+ id: delivery.id ?? `II-${import_node_crypto10.default.randomUUID()}`,
50586
51240
  kind: delivery.kind,
50587
51241
  body: delivery.body,
50588
51242
  ...delivery.taskId ? { taskId: delivery.taskId } : {},
@@ -50600,13 +51254,13 @@ async function deriveRequestedHash(client, toolName, input) {
50600
51254
  if (input.requestedHash) return input.requestedHash;
50601
51255
  if (toolName === "run_spec_consensus" && input.pageId) {
50602
51256
  const page = await client.getWikiPage(input.projectSlug, input.pageId);
50603
- return page.contentHash ?? import_node_crypto9.default.createHash("sha256").update(page.markdownBody).digest("hex");
51257
+ return page.contentHash ?? import_node_crypto10.default.createHash("sha256").update(page.markdownBody).digest("hex");
50604
51258
  }
50605
51259
  if (toolName === "draft_task_spec" && input.taskId) {
50606
51260
  const task = await client.getTask(input.projectSlug, input.taskId);
50607
- return task.updatedAt ?? import_node_crypto9.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
51261
+ return task.updatedAt ?? import_node_crypto10.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
50608
51262
  }
50609
- return import_node_crypto9.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
51263
+ return import_node_crypto10.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
50610
51264
  }
50611
51265
  async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
50612
51266
  const projects = await deps.client.listProjects();
@@ -50632,12 +51286,12 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
50632
51286
  }
50633
51287
 
50634
51288
  // src/state-dir.ts
50635
- var import_node_os10 = __toESM(require("node:os"), 1);
50636
- var import_node_path22 = __toESM(require("node:path"), 1);
51289
+ var import_node_os11 = __toESM(require("node:os"), 1);
51290
+ var import_node_path24 = __toESM(require("node:path"), 1);
50637
51291
  function resolveStateDir(env = process.env) {
50638
51292
  const codexHome = env.CODEX_HOME;
50639
- if (codexHome) return import_node_path22.default.join(codexHome, "mrrlin", "director-bridge");
50640
- return import_node_path22.default.join(import_node_os10.default.homedir(), ".mrrlin", "director-bridge");
51293
+ if (codexHome) return import_node_path24.default.join(codexHome, "mrrlin", "director-bridge");
51294
+ return import_node_path24.default.join(import_node_os11.default.homedir(), ".mrrlin", "director-bridge");
50641
51295
  }
50642
51296
 
50643
51297
  // src/consensus/deliverable-gate.ts
@@ -50892,56 +51546,11 @@ function agentIdleMs(provider) {
50892
51546
  return seconds * 1e3;
50893
51547
  }
50894
51548
 
50895
- // src/operator-token.ts
50896
- var import_node_fs14 = require("node:fs");
50897
- var import_node_os11 = __toESM(require("node:os"), 1);
50898
- var import_node_path23 = __toESM(require("node:path"), 1);
50899
- function operatorDir() {
50900
- const base = process.env.CODEX_HOME ? import_node_path23.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path23.default.join(import_node_os11.default.homedir(), ".mrrlin");
50901
- return base;
50902
- }
50903
- function operatorTokenPath() {
50904
- return import_node_path23.default.join(operatorDir(), "operator-token");
50905
- }
50906
- function readOperatorToken() {
50907
- try {
50908
- const token = (0, import_node_fs14.readFileSync)(operatorTokenPath(), "utf8").trim();
50909
- return token.length > 0 ? token : null;
50910
- } catch {
50911
- return null;
50912
- }
50913
- }
50914
- function persistOperatorToken(token) {
50915
- const dir = operatorDir();
50916
- (0, import_node_fs14.mkdirSync)(dir, { recursive: true, mode: 448 });
50917
- (0, import_node_fs14.writeFileSync)(operatorTokenPath(), `${token.trim()}
50918
- `, { encoding: "utf8", mode: 384 });
50919
- }
50920
- function agentCredentialPath() {
50921
- return import_node_path23.default.join(operatorDir(), "agent-credential");
50922
- }
50923
- function persistAgentSecret(secret) {
50924
- const dir = operatorDir();
50925
- (0, import_node_fs14.mkdirSync)(dir, { recursive: true, mode: 448 });
50926
- (0, import_node_fs14.writeFileSync)(agentCredentialPath(), `${secret.trim()}
50927
- `, { encoding: "utf8", mode: 384 });
50928
- }
50929
- function readAgentSecret() {
50930
- const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
50931
- if (fromEnv) return fromEnv;
50932
- try {
50933
- const raw = (0, import_node_fs14.readFileSync)(agentCredentialPath(), "utf8").trim();
50934
- return raw || void 0;
50935
- } catch {
50936
- return void 0;
50937
- }
50938
- }
50939
-
50940
51549
  // src/thread-index.ts
50941
51550
  var import_node_fs15 = require("node:fs");
50942
- var import_node_path24 = __toESM(require("node:path"), 1);
51551
+ var import_node_path25 = __toESM(require("node:path"), 1);
50943
51552
  function threadIndexPath(stateDir) {
50944
- return import_node_path24.default.join(stateDir, "threads.json");
51553
+ return import_node_path25.default.join(stateDir, "threads.json");
50945
51554
  }
50946
51555
  function loadThreadIndex(stateDir, ttlMs, now) {
50947
51556
  const result = /* @__PURE__ */ new Map();
@@ -51106,10 +51715,10 @@ function createToolBusyClock(opts) {
51106
51715
  }
51107
51716
 
51108
51717
  // src/worker-token.ts
51109
- var import_node_crypto10 = require("node:crypto");
51718
+ var import_node_crypto11 = require("node:crypto");
51110
51719
  var import_node_fs16 = require("node:fs");
51111
51720
  var import_node_os12 = __toESM(require("node:os"), 1);
51112
- var import_node_path25 = __toESM(require("node:path"), 1);
51721
+ var import_node_path26 = __toESM(require("node:path"), 1);
51113
51722
  var DEFAULT_WORKER_PORT = 8792;
51114
51723
  function workerPort() {
51115
51724
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -51118,11 +51727,11 @@ function workerPort() {
51118
51727
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
51119
51728
  }
51120
51729
  function workerDir() {
51121
- const base = process.env.CODEX_HOME ? import_node_path25.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path25.default.join(import_node_os12.default.homedir(), ".mrrlin");
51122
- return import_node_path25.default.join(base, "worker");
51730
+ const base = process.env.CODEX_HOME ? import_node_path26.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path26.default.join(import_node_os12.default.homedir(), ".mrrlin");
51731
+ return import_node_path26.default.join(base, "worker");
51123
51732
  }
51124
51733
  function workerTokenPath() {
51125
- return import_node_path25.default.join(workerDir(), "token");
51734
+ return import_node_path26.default.join(workerDir(), "token");
51126
51735
  }
51127
51736
  function readWorkerToken() {
51128
51737
  try {
@@ -51137,17 +51746,17 @@ function readOrCreateWorkerToken() {
51137
51746
  if (existing) return existing;
51138
51747
  const dir = workerDir();
51139
51748
  (0, import_node_fs16.mkdirSync)(dir, { recursive: true, mode: 448 });
51140
- const token = (0, import_node_crypto10.randomBytes)(32).toString("hex");
51749
+ const token = (0, import_node_crypto11.randomBytes)(32).toString("hex");
51141
51750
  (0, import_node_fs16.writeFileSync)(workerTokenPath(), `${token}
51142
51751
  `, { encoding: "utf8", mode: 384 });
51143
51752
  return token;
51144
51753
  }
51145
51754
 
51146
51755
  // src/remote-phone-relay.ts
51147
- var import_node_events2 = require("node:events");
51756
+ var import_node_events3 = require("node:events");
51148
51757
  var import_node_fs17 = require("node:fs");
51149
51758
  var import_node_os13 = require("node:os");
51150
- var import_node_path26 = require("node:path");
51759
+ var import_node_path27 = require("node:path");
51151
51760
 
51152
51761
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
51153
51762
  var nc = __toESM(require("node:crypto"), 1);
@@ -54173,9 +54782,9 @@ var RelayClient = class {
54173
54782
  this.socket = null;
54174
54783
  this.nextHeartbeatAt = Number.POSITIVE_INFINITY;
54175
54784
  if (this.stopped || this.register === null) return;
54176
- const delay = this.backoff[Math.min(this.backoffIndex, this.backoff.length - 1)] ?? 0;
54785
+ const delay2 = this.backoff[Math.min(this.backoffIndex, this.backoff.length - 1)] ?? 0;
54177
54786
  this.backoffIndex += 1;
54178
- this.reconnectAt = this.deps.now() + delay;
54787
+ this.reconnectAt = this.deps.now() + delay2;
54179
54788
  }
54180
54789
  onMessage(data) {
54181
54790
  let frame;
@@ -54718,7 +55327,7 @@ var DirectorRelay = class {
54718
55327
 
54719
55328
  // src/remote-phone-relay.ts
54720
55329
  function loadOrCreateAgentDeviceKey() {
54721
- const path25 = (0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-device-key");
55330
+ const path25 = (0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-device-key");
54722
55331
  try {
54723
55332
  const raw = JSON.parse((0, import_node_fs17.readFileSync)(path25, "utf8"));
54724
55333
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
@@ -54728,7 +55337,7 @@ function loadOrCreateAgentDeviceKey() {
54728
55337
  }
54729
55338
  const kp = generateIdentityKeyPair();
54730
55339
  try {
54731
- (0, import_node_fs17.mkdirSync)((0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
55340
+ (0, import_node_fs17.mkdirSync)((0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
54732
55341
  (0, import_node_fs17.writeFileSync)(
54733
55342
  path25,
54734
55343
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
@@ -54738,7 +55347,7 @@ function loadOrCreateAgentDeviceKey() {
54738
55347
  }
54739
55348
  return kp;
54740
55349
  }
54741
- var AGENT_PAIRING_PATH = (0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-pairing.json");
55350
+ var AGENT_PAIRING_PATH = (0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-pairing.json");
54742
55351
  function loadAgentPairing() {
54743
55352
  try {
54744
55353
  const raw = JSON.parse((0, import_node_fs17.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
@@ -54756,14 +55365,14 @@ function loadAgentPairing() {
54756
55365
  }
54757
55366
  function saveAgentPairing(record2) {
54758
55367
  try {
54759
- (0, import_node_fs17.mkdirSync)((0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
55368
+ (0, import_node_fs17.mkdirSync)((0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
54760
55369
  (0, import_node_fs17.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
54761
55370
  } catch {
54762
55371
  }
54763
55372
  }
54764
55373
  function runPhoneTurn(handler, directorSessionId, text, emit) {
54765
55374
  return new Promise((resolve) => {
54766
- const emitter = new import_node_events2.EventEmitter();
55375
+ const emitter = new import_node_events3.EventEmitter();
54767
55376
  const fakeSocket = {
54768
55377
  on: (event, cb) => {
54769
55378
  emitter.on(event, cb);
@@ -54936,11 +55545,11 @@ async function renderPairingQrSvg(payload) {
54936
55545
 
54937
55546
  // src/checkout-registry.ts
54938
55547
  var import_node_fs18 = require("node:fs");
54939
- var import_node_path27 = require("node:path");
55548
+ var import_node_path28 = require("node:path");
54940
55549
  var CheckoutRegistry = class {
54941
55550
  file;
54942
55551
  constructor(stateDir) {
54943
- this.file = (0, import_node_path27.join)(stateDir, "checkouts.json");
55552
+ this.file = (0, import_node_path28.join)(stateDir, "checkouts.json");
54944
55553
  (0, import_node_fs18.mkdirSync)(stateDir, { recursive: true });
54945
55554
  }
54946
55555
  read() {
@@ -54997,7 +55606,7 @@ var CheckoutRegistry = class {
54997
55606
  };
54998
55607
 
54999
55608
  // src/checkout-handlers.ts
55000
- var import_node_child_process14 = require("node:child_process");
55609
+ var import_node_child_process16 = require("node:child_process");
55001
55610
  var import_node_fs19 = require("node:fs");
55002
55611
 
55003
55612
  // src/git-remote-match.ts
@@ -55043,7 +55652,7 @@ function validateCheckoutPath(checkoutPath, repo) {
55043
55652
  }
55044
55653
  let remoteUrl;
55045
55654
  try {
55046
- remoteUrl = (0, import_node_child_process14.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
55655
+ remoteUrl = (0, import_node_child_process16.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
55047
55656
  encoding: "utf8",
55048
55657
  stdio: ["ignore", "pipe", "ignore"],
55049
55658
  timeout: 15e3,
@@ -55094,11 +55703,11 @@ function checkoutStateData(projectSlug, entry, machineLabel) {
55094
55703
  }
55095
55704
 
55096
55705
  // src/executor-server.ts
55097
- var import_node_child_process15 = require("node:child_process");
55706
+ var import_node_child_process17 = require("node:child_process");
55098
55707
  function defaultReadinessRunner(provider) {
55099
55708
  const command = provider === "claude" ? "claude" : "codex";
55100
55709
  return (args) => {
55101
- const r = (0, import_node_child_process15.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
55710
+ const r = (0, import_node_child_process17.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
55102
55711
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
55103
55712
  };
55104
55713
  }
@@ -55341,7 +55950,7 @@ function extractVerificationSection(markdown) {
55341
55950
  // src/director-reseed.ts
55342
55951
  var import_node_fs20 = require("node:fs");
55343
55952
  var import_node_readline = require("node:readline");
55344
- var import_node_path28 = require("node:path");
55953
+ var import_node_path29 = require("node:path");
55345
55954
  function estimateTokens(s) {
55346
55955
  return Buffer.byteLength(s, "utf8");
55347
55956
  }
@@ -55473,7 +56082,7 @@ async function readSessionRows(logsDir, files, sessionIds) {
55473
56082
  const lines2 = [];
55474
56083
  let missingFiles = 0;
55475
56084
  for (const f of files) {
55476
- const filePath = (0, import_node_path28.join)(logsDir, f);
56085
+ const filePath = (0, import_node_path29.join)(logsDir, f);
55477
56086
  try {
55478
56087
  const stream = (0, import_node_fs20.createReadStream)(filePath, { encoding: "utf8" });
55479
56088
  const rl = (0, import_node_readline.createInterface)({ input: stream, crlfDelay: Infinity });
@@ -55501,10 +56110,10 @@ async function readSessionRows(logsDir, files, sessionIds) {
55501
56110
  // src/external-agents-scrub.ts
55502
56111
  var import_node_fs21 = __toESM(require("node:fs"), 1);
55503
56112
  var import_node_os14 = __toESM(require("node:os"), 1);
55504
- var import_node_path29 = __toESM(require("node:path"), 1);
56113
+ var import_node_path30 = __toESM(require("node:path"), 1);
55505
56114
  var REDACTION = "[REDACTED]";
55506
56115
  var SHORT_VALUE_THRESHOLD = 8;
55507
- var KEYS_ENV_PATH = () => import_node_path29.default.join(import_node_os14.default.homedir(), ".local", "state", "external-agents", "keys.env");
56116
+ var KEYS_ENV_PATH = () => import_node_path30.default.join(import_node_os14.default.homedir(), ".local", "state", "external-agents", "keys.env");
55508
56117
  var keysEnvCache = null;
55509
56118
  function readKeysEnv() {
55510
56119
  const filePath = KEYS_ENV_PATH();
@@ -55948,9 +56557,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
55948
56557
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
55949
56558
  }
55950
56559
  function readCodexFallbackModels() {
55951
- const codexHome = process.env.CODEX_HOME?.trim() || import_node_path30.default.join(import_node_os15.default.homedir(), ".codex");
56560
+ const codexHome = process.env.CODEX_HOME?.trim() || import_node_path31.default.join(import_node_os15.default.homedir(), ".codex");
55952
56561
  const models = /* @__PURE__ */ new Map();
55953
- const cachePath = import_node_path30.default.join(codexHome, "models_cache.json");
56562
+ const cachePath = import_node_path31.default.join(codexHome, "models_cache.json");
55954
56563
  const cacheRaw = readTextIfExists(cachePath);
55955
56564
  if (cacheRaw) {
55956
56565
  try {
@@ -56000,7 +56609,7 @@ function readCodexFallbackModels() {
56000
56609
  );
56001
56610
  }
56002
56611
  }
56003
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path30.default.join(codexHome, "config.toml"))) {
56612
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path31.default.join(codexHome, "config.toml"))) {
56004
56613
  addBridgeModel(
56005
56614
  models,
56006
56615
  mapBridgeModel({
@@ -56014,11 +56623,11 @@ function readCodexFallbackModels() {
56014
56623
  })
56015
56624
  );
56016
56625
  }
56017
- const automationsDir = import_node_path30.default.join(codexHome, "automations");
56626
+ const automationsDir = import_node_path31.default.join(codexHome, "automations");
56018
56627
  try {
56019
56628
  for (const entry of import_node_fs22.default.readdirSync(automationsDir, { withFileTypes: true })) {
56020
56629
  if (!entry.isDirectory()) continue;
56021
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path30.default.join(automationsDir, entry.name, "automation.toml"))) {
56630
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path31.default.join(automationsDir, entry.name, "automation.toml"))) {
56022
56631
  addBridgeModel(
56023
56632
  models,
56024
56633
  mapBridgeModel({
@@ -56038,13 +56647,13 @@ function readCodexFallbackModels() {
56038
56647
  return [...models.values()];
56039
56648
  }
56040
56649
  function selfUpdateInboxItemId(offeredVersion) {
56041
- if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto11.randomUUID)()}`;
56650
+ if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto12.randomUUID)()}`;
56042
56651
  if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
56043
- const hash3 = import_node_crypto11.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
56652
+ const hash3 = import_node_crypto12.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
56044
56653
  return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
56045
56654
  }
56046
56655
  function neutralCheckoutCwd(stateDir) {
56047
- const dir = import_node_path30.default.join(stateDir, "no-checkout");
56656
+ const dir = import_node_path31.default.join(stateDir, "no-checkout");
56048
56657
  try {
56049
56658
  import_node_fs22.default.mkdirSync(dir, { recursive: true });
56050
56659
  } catch {
@@ -56520,7 +57129,7 @@ function resolveDefaultBranch(checkoutPath) {
56520
57129
  if (!checkoutPath) return "main";
56521
57130
  const runGit = (args) => {
56522
57131
  try {
56523
- return (0, import_node_child_process16.execFileSync)("git", ["-C", checkoutPath, ...args], {
57132
+ return (0, import_node_child_process18.execFileSync)("git", ["-C", checkoutPath, ...args], {
56524
57133
  encoding: "utf8",
56525
57134
  stdio: ["ignore", "pipe", "ignore"],
56526
57135
  timeout: 15e3,
@@ -56670,7 +57279,7 @@ function createBridgeRequestListener(opts) {
56670
57279
  res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
56671
57280
  return;
56672
57281
  }
56673
- const nonce = import_node_crypto11.default.randomBytes(16).toString("base64url");
57282
+ const nonce = import_node_crypto12.default.randomBytes(16).toString("base64url");
56674
57283
  res.writeHead(200, { "content-type": "application/json" });
56675
57284
  res.end(JSON.stringify({ ok: true, wsUrl: `ws://${host}:${port}/ws`, token, nonce }));
56676
57285
  return;
@@ -56970,7 +57579,7 @@ function createBridgeMessageHandler(deps) {
56970
57579
  }
56971
57580
  }
56972
57581
  socket.on("message", async (data) => {
56973
- const spanId = import_node_crypto11.default.randomUUID();
57582
+ const spanId = import_node_crypto12.default.randomUUID();
56974
57583
  if (logCtx) {
56975
57584
  logCtx.span.id = spanId;
56976
57585
  logCtx.span.at = Date.now();
@@ -57102,6 +57711,7 @@ function createBridgeMessageHandler(deps) {
57102
57711
  return;
57103
57712
  }
57104
57713
  const compactionSeat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
57714
+ void notifyPinRetirementIfRetired(compactionSeat);
57105
57715
  const result = await deps.runCompaction({
57106
57716
  history,
57107
57717
  provider: compactionSeat.id,
@@ -57288,7 +57898,15 @@ function createBridgeMessageHandler(deps) {
57288
57898
  const bootstrapProvider = resolveProvider(process.env, getSelectedProvider());
57289
57899
  bootstrapProviderId = bootstrapProvider.id;
57290
57900
  const bootstrapCapabilities = bootstrapProvider.capabilities();
57291
- fallbackModels = bootstrapCapabilities.listsModels ? readCodexFallbackModels() : [];
57901
+ const agyStaticFallback = bootstrapProviderId === "agy" && bootstrapCapabilities.modelCatalog.length > 0 ? bootstrapCapabilities.modelCatalog.map(
57902
+ (entry) => mapBridgeModel({
57903
+ id: entry.id,
57904
+ model: entry.id,
57905
+ displayName: entry.displayName,
57906
+ description: entry.description
57907
+ })
57908
+ ).filter((m) => m !== null) : [];
57909
+ fallbackModels = bootstrapProviderId === "codex" && bootstrapCapabilities.listsModels ? readCodexFallbackModels() : agyStaticFallback;
57292
57910
  if (!bootstrapCapabilities.listsModels) {
57293
57911
  const staticModels = /* @__PURE__ */ new Map();
57294
57912
  for (const entry of bootstrapCapabilities.modelCatalog) {
@@ -57473,6 +58091,7 @@ function createBridgeMessageHandler(deps) {
57473
58091
  }
57474
58092
  pendingTurnSessions.add(directorSessionId);
57475
58093
  const turnSeat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
58094
+ void notifyPinRetirementIfRetired(turnSeat);
57476
58095
  const turnProviderCapabilities = turnSeat.capabilities;
57477
58096
  const codexClient = await deps.acquireCodex(turnSeat.id);
57478
58097
  let thread = deps.threads.get(directorSessionId);
@@ -57587,7 +58206,7 @@ function createBridgeMessageHandler(deps) {
57587
58206
  thread.inFlight = true;
57588
58207
  pendingTurnSessions.delete(directorSessionId);
57589
58208
  thread.replay = createReplayBuffer({
57590
- turnId: (0, import_node_crypto11.randomUUID)(),
58209
+ turnId: (0, import_node_crypto12.randomUUID)(),
57591
58210
  spanId,
57592
58211
  ...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
57593
58212
  ...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
@@ -57990,7 +58609,7 @@ function parseConfig() {
57990
58609
  }
57991
58610
  function scanForOtherBridges() {
57992
58611
  try {
57993
- const result = (0, import_node_child_process16.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
58612
+ const result = (0, import_node_child_process18.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
57994
58613
  encoding: "utf8"
57995
58614
  });
57996
58615
  if (result.status !== 0) return [];
@@ -58166,8 +58785,8 @@ async function startDirectorBridge() {
58166
58785
  codexCwd: config2.codexCwd,
58167
58786
  codexExecutable: config2.codexExecutable,
58168
58787
  checkoutRegistry,
58169
- worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58170
- locksDir: import_node_path30.default.join(config2.stateDir, "locks"),
58788
+ worktreeRoot: import_node_path31.default.join(config2.stateDir, "worktrees"),
58789
+ locksDir: import_node_path31.default.join(config2.stateDir, "locks"),
58171
58790
  // Wire the executor server for code-execution runs. Each run gets its own provider process
58172
58791
  // (app-server for codex, a resident CLI child for claude) at the run worktree, running
58173
58792
  // UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
@@ -58211,7 +58830,7 @@ async function startDirectorBridge() {
58211
58830
  // egressDomains is retained in the seam signature (verification-turn.ts still computes the
58212
58831
  // env host) but no longer constrains anything — the executor is unrestricted.
58213
58832
  startSandbox: async (_egressDomains, providerId) => {
58214
- const cwd = import_node_fs22.default.mkdtempSync(import_node_path30.default.join(import_node_os15.default.tmpdir(), "mrrlin-verify-"));
58833
+ const cwd = import_node_fs22.default.mkdtempSync(import_node_path31.default.join(import_node_os15.default.tmpdir(), "mrrlin-verify-"));
58215
58834
  let executor;
58216
58835
  try {
58217
58836
  executor = await startExecutorServer({ worktree: cwd, provider: providerId });
@@ -58261,7 +58880,7 @@ async function startDirectorBridge() {
58261
58880
  };
58262
58881
  const sessionSinks = createSessionSinkRegistry();
58263
58882
  const tombstones = /* @__PURE__ */ new Map();
58264
- const bridgeInstanceId = (0, import_node_crypto11.randomUUID)();
58883
+ const bridgeInstanceId = (0, import_node_crypto12.randomUUID)();
58265
58884
  const asyncConsumerDeps = {
58266
58885
  client,
58267
58886
  run: wrappedTurnLock.run,
@@ -58439,7 +59058,7 @@ async function startDirectorBridge() {
58439
59058
  }
58440
59059
  const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
58441
59060
  const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
58442
- const { lines: lines2, missingFiles } = await readSessionRows(import_node_path30.default.join(config2.stateDir, "logs"), files, sessionIds);
59061
+ const { lines: lines2, missingFiles } = await readSessionRows(import_node_path31.default.join(config2.stateDir, "logs"), files, sessionIds);
58443
59062
  const { items, skipped: skipped2 } = extractItems(lines2, sessionIds);
58444
59063
  if (items.length === 0) return refuse2("no-rows");
58445
59064
  const budget = Math.max(0, Math.min(config2.reseedMaxTokens, config2.turnMaxTokens - args.otherBytes));
@@ -58546,7 +59165,7 @@ async function startDirectorBridge() {
58546
59165
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
58547
59166
  let bridgeBinShaShort = "unknown00000";
58548
59167
  try {
58549
- bridgeBinShaShort = import_node_crypto11.default.createHash("sha256").update(import_node_fs22.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
59168
+ bridgeBinShaShort = import_node_crypto12.default.createHash("sha256").update(import_node_fs22.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
58550
59169
  } catch {
58551
59170
  }
58552
59171
  attachBridgeWss(server, {
@@ -58682,8 +59301,8 @@ async function startDirectorBridge() {
58682
59301
  );
58683
59302
  void runOrphanWorktreeSweep(client, {
58684
59303
  checkoutRegistry,
58685
- worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58686
- locksDir: import_node_path30.default.join(config2.stateDir, "locks")
59304
+ worktreeRoot: import_node_path31.default.join(config2.stateDir, "worktrees"),
59305
+ locksDir: import_node_path31.default.join(config2.stateDir, "locks")
58687
59306
  });
58688
59307
  {
58689
59308
  const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
@@ -58986,7 +59605,7 @@ function timingSafeTokenEqual(provided, expected) {
58986
59605
  const a = Buffer.from(provided);
58987
59606
  const b = Buffer.from(expected);
58988
59607
  if (a.length !== b.length) return false;
58989
- return import_node_crypto11.default.timingSafeEqual(a, b);
59608
+ return import_node_crypto12.default.timingSafeEqual(a, b);
58990
59609
  }
58991
59610
  function readDispatchBody(req) {
58992
59611
  return new Promise((resolve, reject) => {
@@ -59008,14 +59627,14 @@ function readDispatchBody(req) {
59008
59627
  function readOrCreateBridgeToken(stateDir) {
59009
59628
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
59010
59629
  if (explicit) return explicit;
59011
- const tokenPath = import_node_path30.default.join(stateDir, "token.txt");
59630
+ const tokenPath = import_node_path31.default.join(stateDir, "token.txt");
59012
59631
  try {
59013
59632
  const existing = import_node_fs22.default.readFileSync(tokenPath, "utf8").trim();
59014
59633
  if (existing) return existing;
59015
59634
  } catch {
59016
59635
  }
59017
59636
  import_node_fs22.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
59018
- const token = import_node_crypto11.default.randomBytes(32).toString("base64url");
59637
+ const token = import_node_crypto12.default.randomBytes(32).toString("base64url");
59019
59638
  import_node_fs22.default.writeFileSync(tokenPath, `${token}
59020
59639
  `, { mode: 384 });
59021
59640
  return token;
@@ -62405,36 +63024,36 @@ var StdioServerTransport = class {
62405
63024
  };
62406
63025
 
62407
63026
  // src/tools.ts
62408
- var import_node_crypto14 = require("node:crypto");
62409
- var import_promises10 = require("node:fs/promises");
62410
- var import_node_path33 = __toESM(require("node:path"), 1);
63027
+ var import_node_crypto15 = require("node:crypto");
63028
+ var import_promises12 = require("node:fs/promises");
63029
+ var import_node_path34 = __toESM(require("node:path"), 1);
62411
63030
  var import_node_os16 = __toESM(require("node:os"), 1);
62412
63031
 
62413
63032
  // ../../packages/wiki/dist/index.js
62414
- var import_promises8 = __toESM(require("node:fs/promises"), 1);
62415
- var import_node_path31 = __toESM(require("node:path"), 1);
63033
+ var import_promises10 = __toESM(require("node:fs/promises"), 1);
63034
+ var import_node_path32 = __toESM(require("node:path"), 1);
62416
63035
  var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
62417
63036
  function toPosixPath(input) {
62418
- return input.split(import_node_path31.default.sep).join("/");
63037
+ return input.split(import_node_path32.default.sep).join("/");
62419
63038
  }
62420
63039
  function slugifyWikiSegment(input) {
62421
63040
  return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
62422
63041
  }
62423
63042
  async function pathExists3(input) {
62424
63043
  try {
62425
- await import_promises8.default.access(input);
63044
+ await import_promises10.default.access(input);
62426
63045
  return true;
62427
63046
  } catch {
62428
63047
  return false;
62429
63048
  }
62430
63049
  }
62431
63050
  async function findWorkspaceRoot(start = process.cwd()) {
62432
- let current2 = import_node_path31.default.resolve(start);
63051
+ let current2 = import_node_path32.default.resolve(start);
62433
63052
  while (true) {
62434
- if (await pathExists3(import_node_path31.default.join(current2, "pnpm-workspace.yaml")) && await pathExists3(import_node_path31.default.join(current2, "docs"))) {
63053
+ if (await pathExists3(import_node_path32.default.join(current2, "pnpm-workspace.yaml")) && await pathExists3(import_node_path32.default.join(current2, "docs"))) {
62435
63054
  return current2;
62436
63055
  }
62437
- const parent = import_node_path31.default.dirname(current2);
63056
+ const parent = import_node_path32.default.dirname(current2);
62438
63057
  if (parent === current2) {
62439
63058
  throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
62440
63059
  }
@@ -62443,28 +63062,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
62443
63062
  }
62444
63063
  async function resolveDocsRoot(input) {
62445
63064
  if (input) {
62446
- return import_node_path31.default.resolve(input);
63065
+ return import_node_path32.default.resolve(input);
62447
63066
  }
62448
63067
  if (process.env.MRRLIN_DOCS_ROOT) {
62449
- return import_node_path31.default.resolve(process.env.MRRLIN_DOCS_ROOT);
63068
+ return import_node_path32.default.resolve(process.env.MRRLIN_DOCS_ROOT);
62450
63069
  }
62451
- return import_node_path31.default.join(await findWorkspaceRoot(), "docs");
63070
+ return import_node_path32.default.join(await findWorkspaceRoot(), "docs");
62452
63071
  }
62453
63072
  async function resolveIndexPath(input) {
62454
63073
  if (input) {
62455
- return import_node_path31.default.resolve(input);
63074
+ return import_node_path32.default.resolve(input);
62456
63075
  }
62457
63076
  if (process.env.MRRLIN_WIKI_INDEX_PATH) {
62458
- return import_node_path31.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
63077
+ return import_node_path32.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
62459
63078
  }
62460
63079
  const workspaceRoot = await findWorkspaceRoot();
62461
- return import_node_path31.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
63080
+ return import_node_path32.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
62462
63081
  }
62463
63082
  async function walkMarkdownFiles(root, dir = root) {
62464
- const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
63083
+ const entries = await import_promises10.default.readdir(dir, { withFileTypes: true });
62465
63084
  const files = [];
62466
63085
  for (const entry of entries) {
62467
- const absolute = import_node_path31.default.join(dir, entry.name);
63086
+ const absolute = import_node_path32.default.join(dir, entry.name);
62468
63087
  if (entry.isDirectory()) {
62469
63088
  files.push(...await walkMarkdownFiles(root, absolute));
62470
63089
  continue;
@@ -62483,7 +63102,7 @@ function parseTitle(markdown, sourcePath) {
62483
63102
  return title;
62484
63103
  }
62485
63104
  function documentFromFile(docsRoot, absolutePath, markdown) {
62486
- const relativePath = toPosixPath(import_node_path31.default.relative(docsRoot, absolutePath));
63105
+ const relativePath = toPosixPath(import_node_path32.default.relative(docsRoot, absolutePath));
62487
63106
  const [section, fileName] = relativePath.split("/");
62488
63107
  if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
62489
63108
  return null;
@@ -62503,7 +63122,7 @@ async function listWikiDocuments(options = {}) {
62503
63122
  const files = await walkMarkdownFiles(docsRoot);
62504
63123
  const documents = [];
62505
63124
  for (const file2 of files) {
62506
- const markdown = await import_promises8.default.readFile(file2, "utf8");
63125
+ const markdown = await import_promises10.default.readFile(file2, "utf8");
62507
63126
  const document2 = documentFromFile(docsRoot, file2, markdown);
62508
63127
  if (document2) {
62509
63128
  documents.push(document2);
@@ -62557,7 +63176,7 @@ async function buildWikiKnowledgeIndex(options = {}) {
62557
63176
  }
62558
63177
  async function loadBuiltWikiKnowledgeIndex(indexPath) {
62559
63178
  const resolvedIndexPath = await resolveIndexPath(indexPath);
62560
- const raw = await import_promises8.default.readFile(resolvedIndexPath, "utf8");
63179
+ const raw = await import_promises10.default.readFile(resolvedIndexPath, "utf8");
62561
63180
  return wikiKnowledgeIndexSchema.parse(JSON.parse(raw));
62562
63181
  }
62563
63182
  function tokenize(input) {
@@ -62681,15 +63300,15 @@ async function runCodeGate(_target, deps) {
62681
63300
  }
62682
63301
 
62683
63302
  // src/consensus/multi-llm-head.ts
62684
- var import_node_child_process18 = require("node:child_process");
63303
+ var import_node_child_process20 = require("node:child_process");
62685
63304
 
62686
63305
  // src/consensus/provider-limits.ts
62687
- var import_node_child_process17 = require("node:child_process");
63306
+ var import_node_child_process19 = require("node:child_process");
62688
63307
  var DEFAULT_STATUS_TIMEOUT_MS = 1e4;
62689
63308
  function errMessage4(err) {
62690
63309
  return err instanceof Error ? err.message : String(err);
62691
63310
  }
62692
- function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
63311
+ function runExternalAgentsStatus(bin, args, timeoutMs, spawn5) {
62693
63312
  return new Promise((resolve) => {
62694
63313
  let settled = false;
62695
63314
  const timerRef = { id: void 0 };
@@ -62702,7 +63321,7 @@ function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
62702
63321
  const options = { stdio: ["ignore", "pipe", "pipe"], env: process.env, shell: false };
62703
63322
  let child;
62704
63323
  try {
62705
- child = spawn4(bin, args, options);
63324
+ child = spawn5(bin, args, options);
62706
63325
  } catch (err) {
62707
63326
  finish({ stdout: "", error: `spawn ${bin} failed: ${errMessage4(err)}` });
62708
63327
  return;
@@ -62726,13 +63345,13 @@ function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
62726
63345
  });
62727
63346
  }
62728
63347
  async function fetchRegistrySnapshot(deps) {
62729
- const spawn4 = deps?.spawn ?? import_node_child_process17.spawn;
63348
+ const spawn5 = deps?.spawn ?? import_node_child_process19.spawn;
62730
63349
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62731
63350
  const { stdout, error: error51 } = await runExternalAgentsStatus(
62732
63351
  command,
62733
63352
  [...prefixArgs, "status", "--json"],
62734
63353
  deps?.statusTimeoutMs ?? DEFAULT_STATUS_TIMEOUT_MS,
62735
- spawn4
63354
+ spawn5
62736
63355
  );
62737
63356
  if (error51) return { ok: false, error: error51 };
62738
63357
  try {
@@ -62776,7 +63395,7 @@ function estimateTokenCount(text) {
62776
63395
  function errMessage5(err) {
62777
63396
  return err instanceof Error ? err.message : String(err);
62778
63397
  }
62779
- function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
63398
+ function runExternalAgents(bin, args, label, timeoutMs, spawn5) {
62780
63399
  return new Promise((resolve) => {
62781
63400
  let settled = false;
62782
63401
  const timerRef = { id: void 0 };
@@ -62794,7 +63413,7 @@ function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
62794
63413
  };
62795
63414
  let child;
62796
63415
  try {
62797
- child = spawn4(bin, args, options);
63416
+ child = spawn5(bin, args, options);
62798
63417
  } catch (err) {
62799
63418
  finish({ code: null, stdout: "", error: `spawn ${bin} failed: ${errMessage5(err)}` });
62800
63419
  return;
@@ -62814,7 +63433,7 @@ function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
62814
63433
  });
62815
63434
  }
62816
63435
  async function pickPanel(input, deps) {
62817
- const spawn4 = deps?.spawn ?? import_node_child_process18.spawn;
63436
+ const spawn5 = deps?.spawn ?? import_node_child_process20.spawn;
62818
63437
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62819
63438
  const args = [
62820
63439
  "pick",
@@ -62827,7 +63446,7 @@ async function pickPanel(input, deps) {
62827
63446
  "--exclude-providers",
62828
63447
  input.excludeProvider
62829
63448
  ];
62830
- const r = await runExternalAgents(command, [...prefixArgs, ...args], "pick", input.timeoutMs, spawn4);
63449
+ const r = await runExternalAgents(command, [...prefixArgs, ...args], "pick", input.timeoutMs, spawn5);
62831
63450
  if (r.error) return { ok: false, error: r.error };
62832
63451
  if (r.code === 3) return { ok: true, agents: [] };
62833
63452
  if (r.code !== 0) return { ok: false, error: `external-agents pick exited ${r.code}` };
@@ -62861,10 +63480,10 @@ function parseDispatch(agentId, stdout, exitCode) {
62861
63480
  return { ok: true, text: parsed.text, usage };
62862
63481
  }
62863
63482
  async function dispatchHead(agentId, prompt, timeoutMs, deps) {
62864
- const spawn4 = deps?.spawn ?? import_node_child_process18.spawn;
63483
+ const spawn5 = deps?.spawn ?? import_node_child_process20.spawn;
62865
63484
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62866
63485
  const args = ["dispatch", agentId, "--json", prompt];
62867
- const r = await runExternalAgents(command, [...prefixArgs, ...args], "dispatch", timeoutMs, spawn4);
63486
+ const r = await runExternalAgents(command, [...prefixArgs, ...args], "dispatch", timeoutMs, spawn5);
62868
63487
  if (r.error) return { ok: false, error: r.error };
62869
63488
  return parseDispatch(agentId, r.stdout, r.code);
62870
63489
  }
@@ -65006,13 +65625,13 @@ var StreamableHTTPClientTransport = class {
65006
65625
  this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
65007
65626
  return;
65008
65627
  }
65009
- const delay = this._getNextReconnectionDelay(attemptCount);
65628
+ const delay2 = this._getNextReconnectionDelay(attemptCount);
65010
65629
  this._reconnectionTimeout = setTimeout(() => {
65011
65630
  this._startOrAuthSse(options).catch((error51) => {
65012
65631
  this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error51 instanceof Error ? error51.message : String(error51)}`));
65013
65632
  this._scheduleReconnection(options, attemptCount + 1);
65014
65633
  });
65015
- }, delay);
65634
+ }, delay2);
65016
65635
  }
65017
65636
  _handleSseStream(stream, options, isReconnectable) {
65018
65637
  if (!stream) {
@@ -65848,7 +66467,7 @@ async function runDecisionConsensus(input, deps) {
65848
66467
  }
65849
66468
 
65850
66469
  // src/async-tools/consensus.ts
65851
- var import_node_crypto12 = require("node:crypto");
66470
+ var import_node_crypto13 = require("node:crypto");
65852
66471
 
65853
66472
  // src/consensus/question-similarity.ts
65854
66473
  var SUPPRESSION_SIMILARITY_THRESHOLD = 0.6;
@@ -66128,9 +66747,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66128
66747
  }
66129
66748
  if (taskId) {
66130
66749
  const scopeId = taskId;
66131
- const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto12.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
66750
+ const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto13.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
66132
66751
  for (const clarification of toFile) {
66133
- const id = `II-${scopeId}-gate-${(0, import_node_crypto12.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
66752
+ const id = `II-${scopeId}-gate-${(0, import_node_crypto13.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
66134
66753
  try {
66135
66754
  const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
66136
66755
  await ctx.client.createInboxItem(input.projectSlug, {
@@ -66148,9 +66767,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66148
66767
  filedQuestionCount = toFile.length;
66149
66768
  } else if (planId) {
66150
66769
  const scopeId = planId;
66151
- const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto12.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
66770
+ const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto13.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
66152
66771
  for (const clarification of toFile) {
66153
- const id = `II-${scopeId}-gate-${(0, import_node_crypto12.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
66772
+ const id = `II-${scopeId}-gate-${(0, import_node_crypto13.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
66154
66773
  try {
66155
66774
  const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
66156
66775
  await ctx.client.createInboxItem(input.projectSlug, {
@@ -66174,7 +66793,7 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66174
66793
  taskId: page.taskId ?? null
66175
66794
  });
66176
66795
  const reviewHash = domainScopedReviewHash2(page.contentHash, domain2);
66177
- const baseBlockItemId = `II-${taskId}-gateblock-${(0, import_node_crypto12.createHash)("sha256").update(reviewHash).digest("hex").slice(0, 10)}`;
66796
+ const baseBlockItemId = `II-${taskId}-gateblock-${(0, import_node_crypto13.createHash)("sha256").update(reviewHash).digest("hex").slice(0, 10)}`;
66178
66797
  const reviewAgainAvailable = !taskInboxItems.some(
66179
66798
  (item) => item.id === baseBlockItemId && item.status !== "pending" && item.answer === REVIEW_AGAIN_ANSWER
66180
66799
  );
@@ -66748,8 +67367,8 @@ function createIntentCheckDescriptor() {
66748
67367
  var intentCheckDescriptor = createIntentCheckDescriptor();
66749
67368
 
66750
67369
  // src/evidence/assembler.ts
66751
- var import_promises9 = require("node:fs/promises");
66752
- var import_node_path32 = require("node:path");
67370
+ var import_promises11 = require("node:fs/promises");
67371
+ var import_node_path33 = require("node:path");
66753
67372
  function evidenceDedupKey(sessionId, reportId) {
66754
67373
  return `${sessionId}:${reportId}`;
66755
67374
  }
@@ -66759,7 +67378,7 @@ function isRecord7(v) {
66759
67378
  async function readDayLines(stateDir, day, sessionId) {
66760
67379
  let raw;
66761
67380
  try {
66762
- raw = await (0, import_promises9.readFile)((0, import_node_path32.join)(stateDir, "logs", `bridge-${day}.jsonl`), "utf8");
67381
+ raw = await (0, import_promises11.readFile)((0, import_node_path33.join)(stateDir, "logs", `bridge-${day}.jsonl`), "utf8");
66763
67382
  } catch {
66764
67383
  return [];
66765
67384
  }
@@ -66833,7 +67452,7 @@ async function assembleEvidence(stateDir, sessionId, reportId, gateCtx) {
66833
67452
  }
66834
67453
  let windowPruned = false;
66835
67454
  try {
66836
- const raw = await (0, import_promises9.readFile)((0, import_node_path32.join)(stateDir, "logs", ".pruned.jsonl"), "utf8");
67455
+ const raw = await (0, import_promises11.readFile)((0, import_node_path33.join)(stateDir, "logs", ".pruned.jsonl"), "utf8");
66837
67456
  outer: for (const line of raw.split("\n")) {
66838
67457
  if (!line.trim()) continue;
66839
67458
  let rec;
@@ -66899,7 +67518,7 @@ function createReportEvidenceDescriptor() {
66899
67518
  var reportEvidenceDescriptor = createReportEvidenceDescriptor();
66900
67519
 
66901
67520
  // src/async-tools/enqueue.ts
66902
- var import_node_crypto13 = __toESM(require("node:crypto"), 1);
67521
+ var import_node_crypto14 = __toESM(require("node:crypto"), 1);
66903
67522
  async function enqueueAsyncTool(client, descriptor2, input) {
66904
67523
  if (descriptor2.cachedResult) {
66905
67524
  const cached2 = await descriptor2.cachedResult(client, input);
@@ -66912,7 +67531,7 @@ async function enqueueAsyncTool(client, descriptor2, input) {
66912
67531
  if (active) {
66913
67532
  return { status: "already_running", jobId: active.id, message: "Already running; will notify in inbox." };
66914
67533
  }
66915
- const jobId = `AJ-${import_node_crypto13.default.randomUUID()}`;
67534
+ const jobId = `AJ-${import_node_crypto14.default.randomUUID()}`;
66916
67535
  try {
66917
67536
  await client.createAsyncJob(input.projectSlug, {
66918
67537
  id: jobId,
@@ -68572,7 +69191,7 @@ function createMrrlinTools(options) {
68572
69191
  "PRODUCED_URL_RECORD_FAILED",
68573
69192
  "Unable to record produced URL.",
68574
69193
  async (c, { projectSlug, runId, url: url2, label }) => {
68575
- const id = `EA-pu-${(0, import_node_crypto14.randomBytes)(4).toString("hex")}`;
69194
+ const id = `EA-pu-${(0, import_node_crypto15.randomBytes)(4).toString("hex")}`;
68576
69195
  const payload = label ? { url: url2, label } : { url: url2 };
68577
69196
  return await c.appendExecutionArtifact(projectSlug, runId, {
68578
69197
  id,
@@ -68646,7 +69265,7 @@ function createMrrlinTools(options) {
68646
69265
  "ARTIFACT_FILE_UPLOAD_FAILED",
68647
69266
  "Unable to upload artifact file.",
68648
69267
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
68649
- const extension2 = import_node_path33.default.extname(filePath).toLowerCase();
69268
+ const extension2 = import_node_path34.default.extname(filePath).toLowerCase();
68650
69269
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68651
69270
  if (!contentType) {
68652
69271
  throw new McpToolCodedError(
@@ -68654,7 +69273,7 @@ function createMrrlinTools(options) {
68654
69273
  `Unsupported artifact extension '${extension2}'. Allowed: ${Object.keys(ARTIFACT_EXTENSION_TYPES).join(", ")}.`
68655
69274
  );
68656
69275
  }
68657
- const stats = await (0, import_promises10.stat)(filePath);
69276
+ const stats = await (0, import_promises12.stat)(filePath);
68658
69277
  if (stats.size > MRRLIN_ARTIFACT_FILE_MAX_BYTES) {
68659
69278
  throw new McpToolCodedError(
68660
69279
  "ARTIFACT_FILE_TOO_LARGE",
@@ -68667,14 +69286,14 @@ function createMrrlinTools(options) {
68667
69286
  "File is empty (0 bytes); write content before uploading."
68668
69287
  );
68669
69288
  }
68670
- const bytes3 = new Uint8Array(await (0, import_promises10.readFile)(filePath));
69289
+ const bytes3 = new Uint8Array(await (0, import_promises12.readFile)(filePath));
68671
69290
  if (bytes3.byteLength > MRRLIN_ARTIFACT_FILE_MAX_BYTES) {
68672
69291
  throw new McpToolCodedError(
68673
69292
  "ARTIFACT_FILE_TOO_LARGE",
68674
69293
  "Artifact exceeds 5MB; split or summarize instead."
68675
69294
  );
68676
69295
  }
68677
- const filename = import_node_path33.default.basename(filePath);
69296
+ const filename = import_node_path34.default.basename(filePath);
68678
69297
  return deliverBuiltIn(
68679
69298
  c,
68680
69299
  projectSlug,
@@ -68696,7 +69315,7 @@ function createMrrlinTools(options) {
68696
69315
  `Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
68697
69316
  );
68698
69317
  }
68699
- const extension2 = import_node_path33.default.extname(filename).toLowerCase();
69318
+ const extension2 = import_node_path34.default.extname(filename).toLowerCase();
68700
69319
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68701
69320
  if (!contentType) {
68702
69321
  throw new McpToolCodedError(
@@ -69007,7 +69626,7 @@ function runSetCredential(args) {
69007
69626
  // src/install-service.ts
69008
69627
  var import_node_os17 = __toESM(require("node:os"), 1);
69009
69628
  var import_node_fs23 = require("node:fs");
69010
- var import_node_path34 = __toESM(require("node:path"), 1);
69629
+ var import_node_path35 = __toESM(require("node:path"), 1);
69011
69630
  function readExistingTelemetryDefaultProject(deps, ecoPath) {
69012
69631
  try {
69013
69632
  const existing = deps.readFile?.(ecoPath);
@@ -69128,9 +69747,9 @@ function installService(deps) {
69128
69747
  const claudeBin = deps.which("claude");
69129
69748
  const resolvedBins = [...bins, claudeBin].filter((b) => b !== null);
69130
69749
  const pathEnv = Array.from(
69131
- /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path34.default.dirname(b)), ...SYSTEM_PATH_DIRS])
69750
+ /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path35.default.dirname(b)), ...SYSTEM_PATH_DIRS])
69132
69751
  ).join(":");
69133
- const ecoPath = import_node_path34.default.join(home, ".mrrlin", "ecosystem.config.cjs");
69752
+ const ecoPath = import_node_path35.default.join(home, ".mrrlin", "ecosystem.config.cjs");
69134
69753
  const apiTarget = deriveServiceApiTarget(deps, ecoPath);
69135
69754
  const telemetryDefaultProject = "MRRLIN_TELEMETRY_DEFAULT_PROJECT" in deps.env ? deps.env.MRRLIN_TELEMETRY_DEFAULT_PROJECT?.trim() || void 0 : readExistingTelemetryDefaultProject(deps, ecoPath);
69136
69755
  const text = renderEcosystemConfig({
@@ -69194,18 +69813,18 @@ function uninstallService(deps) {
69194
69813
  }
69195
69814
 
69196
69815
  // src/uninstall-codex.ts
69197
- var import_promises11 = __toESM(require("node:fs/promises"), 1);
69816
+ var import_promises13 = __toESM(require("node:fs/promises"), 1);
69198
69817
  var import_node_os18 = __toESM(require("node:os"), 1);
69199
- var import_node_path35 = __toESM(require("node:path"), 1);
69818
+ var import_node_path36 = __toESM(require("node:path"), 1);
69200
69819
  var toml3 = __toESM(require_toml(), 1);
69201
69820
  function resolveCodexHome3(options) {
69202
69821
  if (options.codexHome) return options.codexHome;
69203
69822
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
69204
- return import_node_path35.default.join(options.homeDir ?? import_node_os18.default.homedir(), ".codex");
69823
+ return import_node_path36.default.join(options.homeDir ?? import_node_os18.default.homedir(), ".codex");
69205
69824
  }
69206
69825
  async function pathExists4(target) {
69207
69826
  try {
69208
- await import_promises11.default.access(target);
69827
+ await import_promises13.default.access(target);
69209
69828
  return true;
69210
69829
  } catch {
69211
69830
  return false;
@@ -69214,13 +69833,13 @@ async function pathExists4(target) {
69214
69833
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
69215
69834
  async function uninstallCodex(options = {}) {
69216
69835
  const codexHome = resolveCodexHome3(options);
69217
- const configPath = import_node_path35.default.join(codexHome, "config.toml");
69836
+ const configPath = import_node_path36.default.join(codexHome, "config.toml");
69218
69837
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
69219
69838
  if (!await pathExists4(configPath)) {
69220
69839
  return { action: "missing", configPath, prompts: await removePrompts() };
69221
69840
  }
69222
- const realPath = await import_promises11.default.realpath(configPath).catch(() => configPath);
69223
- const existing = await import_promises11.default.readFile(realPath, "utf8");
69841
+ const realPath = await import_promises13.default.realpath(configPath).catch(() => configPath);
69842
+ const existing = await import_promises13.default.readFile(realPath, "utf8");
69224
69843
  let parsed = null;
69225
69844
  try {
69226
69845
  parsed = toml3.parse(existing);
@@ -69237,17 +69856,17 @@ async function uninstallCodex(options = {}) {
69237
69856
  return { action: "noop", configPath: realPath, prompts: await removePrompts() };
69238
69857
  }
69239
69858
  const stripped = existing.replace(MRRLIN_BLOCK_RE, (match) => match.startsWith("\n") ? "\n" : "").replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "");
69240
- await import_promises11.default.writeFile(realPath, stripped, { mode: 384 });
69859
+ await import_promises13.default.writeFile(realPath, stripped, { mode: 384 });
69241
69860
  return { action: "removed", configPath: realPath, prompts: await removePrompts() };
69242
69861
  }
69243
69862
  async function uninstallPrompts(codexHome, names) {
69244
69863
  if (names.length === 0) return [];
69245
- const promptsDir = import_node_path35.default.join(codexHome, "prompts");
69864
+ const promptsDir = import_node_path36.default.join(codexHome, "prompts");
69246
69865
  const out = [];
69247
69866
  for (const name of names) {
69248
- const promptPath = import_node_path35.default.join(promptsDir, `${name}.md`);
69867
+ const promptPath = import_node_path36.default.join(promptsDir, `${name}.md`);
69249
69868
  try {
69250
- await import_promises11.default.unlink(promptPath);
69869
+ await import_promises13.default.unlink(promptPath);
69251
69870
  out.push({ name, action: "removed", promptPath });
69252
69871
  } catch (error51) {
69253
69872
  const code = error51?.code;
@@ -69262,8 +69881,8 @@ async function uninstallPrompts(codexHome, names) {
69262
69881
  }
69263
69882
 
69264
69883
  // src/extract/command.ts
69265
- var import_promises12 = require("node:fs/promises");
69266
- var import_node_path36 = require("node:path");
69884
+ var import_promises14 = require("node:fs/promises");
69885
+ var import_node_path37 = require("node:path");
69267
69886
  function parseArgs(args) {
69268
69887
  const map2 = /* @__PURE__ */ new Map();
69269
69888
  for (let i = 0; i < args.length; i++) {
@@ -69300,10 +69919,10 @@ Missing required flag(s): ${missing.join(
69300
69919
  const days = await findSessionDays(deps.stateDir, sessionId);
69301
69920
  const matchingLines = [];
69302
69921
  for (const day of days) {
69303
- const logPath = (0, import_node_path36.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
69922
+ const logPath = (0, import_node_path37.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
69304
69923
  let raw;
69305
69924
  try {
69306
- raw = await (0, import_promises12.readFile)(logPath, "utf8");
69925
+ raw = await (0, import_promises14.readFile)(logPath, "utf8");
69307
69926
  } catch {
69308
69927
  continue;
69309
69928
  }
@@ -69337,7 +69956,7 @@ Missing required flag(s): ${missing.join(
69337
69956
  }
69338
69957
  const outputText = cappedLines.join("\n");
69339
69958
  if (outPath) {
69340
- await (0, import_promises12.writeFile)(outPath, outputText, "utf8");
69959
+ await (0, import_promises14.writeFile)(outPath, outputText, "utf8");
69341
69960
  return {
69342
69961
  ok: true,
69343
69962
  message: `Wrote extract to ${outPath}`,
@@ -69386,13 +70005,13 @@ Missing required flag(s): ${missing.join(
69386
70005
 
69387
70006
  // src/bin.ts
69388
70007
  function pm2Runner(args) {
69389
- const r = (0, import_node_child_process19.spawnSync)("pm2", args, { encoding: "utf8" });
70008
+ const r = (0, import_node_child_process21.spawnSync)("pm2", args, { encoding: "utf8" });
69390
70009
  process.stderr.write(r.stdout ?? "");
69391
70010
  process.stderr.write(r.stderr ?? "");
69392
70011
  return { code: r.status ?? 1, stdout: r.stdout ?? "" };
69393
70012
  }
69394
70013
  function whichBin(bin) {
69395
- const r = (0, import_node_child_process19.spawnSync)("which", [bin], { encoding: "utf8" });
70014
+ const r = (0, import_node_child_process21.spawnSync)("which", [bin], { encoding: "utf8" });
69396
70015
  const out = (r.stdout ?? "").trim();
69397
70016
  return r.status === 0 && out ? out.split("\n")[0] ?? null : null;
69398
70017
  }
@@ -69401,13 +70020,13 @@ function bootHookStatus() {
69401
70020
  const uid = process.getuid?.();
69402
70021
  if (uid === void 0 || uid === 0) return { status: "unknown" };
69403
70022
  const home = process.env.HOME ?? (0, import_node_os19.homedir)();
69404
- const agents = import_node_path38.default.join(home, "Library", "LaunchAgents");
70023
+ const agents = import_node_path39.default.join(home, "Library", "LaunchAgents");
69405
70024
  const candidates = [
69406
- { label: "com.mrrlin.director-bridge", plist: import_node_path38.default.join(agents, "com.mrrlin.director-bridge.plist") },
69407
- { label: "com.PM2", plist: import_node_path38.default.join(agents, `pm2.${(0, import_node_os19.userInfo)().username}.plist`) }
70025
+ { label: "com.mrrlin.director-bridge", plist: import_node_path39.default.join(agents, "com.mrrlin.director-bridge.plist") },
70026
+ { label: "com.PM2", plist: import_node_path39.default.join(agents, `pm2.${(0, import_node_os19.userInfo)().username}.plist`) }
69408
70027
  ];
69409
70028
  for (const candidate of candidates) {
69410
- const printed = (0, import_node_child_process19.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
70029
+ const printed = (0, import_node_child_process21.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
69411
70030
  if (printed.status !== 0) continue;
69412
70031
  if (!(0, import_node_fs24.existsSync)(candidate.plist)) continue;
69413
70032
  const out = printed.stdout ?? "";
@@ -69629,7 +70248,7 @@ async function main() {
69629
70248
  );
69630
70249
  }
69631
70250
  const { command: command2, args, env } = browserServeArgs();
69632
- const r = (0, import_node_child_process19.spawnSync)(command2, args, { stdio: "inherit", env: { ...process.env, ...env } });
70251
+ const r = (0, import_node_child_process21.spawnSync)(command2, args, { stdio: "inherit", env: { ...process.env, ...env } });
69633
70252
  process.exitCode = r.status ?? 1;
69634
70253
  return;
69635
70254
  }
@@ -69640,7 +70259,7 @@ async function main() {
69640
70259
  }
69641
70260
  case "external-agents-serve": {
69642
70261
  const { command: command2, args } = externalAgentsServeArgs();
69643
- const r = (0, import_node_child_process19.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
70262
+ const r = (0, import_node_child_process21.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
69644
70263
  process.exitCode = r.status ?? 1;
69645
70264
  return;
69646
70265
  }
@@ -69694,8 +70313,8 @@ async function main() {
69694
70313
  }
69695
70314
  }
69696
70315
  try {
69697
- const codexHome = process.env.CODEX_HOME ?? import_node_path38.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".codex");
69698
- (0, import_node_fs24.rmSync)(import_node_path38.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
70316
+ const codexHome = process.env.CODEX_HOME ?? import_node_path39.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".codex");
70317
+ (0, import_node_fs24.rmSync)(import_node_path39.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
69699
70318
  } catch {
69700
70319
  }
69701
70320
  const claudeResult = await installClaude({ binPath, force, serveEnv });
@@ -69708,7 +70327,7 @@ async function main() {
69708
70327
  );
69709
70328
  }
69710
70329
  const realProviderRunner = (command2) => (args) => {
69711
- const r = (0, import_node_child_process19.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
70330
+ const r = (0, import_node_child_process21.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
69712
70331
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
69713
70332
  };
69714
70333
  for (const provider of ["codex", "claude"]) {
@@ -69756,7 +70375,7 @@ async function main() {
69756
70375
  env: process.env,
69757
70376
  cwd: process.cwd(),
69758
70377
  writeFile: (p, c) => {
69759
- (0, import_node_fs24.mkdirSync)(import_node_path38.default.dirname(p), { recursive: true, mode: 448 });
70378
+ (0, import_node_fs24.mkdirSync)(import_node_path39.default.dirname(p), { recursive: true, mode: 448 });
69760
70379
  (0, import_node_fs24.writeFileSync)(p, c, { mode: 384 });
69761
70380
  },
69762
70381
  // Swallows every error on purpose — the only caller uses this to recover settings from the
@@ -69792,7 +70411,7 @@ async function main() {
69792
70411
  purgeSecret: purge,
69793
70412
  secretPath: agentCredentialPath(),
69794
70413
  tokenPath: operatorTokenPath(),
69795
- ecoPath: import_node_path38.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
70414
+ ecoPath: import_node_path39.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
69796
70415
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
69797
70416
  `)
69798
70417
  });
@@ -69813,7 +70432,7 @@ async function main() {
69813
70432
  purgeSecret: true,
69814
70433
  secretPath: agentCredentialPath(),
69815
70434
  tokenPath: operatorTokenPath(),
69816
- ecoPath: import_node_path38.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
70435
+ ecoPath: import_node_path39.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
69817
70436
  log
69818
70437
  });
69819
70438
  let codexOk = true;
@@ -69833,7 +70452,7 @@ async function main() {
69833
70452
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
69834
70453
  }
69835
70454
  try {
69836
- (0, import_node_fs24.rmSync)(import_node_path38.default.join(home, ".mrrlin"), { recursive: true, force: true });
70455
+ (0, import_node_fs24.rmSync)(import_node_path39.default.join(home, ".mrrlin"), { recursive: true, force: true });
69837
70456
  } catch {
69838
70457
  }
69839
70458
  log("removed ~/.mrrlin");
@@ -69874,7 +70493,7 @@ ${HELP_TEXT}`);
69874
70493
  }
69875
70494
  }
69876
70495
  function resolveSelfBinPath() {
69877
- return import_node_path37.default.resolve(process.argv[1] ?? process.execPath);
70496
+ return import_node_path38.default.resolve(process.argv[1] ?? process.execPath);
69878
70497
  }
69879
70498
  main().catch((error51) => {
69880
70499
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}