@lazehq/cli 0.1.133 → 0.1.134
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 +308 -234
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -19486,7 +19486,7 @@ var require_snapshot_utils = __commonJS({
|
|
|
19486
19486
|
var require_snapshot_recorder = __commonJS({
|
|
19487
19487
|
"../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
19488
19488
|
"use strict";
|
|
19489
|
-
var { writeFile: writeFile12, readFile:
|
|
19489
|
+
var { writeFile: writeFile12, readFile: readFile40, mkdir: mkdir14 } = __require("node:fs/promises");
|
|
19490
19490
|
var { dirname: dirname29, resolve: resolve27 } = __require("node:path");
|
|
19491
19491
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
19492
19492
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
@@ -19703,7 +19703,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19703
19703
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19704
19704
|
}
|
|
19705
19705
|
try {
|
|
19706
|
-
const data = await
|
|
19706
|
+
const data = await readFile40(resolve27(path), "utf8");
|
|
19707
19707
|
const parsed = JSON.parse(data);
|
|
19708
19708
|
if (Array.isArray(parsed)) {
|
|
19709
19709
|
this.#snapshots.clear();
|
|
@@ -20951,17 +20951,17 @@ var require_dns = __commonJS({
|
|
|
20951
20951
|
const timestamp = Date.now();
|
|
20952
20952
|
const records = { records: { 4: null, 6: null } };
|
|
20953
20953
|
let minTTL = this.#maxTTL;
|
|
20954
|
-
for (const
|
|
20955
|
-
|
|
20956
|
-
if (typeof
|
|
20957
|
-
|
|
20958
|
-
minTTL = Math.min(minTTL,
|
|
20954
|
+
for (const record5 of addresses) {
|
|
20955
|
+
record5.timestamp = timestamp;
|
|
20956
|
+
if (typeof record5.ttl === "number") {
|
|
20957
|
+
record5.ttl = Math.min(record5.ttl, this.#maxTTL);
|
|
20958
|
+
minTTL = Math.min(minTTL, record5.ttl);
|
|
20959
20959
|
} else {
|
|
20960
|
-
|
|
20960
|
+
record5.ttl = this.#maxTTL;
|
|
20961
20961
|
}
|
|
20962
|
-
const familyRecords = records.records[
|
|
20963
|
-
familyRecords.ips.push(
|
|
20964
|
-
records.records[
|
|
20962
|
+
const familyRecords = records.records[record5.family] ?? { ips: [] };
|
|
20963
|
+
familyRecords.ips.push(record5);
|
|
20964
|
+
records.records[record5.family] = familyRecords;
|
|
20965
20965
|
}
|
|
20966
20966
|
this.storage.set(origin.hostname, records, { ttl: minTTL });
|
|
20967
20967
|
}
|
|
@@ -31632,7 +31632,7 @@ ${captureLines}` : capture.stack;
|
|
|
31632
31632
|
});
|
|
31633
31633
|
|
|
31634
31634
|
// src/main.ts
|
|
31635
|
-
import { homedir as
|
|
31635
|
+
import { homedir as homedir6 } from "node:os";
|
|
31636
31636
|
import { stderr, stdin, stdout } from "node:process";
|
|
31637
31637
|
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
31638
31638
|
|
|
@@ -32569,10 +32569,10 @@ var JSONL_STRUCTURAL_KEYS = /* @__PURE__ */ new Set([
|
|
|
32569
32569
|
"originator",
|
|
32570
32570
|
"cli_version"
|
|
32571
32571
|
]);
|
|
32572
|
-
function recordSlotsOf(
|
|
32573
|
-
for (const [key, item] of Object.entries(
|
|
32572
|
+
function recordSlotsOf(record5, into) {
|
|
32573
|
+
for (const [key, item] of Object.entries(record5)) {
|
|
32574
32574
|
if (typeof item !== "string") slotsOf(item, into);
|
|
32575
|
-
else if (!JSONL_STRUCTURAL_KEYS.has(key)) into.push({ holder:
|
|
32575
|
+
else if (!JSONL_STRUCTURAL_KEYS.has(key)) into.push({ holder: record5, key });
|
|
32576
32576
|
}
|
|
32577
32577
|
}
|
|
32578
32578
|
function slotsOf(value, into) {
|
|
@@ -34718,10 +34718,10 @@ var queryTimeZoneIntlFormat = /* @__PURE__ */ memoize((upperNormId) => new RawDa
|
|
|
34718
34718
|
second: "numeric"
|
|
34719
34719
|
}));
|
|
34720
34720
|
function queryTimeZone(rawTimeZoneId) {
|
|
34721
|
-
const
|
|
34722
|
-
return queryTimeZoneRecord(
|
|
34721
|
+
const record5 = resolveTimeZoneRecord(rawTimeZoneId);
|
|
34722
|
+
return queryTimeZoneRecord(record5.id, record5);
|
|
34723
34723
|
}
|
|
34724
|
-
var queryTimeZoneRecord = /* @__PURE__ */ memoize((normTimeZoneId,
|
|
34724
|
+
var queryTimeZoneRecord = /* @__PURE__ */ memoize((normTimeZoneId, record5) => "named" === record5.kind ? new IntlTimeZone(normTimeZoneId, record5.m, record5.format) : new FixedTimeZone(normTimeZoneId, record5.m, "fixed" === record5.kind ? record5.X : 0));
|
|
34725
34725
|
var FixedTimeZone = class {
|
|
34726
34726
|
constructor(id8, compareKey, offsetNano) {
|
|
34727
34727
|
this.id = id8, this.m = compareKey, this.X = offsetNano;
|
|
@@ -36960,7 +36960,7 @@ function shadowedLinkLineOf({ shadow }) {
|
|
|
36960
36960
|
}
|
|
36961
36961
|
|
|
36962
36962
|
// src/rules/cli-version.rules.ts
|
|
36963
|
-
var STAMPED = "0.1.
|
|
36963
|
+
var STAMPED = "0.1.134";
|
|
36964
36964
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
36965
36965
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
36966
36966
|
}
|
|
@@ -54234,8 +54234,8 @@ function rewriteKeyNames(ctx) {
|
|
|
54234
54234
|
bySchema.set(entry2.schema, entry2);
|
|
54235
54235
|
}
|
|
54236
54236
|
const rewrites = /* @__PURE__ */ new Map();
|
|
54237
|
-
for (const
|
|
54238
|
-
const seen = ctx.seen.get(
|
|
54237
|
+
for (const record5 of pendingRecords.get(ctx) ?? []) {
|
|
54238
|
+
const seen = ctx.seen.get(record5);
|
|
54239
54239
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
54240
54240
|
if (!names || names === true || rewrites.has(names))
|
|
54241
54241
|
continue;
|
|
@@ -70745,6 +70745,8 @@ var harnessLoginEntrySchemaDefinition = external_exports.object({
|
|
|
70745
70745
|
checkedAt: external_exports.iso.datetime().nullable(),
|
|
70746
70746
|
/** The agents running on this login now. */
|
|
70747
70747
|
agentsOnIt: external_exports.number().int().nonnegative(),
|
|
70748
|
+
/** Their names, so two logins in use say which agents each one serves. */
|
|
70749
|
+
agentNames: external_exports.array(external_exports.string()).optional(),
|
|
70748
70750
|
/** `computer`: signed in on the person's own Laze computer, which keeps the token. */
|
|
70749
70751
|
source: external_exports.enum(["keychain", "computer"]).optional()
|
|
70750
70752
|
});
|
|
@@ -73648,9 +73650,9 @@ function apiErrorOf({ status: status11, text: text3 }) {
|
|
|
73648
73650
|
return errorOf({ status: status11, body });
|
|
73649
73651
|
}
|
|
73650
73652
|
function errorOf({ status: status11, body }) {
|
|
73651
|
-
const
|
|
73652
|
-
const nested = typeof
|
|
73653
|
-
const fallback = typeof
|
|
73653
|
+
const record5 = typeof body === "object" && body !== null ? body : {};
|
|
73654
|
+
const nested = typeof record5.error === "object" && record5.error !== null ? record5.error : record5;
|
|
73655
|
+
const fallback = typeof record5.error === "string" ? record5.error : `http_${status11}`;
|
|
73654
73656
|
const code4 = typeof nested.code === "string" ? nested.code : fallback;
|
|
73655
73657
|
const message2 = typeof nested.message === "string" ? nested.message : `Laze answered ${status11}`;
|
|
73656
73658
|
const meta3 = typeof nested.meta === "object" && nested.meta !== null ? nested.meta : void 0;
|
|
@@ -74154,8 +74156,8 @@ async function copyAgent({
|
|
|
74154
74156
|
}
|
|
74155
74157
|
|
|
74156
74158
|
// src/services/agent-commands.service.ts
|
|
74157
|
-
import { mkdir as mkdir6, readFile as
|
|
74158
|
-
import { join as
|
|
74159
|
+
import { mkdir as mkdir6, readFile as readFile13, writeFile as writeFile3 } from "node:fs/promises";
|
|
74160
|
+
import { join as join23, resolve as resolve4 } from "node:path";
|
|
74159
74161
|
|
|
74160
74162
|
// src/rules/link-format.rules.ts
|
|
74161
74163
|
function linkOf({ url: url2, base }) {
|
|
@@ -74337,8 +74339,23 @@ function parse3(line) {
|
|
|
74337
74339
|
return void 0;
|
|
74338
74340
|
}
|
|
74339
74341
|
}
|
|
74342
|
+
var STANDARD_WINDOW = 2e5;
|
|
74343
|
+
var LONG_WINDOW = 1e6;
|
|
74340
74344
|
function contextWindowOf({ model }) {
|
|
74341
|
-
return /\[1m\]|-1m\b/i.test(model) ?
|
|
74345
|
+
return /\[1m\]|-1m\b/i.test(model) ? LONG_WINDOW : STANDARD_WINDOW;
|
|
74346
|
+
}
|
|
74347
|
+
function windowOf({
|
|
74348
|
+
run: run4,
|
|
74349
|
+
model,
|
|
74350
|
+
largest,
|
|
74351
|
+
tokens
|
|
74352
|
+
}) {
|
|
74353
|
+
const named = run4.model ?? model;
|
|
74354
|
+
if (named === void 0 && largest <= STANDARD_WINDOW) return void 0;
|
|
74355
|
+
let window2 = named === void 0 ? STANDARD_WINDOW : contextWindowOf({ model: named });
|
|
74356
|
+
if (largest > STANDARD_WINDOW) window2 = LONG_WINDOW;
|
|
74357
|
+
if (run4.compactWindow) window2 = Math.min(window2, run4.compactWindow);
|
|
74358
|
+
return tokens !== void 0 && tokens > window2 ? void 0 : window2;
|
|
74342
74359
|
}
|
|
74343
74360
|
function compactionOf({
|
|
74344
74361
|
entry: entry2,
|
|
@@ -74364,9 +74381,13 @@ function usageOf({ entry: entry2 }) {
|
|
|
74364
74381
|
...typeof message2.model === "string" ? { model: message2.model } : {}
|
|
74365
74382
|
};
|
|
74366
74383
|
}
|
|
74367
|
-
function readTranscript({
|
|
74384
|
+
function readTranscript({
|
|
74385
|
+
lines: lines2,
|
|
74386
|
+
run: run4 = {}
|
|
74387
|
+
}) {
|
|
74368
74388
|
let contextTokens;
|
|
74369
|
-
let
|
|
74389
|
+
let model;
|
|
74390
|
+
let largest = 0;
|
|
74370
74391
|
const compactions = [];
|
|
74371
74392
|
for (const line of lines2) {
|
|
74372
74393
|
const entry2 = parse3(line);
|
|
@@ -74374,14 +74395,17 @@ function readTranscript({ lines: lines2 }) {
|
|
|
74374
74395
|
if (entry2.type === "system" && entry2.subtype === "compact_boundary") {
|
|
74375
74396
|
const compaction = compactionOf({ entry: entry2, index: compactions.length });
|
|
74376
74397
|
compactions.push(compaction);
|
|
74398
|
+
largest = Math.max(largest, compaction.tokensBefore ?? 0);
|
|
74377
74399
|
contextTokens = compaction.tokensAfter ?? contextTokens;
|
|
74378
74400
|
continue;
|
|
74379
74401
|
}
|
|
74380
74402
|
const usage2 = entry2.type === "assistant" ? usageOf({ entry: entry2 }) : void 0;
|
|
74381
74403
|
if (!usage2) continue;
|
|
74382
74404
|
contextTokens = usage2.tokens;
|
|
74383
|
-
|
|
74405
|
+
largest = Math.max(largest, usage2.tokens);
|
|
74406
|
+
if (usage2.model) model = usage2.model;
|
|
74384
74407
|
}
|
|
74408
|
+
const contextWindow = windowOf({ run: run4, model, largest, tokens: contextTokens });
|
|
74385
74409
|
return { contextTokens, contextWindow, compactions };
|
|
74386
74410
|
}
|
|
74387
74411
|
|
|
@@ -76949,8 +76973,54 @@ function channelLabelIn(channel) {
|
|
|
76949
76973
|
return `#${channel.name}`;
|
|
76950
76974
|
}
|
|
76951
76975
|
|
|
76976
|
+
// src/services/claude-run.service.ts
|
|
76977
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
76978
|
+
import { homedir as homedir3 } from "node:os";
|
|
76979
|
+
import { join as join12 } from "node:path";
|
|
76980
|
+
function record3(value) {
|
|
76981
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
76982
|
+
}
|
|
76983
|
+
async function settingsOf({ path }) {
|
|
76984
|
+
try {
|
|
76985
|
+
return record3(JSON.parse(await readFile9(path, "utf8")));
|
|
76986
|
+
} catch {
|
|
76987
|
+
return {};
|
|
76988
|
+
}
|
|
76989
|
+
}
|
|
76990
|
+
function windowOf2(value) {
|
|
76991
|
+
const tokens = Number(value);
|
|
76992
|
+
return Number.isInteger(tokens) && tokens > 0 ? tokens : void 0;
|
|
76993
|
+
}
|
|
76994
|
+
function modelFlagOf(args) {
|
|
76995
|
+
const at8 = args?.indexOf("--model") ?? -1;
|
|
76996
|
+
if (at8 >= 0) return args?.[at8 + 1];
|
|
76997
|
+
return args?.find((arg) => arg.startsWith("--model="))?.slice("--model=".length);
|
|
76998
|
+
}
|
|
76999
|
+
async function claudeRunOf({
|
|
77000
|
+
context,
|
|
77001
|
+
folder,
|
|
77002
|
+
claudePid
|
|
77003
|
+
}) {
|
|
77004
|
+
const env = context.environment.inherited;
|
|
77005
|
+
const user = env.CLAUDE_CONFIG_DIR || join12(env.HOME || homedir3(), ".claude");
|
|
77006
|
+
const files2 = await Promise.all(
|
|
77007
|
+
[
|
|
77008
|
+
join12(folder, ".claude", "settings.local.json"),
|
|
77009
|
+
join12(folder, ".claude", "settings.json"),
|
|
77010
|
+
join12(user, "settings.json")
|
|
77011
|
+
].map((path) => settingsOf({ path }))
|
|
77012
|
+
);
|
|
77013
|
+
const args = claudePid > 0 ? await context.processes.argsOf(claudePid) : void 0;
|
|
77014
|
+
const model = env.ANTHROPIC_MODEL || modelFlagOf(args) || files2.map((file4) => file4.model).find((value) => typeof value === "string");
|
|
77015
|
+
const compactWindow = windowOf2(env.CLAUDE_CODE_AUTO_COMPACT_WINDOW) ?? files2.map((file4) => windowOf2(record3(file4.env).CLAUDE_CODE_AUTO_COMPACT_WINDOW)).find(Boolean);
|
|
77016
|
+
return {
|
|
77017
|
+
...model ? { model } : {},
|
|
77018
|
+
...compactWindow ? { compactWindow } : {}
|
|
77019
|
+
};
|
|
77020
|
+
}
|
|
77021
|
+
|
|
76952
77022
|
// src/services/claude-wait.service.ts
|
|
76953
|
-
import { readFile as
|
|
77023
|
+
import { readFile as readFile10, rm as rm6 } from "node:fs/promises";
|
|
76954
77024
|
|
|
76955
77025
|
// src/rules/listener-retry.rules.ts
|
|
76956
77026
|
var FIRST_MS = 1e3;
|
|
@@ -76989,7 +77059,7 @@ var ListenerBackoff = class {
|
|
|
76989
77059
|
// src/services/connect-service.service.ts
|
|
76990
77060
|
import { createHash as createHash3 } from "node:crypto";
|
|
76991
77061
|
import { mkdir as mkdir3, rm as rm5, writeFile } from "node:fs/promises";
|
|
76992
|
-
import { dirname as dirname14, join as
|
|
77062
|
+
import { dirname as dirname14, join as join18 } from "node:path";
|
|
76993
77063
|
|
|
76994
77064
|
// src/rules/connect-service.rules.ts
|
|
76995
77065
|
function systemdWordOf(word3) {
|
|
@@ -77098,24 +77168,24 @@ function rolloutEventOf({
|
|
|
77098
77168
|
|
|
77099
77169
|
// src/services/connect-delivery.service.ts
|
|
77100
77170
|
import { rm as rm4, stat as stat5 } from "node:fs/promises";
|
|
77101
|
-
import { homedir as
|
|
77102
|
-
import { dirname as dirname13, join as
|
|
77171
|
+
import { homedir as homedir4, hostname as hostname6 } from "node:os";
|
|
77172
|
+
import { dirname as dirname13, join as join17 } from "node:path";
|
|
77103
77173
|
|
|
77104
77174
|
// src/services/codex-turn-watch.service.ts
|
|
77105
77175
|
import { open as open4, readdir as readdir4 } from "node:fs/promises";
|
|
77106
|
-
import { basename as basename5, join as
|
|
77176
|
+
import { basename as basename5, join as join13 } from "node:path";
|
|
77107
77177
|
var READ_MS = 1500;
|
|
77108
77178
|
var KEEP_WORKING_MS = 3e4;
|
|
77109
77179
|
async function codexRolloutPathOf({
|
|
77110
77180
|
codexHome,
|
|
77111
77181
|
threadId
|
|
77112
77182
|
}) {
|
|
77113
|
-
const root =
|
|
77183
|
+
const root = join13(codexHome, "sessions");
|
|
77114
77184
|
const files2 = await readdir4(root, { recursive: true }).catch(() => []);
|
|
77115
77185
|
const file4 = files2.find(
|
|
77116
77186
|
(name3) => basename5(name3).startsWith("rollout-") && name3.endsWith(`-${threadId}.jsonl`)
|
|
77117
77187
|
);
|
|
77118
|
-
return file4 ?
|
|
77188
|
+
return file4 ? join13(root, file4) : void 0;
|
|
77119
77189
|
}
|
|
77120
77190
|
function rolloutPathOf({ delivery }) {
|
|
77121
77191
|
return codexRolloutPathOf({ codexHome: delivery.codexHome, threadId: delivery.threadId });
|
|
@@ -77204,7 +77274,7 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
77204
77274
|
};
|
|
77205
77275
|
|
|
77206
77276
|
// src/services/mcp-relay.service.ts
|
|
77207
|
-
import { dirname as dirname10, join as
|
|
77277
|
+
import { dirname as dirname10, join as join14 } from "node:path";
|
|
77208
77278
|
|
|
77209
77279
|
// ../../node_modules/.pnpm/ws@8.21.3_bufferutil@4.1.0/node_modules/ws/wrapper.mjs
|
|
77210
77280
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -77540,7 +77610,7 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
77540
77610
|
[CONNECTOR_RELAY_CLOSE.replaced.code, "another relay for this server took over"]
|
|
77541
77611
|
]);
|
|
77542
77612
|
function mcpRelaysPathOf({ context }) {
|
|
77543
|
-
return
|
|
77613
|
+
return join14(dirname10(context.environment.configPath), "connect", "mcp-relays.json");
|
|
77544
77614
|
}
|
|
77545
77615
|
async function readMcpRelays({ context }) {
|
|
77546
77616
|
return await readStateJson({ path: mcpRelaysPathOf({ context }) }) ?? {};
|
|
@@ -77700,7 +77770,7 @@ var McpRelayLoops = class _McpRelayLoops {
|
|
|
77700
77770
|
};
|
|
77701
77771
|
|
|
77702
77772
|
// src/services/openclaw-relay.service.ts
|
|
77703
|
-
import { dirname as dirname11, join as
|
|
77773
|
+
import { dirname as dirname11, join as join15 } from "node:path";
|
|
77704
77774
|
|
|
77705
77775
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
77706
77776
|
var workspaceIdSchema18 = external_exports.string().min(1);
|
|
@@ -77921,7 +77991,7 @@ var STOPS2 = /* @__PURE__ */ new Map([
|
|
|
77921
77991
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
77922
77992
|
]);
|
|
77923
77993
|
function relaysPathOf({ context }) {
|
|
77924
|
-
return
|
|
77994
|
+
return join15(dirname11(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
77925
77995
|
}
|
|
77926
77996
|
async function readRelays({ context }) {
|
|
77927
77997
|
return await readStateJson({ path: relaysPathOf({ context }) }) ?? {};
|
|
@@ -78114,7 +78184,7 @@ var RelayLoops = class _RelayLoops {
|
|
|
78114
78184
|
};
|
|
78115
78185
|
|
|
78116
78186
|
// src/services/rush-host.service.ts
|
|
78117
|
-
import { dirname as dirname12, join as
|
|
78187
|
+
import { dirname as dirname12, join as join16 } from "node:path";
|
|
78118
78188
|
async function rushAboveOf({
|
|
78119
78189
|
context,
|
|
78120
78190
|
from = context.processes.pid
|
|
@@ -78128,7 +78198,7 @@ async function rushAboveOf({
|
|
|
78128
78198
|
return void 0;
|
|
78129
78199
|
}
|
|
78130
78200
|
function guardPathOf({ context, claudePid }) {
|
|
78131
|
-
return
|
|
78201
|
+
return join16(dirname12(context.environment.configPath), "rush-guards", `${claudePid}.json`);
|
|
78132
78202
|
}
|
|
78133
78203
|
async function startRushGuard({
|
|
78134
78204
|
context,
|
|
@@ -78141,7 +78211,7 @@ async function startRushGuard({
|
|
|
78141
78211
|
if (holder && context.processes.alive(holder.pid)) return;
|
|
78142
78212
|
const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
|
|
78143
78213
|
const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
|
|
78144
|
-
const logPath =
|
|
78214
|
+
const logPath = join16(dirname12(context.environment.configPath), "rush-guards", "guard.log");
|
|
78145
78215
|
context.processes.spawnDetached({ argv: ["sh", "-c", '"$@" &', "sh", ...argv], logPath });
|
|
78146
78216
|
}
|
|
78147
78217
|
async function claimRushGuard({
|
|
@@ -78365,10 +78435,10 @@ async function watchRushDelivery({
|
|
|
78365
78435
|
|
|
78366
78436
|
// src/services/connect-delivery.service.ts
|
|
78367
78437
|
function connectFolderOf({ context }) {
|
|
78368
|
-
return
|
|
78438
|
+
return join17(dirname13(context.environment.configPath), "connect");
|
|
78369
78439
|
}
|
|
78370
78440
|
function runStatePathOf({ context }) {
|
|
78371
|
-
return
|
|
78441
|
+
return join17(connectFolderOf({ context }), "run.json");
|
|
78372
78442
|
}
|
|
78373
78443
|
async function readJson({ path }) {
|
|
78374
78444
|
return readStateJson({ path });
|
|
@@ -78425,7 +78495,7 @@ async function takeRound({
|
|
|
78425
78495
|
const session = {
|
|
78426
78496
|
harness: "codex",
|
|
78427
78497
|
sessionId: delivery.threadId,
|
|
78428
|
-
folder: displayFolderOf({ folder: delivery.cwd, home:
|
|
78498
|
+
folder: displayFolderOf({ folder: delivery.cwd, home: homedir4() }),
|
|
78429
78499
|
host: hostname6()
|
|
78430
78500
|
};
|
|
78431
78501
|
try {
|
|
@@ -78666,17 +78736,17 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
|
|
|
78666
78736
|
\`laze openclaw connect --local\` and \`laze kanban connect\`, whose relays it also runs.
|
|
78667
78737
|
`;
|
|
78668
78738
|
function installedPathOf({ context }) {
|
|
78669
|
-
return
|
|
78739
|
+
return join18(connectFolderOf({ context }), "service.json");
|
|
78670
78740
|
}
|
|
78671
78741
|
function logPathOf({ context }) {
|
|
78672
|
-
return
|
|
78742
|
+
return join18(connectFolderOf({ context }), "connect.log");
|
|
78673
78743
|
}
|
|
78674
78744
|
function homeOf({ context }) {
|
|
78675
78745
|
return context.environment.inherited.HOME ?? dirname14(dirname14(context.environment.configPath));
|
|
78676
78746
|
}
|
|
78677
78747
|
function serviceNameOf({ context }) {
|
|
78678
78748
|
const { configPath } = context.environment;
|
|
78679
|
-
if (configPath ===
|
|
78749
|
+
if (configPath === join18(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
|
|
78680
78750
|
return `laze-connect-${createHash3("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
78681
78751
|
}
|
|
78682
78752
|
function serviceEnvOf({ context }) {
|
|
@@ -78699,8 +78769,8 @@ async function run({ context, command }) {
|
|
|
78699
78769
|
async function installSystemd({ context }) {
|
|
78700
78770
|
const name3 = serviceNameOf({ context });
|
|
78701
78771
|
const env = context.environment.inherited;
|
|
78702
|
-
const base = env.XDG_CONFIG_HOME ||
|
|
78703
|
-
const file4 =
|
|
78772
|
+
const base = env.XDG_CONFIG_HOME || join18(homeOf({ context }), ".config");
|
|
78773
|
+
const file4 = join18(base, "systemd", "user", `${name3}.service`);
|
|
78704
78774
|
await mkdir3(dirname14(file4), { recursive: true });
|
|
78705
78775
|
await writeFile(
|
|
78706
78776
|
file4,
|
|
@@ -78715,7 +78785,7 @@ async function installSystemd({ context }) {
|
|
|
78715
78785
|
async function installLaunchd({ context }) {
|
|
78716
78786
|
const name3 = serviceNameOf({ context });
|
|
78717
78787
|
const label3 = `ai.laze.${name3}`;
|
|
78718
|
-
const file4 =
|
|
78788
|
+
const file4 = join18(homeOf({ context }), "Library", "LaunchAgents", `${label3}.plist`);
|
|
78719
78789
|
const log = logPathOf({ context });
|
|
78720
78790
|
await mkdir3(dirname14(file4), { recursive: true });
|
|
78721
78791
|
await writeFile(
|
|
@@ -79163,7 +79233,7 @@ async function waitForMessages({ context, args }) {
|
|
|
79163
79233
|
if (rush) await healRushDelivery({ context });
|
|
79164
79234
|
const lock = statePathOf({ context, kind: "waiters", profile: name3 });
|
|
79165
79235
|
if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
|
|
79166
|
-
const seen = () => input2.transcript_path ?
|
|
79236
|
+
const seen = () => input2.transcript_path ? readFile10(input2.transcript_path, "utf8") : Promise.resolve("");
|
|
79167
79237
|
const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
|
|
79168
79238
|
try {
|
|
79169
79239
|
const backoff = new ListenerBackoff();
|
|
@@ -79214,7 +79284,7 @@ async function refusedOnce({
|
|
|
79214
79284
|
}) {
|
|
79215
79285
|
const profile = error63 instanceof ProfileRefusedError ? error63.profile : String(args.flags.profile ?? "default");
|
|
79216
79286
|
const path = statePathOf({ context, kind: "told", profile: `refused-${profile}` });
|
|
79217
|
-
const told = await
|
|
79287
|
+
const told = await readFile10(path, "utf8").then(
|
|
79218
79288
|
() => true,
|
|
79219
79289
|
() => false
|
|
79220
79290
|
);
|
|
@@ -79280,7 +79350,7 @@ import { rm as rm8 } from "node:fs/promises";
|
|
|
79280
79350
|
// src/services/codex-adopt.service.ts
|
|
79281
79351
|
import { spawn as spawn2 } from "node:child_process";
|
|
79282
79352
|
import { readdir as readdir5, rm as rm7, stat as stat6 } from "node:fs/promises";
|
|
79283
|
-
import { join as
|
|
79353
|
+
import { join as join19 } from "node:path";
|
|
79284
79354
|
import { createInterface } from "node:readline";
|
|
79285
79355
|
|
|
79286
79356
|
// src/rules/codex-requests.rules.ts
|
|
@@ -79303,19 +79373,19 @@ function codexRequestReplyOf({ method }) {
|
|
|
79303
79373
|
}
|
|
79304
79374
|
|
|
79305
79375
|
// src/services/codex-adopt.service.ts
|
|
79306
|
-
function
|
|
79376
|
+
function record4(value) {
|
|
79307
79377
|
return typeof value === "object" && value !== null ? value : {};
|
|
79308
79378
|
}
|
|
79309
79379
|
function absorbTurnEvent({ result: result2, message: message2 }) {
|
|
79310
|
-
const params =
|
|
79380
|
+
const params = record4(message2.params);
|
|
79311
79381
|
if (message2.method === "item/completed") {
|
|
79312
|
-
const item =
|
|
79382
|
+
const item = record4(params.item);
|
|
79313
79383
|
if (item.type === "agentMessage" && typeof item.text === "string") result2.answer = item.text;
|
|
79314
79384
|
return;
|
|
79315
79385
|
}
|
|
79316
79386
|
if (message2.method !== "thread/tokenUsage/updated") return;
|
|
79317
|
-
const usage2 =
|
|
79318
|
-
const total =
|
|
79387
|
+
const usage2 = record4(params.tokenUsage);
|
|
79388
|
+
const total = record4(usage2.last).totalTokens;
|
|
79319
79389
|
if (typeof total === "number") result2.contextTokens = total;
|
|
79320
79390
|
const window2 = usage2.modelContextWindow;
|
|
79321
79391
|
if (typeof window2 === "number" && window2 > 0) result2.contextWindow = window2;
|
|
@@ -79344,7 +79414,7 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
79344
79414
|
this.write({ id: id8, method, params });
|
|
79345
79415
|
});
|
|
79346
79416
|
if (reply2.error !== void 0) throw new Error(`${method}: ${JSON.stringify(reply2.error)}`);
|
|
79347
|
-
return
|
|
79417
|
+
return record4(reply2.result);
|
|
79348
79418
|
}
|
|
79349
79419
|
notify(method) {
|
|
79350
79420
|
this.write({ method });
|
|
@@ -79365,7 +79435,7 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
79365
79435
|
threadId,
|
|
79366
79436
|
input: [{ type: "text", text: text3, text_elements: [] }]
|
|
79367
79437
|
});
|
|
79368
|
-
const turnId =
|
|
79438
|
+
const turnId = record4(started.turn).id;
|
|
79369
79439
|
return { turnId: typeof turnId === "string" ? turnId : null, done };
|
|
79370
79440
|
}
|
|
79371
79441
|
stop() {
|
|
@@ -79378,7 +79448,7 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
79378
79448
|
receive(line) {
|
|
79379
79449
|
let message2;
|
|
79380
79450
|
try {
|
|
79381
|
-
message2 =
|
|
79451
|
+
message2 = record4(JSON.parse(line));
|
|
79382
79452
|
} catch {
|
|
79383
79453
|
return;
|
|
79384
79454
|
}
|
|
@@ -79400,11 +79470,11 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
79400
79470
|
}
|
|
79401
79471
|
};
|
|
79402
79472
|
async function newestThreadId({ codexHome }) {
|
|
79403
|
-
const root =
|
|
79473
|
+
const root = join19(codexHome, "sessions");
|
|
79404
79474
|
const files2 = await readdir5(root, { recursive: true }).catch(() => []);
|
|
79405
79475
|
const rollouts = files2.filter((file4) => /rollout-.*\.jsonl$/.test(file4));
|
|
79406
79476
|
const dated = await Promise.all(
|
|
79407
|
-
rollouts.map(async (file4) => ({ file: file4, at: (await stat6(
|
|
79477
|
+
rollouts.map(async (file4) => ({ file: file4, at: (await stat6(join19(root, file4))).mtimeMs }))
|
|
79408
79478
|
);
|
|
79409
79479
|
const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
|
|
79410
79480
|
const id8 = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/.exec(newest);
|
|
@@ -79541,29 +79611,29 @@ async function supervise({
|
|
|
79541
79611
|
return 0;
|
|
79542
79612
|
}
|
|
79543
79613
|
async function adoptStatus({ context, profile }) {
|
|
79544
|
-
const
|
|
79545
|
-
if (!
|
|
79614
|
+
const record5 = await recordOf({ path: statePathOf({ context, kind: "adopt", profile }) });
|
|
79615
|
+
if (!record5 || !context.processes.alive(record5.pid)) {
|
|
79546
79616
|
context.out(`laze adopt codex does not run in the background for profile "${profile}".
|
|
79547
79617
|
`);
|
|
79548
79618
|
return;
|
|
79549
79619
|
}
|
|
79550
|
-
const thread2 =
|
|
79620
|
+
const thread2 = record5.thread ?? "the newest thread";
|
|
79551
79621
|
context.out(
|
|
79552
|
-
`laze adopt codex runs in the background for profile "${profile}" (pid ${
|
|
79553
|
-
Log: ${
|
|
79622
|
+
`laze adopt codex runs in the background for profile "${profile}" (pid ${record5.pid}), thread ${thread2}.
|
|
79623
|
+
Log: ${record5.log}
|
|
79554
79624
|
`
|
|
79555
79625
|
);
|
|
79556
79626
|
}
|
|
79557
79627
|
async function adoptStop({ context, profile }) {
|
|
79558
79628
|
const path = statePathOf({ context, kind: "adopt", profile });
|
|
79559
|
-
const
|
|
79629
|
+
const record5 = await recordOf({ path });
|
|
79560
79630
|
await rm7(path, { force: true });
|
|
79561
|
-
if (!
|
|
79631
|
+
if (!record5 || !context.processes.stop(record5.pid)) {
|
|
79562
79632
|
context.out(`laze adopt codex was not running in the background for profile "${profile}".
|
|
79563
79633
|
`);
|
|
79564
79634
|
return;
|
|
79565
79635
|
}
|
|
79566
|
-
context.out(`Stopped laze adopt codex (pid ${
|
|
79636
|
+
context.out(`Stopped laze adopt codex (pid ${record5.pid}) for profile "${profile}".
|
|
79567
79637
|
`);
|
|
79568
79638
|
}
|
|
79569
79639
|
var HELD_THREAD = /active writer/;
|
|
@@ -79592,7 +79662,7 @@ async function adoptedThreadOf({
|
|
|
79592
79662
|
`);
|
|
79593
79663
|
return known;
|
|
79594
79664
|
}
|
|
79595
|
-
const forked =
|
|
79665
|
+
const forked = record4((await codex.call("thread/fork", { threadId })).thread).id;
|
|
79596
79666
|
if (typeof forked !== "string") throw new Error("thread/fork answered no thread id");
|
|
79597
79667
|
await writeStateJson({ path, value: { ...forks, [threadId]: forked } });
|
|
79598
79668
|
context.out(
|
|
@@ -79722,16 +79792,16 @@ async function linkCodexSession({
|
|
|
79722
79792
|
}
|
|
79723
79793
|
|
|
79724
79794
|
// src/services/laze-plugin.service.ts
|
|
79725
|
-
import { mkdir as mkdir4, readFile as
|
|
79726
|
-
import { homedir as
|
|
79727
|
-
import { dirname as dirname15, join as
|
|
79795
|
+
import { mkdir as mkdir4, readFile as readFile11, rm as rm9, writeFile as writeFile2 } from "node:fs/promises";
|
|
79796
|
+
import { homedir as homedir5 } from "node:os";
|
|
79797
|
+
import { dirname as dirname15, join as join21 } from "node:path";
|
|
79728
79798
|
|
|
79729
79799
|
// src/rules/laze-plugin.rules.ts
|
|
79730
79800
|
import { createHash as createHash4 } from "node:crypto";
|
|
79731
|
-
import { join as
|
|
79801
|
+
import { join as join20 } from "node:path";
|
|
79732
79802
|
var LAZE_PLUGIN = "laze";
|
|
79733
79803
|
function pluginNameOf({ configPath, home }) {
|
|
79734
|
-
if (configPath ===
|
|
79804
|
+
if (configPath === join20(home, ".laze", "config.json")) return LAZE_PLUGIN;
|
|
79735
79805
|
return `${LAZE_PLUGIN}-${createHash4("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
79736
79806
|
}
|
|
79737
79807
|
var NPX_CLI = ["npx", "-y", "@lazehq/cli@latest"];
|
|
@@ -80012,7 +80082,7 @@ function lazePluginFiles({
|
|
|
80012
80082
|
var REGISTER_LIMIT_MS = 6e4;
|
|
80013
80083
|
var quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
80014
80084
|
function homeOf2({ context }) {
|
|
80015
|
-
return context.environment.inherited.HOME ||
|
|
80085
|
+
return context.environment.inherited.HOME || homedir5();
|
|
80016
80086
|
}
|
|
80017
80087
|
function pluginNameHere({ context }) {
|
|
80018
80088
|
return pluginNameOf({ configPath: context.environment.configPath, home: homeOf2({ context }) });
|
|
@@ -80022,11 +80092,11 @@ function installedNameOf({ context }) {
|
|
|
80022
80092
|
return `${name3}@${name3}`;
|
|
80023
80093
|
}
|
|
80024
80094
|
function pluginFolderOf({ context }) {
|
|
80025
|
-
return
|
|
80095
|
+
return join21(dirname15(context.environment.configPath), "plugins");
|
|
80026
80096
|
}
|
|
80027
80097
|
async function pluginIsCurrent({ context }) {
|
|
80028
|
-
const manifest =
|
|
80029
|
-
const written = await
|
|
80098
|
+
const manifest = join21(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
|
|
80099
|
+
const written = await readFile11(manifest, "utf8").then((text3) => JSON.parse(text3).version).catch(() => void 0);
|
|
80030
80100
|
return written === cliVersionOf();
|
|
80031
80101
|
}
|
|
80032
80102
|
async function writeLazePlugin({ context }) {
|
|
@@ -80038,7 +80108,7 @@ async function writeLazePlugin({ context }) {
|
|
|
80038
80108
|
configPath: context.environment.configPath
|
|
80039
80109
|
});
|
|
80040
80110
|
for (const [path, text3] of Object.entries(files2)) {
|
|
80041
|
-
const target =
|
|
80111
|
+
const target = join21(folder, path);
|
|
80042
80112
|
await mkdir4(dirname15(target), { recursive: true });
|
|
80043
80113
|
await writeFile2(target, text3);
|
|
80044
80114
|
}
|
|
@@ -80069,7 +80139,7 @@ async function registerWithClaude({ context, folder }) {
|
|
|
80069
80139
|
return claudeScript({ context, script });
|
|
80070
80140
|
}
|
|
80071
80141
|
function claudeDirOf({ context }) {
|
|
80072
|
-
return context.environment.inherited.CLAUDE_CONFIG_DIR ||
|
|
80142
|
+
return context.environment.inherited.CLAUDE_CONFIG_DIR || join21(homeOf2({ context }), ".claude");
|
|
80073
80143
|
}
|
|
80074
80144
|
function unregisterAs({ context, name: name3 }) {
|
|
80075
80145
|
const script = [
|
|
@@ -80080,8 +80150,8 @@ function unregisterAs({ context, name: name3 }) {
|
|
|
80080
80150
|
}
|
|
80081
80151
|
async function dropOwnLeftover({ context, folder }) {
|
|
80082
80152
|
if (pluginNameHere({ context }) === LAZE_PLUGIN) return;
|
|
80083
|
-
const known = await
|
|
80084
|
-
|
|
80153
|
+
const known = await readFile11(
|
|
80154
|
+
join21(claudeDirOf({ context }), "plugins", "known_marketplaces.json"),
|
|
80085
80155
|
"utf8"
|
|
80086
80156
|
).then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
80087
80157
|
if (known?.[LAZE_PLUGIN]?.source?.path !== folder) return;
|
|
@@ -80089,17 +80159,17 @@ async function dropOwnLeftover({ context, folder }) {
|
|
|
80089
80159
|
}
|
|
80090
80160
|
var RUN_FILES = ["hooks/hooks.json", "monitors/monitors.json"];
|
|
80091
80161
|
async function cachedPluginOf({ context }) {
|
|
80092
|
-
const path =
|
|
80093
|
-
const listed = await
|
|
80162
|
+
const path = join21(claudeDirOf({ context }), "plugins", "installed_plugins.json");
|
|
80163
|
+
const listed = await readFile11(path, "utf8").then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
80094
80164
|
return listed?.plugins?.[installedNameOf({ context })]?.[0]?.installPath;
|
|
80095
80165
|
}
|
|
80096
80166
|
async function refreshStaleCache({ context, folder }) {
|
|
80097
80167
|
const cached2 = await cachedPluginOf({ context });
|
|
80098
80168
|
if (!cached2) return true;
|
|
80099
|
-
const read4 = (path) =>
|
|
80169
|
+
const read4 = (path) => readFile11(path, "utf8").catch(() => "");
|
|
80100
80170
|
for (const file4 of RUN_FILES) {
|
|
80101
|
-
const ours = await read4(
|
|
80102
|
-
if (ours === await read4(
|
|
80171
|
+
const ours = await read4(join21(folder, LAZE_PLUGIN, file4));
|
|
80172
|
+
if (ours === await read4(join21(cached2, file4))) continue;
|
|
80103
80173
|
const plugin2 = installedNameOf({ context });
|
|
80104
80174
|
const script = [
|
|
80105
80175
|
`claude plugin uninstall ${plugin2} --scope user ${QUIET}`,
|
|
@@ -80110,10 +80180,10 @@ async function refreshStaleCache({ context, folder }) {
|
|
|
80110
80180
|
return true;
|
|
80111
80181
|
}
|
|
80112
80182
|
function registeredMarkOf({ context }) {
|
|
80113
|
-
return
|
|
80183
|
+
return join21(pluginFolderOf({ context }), "registered");
|
|
80114
80184
|
}
|
|
80115
80185
|
async function pluginRegistered({ context }) {
|
|
80116
|
-
return
|
|
80186
|
+
return readFile11(registeredMarkOf({ context }), "utf8").then(
|
|
80117
80187
|
() => true,
|
|
80118
80188
|
() => false
|
|
80119
80189
|
);
|
|
@@ -80128,7 +80198,7 @@ async function installLazePlugin({ context }) {
|
|
|
80128
80198
|
async function plugin({ context, args }) {
|
|
80129
80199
|
const action = args.words[1] ?? "install";
|
|
80130
80200
|
if (action === "path") {
|
|
80131
|
-
context.out(`${
|
|
80201
|
+
context.out(`${join21(pluginFolderOf({ context }), LAZE_PLUGIN)}
|
|
80132
80202
|
`);
|
|
80133
80203
|
return 0;
|
|
80134
80204
|
}
|
|
@@ -80339,7 +80409,7 @@ async function pushInbox({
|
|
|
80339
80409
|
}
|
|
80340
80410
|
|
|
80341
80411
|
// src/services/plugin-tip.service.ts
|
|
80342
|
-
import { readFile as
|
|
80412
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
80343
80413
|
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.";
|
|
80344
80414
|
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.";
|
|
80345
80415
|
function monitorsRunHere({ context }) {
|
|
@@ -80381,7 +80451,7 @@ async function reloadTipOnce({
|
|
|
80381
80451
|
}) {
|
|
80382
80452
|
if (!session || !monitorsRunHere({ context })) return void 0;
|
|
80383
80453
|
if (!await pluginRegistered({ context })) return void 0;
|
|
80384
|
-
const told = await
|
|
80454
|
+
const told = await readFile12(toldPathOf({ context, session }), "utf8").then(
|
|
80385
80455
|
() => true,
|
|
80386
80456
|
() => false
|
|
80387
80457
|
);
|
|
@@ -80394,7 +80464,7 @@ async function reloadTipOnce({
|
|
|
80394
80464
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
80395
80465
|
import { createHash as createHash5 } from "node:crypto";
|
|
80396
80466
|
import { mkdir as mkdir5, open as open5 } from "node:fs/promises";
|
|
80397
|
-
import { dirname as dirname16, join as
|
|
80467
|
+
import { dirname as dirname16, join as join22 } from "node:path";
|
|
80398
80468
|
|
|
80399
80469
|
// src/rules/session-scrub.rules.ts
|
|
80400
80470
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
@@ -80454,7 +80524,7 @@ function paddedTo({ text: text3, bytes }) {
|
|
|
80454
80524
|
// src/services/session-scrub.service.ts
|
|
80455
80525
|
function offsetPathOf({ context, transcript }) {
|
|
80456
80526
|
const key = createHash5("sha256").update(transcript).digest("hex").slice(0, 24);
|
|
80457
|
-
return
|
|
80527
|
+
return join22(dirname16(context.environment.configPath), "session-scrub", `${key}.json`);
|
|
80458
80528
|
}
|
|
80459
80529
|
async function offsetOf({ path }) {
|
|
80460
80530
|
const saved3 = await readStateJson({ path });
|
|
@@ -80633,7 +80703,7 @@ async function harnessOf2({ context, args }) {
|
|
|
80633
80703
|
const nearest = await nearestHarnessOf({ context });
|
|
80634
80704
|
return nearest ?? { harness: context.environment.harness, pid: void 0 };
|
|
80635
80705
|
}
|
|
80636
|
-
function
|
|
80706
|
+
function settingsOf2({ path, text: text3 }) {
|
|
80637
80707
|
try {
|
|
80638
80708
|
return JSON.parse(text3);
|
|
80639
80709
|
} catch {
|
|
@@ -80641,10 +80711,10 @@ function settingsOf({ path, text: text3 }) {
|
|
|
80641
80711
|
}
|
|
80642
80712
|
}
|
|
80643
80713
|
async function installHooks({ context, directory }) {
|
|
80644
|
-
const folder =
|
|
80645
|
-
const path =
|
|
80646
|
-
const text3 = await
|
|
80647
|
-
const current3 =
|
|
80714
|
+
const folder = join23(directory, ".claude");
|
|
80715
|
+
const path = join23(folder, "settings.local.json");
|
|
80716
|
+
const text3 = await readFile13(path, "utf8").catch(() => "{}");
|
|
80717
|
+
const current3 = settingsOf2({ path, text: text3 });
|
|
80648
80718
|
const command = (hook) => hookCommand({ program: context.program, hook });
|
|
80649
80719
|
const settings3 = withLazeHooks({
|
|
80650
80720
|
settings: current3,
|
|
@@ -80874,12 +80944,16 @@ async function bindInLaze({
|
|
|
80874
80944
|
}
|
|
80875
80945
|
}
|
|
80876
80946
|
async function reportTranscript({
|
|
80947
|
+
context: cli,
|
|
80877
80948
|
client,
|
|
80878
|
-
input: input2
|
|
80949
|
+
input: input2,
|
|
80950
|
+
claudePid
|
|
80879
80951
|
}) {
|
|
80880
80952
|
if (!input2.transcript_path || !input2.session_id) return;
|
|
80881
|
-
const lines2 = (await
|
|
80882
|
-
const
|
|
80953
|
+
const lines2 = (await readFile13(input2.transcript_path, "utf8")).split("\n");
|
|
80954
|
+
const { folder } = await claudeFoldersOf({ context: cli, claudePid });
|
|
80955
|
+
const run4 = await claudeRunOf({ context: cli, folder: input2.cwd ?? folder, claudePid });
|
|
80956
|
+
const context = readTranscript({ lines: lines2, run: run4 });
|
|
80883
80957
|
await client.post("/api/agents/me/activity", {
|
|
80884
80958
|
sessionId: input2.session_id,
|
|
80885
80959
|
...context.contextTokens !== void 0 ? { contextTokens: context.contextTokens } : {},
|
|
@@ -80904,7 +80978,7 @@ async function handOver({ context, args }) {
|
|
|
80904
80978
|
const named = await pluginHookArgs({ context, args, session, claudePid });
|
|
80905
80979
|
if (!named) return;
|
|
80906
80980
|
const { client, name: agent3 } = await signedIn({ context, args: named });
|
|
80907
|
-
await reportTranscript({ client, input: input2 }).catch(
|
|
80981
|
+
await reportTranscript({ context, client, input: input2, claudePid }).catch(
|
|
80908
80982
|
(error63) => reportFailed({ context, error: error63 })
|
|
80909
80983
|
);
|
|
80910
80984
|
if (input2.transcript_path) {
|
|
@@ -80922,7 +80996,7 @@ async function handOver({ context, args }) {
|
|
|
80922
80996
|
const kept = await dueFromSpool({
|
|
80923
80997
|
context,
|
|
80924
80998
|
profile: agent3,
|
|
80925
|
-
seen: () => input2.transcript_path ?
|
|
80999
|
+
seen: () => input2.transcript_path ? readFile13(input2.transcript_path, "utf8") : Promise.resolve(""),
|
|
80926
81000
|
pushedToo: false,
|
|
80927
81001
|
settledOnly: true
|
|
80928
81002
|
});
|
|
@@ -80954,14 +81028,14 @@ async function handOver({ context, args }) {
|
|
|
80954
81028
|
async function addSessionStartWaiter({ context, args }) {
|
|
80955
81029
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
|
|
80956
81030
|
if (!directory || args.flags.plugin) return;
|
|
80957
|
-
const path =
|
|
80958
|
-
const settings3 = await
|
|
81031
|
+
const path = join23(directory, ".claude", "settings.local.json");
|
|
81032
|
+
const settings3 = await readFile13(path, "utf8").then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
80959
81033
|
if (!settings3 || !lacksSessionStartWaiter({ settings: settings3 })) return;
|
|
80960
81034
|
await installHooks({ context, directory });
|
|
80961
81035
|
}
|
|
80962
81036
|
async function refreshPlugin({ context }) {
|
|
80963
81037
|
if (await pluginIsCurrent({ context })) return;
|
|
80964
|
-
const logPath =
|
|
81038
|
+
const logPath = join23(pluginFolderOf({ context }), "install.log");
|
|
80965
81039
|
context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
|
|
80966
81040
|
}
|
|
80967
81041
|
async function stopHook({ context, args }) {
|
|
@@ -80987,7 +81061,7 @@ async function stopHook({ context, args }) {
|
|
|
80987
81061
|
}
|
|
80988
81062
|
|
|
80989
81063
|
// src/services/agent-manage-commands.service.ts
|
|
80990
|
-
import { readFile as
|
|
81064
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
80991
81065
|
import { extname, resolve as resolve5 } from "node:path";
|
|
80992
81066
|
|
|
80993
81067
|
// src/rules/login-format.rules.ts
|
|
@@ -81120,7 +81194,7 @@ async function avatarOf({
|
|
|
81120
81194
|
return emoji4;
|
|
81121
81195
|
}
|
|
81122
81196
|
if (!path) return void 0;
|
|
81123
|
-
const bytes = await
|
|
81197
|
+
const bytes = await readFile14(resolve5(context.cwd, path)).catch(() => {
|
|
81124
81198
|
throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
|
|
81125
81199
|
});
|
|
81126
81200
|
const uploaded = await client.post("/api/agents/avatars", {
|
|
@@ -81836,8 +81910,8 @@ async function setAgentRunsOn({
|
|
|
81836
81910
|
}
|
|
81837
81911
|
|
|
81838
81912
|
// src/services/agent-migrate-commands.service.ts
|
|
81839
|
-
import { readFile as
|
|
81840
|
-
import { basename as basename6, join as
|
|
81913
|
+
import { readFile as readFile15, stat as stat7 } from "node:fs/promises";
|
|
81914
|
+
import { basename as basename6, join as join24, resolve as resolve6 } from "node:path";
|
|
81841
81915
|
|
|
81842
81916
|
// src/rules/migration-upload.rules.ts
|
|
81843
81917
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -81900,8 +81974,8 @@ function packed({ lines: lines2, maxBytes }) {
|
|
|
81900
81974
|
function isCompactBoundary(line) {
|
|
81901
81975
|
if (!line.includes('"compact_boundary"')) return false;
|
|
81902
81976
|
try {
|
|
81903
|
-
const
|
|
81904
|
-
return
|
|
81977
|
+
const record5 = JSON.parse(line);
|
|
81978
|
+
return record5.type === "system" && record5.subtype === "compact_boundary";
|
|
81905
81979
|
} catch {
|
|
81906
81980
|
return false;
|
|
81907
81981
|
}
|
|
@@ -82074,7 +82148,7 @@ async function transcriptOf({ context, args, ticket }) {
|
|
|
82074
82148
|
if (ticket.source === "codex") {
|
|
82075
82149
|
const codexHome = context.environment.codexHome;
|
|
82076
82150
|
const path2 = await codexRolloutPathOf({ codexHome, threadId: sessionId });
|
|
82077
|
-
return { sessionId, path: path2, where:
|
|
82151
|
+
return { sessionId, path: path2, where: join24(codexHome, "sessions") };
|
|
82078
82152
|
}
|
|
82079
82153
|
const { root, path } = await claudeTranscriptOf({ context, sessionId });
|
|
82080
82154
|
return { sessionId, path, where: root };
|
|
@@ -82126,7 +82200,7 @@ async function uploadTranscript({ context, args, client }) {
|
|
|
82126
82200
|
`The transcript of session ${found.sessionId} was not found under ${found.where}; nothing was uploaded.`
|
|
82127
82201
|
);
|
|
82128
82202
|
}
|
|
82129
|
-
const raw = await
|
|
82203
|
+
const raw = await readFile15(found.path, "utf8");
|
|
82130
82204
|
if (!raw.trim()) throw new CliUsageError(`${found.path} is empty; nothing was uploaded.`);
|
|
82131
82205
|
const redacted = await redactTranscript({ text: raw });
|
|
82132
82206
|
const { parts, truncated } = transcriptPartsOf({
|
|
@@ -82449,8 +82523,8 @@ async function listAgentSessions({
|
|
|
82449
82523
|
}
|
|
82450
82524
|
|
|
82451
82525
|
// src/services/app-commands.service.ts
|
|
82452
|
-
import { mkdir as mkdir8, readdir as readdir6, readFile as
|
|
82453
|
-
import { dirname as dirname18, join as
|
|
82526
|
+
import { mkdir as mkdir8, readdir as readdir6, readFile as readFile18, writeFile as writeFile6 } from "node:fs/promises";
|
|
82527
|
+
import { dirname as dirname18, join as join29, relative as relative3, resolve as resolve9, sep as sep3 } from "node:path";
|
|
82454
82528
|
|
|
82455
82529
|
// ../../modules/app/contract/src/app.connections.ts
|
|
82456
82530
|
var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
@@ -85256,7 +85330,7 @@ async function appAsset(input2) {
|
|
|
85256
85330
|
// src/services/browser-tab-commands.service.ts
|
|
85257
85331
|
import { mkdir as mkdir7, writeFile as writeFile4 } from "node:fs/promises";
|
|
85258
85332
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
85259
|
-
import { join as
|
|
85333
|
+
import { join as join26, resolve as resolve8 } from "node:path";
|
|
85260
85334
|
|
|
85261
85335
|
// src/rules/browser-login.rules.ts
|
|
85262
85336
|
var PASSWORD_NAME = /pass|pwd/i;
|
|
@@ -85321,9 +85395,9 @@ async function patiently({
|
|
|
85321
85395
|
|
|
85322
85396
|
// src/services/vault-commands.service.ts
|
|
85323
85397
|
import { createHash as createHash8 } from "node:crypto";
|
|
85324
|
-
import { readFile as
|
|
85398
|
+
import { readFile as readFile16, rm as rm11 } from "node:fs/promises";
|
|
85325
85399
|
import { hostname as hostname7, tmpdir } from "node:os";
|
|
85326
|
-
import { dirname as dirname17, join as
|
|
85400
|
+
import { dirname as dirname17, join as join25 } from "node:path";
|
|
85327
85401
|
|
|
85328
85402
|
// src/rules/vault-session.rules.ts
|
|
85329
85403
|
function vaultSessionOf({
|
|
@@ -85383,7 +85457,7 @@ async function handedOut({
|
|
|
85383
85457
|
() => void 0
|
|
85384
85458
|
);
|
|
85385
85459
|
context.err(
|
|
85386
|
-
`laze vault: ${Object.keys(fields).join(", ")} of ${name3} hold a stand-in; Laze's proxy puts the key in only on sites approved for it. A command that needs the value itself (signing, a database) needs ${name3} marked "Used on the computer only".
|
|
85460
|
+
`laze vault: ${Object.keys(fields).join(", ")} of ${name3} ${Object.keys(fields).length === 1 ? "holds" : "hold"} a stand-in; Laze's proxy puts the key in only on sites approved for it. A command that needs the value itself (signing, a database) needs ${name3} marked "Used on the computer only".
|
|
85387
85461
|
`
|
|
85388
85462
|
);
|
|
85389
85463
|
}
|
|
@@ -85426,7 +85500,7 @@ async function turnTokenOf2({
|
|
|
85426
85500
|
if (pinned) return pinned;
|
|
85427
85501
|
if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
85428
85502
|
try {
|
|
85429
|
-
return (await
|
|
85503
|
+
return (await readFile16(turnFile, "utf8")).trim();
|
|
85430
85504
|
} catch {
|
|
85431
85505
|
throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
85432
85506
|
}
|
|
@@ -85437,8 +85511,8 @@ function runKeyPathOf({
|
|
|
85437
85511
|
profile = ""
|
|
85438
85512
|
}) {
|
|
85439
85513
|
const name3 = createHash8("sha256").update(connection).digest("hex");
|
|
85440
|
-
const base = turnFile ? dirname17(turnFile) :
|
|
85441
|
-
return
|
|
85514
|
+
const base = turnFile ? dirname17(turnFile) : join25(tmpdir(), "laze-vault", profile);
|
|
85515
|
+
return join25(base, "vault-run-keys", `${name3}.json`);
|
|
85442
85516
|
}
|
|
85443
85517
|
async function runKeyAt({ path }) {
|
|
85444
85518
|
const saved3 = await readStateJson({
|
|
@@ -86021,9 +86095,9 @@ async function savedScreenshot({
|
|
|
86021
86095
|
nowMs: nowMs2,
|
|
86022
86096
|
what
|
|
86023
86097
|
}) {
|
|
86024
|
-
const folder =
|
|
86098
|
+
const folder = join26(tmpdir2(), "laze-browser");
|
|
86025
86099
|
await mkdir7(folder, { recursive: true, mode: 448 });
|
|
86026
|
-
const path =
|
|
86100
|
+
const path = join26(folder, `${tabId.replace(/[^a-zA-Z0-9_-]/g, "_")}-${what}-${nowMs2}.jpg`);
|
|
86027
86101
|
await writeFile4(path, Buffer.from(data, "base64"), { mode: 384 });
|
|
86028
86102
|
return path;
|
|
86029
86103
|
}
|
|
@@ -86501,7 +86575,7 @@ async function appPinsCommand({
|
|
|
86501
86575
|
import { execFile } from "node:child_process";
|
|
86502
86576
|
import { mkdtemp, rm as rm12, writeFile as writeFile5 } from "node:fs/promises";
|
|
86503
86577
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
86504
|
-
import { join as
|
|
86578
|
+
import { join as join27 } from "node:path";
|
|
86505
86579
|
import { promisify } from "node:util";
|
|
86506
86580
|
var run2 = promisify(execFile);
|
|
86507
86581
|
var MODULE_SYNTAX = /^\s*(import|export)\s/m;
|
|
@@ -86530,11 +86604,11 @@ async function scriptErrorsOf({
|
|
|
86530
86604
|
const unknown2 = unknownCollectionsOf({ files: files2, collections });
|
|
86531
86605
|
const scripts = files2.flatMap(scriptsOf);
|
|
86532
86606
|
if (scripts.length === 0) return unknown2;
|
|
86533
|
-
const dir = await mkdtemp(
|
|
86607
|
+
const dir = await mkdtemp(join27(tmpdir3(), "laze-app-check-"));
|
|
86534
86608
|
try {
|
|
86535
86609
|
const errors = await Promise.all(
|
|
86536
86610
|
scripts.map(async (script, index) => {
|
|
86537
|
-
const file4 =
|
|
86611
|
+
const file4 = join27(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
|
|
86538
86612
|
await writeFile5(file4, script.code);
|
|
86539
86613
|
try {
|
|
86540
86614
|
await run2(process.execPath, ["--check", file4]);
|
|
@@ -86552,9 +86626,9 @@ async function scriptErrorsOf({
|
|
|
86552
86626
|
}
|
|
86553
86627
|
|
|
86554
86628
|
// src/services/app-serve.service.ts
|
|
86555
|
-
import { readFile as
|
|
86629
|
+
import { readFile as readFile17, stat as stat9 } from "node:fs/promises";
|
|
86556
86630
|
import { createServer } from "node:http";
|
|
86557
|
-
import { extname as extname2, join as
|
|
86631
|
+
import { extname as extname2, join as join28, normalize, sep as sep2 } from "node:path";
|
|
86558
86632
|
var TYPES2 = {
|
|
86559
86633
|
".html": "text/html; charset=utf-8",
|
|
86560
86634
|
".js": "text/javascript; charset=utf-8",
|
|
@@ -86605,13 +86679,13 @@ async function staticFile({
|
|
|
86605
86679
|
if (clean.startsWith("..") || hidden) {
|
|
86606
86680
|
return json2({ response, status: 404, value: { code: "not_found", message: "Not found" } });
|
|
86607
86681
|
}
|
|
86608
|
-
const candidates = [
|
|
86609
|
-
if (!extname2(clean)) candidates.push(
|
|
86682
|
+
const candidates = [join28(folder, clean), join28(folder, clean, "index.html")];
|
|
86683
|
+
if (!extname2(clean)) candidates.push(join28(folder, "index.html"));
|
|
86610
86684
|
for (const target of candidates) {
|
|
86611
86685
|
const info = await stat9(target).catch(() => void 0);
|
|
86612
86686
|
if (!info?.isFile()) continue;
|
|
86613
86687
|
const type = TYPES2[extname2(target).toLowerCase()] ?? "application/octet-stream";
|
|
86614
|
-
const body = await
|
|
86688
|
+
const body = await readFile17(target);
|
|
86615
86689
|
if (extname2(target) === ".html") {
|
|
86616
86690
|
return send2({ response, status: 200, type, body: withServeThemeScript(body.toString()) });
|
|
86617
86691
|
}
|
|
@@ -86861,7 +86935,7 @@ async function turnTokenOf3({
|
|
|
86861
86935
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
86862
86936
|
if (pinned) return pinned;
|
|
86863
86937
|
if (env.LAZE_TURN_FILE) {
|
|
86864
|
-
return
|
|
86938
|
+
return readFile18(env.LAZE_TURN_FILE, "utf8").then(
|
|
86865
86939
|
(text3) => text3.trim(),
|
|
86866
86940
|
() => ""
|
|
86867
86941
|
);
|
|
@@ -86895,7 +86969,7 @@ function folderOf({ context, word: word3 }) {
|
|
|
86895
86969
|
return resolve9(context.cwd, word3 ?? ".");
|
|
86896
86970
|
}
|
|
86897
86971
|
async function readManifest(folder) {
|
|
86898
|
-
const text3 = await
|
|
86972
|
+
const text3 = await readFile18(join29(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
86899
86973
|
if (text3 === void 0) return void 0;
|
|
86900
86974
|
const parsed = appManifestSchema.safeParse(JSON.parse(text3));
|
|
86901
86975
|
if (!parsed.success) {
|
|
@@ -86936,7 +87010,7 @@ async function jsonFlag({
|
|
|
86936
87010
|
}) {
|
|
86937
87011
|
const raw = flagText({ args, name: name3 });
|
|
86938
87012
|
if (!raw) return void 0;
|
|
86939
|
-
const text3 = raw.startsWith("@") ? await
|
|
87013
|
+
const text3 = raw.startsWith("@") ? await readFile18(resolve9(context.cwd, raw.slice(1)), "utf8") : raw;
|
|
86940
87014
|
try {
|
|
86941
87015
|
return JSON.parse(text3);
|
|
86942
87016
|
} catch {
|
|
@@ -86949,7 +87023,7 @@ async function listFiles(folder) {
|
|
|
86949
87023
|
while (pending2.length > 0 && found.length <= MAX_FILES) {
|
|
86950
87024
|
const current3 = pending2.pop() ?? folder;
|
|
86951
87025
|
for (const entry2 of await readdir6(current3, { withFileTypes: true })) {
|
|
86952
|
-
const path =
|
|
87026
|
+
const path = join29(current3, entry2.name);
|
|
86953
87027
|
const rel = relative3(folder, path).split(sep3).join("/");
|
|
86954
87028
|
if (isSkippedPath({ path: rel })) continue;
|
|
86955
87029
|
if (entry2.isDirectory()) pending2.push(path);
|
|
@@ -86988,7 +87062,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
86988
87062
|
await mkdir8(folder, { recursive: true });
|
|
86989
87063
|
const start2 = template ? await templateStart({ client, appId: app2.id, template }) : null;
|
|
86990
87064
|
for (const file4 of start2?.files ?? []) {
|
|
86991
|
-
const target =
|
|
87065
|
+
const target = join29(folder, ...file4.path.split("/"));
|
|
86992
87066
|
await mkdir8(dirname18(target), { recursive: true });
|
|
86993
87067
|
await writeFile6(
|
|
86994
87068
|
target,
|
|
@@ -87001,7 +87075,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
87001
87075
|
views: [...start2?.template.views ?? []],
|
|
87002
87076
|
seed: { ...start2?.template.seed }
|
|
87003
87077
|
};
|
|
87004
|
-
await writeFile6(
|
|
87078
|
+
await writeFile6(join29(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
87005
87079
|
`);
|
|
87006
87080
|
const where = relative3(context.cwd, folder) || ".";
|
|
87007
87081
|
const created = start2 ? `Created ${app2.name} (${app2.id}) from the ${template} template in ${where}; its first version is live at ${app2.publishedUrl}.
|
|
@@ -87072,7 +87146,7 @@ var appPush = async ({ context, args }) => {
|
|
|
87072
87146
|
paths.map(
|
|
87073
87147
|
async (path) => buildFileOf({
|
|
87074
87148
|
path: relative3(folder, path).split(sep3).join("/"),
|
|
87075
|
-
bytes: await
|
|
87149
|
+
bytes: await readFile18(path)
|
|
87076
87150
|
})
|
|
87077
87151
|
)
|
|
87078
87152
|
);
|
|
@@ -87142,7 +87216,7 @@ var appWrite = async ({ context, args }) => {
|
|
|
87142
87216
|
const path = resolve9(context.cwd, word3);
|
|
87143
87217
|
const { bytes: _bytes, ...file4 } = buildFileOf({
|
|
87144
87218
|
path: relative3(folder, path).split(sep3).join("/"),
|
|
87145
|
-
bytes: await
|
|
87219
|
+
bytes: await readFile18(path)
|
|
87146
87220
|
});
|
|
87147
87221
|
return file4;
|
|
87148
87222
|
})
|
|
@@ -87270,7 +87344,7 @@ var appPull = async ({ context, args }) => {
|
|
|
87270
87344
|
);
|
|
87271
87345
|
}
|
|
87272
87346
|
for (const file4 of pulled.files) {
|
|
87273
|
-
const target =
|
|
87347
|
+
const target = join29(folder, ...file4.path.split("/"));
|
|
87274
87348
|
await mkdir8(dirname18(target), { recursive: true });
|
|
87275
87349
|
await writeFile6(
|
|
87276
87350
|
target,
|
|
@@ -87289,7 +87363,7 @@ var appPull = async ({ context, args }) => {
|
|
|
87289
87363
|
])
|
|
87290
87364
|
)
|
|
87291
87365
|
};
|
|
87292
|
-
await writeFile6(
|
|
87366
|
+
await writeFile6(join29(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
87293
87367
|
`);
|
|
87294
87368
|
const names = pulled.collections.map((collection) => collection.name);
|
|
87295
87369
|
const where = relative3(context.cwd, folder) || ".";
|
|
@@ -87534,7 +87608,7 @@ var appRefresh = async ({ context, args }) => {
|
|
|
87534
87608
|
};
|
|
87535
87609
|
function recordPageText({ records }) {
|
|
87536
87610
|
if (records.totalItems === 0) return "No records yet.\n";
|
|
87537
|
-
const lines2 = records.items.map((
|
|
87611
|
+
const lines2 = records.items.map((record5) => JSON.stringify(record5)).join("\n");
|
|
87538
87612
|
return `${lines2}
|
|
87539
87613
|
(page ${records.page} of ${records.totalPages}, ${records.totalItems} records)
|
|
87540
87614
|
`;
|
|
@@ -87605,7 +87679,7 @@ var appImport = async ({ context, args }) => {
|
|
|
87605
87679
|
const words = args.words.slice(2);
|
|
87606
87680
|
const [named, collection, file4] = words.length >= 3 ? words : [void 0, ...words];
|
|
87607
87681
|
if (!collection || !file4) throw new CliUsageError(USAGE7);
|
|
87608
|
-
const csv = await
|
|
87682
|
+
const csv = await readFile18(resolve9(context.cwd, file4), "utf8").catch(() => {
|
|
87609
87683
|
throw new CliUsageError(`Cannot read ${file4}`);
|
|
87610
87684
|
});
|
|
87611
87685
|
const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
|
|
@@ -88557,8 +88631,8 @@ async function billing({ context, args }) {
|
|
|
88557
88631
|
|
|
88558
88632
|
// src/services/browser-commands.service.ts
|
|
88559
88633
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
88560
|
-
import { readFile as
|
|
88561
|
-
import { dirname as dirname19, join as
|
|
88634
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
88635
|
+
import { dirname as dirname19, join as join30 } from "node:path";
|
|
88562
88636
|
|
|
88563
88637
|
// src/services/cdp-bridge.service.ts
|
|
88564
88638
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -88978,7 +89052,7 @@ async function turnTokenOf4({
|
|
|
88978
89052
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
88979
89053
|
if (pinned) return pinned;
|
|
88980
89054
|
if (env.LAZE_TURN_FILE) {
|
|
88981
|
-
return
|
|
89055
|
+
return readFile19(env.LAZE_TURN_FILE, "utf8").then(
|
|
88982
89056
|
(text3) => text3.trim(),
|
|
88983
89057
|
() => ""
|
|
88984
89058
|
);
|
|
@@ -89068,7 +89142,7 @@ async function answering({
|
|
|
89068
89142
|
}
|
|
89069
89143
|
function bridgeStatePath({ context, machine: machine2 }) {
|
|
89070
89144
|
const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
89071
|
-
return
|
|
89145
|
+
return join30(dirname19(context.environment.configPath), "bridges", `${safe}.json`);
|
|
89072
89146
|
}
|
|
89073
89147
|
async function bridgePort({
|
|
89074
89148
|
context,
|
|
@@ -89781,7 +89855,7 @@ async function channelSettings({ context, args }) {
|
|
|
89781
89855
|
}
|
|
89782
89856
|
|
|
89783
89857
|
// src/services/chat-actions-commands.service.ts
|
|
89784
|
-
import { readFile as
|
|
89858
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
89785
89859
|
import { basename as basename9, resolve as resolve11 } from "node:path";
|
|
89786
89860
|
|
|
89787
89861
|
// src/rules/app-link.rules.ts
|
|
@@ -90228,7 +90302,7 @@ var files = async ({ context, args, client }) => {
|
|
|
90228
90302
|
};
|
|
90229
90303
|
var fileUpload = async ({ context, args, client }) => {
|
|
90230
90304
|
const path = resolve11(context.cwd, wordAt(args, 3));
|
|
90231
|
-
const bytes = new Uint8Array(await
|
|
90305
|
+
const bytes = new Uint8Array(await readFile20(path));
|
|
90232
90306
|
const answer6 = await uploadFile({
|
|
90233
90307
|
context,
|
|
90234
90308
|
client,
|
|
@@ -93821,11 +93895,11 @@ async function computer({ context, args }) {
|
|
|
93821
93895
|
}
|
|
93822
93896
|
|
|
93823
93897
|
// src/services/connect-commands.service.ts
|
|
93824
|
-
import { readFile as
|
|
93898
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
93825
93899
|
|
|
93826
93900
|
// src/services/mcp-gateway.service.ts
|
|
93827
|
-
import { mkdir as mkdir10, readFile as
|
|
93828
|
-
import { basename as basename11, join as
|
|
93901
|
+
import { mkdir as mkdir10, readFile as readFile21, writeFile as writeFile7 } from "node:fs/promises";
|
|
93902
|
+
import { basename as basename11, join as join31, resolve as resolve13 } from "node:path";
|
|
93829
93903
|
import { createInterface as createInterface2 } from "node:readline";
|
|
93830
93904
|
|
|
93831
93905
|
// src/services/mcp-support.service.ts
|
|
@@ -93961,7 +94035,7 @@ async function relayMcpLines({
|
|
|
93961
94035
|
const github3 = env.LAZE_GITHUB_CONNECTION;
|
|
93962
94036
|
const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
|
|
93963
94037
|
const turnFile = env.LAZE_TURN_FILE;
|
|
93964
|
-
const readTurn = () =>
|
|
94038
|
+
const readTurn = () => readFile21(turnFile, "utf8").then(
|
|
93965
94039
|
(text3) => text3.trim(),
|
|
93966
94040
|
() => ""
|
|
93967
94041
|
);
|
|
@@ -94004,8 +94078,8 @@ function safeName(name3, fallback) {
|
|
|
94004
94078
|
return last && last !== "." && last !== ".." ? last : fallback;
|
|
94005
94079
|
}
|
|
94006
94080
|
async function saveMailFile({ root, file: file4 }) {
|
|
94007
|
-
const dir =
|
|
94008
|
-
const path =
|
|
94081
|
+
const dir = join31(root, safeName(file4.messageId, "message"));
|
|
94082
|
+
const path = join31(dir, safeName(file4.fileName, "attachment"));
|
|
94009
94083
|
await mkdir10(dir, { recursive: true });
|
|
94010
94084
|
await writeFile7(path, Buffer.from(file4.base64, "base64"));
|
|
94011
94085
|
return path;
|
|
@@ -94131,7 +94205,7 @@ async function turnOf({ context }) {
|
|
|
94131
94205
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
94132
94206
|
if (pinned) return pinned;
|
|
94133
94207
|
const file4 = env.LAZE_TURN_FILE;
|
|
94134
|
-
const turn = file4 ? await
|
|
94208
|
+
const turn = file4 ? await readFile22(file4, "utf8").then(
|
|
94135
94209
|
(text3) => text3.trim(),
|
|
94136
94210
|
() => ""
|
|
94137
94211
|
) : "";
|
|
@@ -94255,11 +94329,11 @@ async function suggestServer({
|
|
|
94255
94329
|
}
|
|
94256
94330
|
|
|
94257
94331
|
// src/services/connector-commands.service.ts
|
|
94258
|
-
import { readFile as
|
|
94332
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
94259
94333
|
import { resolve as resolve14 } from "node:path";
|
|
94260
94334
|
|
|
94261
94335
|
// src/services/vault-keychain-commands.service.ts
|
|
94262
|
-
import { readFile as
|
|
94336
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
94263
94337
|
|
|
94264
94338
|
// src/rules/vault-input.rules.ts
|
|
94265
94339
|
function secondsOf(text3) {
|
|
@@ -94680,7 +94754,7 @@ async function secretText({ context, args }) {
|
|
|
94680
94754
|
);
|
|
94681
94755
|
}
|
|
94682
94756
|
const file4 = flagText({ args, name: "from-file" });
|
|
94683
|
-
const text3 = file4 ? await
|
|
94757
|
+
const text3 = file4 ? await readFile23(file4, "utf8") : await context.readStdin();
|
|
94684
94758
|
const trimmed = text3.replace(/\r?\n$/, "");
|
|
94685
94759
|
if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
|
|
94686
94760
|
const held = await placeholdersOf({ env: context.environment.inherited });
|
|
@@ -94701,7 +94775,7 @@ async function keychainOf2({ client, args }) {
|
|
|
94701
94775
|
const me = await client.get("/api/agents/me");
|
|
94702
94776
|
return { kind: "personal", ownerUserId: me.id };
|
|
94703
94777
|
}
|
|
94704
|
-
function
|
|
94778
|
+
function settingsOf3(args) {
|
|
94705
94779
|
const lease = flagText({ args, name: "lease" }) || flagText({ args, name: "max-lease" });
|
|
94706
94780
|
const approvers = args.lists.approver;
|
|
94707
94781
|
const everyUseAsks = yesNoOf({ args, name: "every-use-asks" });
|
|
@@ -94745,7 +94819,7 @@ var add4 = async ({ context, args }) => {
|
|
|
94745
94819
|
name: name3,
|
|
94746
94820
|
keychain: await keychainOf2({ client, args }),
|
|
94747
94821
|
sensitivity: levelOf2(args) ?? "checked",
|
|
94748
|
-
...
|
|
94822
|
+
...settingsOf3(args),
|
|
94749
94823
|
secret
|
|
94750
94824
|
});
|
|
94751
94825
|
if (args.flags.json) return printJson4({ context, data: created });
|
|
@@ -94755,7 +94829,7 @@ var add4 = async ({ context, args }) => {
|
|
|
94755
94829
|
);
|
|
94756
94830
|
};
|
|
94757
94831
|
var update = async ({ context, args }) => {
|
|
94758
|
-
const settings3 = { ...
|
|
94832
|
+
const settings3 = { ...settingsOf3(args), ...deviceApprovalOf(args) };
|
|
94759
94833
|
const { client, profile } = await signedIn({ context, args });
|
|
94760
94834
|
if (Object.keys(settings3).length === 0) throw new CliUsageError(VAULT_USAGE);
|
|
94761
94835
|
const word3 = args.words[2];
|
|
@@ -94925,7 +94999,7 @@ async function keyText({ context, args }) {
|
|
|
94925
94999
|
throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
|
|
94926
95000
|
}
|
|
94927
95001
|
const file4 = flagText({ args, name: "from-file" });
|
|
94928
|
-
const text3 = file4 ? await
|
|
95002
|
+
const text3 = file4 ? await readFile24(resolve14(context.cwd, file4), "utf8") : await context.readStdin();
|
|
94929
95003
|
const trimmed = text3.trim();
|
|
94930
95004
|
if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
|
|
94931
95005
|
return trimmed;
|
|
@@ -95314,7 +95388,7 @@ async function conversationDelete({ context, args }) {
|
|
|
95314
95388
|
}
|
|
95315
95389
|
|
|
95316
95390
|
// src/services/discord-commands.service.ts
|
|
95317
|
-
import { readFile as
|
|
95391
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
95318
95392
|
import { resolve as resolve15 } from "node:path";
|
|
95319
95393
|
|
|
95320
95394
|
// ../../modules/discord/contract/src/discord.ts
|
|
@@ -95662,7 +95736,7 @@ async function secretsOf({ context, args }) {
|
|
|
95662
95736
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
95663
95737
|
if (fromConnection) return { fromConnection };
|
|
95664
95738
|
const file4 = flagText({ args, name: "from-file" });
|
|
95665
|
-
const text3 = file4 ? await
|
|
95739
|
+
const text3 = file4 ? await readFile25(resolve15(context.cwd, file4), "utf8") : await context.readStdin();
|
|
95666
95740
|
const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
95667
95741
|
if (lines2.length !== 2) {
|
|
95668
95742
|
throw new CliUsageError(
|
|
@@ -95932,8 +96006,8 @@ var DOMAINS_USAGE = `Usage:
|
|
|
95932
96006
|
var printJson5 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
|
|
95933
96007
|
`);
|
|
95934
96008
|
function printDomain(context, row) {
|
|
95935
|
-
const
|
|
95936
|
-
context.out(`${row.domain} ${
|
|
96009
|
+
const join39 = row.autoJoin ? "auto-join on" : "auto-join off";
|
|
96010
|
+
context.out(`${row.domain} ${join39}${row.enforced ? " single sign-on enforced" : ""}
|
|
95937
96011
|
`);
|
|
95938
96012
|
}
|
|
95939
96013
|
async function list5({ context, args }) {
|
|
@@ -95965,7 +96039,7 @@ async function domains({ context, args }) {
|
|
|
95965
96039
|
}
|
|
95966
96040
|
|
|
95967
96041
|
// src/services/emoji-commands.service.ts
|
|
95968
|
-
import { readFile as
|
|
96042
|
+
import { readFile as readFile26 } from "node:fs/promises";
|
|
95969
96043
|
import { resolve as resolve16 } from "node:path";
|
|
95970
96044
|
var EMOJI_USAGE = `Usage:
|
|
95971
96045
|
laze emoji list [--json] the workspace's custom emoji, aliases and who added each
|
|
@@ -96006,7 +96080,7 @@ async function addEmoji({ context, args, client }) {
|
|
|
96006
96080
|
const file4 = wordAt4(args, 3);
|
|
96007
96081
|
let bytes;
|
|
96008
96082
|
try {
|
|
96009
|
-
bytes = new Uint8Array(await
|
|
96083
|
+
bytes = new Uint8Array(await readFile26(resolve16(context.cwd, file4)));
|
|
96010
96084
|
} catch {
|
|
96011
96085
|
throw new CliUsageError(`Cannot read ${file4}.`);
|
|
96012
96086
|
}
|
|
@@ -96345,7 +96419,7 @@ var ExternalChannelBannerSlot = externalUi.component("channel-banner");
|
|
|
96345
96419
|
var ExternalSharingHooksToken = externalUi.hooks("sharing");
|
|
96346
96420
|
|
|
96347
96421
|
// src/services/workspace-commands.service.ts
|
|
96348
|
-
import { readFile as
|
|
96422
|
+
import { readFile as readFile27 } from "node:fs/promises";
|
|
96349
96423
|
import { resolve as resolve17 } from "node:path";
|
|
96350
96424
|
var ROLE_NAMES2 = {
|
|
96351
96425
|
OWNER: "Owner",
|
|
@@ -96528,7 +96602,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
|
|
|
96528
96602
|
async function readLogo({ context, file: file4 }) {
|
|
96529
96603
|
let bytes;
|
|
96530
96604
|
try {
|
|
96531
|
-
bytes = new Uint8Array(await
|
|
96605
|
+
bytes = new Uint8Array(await readFile27(resolve17(context.cwd, file4)));
|
|
96532
96606
|
} catch {
|
|
96533
96607
|
throw new CliUsageError(`No file to read at ${file4}.`);
|
|
96534
96608
|
}
|
|
@@ -97163,7 +97237,7 @@ async function agentFeedAccess({
|
|
|
97163
97237
|
}
|
|
97164
97238
|
|
|
97165
97239
|
// src/services/feed-commands.service.ts
|
|
97166
|
-
import { readFile as
|
|
97240
|
+
import { readFile as readFile28 } from "node:fs/promises";
|
|
97167
97241
|
import { resolve as resolve18 } from "node:path";
|
|
97168
97242
|
|
|
97169
97243
|
// ../../modules/feed/contract/src/feed.delegate.ts
|
|
@@ -98317,7 +98391,7 @@ async function feedTurnOf({
|
|
|
98317
98391
|
const read4 = async () => {
|
|
98318
98392
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
98319
98393
|
if (pinned) return pinned;
|
|
98320
|
-
if (env.LAZE_TURN_FILE) return (await
|
|
98394
|
+
if (env.LAZE_TURN_FILE) return (await readFile28(env.LAZE_TURN_FILE, "utf8")).trim();
|
|
98321
98395
|
return agent3 ? connectedTurnTokenOf({ client, channelId: channel }) : "";
|
|
98322
98396
|
};
|
|
98323
98397
|
const turn = await read4().catch(() => "");
|
|
@@ -98391,7 +98465,7 @@ async function bodyOf2({
|
|
|
98391
98465
|
flags: flags2
|
|
98392
98466
|
}) {
|
|
98393
98467
|
const body = { ...flags2.fields };
|
|
98394
|
-
const read4 = (source) => "file" in source ?
|
|
98468
|
+
const read4 = (source) => "file" in source ? readFile28(resolve18(context.cwd, source.file), "utf8") : source.text;
|
|
98395
98469
|
for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read4(source);
|
|
98396
98470
|
if (flags2.rich) {
|
|
98397
98471
|
const text3 = await read4(flags2.rich.source);
|
|
@@ -98668,7 +98742,7 @@ async function textFlag({
|
|
|
98668
98742
|
}) {
|
|
98669
98743
|
const value = flagText({ args, name: name3 });
|
|
98670
98744
|
if (!value.startsWith("@")) return value;
|
|
98671
|
-
return
|
|
98745
|
+
return readFile28(resolve18(context.cwd, value.slice(1)), "utf8");
|
|
98672
98746
|
}
|
|
98673
98747
|
async function feedList({ context, args }) {
|
|
98674
98748
|
const { client, profile } = await signedIn({ context, args });
|
|
@@ -98758,7 +98832,7 @@ async function ranksOf({
|
|
|
98758
98832
|
}) {
|
|
98759
98833
|
const file4 = flagText({ args, name: "file" });
|
|
98760
98834
|
if (file4) {
|
|
98761
|
-
const parsed = JSON.parse(await
|
|
98835
|
+
const parsed = JSON.parse(await readFile28(resolve18(context.cwd, file4), "utf8"));
|
|
98762
98836
|
if (Array.isArray(parsed)) return parsed;
|
|
98763
98837
|
throw new CliUsageError("--file holds a list of {itemId, priority}");
|
|
98764
98838
|
}
|
|
@@ -98873,7 +98947,7 @@ async function feed({ context, args }) {
|
|
|
98873
98947
|
}
|
|
98874
98948
|
|
|
98875
98949
|
// src/services/github-commands.service.ts
|
|
98876
|
-
import { readFile as
|
|
98950
|
+
import { readFile as readFile29 } from "node:fs/promises";
|
|
98877
98951
|
|
|
98878
98952
|
// src/rules/github-signature.rules.ts
|
|
98879
98953
|
var TURN_SEPARATOR = "~";
|
|
@@ -98943,7 +99017,7 @@ var REAL_GH = "/usr/bin/gh";
|
|
|
98943
99017
|
var NOT_SET = "laze: agent_github_not_set: this agent has no GitHub connection. Run `laze github request --repo <owner/name>` to post a card that gets it in one click, or its owner runs `laze agent set-github <agent> <connection>`.";
|
|
98944
99018
|
async function turnFileToken({ env }) {
|
|
98945
99019
|
if (!env.LAZE_TURN_FILE) return "";
|
|
98946
|
-
return
|
|
99020
|
+
return readFile29(env.LAZE_TURN_FILE, "utf8").then(
|
|
98947
99021
|
(text3) => text3.trim(),
|
|
98948
99022
|
() => ""
|
|
98949
99023
|
);
|
|
@@ -98977,7 +99051,7 @@ async function githubGh({
|
|
|
98977
99051
|
args: args.rest,
|
|
98978
99052
|
agentName: profile.name ?? "An agent",
|
|
98979
99053
|
threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
|
|
98980
|
-
readBodyFile: (path) => path === "-" ? context.readStdin() :
|
|
99054
|
+
readBodyFile: (path) => path === "-" ? context.readStdin() : readFile29(path, "utf8")
|
|
98981
99055
|
});
|
|
98982
99056
|
return context.runCommand({
|
|
98983
99057
|
command: [REAL_GH, ...ghArgs],
|
|
@@ -99643,11 +99717,11 @@ async function ip({ context, args }) {
|
|
|
99643
99717
|
// src/services/join-commands.service.ts
|
|
99644
99718
|
import { rm as rm16 } from "node:fs/promises";
|
|
99645
99719
|
import { hostname as hostname9 } from "node:os";
|
|
99646
|
-
import { dirname as dirname22, join as
|
|
99720
|
+
import { dirname as dirname22, join as join32 } from "node:path";
|
|
99647
99721
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
99648
99722
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
99649
99723
|
function pendingPathOf({ context }) {
|
|
99650
|
-
return
|
|
99724
|
+
return join32(dirname22(context.environment.configPath), "join", "pending.json");
|
|
99651
99725
|
}
|
|
99652
99726
|
async function readPending({
|
|
99653
99727
|
context,
|
|
@@ -100929,18 +101003,18 @@ async function serveMcp({
|
|
|
100929
101003
|
}
|
|
100930
101004
|
|
|
100931
101005
|
// src/services/memory-commands.service.ts
|
|
100932
|
-
import { readdir as readdir7, readFile as
|
|
100933
|
-
import { join as
|
|
101006
|
+
import { readdir as readdir7, readFile as readFile31 } from "node:fs/promises";
|
|
101007
|
+
import { join as join33, resolve as resolve20 } from "node:path";
|
|
100934
101008
|
|
|
100935
101009
|
// src/services/mount-files.service.ts
|
|
100936
|
-
import { mkdir as mkdir11, readFile as
|
|
101010
|
+
import { mkdir as mkdir11, readFile as readFile30, rm as rm17, writeFile as writeFile8 } from "node:fs/promises";
|
|
100937
101011
|
import { dirname as dirname23, relative as relative4, resolve as resolve19 } from "node:path";
|
|
100938
101012
|
async function textArgument({
|
|
100939
101013
|
context,
|
|
100940
101014
|
value
|
|
100941
101015
|
}) {
|
|
100942
101016
|
if (value === "-") return context.readStdin();
|
|
100943
|
-
if (value.startsWith("@")) return
|
|
101017
|
+
if (value.startsWith("@")) return readFile30(resolve19(context.cwd, value.slice(1)), "utf8");
|
|
100944
101018
|
return value;
|
|
100945
101019
|
}
|
|
100946
101020
|
function turnChannel({ context, args }) {
|
|
@@ -101087,7 +101161,7 @@ async function turnTokenOf5({ context }) {
|
|
|
101087
101161
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
101088
101162
|
if (pinned) return pinned;
|
|
101089
101163
|
if (!env.LAZE_TURN_FILE) return "";
|
|
101090
|
-
return
|
|
101164
|
+
return readFile31(env.LAZE_TURN_FILE, "utf8").then(
|
|
101091
101165
|
(text3) => text3.trim(),
|
|
101092
101166
|
() => ""
|
|
101093
101167
|
);
|
|
@@ -101217,15 +101291,15 @@ async function siestaImport({
|
|
|
101217
101291
|
dir
|
|
101218
101292
|
}) {
|
|
101219
101293
|
const root = resolve20(context.cwd, dir);
|
|
101220
|
-
const log = await
|
|
101221
|
-
const names = (await readdir7(
|
|
101294
|
+
const log = await readFile31(join33(root, "LOG.md"));
|
|
101295
|
+
const names = (await readdir7(join33(root, "tree")).catch(() => [])).filter(
|
|
101222
101296
|
(name3) => /^\d{1,6}-\d{1,6}\.md$/.test(name3)
|
|
101223
101297
|
);
|
|
101224
101298
|
const tree = Object.fromEntries(
|
|
101225
101299
|
await Promise.all(
|
|
101226
101300
|
names.map(async (name3) => [
|
|
101227
101301
|
name3.slice(0, -3),
|
|
101228
|
-
(await
|
|
101302
|
+
(await readFile31(join33(root, "tree", name3))).toString("base64")
|
|
101229
101303
|
])
|
|
101230
101304
|
)
|
|
101231
101305
|
);
|
|
@@ -101245,15 +101319,15 @@ async function memoryImport({ context, args }) {
|
|
|
101245
101319
|
const dir = flagText({ args, name: "optmem" });
|
|
101246
101320
|
if (!dir) throw new CliUsageError(USAGE14);
|
|
101247
101321
|
const root = resolve20(context.cwd, dir);
|
|
101248
|
-
const log = await
|
|
101249
|
-
const sizes2 = (await readdir7(
|
|
101322
|
+
const log = await readFile31(join33(root, "LOG.txt"));
|
|
101323
|
+
const sizes2 = (await readdir7(join33(root, "TREE")).catch(() => [])).filter(
|
|
101250
101324
|
(name3) => /^\d{1,4}$/.test(name3)
|
|
101251
101325
|
);
|
|
101252
101326
|
const tree = Object.fromEntries(
|
|
101253
101327
|
await Promise.all(
|
|
101254
101328
|
sizes2.map(async (size) => [
|
|
101255
101329
|
size,
|
|
101256
|
-
(await
|
|
101330
|
+
(await readFile31(join33(root, "TREE", size))).toString("base64")
|
|
101257
101331
|
])
|
|
101258
101332
|
)
|
|
101259
101333
|
);
|
|
@@ -101850,8 +101924,8 @@ async function openclaw({
|
|
|
101850
101924
|
|
|
101851
101925
|
// src/services/operator-key-commands.service.ts
|
|
101852
101926
|
import { createHash as createHash10, randomBytes as randomBytes5 } from "node:crypto";
|
|
101853
|
-
import { mkdir as mkdir12, readFile as
|
|
101854
|
-
import { dirname as dirname24, join as
|
|
101927
|
+
import { mkdir as mkdir12, readFile as readFile32, rm as rm18, writeFile as writeFile9 } from "node:fs/promises";
|
|
101928
|
+
import { dirname as dirname24, join as join34 } from "node:path";
|
|
101855
101929
|
|
|
101856
101930
|
// ../../modules/audit-log/contract/src/audit-log.api.ts
|
|
101857
101931
|
var auditEntrySchemaDefinition = external_exports.object({
|
|
@@ -103691,7 +103765,7 @@ Ops function leases (ADR-214), instead of reading the database:
|
|
|
103691
103765
|
call one function of an approved lease; a cut
|
|
103692
103766
|
list says so and names the cursor of the next page`;
|
|
103693
103767
|
var POLL_MS3 = 5e3;
|
|
103694
|
-
var keyFile = ({ context, keyId }) =>
|
|
103768
|
+
var keyFile = ({ context, keyId }) => join34(dirname24(context.environment.configPath), "operator-keys", keyId.replaceAll("/", "_"));
|
|
103695
103769
|
async function saveSecret({
|
|
103696
103770
|
context,
|
|
103697
103771
|
keyId,
|
|
@@ -103802,7 +103876,7 @@ async function useKey({
|
|
|
103802
103876
|
if (!keyId) throw new CliUsageError(OPERATOR_KEY_USAGE);
|
|
103803
103877
|
const { client } = await signedIn({ context, args });
|
|
103804
103878
|
const path = keyFile({ context, keyId });
|
|
103805
|
-
const secret = await
|
|
103879
|
+
const secret = await readFile32(path, "utf8").catch(() => null);
|
|
103806
103880
|
if (secret === null) {
|
|
103807
103881
|
throw new CliUsageError(`No operator key ${keyId} is kept on this machine.`);
|
|
103808
103882
|
}
|
|
@@ -103939,7 +104013,7 @@ ${OPS_USAGE}`);
|
|
|
103939
104013
|
|
|
103940
104014
|
// src/services/release-watch.service.ts
|
|
103941
104015
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
103942
|
-
import { dirname as dirname25, join as
|
|
104016
|
+
import { dirname as dirname25, join as join35 } from "node:path";
|
|
103943
104017
|
var RETRY_AFTER_MS = 6 * 60 * 60 * 1e3;
|
|
103944
104018
|
async function scriptOf(context) {
|
|
103945
104019
|
const script = context.program.at(-1) ?? "";
|
|
@@ -103957,14 +104031,14 @@ async function startedUpdate({
|
|
|
103957
104031
|
const plan2 = updatePlanOf({ script: await scriptOf(context) });
|
|
103958
104032
|
if (plan2.kind !== "install") return null;
|
|
103959
104033
|
const folder = dirname25(context.environment.configPath);
|
|
103960
|
-
const stamp =
|
|
104034
|
+
const stamp = join35(folder, "auto-update.json");
|
|
103961
104035
|
const last = await readStateJson({ path: stamp }) ?? null;
|
|
103962
104036
|
const now = context.nowMs();
|
|
103963
104037
|
if (last?.server === server && now - last.atMs < RETRY_AFTER_MS) return null;
|
|
103964
104038
|
await writeStateJson({ path: stamp, value: { server, atMs: now } });
|
|
103965
104039
|
context.processes.spawnDetached({
|
|
103966
104040
|
argv: [...context.program, "update"],
|
|
103967
|
-
logPath:
|
|
104041
|
+
logPath: join35(folder, "auto-update.log")
|
|
103968
104042
|
});
|
|
103969
104043
|
return { manager: plan2.manager };
|
|
103970
104044
|
}
|
|
@@ -104260,8 +104334,8 @@ async function schedule({ context, args }) {
|
|
|
104260
104334
|
}
|
|
104261
104335
|
|
|
104262
104336
|
// src/services/skill-commands.service.ts
|
|
104263
|
-
import { readdir as readdir8, readFile as
|
|
104264
|
-
import { join as
|
|
104337
|
+
import { readdir as readdir8, readFile as readFile33 } from "node:fs/promises";
|
|
104338
|
+
import { join as join36, relative as relative5, resolve as resolve22 } from "node:path";
|
|
104265
104339
|
var USAGE18 = `Usage:
|
|
104266
104340
|
laze skill list [--agent <agentId>]
|
|
104267
104341
|
laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
|
|
@@ -104282,8 +104356,8 @@ async function folderFiles({ root }) {
|
|
|
104282
104356
|
const files2 = [];
|
|
104283
104357
|
for (const entry2 of entries) {
|
|
104284
104358
|
if (!entry2.isFile()) continue;
|
|
104285
|
-
const full =
|
|
104286
|
-
files2.push({ path: relative5(root, full), content: await
|
|
104359
|
+
const full = join36(entry2.parentPath, entry2.name);
|
|
104360
|
+
files2.push({ path: relative5(root, full), content: await readFile33(full, "utf8") });
|
|
104287
104361
|
}
|
|
104288
104362
|
return files2.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
104289
104363
|
}
|
|
@@ -104381,7 +104455,7 @@ async function skillUpdate({ context, args }) {
|
|
|
104381
104455
|
if (!name3 || !newName && description === void 0 && !skillMdFile) {
|
|
104382
104456
|
throw new CliUsageError(USAGE18);
|
|
104383
104457
|
}
|
|
104384
|
-
const skillMd = skillMdFile ? await
|
|
104458
|
+
const skillMd = skillMdFile ? await readFile33(resolve22(context.cwd, skillMdFile), "utf8") : void 0;
|
|
104385
104459
|
const { client } = await signedIn({ context, args });
|
|
104386
104460
|
const updated = await client.post("/api/skills/update", {
|
|
104387
104461
|
name: name3,
|
|
@@ -104427,7 +104501,7 @@ async function skill({ context, args }) {
|
|
|
104427
104501
|
}
|
|
104428
104502
|
|
|
104429
104503
|
// src/services/slack-commands.service.ts
|
|
104430
|
-
import { readFile as
|
|
104504
|
+
import { readFile as readFile34 } from "node:fs/promises";
|
|
104431
104505
|
import { resolve as resolve23 } from "node:path";
|
|
104432
104506
|
var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
|
|
104433
104507
|
laze slack overview connected Slack workspaces, mirrors, your link
|
|
@@ -104478,7 +104552,7 @@ async function secretLines({ context, args }) {
|
|
|
104478
104552
|
throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
|
|
104479
104553
|
}
|
|
104480
104554
|
const file4 = flagText({ args, name: "from-file" });
|
|
104481
|
-
const text3 = file4 ? await
|
|
104555
|
+
const text3 = file4 ? await readFile34(resolve23(context.cwd, file4), "utf8") : await context.readStdin();
|
|
104482
104556
|
return text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
104483
104557
|
}
|
|
104484
104558
|
async function secretsOf2({
|
|
@@ -104796,7 +104870,7 @@ async function slack({
|
|
|
104796
104870
|
}
|
|
104797
104871
|
|
|
104798
104872
|
// src/services/sso-commands.service.ts
|
|
104799
|
-
import { readFile as
|
|
104873
|
+
import { readFile as readFile35 } from "node:fs/promises";
|
|
104800
104874
|
var SSO_USAGE = `Usage:
|
|
104801
104875
|
laze sso domains claimed domains and how each signs in (admins)
|
|
104802
104876
|
laze sso claim <domain> the TXT record that proves the domain
|
|
@@ -104883,7 +104957,7 @@ function refuseSecretFlags({ args }) {
|
|
|
104883
104957
|
}
|
|
104884
104958
|
async function clientSecretOf({ context, args }) {
|
|
104885
104959
|
const file4 = flagText({ args, name: "from-file" });
|
|
104886
|
-
const text3 = file4 ? await
|
|
104960
|
+
const text3 = file4 ? await readFile35(file4, "utf8") : await context.readStdin();
|
|
104887
104961
|
const secret = text3.trim();
|
|
104888
104962
|
if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
|
|
104889
104963
|
return secret;
|
|
@@ -105227,8 +105301,8 @@ async function checkInstalled({
|
|
|
105227
105301
|
}
|
|
105228
105302
|
|
|
105229
105303
|
// src/services/vault-env-commands.service.ts
|
|
105230
|
-
import { readFile as
|
|
105231
|
-
import { dirname as dirname26, join as
|
|
105304
|
+
import { readFile as readFile36, stat as stat12 } from "node:fs/promises";
|
|
105305
|
+
import { dirname as dirname26, join as join37, resolve as resolve24 } from "node:path";
|
|
105232
105306
|
|
|
105233
105307
|
// src/rules/vault-manifest.rules.ts
|
|
105234
105308
|
var VARIABLE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -105610,7 +105684,7 @@ async function manifestPathOf({
|
|
|
105610
105684
|
const environment = flagText({ args, name: "env" });
|
|
105611
105685
|
const file4 = environment ? `.env.${environment}.vault` : ".env.vault";
|
|
105612
105686
|
for (let dir = resolve24(context.cwd); ; dir = dirname26(dir)) {
|
|
105613
|
-
if (await isFile(
|
|
105687
|
+
if (await isFile(join37(dir, file4))) return join37(dir, file4);
|
|
105614
105688
|
if (dirname26(dir) === dir) break;
|
|
105615
105689
|
}
|
|
105616
105690
|
throw new CliUsageError(`laze vault: no ${file4} here or in a parent folder
|
|
@@ -105621,7 +105695,7 @@ async function manifestOf({
|
|
|
105621
105695
|
args
|
|
105622
105696
|
}) {
|
|
105623
105697
|
const file4 = await manifestPathOf({ context, args });
|
|
105624
|
-
const text3 = await
|
|
105698
|
+
const text3 = await readFile36(file4, "utf8").catch(() => {
|
|
105625
105699
|
throw new CliUsageError(`laze vault: cannot read ${file4}`);
|
|
105626
105700
|
});
|
|
105627
105701
|
return { file: file4, lines: parseManifest({ text: text3, file: file4 }) };
|
|
@@ -105983,7 +106057,7 @@ async function vaultScrub({ context, args }) {
|
|
|
105983
106057
|
}
|
|
105984
106058
|
|
|
105985
106059
|
// src/services/whatsapp-business-commands.service.ts
|
|
105986
|
-
import { readFile as
|
|
106060
|
+
import { readFile as readFile37 } from "node:fs/promises";
|
|
105987
106061
|
import { resolve as resolve25 } from "node:path";
|
|
105988
106062
|
|
|
105989
106063
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
|
|
@@ -106480,7 +106554,7 @@ async function secretsOf3({ context, args }) {
|
|
|
106480
106554
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
106481
106555
|
if (fromConnection) return { fromConnection };
|
|
106482
106556
|
const file4 = flagText({ args, name: "from-file" });
|
|
106483
|
-
const text3 = file4 ? await
|
|
106557
|
+
const text3 = file4 ? await readFile37(resolve25(context.cwd, file4), "utf8") : await context.readStdin();
|
|
106484
106558
|
const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
106485
106559
|
if (lines2.length !== 2) {
|
|
106486
106560
|
throw new CliUsageError(
|
|
@@ -107687,8 +107761,8 @@ import {
|
|
|
107687
107761
|
randomBytes as randomBytes6,
|
|
107688
107762
|
sign
|
|
107689
107763
|
} from "node:crypto";
|
|
107690
|
-
import { chmod, link, mkdir as mkdir13, readFile as
|
|
107691
|
-
import { dirname as dirname27, join as
|
|
107764
|
+
import { chmod, link, mkdir as mkdir13, readFile as readFile38, rm as rm21, writeFile as writeFile11 } from "node:fs/promises";
|
|
107765
|
+
import { dirname as dirname27, join as join38 } from "node:path";
|
|
107692
107766
|
var KEYCHAIN_SERVICE = "laze-cli-machine-key";
|
|
107693
107767
|
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((resolve27, reject) => {
|
|
107694
107768
|
const child = execFile2(
|
|
@@ -107728,11 +107802,11 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
107728
107802
|
});
|
|
107729
107803
|
}
|
|
107730
107804
|
get metaPath() {
|
|
107731
|
-
return
|
|
107805
|
+
return join38(dirname27(this.options.configPath), "machine-key.json");
|
|
107732
107806
|
}
|
|
107733
107807
|
/** Named by the key, so two CLIs making a key at once never overwrite each other's. */
|
|
107734
107808
|
pemPathOf(jwk) {
|
|
107735
|
-
return
|
|
107809
|
+
return join38(dirname27(this.options.configPath), `machine-key-${shortOf(jwk)}.pem`);
|
|
107736
107810
|
}
|
|
107737
107811
|
/** The Keychain item's account: one per config file and key. */
|
|
107738
107812
|
accountOf(jwk) {
|
|
@@ -107760,7 +107834,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
107760
107834
|
async read() {
|
|
107761
107835
|
let meta3;
|
|
107762
107836
|
try {
|
|
107763
|
-
meta3 = machineKeyRegistrationSchema.parse(JSON.parse(await
|
|
107837
|
+
meta3 = machineKeyRegistrationSchema.parse(JSON.parse(await readFile38(this.metaPath, "utf8")));
|
|
107764
107838
|
} catch {
|
|
107765
107839
|
return null;
|
|
107766
107840
|
}
|
|
@@ -107775,7 +107849,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
107775
107849
|
"-w"
|
|
107776
107850
|
],
|
|
107777
107851
|
timeoutMs: 1e4
|
|
107778
|
-
}) : await
|
|
107852
|
+
}) : await readFile38(this.pemPathOf(meta3.jwk), "utf8");
|
|
107779
107853
|
return keyOf2({ meta: meta3, privateKey: createPrivateKey(pemOf(pem)) });
|
|
107780
107854
|
}
|
|
107781
107855
|
async make() {
|
|
@@ -107917,7 +107991,7 @@ function machineProofFetch({
|
|
|
107917
107991
|
// src/services/processes.service.ts
|
|
107918
107992
|
import { execFile as execFile3, spawn as spawn4, spawnSync } from "node:child_process";
|
|
107919
107993
|
import { closeSync, mkdirSync, openSync, renameSync, statSync } from "node:fs";
|
|
107920
|
-
import { readFile as
|
|
107994
|
+
import { readFile as readFile39, readlink } from "node:fs/promises";
|
|
107921
107995
|
import { dirname as dirname28 } from "node:path";
|
|
107922
107996
|
import { promisify as promisify2 } from "node:util";
|
|
107923
107997
|
var run3 = promisify2(execFile3);
|
|
@@ -107931,14 +108005,14 @@ function alive(pid) {
|
|
|
107931
108005
|
}
|
|
107932
108006
|
}
|
|
107933
108007
|
async function argsOf2(pid) {
|
|
107934
|
-
const raw = await
|
|
108008
|
+
const raw = await readFile39(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
|
|
107935
108009
|
if (raw) return raw.split("\0").filter(Boolean);
|
|
107936
108010
|
const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
|
|
107937
108011
|
const line = listed?.stdout.trim();
|
|
107938
108012
|
return line ? line.split(/\s+/) : void 0;
|
|
107939
108013
|
}
|
|
107940
108014
|
async function parentOf(pid) {
|
|
107941
|
-
const stat13 = await
|
|
108015
|
+
const stat13 = await readFile39(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
107942
108016
|
const fromStat = stat13 ? Number(stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
|
|
107943
108017
|
if (fromStat > 0) return fromStat;
|
|
107944
108018
|
const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
|
|
@@ -107946,7 +108020,7 @@ async function parentOf(pid) {
|
|
|
107946
108020
|
return parent > 0 ? parent : void 0;
|
|
107947
108021
|
}
|
|
107948
108022
|
async function startOf(pid) {
|
|
107949
|
-
const stat13 = await
|
|
108023
|
+
const stat13 = await readFile39(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
107950
108024
|
const ticks = stat13 ? stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[19] : void 0;
|
|
107951
108025
|
if (ticks) return ticks;
|
|
107952
108026
|
const listed = await run3("ps", ["-o", "lstart=", "-p", String(pid)]).catch(() => void 0);
|
|
@@ -108136,7 +108210,7 @@ if (true) {
|
|
|
108136
108210
|
err: (text3) => void process.stderr.write(text3),
|
|
108137
108211
|
readStdin,
|
|
108138
108212
|
stdoutIsTerminal: process.stdout.isTTY === true,
|
|
108139
|
-
lazeInstalls: () => scanLazeInstalls({ env: environment.inherited, home:
|
|
108213
|
+
lazeInstalls: () => scanLazeInstalls({ env: environment.inherited, home: homedir6() }),
|
|
108140
108214
|
...ask ? { ask } : {},
|
|
108141
108215
|
sleep,
|
|
108142
108216
|
nowMs: nowMs2,
|