@lazehq/cli 0.1.21 → 0.1.22
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.
- package/dist/laze.mjs +286 -243
- 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:
|
|
18737
|
-
var { dirname:
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
35623
|
+
var STAMPED = "0.1.22";
|
|
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
|
|
65408
|
-
import { join as
|
|
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
|
|
67482
|
-
import { dirname as
|
|
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,50 @@ 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 readFile6(path, "utf8").then(
|
|
67524
|
+
(text2) => JSON.parse(text2),
|
|
67525
|
+
() => void 0
|
|
67526
|
+
);
|
|
67527
|
+
if (holder && context.processes.alive(holder.pid)) return;
|
|
67528
|
+
const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
|
|
67529
|
+
const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
|
|
67530
|
+
const logPath = join6(dirname5(context.environment.configPath), "rush-guards", "guard.log");
|
|
67531
|
+
const pid = context.processes.spawnDetached({ argv, logPath });
|
|
67532
|
+
await mkdir5(dirname5(path), { recursive: true, mode: 448 });
|
|
67533
|
+
await writeFile5(path, JSON.stringify({ pid, claudePid }), { mode: 384 });
|
|
67534
|
+
}
|
|
67535
|
+
|
|
67498
67536
|
// src/services/claude-wait.service.ts
|
|
67499
67537
|
var ROUND_SECONDS = 50;
|
|
67500
67538
|
var WATCH_MS = 2e3;
|
|
67501
|
-
var RUSH_RETRY_MS = 3e4;
|
|
67502
67539
|
var CHANNEL_CHECK_MS = 5e3;
|
|
67503
67540
|
async function holderOf({ path }) {
|
|
67504
|
-
return
|
|
67541
|
+
return readFile7(path, "utf8").then(
|
|
67505
67542
|
(text2) => JSON.parse(text2),
|
|
67506
67543
|
() => void 0
|
|
67507
67544
|
);
|
|
@@ -67525,8 +67562,8 @@ async function takeLock({
|
|
|
67525
67562
|
if (served && context.processes.alive(served) && !mine3) return false;
|
|
67526
67563
|
context.processes.stop(holder.pid);
|
|
67527
67564
|
}
|
|
67528
|
-
await
|
|
67529
|
-
await
|
|
67565
|
+
await mkdir6(dirname6(path), { recursive: true, mode: 448 });
|
|
67566
|
+
await writeFile6(
|
|
67530
67567
|
path,
|
|
67531
67568
|
JSON.stringify({
|
|
67532
67569
|
pid: self2,
|
|
@@ -67632,26 +67669,16 @@ async function waitForMessages({ context, args }) {
|
|
|
67632
67669
|
await rememberSession({ context, claudePid, session });
|
|
67633
67670
|
const lock = statePathOf({ context, kind: "waiters", profile: name2 });
|
|
67634
67671
|
if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
|
|
67635
|
-
const seen = () => input2.transcript_path ?
|
|
67672
|
+
const seen = () => input2.transcript_path ? readFile7(input2.transcript_path, "utf8") : Promise.resolve("");
|
|
67636
67673
|
const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
|
|
67637
67674
|
const rush = rushSessionOf({
|
|
67638
67675
|
parentArgs: await context.processes.argsOf(await context.processes.parentOf(claudePid) ?? 0)
|
|
67639
67676
|
});
|
|
67677
|
+
if (rush) await startRushGuard({ context, profile: name2, claudePid, rush });
|
|
67640
67678
|
try {
|
|
67641
67679
|
while (context.nowMs() < deadline) {
|
|
67642
67680
|
const code = await settleRound({ context, client, name: name2, lock, claudePid, session, seen });
|
|
67643
|
-
if (code
|
|
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
|
-
});
|
|
67681
|
+
if (code !== "again") return code;
|
|
67655
67682
|
}
|
|
67656
67683
|
return 0;
|
|
67657
67684
|
} finally {
|
|
@@ -67659,40 +67686,6 @@ async function waitForMessages({ context, args }) {
|
|
|
67659
67686
|
await rm2(lock, { force: true });
|
|
67660
67687
|
}
|
|
67661
67688
|
}
|
|
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
67689
|
async function waitHook({ context, args }) {
|
|
67697
67690
|
try {
|
|
67698
67691
|
return await waitForMessages({ context, args });
|
|
@@ -67715,7 +67708,7 @@ async function monitorServes({
|
|
|
67715
67708
|
// src/services/codex-link.service.ts
|
|
67716
67709
|
import { createReadStream } from "node:fs";
|
|
67717
67710
|
import { readdir as readdir4, rm as rm6, stat as stat2 } from "node:fs/promises";
|
|
67718
|
-
import { join as
|
|
67711
|
+
import { join as join12, resolve as resolve3 } from "node:path";
|
|
67719
67712
|
import { createInterface as createInterface2 } from "node:readline";
|
|
67720
67713
|
|
|
67721
67714
|
// src/rules/connect-service.rules.ts
|
|
@@ -67835,8 +67828,8 @@ function rolloutEventOf({
|
|
|
67835
67828
|
|
|
67836
67829
|
// src/services/codex-adopt.service.ts
|
|
67837
67830
|
import { spawn as spawn2 } from "node:child_process";
|
|
67838
|
-
import { mkdir as
|
|
67839
|
-
import { dirname as
|
|
67831
|
+
import { mkdir as mkdir7, readdir as readdir2, readFile as readFile8, rm as rm3, stat, writeFile as writeFile7 } from "node:fs/promises";
|
|
67832
|
+
import { dirname as dirname7, join as join7 } from "node:path";
|
|
67840
67833
|
import { createInterface } from "node:readline";
|
|
67841
67834
|
|
|
67842
67835
|
// src/rules/codex-requests.rules.ts
|
|
@@ -67956,11 +67949,11 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
67956
67949
|
}
|
|
67957
67950
|
};
|
|
67958
67951
|
async function newestThreadId({ codexHome }) {
|
|
67959
|
-
const root =
|
|
67952
|
+
const root = join7(codexHome, "sessions");
|
|
67960
67953
|
const files2 = await readdir2(root, { recursive: true }).catch(() => []);
|
|
67961
67954
|
const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
|
|
67962
67955
|
const dated = await Promise.all(
|
|
67963
|
-
rollouts.map(async (file3) => ({ file: file3, at: (await stat(
|
|
67956
|
+
rollouts.map(async (file3) => ({ file: file3, at: (await stat(join7(root, file3))).mtimeMs }))
|
|
67964
67957
|
);
|
|
67965
67958
|
const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
|
|
67966
67959
|
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 +68028,7 @@ async function answer({
|
|
|
68035
68028
|
var MAX_RESTART_WAIT_SECONDS = 60;
|
|
68036
68029
|
var HEALTHY_RUN_MS = 6e4;
|
|
68037
68030
|
async function recordOf({ path }) {
|
|
68038
|
-
return
|
|
68031
|
+
return readFile8(path, "utf8").then(
|
|
68039
68032
|
(text2) => JSON.parse(text2),
|
|
68040
68033
|
() => void 0
|
|
68041
68034
|
);
|
|
@@ -68057,8 +68050,8 @@ async function startAdoptInBackground({
|
|
|
68057
68050
|
const adopt = ["adopt", "codex", "--profile", profile, ...threadFlag({ thread: thread2 })];
|
|
68058
68051
|
const argv = [...context.program, ...adopt, "--supervise"];
|
|
68059
68052
|
const pid = context.processes.spawnDetached({ argv, logPath: log });
|
|
68060
|
-
await
|
|
68061
|
-
await
|
|
68053
|
+
await mkdir7(dirname7(path), { recursive: true, mode: 448 });
|
|
68054
|
+
await writeFile7(path, JSON.stringify({ pid, thread: thread2, log, startedAt: context.nowMs() }));
|
|
68062
68055
|
return [
|
|
68063
68056
|
`Started \`${laze} adopt codex\` in the background (pid ${pid}). It answers each Laze message`,
|
|
68064
68057
|
`as a turn in ${thread2 ? `this Codex thread (${thread2})` : "the newest Codex thread"}, and starts again if it stops.`,
|
|
@@ -68138,7 +68131,7 @@ async function adoptedThreadOf({
|
|
|
68138
68131
|
);
|
|
68139
68132
|
if (!held) return threadId;
|
|
68140
68133
|
const path = statePathOf({ context, kind: "adopt", profile, extension: "forks.json" });
|
|
68141
|
-
const forks = await
|
|
68134
|
+
const forks = await readFile8(path, "utf8").then(
|
|
68142
68135
|
(text2) => JSON.parse(text2),
|
|
68143
68136
|
() => ({})
|
|
68144
68137
|
);
|
|
@@ -68153,8 +68146,8 @@ async function adoptedThreadOf({
|
|
|
68153
68146
|
}
|
|
68154
68147
|
const forked = record3((await codex.call("thread/fork", { threadId })).thread).id;
|
|
68155
68148
|
if (typeof forked !== "string") throw new Error("thread/fork answered no thread id");
|
|
68156
|
-
await
|
|
68157
|
-
await
|
|
68149
|
+
await mkdir7(dirname7(path), { recursive: true, mode: 448 });
|
|
68150
|
+
await writeFile7(path, JSON.stringify({ ...forks, [threadId]: forked }));
|
|
68158
68151
|
context.out(
|
|
68159
68152
|
`Codex holds thread ${threadId} open elsewhere; answering in its new fork ${forked}.
|
|
68160
68153
|
`
|
|
@@ -68209,20 +68202,20 @@ async function adoptCodex({ context, args }) {
|
|
|
68209
68202
|
}
|
|
68210
68203
|
|
|
68211
68204
|
// src/services/connect-delivery.service.ts
|
|
68212
|
-
import { mkdir as
|
|
68205
|
+
import { mkdir as mkdir9, readFile as readFile10, rename as rename3, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
|
|
68213
68206
|
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
68214
|
-
import { dirname as
|
|
68207
|
+
import { dirname as dirname9, join as join10 } from "node:path";
|
|
68215
68208
|
|
|
68216
68209
|
// src/services/codex-turn-watch.service.ts
|
|
68217
68210
|
import { open as open2, readdir as readdir3 } from "node:fs/promises";
|
|
68218
|
-
import { join as
|
|
68211
|
+
import { join as join8 } from "node:path";
|
|
68219
68212
|
var READ_MS = 1500;
|
|
68220
68213
|
var KEEP_WORKING_MS = 3e4;
|
|
68221
68214
|
async function rolloutPathOf({ delivery }) {
|
|
68222
|
-
const root =
|
|
68215
|
+
const root = join8(delivery.codexHome, "sessions");
|
|
68223
68216
|
const files2 = await readdir3(root, { recursive: true }).catch(() => []);
|
|
68224
68217
|
const file3 = files2.find((name2) => name2.endsWith(`-${delivery.threadId}.jsonl`));
|
|
68225
|
-
return file3 ?
|
|
68218
|
+
return file3 ? join8(root, file3) : void 0;
|
|
68226
68219
|
}
|
|
68227
68220
|
async function readFrom({ path, offset }) {
|
|
68228
68221
|
const handle = await open2(path, "r");
|
|
@@ -68308,8 +68301,8 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
68308
68301
|
};
|
|
68309
68302
|
|
|
68310
68303
|
// src/services/openclaw-relay.service.ts
|
|
68311
|
-
import { chmod as chmod2, mkdir as
|
|
68312
|
-
import { dirname as
|
|
68304
|
+
import { chmod as chmod2, mkdir as mkdir8, readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
|
|
68305
|
+
import { dirname as dirname8, join as join9 } from "node:path";
|
|
68313
68306
|
|
|
68314
68307
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
68315
68308
|
var workspaceIdSchema14 = external_exports.string().min(1);
|
|
@@ -68537,11 +68530,11 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
68537
68530
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
68538
68531
|
]);
|
|
68539
68532
|
function relaysPathOf({ context }) {
|
|
68540
|
-
return
|
|
68533
|
+
return join9(dirname8(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
68541
68534
|
}
|
|
68542
68535
|
async function readRelays({ context }) {
|
|
68543
68536
|
try {
|
|
68544
|
-
return JSON.parse(await
|
|
68537
|
+
return JSON.parse(await readFile9(relaysPathOf({ context }), "utf8"));
|
|
68545
68538
|
} catch {
|
|
68546
68539
|
return {};
|
|
68547
68540
|
}
|
|
@@ -68551,8 +68544,8 @@ async function saveRelays({
|
|
|
68551
68544
|
relays
|
|
68552
68545
|
}) {
|
|
68553
68546
|
const path = relaysPathOf({ context });
|
|
68554
|
-
await
|
|
68555
|
-
await
|
|
68547
|
+
await mkdir8(dirname8(path), { recursive: true, mode: 448 });
|
|
68548
|
+
await writeFile8(path, `${JSON.stringify(relays, null, 2)}
|
|
68556
68549
|
`, { mode: 384 });
|
|
68557
68550
|
await chmod2(path, 384);
|
|
68558
68551
|
}
|
|
@@ -68738,14 +68731,14 @@ var RelayLoops = class _RelayLoops {
|
|
|
68738
68731
|
|
|
68739
68732
|
// src/services/connect-delivery.service.ts
|
|
68740
68733
|
function connectFolderOf({ context }) {
|
|
68741
|
-
return
|
|
68734
|
+
return join10(dirname9(context.environment.configPath), "connect");
|
|
68742
68735
|
}
|
|
68743
68736
|
function runStatePathOf({ context }) {
|
|
68744
|
-
return
|
|
68737
|
+
return join10(connectFolderOf({ context }), "run.json");
|
|
68745
68738
|
}
|
|
68746
68739
|
async function readJson({ path }) {
|
|
68747
68740
|
try {
|
|
68748
|
-
return JSON.parse(await
|
|
68741
|
+
return JSON.parse(await readFile10(path, "utf8"));
|
|
68749
68742
|
} catch {
|
|
68750
68743
|
return void 0;
|
|
68751
68744
|
}
|
|
@@ -68896,9 +68889,9 @@ async function serveRounds({
|
|
|
68896
68889
|
}
|
|
68897
68890
|
var saves = 0;
|
|
68898
68891
|
async function save(run4) {
|
|
68899
|
-
await
|
|
68892
|
+
await mkdir9(dirname9(run4.path), { recursive: true, mode: 448 });
|
|
68900
68893
|
const temporary = `${run4.path}.${run4.self}.${saves += 1}.tmp`;
|
|
68901
|
-
await
|
|
68894
|
+
await writeFile9(temporary, JSON.stringify(run4.state));
|
|
68902
68895
|
await rename3(temporary, run4.path);
|
|
68903
68896
|
}
|
|
68904
68897
|
async function holdsLock(run4) {
|
|
@@ -68979,8 +68972,8 @@ async function runConnectLoop({ context }) {
|
|
|
68979
68972
|
|
|
68980
68973
|
// src/services/connect-service.service.ts
|
|
68981
68974
|
import { createHash } from "node:crypto";
|
|
68982
|
-
import { mkdir as
|
|
68983
|
-
import { dirname as
|
|
68975
|
+
import { mkdir as mkdir10, rm as rm5, writeFile as writeFile10 } from "node:fs/promises";
|
|
68976
|
+
import { dirname as dirname10, join as join11 } from "node:path";
|
|
68984
68977
|
var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the service that delivers to linked Codex sessions.
|
|
68985
68978
|
|
|
68986
68979
|
laze connect install install and start it (systemd --user, a LaunchAgent, or detached)
|
|
@@ -68993,17 +68986,17 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
|
|
|
68993
68986
|
\`laze openclaw connect --local\`, whose OpenClaw relay it also runs.
|
|
68994
68987
|
`;
|
|
68995
68988
|
function installedPathOf({ context }) {
|
|
68996
|
-
return
|
|
68989
|
+
return join11(connectFolderOf({ context }), "service.json");
|
|
68997
68990
|
}
|
|
68998
68991
|
function logPathOf({ context }) {
|
|
68999
|
-
return
|
|
68992
|
+
return join11(connectFolderOf({ context }), "connect.log");
|
|
69000
68993
|
}
|
|
69001
68994
|
function homeOf({ context }) {
|
|
69002
|
-
return context.environment.inherited.HOME ??
|
|
68995
|
+
return context.environment.inherited.HOME ?? dirname10(dirname10(context.environment.configPath));
|
|
69003
68996
|
}
|
|
69004
68997
|
function serviceNameOf({ context }) {
|
|
69005
68998
|
const { configPath } = context.environment;
|
|
69006
|
-
if (configPath ===
|
|
68999
|
+
if (configPath === join11(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
|
|
69007
69000
|
return `laze-connect-${createHash("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
69008
69001
|
}
|
|
69009
69002
|
function serviceEnvOf({ context }) {
|
|
@@ -69026,10 +69019,10 @@ async function run({ context, command }) {
|
|
|
69026
69019
|
async function installSystemd({ context }) {
|
|
69027
69020
|
const name2 = serviceNameOf({ context });
|
|
69028
69021
|
const env = context.environment.inherited;
|
|
69029
|
-
const base = env.XDG_CONFIG_HOME ||
|
|
69030
|
-
const file3 =
|
|
69031
|
-
await
|
|
69032
|
-
await
|
|
69022
|
+
const base = env.XDG_CONFIG_HOME || join11(homeOf({ context }), ".config");
|
|
69023
|
+
const file3 = join11(base, "systemd", "user", `${name2}.service`);
|
|
69024
|
+
await mkdir10(dirname10(file3), { recursive: true });
|
|
69025
|
+
await writeFile10(
|
|
69033
69026
|
file3,
|
|
69034
69027
|
systemdUnitOf({ argv: runArgvOf({ context }), env: serviceEnvOf({ context }) })
|
|
69035
69028
|
);
|
|
@@ -69042,10 +69035,10 @@ async function installSystemd({ context }) {
|
|
|
69042
69035
|
async function installLaunchd({ context }) {
|
|
69043
69036
|
const name2 = serviceNameOf({ context });
|
|
69044
69037
|
const label2 = `ai.laze.${name2}`;
|
|
69045
|
-
const file3 =
|
|
69038
|
+
const file3 = join11(homeOf({ context }), "Library", "LaunchAgents", `${label2}.plist`);
|
|
69046
69039
|
const log = logPathOf({ context });
|
|
69047
|
-
await
|
|
69048
|
-
await
|
|
69040
|
+
await mkdir10(dirname10(file3), { recursive: true });
|
|
69041
|
+
await writeFile10(
|
|
69049
69042
|
file3,
|
|
69050
69043
|
launchAgentOf({
|
|
69051
69044
|
label: label2,
|
|
@@ -69097,8 +69090,8 @@ async function installConnectService({ context }) {
|
|
|
69097
69090
|
const manager = await managerOf({ context });
|
|
69098
69091
|
const install = { systemd: installSystemd, launchd: installLaunchd, detached: installDetached };
|
|
69099
69092
|
const installed = await install[manager]({ context });
|
|
69100
|
-
await
|
|
69101
|
-
await
|
|
69093
|
+
await mkdir10(dirname10(path), { recursive: true, mode: 448 });
|
|
69094
|
+
await writeFile10(path, JSON.stringify(installed));
|
|
69102
69095
|
return describeInstalled({ installed });
|
|
69103
69096
|
}
|
|
69104
69097
|
function describeInstalled({ installed }) {
|
|
@@ -69193,20 +69186,6 @@ async function connectService({ context, args }) {
|
|
|
69193
69186
|
}
|
|
69194
69187
|
}
|
|
69195
69188
|
|
|
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
69189
|
// src/services/codex-link.service.ts
|
|
69211
69190
|
var ROLLOUTS_READ = 200;
|
|
69212
69191
|
async function firstLineOf({ path }) {
|
|
@@ -69224,13 +69203,13 @@ async function newestThreadIn({
|
|
|
69224
69203
|
codexHome,
|
|
69225
69204
|
directory
|
|
69226
69205
|
}) {
|
|
69227
|
-
const root =
|
|
69206
|
+
const root = join12(codexHome, "sessions");
|
|
69228
69207
|
const files2 = await readdir4(root, { recursive: true }).catch(() => []);
|
|
69229
69208
|
const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
|
|
69230
69209
|
const dated = await Promise.all(
|
|
69231
69210
|
rollouts.map(async (file3) => ({
|
|
69232
|
-
path:
|
|
69233
|
-
at: await stat2(
|
|
69211
|
+
path: join12(root, file3),
|
|
69212
|
+
at: await stat2(join12(root, file3)).then(
|
|
69234
69213
|
(info) => info.mtimeMs,
|
|
69235
69214
|
() => 0
|
|
69236
69215
|
)
|
|
@@ -69300,8 +69279,8 @@ async function linkCodexSession({
|
|
|
69300
69279
|
}
|
|
69301
69280
|
|
|
69302
69281
|
// src/services/laze-plugin.service.ts
|
|
69303
|
-
import { mkdir as
|
|
69304
|
-
import { dirname as
|
|
69282
|
+
import { mkdir as mkdir11, readFile as readFile11, writeFile as writeFile11 } from "node:fs/promises";
|
|
69283
|
+
import { dirname as dirname11, join as join13 } from "node:path";
|
|
69305
69284
|
|
|
69306
69285
|
// src/rules/laze-plugin.rules.ts
|
|
69307
69286
|
var LAZE_PLUGIN = "laze";
|
|
@@ -69417,11 +69396,11 @@ function lazePluginFiles({
|
|
|
69417
69396
|
var REGISTER_LIMIT_MS = 6e4;
|
|
69418
69397
|
var quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
69419
69398
|
function pluginFolderOf({ context }) {
|
|
69420
|
-
return
|
|
69399
|
+
return join13(dirname11(context.environment.configPath), "plugins");
|
|
69421
69400
|
}
|
|
69422
69401
|
async function pluginIsCurrent({ context }) {
|
|
69423
|
-
const manifest =
|
|
69424
|
-
const written = await
|
|
69402
|
+
const manifest = join13(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
|
|
69403
|
+
const written = await readFile11(manifest, "utf8").then(
|
|
69425
69404
|
(text2) => JSON.parse(text2).version,
|
|
69426
69405
|
() => void 0
|
|
69427
69406
|
);
|
|
@@ -69435,9 +69414,9 @@ async function writeLazePlugin({ context }) {
|
|
|
69435
69414
|
configPath: context.environment.configPath
|
|
69436
69415
|
});
|
|
69437
69416
|
for (const [path, text2] of Object.entries(files2)) {
|
|
69438
|
-
const target =
|
|
69439
|
-
await
|
|
69440
|
-
await
|
|
69417
|
+
const target = join13(folder, path);
|
|
69418
|
+
await mkdir11(dirname11(target), { recursive: true });
|
|
69419
|
+
await writeFile11(target, text2);
|
|
69441
69420
|
}
|
|
69442
69421
|
return folder;
|
|
69443
69422
|
}
|
|
@@ -69459,10 +69438,10 @@ async function registerWithClaude({ context, folder }) {
|
|
|
69459
69438
|
return code === 0;
|
|
69460
69439
|
}
|
|
69461
69440
|
function registeredMarkOf({ context }) {
|
|
69462
|
-
return
|
|
69441
|
+
return join13(pluginFolderOf({ context }), "registered");
|
|
69463
69442
|
}
|
|
69464
69443
|
async function pluginRegistered({ context }) {
|
|
69465
|
-
return
|
|
69444
|
+
return readFile11(registeredMarkOf({ context }), "utf8").then(
|
|
69466
69445
|
() => true,
|
|
69467
69446
|
() => false
|
|
69468
69447
|
);
|
|
@@ -69470,13 +69449,13 @@ async function pluginRegistered({ context }) {
|
|
|
69470
69449
|
async function installLazePlugin({ context }) {
|
|
69471
69450
|
const folder = await writeLazePlugin({ context });
|
|
69472
69451
|
const registered = await registerWithClaude({ context, folder });
|
|
69473
|
-
if (registered) await
|
|
69452
|
+
if (registered) await writeFile11(registeredMarkOf({ context }), cliVersionOf());
|
|
69474
69453
|
return { folder, registered };
|
|
69475
69454
|
}
|
|
69476
69455
|
async function plugin({ context, args }) {
|
|
69477
69456
|
const action = args.words[1] ?? "install";
|
|
69478
69457
|
if (action === "path") {
|
|
69479
|
-
context.out(`${
|
|
69458
|
+
context.out(`${join13(pluginFolderOf({ context }), LAZE_PLUGIN)}
|
|
69480
69459
|
`);
|
|
69481
69460
|
return 0;
|
|
69482
69461
|
}
|
|
@@ -69494,8 +69473,8 @@ async function plugin({ context, args }) {
|
|
|
69494
69473
|
}
|
|
69495
69474
|
|
|
69496
69475
|
// src/services/mcp-channel.service.ts
|
|
69497
|
-
import { mkdir as
|
|
69498
|
-
import { dirname as
|
|
69476
|
+
import { mkdir as mkdir12, rm as rm7, writeFile as writeFile12 } from "node:fs/promises";
|
|
69477
|
+
import { dirname as dirname12 } from "node:path";
|
|
69499
69478
|
var LAZE_MCP_SERVER = "laze";
|
|
69500
69479
|
var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
|
|
69501
69480
|
var ROUND_SECONDS3 = 50;
|
|
@@ -69585,8 +69564,8 @@ async function pushInbox({
|
|
|
69585
69564
|
signal
|
|
69586
69565
|
}) {
|
|
69587
69566
|
const marker = statePathOf({ context, kind: "channels", profile });
|
|
69588
|
-
await
|
|
69589
|
-
await
|
|
69567
|
+
await mkdir12(dirname12(marker), { recursive: true, mode: 448 });
|
|
69568
|
+
await writeFile12(marker, JSON.stringify({ pid: context.processes.pid }));
|
|
69590
69569
|
try {
|
|
69591
69570
|
while (!signal.aborted) {
|
|
69592
69571
|
const messages = await client.post("/api/agents/me/inbox", { waitSeconds: ROUND_SECONDS3 }, { signal }).catch(async (error62) => {
|
|
@@ -69613,8 +69592,8 @@ async function pushInbox({
|
|
|
69613
69592
|
}
|
|
69614
69593
|
|
|
69615
69594
|
// src/services/plugin-tip.service.ts
|
|
69616
|
-
import { mkdir as
|
|
69617
|
-
import { dirname as
|
|
69595
|
+
import { mkdir as mkdir13, readFile as readFile12, writeFile as writeFile13 } from "node:fs/promises";
|
|
69596
|
+
import { dirname as dirname13 } from "node:path";
|
|
69618
69597
|
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
69598
|
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
69599
|
function monitorsRunHere({ context }) {
|
|
@@ -69648,8 +69627,8 @@ async function markReloadTipTold({
|
|
|
69648
69627
|
}) {
|
|
69649
69628
|
if (!session) return;
|
|
69650
69629
|
const path = toldPathOf({ context, session });
|
|
69651
|
-
await
|
|
69652
|
-
await
|
|
69630
|
+
await mkdir13(dirname13(path), { recursive: true, mode: 448 });
|
|
69631
|
+
await writeFile13(path, String(context.nowMs()), { mode: 384 });
|
|
69653
69632
|
}
|
|
69654
69633
|
async function reloadTipOnce({
|
|
69655
69634
|
context,
|
|
@@ -69657,7 +69636,7 @@ async function reloadTipOnce({
|
|
|
69657
69636
|
}) {
|
|
69658
69637
|
if (!session || !monitorsRunHere({ context })) return void 0;
|
|
69659
69638
|
if (!await pluginRegistered({ context })) return void 0;
|
|
69660
|
-
const told = await
|
|
69639
|
+
const told = await readFile12(toldPathOf({ context, session }), "utf8").then(
|
|
69661
69640
|
() => true,
|
|
69662
69641
|
() => false
|
|
69663
69642
|
);
|
|
@@ -69723,9 +69702,9 @@ async function installHooks({
|
|
|
69723
69702
|
directory,
|
|
69724
69703
|
profile
|
|
69725
69704
|
}) {
|
|
69726
|
-
const folder =
|
|
69727
|
-
const path =
|
|
69728
|
-
const current2 = await
|
|
69705
|
+
const folder = join14(directory, ".claude");
|
|
69706
|
+
const path = join14(folder, "settings.local.json");
|
|
69707
|
+
const current2 = await readFile13(path, "utf8").then(
|
|
69729
69708
|
(text2) => JSON.parse(text2),
|
|
69730
69709
|
() => ({})
|
|
69731
69710
|
);
|
|
@@ -69736,8 +69715,8 @@ async function installHooks({
|
|
|
69736
69715
|
waitCommand: command("wait"),
|
|
69737
69716
|
preToolCommand: command("pre-tool")
|
|
69738
69717
|
});
|
|
69739
|
-
await
|
|
69740
|
-
await
|
|
69718
|
+
await mkdir14(folder, { recursive: true });
|
|
69719
|
+
await writeFile14(path, `${JSON.stringify(settings2, null, 2)}
|
|
69741
69720
|
`);
|
|
69742
69721
|
return path;
|
|
69743
69722
|
}
|
|
@@ -69926,7 +69905,7 @@ async function reportTranscript({
|
|
|
69926
69905
|
input: input2
|
|
69927
69906
|
}) {
|
|
69928
69907
|
if (!input2.transcript_path || !input2.session_id) return;
|
|
69929
|
-
const lines = (await
|
|
69908
|
+
const lines = (await readFile13(input2.transcript_path, "utf8")).split("\n");
|
|
69930
69909
|
const context = readTranscript({ lines });
|
|
69931
69910
|
await client.post("/api/agents/me/activity", {
|
|
69932
69911
|
sessionId: input2.session_id,
|
|
@@ -69959,7 +69938,7 @@ async function handOver({ context, args }) {
|
|
|
69959
69938
|
const kept = await dueFromSpool({
|
|
69960
69939
|
context,
|
|
69961
69940
|
profile: agent2,
|
|
69962
|
-
seen: () => input2.transcript_path ?
|
|
69941
|
+
seen: () => input2.transcript_path ? readFile13(input2.transcript_path, "utf8") : Promise.resolve(""),
|
|
69963
69942
|
pushedToo: false
|
|
69964
69943
|
});
|
|
69965
69944
|
const claim3 = forSession({ client, session });
|
|
@@ -69993,8 +69972,8 @@ async function addSessionStartWaiter({ context, args }) {
|
|
|
69993
69972
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
|
|
69994
69973
|
const profile = flagText({ args, name: "profile" });
|
|
69995
69974
|
if (!directory || !profile) return;
|
|
69996
|
-
const path =
|
|
69997
|
-
const settings2 = await
|
|
69975
|
+
const path = join14(directory, ".claude", "settings.local.json");
|
|
69976
|
+
const settings2 = await readFile13(path, "utf8").then(
|
|
69998
69977
|
(text2) => JSON.parse(text2),
|
|
69999
69978
|
() => void 0
|
|
70000
69979
|
);
|
|
@@ -70003,7 +69982,7 @@ async function addSessionStartWaiter({ context, args }) {
|
|
|
70003
69982
|
}
|
|
70004
69983
|
async function refreshPlugin({ context }) {
|
|
70005
69984
|
if (await pluginIsCurrent({ context })) return;
|
|
70006
|
-
const logPath =
|
|
69985
|
+
const logPath = join14(pluginFolderOf({ context }), "install.log");
|
|
70007
69986
|
context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
|
|
70008
69987
|
}
|
|
70009
69988
|
async function stopHook({ context, args }) {
|
|
@@ -70021,7 +70000,7 @@ async function stopHook({ context, args }) {
|
|
|
70021
70000
|
}
|
|
70022
70001
|
|
|
70023
70002
|
// src/services/agent-manage-commands.service.ts
|
|
70024
|
-
import { readFile as
|
|
70003
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
70025
70004
|
import { extname, resolve as resolve5 } from "node:path";
|
|
70026
70005
|
|
|
70027
70006
|
// src/rules/login-format.rules.ts
|
|
@@ -70150,7 +70129,7 @@ async function avatarOf({
|
|
|
70150
70129
|
}) {
|
|
70151
70130
|
const path = flagText({ args, name: "avatar" });
|
|
70152
70131
|
if (!path) return void 0;
|
|
70153
|
-
const bytes = await
|
|
70132
|
+
const bytes = await readFile14(resolve5(context.cwd, path)).catch(() => {
|
|
70154
70133
|
throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
|
|
70155
70134
|
});
|
|
70156
70135
|
const uploaded = await client.post("/api/agents/avatars", {
|
|
@@ -70840,8 +70819,8 @@ async function requestAgent({ context, args }) {
|
|
|
70840
70819
|
}
|
|
70841
70820
|
|
|
70842
70821
|
// src/services/app-commands.service.ts
|
|
70843
|
-
import { mkdir as
|
|
70844
|
-
import { dirname as
|
|
70822
|
+
import { mkdir as mkdir15, readdir as readdir5, readFile as readFile15, writeFile as writeFile16 } from "node:fs/promises";
|
|
70823
|
+
import { dirname as dirname14, join as join16, relative as relative3, resolve as resolve6, sep as sep2 } from "node:path";
|
|
70845
70824
|
|
|
70846
70825
|
// ../../modules/app/contract/src/app.connections.ts
|
|
70847
70826
|
var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
@@ -73232,9 +73211,9 @@ async function appPinsCommand({
|
|
|
73232
73211
|
|
|
73233
73212
|
// src/services/app-script-check.service.ts
|
|
73234
73213
|
import { execFile } from "node:child_process";
|
|
73235
|
-
import { mkdtemp, rm as rm8, writeFile as
|
|
73214
|
+
import { mkdtemp, rm as rm8, writeFile as writeFile15 } from "node:fs/promises";
|
|
73236
73215
|
import { tmpdir } from "node:os";
|
|
73237
|
-
import { join as
|
|
73216
|
+
import { join as join15 } from "node:path";
|
|
73238
73217
|
import { promisify } from "node:util";
|
|
73239
73218
|
var run2 = promisify(execFile);
|
|
73240
73219
|
var MODULE_SYNTAX = /^\s*(import|export)\s/m;
|
|
@@ -73263,12 +73242,12 @@ async function scriptErrorsOf({
|
|
|
73263
73242
|
const unknown2 = unknownCollectionsOf({ files: files2, collections });
|
|
73264
73243
|
const scripts = files2.flatMap(scriptsOf);
|
|
73265
73244
|
if (scripts.length === 0) return unknown2;
|
|
73266
|
-
const dir = await mkdtemp(
|
|
73245
|
+
const dir = await mkdtemp(join15(tmpdir(), "laze-app-check-"));
|
|
73267
73246
|
try {
|
|
73268
73247
|
const errors = await Promise.all(
|
|
73269
73248
|
scripts.map(async (script, index) => {
|
|
73270
|
-
const file3 =
|
|
73271
|
-
await
|
|
73249
|
+
const file3 = join15(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
|
|
73250
|
+
await writeFile15(file3, script.code);
|
|
73272
73251
|
try {
|
|
73273
73252
|
await run2(process.execPath, ["--check", file3]);
|
|
73274
73253
|
return null;
|
|
@@ -73417,7 +73396,7 @@ async function turnTokenOf({
|
|
|
73417
73396
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
73418
73397
|
if (pinned) return pinned;
|
|
73419
73398
|
if (env.LAZE_TURN_FILE) {
|
|
73420
|
-
return
|
|
73399
|
+
return readFile15(env.LAZE_TURN_FILE, "utf8").then(
|
|
73421
73400
|
(text2) => text2.trim(),
|
|
73422
73401
|
() => ""
|
|
73423
73402
|
);
|
|
@@ -73443,7 +73422,7 @@ function folderOf({ context, word: word3 }) {
|
|
|
73443
73422
|
return resolve6(context.cwd, word3 ?? ".");
|
|
73444
73423
|
}
|
|
73445
73424
|
async function readManifest(folder) {
|
|
73446
|
-
const text2 = await
|
|
73425
|
+
const text2 = await readFile15(join16(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
73447
73426
|
if (text2 === void 0) return void 0;
|
|
73448
73427
|
const parsed = appManifestSchema.safeParse(JSON.parse(text2));
|
|
73449
73428
|
if (!parsed.success) {
|
|
@@ -73478,7 +73457,7 @@ async function jsonFlag({
|
|
|
73478
73457
|
}) {
|
|
73479
73458
|
const raw = flagText({ args, name: name2 });
|
|
73480
73459
|
if (!raw) return void 0;
|
|
73481
|
-
const text2 = raw.startsWith("@") ? await
|
|
73460
|
+
const text2 = raw.startsWith("@") ? await readFile15(resolve6(context.cwd, raw.slice(1)), "utf8") : raw;
|
|
73482
73461
|
try {
|
|
73483
73462
|
return JSON.parse(text2);
|
|
73484
73463
|
} catch {
|
|
@@ -73491,7 +73470,7 @@ async function listFiles(folder) {
|
|
|
73491
73470
|
while (pending.length > 0 && found.length <= MAX_FILES) {
|
|
73492
73471
|
const current2 = pending.pop() ?? folder;
|
|
73493
73472
|
for (const entry of await readdir5(current2, { withFileTypes: true })) {
|
|
73494
|
-
const path =
|
|
73473
|
+
const path = join16(current2, entry.name);
|
|
73495
73474
|
const rel = relative3(folder, path).split(sep2).join("/");
|
|
73496
73475
|
if (isSkippedPath({ path: rel })) continue;
|
|
73497
73476
|
if (entry.isDirectory()) pending.push(path);
|
|
@@ -73532,11 +73511,11 @@ var appCreate = async ({ context, args }) => {
|
|
|
73532
73511
|
...visibility ? { visibility } : {}
|
|
73533
73512
|
});
|
|
73534
73513
|
const folder = resolve6(context.cwd, flagText({ args, name: "dir", fallback: app2.slug }));
|
|
73535
|
-
await
|
|
73514
|
+
await mkdir15(folder, { recursive: true });
|
|
73536
73515
|
const files2 = template ? templateFiles({ template, name: name2 }) : {};
|
|
73537
73516
|
for (const [path, content] of Object.entries(files2)) {
|
|
73538
|
-
await
|
|
73539
|
-
await
|
|
73517
|
+
await mkdir15(dirname14(join16(folder, path)), { recursive: true });
|
|
73518
|
+
await writeFile16(join16(folder, path), content);
|
|
73540
73519
|
}
|
|
73541
73520
|
const manifest = {
|
|
73542
73521
|
app: { id: app2.id, name: app2.name, slug: app2.slug },
|
|
@@ -73544,7 +73523,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
73544
73523
|
views: template?.views ? [...template.views] : [],
|
|
73545
73524
|
seed: template ? { ...template.seed } : {}
|
|
73546
73525
|
};
|
|
73547
|
-
await
|
|
73526
|
+
await writeFile16(join16(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
73548
73527
|
`);
|
|
73549
73528
|
print5({
|
|
73550
73529
|
context,
|
|
@@ -73581,7 +73560,7 @@ var appPush = async ({ context, args }) => {
|
|
|
73581
73560
|
paths.map(
|
|
73582
73561
|
async (path) => buildFileOf({
|
|
73583
73562
|
path: relative3(folder, path).split(sep2).join("/"),
|
|
73584
|
-
bytes: await
|
|
73563
|
+
bytes: await readFile15(path)
|
|
73585
73564
|
})
|
|
73586
73565
|
)
|
|
73587
73566
|
);
|
|
@@ -73956,7 +73935,7 @@ var appExport = async ({ context, args }) => {
|
|
|
73956
73935
|
const out = flagText({ args, name: "out" });
|
|
73957
73936
|
if (!out) return context.out(exported.body);
|
|
73958
73937
|
const target = resolve6(context.cwd, out);
|
|
73959
|
-
await
|
|
73938
|
+
await writeFile16(target, exported.body);
|
|
73960
73939
|
context.out(`Wrote ${exported.rows} records to ${relative3(context.cwd, target)}
|
|
73961
73940
|
`);
|
|
73962
73941
|
};
|
|
@@ -73964,7 +73943,7 @@ var appImport = async ({ context, args }) => {
|
|
|
73964
73943
|
const words = args.words.slice(2);
|
|
73965
73944
|
const [named, collection, file3] = words.length >= 3 ? words : [void 0, ...words];
|
|
73966
73945
|
if (!collection || !file3) throw new CliUsageError(USAGE5);
|
|
73967
|
-
const csv = await
|
|
73946
|
+
const csv = await readFile15(resolve6(context.cwd, file3), "utf8").catch(() => {
|
|
73968
73947
|
throw new CliUsageError(`Cannot read ${file3}`);
|
|
73969
73948
|
});
|
|
73970
73949
|
const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
|
|
@@ -73983,7 +73962,7 @@ var appImport = async ({ context, args }) => {
|
|
|
73983
73962
|
});
|
|
73984
73963
|
const refusedOut = flagText({ args, name: "refused" });
|
|
73985
73964
|
if (refusedOut && result.refusedCsv) {
|
|
73986
|
-
await
|
|
73965
|
+
await writeFile16(resolve6(context.cwd, refusedOut), result.refusedCsv);
|
|
73987
73966
|
}
|
|
73988
73967
|
const fitting = result.rows - result.refused.length;
|
|
73989
73968
|
const skipped = result.refused.slice(0, 20).map((row) => ` line ${row.line}: ${row.reason}
|
|
@@ -74530,8 +74509,8 @@ async function billing({ context, args }) {
|
|
|
74530
74509
|
|
|
74531
74510
|
// src/services/browser-commands.service.ts
|
|
74532
74511
|
import { randomBytes } from "node:crypto";
|
|
74533
|
-
import { mkdir as
|
|
74534
|
-
import { dirname as
|
|
74512
|
+
import { mkdir as mkdir16, readFile as readFile16, writeFile as writeFile17 } from "node:fs/promises";
|
|
74513
|
+
import { dirname as dirname15, join as join17 } from "node:path";
|
|
74535
74514
|
|
|
74536
74515
|
// src/services/browser-tab-commands.service.ts
|
|
74537
74516
|
var BROWSER_TAB_PATHS = {
|
|
@@ -75077,7 +75056,7 @@ async function turnTokenOf2({ context }) {
|
|
|
75077
75056
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
75078
75057
|
if (pinned) return pinned;
|
|
75079
75058
|
if (!env.LAZE_TURN_FILE) return "";
|
|
75080
|
-
return
|
|
75059
|
+
return readFile16(env.LAZE_TURN_FILE, "utf8").then(
|
|
75081
75060
|
(text2) => text2.trim(),
|
|
75082
75061
|
() => ""
|
|
75083
75062
|
);
|
|
@@ -75151,7 +75130,7 @@ async function cdp({ context, args }) {
|
|
|
75151
75130
|
}
|
|
75152
75131
|
function bridgeStatePath({ context, machine: machine2 }) {
|
|
75153
75132
|
const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
75154
|
-
return
|
|
75133
|
+
return join17(dirname15(context.environment.configPath), "bridges", `${safe}.json`);
|
|
75155
75134
|
}
|
|
75156
75135
|
async function bridgePort({
|
|
75157
75136
|
context,
|
|
@@ -75159,7 +75138,7 @@ async function bridgePort({
|
|
|
75159
75138
|
access
|
|
75160
75139
|
}) {
|
|
75161
75140
|
const path = bridgeStatePath({ context, machine: machine2 });
|
|
75162
|
-
const live = await
|
|
75141
|
+
const live = await readFile16(path, "utf8").then(
|
|
75163
75142
|
(text2) => JSON.parse(text2),
|
|
75164
75143
|
() => void 0
|
|
75165
75144
|
);
|
|
@@ -75172,8 +75151,8 @@ async function bridgePort({
|
|
|
75172
75151
|
key,
|
|
75173
75152
|
...target
|
|
75174
75153
|
});
|
|
75175
|
-
await
|
|
75176
|
-
await
|
|
75154
|
+
await mkdir16(dirname15(path), { recursive: true, mode: 448 });
|
|
75155
|
+
await writeFile17(path, JSON.stringify({ port, key }), { mode: 384 });
|
|
75177
75156
|
return port;
|
|
75178
75157
|
}
|
|
75179
75158
|
async function bridge({ context }) {
|
|
@@ -75817,7 +75796,7 @@ async function channelSettings({ context, args }) {
|
|
|
75817
75796
|
}
|
|
75818
75797
|
|
|
75819
75798
|
// src/services/chat-actions-commands.service.ts
|
|
75820
|
-
import { readFile as
|
|
75799
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
75821
75800
|
import { basename as basename2, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve7 } from "node:path";
|
|
75822
75801
|
|
|
75823
75802
|
// src/services/file-upload.service.ts
|
|
@@ -76122,7 +76101,7 @@ function uploadNameOf({ cwd, path }) {
|
|
|
76122
76101
|
}
|
|
76123
76102
|
var fileUpload = async ({ context, args, client }) => {
|
|
76124
76103
|
const path = resolve7(context.cwd, wordAt(args, 3));
|
|
76125
|
-
const bytes = new Uint8Array(await
|
|
76104
|
+
const bytes = new Uint8Array(await readFile17(path));
|
|
76126
76105
|
const answer4 = await uploadFile({
|
|
76127
76106
|
context,
|
|
76128
76107
|
client,
|
|
@@ -76287,7 +76266,7 @@ async function chatActions({
|
|
|
76287
76266
|
}
|
|
76288
76267
|
|
|
76289
76268
|
// src/services/claude-monitor.service.ts
|
|
76290
|
-
import { readFile as
|
|
76269
|
+
import { readFile as readFile18, rm as rm9 } from "node:fs/promises";
|
|
76291
76270
|
var MONITOR_IDLE_MS = 3e4;
|
|
76292
76271
|
var MONITOR_OUTRANKED_MS = 3e3;
|
|
76293
76272
|
async function deliverOnce({
|
|
@@ -76376,7 +76355,7 @@ async function monitorSessionOf({
|
|
|
76376
76355
|
const fromEnv = sessionOf({ context, harness: "claude-code", sessionId });
|
|
76377
76356
|
if (fromEnv || !claudePid) return fromEnv;
|
|
76378
76357
|
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
76379
|
-
return
|
|
76358
|
+
return readFile18(path, "utf8").then(
|
|
76380
76359
|
(text2) => JSON.parse(text2),
|
|
76381
76360
|
() => void 0
|
|
76382
76361
|
);
|
|
@@ -77863,10 +77842,10 @@ async function computer({ context, args }) {
|
|
|
77863
77842
|
}
|
|
77864
77843
|
|
|
77865
77844
|
// src/services/connect-commands.service.ts
|
|
77866
|
-
import { readFile as
|
|
77845
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
77867
77846
|
|
|
77868
77847
|
// src/services/mcp-gateway.service.ts
|
|
77869
|
-
import { readFile as
|
|
77848
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
77870
77849
|
import { createInterface as createInterface3 } from "node:readline";
|
|
77871
77850
|
var TURN_HEADER = "x-laze-turn";
|
|
77872
77851
|
function serveMcpGateway({
|
|
@@ -77909,7 +77888,7 @@ async function relayMcpLines({
|
|
|
77909
77888
|
const github3 = env.LAZE_GITHUB_CONNECTION;
|
|
77910
77889
|
const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
|
|
77911
77890
|
const turnFile = env.LAZE_TURN_FILE;
|
|
77912
|
-
const readTurn = () =>
|
|
77891
|
+
const readTurn = () => readFile19(turnFile, "utf8").then(
|
|
77913
77892
|
(text2) => text2.trim(),
|
|
77914
77893
|
() => ""
|
|
77915
77894
|
);
|
|
@@ -77999,7 +77978,7 @@ async function turnOf({ context }) {
|
|
|
77999
77978
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
78000
77979
|
if (pinned) return pinned;
|
|
78001
77980
|
const file3 = env.LAZE_TURN_FILE;
|
|
78002
|
-
const turn = file3 ? await
|
|
77981
|
+
const turn = file3 ? await readFile20(file3, "utf8").then(
|
|
78003
77982
|
(text2) => text2.trim(),
|
|
78004
77983
|
() => ""
|
|
78005
77984
|
) : "";
|
|
@@ -78057,11 +78036,11 @@ async function connect({
|
|
|
78057
78036
|
}
|
|
78058
78037
|
|
|
78059
78038
|
// src/services/connector-commands.service.ts
|
|
78060
|
-
import { readFile as
|
|
78039
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
78061
78040
|
import { resolve as resolve8 } from "node:path";
|
|
78062
78041
|
|
|
78063
78042
|
// src/services/vault-keychain-commands.service.ts
|
|
78064
|
-
import { readFile as
|
|
78043
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
78065
78044
|
|
|
78066
78045
|
// src/rules/vault-input.rules.ts
|
|
78067
78046
|
function secondsOf(text2) {
|
|
@@ -78372,7 +78351,7 @@ async function secretText({ context, args }) {
|
|
|
78372
78351
|
);
|
|
78373
78352
|
}
|
|
78374
78353
|
const file3 = flagText({ args, name: "from-file" });
|
|
78375
|
-
const text2 = file3 ? await
|
|
78354
|
+
const text2 = file3 ? await readFile21(file3, "utf8") : await context.readStdin();
|
|
78376
78355
|
const trimmed = text2.replace(/\r?\n$/, "");
|
|
78377
78356
|
if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
|
|
78378
78357
|
return trimmed;
|
|
@@ -78570,7 +78549,7 @@ async function keyText({ context, args }) {
|
|
|
78570
78549
|
throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
|
|
78571
78550
|
}
|
|
78572
78551
|
const file3 = flagText({ args, name: "from-file" });
|
|
78573
|
-
const text2 = file3 ? await
|
|
78552
|
+
const text2 = file3 ? await readFile22(resolve8(context.cwd, file3), "utf8") : await context.readStdin();
|
|
78574
78553
|
const trimmed = text2.trim();
|
|
78575
78554
|
if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
|
|
78576
78555
|
return trimmed;
|
|
@@ -78956,8 +78935,8 @@ var DOMAINS_USAGE = `Usage:
|
|
|
78956
78935
|
var printJson4 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
|
|
78957
78936
|
`);
|
|
78958
78937
|
function printDomain(context, row) {
|
|
78959
|
-
const
|
|
78960
|
-
context.out(`${row.domain} ${
|
|
78938
|
+
const join21 = row.autoJoin ? "auto-join on" : "auto-join off";
|
|
78939
|
+
context.out(`${row.domain} ${join21}${row.enforced ? " single sign-on enforced" : ""}
|
|
78961
78940
|
`);
|
|
78962
78941
|
}
|
|
78963
78942
|
async function list4({ context, args }) {
|
|
@@ -78989,7 +78968,7 @@ async function domains({ context, args }) {
|
|
|
78989
78968
|
}
|
|
78990
78969
|
|
|
78991
78970
|
// src/services/feed-commands.service.ts
|
|
78992
|
-
import { readFile as
|
|
78971
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
78993
78972
|
import { resolve as resolve10 } from "node:path";
|
|
78994
78973
|
|
|
78995
78974
|
// src/rules/feed-input.rules.ts
|
|
@@ -79114,7 +79093,7 @@ function feedFlagsOf({ args }) {
|
|
|
79114
79093
|
}
|
|
79115
79094
|
|
|
79116
79095
|
// src/services/feed-files.service.ts
|
|
79117
|
-
import { readFile as
|
|
79096
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
79118
79097
|
import { basename as basename3, resolve as resolve9 } from "node:path";
|
|
79119
79098
|
|
|
79120
79099
|
// ../../modules/feed/contract/src/feed.ts
|
|
@@ -79708,7 +79687,7 @@ async function local({ context, path }) {
|
|
|
79708
79687
|
return {
|
|
79709
79688
|
fileName,
|
|
79710
79689
|
contentType: contentTypeOf(fileName),
|
|
79711
|
-
bytes: new Uint8Array(await
|
|
79690
|
+
bytes: new Uint8Array(await readFile23(full))
|
|
79712
79691
|
};
|
|
79713
79692
|
}
|
|
79714
79693
|
async function directWith({ client, to }) {
|
|
@@ -79786,7 +79765,7 @@ async function bodyOf2({
|
|
|
79786
79765
|
flags: flags2
|
|
79787
79766
|
}) {
|
|
79788
79767
|
const body = { ...flags2.fields };
|
|
79789
|
-
const read3 = (source) => "file" in source ?
|
|
79768
|
+
const read3 = (source) => "file" in source ? readFile24(resolve10(context.cwd, source.file), "utf8") : source.text;
|
|
79790
79769
|
for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read3(source);
|
|
79791
79770
|
if (flags2.rich) {
|
|
79792
79771
|
const text2 = await read3(flags2.rich.source);
|
|
@@ -79948,7 +79927,7 @@ async function textFlag({
|
|
|
79948
79927
|
}) {
|
|
79949
79928
|
const value = flagText({ args, name: name2 });
|
|
79950
79929
|
if (!value.startsWith("@")) return value;
|
|
79951
|
-
return
|
|
79930
|
+
return readFile24(resolve10(context.cwd, value.slice(1)), "utf8");
|
|
79952
79931
|
}
|
|
79953
79932
|
async function feedList({ context, args }) {
|
|
79954
79933
|
const { client } = await signedIn({ context, args });
|
|
@@ -80058,7 +80037,7 @@ async function feed({ context, args }) {
|
|
|
80058
80037
|
}
|
|
80059
80038
|
|
|
80060
80039
|
// src/services/github-commands.service.ts
|
|
80061
|
-
import { readFile as
|
|
80040
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
80062
80041
|
|
|
80063
80042
|
// src/rules/github-signature.rules.ts
|
|
80064
80043
|
var TURN_SEPARATOR = "~";
|
|
@@ -80128,7 +80107,7 @@ var REAL_GH = "/usr/bin/gh";
|
|
|
80128
80107
|
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
80108
|
async function turnFileToken({ env }) {
|
|
80130
80109
|
if (!env.LAZE_TURN_FILE) return "";
|
|
80131
|
-
return
|
|
80110
|
+
return readFile25(env.LAZE_TURN_FILE, "utf8").then(
|
|
80132
80111
|
(text2) => text2.trim(),
|
|
80133
80112
|
() => ""
|
|
80134
80113
|
);
|
|
@@ -80162,7 +80141,7 @@ async function githubGh({
|
|
|
80162
80141
|
args: args.rest,
|
|
80163
80142
|
agentName: profile.name ?? "An agent",
|
|
80164
80143
|
threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
|
|
80165
|
-
readBodyFile: (path) => path === "-" ? context.readStdin() :
|
|
80144
|
+
readBodyFile: (path) => path === "-" ? context.readStdin() : readFile25(path, "utf8")
|
|
80166
80145
|
});
|
|
80167
80146
|
return context.runCommand({
|
|
80168
80147
|
command: [REAL_GH, ...ghArgs],
|
|
@@ -80261,7 +80240,7 @@ async function setAgentGithub({
|
|
|
80261
80240
|
}
|
|
80262
80241
|
|
|
80263
80242
|
// src/services/history-commands.service.ts
|
|
80264
|
-
import { readFile as
|
|
80243
|
+
import { readFile as readFile26 } from "node:fs/promises";
|
|
80265
80244
|
|
|
80266
80245
|
// src/rules/history-format.rules.ts
|
|
80267
80246
|
function timeOf2(iso) {
|
|
@@ -80357,7 +80336,7 @@ async function turnTokenOf3({ context }) {
|
|
|
80357
80336
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
80358
80337
|
if (pinned) return pinned;
|
|
80359
80338
|
if (!env.LAZE_TURN_FILE) return "";
|
|
80360
|
-
return
|
|
80339
|
+
return readFile26(env.LAZE_TURN_FILE, "utf8").then(
|
|
80361
80340
|
(text2) => text2.trim(),
|
|
80362
80341
|
() => ""
|
|
80363
80342
|
);
|
|
@@ -80549,19 +80528,19 @@ async function ip({ context, args }) {
|
|
|
80549
80528
|
}
|
|
80550
80529
|
|
|
80551
80530
|
// src/services/join-commands.service.ts
|
|
80552
|
-
import { mkdir as
|
|
80553
|
-
import { dirname as
|
|
80531
|
+
import { mkdir as mkdir17, readFile as readFile27, rename as rename5, rm as rm10, writeFile as writeFile18 } from "node:fs/promises";
|
|
80532
|
+
import { dirname as dirname16, join as join18 } from "node:path";
|
|
80554
80533
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
80555
80534
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
80556
80535
|
function pendingPathOf({ context }) {
|
|
80557
|
-
return
|
|
80536
|
+
return join18(dirname16(context.environment.configPath), "join", "pending.json");
|
|
80558
80537
|
}
|
|
80559
80538
|
async function readPending({
|
|
80560
80539
|
context,
|
|
80561
80540
|
url: url2,
|
|
80562
80541
|
args
|
|
80563
80542
|
}) {
|
|
80564
|
-
const pending = await
|
|
80543
|
+
const pending = await readFile27(pendingPathOf({ context }), "utf8").then(
|
|
80565
80544
|
(text2) => JSON.parse(text2),
|
|
80566
80545
|
() => void 0
|
|
80567
80546
|
);
|
|
@@ -80571,9 +80550,9 @@ async function readPending({
|
|
|
80571
80550
|
}
|
|
80572
80551
|
async function keepPending({ context, pending }) {
|
|
80573
80552
|
const path = pendingPathOf({ context });
|
|
80574
|
-
await
|
|
80553
|
+
await mkdir17(dirname16(path), { recursive: true, mode: 448 });
|
|
80575
80554
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
80576
|
-
await
|
|
80555
|
+
await writeFile18(temporary, JSON.stringify(pending), { mode: 384 });
|
|
80577
80556
|
await rename5(temporary, path);
|
|
80578
80557
|
}
|
|
80579
80558
|
async function dropPending({ context }) {
|
|
@@ -80891,9 +80870,9 @@ function machineAccessCommand(name2) {
|
|
|
80891
80870
|
|
|
80892
80871
|
// src/services/vault-commands.service.ts
|
|
80893
80872
|
import { createHash as createHash2 } from "node:crypto";
|
|
80894
|
-
import { mkdir as
|
|
80873
|
+
import { mkdir as mkdir18, readFile as readFile28, rm as rm11, writeFile as writeFile19 } from "node:fs/promises";
|
|
80895
80874
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
80896
|
-
import { dirname as
|
|
80875
|
+
import { dirname as dirname17, join as join19 } from "node:path";
|
|
80897
80876
|
var USAGE10 = `Usage: laze vault run <connection> --reason "<one plain sentence>" [--wait <s>] -- <command> [args...]
|
|
80898
80877
|
Runs the command with the connection's values in its environment, on a Laze agent's computer
|
|
80899
80878
|
or on a machine it runs on.`;
|
|
@@ -80932,7 +80911,7 @@ async function turnTokenOf4({
|
|
|
80932
80911
|
if (pinned) return pinned;
|
|
80933
80912
|
if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
80934
80913
|
try {
|
|
80935
|
-
return (await
|
|
80914
|
+
return (await readFile28(turnFile, "utf8")).trim();
|
|
80936
80915
|
} catch {
|
|
80937
80916
|
throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
80938
80917
|
}
|
|
@@ -80942,11 +80921,11 @@ function runKeyPathOf({
|
|
|
80942
80921
|
connection
|
|
80943
80922
|
}) {
|
|
80944
80923
|
const name2 = createHash2("sha256").update(connection).digest("hex");
|
|
80945
|
-
const base = turnFile ?
|
|
80946
|
-
return
|
|
80924
|
+
const base = turnFile ? dirname17(turnFile) : join19(tmpdir2(), "laze-vault");
|
|
80925
|
+
return join19(base, "vault-run-keys", `${name2}.json`);
|
|
80947
80926
|
}
|
|
80948
80927
|
async function runKeyAt({ path }) {
|
|
80949
|
-
const saved3 = await
|
|
80928
|
+
const saved3 = await readFile28(path, "utf8").then(
|
|
80950
80929
|
(text2) => JSON.parse(text2),
|
|
80951
80930
|
() => void 0
|
|
80952
80931
|
);
|
|
@@ -80956,8 +80935,8 @@ async function runKeyAt({ path }) {
|
|
|
80956
80935
|
}
|
|
80957
80936
|
const fresh = await generateEcdhKeys();
|
|
80958
80937
|
const jwk = await globalThis.crypto.subtle.exportKey("jwk", fresh.privateKey);
|
|
80959
|
-
await
|
|
80960
|
-
await
|
|
80938
|
+
await mkdir18(dirname17(path), { recursive: true, mode: 448 });
|
|
80939
|
+
await writeFile19(path, JSON.stringify({ publicKey: fresh.publicKey, privateKey: jwk }), {
|
|
80961
80940
|
mode: 384
|
|
80962
80941
|
});
|
|
80963
80942
|
return fresh;
|
|
@@ -81628,14 +81607,14 @@ async function serveMcp({
|
|
|
81628
81607
|
}
|
|
81629
81608
|
|
|
81630
81609
|
// src/services/mount-files.service.ts
|
|
81631
|
-
import { mkdir as
|
|
81632
|
-
import { dirname as
|
|
81610
|
+
import { mkdir as mkdir19, readFile as readFile29, rm as rm12, writeFile as writeFile20 } from "node:fs/promises";
|
|
81611
|
+
import { dirname as dirname18, relative as relative5, resolve as resolve11 } from "node:path";
|
|
81633
81612
|
async function textArgument({
|
|
81634
81613
|
context,
|
|
81635
81614
|
value
|
|
81636
81615
|
}) {
|
|
81637
81616
|
if (value === "-") return context.readStdin();
|
|
81638
|
-
if (value.startsWith("@")) return
|
|
81617
|
+
if (value.startsWith("@")) return readFile29(resolve11(context.cwd, value.slice(1)), "utf8");
|
|
81639
81618
|
return value;
|
|
81640
81619
|
}
|
|
81641
81620
|
function turnChannel({ context, args }) {
|
|
@@ -81649,14 +81628,14 @@ async function writeMount({
|
|
|
81649
81628
|
}) {
|
|
81650
81629
|
const root = resolve11(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
81651
81630
|
await rm12(root, { recursive: true, force: true });
|
|
81652
|
-
await
|
|
81631
|
+
await mkdir19(root, { recursive: true });
|
|
81653
81632
|
for (const file3 of files2) {
|
|
81654
81633
|
const target = resolve11(root, file3.path);
|
|
81655
81634
|
const inside = relative5(root, target);
|
|
81656
81635
|
if (!inside || inside.startsWith(".."))
|
|
81657
81636
|
throw new Error(`Refusing to write outside ${root}: ${file3.path}`);
|
|
81658
|
-
await
|
|
81659
|
-
await
|
|
81637
|
+
await mkdir19(dirname18(target), { recursive: true });
|
|
81638
|
+
await writeFile20(target, file3.content);
|
|
81660
81639
|
}
|
|
81661
81640
|
return root;
|
|
81662
81641
|
}
|
|
@@ -82394,6 +82373,69 @@ function watchingRelease({
|
|
|
82394
82373
|
};
|
|
82395
82374
|
}
|
|
82396
82375
|
|
|
82376
|
+
// src/services/rush-guard.service.ts
|
|
82377
|
+
import { readFile as readFile30, rm as rm13 } from "node:fs/promises";
|
|
82378
|
+
var WATCH_MS3 = 2e3;
|
|
82379
|
+
var RETRY_MS2 = 3e4;
|
|
82380
|
+
async function guardRound({ context, client, name: name2, lock, claudePid, session, rush }) {
|
|
82381
|
+
const key = session ? sessionKeyOf({ session }) : void 0;
|
|
82382
|
+
if (key && await liveElsewhere({ context, key, claudePid })) return true;
|
|
82383
|
+
const holder = await holderOf({ path: lock });
|
|
82384
|
+
if (holder?.pid !== context.processes.pid) {
|
|
82385
|
+
if (!await takeLock({ context, path: lock, claudePid, ...sessionIdOf({ session }) }))
|
|
82386
|
+
return true;
|
|
82387
|
+
}
|
|
82388
|
+
const due = await dueFromSpool({ context, profile: name2, seen: async () => "", pushedToo: true });
|
|
82389
|
+
const messages = due.length > 0 ? due : await takeRound({ context, client, claudePid: 0, session });
|
|
82390
|
+
if (messages.length === 0) return false;
|
|
82391
|
+
await keepTaken({ context, profile: name2, messages });
|
|
82392
|
+
const self2 = await currentNameOf({ context, client, profile: name2 });
|
|
82393
|
+
const env = { LAZE_WAKE_TEXT: hookContextOf({ messages, self: self2 }) };
|
|
82394
|
+
if (await context.runCommand({ command: rushSendCommand(rush), env }) !== 0) return false;
|
|
82395
|
+
await turnStarted({ context, client, agent: name2, messages }).catch(() => void 0);
|
|
82396
|
+
await dropFromSpool({ context, profile: name2, messageIds: messages.map((m) => m.messageId) });
|
|
82397
|
+
return true;
|
|
82398
|
+
}
|
|
82399
|
+
function sessionIdOf({ session }) {
|
|
82400
|
+
return session ? { sessionId: session.sessionId } : {};
|
|
82401
|
+
}
|
|
82402
|
+
async function rushWakeHook({ context, args }) {
|
|
82403
|
+
const claudePid = Number(flagText({ args, name: "claude-pid" }));
|
|
82404
|
+
const id = flagText({ args, name: "rush-id" });
|
|
82405
|
+
const program = flagText({ args, name: "rush-program" }) || "rush";
|
|
82406
|
+
if (!claudePid || !id) return 1;
|
|
82407
|
+
const path = guardPathOf({ context, claudePid });
|
|
82408
|
+
try {
|
|
82409
|
+
while (context.processes.alive(claudePid)) await context.sleep(WATCH_MS3);
|
|
82410
|
+
const { client, name: name2 } = await signedIn({ context, args });
|
|
82411
|
+
const noted = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
82412
|
+
const session = await readFile30(noted, "utf8").then(
|
|
82413
|
+
(text2) => JSON.parse(text2),
|
|
82414
|
+
() => void 0
|
|
82415
|
+
);
|
|
82416
|
+
const lock = statePathOf({ context, kind: "waiters", profile: name2 });
|
|
82417
|
+
const guard = { context, client, name: name2, lock, claudePid, session, rush: { id, program } };
|
|
82418
|
+
const deadline = context.nowMs() + WAIT_HOOK_TIMEOUT_SECONDS * 1e3;
|
|
82419
|
+
try {
|
|
82420
|
+
while (context.nowMs() < deadline) {
|
|
82421
|
+
const done = await guardRound(guard).catch((error62) => {
|
|
82422
|
+
context.err(`laze: the rush guard will try again: ${String(error62)}
|
|
82423
|
+
`);
|
|
82424
|
+
return "failed";
|
|
82425
|
+
});
|
|
82426
|
+
if (done === true) return 0;
|
|
82427
|
+
await context.sleep(done === "failed" ? RETRY_MS2 : 1e3);
|
|
82428
|
+
}
|
|
82429
|
+
return 0;
|
|
82430
|
+
} finally {
|
|
82431
|
+
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
82432
|
+
await rm13(lock, { force: true });
|
|
82433
|
+
}
|
|
82434
|
+
} finally {
|
|
82435
|
+
await rm13(path, { force: true });
|
|
82436
|
+
}
|
|
82437
|
+
}
|
|
82438
|
+
|
|
82397
82439
|
// src/services/schedule-commands.service.ts
|
|
82398
82440
|
var USAGE15 = `Usage:
|
|
82399
82441
|
laze schedule add <name> --prompt <text> (--cron "<m h dom mon dow>" | --rrule "<RRULE>" | --at <local time>)
|
|
@@ -82533,8 +82575,8 @@ async function schedule({ context, args }) {
|
|
|
82533
82575
|
}
|
|
82534
82576
|
|
|
82535
82577
|
// src/services/skill-commands.service.ts
|
|
82536
|
-
import { readdir as readdir6, readFile as
|
|
82537
|
-
import { join as
|
|
82578
|
+
import { readdir as readdir6, readFile as readFile31 } from "node:fs/promises";
|
|
82579
|
+
import { join as join20, relative as relative6, resolve as resolve12 } from "node:path";
|
|
82538
82580
|
var USAGE16 = `Usage:
|
|
82539
82581
|
laze skill list [--agent <agentId>]
|
|
82540
82582
|
laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
|
|
@@ -82555,8 +82597,8 @@ async function folderFiles({ root }) {
|
|
|
82555
82597
|
const files2 = [];
|
|
82556
82598
|
for (const entry of entries) {
|
|
82557
82599
|
if (!entry.isFile()) continue;
|
|
82558
|
-
const full =
|
|
82559
|
-
files2.push({ path: relative6(root, full), content: await
|
|
82600
|
+
const full = join20(entry.parentPath, entry.name);
|
|
82601
|
+
files2.push({ path: relative6(root, full), content: await readFile31(full, "utf8") });
|
|
82560
82602
|
}
|
|
82561
82603
|
return files2.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
82562
82604
|
}
|
|
@@ -82654,7 +82696,7 @@ async function skillUpdate({ context, args }) {
|
|
|
82654
82696
|
if (!name2 || !newName && description === void 0 && !skillMdFile) {
|
|
82655
82697
|
throw new CliUsageError(USAGE16);
|
|
82656
82698
|
}
|
|
82657
|
-
const skillMd = skillMdFile ? await
|
|
82699
|
+
const skillMd = skillMdFile ? await readFile31(resolve12(context.cwd, skillMdFile), "utf8") : void 0;
|
|
82658
82700
|
const { client } = await signedIn({ context, args });
|
|
82659
82701
|
const updated = await client.post("/api/skills/update", {
|
|
82660
82702
|
name: name2,
|
|
@@ -82700,7 +82742,7 @@ async function skill({ context, args }) {
|
|
|
82700
82742
|
}
|
|
82701
82743
|
|
|
82702
82744
|
// src/services/slack-commands.service.ts
|
|
82703
|
-
import { readFile as
|
|
82745
|
+
import { readFile as readFile32 } from "node:fs/promises";
|
|
82704
82746
|
import { resolve as resolve13 } from "node:path";
|
|
82705
82747
|
var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
|
|
82706
82748
|
laze slack overview connected Slack workspaces, mirrors, your link
|
|
@@ -82748,7 +82790,7 @@ async function secretLines({ context, args }) {
|
|
|
82748
82790
|
throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
|
|
82749
82791
|
}
|
|
82750
82792
|
const file3 = flagText({ args, name: "from-file" });
|
|
82751
|
-
const text2 = file3 ? await
|
|
82793
|
+
const text2 = file3 ? await readFile32(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
|
|
82752
82794
|
return text2.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
82753
82795
|
}
|
|
82754
82796
|
async function secretsOf({
|
|
@@ -83052,7 +83094,7 @@ async function slack({
|
|
|
83052
83094
|
}
|
|
83053
83095
|
|
|
83054
83096
|
// src/services/sso-commands.service.ts
|
|
83055
|
-
import { readFile as
|
|
83097
|
+
import { readFile as readFile33 } from "node:fs/promises";
|
|
83056
83098
|
var SSO_USAGE = `Usage:
|
|
83057
83099
|
laze sso domains claimed domains and how each signs in (admins)
|
|
83058
83100
|
laze sso claim <domain> the TXT record that proves the domain
|
|
@@ -83139,7 +83181,7 @@ function refuseSecretFlags({ args }) {
|
|
|
83139
83181
|
}
|
|
83140
83182
|
async function clientSecretOf({ context, args }) {
|
|
83141
83183
|
const file3 = flagText({ args, name: "from-file" });
|
|
83142
|
-
const text2 = file3 ? await
|
|
83184
|
+
const text2 = file3 ? await readFile33(file3, "utf8") : await context.readStdin();
|
|
83143
83185
|
const secret = text2.trim();
|
|
83144
83186
|
if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
|
|
83145
83187
|
return secret;
|
|
@@ -83472,7 +83514,7 @@ async function vaultScrub({ context, args }) {
|
|
|
83472
83514
|
}
|
|
83473
83515
|
|
|
83474
83516
|
// src/services/whatsapp-business-commands.service.ts
|
|
83475
|
-
import { readFile as
|
|
83517
|
+
import { readFile as readFile34 } from "node:fs/promises";
|
|
83476
83518
|
import { resolve as resolve14 } from "node:path";
|
|
83477
83519
|
|
|
83478
83520
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
|
|
@@ -83892,7 +83934,7 @@ async function secretsOf2({ context, args }) {
|
|
|
83892
83934
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
83893
83935
|
if (fromConnection) return { fromConnection };
|
|
83894
83936
|
const file3 = flagText({ args, name: "from-file" });
|
|
83895
|
-
const text2 = file3 ? await
|
|
83937
|
+
const text2 = file3 ? await readFile34(resolve14(context.cwd, file3), "utf8") : await context.readStdin();
|
|
83896
83938
|
const lines = text2.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
83897
83939
|
if (lines.length !== 2) {
|
|
83898
83940
|
throw new CliUsageError(
|
|
@@ -84093,7 +84135,7 @@ async function whatsappBusiness({
|
|
|
84093
84135
|
}
|
|
84094
84136
|
|
|
84095
84137
|
// src/services/whatsapp-pairing-commands.service.ts
|
|
84096
|
-
import { writeFile as
|
|
84138
|
+
import { writeFile as writeFile21 } from "node:fs/promises";
|
|
84097
84139
|
import { resolve as resolve15 } from "node:path";
|
|
84098
84140
|
var WHATSAPP_PAIRING_USAGE = [
|
|
84099
84141
|
" laze whatsapp pair <machine> [--qr <file.svg>] link WhatsApp on your machine; scan the code (owner)",
|
|
@@ -84114,7 +84156,7 @@ function svgOf(dataUrl) {
|
|
|
84114
84156
|
}
|
|
84115
84157
|
async function report({ context, args, pairing: pairing2 }) {
|
|
84116
84158
|
const qrFile = pairing2.qrSvg ? resolve15(context.cwd, flagText({ args, name: "qr", fallback: "whatsapp-qr.svg" })) : null;
|
|
84117
|
-
if (qrFile && pairing2.qrSvg) await
|
|
84159
|
+
if (qrFile && pairing2.qrSvg) await writeFile21(qrFile, svgOf(pairing2.qrSvg), "utf8");
|
|
84118
84160
|
if (args.flags.json) return context.out(`${JSON.stringify({ ...pairing2, qrFile }, null, 2)}
|
|
84119
84161
|
`);
|
|
84120
84162
|
context.out(`${pairing2.pairingId} ${pairing2.state}
|
|
@@ -84473,7 +84515,7 @@ async function flags({ context, args }) {
|
|
|
84473
84515
|
}
|
|
84474
84516
|
|
|
84475
84517
|
// src/services/workspace-commands.service.ts
|
|
84476
|
-
import { readFile as
|
|
84518
|
+
import { readFile as readFile35 } from "node:fs/promises";
|
|
84477
84519
|
import { resolve as resolve16 } from "node:path";
|
|
84478
84520
|
var ROLE_NAMES2 = {
|
|
84479
84521
|
OWNER: "Owner",
|
|
@@ -84656,7 +84698,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
|
|
|
84656
84698
|
async function readLogo({ context, file: file3 }) {
|
|
84657
84699
|
let bytes;
|
|
84658
84700
|
try {
|
|
84659
|
-
bytes = new Uint8Array(await
|
|
84701
|
+
bytes = new Uint8Array(await readFile35(resolve16(context.cwd, file3)));
|
|
84660
84702
|
} catch {
|
|
84661
84703
|
throw new CliUsageError(`No file to read at ${file3}.`);
|
|
84662
84704
|
}
|
|
@@ -85164,6 +85206,7 @@ var COMMANDS3 = {
|
|
|
85164
85206
|
"hook wait": waitHook,
|
|
85165
85207
|
"hook pre-tool": preToolHook,
|
|
85166
85208
|
"hook monitor": monitorHook,
|
|
85209
|
+
"hook rush-wake": rushWakeHook,
|
|
85167
85210
|
plugin,
|
|
85168
85211
|
adopt: adoptCodex,
|
|
85169
85212
|
feed,
|
|
@@ -85317,8 +85360,8 @@ async function runCli({
|
|
|
85317
85360
|
// src/services/processes.service.ts
|
|
85318
85361
|
import { execFile as execFile2, spawn as spawn4 } from "node:child_process";
|
|
85319
85362
|
import { mkdirSync, openSync } from "node:fs";
|
|
85320
|
-
import { readFile as
|
|
85321
|
-
import { dirname as
|
|
85363
|
+
import { readFile as readFile36, readlink } from "node:fs/promises";
|
|
85364
|
+
import { dirname as dirname19 } from "node:path";
|
|
85322
85365
|
import { promisify as promisify2 } from "node:util";
|
|
85323
85366
|
var run3 = promisify2(execFile2);
|
|
85324
85367
|
function alive(pid) {
|
|
@@ -85331,14 +85374,14 @@ function alive(pid) {
|
|
|
85331
85374
|
}
|
|
85332
85375
|
}
|
|
85333
85376
|
async function argsOf(pid) {
|
|
85334
|
-
const raw = await
|
|
85377
|
+
const raw = await readFile36(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
|
|
85335
85378
|
if (raw) return raw.split("\0").filter(Boolean);
|
|
85336
85379
|
const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
|
|
85337
85380
|
const line = listed?.stdout.trim();
|
|
85338
85381
|
return line ? line.split(/\s+/) : void 0;
|
|
85339
85382
|
}
|
|
85340
85383
|
async function parentOf(pid) {
|
|
85341
|
-
const stat3 = await
|
|
85384
|
+
const stat3 = await readFile36(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
85342
85385
|
const fromStat = stat3 ? Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
|
|
85343
85386
|
if (fromStat > 0) return fromStat;
|
|
85344
85387
|
const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
|
|
@@ -85355,7 +85398,7 @@ async function cwdOf(pid) {
|
|
|
85355
85398
|
return line ? line.slice(1) : void 0;
|
|
85356
85399
|
}
|
|
85357
85400
|
function spawnDetached({ argv, logPath }) {
|
|
85358
|
-
mkdirSync(
|
|
85401
|
+
mkdirSync(dirname19(logPath), { recursive: true, mode: 448 });
|
|
85359
85402
|
const log = openSync(logPath, "a", 384);
|
|
85360
85403
|
const [program = "", ...rest] = argv;
|
|
85361
85404
|
const child = spawn4(program, rest, { detached: true, stdio: ["ignore", log, log] });
|