@mrrlin-dev/mcp 0.4.66 → 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 +855 -325
  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) {
@@ -40816,7 +41337,8 @@ async function mintResolvedSeat(provider, opts) {
40816
41337
  let weakModel;
40817
41338
  let pinRetired;
40818
41339
  let retiredPin;
40819
- const strongEnvValue = process.env[providerId === "codex" ? CODEX_STRONG_MODEL_ENV : CLAUDE_STRONG_MODEL_ENV]?.trim();
41340
+ const strongEnvVar = strongEnvVarFor(providerId);
41341
+ const strongEnvValue = process.env[strongEnvVar]?.trim();
40820
41342
  if (opts?.handle && capabilities.listsModels) {
40821
41343
  try {
40822
41344
  const models = await opts.handle.listModels();
@@ -40841,7 +41363,7 @@ async function mintResolvedSeat(provider, opts) {
40841
41363
  strongModel = strongEnvValue;
40842
41364
  logFallback(providerId, "strong", "env", strongModel);
40843
41365
  } else {
40844
- strongModel = providerId === "codex" ? CODEX_STRONG_MODEL_CONSTANT : CLAUDE_STRONG_MODEL_CONSTANT;
41366
+ strongModel = strongConstantFor(providerId);
40845
41367
  logFallback(providerId, "strong", "constant", strongModel);
40846
41368
  }
40847
41369
  }
@@ -40849,7 +41371,7 @@ async function mintResolvedSeat(provider, opts) {
40849
41371
  strongModel = strongEnvValue;
40850
41372
  logFallback(providerId, "strong", "env", strongModel);
40851
41373
  } else {
40852
- strongModel = providerId === "codex" ? CODEX_STRONG_MODEL_CONSTANT : CLAUDE_STRONG_MODEL_CONSTANT;
41374
+ strongModel = strongConstantFor(providerId);
40853
41375
  logFallback(providerId, "strong", "constant", strongModel);
40854
41376
  }
40855
41377
  if (providerId === "claude") {
@@ -40867,11 +41389,11 @@ async function mintResolvedSeat(provider, opts) {
40867
41389
  logFallback(providerId, "weak", "degenerate (weak=strong)", weakModel);
40868
41390
  }
40869
41391
  } catch {
40870
- weakModel = CODEX_WEAK_MODEL_CONSTANT;
41392
+ weakModel = weakConstantFor(providerId);
40871
41393
  logFallback(providerId, "weak", "constant", weakModel);
40872
41394
  }
40873
41395
  } else {
40874
- weakModel = CODEX_WEAK_MODEL_CONSTANT;
41396
+ weakModel = weakConstantFor(providerId);
40875
41397
  logFallback(providerId, "weak", "constant", weakModel);
40876
41398
  }
40877
41399
  }
@@ -42360,17 +42882,17 @@ function createTurnLock() {
42360
42882
  }
42361
42883
 
42362
42884
  // src/self-update.ts
42363
- var import_node_child_process8 = require("node:child_process");
42364
- 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");
42365
42887
  var import_node_fs4 = require("node:fs");
42366
- var import_node_path7 = __toESM(require("node:path"), 1);
42888
+ var import_node_path8 = __toESM(require("node:path"), 1);
42367
42889
  var import_semver3 = __toESM(require_semver2(), 1);
42368
42890
 
42369
42891
  // src/codex-auth-preflight.ts
42370
- var import_node_child_process7 = require("node:child_process");
42892
+ var import_node_child_process9 = require("node:child_process");
42371
42893
  var import_node_fs3 = require("node:fs");
42372
42894
  var import_node_os6 = __toESM(require("node:os"), 1);
42373
- var import_node_path6 = __toESM(require("node:path"), 1);
42895
+ var import_node_path7 = __toESM(require("node:path"), 1);
42374
42896
  var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
42375
42897
  var DEFAULT_CODEX_AUTH_SMOKE_TIMEOUT_MS = 2e4;
42376
42898
  var DEFAULT_CODEX_AUTH_SMOKE_MODEL = "gpt-5.4-mini";
@@ -42389,7 +42911,7 @@ function codexAuthSmokeTimeoutMs(env = process.env) {
42389
42911
  function resolveCodexAuthPath(opts = {}) {
42390
42912
  const env = opts.env ?? process.env;
42391
42913
  const codexHome = env.CODEX_HOME?.trim();
42392
- 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");
42393
42915
  }
42394
42916
  function decodeJwtExpMs(token) {
42395
42917
  const parts = token.split(".");
@@ -42458,7 +42980,7 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
42458
42980
  CODEX_AUTH_SMOKE_PROMPT
42459
42981
  ];
42460
42982
  const command = commandForSmoke(executable, model);
42461
- const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process7.execFileSync;
42983
+ const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process9.execFileSync;
42462
42984
  try {
42463
42985
  execFileSync5(executable, args, {
42464
42986
  cwd,
@@ -42609,12 +43131,12 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
42609
43131
  var BIN_NAME = "mrrlin-mcp";
42610
43132
  var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
42611
43133
  function resolveBinPath(opts) {
42612
- 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")) {
42613
43135
  return { path: opts.argv1, source: "argv" };
42614
43136
  }
42615
43137
  const whichSync = opts.whichSync ?? ((name) => {
42616
43138
  try {
42617
- 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;
42618
43140
  } catch {
42619
43141
  return null;
42620
43142
  }
@@ -42625,9 +43147,9 @@ function resolveBinPath(opts) {
42625
43147
  return { path: resolved, source: "which" };
42626
43148
  }
42627
43149
  const envPath = (opts.env ?? process.env).PATH ?? "";
42628
- for (const dir of envPath.split(import_node_path7.default.delimiter)) {
43150
+ for (const dir of envPath.split(import_node_path8.default.delimiter)) {
42629
43151
  if (!dir) continue;
42630
- const candidate = import_node_path7.default.join(dir, BIN_NAME);
43152
+ const candidate = import_node_path8.default.join(dir, BIN_NAME);
42631
43153
  if (existsSync5(candidate)) {
42632
43154
  return { path: candidate, source: "path-walk" };
42633
43155
  }
@@ -42653,7 +43175,7 @@ function readIntervalEnv(name, fallback) {
42653
43175
  return Number.isFinite(n) && n > 0 ? n : fallback;
42654
43176
  }
42655
43177
  function sha256(buf) {
42656
- return (0, import_node_crypto2.createHash)("sha256").update(buf).digest("hex");
43178
+ return (0, import_node_crypto3.createHash)("sha256").update(buf).digest("hex");
42657
43179
  }
42658
43180
  function startSelfUpdate(deps) {
42659
43181
  const log = deps.log ?? (() => {
@@ -42945,17 +43467,17 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
42945
43467
  }
42946
43468
 
42947
43469
  // src/_generated/version.ts
42948
- var PKG_VERSION = "0.4.66";
43470
+ var PKG_VERSION = "0.4.67";
42949
43471
 
42950
43472
  // src/api-base-url-migrate.ts
42951
43473
  var import_node_fs5 = __toESM(require("node:fs"), 1);
42952
43474
  var import_node_os7 = __toESM(require("node:os"), 1);
42953
- var import_node_path9 = __toESM(require("node:path"), 1);
43475
+ var import_node_path10 = __toESM(require("node:path"), 1);
42954
43476
 
42955
43477
  // src/service-paths.ts
42956
- var import_node_path8 = __toESM(require("node:path"), 1);
43478
+ var import_node_path9 = __toESM(require("node:path"), 1);
42957
43479
  function isWorktreePath(p) {
42958
- 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("/");
42959
43481
  return norm.includes("/.claude/worktrees/");
42960
43482
  }
42961
43483
  function resolveServiceCwd(opts) {
@@ -43013,7 +43535,7 @@ function defaultDeps(deps) {
43013
43535
  const home = deps.home ?? process.env.HOME ?? import_node_os7.default.homedir();
43014
43536
  return {
43015
43537
  home,
43016
- 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"),
43017
43539
  readFile: deps.readFile ?? ((p) => import_node_fs5.default.readFileSync(p, "utf8")),
43018
43540
  // Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
43019
43541
  // interleave partial writes into a config the next start has to parse. Note this normalizes the
@@ -43062,7 +43584,7 @@ function backupOnce(file2, text, deps) {
43062
43584
  }
43063
43585
  function migrateEcosystemConfig(deps = {}) {
43064
43586
  const d = defaultDeps(deps);
43065
- 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");
43066
43588
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43067
43589
  const text = d.readFile(file2);
43068
43590
  if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
@@ -43212,7 +43734,7 @@ ${envLines}
43212
43734
  }
43213
43735
  function migrateCodexConfig(deps = {}) {
43214
43736
  const d = defaultDeps(deps);
43215
- const file2 = import_node_path9.default.join(d.codexHome, "config.toml");
43737
+ const file2 = import_node_path10.default.join(d.codexHome, "config.toml");
43216
43738
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43217
43739
  const text = d.readFile(file2);
43218
43740
  const host = findRetiredHost(text);
@@ -43298,7 +43820,7 @@ $1`
43298
43820
  }
43299
43821
  function migrateClaudeConfig(deps = {}) {
43300
43822
  const d = defaultDeps(deps);
43301
- const file2 = import_node_path9.default.join(d.home, ".claude.json");
43823
+ const file2 = import_node_path10.default.join(d.home, ".claude.json");
43302
43824
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43303
43825
  const text = d.readFile(file2);
43304
43826
  let parsed;
@@ -43348,9 +43870,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
43348
43870
  const d = defaultDeps(deps);
43349
43871
  const results = [];
43350
43872
  const steps = [
43351
- { run: migrateEcosystemConfig, file: import_node_path9.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
43352
- { run: migrateCodexConfig, file: import_node_path9.default.join(d.codexHome, "config.toml") },
43353
- { 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") }
43354
43876
  ];
43355
43877
  for (const step of steps) {
43356
43878
  try {
@@ -43377,7 +43899,7 @@ function migrateRetiredApiBaseUrls(deps = {}) {
43377
43899
 
43378
43900
  // src/bridge-health.ts
43379
43901
  var import_node_fs6 = require("node:fs");
43380
- var import_node_path10 = __toESM(require("node:path"), 1);
43902
+ var import_node_path11 = __toESM(require("node:path"), 1);
43381
43903
  var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
43382
43904
  var CRASH_WINDOW_MS = 60 * 60 * 1e3;
43383
43905
  var MAX_CRASHES_PER_WINDOW = 3;
@@ -43389,7 +43911,7 @@ function isCrashSentinel(value) {
43389
43911
  return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
43390
43912
  }
43391
43913
  async function readCrashSentinel(stateDir, now = Date.now) {
43392
- const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
43914
+ const sentinelPath = import_node_path11.default.join(stateDir, SENTINEL_FILE_NAME);
43393
43915
  try {
43394
43916
  const raw = await import_node_fs6.promises.readFile(sentinelPath, "utf8");
43395
43917
  const parsed = JSON.parse(raw);
@@ -43400,7 +43922,7 @@ async function readCrashSentinel(stateDir, now = Date.now) {
43400
43922
  }
43401
43923
  async function writeCrashSentinel(stateDir, sentinel) {
43402
43924
  await import_node_fs6.promises.mkdir(stateDir, { recursive: true });
43403
- const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
43925
+ const sentinelPath = import_node_path11.default.join(stateDir, SENTINEL_FILE_NAME);
43404
43926
  const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
43405
43927
  await import_node_fs6.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
43406
43928
  await import_node_fs6.promises.rename(tmpPath, sentinelPath);
@@ -43729,16 +44251,16 @@ function startSchedulerTickLoop(deps) {
43729
44251
  }
43730
44252
 
43731
44253
  // src/retention/pruner.ts
43732
- var import_promises4 = require("node:fs/promises");
43733
- 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);
43734
44256
  function protectedDayFloor(protectedSinceMs) {
43735
44257
  return new Date(protectedSinceMs).toISOString().slice(0, 10);
43736
44258
  }
43737
44259
  async function prune(stateDir, bounds) {
43738
- const logsDir = import_node_path11.default.join(stateDir, "logs");
44260
+ const logsDir = import_node_path12.default.join(stateDir, "logs");
43739
44261
  let entries;
43740
44262
  try {
43741
- entries = await (0, import_promises4.readdir)(logsDir);
44263
+ entries = await (0, import_promises6.readdir)(logsDir);
43742
44264
  } catch (err) {
43743
44265
  if (err?.code === "ENOENT") {
43744
44266
  await emitPruneLog(stateDir, [], {}, 0, null);
@@ -43751,8 +44273,8 @@ async function prune(stateDir, bounds) {
43751
44273
  for (const entry of entries) {
43752
44274
  const m = bridgeRe.exec(entry);
43753
44275
  if (!m?.[1]) continue;
43754
- const fullPath = import_node_path11.default.join(logsDir, entry);
43755
- 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);
43756
44278
  files.push({ day: m[1], size: s.size, fullPath });
43757
44279
  }
43758
44280
  files.sort((a, b) => a.day < b.day ? -1 : a.day > b.day ? 1 : 0);
@@ -43760,10 +44282,10 @@ async function prune(stateDir, bounds) {
43760
44282
  const reasonByDay = {};
43761
44283
  let bytesRemoved = 0;
43762
44284
  async function isDaySafeToDelete(day) {
43763
- const telemetryDir = import_node_path11.default.join(stateDir, "telemetry");
44285
+ const telemetryDir = import_node_path12.default.join(stateDir, "telemetry");
43764
44286
  let telemetryEntries;
43765
44287
  try {
43766
- telemetryEntries = await (0, import_promises4.readdir)(telemetryDir);
44288
+ telemetryEntries = await (0, import_promises6.readdir)(telemetryDir);
43767
44289
  } catch (err) {
43768
44290
  if (err?.code === "ENOENT") return true;
43769
44291
  throw err;
@@ -43776,9 +44298,9 @@ async function prune(stateDir, bounds) {
43776
44298
  }
43777
44299
  if (projectSlugs.length === 0) return true;
43778
44300
  for (const slug of projectSlugs) {
43779
- const markerPath = import_node_path11.default.join(telemetryDir, `.processed-${slug}-${day}`);
44301
+ const markerPath = import_node_path12.default.join(telemetryDir, `.processed-${slug}-${day}`);
43780
44302
  try {
43781
- await (0, import_promises4.stat)(markerPath);
44303
+ await (0, import_promises6.stat)(markerPath);
43782
44304
  } catch (err) {
43783
44305
  if (err?.code === "ENOENT") return false;
43784
44306
  throw err;
@@ -43799,7 +44321,7 @@ async function prune(stateDir, bounds) {
43799
44321
  i += 1;
43800
44322
  continue;
43801
44323
  }
43802
- await (0, import_promises4.unlink)(candidate.fullPath);
44324
+ await (0, import_promises6.unlink)(candidate.fullPath);
43803
44325
  daysRemoved.push(candidate.day);
43804
44326
  reasonByDay[candidate.day] = "size";
43805
44327
  bytesRemoved += candidate.size;
@@ -43813,7 +44335,7 @@ async function prune(stateDir, bounds) {
43813
44335
  const fileDate = /* @__PURE__ */ new Date(`${info.day}T00:00:00Z`);
43814
44336
  const ageInDays = (now - fileDate.getTime()) / msPerDay;
43815
44337
  if (ageInDays > bounds.ageDays && !isProtected(info.day) && await isDaySafeToDelete(info.day)) {
43816
- await (0, import_promises4.unlink)(info.fullPath);
44338
+ await (0, import_promises6.unlink)(info.fullPath);
43817
44339
  daysRemoved.push(info.day);
43818
44340
  reasonByDay[info.day] = "age";
43819
44341
  bytesRemoved += info.size;
@@ -43826,11 +44348,11 @@ async function prune(stateDir, bounds) {
43826
44348
  const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
43827
44349
  await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
43828
44350
  if (daysRemoved.length > 0) {
43829
- const sessionsPath = import_node_path11.default.join(logsDir, ".sessions.json");
44351
+ const sessionsPath = import_node_path12.default.join(logsDir, ".sessions.json");
43830
44352
  let sessionsObj = {};
43831
44353
  let fileExists = true;
43832
44354
  try {
43833
- sessionsObj = JSON.parse(await (0, import_promises4.readFile)(sessionsPath, "utf8"));
44355
+ sessionsObj = JSON.parse(await (0, import_promises6.readFile)(sessionsPath, "utf8"));
43834
44356
  } catch (err) {
43835
44357
  if (err?.code === "ENOENT") {
43836
44358
  fileExists = false;
@@ -43841,25 +44363,25 @@ async function prune(stateDir, bounds) {
43841
44363
  if (fileExists) {
43842
44364
  for (const day of daysRemoved) Reflect.deleteProperty(sessionsObj, day);
43843
44365
  const tmpPath = `${sessionsPath}.tmp`;
43844
- await (0, import_promises4.writeFile)(tmpPath, JSON.stringify(sessionsObj));
43845
- 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);
43846
44368
  }
43847
44369
  }
43848
44370
  return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
43849
44371
  }
43850
44372
  async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining) {
43851
- const logsDir = import_node_path11.default.join(stateDir, "logs");
43852
- const logPath = import_node_path11.default.join(logsDir, ".pruned.jsonl");
43853
- 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 });
43854
44376
  const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
43855
- await (0, import_promises4.appendFile)(logPath, `${JSON.stringify(record2)}
44377
+ await (0, import_promises6.appendFile)(logPath, `${JSON.stringify(record2)}
43856
44378
  `);
43857
44379
  }
43858
44380
 
43859
44381
  // src/telemetry/turn-aggregator.ts
43860
- var import_node_crypto3 = require("node:crypto");
43861
- var import_promises5 = require("node:fs/promises");
43862
- 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");
43863
44385
  var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
43864
44386
  var PLUMBING_COUNTER_KEY = {
43865
44387
  socket_close: "socketCloses",
@@ -43888,10 +44410,10 @@ function inheritSlug(seeds, index) {
43888
44410
  return (preceding ?? following)?.slug;
43889
44411
  }
43890
44412
  async function foldClosedDays(stateDir, today) {
43891
- const logsDir = (0, import_node_path12.join)(stateDir, "logs");
44413
+ const logsDir = (0, import_node_path13.join)(stateDir, "logs");
43892
44414
  let entries;
43893
44415
  try {
43894
- entries = await (0, import_promises5.readdir)(logsDir);
44416
+ entries = await (0, import_promises7.readdir)(logsDir);
43895
44417
  } catch {
43896
44418
  return;
43897
44419
  }
@@ -43900,7 +44422,7 @@ async function foldClosedDays(stateDir, today) {
43900
44422
  if (!m) continue;
43901
44423
  const day = m[1];
43902
44424
  if (day === today) continue;
43903
- 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");
43904
44426
  const groups = /* @__PURE__ */ new Map();
43905
44427
  let groupCounter = 0;
43906
44428
  for (const line of raw.split("\n")) {
@@ -44011,16 +44533,16 @@ async function foldClosedDays(stateDir, today) {
44011
44533
  rowsByProject.set(slug, rows);
44012
44534
  }
44013
44535
  if (rowsByProject.size === 0) continue;
44014
- const telemetryDir = (0, import_node_path12.join)(stateDir, "telemetry");
44015
- 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 });
44016
44538
  for (const [slug, rows] of rowsByProject) {
44017
- const finalPath = (0, import_node_path12.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
44018
- 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")}`;
44019
44541
  try {
44020
- await (0, import_promises5.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
44021
- 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);
44022
44544
  } finally {
44023
- await (0, import_promises5.unlink)(tmpPath).catch(() => {
44545
+ await (0, import_promises7.unlink)(tmpPath).catch(() => {
44024
44546
  });
44025
44547
  }
44026
44548
  }
@@ -44028,23 +44550,23 @@ async function foldClosedDays(stateDir, today) {
44028
44550
  }
44029
44551
 
44030
44552
  // src/telemetry/daily-uploader.ts
44031
- var import_promises6 = require("node:fs/promises");
44032
- var import_node_path17 = require("node:path");
44553
+ var import_promises8 = require("node:fs/promises");
44554
+ var import_node_path18 = require("node:path");
44033
44555
 
44034
44556
  // src/consensus/wiring.ts
44035
- var import_node_crypto4 = __toESM(require("node:crypto"), 1);
44557
+ var import_node_crypto5 = __toESM(require("node:crypto"), 1);
44036
44558
  var import_node_fs9 = __toESM(require("node:fs"), 1);
44037
- var import_node_path15 = __toESM(require("node:path"), 1);
44559
+ var import_node_path16 = __toESM(require("node:path"), 1);
44038
44560
  var import_node_url2 = require("node:url");
44039
44561
 
44040
44562
  // src/consensus/gate-usage-log.ts
44041
44563
  var import_node_fs7 = require("node:fs");
44042
- var import_node_path13 = require("node:path");
44564
+ var import_node_path14 = require("node:path");
44043
44565
  function recordGateCall(stateDir, projectSlug, record2) {
44044
44566
  try {
44045
- const dir = (0, import_node_path13.join)(stateDir, "telemetry");
44567
+ const dir = (0, import_node_path14.join)(stateDir, "telemetry");
44046
44568
  (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
44047
- (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)}
44048
44570
  `, "utf8");
44049
44571
  } catch {
44050
44572
  }
@@ -44912,15 +45434,15 @@ ${issuesBlock}`,
44912
45434
  // src/consensus/sterile-cwd.ts
44913
45435
  var import_node_fs8 = require("node:fs");
44914
45436
  var import_node_os8 = require("node:os");
44915
- var import_node_path14 = require("node:path");
45437
+ var import_node_path15 = require("node:path");
44916
45438
  var sterileDir = null;
44917
45439
  function sterileCwd() {
44918
- 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-"));
44919
45441
  return sterileDir;
44920
45442
  }
44921
45443
 
44922
45444
  // src/consensus/code-gate-git.ts
44923
- var import_node_child_process9 = require("node:child_process");
45445
+ var import_node_child_process11 = require("node:child_process");
44924
45446
  var DIFF_MAX_BYTES = 2e5;
44925
45447
  var FASTGATE_OUTPUT_MAX_BYTES = 16e3;
44926
45448
  var GIT_TIMEOUT_MS = 6e4;
@@ -44936,7 +45458,7 @@ var defaultRunCmd = (cmd, args, opts) => new Promise((resolve) => {
44936
45458
  };
44937
45459
  let child;
44938
45460
  try {
44939
- child = (0, import_node_child_process9.spawn)(cmd, args, {
45461
+ child = (0, import_node_child_process11.spawn)(cmd, args, {
44940
45462
  cwd: opts.cwd,
44941
45463
  env: process.env,
44942
45464
  shell: false,
@@ -45151,15 +45673,15 @@ ${res.stdout}${res.stderr}`);
45151
45673
  var import_meta2 = {};
45152
45674
  function getPersonasDir() {
45153
45675
  if (typeof __dirname !== "undefined") {
45154
- return import_node_path15.default.join(__dirname, "consensus", "personas");
45676
+ return import_node_path16.default.join(__dirname, "consensus", "personas");
45155
45677
  }
45156
- 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");
45157
45679
  }
45158
45680
  var personaCache = /* @__PURE__ */ new Map();
45159
45681
  function loadPersona(name) {
45160
45682
  const cached2 = personaCache.get(name);
45161
45683
  if (cached2 !== void 0) return cached2;
45162
- 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");
45163
45685
  personaCache.set(name, content);
45164
45686
  return content;
45165
45687
  }
@@ -45724,7 +46246,7 @@ You revise a deliverable to address the accepted issues so it satisfies the acce
45724
46246
  try {
45725
46247
  const diagnostics = Array.isArray(r["diagnostics"]) ? r["diagnostics"] : void 0;
45726
46248
  await client.appendExecutionArtifact(projectSlug, runId, {
45727
- id: `EA-${import_node_crypto4.default.randomUUID()}`,
46249
+ id: `EA-${import_node_crypto5.default.randomUUID()}`,
45728
46250
  kind: "verification",
45729
46251
  payload: {
45730
46252
  source: "deliverable-gate",
@@ -45826,23 +46348,23 @@ async function gate(artifact, prose, ctx) {
45826
46348
  }
45827
46349
 
45828
46350
  // src/telemetry/installation-id.ts
45829
- var import_node_crypto5 = require("node:crypto");
46351
+ var import_node_crypto6 = require("node:crypto");
45830
46352
  var import_node_fs10 = require("node:fs");
45831
- var import_node_path16 = require("node:path");
46353
+ var import_node_path17 = require("node:path");
45832
46354
  var FILE_NAME = "installation-id";
45833
46355
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
45834
46356
  var cache = /* @__PURE__ */ new Map();
45835
46357
  function resolveInstallationId(stateDir) {
45836
46358
  const cached2 = cache.get(stateDir);
45837
46359
  if (cached2 !== void 0) return cached2;
45838
- const path25 = (0, import_node_path16.join)(stateDir, FILE_NAME);
46360
+ const path25 = (0, import_node_path17.join)(stateDir, FILE_NAME);
45839
46361
  let id;
45840
46362
  try {
45841
46363
  id = (0, import_node_fs10.readFileSync)(path25, "utf8").trim();
45842
46364
  if (!UUID.test(id)) throw new Error("unusable");
45843
46365
  } catch {
45844
- id = (0, import_node_crypto5.randomUUID)();
45845
- (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 });
45846
46368
  (0, import_node_fs10.writeFileSync)(path25, `${id}
45847
46369
  `, "utf8");
45848
46370
  }
@@ -45860,10 +46382,10 @@ function truncateCause(err) {
45860
46382
  return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
45861
46383
  }
45862
46384
  async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45863
- const telemetryDir = (0, import_node_path17.join)(stateDir, "telemetry");
46385
+ const telemetryDir = (0, import_node_path18.join)(stateDir, "telemetry");
45864
46386
  let files;
45865
46387
  try {
45866
- files = await (0, import_promises6.readdir)(telemetryDir);
46388
+ files = await (0, import_promises8.readdir)(telemetryDir);
45867
46389
  } catch (err) {
45868
46390
  if (err?.code === "ENOENT") return;
45869
46391
  throw err;
@@ -45876,24 +46398,24 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45876
46398
  const [, projectSlug, day] = match;
45877
46399
  const key = `${projectSlug}\0${day}`;
45878
46400
  const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
45879
- if (rowsMatch) entry.rowsPath = (0, import_node_path17.join)(telemetryDir, file2);
46401
+ if (rowsMatch) entry.rowsPath = (0, import_node_path18.join)(telemetryDir, file2);
45880
46402
  discovered.set(key, entry);
45881
46403
  }
45882
46404
  const today = telemetryDay();
45883
46405
  const pending = [];
45884
46406
  const deferred = [];
45885
46407
  for (const { projectSlug, day, rowsPath } of discovered.values()) {
45886
- const markerPath = (0, import_node_path17.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
46408
+ const markerPath = (0, import_node_path18.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
45887
46409
  if (rowsPath === null && day >= today) {
45888
46410
  try {
45889
- await (0, import_promises6.access)(markerPath);
46411
+ await (0, import_promises8.access)(markerPath);
45890
46412
  } catch {
45891
46413
  deferred.push({ projectSlug, day });
45892
46414
  }
45893
46415
  continue;
45894
46416
  }
45895
46417
  try {
45896
- await (0, import_promises6.access)(markerPath);
46418
+ await (0, import_promises8.access)(markerPath);
45897
46419
  } catch {
45898
46420
  pending.push({ projectSlug, day, rowsPath, markerPath });
45899
46421
  }
@@ -45903,10 +46425,10 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45903
46425
  const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
45904
46426
  pending.sort((a, b) => a.day.localeCompare(b.day));
45905
46427
  for (const cur of pending) {
45906
- 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`);
45907
46429
  let failureState = null;
45908
46430
  try {
45909
- const data = await (0, import_promises6.readFile)(failurePath, "utf8");
46431
+ const data = await (0, import_promises8.readFile)(failurePath, "utf8");
45910
46432
  failureState = JSON.parse(data);
45911
46433
  } catch {
45912
46434
  failureState = null;
@@ -45921,7 +46443,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45921
46443
  let raw = "";
45922
46444
  if (cur.rowsPath !== null) {
45923
46445
  try {
45924
- raw = await (0, import_promises6.readFile)(cur.rowsPath, "utf8");
46446
+ raw = await (0, import_promises8.readFile)(cur.rowsPath, "utf8");
45925
46447
  } catch (err) {
45926
46448
  console.error(`uploadPendingDays: failed to read ${cur.rowsPath}`, err);
45927
46449
  throw err;
@@ -45937,7 +46459,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45937
46459
  }
45938
46460
  const gateCalls = [];
45939
46461
  try {
45940
- 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");
45941
46463
  for (const line of rawGate.split("\n")) {
45942
46464
  if (!line.trim()) continue;
45943
46465
  try {
@@ -45979,14 +46501,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45979
46501
  if (success2) {
45980
46502
  const tmpMarker = `${cur.markerPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
45981
46503
  try {
45982
- await (0, import_promises6.writeFile)(tmpMarker, "");
45983
- await (0, import_promises6.rename)(tmpMarker, cur.markerPath);
46504
+ await (0, import_promises8.writeFile)(tmpMarker, "");
46505
+ await (0, import_promises8.rename)(tmpMarker, cur.markerPath);
45984
46506
  } catch (err) {
45985
46507
  console.error(`uploadPendingDays: failed to write marker for ${cur.projectSlug}/${cur.day}`, err);
45986
46508
  }
45987
46509
  if (failureState) {
45988
46510
  try {
45989
- await (0, import_promises6.unlink)(failurePath);
46511
+ await (0, import_promises8.unlink)(failurePath);
45990
46512
  console.log(`uploadPendingDays: partition ${cur.projectSlug}/${cur.day} recovered after ${failureState.failureCount + 1} consecutive failures`);
45991
46513
  } catch (err) {
45992
46514
  console.error(`uploadPendingDays: failed to remove failure state for ${cur.projectSlug}/${cur.day}`, err);
@@ -46014,8 +46536,8 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
46014
46536
  };
46015
46537
  const tmpFailurePath = `${failurePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
46016
46538
  try {
46017
- await (0, import_promises6.writeFile)(tmpFailurePath, JSON.stringify(newFailureState));
46018
- 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);
46019
46541
  } catch (writeErr) {
46020
46542
  console.error(`uploadPendingDays: failed to write failure state for ${cur.projectSlug}/${cur.day}`, writeErr);
46021
46543
  }
@@ -46141,7 +46663,7 @@ async function collectAgentPoolSnapshot(deps) {
46141
46663
  }
46142
46664
 
46143
46665
  // src/external-agents-spawn.ts
46144
- var import_node_child_process10 = require("node:child_process");
46666
+ var import_node_child_process12 = require("node:child_process");
46145
46667
 
46146
46668
  // src/external-agents-bin.ts
46147
46669
  function resolveExternalAgentsCliInvocation(override) {
@@ -46187,7 +46709,7 @@ function runExternalAgentsCli(args, opts) {
46187
46709
  };
46188
46710
  let spawned;
46189
46711
  try {
46190
- 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 });
46191
46713
  } catch {
46192
46714
  done(1);
46193
46715
  return;
@@ -46299,14 +46821,14 @@ function startAgentPoolLoop(deps) {
46299
46821
  }
46300
46822
 
46301
46823
  // src/provider-readiness-loop.ts
46302
- var import_node_child_process11 = require("node:child_process");
46824
+ var import_node_child_process13 = require("node:child_process");
46303
46825
  var DEFAULT_INTERVAL_MS3 = 6e4;
46304
46826
  function providerReadinessLoopDisabled(env = process.env) {
46305
46827
  return env["MRRLIN_BRIDGE_PROVIDER_READINESS_DISABLE"] === "1";
46306
46828
  }
46307
46829
  function defaultRunnerFor(command) {
46308
46830
  return (args) => {
46309
- 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 });
46310
46832
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
46311
46833
  };
46312
46834
  }
@@ -46358,10 +46880,10 @@ function setSelectedProvider(value) {
46358
46880
  }
46359
46881
 
46360
46882
  // src/execution-consumer.ts
46361
- var import_node_child_process13 = require("node:child_process");
46362
- var import_node_crypto7 = __toESM(require("node:crypto"), 1);
46363
- var import_node_path21 = __toESM(require("node:path"), 1);
46364
- 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");
46365
46887
 
46366
46888
  // src/consensus/deliverable-gate-outcome.ts
46367
46889
  var MAX_DELIVERABLE_DIAGNOSTICS = 5;
@@ -46430,7 +46952,7 @@ function mapDeliverableGateResult(result) {
46430
46952
  }
46431
46953
 
46432
46954
  // src/async-tools/draft-spec.ts
46433
- var import_node_crypto6 = require("node:crypto");
46955
+ var import_node_crypto7 = require("node:crypto");
46434
46956
  var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
46435
46957
  var SPECS_FOLDER = "Specs";
46436
46958
  var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
@@ -46925,7 +47447,7 @@ function onComplete(outcome, input) {
46925
47447
  };
46926
47448
  }
46927
47449
  const summary = outcome.error;
46928
- 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);
46929
47451
  return {
46930
47452
  kind: "info",
46931
47453
  id: `II-sched-draft-failed-${input.taskId}-${hash3}`,
@@ -47655,18 +48177,18 @@ async function awaitTurnWithDeadline(opts) {
47655
48177
  }
47656
48178
 
47657
48179
  // src/worktree.ts
47658
- var import_node_child_process12 = require("node:child_process");
48180
+ var import_node_child_process14 = require("node:child_process");
47659
48181
  var import_node_fs12 = require("node:fs");
47660
48182
  var import_node_os9 = require("node:os");
47661
- var import_node_path19 = require("node:path");
48183
+ var import_node_path20 = require("node:path");
47662
48184
 
47663
48185
  // src/checkout-lock.ts
47664
48186
  var import_node_fs11 = require("node:fs");
47665
- var import_node_path18 = require("node:path");
48187
+ var import_node_path19 = require("node:path");
47666
48188
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
47667
48189
  async function withCheckoutLock(locksDir, slug, fn) {
47668
48190
  (0, import_node_fs11.mkdirSync)(locksDir, { recursive: true });
47669
- const target = (0, import_node_path18.join)(locksDir, `${slug}.lock`);
48191
+ const target = (0, import_node_path19.join)(locksDir, `${slug}.lock`);
47670
48192
  if (!(0, import_node_fs11.existsSync)(target)) (0, import_node_fs11.writeFileSync)(target, "");
47671
48193
  const release = await import_proper_lockfile.default.lock(target, {
47672
48194
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
@@ -47683,16 +48205,16 @@ async function withCheckoutLock(locksDir, slug, fn) {
47683
48205
  function worktreeBranch(runId) {
47684
48206
  return `mrrlin/run-${runId}`;
47685
48207
  }
47686
- 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 });
47687
48209
  function git(checkout, args) {
47688
- return (0, import_node_child_process12.execFileSync)("git", ["-C", checkout, ...args], {
48210
+ return (0, import_node_child_process14.execFileSync)("git", ["-C", checkout, ...args], {
47689
48211
  encoding: "utf8",
47690
48212
  timeout: 3e4,
47691
48213
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
47692
48214
  });
47693
48215
  }
47694
48216
  async function createRunWorktree(opts) {
47695
- 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);
47696
48218
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47697
48219
  (0, import_node_fs12.mkdirSync)(opts.worktreeRoot, { recursive: true });
47698
48220
  try {
@@ -47769,8 +48291,8 @@ async function doPushRunBranch(opts, execGit) {
47769
48291
  if (localConfig.trim()) {
47770
48292
  throw new Error(`push aborted: agent-controlled git config present in worktree: ${localConfig.trim().split("\n")[0]}`);
47771
48293
  }
47772
- const dir = (0, import_node_fs12.mkdtempSync)((0, import_node_path19.join)((0, import_node_os9.tmpdir)(), "mrrlin-push-"));
47773
- 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");
47774
48296
  try {
47775
48297
  (0, import_node_fs12.writeFileSync)(
47776
48298
  askpass,
@@ -47807,7 +48329,7 @@ async function sweepOrphanWorktrees(opts) {
47807
48329
  } catch {
47808
48330
  return opts.worktreeRoot;
47809
48331
  }
47810
- })() + import_node_path19.sep + opts.slug + import_node_path19.sep;
48332
+ })() + import_node_path20.sep + opts.slug + import_node_path20.sep;
47811
48333
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47812
48334
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"]);
47813
48335
  for (const block of listing.split("\n\n")) {
@@ -47970,13 +48492,13 @@ function effortDisabled(env = process.env) {
47970
48492
  // src/operator-token.ts
47971
48493
  var import_node_fs13 = require("node:fs");
47972
48494
  var import_node_os10 = __toESM(require("node:os"), 1);
47973
- var import_node_path20 = __toESM(require("node:path"), 1);
48495
+ var import_node_path21 = __toESM(require("node:path"), 1);
47974
48496
  function operatorDir() {
47975
- const base = process.env.CODEX_HOME ? import_node_path20.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path20.default.join(import_node_os10.default.homedir(), ".mrrlin");
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");
47976
48498
  return base;
47977
48499
  }
47978
48500
  function operatorTokenPath() {
47979
- return import_node_path20.default.join(operatorDir(), "operator-token");
48501
+ return import_node_path21.default.join(operatorDir(), "operator-token");
47980
48502
  }
47981
48503
  function readOperatorToken() {
47982
48504
  try {
@@ -47993,7 +48515,7 @@ function persistOperatorToken(token) {
47993
48515
  `, { encoding: "utf8", mode: 384 });
47994
48516
  }
47995
48517
  function agentCredentialPath() {
47996
- return import_node_path20.default.join(operatorDir(), "agent-credential");
48518
+ return import_node_path21.default.join(operatorDir(), "agent-credential");
47997
48519
  }
47998
48520
  function persistAgentSecret(secret) {
47999
48521
  const dir = operatorDir();
@@ -48453,24 +48975,24 @@ function isBridgeGeneratedArtifact(artifact) {
48453
48975
  return typeof payload === "object" && payload !== null && "event" in payload;
48454
48976
  }
48455
48977
  function newArtifactId() {
48456
- return `EA-${import_node_crypto7.default.randomUUID()}`;
48978
+ return `EA-${import_node_crypto8.default.randomUUID()}`;
48457
48979
  }
48458
48980
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
48459
48981
  function isBlastRadiusFloorPath(path25) {
48460
48982
  return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path25));
48461
48983
  }
48462
- 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);
48463
48985
  async function defaultListRunDiffPaths(opts) {
48464
48986
  const parse6 = (stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
48465
48987
  try {
48466
- const { stdout } = await execFileAsync(
48988
+ const { stdout } = await execFileAsync2(
48467
48989
  "git",
48468
48990
  ["-C", opts.worktreePath, "diff", "--name-only", `origin/${opts.defaultBranch}...HEAD`],
48469
48991
  { timeout: 3e4 }
48470
48992
  );
48471
48993
  return parse6(stdout);
48472
48994
  } catch {
48473
- const { stdout } = await execFileAsync(
48995
+ const { stdout } = await execFileAsync2(
48474
48996
  "git",
48475
48997
  ["-C", opts.worktreePath, "diff", "--name-only", `${opts.defaultBranch}...HEAD`],
48476
48998
  { timeout: 3e4 }
@@ -48695,7 +49217,7 @@ async function driveRun(deps, projectSlug, runId) {
48695
49217
  if (!claimed) return;
48696
49218
  if (!claimed.leaseId) {
48697
49219
  await deps.client.createInboxItem(projectSlug, {
48698
- id: `II-${import_node_crypto7.default.randomUUID()}`,
49220
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
48699
49221
  kind: "handoff",
48700
49222
  taskId: claimed.taskId,
48701
49223
  body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
@@ -49913,7 +50435,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
49913
50435
  }
49914
50436
  try {
49915
50437
  await deps.client.createInboxItem(projectSlug, {
49916
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50438
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49917
50439
  kind: "handoff",
49918
50440
  taskId: task.id,
49919
50441
  body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
@@ -49948,7 +50470,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
49948
50470
  }
49949
50471
  try {
49950
50472
  await deps.client.createInboxItem(projectSlug, {
49951
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50473
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49952
50474
  kind: "handoff",
49953
50475
  taskId: task.id,
49954
50476
  body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
@@ -50088,8 +50610,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
50088
50610
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
50089
50611
  if (!worktreeRoot) return true;
50090
50612
  if (!run3.worktreeId) return false;
50091
- const relative = import_node_path21.default.relative(import_node_path21.default.resolve(worktreeRoot), import_node_path21.default.resolve(run3.worktreeId));
50092
- return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path21.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);
50093
50615
  }
50094
50616
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
50095
50617
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -50107,7 +50629,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
50107
50629
  }).catch(() => {
50108
50630
  });
50109
50631
  await deps.client.createInboxItem(projectSlug, {
50110
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50632
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
50111
50633
  kind: "handoff",
50112
50634
  taskId: task.id,
50113
50635
  body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
@@ -50126,7 +50648,7 @@ function maxLeaseReclaims() {
50126
50648
  }
50127
50649
 
50128
50650
  // src/async-job-consumer.ts
50129
- var import_node_crypto9 = __toESM(require("node:crypto"), 1);
50651
+ var import_node_crypto10 = __toESM(require("node:crypto"), 1);
50130
50652
 
50131
50653
  // src/async-tools/registry.ts
50132
50654
  var registry2 = /* @__PURE__ */ new Map();
@@ -50139,8 +50661,8 @@ function getAsyncToolDescriptor(toolName) {
50139
50661
 
50140
50662
  // src/bridge-log.ts
50141
50663
  var import_node_fs14 = require("node:fs");
50142
- var import_promises7 = require("node:fs/promises");
50143
- var import_node_path22 = require("node:path");
50664
+ var import_promises9 = require("node:fs/promises");
50665
+ var import_node_path23 = require("node:path");
50144
50666
 
50145
50667
  // src/redact.ts
50146
50668
  var REDACTED = "[REDACTED]";
@@ -50165,7 +50687,7 @@ function redact(input) {
50165
50687
  }
50166
50688
 
50167
50689
  // src/telemetry/projector.ts
50168
- var import_node_crypto8 = require("node:crypto");
50690
+ var import_node_crypto9 = require("node:crypto");
50169
50691
  function isRecord3(x) {
50170
50692
  return typeof x === "object" && x !== null;
50171
50693
  }
@@ -50206,7 +50728,7 @@ function buildProjection(payload, type, ms, telemetry) {
50206
50728
  if (typeof exitCode === "number") proj.exitCode = exitCode;
50207
50729
  const status = tool.status;
50208
50730
  if (typeof status === "string" && status.trim() !== "") {
50209
- 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);
50210
50732
  }
50211
50733
  return proj;
50212
50734
  }
@@ -50416,14 +50938,14 @@ function resolvePromptsEnabled(env = process.env) {
50416
50938
  }
50417
50939
  function createBridgeLogger(stateDir, env = process.env) {
50418
50940
  if (!resolveBridgeLogEnabled(env)) return NOOP_LOGGER;
50419
- const logsDir = (0, import_node_path22.join)(stateDir, "logs");
50941
+ const logsDir = (0, import_node_path23.join)(stateDir, "logs");
50420
50942
  try {
50421
50943
  (0, import_node_fs14.mkdirSync)(logsDir, { recursive: true });
50422
50944
  } catch {
50423
50945
  return NOOP_LOGGER;
50424
50946
  }
50425
50947
  const includePrompts = resolvePromptsEnabled(env);
50426
- const fileFor = () => (0, import_node_path22.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`);
50427
50949
  const MAX_TRACKED_SESSIONS = 64;
50428
50950
  const contextSlugBySession = /* @__PURE__ */ new Map();
50429
50951
  const rememberContextSlug = (sessionId, payload) => {
@@ -50464,7 +50986,7 @@ function createBridgeLogger(stateDir, env = process.env) {
50464
50986
  return { isGap, isNewTurn };
50465
50987
  };
50466
50988
  const gainDay = (sessionId) => {
50467
- const sessionsPath = (0, import_node_path22.join)(logsDir, ".sessions.json");
50989
+ const sessionsPath = (0, import_node_path23.join)(logsDir, ".sessions.json");
50468
50990
  let sessionsObj = {};
50469
50991
  try {
50470
50992
  const parsed = JSON.parse((0, import_node_fs14.readFileSync)(sessionsPath, "utf8"));
@@ -50582,10 +51104,10 @@ function createBridgeLogger(stateDir, env = process.env) {
50582
51104
  };
50583
51105
  }
50584
51106
  async function findSessionDays(stateDir, sessionId) {
50585
- const sessionsPath = (0, import_node_path22.join)(stateDir, "logs", ".sessions.json");
51107
+ const sessionsPath = (0, import_node_path23.join)(stateDir, "logs", ".sessions.json");
50586
51108
  let sessionsObj;
50587
51109
  try {
50588
- const parsed = JSON.parse(await (0, import_promises7.readFile)(sessionsPath, "utf8"));
51110
+ const parsed = JSON.parse(await (0, import_promises9.readFile)(sessionsPath, "utf8"));
50589
51111
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return [];
50590
51112
  sessionsObj = parsed;
50591
51113
  } catch {
@@ -50714,7 +51236,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
50714
51236
  const delivery = descriptor2.onComplete(outcome, input);
50715
51237
  if (!delivery.suppressInbox) {
50716
51238
  await deps.client.createInboxItem(projectSlug, {
50717
- id: delivery.id ?? `II-${import_node_crypto9.default.randomUUID()}`,
51239
+ id: delivery.id ?? `II-${import_node_crypto10.default.randomUUID()}`,
50718
51240
  kind: delivery.kind,
50719
51241
  body: delivery.body,
50720
51242
  ...delivery.taskId ? { taskId: delivery.taskId } : {},
@@ -50732,13 +51254,13 @@ async function deriveRequestedHash(client, toolName, input) {
50732
51254
  if (input.requestedHash) return input.requestedHash;
50733
51255
  if (toolName === "run_spec_consensus" && input.pageId) {
50734
51256
  const page = await client.getWikiPage(input.projectSlug, input.pageId);
50735
- 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");
50736
51258
  }
50737
51259
  if (toolName === "draft_task_spec" && input.taskId) {
50738
51260
  const task = await client.getTask(input.projectSlug, input.taskId);
50739
- 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");
50740
51262
  }
50741
- 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");
50742
51264
  }
50743
51265
  async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
50744
51266
  const projects = await deps.client.listProjects();
@@ -50765,11 +51287,11 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
50765
51287
 
50766
51288
  // src/state-dir.ts
50767
51289
  var import_node_os11 = __toESM(require("node:os"), 1);
50768
- var import_node_path23 = __toESM(require("node:path"), 1);
51290
+ var import_node_path24 = __toESM(require("node:path"), 1);
50769
51291
  function resolveStateDir(env = process.env) {
50770
51292
  const codexHome = env.CODEX_HOME;
50771
- if (codexHome) return import_node_path23.default.join(codexHome, "mrrlin", "director-bridge");
50772
- return import_node_path23.default.join(import_node_os11.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");
50773
51295
  }
50774
51296
 
50775
51297
  // src/consensus/deliverable-gate.ts
@@ -51026,9 +51548,9 @@ function agentIdleMs(provider) {
51026
51548
 
51027
51549
  // src/thread-index.ts
51028
51550
  var import_node_fs15 = require("node:fs");
51029
- var import_node_path24 = __toESM(require("node:path"), 1);
51551
+ var import_node_path25 = __toESM(require("node:path"), 1);
51030
51552
  function threadIndexPath(stateDir) {
51031
- return import_node_path24.default.join(stateDir, "threads.json");
51553
+ return import_node_path25.default.join(stateDir, "threads.json");
51032
51554
  }
51033
51555
  function loadThreadIndex(stateDir, ttlMs, now) {
51034
51556
  const result = /* @__PURE__ */ new Map();
@@ -51193,10 +51715,10 @@ function createToolBusyClock(opts) {
51193
51715
  }
51194
51716
 
51195
51717
  // src/worker-token.ts
51196
- var import_node_crypto10 = require("node:crypto");
51718
+ var import_node_crypto11 = require("node:crypto");
51197
51719
  var import_node_fs16 = require("node:fs");
51198
51720
  var import_node_os12 = __toESM(require("node:os"), 1);
51199
- var import_node_path25 = __toESM(require("node:path"), 1);
51721
+ var import_node_path26 = __toESM(require("node:path"), 1);
51200
51722
  var DEFAULT_WORKER_PORT = 8792;
51201
51723
  function workerPort() {
51202
51724
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -51205,11 +51727,11 @@ function workerPort() {
51205
51727
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
51206
51728
  }
51207
51729
  function workerDir() {
51208
- 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");
51209
- 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");
51210
51732
  }
51211
51733
  function workerTokenPath() {
51212
- return import_node_path25.default.join(workerDir(), "token");
51734
+ return import_node_path26.default.join(workerDir(), "token");
51213
51735
  }
51214
51736
  function readWorkerToken() {
51215
51737
  try {
@@ -51224,17 +51746,17 @@ function readOrCreateWorkerToken() {
51224
51746
  if (existing) return existing;
51225
51747
  const dir = workerDir();
51226
51748
  (0, import_node_fs16.mkdirSync)(dir, { recursive: true, mode: 448 });
51227
- const token = (0, import_node_crypto10.randomBytes)(32).toString("hex");
51749
+ const token = (0, import_node_crypto11.randomBytes)(32).toString("hex");
51228
51750
  (0, import_node_fs16.writeFileSync)(workerTokenPath(), `${token}
51229
51751
  `, { encoding: "utf8", mode: 384 });
51230
51752
  return token;
51231
51753
  }
51232
51754
 
51233
51755
  // src/remote-phone-relay.ts
51234
- var import_node_events2 = require("node:events");
51756
+ var import_node_events3 = require("node:events");
51235
51757
  var import_node_fs17 = require("node:fs");
51236
51758
  var import_node_os13 = require("node:os");
51237
- var import_node_path26 = require("node:path");
51759
+ var import_node_path27 = require("node:path");
51238
51760
 
51239
51761
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
51240
51762
  var nc = __toESM(require("node:crypto"), 1);
@@ -54260,9 +54782,9 @@ var RelayClient = class {
54260
54782
  this.socket = null;
54261
54783
  this.nextHeartbeatAt = Number.POSITIVE_INFINITY;
54262
54784
  if (this.stopped || this.register === null) return;
54263
- 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;
54264
54786
  this.backoffIndex += 1;
54265
- this.reconnectAt = this.deps.now() + delay;
54787
+ this.reconnectAt = this.deps.now() + delay2;
54266
54788
  }
54267
54789
  onMessage(data) {
54268
54790
  let frame;
@@ -54805,7 +55327,7 @@ var DirectorRelay = class {
54805
55327
 
54806
55328
  // src/remote-phone-relay.ts
54807
55329
  function loadOrCreateAgentDeviceKey() {
54808
- 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");
54809
55331
  try {
54810
55332
  const raw = JSON.parse((0, import_node_fs17.readFileSync)(path25, "utf8"));
54811
55333
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
@@ -54815,7 +55337,7 @@ function loadOrCreateAgentDeviceKey() {
54815
55337
  }
54816
55338
  const kp = generateIdentityKeyPair();
54817
55339
  try {
54818
- (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 });
54819
55341
  (0, import_node_fs17.writeFileSync)(
54820
55342
  path25,
54821
55343
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
@@ -54825,7 +55347,7 @@ function loadOrCreateAgentDeviceKey() {
54825
55347
  }
54826
55348
  return kp;
54827
55349
  }
54828
- 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");
54829
55351
  function loadAgentPairing() {
54830
55352
  try {
54831
55353
  const raw = JSON.parse((0, import_node_fs17.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
@@ -54843,14 +55365,14 @@ function loadAgentPairing() {
54843
55365
  }
54844
55366
  function saveAgentPairing(record2) {
54845
55367
  try {
54846
- (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 });
54847
55369
  (0, import_node_fs17.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
54848
55370
  } catch {
54849
55371
  }
54850
55372
  }
54851
55373
  function runPhoneTurn(handler, directorSessionId, text, emit) {
54852
55374
  return new Promise((resolve) => {
54853
- const emitter = new import_node_events2.EventEmitter();
55375
+ const emitter = new import_node_events3.EventEmitter();
54854
55376
  const fakeSocket = {
54855
55377
  on: (event, cb) => {
54856
55378
  emitter.on(event, cb);
@@ -55023,11 +55545,11 @@ async function renderPairingQrSvg(payload) {
55023
55545
 
55024
55546
  // src/checkout-registry.ts
55025
55547
  var import_node_fs18 = require("node:fs");
55026
- var import_node_path27 = require("node:path");
55548
+ var import_node_path28 = require("node:path");
55027
55549
  var CheckoutRegistry = class {
55028
55550
  file;
55029
55551
  constructor(stateDir) {
55030
- this.file = (0, import_node_path27.join)(stateDir, "checkouts.json");
55552
+ this.file = (0, import_node_path28.join)(stateDir, "checkouts.json");
55031
55553
  (0, import_node_fs18.mkdirSync)(stateDir, { recursive: true });
55032
55554
  }
55033
55555
  read() {
@@ -55084,7 +55606,7 @@ var CheckoutRegistry = class {
55084
55606
  };
55085
55607
 
55086
55608
  // src/checkout-handlers.ts
55087
- var import_node_child_process14 = require("node:child_process");
55609
+ var import_node_child_process16 = require("node:child_process");
55088
55610
  var import_node_fs19 = require("node:fs");
55089
55611
 
55090
55612
  // src/git-remote-match.ts
@@ -55130,7 +55652,7 @@ function validateCheckoutPath(checkoutPath, repo) {
55130
55652
  }
55131
55653
  let remoteUrl;
55132
55654
  try {
55133
- 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"], {
55134
55656
  encoding: "utf8",
55135
55657
  stdio: ["ignore", "pipe", "ignore"],
55136
55658
  timeout: 15e3,
@@ -55181,11 +55703,11 @@ function checkoutStateData(projectSlug, entry, machineLabel) {
55181
55703
  }
55182
55704
 
55183
55705
  // src/executor-server.ts
55184
- var import_node_child_process15 = require("node:child_process");
55706
+ var import_node_child_process17 = require("node:child_process");
55185
55707
  function defaultReadinessRunner(provider) {
55186
55708
  const command = provider === "claude" ? "claude" : "codex";
55187
55709
  return (args) => {
55188
- 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 });
55189
55711
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
55190
55712
  };
55191
55713
  }
@@ -55428,7 +55950,7 @@ function extractVerificationSection(markdown) {
55428
55950
  // src/director-reseed.ts
55429
55951
  var import_node_fs20 = require("node:fs");
55430
55952
  var import_node_readline = require("node:readline");
55431
- var import_node_path28 = require("node:path");
55953
+ var import_node_path29 = require("node:path");
55432
55954
  function estimateTokens(s) {
55433
55955
  return Buffer.byteLength(s, "utf8");
55434
55956
  }
@@ -55560,7 +56082,7 @@ async function readSessionRows(logsDir, files, sessionIds) {
55560
56082
  const lines2 = [];
55561
56083
  let missingFiles = 0;
55562
56084
  for (const f of files) {
55563
- const filePath = (0, import_node_path28.join)(logsDir, f);
56085
+ const filePath = (0, import_node_path29.join)(logsDir, f);
55564
56086
  try {
55565
56087
  const stream = (0, import_node_fs20.createReadStream)(filePath, { encoding: "utf8" });
55566
56088
  const rl = (0, import_node_readline.createInterface)({ input: stream, crlfDelay: Infinity });
@@ -55588,10 +56110,10 @@ async function readSessionRows(logsDir, files, sessionIds) {
55588
56110
  // src/external-agents-scrub.ts
55589
56111
  var import_node_fs21 = __toESM(require("node:fs"), 1);
55590
56112
  var import_node_os14 = __toESM(require("node:os"), 1);
55591
- var import_node_path29 = __toESM(require("node:path"), 1);
56113
+ var import_node_path30 = __toESM(require("node:path"), 1);
55592
56114
  var REDACTION = "[REDACTED]";
55593
56115
  var SHORT_VALUE_THRESHOLD = 8;
55594
- 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");
55595
56117
  var keysEnvCache = null;
55596
56118
  function readKeysEnv() {
55597
56119
  const filePath = KEYS_ENV_PATH();
@@ -56035,9 +56557,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
56035
56557
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
56036
56558
  }
56037
56559
  function readCodexFallbackModels() {
56038
- 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");
56039
56561
  const models = /* @__PURE__ */ new Map();
56040
- const cachePath = import_node_path30.default.join(codexHome, "models_cache.json");
56562
+ const cachePath = import_node_path31.default.join(codexHome, "models_cache.json");
56041
56563
  const cacheRaw = readTextIfExists(cachePath);
56042
56564
  if (cacheRaw) {
56043
56565
  try {
@@ -56087,7 +56609,7 @@ function readCodexFallbackModels() {
56087
56609
  );
56088
56610
  }
56089
56611
  }
56090
- 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"))) {
56091
56613
  addBridgeModel(
56092
56614
  models,
56093
56615
  mapBridgeModel({
@@ -56101,11 +56623,11 @@ function readCodexFallbackModels() {
56101
56623
  })
56102
56624
  );
56103
56625
  }
56104
- const automationsDir = import_node_path30.default.join(codexHome, "automations");
56626
+ const automationsDir = import_node_path31.default.join(codexHome, "automations");
56105
56627
  try {
56106
56628
  for (const entry of import_node_fs22.default.readdirSync(automationsDir, { withFileTypes: true })) {
56107
56629
  if (!entry.isDirectory()) continue;
56108
- 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"))) {
56109
56631
  addBridgeModel(
56110
56632
  models,
56111
56633
  mapBridgeModel({
@@ -56125,13 +56647,13 @@ function readCodexFallbackModels() {
56125
56647
  return [...models.values()];
56126
56648
  }
56127
56649
  function selfUpdateInboxItemId(offeredVersion) {
56128
- if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto11.randomUUID)()}`;
56650
+ if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto12.randomUUID)()}`;
56129
56651
  if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
56130
- 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);
56131
56653
  return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
56132
56654
  }
56133
56655
  function neutralCheckoutCwd(stateDir) {
56134
- const dir = import_node_path30.default.join(stateDir, "no-checkout");
56656
+ const dir = import_node_path31.default.join(stateDir, "no-checkout");
56135
56657
  try {
56136
56658
  import_node_fs22.default.mkdirSync(dir, { recursive: true });
56137
56659
  } catch {
@@ -56607,7 +57129,7 @@ function resolveDefaultBranch(checkoutPath) {
56607
57129
  if (!checkoutPath) return "main";
56608
57130
  const runGit = (args) => {
56609
57131
  try {
56610
- return (0, import_node_child_process16.execFileSync)("git", ["-C", checkoutPath, ...args], {
57132
+ return (0, import_node_child_process18.execFileSync)("git", ["-C", checkoutPath, ...args], {
56611
57133
  encoding: "utf8",
56612
57134
  stdio: ["ignore", "pipe", "ignore"],
56613
57135
  timeout: 15e3,
@@ -56757,7 +57279,7 @@ function createBridgeRequestListener(opts) {
56757
57279
  res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
56758
57280
  return;
56759
57281
  }
56760
- const nonce = import_node_crypto11.default.randomBytes(16).toString("base64url");
57282
+ const nonce = import_node_crypto12.default.randomBytes(16).toString("base64url");
56761
57283
  res.writeHead(200, { "content-type": "application/json" });
56762
57284
  res.end(JSON.stringify({ ok: true, wsUrl: `ws://${host}:${port}/ws`, token, nonce }));
56763
57285
  return;
@@ -57057,7 +57579,7 @@ function createBridgeMessageHandler(deps) {
57057
57579
  }
57058
57580
  }
57059
57581
  socket.on("message", async (data) => {
57060
- const spanId = import_node_crypto11.default.randomUUID();
57582
+ const spanId = import_node_crypto12.default.randomUUID();
57061
57583
  if (logCtx) {
57062
57584
  logCtx.span.id = spanId;
57063
57585
  logCtx.span.at = Date.now();
@@ -57376,7 +57898,15 @@ function createBridgeMessageHandler(deps) {
57376
57898
  const bootstrapProvider = resolveProvider(process.env, getSelectedProvider());
57377
57899
  bootstrapProviderId = bootstrapProvider.id;
57378
57900
  const bootstrapCapabilities = bootstrapProvider.capabilities();
57379
- 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;
57380
57910
  if (!bootstrapCapabilities.listsModels) {
57381
57911
  const staticModels = /* @__PURE__ */ new Map();
57382
57912
  for (const entry of bootstrapCapabilities.modelCatalog) {
@@ -57676,7 +58206,7 @@ function createBridgeMessageHandler(deps) {
57676
58206
  thread.inFlight = true;
57677
58207
  pendingTurnSessions.delete(directorSessionId);
57678
58208
  thread.replay = createReplayBuffer({
57679
- turnId: (0, import_node_crypto11.randomUUID)(),
58209
+ turnId: (0, import_node_crypto12.randomUUID)(),
57680
58210
  spanId,
57681
58211
  ...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
57682
58212
  ...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
@@ -58079,7 +58609,7 @@ function parseConfig() {
58079
58609
  }
58080
58610
  function scanForOtherBridges() {
58081
58611
  try {
58082
- 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"], {
58083
58613
  encoding: "utf8"
58084
58614
  });
58085
58615
  if (result.status !== 0) return [];
@@ -58255,8 +58785,8 @@ async function startDirectorBridge() {
58255
58785
  codexCwd: config2.codexCwd,
58256
58786
  codexExecutable: config2.codexExecutable,
58257
58787
  checkoutRegistry,
58258
- worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58259
- 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"),
58260
58790
  // Wire the executor server for code-execution runs. Each run gets its own provider process
58261
58791
  // (app-server for codex, a resident CLI child for claude) at the run worktree, running
58262
58792
  // UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
@@ -58300,7 +58830,7 @@ async function startDirectorBridge() {
58300
58830
  // egressDomains is retained in the seam signature (verification-turn.ts still computes the
58301
58831
  // env host) but no longer constrains anything — the executor is unrestricted.
58302
58832
  startSandbox: async (_egressDomains, providerId) => {
58303
- 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-"));
58304
58834
  let executor;
58305
58835
  try {
58306
58836
  executor = await startExecutorServer({ worktree: cwd, provider: providerId });
@@ -58350,7 +58880,7 @@ async function startDirectorBridge() {
58350
58880
  };
58351
58881
  const sessionSinks = createSessionSinkRegistry();
58352
58882
  const tombstones = /* @__PURE__ */ new Map();
58353
- const bridgeInstanceId = (0, import_node_crypto11.randomUUID)();
58883
+ const bridgeInstanceId = (0, import_node_crypto12.randomUUID)();
58354
58884
  const asyncConsumerDeps = {
58355
58885
  client,
58356
58886
  run: wrappedTurnLock.run,
@@ -58528,7 +59058,7 @@ async function startDirectorBridge() {
58528
59058
  }
58529
59059
  const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
58530
59060
  const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
58531
- 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);
58532
59062
  const { items, skipped: skipped2 } = extractItems(lines2, sessionIds);
58533
59063
  if (items.length === 0) return refuse2("no-rows");
58534
59064
  const budget = Math.max(0, Math.min(config2.reseedMaxTokens, config2.turnMaxTokens - args.otherBytes));
@@ -58635,7 +59165,7 @@ async function startDirectorBridge() {
58635
59165
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
58636
59166
  let bridgeBinShaShort = "unknown00000";
58637
59167
  try {
58638
- 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);
58639
59169
  } catch {
58640
59170
  }
58641
59171
  attachBridgeWss(server, {
@@ -58771,8 +59301,8 @@ async function startDirectorBridge() {
58771
59301
  );
58772
59302
  void runOrphanWorktreeSweep(client, {
58773
59303
  checkoutRegistry,
58774
- worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58775
- 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")
58776
59306
  });
58777
59307
  {
58778
59308
  const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
@@ -59075,7 +59605,7 @@ function timingSafeTokenEqual(provided, expected) {
59075
59605
  const a = Buffer.from(provided);
59076
59606
  const b = Buffer.from(expected);
59077
59607
  if (a.length !== b.length) return false;
59078
- return import_node_crypto11.default.timingSafeEqual(a, b);
59608
+ return import_node_crypto12.default.timingSafeEqual(a, b);
59079
59609
  }
59080
59610
  function readDispatchBody(req) {
59081
59611
  return new Promise((resolve, reject) => {
@@ -59097,14 +59627,14 @@ function readDispatchBody(req) {
59097
59627
  function readOrCreateBridgeToken(stateDir) {
59098
59628
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
59099
59629
  if (explicit) return explicit;
59100
- const tokenPath = import_node_path30.default.join(stateDir, "token.txt");
59630
+ const tokenPath = import_node_path31.default.join(stateDir, "token.txt");
59101
59631
  try {
59102
59632
  const existing = import_node_fs22.default.readFileSync(tokenPath, "utf8").trim();
59103
59633
  if (existing) return existing;
59104
59634
  } catch {
59105
59635
  }
59106
59636
  import_node_fs22.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
59107
- const token = import_node_crypto11.default.randomBytes(32).toString("base64url");
59637
+ const token = import_node_crypto12.default.randomBytes(32).toString("base64url");
59108
59638
  import_node_fs22.default.writeFileSync(tokenPath, `${token}
59109
59639
  `, { mode: 384 });
59110
59640
  return token;
@@ -62494,36 +63024,36 @@ var StdioServerTransport = class {
62494
63024
  };
62495
63025
 
62496
63026
  // src/tools.ts
62497
- var import_node_crypto14 = require("node:crypto");
62498
- var import_promises10 = require("node:fs/promises");
62499
- 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);
62500
63030
  var import_node_os16 = __toESM(require("node:os"), 1);
62501
63031
 
62502
63032
  // ../../packages/wiki/dist/index.js
62503
- var import_promises8 = __toESM(require("node:fs/promises"), 1);
62504
- 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);
62505
63035
  var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
62506
63036
  function toPosixPath(input) {
62507
- return input.split(import_node_path31.default.sep).join("/");
63037
+ return input.split(import_node_path32.default.sep).join("/");
62508
63038
  }
62509
63039
  function slugifyWikiSegment(input) {
62510
63040
  return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
62511
63041
  }
62512
63042
  async function pathExists3(input) {
62513
63043
  try {
62514
- await import_promises8.default.access(input);
63044
+ await import_promises10.default.access(input);
62515
63045
  return true;
62516
63046
  } catch {
62517
63047
  return false;
62518
63048
  }
62519
63049
  }
62520
63050
  async function findWorkspaceRoot(start = process.cwd()) {
62521
- let current2 = import_node_path31.default.resolve(start);
63051
+ let current2 = import_node_path32.default.resolve(start);
62522
63052
  while (true) {
62523
- 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"))) {
62524
63054
  return current2;
62525
63055
  }
62526
- const parent = import_node_path31.default.dirname(current2);
63056
+ const parent = import_node_path32.default.dirname(current2);
62527
63057
  if (parent === current2) {
62528
63058
  throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
62529
63059
  }
@@ -62532,28 +63062,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
62532
63062
  }
62533
63063
  async function resolveDocsRoot(input) {
62534
63064
  if (input) {
62535
- return import_node_path31.default.resolve(input);
63065
+ return import_node_path32.default.resolve(input);
62536
63066
  }
62537
63067
  if (process.env.MRRLIN_DOCS_ROOT) {
62538
- return import_node_path31.default.resolve(process.env.MRRLIN_DOCS_ROOT);
63068
+ return import_node_path32.default.resolve(process.env.MRRLIN_DOCS_ROOT);
62539
63069
  }
62540
- return import_node_path31.default.join(await findWorkspaceRoot(), "docs");
63070
+ return import_node_path32.default.join(await findWorkspaceRoot(), "docs");
62541
63071
  }
62542
63072
  async function resolveIndexPath(input) {
62543
63073
  if (input) {
62544
- return import_node_path31.default.resolve(input);
63074
+ return import_node_path32.default.resolve(input);
62545
63075
  }
62546
63076
  if (process.env.MRRLIN_WIKI_INDEX_PATH) {
62547
- 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);
62548
63078
  }
62549
63079
  const workspaceRoot = await findWorkspaceRoot();
62550
- 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");
62551
63081
  }
62552
63082
  async function walkMarkdownFiles(root, dir = root) {
62553
- const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
63083
+ const entries = await import_promises10.default.readdir(dir, { withFileTypes: true });
62554
63084
  const files = [];
62555
63085
  for (const entry of entries) {
62556
- const absolute = import_node_path31.default.join(dir, entry.name);
63086
+ const absolute = import_node_path32.default.join(dir, entry.name);
62557
63087
  if (entry.isDirectory()) {
62558
63088
  files.push(...await walkMarkdownFiles(root, absolute));
62559
63089
  continue;
@@ -62572,7 +63102,7 @@ function parseTitle(markdown, sourcePath) {
62572
63102
  return title;
62573
63103
  }
62574
63104
  function documentFromFile(docsRoot, absolutePath, markdown) {
62575
- const relativePath = toPosixPath(import_node_path31.default.relative(docsRoot, absolutePath));
63105
+ const relativePath = toPosixPath(import_node_path32.default.relative(docsRoot, absolutePath));
62576
63106
  const [section, fileName] = relativePath.split("/");
62577
63107
  if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
62578
63108
  return null;
@@ -62592,7 +63122,7 @@ async function listWikiDocuments(options = {}) {
62592
63122
  const files = await walkMarkdownFiles(docsRoot);
62593
63123
  const documents = [];
62594
63124
  for (const file2 of files) {
62595
- const markdown = await import_promises8.default.readFile(file2, "utf8");
63125
+ const markdown = await import_promises10.default.readFile(file2, "utf8");
62596
63126
  const document2 = documentFromFile(docsRoot, file2, markdown);
62597
63127
  if (document2) {
62598
63128
  documents.push(document2);
@@ -62646,7 +63176,7 @@ async function buildWikiKnowledgeIndex(options = {}) {
62646
63176
  }
62647
63177
  async function loadBuiltWikiKnowledgeIndex(indexPath) {
62648
63178
  const resolvedIndexPath = await resolveIndexPath(indexPath);
62649
- const raw = await import_promises8.default.readFile(resolvedIndexPath, "utf8");
63179
+ const raw = await import_promises10.default.readFile(resolvedIndexPath, "utf8");
62650
63180
  return wikiKnowledgeIndexSchema.parse(JSON.parse(raw));
62651
63181
  }
62652
63182
  function tokenize(input) {
@@ -62770,15 +63300,15 @@ async function runCodeGate(_target, deps) {
62770
63300
  }
62771
63301
 
62772
63302
  // src/consensus/multi-llm-head.ts
62773
- var import_node_child_process18 = require("node:child_process");
63303
+ var import_node_child_process20 = require("node:child_process");
62774
63304
 
62775
63305
  // src/consensus/provider-limits.ts
62776
- var import_node_child_process17 = require("node:child_process");
63306
+ var import_node_child_process19 = require("node:child_process");
62777
63307
  var DEFAULT_STATUS_TIMEOUT_MS = 1e4;
62778
63308
  function errMessage4(err) {
62779
63309
  return err instanceof Error ? err.message : String(err);
62780
63310
  }
62781
- function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
63311
+ function runExternalAgentsStatus(bin, args, timeoutMs, spawn5) {
62782
63312
  return new Promise((resolve) => {
62783
63313
  let settled = false;
62784
63314
  const timerRef = { id: void 0 };
@@ -62791,7 +63321,7 @@ function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
62791
63321
  const options = { stdio: ["ignore", "pipe", "pipe"], env: process.env, shell: false };
62792
63322
  let child;
62793
63323
  try {
62794
- child = spawn4(bin, args, options);
63324
+ child = spawn5(bin, args, options);
62795
63325
  } catch (err) {
62796
63326
  finish({ stdout: "", error: `spawn ${bin} failed: ${errMessage4(err)}` });
62797
63327
  return;
@@ -62815,13 +63345,13 @@ function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
62815
63345
  });
62816
63346
  }
62817
63347
  async function fetchRegistrySnapshot(deps) {
62818
- const spawn4 = deps?.spawn ?? import_node_child_process17.spawn;
63348
+ const spawn5 = deps?.spawn ?? import_node_child_process19.spawn;
62819
63349
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62820
63350
  const { stdout, error: error51 } = await runExternalAgentsStatus(
62821
63351
  command,
62822
63352
  [...prefixArgs, "status", "--json"],
62823
63353
  deps?.statusTimeoutMs ?? DEFAULT_STATUS_TIMEOUT_MS,
62824
- spawn4
63354
+ spawn5
62825
63355
  );
62826
63356
  if (error51) return { ok: false, error: error51 };
62827
63357
  try {
@@ -62865,7 +63395,7 @@ function estimateTokenCount(text) {
62865
63395
  function errMessage5(err) {
62866
63396
  return err instanceof Error ? err.message : String(err);
62867
63397
  }
62868
- function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
63398
+ function runExternalAgents(bin, args, label, timeoutMs, spawn5) {
62869
63399
  return new Promise((resolve) => {
62870
63400
  let settled = false;
62871
63401
  const timerRef = { id: void 0 };
@@ -62883,7 +63413,7 @@ function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
62883
63413
  };
62884
63414
  let child;
62885
63415
  try {
62886
- child = spawn4(bin, args, options);
63416
+ child = spawn5(bin, args, options);
62887
63417
  } catch (err) {
62888
63418
  finish({ code: null, stdout: "", error: `spawn ${bin} failed: ${errMessage5(err)}` });
62889
63419
  return;
@@ -62903,7 +63433,7 @@ function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
62903
63433
  });
62904
63434
  }
62905
63435
  async function pickPanel(input, deps) {
62906
- const spawn4 = deps?.spawn ?? import_node_child_process18.spawn;
63436
+ const spawn5 = deps?.spawn ?? import_node_child_process20.spawn;
62907
63437
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62908
63438
  const args = [
62909
63439
  "pick",
@@ -62916,7 +63446,7 @@ async function pickPanel(input, deps) {
62916
63446
  "--exclude-providers",
62917
63447
  input.excludeProvider
62918
63448
  ];
62919
- const r = await runExternalAgents(command, [...prefixArgs, ...args], "pick", input.timeoutMs, spawn4);
63449
+ const r = await runExternalAgents(command, [...prefixArgs, ...args], "pick", input.timeoutMs, spawn5);
62920
63450
  if (r.error) return { ok: false, error: r.error };
62921
63451
  if (r.code === 3) return { ok: true, agents: [] };
62922
63452
  if (r.code !== 0) return { ok: false, error: `external-agents pick exited ${r.code}` };
@@ -62950,10 +63480,10 @@ function parseDispatch(agentId, stdout, exitCode) {
62950
63480
  return { ok: true, text: parsed.text, usage };
62951
63481
  }
62952
63482
  async function dispatchHead(agentId, prompt, timeoutMs, deps) {
62953
- const spawn4 = deps?.spawn ?? import_node_child_process18.spawn;
63483
+ const spawn5 = deps?.spawn ?? import_node_child_process20.spawn;
62954
63484
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62955
63485
  const args = ["dispatch", agentId, "--json", prompt];
62956
- const r = await runExternalAgents(command, [...prefixArgs, ...args], "dispatch", timeoutMs, spawn4);
63486
+ const r = await runExternalAgents(command, [...prefixArgs, ...args], "dispatch", timeoutMs, spawn5);
62957
63487
  if (r.error) return { ok: false, error: r.error };
62958
63488
  return parseDispatch(agentId, r.stdout, r.code);
62959
63489
  }
@@ -65095,13 +65625,13 @@ var StreamableHTTPClientTransport = class {
65095
65625
  this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
65096
65626
  return;
65097
65627
  }
65098
- const delay = this._getNextReconnectionDelay(attemptCount);
65628
+ const delay2 = this._getNextReconnectionDelay(attemptCount);
65099
65629
  this._reconnectionTimeout = setTimeout(() => {
65100
65630
  this._startOrAuthSse(options).catch((error51) => {
65101
65631
  this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error51 instanceof Error ? error51.message : String(error51)}`));
65102
65632
  this._scheduleReconnection(options, attemptCount + 1);
65103
65633
  });
65104
- }, delay);
65634
+ }, delay2);
65105
65635
  }
65106
65636
  _handleSseStream(stream, options, isReconnectable) {
65107
65637
  if (!stream) {
@@ -65937,7 +66467,7 @@ async function runDecisionConsensus(input, deps) {
65937
66467
  }
65938
66468
 
65939
66469
  // src/async-tools/consensus.ts
65940
- var import_node_crypto12 = require("node:crypto");
66470
+ var import_node_crypto13 = require("node:crypto");
65941
66471
 
65942
66472
  // src/consensus/question-similarity.ts
65943
66473
  var SUPPRESSION_SIMILARITY_THRESHOLD = 0.6;
@@ -66217,9 +66747,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66217
66747
  }
66218
66748
  if (taskId) {
66219
66749
  const scopeId = taskId;
66220
- 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;
66221
66751
  for (const clarification of toFile) {
66222
- 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)}`;
66223
66753
  try {
66224
66754
  const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
66225
66755
  await ctx.client.createInboxItem(input.projectSlug, {
@@ -66237,9 +66767,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66237
66767
  filedQuestionCount = toFile.length;
66238
66768
  } else if (planId) {
66239
66769
  const scopeId = planId;
66240
- 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;
66241
66771
  for (const clarification of toFile) {
66242
- 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)}`;
66243
66773
  try {
66244
66774
  const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
66245
66775
  await ctx.client.createInboxItem(input.projectSlug, {
@@ -66263,7 +66793,7 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66263
66793
  taskId: page.taskId ?? null
66264
66794
  });
66265
66795
  const reviewHash = domainScopedReviewHash2(page.contentHash, domain2);
66266
- 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)}`;
66267
66797
  const reviewAgainAvailable = !taskInboxItems.some(
66268
66798
  (item) => item.id === baseBlockItemId && item.status !== "pending" && item.answer === REVIEW_AGAIN_ANSWER
66269
66799
  );
@@ -66837,8 +67367,8 @@ function createIntentCheckDescriptor() {
66837
67367
  var intentCheckDescriptor = createIntentCheckDescriptor();
66838
67368
 
66839
67369
  // src/evidence/assembler.ts
66840
- var import_promises9 = require("node:fs/promises");
66841
- var import_node_path32 = require("node:path");
67370
+ var import_promises11 = require("node:fs/promises");
67371
+ var import_node_path33 = require("node:path");
66842
67372
  function evidenceDedupKey(sessionId, reportId) {
66843
67373
  return `${sessionId}:${reportId}`;
66844
67374
  }
@@ -66848,7 +67378,7 @@ function isRecord7(v) {
66848
67378
  async function readDayLines(stateDir, day, sessionId) {
66849
67379
  let raw;
66850
67380
  try {
66851
- 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");
66852
67382
  } catch {
66853
67383
  return [];
66854
67384
  }
@@ -66922,7 +67452,7 @@ async function assembleEvidence(stateDir, sessionId, reportId, gateCtx) {
66922
67452
  }
66923
67453
  let windowPruned = false;
66924
67454
  try {
66925
- 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");
66926
67456
  outer: for (const line of raw.split("\n")) {
66927
67457
  if (!line.trim()) continue;
66928
67458
  let rec;
@@ -66988,7 +67518,7 @@ function createReportEvidenceDescriptor() {
66988
67518
  var reportEvidenceDescriptor = createReportEvidenceDescriptor();
66989
67519
 
66990
67520
  // src/async-tools/enqueue.ts
66991
- var import_node_crypto13 = __toESM(require("node:crypto"), 1);
67521
+ var import_node_crypto14 = __toESM(require("node:crypto"), 1);
66992
67522
  async function enqueueAsyncTool(client, descriptor2, input) {
66993
67523
  if (descriptor2.cachedResult) {
66994
67524
  const cached2 = await descriptor2.cachedResult(client, input);
@@ -67001,7 +67531,7 @@ async function enqueueAsyncTool(client, descriptor2, input) {
67001
67531
  if (active) {
67002
67532
  return { status: "already_running", jobId: active.id, message: "Already running; will notify in inbox." };
67003
67533
  }
67004
- const jobId = `AJ-${import_node_crypto13.default.randomUUID()}`;
67534
+ const jobId = `AJ-${import_node_crypto14.default.randomUUID()}`;
67005
67535
  try {
67006
67536
  await client.createAsyncJob(input.projectSlug, {
67007
67537
  id: jobId,
@@ -68661,7 +69191,7 @@ function createMrrlinTools(options) {
68661
69191
  "PRODUCED_URL_RECORD_FAILED",
68662
69192
  "Unable to record produced URL.",
68663
69193
  async (c, { projectSlug, runId, url: url2, label }) => {
68664
- 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")}`;
68665
69195
  const payload = label ? { url: url2, label } : { url: url2 };
68666
69196
  return await c.appendExecutionArtifact(projectSlug, runId, {
68667
69197
  id,
@@ -68735,7 +69265,7 @@ function createMrrlinTools(options) {
68735
69265
  "ARTIFACT_FILE_UPLOAD_FAILED",
68736
69266
  "Unable to upload artifact file.",
68737
69267
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
68738
- const extension2 = import_node_path33.default.extname(filePath).toLowerCase();
69268
+ const extension2 = import_node_path34.default.extname(filePath).toLowerCase();
68739
69269
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68740
69270
  if (!contentType) {
68741
69271
  throw new McpToolCodedError(
@@ -68743,7 +69273,7 @@ function createMrrlinTools(options) {
68743
69273
  `Unsupported artifact extension '${extension2}'. Allowed: ${Object.keys(ARTIFACT_EXTENSION_TYPES).join(", ")}.`
68744
69274
  );
68745
69275
  }
68746
- const stats = await (0, import_promises10.stat)(filePath);
69276
+ const stats = await (0, import_promises12.stat)(filePath);
68747
69277
  if (stats.size > MRRLIN_ARTIFACT_FILE_MAX_BYTES) {
68748
69278
  throw new McpToolCodedError(
68749
69279
  "ARTIFACT_FILE_TOO_LARGE",
@@ -68756,14 +69286,14 @@ function createMrrlinTools(options) {
68756
69286
  "File is empty (0 bytes); write content before uploading."
68757
69287
  );
68758
69288
  }
68759
- const bytes3 = new Uint8Array(await (0, import_promises10.readFile)(filePath));
69289
+ const bytes3 = new Uint8Array(await (0, import_promises12.readFile)(filePath));
68760
69290
  if (bytes3.byteLength > MRRLIN_ARTIFACT_FILE_MAX_BYTES) {
68761
69291
  throw new McpToolCodedError(
68762
69292
  "ARTIFACT_FILE_TOO_LARGE",
68763
69293
  "Artifact exceeds 5MB; split or summarize instead."
68764
69294
  );
68765
69295
  }
68766
- const filename = import_node_path33.default.basename(filePath);
69296
+ const filename = import_node_path34.default.basename(filePath);
68767
69297
  return deliverBuiltIn(
68768
69298
  c,
68769
69299
  projectSlug,
@@ -68785,7 +69315,7 @@ function createMrrlinTools(options) {
68785
69315
  `Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
68786
69316
  );
68787
69317
  }
68788
- const extension2 = import_node_path33.default.extname(filename).toLowerCase();
69318
+ const extension2 = import_node_path34.default.extname(filename).toLowerCase();
68789
69319
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68790
69320
  if (!contentType) {
68791
69321
  throw new McpToolCodedError(
@@ -69096,7 +69626,7 @@ function runSetCredential(args) {
69096
69626
  // src/install-service.ts
69097
69627
  var import_node_os17 = __toESM(require("node:os"), 1);
69098
69628
  var import_node_fs23 = require("node:fs");
69099
- var import_node_path34 = __toESM(require("node:path"), 1);
69629
+ var import_node_path35 = __toESM(require("node:path"), 1);
69100
69630
  function readExistingTelemetryDefaultProject(deps, ecoPath) {
69101
69631
  try {
69102
69632
  const existing = deps.readFile?.(ecoPath);
@@ -69217,9 +69747,9 @@ function installService(deps) {
69217
69747
  const claudeBin = deps.which("claude");
69218
69748
  const resolvedBins = [...bins, claudeBin].filter((b) => b !== null);
69219
69749
  const pathEnv = Array.from(
69220
- /* @__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])
69221
69751
  ).join(":");
69222
- 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");
69223
69753
  const apiTarget = deriveServiceApiTarget(deps, ecoPath);
69224
69754
  const telemetryDefaultProject = "MRRLIN_TELEMETRY_DEFAULT_PROJECT" in deps.env ? deps.env.MRRLIN_TELEMETRY_DEFAULT_PROJECT?.trim() || void 0 : readExistingTelemetryDefaultProject(deps, ecoPath);
69225
69755
  const text = renderEcosystemConfig({
@@ -69283,18 +69813,18 @@ function uninstallService(deps) {
69283
69813
  }
69284
69814
 
69285
69815
  // src/uninstall-codex.ts
69286
- var import_promises11 = __toESM(require("node:fs/promises"), 1);
69816
+ var import_promises13 = __toESM(require("node:fs/promises"), 1);
69287
69817
  var import_node_os18 = __toESM(require("node:os"), 1);
69288
- var import_node_path35 = __toESM(require("node:path"), 1);
69818
+ var import_node_path36 = __toESM(require("node:path"), 1);
69289
69819
  var toml3 = __toESM(require_toml(), 1);
69290
69820
  function resolveCodexHome3(options) {
69291
69821
  if (options.codexHome) return options.codexHome;
69292
69822
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
69293
- 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");
69294
69824
  }
69295
69825
  async function pathExists4(target) {
69296
69826
  try {
69297
- await import_promises11.default.access(target);
69827
+ await import_promises13.default.access(target);
69298
69828
  return true;
69299
69829
  } catch {
69300
69830
  return false;
@@ -69303,13 +69833,13 @@ async function pathExists4(target) {
69303
69833
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
69304
69834
  async function uninstallCodex(options = {}) {
69305
69835
  const codexHome = resolveCodexHome3(options);
69306
- const configPath = import_node_path35.default.join(codexHome, "config.toml");
69836
+ const configPath = import_node_path36.default.join(codexHome, "config.toml");
69307
69837
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
69308
69838
  if (!await pathExists4(configPath)) {
69309
69839
  return { action: "missing", configPath, prompts: await removePrompts() };
69310
69840
  }
69311
- const realPath = await import_promises11.default.realpath(configPath).catch(() => configPath);
69312
- 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");
69313
69843
  let parsed = null;
69314
69844
  try {
69315
69845
  parsed = toml3.parse(existing);
@@ -69326,17 +69856,17 @@ async function uninstallCodex(options = {}) {
69326
69856
  return { action: "noop", configPath: realPath, prompts: await removePrompts() };
69327
69857
  }
69328
69858
  const stripped = existing.replace(MRRLIN_BLOCK_RE, (match) => match.startsWith("\n") ? "\n" : "").replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "");
69329
- await import_promises11.default.writeFile(realPath, stripped, { mode: 384 });
69859
+ await import_promises13.default.writeFile(realPath, stripped, { mode: 384 });
69330
69860
  return { action: "removed", configPath: realPath, prompts: await removePrompts() };
69331
69861
  }
69332
69862
  async function uninstallPrompts(codexHome, names) {
69333
69863
  if (names.length === 0) return [];
69334
- const promptsDir = import_node_path35.default.join(codexHome, "prompts");
69864
+ const promptsDir = import_node_path36.default.join(codexHome, "prompts");
69335
69865
  const out = [];
69336
69866
  for (const name of names) {
69337
- const promptPath = import_node_path35.default.join(promptsDir, `${name}.md`);
69867
+ const promptPath = import_node_path36.default.join(promptsDir, `${name}.md`);
69338
69868
  try {
69339
- await import_promises11.default.unlink(promptPath);
69869
+ await import_promises13.default.unlink(promptPath);
69340
69870
  out.push({ name, action: "removed", promptPath });
69341
69871
  } catch (error51) {
69342
69872
  const code = error51?.code;
@@ -69351,8 +69881,8 @@ async function uninstallPrompts(codexHome, names) {
69351
69881
  }
69352
69882
 
69353
69883
  // src/extract/command.ts
69354
- var import_promises12 = require("node:fs/promises");
69355
- var import_node_path36 = require("node:path");
69884
+ var import_promises14 = require("node:fs/promises");
69885
+ var import_node_path37 = require("node:path");
69356
69886
  function parseArgs(args) {
69357
69887
  const map2 = /* @__PURE__ */ new Map();
69358
69888
  for (let i = 0; i < args.length; i++) {
@@ -69389,10 +69919,10 @@ Missing required flag(s): ${missing.join(
69389
69919
  const days = await findSessionDays(deps.stateDir, sessionId);
69390
69920
  const matchingLines = [];
69391
69921
  for (const day of days) {
69392
- 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`);
69393
69923
  let raw;
69394
69924
  try {
69395
- raw = await (0, import_promises12.readFile)(logPath, "utf8");
69925
+ raw = await (0, import_promises14.readFile)(logPath, "utf8");
69396
69926
  } catch {
69397
69927
  continue;
69398
69928
  }
@@ -69426,7 +69956,7 @@ Missing required flag(s): ${missing.join(
69426
69956
  }
69427
69957
  const outputText = cappedLines.join("\n");
69428
69958
  if (outPath) {
69429
- await (0, import_promises12.writeFile)(outPath, outputText, "utf8");
69959
+ await (0, import_promises14.writeFile)(outPath, outputText, "utf8");
69430
69960
  return {
69431
69961
  ok: true,
69432
69962
  message: `Wrote extract to ${outPath}`,
@@ -69475,13 +70005,13 @@ Missing required flag(s): ${missing.join(
69475
70005
 
69476
70006
  // src/bin.ts
69477
70007
  function pm2Runner(args) {
69478
- 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" });
69479
70009
  process.stderr.write(r.stdout ?? "");
69480
70010
  process.stderr.write(r.stderr ?? "");
69481
70011
  return { code: r.status ?? 1, stdout: r.stdout ?? "" };
69482
70012
  }
69483
70013
  function whichBin(bin) {
69484
- 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" });
69485
70015
  const out = (r.stdout ?? "").trim();
69486
70016
  return r.status === 0 && out ? out.split("\n")[0] ?? null : null;
69487
70017
  }
@@ -69490,13 +70020,13 @@ function bootHookStatus() {
69490
70020
  const uid = process.getuid?.();
69491
70021
  if (uid === void 0 || uid === 0) return { status: "unknown" };
69492
70022
  const home = process.env.HOME ?? (0, import_node_os19.homedir)();
69493
- const agents = import_node_path38.default.join(home, "Library", "LaunchAgents");
70023
+ const agents = import_node_path39.default.join(home, "Library", "LaunchAgents");
69494
70024
  const candidates = [
69495
- { label: "com.mrrlin.director-bridge", plist: import_node_path38.default.join(agents, "com.mrrlin.director-bridge.plist") },
69496
- { 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`) }
69497
70027
  ];
69498
70028
  for (const candidate of candidates) {
69499
- 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" });
69500
70030
  if (printed.status !== 0) continue;
69501
70031
  if (!(0, import_node_fs24.existsSync)(candidate.plist)) continue;
69502
70032
  const out = printed.stdout ?? "";
@@ -69718,7 +70248,7 @@ async function main() {
69718
70248
  );
69719
70249
  }
69720
70250
  const { command: command2, args, env } = browserServeArgs();
69721
- 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 } });
69722
70252
  process.exitCode = r.status ?? 1;
69723
70253
  return;
69724
70254
  }
@@ -69729,7 +70259,7 @@ async function main() {
69729
70259
  }
69730
70260
  case "external-agents-serve": {
69731
70261
  const { command: command2, args } = externalAgentsServeArgs();
69732
- 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 });
69733
70263
  process.exitCode = r.status ?? 1;
69734
70264
  return;
69735
70265
  }
@@ -69783,8 +70313,8 @@ async function main() {
69783
70313
  }
69784
70314
  }
69785
70315
  try {
69786
- const codexHome = process.env.CODEX_HOME ?? import_node_path38.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".codex");
69787
- (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 });
69788
70318
  } catch {
69789
70319
  }
69790
70320
  const claudeResult = await installClaude({ binPath, force, serveEnv });
@@ -69797,7 +70327,7 @@ async function main() {
69797
70327
  );
69798
70328
  }
69799
70329
  const realProviderRunner = (command2) => (args) => {
69800
- 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 });
69801
70331
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
69802
70332
  };
69803
70333
  for (const provider of ["codex", "claude"]) {
@@ -69845,7 +70375,7 @@ async function main() {
69845
70375
  env: process.env,
69846
70376
  cwd: process.cwd(),
69847
70377
  writeFile: (p, c) => {
69848
- (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 });
69849
70379
  (0, import_node_fs24.writeFileSync)(p, c, { mode: 384 });
69850
70380
  },
69851
70381
  // Swallows every error on purpose — the only caller uses this to recover settings from the
@@ -69881,7 +70411,7 @@ async function main() {
69881
70411
  purgeSecret: purge,
69882
70412
  secretPath: agentCredentialPath(),
69883
70413
  tokenPath: operatorTokenPath(),
69884
- 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"),
69885
70415
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
69886
70416
  `)
69887
70417
  });
@@ -69902,7 +70432,7 @@ async function main() {
69902
70432
  purgeSecret: true,
69903
70433
  secretPath: agentCredentialPath(),
69904
70434
  tokenPath: operatorTokenPath(),
69905
- ecoPath: import_node_path38.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
70435
+ ecoPath: import_node_path39.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
69906
70436
  log
69907
70437
  });
69908
70438
  let codexOk = true;
@@ -69922,7 +70452,7 @@ async function main() {
69922
70452
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
69923
70453
  }
69924
70454
  try {
69925
- (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 });
69926
70456
  } catch {
69927
70457
  }
69928
70458
  log("removed ~/.mrrlin");
@@ -69963,7 +70493,7 @@ ${HELP_TEXT}`);
69963
70493
  }
69964
70494
  }
69965
70495
  function resolveSelfBinPath() {
69966
- return import_node_path37.default.resolve(process.argv[1] ?? process.execPath);
70496
+ return import_node_path38.default.resolve(process.argv[1] ?? process.execPath);
69967
70497
  }
69968
70498
  main().catch((error51) => {
69969
70499
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}