@lazehq/cli 0.1.21 → 0.1.23

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/laze.mjs +300 -243
  2. package/package.json +1 -1
package/dist/laze.mjs CHANGED
@@ -18733,8 +18733,8 @@ var require_snapshot_utils = __commonJS({
18733
18733
  var require_snapshot_recorder = __commonJS({
18734
18734
  "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
18735
18735
  "use strict";
18736
- var { writeFile: writeFile21, readFile: readFile35, mkdir: mkdir19 } = __require("node:fs/promises");
18737
- var { dirname: dirname19, resolve: resolve17 } = __require("node:path");
18736
+ var { writeFile: writeFile22, readFile: readFile37, mkdir: mkdir20 } = __require("node:fs/promises");
18737
+ var { dirname: dirname20, resolve: resolve17 } = __require("node:path");
18738
18738
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
18739
18739
  var { InvalidArgumentError, UndiciError } = require_errors();
18740
18740
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -18950,7 +18950,7 @@ var require_snapshot_recorder = __commonJS({
18950
18950
  throw new InvalidArgumentError("Snapshot path is required");
18951
18951
  }
18952
18952
  try {
18953
- const data = await readFile35(resolve17(path), "utf8");
18953
+ const data = await readFile37(resolve17(path), "utf8");
18954
18954
  const parsed = JSON.parse(data);
18955
18955
  if (Array.isArray(parsed)) {
18956
18956
  this.#snapshots.clear();
@@ -18980,12 +18980,12 @@ var require_snapshot_recorder = __commonJS({
18980
18980
  throw new InvalidArgumentError("Snapshot path is required");
18981
18981
  }
18982
18982
  const resolvedPath = resolve17(path);
18983
- await mkdir19(dirname19(resolvedPath), { recursive: true });
18983
+ await mkdir20(dirname20(resolvedPath), { recursive: true });
18984
18984
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
18985
18985
  hash: hash2,
18986
18986
  snapshot
18987
18987
  }));
18988
- await writeFile21(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
18988
+ await writeFile22(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
18989
18989
  }
18990
18990
  /**
18991
18991
  * Clears all recorded snapshots
@@ -35620,7 +35620,7 @@ function flagText({
35620
35620
  }
35621
35621
 
35622
35622
  // src/rules/cli-version.rules.ts
35623
- var STAMPED = "0.1.21";
35623
+ var STAMPED = "0.1.23";
35624
35624
  function cliVersionOf({ stamped = STAMPED } = {}) {
35625
35625
  return stamped.startsWith("__") ? "dev" : stamped;
35626
35626
  }
@@ -65404,8 +65404,8 @@ async function copyAgent({
65404
65404
  }
65405
65405
 
65406
65406
  // src/services/agent-commands.service.ts
65407
- import { mkdir as mkdir13, readFile as readFile12, writeFile as writeFile13 } from "node:fs/promises";
65408
- import { join as join13, resolve as resolve4 } from "node:path";
65407
+ import { mkdir as mkdir14, readFile as readFile13, writeFile as writeFile14 } from "node:fs/promises";
65408
+ import { join as join14, resolve as resolve4 } from "node:path";
65409
65409
 
65410
65410
  // src/rules/agent-profile.rules.ts
65411
65411
  var LEVELS = { fast: "Laze Fast", frontier: "Laze Frontier" };
@@ -67478,8 +67478,8 @@ function channelLabelIn(channel) {
67478
67478
  }
67479
67479
 
67480
67480
  // src/services/claude-wait.service.ts
67481
- import { readFile as readFile6, rm as rm2, writeFile as writeFile5, mkdir as mkdir5 } from "node:fs/promises";
67482
- import { dirname as dirname5 } from "node:path";
67481
+ import { readFile as readFile7, rm as rm2, writeFile as writeFile6, mkdir as mkdir6 } from "node:fs/promises";
67482
+ import { dirname as dirname6 } from "node:path";
67483
67483
 
67484
67484
  // src/rules/rush-host.rules.ts
67485
67485
  function rushSessionOf({
@@ -67495,13 +67495,63 @@ function rushSendCommand({ program, id }) {
67495
67495
  return ["sh", "-c", 'printf "%s\\n" "$LAZE_WAKE_TEXT" | "$0" session send "$1"', program, id];
67496
67496
  }
67497
67497
 
67498
+ // src/services/rush-host.service.ts
67499
+ import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
67500
+ import { dirname as dirname5, join as join6 } from "node:path";
67501
+ async function rushAboveOf({
67502
+ context,
67503
+ from = context.processes.pid
67504
+ }) {
67505
+ let pid = await context.processes.parentOf(from);
67506
+ for (let depth = 0; pid !== void 0 && pid > 1 && depth < 16; depth += 1) {
67507
+ const rush = rushSessionOf({ parentArgs: await context.processes.argsOf(pid) });
67508
+ if (rush) return rush;
67509
+ pid = await context.processes.parentOf(pid);
67510
+ }
67511
+ return void 0;
67512
+ }
67513
+ function guardPathOf({ context, claudePid }) {
67514
+ return join6(dirname5(context.environment.configPath), "rush-guards", `${claudePid}.json`);
67515
+ }
67516
+ async function startRushGuard({
67517
+ context,
67518
+ profile,
67519
+ claudePid,
67520
+ rush
67521
+ }) {
67522
+ const path = guardPathOf({ context, claudePid });
67523
+ const holder = await guardHolderOf({ path });
67524
+ if (holder && context.processes.alive(holder.pid)) return;
67525
+ const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
67526
+ const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
67527
+ const logPath = join6(dirname5(context.environment.configPath), "rush-guards", "guard.log");
67528
+ context.processes.spawnDetached({ argv: ["sh", "-c", '"$@" &', "sh", ...argv], logPath });
67529
+ }
67530
+ async function claimRushGuard({
67531
+ context,
67532
+ claudePid
67533
+ }) {
67534
+ const path = guardPathOf({ context, claudePid });
67535
+ const holder = await guardHolderOf({ path });
67536
+ const self2 = context.processes.pid;
67537
+ if (holder && holder.pid !== self2 && context.processes.alive(holder.pid)) return false;
67538
+ await mkdir5(dirname5(path), { recursive: true, mode: 448 });
67539
+ await writeFile5(path, JSON.stringify({ pid: self2, claudePid }), { mode: 384 });
67540
+ return true;
67541
+ }
67542
+ function guardHolderOf({ path }) {
67543
+ return readFile6(path, "utf8").then(
67544
+ (text2) => JSON.parse(text2),
67545
+ () => void 0
67546
+ );
67547
+ }
67548
+
67498
67549
  // src/services/claude-wait.service.ts
67499
67550
  var ROUND_SECONDS = 50;
67500
67551
  var WATCH_MS = 2e3;
67501
- var RUSH_RETRY_MS = 3e4;
67502
67552
  var CHANNEL_CHECK_MS = 5e3;
67503
67553
  async function holderOf({ path }) {
67504
- return readFile6(path, "utf8").then(
67554
+ return readFile7(path, "utf8").then(
67505
67555
  (text2) => JSON.parse(text2),
67506
67556
  () => void 0
67507
67557
  );
@@ -67525,8 +67575,8 @@ async function takeLock({
67525
67575
  if (served && context.processes.alive(served) && !mine3) return false;
67526
67576
  context.processes.stop(holder.pid);
67527
67577
  }
67528
- await mkdir5(dirname5(path), { recursive: true, mode: 448 });
67529
- await writeFile5(
67578
+ await mkdir6(dirname6(path), { recursive: true, mode: 448 });
67579
+ await writeFile6(
67530
67580
  path,
67531
67581
  JSON.stringify({
67532
67582
  pid: self2,
@@ -67632,26 +67682,16 @@ async function waitForMessages({ context, args }) {
67632
67682
  await rememberSession({ context, claudePid, session });
67633
67683
  const lock = statePathOf({ context, kind: "waiters", profile: name2 });
67634
67684
  if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
67635
- const seen = () => input2.transcript_path ? readFile6(input2.transcript_path, "utf8") : Promise.resolve("");
67685
+ const seen = () => input2.transcript_path ? readFile7(input2.transcript_path, "utf8") : Promise.resolve("");
67636
67686
  const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
67637
67687
  const rush = rushSessionOf({
67638
67688
  parentArgs: await context.processes.argsOf(await context.processes.parentOf(claudePid) ?? 0)
67639
67689
  });
67690
+ if (rush) await startRushGuard({ context, profile: name2, claudePid, rush });
67640
67691
  try {
67641
67692
  while (context.nowMs() < deadline) {
67642
67693
  const code = await settleRound({ context, client, name: name2, lock, claudePid, session, seen });
67643
- if (code === "again") continue;
67644
- if (code !== 0 || !rush || context.processes.alive(claudePid)) return code;
67645
- return await wakeThroughRush({
67646
- context,
67647
- client,
67648
- name: name2,
67649
- lock,
67650
- claudePid,
67651
- session,
67652
- rush,
67653
- deadline
67654
- });
67694
+ if (code !== "again") return code;
67655
67695
  }
67656
67696
  return 0;
67657
67697
  } finally {
@@ -67659,40 +67699,6 @@ async function waitForMessages({ context, args }) {
67659
67699
  await rm2(lock, { force: true });
67660
67700
  }
67661
67701
  }
67662
- async function rushRound({
67663
- context,
67664
- client,
67665
- name: name2,
67666
- lock,
67667
- claudePid,
67668
- session,
67669
- rush
67670
- }) {
67671
- if ((await holderOf({ path: lock }))?.pid !== context.processes.pid) return true;
67672
- const key = session ? sessionKeyOf({ session }) : void 0;
67673
- if (key && await liveElsewhere({ context, key, claudePid })) return true;
67674
- const due = await dueFromSpool({ context, profile: name2, seen: async () => "", pushedToo: true });
67675
- const messages = due.length > 0 ? due : await takeRound({ context, client, claudePid: 0, session });
67676
- if (messages.length === 0) return false;
67677
- await keepTaken({ context, profile: name2, messages });
67678
- const self2 = await currentNameOf({ context, client, profile: name2 });
67679
- const command = rushSendCommand(rush);
67680
- const env = { LAZE_WAKE_TEXT: hookContextOf({ messages, self: self2 }) };
67681
- const quiet = { write: () => true };
67682
- const sent = await context.runCommand({ command, env, stdout: quiet, stderr: quiet });
67683
- if (sent !== 0) return false;
67684
- await turnStarted({ context, client, agent: name2, messages }).catch(() => void 0);
67685
- await dropFromSpool({ context, profile: name2, messageIds: messages.map((m) => m.messageId) });
67686
- return true;
67687
- }
67688
- async function wakeThroughRush(round) {
67689
- while (round.context.nowMs() < round.deadline) {
67690
- const done = await rushRound(round).catch(() => "failed");
67691
- if (done === true) return 0;
67692
- await round.context.sleep(done === "failed" ? RUSH_RETRY_MS : 1e3);
67693
- }
67694
- return 0;
67695
- }
67696
67702
  async function waitHook({ context, args }) {
67697
67703
  try {
67698
67704
  return await waitForMessages({ context, args });
@@ -67715,7 +67721,7 @@ async function monitorServes({
67715
67721
  // src/services/codex-link.service.ts
67716
67722
  import { createReadStream } from "node:fs";
67717
67723
  import { readdir as readdir4, rm as rm6, stat as stat2 } from "node:fs/promises";
67718
- import { join as join11, resolve as resolve3 } from "node:path";
67724
+ import { join as join12, resolve as resolve3 } from "node:path";
67719
67725
  import { createInterface as createInterface2 } from "node:readline";
67720
67726
 
67721
67727
  // src/rules/connect-service.rules.ts
@@ -67835,8 +67841,8 @@ function rolloutEventOf({
67835
67841
 
67836
67842
  // src/services/codex-adopt.service.ts
67837
67843
  import { spawn as spawn2 } from "node:child_process";
67838
- import { mkdir as mkdir6, readdir as readdir2, readFile as readFile7, rm as rm3, stat, writeFile as writeFile6 } from "node:fs/promises";
67839
- import { dirname as dirname6, join as join6 } from "node:path";
67844
+ import { mkdir as mkdir7, readdir as readdir2, readFile as readFile8, rm as rm3, stat, writeFile as writeFile7 } from "node:fs/promises";
67845
+ import { dirname as dirname7, join as join7 } from "node:path";
67840
67846
  import { createInterface } from "node:readline";
67841
67847
 
67842
67848
  // src/rules/codex-requests.rules.ts
@@ -67956,11 +67962,11 @@ var CodexAppServer = class _CodexAppServer {
67956
67962
  }
67957
67963
  };
67958
67964
  async function newestThreadId({ codexHome }) {
67959
- const root = join6(codexHome, "sessions");
67965
+ const root = join7(codexHome, "sessions");
67960
67966
  const files2 = await readdir2(root, { recursive: true }).catch(() => []);
67961
67967
  const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
67962
67968
  const dated = await Promise.all(
67963
- rollouts.map(async (file3) => ({ file: file3, at: (await stat(join6(root, file3))).mtimeMs }))
67969
+ rollouts.map(async (file3) => ({ file: file3, at: (await stat(join7(root, file3))).mtimeMs }))
67964
67970
  );
67965
67971
  const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
67966
67972
  const id = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/.exec(newest);
@@ -68035,7 +68041,7 @@ async function answer({
68035
68041
  var MAX_RESTART_WAIT_SECONDS = 60;
68036
68042
  var HEALTHY_RUN_MS = 6e4;
68037
68043
  async function recordOf({ path }) {
68038
- return readFile7(path, "utf8").then(
68044
+ return readFile8(path, "utf8").then(
68039
68045
  (text2) => JSON.parse(text2),
68040
68046
  () => void 0
68041
68047
  );
@@ -68057,8 +68063,8 @@ async function startAdoptInBackground({
68057
68063
  const adopt = ["adopt", "codex", "--profile", profile, ...threadFlag({ thread: thread2 })];
68058
68064
  const argv = [...context.program, ...adopt, "--supervise"];
68059
68065
  const pid = context.processes.spawnDetached({ argv, logPath: log });
68060
- await mkdir6(dirname6(path), { recursive: true, mode: 448 });
68061
- await writeFile6(path, JSON.stringify({ pid, thread: thread2, log, startedAt: context.nowMs() }));
68066
+ await mkdir7(dirname7(path), { recursive: true, mode: 448 });
68067
+ await writeFile7(path, JSON.stringify({ pid, thread: thread2, log, startedAt: context.nowMs() }));
68062
68068
  return [
68063
68069
  `Started \`${laze} adopt codex\` in the background (pid ${pid}). It answers each Laze message`,
68064
68070
  `as a turn in ${thread2 ? `this Codex thread (${thread2})` : "the newest Codex thread"}, and starts again if it stops.`,
@@ -68138,7 +68144,7 @@ async function adoptedThreadOf({
68138
68144
  );
68139
68145
  if (!held) return threadId;
68140
68146
  const path = statePathOf({ context, kind: "adopt", profile, extension: "forks.json" });
68141
- const forks = await readFile7(path, "utf8").then(
68147
+ const forks = await readFile8(path, "utf8").then(
68142
68148
  (text2) => JSON.parse(text2),
68143
68149
  () => ({})
68144
68150
  );
@@ -68153,8 +68159,8 @@ async function adoptedThreadOf({
68153
68159
  }
68154
68160
  const forked = record3((await codex.call("thread/fork", { threadId })).thread).id;
68155
68161
  if (typeof forked !== "string") throw new Error("thread/fork answered no thread id");
68156
- await mkdir6(dirname6(path), { recursive: true, mode: 448 });
68157
- await writeFile6(path, JSON.stringify({ ...forks, [threadId]: forked }));
68162
+ await mkdir7(dirname7(path), { recursive: true, mode: 448 });
68163
+ await writeFile7(path, JSON.stringify({ ...forks, [threadId]: forked }));
68158
68164
  context.out(
68159
68165
  `Codex holds thread ${threadId} open elsewhere; answering in its new fork ${forked}.
68160
68166
  `
@@ -68209,20 +68215,20 @@ async function adoptCodex({ context, args }) {
68209
68215
  }
68210
68216
 
68211
68217
  // src/services/connect-delivery.service.ts
68212
- import { mkdir as mkdir8, readFile as readFile9, rename as rename3, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
68218
+ import { mkdir as mkdir9, readFile as readFile10, rename as rename3, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
68213
68219
  import { homedir as homedir2, hostname as hostname4 } from "node:os";
68214
- import { dirname as dirname8, join as join9 } from "node:path";
68220
+ import { dirname as dirname9, join as join10 } from "node:path";
68215
68221
 
68216
68222
  // src/services/codex-turn-watch.service.ts
68217
68223
  import { open as open2, readdir as readdir3 } from "node:fs/promises";
68218
- import { join as join7 } from "node:path";
68224
+ import { join as join8 } from "node:path";
68219
68225
  var READ_MS = 1500;
68220
68226
  var KEEP_WORKING_MS = 3e4;
68221
68227
  async function rolloutPathOf({ delivery }) {
68222
- const root = join7(delivery.codexHome, "sessions");
68228
+ const root = join8(delivery.codexHome, "sessions");
68223
68229
  const files2 = await readdir3(root, { recursive: true }).catch(() => []);
68224
68230
  const file3 = files2.find((name2) => name2.endsWith(`-${delivery.threadId}.jsonl`));
68225
- return file3 ? join7(root, file3) : void 0;
68231
+ return file3 ? join8(root, file3) : void 0;
68226
68232
  }
68227
68233
  async function readFrom({ path, offset }) {
68228
68234
  const handle = await open2(path, "r");
@@ -68308,8 +68314,8 @@ var CodexTurnWatch = class _CodexTurnWatch {
68308
68314
  };
68309
68315
 
68310
68316
  // src/services/openclaw-relay.service.ts
68311
- import { chmod as chmod2, mkdir as mkdir7, readFile as readFile8, writeFile as writeFile7 } from "node:fs/promises";
68312
- import { dirname as dirname7, join as join8 } from "node:path";
68317
+ import { chmod as chmod2, mkdir as mkdir8, readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
68318
+ import { dirname as dirname8, join as join9 } from "node:path";
68313
68319
 
68314
68320
  // ../../modules/openclaw/contract/src/openclaw.ts
68315
68321
  var workspaceIdSchema14 = external_exports.string().min(1);
@@ -68537,11 +68543,11 @@ var STOPS = /* @__PURE__ */ new Map([
68537
68543
  [OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
68538
68544
  ]);
68539
68545
  function relaysPathOf({ context }) {
68540
- return join8(dirname7(context.environment.configPath), "connect", "openclaw-relays.json");
68546
+ return join9(dirname8(context.environment.configPath), "connect", "openclaw-relays.json");
68541
68547
  }
68542
68548
  async function readRelays({ context }) {
68543
68549
  try {
68544
- return JSON.parse(await readFile8(relaysPathOf({ context }), "utf8"));
68550
+ return JSON.parse(await readFile9(relaysPathOf({ context }), "utf8"));
68545
68551
  } catch {
68546
68552
  return {};
68547
68553
  }
@@ -68551,8 +68557,8 @@ async function saveRelays({
68551
68557
  relays
68552
68558
  }) {
68553
68559
  const path = relaysPathOf({ context });
68554
- await mkdir7(dirname7(path), { recursive: true, mode: 448 });
68555
- await writeFile7(path, `${JSON.stringify(relays, null, 2)}
68560
+ await mkdir8(dirname8(path), { recursive: true, mode: 448 });
68561
+ await writeFile8(path, `${JSON.stringify(relays, null, 2)}
68556
68562
  `, { mode: 384 });
68557
68563
  await chmod2(path, 384);
68558
68564
  }
@@ -68738,14 +68744,14 @@ var RelayLoops = class _RelayLoops {
68738
68744
 
68739
68745
  // src/services/connect-delivery.service.ts
68740
68746
  function connectFolderOf({ context }) {
68741
- return join9(dirname8(context.environment.configPath), "connect");
68747
+ return join10(dirname9(context.environment.configPath), "connect");
68742
68748
  }
68743
68749
  function runStatePathOf({ context }) {
68744
- return join9(connectFolderOf({ context }), "run.json");
68750
+ return join10(connectFolderOf({ context }), "run.json");
68745
68751
  }
68746
68752
  async function readJson({ path }) {
68747
68753
  try {
68748
- return JSON.parse(await readFile9(path, "utf8"));
68754
+ return JSON.parse(await readFile10(path, "utf8"));
68749
68755
  } catch {
68750
68756
  return void 0;
68751
68757
  }
@@ -68896,9 +68902,9 @@ async function serveRounds({
68896
68902
  }
68897
68903
  var saves = 0;
68898
68904
  async function save(run4) {
68899
- await mkdir8(dirname8(run4.path), { recursive: true, mode: 448 });
68905
+ await mkdir9(dirname9(run4.path), { recursive: true, mode: 448 });
68900
68906
  const temporary = `${run4.path}.${run4.self}.${saves += 1}.tmp`;
68901
- await writeFile8(temporary, JSON.stringify(run4.state));
68907
+ await writeFile9(temporary, JSON.stringify(run4.state));
68902
68908
  await rename3(temporary, run4.path);
68903
68909
  }
68904
68910
  async function holdsLock(run4) {
@@ -68979,8 +68985,8 @@ async function runConnectLoop({ context }) {
68979
68985
 
68980
68986
  // src/services/connect-service.service.ts
68981
68987
  import { createHash } from "node:crypto";
68982
- import { mkdir as mkdir9, rm as rm5, writeFile as writeFile9 } from "node:fs/promises";
68983
- import { dirname as dirname9, join as join10 } from "node:path";
68988
+ import { mkdir as mkdir10, rm as rm5, writeFile as writeFile10 } from "node:fs/promises";
68989
+ import { dirname as dirname10, join as join11 } from "node:path";
68984
68990
  var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the service that delivers to linked Codex sessions.
68985
68991
 
68986
68992
  laze connect install install and start it (systemd --user, a LaunchAgent, or detached)
@@ -68993,17 +68999,17 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
68993
68999
  \`laze openclaw connect --local\`, whose OpenClaw relay it also runs.
68994
69000
  `;
68995
69001
  function installedPathOf({ context }) {
68996
- return join10(connectFolderOf({ context }), "service.json");
69002
+ return join11(connectFolderOf({ context }), "service.json");
68997
69003
  }
68998
69004
  function logPathOf({ context }) {
68999
- return join10(connectFolderOf({ context }), "connect.log");
69005
+ return join11(connectFolderOf({ context }), "connect.log");
69000
69006
  }
69001
69007
  function homeOf({ context }) {
69002
- return context.environment.inherited.HOME ?? dirname9(dirname9(context.environment.configPath));
69008
+ return context.environment.inherited.HOME ?? dirname10(dirname10(context.environment.configPath));
69003
69009
  }
69004
69010
  function serviceNameOf({ context }) {
69005
69011
  const { configPath } = context.environment;
69006
- if (configPath === join10(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
69012
+ if (configPath === join11(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
69007
69013
  return `laze-connect-${createHash("sha256").update(configPath).digest("hex").slice(0, 8)}`;
69008
69014
  }
69009
69015
  function serviceEnvOf({ context }) {
@@ -69026,10 +69032,10 @@ async function run({ context, command }) {
69026
69032
  async function installSystemd({ context }) {
69027
69033
  const name2 = serviceNameOf({ context });
69028
69034
  const env = context.environment.inherited;
69029
- const base = env.XDG_CONFIG_HOME || join10(homeOf({ context }), ".config");
69030
- const file3 = join10(base, "systemd", "user", `${name2}.service`);
69031
- await mkdir9(dirname9(file3), { recursive: true });
69032
- await writeFile9(
69035
+ const base = env.XDG_CONFIG_HOME || join11(homeOf({ context }), ".config");
69036
+ const file3 = join11(base, "systemd", "user", `${name2}.service`);
69037
+ await mkdir10(dirname10(file3), { recursive: true });
69038
+ await writeFile10(
69033
69039
  file3,
69034
69040
  systemdUnitOf({ argv: runArgvOf({ context }), env: serviceEnvOf({ context }) })
69035
69041
  );
@@ -69042,10 +69048,10 @@ async function installSystemd({ context }) {
69042
69048
  async function installLaunchd({ context }) {
69043
69049
  const name2 = serviceNameOf({ context });
69044
69050
  const label2 = `ai.laze.${name2}`;
69045
- const file3 = join10(homeOf({ context }), "Library", "LaunchAgents", `${label2}.plist`);
69051
+ const file3 = join11(homeOf({ context }), "Library", "LaunchAgents", `${label2}.plist`);
69046
69052
  const log = logPathOf({ context });
69047
- await mkdir9(dirname9(file3), { recursive: true });
69048
- await writeFile9(
69053
+ await mkdir10(dirname10(file3), { recursive: true });
69054
+ await writeFile10(
69049
69055
  file3,
69050
69056
  launchAgentOf({
69051
69057
  label: label2,
@@ -69097,8 +69103,8 @@ async function installConnectService({ context }) {
69097
69103
  const manager = await managerOf({ context });
69098
69104
  const install = { systemd: installSystemd, launchd: installLaunchd, detached: installDetached };
69099
69105
  const installed = await install[manager]({ context });
69100
- await mkdir9(dirname9(path), { recursive: true, mode: 448 });
69101
- await writeFile9(path, JSON.stringify(installed));
69106
+ await mkdir10(dirname10(path), { recursive: true, mode: 448 });
69107
+ await writeFile10(path, JSON.stringify(installed));
69102
69108
  return describeInstalled({ installed });
69103
69109
  }
69104
69110
  function describeInstalled({ installed }) {
@@ -69193,20 +69199,6 @@ async function connectService({ context, args }) {
69193
69199
  }
69194
69200
  }
69195
69201
 
69196
- // src/services/rush-host.service.ts
69197
- async function rushAboveOf({
69198
- context,
69199
- from = context.processes.pid
69200
- }) {
69201
- let pid = await context.processes.parentOf(from);
69202
- for (let depth = 0; pid !== void 0 && pid > 1 && depth < 16; depth += 1) {
69203
- const rush = rushSessionOf({ parentArgs: await context.processes.argsOf(pid) });
69204
- if (rush) return rush;
69205
- pid = await context.processes.parentOf(pid);
69206
- }
69207
- return void 0;
69208
- }
69209
-
69210
69202
  // src/services/codex-link.service.ts
69211
69203
  var ROLLOUTS_READ = 200;
69212
69204
  async function firstLineOf({ path }) {
@@ -69224,13 +69216,13 @@ async function newestThreadIn({
69224
69216
  codexHome,
69225
69217
  directory
69226
69218
  }) {
69227
- const root = join11(codexHome, "sessions");
69219
+ const root = join12(codexHome, "sessions");
69228
69220
  const files2 = await readdir4(root, { recursive: true }).catch(() => []);
69229
69221
  const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
69230
69222
  const dated = await Promise.all(
69231
69223
  rollouts.map(async (file3) => ({
69232
- path: join11(root, file3),
69233
- at: await stat2(join11(root, file3)).then(
69224
+ path: join12(root, file3),
69225
+ at: await stat2(join12(root, file3)).then(
69234
69226
  (info) => info.mtimeMs,
69235
69227
  () => 0
69236
69228
  )
@@ -69300,8 +69292,8 @@ async function linkCodexSession({
69300
69292
  }
69301
69293
 
69302
69294
  // src/services/laze-plugin.service.ts
69303
- import { mkdir as mkdir10, readFile as readFile10, writeFile as writeFile10 } from "node:fs/promises";
69304
- import { dirname as dirname10, join as join12 } from "node:path";
69295
+ import { mkdir as mkdir11, readFile as readFile11, writeFile as writeFile11 } from "node:fs/promises";
69296
+ import { dirname as dirname11, join as join13 } from "node:path";
69305
69297
 
69306
69298
  // src/rules/laze-plugin.rules.ts
69307
69299
  var LAZE_PLUGIN = "laze";
@@ -69417,11 +69409,11 @@ function lazePluginFiles({
69417
69409
  var REGISTER_LIMIT_MS = 6e4;
69418
69410
  var quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
69419
69411
  function pluginFolderOf({ context }) {
69420
- return join12(dirname10(context.environment.configPath), "plugins");
69412
+ return join13(dirname11(context.environment.configPath), "plugins");
69421
69413
  }
69422
69414
  async function pluginIsCurrent({ context }) {
69423
- const manifest = join12(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
69424
- const written = await readFile10(manifest, "utf8").then(
69415
+ const manifest = join13(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
69416
+ const written = await readFile11(manifest, "utf8").then(
69425
69417
  (text2) => JSON.parse(text2).version,
69426
69418
  () => void 0
69427
69419
  );
@@ -69435,9 +69427,9 @@ async function writeLazePlugin({ context }) {
69435
69427
  configPath: context.environment.configPath
69436
69428
  });
69437
69429
  for (const [path, text2] of Object.entries(files2)) {
69438
- const target = join12(folder, path);
69439
- await mkdir10(dirname10(target), { recursive: true });
69440
- await writeFile10(target, text2);
69430
+ const target = join13(folder, path);
69431
+ await mkdir11(dirname11(target), { recursive: true });
69432
+ await writeFile11(target, text2);
69441
69433
  }
69442
69434
  return folder;
69443
69435
  }
@@ -69459,10 +69451,10 @@ async function registerWithClaude({ context, folder }) {
69459
69451
  return code === 0;
69460
69452
  }
69461
69453
  function registeredMarkOf({ context }) {
69462
- return join12(pluginFolderOf({ context }), "registered");
69454
+ return join13(pluginFolderOf({ context }), "registered");
69463
69455
  }
69464
69456
  async function pluginRegistered({ context }) {
69465
- return readFile10(registeredMarkOf({ context }), "utf8").then(
69457
+ return readFile11(registeredMarkOf({ context }), "utf8").then(
69466
69458
  () => true,
69467
69459
  () => false
69468
69460
  );
@@ -69470,13 +69462,13 @@ async function pluginRegistered({ context }) {
69470
69462
  async function installLazePlugin({ context }) {
69471
69463
  const folder = await writeLazePlugin({ context });
69472
69464
  const registered = await registerWithClaude({ context, folder });
69473
- if (registered) await writeFile10(registeredMarkOf({ context }), cliVersionOf());
69465
+ if (registered) await writeFile11(registeredMarkOf({ context }), cliVersionOf());
69474
69466
  return { folder, registered };
69475
69467
  }
69476
69468
  async function plugin({ context, args }) {
69477
69469
  const action = args.words[1] ?? "install";
69478
69470
  if (action === "path") {
69479
- context.out(`${join12(pluginFolderOf({ context }), LAZE_PLUGIN)}
69471
+ context.out(`${join13(pluginFolderOf({ context }), LAZE_PLUGIN)}
69480
69472
  `);
69481
69473
  return 0;
69482
69474
  }
@@ -69494,8 +69486,8 @@ async function plugin({ context, args }) {
69494
69486
  }
69495
69487
 
69496
69488
  // src/services/mcp-channel.service.ts
69497
- import { mkdir as mkdir11, rm as rm7, writeFile as writeFile11 } from "node:fs/promises";
69498
- import { dirname as dirname11 } from "node:path";
69489
+ import { mkdir as mkdir12, rm as rm7, writeFile as writeFile12 } from "node:fs/promises";
69490
+ import { dirname as dirname12 } from "node:path";
69499
69491
  var LAZE_MCP_SERVER = "laze";
69500
69492
  var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
69501
69493
  var ROUND_SECONDS3 = 50;
@@ -69585,8 +69577,8 @@ async function pushInbox({
69585
69577
  signal
69586
69578
  }) {
69587
69579
  const marker = statePathOf({ context, kind: "channels", profile });
69588
- await mkdir11(dirname11(marker), { recursive: true, mode: 448 });
69589
- await writeFile11(marker, JSON.stringify({ pid: context.processes.pid }));
69580
+ await mkdir12(dirname12(marker), { recursive: true, mode: 448 });
69581
+ await writeFile12(marker, JSON.stringify({ pid: context.processes.pid }));
69590
69582
  try {
69591
69583
  while (!signal.aborted) {
69592
69584
  const messages = await client.post("/api/agents/me/inbox", { waitSeconds: ROUND_SECONDS3 }, { signal }).catch(async (error62) => {
@@ -69613,8 +69605,8 @@ async function pushInbox({
69613
69605
  }
69614
69606
 
69615
69607
  // src/services/plugin-tip.service.ts
69616
- import { mkdir as mkdir12, readFile as readFile11, writeFile as writeFile12 } from "node:fs/promises";
69617
- import { dirname as dirname12 } from "node:path";
69608
+ import { mkdir as mkdir13, readFile as readFile12, writeFile as writeFile13 } from "node:fs/promises";
69609
+ import { dirname as dirname13 } from "node:path";
69618
69610
  var RELOAD_TIP = "Laze: the Laze plugin is installed in Claude Code, and this session has not loaded it yet. Tell the user once, in one plain line, that it is optional: typing /reload-plugins makes Laze messages arrive right away; until then they still arrive through the hooks.";
69619
69611
  var LINK_RELOAD_TIP = "Tell the user once, in one plain line, that it is optional: typing /reload-plugins makes Laze messages arrive right away; until then they still arrive through the hooks.";
69620
69612
  function monitorsRunHere({ context }) {
@@ -69648,8 +69640,8 @@ async function markReloadTipTold({
69648
69640
  }) {
69649
69641
  if (!session) return;
69650
69642
  const path = toldPathOf({ context, session });
69651
- await mkdir12(dirname12(path), { recursive: true, mode: 448 });
69652
- await writeFile12(path, String(context.nowMs()), { mode: 384 });
69643
+ await mkdir13(dirname13(path), { recursive: true, mode: 448 });
69644
+ await writeFile13(path, String(context.nowMs()), { mode: 384 });
69653
69645
  }
69654
69646
  async function reloadTipOnce({
69655
69647
  context,
@@ -69657,7 +69649,7 @@ async function reloadTipOnce({
69657
69649
  }) {
69658
69650
  if (!session || !monitorsRunHere({ context })) return void 0;
69659
69651
  if (!await pluginRegistered({ context })) return void 0;
69660
- const told = await readFile11(toldPathOf({ context, session }), "utf8").then(
69652
+ const told = await readFile12(toldPathOf({ context, session }), "utf8").then(
69661
69653
  () => true,
69662
69654
  () => false
69663
69655
  );
@@ -69723,9 +69715,9 @@ async function installHooks({
69723
69715
  directory,
69724
69716
  profile
69725
69717
  }) {
69726
- const folder = join13(directory, ".claude");
69727
- const path = join13(folder, "settings.local.json");
69728
- const current2 = await readFile12(path, "utf8").then(
69718
+ const folder = join14(directory, ".claude");
69719
+ const path = join14(folder, "settings.local.json");
69720
+ const current2 = await readFile13(path, "utf8").then(
69729
69721
  (text2) => JSON.parse(text2),
69730
69722
  () => ({})
69731
69723
  );
@@ -69736,8 +69728,8 @@ async function installHooks({
69736
69728
  waitCommand: command("wait"),
69737
69729
  preToolCommand: command("pre-tool")
69738
69730
  });
69739
- await mkdir13(folder, { recursive: true });
69740
- await writeFile13(path, `${JSON.stringify(settings2, null, 2)}
69731
+ await mkdir14(folder, { recursive: true });
69732
+ await writeFile14(path, `${JSON.stringify(settings2, null, 2)}
69741
69733
  `);
69742
69734
  return path;
69743
69735
  }
@@ -69926,7 +69918,7 @@ async function reportTranscript({
69926
69918
  input: input2
69927
69919
  }) {
69928
69920
  if (!input2.transcript_path || !input2.session_id) return;
69929
- const lines = (await readFile12(input2.transcript_path, "utf8")).split("\n");
69921
+ const lines = (await readFile13(input2.transcript_path, "utf8")).split("\n");
69930
69922
  const context = readTranscript({ lines });
69931
69923
  await client.post("/api/agents/me/activity", {
69932
69924
  sessionId: input2.session_id,
@@ -69959,7 +69951,7 @@ async function handOver({ context, args }) {
69959
69951
  const kept = await dueFromSpool({
69960
69952
  context,
69961
69953
  profile: agent2,
69962
- seen: () => input2.transcript_path ? readFile12(input2.transcript_path, "utf8") : Promise.resolve(""),
69954
+ seen: () => input2.transcript_path ? readFile13(input2.transcript_path, "utf8") : Promise.resolve(""),
69963
69955
  pushedToo: false
69964
69956
  });
69965
69957
  const claim3 = forSession({ client, session });
@@ -69993,8 +69985,8 @@ async function addSessionStartWaiter({ context, args }) {
69993
69985
  const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
69994
69986
  const profile = flagText({ args, name: "profile" });
69995
69987
  if (!directory || !profile) return;
69996
- const path = join13(directory, ".claude", "settings.local.json");
69997
- const settings2 = await readFile12(path, "utf8").then(
69988
+ const path = join14(directory, ".claude", "settings.local.json");
69989
+ const settings2 = await readFile13(path, "utf8").then(
69998
69990
  (text2) => JSON.parse(text2),
69999
69991
  () => void 0
70000
69992
  );
@@ -70003,7 +69995,7 @@ async function addSessionStartWaiter({ context, args }) {
70003
69995
  }
70004
69996
  async function refreshPlugin({ context }) {
70005
69997
  if (await pluginIsCurrent({ context })) return;
70006
- const logPath = join13(pluginFolderOf({ context }), "install.log");
69998
+ const logPath = join14(pluginFolderOf({ context }), "install.log");
70007
69999
  context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
70008
70000
  }
70009
70001
  async function stopHook({ context, args }) {
@@ -70021,7 +70013,7 @@ async function stopHook({ context, args }) {
70021
70013
  }
70022
70014
 
70023
70015
  // src/services/agent-manage-commands.service.ts
70024
- import { readFile as readFile13 } from "node:fs/promises";
70016
+ import { readFile as readFile14 } from "node:fs/promises";
70025
70017
  import { extname, resolve as resolve5 } from "node:path";
70026
70018
 
70027
70019
  // src/rules/login-format.rules.ts
@@ -70150,7 +70142,7 @@ async function avatarOf({
70150
70142
  }) {
70151
70143
  const path = flagText({ args, name: "avatar" });
70152
70144
  if (!path) return void 0;
70153
- const bytes = await readFile13(resolve5(context.cwd, path)).catch(() => {
70145
+ const bytes = await readFile14(resolve5(context.cwd, path)).catch(() => {
70154
70146
  throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
70155
70147
  });
70156
70148
  const uploaded = await client.post("/api/agents/avatars", {
@@ -70840,8 +70832,8 @@ async function requestAgent({ context, args }) {
70840
70832
  }
70841
70833
 
70842
70834
  // src/services/app-commands.service.ts
70843
- import { mkdir as mkdir14, readdir as readdir5, readFile as readFile14, writeFile as writeFile15 } from "node:fs/promises";
70844
- import { dirname as dirname13, join as join15, relative as relative3, resolve as resolve6, sep as sep2 } from "node:path";
70835
+ import { mkdir as mkdir15, readdir as readdir5, readFile as readFile15, writeFile as writeFile16 } from "node:fs/promises";
70836
+ import { dirname as dirname14, join as join16, relative as relative3, resolve as resolve6, sep as sep2 } from "node:path";
70845
70837
 
70846
70838
  // ../../modules/app/contract/src/app.connections.ts
70847
70839
  var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
@@ -73232,9 +73224,9 @@ async function appPinsCommand({
73232
73224
 
73233
73225
  // src/services/app-script-check.service.ts
73234
73226
  import { execFile } from "node:child_process";
73235
- import { mkdtemp, rm as rm8, writeFile as writeFile14 } from "node:fs/promises";
73227
+ import { mkdtemp, rm as rm8, writeFile as writeFile15 } from "node:fs/promises";
73236
73228
  import { tmpdir } from "node:os";
73237
- import { join as join14 } from "node:path";
73229
+ import { join as join15 } from "node:path";
73238
73230
  import { promisify } from "node:util";
73239
73231
  var run2 = promisify(execFile);
73240
73232
  var MODULE_SYNTAX = /^\s*(import|export)\s/m;
@@ -73263,12 +73255,12 @@ async function scriptErrorsOf({
73263
73255
  const unknown2 = unknownCollectionsOf({ files: files2, collections });
73264
73256
  const scripts = files2.flatMap(scriptsOf);
73265
73257
  if (scripts.length === 0) return unknown2;
73266
- const dir = await mkdtemp(join14(tmpdir(), "laze-app-check-"));
73258
+ const dir = await mkdtemp(join15(tmpdir(), "laze-app-check-"));
73267
73259
  try {
73268
73260
  const errors = await Promise.all(
73269
73261
  scripts.map(async (script, index) => {
73270
- const file3 = join14(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
73271
- await writeFile14(file3, script.code);
73262
+ const file3 = join15(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
73263
+ await writeFile15(file3, script.code);
73272
73264
  try {
73273
73265
  await run2(process.execPath, ["--check", file3]);
73274
73266
  return null;
@@ -73417,7 +73409,7 @@ async function turnTokenOf({
73417
73409
  const pinned = env.LAZE_TURN_TOKEN?.trim();
73418
73410
  if (pinned) return pinned;
73419
73411
  if (env.LAZE_TURN_FILE) {
73420
- return readFile14(env.LAZE_TURN_FILE, "utf8").then(
73412
+ return readFile15(env.LAZE_TURN_FILE, "utf8").then(
73421
73413
  (text2) => text2.trim(),
73422
73414
  () => ""
73423
73415
  );
@@ -73443,7 +73435,7 @@ function folderOf({ context, word: word3 }) {
73443
73435
  return resolve6(context.cwd, word3 ?? ".");
73444
73436
  }
73445
73437
  async function readManifest(folder) {
73446
- const text2 = await readFile14(join15(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
73438
+ const text2 = await readFile15(join16(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
73447
73439
  if (text2 === void 0) return void 0;
73448
73440
  const parsed = appManifestSchema.safeParse(JSON.parse(text2));
73449
73441
  if (!parsed.success) {
@@ -73478,7 +73470,7 @@ async function jsonFlag({
73478
73470
  }) {
73479
73471
  const raw = flagText({ args, name: name2 });
73480
73472
  if (!raw) return void 0;
73481
- const text2 = raw.startsWith("@") ? await readFile14(resolve6(context.cwd, raw.slice(1)), "utf8") : raw;
73473
+ const text2 = raw.startsWith("@") ? await readFile15(resolve6(context.cwd, raw.slice(1)), "utf8") : raw;
73482
73474
  try {
73483
73475
  return JSON.parse(text2);
73484
73476
  } catch {
@@ -73491,7 +73483,7 @@ async function listFiles(folder) {
73491
73483
  while (pending.length > 0 && found.length <= MAX_FILES) {
73492
73484
  const current2 = pending.pop() ?? folder;
73493
73485
  for (const entry of await readdir5(current2, { withFileTypes: true })) {
73494
- const path = join15(current2, entry.name);
73486
+ const path = join16(current2, entry.name);
73495
73487
  const rel = relative3(folder, path).split(sep2).join("/");
73496
73488
  if (isSkippedPath({ path: rel })) continue;
73497
73489
  if (entry.isDirectory()) pending.push(path);
@@ -73532,11 +73524,11 @@ var appCreate = async ({ context, args }) => {
73532
73524
  ...visibility ? { visibility } : {}
73533
73525
  });
73534
73526
  const folder = resolve6(context.cwd, flagText({ args, name: "dir", fallback: app2.slug }));
73535
- await mkdir14(folder, { recursive: true });
73527
+ await mkdir15(folder, { recursive: true });
73536
73528
  const files2 = template ? templateFiles({ template, name: name2 }) : {};
73537
73529
  for (const [path, content] of Object.entries(files2)) {
73538
- await mkdir14(dirname13(join15(folder, path)), { recursive: true });
73539
- await writeFile15(join15(folder, path), content);
73530
+ await mkdir15(dirname14(join16(folder, path)), { recursive: true });
73531
+ await writeFile16(join16(folder, path), content);
73540
73532
  }
73541
73533
  const manifest = {
73542
73534
  app: { id: app2.id, name: app2.name, slug: app2.slug },
@@ -73544,7 +73536,7 @@ var appCreate = async ({ context, args }) => {
73544
73536
  views: template?.views ? [...template.views] : [],
73545
73537
  seed: template ? { ...template.seed } : {}
73546
73538
  };
73547
- await writeFile15(join15(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
73539
+ await writeFile16(join16(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
73548
73540
  `);
73549
73541
  print5({
73550
73542
  context,
@@ -73581,7 +73573,7 @@ var appPush = async ({ context, args }) => {
73581
73573
  paths.map(
73582
73574
  async (path) => buildFileOf({
73583
73575
  path: relative3(folder, path).split(sep2).join("/"),
73584
- bytes: await readFile14(path)
73576
+ bytes: await readFile15(path)
73585
73577
  })
73586
73578
  )
73587
73579
  );
@@ -73956,7 +73948,7 @@ var appExport = async ({ context, args }) => {
73956
73948
  const out = flagText({ args, name: "out" });
73957
73949
  if (!out) return context.out(exported.body);
73958
73950
  const target = resolve6(context.cwd, out);
73959
- await writeFile15(target, exported.body);
73951
+ await writeFile16(target, exported.body);
73960
73952
  context.out(`Wrote ${exported.rows} records to ${relative3(context.cwd, target)}
73961
73953
  `);
73962
73954
  };
@@ -73964,7 +73956,7 @@ var appImport = async ({ context, args }) => {
73964
73956
  const words = args.words.slice(2);
73965
73957
  const [named, collection, file3] = words.length >= 3 ? words : [void 0, ...words];
73966
73958
  if (!collection || !file3) throw new CliUsageError(USAGE5);
73967
- const csv = await readFile14(resolve6(context.cwd, file3), "utf8").catch(() => {
73959
+ const csv = await readFile15(resolve6(context.cwd, file3), "utf8").catch(() => {
73968
73960
  throw new CliUsageError(`Cannot read ${file3}`);
73969
73961
  });
73970
73962
  const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
@@ -73983,7 +73975,7 @@ var appImport = async ({ context, args }) => {
73983
73975
  });
73984
73976
  const refusedOut = flagText({ args, name: "refused" });
73985
73977
  if (refusedOut && result.refusedCsv) {
73986
- await writeFile15(resolve6(context.cwd, refusedOut), result.refusedCsv);
73978
+ await writeFile16(resolve6(context.cwd, refusedOut), result.refusedCsv);
73987
73979
  }
73988
73980
  const fitting = result.rows - result.refused.length;
73989
73981
  const skipped = result.refused.slice(0, 20).map((row) => ` line ${row.line}: ${row.reason}
@@ -74530,8 +74522,8 @@ async function billing({ context, args }) {
74530
74522
 
74531
74523
  // src/services/browser-commands.service.ts
74532
74524
  import { randomBytes } from "node:crypto";
74533
- import { mkdir as mkdir15, readFile as readFile15, writeFile as writeFile16 } from "node:fs/promises";
74534
- import { dirname as dirname14, join as join16 } from "node:path";
74525
+ import { mkdir as mkdir16, readFile as readFile16, writeFile as writeFile17 } from "node:fs/promises";
74526
+ import { dirname as dirname15, join as join17 } from "node:path";
74535
74527
 
74536
74528
  // src/services/browser-tab-commands.service.ts
74537
74529
  var BROWSER_TAB_PATHS = {
@@ -75077,7 +75069,7 @@ async function turnTokenOf2({ context }) {
75077
75069
  const pinned = env.LAZE_TURN_TOKEN?.trim();
75078
75070
  if (pinned) return pinned;
75079
75071
  if (!env.LAZE_TURN_FILE) return "";
75080
- return readFile15(env.LAZE_TURN_FILE, "utf8").then(
75072
+ return readFile16(env.LAZE_TURN_FILE, "utf8").then(
75081
75073
  (text2) => text2.trim(),
75082
75074
  () => ""
75083
75075
  );
@@ -75151,7 +75143,7 @@ async function cdp({ context, args }) {
75151
75143
  }
75152
75144
  function bridgeStatePath({ context, machine: machine2 }) {
75153
75145
  const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
75154
- return join16(dirname14(context.environment.configPath), "bridges", `${safe}.json`);
75146
+ return join17(dirname15(context.environment.configPath), "bridges", `${safe}.json`);
75155
75147
  }
75156
75148
  async function bridgePort({
75157
75149
  context,
@@ -75159,7 +75151,7 @@ async function bridgePort({
75159
75151
  access
75160
75152
  }) {
75161
75153
  const path = bridgeStatePath({ context, machine: machine2 });
75162
- const live = await readFile15(path, "utf8").then(
75154
+ const live = await readFile16(path, "utf8").then(
75163
75155
  (text2) => JSON.parse(text2),
75164
75156
  () => void 0
75165
75157
  );
@@ -75172,8 +75164,8 @@ async function bridgePort({
75172
75164
  key,
75173
75165
  ...target
75174
75166
  });
75175
- await mkdir15(dirname14(path), { recursive: true, mode: 448 });
75176
- await writeFile16(path, JSON.stringify({ port, key }), { mode: 384 });
75167
+ await mkdir16(dirname15(path), { recursive: true, mode: 448 });
75168
+ await writeFile17(path, JSON.stringify({ port, key }), { mode: 384 });
75177
75169
  return port;
75178
75170
  }
75179
75171
  async function bridge({ context }) {
@@ -75817,7 +75809,7 @@ async function channelSettings({ context, args }) {
75817
75809
  }
75818
75810
 
75819
75811
  // src/services/chat-actions-commands.service.ts
75820
- import { readFile as readFile16 } from "node:fs/promises";
75812
+ import { readFile as readFile17 } from "node:fs/promises";
75821
75813
  import { basename as basename2, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve7 } from "node:path";
75822
75814
 
75823
75815
  // src/services/file-upload.service.ts
@@ -76122,7 +76114,7 @@ function uploadNameOf({ cwd, path }) {
76122
76114
  }
76123
76115
  var fileUpload = async ({ context, args, client }) => {
76124
76116
  const path = resolve7(context.cwd, wordAt(args, 3));
76125
- const bytes = new Uint8Array(await readFile16(path));
76117
+ const bytes = new Uint8Array(await readFile17(path));
76126
76118
  const answer4 = await uploadFile({
76127
76119
  context,
76128
76120
  client,
@@ -76287,7 +76279,7 @@ async function chatActions({
76287
76279
  }
76288
76280
 
76289
76281
  // src/services/claude-monitor.service.ts
76290
- import { readFile as readFile17, rm as rm9 } from "node:fs/promises";
76282
+ import { readFile as readFile18, rm as rm9 } from "node:fs/promises";
76291
76283
  var MONITOR_IDLE_MS = 3e4;
76292
76284
  var MONITOR_OUTRANKED_MS = 3e3;
76293
76285
  async function deliverOnce({
@@ -76376,7 +76368,7 @@ async function monitorSessionOf({
76376
76368
  const fromEnv = sessionOf({ context, harness: "claude-code", sessionId });
76377
76369
  if (fromEnv || !claudePid) return fromEnv;
76378
76370
  const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
76379
- return readFile17(path, "utf8").then(
76371
+ return readFile18(path, "utf8").then(
76380
76372
  (text2) => JSON.parse(text2),
76381
76373
  () => void 0
76382
76374
  );
@@ -77863,10 +77855,10 @@ async function computer({ context, args }) {
77863
77855
  }
77864
77856
 
77865
77857
  // src/services/connect-commands.service.ts
77866
- import { readFile as readFile19 } from "node:fs/promises";
77858
+ import { readFile as readFile20 } from "node:fs/promises";
77867
77859
 
77868
77860
  // src/services/mcp-gateway.service.ts
77869
- import { readFile as readFile18 } from "node:fs/promises";
77861
+ import { readFile as readFile19 } from "node:fs/promises";
77870
77862
  import { createInterface as createInterface3 } from "node:readline";
77871
77863
  var TURN_HEADER = "x-laze-turn";
77872
77864
  function serveMcpGateway({
@@ -77909,7 +77901,7 @@ async function relayMcpLines({
77909
77901
  const github3 = env.LAZE_GITHUB_CONNECTION;
77910
77902
  const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
77911
77903
  const turnFile = env.LAZE_TURN_FILE;
77912
- const readTurn = () => readFile18(turnFile, "utf8").then(
77904
+ const readTurn = () => readFile19(turnFile, "utf8").then(
77913
77905
  (text2) => text2.trim(),
77914
77906
  () => ""
77915
77907
  );
@@ -77999,7 +77991,7 @@ async function turnOf({ context }) {
77999
77991
  const pinned = env.LAZE_TURN_TOKEN?.trim();
78000
77992
  if (pinned) return pinned;
78001
77993
  const file3 = env.LAZE_TURN_FILE;
78002
- const turn = file3 ? await readFile19(file3, "utf8").then(
77994
+ const turn = file3 ? await readFile20(file3, "utf8").then(
78003
77995
  (text2) => text2.trim(),
78004
77996
  () => ""
78005
77997
  ) : "";
@@ -78057,11 +78049,11 @@ async function connect({
78057
78049
  }
78058
78050
 
78059
78051
  // src/services/connector-commands.service.ts
78060
- import { readFile as readFile21 } from "node:fs/promises";
78052
+ import { readFile as readFile22 } from "node:fs/promises";
78061
78053
  import { resolve as resolve8 } from "node:path";
78062
78054
 
78063
78055
  // src/services/vault-keychain-commands.service.ts
78064
- import { readFile as readFile20 } from "node:fs/promises";
78056
+ import { readFile as readFile21 } from "node:fs/promises";
78065
78057
 
78066
78058
  // src/rules/vault-input.rules.ts
78067
78059
  function secondsOf(text2) {
@@ -78372,7 +78364,7 @@ async function secretText({ context, args }) {
78372
78364
  );
78373
78365
  }
78374
78366
  const file3 = flagText({ args, name: "from-file" });
78375
- const text2 = file3 ? await readFile20(file3, "utf8") : await context.readStdin();
78367
+ const text2 = file3 ? await readFile21(file3, "utf8") : await context.readStdin();
78376
78368
  const trimmed = text2.replace(/\r?\n$/, "");
78377
78369
  if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
78378
78370
  return trimmed;
@@ -78570,7 +78562,7 @@ async function keyText({ context, args }) {
78570
78562
  throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
78571
78563
  }
78572
78564
  const file3 = flagText({ args, name: "from-file" });
78573
- const text2 = file3 ? await readFile21(resolve8(context.cwd, file3), "utf8") : await context.readStdin();
78565
+ const text2 = file3 ? await readFile22(resolve8(context.cwd, file3), "utf8") : await context.readStdin();
78574
78566
  const trimmed = text2.trim();
78575
78567
  if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
78576
78568
  return trimmed;
@@ -78956,8 +78948,8 @@ var DOMAINS_USAGE = `Usage:
78956
78948
  var printJson4 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
78957
78949
  `);
78958
78950
  function printDomain(context, row) {
78959
- const join20 = row.autoJoin ? "auto-join on" : "auto-join off";
78960
- context.out(`${row.domain} ${join20}${row.enforced ? " single sign-on enforced" : ""}
78951
+ const join21 = row.autoJoin ? "auto-join on" : "auto-join off";
78952
+ context.out(`${row.domain} ${join21}${row.enforced ? " single sign-on enforced" : ""}
78961
78953
  `);
78962
78954
  }
78963
78955
  async function list4({ context, args }) {
@@ -78989,7 +78981,7 @@ async function domains({ context, args }) {
78989
78981
  }
78990
78982
 
78991
78983
  // src/services/feed-commands.service.ts
78992
- import { readFile as readFile23 } from "node:fs/promises";
78984
+ import { readFile as readFile24 } from "node:fs/promises";
78993
78985
  import { resolve as resolve10 } from "node:path";
78994
78986
 
78995
78987
  // src/rules/feed-input.rules.ts
@@ -79114,7 +79106,7 @@ function feedFlagsOf({ args }) {
79114
79106
  }
79115
79107
 
79116
79108
  // src/services/feed-files.service.ts
79117
- import { readFile as readFile22 } from "node:fs/promises";
79109
+ import { readFile as readFile23 } from "node:fs/promises";
79118
79110
  import { basename as basename3, resolve as resolve9 } from "node:path";
79119
79111
 
79120
79112
  // ../../modules/feed/contract/src/feed.ts
@@ -79708,7 +79700,7 @@ async function local({ context, path }) {
79708
79700
  return {
79709
79701
  fileName,
79710
79702
  contentType: contentTypeOf(fileName),
79711
- bytes: new Uint8Array(await readFile22(full))
79703
+ bytes: new Uint8Array(await readFile23(full))
79712
79704
  };
79713
79705
  }
79714
79706
  async function directWith({ client, to }) {
@@ -79786,7 +79778,7 @@ async function bodyOf2({
79786
79778
  flags: flags2
79787
79779
  }) {
79788
79780
  const body = { ...flags2.fields };
79789
- const read3 = (source) => "file" in source ? readFile23(resolve10(context.cwd, source.file), "utf8") : source.text;
79781
+ const read3 = (source) => "file" in source ? readFile24(resolve10(context.cwd, source.file), "utf8") : source.text;
79790
79782
  for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read3(source);
79791
79783
  if (flags2.rich) {
79792
79784
  const text2 = await read3(flags2.rich.source);
@@ -79948,7 +79940,7 @@ async function textFlag({
79948
79940
  }) {
79949
79941
  const value = flagText({ args, name: name2 });
79950
79942
  if (!value.startsWith("@")) return value;
79951
- return readFile23(resolve10(context.cwd, value.slice(1)), "utf8");
79943
+ return readFile24(resolve10(context.cwd, value.slice(1)), "utf8");
79952
79944
  }
79953
79945
  async function feedList({ context, args }) {
79954
79946
  const { client } = await signedIn({ context, args });
@@ -80058,7 +80050,7 @@ async function feed({ context, args }) {
80058
80050
  }
80059
80051
 
80060
80052
  // src/services/github-commands.service.ts
80061
- import { readFile as readFile24 } from "node:fs/promises";
80053
+ import { readFile as readFile25 } from "node:fs/promises";
80062
80054
 
80063
80055
  // src/rules/github-signature.rules.ts
80064
80056
  var TURN_SEPARATOR = "~";
@@ -80128,7 +80120,7 @@ var REAL_GH = "/usr/bin/gh";
80128
80120
  var NOT_SET = "laze: agent_github_not_set: this agent has no GitHub connection. Its owner sets one on the agent's settings page or with `laze agent set-github <agent> <connection>`.";
80129
80121
  async function turnFileToken({ env }) {
80130
80122
  if (!env.LAZE_TURN_FILE) return "";
80131
- return readFile24(env.LAZE_TURN_FILE, "utf8").then(
80123
+ return readFile25(env.LAZE_TURN_FILE, "utf8").then(
80132
80124
  (text2) => text2.trim(),
80133
80125
  () => ""
80134
80126
  );
@@ -80162,7 +80154,7 @@ async function githubGh({
80162
80154
  args: args.rest,
80163
80155
  agentName: profile.name ?? "An agent",
80164
80156
  threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
80165
- readBodyFile: (path) => path === "-" ? context.readStdin() : readFile24(path, "utf8")
80157
+ readBodyFile: (path) => path === "-" ? context.readStdin() : readFile25(path, "utf8")
80166
80158
  });
80167
80159
  return context.runCommand({
80168
80160
  command: [REAL_GH, ...ghArgs],
@@ -80261,7 +80253,7 @@ async function setAgentGithub({
80261
80253
  }
80262
80254
 
80263
80255
  // src/services/history-commands.service.ts
80264
- import { readFile as readFile25 } from "node:fs/promises";
80256
+ import { readFile as readFile26 } from "node:fs/promises";
80265
80257
 
80266
80258
  // src/rules/history-format.rules.ts
80267
80259
  function timeOf2(iso) {
@@ -80357,7 +80349,7 @@ async function turnTokenOf3({ context }) {
80357
80349
  const pinned = env.LAZE_TURN_TOKEN?.trim();
80358
80350
  if (pinned) return pinned;
80359
80351
  if (!env.LAZE_TURN_FILE) return "";
80360
- return readFile25(env.LAZE_TURN_FILE, "utf8").then(
80352
+ return readFile26(env.LAZE_TURN_FILE, "utf8").then(
80361
80353
  (text2) => text2.trim(),
80362
80354
  () => ""
80363
80355
  );
@@ -80549,19 +80541,19 @@ async function ip({ context, args }) {
80549
80541
  }
80550
80542
 
80551
80543
  // src/services/join-commands.service.ts
80552
- import { mkdir as mkdir16, readFile as readFile26, rename as rename5, rm as rm10, writeFile as writeFile17 } from "node:fs/promises";
80553
- import { dirname as dirname15, join as join17 } from "node:path";
80544
+ import { mkdir as mkdir17, readFile as readFile27, rename as rename5, rm as rm10, writeFile as writeFile18 } from "node:fs/promises";
80545
+ import { dirname as dirname16, join as join18 } from "node:path";
80554
80546
  var DEFAULT_WAIT_SECONDS2 = 100;
80555
80547
  var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
80556
80548
  function pendingPathOf({ context }) {
80557
- return join17(dirname15(context.environment.configPath), "join", "pending.json");
80549
+ return join18(dirname16(context.environment.configPath), "join", "pending.json");
80558
80550
  }
80559
80551
  async function readPending({
80560
80552
  context,
80561
80553
  url: url2,
80562
80554
  args
80563
80555
  }) {
80564
- const pending = await readFile26(pendingPathOf({ context }), "utf8").then(
80556
+ const pending = await readFile27(pendingPathOf({ context }), "utf8").then(
80565
80557
  (text2) => JSON.parse(text2),
80566
80558
  () => void 0
80567
80559
  );
@@ -80571,9 +80563,9 @@ async function readPending({
80571
80563
  }
80572
80564
  async function keepPending({ context, pending }) {
80573
80565
  const path = pendingPathOf({ context });
80574
- await mkdir16(dirname15(path), { recursive: true, mode: 448 });
80566
+ await mkdir17(dirname16(path), { recursive: true, mode: 448 });
80575
80567
  const temporary = `${path}.${process.pid}.tmp`;
80576
- await writeFile17(temporary, JSON.stringify(pending), { mode: 384 });
80568
+ await writeFile18(temporary, JSON.stringify(pending), { mode: 384 });
80577
80569
  await rename5(temporary, path);
80578
80570
  }
80579
80571
  async function dropPending({ context }) {
@@ -80891,9 +80883,9 @@ function machineAccessCommand(name2) {
80891
80883
 
80892
80884
  // src/services/vault-commands.service.ts
80893
80885
  import { createHash as createHash2 } from "node:crypto";
80894
- import { mkdir as mkdir17, readFile as readFile27, rm as rm11, writeFile as writeFile18 } from "node:fs/promises";
80886
+ import { mkdir as mkdir18, readFile as readFile28, rm as rm11, writeFile as writeFile19 } from "node:fs/promises";
80895
80887
  import { tmpdir as tmpdir2 } from "node:os";
80896
- import { dirname as dirname16, join as join18 } from "node:path";
80888
+ import { dirname as dirname17, join as join19 } from "node:path";
80897
80889
  var USAGE10 = `Usage: laze vault run <connection> --reason "<one plain sentence>" [--wait <s>] -- <command> [args...]
80898
80890
  Runs the command with the connection's values in its environment, on a Laze agent's computer
80899
80891
  or on a machine it runs on.`;
@@ -80932,7 +80924,7 @@ async function turnTokenOf4({
80932
80924
  if (pinned) return pinned;
80933
80925
  if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
80934
80926
  try {
80935
- return (await readFile27(turnFile, "utf8")).trim();
80927
+ return (await readFile28(turnFile, "utf8")).trim();
80936
80928
  } catch {
80937
80929
  throw new CliUsageError(`${command} works only during an agent's turn`);
80938
80930
  }
@@ -80942,11 +80934,11 @@ function runKeyPathOf({
80942
80934
  connection
80943
80935
  }) {
80944
80936
  const name2 = createHash2("sha256").update(connection).digest("hex");
80945
- const base = turnFile ? dirname16(turnFile) : join18(tmpdir2(), "laze-vault");
80946
- return join18(base, "vault-run-keys", `${name2}.json`);
80937
+ const base = turnFile ? dirname17(turnFile) : join19(tmpdir2(), "laze-vault");
80938
+ return join19(base, "vault-run-keys", `${name2}.json`);
80947
80939
  }
80948
80940
  async function runKeyAt({ path }) {
80949
- const saved3 = await readFile27(path, "utf8").then(
80941
+ const saved3 = await readFile28(path, "utf8").then(
80950
80942
  (text2) => JSON.parse(text2),
80951
80943
  () => void 0
80952
80944
  );
@@ -80956,8 +80948,8 @@ async function runKeyAt({ path }) {
80956
80948
  }
80957
80949
  const fresh = await generateEcdhKeys();
80958
80950
  const jwk = await globalThis.crypto.subtle.exportKey("jwk", fresh.privateKey);
80959
- await mkdir17(dirname16(path), { recursive: true, mode: 448 });
80960
- await writeFile18(path, JSON.stringify({ publicKey: fresh.publicKey, privateKey: jwk }), {
80951
+ await mkdir18(dirname17(path), { recursive: true, mode: 448 });
80952
+ await writeFile19(path, JSON.stringify({ publicKey: fresh.publicKey, privateKey: jwk }), {
80961
80953
  mode: 384
80962
80954
  });
80963
80955
  return fresh;
@@ -81628,14 +81620,14 @@ async function serveMcp({
81628
81620
  }
81629
81621
 
81630
81622
  // src/services/mount-files.service.ts
81631
- import { mkdir as mkdir18, readFile as readFile28, rm as rm12, writeFile as writeFile19 } from "node:fs/promises";
81632
- import { dirname as dirname17, relative as relative5, resolve as resolve11 } from "node:path";
81623
+ import { mkdir as mkdir19, readFile as readFile29, rm as rm12, writeFile as writeFile20 } from "node:fs/promises";
81624
+ import { dirname as dirname18, relative as relative5, resolve as resolve11 } from "node:path";
81633
81625
  async function textArgument({
81634
81626
  context,
81635
81627
  value
81636
81628
  }) {
81637
81629
  if (value === "-") return context.readStdin();
81638
- if (value.startsWith("@")) return readFile28(resolve11(context.cwd, value.slice(1)), "utf8");
81630
+ if (value.startsWith("@")) return readFile29(resolve11(context.cwd, value.slice(1)), "utf8");
81639
81631
  return value;
81640
81632
  }
81641
81633
  function turnChannel({ context, args }) {
@@ -81649,14 +81641,14 @@ async function writeMount({
81649
81641
  }) {
81650
81642
  const root = resolve11(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
81651
81643
  await rm12(root, { recursive: true, force: true });
81652
- await mkdir18(root, { recursive: true });
81644
+ await mkdir19(root, { recursive: true });
81653
81645
  for (const file3 of files2) {
81654
81646
  const target = resolve11(root, file3.path);
81655
81647
  const inside = relative5(root, target);
81656
81648
  if (!inside || inside.startsWith(".."))
81657
81649
  throw new Error(`Refusing to write outside ${root}: ${file3.path}`);
81658
- await mkdir18(dirname17(target), { recursive: true });
81659
- await writeFile19(target, file3.content);
81650
+ await mkdir19(dirname18(target), { recursive: true });
81651
+ await writeFile20(target, file3.content);
81660
81652
  }
81661
81653
  return root;
81662
81654
  }
@@ -82394,6 +82386,70 @@ function watchingRelease({
82394
82386
  };
82395
82387
  }
82396
82388
 
82389
+ // src/services/rush-guard.service.ts
82390
+ import { readFile as readFile30, rm as rm13 } from "node:fs/promises";
82391
+ var WATCH_MS3 = 2e3;
82392
+ var RETRY_MS2 = 3e4;
82393
+ async function guardRound({ context, client, name: name2, lock, claudePid, session, rush }) {
82394
+ const key = session ? sessionKeyOf({ session }) : void 0;
82395
+ if (key && await liveElsewhere({ context, key, claudePid })) return true;
82396
+ const holder = await holderOf({ path: lock });
82397
+ if (holder?.pid !== context.processes.pid) {
82398
+ if (!await takeLock({ context, path: lock, claudePid, ...sessionIdOf({ session }) }))
82399
+ return true;
82400
+ }
82401
+ const due = await dueFromSpool({ context, profile: name2, seen: async () => "", pushedToo: true });
82402
+ const messages = due.length > 0 ? due : await takeRound({ context, client, claudePid: 0, session });
82403
+ if (messages.length === 0) return false;
82404
+ await keepTaken({ context, profile: name2, messages });
82405
+ const self2 = await currentNameOf({ context, client, profile: name2 });
82406
+ const env = { LAZE_WAKE_TEXT: hookContextOf({ messages, self: self2 }) };
82407
+ if (await context.runCommand({ command: rushSendCommand(rush), env }) !== 0) return false;
82408
+ await turnStarted({ context, client, agent: name2, messages }).catch(() => void 0);
82409
+ await dropFromSpool({ context, profile: name2, messageIds: messages.map((m) => m.messageId) });
82410
+ return true;
82411
+ }
82412
+ function sessionIdOf({ session }) {
82413
+ return session ? { sessionId: session.sessionId } : {};
82414
+ }
82415
+ async function rushWakeHook({ context, args }) {
82416
+ const claudePid = Number(flagText({ args, name: "claude-pid" }));
82417
+ const id = flagText({ args, name: "rush-id" });
82418
+ const program = flagText({ args, name: "rush-program" }) || "rush";
82419
+ if (!claudePid || !id) return 1;
82420
+ if (!await claimRushGuard({ context, claudePid })) return 0;
82421
+ const path = guardPathOf({ context, claudePid });
82422
+ try {
82423
+ while (context.processes.alive(claudePid)) await context.sleep(WATCH_MS3);
82424
+ const { client, name: name2 } = await signedIn({ context, args });
82425
+ const noted = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
82426
+ const session = await readFile30(noted, "utf8").then(
82427
+ (text2) => JSON.parse(text2),
82428
+ () => void 0
82429
+ );
82430
+ const lock = statePathOf({ context, kind: "waiters", profile: name2 });
82431
+ const guard = { context, client, name: name2, lock, claudePid, session, rush: { id, program } };
82432
+ const deadline = context.nowMs() + WAIT_HOOK_TIMEOUT_SECONDS * 1e3;
82433
+ try {
82434
+ while (context.nowMs() < deadline) {
82435
+ const done = await guardRound(guard).catch((error62) => {
82436
+ context.err(`laze: the rush guard will try again: ${String(error62)}
82437
+ `);
82438
+ return "failed";
82439
+ });
82440
+ if (done === true) return 0;
82441
+ await context.sleep(done === "failed" ? RETRY_MS2 : 1e3);
82442
+ }
82443
+ return 0;
82444
+ } finally {
82445
+ if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
82446
+ await rm13(lock, { force: true });
82447
+ }
82448
+ } finally {
82449
+ await rm13(path, { force: true });
82450
+ }
82451
+ }
82452
+
82397
82453
  // src/services/schedule-commands.service.ts
82398
82454
  var USAGE15 = `Usage:
82399
82455
  laze schedule add <name> --prompt <text> (--cron "<m h dom mon dow>" | --rrule "<RRULE>" | --at <local time>)
@@ -82533,8 +82589,8 @@ async function schedule({ context, args }) {
82533
82589
  }
82534
82590
 
82535
82591
  // src/services/skill-commands.service.ts
82536
- import { readdir as readdir6, readFile as readFile29 } from "node:fs/promises";
82537
- import { join as join19, relative as relative6, resolve as resolve12 } from "node:path";
82592
+ import { readdir as readdir6, readFile as readFile31 } from "node:fs/promises";
82593
+ import { join as join20, relative as relative6, resolve as resolve12 } from "node:path";
82538
82594
  var USAGE16 = `Usage:
82539
82595
  laze skill list [--agent <agentId>]
82540
82596
  laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
@@ -82555,8 +82611,8 @@ async function folderFiles({ root }) {
82555
82611
  const files2 = [];
82556
82612
  for (const entry of entries) {
82557
82613
  if (!entry.isFile()) continue;
82558
- const full = join19(entry.parentPath, entry.name);
82559
- files2.push({ path: relative6(root, full), content: await readFile29(full, "utf8") });
82614
+ const full = join20(entry.parentPath, entry.name);
82615
+ files2.push({ path: relative6(root, full), content: await readFile31(full, "utf8") });
82560
82616
  }
82561
82617
  return files2.toSorted((a, b) => a.path.localeCompare(b.path));
82562
82618
  }
@@ -82654,7 +82710,7 @@ async function skillUpdate({ context, args }) {
82654
82710
  if (!name2 || !newName && description === void 0 && !skillMdFile) {
82655
82711
  throw new CliUsageError(USAGE16);
82656
82712
  }
82657
- const skillMd = skillMdFile ? await readFile29(resolve12(context.cwd, skillMdFile), "utf8") : void 0;
82713
+ const skillMd = skillMdFile ? await readFile31(resolve12(context.cwd, skillMdFile), "utf8") : void 0;
82658
82714
  const { client } = await signedIn({ context, args });
82659
82715
  const updated = await client.post("/api/skills/update", {
82660
82716
  name: name2,
@@ -82700,7 +82756,7 @@ async function skill({ context, args }) {
82700
82756
  }
82701
82757
 
82702
82758
  // src/services/slack-commands.service.ts
82703
- import { readFile as readFile30 } from "node:fs/promises";
82759
+ import { readFile as readFile32 } from "node:fs/promises";
82704
82760
  import { resolve as resolve13 } from "node:path";
82705
82761
  var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
82706
82762
  laze slack overview connected Slack workspaces, mirrors, your link
@@ -82748,7 +82804,7 @@ async function secretLines({ context, args }) {
82748
82804
  throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
82749
82805
  }
82750
82806
  const file3 = flagText({ args, name: "from-file" });
82751
- const text2 = file3 ? await readFile30(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
82807
+ const text2 = file3 ? await readFile32(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
82752
82808
  return text2.split("\n").map((line) => line.trim()).filter(Boolean);
82753
82809
  }
82754
82810
  async function secretsOf({
@@ -83052,7 +83108,7 @@ async function slack({
83052
83108
  }
83053
83109
 
83054
83110
  // src/services/sso-commands.service.ts
83055
- import { readFile as readFile31 } from "node:fs/promises";
83111
+ import { readFile as readFile33 } from "node:fs/promises";
83056
83112
  var SSO_USAGE = `Usage:
83057
83113
  laze sso domains claimed domains and how each signs in (admins)
83058
83114
  laze sso claim <domain> the TXT record that proves the domain
@@ -83139,7 +83195,7 @@ function refuseSecretFlags({ args }) {
83139
83195
  }
83140
83196
  async function clientSecretOf({ context, args }) {
83141
83197
  const file3 = flagText({ args, name: "from-file" });
83142
- const text2 = file3 ? await readFile31(file3, "utf8") : await context.readStdin();
83198
+ const text2 = file3 ? await readFile33(file3, "utf8") : await context.readStdin();
83143
83199
  const secret = text2.trim();
83144
83200
  if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
83145
83201
  return secret;
@@ -83472,7 +83528,7 @@ async function vaultScrub({ context, args }) {
83472
83528
  }
83473
83529
 
83474
83530
  // src/services/whatsapp-business-commands.service.ts
83475
- import { readFile as readFile32 } from "node:fs/promises";
83531
+ import { readFile as readFile34 } from "node:fs/promises";
83476
83532
  import { resolve as resolve14 } from "node:path";
83477
83533
 
83478
83534
  // ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
@@ -83892,7 +83948,7 @@ async function secretsOf2({ context, args }) {
83892
83948
  const fromConnection = flagText({ args, name: "from-vault" });
83893
83949
  if (fromConnection) return { fromConnection };
83894
83950
  const file3 = flagText({ args, name: "from-file" });
83895
- const text2 = file3 ? await readFile32(resolve14(context.cwd, file3), "utf8") : await context.readStdin();
83951
+ const text2 = file3 ? await readFile34(resolve14(context.cwd, file3), "utf8") : await context.readStdin();
83896
83952
  const lines = text2.split("\n").map((line) => line.trim()).filter(Boolean);
83897
83953
  if (lines.length !== 2) {
83898
83954
  throw new CliUsageError(
@@ -84093,7 +84149,7 @@ async function whatsappBusiness({
84093
84149
  }
84094
84150
 
84095
84151
  // src/services/whatsapp-pairing-commands.service.ts
84096
- import { writeFile as writeFile20 } from "node:fs/promises";
84152
+ import { writeFile as writeFile21 } from "node:fs/promises";
84097
84153
  import { resolve as resolve15 } from "node:path";
84098
84154
  var WHATSAPP_PAIRING_USAGE = [
84099
84155
  " laze whatsapp pair <machine> [--qr <file.svg>] link WhatsApp on your machine; scan the code (owner)",
@@ -84114,7 +84170,7 @@ function svgOf(dataUrl) {
84114
84170
  }
84115
84171
  async function report({ context, args, pairing: pairing2 }) {
84116
84172
  const qrFile = pairing2.qrSvg ? resolve15(context.cwd, flagText({ args, name: "qr", fallback: "whatsapp-qr.svg" })) : null;
84117
- if (qrFile && pairing2.qrSvg) await writeFile20(qrFile, svgOf(pairing2.qrSvg), "utf8");
84173
+ if (qrFile && pairing2.qrSvg) await writeFile21(qrFile, svgOf(pairing2.qrSvg), "utf8");
84118
84174
  if (args.flags.json) return context.out(`${JSON.stringify({ ...pairing2, qrFile }, null, 2)}
84119
84175
  `);
84120
84176
  context.out(`${pairing2.pairingId} ${pairing2.state}
@@ -84473,7 +84529,7 @@ async function flags({ context, args }) {
84473
84529
  }
84474
84530
 
84475
84531
  // src/services/workspace-commands.service.ts
84476
- import { readFile as readFile33 } from "node:fs/promises";
84532
+ import { readFile as readFile35 } from "node:fs/promises";
84477
84533
  import { resolve as resolve16 } from "node:path";
84478
84534
  var ROLE_NAMES2 = {
84479
84535
  OWNER: "Owner",
@@ -84656,7 +84712,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
84656
84712
  async function readLogo({ context, file: file3 }) {
84657
84713
  let bytes;
84658
84714
  try {
84659
- bytes = new Uint8Array(await readFile33(resolve16(context.cwd, file3)));
84715
+ bytes = new Uint8Array(await readFile35(resolve16(context.cwd, file3)));
84660
84716
  } catch {
84661
84717
  throw new CliUsageError(`No file to read at ${file3}.`);
84662
84718
  }
@@ -85164,6 +85220,7 @@ var COMMANDS3 = {
85164
85220
  "hook wait": waitHook,
85165
85221
  "hook pre-tool": preToolHook,
85166
85222
  "hook monitor": monitorHook,
85223
+ "hook rush-wake": rushWakeHook,
85167
85224
  plugin,
85168
85225
  adopt: adoptCodex,
85169
85226
  feed,
@@ -85317,8 +85374,8 @@ async function runCli({
85317
85374
  // src/services/processes.service.ts
85318
85375
  import { execFile as execFile2, spawn as spawn4 } from "node:child_process";
85319
85376
  import { mkdirSync, openSync } from "node:fs";
85320
- import { readFile as readFile34, readlink } from "node:fs/promises";
85321
- import { dirname as dirname18 } from "node:path";
85377
+ import { readFile as readFile36, readlink } from "node:fs/promises";
85378
+ import { dirname as dirname19 } from "node:path";
85322
85379
  import { promisify as promisify2 } from "node:util";
85323
85380
  var run3 = promisify2(execFile2);
85324
85381
  function alive(pid) {
@@ -85331,14 +85388,14 @@ function alive(pid) {
85331
85388
  }
85332
85389
  }
85333
85390
  async function argsOf(pid) {
85334
- const raw = await readFile34(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
85391
+ const raw = await readFile36(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
85335
85392
  if (raw) return raw.split("\0").filter(Boolean);
85336
85393
  const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
85337
85394
  const line = listed?.stdout.trim();
85338
85395
  return line ? line.split(/\s+/) : void 0;
85339
85396
  }
85340
85397
  async function parentOf(pid) {
85341
- const stat3 = await readFile34(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
85398
+ const stat3 = await readFile36(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
85342
85399
  const fromStat = stat3 ? Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
85343
85400
  if (fromStat > 0) return fromStat;
85344
85401
  const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
@@ -85355,7 +85412,7 @@ async function cwdOf(pid) {
85355
85412
  return line ? line.slice(1) : void 0;
85356
85413
  }
85357
85414
  function spawnDetached({ argv, logPath }) {
85358
- mkdirSync(dirname18(logPath), { recursive: true, mode: 448 });
85415
+ mkdirSync(dirname19(logPath), { recursive: true, mode: 448 });
85359
85416
  const log = openSync(logPath, "a", 384);
85360
85417
  const [program = "", ...rest] = argv;
85361
85418
  const child = spawn4(program, rest, { detached: true, stdio: ["ignore", log, log] });