@lazehq/cli 0.1.20 → 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 +296 -233
- 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,11 +67478,13 @@ 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
|
-
function rushSessionOf({
|
|
67485
|
+
function rushSessionOf({
|
|
67486
|
+
parentArgs
|
|
67487
|
+
}) {
|
|
67486
67488
|
if (!parentArgs) return void 0;
|
|
67487
67489
|
const [program = "", verb, action, id] = parentArgs;
|
|
67488
67490
|
const isRush = program === "rush" || program.endsWith("/rush");
|
|
@@ -67493,13 +67495,50 @@ function rushSendCommand({ program, id }) {
|
|
|
67493
67495
|
return ["sh", "-c", 'printf "%s\\n" "$LAZE_WAKE_TEXT" | "$0" session send "$1"', program, id];
|
|
67494
67496
|
}
|
|
67495
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
|
+
|
|
67496
67536
|
// src/services/claude-wait.service.ts
|
|
67497
67537
|
var ROUND_SECONDS = 50;
|
|
67498
67538
|
var WATCH_MS = 2e3;
|
|
67499
|
-
var RUSH_RETRY_MS = 3e4;
|
|
67500
67539
|
var CHANNEL_CHECK_MS = 5e3;
|
|
67501
67540
|
async function holderOf({ path }) {
|
|
67502
|
-
return
|
|
67541
|
+
return readFile7(path, "utf8").then(
|
|
67503
67542
|
(text2) => JSON.parse(text2),
|
|
67504
67543
|
() => void 0
|
|
67505
67544
|
);
|
|
@@ -67523,8 +67562,8 @@ async function takeLock({
|
|
|
67523
67562
|
if (served && context.processes.alive(served) && !mine3) return false;
|
|
67524
67563
|
context.processes.stop(holder.pid);
|
|
67525
67564
|
}
|
|
67526
|
-
await
|
|
67527
|
-
await
|
|
67565
|
+
await mkdir6(dirname6(path), { recursive: true, mode: 448 });
|
|
67566
|
+
await writeFile6(
|
|
67528
67567
|
path,
|
|
67529
67568
|
JSON.stringify({
|
|
67530
67569
|
pid: self2,
|
|
@@ -67630,26 +67669,16 @@ async function waitForMessages({ context, args }) {
|
|
|
67630
67669
|
await rememberSession({ context, claudePid, session });
|
|
67631
67670
|
const lock = statePathOf({ context, kind: "waiters", profile: name2 });
|
|
67632
67671
|
if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
|
|
67633
|
-
const seen = () => input2.transcript_path ?
|
|
67672
|
+
const seen = () => input2.transcript_path ? readFile7(input2.transcript_path, "utf8") : Promise.resolve("");
|
|
67634
67673
|
const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
|
|
67635
67674
|
const rush = rushSessionOf({
|
|
67636
67675
|
parentArgs: await context.processes.argsOf(await context.processes.parentOf(claudePid) ?? 0)
|
|
67637
67676
|
});
|
|
67677
|
+
if (rush) await startRushGuard({ context, profile: name2, claudePid, rush });
|
|
67638
67678
|
try {
|
|
67639
67679
|
while (context.nowMs() < deadline) {
|
|
67640
67680
|
const code = await settleRound({ context, client, name: name2, lock, claudePid, session, seen });
|
|
67641
|
-
if (code
|
|
67642
|
-
if (code !== 0 || !rush || context.processes.alive(claudePid)) return code;
|
|
67643
|
-
return await wakeThroughRush({
|
|
67644
|
-
context,
|
|
67645
|
-
client,
|
|
67646
|
-
name: name2,
|
|
67647
|
-
lock,
|
|
67648
|
-
claudePid,
|
|
67649
|
-
session,
|
|
67650
|
-
rush,
|
|
67651
|
-
deadline
|
|
67652
|
-
});
|
|
67681
|
+
if (code !== "again") return code;
|
|
67653
67682
|
}
|
|
67654
67683
|
return 0;
|
|
67655
67684
|
} finally {
|
|
@@ -67657,40 +67686,6 @@ async function waitForMessages({ context, args }) {
|
|
|
67657
67686
|
await rm2(lock, { force: true });
|
|
67658
67687
|
}
|
|
67659
67688
|
}
|
|
67660
|
-
async function rushRound({
|
|
67661
|
-
context,
|
|
67662
|
-
client,
|
|
67663
|
-
name: name2,
|
|
67664
|
-
lock,
|
|
67665
|
-
claudePid,
|
|
67666
|
-
session,
|
|
67667
|
-
rush
|
|
67668
|
-
}) {
|
|
67669
|
-
if ((await holderOf({ path: lock }))?.pid !== context.processes.pid) return true;
|
|
67670
|
-
const key = session ? sessionKeyOf({ session }) : void 0;
|
|
67671
|
-
if (key && await liveElsewhere({ context, key, claudePid })) return true;
|
|
67672
|
-
const due = await dueFromSpool({ context, profile: name2, seen: async () => "", pushedToo: true });
|
|
67673
|
-
const messages = due.length > 0 ? due : await takeRound({ context, client, claudePid: 0, session });
|
|
67674
|
-
if (messages.length === 0) return false;
|
|
67675
|
-
await keepTaken({ context, profile: name2, messages });
|
|
67676
|
-
const self2 = await currentNameOf({ context, client, profile: name2 });
|
|
67677
|
-
const command = rushSendCommand(rush);
|
|
67678
|
-
const env = { LAZE_WAKE_TEXT: hookContextOf({ messages, self: self2 }) };
|
|
67679
|
-
const quiet = { write: () => true };
|
|
67680
|
-
const sent = await context.runCommand({ command, env, stdout: quiet, stderr: quiet });
|
|
67681
|
-
if (sent !== 0) return false;
|
|
67682
|
-
await turnStarted({ context, client, agent: name2, messages }).catch(() => void 0);
|
|
67683
|
-
await dropFromSpool({ context, profile: name2, messageIds: messages.map((m) => m.messageId) });
|
|
67684
|
-
return true;
|
|
67685
|
-
}
|
|
67686
|
-
async function wakeThroughRush(round) {
|
|
67687
|
-
while (round.context.nowMs() < round.deadline) {
|
|
67688
|
-
const done = await rushRound(round).catch(() => "failed");
|
|
67689
|
-
if (done === true) return 0;
|
|
67690
|
-
await round.context.sleep(done === "failed" ? RUSH_RETRY_MS : 1e3);
|
|
67691
|
-
}
|
|
67692
|
-
return 0;
|
|
67693
|
-
}
|
|
67694
67689
|
async function waitHook({ context, args }) {
|
|
67695
67690
|
try {
|
|
67696
67691
|
return await waitForMessages({ context, args });
|
|
@@ -67713,7 +67708,7 @@ async function monitorServes({
|
|
|
67713
67708
|
// src/services/codex-link.service.ts
|
|
67714
67709
|
import { createReadStream } from "node:fs";
|
|
67715
67710
|
import { readdir as readdir4, rm as rm6, stat as stat2 } from "node:fs/promises";
|
|
67716
|
-
import { join as
|
|
67711
|
+
import { join as join12, resolve as resolve3 } from "node:path";
|
|
67717
67712
|
import { createInterface as createInterface2 } from "node:readline";
|
|
67718
67713
|
|
|
67719
67714
|
// src/rules/connect-service.rules.ts
|
|
@@ -67833,8 +67828,8 @@ function rolloutEventOf({
|
|
|
67833
67828
|
|
|
67834
67829
|
// src/services/codex-adopt.service.ts
|
|
67835
67830
|
import { spawn as spawn2 } from "node:child_process";
|
|
67836
|
-
import { mkdir as
|
|
67837
|
-
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";
|
|
67838
67833
|
import { createInterface } from "node:readline";
|
|
67839
67834
|
|
|
67840
67835
|
// src/rules/codex-requests.rules.ts
|
|
@@ -67954,11 +67949,11 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
67954
67949
|
}
|
|
67955
67950
|
};
|
|
67956
67951
|
async function newestThreadId({ codexHome }) {
|
|
67957
|
-
const root =
|
|
67952
|
+
const root = join7(codexHome, "sessions");
|
|
67958
67953
|
const files2 = await readdir2(root, { recursive: true }).catch(() => []);
|
|
67959
67954
|
const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
|
|
67960
67955
|
const dated = await Promise.all(
|
|
67961
|
-
rollouts.map(async (file3) => ({ file: file3, at: (await stat(
|
|
67956
|
+
rollouts.map(async (file3) => ({ file: file3, at: (await stat(join7(root, file3))).mtimeMs }))
|
|
67962
67957
|
);
|
|
67963
67958
|
const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
|
|
67964
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);
|
|
@@ -68033,7 +68028,7 @@ async function answer({
|
|
|
68033
68028
|
var MAX_RESTART_WAIT_SECONDS = 60;
|
|
68034
68029
|
var HEALTHY_RUN_MS = 6e4;
|
|
68035
68030
|
async function recordOf({ path }) {
|
|
68036
|
-
return
|
|
68031
|
+
return readFile8(path, "utf8").then(
|
|
68037
68032
|
(text2) => JSON.parse(text2),
|
|
68038
68033
|
() => void 0
|
|
68039
68034
|
);
|
|
@@ -68055,8 +68050,8 @@ async function startAdoptInBackground({
|
|
|
68055
68050
|
const adopt = ["adopt", "codex", "--profile", profile, ...threadFlag({ thread: thread2 })];
|
|
68056
68051
|
const argv = [...context.program, ...adopt, "--supervise"];
|
|
68057
68052
|
const pid = context.processes.spawnDetached({ argv, logPath: log });
|
|
68058
|
-
await
|
|
68059
|
-
await
|
|
68053
|
+
await mkdir7(dirname7(path), { recursive: true, mode: 448 });
|
|
68054
|
+
await writeFile7(path, JSON.stringify({ pid, thread: thread2, log, startedAt: context.nowMs() }));
|
|
68060
68055
|
return [
|
|
68061
68056
|
`Started \`${laze} adopt codex\` in the background (pid ${pid}). It answers each Laze message`,
|
|
68062
68057
|
`as a turn in ${thread2 ? `this Codex thread (${thread2})` : "the newest Codex thread"}, and starts again if it stops.`,
|
|
@@ -68136,7 +68131,7 @@ async function adoptedThreadOf({
|
|
|
68136
68131
|
);
|
|
68137
68132
|
if (!held) return threadId;
|
|
68138
68133
|
const path = statePathOf({ context, kind: "adopt", profile, extension: "forks.json" });
|
|
68139
|
-
const forks = await
|
|
68134
|
+
const forks = await readFile8(path, "utf8").then(
|
|
68140
68135
|
(text2) => JSON.parse(text2),
|
|
68141
68136
|
() => ({})
|
|
68142
68137
|
);
|
|
@@ -68151,8 +68146,8 @@ async function adoptedThreadOf({
|
|
|
68151
68146
|
}
|
|
68152
68147
|
const forked = record3((await codex.call("thread/fork", { threadId })).thread).id;
|
|
68153
68148
|
if (typeof forked !== "string") throw new Error("thread/fork answered no thread id");
|
|
68154
|
-
await
|
|
68155
|
-
await
|
|
68149
|
+
await mkdir7(dirname7(path), { recursive: true, mode: 448 });
|
|
68150
|
+
await writeFile7(path, JSON.stringify({ ...forks, [threadId]: forked }));
|
|
68156
68151
|
context.out(
|
|
68157
68152
|
`Codex holds thread ${threadId} open elsewhere; answering in its new fork ${forked}.
|
|
68158
68153
|
`
|
|
@@ -68207,20 +68202,20 @@ async function adoptCodex({ context, args }) {
|
|
|
68207
68202
|
}
|
|
68208
68203
|
|
|
68209
68204
|
// src/services/connect-delivery.service.ts
|
|
68210
|
-
import { mkdir as
|
|
68205
|
+
import { mkdir as mkdir9, readFile as readFile10, rename as rename3, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
|
|
68211
68206
|
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
68212
|
-
import { dirname as
|
|
68207
|
+
import { dirname as dirname9, join as join10 } from "node:path";
|
|
68213
68208
|
|
|
68214
68209
|
// src/services/codex-turn-watch.service.ts
|
|
68215
68210
|
import { open as open2, readdir as readdir3 } from "node:fs/promises";
|
|
68216
|
-
import { join as
|
|
68211
|
+
import { join as join8 } from "node:path";
|
|
68217
68212
|
var READ_MS = 1500;
|
|
68218
68213
|
var KEEP_WORKING_MS = 3e4;
|
|
68219
68214
|
async function rolloutPathOf({ delivery }) {
|
|
68220
|
-
const root =
|
|
68215
|
+
const root = join8(delivery.codexHome, "sessions");
|
|
68221
68216
|
const files2 = await readdir3(root, { recursive: true }).catch(() => []);
|
|
68222
68217
|
const file3 = files2.find((name2) => name2.endsWith(`-${delivery.threadId}.jsonl`));
|
|
68223
|
-
return file3 ?
|
|
68218
|
+
return file3 ? join8(root, file3) : void 0;
|
|
68224
68219
|
}
|
|
68225
68220
|
async function readFrom({ path, offset }) {
|
|
68226
68221
|
const handle = await open2(path, "r");
|
|
@@ -68306,8 +68301,8 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
68306
68301
|
};
|
|
68307
68302
|
|
|
68308
68303
|
// src/services/openclaw-relay.service.ts
|
|
68309
|
-
import { chmod as chmod2, mkdir as
|
|
68310
|
-
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";
|
|
68311
68306
|
|
|
68312
68307
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
68313
68308
|
var workspaceIdSchema14 = external_exports.string().min(1);
|
|
@@ -68535,11 +68530,11 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
68535
68530
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
68536
68531
|
]);
|
|
68537
68532
|
function relaysPathOf({ context }) {
|
|
68538
|
-
return
|
|
68533
|
+
return join9(dirname8(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
68539
68534
|
}
|
|
68540
68535
|
async function readRelays({ context }) {
|
|
68541
68536
|
try {
|
|
68542
|
-
return JSON.parse(await
|
|
68537
|
+
return JSON.parse(await readFile9(relaysPathOf({ context }), "utf8"));
|
|
68543
68538
|
} catch {
|
|
68544
68539
|
return {};
|
|
68545
68540
|
}
|
|
@@ -68549,8 +68544,8 @@ async function saveRelays({
|
|
|
68549
68544
|
relays
|
|
68550
68545
|
}) {
|
|
68551
68546
|
const path = relaysPathOf({ context });
|
|
68552
|
-
await
|
|
68553
|
-
await
|
|
68547
|
+
await mkdir8(dirname8(path), { recursive: true, mode: 448 });
|
|
68548
|
+
await writeFile8(path, `${JSON.stringify(relays, null, 2)}
|
|
68554
68549
|
`, { mode: 384 });
|
|
68555
68550
|
await chmod2(path, 384);
|
|
68556
68551
|
}
|
|
@@ -68736,14 +68731,14 @@ var RelayLoops = class _RelayLoops {
|
|
|
68736
68731
|
|
|
68737
68732
|
// src/services/connect-delivery.service.ts
|
|
68738
68733
|
function connectFolderOf({ context }) {
|
|
68739
|
-
return
|
|
68734
|
+
return join10(dirname9(context.environment.configPath), "connect");
|
|
68740
68735
|
}
|
|
68741
68736
|
function runStatePathOf({ context }) {
|
|
68742
|
-
return
|
|
68737
|
+
return join10(connectFolderOf({ context }), "run.json");
|
|
68743
68738
|
}
|
|
68744
68739
|
async function readJson({ path }) {
|
|
68745
68740
|
try {
|
|
68746
|
-
return JSON.parse(await
|
|
68741
|
+
return JSON.parse(await readFile10(path, "utf8"));
|
|
68747
68742
|
} catch {
|
|
68748
68743
|
return void 0;
|
|
68749
68744
|
}
|
|
@@ -68769,9 +68764,10 @@ async function queueInCodex({
|
|
|
68769
68764
|
text: text2
|
|
68770
68765
|
}) {
|
|
68771
68766
|
let stderr2 = "";
|
|
68767
|
+
const queue = ["codex", "queue", "--thread", delivery.threadId, "--message", text2];
|
|
68772
68768
|
const code = await context.runCommand({
|
|
68773
|
-
command:
|
|
68774
|
-
env: { CODEX_HOME: delivery.codexHome },
|
|
68769
|
+
command: delivery.rush ? rushSendCommand(delivery.rush) : queue,
|
|
68770
|
+
env: delivery.rush ? { LAZE_WAKE_TEXT: text2 } : { CODEX_HOME: delivery.codexHome },
|
|
68775
68771
|
stderr: {
|
|
68776
68772
|
write: (chunk) => {
|
|
68777
68773
|
stderr2 += chunk;
|
|
@@ -68893,9 +68889,9 @@ async function serveRounds({
|
|
|
68893
68889
|
}
|
|
68894
68890
|
var saves = 0;
|
|
68895
68891
|
async function save(run4) {
|
|
68896
|
-
await
|
|
68892
|
+
await mkdir9(dirname9(run4.path), { recursive: true, mode: 448 });
|
|
68897
68893
|
const temporary = `${run4.path}.${run4.self}.${saves += 1}.tmp`;
|
|
68898
|
-
await
|
|
68894
|
+
await writeFile9(temporary, JSON.stringify(run4.state));
|
|
68899
68895
|
await rename3(temporary, run4.path);
|
|
68900
68896
|
}
|
|
68901
68897
|
async function holdsLock(run4) {
|
|
@@ -68976,8 +68972,8 @@ async function runConnectLoop({ context }) {
|
|
|
68976
68972
|
|
|
68977
68973
|
// src/services/connect-service.service.ts
|
|
68978
68974
|
import { createHash } from "node:crypto";
|
|
68979
|
-
import { mkdir as
|
|
68980
|
-
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";
|
|
68981
68977
|
var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the service that delivers to linked Codex sessions.
|
|
68982
68978
|
|
|
68983
68979
|
laze connect install install and start it (systemd --user, a LaunchAgent, or detached)
|
|
@@ -68990,17 +68986,17 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
|
|
|
68990
68986
|
\`laze openclaw connect --local\`, whose OpenClaw relay it also runs.
|
|
68991
68987
|
`;
|
|
68992
68988
|
function installedPathOf({ context }) {
|
|
68993
|
-
return
|
|
68989
|
+
return join11(connectFolderOf({ context }), "service.json");
|
|
68994
68990
|
}
|
|
68995
68991
|
function logPathOf({ context }) {
|
|
68996
|
-
return
|
|
68992
|
+
return join11(connectFolderOf({ context }), "connect.log");
|
|
68997
68993
|
}
|
|
68998
68994
|
function homeOf({ context }) {
|
|
68999
|
-
return context.environment.inherited.HOME ??
|
|
68995
|
+
return context.environment.inherited.HOME ?? dirname10(dirname10(context.environment.configPath));
|
|
69000
68996
|
}
|
|
69001
68997
|
function serviceNameOf({ context }) {
|
|
69002
68998
|
const { configPath } = context.environment;
|
|
69003
|
-
if (configPath ===
|
|
68999
|
+
if (configPath === join11(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
|
|
69004
69000
|
return `laze-connect-${createHash("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
69005
69001
|
}
|
|
69006
69002
|
function serviceEnvOf({ context }) {
|
|
@@ -69023,10 +69019,10 @@ async function run({ context, command }) {
|
|
|
69023
69019
|
async function installSystemd({ context }) {
|
|
69024
69020
|
const name2 = serviceNameOf({ context });
|
|
69025
69021
|
const env = context.environment.inherited;
|
|
69026
|
-
const base = env.XDG_CONFIG_HOME ||
|
|
69027
|
-
const file3 =
|
|
69028
|
-
await
|
|
69029
|
-
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(
|
|
69030
69026
|
file3,
|
|
69031
69027
|
systemdUnitOf({ argv: runArgvOf({ context }), env: serviceEnvOf({ context }) })
|
|
69032
69028
|
);
|
|
@@ -69039,10 +69035,10 @@ async function installSystemd({ context }) {
|
|
|
69039
69035
|
async function installLaunchd({ context }) {
|
|
69040
69036
|
const name2 = serviceNameOf({ context });
|
|
69041
69037
|
const label2 = `ai.laze.${name2}`;
|
|
69042
|
-
const file3 =
|
|
69038
|
+
const file3 = join11(homeOf({ context }), "Library", "LaunchAgents", `${label2}.plist`);
|
|
69043
69039
|
const log = logPathOf({ context });
|
|
69044
|
-
await
|
|
69045
|
-
await
|
|
69040
|
+
await mkdir10(dirname10(file3), { recursive: true });
|
|
69041
|
+
await writeFile10(
|
|
69046
69042
|
file3,
|
|
69047
69043
|
launchAgentOf({
|
|
69048
69044
|
label: label2,
|
|
@@ -69094,8 +69090,8 @@ async function installConnectService({ context }) {
|
|
|
69094
69090
|
const manager = await managerOf({ context });
|
|
69095
69091
|
const install = { systemd: installSystemd, launchd: installLaunchd, detached: installDetached };
|
|
69096
69092
|
const installed = await install[manager]({ context });
|
|
69097
|
-
await
|
|
69098
|
-
await
|
|
69093
|
+
await mkdir10(dirname10(path), { recursive: true, mode: 448 });
|
|
69094
|
+
await writeFile10(path, JSON.stringify(installed));
|
|
69099
69095
|
return describeInstalled({ installed });
|
|
69100
69096
|
}
|
|
69101
69097
|
function describeInstalled({ installed }) {
|
|
@@ -69207,13 +69203,13 @@ async function newestThreadIn({
|
|
|
69207
69203
|
codexHome,
|
|
69208
69204
|
directory
|
|
69209
69205
|
}) {
|
|
69210
|
-
const root =
|
|
69206
|
+
const root = join12(codexHome, "sessions");
|
|
69211
69207
|
const files2 = await readdir4(root, { recursive: true }).catch(() => []);
|
|
69212
69208
|
const rollouts = files2.filter((file3) => /rollout-.*\.jsonl$/.test(file3));
|
|
69213
69209
|
const dated = await Promise.all(
|
|
69214
69210
|
rollouts.map(async (file3) => ({
|
|
69215
|
-
path:
|
|
69216
|
-
at: await stat2(
|
|
69211
|
+
path: join12(root, file3),
|
|
69212
|
+
at: await stat2(join12(root, file3)).then(
|
|
69217
69213
|
(info) => info.mtimeMs,
|
|
69218
69214
|
() => 0
|
|
69219
69215
|
)
|
|
@@ -69258,6 +69254,7 @@ async function linkCodexSession({
|
|
|
69258
69254
|
return startAdoptInBackground({ context, args, profile, laze });
|
|
69259
69255
|
}
|
|
69260
69256
|
await stopAdopt({ context, profile });
|
|
69257
|
+
const rush = await rushAboveOf({ context });
|
|
69261
69258
|
await context.store.setDelivery({
|
|
69262
69259
|
name: profile,
|
|
69263
69260
|
delivery: {
|
|
@@ -69265,7 +69262,8 @@ async function linkCodexSession({
|
|
|
69265
69262
|
threadId,
|
|
69266
69263
|
codexHome: context.environment.codexHome,
|
|
69267
69264
|
cwd: directory,
|
|
69268
|
-
linkedAt: context.nowMs()
|
|
69265
|
+
linkedAt: context.nowMs(),
|
|
69266
|
+
...rush ? { rush } : {}
|
|
69269
69267
|
}
|
|
69270
69268
|
});
|
|
69271
69269
|
const service = await installConnectService({ context });
|
|
@@ -69281,8 +69279,8 @@ async function linkCodexSession({
|
|
|
69281
69279
|
}
|
|
69282
69280
|
|
|
69283
69281
|
// src/services/laze-plugin.service.ts
|
|
69284
|
-
import { mkdir as
|
|
69285
|
-
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";
|
|
69286
69284
|
|
|
69287
69285
|
// src/rules/laze-plugin.rules.ts
|
|
69288
69286
|
var LAZE_PLUGIN = "laze";
|
|
@@ -69398,11 +69396,11 @@ function lazePluginFiles({
|
|
|
69398
69396
|
var REGISTER_LIMIT_MS = 6e4;
|
|
69399
69397
|
var quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
69400
69398
|
function pluginFolderOf({ context }) {
|
|
69401
|
-
return
|
|
69399
|
+
return join13(dirname11(context.environment.configPath), "plugins");
|
|
69402
69400
|
}
|
|
69403
69401
|
async function pluginIsCurrent({ context }) {
|
|
69404
|
-
const manifest =
|
|
69405
|
-
const written = await
|
|
69402
|
+
const manifest = join13(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
|
|
69403
|
+
const written = await readFile11(manifest, "utf8").then(
|
|
69406
69404
|
(text2) => JSON.parse(text2).version,
|
|
69407
69405
|
() => void 0
|
|
69408
69406
|
);
|
|
@@ -69416,9 +69414,9 @@ async function writeLazePlugin({ context }) {
|
|
|
69416
69414
|
configPath: context.environment.configPath
|
|
69417
69415
|
});
|
|
69418
69416
|
for (const [path, text2] of Object.entries(files2)) {
|
|
69419
|
-
const target =
|
|
69420
|
-
await
|
|
69421
|
-
await
|
|
69417
|
+
const target = join13(folder, path);
|
|
69418
|
+
await mkdir11(dirname11(target), { recursive: true });
|
|
69419
|
+
await writeFile11(target, text2);
|
|
69422
69420
|
}
|
|
69423
69421
|
return folder;
|
|
69424
69422
|
}
|
|
@@ -69440,10 +69438,10 @@ async function registerWithClaude({ context, folder }) {
|
|
|
69440
69438
|
return code === 0;
|
|
69441
69439
|
}
|
|
69442
69440
|
function registeredMarkOf({ context }) {
|
|
69443
|
-
return
|
|
69441
|
+
return join13(pluginFolderOf({ context }), "registered");
|
|
69444
69442
|
}
|
|
69445
69443
|
async function pluginRegistered({ context }) {
|
|
69446
|
-
return
|
|
69444
|
+
return readFile11(registeredMarkOf({ context }), "utf8").then(
|
|
69447
69445
|
() => true,
|
|
69448
69446
|
() => false
|
|
69449
69447
|
);
|
|
@@ -69451,13 +69449,13 @@ async function pluginRegistered({ context }) {
|
|
|
69451
69449
|
async function installLazePlugin({ context }) {
|
|
69452
69450
|
const folder = await writeLazePlugin({ context });
|
|
69453
69451
|
const registered = await registerWithClaude({ context, folder });
|
|
69454
|
-
if (registered) await
|
|
69452
|
+
if (registered) await writeFile11(registeredMarkOf({ context }), cliVersionOf());
|
|
69455
69453
|
return { folder, registered };
|
|
69456
69454
|
}
|
|
69457
69455
|
async function plugin({ context, args }) {
|
|
69458
69456
|
const action = args.words[1] ?? "install";
|
|
69459
69457
|
if (action === "path") {
|
|
69460
|
-
context.out(`${
|
|
69458
|
+
context.out(`${join13(pluginFolderOf({ context }), LAZE_PLUGIN)}
|
|
69461
69459
|
`);
|
|
69462
69460
|
return 0;
|
|
69463
69461
|
}
|
|
@@ -69475,8 +69473,8 @@ async function plugin({ context, args }) {
|
|
|
69475
69473
|
}
|
|
69476
69474
|
|
|
69477
69475
|
// src/services/mcp-channel.service.ts
|
|
69478
|
-
import { mkdir as
|
|
69479
|
-
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";
|
|
69480
69478
|
var LAZE_MCP_SERVER = "laze";
|
|
69481
69479
|
var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
|
|
69482
69480
|
var ROUND_SECONDS3 = 50;
|
|
@@ -69566,8 +69564,8 @@ async function pushInbox({
|
|
|
69566
69564
|
signal
|
|
69567
69565
|
}) {
|
|
69568
69566
|
const marker = statePathOf({ context, kind: "channels", profile });
|
|
69569
|
-
await
|
|
69570
|
-
await
|
|
69567
|
+
await mkdir12(dirname12(marker), { recursive: true, mode: 448 });
|
|
69568
|
+
await writeFile12(marker, JSON.stringify({ pid: context.processes.pid }));
|
|
69571
69569
|
try {
|
|
69572
69570
|
while (!signal.aborted) {
|
|
69573
69571
|
const messages = await client.post("/api/agents/me/inbox", { waitSeconds: ROUND_SECONDS3 }, { signal }).catch(async (error62) => {
|
|
@@ -69594,8 +69592,8 @@ async function pushInbox({
|
|
|
69594
69592
|
}
|
|
69595
69593
|
|
|
69596
69594
|
// src/services/plugin-tip.service.ts
|
|
69597
|
-
import { mkdir as
|
|
69598
|
-
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";
|
|
69599
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.";
|
|
69600
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.";
|
|
69601
69599
|
function monitorsRunHere({ context }) {
|
|
@@ -69629,8 +69627,8 @@ async function markReloadTipTold({
|
|
|
69629
69627
|
}) {
|
|
69630
69628
|
if (!session) return;
|
|
69631
69629
|
const path = toldPathOf({ context, session });
|
|
69632
|
-
await
|
|
69633
|
-
await
|
|
69630
|
+
await mkdir13(dirname13(path), { recursive: true, mode: 448 });
|
|
69631
|
+
await writeFile13(path, String(context.nowMs()), { mode: 384 });
|
|
69634
69632
|
}
|
|
69635
69633
|
async function reloadTipOnce({
|
|
69636
69634
|
context,
|
|
@@ -69638,7 +69636,7 @@ async function reloadTipOnce({
|
|
|
69638
69636
|
}) {
|
|
69639
69637
|
if (!session || !monitorsRunHere({ context })) return void 0;
|
|
69640
69638
|
if (!await pluginRegistered({ context })) return void 0;
|
|
69641
|
-
const told = await
|
|
69639
|
+
const told = await readFile12(toldPathOf({ context, session }), "utf8").then(
|
|
69642
69640
|
() => true,
|
|
69643
69641
|
() => false
|
|
69644
69642
|
);
|
|
@@ -69704,9 +69702,9 @@ async function installHooks({
|
|
|
69704
69702
|
directory,
|
|
69705
69703
|
profile
|
|
69706
69704
|
}) {
|
|
69707
|
-
const folder =
|
|
69708
|
-
const path =
|
|
69709
|
-
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(
|
|
69710
69708
|
(text2) => JSON.parse(text2),
|
|
69711
69709
|
() => ({})
|
|
69712
69710
|
);
|
|
@@ -69717,8 +69715,8 @@ async function installHooks({
|
|
|
69717
69715
|
waitCommand: command("wait"),
|
|
69718
69716
|
preToolCommand: command("pre-tool")
|
|
69719
69717
|
});
|
|
69720
|
-
await
|
|
69721
|
-
await
|
|
69718
|
+
await mkdir14(folder, { recursive: true });
|
|
69719
|
+
await writeFile14(path, `${JSON.stringify(settings2, null, 2)}
|
|
69722
69720
|
`);
|
|
69723
69721
|
return path;
|
|
69724
69722
|
}
|
|
@@ -69907,7 +69905,7 @@ async function reportTranscript({
|
|
|
69907
69905
|
input: input2
|
|
69908
69906
|
}) {
|
|
69909
69907
|
if (!input2.transcript_path || !input2.session_id) return;
|
|
69910
|
-
const lines = (await
|
|
69908
|
+
const lines = (await readFile13(input2.transcript_path, "utf8")).split("\n");
|
|
69911
69909
|
const context = readTranscript({ lines });
|
|
69912
69910
|
await client.post("/api/agents/me/activity", {
|
|
69913
69911
|
sessionId: input2.session_id,
|
|
@@ -69940,7 +69938,7 @@ async function handOver({ context, args }) {
|
|
|
69940
69938
|
const kept = await dueFromSpool({
|
|
69941
69939
|
context,
|
|
69942
69940
|
profile: agent2,
|
|
69943
|
-
seen: () => input2.transcript_path ?
|
|
69941
|
+
seen: () => input2.transcript_path ? readFile13(input2.transcript_path, "utf8") : Promise.resolve(""),
|
|
69944
69942
|
pushedToo: false
|
|
69945
69943
|
});
|
|
69946
69944
|
const claim3 = forSession({ client, session });
|
|
@@ -69974,8 +69972,8 @@ async function addSessionStartWaiter({ context, args }) {
|
|
|
69974
69972
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
|
|
69975
69973
|
const profile = flagText({ args, name: "profile" });
|
|
69976
69974
|
if (!directory || !profile) return;
|
|
69977
|
-
const path =
|
|
69978
|
-
const settings2 = await
|
|
69975
|
+
const path = join14(directory, ".claude", "settings.local.json");
|
|
69976
|
+
const settings2 = await readFile13(path, "utf8").then(
|
|
69979
69977
|
(text2) => JSON.parse(text2),
|
|
69980
69978
|
() => void 0
|
|
69981
69979
|
);
|
|
@@ -69984,7 +69982,7 @@ async function addSessionStartWaiter({ context, args }) {
|
|
|
69984
69982
|
}
|
|
69985
69983
|
async function refreshPlugin({ context }) {
|
|
69986
69984
|
if (await pluginIsCurrent({ context })) return;
|
|
69987
|
-
const logPath =
|
|
69985
|
+
const logPath = join14(pluginFolderOf({ context }), "install.log");
|
|
69988
69986
|
context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
|
|
69989
69987
|
}
|
|
69990
69988
|
async function stopHook({ context, args }) {
|
|
@@ -70002,7 +70000,7 @@ async function stopHook({ context, args }) {
|
|
|
70002
70000
|
}
|
|
70003
70001
|
|
|
70004
70002
|
// src/services/agent-manage-commands.service.ts
|
|
70005
|
-
import { readFile as
|
|
70003
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
70006
70004
|
import { extname, resolve as resolve5 } from "node:path";
|
|
70007
70005
|
|
|
70008
70006
|
// src/rules/login-format.rules.ts
|
|
@@ -70131,7 +70129,7 @@ async function avatarOf({
|
|
|
70131
70129
|
}) {
|
|
70132
70130
|
const path = flagText({ args, name: "avatar" });
|
|
70133
70131
|
if (!path) return void 0;
|
|
70134
|
-
const bytes = await
|
|
70132
|
+
const bytes = await readFile14(resolve5(context.cwd, path)).catch(() => {
|
|
70135
70133
|
throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
|
|
70136
70134
|
});
|
|
70137
70135
|
const uploaded = await client.post("/api/agents/avatars", {
|
|
@@ -70821,8 +70819,8 @@ async function requestAgent({ context, args }) {
|
|
|
70821
70819
|
}
|
|
70822
70820
|
|
|
70823
70821
|
// src/services/app-commands.service.ts
|
|
70824
|
-
import { mkdir as
|
|
70825
|
-
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";
|
|
70826
70824
|
|
|
70827
70825
|
// ../../modules/app/contract/src/app.connections.ts
|
|
70828
70826
|
var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
@@ -73213,9 +73211,9 @@ async function appPinsCommand({
|
|
|
73213
73211
|
|
|
73214
73212
|
// src/services/app-script-check.service.ts
|
|
73215
73213
|
import { execFile } from "node:child_process";
|
|
73216
|
-
import { mkdtemp, rm as rm8, writeFile as
|
|
73214
|
+
import { mkdtemp, rm as rm8, writeFile as writeFile15 } from "node:fs/promises";
|
|
73217
73215
|
import { tmpdir } from "node:os";
|
|
73218
|
-
import { join as
|
|
73216
|
+
import { join as join15 } from "node:path";
|
|
73219
73217
|
import { promisify } from "node:util";
|
|
73220
73218
|
var run2 = promisify(execFile);
|
|
73221
73219
|
var MODULE_SYNTAX = /^\s*(import|export)\s/m;
|
|
@@ -73244,12 +73242,12 @@ async function scriptErrorsOf({
|
|
|
73244
73242
|
const unknown2 = unknownCollectionsOf({ files: files2, collections });
|
|
73245
73243
|
const scripts = files2.flatMap(scriptsOf);
|
|
73246
73244
|
if (scripts.length === 0) return unknown2;
|
|
73247
|
-
const dir = await mkdtemp(
|
|
73245
|
+
const dir = await mkdtemp(join15(tmpdir(), "laze-app-check-"));
|
|
73248
73246
|
try {
|
|
73249
73247
|
const errors = await Promise.all(
|
|
73250
73248
|
scripts.map(async (script, index) => {
|
|
73251
|
-
const file3 =
|
|
73252
|
-
await
|
|
73249
|
+
const file3 = join15(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
|
|
73250
|
+
await writeFile15(file3, script.code);
|
|
73253
73251
|
try {
|
|
73254
73252
|
await run2(process.execPath, ["--check", file3]);
|
|
73255
73253
|
return null;
|
|
@@ -73398,7 +73396,7 @@ async function turnTokenOf({
|
|
|
73398
73396
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
73399
73397
|
if (pinned) return pinned;
|
|
73400
73398
|
if (env.LAZE_TURN_FILE) {
|
|
73401
|
-
return
|
|
73399
|
+
return readFile15(env.LAZE_TURN_FILE, "utf8").then(
|
|
73402
73400
|
(text2) => text2.trim(),
|
|
73403
73401
|
() => ""
|
|
73404
73402
|
);
|
|
@@ -73424,7 +73422,7 @@ function folderOf({ context, word: word3 }) {
|
|
|
73424
73422
|
return resolve6(context.cwd, word3 ?? ".");
|
|
73425
73423
|
}
|
|
73426
73424
|
async function readManifest(folder) {
|
|
73427
|
-
const text2 = await
|
|
73425
|
+
const text2 = await readFile15(join16(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
73428
73426
|
if (text2 === void 0) return void 0;
|
|
73429
73427
|
const parsed = appManifestSchema.safeParse(JSON.parse(text2));
|
|
73430
73428
|
if (!parsed.success) {
|
|
@@ -73459,7 +73457,7 @@ async function jsonFlag({
|
|
|
73459
73457
|
}) {
|
|
73460
73458
|
const raw = flagText({ args, name: name2 });
|
|
73461
73459
|
if (!raw) return void 0;
|
|
73462
|
-
const text2 = raw.startsWith("@") ? await
|
|
73460
|
+
const text2 = raw.startsWith("@") ? await readFile15(resolve6(context.cwd, raw.slice(1)), "utf8") : raw;
|
|
73463
73461
|
try {
|
|
73464
73462
|
return JSON.parse(text2);
|
|
73465
73463
|
} catch {
|
|
@@ -73472,7 +73470,7 @@ async function listFiles(folder) {
|
|
|
73472
73470
|
while (pending.length > 0 && found.length <= MAX_FILES) {
|
|
73473
73471
|
const current2 = pending.pop() ?? folder;
|
|
73474
73472
|
for (const entry of await readdir5(current2, { withFileTypes: true })) {
|
|
73475
|
-
const path =
|
|
73473
|
+
const path = join16(current2, entry.name);
|
|
73476
73474
|
const rel = relative3(folder, path).split(sep2).join("/");
|
|
73477
73475
|
if (isSkippedPath({ path: rel })) continue;
|
|
73478
73476
|
if (entry.isDirectory()) pending.push(path);
|
|
@@ -73513,11 +73511,11 @@ var appCreate = async ({ context, args }) => {
|
|
|
73513
73511
|
...visibility ? { visibility } : {}
|
|
73514
73512
|
});
|
|
73515
73513
|
const folder = resolve6(context.cwd, flagText({ args, name: "dir", fallback: app2.slug }));
|
|
73516
|
-
await
|
|
73514
|
+
await mkdir15(folder, { recursive: true });
|
|
73517
73515
|
const files2 = template ? templateFiles({ template, name: name2 }) : {};
|
|
73518
73516
|
for (const [path, content] of Object.entries(files2)) {
|
|
73519
|
-
await
|
|
73520
|
-
await
|
|
73517
|
+
await mkdir15(dirname14(join16(folder, path)), { recursive: true });
|
|
73518
|
+
await writeFile16(join16(folder, path), content);
|
|
73521
73519
|
}
|
|
73522
73520
|
const manifest = {
|
|
73523
73521
|
app: { id: app2.id, name: app2.name, slug: app2.slug },
|
|
@@ -73525,7 +73523,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
73525
73523
|
views: template?.views ? [...template.views] : [],
|
|
73526
73524
|
seed: template ? { ...template.seed } : {}
|
|
73527
73525
|
};
|
|
73528
|
-
await
|
|
73526
|
+
await writeFile16(join16(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
73529
73527
|
`);
|
|
73530
73528
|
print5({
|
|
73531
73529
|
context,
|
|
@@ -73562,7 +73560,7 @@ var appPush = async ({ context, args }) => {
|
|
|
73562
73560
|
paths.map(
|
|
73563
73561
|
async (path) => buildFileOf({
|
|
73564
73562
|
path: relative3(folder, path).split(sep2).join("/"),
|
|
73565
|
-
bytes: await
|
|
73563
|
+
bytes: await readFile15(path)
|
|
73566
73564
|
})
|
|
73567
73565
|
)
|
|
73568
73566
|
);
|
|
@@ -73937,7 +73935,7 @@ var appExport = async ({ context, args }) => {
|
|
|
73937
73935
|
const out = flagText({ args, name: "out" });
|
|
73938
73936
|
if (!out) return context.out(exported.body);
|
|
73939
73937
|
const target = resolve6(context.cwd, out);
|
|
73940
|
-
await
|
|
73938
|
+
await writeFile16(target, exported.body);
|
|
73941
73939
|
context.out(`Wrote ${exported.rows} records to ${relative3(context.cwd, target)}
|
|
73942
73940
|
`);
|
|
73943
73941
|
};
|
|
@@ -73945,7 +73943,7 @@ var appImport = async ({ context, args }) => {
|
|
|
73945
73943
|
const words = args.words.slice(2);
|
|
73946
73944
|
const [named, collection, file3] = words.length >= 3 ? words : [void 0, ...words];
|
|
73947
73945
|
if (!collection || !file3) throw new CliUsageError(USAGE5);
|
|
73948
|
-
const csv = await
|
|
73946
|
+
const csv = await readFile15(resolve6(context.cwd, file3), "utf8").catch(() => {
|
|
73949
73947
|
throw new CliUsageError(`Cannot read ${file3}`);
|
|
73950
73948
|
});
|
|
73951
73949
|
const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
|
|
@@ -73964,7 +73962,7 @@ var appImport = async ({ context, args }) => {
|
|
|
73964
73962
|
});
|
|
73965
73963
|
const refusedOut = flagText({ args, name: "refused" });
|
|
73966
73964
|
if (refusedOut && result.refusedCsv) {
|
|
73967
|
-
await
|
|
73965
|
+
await writeFile16(resolve6(context.cwd, refusedOut), result.refusedCsv);
|
|
73968
73966
|
}
|
|
73969
73967
|
const fitting = result.rows - result.refused.length;
|
|
73970
73968
|
const skipped = result.refused.slice(0, 20).map((row) => ` line ${row.line}: ${row.reason}
|
|
@@ -74511,8 +74509,8 @@ async function billing({ context, args }) {
|
|
|
74511
74509
|
|
|
74512
74510
|
// src/services/browser-commands.service.ts
|
|
74513
74511
|
import { randomBytes } from "node:crypto";
|
|
74514
|
-
import { mkdir as
|
|
74515
|
-
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";
|
|
74516
74514
|
|
|
74517
74515
|
// src/services/browser-tab-commands.service.ts
|
|
74518
74516
|
var BROWSER_TAB_PATHS = {
|
|
@@ -75058,7 +75056,7 @@ async function turnTokenOf2({ context }) {
|
|
|
75058
75056
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
75059
75057
|
if (pinned) return pinned;
|
|
75060
75058
|
if (!env.LAZE_TURN_FILE) return "";
|
|
75061
|
-
return
|
|
75059
|
+
return readFile16(env.LAZE_TURN_FILE, "utf8").then(
|
|
75062
75060
|
(text2) => text2.trim(),
|
|
75063
75061
|
() => ""
|
|
75064
75062
|
);
|
|
@@ -75132,7 +75130,7 @@ async function cdp({ context, args }) {
|
|
|
75132
75130
|
}
|
|
75133
75131
|
function bridgeStatePath({ context, machine: machine2 }) {
|
|
75134
75132
|
const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
75135
|
-
return
|
|
75133
|
+
return join17(dirname15(context.environment.configPath), "bridges", `${safe}.json`);
|
|
75136
75134
|
}
|
|
75137
75135
|
async function bridgePort({
|
|
75138
75136
|
context,
|
|
@@ -75140,7 +75138,7 @@ async function bridgePort({
|
|
|
75140
75138
|
access
|
|
75141
75139
|
}) {
|
|
75142
75140
|
const path = bridgeStatePath({ context, machine: machine2 });
|
|
75143
|
-
const live = await
|
|
75141
|
+
const live = await readFile16(path, "utf8").then(
|
|
75144
75142
|
(text2) => JSON.parse(text2),
|
|
75145
75143
|
() => void 0
|
|
75146
75144
|
);
|
|
@@ -75153,8 +75151,8 @@ async function bridgePort({
|
|
|
75153
75151
|
key,
|
|
75154
75152
|
...target
|
|
75155
75153
|
});
|
|
75156
|
-
await
|
|
75157
|
-
await
|
|
75154
|
+
await mkdir16(dirname15(path), { recursive: true, mode: 448 });
|
|
75155
|
+
await writeFile17(path, JSON.stringify({ port, key }), { mode: 384 });
|
|
75158
75156
|
return port;
|
|
75159
75157
|
}
|
|
75160
75158
|
async function bridge({ context }) {
|
|
@@ -75798,7 +75796,7 @@ async function channelSettings({ context, args }) {
|
|
|
75798
75796
|
}
|
|
75799
75797
|
|
|
75800
75798
|
// src/services/chat-actions-commands.service.ts
|
|
75801
|
-
import { readFile as
|
|
75799
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
75802
75800
|
import { basename as basename2, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve7 } from "node:path";
|
|
75803
75801
|
|
|
75804
75802
|
// src/services/file-upload.service.ts
|
|
@@ -76103,7 +76101,7 @@ function uploadNameOf({ cwd, path }) {
|
|
|
76103
76101
|
}
|
|
76104
76102
|
var fileUpload = async ({ context, args, client }) => {
|
|
76105
76103
|
const path = resolve7(context.cwd, wordAt(args, 3));
|
|
76106
|
-
const bytes = new Uint8Array(await
|
|
76104
|
+
const bytes = new Uint8Array(await readFile17(path));
|
|
76107
76105
|
const answer4 = await uploadFile({
|
|
76108
76106
|
context,
|
|
76109
76107
|
client,
|
|
@@ -76268,7 +76266,7 @@ async function chatActions({
|
|
|
76268
76266
|
}
|
|
76269
76267
|
|
|
76270
76268
|
// src/services/claude-monitor.service.ts
|
|
76271
|
-
import { readFile as
|
|
76269
|
+
import { readFile as readFile18, rm as rm9 } from "node:fs/promises";
|
|
76272
76270
|
var MONITOR_IDLE_MS = 3e4;
|
|
76273
76271
|
var MONITOR_OUTRANKED_MS = 3e3;
|
|
76274
76272
|
async function deliverOnce({
|
|
@@ -76357,7 +76355,7 @@ async function monitorSessionOf({
|
|
|
76357
76355
|
const fromEnv = sessionOf({ context, harness: "claude-code", sessionId });
|
|
76358
76356
|
if (fromEnv || !claudePid) return fromEnv;
|
|
76359
76357
|
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
76360
|
-
return
|
|
76358
|
+
return readFile18(path, "utf8").then(
|
|
76361
76359
|
(text2) => JSON.parse(text2),
|
|
76362
76360
|
() => void 0
|
|
76363
76361
|
);
|
|
@@ -77844,10 +77842,10 @@ async function computer({ context, args }) {
|
|
|
77844
77842
|
}
|
|
77845
77843
|
|
|
77846
77844
|
// src/services/connect-commands.service.ts
|
|
77847
|
-
import { readFile as
|
|
77845
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
77848
77846
|
|
|
77849
77847
|
// src/services/mcp-gateway.service.ts
|
|
77850
|
-
import { readFile as
|
|
77848
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
77851
77849
|
import { createInterface as createInterface3 } from "node:readline";
|
|
77852
77850
|
var TURN_HEADER = "x-laze-turn";
|
|
77853
77851
|
function serveMcpGateway({
|
|
@@ -77890,7 +77888,7 @@ async function relayMcpLines({
|
|
|
77890
77888
|
const github3 = env.LAZE_GITHUB_CONNECTION;
|
|
77891
77889
|
const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
|
|
77892
77890
|
const turnFile = env.LAZE_TURN_FILE;
|
|
77893
|
-
const readTurn = () =>
|
|
77891
|
+
const readTurn = () => readFile19(turnFile, "utf8").then(
|
|
77894
77892
|
(text2) => text2.trim(),
|
|
77895
77893
|
() => ""
|
|
77896
77894
|
);
|
|
@@ -77980,7 +77978,7 @@ async function turnOf({ context }) {
|
|
|
77980
77978
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
77981
77979
|
if (pinned) return pinned;
|
|
77982
77980
|
const file3 = env.LAZE_TURN_FILE;
|
|
77983
|
-
const turn = file3 ? await
|
|
77981
|
+
const turn = file3 ? await readFile20(file3, "utf8").then(
|
|
77984
77982
|
(text2) => text2.trim(),
|
|
77985
77983
|
() => ""
|
|
77986
77984
|
) : "";
|
|
@@ -78038,11 +78036,11 @@ async function connect({
|
|
|
78038
78036
|
}
|
|
78039
78037
|
|
|
78040
78038
|
// src/services/connector-commands.service.ts
|
|
78041
|
-
import { readFile as
|
|
78039
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
78042
78040
|
import { resolve as resolve8 } from "node:path";
|
|
78043
78041
|
|
|
78044
78042
|
// src/services/vault-keychain-commands.service.ts
|
|
78045
|
-
import { readFile as
|
|
78043
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
78046
78044
|
|
|
78047
78045
|
// src/rules/vault-input.rules.ts
|
|
78048
78046
|
function secondsOf(text2) {
|
|
@@ -78353,7 +78351,7 @@ async function secretText({ context, args }) {
|
|
|
78353
78351
|
);
|
|
78354
78352
|
}
|
|
78355
78353
|
const file3 = flagText({ args, name: "from-file" });
|
|
78356
|
-
const text2 = file3 ? await
|
|
78354
|
+
const text2 = file3 ? await readFile21(file3, "utf8") : await context.readStdin();
|
|
78357
78355
|
const trimmed = text2.replace(/\r?\n$/, "");
|
|
78358
78356
|
if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
|
|
78359
78357
|
return trimmed;
|
|
@@ -78551,7 +78549,7 @@ async function keyText({ context, args }) {
|
|
|
78551
78549
|
throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
|
|
78552
78550
|
}
|
|
78553
78551
|
const file3 = flagText({ args, name: "from-file" });
|
|
78554
|
-
const text2 = file3 ? await
|
|
78552
|
+
const text2 = file3 ? await readFile22(resolve8(context.cwd, file3), "utf8") : await context.readStdin();
|
|
78555
78553
|
const trimmed = text2.trim();
|
|
78556
78554
|
if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
|
|
78557
78555
|
return trimmed;
|
|
@@ -78937,8 +78935,8 @@ var DOMAINS_USAGE = `Usage:
|
|
|
78937
78935
|
var printJson4 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
|
|
78938
78936
|
`);
|
|
78939
78937
|
function printDomain(context, row) {
|
|
78940
|
-
const
|
|
78941
|
-
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" : ""}
|
|
78942
78940
|
`);
|
|
78943
78941
|
}
|
|
78944
78942
|
async function list4({ context, args }) {
|
|
@@ -78970,7 +78968,7 @@ async function domains({ context, args }) {
|
|
|
78970
78968
|
}
|
|
78971
78969
|
|
|
78972
78970
|
// src/services/feed-commands.service.ts
|
|
78973
|
-
import { readFile as
|
|
78971
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
78974
78972
|
import { resolve as resolve10 } from "node:path";
|
|
78975
78973
|
|
|
78976
78974
|
// src/rules/feed-input.rules.ts
|
|
@@ -79095,7 +79093,7 @@ function feedFlagsOf({ args }) {
|
|
|
79095
79093
|
}
|
|
79096
79094
|
|
|
79097
79095
|
// src/services/feed-files.service.ts
|
|
79098
|
-
import { readFile as
|
|
79096
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
79099
79097
|
import { basename as basename3, resolve as resolve9 } from "node:path";
|
|
79100
79098
|
|
|
79101
79099
|
// ../../modules/feed/contract/src/feed.ts
|
|
@@ -79563,6 +79561,7 @@ var feedTrpc = defineTrpcContract("feed").query("channelItems").withInput(extern
|
|
|
79563
79561
|
var feedUi = uiTokens("feed");
|
|
79564
79562
|
var FeedNavSlot = feedUi.component("nav");
|
|
79565
79563
|
var FeedChannelCardSlot = feedUi.component("channel-card");
|
|
79564
|
+
var FeedSearchSlot = feedUi.component("search");
|
|
79566
79565
|
|
|
79567
79566
|
// ../../modules/feed/contract/src/feed.events.ts
|
|
79568
79567
|
var byKind = external_exports.enum(["agent", "person", "system"]);
|
|
@@ -79688,7 +79687,7 @@ async function local({ context, path }) {
|
|
|
79688
79687
|
return {
|
|
79689
79688
|
fileName,
|
|
79690
79689
|
contentType: contentTypeOf(fileName),
|
|
79691
|
-
bytes: new Uint8Array(await
|
|
79690
|
+
bytes: new Uint8Array(await readFile23(full))
|
|
79692
79691
|
};
|
|
79693
79692
|
}
|
|
79694
79693
|
async function directWith({ client, to }) {
|
|
@@ -79766,7 +79765,7 @@ async function bodyOf2({
|
|
|
79766
79765
|
flags: flags2
|
|
79767
79766
|
}) {
|
|
79768
79767
|
const body = { ...flags2.fields };
|
|
79769
|
-
const read3 = (source) => "file" in source ?
|
|
79768
|
+
const read3 = (source) => "file" in source ? readFile24(resolve10(context.cwd, source.file), "utf8") : source.text;
|
|
79770
79769
|
for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read3(source);
|
|
79771
79770
|
if (flags2.rich) {
|
|
79772
79771
|
const text2 = await read3(flags2.rich.source);
|
|
@@ -79928,7 +79927,7 @@ async function textFlag({
|
|
|
79928
79927
|
}) {
|
|
79929
79928
|
const value = flagText({ args, name: name2 });
|
|
79930
79929
|
if (!value.startsWith("@")) return value;
|
|
79931
|
-
return
|
|
79930
|
+
return readFile24(resolve10(context.cwd, value.slice(1)), "utf8");
|
|
79932
79931
|
}
|
|
79933
79932
|
async function feedList({ context, args }) {
|
|
79934
79933
|
const { client } = await signedIn({ context, args });
|
|
@@ -80038,7 +80037,7 @@ async function feed({ context, args }) {
|
|
|
80038
80037
|
}
|
|
80039
80038
|
|
|
80040
80039
|
// src/services/github-commands.service.ts
|
|
80041
|
-
import { readFile as
|
|
80040
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
80042
80041
|
|
|
80043
80042
|
// src/rules/github-signature.rules.ts
|
|
80044
80043
|
var TURN_SEPARATOR = "~";
|
|
@@ -80108,7 +80107,7 @@ var REAL_GH = "/usr/bin/gh";
|
|
|
80108
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>`.";
|
|
80109
80108
|
async function turnFileToken({ env }) {
|
|
80110
80109
|
if (!env.LAZE_TURN_FILE) return "";
|
|
80111
|
-
return
|
|
80110
|
+
return readFile25(env.LAZE_TURN_FILE, "utf8").then(
|
|
80112
80111
|
(text2) => text2.trim(),
|
|
80113
80112
|
() => ""
|
|
80114
80113
|
);
|
|
@@ -80142,7 +80141,7 @@ async function githubGh({
|
|
|
80142
80141
|
args: args.rest,
|
|
80143
80142
|
agentName: profile.name ?? "An agent",
|
|
80144
80143
|
threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
|
|
80145
|
-
readBodyFile: (path) => path === "-" ? context.readStdin() :
|
|
80144
|
+
readBodyFile: (path) => path === "-" ? context.readStdin() : readFile25(path, "utf8")
|
|
80146
80145
|
});
|
|
80147
80146
|
return context.runCommand({
|
|
80148
80147
|
command: [REAL_GH, ...ghArgs],
|
|
@@ -80241,7 +80240,7 @@ async function setAgentGithub({
|
|
|
80241
80240
|
}
|
|
80242
80241
|
|
|
80243
80242
|
// src/services/history-commands.service.ts
|
|
80244
|
-
import { readFile as
|
|
80243
|
+
import { readFile as readFile26 } from "node:fs/promises";
|
|
80245
80244
|
|
|
80246
80245
|
// src/rules/history-format.rules.ts
|
|
80247
80246
|
function timeOf2(iso) {
|
|
@@ -80337,7 +80336,7 @@ async function turnTokenOf3({ context }) {
|
|
|
80337
80336
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
80338
80337
|
if (pinned) return pinned;
|
|
80339
80338
|
if (!env.LAZE_TURN_FILE) return "";
|
|
80340
|
-
return
|
|
80339
|
+
return readFile26(env.LAZE_TURN_FILE, "utf8").then(
|
|
80341
80340
|
(text2) => text2.trim(),
|
|
80342
80341
|
() => ""
|
|
80343
80342
|
);
|
|
@@ -80529,19 +80528,19 @@ async function ip({ context, args }) {
|
|
|
80529
80528
|
}
|
|
80530
80529
|
|
|
80531
80530
|
// src/services/join-commands.service.ts
|
|
80532
|
-
import { mkdir as
|
|
80533
|
-
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";
|
|
80534
80533
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
80535
80534
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
80536
80535
|
function pendingPathOf({ context }) {
|
|
80537
|
-
return
|
|
80536
|
+
return join18(dirname16(context.environment.configPath), "join", "pending.json");
|
|
80538
80537
|
}
|
|
80539
80538
|
async function readPending({
|
|
80540
80539
|
context,
|
|
80541
80540
|
url: url2,
|
|
80542
80541
|
args
|
|
80543
80542
|
}) {
|
|
80544
|
-
const pending = await
|
|
80543
|
+
const pending = await readFile27(pendingPathOf({ context }), "utf8").then(
|
|
80545
80544
|
(text2) => JSON.parse(text2),
|
|
80546
80545
|
() => void 0
|
|
80547
80546
|
);
|
|
@@ -80551,9 +80550,9 @@ async function readPending({
|
|
|
80551
80550
|
}
|
|
80552
80551
|
async function keepPending({ context, pending }) {
|
|
80553
80552
|
const path = pendingPathOf({ context });
|
|
80554
|
-
await
|
|
80553
|
+
await mkdir17(dirname16(path), { recursive: true, mode: 448 });
|
|
80555
80554
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
80556
|
-
await
|
|
80555
|
+
await writeFile18(temporary, JSON.stringify(pending), { mode: 384 });
|
|
80557
80556
|
await rename5(temporary, path);
|
|
80558
80557
|
}
|
|
80559
80558
|
async function dropPending({ context }) {
|
|
@@ -80871,9 +80870,9 @@ function machineAccessCommand(name2) {
|
|
|
80871
80870
|
|
|
80872
80871
|
// src/services/vault-commands.service.ts
|
|
80873
80872
|
import { createHash as createHash2 } from "node:crypto";
|
|
80874
|
-
import { mkdir as
|
|
80873
|
+
import { mkdir as mkdir18, readFile as readFile28, rm as rm11, writeFile as writeFile19 } from "node:fs/promises";
|
|
80875
80874
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
80876
|
-
import { dirname as
|
|
80875
|
+
import { dirname as dirname17, join as join19 } from "node:path";
|
|
80877
80876
|
var USAGE10 = `Usage: laze vault run <connection> --reason "<one plain sentence>" [--wait <s>] -- <command> [args...]
|
|
80878
80877
|
Runs the command with the connection's values in its environment, on a Laze agent's computer
|
|
80879
80878
|
or on a machine it runs on.`;
|
|
@@ -80912,7 +80911,7 @@ async function turnTokenOf4({
|
|
|
80912
80911
|
if (pinned) return pinned;
|
|
80913
80912
|
if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
80914
80913
|
try {
|
|
80915
|
-
return (await
|
|
80914
|
+
return (await readFile28(turnFile, "utf8")).trim();
|
|
80916
80915
|
} catch {
|
|
80917
80916
|
throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
80918
80917
|
}
|
|
@@ -80922,11 +80921,11 @@ function runKeyPathOf({
|
|
|
80922
80921
|
connection
|
|
80923
80922
|
}) {
|
|
80924
80923
|
const name2 = createHash2("sha256").update(connection).digest("hex");
|
|
80925
|
-
const base = turnFile ?
|
|
80926
|
-
return
|
|
80924
|
+
const base = turnFile ? dirname17(turnFile) : join19(tmpdir2(), "laze-vault");
|
|
80925
|
+
return join19(base, "vault-run-keys", `${name2}.json`);
|
|
80927
80926
|
}
|
|
80928
80927
|
async function runKeyAt({ path }) {
|
|
80929
|
-
const saved3 = await
|
|
80928
|
+
const saved3 = await readFile28(path, "utf8").then(
|
|
80930
80929
|
(text2) => JSON.parse(text2),
|
|
80931
80930
|
() => void 0
|
|
80932
80931
|
);
|
|
@@ -80936,8 +80935,8 @@ async function runKeyAt({ path }) {
|
|
|
80936
80935
|
}
|
|
80937
80936
|
const fresh = await generateEcdhKeys();
|
|
80938
80937
|
const jwk = await globalThis.crypto.subtle.exportKey("jwk", fresh.privateKey);
|
|
80939
|
-
await
|
|
80940
|
-
await
|
|
80938
|
+
await mkdir18(dirname17(path), { recursive: true, mode: 448 });
|
|
80939
|
+
await writeFile19(path, JSON.stringify({ publicKey: fresh.publicKey, privateKey: jwk }), {
|
|
80941
80940
|
mode: 384
|
|
80942
80941
|
});
|
|
80943
80942
|
return fresh;
|
|
@@ -81608,14 +81607,14 @@ async function serveMcp({
|
|
|
81608
81607
|
}
|
|
81609
81608
|
|
|
81610
81609
|
// src/services/mount-files.service.ts
|
|
81611
|
-
import { mkdir as
|
|
81612
|
-
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";
|
|
81613
81612
|
async function textArgument({
|
|
81614
81613
|
context,
|
|
81615
81614
|
value
|
|
81616
81615
|
}) {
|
|
81617
81616
|
if (value === "-") return context.readStdin();
|
|
81618
|
-
if (value.startsWith("@")) return
|
|
81617
|
+
if (value.startsWith("@")) return readFile29(resolve11(context.cwd, value.slice(1)), "utf8");
|
|
81619
81618
|
return value;
|
|
81620
81619
|
}
|
|
81621
81620
|
function turnChannel({ context, args }) {
|
|
@@ -81629,14 +81628,14 @@ async function writeMount({
|
|
|
81629
81628
|
}) {
|
|
81630
81629
|
const root = resolve11(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
81631
81630
|
await rm12(root, { recursive: true, force: true });
|
|
81632
|
-
await
|
|
81631
|
+
await mkdir19(root, { recursive: true });
|
|
81633
81632
|
for (const file3 of files2) {
|
|
81634
81633
|
const target = resolve11(root, file3.path);
|
|
81635
81634
|
const inside = relative5(root, target);
|
|
81636
81635
|
if (!inside || inside.startsWith(".."))
|
|
81637
81636
|
throw new Error(`Refusing to write outside ${root}: ${file3.path}`);
|
|
81638
|
-
await
|
|
81639
|
-
await
|
|
81637
|
+
await mkdir19(dirname18(target), { recursive: true });
|
|
81638
|
+
await writeFile20(target, file3.content);
|
|
81640
81639
|
}
|
|
81641
81640
|
return root;
|
|
81642
81641
|
}
|
|
@@ -82374,6 +82373,69 @@ function watchingRelease({
|
|
|
82374
82373
|
};
|
|
82375
82374
|
}
|
|
82376
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
|
+
|
|
82377
82439
|
// src/services/schedule-commands.service.ts
|
|
82378
82440
|
var USAGE15 = `Usage:
|
|
82379
82441
|
laze schedule add <name> --prompt <text> (--cron "<m h dom mon dow>" | --rrule "<RRULE>" | --at <local time>)
|
|
@@ -82513,8 +82575,8 @@ async function schedule({ context, args }) {
|
|
|
82513
82575
|
}
|
|
82514
82576
|
|
|
82515
82577
|
// src/services/skill-commands.service.ts
|
|
82516
|
-
import { readdir as readdir6, readFile as
|
|
82517
|
-
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";
|
|
82518
82580
|
var USAGE16 = `Usage:
|
|
82519
82581
|
laze skill list [--agent <agentId>]
|
|
82520
82582
|
laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
|
|
@@ -82535,8 +82597,8 @@ async function folderFiles({ root }) {
|
|
|
82535
82597
|
const files2 = [];
|
|
82536
82598
|
for (const entry of entries) {
|
|
82537
82599
|
if (!entry.isFile()) continue;
|
|
82538
|
-
const full =
|
|
82539
|
-
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") });
|
|
82540
82602
|
}
|
|
82541
82603
|
return files2.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
82542
82604
|
}
|
|
@@ -82634,7 +82696,7 @@ async function skillUpdate({ context, args }) {
|
|
|
82634
82696
|
if (!name2 || !newName && description === void 0 && !skillMdFile) {
|
|
82635
82697
|
throw new CliUsageError(USAGE16);
|
|
82636
82698
|
}
|
|
82637
|
-
const skillMd = skillMdFile ? await
|
|
82699
|
+
const skillMd = skillMdFile ? await readFile31(resolve12(context.cwd, skillMdFile), "utf8") : void 0;
|
|
82638
82700
|
const { client } = await signedIn({ context, args });
|
|
82639
82701
|
const updated = await client.post("/api/skills/update", {
|
|
82640
82702
|
name: name2,
|
|
@@ -82680,7 +82742,7 @@ async function skill({ context, args }) {
|
|
|
82680
82742
|
}
|
|
82681
82743
|
|
|
82682
82744
|
// src/services/slack-commands.service.ts
|
|
82683
|
-
import { readFile as
|
|
82745
|
+
import { readFile as readFile32 } from "node:fs/promises";
|
|
82684
82746
|
import { resolve as resolve13 } from "node:path";
|
|
82685
82747
|
var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
|
|
82686
82748
|
laze slack overview connected Slack workspaces, mirrors, your link
|
|
@@ -82728,7 +82790,7 @@ async function secretLines({ context, args }) {
|
|
|
82728
82790
|
throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
|
|
82729
82791
|
}
|
|
82730
82792
|
const file3 = flagText({ args, name: "from-file" });
|
|
82731
|
-
const text2 = file3 ? await
|
|
82793
|
+
const text2 = file3 ? await readFile32(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
|
|
82732
82794
|
return text2.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
82733
82795
|
}
|
|
82734
82796
|
async function secretsOf({
|
|
@@ -83032,7 +83094,7 @@ async function slack({
|
|
|
83032
83094
|
}
|
|
83033
83095
|
|
|
83034
83096
|
// src/services/sso-commands.service.ts
|
|
83035
|
-
import { readFile as
|
|
83097
|
+
import { readFile as readFile33 } from "node:fs/promises";
|
|
83036
83098
|
var SSO_USAGE = `Usage:
|
|
83037
83099
|
laze sso domains claimed domains and how each signs in (admins)
|
|
83038
83100
|
laze sso claim <domain> the TXT record that proves the domain
|
|
@@ -83119,7 +83181,7 @@ function refuseSecretFlags({ args }) {
|
|
|
83119
83181
|
}
|
|
83120
83182
|
async function clientSecretOf({ context, args }) {
|
|
83121
83183
|
const file3 = flagText({ args, name: "from-file" });
|
|
83122
|
-
const text2 = file3 ? await
|
|
83184
|
+
const text2 = file3 ? await readFile33(file3, "utf8") : await context.readStdin();
|
|
83123
83185
|
const secret = text2.trim();
|
|
83124
83186
|
if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
|
|
83125
83187
|
return secret;
|
|
@@ -83452,7 +83514,7 @@ async function vaultScrub({ context, args }) {
|
|
|
83452
83514
|
}
|
|
83453
83515
|
|
|
83454
83516
|
// src/services/whatsapp-business-commands.service.ts
|
|
83455
|
-
import { readFile as
|
|
83517
|
+
import { readFile as readFile34 } from "node:fs/promises";
|
|
83456
83518
|
import { resolve as resolve14 } from "node:path";
|
|
83457
83519
|
|
|
83458
83520
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
|
|
@@ -83872,7 +83934,7 @@ async function secretsOf2({ context, args }) {
|
|
|
83872
83934
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
83873
83935
|
if (fromConnection) return { fromConnection };
|
|
83874
83936
|
const file3 = flagText({ args, name: "from-file" });
|
|
83875
|
-
const text2 = file3 ? await
|
|
83937
|
+
const text2 = file3 ? await readFile34(resolve14(context.cwd, file3), "utf8") : await context.readStdin();
|
|
83876
83938
|
const lines = text2.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
83877
83939
|
if (lines.length !== 2) {
|
|
83878
83940
|
throw new CliUsageError(
|
|
@@ -84073,7 +84135,7 @@ async function whatsappBusiness({
|
|
|
84073
84135
|
}
|
|
84074
84136
|
|
|
84075
84137
|
// src/services/whatsapp-pairing-commands.service.ts
|
|
84076
|
-
import { writeFile as
|
|
84138
|
+
import { writeFile as writeFile21 } from "node:fs/promises";
|
|
84077
84139
|
import { resolve as resolve15 } from "node:path";
|
|
84078
84140
|
var WHATSAPP_PAIRING_USAGE = [
|
|
84079
84141
|
" laze whatsapp pair <machine> [--qr <file.svg>] link WhatsApp on your machine; scan the code (owner)",
|
|
@@ -84094,7 +84156,7 @@ function svgOf(dataUrl) {
|
|
|
84094
84156
|
}
|
|
84095
84157
|
async function report({ context, args, pairing: pairing2 }) {
|
|
84096
84158
|
const qrFile = pairing2.qrSvg ? resolve15(context.cwd, flagText({ args, name: "qr", fallback: "whatsapp-qr.svg" })) : null;
|
|
84097
|
-
if (qrFile && pairing2.qrSvg) await
|
|
84159
|
+
if (qrFile && pairing2.qrSvg) await writeFile21(qrFile, svgOf(pairing2.qrSvg), "utf8");
|
|
84098
84160
|
if (args.flags.json) return context.out(`${JSON.stringify({ ...pairing2, qrFile }, null, 2)}
|
|
84099
84161
|
`);
|
|
84100
84162
|
context.out(`${pairing2.pairingId} ${pairing2.state}
|
|
@@ -84453,7 +84515,7 @@ async function flags({ context, args }) {
|
|
|
84453
84515
|
}
|
|
84454
84516
|
|
|
84455
84517
|
// src/services/workspace-commands.service.ts
|
|
84456
|
-
import { readFile as
|
|
84518
|
+
import { readFile as readFile35 } from "node:fs/promises";
|
|
84457
84519
|
import { resolve as resolve16 } from "node:path";
|
|
84458
84520
|
var ROLE_NAMES2 = {
|
|
84459
84521
|
OWNER: "Owner",
|
|
@@ -84636,7 +84698,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
|
|
|
84636
84698
|
async function readLogo({ context, file: file3 }) {
|
|
84637
84699
|
let bytes;
|
|
84638
84700
|
try {
|
|
84639
|
-
bytes = new Uint8Array(await
|
|
84701
|
+
bytes = new Uint8Array(await readFile35(resolve16(context.cwd, file3)));
|
|
84640
84702
|
} catch {
|
|
84641
84703
|
throw new CliUsageError(`No file to read at ${file3}.`);
|
|
84642
84704
|
}
|
|
@@ -85144,6 +85206,7 @@ var COMMANDS3 = {
|
|
|
85144
85206
|
"hook wait": waitHook,
|
|
85145
85207
|
"hook pre-tool": preToolHook,
|
|
85146
85208
|
"hook monitor": monitorHook,
|
|
85209
|
+
"hook rush-wake": rushWakeHook,
|
|
85147
85210
|
plugin,
|
|
85148
85211
|
adopt: adoptCodex,
|
|
85149
85212
|
feed,
|
|
@@ -85297,8 +85360,8 @@ async function runCli({
|
|
|
85297
85360
|
// src/services/processes.service.ts
|
|
85298
85361
|
import { execFile as execFile2, spawn as spawn4 } from "node:child_process";
|
|
85299
85362
|
import { mkdirSync, openSync } from "node:fs";
|
|
85300
|
-
import { readFile as
|
|
85301
|
-
import { dirname as
|
|
85363
|
+
import { readFile as readFile36, readlink } from "node:fs/promises";
|
|
85364
|
+
import { dirname as dirname19 } from "node:path";
|
|
85302
85365
|
import { promisify as promisify2 } from "node:util";
|
|
85303
85366
|
var run3 = promisify2(execFile2);
|
|
85304
85367
|
function alive(pid) {
|
|
@@ -85311,14 +85374,14 @@ function alive(pid) {
|
|
|
85311
85374
|
}
|
|
85312
85375
|
}
|
|
85313
85376
|
async function argsOf(pid) {
|
|
85314
|
-
const raw = await
|
|
85377
|
+
const raw = await readFile36(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
|
|
85315
85378
|
if (raw) return raw.split("\0").filter(Boolean);
|
|
85316
85379
|
const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
|
|
85317
85380
|
const line = listed?.stdout.trim();
|
|
85318
85381
|
return line ? line.split(/\s+/) : void 0;
|
|
85319
85382
|
}
|
|
85320
85383
|
async function parentOf(pid) {
|
|
85321
|
-
const stat3 = await
|
|
85384
|
+
const stat3 = await readFile36(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
85322
85385
|
const fromStat = stat3 ? Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
|
|
85323
85386
|
if (fromStat > 0) return fromStat;
|
|
85324
85387
|
const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
|
|
@@ -85335,7 +85398,7 @@ async function cwdOf(pid) {
|
|
|
85335
85398
|
return line ? line.slice(1) : void 0;
|
|
85336
85399
|
}
|
|
85337
85400
|
function spawnDetached({ argv, logPath }) {
|
|
85338
|
-
mkdirSync(
|
|
85401
|
+
mkdirSync(dirname19(logPath), { recursive: true, mode: 448 });
|
|
85339
85402
|
const log = openSync(logPath, "a", 384);
|
|
85340
85403
|
const [program = "", ...rest] = argv;
|
|
85341
85404
|
const child = spawn4(program, rest, { detached: true, stdio: ["ignore", log, log] });
|