@lazehq/cli 0.1.10 → 0.1.11
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 +1183 -287
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -91,14 +91,14 @@ var require_node_gyp_build = __commonJS({
|
|
|
91
91
|
} catch (err) {
|
|
92
92
|
}
|
|
93
93
|
if (!prebuildsOnly) {
|
|
94
|
-
var
|
|
95
|
-
if (
|
|
94
|
+
var release2 = getFirst(path.join(dir, "build/Release"), matchBuild);
|
|
95
|
+
if (release2) return release2;
|
|
96
96
|
var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
|
|
97
97
|
if (debug) return debug;
|
|
98
98
|
}
|
|
99
|
-
var prebuild =
|
|
99
|
+
var prebuild = resolve16(dir);
|
|
100
100
|
if (prebuild) return prebuild;
|
|
101
|
-
var nearby =
|
|
101
|
+
var nearby = resolve16(path.dirname(process.execPath));
|
|
102
102
|
if (nearby) return nearby;
|
|
103
103
|
var target = [
|
|
104
104
|
"platform=" + platform,
|
|
@@ -114,7 +114,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
114
114
|
// eslint-disable-line
|
|
115
115
|
].filter(Boolean).join(" ");
|
|
116
116
|
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
117
|
-
function
|
|
117
|
+
function resolve16(dir2) {
|
|
118
118
|
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
119
119
|
var tuple2 = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
120
120
|
if (!tuple2) return;
|
|
@@ -6561,9 +6561,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
6561
6561
|
}
|
|
6562
6562
|
close(callback) {
|
|
6563
6563
|
if (callback === void 0) {
|
|
6564
|
-
return new Promise((
|
|
6564
|
+
return new Promise((resolve16, reject) => {
|
|
6565
6565
|
this.close((err, data) => {
|
|
6566
|
-
return err ? reject(err) :
|
|
6566
|
+
return err ? reject(err) : resolve16(data);
|
|
6567
6567
|
});
|
|
6568
6568
|
});
|
|
6569
6569
|
}
|
|
@@ -6601,9 +6601,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
6601
6601
|
err = null;
|
|
6602
6602
|
}
|
|
6603
6603
|
if (callback === void 0) {
|
|
6604
|
-
return new Promise((
|
|
6604
|
+
return new Promise((resolve16, reject) => {
|
|
6605
6605
|
this.destroy(err, (err2, data) => {
|
|
6606
|
-
return err2 ? reject(err2) :
|
|
6606
|
+
return err2 ? reject(err2) : resolve16(data);
|
|
6607
6607
|
});
|
|
6608
6608
|
});
|
|
6609
6609
|
}
|
|
@@ -11558,12 +11558,12 @@ upgrade: ${upgrade2}\r
|
|
|
11558
11558
|
cb();
|
|
11559
11559
|
}
|
|
11560
11560
|
}
|
|
11561
|
-
const waitForDrain = () => new Promise((
|
|
11561
|
+
const waitForDrain = () => new Promise((resolve16, reject) => {
|
|
11562
11562
|
assert2(callback === null);
|
|
11563
11563
|
if (socket[kError]) {
|
|
11564
11564
|
reject(socket[kError]);
|
|
11565
11565
|
} else {
|
|
11566
|
-
callback =
|
|
11566
|
+
callback = resolve16;
|
|
11567
11567
|
}
|
|
11568
11568
|
});
|
|
11569
11569
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -12921,12 +12921,12 @@ var require_client_h2 = __commonJS({
|
|
|
12921
12921
|
cb();
|
|
12922
12922
|
}
|
|
12923
12923
|
}
|
|
12924
|
-
const waitForDrain = () => new Promise((
|
|
12924
|
+
const waitForDrain = () => new Promise((resolve16, reject) => {
|
|
12925
12925
|
assert2(callback === null);
|
|
12926
12926
|
if (socket[kError]) {
|
|
12927
12927
|
reject(socket[kError]);
|
|
12928
12928
|
} else {
|
|
12929
|
-
callback =
|
|
12929
|
+
callback = resolve16;
|
|
12930
12930
|
}
|
|
12931
12931
|
});
|
|
12932
12932
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -13294,16 +13294,16 @@ var require_client = __commonJS({
|
|
|
13294
13294
|
return this[kNeedDrain] < 2;
|
|
13295
13295
|
}
|
|
13296
13296
|
[kClose]() {
|
|
13297
|
-
return new Promise((
|
|
13297
|
+
return new Promise((resolve16) => {
|
|
13298
13298
|
if (this[kSize]) {
|
|
13299
|
-
this[kClosedResolve] =
|
|
13299
|
+
this[kClosedResolve] = resolve16;
|
|
13300
13300
|
} else {
|
|
13301
|
-
|
|
13301
|
+
resolve16(null);
|
|
13302
13302
|
}
|
|
13303
13303
|
});
|
|
13304
13304
|
}
|
|
13305
13305
|
[kDestroy](err) {
|
|
13306
|
-
return new Promise((
|
|
13306
|
+
return new Promise((resolve16) => {
|
|
13307
13307
|
const requests2 = this[kQueue].splice(this[kPendingIdx]);
|
|
13308
13308
|
for (let i = 0; i < requests2.length; i++) {
|
|
13309
13309
|
const request2 = requests2[i];
|
|
@@ -13316,7 +13316,7 @@ var require_client = __commonJS({
|
|
|
13316
13316
|
this[kClosedResolve]();
|
|
13317
13317
|
this[kClosedResolve] = null;
|
|
13318
13318
|
}
|
|
13319
|
-
|
|
13319
|
+
resolve16(null);
|
|
13320
13320
|
};
|
|
13321
13321
|
if (this[kHTTPContext]) {
|
|
13322
13322
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -13729,8 +13729,8 @@ var require_pool_base = __commonJS({
|
|
|
13729
13729
|
}
|
|
13730
13730
|
return Promise.all(closeAll);
|
|
13731
13731
|
} else {
|
|
13732
|
-
return new Promise((
|
|
13733
|
-
this[kClosedResolve] =
|
|
13732
|
+
return new Promise((resolve16) => {
|
|
13733
|
+
this[kClosedResolve] = resolve16;
|
|
13734
13734
|
});
|
|
13735
13735
|
}
|
|
13736
13736
|
}
|
|
@@ -16241,7 +16241,7 @@ var require_readable = __commonJS({
|
|
|
16241
16241
|
if (this._readableState.closeEmitted) {
|
|
16242
16242
|
return Promise.resolve(null);
|
|
16243
16243
|
}
|
|
16244
|
-
return new Promise((
|
|
16244
|
+
return new Promise((resolve16, reject) => {
|
|
16245
16245
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
16246
16246
|
this.destroy(new AbortError());
|
|
16247
16247
|
}
|
|
@@ -16255,11 +16255,11 @@ var require_readable = __commonJS({
|
|
|
16255
16255
|
if (signal.aborted) {
|
|
16256
16256
|
reject(signal.reason ?? new AbortError());
|
|
16257
16257
|
} else {
|
|
16258
|
-
|
|
16258
|
+
resolve16(null);
|
|
16259
16259
|
}
|
|
16260
16260
|
});
|
|
16261
16261
|
} else {
|
|
16262
|
-
this.on("close",
|
|
16262
|
+
this.on("close", resolve16);
|
|
16263
16263
|
}
|
|
16264
16264
|
this.on("error", noop2).on("data", () => {
|
|
16265
16265
|
if (this[kBytesRead] > limit) {
|
|
@@ -16287,7 +16287,7 @@ var require_readable = __commonJS({
|
|
|
16287
16287
|
}
|
|
16288
16288
|
function consume(stream, type) {
|
|
16289
16289
|
assert2(!stream[kConsume]);
|
|
16290
|
-
return new Promise((
|
|
16290
|
+
return new Promise((resolve16, reject) => {
|
|
16291
16291
|
if (isUnusable(stream)) {
|
|
16292
16292
|
const rState = stream._readableState;
|
|
16293
16293
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -16302,7 +16302,7 @@ var require_readable = __commonJS({
|
|
|
16302
16302
|
stream[kConsume] = {
|
|
16303
16303
|
type,
|
|
16304
16304
|
stream,
|
|
16305
|
-
resolve:
|
|
16305
|
+
resolve: resolve16,
|
|
16306
16306
|
reject,
|
|
16307
16307
|
length: 0,
|
|
16308
16308
|
body: []
|
|
@@ -16380,18 +16380,18 @@ var require_readable = __commonJS({
|
|
|
16380
16380
|
return buffer;
|
|
16381
16381
|
}
|
|
16382
16382
|
function consumeEnd(consume2, encoding) {
|
|
16383
|
-
const { type, body, resolve:
|
|
16383
|
+
const { type, body, resolve: resolve16, stream, length } = consume2;
|
|
16384
16384
|
try {
|
|
16385
16385
|
if (type === "text") {
|
|
16386
|
-
|
|
16386
|
+
resolve16(chunksDecode(body, length, encoding));
|
|
16387
16387
|
} else if (type === "json") {
|
|
16388
|
-
|
|
16388
|
+
resolve16(JSON.parse(chunksDecode(body, length, encoding)));
|
|
16389
16389
|
} else if (type === "arrayBuffer") {
|
|
16390
|
-
|
|
16390
|
+
resolve16(chunksConcat(body, length).buffer);
|
|
16391
16391
|
} else if (type === "blob") {
|
|
16392
|
-
|
|
16392
|
+
resolve16(new Blob(body, { type: stream[kContentType] }));
|
|
16393
16393
|
} else if (type === "bytes") {
|
|
16394
|
-
|
|
16394
|
+
resolve16(chunksConcat(body, length));
|
|
16395
16395
|
}
|
|
16396
16396
|
consumeFinish(consume2);
|
|
16397
16397
|
} catch (err) {
|
|
@@ -16610,9 +16610,9 @@ var require_api_request = __commonJS({
|
|
|
16610
16610
|
};
|
|
16611
16611
|
function request2(opts, callback) {
|
|
16612
16612
|
if (callback === void 0) {
|
|
16613
|
-
return new Promise((
|
|
16613
|
+
return new Promise((resolve16, reject) => {
|
|
16614
16614
|
request2.call(this, opts, (err, data) => {
|
|
16615
|
-
return err ? reject(err) :
|
|
16615
|
+
return err ? reject(err) : resolve16(data);
|
|
16616
16616
|
});
|
|
16617
16617
|
});
|
|
16618
16618
|
}
|
|
@@ -16873,9 +16873,9 @@ var require_api_stream = __commonJS({
|
|
|
16873
16873
|
};
|
|
16874
16874
|
function stream(opts, factory, callback) {
|
|
16875
16875
|
if (callback === void 0) {
|
|
16876
|
-
return new Promise((
|
|
16876
|
+
return new Promise((resolve16, reject) => {
|
|
16877
16877
|
stream.call(this, opts, factory, (err, data) => {
|
|
16878
|
-
return err ? reject(err) :
|
|
16878
|
+
return err ? reject(err) : resolve16(data);
|
|
16879
16879
|
});
|
|
16880
16880
|
});
|
|
16881
16881
|
}
|
|
@@ -17175,9 +17175,9 @@ var require_api_upgrade = __commonJS({
|
|
|
17175
17175
|
};
|
|
17176
17176
|
function upgrade2(opts, callback) {
|
|
17177
17177
|
if (callback === void 0) {
|
|
17178
|
-
return new Promise((
|
|
17178
|
+
return new Promise((resolve16, reject) => {
|
|
17179
17179
|
upgrade2.call(this, opts, (err, data) => {
|
|
17180
|
-
return err ? reject(err) :
|
|
17180
|
+
return err ? reject(err) : resolve16(data);
|
|
17181
17181
|
});
|
|
17182
17182
|
});
|
|
17183
17183
|
}
|
|
@@ -17271,9 +17271,9 @@ var require_api_connect = __commonJS({
|
|
|
17271
17271
|
};
|
|
17272
17272
|
function connect6(opts, callback) {
|
|
17273
17273
|
if (callback === void 0) {
|
|
17274
|
-
return new Promise((
|
|
17274
|
+
return new Promise((resolve16, reject) => {
|
|
17275
17275
|
connect6.call(this, opts, (err, data) => {
|
|
17276
|
-
return err ? reject(err) :
|
|
17276
|
+
return err ? reject(err) : resolve16(data);
|
|
17277
17277
|
});
|
|
17278
17278
|
});
|
|
17279
17279
|
}
|
|
@@ -18733,8 +18733,8 @@ var require_snapshot_utils = __commonJS({
|
|
|
18733
18733
|
var require_snapshot_recorder = __commonJS({
|
|
18734
18734
|
"../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
18735
18735
|
"use strict";
|
|
18736
|
-
var { writeFile:
|
|
18737
|
-
var { dirname:
|
|
18736
|
+
var { writeFile: writeFile16, readFile: readFile29, mkdir: mkdir14 } = __require("node:fs/promises");
|
|
18737
|
+
var { dirname: dirname14, resolve: resolve16 } = __require("node:path");
|
|
18738
18738
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
18739
18739
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
18740
18740
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -18950,7 +18950,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
18950
18950
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
18951
18951
|
}
|
|
18952
18952
|
try {
|
|
18953
|
-
const data = await
|
|
18953
|
+
const data = await readFile29(resolve16(path), "utf8");
|
|
18954
18954
|
const parsed = JSON.parse(data);
|
|
18955
18955
|
if (Array.isArray(parsed)) {
|
|
18956
18956
|
this.#snapshots.clear();
|
|
@@ -18979,13 +18979,13 @@ var require_snapshot_recorder = __commonJS({
|
|
|
18979
18979
|
if (!path) {
|
|
18980
18980
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
18981
18981
|
}
|
|
18982
|
-
const resolvedPath =
|
|
18983
|
-
await
|
|
18982
|
+
const resolvedPath = resolve16(path);
|
|
18983
|
+
await mkdir14(dirname14(resolvedPath), { recursive: true });
|
|
18984
18984
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
18985
18985
|
hash: hash2,
|
|
18986
18986
|
snapshot
|
|
18987
18987
|
}));
|
|
18988
|
-
await
|
|
18988
|
+
await writeFile16(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
|
|
18989
18989
|
}
|
|
18990
18990
|
/**
|
|
18991
18991
|
* Clears all recorded snapshots
|
|
@@ -26477,7 +26477,7 @@ var require_fetch = __commonJS({
|
|
|
26477
26477
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
26478
26478
|
return dispatchWithProtocolPreference(body);
|
|
26479
26479
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
26480
|
-
return new Promise((
|
|
26480
|
+
return new Promise((resolve16, reject) => agent2.dispatch(
|
|
26481
26481
|
{
|
|
26482
26482
|
path: hasTrailingQuestionMark ? `${path}?` : path,
|
|
26483
26483
|
origin: url2.origin,
|
|
@@ -26560,7 +26560,7 @@ var require_fetch = __commonJS({
|
|
|
26560
26560
|
}
|
|
26561
26561
|
}
|
|
26562
26562
|
const onError = (err) => this.onResponseError(controller, err);
|
|
26563
|
-
|
|
26563
|
+
resolve16({
|
|
26564
26564
|
status: status7,
|
|
26565
26565
|
statusText,
|
|
26566
26566
|
headersList,
|
|
@@ -26593,7 +26593,7 @@ var require_fetch = __commonJS({
|
|
|
26593
26593
|
fetchParams.controller.off("terminated", this.abort);
|
|
26594
26594
|
}
|
|
26595
26595
|
if (request2.mode === "websocket" && allowH2 !== false && error62?.code === "UND_ERR_INFO" && error62?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
26596
|
-
|
|
26596
|
+
resolve16(dispatchWithProtocolPreference(body2, false));
|
|
26597
26597
|
return;
|
|
26598
26598
|
}
|
|
26599
26599
|
this.body?.destroy(error62);
|
|
@@ -26607,7 +26607,7 @@ var require_fetch = __commonJS({
|
|
|
26607
26607
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
26608
26608
|
const headersList = new HeadersList();
|
|
26609
26609
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
26610
|
-
|
|
26610
|
+
resolve16({
|
|
26611
26611
|
status: status7,
|
|
26612
26612
|
statusText: STATUS_CODES[status7],
|
|
26613
26613
|
headersList,
|
|
@@ -31500,7 +31500,7 @@ function runRedacted({
|
|
|
31500
31500
|
cwd
|
|
31501
31501
|
}) {
|
|
31502
31502
|
const values = Object.values(env);
|
|
31503
|
-
return new Promise((
|
|
31503
|
+
return new Promise((resolve16, reject) => {
|
|
31504
31504
|
const [file3, ...args] = command;
|
|
31505
31505
|
const child = spawn(file3, args, {
|
|
31506
31506
|
env: { ...baseEnv, ...env },
|
|
@@ -31521,7 +31521,7 @@ function runRedacted({
|
|
|
31521
31521
|
const drained = Promise.all([pipe2(child.stdout, stdout2), pipe2(child.stderr, stderr2)]);
|
|
31522
31522
|
child.on("error", reject);
|
|
31523
31523
|
child.on("close", (code, signal) => {
|
|
31524
|
-
void drained.then(() =>
|
|
31524
|
+
void drained.then(() => resolve16(code ?? (signal ? 128 + signalNumber(signal) : 1)));
|
|
31525
31525
|
});
|
|
31526
31526
|
});
|
|
31527
31527
|
}
|
|
@@ -35575,7 +35575,7 @@ function flagText({
|
|
|
35575
35575
|
}
|
|
35576
35576
|
|
|
35577
35577
|
// src/rules/cli-version.rules.ts
|
|
35578
|
-
var STAMPED = "0.1.
|
|
35578
|
+
var STAMPED = "0.1.11";
|
|
35579
35579
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
35580
35580
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
35581
35581
|
}
|
|
@@ -40614,7 +40614,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
40614
40614
|
var NONE = 0;
|
|
40615
40615
|
var ASSUMED = 1;
|
|
40616
40616
|
var PROVEN = 2;
|
|
40617
|
-
function isRecursive(inst, stack,
|
|
40617
|
+
function isRecursive(inst, stack, resolve16) {
|
|
40618
40618
|
const cached2 = recursive.get(inst);
|
|
40619
40619
|
if (cached2 !== void 0)
|
|
40620
40620
|
return cached2 ? PROVEN : NONE;
|
|
@@ -40624,7 +40624,7 @@ function isRecursive(inst, stack, resolve15) {
|
|
|
40624
40624
|
let result = NONE;
|
|
40625
40625
|
const check3 = (child) => {
|
|
40626
40626
|
if (result !== PROVEN && child?._zod) {
|
|
40627
|
-
const answer4 = isRecursive(child, stack,
|
|
40627
|
+
const answer4 = isRecursive(child, stack, resolve16);
|
|
40628
40628
|
if (answer4 > result)
|
|
40629
40629
|
result = answer4;
|
|
40630
40630
|
}
|
|
@@ -40635,7 +40635,7 @@ function isRecursive(inst, stack, resolve15) {
|
|
|
40635
40635
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
40636
40636
|
if (spread && !desc.enumerable)
|
|
40637
40637
|
continue;
|
|
40638
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
40638
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve16) : NONE;
|
|
40639
40639
|
if (child > answer4)
|
|
40640
40640
|
answer4 = child;
|
|
40641
40641
|
}
|
|
@@ -40699,7 +40699,7 @@ function isRecursive(inst, stack, resolve15) {
|
|
|
40699
40699
|
break;
|
|
40700
40700
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
40701
40701
|
case "lazy": {
|
|
40702
|
-
const inner = def._cachedInner ?? (
|
|
40702
|
+
const inner = def._cachedInner ?? (resolve16 ? inst._zod.innerType : void 0);
|
|
40703
40703
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
40704
40704
|
break;
|
|
40705
40705
|
}
|
|
@@ -59824,6 +59824,12 @@ var NotificationPauseHooksToken = notificationUi.hooks("pause");
|
|
|
59824
59824
|
var NotificationPauseDialogSlot = notificationUi.component("pause-dialog");
|
|
59825
59825
|
|
|
59826
59826
|
// ../../modules/chat/contract/src/chat.events.ts
|
|
59827
|
+
var personErasedPayloadSchemaDefinition = external_exports.object({
|
|
59828
|
+
workspaceId: external_exports.string().min(1),
|
|
59829
|
+
channelId: external_exports.string().min(1),
|
|
59830
|
+
userId: external_exports.string().min(1),
|
|
59831
|
+
at: external_exports.iso.datetime()
|
|
59832
|
+
});
|
|
59827
59833
|
var reminderSetPayloadSchemaDefinition = external_exports.object({
|
|
59828
59834
|
workspaceId: external_exports.string().min(1),
|
|
59829
59835
|
userId: external_exports.string().min(1),
|
|
@@ -65040,7 +65046,7 @@ async function signedIn({
|
|
|
65040
65046
|
if (chosen.profile.kind === "agent") await namingFirst({ client, args });
|
|
65041
65047
|
return { name: chosen.name, profile: chosen.profile, client };
|
|
65042
65048
|
}
|
|
65043
|
-
var ALWAYS_FREE = ["hook", "adopt", "mcp", "login", "logout", "update", "agent link"];
|
|
65049
|
+
var ALWAYS_FREE = ["hook", "adopt", "mcp", "plugin", "login", "logout", "update", "agent link"];
|
|
65044
65050
|
async function namingFirst({ client, args }) {
|
|
65045
65051
|
const [first = "", second = ""] = args.words;
|
|
65046
65052
|
const free = [...NAMING_FREE_CLI_COMMANDS, ...ALWAYS_FREE];
|
|
@@ -65228,8 +65234,8 @@ async function copyAgent({
|
|
|
65228
65234
|
}
|
|
65229
65235
|
|
|
65230
65236
|
// src/services/agent-commands.service.ts
|
|
65231
|
-
import { mkdir as
|
|
65232
|
-
import { join as
|
|
65237
|
+
import { mkdir as mkdir7, readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
65238
|
+
import { join as join6, resolve as resolve3 } from "node:path";
|
|
65233
65239
|
|
|
65234
65240
|
// src/rules/agent-profile.rules.ts
|
|
65235
65241
|
var LEVELS = { fast: "Laze Fast", frontier: "Laze Frontier" };
|
|
@@ -65383,8 +65389,8 @@ function hookCommand({
|
|
|
65383
65389
|
profile,
|
|
65384
65390
|
hook
|
|
65385
65391
|
}) {
|
|
65386
|
-
const
|
|
65387
|
-
const words = [...program, "hook", hook, "--profile", profile].map(
|
|
65392
|
+
const quote4 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
65393
|
+
const words = [...program, "hook", hook, "--profile", profile].map(quote4).join(" ");
|
|
65388
65394
|
return `${words} # ${LAZE_HOOK_MARKER}`;
|
|
65389
65395
|
}
|
|
65390
65396
|
function lacksSessionStartWaiter({ settings: settings2 }) {
|
|
@@ -66588,8 +66594,8 @@ var UTC_ZONES = /^(Etc\/)?(UTC|UCT|GMT|Zulu|Universal)$/i;
|
|
|
66588
66594
|
function zonedTimeOf({ iso, timeZone }) {
|
|
66589
66595
|
if (UTC_ZONES.test(timeZone)) return utcTimeOf(iso);
|
|
66590
66596
|
const zoned = Temporal3.Instant.from(iso).toZonedDateTimeISO(timeZone);
|
|
66591
|
-
const
|
|
66592
|
-
return `${
|
|
66597
|
+
const local2 = zoned.toPlainDateTime().toString({ smallestUnit: "minute" }).replace("T", " ");
|
|
66598
|
+
return `${local2} ${timeZone} (${utcTimeOf(iso)})`;
|
|
66593
66599
|
}
|
|
66594
66600
|
function indented(body) {
|
|
66595
66601
|
return ` ${body.trim().split("\n").join("\n ")}`;
|
|
@@ -67148,8 +67154,8 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
67148
67154
|
}
|
|
67149
67155
|
async call(method, params) {
|
|
67150
67156
|
const id = ++this.#nextId;
|
|
67151
|
-
const reply2 = await new Promise((
|
|
67152
|
-
this.#pending.set(id,
|
|
67157
|
+
const reply2 = await new Promise((resolve16) => {
|
|
67158
|
+
this.#pending.set(id, resolve16);
|
|
67153
67159
|
this.write({ id, method, params });
|
|
67154
67160
|
});
|
|
67155
67161
|
if (reply2.error !== void 0) throw new Error(`${method}: ${JSON.stringify(reply2.error)}`);
|
|
@@ -67161,12 +67167,12 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
67161
67167
|
/** Starts one turn; `done` settles when it completes, keeping its last agent message. */
|
|
67162
67168
|
async startTurn({ threadId, text: text2 }) {
|
|
67163
67169
|
const result = { answer: "" };
|
|
67164
|
-
const done = new Promise((
|
|
67170
|
+
const done = new Promise((resolve16) => {
|
|
67165
67171
|
const listen = (message2) => {
|
|
67166
67172
|
absorbTurnEvent({ result, message: message2 });
|
|
67167
67173
|
if (message2.method !== "turn/completed") return;
|
|
67168
67174
|
this.#listeners.delete(listen);
|
|
67169
|
-
|
|
67175
|
+
resolve16(result);
|
|
67170
67176
|
};
|
|
67171
67177
|
this.#listeners.add(listen);
|
|
67172
67178
|
});
|
|
@@ -67461,9 +67467,162 @@ async function adoptCodex({ context, args }) {
|
|
|
67461
67467
|
}
|
|
67462
67468
|
}
|
|
67463
67469
|
|
|
67470
|
+
// src/services/laze-plugin.service.ts
|
|
67471
|
+
import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile5 } from "node:fs/promises";
|
|
67472
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
67473
|
+
|
|
67474
|
+
// src/rules/laze-plugin.rules.ts
|
|
67475
|
+
var LAZE_PLUGIN = "laze";
|
|
67476
|
+
var NPX_CLI = ["npx", "-y", "@lazehq/cli@latest"];
|
|
67477
|
+
var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
67478
|
+
function cliLineOf({ program, args }) {
|
|
67479
|
+
const here = [...program, ...args].map(quote).join(" ");
|
|
67480
|
+
const fallback = [...NPX_CLI, ...args].join(" ");
|
|
67481
|
+
return `if [ -e ${quote(program.at(-1) ?? "")} ]; then exec ${here}; else exec ${fallback}; fi`;
|
|
67482
|
+
}
|
|
67483
|
+
var SKILL = `---
|
|
67484
|
+
name: laze
|
|
67485
|
+
description: Work in a Laze workspace as an agent - read your inbox, reply to messages, post in channels and search history with the laze CLI. Use when a Laze message reaches you or someone asks you to post, reply or look something up in Laze.
|
|
67486
|
+
---
|
|
67487
|
+
|
|
67488
|
+
# Laze
|
|
67489
|
+
|
|
67490
|
+
Laze is a workspace where people and agents chat in channels, threads and direct messages.
|
|
67491
|
+
The \`laze\` command line is how you act there. Run \`laze --help\` for every command.
|
|
67492
|
+
|
|
67493
|
+
## Messages that reach you
|
|
67494
|
+
|
|
67495
|
+
A message addressed to you arrives on its own, with its id, author and channel. Answer each one
|
|
67496
|
+
where it was said:
|
|
67497
|
+
|
|
67498
|
+
\`\`\`bash
|
|
67499
|
+
laze reply MESSAGE_ID "your answer"
|
|
67500
|
+
\`\`\`
|
|
67501
|
+
|
|
67502
|
+
Use \`-\` instead of the text to read a long answer from stdin. \`laze inbox\` lists messages that
|
|
67503
|
+
are waiting, if you think one was missed.
|
|
67504
|
+
|
|
67505
|
+
## Other things you can do
|
|
67506
|
+
|
|
67507
|
+
- \`laze post <channel> "text"\` posts in a channel you are in.
|
|
67508
|
+
- \`laze history <channel>\` and \`laze thread <id>\` read a conversation.
|
|
67509
|
+
- \`laze search "words"\` searches messages.
|
|
67510
|
+
- \`laze channels list\` lists the conversations you are in.
|
|
67511
|
+
|
|
67512
|
+
If \`laze\` is not on the PATH, run the same commands through \`npx -y @lazehq/cli@latest\`.
|
|
67513
|
+
Never print or repeat your Laze key.
|
|
67514
|
+
`;
|
|
67515
|
+
function lazePluginFiles({
|
|
67516
|
+
program,
|
|
67517
|
+
version: version2
|
|
67518
|
+
}) {
|
|
67519
|
+
const json5 = (value) => `${JSON.stringify(value, null, 2)}
|
|
67520
|
+
`;
|
|
67521
|
+
const description = "Laze messages reach this session, and the laze tools to answer them";
|
|
67522
|
+
const author = { name: "Laze", url: "https://laze.langwatch.ai" };
|
|
67523
|
+
return {
|
|
67524
|
+
".claude-plugin/marketplace.json": json5({
|
|
67525
|
+
name: LAZE_PLUGIN,
|
|
67526
|
+
owner: author,
|
|
67527
|
+
plugins: [{ name: LAZE_PLUGIN, source: `./${LAZE_PLUGIN}`, description }]
|
|
67528
|
+
}),
|
|
67529
|
+
"laze/plugin.json": json5({
|
|
67530
|
+
$schema: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
67531
|
+
name: LAZE_PLUGIN,
|
|
67532
|
+
version: version2,
|
|
67533
|
+
description,
|
|
67534
|
+
author,
|
|
67535
|
+
homepage: "https://laze.langwatch.ai/docs/agents/connect",
|
|
67536
|
+
keywords: ["laze", "chat", "agents"],
|
|
67537
|
+
extensions: { "ai.laze": { delivery: "ai.laze/delivery.json" } }
|
|
67538
|
+
}),
|
|
67539
|
+
"laze/skills/laze/SKILL.md": SKILL,
|
|
67540
|
+
"laze/ai.laze/delivery.json": json5({
|
|
67541
|
+
about: "How a client that can run a background command and start a turn with its output delivers Laze messages. Run the command for the whole session; each block it prints is one message for the agent.",
|
|
67542
|
+
command: [...NPX_CLI, "hook", "monitor"]
|
|
67543
|
+
}),
|
|
67544
|
+
"laze/.claude-plugin/plugin.json": json5({
|
|
67545
|
+
name: LAZE_PLUGIN,
|
|
67546
|
+
version: version2,
|
|
67547
|
+
description,
|
|
67548
|
+
author
|
|
67549
|
+
}),
|
|
67550
|
+
"laze/monitors/monitors.json": json5([
|
|
67551
|
+
{
|
|
67552
|
+
name: "laze-messages",
|
|
67553
|
+
command: cliLineOf({ program, args: ["hook", "monitor"] }),
|
|
67554
|
+
description: "Laze messages for this session"
|
|
67555
|
+
}
|
|
67556
|
+
])
|
|
67557
|
+
};
|
|
67558
|
+
}
|
|
67559
|
+
|
|
67560
|
+
// src/services/laze-plugin.service.ts
|
|
67561
|
+
var REGISTER_LIMIT_MS = 6e4;
|
|
67562
|
+
var quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
67563
|
+
function pluginFolderOf({ context }) {
|
|
67564
|
+
return join5(dirname5(context.environment.configPath), "plugins");
|
|
67565
|
+
}
|
|
67566
|
+
async function pluginIsCurrent({ context }) {
|
|
67567
|
+
const manifest = join5(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
|
|
67568
|
+
const written = await readFile5(manifest, "utf8").then(
|
|
67569
|
+
(text2) => JSON.parse(text2).version,
|
|
67570
|
+
() => void 0
|
|
67571
|
+
);
|
|
67572
|
+
return written === cliVersionOf();
|
|
67573
|
+
}
|
|
67574
|
+
async function writeLazePlugin({ context }) {
|
|
67575
|
+
const folder = pluginFolderOf({ context });
|
|
67576
|
+
const files2 = lazePluginFiles({ program: context.program, version: cliVersionOf() });
|
|
67577
|
+
for (const [path, text2] of Object.entries(files2)) {
|
|
67578
|
+
const target = join5(folder, path);
|
|
67579
|
+
await mkdir5(dirname5(target), { recursive: true });
|
|
67580
|
+
await writeFile5(target, text2);
|
|
67581
|
+
}
|
|
67582
|
+
return folder;
|
|
67583
|
+
}
|
|
67584
|
+
async function registerWithClaude({ context, folder }) {
|
|
67585
|
+
const quiet = ">/dev/null 2>&1 </dev/null";
|
|
67586
|
+
const script = [
|
|
67587
|
+
`claude plugin marketplace add ${quote2(folder)} --scope user ${quiet}`,
|
|
67588
|
+
`claude plugin marketplace update ${LAZE_PLUGIN} ${quiet}`,
|
|
67589
|
+
`{ claude plugin install ${LAZE_PLUGIN}@${LAZE_PLUGIN} --scope user ${quiet} || claude plugin update ${LAZE_PLUGIN}@${LAZE_PLUGIN} ${quiet}; }`
|
|
67590
|
+
].join("; ");
|
|
67591
|
+
const run3 = context.runCommand({ command: ["sh", "-c", script], env: {} }).catch(() => 1);
|
|
67592
|
+
const done = new AbortController();
|
|
67593
|
+
const gaveUp = context.sleep(REGISTER_LIMIT_MS, done.signal).then(() => -1);
|
|
67594
|
+
const code = await Promise.race([run3, gaveUp]);
|
|
67595
|
+
done.abort();
|
|
67596
|
+
return code === 0;
|
|
67597
|
+
}
|
|
67598
|
+
async function installLazePlugin({ context }) {
|
|
67599
|
+
const folder = await writeLazePlugin({ context });
|
|
67600
|
+
const registered = await registerWithClaude({ context, folder });
|
|
67601
|
+
return { folder, registered };
|
|
67602
|
+
}
|
|
67603
|
+
async function plugin({ context, args }) {
|
|
67604
|
+
const action = args.words[1] ?? "install";
|
|
67605
|
+
if (action === "path") {
|
|
67606
|
+
context.out(`${join5(pluginFolderOf({ context }), LAZE_PLUGIN)}
|
|
67607
|
+
`);
|
|
67608
|
+
return 0;
|
|
67609
|
+
}
|
|
67610
|
+
if (action !== "install") {
|
|
67611
|
+
context.err("Usage: laze plugin install | laze plugin path\n");
|
|
67612
|
+
return 1;
|
|
67613
|
+
}
|
|
67614
|
+
const { folder, registered } = await installLazePlugin({ context });
|
|
67615
|
+
context.out(
|
|
67616
|
+
registered ? `Installed the Laze plugin from ${folder} in Claude Code. It starts with your next session or resume.
|
|
67617
|
+
` : `Wrote the Laze plugin to ${folder}. Claude Code did not take it; run: claude plugin marketplace add ${folder} && claude plugin install ${LAZE_PLUGIN}@${LAZE_PLUGIN}
|
|
67618
|
+
`
|
|
67619
|
+
);
|
|
67620
|
+
return 0;
|
|
67621
|
+
}
|
|
67622
|
+
|
|
67464
67623
|
// src/services/mcp-channel.service.ts
|
|
67465
|
-
import { mkdir as
|
|
67466
|
-
import { dirname as
|
|
67624
|
+
import { mkdir as mkdir6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
67625
|
+
import { dirname as dirname6 } from "node:path";
|
|
67467
67626
|
var LAZE_MCP_SERVER = "laze";
|
|
67468
67627
|
var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
|
|
67469
67628
|
var ROUND_SECONDS = 50;
|
|
@@ -67553,8 +67712,8 @@ async function pushInbox({
|
|
|
67553
67712
|
signal
|
|
67554
67713
|
}) {
|
|
67555
67714
|
const marker = statePathOf({ context, kind: "channels", profile });
|
|
67556
|
-
await
|
|
67557
|
-
await
|
|
67715
|
+
await mkdir6(dirname6(marker), { recursive: true, mode: 448 });
|
|
67716
|
+
await writeFile6(marker, JSON.stringify({ pid: context.processes.pid }));
|
|
67558
67717
|
try {
|
|
67559
67718
|
while (!signal.aborted) {
|
|
67560
67719
|
const messages = await client.post("/api/agents/me/inbox", { waitSeconds: ROUND_SECONDS }, { signal }).catch(async (error62) => {
|
|
@@ -67637,9 +67796,9 @@ async function installHooks({
|
|
|
67637
67796
|
directory,
|
|
67638
67797
|
profile
|
|
67639
67798
|
}) {
|
|
67640
|
-
const folder =
|
|
67641
|
-
const path =
|
|
67642
|
-
const current2 = await
|
|
67799
|
+
const folder = join6(directory, ".claude");
|
|
67800
|
+
const path = join6(folder, "settings.local.json");
|
|
67801
|
+
const current2 = await readFile6(path, "utf8").then(
|
|
67643
67802
|
(text2) => JSON.parse(text2),
|
|
67644
67803
|
() => ({})
|
|
67645
67804
|
);
|
|
@@ -67650,14 +67809,14 @@ async function installHooks({
|
|
|
67650
67809
|
waitCommand: command("wait"),
|
|
67651
67810
|
preToolCommand: command("pre-tool")
|
|
67652
67811
|
});
|
|
67653
|
-
await
|
|
67654
|
-
await
|
|
67812
|
+
await mkdir7(folder, { recursive: true });
|
|
67813
|
+
await writeFile7(path, `${JSON.stringify(settings2, null, 2)}
|
|
67655
67814
|
`);
|
|
67656
67815
|
return path;
|
|
67657
67816
|
}
|
|
67658
|
-
var
|
|
67817
|
+
var quote3 = (value) => /^[\w./@:+-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
67659
67818
|
function mcpAddCommandOf({ context, profile }) {
|
|
67660
|
-
const serve = [...context.program, "mcp", "--profile", profile].map(
|
|
67819
|
+
const serve = [...context.program, "mcp", "--profile", profile].map(quote3).join(" ");
|
|
67661
67820
|
return `claude mcp add --scope local ${LAZE_MCP_SERVER} -- ${serve}`;
|
|
67662
67821
|
}
|
|
67663
67822
|
var MCP_REGISTER_LIMIT_MS = 3e4;
|
|
@@ -67667,7 +67826,7 @@ async function registerMcp({
|
|
|
67667
67826
|
profile
|
|
67668
67827
|
}) {
|
|
67669
67828
|
const add3 = mcpAddCommandOf({ context, profile });
|
|
67670
|
-
const script = `cd ${
|
|
67829
|
+
const script = `cd ${quote3(directory)} && { claude mcp remove --scope local ${LAZE_MCP_SERVER} >/dev/null 2>&1 </dev/null; ${add3} >/dev/null 2>&1 </dev/null; }`;
|
|
67671
67830
|
const run3 = context.runCommand({ command: ["sh", "-c", script], env: {} }).catch(() => 1);
|
|
67672
67831
|
const done = new AbortController();
|
|
67673
67832
|
const gaveUp = context.sleep(MCP_REGISTER_LIMIT_MS, done.signal).then(() => -1);
|
|
@@ -67675,12 +67834,34 @@ async function registerMcp({
|
|
|
67675
67834
|
done.abort();
|
|
67676
67835
|
return code === 0;
|
|
67677
67836
|
}
|
|
67837
|
+
function pluginLinesOf({ plugin: plugin2 }) {
|
|
67838
|
+
if (plugin2 === void 0) return [];
|
|
67839
|
+
if (!plugin2) return ["Claude Code did not take the Laze plugin; the hooks deliver on their own."];
|
|
67840
|
+
return [
|
|
67841
|
+
"The Laze plugin is installed in Claude Code: from the next start or resume it delivers too."
|
|
67842
|
+
];
|
|
67843
|
+
}
|
|
67844
|
+
function mcpLinesOf({
|
|
67845
|
+
mcp: mcp2,
|
|
67846
|
+
mcpAdd: mcpAdd2,
|
|
67847
|
+
directory
|
|
67848
|
+
}) {
|
|
67849
|
+
if (mcp2 === void 0) return [];
|
|
67850
|
+
if (!mcp2) return ["Could not register laze mcp. To add it, run in that folder:", ` ${mcpAdd2}`];
|
|
67851
|
+
return [
|
|
67852
|
+
`Registered laze mcp as the MCP server "${LAZE_MCP_SERVER}" for ${directory}.`,
|
|
67853
|
+
"Optional (Claude Code channels, research preview): to get each message pushed into the",
|
|
67854
|
+
`session the moment it arrives, start Claude Code again in ${directory} with`,
|
|
67855
|
+
` claude --dangerously-load-development-channels server:${LAZE_MCP_SERVER}`
|
|
67856
|
+
];
|
|
67857
|
+
}
|
|
67678
67858
|
function claudeStepsOf({
|
|
67679
67859
|
profile,
|
|
67680
67860
|
laze,
|
|
67681
67861
|
directory,
|
|
67682
|
-
|
|
67683
|
-
mcpAdd: mcpAdd2
|
|
67862
|
+
mcp: mcp2,
|
|
67863
|
+
mcpAdd: mcpAdd2,
|
|
67864
|
+
plugin: plugin2
|
|
67684
67865
|
}) {
|
|
67685
67866
|
return [
|
|
67686
67867
|
"Messages addressed to you now reach this session on their own: a background hook waits",
|
|
@@ -67688,11 +67869,8 @@ function claudeStepsOf({
|
|
|
67688
67869
|
"Answer each with",
|
|
67689
67870
|
` ${laze} reply <message-id> "<answer>" --profile ${profile}`,
|
|
67690
67871
|
"Nothing else needs to keep running.",
|
|
67691
|
-
|
|
67692
|
-
...
|
|
67693
|
-
"Optional (Claude Code channels, research preview): to get each message pushed into the",
|
|
67694
|
-
`session the moment it arrives, start Claude Code again in ${directory} with`,
|
|
67695
|
-
` claude --dangerously-load-development-channels server:${LAZE_MCP_SERVER}`
|
|
67872
|
+
...pluginLinesOf({ plugin: plugin2 }),
|
|
67873
|
+
...mcpLinesOf({ mcp: mcp2, mcpAdd: mcpAdd2, directory })
|
|
67696
67874
|
].join("\n");
|
|
67697
67875
|
}
|
|
67698
67876
|
function waiterStepsOf({ profile, laze }) {
|
|
@@ -67796,16 +67974,17 @@ async function nextStepsFor({
|
|
|
67796
67974
|
}) {
|
|
67797
67975
|
if (harness === "codex") return startAdoptInBackground({ context, args, profile, laze });
|
|
67798
67976
|
if (!hooked) return waiterStepsOf({ profile, laze });
|
|
67799
|
-
const
|
|
67977
|
+
const plugin2 = args.flags["no-plugin"] ? void 0 : await installLazePlugin({ context });
|
|
67978
|
+
const mcp2 = args.flags.mcp ? await registerMcp({ context, directory, profile }) : void 0;
|
|
67800
67979
|
const mcpAdd2 = mcpAddCommandOf({ context, profile });
|
|
67801
|
-
return claudeStepsOf({ profile, laze, directory,
|
|
67980
|
+
return claudeStepsOf({ profile, laze, directory, mcp: mcp2, mcpAdd: mcpAdd2, plugin: plugin2?.registered });
|
|
67802
67981
|
}
|
|
67803
67982
|
async function reportTranscript({
|
|
67804
67983
|
client,
|
|
67805
67984
|
input: input2
|
|
67806
67985
|
}) {
|
|
67807
67986
|
if (!input2.transcript_path || !input2.session_id) return;
|
|
67808
|
-
const lines = (await
|
|
67987
|
+
const lines = (await readFile6(input2.transcript_path, "utf8")).split("\n");
|
|
67809
67988
|
const context = readTranscript({ lines });
|
|
67810
67989
|
await client.post("/api/agents/me/activity", {
|
|
67811
67990
|
sessionId: input2.session_id,
|
|
@@ -67826,7 +68005,7 @@ async function handOver({ context, args }) {
|
|
|
67826
68005
|
const kept = await dueFromSpool({
|
|
67827
68006
|
context,
|
|
67828
68007
|
profile: agent2,
|
|
67829
|
-
seen: () => input2.transcript_path ?
|
|
68008
|
+
seen: () => input2.transcript_path ? readFile6(input2.transcript_path, "utf8") : Promise.resolve(""),
|
|
67830
68009
|
pushedToo: false
|
|
67831
68010
|
});
|
|
67832
68011
|
const fresh = await receiveMessages({ context, client, waitSeconds: 0 });
|
|
@@ -67844,19 +68023,25 @@ async function addSessionStartWaiter({ context, args }) {
|
|
|
67844
68023
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
|
|
67845
68024
|
const profile = flagText({ args, name: "profile" });
|
|
67846
68025
|
if (!directory || !profile) return;
|
|
67847
|
-
const path =
|
|
67848
|
-
const settings2 = await
|
|
68026
|
+
const path = join6(directory, ".claude", "settings.local.json");
|
|
68027
|
+
const settings2 = await readFile6(path, "utf8").then(
|
|
67849
68028
|
(text2) => JSON.parse(text2),
|
|
67850
68029
|
() => void 0
|
|
67851
68030
|
);
|
|
67852
68031
|
if (!settings2 || !lacksSessionStartWaiter({ settings: settings2 })) return;
|
|
67853
68032
|
await installHooks({ context, directory, profile });
|
|
67854
68033
|
}
|
|
68034
|
+
async function refreshPlugin({ context }) {
|
|
68035
|
+
if (await pluginIsCurrent({ context })) return;
|
|
68036
|
+
const logPath = join6(pluginFolderOf({ context }), "install.log");
|
|
68037
|
+
context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
|
|
68038
|
+
}
|
|
67855
68039
|
async function stopHook({ context, args }) {
|
|
67856
68040
|
await addSessionStartWaiter({ context, args }).catch(
|
|
67857
68041
|
(error62) => context.err(`laze: could not add the SessionStart hook: ${String(error62)}
|
|
67858
68042
|
`)
|
|
67859
68043
|
);
|
|
68044
|
+
await refreshPlugin({ context }).catch(() => void 0);
|
|
67860
68045
|
try {
|
|
67861
68046
|
await handOver({ context, args });
|
|
67862
68047
|
} catch (error62) {
|
|
@@ -67866,7 +68051,7 @@ async function stopHook({ context, args }) {
|
|
|
67866
68051
|
}
|
|
67867
68052
|
|
|
67868
68053
|
// src/services/agent-manage-commands.service.ts
|
|
67869
|
-
import { readFile as
|
|
68054
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
67870
68055
|
import { extname, resolve as resolve4 } from "node:path";
|
|
67871
68056
|
|
|
67872
68057
|
// src/rules/login-format.rules.ts
|
|
@@ -67995,7 +68180,7 @@ async function avatarOf({
|
|
|
67995
68180
|
}) {
|
|
67996
68181
|
const path = flagText({ args, name: "avatar" });
|
|
67997
68182
|
if (!path) return void 0;
|
|
67998
|
-
const bytes = await
|
|
68183
|
+
const bytes = await readFile7(resolve4(context.cwd, path)).catch(() => {
|
|
67999
68184
|
throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
|
|
68000
68185
|
});
|
|
68001
68186
|
const uploaded = await client.post("/api/agents/avatars", {
|
|
@@ -68545,8 +68730,8 @@ async function setAgentPool({
|
|
|
68545
68730
|
}
|
|
68546
68731
|
|
|
68547
68732
|
// src/services/app-commands.service.ts
|
|
68548
|
-
import { mkdir as
|
|
68549
|
-
import { dirname as
|
|
68733
|
+
import { mkdir as mkdir8, readdir as readdir2, readFile as readFile8, writeFile as writeFile9 } from "node:fs/promises";
|
|
68734
|
+
import { dirname as dirname7, join as join8, relative as relative2, resolve as resolve5, sep } from "node:path";
|
|
68550
68735
|
|
|
68551
68736
|
// ../../modules/app/contract/src/app.connections.ts
|
|
68552
68737
|
var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
@@ -70937,9 +71122,9 @@ async function appPinsCommand({
|
|
|
70937
71122
|
|
|
70938
71123
|
// src/services/app-script-check.service.ts
|
|
70939
71124
|
import { execFile } from "node:child_process";
|
|
70940
|
-
import { mkdtemp, rm as rm4, writeFile as
|
|
71125
|
+
import { mkdtemp, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
70941
71126
|
import { tmpdir } from "node:os";
|
|
70942
|
-
import { join as
|
|
71127
|
+
import { join as join7 } from "node:path";
|
|
70943
71128
|
import { promisify } from "node:util";
|
|
70944
71129
|
var run = promisify(execFile);
|
|
70945
71130
|
var MODULE_SYNTAX = /^\s*(import|export)\s/m;
|
|
@@ -70968,12 +71153,12 @@ async function scriptErrorsOf({
|
|
|
70968
71153
|
const unknown2 = unknownCollectionsOf({ files: files2, collections });
|
|
70969
71154
|
const scripts = files2.flatMap(scriptsOf);
|
|
70970
71155
|
if (scripts.length === 0) return unknown2;
|
|
70971
|
-
const dir = await mkdtemp(
|
|
71156
|
+
const dir = await mkdtemp(join7(tmpdir(), "laze-app-check-"));
|
|
70972
71157
|
try {
|
|
70973
71158
|
const errors = await Promise.all(
|
|
70974
71159
|
scripts.map(async (script, index) => {
|
|
70975
|
-
const file3 =
|
|
70976
|
-
await
|
|
71160
|
+
const file3 = join7(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
|
|
71161
|
+
await writeFile8(file3, script.code);
|
|
70977
71162
|
try {
|
|
70978
71163
|
await run(process.execPath, ["--check", file3]);
|
|
70979
71164
|
return null;
|
|
@@ -71122,7 +71307,7 @@ async function turnTokenOf({
|
|
|
71122
71307
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
71123
71308
|
if (pinned) return pinned;
|
|
71124
71309
|
if (env.LAZE_TURN_FILE) {
|
|
71125
|
-
return
|
|
71310
|
+
return readFile8(env.LAZE_TURN_FILE, "utf8").then(
|
|
71126
71311
|
(text2) => text2.trim(),
|
|
71127
71312
|
() => ""
|
|
71128
71313
|
);
|
|
@@ -71148,7 +71333,7 @@ function folderOf({ context, word: word3 }) {
|
|
|
71148
71333
|
return resolve5(context.cwd, word3 ?? ".");
|
|
71149
71334
|
}
|
|
71150
71335
|
async function readManifest(folder) {
|
|
71151
|
-
const text2 = await
|
|
71336
|
+
const text2 = await readFile8(join8(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
71152
71337
|
if (text2 === void 0) return void 0;
|
|
71153
71338
|
const parsed = appManifestSchema.safeParse(JSON.parse(text2));
|
|
71154
71339
|
if (!parsed.success) {
|
|
@@ -71183,7 +71368,7 @@ async function jsonFlag({
|
|
|
71183
71368
|
}) {
|
|
71184
71369
|
const raw = flagText({ args, name: name2 });
|
|
71185
71370
|
if (!raw) return void 0;
|
|
71186
|
-
const text2 = raw.startsWith("@") ? await
|
|
71371
|
+
const text2 = raw.startsWith("@") ? await readFile8(resolve5(context.cwd, raw.slice(1)), "utf8") : raw;
|
|
71187
71372
|
try {
|
|
71188
71373
|
return JSON.parse(text2);
|
|
71189
71374
|
} catch {
|
|
@@ -71196,7 +71381,7 @@ async function listFiles(folder) {
|
|
|
71196
71381
|
while (pending.length > 0 && found.length <= MAX_FILES) {
|
|
71197
71382
|
const current2 = pending.pop() ?? folder;
|
|
71198
71383
|
for (const entry of await readdir2(current2, { withFileTypes: true })) {
|
|
71199
|
-
const path =
|
|
71384
|
+
const path = join8(current2, entry.name);
|
|
71200
71385
|
const rel = relative2(folder, path).split(sep).join("/");
|
|
71201
71386
|
if (isSkippedPath({ path: rel })) continue;
|
|
71202
71387
|
if (entry.isDirectory()) pending.push(path);
|
|
@@ -71237,11 +71422,11 @@ var appCreate = async ({ context, args }) => {
|
|
|
71237
71422
|
...visibility ? { visibility } : {}
|
|
71238
71423
|
});
|
|
71239
71424
|
const folder = resolve5(context.cwd, flagText({ args, name: "dir", fallback: app2.slug }));
|
|
71240
|
-
await
|
|
71425
|
+
await mkdir8(folder, { recursive: true });
|
|
71241
71426
|
const files2 = template ? templateFiles({ template, name: name2 }) : {};
|
|
71242
71427
|
for (const [path, content] of Object.entries(files2)) {
|
|
71243
|
-
await
|
|
71244
|
-
await
|
|
71428
|
+
await mkdir8(dirname7(join8(folder, path)), { recursive: true });
|
|
71429
|
+
await writeFile9(join8(folder, path), content);
|
|
71245
71430
|
}
|
|
71246
71431
|
const manifest = {
|
|
71247
71432
|
app: { id: app2.id, name: app2.name, slug: app2.slug },
|
|
@@ -71249,7 +71434,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
71249
71434
|
views: template?.views ? [...template.views] : [],
|
|
71250
71435
|
seed: template ? { ...template.seed } : {}
|
|
71251
71436
|
};
|
|
71252
|
-
await
|
|
71437
|
+
await writeFile9(join8(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
71253
71438
|
`);
|
|
71254
71439
|
print5({
|
|
71255
71440
|
context,
|
|
@@ -71286,7 +71471,7 @@ var appPush = async ({ context, args }) => {
|
|
|
71286
71471
|
paths.map(
|
|
71287
71472
|
async (path) => buildFileOf({
|
|
71288
71473
|
path: relative2(folder, path).split(sep).join("/"),
|
|
71289
|
-
bytes: await
|
|
71474
|
+
bytes: await readFile8(path)
|
|
71290
71475
|
})
|
|
71291
71476
|
)
|
|
71292
71477
|
);
|
|
@@ -71661,7 +71846,7 @@ var appExport = async ({ context, args }) => {
|
|
|
71661
71846
|
const out = flagText({ args, name: "out" });
|
|
71662
71847
|
if (!out) return context.out(exported.body);
|
|
71663
71848
|
const target = resolve5(context.cwd, out);
|
|
71664
|
-
await
|
|
71849
|
+
await writeFile9(target, exported.body);
|
|
71665
71850
|
context.out(`Wrote ${exported.rows} records to ${relative2(context.cwd, target)}
|
|
71666
71851
|
`);
|
|
71667
71852
|
};
|
|
@@ -71669,7 +71854,7 @@ var appImport = async ({ context, args }) => {
|
|
|
71669
71854
|
const words = args.words.slice(2);
|
|
71670
71855
|
const [named, collection, file3] = words.length >= 3 ? words : [void 0, ...words];
|
|
71671
71856
|
if (!collection || !file3) throw new CliUsageError(USAGE5);
|
|
71672
|
-
const csv = await
|
|
71857
|
+
const csv = await readFile8(resolve5(context.cwd, file3), "utf8").catch(() => {
|
|
71673
71858
|
throw new CliUsageError(`Cannot read ${file3}`);
|
|
71674
71859
|
});
|
|
71675
71860
|
const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
|
|
@@ -71688,7 +71873,7 @@ var appImport = async ({ context, args }) => {
|
|
|
71688
71873
|
});
|
|
71689
71874
|
const refusedOut = flagText({ args, name: "refused" });
|
|
71690
71875
|
if (refusedOut && result.refusedCsv) {
|
|
71691
|
-
await
|
|
71876
|
+
await writeFile9(resolve5(context.cwd, refusedOut), result.refusedCsv);
|
|
71692
71877
|
}
|
|
71693
71878
|
const fitting = result.rows - result.refused.length;
|
|
71694
71879
|
const skipped = result.refused.slice(0, 20).map((row) => ` line ${row.line}: ${row.reason}
|
|
@@ -72235,8 +72420,8 @@ async function billing({ context, args }) {
|
|
|
72235
72420
|
|
|
72236
72421
|
// src/services/browser-commands.service.ts
|
|
72237
72422
|
import { randomBytes } from "node:crypto";
|
|
72238
|
-
import { mkdir as
|
|
72239
|
-
import { dirname as
|
|
72423
|
+
import { mkdir as mkdir9, readFile as readFile9, writeFile as writeFile10 } from "node:fs/promises";
|
|
72424
|
+
import { dirname as dirname8, join as join9 } from "node:path";
|
|
72240
72425
|
|
|
72241
72426
|
// src/services/browser-tab-commands.service.ts
|
|
72242
72427
|
var BROWSER_TAB_PATHS = {
|
|
@@ -72437,7 +72622,7 @@ function tunnel({
|
|
|
72437
72622
|
host: host2,
|
|
72438
72623
|
port
|
|
72439
72624
|
}) {
|
|
72440
|
-
return new Promise((
|
|
72625
|
+
return new Promise((resolve16, reject) => {
|
|
72441
72626
|
const socket = connectTcp(proxy.port, proxy.host);
|
|
72442
72627
|
let answer4 = "";
|
|
72443
72628
|
const auth = proxy.authorization ? `Proxy-Authorization: ${proxy.authorization}\r
|
|
@@ -72454,7 +72639,7 @@ ${auth}\r
|
|
|
72454
72639
|
answer4 += chunk.toString("latin1");
|
|
72455
72640
|
if (!answer4.includes(HEADER_END)) return;
|
|
72456
72641
|
socket.off("data", onData);
|
|
72457
|
-
if (/^HTTP\/1\.[01] 200/.test(answer4)) return
|
|
72642
|
+
if (/^HTTP\/1\.[01] 200/.test(answer4)) return resolve16(socket);
|
|
72458
72643
|
socket.destroy();
|
|
72459
72644
|
reject(new Error(`proxy refused the tunnel: ${answer4.split("\r\n")[0] ?? ""}`));
|
|
72460
72645
|
};
|
|
@@ -72467,8 +72652,8 @@ async function upstreamOf({ target, proxy }) {
|
|
|
72467
72652
|
const raw = proxy ? await tunnel({ proxy, host: target.hostname, port }) : connectTcp(port, target.hostname);
|
|
72468
72653
|
if (!secure) return raw;
|
|
72469
72654
|
const tls = connectTls({ socket: raw, servername: target.hostname });
|
|
72470
|
-
await new Promise((
|
|
72471
|
-
tls.once("secureConnect", () =>
|
|
72655
|
+
await new Promise((resolve16, reject) => {
|
|
72656
|
+
tls.once("secureConnect", () => resolve16());
|
|
72472
72657
|
tls.once("error", reject);
|
|
72473
72658
|
});
|
|
72474
72659
|
return tls;
|
|
@@ -72510,8 +72695,8 @@ async function browserSocket({
|
|
|
72510
72695
|
createConnection: () => upstream,
|
|
72511
72696
|
perMessageDeflate: false
|
|
72512
72697
|
});
|
|
72513
|
-
await new Promise((
|
|
72514
|
-
socket.once("open", () =>
|
|
72698
|
+
await new Promise((resolve16, reject) => {
|
|
72699
|
+
socket.once("open", () => resolve16());
|
|
72515
72700
|
socket.once("error", reject);
|
|
72516
72701
|
});
|
|
72517
72702
|
return socket;
|
|
@@ -72524,12 +72709,12 @@ async function browserCall({
|
|
|
72524
72709
|
}) {
|
|
72525
72710
|
const socket = await browserSocket({ target, proxy });
|
|
72526
72711
|
try {
|
|
72527
|
-
return await new Promise((
|
|
72712
|
+
return await new Promise((resolve16, reject) => {
|
|
72528
72713
|
socket.on("message", (data) => {
|
|
72529
72714
|
const reply2 = JSON.parse(textOf2(data));
|
|
72530
72715
|
if (reply2.id !== 1) return;
|
|
72531
72716
|
if (reply2.error) reject(new Error(`${method}: ${JSON.stringify(reply2.error)}`));
|
|
72532
|
-
else
|
|
72717
|
+
else resolve16(reply2.result ?? {});
|
|
72533
72718
|
});
|
|
72534
72719
|
socket.once("close", () => reject(new Error(`${method}: the machine closed the socket`)));
|
|
72535
72720
|
socket.send(JSON.stringify({ id: 1, method, params }));
|
|
@@ -72668,18 +72853,18 @@ function retargetCdpBridge({
|
|
|
72668
72853
|
target,
|
|
72669
72854
|
expiresAt
|
|
72670
72855
|
}) {
|
|
72671
|
-
return new Promise((
|
|
72856
|
+
return new Promise((resolve16) => {
|
|
72672
72857
|
const call = httpRequest(
|
|
72673
72858
|
{ host: "127.0.0.1", port, path: TARGET_PATH, method: "PUT", timeout: 2e3 },
|
|
72674
72859
|
(response) => {
|
|
72675
72860
|
response.resume();
|
|
72676
|
-
|
|
72861
|
+
resolve16(response.statusCode === 204);
|
|
72677
72862
|
}
|
|
72678
72863
|
);
|
|
72679
72864
|
call.setHeader(KEY_HEADER, key);
|
|
72680
72865
|
call.setHeader("content-type", "application/json");
|
|
72681
72866
|
call.once("timeout", () => call.destroy());
|
|
72682
|
-
call.once("error", () =>
|
|
72867
|
+
call.once("error", () => resolve16(false));
|
|
72683
72868
|
call.end(JSON.stringify({ target, expiresAt }));
|
|
72684
72869
|
});
|
|
72685
72870
|
}
|
|
@@ -72728,15 +72913,15 @@ async function startCdpBridge({
|
|
|
72728
72913
|
(socket) => relayPage({ client: socket, targetId, target: url2, proxy })
|
|
72729
72914
|
);
|
|
72730
72915
|
});
|
|
72731
|
-
await new Promise((
|
|
72916
|
+
await new Promise((resolve16) => server.listen(0, "127.0.0.1", resolve16));
|
|
72732
72917
|
const port = server.address().port;
|
|
72733
72918
|
return {
|
|
72734
72919
|
port,
|
|
72735
|
-
close: () => new Promise((
|
|
72920
|
+
close: () => new Promise((resolve16) => {
|
|
72736
72921
|
for (const client of relayed) client.destroy();
|
|
72737
72922
|
pages.close();
|
|
72738
72923
|
server.closeAllConnections();
|
|
72739
|
-
server.close(() =>
|
|
72924
|
+
server.close(() => resolve16());
|
|
72740
72925
|
})
|
|
72741
72926
|
};
|
|
72742
72927
|
}
|
|
@@ -72753,7 +72938,7 @@ function launchCdpBridge({
|
|
|
72753
72938
|
stdio: ["ignore", "pipe", "ignore"],
|
|
72754
72939
|
env: { ...env, LAZE_CDP_TARGET: target, LAZE_CDP_EXPIRES_AT: expiresAt, LAZE_CDP_KEY: key }
|
|
72755
72940
|
});
|
|
72756
|
-
return new Promise((
|
|
72941
|
+
return new Promise((resolve16, reject) => {
|
|
72757
72942
|
let printed = "";
|
|
72758
72943
|
child.once("error", reject);
|
|
72759
72944
|
child.once("exit", (code) => reject(new Error(`the CDP bridge stopped (${code})`)));
|
|
@@ -72764,7 +72949,7 @@ function launchCdpBridge({
|
|
|
72764
72949
|
child.stdout.destroy();
|
|
72765
72950
|
child.removeAllListeners("exit");
|
|
72766
72951
|
child.unref();
|
|
72767
|
-
if (Number.isInteger(port) && port > 0)
|
|
72952
|
+
if (Number.isInteger(port) && port > 0) resolve16(port);
|
|
72768
72953
|
else reject(new Error("the CDP bridge printed no port"));
|
|
72769
72954
|
});
|
|
72770
72955
|
});
|
|
@@ -72795,7 +72980,7 @@ async function turnTokenOf2({ context }) {
|
|
|
72795
72980
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
72796
72981
|
if (pinned) return pinned;
|
|
72797
72982
|
if (!env.LAZE_TURN_FILE) return "";
|
|
72798
|
-
return
|
|
72983
|
+
return readFile9(env.LAZE_TURN_FILE, "utf8").then(
|
|
72799
72984
|
(text2) => text2.trim(),
|
|
72800
72985
|
() => ""
|
|
72801
72986
|
);
|
|
@@ -72869,7 +73054,7 @@ async function cdp({ context, args }) {
|
|
|
72869
73054
|
}
|
|
72870
73055
|
function bridgeStatePath({ context, machine: machine2 }) {
|
|
72871
73056
|
const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
72872
|
-
return
|
|
73057
|
+
return join9(dirname8(context.environment.configPath), "bridges", `${safe}.json`);
|
|
72873
73058
|
}
|
|
72874
73059
|
async function bridgePort({
|
|
72875
73060
|
context,
|
|
@@ -72877,7 +73062,7 @@ async function bridgePort({
|
|
|
72877
73062
|
access
|
|
72878
73063
|
}) {
|
|
72879
73064
|
const path = bridgeStatePath({ context, machine: machine2 });
|
|
72880
|
-
const live = await
|
|
73065
|
+
const live = await readFile9(path, "utf8").then(
|
|
72881
73066
|
(text2) => JSON.parse(text2),
|
|
72882
73067
|
() => void 0
|
|
72883
73068
|
);
|
|
@@ -72890,8 +73075,8 @@ async function bridgePort({
|
|
|
72890
73075
|
key,
|
|
72891
73076
|
...target
|
|
72892
73077
|
});
|
|
72893
|
-
await
|
|
72894
|
-
await
|
|
73078
|
+
await mkdir9(dirname8(path), { recursive: true, mode: 448 });
|
|
73079
|
+
await writeFile10(path, JSON.stringify({ port, key }), { mode: 384 });
|
|
72895
73080
|
return port;
|
|
72896
73081
|
}
|
|
72897
73082
|
async function bridge({ context }) {
|
|
@@ -73490,8 +73675,54 @@ async function channelSettings({ context, args }) {
|
|
|
73490
73675
|
}
|
|
73491
73676
|
|
|
73492
73677
|
// src/services/chat-actions-commands.service.ts
|
|
73493
|
-
import { readFile as
|
|
73678
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
73494
73679
|
import { basename as basename2, isAbsolute as isAbsolute2, relative as relative3, resolve as resolve6 } from "node:path";
|
|
73680
|
+
|
|
73681
|
+
// src/services/file-upload.service.ts
|
|
73682
|
+
async function sendParts({
|
|
73683
|
+
context,
|
|
73684
|
+
ticket,
|
|
73685
|
+
bytes
|
|
73686
|
+
}) {
|
|
73687
|
+
const parts = [];
|
|
73688
|
+
for (const part of ticket.parts) {
|
|
73689
|
+
const single = ticket.mode === "single";
|
|
73690
|
+
const response = await context.fetcher(part.url, {
|
|
73691
|
+
method: "PUT",
|
|
73692
|
+
body: single ? bytes : bytes.subarray(part.start, part.end),
|
|
73693
|
+
headers: single ? ticket.headers : {}
|
|
73694
|
+
});
|
|
73695
|
+
if (!response.ok)
|
|
73696
|
+
throw new CliUsageError(`The file store refused the upload (${response.status})`);
|
|
73697
|
+
parts.push({
|
|
73698
|
+
partNumber: part.partNumber,
|
|
73699
|
+
etag: (response.headers.get("etag") ?? "").replaceAll('"', "")
|
|
73700
|
+
});
|
|
73701
|
+
}
|
|
73702
|
+
return ticket.mode === "multipart" ? parts : [];
|
|
73703
|
+
}
|
|
73704
|
+
async function uploadFile({
|
|
73705
|
+
context,
|
|
73706
|
+
client,
|
|
73707
|
+
file: file3
|
|
73708
|
+
}) {
|
|
73709
|
+
const ticket = await client.post(CHAT_KEY_PATHS.startUpload, {
|
|
73710
|
+
channel: file3.channel,
|
|
73711
|
+
fileName: file3.fileName,
|
|
73712
|
+
contentType: file3.contentType,
|
|
73713
|
+
sizeBytes: file3.bytes.byteLength
|
|
73714
|
+
});
|
|
73715
|
+
const attachmentId = ticket.attachment.id;
|
|
73716
|
+
try {
|
|
73717
|
+
const parts = await sendParts({ context, ticket, bytes: file3.bytes });
|
|
73718
|
+
return await client.post(CHAT_KEY_PATHS.completeUpload, { attachmentId, parts });
|
|
73719
|
+
} catch (cause) {
|
|
73720
|
+
await client.post(CHAT_KEY_PATHS.abortUpload, { attachmentId }).catch(() => void 0);
|
|
73721
|
+
throw cause;
|
|
73722
|
+
}
|
|
73723
|
+
}
|
|
73724
|
+
|
|
73725
|
+
// src/services/chat-actions-commands.service.ts
|
|
73495
73726
|
var CHAT_ACTIONS_USAGE = `Usage:
|
|
73496
73727
|
laze thread <messageId> a message's thread: its root and replies
|
|
73497
73728
|
laze thread follow <messageId> [--off] follow a thread, or stop
|
|
@@ -73708,54 +73939,25 @@ var files = async ({ context, args, client }) => {
|
|
|
73708
73939
|
`).join("") || "No files.\n"
|
|
73709
73940
|
});
|
|
73710
73941
|
};
|
|
73711
|
-
async function sendParts({
|
|
73712
|
-
context,
|
|
73713
|
-
ticket,
|
|
73714
|
-
bytes
|
|
73715
|
-
}) {
|
|
73716
|
-
const parts = [];
|
|
73717
|
-
for (const part of ticket.parts) {
|
|
73718
|
-
const single = ticket.mode === "single";
|
|
73719
|
-
const response = await context.fetcher(part.url, {
|
|
73720
|
-
method: "PUT",
|
|
73721
|
-
body: single ? bytes : bytes.subarray(part.start, part.end),
|
|
73722
|
-
headers: single ? ticket.headers : {}
|
|
73723
|
-
});
|
|
73724
|
-
if (!response.ok)
|
|
73725
|
-
throw new CliUsageError(`The file store refused the upload (${response.status})`);
|
|
73726
|
-
parts.push({
|
|
73727
|
-
partNumber: part.partNumber,
|
|
73728
|
-
etag: (response.headers.get("etag") ?? "").replaceAll('"', "")
|
|
73729
|
-
});
|
|
73730
|
-
}
|
|
73731
|
-
return ticket.mode === "multipart" ? parts : [];
|
|
73732
|
-
}
|
|
73733
73942
|
function uploadNameOf({ cwd, path }) {
|
|
73734
73943
|
const inside = relative3(cwd, path);
|
|
73735
73944
|
return inside && !inside.startsWith("..") && !isAbsolute2(inside) ? inside : basename2(path);
|
|
73736
73945
|
}
|
|
73737
73946
|
var fileUpload = async ({ context, args, client }) => {
|
|
73738
73947
|
const path = resolve6(context.cwd, wordAt(args, 3));
|
|
73739
|
-
const bytes = new Uint8Array(await
|
|
73740
|
-
const
|
|
73741
|
-
|
|
73742
|
-
|
|
73743
|
-
|
|
73744
|
-
|
|
73948
|
+
const bytes = new Uint8Array(await readFile10(path));
|
|
73949
|
+
const answer4 = await uploadFile({
|
|
73950
|
+
context,
|
|
73951
|
+
client,
|
|
73952
|
+
file: {
|
|
73953
|
+
channel: wordAt(args, 2),
|
|
73954
|
+
fileName: uploadNameOf({ cwd: context.cwd, path }),
|
|
73955
|
+
contentType: flagText({ args, name: "type", fallback: "application/octet-stream" }),
|
|
73956
|
+
bytes
|
|
73957
|
+
}
|
|
73745
73958
|
});
|
|
73746
|
-
|
|
73747
|
-
try {
|
|
73748
|
-
const parts = await sendParts({ context, ticket, bytes });
|
|
73749
|
-
const answer4 = await client.post(CHAT_KEY_PATHS.completeUpload, {
|
|
73750
|
-
attachmentId,
|
|
73751
|
-
parts
|
|
73752
|
-
});
|
|
73753
|
-
print6({ context, args, answer: answer4, text: (it) => `Uploaded ${it.fileName} as ${it.id}.
|
|
73959
|
+
print6({ context, args, answer: answer4, text: (it) => `Uploaded ${it.fileName} as ${it.id}.
|
|
73754
73960
|
` });
|
|
73755
|
-
} catch (cause) {
|
|
73756
|
-
await client.post(CHAT_KEY_PATHS.abortUpload, { attachmentId }).catch(() => void 0);
|
|
73757
|
-
throw cause;
|
|
73758
|
-
}
|
|
73759
73961
|
};
|
|
73760
73962
|
var FILE_VERBS = {
|
|
73761
73963
|
link: async ({ context, args, client }) => {
|
|
@@ -73904,14 +74106,17 @@ async function chatActions({
|
|
|
73904
74106
|
await run3({ context, args, client });
|
|
73905
74107
|
}
|
|
73906
74108
|
|
|
74109
|
+
// src/services/claude-monitor.service.ts
|
|
74110
|
+
import { rm as rm6 } from "node:fs/promises";
|
|
74111
|
+
|
|
73907
74112
|
// src/services/claude-wait.service.ts
|
|
73908
|
-
import { readFile as
|
|
73909
|
-
import { dirname as
|
|
74113
|
+
import { readFile as readFile11, rm as rm5, writeFile as writeFile11, mkdir as mkdir10 } from "node:fs/promises";
|
|
74114
|
+
import { dirname as dirname9 } from "node:path";
|
|
73910
74115
|
var ROUND_SECONDS2 = 50;
|
|
73911
74116
|
var WATCH_MS = 2e3;
|
|
73912
74117
|
var CHANNEL_CHECK_MS = 5e3;
|
|
73913
74118
|
async function holderOf({ path }) {
|
|
73914
|
-
return
|
|
74119
|
+
return readFile11(path, "utf8").then(
|
|
73915
74120
|
(text2) => JSON.parse(text2),
|
|
73916
74121
|
() => void 0
|
|
73917
74122
|
);
|
|
@@ -73924,19 +74129,26 @@ async function takeLock({
|
|
|
73924
74129
|
context,
|
|
73925
74130
|
path,
|
|
73926
74131
|
sessionId,
|
|
73927
|
-
claudePid
|
|
74132
|
+
claudePid,
|
|
74133
|
+
preempt = false
|
|
73928
74134
|
}) {
|
|
73929
74135
|
const holder = await holderOf({ path });
|
|
73930
74136
|
const self2 = context.processes.pid;
|
|
73931
74137
|
if (holder && holder.pid !== self2 && context.processes.alive(holder.pid)) {
|
|
73932
74138
|
const served = await holderClaudeOf({ context, holder });
|
|
73933
|
-
|
|
74139
|
+
const mine3 = preempt && served === claudePid && !holder.monitor;
|
|
74140
|
+
if (served && context.processes.alive(served) && !mine3) return false;
|
|
73934
74141
|
context.processes.stop(holder.pid);
|
|
73935
74142
|
}
|
|
73936
|
-
await
|
|
73937
|
-
await
|
|
74143
|
+
await mkdir10(dirname9(path), { recursive: true, mode: 448 });
|
|
74144
|
+
await writeFile11(
|
|
73938
74145
|
path,
|
|
73939
|
-
JSON.stringify({
|
|
74146
|
+
JSON.stringify({
|
|
74147
|
+
pid: self2,
|
|
74148
|
+
claudePid,
|
|
74149
|
+
...sessionId ? { sessionId } : {},
|
|
74150
|
+
...preempt ? { monitor: true } : {}
|
|
74151
|
+
})
|
|
73940
74152
|
);
|
|
73941
74153
|
return true;
|
|
73942
74154
|
}
|
|
@@ -74000,7 +74212,7 @@ async function waitForMessages({ context, args }) {
|
|
|
74000
74212
|
const claudePid = await claudePidOf({ context });
|
|
74001
74213
|
const lock = statePathOf({ context, kind: "waiters", profile: name2 });
|
|
74002
74214
|
if (!await takeLock({ context, path: lock, sessionId: input2.session_id, claudePid })) return 0;
|
|
74003
|
-
const seen = () => input2.transcript_path ?
|
|
74215
|
+
const seen = () => input2.transcript_path ? readFile11(input2.transcript_path, "utf8") : Promise.resolve("");
|
|
74004
74216
|
const deadline = context.nowMs() + (WAIT_HOOK_TIMEOUT_SECONDS - 60) * 1e3;
|
|
74005
74217
|
try {
|
|
74006
74218
|
while (context.nowMs() < deadline) {
|
|
@@ -74031,6 +74243,59 @@ async function waitHook({ context, args }) {
|
|
|
74031
74243
|
}
|
|
74032
74244
|
}
|
|
74033
74245
|
|
|
74246
|
+
// src/services/claude-monitor.service.ts
|
|
74247
|
+
var MONITOR_IDLE_MS = 3e4;
|
|
74248
|
+
async function agentProfileHere({ context }) {
|
|
74249
|
+
const config2 = await context.store.read();
|
|
74250
|
+
const name2 = boundProfileOf({ bindings: config2.bindings, cwd: context.cwd });
|
|
74251
|
+
return name2 && config2.profiles[name2]?.kind === "agent" ? name2 : void 0;
|
|
74252
|
+
}
|
|
74253
|
+
async function deliverOnce({ context, args, claudePid, profile }) {
|
|
74254
|
+
const lock = statePathOf({ context, kind: "waiters", profile });
|
|
74255
|
+
const mine3 = (await holderOf({ path: lock }))?.pid === context.processes.pid;
|
|
74256
|
+
if (!mine3 && !await takeLock({ context, path: lock, claudePid, preempt: true })) return false;
|
|
74257
|
+
const named = { ...args, flags: { ...args.flags, profile } };
|
|
74258
|
+
const { client } = await signedIn({ context, args: named });
|
|
74259
|
+
const due = await dueFromSpool({ context, profile, seen: async () => "", pushedToo: true });
|
|
74260
|
+
const taken = due.length > 0 ? [] : await takeRound({ context, client, claudePid });
|
|
74261
|
+
const messages = [...due, ...taken];
|
|
74262
|
+
if (messages.length === 0) {
|
|
74263
|
+
await context.sleep(1e3);
|
|
74264
|
+
return true;
|
|
74265
|
+
}
|
|
74266
|
+
await keepTaken({ context, profile, messages: taken });
|
|
74267
|
+
await turnStarted({ context, client, agent: profile, messages }).catch(() => void 0);
|
|
74268
|
+
const self2 = await currentNameOf({ context, client, profile });
|
|
74269
|
+
context.out(`${hookContextOf({ messages, self: self2 })}
|
|
74270
|
+
`);
|
|
74271
|
+
await dropFromSpool({ context, profile, messageIds: messages.map((each) => each.messageId) });
|
|
74272
|
+
return true;
|
|
74273
|
+
}
|
|
74274
|
+
async function release({ context, profile }) {
|
|
74275
|
+
const lock = statePathOf({ context, kind: "waiters", profile });
|
|
74276
|
+
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
74277
|
+
await rm6(lock, { force: true });
|
|
74278
|
+
}
|
|
74279
|
+
async function monitorHook({ context, args }) {
|
|
74280
|
+
const claudePid = await claudePidOf({ context });
|
|
74281
|
+
const held = /* @__PURE__ */ new Set();
|
|
74282
|
+
try {
|
|
74283
|
+
while (claudePid && context.processes.alive(claudePid)) {
|
|
74284
|
+
const profile = await agentProfileHere({ context });
|
|
74285
|
+
const busy = profile ? await deliverOnce({ context, args, claudePid, profile }).catch((error62) => {
|
|
74286
|
+
context.err(`laze: the monitor will try again: ${String(error62)}
|
|
74287
|
+
`);
|
|
74288
|
+
return false;
|
|
74289
|
+
}) : false;
|
|
74290
|
+
if (profile && busy) held.add(profile);
|
|
74291
|
+
if (!busy) await context.sleep(MONITOR_IDLE_MS);
|
|
74292
|
+
}
|
|
74293
|
+
return 0;
|
|
74294
|
+
} finally {
|
|
74295
|
+
for (const profile of held) await release({ context, profile });
|
|
74296
|
+
}
|
|
74297
|
+
}
|
|
74298
|
+
|
|
74034
74299
|
// ../../modules/compute/contract/src/browser-tab.ts
|
|
74035
74300
|
var browserTabSharingSchema = external_exports.enum(["private", "watch", "use"]);
|
|
74036
74301
|
var browserTabActorDefinition = external_exports.object({
|
|
@@ -75512,10 +75777,10 @@ async function computer({ context, args }) {
|
|
|
75512
75777
|
}
|
|
75513
75778
|
|
|
75514
75779
|
// src/services/connect-commands.service.ts
|
|
75515
|
-
import { readFile as
|
|
75780
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
75516
75781
|
|
|
75517
75782
|
// src/services/mcp-gateway.service.ts
|
|
75518
|
-
import { readFile as
|
|
75783
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
75519
75784
|
import { createInterface as createInterface2 } from "node:readline";
|
|
75520
75785
|
var TURN_HEADER = "x-laze-turn";
|
|
75521
75786
|
function serveMcpGateway({
|
|
@@ -75558,7 +75823,7 @@ async function relayMcpLines({
|
|
|
75558
75823
|
const github3 = env.LAZE_GITHUB_CONNECTION;
|
|
75559
75824
|
const url2 = `${profile.url.replace(/\/+$/, "")}/api/connectors/mcp/${encodeURIComponent(profile.agentId)}${github3 ? `?github=${encodeURIComponent(github3)}` : ""}`;
|
|
75560
75825
|
const turnFile = env.LAZE_TURN_FILE;
|
|
75561
|
-
const readTurn = () =>
|
|
75826
|
+
const readTurn = () => readFile12(turnFile, "utf8").then(
|
|
75562
75827
|
(text2) => text2.trim(),
|
|
75563
75828
|
() => ""
|
|
75564
75829
|
);
|
|
@@ -75648,7 +75913,7 @@ async function turnOf({ context }) {
|
|
|
75648
75913
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
75649
75914
|
if (pinned) return pinned;
|
|
75650
75915
|
const file3 = env.LAZE_TURN_FILE;
|
|
75651
|
-
const turn = file3 ? await
|
|
75916
|
+
const turn = file3 ? await readFile13(file3, "utf8").then(
|
|
75652
75917
|
(text2) => text2.trim(),
|
|
75653
75918
|
() => ""
|
|
75654
75919
|
) : "";
|
|
@@ -75706,11 +75971,11 @@ async function connect({
|
|
|
75706
75971
|
}
|
|
75707
75972
|
|
|
75708
75973
|
// src/services/connector-commands.service.ts
|
|
75709
|
-
import { readFile as
|
|
75974
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
75710
75975
|
import { resolve as resolve7 } from "node:path";
|
|
75711
75976
|
|
|
75712
75977
|
// src/services/vault-keychain-commands.service.ts
|
|
75713
|
-
import { readFile as
|
|
75978
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
75714
75979
|
|
|
75715
75980
|
// src/rules/vault-input.rules.ts
|
|
75716
75981
|
function secondsOf(text2) {
|
|
@@ -76021,7 +76286,7 @@ async function secretText({ context, args }) {
|
|
|
76021
76286
|
);
|
|
76022
76287
|
}
|
|
76023
76288
|
const file3 = flagText({ args, name: "from-file" });
|
|
76024
|
-
const text2 = file3 ? await
|
|
76289
|
+
const text2 = file3 ? await readFile14(file3, "utf8") : await context.readStdin();
|
|
76025
76290
|
const trimmed = text2.replace(/\r?\n$/, "");
|
|
76026
76291
|
if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
|
|
76027
76292
|
return trimmed;
|
|
@@ -76219,7 +76484,7 @@ async function keyText({ context, args }) {
|
|
|
76219
76484
|
throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
|
|
76220
76485
|
}
|
|
76221
76486
|
const file3 = flagText({ args, name: "from-file" });
|
|
76222
|
-
const text2 = file3 ? await
|
|
76487
|
+
const text2 = file3 ? await readFile15(resolve7(context.cwd, file3), "utf8") : await context.readStdin();
|
|
76223
76488
|
const trimmed = text2.trim();
|
|
76224
76489
|
if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
|
|
76225
76490
|
return trimmed;
|
|
@@ -76538,8 +76803,8 @@ function nextClock({
|
|
|
76538
76803
|
now,
|
|
76539
76804
|
timeZone
|
|
76540
76805
|
}) {
|
|
76541
|
-
const
|
|
76542
|
-
const at =
|
|
76806
|
+
const local2 = now.toZonedDateTimeISO(timeZone);
|
|
76807
|
+
const at = local2.with({
|
|
76543
76808
|
hour: Number(clock[1]),
|
|
76544
76809
|
minute: Number(clock[2]),
|
|
76545
76810
|
second: 0,
|
|
@@ -76547,7 +76812,7 @@ function nextClock({
|
|
|
76547
76812
|
microsecond: 0,
|
|
76548
76813
|
nanosecond: 0
|
|
76549
76814
|
});
|
|
76550
|
-
const next = Temporal3.ZonedDateTime.compare(at,
|
|
76815
|
+
const next = Temporal3.ZonedDateTime.compare(at, local2) > 0 ? at : at.add({ days: 1 });
|
|
76551
76816
|
return next.toString({ timeZoneName: "never", smallestUnit: "second" });
|
|
76552
76817
|
}
|
|
76553
76818
|
function dndInputOf({
|
|
@@ -76605,8 +76870,8 @@ var DOMAINS_USAGE = `Usage:
|
|
|
76605
76870
|
var printJson4 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
|
|
76606
76871
|
`);
|
|
76607
76872
|
function printDomain(context, row) {
|
|
76608
|
-
const
|
|
76609
|
-
context.out(`${row.domain} ${
|
|
76873
|
+
const join13 = row.autoJoin ? "auto-join on" : "auto-join off";
|
|
76874
|
+
context.out(`${row.domain} ${join13}${row.enforced ? " single sign-on enforced" : ""}
|
|
76610
76875
|
`);
|
|
76611
76876
|
}
|
|
76612
76877
|
async function list4({ context, args }) {
|
|
@@ -76638,8 +76903,8 @@ async function domains({ context, args }) {
|
|
|
76638
76903
|
}
|
|
76639
76904
|
|
|
76640
76905
|
// src/services/feed-commands.service.ts
|
|
76641
|
-
import { readFile as
|
|
76642
|
-
import { resolve as
|
|
76906
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
76907
|
+
import { resolve as resolve9 } from "node:path";
|
|
76643
76908
|
|
|
76644
76909
|
// src/rules/feed-input.rules.ts
|
|
76645
76910
|
function csvCellsOf(line) {
|
|
@@ -76762,11 +77027,638 @@ function feedFlagsOf({ args }) {
|
|
|
76762
77027
|
return { fields: { ...fields, ...snoozeOf(args) }, texts, ...rich ? { rich } : {} };
|
|
76763
77028
|
}
|
|
76764
77029
|
|
|
77030
|
+
// src/services/feed-files.service.ts
|
|
77031
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
77032
|
+
import { basename as basename3, resolve as resolve8 } from "node:path";
|
|
77033
|
+
|
|
77034
|
+
// ../../modules/feed/contract/src/feed.ts
|
|
77035
|
+
var feedAuthorSchemaDefinition = external_exports.object({
|
|
77036
|
+
kind: external_exports.enum(["agent", "person", "system"]),
|
|
77037
|
+
id: external_exports.string().min(1),
|
|
77038
|
+
name: external_exports.string()
|
|
77039
|
+
});
|
|
77040
|
+
var feedAuthorSchema = feedAuthorSchemaDefinition;
|
|
77041
|
+
var feedAgentSchemaDefinition = external_exports.object({ id: external_exports.string().min(1), name: external_exports.string().min(1) });
|
|
77042
|
+
var feedAgentSchema = feedAgentSchemaDefinition;
|
|
77043
|
+
var feedActionSchemaDefinition = external_exports.object({
|
|
77044
|
+
/** Defaults to the label as a slug: "Make it shorter" is `make-it-shorter`. */
|
|
77045
|
+
id: external_exports.string().optional(),
|
|
77046
|
+
label: external_exports.string(),
|
|
77047
|
+
message: external_exports.string(),
|
|
77048
|
+
style: external_exports.enum(["primary", "secondary"]).optional(),
|
|
77049
|
+
/** What the button says once pressed, and the handled line: "Sent". */
|
|
77050
|
+
doneLabel: external_exports.string().optional()
|
|
77051
|
+
});
|
|
77052
|
+
var feedActionSchema = feedActionSchemaDefinition;
|
|
77053
|
+
var feedItemActionSchemaDefinition = external_exports.object({
|
|
77054
|
+
id: external_exports.string(),
|
|
77055
|
+
label: external_exports.string(),
|
|
77056
|
+
message: external_exports.string(),
|
|
77057
|
+
style: external_exports.enum(["primary", "secondary"]),
|
|
77058
|
+
doneLabel: external_exports.string().nullable()
|
|
77059
|
+
});
|
|
77060
|
+
var feedItemActionSchema = feedItemActionSchemaDefinition;
|
|
77061
|
+
var feedLinkSchemaDefinition = external_exports.object({ label: external_exports.string(), url: external_exports.string() });
|
|
77062
|
+
var feedLinkSchema = feedLinkSchemaDefinition;
|
|
77063
|
+
var feedMetricBodySchemaDefinition = external_exports.object({
|
|
77064
|
+
kind: external_exports.literal("metric"),
|
|
77065
|
+
label: external_exports.string(),
|
|
77066
|
+
unit: external_exports.string().default(""),
|
|
77067
|
+
value: external_exports.number(),
|
|
77068
|
+
/** The change since the last reading; up shows green, down red. */
|
|
77069
|
+
delta: external_exports.number().nullable().default(null),
|
|
77070
|
+
bars: external_exports.array(external_exports.object({ label: external_exports.string(), value: external_exports.number() })).default([])
|
|
77071
|
+
});
|
|
77072
|
+
var feedTableBodySchemaDefinition = external_exports.object({
|
|
77073
|
+
kind: external_exports.literal("table"),
|
|
77074
|
+
columns: external_exports.array(external_exports.string()),
|
|
77075
|
+
rows: external_exports.array(external_exports.array(external_exports.string()))
|
|
77076
|
+
});
|
|
77077
|
+
var feedRichBodySchemaDefinition = external_exports.discriminatedUnion("kind", [
|
|
77078
|
+
feedMetricBodySchemaDefinition,
|
|
77079
|
+
feedTableBodySchemaDefinition
|
|
77080
|
+
]);
|
|
77081
|
+
var feedShownRichBodySchemaDefinition = external_exports.union([
|
|
77082
|
+
feedRichBodySchemaDefinition,
|
|
77083
|
+
external_exports.looseObject({ kind: external_exports.string() })
|
|
77084
|
+
]);
|
|
77085
|
+
var FEED_ATTACHMENTS_MAX = 6;
|
|
77086
|
+
var feedAttachmentSchemaDefinition = external_exports.object({
|
|
77087
|
+
id: external_exports.string().min(1),
|
|
77088
|
+
fileName: external_exports.string(),
|
|
77089
|
+
contentType: external_exports.string(),
|
|
77090
|
+
sizeBytes: external_exports.number().int().nonnegative(),
|
|
77091
|
+
width: external_exports.number().int().positive().nullable(),
|
|
77092
|
+
height: external_exports.number().int().positive().nullable()
|
|
77093
|
+
});
|
|
77094
|
+
var feedContentSchemaDefinition = external_exports.object({
|
|
77095
|
+
tag: external_exports.string().default(""),
|
|
77096
|
+
title: external_exports.string(),
|
|
77097
|
+
summary: external_exports.string().nullable().default(null),
|
|
77098
|
+
body: external_exports.string().nullable().default(null),
|
|
77099
|
+
draft: external_exports.string().nullable().default(null),
|
|
77100
|
+
/** Lines above the draft as `Key: value`, such as `To: ACME\nRe: Renewal`. */
|
|
77101
|
+
draftHeader: external_exports.string().nullable().default(null),
|
|
77102
|
+
links: external_exports.array(feedLinkSchema).default([]),
|
|
77103
|
+
actions: external_exports.array(feedActionSchema).default([]),
|
|
77104
|
+
urgent: external_exports.boolean().default(false),
|
|
77105
|
+
/** The handled line once the primary action is taken. */
|
|
77106
|
+
doneLabel: external_exports.string().nullable().default(null),
|
|
77107
|
+
rich: feedRichBodySchemaDefinition.nullable().default(null)
|
|
77108
|
+
});
|
|
77109
|
+
var feedGroupSchema = external_exports.string().trim().min(1).max(80);
|
|
77110
|
+
var feedLabelSchema = external_exports.string().trim().min(1).max(24).transform((label2) => label2.toLowerCase());
|
|
77111
|
+
var feedLabelsSchema = external_exports.array(feedLabelSchema).max(5);
|
|
77112
|
+
var feedDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "a date like 2026-10-14");
|
|
77113
|
+
var feedSnoozeForSchemaDefinition = external_exports.object({
|
|
77114
|
+
userIds: external_exports.array(external_exports.string().min(1)).min(1),
|
|
77115
|
+
/** Null clears an earlier snooze the agent set. */
|
|
77116
|
+
until: external_exports.iso.datetime({ offset: true }).nullable()
|
|
77117
|
+
});
|
|
77118
|
+
var feedSnoozeForSchema = feedSnoozeForSchemaDefinition;
|
|
77119
|
+
var postFeedItemInputSchemaDefinition = external_exports.object({
|
|
77120
|
+
...feedContentSchemaDefinition.shape,
|
|
77121
|
+
workspaceId: external_exports.string().min(1),
|
|
77122
|
+
/** The channel the agent posts from; the item also shows as a card there. */
|
|
77123
|
+
channelId: external_exports.string().min(1).nullable().default(null),
|
|
77124
|
+
/** Who sees the item: the channel's members, or the person who asked. */
|
|
77125
|
+
recipientUserIds: external_exports.array(external_exports.string().min(1)).min(1),
|
|
77126
|
+
/** The recipients are the channel's people, not a subset: someone joining later gets it. */
|
|
77127
|
+
forChannel: external_exports.boolean().default(false),
|
|
77128
|
+
agent: feedAgentSchema,
|
|
77129
|
+
/** Keeps the item under "Coming up" for everyone until then. */
|
|
77130
|
+
showAt: external_exports.iso.datetime({ offset: true }).nullable().default(null),
|
|
77131
|
+
snoozeFor: feedSnoozeForSchema.nullable().default(null),
|
|
77132
|
+
/** The group the card belongs to, and its labels, the group's filter chips. */
|
|
77133
|
+
group: feedGroupSchema.nullable().default(null),
|
|
77134
|
+
labels: feedLabelsSchema.default([]),
|
|
77135
|
+
/** One card per open loop: a second post with the same key updates that card instead. */
|
|
77136
|
+
loop: external_exports.string().trim().min(1).max(120).nullable().default(null),
|
|
77137
|
+
/** The day the agent acts unless a person says stop; the card counts down to it. */
|
|
77138
|
+
autoSendOn: feedDateSchema.nullable().default(null),
|
|
77139
|
+
/** With a loop key: puts the updated card back in front of people who had handled it. */
|
|
77140
|
+
reopen: external_exports.boolean().default(false),
|
|
77141
|
+
/** Files every recipient can open, checked by the feed's key path; a loop update replaces. */
|
|
77142
|
+
attachments: external_exports.array(feedAttachmentSchemaDefinition).max(FEED_ATTACHMENTS_MAX).default([])
|
|
77143
|
+
});
|
|
77144
|
+
var updateFeedItemInputSchemaDefinition = external_exports.object({
|
|
77145
|
+
workspaceId: external_exports.string().min(1),
|
|
77146
|
+
itemId: external_exports.string().min(1),
|
|
77147
|
+
agent: feedAgentSchema,
|
|
77148
|
+
tag: external_exports.string().optional(),
|
|
77149
|
+
title: external_exports.string().optional(),
|
|
77150
|
+
summary: external_exports.string().nullable().optional(),
|
|
77151
|
+
body: external_exports.string().nullable().optional(),
|
|
77152
|
+
draft: external_exports.string().nullable().optional(),
|
|
77153
|
+
draftHeader: external_exports.string().nullable().optional(),
|
|
77154
|
+
rich: feedRichBodySchemaDefinition.nullable().optional(),
|
|
77155
|
+
links: external_exports.array(feedLinkSchema).optional(),
|
|
77156
|
+
actions: external_exports.array(feedActionSchema).optional(),
|
|
77157
|
+
urgent: external_exports.boolean().optional(),
|
|
77158
|
+
doneLabel: external_exports.string().nullable().optional(),
|
|
77159
|
+
showAt: external_exports.iso.datetime({ offset: true }).nullable().optional(),
|
|
77160
|
+
snoozeFor: feedSnoozeForSchema.optional(),
|
|
77161
|
+
group: feedGroupSchema.nullable().optional(),
|
|
77162
|
+
labels: feedLabelsSchema.optional(),
|
|
77163
|
+
/** Null removes the countdown. */
|
|
77164
|
+
autoSendOn: feedDateSchema.nullable().optional(),
|
|
77165
|
+
/** Puts the item back in front of everyone who handled it, without a reply. */
|
|
77166
|
+
reopen: external_exports.boolean().default(false)
|
|
77167
|
+
});
|
|
77168
|
+
var replyFeedItemInputSchemaDefinition = external_exports.object({
|
|
77169
|
+
workspaceId: external_exports.string().min(1),
|
|
77170
|
+
itemId: external_exports.string().min(1),
|
|
77171
|
+
agent: feedAgentSchema,
|
|
77172
|
+
body: external_exports.string(),
|
|
77173
|
+
/** Wakes the item now for everyone who snoozed it. */
|
|
77174
|
+
urgent: external_exports.boolean().default(false)
|
|
77175
|
+
});
|
|
77176
|
+
var feedEntrySchemaDefinition = external_exports.object({
|
|
77177
|
+
id: external_exports.string(),
|
|
77178
|
+
author: feedAuthorSchema,
|
|
77179
|
+
kind: external_exports.enum(["comment", "action", "reply", "note"]),
|
|
77180
|
+
body: external_exports.string(),
|
|
77181
|
+
actionId: external_exports.string().nullable(),
|
|
77182
|
+
/** The pressed action's message, which the agent wrote for its future self. */
|
|
77183
|
+
actionMessage: external_exports.string().nullable(),
|
|
77184
|
+
/** The draft as the person edited it, sent with the action or the comment. */
|
|
77185
|
+
draft: external_exports.string().nullable(),
|
|
77186
|
+
urgent: external_exports.boolean(),
|
|
77187
|
+
createdAt: external_exports.iso.datetime()
|
|
77188
|
+
});
|
|
77189
|
+
var feedEntrySchema = feedEntrySchemaDefinition;
|
|
77190
|
+
var feedApprovalStateSchema = external_exports.enum([
|
|
77191
|
+
"pending",
|
|
77192
|
+
"approved_once",
|
|
77193
|
+
"approved_for_agent",
|
|
77194
|
+
"approved",
|
|
77195
|
+
"denied",
|
|
77196
|
+
"expired"
|
|
77197
|
+
]);
|
|
77198
|
+
var feedApprovalSchemaDefinition = external_exports.object({
|
|
77199
|
+
source: external_exports.enum([
|
|
77200
|
+
"vault",
|
|
77201
|
+
"app_publish",
|
|
77202
|
+
"workspace_access",
|
|
77203
|
+
"agent",
|
|
77204
|
+
"connector_server",
|
|
77205
|
+
"connector_connect",
|
|
77206
|
+
"app_access",
|
|
77207
|
+
"computer",
|
|
77208
|
+
"agent_join"
|
|
77209
|
+
]),
|
|
77210
|
+
requestId: external_exports.string(),
|
|
77211
|
+
/** The app, for an `app_publish` or `app_access` card. */
|
|
77212
|
+
appId: external_exports.string().nullable(),
|
|
77213
|
+
subject: external_exports.string(),
|
|
77214
|
+
action: external_exports.string(),
|
|
77215
|
+
agentId: external_exports.string(),
|
|
77216
|
+
reason: external_exports.string(),
|
|
77217
|
+
why: external_exports.string(),
|
|
77218
|
+
/** The longest lease Allow for this agent may give; null offers only once and deny. */
|
|
77219
|
+
maxLeaseSeconds: external_exports.number().int().positive().nullable(),
|
|
77220
|
+
/** The card's timeout; a publish waits without one. */
|
|
77221
|
+
expiresAt: external_exports.iso.datetime().nullable(),
|
|
77222
|
+
state: feedApprovalStateSchema,
|
|
77223
|
+
answeredByUserId: external_exports.string().nullable(),
|
|
77224
|
+
answeredByName: external_exports.string().nullable(),
|
|
77225
|
+
answeredVia: external_exports.string().nullable(),
|
|
77226
|
+
/** An agent card's exact command, shown as code; null elsewhere. */
|
|
77227
|
+
call: external_exports.string().nullable().default(null),
|
|
77228
|
+
/** How the card ended, as the owning module words it: "Allowed by Ana". */
|
|
77229
|
+
outcome: external_exports.string().nullable().default(null)
|
|
77230
|
+
});
|
|
77231
|
+
var feedApprovalSchema = feedApprovalSchemaDefinition;
|
|
77232
|
+
var feedViewerStateSchemaDefinition = external_exports.object({
|
|
77233
|
+
place: external_exports.enum(["open", "coming_up", "handled"]),
|
|
77234
|
+
/** The agent answered after the person last touched the item. */
|
|
77235
|
+
unread: external_exports.boolean(),
|
|
77236
|
+
/** Back from a snooze or a show-at date, not yet touched. */
|
|
77237
|
+
woke: external_exports.enum(["snooze", "show_at"]).nullable(),
|
|
77238
|
+
snoozedUntil: external_exports.iso.datetime().nullable(),
|
|
77239
|
+
/** The agent that snoozed it for the person, when it was not the person. */
|
|
77240
|
+
snoozedBy: feedAuthorSchema.nullable(),
|
|
77241
|
+
handledAt: external_exports.iso.datetime().nullable(),
|
|
77242
|
+
/** The line under "Handled today". */
|
|
77243
|
+
handledLabel: external_exports.string().nullable(),
|
|
77244
|
+
/** The time the card shows and sorts by. */
|
|
77245
|
+
sortAt: external_exports.iso.datetime(),
|
|
77246
|
+
/** The person joined the item's channel after it was posted. */
|
|
77247
|
+
beforeYouJoined: external_exports.boolean().optional(),
|
|
77248
|
+
/** The item is the person's alone, so they may edit its title and summary. */
|
|
77249
|
+
canEdit: external_exports.boolean().optional()
|
|
77250
|
+
});
|
|
77251
|
+
var feedViewerStateSchema = feedViewerStateSchemaDefinition;
|
|
77252
|
+
var feedItemSchemaDefinition = external_exports.object({
|
|
77253
|
+
id: external_exports.string(),
|
|
77254
|
+
workspaceId: external_exports.string(),
|
|
77255
|
+
kind: external_exports.enum(["item", "approval"]),
|
|
77256
|
+
channelId: external_exports.string().nullable(),
|
|
77257
|
+
author: feedAuthorSchema,
|
|
77258
|
+
tag: external_exports.string(),
|
|
77259
|
+
title: external_exports.string(),
|
|
77260
|
+
summary: external_exports.string().nullable(),
|
|
77261
|
+
body: external_exports.string().nullable(),
|
|
77262
|
+
draft: external_exports.string().nullable(),
|
|
77263
|
+
draftHeader: external_exports.string().nullable(),
|
|
77264
|
+
rich: feedShownRichBodySchemaDefinition.nullable().default(null),
|
|
77265
|
+
attachments: external_exports.array(feedAttachmentSchemaDefinition).default([]),
|
|
77266
|
+
/** A person edited the draft last, so it travels with the next action or comment. */
|
|
77267
|
+
draftEdited: external_exports.boolean(),
|
|
77268
|
+
/** The person who last edited the title or summary, shown as "Edited by". */
|
|
77269
|
+
editedBy: external_exports.string().nullable().optional(),
|
|
77270
|
+
links: external_exports.array(feedLinkSchema),
|
|
77271
|
+
actions: external_exports.array(feedItemActionSchema),
|
|
77272
|
+
urgent: external_exports.boolean(),
|
|
77273
|
+
doneLabel: external_exports.string().nullable(),
|
|
77274
|
+
showAt: external_exports.iso.datetime().nullable(),
|
|
77275
|
+
approval: feedApprovalSchema.nullable(),
|
|
77276
|
+
group: external_exports.string().nullable(),
|
|
77277
|
+
labels: external_exports.array(external_exports.string()),
|
|
77278
|
+
loop: external_exports.string().nullable(),
|
|
77279
|
+
/** How many groups the card has been posted in: 2 shows "Seen 2 times". */
|
|
77280
|
+
groupDays: external_exports.number().int().nonnegative(),
|
|
77281
|
+
/** The day the agent acts unless someone says stop. */
|
|
77282
|
+
autoSendOn: external_exports.string().nullable(),
|
|
77283
|
+
entries: external_exports.array(feedEntrySchema),
|
|
77284
|
+
createdAt: external_exports.iso.datetime(),
|
|
77285
|
+
updatedAt: external_exports.iso.datetime(),
|
|
77286
|
+
lastReplyAt: external_exports.iso.datetime().nullable(),
|
|
77287
|
+
me: feedViewerStateSchema
|
|
77288
|
+
});
|
|
77289
|
+
var feedItemSchema = feedItemSchemaDefinition;
|
|
77290
|
+
var feedGroupSummarySchemaDefinition = external_exports.object({
|
|
77291
|
+
group: external_exports.string(),
|
|
77292
|
+
total: external_exports.number().int().nonnegative(),
|
|
77293
|
+
counts: external_exports.array(external_exports.object({ label: external_exports.string(), count: external_exports.number().int().positive() }))
|
|
77294
|
+
});
|
|
77295
|
+
var feedGroupSummarySchema = feedGroupSummarySchemaDefinition;
|
|
77296
|
+
var feedViewSchemaDefinition = external_exports.object({
|
|
77297
|
+
open: external_exports.array(feedItemSchema),
|
|
77298
|
+
comingUp: external_exports.array(feedItemSchema),
|
|
77299
|
+
handled: external_exports.array(feedItemSchema),
|
|
77300
|
+
/** The sidebar's number: the open cards. */
|
|
77301
|
+
count: external_exports.number().int().nonnegative(),
|
|
77302
|
+
/** When the next snoozed or scheduled card comes back, so the page can refresh then. */
|
|
77303
|
+
nextWakeAt: external_exports.iso.datetime().nullable(),
|
|
77304
|
+
group: feedGroupSummarySchema.nullable()
|
|
77305
|
+
});
|
|
77306
|
+
var feedViewSchema = feedViewSchemaDefinition;
|
|
77307
|
+
var feedCardViewSchemaDefinition = external_exports.discriminatedUnion("for", [
|
|
77308
|
+
external_exports.object({ for: external_exports.literal("you"), item: feedItemSchema }),
|
|
77309
|
+
external_exports.object({ for: external_exports.literal("others") })
|
|
77310
|
+
]);
|
|
77311
|
+
var feedCardViewSchema = feedCardViewSchemaDefinition;
|
|
77312
|
+
var feedAgentItemSchemaDefinition = external_exports.object({
|
|
77313
|
+
item: feedItemSchema.omit({ me: true }),
|
|
77314
|
+
recipientUserIds: external_exports.array(external_exports.string()),
|
|
77315
|
+
/** Person entries newer than the agent's own last reply, as messages ready to act on. */
|
|
77316
|
+
messages: external_exports.array(external_exports.string())
|
|
77317
|
+
});
|
|
77318
|
+
var feedAgentItemSchema = feedAgentItemSchemaDefinition;
|
|
77319
|
+
var itemRef = external_exports.object({ workspaceId: external_exports.string().min(1), itemId: external_exports.string().min(1) });
|
|
77320
|
+
var putBackFeedItemInputSchemaDefinition = external_exports.object({
|
|
77321
|
+
...itemRef.shape,
|
|
77322
|
+
undoEntryId: external_exports.string().min(1).optional()
|
|
77323
|
+
});
|
|
77324
|
+
var putBackFeedItemInputSchema = putBackFeedItemInputSchemaDefinition;
|
|
77325
|
+
var listFeedInputSchemaDefinition = external_exports.object({
|
|
77326
|
+
workspaceId: external_exports.string().min(1),
|
|
77327
|
+
/** The start of the viewer's day, for "Handled today"; the last 24 hours when absent. */
|
|
77328
|
+
handledSince: external_exports.iso.datetime({ offset: true }).optional()
|
|
77329
|
+
});
|
|
77330
|
+
var listFeedInputSchema = listFeedInputSchemaDefinition;
|
|
77331
|
+
var actFeedItemInputSchemaDefinition = external_exports.object({
|
|
77332
|
+
...itemRef.shape,
|
|
77333
|
+
actionId: external_exports.string().min(1),
|
|
77334
|
+
/** The draft as edited in the card, when the person changed it before pressing. */
|
|
77335
|
+
draft: external_exports.string().optional()
|
|
77336
|
+
});
|
|
77337
|
+
var actFeedItemInputSchema = actFeedItemInputSchemaDefinition;
|
|
77338
|
+
var commentFeedItemInputSchemaDefinition = external_exports.object({
|
|
77339
|
+
...itemRef.shape,
|
|
77340
|
+
body: external_exports.string(),
|
|
77341
|
+
draft: external_exports.string().optional()
|
|
77342
|
+
});
|
|
77343
|
+
var commentFeedItemInputSchema = commentFeedItemInputSchemaDefinition;
|
|
77344
|
+
var snoozeFeedItemInputSchemaDefinition = external_exports.object({
|
|
77345
|
+
...itemRef.shape,
|
|
77346
|
+
until: external_exports.iso.datetime({ offset: true })
|
|
77347
|
+
});
|
|
77348
|
+
var snoozeFeedItemInputSchema = snoozeFeedItemInputSchemaDefinition;
|
|
77349
|
+
var saveFeedDraftInputSchemaDefinition = external_exports.object({ ...itemRef.shape, draft: external_exports.string() });
|
|
77350
|
+
var saveFeedDraftInputSchema = saveFeedDraftInputSchemaDefinition;
|
|
77351
|
+
var saveFeedMessageInputSchemaDefinition = external_exports.object({
|
|
77352
|
+
workspaceId: external_exports.string().min(1),
|
|
77353
|
+
messageId: external_exports.string().min(1)
|
|
77354
|
+
});
|
|
77355
|
+
var saveFeedMessageInputSchema = saveFeedMessageInputSchemaDefinition;
|
|
77356
|
+
var editFeedItemInputSchemaDefinition = external_exports.object({
|
|
77357
|
+
...itemRef.shape,
|
|
77358
|
+
title: external_exports.string().min(1).max(200).optional(),
|
|
77359
|
+
summary: external_exports.string().max(300).nullable().optional()
|
|
77360
|
+
}).refine((input2) => input2.title !== void 0 || input2.summary !== void 0, {
|
|
77361
|
+
message: "Name a title or a summary to change"
|
|
77362
|
+
});
|
|
77363
|
+
var editFeedItemInputSchema = editFeedItemInputSchemaDefinition;
|
|
77364
|
+
var answerFeedApprovalInputSchemaDefinition = external_exports.object({
|
|
77365
|
+
...itemRef.shape,
|
|
77366
|
+
answer: external_exports.enum(["approve_once", "approve_for_agent", "deny"]),
|
|
77367
|
+
durationSeconds: external_exports.number().int().positive().optional(),
|
|
77368
|
+
/** Why, or a steer for the agent: one line, at most 500 characters once cleaned. */
|
|
77369
|
+
resolutionNote: external_exports.string().max(4e3).default("")
|
|
77370
|
+
});
|
|
77371
|
+
var answerFeedApprovalInputSchema = answerFeedApprovalInputSchemaDefinition;
|
|
77372
|
+
var decideFeedRequestInputSchemaDefinition = external_exports.object({
|
|
77373
|
+
...itemRef.shape,
|
|
77374
|
+
decision: external_exports.enum(["approved", "denied"])
|
|
77375
|
+
});
|
|
77376
|
+
var decideFeedRequestInputSchema = decideFeedRequestInputSchemaDefinition;
|
|
77377
|
+
var feedPublishDurationSchema = external_exports.enum(["once", "day", "always"]);
|
|
77378
|
+
var decideFeedPublishInputSchemaDefinition = external_exports.object({
|
|
77379
|
+
...decideFeedRequestInputSchemaDefinition.shape,
|
|
77380
|
+
duration: feedPublishDurationSchema.default("once")
|
|
77381
|
+
});
|
|
77382
|
+
var decideFeedPublishInputSchema = decideFeedPublishInputSchemaDefinition;
|
|
77383
|
+
var feedPostByKeyInputSchemaDefinition = external_exports.object({
|
|
77384
|
+
...postFeedItemInputSchemaDefinition.omit({
|
|
77385
|
+
workspaceId: true,
|
|
77386
|
+
agent: true,
|
|
77387
|
+
channelId: true,
|
|
77388
|
+
recipientUserIds: true,
|
|
77389
|
+
attachments: true
|
|
77390
|
+
}).shape,
|
|
77391
|
+
/** Chat attachment ids, uploaded to the item's channel or the agent's DM with its people. */
|
|
77392
|
+
attachmentIds: external_exports.array(external_exports.string().min(1)).max(FEED_ATTACHMENTS_MAX).default([]),
|
|
77393
|
+
/** A channel the agent is in, by id or name; the item also shows as a card there. */
|
|
77394
|
+
channel: external_exports.string().min(1).nullable().default(null),
|
|
77395
|
+
/** Who sees it; empty means the channel's people, or the agent's owner without a channel. */
|
|
77396
|
+
to: external_exports.array(external_exports.string().min(1)).default([]),
|
|
77397
|
+
force: external_exports.boolean().default(false)
|
|
77398
|
+
});
|
|
77399
|
+
var feedUpdateByKeyInputSchemaDefinition = external_exports.object({
|
|
77400
|
+
...updateFeedItemInputSchemaDefinition.omit({ workspaceId: true, agent: true }).shape,
|
|
77401
|
+
/** Post the text as written even when the readability check pushes it back. */
|
|
77402
|
+
force: external_exports.boolean().default(false)
|
|
77403
|
+
});
|
|
77404
|
+
var feedReplyByKeyInputSchemaDefinition = external_exports.object({
|
|
77405
|
+
...replyFeedItemInputSchemaDefinition.omit({ workspaceId: true, agent: true }).shape,
|
|
77406
|
+
/** Post the text as written even when the readability check pushes it back. */
|
|
77407
|
+
force: external_exports.boolean().default(false)
|
|
77408
|
+
});
|
|
77409
|
+
var feedItemByKeySchemaDefinition = external_exports.object({ itemId: external_exports.string().min(1) });
|
|
77410
|
+
var feedGroupSummaryByKeyInputSchemaDefinition = external_exports.object({ group: feedGroupSchema });
|
|
77411
|
+
var feedGroupPointerSchemaDefinition = external_exports.object({
|
|
77412
|
+
group: external_exports.string(),
|
|
77413
|
+
total: external_exports.number().int().nonnegative(),
|
|
77414
|
+
counts: feedGroupSummarySchema.shape.counts,
|
|
77415
|
+
/** "22 things in your Feed: 5 money, 5 promise, 8 decide". */
|
|
77416
|
+
headline: external_exports.string(),
|
|
77417
|
+
/** The feed page filtered to this group, a path on this deployment. */
|
|
77418
|
+
path: external_exports.string(),
|
|
77419
|
+
/** The same page as a full address, for chat. */
|
|
77420
|
+
link: external_exports.string(),
|
|
77421
|
+
/** The top 3 titles in rank order. */
|
|
77422
|
+
top: external_exports.array(external_exports.string()),
|
|
77423
|
+
/** People the push went to: everyone with an open card in this group. */
|
|
77424
|
+
notifiedUserIds: external_exports.array(external_exports.string())
|
|
77425
|
+
});
|
|
77426
|
+
var loopKeySchema = external_exports.string().trim().min(1).max(120);
|
|
77427
|
+
var closeFeedItemInputSchemaDefinition = external_exports.object({
|
|
77428
|
+
workspaceId: external_exports.string().min(1),
|
|
77429
|
+
agent: feedAgentSchema,
|
|
77430
|
+
itemId: external_exports.string().min(1).optional(),
|
|
77431
|
+
loop: loopKeySchema.optional(),
|
|
77432
|
+
/** Why it is done, shown to everyone as "Closed by <agent>: <note>". */
|
|
77433
|
+
note: external_exports.string().trim().min(1).max(500)
|
|
77434
|
+
}).refine((input2) => Boolean(input2.itemId) !== Boolean(input2.loop), {
|
|
77435
|
+
message: "Name the item by its id or by its loop key, not both"
|
|
77436
|
+
});
|
|
77437
|
+
var feedCloseByKeyInputSchemaDefinition = external_exports.object({
|
|
77438
|
+
itemId: external_exports.string().min(1).optional(),
|
|
77439
|
+
loop: loopKeySchema.optional(),
|
|
77440
|
+
note: external_exports.string().trim().min(1).max(500)
|
|
77441
|
+
}).refine((input2) => Boolean(input2.itemId) !== Boolean(input2.loop), {
|
|
77442
|
+
message: "Name the item by its id or by its loop key, not both"
|
|
77443
|
+
});
|
|
77444
|
+
var feedLoopSchemaDefinition = external_exports.object({
|
|
77445
|
+
loop: external_exports.string(),
|
|
77446
|
+
itemId: external_exports.string(),
|
|
77447
|
+
title: external_exports.string(),
|
|
77448
|
+
recipients: external_exports.array(
|
|
77449
|
+
external_exports.object({
|
|
77450
|
+
userId: external_exports.string(),
|
|
77451
|
+
/** The person's name in the workspace; their id when the lookup finds none. */
|
|
77452
|
+
name: external_exports.string(),
|
|
77453
|
+
state: external_exports.enum(["open", "handled", "snoozed"])
|
|
77454
|
+
})
|
|
77455
|
+
),
|
|
77456
|
+
/** The newest post, update, press, comment or reply on the card. */
|
|
77457
|
+
lastActivityAt: external_exports.iso.datetime()
|
|
77458
|
+
});
|
|
77459
|
+
var feedListByKeyInputSchemaDefinition = external_exports.object({
|
|
77460
|
+
handledSince: external_exports.iso.datetime({ offset: true }).optional()
|
|
77461
|
+
});
|
|
77462
|
+
var feedActByKeyInputSchemaDefinition = external_exports.object({
|
|
77463
|
+
itemId: external_exports.string().min(1),
|
|
77464
|
+
actionId: external_exports.string().min(1),
|
|
77465
|
+
draft: external_exports.string().optional()
|
|
77466
|
+
});
|
|
77467
|
+
var feedCommentByKeyInputSchemaDefinition = external_exports.object({
|
|
77468
|
+
itemId: external_exports.string().min(1),
|
|
77469
|
+
body: external_exports.string(),
|
|
77470
|
+
draft: external_exports.string().optional(),
|
|
77471
|
+
/** Post the text as written even when the readability check pushes it back. */
|
|
77472
|
+
force: external_exports.boolean().default(false)
|
|
77473
|
+
});
|
|
77474
|
+
var feedSnoozeByKeyInputSchemaDefinition = external_exports.object({
|
|
77475
|
+
itemId: external_exports.string().min(1),
|
|
77476
|
+
until: external_exports.iso.datetime({ offset: true })
|
|
77477
|
+
});
|
|
77478
|
+
var feedChannelItemsByKeyInputSchemaDefinition = external_exports.object({ channelId: external_exports.string().min(1) });
|
|
77479
|
+
var FeedApi = moduleApi()("feed");
|
|
77480
|
+
var feedFileLinkInputSchemaDefinition = external_exports.object({
|
|
77481
|
+
workspaceId: external_exports.string().min(1),
|
|
77482
|
+
itemId: external_exports.string().min(1),
|
|
77483
|
+
attachmentId: external_exports.string().min(1),
|
|
77484
|
+
variant: external_exports.enum(["original", "thumbnail", "preview"]).default("original"),
|
|
77485
|
+
download: external_exports.boolean().default(false)
|
|
77486
|
+
});
|
|
77487
|
+
var feedFileLinkInputSchema = feedFileLinkInputSchemaDefinition;
|
|
77488
|
+
var feedFileLinkSchemaDefinition = external_exports.object({ url: external_exports.string(), expiresAt: external_exports.iso.datetime() });
|
|
77489
|
+
var feedFileLinkSchema = feedFileLinkSchemaDefinition;
|
|
77490
|
+
var feedTrpc = defineTrpcContract("feed").query("channelItems").withInput(external_exports.object({ workspaceId: external_exports.string().min(1), channelId: external_exports.string().min(1) })).withOutput(external_exports.array(feedAgentItemSchema)).query("list").withInput(listFeedInputSchema).withOutput(feedViewSchema).query("card").withInput(itemRef).withOutput(feedCardViewSchema).query("fileLink").withInput(feedFileLinkInputSchema).withOutput(feedFileLinkSchema).query("count").withInput(external_exports.object({ workspaceId: external_exports.string().min(1) })).withOutput(external_exports.object({ count: external_exports.number().int().nonnegative() })).mutation("act").withInput(actFeedItemInputSchema).withOutput(feedItemSchema).mutation("comment").withInput(commentFeedItemInputSchema).withOutput(feedItemSchema).mutation("done").withInput(itemRef).withOutput(feedItemSchema).mutation("stopAutoSend").withInput(itemRef).withOutput(feedItemSchema).mutation("putBack").withInput(putBackFeedItemInputSchema).withOutput(feedItemSchema).mutation("snooze").withInput(snoozeFeedItemInputSchema).withOutput(feedItemSchema).mutation("unsnooze").withInput(itemRef).withOutput(feedItemSchema).mutation("saveDraft").withInput(saveFeedDraftInputSchema).withOutput(feedItemSchema).mutation("editItem").withInput(editFeedItemInputSchema).withOutput(feedItemSchema).mutation("saveMessage").withInput(saveFeedMessageInputSchema).withOutput(feedItemSchema).mutation("answerApproval").withInput(answerFeedApprovalInputSchema).withOutput(feedItemSchema).mutation("decidePublish").withInput(decideFeedPublishInputSchema).withOutput(feedItemSchema).mutation("decideAccess").withInput(decideFeedRequestInputSchema).withOutput(feedItemSchema).mutation("decideServer").withInput(decideFeedRequestInputSchema).withOutput(feedItemSchema).mutation("decideAppAccess").withInput(decideFeedRequestInputSchema).withOutput(feedItemSchema).mutation("decideComputer").withInput(decideFeedRequestInputSchema).withOutput(feedItemSchema).mutation("decideAgentJoin").withInput(decideFeedRequestInputSchema).withOutput(feedItemSchema).build();
|
|
77491
|
+
var feedUi = uiTokens("feed");
|
|
77492
|
+
var FeedNavSlot = feedUi.component("nav");
|
|
77493
|
+
var FeedChannelCardSlot = feedUi.component("channel-card");
|
|
77494
|
+
|
|
77495
|
+
// ../../modules/feed/contract/src/feed.events.ts
|
|
77496
|
+
var byKind = external_exports.enum(["agent", "person", "system"]);
|
|
77497
|
+
var feedItemPostedPayloadSchemaDefinition = external_exports.object({
|
|
77498
|
+
workspaceId: external_exports.string().min(1),
|
|
77499
|
+
itemId: external_exports.string().min(1),
|
|
77500
|
+
kind: external_exports.enum(["item", "approval"]),
|
|
77501
|
+
channelId: external_exports.string().nullable(),
|
|
77502
|
+
authorKind: byKind,
|
|
77503
|
+
authorId: external_exports.string(),
|
|
77504
|
+
recipientUserIds: external_exports.array(external_exports.string()),
|
|
77505
|
+
showAt: external_exports.iso.datetime().nullable(),
|
|
77506
|
+
at: external_exports.iso.datetime()
|
|
77507
|
+
});
|
|
77508
|
+
var feedItemChangedPayloadSchemaDefinition = external_exports.object({
|
|
77509
|
+
workspaceId: external_exports.string().min(1),
|
|
77510
|
+
itemId: external_exports.string().min(1),
|
|
77511
|
+
changeId: external_exports.string().min(1),
|
|
77512
|
+
change: external_exports.enum([
|
|
77513
|
+
"updated",
|
|
77514
|
+
"acted",
|
|
77515
|
+
"commented",
|
|
77516
|
+
"replied",
|
|
77517
|
+
"done",
|
|
77518
|
+
"put_back",
|
|
77519
|
+
"draft_saved",
|
|
77520
|
+
"edited",
|
|
77521
|
+
"approval_resolved",
|
|
77522
|
+
"closed"
|
|
77523
|
+
]),
|
|
77524
|
+
byKind,
|
|
77525
|
+
byId: external_exports.string(),
|
|
77526
|
+
/** The thread entry the change wrote, for acted, commented and replied. */
|
|
77527
|
+
entryId: external_exports.string().nullable(),
|
|
77528
|
+
/** Written as a reply in the item card's chat thread, so it is already there. */
|
|
77529
|
+
fromThread: external_exports.boolean().optional(),
|
|
77530
|
+
/** The agent the item answers to, so its runtime can pick up the entry. */
|
|
77531
|
+
agentId: external_exports.string(),
|
|
77532
|
+
showAt: external_exports.iso.datetime().nullable(),
|
|
77533
|
+
urgent: external_exports.boolean(),
|
|
77534
|
+
/** The people whose feed holds the item, so their open feeds read it again. */
|
|
77535
|
+
userIds: external_exports.array(external_exports.string()).optional(),
|
|
77536
|
+
at: external_exports.iso.datetime()
|
|
77537
|
+
});
|
|
77538
|
+
var feedItemSnoozedPayloadSchemaDefinition = external_exports.object({
|
|
77539
|
+
workspaceId: external_exports.string().min(1),
|
|
77540
|
+
itemId: external_exports.string().min(1),
|
|
77541
|
+
changeId: external_exports.string().min(1),
|
|
77542
|
+
userId: external_exports.string().min(1),
|
|
77543
|
+
until: external_exports.iso.datetime().nullable(),
|
|
77544
|
+
byKind,
|
|
77545
|
+
byId: external_exports.string(),
|
|
77546
|
+
at: external_exports.iso.datetime()
|
|
77547
|
+
});
|
|
77548
|
+
var feedItemWokePayloadSchemaDefinition = external_exports.object({
|
|
77549
|
+
workspaceId: external_exports.string().min(1),
|
|
77550
|
+
itemId: external_exports.string().min(1),
|
|
77551
|
+
changeId: external_exports.string().min(1),
|
|
77552
|
+
userIds: external_exports.array(external_exports.string()),
|
|
77553
|
+
cause: external_exports.enum(["snooze", "show_at", "urgent_reply"]),
|
|
77554
|
+
at: external_exports.iso.datetime()
|
|
77555
|
+
});
|
|
77556
|
+
var feedWakeStateSchemaDefinition = external_exports.object({
|
|
77557
|
+
workspaceId: external_exports.string(),
|
|
77558
|
+
showAt: external_exports.number().nullable(),
|
|
77559
|
+
snoozes: external_exports.record(external_exports.string(), external_exports.number())
|
|
77560
|
+
});
|
|
77561
|
+
var feedWakeIntentSchemaDefinition = external_exports.object({
|
|
77562
|
+
workspaceId: external_exports.string().min(1),
|
|
77563
|
+
itemId: external_exports.string().min(1)
|
|
77564
|
+
});
|
|
77565
|
+
|
|
77566
|
+
// ../../modules/feed/contract/src/feed.config.ts
|
|
77567
|
+
var feedConfig = Config.define(() => ({ publicBaseUrl }));
|
|
77568
|
+
|
|
77569
|
+
// src/rules/file-types.rules.ts
|
|
77570
|
+
var TYPES = {
|
|
77571
|
+
png: "image/png",
|
|
77572
|
+
jpg: "image/jpeg",
|
|
77573
|
+
jpeg: "image/jpeg",
|
|
77574
|
+
webp: "image/webp",
|
|
77575
|
+
gif: "image/gif",
|
|
77576
|
+
svg: "image/svg+xml",
|
|
77577
|
+
pdf: "application/pdf",
|
|
77578
|
+
txt: "text/plain",
|
|
77579
|
+
md: "text/markdown",
|
|
77580
|
+
csv: "text/csv",
|
|
77581
|
+
json: "application/json",
|
|
77582
|
+
zip: "application/zip"
|
|
77583
|
+
};
|
|
77584
|
+
function contentTypeOf(fileName) {
|
|
77585
|
+
const extension2 = fileName.toLowerCase().split(".").pop() ?? "";
|
|
77586
|
+
return TYPES[extension2] ?? "application/octet-stream";
|
|
77587
|
+
}
|
|
77588
|
+
|
|
77589
|
+
// src/services/feed-files.service.ts
|
|
77590
|
+
async function bytesOf({
|
|
77591
|
+
context,
|
|
77592
|
+
source
|
|
77593
|
+
}) {
|
|
77594
|
+
const file3 = /^https?:\/\//i.test(source.value) ? await downloaded({ context, url: source.value }) : await local({ context, path: source.value });
|
|
77595
|
+
if (source.image && !file3.contentType.startsWith("image/")) {
|
|
77596
|
+
throw new CliUsageError(
|
|
77597
|
+
`--image ${source.value} is not an image (${file3.contentType}); send it with --file`
|
|
77598
|
+
);
|
|
77599
|
+
}
|
|
77600
|
+
return file3;
|
|
77601
|
+
}
|
|
77602
|
+
async function downloaded({ context, url: url2 }) {
|
|
77603
|
+
const response = await context.fetcher(url2);
|
|
77604
|
+
if (!response.ok) throw new CliUsageError(`${url2} answered ${response.status}`);
|
|
77605
|
+
const fileName = basename3(new URL(url2).pathname) || "file";
|
|
77606
|
+
const header = (response.headers.get("content-type") ?? "").split(";")[0]?.trim();
|
|
77607
|
+
return {
|
|
77608
|
+
fileName,
|
|
77609
|
+
contentType: header || contentTypeOf(fileName),
|
|
77610
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
77611
|
+
};
|
|
77612
|
+
}
|
|
77613
|
+
async function local({ context, path }) {
|
|
77614
|
+
const full = resolve8(context.cwd, path);
|
|
77615
|
+
const fileName = basename3(full);
|
|
77616
|
+
return {
|
|
77617
|
+
fileName,
|
|
77618
|
+
contentType: contentTypeOf(fileName),
|
|
77619
|
+
bytes: new Uint8Array(await readFile16(full))
|
|
77620
|
+
};
|
|
77621
|
+
}
|
|
77622
|
+
async function directWith({ client, to }) {
|
|
77623
|
+
const me = await client.get("/api/agents/me");
|
|
77624
|
+
const owner = me.kind === "agent" ? me.agent?.ownerUserId : void 0;
|
|
77625
|
+
const people2 = to.length > 0 ? [...to] : [owner ?? ""].filter(Boolean);
|
|
77626
|
+
if (people2.length === 0) {
|
|
77627
|
+
throw new CliUsageError("Files on an item need --channel, or --to for a team agent");
|
|
77628
|
+
}
|
|
77629
|
+
const detail = await client.post("/api/agents/me/dm", { people: people2 });
|
|
77630
|
+
return detail.id;
|
|
77631
|
+
}
|
|
77632
|
+
async function feedAttachmentIdsOf({
|
|
77633
|
+
context,
|
|
77634
|
+
args,
|
|
77635
|
+
client,
|
|
77636
|
+
channel
|
|
77637
|
+
}) {
|
|
77638
|
+
const sources = [
|
|
77639
|
+
...(args.lists.image ?? []).map((value) => ({ value, image: true })),
|
|
77640
|
+
...(args.lists.file ?? []).map((value) => ({ value, image: false }))
|
|
77641
|
+
];
|
|
77642
|
+
if (sources.length === 0) return [];
|
|
77643
|
+
if (sources.length > FEED_ATTACHMENTS_MAX) {
|
|
77644
|
+
throw new CliUsageError(`An item carries at most ${FEED_ATTACHMENTS_MAX} files`);
|
|
77645
|
+
}
|
|
77646
|
+
const files2 = [];
|
|
77647
|
+
for (const source of sources) files2.push(await bytesOf({ context, source }));
|
|
77648
|
+
const target = channel || await directWith({ client, to: args.lists.to ?? [] });
|
|
77649
|
+
const ids = [];
|
|
77650
|
+
for (const file3 of files2) {
|
|
77651
|
+
ids.push((await uploadFile({ context, client, file: { ...file3, channel: target } })).id);
|
|
77652
|
+
}
|
|
77653
|
+
return ids;
|
|
77654
|
+
}
|
|
77655
|
+
|
|
76765
77656
|
// src/services/feed-commands.service.ts
|
|
76766
77657
|
var USAGE8 = `Usage:
|
|
76767
77658
|
laze feed post <title> [--channel <channel>] [--tag <tag>] [--summary <line>]
|
|
76768
77659
|
[--draft <text|@file>] [--draft-header "To: ...\\nRe: ..."]
|
|
76769
77660
|
[--metric <json|@file.json> | --table <csv|@file.csv>]
|
|
77661
|
+
[--image <path|url>]... [--file <path|url>]... (post only, at most 6)
|
|
76770
77662
|
[--link <label>=<url>]... [--action <label>=<message>]... [--to <userId>]...
|
|
76771
77663
|
[--urgent] [--done-label <line>] [--show-at <ISO time>]
|
|
76772
77664
|
[--snooze-for <userId>... --until <ISO time>]
|
|
@@ -76802,7 +77694,7 @@ async function bodyOf2({
|
|
|
76802
77694
|
flags: flags2
|
|
76803
77695
|
}) {
|
|
76804
77696
|
const body = { ...flags2.fields };
|
|
76805
|
-
const read3 = (source) => "file" in source ?
|
|
77697
|
+
const read3 = (source) => "file" in source ? readFile17(resolve9(context.cwd, source.file), "utf8") : source.text;
|
|
76806
77698
|
for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read3(source);
|
|
76807
77699
|
if (flags2.rich) {
|
|
76808
77700
|
const text2 = await read3(flags2.rich.source);
|
|
@@ -76837,9 +77729,11 @@ async function feedPost({ context, args }) {
|
|
|
76837
77729
|
const channel = flagText({ args, name: "channel" });
|
|
76838
77730
|
const loop = flagText({ args, name: "loop" });
|
|
76839
77731
|
const body = await bodyOf2({ context, flags: flags2 });
|
|
77732
|
+
const attachmentIds = await feedAttachmentIdsOf({ context, args, client, channel });
|
|
76840
77733
|
const posted = await client.post("/api/feed/items", {
|
|
76841
77734
|
...body,
|
|
76842
77735
|
title,
|
|
77736
|
+
...attachmentIds.length > 0 ? { attachmentIds } : {},
|
|
76843
77737
|
...channel ? { channel } : {},
|
|
76844
77738
|
...loop ? { loop } : {},
|
|
76845
77739
|
...loop && args.flags.reopen ? { reopen: true } : {},
|
|
@@ -76962,7 +77856,7 @@ async function textFlag({
|
|
|
76962
77856
|
}) {
|
|
76963
77857
|
const value = flagText({ args, name: name2 });
|
|
76964
77858
|
if (!value.startsWith("@")) return value;
|
|
76965
|
-
return
|
|
77859
|
+
return readFile17(resolve9(context.cwd, value.slice(1)), "utf8");
|
|
76966
77860
|
}
|
|
76967
77861
|
async function feedList({ context, args }) {
|
|
76968
77862
|
const { client } = await signedIn({ context, args });
|
|
@@ -77072,7 +77966,7 @@ async function feed({ context, args }) {
|
|
|
77072
77966
|
}
|
|
77073
77967
|
|
|
77074
77968
|
// src/services/github-commands.service.ts
|
|
77075
|
-
import { readFile as
|
|
77969
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
77076
77970
|
|
|
77077
77971
|
// src/rules/github-signature.rules.ts
|
|
77078
77972
|
var TURN_SEPARATOR = "~";
|
|
@@ -77142,7 +78036,7 @@ var REAL_GH = "/usr/bin/gh";
|
|
|
77142
78036
|
var NOT_SET = "laze: agent_github_not_set: this agent has no GitHub connection. Its owner sets one on the agent's settings page or with `laze agent set-github <agent> <connection>`.";
|
|
77143
78037
|
async function turnFileToken({ env }) {
|
|
77144
78038
|
if (!env.LAZE_TURN_FILE) return "";
|
|
77145
|
-
return
|
|
78039
|
+
return readFile18(env.LAZE_TURN_FILE, "utf8").then(
|
|
77146
78040
|
(text2) => text2.trim(),
|
|
77147
78041
|
() => ""
|
|
77148
78042
|
);
|
|
@@ -77176,7 +78070,7 @@ async function githubGh({
|
|
|
77176
78070
|
args: args.rest,
|
|
77177
78071
|
agentName: profile.name ?? "An agent",
|
|
77178
78072
|
threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
|
|
77179
|
-
readBodyFile: (path) => path === "-" ? context.readStdin() :
|
|
78073
|
+
readBodyFile: (path) => path === "-" ? context.readStdin() : readFile18(path, "utf8")
|
|
77180
78074
|
});
|
|
77181
78075
|
return context.runCommand({
|
|
77182
78076
|
command: [REAL_GH, ...ghArgs],
|
|
@@ -77275,7 +78169,7 @@ async function setAgentGithub({
|
|
|
77275
78169
|
}
|
|
77276
78170
|
|
|
77277
78171
|
// src/services/history-commands.service.ts
|
|
77278
|
-
import { readFile as
|
|
78172
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
77279
78173
|
|
|
77280
78174
|
// src/rules/history-format.rules.ts
|
|
77281
78175
|
function timeOf2(iso) {
|
|
@@ -77371,7 +78265,7 @@ async function turnTokenOf3({ context }) {
|
|
|
77371
78265
|
const pinned = env.LAZE_TURN_TOKEN?.trim();
|
|
77372
78266
|
if (pinned) return pinned;
|
|
77373
78267
|
if (!env.LAZE_TURN_FILE) return "";
|
|
77374
|
-
return
|
|
78268
|
+
return readFile19(env.LAZE_TURN_FILE, "utf8").then(
|
|
77375
78269
|
(text2) => text2.trim(),
|
|
77376
78270
|
() => ""
|
|
77377
78271
|
);
|
|
@@ -77563,19 +78457,19 @@ async function ip({ context, args }) {
|
|
|
77563
78457
|
}
|
|
77564
78458
|
|
|
77565
78459
|
// src/services/join-commands.service.ts
|
|
77566
|
-
import { mkdir as
|
|
77567
|
-
import { dirname as
|
|
78460
|
+
import { mkdir as mkdir11, readFile as readFile20, rename as rename4, rm as rm7, writeFile as writeFile12 } from "node:fs/promises";
|
|
78461
|
+
import { dirname as dirname10, join as join10 } from "node:path";
|
|
77568
78462
|
var DEFAULT_WAIT_SECONDS = 100;
|
|
77569
78463
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
77570
78464
|
function pendingPathOf({ context }) {
|
|
77571
|
-
return
|
|
78465
|
+
return join10(dirname10(context.environment.configPath), "join", "pending.json");
|
|
77572
78466
|
}
|
|
77573
78467
|
async function readPending({
|
|
77574
78468
|
context,
|
|
77575
78469
|
url: url2,
|
|
77576
78470
|
args
|
|
77577
78471
|
}) {
|
|
77578
|
-
const pending = await
|
|
78472
|
+
const pending = await readFile20(pendingPathOf({ context }), "utf8").then(
|
|
77579
78473
|
(text2) => JSON.parse(text2),
|
|
77580
78474
|
() => void 0
|
|
77581
78475
|
);
|
|
@@ -77585,13 +78479,13 @@ async function readPending({
|
|
|
77585
78479
|
}
|
|
77586
78480
|
async function keepPending({ context, pending }) {
|
|
77587
78481
|
const path = pendingPathOf({ context });
|
|
77588
|
-
await
|
|
78482
|
+
await mkdir11(dirname10(path), { recursive: true, mode: 448 });
|
|
77589
78483
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
77590
|
-
await
|
|
78484
|
+
await writeFile12(temporary, JSON.stringify(pending), { mode: 384 });
|
|
77591
78485
|
await rename4(temporary, path);
|
|
77592
78486
|
}
|
|
77593
78487
|
async function dropPending({ context }) {
|
|
77594
|
-
await
|
|
78488
|
+
await rm7(pendingPathOf({ context }), { force: true });
|
|
77595
78489
|
}
|
|
77596
78490
|
function waitSecondsOf2({ args }) {
|
|
77597
78491
|
const raw = flagText({ args, name: "timeout" });
|
|
@@ -77905,9 +78799,9 @@ function machineAccessCommand(name2) {
|
|
|
77905
78799
|
|
|
77906
78800
|
// src/services/vault-commands.service.ts
|
|
77907
78801
|
import { createHash } from "node:crypto";
|
|
77908
|
-
import { mkdir as
|
|
78802
|
+
import { mkdir as mkdir12, readFile as readFile21, rm as rm8, writeFile as writeFile13 } from "node:fs/promises";
|
|
77909
78803
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
77910
|
-
import { dirname as
|
|
78804
|
+
import { dirname as dirname11, join as join11 } from "node:path";
|
|
77911
78805
|
var USAGE9 = `Usage: laze vault run <connection> --reason "<one plain sentence>" [--wait <s>] -- <command> [args...]
|
|
77912
78806
|
Runs the command with the connection's values in its environment, on a Laze agent's computer
|
|
77913
78807
|
or on a machine it runs on.`;
|
|
@@ -77946,7 +78840,7 @@ async function turnTokenOf4({
|
|
|
77946
78840
|
if (pinned) return pinned;
|
|
77947
78841
|
if (!turnFile) throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
77948
78842
|
try {
|
|
77949
|
-
return (await
|
|
78843
|
+
return (await readFile21(turnFile, "utf8")).trim();
|
|
77950
78844
|
} catch {
|
|
77951
78845
|
throw new CliUsageError(`${command} works only during an agent's turn`);
|
|
77952
78846
|
}
|
|
@@ -77956,11 +78850,11 @@ function runKeyPathOf({
|
|
|
77956
78850
|
connection
|
|
77957
78851
|
}) {
|
|
77958
78852
|
const name2 = createHash("sha256").update(connection).digest("hex");
|
|
77959
|
-
const base = turnFile ?
|
|
77960
|
-
return
|
|
78853
|
+
const base = turnFile ? dirname11(turnFile) : join11(tmpdir2(), "laze-vault");
|
|
78854
|
+
return join11(base, "vault-run-keys", `${name2}.json`);
|
|
77961
78855
|
}
|
|
77962
78856
|
async function runKeyAt({ path }) {
|
|
77963
|
-
const saved3 = await
|
|
78857
|
+
const saved3 = await readFile21(path, "utf8").then(
|
|
77964
78858
|
(text2) => JSON.parse(text2),
|
|
77965
78859
|
() => void 0
|
|
77966
78860
|
);
|
|
@@ -77970,8 +78864,8 @@ async function runKeyAt({ path }) {
|
|
|
77970
78864
|
}
|
|
77971
78865
|
const fresh = await generateEcdhKeys();
|
|
77972
78866
|
const jwk = await globalThis.crypto.subtle.exportKey("jwk", fresh.privateKey);
|
|
77973
|
-
await
|
|
77974
|
-
await
|
|
78867
|
+
await mkdir12(dirname11(path), { recursive: true, mode: 448 });
|
|
78868
|
+
await writeFile13(path, JSON.stringify({ publicKey: fresh.publicKey, privateKey: jwk }), {
|
|
77975
78869
|
mode: 384
|
|
77976
78870
|
});
|
|
77977
78871
|
return fresh;
|
|
@@ -78035,17 +78929,17 @@ async function releaseOf({ response }) {
|
|
|
78035
78929
|
return JSON.parse(text2);
|
|
78036
78930
|
}
|
|
78037
78931
|
async function envOf({
|
|
78038
|
-
release,
|
|
78932
|
+
release: release2,
|
|
78039
78933
|
run: run3
|
|
78040
78934
|
}) {
|
|
78041
|
-
if (!
|
|
78935
|
+
if (!release2.sealed) return release2.env;
|
|
78042
78936
|
const sealed = await openRunRelease({
|
|
78043
|
-
release:
|
|
78937
|
+
release: release2.sealed,
|
|
78044
78938
|
runPrivateKey: run3.privateKey,
|
|
78045
78939
|
runPublicKey: run3.publicKey,
|
|
78046
|
-
requestId:
|
|
78940
|
+
requestId: release2.sealed.requestId
|
|
78047
78941
|
});
|
|
78048
|
-
return { ...
|
|
78942
|
+
return { ...release2.env, ...sealed };
|
|
78049
78943
|
}
|
|
78050
78944
|
function deadlineOf({ args, nowMs }) {
|
|
78051
78945
|
const wait = flagText({ args, name: "wait" }) || (args.flags.wait === true ? args.words[3] : "");
|
|
@@ -78061,24 +78955,24 @@ async function untilAnswered({
|
|
|
78061
78955
|
headers,
|
|
78062
78956
|
deadline
|
|
78063
78957
|
}) {
|
|
78064
|
-
let
|
|
78065
|
-
while (
|
|
78958
|
+
let release2 = first;
|
|
78959
|
+
while (release2.outcome === "ask") {
|
|
78066
78960
|
if (context.nowMs() + POLL_MS > deadline) {
|
|
78067
|
-
context.err(`${
|
|
78961
|
+
context.err(`${release2.message}. Not approved yet; ask again later.
|
|
78068
78962
|
`);
|
|
78069
78963
|
return "capped";
|
|
78070
78964
|
}
|
|
78071
|
-
if (
|
|
78072
|
-
context.err(`${
|
|
78965
|
+
if (release2 === first) {
|
|
78966
|
+
context.err(`${release2.message}. Waiting for an answer (cards expire after 12 hours)...
|
|
78073
78967
|
`);
|
|
78074
78968
|
}
|
|
78075
78969
|
await context.sleep(POLL_MS);
|
|
78076
|
-
const url2 = `${origin}/vault/release/${encodeURIComponent(
|
|
78077
|
-
|
|
78970
|
+
const url2 = `${origin}/vault/release/${encodeURIComponent(release2.requestId)}`;
|
|
78971
|
+
release2 = await releaseOf({
|
|
78078
78972
|
response: await reach({ context, url: url2, init: { method: "GET", headers } })
|
|
78079
78973
|
});
|
|
78080
78974
|
}
|
|
78081
|
-
return
|
|
78975
|
+
return release2;
|
|
78082
78976
|
}
|
|
78083
78977
|
async function vaultRelease({
|
|
78084
78978
|
context,
|
|
@@ -78098,7 +78992,7 @@ async function vaultRelease({
|
|
|
78098
78992
|
const keyPath = runKeyPathOf({ turnFile, connection });
|
|
78099
78993
|
const run3 = await runKeyAt({ path: keyPath });
|
|
78100
78994
|
const body = JSON.stringify({ connection, reason, command, recipient: run3.publicKey });
|
|
78101
|
-
let
|
|
78995
|
+
let release2;
|
|
78102
78996
|
try {
|
|
78103
78997
|
const first = await releaseOf({
|
|
78104
78998
|
response: await reach({
|
|
@@ -78107,23 +79001,23 @@ async function vaultRelease({
|
|
|
78107
79001
|
init: { method: "POST", headers: { ...headers, "content-type": "application/json" }, body }
|
|
78108
79002
|
})
|
|
78109
79003
|
});
|
|
78110
|
-
|
|
79004
|
+
release2 = await untilAnswered({ context, first, origin: proxy.origin, headers, deadline });
|
|
78111
79005
|
} catch (error62) {
|
|
78112
79006
|
if (!(error62 instanceof ServerGoneError)) throw error62;
|
|
78113
79007
|
context.err(`${error62.message}. Run the command again to keep waiting.
|
|
78114
79008
|
`);
|
|
78115
79009
|
return { exitCode: 75 };
|
|
78116
79010
|
}
|
|
78117
|
-
if (
|
|
78118
|
-
if (
|
|
78119
|
-
await
|
|
78120
|
-
context.err(`${
|
|
79011
|
+
if (release2 === "capped") return { exitCode: 75 };
|
|
79012
|
+
if (release2.outcome === "deny") {
|
|
79013
|
+
await rm8(keyPath, { force: true });
|
|
79014
|
+
context.err(`${release2.message}
|
|
78121
79015
|
`);
|
|
78122
|
-
return { exitCode:
|
|
79016
|
+
return { exitCode: release2.exitCode || 1 };
|
|
78123
79017
|
}
|
|
78124
|
-
const values = await envOf({ release, run: run3 });
|
|
78125
|
-
await
|
|
78126
|
-
if (
|
|
79018
|
+
const values = await envOf({ release: release2, run: run3 });
|
|
79019
|
+
await rm8(keyPath, { force: true });
|
|
79020
|
+
if (release2.message) context.err(`${release2.message}
|
|
78127
79021
|
`);
|
|
78128
79022
|
return { env: values };
|
|
78129
79023
|
}
|
|
@@ -78642,14 +79536,14 @@ async function serveMcp({
|
|
|
78642
79536
|
}
|
|
78643
79537
|
|
|
78644
79538
|
// src/services/mount-files.service.ts
|
|
78645
|
-
import { mkdir as
|
|
78646
|
-
import { dirname as
|
|
79539
|
+
import { mkdir as mkdir13, readFile as readFile22, rm as rm9, writeFile as writeFile14 } from "node:fs/promises";
|
|
79540
|
+
import { dirname as dirname12, relative as relative4, resolve as resolve10 } from "node:path";
|
|
78647
79541
|
async function textArgument({
|
|
78648
79542
|
context,
|
|
78649
79543
|
value
|
|
78650
79544
|
}) {
|
|
78651
79545
|
if (value === "-") return context.readStdin();
|
|
78652
|
-
if (value.startsWith("@")) return
|
|
79546
|
+
if (value.startsWith("@")) return readFile22(resolve10(context.cwd, value.slice(1)), "utf8");
|
|
78653
79547
|
return value;
|
|
78654
79548
|
}
|
|
78655
79549
|
function turnChannel({ context, args }) {
|
|
@@ -78661,16 +79555,16 @@ async function writeMount({
|
|
|
78661
79555
|
folder,
|
|
78662
79556
|
files: files2
|
|
78663
79557
|
}) {
|
|
78664
|
-
const root =
|
|
78665
|
-
await
|
|
78666
|
-
await
|
|
79558
|
+
const root = resolve10(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
79559
|
+
await rm9(root, { recursive: true, force: true });
|
|
79560
|
+
await mkdir13(root, { recursive: true });
|
|
78667
79561
|
for (const file3 of files2) {
|
|
78668
|
-
const target =
|
|
79562
|
+
const target = resolve10(root, file3.path);
|
|
78669
79563
|
const inside = relative4(root, target);
|
|
78670
79564
|
if (!inside || inside.startsWith(".."))
|
|
78671
79565
|
throw new Error(`Refusing to write outside ${root}: ${file3.path}`);
|
|
78672
|
-
await
|
|
78673
|
-
await
|
|
79566
|
+
await mkdir13(dirname12(target), { recursive: true });
|
|
79567
|
+
await writeFile14(target, file3.content);
|
|
78674
79568
|
}
|
|
78675
79569
|
return root;
|
|
78676
79570
|
}
|
|
@@ -79649,8 +80543,8 @@ async function schedule({ context, args }) {
|
|
|
79649
80543
|
}
|
|
79650
80544
|
|
|
79651
80545
|
// src/services/skill-commands.service.ts
|
|
79652
|
-
import { readdir as readdir3, readFile as
|
|
79653
|
-
import { join as
|
|
80546
|
+
import { readdir as readdir3, readFile as readFile23 } from "node:fs/promises";
|
|
80547
|
+
import { join as join12, relative as relative5, resolve as resolve11 } from "node:path";
|
|
79654
80548
|
var USAGE15 = `Usage:
|
|
79655
80549
|
laze skill list [--agent <agentId>]
|
|
79656
80550
|
laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
|
|
@@ -79671,8 +80565,8 @@ async function folderFiles({ root }) {
|
|
|
79671
80565
|
const files2 = [];
|
|
79672
80566
|
for (const entry of entries) {
|
|
79673
80567
|
if (!entry.isFile()) continue;
|
|
79674
|
-
const full =
|
|
79675
|
-
files2.push({ path: relative5(root, full), content: await
|
|
80568
|
+
const full = join12(entry.parentPath, entry.name);
|
|
80569
|
+
files2.push({ path: relative5(root, full), content: await readFile23(full, "utf8") });
|
|
79676
80570
|
}
|
|
79677
80571
|
return files2.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
79678
80572
|
}
|
|
@@ -79703,7 +80597,7 @@ async function skillInstall({ context, args }) {
|
|
|
79703
80597
|
if (!catalogueId === !from) throw new CliUsageError(USAGE15);
|
|
79704
80598
|
const name2 = flagText({ args, name: "as" });
|
|
79705
80599
|
const agent2 = flagText({ args, name: "agent" });
|
|
79706
|
-
const files2 = from ? await folderFiles({ root:
|
|
80600
|
+
const files2 = from ? await folderFiles({ root: resolve11(context.cwd, from) }) : void 0;
|
|
79707
80601
|
const { client } = await signedIn({ context, args });
|
|
79708
80602
|
const installed = await client.post("/api/skills/install", {
|
|
79709
80603
|
...catalogueId ? { catalogueId } : {},
|
|
@@ -79770,7 +80664,7 @@ async function skillUpdate({ context, args }) {
|
|
|
79770
80664
|
if (!name2 || !newName && description === void 0 && !skillMdFile) {
|
|
79771
80665
|
throw new CliUsageError(USAGE15);
|
|
79772
80666
|
}
|
|
79773
|
-
const skillMd = skillMdFile ? await
|
|
80667
|
+
const skillMd = skillMdFile ? await readFile23(resolve11(context.cwd, skillMdFile), "utf8") : void 0;
|
|
79774
80668
|
const { client } = await signedIn({ context, args });
|
|
79775
80669
|
const updated = await client.post("/api/skills/update", {
|
|
79776
80670
|
name: name2,
|
|
@@ -79816,8 +80710,8 @@ async function skill({ context, args }) {
|
|
|
79816
80710
|
}
|
|
79817
80711
|
|
|
79818
80712
|
// src/services/slack-commands.service.ts
|
|
79819
|
-
import { readFile as
|
|
79820
|
-
import { resolve as
|
|
80713
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
80714
|
+
import { resolve as resolve12 } from "node:path";
|
|
79821
80715
|
var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
|
|
79822
80716
|
laze slack overview connected Slack workspaces, mirrors, your link
|
|
79823
80717
|
laze slack link-prompts Slack workspaces you have not linked yet
|
|
@@ -79864,7 +80758,7 @@ async function secretLines({ context, args }) {
|
|
|
79864
80758
|
throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
|
|
79865
80759
|
}
|
|
79866
80760
|
const file3 = flagText({ args, name: "from-file" });
|
|
79867
|
-
const text2 = file3 ? await
|
|
80761
|
+
const text2 = file3 ? await readFile24(resolve12(context.cwd, file3), "utf8") : await context.readStdin();
|
|
79868
80762
|
return text2.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
79869
80763
|
}
|
|
79870
80764
|
async function secretsOf({
|
|
@@ -80168,7 +81062,7 @@ async function slack({
|
|
|
80168
81062
|
}
|
|
80169
81063
|
|
|
80170
81064
|
// src/services/sso-commands.service.ts
|
|
80171
|
-
import { readFile as
|
|
81065
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
80172
81066
|
var SSO_USAGE = `Usage:
|
|
80173
81067
|
laze sso domains claimed domains and how each signs in (admins)
|
|
80174
81068
|
laze sso claim <domain> the TXT record that proves the domain
|
|
@@ -80255,7 +81149,7 @@ function refuseSecretFlags({ args }) {
|
|
|
80255
81149
|
}
|
|
80256
81150
|
async function clientSecretOf({ context, args }) {
|
|
80257
81151
|
const file3 = flagText({ args, name: "from-file" });
|
|
80258
|
-
const text2 = file3 ? await
|
|
81152
|
+
const text2 = file3 ? await readFile25(file3, "utf8") : await context.readStdin();
|
|
80259
81153
|
const secret = text2.trim();
|
|
80260
81154
|
if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
|
|
80261
81155
|
return secret;
|
|
@@ -80588,8 +81482,8 @@ async function vaultScrub({ context, args }) {
|
|
|
80588
81482
|
}
|
|
80589
81483
|
|
|
80590
81484
|
// src/services/whatsapp-business-commands.service.ts
|
|
80591
|
-
import { readFile as
|
|
80592
|
-
import { resolve as
|
|
81485
|
+
import { readFile as readFile26 } from "node:fs/promises";
|
|
81486
|
+
import { resolve as resolve13 } from "node:path";
|
|
80593
81487
|
|
|
80594
81488
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
|
|
80595
81489
|
var whatsappBusinessCategorySchema = external_exports.enum([
|
|
@@ -80613,8 +81507,8 @@ var quoteDefinition = external_exports.object({
|
|
|
80613
81507
|
priceUsd: external_exports.number().nonnegative()
|
|
80614
81508
|
});
|
|
80615
81509
|
var whatsappBusinessQuoteSchema = quoteDefinition;
|
|
80616
|
-
function whatsappBusinessQuoteLine({ quote:
|
|
80617
|
-
return `${
|
|
81510
|
+
function whatsappBusinessQuoteLine({ quote: quote4 }) {
|
|
81511
|
+
return `${quote4.market}, ${quote4.category}: ${quote4.priceUsd.toFixed(4)} USD`;
|
|
80618
81512
|
}
|
|
80619
81513
|
|
|
80620
81514
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.ts
|
|
@@ -81008,7 +81902,7 @@ async function secretsOf2({ context, args }) {
|
|
|
81008
81902
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
81009
81903
|
if (fromConnection) return { fromConnection };
|
|
81010
81904
|
const file3 = flagText({ args, name: "from-file" });
|
|
81011
|
-
const text2 = file3 ? await
|
|
81905
|
+
const text2 = file3 ? await readFile26(resolve13(context.cwd, file3), "utf8") : await context.readStdin();
|
|
81012
81906
|
const lines = text2.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
81013
81907
|
if (lines.length !== 2) {
|
|
81014
81908
|
throw new CliUsageError(
|
|
@@ -81209,8 +82103,8 @@ async function whatsappBusiness({
|
|
|
81209
82103
|
}
|
|
81210
82104
|
|
|
81211
82105
|
// src/services/whatsapp-pairing-commands.service.ts
|
|
81212
|
-
import { writeFile as
|
|
81213
|
-
import { resolve as
|
|
82106
|
+
import { writeFile as writeFile15 } from "node:fs/promises";
|
|
82107
|
+
import { resolve as resolve14 } from "node:path";
|
|
81214
82108
|
var WHATSAPP_PAIRING_USAGE = [
|
|
81215
82109
|
" laze whatsapp pair <machine> [--qr <file.svg>] link WhatsApp on your machine; scan the code (owner)",
|
|
81216
82110
|
" laze whatsapp pairing <pairing-id> [--qr <file.svg>] where the linking stands, with a fresh code",
|
|
@@ -81229,8 +82123,8 @@ function svgOf(dataUrl) {
|
|
|
81229
82123
|
return decodeURIComponent(body);
|
|
81230
82124
|
}
|
|
81231
82125
|
async function report({ context, args, pairing: pairing2 }) {
|
|
81232
|
-
const qrFile = pairing2.qrSvg ?
|
|
81233
|
-
if (qrFile && pairing2.qrSvg) await
|
|
82126
|
+
const qrFile = pairing2.qrSvg ? resolve14(context.cwd, flagText({ args, name: "qr", fallback: "whatsapp-qr.svg" })) : null;
|
|
82127
|
+
if (qrFile && pairing2.qrSvg) await writeFile15(qrFile, svgOf(pairing2.qrSvg), "utf8");
|
|
81234
82128
|
if (args.flags.json) return context.out(`${JSON.stringify({ ...pairing2, qrFile }, null, 2)}
|
|
81235
82129
|
`);
|
|
81236
82130
|
context.out(`${pairing2.pairingId} ${pairing2.state}
|
|
@@ -81589,8 +82483,8 @@ async function flags({ context, args }) {
|
|
|
81589
82483
|
}
|
|
81590
82484
|
|
|
81591
82485
|
// src/services/workspace-commands.service.ts
|
|
81592
|
-
import { readFile as
|
|
81593
|
-
import { resolve as
|
|
82486
|
+
import { readFile as readFile27 } from "node:fs/promises";
|
|
82487
|
+
import { resolve as resolve15 } from "node:path";
|
|
81594
82488
|
var ROLE_NAMES2 = {
|
|
81595
82489
|
OWNER: "Owner",
|
|
81596
82490
|
ADMIN: "Admin",
|
|
@@ -81772,7 +82666,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
|
|
|
81772
82666
|
async function readLogo({ context, file: file3 }) {
|
|
81773
82667
|
let bytes;
|
|
81774
82668
|
try {
|
|
81775
|
-
bytes = new Uint8Array(await
|
|
82669
|
+
bytes = new Uint8Array(await readFile27(resolve15(context.cwd, file3)));
|
|
81776
82670
|
} catch {
|
|
81777
82671
|
throw new CliUsageError(`No file to read at ${file3}.`);
|
|
81778
82672
|
}
|
|
@@ -82269,6 +83163,8 @@ var COMMANDS3 = {
|
|
|
82269
83163
|
"hook stop": stopHook,
|
|
82270
83164
|
"hook wait": waitHook,
|
|
82271
83165
|
"hook pre-tool": preToolHook,
|
|
83166
|
+
"hook monitor": monitorHook,
|
|
83167
|
+
plugin,
|
|
82272
83168
|
adopt: adoptCodex,
|
|
82273
83169
|
feed,
|
|
82274
83170
|
schedule,
|
|
@@ -82415,8 +83311,8 @@ async function runCli({
|
|
|
82415
83311
|
// src/services/processes.service.ts
|
|
82416
83312
|
import { execFile as execFile2, spawn as spawn4 } from "node:child_process";
|
|
82417
83313
|
import { mkdirSync, openSync } from "node:fs";
|
|
82418
|
-
import { readFile as
|
|
82419
|
-
import { dirname as
|
|
83314
|
+
import { readFile as readFile28, readlink } from "node:fs/promises";
|
|
83315
|
+
import { dirname as dirname13 } from "node:path";
|
|
82420
83316
|
import { promisify as promisify2 } from "node:util";
|
|
82421
83317
|
var run2 = promisify2(execFile2);
|
|
82422
83318
|
function alive(pid) {
|
|
@@ -82429,14 +83325,14 @@ function alive(pid) {
|
|
|
82429
83325
|
}
|
|
82430
83326
|
}
|
|
82431
83327
|
async function argsOf(pid) {
|
|
82432
|
-
const raw = await
|
|
83328
|
+
const raw = await readFile28(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
|
|
82433
83329
|
if (raw) return raw.split("\0").filter(Boolean);
|
|
82434
83330
|
const listed = await run2("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
|
|
82435
83331
|
const line = listed?.stdout.trim();
|
|
82436
83332
|
return line ? line.split(/\s+/) : void 0;
|
|
82437
83333
|
}
|
|
82438
83334
|
async function parentOf(pid) {
|
|
82439
|
-
const stat2 = await
|
|
83335
|
+
const stat2 = await readFile28(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
82440
83336
|
const fromStat = stat2 ? Number(stat2.slice(stat2.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
|
|
82441
83337
|
if (fromStat > 0) return fromStat;
|
|
82442
83338
|
const listed = await run2("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
|
|
@@ -82453,7 +83349,7 @@ async function cwdOf(pid) {
|
|
|
82453
83349
|
return line ? line.slice(1) : void 0;
|
|
82454
83350
|
}
|
|
82455
83351
|
function spawnDetached({ argv, logPath }) {
|
|
82456
|
-
mkdirSync(
|
|
83352
|
+
mkdirSync(dirname13(logPath), { recursive: true, mode: 448 });
|
|
82457
83353
|
const log = openSync(logPath, "a", 384);
|
|
82458
83354
|
const [program = "", ...rest] = argv;
|
|
82459
83355
|
const child = spawn4(program, rest, { detached: true, stdio: ["ignore", log, log] });
|
|
@@ -82545,15 +83441,15 @@ function terminalAsk() {
|
|
|
82545
83441
|
};
|
|
82546
83442
|
}
|
|
82547
83443
|
function sleep(ms, signal) {
|
|
82548
|
-
return new Promise((
|
|
82549
|
-
if (signal?.aborted) return
|
|
83444
|
+
return new Promise((resolve16) => {
|
|
83445
|
+
if (signal?.aborted) return resolve16();
|
|
82550
83446
|
const stop2 = () => {
|
|
82551
83447
|
clearTimeout(timer);
|
|
82552
|
-
|
|
83448
|
+
resolve16();
|
|
82553
83449
|
};
|
|
82554
83450
|
const timer = setTimeout(() => {
|
|
82555
83451
|
signal?.removeEventListener("abort", stop2);
|
|
82556
|
-
|
|
83452
|
+
resolve16();
|
|
82557
83453
|
}, ms);
|
|
82558
83454
|
signal?.addEventListener("abort", stop2, { once: true });
|
|
82559
83455
|
});
|