@lazehq/cli 0.1.17 → 0.1.19

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 +527 -443
  2. package/package.json +1 -1
package/dist/laze.mjs CHANGED
@@ -18733,7 +18733,7 @@ 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: readFile34, mkdir: mkdir19 } = __require("node:fs/promises");
18736
+ var { writeFile: writeFile21, readFile: readFile35, mkdir: mkdir19 } = __require("node:fs/promises");
18737
18737
  var { dirname: dirname19, resolve: resolve17 } = __require("node:path");
18738
18738
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
18739
18739
  var { InvalidArgumentError, UndiciError } = require_errors();
@@ -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 readFile34(resolve17(path), "utf8");
18953
+ const data = await readFile35(resolve17(path), "utf8");
18954
18954
  const parsed = JSON.parse(data);
18955
18955
  if (Array.isArray(parsed)) {
18956
18956
  this.#snapshots.clear();
@@ -31497,7 +31497,8 @@ function runRedacted({
31497
31497
  baseEnv,
31498
31498
  stdout: stdout2,
31499
31499
  stderr: stderr2,
31500
- cwd
31500
+ cwd,
31501
+ signal
31501
31502
  }) {
31502
31503
  const values = Object.values(env);
31503
31504
  return new Promise((resolve17, reject) => {
@@ -31505,8 +31506,12 @@ function runRedacted({
31505
31506
  const child = spawn(file3, args, {
31506
31507
  env: { ...baseEnv, ...env },
31507
31508
  stdio: ["inherit", "pipe", "pipe"],
31508
- ...cwd ? { cwd } : {}
31509
+ ...cwd ? { cwd } : {},
31510
+ ...signal ? { detached: true } : {}
31509
31511
  });
31512
+ const killGroup = () => killProcessGroup({ child });
31513
+ if (signal?.aborted) killGroup();
31514
+ signal?.addEventListener("abort", killGroup, { once: true });
31510
31515
  const pipe2 = (stream, sink) => {
31511
31516
  const decoder2 = new StringDecoder("utf8");
31512
31517
  const redactor = createRedactor({ values });
@@ -31520,11 +31525,20 @@ function runRedacted({
31520
31525
  };
31521
31526
  const drained = Promise.all([pipe2(child.stdout, stdout2), pipe2(child.stderr, stderr2)]);
31522
31527
  child.on("error", reject);
31523
- child.on("close", (code, signal) => {
31524
- void drained.then(() => resolve17(code ?? (signal ? 128 + signalNumber(signal) : 1)));
31528
+ child.on("close", (code, ended) => {
31529
+ signal?.removeEventListener("abort", killGroup);
31530
+ void drained.then(() => resolve17(code ?? (ended ? 128 + signalNumber(ended) : 1)));
31525
31531
  });
31526
31532
  });
31527
31533
  }
31534
+ function killProcessGroup({ child }) {
31535
+ if (child.pid === void 0) return;
31536
+ try {
31537
+ process.kill(-child.pid, "SIGKILL");
31538
+ } catch {
31539
+ child.kill("SIGKILL");
31540
+ }
31541
+ }
31528
31542
  function signalNumber(signal) {
31529
31543
  const numbers = { SIGINT: 2, SIGKILL: 9, SIGTERM: 15 };
31530
31544
  return numbers[signal] ?? 1;
@@ -35606,7 +35620,7 @@ function flagText({
35606
35620
  }
35607
35621
 
35608
35622
  // src/rules/cli-version.rules.ts
35609
- var STAMPED = "0.1.17";
35623
+ var STAMPED = "0.1.19";
35610
35624
  function cliVersionOf({ stamped = STAMPED } = {}) {
35611
35625
  return stamped.startsWith("__") ? "dev" : stamped;
35612
35626
  }
@@ -65390,8 +65404,8 @@ async function copyAgent({
65390
65404
  }
65391
65405
 
65392
65406
  // src/services/agent-commands.service.ts
65393
- import { mkdir as mkdir13, readFile as readFile11, writeFile as writeFile13 } from "node:fs/promises";
65394
- import { join as join12, resolve as resolve4 } from "node:path";
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";
65395
65409
 
65396
65410
  // src/rules/agent-profile.rules.ts
65397
65411
  var LEVELS = { fast: "Laze Fast", frontier: "Laze Frontier" };
@@ -65486,7 +65500,8 @@ function lazeCommandOf({ program }) {
65486
65500
 
65487
65501
  // src/rules/hook-settings.rules.ts
65488
65502
  var LAZE_HOOK_MARKER = "laze-cli-hook";
65489
- var TIMEOUTS = { Stop: 30, PreToolUse: 5, SessionStart: 30 };
65503
+ var HOOK_TIMEOUTS = { Stop: 30, PreToolUse: 5, SessionStart: 30 };
65504
+ var TIMEOUTS = HOOK_TIMEOUTS;
65490
65505
  var WAIT_HOOK_TIMEOUT_SECONDS = 7 * 24 * 60 * 60;
65491
65506
  function withHooks({
65492
65507
  hooks,
@@ -65549,12 +65564,17 @@ function hookCommand({
65549
65564
  const words = [...program, "hook", hook, "--profile", profile].map(quote4).join(" ");
65550
65565
  return `${words} # ${LAZE_HOOK_MARKER}`;
65551
65566
  }
65552
- function lacksSessionStartWaiter({ settings: settings2 }) {
65567
+ function holdsOurs({ settings: settings2, event }) {
65553
65568
  const hooks = settings2.hooks ?? {};
65554
- const ours = (event) => Array.isArray(hooks[event]) && hooks[event].some(
65569
+ return Array.isArray(hooks[event]) && hooks[event].some(
65555
65570
  (entry) => entry.hooks?.some((hook) => hook.command?.includes(LAZE_HOOK_MARKER))
65556
65571
  );
65557
- return ours("Stop") && !ours("SessionStart");
65572
+ }
65573
+ function lacksSessionStartWaiter({ settings: settings2 }) {
65574
+ return holdsOurs({ settings: settings2, event: "Stop" }) && !holdsOurs({ settings: settings2, event: "SessionStart" });
65575
+ }
65576
+ function hasLazeHooks({ settings: settings2 }) {
65577
+ return holdsOurs({ settings: settings2, event: "Stop" });
65558
65578
  }
65559
65579
 
65560
65580
  // src/rules/inbox-format.rules.ts
@@ -66516,15 +66536,323 @@ function formatSearch({
66516
66536
  }
66517
66537
 
66518
66538
  // src/services/claude-turn.service.ts
66519
- import { mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "node:fs/promises";
66539
+ import { mkdir as mkdir4, readFile as readFile5, rm, writeFile as writeFile4 } from "node:fs/promises";
66540
+ import { dirname as dirname4, join as join5 } from "node:path";
66541
+
66542
+ // src/services/harness-session.service.ts
66543
+ import { mkdir as mkdir3, readdir, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
66544
+ import { hostname as hostname3 } from "node:os";
66545
+ import { dirname as dirname3, join as join3 } from "node:path";
66546
+
66547
+ // src/rules/session-headers.rules.ts
66548
+ import { relative, sep } from "node:path";
66549
+ function sessionKeyOf({ session }) {
66550
+ return `${session.harness}:${session.sessionId}`;
66551
+ }
66552
+ function sessionHeadersOf({
66553
+ session
66554
+ }) {
66555
+ if (!session) return {};
66556
+ return {
66557
+ [AGENT_SESSION_HEADER]: sessionKeyOf({ session }),
66558
+ [AGENT_SESSION_FOLDER_HEADER]: encodeURIComponent(session.folder),
66559
+ [AGENT_SESSION_HOST_HEADER]: encodeURIComponent(session.host)
66560
+ };
66561
+ }
66562
+ function displayFolderOf({ folder, home }) {
66563
+ if (!home) return folder;
66564
+ const below = relative(home, folder);
66565
+ if (below === "") return "~";
66566
+ if (below.startsWith("..") || below.startsWith(sep)) return folder;
66567
+ return `~/${below.split(sep).join("/")}`;
66568
+ }
66569
+
66570
+ // src/services/claude-project.service.ts
66571
+ import { basename, isAbsolute, relative as relative2, resolve as resolve2 } from "node:path";
66572
+ function harnessIn({ words }) {
66573
+ const names = words.slice(0, 2).map((word3) => basename(word3).replace(/\.(js|mjs|cjs)$/, ""));
66574
+ if (names.includes("codex")) return "codex";
66575
+ if (words.some((word3) => word3.includes("@openai/codex"))) return "codex";
66576
+ const claude = words.some((word3) => word3.includes("@anthropic-ai/claude-code"));
66577
+ return claude || names.includes("claude") ? "claude-code" : void 0;
66578
+ }
66579
+ async function nearestHarnessOf({
66580
+ context,
66581
+ from = context.processes.pid
66582
+ }) {
66583
+ let pid = await context.processes.parentOf(from);
66584
+ for (let depth = 0; pid !== void 0 && pid > 1 && depth < 12; depth += 1) {
66585
+ const harness = harnessIn({ words: await context.processes.argsOf(pid) ?? [] });
66586
+ if (harness) return { harness, pid };
66587
+ pid = await context.processes.parentOf(pid);
66588
+ }
66589
+ return void 0;
66590
+ }
66591
+ function holds({ folder, inner }) {
66592
+ const rel = relative2(resolve2(folder), resolve2(inner));
66593
+ return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
66594
+ }
66595
+ async function claudeProjectOf({
66596
+ context,
66597
+ claudePid
66598
+ }) {
66599
+ const env = context.environment.inherited;
66600
+ const pid = Number(env.CLAUDE_PID);
66601
+ const candidates = [
66602
+ claudePid ? await context.processes.cwdOf(claudePid) : void 0,
66603
+ env.CLAUDE_PROJECT_DIR ? resolve2(env.CLAUDE_PROJECT_DIR) : void 0,
66604
+ pid > 0 ? await context.processes.cwdOf(pid) : void 0
66605
+ ].filter((folder) => Boolean(folder));
66606
+ return candidates.find((folder) => holds({ folder, inner: context.cwd })) ?? resolve2(context.cwd);
66607
+ }
66608
+
66609
+ // src/services/inbox-spool.service.ts
66610
+ import { mkdir as mkdir2, readFile as readFile2, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
66520
66611
  import { dirname as dirname2, join as join2 } from "node:path";
66612
+ var PUSH_GRACE_MS = 3 * 6e4;
66613
+ function fileNameOf({ profile }) {
66614
+ return profile.replace(/[^a-zA-Z0-9_-]/g, "_");
66615
+ }
66616
+ function statePathOf({
66617
+ context,
66618
+ kind,
66619
+ profile,
66620
+ extension: extension2 = "json"
66621
+ }) {
66622
+ const directory = join2(dirname2(context.environment.configPath), kind);
66623
+ return join2(directory, `${fileNameOf({ profile })}.${extension2}`);
66624
+ }
66625
+ async function readSpool({ path }) {
66626
+ return readFile2(path, "utf8").then(
66627
+ (text2) => JSON.parse(text2),
66628
+ () => []
66629
+ );
66630
+ }
66631
+ async function writeSpool({ path, entries }) {
66632
+ await mkdir2(dirname2(path), { recursive: true, mode: 448 });
66633
+ const temporary = `${path}.${process.pid}.tmp`;
66634
+ await writeFile2(temporary, JSON.stringify(entries), { mode: 384 });
66635
+ await rename2(temporary, path);
66636
+ }
66637
+ async function keepTaken({
66638
+ context,
66639
+ profile,
66640
+ messages,
66641
+ pushed = false
66642
+ }) {
66643
+ if (messages.length === 0) return;
66644
+ const path = statePathOf({ context, kind: "spool", profile });
66645
+ const ids = new Set(messages.map((message2) => message2.messageId));
66646
+ const kept = (await readSpool({ path })).filter((entry) => !ids.has(entry.message.messageId));
66647
+ const now = context.nowMs();
66648
+ const taken = messages.map((message2) => ({
66649
+ message: message2,
66650
+ takenAt: now,
66651
+ ...pushed ? { pushedAt: now } : {}
66652
+ }));
66653
+ await writeSpool({ path, entries: [...kept, ...taken] });
66654
+ }
66655
+ async function dropFromSpool({
66656
+ context,
66657
+ profile,
66658
+ messageIds
66659
+ }) {
66660
+ if (messageIds.length === 0) return;
66661
+ const path = statePathOf({ context, kind: "spool", profile });
66662
+ const entries = await readSpool({ path });
66663
+ const ids = new Set(messageIds);
66664
+ const kept = entries.filter((entry) => !ids.has(entry.message.messageId));
66665
+ if (kept.length !== entries.length) await writeSpool({ path, entries: kept });
66666
+ }
66667
+ async function dueFromSpool({
66668
+ context,
66669
+ profile,
66670
+ seen,
66671
+ pushedToo
66672
+ }) {
66673
+ const path = statePathOf({ context, kind: "spool", profile });
66674
+ const entries = await readSpool({ path });
66675
+ const pushed = entries.some((entry) => entry.pushedAt !== void 0);
66676
+ const text2 = pushed ? await seen().catch(() => "") : "";
66677
+ const shown = entries.filter(
66678
+ (entry) => entry.pushedAt !== void 0 && text2.includes(entry.message.messageId)
66679
+ );
66680
+ await dropFromSpool({
66681
+ context,
66682
+ profile,
66683
+ messageIds: shown.map((entry) => entry.message.messageId)
66684
+ });
66685
+ const late = context.nowMs() - PUSH_GRACE_MS;
66686
+ return entries.filter((entry) => !shown.includes(entry)).filter((entry) => entry.pushedAt === void 0 || pushedToo && entry.pushedAt <= late).map((entry) => entry.message);
66687
+ }
66688
+
66689
+ // src/services/harness-session.service.ts
66690
+ function sessionOf({
66691
+ context,
66692
+ harness,
66693
+ sessionId
66694
+ }) {
66695
+ if (!sessionId) return void 0;
66696
+ const inherited = context.environment.inherited;
66697
+ const folder = inherited.CLAUDE_PROJECT_DIR || context.cwd;
66698
+ return {
66699
+ harness,
66700
+ sessionId,
66701
+ folder: displayFolderOf({ folder, home: inherited.HOME }),
66702
+ host: hostname3()
66703
+ };
66704
+ }
66705
+ function forSession({
66706
+ client,
66707
+ session
66708
+ }) {
66709
+ return client.withHeaders(sessionHeadersOf({ session }));
66710
+ }
66711
+ async function rememberSession({
66712
+ context,
66713
+ claudePid,
66714
+ session
66715
+ }) {
66716
+ if (!session || !claudePid) return;
66717
+ const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
66718
+ await mkdir3(dirname3(path), { recursive: true, mode: 448 });
66719
+ await writeFile3(path, JSON.stringify(session), { mode: 384 });
66720
+ }
66721
+ async function currentSessionOf({
66722
+ context,
66723
+ args
66724
+ }) {
66725
+ const inherited = context.environment.inherited;
66726
+ const named = flagText({ args, name: "session" });
66727
+ const harness = context.environment.harness;
66728
+ if (named) return sessionOf({ context, harness, sessionId: named });
66729
+ if (harness === "claude-code" && inherited.CLAUDE_CODE_SESSION_ID) {
66730
+ return sessionOf({ context, harness, sessionId: inherited.CLAUDE_CODE_SESSION_ID });
66731
+ }
66732
+ if (harness === "codex" && inherited.CODEX_THREAD_ID) {
66733
+ return sessionOf({ context, harness, sessionId: inherited.CODEX_THREAD_ID });
66734
+ }
66735
+ const nearest = await nearestHarnessOf({ context });
66736
+ if (!nearest) return void 0;
66737
+ const path = statePathOf({ context, kind: "sessions", profile: String(nearest.pid) });
66738
+ return readFile3(path, "utf8").then(
66739
+ (text2) => JSON.parse(text2),
66740
+ () => void 0
66741
+ );
66742
+ }
66743
+ async function sessionProfileArgs({
66744
+ context,
66745
+ args,
66746
+ session
66747
+ }) {
66748
+ if (!session) return args;
66749
+ const key = sessionKeyOf({ session });
66750
+ const config2 = await context.store.read();
66751
+ const bound = config2.sessions?.[key];
66752
+ if (bound && config2.profiles[bound]) {
66753
+ return { ...args, flags: { ...args.flags, profile: bound } };
66754
+ }
66755
+ const own2 = flagText({ args, name: "profile" });
66756
+ if (own2 && config2.profiles[own2]?.kind === "agent") {
66757
+ await context.store.bindSession({ session: key, profile: own2 });
66758
+ }
66759
+ return args;
66760
+ }
66761
+ async function liveElsewhere({
66762
+ context,
66763
+ key,
66764
+ claudePid
66765
+ }) {
66766
+ const folder = dirname3(statePathOf({ context, kind: "sessions", profile: "x" }));
66767
+ for (const file3 of await readdir(folder).catch(() => [])) {
66768
+ const pid = Number(file3.replace(/\.json$/, ""));
66769
+ if (!pid || pid === claudePid || !context.processes.alive(pid)) continue;
66770
+ const noted = await readFile3(join3(folder, file3), "utf8").then(
66771
+ (text2) => JSON.parse(text2),
66772
+ () => void 0
66773
+ );
66774
+ if (noted && sessionKeyOf({ session: noted }) === key) return true;
66775
+ }
66776
+ return false;
66777
+ }
66778
+ function notBoundText({ meta: meta3 }) {
66779
+ return `Laze: this agent listens in another session${meta3.bound ? `: ${meta3.bound}` : ""}. Create a new Laze agent with this session: laze agent request. Or move this agent here: laze agent bind.`;
66780
+ }
66781
+ async function notBoundNotice({
66782
+ context,
66783
+ client,
66784
+ session,
66785
+ error: error62
66786
+ }) {
66787
+ if (!(error62 instanceof LazeApiError) || error62.code !== "session_not_bound") return void 0;
66788
+ const meta3 = error62.meta ?? {};
66789
+ if (client && session && meta3.session && meta3.host === session.host) {
66790
+ const claudePid = (await nearestHarnessOf({ context }))?.pid;
66791
+ if (!await liveElsewhere({ context, key: meta3.session, claudePid })) {
66792
+ await client.post("/api/agents/me/bind", {});
66793
+ return { notice: void 0, rebound: true };
66794
+ }
66795
+ }
66796
+ const key = session ? sessionKeyOf({ session }) : "unknown";
66797
+ const path = statePathOf({ context, kind: "told", profile: key });
66798
+ const told = await readFile3(path, "utf8").then(
66799
+ () => true,
66800
+ () => false
66801
+ );
66802
+ if (told) return { notice: void 0 };
66803
+ await mkdir3(dirname3(path), { recursive: true, mode: 448 });
66804
+ await writeFile3(path, String(context.nowMs()), { mode: 384 });
66805
+ return { notice: notBoundText({ meta: meta3 }) };
66806
+ }
66807
+
66808
+ // src/services/plugin-hook.service.ts
66809
+ import { readFile as readFile4 } from "node:fs/promises";
66810
+ import { join as join4 } from "node:path";
66811
+ async function agentProfileHere({
66812
+ context,
66813
+ args,
66814
+ session,
66815
+ claudePid
66816
+ }) {
66817
+ const config2 = await context.store.read();
66818
+ const cwd = (claudePid ? await context.processes.cwdOf(claudePid) : void 0) ?? (context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd);
66819
+ const folder = boundProfileOf({ bindings: config2.bindings, cwd });
66820
+ if (!folder && !session) return void 0;
66821
+ const asked = { ...args, flags: { ...args.flags, ...folder ? { profile: folder } : {} } };
66822
+ const name2 = flagText({
66823
+ args: await sessionProfileArgs({ context, args: asked, session }),
66824
+ name: "profile"
66825
+ });
66826
+ return name2 && config2.profiles[name2]?.kind === "agent" ? name2 : void 0;
66827
+ }
66828
+ async function projectHooksHere({ context }) {
66829
+ const directory = context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd;
66830
+ const path = join4(directory, ".claude", "settings.local.json");
66831
+ return readFile4(path, "utf8").then(
66832
+ (text2) => hasLazeHooks({ settings: JSON.parse(text2) }),
66833
+ () => false
66834
+ );
66835
+ }
66836
+ async function pluginHookArgs({
66837
+ context,
66838
+ args,
66839
+ session,
66840
+ claudePid
66841
+ }) {
66842
+ if (!args.flags.plugin) return args;
66843
+ if (await projectHooksHere({ context })) return void 0;
66844
+ const profile = await agentProfileHere({ context, args, session, claudePid });
66845
+ return profile ? { ...args, flags: { ...args.flags, profile } } : void 0;
66846
+ }
66847
+
66848
+ // src/services/claude-turn.service.ts
66521
66849
  var PRE_TOOL_TIMEOUT_MS = 3e3;
66522
66850
  function statePath({ context, agent: agent2 }) {
66523
66851
  const safe = agent2.replace(/[^a-zA-Z0-9_-]/g, "_");
66524
- return join2(dirname2(context.environment.configPath), "turns", `${safe}.json`);
66852
+ return join5(dirname4(context.environment.configPath), "turns", `${safe}.json`);
66525
66853
  }
66526
66854
  async function readState({ context, agent: agent2 }) {
66527
- return readFile2(statePath({ context, agent: agent2 }), "utf8").then(
66855
+ return readFile5(statePath({ context, agent: agent2 }), "utf8").then(
66528
66856
  (text2) => JSON.parse(text2),
66529
66857
  () => void 0
66530
66858
  );
@@ -66560,8 +66888,8 @@ async function turnStarted({
66560
66888
  await beat({ client, state: before, working: false }).catch(() => void 0);
66561
66889
  }
66562
66890
  const path = statePath({ context, agent: agent2 });
66563
- await mkdir2(dirname2(path), { recursive: true, mode: 448 });
66564
- await writeFile2(path, JSON.stringify(state));
66891
+ await mkdir4(dirname4(path), { recursive: true, mode: 448 });
66892
+ await writeFile4(path, JSON.stringify(state));
66565
66893
  await beat({ client, state, working: true }).catch(() => void 0);
66566
66894
  }
66567
66895
  async function turnEnded({
@@ -66576,12 +66904,16 @@ async function turnEnded({
66576
66904
  }
66577
66905
  async function preToolHook({ context, args }) {
66578
66906
  try {
66579
- await context.readStdin();
66580
- const { name: name2, profile } = await signedIn({ context, args });
66907
+ const raw = await context.readStdin();
66908
+ const input2 = raw.trim() ? JSON.parse(raw) : {};
66909
+ const session = sessionOf({ context, harness: "claude-code", sessionId: input2.session_id });
66910
+ const asked = await pluginHookArgs({ context, args, session, claudePid: 0 });
66911
+ if (!asked) return;
66912
+ const { name: name2, profile } = await signedIn({ context, args: asked });
66581
66913
  const client = LazeClient.create({
66582
66914
  baseUrl: profile.url,
66583
66915
  token: profile.token,
66584
- fetcher: (input2, init) => context.fetcher(input2, { ...init, signal: AbortSignal.timeout(PRE_TOOL_TIMEOUT_MS) })
66916
+ fetcher: (input3, init) => context.fetcher(input3, { ...init, signal: AbortSignal.timeout(PRE_TOOL_TIMEOUT_MS) })
66585
66917
  });
66586
66918
  const state = await readState({ context, agent: name2 });
66587
66919
  const answer4 = await beat({ client, state, working: true });
@@ -66605,86 +66937,6 @@ async function preToolHook({ context, args }) {
66605
66937
  }
66606
66938
  }
66607
66939
 
66608
- // src/services/inbox-spool.service.ts
66609
- import { mkdir as mkdir3, readFile as readFile3, rename as rename2, writeFile as writeFile3 } from "node:fs/promises";
66610
- import { dirname as dirname3, join as join3 } from "node:path";
66611
- var PUSH_GRACE_MS = 3 * 6e4;
66612
- function fileNameOf({ profile }) {
66613
- return profile.replace(/[^a-zA-Z0-9_-]/g, "_");
66614
- }
66615
- function statePathOf({
66616
- context,
66617
- kind,
66618
- profile,
66619
- extension: extension2 = "json"
66620
- }) {
66621
- const directory = join3(dirname3(context.environment.configPath), kind);
66622
- return join3(directory, `${fileNameOf({ profile })}.${extension2}`);
66623
- }
66624
- async function readSpool({ path }) {
66625
- return readFile3(path, "utf8").then(
66626
- (text2) => JSON.parse(text2),
66627
- () => []
66628
- );
66629
- }
66630
- async function writeSpool({ path, entries }) {
66631
- await mkdir3(dirname3(path), { recursive: true, mode: 448 });
66632
- const temporary = `${path}.${process.pid}.tmp`;
66633
- await writeFile3(temporary, JSON.stringify(entries), { mode: 384 });
66634
- await rename2(temporary, path);
66635
- }
66636
- async function keepTaken({
66637
- context,
66638
- profile,
66639
- messages,
66640
- pushed = false
66641
- }) {
66642
- if (messages.length === 0) return;
66643
- const path = statePathOf({ context, kind: "spool", profile });
66644
- const ids = new Set(messages.map((message2) => message2.messageId));
66645
- const kept = (await readSpool({ path })).filter((entry) => !ids.has(entry.message.messageId));
66646
- const now = context.nowMs();
66647
- const taken = messages.map((message2) => ({
66648
- message: message2,
66649
- takenAt: now,
66650
- ...pushed ? { pushedAt: now } : {}
66651
- }));
66652
- await writeSpool({ path, entries: [...kept, ...taken] });
66653
- }
66654
- async function dropFromSpool({
66655
- context,
66656
- profile,
66657
- messageIds
66658
- }) {
66659
- if (messageIds.length === 0) return;
66660
- const path = statePathOf({ context, kind: "spool", profile });
66661
- const entries = await readSpool({ path });
66662
- const ids = new Set(messageIds);
66663
- const kept = entries.filter((entry) => !ids.has(entry.message.messageId));
66664
- if (kept.length !== entries.length) await writeSpool({ path, entries: kept });
66665
- }
66666
- async function dueFromSpool({
66667
- context,
66668
- profile,
66669
- seen,
66670
- pushedToo
66671
- }) {
66672
- const path = statePathOf({ context, kind: "spool", profile });
66673
- const entries = await readSpool({ path });
66674
- const pushed = entries.some((entry) => entry.pushedAt !== void 0);
66675
- const text2 = pushed ? await seen().catch(() => "") : "";
66676
- const shown = entries.filter(
66677
- (entry) => entry.pushedAt !== void 0 && text2.includes(entry.message.messageId)
66678
- );
66679
- await dropFromSpool({
66680
- context,
66681
- profile,
66682
- messageIds: shown.map((entry) => entry.message.messageId)
66683
- });
66684
- const late = context.nowMs() - PUSH_GRACE_MS;
66685
- return entries.filter((entry) => !shown.includes(entry)).filter((entry) => entry.pushedAt === void 0 || pushedToo && entry.pushedAt <= late).map((entry) => entry.message);
66686
- }
66687
-
66688
66940
  // src/rules/activity-format.rules.ts
66689
66941
  function utcTimeOf(iso) {
66690
66942
  return `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
@@ -67225,202 +67477,14 @@ function channelLabelIn(channel) {
67225
67477
  return `#${channel.name}`;
67226
67478
  }
67227
67479
 
67228
- // src/services/claude-project.service.ts
67229
- import { basename, isAbsolute, relative, resolve as resolve2 } from "node:path";
67230
- function harnessIn({ words }) {
67231
- const names = words.slice(0, 2).map((word3) => basename(word3).replace(/\.(js|mjs|cjs)$/, ""));
67232
- if (names.includes("codex")) return "codex";
67233
- if (words.some((word3) => word3.includes("@openai/codex"))) return "codex";
67234
- const claude = words.some((word3) => word3.includes("@anthropic-ai/claude-code"));
67235
- return claude || names.includes("claude") ? "claude-code" : void 0;
67236
- }
67237
- async function nearestHarnessOf({
67238
- context,
67239
- from = context.processes.pid
67240
- }) {
67241
- let pid = await context.processes.parentOf(from);
67242
- for (let depth = 0; pid !== void 0 && pid > 1 && depth < 12; depth += 1) {
67243
- const harness = harnessIn({ words: await context.processes.argsOf(pid) ?? [] });
67244
- if (harness) return { harness, pid };
67245
- pid = await context.processes.parentOf(pid);
67246
- }
67247
- return void 0;
67248
- }
67249
- function holds({ folder, inner }) {
67250
- const rel = relative(resolve2(folder), resolve2(inner));
67251
- return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
67252
- }
67253
- async function claudeProjectOf({
67254
- context,
67255
- claudePid
67256
- }) {
67257
- const env = context.environment.inherited;
67258
- const pid = Number(env.CLAUDE_PID);
67259
- const candidates = [
67260
- claudePid ? await context.processes.cwdOf(claudePid) : void 0,
67261
- env.CLAUDE_PROJECT_DIR ? resolve2(env.CLAUDE_PROJECT_DIR) : void 0,
67262
- pid > 0 ? await context.processes.cwdOf(pid) : void 0
67263
- ].filter((folder) => Boolean(folder));
67264
- return candidates.find((folder) => holds({ folder, inner: context.cwd })) ?? resolve2(context.cwd);
67265
- }
67266
-
67267
67480
  // src/services/claude-wait.service.ts
67268
- import { readFile as readFile5, rm as rm2, writeFile as writeFile5, mkdir as mkdir5 } from "node:fs/promises";
67481
+ import { readFile as readFile6, rm as rm2, writeFile as writeFile5, mkdir as mkdir5 } from "node:fs/promises";
67269
67482
  import { dirname as dirname5 } from "node:path";
67270
-
67271
- // src/services/harness-session.service.ts
67272
- import { mkdir as mkdir4, readdir, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
67273
- import { hostname as hostname3 } from "node:os";
67274
- import { dirname as dirname4, join as join4 } from "node:path";
67275
-
67276
- // src/rules/session-headers.rules.ts
67277
- import { relative as relative2, sep } from "node:path";
67278
- function sessionKeyOf({ session }) {
67279
- return `${session.harness}:${session.sessionId}`;
67280
- }
67281
- function sessionHeadersOf({
67282
- session
67283
- }) {
67284
- if (!session) return {};
67285
- return {
67286
- [AGENT_SESSION_HEADER]: sessionKeyOf({ session }),
67287
- [AGENT_SESSION_FOLDER_HEADER]: encodeURIComponent(session.folder),
67288
- [AGENT_SESSION_HOST_HEADER]: encodeURIComponent(session.host)
67289
- };
67290
- }
67291
- function displayFolderOf({ folder, home }) {
67292
- if (!home) return folder;
67293
- const below = relative2(home, folder);
67294
- if (below === "") return "~";
67295
- if (below.startsWith("..") || below.startsWith(sep)) return folder;
67296
- return `~/${below.split(sep).join("/")}`;
67297
- }
67298
-
67299
- // src/services/harness-session.service.ts
67300
- function sessionOf({
67301
- context,
67302
- harness,
67303
- sessionId
67304
- }) {
67305
- if (!sessionId) return void 0;
67306
- const inherited = context.environment.inherited;
67307
- const folder = inherited.CLAUDE_PROJECT_DIR || context.cwd;
67308
- return {
67309
- harness,
67310
- sessionId,
67311
- folder: displayFolderOf({ folder, home: inherited.HOME }),
67312
- host: hostname3()
67313
- };
67314
- }
67315
- function forSession({
67316
- client,
67317
- session
67318
- }) {
67319
- return client.withHeaders(sessionHeadersOf({ session }));
67320
- }
67321
- async function rememberSession({
67322
- context,
67323
- claudePid,
67324
- session
67325
- }) {
67326
- if (!session || !claudePid) return;
67327
- const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
67328
- await mkdir4(dirname4(path), { recursive: true, mode: 448 });
67329
- await writeFile4(path, JSON.stringify(session), { mode: 384 });
67330
- }
67331
- async function currentSessionOf({
67332
- context,
67333
- args
67334
- }) {
67335
- const inherited = context.environment.inherited;
67336
- const named = flagText({ args, name: "session" });
67337
- const harness = context.environment.harness;
67338
- if (named) return sessionOf({ context, harness, sessionId: named });
67339
- if (harness === "claude-code" && inherited.CLAUDE_CODE_SESSION_ID) {
67340
- return sessionOf({ context, harness, sessionId: inherited.CLAUDE_CODE_SESSION_ID });
67341
- }
67342
- if (harness === "codex" && inherited.CODEX_THREAD_ID) {
67343
- return sessionOf({ context, harness, sessionId: inherited.CODEX_THREAD_ID });
67344
- }
67345
- const nearest = await nearestHarnessOf({ context });
67346
- if (!nearest) return void 0;
67347
- const path = statePathOf({ context, kind: "sessions", profile: String(nearest.pid) });
67348
- return readFile4(path, "utf8").then(
67349
- (text2) => JSON.parse(text2),
67350
- () => void 0
67351
- );
67352
- }
67353
- async function sessionProfileArgs({
67354
- context,
67355
- args,
67356
- session
67357
- }) {
67358
- if (!session) return args;
67359
- const key = sessionKeyOf({ session });
67360
- const config2 = await context.store.read();
67361
- const bound = config2.sessions?.[key];
67362
- if (bound && config2.profiles[bound]) {
67363
- return { ...args, flags: { ...args.flags, profile: bound } };
67364
- }
67365
- const own2 = flagText({ args, name: "profile" });
67366
- if (own2 && config2.profiles[own2]?.kind === "agent") {
67367
- await context.store.bindSession({ session: key, profile: own2 });
67368
- }
67369
- return args;
67370
- }
67371
- async function liveElsewhere({
67372
- context,
67373
- key,
67374
- claudePid
67375
- }) {
67376
- const folder = dirname4(statePathOf({ context, kind: "sessions", profile: "x" }));
67377
- for (const file3 of await readdir(folder).catch(() => [])) {
67378
- const pid = Number(file3.replace(/\.json$/, ""));
67379
- if (!pid || pid === claudePid || !context.processes.alive(pid)) continue;
67380
- const noted = await readFile4(join4(folder, file3), "utf8").then(
67381
- (text2) => JSON.parse(text2),
67382
- () => void 0
67383
- );
67384
- if (noted && sessionKeyOf({ session: noted }) === key) return true;
67385
- }
67386
- return false;
67387
- }
67388
- function notBoundText({ meta: meta3 }) {
67389
- return `Laze: this agent listens in another session${meta3.bound ? `: ${meta3.bound}` : ""}. Create a new Laze agent with this session: laze agent request. Or move this agent here: laze agent bind.`;
67390
- }
67391
- async function notBoundNotice({
67392
- context,
67393
- client,
67394
- session,
67395
- error: error62
67396
- }) {
67397
- if (!(error62 instanceof LazeApiError) || error62.code !== "session_not_bound") return void 0;
67398
- const meta3 = error62.meta ?? {};
67399
- if (client && session && meta3.session && meta3.host === session.host) {
67400
- const claudePid = (await nearestHarnessOf({ context }))?.pid;
67401
- if (!await liveElsewhere({ context, key: meta3.session, claudePid })) {
67402
- await client.post("/api/agents/me/bind", {});
67403
- return { notice: void 0, rebound: true };
67404
- }
67405
- }
67406
- const key = session ? sessionKeyOf({ session }) : "unknown";
67407
- const path = statePathOf({ context, kind: "told", profile: key });
67408
- const told = await readFile4(path, "utf8").then(
67409
- () => true,
67410
- () => false
67411
- );
67412
- if (told) return { notice: void 0 };
67413
- await mkdir4(dirname4(path), { recursive: true, mode: 448 });
67414
- await writeFile4(path, String(context.nowMs()), { mode: 384 });
67415
- return { notice: notBoundText({ meta: meta3 }) };
67416
- }
67417
-
67418
- // src/services/claude-wait.service.ts
67419
67483
  var ROUND_SECONDS = 50;
67420
67484
  var WATCH_MS = 2e3;
67421
67485
  var CHANNEL_CHECK_MS = 5e3;
67422
67486
  async function holderOf({ path }) {
67423
- return readFile5(path, "utf8").then(
67487
+ return readFile6(path, "utf8").then(
67424
67488
  (text2) => JSON.parse(text2),
67425
67489
  () => void 0
67426
67490
  );
@@ -67543,13 +67607,15 @@ async function waitForMessages({ context, args }) {
67543
67607
  const raw = await context.readStdin();
67544
67608
  const input2 = raw.trim() ? JSON.parse(raw) : {};
67545
67609
  const session = sessionOf({ context, harness: "claude-code", sessionId: input2.session_id });
67546
- const named = await sessionProfileArgs({ context, args, session });
67547
- const { client, name: name2 } = await signedIn({ context, args: named });
67548
67610
  const claudePid = await claudePidOf({ context });
67611
+ const asked = await pluginHookArgs({ context, args, session, claudePid });
67612
+ if (!asked) return 0;
67613
+ const named = await sessionProfileArgs({ context, args: asked, session });
67614
+ const { client, name: name2 } = await signedIn({ context, args: named });
67549
67615
  await rememberSession({ context, claudePid, session });
67550
67616
  const lock = statePathOf({ context, kind: "waiters", profile: name2 });
67551
67617
  if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
67552
- const seen = () => input2.transcript_path ? readFile5(input2.transcript_path, "utf8") : Promise.resolve("");
67618
+ const seen = () => input2.transcript_path ? readFile6(input2.transcript_path, "utf8") : Promise.resolve("");
67553
67619
  const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
67554
67620
  try {
67555
67621
  while (context.nowMs() < deadline) {
@@ -67584,7 +67650,7 @@ async function monitorServes({
67584
67650
  // src/services/codex-link.service.ts
67585
67651
  import { createReadStream } from "node:fs";
67586
67652
  import { readdir as readdir4, rm as rm6, stat as stat2 } from "node:fs/promises";
67587
- import { join as join10, resolve as resolve3 } from "node:path";
67653
+ import { join as join11, resolve as resolve3 } from "node:path";
67588
67654
  import { createInterface as createInterface2 } from "node:readline";
67589
67655
 
67590
67656
  // src/rules/connect-service.rules.ts
@@ -67704,8 +67770,8 @@ function rolloutEventOf({
67704
67770
 
67705
67771
  // src/services/codex-adopt.service.ts
67706
67772
  import { spawn as spawn2 } from "node:child_process";
67707
- import { mkdir as mkdir6, readdir as readdir2, readFile as readFile6, rm as rm3, stat, writeFile as writeFile6 } from "node:fs/promises";
67708
- import { dirname as dirname6, join as join5 } from "node:path";
67773
+ import { mkdir as mkdir6, readdir as readdir2, readFile as readFile7, rm as rm3, stat, writeFile as writeFile6 } from "node:fs/promises";
67774
+ import { dirname as dirname6, join as join6 } from "node:path";
67709
67775
  import { createInterface } from "node:readline";
67710
67776
 
67711
67777
  // src/rules/codex-requests.rules.ts
@@ -67825,11 +67891,11 @@ var CodexAppServer = class _CodexAppServer {
67825
67891
  }
67826
67892
  };
67827
67893
  async function newestThreadId({ codexHome }) {
67828
- const root = join5(codexHome, "sessions");
67894
+ const root = join6(codexHome, "sessions");
67829
67895
  const files2 = await readdir2(root, { recursive: true }).catch(() => []);
67830
67896
  const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
67831
67897
  const dated = await Promise.all(
67832
- rollouts.map(async (file3) => ({ file: file3, at: (await stat(join5(root, file3))).mtimeMs }))
67898
+ rollouts.map(async (file3) => ({ file: file3, at: (await stat(join6(root, file3))).mtimeMs }))
67833
67899
  );
67834
67900
  const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
67835
67901
  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);
@@ -67904,7 +67970,7 @@ async function answer({
67904
67970
  var MAX_RESTART_WAIT_SECONDS = 60;
67905
67971
  var HEALTHY_RUN_MS = 6e4;
67906
67972
  async function recordOf({ path }) {
67907
- return readFile6(path, "utf8").then(
67973
+ return readFile7(path, "utf8").then(
67908
67974
  (text2) => JSON.parse(text2),
67909
67975
  () => void 0
67910
67976
  );
@@ -68007,7 +68073,7 @@ async function adoptedThreadOf({
68007
68073
  );
68008
68074
  if (!held) return threadId;
68009
68075
  const path = statePathOf({ context, kind: "adopt", profile, extension: "forks.json" });
68010
- const forks = await readFile6(path, "utf8").then(
68076
+ const forks = await readFile7(path, "utf8").then(
68011
68077
  (text2) => JSON.parse(text2),
68012
68078
  () => ({})
68013
68079
  );
@@ -68078,20 +68144,20 @@ async function adoptCodex({ context, args }) {
68078
68144
  }
68079
68145
 
68080
68146
  // src/services/connect-delivery.service.ts
68081
- import { mkdir as mkdir8, readFile as readFile8, rename as rename3, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
68147
+ import { mkdir as mkdir8, readFile as readFile9, rename as rename3, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
68082
68148
  import { homedir as homedir2, hostname as hostname4 } from "node:os";
68083
- import { dirname as dirname8, join as join8 } from "node:path";
68149
+ import { dirname as dirname8, join as join9 } from "node:path";
68084
68150
 
68085
68151
  // src/services/codex-turn-watch.service.ts
68086
68152
  import { open as open2, readdir as readdir3 } from "node:fs/promises";
68087
- import { join as join6 } from "node:path";
68153
+ import { join as join7 } from "node:path";
68088
68154
  var READ_MS = 1500;
68089
68155
  var KEEP_WORKING_MS = 3e4;
68090
68156
  async function rolloutPathOf({ delivery }) {
68091
- const root = join6(delivery.codexHome, "sessions");
68157
+ const root = join7(delivery.codexHome, "sessions");
68092
68158
  const files2 = await readdir3(root, { recursive: true }).catch(() => []);
68093
68159
  const file3 = files2.find((name2) => name2.endsWith(`-${delivery.threadId}.jsonl`));
68094
- return file3 ? join6(root, file3) : void 0;
68160
+ return file3 ? join7(root, file3) : void 0;
68095
68161
  }
68096
68162
  async function readFrom({ path, offset }) {
68097
68163
  const handle = await open2(path, "r");
@@ -68177,8 +68243,8 @@ var CodexTurnWatch = class _CodexTurnWatch {
68177
68243
  };
68178
68244
 
68179
68245
  // src/services/openclaw-relay.service.ts
68180
- import { chmod as chmod2, mkdir as mkdir7, readFile as readFile7, writeFile as writeFile7 } from "node:fs/promises";
68181
- import { dirname as dirname7, join as join7 } from "node:path";
68246
+ import { chmod as chmod2, mkdir as mkdir7, readFile as readFile8, writeFile as writeFile7 } from "node:fs/promises";
68247
+ import { dirname as dirname7, join as join8 } from "node:path";
68182
68248
 
68183
68249
  // ../../modules/openclaw/contract/src/openclaw.ts
68184
68250
  var workspaceIdSchema14 = external_exports.string().min(1);
@@ -68406,11 +68472,11 @@ var STOPS = /* @__PURE__ */ new Map([
68406
68472
  [OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
68407
68473
  ]);
68408
68474
  function relaysPathOf({ context }) {
68409
- return join7(dirname7(context.environment.configPath), "connect", "openclaw-relays.json");
68475
+ return join8(dirname7(context.environment.configPath), "connect", "openclaw-relays.json");
68410
68476
  }
68411
68477
  async function readRelays({ context }) {
68412
68478
  try {
68413
- return JSON.parse(await readFile7(relaysPathOf({ context }), "utf8"));
68479
+ return JSON.parse(await readFile8(relaysPathOf({ context }), "utf8"));
68414
68480
  } catch {
68415
68481
  return {};
68416
68482
  }
@@ -68607,14 +68673,14 @@ var RelayLoops = class _RelayLoops {
68607
68673
 
68608
68674
  // src/services/connect-delivery.service.ts
68609
68675
  function connectFolderOf({ context }) {
68610
- return join8(dirname8(context.environment.configPath), "connect");
68676
+ return join9(dirname8(context.environment.configPath), "connect");
68611
68677
  }
68612
68678
  function runStatePathOf({ context }) {
68613
- return join8(connectFolderOf({ context }), "run.json");
68679
+ return join9(connectFolderOf({ context }), "run.json");
68614
68680
  }
68615
68681
  async function readJson({ path }) {
68616
68682
  try {
68617
- return JSON.parse(await readFile8(path, "utf8"));
68683
+ return JSON.parse(await readFile9(path, "utf8"));
68618
68684
  } catch {
68619
68685
  return void 0;
68620
68686
  }
@@ -68848,7 +68914,7 @@ async function runConnectLoop({ context }) {
68848
68914
  // src/services/connect-service.service.ts
68849
68915
  import { createHash } from "node:crypto";
68850
68916
  import { mkdir as mkdir9, rm as rm5, writeFile as writeFile9 } from "node:fs/promises";
68851
- import { dirname as dirname9, join as join9 } from "node:path";
68917
+ import { dirname as dirname9, join as join10 } from "node:path";
68852
68918
  var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the service that delivers to linked Codex sessions.
68853
68919
 
68854
68920
  laze connect install install and start it (systemd --user, a LaunchAgent, or detached)
@@ -68861,17 +68927,17 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
68861
68927
  \`laze openclaw connect --local\`, whose OpenClaw relay it also runs.
68862
68928
  `;
68863
68929
  function installedPathOf({ context }) {
68864
- return join9(connectFolderOf({ context }), "service.json");
68930
+ return join10(connectFolderOf({ context }), "service.json");
68865
68931
  }
68866
68932
  function logPathOf({ context }) {
68867
- return join9(connectFolderOf({ context }), "connect.log");
68933
+ return join10(connectFolderOf({ context }), "connect.log");
68868
68934
  }
68869
68935
  function homeOf({ context }) {
68870
68936
  return context.environment.inherited.HOME ?? dirname9(dirname9(context.environment.configPath));
68871
68937
  }
68872
68938
  function serviceNameOf({ context }) {
68873
68939
  const { configPath } = context.environment;
68874
- if (configPath === join9(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
68940
+ if (configPath === join10(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
68875
68941
  return `laze-connect-${createHash("sha256").update(configPath).digest("hex").slice(0, 8)}`;
68876
68942
  }
68877
68943
  function serviceEnvOf({ context }) {
@@ -68894,8 +68960,8 @@ async function run({ context, command }) {
68894
68960
  async function installSystemd({ context }) {
68895
68961
  const name2 = serviceNameOf({ context });
68896
68962
  const env = context.environment.inherited;
68897
- const base = env.XDG_CONFIG_HOME || join9(homeOf({ context }), ".config");
68898
- const file3 = join9(base, "systemd", "user", `${name2}.service`);
68963
+ const base = env.XDG_CONFIG_HOME || join10(homeOf({ context }), ".config");
68964
+ const file3 = join10(base, "systemd", "user", `${name2}.service`);
68899
68965
  await mkdir9(dirname9(file3), { recursive: true });
68900
68966
  await writeFile9(
68901
68967
  file3,
@@ -68910,7 +68976,7 @@ async function installSystemd({ context }) {
68910
68976
  async function installLaunchd({ context }) {
68911
68977
  const name2 = serviceNameOf({ context });
68912
68978
  const label2 = `ai.laze.${name2}`;
68913
- const file3 = join9(homeOf({ context }), "Library", "LaunchAgents", `${label2}.plist`);
68979
+ const file3 = join10(homeOf({ context }), "Library", "LaunchAgents", `${label2}.plist`);
68914
68980
  const log = logPathOf({ context });
68915
68981
  await mkdir9(dirname9(file3), { recursive: true });
68916
68982
  await writeFile9(
@@ -69078,13 +69144,13 @@ async function newestThreadIn({
69078
69144
  codexHome,
69079
69145
  directory
69080
69146
  }) {
69081
- const root = join10(codexHome, "sessions");
69147
+ const root = join11(codexHome, "sessions");
69082
69148
  const files2 = await readdir4(root, { recursive: true }).catch(() => []);
69083
69149
  const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
69084
69150
  const dated = await Promise.all(
69085
69151
  rollouts.map(async (file3) => ({
69086
- path: join10(root, file3),
69087
- at: await stat2(join10(root, file3)).then(
69152
+ path: join11(root, file3),
69153
+ at: await stat2(join11(root, file3)).then(
69088
69154
  (info) => info.mtimeMs,
69089
69155
  () => 0
69090
69156
  )
@@ -69152,17 +69218,22 @@ async function linkCodexSession({
69152
69218
  }
69153
69219
 
69154
69220
  // src/services/laze-plugin.service.ts
69155
- import { mkdir as mkdir10, readFile as readFile9, writeFile as writeFile10 } from "node:fs/promises";
69156
- import { dirname as dirname10, join as join11 } from "node:path";
69221
+ import { mkdir as mkdir10, readFile as readFile10, writeFile as writeFile10 } from "node:fs/promises";
69222
+ import { dirname as dirname10, join as join12 } from "node:path";
69157
69223
 
69158
69224
  // src/rules/laze-plugin.rules.ts
69159
69225
  var LAZE_PLUGIN = "laze";
69160
69226
  var NPX_CLI = ["npx", "-y", "@lazehq/cli@latest"];
69161
69227
  var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
69162
- function cliLineOf({ program, args }) {
69228
+ function cliLineOf({
69229
+ program,
69230
+ args,
69231
+ configPath
69232
+ }) {
69163
69233
  const here = [...program, ...args].map(quote).join(" ");
69164
69234
  const fallback = [...NPX_CLI, ...args].join(" ");
69165
- return `if [ -e ${quote(program.at(-1) ?? "")} ]; then exec ${here}; else exec ${fallback}; fi`;
69235
+ const run4 = `if [ -e ${quote(program.at(-1) ?? "")} ]; then exec ${here}; else exec ${fallback}; fi`;
69236
+ return `export LAZE_CLI_CONFIG=${quote(configPath)}; ${run4}`;
69166
69237
  }
69167
69238
  var SKILL = `---
69168
69239
  name: laze
@@ -69196,10 +69267,28 @@ are waiting, if you think one was missed.
69196
69267
  If \`laze\` is not on the PATH, run the same commands through \`npx -y @lazehq/cli@latest\`.
69197
69268
  Never print or repeat your Laze key.
69198
69269
  `;
69270
+ function pluginHooksOf({ line }) {
69271
+ const hook = (name2, timeout) => ({
69272
+ type: "command",
69273
+ command: line(["hook", name2, "--plugin"]),
69274
+ timeout
69275
+ });
69276
+ const waiter = { ...hook("wait", WAIT_HOOK_TIMEOUT_SECONDS), async: true, asyncRewake: true };
69277
+ return {
69278
+ description: "Hands Laze messages to the session and wakes it when one arrives",
69279
+ hooks: {
69280
+ Stop: [{ hooks: [hook("stop", HOOK_TIMEOUTS.Stop), waiter] }],
69281
+ SessionStart: [{ hooks: [waiter] }],
69282
+ PreToolUse: [{ hooks: [hook("pre-tool", HOOK_TIMEOUTS.PreToolUse)] }]
69283
+ }
69284
+ };
69285
+ }
69199
69286
  function lazePluginFiles({
69200
69287
  program,
69201
- version: version2
69288
+ version: version2,
69289
+ configPath
69202
69290
  }) {
69291
+ const line = (args) => cliLineOf({ program, args, configPath });
69203
69292
  const json5 = (value) => `${JSON.stringify(value, null, 2)}
69204
69293
  `;
69205
69294
  const description = "Laze messages reach this session, and the laze tools to answer them";
@@ -69234,10 +69323,11 @@ function lazePluginFiles({
69234
69323
  "laze/monitors/monitors.json": json5([
69235
69324
  {
69236
69325
  name: "laze-messages",
69237
- command: cliLineOf({ program, args: ["hook", "monitor"] }),
69326
+ command: line(["hook", "monitor"]),
69238
69327
  description: "Laze messages for this session"
69239
69328
  }
69240
- ])
69329
+ ]),
69330
+ "laze/hooks/hooks.json": json5(pluginHooksOf({ line }))
69241
69331
  };
69242
69332
  }
69243
69333
 
@@ -69245,11 +69335,11 @@ function lazePluginFiles({
69245
69335
  var REGISTER_LIMIT_MS = 6e4;
69246
69336
  var quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
69247
69337
  function pluginFolderOf({ context }) {
69248
- return join11(dirname10(context.environment.configPath), "plugins");
69338
+ return join12(dirname10(context.environment.configPath), "plugins");
69249
69339
  }
69250
69340
  async function pluginIsCurrent({ context }) {
69251
- const manifest = join11(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
69252
- const written = await readFile9(manifest, "utf8").then(
69341
+ const manifest = join12(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
69342
+ const written = await readFile10(manifest, "utf8").then(
69253
69343
  (text2) => JSON.parse(text2).version,
69254
69344
  () => void 0
69255
69345
  );
@@ -69257,9 +69347,13 @@ async function pluginIsCurrent({ context }) {
69257
69347
  }
69258
69348
  async function writeLazePlugin({ context }) {
69259
69349
  const folder = pluginFolderOf({ context });
69260
- const files2 = lazePluginFiles({ program: context.program, version: cliVersionOf() });
69350
+ const files2 = lazePluginFiles({
69351
+ program: context.program,
69352
+ version: cliVersionOf(),
69353
+ configPath: context.environment.configPath
69354
+ });
69261
69355
  for (const [path, text2] of Object.entries(files2)) {
69262
- const target = join11(folder, path);
69356
+ const target = join12(folder, path);
69263
69357
  await mkdir10(dirname10(target), { recursive: true });
69264
69358
  await writeFile10(target, text2);
69265
69359
  }
@@ -69272,18 +69366,21 @@ async function registerWithClaude({ context, folder }) {
69272
69366
  `claude plugin marketplace update ${LAZE_PLUGIN} ${quiet}`,
69273
69367
  `{ claude plugin install ${LAZE_PLUGIN}@${LAZE_PLUGIN} --scope user ${quiet} || claude plugin update ${LAZE_PLUGIN}@${LAZE_PLUGIN} ${quiet}; }`
69274
69368
  ].join("; ");
69275
- const run4 = context.runCommand({ command: ["sh", "-c", script], env: {} }).catch(() => 1);
69369
+ const stop3 = new AbortController();
69370
+ const command = ["sh", "-c", script];
69371
+ const run4 = context.runCommand({ command, env: {}, signal: stop3.signal }).catch(() => 1);
69276
69372
  const done = new AbortController();
69277
69373
  const gaveUp = context.sleep(REGISTER_LIMIT_MS, done.signal).then(() => -1);
69278
69374
  const code = await Promise.race([run4, gaveUp]);
69279
69375
  done.abort();
69376
+ stop3.abort();
69280
69377
  return code === 0;
69281
69378
  }
69282
69379
  function registeredMarkOf({ context }) {
69283
- return join11(pluginFolderOf({ context }), "registered");
69380
+ return join12(pluginFolderOf({ context }), "registered");
69284
69381
  }
69285
69382
  async function pluginRegistered({ context }) {
69286
- return readFile9(registeredMarkOf({ context }), "utf8").then(
69383
+ return readFile10(registeredMarkOf({ context }), "utf8").then(
69287
69384
  () => true,
69288
69385
  () => false
69289
69386
  );
@@ -69297,7 +69394,7 @@ async function installLazePlugin({ context }) {
69297
69394
  async function plugin({ context, args }) {
69298
69395
  const action = args.words[1] ?? "install";
69299
69396
  if (action === "path") {
69300
- context.out(`${join11(pluginFolderOf({ context }), LAZE_PLUGIN)}
69397
+ context.out(`${join12(pluginFolderOf({ context }), LAZE_PLUGIN)}
69301
69398
  `);
69302
69399
  return 0;
69303
69400
  }
@@ -69434,7 +69531,7 @@ async function pushInbox({
69434
69531
  }
69435
69532
 
69436
69533
  // src/services/plugin-tip.service.ts
69437
- import { mkdir as mkdir12, readFile as readFile10, writeFile as writeFile12 } from "node:fs/promises";
69534
+ import { mkdir as mkdir12, readFile as readFile11, writeFile as writeFile12 } from "node:fs/promises";
69438
69535
  import { dirname as dirname12 } from "node:path";
69439
69536
  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.";
69440
69537
  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.";
@@ -69478,7 +69575,7 @@ async function reloadTipOnce({
69478
69575
  }) {
69479
69576
  if (!session || !monitorsRunHere({ context })) return void 0;
69480
69577
  if (!await pluginRegistered({ context })) return void 0;
69481
- const told = await readFile10(toldPathOf({ context, session }), "utf8").then(
69578
+ const told = await readFile11(toldPathOf({ context, session }), "utf8").then(
69482
69579
  () => true,
69483
69580
  () => false
69484
69581
  );
@@ -69544,9 +69641,9 @@ async function installHooks({
69544
69641
  directory,
69545
69642
  profile
69546
69643
  }) {
69547
- const folder = join12(directory, ".claude");
69548
- const path = join12(folder, "settings.local.json");
69549
- const current2 = await readFile11(path, "utf8").then(
69644
+ const folder = join13(directory, ".claude");
69645
+ const path = join13(folder, "settings.local.json");
69646
+ const current2 = await readFile12(path, "utf8").then(
69550
69647
  (text2) => JSON.parse(text2),
69551
69648
  () => ({})
69552
69649
  );
@@ -69747,7 +69844,7 @@ async function reportTranscript({
69747
69844
  input: input2
69748
69845
  }) {
69749
69846
  if (!input2.transcript_path || !input2.session_id) return;
69750
- const lines = (await readFile11(input2.transcript_path, "utf8")).split("\n");
69847
+ const lines = (await readFile12(input2.transcript_path, "utf8")).split("\n");
69751
69848
  const context = readTranscript({ lines });
69752
69849
  await client.post("/api/agents/me/activity", {
69753
69850
  sessionId: input2.session_id,
@@ -69764,21 +69861,23 @@ async function handOver({ context, args }) {
69764
69861
  const raw = await context.readStdin();
69765
69862
  const input2 = raw.trim() ? JSON.parse(raw) : {};
69766
69863
  const session = sessionOf({ context, harness: "claude-code", sessionId: input2.session_id });
69767
- const named = await sessionProfileArgs({ context, args, session });
69864
+ const claudePid = await claudePidOf({ context });
69865
+ const asked = await pluginHookArgs({ context, args, session, claudePid });
69866
+ if (!asked) return;
69867
+ const named = await sessionProfileArgs({ context, args: asked, session });
69768
69868
  const { client, name: agent2 } = await signedIn({ context, args: named });
69769
69869
  await reportTranscript({ client, input: input2 }).catch(
69770
69870
  (error62) => context.err(`laze: could not report context: ${String(error62)}
69771
69871
  `)
69772
69872
  );
69773
69873
  if (input2.stop_hook_active) return;
69774
- const claudePid = await claudePidOf({ context });
69775
69874
  if (await monitorServes({ context, profile: agent2, claudePid })) {
69776
69875
  return turnEnded({ context, client, agent: agent2 });
69777
69876
  }
69778
69877
  const kept = await dueFromSpool({
69779
69878
  context,
69780
69879
  profile: agent2,
69781
- seen: () => input2.transcript_path ? readFile11(input2.transcript_path, "utf8") : Promise.resolve(""),
69880
+ seen: () => input2.transcript_path ? readFile12(input2.transcript_path, "utf8") : Promise.resolve(""),
69782
69881
  pushedToo: false
69783
69882
  });
69784
69883
  const claim3 = forSession({ client, session });
@@ -69812,8 +69911,8 @@ async function addSessionStartWaiter({ context, args }) {
69812
69911
  const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
69813
69912
  const profile = flagText({ args, name: "profile" });
69814
69913
  if (!directory || !profile) return;
69815
- const path = join12(directory, ".claude", "settings.local.json");
69816
- const settings2 = await readFile11(path, "utf8").then(
69914
+ const path = join13(directory, ".claude", "settings.local.json");
69915
+ const settings2 = await readFile12(path, "utf8").then(
69817
69916
  (text2) => JSON.parse(text2),
69818
69917
  () => void 0
69819
69918
  );
@@ -69822,7 +69921,7 @@ async function addSessionStartWaiter({ context, args }) {
69822
69921
  }
69823
69922
  async function refreshPlugin({ context }) {
69824
69923
  if (await pluginIsCurrent({ context })) return;
69825
- const logPath = join12(pluginFolderOf({ context }), "install.log");
69924
+ const logPath = join13(pluginFolderOf({ context }), "install.log");
69826
69925
  context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
69827
69926
  }
69828
69927
  async function stopHook({ context, args }) {
@@ -69840,7 +69939,7 @@ async function stopHook({ context, args }) {
69840
69939
  }
69841
69940
 
69842
69941
  // src/services/agent-manage-commands.service.ts
69843
- import { readFile as readFile12 } from "node:fs/promises";
69942
+ import { readFile as readFile13 } from "node:fs/promises";
69844
69943
  import { extname, resolve as resolve5 } from "node:path";
69845
69944
 
69846
69945
  // src/rules/login-format.rules.ts
@@ -69969,7 +70068,7 @@ async function avatarOf({
69969
70068
  }) {
69970
70069
  const path = flagText({ args, name: "avatar" });
69971
70070
  if (!path) return void 0;
69972
- const bytes = await readFile12(resolve5(context.cwd, path)).catch(() => {
70071
+ const bytes = await readFile13(resolve5(context.cwd, path)).catch(() => {
69973
70072
  throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
69974
70073
  });
69975
70074
  const uploaded = await client.post("/api/agents/avatars", {
@@ -70659,8 +70758,8 @@ async function requestAgent({ context, args }) {
70659
70758
  }
70660
70759
 
70661
70760
  // src/services/app-commands.service.ts
70662
- import { mkdir as mkdir14, readdir as readdir5, readFile as readFile13, writeFile as writeFile15 } from "node:fs/promises";
70663
- import { dirname as dirname13, join as join14, relative as relative3, resolve as resolve6, sep as sep2 } from "node:path";
70761
+ import { mkdir as mkdir14, readdir as readdir5, readFile as readFile14, writeFile as writeFile15 } from "node:fs/promises";
70762
+ import { dirname as dirname13, join as join15, relative as relative3, resolve as resolve6, sep as sep2 } from "node:path";
70664
70763
 
70665
70764
  // ../../modules/app/contract/src/app.connections.ts
70666
70765
  var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
@@ -73053,7 +73152,7 @@ async function appPinsCommand({
73053
73152
  import { execFile } from "node:child_process";
73054
73153
  import { mkdtemp, rm as rm8, writeFile as writeFile14 } from "node:fs/promises";
73055
73154
  import { tmpdir } from "node:os";
73056
- import { join as join13 } from "node:path";
73155
+ import { join as join14 } from "node:path";
73057
73156
  import { promisify } from "node:util";
73058
73157
  var run2 = promisify(execFile);
73059
73158
  var MODULE_SYNTAX = /^\s*(import|export)\s/m;
@@ -73082,11 +73181,11 @@ async function scriptErrorsOf({
73082
73181
  const unknown2 = unknownCollectionsOf({ files: files2, collections });
73083
73182
  const scripts = files2.flatMap(scriptsOf);
73084
73183
  if (scripts.length === 0) return unknown2;
73085
- const dir = await mkdtemp(join13(tmpdir(), "laze-app-check-"));
73184
+ const dir = await mkdtemp(join14(tmpdir(), "laze-app-check-"));
73086
73185
  try {
73087
73186
  const errors = await Promise.all(
73088
73187
  scripts.map(async (script, index) => {
73089
- const file3 = join13(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
73188
+ const file3 = join14(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
73090
73189
  await writeFile14(file3, script.code);
73091
73190
  try {
73092
73191
  await run2(process.execPath, ["--check", file3]);
@@ -73236,7 +73335,7 @@ async function turnTokenOf({
73236
73335
  const pinned = env.LAZE_TURN_TOKEN?.trim();
73237
73336
  if (pinned) return pinned;
73238
73337
  if (env.LAZE_TURN_FILE) {
73239
- return readFile13(env.LAZE_TURN_FILE, "utf8").then(
73338
+ return readFile14(env.LAZE_TURN_FILE, "utf8").then(
73240
73339
  (text2) => text2.trim(),
73241
73340
  () => ""
73242
73341
  );
@@ -73262,7 +73361,7 @@ function folderOf({ context, word: word3 }) {
73262
73361
  return resolve6(context.cwd, word3 ?? ".");
73263
73362
  }
73264
73363
  async function readManifest(folder) {
73265
- const text2 = await readFile13(join14(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
73364
+ const text2 = await readFile14(join15(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
73266
73365
  if (text2 === void 0) return void 0;
73267
73366
  const parsed = appManifestSchema.safeParse(JSON.parse(text2));
73268
73367
  if (!parsed.success) {
@@ -73297,7 +73396,7 @@ async function jsonFlag({
73297
73396
  }) {
73298
73397
  const raw = flagText({ args, name: name2 });
73299
73398
  if (!raw) return void 0;
73300
- const text2 = raw.startsWith("@") ? await readFile13(resolve6(context.cwd, raw.slice(1)), "utf8") : raw;
73399
+ const text2 = raw.startsWith("@") ? await readFile14(resolve6(context.cwd, raw.slice(1)), "utf8") : raw;
73301
73400
  try {
73302
73401
  return JSON.parse(text2);
73303
73402
  } catch {
@@ -73310,7 +73409,7 @@ async function listFiles(folder) {
73310
73409
  while (pending.length > 0 && found.length <= MAX_FILES) {
73311
73410
  const current2 = pending.pop() ?? folder;
73312
73411
  for (const entry of await readdir5(current2, { withFileTypes: true })) {
73313
- const path = join14(current2, entry.name);
73412
+ const path = join15(current2, entry.name);
73314
73413
  const rel = relative3(folder, path).split(sep2).join("/");
73315
73414
  if (isSkippedPath({ path: rel })) continue;
73316
73415
  if (entry.isDirectory()) pending.push(path);
@@ -73354,8 +73453,8 @@ var appCreate = async ({ context, args }) => {
73354
73453
  await mkdir14(folder, { recursive: true });
73355
73454
  const files2 = template ? templateFiles({ template, name: name2 }) : {};
73356
73455
  for (const [path, content] of Object.entries(files2)) {
73357
- await mkdir14(dirname13(join14(folder, path)), { recursive: true });
73358
- await writeFile15(join14(folder, path), content);
73456
+ await mkdir14(dirname13(join15(folder, path)), { recursive: true });
73457
+ await writeFile15(join15(folder, path), content);
73359
73458
  }
73360
73459
  const manifest = {
73361
73460
  app: { id: app2.id, name: app2.name, slug: app2.slug },
@@ -73363,7 +73462,7 @@ var appCreate = async ({ context, args }) => {
73363
73462
  views: template?.views ? [...template.views] : [],
73364
73463
  seed: template ? { ...template.seed } : {}
73365
73464
  };
73366
- await writeFile15(join14(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
73465
+ await writeFile15(join15(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
73367
73466
  `);
73368
73467
  print5({
73369
73468
  context,
@@ -73400,7 +73499,7 @@ var appPush = async ({ context, args }) => {
73400
73499
  paths.map(
73401
73500
  async (path) => buildFileOf({
73402
73501
  path: relative3(folder, path).split(sep2).join("/"),
73403
- bytes: await readFile13(path)
73502
+ bytes: await readFile14(path)
73404
73503
  })
73405
73504
  )
73406
73505
  );
@@ -73783,7 +73882,7 @@ var appImport = async ({ context, args }) => {
73783
73882
  const words = args.words.slice(2);
73784
73883
  const [named, collection, file3] = words.length >= 3 ? words : [void 0, ...words];
73785
73884
  if (!collection || !file3) throw new CliUsageError(USAGE5);
73786
- const csv = await readFile13(resolve6(context.cwd, file3), "utf8").catch(() => {
73885
+ const csv = await readFile14(resolve6(context.cwd, file3), "utf8").catch(() => {
73787
73886
  throw new CliUsageError(`Cannot read ${file3}`);
73788
73887
  });
73789
73888
  const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
@@ -74349,8 +74448,8 @@ async function billing({ context, args }) {
74349
74448
 
74350
74449
  // src/services/browser-commands.service.ts
74351
74450
  import { randomBytes } from "node:crypto";
74352
- import { mkdir as mkdir15, readFile as readFile14, writeFile as writeFile16 } from "node:fs/promises";
74353
- import { dirname as dirname14, join as join15 } from "node:path";
74451
+ import { mkdir as mkdir15, readFile as readFile15, writeFile as writeFile16 } from "node:fs/promises";
74452
+ import { dirname as dirname14, join as join16 } from "node:path";
74354
74453
 
74355
74454
  // src/services/browser-tab-commands.service.ts
74356
74455
  var BROWSER_TAB_PATHS = {
@@ -74896,7 +74995,7 @@ async function turnTokenOf2({ context }) {
74896
74995
  const pinned = env.LAZE_TURN_TOKEN?.trim();
74897
74996
  if (pinned) return pinned;
74898
74997
  if (!env.LAZE_TURN_FILE) return "";
74899
- return readFile14(env.LAZE_TURN_FILE, "utf8").then(
74998
+ return readFile15(env.LAZE_TURN_FILE, "utf8").then(
74900
74999
  (text2) => text2.trim(),
74901
75000
  () => ""
74902
75001
  );
@@ -74970,7 +75069,7 @@ async function cdp({ context, args }) {
74970
75069
  }
74971
75070
  function bridgeStatePath({ context, machine: machine2 }) {
74972
75071
  const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
74973
- return join15(dirname14(context.environment.configPath), "bridges", `${safe}.json`);
75072
+ return join16(dirname14(context.environment.configPath), "bridges", `${safe}.json`);
74974
75073
  }
74975
75074
  async function bridgePort({
74976
75075
  context,
@@ -74978,7 +75077,7 @@ async function bridgePort({
74978
75077
  access
74979
75078
  }) {
74980
75079
  const path = bridgeStatePath({ context, machine: machine2 });
74981
- const live = await readFile14(path, "utf8").then(
75080
+ const live = await readFile15(path, "utf8").then(
74982
75081
  (text2) => JSON.parse(text2),
74983
75082
  () => void 0
74984
75083
  );
@@ -75636,7 +75735,7 @@ async function channelSettings({ context, args }) {
75636
75735
  }
75637
75736
 
75638
75737
  // src/services/chat-actions-commands.service.ts
75639
- import { readFile as readFile15 } from "node:fs/promises";
75738
+ import { readFile as readFile16 } from "node:fs/promises";
75640
75739
  import { basename as basename2, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve7 } from "node:path";
75641
75740
 
75642
75741
  // src/services/file-upload.service.ts
@@ -75941,7 +76040,7 @@ function uploadNameOf({ cwd, path }) {
75941
76040
  }
75942
76041
  var fileUpload = async ({ context, args, client }) => {
75943
76042
  const path = resolve7(context.cwd, wordAt(args, 3));
75944
- const bytes = new Uint8Array(await readFile15(path));
76043
+ const bytes = new Uint8Array(await readFile16(path));
75945
76044
  const answer4 = await uploadFile({
75946
76045
  context,
75947
76046
  client,
@@ -76106,26 +76205,9 @@ async function chatActions({
76106
76205
  }
76107
76206
 
76108
76207
  // src/services/claude-monitor.service.ts
76109
- import { readFile as readFile16, rm as rm9 } from "node:fs/promises";
76208
+ import { readFile as readFile17, rm as rm9 } from "node:fs/promises";
76110
76209
  var MONITOR_IDLE_MS = 3e4;
76111
76210
  var MONITOR_OUTRANKED_MS = 3e3;
76112
- async function agentProfileHere({
76113
- context,
76114
- args,
76115
- session,
76116
- claudePid
76117
- }) {
76118
- const config2 = await context.store.read();
76119
- const cwd = (claudePid ? await context.processes.cwdOf(claudePid) : void 0) ?? context.cwd;
76120
- const folder = boundProfileOf({ bindings: config2.bindings, cwd });
76121
- if (!folder && !session) return void 0;
76122
- const asked = { ...args, flags: { ...args.flags, ...folder ? { profile: folder } : {} } };
76123
- const name2 = flagText({
76124
- args: await sessionProfileArgs({ context, args: asked, session }),
76125
- name: "profile"
76126
- });
76127
- return name2 && config2.profiles[name2]?.kind === "agent" ? name2 : void 0;
76128
- }
76129
76211
  async function deliverOnce({
76130
76212
  context,
76131
76213
  args,
@@ -76212,7 +76294,7 @@ async function monitorSessionOf({
76212
76294
  const fromEnv = sessionOf({ context, harness: "claude-code", sessionId });
76213
76295
  if (fromEnv || !claudePid) return fromEnv;
76214
76296
  const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
76215
- return readFile16(path, "utf8").then(
76297
+ return readFile17(path, "utf8").then(
76216
76298
  (text2) => JSON.parse(text2),
76217
76299
  () => void 0
76218
76300
  );
@@ -77699,10 +77781,10 @@ async function computer({ context, args }) {
77699
77781
  }
77700
77782
 
77701
77783
  // src/services/connect-commands.service.ts
77702
- import { readFile as readFile18 } from "node:fs/promises";
77784
+ import { readFile as readFile19 } from "node:fs/promises";
77703
77785
 
77704
77786
  // src/services/mcp-gateway.service.ts
77705
- import { readFile as readFile17 } from "node:fs/promises";
77787
+ import { readFile as readFile18 } from "node:fs/promises";
77706
77788
  import { createInterface as createInterface3 } from "node:readline";
77707
77789
  var TURN_HEADER = "x-laze-turn";
77708
77790
  function serveMcpGateway({
@@ -77745,7 +77827,7 @@ async function relayMcpLines({
77745
77827
  const github3 = env.LAZE_GITHUB_CONNECTION;
77746
77828
  const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
77747
77829
  const turnFile = env.LAZE_TURN_FILE;
77748
- const readTurn = () => readFile17(turnFile, "utf8").then(
77830
+ const readTurn = () => readFile18(turnFile, "utf8").then(
77749
77831
  (text2) => text2.trim(),
77750
77832
  () => ""
77751
77833
  );
@@ -77835,7 +77917,7 @@ async function turnOf({ context }) {
77835
77917
  const pinned = env.LAZE_TURN_TOKEN?.trim();
77836
77918
  if (pinned) return pinned;
77837
77919
  const file3 = env.LAZE_TURN_FILE;
77838
- const turn = file3 ? await readFile18(file3, "utf8").then(
77920
+ const turn = file3 ? await readFile19(file3, "utf8").then(
77839
77921
  (text2) => text2.trim(),
77840
77922
  () => ""
77841
77923
  ) : "";
@@ -77893,11 +77975,11 @@ async function connect({
77893
77975
  }
77894
77976
 
77895
77977
  // src/services/connector-commands.service.ts
77896
- import { readFile as readFile20 } from "node:fs/promises";
77978
+ import { readFile as readFile21 } from "node:fs/promises";
77897
77979
  import { resolve as resolve8 } from "node:path";
77898
77980
 
77899
77981
  // src/services/vault-keychain-commands.service.ts
77900
- import { readFile as readFile19 } from "node:fs/promises";
77982
+ import { readFile as readFile20 } from "node:fs/promises";
77901
77983
 
77902
77984
  // src/rules/vault-input.rules.ts
77903
77985
  function secondsOf(text2) {
@@ -78208,7 +78290,7 @@ async function secretText({ context, args }) {
78208
78290
  );
78209
78291
  }
78210
78292
  const file3 = flagText({ args, name: "from-file" });
78211
- const text2 = file3 ? await readFile19(file3, "utf8") : await context.readStdin();
78293
+ const text2 = file3 ? await readFile20(file3, "utf8") : await context.readStdin();
78212
78294
  const trimmed = text2.replace(/\r?\n$/, "");
78213
78295
  if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
78214
78296
  return trimmed;
@@ -78406,7 +78488,7 @@ async function keyText({ context, args }) {
78406
78488
  throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
78407
78489
  }
78408
78490
  const file3 = flagText({ args, name: "from-file" });
78409
- const text2 = file3 ? await readFile20(resolve8(context.cwd, file3), "utf8") : await context.readStdin();
78491
+ const text2 = file3 ? await readFile21(resolve8(context.cwd, file3), "utf8") : await context.readStdin();
78410
78492
  const trimmed = text2.trim();
78411
78493
  if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
78412
78494
  return trimmed;
@@ -78792,8 +78874,8 @@ var DOMAINS_USAGE = `Usage:
78792
78874
  var printJson4 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
78793
78875
  `);
78794
78876
  function printDomain(context, row) {
78795
- const join19 = row.autoJoin ? "auto-join on" : "auto-join off";
78796
- context.out(`${row.domain} ${join19}${row.enforced ? " single sign-on enforced" : ""}
78877
+ const join20 = row.autoJoin ? "auto-join on" : "auto-join off";
78878
+ context.out(`${row.domain} ${join20}${row.enforced ? " single sign-on enforced" : ""}
78797
78879
  `);
78798
78880
  }
78799
78881
  async function list4({ context, args }) {
@@ -78825,7 +78907,7 @@ async function domains({ context, args }) {
78825
78907
  }
78826
78908
 
78827
78909
  // src/services/feed-commands.service.ts
78828
- import { readFile as readFile22 } from "node:fs/promises";
78910
+ import { readFile as readFile23 } from "node:fs/promises";
78829
78911
  import { resolve as resolve10 } from "node:path";
78830
78912
 
78831
78913
  // src/rules/feed-input.rules.ts
@@ -78950,7 +79032,7 @@ function feedFlagsOf({ args }) {
78950
79032
  }
78951
79033
 
78952
79034
  // src/services/feed-files.service.ts
78953
- import { readFile as readFile21 } from "node:fs/promises";
79035
+ import { readFile as readFile22 } from "node:fs/promises";
78954
79036
  import { basename as basename3, resolve as resolve9 } from "node:path";
78955
79037
 
78956
79038
  // ../../modules/feed/contract/src/feed.ts
@@ -79543,7 +79625,7 @@ async function local({ context, path }) {
79543
79625
  return {
79544
79626
  fileName,
79545
79627
  contentType: contentTypeOf(fileName),
79546
- bytes: new Uint8Array(await readFile21(full))
79628
+ bytes: new Uint8Array(await readFile22(full))
79547
79629
  };
79548
79630
  }
79549
79631
  async function directWith({ client, to }) {
@@ -79621,7 +79703,7 @@ async function bodyOf2({
79621
79703
  flags: flags2
79622
79704
  }) {
79623
79705
  const body = { ...flags2.fields };
79624
- const read3 = (source) => "file" in source ? readFile22(resolve10(context.cwd, source.file), "utf8") : source.text;
79706
+ const read3 = (source) => "file" in source ? readFile23(resolve10(context.cwd, source.file), "utf8") : source.text;
79625
79707
  for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read3(source);
79626
79708
  if (flags2.rich) {
79627
79709
  const text2 = await read3(flags2.rich.source);
@@ -79783,7 +79865,7 @@ async function textFlag({
79783
79865
  }) {
79784
79866
  const value = flagText({ args, name: name2 });
79785
79867
  if (!value.startsWith("@")) return value;
79786
- return readFile22(resolve10(context.cwd, value.slice(1)), "utf8");
79868
+ return readFile23(resolve10(context.cwd, value.slice(1)), "utf8");
79787
79869
  }
79788
79870
  async function feedList({ context, args }) {
79789
79871
  const { client } = await signedIn({ context, args });
@@ -79893,7 +79975,7 @@ async function feed({ context, args }) {
79893
79975
  }
79894
79976
 
79895
79977
  // src/services/github-commands.service.ts
79896
- import { readFile as readFile23 } from "node:fs/promises";
79978
+ import { readFile as readFile24 } from "node:fs/promises";
79897
79979
 
79898
79980
  // src/rules/github-signature.rules.ts
79899
79981
  var TURN_SEPARATOR = "~";
@@ -79963,7 +80045,7 @@ var REAL_GH = "/usr/bin/gh";
79963
80045
  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>`.";
79964
80046
  async function turnFileToken({ env }) {
79965
80047
  if (!env.LAZE_TURN_FILE) return "";
79966
- return readFile23(env.LAZE_TURN_FILE, "utf8").then(
80048
+ return readFile24(env.LAZE_TURN_FILE, "utf8").then(
79967
80049
  (text2) => text2.trim(),
79968
80050
  () => ""
79969
80051
  );
@@ -79997,7 +80079,7 @@ async function githubGh({
79997
80079
  args: args.rest,
79998
80080
  agentName: profile.name ?? "An agent",
79999
80081
  threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
80000
- readBodyFile: (path) => path === "-" ? context.readStdin() : readFile23(path, "utf8")
80082
+ readBodyFile: (path) => path === "-" ? context.readStdin() : readFile24(path, "utf8")
80001
80083
  });
80002
80084
  return context.runCommand({
80003
80085
  command: [REAL_GH, ...ghArgs],
@@ -80096,7 +80178,7 @@ async function setAgentGithub({
80096
80178
  }
80097
80179
 
80098
80180
  // src/services/history-commands.service.ts
80099
- import { readFile as readFile24 } from "node:fs/promises";
80181
+ import { readFile as readFile25 } from "node:fs/promises";
80100
80182
 
80101
80183
  // src/rules/history-format.rules.ts
80102
80184
  function timeOf2(iso) {
@@ -80192,7 +80274,7 @@ async function turnTokenOf3({ context }) {
80192
80274
  const pinned = env.LAZE_TURN_TOKEN?.trim();
80193
80275
  if (pinned) return pinned;
80194
80276
  if (!env.LAZE_TURN_FILE) return "";
80195
- return readFile24(env.LAZE_TURN_FILE, "utf8").then(
80277
+ return readFile25(env.LAZE_TURN_FILE, "utf8").then(
80196
80278
  (text2) => text2.trim(),
80197
80279
  () => ""
80198
80280
  );
@@ -80384,19 +80466,19 @@ async function ip({ context, args }) {
80384
80466
  }
80385
80467
 
80386
80468
  // src/services/join-commands.service.ts
80387
- import { mkdir as mkdir16, readFile as readFile25, rename as rename5, rm as rm10, writeFile as writeFile17 } from "node:fs/promises";
80388
- import { dirname as dirname15, join as join16 } from "node:path";
80469
+ import { mkdir as mkdir16, readFile as readFile26, rename as rename5, rm as rm10, writeFile as writeFile17 } from "node:fs/promises";
80470
+ import { dirname as dirname15, join as join17 } from "node:path";
80389
80471
  var DEFAULT_WAIT_SECONDS2 = 100;
80390
80472
  var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
80391
80473
  function pendingPathOf({ context }) {
80392
- return join16(dirname15(context.environment.configPath), "join", "pending.json");
80474
+ return join17(dirname15(context.environment.configPath), "join", "pending.json");
80393
80475
  }
80394
80476
  async function readPending({
80395
80477
  context,
80396
80478
  url: url2,
80397
80479
  args
80398
80480
  }) {
80399
- const pending = await readFile25(pendingPathOf({ context }), "utf8").then(
80481
+ const pending = await readFile26(pendingPathOf({ context }), "utf8").then(
80400
80482
  (text2) => JSON.parse(text2),
80401
80483
  () => void 0
80402
80484
  );
@@ -80726,9 +80808,9 @@ function machineAccessCommand(name2) {
80726
80808
 
80727
80809
  // src/services/vault-commands.service.ts
80728
80810
  import { createHash as createHash2 } from "node:crypto";
80729
- import { mkdir as mkdir17, readFile as readFile26, rm as rm11, writeFile as writeFile18 } from "node:fs/promises";
80811
+ import { mkdir as mkdir17, readFile as readFile27, rm as rm11, writeFile as writeFile18 } from "node:fs/promises";
80730
80812
  import { tmpdir as tmpdir2 } from "node:os";
80731
- import { dirname as dirname16, join as join17 } from "node:path";
80813
+ import { dirname as dirname16, join as join18 } from "node:path";
80732
80814
  var USAGE10 = `Usage: laze vault run <connection> --reason "<one plain sentence>" [--wait <s>] -- <command> [args...]
80733
80815
  Runs the command with the connection's values in its environment, on a Laze agent's computer
80734
80816
  or on a machine it runs on.`;
@@ -80767,7 +80849,7 @@ async function turnTokenOf4({
80767
80849
  if (pinned) return pinned;
80768
80850
  if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
80769
80851
  try {
80770
- return (await readFile26(turnFile, "utf8")).trim();
80852
+ return (await readFile27(turnFile, "utf8")).trim();
80771
80853
  } catch {
80772
80854
  throw new CliUsageError(`${command} works only during an agent's turn`);
80773
80855
  }
@@ -80777,11 +80859,11 @@ function runKeyPathOf({
80777
80859
  connection
80778
80860
  }) {
80779
80861
  const name2 = createHash2("sha256").update(connection).digest("hex");
80780
- const base = turnFile ? dirname16(turnFile) : join17(tmpdir2(), "laze-vault");
80781
- return join17(base, "vault-run-keys", `${name2}.json`);
80862
+ const base = turnFile ? dirname16(turnFile) : join18(tmpdir2(), "laze-vault");
80863
+ return join18(base, "vault-run-keys", `${name2}.json`);
80782
80864
  }
80783
80865
  async function runKeyAt({ path }) {
80784
- const saved3 = await readFile26(path, "utf8").then(
80866
+ const saved3 = await readFile27(path, "utf8").then(
80785
80867
  (text2) => JSON.parse(text2),
80786
80868
  () => void 0
80787
80869
  );
@@ -81463,14 +81545,14 @@ async function serveMcp({
81463
81545
  }
81464
81546
 
81465
81547
  // src/services/mount-files.service.ts
81466
- import { mkdir as mkdir18, readFile as readFile27, rm as rm12, writeFile as writeFile19 } from "node:fs/promises";
81548
+ import { mkdir as mkdir18, readFile as readFile28, rm as rm12, writeFile as writeFile19 } from "node:fs/promises";
81467
81549
  import { dirname as dirname17, relative as relative5, resolve as resolve11 } from "node:path";
81468
81550
  async function textArgument({
81469
81551
  context,
81470
81552
  value
81471
81553
  }) {
81472
81554
  if (value === "-") return context.readStdin();
81473
- if (value.startsWith("@")) return readFile27(resolve11(context.cwd, value.slice(1)), "utf8");
81555
+ if (value.startsWith("@")) return readFile28(resolve11(context.cwd, value.slice(1)), "utf8");
81474
81556
  return value;
81475
81557
  }
81476
81558
  function turnChannel({ context, args }) {
@@ -82368,8 +82450,8 @@ async function schedule({ context, args }) {
82368
82450
  }
82369
82451
 
82370
82452
  // src/services/skill-commands.service.ts
82371
- import { readdir as readdir6, readFile as readFile28 } from "node:fs/promises";
82372
- import { join as join18, relative as relative6, resolve as resolve12 } from "node:path";
82453
+ import { readdir as readdir6, readFile as readFile29 } from "node:fs/promises";
82454
+ import { join as join19, relative as relative6, resolve as resolve12 } from "node:path";
82373
82455
  var USAGE16 = `Usage:
82374
82456
  laze skill list [--agent <agentId>]
82375
82457
  laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
@@ -82390,8 +82472,8 @@ async function folderFiles({ root }) {
82390
82472
  const files2 = [];
82391
82473
  for (const entry of entries) {
82392
82474
  if (!entry.isFile()) continue;
82393
- const full = join18(entry.parentPath, entry.name);
82394
- files2.push({ path: relative6(root, full), content: await readFile28(full, "utf8") });
82475
+ const full = join19(entry.parentPath, entry.name);
82476
+ files2.push({ path: relative6(root, full), content: await readFile29(full, "utf8") });
82395
82477
  }
82396
82478
  return files2.toSorted((a, b) => a.path.localeCompare(b.path));
82397
82479
  }
@@ -82489,7 +82571,7 @@ async function skillUpdate({ context, args }) {
82489
82571
  if (!name2 || !newName && description === void 0 && !skillMdFile) {
82490
82572
  throw new CliUsageError(USAGE16);
82491
82573
  }
82492
- const skillMd = skillMdFile ? await readFile28(resolve12(context.cwd, skillMdFile), "utf8") : void 0;
82574
+ const skillMd = skillMdFile ? await readFile29(resolve12(context.cwd, skillMdFile), "utf8") : void 0;
82493
82575
  const { client } = await signedIn({ context, args });
82494
82576
  const updated = await client.post("/api/skills/update", {
82495
82577
  name: name2,
@@ -82535,7 +82617,7 @@ async function skill({ context, args }) {
82535
82617
  }
82536
82618
 
82537
82619
  // src/services/slack-commands.service.ts
82538
- import { readFile as readFile29 } from "node:fs/promises";
82620
+ import { readFile as readFile30 } from "node:fs/promises";
82539
82621
  import { resolve as resolve13 } from "node:path";
82540
82622
  var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
82541
82623
  laze slack overview connected Slack workspaces, mirrors, your link
@@ -82583,7 +82665,7 @@ async function secretLines({ context, args }) {
82583
82665
  throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
82584
82666
  }
82585
82667
  const file3 = flagText({ args, name: "from-file" });
82586
- const text2 = file3 ? await readFile29(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
82668
+ const text2 = file3 ? await readFile30(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
82587
82669
  return text2.split("\n").map((line) => line.trim()).filter(Boolean);
82588
82670
  }
82589
82671
  async function secretsOf({
@@ -82887,7 +82969,7 @@ async function slack({
82887
82969
  }
82888
82970
 
82889
82971
  // src/services/sso-commands.service.ts
82890
- import { readFile as readFile30 } from "node:fs/promises";
82972
+ import { readFile as readFile31 } from "node:fs/promises";
82891
82973
  var SSO_USAGE = `Usage:
82892
82974
  laze sso domains claimed domains and how each signs in (admins)
82893
82975
  laze sso claim <domain> the TXT record that proves the domain
@@ -82974,7 +83056,7 @@ function refuseSecretFlags({ args }) {
82974
83056
  }
82975
83057
  async function clientSecretOf({ context, args }) {
82976
83058
  const file3 = flagText({ args, name: "from-file" });
82977
- const text2 = file3 ? await readFile30(file3, "utf8") : await context.readStdin();
83059
+ const text2 = file3 ? await readFile31(file3, "utf8") : await context.readStdin();
82978
83060
  const secret = text2.trim();
82979
83061
  if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
82980
83062
  return secret;
@@ -83307,7 +83389,7 @@ async function vaultScrub({ context, args }) {
83307
83389
  }
83308
83390
 
83309
83391
  // src/services/whatsapp-business-commands.service.ts
83310
- import { readFile as readFile31 } from "node:fs/promises";
83392
+ import { readFile as readFile32 } from "node:fs/promises";
83311
83393
  import { resolve as resolve14 } from "node:path";
83312
83394
 
83313
83395
  // ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
@@ -83727,7 +83809,7 @@ async function secretsOf2({ context, args }) {
83727
83809
  const fromConnection = flagText({ args, name: "from-vault" });
83728
83810
  if (fromConnection) return { fromConnection };
83729
83811
  const file3 = flagText({ args, name: "from-file" });
83730
- const text2 = file3 ? await readFile31(resolve14(context.cwd, file3), "utf8") : await context.readStdin();
83812
+ const text2 = file3 ? await readFile32(resolve14(context.cwd, file3), "utf8") : await context.readStdin();
83731
83813
  const lines = text2.split("\n").map((line) => line.trim()).filter(Boolean);
83732
83814
  if (lines.length !== 2) {
83733
83815
  throw new CliUsageError(
@@ -84308,7 +84390,7 @@ async function flags({ context, args }) {
84308
84390
  }
84309
84391
 
84310
84392
  // src/services/workspace-commands.service.ts
84311
- import { readFile as readFile32 } from "node:fs/promises";
84393
+ import { readFile as readFile33 } from "node:fs/promises";
84312
84394
  import { resolve as resolve16 } from "node:path";
84313
84395
  var ROLE_NAMES2 = {
84314
84396
  OWNER: "Owner",
@@ -84491,7 +84573,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
84491
84573
  async function readLogo({ context, file: file3 }) {
84492
84574
  let bytes;
84493
84575
  try {
84494
- bytes = new Uint8Array(await readFile32(resolve16(context.cwd, file3)));
84576
+ bytes = new Uint8Array(await readFile33(resolve16(context.cwd, file3)));
84495
84577
  } catch {
84496
84578
  throw new CliUsageError(`No file to read at ${file3}.`);
84497
84579
  }
@@ -85152,7 +85234,7 @@ async function runCli({
85152
85234
  // src/services/processes.service.ts
85153
85235
  import { execFile as execFile2, spawn as spawn4 } from "node:child_process";
85154
85236
  import { mkdirSync, openSync } from "node:fs";
85155
- import { readFile as readFile33, readlink } from "node:fs/promises";
85237
+ import { readFile as readFile34, readlink } from "node:fs/promises";
85156
85238
  import { dirname as dirname18 } from "node:path";
85157
85239
  import { promisify as promisify2 } from "node:util";
85158
85240
  var run3 = promisify2(execFile2);
@@ -85166,14 +85248,14 @@ function alive(pid) {
85166
85248
  }
85167
85249
  }
85168
85250
  async function argsOf(pid) {
85169
- const raw = await readFile33(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
85251
+ const raw = await readFile34(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
85170
85252
  if (raw) return raw.split("\0").filter(Boolean);
85171
85253
  const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
85172
85254
  const line = listed?.stdout.trim();
85173
85255
  return line ? line.split(/\s+/) : void 0;
85174
85256
  }
85175
85257
  async function parentOf(pid) {
85176
- const stat3 = await readFile33(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
85258
+ const stat3 = await readFile34(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
85177
85259
  const fromStat = stat3 ? Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
85178
85260
  if (fromStat > 0) return fromStat;
85179
85261
  const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
@@ -85247,7 +85329,8 @@ async function runCommand({
85247
85329
  inherited,
85248
85330
  env,
85249
85331
  stdout: stdout2 = process.stdout,
85250
- stderr: stderr2 = process.stderr
85332
+ stderr: stderr2 = process.stderr,
85333
+ signal
85251
85334
  }) {
85252
85335
  const [program = "", ...rest] = command;
85253
85336
  try {
@@ -85256,7 +85339,8 @@ async function runCommand({
85256
85339
  env,
85257
85340
  baseEnv: inherited,
85258
85341
  stdout: stdout2,
85259
- stderr: stderr2
85342
+ stderr: stderr2,
85343
+ ...signal ? { signal } : {}
85260
85344
  });
85261
85345
  } catch (error62) {
85262
85346
  stderr2.write(`laze vault: ${error62 instanceof Error ? error62.message : String(error62)}