@lazehq/cli 0.1.85 → 0.1.87
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 +948 -741
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -849,9 +849,9 @@ var require_node_gyp_build = __commonJS({
|
|
|
849
849
|
var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
|
|
850
850
|
if (debug) return debug;
|
|
851
851
|
}
|
|
852
|
-
var prebuild =
|
|
852
|
+
var prebuild = resolve26(dir);
|
|
853
853
|
if (prebuild) return prebuild;
|
|
854
|
-
var nearby =
|
|
854
|
+
var nearby = resolve26(path.dirname(process.execPath));
|
|
855
855
|
if (nearby) return nearby;
|
|
856
856
|
var target = [
|
|
857
857
|
"platform=" + platform,
|
|
@@ -867,7 +867,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
867
867
|
// eslint-disable-line
|
|
868
868
|
].filter(Boolean).join(" ");
|
|
869
869
|
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
870
|
-
function
|
|
870
|
+
function resolve26(dir2) {
|
|
871
871
|
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
872
872
|
var tuple2 = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
873
873
|
if (!tuple2) return;
|
|
@@ -3244,7 +3244,7 @@ var require_websocket = __commonJS({
|
|
|
3244
3244
|
var http = __require("http");
|
|
3245
3245
|
var net = __require("net");
|
|
3246
3246
|
var tls = __require("tls");
|
|
3247
|
-
var { randomBytes:
|
|
3247
|
+
var { randomBytes: randomBytes6, createHash: createHash9 } = __require("crypto");
|
|
3248
3248
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
3249
3249
|
var { URL: URL3 } = __require("url");
|
|
3250
3250
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -3782,7 +3782,7 @@ var require_websocket = __commonJS({
|
|
|
3782
3782
|
}
|
|
3783
3783
|
}
|
|
3784
3784
|
const defaultPort = isSecure ? 443 : 80;
|
|
3785
|
-
const key =
|
|
3785
|
+
const key = randomBytes6(16).toString("base64");
|
|
3786
3786
|
const request2 = isSecure ? https.request : http.request;
|
|
3787
3787
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
3788
3788
|
let perMessageDeflate;
|
|
@@ -4193,7 +4193,7 @@ var require_stream = __commonJS({
|
|
|
4193
4193
|
};
|
|
4194
4194
|
duplex._final = function(callback) {
|
|
4195
4195
|
if (ws.readyState === ws.CONNECTING) {
|
|
4196
|
-
ws.once("open", function
|
|
4196
|
+
ws.once("open", function open6() {
|
|
4197
4197
|
duplex._final(callback);
|
|
4198
4198
|
});
|
|
4199
4199
|
return;
|
|
@@ -4214,7 +4214,7 @@ var require_stream = __commonJS({
|
|
|
4214
4214
|
};
|
|
4215
4215
|
duplex._write = function(chunk, encoding, callback) {
|
|
4216
4216
|
if (ws.readyState === ws.CONNECTING) {
|
|
4217
|
-
ws.once("open", function
|
|
4217
|
+
ws.once("open", function open6() {
|
|
4218
4218
|
duplex._write(chunk, encoding, callback);
|
|
4219
4219
|
});
|
|
4220
4220
|
return;
|
|
@@ -7314,9 +7314,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
7314
7314
|
}
|
|
7315
7315
|
close(callback) {
|
|
7316
7316
|
if (callback === void 0) {
|
|
7317
|
-
return new Promise((
|
|
7317
|
+
return new Promise((resolve26, reject) => {
|
|
7318
7318
|
this.close((err, data) => {
|
|
7319
|
-
return err ? reject(err) :
|
|
7319
|
+
return err ? reject(err) : resolve26(data);
|
|
7320
7320
|
});
|
|
7321
7321
|
});
|
|
7322
7322
|
}
|
|
@@ -7354,9 +7354,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
7354
7354
|
err = null;
|
|
7355
7355
|
}
|
|
7356
7356
|
if (callback === void 0) {
|
|
7357
|
-
return new Promise((
|
|
7357
|
+
return new Promise((resolve26, reject) => {
|
|
7358
7358
|
this.destroy(err, (err2, data) => {
|
|
7359
|
-
return err2 ? reject(err2) :
|
|
7359
|
+
return err2 ? reject(err2) : resolve26(data);
|
|
7360
7360
|
});
|
|
7361
7361
|
});
|
|
7362
7362
|
}
|
|
@@ -12311,12 +12311,12 @@ upgrade: ${upgrade2}\r
|
|
|
12311
12311
|
cb();
|
|
12312
12312
|
}
|
|
12313
12313
|
}
|
|
12314
|
-
const waitForDrain = () => new Promise((
|
|
12314
|
+
const waitForDrain = () => new Promise((resolve26, reject) => {
|
|
12315
12315
|
assert2(callback === null);
|
|
12316
12316
|
if (socket[kError]) {
|
|
12317
12317
|
reject(socket[kError]);
|
|
12318
12318
|
} else {
|
|
12319
|
-
callback =
|
|
12319
|
+
callback = resolve26;
|
|
12320
12320
|
}
|
|
12321
12321
|
});
|
|
12322
12322
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -13674,12 +13674,12 @@ var require_client_h2 = __commonJS({
|
|
|
13674
13674
|
cb();
|
|
13675
13675
|
}
|
|
13676
13676
|
}
|
|
13677
|
-
const waitForDrain = () => new Promise((
|
|
13677
|
+
const waitForDrain = () => new Promise((resolve26, reject) => {
|
|
13678
13678
|
assert2(callback === null);
|
|
13679
13679
|
if (socket[kError]) {
|
|
13680
13680
|
reject(socket[kError]);
|
|
13681
13681
|
} else {
|
|
13682
|
-
callback =
|
|
13682
|
+
callback = resolve26;
|
|
13683
13683
|
}
|
|
13684
13684
|
});
|
|
13685
13685
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -13996,7 +13996,7 @@ var require_client = __commonJS({
|
|
|
13996
13996
|
this[kQueue] = [];
|
|
13997
13997
|
this[kRunningIdx] = 0;
|
|
13998
13998
|
this[kPendingIdx] = 0;
|
|
13999
|
-
this[kResume] = (
|
|
13999
|
+
this[kResume] = (sync2) => resume(this, sync2);
|
|
14000
14000
|
this[kOnError] = (err) => onError(this, err);
|
|
14001
14001
|
}
|
|
14002
14002
|
get pipelining() {
|
|
@@ -14047,16 +14047,16 @@ var require_client = __commonJS({
|
|
|
14047
14047
|
return this[kNeedDrain] < 2;
|
|
14048
14048
|
}
|
|
14049
14049
|
[kClose]() {
|
|
14050
|
-
return new Promise((
|
|
14050
|
+
return new Promise((resolve26) => {
|
|
14051
14051
|
if (this[kSize]) {
|
|
14052
|
-
this[kClosedResolve] =
|
|
14052
|
+
this[kClosedResolve] = resolve26;
|
|
14053
14053
|
} else {
|
|
14054
|
-
|
|
14054
|
+
resolve26(null);
|
|
14055
14055
|
}
|
|
14056
14056
|
});
|
|
14057
14057
|
}
|
|
14058
14058
|
[kDestroy](err) {
|
|
14059
|
-
return new Promise((
|
|
14059
|
+
return new Promise((resolve26) => {
|
|
14060
14060
|
const requests2 = this[kQueue].splice(this[kPendingIdx]);
|
|
14061
14061
|
for (let i = 0; i < requests2.length; i++) {
|
|
14062
14062
|
const request2 = requests2[i];
|
|
@@ -14069,7 +14069,7 @@ var require_client = __commonJS({
|
|
|
14069
14069
|
this[kClosedResolve]();
|
|
14070
14070
|
this[kClosedResolve] = null;
|
|
14071
14071
|
}
|
|
14072
|
-
|
|
14072
|
+
resolve26(null);
|
|
14073
14073
|
};
|
|
14074
14074
|
if (this[kHTTPContext]) {
|
|
14075
14075
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -14215,12 +14215,12 @@ var require_client = __commonJS({
|
|
|
14215
14215
|
client[kNeedDrain] = 0;
|
|
14216
14216
|
client.emit("drain", client[kUrl], [client]);
|
|
14217
14217
|
}
|
|
14218
|
-
function resume(client,
|
|
14218
|
+
function resume(client, sync2) {
|
|
14219
14219
|
if (client[kResuming] === 2) {
|
|
14220
14220
|
return;
|
|
14221
14221
|
}
|
|
14222
14222
|
client[kResuming] = 2;
|
|
14223
|
-
_resume(client,
|
|
14223
|
+
_resume(client, sync2);
|
|
14224
14224
|
client[kResuming] = 0;
|
|
14225
14225
|
if (client[kRunningIdx] > 256) {
|
|
14226
14226
|
client[kQueue].splice(0, client[kRunningIdx]);
|
|
@@ -14228,7 +14228,7 @@ var require_client = __commonJS({
|
|
|
14228
14228
|
client[kRunningIdx] = 0;
|
|
14229
14229
|
}
|
|
14230
14230
|
}
|
|
14231
|
-
function _resume(client,
|
|
14231
|
+
function _resume(client, sync2) {
|
|
14232
14232
|
while (true) {
|
|
14233
14233
|
if (client.destroyed) {
|
|
14234
14234
|
assert2(client[kPending] === 0);
|
|
@@ -14245,7 +14245,7 @@ var require_client = __commonJS({
|
|
|
14245
14245
|
if (client[kBusy]) {
|
|
14246
14246
|
client[kNeedDrain] = 2;
|
|
14247
14247
|
} else if (client[kNeedDrain] === 2) {
|
|
14248
|
-
if (
|
|
14248
|
+
if (sync2) {
|
|
14249
14249
|
client[kNeedDrain] = 1;
|
|
14250
14250
|
queueMicrotask(() => emitDrain(client));
|
|
14251
14251
|
} else {
|
|
@@ -14482,8 +14482,8 @@ var require_pool_base = __commonJS({
|
|
|
14482
14482
|
}
|
|
14483
14483
|
return Promise.all(closeAll);
|
|
14484
14484
|
} else {
|
|
14485
|
-
return new Promise((
|
|
14486
|
-
this[kClosedResolve] =
|
|
14485
|
+
return new Promise((resolve26) => {
|
|
14486
|
+
this[kClosedResolve] = resolve26;
|
|
14487
14487
|
});
|
|
14488
14488
|
}
|
|
14489
14489
|
}
|
|
@@ -16994,7 +16994,7 @@ var require_readable = __commonJS({
|
|
|
16994
16994
|
if (this._readableState.closeEmitted) {
|
|
16995
16995
|
return Promise.resolve(null);
|
|
16996
16996
|
}
|
|
16997
|
-
return new Promise((
|
|
16997
|
+
return new Promise((resolve26, reject) => {
|
|
16998
16998
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
16999
16999
|
this.destroy(new AbortError());
|
|
17000
17000
|
}
|
|
@@ -17008,11 +17008,11 @@ var require_readable = __commonJS({
|
|
|
17008
17008
|
if (signal.aborted) {
|
|
17009
17009
|
reject(signal.reason ?? new AbortError());
|
|
17010
17010
|
} else {
|
|
17011
|
-
|
|
17011
|
+
resolve26(null);
|
|
17012
17012
|
}
|
|
17013
17013
|
});
|
|
17014
17014
|
} else {
|
|
17015
|
-
this.on("close",
|
|
17015
|
+
this.on("close", resolve26);
|
|
17016
17016
|
}
|
|
17017
17017
|
this.on("error", noop2).on("data", () => {
|
|
17018
17018
|
if (this[kBytesRead] > limit) {
|
|
@@ -17040,7 +17040,7 @@ var require_readable = __commonJS({
|
|
|
17040
17040
|
}
|
|
17041
17041
|
function consume(stream, type) {
|
|
17042
17042
|
assert2(!stream[kConsume]);
|
|
17043
|
-
return new Promise((
|
|
17043
|
+
return new Promise((resolve26, reject) => {
|
|
17044
17044
|
if (isUnusable(stream)) {
|
|
17045
17045
|
const rState = stream._readableState;
|
|
17046
17046
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -17055,7 +17055,7 @@ var require_readable = __commonJS({
|
|
|
17055
17055
|
stream[kConsume] = {
|
|
17056
17056
|
type,
|
|
17057
17057
|
stream,
|
|
17058
|
-
resolve:
|
|
17058
|
+
resolve: resolve26,
|
|
17059
17059
|
reject,
|
|
17060
17060
|
length: 0,
|
|
17061
17061
|
body: []
|
|
@@ -17133,18 +17133,18 @@ var require_readable = __commonJS({
|
|
|
17133
17133
|
return buffer;
|
|
17134
17134
|
}
|
|
17135
17135
|
function consumeEnd(consume2, encoding) {
|
|
17136
|
-
const { type, body, resolve:
|
|
17136
|
+
const { type, body, resolve: resolve26, stream, length } = consume2;
|
|
17137
17137
|
try {
|
|
17138
17138
|
if (type === "text") {
|
|
17139
|
-
|
|
17139
|
+
resolve26(chunksDecode(body, length, encoding));
|
|
17140
17140
|
} else if (type === "json") {
|
|
17141
|
-
|
|
17141
|
+
resolve26(JSON.parse(chunksDecode(body, length, encoding)));
|
|
17142
17142
|
} else if (type === "arrayBuffer") {
|
|
17143
|
-
|
|
17143
|
+
resolve26(chunksConcat(body, length).buffer);
|
|
17144
17144
|
} else if (type === "blob") {
|
|
17145
|
-
|
|
17145
|
+
resolve26(new Blob(body, { type: stream[kContentType] }));
|
|
17146
17146
|
} else if (type === "bytes") {
|
|
17147
|
-
|
|
17147
|
+
resolve26(chunksConcat(body, length));
|
|
17148
17148
|
}
|
|
17149
17149
|
consumeFinish(consume2);
|
|
17150
17150
|
} catch (err) {
|
|
@@ -17363,9 +17363,9 @@ var require_api_request = __commonJS({
|
|
|
17363
17363
|
};
|
|
17364
17364
|
function request2(opts, callback) {
|
|
17365
17365
|
if (callback === void 0) {
|
|
17366
|
-
return new Promise((
|
|
17366
|
+
return new Promise((resolve26, reject) => {
|
|
17367
17367
|
request2.call(this, opts, (err, data) => {
|
|
17368
|
-
return err ? reject(err) :
|
|
17368
|
+
return err ? reject(err) : resolve26(data);
|
|
17369
17369
|
});
|
|
17370
17370
|
});
|
|
17371
17371
|
}
|
|
@@ -17626,9 +17626,9 @@ var require_api_stream = __commonJS({
|
|
|
17626
17626
|
};
|
|
17627
17627
|
function stream(opts, factory, callback) {
|
|
17628
17628
|
if (callback === void 0) {
|
|
17629
|
-
return new Promise((
|
|
17629
|
+
return new Promise((resolve26, reject) => {
|
|
17630
17630
|
stream.call(this, opts, factory, (err, data) => {
|
|
17631
|
-
return err ? reject(err) :
|
|
17631
|
+
return err ? reject(err) : resolve26(data);
|
|
17632
17632
|
});
|
|
17633
17633
|
});
|
|
17634
17634
|
}
|
|
@@ -17928,9 +17928,9 @@ var require_api_upgrade = __commonJS({
|
|
|
17928
17928
|
};
|
|
17929
17929
|
function upgrade2(opts, callback) {
|
|
17930
17930
|
if (callback === void 0) {
|
|
17931
|
-
return new Promise((
|
|
17931
|
+
return new Promise((resolve26, reject) => {
|
|
17932
17932
|
upgrade2.call(this, opts, (err, data) => {
|
|
17933
|
-
return err ? reject(err) :
|
|
17933
|
+
return err ? reject(err) : resolve26(data);
|
|
17934
17934
|
});
|
|
17935
17935
|
});
|
|
17936
17936
|
}
|
|
@@ -18024,9 +18024,9 @@ var require_api_connect = __commonJS({
|
|
|
18024
18024
|
};
|
|
18025
18025
|
function connect8(opts, callback) {
|
|
18026
18026
|
if (callback === void 0) {
|
|
18027
|
-
return new Promise((
|
|
18027
|
+
return new Promise((resolve26, reject) => {
|
|
18028
18028
|
connect8.call(this, opts, (err, data) => {
|
|
18029
|
-
return err ? reject(err) :
|
|
18029
|
+
return err ? reject(err) : resolve26(data);
|
|
18030
18030
|
});
|
|
18031
18031
|
});
|
|
18032
18032
|
}
|
|
@@ -19486,8 +19486,8 @@ 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:
|
|
19490
|
-
var { dirname:
|
|
19489
|
+
var { writeFile: writeFile12, readFile: readFile38, mkdir: mkdir13 } = __require("node:fs/promises");
|
|
19490
|
+
var { dirname: dirname26, resolve: resolve26 } = __require("node:path");
|
|
19491
19491
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
19492
19492
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
19493
19493
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -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 readFile38(resolve26(path), "utf8");
|
|
19707
19707
|
const parsed = JSON.parse(data);
|
|
19708
19708
|
if (Array.isArray(parsed)) {
|
|
19709
19709
|
this.#snapshots.clear();
|
|
@@ -19732,13 +19732,13 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19732
19732
|
if (!path) {
|
|
19733
19733
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19734
19734
|
}
|
|
19735
|
-
const resolvedPath =
|
|
19736
|
-
await
|
|
19735
|
+
const resolvedPath = resolve26(path);
|
|
19736
|
+
await mkdir13(dirname26(resolvedPath), { recursive: true });
|
|
19737
19737
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
19738
19738
|
hash: hash2,
|
|
19739
19739
|
snapshot
|
|
19740
19740
|
}));
|
|
19741
|
-
await
|
|
19741
|
+
await writeFile12(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
|
|
19742
19742
|
}
|
|
19743
19743
|
/**
|
|
19744
19744
|
* Clears all recorded snapshots
|
|
@@ -27230,7 +27230,7 @@ var require_fetch = __commonJS({
|
|
|
27230
27230
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
27231
27231
|
return dispatchWithProtocolPreference(body);
|
|
27232
27232
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
27233
|
-
return new Promise((
|
|
27233
|
+
return new Promise((resolve26, reject) => agent3.dispatch(
|
|
27234
27234
|
{
|
|
27235
27235
|
path: hasTrailingQuestionMark ? `${path}?` : path,
|
|
27236
27236
|
origin: url2.origin,
|
|
@@ -27313,7 +27313,7 @@ var require_fetch = __commonJS({
|
|
|
27313
27313
|
}
|
|
27314
27314
|
}
|
|
27315
27315
|
const onError = (err) => this.onResponseError(controller, err);
|
|
27316
|
-
|
|
27316
|
+
resolve26({
|
|
27317
27317
|
status: status11,
|
|
27318
27318
|
statusText,
|
|
27319
27319
|
headersList,
|
|
@@ -27346,7 +27346,7 @@ var require_fetch = __commonJS({
|
|
|
27346
27346
|
fetchParams.controller.off("terminated", this.abort);
|
|
27347
27347
|
}
|
|
27348
27348
|
if (request2.mode === "websocket" && allowH2 !== false && error63?.code === "UND_ERR_INFO" && error63?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
27349
|
-
|
|
27349
|
+
resolve26(dispatchWithProtocolPreference(body2, false));
|
|
27350
27350
|
return;
|
|
27351
27351
|
}
|
|
27352
27352
|
this.body?.destroy(error63);
|
|
@@ -27360,7 +27360,7 @@ var require_fetch = __commonJS({
|
|
|
27360
27360
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
27361
27361
|
const headersList = new HeadersList();
|
|
27362
27362
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
27363
|
-
|
|
27363
|
+
resolve26({
|
|
27364
27364
|
status: status11,
|
|
27365
27365
|
statusText: STATUS_CODES[status11],
|
|
27366
27366
|
headersList,
|
|
@@ -32692,7 +32692,7 @@ function runRedacted({
|
|
|
32692
32692
|
redact
|
|
32693
32693
|
}) {
|
|
32694
32694
|
const values = redact ?? Object.values(env);
|
|
32695
|
-
return new Promise((
|
|
32695
|
+
return new Promise((resolve26, reject) => {
|
|
32696
32696
|
const [file4, ...args] = command;
|
|
32697
32697
|
const child = spawn(file4, args, {
|
|
32698
32698
|
env: { ...baseEnv, ...env },
|
|
@@ -32718,7 +32718,7 @@ function runRedacted({
|
|
|
32718
32718
|
child.on("error", reject);
|
|
32719
32719
|
child.on("close", (code, ended) => {
|
|
32720
32720
|
signal?.removeEventListener("abort", killGroup);
|
|
32721
|
-
void drained.then(() =>
|
|
32721
|
+
void drained.then(() => resolve26(code ?? (ended ? 128 + signalNumber(ended) : 1)));
|
|
32722
32722
|
});
|
|
32723
32723
|
});
|
|
32724
32724
|
}
|
|
@@ -36780,8 +36780,150 @@ function cliEnvironment({
|
|
|
36780
36780
|
}
|
|
36781
36781
|
|
|
36782
36782
|
// src/services/config-store.service.ts
|
|
36783
|
-
import {
|
|
36784
|
-
import { basename, dirname, resolve } from "node:path";
|
|
36783
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
36784
|
+
import { basename as basename2, dirname as dirname2, resolve } from "node:path";
|
|
36785
|
+
|
|
36786
|
+
// src/rules/state-file.rules.ts
|
|
36787
|
+
function stepOf({ scan, char }) {
|
|
36788
|
+
if (scan.skip) {
|
|
36789
|
+
scan.skip = false;
|
|
36790
|
+
return false;
|
|
36791
|
+
}
|
|
36792
|
+
if (scan.inString) {
|
|
36793
|
+
if (char === "\\") scan.skip = true;
|
|
36794
|
+
if (char === '"') scan.inString = false;
|
|
36795
|
+
return false;
|
|
36796
|
+
}
|
|
36797
|
+
if (char === '"') scan.inString = true;
|
|
36798
|
+
if (char === "{" || char === "[") scan.depth += 1;
|
|
36799
|
+
if (char !== "}" && char !== "]") return false;
|
|
36800
|
+
scan.depth -= 1;
|
|
36801
|
+
return scan.depth === 0;
|
|
36802
|
+
}
|
|
36803
|
+
function firstValueEndOf({ text: text3 }) {
|
|
36804
|
+
const start2 = text3.search(/\S/);
|
|
36805
|
+
if (start2 < 0 || text3[start2] !== "{" && text3[start2] !== "[") return -1;
|
|
36806
|
+
const scan = { depth: 0, inString: false, skip: false };
|
|
36807
|
+
for (let index = start2; index < text3.length; index += 1) {
|
|
36808
|
+
if (stepOf({ scan, char: text3[index] })) return index + 1;
|
|
36809
|
+
}
|
|
36810
|
+
return -1;
|
|
36811
|
+
}
|
|
36812
|
+
function stateTextOf({ text: text3 }) {
|
|
36813
|
+
try {
|
|
36814
|
+
return { kind: "valid", value: JSON.parse(text3) };
|
|
36815
|
+
} catch {
|
|
36816
|
+
const end = firstValueEndOf({ text: text3 });
|
|
36817
|
+
if (end < 0) return { kind: "damaged" };
|
|
36818
|
+
try {
|
|
36819
|
+
return { kind: "trailing", value: JSON.parse(text3.slice(0, end)) };
|
|
36820
|
+
} catch {
|
|
36821
|
+
return { kind: "damaged" };
|
|
36822
|
+
}
|
|
36823
|
+
}
|
|
36824
|
+
}
|
|
36825
|
+
|
|
36826
|
+
// src/services/state-file.service.ts
|
|
36827
|
+
import { randomBytes } from "node:crypto";
|
|
36828
|
+
import { mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
36829
|
+
import { basename, dirname, join as join2 } from "node:path";
|
|
36830
|
+
var damaged = /* @__PURE__ */ new Map();
|
|
36831
|
+
function damagedStateFiles() {
|
|
36832
|
+
return [...damaged.values()];
|
|
36833
|
+
}
|
|
36834
|
+
async function writeStateText({
|
|
36835
|
+
path,
|
|
36836
|
+
text: text3,
|
|
36837
|
+
mode = 384
|
|
36838
|
+
}) {
|
|
36839
|
+
const folder = dirname(path);
|
|
36840
|
+
await mkdir(folder, { recursive: true, mode: 448 });
|
|
36841
|
+
const temporary = join2(
|
|
36842
|
+
folder,
|
|
36843
|
+
`.${basename(path)}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`
|
|
36844
|
+
);
|
|
36845
|
+
const handle = await open(temporary, "wx", mode);
|
|
36846
|
+
try {
|
|
36847
|
+
await handle.writeFile(text3);
|
|
36848
|
+
await handle.chmod(mode);
|
|
36849
|
+
await handle.sync();
|
|
36850
|
+
} finally {
|
|
36851
|
+
await handle.close();
|
|
36852
|
+
}
|
|
36853
|
+
try {
|
|
36854
|
+
await rename(temporary, path);
|
|
36855
|
+
} catch (error63) {
|
|
36856
|
+
await rm(temporary, { force: true });
|
|
36857
|
+
throw error63;
|
|
36858
|
+
}
|
|
36859
|
+
damaged.delete(path);
|
|
36860
|
+
}
|
|
36861
|
+
async function writeStateJson({
|
|
36862
|
+
path,
|
|
36863
|
+
value,
|
|
36864
|
+
mode,
|
|
36865
|
+
pretty = false
|
|
36866
|
+
}) {
|
|
36867
|
+
const text3 = pretty ? `${JSON.stringify(value, null, 2)}
|
|
36868
|
+
` : JSON.stringify(value);
|
|
36869
|
+
await writeStateText({ path, text: text3, ...mode === void 0 ? {} : { mode } });
|
|
36870
|
+
}
|
|
36871
|
+
async function readStateJson({ path }) {
|
|
36872
|
+
const text3 = await readFile(path, "utf8").catch(() => void 0);
|
|
36873
|
+
if (text3 === void 0) return void 0;
|
|
36874
|
+
const read4 = stateTextOf({ text: text3 });
|
|
36875
|
+
if (read4.kind === "valid") return read4.value;
|
|
36876
|
+
damaged.set(path, { path, repairable: read4.kind === "trailing" });
|
|
36877
|
+
return read4.kind === "trailing" ? read4.value : void 0;
|
|
36878
|
+
}
|
|
36879
|
+
async function repairDamagedStateFiles() {
|
|
36880
|
+
const lines2 = [];
|
|
36881
|
+
for (const file4 of damagedStateFiles()) {
|
|
36882
|
+
const value = file4.repairable ? await readStateJson({ path: file4.path }) : void 0;
|
|
36883
|
+
if (value !== void 0) {
|
|
36884
|
+
await writeStateJson({ path: file4.path, value });
|
|
36885
|
+
lines2.push(`Repaired ${file4.path}: it had extra text after its JSON.`);
|
|
36886
|
+
} else {
|
|
36887
|
+
damaged.delete(file4.path);
|
|
36888
|
+
lines2.push(`Skipped ${file4.path}: it is not valid JSON; the next write replaces it.`);
|
|
36889
|
+
}
|
|
36890
|
+
}
|
|
36891
|
+
return lines2;
|
|
36892
|
+
}
|
|
36893
|
+
var LOCK_STALE_MS = 5e3;
|
|
36894
|
+
var nowMs = () => nowInstant().epochMilliseconds;
|
|
36895
|
+
var LOCK_WAIT_MS = 3e3;
|
|
36896
|
+
async function withStateLock({
|
|
36897
|
+
path,
|
|
36898
|
+
work
|
|
36899
|
+
}) {
|
|
36900
|
+
const lock = `${path}.lock`;
|
|
36901
|
+
await mkdir(dirname(lock), { recursive: true, mode: 448 });
|
|
36902
|
+
const deadline = nowMs() + LOCK_WAIT_MS;
|
|
36903
|
+
for (; ; ) {
|
|
36904
|
+
const handle = await open(lock, "wx", 384).catch((error63) => {
|
|
36905
|
+
if (error63.code === "EEXIST") return void 0;
|
|
36906
|
+
throw error63;
|
|
36907
|
+
});
|
|
36908
|
+
if (handle) {
|
|
36909
|
+
await handle.close();
|
|
36910
|
+
break;
|
|
36911
|
+
}
|
|
36912
|
+
const since = await stat(lock).then(
|
|
36913
|
+
(info) => nowMs() - info.mtimeMs,
|
|
36914
|
+
() => 0
|
|
36915
|
+
);
|
|
36916
|
+
if (since > LOCK_STALE_MS || nowMs() > deadline) await rm(lock, { force: true });
|
|
36917
|
+
else await new Promise((resolve26) => setTimeout(resolve26, 15 + Math.random() * 20));
|
|
36918
|
+
}
|
|
36919
|
+
try {
|
|
36920
|
+
return await work();
|
|
36921
|
+
} finally {
|
|
36922
|
+
await rm(lock, { force: true });
|
|
36923
|
+
}
|
|
36924
|
+
}
|
|
36925
|
+
|
|
36926
|
+
// src/services/config-store.service.ts
|
|
36785
36927
|
var EMPTY = { profiles: {}, bindings: {} };
|
|
36786
36928
|
var ConfigStore = class _ConfigStore {
|
|
36787
36929
|
constructor(path) {
|
|
@@ -36792,21 +36934,19 @@ var ConfigStore = class _ConfigStore {
|
|
|
36792
36934
|
return new _ConfigStore(path);
|
|
36793
36935
|
}
|
|
36794
36936
|
async read() {
|
|
36795
|
-
|
|
36796
|
-
|
|
36797
|
-
return { ...EMPTY, ...parsed };
|
|
36798
|
-
} catch (error63) {
|
|
36799
|
-
if (error63.code === "ENOENT") return EMPTY;
|
|
36937
|
+
const text3 = await readFile2(this.path, "utf8").catch((error63) => {
|
|
36938
|
+
if (error63.code === "ENOENT") return void 0;
|
|
36800
36939
|
throw error63;
|
|
36940
|
+
});
|
|
36941
|
+
if (text3 === void 0) return EMPTY;
|
|
36942
|
+
const read4 = stateTextOf({ text: text3 });
|
|
36943
|
+
if (read4.kind === "damaged") {
|
|
36944
|
+
throw new Error(`${this.path} is not valid JSON; move it aside and sign in again.`);
|
|
36801
36945
|
}
|
|
36946
|
+
return { ...EMPTY, ...read4.value };
|
|
36802
36947
|
}
|
|
36803
36948
|
async write(config2) {
|
|
36804
|
-
await
|
|
36805
|
-
const temporary = `${this.path}.${process.pid}.tmp`;
|
|
36806
|
-
await writeFile(temporary, `${JSON.stringify(config2, null, 2)}
|
|
36807
|
-
`, { mode: 384 });
|
|
36808
|
-
await chmod(temporary, 384);
|
|
36809
|
-
await rename(temporary, this.path);
|
|
36949
|
+
await writeStateJson({ path: this.path, value: config2, pretty: true });
|
|
36810
36950
|
}
|
|
36811
36951
|
async saveProfile({
|
|
36812
36952
|
name: name3,
|
|
@@ -36896,9 +37036,9 @@ function chooseProfile({
|
|
|
36896
37036
|
return name3 && profile ? { name: name3, profile } : { name: void 0, profile: void 0 };
|
|
36897
37037
|
}
|
|
36898
37038
|
function isWorktreeRoot({ directory }) {
|
|
36899
|
-
const parent =
|
|
36900
|
-
if (
|
|
36901
|
-
return
|
|
37039
|
+
const parent = dirname2(directory);
|
|
37040
|
+
if (basename2(parent) === ".worktrees") return true;
|
|
37041
|
+
return basename2(parent) === "worktrees" && basename2(dirname2(parent)) === ".claude";
|
|
36902
37042
|
}
|
|
36903
37043
|
function boundProfileOf({
|
|
36904
37044
|
bindings,
|
|
@@ -36908,7 +37048,7 @@ function boundProfileOf({
|
|
|
36908
37048
|
for (let depth = 0; depth < 64; depth += 1) {
|
|
36909
37049
|
const bound = bindings[directory];
|
|
36910
37050
|
if (bound) return bound;
|
|
36911
|
-
const parent =
|
|
37051
|
+
const parent = dirname2(directory);
|
|
36912
37052
|
if (parent === directory || isWorktreeRoot({ directory })) return void 0;
|
|
36913
37053
|
directory = parent;
|
|
36914
37054
|
}
|
|
@@ -36990,7 +37130,7 @@ function flagText({
|
|
|
36990
37130
|
}
|
|
36991
37131
|
|
|
36992
37132
|
// src/rules/cli-version.rules.ts
|
|
36993
|
-
var STAMPED = "0.1.
|
|
37133
|
+
var STAMPED = "0.1.87";
|
|
36994
37134
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
36995
37135
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
36996
37136
|
}
|
|
@@ -42040,7 +42180,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
42040
42180
|
var NONE = 0;
|
|
42041
42181
|
var ASSUMED = 1;
|
|
42042
42182
|
var PROVEN = 2;
|
|
42043
|
-
function isRecursive(inst, stack,
|
|
42183
|
+
function isRecursive(inst, stack, resolve26) {
|
|
42044
42184
|
const cached2 = recursive.get(inst);
|
|
42045
42185
|
if (cached2 !== void 0)
|
|
42046
42186
|
return cached2 ? PROVEN : NONE;
|
|
@@ -42050,7 +42190,7 @@ function isRecursive(inst, stack, resolve25) {
|
|
|
42050
42190
|
let result2 = NONE;
|
|
42051
42191
|
const check3 = (child) => {
|
|
42052
42192
|
if (result2 !== PROVEN && child?._zod) {
|
|
42053
|
-
const answer6 = isRecursive(child, stack,
|
|
42193
|
+
const answer6 = isRecursive(child, stack, resolve26);
|
|
42054
42194
|
if (answer6 > result2)
|
|
42055
42195
|
result2 = answer6;
|
|
42056
42196
|
}
|
|
@@ -42061,7 +42201,7 @@ function isRecursive(inst, stack, resolve25) {
|
|
|
42061
42201
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
42062
42202
|
if (spread && !desc.enumerable)
|
|
42063
42203
|
continue;
|
|
42064
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
42204
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve26) : NONE;
|
|
42065
42205
|
if (child > answer6)
|
|
42066
42206
|
answer6 = child;
|
|
42067
42207
|
}
|
|
@@ -42125,7 +42265,7 @@ function isRecursive(inst, stack, resolve25) {
|
|
|
42125
42265
|
break;
|
|
42126
42266
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
42127
42267
|
case "lazy": {
|
|
42128
|
-
const inner = def._cachedInner ?? (
|
|
42268
|
+
const inner = def._cachedInner ?? (resolve26 ? inst._zod.innerType : void 0);
|
|
42129
42269
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
42130
42270
|
break;
|
|
42131
42271
|
}
|
|
@@ -42189,7 +42329,7 @@ function bucketFor(state, inst) {
|
|
|
42189
42329
|
return bucket;
|
|
42190
42330
|
}
|
|
42191
42331
|
var handoff;
|
|
42192
|
-
var
|
|
42332
|
+
var open2 = [];
|
|
42193
42333
|
var memo = {
|
|
42194
42334
|
alloc(_inst, payload, empty) {
|
|
42195
42335
|
const bucket = handoff;
|
|
@@ -42198,7 +42338,7 @@ var memo = {
|
|
|
42198
42338
|
handoff = void 0;
|
|
42199
42339
|
const entry = { value: empty, issues: null };
|
|
42200
42340
|
bucket.set(payload.value, entry);
|
|
42201
|
-
|
|
42341
|
+
open2.push(entry);
|
|
42202
42342
|
return empty;
|
|
42203
42343
|
},
|
|
42204
42344
|
guard(inst) {
|
|
@@ -42269,10 +42409,10 @@ var memo = {
|
|
|
42269
42409
|
return payload;
|
|
42270
42410
|
}
|
|
42271
42411
|
handoff = bucket;
|
|
42272
|
-
const depth =
|
|
42412
|
+
const depth = open2.length;
|
|
42273
42413
|
const result2 = base(payload, ctx);
|
|
42274
42414
|
handoff = void 0;
|
|
42275
|
-
const entry =
|
|
42415
|
+
const entry = open2.length > depth ? open2.pop() : void 0;
|
|
42276
42416
|
if (result2 instanceof Promise) {
|
|
42277
42417
|
return result2.then((r) => {
|
|
42278
42418
|
if (entry)
|
|
@@ -60239,6 +60379,8 @@ var vaultUseInputSchemaDefinition = external_exports.object({
|
|
|
60239
60379
|
requiredScopes: external_exports.array(external_exports.string().min(1)).default([]),
|
|
60240
60380
|
/** A floor on the connection's sensitivity, for a tool its owner marked more guarded. */
|
|
60241
60381
|
atLeast: vaultSensitivitySchema.optional(),
|
|
60382
|
+
/** The tool `atLeast` is for: when that floor alone asks, Allow for a set time covers it. */
|
|
60383
|
+
leaseScope: external_exports.string().min(1).max(200).optional(),
|
|
60242
60384
|
/** The caller knows the use only reads, such as an MCP tool marked read-only. */
|
|
60243
60385
|
readOnly: external_exports.boolean().default(false),
|
|
60244
60386
|
/** A use that would ask comes back denied with no card: a lookup made only for another card. */
|
|
@@ -61170,11 +61312,11 @@ var FENCE = /^\s*(?:>\s?)*(`{3,}|~{3,})/;
|
|
|
61170
61312
|
var BLANK = /^\s*(?:>\s*)*$/;
|
|
61171
61313
|
function segmentsOf({ lines: lines2 }) {
|
|
61172
61314
|
const out = [];
|
|
61173
|
-
let
|
|
61315
|
+
let open6 = null;
|
|
61174
61316
|
let fence = null;
|
|
61175
61317
|
const close = (end) => {
|
|
61176
|
-
if (
|
|
61177
|
-
|
|
61318
|
+
if (open6 && end >= open6.start) out.push({ start: open6.start, end, fenced: open6.fenced });
|
|
61319
|
+
open6 = null;
|
|
61178
61320
|
};
|
|
61179
61321
|
lines2.forEach((line, index) => {
|
|
61180
61322
|
const marker = FENCE.exec(line)?.[1];
|
|
@@ -61182,7 +61324,7 @@ function segmentsOf({ lines: lines2 }) {
|
|
|
61182
61324
|
if (marker && marker[0] === fence[0] && marker.length >= fence.length) {
|
|
61183
61325
|
close(index - 1);
|
|
61184
61326
|
fence = null;
|
|
61185
|
-
} else if (!
|
|
61327
|
+
} else if (!open6) open6 = { start: index, fenced: true };
|
|
61186
61328
|
return;
|
|
61187
61329
|
}
|
|
61188
61330
|
if (marker) {
|
|
@@ -61191,7 +61333,7 @@ function segmentsOf({ lines: lines2 }) {
|
|
|
61191
61333
|
return;
|
|
61192
61334
|
}
|
|
61193
61335
|
if (BLANK.test(line)) close(index - 1);
|
|
61194
|
-
else if (!
|
|
61336
|
+
else if (!open6) open6 = { start: index, fenced: false };
|
|
61195
61337
|
});
|
|
61196
61338
|
close(lines2.length - 1);
|
|
61197
61339
|
return out;
|
|
@@ -62208,6 +62350,7 @@ var mirrorSourceSchema = external_exports.enum([
|
|
|
62208
62350
|
"laze"
|
|
62209
62351
|
]);
|
|
62210
62352
|
var mirrorDeliverySchema = external_exports.enum(["waiting", "failed"]);
|
|
62353
|
+
var mirrorDeliveryStateSchema = external_exports.enum(["waiting", "failed", "edit_kept"]);
|
|
62211
62354
|
var messageOriginSchemaDefinition = external_exports.object({
|
|
62212
62355
|
source: mirrorSourceSchema,
|
|
62213
62356
|
/** The message's key at the source, unique in the workspace (e.g. `slack:T1:C1:1792.0001`). */
|
|
@@ -62608,6 +62751,8 @@ var messageSchemaDefinition = external_exports.object({
|
|
|
62608
62751
|
images: external_exports.record(external_exports.string().max(2e3), external_exports.string().max(5e3)).optional(),
|
|
62609
62752
|
/** A message written in Laze that its mirror is still waiting to send, or could not send. */
|
|
62610
62753
|
mirrorDelivery: mirrorDeliverySchema.nullable().optional(),
|
|
62754
|
+
/** Set when the source would not take the last edit of this sent message: it is only in Laze. */
|
|
62755
|
+
mirrorEditKept: external_exports.boolean().optional(),
|
|
62611
62756
|
/** A thread reply also sent to its conversation: it shows in the thread and the channel. */
|
|
62612
62757
|
alsoInChannel: external_exports.boolean().optional(),
|
|
62613
62758
|
/** For a reply also sent to the channel: its root's text, for the "replied to a thread" line. */
|
|
@@ -62698,7 +62843,9 @@ var directoryEntrySchemaDefinition = external_exports.object({
|
|
|
62698
62843
|
/** An agent that runs outside Laze: what it reads leaves Laze. False for people. */
|
|
62699
62844
|
runsOutside: external_exports.boolean().default(false),
|
|
62700
62845
|
/** Other names a person goes by, such as "Drew" or their Slack name; mentions match them. */
|
|
62701
|
-
aliases: external_exports.array(external_exports.string()).optional()
|
|
62846
|
+
aliases: external_exports.array(external_exports.string()).optional(),
|
|
62847
|
+
/** A person invited and not joined yet, by their invitation's state; absent for members. */
|
|
62848
|
+
invited: external_exports.enum(["pending", "held", "expired"]).optional()
|
|
62702
62849
|
});
|
|
62703
62850
|
var chatOverviewSchemaDefinition = external_exports.object({
|
|
62704
62851
|
viewer: chatActorSchemaDefinition,
|
|
@@ -63087,7 +63234,7 @@ var pinMirroredInputSchemaDefinition = external_exports.object({
|
|
|
63087
63234
|
var setMirrorDeliveryInputSchemaDefinition = external_exports.object({
|
|
63088
63235
|
workspaceId: workspaceIdSchema,
|
|
63089
63236
|
messageId: idSchema4,
|
|
63090
|
-
state:
|
|
63237
|
+
state: mirrorDeliveryStateSchema.nullable()
|
|
63091
63238
|
});
|
|
63092
63239
|
var reactMirroredInputSchemaDefinition = external_exports.object({
|
|
63093
63240
|
workspaceId: workspaceIdSchema,
|
|
@@ -63137,7 +63284,9 @@ var syncMirrorReadInputSchemaDefinition = external_exports.object({
|
|
|
63137
63284
|
channelId: idSchema4,
|
|
63138
63285
|
userId: idSchema4,
|
|
63139
63286
|
readTo: external_exports.iso.datetime(),
|
|
63140
|
-
unread: external_exports.number().int().positive().max(1e6).optional()
|
|
63287
|
+
unread: external_exports.number().int().positive().max(1e6).optional(),
|
|
63288
|
+
/** The source and Laze keep marks in step: a read there also ends a mark unread set in Laze. */
|
|
63289
|
+
releasesHold: external_exports.boolean().optional()
|
|
63141
63290
|
});
|
|
63142
63291
|
var mirroredReadToInputSchemaDefinition = external_exports.object({
|
|
63143
63292
|
workspaceId: workspaceIdSchema,
|
|
@@ -64020,7 +64169,7 @@ var mirrorNotifyLevelSchema = external_exports.enum(["everywhere", "desktop", "o
|
|
|
64020
64169
|
var mirrorNotifySchemaDefinition = external_exports.object({
|
|
64021
64170
|
slack: mirrorNotifyLevelSchema.default("everywhere"),
|
|
64022
64171
|
discord: mirrorNotifyLevelSchema.default("everywhere"),
|
|
64023
|
-
whatsapp: mirrorNotifyLevelSchema.default("
|
|
64172
|
+
whatsapp: mirrorNotifyLevelSchema.default("everywhere")
|
|
64024
64173
|
});
|
|
64025
64174
|
var notificationSettingsSchemaDefinition = external_exports.object({
|
|
64026
64175
|
channelDefault: channelDefaultSchema,
|
|
@@ -64299,7 +64448,9 @@ var desktopTextReviewRequestedPayloadSchemaDefinition = external_exports.object(
|
|
|
64299
64448
|
workspaceId: external_exports.string().min(1),
|
|
64300
64449
|
userId: external_exports.string().min(1),
|
|
64301
64450
|
requestId: external_exports.string().min(1),
|
|
64302
|
-
at: external_exports.iso.datetime()
|
|
64451
|
+
at: external_exports.iso.datetime(),
|
|
64452
|
+
/** The notice tags (`<channel id>:<message id>`) that changed; absent, every fact is checked. */
|
|
64453
|
+
tags: external_exports.array(external_exports.string().min(1)).optional()
|
|
64303
64454
|
});
|
|
64304
64455
|
var notificationsPausedPayloadSchemaDefinition = external_exports.object({
|
|
64305
64456
|
workspaceId: external_exports.string().min(1),
|
|
@@ -64798,7 +64949,13 @@ var agentAccessSchemaDefinition = external_exports.object({
|
|
|
64798
64949
|
kind: external_exports.enum(["personal", "team"]),
|
|
64799
64950
|
ownerUserId: idSchema5,
|
|
64800
64951
|
people: external_exports.array(
|
|
64801
|
-
external_exports.object({
|
|
64952
|
+
external_exports.object({
|
|
64953
|
+
userId: idSchema5,
|
|
64954
|
+
grantedByUserId: idSchema5,
|
|
64955
|
+
grantedAt: external_exports.iso.datetime(),
|
|
64956
|
+
/** The address of a person invited and not joined yet, who is named by it. */
|
|
64957
|
+
invitedEmail: external_exports.string().optional()
|
|
64958
|
+
})
|
|
64802
64959
|
),
|
|
64803
64960
|
channels: external_exports.array(
|
|
64804
64961
|
external_exports.object({ id: idSchema5, name: external_exports.string(), kind: external_exports.enum(["public", "private"]) })
|
|
@@ -66780,6 +66937,11 @@ var connectorCategorySchema = external_exports.enum([
|
|
|
66780
66937
|
"Projects and code"
|
|
66781
66938
|
]);
|
|
66782
66939
|
var TWO_DAYS = 2 * 86400;
|
|
66940
|
+
var GMAIL_MODIFY_SCOPE = "https://www.googleapis.com/auth/gmail.modify";
|
|
66941
|
+
var GMAIL_TRASH_PATHS = [
|
|
66942
|
+
"/gmail/v1/users/*/threads/*/trash",
|
|
66943
|
+
"/gmail/v1/users/*/messages/*/trash"
|
|
66944
|
+
];
|
|
66783
66945
|
var GOOGLE = {
|
|
66784
66946
|
family: "google",
|
|
66785
66947
|
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
@@ -66801,22 +66963,18 @@ var CONNECTOR_PROVIDERS = [
|
|
|
66801
66963
|
id: "gmail",
|
|
66802
66964
|
label: "Gmail",
|
|
66803
66965
|
category: "Email and calendar",
|
|
66804
|
-
description: "Search and
|
|
66805
|
-
|
|
66806
|
-
|
|
66807
|
-
"email",
|
|
66808
|
-
"https://www.googleapis.com/auth/gmail.readonly",
|
|
66809
|
-
"https://www.googleapis.com/auth/gmail.compose"
|
|
66810
|
-
],
|
|
66966
|
+
description: "Search, read, archive and label mail and write drafts. Sending, trash and unsubscribing ask you first.",
|
|
66967
|
+
// gmail.modify covers reading, drafts and sending as well as labels, archive and trash.
|
|
66968
|
+
scopes: ["openid", "email", GMAIL_MODIFY_SCOPE],
|
|
66811
66969
|
sensitivity: "auto",
|
|
66812
66970
|
maxLeaseSeconds: TWO_DAYS,
|
|
66813
66971
|
egress: {
|
|
66814
66972
|
upstream: "https://gmail.googleapis.com",
|
|
66815
66973
|
header: "Authorization",
|
|
66816
66974
|
prefix: "Bearer ",
|
|
66817
|
-
askPaths: VAULT_GMAIL_SEND_PATHS
|
|
66975
|
+
askPaths: [...VAULT_GMAIL_SEND_PATHS, ...GMAIL_TRASH_PATHS]
|
|
66818
66976
|
},
|
|
66819
|
-
rules: "Read mail and write drafts freely; send only
|
|
66977
|
+
rules: "Read, label and archive mail and write drafts freely; send, trash or unsubscribe only when the requester asked for it."
|
|
66820
66978
|
},
|
|
66821
66979
|
{
|
|
66822
66980
|
...GOOGLE,
|
|
@@ -69554,7 +69712,9 @@ var callerWorkspaceInviteSchemaDefinition = external_exports.object({
|
|
|
69554
69712
|
role: roleSchema,
|
|
69555
69713
|
status: external_exports.enum(["pending", "held"]).optional(),
|
|
69556
69714
|
expiresAt: external_exports.iso.datetime(),
|
|
69557
|
-
createdAt: external_exports.iso.datetime()
|
|
69715
|
+
createdAt: external_exports.iso.datetime(),
|
|
69716
|
+
/** The invited person, who can be given agents, apps and channels before they join. */
|
|
69717
|
+
personId: external_exports.string().optional()
|
|
69558
69718
|
});
|
|
69559
69719
|
var callerInviteLinkSchemaDefinition = external_exports.object({
|
|
69560
69720
|
inviteId: external_exports.string().min(1),
|
|
@@ -69993,13 +70153,11 @@ function errorOf({ status: status11, body }) {
|
|
|
69993
70153
|
|
|
69994
70154
|
// src/services/machine-report.service.ts
|
|
69995
70155
|
import { createHash } from "node:crypto";
|
|
69996
|
-
import {
|
|
70156
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
69997
70157
|
import { hostname as hostname3 } from "node:os";
|
|
69998
|
-
import { dirname as dirname3 } from "node:path";
|
|
69999
70158
|
|
|
70000
70159
|
// src/services/inbox-spool.service.ts
|
|
70001
|
-
import {
|
|
70002
|
-
import { dirname as dirname2, join as join2 } from "node:path";
|
|
70160
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
70003
70161
|
var PUSH_GRACE_MS = 3 * 6e4;
|
|
70004
70162
|
var IN_FLIGHT_MS = 35e3;
|
|
70005
70163
|
function fileNameOf({ profile }) {
|
|
@@ -70011,20 +70169,14 @@ function statePathOf({
|
|
|
70011
70169
|
profile,
|
|
70012
70170
|
extension: extension2 = "json"
|
|
70013
70171
|
}) {
|
|
70014
|
-
const directory =
|
|
70015
|
-
return
|
|
70172
|
+
const directory = join3(dirname3(context.environment.configPath), kind2);
|
|
70173
|
+
return join3(directory, `${fileNameOf({ profile })}.${extension2}`);
|
|
70016
70174
|
}
|
|
70017
70175
|
async function readSpool({ path }) {
|
|
70018
|
-
return
|
|
70019
|
-
(text3) => JSON.parse(text3),
|
|
70020
|
-
() => []
|
|
70021
|
-
);
|
|
70176
|
+
return await readStateJson({ path }) ?? [];
|
|
70022
70177
|
}
|
|
70023
70178
|
async function writeSpool({ path, entries }) {
|
|
70024
|
-
await
|
|
70025
|
-
const temporary = `${path}.${process.pid}.tmp`;
|
|
70026
|
-
await writeFile2(temporary, JSON.stringify(entries), { mode: 384 });
|
|
70027
|
-
await rename2(temporary, path);
|
|
70179
|
+
await writeStateJson({ path, value: entries });
|
|
70028
70180
|
}
|
|
70029
70181
|
async function keepTaken({
|
|
70030
70182
|
context,
|
|
@@ -70094,8 +70246,7 @@ async function reportMachine({
|
|
|
70094
70246
|
if (await readFile3(path, "utf8").catch(() => "") === stamp) return;
|
|
70095
70247
|
try {
|
|
70096
70248
|
await client.post("/api/agents/me/machine", { host: host2 });
|
|
70097
|
-
await
|
|
70098
|
-
await writeFile3(path, stamp, { mode: 384 });
|
|
70249
|
+
await writeStateText({ path, text: stamp });
|
|
70099
70250
|
} catch {
|
|
70100
70251
|
return;
|
|
70101
70252
|
}
|
|
@@ -70388,8 +70539,8 @@ async function copyAgent({
|
|
|
70388
70539
|
}
|
|
70389
70540
|
|
|
70390
70541
|
// src/services/agent-commands.service.ts
|
|
70391
|
-
import { mkdir as
|
|
70392
|
-
import { join as
|
|
70542
|
+
import { mkdir as mkdir5, readFile as readFile11, writeFile as writeFile3 } from "node:fs/promises";
|
|
70543
|
+
import { join as join19, resolve as resolve5 } from "node:path";
|
|
70393
70544
|
|
|
70394
70545
|
// src/rules/agent-profile.rules.ts
|
|
70395
70546
|
var HARNESS_NAMES = {
|
|
@@ -71679,13 +71830,13 @@ function formatSearch({
|
|
|
71679
71830
|
}
|
|
71680
71831
|
|
|
71681
71832
|
// src/services/claude-turn.service.ts
|
|
71682
|
-
import {
|
|
71683
|
-
import { dirname as dirname5, join as
|
|
71833
|
+
import { rm as rm2 } from "node:fs/promises";
|
|
71834
|
+
import { dirname as dirname5, join as join6 } from "node:path";
|
|
71684
71835
|
|
|
71685
71836
|
// src/services/harness-session.service.ts
|
|
71686
|
-
import {
|
|
71837
|
+
import { open as open3, readdir, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
71687
71838
|
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
71688
|
-
import { dirname as dirname4, join as
|
|
71839
|
+
import { dirname as dirname4, join as join4 } from "node:path";
|
|
71689
71840
|
|
|
71690
71841
|
// src/rules/claude-subagent.rules.ts
|
|
71691
71842
|
function lastCallAtOf({ text: text3, command }) {
|
|
@@ -71779,9 +71930,9 @@ function launchEnvOf({
|
|
|
71779
71930
|
}
|
|
71780
71931
|
|
|
71781
71932
|
// src/services/claude-project.service.ts
|
|
71782
|
-
import { basename as
|
|
71933
|
+
import { basename as basename3, isAbsolute, relative as relative2, resolve as resolve2 } from "node:path";
|
|
71783
71934
|
function harnessIn({ words }) {
|
|
71784
|
-
const names = words.slice(0, 2).map((word3) =>
|
|
71935
|
+
const names = words.slice(0, 2).map((word3) => basename3(word3).replace(/\.(js|mjs|cjs)$/, ""));
|
|
71785
71936
|
if (names.includes("codex")) return "codex";
|
|
71786
71937
|
if (words.some((word3) => word3.includes("@openai/codex"))) return "codex";
|
|
71787
71938
|
const claude = words.some((word3) => word3.includes("@anthropic-ai/claude-code"));
|
|
@@ -71846,9 +71997,8 @@ async function rememberSession({
|
|
|
71846
71997
|
}) {
|
|
71847
71998
|
if (!session || !claudePid) return;
|
|
71848
71999
|
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
71849
|
-
await mkdir4(dirname4(path), { recursive: true, mode: 448 });
|
|
71850
72000
|
const launch = launchEnvOf({ inherited: context.environment.inherited });
|
|
71851
|
-
await
|
|
72001
|
+
await writeStateJson({ path, value: { ...session, launch } });
|
|
71852
72002
|
}
|
|
71853
72003
|
async function currentSessionOf({
|
|
71854
72004
|
context,
|
|
@@ -71867,10 +72017,7 @@ async function currentSessionOf({
|
|
|
71867
72017
|
const nearest = await nearestHarnessOf({ context });
|
|
71868
72018
|
if (!nearest) return void 0;
|
|
71869
72019
|
const path = statePathOf({ context, kind: "sessions", profile: String(nearest.pid) });
|
|
71870
|
-
return
|
|
71871
|
-
(text3) => JSON.parse(text3),
|
|
71872
|
-
() => void 0
|
|
71873
|
-
);
|
|
72020
|
+
return readStateJson({ path });
|
|
71874
72021
|
}
|
|
71875
72022
|
async function sessionProfileArgs({
|
|
71876
72023
|
context,
|
|
@@ -71924,10 +72071,7 @@ async function liveElsewhere({
|
|
|
71924
72071
|
for (const file4 of await readdir(folder).catch(() => [])) {
|
|
71925
72072
|
const pid = Number(file4.replace(/\.json$/, ""));
|
|
71926
72073
|
if (!pid || pid === claudePid || !context.processes.alive(pid)) continue;
|
|
71927
|
-
const noted = await
|
|
71928
|
-
(text3) => JSON.parse(text3),
|
|
71929
|
-
() => void 0
|
|
71930
|
-
);
|
|
72074
|
+
const noted = await readStateJson({ path: join4(folder, file4) });
|
|
71931
72075
|
if (noted && sessionKeyOf({ session: noted }) === key) return true;
|
|
71932
72076
|
}
|
|
71933
72077
|
return false;
|
|
@@ -71937,15 +72081,15 @@ async function claudeTranscriptOf({
|
|
|
71937
72081
|
sessionId
|
|
71938
72082
|
}) {
|
|
71939
72083
|
const inherited = context.environment.inherited;
|
|
71940
|
-
const root =
|
|
71941
|
-
inherited.CLAUDE_CONFIG_DIR ||
|
|
72084
|
+
const root = join4(
|
|
72085
|
+
inherited.CLAUDE_CONFIG_DIR || join4(inherited.HOME || homedir2(), ".claude"),
|
|
71942
72086
|
"projects"
|
|
71943
72087
|
);
|
|
71944
72088
|
const folders = await readdir(root).catch(() => []);
|
|
71945
72089
|
const found = await Promise.all(
|
|
71946
72090
|
folders.map(async (folder) => {
|
|
71947
|
-
const path =
|
|
71948
|
-
return
|
|
72091
|
+
const path = join4(root, folder, `${sessionId}.jsonl`);
|
|
72092
|
+
return stat2(path).then(
|
|
71949
72093
|
(info) => info.isFile() ? [{ path, at: info.mtimeMs }] : [],
|
|
71950
72094
|
() => []
|
|
71951
72095
|
);
|
|
@@ -71955,7 +72099,7 @@ async function claudeTranscriptOf({
|
|
|
71955
72099
|
}
|
|
71956
72100
|
var TAIL_BYTES = 512 * 1024;
|
|
71957
72101
|
async function tailOf({ path }) {
|
|
71958
|
-
const handle = await
|
|
72102
|
+
const handle = await open3(path, "r").catch(() => void 0);
|
|
71959
72103
|
if (!handle) return "";
|
|
71960
72104
|
try {
|
|
71961
72105
|
const { size } = await handle.stat();
|
|
@@ -71972,11 +72116,11 @@ async function runsInSubagent({ context, command }) {
|
|
|
71972
72116
|
if (!sessionId) return false;
|
|
71973
72117
|
const { path } = await claudeTranscriptOf({ context, sessionId });
|
|
71974
72118
|
if (!path) return false;
|
|
71975
|
-
const folder =
|
|
72119
|
+
const folder = join4(dirname4(path), sessionId, "subagents");
|
|
71976
72120
|
const files2 = await readdir(folder).catch(() => []);
|
|
71977
72121
|
const subagents = await Promise.all(
|
|
71978
72122
|
files2.filter((file4) => file4.endsWith(".jsonl")).map(
|
|
71979
|
-
async (file4) => lastCallAtOf({ text: await tailOf({ path:
|
|
72123
|
+
async (file4) => lastCallAtOf({ text: await tailOf({ path: join4(folder, file4) }), command })
|
|
71980
72124
|
)
|
|
71981
72125
|
);
|
|
71982
72126
|
const session = lastCallAtOf({ text: await tailOf({ path }), command });
|
|
@@ -72041,8 +72185,7 @@ async function notBoundNotice({
|
|
|
72041
72185
|
() => false
|
|
72042
72186
|
);
|
|
72043
72187
|
if (told) return { notice: void 0 };
|
|
72044
|
-
await
|
|
72045
|
-
await writeFile4(path, String(context.nowMs()), { mode: 384 });
|
|
72188
|
+
await writeStateText({ path, text: String(context.nowMs()) });
|
|
72046
72189
|
const agent3 = (await context.store.read()).profiles[profile]?.name;
|
|
72047
72190
|
return {
|
|
72048
72191
|
notice: notBoundText({ meta: meta3, agent: agent3, configPath: context.environment.configPath })
|
|
@@ -72051,7 +72194,7 @@ async function notBoundNotice({
|
|
|
72051
72194
|
|
|
72052
72195
|
// src/services/plugin-hook.service.ts
|
|
72053
72196
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
72054
|
-
import { join as
|
|
72197
|
+
import { join as join5 } from "node:path";
|
|
72055
72198
|
async function agentProfileHere({
|
|
72056
72199
|
context,
|
|
72057
72200
|
args,
|
|
@@ -72072,11 +72215,8 @@ async function agentProfileHere({
|
|
|
72072
72215
|
}
|
|
72073
72216
|
async function projectHooksHere({ context }) {
|
|
72074
72217
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd;
|
|
72075
|
-
const path =
|
|
72076
|
-
return readFile6(path, "utf8").then(
|
|
72077
|
-
(text3) => hasLazeHooks({ settings: JSON.parse(text3) }),
|
|
72078
|
-
() => false
|
|
72079
|
-
);
|
|
72218
|
+
const path = join5(directory, ".claude", "settings.local.json");
|
|
72219
|
+
return readFile6(path, "utf8").then((text3) => hasLazeHooks({ settings: JSON.parse(text3) })).catch(() => false);
|
|
72080
72220
|
}
|
|
72081
72221
|
async function pluginHookArgs({
|
|
72082
72222
|
context,
|
|
@@ -72094,13 +72234,10 @@ async function pluginHookArgs({
|
|
|
72094
72234
|
var PRE_TOOL_TIMEOUT_MS = 3e3;
|
|
72095
72235
|
function statePath({ context, agent: agent3 }) {
|
|
72096
72236
|
const safe = agent3.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
72097
|
-
return
|
|
72237
|
+
return join6(dirname5(context.environment.configPath), "turns", `${safe}.json`);
|
|
72098
72238
|
}
|
|
72099
72239
|
async function readState({ context, agent: agent3 }) {
|
|
72100
|
-
return
|
|
72101
|
-
(text3) => JSON.parse(text3),
|
|
72102
|
-
() => void 0
|
|
72103
|
-
);
|
|
72240
|
+
return readStateJson({ path: statePath({ context, agent: agent3 }) });
|
|
72104
72241
|
}
|
|
72105
72242
|
function beat({
|
|
72106
72243
|
client,
|
|
@@ -72152,8 +72289,7 @@ async function turnStarted({
|
|
|
72152
72289
|
await beat({ client, state: opened, working: true }).catch(() => void 0);
|
|
72153
72290
|
}
|
|
72154
72291
|
const path = statePath({ context, agent: agent3 });
|
|
72155
|
-
await
|
|
72156
|
-
await writeFile5(path, JSON.stringify(state));
|
|
72292
|
+
await writeStateJson({ path, value: state });
|
|
72157
72293
|
await beat({ client, state, working: true }).catch(() => void 0);
|
|
72158
72294
|
}
|
|
72159
72295
|
async function turnEnded({
|
|
@@ -72163,7 +72299,7 @@ async function turnEnded({
|
|
|
72163
72299
|
}) {
|
|
72164
72300
|
const state = await readState({ context, agent: agent3 });
|
|
72165
72301
|
if (!state) return;
|
|
72166
|
-
await
|
|
72302
|
+
await rm2(statePath({ context, agent: agent3 }), { force: true });
|
|
72167
72303
|
await beat({ client, state, working: false }).catch(() => void 0);
|
|
72168
72304
|
}
|
|
72169
72305
|
async function preToolHook({ context, args }) {
|
|
@@ -72211,8 +72347,8 @@ async function preToolHook({ context, args }) {
|
|
|
72211
72347
|
}
|
|
72212
72348
|
|
|
72213
72349
|
// src/services/message-files.service.ts
|
|
72214
|
-
import { readFile as
|
|
72215
|
-
import { basename as
|
|
72350
|
+
import { readFile as readFile7, stat as stat3 } from "node:fs/promises";
|
|
72351
|
+
import { basename as basename4, resolve as resolve3 } from "node:path";
|
|
72216
72352
|
|
|
72217
72353
|
// src/rules/file-types.rules.ts
|
|
72218
72354
|
var TYPES = {
|
|
@@ -72310,7 +72446,7 @@ async function readyOf({ context, source }) {
|
|
|
72310
72446
|
return asBytes({ source, file: await downloaded({ context, url: value }) });
|
|
72311
72447
|
}
|
|
72312
72448
|
const full = resolve3(context.cwd, value);
|
|
72313
|
-
const found = await
|
|
72449
|
+
const found = await stat3(full).catch(() => void 0);
|
|
72314
72450
|
if (found?.isFile()) return asBytes({ source, file: await local({ full }) });
|
|
72315
72451
|
const marked = fileMarkerIdsIn(value)[0] ?? (UPLOADED_ID.test(value) ? value : void 0);
|
|
72316
72452
|
if (marked) return { kind: "id", id: marked };
|
|
@@ -72327,7 +72463,7 @@ function asBytes({ source, file: file4 }) {
|
|
|
72327
72463
|
async function downloaded({ context, url: url2 }) {
|
|
72328
72464
|
const response = await context.fetcher(url2);
|
|
72329
72465
|
if (!response.ok) throw new CliUsageError(`${url2} answered ${response.status}`);
|
|
72330
|
-
const fileName =
|
|
72466
|
+
const fileName = basename4(new URL(url2).pathname) || "file";
|
|
72331
72467
|
const header = (response.headers.get("content-type") ?? "").split(";")[0]?.trim();
|
|
72332
72468
|
return {
|
|
72333
72469
|
fileName,
|
|
@@ -72336,11 +72472,11 @@ async function downloaded({ context, url: url2 }) {
|
|
|
72336
72472
|
};
|
|
72337
72473
|
}
|
|
72338
72474
|
async function local({ full }) {
|
|
72339
|
-
const fileName =
|
|
72475
|
+
const fileName = basename4(full);
|
|
72340
72476
|
return {
|
|
72341
72477
|
fileName,
|
|
72342
72478
|
contentType: contentTypeOf(fileName),
|
|
72343
|
-
bytes: new Uint8Array(await
|
|
72479
|
+
bytes: new Uint8Array(await readFile7(full))
|
|
72344
72480
|
};
|
|
72345
72481
|
}
|
|
72346
72482
|
async function attachmentIdsOf({
|
|
@@ -72963,13 +73099,12 @@ function channelLabelIn(channel) {
|
|
|
72963
73099
|
}
|
|
72964
73100
|
|
|
72965
73101
|
// src/services/claude-wait.service.ts
|
|
72966
|
-
import { readFile as
|
|
72967
|
-
import { dirname as dirname13 } from "node:path";
|
|
73102
|
+
import { readFile as readFile8, rm as rm5 } from "node:fs/promises";
|
|
72968
73103
|
|
|
72969
73104
|
// src/services/connect-service.service.ts
|
|
72970
73105
|
import { createHash as createHash2 } from "node:crypto";
|
|
72971
|
-
import { mkdir as
|
|
72972
|
-
import { dirname as dirname12, join as
|
|
73106
|
+
import { mkdir as mkdir3, rm as rm4, writeFile } from "node:fs/promises";
|
|
73107
|
+
import { dirname as dirname12, join as join14 } from "node:path";
|
|
72973
73108
|
|
|
72974
73109
|
// src/rules/connect-service.rules.ts
|
|
72975
73110
|
function systemdWordOf(word3) {
|
|
@@ -73091,31 +73226,31 @@ function rolloutEventOf({
|
|
|
73091
73226
|
}
|
|
73092
73227
|
|
|
73093
73228
|
// src/services/connect-delivery.service.ts
|
|
73094
|
-
import {
|
|
73229
|
+
import { rm as rm3, stat as stat5 } from "node:fs/promises";
|
|
73095
73230
|
import { homedir as homedir3, hostname as hostname5 } from "node:os";
|
|
73096
|
-
import { dirname as dirname11, join as
|
|
73231
|
+
import { dirname as dirname11, join as join13 } from "node:path";
|
|
73097
73232
|
|
|
73098
73233
|
// src/services/codex-turn-watch.service.ts
|
|
73099
|
-
import { open as
|
|
73100
|
-
import { basename as
|
|
73234
|
+
import { open as open4, readdir as readdir2 } from "node:fs/promises";
|
|
73235
|
+
import { basename as basename5, join as join7 } from "node:path";
|
|
73101
73236
|
var READ_MS = 1500;
|
|
73102
73237
|
var KEEP_WORKING_MS = 3e4;
|
|
73103
73238
|
async function codexRolloutPathOf({
|
|
73104
73239
|
codexHome,
|
|
73105
73240
|
threadId
|
|
73106
73241
|
}) {
|
|
73107
|
-
const root =
|
|
73242
|
+
const root = join7(codexHome, "sessions");
|
|
73108
73243
|
const files2 = await readdir2(root, { recursive: true }).catch(() => []);
|
|
73109
73244
|
const file4 = files2.find(
|
|
73110
|
-
(name3) =>
|
|
73245
|
+
(name3) => basename5(name3).startsWith("rollout-") && name3.endsWith(`-${threadId}.jsonl`)
|
|
73111
73246
|
);
|
|
73112
|
-
return file4 ?
|
|
73247
|
+
return file4 ? join7(root, file4) : void 0;
|
|
73113
73248
|
}
|
|
73114
73249
|
function rolloutPathOf({ delivery }) {
|
|
73115
73250
|
return codexRolloutPathOf({ codexHome: delivery.codexHome, threadId: delivery.threadId });
|
|
73116
73251
|
}
|
|
73117
73252
|
async function readFrom({ path, offset }) {
|
|
73118
|
-
const handle = await
|
|
73253
|
+
const handle = await open4(path, "r");
|
|
73119
73254
|
try {
|
|
73120
73255
|
const { size } = await handle.stat();
|
|
73121
73256
|
if (size <= offset) return { text: "", size };
|
|
@@ -73198,8 +73333,7 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
73198
73333
|
};
|
|
73199
73334
|
|
|
73200
73335
|
// src/services/mcp-relay.service.ts
|
|
73201
|
-
import {
|
|
73202
|
-
import { dirname as dirname6, join as join7 } from "node:path";
|
|
73336
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
73203
73337
|
|
|
73204
73338
|
// ../../node_modules/.pnpm/ws@8.21.3_bufferutil@4.1.0/node_modules/ws/wrapper.mjs
|
|
73205
73339
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -73535,24 +73669,17 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
73535
73669
|
[CONNECTOR_RELAY_CLOSE.replaced.code, "another relay for this server took over"]
|
|
73536
73670
|
]);
|
|
73537
73671
|
function mcpRelaysPathOf({ context }) {
|
|
73538
|
-
return
|
|
73672
|
+
return join8(dirname6(context.environment.configPath), "connect", "mcp-relays.json");
|
|
73539
73673
|
}
|
|
73540
73674
|
async function readMcpRelays({ context }) {
|
|
73541
|
-
|
|
73542
|
-
return JSON.parse(await readFile9(mcpRelaysPathOf({ context }), "utf8"));
|
|
73543
|
-
} catch {
|
|
73544
|
-
return {};
|
|
73545
|
-
}
|
|
73675
|
+
return await readStateJson({ path: mcpRelaysPathOf({ context }) }) ?? {};
|
|
73546
73676
|
}
|
|
73547
73677
|
async function saveMcpRelays({
|
|
73548
73678
|
context,
|
|
73549
73679
|
relays
|
|
73550
73680
|
}) {
|
|
73551
73681
|
const path = mcpRelaysPathOf({ context });
|
|
73552
|
-
await
|
|
73553
|
-
await writeFile6(path, `${JSON.stringify(relays, null, 2)}
|
|
73554
|
-
`, { mode: 384 });
|
|
73555
|
-
await chmod2(path, 384);
|
|
73682
|
+
await writeStateJson({ path, value: relays, pretty: true });
|
|
73556
73683
|
}
|
|
73557
73684
|
function mcpRelaySocketUrlOf(url2) {
|
|
73558
73685
|
const parsed = new URL(CONNECTOR_RELAY_PATH, url2);
|
|
@@ -73702,8 +73829,7 @@ var McpRelayLoops = class _McpRelayLoops {
|
|
|
73702
73829
|
};
|
|
73703
73830
|
|
|
73704
73831
|
// src/services/openclaw-relay.service.ts
|
|
73705
|
-
import {
|
|
73706
|
-
import { dirname as dirname7, join as join8 } from "node:path";
|
|
73832
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
73707
73833
|
|
|
73708
73834
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
73709
73835
|
var workspaceIdSchema18 = external_exports.string().min(1);
|
|
@@ -73924,24 +74050,17 @@ var STOPS2 = /* @__PURE__ */ new Map([
|
|
|
73924
74050
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
73925
74051
|
]);
|
|
73926
74052
|
function relaysPathOf({ context }) {
|
|
73927
|
-
return
|
|
74053
|
+
return join9(dirname7(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
73928
74054
|
}
|
|
73929
74055
|
async function readRelays({ context }) {
|
|
73930
|
-
|
|
73931
|
-
return JSON.parse(await readFile10(relaysPathOf({ context }), "utf8"));
|
|
73932
|
-
} catch {
|
|
73933
|
-
return {};
|
|
73934
|
-
}
|
|
74056
|
+
return await readStateJson({ path: relaysPathOf({ context }) }) ?? {};
|
|
73935
74057
|
}
|
|
73936
74058
|
async function saveRelays({
|
|
73937
74059
|
context,
|
|
73938
74060
|
relays
|
|
73939
74061
|
}) {
|
|
73940
74062
|
const path = relaysPathOf({ context });
|
|
73941
|
-
await
|
|
73942
|
-
await writeFile7(path, `${JSON.stringify(relays, null, 2)}
|
|
73943
|
-
`, { mode: 384 });
|
|
73944
|
-
await chmod3(path, 384);
|
|
74063
|
+
await writeStateJson({ path, value: relays, pretty: true });
|
|
73945
74064
|
}
|
|
73946
74065
|
function relaySocketUrlOf(url2) {
|
|
73947
74066
|
const parsed = new URL(OPENCLAW_RELAY_PATH, url2);
|
|
@@ -74019,18 +74138,18 @@ var RelaySession = class {
|
|
|
74019
74138
|
if (!envelope) return;
|
|
74020
74139
|
const { line, payload } = envelope;
|
|
74021
74140
|
if (envelope.kind === "open") return this.dial(relay2, line);
|
|
74022
|
-
const
|
|
74023
|
-
if (!
|
|
74141
|
+
const open6 = this.#lines.get(line);
|
|
74142
|
+
if (!open6) return;
|
|
74024
74143
|
if (envelope.kind === "close") {
|
|
74025
74144
|
this.#lines.delete(line);
|
|
74026
|
-
|
|
74145
|
+
open6.socket.close(1e3);
|
|
74027
74146
|
return;
|
|
74028
74147
|
}
|
|
74029
74148
|
if (envelope.kind !== "text" && envelope.kind !== "binary") return;
|
|
74030
74149
|
const frame = { data: Buffer.from(payload), binary: envelope.kind === "binary" };
|
|
74031
|
-
if (
|
|
74032
|
-
|
|
74033
|
-
} else
|
|
74150
|
+
if (open6.socket.readyState === wrapper_default.OPEN) {
|
|
74151
|
+
open6.socket.send(frame.data, { binary: frame.binary });
|
|
74152
|
+
} else open6.waiting.push(frame);
|
|
74034
74153
|
}
|
|
74035
74154
|
/** Dials the gateway for a line; its frames go back to Laze as they came. */
|
|
74036
74155
|
dial(relay2, line) {
|
|
@@ -74124,12 +74243,11 @@ var RelayLoops = class _RelayLoops {
|
|
|
74124
74243
|
};
|
|
74125
74244
|
|
|
74126
74245
|
// src/services/rush-listeners.service.ts
|
|
74127
|
-
import {
|
|
74128
|
-
import { dirname as dirname9, join as
|
|
74246
|
+
import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
74247
|
+
import { dirname as dirname9, join as join11 } from "node:path";
|
|
74129
74248
|
|
|
74130
74249
|
// src/services/rush-host.service.ts
|
|
74131
|
-
import {
|
|
74132
|
-
import { dirname as dirname8, join as join9 } from "node:path";
|
|
74250
|
+
import { dirname as dirname8, join as join10 } from "node:path";
|
|
74133
74251
|
async function rushAboveOf({
|
|
74134
74252
|
context,
|
|
74135
74253
|
from = context.processes.pid
|
|
@@ -74143,7 +74261,7 @@ async function rushAboveOf({
|
|
|
74143
74261
|
return void 0;
|
|
74144
74262
|
}
|
|
74145
74263
|
function guardPathOf({ context, claudePid }) {
|
|
74146
|
-
return
|
|
74264
|
+
return join10(dirname8(context.environment.configPath), "rush-guards", `${claudePid}.json`);
|
|
74147
74265
|
}
|
|
74148
74266
|
async function startRushGuard({
|
|
74149
74267
|
context,
|
|
@@ -74156,7 +74274,7 @@ async function startRushGuard({
|
|
|
74156
74274
|
if (holder && context.processes.alive(holder.pid)) return;
|
|
74157
74275
|
const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
|
|
74158
74276
|
const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
|
|
74159
|
-
const logPath =
|
|
74277
|
+
const logPath = join10(dirname8(context.environment.configPath), "rush-guards", "guard.log");
|
|
74160
74278
|
context.processes.spawnDetached({ argv: ["sh", "-c", '"$@" &', "sh", ...argv], logPath });
|
|
74161
74279
|
}
|
|
74162
74280
|
async function claimRushGuard({
|
|
@@ -74164,26 +74282,24 @@ async function claimRushGuard({
|
|
|
74164
74282
|
claudePid
|
|
74165
74283
|
}) {
|
|
74166
74284
|
const path = guardPathOf({ context, claudePid });
|
|
74167
|
-
|
|
74168
|
-
|
|
74169
|
-
|
|
74170
|
-
|
|
74171
|
-
|
|
74172
|
-
|
|
74285
|
+
return withStateLock({
|
|
74286
|
+
path,
|
|
74287
|
+
work: async () => {
|
|
74288
|
+
const holder = await guardHolderOf({ path });
|
|
74289
|
+
const self2 = context.processes.pid;
|
|
74290
|
+
if (holder && holder.pid !== self2 && context.processes.alive(holder.pid)) return false;
|
|
74291
|
+
await writeStateJson({ path, value: { pid: self2, claudePid } });
|
|
74292
|
+
return true;
|
|
74293
|
+
}
|
|
74294
|
+
});
|
|
74173
74295
|
}
|
|
74174
74296
|
function guardHolderOf({ path }) {
|
|
74175
|
-
return
|
|
74176
|
-
(text3) => JSON.parse(text3),
|
|
74177
|
-
() => void 0
|
|
74178
|
-
);
|
|
74297
|
+
return readStateJson({ path });
|
|
74179
74298
|
}
|
|
74180
74299
|
|
|
74181
74300
|
// src/services/rush-listeners.service.ts
|
|
74182
74301
|
async function jsonOf(path) {
|
|
74183
|
-
return
|
|
74184
|
-
(text3) => JSON.parse(text3),
|
|
74185
|
-
() => void 0
|
|
74186
|
-
);
|
|
74302
|
+
return readStateJson({ path });
|
|
74187
74303
|
}
|
|
74188
74304
|
async function notesOf({ context }) {
|
|
74189
74305
|
const folder = dirname9(statePathOf({ context, kind: "sessions", profile: "x" }));
|
|
@@ -74191,8 +74307,8 @@ async function notesOf({ context }) {
|
|
|
74191
74307
|
const notes = await Promise.all(
|
|
74192
74308
|
files2.map(async (file4) => {
|
|
74193
74309
|
const pid = Number(file4.replace(/\.json$/, ""));
|
|
74194
|
-
const note = await jsonOf(
|
|
74195
|
-
const at = await
|
|
74310
|
+
const note = await jsonOf(join11(folder, file4));
|
|
74311
|
+
const at = await stat4(join11(folder, file4)).then(
|
|
74196
74312
|
(info) => info.mtimeMs,
|
|
74197
74313
|
() => 0
|
|
74198
74314
|
);
|
|
@@ -74272,8 +74388,8 @@ async function rearmRushGuards({ context }) {
|
|
|
74272
74388
|
}
|
|
74273
74389
|
|
|
74274
74390
|
// src/services/rush-watchdog.service.ts
|
|
74275
|
-
import { appendFile, mkdir as
|
|
74276
|
-
import { dirname as dirname10, join as
|
|
74391
|
+
import { appendFile, mkdir as mkdir2 } from "node:fs/promises";
|
|
74392
|
+
import { dirname as dirname10, join as join12 } from "node:path";
|
|
74277
74393
|
var UNDELIVERED_AFTER_MS = 6e4;
|
|
74278
74394
|
var CHECK_TIMEOUT_MS = 5e3;
|
|
74279
74395
|
function clientOf({ context, profile }) {
|
|
@@ -74292,9 +74408,9 @@ async function waitingOf({ context, profile }) {
|
|
|
74292
74408
|
const client = await clientOf({ context, profile });
|
|
74293
74409
|
return client?.get("/api/agents/me/inbox/waiting").catch(() => void 0);
|
|
74294
74410
|
}
|
|
74295
|
-
function waitedMsOf({ waiting, nowMs }) {
|
|
74411
|
+
function waitedMsOf({ waiting, nowMs: nowMs2 }) {
|
|
74296
74412
|
if (waiting.count === 0 || !waiting.oldestPostedAt) return 0;
|
|
74297
|
-
return Math.max(0,
|
|
74413
|
+
return Math.max(0, nowMs2 - Temporal3.Instant.from(waiting.oldestPostedAt).epochMilliseconds);
|
|
74298
74414
|
}
|
|
74299
74415
|
function boundAwayOf({ waiting, key }) {
|
|
74300
74416
|
const bound = waiting.session;
|
|
@@ -74302,13 +74418,13 @@ function boundAwayOf({ waiting, key }) {
|
|
|
74302
74418
|
return `${sessionLabelOf(bound)} (${bound.harness}:${bound.sessionId})`;
|
|
74303
74419
|
}
|
|
74304
74420
|
async function logDelivery({ context, line }) {
|
|
74305
|
-
const folder =
|
|
74421
|
+
const folder = join12(dirname10(context.environment.configPath), "connect");
|
|
74306
74422
|
const at = Temporal3.Instant.fromEpochMilliseconds(context.nowMs());
|
|
74307
74423
|
const stamped = `${at.toString({ smallestUnit: "second" })} ${line}
|
|
74308
74424
|
`;
|
|
74309
74425
|
context.out(stamped);
|
|
74310
|
-
await
|
|
74311
|
-
await appendFile(
|
|
74426
|
+
await mkdir2(folder, { recursive: true, mode: 448 });
|
|
74427
|
+
await appendFile(join12(folder, "delivery.log"), stamped, { mode: 384 });
|
|
74312
74428
|
}
|
|
74313
74429
|
async function claimFor({
|
|
74314
74430
|
context,
|
|
@@ -74384,17 +74500,13 @@ async function watchRushDelivery({
|
|
|
74384
74500
|
|
|
74385
74501
|
// src/services/connect-delivery.service.ts
|
|
74386
74502
|
function connectFolderOf({ context }) {
|
|
74387
|
-
return
|
|
74503
|
+
return join13(dirname11(context.environment.configPath), "connect");
|
|
74388
74504
|
}
|
|
74389
74505
|
function runStatePathOf({ context }) {
|
|
74390
|
-
return
|
|
74506
|
+
return join13(connectFolderOf({ context }), "run.json");
|
|
74391
74507
|
}
|
|
74392
74508
|
async function readJson({ path }) {
|
|
74393
|
-
|
|
74394
|
-
return JSON.parse(await readFile13(path, "utf8"));
|
|
74395
|
-
} catch {
|
|
74396
|
-
return void 0;
|
|
74397
|
-
}
|
|
74509
|
+
return readStateJson({ path });
|
|
74398
74510
|
}
|
|
74399
74511
|
async function runStateOf({ context }) {
|
|
74400
74512
|
return readJson({ path: runStatePathOf({ context }) });
|
|
@@ -74406,7 +74518,7 @@ var CLI_CHANGED_EXIT = 75;
|
|
|
74406
74518
|
async function cliStampOf({ context }) {
|
|
74407
74519
|
const file4 = context.program.at(-1);
|
|
74408
74520
|
if (!file4) return "";
|
|
74409
|
-
return
|
|
74521
|
+
return stat5(file4).then(
|
|
74410
74522
|
(info) => `${info.mtimeMs}:${info.size}`,
|
|
74411
74523
|
() => ""
|
|
74412
74524
|
);
|
|
@@ -74557,12 +74669,8 @@ async function serveRounds({
|
|
|
74557
74669
|
}
|
|
74558
74670
|
}
|
|
74559
74671
|
}
|
|
74560
|
-
var saves = 0;
|
|
74561
74672
|
async function save(run4) {
|
|
74562
|
-
await
|
|
74563
|
-
const temporary = `${run4.path}.${run4.self}.${saves += 1}.tmp`;
|
|
74564
|
-
await writeFile9(temporary, JSON.stringify(run4.state));
|
|
74565
|
-
await rename3(temporary, run4.path);
|
|
74673
|
+
await writeStateJson({ path: run4.path, value: run4.state });
|
|
74566
74674
|
}
|
|
74567
74675
|
async function holdsLock(run4) {
|
|
74568
74676
|
return (await runStateOf({ context: run4.context }))?.pid === run4.self;
|
|
@@ -74660,7 +74768,7 @@ async function runConnectLoop({ context }) {
|
|
|
74660
74768
|
await mcpRelays.stopAll();
|
|
74661
74769
|
for (const current3 of run4.served.values()) current3.stop.abort();
|
|
74662
74770
|
await Promise.all([...run4.served.values()].map((current3) => current3.done));
|
|
74663
|
-
if (await holdsLock(run4)) await
|
|
74771
|
+
if (await holdsLock(run4)) await rm3(run4.path, { force: true });
|
|
74664
74772
|
}
|
|
74665
74773
|
return 0;
|
|
74666
74774
|
}
|
|
@@ -74678,17 +74786,17 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
|
|
|
74678
74786
|
\`laze openclaw connect --local\` and \`laze kanban connect\`, whose relays it also runs.
|
|
74679
74787
|
`;
|
|
74680
74788
|
function installedPathOf({ context }) {
|
|
74681
|
-
return
|
|
74789
|
+
return join14(connectFolderOf({ context }), "service.json");
|
|
74682
74790
|
}
|
|
74683
74791
|
function logPathOf({ context }) {
|
|
74684
|
-
return
|
|
74792
|
+
return join14(connectFolderOf({ context }), "connect.log");
|
|
74685
74793
|
}
|
|
74686
74794
|
function homeOf({ context }) {
|
|
74687
74795
|
return context.environment.inherited.HOME ?? dirname12(dirname12(context.environment.configPath));
|
|
74688
74796
|
}
|
|
74689
74797
|
function serviceNameOf({ context }) {
|
|
74690
74798
|
const { configPath } = context.environment;
|
|
74691
|
-
if (configPath ===
|
|
74799
|
+
if (configPath === join14(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
|
|
74692
74800
|
return `laze-connect-${createHash2("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
74693
74801
|
}
|
|
74694
74802
|
function serviceEnvOf({ context }) {
|
|
@@ -74711,10 +74819,10 @@ async function run({ context, command }) {
|
|
|
74711
74819
|
async function installSystemd({ context }) {
|
|
74712
74820
|
const name3 = serviceNameOf({ context });
|
|
74713
74821
|
const env = context.environment.inherited;
|
|
74714
|
-
const base = env.XDG_CONFIG_HOME ||
|
|
74715
|
-
const file4 =
|
|
74716
|
-
await
|
|
74717
|
-
await
|
|
74822
|
+
const base = env.XDG_CONFIG_HOME || join14(homeOf({ context }), ".config");
|
|
74823
|
+
const file4 = join14(base, "systemd", "user", `${name3}.service`);
|
|
74824
|
+
await mkdir3(dirname12(file4), { recursive: true });
|
|
74825
|
+
await writeFile(
|
|
74718
74826
|
file4,
|
|
74719
74827
|
systemdUnitOf({ argv: runArgvOf({ context }), env: serviceEnvOf({ context }) })
|
|
74720
74828
|
);
|
|
@@ -74727,10 +74835,10 @@ async function installSystemd({ context }) {
|
|
|
74727
74835
|
async function installLaunchd({ context }) {
|
|
74728
74836
|
const name3 = serviceNameOf({ context });
|
|
74729
74837
|
const label3 = `ai.laze.${name3}`;
|
|
74730
|
-
const file4 =
|
|
74838
|
+
const file4 = join14(homeOf({ context }), "Library", "LaunchAgents", `${label3}.plist`);
|
|
74731
74839
|
const log = logPathOf({ context });
|
|
74732
|
-
await
|
|
74733
|
-
await
|
|
74840
|
+
await mkdir3(dirname12(file4), { recursive: true });
|
|
74841
|
+
await writeFile(
|
|
74734
74842
|
file4,
|
|
74735
74843
|
launchAgentOf({
|
|
74736
74844
|
label: label3,
|
|
@@ -74782,8 +74890,7 @@ async function installConnectService({ context }) {
|
|
|
74782
74890
|
const manager = await managerOf({ context });
|
|
74783
74891
|
const install = { systemd: installSystemd, launchd: installLaunchd, detached: installDetached };
|
|
74784
74892
|
const installed = await install[manager]({ context });
|
|
74785
|
-
await
|
|
74786
|
-
await writeFile10(path, JSON.stringify(installed));
|
|
74893
|
+
await writeStateJson({ path, value: installed });
|
|
74787
74894
|
return describeInstalled({ installed });
|
|
74788
74895
|
}
|
|
74789
74896
|
async function ensureConnectService({ context }) {
|
|
@@ -74830,15 +74937,14 @@ async function status2({ context }) {
|
|
|
74830
74937
|
}
|
|
74831
74938
|
const config2 = await context.store.read();
|
|
74832
74939
|
const linked = Object.entries(config2.profiles).filter(([, profile]) => profile.delivery);
|
|
74833
|
-
if (linked.length === 0)
|
|
74834
|
-
context.out("No Codex agent is linked on this machine.\n");
|
|
74835
|
-
return;
|
|
74836
|
-
}
|
|
74940
|
+
if (linked.length === 0) context.out("No Codex agent is linked on this machine.\n");
|
|
74837
74941
|
for (const [profile, { name: name3, delivery }] of linked) {
|
|
74838
74942
|
const state = live ? running.agents[profile]?.state ?? "starting" : "not served";
|
|
74839
74943
|
context.out(`${profile} ${name3} Codex thread ${delivery?.threadId} ${state}
|
|
74840
74944
|
`);
|
|
74841
74945
|
}
|
|
74946
|
+
for (const line of await repairDamagedStateFiles()) context.out(`${line}
|
|
74947
|
+
`);
|
|
74842
74948
|
}
|
|
74843
74949
|
async function mcpRelayLinesOf({ context }) {
|
|
74844
74950
|
const running = await runStateOf({ context });
|
|
@@ -74863,12 +74969,12 @@ function rushLineOf({ row }) {
|
|
|
74863
74969
|
function inLazeOf({
|
|
74864
74970
|
row,
|
|
74865
74971
|
waiting,
|
|
74866
|
-
nowMs
|
|
74972
|
+
nowMs: nowMs2
|
|
74867
74973
|
}) {
|
|
74868
74974
|
if (!waiting) return "; Laze could not say what waits";
|
|
74869
74975
|
const away = boundAwayOf({ waiting, key: row.key });
|
|
74870
74976
|
const bound = away ? `; Laze binds the agent to ${away}, not this session` : "";
|
|
74871
|
-
const waited = waitedMsOf({ waiting, nowMs });
|
|
74977
|
+
const waited = waitedMsOf({ waiting, nowMs: nowMs2 });
|
|
74872
74978
|
if (waiting.count === 0) return bound;
|
|
74873
74979
|
const age = `the oldest for ${Math.round(waited / 1e3)}s`;
|
|
74874
74980
|
if (waited > UNDELIVERED_AFTER_MS)
|
|
@@ -74899,11 +75005,11 @@ async function uninstall({ context }) {
|
|
|
74899
75005
|
command: ["systemctl", "--user", "disable", `${installed.name}.service`]
|
|
74900
75006
|
});
|
|
74901
75007
|
}
|
|
74902
|
-
if (installed.file) await
|
|
75008
|
+
if (installed.file) await rm4(installed.file, { force: true });
|
|
74903
75009
|
if (installed.manager === "systemd") {
|
|
74904
75010
|
await run({ context, command: ["systemctl", "--user", "daemon-reload"] });
|
|
74905
75011
|
}
|
|
74906
|
-
await
|
|
75012
|
+
await rm4(path, { force: true });
|
|
74907
75013
|
context.out(
|
|
74908
75014
|
`Removed the connect service (${installed.manager}, ${installed.name}). Linked Codex agents get no messages until \`laze connect install\`.
|
|
74909
75015
|
`
|
|
@@ -74933,10 +75039,7 @@ var ROUND_SECONDS2 = 50;
|
|
|
74933
75039
|
var WATCH_MS = 2e3;
|
|
74934
75040
|
var CHANNEL_CHECK_MS = 5e3;
|
|
74935
75041
|
async function holderOf({ path }) {
|
|
74936
|
-
return
|
|
74937
|
-
(text3) => JSON.parse(text3),
|
|
74938
|
-
() => void 0
|
|
74939
|
-
);
|
|
75042
|
+
return readStateJson({ path });
|
|
74940
75043
|
}
|
|
74941
75044
|
async function holderClaudeOf({ context, holder }) {
|
|
74942
75045
|
if (holder.claudePid) return holder.claudePid;
|
|
@@ -74949,25 +75052,27 @@ async function takeLock({
|
|
|
74949
75052
|
claudePid,
|
|
74950
75053
|
preempt = false
|
|
74951
75054
|
}) {
|
|
74952
|
-
|
|
74953
|
-
const self2 = context.processes.pid;
|
|
74954
|
-
if (holder && holder.pid !== self2 && context.processes.alive(holder.pid)) {
|
|
74955
|
-
const served = await holderClaudeOf({ context, holder });
|
|
74956
|
-
const mine4 = preempt && served === claudePid && !holder.monitor;
|
|
74957
|
-
if (served && context.processes.alive(served) && !mine4) return false;
|
|
74958
|
-
context.processes.stop(holder.pid);
|
|
74959
|
-
}
|
|
74960
|
-
await mkdir12(dirname13(path), { recursive: true, mode: 448 });
|
|
74961
|
-
await writeFile11(
|
|
75055
|
+
return withStateLock({
|
|
74962
75056
|
path,
|
|
74963
|
-
|
|
74964
|
-
|
|
74965
|
-
|
|
74966
|
-
|
|
74967
|
-
|
|
74968
|
-
|
|
74969
|
-
|
|
74970
|
-
|
|
75057
|
+
work: async () => {
|
|
75058
|
+
const holder = await holderOf({ path });
|
|
75059
|
+
const self2 = context.processes.pid;
|
|
75060
|
+
if (holder && holder.pid !== self2 && context.processes.alive(holder.pid)) {
|
|
75061
|
+
const served = await holderClaudeOf({ context, holder });
|
|
75062
|
+
const mine4 = preempt && served === claudePid && !holder.monitor;
|
|
75063
|
+
if (served && context.processes.alive(served) && !mine4) return false;
|
|
75064
|
+
context.processes.stop(holder.pid);
|
|
75065
|
+
}
|
|
75066
|
+
const value = {
|
|
75067
|
+
pid: self2,
|
|
75068
|
+
claudePid,
|
|
75069
|
+
...sessionId ? { sessionId } : {},
|
|
75070
|
+
...preempt ? { monitor: true } : {}
|
|
75071
|
+
};
|
|
75072
|
+
await writeStateJson({ path, value });
|
|
75073
|
+
return true;
|
|
75074
|
+
}
|
|
75075
|
+
});
|
|
74971
75076
|
}
|
|
74972
75077
|
async function channelLive({ context, profile }) {
|
|
74973
75078
|
const holder = await holderOf({ path: statePathOf({ context, kind: "channels", profile }) });
|
|
@@ -75087,7 +75192,7 @@ async function waitForMessages({ context, args }) {
|
|
|
75087
75192
|
if (rush) await healRushDelivery({ context });
|
|
75088
75193
|
const lock = statePathOf({ context, kind: "waiters", profile: name3 });
|
|
75089
75194
|
if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
|
|
75090
|
-
const seen = () => input2.transcript_path ?
|
|
75195
|
+
const seen = () => input2.transcript_path ? readFile8(input2.transcript_path, "utf8") : Promise.resolve("");
|
|
75091
75196
|
const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
|
|
75092
75197
|
try {
|
|
75093
75198
|
while (context.nowMs() < deadline) {
|
|
@@ -75098,7 +75203,7 @@ async function waitForMessages({ context, args }) {
|
|
|
75098
75203
|
return 0;
|
|
75099
75204
|
} finally {
|
|
75100
75205
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
75101
|
-
await
|
|
75206
|
+
await rm5(lock, { force: true });
|
|
75102
75207
|
}
|
|
75103
75208
|
}
|
|
75104
75209
|
async function healRushDelivery({ context }) {
|
|
@@ -75139,14 +75244,14 @@ async function monitorServes({
|
|
|
75139
75244
|
|
|
75140
75245
|
// src/services/codex-link.service.ts
|
|
75141
75246
|
import { createReadStream } from "node:fs";
|
|
75142
|
-
import { readdir as readdir5, rm as
|
|
75143
|
-
import { join as
|
|
75247
|
+
import { readdir as readdir5, rm as rm7, stat as stat7 } from "node:fs/promises";
|
|
75248
|
+
import { join as join16, resolve as resolve4 } from "node:path";
|
|
75144
75249
|
import { createInterface as createInterface2 } from "node:readline";
|
|
75145
75250
|
|
|
75146
75251
|
// src/services/codex-adopt.service.ts
|
|
75147
75252
|
import { spawn as spawn2 } from "node:child_process";
|
|
75148
|
-
import {
|
|
75149
|
-
import {
|
|
75253
|
+
import { readdir as readdir4, rm as rm6, stat as stat6 } from "node:fs/promises";
|
|
75254
|
+
import { join as join15 } from "node:path";
|
|
75150
75255
|
import { createInterface } from "node:readline";
|
|
75151
75256
|
|
|
75152
75257
|
// src/rules/codex-requests.rules.ts
|
|
@@ -75205,8 +75310,8 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
75205
75310
|
}
|
|
75206
75311
|
async call(method, params) {
|
|
75207
75312
|
const id4 = ++this.#nextId;
|
|
75208
|
-
const reply2 = await new Promise((
|
|
75209
|
-
this.#pending.set(id4,
|
|
75313
|
+
const reply2 = await new Promise((resolve26) => {
|
|
75314
|
+
this.#pending.set(id4, resolve26);
|
|
75210
75315
|
this.write({ id: id4, method, params });
|
|
75211
75316
|
});
|
|
75212
75317
|
if (reply2.error !== void 0) throw new Error(`${method}: ${JSON.stringify(reply2.error)}`);
|
|
@@ -75218,12 +75323,12 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
75218
75323
|
/** Starts one turn; `done` settles when it completes, keeping its last agent message. */
|
|
75219
75324
|
async startTurn({ threadId, text: text3 }) {
|
|
75220
75325
|
const result2 = { answer: "" };
|
|
75221
|
-
const done = new Promise((
|
|
75326
|
+
const done = new Promise((resolve26) => {
|
|
75222
75327
|
const listen = (message2) => {
|
|
75223
75328
|
absorbTurnEvent({ result: result2, message: message2 });
|
|
75224
75329
|
if (message2.method !== "turn/completed") return;
|
|
75225
75330
|
this.#listeners.delete(listen);
|
|
75226
|
-
|
|
75331
|
+
resolve26(result2);
|
|
75227
75332
|
};
|
|
75228
75333
|
this.#listeners.add(listen);
|
|
75229
75334
|
});
|
|
@@ -75266,11 +75371,11 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
75266
75371
|
}
|
|
75267
75372
|
};
|
|
75268
75373
|
async function newestThreadId({ codexHome }) {
|
|
75269
|
-
const root =
|
|
75374
|
+
const root = join15(codexHome, "sessions");
|
|
75270
75375
|
const files2 = await readdir4(root, { recursive: true }).catch(() => []);
|
|
75271
75376
|
const rollouts = files2.filter((file4) => /rollout-.*\.jsonl$/.test(file4));
|
|
75272
75377
|
const dated = await Promise.all(
|
|
75273
|
-
rollouts.map(async (file4) => ({ file: file4, at: (await
|
|
75378
|
+
rollouts.map(async (file4) => ({ file: file4, at: (await stat6(join15(root, file4))).mtimeMs }))
|
|
75274
75379
|
);
|
|
75275
75380
|
const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
|
|
75276
75381
|
const id4 = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/.exec(newest);
|
|
@@ -75345,10 +75450,7 @@ async function answer2({
|
|
|
75345
75450
|
var MAX_RESTART_WAIT_SECONDS = 60;
|
|
75346
75451
|
var HEALTHY_RUN_MS = 6e4;
|
|
75347
75452
|
async function recordOf({ path }) {
|
|
75348
|
-
return
|
|
75349
|
-
(text3) => JSON.parse(text3),
|
|
75350
|
-
() => void 0
|
|
75351
|
-
);
|
|
75453
|
+
return readStateJson({ path });
|
|
75352
75454
|
}
|
|
75353
75455
|
function threadFlag({ thread: thread2 }) {
|
|
75354
75456
|
return thread2 ? ["--thread", thread2] : [];
|
|
@@ -75367,8 +75469,7 @@ async function startAdoptInBackground({
|
|
|
75367
75469
|
const adopt = ["adopt", "codex", "--profile", profile, ...threadFlag({ thread: thread2 })];
|
|
75368
75470
|
const argv = [...context.program, ...adopt, "--supervise"];
|
|
75369
75471
|
const pid = context.processes.spawnDetached({ argv, logPath: log });
|
|
75370
|
-
await
|
|
75371
|
-
await writeFile12(path, JSON.stringify({ pid, thread: thread2, log, startedAt: context.nowMs() }));
|
|
75472
|
+
await writeStateJson({ path, value: { pid, thread: thread2, log, startedAt: context.nowMs() } });
|
|
75372
75473
|
return [
|
|
75373
75474
|
`Started \`${laze} adopt codex\` in the background (pid ${pid}). It answers each Laze message`,
|
|
75374
75475
|
`as a turn in ${thread2 ? `this Codex thread (${thread2})` : "the newest Codex thread"}, and starts again if it stops.`,
|
|
@@ -75427,7 +75528,7 @@ Log: ${record4.log}
|
|
|
75427
75528
|
async function adoptStop({ context, profile }) {
|
|
75428
75529
|
const path = statePathOf({ context, kind: "adopt", profile });
|
|
75429
75530
|
const record4 = await recordOf({ path });
|
|
75430
|
-
await
|
|
75531
|
+
await rm6(path, { force: true });
|
|
75431
75532
|
if (!record4 || !context.processes.stop(record4.pid)) {
|
|
75432
75533
|
context.out(`laze adopt codex was not running in the background for profile "${profile}".
|
|
75433
75534
|
`);
|
|
@@ -75452,10 +75553,7 @@ async function adoptedThreadOf({
|
|
|
75452
75553
|
);
|
|
75453
75554
|
if (!held) return threadId;
|
|
75454
75555
|
const path = statePathOf({ context, kind: "adopt", profile, extension: "forks.json" });
|
|
75455
|
-
const forks = await
|
|
75456
|
-
(text3) => JSON.parse(text3),
|
|
75457
|
-
() => ({})
|
|
75458
|
-
);
|
|
75556
|
+
const forks = await readStateJson({ path }) ?? {};
|
|
75459
75557
|
const known = forks[threadId];
|
|
75460
75558
|
if (known && await codex.call("thread/resume", { threadId: known }).then(
|
|
75461
75559
|
() => true,
|
|
@@ -75467,8 +75565,7 @@ async function adoptedThreadOf({
|
|
|
75467
75565
|
}
|
|
75468
75566
|
const forked = record3((await codex.call("thread/fork", { threadId })).thread).id;
|
|
75469
75567
|
if (typeof forked !== "string") throw new Error("thread/fork answered no thread id");
|
|
75470
|
-
await
|
|
75471
|
-
await writeFile12(path, JSON.stringify({ ...forks, [threadId]: forked }));
|
|
75568
|
+
await writeStateJson({ path, value: { ...forks, [threadId]: forked } });
|
|
75472
75569
|
context.out(
|
|
75473
75570
|
`Codex holds thread ${threadId} open elsewhere; answering in its new fork ${forked}.
|
|
75474
75571
|
`
|
|
@@ -75539,13 +75636,13 @@ async function newestThreadIn({
|
|
|
75539
75636
|
codexHome,
|
|
75540
75637
|
directory
|
|
75541
75638
|
}) {
|
|
75542
|
-
const root =
|
|
75639
|
+
const root = join16(codexHome, "sessions");
|
|
75543
75640
|
const files2 = await readdir5(root, { recursive: true }).catch(() => []);
|
|
75544
75641
|
const rollouts = files2.filter((file4) => /rollout-.*\.jsonl$/.test(file4));
|
|
75545
75642
|
const dated = await Promise.all(
|
|
75546
75643
|
rollouts.map(async (file4) => ({
|
|
75547
|
-
path:
|
|
75548
|
-
at: await
|
|
75644
|
+
path: join16(root, file4),
|
|
75645
|
+
at: await stat7(join16(root, file4)).then(
|
|
75549
75646
|
(info) => info.mtimeMs,
|
|
75550
75647
|
() => 0
|
|
75551
75648
|
)
|
|
@@ -75576,7 +75673,7 @@ async function stopAdopt({ context, profile }) {
|
|
|
75576
75673
|
const running = await readJson({ path });
|
|
75577
75674
|
if (!running) return;
|
|
75578
75675
|
context.processes.stop(running.pid);
|
|
75579
|
-
await
|
|
75676
|
+
await rm7(path, { force: true });
|
|
75580
75677
|
}
|
|
75581
75678
|
async function linkCodexSession({
|
|
75582
75679
|
context,
|
|
@@ -75615,16 +75712,16 @@ async function linkCodexSession({
|
|
|
75615
75712
|
}
|
|
75616
75713
|
|
|
75617
75714
|
// src/services/laze-plugin.service.ts
|
|
75618
|
-
import { mkdir as
|
|
75715
|
+
import { mkdir as mkdir4, readFile as readFile9, rm as rm8, writeFile as writeFile2 } from "node:fs/promises";
|
|
75619
75716
|
import { homedir as homedir4 } from "node:os";
|
|
75620
|
-
import { dirname as
|
|
75717
|
+
import { dirname as dirname13, join as join18 } from "node:path";
|
|
75621
75718
|
|
|
75622
75719
|
// src/rules/laze-plugin.rules.ts
|
|
75623
75720
|
import { createHash as createHash3 } from "node:crypto";
|
|
75624
|
-
import { join as
|
|
75721
|
+
import { join as join17 } from "node:path";
|
|
75625
75722
|
var LAZE_PLUGIN = "laze";
|
|
75626
75723
|
function pluginNameOf({ configPath, home }) {
|
|
75627
|
-
if (configPath ===
|
|
75724
|
+
if (configPath === join17(home, ".laze", "config.json")) return LAZE_PLUGIN;
|
|
75628
75725
|
return `${LAZE_PLUGIN}-${createHash3("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
75629
75726
|
}
|
|
75630
75727
|
var NPX_CLI = ["npx", "-y", "@lazehq/cli@latest"];
|
|
@@ -75702,13 +75799,26 @@ When something needs a person to decide or act, post a card in their feed:
|
|
|
75702
75799
|
\`laze feed post "<title>" --summary "<why>" --action "<label>=<what to do>"\`. Run
|
|
75703
75800
|
\`laze feed post\` with no title for every flag and how to write a card.
|
|
75704
75801
|
|
|
75705
|
-
|
|
75706
|
-
|
|
75707
|
-
|
|
75708
|
-
|
|
75709
|
-
|
|
75710
|
-
|
|
75711
|
-
|
|
75802
|
+
Anything that goes to people outside this conversation (an email, a Slack, WhatsApp or LinkedIn
|
|
75803
|
+
message to someone else, a post) is a draft for your person first, on a feed card: a one-line ask
|
|
75804
|
+
as the title, the full text in \`--draft\`, the recipients and subject in
|
|
75805
|
+
\`--draft-header "To: ...\\nCc: ...\\nSubject: ..."\`, \`--action "Send it=<what to do>"\` and a
|
|
75806
|
+
\`--link\` that opens the original in its own app: for Gmail
|
|
75807
|
+
\`"Open thread with the draft=https://mail.google.com/mail/u/0/#all/<thread id>"\`, else the Slack,
|
|
75808
|
+
WhatsApp or LinkedIn thread or the GitHub PR. For example:
|
|
75809
|
+
|
|
75810
|
+
\`\`\`bash
|
|
75811
|
+
laze feed post "Reply to Dana about the renewal" --summary "She asked for the price by Friday" \\
|
|
75812
|
+
--draft @reply.md --draft-header "To: dana@acme.test\\nSubject: Re: Renewal" \\
|
|
75813
|
+
--link "Open thread with the draft=https://mail.google.com/mail/u/0/#all/<thread id>" \\
|
|
75814
|
+
--action "Send it=Send this reply"
|
|
75815
|
+
\`\`\`
|
|
75816
|
+
|
|
75817
|
+
They edit and send it from the card. Send such a message only when they pressed Send on its card
|
|
75818
|
+
or told you in chat to send that exact message ("send it", "manda"): a send approval card is not
|
|
75819
|
+
their review, so post the feed card first. After a send, say in one line what went to whom.
|
|
75820
|
+
Never leave a draft only in Gmail drafts. If they edit the text on the card, the press brings you
|
|
75821
|
+
the edited text: update the native draft with it first, then send.
|
|
75712
75822
|
|
|
75713
75823
|
A card you post or update while answering is linked under your reply: don't describe where the
|
|
75714
75824
|
card is, say what changed.
|
|
@@ -75853,14 +75963,11 @@ function installedNameOf({ context }) {
|
|
|
75853
75963
|
return `${name3}@${name3}`;
|
|
75854
75964
|
}
|
|
75855
75965
|
function pluginFolderOf({ context }) {
|
|
75856
|
-
return
|
|
75966
|
+
return join18(dirname13(context.environment.configPath), "plugins");
|
|
75857
75967
|
}
|
|
75858
75968
|
async function pluginIsCurrent({ context }) {
|
|
75859
|
-
const manifest =
|
|
75860
|
-
const written = await
|
|
75861
|
-
(text3) => JSON.parse(text3).version,
|
|
75862
|
-
() => void 0
|
|
75863
|
-
);
|
|
75969
|
+
const manifest = join18(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
|
|
75970
|
+
const written = await readFile9(manifest, "utf8").then((text3) => JSON.parse(text3).version).catch(() => void 0);
|
|
75864
75971
|
return written === cliVersionOf();
|
|
75865
75972
|
}
|
|
75866
75973
|
async function writeLazePlugin({ context }) {
|
|
@@ -75872,9 +75979,9 @@ async function writeLazePlugin({ context }) {
|
|
|
75872
75979
|
configPath: context.environment.configPath
|
|
75873
75980
|
});
|
|
75874
75981
|
for (const [path, text3] of Object.entries(files2)) {
|
|
75875
|
-
const target =
|
|
75876
|
-
await
|
|
75877
|
-
await
|
|
75982
|
+
const target = join18(folder, path);
|
|
75983
|
+
await mkdir4(dirname13(target), { recursive: true });
|
|
75984
|
+
await writeFile2(target, text3);
|
|
75878
75985
|
}
|
|
75879
75986
|
return folder;
|
|
75880
75987
|
}
|
|
@@ -75903,7 +76010,7 @@ async function registerWithClaude({ context, folder }) {
|
|
|
75903
76010
|
return claudeScript({ context, script });
|
|
75904
76011
|
}
|
|
75905
76012
|
function claudeDirOf({ context }) {
|
|
75906
|
-
return context.environment.inherited.CLAUDE_CONFIG_DIR ||
|
|
76013
|
+
return context.environment.inherited.CLAUDE_CONFIG_DIR || join18(homeOf2({ context }), ".claude");
|
|
75907
76014
|
}
|
|
75908
76015
|
function unregisterAs({ context, name: name3 }) {
|
|
75909
76016
|
const script = [
|
|
@@ -75914,8 +76021,8 @@ function unregisterAs({ context, name: name3 }) {
|
|
|
75914
76021
|
}
|
|
75915
76022
|
async function dropOwnLeftover({ context, folder }) {
|
|
75916
76023
|
if (pluginNameHere({ context }) === LAZE_PLUGIN) return;
|
|
75917
|
-
const known = await
|
|
75918
|
-
|
|
76024
|
+
const known = await readFile9(
|
|
76025
|
+
join18(claudeDirOf({ context }), "plugins", "known_marketplaces.json"),
|
|
75919
76026
|
"utf8"
|
|
75920
76027
|
).then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
75921
76028
|
if (known?.[LAZE_PLUGIN]?.source?.path !== folder) return;
|
|
@@ -75923,20 +76030,17 @@ async function dropOwnLeftover({ context, folder }) {
|
|
|
75923
76030
|
}
|
|
75924
76031
|
var RUN_FILES = ["hooks/hooks.json", "monitors/monitors.json"];
|
|
75925
76032
|
async function cachedPluginOf({ context }) {
|
|
75926
|
-
const path =
|
|
75927
|
-
const listed = await
|
|
75928
|
-
(text3) => JSON.parse(text3),
|
|
75929
|
-
() => void 0
|
|
75930
|
-
);
|
|
76033
|
+
const path = join18(claudeDirOf({ context }), "plugins", "installed_plugins.json");
|
|
76034
|
+
const listed = await readFile9(path, "utf8").then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
75931
76035
|
return listed?.plugins?.[installedNameOf({ context })]?.[0]?.installPath;
|
|
75932
76036
|
}
|
|
75933
76037
|
async function refreshStaleCache({ context, folder }) {
|
|
75934
76038
|
const cached2 = await cachedPluginOf({ context });
|
|
75935
76039
|
if (!cached2) return true;
|
|
75936
|
-
const read4 = (path) =>
|
|
76040
|
+
const read4 = (path) => readFile9(path, "utf8").catch(() => "");
|
|
75937
76041
|
for (const file4 of RUN_FILES) {
|
|
75938
|
-
const ours = await read4(
|
|
75939
|
-
if (ours === await read4(
|
|
76042
|
+
const ours = await read4(join18(folder, LAZE_PLUGIN, file4));
|
|
76043
|
+
if (ours === await read4(join18(cached2, file4))) continue;
|
|
75940
76044
|
const plugin2 = installedNameOf({ context });
|
|
75941
76045
|
const script = [
|
|
75942
76046
|
`claude plugin uninstall ${plugin2} --scope user ${QUIET}`,
|
|
@@ -75947,10 +76051,10 @@ async function refreshStaleCache({ context, folder }) {
|
|
|
75947
76051
|
return true;
|
|
75948
76052
|
}
|
|
75949
76053
|
function registeredMarkOf({ context }) {
|
|
75950
|
-
return
|
|
76054
|
+
return join18(pluginFolderOf({ context }), "registered");
|
|
75951
76055
|
}
|
|
75952
76056
|
async function pluginRegistered({ context }) {
|
|
75953
|
-
return
|
|
76057
|
+
return readFile9(registeredMarkOf({ context }), "utf8").then(
|
|
75954
76058
|
() => true,
|
|
75955
76059
|
() => false
|
|
75956
76060
|
);
|
|
@@ -75959,20 +76063,20 @@ async function installLazePlugin({ context }) {
|
|
|
75959
76063
|
const folder = await writeLazePlugin({ context });
|
|
75960
76064
|
await dropOwnLeftover({ context, folder });
|
|
75961
76065
|
const registered = await registerWithClaude({ context, folder }) && await refreshStaleCache({ context, folder });
|
|
75962
|
-
if (registered) await
|
|
76066
|
+
if (registered) await writeFile2(registeredMarkOf({ context }), cliVersionOf());
|
|
75963
76067
|
return { folder, registered };
|
|
75964
76068
|
}
|
|
75965
76069
|
async function plugin({ context, args }) {
|
|
75966
76070
|
const action = args.words[1] ?? "install";
|
|
75967
76071
|
if (action === "path") {
|
|
75968
|
-
context.out(`${
|
|
76072
|
+
context.out(`${join18(pluginFolderOf({ context }), LAZE_PLUGIN)}
|
|
75969
76073
|
`);
|
|
75970
76074
|
return 0;
|
|
75971
76075
|
}
|
|
75972
76076
|
if (action === "uninstall") {
|
|
75973
76077
|
const name3 = pluginNameHere({ context });
|
|
75974
76078
|
const removed = await unregisterAs({ context, name: name3 });
|
|
75975
|
-
await
|
|
76079
|
+
await rm8(registeredMarkOf({ context }), { force: true });
|
|
75976
76080
|
context.out(
|
|
75977
76081
|
removed ? `Removed the Laze plugin ${name3}@${name3} from Claude Code.
|
|
75978
76082
|
` : `Claude Code did not remove it; run: claude plugin uninstall ${name3}@${name3} && claude plugin marketplace remove ${name3}
|
|
@@ -75994,8 +76098,7 @@ async function plugin({ context, args }) {
|
|
|
75994
76098
|
}
|
|
75995
76099
|
|
|
75996
76100
|
// src/services/mcp-channel.service.ts
|
|
75997
|
-
import {
|
|
75998
|
-
import { dirname as dirname16 } from "node:path";
|
|
76101
|
+
import { rm as rm9 } from "node:fs/promises";
|
|
75999
76102
|
var LAZE_MCP_SERVER = "laze";
|
|
76000
76103
|
var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
|
|
76001
76104
|
var ROUND_SECONDS3 = 50;
|
|
@@ -76085,8 +76188,7 @@ async function pushInbox({
|
|
|
76085
76188
|
signal
|
|
76086
76189
|
}) {
|
|
76087
76190
|
const marker = statePathOf({ context, kind: "channels", profile });
|
|
76088
|
-
await
|
|
76089
|
-
await writeFile14(marker, JSON.stringify({ pid: context.processes.pid }));
|
|
76191
|
+
await writeStateJson({ path: marker, value: { pid: context.processes.pid } });
|
|
76090
76192
|
try {
|
|
76091
76193
|
while (!signal.aborted) {
|
|
76092
76194
|
const messages = await client.post("/api/agents/me/inbox", { waitSeconds: ROUND_SECONDS3 }, { signal }).catch(async (error63) => {
|
|
@@ -76115,13 +76217,12 @@ async function pushInbox({
|
|
|
76115
76217
|
`);
|
|
76116
76218
|
}
|
|
76117
76219
|
} finally {
|
|
76118
|
-
await
|
|
76220
|
+
await rm9(marker, { force: true });
|
|
76119
76221
|
}
|
|
76120
76222
|
}
|
|
76121
76223
|
|
|
76122
76224
|
// src/services/plugin-tip.service.ts
|
|
76123
|
-
import {
|
|
76124
|
-
import { dirname as dirname17 } from "node:path";
|
|
76225
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
76125
76226
|
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.";
|
|
76126
76227
|
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.";
|
|
76127
76228
|
function monitorsRunHere({ context }) {
|
|
@@ -76155,8 +76256,7 @@ async function markReloadTipTold({
|
|
|
76155
76256
|
}) {
|
|
76156
76257
|
if (!session) return;
|
|
76157
76258
|
const path = toldPathOf({ context, session });
|
|
76158
|
-
await
|
|
76159
|
-
await writeFile15(path, String(context.nowMs()), { mode: 384 });
|
|
76259
|
+
await writeStateText({ path, text: String(context.nowMs()) });
|
|
76160
76260
|
}
|
|
76161
76261
|
async function reloadTipOnce({
|
|
76162
76262
|
context,
|
|
@@ -76164,7 +76264,7 @@ async function reloadTipOnce({
|
|
|
76164
76264
|
}) {
|
|
76165
76265
|
if (!session || !monitorsRunHere({ context })) return void 0;
|
|
76166
76266
|
if (!await pluginRegistered({ context })) return void 0;
|
|
76167
|
-
const told = await
|
|
76267
|
+
const told = await readFile10(toldPathOf({ context, session }), "utf8").then(
|
|
76168
76268
|
() => true,
|
|
76169
76269
|
() => false
|
|
76170
76270
|
);
|
|
@@ -76225,17 +76325,22 @@ async function harnessOf2({ context, args }) {
|
|
|
76225
76325
|
function slugOf(name3) {
|
|
76226
76326
|
return name3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "agent";
|
|
76227
76327
|
}
|
|
76328
|
+
function settingsOf({ path, text: text3 }) {
|
|
76329
|
+
try {
|
|
76330
|
+
return JSON.parse(text3);
|
|
76331
|
+
} catch {
|
|
76332
|
+
throw new CliUsageError(`${path} is not valid JSON; fix it, then link again.`);
|
|
76333
|
+
}
|
|
76334
|
+
}
|
|
76228
76335
|
async function installHooks({
|
|
76229
76336
|
context,
|
|
76230
76337
|
directory,
|
|
76231
76338
|
profile
|
|
76232
76339
|
}) {
|
|
76233
|
-
const folder =
|
|
76234
|
-
const path =
|
|
76235
|
-
const
|
|
76236
|
-
|
|
76237
|
-
() => ({})
|
|
76238
|
-
);
|
|
76340
|
+
const folder = join19(directory, ".claude");
|
|
76341
|
+
const path = join19(folder, "settings.local.json");
|
|
76342
|
+
const text3 = await readFile11(path, "utf8").catch(() => "{}");
|
|
76343
|
+
const current3 = settingsOf({ path, text: text3 });
|
|
76239
76344
|
const command = (hook) => hookCommand({ program: context.program, profile, hook });
|
|
76240
76345
|
const settings3 = withLazeHooks({
|
|
76241
76346
|
settings: current3,
|
|
@@ -76243,8 +76348,8 @@ async function installHooks({
|
|
|
76243
76348
|
waitCommand: command("wait"),
|
|
76244
76349
|
preToolCommand: command("pre-tool")
|
|
76245
76350
|
});
|
|
76246
|
-
await
|
|
76247
|
-
await
|
|
76351
|
+
await mkdir5(folder, { recursive: true });
|
|
76352
|
+
await writeFile3(path, `${JSON.stringify(settings3, null, 2)}
|
|
76248
76353
|
`);
|
|
76249
76354
|
return path;
|
|
76250
76355
|
}
|
|
@@ -76471,7 +76576,7 @@ async function reportTranscript({
|
|
|
76471
76576
|
input: input2
|
|
76472
76577
|
}) {
|
|
76473
76578
|
if (!input2.transcript_path || !input2.session_id) return;
|
|
76474
|
-
const lines2 = (await
|
|
76579
|
+
const lines2 = (await readFile11(input2.transcript_path, "utf8")).split("\n");
|
|
76475
76580
|
const context = readTranscript({ lines: lines2 });
|
|
76476
76581
|
await client.post("/api/agents/me/activity", {
|
|
76477
76582
|
sessionId: input2.session_id,
|
|
@@ -76510,7 +76615,7 @@ async function handOver({ context, args }) {
|
|
|
76510
76615
|
const kept = await dueFromSpool({
|
|
76511
76616
|
context,
|
|
76512
76617
|
profile: agent3,
|
|
76513
|
-
seen: () => input2.transcript_path ?
|
|
76618
|
+
seen: () => input2.transcript_path ? readFile11(input2.transcript_path, "utf8") : Promise.resolve(""),
|
|
76514
76619
|
pushedToo: false,
|
|
76515
76620
|
settledOnly: true
|
|
76516
76621
|
});
|
|
@@ -76551,17 +76656,14 @@ async function addSessionStartWaiter({ context, args }) {
|
|
|
76551
76656
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
|
|
76552
76657
|
const profile = flagText({ args, name: "profile" });
|
|
76553
76658
|
if (!directory || !profile) return;
|
|
76554
|
-
const path =
|
|
76555
|
-
const settings3 = await
|
|
76556
|
-
(text3) => JSON.parse(text3),
|
|
76557
|
-
() => void 0
|
|
76558
|
-
);
|
|
76659
|
+
const path = join19(directory, ".claude", "settings.local.json");
|
|
76660
|
+
const settings3 = await readFile11(path, "utf8").then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
76559
76661
|
if (!settings3 || !lacksSessionStartWaiter({ settings: settings3 })) return;
|
|
76560
76662
|
await installHooks({ context, directory, profile });
|
|
76561
76663
|
}
|
|
76562
76664
|
async function refreshPlugin({ context }) {
|
|
76563
76665
|
if (await pluginIsCurrent({ context })) return;
|
|
76564
|
-
const logPath =
|
|
76666
|
+
const logPath = join19(pluginFolderOf({ context }), "install.log");
|
|
76565
76667
|
context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
|
|
76566
76668
|
}
|
|
76567
76669
|
async function stopHook({ context, args }) {
|
|
@@ -76582,7 +76684,7 @@ async function stopHook({ context, args }) {
|
|
|
76582
76684
|
}
|
|
76583
76685
|
|
|
76584
76686
|
// src/services/agent-manage-commands.service.ts
|
|
76585
|
-
import { readFile as
|
|
76687
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
76586
76688
|
import { extname, resolve as resolve6 } from "node:path";
|
|
76587
76689
|
|
|
76588
76690
|
// src/rules/login-format.rules.ts
|
|
@@ -76590,31 +76692,31 @@ var HARNESS_NAMES2 = {
|
|
|
76590
76692
|
"claude-code": "Claude",
|
|
76591
76693
|
codex: "Codex"
|
|
76592
76694
|
};
|
|
76593
|
-
function ahead({ iso: iso3, nowMs }) {
|
|
76594
|
-
return iso3 !== null && Temporal3.Instant.from(iso3).epochMilliseconds >
|
|
76695
|
+
function ahead({ iso: iso3, nowMs: nowMs2 }) {
|
|
76696
|
+
return iso3 !== null && Temporal3.Instant.from(iso3).epochMilliseconds > nowMs2 ? iso3 : null;
|
|
76595
76697
|
}
|
|
76596
76698
|
function usageOf2({
|
|
76597
76699
|
usedPercent,
|
|
76598
76700
|
resetsAt,
|
|
76599
76701
|
limitedUntil,
|
|
76600
|
-
nowMs
|
|
76702
|
+
nowMs: nowMs2
|
|
76601
76703
|
}) {
|
|
76602
|
-
const limited2 = ahead({ iso: limitedUntil, nowMs });
|
|
76704
|
+
const limited2 = ahead({ iso: limitedUntil, nowMs: nowMs2 });
|
|
76603
76705
|
if (limited2) return `out of usage until ${utcTimeOf(limited2)}`;
|
|
76604
76706
|
if (usedPercent === null) return "no usage reading yet";
|
|
76605
|
-
const resets = ahead({ iso: resetsAt, nowMs });
|
|
76707
|
+
const resets = ahead({ iso: resetsAt, nowMs: nowMs2 });
|
|
76606
76708
|
const used = `${Math.round(usedPercent)}% used`;
|
|
76607
76709
|
return resets ? `${used}, resets ${utcTimeOf(resets)}` : used;
|
|
76608
76710
|
}
|
|
76609
76711
|
var INVALID2 = "signed out: its provider refused this token, sign in again with a new one";
|
|
76610
76712
|
var EXPIRES_SOON = " expires within hours: run claude setup-token for a token that lasts a year";
|
|
76611
|
-
function formatLogins({ list: list12, nowMs }) {
|
|
76713
|
+
function formatLogins({ list: list12, nowMs: nowMs2 }) {
|
|
76612
76714
|
if (list12.logins.length === 0) {
|
|
76613
76715
|
return "No logins yet. Add one with: laze agent logins add --harness claude-code --name <name> < token-file\n";
|
|
76614
76716
|
}
|
|
76615
76717
|
const lines2 = list12.logins.map((login2) => {
|
|
76616
76718
|
const state = login2.agentsOnIt > 0 ? `in use by ${login2.agentsOnIt} ${login2.agentsOnIt === 1 ? "agent" : "agents"}` : "ready";
|
|
76617
|
-
const usage = usageOf2({ ...login2, nowMs });
|
|
76719
|
+
const usage = usageOf2({ ...login2, nowMs: nowMs2 });
|
|
76618
76720
|
let shown2 = usage.startsWith("out of usage") ? usage : `${state}, ${usage}`;
|
|
76619
76721
|
if (login2.state === "invalid") shown2 = INVALID2;
|
|
76620
76722
|
const line = `${HARNESS_NAMES2[login2.harness]} ${login2.name} (${shown2}) ${login2.id}`;
|
|
@@ -76624,13 +76726,13 @@ ${EXPIRES_SOON}` : line;
|
|
|
76624
76726
|
return `${lines2.join("\n")}
|
|
76625
76727
|
`;
|
|
76626
76728
|
}
|
|
76627
|
-
function formatPool({ pool, nowMs }) {
|
|
76729
|
+
function formatPool({ pool, nowMs: nowMs2 }) {
|
|
76628
76730
|
const role2 = pool.myRole ?? "admin view";
|
|
76629
76731
|
const lines2 = [`${pool.name} (you: ${role2}) ${pool.id}`];
|
|
76630
76732
|
lines2.push(
|
|
76631
76733
|
pool.logins.length === 0 ? " Logins: none yet" : " Logins:",
|
|
76632
76734
|
...pool.logins.map((login2) => {
|
|
76633
|
-
const usage = login2.invalid ? INVALID2 : usageOf2({ ...login2, nowMs });
|
|
76735
|
+
const usage = login2.invalid ? INVALID2 : usageOf2({ ...login2, nowMs: nowMs2 });
|
|
76634
76736
|
const use = login2.inUse && !login2.invalid ? "in use, " : "";
|
|
76635
76737
|
const line = ` ${HARNESS_NAMES2[login2.harness]} ${login2.name} added by ${login2.contributedByName} (${use}${usage})`;
|
|
76636
76738
|
return login2.expiresSoon ? `${line}
|
|
@@ -76646,8 +76748,8 @@ function formatPool({ pool, nowMs }) {
|
|
|
76646
76748
|
}
|
|
76647
76749
|
return lines2.join("\n");
|
|
76648
76750
|
}
|
|
76649
|
-
function formatOnePool({ pool, nowMs }) {
|
|
76650
|
-
return `${formatPool({ pool, nowMs })}
|
|
76751
|
+
function formatOnePool({ pool, nowMs: nowMs2 }) {
|
|
76752
|
+
return `${formatPool({ pool, nowMs: nowMs2 })}
|
|
76651
76753
|
`;
|
|
76652
76754
|
}
|
|
76653
76755
|
function formatUsageCheck({ check: check3 }) {
|
|
@@ -76658,11 +76760,11 @@ function formatUsageCheck({ check: check3 }) {
|
|
|
76658
76760
|
return `${checked}, ${check3.skipped} skipped (checked in the last ${minutes} minutes).
|
|
76659
76761
|
`;
|
|
76660
76762
|
}
|
|
76661
|
-
function formatPools({ pools, nowMs }) {
|
|
76763
|
+
function formatPools({ pools, nowMs: nowMs2 }) {
|
|
76662
76764
|
if (pools.pools.length === 0) {
|
|
76663
76765
|
return 'You are in no login pool. Create one with: laze agent pools create "<name>"\n';
|
|
76664
76766
|
}
|
|
76665
|
-
return `${pools.pools.map((pool) => formatPool({ pool, nowMs })).join("\n\n")}
|
|
76767
|
+
return `${pools.pools.map((pool) => formatPool({ pool, nowMs: nowMs2 })).join("\n\n")}
|
|
76666
76768
|
`;
|
|
76667
76769
|
}
|
|
76668
76770
|
function refusalLine({ code, message: message2 }) {
|
|
@@ -76720,7 +76822,7 @@ async function avatarOf({
|
|
|
76720
76822
|
return emoji4;
|
|
76721
76823
|
}
|
|
76722
76824
|
if (!path) return void 0;
|
|
76723
|
-
const bytes = await
|
|
76825
|
+
const bytes = await readFile12(resolve6(context.cwd, path)).catch(() => {
|
|
76724
76826
|
throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
|
|
76725
76827
|
});
|
|
76726
76828
|
const uploaded = await client.post("/api/agents/avatars", {
|
|
@@ -77136,7 +77238,7 @@ var LOGIN_ACTIONS = {
|
|
|
77136
77238
|
PATHS.checkLogins,
|
|
77137
77239
|
wanted ? { poolId: wanted } : {}
|
|
77138
77240
|
);
|
|
77139
|
-
const
|
|
77241
|
+
const nowMs2 = step.context.nowMs();
|
|
77140
77242
|
if (wanted) {
|
|
77141
77243
|
const pools = await step.client.get(PATHS.pools);
|
|
77142
77244
|
const pool = poolNamed({ pools: pools.pools, wanted });
|
|
@@ -77144,14 +77246,14 @@ var LOGIN_ACTIONS = {
|
|
|
77144
77246
|
return step.context.out(`${JSON.stringify({ ...check3, pool }, null, 2)}
|
|
77145
77247
|
`);
|
|
77146
77248
|
}
|
|
77147
|
-
return step.context.out(`${formatUsageCheck({ check: check3 })}${formatOnePool({ pool, nowMs })}`);
|
|
77249
|
+
return step.context.out(`${formatUsageCheck({ check: check3 })}${formatOnePool({ pool, nowMs: nowMs2 })}`);
|
|
77148
77250
|
}
|
|
77149
77251
|
const list12 = await step.client.get(PATHS.logins);
|
|
77150
77252
|
if (step.args.flags.json) {
|
|
77151
77253
|
return step.context.out(`${JSON.stringify({ ...check3, ...list12 }, null, 2)}
|
|
77152
77254
|
`);
|
|
77153
77255
|
}
|
|
77154
|
-
step.context.out(`${formatUsageCheck({ check: check3 })}${formatLogins({ list: list12, nowMs })}`);
|
|
77256
|
+
step.context.out(`${formatUsageCheck({ check: check3 })}${formatLogins({ list: list12, nowMs: nowMs2 })}`);
|
|
77155
77257
|
}
|
|
77156
77258
|
},
|
|
77157
77259
|
history: {
|
|
@@ -77436,8 +77538,8 @@ async function setAgentRunsOn({
|
|
|
77436
77538
|
}
|
|
77437
77539
|
|
|
77438
77540
|
// src/services/agent-migrate-commands.service.ts
|
|
77439
|
-
import { readFile as
|
|
77440
|
-
import { basename as
|
|
77541
|
+
import { readFile as readFile13, stat as stat8 } from "node:fs/promises";
|
|
77542
|
+
import { basename as basename6, join as join20, resolve as resolve7 } from "node:path";
|
|
77441
77543
|
|
|
77442
77544
|
// src/rules/migration-upload.rules.ts
|
|
77443
77545
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -77648,13 +77750,13 @@ async function chosenTranscriptOf({
|
|
|
77648
77750
|
file: file4
|
|
77649
77751
|
}) {
|
|
77650
77752
|
const path = resolve7(context.cwd, file4);
|
|
77651
|
-
const sessionId =
|
|
77753
|
+
const sessionId = basename6(path).replace(/\.jsonl$/, "");
|
|
77652
77754
|
if (ticket.source !== "claude-code" || !SESSION_ID.test(sessionId)) {
|
|
77653
77755
|
throw new CliUsageError(
|
|
77654
77756
|
"--transcript takes a Claude Code transcript named <session id>.jsonl. Nothing was uploaded."
|
|
77655
77757
|
);
|
|
77656
77758
|
}
|
|
77657
|
-
const found = await
|
|
77759
|
+
const found = await stat8(path).then(
|
|
77658
77760
|
(info) => info.isFile(),
|
|
77659
77761
|
() => false
|
|
77660
77762
|
);
|
|
@@ -77674,7 +77776,7 @@ async function transcriptOf({ context, args, ticket }) {
|
|
|
77674
77776
|
if (ticket.source === "codex") {
|
|
77675
77777
|
const codexHome = context.environment.codexHome;
|
|
77676
77778
|
const path2 = await codexRolloutPathOf({ codexHome, threadId: sessionId });
|
|
77677
|
-
return { sessionId, path: path2, where:
|
|
77779
|
+
return { sessionId, path: path2, where: join20(codexHome, "sessions") };
|
|
77678
77780
|
}
|
|
77679
77781
|
const { root, path } = await claudeTranscriptOf({ context, sessionId });
|
|
77680
77782
|
return { sessionId, path, where: root };
|
|
@@ -77726,7 +77828,7 @@ async function uploadTranscript({ context, args, client }) {
|
|
|
77726
77828
|
`The transcript of session ${found.sessionId} was not found under ${found.where}; nothing was uploaded.`
|
|
77727
77829
|
);
|
|
77728
77830
|
}
|
|
77729
|
-
const raw = await
|
|
77831
|
+
const raw = await readFile13(found.path, "utf8");
|
|
77730
77832
|
if (!raw.trim()) throw new CliUsageError(`${found.path} is empty; nothing was uploaded.`);
|
|
77731
77833
|
const redacted = await redactTranscript({ text: raw });
|
|
77732
77834
|
const { parts, truncated } = transcriptPartsOf({
|
|
@@ -77736,7 +77838,7 @@ async function uploadTranscript({ context, args, client }) {
|
|
|
77736
77838
|
});
|
|
77737
77839
|
const upload = { parts, truncated, redactions: redacted.redactions };
|
|
77738
77840
|
await uploadParts({ client, migrationId: id4, upload });
|
|
77739
|
-
const fileName =
|
|
77841
|
+
const fileName = basename6(found.path);
|
|
77740
77842
|
const completed = await client.post(
|
|
77741
77843
|
`/api/agents/me/migrations/${id4}/complete`,
|
|
77742
77844
|
{
|
|
@@ -77980,8 +78082,8 @@ async function requestAgent({ context, args }) {
|
|
|
77980
78082
|
}
|
|
77981
78083
|
|
|
77982
78084
|
// src/services/app-commands.service.ts
|
|
77983
|
-
import { mkdir as
|
|
77984
|
-
import { dirname as
|
|
78085
|
+
import { mkdir as mkdir6, readdir as readdir6, readFile as readFile15, writeFile as writeFile5 } from "node:fs/promises";
|
|
78086
|
+
import { dirname as dirname14, join as join23, relative as relative3, resolve as resolve8, sep as sep3 } from "node:path";
|
|
77985
78087
|
|
|
77986
78088
|
// ../../modules/app/contract/src/app.connections.ts
|
|
77987
78089
|
var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
@@ -80120,16 +80222,16 @@ function print({
|
|
|
80120
80222
|
async function appConnections({
|
|
80121
80223
|
context,
|
|
80122
80224
|
args,
|
|
80123
|
-
open:
|
|
80225
|
+
open: open6
|
|
80124
80226
|
}) {
|
|
80125
|
-
const { client, appId, name: name3 } = await
|
|
80227
|
+
const { client, appId, name: name3 } = await open6();
|
|
80126
80228
|
const listed = await client.post("/api/apps/connections", { appId });
|
|
80127
80229
|
print({ context, args, value: listed, text: connectionsText({ name: name3, listed }) });
|
|
80128
80230
|
}
|
|
80129
80231
|
async function appConnection({
|
|
80130
80232
|
context,
|
|
80131
80233
|
args,
|
|
80132
|
-
open:
|
|
80234
|
+
open: open6
|
|
80133
80235
|
}) {
|
|
80134
80236
|
const [, , verb, connection] = args.words;
|
|
80135
80237
|
if (verb !== "allow" && verb !== "revoke" || !connection) {
|
|
@@ -80138,7 +80240,7 @@ async function appConnection({
|
|
|
80138
80240
|
if (verb) throw new CliUsageError(USAGE2);
|
|
80139
80241
|
return;
|
|
80140
80242
|
}
|
|
80141
|
-
const { client, appId, name: name3 } = await
|
|
80243
|
+
const { client, appId, name: name3 } = await open6();
|
|
80142
80244
|
const listed = await client.post(`/api/apps/connections/${verb}`, { appId, connection }).catch((error63) => {
|
|
80143
80245
|
if (!(error63 instanceof LazeApiError) || error63.code !== "permission_denied") throw error63;
|
|
80144
80246
|
throw new CliUsageError(
|
|
@@ -80167,40 +80269,40 @@ function appAndWord({ args, usage }) {
|
|
|
80167
80269
|
if (!word3) throw new CliUsageError(usage);
|
|
80168
80270
|
return { app: app2, word: word3 };
|
|
80169
80271
|
}
|
|
80170
|
-
var
|
|
80272
|
+
var rename2 = async ({ context, args, open: open6 }) => {
|
|
80171
80273
|
const { app: app2, word: word3 } = appAndWord({ args, usage: "Usage: laze app rename [app] <new name>" });
|
|
80172
|
-
const { client, appId, name: name3 } = await
|
|
80274
|
+
const { client, appId, name: name3 } = await open6(app2);
|
|
80173
80275
|
const renamed = await client.post("/api/apps/rename", { appId, name: word3 });
|
|
80174
80276
|
print2({ context, args, value: renamed, text: `${name3} is now called ${renamed.name}.
|
|
80175
80277
|
` });
|
|
80176
80278
|
};
|
|
80177
|
-
var archive = async ({ context, args, open:
|
|
80178
|
-
const { client, appId } = await
|
|
80279
|
+
var archive = async ({ context, args, open: open6 }) => {
|
|
80280
|
+
const { client, appId } = await open6(args.words[2]);
|
|
80179
80281
|
const archived = await client.post("/api/apps/archive", { appId });
|
|
80180
80282
|
const text3 = `Archived ${archived.name}: it serves nothing and keeps its versions and data. laze app unarchive brings it back.
|
|
80181
80283
|
`;
|
|
80182
80284
|
print2({ context, args, value: archived, text: text3 });
|
|
80183
80285
|
};
|
|
80184
|
-
var unarchive = async ({ context, args, open:
|
|
80185
|
-
const { client, appId } = await
|
|
80286
|
+
var unarchive = async ({ context, args, open: open6 }) => {
|
|
80287
|
+
const { client, appId } = await open6(args.words[2]);
|
|
80186
80288
|
const back = await client.post("/api/apps/unarchive", { appId });
|
|
80187
80289
|
const text3 = `${back.name} is back at the same addresses.
|
|
80188
80290
|
`;
|
|
80189
80291
|
print2({ context, args, value: back, text: text3 });
|
|
80190
80292
|
};
|
|
80191
|
-
var remove = async ({ context, args, open:
|
|
80293
|
+
var remove = async ({ context, args, open: open6 }) => {
|
|
80192
80294
|
const confirmName = flagText({ args, name: "confirm" });
|
|
80193
80295
|
if (!confirmName) {
|
|
80194
80296
|
throw new CliUsageError("Usage: laze app delete [app] --confirm <the app's name>");
|
|
80195
80297
|
}
|
|
80196
|
-
const { client, appId, name: name3 } = await
|
|
80298
|
+
const { client, appId, name: name3 } = await open6(args.words[2]);
|
|
80197
80299
|
await client.post("/api/apps/delete", { appId, confirmName });
|
|
80198
80300
|
const text3 = `Deleted ${name3}: it stopped serving and is gone from the workspace.
|
|
80199
80301
|
`;
|
|
80200
80302
|
print2({ context, args, value: { deleted: appId }, text: text3 });
|
|
80201
80303
|
};
|
|
80202
|
-
var revokeLease = async ({ context, args, open:
|
|
80203
|
-
const { client, appId, name: name3 } = await
|
|
80304
|
+
var revokeLease = async ({ context, args, open: open6 }) => {
|
|
80305
|
+
const { client, appId, name: name3 } = await open6(args.words[2]);
|
|
80204
80306
|
const app2 = await client.post("/api/apps/publish/revoke-lease", { appId });
|
|
80205
80307
|
const text3 = `${name3}'s builder asks for an approval again before its next public publish.
|
|
80206
80308
|
`;
|
|
@@ -80261,18 +80363,18 @@ function backupsText({ name: name3, status: status11 }) {
|
|
|
80261
80363
|
return `${name3}: ${replicating} ${window2}
|
|
80262
80364
|
${restores.join("")}`;
|
|
80263
80365
|
}
|
|
80264
|
-
var backups = async ({ context, args, open:
|
|
80265
|
-
const { client, appId, name: name3 } = await
|
|
80366
|
+
var backups = async ({ context, args, open: open6 }) => {
|
|
80367
|
+
const { client, appId, name: name3 } = await open6(args.words[2]);
|
|
80266
80368
|
const status11 = await client.post("/api/apps/backups", { appId });
|
|
80267
80369
|
print2({ context, args, value: status11, text: backupsText({ name: name3, status: status11 }) });
|
|
80268
80370
|
};
|
|
80269
|
-
var restore = async ({ context, args, open:
|
|
80371
|
+
var restore = async ({ context, args, open: open6 }) => {
|
|
80270
80372
|
const to = flagText({ args, name: "to" });
|
|
80271
80373
|
const undo = flagText({ args, name: "undo" });
|
|
80272
80374
|
if (Boolean(to) === Boolean(undo)) {
|
|
80273
80375
|
throw new CliUsageError("Usage: laze app restore [app] --to <ISO time> | --undo <restore-id>");
|
|
80274
80376
|
}
|
|
80275
|
-
const { client, appId, name: name3 } = await
|
|
80377
|
+
const { client, appId, name: name3 } = await open6(args.words[2]);
|
|
80276
80378
|
const done = await client.post("/api/apps/backups/restore", {
|
|
80277
80379
|
appId,
|
|
80278
80380
|
...to ? { to } : { undo }
|
|
@@ -80298,16 +80400,16 @@ function usersText({ name: name3, users: users2 }) {
|
|
|
80298
80400
|
return `${name3}'s app users:
|
|
80299
80401
|
${lines2.join("")}`;
|
|
80300
80402
|
}
|
|
80301
|
-
var users = async ({ context, args, open:
|
|
80302
|
-
const { client, appId, name: name3 } = await
|
|
80403
|
+
var users = async ({ context, args, open: open6 }) => {
|
|
80404
|
+
const { client, appId, name: name3 } = await open6(args.words[2]);
|
|
80303
80405
|
const listed = await client.post("/api/apps/users", { appId });
|
|
80304
80406
|
print2({ context, args, value: listed, text: usersText({ name: name3, users: listed }) });
|
|
80305
80407
|
};
|
|
80306
80408
|
function blocking(blocked) {
|
|
80307
|
-
return async ({ context, args, open:
|
|
80409
|
+
return async ({ context, args, open: open6 }) => {
|
|
80308
80410
|
const verb = blocked ? "block-user" : "unblock-user";
|
|
80309
80411
|
const { app: app2, word: word3 } = appAndWord({ args, usage: `Usage: laze app ${verb} [app] <user-id>` });
|
|
80310
|
-
const { client, appId, name: name3 } = await
|
|
80412
|
+
const { client, appId, name: name3 } = await open6(app2);
|
|
80311
80413
|
const listed = await client.post("/api/apps/users/block", {
|
|
80312
80414
|
appId,
|
|
80313
80415
|
userId: word3,
|
|
@@ -80316,16 +80418,16 @@ function blocking(blocked) {
|
|
|
80316
80418
|
print2({ context, args, value: listed, text: usersText({ name: name3, users: listed }) });
|
|
80317
80419
|
};
|
|
80318
80420
|
}
|
|
80319
|
-
var deleteUser = async ({ context, args, open:
|
|
80421
|
+
var deleteUser = async ({ context, args, open: open6 }) => {
|
|
80320
80422
|
const { app: app2, word: word3 } = appAndWord({ args, usage: "Usage: laze app delete-user [app] <user-id>" });
|
|
80321
|
-
const { client, appId, name: name3 } = await
|
|
80423
|
+
const { client, appId, name: name3 } = await open6(app2);
|
|
80322
80424
|
const gone = await client.post("/api/apps/users/delete", { appId, userId: word3 });
|
|
80323
80425
|
const text3 = `Deleted ${gone.userId} from ${name3} with the ${gone.removedRecords.toString()} records they owned.
|
|
80324
80426
|
`;
|
|
80325
80427
|
print2({ context, args, value: gone, text: text3 });
|
|
80326
80428
|
};
|
|
80327
80429
|
var appManageCommands = {
|
|
80328
|
-
rename:
|
|
80430
|
+
rename: rename2,
|
|
80329
80431
|
archive,
|
|
80330
80432
|
unarchive,
|
|
80331
80433
|
delete: remove,
|
|
@@ -80394,10 +80496,10 @@ async function appPinCommand({
|
|
|
80394
80496
|
context,
|
|
80395
80497
|
args,
|
|
80396
80498
|
verb,
|
|
80397
|
-
open:
|
|
80499
|
+
open: open6
|
|
80398
80500
|
}) {
|
|
80399
80501
|
const channel = flagText({ args, name: "channel" });
|
|
80400
|
-
const { client, appId, name: name3 } = await
|
|
80502
|
+
const { client, appId, name: name3 } = await open6();
|
|
80401
80503
|
const role2 = verb === "pin" ? pinRoleOf(args) : void 0;
|
|
80402
80504
|
const listed = await client.post(`/api/apps/${verb}`, {
|
|
80403
80505
|
appId,
|
|
@@ -80431,9 +80533,9 @@ async function appPinsCommand({
|
|
|
80431
80533
|
|
|
80432
80534
|
// src/services/app-script-check.service.ts
|
|
80433
80535
|
import { execFile } from "node:child_process";
|
|
80434
|
-
import { mkdtemp, rm as
|
|
80536
|
+
import { mkdtemp, rm as rm10, writeFile as writeFile4 } from "node:fs/promises";
|
|
80435
80537
|
import { tmpdir } from "node:os";
|
|
80436
|
-
import { join as
|
|
80538
|
+
import { join as join21 } from "node:path";
|
|
80437
80539
|
import { promisify } from "node:util";
|
|
80438
80540
|
var run2 = promisify(execFile);
|
|
80439
80541
|
var MODULE_SYNTAX = /^\s*(import|export)\s/m;
|
|
@@ -80462,12 +80564,12 @@ async function scriptErrorsOf({
|
|
|
80462
80564
|
const unknown2 = unknownCollectionsOf({ files: files2, collections });
|
|
80463
80565
|
const scripts = files2.flatMap(scriptsOf);
|
|
80464
80566
|
if (scripts.length === 0) return unknown2;
|
|
80465
|
-
const dir = await mkdtemp(
|
|
80567
|
+
const dir = await mkdtemp(join21(tmpdir(), "laze-app-check-"));
|
|
80466
80568
|
try {
|
|
80467
80569
|
const errors = await Promise.all(
|
|
80468
80570
|
scripts.map(async (script, index) => {
|
|
80469
|
-
const file4 =
|
|
80470
|
-
await
|
|
80571
|
+
const file4 = join21(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
|
|
80572
|
+
await writeFile4(file4, script.code);
|
|
80471
80573
|
try {
|
|
80472
80574
|
await run2(process.execPath, ["--check", file4]);
|
|
80473
80575
|
return null;
|
|
@@ -80479,14 +80581,14 @@ async function scriptErrorsOf({
|
|
|
80479
80581
|
);
|
|
80480
80582
|
return [...errors.filter((error63) => error63 !== null), ...unknown2];
|
|
80481
80583
|
} finally {
|
|
80482
|
-
await
|
|
80584
|
+
await rm10(dir, { recursive: true, force: true });
|
|
80483
80585
|
}
|
|
80484
80586
|
}
|
|
80485
80587
|
|
|
80486
80588
|
// src/services/app-serve.service.ts
|
|
80487
|
-
import { readFile as
|
|
80589
|
+
import { readFile as readFile14, stat as stat9 } from "node:fs/promises";
|
|
80488
80590
|
import { createServer } from "node:http";
|
|
80489
|
-
import { extname as extname2, join as
|
|
80591
|
+
import { extname as extname2, join as join22, normalize, sep as sep2 } from "node:path";
|
|
80490
80592
|
var TYPES2 = {
|
|
80491
80593
|
".html": "text/html; charset=utf-8",
|
|
80492
80594
|
".js": "text/javascript; charset=utf-8",
|
|
@@ -80537,13 +80639,13 @@ async function staticFile({
|
|
|
80537
80639
|
if (clean.startsWith("..") || hidden) {
|
|
80538
80640
|
return json2({ response, status: 404, value: { code: "not_found", message: "Not found" } });
|
|
80539
80641
|
}
|
|
80540
|
-
const candidates = [
|
|
80541
|
-
if (!extname2(clean)) candidates.push(
|
|
80642
|
+
const candidates = [join22(folder, clean), join22(folder, clean, "index.html")];
|
|
80643
|
+
if (!extname2(clean)) candidates.push(join22(folder, "index.html"));
|
|
80542
80644
|
for (const target of candidates) {
|
|
80543
|
-
const info = await
|
|
80645
|
+
const info = await stat9(target).catch(() => void 0);
|
|
80544
80646
|
if (!info?.isFile()) continue;
|
|
80545
80647
|
const type = TYPES2[extname2(target).toLowerCase()] ?? "application/octet-stream";
|
|
80546
|
-
const body = await
|
|
80648
|
+
const body = await readFile14(target);
|
|
80547
80649
|
if (extname2(target) === ".html") {
|
|
80548
80650
|
return send2({ response, status: 200, type, body: withServeThemeScript(body.toString()) });
|
|
80549
80651
|
}
|
|
@@ -80629,16 +80731,16 @@ async function serveAppFolder({
|
|
|
80629
80731
|
(error63) => failed({ response, error: error63 })
|
|
80630
80732
|
);
|
|
80631
80733
|
});
|
|
80632
|
-
await new Promise((
|
|
80734
|
+
await new Promise((resolve26, reject) => {
|
|
80633
80735
|
server.once("error", reject);
|
|
80634
|
-
server.listen(port, "127.0.0.1", () =>
|
|
80736
|
+
server.listen(port, "127.0.0.1", () => resolve26());
|
|
80635
80737
|
});
|
|
80636
80738
|
const { port: bound } = server.address();
|
|
80637
80739
|
return {
|
|
80638
80740
|
url: `http://127.0.0.1:${bound}/`,
|
|
80639
|
-
close: () => new Promise((
|
|
80741
|
+
close: () => new Promise((resolve26) => {
|
|
80640
80742
|
server.closeAllConnections();
|
|
80641
|
-
server.close(() =>
|
|
80743
|
+
server.close(() => resolve26());
|
|
80642
80744
|
})
|
|
80643
80745
|
};
|
|
80644
80746
|
}
|
|
@@ -80689,26 +80791,26 @@ function print4({
|
|
|
80689
80791
|
context.out(args.flags.json ? `${JSON.stringify(value, null, 2)}
|
|
80690
80792
|
` : text3);
|
|
80691
80793
|
}
|
|
80692
|
-
async function add({ context, args, open:
|
|
80794
|
+
async function add({ context, args, open: open6, word: word3 }) {
|
|
80693
80795
|
const prompt = flagText({ args, name: "prompt" }).trim();
|
|
80694
80796
|
if (!prompt) throw new CliUsageError("--prompt says what the agent does with the records");
|
|
80695
80797
|
const body = { collection: word3, on: onOf(args), where: whereOf3(args), prompt };
|
|
80696
|
-
const { client, appId, name: name3 } = await
|
|
80798
|
+
const { client, appId, name: name3 } = await open6();
|
|
80697
80799
|
const trigger = await client.post("/api/apps/triggers/add", { appId, ...body });
|
|
80698
80800
|
const text3 = `Added a trigger on ${name3}:
|
|
80699
80801
|
${triggerLine(trigger)}Matching changes to ${word3} records wake ${trigger.agentName} in ${trigger.channelName}.
|
|
80700
80802
|
`;
|
|
80701
80803
|
print4({ context, args, value: trigger, text: text3 });
|
|
80702
80804
|
}
|
|
80703
|
-
async function list({ context, args, open:
|
|
80704
|
-
const { client, appId, name: name3 } = await
|
|
80805
|
+
async function list({ context, args, open: open6 }) {
|
|
80806
|
+
const { client, appId, name: name3 } = await open6();
|
|
80705
80807
|
const listed = await client.post("/api/apps/triggers", { appId });
|
|
80706
80808
|
const text3 = listed.triggers.length === 0 ? `${name3} has no triggers. laze app trigger add <collection> adds one.
|
|
80707
80809
|
` : listed.triggers.map(triggerLine).join("");
|
|
80708
80810
|
print4({ context, args, value: listed, text: text3 });
|
|
80709
80811
|
}
|
|
80710
|
-
async function setPaused({ context, args, open:
|
|
80711
|
-
const { client, appId } = await
|
|
80812
|
+
async function setPaused({ context, args, open: open6, word: word3, paused }) {
|
|
80813
|
+
const { client, appId } = await open6();
|
|
80712
80814
|
const trigger = await client.post("/api/apps/triggers/pause", {
|
|
80713
80815
|
appId,
|
|
80714
80816
|
triggerId: word3,
|
|
@@ -80716,8 +80818,8 @@ async function setPaused({ context, args, open: open5, word: word3, paused }) {
|
|
|
80716
80818
|
});
|
|
80717
80819
|
print4({ context, args, value: trigger, text: triggerLine(trigger) });
|
|
80718
80820
|
}
|
|
80719
|
-
async function remove2({ context, args, open:
|
|
80720
|
-
const { client, appId } = await
|
|
80821
|
+
async function remove2({ context, args, open: open6, word: word3 }) {
|
|
80822
|
+
const { client, appId } = await open6();
|
|
80721
80823
|
await client.post("/api/apps/triggers/remove", { appId, triggerId: word3 });
|
|
80722
80824
|
print4({ context, args, value: { removed: word3 }, text: `Removed trigger ${word3}.
|
|
80723
80825
|
` });
|
|
@@ -80725,14 +80827,14 @@ async function remove2({ context, args, open: open5, word: word3 }) {
|
|
|
80725
80827
|
async function appTrigger({
|
|
80726
80828
|
context,
|
|
80727
80829
|
args,
|
|
80728
|
-
open:
|
|
80830
|
+
open: open6
|
|
80729
80831
|
}) {
|
|
80730
80832
|
const [, , verb, word3] = args.words;
|
|
80731
|
-
if (verb === "list") return list({ context, args, open:
|
|
80833
|
+
if (verb === "list") return list({ context, args, open: open6 });
|
|
80732
80834
|
const known = verb === "add" || verb === "pause" || verb === "resume" || verb === "remove";
|
|
80733
80835
|
if (known && !word3) throw new CliUsageError(USAGE4);
|
|
80734
80836
|
if (known && word3) {
|
|
80735
|
-
const run4 = { context, args, open:
|
|
80837
|
+
const run4 = { context, args, open: open6, word: word3 };
|
|
80736
80838
|
if (verb === "add") return add(run4);
|
|
80737
80839
|
if (verb === "remove") return remove2(run4);
|
|
80738
80840
|
return setPaused({ ...run4, paused: verb === "pause" });
|
|
@@ -80776,7 +80878,7 @@ async function turnTokenOf2({
|
|
|
80776
80878
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
80777
80879
|
if (pinned) return pinned;
|
|
80778
80880
|
if (env.LAZE_TURN_FILE) {
|
|
80779
|
-
return
|
|
80881
|
+
return readFile15(env.LAZE_TURN_FILE, "utf8").then(
|
|
80780
80882
|
(text3) => text3.trim(),
|
|
80781
80883
|
() => ""
|
|
80782
80884
|
);
|
|
@@ -80806,7 +80908,7 @@ function folderOf({ context, word: word3 }) {
|
|
|
80806
80908
|
return resolve8(context.cwd, word3 ?? ".");
|
|
80807
80909
|
}
|
|
80808
80910
|
async function readManifest(folder) {
|
|
80809
|
-
const text3 = await
|
|
80911
|
+
const text3 = await readFile15(join23(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
80810
80912
|
if (text3 === void 0) return void 0;
|
|
80811
80913
|
const parsed = appManifestSchema.safeParse(JSON.parse(text3));
|
|
80812
80914
|
if (!parsed.success) {
|
|
@@ -80841,7 +80943,7 @@ async function jsonFlag({
|
|
|
80841
80943
|
}) {
|
|
80842
80944
|
const raw = flagText({ args, name: name3 });
|
|
80843
80945
|
if (!raw) return void 0;
|
|
80844
|
-
const text3 = raw.startsWith("@") ? await
|
|
80946
|
+
const text3 = raw.startsWith("@") ? await readFile15(resolve8(context.cwd, raw.slice(1)), "utf8") : raw;
|
|
80845
80947
|
try {
|
|
80846
80948
|
return JSON.parse(text3);
|
|
80847
80949
|
} catch {
|
|
@@ -80854,7 +80956,7 @@ async function listFiles(folder) {
|
|
|
80854
80956
|
while (pending2.length > 0 && found.length <= MAX_FILES) {
|
|
80855
80957
|
const current3 = pending2.pop() ?? folder;
|
|
80856
80958
|
for (const entry of await readdir6(current3, { withFileTypes: true })) {
|
|
80857
|
-
const path =
|
|
80959
|
+
const path = join23(current3, entry.name);
|
|
80858
80960
|
const rel = relative3(folder, path).split(sep3).join("/");
|
|
80859
80961
|
if (isSkippedPath({ path: rel })) continue;
|
|
80860
80962
|
if (entry.isDirectory()) pending2.push(path);
|
|
@@ -80890,12 +80992,12 @@ var appCreate = async ({ context, args }) => {
|
|
|
80890
80992
|
...template ? { template } : {}
|
|
80891
80993
|
});
|
|
80892
80994
|
const folder = resolve8(context.cwd, flagText({ args, name: "dir", fallback: app2.slug }));
|
|
80893
|
-
await
|
|
80995
|
+
await mkdir6(folder, { recursive: true });
|
|
80894
80996
|
const start2 = template ? await templateStart({ client, appId: app2.id, template }) : null;
|
|
80895
80997
|
for (const file4 of start2?.files ?? []) {
|
|
80896
|
-
const target =
|
|
80897
|
-
await
|
|
80898
|
-
await
|
|
80998
|
+
const target = join23(folder, ...file4.path.split("/"));
|
|
80999
|
+
await mkdir6(dirname14(target), { recursive: true });
|
|
81000
|
+
await writeFile5(
|
|
80899
81001
|
target,
|
|
80900
81002
|
file4.encoding === "base64" ? Buffer.from(file4.content, "base64") : file4.content
|
|
80901
81003
|
);
|
|
@@ -80906,7 +81008,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
80906
81008
|
views: [...start2?.template.views ?? []],
|
|
80907
81009
|
seed: { ...start2?.template.seed }
|
|
80908
81010
|
};
|
|
80909
|
-
await
|
|
81011
|
+
await writeFile5(join23(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
80910
81012
|
`);
|
|
80911
81013
|
const where = relative3(context.cwd, folder) || ".";
|
|
80912
81014
|
print5({
|
|
@@ -80978,7 +81080,7 @@ var appPush = async ({ context, args }) => {
|
|
|
80978
81080
|
paths.map(
|
|
80979
81081
|
async (path) => buildFileOf({
|
|
80980
81082
|
path: relative3(folder, path).split(sep3).join("/"),
|
|
80981
|
-
bytes: await
|
|
81083
|
+
bytes: await readFile15(path)
|
|
80982
81084
|
})
|
|
80983
81085
|
)
|
|
80984
81086
|
);
|
|
@@ -81048,7 +81150,7 @@ var appWrite = async ({ context, args }) => {
|
|
|
81048
81150
|
const path = resolve8(context.cwd, word3);
|
|
81049
81151
|
const { bytes: _bytes, ...file4 } = buildFileOf({
|
|
81050
81152
|
path: relative3(folder, path).split(sep3).join("/"),
|
|
81051
|
-
bytes: await
|
|
81153
|
+
bytes: await readFile15(path)
|
|
81052
81154
|
});
|
|
81053
81155
|
return file4;
|
|
81054
81156
|
})
|
|
@@ -81175,9 +81277,9 @@ var appPull = async ({ context, args }) => {
|
|
|
81175
81277
|
);
|
|
81176
81278
|
}
|
|
81177
81279
|
for (const file4 of pulled.files) {
|
|
81178
|
-
const target =
|
|
81179
|
-
await
|
|
81180
|
-
await
|
|
81280
|
+
const target = join23(folder, ...file4.path.split("/"));
|
|
81281
|
+
await mkdir6(dirname14(target), { recursive: true });
|
|
81282
|
+
await writeFile5(
|
|
81181
81283
|
target,
|
|
81182
81284
|
file4.encoding === "base64" ? Buffer.from(file4.content, "base64") : file4.content
|
|
81183
81285
|
);
|
|
@@ -81194,7 +81296,7 @@ var appPull = async ({ context, args }) => {
|
|
|
81194
81296
|
])
|
|
81195
81297
|
)
|
|
81196
81298
|
};
|
|
81197
|
-
await
|
|
81299
|
+
await writeFile5(join23(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
81198
81300
|
`);
|
|
81199
81301
|
const names = pulled.collections.map((collection) => collection.name);
|
|
81200
81302
|
const where = relative3(context.cwd, folder) || ".";
|
|
@@ -81501,7 +81603,7 @@ var appExport = async ({ context, args }) => {
|
|
|
81501
81603
|
const out = flagText({ args, name: "out" });
|
|
81502
81604
|
if (!out) return context.out(exported.body);
|
|
81503
81605
|
const target = resolve8(context.cwd, out);
|
|
81504
|
-
await
|
|
81606
|
+
await writeFile5(target, exported.body);
|
|
81505
81607
|
context.out(`Wrote ${exported.rows} records to ${relative3(context.cwd, target)}
|
|
81506
81608
|
`);
|
|
81507
81609
|
};
|
|
@@ -81509,7 +81611,7 @@ var appImport = async ({ context, args }) => {
|
|
|
81509
81611
|
const words = args.words.slice(2);
|
|
81510
81612
|
const [named, collection, file4] = words.length >= 3 ? words : [void 0, ...words];
|
|
81511
81613
|
if (!collection || !file4) throw new CliUsageError(USAGE5);
|
|
81512
|
-
const csv = await
|
|
81614
|
+
const csv = await readFile15(resolve8(context.cwd, file4), "utf8").catch(() => {
|
|
81513
81615
|
throw new CliUsageError(`Cannot read ${file4}`);
|
|
81514
81616
|
});
|
|
81515
81617
|
const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
|
|
@@ -81527,7 +81629,7 @@ var appImport = async ({ context, args }) => {
|
|
|
81527
81629
|
});
|
|
81528
81630
|
const refusedOut = flagText({ args, name: "refused" });
|
|
81529
81631
|
if (refusedOut && result2.refusedCsv) {
|
|
81530
|
-
await
|
|
81632
|
+
await writeFile5(resolve8(context.cwd, refusedOut), result2.refusedCsv);
|
|
81531
81633
|
}
|
|
81532
81634
|
const fitting = result2.rows - result2.refused.length;
|
|
81533
81635
|
const skipped = result2.refused.slice(0, 20).map((row) => ` line ${row.line}: ${row.reason}
|
|
@@ -81923,7 +82025,7 @@ async function app({ context, args }) {
|
|
|
81923
82025
|
import { hostname as hostname6 } from "node:os";
|
|
81924
82026
|
|
|
81925
82027
|
// src/rules/machine-proof.rules.ts
|
|
81926
|
-
import { createHash as createHash5, randomBytes } from "node:crypto";
|
|
82028
|
+
import { createHash as createHash5, randomBytes as randomBytes2 } from "node:crypto";
|
|
81927
82029
|
var b64url3 = (bytes) => Buffer.from(bytes).toString("base64url");
|
|
81928
82030
|
function thumbprintOf({ jwk }) {
|
|
81929
82031
|
const canonical = JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y });
|
|
@@ -81940,16 +82042,16 @@ function machineProofOf({
|
|
|
81940
82042
|
method,
|
|
81941
82043
|
url: url2,
|
|
81942
82044
|
credential,
|
|
81943
|
-
nowMs,
|
|
82045
|
+
nowMs: nowMs2,
|
|
81944
82046
|
tailscaleNodeId,
|
|
81945
|
-
jti = b64url3(
|
|
82047
|
+
jti = b64url3(randomBytes2(18))
|
|
81946
82048
|
}) {
|
|
81947
82049
|
const header = b64url3(JSON.stringify({ typ: "dpop+jwt", alg: "ES256", jwk }));
|
|
81948
82050
|
const payload = b64url3(
|
|
81949
82051
|
JSON.stringify({
|
|
81950
82052
|
htm: method.toUpperCase(),
|
|
81951
82053
|
htu: url2,
|
|
81952
|
-
iat: Math.floor(
|
|
82054
|
+
iat: Math.floor(nowMs2 / 1e3),
|
|
81953
82055
|
jti,
|
|
81954
82056
|
ath: b64url3(createHash5("sha256").update(credential).digest()),
|
|
81955
82057
|
lz_tier: tier,
|
|
@@ -82367,14 +82469,14 @@ async function billing({ context, args }) {
|
|
|
82367
82469
|
}
|
|
82368
82470
|
|
|
82369
82471
|
// src/services/browser-commands.service.ts
|
|
82370
|
-
import { randomBytes as
|
|
82371
|
-
import {
|
|
82372
|
-
import { dirname as
|
|
82472
|
+
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
82473
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
82474
|
+
import { dirname as dirname16, join as join26 } from "node:path";
|
|
82373
82475
|
|
|
82374
82476
|
// src/services/browser-tab-commands.service.ts
|
|
82375
|
-
import { mkdir as
|
|
82477
|
+
import { mkdir as mkdir7, writeFile as writeFile6 } from "node:fs/promises";
|
|
82376
82478
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
82377
|
-
import { join as
|
|
82479
|
+
import { join as join25 } from "node:path";
|
|
82378
82480
|
|
|
82379
82481
|
// src/rules/browser-login.rules.ts
|
|
82380
82482
|
var PASSWORD_NAME = /pass|pwd/i;
|
|
@@ -82405,9 +82507,9 @@ function loginValuesOf({
|
|
|
82405
82507
|
|
|
82406
82508
|
// src/services/vault-commands.service.ts
|
|
82407
82509
|
import { createHash as createHash6 } from "node:crypto";
|
|
82408
|
-
import {
|
|
82510
|
+
import { readFile as readFile16, rm as rm11 } from "node:fs/promises";
|
|
82409
82511
|
import { hostname as hostname7, tmpdir as tmpdir2 } from "node:os";
|
|
82410
|
-
import { dirname as
|
|
82512
|
+
import { dirname as dirname15, join as join24 } from "node:path";
|
|
82411
82513
|
|
|
82412
82514
|
// src/rules/vault-session.rules.ts
|
|
82413
82515
|
function vaultSessionOf({
|
|
@@ -82472,7 +82574,7 @@ async function turnTokenOf3({
|
|
|
82472
82574
|
if (pinned) return pinned;
|
|
82473
82575
|
if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
82474
82576
|
try {
|
|
82475
|
-
return (await
|
|
82577
|
+
return (await readFile16(turnFile, "utf8")).trim();
|
|
82476
82578
|
} catch {
|
|
82477
82579
|
throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
82478
82580
|
}
|
|
@@ -82483,24 +82585,20 @@ function runKeyPathOf({
|
|
|
82483
82585
|
profile = ""
|
|
82484
82586
|
}) {
|
|
82485
82587
|
const name3 = createHash6("sha256").update(connection).digest("hex");
|
|
82486
|
-
const base = turnFile ?
|
|
82487
|
-
return
|
|
82588
|
+
const base = turnFile ? dirname15(turnFile) : join24(tmpdir2(), "laze-vault", profile);
|
|
82589
|
+
return join24(base, "vault-run-keys", `${name3}.json`);
|
|
82488
82590
|
}
|
|
82489
82591
|
async function runKeyAt({ path }) {
|
|
82490
|
-
const saved3 = await
|
|
82491
|
-
|
|
82492
|
-
|
|
82493
|
-
);
|
|
82592
|
+
const saved3 = await readStateJson({
|
|
82593
|
+
path
|
|
82594
|
+
});
|
|
82494
82595
|
if (saved3 && typeof saved3.publicKey === "string" && saved3.privateKey) {
|
|
82495
82596
|
const privateKey = await globalThis.crypto.subtle.importKey("jwk", saved3.privateKey, P2562, false, ["deriveBits"]).catch(() => void 0);
|
|
82496
82597
|
if (privateKey) return { privateKey, publicKey: saved3.publicKey };
|
|
82497
82598
|
}
|
|
82498
82599
|
const fresh = await generateEcdhKeys();
|
|
82499
82600
|
const jwk = await globalThis.crypto.subtle.exportKey("jwk", fresh.privateKey);
|
|
82500
|
-
await
|
|
82501
|
-
await writeFile19(path, JSON.stringify({ publicKey: fresh.publicKey, privateKey: jwk }), {
|
|
82502
|
-
mode: 384
|
|
82503
|
-
});
|
|
82601
|
+
await writeStateJson({ path, value: { publicKey: fresh.publicKey, privateKey: jwk } });
|
|
82504
82602
|
return fresh;
|
|
82505
82603
|
}
|
|
82506
82604
|
function connectionRefused(error63) {
|
|
@@ -82574,12 +82672,12 @@ async function envOf({
|
|
|
82574
82672
|
});
|
|
82575
82673
|
return { ...release2.env, ...sealed };
|
|
82576
82674
|
}
|
|
82577
|
-
function deadlineOf({ args, nowMs }) {
|
|
82675
|
+
function deadlineOf({ args, nowMs: nowMs2 }) {
|
|
82578
82676
|
const wait = flagText({ args, name: "wait" }) || (args.flags.wait === true ? args.words[3] : "");
|
|
82579
82677
|
if (!wait) return Infinity;
|
|
82580
82678
|
if (!(Number(wait) >= 0)) throw new CliUsageError(`--wait takes a number of seconds
|
|
82581
82679
|
${USAGE6}`);
|
|
82582
|
-
return
|
|
82680
|
+
return nowMs2 + Number(wait) * 1e3;
|
|
82583
82681
|
}
|
|
82584
82682
|
async function untilAnswered({
|
|
82585
82683
|
context,
|
|
@@ -82605,10 +82703,10 @@ async function untilAnswered({
|
|
|
82605
82703
|
}
|
|
82606
82704
|
function leaseHolds({
|
|
82607
82705
|
release: release2,
|
|
82608
|
-
nowMs
|
|
82706
|
+
nowMs: nowMs2
|
|
82609
82707
|
}) {
|
|
82610
82708
|
const ends = release2.sealed?.leaseEndsAt;
|
|
82611
|
-
return ends !== void 0 && Temporal3.Instant.from(ends).epochMilliseconds >
|
|
82709
|
+
return ends !== void 0 && Temporal3.Instant.from(ends).epochMilliseconds > nowMs2;
|
|
82612
82710
|
}
|
|
82613
82711
|
async function vaultRelease({
|
|
82614
82712
|
context,
|
|
@@ -82662,13 +82760,13 @@ async function settled({
|
|
|
82662
82760
|
}) {
|
|
82663
82761
|
if (release2 === "capped") return { exitCode: 75 };
|
|
82664
82762
|
if (release2.outcome === "deny") {
|
|
82665
|
-
await
|
|
82763
|
+
await rm11(keyPath, { force: true });
|
|
82666
82764
|
context.err(`${release2.message}
|
|
82667
82765
|
`);
|
|
82668
82766
|
return { exitCode: release2.exitCode || 1 };
|
|
82669
82767
|
}
|
|
82670
82768
|
const values = await envOf({ release: release2, run: run4 });
|
|
82671
|
-
if (!leaseHolds({ release: release2, nowMs: context.nowMs() })) await
|
|
82769
|
+
if (!leaseHolds({ release: release2, nowMs: context.nowMs() })) await rm11(keyPath, { force: true });
|
|
82672
82770
|
if (release2.message) context.err(`${release2.message}
|
|
82673
82771
|
`);
|
|
82674
82772
|
return { env: values };
|
|
@@ -83011,12 +83109,12 @@ ${page}${shot}`;
|
|
|
83011
83109
|
async function savedScreenshot({
|
|
83012
83110
|
tabId,
|
|
83013
83111
|
data,
|
|
83014
|
-
nowMs
|
|
83112
|
+
nowMs: nowMs2
|
|
83015
83113
|
}) {
|
|
83016
|
-
const folder =
|
|
83017
|
-
await
|
|
83018
|
-
const path =
|
|
83019
|
-
await
|
|
83114
|
+
const folder = join25(tmpdir3(), "laze-browser");
|
|
83115
|
+
await mkdir7(folder, { recursive: true, mode: 448 });
|
|
83116
|
+
const path = join25(folder, `${tabId.replace(/[^a-zA-Z0-9_-]/g, "_")}-login-${nowMs2}.jpg`);
|
|
83117
|
+
await writeFile6(path, Buffer.from(data, "base64"), { mode: 384 });
|
|
83020
83118
|
return path;
|
|
83021
83119
|
}
|
|
83022
83120
|
async function shareTab({ args, client, channel, print: print9 }) {
|
|
@@ -83103,7 +83201,7 @@ function tunnel({
|
|
|
83103
83201
|
host: host2,
|
|
83104
83202
|
port
|
|
83105
83203
|
}) {
|
|
83106
|
-
return new Promise((
|
|
83204
|
+
return new Promise((resolve26, reject) => {
|
|
83107
83205
|
const socket = connectTcp(proxy.port, proxy.host);
|
|
83108
83206
|
let answer6 = "";
|
|
83109
83207
|
const auth = proxy.authorization ? `Proxy-Authorization: ${proxy.authorization}\r
|
|
@@ -83120,7 +83218,7 @@ ${auth}\r
|
|
|
83120
83218
|
answer6 += chunk.toString("latin1");
|
|
83121
83219
|
if (!answer6.includes(HEADER_END)) return;
|
|
83122
83220
|
socket.off("data", onData);
|
|
83123
|
-
if (/^HTTP\/1\.[01] 200/.test(answer6)) return
|
|
83221
|
+
if (/^HTTP\/1\.[01] 200/.test(answer6)) return resolve26(socket);
|
|
83124
83222
|
socket.destroy();
|
|
83125
83223
|
reject(new Error(`proxy refused the tunnel: ${answer6.split("\r\n")[0] ?? ""}`));
|
|
83126
83224
|
};
|
|
@@ -83133,8 +83231,8 @@ async function upstreamOf({ target, proxy }) {
|
|
|
83133
83231
|
const raw = proxy ? await tunnel({ proxy, host: target.hostname, port }) : connectTcp(port, target.hostname);
|
|
83134
83232
|
if (!secure) return raw;
|
|
83135
83233
|
const tls = connectTls({ socket: raw, servername: target.hostname });
|
|
83136
|
-
await new Promise((
|
|
83137
|
-
tls.once("secureConnect", () =>
|
|
83234
|
+
await new Promise((resolve26, reject) => {
|
|
83235
|
+
tls.once("secureConnect", () => resolve26());
|
|
83138
83236
|
tls.once("error", reject);
|
|
83139
83237
|
});
|
|
83140
83238
|
return tls;
|
|
@@ -83176,8 +83274,8 @@ async function browserSocket({
|
|
|
83176
83274
|
createConnection: () => upstream,
|
|
83177
83275
|
perMessageDeflate: false
|
|
83178
83276
|
});
|
|
83179
|
-
await new Promise((
|
|
83180
|
-
socket.once("open", () =>
|
|
83277
|
+
await new Promise((resolve26, reject) => {
|
|
83278
|
+
socket.once("open", () => resolve26());
|
|
83181
83279
|
socket.once("error", reject);
|
|
83182
83280
|
});
|
|
83183
83281
|
return socket;
|
|
@@ -83190,12 +83288,12 @@ async function browserCall({
|
|
|
83190
83288
|
}) {
|
|
83191
83289
|
const socket = await browserSocket({ target, proxy });
|
|
83192
83290
|
try {
|
|
83193
|
-
return await new Promise((
|
|
83291
|
+
return await new Promise((resolve26, reject) => {
|
|
83194
83292
|
socket.on("message", (data) => {
|
|
83195
83293
|
const reply2 = JSON.parse(textOf3(data));
|
|
83196
83294
|
if (reply2.id !== 1) return;
|
|
83197
83295
|
if (reply2.error) reject(new Error(`${method}: ${JSON.stringify(reply2.error)}`));
|
|
83198
|
-
else
|
|
83296
|
+
else resolve26(reply2.result ?? {});
|
|
83199
83297
|
});
|
|
83200
83298
|
socket.once(
|
|
83201
83299
|
"close",
|
|
@@ -83359,18 +83457,18 @@ function retargetCdpBridge({
|
|
|
83359
83457
|
target,
|
|
83360
83458
|
expiresAt
|
|
83361
83459
|
}) {
|
|
83362
|
-
return new Promise((
|
|
83460
|
+
return new Promise((resolve26) => {
|
|
83363
83461
|
const call = httpRequest(
|
|
83364
83462
|
{ host: "127.0.0.1", port, path: TARGET_PATH, method: "PUT", timeout: 2e3 },
|
|
83365
83463
|
(response) => {
|
|
83366
83464
|
response.resume();
|
|
83367
|
-
|
|
83465
|
+
resolve26(response.statusCode === 204);
|
|
83368
83466
|
}
|
|
83369
83467
|
);
|
|
83370
83468
|
call.setHeader(KEY_HEADER, key);
|
|
83371
83469
|
call.setHeader("content-type", "application/json");
|
|
83372
83470
|
call.once("timeout", () => call.destroy());
|
|
83373
|
-
call.once("error", () =>
|
|
83471
|
+
call.once("error", () => resolve26(false));
|
|
83374
83472
|
call.end(JSON.stringify({ target, expiresAt }));
|
|
83375
83473
|
});
|
|
83376
83474
|
}
|
|
@@ -83419,15 +83517,15 @@ async function startCdpBridge({
|
|
|
83419
83517
|
(socket) => relayPage({ client: socket, targetId, target: url2, proxy })
|
|
83420
83518
|
);
|
|
83421
83519
|
});
|
|
83422
|
-
await new Promise((
|
|
83520
|
+
await new Promise((resolve26) => server.listen(0, "127.0.0.1", resolve26));
|
|
83423
83521
|
const port = server.address().port;
|
|
83424
83522
|
return {
|
|
83425
83523
|
port,
|
|
83426
|
-
close: () => new Promise((
|
|
83524
|
+
close: () => new Promise((resolve26) => {
|
|
83427
83525
|
for (const client of relayed) client.destroy();
|
|
83428
83526
|
pages.close();
|
|
83429
83527
|
server.closeAllConnections();
|
|
83430
|
-
server.close(() =>
|
|
83528
|
+
server.close(() => resolve26());
|
|
83431
83529
|
})
|
|
83432
83530
|
};
|
|
83433
83531
|
}
|
|
@@ -83444,7 +83542,7 @@ function launchCdpBridge({
|
|
|
83444
83542
|
stdio: ["ignore", "pipe", "ignore"],
|
|
83445
83543
|
env: { ...env, LAZE_CDP_TARGET: target, LAZE_CDP_EXPIRES_AT: expiresAt, LAZE_CDP_KEY: key }
|
|
83446
83544
|
});
|
|
83447
|
-
return new Promise((
|
|
83545
|
+
return new Promise((resolve26, reject) => {
|
|
83448
83546
|
let printed2 = "";
|
|
83449
83547
|
child.once("error", reject);
|
|
83450
83548
|
child.once("exit", (code) => reject(new Error(`the CDP bridge stopped (${code})`)));
|
|
@@ -83455,7 +83553,7 @@ function launchCdpBridge({
|
|
|
83455
83553
|
child.stdout.destroy();
|
|
83456
83554
|
child.removeAllListeners("exit");
|
|
83457
83555
|
child.unref();
|
|
83458
|
-
if (Number.isInteger(port) && port > 0)
|
|
83556
|
+
if (Number.isInteger(port) && port > 0) resolve26(port);
|
|
83459
83557
|
else reject(new Error("the CDP bridge printed no port"));
|
|
83460
83558
|
});
|
|
83461
83559
|
});
|
|
@@ -83492,7 +83590,7 @@ async function turnTokenOf4({
|
|
|
83492
83590
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
83493
83591
|
if (pinned) return pinned;
|
|
83494
83592
|
if (env.LAZE_TURN_FILE) {
|
|
83495
|
-
return
|
|
83593
|
+
return readFile17(env.LAZE_TURN_FILE, "utf8").then(
|
|
83496
83594
|
(text3) => text3.trim(),
|
|
83497
83595
|
() => ""
|
|
83498
83596
|
);
|
|
@@ -83582,7 +83680,7 @@ async function answering({
|
|
|
83582
83680
|
}
|
|
83583
83681
|
function bridgeStatePath({ context, machine: machine2 }) {
|
|
83584
83682
|
const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
83585
|
-
return
|
|
83683
|
+
return join26(dirname16(context.environment.configPath), "bridges", `${safe}.json`);
|
|
83586
83684
|
}
|
|
83587
83685
|
async function bridgePort({
|
|
83588
83686
|
context,
|
|
@@ -83590,21 +83688,17 @@ async function bridgePort({
|
|
|
83590
83688
|
access
|
|
83591
83689
|
}) {
|
|
83592
83690
|
const path = bridgeStatePath({ context, machine: machine2 });
|
|
83593
|
-
const live = await
|
|
83594
|
-
(text3) => JSON.parse(text3),
|
|
83595
|
-
() => void 0
|
|
83596
|
-
);
|
|
83691
|
+
const live = await readStateJson({ path });
|
|
83597
83692
|
const target = { target: access.url, expiresAt: access.expiresAt };
|
|
83598
83693
|
if (live && await retargetCdpBridge({ ...live, ...target })) return live.port;
|
|
83599
|
-
const key =
|
|
83694
|
+
const key = randomBytes3(24).toString("hex");
|
|
83600
83695
|
const port = await launchCdpBridge({
|
|
83601
83696
|
program: context.program,
|
|
83602
83697
|
env: context.environment.inherited,
|
|
83603
83698
|
key,
|
|
83604
83699
|
...target
|
|
83605
83700
|
});
|
|
83606
|
-
await
|
|
83607
|
-
await writeFile21(path, JSON.stringify({ port, key }), { mode: 384 });
|
|
83701
|
+
await writeStateJson({ path, value: { port, key } });
|
|
83608
83702
|
return port;
|
|
83609
83703
|
}
|
|
83610
83704
|
async function bridge({ context }) {
|
|
@@ -84300,13 +84394,13 @@ async function channelSettings({ context, args }) {
|
|
|
84300
84394
|
}
|
|
84301
84395
|
|
|
84302
84396
|
// src/services/chat-actions-commands.service.ts
|
|
84303
|
-
import { readFile as
|
|
84304
|
-
import { basename as
|
|
84397
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
84398
|
+
import { basename as basename8, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve10 } from "node:path";
|
|
84305
84399
|
|
|
84306
84400
|
// src/services/file-download.service.ts
|
|
84307
84401
|
import { createWriteStream } from "node:fs";
|
|
84308
|
-
import { mkdir as
|
|
84309
|
-
import { basename as
|
|
84402
|
+
import { mkdir as mkdir8, rename as rename3, rm as rm12, stat as stat10, truncate } from "node:fs/promises";
|
|
84403
|
+
import { basename as basename7, dirname as dirname17, resolve as resolve9 } from "node:path";
|
|
84310
84404
|
import { Readable, Transform } from "node:stream";
|
|
84311
84405
|
import { pipeline } from "node:stream/promises";
|
|
84312
84406
|
var NOT_READY_WAIT_MS = 5e3;
|
|
@@ -84334,7 +84428,7 @@ function nameFrom({ response, attachmentId }) {
|
|
|
84334
84428
|
const encoded = /filename\*=UTF-8''([^;]+)/i.exec(header)?.[1];
|
|
84335
84429
|
const plain3 = /filename="?([^";]+)"?/i.exec(header)?.[1];
|
|
84336
84430
|
const name3 = encoded ? decodeURIComponent(encoded) : plain3;
|
|
84337
|
-
const safe = name3 ?
|
|
84431
|
+
const safe = name3 ? basename7(name3.replaceAll("\\", "/")) : "";
|
|
84338
84432
|
return safe && safe !== "." && safe !== ".." ? safe : attachmentId;
|
|
84339
84433
|
}
|
|
84340
84434
|
function limited({ start: start2 }) {
|
|
@@ -84354,7 +84448,7 @@ function totalOf({ response, start: start2 }) {
|
|
|
84354
84448
|
if (length === null) return void 0;
|
|
84355
84449
|
return Number(length) + (response.status === 206 ? start2 : 0);
|
|
84356
84450
|
}
|
|
84357
|
-
var sizeOnDisk = (path) =>
|
|
84451
|
+
var sizeOnDisk = (path) => stat10(path).then(
|
|
84358
84452
|
(found) => found.size,
|
|
84359
84453
|
() => 0
|
|
84360
84454
|
);
|
|
@@ -84426,17 +84520,17 @@ async function downloadFile({
|
|
|
84426
84520
|
out
|
|
84427
84521
|
}) {
|
|
84428
84522
|
const asked = out ? resolve9(context.cwd, out) : void 0;
|
|
84429
|
-
const part = resolve9(asked ?
|
|
84430
|
-
await
|
|
84523
|
+
const part = resolve9(asked ? dirname17(asked) : context.cwd, `.${attachmentId}.part`);
|
|
84524
|
+
await mkdir8(dirname17(part), { recursive: true });
|
|
84431
84525
|
const named = await fetchWhole({ context, client, attachmentId, part, out }).catch(
|
|
84432
84526
|
async (error63) => {
|
|
84433
|
-
await
|
|
84527
|
+
await rm12(part, { force: true });
|
|
84434
84528
|
if (!isDiskError(error63)) throw error63;
|
|
84435
84529
|
throw new CliUsageError(`Could not write ${attachmentId} to disk: ${String(error63)}`);
|
|
84436
84530
|
}
|
|
84437
84531
|
);
|
|
84438
84532
|
const path = asked ?? resolve9(context.cwd, named ?? attachmentId);
|
|
84439
|
-
await
|
|
84533
|
+
await rename3(part, path);
|
|
84440
84534
|
return { path, sizeBytes: await sizeOnDisk(path) };
|
|
84441
84535
|
}
|
|
84442
84536
|
|
|
@@ -84694,11 +84788,11 @@ var files = async ({ context, args, client }) => {
|
|
|
84694
84788
|
};
|
|
84695
84789
|
function uploadNameOf({ cwd, path }) {
|
|
84696
84790
|
const inside = relative4(cwd, path);
|
|
84697
|
-
return inside && !inside.startsWith("..") && !isAbsolute2(inside) ? inside :
|
|
84791
|
+
return inside && !inside.startsWith("..") && !isAbsolute2(inside) ? inside : basename8(path);
|
|
84698
84792
|
}
|
|
84699
84793
|
var fileUpload = async ({ context, args, client }) => {
|
|
84700
84794
|
const path = resolve10(context.cwd, wordAt(args, 3));
|
|
84701
|
-
const bytes = new Uint8Array(await
|
|
84795
|
+
const bytes = new Uint8Array(await readFile18(path));
|
|
84702
84796
|
const answer6 = await uploadFile({
|
|
84703
84797
|
context,
|
|
84704
84798
|
client,
|
|
@@ -84882,7 +84976,7 @@ async function chatActions({
|
|
|
84882
84976
|
}
|
|
84883
84977
|
|
|
84884
84978
|
// src/services/claude-monitor.service.ts
|
|
84885
|
-
import {
|
|
84979
|
+
import { rm as rm13 } from "node:fs/promises";
|
|
84886
84980
|
var MONITOR_IDLE_MS = 3e4;
|
|
84887
84981
|
var MONITOR_OUTRANKED_MS = 3e3;
|
|
84888
84982
|
async function deliverOnce({
|
|
@@ -84950,7 +85044,7 @@ async function monitorRound(turn) {
|
|
|
84950
85044
|
async function release({ context, profile }) {
|
|
84951
85045
|
const lock = statePathOf({ context, kind: "waiters", profile });
|
|
84952
85046
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
84953
|
-
await
|
|
85047
|
+
await rm13(lock, { force: true });
|
|
84954
85048
|
}
|
|
84955
85049
|
async function monitorHook({ context, args }) {
|
|
84956
85050
|
const claudePid = await claudePidOf({ context });
|
|
@@ -84989,10 +85083,7 @@ async function monitorSessionOf({
|
|
|
84989
85083
|
const fromEnv = sessionOf({ context, harness: "claude-code", sessionId });
|
|
84990
85084
|
if (fromEnv || !claudePid) return fromEnv;
|
|
84991
85085
|
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
84992
|
-
return
|
|
84993
|
-
(text3) => JSON.parse(text3),
|
|
84994
|
-
() => void 0
|
|
84995
|
-
);
|
|
85086
|
+
return readStateJson({ path });
|
|
84996
85087
|
}
|
|
84997
85088
|
|
|
84998
85089
|
// ../../modules/compute/contract/src/browser-tab.ts
|
|
@@ -86479,6 +86570,7 @@ var pairingRefDefinition = external_exports.object({
|
|
|
86479
86570
|
var whatsappPairingRefSchema = pairingRefDefinition;
|
|
86480
86571
|
var restPairingRefDefinition = external_exports.object({ pairingId: external_exports.string().min(1).max(64) });
|
|
86481
86572
|
var restChatsDefinition = chatsInputDefinition.omit({ workspaceId: true });
|
|
86573
|
+
var restSyncDefinition = external_exports.object({ machine: whatsappMachineRef });
|
|
86482
86574
|
var restReadDefinition = readInputDefinition.omit({ workspaceId: true });
|
|
86483
86575
|
var restFileDefinition = fileInputDefinition.omit({ workspaceId: true });
|
|
86484
86576
|
var restSendDefinition = sendInputDefinition.omit({ workspaceId: true });
|
|
@@ -86489,7 +86581,8 @@ var COMPUTE_WHATSAPP_REST_PATHS = {
|
|
|
86489
86581
|
file: "/api/compute/whatsapp/file",
|
|
86490
86582
|
send: "/api/compute/whatsapp/send",
|
|
86491
86583
|
sendStatus: "/api/compute/whatsapp/send-status",
|
|
86492
|
-
unpair: "/api/compute/whatsapp/unpair"
|
|
86584
|
+
unpair: "/api/compute/whatsapp/unpair",
|
|
86585
|
+
sync: "/api/compute/whatsapp/sync"
|
|
86493
86586
|
};
|
|
86494
86587
|
|
|
86495
86588
|
// ../../modules/compute/contract/src/own-machine.ts
|
|
@@ -86766,7 +86859,12 @@ var openLoginTerminalDefinition = external_exports.object({
|
|
|
86766
86859
|
});
|
|
86767
86860
|
var openLoginTerminalInputSchema = openLoginTerminalDefinition;
|
|
86768
86861
|
var loginTerminalDefinition = external_exports.discriminatedUnion("status", [
|
|
86769
|
-
external_exports.object({
|
|
86862
|
+
external_exports.object({
|
|
86863
|
+
status: external_exports.literal("starting"),
|
|
86864
|
+
retryAfterSeconds: external_exports.number().int().positive(),
|
|
86865
|
+
/** The computer is awake and only its link is coming back, e.g. after a deploy. */
|
|
86866
|
+
reconnecting: external_exports.boolean().optional()
|
|
86867
|
+
}),
|
|
86770
86868
|
external_exports.object({
|
|
86771
86869
|
status: external_exports.literal("ready"),
|
|
86772
86870
|
/** The WebSocket path of the terminal, token included; add `cols` and `rows`. */
|
|
@@ -86775,6 +86873,8 @@ var loginTerminalDefinition = external_exports.discriminatedUnion("status", [
|
|
|
86775
86873
|
})
|
|
86776
86874
|
]);
|
|
86777
86875
|
var loginTerminalSchema = loginTerminalDefinition;
|
|
86876
|
+
var warmComputerDefinition = external_exports.object({ status: external_exports.enum(["starting", "ready"]) });
|
|
86877
|
+
var warmComputerSchema = warmComputerDefinition;
|
|
86778
86878
|
var screenRefDefinition = external_exports.object({ workspaceId: workspaceIdSchema22, sessionId: idSchema23 });
|
|
86779
86879
|
var screenRefSchema = screenRefDefinition;
|
|
86780
86880
|
var screenSessionDefinition = external_exports.object({
|
|
@@ -86816,7 +86916,7 @@ var ownMachineSshConnectSchema = ownMachineSshConnectDefinition;
|
|
|
86816
86916
|
var reconcileDefinition = external_exports.object({ workspaceId: workspaceIdSchema22, machineId: idSchema23 });
|
|
86817
86917
|
var ComputeApi = moduleApi()("compute");
|
|
86818
86918
|
var computeCoreTrpc = defineTrpcContract("compute").query("status").withInput(computeWorkspaceInputSchema).withOutput(computeStatusSchema).query("browserTabs").withInput(browserTabListInputSchema).withOutput(browserTabListSchema).query("browserTab").withInput(browserTabInputSchema).withOutput(browserTabSchema).mutation("openBrowserTab").withInput(openBrowserTabInputSchema).withOutput(browserTabSchema).mutation("browserTabScreen").withInput(browserTabInputSchema).withOutput(browserTabScreenSchema).mutation("sizeBrowserTabScreen").withInput(browserTabScreenSizeInputSchema).withOutput(browserTabScreenSizeSchema).mutation("gotoBrowserTab").withInput(browserTabGotoInputSchema).withOutput(browserTabPageSchema).mutation("doneOnBrowserTab").withInput(browserTabInputSchema).withOutput(browserTabSchema).mutation("shareBrowserTab").withInput(browserTabShareInputSchema).withOutput(browserTabSchema).mutation("closeBrowserTab").withInput(browserTabInputSchema).withOutput(external_exports.object({ closed: external_exports.literal(true) })).query("computer").withInput(computeWorkspaceInputSchema).withOutput(computerStatusSchema).mutation("setComputerSize").withInput(setComputerSizeInputSchema).withOutput(computerSizeAnswerSchema).mutation("requestComputerSize").withInput(setComputerSizeInputSchema).withOutput(computerRequestSchema).mutation("cancelComputerRequest").withInput(computerRequestRefSchema).withOutput(computerRequestSchema).mutation("restartComputer").withInput(restartComputerInputSchema).withOutput(computerRestartAnswerSchema).query("computers").withInput(computeWorkspaceInputSchema).withOutput(computerListSchema).query("dedicatedIp").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpStatusSchema).mutation("setDedicatedIp").withInput(setDedicatedIpInputSchema).withOutput(dedicatedIpAnswerSchema).mutation("turnOffDedicatedIp").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpAnswerSchema).mutation("setDedicatedIpDomains").withInput(setDedicatedIpDomainsInputSchema).withOutput(dedicatedIpAnswerSchema).query("dedicatedIps").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpListSchema).query("dedicatedIpCountries").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpCountriesSchema).query("dedicatedIpOffer").withInput(dedicatedIpOfferInputSchema).withOutput(dedicatedIpOfferSchema).query("list").withInput(computeWorkspaceInputSchema).withOutput(external_exports.array(machineSchema)).query("get").withInput(machineRefSchema).withOutput(machineSchema).mutation("setupBrowser").withInput(setupBrowserInputSchema).withOutput(machineSchema).mutation("sleep").withInput(machineRefSchema).withOutput(machineSchema).mutation("wake").withInput(machineRefSchema).withOutput(machineSchema).mutation("delete").withInput(machineRefSchema).withOutput(machineSchema).mutation("rename").withInput(renameMachineInputSchema).withOutput(machineSchema).mutation("grant").withInput(machineGrantInputSchema).withOutput(machineSchema).mutation("revokeGrant").withInput(machineGrantInputSchema).withOutput(machineSchema).mutation("setBudget").withInput(setMachineBudgetInputSchema).withOutput(machineSchema).mutation("openScreen").withInput(openScreenInputSchema).withOutput(screenSessionSchema).mutation("openLoginTerminal").withInput(openLoginTerminalInputSchema).withOutput(loginTerminalSchema).mutation("finishScreen").withInput(screenRefSchema).withOutput(machineSchema).mutation("connectOwn").withInput(connectOwnMachineInputSchema).withOutput(ownMachineConnectSchema).mutation("newConnectCommand").withInput(machineRefSchema).withOutput(ownMachineConnectSchema).mutation("connectSsh").withInput(connectSshMachineInputSchema).withOutput(ownMachineSshConnectSchema).mutation("trustHostKey").withInput(trustHostKeyInputSchema).withOutput(machineSchema).mutation("checkHealth").withInput(machineRefSchema).withOutput(machineSchema).mutation("hostAgent").withInput(hostAgentInputSchema).withOutput(machineSchema).mutation("unhostAgent").withInput(unhostAgentInputSchema).withOutput(external_exports.object({ agentId: external_exports.string() })).mutation("pairWhatsapp").withInput(whatsappPairInputSchema).withOutput(whatsappPairingSchema).query("whatsappMirror").withInput(machineRefSchema).withOutput(whatsappMirrorSettingsSchema).mutation("setWhatsappMirror").withInput(setWhatsappMirrorInputSchema).withOutput(whatsappMirrorSettingsSchema).query("whatsappPairing").withInput(whatsappPairingRefSchema).withOutput(whatsappPairingSchema).mutation("cancelWhatsappPairing").withInput(whatsappPairingRefSchema).withOutput(whatsappPairingSchema).mutation("unpairWhatsapp").withInput(machineRefSchema).withOutput(machineSchema).build();
|
|
86819
|
-
var computeFleetTrpc = defineTrpcContract("compute").query("whatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("prepareWhatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).query("myComputers").withInput(computeWorkspaceInputSchema).withOutput(myComputersSchema).mutation("createComputer").withInput(createComputerInputSchema).withOutput(computerStatusSchema).mutation("deleteComputer").withInput(deleteComputerInputSchema).withOutput(deleteComputerAnswerSchema).mutation("setComputerCreators").withInput(setComputerCreatorsInputSchema).withOutput(computerStatusSchema).mutation("setAgentComputer").withInput(setAgentComputerInputSchema).withOutput(agentComputerAnswerSchema).query("whatsappAgents").withInput(machineRefSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgent").withInput(setWhatsappAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentLease").withInput(setWhatsappAgentLeaseInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappEveryAgent").withInput(setWhatsappEveryAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentAccess").withInput(setWhatsappAgentAccessInputSchema).withOutput(whatsappAgentsSchema).build();
|
|
86919
|
+
var computeFleetTrpc = defineTrpcContract("compute").query("whatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("prepareWhatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("warmComputer").withInput(computeWorkspaceInputSchema).withOutput(warmComputerSchema).query("myComputers").withInput(computeWorkspaceInputSchema).withOutput(myComputersSchema).mutation("createComputer").withInput(createComputerInputSchema).withOutput(computerStatusSchema).mutation("deleteComputer").withInput(deleteComputerInputSchema).withOutput(deleteComputerAnswerSchema).mutation("setComputerCreators").withInput(setComputerCreatorsInputSchema).withOutput(computerStatusSchema).mutation("setAgentComputer").withInput(setAgentComputerInputSchema).withOutput(agentComputerAnswerSchema).query("whatsappAgents").withInput(machineRefSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgent").withInput(setWhatsappAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentLease").withInput(setWhatsappAgentLeaseInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappEveryAgent").withInput(setWhatsappEveryAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentAccess").withInput(setWhatsappAgentAccessInputSchema).withOutput(whatsappAgentsSchema).mutation("checkWhatsappNow").withInput(machineRefSchema).withOutput(whatsappMirrorSettingsSchema).build();
|
|
86820
86920
|
var computeTrpc = joinTrpcContracts("compute", computeCoreTrpc, computeFleetTrpc);
|
|
86821
86921
|
var restMachineInputDefinition = external_exports.object({ machine: external_exports.string().min(1).max(64) });
|
|
86822
86922
|
var restRenameInputDefinition = external_exports.object({
|
|
@@ -86976,9 +87076,9 @@ var restSettleComputerCopyInputDefinition = settleComputerCopyInputDefinition.om
|
|
|
86976
87076
|
});
|
|
86977
87077
|
|
|
86978
87078
|
// src/services/computer-copy-commands.service.ts
|
|
86979
|
-
import { mkdtemp as mkdtemp2, open as
|
|
87079
|
+
import { mkdtemp as mkdtemp2, open as open5, rm as rm14, stat as stat11 } from "node:fs/promises";
|
|
86980
87080
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
86981
|
-
import { basename as
|
|
87081
|
+
import { basename as basename9, dirname as dirname18, resolve as resolve11 } from "node:path";
|
|
86982
87082
|
var COMPUTER_COPY_USAGE = ` laze computer copy <path> --agent <agent> [--to <folder>] [--json]
|
|
86983
87083
|
copy a local file or folder into your hosted agent's work folder
|
|
86984
87084
|
(its owner only, up to 2 GiB packed); <folder> is relative to the
|
|
@@ -86993,8 +87093,8 @@ function stringFlag(args, name3) {
|
|
|
86993
87093
|
function packingOf({ path, isDirectory }) {
|
|
86994
87094
|
const contents = isDirectory && path.endsWith("/");
|
|
86995
87095
|
const absolute = resolve11(path);
|
|
86996
|
-
const name3 =
|
|
86997
|
-
return contents ? { name: name3, parent: absolute, entry: "." } : { name: name3, parent:
|
|
87096
|
+
const name3 = basename9(absolute);
|
|
87097
|
+
return contents ? { name: name3, parent: absolute, entry: "." } : { name: name3, parent: dirname18(absolute), entry: name3 };
|
|
86998
87098
|
}
|
|
86999
87099
|
async function sendParts2({
|
|
87000
87100
|
context,
|
|
@@ -87003,7 +87103,7 @@ async function sendParts2({
|
|
|
87003
87103
|
}) {
|
|
87004
87104
|
const { upload } = started;
|
|
87005
87105
|
const parts = [];
|
|
87006
|
-
const file4 = await
|
|
87106
|
+
const file4 = await open5(archive2, "r");
|
|
87007
87107
|
try {
|
|
87008
87108
|
for (const part of upload.parts) {
|
|
87009
87109
|
const length = part.end - part.start;
|
|
@@ -87039,7 +87139,7 @@ async function copy({ context, args }) {
|
|
|
87039
87139
|
${COMPUTER_COPY_USAGE}`);
|
|
87040
87140
|
const to = stringFlag(args, "to") ?? ".";
|
|
87041
87141
|
const full = resolve11(context.cwd, path);
|
|
87042
|
-
const found = await
|
|
87142
|
+
const found = await stat11(full).catch(() => void 0);
|
|
87043
87143
|
if (!found) throw new CliUsageError(`${path} does not exist`);
|
|
87044
87144
|
const { name: name3, parent, entry } = packingOf({
|
|
87045
87145
|
path: path.endsWith("/") ? `${full}/` : full,
|
|
@@ -87053,7 +87153,7 @@ ${COMPUTER_COPY_USAGE}`);
|
|
|
87053
87153
|
env: { COPYFILE_DISABLE: "1" }
|
|
87054
87154
|
});
|
|
87055
87155
|
if (code !== 0) throw new CliUsageError(`tar could not pack ${path} (exit ${code})`);
|
|
87056
|
-
const sizeBytes = (await
|
|
87156
|
+
const sizeBytes = (await stat11(archive2)).size;
|
|
87057
87157
|
if (sizeBytes > COMPUTER_COPY_MAX_BYTES)
|
|
87058
87158
|
throw new CliUsageError(`${path} packs to ${mb(sizeBytes)}; a copy holds at most 2 GiB`);
|
|
87059
87159
|
const client = await computeClient({ context, args });
|
|
@@ -87077,7 +87177,7 @@ It lands before ${done.agentName}'s next turn.
|
|
|
87077
87177
|
`
|
|
87078
87178
|
);
|
|
87079
87179
|
} finally {
|
|
87080
|
-
await
|
|
87180
|
+
await rm14(dir, { recursive: true, force: true });
|
|
87081
87181
|
}
|
|
87082
87182
|
}
|
|
87083
87183
|
|
|
@@ -87368,10 +87468,11 @@ async function computer({ context, args }) {
|
|
|
87368
87468
|
}
|
|
87369
87469
|
|
|
87370
87470
|
// src/services/connect-commands.service.ts
|
|
87371
|
-
import { readFile as
|
|
87471
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
87372
87472
|
|
|
87373
87473
|
// src/services/mcp-gateway.service.ts
|
|
87374
|
-
import { readFile as
|
|
87474
|
+
import { mkdir as mkdir9, readFile as readFile19, writeFile as writeFile7 } from "node:fs/promises";
|
|
87475
|
+
import { basename as basename10, join as join27, resolve as resolve12 } from "node:path";
|
|
87375
87476
|
import { createInterface as createInterface3 } from "node:readline";
|
|
87376
87477
|
var TURN_HEADER = "x-laze-turn";
|
|
87377
87478
|
function serveMcpGateway({
|
|
@@ -87414,13 +87515,14 @@ async function relayMcpLines({
|
|
|
87414
87515
|
const github3 = env.LAZE_GITHUB_CONNECTION;
|
|
87415
87516
|
const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
|
|
87416
87517
|
const turnFile = env.LAZE_TURN_FILE;
|
|
87417
|
-
const readTurn = () =>
|
|
87518
|
+
const readTurn = () => readFile19(turnFile, "utf8").then(
|
|
87418
87519
|
(text3) => text3.trim(),
|
|
87419
87520
|
() => ""
|
|
87420
87521
|
);
|
|
87421
87522
|
const relay2 = {
|
|
87422
87523
|
readTurn,
|
|
87423
87524
|
out: (text3) => context.out(text3),
|
|
87525
|
+
saveFile: (file4) => saveMailFile({ root: resolve12(context.cwd, MAIL_FILES_DIR), file: file4 }),
|
|
87424
87526
|
post: async ({ line, turn }) => {
|
|
87425
87527
|
const response = await context.fetcher(url2, {
|
|
87426
87528
|
method: "POST",
|
|
@@ -87446,13 +87548,84 @@ async function relayMcpLines({
|
|
|
87446
87548
|
clearInterval(timer);
|
|
87447
87549
|
}
|
|
87448
87550
|
}
|
|
87551
|
+
var MAIL_FILES_DIR = "mail-attachments";
|
|
87552
|
+
var SAVES_FILES_META = "laze/files";
|
|
87553
|
+
var FILE_META = "laze/file";
|
|
87554
|
+
function safeName(name3, fallback) {
|
|
87555
|
+
const printable = name3.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
87556
|
+
const last = basename10(printable.replaceAll("\\", "/"));
|
|
87557
|
+
return last && last !== "." && last !== ".." ? last : fallback;
|
|
87558
|
+
}
|
|
87559
|
+
async function saveMailFile({ root, file: file4 }) {
|
|
87560
|
+
const dir = join27(root, safeName(file4.messageId, "message"));
|
|
87561
|
+
const path = join27(dir, safeName(file4.fileName, "attachment"));
|
|
87562
|
+
await mkdir9(dir, { recursive: true });
|
|
87563
|
+
await writeFile7(path, Buffer.from(file4.base64, "base64"));
|
|
87564
|
+
return path;
|
|
87565
|
+
}
|
|
87566
|
+
function markSavesFiles(line) {
|
|
87567
|
+
try {
|
|
87568
|
+
const request2 = JSON.parse(line);
|
|
87569
|
+
if (request2.method !== "tools/call" || typeof request2.params !== "object" || !request2.params)
|
|
87570
|
+
return line;
|
|
87571
|
+
const meta3 = request2.params._meta;
|
|
87572
|
+
const own2 = typeof meta3 === "object" && meta3 !== null ? meta3 : {};
|
|
87573
|
+
request2.params._meta = { ...own2, [SAVES_FILES_META]: "save" };
|
|
87574
|
+
return JSON.stringify(request2);
|
|
87575
|
+
} catch {
|
|
87576
|
+
return line;
|
|
87577
|
+
}
|
|
87578
|
+
}
|
|
87579
|
+
function carriedFileOf(value) {
|
|
87580
|
+
if (typeof value !== "object" || value === null) return null;
|
|
87581
|
+
const file4 = value;
|
|
87582
|
+
const text3 = (key) => typeof file4[key] === "string" ? file4[key] : "";
|
|
87583
|
+
if (text3("base64") === "" && file4.sizeBytes !== 0) return null;
|
|
87584
|
+
return {
|
|
87585
|
+
messageId: text3("messageId"),
|
|
87586
|
+
fileName: text3("fileName"),
|
|
87587
|
+
contentType: text3("contentType") || "application/octet-stream",
|
|
87588
|
+
sizeBytes: typeof file4.sizeBytes === "number" ? file4.sizeBytes : 0,
|
|
87589
|
+
base64: text3("base64")
|
|
87590
|
+
};
|
|
87591
|
+
}
|
|
87592
|
+
async function withFileSaved({ relay: relay2, text: text3 }) {
|
|
87593
|
+
let answer6;
|
|
87594
|
+
try {
|
|
87595
|
+
answer6 = JSON.parse(text3);
|
|
87596
|
+
} catch {
|
|
87597
|
+
return text3;
|
|
87598
|
+
}
|
|
87599
|
+
const result2 = answer6.result;
|
|
87600
|
+
const meta3 = result2?._meta;
|
|
87601
|
+
if (!result2 || !meta3 || !(FILE_META in meta3)) return text3;
|
|
87602
|
+
const file4 = carriedFileOf(meta3[FILE_META]);
|
|
87603
|
+
const { [FILE_META]: _carried, ...rest } = meta3;
|
|
87604
|
+
const kept = Object.keys(rest).length > 0 ? { _meta: rest } : {};
|
|
87605
|
+
const { _meta: _old, ...plain3 } = result2;
|
|
87606
|
+
if (!file4) {
|
|
87607
|
+
const content = [{ type: "text", text: "The gateway sent a file this CLI could not read." }];
|
|
87608
|
+
return JSON.stringify({ ...answer6, result: { ...plain3, ...kept, content, isError: true } });
|
|
87609
|
+
}
|
|
87610
|
+
const what = `${file4.fileName} (${file4.contentType}, ${file4.sizeBytes} bytes)`;
|
|
87611
|
+
try {
|
|
87612
|
+
const path = await relay2.saveFile(file4);
|
|
87613
|
+
const content = [{ type: "text", text: `Saved ${what} to ${path}` }];
|
|
87614
|
+
return JSON.stringify({ ...answer6, result: { ...plain3, ...kept, content } });
|
|
87615
|
+
} catch (error63) {
|
|
87616
|
+
const why = error63 instanceof Error ? error63.message : "it could not be written";
|
|
87617
|
+
const content = [{ type: "text", text: `Could not save ${what}: ${why}` }];
|
|
87618
|
+
return JSON.stringify({ ...answer6, result: { ...plain3, ...kept, content, isError: true } });
|
|
87619
|
+
}
|
|
87620
|
+
}
|
|
87449
87621
|
async function relayLine({
|
|
87450
87622
|
relay: relay2,
|
|
87451
87623
|
listed,
|
|
87452
87624
|
line
|
|
87453
87625
|
}) {
|
|
87454
87626
|
const turn = await relay2.readTurn();
|
|
87455
|
-
const
|
|
87627
|
+
const posted = await relay2.post({ line: markSavesFiles(line), turn });
|
|
87628
|
+
const text3 = methodOf(line) === "tools/call" ? await withFileSaved({ relay: relay2, text: posted }) : posted;
|
|
87456
87629
|
if (methodOf(line) === "tools/list") {
|
|
87457
87630
|
const names = toolNamesOf(text3);
|
|
87458
87631
|
if (names !== null) Object.assign(listed, { names, turn });
|
|
@@ -87504,7 +87677,7 @@ async function turnOf({ context }) {
|
|
|
87504
87677
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
87505
87678
|
if (pinned) return pinned;
|
|
87506
87679
|
const file4 = env.LAZE_TURN_FILE;
|
|
87507
|
-
const turn = file4 ? await
|
|
87680
|
+
const turn = file4 ? await readFile20(file4, "utf8").then(
|
|
87508
87681
|
(text3) => text3.trim(),
|
|
87509
87682
|
() => ""
|
|
87510
87683
|
) : "";
|
|
@@ -87562,11 +87735,11 @@ async function connect({
|
|
|
87562
87735
|
}
|
|
87563
87736
|
|
|
87564
87737
|
// src/services/connector-commands.service.ts
|
|
87565
|
-
import { readFile as
|
|
87566
|
-
import { resolve as
|
|
87738
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
87739
|
+
import { resolve as resolve13 } from "node:path";
|
|
87567
87740
|
|
|
87568
87741
|
// src/services/vault-keychain-commands.service.ts
|
|
87569
|
-
import { readFile as
|
|
87742
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
87570
87743
|
|
|
87571
87744
|
// src/rules/vault-input.rules.ts
|
|
87572
87745
|
function secondsOf(text3) {
|
|
@@ -87984,7 +88157,7 @@ async function secretText({ context, args }) {
|
|
|
87984
88157
|
);
|
|
87985
88158
|
}
|
|
87986
88159
|
const file4 = flagText({ args, name: "from-file" });
|
|
87987
|
-
const text3 = file4 ? await
|
|
88160
|
+
const text3 = file4 ? await readFile21(file4, "utf8") : await context.readStdin();
|
|
87988
88161
|
const trimmed = text3.replace(/\r?\n$/, "");
|
|
87989
88162
|
if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
|
|
87990
88163
|
return trimmed;
|
|
@@ -87998,7 +88171,7 @@ async function keychainOf2({ client, args }) {
|
|
|
87998
88171
|
const me = await client.get("/api/agents/me");
|
|
87999
88172
|
return { kind: "personal", ownerUserId: me.id };
|
|
88000
88173
|
}
|
|
88001
|
-
function
|
|
88174
|
+
function settingsOf2(args) {
|
|
88002
88175
|
const lease = flagText({ args, name: "lease" }) || flagText({ args, name: "max-lease" });
|
|
88003
88176
|
const approvers = args.lists.approver;
|
|
88004
88177
|
const everyUseAsks = yesNoOf({ args, name: "every-use-asks" });
|
|
@@ -88040,7 +88213,7 @@ var add3 = async ({ context, args }) => {
|
|
|
88040
88213
|
name: name3,
|
|
88041
88214
|
keychain: await keychainOf2({ client, args }),
|
|
88042
88215
|
sensitivity: levelOf2(args) ?? "checked",
|
|
88043
|
-
...
|
|
88216
|
+
...settingsOf2(args),
|
|
88044
88217
|
secret
|
|
88045
88218
|
});
|
|
88046
88219
|
if (args.flags.json) return printJson4({ context, data: created });
|
|
@@ -88050,7 +88223,7 @@ var add3 = async ({ context, args }) => {
|
|
|
88050
88223
|
);
|
|
88051
88224
|
};
|
|
88052
88225
|
var update = async ({ context, args }) => {
|
|
88053
|
-
const settings3 = { ...
|
|
88226
|
+
const settings3 = { ...settingsOf2(args), ...deviceApprovalOf(args) };
|
|
88054
88227
|
const { client, profile } = await signedIn({ context, args });
|
|
88055
88228
|
if (Object.keys(settings3).length === 0) throw new CliUsageError(VAULT_USAGE);
|
|
88056
88229
|
const word3 = args.words[2];
|
|
@@ -88217,7 +88390,7 @@ async function keyText({ context, args }) {
|
|
|
88217
88390
|
throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
|
|
88218
88391
|
}
|
|
88219
88392
|
const file4 = flagText({ args, name: "from-file" });
|
|
88220
|
-
const text3 = file4 ? await
|
|
88393
|
+
const text3 = file4 ? await readFile22(resolve13(context.cwd, file4), "utf8") : await context.readStdin();
|
|
88221
88394
|
const trimmed = text3.trim();
|
|
88222
88395
|
if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
|
|
88223
88396
|
return trimmed;
|
|
@@ -88538,8 +88711,8 @@ async function conversationDelete({ context, args }) {
|
|
|
88538
88711
|
}
|
|
88539
88712
|
|
|
88540
88713
|
// src/services/discord-commands.service.ts
|
|
88541
|
-
import { readFile as
|
|
88542
|
-
import { resolve as
|
|
88714
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
88715
|
+
import { resolve as resolve14 } from "node:path";
|
|
88543
88716
|
|
|
88544
88717
|
// ../../modules/discord/contract/src/discord.ts
|
|
88545
88718
|
var workspaceIdSchema24 = external_exports.string().min(1).max(64);
|
|
@@ -88860,7 +89033,7 @@ async function secretsOf({ context, args }) {
|
|
|
88860
89033
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
88861
89034
|
if (fromConnection) return { fromConnection };
|
|
88862
89035
|
const file4 = flagText({ args, name: "from-file" });
|
|
88863
|
-
const text3 = file4 ? await
|
|
89036
|
+
const text3 = file4 ? await readFile23(resolve14(context.cwd, file4), "utf8") : await context.readStdin();
|
|
88864
89037
|
const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
88865
89038
|
if (lines2.length !== 2) {
|
|
88866
89039
|
throw new CliUsageError(
|
|
@@ -89130,8 +89303,8 @@ var DOMAINS_USAGE = `Usage:
|
|
|
89130
89303
|
var printJson5 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
|
|
89131
89304
|
`);
|
|
89132
89305
|
function printDomain(context, row) {
|
|
89133
|
-
const
|
|
89134
|
-
context.out(`${row.domain} ${
|
|
89306
|
+
const join35 = row.autoJoin ? "auto-join on" : "auto-join off";
|
|
89307
|
+
context.out(`${row.domain} ${join35}${row.enforced ? " single sign-on enforced" : ""}
|
|
89135
89308
|
`);
|
|
89136
89309
|
}
|
|
89137
89310
|
async function list4({ context, args }) {
|
|
@@ -89163,8 +89336,8 @@ async function domains({ context, args }) {
|
|
|
89163
89336
|
}
|
|
89164
89337
|
|
|
89165
89338
|
// src/services/emoji-commands.service.ts
|
|
89166
|
-
import { readFile as
|
|
89167
|
-
import { resolve as
|
|
89339
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
89340
|
+
import { resolve as resolve15 } from "node:path";
|
|
89168
89341
|
var EMOJI_USAGE = `Usage:
|
|
89169
89342
|
laze emoji list [--json] the workspace's custom emoji, aliases and who added each
|
|
89170
89343
|
laze emoji add <name> <file> [--alias <a,b>] add a PNG, JPEG or GIF as :name: (made 128px square)
|
|
@@ -89204,7 +89377,7 @@ async function addEmoji({ context, args, client }) {
|
|
|
89204
89377
|
const file4 = wordAt4(args, 3);
|
|
89205
89378
|
let bytes;
|
|
89206
89379
|
try {
|
|
89207
|
-
bytes = new Uint8Array(await
|
|
89380
|
+
bytes = new Uint8Array(await readFile24(resolve15(context.cwd, file4)));
|
|
89208
89381
|
} catch {
|
|
89209
89382
|
throw new CliUsageError(`Cannot read ${file4}.`);
|
|
89210
89383
|
}
|
|
@@ -89520,8 +89693,8 @@ var ExternalChannelBannerSlot = externalUi.component("channel-banner");
|
|
|
89520
89693
|
var ExternalSharingHooksToken = externalUi.hooks("sharing");
|
|
89521
89694
|
|
|
89522
89695
|
// src/services/workspace-commands.service.ts
|
|
89523
|
-
import { readFile as
|
|
89524
|
-
import { resolve as
|
|
89696
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
89697
|
+
import { resolve as resolve16 } from "node:path";
|
|
89525
89698
|
var ROLE_NAMES2 = {
|
|
89526
89699
|
OWNER: "Owner",
|
|
89527
89700
|
ADMIN: "Admin",
|
|
@@ -89564,7 +89737,7 @@ async function mine2({ context, args }) {
|
|
|
89564
89737
|
`).join("") || "No workspaces.\n"
|
|
89565
89738
|
});
|
|
89566
89739
|
}
|
|
89567
|
-
async function
|
|
89740
|
+
async function rename4({ context, args }) {
|
|
89568
89741
|
const name3 = args.words.slice(2).join(" ").trim();
|
|
89569
89742
|
if (!name3) throw new CliUsageError("Usage: laze workspace rename <name>");
|
|
89570
89743
|
const { client } = await signedIn({ context, args });
|
|
@@ -89703,7 +89876,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
|
|
|
89703
89876
|
async function readLogo({ context, file: file4 }) {
|
|
89704
89877
|
let bytes;
|
|
89705
89878
|
try {
|
|
89706
|
-
bytes = new Uint8Array(await
|
|
89879
|
+
bytes = new Uint8Array(await readFile25(resolve16(context.cwd, file4)));
|
|
89707
89880
|
} catch {
|
|
89708
89881
|
throw new CliUsageError(`No file to read at ${file4}.`);
|
|
89709
89882
|
}
|
|
@@ -89743,7 +89916,7 @@ var WORKSPACE_COMMANDS = {
|
|
|
89743
89916
|
switch: switchTo,
|
|
89744
89917
|
logo,
|
|
89745
89918
|
mine: mine2,
|
|
89746
|
-
rename:
|
|
89919
|
+
rename: rename4,
|
|
89747
89920
|
create,
|
|
89748
89921
|
leave,
|
|
89749
89922
|
delete: scheduleDeletion,
|
|
@@ -90303,8 +90476,8 @@ async function agentFeedAccess({
|
|
|
90303
90476
|
}
|
|
90304
90477
|
|
|
90305
90478
|
// src/services/feed-commands.service.ts
|
|
90306
|
-
import { readFile as
|
|
90307
|
-
import { resolve as
|
|
90479
|
+
import { readFile as readFile26 } from "node:fs/promises";
|
|
90480
|
+
import { resolve as resolve17 } from "node:path";
|
|
90308
90481
|
|
|
90309
90482
|
// ../../modules/feed/contract/src/feed.delegate.ts
|
|
90310
90483
|
var feedDelegateSchemaDefinition = external_exports.object({
|
|
@@ -90625,6 +90798,11 @@ var feedViewerStateSchemaDefinition = external_exports.object({
|
|
|
90625
90798
|
unread: external_exports.boolean(),
|
|
90626
90799
|
/** Back from a snooze or a show-at date, not yet touched. */
|
|
90627
90800
|
woke: external_exports.enum(["snooze", "show_at"]).nullable(),
|
|
90801
|
+
/** Why a woke card came back and who brought it; `by` is null on the reader's own snooze. */
|
|
90802
|
+
wake: external_exports.object({
|
|
90803
|
+
cause: external_exports.enum(["snooze", "show_at", "urgent_reply"]),
|
|
90804
|
+
by: feedAuthorSchema.nullable()
|
|
90805
|
+
}).optional(),
|
|
90628
90806
|
snoozedUntil: external_exports.iso.datetime().nullable(),
|
|
90629
90807
|
/** The agent that snoozed it for the person, when it was not the person. */
|
|
90630
90808
|
snoozedBy: feedAuthorSchema.nullable(),
|
|
@@ -91218,15 +91396,24 @@ var FEED_WRITING = `Write for a person deciding on a phone in a few seconds:
|
|
|
91218
91396
|
no "Day 9." counters. Numbers only when they change the decision.
|
|
91219
91397
|
- Not too terse either: whole sentences a person understands without context.
|
|
91220
91398
|
- Replies and comments: same rules, short when you can.
|
|
91221
|
-
-
|
|
91222
|
-
|
|
91399
|
+
- Anything for people outside the conversation (an email, a Slack, WhatsApp or LinkedIn
|
|
91400
|
+
message to someone else, a post) is a draft for your person first, on a card: a one-line
|
|
91401
|
+
ask as the title, the full text in --draft, the recipients and subject in
|
|
91223
91402
|
--draft-header "To: ...
|
|
91224
91403
|
Cc: ...
|
|
91225
|
-
Subject: ...",
|
|
91226
|
-
|
|
91227
|
-
|
|
91228
|
-
|
|
91229
|
-
|
|
91404
|
+
Subject: ...", --action "Send it=<what to do>" and a
|
|
91405
|
+
--link that opens the original in its own app: for Gmail
|
|
91406
|
+
"Open thread with the draft=https://mail.google.com/mail/u/0/#all/<thread id>", else the
|
|
91407
|
+
Slack, WhatsApp or LinkedIn thread or the GitHub PR. For example:
|
|
91408
|
+
laze feed post "Reply to Dana about the renewal" --summary "She asked for the price by
|
|
91409
|
+
Friday" --draft @reply.md --draft-header "To: dana@acme.test
|
|
91410
|
+
Subject: Re: Renewal"
|
|
91411
|
+
--link "Open thread with the draft=https://mail.google.com/mail/u/0/#all/<thread id>"
|
|
91412
|
+
--action "Send it=Send this reply"
|
|
91413
|
+
- Send it only when they pressed Send on the card or told you in chat to send that exact
|
|
91414
|
+
message; a send approval card is not their review. After a send, say what went to whom.
|
|
91415
|
+
Never leave a draft only in Gmail drafts. If they edit the text on the card, the press
|
|
91416
|
+
brings you the edited text: update the native draft with it, then send.
|
|
91230
91417
|
- A draft that sends a file carries the file: pass it with --file. Never name a file you
|
|
91231
91418
|
did not attach; "Attach: deck.pdf" without a file is stopped unless you pass --force.
|
|
91232
91419
|
The server pushes back with feed_hard_to_read when the text reads like a log, and with
|
|
@@ -91386,7 +91573,7 @@ async function feedTurnOf({
|
|
|
91386
91573
|
const read4 = async () => {
|
|
91387
91574
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
91388
91575
|
if (pinned) return pinned;
|
|
91389
|
-
if (env.LAZE_TURN_FILE) return (await
|
|
91576
|
+
if (env.LAZE_TURN_FILE) return (await readFile26(env.LAZE_TURN_FILE, "utf8")).trim();
|
|
91390
91577
|
return agent3 ? connectedTurnTokenOf({ client, channelId: channel }) : "";
|
|
91391
91578
|
};
|
|
91392
91579
|
const turn = await read4().catch(() => "");
|
|
@@ -91460,7 +91647,7 @@ async function bodyOf2({
|
|
|
91460
91647
|
flags: flags2
|
|
91461
91648
|
}) {
|
|
91462
91649
|
const body = { ...flags2.fields };
|
|
91463
|
-
const read4 = (source) => "file" in source ?
|
|
91650
|
+
const read4 = (source) => "file" in source ? readFile26(resolve17(context.cwd, source.file), "utf8") : source.text;
|
|
91464
91651
|
for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read4(source);
|
|
91465
91652
|
if (flags2.rich) {
|
|
91466
91653
|
const text3 = await read4(flags2.rich.source);
|
|
@@ -91723,7 +91910,7 @@ async function textFlag({
|
|
|
91723
91910
|
}) {
|
|
91724
91911
|
const value = flagText({ args, name: name3 });
|
|
91725
91912
|
if (!value.startsWith("@")) return value;
|
|
91726
|
-
return
|
|
91913
|
+
return readFile26(resolve17(context.cwd, value.slice(1)), "utf8");
|
|
91727
91914
|
}
|
|
91728
91915
|
async function feedList({ context, args }) {
|
|
91729
91916
|
const { client } = await signedIn({ context, args });
|
|
@@ -91813,7 +92000,7 @@ async function ranksOf({
|
|
|
91813
92000
|
}) {
|
|
91814
92001
|
const file4 = flagText({ args, name: "file" });
|
|
91815
92002
|
if (file4) {
|
|
91816
|
-
const parsed = JSON.parse(await
|
|
92003
|
+
const parsed = JSON.parse(await readFile26(resolve17(context.cwd, file4), "utf8"));
|
|
91817
92004
|
if (Array.isArray(parsed)) return parsed;
|
|
91818
92005
|
throw new CliUsageError("--file holds a list of {itemId, priority}");
|
|
91819
92006
|
}
|
|
@@ -91926,7 +92113,7 @@ async function feed({ context, args }) {
|
|
|
91926
92113
|
}
|
|
91927
92114
|
|
|
91928
92115
|
// src/services/github-commands.service.ts
|
|
91929
|
-
import { readFile as
|
|
92116
|
+
import { readFile as readFile27 } from "node:fs/promises";
|
|
91930
92117
|
|
|
91931
92118
|
// src/rules/github-signature.rules.ts
|
|
91932
92119
|
var TURN_SEPARATOR = "~";
|
|
@@ -91996,7 +92183,7 @@ var REAL_GH = "/usr/bin/gh";
|
|
|
91996
92183
|
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>`.";
|
|
91997
92184
|
async function turnFileToken({ env }) {
|
|
91998
92185
|
if (!env.LAZE_TURN_FILE) return "";
|
|
91999
|
-
return
|
|
92186
|
+
return readFile27(env.LAZE_TURN_FILE, "utf8").then(
|
|
92000
92187
|
(text3) => text3.trim(),
|
|
92001
92188
|
() => ""
|
|
92002
92189
|
);
|
|
@@ -92030,7 +92217,7 @@ async function githubGh({
|
|
|
92030
92217
|
args: args.rest,
|
|
92031
92218
|
agentName: profile.name ?? "An agent",
|
|
92032
92219
|
threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
|
|
92033
|
-
readBodyFile: (path) => path === "-" ? context.readStdin() :
|
|
92220
|
+
readBodyFile: (path) => path === "-" ? context.readStdin() : readFile27(path, "utf8")
|
|
92034
92221
|
});
|
|
92035
92222
|
return context.runCommand({
|
|
92036
92223
|
command: [REAL_GH, ...ghArgs],
|
|
@@ -92193,7 +92380,7 @@ async function create2({ context, args }) {
|
|
|
92193
92380
|
});
|
|
92194
92381
|
printGroup({ context, args, group });
|
|
92195
92382
|
}
|
|
92196
|
-
async function
|
|
92383
|
+
async function rename5({ context, args }) {
|
|
92197
92384
|
const group = wordAt6({ args, at: 2 });
|
|
92198
92385
|
const name3 = wordAt6({ args, at: 3 });
|
|
92199
92386
|
const { client } = await signedIn({ context, args });
|
|
@@ -92232,7 +92419,7 @@ function changing3(key) {
|
|
|
92232
92419
|
var COMMANDS = {
|
|
92233
92420
|
list: list7,
|
|
92234
92421
|
create: create2,
|
|
92235
|
-
rename:
|
|
92422
|
+
rename: rename5,
|
|
92236
92423
|
delete: remove5,
|
|
92237
92424
|
add: changing3("add"),
|
|
92238
92425
|
remove: changing3("remove")
|
|
@@ -92425,6 +92612,10 @@ function heldLine(sent) {
|
|
|
92425
92612
|
const saved3 = `Saved ${held} ${held === 1 ? "invitation" : "invitations"} for Team: Free holds 2 people.`;
|
|
92426
92613
|
return emailed > 0 ? `Invited ${emailed}. ${saved3}` : saved3;
|
|
92427
92614
|
}
|
|
92615
|
+
function personLines(sent) {
|
|
92616
|
+
return sent.invites.flatMap((one) => one.personId ? [`${one.email} is person ${one.personId}.
|
|
92617
|
+
`] : []).join("");
|
|
92618
|
+
}
|
|
92428
92619
|
function refusedLines(refused) {
|
|
92429
92620
|
const why = { invalid: "not an email address", duplicate: "listed twice", member: "already in" };
|
|
92430
92621
|
return refused.map((one) => `Left out ${one.email}: ${why[one.reason]}.
|
|
@@ -92458,6 +92649,7 @@ async function invite3({ context, args }) {
|
|
|
92458
92649
|
return;
|
|
92459
92650
|
}
|
|
92460
92651
|
context.out(refusedLines(sent.refused));
|
|
92652
|
+
context.out(personLines(sent));
|
|
92461
92653
|
if (!quote4.upgradeNeeded) {
|
|
92462
92654
|
context.out(`Invited ${sent.invites.length}.${sent.held ? " Some wait for seats." : ""}
|
|
92463
92655
|
`);
|
|
@@ -92635,35 +92827,28 @@ async function ip({ context, args }) {
|
|
|
92635
92827
|
}
|
|
92636
92828
|
|
|
92637
92829
|
// src/services/join-commands.service.ts
|
|
92638
|
-
import {
|
|
92639
|
-
import { dirname as
|
|
92830
|
+
import { rm as rm15 } from "node:fs/promises";
|
|
92831
|
+
import { dirname as dirname19, join as join28 } from "node:path";
|
|
92640
92832
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
92641
92833
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
92642
92834
|
function pendingPathOf({ context }) {
|
|
92643
|
-
return
|
|
92835
|
+
return join28(dirname19(context.environment.configPath), "join", "pending.json");
|
|
92644
92836
|
}
|
|
92645
92837
|
async function readPending({
|
|
92646
92838
|
context,
|
|
92647
92839
|
url: url2,
|
|
92648
92840
|
args
|
|
92649
92841
|
}) {
|
|
92650
|
-
const pending2 = await
|
|
92651
|
-
(text3) => JSON.parse(text3),
|
|
92652
|
-
() => void 0
|
|
92653
|
-
);
|
|
92842
|
+
const pending2 = await readStateJson({ path: pendingPathOf({ context }) });
|
|
92654
92843
|
if (!pending2 || pending2.url !== url2) return void 0;
|
|
92655
92844
|
if (args && !asksTheSame({ pending: pending2, flags: flaggedOf({ args }) })) return void 0;
|
|
92656
92845
|
return Temporal3.Instant.from(pending2.expiresAt).epochMilliseconds > context.nowMs() ? pending2 : void 0;
|
|
92657
92846
|
}
|
|
92658
92847
|
async function keepPending({ context, pending: pending2 }) {
|
|
92659
|
-
|
|
92660
|
-
await mkdir23(dirname23(path), { recursive: true, mode: 448 });
|
|
92661
|
-
const temporary = `${path}.${process.pid}.tmp`;
|
|
92662
|
-
await writeFile22(temporary, JSON.stringify(pending2), { mode: 384 });
|
|
92663
|
-
await rename8(temporary, path);
|
|
92848
|
+
await writeStateJson({ path: pendingPathOf({ context }), value: pending2 });
|
|
92664
92849
|
}
|
|
92665
92850
|
async function dropPending({ context }) {
|
|
92666
|
-
await
|
|
92851
|
+
await rm15(pendingPathOf({ context }), { force: true });
|
|
92667
92852
|
}
|
|
92668
92853
|
function waitSecondsOf3({ args }) {
|
|
92669
92854
|
const raw = flagText({ args, name: "timeout" });
|
|
@@ -93231,7 +93416,7 @@ async function get({ context, args }) {
|
|
|
93231
93416
|
machine: await client.post(COMPUTE_REST_PATHS.get, { machine: machine2 })
|
|
93232
93417
|
});
|
|
93233
93418
|
}
|
|
93234
|
-
async function
|
|
93419
|
+
async function rename6({ context, args }) {
|
|
93235
93420
|
const machine2 = wordAt7({ args, at: 2 });
|
|
93236
93421
|
const name3 = wordAt7({ args, at: 3 });
|
|
93237
93422
|
const client = await computeClient({ context, args });
|
|
@@ -93277,7 +93462,7 @@ ${MACHINE_ACCESS_USAGE}`);
|
|
|
93277
93462
|
});
|
|
93278
93463
|
printMachine({ context, args, machine: changed });
|
|
93279
93464
|
}
|
|
93280
|
-
var COMMANDS2 = { status: status8, get, rename:
|
|
93465
|
+
var COMMANDS2 = { status: status8, get, rename: rename6, grant: share2, revoke: share2, budget };
|
|
93281
93466
|
function machineAccessCommand(name3) {
|
|
93282
93467
|
return name3 && Object.hasOwn(COMMANDS2, name3) ? COMMANDS2[name3] : void 0;
|
|
93283
93468
|
}
|
|
@@ -93797,18 +93982,18 @@ async function serveMcp({
|
|
|
93797
93982
|
}
|
|
93798
93983
|
|
|
93799
93984
|
// src/services/memory-commands.service.ts
|
|
93800
|
-
import { readdir as readdir7, readFile as
|
|
93801
|
-
import { join as
|
|
93985
|
+
import { readdir as readdir7, readFile as readFile29 } from "node:fs/promises";
|
|
93986
|
+
import { join as join29, resolve as resolve19 } from "node:path";
|
|
93802
93987
|
|
|
93803
93988
|
// src/services/mount-files.service.ts
|
|
93804
|
-
import { mkdir as
|
|
93805
|
-
import { dirname as
|
|
93989
|
+
import { mkdir as mkdir10, readFile as readFile28, rm as rm16, writeFile as writeFile8 } from "node:fs/promises";
|
|
93990
|
+
import { dirname as dirname20, relative as relative5, resolve as resolve18 } from "node:path";
|
|
93806
93991
|
async function textArgument({
|
|
93807
93992
|
context,
|
|
93808
93993
|
value
|
|
93809
93994
|
}) {
|
|
93810
93995
|
if (value === "-") return context.readStdin();
|
|
93811
|
-
if (value.startsWith("@")) return
|
|
93996
|
+
if (value.startsWith("@")) return readFile28(resolve18(context.cwd, value.slice(1)), "utf8");
|
|
93812
93997
|
return value;
|
|
93813
93998
|
}
|
|
93814
93999
|
function turnChannel({ context, args }) {
|
|
@@ -93820,16 +94005,16 @@ async function writeMount({
|
|
|
93820
94005
|
folder,
|
|
93821
94006
|
files: files2
|
|
93822
94007
|
}) {
|
|
93823
|
-
const root =
|
|
93824
|
-
await
|
|
93825
|
-
await
|
|
94008
|
+
const root = resolve18(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
94009
|
+
await rm16(root, { recursive: true, force: true });
|
|
94010
|
+
await mkdir10(root, { recursive: true });
|
|
93826
94011
|
for (const file4 of files2) {
|
|
93827
|
-
const target =
|
|
94012
|
+
const target = resolve18(root, file4.path);
|
|
93828
94013
|
const inside = relative5(root, target);
|
|
93829
94014
|
if (!inside || inside.startsWith(".."))
|
|
93830
94015
|
throw new Error(`Refusing to write outside ${root}: ${file4.path}`);
|
|
93831
|
-
await
|
|
93832
|
-
await
|
|
94016
|
+
await mkdir10(dirname20(target), { recursive: true });
|
|
94017
|
+
await writeFile8(target, file4.content);
|
|
93833
94018
|
}
|
|
93834
94019
|
return root;
|
|
93835
94020
|
}
|
|
@@ -93955,7 +94140,7 @@ async function turnTokenOf5({ context }) {
|
|
|
93955
94140
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
93956
94141
|
if (pinned) return pinned;
|
|
93957
94142
|
if (!env.LAZE_TURN_FILE) return "";
|
|
93958
|
-
return
|
|
94143
|
+
return readFile29(env.LAZE_TURN_FILE, "utf8").then(
|
|
93959
94144
|
(text3) => text3.trim(),
|
|
93960
94145
|
() => ""
|
|
93961
94146
|
);
|
|
@@ -94084,16 +94269,16 @@ async function siestaImport({
|
|
|
94084
94269
|
args,
|
|
94085
94270
|
dir
|
|
94086
94271
|
}) {
|
|
94087
|
-
const root =
|
|
94088
|
-
const log = await
|
|
94089
|
-
const names = (await readdir7(
|
|
94272
|
+
const root = resolve19(context.cwd, dir);
|
|
94273
|
+
const log = await readFile29(join29(root, "LOG.md"));
|
|
94274
|
+
const names = (await readdir7(join29(root, "tree")).catch(() => [])).filter(
|
|
94090
94275
|
(name3) => /^\d{1,6}-\d{1,6}\.md$/.test(name3)
|
|
94091
94276
|
);
|
|
94092
94277
|
const tree = Object.fromEntries(
|
|
94093
94278
|
await Promise.all(
|
|
94094
94279
|
names.map(async (name3) => [
|
|
94095
94280
|
name3.slice(0, -3),
|
|
94096
|
-
(await
|
|
94281
|
+
(await readFile29(join29(root, "tree", name3))).toString("base64")
|
|
94097
94282
|
])
|
|
94098
94283
|
)
|
|
94099
94284
|
);
|
|
@@ -94112,16 +94297,16 @@ async function memoryImport({ context, args }) {
|
|
|
94112
94297
|
if (siesta) return siestaImport({ context, args, dir: siesta });
|
|
94113
94298
|
const dir = flagText({ args, name: "optmem" });
|
|
94114
94299
|
if (!dir) throw new CliUsageError(USAGE13);
|
|
94115
|
-
const root =
|
|
94116
|
-
const log = await
|
|
94117
|
-
const sizes2 = (await readdir7(
|
|
94300
|
+
const root = resolve19(context.cwd, dir);
|
|
94301
|
+
const log = await readFile29(join29(root, "LOG.txt"));
|
|
94302
|
+
const sizes2 = (await readdir7(join29(root, "TREE")).catch(() => [])).filter(
|
|
94118
94303
|
(name3) => /^\d{1,4}$/.test(name3)
|
|
94119
94304
|
);
|
|
94120
94305
|
const tree = Object.fromEntries(
|
|
94121
94306
|
await Promise.all(
|
|
94122
94307
|
sizes2.map(async (size) => [
|
|
94123
94308
|
size,
|
|
94124
|
-
(await
|
|
94309
|
+
(await readFile29(join29(root, "TREE", size))).toString("base64")
|
|
94125
94310
|
])
|
|
94126
94311
|
)
|
|
94127
94312
|
);
|
|
@@ -94482,7 +94667,7 @@ async function notifications({ context, args }) {
|
|
|
94482
94667
|
}
|
|
94483
94668
|
|
|
94484
94669
|
// src/services/openclaw-commands.service.ts
|
|
94485
|
-
import { resolve as
|
|
94670
|
+
import { resolve as resolve20 } from "node:path";
|
|
94486
94671
|
var OPENCLAW_USAGE = `Usage (a person's key; a gateway belongs to the person who connects it):
|
|
94487
94672
|
laze openclaw list the gateways connected here and their agents
|
|
94488
94673
|
laze openclaw connect <wss url> [--label <label>] (< token | --from-file <file> | --from-vault <connection>)
|
|
@@ -94633,7 +94818,7 @@ var agentKey = async ({ context, args, client, url: url2 }) => {
|
|
|
94633
94818
|
});
|
|
94634
94819
|
const login2 = flagText({ args, name: "login" });
|
|
94635
94820
|
if (login2) {
|
|
94636
|
-
const folder =
|
|
94821
|
+
const folder = resolve20(context.cwd, login2);
|
|
94637
94822
|
const profile = profileNameOf(key.agentName);
|
|
94638
94823
|
await signInFolder({ context, url: url2, token: key.token, name: profile, folder });
|
|
94639
94824
|
context.out(
|
|
@@ -94685,9 +94870,9 @@ async function openclaw({
|
|
|
94685
94870
|
}
|
|
94686
94871
|
|
|
94687
94872
|
// src/services/operator-key-commands.service.ts
|
|
94688
|
-
import { createHash as createHash7, randomBytes as
|
|
94689
|
-
import { mkdir as
|
|
94690
|
-
import { dirname as
|
|
94873
|
+
import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
|
|
94874
|
+
import { mkdir as mkdir11, readFile as readFile30, rm as rm17, writeFile as writeFile9 } from "node:fs/promises";
|
|
94875
|
+
import { dirname as dirname21, join as join30 } from "node:path";
|
|
94691
94876
|
|
|
94692
94877
|
// ../../modules/audit-log/contract/src/audit-log.api.ts
|
|
94693
94878
|
var auditEntrySchemaDefinition = external_exports.object({
|
|
@@ -95122,9 +95307,20 @@ var workspaceInviteSchemaDefinition = external_exports.object({
|
|
|
95122
95307
|
/** Where the invited person lands on joining; null for the workspace's Home. */
|
|
95123
95308
|
landing: inviteLandingSchema.nullable().optional(),
|
|
95124
95309
|
/** Held for Team, so its seat is paid for from the checkout on, before anyone accepts. */
|
|
95125
|
-
seatReserved: external_exports.boolean().optional()
|
|
95310
|
+
seatReserved: external_exports.boolean().optional(),
|
|
95311
|
+
/** The invited person's id: members message them and give them things before they join. */
|
|
95312
|
+
personId: external_exports.string().optional()
|
|
95126
95313
|
});
|
|
95127
95314
|
var workspaceInviteSchema = workspaceInviteSchemaDefinition;
|
|
95315
|
+
var workspaceInviteeSchemaDefinition = external_exports.object({
|
|
95316
|
+
userId: external_exports.string().min(1),
|
|
95317
|
+
inviteId: external_exports.string().min(1),
|
|
95318
|
+
email: external_exports.string(),
|
|
95319
|
+
status: external_exports.enum(["pending", "held", "expired"]),
|
|
95320
|
+
invitedByUserId: external_exports.string(),
|
|
95321
|
+
invitedAt: external_exports.iso.datetime()
|
|
95322
|
+
});
|
|
95323
|
+
var workspaceInviteeSchema = workspaceInviteeSchemaDefinition;
|
|
95128
95324
|
var invitePreviewSchemaDefinition = external_exports.object({
|
|
95129
95325
|
workspaceName: external_exports.string(),
|
|
95130
95326
|
email: external_exports.string(),
|
|
@@ -95263,7 +95459,7 @@ var settingsCopy = {
|
|
|
95263
95459
|
paintOnly: true,
|
|
95264
95460
|
storable: (copy2) => copy2
|
|
95265
95461
|
};
|
|
95266
|
-
var workspaceTrpc = defineTrpcContract("workspace").mutation("create").withInput(createWorkspaceInputSchema).withOutput(workspaceCreatedSchema).query("get", { mirrored: settingsCopy }).withInput(workspaceIdInputSchema).withOutput(workspaceSchema).query("mine").withInput(external_exports.object({})).withOutput(external_exports.array(myWorkspaceSchema)).query("members").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceMemberSchema)).query("myMembership").withInput(workspaceIdInputSchema).withOutput(workspaceMemberSchema.nullable()).mutation("setMyAliases").withInput(setAliasesInputSchema).withOutput(workspaceMemberSchema).mutation("changeRole").withInput(changeRoleInputSchema).withOutput(workspaceMemberSchema).mutation("removeMember").withInput(removeMemberInputSchema2).withOutput(external_exports.object({ removed: external_exports.literal(true) })).mutation("leave").withInput(workspaceIdInputSchema).withOutput(external_exports.object({ left: external_exports.literal(true) })).mutation("invite").withInput(inviteMemberInputSchema).withOutput(workspaceInviteSchema).mutation("inviteMany").withInput(inviteManyInputSchema).withOutput(inviteManyResultSchema).mutation("requestInvites").withInput(inviteManyInputSchema).withOutput(requestInvitesResultSchema).query("invites").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceInviteSchema)).mutation("revokeInvite").withInput(revokeInviteInputSchema).withOutput(external_exports.object({ revoked: external_exports.literal(true) })).mutation("copyInviteLink").withInput(revokeInviteInputSchema).withOutput(copiedInviteLinkSchema).query("previewInvite").withInput(inviteLinkInputSchema).withOutput(invitePreviewSchema).mutation("acceptInvite").withInput(inviteLinkInputSchema).withOutput(acceptedInviteSchema).mutation("rename").withInput(renameWorkspaceInputSchema).withOutput(workspaceSchema).mutation("setLogo").withInput(setWorkspaceLogoInputSchema).withOutput(workspaceSchema).mutation("removeLogo").withInput(workspaceIdInputSchema).withOutput(workspaceSchema).mutation("delete").withInput(deleteWorkspaceInputSchema).withOutput(workspaceSchema).mutation("cancelDeletion").withInput(workspaceIdInputSchema).withOutput(workspaceSchema).mutation("requestInvite").withInput(requestInviteInputSchema).withOutput(accessRequestSchema).query("accessRequests").withInput(workspaceIdInputSchema).withOutput(external_exports.array(accessRequestSchema)).mutation("decideAccessRequest").withInput(decideAccessRequestInputSchema).withOutput(accessRequestSchema).mutation("withdrawJoinRequest").withInput(external_exports.object({ workspaceId: external_exports.string().min(1), requestId: external_exports.string().min(1) })).withOutput(accessRequestSchema).query("groups").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceGroupSchema)).mutation("createGroup").withInput(createGroupInputSchema).withOutput(workspaceGroupSchema).mutation("renameGroup").withInput(renameGroupInputSchema).withOutput(workspaceGroupSchema).mutation("deleteGroup").withInput(groupInputSchema).withOutput(external_exports.object({ deleted: external_exports.literal(true) })).mutation("changeGroupMembers").withInput(changeGroupMembersInputSchema).withOutput(workspaceGroupSchema).build();
|
|
95462
|
+
var workspaceTrpc = defineTrpcContract("workspace").mutation("create").withInput(createWorkspaceInputSchema).withOutput(workspaceCreatedSchema).query("get", { mirrored: settingsCopy }).withInput(workspaceIdInputSchema).withOutput(workspaceSchema).query("mine").withInput(external_exports.object({})).withOutput(external_exports.array(myWorkspaceSchema)).query("members").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceMemberSchema)).query("myMembership").withInput(workspaceIdInputSchema).withOutput(workspaceMemberSchema.nullable()).mutation("setMyAliases").withInput(setAliasesInputSchema).withOutput(workspaceMemberSchema).mutation("changeRole").withInput(changeRoleInputSchema).withOutput(workspaceMemberSchema).mutation("removeMember").withInput(removeMemberInputSchema2).withOutput(external_exports.object({ removed: external_exports.literal(true) })).mutation("leave").withInput(workspaceIdInputSchema).withOutput(external_exports.object({ left: external_exports.literal(true) })).mutation("invite").withInput(inviteMemberInputSchema).withOutput(workspaceInviteSchema).mutation("inviteMany").withInput(inviteManyInputSchema).withOutput(inviteManyResultSchema).mutation("requestInvites").withInput(inviteManyInputSchema).withOutput(requestInvitesResultSchema).query("invites").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceInviteSchema)).query("invitees").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceInviteeSchema)).mutation("revokeInvite").withInput(revokeInviteInputSchema).withOutput(external_exports.object({ revoked: external_exports.literal(true) })).mutation("copyInviteLink").withInput(revokeInviteInputSchema).withOutput(copiedInviteLinkSchema).query("previewInvite").withInput(inviteLinkInputSchema).withOutput(invitePreviewSchema).mutation("acceptInvite").withInput(inviteLinkInputSchema).withOutput(acceptedInviteSchema).mutation("rename").withInput(renameWorkspaceInputSchema).withOutput(workspaceSchema).mutation("setLogo").withInput(setWorkspaceLogoInputSchema).withOutput(workspaceSchema).mutation("removeLogo").withInput(workspaceIdInputSchema).withOutput(workspaceSchema).mutation("delete").withInput(deleteWorkspaceInputSchema).withOutput(workspaceSchema).mutation("cancelDeletion").withInput(workspaceIdInputSchema).withOutput(workspaceSchema).mutation("requestInvite").withInput(requestInviteInputSchema).withOutput(accessRequestSchema).query("accessRequests").withInput(workspaceIdInputSchema).withOutput(external_exports.array(accessRequestSchema)).mutation("decideAccessRequest").withInput(decideAccessRequestInputSchema).withOutput(accessRequestSchema).mutation("withdrawJoinRequest").withInput(external_exports.object({ workspaceId: external_exports.string().min(1), requestId: external_exports.string().min(1) })).withOutput(accessRequestSchema).query("groups").withInput(workspaceIdInputSchema).withOutput(external_exports.array(workspaceGroupSchema)).mutation("createGroup").withInput(createGroupInputSchema).withOutput(workspaceGroupSchema).mutation("renameGroup").withInput(renameGroupInputSchema).withOutput(workspaceGroupSchema).mutation("deleteGroup").withInput(groupInputSchema).withOutput(external_exports.object({ deleted: external_exports.literal(true) })).mutation("changeGroupMembers").withInput(changeGroupMembersInputSchema).withOutput(workspaceGroupSchema).build();
|
|
95267
95463
|
|
|
95268
95464
|
// ../../modules/workspace/contract/src/workspace.config.ts
|
|
95269
95465
|
var workspaceConfig = Config.define((c) => ({
|
|
@@ -95308,6 +95504,10 @@ var memberRemovedDefinition = external_exports.object({
|
|
|
95308
95504
|
/** ISO 8601. */
|
|
95309
95505
|
at: external_exports.iso.datetime()
|
|
95310
95506
|
});
|
|
95507
|
+
var inviteeReleasedDefinition = external_exports.object({
|
|
95508
|
+
...memberRemovedDefinition.shape,
|
|
95509
|
+
email: external_exports.string().optional()
|
|
95510
|
+
});
|
|
95311
95511
|
var memberErasedDefinition = external_exports.object({
|
|
95312
95512
|
workspaceId: external_exports.string().min(1),
|
|
95313
95513
|
userId: external_exports.string().min(1),
|
|
@@ -96017,15 +96217,15 @@ var OPERATOR_KEY_USAGE = `Temporary operator keys (ask, an operator approves wit
|
|
|
96017
96217
|
laze ops status <key> waiting, approved or ended
|
|
96018
96218
|
laze ops use <key> run the approved action and print the answer`;
|
|
96019
96219
|
var POLL_MS3 = 5e3;
|
|
96020
|
-
var keyFile = ({ context, keyId }) =>
|
|
96220
|
+
var keyFile = ({ context, keyId }) => join30(dirname21(context.environment.configPath), "operator-keys", keyId.replaceAll("/", "_"));
|
|
96021
96221
|
async function saveSecret({
|
|
96022
96222
|
context,
|
|
96023
96223
|
keyId,
|
|
96024
96224
|
secret
|
|
96025
96225
|
}) {
|
|
96026
96226
|
const path = keyFile({ context, keyId });
|
|
96027
|
-
await
|
|
96028
|
-
await
|
|
96227
|
+
await mkdir11(dirname21(path), { recursive: true, mode: 448 });
|
|
96228
|
+
await writeFile9(path, secret, { mode: 384 });
|
|
96029
96229
|
}
|
|
96030
96230
|
function typedArg(text3) {
|
|
96031
96231
|
if (["true", "false", "null"].includes(text3)) return JSON.parse(text3);
|
|
@@ -96042,12 +96242,12 @@ ${OPERATOR_KEY_USAGE}`);
|
|
|
96042
96242
|
return Object.fromEntries(pairs);
|
|
96043
96243
|
}
|
|
96044
96244
|
var EXPIRED_LINE = `Expired: nobody answered within ${OPERATOR_KEY.pendingMinutes} minutes. Nothing ran. Ask again with laze ops request.`;
|
|
96045
|
-
function statusLine2({ key, nowMs }) {
|
|
96245
|
+
function statusLine2({ key, nowMs: nowMs2 }) {
|
|
96046
96246
|
switch (key.status) {
|
|
96047
96247
|
case "approved":
|
|
96048
96248
|
return `Approved until ${key.endsAt}. Run: laze ops use ${key.id}`;
|
|
96049
96249
|
case "pending":
|
|
96050
|
-
return Temporal3.Instant.from(key.pendingUntil).epochMilliseconds <=
|
|
96250
|
+
return Temporal3.Instant.from(key.pendingUntil).epochMilliseconds <= nowMs2 ? EXPIRED_LINE : `Waiting for an operator's passkey at /ops/keys. Nothing runs until they approve. It expires at ${key.pendingUntil} if nobody answers.`;
|
|
96051
96251
|
case "expired":
|
|
96052
96252
|
return EXPIRED_LINE;
|
|
96053
96253
|
case "denied":
|
|
@@ -96076,7 +96276,7 @@ async function requestKey({ context, args }) {
|
|
|
96076
96276
|
const reason2 = flagText({ args, name: "reason" });
|
|
96077
96277
|
if (!action || !target || !reason2.trim()) throw new CliUsageError(OPERATOR_KEY_USAGE);
|
|
96078
96278
|
const { client } = await signedIn({ context, args });
|
|
96079
|
-
const secret =
|
|
96279
|
+
const secret = randomBytes4(32).toString("hex");
|
|
96080
96280
|
const key = await client.post(OPERATOR_KEY_REST_PATHS.request, {
|
|
96081
96281
|
action,
|
|
96082
96282
|
target,
|
|
@@ -96109,7 +96309,7 @@ async function forgetIfOver({
|
|
|
96109
96309
|
const key = await client.post(OPERATOR_KEY_REST_PATHS.status, { keyId });
|
|
96110
96310
|
const windowOver = key.endsAt !== null && Temporal3.Instant.from(key.endsAt).epochMilliseconds <= context.nowMs();
|
|
96111
96311
|
if (key.status !== "pending" && (key.status !== "approved" || windowOver || key.spentAt)) {
|
|
96112
|
-
await
|
|
96312
|
+
await rm17(keyFile({ context, keyId }), { force: true });
|
|
96113
96313
|
}
|
|
96114
96314
|
return key;
|
|
96115
96315
|
}
|
|
@@ -96118,7 +96318,7 @@ async function useKey({ context, args }) {
|
|
|
96118
96318
|
if (!keyId) throw new CliUsageError(OPERATOR_KEY_USAGE);
|
|
96119
96319
|
const { client } = await signedIn({ context, args });
|
|
96120
96320
|
const path = keyFile({ context, keyId });
|
|
96121
|
-
const secret = await
|
|
96321
|
+
const secret = await readFile30(path, "utf8").catch(() => null);
|
|
96122
96322
|
if (secret === null) {
|
|
96123
96323
|
throw new CliUsageError(`No operator key ${keyId} is kept on this machine.`);
|
|
96124
96324
|
}
|
|
@@ -96183,8 +96383,8 @@ ${OPS_USAGE}`);
|
|
|
96183
96383
|
}
|
|
96184
96384
|
|
|
96185
96385
|
// src/services/release-watch.service.ts
|
|
96186
|
-
import {
|
|
96187
|
-
import { dirname as
|
|
96386
|
+
import { realpath } from "node:fs/promises";
|
|
96387
|
+
import { dirname as dirname22, join as join31 } from "node:path";
|
|
96188
96388
|
|
|
96189
96389
|
// src/rules/cli-update.rules.ts
|
|
96190
96390
|
var CLI_PACKAGE = "@lazehq/cli";
|
|
@@ -96330,16 +96530,15 @@ async function startedUpdate({
|
|
|
96330
96530
|
if (context.environment.inherited.LAZE_AUTO_UPDATE === "0") return null;
|
|
96331
96531
|
const plan2 = updatePlanOf({ script: await scriptOf(context) });
|
|
96332
96532
|
if (plan2.kind !== "install") return null;
|
|
96333
|
-
const folder =
|
|
96334
|
-
const stamp =
|
|
96335
|
-
const last = await
|
|
96533
|
+
const folder = dirname22(context.environment.configPath);
|
|
96534
|
+
const stamp = join31(folder, "auto-update.json");
|
|
96535
|
+
const last = await readStateJson({ path: stamp }) ?? null;
|
|
96336
96536
|
const now = context.nowMs();
|
|
96337
96537
|
if (last?.server === server && now - last.atMs < RETRY_AFTER_MS) return null;
|
|
96338
|
-
await
|
|
96339
|
-
await writeFile25(stamp, JSON.stringify({ server, atMs: now }), { mode: 384 });
|
|
96538
|
+
await writeStateJson({ path: stamp, value: { server, atMs: now } });
|
|
96340
96539
|
context.processes.spawnDetached({
|
|
96341
96540
|
argv: [...context.program, "update"],
|
|
96342
|
-
logPath:
|
|
96541
|
+
logPath: join31(folder, "auto-update.log")
|
|
96343
96542
|
});
|
|
96344
96543
|
return { manager: plan2.manager };
|
|
96345
96544
|
}
|
|
@@ -96376,7 +96575,7 @@ function watchingRelease({
|
|
|
96376
96575
|
}
|
|
96377
96576
|
|
|
96378
96577
|
// src/services/rush-guard.service.ts
|
|
96379
|
-
import {
|
|
96578
|
+
import { rm as rm18 } from "node:fs/promises";
|
|
96380
96579
|
var WATCH_MS3 = 2e3;
|
|
96381
96580
|
var RETRY_MS2 = 3e4;
|
|
96382
96581
|
async function guardRound(guard) {
|
|
@@ -96419,10 +96618,7 @@ async function rushWakeHook({ context, args }) {
|
|
|
96419
96618
|
while (context.processes.alive(claudePid)) await context.sleep(WATCH_MS3);
|
|
96420
96619
|
const { client, name: name3 } = await signedIn({ context, args });
|
|
96421
96620
|
const noted = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
96422
|
-
const note = await
|
|
96423
|
-
(text3) => JSON.parse(text3),
|
|
96424
|
-
() => void 0
|
|
96425
|
-
);
|
|
96621
|
+
const note = await readStateJson({ path: noted });
|
|
96426
96622
|
const { launch = {}, ...session } = note ?? {};
|
|
96427
96623
|
const lock = statePathOf({ context, kind: "waiters", profile: name3 });
|
|
96428
96624
|
const rush = { id: id4, program };
|
|
@@ -96448,10 +96644,10 @@ async function rushWakeHook({ context, args }) {
|
|
|
96448
96644
|
return 0;
|
|
96449
96645
|
} finally {
|
|
96450
96646
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
96451
|
-
await
|
|
96647
|
+
await rm18(lock, { force: true });
|
|
96452
96648
|
}
|
|
96453
96649
|
} finally {
|
|
96454
|
-
await
|
|
96650
|
+
await rm18(path, { force: true });
|
|
96455
96651
|
}
|
|
96456
96652
|
}
|
|
96457
96653
|
|
|
@@ -96617,8 +96813,8 @@ async function schedule({ context, args }) {
|
|
|
96617
96813
|
}
|
|
96618
96814
|
|
|
96619
96815
|
// src/services/skill-commands.service.ts
|
|
96620
|
-
import { readdir as readdir8, readFile as
|
|
96621
|
-
import { join as
|
|
96816
|
+
import { readdir as readdir8, readFile as readFile31 } from "node:fs/promises";
|
|
96817
|
+
import { join as join32, relative as relative6, resolve as resolve21 } from "node:path";
|
|
96622
96818
|
var USAGE17 = `Usage:
|
|
96623
96819
|
laze skill list [--agent <agentId>]
|
|
96624
96820
|
laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
|
|
@@ -96639,8 +96835,8 @@ async function folderFiles({ root }) {
|
|
|
96639
96835
|
const files2 = [];
|
|
96640
96836
|
for (const entry of entries) {
|
|
96641
96837
|
if (!entry.isFile()) continue;
|
|
96642
|
-
const full =
|
|
96643
|
-
files2.push({ path: relative6(root, full), content: await
|
|
96838
|
+
const full = join32(entry.parentPath, entry.name);
|
|
96839
|
+
files2.push({ path: relative6(root, full), content: await readFile31(full, "utf8") });
|
|
96644
96840
|
}
|
|
96645
96841
|
return files2.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
96646
96842
|
}
|
|
@@ -96671,7 +96867,7 @@ async function skillInstall({ context, args }) {
|
|
|
96671
96867
|
if (!catalogueId === !from) throw new CliUsageError(USAGE17);
|
|
96672
96868
|
const name3 = flagText({ args, name: "as" });
|
|
96673
96869
|
const agent3 = flagText({ args, name: "agent" });
|
|
96674
|
-
const files2 = from ? await folderFiles({ root:
|
|
96870
|
+
const files2 = from ? await folderFiles({ root: resolve21(context.cwd, from) }) : void 0;
|
|
96675
96871
|
const { client } = await signedIn({ context, args });
|
|
96676
96872
|
const installed = await client.post("/api/skills/install", {
|
|
96677
96873
|
...catalogueId ? { catalogueId } : {},
|
|
@@ -96738,7 +96934,7 @@ async function skillUpdate({ context, args }) {
|
|
|
96738
96934
|
if (!name3 || !newName && description === void 0 && !skillMdFile) {
|
|
96739
96935
|
throw new CliUsageError(USAGE17);
|
|
96740
96936
|
}
|
|
96741
|
-
const skillMd = skillMdFile ? await
|
|
96937
|
+
const skillMd = skillMdFile ? await readFile31(resolve21(context.cwd, skillMdFile), "utf8") : void 0;
|
|
96742
96938
|
const { client } = await signedIn({ context, args });
|
|
96743
96939
|
const updated = await client.post("/api/skills/update", {
|
|
96744
96940
|
name: name3,
|
|
@@ -96784,8 +96980,8 @@ async function skill({ context, args }) {
|
|
|
96784
96980
|
}
|
|
96785
96981
|
|
|
96786
96982
|
// src/services/slack-commands.service.ts
|
|
96787
|
-
import { readFile as
|
|
96788
|
-
import { resolve as
|
|
96983
|
+
import { readFile as readFile32 } from "node:fs/promises";
|
|
96984
|
+
import { resolve as resolve22 } from "node:path";
|
|
96789
96985
|
var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
|
|
96790
96986
|
laze slack overview connected Slack workspaces, mirrors, your link
|
|
96791
96987
|
laze slack link-prompts Slack workspaces you have not linked yet
|
|
@@ -96832,7 +97028,7 @@ async function secretLines({ context, args }) {
|
|
|
96832
97028
|
throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
|
|
96833
97029
|
}
|
|
96834
97030
|
const file4 = flagText({ args, name: "from-file" });
|
|
96835
|
-
const text3 = file4 ? await
|
|
97031
|
+
const text3 = file4 ? await readFile32(resolve22(context.cwd, file4), "utf8") : await context.readStdin();
|
|
96836
97032
|
return text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
96837
97033
|
}
|
|
96838
97034
|
async function secretsOf2({
|
|
@@ -97136,7 +97332,7 @@ async function slack({
|
|
|
97136
97332
|
}
|
|
97137
97333
|
|
|
97138
97334
|
// src/services/sso-commands.service.ts
|
|
97139
|
-
import { readFile as
|
|
97335
|
+
import { readFile as readFile33 } from "node:fs/promises";
|
|
97140
97336
|
var SSO_USAGE = `Usage:
|
|
97141
97337
|
laze sso domains claimed domains and how each signs in (admins)
|
|
97142
97338
|
laze sso claim <domain> the TXT record that proves the domain
|
|
@@ -97223,7 +97419,7 @@ function refuseSecretFlags({ args }) {
|
|
|
97223
97419
|
}
|
|
97224
97420
|
async function clientSecretOf({ context, args }) {
|
|
97225
97421
|
const file4 = flagText({ args, name: "from-file" });
|
|
97226
|
-
const text3 = file4 ? await
|
|
97422
|
+
const text3 = file4 ? await readFile33(file4, "utf8") : await context.readStdin();
|
|
97227
97423
|
const secret = text3.trim();
|
|
97228
97424
|
if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
|
|
97229
97425
|
return secret;
|
|
@@ -97555,8 +97751,8 @@ async function update2({
|
|
|
97555
97751
|
}
|
|
97556
97752
|
|
|
97557
97753
|
// src/services/vault-env-commands.service.ts
|
|
97558
|
-
import { readFile as
|
|
97559
|
-
import { dirname as
|
|
97754
|
+
import { readFile as readFile34, stat as stat12 } from "node:fs/promises";
|
|
97755
|
+
import { dirname as dirname23, join as join33, resolve as resolve23 } from "node:path";
|
|
97560
97756
|
|
|
97561
97757
|
// src/rules/vault-manifest.rules.ts
|
|
97562
97758
|
var VARIABLE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -97644,7 +97840,7 @@ function credentialProcessJson(fields) {
|
|
|
97644
97840
|
}
|
|
97645
97841
|
|
|
97646
97842
|
// src/services/vault-batch.service.ts
|
|
97647
|
-
import { rm as
|
|
97843
|
+
import { rm as rm19 } from "node:fs/promises";
|
|
97648
97844
|
async function batchOf({ response }) {
|
|
97649
97845
|
const text3 = await response.text();
|
|
97650
97846
|
if (!response.ok) {
|
|
@@ -97826,7 +98022,7 @@ async function valuesOf({
|
|
|
97826
98022
|
}) {
|
|
97827
98023
|
const refused = refusalOf({ context, settled: settled2 });
|
|
97828
98024
|
if (refused !== 0) {
|
|
97829
|
-
await
|
|
98025
|
+
await rm19(keyPath, { force: true });
|
|
97830
98026
|
return { exitCode: refused };
|
|
97831
98027
|
}
|
|
97832
98028
|
const opened = /* @__PURE__ */ new Map();
|
|
@@ -97838,7 +98034,7 @@ async function valuesOf({
|
|
|
97838
98034
|
if (release2.message) context.err(`${release2.message}
|
|
97839
98035
|
`);
|
|
97840
98036
|
}
|
|
97841
|
-
if (!keep2) await
|
|
98037
|
+
if (!keep2) await rm19(keyPath, { force: true });
|
|
97842
98038
|
const released = /* @__PURE__ */ new Map();
|
|
97843
98039
|
for (const entry of entries) {
|
|
97844
98040
|
const fields = opened.get(keyOf(entry));
|
|
@@ -97891,7 +98087,7 @@ function refusedReason({
|
|
|
97891
98087
|
return VAULT_EXIT_BAD_REASON;
|
|
97892
98088
|
}
|
|
97893
98089
|
async function isFile(path) {
|
|
97894
|
-
return
|
|
98090
|
+
return stat12(path).then(
|
|
97895
98091
|
(found) => found.isFile(),
|
|
97896
98092
|
() => false
|
|
97897
98093
|
);
|
|
@@ -97901,12 +98097,12 @@ async function manifestPathOf({
|
|
|
97901
98097
|
args
|
|
97902
98098
|
}) {
|
|
97903
98099
|
const named = args.words[2];
|
|
97904
|
-
if (named) return
|
|
98100
|
+
if (named) return resolve23(context.cwd, named);
|
|
97905
98101
|
const environment = flagText({ args, name: "env" });
|
|
97906
98102
|
const file4 = environment ? `.env.${environment}.vault` : ".env.vault";
|
|
97907
|
-
for (let dir =
|
|
97908
|
-
if (await isFile(
|
|
97909
|
-
if (
|
|
98103
|
+
for (let dir = resolve23(context.cwd); ; dir = dirname23(dir)) {
|
|
98104
|
+
if (await isFile(join33(dir, file4))) return join33(dir, file4);
|
|
98105
|
+
if (dirname23(dir) === dir) break;
|
|
97910
98106
|
}
|
|
97911
98107
|
throw new CliUsageError(`laze vault: no ${file4} here or in a parent folder
|
|
97912
98108
|
${ENV_USAGE}`);
|
|
@@ -97916,7 +98112,7 @@ async function manifestOf({
|
|
|
97916
98112
|
args
|
|
97917
98113
|
}) {
|
|
97918
98114
|
const file4 = await manifestPathOf({ context, args });
|
|
97919
|
-
const text3 = await
|
|
98115
|
+
const text3 = await readFile34(file4, "utf8").catch(() => {
|
|
97920
98116
|
throw new CliUsageError(`laze vault: cannot read ${file4}`);
|
|
97921
98117
|
});
|
|
97922
98118
|
return { file: file4, lines: parseManifest({ text: text3, file: file4 }) };
|
|
@@ -98231,8 +98427,8 @@ async function vaultScrub({ context, args }) {
|
|
|
98231
98427
|
}
|
|
98232
98428
|
|
|
98233
98429
|
// src/services/whatsapp-business-commands.service.ts
|
|
98234
|
-
import { readFile as
|
|
98235
|
-
import { resolve as
|
|
98430
|
+
import { readFile as readFile35 } from "node:fs/promises";
|
|
98431
|
+
import { resolve as resolve24 } from "node:path";
|
|
98236
98432
|
|
|
98237
98433
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
|
|
98238
98434
|
var whatsappBusinessCategorySchema = external_exports.enum([
|
|
@@ -98651,7 +98847,7 @@ async function secretsOf3({ context, args }) {
|
|
|
98651
98847
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
98652
98848
|
if (fromConnection) return { fromConnection };
|
|
98653
98849
|
const file4 = flagText({ args, name: "from-file" });
|
|
98654
|
-
const text3 = file4 ? await
|
|
98850
|
+
const text3 = file4 ? await readFile35(resolve24(context.cwd, file4), "utf8") : await context.readStdin();
|
|
98655
98851
|
const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
98656
98852
|
if (lines2.length !== 2) {
|
|
98657
98853
|
throw new CliUsageError(
|
|
@@ -98852,8 +99048,8 @@ async function whatsappBusiness({
|
|
|
98852
99048
|
}
|
|
98853
99049
|
|
|
98854
99050
|
// src/services/whatsapp-commands.service.ts
|
|
98855
|
-
import { writeFile as
|
|
98856
|
-
import { basename as
|
|
99051
|
+
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
99052
|
+
import { basename as basename11, resolve as resolve25 } from "node:path";
|
|
98857
99053
|
|
|
98858
99054
|
// src/services/whatsapp-pairing-commands.service.ts
|
|
98859
99055
|
var WHATSAPP_PAIRING_USAGE = " laze whatsapp unpair <machine> unlink WhatsApp from the machine (owner)";
|
|
@@ -98879,7 +99075,8 @@ var PATHS3 = {
|
|
|
98879
99075
|
read: "/api/compute/whatsapp/read",
|
|
98880
99076
|
file: "/api/compute/whatsapp/file",
|
|
98881
99077
|
send: "/api/compute/whatsapp/send",
|
|
98882
|
-
sendStatus: "/api/compute/whatsapp/send-status"
|
|
99078
|
+
sendStatus: "/api/compute/whatsapp/send-status",
|
|
99079
|
+
sync: "/api/compute/whatsapp/sync"
|
|
98883
99080
|
};
|
|
98884
99081
|
var STATUS_WAIT_SECONDS2 = 50;
|
|
98885
99082
|
var STATUS_CALLS2 = 2;
|
|
@@ -98892,6 +99089,7 @@ var USAGE19 = [
|
|
|
98892
99089
|
" laze whatsapp file [<machine>] <chat> <message-id> [--out <path>] save a message's photo, voice message or file",
|
|
98893
99090
|
' laze whatsapp send <machine> <chat> "<text>" send as the owner; an agent waits for their approval',
|
|
98894
99091
|
" laze whatsapp status <send-id> where a send stands",
|
|
99092
|
+
" laze whatsapp sync [<machine>] check WhatsApp now (the owner only)",
|
|
98895
99093
|
WHATSAPP_PAIRING_USAGE,
|
|
98896
99094
|
"With no machine it is the WhatsApp linked on your (or your agent's owner's) Laze computer.",
|
|
98897
99095
|
"A chat is its id, a phone number or a contact or group name."
|
|
@@ -98991,10 +99189,10 @@ async function file3({ context, args }) {
|
|
|
98991
99189
|
},
|
|
98992
99190
|
args
|
|
98993
99191
|
});
|
|
98994
|
-
const out =
|
|
99192
|
+
const out = resolve25(context.cwd, flagText({ args, name: "out" }) ?? basename11(answer6.fileName));
|
|
98995
99193
|
const response = await context.fetcher(answer6.url);
|
|
98996
99194
|
if (!response.ok) throw new Error(`The file link answered ${response.status}`);
|
|
98997
|
-
await
|
|
99195
|
+
await writeFile10(out, new Uint8Array(await response.arrayBuffer()));
|
|
98998
99196
|
if (args.flags.json) return context.out(`${JSON.stringify({ ...answer6, path: out }, null, 2)}
|
|
98999
99197
|
`);
|
|
99000
99198
|
context.out(`${out}
|
|
@@ -99038,6 +99236,14 @@ async function send4({ context, args }) {
|
|
|
99038
99236
|
`);
|
|
99039
99237
|
return report2({ context, args, send: await settle3({ client, send: asked }) });
|
|
99040
99238
|
}
|
|
99239
|
+
async function sync({ context, args }) {
|
|
99240
|
+
const client = await computeClient({ context, args });
|
|
99241
|
+
const machine2 = args.words[2];
|
|
99242
|
+
const answer6 = await client.post(PATHS3.sync, machine2 ? { machine: machine2 } : {});
|
|
99243
|
+
if (args.flags.json) context.out(`${JSON.stringify(answer6)}
|
|
99244
|
+
`);
|
|
99245
|
+
else context.out("WhatsApp check booked: new messages land in Laze within a minute or two.\n");
|
|
99246
|
+
}
|
|
99041
99247
|
async function status10({ context, args }) {
|
|
99042
99248
|
const client = await computeClient({ context, args });
|
|
99043
99249
|
const answer6 = await client.post(PATHS3.sendStatus, { sendId: word2({ args, at: 2 }) });
|
|
@@ -99056,6 +99262,7 @@ async function whatsapp({
|
|
|
99056
99262
|
if (command === "file") return file3({ context, args });
|
|
99057
99263
|
if (command === "send") return send4({ context, args });
|
|
99058
99264
|
if (command === "status") return status10({ context, args });
|
|
99265
|
+
if (command === "sync") return sync({ context, args });
|
|
99059
99266
|
const linking = whatsappPairingCommand(command);
|
|
99060
99267
|
if (linking) return linking({ context, args });
|
|
99061
99268
|
throw new CliUsageError(USAGE19);
|
|
@@ -99797,18 +100004,18 @@ import {
|
|
|
99797
100004
|
createHash as createHash8,
|
|
99798
100005
|
createPrivateKey,
|
|
99799
100006
|
generateKeyPairSync,
|
|
99800
|
-
randomBytes as
|
|
100007
|
+
randomBytes as randomBytes5,
|
|
99801
100008
|
sign
|
|
99802
100009
|
} from "node:crypto";
|
|
99803
|
-
import { chmod
|
|
99804
|
-
import { dirname as
|
|
100010
|
+
import { chmod, link, mkdir as mkdir12, readFile as readFile36, rm as rm20, writeFile as writeFile11 } from "node:fs/promises";
|
|
100011
|
+
import { dirname as dirname24, join as join34 } from "node:path";
|
|
99805
100012
|
var KEYCHAIN_SERVICE = "laze-cli-machine-key";
|
|
99806
|
-
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((
|
|
100013
|
+
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((resolve26, reject) => {
|
|
99807
100014
|
const child = execFile2(
|
|
99808
100015
|
program,
|
|
99809
100016
|
[...args],
|
|
99810
100017
|
{ timeout: timeoutMs },
|
|
99811
|
-
(error63, stdout2) => error63 ? reject(error63) :
|
|
100018
|
+
(error63, stdout2) => error63 ? reject(error63) : resolve26(String(stdout2))
|
|
99812
100019
|
);
|
|
99813
100020
|
if (stdin2 !== void 0) child.stdin?.end(stdin2);
|
|
99814
100021
|
});
|
|
@@ -99841,11 +100048,11 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
99841
100048
|
});
|
|
99842
100049
|
}
|
|
99843
100050
|
get metaPath() {
|
|
99844
|
-
return
|
|
100051
|
+
return join34(dirname24(this.options.configPath), "machine-key.json");
|
|
99845
100052
|
}
|
|
99846
100053
|
/** Named by the key, so two CLIs making a key at once never overwrite each other's. */
|
|
99847
100054
|
pemPathOf(jwk) {
|
|
99848
|
-
return
|
|
100055
|
+
return join34(dirname24(this.options.configPath), `machine-key-${shortOf(jwk)}.pem`);
|
|
99849
100056
|
}
|
|
99850
100057
|
/** The Keychain item's account: one per config file and key. */
|
|
99851
100058
|
accountOf(jwk) {
|
|
@@ -99873,7 +100080,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
99873
100080
|
async read() {
|
|
99874
100081
|
let meta3;
|
|
99875
100082
|
try {
|
|
99876
|
-
meta3 = machineKeyRegistrationSchema.parse(JSON.parse(await
|
|
100083
|
+
meta3 = machineKeyRegistrationSchema.parse(JSON.parse(await readFile36(this.metaPath, "utf8")));
|
|
99877
100084
|
} catch {
|
|
99878
100085
|
return null;
|
|
99879
100086
|
}
|
|
@@ -99888,7 +100095,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
99888
100095
|
"-w"
|
|
99889
100096
|
],
|
|
99890
100097
|
timeoutMs: 1e4
|
|
99891
|
-
}) : await
|
|
100098
|
+
}) : await readFile36(this.pemPathOf(meta3.jwk), "utf8");
|
|
99892
100099
|
return keyOf2({ meta: meta3, privateKey: createPrivateKey(pemOf(pem)) });
|
|
99893
100100
|
}
|
|
99894
100101
|
async make() {
|
|
@@ -99912,7 +100119,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
99912
100119
|
return kept;
|
|
99913
100120
|
}
|
|
99914
100121
|
async drop({ tier, jwk }) {
|
|
99915
|
-
if (tier === "file") return
|
|
100122
|
+
if (tier === "file") return rm20(this.pemPathOf(jwk), { force: true });
|
|
99916
100123
|
await this.options.run({
|
|
99917
100124
|
program: "security",
|
|
99918
100125
|
args: ["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", this.accountOf(jwk)],
|
|
@@ -99959,7 +100166,7 @@ function keyOf2({ meta: meta3, privateKey }) {
|
|
|
99959
100166
|
}
|
|
99960
100167
|
var shortOf = (jwk) => thumbprintOf({ jwk }).slice(0, 12);
|
|
99961
100168
|
async function writeOnce({ path, text: text3 }) {
|
|
99962
|
-
const temporary = `${path}.${process.pid}.${
|
|
100169
|
+
const temporary = `${path}.${process.pid}.${randomBytes5(6).toString("hex")}.tmp`;
|
|
99963
100170
|
await writePrivate({ path: temporary, text: text3 });
|
|
99964
100171
|
try {
|
|
99965
100172
|
await link(temporary, path);
|
|
@@ -99968,13 +100175,13 @@ async function writeOnce({ path, text: text3 }) {
|
|
|
99968
100175
|
if (error63.code === "EEXIST") return false;
|
|
99969
100176
|
throw error63;
|
|
99970
100177
|
} finally {
|
|
99971
|
-
await
|
|
100178
|
+
await rm20(temporary, { force: true });
|
|
99972
100179
|
}
|
|
99973
100180
|
}
|
|
99974
100181
|
async function writePrivate({ path, text: text3 }) {
|
|
99975
|
-
await
|
|
99976
|
-
await
|
|
99977
|
-
await
|
|
100182
|
+
await mkdir12(dirname24(path), { recursive: true, mode: 448 });
|
|
100183
|
+
await writeFile11(path, text3, { mode: 384 });
|
|
100184
|
+
await chmod(path, 384);
|
|
99978
100185
|
}
|
|
99979
100186
|
|
|
99980
100187
|
// src/services/machine-proof-fetch.service.ts
|
|
@@ -99996,7 +100203,7 @@ function machineProofFetch({
|
|
|
99996
100203
|
fetcher,
|
|
99997
100204
|
store,
|
|
99998
100205
|
keys: keys2,
|
|
99999
|
-
nowMs,
|
|
100206
|
+
nowMs: nowMs2,
|
|
100000
100207
|
warn
|
|
100001
100208
|
}) {
|
|
100002
100209
|
const warned = /* @__PURE__ */ new Set();
|
|
@@ -100012,7 +100219,7 @@ function machineProofFetch({
|
|
|
100012
100219
|
method: init?.method ?? "GET",
|
|
100013
100220
|
url: input2,
|
|
100014
100221
|
credential: token2,
|
|
100015
|
-
nowMs:
|
|
100222
|
+
nowMs: nowMs2(),
|
|
100016
100223
|
tailscaleNodeId: key.tailscale?.nodeId ?? null
|
|
100017
100224
|
});
|
|
100018
100225
|
}
|
|
@@ -100030,8 +100237,8 @@ function machineProofFetch({
|
|
|
100030
100237
|
// src/services/processes.service.ts
|
|
100031
100238
|
import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
100032
100239
|
import { mkdirSync, openSync } from "node:fs";
|
|
100033
|
-
import { readFile as
|
|
100034
|
-
import { dirname as
|
|
100240
|
+
import { readFile as readFile37, readlink } from "node:fs/promises";
|
|
100241
|
+
import { dirname as dirname25 } from "node:path";
|
|
100035
100242
|
import { promisify as promisify2 } from "node:util";
|
|
100036
100243
|
var run3 = promisify2(execFile3);
|
|
100037
100244
|
function alive(pid) {
|
|
@@ -100044,15 +100251,15 @@ function alive(pid) {
|
|
|
100044
100251
|
}
|
|
100045
100252
|
}
|
|
100046
100253
|
async function argsOf2(pid) {
|
|
100047
|
-
const raw = await
|
|
100254
|
+
const raw = await readFile37(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
|
|
100048
100255
|
if (raw) return raw.split("\0").filter(Boolean);
|
|
100049
100256
|
const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
|
|
100050
100257
|
const line = listed?.stdout.trim();
|
|
100051
100258
|
return line ? line.split(/\s+/) : void 0;
|
|
100052
100259
|
}
|
|
100053
100260
|
async function parentOf(pid) {
|
|
100054
|
-
const
|
|
100055
|
-
const fromStat =
|
|
100261
|
+
const stat13 = await readFile37(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
100262
|
+
const fromStat = stat13 ? Number(stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
|
|
100056
100263
|
if (fromStat > 0) return fromStat;
|
|
100057
100264
|
const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
|
|
100058
100265
|
const parent = Number(listed?.stdout.trim());
|
|
@@ -100068,7 +100275,7 @@ async function cwdOf(pid) {
|
|
|
100068
100275
|
return line ? line.slice(1) : void 0;
|
|
100069
100276
|
}
|
|
100070
100277
|
function spawnDetached({ argv, logPath }) {
|
|
100071
|
-
mkdirSync(
|
|
100278
|
+
mkdirSync(dirname25(logPath), { recursive: true, mode: 448 });
|
|
100072
100279
|
const log = openSync(logPath, "a", 384);
|
|
100073
100280
|
const [program = "", ...rest] = argv;
|
|
100074
100281
|
const child = spawn4(program, rest, { detached: true, stdio: ["ignore", log, log] });
|
|
@@ -100164,15 +100371,15 @@ function terminalAsk() {
|
|
|
100164
100371
|
};
|
|
100165
100372
|
}
|
|
100166
100373
|
function sleep(ms, signal) {
|
|
100167
|
-
return new Promise((
|
|
100168
|
-
if (signal?.aborted) return
|
|
100374
|
+
return new Promise((resolve26) => {
|
|
100375
|
+
if (signal?.aborted) return resolve26();
|
|
100169
100376
|
const stop3 = () => {
|
|
100170
100377
|
clearTimeout(timer);
|
|
100171
|
-
|
|
100378
|
+
resolve26();
|
|
100172
100379
|
};
|
|
100173
100380
|
const timer = setTimeout(() => {
|
|
100174
100381
|
signal?.removeEventListener("abort", stop3);
|
|
100175
|
-
|
|
100382
|
+
resolve26();
|
|
100176
100383
|
}, ms);
|
|
100177
100384
|
signal?.addEventListener("abort", stop3, { once: true });
|
|
100178
100385
|
});
|
|
@@ -100190,7 +100397,7 @@ if (true) {
|
|
|
100190
100397
|
configPath: environment.configPath,
|
|
100191
100398
|
tier: environment.machineKeyTier
|
|
100192
100399
|
});
|
|
100193
|
-
const
|
|
100400
|
+
const nowMs2 = () => nowInstant().epochMilliseconds;
|
|
100194
100401
|
process.exitCode = await runCli({
|
|
100195
100402
|
argv: process.argv.slice(2),
|
|
100196
100403
|
context: {
|
|
@@ -100203,7 +100410,7 @@ if (true) {
|
|
|
100203
100410
|
fetcher: proxiedFetch(environment.inherited),
|
|
100204
100411
|
store,
|
|
100205
100412
|
keys: machineKeys,
|
|
100206
|
-
nowMs,
|
|
100413
|
+
nowMs: nowMs2,
|
|
100207
100414
|
warn: (text3) => void process.stderr.write(text3)
|
|
100208
100415
|
}),
|
|
100209
100416
|
out: (text3) => void process.stdout.write(text3),
|
|
@@ -100212,7 +100419,7 @@ if (true) {
|
|
|
100212
100419
|
stdoutIsTerminal: process.stdout.isTTY === true,
|
|
100213
100420
|
...ask ? { ask } : {},
|
|
100214
100421
|
sleep,
|
|
100215
|
-
nowMs,
|
|
100422
|
+
nowMs: nowMs2,
|
|
100216
100423
|
processes: nodeProcesses(),
|
|
100217
100424
|
runCommand: (input2) => runCommand({ ...input2, inherited: environment.inherited })
|
|
100218
100425
|
}
|