@lazehq/cli 0.1.125 → 0.1.127
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 +1040 -902
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -849,9 +849,9 @@ var require_node_gyp_build = __commonJS({
|
|
|
849
849
|
var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
|
|
850
850
|
if (debug) return debug;
|
|
851
851
|
}
|
|
852
|
-
var prebuild =
|
|
852
|
+
var prebuild = resolve27(dir);
|
|
853
853
|
if (prebuild) return prebuild;
|
|
854
|
-
var nearby =
|
|
854
|
+
var nearby = resolve27(path.dirname(process.execPath));
|
|
855
855
|
if (nearby) return nearby;
|
|
856
856
|
var target = [
|
|
857
857
|
"platform=" + platform,
|
|
@@ -867,7 +867,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
867
867
|
// eslint-disable-line
|
|
868
868
|
].filter(Boolean).join(" ");
|
|
869
869
|
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
870
|
-
function
|
|
870
|
+
function resolve27(dir2) {
|
|
871
871
|
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
872
872
|
var tuple2 = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
873
873
|
if (!tuple2) return;
|
|
@@ -3244,7 +3244,7 @@ var require_websocket = __commonJS({
|
|
|
3244
3244
|
var http = __require("http");
|
|
3245
3245
|
var net = __require("net");
|
|
3246
3246
|
var tls = __require("tls");
|
|
3247
|
-
var { randomBytes: randomBytes7, createHash:
|
|
3247
|
+
var { randomBytes: randomBytes7, createHash: createHash12 } = __require("crypto");
|
|
3248
3248
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
3249
3249
|
var { URL: URL3 } = __require("url");
|
|
3250
3250
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -3912,7 +3912,7 @@ var require_websocket = __commonJS({
|
|
|
3912
3912
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
3913
3913
|
return;
|
|
3914
3914
|
}
|
|
3915
|
-
const digest =
|
|
3915
|
+
const digest = createHash12("sha1").update(key + GUID).digest("base64");
|
|
3916
3916
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
3917
3917
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
3918
3918
|
return;
|
|
@@ -4281,7 +4281,7 @@ var require_websocket_server = __commonJS({
|
|
|
4281
4281
|
var EventEmitter = __require("events");
|
|
4282
4282
|
var http = __require("http");
|
|
4283
4283
|
var { Duplex } = __require("stream");
|
|
4284
|
-
var { createHash:
|
|
4284
|
+
var { createHash: createHash12 } = __require("crypto");
|
|
4285
4285
|
var extension2 = require_extension();
|
|
4286
4286
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
4287
4287
|
var subprotocol2 = require_subprotocol();
|
|
@@ -4588,7 +4588,7 @@ var require_websocket_server = __commonJS({
|
|
|
4588
4588
|
);
|
|
4589
4589
|
}
|
|
4590
4590
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
4591
|
-
const digest =
|
|
4591
|
+
const digest = createHash12("sha1").update(key + GUID).digest("base64");
|
|
4592
4592
|
const headers = [
|
|
4593
4593
|
"HTTP/1.1 101 Switching Protocols",
|
|
4594
4594
|
"Upgrade: websocket",
|
|
@@ -7314,9 +7314,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
7314
7314
|
}
|
|
7315
7315
|
close(callback) {
|
|
7316
7316
|
if (callback === void 0) {
|
|
7317
|
-
return new Promise((
|
|
7317
|
+
return new Promise((resolve27, reject) => {
|
|
7318
7318
|
this.close((err, data) => {
|
|
7319
|
-
return err ? reject(err) :
|
|
7319
|
+
return err ? reject(err) : resolve27(data);
|
|
7320
7320
|
});
|
|
7321
7321
|
});
|
|
7322
7322
|
}
|
|
@@ -7354,9 +7354,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
7354
7354
|
err = null;
|
|
7355
7355
|
}
|
|
7356
7356
|
if (callback === void 0) {
|
|
7357
|
-
return new Promise((
|
|
7357
|
+
return new Promise((resolve27, reject) => {
|
|
7358
7358
|
this.destroy(err, (err2, data) => {
|
|
7359
|
-
return err2 ? reject(err2) :
|
|
7359
|
+
return err2 ? reject(err2) : resolve27(data);
|
|
7360
7360
|
});
|
|
7361
7361
|
});
|
|
7362
7362
|
}
|
|
@@ -7474,14 +7474,14 @@ var require_connect = __commonJS({
|
|
|
7474
7474
|
const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions);
|
|
7475
7475
|
timeout = timeout == null ? 1e4 : timeout;
|
|
7476
7476
|
allowH2 = allowH2 != null ? allowH2 : true;
|
|
7477
|
-
return function connect8({ hostname:
|
|
7477
|
+
return function connect8({ hostname: hostname10, host: host2, protocol, port, servername, localAddress, httpSocket }, callback) {
|
|
7478
7478
|
let socket;
|
|
7479
7479
|
if (protocol === "https:") {
|
|
7480
7480
|
if (!tls) {
|
|
7481
7481
|
tls = __require("node:tls");
|
|
7482
7482
|
}
|
|
7483
7483
|
servername = servername || options.servername || util.getServerName(host2) || null;
|
|
7484
|
-
const sessionKey = servername ||
|
|
7484
|
+
const sessionKey = servername || hostname10;
|
|
7485
7485
|
assert2(sessionKey);
|
|
7486
7486
|
const session = customSession || sessionCache.get(sessionKey) || null;
|
|
7487
7487
|
port = port || 443;
|
|
@@ -7496,7 +7496,7 @@ var require_connect = __commonJS({
|
|
|
7496
7496
|
socket: httpSocket,
|
|
7497
7497
|
// upgrade socket connection
|
|
7498
7498
|
port,
|
|
7499
|
-
host:
|
|
7499
|
+
host: hostname10
|
|
7500
7500
|
});
|
|
7501
7501
|
socket.on("session", function(session2) {
|
|
7502
7502
|
sessionCache.set(sessionKey, session2);
|
|
@@ -7510,16 +7510,16 @@ var require_connect = __commonJS({
|
|
|
7510
7510
|
...options,
|
|
7511
7511
|
localAddress,
|
|
7512
7512
|
port,
|
|
7513
|
-
host:
|
|
7513
|
+
host: hostname10
|
|
7514
7514
|
};
|
|
7515
|
-
const family2 = net.isIP(
|
|
7516
|
-
if (family2 !== 0 && servername && servername !==
|
|
7515
|
+
const family2 = net.isIP(hostname10);
|
|
7516
|
+
if (family2 !== 0 && servername && servername !== hostname10) {
|
|
7517
7517
|
connectOptions.host = servername;
|
|
7518
7518
|
connectOptions.lookup = (_hostname, lookupOptions, cb) => {
|
|
7519
7519
|
if (lookupOptions.all) {
|
|
7520
|
-
cb(null, [{ address:
|
|
7520
|
+
cb(null, [{ address: hostname10, family: family2 }]);
|
|
7521
7521
|
} else {
|
|
7522
|
-
cb(null,
|
|
7522
|
+
cb(null, hostname10, family2);
|
|
7523
7523
|
}
|
|
7524
7524
|
};
|
|
7525
7525
|
}
|
|
@@ -7532,7 +7532,7 @@ var require_connect = __commonJS({
|
|
|
7532
7532
|
const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay;
|
|
7533
7533
|
socket.setKeepAlive(true, keepAliveInitialDelay);
|
|
7534
7534
|
}
|
|
7535
|
-
const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname:
|
|
7535
|
+
const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname: hostname10, port });
|
|
7536
7536
|
socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() {
|
|
7537
7537
|
queueMicrotask(clearConnectTimeout);
|
|
7538
7538
|
if (callback) {
|
|
@@ -7545,7 +7545,7 @@ var require_connect = __commonJS({
|
|
|
7545
7545
|
if (callback) {
|
|
7546
7546
|
const cb = callback;
|
|
7547
7547
|
callback = null;
|
|
7548
|
-
cb(maybeNormalizeConnectError(err, this, { timeout, hostname:
|
|
7548
|
+
cb(maybeNormalizeConnectError(err, this, { timeout, hostname: hostname10, port }));
|
|
7549
7549
|
}
|
|
7550
7550
|
});
|
|
7551
7551
|
return socket;
|
|
@@ -12311,12 +12311,12 @@ upgrade: ${upgrade2}\r
|
|
|
12311
12311
|
cb();
|
|
12312
12312
|
}
|
|
12313
12313
|
}
|
|
12314
|
-
const waitForDrain = () => new Promise((
|
|
12314
|
+
const waitForDrain = () => new Promise((resolve27, reject) => {
|
|
12315
12315
|
assert2(callback === null);
|
|
12316
12316
|
if (socket[kError]) {
|
|
12317
12317
|
reject(socket[kError]);
|
|
12318
12318
|
} else {
|
|
12319
|
-
callback =
|
|
12319
|
+
callback = resolve27;
|
|
12320
12320
|
}
|
|
12321
12321
|
});
|
|
12322
12322
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -13674,12 +13674,12 @@ var require_client_h2 = __commonJS({
|
|
|
13674
13674
|
cb();
|
|
13675
13675
|
}
|
|
13676
13676
|
}
|
|
13677
|
-
const waitForDrain = () => new Promise((
|
|
13677
|
+
const waitForDrain = () => new Promise((resolve27, reject) => {
|
|
13678
13678
|
assert2(callback === null);
|
|
13679
13679
|
if (socket[kError]) {
|
|
13680
13680
|
reject(socket[kError]);
|
|
13681
13681
|
} else {
|
|
13682
|
-
callback =
|
|
13682
|
+
callback = resolve27;
|
|
13683
13683
|
}
|
|
13684
13684
|
});
|
|
13685
13685
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -14047,16 +14047,16 @@ var require_client = __commonJS({
|
|
|
14047
14047
|
return this[kNeedDrain] < 2;
|
|
14048
14048
|
}
|
|
14049
14049
|
[kClose]() {
|
|
14050
|
-
return new Promise((
|
|
14050
|
+
return new Promise((resolve27) => {
|
|
14051
14051
|
if (this[kSize]) {
|
|
14052
|
-
this[kClosedResolve] =
|
|
14052
|
+
this[kClosedResolve] = resolve27;
|
|
14053
14053
|
} else {
|
|
14054
|
-
|
|
14054
|
+
resolve27(null);
|
|
14055
14055
|
}
|
|
14056
14056
|
});
|
|
14057
14057
|
}
|
|
14058
14058
|
[kDestroy](err) {
|
|
14059
|
-
return new Promise((
|
|
14059
|
+
return new Promise((resolve27) => {
|
|
14060
14060
|
const requests2 = this[kQueue].splice(this[kPendingIdx]);
|
|
14061
14061
|
for (let i = 0; i < requests2.length; i++) {
|
|
14062
14062
|
const request2 = requests2[i];
|
|
@@ -14069,7 +14069,7 @@ var require_client = __commonJS({
|
|
|
14069
14069
|
this[kClosedResolve]();
|
|
14070
14070
|
this[kClosedResolve] = null;
|
|
14071
14071
|
}
|
|
14072
|
-
|
|
14072
|
+
resolve27(null);
|
|
14073
14073
|
};
|
|
14074
14074
|
if (this[kHTTPContext]) {
|
|
14075
14075
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -14097,20 +14097,20 @@ var require_client = __commonJS({
|
|
|
14097
14097
|
function connect8(client) {
|
|
14098
14098
|
assert2(!client[kConnecting]);
|
|
14099
14099
|
assert2(!client[kHTTPContext]);
|
|
14100
|
-
let { host: host2, hostname:
|
|
14101
|
-
if (
|
|
14102
|
-
const idx =
|
|
14100
|
+
let { host: host2, hostname: hostname10, protocol, port } = client[kUrl];
|
|
14101
|
+
if (hostname10[0] === "[") {
|
|
14102
|
+
const idx = hostname10.indexOf("]");
|
|
14103
14103
|
assert2(idx !== -1);
|
|
14104
|
-
const ip2 =
|
|
14104
|
+
const ip2 = hostname10.substring(1, idx);
|
|
14105
14105
|
assert2(net.isIPv6(ip2));
|
|
14106
|
-
|
|
14106
|
+
hostname10 = ip2;
|
|
14107
14107
|
}
|
|
14108
14108
|
client[kConnecting] = true;
|
|
14109
14109
|
if (channels3.beforeConnect.hasSubscribers) {
|
|
14110
14110
|
channels3.beforeConnect.publish({
|
|
14111
14111
|
connectParams: {
|
|
14112
14112
|
host: host2,
|
|
14113
|
-
hostname:
|
|
14113
|
+
hostname: hostname10,
|
|
14114
14114
|
protocol,
|
|
14115
14115
|
port,
|
|
14116
14116
|
version: client[kHTTPContext]?.version,
|
|
@@ -14123,14 +14123,14 @@ var require_client = __commonJS({
|
|
|
14123
14123
|
try {
|
|
14124
14124
|
client[kConnector]({
|
|
14125
14125
|
host: host2,
|
|
14126
|
-
hostname:
|
|
14126
|
+
hostname: hostname10,
|
|
14127
14127
|
protocol,
|
|
14128
14128
|
port,
|
|
14129
14129
|
servername: client[kServerName],
|
|
14130
14130
|
localAddress: client[kLocalAddress]
|
|
14131
14131
|
}, (err, socket) => {
|
|
14132
14132
|
if (err) {
|
|
14133
|
-
handleConnectError(client, err, { host: host2, hostname:
|
|
14133
|
+
handleConnectError(client, err, { host: host2, hostname: hostname10, protocol, port });
|
|
14134
14134
|
client[kResume]();
|
|
14135
14135
|
return;
|
|
14136
14136
|
}
|
|
@@ -14144,7 +14144,7 @@ var require_client = __commonJS({
|
|
|
14144
14144
|
client[kHTTPContext] = socket.alpnProtocol === "h2" ? connectH2(client, socket) : connectH1(client, socket);
|
|
14145
14145
|
} catch (err2) {
|
|
14146
14146
|
socket.destroy().on("error", noop2);
|
|
14147
|
-
handleConnectError(client, err2, { host: host2, hostname:
|
|
14147
|
+
handleConnectError(client, err2, { host: host2, hostname: hostname10, protocol, port });
|
|
14148
14148
|
client[kResume]();
|
|
14149
14149
|
return;
|
|
14150
14150
|
}
|
|
@@ -14157,7 +14157,7 @@ var require_client = __commonJS({
|
|
|
14157
14157
|
channels3.connected.publish({
|
|
14158
14158
|
connectParams: {
|
|
14159
14159
|
host: host2,
|
|
14160
|
-
hostname:
|
|
14160
|
+
hostname: hostname10,
|
|
14161
14161
|
protocol,
|
|
14162
14162
|
port,
|
|
14163
14163
|
version: client[kHTTPContext]?.version,
|
|
@@ -14172,11 +14172,11 @@ var require_client = __commonJS({
|
|
|
14172
14172
|
client[kResume]();
|
|
14173
14173
|
});
|
|
14174
14174
|
} catch (err) {
|
|
14175
|
-
handleConnectError(client, err, { host: host2, hostname:
|
|
14175
|
+
handleConnectError(client, err, { host: host2, hostname: hostname10, protocol, port });
|
|
14176
14176
|
client[kResume]();
|
|
14177
14177
|
}
|
|
14178
14178
|
}
|
|
14179
|
-
function handleConnectError(client, err, { host: host2, hostname:
|
|
14179
|
+
function handleConnectError(client, err, { host: host2, hostname: hostname10, protocol, port }) {
|
|
14180
14180
|
if (client.destroyed) {
|
|
14181
14181
|
return;
|
|
14182
14182
|
}
|
|
@@ -14185,7 +14185,7 @@ var require_client = __commonJS({
|
|
|
14185
14185
|
channels3.connectError.publish({
|
|
14186
14186
|
connectParams: {
|
|
14187
14187
|
host: host2,
|
|
14188
|
-
hostname:
|
|
14188
|
+
hostname: hostname10,
|
|
14189
14189
|
protocol,
|
|
14190
14190
|
port,
|
|
14191
14191
|
version: client[kHTTPContext]?.version,
|
|
@@ -14482,8 +14482,8 @@ var require_pool_base = __commonJS({
|
|
|
14482
14482
|
}
|
|
14483
14483
|
return Promise.all(closeAll);
|
|
14484
14484
|
} else {
|
|
14485
|
-
return new Promise((
|
|
14486
|
-
this[kClosedResolve] =
|
|
14485
|
+
return new Promise((resolve27) => {
|
|
14486
|
+
this[kClosedResolve] = resolve27;
|
|
14487
14487
|
});
|
|
14488
14488
|
}
|
|
14489
14489
|
}
|
|
@@ -16240,10 +16240,10 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
16240
16240
|
]);
|
|
16241
16241
|
}
|
|
16242
16242
|
#getProxyAgentForUrl(url2) {
|
|
16243
|
-
let { protocol, host:
|
|
16244
|
-
|
|
16243
|
+
let { protocol, host: hostname10, port } = url2;
|
|
16244
|
+
hostname10 = hostname10.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
|
|
16245
16245
|
port = Number.parseInt(port, 10) || DEFAULT_PORTS[protocol] || 0;
|
|
16246
|
-
if (!this.#shouldProxy(
|
|
16246
|
+
if (!this.#shouldProxy(hostname10, port)) {
|
|
16247
16247
|
return this[kNoProxyAgent];
|
|
16248
16248
|
}
|
|
16249
16249
|
if (protocol === "https:") {
|
|
@@ -16251,7 +16251,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
16251
16251
|
}
|
|
16252
16252
|
return this[kHttpProxyAgent];
|
|
16253
16253
|
}
|
|
16254
|
-
#shouldProxy(
|
|
16254
|
+
#shouldProxy(hostname10, port) {
|
|
16255
16255
|
if (this.#noProxyChanged) {
|
|
16256
16256
|
this.#parseNoProxy();
|
|
16257
16257
|
}
|
|
@@ -16266,10 +16266,10 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
16266
16266
|
if (entry2.port && entry2.port !== port) {
|
|
16267
16267
|
continue;
|
|
16268
16268
|
}
|
|
16269
|
-
if (
|
|
16269
|
+
if (hostname10 === entry2.hostname) {
|
|
16270
16270
|
return false;
|
|
16271
16271
|
}
|
|
16272
|
-
if (
|
|
16272
|
+
if (hostname10.slice(-(entry2.hostname.length + 1)) === `.${entry2.hostname}`) {
|
|
16273
16273
|
return false;
|
|
16274
16274
|
}
|
|
16275
16275
|
}
|
|
@@ -16284,21 +16284,21 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
16284
16284
|
if (!entry2) {
|
|
16285
16285
|
continue;
|
|
16286
16286
|
}
|
|
16287
|
-
let
|
|
16287
|
+
let hostname10, port;
|
|
16288
16288
|
const ipv6WithPort = entry2.match(/^\[(.+)\]:(\d+)$/);
|
|
16289
16289
|
if (ipv6WithPort) {
|
|
16290
|
-
|
|
16290
|
+
hostname10 = ipv6WithPort[1];
|
|
16291
16291
|
port = Number.parseInt(ipv6WithPort[2], 10);
|
|
16292
16292
|
} else {
|
|
16293
16293
|
const unbracketed = entry2.replace(/^\[(.+)\]$/, "$1");
|
|
16294
16294
|
const colonCount = (unbracketed.match(/:/g) || []).length;
|
|
16295
16295
|
const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/);
|
|
16296
|
-
|
|
16296
|
+
hostname10 = parsed ? parsed[1] : unbracketed;
|
|
16297
16297
|
port = parsed ? Number.parseInt(parsed[2], 10) : 0;
|
|
16298
16298
|
}
|
|
16299
16299
|
noProxyEntries.push({
|
|
16300
16300
|
// strip leading dot or asterisk with dot
|
|
16301
|
-
hostname:
|
|
16301
|
+
hostname: hostname10.replace(/^\*?\./, "").toLowerCase(),
|
|
16302
16302
|
port
|
|
16303
16303
|
});
|
|
16304
16304
|
}
|
|
@@ -16994,7 +16994,7 @@ var require_readable = __commonJS({
|
|
|
16994
16994
|
if (this._readableState.closeEmitted) {
|
|
16995
16995
|
return Promise.resolve(null);
|
|
16996
16996
|
}
|
|
16997
|
-
return new Promise((
|
|
16997
|
+
return new Promise((resolve27, reject) => {
|
|
16998
16998
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
16999
16999
|
this.destroy(new AbortError());
|
|
17000
17000
|
}
|
|
@@ -17008,11 +17008,11 @@ var require_readable = __commonJS({
|
|
|
17008
17008
|
if (signal.aborted) {
|
|
17009
17009
|
reject(signal.reason ?? new AbortError());
|
|
17010
17010
|
} else {
|
|
17011
|
-
|
|
17011
|
+
resolve27(null);
|
|
17012
17012
|
}
|
|
17013
17013
|
});
|
|
17014
17014
|
} else {
|
|
17015
|
-
this.on("close",
|
|
17015
|
+
this.on("close", resolve27);
|
|
17016
17016
|
}
|
|
17017
17017
|
this.on("error", noop2).on("data", () => {
|
|
17018
17018
|
if (this[kBytesRead] > limit) {
|
|
@@ -17040,7 +17040,7 @@ var require_readable = __commonJS({
|
|
|
17040
17040
|
}
|
|
17041
17041
|
function consume(stream, type) {
|
|
17042
17042
|
assert2(!stream[kConsume]);
|
|
17043
|
-
return new Promise((
|
|
17043
|
+
return new Promise((resolve27, reject) => {
|
|
17044
17044
|
if (isUnusable(stream)) {
|
|
17045
17045
|
const rState = stream._readableState;
|
|
17046
17046
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -17055,7 +17055,7 @@ var require_readable = __commonJS({
|
|
|
17055
17055
|
stream[kConsume] = {
|
|
17056
17056
|
type,
|
|
17057
17057
|
stream,
|
|
17058
|
-
resolve:
|
|
17058
|
+
resolve: resolve27,
|
|
17059
17059
|
reject,
|
|
17060
17060
|
length: 0,
|
|
17061
17061
|
body: []
|
|
@@ -17133,18 +17133,18 @@ var require_readable = __commonJS({
|
|
|
17133
17133
|
return buffer;
|
|
17134
17134
|
}
|
|
17135
17135
|
function consumeEnd(consume2, encoding) {
|
|
17136
|
-
const { type, body, resolve:
|
|
17136
|
+
const { type, body, resolve: resolve27, stream, length } = consume2;
|
|
17137
17137
|
try {
|
|
17138
17138
|
if (type === "text") {
|
|
17139
|
-
|
|
17139
|
+
resolve27(chunksDecode(body, length, encoding));
|
|
17140
17140
|
} else if (type === "json") {
|
|
17141
|
-
|
|
17141
|
+
resolve27(JSON.parse(chunksDecode(body, length, encoding)));
|
|
17142
17142
|
} else if (type === "arrayBuffer") {
|
|
17143
|
-
|
|
17143
|
+
resolve27(chunksConcat(body, length).buffer);
|
|
17144
17144
|
} else if (type === "blob") {
|
|
17145
|
-
|
|
17145
|
+
resolve27(new Blob(body, { type: stream[kContentType] }));
|
|
17146
17146
|
} else if (type === "bytes") {
|
|
17147
|
-
|
|
17147
|
+
resolve27(chunksConcat(body, length));
|
|
17148
17148
|
}
|
|
17149
17149
|
consumeFinish(consume2);
|
|
17150
17150
|
} catch (err) {
|
|
@@ -17363,9 +17363,9 @@ var require_api_request = __commonJS({
|
|
|
17363
17363
|
};
|
|
17364
17364
|
function request2(opts, callback) {
|
|
17365
17365
|
if (callback === void 0) {
|
|
17366
|
-
return new Promise((
|
|
17366
|
+
return new Promise((resolve27, reject) => {
|
|
17367
17367
|
request2.call(this, opts, (err, data) => {
|
|
17368
|
-
return err ? reject(err) :
|
|
17368
|
+
return err ? reject(err) : resolve27(data);
|
|
17369
17369
|
});
|
|
17370
17370
|
});
|
|
17371
17371
|
}
|
|
@@ -17626,9 +17626,9 @@ var require_api_stream = __commonJS({
|
|
|
17626
17626
|
};
|
|
17627
17627
|
function stream(opts, factory, callback) {
|
|
17628
17628
|
if (callback === void 0) {
|
|
17629
|
-
return new Promise((
|
|
17629
|
+
return new Promise((resolve27, reject) => {
|
|
17630
17630
|
stream.call(this, opts, factory, (err, data) => {
|
|
17631
|
-
return err ? reject(err) :
|
|
17631
|
+
return err ? reject(err) : resolve27(data);
|
|
17632
17632
|
});
|
|
17633
17633
|
});
|
|
17634
17634
|
}
|
|
@@ -17928,9 +17928,9 @@ var require_api_upgrade = __commonJS({
|
|
|
17928
17928
|
};
|
|
17929
17929
|
function upgrade2(opts, callback) {
|
|
17930
17930
|
if (callback === void 0) {
|
|
17931
|
-
return new Promise((
|
|
17931
|
+
return new Promise((resolve27, reject) => {
|
|
17932
17932
|
upgrade2.call(this, opts, (err, data) => {
|
|
17933
|
-
return err ? reject(err) :
|
|
17933
|
+
return err ? reject(err) : resolve27(data);
|
|
17934
17934
|
});
|
|
17935
17935
|
});
|
|
17936
17936
|
}
|
|
@@ -18024,9 +18024,9 @@ var require_api_connect = __commonJS({
|
|
|
18024
18024
|
};
|
|
18025
18025
|
function connect8(opts, callback) {
|
|
18026
18026
|
if (callback === void 0) {
|
|
18027
|
-
return new Promise((
|
|
18027
|
+
return new Promise((resolve27, reject) => {
|
|
18028
18028
|
connect8.call(this, opts, (err, data) => {
|
|
18029
|
-
return err ? reject(err) :
|
|
18029
|
+
return err ? reject(err) : resolve27(data);
|
|
18030
18030
|
});
|
|
18031
18031
|
});
|
|
18032
18032
|
}
|
|
@@ -19487,7 +19487,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19487
19487
|
"../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
19488
19488
|
"use strict";
|
|
19489
19489
|
var { writeFile: writeFile12, readFile: readFile39, mkdir: mkdir14 } = __require("node:fs/promises");
|
|
19490
|
-
var { dirname:
|
|
19490
|
+
var { dirname: dirname29, resolve: resolve27 } = __require("node:path");
|
|
19491
19491
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
19492
19492
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
19493
19493
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -19703,7 +19703,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19703
19703
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19704
19704
|
}
|
|
19705
19705
|
try {
|
|
19706
|
-
const data = await readFile39(
|
|
19706
|
+
const data = await readFile39(resolve27(path), "utf8");
|
|
19707
19707
|
const parsed = JSON.parse(data);
|
|
19708
19708
|
if (Array.isArray(parsed)) {
|
|
19709
19709
|
this.#snapshots.clear();
|
|
@@ -19732,8 +19732,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19732
19732
|
if (!path) {
|
|
19733
19733
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
19734
19734
|
}
|
|
19735
|
-
const resolvedPath =
|
|
19736
|
-
await mkdir14(
|
|
19735
|
+
const resolvedPath = resolve27(path);
|
|
19736
|
+
await mkdir14(dirname29(resolvedPath), { recursive: true });
|
|
19737
19737
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
19738
19738
|
hash: hash2,
|
|
19739
19739
|
snapshot
|
|
@@ -20765,14 +20765,14 @@ var require_dns = __commonJS({
|
|
|
20765
20765
|
get size() {
|
|
20766
20766
|
return this.#records.size;
|
|
20767
20767
|
}
|
|
20768
|
-
get(
|
|
20769
|
-
return this.#records.get(
|
|
20768
|
+
get(hostname10) {
|
|
20769
|
+
return this.#records.get(hostname10) ?? null;
|
|
20770
20770
|
}
|
|
20771
|
-
set(
|
|
20772
|
-
this.#records.set(
|
|
20771
|
+
set(hostname10, records) {
|
|
20772
|
+
this.#records.set(hostname10, records);
|
|
20773
20773
|
}
|
|
20774
|
-
delete(
|
|
20775
|
-
this.#records.delete(
|
|
20774
|
+
delete(hostname10) {
|
|
20775
|
+
this.#records.delete(hostname10);
|
|
20776
20776
|
}
|
|
20777
20777
|
// Delegate to storage decide can we do more lookups or not
|
|
20778
20778
|
full() {
|
|
@@ -27230,7 +27230,7 @@ var require_fetch = __commonJS({
|
|
|
27230
27230
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
27231
27231
|
return dispatchWithProtocolPreference(body);
|
|
27232
27232
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
27233
|
-
return new Promise((
|
|
27233
|
+
return new Promise((resolve27, reject) => agent3.dispatch(
|
|
27234
27234
|
{
|
|
27235
27235
|
path: hasTrailingQuestionMark ? `${path}?` : path,
|
|
27236
27236
|
origin: url2.origin,
|
|
@@ -27313,7 +27313,7 @@ var require_fetch = __commonJS({
|
|
|
27313
27313
|
}
|
|
27314
27314
|
}
|
|
27315
27315
|
const onError = (err) => this.onResponseError(controller, err);
|
|
27316
|
-
|
|
27316
|
+
resolve27({
|
|
27317
27317
|
status: status11,
|
|
27318
27318
|
statusText,
|
|
27319
27319
|
headersList,
|
|
@@ -27346,7 +27346,7 @@ var require_fetch = __commonJS({
|
|
|
27346
27346
|
fetchParams.controller.off("terminated", this.abort);
|
|
27347
27347
|
}
|
|
27348
27348
|
if (request2.mode === "websocket" && allowH2 !== false && error63?.code === "UND_ERR_INFO" && error63?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
27349
|
-
|
|
27349
|
+
resolve27(dispatchWithProtocolPreference(body2, false));
|
|
27350
27350
|
return;
|
|
27351
27351
|
}
|
|
27352
27352
|
this.body?.destroy(error63);
|
|
@@ -27360,7 +27360,7 @@ var require_fetch = __commonJS({
|
|
|
27360
27360
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
27361
27361
|
const headersList = new HeadersList();
|
|
27362
27362
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
27363
|
-
|
|
27363
|
+
resolve27({
|
|
27364
27364
|
status: status11,
|
|
27365
27365
|
statusText: STATUS_CODES[status11],
|
|
27366
27366
|
headersList,
|
|
@@ -31634,7 +31634,7 @@ ${captureLines}` : capture.stack;
|
|
|
31634
31634
|
// src/main.ts
|
|
31635
31635
|
import { homedir as homedir5 } from "node:os";
|
|
31636
31636
|
import { stderr, stdin, stdout } from "node:process";
|
|
31637
|
-
import { createInterface as
|
|
31637
|
+
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
31638
31638
|
|
|
31639
31639
|
// ../../packages/secret-guard/src/detector/laze-id.ts
|
|
31640
31640
|
var LAZE_ID = /^(?:[a-z\d]+_)?[a-z\d]+_([0-9A-Za-z]{29})$/;
|
|
@@ -32693,7 +32693,7 @@ function runRedacted({
|
|
|
32693
32693
|
redact
|
|
32694
32694
|
}) {
|
|
32695
32695
|
const values = redact ?? Object.values(env);
|
|
32696
|
-
return new Promise((
|
|
32696
|
+
return new Promise((resolve27, reject) => {
|
|
32697
32697
|
const [file4, ...args] = command;
|
|
32698
32698
|
const child = spawn(file4, args, {
|
|
32699
32699
|
env: { ...baseEnv, ...env },
|
|
@@ -32719,7 +32719,7 @@ function runRedacted({
|
|
|
32719
32719
|
child.on("error", reject);
|
|
32720
32720
|
child.on("close", (code4, ended) => {
|
|
32721
32721
|
signal?.removeEventListener("abort", killGroup);
|
|
32722
|
-
void drained.then(() =>
|
|
32722
|
+
void drained.then(() => resolve27(code4 ?? (ended ? 128 + signalNumber(ended) : 1)));
|
|
32723
32723
|
});
|
|
32724
32724
|
});
|
|
32725
32725
|
}
|
|
@@ -36960,7 +36960,7 @@ function shadowedLinkLineOf({ shadow }) {
|
|
|
36960
36960
|
}
|
|
36961
36961
|
|
|
36962
36962
|
// src/rules/cli-version.rules.ts
|
|
36963
|
-
var STAMPED = "0.1.
|
|
36963
|
+
var STAMPED = "0.1.127";
|
|
36964
36964
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
36965
36965
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
36966
36966
|
}
|
|
@@ -37056,8 +37056,87 @@ async function rerunCommandOf({
|
|
|
37056
37056
|
}
|
|
37057
37057
|
|
|
37058
37058
|
// src/services/config-store.service.ts
|
|
37059
|
+
import { readFileSync } from "node:fs";
|
|
37059
37060
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
37060
|
-
import { basename as basename2, dirname as dirname3, resolve } from "node:path";
|
|
37061
|
+
import { basename as basename2, dirname as dirname3, join as join4, resolve } from "node:path";
|
|
37062
|
+
|
|
37063
|
+
// src/rules/hook-settings.rules.ts
|
|
37064
|
+
var LAZE_HOOK_MARKER = "laze-cli-hook";
|
|
37065
|
+
var HOOK_TIMEOUTS = { Stop: 30, PreToolUse: 5, SessionStart: 30 };
|
|
37066
|
+
var TIMEOUTS = HOOK_TIMEOUTS;
|
|
37067
|
+
var WAIT_HOOK_TIMEOUT_SECONDS = 7 * 24 * 60 * 60;
|
|
37068
|
+
function withHooks({
|
|
37069
|
+
hooks,
|
|
37070
|
+
event,
|
|
37071
|
+
added
|
|
37072
|
+
}) {
|
|
37073
|
+
const current3 = Array.isArray(hooks[event]) ? hooks[event] : [];
|
|
37074
|
+
const others = current3.filter(
|
|
37075
|
+
(entry2) => !entry2.hooks?.some((hook) => hook.command?.includes(LAZE_HOOK_MARKER))
|
|
37076
|
+
);
|
|
37077
|
+
hooks[event] = [...others, ...added.map((hook) => ({ hooks: [hook] }))];
|
|
37078
|
+
}
|
|
37079
|
+
function withLazeHooks({
|
|
37080
|
+
settings: settings3,
|
|
37081
|
+
stopCommand,
|
|
37082
|
+
waitCommand,
|
|
37083
|
+
preToolCommand
|
|
37084
|
+
}) {
|
|
37085
|
+
const hooks = { ...settings3.hooks };
|
|
37086
|
+
withHooks({
|
|
37087
|
+
hooks,
|
|
37088
|
+
event: "Stop",
|
|
37089
|
+
added: [
|
|
37090
|
+
{ type: "command", command: stopCommand, timeout: TIMEOUTS.Stop },
|
|
37091
|
+
{
|
|
37092
|
+
type: "command",
|
|
37093
|
+
command: waitCommand,
|
|
37094
|
+
timeout: WAIT_HOOK_TIMEOUT_SECONDS,
|
|
37095
|
+
async: true,
|
|
37096
|
+
asyncRewake: true
|
|
37097
|
+
}
|
|
37098
|
+
]
|
|
37099
|
+
});
|
|
37100
|
+
withHooks({
|
|
37101
|
+
hooks,
|
|
37102
|
+
event: "SessionStart",
|
|
37103
|
+
added: [
|
|
37104
|
+
{
|
|
37105
|
+
type: "command",
|
|
37106
|
+
command: waitCommand,
|
|
37107
|
+
timeout: WAIT_HOOK_TIMEOUT_SECONDS,
|
|
37108
|
+
async: true,
|
|
37109
|
+
asyncRewake: true
|
|
37110
|
+
}
|
|
37111
|
+
]
|
|
37112
|
+
});
|
|
37113
|
+
withHooks({
|
|
37114
|
+
hooks,
|
|
37115
|
+
event: "PreToolUse",
|
|
37116
|
+
added: [{ type: "command", command: preToolCommand, timeout: TIMEOUTS.PreToolUse }]
|
|
37117
|
+
});
|
|
37118
|
+
return { ...settings3, hooks };
|
|
37119
|
+
}
|
|
37120
|
+
function hookCommand({
|
|
37121
|
+
program,
|
|
37122
|
+
hook
|
|
37123
|
+
}) {
|
|
37124
|
+
const quote4 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
37125
|
+
const words = [...program, "hook", hook].map(quote4).join(" ");
|
|
37126
|
+
return `${words} # ${LAZE_HOOK_MARKER}`;
|
|
37127
|
+
}
|
|
37128
|
+
function holdsOurs({ settings: settings3, event }) {
|
|
37129
|
+
const hooks = settings3.hooks ?? {};
|
|
37130
|
+
return Array.isArray(hooks[event]) && hooks[event].some(
|
|
37131
|
+
(entry2) => entry2.hooks?.some((hook) => hook.command?.includes(LAZE_HOOK_MARKER))
|
|
37132
|
+
);
|
|
37133
|
+
}
|
|
37134
|
+
function lacksSessionStartWaiter({ settings: settings3 }) {
|
|
37135
|
+
return holdsOurs({ settings: settings3, event: "Stop" }) && !holdsOurs({ settings: settings3, event: "SessionStart" });
|
|
37136
|
+
}
|
|
37137
|
+
function hasLazeHooks({ settings: settings3 }) {
|
|
37138
|
+
return holdsOurs({ settings: settings3, event: "Stop" });
|
|
37139
|
+
}
|
|
37061
37140
|
|
|
37062
37141
|
// src/rules/state-file.rules.ts
|
|
37063
37142
|
function stepOf({ scan, char }) {
|
|
@@ -37188,7 +37267,7 @@ async function withStateLock({
|
|
|
37188
37267
|
() => 0
|
|
37189
37268
|
);
|
|
37190
37269
|
if (since > LOCK_STALE_MS) await rm(lock, { force: true });
|
|
37191
|
-
else await new Promise((
|
|
37270
|
+
else await new Promise((resolve27) => setTimeout(resolve27, 15 + Math.random() * 20));
|
|
37192
37271
|
}
|
|
37193
37272
|
try {
|
|
37194
37273
|
return await work();
|
|
@@ -37261,12 +37340,23 @@ var ConfigStore = class _ConfigStore {
|
|
|
37261
37340
|
config: { ...config2, profiles: { ...config2.profiles, [name3]: profile } }
|
|
37262
37341
|
}));
|
|
37263
37342
|
}
|
|
37264
|
-
/** Binds a harness session to a profile,
|
|
37343
|
+
/** Binds a harness session to a profile, the agent's one session on this machine. */
|
|
37265
37344
|
async bindSession({ session, profile }) {
|
|
37266
|
-
await this.update((config2) =>
|
|
37267
|
-
|
|
37268
|
-
|
|
37269
|
-
|
|
37345
|
+
await this.update((config2) => {
|
|
37346
|
+
const others = Object.entries(config2.sessions ?? {}).filter(([, bound]) => bound !== profile);
|
|
37347
|
+
const sessions = { ...Object.fromEntries(others), [session]: profile };
|
|
37348
|
+
return { result: void 0, config: { ...config2, sessions } };
|
|
37349
|
+
});
|
|
37350
|
+
}
|
|
37351
|
+
/** Drops the session's binding while it still names `profile`; true when it did. */
|
|
37352
|
+
async unbindSession({ session, profile }) {
|
|
37353
|
+
return this.update((config2) => {
|
|
37354
|
+
if (config2.sessions?.[session] !== profile) return { result: false };
|
|
37355
|
+
const sessions = Object.fromEntries(
|
|
37356
|
+
Object.entries(config2.sessions).filter(([key]) => key !== session)
|
|
37357
|
+
);
|
|
37358
|
+
return { result: true, config: { ...config2, sessions } };
|
|
37359
|
+
});
|
|
37270
37360
|
}
|
|
37271
37361
|
/** Keeps a profile's agent name in step with Laze; a missing or unchanged profile stays. */
|
|
37272
37362
|
async renameProfileAgent({ name: name3, agentName }) {
|
|
@@ -37350,11 +37440,35 @@ function chooseProfile({
|
|
|
37350
37440
|
}) {
|
|
37351
37441
|
const heard = session ? config2.sessions?.[session] : void 0;
|
|
37352
37442
|
const sessionBound = heard && config2.profiles[heard] ? heard : void 0;
|
|
37353
|
-
const bound =
|
|
37443
|
+
const bound = folderLoginOf({ config: config2, cwd });
|
|
37354
37444
|
const name3 = flag2 || environment || sessionBound || bound || config2.current;
|
|
37355
37445
|
const profile = name3 ? config2.profiles[name3] : void 0;
|
|
37356
37446
|
return name3 && profile ? { name: name3, profile } : { name: void 0, profile: void 0 };
|
|
37357
37447
|
}
|
|
37448
|
+
function linkedFolder({
|
|
37449
|
+
config: config2,
|
|
37450
|
+
directory,
|
|
37451
|
+
profile
|
|
37452
|
+
}) {
|
|
37453
|
+
if (Object.values(config2.sessions ?? {}).includes(profile)) return true;
|
|
37454
|
+
if (config2.profiles[profile]?.delivery) return true;
|
|
37455
|
+
const settings3 = (() => {
|
|
37456
|
+
try {
|
|
37457
|
+
return readFileSync(join4(directory, ".claude", "settings.local.json"), "utf8");
|
|
37458
|
+
} catch {
|
|
37459
|
+
return "";
|
|
37460
|
+
}
|
|
37461
|
+
})();
|
|
37462
|
+
return settings3.includes(LAZE_HOOK_MARKER);
|
|
37463
|
+
}
|
|
37464
|
+
function folderLoginOf({ config: config2, cwd }) {
|
|
37465
|
+
const logins = Object.fromEntries(
|
|
37466
|
+
Object.entries(config2.bindings).filter(
|
|
37467
|
+
([directory, profile]) => !linkedFolder({ config: config2, directory, profile })
|
|
37468
|
+
)
|
|
37469
|
+
);
|
|
37470
|
+
return boundProfileOf({ bindings: logins, cwd });
|
|
37471
|
+
}
|
|
37358
37472
|
function isWorktreeRoot({ directory }) {
|
|
37359
37473
|
const parent = dirname3(directory);
|
|
37360
37474
|
if (basename2(parent) === ".worktrees") return true;
|
|
@@ -40324,9 +40438,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
|
|
|
40324
40438
|
function stripTabAndNewline(value) {
|
|
40325
40439
|
return value.replace(asciiTabOrNewline, "");
|
|
40326
40440
|
}
|
|
40327
|
-
function urlHostnameOk(url2,
|
|
40328
|
-
|
|
40329
|
-
return
|
|
40441
|
+
function urlHostnameOk(url2, hostname10) {
|
|
40442
|
+
hostname10.lastIndex = 0;
|
|
40443
|
+
return hostname10.test(url2.hostname);
|
|
40330
40444
|
}
|
|
40331
40445
|
function urlProtocolOk(url2, protocol) {
|
|
40332
40446
|
protocol.lastIndex = 0;
|
|
@@ -42537,7 +42651,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
42537
42651
|
var NONE = 0;
|
|
42538
42652
|
var ASSUMED = 1;
|
|
42539
42653
|
var PROVEN = 2;
|
|
42540
|
-
function isRecursive(inst, stack,
|
|
42654
|
+
function isRecursive(inst, stack, resolve27) {
|
|
42541
42655
|
const cached2 = recursive.get(inst);
|
|
42542
42656
|
if (cached2 !== void 0)
|
|
42543
42657
|
return cached2 ? PROVEN : NONE;
|
|
@@ -42547,7 +42661,7 @@ function isRecursive(inst, stack, resolve28) {
|
|
|
42547
42661
|
let result2 = NONE;
|
|
42548
42662
|
const check4 = (child) => {
|
|
42549
42663
|
if (result2 !== PROVEN && child?._zod) {
|
|
42550
|
-
const answer6 = isRecursive(child, stack,
|
|
42664
|
+
const answer6 = isRecursive(child, stack, resolve27);
|
|
42551
42665
|
if (answer6 > result2)
|
|
42552
42666
|
result2 = answer6;
|
|
42553
42667
|
}
|
|
@@ -42558,7 +42672,7 @@ function isRecursive(inst, stack, resolve28) {
|
|
|
42558
42672
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
42559
42673
|
if (spread && !desc.enumerable)
|
|
42560
42674
|
continue;
|
|
42561
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
42675
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve27) : NONE;
|
|
42562
42676
|
if (child > answer6)
|
|
42563
42677
|
answer6 = child;
|
|
42564
42678
|
}
|
|
@@ -42622,7 +42736,7 @@ function isRecursive(inst, stack, resolve28) {
|
|
|
42622
42736
|
break;
|
|
42623
42737
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
42624
42738
|
case "lazy": {
|
|
42625
|
-
const inner = def._cachedInner ?? (
|
|
42739
|
+
const inner = def._cachedInner ?? (resolve27 ? inst._zod.innerType : void 0);
|
|
42626
42740
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
42627
42741
|
break;
|
|
42628
42742
|
}
|
|
@@ -61533,13 +61647,19 @@ var scrubVaultEventTextsInputSchemaDefinition = external_exports.object({
|
|
|
61533
61647
|
session: external_exports.object({ agentId: external_exports.string().min(1), channelId: external_exports.string() }).optional()
|
|
61534
61648
|
});
|
|
61535
61649
|
var VAULT_SESSION_SCRUB_MAX_LINES = 200;
|
|
61536
|
-
var VAULT_SESSION_SCRUB_MAX_LINE =
|
|
61650
|
+
var VAULT_SESSION_SCRUB_MAX_LINE = 64e3;
|
|
61651
|
+
var VAULT_SESSION_SCRUB_MAX_TEXT = 256e3;
|
|
61652
|
+
var vaultSessionScrubTextsSchemaDefinition = external_exports.array(external_exports.string().max(VAULT_SESSION_SCRUB_MAX_LINE)).max(VAULT_SESSION_SCRUB_MAX_LINES).refine(
|
|
61653
|
+
(texts) => texts.reduce((total, text3) => total + text3.length, 0) <= VAULT_SESSION_SCRUB_MAX_TEXT,
|
|
61654
|
+
{ message: `At most ${VAULT_SESSION_SCRUB_MAX_TEXT} characters of session lines per request` }
|
|
61655
|
+
);
|
|
61656
|
+
var vaultSessionScrubTextsSchema = vaultSessionScrubTextsSchemaDefinition;
|
|
61537
61657
|
var scrubSessionTextsInputSchemaDefinition = external_exports.object({
|
|
61538
61658
|
workspaceId: external_exports.string().min(1),
|
|
61539
61659
|
agentId: external_exports.string().min(1),
|
|
61540
61660
|
/** The agent module's view of the agent: its reach follows its owner. */
|
|
61541
61661
|
owner: external_exports.object({ agentKind: external_exports.enum(["personal", "team"]), ownerUserId: external_exports.string().min(1) }),
|
|
61542
|
-
texts:
|
|
61662
|
+
texts: vaultSessionScrubTextsSchema
|
|
61543
61663
|
});
|
|
61544
61664
|
var hideVaultNamesInputSchemaDefinition = external_exports.object({
|
|
61545
61665
|
workspaceId: external_exports.string().min(1),
|
|
@@ -71854,7 +71974,7 @@ var agentVaultReleaseStatusInputSchemaDefinition = external_exports.object({
|
|
|
71854
71974
|
channelId: external_exports.string().min(1).max(80).nullable().default(null)
|
|
71855
71975
|
});
|
|
71856
71976
|
var agentSessionScrubInputSchemaDefinition = external_exports.object({
|
|
71857
|
-
texts:
|
|
71977
|
+
texts: vaultSessionScrubTextsSchema
|
|
71858
71978
|
});
|
|
71859
71979
|
var agentSessionScrubbedSchemaDefinition = external_exports.object({
|
|
71860
71980
|
texts: external_exports.array(external_exports.string()),
|
|
@@ -73107,158 +73227,49 @@ function displayFolderOf({ folder, home }) {
|
|
|
73107
73227
|
return `~/${below.split(sep).join("/")}`;
|
|
73108
73228
|
}
|
|
73109
73229
|
|
|
73110
|
-
// src/services/
|
|
73111
|
-
|
|
73112
|
-
|
|
73113
|
-
|
|
73114
|
-
|
|
73115
|
-
|
|
73116
|
-
|
|
73117
|
-
|
|
73118
|
-
}
|
|
73119
|
-
status;
|
|
73120
|
-
code;
|
|
73121
|
-
/** What Laze adds to the code, such as the bound session of a `session_not_bound`. */
|
|
73122
|
-
meta;
|
|
73123
|
-
};
|
|
73124
|
-
var AGENT_MIGRATED = "agent_migrated";
|
|
73125
|
-
function unreachableReasonOf(error63) {
|
|
73126
|
-
if (!(error63 instanceof TypeError) || error63.message !== "fetch failed") return void 0;
|
|
73127
|
-
const { cause } = error63;
|
|
73128
|
-
return cause instanceof Error && cause.message ? cause.message : "the connection failed";
|
|
73129
|
-
}
|
|
73130
|
-
function migratedNoticeOf(error63) {
|
|
73131
|
-
if (!(error63 instanceof LazeApiError) || error63.code !== AGENT_MIGRATED) return void 0;
|
|
73132
|
-
const notice = typeof error63.meta?.notice === "string" ? error63.meta.notice : error63.message;
|
|
73133
|
-
const link2 = typeof error63.meta?.link === "string" ? error63.meta.link : null;
|
|
73134
|
-
return { notice, link: link2 };
|
|
73230
|
+
// src/services/claude-project.service.ts
|
|
73231
|
+
import { basename as basename3, isAbsolute, relative as relative2, resolve as resolve2 } from "node:path";
|
|
73232
|
+
function harnessIn({ words }) {
|
|
73233
|
+
const names = words.slice(0, 2).map((word3) => basename3(word3).replace(/\.(js|mjs|cjs)$/, ""));
|
|
73234
|
+
if (names.includes("codex")) return "codex";
|
|
73235
|
+
if (words.some((word3) => word3.includes("@openai/codex"))) return "codex";
|
|
73236
|
+
const claude = words.some((word3) => word3.includes("@anthropic-ai/claude-code"));
|
|
73237
|
+
return claude || names.includes("claude") ? "claude-code" : void 0;
|
|
73135
73238
|
}
|
|
73136
|
-
|
|
73137
|
-
|
|
73138
|
-
|
|
73139
|
-
|
|
73140
|
-
|
|
73141
|
-
|
|
73142
|
-
|
|
73143
|
-
|
|
73144
|
-
|
|
73145
|
-
onMigrated,
|
|
73146
|
-
onRefused,
|
|
73147
|
-
onAnswered
|
|
73148
|
-
}) {
|
|
73149
|
-
return new _LazeClient({
|
|
73150
|
-
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
73151
|
-
token: token2,
|
|
73152
|
-
fetcher,
|
|
73153
|
-
headers: {},
|
|
73154
|
-
onMigrated,
|
|
73155
|
-
onRefused,
|
|
73156
|
-
onAnswered
|
|
73157
|
-
});
|
|
73158
|
-
}
|
|
73159
|
-
/** The address this client calls, which completes a link the api wrote as a path. */
|
|
73160
|
-
get baseUrl() {
|
|
73161
|
-
return this.options.baseUrl;
|
|
73162
|
-
}
|
|
73163
|
-
/** The same client, sending these headers too on every call. */
|
|
73164
|
-
withHeaders(headers) {
|
|
73165
|
-
return new _LazeClient({ ...this.options, headers: { ...this.options.headers, ...headers } });
|
|
73166
|
-
}
|
|
73167
|
-
get(path) {
|
|
73168
|
-
return this.send({ method: "GET", path });
|
|
73169
|
-
}
|
|
73170
|
-
/** `signal` aborts the call, such as a long-poll whose caller left. */
|
|
73171
|
-
post(path, body, { signal } = {}) {
|
|
73172
|
-
return this.send({ method: "POST", path, body, signal });
|
|
73173
|
-
}
|
|
73174
|
-
put(path, body) {
|
|
73175
|
-
return this.send({ method: "PUT", path, body });
|
|
73176
|
-
}
|
|
73177
|
-
/** A JSON body sent as it is, answered as it came: the status and text, never thrown. */
|
|
73178
|
-
async forward({
|
|
73179
|
-
path,
|
|
73180
|
-
body
|
|
73181
|
-
}) {
|
|
73182
|
-
const headers = {
|
|
73183
|
-
...this.options.headers,
|
|
73184
|
-
accept: "application/json, text/event-stream",
|
|
73185
|
-
"content-type": "application/json",
|
|
73186
|
-
[CLI_VERSION_HEADER]: cliVersionOf()
|
|
73187
|
-
};
|
|
73188
|
-
if (this.options.token) headers.authorization = `Bearer ${this.options.token}`;
|
|
73189
|
-
const response = await this.options.fetcher(`${this.options.baseUrl}${path}`, {
|
|
73190
|
-
method: "POST",
|
|
73191
|
-
headers,
|
|
73192
|
-
body
|
|
73193
|
-
});
|
|
73194
|
-
const text3 = await response.text();
|
|
73195
|
-
if (response.status === 401) await this.toldMigrated(apiErrorOf({ status: 401, text: text3 }));
|
|
73196
|
-
return { status: response.status, text: text3 };
|
|
73197
|
-
}
|
|
73198
|
-
async toldMigrated(error63) {
|
|
73199
|
-
const found = migratedNoticeOf(error63);
|
|
73200
|
-
if (found && this.options.onMigrated)
|
|
73201
|
-
await this.options.onMigrated(found).catch(() => void 0);
|
|
73202
|
-
else if (!found && refusesTheKey(error63) && this.options.onRefused)
|
|
73203
|
-
await this.options.onRefused(error63).catch(() => void 0);
|
|
73204
|
-
}
|
|
73205
|
-
async send({
|
|
73206
|
-
method,
|
|
73207
|
-
path,
|
|
73208
|
-
body,
|
|
73209
|
-
signal
|
|
73210
|
-
}) {
|
|
73211
|
-
const headers = {
|
|
73212
|
-
...this.options.headers,
|
|
73213
|
-
accept: "application/json",
|
|
73214
|
-
[CLI_VERSION_HEADER]: cliVersionOf()
|
|
73215
|
-
};
|
|
73216
|
-
if (body !== void 0) headers["content-type"] = "application/json";
|
|
73217
|
-
if (this.options.token) headers.authorization = `Bearer ${this.options.token}`;
|
|
73218
|
-
const response = await this.options.fetcher(`${this.options.baseUrl}${path}`, {
|
|
73219
|
-
method,
|
|
73220
|
-
headers,
|
|
73221
|
-
...body !== void 0 ? { body: JSON.stringify(body) } : {},
|
|
73222
|
-
...signal ? { signal } : {}
|
|
73223
|
-
});
|
|
73224
|
-
const text3 = await response.text();
|
|
73225
|
-
if (!response.ok) {
|
|
73226
|
-
const error63 = apiErrorOf({ status: response.status, text: text3 });
|
|
73227
|
-
await this.toldMigrated(error63);
|
|
73228
|
-
throw error63;
|
|
73229
|
-
}
|
|
73230
|
-
if (this.options.onAnswered) await this.options.onAnswered().catch(() => void 0);
|
|
73231
|
-
return text3 ? JSON.parse(text3) : void 0;
|
|
73232
|
-
}
|
|
73233
|
-
};
|
|
73234
|
-
function apiErrorOf({ status: status11, text: text3 }) {
|
|
73235
|
-
let body;
|
|
73236
|
-
try {
|
|
73237
|
-
body = text3 ? JSON.parse(text3) : void 0;
|
|
73238
|
-
} catch {
|
|
73239
|
-
body = void 0;
|
|
73239
|
+
async function nearestHarnessOf({
|
|
73240
|
+
context,
|
|
73241
|
+
from = context.processes.pid
|
|
73242
|
+
}) {
|
|
73243
|
+
let pid = await context.processes.parentOf(from);
|
|
73244
|
+
for (let depth = 0; pid !== void 0 && pid > 1 && depth < 12; depth += 1) {
|
|
73245
|
+
const harness = harnessIn({ words: await context.processes.argsOf(pid) ?? [] });
|
|
73246
|
+
if (harness) return { harness, pid };
|
|
73247
|
+
pid = await context.processes.parentOf(pid);
|
|
73240
73248
|
}
|
|
73241
|
-
return
|
|
73249
|
+
return void 0;
|
|
73242
73250
|
}
|
|
73243
|
-
function
|
|
73244
|
-
const
|
|
73245
|
-
|
|
73246
|
-
|
|
73247
|
-
|
|
73248
|
-
|
|
73249
|
-
|
|
73250
|
-
|
|
73251
|
-
|
|
73252
|
-
|
|
73251
|
+
function holds({ folder, inner }) {
|
|
73252
|
+
const rel = relative2(resolve2(folder), resolve2(inner));
|
|
73253
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
73254
|
+
}
|
|
73255
|
+
async function claudeFoldersOf({
|
|
73256
|
+
context,
|
|
73257
|
+
claudePid
|
|
73258
|
+
}) {
|
|
73259
|
+
const env = context.environment.inherited;
|
|
73260
|
+
const pid = Number(env.CLAUDE_PID);
|
|
73261
|
+
const candidates = [
|
|
73262
|
+
claudePid ? await context.processes.cwdOf(claudePid) : void 0,
|
|
73263
|
+
env.CLAUDE_PROJECT_DIR ? resolve2(env.CLAUDE_PROJECT_DIR) : void 0,
|
|
73264
|
+
pid > 0 ? await context.processes.cwdOf(pid) : void 0
|
|
73265
|
+
].filter((folder) => Boolean(folder));
|
|
73266
|
+
const holding = candidates.find((folder) => holds({ folder, inner: context.cwd }));
|
|
73267
|
+
if (holding) return { folder: holding, elsewhere: void 0 };
|
|
73268
|
+
return { folder: resolve2(context.cwd), elsewhere: candidates[0] };
|
|
73253
73269
|
}
|
|
73254
|
-
|
|
73255
|
-
// src/services/machine-report.service.ts
|
|
73256
|
-
import { createHash } from "node:crypto";
|
|
73257
|
-
import { readFile as readFile4 } from "node:fs/promises";
|
|
73258
|
-
import { hostname as hostname3 } from "node:os";
|
|
73259
73270
|
|
|
73260
73271
|
// src/services/inbox-spool.service.ts
|
|
73261
|
-
import { dirname as dirname4, join as
|
|
73272
|
+
import { dirname as dirname4, join as join5 } from "node:path";
|
|
73262
73273
|
var PUSH_GRACE_MS = 3 * 6e4;
|
|
73263
73274
|
var IN_FLIGHT_MS = 35e3;
|
|
73264
73275
|
function fileNameOf({ profile }) {
|
|
@@ -73270,8 +73281,8 @@ function statePathOf({
|
|
|
73270
73281
|
profile,
|
|
73271
73282
|
extension: extension2 = "json"
|
|
73272
73283
|
}) {
|
|
73273
|
-
const directory =
|
|
73274
|
-
return
|
|
73284
|
+
const directory = join5(dirname4(context.environment.configPath), kind2);
|
|
73285
|
+
return join5(directory, `${fileNameOf({ profile })}.${extension2}`);
|
|
73275
73286
|
}
|
|
73276
73287
|
async function readSpool({ path }) {
|
|
73277
73288
|
return await readStateJson({ path }) ?? [];
|
|
@@ -73333,7 +73344,155 @@ async function dueFromSpool({
|
|
|
73333
73344
|
return entries.filter((entry2) => !shown2.includes(entry2)).filter((entry2) => !settledOnly || entry2.takenAt <= settled3).filter((entry2) => entry2.pushedAt === void 0 || pushedToo && entry2.pushedAt <= late).map((entry2) => entry2.message);
|
|
73334
73345
|
}
|
|
73335
73346
|
|
|
73347
|
+
// src/services/laze-client.service.ts
|
|
73348
|
+
var CLI_VERSION_HEADER = "x-laze-cli-version";
|
|
73349
|
+
var LazeApiError = class extends Error {
|
|
73350
|
+
constructor(status11, code4, message2) {
|
|
73351
|
+
super(message2);
|
|
73352
|
+
this.status = status11;
|
|
73353
|
+
this.code = code4;
|
|
73354
|
+
this.name = "LazeApiError";
|
|
73355
|
+
}
|
|
73356
|
+
status;
|
|
73357
|
+
code;
|
|
73358
|
+
/** What Laze adds to the code, such as the bound session of a `session_not_bound`. */
|
|
73359
|
+
meta;
|
|
73360
|
+
};
|
|
73361
|
+
var AGENT_MIGRATED = "agent_migrated";
|
|
73362
|
+
function unreachableReasonOf(error63) {
|
|
73363
|
+
if (!(error63 instanceof TypeError) || error63.message !== "fetch failed") return void 0;
|
|
73364
|
+
const { cause } = error63;
|
|
73365
|
+
return cause instanceof Error && cause.message ? cause.message : "the connection failed";
|
|
73366
|
+
}
|
|
73367
|
+
function migratedNoticeOf(error63) {
|
|
73368
|
+
if (!(error63 instanceof LazeApiError) || error63.code !== AGENT_MIGRATED) return void 0;
|
|
73369
|
+
const notice = typeof error63.meta?.notice === "string" ? error63.meta.notice : error63.message;
|
|
73370
|
+
const link2 = typeof error63.meta?.link === "string" ? error63.meta.link : null;
|
|
73371
|
+
return { notice, link: link2 };
|
|
73372
|
+
}
|
|
73373
|
+
var LazeClient = class _LazeClient {
|
|
73374
|
+
constructor(options) {
|
|
73375
|
+
this.options = options;
|
|
73376
|
+
}
|
|
73377
|
+
options;
|
|
73378
|
+
static create({
|
|
73379
|
+
baseUrl,
|
|
73380
|
+
token: token2,
|
|
73381
|
+
fetcher,
|
|
73382
|
+
onMigrated,
|
|
73383
|
+
onRefused,
|
|
73384
|
+
onAnswered
|
|
73385
|
+
}) {
|
|
73386
|
+
return new _LazeClient({
|
|
73387
|
+
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
73388
|
+
token: token2,
|
|
73389
|
+
fetcher,
|
|
73390
|
+
headers: {},
|
|
73391
|
+
onMigrated,
|
|
73392
|
+
onRefused,
|
|
73393
|
+
onAnswered
|
|
73394
|
+
});
|
|
73395
|
+
}
|
|
73396
|
+
/** The address this client calls, which completes a link the api wrote as a path. */
|
|
73397
|
+
get baseUrl() {
|
|
73398
|
+
return this.options.baseUrl;
|
|
73399
|
+
}
|
|
73400
|
+
/** The same client, sending these headers too on every call. */
|
|
73401
|
+
withHeaders(headers) {
|
|
73402
|
+
return new _LazeClient({ ...this.options, headers: { ...this.options.headers, ...headers } });
|
|
73403
|
+
}
|
|
73404
|
+
get(path) {
|
|
73405
|
+
return this.send({ method: "GET", path });
|
|
73406
|
+
}
|
|
73407
|
+
/** `signal` aborts the call, such as a long-poll whose caller left. */
|
|
73408
|
+
post(path, body, { signal } = {}) {
|
|
73409
|
+
return this.send({ method: "POST", path, body, signal });
|
|
73410
|
+
}
|
|
73411
|
+
put(path, body) {
|
|
73412
|
+
return this.send({ method: "PUT", path, body });
|
|
73413
|
+
}
|
|
73414
|
+
/** A JSON body sent as it is, answered as it came: the status and text, never thrown. */
|
|
73415
|
+
async forward({
|
|
73416
|
+
path,
|
|
73417
|
+
body
|
|
73418
|
+
}) {
|
|
73419
|
+
const headers = {
|
|
73420
|
+
...this.options.headers,
|
|
73421
|
+
accept: "application/json, text/event-stream",
|
|
73422
|
+
"content-type": "application/json",
|
|
73423
|
+
[CLI_VERSION_HEADER]: cliVersionOf()
|
|
73424
|
+
};
|
|
73425
|
+
if (this.options.token) headers.authorization = `Bearer ${this.options.token}`;
|
|
73426
|
+
const response = await this.options.fetcher(`${this.options.baseUrl}${path}`, {
|
|
73427
|
+
method: "POST",
|
|
73428
|
+
headers,
|
|
73429
|
+
body
|
|
73430
|
+
});
|
|
73431
|
+
const text3 = await response.text();
|
|
73432
|
+
if (response.status === 401) await this.toldMigrated(apiErrorOf({ status: 401, text: text3 }));
|
|
73433
|
+
return { status: response.status, text: text3 };
|
|
73434
|
+
}
|
|
73435
|
+
async toldMigrated(error63) {
|
|
73436
|
+
const found = migratedNoticeOf(error63);
|
|
73437
|
+
if (found && this.options.onMigrated)
|
|
73438
|
+
await this.options.onMigrated(found).catch(() => void 0);
|
|
73439
|
+
else if (!found && refusesTheKey(error63) && this.options.onRefused)
|
|
73440
|
+
await this.options.onRefused(error63).catch(() => void 0);
|
|
73441
|
+
}
|
|
73442
|
+
async send({
|
|
73443
|
+
method,
|
|
73444
|
+
path,
|
|
73445
|
+
body,
|
|
73446
|
+
signal
|
|
73447
|
+
}) {
|
|
73448
|
+
const headers = {
|
|
73449
|
+
...this.options.headers,
|
|
73450
|
+
accept: "application/json",
|
|
73451
|
+
[CLI_VERSION_HEADER]: cliVersionOf()
|
|
73452
|
+
};
|
|
73453
|
+
if (body !== void 0) headers["content-type"] = "application/json";
|
|
73454
|
+
if (this.options.token) headers.authorization = `Bearer ${this.options.token}`;
|
|
73455
|
+
const response = await this.options.fetcher(`${this.options.baseUrl}${path}`, {
|
|
73456
|
+
method,
|
|
73457
|
+
headers,
|
|
73458
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {},
|
|
73459
|
+
...signal ? { signal } : {}
|
|
73460
|
+
});
|
|
73461
|
+
const text3 = await response.text();
|
|
73462
|
+
if (!response.ok) {
|
|
73463
|
+
const error63 = apiErrorOf({ status: response.status, text: text3 });
|
|
73464
|
+
await this.toldMigrated(error63);
|
|
73465
|
+
throw error63;
|
|
73466
|
+
}
|
|
73467
|
+
if (this.options.onAnswered) await this.options.onAnswered().catch(() => void 0);
|
|
73468
|
+
return text3 ? JSON.parse(text3) : void 0;
|
|
73469
|
+
}
|
|
73470
|
+
};
|
|
73471
|
+
function apiErrorOf({ status: status11, text: text3 }) {
|
|
73472
|
+
let body;
|
|
73473
|
+
try {
|
|
73474
|
+
body = text3 ? JSON.parse(text3) : void 0;
|
|
73475
|
+
} catch {
|
|
73476
|
+
body = void 0;
|
|
73477
|
+
}
|
|
73478
|
+
return errorOf({ status: status11, body });
|
|
73479
|
+
}
|
|
73480
|
+
function errorOf({ status: status11, body }) {
|
|
73481
|
+
const record4 = typeof body === "object" && body !== null ? body : {};
|
|
73482
|
+
const nested = typeof record4.error === "object" && record4.error !== null ? record4.error : record4;
|
|
73483
|
+
const fallback = typeof record4.error === "string" ? record4.error : `http_${status11}`;
|
|
73484
|
+
const code4 = typeof nested.code === "string" ? nested.code : fallback;
|
|
73485
|
+
const message2 = typeof nested.message === "string" ? nested.message : `Laze answered ${status11}`;
|
|
73486
|
+
const meta3 = typeof nested.meta === "object" && nested.meta !== null ? nested.meta : void 0;
|
|
73487
|
+
const error63 = new LazeApiError(status11, code4, message2);
|
|
73488
|
+
error63.meta = meta3;
|
|
73489
|
+
return error63;
|
|
73490
|
+
}
|
|
73491
|
+
|
|
73336
73492
|
// src/services/machine-report.service.ts
|
|
73493
|
+
import { createHash } from "node:crypto";
|
|
73494
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
73495
|
+
import { hostname as hostname3 } from "node:os";
|
|
73337
73496
|
async function reportMachine({
|
|
73338
73497
|
context,
|
|
73339
73498
|
profile,
|
|
@@ -73405,14 +73564,20 @@ async function turnTokenOf({ context }) {
|
|
|
73405
73564
|
() => ""
|
|
73406
73565
|
);
|
|
73407
73566
|
}
|
|
73408
|
-
function harnessSessionKeyOf({ context }) {
|
|
73567
|
+
async function harnessSessionKeyOf({ context }) {
|
|
73409
73568
|
const { harness, inherited } = context.environment;
|
|
73410
73569
|
const ids = {
|
|
73411
73570
|
"claude-code": inherited.CLAUDE_CODE_SESSION_ID,
|
|
73412
73571
|
codex: inherited.CODEX_THREAD_ID
|
|
73413
73572
|
};
|
|
73414
73573
|
const sessionId = ids[harness];
|
|
73415
|
-
|
|
73574
|
+
if (sessionId) return sessionKeyOf({ session: { harness, sessionId } });
|
|
73575
|
+
if (harness !== "claude-code") return void 0;
|
|
73576
|
+
const nearest = await nearestHarnessOf({ context }).catch(() => void 0);
|
|
73577
|
+
if (nearest?.harness !== "claude-code") return void 0;
|
|
73578
|
+
const path = statePathOf({ context, kind: "sessions", profile: String(nearest.pid) });
|
|
73579
|
+
const noted = await readStateJson({ path });
|
|
73580
|
+
return noted ? sessionKeyOf({ session: noted }) : void 0;
|
|
73416
73581
|
}
|
|
73417
73582
|
async function profileKindOf({
|
|
73418
73583
|
context,
|
|
@@ -73422,7 +73587,7 @@ async function profileKindOf({
|
|
|
73422
73587
|
config: await context.store.read(),
|
|
73423
73588
|
flag: flagText({ args, name: "profile" }) || void 0,
|
|
73424
73589
|
environment: context.environment.profile,
|
|
73425
|
-
session: harnessSessionKeyOf({ context }),
|
|
73590
|
+
session: await harnessSessionKeyOf({ context }),
|
|
73426
73591
|
cwd: context.cwd
|
|
73427
73592
|
});
|
|
73428
73593
|
return chosen.profile?.kind;
|
|
@@ -73436,7 +73601,7 @@ async function signedIn({
|
|
|
73436
73601
|
config: config2,
|
|
73437
73602
|
flag: flagText({ args, name: "profile" }) || void 0,
|
|
73438
73603
|
environment: context.environment.profile,
|
|
73439
|
-
session: harnessSessionKeyOf({ context }),
|
|
73604
|
+
session: await harnessSessionKeyOf({ context }),
|
|
73440
73605
|
cwd: context.cwd
|
|
73441
73606
|
});
|
|
73442
73607
|
if (!chosen.profile)
|
|
@@ -73820,7 +73985,7 @@ async function copyAgent({
|
|
|
73820
73985
|
|
|
73821
73986
|
// src/services/agent-commands.service.ts
|
|
73822
73987
|
import { mkdir as mkdir6, readFile as readFile12, writeFile as writeFile3 } from "node:fs/promises";
|
|
73823
|
-
import { join as
|
|
73988
|
+
import { join as join22, resolve as resolve4 } from "node:path";
|
|
73824
73989
|
|
|
73825
73990
|
// src/rules/link-format.rules.ts
|
|
73826
73991
|
function linkOf({ url: url2, base }) {
|
|
@@ -73934,85 +74099,6 @@ ${lines2.join("\n")}
|
|
|
73934
74099
|
`;
|
|
73935
74100
|
}
|
|
73936
74101
|
|
|
73937
|
-
// src/rules/hook-settings.rules.ts
|
|
73938
|
-
var LAZE_HOOK_MARKER = "laze-cli-hook";
|
|
73939
|
-
var HOOK_TIMEOUTS = { Stop: 30, PreToolUse: 5, SessionStart: 30 };
|
|
73940
|
-
var TIMEOUTS = HOOK_TIMEOUTS;
|
|
73941
|
-
var WAIT_HOOK_TIMEOUT_SECONDS = 7 * 24 * 60 * 60;
|
|
73942
|
-
function withHooks({
|
|
73943
|
-
hooks,
|
|
73944
|
-
event,
|
|
73945
|
-
added
|
|
73946
|
-
}) {
|
|
73947
|
-
const current3 = Array.isArray(hooks[event]) ? hooks[event] : [];
|
|
73948
|
-
const others = current3.filter(
|
|
73949
|
-
(entry2) => !entry2.hooks?.some((hook) => hook.command?.includes(LAZE_HOOK_MARKER))
|
|
73950
|
-
);
|
|
73951
|
-
hooks[event] = [...others, ...added.map((hook) => ({ hooks: [hook] }))];
|
|
73952
|
-
}
|
|
73953
|
-
function withLazeHooks({
|
|
73954
|
-
settings: settings3,
|
|
73955
|
-
stopCommand,
|
|
73956
|
-
waitCommand,
|
|
73957
|
-
preToolCommand
|
|
73958
|
-
}) {
|
|
73959
|
-
const hooks = { ...settings3.hooks };
|
|
73960
|
-
withHooks({
|
|
73961
|
-
hooks,
|
|
73962
|
-
event: "Stop",
|
|
73963
|
-
added: [
|
|
73964
|
-
{ type: "command", command: stopCommand, timeout: TIMEOUTS.Stop },
|
|
73965
|
-
{
|
|
73966
|
-
type: "command",
|
|
73967
|
-
command: waitCommand,
|
|
73968
|
-
timeout: WAIT_HOOK_TIMEOUT_SECONDS,
|
|
73969
|
-
async: true,
|
|
73970
|
-
asyncRewake: true
|
|
73971
|
-
}
|
|
73972
|
-
]
|
|
73973
|
-
});
|
|
73974
|
-
withHooks({
|
|
73975
|
-
hooks,
|
|
73976
|
-
event: "SessionStart",
|
|
73977
|
-
added: [
|
|
73978
|
-
{
|
|
73979
|
-
type: "command",
|
|
73980
|
-
command: waitCommand,
|
|
73981
|
-
timeout: WAIT_HOOK_TIMEOUT_SECONDS,
|
|
73982
|
-
async: true,
|
|
73983
|
-
asyncRewake: true
|
|
73984
|
-
}
|
|
73985
|
-
]
|
|
73986
|
-
});
|
|
73987
|
-
withHooks({
|
|
73988
|
-
hooks,
|
|
73989
|
-
event: "PreToolUse",
|
|
73990
|
-
added: [{ type: "command", command: preToolCommand, timeout: TIMEOUTS.PreToolUse }]
|
|
73991
|
-
});
|
|
73992
|
-
return { ...settings3, hooks };
|
|
73993
|
-
}
|
|
73994
|
-
function hookCommand({
|
|
73995
|
-
program,
|
|
73996
|
-
profile,
|
|
73997
|
-
hook
|
|
73998
|
-
}) {
|
|
73999
|
-
const quote4 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
74000
|
-
const words = [...program, "hook", hook, "--profile", profile].map(quote4).join(" ");
|
|
74001
|
-
return `${words} # ${LAZE_HOOK_MARKER}`;
|
|
74002
|
-
}
|
|
74003
|
-
function holdsOurs({ settings: settings3, event }) {
|
|
74004
|
-
const hooks = settings3.hooks ?? {};
|
|
74005
|
-
return Array.isArray(hooks[event]) && hooks[event].some(
|
|
74006
|
-
(entry2) => entry2.hooks?.some((hook) => hook.command?.includes(LAZE_HOOK_MARKER))
|
|
74007
|
-
);
|
|
74008
|
-
}
|
|
74009
|
-
function lacksSessionStartWaiter({ settings: settings3 }) {
|
|
74010
|
-
return holdsOurs({ settings: settings3, event: "Stop" }) && !holdsOurs({ settings: settings3, event: "SessionStart" });
|
|
74011
|
-
}
|
|
74012
|
-
function hasLazeHooks({ settings: settings3 }) {
|
|
74013
|
-
return holdsOurs({ settings: settings3, event: "Stop" });
|
|
74014
|
-
}
|
|
74015
|
-
|
|
74016
74102
|
// src/rules/inbox-format.rules.ts
|
|
74017
74103
|
function whereOf(message2) {
|
|
74018
74104
|
if (message2.channelKind === "dm" || message2.channelKind === "group") return "a direct message";
|
|
@@ -75086,6 +75172,27 @@ function waitsForLinesOf({ posted }) {
|
|
|
75086
75172
|
}).join("");
|
|
75087
75173
|
}
|
|
75088
75174
|
|
|
75175
|
+
// src/rules/post-request-id.rules.ts
|
|
75176
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
75177
|
+
var POST_REQUEST_ID_HEADER = "x-laze-request-id";
|
|
75178
|
+
var POST_REPEAT_WINDOW_MS = 15 * 6e4;
|
|
75179
|
+
function postRequestIdOf({
|
|
75180
|
+
path,
|
|
75181
|
+
payload,
|
|
75182
|
+
nowMs: nowMs2
|
|
75183
|
+
}) {
|
|
75184
|
+
const { attachmentIds: _files, ...said } = payload;
|
|
75185
|
+
const window2 = Math.floor(nowMs2 / POST_REPEAT_WINDOW_MS);
|
|
75186
|
+
const digest = createHash2("sha256").update(
|
|
75187
|
+
JSON.stringify([
|
|
75188
|
+
path,
|
|
75189
|
+
window2,
|
|
75190
|
+
Object.entries(said).toSorted(([a], [b]) => a.localeCompare(b))
|
|
75191
|
+
])
|
|
75192
|
+
).digest("base64url");
|
|
75193
|
+
return `p${digest.slice(0, 40)}`;
|
|
75194
|
+
}
|
|
75195
|
+
|
|
75089
75196
|
// src/rules/search-format.rules.ts
|
|
75090
75197
|
var SNIPPET_CHARACTERS = 160;
|
|
75091
75198
|
var TOKEN = /<@(person|agent):([A-Za-z0-9_-]+)>|<!(channel|here)>|<#([A-Za-z0-9_-]{1,64})>/g;
|
|
@@ -75237,12 +75344,12 @@ function formatSearch({
|
|
|
75237
75344
|
|
|
75238
75345
|
// src/services/claude-turn.service.ts
|
|
75239
75346
|
import { rm as rm3 } from "node:fs/promises";
|
|
75240
|
-
import { dirname as
|
|
75347
|
+
import { dirname as dirname9, join as join11 } from "node:path";
|
|
75241
75348
|
|
|
75242
75349
|
// src/services/harness-session.service.ts
|
|
75243
|
-
import { open as open3, readdir as readdir3,
|
|
75350
|
+
import { open as open3, readdir as readdir3, stat as stat3 } from "node:fs/promises";
|
|
75244
75351
|
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
75245
|
-
import { dirname as
|
|
75352
|
+
import { dirname as dirname7, join as join8 } from "node:path";
|
|
75246
75353
|
|
|
75247
75354
|
// src/rules/claude-subagent.rules.ts
|
|
75248
75355
|
function lastCallAtOf({ text: text3, command }) {
|
|
@@ -75335,50 +75442,22 @@ function launchEnvOf({
|
|
|
75335
75442
|
return picked;
|
|
75336
75443
|
}
|
|
75337
75444
|
|
|
75338
|
-
// src/services/
|
|
75339
|
-
import {
|
|
75340
|
-
|
|
75341
|
-
|
|
75342
|
-
|
|
75343
|
-
|
|
75344
|
-
const
|
|
75345
|
-
|
|
75346
|
-
|
|
75347
|
-
|
|
75348
|
-
|
|
75349
|
-
from = context.processes.pid
|
|
75350
|
-
}) {
|
|
75351
|
-
let pid = await context.processes.parentOf(from);
|
|
75352
|
-
for (let depth = 0; pid !== void 0 && pid > 1 && depth < 12; depth += 1) {
|
|
75353
|
-
const harness = harnessIn({ words: await context.processes.argsOf(pid) ?? [] });
|
|
75354
|
-
if (harness) return { harness, pid };
|
|
75355
|
-
pid = await context.processes.parentOf(pid);
|
|
75356
|
-
}
|
|
75357
|
-
return void 0;
|
|
75358
|
-
}
|
|
75359
|
-
function holds({ folder, inner }) {
|
|
75360
|
-
const rel = relative2(resolve2(folder), resolve2(inner));
|
|
75361
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
75362
|
-
}
|
|
75363
|
-
async function claudeFoldersOf({
|
|
75364
|
-
context,
|
|
75365
|
-
claudePid
|
|
75366
|
-
}) {
|
|
75367
|
-
const env = context.environment.inherited;
|
|
75368
|
-
const pid = Number(env.CLAUDE_PID);
|
|
75369
|
-
const candidates = [
|
|
75370
|
-
claudePid ? await context.processes.cwdOf(claudePid) : void 0,
|
|
75371
|
-
env.CLAUDE_PROJECT_DIR ? resolve2(env.CLAUDE_PROJECT_DIR) : void 0,
|
|
75372
|
-
pid > 0 ? await context.processes.cwdOf(pid) : void 0
|
|
75373
|
-
].filter((folder) => Boolean(folder));
|
|
75374
|
-
const holding = candidates.find((folder) => holds({ folder, inner: context.cwd }));
|
|
75375
|
-
if (holding) return { folder: holding, elsewhere: void 0 };
|
|
75376
|
-
return { folder: resolve2(context.cwd), elsewhere: candidates[0] };
|
|
75445
|
+
// src/services/connect-log.service.ts
|
|
75446
|
+
import { appendFile, mkdir as mkdir2 } from "node:fs/promises";
|
|
75447
|
+
import { dirname as dirname5, join as join6 } from "node:path";
|
|
75448
|
+
async function logDelivery({ context, line }) {
|
|
75449
|
+
const folder = join6(dirname5(context.environment.configPath), "connect");
|
|
75450
|
+
const at8 = Temporal3.Instant.fromEpochMilliseconds(context.nowMs());
|
|
75451
|
+
const stamped = `${at8.toString({ smallestUnit: "second" })} ${line}
|
|
75452
|
+
`;
|
|
75453
|
+
context.out(stamped);
|
|
75454
|
+
await mkdir2(folder, { recursive: true, mode: 448 });
|
|
75455
|
+
await appendFile(join6(folder, "delivery.log"), stamped, { mode: 384 });
|
|
75377
75456
|
}
|
|
75378
75457
|
|
|
75379
75458
|
// src/services/session-notes.service.ts
|
|
75380
75459
|
import { readdir as readdir2, rm as rm2, stat as stat2 } from "node:fs/promises";
|
|
75381
|
-
import { dirname as
|
|
75460
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
75382
75461
|
function notePathOf({ context, pid }) {
|
|
75383
75462
|
return statePathOf({ context, kind: "sessions", profile: String(pid) });
|
|
75384
75463
|
}
|
|
@@ -75425,13 +75504,13 @@ async function sessionNotesOf({
|
|
|
75425
75504
|
context,
|
|
75426
75505
|
tell = true
|
|
75427
75506
|
}) {
|
|
75428
|
-
const folder =
|
|
75507
|
+
const folder = dirname6(notePathOf({ context, pid: 1 }));
|
|
75429
75508
|
const files2 = await readdir2(folder).catch(() => []);
|
|
75430
75509
|
const notes = [];
|
|
75431
75510
|
const dropped = [];
|
|
75432
75511
|
for (const file4 of files2) {
|
|
75433
75512
|
const pid = Number(file4.replace(/\.json$/, ""));
|
|
75434
|
-
const path =
|
|
75513
|
+
const path = join7(folder, file4);
|
|
75435
75514
|
const note = pid ? await readStateJson({ path }) : void 0;
|
|
75436
75515
|
if (!note) continue;
|
|
75437
75516
|
const standing = await standingOf({ context, pid, note });
|
|
@@ -75503,24 +75582,51 @@ async function currentSessionOf({
|
|
|
75503
75582
|
const path = statePathOf({ context, kind: "sessions", profile: String(nearest.pid) });
|
|
75504
75583
|
return readStateJson({ path });
|
|
75505
75584
|
}
|
|
75585
|
+
async function sessionAgentOf({
|
|
75586
|
+
context,
|
|
75587
|
+
session
|
|
75588
|
+
}) {
|
|
75589
|
+
if (!session) return void 0;
|
|
75590
|
+
const config2 = await context.store.read();
|
|
75591
|
+
const bound = config2.sessions?.[sessionKeyOf({ session })];
|
|
75592
|
+
const profile = bound ? config2.profiles[bound] : void 0;
|
|
75593
|
+
return bound && profile?.kind === "agent" && !profile.migrated ? bound : void 0;
|
|
75594
|
+
}
|
|
75506
75595
|
async function sessionProfileArgs({
|
|
75507
75596
|
context,
|
|
75508
75597
|
args,
|
|
75509
|
-
session
|
|
75510
|
-
binds = true
|
|
75598
|
+
session
|
|
75511
75599
|
}) {
|
|
75512
|
-
if (
|
|
75513
|
-
const
|
|
75600
|
+
if (flagText({ args, name: "profile" })) return args;
|
|
75601
|
+
const bound = await sessionAgentOf({ context, session });
|
|
75602
|
+
return bound ? { ...args, flags: { ...args.flags, profile: bound } } : args;
|
|
75603
|
+
}
|
|
75604
|
+
async function carryOverClear({
|
|
75605
|
+
context,
|
|
75606
|
+
claudePid,
|
|
75607
|
+
session
|
|
75608
|
+
}) {
|
|
75609
|
+
if (!session || !claudePid) return void 0;
|
|
75610
|
+
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
75611
|
+
const before = await readStateJson({ path });
|
|
75612
|
+
if (!before || before.sessionId === session.sessionId) return void 0;
|
|
75613
|
+
const profile = await sessionAgentOf({ context, session: before });
|
|
75614
|
+
if (!profile) return void 0;
|
|
75514
75615
|
const config2 = await context.store.read();
|
|
75515
|
-
const
|
|
75516
|
-
if (
|
|
75517
|
-
|
|
75518
|
-
|
|
75519
|
-
|
|
75520
|
-
|
|
75521
|
-
|
|
75522
|
-
}
|
|
75523
|
-
|
|
75616
|
+
const own2 = config2.profiles[profile];
|
|
75617
|
+
if (!own2) return void 0;
|
|
75618
|
+
const client = LazeClient.create({
|
|
75619
|
+
baseUrl: own2.url,
|
|
75620
|
+
token: own2.token,
|
|
75621
|
+
fetcher: context.fetcher
|
|
75622
|
+
});
|
|
75623
|
+
await forSession({ client, session }).post("/api/agents/me/bind", {});
|
|
75624
|
+
await context.store.bindSession({ session: sessionKeyOf({ session }), profile });
|
|
75625
|
+
await logDelivery({
|
|
75626
|
+
context: { ...context, out: () => void 0 },
|
|
75627
|
+
line: `${profile}: /clear moved the agent from ${sessionKeyOf({ session: before })} to ${sessionKeyOf({ session })}`
|
|
75628
|
+
}).catch(() => void 0);
|
|
75629
|
+
return profile;
|
|
75524
75630
|
}
|
|
75525
75631
|
async function rushListingOf({ context }) {
|
|
75526
75632
|
let listed = "";
|
|
@@ -75561,14 +75667,14 @@ async function claudeTranscriptOf({
|
|
|
75561
75667
|
sessionId
|
|
75562
75668
|
}) {
|
|
75563
75669
|
const inherited = context.environment.inherited;
|
|
75564
|
-
const root =
|
|
75565
|
-
inherited.CLAUDE_CONFIG_DIR ||
|
|
75670
|
+
const root = join8(
|
|
75671
|
+
inherited.CLAUDE_CONFIG_DIR || join8(inherited.HOME || homedir2(), ".claude"),
|
|
75566
75672
|
"projects"
|
|
75567
75673
|
);
|
|
75568
75674
|
const folders = await readdir3(root).catch(() => []);
|
|
75569
75675
|
const found = await Promise.all(
|
|
75570
75676
|
folders.map(async (folder) => {
|
|
75571
|
-
const path =
|
|
75677
|
+
const path = join8(root, folder, `${sessionId}.jsonl`);
|
|
75572
75678
|
return stat3(path).then(
|
|
75573
75679
|
(info) => info.isFile() ? [{ path, at: info.mtimeMs }] : [],
|
|
75574
75680
|
() => []
|
|
@@ -75596,11 +75702,11 @@ async function runsInSubagent({ context, command }) {
|
|
|
75596
75702
|
if (!sessionId) return false;
|
|
75597
75703
|
const { path } = await claudeTranscriptOf({ context, sessionId });
|
|
75598
75704
|
if (!path) return false;
|
|
75599
|
-
const folder =
|
|
75705
|
+
const folder = join8(dirname7(path), sessionId, "subagents");
|
|
75600
75706
|
const files2 = await readdir3(folder).catch(() => []);
|
|
75601
75707
|
const subagents = await Promise.all(
|
|
75602
75708
|
files2.filter((file4) => file4.endsWith(".jsonl")).map(
|
|
75603
|
-
async (file4) => lastCallAtOf({ text: await tailOf({ path:
|
|
75709
|
+
async (file4) => lastCallAtOf({ text: await tailOf({ path: join8(folder, file4) }), command })
|
|
75604
75710
|
)
|
|
75605
75711
|
);
|
|
75606
75712
|
const session = lastCallAtOf({ text: await tailOf({ path }), command });
|
|
@@ -75617,96 +75723,142 @@ async function refuseInSubagent({
|
|
|
75617
75723
|
"This runs inside a Claude Code subagent, which shares its parent's session: it would take that session. Run it in the session itself, or pass --session <id>."
|
|
75618
75724
|
);
|
|
75619
75725
|
}
|
|
75620
|
-
function notBoundText({
|
|
75621
|
-
meta: meta3,
|
|
75622
|
-
agent: agent3,
|
|
75623
|
-
configPath
|
|
75624
|
-
}) {
|
|
75625
|
-
const who = `${agent3 ? `"${agent3}"` : "this agent"} (config ${configPath})`;
|
|
75626
|
-
return `Laze: ${who} listens in another session${meta3.bound ? `: ${meta3.bound}` : ""}. Create a new Laze agent with this session: laze agent request. Or move this agent here: laze agent bind.`;
|
|
75627
|
-
}
|
|
75628
75726
|
function boundMetaOf({ error: error63 }) {
|
|
75629
75727
|
if (!(error63 instanceof LazeApiError) || error63.code !== "session_not_bound") return void 0;
|
|
75630
75728
|
return error63.meta ?? {};
|
|
75631
75729
|
}
|
|
75632
|
-
async function
|
|
75730
|
+
async function droppedBinding({
|
|
75633
75731
|
context,
|
|
75634
|
-
client,
|
|
75635
75732
|
session,
|
|
75636
|
-
|
|
75733
|
+
error: error63,
|
|
75637
75734
|
profile
|
|
75638
75735
|
}) {
|
|
75639
|
-
|
|
75640
|
-
|
|
75641
|
-
|
|
75642
|
-
const
|
|
75643
|
-
|
|
75644
|
-
|
|
75645
|
-
|
|
75646
|
-
|
|
75736
|
+
const meta3 = boundMetaOf({ error: error63 });
|
|
75737
|
+
if (!meta3) return false;
|
|
75738
|
+
if (!session) return true;
|
|
75739
|
+
const key = sessionKeyOf({ session });
|
|
75740
|
+
if (await context.store.unbindSession({ session: key, profile })) {
|
|
75741
|
+
await logDelivery({
|
|
75742
|
+
context: { ...context, out: () => void 0 },
|
|
75743
|
+
line: `${profile}: Laze binds the agent to ${meta3.bound ?? meta3.session ?? "another session"}, so ${key} no longer listens for it`
|
|
75744
|
+
}).catch(() => void 0);
|
|
75745
|
+
}
|
|
75647
75746
|
return true;
|
|
75648
75747
|
}
|
|
75649
|
-
|
|
75748
|
+
|
|
75749
|
+
// src/services/plugin-hook.service.ts
|
|
75750
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
75751
|
+
import { join as join10 } from "node:path";
|
|
75752
|
+
|
|
75753
|
+
// src/services/session-migration.service.ts
|
|
75754
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
75755
|
+
import { hostname as hostname5 } from "node:os";
|
|
75756
|
+
import { dirname as dirname8, join as join9 } from "node:path";
|
|
75757
|
+
var START_EVERY_MS = 10 * 60 * 1e3;
|
|
75758
|
+
function needsMigration({ config: config2 }) {
|
|
75759
|
+
return !config2.sessionsMigratedAt && Object.keys(config2.bindings).length > 0;
|
|
75760
|
+
}
|
|
75761
|
+
async function migrateLaterIfNeeded({ context }) {
|
|
75762
|
+
if (!needsMigration({ config: await context.store.read() })) return;
|
|
75763
|
+
const marker = statePathOf({ context, kind: "told", profile: "sessions-migration" });
|
|
75764
|
+
const last = Number(await readFile6(marker, "utf8").catch(() => "0"));
|
|
75765
|
+
if (context.nowMs() - last < START_EVERY_MS) return;
|
|
75766
|
+
await writeStateText({ path: marker, text: String(context.nowMs()) });
|
|
75767
|
+
const logPath = join9(dirname8(context.environment.configPath), "connect", "migrate.log");
|
|
75768
|
+
context.processes.spawnDetached({
|
|
75769
|
+
argv: [...context.program, "agent", "sessions", "--migrate"],
|
|
75770
|
+
logPath
|
|
75771
|
+
});
|
|
75772
|
+
}
|
|
75773
|
+
async function boundOf({ context, profile }) {
|
|
75774
|
+
const entry2 = (await context.store.read()).profiles[profile];
|
|
75775
|
+
if (!entry2) return "unknown";
|
|
75776
|
+
const client = LazeClient.create({
|
|
75777
|
+
baseUrl: entry2.url,
|
|
75778
|
+
token: entry2.token,
|
|
75779
|
+
fetcher: (input2, init) => context.fetcher(input2, { ...init, signal: AbortSignal.timeout(1e4) })
|
|
75780
|
+
});
|
|
75781
|
+
const waiting = await client.get("/api/agents/me/inbox/waiting").catch(() => void 0);
|
|
75782
|
+
if (!waiting) return "unknown";
|
|
75783
|
+
const session = waiting.session;
|
|
75784
|
+
return session ? { key: `${session.harness}:${session.sessionId}`, host: session.host } : null;
|
|
75785
|
+
}
|
|
75786
|
+
async function settleProfile({
|
|
75650
75787
|
context,
|
|
75651
|
-
|
|
75652
|
-
|
|
75653
|
-
error: error63,
|
|
75654
|
-
profile
|
|
75788
|
+
profile,
|
|
75789
|
+
bound
|
|
75655
75790
|
}) {
|
|
75656
|
-
if (
|
|
75657
|
-
const
|
|
75658
|
-
|
|
75659
|
-
|
|
75660
|
-
|
|
75661
|
-
|
|
75662
|
-
|
|
75663
|
-
|
|
75664
|
-
|
|
75665
|
-
|
|
75791
|
+
if (bound === "unknown") return `${profile}: Laze did not say where it listens; left as it is`;
|
|
75792
|
+
const here = bound && bound.host === hostname5() ? bound.key : void 0;
|
|
75793
|
+
return context.store.update((config2) => {
|
|
75794
|
+
const sessions = config2.sessions ?? {};
|
|
75795
|
+
const mine5 = Object.keys(sessions).filter((key) => sessions[key] === profile);
|
|
75796
|
+
if (bound === null) {
|
|
75797
|
+
return { result: `${profile}: bound to no session in Laze; ${mine5.length} kept` };
|
|
75798
|
+
}
|
|
75799
|
+
const taken = here && sessions[here] && sessions[here] !== profile;
|
|
75800
|
+
const kept = Object.fromEntries(
|
|
75801
|
+
Object.entries(sessions).filter(([key, name3]) => name3 !== profile || key === here)
|
|
75802
|
+
);
|
|
75803
|
+
const next = here && !taken ? { ...kept, [here]: profile } : kept;
|
|
75804
|
+
const where = here ?? `${bound.key} on ${bound.host}`;
|
|
75805
|
+
const line = taken ? `${profile}: Laze binds it to ${here}, which this machine binds to ${sessions[here]}; left unbound here` : `${profile}: listens in ${where}; dropped ${mine5.filter((key) => key !== here).length} other sessions`;
|
|
75806
|
+
return { result: line, config: { ...config2, sessions: next } };
|
|
75807
|
+
});
|
|
75808
|
+
}
|
|
75809
|
+
async function migrateSessions({ context }) {
|
|
75810
|
+
const config2 = await context.store.read();
|
|
75811
|
+
const agents2 = Object.entries(config2.profiles).filter(
|
|
75812
|
+
([, one]) => one.kind === "agent" && !one.migrated && !one.refused
|
|
75666
75813
|
);
|
|
75667
|
-
|
|
75668
|
-
|
|
75669
|
-
|
|
75670
|
-
|
|
75671
|
-
|
|
75672
|
-
|
|
75814
|
+
const lines2 = [];
|
|
75815
|
+
for (const [profile] of agents2) {
|
|
75816
|
+
const bound = await boundOf({ context, profile });
|
|
75817
|
+
lines2.push(await settleProfile({ context, profile, bound }));
|
|
75818
|
+
}
|
|
75819
|
+
const dropped = await context.store.update((current3) => {
|
|
75820
|
+
const gone = Object.entries(current3.bindings).filter(
|
|
75821
|
+
([directory, profile]) => linkedFolder({ config: config2, directory, profile })
|
|
75822
|
+
);
|
|
75823
|
+
const bindings = Object.fromEntries(
|
|
75824
|
+
Object.entries(current3.bindings).filter(
|
|
75825
|
+
([directory]) => gone.every(([other]) => other !== directory)
|
|
75826
|
+
)
|
|
75827
|
+
);
|
|
75828
|
+
const next = { ...current3, bindings, sessionsMigratedAt: context.nowMs() };
|
|
75829
|
+
return { result: gone, config: next };
|
|
75830
|
+
});
|
|
75831
|
+
for (const [directory, profile] of dropped) {
|
|
75832
|
+
lines2.push(`${profile}: dropped the folder binding of ${directory}`);
|
|
75833
|
+
}
|
|
75834
|
+
for (const line of lines2) {
|
|
75835
|
+
await logDelivery({ context: { ...context, out: () => void 0 }, line: `migrate ${line}` });
|
|
75836
|
+
}
|
|
75837
|
+
return lines2;
|
|
75673
75838
|
}
|
|
75674
75839
|
|
|
75675
75840
|
// src/services/plugin-hook.service.ts
|
|
75676
|
-
import { readFile as readFile7 } from "node:fs/promises";
|
|
75677
|
-
import { join as join7 } from "node:path";
|
|
75678
75841
|
async function agentProfileHere({
|
|
75679
75842
|
context,
|
|
75680
|
-
|
|
75681
|
-
session,
|
|
75682
|
-
claudePid
|
|
75843
|
+
session
|
|
75683
75844
|
}) {
|
|
75684
|
-
|
|
75685
|
-
const cwd = (claudePid ? await context.processes.cwdOf(claudePid) : void 0) ?? (context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd);
|
|
75686
|
-
const folder = boundProfileOf({ bindings: config2.bindings, cwd });
|
|
75687
|
-
if (!folder && !session) return void 0;
|
|
75688
|
-
const asked = { ...args, flags: { ...args.flags, ...folder ? { profile: folder } : {} } };
|
|
75689
|
-
const name3 = flagText({
|
|
75690
|
-
args: await sessionProfileArgs({ context, args: asked, session, binds: false }),
|
|
75691
|
-
name: "profile"
|
|
75692
|
-
});
|
|
75693
|
-
const profile = name3 ? config2.profiles[name3] : void 0;
|
|
75694
|
-
return name3 && profile?.kind === "agent" && !profile.migrated ? name3 : void 0;
|
|
75845
|
+
return sessionAgentOf({ context, session });
|
|
75695
75846
|
}
|
|
75696
75847
|
async function projectHooksHere({ context }) {
|
|
75697
75848
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd;
|
|
75698
|
-
const path =
|
|
75849
|
+
const path = join10(directory, ".claude", "settings.local.json");
|
|
75699
75850
|
return readFile7(path, "utf8").then((text3) => hasLazeHooks({ settings: JSON.parse(text3) })).catch(() => false);
|
|
75700
75851
|
}
|
|
75701
75852
|
async function pluginHookArgs({
|
|
75702
75853
|
context,
|
|
75703
75854
|
args,
|
|
75704
75855
|
session,
|
|
75705
|
-
claudePid
|
|
75856
|
+
claudePid,
|
|
75857
|
+
source
|
|
75706
75858
|
}) {
|
|
75707
|
-
|
|
75708
|
-
if (await projectHooksHere({ context })) return void 0;
|
|
75709
|
-
const profile = await agentProfileHere({ context,
|
|
75859
|
+
await migrateLaterIfNeeded({ context }).catch(() => void 0);
|
|
75860
|
+
if (args.flags.plugin && await projectHooksHere({ context })) return void 0;
|
|
75861
|
+
const profile = await agentProfileHere({ context, session }) ?? (source === "clear" ? await carryOverClear({ context, claudePid, session }).catch(() => void 0) : void 0);
|
|
75710
75862
|
return profile ? { ...args, flags: { ...args.flags, profile } } : void 0;
|
|
75711
75863
|
}
|
|
75712
75864
|
|
|
@@ -75714,7 +75866,7 @@ async function pluginHookArgs({
|
|
|
75714
75866
|
var PRE_TOOL_TIMEOUT_MS = 3e3;
|
|
75715
75867
|
function statePath({ context, agent: agent3 }) {
|
|
75716
75868
|
const safe = agent3.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
75717
|
-
return
|
|
75869
|
+
return join11(dirname9(context.environment.configPath), "turns", `${safe}.json`);
|
|
75718
75870
|
}
|
|
75719
75871
|
async function readState({ context, agent: agent3 }) {
|
|
75720
75872
|
return readStateJson({ path: statePath({ context, agent: agent3 }) });
|
|
@@ -76368,6 +76520,14 @@ function turnAnswersOf({ context }) {
|
|
|
76368
76520
|
var FILES_USAGE = "[--image <path|url|fileId>]... [--file <path|url|fileId>]... (at most 6)";
|
|
76369
76521
|
var POST_USAGE = `Usage: laze post <channel> <text|-> [--thread <id>] ${FILES_USAGE} [--at <time> [--tz <zone>]] [--json]`;
|
|
76370
76522
|
var REPLY_USAGE = `Usage: laze reply <message-id> <text|-> [--new-thread] [--also-channel] ${FILES_USAGE} [--at <time> [--tz <zone>]]`;
|
|
76523
|
+
function keyedPost({
|
|
76524
|
+
client,
|
|
76525
|
+
path,
|
|
76526
|
+
payload
|
|
76527
|
+
}) {
|
|
76528
|
+
const requestId = postRequestIdOf({ path, payload, nowMs: nowInstant().epochMilliseconds });
|
|
76529
|
+
return client.withHeaders({ [POST_REQUEST_ID_HEADER]: requestId }).post(path, payload);
|
|
76530
|
+
}
|
|
76371
76531
|
async function filesOf({
|
|
76372
76532
|
context,
|
|
76373
76533
|
args,
|
|
@@ -76407,12 +76567,16 @@ async function post({
|
|
|
76407
76567
|
const target = { channel, ...thread2 ? { threadRootId: thread2 } : {} };
|
|
76408
76568
|
return scheduleMessage({ context, args, client, at: at8, target, body });
|
|
76409
76569
|
}
|
|
76410
|
-
const posted = await
|
|
76411
|
-
|
|
76412
|
-
|
|
76413
|
-
|
|
76414
|
-
|
|
76415
|
-
|
|
76570
|
+
const posted = await keyedPost({
|
|
76571
|
+
client,
|
|
76572
|
+
path: "/api/agents/me/messages",
|
|
76573
|
+
payload: {
|
|
76574
|
+
channel,
|
|
76575
|
+
body,
|
|
76576
|
+
...thread2 ? { threadRootId: thread2 } : {},
|
|
76577
|
+
...files2,
|
|
76578
|
+
...turnAnswersOf({ context })
|
|
76579
|
+
}
|
|
76416
76580
|
});
|
|
76417
76581
|
if (args.flags.json) {
|
|
76418
76582
|
context.out(`${JSON.stringify(posted, null, 2)}
|
|
@@ -76448,14 +76612,18 @@ async function reply({
|
|
|
76448
76612
|
if (at8) {
|
|
76449
76613
|
return scheduleMessage({ context, args, client, at: at8, target: { replyTo: messageId }, body });
|
|
76450
76614
|
}
|
|
76451
|
-
const posted = await
|
|
76452
|
-
|
|
76453
|
-
|
|
76454
|
-
|
|
76455
|
-
|
|
76456
|
-
|
|
76457
|
-
|
|
76458
|
-
|
|
76615
|
+
const posted = await keyedPost({
|
|
76616
|
+
client,
|
|
76617
|
+
path: "/api/agents/me/replies",
|
|
76618
|
+
payload: {
|
|
76619
|
+
messageId,
|
|
76620
|
+
body,
|
|
76621
|
+
...channel ? { channel } : {},
|
|
76622
|
+
...args.flags["new-thread"] === true ? { thread: true } : {},
|
|
76623
|
+
...args.flags["also-channel"] === true ? { alsoInChannel: true } : {},
|
|
76624
|
+
...files2,
|
|
76625
|
+
...turnAnswersOf({ context })
|
|
76626
|
+
}
|
|
76459
76627
|
});
|
|
76460
76628
|
await dropFromSpool({ context, profile: name3, messageIds: [messageId] }).catch(() => void 0);
|
|
76461
76629
|
context.out(
|
|
@@ -76634,9 +76802,9 @@ var ListenerBackoff = class {
|
|
|
76634
76802
|
};
|
|
76635
76803
|
|
|
76636
76804
|
// src/services/connect-service.service.ts
|
|
76637
|
-
import { createHash as
|
|
76805
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
76638
76806
|
import { mkdir as mkdir3, rm as rm5, writeFile } from "node:fs/promises";
|
|
76639
|
-
import { dirname as
|
|
76807
|
+
import { dirname as dirname14, join as join17 } from "node:path";
|
|
76640
76808
|
|
|
76641
76809
|
// src/rules/connect-service.rules.ts
|
|
76642
76810
|
function systemdWordOf(word3) {
|
|
@@ -76715,20 +76883,6 @@ function launchAgentOf({
|
|
|
76715
76883
|
function codexQueueFailureOf({ stderr: stderr2 }) {
|
|
76716
76884
|
return /no rollout found|thread not found|unknown thread/i.test(stderr2) ? "thread_unknown" : "failed";
|
|
76717
76885
|
}
|
|
76718
|
-
function rolloutSessionOf({
|
|
76719
|
-
firstLine
|
|
76720
|
-
}) {
|
|
76721
|
-
try {
|
|
76722
|
-
const parsed = JSON.parse(firstLine);
|
|
76723
|
-
const { id: id8, cwd } = parsed.payload ?? {};
|
|
76724
|
-
if (parsed.type !== "session_meta" || typeof id8 !== "string" || typeof cwd !== "string") {
|
|
76725
|
-
return void 0;
|
|
76726
|
-
}
|
|
76727
|
-
return { id: id8, cwd };
|
|
76728
|
-
} catch {
|
|
76729
|
-
return void 0;
|
|
76730
|
-
}
|
|
76731
|
-
}
|
|
76732
76886
|
function userTextOf({ parsed }) {
|
|
76733
76887
|
const payload = parsed.payload ?? {};
|
|
76734
76888
|
if (parsed.type === "event_msg" && payload.type === "user_message") {
|
|
@@ -76759,24 +76913,24 @@ function rolloutEventOf({
|
|
|
76759
76913
|
|
|
76760
76914
|
// src/services/connect-delivery.service.ts
|
|
76761
76915
|
import { rm as rm4, stat as stat5 } from "node:fs/promises";
|
|
76762
|
-
import { homedir as homedir3, hostname as
|
|
76763
|
-
import { dirname as
|
|
76916
|
+
import { homedir as homedir3, hostname as hostname6 } from "node:os";
|
|
76917
|
+
import { dirname as dirname13, join as join16 } from "node:path";
|
|
76764
76918
|
|
|
76765
76919
|
// src/services/codex-turn-watch.service.ts
|
|
76766
76920
|
import { open as open4, readdir as readdir4 } from "node:fs/promises";
|
|
76767
|
-
import { basename as basename5, join as
|
|
76921
|
+
import { basename as basename5, join as join12 } from "node:path";
|
|
76768
76922
|
var READ_MS = 1500;
|
|
76769
76923
|
var KEEP_WORKING_MS = 3e4;
|
|
76770
76924
|
async function codexRolloutPathOf({
|
|
76771
76925
|
codexHome,
|
|
76772
76926
|
threadId
|
|
76773
76927
|
}) {
|
|
76774
|
-
const root =
|
|
76928
|
+
const root = join12(codexHome, "sessions");
|
|
76775
76929
|
const files2 = await readdir4(root, { recursive: true }).catch(() => []);
|
|
76776
76930
|
const file4 = files2.find(
|
|
76777
76931
|
(name3) => basename5(name3).startsWith("rollout-") && name3.endsWith(`-${threadId}.jsonl`)
|
|
76778
76932
|
);
|
|
76779
|
-
return file4 ?
|
|
76933
|
+
return file4 ? join12(root, file4) : void 0;
|
|
76780
76934
|
}
|
|
76781
76935
|
function rolloutPathOf({ delivery }) {
|
|
76782
76936
|
return codexRolloutPathOf({ codexHome: delivery.codexHome, threadId: delivery.threadId });
|
|
@@ -76865,7 +77019,7 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
76865
77019
|
};
|
|
76866
77020
|
|
|
76867
77021
|
// src/services/mcp-relay.service.ts
|
|
76868
|
-
import { dirname as
|
|
77022
|
+
import { dirname as dirname10, join as join13 } from "node:path";
|
|
76869
77023
|
|
|
76870
77024
|
// ../../node_modules/.pnpm/ws@8.21.3_bufferutil@4.1.0/node_modules/ws/wrapper.mjs
|
|
76871
77025
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -77201,7 +77355,7 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
77201
77355
|
[CONNECTOR_RELAY_CLOSE.replaced.code, "another relay for this server took over"]
|
|
77202
77356
|
]);
|
|
77203
77357
|
function mcpRelaysPathOf({ context }) {
|
|
77204
|
-
return
|
|
77358
|
+
return join13(dirname10(context.environment.configPath), "connect", "mcp-relays.json");
|
|
77205
77359
|
}
|
|
77206
77360
|
async function readMcpRelays({ context }) {
|
|
77207
77361
|
return await readStateJson({ path: mcpRelaysPathOf({ context }) }) ?? {};
|
|
@@ -77361,7 +77515,7 @@ var McpRelayLoops = class _McpRelayLoops {
|
|
|
77361
77515
|
};
|
|
77362
77516
|
|
|
77363
77517
|
// src/services/openclaw-relay.service.ts
|
|
77364
|
-
import { dirname as
|
|
77518
|
+
import { dirname as dirname11, join as join14 } from "node:path";
|
|
77365
77519
|
|
|
77366
77520
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
77367
77521
|
var workspaceIdSchema18 = external_exports.string().min(1);
|
|
@@ -77582,7 +77736,7 @@ var STOPS2 = /* @__PURE__ */ new Map([
|
|
|
77582
77736
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
77583
77737
|
]);
|
|
77584
77738
|
function relaysPathOf({ context }) {
|
|
77585
|
-
return
|
|
77739
|
+
return join14(dirname11(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
77586
77740
|
}
|
|
77587
77741
|
async function readRelays({ context }) {
|
|
77588
77742
|
return await readStateJson({ path: relaysPathOf({ context }) }) ?? {};
|
|
@@ -77775,7 +77929,7 @@ var RelayLoops = class _RelayLoops {
|
|
|
77775
77929
|
};
|
|
77776
77930
|
|
|
77777
77931
|
// src/services/rush-host.service.ts
|
|
77778
|
-
import { dirname as
|
|
77932
|
+
import { dirname as dirname12, join as join15 } from "node:path";
|
|
77779
77933
|
async function rushAboveOf({
|
|
77780
77934
|
context,
|
|
77781
77935
|
from = context.processes.pid
|
|
@@ -77789,7 +77943,7 @@ async function rushAboveOf({
|
|
|
77789
77943
|
return void 0;
|
|
77790
77944
|
}
|
|
77791
77945
|
function guardPathOf({ context, claudePid }) {
|
|
77792
|
-
return
|
|
77946
|
+
return join15(dirname12(context.environment.configPath), "rush-guards", `${claudePid}.json`);
|
|
77793
77947
|
}
|
|
77794
77948
|
async function startRushGuard({
|
|
77795
77949
|
context,
|
|
@@ -77802,7 +77956,7 @@ async function startRushGuard({
|
|
|
77802
77956
|
if (holder && context.processes.alive(holder.pid)) return;
|
|
77803
77957
|
const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
|
|
77804
77958
|
const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
|
|
77805
|
-
const logPath =
|
|
77959
|
+
const logPath = join15(dirname12(context.environment.configPath), "rush-guards", "guard.log");
|
|
77806
77960
|
context.processes.spawnDetached({ argv: ["sh", "-c", '"$@" &', "sh", ...argv], logPath });
|
|
77807
77961
|
}
|
|
77808
77962
|
async function claimRushGuard({
|
|
@@ -77919,8 +78073,6 @@ async function rearmRushGuards({ context }) {
|
|
|
77919
78073
|
}
|
|
77920
78074
|
|
|
77921
78075
|
// src/services/rush-watchdog.service.ts
|
|
77922
|
-
import { appendFile, mkdir as mkdir2 } from "node:fs/promises";
|
|
77923
|
-
import { dirname as dirname11, join as join13 } from "node:path";
|
|
77924
78076
|
var UNDELIVERED_AFTER_MS = 6e4;
|
|
77925
78077
|
var CHECK_TIMEOUT_MS = 5e3;
|
|
77926
78078
|
function clientOf({ context, profile }) {
|
|
@@ -77955,38 +78107,20 @@ function boundAwayOf({ waiting, key }) {
|
|
|
77955
78107
|
if (!bound || `${bound.harness}:${bound.sessionId}` === key) return void 0;
|
|
77956
78108
|
return `${sessionLabelOf(bound)} (${bound.harness}:${bound.sessionId})`;
|
|
77957
78109
|
}
|
|
77958
|
-
async function logDelivery({ context, line }) {
|
|
77959
|
-
const folder = join13(dirname11(context.environment.configPath), "connect");
|
|
77960
|
-
const at8 = Temporal3.Instant.fromEpochMilliseconds(context.nowMs());
|
|
77961
|
-
const stamped = `${at8.toString({ smallestUnit: "second" })} ${line}
|
|
77962
|
-
`;
|
|
77963
|
-
context.out(stamped);
|
|
77964
|
-
await mkdir2(folder, { recursive: true, mode: 448 });
|
|
77965
|
-
await appendFile(join13(folder, "delivery.log"), stamped, { mode: 384 });
|
|
77966
|
-
}
|
|
77967
78110
|
async function claimFor({
|
|
77968
78111
|
context,
|
|
77969
78112
|
client,
|
|
77970
78113
|
row
|
|
77971
78114
|
}) {
|
|
77972
78115
|
const session = row.noted.session;
|
|
77973
|
-
const claim3 = () => forSession({ client, session }).post("/api/agents/me/inbox", {
|
|
77974
|
-
waitSeconds: 0
|
|
77975
|
-
});
|
|
77976
78116
|
try {
|
|
77977
|
-
return await
|
|
78117
|
+
return await forSession({ client, session }).post("/api/agents/me/inbox", {
|
|
78118
|
+
waitSeconds: 0
|
|
78119
|
+
});
|
|
77978
78120
|
} catch (error63) {
|
|
77979
|
-
const meta3 = boundMetaOf({ error: error63 });
|
|
77980
|
-
if (!meta3) throw error63;
|
|
77981
78121
|
const profile = row.profile;
|
|
77982
|
-
if (!await
|
|
77983
|
-
|
|
77984
|
-
}
|
|
77985
|
-
await logDelivery({
|
|
77986
|
-
context,
|
|
77987
|
-
line: `${profile}: moved the agent from ${meta3.session} to ${row.key}, which this machine binds it to`
|
|
77988
|
-
});
|
|
77989
|
-
return claim3();
|
|
78122
|
+
if (!await droppedBinding({ context, session, error: error63, profile })) throw error63;
|
|
78123
|
+
return `Laze binds it to another session, so rush ${row.rushId} no longer listens for it`;
|
|
77990
78124
|
}
|
|
77991
78125
|
}
|
|
77992
78126
|
async function checkSession({ context, row }) {
|
|
@@ -78038,10 +78172,10 @@ async function watchRushDelivery({
|
|
|
78038
78172
|
|
|
78039
78173
|
// src/services/connect-delivery.service.ts
|
|
78040
78174
|
function connectFolderOf({ context }) {
|
|
78041
|
-
return
|
|
78175
|
+
return join16(dirname13(context.environment.configPath), "connect");
|
|
78042
78176
|
}
|
|
78043
78177
|
function runStatePathOf({ context }) {
|
|
78044
|
-
return
|
|
78178
|
+
return join16(connectFolderOf({ context }), "run.json");
|
|
78045
78179
|
}
|
|
78046
78180
|
async function readJson({ path }) {
|
|
78047
78181
|
return readStateJson({ path });
|
|
@@ -78099,7 +78233,7 @@ async function takeRound({
|
|
|
78099
78233
|
harness: "codex",
|
|
78100
78234
|
sessionId: delivery.threadId,
|
|
78101
78235
|
folder: displayFolderOf({ folder: delivery.cwd, home: homedir3() }),
|
|
78102
|
-
host:
|
|
78236
|
+
host: hostname6()
|
|
78103
78237
|
};
|
|
78104
78238
|
try {
|
|
78105
78239
|
return await client.withHeaders(sessionHeadersOf({ session })).post("/api/agents/me/inbox", { waitSeconds: ROUND_SECONDS }, { signal });
|
|
@@ -78339,18 +78473,18 @@ var CONNECT_SERVICE_USAGE = `laze connect install|status|stop|uninstall|run: the
|
|
|
78339
78473
|
\`laze openclaw connect --local\` and \`laze kanban connect\`, whose relays it also runs.
|
|
78340
78474
|
`;
|
|
78341
78475
|
function installedPathOf({ context }) {
|
|
78342
|
-
return
|
|
78476
|
+
return join17(connectFolderOf({ context }), "service.json");
|
|
78343
78477
|
}
|
|
78344
78478
|
function logPathOf({ context }) {
|
|
78345
|
-
return
|
|
78479
|
+
return join17(connectFolderOf({ context }), "connect.log");
|
|
78346
78480
|
}
|
|
78347
78481
|
function homeOf({ context }) {
|
|
78348
|
-
return context.environment.inherited.HOME ??
|
|
78482
|
+
return context.environment.inherited.HOME ?? dirname14(dirname14(context.environment.configPath));
|
|
78349
78483
|
}
|
|
78350
78484
|
function serviceNameOf({ context }) {
|
|
78351
78485
|
const { configPath } = context.environment;
|
|
78352
|
-
if (configPath ===
|
|
78353
|
-
return `laze-connect-${
|
|
78486
|
+
if (configPath === join17(homeOf({ context }), ".laze", "config.json")) return "laze-connect";
|
|
78487
|
+
return `laze-connect-${createHash3("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
78354
78488
|
}
|
|
78355
78489
|
function serviceEnvOf({ context }) {
|
|
78356
78490
|
const path = context.environment.inherited.PATH;
|
|
@@ -78372,9 +78506,9 @@ async function run({ context, command }) {
|
|
|
78372
78506
|
async function installSystemd({ context }) {
|
|
78373
78507
|
const name3 = serviceNameOf({ context });
|
|
78374
78508
|
const env = context.environment.inherited;
|
|
78375
|
-
const base = env.XDG_CONFIG_HOME ||
|
|
78376
|
-
const file4 =
|
|
78377
|
-
await mkdir3(
|
|
78509
|
+
const base = env.XDG_CONFIG_HOME || join17(homeOf({ context }), ".config");
|
|
78510
|
+
const file4 = join17(base, "systemd", "user", `${name3}.service`);
|
|
78511
|
+
await mkdir3(dirname14(file4), { recursive: true });
|
|
78378
78512
|
await writeFile(
|
|
78379
78513
|
file4,
|
|
78380
78514
|
systemdUnitOf({ argv: runArgvOf({ context }), env: serviceEnvOf({ context }) })
|
|
@@ -78388,9 +78522,9 @@ async function installSystemd({ context }) {
|
|
|
78388
78522
|
async function installLaunchd({ context }) {
|
|
78389
78523
|
const name3 = serviceNameOf({ context });
|
|
78390
78524
|
const label3 = `ai.laze.${name3}`;
|
|
78391
|
-
const file4 =
|
|
78525
|
+
const file4 = join17(homeOf({ context }), "Library", "LaunchAgents", `${label3}.plist`);
|
|
78392
78526
|
const log = logPathOf({ context });
|
|
78393
|
-
await mkdir3(
|
|
78527
|
+
await mkdir3(dirname14(file4), { recursive: true });
|
|
78394
78528
|
await writeFile(
|
|
78395
78529
|
file4,
|
|
78396
78530
|
launchAgentOf({
|
|
@@ -78706,24 +78840,10 @@ async function claudePidOf({ context }) {
|
|
|
78706
78840
|
async function settleRound(round) {
|
|
78707
78841
|
const { context, client, name: name3, session } = round;
|
|
78708
78842
|
const messages = await roundOf(round).catch(async (error63) => {
|
|
78709
|
-
|
|
78710
|
-
|
|
78711
|
-
client: forSession({ client, session }),
|
|
78712
|
-
session,
|
|
78713
|
-
error: error63,
|
|
78714
|
-
profile: name3
|
|
78715
|
-
});
|
|
78716
|
-
if (!refused) throw error63;
|
|
78717
|
-
return refused;
|
|
78843
|
+
if (await droppedBinding({ context, session, error: error63, profile: name3 })) return void 0;
|
|
78844
|
+
throw error63;
|
|
78718
78845
|
});
|
|
78719
78846
|
if (messages === void 0) return 0;
|
|
78720
|
-
if (!Array.isArray(messages)) {
|
|
78721
|
-
if (messages.rebound) return "again";
|
|
78722
|
-
if (!messages.notice) return 0;
|
|
78723
|
-
context.err(`${messages.notice}
|
|
78724
|
-
`);
|
|
78725
|
-
return 2;
|
|
78726
|
-
}
|
|
78727
78847
|
if (messages.length === 0) return "again";
|
|
78728
78848
|
const self2 = await currentNameOf({ context, client, profile: name3 });
|
|
78729
78849
|
const text3 = hookContextOf({ messages, self: self2 });
|
|
@@ -78749,9 +78869,8 @@ async function waitForMessages({ context, args }) {
|
|
|
78749
78869
|
const input2 = raw.trim() ? JSON.parse(raw) : {};
|
|
78750
78870
|
const session = sessionOf({ context, harness: "claude-code", sessionId: input2.session_id });
|
|
78751
78871
|
const claudePid = await claudePidOf({ context });
|
|
78752
|
-
const
|
|
78753
|
-
if (!
|
|
78754
|
-
const named = await sessionProfileArgs({ context, args: asked, session });
|
|
78872
|
+
const named = await pluginHookArgs({ context, args, session, claudePid, source: input2.source });
|
|
78873
|
+
if (!named) return 0;
|
|
78755
78874
|
const { client, name: name3 } = await signedIn({ context, args: named });
|
|
78756
78875
|
await rememberSession({ context, claudePid, session });
|
|
78757
78876
|
const rush = claudePid ? await rushAboveOf({ context, from: claudePid }) : void 0;
|
|
@@ -78871,15 +78990,12 @@ async function monitorServes({
|
|
|
78871
78990
|
}
|
|
78872
78991
|
|
|
78873
78992
|
// src/services/codex-link.service.ts
|
|
78874
|
-
import {
|
|
78875
|
-
import { readdir as readdir6, rm as rm8, stat as stat7 } from "node:fs/promises";
|
|
78876
|
-
import { join as join17, resolve as resolve4 } from "node:path";
|
|
78877
|
-
import { createInterface as createInterface2 } from "node:readline";
|
|
78993
|
+
import { rm as rm8 } from "node:fs/promises";
|
|
78878
78994
|
|
|
78879
78995
|
// src/services/codex-adopt.service.ts
|
|
78880
78996
|
import { spawn as spawn2 } from "node:child_process";
|
|
78881
78997
|
import { readdir as readdir5, rm as rm7, stat as stat6 } from "node:fs/promises";
|
|
78882
|
-
import { join as
|
|
78998
|
+
import { join as join18 } from "node:path";
|
|
78883
78999
|
import { createInterface } from "node:readline";
|
|
78884
79000
|
|
|
78885
79001
|
// src/rules/codex-requests.rules.ts
|
|
@@ -78938,8 +79054,8 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
78938
79054
|
}
|
|
78939
79055
|
async call(method, params) {
|
|
78940
79056
|
const id8 = ++this.#nextId;
|
|
78941
|
-
const reply2 = await new Promise((
|
|
78942
|
-
this.#pending.set(id8,
|
|
79057
|
+
const reply2 = await new Promise((resolve27) => {
|
|
79058
|
+
this.#pending.set(id8, resolve27);
|
|
78943
79059
|
this.write({ id: id8, method, params });
|
|
78944
79060
|
});
|
|
78945
79061
|
if (reply2.error !== void 0) throw new Error(`${method}: ${JSON.stringify(reply2.error)}`);
|
|
@@ -78951,12 +79067,12 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
78951
79067
|
/** Starts one turn; `done` settles when it completes, keeping its last agent message. */
|
|
78952
79068
|
async startTurn({ threadId, text: text3 }) {
|
|
78953
79069
|
const result2 = { answer: "" };
|
|
78954
|
-
const done = new Promise((
|
|
79070
|
+
const done = new Promise((resolve27) => {
|
|
78955
79071
|
const listen = (message2) => {
|
|
78956
79072
|
absorbTurnEvent({ result: result2, message: message2 });
|
|
78957
79073
|
if (message2.method !== "turn/completed") return;
|
|
78958
79074
|
this.#listeners.delete(listen);
|
|
78959
|
-
|
|
79075
|
+
resolve27(result2);
|
|
78960
79076
|
};
|
|
78961
79077
|
this.#listeners.add(listen);
|
|
78962
79078
|
});
|
|
@@ -78999,11 +79115,11 @@ var CodexAppServer = class _CodexAppServer {
|
|
|
78999
79115
|
}
|
|
79000
79116
|
};
|
|
79001
79117
|
async function newestThreadId({ codexHome }) {
|
|
79002
|
-
const root =
|
|
79118
|
+
const root = join18(codexHome, "sessions");
|
|
79003
79119
|
const files2 = await readdir5(root, { recursive: true }).catch(() => []);
|
|
79004
79120
|
const rollouts = files2.filter((file4) => /rollout-.*\.jsonl$/.test(file4));
|
|
79005
79121
|
const dated = await Promise.all(
|
|
79006
|
-
rollouts.map(async (file4) => ({ file: file4, at: (await stat6(
|
|
79122
|
+
rollouts.map(async (file4) => ({ file: file4, at: (await stat6(join18(root, file4))).mtimeMs }))
|
|
79007
79123
|
);
|
|
79008
79124
|
const newest = dated.toSorted((a, b) => b.at - a.at)[0]?.file ?? "";
|
|
79009
79125
|
const id8 = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/.exec(newest);
|
|
@@ -79248,49 +79364,8 @@ async function adoptCodex({ context, args }) {
|
|
|
79248
79364
|
}
|
|
79249
79365
|
|
|
79250
79366
|
// src/services/codex-link.service.ts
|
|
79251
|
-
|
|
79252
|
-
|
|
79253
|
-
const stream = createReadStream(path, { encoding: "utf8" });
|
|
79254
|
-
const lines2 = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
79255
|
-
try {
|
|
79256
|
-
for await (const line of lines2) return line;
|
|
79257
|
-
return "";
|
|
79258
|
-
} finally {
|
|
79259
|
-
lines2.close();
|
|
79260
|
-
stream.destroy();
|
|
79261
|
-
}
|
|
79262
|
-
}
|
|
79263
|
-
async function newestThreadIn({
|
|
79264
|
-
codexHome,
|
|
79265
|
-
directory
|
|
79266
|
-
}) {
|
|
79267
|
-
const root = join17(codexHome, "sessions");
|
|
79268
|
-
const files2 = await readdir6(root, { recursive: true }).catch(() => []);
|
|
79269
|
-
const rollouts = files2.filter((file4) => /rollout-.*\.jsonl$/.test(file4));
|
|
79270
|
-
const dated = await Promise.all(
|
|
79271
|
-
rollouts.map(async (file4) => ({
|
|
79272
|
-
path: join17(root, file4),
|
|
79273
|
-
at: await stat7(join17(root, file4)).then(
|
|
79274
|
-
(info) => info.mtimeMs,
|
|
79275
|
-
() => 0
|
|
79276
|
-
)
|
|
79277
|
-
}))
|
|
79278
|
-
);
|
|
79279
|
-
const newest = dated.toSorted((a, b) => b.at - a.at).slice(0, ROLLOUTS_READ);
|
|
79280
|
-
for (const { path } of newest) {
|
|
79281
|
-
const session = rolloutSessionOf({ firstLine: await firstLineOf({ path }).catch(() => "") });
|
|
79282
|
-
if (session && resolve4(session.cwd) === resolve4(directory)) return session.id;
|
|
79283
|
-
}
|
|
79284
|
-
return void 0;
|
|
79285
|
-
}
|
|
79286
|
-
async function threadOf({
|
|
79287
|
-
context,
|
|
79288
|
-
args,
|
|
79289
|
-
directory
|
|
79290
|
-
}) {
|
|
79291
|
-
const named = flagText({ args, name: "thread" }) || context.environment.inherited.CODEX_THREAD_ID;
|
|
79292
|
-
if (named) return named;
|
|
79293
|
-
return newestThreadIn({ codexHome: context.environment.codexHome, directory });
|
|
79367
|
+
function threadOf({ context, args }) {
|
|
79368
|
+
return flagText({ args, name: "thread" }) || context.environment.inherited.CODEX_THREAD_ID;
|
|
79294
79369
|
}
|
|
79295
79370
|
async function codexQueues({ context }) {
|
|
79296
79371
|
const code4 = await context.runCommand({ command: ["sh", "-c", "codex queue --help >/dev/null 2>&1"], env: {} }).catch(() => 1);
|
|
@@ -79303,6 +79378,24 @@ async function stopAdopt({ context, profile }) {
|
|
|
79303
79378
|
context.processes.stop(running.pid);
|
|
79304
79379
|
await rm8(path, { force: true });
|
|
79305
79380
|
}
|
|
79381
|
+
async function bindThread({
|
|
79382
|
+
context,
|
|
79383
|
+
args,
|
|
79384
|
+
profile,
|
|
79385
|
+
threadId
|
|
79386
|
+
}) {
|
|
79387
|
+
const session = sessionOf({ context, harness: "codex", sessionId: threadId });
|
|
79388
|
+
if (!session) return;
|
|
79389
|
+
await context.store.bindSession({ session: sessionKeyOf({ session }), profile });
|
|
79390
|
+
try {
|
|
79391
|
+
const named = { ...args, flags: { ...args.flags, profile } };
|
|
79392
|
+
const { client } = await signedIn({ context, args: named });
|
|
79393
|
+
await forSession({ client, session }).post("/api/agents/me/bind", {});
|
|
79394
|
+
} catch (error63) {
|
|
79395
|
+
context.err(`laze: could not bind the agent to this thread yet: ${String(error63)}
|
|
79396
|
+
`);
|
|
79397
|
+
}
|
|
79398
|
+
}
|
|
79306
79399
|
async function linkCodexSession({
|
|
79307
79400
|
context,
|
|
79308
79401
|
args,
|
|
@@ -79310,8 +79403,12 @@ async function linkCodexSession({
|
|
|
79310
79403
|
laze,
|
|
79311
79404
|
directory
|
|
79312
79405
|
}) {
|
|
79313
|
-
const threadId =
|
|
79314
|
-
if (!threadId
|
|
79406
|
+
const threadId = threadOf({ context, args });
|
|
79407
|
+
if (!threadId) {
|
|
79408
|
+
return `No Codex thread id here (CODEX_THREAD_ID): link again with --thread <id>, so ${profile} is bound to that thread and no other.`;
|
|
79409
|
+
}
|
|
79410
|
+
await bindThread({ context, args, profile, threadId });
|
|
79411
|
+
if (!await codexQueues({ context })) {
|
|
79315
79412
|
return startAdoptInBackground({ context, args, profile, laze });
|
|
79316
79413
|
}
|
|
79317
79414
|
await stopAdopt({ context, profile });
|
|
@@ -79342,15 +79439,15 @@ async function linkCodexSession({
|
|
|
79342
79439
|
// src/services/laze-plugin.service.ts
|
|
79343
79440
|
import { mkdir as mkdir4, readFile as readFile10, rm as rm9, writeFile as writeFile2 } from "node:fs/promises";
|
|
79344
79441
|
import { homedir as homedir4 } from "node:os";
|
|
79345
|
-
import { dirname as
|
|
79442
|
+
import { dirname as dirname15, join as join20 } from "node:path";
|
|
79346
79443
|
|
|
79347
79444
|
// src/rules/laze-plugin.rules.ts
|
|
79348
|
-
import { createHash as
|
|
79349
|
-
import { join as
|
|
79445
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
79446
|
+
import { join as join19 } from "node:path";
|
|
79350
79447
|
var LAZE_PLUGIN = "laze";
|
|
79351
79448
|
function pluginNameOf({ configPath, home }) {
|
|
79352
|
-
if (configPath ===
|
|
79353
|
-
return `${LAZE_PLUGIN}-${
|
|
79449
|
+
if (configPath === join19(home, ".laze", "config.json")) return LAZE_PLUGIN;
|
|
79450
|
+
return `${LAZE_PLUGIN}-${createHash4("sha256").update(configPath).digest("hex").slice(0, 8)}`;
|
|
79354
79451
|
}
|
|
79355
79452
|
var NPX_CLI = ["npx", "-y", "@lazehq/cli@latest"];
|
|
79356
79453
|
var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
@@ -79620,10 +79717,10 @@ function installedNameOf({ context }) {
|
|
|
79620
79717
|
return `${name3}@${name3}`;
|
|
79621
79718
|
}
|
|
79622
79719
|
function pluginFolderOf({ context }) {
|
|
79623
|
-
return
|
|
79720
|
+
return join20(dirname15(context.environment.configPath), "plugins");
|
|
79624
79721
|
}
|
|
79625
79722
|
async function pluginIsCurrent({ context }) {
|
|
79626
|
-
const manifest =
|
|
79723
|
+
const manifest = join20(pluginFolderOf({ context }), LAZE_PLUGIN, ".claude-plugin", "plugin.json");
|
|
79627
79724
|
const written = await readFile10(manifest, "utf8").then((text3) => JSON.parse(text3).version).catch(() => void 0);
|
|
79628
79725
|
return written === cliVersionOf();
|
|
79629
79726
|
}
|
|
@@ -79636,8 +79733,8 @@ async function writeLazePlugin({ context }) {
|
|
|
79636
79733
|
configPath: context.environment.configPath
|
|
79637
79734
|
});
|
|
79638
79735
|
for (const [path, text3] of Object.entries(files2)) {
|
|
79639
|
-
const target =
|
|
79640
|
-
await mkdir4(
|
|
79736
|
+
const target = join20(folder, path);
|
|
79737
|
+
await mkdir4(dirname15(target), { recursive: true });
|
|
79641
79738
|
await writeFile2(target, text3);
|
|
79642
79739
|
}
|
|
79643
79740
|
return folder;
|
|
@@ -79667,7 +79764,7 @@ async function registerWithClaude({ context, folder }) {
|
|
|
79667
79764
|
return claudeScript({ context, script });
|
|
79668
79765
|
}
|
|
79669
79766
|
function claudeDirOf({ context }) {
|
|
79670
|
-
return context.environment.inherited.CLAUDE_CONFIG_DIR ||
|
|
79767
|
+
return context.environment.inherited.CLAUDE_CONFIG_DIR || join20(homeOf2({ context }), ".claude");
|
|
79671
79768
|
}
|
|
79672
79769
|
function unregisterAs({ context, name: name3 }) {
|
|
79673
79770
|
const script = [
|
|
@@ -79679,7 +79776,7 @@ function unregisterAs({ context, name: name3 }) {
|
|
|
79679
79776
|
async function dropOwnLeftover({ context, folder }) {
|
|
79680
79777
|
if (pluginNameHere({ context }) === LAZE_PLUGIN) return;
|
|
79681
79778
|
const known = await readFile10(
|
|
79682
|
-
|
|
79779
|
+
join20(claudeDirOf({ context }), "plugins", "known_marketplaces.json"),
|
|
79683
79780
|
"utf8"
|
|
79684
79781
|
).then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
79685
79782
|
if (known?.[LAZE_PLUGIN]?.source?.path !== folder) return;
|
|
@@ -79687,7 +79784,7 @@ async function dropOwnLeftover({ context, folder }) {
|
|
|
79687
79784
|
}
|
|
79688
79785
|
var RUN_FILES = ["hooks/hooks.json", "monitors/monitors.json"];
|
|
79689
79786
|
async function cachedPluginOf({ context }) {
|
|
79690
|
-
const path =
|
|
79787
|
+
const path = join20(claudeDirOf({ context }), "plugins", "installed_plugins.json");
|
|
79691
79788
|
const listed = await readFile10(path, "utf8").then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
79692
79789
|
return listed?.plugins?.[installedNameOf({ context })]?.[0]?.installPath;
|
|
79693
79790
|
}
|
|
@@ -79696,8 +79793,8 @@ async function refreshStaleCache({ context, folder }) {
|
|
|
79696
79793
|
if (!cached2) return true;
|
|
79697
79794
|
const read4 = (path) => readFile10(path, "utf8").catch(() => "");
|
|
79698
79795
|
for (const file4 of RUN_FILES) {
|
|
79699
|
-
const ours = await read4(
|
|
79700
|
-
if (ours === await read4(
|
|
79796
|
+
const ours = await read4(join20(folder, LAZE_PLUGIN, file4));
|
|
79797
|
+
if (ours === await read4(join20(cached2, file4))) continue;
|
|
79701
79798
|
const plugin2 = installedNameOf({ context });
|
|
79702
79799
|
const script = [
|
|
79703
79800
|
`claude plugin uninstall ${plugin2} --scope user ${QUIET}`,
|
|
@@ -79708,7 +79805,7 @@ async function refreshStaleCache({ context, folder }) {
|
|
|
79708
79805
|
return true;
|
|
79709
79806
|
}
|
|
79710
79807
|
function registeredMarkOf({ context }) {
|
|
79711
|
-
return
|
|
79808
|
+
return join20(pluginFolderOf({ context }), "registered");
|
|
79712
79809
|
}
|
|
79713
79810
|
async function pluginRegistered({ context }) {
|
|
79714
79811
|
return readFile10(registeredMarkOf({ context }), "utf8").then(
|
|
@@ -79726,7 +79823,7 @@ async function installLazePlugin({ context }) {
|
|
|
79726
79823
|
async function plugin({ context, args }) {
|
|
79727
79824
|
const action = args.words[1] ?? "install";
|
|
79728
79825
|
if (action === "path") {
|
|
79729
|
-
context.out(`${
|
|
79826
|
+
context.out(`${join20(pluginFolderOf({ context }), LAZE_PLUGIN)}
|
|
79730
79827
|
`);
|
|
79731
79828
|
return 0;
|
|
79732
79829
|
}
|
|
@@ -79990,16 +80087,17 @@ async function reloadTipOnce({
|
|
|
79990
80087
|
|
|
79991
80088
|
// src/services/session-scrub.service.ts
|
|
79992
80089
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
79993
|
-
import { createHash as
|
|
80090
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
79994
80091
|
import { mkdir as mkdir5, open as open5 } from "node:fs/promises";
|
|
79995
|
-
import { dirname as
|
|
80092
|
+
import { dirname as dirname16, join as join21 } from "node:path";
|
|
79996
80093
|
|
|
79997
80094
|
// src/rules/session-scrub.rules.ts
|
|
79998
80095
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
79999
80096
|
var SESSION_SCRUB_BATCH_LINES = 200;
|
|
80000
|
-
var SESSION_SCRUB_BATCH_BYTES =
|
|
80097
|
+
var SESSION_SCRUB_BATCH_BYTES = VAULT_SESSION_SCRUB_MAX_TEXT;
|
|
80001
80098
|
var SESSION_SCRUB_MAX_BATCHES = 8;
|
|
80002
|
-
var
|
|
80099
|
+
var SESSION_SCRUB_READ_BYTES = SESSION_SCRUB_BATCH_BYTES * SESSION_SCRUB_MAX_BATCHES;
|
|
80100
|
+
var SESSION_SCRUB_MAX_LINE = VAULT_SESSION_SCRUB_MAX_LINE;
|
|
80003
80101
|
function completeLinesOf({ chunk, from }) {
|
|
80004
80102
|
const lines2 = [];
|
|
80005
80103
|
let start2 = 0;
|
|
@@ -80050,15 +80148,15 @@ function paddedTo({ text: text3, bytes }) {
|
|
|
80050
80148
|
|
|
80051
80149
|
// src/services/session-scrub.service.ts
|
|
80052
80150
|
function offsetPathOf({ context, transcript }) {
|
|
80053
|
-
const key =
|
|
80054
|
-
return
|
|
80151
|
+
const key = createHash5("sha256").update(transcript).digest("hex").slice(0, 24);
|
|
80152
|
+
return join21(dirname16(context.environment.configPath), "session-scrub", `${key}.json`);
|
|
80055
80153
|
}
|
|
80056
80154
|
async function offsetOf({ path }) {
|
|
80057
80155
|
const saved3 = await readStateJson({ path });
|
|
80058
80156
|
return typeof saved3?.offset === "number" && saved3.offset >= 0 ? saved3.offset : 0;
|
|
80059
80157
|
}
|
|
80060
80158
|
async function keepOffset({ path, offset }) {
|
|
80061
|
-
await mkdir5(
|
|
80159
|
+
await mkdir5(dirname16(path), { recursive: true });
|
|
80062
80160
|
await writeStateJson({ path, value: { offset } });
|
|
80063
80161
|
}
|
|
80064
80162
|
async function stillThere({ file: file4, line }) {
|
|
@@ -80096,6 +80194,19 @@ async function writeBack({ file: file4, rewrites }) {
|
|
|
80096
80194
|
await file4.truncate(first.line.at + out.length);
|
|
80097
80195
|
return moved;
|
|
80098
80196
|
}
|
|
80197
|
+
async function pastLongLine({
|
|
80198
|
+
file: file4,
|
|
80199
|
+
from,
|
|
80200
|
+
size
|
|
80201
|
+
}) {
|
|
80202
|
+
const chunk = Buffer3.alloc(SESSION_SCRUB_READ_BYTES);
|
|
80203
|
+
for (let at8 = from; at8 < size; at8 += chunk.length) {
|
|
80204
|
+
const { bytesRead } = await file4.read(chunk, 0, chunk.length, at8);
|
|
80205
|
+
const newline = chunk.subarray(0, bytesRead).indexOf(10);
|
|
80206
|
+
if (newline !== -1) return at8 + newline + 1;
|
|
80207
|
+
}
|
|
80208
|
+
return from;
|
|
80209
|
+
}
|
|
80099
80210
|
async function scrubOwnSession({
|
|
80100
80211
|
context,
|
|
80101
80212
|
client,
|
|
@@ -80107,27 +80218,39 @@ async function scrubOwnSession({
|
|
|
80107
80218
|
const size = (await file4.stat()).size;
|
|
80108
80219
|
const saved3 = await offsetOf({ path: statePath2 });
|
|
80109
80220
|
const from = saved3 > size ? 0 : saved3;
|
|
80110
|
-
const chunk = Buffer3.alloc(size - from);
|
|
80221
|
+
const chunk = Buffer3.alloc(Math.min(size - from, SESSION_SCRUB_READ_BYTES));
|
|
80111
80222
|
await file4.read(chunk, 0, chunk.length, from);
|
|
80112
80223
|
const complete = completeLinesOf({ chunk, from });
|
|
80113
80224
|
const { lines: lines2 } = complete;
|
|
80225
|
+
if (lines2.length === 0 && chunk.length === SESSION_SCRUB_READ_BYTES) {
|
|
80226
|
+
await keepOffset({ path: statePath2, offset: await pastLongLine({ file: file4, from, size }) });
|
|
80227
|
+
return { lines: 0 };
|
|
80228
|
+
}
|
|
80114
80229
|
const rewrites = [];
|
|
80115
80230
|
const batches = batchesOf({ lines: lines2 });
|
|
80116
80231
|
let reached = from;
|
|
80232
|
+
let failure2;
|
|
80117
80233
|
for (const batch2 of batches.slice(0, SESSION_SCRUB_MAX_BATCHES)) {
|
|
80118
|
-
|
|
80119
|
-
|
|
80120
|
-
|
|
80121
|
-
|
|
80122
|
-
|
|
80123
|
-
|
|
80124
|
-
|
|
80234
|
+
try {
|
|
80235
|
+
const answer6 = await client.post("/api/agents/me/vault/session-scrub", {
|
|
80236
|
+
texts: batch2.map((line) => line.text)
|
|
80237
|
+
});
|
|
80238
|
+
batch2.forEach((line, index) => {
|
|
80239
|
+
const text3 = rewriteOf({ before: line.text, after: answer6.texts[index] ?? line.text });
|
|
80240
|
+
if (text3 !== void 0) rewrites.push({ line, text: text3 });
|
|
80241
|
+
});
|
|
80242
|
+
} catch (error63) {
|
|
80243
|
+
failure2 = error63;
|
|
80244
|
+
break;
|
|
80245
|
+
}
|
|
80125
80246
|
const last = batch2.at(-1);
|
|
80126
80247
|
if (last) reached = last.at + last.bytes + 1;
|
|
80127
80248
|
}
|
|
80128
|
-
const
|
|
80249
|
+
const whole = failure2 === void 0 && batches.length <= SESSION_SCRUB_MAX_BATCHES;
|
|
80250
|
+
const end = whole ? complete.end : reached;
|
|
80129
80251
|
const moved = await writeBack({ file: file4, rewrites });
|
|
80130
80252
|
await keepOffset({ path: statePath2, offset: end + moved });
|
|
80253
|
+
if (failure2 !== void 0) throw failure2;
|
|
80131
80254
|
return { lines: rewrites.length };
|
|
80132
80255
|
} finally {
|
|
80133
80256
|
await file4.close();
|
|
@@ -80212,16 +80335,12 @@ function settingsOf({ path, text: text3 }) {
|
|
|
80212
80335
|
throw new CliUsageError(`${path} is not valid JSON; fix it, then link again.`);
|
|
80213
80336
|
}
|
|
80214
80337
|
}
|
|
80215
|
-
async function installHooks({
|
|
80216
|
-
|
|
80217
|
-
|
|
80218
|
-
profile
|
|
80219
|
-
}) {
|
|
80220
|
-
const folder = join21(directory, ".claude");
|
|
80221
|
-
const path = join21(folder, "settings.local.json");
|
|
80338
|
+
async function installHooks({ context, directory }) {
|
|
80339
|
+
const folder = join22(directory, ".claude");
|
|
80340
|
+
const path = join22(folder, "settings.local.json");
|
|
80222
80341
|
const text3 = await readFile12(path, "utf8").catch(() => "{}");
|
|
80223
80342
|
const current3 = settingsOf({ path, text: text3 });
|
|
80224
|
-
const command = (hook) => hookCommand({ program: context.program,
|
|
80343
|
+
const command = (hook) => hookCommand({ program: context.program, hook });
|
|
80225
80344
|
const settings3 = withLazeHooks({
|
|
80226
80345
|
settings: current3,
|
|
80227
80346
|
stopCommand: command("stop"),
|
|
@@ -80329,7 +80448,7 @@ async function sessionFolderOf({
|
|
|
80329
80448
|
pid
|
|
80330
80449
|
}) {
|
|
80331
80450
|
const asked = flagText({ args, name: "project" });
|
|
80332
|
-
if (asked) return { folder:
|
|
80451
|
+
if (asked) return { folder: resolve4(context.cwd, asked), elsewhere: void 0 };
|
|
80333
80452
|
if (!claude) return { folder: context.cwd, elsewhere: void 0 };
|
|
80334
80453
|
return claudeFoldersOf({ context, claudePid: pid });
|
|
80335
80454
|
}
|
|
@@ -80355,9 +80474,9 @@ async function settleLinked({
|
|
|
80355
80474
|
});
|
|
80356
80475
|
const claude = harness === "claude-code";
|
|
80357
80476
|
const { folder: directory, elsewhere } = await sessionFolderOf({ context, args, claude, pid });
|
|
80358
|
-
await context.store.
|
|
80477
|
+
const first = !(await context.store.read()).current;
|
|
80478
|
+
await context.store[first ? "saveProfile" : "keepProfile"]({
|
|
80359
80479
|
name: name3,
|
|
80360
|
-
bindDirectory: directory,
|
|
80361
80480
|
profile: {
|
|
80362
80481
|
url: url2,
|
|
80363
80482
|
token: linked.apiKey,
|
|
@@ -80380,7 +80499,7 @@ async function settleLinked({
|
|
|
80380
80499
|
});
|
|
80381
80500
|
}
|
|
80382
80501
|
const hooked = claude && !args.flags["no-hook"];
|
|
80383
|
-
const hookPath = hooked ? await installHooks({ context, directory
|
|
80502
|
+
const hookPath = hooked ? await installHooks({ context, directory }) : void 0;
|
|
80384
80503
|
const listener = hooked ? await listenAfterLink({ context, args, profile: name3, claudePid: pid }) : void 0;
|
|
80385
80504
|
const { command: laze, shadow } = await rerunCommandOf({ context });
|
|
80386
80505
|
const steps = await nextStepsFor({
|
|
@@ -80394,7 +80513,7 @@ async function settleLinked({
|
|
|
80394
80513
|
});
|
|
80395
80514
|
context.out(
|
|
80396
80515
|
[
|
|
80397
|
-
`Linked as ${linked.agent.name} (${linked.agent.id}), profile "${name3}"
|
|
80516
|
+
`Linked as ${linked.agent.name} (${linked.agent.id}), profile "${name3}", in ${directory}.`,
|
|
80398
80517
|
...hookPath ? [`Added the Laze hooks to ${hookPath}.`] : [],
|
|
80399
80518
|
...elsewhereLinesOf({ folder: directory, elsewhere }),
|
|
80400
80519
|
...shadowedLinkLineOf({ shadow }),
|
|
@@ -80419,12 +80538,12 @@ async function nextStepsFor({
|
|
|
80419
80538
|
laze
|
|
80420
80539
|
}) {
|
|
80421
80540
|
if (harness === "codex") return linkCodexSession({ context, args, profile, laze, directory });
|
|
80422
|
-
if (!hooked) return waiterStepsOf({ profile, laze });
|
|
80423
80541
|
const session = await currentSessionOf({ context, args });
|
|
80424
80542
|
if (session) {
|
|
80425
80543
|
await context.store.bindSession({ session: sessionKeyOf({ session }), profile });
|
|
80426
80544
|
await bindInLaze({ context, args, session, profile });
|
|
80427
80545
|
}
|
|
80546
|
+
if (!hooked) return waiterStepsOf({ profile, laze });
|
|
80428
80547
|
const plugin2 = args.flags["no-plugin"] ? void 0 : await installLazePlugin({ context });
|
|
80429
80548
|
if (plugin2?.registered) await markReloadTipTold({ context, session });
|
|
80430
80549
|
const mcp2 = args.flags.mcp ? await registerMcp({ context, directory, profile }) : void 0;
|
|
@@ -80477,9 +80596,8 @@ async function handOver({ context, args }) {
|
|
|
80477
80596
|
const input2 = raw.trim() ? JSON.parse(raw) : {};
|
|
80478
80597
|
const session = sessionOf({ context, harness: "claude-code", sessionId: input2.session_id });
|
|
80479
80598
|
const claudePid = await claudePidOf({ context });
|
|
80480
|
-
const
|
|
80481
|
-
if (!
|
|
80482
|
-
const named = await sessionProfileArgs({ context, args: asked, session });
|
|
80599
|
+
const named = await pluginHookArgs({ context, args, session, claudePid });
|
|
80600
|
+
if (!named) return;
|
|
80483
80601
|
const { client, name: agent3 } = await signedIn({ context, args: named });
|
|
80484
80602
|
await reportTranscript({ client, input: input2 }).catch(
|
|
80485
80603
|
(error63) => reportFailed({ context, error: error63 })
|
|
@@ -80508,16 +80626,8 @@ async function handOver({ context, args }) {
|
|
|
80508
80626
|
try {
|
|
80509
80627
|
fresh = await receiveMessages({ context, client: claim3, waitSeconds: 0 });
|
|
80510
80628
|
} catch (error63) {
|
|
80511
|
-
|
|
80512
|
-
|
|
80513
|
-
client: claim3,
|
|
80514
|
-
session,
|
|
80515
|
-
error: error63,
|
|
80516
|
-
profile: agent3
|
|
80517
|
-
});
|
|
80518
|
-
if (!refused) throw error63;
|
|
80519
|
-
if (refused.notice) stopContext({ context, text: refused.notice });
|
|
80520
|
-
return;
|
|
80629
|
+
if (await droppedBinding({ context, session, error: error63, profile: agent3 })) return;
|
|
80630
|
+
throw error63;
|
|
80521
80631
|
}
|
|
80522
80632
|
await keepTaken({ context, profile: agent3, messages: fresh });
|
|
80523
80633
|
const messages = [...kept, ...fresh];
|
|
@@ -80538,16 +80648,15 @@ async function handOver({ context, args }) {
|
|
|
80538
80648
|
}
|
|
80539
80649
|
async function addSessionStartWaiter({ context, args }) {
|
|
80540
80650
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR;
|
|
80541
|
-
|
|
80542
|
-
|
|
80543
|
-
const path = join21(directory, ".claude", "settings.local.json");
|
|
80651
|
+
if (!directory || args.flags.plugin) return;
|
|
80652
|
+
const path = join22(directory, ".claude", "settings.local.json");
|
|
80544
80653
|
const settings3 = await readFile12(path, "utf8").then((text3) => JSON.parse(text3)).catch(() => void 0);
|
|
80545
80654
|
if (!settings3 || !lacksSessionStartWaiter({ settings: settings3 })) return;
|
|
80546
|
-
await installHooks({ context, directory
|
|
80655
|
+
await installHooks({ context, directory });
|
|
80547
80656
|
}
|
|
80548
80657
|
async function refreshPlugin({ context }) {
|
|
80549
80658
|
if (await pluginIsCurrent({ context })) return;
|
|
80550
|
-
const logPath =
|
|
80659
|
+
const logPath = join22(pluginFolderOf({ context }), "install.log");
|
|
80551
80660
|
context.processes.spawnDetached({ argv: [...context.program, "plugin", "install"], logPath });
|
|
80552
80661
|
}
|
|
80553
80662
|
async function stopHook({ context, args }) {
|
|
@@ -80574,7 +80683,7 @@ async function stopHook({ context, args }) {
|
|
|
80574
80683
|
|
|
80575
80684
|
// src/services/agent-manage-commands.service.ts
|
|
80576
80685
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
80577
|
-
import { extname, resolve as
|
|
80686
|
+
import { extname, resolve as resolve5 } from "node:path";
|
|
80578
80687
|
|
|
80579
80688
|
// src/rules/login-format.rules.ts
|
|
80580
80689
|
var HARNESS_NAMES2 = {
|
|
@@ -80706,7 +80815,7 @@ async function avatarOf({
|
|
|
80706
80815
|
return emoji4;
|
|
80707
80816
|
}
|
|
80708
80817
|
if (!path) return void 0;
|
|
80709
|
-
const bytes = await readFile13(
|
|
80818
|
+
const bytes = await readFile13(resolve5(context.cwd, path)).catch(() => {
|
|
80710
80819
|
throw new CliUsageError(`laze: cannot read the avatar file ${path}.`);
|
|
80711
80820
|
});
|
|
80712
80821
|
const uploaded = await client.post("/api/agents/avatars", {
|
|
@@ -81422,11 +81531,11 @@ async function setAgentRunsOn({
|
|
|
81422
81531
|
}
|
|
81423
81532
|
|
|
81424
81533
|
// src/services/agent-migrate-commands.service.ts
|
|
81425
|
-
import { readFile as readFile14, stat as
|
|
81426
|
-
import { basename as basename6, join as
|
|
81534
|
+
import { readFile as readFile14, stat as stat7 } from "node:fs/promises";
|
|
81535
|
+
import { basename as basename6, join as join23, resolve as resolve6 } from "node:path";
|
|
81427
81536
|
|
|
81428
81537
|
// src/rules/migration-upload.rules.ts
|
|
81429
|
-
import { createHash as
|
|
81538
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
81430
81539
|
function markersIn(text3) {
|
|
81431
81540
|
return text3.split(REDACTION_MARKER).length - 1;
|
|
81432
81541
|
}
|
|
@@ -81445,7 +81554,7 @@ async function redactTranscript({
|
|
|
81445
81554
|
return { text: redacted.text, redactions };
|
|
81446
81555
|
}
|
|
81447
81556
|
function sha256Of({ text: text3 }) {
|
|
81448
|
-
return
|
|
81557
|
+
return createHash6("sha256").update(text3, "utf8").digest("hex");
|
|
81449
81558
|
}
|
|
81450
81559
|
var bytesOf2 = (text3) => Buffer.byteLength(text3, "utf8");
|
|
81451
81560
|
function piecesOf({ line, maxBytes }) {
|
|
@@ -81633,14 +81742,14 @@ async function chosenTranscriptOf({
|
|
|
81633
81742
|
ticket,
|
|
81634
81743
|
file: file4
|
|
81635
81744
|
}) {
|
|
81636
|
-
const path =
|
|
81745
|
+
const path = resolve6(context.cwd, file4);
|
|
81637
81746
|
const sessionId = basename6(path).replace(/\.jsonl$/, "");
|
|
81638
81747
|
if (ticket.source !== "claude-code" || !SESSION_ID.test(sessionId)) {
|
|
81639
81748
|
throw new CliUsageError(
|
|
81640
81749
|
"--transcript takes a Claude Code transcript named <session id>.jsonl. Nothing was uploaded."
|
|
81641
81750
|
);
|
|
81642
81751
|
}
|
|
81643
|
-
const found = await
|
|
81752
|
+
const found = await stat7(path).then(
|
|
81644
81753
|
(info) => info.isFile(),
|
|
81645
81754
|
() => false
|
|
81646
81755
|
);
|
|
@@ -81660,7 +81769,7 @@ async function transcriptOf({ context, args, ticket }) {
|
|
|
81660
81769
|
if (ticket.source === "codex") {
|
|
81661
81770
|
const codexHome = context.environment.codexHome;
|
|
81662
81771
|
const path2 = await codexRolloutPathOf({ codexHome, threadId: sessionId });
|
|
81663
|
-
return { sessionId, path: path2, where:
|
|
81772
|
+
return { sessionId, path: path2, where: join23(codexHome, "sessions") };
|
|
81664
81773
|
}
|
|
81665
81774
|
const { root, path } = await claudeTranscriptOf({ context, sessionId });
|
|
81666
81775
|
return { sessionId, path, where: root };
|
|
@@ -81668,7 +81777,7 @@ async function transcriptOf({ context, args, ticket }) {
|
|
|
81668
81777
|
async function agentHere({ context, args }) {
|
|
81669
81778
|
const chosen = Boolean(flagText({ args, name: "transcript" }));
|
|
81670
81779
|
const session = chosen ? void 0 : await currentSessionOf({ context, args });
|
|
81671
|
-
const named = await sessionProfileArgs({ context, args, session
|
|
81780
|
+
const named = await sessionProfileArgs({ context, args, session });
|
|
81672
81781
|
const signed2 = await signedIn({ context, args: named });
|
|
81673
81782
|
if (signed2.profile.kind !== "agent") {
|
|
81674
81783
|
throw new CliUsageError(
|
|
@@ -81786,7 +81895,7 @@ function whyOf(error63) {
|
|
|
81786
81895
|
|
|
81787
81896
|
// src/services/agent-session-commands.service.ts
|
|
81788
81897
|
var NO_SESSION = "Run this inside the Claude Code or Codex session the agent should listen in, or pass --session <id>.";
|
|
81789
|
-
var NO_AGENT = "This session
|
|
81898
|
+
var NO_AGENT = "This session has no agent: name one with `laze agent bind --profile <name>`.";
|
|
81790
81899
|
var DEFAULT_WAIT_SECONDS = 300;
|
|
81791
81900
|
async function bindAgentSession({
|
|
81792
81901
|
context,
|
|
@@ -81800,7 +81909,7 @@ async function bindAgentSession({
|
|
|
81800
81909
|
const held = config2.sessions?.[key];
|
|
81801
81910
|
const own2 = held && config2.profiles[held] ? held : void 0;
|
|
81802
81911
|
const explicit = flagText({ args, name: "profile" }) || void 0;
|
|
81803
|
-
const target = explicit ?? own2
|
|
81912
|
+
const target = explicit ?? own2;
|
|
81804
81913
|
if (!target) throw new CliUsageError(NO_AGENT);
|
|
81805
81914
|
const named = { ...args, flags: { ...args.flags, profile: target } };
|
|
81806
81915
|
const { client, name: name3, profile } = await signedIn({ context, args: named });
|
|
@@ -81874,7 +81983,8 @@ async function requestProfileOf({
|
|
|
81874
81983
|
const config2 = await context.store.read();
|
|
81875
81984
|
const requests2 = Object.entries(config2.profiles).filter(([, one]) => one.kind === "request");
|
|
81876
81985
|
const asked = flagText({ args, name: "from" });
|
|
81877
|
-
const
|
|
81986
|
+
const session = await currentSessionOf({ context, args });
|
|
81987
|
+
const bound = await sessionAgentOf({ context, session });
|
|
81878
81988
|
const wanted = asked ? requestProfileNameOf({ profile: asked }) : bound && requestProfileNameOf({ profile: bound });
|
|
81879
81989
|
const found = requests2.find(([name3]) => name3 === wanted || name3 === asked) ?? (requests2.length === 1 && !asked ? requests2[0] : void 0);
|
|
81880
81990
|
if (found) return { name: found[0], profile: found[1] };
|
|
@@ -81990,10 +82100,48 @@ async function requestAgent({ context, args }) {
|
|
|
81990
82100
|
await forSession({ client: own2, session }).post("/api/agents/me/bind", {});
|
|
81991
82101
|
await context.store.bindSession({ session: sessionKeyOf({ session }), profile });
|
|
81992
82102
|
}
|
|
82103
|
+
async function listAgentSessions({
|
|
82104
|
+
context,
|
|
82105
|
+
args
|
|
82106
|
+
}) {
|
|
82107
|
+
if (args.flags.migrate) {
|
|
82108
|
+
const lines2 = await migrateSessions({ context });
|
|
82109
|
+
context.out(lines2.length > 0 ? `${lines2.join("\n")}
|
|
82110
|
+
` : "Nothing to migrate.\n");
|
|
82111
|
+
return;
|
|
82112
|
+
}
|
|
82113
|
+
const config2 = await context.store.read();
|
|
82114
|
+
const rows = Object.entries(config2.sessions ?? {}).map(([key, profile]) => {
|
|
82115
|
+
const split = key.indexOf(":");
|
|
82116
|
+
const entry2 = config2.profiles[profile];
|
|
82117
|
+
return {
|
|
82118
|
+
harness: key.slice(0, split),
|
|
82119
|
+
sessionId: key.slice(split + 1),
|
|
82120
|
+
profile,
|
|
82121
|
+
agent: entry2?.name ?? null,
|
|
82122
|
+
exists: Boolean(entry2)
|
|
82123
|
+
};
|
|
82124
|
+
});
|
|
82125
|
+
if (args.flags.json) {
|
|
82126
|
+
context.out(`${JSON.stringify(rows, null, 2)}
|
|
82127
|
+
`);
|
|
82128
|
+
return;
|
|
82129
|
+
}
|
|
82130
|
+
if (rows.length === 0) {
|
|
82131
|
+
context.out("No session on this machine is bound to an agent.\n");
|
|
82132
|
+
return;
|
|
82133
|
+
}
|
|
82134
|
+
const text3 = rows.map((row) => {
|
|
82135
|
+
const who = row.exists ? `"${row.agent}" (profile ${row.profile})` : `profile ${row.profile}, gone`;
|
|
82136
|
+
return `${row.harness} ${row.sessionId} ${who}
|
|
82137
|
+
`;
|
|
82138
|
+
});
|
|
82139
|
+
context.out(text3.join(""));
|
|
82140
|
+
}
|
|
81993
82141
|
|
|
81994
82142
|
// src/services/app-commands.service.ts
|
|
81995
|
-
import { mkdir as mkdir8, readdir as
|
|
81996
|
-
import { dirname as
|
|
82143
|
+
import { mkdir as mkdir8, readdir as readdir6, readFile as readFile17, writeFile as writeFile6 } from "node:fs/promises";
|
|
82144
|
+
import { dirname as dirname18, join as join28, relative as relative3, resolve as resolve9, sep as sep3 } from "node:path";
|
|
81997
82145
|
|
|
81998
82146
|
// ../../modules/app/contract/src/app.connections.ts
|
|
81999
82147
|
var appFunctionNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
@@ -84589,10 +84737,10 @@ function unknownCollectionsOf({
|
|
|
84589
84737
|
}
|
|
84590
84738
|
|
|
84591
84739
|
// src/services/app-asset-commands.service.ts
|
|
84592
|
-
import { createHash as
|
|
84593
|
-
import { createReadStream
|
|
84594
|
-
import { open as open6, stat as
|
|
84595
|
-
import { basename as basename7, resolve as
|
|
84740
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
84741
|
+
import { createReadStream } from "node:fs";
|
|
84742
|
+
import { open as open6, stat as stat8 } from "node:fs/promises";
|
|
84743
|
+
import { basename as basename7, resolve as resolve7 } from "node:path";
|
|
84596
84744
|
var USAGE2 = `Usage:
|
|
84597
84745
|
laze app asset add <file> [--type <content type>] upload a video, audio, image, PDF, font or captions file
|
|
84598
84746
|
laze app asset list the app's assets with their addresses
|
|
@@ -84644,8 +84792,8 @@ async function h264LevelOf(path) {
|
|
|
84644
84792
|
}
|
|
84645
84793
|
}
|
|
84646
84794
|
async function sha256Of2(path) {
|
|
84647
|
-
const hash2 =
|
|
84648
|
-
for await (const chunk of
|
|
84795
|
+
const hash2 = createHash7("sha256");
|
|
84796
|
+
for await (const chunk of createReadStream(path)) hash2.update(chunk);
|
|
84649
84797
|
return hash2.digest("hex");
|
|
84650
84798
|
}
|
|
84651
84799
|
async function sendParts2({
|
|
@@ -84704,8 +84852,8 @@ function sizeText(bytes) {
|
|
|
84704
84852
|
async function add({ context, args, open: openApp }) {
|
|
84705
84853
|
const file4 = args.words[3];
|
|
84706
84854
|
if (!file4) throw new CliUsageError(USAGE2);
|
|
84707
|
-
const path =
|
|
84708
|
-
const info = await
|
|
84855
|
+
const path = resolve7(context.cwd, file4);
|
|
84856
|
+
const info = await stat8(path).catch(() => void 0);
|
|
84709
84857
|
if (!info?.isFile()) throw new CliUsageError(`No file at ${file4}`);
|
|
84710
84858
|
if (info.size > MAX_APP_ASSET_BYTES) {
|
|
84711
84859
|
throw new CliUsageError(
|
|
@@ -84799,7 +84947,7 @@ async function appAsset(input2) {
|
|
|
84799
84947
|
// src/services/browser-tab-commands.service.ts
|
|
84800
84948
|
import { mkdir as mkdir7, writeFile as writeFile4 } from "node:fs/promises";
|
|
84801
84949
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
84802
|
-
import { join as
|
|
84950
|
+
import { join as join25, resolve as resolve8 } from "node:path";
|
|
84803
84951
|
|
|
84804
84952
|
// src/rules/browser-login.rules.ts
|
|
84805
84953
|
var PASSWORD_NAME = /pass|pwd/i;
|
|
@@ -84829,10 +84977,10 @@ function loginValuesOf({
|
|
|
84829
84977
|
}
|
|
84830
84978
|
|
|
84831
84979
|
// src/services/vault-commands.service.ts
|
|
84832
|
-
import { createHash as
|
|
84980
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
84833
84981
|
import { readFile as readFile15, rm as rm11 } from "node:fs/promises";
|
|
84834
|
-
import { hostname as
|
|
84835
|
-
import { dirname as
|
|
84982
|
+
import { hostname as hostname7, tmpdir } from "node:os";
|
|
84983
|
+
import { dirname as dirname17, join as join24 } from "node:path";
|
|
84836
84984
|
|
|
84837
84985
|
// src/rules/vault-session.rules.ts
|
|
84838
84986
|
function vaultSessionOf({
|
|
@@ -84907,9 +85055,9 @@ function runKeyPathOf({
|
|
|
84907
85055
|
connection,
|
|
84908
85056
|
profile = ""
|
|
84909
85057
|
}) {
|
|
84910
|
-
const name3 =
|
|
84911
|
-
const base = turnFile ?
|
|
84912
|
-
return
|
|
85058
|
+
const name3 = createHash8("sha256").update(connection).digest("hex");
|
|
85059
|
+
const base = turnFile ? dirname17(turnFile) : join24(tmpdir(), "laze-vault", profile);
|
|
85060
|
+
return join24(base, "vault-run-keys", `${name3}.json`);
|
|
84913
85061
|
}
|
|
84914
85062
|
async function runKeyAt({ path }) {
|
|
84915
85063
|
const saved3 = await readStateJson({
|
|
@@ -85112,7 +85260,7 @@ async function vaultSessionFor({
|
|
|
85112
85260
|
harnessSession,
|
|
85113
85261
|
inherited: context.environment.inherited,
|
|
85114
85262
|
cwd: context.cwd,
|
|
85115
|
-
host:
|
|
85263
|
+
host: hostname7(),
|
|
85116
85264
|
named: flagText({ args, name: "as" }),
|
|
85117
85265
|
shellPid: await context.processes.parentOf(context.processes.pid),
|
|
85118
85266
|
terminal: context.stdoutIsTerminal === true
|
|
@@ -85320,7 +85468,7 @@ async function saveScreenshot({
|
|
|
85320
85468
|
path
|
|
85321
85469
|
}) {
|
|
85322
85470
|
if (path) {
|
|
85323
|
-
const target =
|
|
85471
|
+
const target = resolve8(context.cwd, path);
|
|
85324
85472
|
await writeFile4(target, Buffer.from(shot.image, "base64"), { mode: 384 });
|
|
85325
85473
|
return target;
|
|
85326
85474
|
}
|
|
@@ -85470,9 +85618,9 @@ async function savedScreenshot({
|
|
|
85470
85618
|
nowMs: nowMs2,
|
|
85471
85619
|
what
|
|
85472
85620
|
}) {
|
|
85473
|
-
const folder =
|
|
85621
|
+
const folder = join25(tmpdir2(), "laze-browser");
|
|
85474
85622
|
await mkdir7(folder, { recursive: true, mode: 448 });
|
|
85475
|
-
const path =
|
|
85623
|
+
const path = join25(folder, `${tabId.replace(/[^a-zA-Z0-9_-]/g, "_")}-${what}-${nowMs2}.jpg`);
|
|
85476
85624
|
await writeFile4(path, Buffer.from(data, "base64"), { mode: 384 });
|
|
85477
85625
|
return path;
|
|
85478
85626
|
}
|
|
@@ -85950,7 +86098,7 @@ async function appPinsCommand({
|
|
|
85950
86098
|
import { execFile } from "node:child_process";
|
|
85951
86099
|
import { mkdtemp, rm as rm12, writeFile as writeFile5 } from "node:fs/promises";
|
|
85952
86100
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
85953
|
-
import { join as
|
|
86101
|
+
import { join as join26 } from "node:path";
|
|
85954
86102
|
import { promisify } from "node:util";
|
|
85955
86103
|
var run2 = promisify(execFile);
|
|
85956
86104
|
var MODULE_SYNTAX = /^\s*(import|export)\s/m;
|
|
@@ -85979,11 +86127,11 @@ async function scriptErrorsOf({
|
|
|
85979
86127
|
const unknown2 = unknownCollectionsOf({ files: files2, collections });
|
|
85980
86128
|
const scripts = files2.flatMap(scriptsOf);
|
|
85981
86129
|
if (scripts.length === 0) return unknown2;
|
|
85982
|
-
const dir = await mkdtemp(
|
|
86130
|
+
const dir = await mkdtemp(join26(tmpdir3(), "laze-app-check-"));
|
|
85983
86131
|
try {
|
|
85984
86132
|
const errors = await Promise.all(
|
|
85985
86133
|
scripts.map(async (script, index) => {
|
|
85986
|
-
const file4 =
|
|
86134
|
+
const file4 = join26(dir, `${index}.${script.module ? "mjs" : "cjs"}`);
|
|
85987
86135
|
await writeFile5(file4, script.code);
|
|
85988
86136
|
try {
|
|
85989
86137
|
await run2(process.execPath, ["--check", file4]);
|
|
@@ -86001,9 +86149,9 @@ async function scriptErrorsOf({
|
|
|
86001
86149
|
}
|
|
86002
86150
|
|
|
86003
86151
|
// src/services/app-serve.service.ts
|
|
86004
|
-
import { readFile as readFile16, stat as
|
|
86152
|
+
import { readFile as readFile16, stat as stat9 } from "node:fs/promises";
|
|
86005
86153
|
import { createServer } from "node:http";
|
|
86006
|
-
import { extname as extname2, join as
|
|
86154
|
+
import { extname as extname2, join as join27, normalize, sep as sep2 } from "node:path";
|
|
86007
86155
|
var TYPES2 = {
|
|
86008
86156
|
".html": "text/html; charset=utf-8",
|
|
86009
86157
|
".js": "text/javascript; charset=utf-8",
|
|
@@ -86054,10 +86202,10 @@ async function staticFile({
|
|
|
86054
86202
|
if (clean.startsWith("..") || hidden) {
|
|
86055
86203
|
return json2({ response, status: 404, value: { code: "not_found", message: "Not found" } });
|
|
86056
86204
|
}
|
|
86057
|
-
const candidates = [
|
|
86058
|
-
if (!extname2(clean)) candidates.push(
|
|
86205
|
+
const candidates = [join27(folder, clean), join27(folder, clean, "index.html")];
|
|
86206
|
+
if (!extname2(clean)) candidates.push(join27(folder, "index.html"));
|
|
86059
86207
|
for (const target of candidates) {
|
|
86060
|
-
const info = await
|
|
86208
|
+
const info = await stat9(target).catch(() => void 0);
|
|
86061
86209
|
if (!info?.isFile()) continue;
|
|
86062
86210
|
const type = TYPES2[extname2(target).toLowerCase()] ?? "application/octet-stream";
|
|
86063
86211
|
const body = await readFile16(target);
|
|
@@ -86146,16 +86294,16 @@ async function serveAppFolder({
|
|
|
86146
86294
|
(error63) => failed({ response, error: error63 })
|
|
86147
86295
|
);
|
|
86148
86296
|
});
|
|
86149
|
-
await new Promise((
|
|
86297
|
+
await new Promise((resolve27, reject) => {
|
|
86150
86298
|
server.once("error", reject);
|
|
86151
|
-
server.listen(port, "127.0.0.1", () =>
|
|
86299
|
+
server.listen(port, "127.0.0.1", () => resolve27());
|
|
86152
86300
|
});
|
|
86153
86301
|
const { port: bound } = server.address();
|
|
86154
86302
|
return {
|
|
86155
86303
|
url: `http://127.0.0.1:${bound}/`,
|
|
86156
|
-
close: () => new Promise((
|
|
86304
|
+
close: () => new Promise((resolve27) => {
|
|
86157
86305
|
server.closeAllConnections();
|
|
86158
|
-
server.close(() =>
|
|
86306
|
+
server.close(() => resolve27());
|
|
86159
86307
|
})
|
|
86160
86308
|
};
|
|
86161
86309
|
}
|
|
@@ -86326,10 +86474,10 @@ function noteRetiredFlags({ context, args }) {
|
|
|
86326
86474
|
}
|
|
86327
86475
|
}
|
|
86328
86476
|
function folderOf({ context, word: word3 }) {
|
|
86329
|
-
return
|
|
86477
|
+
return resolve9(context.cwd, word3 ?? ".");
|
|
86330
86478
|
}
|
|
86331
86479
|
async function readManifest(folder) {
|
|
86332
|
-
const text3 = await readFile17(
|
|
86480
|
+
const text3 = await readFile17(join28(folder, APP_MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
86333
86481
|
if (text3 === void 0) return void 0;
|
|
86334
86482
|
const parsed = appManifestSchema.safeParse(JSON.parse(text3));
|
|
86335
86483
|
if (!parsed.success) {
|
|
@@ -86370,7 +86518,7 @@ async function jsonFlag({
|
|
|
86370
86518
|
}) {
|
|
86371
86519
|
const raw = flagText({ args, name: name3 });
|
|
86372
86520
|
if (!raw) return void 0;
|
|
86373
|
-
const text3 = raw.startsWith("@") ? await readFile17(
|
|
86521
|
+
const text3 = raw.startsWith("@") ? await readFile17(resolve9(context.cwd, raw.slice(1)), "utf8") : raw;
|
|
86374
86522
|
try {
|
|
86375
86523
|
return JSON.parse(text3);
|
|
86376
86524
|
} catch {
|
|
@@ -86382,8 +86530,8 @@ async function listFiles(folder) {
|
|
|
86382
86530
|
const pending2 = [folder];
|
|
86383
86531
|
while (pending2.length > 0 && found.length <= MAX_FILES) {
|
|
86384
86532
|
const current3 = pending2.pop() ?? folder;
|
|
86385
|
-
for (const entry2 of await
|
|
86386
|
-
const path =
|
|
86533
|
+
for (const entry2 of await readdir6(current3, { withFileTypes: true })) {
|
|
86534
|
+
const path = join28(current3, entry2.name);
|
|
86387
86535
|
const rel = relative3(folder, path).split(sep3).join("/");
|
|
86388
86536
|
if (isSkippedPath({ path: rel })) continue;
|
|
86389
86537
|
if (entry2.isDirectory()) pending2.push(path);
|
|
@@ -86418,12 +86566,12 @@ var appCreate = async ({ context, args }) => {
|
|
|
86418
86566
|
...visibility ? { visibility } : {},
|
|
86419
86567
|
...template ? { template } : {}
|
|
86420
86568
|
});
|
|
86421
|
-
const folder =
|
|
86569
|
+
const folder = resolve9(context.cwd, flagText({ args, name: "dir", fallback: app2.slug }));
|
|
86422
86570
|
await mkdir8(folder, { recursive: true });
|
|
86423
86571
|
const start2 = template ? await templateStart({ client, appId: app2.id, template }) : null;
|
|
86424
86572
|
for (const file4 of start2?.files ?? []) {
|
|
86425
|
-
const target =
|
|
86426
|
-
await mkdir8(
|
|
86573
|
+
const target = join28(folder, ...file4.path.split("/"));
|
|
86574
|
+
await mkdir8(dirname18(target), { recursive: true });
|
|
86427
86575
|
await writeFile6(
|
|
86428
86576
|
target,
|
|
86429
86577
|
file4.encoding === "base64" ? Buffer.from(file4.content, "base64") : file4.content
|
|
@@ -86435,7 +86583,7 @@ var appCreate = async ({ context, args }) => {
|
|
|
86435
86583
|
views: [...start2?.template.views ?? []],
|
|
86436
86584
|
seed: { ...start2?.template.seed }
|
|
86437
86585
|
};
|
|
86438
|
-
await writeFile6(
|
|
86586
|
+
await writeFile6(join28(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
86439
86587
|
`);
|
|
86440
86588
|
const where = relative3(context.cwd, folder) || ".";
|
|
86441
86589
|
const created = start2 ? `Created ${app2.name} (${app2.id}) from the ${template} template in ${where}; its first version is live at ${app2.publishedUrl}.
|
|
@@ -86573,7 +86721,7 @@ var appWrite = async ({ context, args }) => {
|
|
|
86573
86721
|
const remove9 = (flagText({ args, name: "remove" }) ?? "").split(",").map((path) => path.trim()).filter(Boolean);
|
|
86574
86722
|
const files2 = await Promise.all(
|
|
86575
86723
|
words.slice(2).map(async (word3) => {
|
|
86576
|
-
const path =
|
|
86724
|
+
const path = resolve9(context.cwd, word3);
|
|
86577
86725
|
const { bytes: _bytes, ...file4 } = buildFileOf({
|
|
86578
86726
|
path: relative3(folder, path).split(sep3).join("/"),
|
|
86579
86727
|
bytes: await readFile17(path)
|
|
@@ -86665,7 +86813,7 @@ async function folderClaim({
|
|
|
86665
86813
|
folder,
|
|
86666
86814
|
appId
|
|
86667
86815
|
}) {
|
|
86668
|
-
const entries = await
|
|
86816
|
+
const entries = await readdir6(folder).catch(() => []);
|
|
86669
86817
|
if (entries.length === 0) return "empty";
|
|
86670
86818
|
const manifest = await readManifest(folder).catch(() => void 0);
|
|
86671
86819
|
if (!manifest) return "other-files";
|
|
@@ -86703,8 +86851,8 @@ var appPull = async ({ context, args }) => {
|
|
|
86703
86851
|
);
|
|
86704
86852
|
}
|
|
86705
86853
|
for (const file4 of pulled.files) {
|
|
86706
|
-
const target =
|
|
86707
|
-
await mkdir8(
|
|
86854
|
+
const target = join28(folder, ...file4.path.split("/"));
|
|
86855
|
+
await mkdir8(dirname18(target), { recursive: true });
|
|
86708
86856
|
await writeFile6(
|
|
86709
86857
|
target,
|
|
86710
86858
|
file4.encoding === "base64" ? Buffer.from(file4.content, "base64") : file4.content
|
|
@@ -86722,7 +86870,7 @@ var appPull = async ({ context, args }) => {
|
|
|
86722
86870
|
])
|
|
86723
86871
|
)
|
|
86724
86872
|
};
|
|
86725
|
-
await writeFile6(
|
|
86873
|
+
await writeFile6(join28(folder, APP_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
86726
86874
|
`);
|
|
86727
86875
|
const names = pulled.collections.map((collection) => collection.name);
|
|
86728
86876
|
const where = relative3(context.cwd, folder) || ".";
|
|
@@ -87029,7 +87177,7 @@ var appExport = async ({ context, args }) => {
|
|
|
87029
87177
|
});
|
|
87030
87178
|
const out = flagText({ args, name: "out" });
|
|
87031
87179
|
if (!out) return context.out(exported.body);
|
|
87032
|
-
const target =
|
|
87180
|
+
const target = resolve9(context.cwd, out);
|
|
87033
87181
|
await writeFile6(target, exported.body);
|
|
87034
87182
|
context.out(`Wrote ${exported.rows} records to ${relative3(context.cwd, target)}
|
|
87035
87183
|
`);
|
|
@@ -87038,7 +87186,7 @@ var appImport = async ({ context, args }) => {
|
|
|
87038
87186
|
const words = args.words.slice(2);
|
|
87039
87187
|
const [named, collection, file4] = words.length >= 3 ? words : [void 0, ...words];
|
|
87040
87188
|
if (!collection || !file4) throw new CliUsageError(USAGE7);
|
|
87041
|
-
const csv = await readFile17(
|
|
87189
|
+
const csv = await readFile17(resolve9(context.cwd, file4), "utf8").catch(() => {
|
|
87042
87190
|
throw new CliUsageError(`Cannot read ${file4}`);
|
|
87043
87191
|
});
|
|
87044
87192
|
const scoped = named ? { ...args, flags: { ...args.flags, app: named } } : args;
|
|
@@ -87056,7 +87204,7 @@ var appImport = async ({ context, args }) => {
|
|
|
87056
87204
|
});
|
|
87057
87205
|
const refusedOut = flagText({ args, name: "refused" });
|
|
87058
87206
|
if (refusedOut && result2.refusedCsv) {
|
|
87059
|
-
await writeFile6(
|
|
87207
|
+
await writeFile6(resolve9(context.cwd, refusedOut), result2.refusedCsv);
|
|
87060
87208
|
}
|
|
87061
87209
|
const fitting = result2.rows - result2.refused.length;
|
|
87062
87210
|
const skipped = result2.refused.slice(0, 20).map((row) => ` line ${row.line}: ${row.reason}
|
|
@@ -87473,14 +87621,14 @@ async function app({ context, args }) {
|
|
|
87473
87621
|
}
|
|
87474
87622
|
|
|
87475
87623
|
// src/services/auth-commands.service.ts
|
|
87476
|
-
import { hostname as
|
|
87624
|
+
import { hostname as hostname8 } from "node:os";
|
|
87477
87625
|
|
|
87478
87626
|
// src/rules/machine-proof.rules.ts
|
|
87479
|
-
import { createHash as
|
|
87627
|
+
import { createHash as createHash9, randomBytes as randomBytes2 } from "node:crypto";
|
|
87480
87628
|
var b64url3 = (bytes) => Buffer.from(bytes).toString("base64url");
|
|
87481
87629
|
function thumbprintOf({ jwk }) {
|
|
87482
87630
|
const canonical = JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y });
|
|
87483
|
-
return b64url3(
|
|
87631
|
+
return b64url3(createHash9("sha256").update(canonical).digest());
|
|
87484
87632
|
}
|
|
87485
87633
|
function lazeTokenOf({ authorization }) {
|
|
87486
87634
|
const match = /^Bearer (lz_\S+)$/.exec(authorization ?? "");
|
|
@@ -87504,7 +87652,7 @@ function machineProofOf({
|
|
|
87504
87652
|
htu: url2,
|
|
87505
87653
|
iat: Math.floor(nowMs2 / 1e3),
|
|
87506
87654
|
jti,
|
|
87507
|
-
ath: b64url3(
|
|
87655
|
+
ath: b64url3(createHash9("sha256").update(credential).digest()),
|
|
87508
87656
|
lz_tier: tier,
|
|
87509
87657
|
...tailscaleNodeId ? { lz_ts: tailscaleNodeId } : {}
|
|
87510
87658
|
})
|
|
@@ -87577,7 +87725,7 @@ async function deviceToken({
|
|
|
87577
87725
|
clientName: flagText({
|
|
87578
87726
|
args,
|
|
87579
87727
|
name: "client",
|
|
87580
|
-
fallback: `laze CLI on ${
|
|
87728
|
+
fallback: `laze CLI on ${hostname8()}`.slice(0, 80)
|
|
87581
87729
|
}),
|
|
87582
87730
|
...machineKey ? { machineKey } : {}
|
|
87583
87731
|
});
|
|
@@ -87990,7 +88138,7 @@ async function billing({ context, args }) {
|
|
|
87990
88138
|
// src/services/browser-commands.service.ts
|
|
87991
88139
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
87992
88140
|
import { readFile as readFile18 } from "node:fs/promises";
|
|
87993
|
-
import { dirname as
|
|
88141
|
+
import { dirname as dirname19, join as join29 } from "node:path";
|
|
87994
88142
|
|
|
87995
88143
|
// src/services/cdp-bridge.service.ts
|
|
87996
88144
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -88021,7 +88169,7 @@ function tunnel({
|
|
|
88021
88169
|
host: host2,
|
|
88022
88170
|
port
|
|
88023
88171
|
}) {
|
|
88024
|
-
return new Promise((
|
|
88172
|
+
return new Promise((resolve27, reject) => {
|
|
88025
88173
|
const socket = connectTcp(proxy.port, proxy.host);
|
|
88026
88174
|
let answer6 = "";
|
|
88027
88175
|
const auth = proxy.authorization ? `Proxy-Authorization: ${proxy.authorization}\r
|
|
@@ -88038,7 +88186,7 @@ ${auth}\r
|
|
|
88038
88186
|
answer6 += chunk.toString("latin1");
|
|
88039
88187
|
if (!answer6.includes(HEADER_END)) return;
|
|
88040
88188
|
socket.off("data", onData);
|
|
88041
|
-
if (/^HTTP\/1\.[01] 200/.test(answer6)) return
|
|
88189
|
+
if (/^HTTP\/1\.[01] 200/.test(answer6)) return resolve27(socket);
|
|
88042
88190
|
socket.destroy();
|
|
88043
88191
|
reject(new Error(`proxy refused the tunnel: ${answer6.split("\r\n")[0] ?? ""}`));
|
|
88044
88192
|
};
|
|
@@ -88051,8 +88199,8 @@ async function upstreamOf({ target, proxy }) {
|
|
|
88051
88199
|
const raw = proxy ? await tunnel({ proxy, host: target.hostname, port }) : connectTcp(port, target.hostname);
|
|
88052
88200
|
if (!secure) return raw;
|
|
88053
88201
|
const tls = connectTls({ socket: raw, servername: target.hostname });
|
|
88054
|
-
await new Promise((
|
|
88055
|
-
tls.once("secureConnect", () =>
|
|
88202
|
+
await new Promise((resolve27, reject) => {
|
|
88203
|
+
tls.once("secureConnect", () => resolve27());
|
|
88056
88204
|
tls.once("error", reject);
|
|
88057
88205
|
});
|
|
88058
88206
|
return tls;
|
|
@@ -88094,8 +88242,8 @@ async function browserSocket({
|
|
|
88094
88242
|
createConnection: () => upstream,
|
|
88095
88243
|
perMessageDeflate: false
|
|
88096
88244
|
});
|
|
88097
|
-
await new Promise((
|
|
88098
|
-
socket.once("open", () =>
|
|
88245
|
+
await new Promise((resolve27, reject) => {
|
|
88246
|
+
socket.once("open", () => resolve27());
|
|
88099
88247
|
socket.once("error", reject);
|
|
88100
88248
|
});
|
|
88101
88249
|
return socket;
|
|
@@ -88108,12 +88256,12 @@ async function browserCall({
|
|
|
88108
88256
|
}) {
|
|
88109
88257
|
const socket = await browserSocket({ target, proxy });
|
|
88110
88258
|
try {
|
|
88111
|
-
return await new Promise((
|
|
88259
|
+
return await new Promise((resolve27, reject) => {
|
|
88112
88260
|
socket.on("message", (data) => {
|
|
88113
88261
|
const reply2 = JSON.parse(textOf3(data));
|
|
88114
88262
|
if (reply2.id !== 1) return;
|
|
88115
88263
|
if (reply2.error) reject(new Error(`${method}: ${JSON.stringify(reply2.error)}`));
|
|
88116
|
-
else
|
|
88264
|
+
else resolve27(reply2.result ?? {});
|
|
88117
88265
|
});
|
|
88118
88266
|
socket.once(
|
|
88119
88267
|
"close",
|
|
@@ -88277,18 +88425,18 @@ function retargetCdpBridge({
|
|
|
88277
88425
|
target,
|
|
88278
88426
|
expiresAt
|
|
88279
88427
|
}) {
|
|
88280
|
-
return new Promise((
|
|
88428
|
+
return new Promise((resolve27) => {
|
|
88281
88429
|
const call = httpRequest(
|
|
88282
88430
|
{ host: "127.0.0.1", port, path: TARGET_PATH, method: "PUT", timeout: 2e3 },
|
|
88283
88431
|
(response) => {
|
|
88284
88432
|
response.resume();
|
|
88285
|
-
|
|
88433
|
+
resolve27(response.statusCode === 204);
|
|
88286
88434
|
}
|
|
88287
88435
|
);
|
|
88288
88436
|
call.setHeader(KEY_HEADER, key);
|
|
88289
88437
|
call.setHeader("content-type", "application/json");
|
|
88290
88438
|
call.once("timeout", () => call.destroy());
|
|
88291
|
-
call.once("error", () =>
|
|
88439
|
+
call.once("error", () => resolve27(false));
|
|
88292
88440
|
call.end(JSON.stringify({ target, expiresAt }));
|
|
88293
88441
|
});
|
|
88294
88442
|
}
|
|
@@ -88337,15 +88485,15 @@ async function startCdpBridge({
|
|
|
88337
88485
|
(socket) => relayPage({ client: socket, targetId, target: url2, proxy })
|
|
88338
88486
|
);
|
|
88339
88487
|
});
|
|
88340
|
-
await new Promise((
|
|
88488
|
+
await new Promise((resolve27) => server.listen(0, "127.0.0.1", resolve27));
|
|
88341
88489
|
const port = server.address().port;
|
|
88342
88490
|
return {
|
|
88343
88491
|
port,
|
|
88344
|
-
close: () => new Promise((
|
|
88492
|
+
close: () => new Promise((resolve27) => {
|
|
88345
88493
|
for (const client of relayed) client.destroy();
|
|
88346
88494
|
pages.close();
|
|
88347
88495
|
server.closeAllConnections();
|
|
88348
|
-
server.close(() =>
|
|
88496
|
+
server.close(() => resolve27());
|
|
88349
88497
|
})
|
|
88350
88498
|
};
|
|
88351
88499
|
}
|
|
@@ -88362,7 +88510,7 @@ function launchCdpBridge({
|
|
|
88362
88510
|
stdio: ["ignore", "pipe", "ignore"],
|
|
88363
88511
|
env: { ...env, LAZE_CDP_TARGET: target, LAZE_CDP_EXPIRES_AT: expiresAt, LAZE_CDP_KEY: key }
|
|
88364
88512
|
});
|
|
88365
|
-
return new Promise((
|
|
88513
|
+
return new Promise((resolve27, reject) => {
|
|
88366
88514
|
let printed2 = "";
|
|
88367
88515
|
child.once("error", reject);
|
|
88368
88516
|
child.once("exit", (code4) => reject(new Error(`the CDP bridge stopped (${code4})`)));
|
|
@@ -88373,7 +88521,7 @@ function launchCdpBridge({
|
|
|
88373
88521
|
child.stdout.destroy();
|
|
88374
88522
|
child.removeAllListeners("exit");
|
|
88375
88523
|
child.unref();
|
|
88376
|
-
if (Number.isInteger(port) && port > 0)
|
|
88524
|
+
if (Number.isInteger(port) && port > 0) resolve27(port);
|
|
88377
88525
|
else reject(new Error("the CDP bridge printed no port"));
|
|
88378
88526
|
});
|
|
88379
88527
|
});
|
|
@@ -88500,7 +88648,7 @@ async function answering({
|
|
|
88500
88648
|
}
|
|
88501
88649
|
function bridgeStatePath({ context, machine: machine2 }) {
|
|
88502
88650
|
const safe = machine2.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
88503
|
-
return
|
|
88651
|
+
return join29(dirname19(context.environment.configPath), "bridges", `${safe}.json`);
|
|
88504
88652
|
}
|
|
88505
88653
|
async function bridgePort({
|
|
88506
88654
|
context,
|
|
@@ -89214,7 +89362,7 @@ async function channelSettings({ context, args }) {
|
|
|
89214
89362
|
|
|
89215
89363
|
// src/services/chat-actions-commands.service.ts
|
|
89216
89364
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
89217
|
-
import { basename as basename9, isAbsolute as isAbsolute2, relative as relative4, resolve as
|
|
89365
|
+
import { basename as basename9, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve11 } from "node:path";
|
|
89218
89366
|
|
|
89219
89367
|
// src/rules/app-link.rules.ts
|
|
89220
89368
|
var MARKDOWN_LINK = /^\[[^\]]*\]\((\S+)\)$/;
|
|
@@ -89242,8 +89390,8 @@ function appOfLinkOnly(body) {
|
|
|
89242
89390
|
|
|
89243
89391
|
// src/services/file-download.service.ts
|
|
89244
89392
|
import { createWriteStream } from "node:fs";
|
|
89245
|
-
import { mkdir as mkdir9, rename as rename3, rm as rm13, stat as
|
|
89246
|
-
import { basename as basename8, dirname as
|
|
89393
|
+
import { mkdir as mkdir9, rename as rename3, rm as rm13, stat as stat10, truncate } from "node:fs/promises";
|
|
89394
|
+
import { basename as basename8, dirname as dirname20, resolve as resolve10 } from "node:path";
|
|
89247
89395
|
import { Readable, Transform } from "node:stream";
|
|
89248
89396
|
import { pipeline } from "node:stream/promises";
|
|
89249
89397
|
var NOT_READY_WAIT_MS = 5e3;
|
|
@@ -89291,7 +89439,7 @@ function totalOf({ response, start: start2 }) {
|
|
|
89291
89439
|
if (length === null) return void 0;
|
|
89292
89440
|
return Number(length) + (response.status === 206 ? start2 : 0);
|
|
89293
89441
|
}
|
|
89294
|
-
var sizeOnDisk = (path) =>
|
|
89442
|
+
var sizeOnDisk = (path) => stat10(path).then(
|
|
89295
89443
|
(found) => found.size,
|
|
89296
89444
|
() => 0
|
|
89297
89445
|
);
|
|
@@ -89362,9 +89510,9 @@ async function downloadFile({
|
|
|
89362
89510
|
attachmentId,
|
|
89363
89511
|
out
|
|
89364
89512
|
}) {
|
|
89365
|
-
const asked = out ?
|
|
89366
|
-
const part =
|
|
89367
|
-
await mkdir9(
|
|
89513
|
+
const asked = out ? resolve10(context.cwd, out) : void 0;
|
|
89514
|
+
const part = resolve10(asked ? dirname20(asked) : context.cwd, `.${attachmentId}.part`);
|
|
89515
|
+
await mkdir9(dirname20(part), { recursive: true });
|
|
89368
89516
|
const named = await fetchWhole({ context, client, attachmentId, part, out }).catch(
|
|
89369
89517
|
async (error63) => {
|
|
89370
89518
|
await rm13(part, { force: true });
|
|
@@ -89372,7 +89520,7 @@ async function downloadFile({
|
|
|
89372
89520
|
throw new CliUsageError(`Could not write ${attachmentId} to disk: ${String(error63)}`);
|
|
89373
89521
|
}
|
|
89374
89522
|
);
|
|
89375
|
-
const path = asked ??
|
|
89523
|
+
const path = asked ?? resolve10(context.cwd, named ?? attachmentId);
|
|
89376
89524
|
await rename3(part, path);
|
|
89377
89525
|
return { path, sizeBytes: await sizeOnDisk(path) };
|
|
89378
89526
|
}
|
|
@@ -89663,7 +89811,7 @@ function uploadNameOf({ cwd, path }) {
|
|
|
89663
89811
|
return inside && !inside.startsWith("..") && !isAbsolute2(inside) ? inside : basename9(path);
|
|
89664
89812
|
}
|
|
89665
89813
|
var fileUpload = async ({ context, args, client }) => {
|
|
89666
|
-
const path =
|
|
89814
|
+
const path = resolve11(context.cwd, wordAt(args, 3));
|
|
89667
89815
|
const bytes = new Uint8Array(await readFile19(path));
|
|
89668
89816
|
const answer6 = await uploadFile({
|
|
89669
89817
|
context,
|
|
@@ -89895,20 +90043,8 @@ async function monitorRound(turn) {
|
|
|
89895
90043
|
`);
|
|
89896
90044
|
return false;
|
|
89897
90045
|
}
|
|
89898
|
-
|
|
89899
|
-
|
|
89900
|
-
const claim3 = forSession({ client, session });
|
|
89901
|
-
const refused = await notBoundNotice({
|
|
89902
|
-
context,
|
|
89903
|
-
client: claim3,
|
|
89904
|
-
session,
|
|
89905
|
-
error: error63,
|
|
89906
|
-
profile: turn.profile
|
|
89907
|
-
});
|
|
89908
|
-
if (refused?.rebound) return true;
|
|
89909
|
-
if (refused?.notice) context.out(`${refused.notice}
|
|
89910
|
-
`);
|
|
89911
|
-
if (!refused) context.err(`laze: the monitor will try again: ${String(error63)}
|
|
90046
|
+
if (await droppedBinding({ context, session, error: error63, profile: turn.profile })) return false;
|
|
90047
|
+
context.err(`laze: the monitor will try again: ${String(error63)}
|
|
89912
90048
|
`);
|
|
89913
90049
|
return false;
|
|
89914
90050
|
});
|
|
@@ -89920,13 +90056,13 @@ async function release({ context, profile }) {
|
|
|
89920
90056
|
}
|
|
89921
90057
|
async function monitorHook({ context, args }) {
|
|
89922
90058
|
const claudePid = await claudePidOf({ context });
|
|
89923
|
-
const
|
|
89924
|
-
await rememberSession({ context, claudePid, session }).catch(() => void 0);
|
|
90059
|
+
const first = await monitorSessionOf({ context, claudePid });
|
|
90060
|
+
await rememberSession({ context, claudePid, session: first }).catch(() => void 0);
|
|
89925
90061
|
const held = /* @__PURE__ */ new Set();
|
|
89926
|
-
const turn = { context, args, claudePid, session };
|
|
89927
90062
|
try {
|
|
89928
90063
|
while (claudePid && context.processes.alive(claudePid)) {
|
|
89929
|
-
const
|
|
90064
|
+
const session = await monitorSessionOf({ context, claudePid }) ?? first;
|
|
90065
|
+
const round = await oneRound({ turn: { context, args, claudePid, session }, held });
|
|
89930
90066
|
if (round === "outranked") await context.sleep(MONITOR_OUTRANKED_MS);
|
|
89931
90067
|
else if (!round) await context.sleep(MONITOR_IDLE_MS);
|
|
89932
90068
|
}
|
|
@@ -89937,7 +90073,7 @@ async function monitorHook({ context, args }) {
|
|
|
89937
90073
|
}
|
|
89938
90074
|
async function oneRound({ turn, held }) {
|
|
89939
90075
|
try {
|
|
89940
|
-
const profile = await agentProfileHere(turn);
|
|
90076
|
+
const profile = await agentProfileHere({ context: turn.context, session: turn.session });
|
|
89941
90077
|
const round = profile ? await monitorRound({ ...turn, profile }) : false;
|
|
89942
90078
|
if (profile && round === true) held.add(profile);
|
|
89943
90079
|
return round;
|
|
@@ -89953,9 +90089,9 @@ async function monitorSessionOf({
|
|
|
89953
90089
|
}) {
|
|
89954
90090
|
const sessionId = context.environment.inherited.CLAUDE_CODE_SESSION_ID;
|
|
89955
90091
|
const fromEnv = sessionOf({ context, harness: "claude-code", sessionId });
|
|
89956
|
-
if (
|
|
90092
|
+
if (!claudePid) return fromEnv;
|
|
89957
90093
|
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
89958
|
-
return readStateJson({ path });
|
|
90094
|
+
return await readStateJson({ path }) ?? fromEnv;
|
|
89959
90095
|
}
|
|
89960
90096
|
|
|
89961
90097
|
// ../../modules/compute/contract/src/browser-tab.ts
|
|
@@ -92802,9 +92938,9 @@ var computerBrowserFactsDefinition = external_exports.object({
|
|
|
92802
92938
|
var computerBrowserFactsSchema = computerBrowserFactsDefinition;
|
|
92803
92939
|
|
|
92804
92940
|
// src/services/computer-copy-commands.service.ts
|
|
92805
|
-
import { mkdtemp as mkdtemp2, open as open7, rm as rm15, stat as
|
|
92941
|
+
import { mkdtemp as mkdtemp2, open as open7, rm as rm15, stat as stat11 } from "node:fs/promises";
|
|
92806
92942
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
92807
|
-
import { basename as basename10, dirname as
|
|
92943
|
+
import { basename as basename10, dirname as dirname21, resolve as resolve12 } from "node:path";
|
|
92808
92944
|
var COMPUTER_COPY_USAGE = ` laze computer copy <path> --agent <agent> [--to <folder>] [--json]
|
|
92809
92945
|
copy a local file or folder into your hosted agent's work folder
|
|
92810
92946
|
(its owner only, up to 2 GiB packed); <folder> is relative to the
|
|
@@ -92818,9 +92954,9 @@ function stringFlag(args, name3) {
|
|
|
92818
92954
|
}
|
|
92819
92955
|
function packingOf({ path, isDirectory }) {
|
|
92820
92956
|
const contents = isDirectory && path.endsWith("/");
|
|
92821
|
-
const absolute =
|
|
92957
|
+
const absolute = resolve12(path);
|
|
92822
92958
|
const name3 = basename10(absolute);
|
|
92823
|
-
return contents ? { name: name3, parent: absolute, entry: "." } : { name: name3, parent:
|
|
92959
|
+
return contents ? { name: name3, parent: absolute, entry: "." } : { name: name3, parent: dirname21(absolute), entry: name3 };
|
|
92824
92960
|
}
|
|
92825
92961
|
async function sendParts3({
|
|
92826
92962
|
context,
|
|
@@ -92864,22 +93000,22 @@ async function copy({ context, args }) {
|
|
|
92864
93000
|
if (!path || !agent3) throw new CliUsageError(`Usage:
|
|
92865
93001
|
${COMPUTER_COPY_USAGE}`);
|
|
92866
93002
|
const to = stringFlag(args, "to") ?? ".";
|
|
92867
|
-
const full =
|
|
92868
|
-
const found = await
|
|
93003
|
+
const full = resolve12(context.cwd, path);
|
|
93004
|
+
const found = await stat11(full).catch(() => void 0);
|
|
92869
93005
|
if (!found) throw new CliUsageError(`${path} does not exist`);
|
|
92870
93006
|
const { name: name3, parent, entry: entry2 } = packingOf({
|
|
92871
93007
|
path: path.endsWith("/") ? `${full}/` : full,
|
|
92872
93008
|
isDirectory: found.isDirectory()
|
|
92873
93009
|
});
|
|
92874
|
-
const dir = await mkdtemp2(
|
|
92875
|
-
const archive2 =
|
|
93010
|
+
const dir = await mkdtemp2(resolve12(tmpdir4(), "laze-copy-"));
|
|
93011
|
+
const archive2 = resolve12(dir, `${name3}.tar.gz`);
|
|
92876
93012
|
try {
|
|
92877
93013
|
const code4 = await context.runCommand({
|
|
92878
93014
|
command: ["tar", "-czf", archive2, "-C", parent, entry2],
|
|
92879
93015
|
env: { COPYFILE_DISABLE: "1" }
|
|
92880
93016
|
});
|
|
92881
93017
|
if (code4 !== 0) throw new CliUsageError(`tar could not pack ${path} (exit ${code4})`);
|
|
92882
|
-
const sizeBytes = (await
|
|
93018
|
+
const sizeBytes = (await stat11(archive2)).size;
|
|
92883
93019
|
if (sizeBytes > COMPUTER_COPY_MAX_BYTES)
|
|
92884
93020
|
throw new CliUsageError(`${path} packs to ${mb(sizeBytes)}; a copy holds at most 2 GiB`);
|
|
92885
93021
|
const client = await computeClient({ context, args });
|
|
@@ -93203,8 +93339,8 @@ import { readFile as readFile21 } from "node:fs/promises";
|
|
|
93203
93339
|
|
|
93204
93340
|
// src/services/mcp-gateway.service.ts
|
|
93205
93341
|
import { mkdir as mkdir10, readFile as readFile20, writeFile as writeFile7 } from "node:fs/promises";
|
|
93206
|
-
import { basename as basename11, join as
|
|
93207
|
-
import { createInterface as
|
|
93342
|
+
import { basename as basename11, join as join30, resolve as resolve13 } from "node:path";
|
|
93343
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
93208
93344
|
|
|
93209
93345
|
// src/services/mcp-support.service.ts
|
|
93210
93346
|
var SUPPORT_TOOL_NAMES = ["support_read_thread", "support_answer", "support_needs_human"];
|
|
@@ -93303,7 +93439,7 @@ function serveMcpGateway({
|
|
|
93303
93439
|
context,
|
|
93304
93440
|
args
|
|
93305
93441
|
}) {
|
|
93306
|
-
return relayMcpLines({ context, args, lines:
|
|
93442
|
+
return relayMcpLines({ context, args, lines: createInterface2({ input: process.stdin }) });
|
|
93307
93443
|
}
|
|
93308
93444
|
var WATCH_MS2 = 2e3;
|
|
93309
93445
|
var LIST_CHANGED = '{"jsonrpc":"2.0","method":"notifications/tools/list_changed"}';
|
|
@@ -93346,7 +93482,7 @@ async function relayMcpLines({
|
|
|
93346
93482
|
const relay2 = {
|
|
93347
93483
|
readTurn,
|
|
93348
93484
|
out: (text3) => context.out(text3),
|
|
93349
|
-
saveFile: (file4) => saveMailFile({ root:
|
|
93485
|
+
saveFile: (file4) => saveMailFile({ root: resolve13(context.cwd, MAIL_FILES_DIR), file: file4 }),
|
|
93350
93486
|
post: async ({ line, turn }) => {
|
|
93351
93487
|
if (args.flags.support === true) return answerSupportLine({ line, turn, client });
|
|
93352
93488
|
const response = await context.fetcher(url2, {
|
|
@@ -93382,8 +93518,8 @@ function safeName(name3, fallback) {
|
|
|
93382
93518
|
return last && last !== "." && last !== ".." ? last : fallback;
|
|
93383
93519
|
}
|
|
93384
93520
|
async function saveMailFile({ root, file: file4 }) {
|
|
93385
|
-
const dir =
|
|
93386
|
-
const path =
|
|
93521
|
+
const dir = join30(root, safeName(file4.messageId, "message"));
|
|
93522
|
+
const path = join30(dir, safeName(file4.fileName, "attachment"));
|
|
93387
93523
|
await mkdir10(dir, { recursive: true });
|
|
93388
93524
|
await writeFile7(path, Buffer.from(file4.base64, "base64"));
|
|
93389
93525
|
return path;
|
|
@@ -93634,7 +93770,7 @@ async function suggestServer({
|
|
|
93634
93770
|
|
|
93635
93771
|
// src/services/connector-commands.service.ts
|
|
93636
93772
|
import { readFile as readFile23 } from "node:fs/promises";
|
|
93637
|
-
import { resolve as
|
|
93773
|
+
import { resolve as resolve14 } from "node:path";
|
|
93638
93774
|
|
|
93639
93775
|
// src/services/vault-keychain-commands.service.ts
|
|
93640
93776
|
import { readFile as readFile22 } from "node:fs/promises";
|
|
@@ -94294,7 +94430,7 @@ async function keyText({ context, args }) {
|
|
|
94294
94430
|
throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
|
|
94295
94431
|
}
|
|
94296
94432
|
const file4 = flagText({ args, name: "from-file" });
|
|
94297
|
-
const text3 = file4 ? await readFile23(
|
|
94433
|
+
const text3 = file4 ? await readFile23(resolve14(context.cwd, file4), "utf8") : await context.readStdin();
|
|
94298
94434
|
const trimmed = text3.trim();
|
|
94299
94435
|
if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
|
|
94300
94436
|
return trimmed;
|
|
@@ -94684,7 +94820,7 @@ async function conversationDelete({ context, args }) {
|
|
|
94684
94820
|
|
|
94685
94821
|
// src/services/discord-commands.service.ts
|
|
94686
94822
|
import { readFile as readFile24 } from "node:fs/promises";
|
|
94687
|
-
import { resolve as
|
|
94823
|
+
import { resolve as resolve15 } from "node:path";
|
|
94688
94824
|
|
|
94689
94825
|
// ../../modules/discord/contract/src/discord.ts
|
|
94690
94826
|
var workspaceIdSchema25 = external_exports.string().min(1).max(64);
|
|
@@ -95031,7 +95167,7 @@ async function secretsOf({ context, args }) {
|
|
|
95031
95167
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
95032
95168
|
if (fromConnection) return { fromConnection };
|
|
95033
95169
|
const file4 = flagText({ args, name: "from-file" });
|
|
95034
|
-
const text3 = file4 ? await readFile24(
|
|
95170
|
+
const text3 = file4 ? await readFile24(resolve15(context.cwd, file4), "utf8") : await context.readStdin();
|
|
95035
95171
|
const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
95036
95172
|
if (lines2.length !== 2) {
|
|
95037
95173
|
throw new CliUsageError(
|
|
@@ -95301,8 +95437,8 @@ var DOMAINS_USAGE = `Usage:
|
|
|
95301
95437
|
var printJson5 = (context, data) => context.out(`${JSON.stringify(data, null, 2)}
|
|
95302
95438
|
`);
|
|
95303
95439
|
function printDomain(context, row) {
|
|
95304
|
-
const
|
|
95305
|
-
context.out(`${row.domain} ${
|
|
95440
|
+
const join38 = row.autoJoin ? "auto-join on" : "auto-join off";
|
|
95441
|
+
context.out(`${row.domain} ${join38}${row.enforced ? " single sign-on enforced" : ""}
|
|
95306
95442
|
`);
|
|
95307
95443
|
}
|
|
95308
95444
|
async function list5({ context, args }) {
|
|
@@ -95335,7 +95471,7 @@ async function domains({ context, args }) {
|
|
|
95335
95471
|
|
|
95336
95472
|
// src/services/emoji-commands.service.ts
|
|
95337
95473
|
import { readFile as readFile25 } from "node:fs/promises";
|
|
95338
|
-
import { resolve as
|
|
95474
|
+
import { resolve as resolve16 } from "node:path";
|
|
95339
95475
|
var EMOJI_USAGE = `Usage:
|
|
95340
95476
|
laze emoji list [--json] the workspace's custom emoji, aliases and who added each
|
|
95341
95477
|
laze emoji add <name> <file> [--alias <a,b>] add a PNG, JPEG or GIF as :name: (made 128px square)
|
|
@@ -95375,7 +95511,7 @@ async function addEmoji({ context, args, client }) {
|
|
|
95375
95511
|
const file4 = wordAt4(args, 3);
|
|
95376
95512
|
let bytes;
|
|
95377
95513
|
try {
|
|
95378
|
-
bytes = new Uint8Array(await readFile25(
|
|
95514
|
+
bytes = new Uint8Array(await readFile25(resolve16(context.cwd, file4)));
|
|
95379
95515
|
} catch {
|
|
95380
95516
|
throw new CliUsageError(`Cannot read ${file4}.`);
|
|
95381
95517
|
}
|
|
@@ -95715,7 +95851,7 @@ var ExternalSharingHooksToken = externalUi.hooks("sharing");
|
|
|
95715
95851
|
|
|
95716
95852
|
// src/services/workspace-commands.service.ts
|
|
95717
95853
|
import { readFile as readFile26 } from "node:fs/promises";
|
|
95718
|
-
import { resolve as
|
|
95854
|
+
import { resolve as resolve17 } from "node:path";
|
|
95719
95855
|
var ROLE_NAMES2 = {
|
|
95720
95856
|
OWNER: "Owner",
|
|
95721
95857
|
ADMIN: "Admin",
|
|
@@ -95897,7 +96033,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
|
|
|
95897
96033
|
async function readLogo({ context, file: file4 }) {
|
|
95898
96034
|
let bytes;
|
|
95899
96035
|
try {
|
|
95900
|
-
bytes = new Uint8Array(await readFile26(
|
|
96036
|
+
bytes = new Uint8Array(await readFile26(resolve17(context.cwd, file4)));
|
|
95901
96037
|
} catch {
|
|
95902
96038
|
throw new CliUsageError(`No file to read at ${file4}.`);
|
|
95903
96039
|
}
|
|
@@ -96533,7 +96669,7 @@ async function agentFeedAccess({
|
|
|
96533
96669
|
|
|
96534
96670
|
// src/services/feed-commands.service.ts
|
|
96535
96671
|
import { readFile as readFile27 } from "node:fs/promises";
|
|
96536
|
-
import { resolve as
|
|
96672
|
+
import { resolve as resolve18 } from "node:path";
|
|
96537
96673
|
|
|
96538
96674
|
// ../../modules/feed/contract/src/feed.delegate.ts
|
|
96539
96675
|
var feedDelegateSchemaDefinition = external_exports.object({
|
|
@@ -97760,7 +97896,7 @@ async function bodyOf2({
|
|
|
97760
97896
|
flags: flags2
|
|
97761
97897
|
}) {
|
|
97762
97898
|
const body = { ...flags2.fields };
|
|
97763
|
-
const read4 = (source) => "file" in source ? readFile27(
|
|
97899
|
+
const read4 = (source) => "file" in source ? readFile27(resolve18(context.cwd, source.file), "utf8") : source.text;
|
|
97764
97900
|
for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read4(source);
|
|
97765
97901
|
if (flags2.rich) {
|
|
97766
97902
|
const text3 = await read4(flags2.rich.source);
|
|
@@ -98037,7 +98173,7 @@ async function textFlag({
|
|
|
98037
98173
|
}) {
|
|
98038
98174
|
const value = flagText({ args, name: name3 });
|
|
98039
98175
|
if (!value.startsWith("@")) return value;
|
|
98040
|
-
return readFile27(
|
|
98176
|
+
return readFile27(resolve18(context.cwd, value.slice(1)), "utf8");
|
|
98041
98177
|
}
|
|
98042
98178
|
async function feedList({ context, args }) {
|
|
98043
98179
|
const { client, profile } = await signedIn({ context, args });
|
|
@@ -98127,7 +98263,7 @@ async function ranksOf({
|
|
|
98127
98263
|
}) {
|
|
98128
98264
|
const file4 = flagText({ args, name: "file" });
|
|
98129
98265
|
if (file4) {
|
|
98130
|
-
const parsed = JSON.parse(await readFile27(
|
|
98266
|
+
const parsed = JSON.parse(await readFile27(resolve18(context.cwd, file4), "utf8"));
|
|
98131
98267
|
if (Array.isArray(parsed)) return parsed;
|
|
98132
98268
|
throw new CliUsageError("--file holds a list of {itemId, priority}");
|
|
98133
98269
|
}
|
|
@@ -98995,12 +99131,12 @@ async function ip({ context, args }) {
|
|
|
98995
99131
|
|
|
98996
99132
|
// src/services/join-commands.service.ts
|
|
98997
99133
|
import { rm as rm16 } from "node:fs/promises";
|
|
98998
|
-
import { hostname as
|
|
98999
|
-
import { dirname as
|
|
99134
|
+
import { hostname as hostname9 } from "node:os";
|
|
99135
|
+
import { dirname as dirname22, join as join31 } from "node:path";
|
|
99000
99136
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
99001
99137
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
99002
99138
|
function pendingPathOf({ context }) {
|
|
99003
|
-
return
|
|
99139
|
+
return join31(dirname22(context.environment.configPath), "join", "pending.json");
|
|
99004
99140
|
}
|
|
99005
99141
|
async function readPending({
|
|
99006
99142
|
context,
|
|
@@ -99137,7 +99273,7 @@ async function joinAsAgent({ context, args }) {
|
|
|
99137
99273
|
harness,
|
|
99138
99274
|
...asked,
|
|
99139
99275
|
...machineOwners.length > 0 ? { machineOwners } : {},
|
|
99140
|
-
machine:
|
|
99276
|
+
machine: hostname9().slice(0, 120),
|
|
99141
99277
|
...flagText({ args, name: "name" }) ? { name: flagText({ args, name: "name" }) } : {},
|
|
99142
99278
|
...flagText({ args, name: "note" }) ? { note: flagText({ args, name: "note" }) } : {}
|
|
99143
99279
|
}).then((started) => ({ ...started, url: url2, asked })).catch((error63) => sandboxed({ context, error: error63 }));
|
|
@@ -100025,7 +100161,7 @@ async function machine({ context, args }) {
|
|
|
100025
100161
|
}
|
|
100026
100162
|
|
|
100027
100163
|
// src/services/mcp-server.service.ts
|
|
100028
|
-
import { createInterface as
|
|
100164
|
+
import { createInterface as createInterface3 } from "node:readline";
|
|
100029
100165
|
var SERVER_REFUSED = -32001;
|
|
100030
100166
|
var MCP_REFUSED_COMMANDS = /* @__PURE__ */ new Set([
|
|
100031
100167
|
"login",
|
|
@@ -100269,24 +100405,24 @@ async function serveMcp({
|
|
|
100269
100405
|
runCommandLine
|
|
100270
100406
|
}) {
|
|
100271
100407
|
const lines2 = {
|
|
100272
|
-
[Symbol.asyncIterator]: () =>
|
|
100408
|
+
[Symbol.asyncIterator]: () => createInterface3({ input: process.stdin })[Symbol.asyncIterator]()
|
|
100273
100409
|
};
|
|
100274
100410
|
await answerMcpLines({ context, args, lines: lines2, runCommandLine });
|
|
100275
100411
|
}
|
|
100276
100412
|
|
|
100277
100413
|
// src/services/memory-commands.service.ts
|
|
100278
|
-
import { readdir as
|
|
100279
|
-
import { join as
|
|
100414
|
+
import { readdir as readdir7, readFile as readFile30 } from "node:fs/promises";
|
|
100415
|
+
import { join as join32, resolve as resolve20 } from "node:path";
|
|
100280
100416
|
|
|
100281
100417
|
// src/services/mount-files.service.ts
|
|
100282
100418
|
import { mkdir as mkdir11, readFile as readFile29, rm as rm17, writeFile as writeFile8 } from "node:fs/promises";
|
|
100283
|
-
import { dirname as
|
|
100419
|
+
import { dirname as dirname23, relative as relative5, resolve as resolve19 } from "node:path";
|
|
100284
100420
|
async function textArgument({
|
|
100285
100421
|
context,
|
|
100286
100422
|
value
|
|
100287
100423
|
}) {
|
|
100288
100424
|
if (value === "-") return context.readStdin();
|
|
100289
|
-
if (value.startsWith("@")) return readFile29(
|
|
100425
|
+
if (value.startsWith("@")) return readFile29(resolve19(context.cwd, value.slice(1)), "utf8");
|
|
100290
100426
|
return value;
|
|
100291
100427
|
}
|
|
100292
100428
|
function turnChannel({ context, args }) {
|
|
@@ -100298,15 +100434,15 @@ async function writeMount({
|
|
|
100298
100434
|
folder,
|
|
100299
100435
|
files: files2
|
|
100300
100436
|
}) {
|
|
100301
|
-
const root =
|
|
100437
|
+
const root = resolve19(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
100302
100438
|
await rm17(root, { recursive: true, force: true });
|
|
100303
100439
|
await mkdir11(root, { recursive: true });
|
|
100304
100440
|
for (const file4 of files2) {
|
|
100305
|
-
const target =
|
|
100441
|
+
const target = resolve19(root, file4.path);
|
|
100306
100442
|
const inside = relative5(root, target);
|
|
100307
100443
|
if (!inside || inside.startsWith(".."))
|
|
100308
100444
|
throw new Error(`Refusing to write outside ${root}: ${file4.path}`);
|
|
100309
|
-
await mkdir11(
|
|
100445
|
+
await mkdir11(dirname23(target), { recursive: true });
|
|
100310
100446
|
await writeFile8(target, file4.content);
|
|
100311
100447
|
}
|
|
100312
100448
|
return root;
|
|
@@ -100562,16 +100698,16 @@ async function siestaImport({
|
|
|
100562
100698
|
args,
|
|
100563
100699
|
dir
|
|
100564
100700
|
}) {
|
|
100565
|
-
const root =
|
|
100566
|
-
const log = await readFile30(
|
|
100567
|
-
const names = (await
|
|
100701
|
+
const root = resolve20(context.cwd, dir);
|
|
100702
|
+
const log = await readFile30(join32(root, "LOG.md"));
|
|
100703
|
+
const names = (await readdir7(join32(root, "tree")).catch(() => [])).filter(
|
|
100568
100704
|
(name3) => /^\d{1,6}-\d{1,6}\.md$/.test(name3)
|
|
100569
100705
|
);
|
|
100570
100706
|
const tree = Object.fromEntries(
|
|
100571
100707
|
await Promise.all(
|
|
100572
100708
|
names.map(async (name3) => [
|
|
100573
100709
|
name3.slice(0, -3),
|
|
100574
|
-
(await readFile30(
|
|
100710
|
+
(await readFile30(join32(root, "tree", name3))).toString("base64")
|
|
100575
100711
|
])
|
|
100576
100712
|
)
|
|
100577
100713
|
);
|
|
@@ -100590,16 +100726,16 @@ async function memoryImport({ context, args }) {
|
|
|
100590
100726
|
if (siesta) return siestaImport({ context, args, dir: siesta });
|
|
100591
100727
|
const dir = flagText({ args, name: "optmem" });
|
|
100592
100728
|
if (!dir) throw new CliUsageError(USAGE14);
|
|
100593
|
-
const root =
|
|
100594
|
-
const log = await readFile30(
|
|
100595
|
-
const sizes2 = (await
|
|
100729
|
+
const root = resolve20(context.cwd, dir);
|
|
100730
|
+
const log = await readFile30(join32(root, "LOG.txt"));
|
|
100731
|
+
const sizes2 = (await readdir7(join32(root, "TREE")).catch(() => [])).filter(
|
|
100596
100732
|
(name3) => /^\d{1,4}$/.test(name3)
|
|
100597
100733
|
);
|
|
100598
100734
|
const tree = Object.fromEntries(
|
|
100599
100735
|
await Promise.all(
|
|
100600
100736
|
sizes2.map(async (size) => [
|
|
100601
100737
|
size,
|
|
100602
|
-
(await readFile30(
|
|
100738
|
+
(await readFile30(join32(root, "TREE", size))).toString("base64")
|
|
100603
100739
|
])
|
|
100604
100740
|
)
|
|
100605
100741
|
);
|
|
@@ -100992,7 +101128,7 @@ async function notifications({ context, args }) {
|
|
|
100992
101128
|
}
|
|
100993
101129
|
|
|
100994
101130
|
// src/services/openclaw-commands.service.ts
|
|
100995
|
-
import { resolve as
|
|
101131
|
+
import { resolve as resolve21 } from "node:path";
|
|
100996
101132
|
var OPENCLAW_USAGE = `Usage (a person's key; a gateway belongs to the person who connects it):
|
|
100997
101133
|
laze openclaw list the gateways connected here and their agents
|
|
100998
101134
|
laze openclaw connect <wss url> [--label <label>] (< token | --from-file <file> | --from-vault <connection>)
|
|
@@ -101143,7 +101279,7 @@ var agentKey = async ({ context, args, client, url: url2 }) => {
|
|
|
101143
101279
|
});
|
|
101144
101280
|
const login2 = flagText({ args, name: "login" });
|
|
101145
101281
|
if (login2) {
|
|
101146
|
-
const folder =
|
|
101282
|
+
const folder = resolve21(context.cwd, login2);
|
|
101147
101283
|
const profile = profileNameOf(key.agentName);
|
|
101148
101284
|
await signInFolder({ context, url: url2, token: key.token, name: profile, folder });
|
|
101149
101285
|
context.out(
|
|
@@ -101195,9 +101331,9 @@ async function openclaw({
|
|
|
101195
101331
|
}
|
|
101196
101332
|
|
|
101197
101333
|
// src/services/operator-key-commands.service.ts
|
|
101198
|
-
import { createHash as
|
|
101334
|
+
import { createHash as createHash10, randomBytes as randomBytes5 } from "node:crypto";
|
|
101199
101335
|
import { mkdir as mkdir12, readFile as readFile31, rm as rm18, writeFile as writeFile9 } from "node:fs/promises";
|
|
101200
|
-
import { dirname as
|
|
101336
|
+
import { dirname as dirname24, join as join33 } from "node:path";
|
|
101201
101337
|
|
|
101202
101338
|
// ../../modules/audit-log/contract/src/audit-log.api.ts
|
|
101203
101339
|
var auditEntrySchemaDefinition = external_exports.object({
|
|
@@ -102972,14 +103108,14 @@ Ops function leases (ADR-214), instead of reading the database:
|
|
|
102972
103108
|
call one function of an approved lease; a cut
|
|
102973
103109
|
list says so and names the cursor of the next page`;
|
|
102974
103110
|
var POLL_MS3 = 5e3;
|
|
102975
|
-
var keyFile = ({ context, keyId }) =>
|
|
103111
|
+
var keyFile = ({ context, keyId }) => join33(dirname24(context.environment.configPath), "operator-keys", keyId.replaceAll("/", "_"));
|
|
102976
103112
|
async function saveSecret({
|
|
102977
103113
|
context,
|
|
102978
103114
|
keyId,
|
|
102979
103115
|
secret
|
|
102980
103116
|
}) {
|
|
102981
103117
|
const path = keyFile({ context, keyId });
|
|
102982
|
-
await mkdir12(
|
|
103118
|
+
await mkdir12(dirname24(path), { recursive: true, mode: 448 });
|
|
102983
103119
|
await writeFile9(path, secret, { mode: 384 });
|
|
102984
103120
|
}
|
|
102985
103121
|
function typedArg(text3) {
|
|
@@ -103037,7 +103173,7 @@ async function requestKey({ context, args }) {
|
|
|
103037
103173
|
target,
|
|
103038
103174
|
args: argsOf({ args }),
|
|
103039
103175
|
reason: reason2,
|
|
103040
|
-
secretHash:
|
|
103176
|
+
secretHash: createHash10("sha256").update(secret).digest("hex")
|
|
103041
103177
|
});
|
|
103042
103178
|
await saveSecret({ context, keyId: key.id, secret });
|
|
103043
103179
|
const answered = args.flags.wait ? await waitForAnswer({ context, client, key }) : key;
|
|
@@ -103135,7 +103271,7 @@ async function requestLease({ context, args }) {
|
|
|
103135
103271
|
args: {},
|
|
103136
103272
|
functions,
|
|
103137
103273
|
reason: reason2,
|
|
103138
|
-
secretHash:
|
|
103274
|
+
secretHash: createHash10("sha256").update(secret).digest("hex")
|
|
103139
103275
|
});
|
|
103140
103276
|
await saveSecret({ context, keyId: key.id, secret });
|
|
103141
103277
|
const answered = args.flags.wait ? await waitForAnswer({ context, client, key }) : key;
|
|
@@ -103216,7 +103352,7 @@ ${OPS_USAGE}`);
|
|
|
103216
103352
|
|
|
103217
103353
|
// src/services/release-watch.service.ts
|
|
103218
103354
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
103219
|
-
import { dirname as
|
|
103355
|
+
import { dirname as dirname25, join as join34 } from "node:path";
|
|
103220
103356
|
var RETRY_AFTER_MS = 6 * 60 * 60 * 1e3;
|
|
103221
103357
|
async function scriptOf(context) {
|
|
103222
103358
|
const script = context.program.at(-1) ?? "";
|
|
@@ -103233,15 +103369,15 @@ async function startedUpdate({
|
|
|
103233
103369
|
if (context.environment.inherited.LAZE_AUTO_UPDATE === "0") return null;
|
|
103234
103370
|
const plan2 = updatePlanOf({ script: await scriptOf(context) });
|
|
103235
103371
|
if (plan2.kind !== "install") return null;
|
|
103236
|
-
const folder =
|
|
103237
|
-
const stamp =
|
|
103372
|
+
const folder = dirname25(context.environment.configPath);
|
|
103373
|
+
const stamp = join34(folder, "auto-update.json");
|
|
103238
103374
|
const last = await readStateJson({ path: stamp }) ?? null;
|
|
103239
103375
|
const now = context.nowMs();
|
|
103240
103376
|
if (last?.server === server && now - last.atMs < RETRY_AFTER_MS) return null;
|
|
103241
103377
|
await writeStateJson({ path: stamp, value: { server, atMs: now } });
|
|
103242
103378
|
context.processes.spawnDetached({
|
|
103243
103379
|
argv: [...context.program, "update"],
|
|
103244
|
-
logPath:
|
|
103380
|
+
logPath: join34(folder, "auto-update.log")
|
|
103245
103381
|
});
|
|
103246
103382
|
return { manager: plan2.manager };
|
|
103247
103383
|
}
|
|
@@ -103537,8 +103673,8 @@ async function schedule({ context, args }) {
|
|
|
103537
103673
|
}
|
|
103538
103674
|
|
|
103539
103675
|
// src/services/skill-commands.service.ts
|
|
103540
|
-
import { readdir as
|
|
103541
|
-
import { join as
|
|
103676
|
+
import { readdir as readdir8, readFile as readFile32 } from "node:fs/promises";
|
|
103677
|
+
import { join as join35, relative as relative6, resolve as resolve22 } from "node:path";
|
|
103542
103678
|
var USAGE18 = `Usage:
|
|
103543
103679
|
laze skill list [--agent <agentId>]
|
|
103544
103680
|
laze skill install <catalogue-id> [--as <name>] [--agent <agentId>]
|
|
@@ -103555,11 +103691,11 @@ var USAGE18 = `Usage:
|
|
|
103555
103691
|
--agent names the agent with a person's key; an agent's key works on its own skills.
|
|
103556
103692
|
With a person's key, list without --agent shows every agent's skills.`;
|
|
103557
103693
|
async function folderFiles({ root }) {
|
|
103558
|
-
const entries = await
|
|
103694
|
+
const entries = await readdir8(root, { recursive: true, withFileTypes: true });
|
|
103559
103695
|
const files2 = [];
|
|
103560
103696
|
for (const entry2 of entries) {
|
|
103561
103697
|
if (!entry2.isFile()) continue;
|
|
103562
|
-
const full =
|
|
103698
|
+
const full = join35(entry2.parentPath, entry2.name);
|
|
103563
103699
|
files2.push({ path: relative6(root, full), content: await readFile32(full, "utf8") });
|
|
103564
103700
|
}
|
|
103565
103701
|
return files2.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
@@ -103591,7 +103727,7 @@ async function skillInstall({ context, args }) {
|
|
|
103591
103727
|
if (!catalogueId === !from) throw new CliUsageError(USAGE18);
|
|
103592
103728
|
const name3 = flagText({ args, name: "as" });
|
|
103593
103729
|
const agent3 = flagText({ args, name: "agent" });
|
|
103594
|
-
const files2 = from ? await folderFiles({ root:
|
|
103730
|
+
const files2 = from ? await folderFiles({ root: resolve22(context.cwd, from) }) : void 0;
|
|
103595
103731
|
const { client } = await signedIn({ context, args });
|
|
103596
103732
|
const installed = await client.post("/api/skills/install", {
|
|
103597
103733
|
...catalogueId ? { catalogueId } : {},
|
|
@@ -103658,7 +103794,7 @@ async function skillUpdate({ context, args }) {
|
|
|
103658
103794
|
if (!name3 || !newName && description === void 0 && !skillMdFile) {
|
|
103659
103795
|
throw new CliUsageError(USAGE18);
|
|
103660
103796
|
}
|
|
103661
|
-
const skillMd = skillMdFile ? await readFile32(
|
|
103797
|
+
const skillMd = skillMdFile ? await readFile32(resolve22(context.cwd, skillMdFile), "utf8") : void 0;
|
|
103662
103798
|
const { client } = await signedIn({ context, args });
|
|
103663
103799
|
const updated = await client.post("/api/skills/update", {
|
|
103664
103800
|
name: name3,
|
|
@@ -103705,7 +103841,7 @@ async function skill({ context, args }) {
|
|
|
103705
103841
|
|
|
103706
103842
|
// src/services/slack-commands.service.ts
|
|
103707
103843
|
import { readFile as readFile33 } from "node:fs/promises";
|
|
103708
|
-
import { resolve as
|
|
103844
|
+
import { resolve as resolve23 } from "node:path";
|
|
103709
103845
|
var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
|
|
103710
103846
|
laze slack overview connected Slack workspaces, mirrors, your link
|
|
103711
103847
|
laze slack link-prompts Slack workspaces you have not linked yet
|
|
@@ -103755,7 +103891,7 @@ async function secretLines({ context, args }) {
|
|
|
103755
103891
|
throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
|
|
103756
103892
|
}
|
|
103757
103893
|
const file4 = flagText({ args, name: "from-file" });
|
|
103758
|
-
const text3 = file4 ? await readFile33(
|
|
103894
|
+
const text3 = file4 ? await readFile33(resolve23(context.cwd, file4), "utf8") : await context.readStdin();
|
|
103759
103895
|
return text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
103760
103896
|
}
|
|
103761
103897
|
async function secretsOf2({
|
|
@@ -104504,8 +104640,8 @@ async function checkInstalled({
|
|
|
104504
104640
|
}
|
|
104505
104641
|
|
|
104506
104642
|
// src/services/vault-env-commands.service.ts
|
|
104507
|
-
import { readFile as readFile35, stat as
|
|
104508
|
-
import { dirname as
|
|
104643
|
+
import { readFile as readFile35, stat as stat12 } from "node:fs/promises";
|
|
104644
|
+
import { dirname as dirname26, join as join36, resolve as resolve24 } from "node:path";
|
|
104509
104645
|
|
|
104510
104646
|
// src/rules/vault-manifest.rules.ts
|
|
104511
104647
|
var VARIABLE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -104838,7 +104974,7 @@ function refusedReason({
|
|
|
104838
104974
|
return VAULT_EXIT_BAD_REASON;
|
|
104839
104975
|
}
|
|
104840
104976
|
async function isFile(path) {
|
|
104841
|
-
return
|
|
104977
|
+
return stat12(path).then(
|
|
104842
104978
|
(found) => found.isFile(),
|
|
104843
104979
|
() => false
|
|
104844
104980
|
);
|
|
@@ -104848,12 +104984,12 @@ async function manifestPathOf({
|
|
|
104848
104984
|
args
|
|
104849
104985
|
}) {
|
|
104850
104986
|
const named = args.words[2];
|
|
104851
|
-
if (named) return
|
|
104987
|
+
if (named) return resolve24(context.cwd, named);
|
|
104852
104988
|
const environment = flagText({ args, name: "env" });
|
|
104853
104989
|
const file4 = environment ? `.env.${environment}.vault` : ".env.vault";
|
|
104854
|
-
for (let dir =
|
|
104855
|
-
if (await isFile(
|
|
104856
|
-
if (
|
|
104990
|
+
for (let dir = resolve24(context.cwd); ; dir = dirname26(dir)) {
|
|
104991
|
+
if (await isFile(join36(dir, file4))) return join36(dir, file4);
|
|
104992
|
+
if (dirname26(dir) === dir) break;
|
|
104857
104993
|
}
|
|
104858
104994
|
throw new CliUsageError(`laze vault: no ${file4} here or in a parent folder
|
|
104859
104995
|
${ENV_USAGE}`);
|
|
@@ -105226,7 +105362,7 @@ async function vaultScrub({ context, args }) {
|
|
|
105226
105362
|
|
|
105227
105363
|
// src/services/whatsapp-business-commands.service.ts
|
|
105228
105364
|
import { readFile as readFile36 } from "node:fs/promises";
|
|
105229
|
-
import { resolve as
|
|
105365
|
+
import { resolve as resolve25 } from "node:path";
|
|
105230
105366
|
|
|
105231
105367
|
// ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
|
|
105232
105368
|
var whatsappBusinessCategorySchema = external_exports.enum([
|
|
@@ -105722,7 +105858,7 @@ async function secretsOf3({ context, args }) {
|
|
|
105722
105858
|
const fromConnection = flagText({ args, name: "from-vault" });
|
|
105723
105859
|
if (fromConnection) return { fromConnection };
|
|
105724
105860
|
const file4 = flagText({ args, name: "from-file" });
|
|
105725
|
-
const text3 = file4 ? await readFile36(
|
|
105861
|
+
const text3 = file4 ? await readFile36(resolve25(context.cwd, file4), "utf8") : await context.readStdin();
|
|
105726
105862
|
const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
105727
105863
|
if (lines2.length !== 2) {
|
|
105728
105864
|
throw new CliUsageError(
|
|
@@ -105924,7 +106060,7 @@ async function whatsappBusiness({
|
|
|
105924
106060
|
|
|
105925
106061
|
// src/services/whatsapp-commands.service.ts
|
|
105926
106062
|
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
105927
|
-
import { basename as basename12, resolve as
|
|
106063
|
+
import { basename as basename12, resolve as resolve26 } from "node:path";
|
|
105928
106064
|
|
|
105929
106065
|
// src/services/whatsapp-pairing-commands.service.ts
|
|
105930
106066
|
var WHATSAPP_PAIRING_USAGE = " laze whatsapp unpair <machine> unlink WhatsApp from the machine (owner)";
|
|
@@ -106064,7 +106200,7 @@ async function file3({ context, args }) {
|
|
|
106064
106200
|
},
|
|
106065
106201
|
args
|
|
106066
106202
|
});
|
|
106067
|
-
const out =
|
|
106203
|
+
const out = resolve26(context.cwd, flagText({ args, name: "out" }) ?? basename12(answer6.fileName));
|
|
106068
106204
|
const response = await context.fetcher(answer6.url);
|
|
106069
106205
|
if (!response.ok) throw new Error(`The file link answered ${response.status}`);
|
|
106070
106206
|
await writeFile10(out, new Uint8Array(await response.arrayBuffer()));
|
|
@@ -106490,6 +106626,7 @@ var HELP = `laze: work in a Laze workspace from your terminal or your agent.
|
|
|
106490
106626
|
laze join [--workspace <name|link>] [--for <email>] [--name <name>] [--project <folder>] ask to join as an agent: a person approves once in their feed
|
|
106491
106627
|
laze agent link --token <token> [--name <name>] [--project <folder>] connect this Claude Code or Codex session
|
|
106492
106628
|
laze agent bind the linked agent listens in this session from now on
|
|
106629
|
+
laze agent sessions [--migrate] [--json] the sessions this machine binds to its agents
|
|
106493
106630
|
laze agent request [--name <name>] ask the agent's owner for a new Laze agent with this session
|
|
106494
106631
|
laze agent create --name <name> [--description <text>] [--harness laze-models|claude-code|codex] [--avatar <file>|--avatar-emoji <emoji>]
|
|
106495
106632
|
make an agent for your owner (or for you): personal, opened in their direct messages
|
|
@@ -106711,6 +106848,7 @@ var COMMANDS5 = {
|
|
|
106711
106848
|
"agent link": linkAgent,
|
|
106712
106849
|
"agent bind": bindAgentSession,
|
|
106713
106850
|
"agent request": requestAgent,
|
|
106851
|
+
"agent sessions": listAgentSessions,
|
|
106714
106852
|
"hook stop": stopHook,
|
|
106715
106853
|
"hook wait": waitHook,
|
|
106716
106854
|
"hook pre-tool": preToolHook,
|
|
@@ -106919,21 +107057,21 @@ function exitCodeOf({
|
|
|
106919
107057
|
// src/services/machine-key.service.ts
|
|
106920
107058
|
import { execFile as execFile2 } from "node:child_process";
|
|
106921
107059
|
import {
|
|
106922
|
-
createHash as
|
|
107060
|
+
createHash as createHash11,
|
|
106923
107061
|
createPrivateKey,
|
|
106924
107062
|
generateKeyPairSync,
|
|
106925
107063
|
randomBytes as randomBytes6,
|
|
106926
107064
|
sign
|
|
106927
107065
|
} from "node:crypto";
|
|
106928
107066
|
import { chmod, link, mkdir as mkdir13, readFile as readFile37, rm as rm21, writeFile as writeFile11 } from "node:fs/promises";
|
|
106929
|
-
import { dirname as
|
|
107067
|
+
import { dirname as dirname27, join as join37 } from "node:path";
|
|
106930
107068
|
var KEYCHAIN_SERVICE = "laze-cli-machine-key";
|
|
106931
|
-
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((
|
|
107069
|
+
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((resolve27, reject) => {
|
|
106932
107070
|
const child = execFile2(
|
|
106933
107071
|
program,
|
|
106934
107072
|
[...args],
|
|
106935
107073
|
{ timeout: timeoutMs },
|
|
106936
|
-
(error63, stdout2) => error63 ? reject(error63) :
|
|
107074
|
+
(error63, stdout2) => error63 ? reject(error63) : resolve27(String(stdout2))
|
|
106937
107075
|
);
|
|
106938
107076
|
if (stdin2 !== void 0) child.stdin?.end(stdin2);
|
|
106939
107077
|
});
|
|
@@ -106966,15 +107104,15 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
106966
107104
|
});
|
|
106967
107105
|
}
|
|
106968
107106
|
get metaPath() {
|
|
106969
|
-
return
|
|
107107
|
+
return join37(dirname27(this.options.configPath), "machine-key.json");
|
|
106970
107108
|
}
|
|
106971
107109
|
/** Named by the key, so two CLIs making a key at once never overwrite each other's. */
|
|
106972
107110
|
pemPathOf(jwk) {
|
|
106973
|
-
return
|
|
107111
|
+
return join37(dirname27(this.options.configPath), `machine-key-${shortOf(jwk)}.pem`);
|
|
106974
107112
|
}
|
|
106975
107113
|
/** The Keychain item's account: one per config file and key. */
|
|
106976
107114
|
accountOf(jwk) {
|
|
106977
|
-
const config2 =
|
|
107115
|
+
const config2 = createHash11("sha256").update(this.options.configPath).digest("hex");
|
|
106978
107116
|
return `${config2.slice(0, 32)}-${shortOf(jwk)}`;
|
|
106979
107117
|
}
|
|
106980
107118
|
/** The key if this machine made one; null otherwise. Read once per process. */
|
|
@@ -107097,7 +107235,7 @@ async function writeOnce({ path, text: text3 }) {
|
|
|
107097
107235
|
}
|
|
107098
107236
|
}
|
|
107099
107237
|
async function writePrivate({ path, text: text3 }) {
|
|
107100
|
-
await mkdir13(
|
|
107238
|
+
await mkdir13(dirname27(path), { recursive: true, mode: 448 });
|
|
107101
107239
|
await writeFile11(path, text3, { mode: 384 });
|
|
107102
107240
|
await chmod(path, 384);
|
|
107103
107241
|
}
|
|
@@ -107156,7 +107294,7 @@ function machineProofFetch({
|
|
|
107156
107294
|
import { execFile as execFile3, spawn as spawn4, spawnSync } from "node:child_process";
|
|
107157
107295
|
import { closeSync, mkdirSync, openSync, renameSync, statSync } from "node:fs";
|
|
107158
107296
|
import { readFile as readFile38, readlink } from "node:fs/promises";
|
|
107159
|
-
import { dirname as
|
|
107297
|
+
import { dirname as dirname28 } from "node:path";
|
|
107160
107298
|
import { promisify as promisify2 } from "node:util";
|
|
107161
107299
|
var run3 = promisify2(execFile3);
|
|
107162
107300
|
function alive(pid) {
|
|
@@ -107176,16 +107314,16 @@ async function argsOf2(pid) {
|
|
|
107176
107314
|
return line ? line.split(/\s+/) : void 0;
|
|
107177
107315
|
}
|
|
107178
107316
|
async function parentOf(pid) {
|
|
107179
|
-
const
|
|
107180
|
-
const fromStat =
|
|
107317
|
+
const stat13 = await readFile38(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
107318
|
+
const fromStat = stat13 ? Number(stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
|
|
107181
107319
|
if (fromStat > 0) return fromStat;
|
|
107182
107320
|
const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
|
|
107183
107321
|
const parent = Number(listed?.stdout.trim());
|
|
107184
107322
|
return parent > 0 ? parent : void 0;
|
|
107185
107323
|
}
|
|
107186
107324
|
async function startOf(pid) {
|
|
107187
|
-
const
|
|
107188
|
-
const ticks =
|
|
107325
|
+
const stat13 = await readFile38(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
107326
|
+
const ticks = stat13 ? stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[19] : void 0;
|
|
107189
107327
|
if (ticks) return ticks;
|
|
107190
107328
|
const listed = await run3("ps", ["-o", "lstart=", "-p", String(pid)]).catch(() => void 0);
|
|
107191
107329
|
return listed?.stdout.trim() || void 0;
|
|
@@ -107224,7 +107362,7 @@ function spawnDetached({
|
|
|
107224
107362
|
logPath,
|
|
107225
107363
|
orphan = false
|
|
107226
107364
|
}) {
|
|
107227
|
-
mkdirSync(
|
|
107365
|
+
mkdirSync(dirname28(logPath), { recursive: true, mode: 448 });
|
|
107228
107366
|
keepLogSmall({ logPath });
|
|
107229
107367
|
const log = openSync(logPath, "a", 384);
|
|
107230
107368
|
if (orphan) {
|
|
@@ -107319,7 +107457,7 @@ async function readStdin() {
|
|
|
107319
107457
|
function terminalAsk() {
|
|
107320
107458
|
if (!stdin.isTTY || !stdout.isTTY) return void 0;
|
|
107321
107459
|
return async (question) => {
|
|
107322
|
-
const terminal =
|
|
107460
|
+
const terminal = createInterface4({ input: stdin, output: stderr });
|
|
107323
107461
|
try {
|
|
107324
107462
|
return await terminal.question(question);
|
|
107325
107463
|
} finally {
|
|
@@ -107328,15 +107466,15 @@ function terminalAsk() {
|
|
|
107328
107466
|
};
|
|
107329
107467
|
}
|
|
107330
107468
|
function sleep(ms2, signal) {
|
|
107331
|
-
return new Promise((
|
|
107332
|
-
if (signal?.aborted) return
|
|
107469
|
+
return new Promise((resolve27) => {
|
|
107470
|
+
if (signal?.aborted) return resolve27();
|
|
107333
107471
|
const stop3 = () => {
|
|
107334
107472
|
clearTimeout(timer);
|
|
107335
|
-
|
|
107473
|
+
resolve27();
|
|
107336
107474
|
};
|
|
107337
107475
|
const timer = setTimeout(() => {
|
|
107338
107476
|
signal?.removeEventListener("abort", stop3);
|
|
107339
|
-
|
|
107477
|
+
resolve27();
|
|
107340
107478
|
}, ms2);
|
|
107341
107479
|
signal?.addEventListener("abort", stop3, { once: true });
|
|
107342
107480
|
});
|