@mrrlin-dev/mcp 0.4.66 → 0.4.71

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 +936 -404
  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;
@@ -37201,22 +37201,35 @@ var openApiOperationIds = {
37201
37201
  };
37202
37202
 
37203
37203
  // ../../packages/schemas/dist/session.js
37204
+ var sessionEmailSchema = external_exports.string().email();
37204
37205
  var operatorSessionSchema = external_exports.object({
37205
- emails: external_exports.array(external_exports.string().email()).default([]),
37206
+ emails: external_exports.array(sessionEmailSchema).default([]),
37206
37207
  expiresAt: external_exports.number().int().positive(),
37207
37208
  handle: external_exports.string().regex(/^@.+/),
37208
37209
  issuedAt: external_exports.number().int().positive(),
37209
37210
  kind: external_exports.enum(["web", "agent"]).default("web"),
37210
37211
  login: external_exports.string().min(1),
37211
37212
  projectSlug: external_exports.string().min(1).optional(),
37212
- provider: external_exports.literal("github"),
37213
+ provider: external_exports.enum(["github", "firebase"]),
37213
37214
  repo: external_exports.string().min(1).nullable(),
37214
37215
  // ADR 0016: `scope` distinguishes project-pinned agent tokens (legacy, default) from
37215
37216
  // operator-scoped agent tokens. Only relevant for kind:"agent". `web` sessions ignore it.
37216
37217
  // Default 'project' for backward-compat: tokens minted before this field existed parse
37217
37218
  // cleanly into the project branch of the middleware (which mirrors today's behavior).
37218
- scope: external_exports.enum(["project", "operator"]).default("project")
37219
+ scope: external_exports.enum(["project", "operator"]).default("project"),
37220
+ // Billing entitlement carried on the session. Optional because a GitHub session never has one
37221
+ // and a Firebase session has one only once the claims exist. `determinedAt` is what makes it
37222
+ // falsifiable: the token lives for 7 days, so a value that can go stale needs a freshness bound
37223
+ // enforced by the reader (readEffectivePlan), not by the cookie.
37224
+ entitlement: external_exports.object({
37225
+ plan: external_exports.string(),
37226
+ status: external_exports.enum(["active", "none"]),
37227
+ determinedAt: external_exports.number()
37228
+ }).optional()
37219
37229
  });
37230
+ var WEB_SESSION_TTL_MS = 1e3 * 60 * 60 * 24 * 7;
37231
+ var WEB_SESSION_TTL_SECONDS = WEB_SESSION_TTL_MS / 1e3;
37232
+ var ENTITLEMENT_FRESHNESS_MS = 1e3 * 60 * 60;
37220
37233
  var AGENT_SESSION_TTL_MS = 1e3 * 60 * 15;
37221
37234
 
37222
37235
  // ../../packages/schemas/dist/github-state.js
@@ -37295,7 +37308,10 @@ var agentPoolResponseSchema = external_exports.object({
37295
37308
  });
37296
37309
  var agentCapabilitiesSchema = external_exports.object({
37297
37310
  listsModels: external_exports.boolean(),
37298
- readsRateLimits: external_exports.boolean(),
37311
+ // claude-rate-limit-percent design.md D1/D2 — split from a single `readsRateLimits`, which
37312
+ // conflated "has a quota pull RPC" with "turn stream pushes a renderable numeric snapshot".
37313
+ pullsRateLimits: external_exports.boolean(),
37314
+ pushesRateLimits: external_exports.boolean(),
37299
37315
  models: external_exports.array(external_exports.string()),
37300
37316
  // Picker entries for a provider that has no model-listing RPC (`listsModels: false`): the alias
37301
37317
  // the CLI accepts as `id`, a human label carrying the version the alias resolves to, and that
@@ -37307,7 +37323,8 @@ var agentCapabilitiesSchema = external_exports.object({
37307
37323
  var AGENT_CAPABILITIES = {
37308
37324
  codex: {
37309
37325
  listsModels: true,
37310
- readsRateLimits: true,
37326
+ pullsRateLimits: true,
37327
+ pushesRateLimits: true,
37311
37328
  models: [],
37312
37329
  modelCatalog: [],
37313
37330
  sandboxModes: ["read-only", "workspace-write", "danger-full-access"],
@@ -37315,7 +37332,8 @@ var AGENT_CAPABILITIES = {
37315
37332
  },
37316
37333
  claude: {
37317
37334
  listsModels: false,
37318
- readsRateLimits: false,
37335
+ pullsRateLimits: false,
37336
+ pushesRateLimits: true,
37319
37337
  // Aliases the Claude CLI documents for `--model` (`claude --help`), and what each resolved to
37320
37338
  // on 2026-09-04 per the CLI's own `system.init.model` frame. Keep in step with
37321
37339
  // packages/agent-client/src/providers/claude/models.ts — the parity test enforces equality.
@@ -37330,12 +37348,43 @@ var AGENT_CAPABILITIES = {
37330
37348
  poolProviderLabels: ["anthropic"]
37331
37349
  },
37332
37350
  agy: {
37333
- listsModels: false,
37334
- readsRateLimits: false,
37335
- models: [],
37336
- modelCatalog: [],
37337
- sandboxModes: ["workspace-write"],
37338
- poolProviderLabels: ["antigravity"]
37351
+ listsModels: true,
37352
+ pullsRateLimits: false,
37353
+ pushesRateLimits: false,
37354
+ models: [
37355
+ "gemini-3.8-flash-high",
37356
+ "gemini-3.8-flash-medium",
37357
+ "gemini-3.8-flash-low",
37358
+ "gemini-3.7-flash-high",
37359
+ "gemini-3.7-flash-medium",
37360
+ "gemini-3.7-flash-low",
37361
+ "gemini-3.6-flash-high",
37362
+ "gemini-3.6-flash-medium",
37363
+ "gemini-3.6-flash-low",
37364
+ "gemini-3.1-pro-high",
37365
+ "gemini-3.1-pro-low",
37366
+ "claude-sonnet-4-6",
37367
+ "claude-opus-4-6-thinking",
37368
+ "gpt-oss-120b-medium"
37369
+ ],
37370
+ modelCatalog: [
37371
+ { id: "gemini-3.8-flash-high", displayName: "Gemini 3.8 Flash (High)", description: "gemini-3.8-flash-high" },
37372
+ { id: "gemini-3.8-flash-medium", displayName: "Gemini 3.8 Flash (Medium)", description: "gemini-3.8-flash-medium" },
37373
+ { id: "gemini-3.8-flash-low", displayName: "Gemini 3.8 Flash (Low)", description: "gemini-3.8-flash-low" },
37374
+ { id: "gemini-3.7-flash-high", displayName: "Gemini 3.7 Flash (High)", description: "gemini-3.7-flash-high" },
37375
+ { id: "gemini-3.7-flash-medium", displayName: "Gemini 3.7 Flash (Medium)", description: "gemini-3.7-flash-medium" },
37376
+ { id: "gemini-3.7-flash-low", displayName: "Gemini 3.7 Flash (Low)", description: "gemini-3.7-flash-low" },
37377
+ { id: "gemini-3.6-flash-high", displayName: "Gemini 3.6 Flash (High)", description: "gemini-3.6-flash-high" },
37378
+ { id: "gemini-3.6-flash-medium", displayName: "Gemini 3.6 Flash (Medium)", description: "gemini-3.6-flash-medium" },
37379
+ { id: "gemini-3.6-flash-low", displayName: "Gemini 3.6 Flash (Low)", description: "gemini-3.6-flash-low" },
37380
+ { id: "gemini-3.1-pro-high", displayName: "Gemini 3.1 Pro (High)", description: "gemini-3.1-pro-high" },
37381
+ { id: "gemini-3.1-pro-low", displayName: "Gemini 3.1 Pro (Low)", description: "gemini-3.1-pro-low" },
37382
+ { id: "claude-sonnet-4-6", displayName: "Claude Sonnet 4.6 (Thinking)", description: "claude-sonnet-4-6" },
37383
+ { id: "claude-opus-4-6-thinking", displayName: "Claude Opus 4.6 (Thinking)", description: "claude-opus-4-6-thinking" },
37384
+ { id: "gpt-oss-120b-medium", displayName: "GPT-OSS 120B (Medium)", description: "gpt-oss-120b-medium" }
37385
+ ],
37386
+ sandboxModes: ["read-only", "workspace-write", "danger-full-access"],
37387
+ poolProviderLabels: ["antigravity", "google"]
37339
37388
  }
37340
37389
  };
37341
37390
  var providerReadinessResultSchema = external_exports.object({
@@ -37351,7 +37400,7 @@ var providerReadinessResultSchema = external_exports.object({
37351
37400
  var providerReadinessSchema = external_exports.object({
37352
37401
  codex: providerReadinessResultSchema,
37353
37402
  claude: providerReadinessResultSchema,
37354
- agy: providerReadinessResultSchema
37403
+ agy: providerReadinessResultSchema.optional()
37355
37404
  });
37356
37405
  var providerReadinessResponseSchema = external_exports.object({
37357
37406
  data: external_exports.object({ readiness: providerReadinessSchema.nullable() })
@@ -39920,7 +39969,8 @@ var CodexProviderAdapter = class {
39920
39969
  capabilities() {
39921
39970
  return {
39922
39971
  listsModels: true,
39923
- readsRateLimits: true,
39972
+ pullsRateLimits: true,
39973
+ pushesRateLimits: true,
39924
39974
  models: [],
39925
39975
  modelCatalog: [],
39926
39976
  sandboxModes: ["read-only", "workspace-write", "danger-full-access"],
@@ -40307,7 +40357,8 @@ var ClaudeProviderAdapter = class {
40307
40357
  capabilities() {
40308
40358
  return {
40309
40359
  listsModels: false,
40310
- readsRateLimits: false,
40360
+ pullsRateLimits: false,
40361
+ pushesRateLimits: true,
40311
40362
  models: [...CLAUDE_MODELS],
40312
40363
  modelCatalog: claudeModelCatalog(),
40313
40364
  // The neutral 3-value vocabulary every startThread/startTurn caller speaks; permissionModeFor
@@ -40421,30 +40472,485 @@ var ClaudeAgentHandle = class {
40421
40472
  }
40422
40473
  };
40423
40474
 
40475
+ // ../../packages/agent-client/dist/providers/agy/process.js
40476
+ var import_node_child_process5 = require("node:child_process");
40477
+ var import_node_crypto2 = require("node:crypto");
40478
+ var import_node_events2 = require("node:events");
40479
+ var import_promises4 = require("node:timers/promises");
40480
+ var MODEL_ID_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,63}$/;
40481
+ 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}$/;
40482
+ var activeProcesses = /* @__PURE__ */ new Set();
40483
+ var globalCleanupInstalled = false;
40484
+ function installGlobalCleanupOnce() {
40485
+ if (globalCleanupInstalled)
40486
+ return;
40487
+ globalCleanupInstalled = true;
40488
+ process.once("exit", () => {
40489
+ for (const child of activeProcesses) {
40490
+ try {
40491
+ child.kill("SIGKILL");
40492
+ } catch {
40493
+ }
40494
+ }
40495
+ });
40496
+ const sigHandler = async () => {
40497
+ for (const child of activeProcesses) {
40498
+ try {
40499
+ child.kill("SIGTERM");
40500
+ } catch {
40501
+ }
40502
+ }
40503
+ await (0, import_promises4.setTimeout)(1e3);
40504
+ for (const child of activeProcesses) {
40505
+ try {
40506
+ child.kill("SIGKILL");
40507
+ } catch {
40508
+ }
40509
+ }
40510
+ process.exit(0);
40511
+ };
40512
+ process.once("SIGTERM", sigHandler);
40513
+ process.once("SIGINT", sigHandler);
40514
+ }
40515
+ installGlobalCleanupOnce();
40516
+ var AgyProcess = class _AgyProcess {
40517
+ options;
40518
+ sessionId;
40519
+ child;
40520
+ lineHandlers = /* @__PURE__ */ new Set();
40521
+ activityHandlers = /* @__PURE__ */ new Set();
40522
+ exitHandlers = /* @__PURE__ */ new Set();
40523
+ killGraceMs;
40524
+ leftover = "";
40525
+ static MAX_BUFFER = 1024 * 1024;
40526
+ // 1 MiB
40527
+ exited = false;
40528
+ constructor(options) {
40529
+ this.options = options;
40530
+ this.killGraceMs = options.killGraceMs ?? 2e3;
40531
+ const { mode } = options;
40532
+ if (mode.kind === "new") {
40533
+ this.sessionId = mode.sessionId ?? (0, import_node_crypto2.randomUUID)();
40534
+ } else {
40535
+ if (!CONVERSATION_ID_REGEX.test(mode.resumeId)) {
40536
+ throw new Error(`Invalid resume conversation ID: "${mode.resumeId}". Must match UUID pattern`);
40537
+ }
40538
+ this.sessionId = mode.resumeId;
40539
+ }
40540
+ if (options.model != null && options.model !== "") {
40541
+ if (!MODEL_ID_REGEX.test(options.model)) {
40542
+ throw new Error(`Invalid model identifier: "${options.model}". Must match ${MODEL_ID_REGEX}`);
40543
+ }
40544
+ }
40545
+ const args = [
40546
+ "--input-format",
40547
+ "stream-json",
40548
+ "--output-format",
40549
+ "stream-json"
40550
+ ];
40551
+ switch (options.permissionMode) {
40552
+ case "bypassPermissions":
40553
+ args.push("--dangerously-skip-permissions");
40554
+ break;
40555
+ case "plan":
40556
+ args.push("--mode", "plan");
40557
+ break;
40558
+ case "acceptEdits":
40559
+ args.push("--mode", "accept-edits");
40560
+ break;
40561
+ }
40562
+ if (options.model) {
40563
+ args.push("--model", options.model);
40564
+ }
40565
+ if (mode.kind === "resume") {
40566
+ args.push("--conversation", mode.resumeId);
40567
+ }
40568
+ const executable = options.agyExecutable?.trim() || "agy";
40569
+ const cwd = options.cwd?.trim() || void 0;
40570
+ this.child = (0, import_node_child_process5.spawn)(executable, args, {
40571
+ cwd,
40572
+ env: process.env,
40573
+ stdio: ["pipe", "pipe", "pipe"]
40574
+ });
40575
+ activeProcesses.add(this.child);
40576
+ this.child.stdout.setEncoding("utf8");
40577
+ this.child.stderr.setEncoding("utf8");
40578
+ this.child.stdout.on("data", (chunk) => this.handleStdoutChunk(chunk));
40579
+ this.child.stderr.on("data", () => this.emitActivity());
40580
+ this.child.on("exit", (code, signal) => {
40581
+ activeProcesses.delete(this.child);
40582
+ if (this.exited)
40583
+ return;
40584
+ this.exited = true;
40585
+ const info = { code, signal };
40586
+ for (const handler of this.exitHandlers)
40587
+ handler(info);
40588
+ });
40589
+ this.child.on("error", () => this.handleTerminalError());
40590
+ this.child.stdin.on("error", () => this.handleTerminalError());
40591
+ this.child.stdout.on("error", () => this.handleTerminalError());
40592
+ this.child.stderr.on("error", () => this.handleTerminalError());
40593
+ }
40594
+ handleTerminalError() {
40595
+ activeProcesses.delete(this.child);
40596
+ if (this.exited)
40597
+ return;
40598
+ this.exited = true;
40599
+ const info = { code: null, signal: null };
40600
+ for (const handler of this.exitHandlers)
40601
+ handler(info);
40602
+ }
40603
+ emitActivity() {
40604
+ for (const handler of this.activityHandlers)
40605
+ handler();
40606
+ }
40607
+ sendTurn(text) {
40608
+ if (this.exited) {
40609
+ throw new Error(`AgyProcess: cannot send turn to exited child process (session ${this.sessionId})`);
40610
+ }
40611
+ const payload = JSON.stringify({
40612
+ event: "user",
40613
+ message: { content: text }
40614
+ });
40615
+ this.child.stdin.write(`${payload}
40616
+ `);
40617
+ }
40618
+ onLine(handler) {
40619
+ this.lineHandlers.add(handler);
40620
+ return () => this.lineHandlers.delete(handler);
40621
+ }
40622
+ onActivity(handler) {
40623
+ this.activityHandlers.add(handler);
40624
+ return () => this.activityHandlers.delete(handler);
40625
+ }
40626
+ onExit(handler) {
40627
+ this.exitHandlers.add(handler);
40628
+ return () => this.exitHandlers.delete(handler);
40629
+ }
40630
+ async dispose() {
40631
+ if (this.exited || this.child.killed) {
40632
+ activeProcesses.delete(this.child);
40633
+ return;
40634
+ }
40635
+ this.child.kill("SIGTERM");
40636
+ try {
40637
+ await Promise.race([
40638
+ (0, import_node_events2.once)(this.child, "exit"),
40639
+ (0, import_promises4.setTimeout)(this.killGraceMs)
40640
+ ]);
40641
+ } catch {
40642
+ }
40643
+ if (!this.exited) {
40644
+ try {
40645
+ this.child.kill("SIGKILL");
40646
+ } catch {
40647
+ }
40648
+ }
40649
+ activeProcesses.delete(this.child);
40650
+ }
40651
+ handleStdoutChunk(chunk) {
40652
+ this.emitActivity();
40653
+ this.leftover += chunk;
40654
+ let newlineIdx;
40655
+ while ((newlineIdx = this.leftover.indexOf("\n")) !== -1) {
40656
+ const line = this.leftover.slice(0, newlineIdx).trim();
40657
+ this.leftover = this.leftover.slice(newlineIdx + 1);
40658
+ if (line.length === 0)
40659
+ continue;
40660
+ try {
40661
+ const parsed = JSON.parse(line);
40662
+ for (const handler of this.lineHandlers)
40663
+ handler(parsed);
40664
+ } catch {
40665
+ }
40666
+ }
40667
+ if (this.leftover.length > _AgyProcess.MAX_BUFFER) {
40668
+ console.error(`[agy-process] stdout line exceeded max buffer (${_AgyProcess.MAX_BUFFER} chars), discarding`);
40669
+ this.leftover = "";
40670
+ }
40671
+ }
40672
+ };
40673
+
40674
+ // ../../packages/agent-client/dist/providers/agy/event-mapper.js
40675
+ function normalizeContent(content) {
40676
+ if (typeof content === "string")
40677
+ return content;
40678
+ if (content === null || content === void 0)
40679
+ return "";
40680
+ try {
40681
+ return JSON.stringify(content);
40682
+ } catch {
40683
+ return String(content);
40684
+ }
40685
+ }
40686
+ var AgyBridgeEventMapper = class {
40687
+ emittedToolUses = /* @__PURE__ */ new Set();
40688
+ emittedToolResults = /* @__PURE__ */ new Set();
40689
+ reset() {
40690
+ this.emittedToolUses.clear();
40691
+ this.emittedToolResults.clear();
40692
+ }
40693
+ mapLine(parsed, _threadId) {
40694
+ if (typeof parsed !== "object" || parsed === null) {
40695
+ return [];
40696
+ }
40697
+ const data = parsed;
40698
+ if (data.event === "step_update") {
40699
+ const step = data.step_update;
40700
+ if (!step || typeof step !== "object") {
40701
+ return [];
40702
+ }
40703
+ if (step.step_type === "agent_response") {
40704
+ const text = typeof step.text_delta === "string" ? step.text_delta : typeof step.response === "string" ? step.response : "";
40705
+ return text ? [{ type: "assistant", content: text }] : [];
40706
+ }
40707
+ if (step.step_type === "tool_use" || step.tool_call) {
40708
+ const id = (typeof step.tool_use_id === "string" ? step.tool_use_id : typeof step.id === "string" ? step.id : "") || "";
40709
+ if (id && !this.emittedToolUses.has(id)) {
40710
+ this.emittedToolUses.add(id);
40711
+ const name = typeof step.tool_name === "string" ? step.tool_name : typeof step.tool === "string" ? step.tool : "tool_use";
40712
+ const input = step.input ?? {};
40713
+ return [{ type: "tool_use", tool: { name, id, input } }];
40714
+ }
40715
+ return [];
40716
+ }
40717
+ if (step.step_type === "tool_result") {
40718
+ const toolUseId = (typeof step.tool_use_id === "string" ? step.tool_use_id : typeof step.id === "string" ? step.id : "") || "";
40719
+ if (toolUseId && !this.emittedToolResults.has(toolUseId)) {
40720
+ this.emittedToolResults.add(toolUseId);
40721
+ const content = step.content ?? step.result ?? "";
40722
+ return [{ type: "tool_result", tool: { id: toolUseId }, content: normalizeContent(content) }];
40723
+ }
40724
+ return [];
40725
+ }
40726
+ if (step.step_type === "error_message") {
40727
+ const message = typeof step.error === "string" ? step.error : typeof step.message === "string" ? step.message : "AGY step error";
40728
+ return [{ type: "error", content: message }];
40729
+ }
40730
+ return [];
40731
+ }
40732
+ if (data.event === "result") {
40733
+ const res = data.result ?? {};
40734
+ const events = [];
40735
+ if (res.status === "ERROR") {
40736
+ events.push({
40737
+ type: "error",
40738
+ content: typeof res.error === "string" ? res.error : "AGY turn error"
40739
+ });
40740
+ } else {
40741
+ events.push({ type: "result", subtype: "success" });
40742
+ }
40743
+ if (res.usage && typeof res.usage === "object") {
40744
+ const usage = res.usage;
40745
+ events.push({
40746
+ type: "token_usage",
40747
+ usage: {
40748
+ inputTokens: typeof usage.input_tokens === "number" ? usage.input_tokens : typeof usage.inputTokens === "number" ? usage.inputTokens : null,
40749
+ cachedInputTokens: typeof usage.cache_read_input_tokens === "number" ? usage.cache_read_input_tokens : typeof usage.cachedInputTokens === "number" ? usage.cachedInputTokens : null,
40750
+ outputTokens: typeof usage.output_tokens === "number" ? usage.output_tokens : typeof usage.outputTokens === "number" ? usage.outputTokens : null
40751
+ }
40752
+ });
40753
+ }
40754
+ events.push({ type: "turn_completed" });
40755
+ return events;
40756
+ }
40757
+ return [];
40758
+ }
40759
+ };
40760
+
40761
+ // ../../packages/agent-client/dist/providers/agy/models.js
40762
+ var import_node_child_process6 = require("node:child_process");
40763
+ var import_node_util = require("node:util");
40764
+ var import_promises5 = require("node:fs/promises");
40765
+ var import_node_path6 = require("node:path");
40766
+ var execFileAsync = (0, import_node_util.promisify)(import_node_child_process6.execFile);
40767
+ var AGY_MODEL_CATALOG = [
40768
+ { id: "gemini-3.8-flash-high", displayName: "Gemini 3.8 Flash (High)", description: "gemini-3.8-flash-high" },
40769
+ { id: "gemini-3.8-flash-medium", displayName: "Gemini 3.8 Flash (Medium)", description: "gemini-3.8-flash-medium" },
40770
+ { id: "gemini-3.8-flash-low", displayName: "Gemini 3.8 Flash (Low)", description: "gemini-3.8-flash-low" },
40771
+ { id: "gemini-3.7-flash-high", displayName: "Gemini 3.7 Flash (High)", description: "gemini-3.7-flash-high" },
40772
+ { id: "gemini-3.7-flash-medium", displayName: "Gemini 3.7 Flash (Medium)", description: "gemini-3.7-flash-medium" },
40773
+ { id: "gemini-3.7-flash-low", displayName: "Gemini 3.7 Flash (Low)", description: "gemini-3.7-flash-low" },
40774
+ { id: "gemini-3.6-flash-high", displayName: "Gemini 3.6 Flash (High)", description: "gemini-3.6-flash-high" },
40775
+ { id: "gemini-3.6-flash-medium", displayName: "Gemini 3.6 Flash (Medium)", description: "gemini-3.6-flash-medium" },
40776
+ { id: "gemini-3.6-flash-low", displayName: "Gemini 3.6 Flash (Low)", description: "gemini-3.6-flash-low" },
40777
+ { id: "gemini-3.1-pro-high", displayName: "Gemini 3.1 Pro (High)", description: "gemini-3.1-pro-high" },
40778
+ { id: "gemini-3.1-pro-low", displayName: "Gemini 3.1 Pro (Low)", description: "gemini-3.1-pro-low" },
40779
+ { id: "claude-sonnet-4-6", displayName: "Claude Sonnet 4.6 (Thinking)", description: "claude-sonnet-4-6" },
40780
+ { id: "claude-opus-4-6-thinking", displayName: "Claude Opus 4.6 (Thinking)", description: "claude-opus-4-6-thinking" },
40781
+ { id: "gpt-oss-120b-medium", displayName: "GPT-OSS 120B (Medium)", description: "gpt-oss-120b-medium" }
40782
+ ];
40783
+ var AGY_MODELS = AGY_MODEL_CATALOG.map((entry) => entry.id);
40784
+ function agyModelCatalog() {
40785
+ return AGY_MODEL_CATALOG.map((entry) => ({
40786
+ id: entry.id,
40787
+ displayName: entry.displayName,
40788
+ description: entry.description,
40789
+ isDefault: entry.id === "gemini-3.1-pro-high"
40790
+ }));
40791
+ }
40792
+ var MODEL_ID_REGEX2 = /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,63}$/;
40793
+ function parseAgyModelsOutput(output3) {
40794
+ const lines2 = output3.split(/\r?\n/);
40795
+ const models = [];
40796
+ for (const raw of lines2) {
40797
+ const line = raw.trim();
40798
+ if (!line)
40799
+ continue;
40800
+ if (/^(Fetching|Warning|Error)/i.test(line))
40801
+ continue;
40802
+ const parts = line.split(/\t+|\s{2,}/).map((p) => p.trim()).filter(Boolean);
40803
+ const id = parts[0];
40804
+ if (!id || !MODEL_ID_REGEX2.test(id)) {
40805
+ console.warn(`[agy:models] skipping malformed model id: ${id}`);
40806
+ continue;
40807
+ }
40808
+ const displayName = parts[1] ?? id;
40809
+ const description = parts[2] ?? displayName;
40810
+ models.push({
40811
+ id,
40812
+ displayName,
40813
+ description,
40814
+ isDefault: id === "gemini-3.1-pro-high"
40815
+ });
40816
+ }
40817
+ return models;
40818
+ }
40819
+ var cachedModels = null;
40820
+ var CACHE_TTL_MS = 3e4;
40821
+ async function fetchAgyModels(opts) {
40822
+ const now = Date.now();
40823
+ if (!opts?.bypassCache && cachedModels && cachedModels.expiresAt > now) {
40824
+ return cachedModels.models;
40825
+ }
40826
+ let executable = "agy";
40827
+ const customPath = process.env.MRRLIN_AGY_PATH?.trim();
40828
+ if (customPath) {
40829
+ try {
40830
+ if ((0, import_node_path6.basename)(customPath) === "agy") {
40831
+ await (0, import_promises5.access)(customPath);
40832
+ executable = customPath;
40833
+ }
40834
+ } catch {
40835
+ }
40836
+ }
40837
+ try {
40838
+ const { stdout } = await execFileAsync(executable, ["models"], {
40839
+ timeout: 1e4,
40840
+ maxBuffer: 1024 * 1024
40841
+ });
40842
+ const parsed = parseAgyModelsOutput(stdout);
40843
+ if (parsed.length > 0) {
40844
+ cachedModels = { expiresAt: now + CACHE_TTL_MS, models: parsed };
40845
+ return parsed;
40846
+ }
40847
+ console.warn("[agy:models] fetchAgyModels succeeded but returned no models, falling back to static catalog");
40848
+ } catch (error51) {
40849
+ console.warn("[agy:models] fetchAgyModels failed, falling back to static catalog", error51);
40850
+ }
40851
+ const fallback = agyModelCatalog();
40852
+ cachedModels = { expiresAt: now + CACHE_TTL_MS, models: fallback };
40853
+ return fallback;
40854
+ }
40855
+
40424
40856
  // ../../packages/agent-client/dist/providers/agy/adapter.js
40425
40857
  var AgyProviderAdapter = class {
40426
40858
  id = "agy";
40427
40859
  capabilities() {
40428
40860
  return AGENT_CAPABILITIES.agy;
40429
40861
  }
40430
- // Stub adapter: real process spawning and JSONL stdio streaming will be implemented in agy-stdio-streaming
40431
40862
  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
- };
40863
+ return new AgyAgentHandle();
40444
40864
  }
40445
40865
  releaseWarm() {
40446
40866
  }
40447
40867
  };
40868
+ function permissionModeFor2(sandbox, approvalPolicy) {
40869
+ if (sandbox === "read-only") {
40870
+ return { permissionMode: "plan" };
40871
+ }
40872
+ if (sandbox === "workspace-write") {
40873
+ return { permissionMode: "acceptEdits" };
40874
+ }
40875
+ if (sandbox === "danger-full-access" || approvalPolicy === "never") {
40876
+ return { permissionMode: "bypassPermissions" };
40877
+ }
40878
+ return { permissionMode: "acceptEdits" };
40879
+ }
40880
+ var AgyAgentHandle = class {
40881
+ processes = /* @__PURE__ */ new Map();
40882
+ mappers = /* @__PURE__ */ new Map();
40883
+ async startThread(params) {
40884
+ const { permissionMode } = permissionModeFor2(params.sandbox, params.approvalPolicy);
40885
+ const child = new AgyProcess({
40886
+ mode: { kind: "new" },
40887
+ permissionMode,
40888
+ model: params.model,
40889
+ cwd: params.cwd
40890
+ });
40891
+ this.processes.set(child.sessionId, child);
40892
+ this.mappers.set(child.sessionId, new AgyBridgeEventMapper());
40893
+ return { threadId: child.sessionId };
40894
+ }
40895
+ async resumeThread(threadId, params) {
40896
+ const existing = this.processes.get(threadId);
40897
+ if (existing) {
40898
+ await existing.dispose().catch(() => {
40899
+ });
40900
+ }
40901
+ const { permissionMode } = permissionModeFor2(params.sandbox, params.approvalPolicy);
40902
+ const child = new AgyProcess({
40903
+ mode: { kind: "resume", resumeId: threadId },
40904
+ permissionMode,
40905
+ model: params.model,
40906
+ cwd: params.cwd
40907
+ });
40908
+ this.processes.set(threadId, child);
40909
+ this.mappers.set(threadId, new AgyBridgeEventMapper());
40910
+ return { threadId: child.sessionId };
40911
+ }
40912
+ async startTurn(threadId, input) {
40913
+ const child = this.requireProcess(threadId);
40914
+ const text = input.filter((block) => block.type === "text").map((block) => block.text).join("\n");
40915
+ child.sendTurn(text);
40916
+ return { turnId: void 0 };
40917
+ }
40918
+ async interruptTurn(threadId) {
40919
+ const child = this.processes.get(threadId);
40920
+ if (child) {
40921
+ await child.dispose().catch(() => {
40922
+ });
40923
+ this.processes.delete(threadId);
40924
+ this.mappers.delete(threadId);
40925
+ }
40926
+ }
40927
+ onEvent(threadId, handler) {
40928
+ const child = this.requireProcess(threadId);
40929
+ const mapper = this.mappers.get(threadId);
40930
+ if (!mapper)
40931
+ throw new Error(`AgyAgentHandle.onEvent: no mapper for thread ${threadId}`);
40932
+ return child.onLine((parsed) => {
40933
+ for (const event of mapper.mapLine(parsed, threadId))
40934
+ handler(event);
40935
+ });
40936
+ }
40937
+ onActivity(threadId, handler) {
40938
+ const child = this.requireProcess(threadId);
40939
+ return child.onActivity(handler);
40940
+ }
40941
+ async listModels() {
40942
+ return fetchAgyModels();
40943
+ }
40944
+ async readRateLimits() {
40945
+ return null;
40946
+ }
40947
+ requireProcess(threadId) {
40948
+ const child = this.processes.get(threadId);
40949
+ if (!child)
40950
+ throw new Error(`AgyAgentHandle: no active process for thread ${threadId}`);
40951
+ return child;
40952
+ }
40953
+ };
40448
40954
 
40449
40955
  // ../../packages/agent-client/dist/registry.js
40450
40956
  var KNOWN_PROVIDERS = { codex: true, claude: true, agy: true };
@@ -40475,7 +40981,7 @@ function resolveProvider(env, persisted) {
40475
40981
  }
40476
40982
 
40477
40983
  // ../../packages/agent-client/dist/providers/codex/exec.js
40478
- var import_node_child_process5 = require("node:child_process");
40984
+ var import_node_child_process7 = require("node:child_process");
40479
40985
 
40480
40986
  // ../../packages/agent-client/dist/exec-usage.js
40481
40987
  function readCount2(source, ...keys) {
@@ -40589,7 +41095,7 @@ function firstString(...values) {
40589
41095
  return null;
40590
41096
  }
40591
41097
  function runCodexExec(input, deps) {
40592
- const spawn4 = deps?.spawn ?? import_node_child_process5.spawn;
41098
+ const spawn5 = deps?.spawn ?? import_node_child_process7.spawn;
40593
41099
  const executable = input.codexExecutable ?? "codex";
40594
41100
  const sandbox = input.sandbox ?? "read-only";
40595
41101
  const fullPrompt = input.developerInstructions.trim() ? `${input.developerInstructions.trim()}
@@ -40626,7 +41132,7 @@ ${input.prompt}` : input.prompt;
40626
41132
  };
40627
41133
  let child;
40628
41134
  try {
40629
- child = spawn4(executable, args, options);
41135
+ child = spawn5(executable, args, options);
40630
41136
  } catch (err) {
40631
41137
  finish({ ok: false, error: `Failed to spawn codex exec: ${errMessage(err)}` });
40632
41138
  return;
@@ -40667,9 +41173,9 @@ function errMessage(err) {
40667
41173
  }
40668
41174
 
40669
41175
  // ../../packages/agent-client/dist/providers/claude/exec.js
40670
- var import_node_child_process6 = require("node:child_process");
41176
+ var import_node_child_process8 = require("node:child_process");
40671
41177
  function runClaudeExec(input, deps) {
40672
- const spawn4 = deps?.spawn ?? import_node_child_process6.spawn;
41178
+ const spawn5 = deps?.spawn ?? import_node_child_process8.spawn;
40673
41179
  const executable = input.codexExecutable ?? "claude";
40674
41180
  const args = ["--print", "--output-format", "json", "--strict-mcp-config"];
40675
41181
  if (input.sandbox === "read-only") {
@@ -40704,7 +41210,7 @@ function runClaudeExec(input, deps) {
40704
41210
  };
40705
41211
  let child;
40706
41212
  try {
40707
- child = spawn4(executable, args, options);
41213
+ child = spawn5(executable, args, options);
40708
41214
  } catch (err) {
40709
41215
  finish({ ok: false, error: `Failed to spawn ${executable} exec: ${errMessage2(err)}` });
40710
41216
  return;
@@ -40782,16 +41288,45 @@ function runAgentExec(input, deps, persistedProvider) {
40782
41288
  }
40783
41289
 
40784
41290
  // ../../packages/agent-client/dist/resolved-seat.js
40785
- var CODEX_STRONG_MODEL_CONSTANT = "gpt-5.6-terra";
40786
- var CLAUDE_STRONG_MODEL_CONSTANT = "sonnet";
40787
- var CODEX_WEAK_MODEL_CONSTANT = "codex-gpt-5.4-mini";
40788
- var CLAUDE_WEAK_MODEL_CONSTANT = "haiku";
41291
+ var CODEX_DEFAULT_MODEL_CONSTANT = "gpt-5.6-terra";
41292
+ var CLAUDE_DEFAULT_MODEL_CONSTANT = "sonnet";
41293
+ var AGY_DEFAULT_MODEL_CONSTANT = "gemini-3.1-pro-high";
41294
+ var CODEX_DEFAULT_MODEL_ENV = "MRRLIN_CODEX_DEFAULT_MODEL";
40789
41295
  var CODEX_STRONG_MODEL_ENV = "MRRLIN_CODEX_STRONG_MODEL";
41296
+ var CLAUDE_DEFAULT_MODEL_ENV = "MRRLIN_CLAUDE_DEFAULT_MODEL";
40790
41297
  var CLAUDE_STRONG_MODEL_ENV = "MRRLIN_CLAUDE_STRONG_MODEL";
41298
+ var AGY_DEFAULT_MODEL_ENV = "MRRLIN_AGY_DEFAULT_MODEL";
41299
+ var AGY_STRONG_MODEL_ENV = "MRRLIN_AGY_STRONG_MODEL";
41300
+ var CODEX_WEAK_MODEL_ENV = "MRRLIN_CODEX_WEAK_MODEL";
41301
+ var CLAUDE_WEAK_MODEL_ENV = "MRRLIN_CLAUDE_WEAK_MODEL";
41302
+ var AGY_WEAK_MODEL_ENV = "MRRLIN_AGY_WEAK_MODEL";
41303
+ function weakEnvVarFor(providerId) {
41304
+ if (providerId === "codex")
41305
+ return CODEX_WEAK_MODEL_ENV;
41306
+ if (providerId === "claude")
41307
+ return CLAUDE_WEAK_MODEL_ENV;
41308
+ return AGY_WEAK_MODEL_ENV;
41309
+ }
41310
+ function defaultConstantFor(providerId) {
41311
+ if (providerId === "codex")
41312
+ return CODEX_DEFAULT_MODEL_CONSTANT;
41313
+ if (providerId === "claude")
41314
+ return CLAUDE_DEFAULT_MODEL_CONSTANT;
41315
+ return AGY_DEFAULT_MODEL_CONSTANT;
41316
+ }
41317
+ function readModelEnv(providerId) {
41318
+ if (providerId === "codex") {
41319
+ return process.env[CODEX_DEFAULT_MODEL_ENV]?.trim() || process.env[CODEX_STRONG_MODEL_ENV]?.trim();
41320
+ }
41321
+ if (providerId === "claude") {
41322
+ return process.env[CLAUDE_DEFAULT_MODEL_ENV]?.trim() || process.env[CLAUDE_STRONG_MODEL_ENV]?.trim();
41323
+ }
41324
+ return process.env[AGY_DEFAULT_MODEL_ENV]?.trim() || process.env[AGY_STRONG_MODEL_ENV]?.trim();
41325
+ }
40791
41326
  function logFallback(providerId, tier, source, value) {
40792
41327
  console.error(`[resolved-seat] provider=${providerId} ${tier}=${value} (source: ${source})`);
40793
41328
  }
40794
- function pickStrongModelFromList(models) {
41329
+ function pickDefaultModelFromList(models) {
40795
41330
  const defaultModel = models.find((m) => m.isDefault === true);
40796
41331
  if (defaultModel)
40797
41332
  return defaultModel.id;
@@ -40800,85 +41335,66 @@ function pickStrongModelFromList(models) {
40800
41335
  return nonHidden.id;
40801
41336
  return models[0]?.id ?? null;
40802
41337
  }
40803
- function pickWeakModelFromList(models, strongModel) {
40804
- const miniModel = models.find((m) => {
40805
- const id = m.id.toLowerCase();
40806
- return id.includes("mini") || id.includes("weak") || id.includes("small");
40807
- });
40808
- if (miniModel && miniModel.id !== strongModel)
40809
- return miniModel.id;
40810
- return null;
40811
- }
41338
+ var warnedEnvVars = /* @__PURE__ */ new Set();
40812
41339
  async function mintResolvedSeat(provider, opts) {
40813
41340
  const capabilities = provider.capabilities();
40814
41341
  const providerId = provider.id;
40815
- let strongModel;
40816
- let weakModel;
41342
+ let model;
40817
41343
  let pinRetired;
40818
41344
  let retiredPin;
40819
- const strongEnvValue = process.env[providerId === "codex" ? CODEX_STRONG_MODEL_ENV : CLAUDE_STRONG_MODEL_ENV]?.trim();
41345
+ const weakEnvVar = weakEnvVarFor(providerId);
41346
+ if (process.env[weakEnvVar] && !warnedEnvVars.has(weakEnvVar)) {
41347
+ warnedEnvVars.add(weakEnvVar);
41348
+ console.warn(`[resolved-seat] ${weakEnvVar} is deprecated; weak model tier has been unified into default model`);
41349
+ }
41350
+ const envValue = readModelEnv(providerId);
40820
41351
  if (opts?.handle && capabilities.listsModels) {
40821
41352
  try {
40822
41353
  const models = await opts.handle.listModels();
40823
- if (strongEnvValue && models.some((m) => m.id === strongEnvValue)) {
40824
- strongModel = strongEnvValue;
40825
- logFallback(providerId, "strong", "env", strongModel);
41354
+ if (models.length === 0) {
41355
+ throw new Error("empty model list");
41356
+ }
41357
+ if (envValue && models.some((m) => m.id === envValue)) {
41358
+ model = envValue;
41359
+ logFallback(providerId, "default", "env", model);
40826
41360
  } else {
40827
- const picked = pickStrongModelFromList(models);
41361
+ const picked = pickDefaultModelFromList(models);
40828
41362
  if (picked) {
40829
- strongModel = picked;
40830
- if (strongEnvValue) {
40831
- logFallback(providerId, "strong", "live-default (env pin retired)", strongModel);
41363
+ model = picked;
41364
+ if (envValue) {
41365
+ logFallback(providerId, "default", "live-default (env pin retired)", model);
40832
41366
  pinRetired = true;
40833
- retiredPin = strongEnvValue;
41367
+ retiredPin = envValue;
40834
41368
  }
40835
41369
  } else {
40836
41370
  throw new Error("empty model list");
40837
41371
  }
40838
41372
  }
40839
41373
  } catch {
40840
- if (strongEnvValue) {
40841
- strongModel = strongEnvValue;
40842
- logFallback(providerId, "strong", "env", strongModel);
41374
+ if (envValue) {
41375
+ model = envValue;
41376
+ logFallback(providerId, "default", "env", model);
40843
41377
  } else {
40844
- strongModel = providerId === "codex" ? CODEX_STRONG_MODEL_CONSTANT : CLAUDE_STRONG_MODEL_CONSTANT;
40845
- logFallback(providerId, "strong", "constant", strongModel);
41378
+ model = defaultConstantFor(providerId);
41379
+ logFallback(providerId, "default", "constant", model);
40846
41380
  }
40847
41381
  }
40848
- } else if (strongEnvValue) {
40849
- strongModel = strongEnvValue;
40850
- logFallback(providerId, "strong", "env", strongModel);
40851
- } else {
40852
- strongModel = providerId === "codex" ? CODEX_STRONG_MODEL_CONSTANT : CLAUDE_STRONG_MODEL_CONSTANT;
40853
- logFallback(providerId, "strong", "constant", strongModel);
40854
- }
40855
- if (providerId === "claude") {
40856
- weakModel = CLAUDE_WEAK_MODEL_CONSTANT;
40857
- logFallback(providerId, "weak", "constant", weakModel);
41382
+ } else if (envValue) {
41383
+ model = envValue;
41384
+ logFallback(providerId, "default", "env", model);
40858
41385
  } else {
40859
- if (opts?.handle && capabilities.listsModels) {
40860
- try {
40861
- const models = await opts.handle.listModels();
40862
- const picked = pickWeakModelFromList(models, strongModel);
40863
- if (picked) {
40864
- weakModel = picked;
40865
- } else {
40866
- weakModel = strongModel;
40867
- logFallback(providerId, "weak", "degenerate (weak=strong)", weakModel);
40868
- }
40869
- } catch {
40870
- weakModel = CODEX_WEAK_MODEL_CONSTANT;
40871
- logFallback(providerId, "weak", "constant", weakModel);
40872
- }
40873
- } else {
40874
- weakModel = CODEX_WEAK_MODEL_CONSTANT;
40875
- logFallback(providerId, "weak", "constant", weakModel);
40876
- }
41386
+ model = defaultConstantFor(providerId);
41387
+ logFallback(providerId, "default", "constant", model);
40877
41388
  }
40878
41389
  return {
40879
41390
  id: providerId,
40880
41391
  capabilities,
40881
- models: { strong: strongModel, weak: weakModel },
41392
+ model,
41393
+ models: {
41394
+ strong: model,
41395
+ weak: model,
41396
+ default: model
41397
+ },
40882
41398
  ...pinRetired ? { pinRetired: true, retiredPin } : {}
40883
41399
  };
40884
41400
  }
@@ -42360,17 +42876,17 @@ function createTurnLock() {
42360
42876
  }
42361
42877
 
42362
42878
  // src/self-update.ts
42363
- var import_node_child_process8 = require("node:child_process");
42364
- var import_node_crypto2 = require("node:crypto");
42879
+ var import_node_child_process10 = require("node:child_process");
42880
+ var import_node_crypto3 = require("node:crypto");
42365
42881
  var import_node_fs4 = require("node:fs");
42366
- var import_node_path7 = __toESM(require("node:path"), 1);
42882
+ var import_node_path8 = __toESM(require("node:path"), 1);
42367
42883
  var import_semver3 = __toESM(require_semver2(), 1);
42368
42884
 
42369
42885
  // src/codex-auth-preflight.ts
42370
- var import_node_child_process7 = require("node:child_process");
42886
+ var import_node_child_process9 = require("node:child_process");
42371
42887
  var import_node_fs3 = require("node:fs");
42372
42888
  var import_node_os6 = __toESM(require("node:os"), 1);
42373
- var import_node_path6 = __toESM(require("node:path"), 1);
42889
+ var import_node_path7 = __toESM(require("node:path"), 1);
42374
42890
  var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
42375
42891
  var DEFAULT_CODEX_AUTH_SMOKE_TIMEOUT_MS = 2e4;
42376
42892
  var DEFAULT_CODEX_AUTH_SMOKE_MODEL = "gpt-5.4-mini";
@@ -42389,7 +42905,7 @@ function codexAuthSmokeTimeoutMs(env = process.env) {
42389
42905
  function resolveCodexAuthPath(opts = {}) {
42390
42906
  const env = opts.env ?? process.env;
42391
42907
  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");
42908
+ return import_node_path7.default.join(codexHome || import_node_path7.default.join(opts.homeDir ?? import_node_os6.default.homedir(), ".codex"), "auth.json");
42393
42909
  }
42394
42910
  function decodeJwtExpMs(token) {
42395
42911
  const parts = token.split(".");
@@ -42458,7 +42974,7 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
42458
42974
  CODEX_AUTH_SMOKE_PROMPT
42459
42975
  ];
42460
42976
  const command = commandForSmoke(executable, model);
42461
- const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process7.execFileSync;
42977
+ const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process9.execFileSync;
42462
42978
  try {
42463
42979
  execFileSync5(executable, args, {
42464
42980
  cwd,
@@ -42609,12 +43125,12 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
42609
43125
  var BIN_NAME = "mrrlin-mcp";
42610
43126
  var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
42611
43127
  function resolveBinPath(opts) {
42612
- if (opts.argv1 && import_node_path7.default.basename(opts.argv1).includes("mrrlin")) {
43128
+ if (opts.argv1 && import_node_path8.default.basename(opts.argv1).includes("mrrlin")) {
42613
43129
  return { path: opts.argv1, source: "argv" };
42614
43130
  }
42615
43131
  const whichSync = opts.whichSync ?? ((name) => {
42616
43132
  try {
42617
- return (0, import_node_child_process8.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
43133
+ return (0, import_node_child_process10.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
42618
43134
  } catch {
42619
43135
  return null;
42620
43136
  }
@@ -42625,9 +43141,9 @@ function resolveBinPath(opts) {
42625
43141
  return { path: resolved, source: "which" };
42626
43142
  }
42627
43143
  const envPath = (opts.env ?? process.env).PATH ?? "";
42628
- for (const dir of envPath.split(import_node_path7.default.delimiter)) {
43144
+ for (const dir of envPath.split(import_node_path8.default.delimiter)) {
42629
43145
  if (!dir) continue;
42630
- const candidate = import_node_path7.default.join(dir, BIN_NAME);
43146
+ const candidate = import_node_path8.default.join(dir, BIN_NAME);
42631
43147
  if (existsSync5(candidate)) {
42632
43148
  return { path: candidate, source: "path-walk" };
42633
43149
  }
@@ -42653,7 +43169,7 @@ function readIntervalEnv(name, fallback) {
42653
43169
  return Number.isFinite(n) && n > 0 ? n : fallback;
42654
43170
  }
42655
43171
  function sha256(buf) {
42656
- return (0, import_node_crypto2.createHash)("sha256").update(buf).digest("hex");
43172
+ return (0, import_node_crypto3.createHash)("sha256").update(buf).digest("hex");
42657
43173
  }
42658
43174
  function startSelfUpdate(deps) {
42659
43175
  const log = deps.log ?? (() => {
@@ -42945,17 +43461,17 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
42945
43461
  }
42946
43462
 
42947
43463
  // src/_generated/version.ts
42948
- var PKG_VERSION = "0.4.66";
43464
+ var PKG_VERSION = "0.4.71";
42949
43465
 
42950
43466
  // src/api-base-url-migrate.ts
42951
43467
  var import_node_fs5 = __toESM(require("node:fs"), 1);
42952
43468
  var import_node_os7 = __toESM(require("node:os"), 1);
42953
- var import_node_path9 = __toESM(require("node:path"), 1);
43469
+ var import_node_path10 = __toESM(require("node:path"), 1);
42954
43470
 
42955
43471
  // src/service-paths.ts
42956
- var import_node_path8 = __toESM(require("node:path"), 1);
43472
+ var import_node_path9 = __toESM(require("node:path"), 1);
42957
43473
  function isWorktreePath(p) {
42958
- const norm = import_node_path8.default.normalize(p).split(import_node_path8.default.sep).join("/");
43474
+ const norm = import_node_path9.default.normalize(p).split(import_node_path9.default.sep).join("/");
42959
43475
  return norm.includes("/.claude/worktrees/");
42960
43476
  }
42961
43477
  function resolveServiceCwd(opts) {
@@ -43013,7 +43529,7 @@ function defaultDeps(deps) {
43013
43529
  const home = deps.home ?? process.env.HOME ?? import_node_os7.default.homedir();
43014
43530
  return {
43015
43531
  home,
43016
- codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path9.default.join(home, ".codex"),
43532
+ codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path10.default.join(home, ".codex"),
43017
43533
  readFile: deps.readFile ?? ((p) => import_node_fs5.default.readFileSync(p, "utf8")),
43018
43534
  // Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
43019
43535
  // interleave partial writes into a config the next start has to parse. Note this normalizes the
@@ -43062,7 +43578,7 @@ function backupOnce(file2, text, deps) {
43062
43578
  }
43063
43579
  function migrateEcosystemConfig(deps = {}) {
43064
43580
  const d = defaultDeps(deps);
43065
- const file2 = import_node_path9.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
43581
+ const file2 = import_node_path10.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
43066
43582
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43067
43583
  const text = d.readFile(file2);
43068
43584
  if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
@@ -43212,7 +43728,7 @@ ${envLines}
43212
43728
  }
43213
43729
  function migrateCodexConfig(deps = {}) {
43214
43730
  const d = defaultDeps(deps);
43215
- const file2 = import_node_path9.default.join(d.codexHome, "config.toml");
43731
+ const file2 = import_node_path10.default.join(d.codexHome, "config.toml");
43216
43732
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43217
43733
  const text = d.readFile(file2);
43218
43734
  const host = findRetiredHost(text);
@@ -43298,7 +43814,7 @@ $1`
43298
43814
  }
43299
43815
  function migrateClaudeConfig(deps = {}) {
43300
43816
  const d = defaultDeps(deps);
43301
- const file2 = import_node_path9.default.join(d.home, ".claude.json");
43817
+ const file2 = import_node_path10.default.join(d.home, ".claude.json");
43302
43818
  if (!d.exists(file2)) return { file: file2, status: "absent" };
43303
43819
  const text = d.readFile(file2);
43304
43820
  let parsed;
@@ -43348,9 +43864,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
43348
43864
  const d = defaultDeps(deps);
43349
43865
  const results = [];
43350
43866
  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") }
43867
+ { run: migrateEcosystemConfig, file: import_node_path10.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
43868
+ { run: migrateCodexConfig, file: import_node_path10.default.join(d.codexHome, "config.toml") },
43869
+ { run: migrateClaudeConfig, file: import_node_path10.default.join(d.home, ".claude.json") }
43354
43870
  ];
43355
43871
  for (const step of steps) {
43356
43872
  try {
@@ -43377,7 +43893,7 @@ function migrateRetiredApiBaseUrls(deps = {}) {
43377
43893
 
43378
43894
  // src/bridge-health.ts
43379
43895
  var import_node_fs6 = require("node:fs");
43380
- var import_node_path10 = __toESM(require("node:path"), 1);
43896
+ var import_node_path11 = __toESM(require("node:path"), 1);
43381
43897
  var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
43382
43898
  var CRASH_WINDOW_MS = 60 * 60 * 1e3;
43383
43899
  var MAX_CRASHES_PER_WINDOW = 3;
@@ -43389,7 +43905,7 @@ function isCrashSentinel(value) {
43389
43905
  return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
43390
43906
  }
43391
43907
  async function readCrashSentinel(stateDir, now = Date.now) {
43392
- const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
43908
+ const sentinelPath = import_node_path11.default.join(stateDir, SENTINEL_FILE_NAME);
43393
43909
  try {
43394
43910
  const raw = await import_node_fs6.promises.readFile(sentinelPath, "utf8");
43395
43911
  const parsed = JSON.parse(raw);
@@ -43400,7 +43916,7 @@ async function readCrashSentinel(stateDir, now = Date.now) {
43400
43916
  }
43401
43917
  async function writeCrashSentinel(stateDir, sentinel) {
43402
43918
  await import_node_fs6.promises.mkdir(stateDir, { recursive: true });
43403
- const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
43919
+ const sentinelPath = import_node_path11.default.join(stateDir, SENTINEL_FILE_NAME);
43404
43920
  const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
43405
43921
  await import_node_fs6.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
43406
43922
  await import_node_fs6.promises.rename(tmpPath, sentinelPath);
@@ -43729,16 +44245,16 @@ function startSchedulerTickLoop(deps) {
43729
44245
  }
43730
44246
 
43731
44247
  // src/retention/pruner.ts
43732
- var import_promises4 = require("node:fs/promises");
43733
- var import_node_path11 = __toESM(require("node:path"), 1);
44248
+ var import_promises6 = require("node:fs/promises");
44249
+ var import_node_path12 = __toESM(require("node:path"), 1);
43734
44250
  function protectedDayFloor(protectedSinceMs) {
43735
44251
  return new Date(protectedSinceMs).toISOString().slice(0, 10);
43736
44252
  }
43737
44253
  async function prune(stateDir, bounds) {
43738
- const logsDir = import_node_path11.default.join(stateDir, "logs");
44254
+ const logsDir = import_node_path12.default.join(stateDir, "logs");
43739
44255
  let entries;
43740
44256
  try {
43741
- entries = await (0, import_promises4.readdir)(logsDir);
44257
+ entries = await (0, import_promises6.readdir)(logsDir);
43742
44258
  } catch (err) {
43743
44259
  if (err?.code === "ENOENT") {
43744
44260
  await emitPruneLog(stateDir, [], {}, 0, null);
@@ -43751,8 +44267,8 @@ async function prune(stateDir, bounds) {
43751
44267
  for (const entry of entries) {
43752
44268
  const m = bridgeRe.exec(entry);
43753
44269
  if (!m?.[1]) continue;
43754
- const fullPath = import_node_path11.default.join(logsDir, entry);
43755
- const s = await (0, import_promises4.stat)(fullPath);
44270
+ const fullPath = import_node_path12.default.join(logsDir, entry);
44271
+ const s = await (0, import_promises6.stat)(fullPath);
43756
44272
  files.push({ day: m[1], size: s.size, fullPath });
43757
44273
  }
43758
44274
  files.sort((a, b) => a.day < b.day ? -1 : a.day > b.day ? 1 : 0);
@@ -43760,10 +44276,10 @@ async function prune(stateDir, bounds) {
43760
44276
  const reasonByDay = {};
43761
44277
  let bytesRemoved = 0;
43762
44278
  async function isDaySafeToDelete(day) {
43763
- const telemetryDir = import_node_path11.default.join(stateDir, "telemetry");
44279
+ const telemetryDir = import_node_path12.default.join(stateDir, "telemetry");
43764
44280
  let telemetryEntries;
43765
44281
  try {
43766
- telemetryEntries = await (0, import_promises4.readdir)(telemetryDir);
44282
+ telemetryEntries = await (0, import_promises6.readdir)(telemetryDir);
43767
44283
  } catch (err) {
43768
44284
  if (err?.code === "ENOENT") return true;
43769
44285
  throw err;
@@ -43776,9 +44292,9 @@ async function prune(stateDir, bounds) {
43776
44292
  }
43777
44293
  if (projectSlugs.length === 0) return true;
43778
44294
  for (const slug of projectSlugs) {
43779
- const markerPath = import_node_path11.default.join(telemetryDir, `.processed-${slug}-${day}`);
44295
+ const markerPath = import_node_path12.default.join(telemetryDir, `.processed-${slug}-${day}`);
43780
44296
  try {
43781
- await (0, import_promises4.stat)(markerPath);
44297
+ await (0, import_promises6.stat)(markerPath);
43782
44298
  } catch (err) {
43783
44299
  if (err?.code === "ENOENT") return false;
43784
44300
  throw err;
@@ -43799,7 +44315,7 @@ async function prune(stateDir, bounds) {
43799
44315
  i += 1;
43800
44316
  continue;
43801
44317
  }
43802
- await (0, import_promises4.unlink)(candidate.fullPath);
44318
+ await (0, import_promises6.unlink)(candidate.fullPath);
43803
44319
  daysRemoved.push(candidate.day);
43804
44320
  reasonByDay[candidate.day] = "size";
43805
44321
  bytesRemoved += candidate.size;
@@ -43813,7 +44329,7 @@ async function prune(stateDir, bounds) {
43813
44329
  const fileDate = /* @__PURE__ */ new Date(`${info.day}T00:00:00Z`);
43814
44330
  const ageInDays = (now - fileDate.getTime()) / msPerDay;
43815
44331
  if (ageInDays > bounds.ageDays && !isProtected(info.day) && await isDaySafeToDelete(info.day)) {
43816
- await (0, import_promises4.unlink)(info.fullPath);
44332
+ await (0, import_promises6.unlink)(info.fullPath);
43817
44333
  daysRemoved.push(info.day);
43818
44334
  reasonByDay[info.day] = "age";
43819
44335
  bytesRemoved += info.size;
@@ -43826,11 +44342,11 @@ async function prune(stateDir, bounds) {
43826
44342
  const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
43827
44343
  await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
43828
44344
  if (daysRemoved.length > 0) {
43829
- const sessionsPath = import_node_path11.default.join(logsDir, ".sessions.json");
44345
+ const sessionsPath = import_node_path12.default.join(logsDir, ".sessions.json");
43830
44346
  let sessionsObj = {};
43831
44347
  let fileExists = true;
43832
44348
  try {
43833
- sessionsObj = JSON.parse(await (0, import_promises4.readFile)(sessionsPath, "utf8"));
44349
+ sessionsObj = JSON.parse(await (0, import_promises6.readFile)(sessionsPath, "utf8"));
43834
44350
  } catch (err) {
43835
44351
  if (err?.code === "ENOENT") {
43836
44352
  fileExists = false;
@@ -43841,25 +44357,25 @@ async function prune(stateDir, bounds) {
43841
44357
  if (fileExists) {
43842
44358
  for (const day of daysRemoved) Reflect.deleteProperty(sessionsObj, day);
43843
44359
  const tmpPath = `${sessionsPath}.tmp`;
43844
- await (0, import_promises4.writeFile)(tmpPath, JSON.stringify(sessionsObj));
43845
- await (0, import_promises4.rename)(tmpPath, sessionsPath);
44360
+ await (0, import_promises6.writeFile)(tmpPath, JSON.stringify(sessionsObj));
44361
+ await (0, import_promises6.rename)(tmpPath, sessionsPath);
43846
44362
  }
43847
44363
  }
43848
44364
  return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
43849
44365
  }
43850
44366
  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 });
44367
+ const logsDir = import_node_path12.default.join(stateDir, "logs");
44368
+ const logPath = import_node_path12.default.join(logsDir, ".pruned.jsonl");
44369
+ await (0, import_promises6.mkdir)(logsDir, { recursive: true });
43854
44370
  const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
43855
- await (0, import_promises4.appendFile)(logPath, `${JSON.stringify(record2)}
44371
+ await (0, import_promises6.appendFile)(logPath, `${JSON.stringify(record2)}
43856
44372
  `);
43857
44373
  }
43858
44374
 
43859
44375
  // 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");
44376
+ var import_node_crypto4 = require("node:crypto");
44377
+ var import_promises7 = require("node:fs/promises");
44378
+ var import_node_path13 = require("node:path");
43863
44379
  var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
43864
44380
  var PLUMBING_COUNTER_KEY = {
43865
44381
  socket_close: "socketCloses",
@@ -43888,10 +44404,10 @@ function inheritSlug(seeds, index) {
43888
44404
  return (preceding ?? following)?.slug;
43889
44405
  }
43890
44406
  async function foldClosedDays(stateDir, today) {
43891
- const logsDir = (0, import_node_path12.join)(stateDir, "logs");
44407
+ const logsDir = (0, import_node_path13.join)(stateDir, "logs");
43892
44408
  let entries;
43893
44409
  try {
43894
- entries = await (0, import_promises5.readdir)(logsDir);
44410
+ entries = await (0, import_promises7.readdir)(logsDir);
43895
44411
  } catch {
43896
44412
  return;
43897
44413
  }
@@ -43900,7 +44416,7 @@ async function foldClosedDays(stateDir, today) {
43900
44416
  if (!m) continue;
43901
44417
  const day = m[1];
43902
44418
  if (day === today) continue;
43903
- const raw = await (0, import_promises5.readFile)((0, import_node_path12.join)(logsDir, entry), "utf8");
44419
+ const raw = await (0, import_promises7.readFile)((0, import_node_path13.join)(logsDir, entry), "utf8");
43904
44420
  const groups = /* @__PURE__ */ new Map();
43905
44421
  let groupCounter = 0;
43906
44422
  for (const line of raw.split("\n")) {
@@ -44011,16 +44527,16 @@ async function foldClosedDays(stateDir, today) {
44011
44527
  rowsByProject.set(slug, rows);
44012
44528
  }
44013
44529
  if (rowsByProject.size === 0) continue;
44014
- const telemetryDir = (0, import_node_path12.join)(stateDir, "telemetry");
44015
- await (0, import_promises5.mkdir)(telemetryDir, { recursive: true });
44530
+ const telemetryDir = (0, import_node_path13.join)(stateDir, "telemetry");
44531
+ await (0, import_promises7.mkdir)(telemetryDir, { recursive: true });
44016
44532
  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")}`;
44533
+ const finalPath = (0, import_node_path13.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
44534
+ const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}`;
44019
44535
  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);
44536
+ await (0, import_promises7.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
44537
+ await (0, import_promises7.rename)(tmpPath, finalPath);
44022
44538
  } finally {
44023
- await (0, import_promises5.unlink)(tmpPath).catch(() => {
44539
+ await (0, import_promises7.unlink)(tmpPath).catch(() => {
44024
44540
  });
44025
44541
  }
44026
44542
  }
@@ -44028,23 +44544,23 @@ async function foldClosedDays(stateDir, today) {
44028
44544
  }
44029
44545
 
44030
44546
  // src/telemetry/daily-uploader.ts
44031
- var import_promises6 = require("node:fs/promises");
44032
- var import_node_path17 = require("node:path");
44547
+ var import_promises8 = require("node:fs/promises");
44548
+ var import_node_path18 = require("node:path");
44033
44549
 
44034
44550
  // src/consensus/wiring.ts
44035
- var import_node_crypto4 = __toESM(require("node:crypto"), 1);
44551
+ var import_node_crypto5 = __toESM(require("node:crypto"), 1);
44036
44552
  var import_node_fs9 = __toESM(require("node:fs"), 1);
44037
- var import_node_path15 = __toESM(require("node:path"), 1);
44553
+ var import_node_path16 = __toESM(require("node:path"), 1);
44038
44554
  var import_node_url2 = require("node:url");
44039
44555
 
44040
44556
  // src/consensus/gate-usage-log.ts
44041
44557
  var import_node_fs7 = require("node:fs");
44042
- var import_node_path13 = require("node:path");
44558
+ var import_node_path14 = require("node:path");
44043
44559
  function recordGateCall(stateDir, projectSlug, record2) {
44044
44560
  try {
44045
- const dir = (0, import_node_path13.join)(stateDir, "telemetry");
44561
+ const dir = (0, import_node_path14.join)(stateDir, "telemetry");
44046
44562
  (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)}
44563
+ (0, import_node_fs7.appendFileSync)((0, import_node_path14.join)(dir, gateFileName(projectSlug, record2.day)), `${JSON.stringify(record2)}
44048
44564
  `, "utf8");
44049
44565
  } catch {
44050
44566
  }
@@ -44912,15 +45428,15 @@ ${issuesBlock}`,
44912
45428
  // src/consensus/sterile-cwd.ts
44913
45429
  var import_node_fs8 = require("node:fs");
44914
45430
  var import_node_os8 = require("node:os");
44915
- var import_node_path14 = require("node:path");
45431
+ var import_node_path15 = require("node:path");
44916
45432
  var sterileDir = null;
44917
45433
  function sterileCwd() {
44918
- sterileDir ??= (0, import_node_fs8.mkdtempSync)((0, import_node_path14.join)((0, import_node_os8.tmpdir)(), "mrrlin-gate-"));
45434
+ sterileDir ??= (0, import_node_fs8.mkdtempSync)((0, import_node_path15.join)((0, import_node_os8.tmpdir)(), "mrrlin-gate-"));
44919
45435
  return sterileDir;
44920
45436
  }
44921
45437
 
44922
45438
  // src/consensus/code-gate-git.ts
44923
- var import_node_child_process9 = require("node:child_process");
45439
+ var import_node_child_process11 = require("node:child_process");
44924
45440
  var DIFF_MAX_BYTES = 2e5;
44925
45441
  var FASTGATE_OUTPUT_MAX_BYTES = 16e3;
44926
45442
  var GIT_TIMEOUT_MS = 6e4;
@@ -44936,7 +45452,7 @@ var defaultRunCmd = (cmd, args, opts) => new Promise((resolve) => {
44936
45452
  };
44937
45453
  let child;
44938
45454
  try {
44939
- child = (0, import_node_child_process9.spawn)(cmd, args, {
45455
+ child = (0, import_node_child_process11.spawn)(cmd, args, {
44940
45456
  cwd: opts.cwd,
44941
45457
  env: process.env,
44942
45458
  shell: false,
@@ -45151,15 +45667,15 @@ ${res.stdout}${res.stderr}`);
45151
45667
  var import_meta2 = {};
45152
45668
  function getPersonasDir() {
45153
45669
  if (typeof __dirname !== "undefined") {
45154
- return import_node_path15.default.join(__dirname, "consensus", "personas");
45670
+ return import_node_path16.default.join(__dirname, "consensus", "personas");
45155
45671
  }
45156
- return import_node_path15.default.join(import_node_path15.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
45672
+ return import_node_path16.default.join(import_node_path16.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
45157
45673
  }
45158
45674
  var personaCache = /* @__PURE__ */ new Map();
45159
45675
  function loadPersona(name) {
45160
45676
  const cached2 = personaCache.get(name);
45161
45677
  if (cached2 !== void 0) return cached2;
45162
- const content = import_node_fs9.default.readFileSync(import_node_path15.default.join(getPersonasDir(), `${name}.md`), "utf8");
45678
+ const content = import_node_fs9.default.readFileSync(import_node_path16.default.join(getPersonasDir(), `${name}.md`), "utf8");
45163
45679
  personaCache.set(name, content);
45164
45680
  return content;
45165
45681
  }
@@ -45347,11 +45863,11 @@ ${artifact}`,
45347
45863
  sandbox: "read-only",
45348
45864
  codexExecutable,
45349
45865
  // model-tier-planning-and-arbiter task 2.5 (D1): the arbiter is pinned to the seat's
45350
- // strongest model.
45351
- model: seat?.models.strong
45866
+ // default model.
45867
+ model: seat?.model ?? seat?.models?.strong
45352
45868
  }
45353
45869
  );
45354
- recordCost("arbiter", "arbiter", seat?.models.strong ?? null, startedAt, result);
45870
+ recordCost("arbiter", "arbiter", seat?.model ?? seat?.models?.strong ?? null, startedAt, result);
45355
45871
  return result;
45356
45872
  },
45357
45873
  async runReviser(artifact, accepted) {
@@ -45513,10 +46029,10 @@ ${artifact}`,
45513
46029
  sandbox: "read-only",
45514
46030
  codexExecutable,
45515
46031
  // model-tier-planning-and-arbiter task 2.5 (D1): the arbiter is pinned to the seat's
45516
- // strongest model.
45517
- model: seat?.models.strong
46032
+ // default model.
46033
+ model: seat?.model ?? seat?.models?.strong
45518
46034
  });
45519
- recordCost("arbiter", "arbiter", seat?.models.strong ?? null, startedAt, result);
46035
+ recordCost("arbiter", "arbiter", seat?.model ?? seat?.models?.strong ?? null, startedAt, result);
45520
46036
  return result;
45521
46037
  },
45522
46038
  async runReviser(artifact, accepted) {
@@ -45644,10 +46160,10 @@ ${persona}`,
45644
46160
  sandbox: "read-only",
45645
46161
  codexExecutable,
45646
46162
  // model-tier-planning-and-arbiter task 2.5 (D1): the arbiter is pinned to the seat's
45647
- // strongest model.
45648
- model: seat?.models.strong
46163
+ // default model.
46164
+ model: seat?.model ?? seat?.models?.strong
45649
46165
  });
45650
- recordCost("arbiter", "arbiter", seat?.models.strong ?? null, startedAt, result);
46166
+ recordCost("arbiter", "arbiter", seat?.model ?? seat?.models?.strong ?? null, startedAt, result);
45651
46167
  return result;
45652
46168
  },
45653
46169
  async runReviser(artifact, accepted) {
@@ -45724,7 +46240,7 @@ You revise a deliverable to address the accepted issues so it satisfies the acce
45724
46240
  try {
45725
46241
  const diagnostics = Array.isArray(r["diagnostics"]) ? r["diagnostics"] : void 0;
45726
46242
  await client.appendExecutionArtifact(projectSlug, runId, {
45727
- id: `EA-${import_node_crypto4.default.randomUUID()}`,
46243
+ id: `EA-${import_node_crypto5.default.randomUUID()}`,
45728
46244
  kind: "verification",
45729
46245
  payload: {
45730
46246
  source: "deliverable-gate",
@@ -45826,23 +46342,23 @@ async function gate(artifact, prose, ctx) {
45826
46342
  }
45827
46343
 
45828
46344
  // src/telemetry/installation-id.ts
45829
- var import_node_crypto5 = require("node:crypto");
46345
+ var import_node_crypto6 = require("node:crypto");
45830
46346
  var import_node_fs10 = require("node:fs");
45831
- var import_node_path16 = require("node:path");
46347
+ var import_node_path17 = require("node:path");
45832
46348
  var FILE_NAME = "installation-id";
45833
46349
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
45834
46350
  var cache = /* @__PURE__ */ new Map();
45835
46351
  function resolveInstallationId(stateDir) {
45836
46352
  const cached2 = cache.get(stateDir);
45837
46353
  if (cached2 !== void 0) return cached2;
45838
- const path25 = (0, import_node_path16.join)(stateDir, FILE_NAME);
46354
+ const path25 = (0, import_node_path17.join)(stateDir, FILE_NAME);
45839
46355
  let id;
45840
46356
  try {
45841
46357
  id = (0, import_node_fs10.readFileSync)(path25, "utf8").trim();
45842
46358
  if (!UUID.test(id)) throw new Error("unusable");
45843
46359
  } catch {
45844
- id = (0, import_node_crypto5.randomUUID)();
45845
- (0, import_node_fs10.mkdirSync)((0, import_node_path16.dirname)(path25), { recursive: true });
46360
+ id = (0, import_node_crypto6.randomUUID)();
46361
+ (0, import_node_fs10.mkdirSync)((0, import_node_path17.dirname)(path25), { recursive: true });
45846
46362
  (0, import_node_fs10.writeFileSync)(path25, `${id}
45847
46363
  `, "utf8");
45848
46364
  }
@@ -45860,10 +46376,10 @@ function truncateCause(err) {
45860
46376
  return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
45861
46377
  }
45862
46378
  async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45863
- const telemetryDir = (0, import_node_path17.join)(stateDir, "telemetry");
46379
+ const telemetryDir = (0, import_node_path18.join)(stateDir, "telemetry");
45864
46380
  let files;
45865
46381
  try {
45866
- files = await (0, import_promises6.readdir)(telemetryDir);
46382
+ files = await (0, import_promises8.readdir)(telemetryDir);
45867
46383
  } catch (err) {
45868
46384
  if (err?.code === "ENOENT") return;
45869
46385
  throw err;
@@ -45876,24 +46392,24 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45876
46392
  const [, projectSlug, day] = match;
45877
46393
  const key = `${projectSlug}\0${day}`;
45878
46394
  const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
45879
- if (rowsMatch) entry.rowsPath = (0, import_node_path17.join)(telemetryDir, file2);
46395
+ if (rowsMatch) entry.rowsPath = (0, import_node_path18.join)(telemetryDir, file2);
45880
46396
  discovered.set(key, entry);
45881
46397
  }
45882
46398
  const today = telemetryDay();
45883
46399
  const pending = [];
45884
46400
  const deferred = [];
45885
46401
  for (const { projectSlug, day, rowsPath } of discovered.values()) {
45886
- const markerPath = (0, import_node_path17.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
46402
+ const markerPath = (0, import_node_path18.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
45887
46403
  if (rowsPath === null && day >= today) {
45888
46404
  try {
45889
- await (0, import_promises6.access)(markerPath);
46405
+ await (0, import_promises8.access)(markerPath);
45890
46406
  } catch {
45891
46407
  deferred.push({ projectSlug, day });
45892
46408
  }
45893
46409
  continue;
45894
46410
  }
45895
46411
  try {
45896
- await (0, import_promises6.access)(markerPath);
46412
+ await (0, import_promises8.access)(markerPath);
45897
46413
  } catch {
45898
46414
  pending.push({ projectSlug, day, rowsPath, markerPath });
45899
46415
  }
@@ -45903,10 +46419,10 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45903
46419
  const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
45904
46420
  pending.sort((a, b) => a.day.localeCompare(b.day));
45905
46421
  for (const cur of pending) {
45906
- const failurePath = (0, import_node_path17.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
46422
+ const failurePath = (0, import_node_path18.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
45907
46423
  let failureState = null;
45908
46424
  try {
45909
- const data = await (0, import_promises6.readFile)(failurePath, "utf8");
46425
+ const data = await (0, import_promises8.readFile)(failurePath, "utf8");
45910
46426
  failureState = JSON.parse(data);
45911
46427
  } catch {
45912
46428
  failureState = null;
@@ -45921,7 +46437,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45921
46437
  let raw = "";
45922
46438
  if (cur.rowsPath !== null) {
45923
46439
  try {
45924
- raw = await (0, import_promises6.readFile)(cur.rowsPath, "utf8");
46440
+ raw = await (0, import_promises8.readFile)(cur.rowsPath, "utf8");
45925
46441
  } catch (err) {
45926
46442
  console.error(`uploadPendingDays: failed to read ${cur.rowsPath}`, err);
45927
46443
  throw err;
@@ -45937,7 +46453,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45937
46453
  }
45938
46454
  const gateCalls = [];
45939
46455
  try {
45940
- const rawGate = await (0, import_promises6.readFile)((0, import_node_path17.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
46456
+ const rawGate = await (0, import_promises8.readFile)((0, import_node_path18.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
45941
46457
  for (const line of rawGate.split("\n")) {
45942
46458
  if (!line.trim()) continue;
45943
46459
  try {
@@ -45979,14 +46495,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45979
46495
  if (success2) {
45980
46496
  const tmpMarker = `${cur.markerPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
45981
46497
  try {
45982
- await (0, import_promises6.writeFile)(tmpMarker, "");
45983
- await (0, import_promises6.rename)(tmpMarker, cur.markerPath);
46498
+ await (0, import_promises8.writeFile)(tmpMarker, "");
46499
+ await (0, import_promises8.rename)(tmpMarker, cur.markerPath);
45984
46500
  } catch (err) {
45985
46501
  console.error(`uploadPendingDays: failed to write marker for ${cur.projectSlug}/${cur.day}`, err);
45986
46502
  }
45987
46503
  if (failureState) {
45988
46504
  try {
45989
- await (0, import_promises6.unlink)(failurePath);
46505
+ await (0, import_promises8.unlink)(failurePath);
45990
46506
  console.log(`uploadPendingDays: partition ${cur.projectSlug}/${cur.day} recovered after ${failureState.failureCount + 1} consecutive failures`);
45991
46507
  } catch (err) {
45992
46508
  console.error(`uploadPendingDays: failed to remove failure state for ${cur.projectSlug}/${cur.day}`, err);
@@ -46014,8 +46530,8 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
46014
46530
  };
46015
46531
  const tmpFailurePath = `${failurePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
46016
46532
  try {
46017
- await (0, import_promises6.writeFile)(tmpFailurePath, JSON.stringify(newFailureState));
46018
- await (0, import_promises6.rename)(tmpFailurePath, failurePath);
46533
+ await (0, import_promises8.writeFile)(tmpFailurePath, JSON.stringify(newFailureState));
46534
+ await (0, import_promises8.rename)(tmpFailurePath, failurePath);
46019
46535
  } catch (writeErr) {
46020
46536
  console.error(`uploadPendingDays: failed to write failure state for ${cur.projectSlug}/${cur.day}`, writeErr);
46021
46537
  }
@@ -46141,7 +46657,7 @@ async function collectAgentPoolSnapshot(deps) {
46141
46657
  }
46142
46658
 
46143
46659
  // src/external-agents-spawn.ts
46144
- var import_node_child_process10 = require("node:child_process");
46660
+ var import_node_child_process12 = require("node:child_process");
46145
46661
 
46146
46662
  // src/external-agents-bin.ts
46147
46663
  function resolveExternalAgentsCliInvocation(override) {
@@ -46187,7 +46703,7 @@ function runExternalAgentsCli(args, opts) {
46187
46703
  };
46188
46704
  let spawned;
46189
46705
  try {
46190
- spawned = (0, import_node_child_process10.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
46706
+ spawned = (0, import_node_child_process12.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
46191
46707
  } catch {
46192
46708
  done(1);
46193
46709
  return;
@@ -46299,14 +46815,14 @@ function startAgentPoolLoop(deps) {
46299
46815
  }
46300
46816
 
46301
46817
  // src/provider-readiness-loop.ts
46302
- var import_node_child_process11 = require("node:child_process");
46818
+ var import_node_child_process13 = require("node:child_process");
46303
46819
  var DEFAULT_INTERVAL_MS3 = 6e4;
46304
46820
  function providerReadinessLoopDisabled(env = process.env) {
46305
46821
  return env["MRRLIN_BRIDGE_PROVIDER_READINESS_DISABLE"] === "1";
46306
46822
  }
46307
46823
  function defaultRunnerFor(command) {
46308
46824
  return (args) => {
46309
- const r = (0, import_node_child_process11.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
46825
+ const r = (0, import_node_child_process13.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
46310
46826
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
46311
46827
  };
46312
46828
  }
@@ -46358,10 +46874,10 @@ function setSelectedProvider(value) {
46358
46874
  }
46359
46875
 
46360
46876
  // 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");
46877
+ var import_node_child_process15 = require("node:child_process");
46878
+ var import_node_crypto8 = __toESM(require("node:crypto"), 1);
46879
+ var import_node_path22 = __toESM(require("node:path"), 1);
46880
+ var import_node_util2 = require("node:util");
46365
46881
 
46366
46882
  // src/consensus/deliverable-gate-outcome.ts
46367
46883
  var MAX_DELIVERABLE_DIAGNOSTICS = 5;
@@ -46430,7 +46946,7 @@ function mapDeliverableGateResult(result) {
46430
46946
  }
46431
46947
 
46432
46948
  // src/async-tools/draft-spec.ts
46433
- var import_node_crypto6 = require("node:crypto");
46949
+ var import_node_crypto7 = require("node:crypto");
46434
46950
  var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
46435
46951
  var SPECS_FOLDER = "Specs";
46436
46952
  var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
@@ -46734,10 +47250,10 @@ async function runDraftSpec(ctx, input, deps) {
46734
47250
  timeoutMs: draftSpecTimeoutMs(),
46735
47251
  sandbox: "read-only",
46736
47252
  codexExecutable: ctx.codexExecutable,
46737
- // model-tier-planning-and-arbiter task 2.4 (D1): planning is pinned to the seat's strongest
47253
+ // model-tier-planning-and-arbiter task 2.4 (D1): planning is pinned to the seat's primary
46738
47254
  // model. Absent when ctx carries no seat (e.g. a hand-built test ctx) — runExec reproduces
46739
47255
  // today's argv byte-for-byte in that case (task 2.3).
46740
- model: ctx.seat?.models.strong
47256
+ model: ctx.seat?.model ?? ctx.seat?.models?.strong
46741
47257
  });
46742
47258
  if (!exec.ok) {
46743
47259
  return { kind: "retry", failureReason: "provider_unavailable", error: `spec authoring failed: ${exec.error}` };
@@ -46925,7 +47441,7 @@ function onComplete(outcome, input) {
46925
47441
  };
46926
47442
  }
46927
47443
  const summary = outcome.error;
46928
- const hash3 = (0, import_node_crypto6.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
47444
+ const hash3 = (0, import_node_crypto7.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
46929
47445
  return {
46930
47446
  kind: "info",
46931
47447
  id: `II-sched-draft-failed-${input.taskId}-${hash3}`,
@@ -47655,18 +48171,18 @@ async function awaitTurnWithDeadline(opts) {
47655
48171
  }
47656
48172
 
47657
48173
  // src/worktree.ts
47658
- var import_node_child_process12 = require("node:child_process");
48174
+ var import_node_child_process14 = require("node:child_process");
47659
48175
  var import_node_fs12 = require("node:fs");
47660
48176
  var import_node_os9 = require("node:os");
47661
- var import_node_path19 = require("node:path");
48177
+ var import_node_path20 = require("node:path");
47662
48178
 
47663
48179
  // src/checkout-lock.ts
47664
48180
  var import_node_fs11 = require("node:fs");
47665
- var import_node_path18 = require("node:path");
48181
+ var import_node_path19 = require("node:path");
47666
48182
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
47667
48183
  async function withCheckoutLock(locksDir, slug, fn) {
47668
48184
  (0, import_node_fs11.mkdirSync)(locksDir, { recursive: true });
47669
- const target = (0, import_node_path18.join)(locksDir, `${slug}.lock`);
48185
+ const target = (0, import_node_path19.join)(locksDir, `${slug}.lock`);
47670
48186
  if (!(0, import_node_fs11.existsSync)(target)) (0, import_node_fs11.writeFileSync)(target, "");
47671
48187
  const release = await import_proper_lockfile.default.lock(target, {
47672
48188
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
@@ -47683,16 +48199,16 @@ async function withCheckoutLock(locksDir, slug, fn) {
47683
48199
  function worktreeBranch(runId) {
47684
48200
  return `mrrlin/run-${runId}`;
47685
48201
  }
47686
- var defaultGitExec = (args, env) => (0, import_node_child_process12.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
48202
+ var defaultGitExec = (args, env) => (0, import_node_child_process14.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
47687
48203
  function git(checkout, args) {
47688
- return (0, import_node_child_process12.execFileSync)("git", ["-C", checkout, ...args], {
48204
+ return (0, import_node_child_process14.execFileSync)("git", ["-C", checkout, ...args], {
47689
48205
  encoding: "utf8",
47690
48206
  timeout: 3e4,
47691
48207
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
47692
48208
  });
47693
48209
  }
47694
48210
  async function createRunWorktree(opts) {
47695
- const worktreePath = (0, import_node_path19.join)(opts.worktreeRoot, opts.slug, opts.runId);
48211
+ const worktreePath = (0, import_node_path20.join)(opts.worktreeRoot, opts.slug, opts.runId);
47696
48212
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47697
48213
  (0, import_node_fs12.mkdirSync)(opts.worktreeRoot, { recursive: true });
47698
48214
  try {
@@ -47769,8 +48285,8 @@ async function doPushRunBranch(opts, execGit) {
47769
48285
  if (localConfig.trim()) {
47770
48286
  throw new Error(`push aborted: agent-controlled git config present in worktree: ${localConfig.trim().split("\n")[0]}`);
47771
48287
  }
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");
48288
+ const dir = (0, import_node_fs12.mkdtempSync)((0, import_node_path20.join)((0, import_node_os9.tmpdir)(), "mrrlin-push-"));
48289
+ const askpass = (0, import_node_path20.join)(dir, "askpass");
47774
48290
  try {
47775
48291
  (0, import_node_fs12.writeFileSync)(
47776
48292
  askpass,
@@ -47807,7 +48323,7 @@ async function sweepOrphanWorktrees(opts) {
47807
48323
  } catch {
47808
48324
  return opts.worktreeRoot;
47809
48325
  }
47810
- })() + import_node_path19.sep + opts.slug + import_node_path19.sep;
48326
+ })() + import_node_path20.sep + opts.slug + import_node_path20.sep;
47811
48327
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47812
48328
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"]);
47813
48329
  for (const block of listing.split("\n\n")) {
@@ -47970,13 +48486,13 @@ function effortDisabled(env = process.env) {
47970
48486
  // src/operator-token.ts
47971
48487
  var import_node_fs13 = require("node:fs");
47972
48488
  var import_node_os10 = __toESM(require("node:os"), 1);
47973
- var import_node_path20 = __toESM(require("node:path"), 1);
48489
+ var import_node_path21 = __toESM(require("node:path"), 1);
47974
48490
  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");
48491
+ 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
48492
  return base;
47977
48493
  }
47978
48494
  function operatorTokenPath() {
47979
- return import_node_path20.default.join(operatorDir(), "operator-token");
48495
+ return import_node_path21.default.join(operatorDir(), "operator-token");
47980
48496
  }
47981
48497
  function readOperatorToken() {
47982
48498
  try {
@@ -47993,7 +48509,7 @@ function persistOperatorToken(token) {
47993
48509
  `, { encoding: "utf8", mode: 384 });
47994
48510
  }
47995
48511
  function agentCredentialPath() {
47996
- return import_node_path20.default.join(operatorDir(), "agent-credential");
48512
+ return import_node_path21.default.join(operatorDir(), "agent-credential");
47997
48513
  }
47998
48514
  function persistAgentSecret(secret) {
47999
48515
  const dir = operatorDir();
@@ -48453,24 +48969,24 @@ function isBridgeGeneratedArtifact(artifact) {
48453
48969
  return typeof payload === "object" && payload !== null && "event" in payload;
48454
48970
  }
48455
48971
  function newArtifactId() {
48456
- return `EA-${import_node_crypto7.default.randomUUID()}`;
48972
+ return `EA-${import_node_crypto8.default.randomUUID()}`;
48457
48973
  }
48458
48974
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
48459
48975
  function isBlastRadiusFloorPath(path25) {
48460
48976
  return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path25));
48461
48977
  }
48462
- var execFileAsync = (0, import_node_util.promisify)(import_node_child_process13.execFile);
48978
+ var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process15.execFile);
48463
48979
  async function defaultListRunDiffPaths(opts) {
48464
48980
  const parse6 = (stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
48465
48981
  try {
48466
- const { stdout } = await execFileAsync(
48982
+ const { stdout } = await execFileAsync2(
48467
48983
  "git",
48468
48984
  ["-C", opts.worktreePath, "diff", "--name-only", `origin/${opts.defaultBranch}...HEAD`],
48469
48985
  { timeout: 3e4 }
48470
48986
  );
48471
48987
  return parse6(stdout);
48472
48988
  } catch {
48473
- const { stdout } = await execFileAsync(
48989
+ const { stdout } = await execFileAsync2(
48474
48990
  "git",
48475
48991
  ["-C", opts.worktreePath, "diff", "--name-only", `${opts.defaultBranch}...HEAD`],
48476
48992
  { timeout: 3e4 }
@@ -48695,7 +49211,7 @@ async function driveRun(deps, projectSlug, runId) {
48695
49211
  if (!claimed) return;
48696
49212
  if (!claimed.leaseId) {
48697
49213
  await deps.client.createInboxItem(projectSlug, {
48698
- id: `II-${import_node_crypto7.default.randomUUID()}`,
49214
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
48699
49215
  kind: "handoff",
48700
49216
  taskId: claimed.taskId,
48701
49217
  body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
@@ -48820,7 +49336,7 @@ async function driveRun(deps, projectSlug, runId) {
48820
49336
  resolvedProviderId = claimed.agentSeat;
48821
49337
  } else {
48822
49338
  const seat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
48823
- void notifyPinRetirementIfRetired(seat, { projectSlug });
49339
+ void notifyPinRetirementIfRetired(seat);
48824
49340
  resolvedProviderId = seat.id;
48825
49341
  await deps.client.updateExecutionRun(projectSlug, runId, { agentSeat: seat.id }).catch((err) => {
48826
49342
  console.warn(
@@ -49913,7 +50429,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
49913
50429
  }
49914
50430
  try {
49915
50431
  await deps.client.createInboxItem(projectSlug, {
49916
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50432
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49917
50433
  kind: "handoff",
49918
50434
  taskId: task.id,
49919
50435
  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 +50464,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
49948
50464
  }
49949
50465
  try {
49950
50466
  await deps.client.createInboxItem(projectSlug, {
49951
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50467
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
49952
50468
  kind: "handoff",
49953
50469
  taskId: task.id,
49954
50470
  body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
@@ -50088,8 +50604,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
50088
50604
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
50089
50605
  if (!worktreeRoot) return true;
50090
50606
  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);
50607
+ const relative = import_node_path22.default.relative(import_node_path22.default.resolve(worktreeRoot), import_node_path22.default.resolve(run3.worktreeId));
50608
+ return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path22.default.isAbsolute(relative);
50093
50609
  }
50094
50610
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
50095
50611
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -50107,7 +50623,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
50107
50623
  }).catch(() => {
50108
50624
  });
50109
50625
  await deps.client.createInboxItem(projectSlug, {
50110
- id: `II-${import_node_crypto7.default.randomUUID()}`,
50626
+ id: `II-${import_node_crypto8.default.randomUUID()}`,
50111
50627
  kind: "handoff",
50112
50628
  taskId: task.id,
50113
50629
  body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
@@ -50126,7 +50642,7 @@ function maxLeaseReclaims() {
50126
50642
  }
50127
50643
 
50128
50644
  // src/async-job-consumer.ts
50129
- var import_node_crypto9 = __toESM(require("node:crypto"), 1);
50645
+ var import_node_crypto10 = __toESM(require("node:crypto"), 1);
50130
50646
 
50131
50647
  // src/async-tools/registry.ts
50132
50648
  var registry2 = /* @__PURE__ */ new Map();
@@ -50139,8 +50655,8 @@ function getAsyncToolDescriptor(toolName) {
50139
50655
 
50140
50656
  // src/bridge-log.ts
50141
50657
  var import_node_fs14 = require("node:fs");
50142
- var import_promises7 = require("node:fs/promises");
50143
- var import_node_path22 = require("node:path");
50658
+ var import_promises9 = require("node:fs/promises");
50659
+ var import_node_path23 = require("node:path");
50144
50660
 
50145
50661
  // src/redact.ts
50146
50662
  var REDACTED = "[REDACTED]";
@@ -50165,7 +50681,7 @@ function redact(input) {
50165
50681
  }
50166
50682
 
50167
50683
  // src/telemetry/projector.ts
50168
- var import_node_crypto8 = require("node:crypto");
50684
+ var import_node_crypto9 = require("node:crypto");
50169
50685
  function isRecord3(x) {
50170
50686
  return typeof x === "object" && x !== null;
50171
50687
  }
@@ -50206,7 +50722,7 @@ function buildProjection(payload, type, ms, telemetry) {
50206
50722
  if (typeof exitCode === "number") proj.exitCode = exitCode;
50207
50723
  const status = tool.status;
50208
50724
  if (typeof status === "string" && status.trim() !== "") {
50209
- proj.statusHash = (0, import_node_crypto8.createHash)("sha256").update(status.trim().toLowerCase()).digest("hex").slice(0, 8);
50725
+ proj.statusHash = (0, import_node_crypto9.createHash)("sha256").update(status.trim().toLowerCase()).digest("hex").slice(0, 8);
50210
50726
  }
50211
50727
  return proj;
50212
50728
  }
@@ -50416,14 +50932,14 @@ function resolvePromptsEnabled(env = process.env) {
50416
50932
  }
50417
50933
  function createBridgeLogger(stateDir, env = process.env) {
50418
50934
  if (!resolveBridgeLogEnabled(env)) return NOOP_LOGGER;
50419
- const logsDir = (0, import_node_path22.join)(stateDir, "logs");
50935
+ const logsDir = (0, import_node_path23.join)(stateDir, "logs");
50420
50936
  try {
50421
50937
  (0, import_node_fs14.mkdirSync)(logsDir, { recursive: true });
50422
50938
  } catch {
50423
50939
  return NOOP_LOGGER;
50424
50940
  }
50425
50941
  const includePrompts = resolvePromptsEnabled(env);
50426
- const fileFor = () => (0, import_node_path22.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
50942
+ const fileFor = () => (0, import_node_path23.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
50427
50943
  const MAX_TRACKED_SESSIONS = 64;
50428
50944
  const contextSlugBySession = /* @__PURE__ */ new Map();
50429
50945
  const rememberContextSlug = (sessionId, payload) => {
@@ -50464,7 +50980,7 @@ function createBridgeLogger(stateDir, env = process.env) {
50464
50980
  return { isGap, isNewTurn };
50465
50981
  };
50466
50982
  const gainDay = (sessionId) => {
50467
- const sessionsPath = (0, import_node_path22.join)(logsDir, ".sessions.json");
50983
+ const sessionsPath = (0, import_node_path23.join)(logsDir, ".sessions.json");
50468
50984
  let sessionsObj = {};
50469
50985
  try {
50470
50986
  const parsed = JSON.parse((0, import_node_fs14.readFileSync)(sessionsPath, "utf8"));
@@ -50582,10 +51098,10 @@ function createBridgeLogger(stateDir, env = process.env) {
50582
51098
  };
50583
51099
  }
50584
51100
  async function findSessionDays(stateDir, sessionId) {
50585
- const sessionsPath = (0, import_node_path22.join)(stateDir, "logs", ".sessions.json");
51101
+ const sessionsPath = (0, import_node_path23.join)(stateDir, "logs", ".sessions.json");
50586
51102
  let sessionsObj;
50587
51103
  try {
50588
- const parsed = JSON.parse(await (0, import_promises7.readFile)(sessionsPath, "utf8"));
51104
+ const parsed = JSON.parse(await (0, import_promises9.readFile)(sessionsPath, "utf8"));
50589
51105
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return [];
50590
51106
  sessionsObj = parsed;
50591
51107
  } catch {
@@ -50714,7 +51230,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
50714
51230
  const delivery = descriptor2.onComplete(outcome, input);
50715
51231
  if (!delivery.suppressInbox) {
50716
51232
  await deps.client.createInboxItem(projectSlug, {
50717
- id: delivery.id ?? `II-${import_node_crypto9.default.randomUUID()}`,
51233
+ id: delivery.id ?? `II-${import_node_crypto10.default.randomUUID()}`,
50718
51234
  kind: delivery.kind,
50719
51235
  body: delivery.body,
50720
51236
  ...delivery.taskId ? { taskId: delivery.taskId } : {},
@@ -50732,13 +51248,13 @@ async function deriveRequestedHash(client, toolName, input) {
50732
51248
  if (input.requestedHash) return input.requestedHash;
50733
51249
  if (toolName === "run_spec_consensus" && input.pageId) {
50734
51250
  const page = await client.getWikiPage(input.projectSlug, input.pageId);
50735
- return page.contentHash ?? import_node_crypto9.default.createHash("sha256").update(page.markdownBody).digest("hex");
51251
+ return page.contentHash ?? import_node_crypto10.default.createHash("sha256").update(page.markdownBody).digest("hex");
50736
51252
  }
50737
51253
  if (toolName === "draft_task_spec" && input.taskId) {
50738
51254
  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");
51255
+ return task.updatedAt ?? import_node_crypto10.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
50740
51256
  }
50741
- return import_node_crypto9.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
51257
+ return import_node_crypto10.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
50742
51258
  }
50743
51259
  async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
50744
51260
  const projects = await deps.client.listProjects();
@@ -50765,11 +51281,11 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
50765
51281
 
50766
51282
  // src/state-dir.ts
50767
51283
  var import_node_os11 = __toESM(require("node:os"), 1);
50768
- var import_node_path23 = __toESM(require("node:path"), 1);
51284
+ var import_node_path24 = __toESM(require("node:path"), 1);
50769
51285
  function resolveStateDir(env = process.env) {
50770
51286
  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");
51287
+ if (codexHome) return import_node_path24.default.join(codexHome, "mrrlin", "director-bridge");
51288
+ return import_node_path24.default.join(import_node_os11.default.homedir(), ".mrrlin", "director-bridge");
50773
51289
  }
50774
51290
 
50775
51291
  // src/consensus/deliverable-gate.ts
@@ -50869,6 +51385,10 @@ async function compactChat(input, deps) {
50869
51385
  "",
50870
51386
  "Summary:"
50871
51387
  ].join("\n");
51388
+ const targetModel = input.model ?? input.weakModel;
51389
+ if (!targetModel) {
51390
+ throw new Error("CompactionInput requires either 'model' or 'weakModel'");
51391
+ }
50872
51392
  const exec = await runExec(
50873
51393
  {
50874
51394
  prompt,
@@ -50877,7 +51397,7 @@ async function compactChat(input, deps) {
50877
51397
  timeoutMs: input.timeoutMs,
50878
51398
  sandbox: "read-only",
50879
51399
  codexExecutable: input.codexExecutable,
50880
- model: input.weakModel
51400
+ model: targetModel
50881
51401
  },
50882
51402
  void 0,
50883
51403
  input.provider
@@ -51026,9 +51546,9 @@ function agentIdleMs(provider) {
51026
51546
 
51027
51547
  // src/thread-index.ts
51028
51548
  var import_node_fs15 = require("node:fs");
51029
- var import_node_path24 = __toESM(require("node:path"), 1);
51549
+ var import_node_path25 = __toESM(require("node:path"), 1);
51030
51550
  function threadIndexPath(stateDir) {
51031
- return import_node_path24.default.join(stateDir, "threads.json");
51551
+ return import_node_path25.default.join(stateDir, "threads.json");
51032
51552
  }
51033
51553
  function loadThreadIndex(stateDir, ttlMs, now) {
51034
51554
  const result = /* @__PURE__ */ new Map();
@@ -51193,10 +51713,10 @@ function createToolBusyClock(opts) {
51193
51713
  }
51194
51714
 
51195
51715
  // src/worker-token.ts
51196
- var import_node_crypto10 = require("node:crypto");
51716
+ var import_node_crypto11 = require("node:crypto");
51197
51717
  var import_node_fs16 = require("node:fs");
51198
51718
  var import_node_os12 = __toESM(require("node:os"), 1);
51199
- var import_node_path25 = __toESM(require("node:path"), 1);
51719
+ var import_node_path26 = __toESM(require("node:path"), 1);
51200
51720
  var DEFAULT_WORKER_PORT = 8792;
51201
51721
  function workerPort() {
51202
51722
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -51205,11 +51725,11 @@ function workerPort() {
51205
51725
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
51206
51726
  }
51207
51727
  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");
51728
+ 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");
51729
+ return import_node_path26.default.join(base, "worker");
51210
51730
  }
51211
51731
  function workerTokenPath() {
51212
- return import_node_path25.default.join(workerDir(), "token");
51732
+ return import_node_path26.default.join(workerDir(), "token");
51213
51733
  }
51214
51734
  function readWorkerToken() {
51215
51735
  try {
@@ -51224,17 +51744,17 @@ function readOrCreateWorkerToken() {
51224
51744
  if (existing) return existing;
51225
51745
  const dir = workerDir();
51226
51746
  (0, import_node_fs16.mkdirSync)(dir, { recursive: true, mode: 448 });
51227
- const token = (0, import_node_crypto10.randomBytes)(32).toString("hex");
51747
+ const token = (0, import_node_crypto11.randomBytes)(32).toString("hex");
51228
51748
  (0, import_node_fs16.writeFileSync)(workerTokenPath(), `${token}
51229
51749
  `, { encoding: "utf8", mode: 384 });
51230
51750
  return token;
51231
51751
  }
51232
51752
 
51233
51753
  // src/remote-phone-relay.ts
51234
- var import_node_events2 = require("node:events");
51754
+ var import_node_events3 = require("node:events");
51235
51755
  var import_node_fs17 = require("node:fs");
51236
51756
  var import_node_os13 = require("node:os");
51237
- var import_node_path26 = require("node:path");
51757
+ var import_node_path27 = require("node:path");
51238
51758
 
51239
51759
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
51240
51760
  var nc = __toESM(require("node:crypto"), 1);
@@ -54260,9 +54780,9 @@ var RelayClient = class {
54260
54780
  this.socket = null;
54261
54781
  this.nextHeartbeatAt = Number.POSITIVE_INFINITY;
54262
54782
  if (this.stopped || this.register === null) return;
54263
- const delay = this.backoff[Math.min(this.backoffIndex, this.backoff.length - 1)] ?? 0;
54783
+ const delay2 = this.backoff[Math.min(this.backoffIndex, this.backoff.length - 1)] ?? 0;
54264
54784
  this.backoffIndex += 1;
54265
- this.reconnectAt = this.deps.now() + delay;
54785
+ this.reconnectAt = this.deps.now() + delay2;
54266
54786
  }
54267
54787
  onMessage(data) {
54268
54788
  let frame;
@@ -54805,7 +55325,7 @@ var DirectorRelay = class {
54805
55325
 
54806
55326
  // src/remote-phone-relay.ts
54807
55327
  function loadOrCreateAgentDeviceKey() {
54808
- const path25 = (0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-device-key");
55328
+ const path25 = (0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-device-key");
54809
55329
  try {
54810
55330
  const raw = JSON.parse((0, import_node_fs17.readFileSync)(path25, "utf8"));
54811
55331
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
@@ -54815,7 +55335,7 @@ function loadOrCreateAgentDeviceKey() {
54815
55335
  }
54816
55336
  const kp = generateIdentityKeyPair();
54817
55337
  try {
54818
- (0, import_node_fs17.mkdirSync)((0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
55338
+ (0, import_node_fs17.mkdirSync)((0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
54819
55339
  (0, import_node_fs17.writeFileSync)(
54820
55340
  path25,
54821
55341
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
@@ -54825,7 +55345,7 @@ function loadOrCreateAgentDeviceKey() {
54825
55345
  }
54826
55346
  return kp;
54827
55347
  }
54828
- var AGENT_PAIRING_PATH = (0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-pairing.json");
55348
+ var AGENT_PAIRING_PATH = (0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-pairing.json");
54829
55349
  function loadAgentPairing() {
54830
55350
  try {
54831
55351
  const raw = JSON.parse((0, import_node_fs17.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
@@ -54843,14 +55363,14 @@ function loadAgentPairing() {
54843
55363
  }
54844
55364
  function saveAgentPairing(record2) {
54845
55365
  try {
54846
- (0, import_node_fs17.mkdirSync)((0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
55366
+ (0, import_node_fs17.mkdirSync)((0, import_node_path27.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
54847
55367
  (0, import_node_fs17.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
54848
55368
  } catch {
54849
55369
  }
54850
55370
  }
54851
55371
  function runPhoneTurn(handler, directorSessionId, text, emit) {
54852
55372
  return new Promise((resolve) => {
54853
- const emitter = new import_node_events2.EventEmitter();
55373
+ const emitter = new import_node_events3.EventEmitter();
54854
55374
  const fakeSocket = {
54855
55375
  on: (event, cb) => {
54856
55376
  emitter.on(event, cb);
@@ -55023,11 +55543,11 @@ async function renderPairingQrSvg(payload) {
55023
55543
 
55024
55544
  // src/checkout-registry.ts
55025
55545
  var import_node_fs18 = require("node:fs");
55026
- var import_node_path27 = require("node:path");
55546
+ var import_node_path28 = require("node:path");
55027
55547
  var CheckoutRegistry = class {
55028
55548
  file;
55029
55549
  constructor(stateDir) {
55030
- this.file = (0, import_node_path27.join)(stateDir, "checkouts.json");
55550
+ this.file = (0, import_node_path28.join)(stateDir, "checkouts.json");
55031
55551
  (0, import_node_fs18.mkdirSync)(stateDir, { recursive: true });
55032
55552
  }
55033
55553
  read() {
@@ -55084,7 +55604,7 @@ var CheckoutRegistry = class {
55084
55604
  };
55085
55605
 
55086
55606
  // src/checkout-handlers.ts
55087
- var import_node_child_process14 = require("node:child_process");
55607
+ var import_node_child_process16 = require("node:child_process");
55088
55608
  var import_node_fs19 = require("node:fs");
55089
55609
 
55090
55610
  // src/git-remote-match.ts
@@ -55130,7 +55650,7 @@ function validateCheckoutPath(checkoutPath, repo) {
55130
55650
  }
55131
55651
  let remoteUrl;
55132
55652
  try {
55133
- remoteUrl = (0, import_node_child_process14.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
55653
+ remoteUrl = (0, import_node_child_process16.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
55134
55654
  encoding: "utf8",
55135
55655
  stdio: ["ignore", "pipe", "ignore"],
55136
55656
  timeout: 15e3,
@@ -55181,11 +55701,11 @@ function checkoutStateData(projectSlug, entry, machineLabel) {
55181
55701
  }
55182
55702
 
55183
55703
  // src/executor-server.ts
55184
- var import_node_child_process15 = require("node:child_process");
55704
+ var import_node_child_process17 = require("node:child_process");
55185
55705
  function defaultReadinessRunner(provider) {
55186
55706
  const command = provider === "claude" ? "claude" : "codex";
55187
55707
  return (args) => {
55188
- const r = (0, import_node_child_process15.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
55708
+ const r = (0, import_node_child_process17.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
55189
55709
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
55190
55710
  };
55191
55711
  }
@@ -55428,7 +55948,7 @@ function extractVerificationSection(markdown) {
55428
55948
  // src/director-reseed.ts
55429
55949
  var import_node_fs20 = require("node:fs");
55430
55950
  var import_node_readline = require("node:readline");
55431
- var import_node_path28 = require("node:path");
55951
+ var import_node_path29 = require("node:path");
55432
55952
  function estimateTokens(s) {
55433
55953
  return Buffer.byteLength(s, "utf8");
55434
55954
  }
@@ -55560,7 +56080,7 @@ async function readSessionRows(logsDir, files, sessionIds) {
55560
56080
  const lines2 = [];
55561
56081
  let missingFiles = 0;
55562
56082
  for (const f of files) {
55563
- const filePath = (0, import_node_path28.join)(logsDir, f);
56083
+ const filePath = (0, import_node_path29.join)(logsDir, f);
55564
56084
  try {
55565
56085
  const stream = (0, import_node_fs20.createReadStream)(filePath, { encoding: "utf8" });
55566
56086
  const rl = (0, import_node_readline.createInterface)({ input: stream, crlfDelay: Infinity });
@@ -55588,10 +56108,10 @@ async function readSessionRows(logsDir, files, sessionIds) {
55588
56108
  // src/external-agents-scrub.ts
55589
56109
  var import_node_fs21 = __toESM(require("node:fs"), 1);
55590
56110
  var import_node_os14 = __toESM(require("node:os"), 1);
55591
- var import_node_path29 = __toESM(require("node:path"), 1);
56111
+ var import_node_path30 = __toESM(require("node:path"), 1);
55592
56112
  var REDACTION = "[REDACTED]";
55593
56113
  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");
56114
+ var KEYS_ENV_PATH = () => import_node_path30.default.join(import_node_os14.default.homedir(), ".local", "state", "external-agents", "keys.env");
55595
56115
  var keysEnvCache = null;
55596
56116
  function readKeysEnv() {
55597
56117
  const filePath = KEYS_ENV_PATH();
@@ -56035,9 +56555,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
56035
56555
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
56036
56556
  }
56037
56557
  function readCodexFallbackModels() {
56038
- const codexHome = process.env.CODEX_HOME?.trim() || import_node_path30.default.join(import_node_os15.default.homedir(), ".codex");
56558
+ const codexHome = process.env.CODEX_HOME?.trim() || import_node_path31.default.join(import_node_os15.default.homedir(), ".codex");
56039
56559
  const models = /* @__PURE__ */ new Map();
56040
- const cachePath = import_node_path30.default.join(codexHome, "models_cache.json");
56560
+ const cachePath = import_node_path31.default.join(codexHome, "models_cache.json");
56041
56561
  const cacheRaw = readTextIfExists(cachePath);
56042
56562
  if (cacheRaw) {
56043
56563
  try {
@@ -56087,7 +56607,7 @@ function readCodexFallbackModels() {
56087
56607
  );
56088
56608
  }
56089
56609
  }
56090
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path30.default.join(codexHome, "config.toml"))) {
56610
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path31.default.join(codexHome, "config.toml"))) {
56091
56611
  addBridgeModel(
56092
56612
  models,
56093
56613
  mapBridgeModel({
@@ -56101,11 +56621,11 @@ function readCodexFallbackModels() {
56101
56621
  })
56102
56622
  );
56103
56623
  }
56104
- const automationsDir = import_node_path30.default.join(codexHome, "automations");
56624
+ const automationsDir = import_node_path31.default.join(codexHome, "automations");
56105
56625
  try {
56106
56626
  for (const entry of import_node_fs22.default.readdirSync(automationsDir, { withFileTypes: true })) {
56107
56627
  if (!entry.isDirectory()) continue;
56108
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path30.default.join(automationsDir, entry.name, "automation.toml"))) {
56628
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path31.default.join(automationsDir, entry.name, "automation.toml"))) {
56109
56629
  addBridgeModel(
56110
56630
  models,
56111
56631
  mapBridgeModel({
@@ -56125,13 +56645,13 @@ function readCodexFallbackModels() {
56125
56645
  return [...models.values()];
56126
56646
  }
56127
56647
  function selfUpdateInboxItemId(offeredVersion) {
56128
- if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto11.randomUUID)()}`;
56648
+ if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto12.randomUUID)()}`;
56129
56649
  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);
56650
+ const hash3 = import_node_crypto12.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
56131
56651
  return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
56132
56652
  }
56133
56653
  function neutralCheckoutCwd(stateDir) {
56134
- const dir = import_node_path30.default.join(stateDir, "no-checkout");
56654
+ const dir = import_node_path31.default.join(stateDir, "no-checkout");
56135
56655
  try {
56136
56656
  import_node_fs22.default.mkdirSync(dir, { recursive: true });
56137
56657
  } catch {
@@ -56607,7 +57127,7 @@ function resolveDefaultBranch(checkoutPath) {
56607
57127
  if (!checkoutPath) return "main";
56608
57128
  const runGit = (args) => {
56609
57129
  try {
56610
- return (0, import_node_child_process16.execFileSync)("git", ["-C", checkoutPath, ...args], {
57130
+ return (0, import_node_child_process18.execFileSync)("git", ["-C", checkoutPath, ...args], {
56611
57131
  encoding: "utf8",
56612
57132
  stdio: ["ignore", "pipe", "ignore"],
56613
57133
  timeout: 15e3,
@@ -56757,7 +57277,7 @@ function createBridgeRequestListener(opts) {
56757
57277
  res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
56758
57278
  return;
56759
57279
  }
56760
- const nonce = import_node_crypto11.default.randomBytes(16).toString("base64url");
57280
+ const nonce = import_node_crypto12.default.randomBytes(16).toString("base64url");
56761
57281
  res.writeHead(200, { "content-type": "application/json" });
56762
57282
  res.end(JSON.stringify({ ok: true, wsUrl: `ws://${host}:${port}/ws`, token, nonce }));
56763
57283
  return;
@@ -56890,6 +57410,9 @@ function describeZeroOutputLimit(signal) {
56890
57410
  resetAt: signal.resetAt
56891
57411
  };
56892
57412
  }
57413
+ function shouldForwardRateLimits(capabilities) {
57414
+ return capabilities.pushesRateLimits;
57415
+ }
56893
57416
  var BOOTSTRAP_SEAT_REFRESH_TIMEOUT_MS = 3e3;
56894
57417
  function createBridgeMessageHandler(deps) {
56895
57418
  const tombstones = deps.tombstones ?? /* @__PURE__ */ new Map();
@@ -57057,7 +57580,7 @@ function createBridgeMessageHandler(deps) {
57057
57580
  }
57058
57581
  }
57059
57582
  socket.on("message", async (data) => {
57060
- const spanId = import_node_crypto11.default.randomUUID();
57583
+ const spanId = import_node_crypto12.default.randomUUID();
57061
57584
  if (logCtx) {
57062
57585
  logCtx.span.id = spanId;
57063
57586
  logCtx.span.at = Date.now();
@@ -57193,7 +57716,7 @@ function createBridgeMessageHandler(deps) {
57193
57716
  const result = await deps.runCompaction({
57194
57717
  history,
57195
57718
  provider: compactionSeat.id,
57196
- weakModel: compactionSeat.models.weak
57719
+ model: compactionSeat.model
57197
57720
  });
57198
57721
  const rawSeed = result.kind === "no-seed" ? result.note : result.seed;
57199
57722
  const seed = rawSeed.trim().length > 0 ? rawSeed : "No prior context could be carried forward.";
@@ -57376,7 +57899,15 @@ function createBridgeMessageHandler(deps) {
57376
57899
  const bootstrapProvider = resolveProvider(process.env, getSelectedProvider());
57377
57900
  bootstrapProviderId = bootstrapProvider.id;
57378
57901
  const bootstrapCapabilities = bootstrapProvider.capabilities();
57379
- fallbackModels = bootstrapCapabilities.listsModels ? readCodexFallbackModels() : [];
57902
+ const agyStaticFallback = bootstrapProviderId === "agy" && bootstrapCapabilities.modelCatalog.length > 0 ? bootstrapCapabilities.modelCatalog.map(
57903
+ (entry) => mapBridgeModel({
57904
+ id: entry.id,
57905
+ model: entry.id,
57906
+ displayName: entry.displayName,
57907
+ description: entry.description
57908
+ })
57909
+ ).filter((m) => m !== null) : [];
57910
+ fallbackModels = bootstrapProviderId === "codex" && bootstrapCapabilities.listsModels ? readCodexFallbackModels() : agyStaticFallback;
57380
57911
  if (!bootstrapCapabilities.listsModels) {
57381
57912
  const staticModels = /* @__PURE__ */ new Map();
57382
57913
  for (const entry of bootstrapCapabilities.modelCatalog) {
@@ -57390,7 +57921,7 @@ function createBridgeMessageHandler(deps) {
57390
57921
  }
57391
57922
  models = staticModels.size > 0 ? [...staticModels.values()] : null;
57392
57923
  }
57393
- const needsHandle = bootstrapCapabilities.listsModels || bootstrapCapabilities.readsRateLimits;
57924
+ const needsHandle = bootstrapCapabilities.listsModels || bootstrapCapabilities.pullsRateLimits;
57394
57925
  const codexClient2 = needsHandle ? await deps.acquireCodex(bootstrapProviderId) : null;
57395
57926
  try {
57396
57927
  if (codexClient2 && bootstrapCapabilities.listsModels) try {
@@ -57419,7 +57950,7 @@ function createBridgeMessageHandler(deps) {
57419
57950
  bootstrapError = error51 instanceof Error ? error51.message : String(error51);
57420
57951
  models = fallbackModels.length > 0 ? fallbackModels : null;
57421
57952
  }
57422
- if (codexClient2 && bootstrapCapabilities.readsRateLimits) {
57953
+ if (codexClient2 && bootstrapCapabilities.pullsRateLimits) {
57423
57954
  try {
57424
57955
  rateLimits = await codexClient2.readRateLimits();
57425
57956
  } catch (error51) {
@@ -57676,7 +58207,7 @@ function createBridgeMessageHandler(deps) {
57676
58207
  thread.inFlight = true;
57677
58208
  pendingTurnSessions.delete(directorSessionId);
57678
58209
  thread.replay = createReplayBuffer({
57679
- turnId: (0, import_node_crypto11.randomUUID)(),
58210
+ turnId: (0, import_node_crypto12.randomUUID)(),
57680
58211
  spanId,
57681
58212
  ...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
57682
58213
  ...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
@@ -57793,7 +58324,7 @@ function createBridgeMessageHandler(deps) {
57793
58324
  else if (event.type === "tool_result") toolBusy.end(event.tool.id);
57794
58325
  forward(event);
57795
58326
  if (event.type === "rate_limits") {
57796
- if (turnProviderCapabilities.readsRateLimits) {
58327
+ if (shouldForwardRateLimits(turnProviderCapabilities)) {
57797
58328
  sendInTurn({ type: "rateLimits", directorSessionId, rateLimits: event.snapshot });
57798
58329
  }
57799
58330
  const signal = detectExhaustedProviderLimit(event.snapshot, Date.now());
@@ -58079,7 +58610,7 @@ function parseConfig() {
58079
58610
  }
58080
58611
  function scanForOtherBridges() {
58081
58612
  try {
58082
- const result = (0, import_node_child_process16.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
58613
+ const result = (0, import_node_child_process18.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
58083
58614
  encoding: "utf8"
58084
58615
  });
58085
58616
  if (result.status !== 0) return [];
@@ -58255,8 +58786,8 @@ async function startDirectorBridge() {
58255
58786
  codexCwd: config2.codexCwd,
58256
58787
  codexExecutable: config2.codexExecutable,
58257
58788
  checkoutRegistry,
58258
- worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58259
- locksDir: import_node_path30.default.join(config2.stateDir, "locks"),
58789
+ worktreeRoot: import_node_path31.default.join(config2.stateDir, "worktrees"),
58790
+ locksDir: import_node_path31.default.join(config2.stateDir, "locks"),
58260
58791
  // Wire the executor server for code-execution runs. Each run gets its own provider process
58261
58792
  // (app-server for codex, a resident CLI child for claude) at the run worktree, running
58262
58793
  // UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
@@ -58300,7 +58831,7 @@ async function startDirectorBridge() {
58300
58831
  // egressDomains is retained in the seam signature (verification-turn.ts still computes the
58301
58832
  // env host) but no longer constrains anything — the executor is unrestricted.
58302
58833
  startSandbox: async (_egressDomains, providerId) => {
58303
- const cwd = import_node_fs22.default.mkdtempSync(import_node_path30.default.join(import_node_os15.default.tmpdir(), "mrrlin-verify-"));
58834
+ const cwd = import_node_fs22.default.mkdtempSync(import_node_path31.default.join(import_node_os15.default.tmpdir(), "mrrlin-verify-"));
58304
58835
  let executor;
58305
58836
  try {
58306
58837
  executor = await startExecutorServer({ worktree: cwd, provider: providerId });
@@ -58350,7 +58881,7 @@ async function startDirectorBridge() {
58350
58881
  };
58351
58882
  const sessionSinks = createSessionSinkRegistry();
58352
58883
  const tombstones = /* @__PURE__ */ new Map();
58353
- const bridgeInstanceId = (0, import_node_crypto11.randomUUID)();
58884
+ const bridgeInstanceId = (0, import_node_crypto12.randomUUID)();
58354
58885
  const asyncConsumerDeps = {
58355
58886
  client,
58356
58887
  run: wrappedTurnLock.run,
@@ -58528,7 +59059,7 @@ async function startDirectorBridge() {
58528
59059
  }
58529
59060
  const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
58530
59061
  const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
58531
- const { lines: lines2, missingFiles } = await readSessionRows(import_node_path30.default.join(config2.stateDir, "logs"), files, sessionIds);
59062
+ const { lines: lines2, missingFiles } = await readSessionRows(import_node_path31.default.join(config2.stateDir, "logs"), files, sessionIds);
58532
59063
  const { items, skipped: skipped2 } = extractItems(lines2, sessionIds);
58533
59064
  if (items.length === 0) return refuse2("no-rows");
58534
59065
  const budget = Math.max(0, Math.min(config2.reseedMaxTokens, config2.turnMaxTokens - args.otherBytes));
@@ -58621,10 +59152,11 @@ async function startDirectorBridge() {
58621
59152
  runExternalAgentsCli: (args, opts) => runExternalAgentsCli(args, { ...opts, envCliPath: process.env["EXTERNAL_AGENTS_CLI"] }),
58622
59153
  // Compaction runner for `compact-request` (agent-seat-surfaces task 2.5). Closes over `config`
58623
59154
  // (in scope here, unlike inside the handler) for cwd/executable, and the module-level budget +
58624
- // timeout constants. The handler supplies only the resolved seat's provider + weak model.
59155
+ // timeout constants. The handler supplies only the resolved seat's provider + default model.
58625
59156
  runCompaction: (args) => compactChat({
58626
59157
  history: args.history,
58627
59158
  provider: args.provider,
59159
+ model: args.model ?? args.weakModel,
58628
59160
  weakModel: args.weakModel,
58629
59161
  budgetBytes: DEFAULT_COMPACTION_SEED_BUDGET_BYTES,
58630
59162
  cwd: config2.codexCwd ?? process.cwd(),
@@ -58635,7 +59167,7 @@ async function startDirectorBridge() {
58635
59167
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
58636
59168
  let bridgeBinShaShort = "unknown00000";
58637
59169
  try {
58638
- bridgeBinShaShort = import_node_crypto11.default.createHash("sha256").update(import_node_fs22.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
59170
+ bridgeBinShaShort = import_node_crypto12.default.createHash("sha256").update(import_node_fs22.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
58639
59171
  } catch {
58640
59172
  }
58641
59173
  attachBridgeWss(server, {
@@ -58771,8 +59303,8 @@ async function startDirectorBridge() {
58771
59303
  );
58772
59304
  void runOrphanWorktreeSweep(client, {
58773
59305
  checkoutRegistry,
58774
- worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58775
- locksDir: import_node_path30.default.join(config2.stateDir, "locks")
59306
+ worktreeRoot: import_node_path31.default.join(config2.stateDir, "worktrees"),
59307
+ locksDir: import_node_path31.default.join(config2.stateDir, "locks")
58776
59308
  });
58777
59309
  {
58778
59310
  const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
@@ -59075,7 +59607,7 @@ function timingSafeTokenEqual(provided, expected) {
59075
59607
  const a = Buffer.from(provided);
59076
59608
  const b = Buffer.from(expected);
59077
59609
  if (a.length !== b.length) return false;
59078
- return import_node_crypto11.default.timingSafeEqual(a, b);
59610
+ return import_node_crypto12.default.timingSafeEqual(a, b);
59079
59611
  }
59080
59612
  function readDispatchBody(req) {
59081
59613
  return new Promise((resolve, reject) => {
@@ -59097,14 +59629,14 @@ function readDispatchBody(req) {
59097
59629
  function readOrCreateBridgeToken(stateDir) {
59098
59630
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
59099
59631
  if (explicit) return explicit;
59100
- const tokenPath = import_node_path30.default.join(stateDir, "token.txt");
59632
+ const tokenPath = import_node_path31.default.join(stateDir, "token.txt");
59101
59633
  try {
59102
59634
  const existing = import_node_fs22.default.readFileSync(tokenPath, "utf8").trim();
59103
59635
  if (existing) return existing;
59104
59636
  } catch {
59105
59637
  }
59106
59638
  import_node_fs22.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
59107
- const token = import_node_crypto11.default.randomBytes(32).toString("base64url");
59639
+ const token = import_node_crypto12.default.randomBytes(32).toString("base64url");
59108
59640
  import_node_fs22.default.writeFileSync(tokenPath, `${token}
59109
59641
  `, { mode: 384 });
59110
59642
  return token;
@@ -62494,36 +63026,36 @@ var StdioServerTransport = class {
62494
63026
  };
62495
63027
 
62496
63028
  // 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);
63029
+ var import_node_crypto15 = require("node:crypto");
63030
+ var import_promises12 = require("node:fs/promises");
63031
+ var import_node_path34 = __toESM(require("node:path"), 1);
62500
63032
  var import_node_os16 = __toESM(require("node:os"), 1);
62501
63033
 
62502
63034
  // ../../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);
63035
+ var import_promises10 = __toESM(require("node:fs/promises"), 1);
63036
+ var import_node_path32 = __toESM(require("node:path"), 1);
62505
63037
  var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
62506
63038
  function toPosixPath(input) {
62507
- return input.split(import_node_path31.default.sep).join("/");
63039
+ return input.split(import_node_path32.default.sep).join("/");
62508
63040
  }
62509
63041
  function slugifyWikiSegment(input) {
62510
63042
  return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
62511
63043
  }
62512
63044
  async function pathExists3(input) {
62513
63045
  try {
62514
- await import_promises8.default.access(input);
63046
+ await import_promises10.default.access(input);
62515
63047
  return true;
62516
63048
  } catch {
62517
63049
  return false;
62518
63050
  }
62519
63051
  }
62520
63052
  async function findWorkspaceRoot(start = process.cwd()) {
62521
- let current2 = import_node_path31.default.resolve(start);
63053
+ let current2 = import_node_path32.default.resolve(start);
62522
63054
  while (true) {
62523
- if (await pathExists3(import_node_path31.default.join(current2, "pnpm-workspace.yaml")) && await pathExists3(import_node_path31.default.join(current2, "docs"))) {
63055
+ if (await pathExists3(import_node_path32.default.join(current2, "pnpm-workspace.yaml")) && await pathExists3(import_node_path32.default.join(current2, "docs"))) {
62524
63056
  return current2;
62525
63057
  }
62526
- const parent = import_node_path31.default.dirname(current2);
63058
+ const parent = import_node_path32.default.dirname(current2);
62527
63059
  if (parent === current2) {
62528
63060
  throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
62529
63061
  }
@@ -62532,28 +63064,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
62532
63064
  }
62533
63065
  async function resolveDocsRoot(input) {
62534
63066
  if (input) {
62535
- return import_node_path31.default.resolve(input);
63067
+ return import_node_path32.default.resolve(input);
62536
63068
  }
62537
63069
  if (process.env.MRRLIN_DOCS_ROOT) {
62538
- return import_node_path31.default.resolve(process.env.MRRLIN_DOCS_ROOT);
63070
+ return import_node_path32.default.resolve(process.env.MRRLIN_DOCS_ROOT);
62539
63071
  }
62540
- return import_node_path31.default.join(await findWorkspaceRoot(), "docs");
63072
+ return import_node_path32.default.join(await findWorkspaceRoot(), "docs");
62541
63073
  }
62542
63074
  async function resolveIndexPath(input) {
62543
63075
  if (input) {
62544
- return import_node_path31.default.resolve(input);
63076
+ return import_node_path32.default.resolve(input);
62545
63077
  }
62546
63078
  if (process.env.MRRLIN_WIKI_INDEX_PATH) {
62547
- return import_node_path31.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
63079
+ return import_node_path32.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
62548
63080
  }
62549
63081
  const workspaceRoot = await findWorkspaceRoot();
62550
- return import_node_path31.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
63082
+ return import_node_path32.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
62551
63083
  }
62552
63084
  async function walkMarkdownFiles(root, dir = root) {
62553
- const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
63085
+ const entries = await import_promises10.default.readdir(dir, { withFileTypes: true });
62554
63086
  const files = [];
62555
63087
  for (const entry of entries) {
62556
- const absolute = import_node_path31.default.join(dir, entry.name);
63088
+ const absolute = import_node_path32.default.join(dir, entry.name);
62557
63089
  if (entry.isDirectory()) {
62558
63090
  files.push(...await walkMarkdownFiles(root, absolute));
62559
63091
  continue;
@@ -62572,7 +63104,7 @@ function parseTitle(markdown, sourcePath) {
62572
63104
  return title;
62573
63105
  }
62574
63106
  function documentFromFile(docsRoot, absolutePath, markdown) {
62575
- const relativePath = toPosixPath(import_node_path31.default.relative(docsRoot, absolutePath));
63107
+ const relativePath = toPosixPath(import_node_path32.default.relative(docsRoot, absolutePath));
62576
63108
  const [section, fileName] = relativePath.split("/");
62577
63109
  if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
62578
63110
  return null;
@@ -62592,7 +63124,7 @@ async function listWikiDocuments(options = {}) {
62592
63124
  const files = await walkMarkdownFiles(docsRoot);
62593
63125
  const documents = [];
62594
63126
  for (const file2 of files) {
62595
- const markdown = await import_promises8.default.readFile(file2, "utf8");
63127
+ const markdown = await import_promises10.default.readFile(file2, "utf8");
62596
63128
  const document2 = documentFromFile(docsRoot, file2, markdown);
62597
63129
  if (document2) {
62598
63130
  documents.push(document2);
@@ -62646,7 +63178,7 @@ async function buildWikiKnowledgeIndex(options = {}) {
62646
63178
  }
62647
63179
  async function loadBuiltWikiKnowledgeIndex(indexPath) {
62648
63180
  const resolvedIndexPath = await resolveIndexPath(indexPath);
62649
- const raw = await import_promises8.default.readFile(resolvedIndexPath, "utf8");
63181
+ const raw = await import_promises10.default.readFile(resolvedIndexPath, "utf8");
62650
63182
  return wikiKnowledgeIndexSchema.parse(JSON.parse(raw));
62651
63183
  }
62652
63184
  function tokenize(input) {
@@ -62770,15 +63302,15 @@ async function runCodeGate(_target, deps) {
62770
63302
  }
62771
63303
 
62772
63304
  // src/consensus/multi-llm-head.ts
62773
- var import_node_child_process18 = require("node:child_process");
63305
+ var import_node_child_process20 = require("node:child_process");
62774
63306
 
62775
63307
  // src/consensus/provider-limits.ts
62776
- var import_node_child_process17 = require("node:child_process");
63308
+ var import_node_child_process19 = require("node:child_process");
62777
63309
  var DEFAULT_STATUS_TIMEOUT_MS = 1e4;
62778
63310
  function errMessage4(err) {
62779
63311
  return err instanceof Error ? err.message : String(err);
62780
63312
  }
62781
- function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
63313
+ function runExternalAgentsStatus(bin, args, timeoutMs, spawn5) {
62782
63314
  return new Promise((resolve) => {
62783
63315
  let settled = false;
62784
63316
  const timerRef = { id: void 0 };
@@ -62791,7 +63323,7 @@ function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
62791
63323
  const options = { stdio: ["ignore", "pipe", "pipe"], env: process.env, shell: false };
62792
63324
  let child;
62793
63325
  try {
62794
- child = spawn4(bin, args, options);
63326
+ child = spawn5(bin, args, options);
62795
63327
  } catch (err) {
62796
63328
  finish({ stdout: "", error: `spawn ${bin} failed: ${errMessage4(err)}` });
62797
63329
  return;
@@ -62815,13 +63347,13 @@ function runExternalAgentsStatus(bin, args, timeoutMs, spawn4) {
62815
63347
  });
62816
63348
  }
62817
63349
  async function fetchRegistrySnapshot(deps) {
62818
- const spawn4 = deps?.spawn ?? import_node_child_process17.spawn;
63350
+ const spawn5 = deps?.spawn ?? import_node_child_process19.spawn;
62819
63351
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62820
63352
  const { stdout, error: error51 } = await runExternalAgentsStatus(
62821
63353
  command,
62822
63354
  [...prefixArgs, "status", "--json"],
62823
63355
  deps?.statusTimeoutMs ?? DEFAULT_STATUS_TIMEOUT_MS,
62824
- spawn4
63356
+ spawn5
62825
63357
  );
62826
63358
  if (error51) return { ok: false, error: error51 };
62827
63359
  try {
@@ -62865,7 +63397,7 @@ function estimateTokenCount(text) {
62865
63397
  function errMessage5(err) {
62866
63398
  return err instanceof Error ? err.message : String(err);
62867
63399
  }
62868
- function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
63400
+ function runExternalAgents(bin, args, label, timeoutMs, spawn5) {
62869
63401
  return new Promise((resolve) => {
62870
63402
  let settled = false;
62871
63403
  const timerRef = { id: void 0 };
@@ -62883,7 +63415,7 @@ function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
62883
63415
  };
62884
63416
  let child;
62885
63417
  try {
62886
- child = spawn4(bin, args, options);
63418
+ child = spawn5(bin, args, options);
62887
63419
  } catch (err) {
62888
63420
  finish({ code: null, stdout: "", error: `spawn ${bin} failed: ${errMessage5(err)}` });
62889
63421
  return;
@@ -62903,7 +63435,7 @@ function runExternalAgents(bin, args, label, timeoutMs, spawn4) {
62903
63435
  });
62904
63436
  }
62905
63437
  async function pickPanel(input, deps) {
62906
- const spawn4 = deps?.spawn ?? import_node_child_process18.spawn;
63438
+ const spawn5 = deps?.spawn ?? import_node_child_process20.spawn;
62907
63439
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62908
63440
  const args = [
62909
63441
  "pick",
@@ -62916,7 +63448,7 @@ async function pickPanel(input, deps) {
62916
63448
  "--exclude-providers",
62917
63449
  input.excludeProvider
62918
63450
  ];
62919
- const r = await runExternalAgents(command, [...prefixArgs, ...args], "pick", input.timeoutMs, spawn4);
63451
+ const r = await runExternalAgents(command, [...prefixArgs, ...args], "pick", input.timeoutMs, spawn5);
62920
63452
  if (r.error) return { ok: false, error: r.error };
62921
63453
  if (r.code === 3) return { ok: true, agents: [] };
62922
63454
  if (r.code !== 0) return { ok: false, error: `external-agents pick exited ${r.code}` };
@@ -62950,10 +63482,10 @@ function parseDispatch(agentId, stdout, exitCode) {
62950
63482
  return { ok: true, text: parsed.text, usage };
62951
63483
  }
62952
63484
  async function dispatchHead(agentId, prompt, timeoutMs, deps) {
62953
- const spawn4 = deps?.spawn ?? import_node_child_process18.spawn;
63485
+ const spawn5 = deps?.spawn ?? import_node_child_process20.spawn;
62954
63486
  const { command, prefixArgs } = resolveExternalAgentsCliInvocation(deps?.externalAgentsBin);
62955
63487
  const args = ["dispatch", agentId, "--json", prompt];
62956
- const r = await runExternalAgents(command, [...prefixArgs, ...args], "dispatch", timeoutMs, spawn4);
63488
+ const r = await runExternalAgents(command, [...prefixArgs, ...args], "dispatch", timeoutMs, spawn5);
62957
63489
  if (r.error) return { ok: false, error: r.error };
62958
63490
  return parseDispatch(agentId, r.stdout, r.code);
62959
63491
  }
@@ -65095,13 +65627,13 @@ var StreamableHTTPClientTransport = class {
65095
65627
  this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
65096
65628
  return;
65097
65629
  }
65098
- const delay = this._getNextReconnectionDelay(attemptCount);
65630
+ const delay2 = this._getNextReconnectionDelay(attemptCount);
65099
65631
  this._reconnectionTimeout = setTimeout(() => {
65100
65632
  this._startOrAuthSse(options).catch((error51) => {
65101
65633
  this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error51 instanceof Error ? error51.message : String(error51)}`));
65102
65634
  this._scheduleReconnection(options, attemptCount + 1);
65103
65635
  });
65104
- }, delay);
65636
+ }, delay2);
65105
65637
  }
65106
65638
  _handleSseStream(stream, options, isReconnectable) {
65107
65639
  if (!stream) {
@@ -65937,7 +66469,7 @@ async function runDecisionConsensus(input, deps) {
65937
66469
  }
65938
66470
 
65939
66471
  // src/async-tools/consensus.ts
65940
- var import_node_crypto12 = require("node:crypto");
66472
+ var import_node_crypto13 = require("node:crypto");
65941
66473
 
65942
66474
  // src/consensus/question-similarity.ts
65943
66475
  var SUPPRESSION_SIMILARITY_THRESHOLD = 0.6;
@@ -66217,9 +66749,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66217
66749
  }
66218
66750
  if (taskId) {
66219
66751
  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;
66752
+ 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
66753
  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)}`;
66754
+ const id = `II-${scopeId}-gate-${(0, import_node_crypto13.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
66223
66755
  try {
66224
66756
  const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
66225
66757
  await ctx.client.createInboxItem(input.projectSlug, {
@@ -66237,9 +66769,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66237
66769
  filedQuestionCount = toFile.length;
66238
66770
  } else if (planId) {
66239
66771
  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;
66772
+ 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
66773
  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)}`;
66774
+ const id = `II-${scopeId}-gate-${(0, import_node_crypto13.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
66243
66775
  try {
66244
66776
  const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
66245
66777
  await ctx.client.createInboxItem(input.projectSlug, {
@@ -66263,7 +66795,7 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
66263
66795
  taskId: page.taskId ?? null
66264
66796
  });
66265
66797
  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)}`;
66798
+ const baseBlockItemId = `II-${taskId}-gateblock-${(0, import_node_crypto13.createHash)("sha256").update(reviewHash).digest("hex").slice(0, 10)}`;
66267
66799
  const reviewAgainAvailable = !taskInboxItems.some(
66268
66800
  (item) => item.id === baseBlockItemId && item.status !== "pending" && item.answer === REVIEW_AGAIN_ANSWER
66269
66801
  );
@@ -66773,9 +67305,9 @@ async function runIntentCheck(ctx, input) {
66773
67305
  timeoutMs: intentCheckTimeoutMs(),
66774
67306
  sandbox: "read-only",
66775
67307
  codexExecutable: ctx.codexExecutable,
66776
- // model-tier-planning-and-arbiter task 2.6 (D1): the judge is pinned to the seat's strongest
67308
+ // model-tier-planning-and-arbiter task 2.6 (D1): the judge is pinned to the seat's primary
66777
67309
  // model.
66778
- model: ctx.seat?.models.strong
67310
+ model: ctx.seat?.model ?? ctx.seat?.models?.strong
66779
67311
  });
66780
67312
  if (!exec.ok) {
66781
67313
  return {
@@ -66837,8 +67369,8 @@ function createIntentCheckDescriptor() {
66837
67369
  var intentCheckDescriptor = createIntentCheckDescriptor();
66838
67370
 
66839
67371
  // src/evidence/assembler.ts
66840
- var import_promises9 = require("node:fs/promises");
66841
- var import_node_path32 = require("node:path");
67372
+ var import_promises11 = require("node:fs/promises");
67373
+ var import_node_path33 = require("node:path");
66842
67374
  function evidenceDedupKey(sessionId, reportId) {
66843
67375
  return `${sessionId}:${reportId}`;
66844
67376
  }
@@ -66848,7 +67380,7 @@ function isRecord7(v) {
66848
67380
  async function readDayLines(stateDir, day, sessionId) {
66849
67381
  let raw;
66850
67382
  try {
66851
- raw = await (0, import_promises9.readFile)((0, import_node_path32.join)(stateDir, "logs", `bridge-${day}.jsonl`), "utf8");
67383
+ raw = await (0, import_promises11.readFile)((0, import_node_path33.join)(stateDir, "logs", `bridge-${day}.jsonl`), "utf8");
66852
67384
  } catch {
66853
67385
  return [];
66854
67386
  }
@@ -66922,7 +67454,7 @@ async function assembleEvidence(stateDir, sessionId, reportId, gateCtx) {
66922
67454
  }
66923
67455
  let windowPruned = false;
66924
67456
  try {
66925
- const raw = await (0, import_promises9.readFile)((0, import_node_path32.join)(stateDir, "logs", ".pruned.jsonl"), "utf8");
67457
+ const raw = await (0, import_promises11.readFile)((0, import_node_path33.join)(stateDir, "logs", ".pruned.jsonl"), "utf8");
66926
67458
  outer: for (const line of raw.split("\n")) {
66927
67459
  if (!line.trim()) continue;
66928
67460
  let rec;
@@ -66988,7 +67520,7 @@ function createReportEvidenceDescriptor() {
66988
67520
  var reportEvidenceDescriptor = createReportEvidenceDescriptor();
66989
67521
 
66990
67522
  // src/async-tools/enqueue.ts
66991
- var import_node_crypto13 = __toESM(require("node:crypto"), 1);
67523
+ var import_node_crypto14 = __toESM(require("node:crypto"), 1);
66992
67524
  async function enqueueAsyncTool(client, descriptor2, input) {
66993
67525
  if (descriptor2.cachedResult) {
66994
67526
  const cached2 = await descriptor2.cachedResult(client, input);
@@ -67001,7 +67533,7 @@ async function enqueueAsyncTool(client, descriptor2, input) {
67001
67533
  if (active) {
67002
67534
  return { status: "already_running", jobId: active.id, message: "Already running; will notify in inbox." };
67003
67535
  }
67004
- const jobId = `AJ-${import_node_crypto13.default.randomUUID()}`;
67536
+ const jobId = `AJ-${import_node_crypto14.default.randomUUID()}`;
67005
67537
  try {
67006
67538
  await client.createAsyncJob(input.projectSlug, {
67007
67539
  id: jobId,
@@ -68661,7 +69193,7 @@ function createMrrlinTools(options) {
68661
69193
  "PRODUCED_URL_RECORD_FAILED",
68662
69194
  "Unable to record produced URL.",
68663
69195
  async (c, { projectSlug, runId, url: url2, label }) => {
68664
- const id = `EA-pu-${(0, import_node_crypto14.randomBytes)(4).toString("hex")}`;
69196
+ const id = `EA-pu-${(0, import_node_crypto15.randomBytes)(4).toString("hex")}`;
68665
69197
  const payload = label ? { url: url2, label } : { url: url2 };
68666
69198
  return await c.appendExecutionArtifact(projectSlug, runId, {
68667
69199
  id,
@@ -68735,7 +69267,7 @@ function createMrrlinTools(options) {
68735
69267
  "ARTIFACT_FILE_UPLOAD_FAILED",
68736
69268
  "Unable to upload artifact file.",
68737
69269
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
68738
- const extension2 = import_node_path33.default.extname(filePath).toLowerCase();
69270
+ const extension2 = import_node_path34.default.extname(filePath).toLowerCase();
68739
69271
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68740
69272
  if (!contentType) {
68741
69273
  throw new McpToolCodedError(
@@ -68743,7 +69275,7 @@ function createMrrlinTools(options) {
68743
69275
  `Unsupported artifact extension '${extension2}'. Allowed: ${Object.keys(ARTIFACT_EXTENSION_TYPES).join(", ")}.`
68744
69276
  );
68745
69277
  }
68746
- const stats = await (0, import_promises10.stat)(filePath);
69278
+ const stats = await (0, import_promises12.stat)(filePath);
68747
69279
  if (stats.size > MRRLIN_ARTIFACT_FILE_MAX_BYTES) {
68748
69280
  throw new McpToolCodedError(
68749
69281
  "ARTIFACT_FILE_TOO_LARGE",
@@ -68756,14 +69288,14 @@ function createMrrlinTools(options) {
68756
69288
  "File is empty (0 bytes); write content before uploading."
68757
69289
  );
68758
69290
  }
68759
- const bytes3 = new Uint8Array(await (0, import_promises10.readFile)(filePath));
69291
+ const bytes3 = new Uint8Array(await (0, import_promises12.readFile)(filePath));
68760
69292
  if (bytes3.byteLength > MRRLIN_ARTIFACT_FILE_MAX_BYTES) {
68761
69293
  throw new McpToolCodedError(
68762
69294
  "ARTIFACT_FILE_TOO_LARGE",
68763
69295
  "Artifact exceeds 5MB; split or summarize instead."
68764
69296
  );
68765
69297
  }
68766
- const filename = import_node_path33.default.basename(filePath);
69298
+ const filename = import_node_path34.default.basename(filePath);
68767
69299
  return deliverBuiltIn(
68768
69300
  c,
68769
69301
  projectSlug,
@@ -68785,7 +69317,7 @@ function createMrrlinTools(options) {
68785
69317
  `Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
68786
69318
  );
68787
69319
  }
68788
- const extension2 = import_node_path33.default.extname(filename).toLowerCase();
69320
+ const extension2 = import_node_path34.default.extname(filename).toLowerCase();
68789
69321
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68790
69322
  if (!contentType) {
68791
69323
  throw new McpToolCodedError(
@@ -69096,7 +69628,7 @@ function runSetCredential(args) {
69096
69628
  // src/install-service.ts
69097
69629
  var import_node_os17 = __toESM(require("node:os"), 1);
69098
69630
  var import_node_fs23 = require("node:fs");
69099
- var import_node_path34 = __toESM(require("node:path"), 1);
69631
+ var import_node_path35 = __toESM(require("node:path"), 1);
69100
69632
  function readExistingTelemetryDefaultProject(deps, ecoPath) {
69101
69633
  try {
69102
69634
  const existing = deps.readFile?.(ecoPath);
@@ -69217,9 +69749,9 @@ function installService(deps) {
69217
69749
  const claudeBin = deps.which("claude");
69218
69750
  const resolvedBins = [...bins, claudeBin].filter((b) => b !== null);
69219
69751
  const pathEnv = Array.from(
69220
- /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path34.default.dirname(b)), ...SYSTEM_PATH_DIRS])
69752
+ /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path35.default.dirname(b)), ...SYSTEM_PATH_DIRS])
69221
69753
  ).join(":");
69222
- const ecoPath = import_node_path34.default.join(home, ".mrrlin", "ecosystem.config.cjs");
69754
+ const ecoPath = import_node_path35.default.join(home, ".mrrlin", "ecosystem.config.cjs");
69223
69755
  const apiTarget = deriveServiceApiTarget(deps, ecoPath);
69224
69756
  const telemetryDefaultProject = "MRRLIN_TELEMETRY_DEFAULT_PROJECT" in deps.env ? deps.env.MRRLIN_TELEMETRY_DEFAULT_PROJECT?.trim() || void 0 : readExistingTelemetryDefaultProject(deps, ecoPath);
69225
69757
  const text = renderEcosystemConfig({
@@ -69283,18 +69815,18 @@ function uninstallService(deps) {
69283
69815
  }
69284
69816
 
69285
69817
  // src/uninstall-codex.ts
69286
- var import_promises11 = __toESM(require("node:fs/promises"), 1);
69818
+ var import_promises13 = __toESM(require("node:fs/promises"), 1);
69287
69819
  var import_node_os18 = __toESM(require("node:os"), 1);
69288
- var import_node_path35 = __toESM(require("node:path"), 1);
69820
+ var import_node_path36 = __toESM(require("node:path"), 1);
69289
69821
  var toml3 = __toESM(require_toml(), 1);
69290
69822
  function resolveCodexHome3(options) {
69291
69823
  if (options.codexHome) return options.codexHome;
69292
69824
  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");
69825
+ return import_node_path36.default.join(options.homeDir ?? import_node_os18.default.homedir(), ".codex");
69294
69826
  }
69295
69827
  async function pathExists4(target) {
69296
69828
  try {
69297
- await import_promises11.default.access(target);
69829
+ await import_promises13.default.access(target);
69298
69830
  return true;
69299
69831
  } catch {
69300
69832
  return false;
@@ -69303,13 +69835,13 @@ async function pathExists4(target) {
69303
69835
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
69304
69836
  async function uninstallCodex(options = {}) {
69305
69837
  const codexHome = resolveCodexHome3(options);
69306
- const configPath = import_node_path35.default.join(codexHome, "config.toml");
69838
+ const configPath = import_node_path36.default.join(codexHome, "config.toml");
69307
69839
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
69308
69840
  if (!await pathExists4(configPath)) {
69309
69841
  return { action: "missing", configPath, prompts: await removePrompts() };
69310
69842
  }
69311
- const realPath = await import_promises11.default.realpath(configPath).catch(() => configPath);
69312
- const existing = await import_promises11.default.readFile(realPath, "utf8");
69843
+ const realPath = await import_promises13.default.realpath(configPath).catch(() => configPath);
69844
+ const existing = await import_promises13.default.readFile(realPath, "utf8");
69313
69845
  let parsed = null;
69314
69846
  try {
69315
69847
  parsed = toml3.parse(existing);
@@ -69326,17 +69858,17 @@ async function uninstallCodex(options = {}) {
69326
69858
  return { action: "noop", configPath: realPath, prompts: await removePrompts() };
69327
69859
  }
69328
69860
  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 });
69861
+ await import_promises13.default.writeFile(realPath, stripped, { mode: 384 });
69330
69862
  return { action: "removed", configPath: realPath, prompts: await removePrompts() };
69331
69863
  }
69332
69864
  async function uninstallPrompts(codexHome, names) {
69333
69865
  if (names.length === 0) return [];
69334
- const promptsDir = import_node_path35.default.join(codexHome, "prompts");
69866
+ const promptsDir = import_node_path36.default.join(codexHome, "prompts");
69335
69867
  const out = [];
69336
69868
  for (const name of names) {
69337
- const promptPath = import_node_path35.default.join(promptsDir, `${name}.md`);
69869
+ const promptPath = import_node_path36.default.join(promptsDir, `${name}.md`);
69338
69870
  try {
69339
- await import_promises11.default.unlink(promptPath);
69871
+ await import_promises13.default.unlink(promptPath);
69340
69872
  out.push({ name, action: "removed", promptPath });
69341
69873
  } catch (error51) {
69342
69874
  const code = error51?.code;
@@ -69351,8 +69883,8 @@ async function uninstallPrompts(codexHome, names) {
69351
69883
  }
69352
69884
 
69353
69885
  // src/extract/command.ts
69354
- var import_promises12 = require("node:fs/promises");
69355
- var import_node_path36 = require("node:path");
69886
+ var import_promises14 = require("node:fs/promises");
69887
+ var import_node_path37 = require("node:path");
69356
69888
  function parseArgs(args) {
69357
69889
  const map2 = /* @__PURE__ */ new Map();
69358
69890
  for (let i = 0; i < args.length; i++) {
@@ -69389,10 +69921,10 @@ Missing required flag(s): ${missing.join(
69389
69921
  const days = await findSessionDays(deps.stateDir, sessionId);
69390
69922
  const matchingLines = [];
69391
69923
  for (const day of days) {
69392
- const logPath = (0, import_node_path36.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
69924
+ const logPath = (0, import_node_path37.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
69393
69925
  let raw;
69394
69926
  try {
69395
- raw = await (0, import_promises12.readFile)(logPath, "utf8");
69927
+ raw = await (0, import_promises14.readFile)(logPath, "utf8");
69396
69928
  } catch {
69397
69929
  continue;
69398
69930
  }
@@ -69426,7 +69958,7 @@ Missing required flag(s): ${missing.join(
69426
69958
  }
69427
69959
  const outputText = cappedLines.join("\n");
69428
69960
  if (outPath) {
69429
- await (0, import_promises12.writeFile)(outPath, outputText, "utf8");
69961
+ await (0, import_promises14.writeFile)(outPath, outputText, "utf8");
69430
69962
  return {
69431
69963
  ok: true,
69432
69964
  message: `Wrote extract to ${outPath}`,
@@ -69475,13 +70007,13 @@ Missing required flag(s): ${missing.join(
69475
70007
 
69476
70008
  // src/bin.ts
69477
70009
  function pm2Runner(args) {
69478
- const r = (0, import_node_child_process19.spawnSync)("pm2", args, { encoding: "utf8" });
70010
+ const r = (0, import_node_child_process21.spawnSync)("pm2", args, { encoding: "utf8" });
69479
70011
  process.stderr.write(r.stdout ?? "");
69480
70012
  process.stderr.write(r.stderr ?? "");
69481
70013
  return { code: r.status ?? 1, stdout: r.stdout ?? "" };
69482
70014
  }
69483
70015
  function whichBin(bin) {
69484
- const r = (0, import_node_child_process19.spawnSync)("which", [bin], { encoding: "utf8" });
70016
+ const r = (0, import_node_child_process21.spawnSync)("which", [bin], { encoding: "utf8" });
69485
70017
  const out = (r.stdout ?? "").trim();
69486
70018
  return r.status === 0 && out ? out.split("\n")[0] ?? null : null;
69487
70019
  }
@@ -69490,13 +70022,13 @@ function bootHookStatus() {
69490
70022
  const uid = process.getuid?.();
69491
70023
  if (uid === void 0 || uid === 0) return { status: "unknown" };
69492
70024
  const home = process.env.HOME ?? (0, import_node_os19.homedir)();
69493
- const agents = import_node_path38.default.join(home, "Library", "LaunchAgents");
70025
+ const agents = import_node_path39.default.join(home, "Library", "LaunchAgents");
69494
70026
  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`) }
70027
+ { label: "com.mrrlin.director-bridge", plist: import_node_path39.default.join(agents, "com.mrrlin.director-bridge.plist") },
70028
+ { label: "com.PM2", plist: import_node_path39.default.join(agents, `pm2.${(0, import_node_os19.userInfo)().username}.plist`) }
69497
70029
  ];
69498
70030
  for (const candidate of candidates) {
69499
- const printed = (0, import_node_child_process19.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
70031
+ const printed = (0, import_node_child_process21.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
69500
70032
  if (printed.status !== 0) continue;
69501
70033
  if (!(0, import_node_fs24.existsSync)(candidate.plist)) continue;
69502
70034
  const out = printed.stdout ?? "";
@@ -69718,7 +70250,7 @@ async function main() {
69718
70250
  );
69719
70251
  }
69720
70252
  const { command: command2, args, env } = browserServeArgs();
69721
- const r = (0, import_node_child_process19.spawnSync)(command2, args, { stdio: "inherit", env: { ...process.env, ...env } });
70253
+ const r = (0, import_node_child_process21.spawnSync)(command2, args, { stdio: "inherit", env: { ...process.env, ...env } });
69722
70254
  process.exitCode = r.status ?? 1;
69723
70255
  return;
69724
70256
  }
@@ -69729,7 +70261,7 @@ async function main() {
69729
70261
  }
69730
70262
  case "external-agents-serve": {
69731
70263
  const { command: command2, args } = externalAgentsServeArgs();
69732
- const r = (0, import_node_child_process19.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
70264
+ const r = (0, import_node_child_process21.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
69733
70265
  process.exitCode = r.status ?? 1;
69734
70266
  return;
69735
70267
  }
@@ -69783,8 +70315,8 @@ async function main() {
69783
70315
  }
69784
70316
  }
69785
70317
  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 });
70318
+ const codexHome = process.env.CODEX_HOME ?? import_node_path39.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".codex");
70319
+ (0, import_node_fs24.rmSync)(import_node_path39.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
69788
70320
  } catch {
69789
70321
  }
69790
70322
  const claudeResult = await installClaude({ binPath, force, serveEnv });
@@ -69797,7 +70329,7 @@ async function main() {
69797
70329
  );
69798
70330
  }
69799
70331
  const realProviderRunner = (command2) => (args) => {
69800
- const r = (0, import_node_child_process19.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
70332
+ const r = (0, import_node_child_process21.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
69801
70333
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
69802
70334
  };
69803
70335
  for (const provider of ["codex", "claude"]) {
@@ -69845,7 +70377,7 @@ async function main() {
69845
70377
  env: process.env,
69846
70378
  cwd: process.cwd(),
69847
70379
  writeFile: (p, c) => {
69848
- (0, import_node_fs24.mkdirSync)(import_node_path38.default.dirname(p), { recursive: true, mode: 448 });
70380
+ (0, import_node_fs24.mkdirSync)(import_node_path39.default.dirname(p), { recursive: true, mode: 448 });
69849
70381
  (0, import_node_fs24.writeFileSync)(p, c, { mode: 384 });
69850
70382
  },
69851
70383
  // Swallows every error on purpose — the only caller uses this to recover settings from the
@@ -69881,7 +70413,7 @@ async function main() {
69881
70413
  purgeSecret: purge,
69882
70414
  secretPath: agentCredentialPath(),
69883
70415
  tokenPath: operatorTokenPath(),
69884
- ecoPath: import_node_path38.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
70416
+ ecoPath: import_node_path39.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
69885
70417
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
69886
70418
  `)
69887
70419
  });
@@ -69902,7 +70434,7 @@ async function main() {
69902
70434
  purgeSecret: true,
69903
70435
  secretPath: agentCredentialPath(),
69904
70436
  tokenPath: operatorTokenPath(),
69905
- ecoPath: import_node_path38.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
70437
+ ecoPath: import_node_path39.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
69906
70438
  log
69907
70439
  });
69908
70440
  let codexOk = true;
@@ -69922,7 +70454,7 @@ async function main() {
69922
70454
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
69923
70455
  }
69924
70456
  try {
69925
- (0, import_node_fs24.rmSync)(import_node_path38.default.join(home, ".mrrlin"), { recursive: true, force: true });
70457
+ (0, import_node_fs24.rmSync)(import_node_path39.default.join(home, ".mrrlin"), { recursive: true, force: true });
69926
70458
  } catch {
69927
70459
  }
69928
70460
  log("removed ~/.mrrlin");
@@ -69963,7 +70495,7 @@ ${HELP_TEXT}`);
69963
70495
  }
69964
70496
  }
69965
70497
  function resolveSelfBinPath() {
69966
- return import_node_path37.default.resolve(process.argv[1] ?? process.execPath);
70498
+ return import_node_path38.default.resolve(process.argv[1] ?? process.execPath);
69967
70499
  }
69968
70500
  main().catch((error51) => {
69969
70501
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}