wildcrane-runner 0.6.43 → 0.6.45
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/README.md +3 -3
- package/dist/akb/dist/kanban.mjs +675 -628
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/launcher.mjs +1538 -705
- package/dist/plugin.mjs +1911 -1078
- package/dist/runner.mjs +1798 -1664
- package/dist/settings.mjs +1576 -743
- package/package.json +1 -1
package/dist/launcher.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.45 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1146,14 +1146,14 @@ var require_util = __commonJS({
|
|
|
1146
1146
|
}
|
|
1147
1147
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
1148
1148
|
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
1149
|
-
let
|
|
1149
|
+
let path31 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
1150
1150
|
if (origin[origin.length - 1] === "/") {
|
|
1151
1151
|
origin = origin.slice(0, origin.length - 1);
|
|
1152
1152
|
}
|
|
1153
|
-
if (
|
|
1154
|
-
|
|
1153
|
+
if (path31 && path31[0] !== "/") {
|
|
1154
|
+
path31 = `/${path31}`;
|
|
1155
1155
|
}
|
|
1156
|
-
return new URL(`${origin}${
|
|
1156
|
+
return new URL(`${origin}${path31}`);
|
|
1157
1157
|
}
|
|
1158
1158
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
1159
1159
|
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -1988,9 +1988,9 @@ var require_diagnostics = __commonJS({
|
|
|
1988
1988
|
"undici:client:sendHeaders",
|
|
1989
1989
|
(evt) => {
|
|
1990
1990
|
const {
|
|
1991
|
-
request: { method, path:
|
|
1991
|
+
request: { method, path: path31, origin }
|
|
1992
1992
|
} = evt;
|
|
1993
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
1993
|
+
debugLog("sending request to %s %s%s", method, origin, path31);
|
|
1994
1994
|
}
|
|
1995
1995
|
);
|
|
1996
1996
|
}
|
|
@@ -2008,14 +2008,14 @@ var require_diagnostics = __commonJS({
|
|
|
2008
2008
|
"undici:request:headers",
|
|
2009
2009
|
(evt) => {
|
|
2010
2010
|
const {
|
|
2011
|
-
request: { method, path:
|
|
2011
|
+
request: { method, path: path31, origin },
|
|
2012
2012
|
response: { statusCode }
|
|
2013
2013
|
} = evt;
|
|
2014
2014
|
debugLog(
|
|
2015
2015
|
"received response to %s %s%s - HTTP %d",
|
|
2016
2016
|
method,
|
|
2017
2017
|
origin,
|
|
2018
|
-
|
|
2018
|
+
path31,
|
|
2019
2019
|
statusCode
|
|
2020
2020
|
);
|
|
2021
2021
|
}
|
|
@@ -2024,23 +2024,23 @@ var require_diagnostics = __commonJS({
|
|
|
2024
2024
|
"undici:request:trailers",
|
|
2025
2025
|
(evt) => {
|
|
2026
2026
|
const {
|
|
2027
|
-
request: { method, path:
|
|
2027
|
+
request: { method, path: path31, origin }
|
|
2028
2028
|
} = evt;
|
|
2029
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
2029
|
+
debugLog("trailers received from %s %s%s", method, origin, path31);
|
|
2030
2030
|
}
|
|
2031
2031
|
);
|
|
2032
2032
|
diagnosticsChannel.subscribe(
|
|
2033
2033
|
"undici:request:error",
|
|
2034
2034
|
(evt) => {
|
|
2035
2035
|
const {
|
|
2036
|
-
request: { method, path:
|
|
2036
|
+
request: { method, path: path31, origin },
|
|
2037
2037
|
error
|
|
2038
2038
|
} = evt;
|
|
2039
2039
|
debugLog(
|
|
2040
2040
|
"request to %s %s%s errored - %s",
|
|
2041
2041
|
method,
|
|
2042
2042
|
origin,
|
|
2043
|
-
|
|
2043
|
+
path31,
|
|
2044
2044
|
error.message
|
|
2045
2045
|
);
|
|
2046
2046
|
}
|
|
@@ -2155,7 +2155,7 @@ var require_request = __commonJS({
|
|
|
2155
2155
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
2156
2156
|
var Request = class {
|
|
2157
2157
|
constructor(origin, {
|
|
2158
|
-
path:
|
|
2158
|
+
path: path31,
|
|
2159
2159
|
method,
|
|
2160
2160
|
body,
|
|
2161
2161
|
headers,
|
|
@@ -2172,11 +2172,11 @@ var require_request = __commonJS({
|
|
|
2172
2172
|
maxRedirections,
|
|
2173
2173
|
typeOfService
|
|
2174
2174
|
}, handler) {
|
|
2175
|
-
if (typeof
|
|
2175
|
+
if (typeof path31 !== "string") {
|
|
2176
2176
|
throw new InvalidArgumentError("path must be a string");
|
|
2177
|
-
} else if (
|
|
2177
|
+
} else if (path31[0] !== "/" && !(path31.startsWith("http://") || path31.startsWith("https://")) && method !== "CONNECT") {
|
|
2178
2178
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
2179
|
-
} else if (invalidPathRegex.test(
|
|
2179
|
+
} else if (invalidPathRegex.test(path31)) {
|
|
2180
2180
|
throw new InvalidArgumentError("invalid request path");
|
|
2181
2181
|
}
|
|
2182
2182
|
if (typeof method !== "string") {
|
|
@@ -2251,7 +2251,7 @@ var require_request = __commonJS({
|
|
|
2251
2251
|
this.completed = false;
|
|
2252
2252
|
this.aborted = false;
|
|
2253
2253
|
this.upgrade = upgrade || null;
|
|
2254
|
-
this.path = query ? serializePathWithQuery(
|
|
2254
|
+
this.path = query ? serializePathWithQuery(path31, query) : path31;
|
|
2255
2255
|
this.origin = origin;
|
|
2256
2256
|
this.protocol = getProtocolFromUrlString(origin);
|
|
2257
2257
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -2443,11 +2443,11 @@ var require_request = __commonJS({
|
|
|
2443
2443
|
} else if (typeof val[i] === "object") {
|
|
2444
2444
|
throw new InvalidArgumentError(`invalid ${key} header`);
|
|
2445
2445
|
} else {
|
|
2446
|
-
const
|
|
2447
|
-
if (!isValidHeaderValue(
|
|
2446
|
+
const str4 = `${val[i]}`;
|
|
2447
|
+
if (!isValidHeaderValue(str4)) {
|
|
2448
2448
|
throw new InvalidArgumentError(`invalid ${key} header`);
|
|
2449
2449
|
}
|
|
2450
|
-
arr2.push(
|
|
2450
|
+
arr2.push(str4);
|
|
2451
2451
|
}
|
|
2452
2452
|
}
|
|
2453
2453
|
val = arr2;
|
|
@@ -3990,8 +3990,8 @@ var require_infra = __commonJS({
|
|
|
3990
3990
|
}
|
|
3991
3991
|
var ASCII_WHITESPACE_REPLACE_REGEX = /[\u0009\u000A\u000C\u000D\u0020]/g;
|
|
3992
3992
|
var nonASCIIRegex = /[^\x00-\x7F]/;
|
|
3993
|
-
function asciiLowercase(
|
|
3994
|
-
return nonASCIIRegex.test(
|
|
3993
|
+
function asciiLowercase(str4) {
|
|
3994
|
+
return nonASCIIRegex.test(str4) ? str4.replace(/[A-Z]+/g, (upper) => upper.toLowerCase()) : str4.toLowerCase();
|
|
3995
3995
|
}
|
|
3996
3996
|
function forgivingBase64(data) {
|
|
3997
3997
|
data = data.replace(ASCII_WHITESPACE_REPLACE_REGEX, "");
|
|
@@ -4041,22 +4041,22 @@ var require_infra = __commonJS({
|
|
|
4041
4041
|
assert(!invalidIsomorphicEncodeValueRegex.test(input));
|
|
4042
4042
|
return input;
|
|
4043
4043
|
}
|
|
4044
|
-
function parseJSONFromBytes(
|
|
4045
|
-
return JSON.parse(utf8DecodeBytes(
|
|
4044
|
+
function parseJSONFromBytes(bytes2) {
|
|
4045
|
+
return JSON.parse(utf8DecodeBytes(bytes2));
|
|
4046
4046
|
}
|
|
4047
|
-
function removeASCIIWhitespace(
|
|
4048
|
-
return removeChars(
|
|
4047
|
+
function removeASCIIWhitespace(str4, leading = true, trailing = true) {
|
|
4048
|
+
return removeChars(str4, leading, trailing, isASCIIWhitespace);
|
|
4049
4049
|
}
|
|
4050
|
-
function removeChars(
|
|
4050
|
+
function removeChars(str4, leading, trailing, predicate) {
|
|
4051
4051
|
let lead = 0;
|
|
4052
|
-
let trail =
|
|
4052
|
+
let trail = str4.length - 1;
|
|
4053
4053
|
if (leading) {
|
|
4054
|
-
while (lead <
|
|
4054
|
+
while (lead < str4.length && predicate(str4.charCodeAt(lead))) lead++;
|
|
4055
4055
|
}
|
|
4056
4056
|
if (trailing) {
|
|
4057
|
-
while (trail > 0 && predicate(
|
|
4057
|
+
while (trail > 0 && predicate(str4.charCodeAt(trail))) trail--;
|
|
4058
4058
|
}
|
|
4059
|
-
return lead === 0 && trail ===
|
|
4059
|
+
return lead === 0 && trail === str4.length - 1 ? str4 : str4.slice(lead, trail + 1);
|
|
4060
4060
|
}
|
|
4061
4061
|
function serializeJavascriptValueToJSONString(value) {
|
|
4062
4062
|
const result = JSON.stringify(value);
|
|
@@ -4142,8 +4142,8 @@ var require_data_url = __commonJS({
|
|
|
4142
4142
|
return serialized;
|
|
4143
4143
|
}
|
|
4144
4144
|
function stringPercentDecode(input) {
|
|
4145
|
-
const
|
|
4146
|
-
return percentDecode(
|
|
4145
|
+
const bytes2 = encoder.encode(input);
|
|
4146
|
+
return percentDecode(bytes2);
|
|
4147
4147
|
}
|
|
4148
4148
|
function isHexCharByte(byte) {
|
|
4149
4149
|
return byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102;
|
|
@@ -4308,8 +4308,8 @@ var require_data_url = __commonJS({
|
|
|
4308
4308
|
function isHTTPWhiteSpace(char) {
|
|
4309
4309
|
return char === 13 || char === 10 || char === 9 || char === 32;
|
|
4310
4310
|
}
|
|
4311
|
-
function removeHTTPWhitespace(
|
|
4312
|
-
return removeChars(
|
|
4311
|
+
function removeHTTPWhitespace(str4, leading = true, trailing = true) {
|
|
4312
|
+
return removeChars(str4, leading, trailing, isHTTPWhiteSpace);
|
|
4313
4313
|
}
|
|
4314
4314
|
function minimizeSupportedMimeType(mimeType) {
|
|
4315
4315
|
switch (mimeType.essence) {
|
|
@@ -4468,7 +4468,7 @@ var require_webidl = __commonJS({
|
|
|
4468
4468
|
"node_modules/undici/lib/web/webidl/index.js"(exports, module) {
|
|
4469
4469
|
"use strict";
|
|
4470
4470
|
var assert = __require("node:assert");
|
|
4471
|
-
var { types, inspect } = __require("node:util");
|
|
4471
|
+
var { types, inspect: inspect2 } = __require("node:util");
|
|
4472
4472
|
var { runtimeFeatures } = require_runtime_features();
|
|
4473
4473
|
var UNDEFINED = 1;
|
|
4474
4474
|
var BOOLEAN = 2;
|
|
@@ -4660,7 +4660,7 @@ var require_webidl = __commonJS({
|
|
|
4660
4660
|
case SYMBOL:
|
|
4661
4661
|
return `Symbol(${V.description})`;
|
|
4662
4662
|
case OBJECT:
|
|
4663
|
-
return
|
|
4663
|
+
return inspect2(V);
|
|
4664
4664
|
case STRING:
|
|
4665
4665
|
return `"${V}"`;
|
|
4666
4666
|
case BIGINT:
|
|
@@ -4829,10 +4829,10 @@ var require_webidl = __commonJS({
|
|
|
4829
4829
|
if (jsArrayBuffer.detached) {
|
|
4830
4830
|
return new Uint8Array(0);
|
|
4831
4831
|
}
|
|
4832
|
-
const
|
|
4832
|
+
const bytes2 = new Uint8Array(length);
|
|
4833
4833
|
const view = new Uint8Array(jsArrayBuffer, offset, length);
|
|
4834
|
-
|
|
4835
|
-
return
|
|
4834
|
+
bytes2.set(view);
|
|
4835
|
+
return bytes2;
|
|
4836
4836
|
};
|
|
4837
4837
|
webidl.converters.DOMString = function(V, prefix, argument, flags) {
|
|
4838
4838
|
if (V === null && webidl.util.HasFlag(flags, webidl.attributes.LegacyNullToEmptyString)) {
|
|
@@ -5548,19 +5548,19 @@ var require_util2 = __commonJS({
|
|
|
5548
5548
|
}
|
|
5549
5549
|
async function readAllBytes(reader, successSteps, failureSteps) {
|
|
5550
5550
|
try {
|
|
5551
|
-
const
|
|
5551
|
+
const bytes2 = [];
|
|
5552
5552
|
let byteLength = 0;
|
|
5553
5553
|
do {
|
|
5554
5554
|
const { done, value: chunk } = await reader.read();
|
|
5555
5555
|
if (done) {
|
|
5556
|
-
successSteps(Buffer.concat(
|
|
5556
|
+
successSteps(Buffer.concat(bytes2, byteLength));
|
|
5557
5557
|
return;
|
|
5558
5558
|
}
|
|
5559
5559
|
if (!isUint8Array(chunk)) {
|
|
5560
5560
|
failureSteps(new TypeError("Received non-Uint8Array chunk"));
|
|
5561
5561
|
return;
|
|
5562
5562
|
}
|
|
5563
|
-
|
|
5563
|
+
bytes2.push(chunk);
|
|
5564
5564
|
byteLength += chunk.length;
|
|
5565
5565
|
} while (true);
|
|
5566
5566
|
} catch (e) {
|
|
@@ -6430,7 +6430,7 @@ var require_body = __commonJS({
|
|
|
6430
6430
|
const boundary = `----formdata-undici-0${`${random2(1e11)}`.padStart(11, "0")}`;
|
|
6431
6431
|
const prefix = `--${boundary}\r
|
|
6432
6432
|
Content-Disposition: form-data`;
|
|
6433
|
-
const formdataEscape = (
|
|
6433
|
+
const formdataEscape = (str4) => str4.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
6434
6434
|
const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
|
|
6435
6435
|
const blobParts = [];
|
|
6436
6436
|
const rn = new Uint8Array([13, 10]);
|
|
@@ -6519,19 +6519,19 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
6519
6519
|
function bodyMixinMethods(instance, getInternalState) {
|
|
6520
6520
|
const methods = {
|
|
6521
6521
|
blob() {
|
|
6522
|
-
return consumeBody(this, (
|
|
6522
|
+
return consumeBody(this, (bytes2) => {
|
|
6523
6523
|
let mimeType = bodyMimeType(getInternalState(this));
|
|
6524
6524
|
if (mimeType === null) {
|
|
6525
6525
|
mimeType = "";
|
|
6526
6526
|
} else if (mimeType) {
|
|
6527
6527
|
mimeType = serializeAMimeType(mimeType);
|
|
6528
6528
|
}
|
|
6529
|
-
return new Blob([
|
|
6529
|
+
return new Blob([bytes2], { type: mimeType });
|
|
6530
6530
|
}, instance, getInternalState);
|
|
6531
6531
|
},
|
|
6532
6532
|
arrayBuffer() {
|
|
6533
|
-
return consumeBody(this, (
|
|
6534
|
-
return new Uint8Array(
|
|
6533
|
+
return consumeBody(this, (bytes2) => {
|
|
6534
|
+
return new Uint8Array(bytes2).buffer;
|
|
6535
6535
|
}, instance, getInternalState);
|
|
6536
6536
|
},
|
|
6537
6537
|
text() {
|
|
@@ -6567,8 +6567,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
6567
6567
|
}, instance, getInternalState);
|
|
6568
6568
|
},
|
|
6569
6569
|
bytes() {
|
|
6570
|
-
return consumeBody(this, (
|
|
6571
|
-
return new Uint8Array(
|
|
6570
|
+
return consumeBody(this, (bytes2) => {
|
|
6571
|
+
return new Uint8Array(bytes2);
|
|
6572
6572
|
}, instance, getInternalState);
|
|
6573
6573
|
}
|
|
6574
6574
|
};
|
|
@@ -7495,7 +7495,7 @@ var require_client_h1 = __commonJS({
|
|
|
7495
7495
|
}
|
|
7496
7496
|
}
|
|
7497
7497
|
function writeH1(client, request2) {
|
|
7498
|
-
const { method, path:
|
|
7498
|
+
const { method, path: path31, host, upgrade, blocking, reset } = request2;
|
|
7499
7499
|
let { body, headers, contentLength } = request2;
|
|
7500
7500
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
7501
7501
|
if (util.isFormDataLike(body)) {
|
|
@@ -7571,7 +7571,7 @@ var require_client_h1 = __commonJS({
|
|
|
7571
7571
|
socket[kBlocking] = true;
|
|
7572
7572
|
}
|
|
7573
7573
|
setTypeOfService(socket, request2);
|
|
7574
|
-
let header = `${method} ${
|
|
7574
|
+
let header = `${method} ${path31} HTTP/1.1\r
|
|
7575
7575
|
`;
|
|
7576
7576
|
if (typeof host === "string") {
|
|
7577
7577
|
header += `host: ${host}\r
|
|
@@ -8248,7 +8248,7 @@ var require_client_h2 = __commonJS({
|
|
|
8248
8248
|
const headersTimeout = request2.headersTimeout ?? client[kHeadersTimeout];
|
|
8249
8249
|
const bodyTimeout = request2.bodyTimeout ?? client[kBodyTimeout];
|
|
8250
8250
|
const session = client[kHTTP2Session];
|
|
8251
|
-
const { method, path:
|
|
8251
|
+
const { method, path: path31, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request2;
|
|
8252
8252
|
let { body } = request2;
|
|
8253
8253
|
if (upgrade != null && upgrade !== "websocket") {
|
|
8254
8254
|
util.errorRequest(client, request2, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -8317,7 +8317,7 @@ var require_client_h2 = __commonJS({
|
|
|
8317
8317
|
}
|
|
8318
8318
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
8319
8319
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
8320
|
-
headers[HTTP2_HEADER_PATH] =
|
|
8320
|
+
headers[HTTP2_HEADER_PATH] = path31;
|
|
8321
8321
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
8322
8322
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
8323
8323
|
} else {
|
|
@@ -8369,7 +8369,7 @@ var require_client_h2 = __commonJS({
|
|
|
8369
8369
|
stream.setTimeout(headersTimeout);
|
|
8370
8370
|
return true;
|
|
8371
8371
|
}
|
|
8372
|
-
headers[HTTP2_HEADER_PATH] =
|
|
8372
|
+
headers[HTTP2_HEADER_PATH] = path31;
|
|
8373
8373
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
8374
8374
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
8375
8375
|
if (body && typeof body.read === "function") {
|
|
@@ -10725,10 +10725,10 @@ var require_proxy_agent = __commonJS({
|
|
|
10725
10725
|
};
|
|
10726
10726
|
const {
|
|
10727
10727
|
origin,
|
|
10728
|
-
path:
|
|
10728
|
+
path: path31 = "/",
|
|
10729
10729
|
headers = {}
|
|
10730
10730
|
} = opts;
|
|
10731
|
-
opts.path = origin +
|
|
10731
|
+
opts.path = origin + path31;
|
|
10732
10732
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
10733
10733
|
const { host } = new URL(origin);
|
|
10734
10734
|
headers.host = host;
|
|
@@ -12888,20 +12888,20 @@ var require_mock_utils = __commonJS({
|
|
|
12888
12888
|
}
|
|
12889
12889
|
return normalizedQp;
|
|
12890
12890
|
}
|
|
12891
|
-
function safeUrl(
|
|
12892
|
-
if (typeof
|
|
12893
|
-
return
|
|
12891
|
+
function safeUrl(path31) {
|
|
12892
|
+
if (typeof path31 !== "string") {
|
|
12893
|
+
return path31;
|
|
12894
12894
|
}
|
|
12895
|
-
const pathSegments =
|
|
12895
|
+
const pathSegments = path31.split("?", 3);
|
|
12896
12896
|
if (pathSegments.length !== 2) {
|
|
12897
|
-
return
|
|
12897
|
+
return path31;
|
|
12898
12898
|
}
|
|
12899
12899
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
12900
12900
|
qp.sort();
|
|
12901
12901
|
return [...pathSegments, qp.toString()].join("?");
|
|
12902
12902
|
}
|
|
12903
|
-
function matchKey(mockDispatch2, { path:
|
|
12904
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
12903
|
+
function matchKey(mockDispatch2, { path: path31, method, body, headers }) {
|
|
12904
|
+
const pathMatch = matchValue(mockDispatch2.path, path31);
|
|
12905
12905
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
12906
12906
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
12907
12907
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -12926,8 +12926,8 @@ var require_mock_utils = __commonJS({
|
|
|
12926
12926
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
12927
12927
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
12928
12928
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
12929
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
12930
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
12929
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path31, ignoreTrailingSlash }) => {
|
|
12930
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path31)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path31), resolvedPath);
|
|
12931
12931
|
});
|
|
12932
12932
|
if (matchedMockDispatches.length === 0) {
|
|
12933
12933
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -12966,19 +12966,19 @@ var require_mock_utils = __commonJS({
|
|
|
12966
12966
|
mockDispatches.splice(index, 1);
|
|
12967
12967
|
}
|
|
12968
12968
|
}
|
|
12969
|
-
function removeTrailingSlash(
|
|
12970
|
-
while (
|
|
12971
|
-
|
|
12969
|
+
function removeTrailingSlash(path31) {
|
|
12970
|
+
while (path31.endsWith("/")) {
|
|
12971
|
+
path31 = path31.slice(0, -1);
|
|
12972
12972
|
}
|
|
12973
|
-
if (
|
|
12974
|
-
|
|
12973
|
+
if (path31.length === 0) {
|
|
12974
|
+
path31 = "/";
|
|
12975
12975
|
}
|
|
12976
|
-
return
|
|
12976
|
+
return path31;
|
|
12977
12977
|
}
|
|
12978
12978
|
function buildKey(opts) {
|
|
12979
|
-
const { path:
|
|
12979
|
+
const { path: path31, method, body, headers, query } = opts;
|
|
12980
12980
|
return {
|
|
12981
|
-
path:
|
|
12981
|
+
path: path31,
|
|
12982
12982
|
method,
|
|
12983
12983
|
body,
|
|
12984
12984
|
headers,
|
|
@@ -13668,10 +13668,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
13668
13668
|
}
|
|
13669
13669
|
format(pendingInterceptors) {
|
|
13670
13670
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
13671
|
-
({ method, path:
|
|
13671
|
+
({ method, path: path31, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
13672
13672
|
Method: method,
|
|
13673
13673
|
Origin: origin,
|
|
13674
|
-
Path:
|
|
13674
|
+
Path: path31,
|
|
13675
13675
|
"Status code": statusCode,
|
|
13676
13676
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
13677
13677
|
Invocations: timesInvoked,
|
|
@@ -13753,9 +13753,9 @@ var require_mock_agent = __commonJS({
|
|
|
13753
13753
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
13754
13754
|
const dispatchOpts = { ...opts };
|
|
13755
13755
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
13756
|
-
const [
|
|
13756
|
+
const [path31, searchParams] = dispatchOpts.path.split("?");
|
|
13757
13757
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
13758
|
-
dispatchOpts.path = `${
|
|
13758
|
+
dispatchOpts.path = `${path31}?${normalizedSearchParams}`;
|
|
13759
13759
|
}
|
|
13760
13760
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
13761
13761
|
}
|
|
@@ -13883,8 +13883,8 @@ var require_snapshot_utils = __commonJS({
|
|
|
13883
13883
|
match: new Set(matchHeaders.map((header) => caseSensitive ? header : header.toLowerCase()))
|
|
13884
13884
|
};
|
|
13885
13885
|
}
|
|
13886
|
-
var
|
|
13887
|
-
var hashId =
|
|
13886
|
+
var crypto10 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
|
|
13887
|
+
var hashId = crypto10?.hash ? (value) => crypto10.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
|
|
13888
13888
|
function isUndiciHeaders(headers) {
|
|
13889
13889
|
return Array.isArray(headers) && (headers.length & 1) === 0;
|
|
13890
13890
|
}
|
|
@@ -14156,12 +14156,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14156
14156
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
14157
14157
|
*/
|
|
14158
14158
|
async loadSnapshots(filePath) {
|
|
14159
|
-
const
|
|
14160
|
-
if (!
|
|
14159
|
+
const path31 = filePath || this.#snapshotPath;
|
|
14160
|
+
if (!path31) {
|
|
14161
14161
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
14162
14162
|
}
|
|
14163
14163
|
try {
|
|
14164
|
-
const data = await readFile(resolve2(
|
|
14164
|
+
const data = await readFile(resolve2(path31), "utf8");
|
|
14165
14165
|
const parsed = JSON.parse(data);
|
|
14166
14166
|
if (Array.isArray(parsed)) {
|
|
14167
14167
|
this.#snapshots.clear();
|
|
@@ -14175,7 +14175,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14175
14175
|
if (error.code === "ENOENT") {
|
|
14176
14176
|
this.#snapshots.clear();
|
|
14177
14177
|
} else {
|
|
14178
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
14178
|
+
throw new UndiciError(`Failed to load snapshots from ${path31}`, { cause: error });
|
|
14179
14179
|
}
|
|
14180
14180
|
}
|
|
14181
14181
|
}
|
|
@@ -14186,11 +14186,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14186
14186
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
14187
14187
|
*/
|
|
14188
14188
|
async saveSnapshots(filePath) {
|
|
14189
|
-
const
|
|
14190
|
-
if (!
|
|
14189
|
+
const path31 = filePath || this.#snapshotPath;
|
|
14190
|
+
if (!path31) {
|
|
14191
14191
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
14192
14192
|
}
|
|
14193
|
-
const resolvedPath = resolve2(
|
|
14193
|
+
const resolvedPath = resolve2(path31);
|
|
14194
14194
|
await mkdir(dirname(resolvedPath), { recursive: true });
|
|
14195
14195
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
14196
14196
|
hash,
|
|
@@ -14831,15 +14831,15 @@ var require_redirect_handler = __commonJS({
|
|
|
14831
14831
|
receivedAt: Date.now()
|
|
14832
14832
|
});
|
|
14833
14833
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
14834
|
-
const
|
|
14835
|
-
const redirectUrlString = `${origin}${
|
|
14834
|
+
const path31 = search ? `${pathname}${search}` : pathname;
|
|
14835
|
+
const redirectUrlString = `${origin}${path31}`;
|
|
14836
14836
|
for (const historyUrl of this.history) {
|
|
14837
14837
|
if (historyUrl.toString() === redirectUrlString) {
|
|
14838
14838
|
throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
14839
14839
|
}
|
|
14840
14840
|
}
|
|
14841
14841
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
14842
|
-
this.opts.path =
|
|
14842
|
+
this.opts.path = path31;
|
|
14843
14843
|
this.opts.origin = origin;
|
|
14844
14844
|
this.opts.query = null;
|
|
14845
14845
|
}
|
|
@@ -16656,10 +16656,10 @@ var require_cache_handler = __commonJS({
|
|
|
16656
16656
|
}
|
|
16657
16657
|
return locationUrl.pathname + locationUrl.search;
|
|
16658
16658
|
}
|
|
16659
|
-
function deleteCachedUri(store, cacheKey,
|
|
16659
|
+
function deleteCachedUri(store, cacheKey, path31) {
|
|
16660
16660
|
deleteCachedValue(store, {
|
|
16661
16661
|
...cacheKey,
|
|
16662
|
-
path:
|
|
16662
|
+
path: path31
|
|
16663
16663
|
});
|
|
16664
16664
|
for (let i = 0; i < util.safeHTTPMethods.length; i++) {
|
|
16665
16665
|
const method = util.safeHTTPMethods[i];
|
|
@@ -16667,7 +16667,7 @@ var require_cache_handler = __commonJS({
|
|
|
16667
16667
|
deleteCachedValue(store, {
|
|
16668
16668
|
...cacheKey,
|
|
16669
16669
|
method,
|
|
16670
|
-
path:
|
|
16670
|
+
path: path31
|
|
16671
16671
|
});
|
|
16672
16672
|
}
|
|
16673
16673
|
}
|
|
@@ -16678,9 +16678,9 @@ var require_cache_handler = __commonJS({
|
|
|
16678
16678
|
}
|
|
16679
16679
|
const values = Array.isArray(headerValue) ? headerValue : [headerValue];
|
|
16680
16680
|
for (let i = 0; i < values.length; i++) {
|
|
16681
|
-
const
|
|
16682
|
-
if (
|
|
16683
|
-
deleteCachedUri(store, cacheKey,
|
|
16681
|
+
const path31 = getSameOriginPath(cacheKey, values[i]);
|
|
16682
|
+
if (path31 !== void 0) {
|
|
16683
|
+
deleteCachedUri(store, cacheKey, path31);
|
|
16684
16684
|
}
|
|
16685
16685
|
}
|
|
16686
16686
|
}
|
|
@@ -19513,13 +19513,13 @@ var require_headers = __commonJS({
|
|
|
19513
19513
|
return headersList.sortedMap;
|
|
19514
19514
|
}
|
|
19515
19515
|
const headers = [];
|
|
19516
|
-
const
|
|
19516
|
+
const names2 = headersList.toSortedArray();
|
|
19517
19517
|
const cookies = headersList.cookies;
|
|
19518
19518
|
if (cookies === null || cookies.length === 1) {
|
|
19519
|
-
return headersList.sortedMap =
|
|
19519
|
+
return headersList.sortedMap = names2;
|
|
19520
19520
|
}
|
|
19521
|
-
for (let i = 0; i <
|
|
19522
|
-
const { 0: name, 1: value } =
|
|
19521
|
+
for (let i = 0; i < names2.length; ++i) {
|
|
19522
|
+
const { 0: name, 1: value } = names2[i];
|
|
19523
19523
|
if (name === "set-cookie") {
|
|
19524
19524
|
for (let j = 0; j < cookies.length; ++j) {
|
|
19525
19525
|
headers.push([name, cookies[j]]);
|
|
@@ -19937,10 +19937,10 @@ var require_response = __commonJS({
|
|
|
19937
19937
|
if (init !== null) {
|
|
19938
19938
|
init = webidl.converters.ResponseInit(init);
|
|
19939
19939
|
}
|
|
19940
|
-
const
|
|
19940
|
+
const bytes2 = textEncoder.encode(
|
|
19941
19941
|
serializeJavascriptValueToJSONString(data)
|
|
19942
19942
|
);
|
|
19943
|
-
const body = extractBody(
|
|
19943
|
+
const body = extractBody(bytes2);
|
|
19944
19944
|
const responseObject = fromInnerResponse(makeResponse({}), "response");
|
|
19945
19945
|
initializeResponse(responseObject, init, { body: body[0], type: "application/json" });
|
|
19946
19946
|
return responseObject;
|
|
@@ -21082,10 +21082,10 @@ var require_subresource_integrity = __commonJS({
|
|
|
21082
21082
|
var { runtimeFeatures } = require_runtime_features();
|
|
21083
21083
|
var { asciiLowercase } = require_infra();
|
|
21084
21084
|
var validSRIHashAlgorithmTokenSet = /* @__PURE__ */ new Map([["sha256", 0], ["sha384", 1], ["sha512", 2]]);
|
|
21085
|
-
var
|
|
21085
|
+
var crypto10;
|
|
21086
21086
|
if (runtimeFeatures.has("crypto")) {
|
|
21087
|
-
|
|
21088
|
-
const cryptoHashes =
|
|
21087
|
+
crypto10 = __require("node:crypto");
|
|
21088
|
+
const cryptoHashes = crypto10.getHashes();
|
|
21089
21089
|
if (cryptoHashes.length === 0) {
|
|
21090
21090
|
validSRIHashAlgorithmTokenSet.clear();
|
|
21091
21091
|
}
|
|
@@ -21104,7 +21104,7 @@ var require_subresource_integrity = __commonJS({
|
|
|
21104
21104
|
)
|
|
21105
21105
|
);
|
|
21106
21106
|
var isValidSRIHashAlgorithm = (algorithm) => validSRIHashAlgorithmTokenSet.has(asciiLowercase(algorithm));
|
|
21107
|
-
var bytesMatch = runtimeFeatures.has("crypto") === false || validSRIHashAlgorithmTokenSet.size === 0 ? () => true : (
|
|
21107
|
+
var bytesMatch = runtimeFeatures.has("crypto") === false || validSRIHashAlgorithmTokenSet.size === 0 ? () => true : (bytes2, metadataList) => {
|
|
21108
21108
|
const parsedMetadata = parseMetadata(metadataList);
|
|
21109
21109
|
if (parsedMetadata.length === 0) {
|
|
21110
21110
|
return true;
|
|
@@ -21113,7 +21113,7 @@ var require_subresource_integrity = __commonJS({
|
|
|
21113
21113
|
for (const item of metadata) {
|
|
21114
21114
|
const algorithm = item.alg;
|
|
21115
21115
|
const expectedValue = item.val;
|
|
21116
|
-
const actualValue = applyAlgorithmToBytes(algorithm,
|
|
21116
|
+
const actualValue = applyAlgorithmToBytes(algorithm, bytes2);
|
|
21117
21117
|
if (caseSensitiveMatch(actualValue, expectedValue)) {
|
|
21118
21118
|
return true;
|
|
21119
21119
|
}
|
|
@@ -21172,8 +21172,8 @@ var require_subresource_integrity = __commonJS({
|
|
|
21172
21172
|
}
|
|
21173
21173
|
return result;
|
|
21174
21174
|
}
|
|
21175
|
-
var applyAlgorithmToBytes = (algorithm,
|
|
21176
|
-
return
|
|
21175
|
+
var applyAlgorithmToBytes = (algorithm, bytes2) => {
|
|
21176
|
+
return crypto10.hash(algorithm, bytes2, "base64");
|
|
21177
21177
|
};
|
|
21178
21178
|
function caseSensitiveMatch(actualValue, expectedValue) {
|
|
21179
21179
|
let actualValueLength = actualValue.length;
|
|
@@ -21584,12 +21584,12 @@ var require_fetch = __commonJS({
|
|
|
21584
21584
|
processBodyError(response.error);
|
|
21585
21585
|
return;
|
|
21586
21586
|
}
|
|
21587
|
-
const processBody = (
|
|
21588
|
-
if (!bytesMatch(
|
|
21587
|
+
const processBody = (bytes2) => {
|
|
21588
|
+
if (!bytesMatch(bytes2, request2.integrity)) {
|
|
21589
21589
|
processBodyError("integrity mismatch");
|
|
21590
21590
|
return;
|
|
21591
21591
|
}
|
|
21592
|
-
response.body = safelyExtractBody(
|
|
21592
|
+
response.body = safelyExtractBody(bytes2)[0];
|
|
21593
21593
|
fetchFinale(fetchParams, response);
|
|
21594
21594
|
};
|
|
21595
21595
|
fullyReadBody(response.body, processBody, processBodyError);
|
|
@@ -22032,12 +22032,12 @@ var require_fetch = __commonJS({
|
|
|
22032
22032
|
if (request2.body == null && fetchParams.processRequestEndOfBody) {
|
|
22033
22033
|
queueMicrotask(() => fetchParams.processRequestEndOfBody());
|
|
22034
22034
|
} else if (request2.body != null) {
|
|
22035
|
-
const processBodyChunk = async function* (
|
|
22035
|
+
const processBodyChunk = async function* (bytes2) {
|
|
22036
22036
|
if (isCancelled(fetchParams)) {
|
|
22037
22037
|
return;
|
|
22038
22038
|
}
|
|
22039
|
-
yield
|
|
22040
|
-
fetchParams.processRequestBodyChunkLength?.(
|
|
22039
|
+
yield bytes2;
|
|
22040
|
+
fetchParams.processRequestBodyChunkLength?.(bytes2.byteLength);
|
|
22041
22041
|
};
|
|
22042
22042
|
const processEndOfBody = () => {
|
|
22043
22043
|
if (isCancelled(fetchParams)) {
|
|
@@ -22059,8 +22059,8 @@ var require_fetch = __commonJS({
|
|
|
22059
22059
|
};
|
|
22060
22060
|
requestBody = (async function* () {
|
|
22061
22061
|
try {
|
|
22062
|
-
for await (const
|
|
22063
|
-
yield* processBodyChunk(
|
|
22062
|
+
for await (const bytes2 of request2.body.stream) {
|
|
22063
|
+
yield* processBodyChunk(bytes2);
|
|
22064
22064
|
}
|
|
22065
22065
|
processEndOfBody();
|
|
22066
22066
|
} catch (err) {
|
|
@@ -22108,33 +22108,33 @@ var require_fetch = __commonJS({
|
|
|
22108
22108
|
}
|
|
22109
22109
|
fetchParams.controller.resume = async () => {
|
|
22110
22110
|
while (true) {
|
|
22111
|
-
let
|
|
22111
|
+
let bytes2;
|
|
22112
22112
|
let isFailure;
|
|
22113
22113
|
try {
|
|
22114
22114
|
const { done, value } = await fetchParams.controller.next();
|
|
22115
22115
|
if (isAborted(fetchParams)) {
|
|
22116
22116
|
break;
|
|
22117
22117
|
}
|
|
22118
|
-
|
|
22118
|
+
bytes2 = done ? void 0 : value;
|
|
22119
22119
|
} catch (err) {
|
|
22120
22120
|
if (fetchParams.controller.ended && !timingInfo.encodedBodySize) {
|
|
22121
|
-
|
|
22121
|
+
bytes2 = void 0;
|
|
22122
22122
|
} else {
|
|
22123
|
-
|
|
22123
|
+
bytes2 = err;
|
|
22124
22124
|
isFailure = true;
|
|
22125
22125
|
}
|
|
22126
22126
|
}
|
|
22127
|
-
if (
|
|
22127
|
+
if (bytes2 === void 0) {
|
|
22128
22128
|
readableStreamClose(fetchParams.controller.controller);
|
|
22129
22129
|
finalizeResponse(fetchParams, response);
|
|
22130
22130
|
return;
|
|
22131
22131
|
}
|
|
22132
|
-
timingInfo.decodedBodySize +=
|
|
22132
|
+
timingInfo.decodedBodySize += bytes2?.byteLength ?? 0;
|
|
22133
22133
|
if (isFailure) {
|
|
22134
|
-
fetchParams.controller.terminate(
|
|
22134
|
+
fetchParams.controller.terminate(bytes2);
|
|
22135
22135
|
return;
|
|
22136
22136
|
}
|
|
22137
|
-
const buffer = new Uint8Array(
|
|
22137
|
+
const buffer = new Uint8Array(bytes2);
|
|
22138
22138
|
if (buffer.byteLength) {
|
|
22139
22139
|
fetchParams.controller.controller.enqueue(buffer);
|
|
22140
22140
|
}
|
|
@@ -22168,11 +22168,11 @@ var require_fetch = __commonJS({
|
|
|
22168
22168
|
function dispatch({ body }) {
|
|
22169
22169
|
const url = requestCurrentURL(request2);
|
|
22170
22170
|
const agent = fetchParams.controller.dispatcher;
|
|
22171
|
-
const
|
|
22171
|
+
const path31 = url.pathname + url.search;
|
|
22172
22172
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
22173
22173
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
22174
22174
|
{
|
|
22175
|
-
path: hasTrailingQuestionMark ? `${
|
|
22175
|
+
path: hasTrailingQuestionMark ? `${path31}?` : path31,
|
|
22176
22176
|
origin: url.origin,
|
|
22177
22177
|
method: request2.method,
|
|
22178
22178
|
body: agent.isMockActive ? request2.body && (request2.body.source || request2.body.stream) : body,
|
|
@@ -22274,9 +22274,9 @@ var require_fetch = __commonJS({
|
|
|
22274
22274
|
if (fetchParams.controller.dump) {
|
|
22275
22275
|
return;
|
|
22276
22276
|
}
|
|
22277
|
-
const
|
|
22278
|
-
timingInfo.encodedBodySize +=
|
|
22279
|
-
return this.body.push(
|
|
22277
|
+
const bytes2 = chunk;
|
|
22278
|
+
timingInfo.encodedBodySize += bytes2.byteLength;
|
|
22279
|
+
return this.body.push(bytes2);
|
|
22280
22280
|
},
|
|
22281
22281
|
onComplete() {
|
|
22282
22282
|
if (this.abort) {
|
|
@@ -22607,9 +22607,9 @@ var require_cache3 = __commonJS({
|
|
|
22607
22607
|
// 16.
|
|
22608
22608
|
};
|
|
22609
22609
|
operations.push(operation);
|
|
22610
|
-
const
|
|
22610
|
+
const bytes2 = await bodyReadPromise.promise;
|
|
22611
22611
|
if (clonedResponse.body != null) {
|
|
22612
|
-
clonedResponse.body.source =
|
|
22612
|
+
clonedResponse.body.source = bytes2;
|
|
22613
22613
|
}
|
|
22614
22614
|
const cacheJobPromise = createDeferredPromise();
|
|
22615
22615
|
let errorData = null;
|
|
@@ -23119,9 +23119,9 @@ var require_util4 = __commonJS({
|
|
|
23119
23119
|
}
|
|
23120
23120
|
}
|
|
23121
23121
|
}
|
|
23122
|
-
function validateCookiePath(
|
|
23123
|
-
for (let i = 0; i <
|
|
23124
|
-
const code =
|
|
23122
|
+
function validateCookiePath(path31) {
|
|
23123
|
+
for (let i = 0; i < path31.length; ++i) {
|
|
23124
|
+
const code = path31.charCodeAt(i);
|
|
23125
23125
|
if (code < 32 || // exclude CTLs (0-31)
|
|
23126
23126
|
code > 126 || // exclude DEL and non-ascii
|
|
23127
23127
|
code === 59) {
|
|
@@ -23460,9 +23460,9 @@ var require_cookies = __commonJS({
|
|
|
23460
23460
|
webidl.argumentLengthCheck(arguments, 2, "setCookie");
|
|
23461
23461
|
brandChecks(headers);
|
|
23462
23462
|
cookie = webidl.converters.Cookie(cookie);
|
|
23463
|
-
const
|
|
23464
|
-
if (
|
|
23465
|
-
headers.append("set-cookie",
|
|
23463
|
+
const str4 = stringify(cookie);
|
|
23464
|
+
if (str4) {
|
|
23465
|
+
headers.append("set-cookie", str4, true);
|
|
23466
23466
|
}
|
|
23467
23467
|
}
|
|
23468
23468
|
webidl.converters.DeleteCookieAttributes = webidl.dictionaryConverter([
|
|
@@ -24161,7 +24161,7 @@ var require_connection = __commonJS({
|
|
|
24161
24161
|
var { WebsocketFrameSend } = require_frame();
|
|
24162
24162
|
var assert = __require("node:assert");
|
|
24163
24163
|
var { runtimeFeatures } = require_runtime_features();
|
|
24164
|
-
var
|
|
24164
|
+
var crypto10 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
|
|
24165
24165
|
var warningEmitted = false;
|
|
24166
24166
|
function establishWebSocketConnection(url, protocols, client, handler, options) {
|
|
24167
24167
|
const requestURL = url;
|
|
@@ -24181,7 +24181,7 @@ var require_connection = __commonJS({
|
|
|
24181
24181
|
const headersList = getHeadersList(new Headers(options.headers));
|
|
24182
24182
|
request2.headersList = headersList;
|
|
24183
24183
|
}
|
|
24184
|
-
const keyValue =
|
|
24184
|
+
const keyValue = crypto10.randomBytes(16).toString("base64");
|
|
24185
24185
|
request2.headersList.append("sec-websocket-key", keyValue, true);
|
|
24186
24186
|
request2.headersList.append("sec-websocket-version", "13", true);
|
|
24187
24187
|
for (const protocol of protocols) {
|
|
@@ -24221,7 +24221,7 @@ var require_connection = __commonJS({
|
|
|
24221
24221
|
return;
|
|
24222
24222
|
}
|
|
24223
24223
|
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
24224
|
-
const digest =
|
|
24224
|
+
const digest = crypto10.hash("sha1", keyValue + uid, "base64");
|
|
24225
24225
|
if (secWSAccept !== digest) {
|
|
24226
24226
|
failHandshake(handler, response, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
24227
24227
|
return;
|
|
@@ -26557,11 +26557,11 @@ var require_undici = __commonJS({
|
|
|
26557
26557
|
if (typeof opts.path !== "string") {
|
|
26558
26558
|
throw new InvalidArgumentError("invalid opts.path");
|
|
26559
26559
|
}
|
|
26560
|
-
let
|
|
26560
|
+
let path31 = opts.path;
|
|
26561
26561
|
if (!opts.path.startsWith("/")) {
|
|
26562
|
-
|
|
26562
|
+
path31 = `/${path31}`;
|
|
26563
26563
|
}
|
|
26564
|
-
url = new URL(util.parseOrigin(url).origin +
|
|
26564
|
+
url = new URL(util.parseOrigin(url).origin + path31);
|
|
26565
26565
|
} else {
|
|
26566
26566
|
if (!opts) {
|
|
26567
26567
|
opts = typeof url === "object" ? url : {};
|
|
@@ -26671,8 +26671,8 @@ ${captureLines}` : capture.stack;
|
|
|
26671
26671
|
});
|
|
26672
26672
|
|
|
26673
26673
|
// src/launcher-main.ts
|
|
26674
|
-
import
|
|
26675
|
-
import { fileURLToPath as
|
|
26674
|
+
import path30 from "node:path";
|
|
26675
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
26676
26676
|
|
|
26677
26677
|
// src/home.ts
|
|
26678
26678
|
import crypto from "node:crypto";
|
|
@@ -26889,8 +26889,8 @@ function saveAlphaUpdates(value) {
|
|
|
26889
26889
|
}
|
|
26890
26890
|
|
|
26891
26891
|
// src/protocol.ts
|
|
26892
|
-
var VERSION = true ? "0.6.
|
|
26893
|
-
var AKB_VERSION = true ? "0.11.
|
|
26892
|
+
var VERSION = true ? "0.6.45" : "0.0.0";
|
|
26893
|
+
var AKB_VERSION = true ? "0.11.39" : "0.0.0";
|
|
26894
26894
|
var EXIT_REFUSED = 10;
|
|
26895
26895
|
var EXIT_OUTDATED = 11;
|
|
26896
26896
|
var EXIT_UPDATE = 12;
|
|
@@ -27295,10 +27295,10 @@ async function refresh() {
|
|
|
27295
27295
|
const now = readSession();
|
|
27296
27296
|
if (!now) return { ok: false, reason: "signed-out" };
|
|
27297
27297
|
if (!expiringSoon(now)) return { ok: true, token: now.accessToken, session: now };
|
|
27298
|
-
const {
|
|
27298
|
+
const { api, anonKey } = cloudEndpoints();
|
|
27299
27299
|
let response;
|
|
27300
27300
|
try {
|
|
27301
|
-
response = await fetch(`${
|
|
27301
|
+
response = await fetch(`${api}/auth/v1/token?grant_type=refresh_token`, {
|
|
27302
27302
|
method: "POST",
|
|
27303
27303
|
headers: { apikey: anonKey, "content-type": "application/json" },
|
|
27304
27304
|
body: JSON.stringify({ refresh_token: now.refreshToken })
|
|
@@ -27601,7 +27601,7 @@ async function startSettingsServer(action, port = 0) {
|
|
|
27601
27601
|
} catch {
|
|
27602
27602
|
}
|
|
27603
27603
|
const keep2 = () => {
|
|
27604
|
-
for (const
|
|
27604
|
+
for (const map2 of [tickets, sessions]) for (const [key, value] of map2) if (value.until < Date.now()) map2.delete(key);
|
|
27605
27605
|
const tmp2 = `${sessionsFile()}.${process.pid}.tmp`;
|
|
27606
27606
|
fs6.writeFileSync(tmp2, JSON.stringify({ tickets: [...tickets], sessions: [...sessions] }), { mode: 384 });
|
|
27607
27607
|
fs6.renameSync(tmp2, sessionsFile());
|
|
@@ -27683,9 +27683,9 @@ async function startSettingsServer(action, port = 0) {
|
|
|
27683
27683
|
}
|
|
27684
27684
|
|
|
27685
27685
|
// src/settings.ts
|
|
27686
|
-
import
|
|
27687
|
-
import
|
|
27688
|
-
import
|
|
27686
|
+
import crypto9 from "node:crypto";
|
|
27687
|
+
import fs25 from "node:fs";
|
|
27688
|
+
import path29 from "node:path";
|
|
27689
27689
|
|
|
27690
27690
|
// src/api.ts
|
|
27691
27691
|
var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok"];
|
|
@@ -27731,7 +27731,7 @@ var FILE_TIMEOUT_MS = 10 * 6e4;
|
|
|
27731
27731
|
var readRunner = () => request("GET", "/v1/runner");
|
|
27732
27732
|
var q = encodeURIComponent;
|
|
27733
27733
|
var listFolders = (machineId2) => request("GET", `/v1/runner/folders?machine=${q(machineId2)}`);
|
|
27734
|
-
var addFolder = (machineId2, name,
|
|
27734
|
+
var addFolder = (machineId2, name, path31, project) => request("POST", "/v1/runner/folders", { machineId: machineId2, name, path: path31, ...project ? { project } : {} });
|
|
27735
27735
|
async function createProject(name, workspace, key) {
|
|
27736
27736
|
const sent = await send("POST", "/v1/projects", { name, workspace }, true, TIMEOUT_MS2, void 0, { "idempotency-key": key });
|
|
27737
27737
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
@@ -27739,13 +27739,708 @@ async function createProject(name, workspace, key) {
|
|
|
27739
27739
|
var removeFolder = (machineId2, project) => request("POST", `/v1/runner/folders/${q(project)}/remove`, { machineId: machineId2 });
|
|
27740
27740
|
|
|
27741
27741
|
// src/cache.ts
|
|
27742
|
+
import crypto6 from "node:crypto";
|
|
27743
|
+
import fs14 from "node:fs";
|
|
27744
|
+
import path16 from "node:path";
|
|
27745
|
+
|
|
27746
|
+
// ../cli/src/lib/agent/cloud-studios.ts
|
|
27747
|
+
import fs12 from "node:fs";
|
|
27748
|
+
import path14 from "node:path";
|
|
27749
|
+
|
|
27750
|
+
// ../cli/src/lib/shared/board-files.ts
|
|
27751
|
+
var BOARD_FILE_LIMIT = 256 * 1024;
|
|
27752
|
+
var studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
27753
|
+
var studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
|
|
27754
|
+
|
|
27755
|
+
// ../official/pack.ts
|
|
27742
27756
|
import crypto5 from "node:crypto";
|
|
27757
|
+
import fs8 from "node:fs";
|
|
27758
|
+
import path9 from "node:path";
|
|
27759
|
+
import { fileURLToPath } from "node:url";
|
|
27760
|
+
|
|
27761
|
+
// ../cli/src/lib/agents/icon.ts
|
|
27762
|
+
var ICON_NAMES = [
|
|
27763
|
+
"file",
|
|
27764
|
+
"text",
|
|
27765
|
+
"article",
|
|
27766
|
+
"outline",
|
|
27767
|
+
"script",
|
|
27768
|
+
"prompt",
|
|
27769
|
+
"email",
|
|
27770
|
+
"image",
|
|
27771
|
+
"post-image",
|
|
27772
|
+
"social-image",
|
|
27773
|
+
"cover",
|
|
27774
|
+
"carousel",
|
|
27775
|
+
"carousel-outline",
|
|
27776
|
+
"slides",
|
|
27777
|
+
"wireframe",
|
|
27778
|
+
"screen",
|
|
27779
|
+
"video",
|
|
27780
|
+
"storyboard",
|
|
27781
|
+
"template",
|
|
27782
|
+
"shots",
|
|
27783
|
+
"api",
|
|
27784
|
+
"schema",
|
|
27785
|
+
"compare",
|
|
27786
|
+
"stack",
|
|
27787
|
+
"studio",
|
|
27788
|
+
"code",
|
|
27789
|
+
"checklist",
|
|
27790
|
+
"card",
|
|
27791
|
+
"plan",
|
|
27792
|
+
"proposal",
|
|
27793
|
+
"dismissed",
|
|
27794
|
+
"inbox",
|
|
27795
|
+
"notebook",
|
|
27796
|
+
"squeeze",
|
|
27797
|
+
"folder",
|
|
27798
|
+
"reply",
|
|
27799
|
+
"feedback",
|
|
27800
|
+
"software",
|
|
27801
|
+
"product-video",
|
|
27802
|
+
"social-post",
|
|
27803
|
+
"blog",
|
|
27804
|
+
"deck",
|
|
27805
|
+
"video-clone",
|
|
27806
|
+
"studio-kit"
|
|
27807
|
+
];
|
|
27808
|
+
var ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
|
|
27809
|
+
var PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
|
|
27810
|
+
var isColor = (v) => ICON_COLORS.includes(v);
|
|
27811
|
+
function readIcon(raw) {
|
|
27812
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
27813
|
+
if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
|
|
27814
|
+
if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
|
|
27815
|
+
const parts = [];
|
|
27816
|
+
for (const [i, item] of raw.entries()) {
|
|
27817
|
+
const at = `part ${i + 1}`;
|
|
27818
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
|
|
27819
|
+
const { d, f, o, s, w, ...extra } = item;
|
|
27820
|
+
if (Object.keys(extra).length) return { problem: `${at} has \`${Object.keys(extra).join("`, `")}\`` };
|
|
27821
|
+
if (typeof d !== "string" || !PATH.test(d)) return { problem: `${at} has no \`d\` of SVG path commands and numbers` };
|
|
27822
|
+
const part = { d: d.trim() };
|
|
27823
|
+
for (const [key, value] of [["f", f], ["s", s]]) {
|
|
27824
|
+
if (value === void 0) continue;
|
|
27825
|
+
if (typeof value !== "string" || !isColor(value)) return { problem: `${at} colours \`${key}\` with "${String(value)}"` };
|
|
27826
|
+
part[key] = value;
|
|
27827
|
+
}
|
|
27828
|
+
if (o !== void 0) {
|
|
27829
|
+
if (o !== "true") return { problem: `${at} has \`o: ${String(o)}\`, not \`true\`` };
|
|
27830
|
+
part.o = true;
|
|
27831
|
+
}
|
|
27832
|
+
if (w !== void 0) {
|
|
27833
|
+
const width = typeof w === "string" ? Number(w) : NaN;
|
|
27834
|
+
if (!(width > 0 && width <= 3)) return { problem: `${at} has \`w: ${String(w)}\`, not above 0 and up to 3` };
|
|
27835
|
+
part.w = width;
|
|
27836
|
+
}
|
|
27837
|
+
parts.push(part);
|
|
27838
|
+
}
|
|
27839
|
+
return parts;
|
|
27840
|
+
}
|
|
27841
|
+
|
|
27842
|
+
// ../cli/src/lib/yaml.ts
|
|
27843
|
+
function unquote(v) {
|
|
27844
|
+
const text3 = String(v).trim();
|
|
27845
|
+
if (text3.startsWith('"') && text3.endsWith('"')) {
|
|
27846
|
+
try {
|
|
27847
|
+
return JSON.parse(text3);
|
|
27848
|
+
} catch {
|
|
27849
|
+
return text3.slice(1, -1);
|
|
27850
|
+
}
|
|
27851
|
+
}
|
|
27852
|
+
if (text3.startsWith("'") && text3.endsWith("'")) return text3.slice(1, -1);
|
|
27853
|
+
return text3;
|
|
27854
|
+
}
|
|
27855
|
+
|
|
27856
|
+
// ../cli/src/lib/agents/yaml.ts
|
|
27857
|
+
function stripComment(value) {
|
|
27858
|
+
let from = 0;
|
|
27859
|
+
const quote2 = value[0];
|
|
27860
|
+
if (quote2 === '"' || quote2 === "'") {
|
|
27861
|
+
let i = 1;
|
|
27862
|
+
while (i < value.length) {
|
|
27863
|
+
if (quote2 === '"' && value[i] === "\\") i += 2;
|
|
27864
|
+
else if (value[i] === quote2 && quote2 === "'" && value[i + 1] === "'") i += 2;
|
|
27865
|
+
else if (value[i] === quote2) break;
|
|
27866
|
+
else i++;
|
|
27867
|
+
}
|
|
27868
|
+
from = i + 1;
|
|
27869
|
+
}
|
|
27870
|
+
const hash = value.slice(from).search(/(^|[ \t])#/);
|
|
27871
|
+
return hash < 0 ? value : value.slice(0, from + hash).trim();
|
|
27872
|
+
}
|
|
27873
|
+
var readLines = (text3) => text3.split("\n").map((raw) => ({ indent: raw.match(/^[ \t]*/)[0].length, text: raw.trim() })).filter((line) => line.text && !line.text.startsWith("#"));
|
|
27874
|
+
function parseYamlBlock(text3) {
|
|
27875
|
+
const [map2] = readMap(readLines(text3), 0, 0);
|
|
27876
|
+
return map2;
|
|
27877
|
+
}
|
|
27878
|
+
function readMap(lines, start, indent) {
|
|
27879
|
+
const out = {};
|
|
27880
|
+
let i = start;
|
|
27881
|
+
while (i < lines.length && lines[i].indent >= indent) {
|
|
27882
|
+
const line = lines[i];
|
|
27883
|
+
if (line.indent > indent) {
|
|
27884
|
+
i++;
|
|
27885
|
+
continue;
|
|
27886
|
+
}
|
|
27887
|
+
if (line.text.startsWith("-")) break;
|
|
27888
|
+
const match = line.text.match(/^([^:]+):\s*(.*)$/);
|
|
27889
|
+
if (!match) {
|
|
27890
|
+
i++;
|
|
27891
|
+
continue;
|
|
27892
|
+
}
|
|
27893
|
+
const key = match[1].trim();
|
|
27894
|
+
const inline = stripComment(match[2].trim());
|
|
27895
|
+
i++;
|
|
27896
|
+
if (inline) {
|
|
27897
|
+
out[key] = readScalar(inline);
|
|
27898
|
+
continue;
|
|
27899
|
+
}
|
|
27900
|
+
const [value, next] = readBlock(lines, i, indent);
|
|
27901
|
+
out[key] = value;
|
|
27902
|
+
i = next;
|
|
27903
|
+
}
|
|
27904
|
+
return [out, i];
|
|
27905
|
+
}
|
|
27906
|
+
function readScalar(value) {
|
|
27907
|
+
const flow = value.match(/^\[(.*)\]$/);
|
|
27908
|
+
if (!flow) return unquote(value);
|
|
27909
|
+
return flow[1].split(",").map((item) => unquote(item.trim())).filter(Boolean);
|
|
27910
|
+
}
|
|
27911
|
+
function readBlock(lines, start, parentIndent) {
|
|
27912
|
+
if (start >= lines.length || lines[start].indent <= parentIndent) return ["", start];
|
|
27913
|
+
const indent = lines[start].indent;
|
|
27914
|
+
if (lines[start].text.startsWith("-")) return readList(lines, start, indent);
|
|
27915
|
+
return readMap(lines, start, indent);
|
|
27916
|
+
}
|
|
27917
|
+
function readList(lines, start, indent) {
|
|
27918
|
+
const out = [];
|
|
27919
|
+
let i = start;
|
|
27920
|
+
while (i < lines.length && lines[i].indent === indent && lines[i].text.startsWith("-")) {
|
|
27921
|
+
const line = lines[i];
|
|
27922
|
+
const rest = line.text.replace(/^-\s*/, "");
|
|
27923
|
+
const keyIndent = indent + (line.text.length - rest.length);
|
|
27924
|
+
i++;
|
|
27925
|
+
if (!stripComment(rest)) {
|
|
27926
|
+
const [value, next2] = readBlock(lines, i, indent);
|
|
27927
|
+
out.push(value);
|
|
27928
|
+
i = next2;
|
|
27929
|
+
continue;
|
|
27930
|
+
}
|
|
27931
|
+
const match = rest.match(/^([^:]+):\s*(.*)$/);
|
|
27932
|
+
if (!match || /^\[.*\]$/.test(stripComment(rest))) {
|
|
27933
|
+
out.push(readScalar(stripComment(rest)));
|
|
27934
|
+
continue;
|
|
27935
|
+
}
|
|
27936
|
+
const item = {};
|
|
27937
|
+
const inline = stripComment(match[2].trim());
|
|
27938
|
+
if (inline) item[match[1].trim()] = unquote(inline);
|
|
27939
|
+
else {
|
|
27940
|
+
const [value, next2] = readBlock(lines, i, keyIndent);
|
|
27941
|
+
item[match[1].trim()] = value;
|
|
27942
|
+
i = next2;
|
|
27943
|
+
}
|
|
27944
|
+
const [rest_, next] = readMap(lines, i, keyIndent);
|
|
27945
|
+
Object.assign(item, rest_);
|
|
27946
|
+
i = next;
|
|
27947
|
+
out.push(item);
|
|
27948
|
+
}
|
|
27949
|
+
return [out, i];
|
|
27950
|
+
}
|
|
27951
|
+
function splitFrontmatter(text3) {
|
|
27952
|
+
const lines = text3.replace(/^/, "").split("\n");
|
|
27953
|
+
if (lines[0]?.trim() !== "---") return { meta: null, body: text3 };
|
|
27954
|
+
let i = 1;
|
|
27955
|
+
while (i < lines.length && lines[i].trim() !== "---") i++;
|
|
27956
|
+
if (i >= lines.length) return { meta: null, body: text3 };
|
|
27957
|
+
return { meta: lines.slice(1, i).join("\n"), body: lines.slice(i + 1).join("\n") };
|
|
27958
|
+
}
|
|
27959
|
+
|
|
27960
|
+
// ../cli/src/lib/agents/parse.ts
|
|
27961
|
+
var OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
|
|
27962
|
+
var AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
27963
|
+
var SCHEDULE_READS = ["archived-cards", "chats", "dismissals"];
|
|
27964
|
+
var isScheduleReads = (value) => SCHEDULE_READS.includes(value);
|
|
27965
|
+
function parseSpecAgent(text3, from, file2, builtIn = false, list = () => []) {
|
|
27966
|
+
let named = "";
|
|
27967
|
+
const bad = (why, old2) => ({
|
|
27968
|
+
problem: `${from}: ${why}`,
|
|
27969
|
+
...named ? { name: named } : {},
|
|
27970
|
+
...old2 ? { old: old2 } : {}
|
|
27971
|
+
});
|
|
27972
|
+
const { meta, body } = splitFrontmatter(text3);
|
|
27973
|
+
if (meta === null) return bad("no `---` frontmatter, so it declares no name or description");
|
|
27974
|
+
const front = parseYamlBlock(meta);
|
|
27975
|
+
const name = str(front.name);
|
|
27976
|
+
if (!name) return bad("its frontmatter has no `name`");
|
|
27977
|
+
if (!AGENT_NAME.test(name)) return bad(`"${name}" is not a usable agent name \u2014 use lower-case words joined by "-"`);
|
|
27978
|
+
named = name;
|
|
27979
|
+
const description = str(front.description);
|
|
27980
|
+
if (!description) return bad(`\`${name}\` has no \`description\`, which says what it does`);
|
|
27981
|
+
const akb = map(front.akb) ?? {};
|
|
27982
|
+
const old = OLD_ROLE_KEYS.filter((key) => akb[key] !== void 0);
|
|
27983
|
+
if (old.length) {
|
|
27984
|
+
return bad(
|
|
27985
|
+
`\`${name}\` declares ${old.map((key) => `\`akb.${key}\``).join(", ")}, which the board no longer reads \u2014 remove ${old.length > 1 ? "them" : "it"}, and list the agent in its studio's \`STUDIO.md\` under \`previews\`, \`land\` or \`scheduled\` (\`akb guide write-agent\`), or ask the Studio builder to rewrite it`,
|
|
27986
|
+
{ keys: old }
|
|
27987
|
+
);
|
|
27988
|
+
}
|
|
27989
|
+
const declaredReads = str(akb.reads) === "commits" ? "archived-cards" : str(akb.reads);
|
|
27990
|
+
if (declaredReads && !isScheduleReads(declaredReads)) {
|
|
27991
|
+
return bad(`\`${name}\` declares \`akb.reads: ${declaredReads}\` \u2014 it is \`${SCHEDULE_READS.join("` or `")}\``);
|
|
27992
|
+
}
|
|
27993
|
+
const when = str(akb.when);
|
|
27994
|
+
const after = names(akb.after);
|
|
27995
|
+
const declaredSession = str(akb.session);
|
|
27996
|
+
if (declaredSession && declaredSession !== "new") {
|
|
27997
|
+
return bad(`\`${name}\` declares \`akb.session: ${declaredSession}\` \u2014 it is \`new\`, or left out to run in the planning session`);
|
|
27998
|
+
}
|
|
27999
|
+
const components = akb.components === void 0 ? ["Asset"] : akb.components;
|
|
28000
|
+
if (!Array.isArray(components) || components.some((value) => typeof value !== "string" || !value.trim())) {
|
|
28001
|
+
return bad(`\`${name}\` declares \`akb.components\` that is not a list of component IDs`);
|
|
28002
|
+
}
|
|
28003
|
+
const icon = readIcon(akb.icon);
|
|
28004
|
+
if (icon && typeof icon === "object" && "problem" in icon) {
|
|
28005
|
+
return bad(
|
|
28006
|
+
`\`${name}\` declares an \`akb.icon\` where ${icon.problem} \u2014 use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
|
|
28007
|
+
);
|
|
28008
|
+
}
|
|
28009
|
+
const workspace = memoryPaths(akb.memoryFiles);
|
|
28010
|
+
if (typeof workspace === "string") return bad(`\`${name}\` declares ${workspace}`);
|
|
28011
|
+
const instructions = body.trim();
|
|
28012
|
+
if (!instructions) return bad(`\`${name}\` has frontmatter but no instructions under it`);
|
|
28013
|
+
return {
|
|
28014
|
+
agent: {
|
|
28015
|
+
name,
|
|
28016
|
+
description,
|
|
28017
|
+
...when ? { when } : {},
|
|
28018
|
+
after,
|
|
28019
|
+
components: [...new Set(components.map((value) => value.trim()))],
|
|
28020
|
+
...icon ? { icon } : {},
|
|
28021
|
+
...akb.merges === "true" ? { merges: true } : {},
|
|
28022
|
+
i18n: readTranslations(akb.i18n),
|
|
28023
|
+
...declaredReads ? { reads: declaredReads } : {},
|
|
28024
|
+
...declaredSession ? { session: "new" } : {},
|
|
28025
|
+
memory: names(akb.memory),
|
|
28026
|
+
memoryFiles: { workspace },
|
|
28027
|
+
files: list(),
|
|
28028
|
+
body: instructions,
|
|
28029
|
+
from,
|
|
28030
|
+
builtIn,
|
|
28031
|
+
file: file2
|
|
28032
|
+
}
|
|
28033
|
+
};
|
|
28034
|
+
}
|
|
28035
|
+
function readTranslations(raw) {
|
|
28036
|
+
const block = map(raw);
|
|
28037
|
+
if (!block) return {};
|
|
28038
|
+
const out = {};
|
|
28039
|
+
for (const [tag, value] of Object.entries(block)) {
|
|
28040
|
+
const said = map(value);
|
|
28041
|
+
if (!said) continue;
|
|
28042
|
+
const lines = {
|
|
28043
|
+
...str(said.title) ? { title: str(said.title) } : {},
|
|
28044
|
+
...str(said.description) ? { description: str(said.description) } : {},
|
|
28045
|
+
...str(said.when) ? { when: str(said.when) } : {}
|
|
28046
|
+
};
|
|
28047
|
+
if (Object.keys(lines).length) out[tag] = lines;
|
|
28048
|
+
}
|
|
28049
|
+
return out;
|
|
28050
|
+
}
|
|
28051
|
+
function memoryPaths(raw) {
|
|
28052
|
+
if (raw === void 0) return [];
|
|
28053
|
+
const block = map(raw);
|
|
28054
|
+
const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
|
|
28055
|
+
if (!block || extra.length) return `\`akb.memoryFiles\` with ${block ? `\`${extra.join("`, `")}\`` : "no `workspace:` list"} \u2014 it holds only \`workspace: [<path>, ...]\``;
|
|
28056
|
+
const list = block.workspace;
|
|
28057
|
+
if (list === void 0) return [];
|
|
28058
|
+
if (!Array.isArray(list) || list.some((v) => typeof v !== "string" || !v.trim())) {
|
|
28059
|
+
return "`akb.memoryFiles.workspace` that is not a list of paths \u2014 write `workspace: [style.md]`";
|
|
28060
|
+
}
|
|
28061
|
+
const paths = [...new Set(list.map((v) => v.trim()))];
|
|
28062
|
+
const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
|
|
28063
|
+
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`memory/agents/<name>/\``;
|
|
28064
|
+
return paths;
|
|
28065
|
+
}
|
|
28066
|
+
var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) => str(v)).filter(Boolean))];
|
|
28067
|
+
var str = (value) => typeof value === "string" ? value.trim() : "";
|
|
28068
|
+
var map = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
28069
|
+
|
|
28070
|
+
// ../cli/src/lib/spec-agent-names.ts
|
|
28071
|
+
var LEGACY_SPEC_AGENT_NAMES = {
|
|
28072
|
+
"recommend-tech-stack": "tech-stack-advisor",
|
|
28073
|
+
"technology-selection": "tech-stack-advisor",
|
|
28074
|
+
"ui-design": "ui-designer",
|
|
28075
|
+
// Renamed in #945 and folded into the editor in #1057; its asset memory stays in
|
|
28076
|
+
// `memory/agents/video-assets/`.
|
|
28077
|
+
"video-assets": "hyperframes-editor",
|
|
28078
|
+
// Renamed in #1502: it reads chats, and writes memory as a result.
|
|
28079
|
+
"memory-reviewer": "chat-reviewer",
|
|
28080
|
+
// Folded into `copywriting` in #1582.
|
|
28081
|
+
"user-docs": "copywriting"
|
|
28082
|
+
};
|
|
28083
|
+
var canonicalSpecAgent = (name) => {
|
|
28084
|
+
const asked = name.trim();
|
|
28085
|
+
return LEGACY_SPEC_AGENT_NAMES[asked] ?? asked;
|
|
28086
|
+
};
|
|
28087
|
+
|
|
28088
|
+
// ../cli/src/lib/agent/studio-def.ts
|
|
28089
|
+
var STUDIO_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
28090
|
+
var OLD_KEYS = ["stages", "delivers", "helpers", "every"];
|
|
28091
|
+
var box = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
28092
|
+
var text = (value) => typeof value === "string" ? value.trim() : "";
|
|
28093
|
+
function readAgent(item) {
|
|
28094
|
+
const row = typeof item === "string" ? { agent: item } : box(item);
|
|
28095
|
+
const agent = canonicalSpecAgent(text(row.agent));
|
|
28096
|
+
if (!agent) return null;
|
|
28097
|
+
return { agent, extra: typeof row.extra === "string" ? row.extra : "", ...text(row.off) === "true" ? { off: true } : {} };
|
|
28098
|
+
}
|
|
28099
|
+
var readGroup = (value) => (Array.isArray(value) ? value : []).map(readAgent).filter((h) => !!h);
|
|
28100
|
+
function readPreviews(value) {
|
|
28101
|
+
if (value === void 0 || value === "") return [];
|
|
28102
|
+
if (!Array.isArray(value)) return "`previews` is a list of agents";
|
|
28103
|
+
if (value.some(Array.isArray)) {
|
|
28104
|
+
return "`previews` is one list of agents, not a list of lists \u2014 flatten it, and give an agent `after` to make it wait on another's approval";
|
|
28105
|
+
}
|
|
28106
|
+
return readGroup(value);
|
|
28107
|
+
}
|
|
28108
|
+
function parseStudioFile(id, source, from) {
|
|
28109
|
+
if (!STUDIO_ID.test(id)) return { problem: `${from}: \`${id}\` is not a studio id \u2014 use lowercase letters, digits and dashes` };
|
|
28110
|
+
const { meta, body } = splitFrontmatter(source);
|
|
28111
|
+
if (meta === null) return { problem: `${from}: no \`---\` frontmatter` };
|
|
28112
|
+
const raw = parseYamlBlock(meta);
|
|
28113
|
+
const name = text(raw.name).replace(/\s+/g, " ");
|
|
28114
|
+
if (!name) return { problem: `${from}: its frontmatter has no \`name\`` };
|
|
28115
|
+
const old = OLD_KEYS.filter((key) => key in raw);
|
|
28116
|
+
if (old.length) {
|
|
28117
|
+
return {
|
|
28118
|
+
problem: `${from}: \`${old.join("`, `")}\` ${old.length > 1 ? "are" : "is"} no longer read \u2014 list the agents under \`previews\`, \`land\` and \`scheduled\` instead (\`akb guide write-agent\`), or ask the Studio builder to rewrite it`
|
|
28119
|
+
};
|
|
28120
|
+
}
|
|
28121
|
+
const icon = readIcon(raw.icon);
|
|
28122
|
+
if (icon && typeof icon === "object" && "problem" in icon) {
|
|
28123
|
+
return {
|
|
28124
|
+
problem: `${from}: its \`icon\` is wrong \u2014 ${icon.problem}; use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
|
|
28125
|
+
};
|
|
28126
|
+
}
|
|
28127
|
+
const previews = readPreviews(raw.previews);
|
|
28128
|
+
if (typeof previews === "string") return { problem: `${from}: ${previews}` };
|
|
28129
|
+
const land = readGroup(raw.land);
|
|
28130
|
+
const seen = /* @__PURE__ */ new Set();
|
|
28131
|
+
for (const { agent } of [...previews, ...land]) {
|
|
28132
|
+
if (seen.has(agent)) return { problem: `${from}: \`${agent}\` is listed more than once \u2014 list an agent once` };
|
|
28133
|
+
seen.add(agent);
|
|
28134
|
+
}
|
|
28135
|
+
const scheduled = [];
|
|
28136
|
+
for (const item of Array.isArray(raw.scheduled) ? raw.scheduled : []) {
|
|
28137
|
+
const row = typeof item === "string" ? { agent: item } : box(item);
|
|
28138
|
+
const agent = canonicalSpecAgent(text(row.agent));
|
|
28139
|
+
if (!agent || scheduled.some((s) => s.agent === agent)) continue;
|
|
28140
|
+
scheduled.push({ agent, ...text(row.cadence) ? { cadence: text(row.cadence) } : {} });
|
|
28141
|
+
}
|
|
28142
|
+
const names2 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said]) => [lang, text(said)]).filter(([, said]) => said));
|
|
28143
|
+
return {
|
|
28144
|
+
def: {
|
|
28145
|
+
id,
|
|
28146
|
+
name,
|
|
28147
|
+
...Object.keys(names2).length ? { names: names2 } : {},
|
|
28148
|
+
description: text(raw.description),
|
|
28149
|
+
when: text(raw.when),
|
|
28150
|
+
needsArtifact: text(raw.needsArtifact) === "true",
|
|
28151
|
+
...icon ? { icon } : {},
|
|
28152
|
+
previews,
|
|
28153
|
+
land,
|
|
28154
|
+
scheduled,
|
|
28155
|
+
rules: body.trim()
|
|
28156
|
+
}
|
|
28157
|
+
};
|
|
28158
|
+
}
|
|
28159
|
+
|
|
28160
|
+
// ../cli/src/lib/agent/studio-folder.ts
|
|
28161
|
+
import fs7 from "node:fs";
|
|
28162
|
+
import path8 from "node:path";
|
|
28163
|
+
|
|
28164
|
+
// ../cli/src/lib/shared/studio-files.ts
|
|
28165
|
+
var STUDIO_FILE = "STUDIO.md";
|
|
28166
|
+
var MCP_FILE = "mcp.json";
|
|
28167
|
+
var VERSION_FILE = "version.json";
|
|
28168
|
+
var KB = 1024;
|
|
28169
|
+
var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
|
|
28170
|
+
var officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
|
|
28171
|
+
var hashInput = (files) => JSON.stringify(Object.entries(files).sort(([a], [b]) => a < b ? -1 : 1));
|
|
28172
|
+
var landsOf = (def) => ({ lands: def.land.some((h) => !h.off) });
|
|
28173
|
+
var SEGMENT = /^[\w.-]+$/;
|
|
28174
|
+
var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
|
|
28175
|
+
var bytes = (text3) => new TextEncoder().encode(text3).length;
|
|
28176
|
+
function folderPath(file2, top) {
|
|
28177
|
+
const parts = file2.split("/");
|
|
28178
|
+
if (parts.length < 3 || parts[0] !== top || !AGENT_NAME.test(parts[1])) return null;
|
|
28179
|
+
if (parts.slice(2).some((p) => !SEGMENT.test(p) || p === "." || p === "..")) return null;
|
|
28180
|
+
return [parts[1], parts.slice(2).join("/")];
|
|
28181
|
+
}
|
|
28182
|
+
function mcpProblem(text3) {
|
|
28183
|
+
let read2;
|
|
28184
|
+
try {
|
|
28185
|
+
read2 = JSON.parse(text3);
|
|
28186
|
+
} catch {
|
|
28187
|
+
return "is not JSON";
|
|
28188
|
+
}
|
|
28189
|
+
const servers = read2?.mcpServers;
|
|
28190
|
+
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
|
|
28191
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
28192
|
+
const { command, args, ...rest } = server ?? {};
|
|
28193
|
+
if (!AGENT_NAME.test(name)) return `names a server \`${name}\`; use lowercase letters, digits and dashes`;
|
|
28194
|
+
if (typeof command !== "string" || !command) return `server \`${name}\` needs a \`command\``;
|
|
28195
|
+
if (args !== void 0 && !(Array.isArray(args) && args.every((a) => typeof a === "string"))) return `server \`${name}\`: \`args\` must be a list of strings`;
|
|
28196
|
+
if (Object.keys(rest).length) return `server \`${name}\` takes only \`command\` and \`args\``;
|
|
28197
|
+
}
|
|
28198
|
+
return null;
|
|
28199
|
+
}
|
|
28200
|
+
function checkStudioFiles(value, official = false) {
|
|
28201
|
+
const read2 = inspect(value, official);
|
|
28202
|
+
const first = read2.problems[0];
|
|
28203
|
+
return first ? { ok: false, ...first } : { ok: true, def: read2.def, files: read2.files };
|
|
28204
|
+
}
|
|
28205
|
+
function inspect(value, official) {
|
|
28206
|
+
const problems = [];
|
|
28207
|
+
const fail = (file2, reason, tooLarge = false) => {
|
|
28208
|
+
problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
|
|
28209
|
+
return { problems };
|
|
28210
|
+
};
|
|
28211
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
|
|
28212
|
+
const files = Object.fromEntries(Object.entries(value).filter(([file2]) => file2 !== VERSION_FILE));
|
|
28213
|
+
const entries = Object.entries(files);
|
|
28214
|
+
if (entries.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
|
|
28215
|
+
let total = 0;
|
|
28216
|
+
const folders2 = /* @__PURE__ */ new Map();
|
|
28217
|
+
const skills = /* @__PURE__ */ new Set();
|
|
28218
|
+
for (const [file2, text3] of entries) {
|
|
28219
|
+
if (typeof text3 !== "string" || text3.includes("\0")) {
|
|
28220
|
+
fail(file2, "is not a text file");
|
|
28221
|
+
continue;
|
|
28222
|
+
}
|
|
28223
|
+
if (file2.length > FILE_LIMITS.path) {
|
|
28224
|
+
fail(file2, `the path is longer than ${FILE_LIMITS.path} characters`);
|
|
28225
|
+
continue;
|
|
28226
|
+
}
|
|
28227
|
+
const size = bytes(text3);
|
|
28228
|
+
if (size > FILE_LIMITS.file) return fail(file2, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
|
|
28229
|
+
total += size;
|
|
28230
|
+
if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
|
|
28231
|
+
if (file2 === STUDIO_FILE) continue;
|
|
28232
|
+
if (official && file2 === MCP_FILE) {
|
|
28233
|
+
const problem = mcpProblem(text3);
|
|
28234
|
+
if (problem) fail(file2, problem);
|
|
28235
|
+
continue;
|
|
28236
|
+
}
|
|
28237
|
+
if (official && isAboutFile(file2)) continue;
|
|
28238
|
+
if (official && file2.startsWith("skills/")) {
|
|
28239
|
+
if (!folderPath(file2, "skills")) fail(file2, "is not inside skills/<name>/");
|
|
28240
|
+
else skills.add(file2.split("/")[1]);
|
|
28241
|
+
continue;
|
|
28242
|
+
}
|
|
28243
|
+
const at = folderPath(file2, "agents");
|
|
28244
|
+
if (!at) {
|
|
28245
|
+
fail(file2, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
|
|
28246
|
+
continue;
|
|
28247
|
+
}
|
|
28248
|
+
if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
|
|
28249
|
+
folders2.get(at[0]).set(at[1], text3);
|
|
28250
|
+
}
|
|
28251
|
+
for (const name of skills) {
|
|
28252
|
+
if (files[`skills/${name}/SKILL.md`] === void 0) fail(`skills/${name}/SKILL.md`, "is missing");
|
|
28253
|
+
}
|
|
28254
|
+
const source = files[STUDIO_FILE];
|
|
28255
|
+
const read2 = typeof source === "string" ? parseStudioFile("studio", source, STUDIO_FILE) : null;
|
|
28256
|
+
if (!read2) fail(STUDIO_FILE, "is missing");
|
|
28257
|
+
else if ("problem" in read2) fail(STUDIO_FILE, read2.problem.replace(`${STUDIO_FILE}: `, ""));
|
|
28258
|
+
const agents = /* @__PURE__ */ new Map();
|
|
28259
|
+
for (const [name, own2] of folders2) {
|
|
28260
|
+
const from = `agents/${name}/AGENT.md`;
|
|
28261
|
+
const text3 = own2.get("AGENT.md");
|
|
28262
|
+
if (text3 === void 0) {
|
|
28263
|
+
fail(from, "is missing");
|
|
28264
|
+
continue;
|
|
28265
|
+
}
|
|
28266
|
+
const parsed = parseSpecAgent(text3, from, (p) => own2.get(p) ?? null, false, () => [...own2.keys()].filter((p) => p !== "AGENT.md"));
|
|
28267
|
+
if ("problem" in parsed) fail(from, parsed.problem.replace(`${from}: `, ""));
|
|
28268
|
+
else if (parsed.agent.name !== name) fail(from, `calls itself \`${parsed.agent.name}\`; it must match its folder`);
|
|
28269
|
+
else agents.set(name, parsed.agent);
|
|
28270
|
+
}
|
|
28271
|
+
if (!read2 || "problem" in read2) return { problems };
|
|
28272
|
+
const def = read2.def;
|
|
28273
|
+
const named = [
|
|
28274
|
+
...def.previews.map((h) => [h.agent, "it previews with"]),
|
|
28275
|
+
...def.land.map((h) => [h.agent, "it lands with"]),
|
|
28276
|
+
...def.scheduled.map((s) => [s.agent, "it schedules"])
|
|
28277
|
+
];
|
|
28278
|
+
for (const [name, why] of named) {
|
|
28279
|
+
if (!agents.has(name) && !folders2.has(name)) fail(STUDIO_FILE, `${why} \`${name}\`, which has no agents/${name}/AGENT.md`);
|
|
28280
|
+
}
|
|
28281
|
+
return { problems, def, files };
|
|
28282
|
+
}
|
|
28283
|
+
|
|
28284
|
+
// ../cli/src/lib/agent/studio-folder.ts
|
|
28285
|
+
var MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
28286
|
+
function filesOf(dir, base = dir) {
|
|
28287
|
+
return fs7.readdirSync(dir, { withFileTypes: true }).filter((e) => !e.name.startsWith(".")).flatMap((e) => {
|
|
28288
|
+
const full = path8.join(dir, e.name);
|
|
28289
|
+
return e.isDirectory() ? filesOf(full, base) : [path8.relative(base, full).split(path8.sep).join("/")];
|
|
28290
|
+
});
|
|
28291
|
+
}
|
|
28292
|
+
function readStudioFile(dir, file2) {
|
|
28293
|
+
const full = path8.join(dir, file2);
|
|
28294
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path8.extname(file2)]};base64,${fs7.readFileSync(full).toString("base64")}` : fs7.readFileSync(full, "utf8");
|
|
28295
|
+
}
|
|
28296
|
+
var readStudioFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f) => [f, readStudioFile(dir, f)]));
|
|
28297
|
+
|
|
28298
|
+
// ../official/pack.ts
|
|
28299
|
+
var OFFICIAL = path9.dirname(fileURLToPath(import.meta.url));
|
|
28300
|
+
var dirs = (dir) => fs8.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
28301
|
+
var hashOf = (files) => crypto5.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
28302
|
+
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
28303
|
+
const agentsDir = path9.join(root2, "agents");
|
|
28304
|
+
const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
|
|
28305
|
+
const dir = path9.join(agentsDir, name);
|
|
28306
|
+
return [name, readStudioFolder(dir)];
|
|
28307
|
+
}));
|
|
28308
|
+
for (const [name, own2] of Object.entries(loose ? {} : agentFiles)) {
|
|
28309
|
+
const read2 = parseSpecAgent(own2["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p) => own2[p] ?? null, true);
|
|
28310
|
+
if ("problem" in read2) throw new Error(read2.problem);
|
|
28311
|
+
}
|
|
28312
|
+
const studiosDir = path9.join(root2, "studios");
|
|
28313
|
+
return dirs(studiosDir).map((folder) => {
|
|
28314
|
+
const dir = path9.join(studiosDir, folder);
|
|
28315
|
+
const files = {};
|
|
28316
|
+
for (const f of filesOf(dir).sort()) {
|
|
28317
|
+
if (f === STUDIO_FILE || f === MCP_FILE || f.startsWith("skills/") || isAboutFile(f)) files[f] = readStudioFile(dir, f);
|
|
28318
|
+
}
|
|
28319
|
+
const read2 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
|
|
28320
|
+
Object.entries(agentFiles).flatMap(([name, own2]) => Object.entries(own2).map(([f, t2]) => [`agents/${name}/${f}`, t2]))
|
|
28321
|
+
) });
|
|
28322
|
+
if (!read2.ok && !loose) throw new Error(`official/studios/${folder}: ${read2.file}: ${read2.reason}`);
|
|
28323
|
+
const parsed = parseStudioFile(folder, files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
28324
|
+
if ("problem" in parsed) throw new Error(parsed.problem);
|
|
28325
|
+
const def = parsed.def;
|
|
28326
|
+
for (const name of [...new Set([...def.previews, ...def.land, ...def.scheduled].map((h) => h.agent))].sort()) {
|
|
28327
|
+
for (const [f, text3] of Object.entries(agentFiles[name] ?? {})) files[`agents/${name}/${f}`] = text3;
|
|
28328
|
+
}
|
|
28329
|
+
const checked = loose ? { ok: true } : checkStudioFiles(files, true);
|
|
28330
|
+
if (!checked.ok) throw new Error(`official/studios/${folder}: ${checked.file}: ${checked.reason}`);
|
|
28331
|
+
if (!def.names?.zh && !loose) throw new Error(`official/studios/${folder}/${STUDIO_FILE}: add its Chinese name under \`names: zh\``);
|
|
28332
|
+
return {
|
|
28333
|
+
id: officialId(folder),
|
|
28334
|
+
name: def.name,
|
|
28335
|
+
names: { en: def.name, ...def.names },
|
|
28336
|
+
description: def.description,
|
|
28337
|
+
when: def.when,
|
|
28338
|
+
...landsOf(def),
|
|
28339
|
+
hash: hashOf(files),
|
|
28340
|
+
files
|
|
28341
|
+
};
|
|
28342
|
+
});
|
|
28343
|
+
}
|
|
28344
|
+
|
|
28345
|
+
// ../cli/src/lib/cloud/tasks.ts
|
|
27743
28346
|
import fs9 from "node:fs";
|
|
27744
28347
|
import path10 from "node:path";
|
|
28348
|
+
var TASK_ENV = "AI4KANBAN_TASK";
|
|
28349
|
+
function workspaceTask() {
|
|
28350
|
+
const id = process.env[TASK_ENV];
|
|
28351
|
+
return id && id.trim() ? id.trim() : null;
|
|
28352
|
+
}
|
|
28353
|
+
function runnerProject(board) {
|
|
28354
|
+
if (path10.basename(board) !== "kanban" || path10.basename(path10.dirname(board)) !== ".akb") return null;
|
|
28355
|
+
const linked = linkedProject(board, path10.dirname(path10.dirname(board)));
|
|
28356
|
+
return linked.ok ? linked.value : null;
|
|
28357
|
+
}
|
|
28358
|
+
function linkedProject(board, root2) {
|
|
28359
|
+
const file2 = path10.join(root2, ".akb", "base.json");
|
|
28360
|
+
if (!fs9.existsSync(file2)) return { ok: true, value: null };
|
|
28361
|
+
try {
|
|
28362
|
+
const base = JSON.parse(fs9.readFileSync(file2, "utf8"));
|
|
28363
|
+
if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
|
|
28364
|
+
const projects = new Set(Object.keys(base.files ?? {}).flatMap((p) => /^projects\/([^/]+)\//.exec(p)?.[1] ?? []));
|
|
28365
|
+
if (typeof base.project === "string") projects.add(base.project);
|
|
28366
|
+
if (projects.size !== 1) throw new Error();
|
|
28367
|
+
return { ok: true, value: [...projects][0] };
|
|
28368
|
+
} catch {
|
|
28369
|
+
return { ok: false, error: "The project link is invalid or names multiple projects.", code: "invalid-link" };
|
|
28370
|
+
}
|
|
28371
|
+
}
|
|
28372
|
+
|
|
28373
|
+
// ../cli/src/lib/file-memo.ts
|
|
28374
|
+
import fs10 from "node:fs";
|
|
28375
|
+
import path11 from "node:path";
|
|
28376
|
+
function stamp(paths) {
|
|
28377
|
+
const parts = [];
|
|
28378
|
+
const visit = (p) => {
|
|
28379
|
+
let st;
|
|
28380
|
+
try {
|
|
28381
|
+
st = fs10.statSync(p, { bigint: true });
|
|
28382
|
+
} catch {
|
|
28383
|
+
parts.push(`${p}:-`);
|
|
28384
|
+
return;
|
|
28385
|
+
}
|
|
28386
|
+
if (!st.isDirectory()) {
|
|
28387
|
+
parts.push(`${p}:${st.mtimeNs}:${st.size}`);
|
|
28388
|
+
return;
|
|
28389
|
+
}
|
|
28390
|
+
parts.push(`${p}/`);
|
|
28391
|
+
let names2;
|
|
28392
|
+
try {
|
|
28393
|
+
names2 = fs10.readdirSync(p).sort();
|
|
28394
|
+
} catch {
|
|
28395
|
+
return;
|
|
28396
|
+
}
|
|
28397
|
+
for (const name of names2) if (name !== "node_modules" && name !== ".git") visit(path11.join(p, name));
|
|
28398
|
+
};
|
|
28399
|
+
for (const p of paths) visit(p);
|
|
28400
|
+
return parts.join("\n");
|
|
28401
|
+
}
|
|
28402
|
+
function copy(v) {
|
|
28403
|
+
if (Array.isArray(v)) return v.map(copy);
|
|
28404
|
+
if (v instanceof Map) return new Map([...v].map(([k, x]) => [k, copy(x)]));
|
|
28405
|
+
if (v instanceof Set) return new Set([...v].map(copy));
|
|
28406
|
+
if (v && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype) {
|
|
28407
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, copy(x)]));
|
|
28408
|
+
}
|
|
28409
|
+
return v;
|
|
28410
|
+
}
|
|
28411
|
+
var perTurn = false;
|
|
28412
|
+
var turn = 0;
|
|
28413
|
+
var turnEnding = false;
|
|
28414
|
+
function currentTurn() {
|
|
28415
|
+
if (!perTurn) return ++turn;
|
|
28416
|
+
if (!turnEnding) {
|
|
28417
|
+
turnEnding = true;
|
|
28418
|
+
setImmediate(() => {
|
|
28419
|
+
turn++;
|
|
28420
|
+
turnEnding = false;
|
|
28421
|
+
}).unref();
|
|
28422
|
+
}
|
|
28423
|
+
return turn;
|
|
28424
|
+
}
|
|
28425
|
+
function memoByFiles(paths, read2) {
|
|
28426
|
+
let last2 = null;
|
|
28427
|
+
return () => {
|
|
28428
|
+
const now = currentTurn();
|
|
28429
|
+
if (last2?.turn !== now) {
|
|
28430
|
+
const seen = stamp(paths());
|
|
28431
|
+
if (last2?.stamp === seen) last2.turn = now;
|
|
28432
|
+
else last2 = { stamp: seen, turn: now, value: read2() };
|
|
28433
|
+
}
|
|
28434
|
+
return copy(last2.value);
|
|
28435
|
+
};
|
|
28436
|
+
}
|
|
28437
|
+
|
|
28438
|
+
// ../cli/src/lib/paths.ts
|
|
28439
|
+
import path13 from "node:path";
|
|
27745
28440
|
|
|
27746
28441
|
// ../cli/src/lib/machine/project.ts
|
|
27747
|
-
import
|
|
27748
|
-
import
|
|
28442
|
+
import fs11 from "node:fs";
|
|
28443
|
+
import path12 from "node:path";
|
|
27749
28444
|
var SESSIONS_FILE = "sessions.json";
|
|
27750
28445
|
var SESSIONS_FOLDER = "sessions";
|
|
27751
28446
|
var ASSETS_FOLDER = "assets";
|
|
@@ -27754,16 +28449,16 @@ var SESSIONS_LOCK = "sessions.lock";
|
|
|
27754
28449
|
var INDEX_LOCK = "index.lock";
|
|
27755
28450
|
var UI_CONFIG_FILE = "ui.config.json";
|
|
27756
28451
|
function realPathOf(dir) {
|
|
27757
|
-
const here2 =
|
|
28452
|
+
const here2 = path12.resolve(dir);
|
|
27758
28453
|
const rest = [];
|
|
27759
28454
|
let at = here2;
|
|
27760
28455
|
for (; ; ) {
|
|
27761
28456
|
try {
|
|
27762
|
-
return
|
|
28457
|
+
return path12.join(fs11.realpathSync(at), ...rest);
|
|
27763
28458
|
} catch {
|
|
27764
|
-
const up =
|
|
28459
|
+
const up = path12.dirname(at);
|
|
27765
28460
|
if (up === at) return here2;
|
|
27766
|
-
rest.unshift(
|
|
28461
|
+
rest.unshift(path12.basename(at));
|
|
27767
28462
|
at = up;
|
|
27768
28463
|
}
|
|
27769
28464
|
}
|
|
@@ -27771,40 +28466,191 @@ function realPathOf(dir) {
|
|
|
27771
28466
|
function stateRootOf(board) {
|
|
27772
28467
|
let dir = realPathOf(board);
|
|
27773
28468
|
for (; ; ) {
|
|
27774
|
-
if (
|
|
27775
|
-
const up =
|
|
28469
|
+
if (fs11.existsSync(path12.join(dir, ".git"))) return dir;
|
|
28470
|
+
const up = path12.dirname(dir);
|
|
27776
28471
|
if (up === dir) break;
|
|
27777
28472
|
dir = up;
|
|
27778
28473
|
}
|
|
27779
28474
|
return rootAbove(realPathOf(board));
|
|
27780
28475
|
}
|
|
27781
28476
|
function rootAbove(board) {
|
|
27782
|
-
const parent =
|
|
27783
|
-
return ["docs", ".akb"].includes(
|
|
28477
|
+
const parent = path12.dirname(board);
|
|
28478
|
+
return ["docs", ".akb"].includes(path12.basename(parent)) ? path12.dirname(parent) : parent;
|
|
27784
28479
|
}
|
|
27785
|
-
function projectStateDir(board,
|
|
27786
|
-
const relative =
|
|
27787
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
28480
|
+
function projectStateDir(board, root2 = stateRootOf(board)) {
|
|
28481
|
+
const relative = path12.relative(realPathOf(root2), realPathOf(board));
|
|
28482
|
+
if (relative === ".." || relative.startsWith(`..${path12.sep}`) || path12.isAbsolute(relative)) {
|
|
27788
28483
|
throw new Error("The board must be inside its project root.");
|
|
27789
28484
|
}
|
|
27790
|
-
return
|
|
28485
|
+
return path12.join(realPathOf(root2), ".akb", "boards", relative || "_root");
|
|
28486
|
+
}
|
|
28487
|
+
|
|
28488
|
+
// ../cli/src/lib/paths.ts
|
|
28489
|
+
var REPO_ROOT = "";
|
|
28490
|
+
var KANBAN = "";
|
|
28491
|
+
var TODO = "";
|
|
28492
|
+
var ARCHIVE = "";
|
|
28493
|
+
var ARCHIVE_MD = "";
|
|
28494
|
+
var README = "";
|
|
28495
|
+
var MODULES_MD = "";
|
|
28496
|
+
var CONFIG = "";
|
|
28497
|
+
var KANBAN_GITIGNORE = "";
|
|
28498
|
+
var RELEASES = "";
|
|
28499
|
+
var RELEASE_SUMMARIES = "";
|
|
28500
|
+
var AGENTS = "";
|
|
28501
|
+
var STUDIOS = "";
|
|
28502
|
+
var LEGACY_AGENTS = "";
|
|
28503
|
+
var ASSETS = "";
|
|
28504
|
+
var BOARD_STATE = "";
|
|
28505
|
+
var MOCKUPS = "";
|
|
28506
|
+
var MEMORY = "";
|
|
28507
|
+
var AGENT_MEMORY = "";
|
|
28508
|
+
var PROJECT_MD = "";
|
|
28509
|
+
var LOCK = "";
|
|
28510
|
+
var UI_CONFIG = "";
|
|
28511
|
+
var LEGACY_UI_CONFIG = "";
|
|
28512
|
+
var LOCAL_CONFIG = "";
|
|
28513
|
+
var ENV_FILE = "";
|
|
28514
|
+
var SESSIONS = "";
|
|
28515
|
+
var SESSIONS_DIR = "";
|
|
28516
|
+
var SESSIONS_LOCK2 = "";
|
|
28517
|
+
var INDEX_LOCK2 = "";
|
|
28518
|
+
var DELIVERIES = "";
|
|
28519
|
+
var PLANS = "";
|
|
28520
|
+
var PLANS_ARCHIVE = "";
|
|
28521
|
+
var RULES = "";
|
|
28522
|
+
var TRIAGE = "";
|
|
28523
|
+
var SIGNALS_ARCHIVED = "";
|
|
28524
|
+
var SIGNALS_DISMISSED = "";
|
|
28525
|
+
var SIGNALS_FILES = "";
|
|
28526
|
+
var SIGNALS_OLD_INBOX = "";
|
|
28527
|
+
var SIGNALS_OLD_HANDLED = "";
|
|
28528
|
+
var AKB_DIR = "";
|
|
28529
|
+
var ROOT_GITIGNORE = "";
|
|
28530
|
+
function boardLockName(kanban, root2) {
|
|
28531
|
+
const from = path13.relative(root2, kanban);
|
|
28532
|
+
const name = from && !from.startsWith("..") ? from : path13.basename(kanban);
|
|
28533
|
+
return `${name.split(path13.sep).join("-")}.lock`;
|
|
28534
|
+
}
|
|
28535
|
+
var BOARD_FLAG = "";
|
|
28536
|
+
function setBoard(kanban, root2, flag) {
|
|
28537
|
+
REPO_ROOT = path13.resolve(root2);
|
|
28538
|
+
KANBAN = path13.resolve(kanban);
|
|
28539
|
+
BOARD_FLAG = flag;
|
|
28540
|
+
TODO = path13.join(KANBAN, "todo");
|
|
28541
|
+
ARCHIVE = path13.join(KANBAN, ".archive");
|
|
28542
|
+
ARCHIVE_MD = path13.join(KANBAN, "archive.md");
|
|
28543
|
+
README = path13.join(TODO, "README.md");
|
|
28544
|
+
MODULES_MD = path13.join(KANBAN, "modules.md");
|
|
28545
|
+
CONFIG = path13.join(KANBAN, "config.md");
|
|
28546
|
+
KANBAN_GITIGNORE = path13.join(KANBAN, ".gitignore");
|
|
28547
|
+
RELEASES = path13.join(KANBAN, "releases.md");
|
|
28548
|
+
RELEASE_SUMMARIES = path13.join(KANBAN, ".release-summaries");
|
|
28549
|
+
AGENTS = path13.join(KANBAN, "agents");
|
|
28550
|
+
STUDIOS = path13.join(KANBAN, "studios");
|
|
28551
|
+
LEGACY_AGENTS = path13.join(KANBAN, "skills");
|
|
28552
|
+
MEMORY = path13.join(KANBAN, "memory");
|
|
28553
|
+
AGENT_MEMORY = path13.join(MEMORY, "agents");
|
|
28554
|
+
PROJECT_MD = path13.join(MEMORY, "project.md");
|
|
28555
|
+
LEGACY_UI_CONFIG = path13.join(KANBAN, UI_CONFIG_FILE);
|
|
28556
|
+
LOCAL_CONFIG = path13.join(KANBAN, ".local.json");
|
|
28557
|
+
ENV_FILE = path13.join(KANBAN, ".env");
|
|
28558
|
+
const machine = projectStateDir(KANBAN, REPO_ROOT);
|
|
28559
|
+
BOARD_STATE = machine;
|
|
28560
|
+
UI_CONFIG = path13.join(machine, UI_CONFIG_FILE);
|
|
28561
|
+
ASSETS = path13.join(machine, ASSETS_FOLDER);
|
|
28562
|
+
MOCKUPS = path13.join(machine, MOCKUPS_FOLDER);
|
|
28563
|
+
SESSIONS = path13.join(machine, SESSIONS_FILE);
|
|
28564
|
+
SESSIONS_DIR = path13.join(machine, SESSIONS_FOLDER);
|
|
28565
|
+
SESSIONS_LOCK2 = path13.join(machine, SESSIONS_LOCK);
|
|
28566
|
+
INDEX_LOCK2 = path13.join(machine, INDEX_LOCK);
|
|
28567
|
+
DELIVERIES = path13.join(KANBAN, "deliveries");
|
|
28568
|
+
RULES = path13.join(KANBAN, "rules");
|
|
28569
|
+
PLANS = path13.join(machine, "plans");
|
|
28570
|
+
PLANS_ARCHIVE = path13.join(PLANS, "archive");
|
|
28571
|
+
TRIAGE = path13.join(KANBAN, "triage");
|
|
28572
|
+
SIGNALS_ARCHIVED = path13.join(TRIAGE, "archived");
|
|
28573
|
+
SIGNALS_DISMISSED = path13.join(TRIAGE, "dismissed");
|
|
28574
|
+
SIGNALS_FILES = path13.join(TRIAGE, "files");
|
|
28575
|
+
SIGNALS_OLD_INBOX = path13.join(TRIAGE, "inbox");
|
|
28576
|
+
SIGNALS_OLD_HANDLED = path13.join(TRIAGE, "handled.md");
|
|
28577
|
+
AKB_DIR = path13.join(REPO_ROOT, ".akb");
|
|
28578
|
+
ROOT_GITIGNORE = path13.join(REPO_ROOT, ".gitignore");
|
|
28579
|
+
LOCK = path13.join(AKB_DIR, boardLockName(KANBAN, REPO_ROOT));
|
|
28580
|
+
return REPO_ROOT;
|
|
28581
|
+
}
|
|
28582
|
+
function setBoardRoot(root2, named = false) {
|
|
28583
|
+
const project = path13.resolve(root2);
|
|
28584
|
+
return setBoard(path13.join(project, "docs", "kanban"), project, named ? ` --dir ${project}` : "");
|
|
28585
|
+
}
|
|
28586
|
+
setBoardRoot(process.cwd());
|
|
28587
|
+
|
|
28588
|
+
// ../cli/src/lib/agent/cloud-studios.ts
|
|
28589
|
+
var DEV = "AI4KANBAN_STUDIOS";
|
|
28590
|
+
var root = () => path14.join(machineHome(), "studios");
|
|
28591
|
+
var safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
28592
|
+
var versionFile = (id, version) => path14.join(root(), "versions", `${safe(id)}@${version}.json`);
|
|
28593
|
+
var listFile = (project) => path14.join(root(), "lists", `${safe(project)}.json`);
|
|
28594
|
+
var pinFile = (task) => path14.join(root(), "tasks", `${safe(task)}.json`);
|
|
28595
|
+
function readJson(file2) {
|
|
28596
|
+
try {
|
|
28597
|
+
return JSON.parse(fs12.readFileSync(file2, "utf8"));
|
|
28598
|
+
} catch {
|
|
28599
|
+
return null;
|
|
28600
|
+
}
|
|
28601
|
+
}
|
|
28602
|
+
var readVersion = (id, version) => readJson(versionFile(id, version));
|
|
28603
|
+
var readPin = (task) => readJson(pinFile(task));
|
|
28604
|
+
var boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
28605
|
+
var devFolder = () => process.env[DEV]?.trim() || "";
|
|
28606
|
+
var flowOf = (held) => {
|
|
28607
|
+
const id = studioName(held.id);
|
|
28608
|
+
const read2 = parseStudioFile(id, held.files["STUDIO.md"] ?? "", `the \`${id}\` studio`);
|
|
28609
|
+
if ("problem" in read2) return null;
|
|
28610
|
+
return { def: read2.def, cloudId: held.id, version: held.version, builtIn: held.id.startsWith("wf_builtin_"), files: held.files };
|
|
28611
|
+
};
|
|
28612
|
+
function readFlows() {
|
|
28613
|
+
const dev = devFolder();
|
|
28614
|
+
if (dev) {
|
|
28615
|
+
return packOfficial(dev, true).flatMap((w) => flowOf({ id: w.id, version: 1, name: w.name, names: w.names, files: w.files }) ?? []);
|
|
28616
|
+
}
|
|
28617
|
+
const project = boardProject();
|
|
28618
|
+
if (!project || !readSession()) return [];
|
|
28619
|
+
const list = readJson(listFile(project))?.studios ?? [];
|
|
28620
|
+
const flows2 = list.flatMap((w) => {
|
|
28621
|
+
const held = readVersion(w.id, w.version);
|
|
28622
|
+
return held ? flowOf(held) ?? [] : [];
|
|
28623
|
+
});
|
|
28624
|
+
const task = workspaceTask();
|
|
28625
|
+
const pin = task ? readPin(task) : null;
|
|
28626
|
+
const pinned = pin && readVersion(pin.studio, pin.version);
|
|
28627
|
+
const mine = pinned && flowOf(pinned);
|
|
28628
|
+
if (!mine) return flows2;
|
|
28629
|
+
return [mine, ...flows2.filter((f) => f.cloudId !== mine.cloudId)];
|
|
27791
28630
|
}
|
|
28631
|
+
var sources = () => {
|
|
28632
|
+
if (devFolder()) return [devFolder()];
|
|
28633
|
+
const project = boardProject();
|
|
28634
|
+
const task = workspaceTask();
|
|
28635
|
+
return [sessionFile(), ...project ? [listFile(project)] : [], ...task ? [pinFile(task)] : []];
|
|
28636
|
+
};
|
|
28637
|
+
var flows = memoByFiles(sources, readFlows);
|
|
27792
28638
|
|
|
27793
28639
|
// src/folders.ts
|
|
27794
|
-
import
|
|
28640
|
+
import fs13 from "node:fs";
|
|
27795
28641
|
import os3 from "node:os";
|
|
27796
|
-
import
|
|
27797
|
-
var projectsFile = () =>
|
|
28642
|
+
import path15 from "node:path";
|
|
28643
|
+
var projectsFile = () => path15.join(runnerHome(), "projects.json");
|
|
27798
28644
|
function realpath(p) {
|
|
27799
28645
|
try {
|
|
27800
|
-
return
|
|
28646
|
+
return fs13.realpathSync(p);
|
|
27801
28647
|
} catch {
|
|
27802
28648
|
return null;
|
|
27803
28649
|
}
|
|
27804
28650
|
}
|
|
27805
28651
|
function readGrants() {
|
|
27806
28652
|
try {
|
|
27807
|
-
const held = JSON.parse(
|
|
28653
|
+
const held = JSON.parse(fs13.readFileSync(projectsFile(), "utf8"));
|
|
27808
28654
|
if (!Array.isArray(held.projects)) throw new Error("invalid_projects");
|
|
27809
28655
|
return held;
|
|
27810
28656
|
} catch (error) {
|
|
@@ -27818,23 +28664,23 @@ function listOf(held) {
|
|
|
27818
28664
|
return subject ? held.accounts[subject] ?? [] : [];
|
|
27819
28665
|
}
|
|
27820
28666
|
function update(change) {
|
|
27821
|
-
|
|
28667
|
+
fs13.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
|
|
27822
28668
|
const lock = `${projectsFile()}.lock`;
|
|
27823
28669
|
let fd;
|
|
27824
28670
|
const until = Date.now() + 2e3;
|
|
27825
28671
|
for (; ; ) {
|
|
27826
28672
|
try {
|
|
27827
|
-
fd =
|
|
27828
|
-
|
|
28673
|
+
fd = fs13.openSync(lock, "wx", 384);
|
|
28674
|
+
fs13.writeFileSync(fd, String(process.pid));
|
|
27829
28675
|
break;
|
|
27830
28676
|
} catch {
|
|
27831
28677
|
try {
|
|
27832
|
-
const pid = Number(
|
|
28678
|
+
const pid = Number(fs13.readFileSync(lock, "utf8"));
|
|
27833
28679
|
if (pid > 0) {
|
|
27834
28680
|
try {
|
|
27835
28681
|
process.kill(pid, 0);
|
|
27836
28682
|
} catch {
|
|
27837
|
-
|
|
28683
|
+
fs13.rmSync(lock, { force: true });
|
|
27838
28684
|
}
|
|
27839
28685
|
}
|
|
27840
28686
|
} catch {
|
|
@@ -27857,13 +28703,13 @@ function update(change) {
|
|
|
27857
28703
|
held.projects = after;
|
|
27858
28704
|
} else held.projects = after;
|
|
27859
28705
|
const tmp = `${projectsFile()}.${process.pid}.tmp`;
|
|
27860
|
-
|
|
28706
|
+
fs13.writeFileSync(tmp, `${JSON.stringify(held, null, 2)}
|
|
27861
28707
|
`, { mode: 384 });
|
|
27862
|
-
|
|
28708
|
+
fs13.renameSync(tmp, projectsFile());
|
|
27863
28709
|
return before.filter((p) => !after.includes(p));
|
|
27864
28710
|
} finally {
|
|
27865
|
-
|
|
27866
|
-
|
|
28711
|
+
fs13.closeSync(fd);
|
|
28712
|
+
fs13.rmSync(lock, { force: true });
|
|
27867
28713
|
}
|
|
27868
28714
|
}
|
|
27869
28715
|
function adoptLegacy() {
|
|
@@ -27878,15 +28724,15 @@ var SYSTEM_WIN = ["Windows", "Program Files", "Program Files (x86)", "ProgramDat
|
|
|
27878
28724
|
var here = () => ({ platform: process.platform, home: os3.homedir(), resolve: realpath });
|
|
27879
28725
|
function refusal(picked, where = here()) {
|
|
27880
28726
|
const win = where.platform === "win32";
|
|
27881
|
-
const p = win ?
|
|
28727
|
+
const p = win ? path15.win32 : path15.posix;
|
|
27882
28728
|
const real = where.resolve(picked);
|
|
27883
|
-
if (!real || !p.isAbsolute(real) || where.resolve === realpath && !
|
|
28729
|
+
if (!real || !p.isAbsolute(real) || where.resolve === realpath && !fs13.statSync(real).isDirectory()) return "missing";
|
|
27884
28730
|
const norm = (d) => {
|
|
27885
28731
|
const n = p.normalize(d).replace(/[\\/]+$/, "") || p.sep;
|
|
27886
28732
|
return win ? n.toLowerCase() : n;
|
|
27887
28733
|
};
|
|
27888
|
-
const within = (dir,
|
|
27889
|
-
const [d, r] = [norm(dir), norm(
|
|
28734
|
+
const within = (dir, root2) => {
|
|
28735
|
+
const [d, r] = [norm(dir), norm(root2)];
|
|
27890
28736
|
return d === r || d.startsWith(r.endsWith(p.sep) ? r : r + p.sep);
|
|
27891
28737
|
};
|
|
27892
28738
|
const forms = [picked, real];
|
|
@@ -27903,16 +28749,16 @@ function refusal(picked, where = here()) {
|
|
|
27903
28749
|
// src/cache.ts
|
|
27904
28750
|
var IDLE_MS = 7 * 24 * 60 * 6e4;
|
|
27905
28751
|
var SWEEP_MS = 24 * 60 * 6e4;
|
|
27906
|
-
var akbDir = (dir) =>
|
|
27907
|
-
var unsentFile = (dir) =>
|
|
27908
|
-
var unsent = (dir) =>
|
|
28752
|
+
var akbDir = (dir) => path16.join(dir, ".akb");
|
|
28753
|
+
var unsentFile = (dir) => path16.join(akbDir(dir), "unsent");
|
|
28754
|
+
var unsent = (dir) => fs14.existsSync(unsentFile(dir));
|
|
27909
28755
|
var holds = /* @__PURE__ */ new Map();
|
|
27910
|
-
var holdsDir = () =>
|
|
27911
|
-
var holdFile = (dir) =>
|
|
28756
|
+
var holdsDir = () => path16.join(runnerHome(), "holds");
|
|
28757
|
+
var holdFile = (dir) => path16.join(holdsDir(), `${crypto6.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
|
|
27912
28758
|
function paused(dir) {
|
|
27913
28759
|
try {
|
|
27914
|
-
const file2 =
|
|
27915
|
-
const held = JSON.parse(
|
|
28760
|
+
const file2 = path16.join(projectStateDir(path16.join(akbDir(dir), "kanban")), SESSIONS_FILE);
|
|
28761
|
+
const held = JSON.parse(fs14.readFileSync(file2, "utf8"));
|
|
27916
28762
|
return (held.deliveries ?? []).some((d) => d.status === "active");
|
|
27917
28763
|
} catch {
|
|
27918
28764
|
return false;
|
|
@@ -27920,14 +28766,14 @@ function paused(dir) {
|
|
|
27920
28766
|
}
|
|
27921
28767
|
function busy(dir) {
|
|
27922
28768
|
if (holds.has(dir)) return true;
|
|
27923
|
-
const prefix =
|
|
28769
|
+
const prefix = path16.basename(holdFile(dir)).split(".")[0] + ".";
|
|
27924
28770
|
try {
|
|
27925
|
-
return
|
|
28771
|
+
return fs14.readdirSync(holdsDir()).filter((file2) => file2.startsWith(prefix)).some((file2) => {
|
|
27926
28772
|
try {
|
|
27927
28773
|
process.kill(Number(file2.split(".")[1]), 0);
|
|
27928
28774
|
return true;
|
|
27929
28775
|
} catch {
|
|
27930
|
-
|
|
28776
|
+
fs14.rmSync(path16.join(holdsDir(), file2), { force: true });
|
|
27931
28777
|
return false;
|
|
27932
28778
|
}
|
|
27933
28779
|
});
|
|
@@ -27938,19 +28784,19 @@ function busy(dir) {
|
|
|
27938
28784
|
var kept = (dir) => busy(dir) || unsent(dir) || paused(dir);
|
|
27939
28785
|
function clearAkb(dir) {
|
|
27940
28786
|
dir = realpath2(dir);
|
|
27941
|
-
if (kept(dir) ||
|
|
28787
|
+
if (kept(dir) || fs14.existsSync(path16.join(akbDir(dir), "worktrees")) || fs14.existsSync(path16.join(akbDir(dir), "handoffs"))) return false;
|
|
27942
28788
|
let entries;
|
|
27943
28789
|
try {
|
|
27944
|
-
entries =
|
|
28790
|
+
entries = fs14.readdirSync(akbDir(dir));
|
|
27945
28791
|
} catch {
|
|
27946
28792
|
return true;
|
|
27947
28793
|
}
|
|
27948
|
-
for (const name of entries)
|
|
28794
|
+
for (const name of entries) fs14.rmSync(path16.join(akbDir(dir), name), { recursive: true, force: true });
|
|
27949
28795
|
return true;
|
|
27950
28796
|
}
|
|
27951
28797
|
function realpath2(p) {
|
|
27952
28798
|
try {
|
|
27953
|
-
return
|
|
28799
|
+
return fs14.realpathSync(p);
|
|
27954
28800
|
} catch {
|
|
27955
28801
|
return p;
|
|
27956
28802
|
}
|
|
@@ -27958,8 +28804,8 @@ function realpath2(p) {
|
|
|
27958
28804
|
|
|
27959
28805
|
// src/kanban-skill.ts
|
|
27960
28806
|
import { spawnSync } from "node:child_process";
|
|
27961
|
-
import
|
|
27962
|
-
import
|
|
28807
|
+
import fs15 from "node:fs";
|
|
28808
|
+
import path17 from "node:path";
|
|
27963
28809
|
|
|
27964
28810
|
// ../skill/SKILL.md
|
|
27965
28811
|
var SKILL_default = '---\nname: kanban\ndescription: Manage the file-based task board with akb. Use for creating and planning tasks, revising or implementing cards, and managing background runs; also for "what\'s running".\n---\n\n# Kanban board\n\nThe board is worked only through `akb`. Find the command for the job in `akb help` and run\nit; never do its work by hand or from memory.\n\n- **`--print` does it here**: `akb raw card revise 12 --print "drop the export"` prints the whole\n flow for that card on this board; follow it to its closing steps. Without `--print` the\n same command starts a separate agent.\n- **Keys**: never read or write API keys; the user sets them with `akb raw agent set apiKey`.\n';
|
|
@@ -27971,26 +28817,26 @@ var CONTENT = `${SKILL_default.trimEnd()}
|
|
|
27971
28817
|
<!-- ai4kanban managed -->
|
|
27972
28818
|
`;
|
|
27973
28819
|
var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
|
|
27974
|
-
function prepareKanbanSkill(
|
|
28820
|
+
function prepareKanbanSkill(root2) {
|
|
27975
28821
|
for (const folder of SKILL_FOLDERS) {
|
|
27976
|
-
const dir =
|
|
27977
|
-
const file2 =
|
|
28822
|
+
const dir = path17.join(root2, folder);
|
|
28823
|
+
const file2 = path17.join(dir, "SKILL.md");
|
|
27978
28824
|
try {
|
|
27979
28825
|
let linked = false;
|
|
27980
|
-
let at =
|
|
28826
|
+
let at = root2;
|
|
27981
28827
|
for (const name of `${folder}/SKILL.md`.split("/")) {
|
|
27982
|
-
at =
|
|
27983
|
-
if (
|
|
28828
|
+
at = path17.join(at, name);
|
|
28829
|
+
if (fs15.lstatSync(at, { throwIfNoEntry: false })?.isSymbolicLink()) linked = true;
|
|
27984
28830
|
}
|
|
27985
|
-
const held =
|
|
27986
|
-
const exists =
|
|
28831
|
+
const held = fs15.existsSync(file2) ? fs15.readFileSync(file2, "utf8") : null;
|
|
28832
|
+
const exists = fs15.lstatSync(dir, { throwIfNoEntry: false }) !== void 0;
|
|
27987
28833
|
if (linked || exists && !MANAGED.test(held ?? "")) {
|
|
27988
28834
|
if (!held?.trim()) throw new Error("\u7528\u6237\u81EA\u6709\u76EE\u5F55\u6216\u7B26\u53F7\u94FE\u63A5\u4E2D\u7F3A\u5C11\u53EF\u8BFB\u7684 SKILL.md");
|
|
27989
28835
|
continue;
|
|
27990
28836
|
}
|
|
27991
28837
|
if (held !== CONTENT) {
|
|
27992
|
-
|
|
27993
|
-
|
|
28838
|
+
fs15.mkdirSync(dir, { recursive: true });
|
|
28839
|
+
fs15.writeFileSync(file2, CONTENT);
|
|
27994
28840
|
}
|
|
27995
28841
|
} catch (e) {
|
|
27996
28842
|
throw new Error(`\u65E0\u6CD5\u51C6\u5907 ${folder}\uFF1A${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -28003,10 +28849,10 @@ function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
|
|
|
28003
28849
|
if (inside.status !== 0) return;
|
|
28004
28850
|
const missing = [".akb/", ...folders2.map((f) => `${f}/`)].filter((p) => git2("check-ignore", "-q", p).status !== 0);
|
|
28005
28851
|
if (!missing.length) return;
|
|
28006
|
-
const exclude =
|
|
28007
|
-
|
|
28008
|
-
const held =
|
|
28009
|
-
|
|
28852
|
+
const exclude = path17.resolve(dir, inside.stdout.trim());
|
|
28853
|
+
fs15.mkdirSync(path17.dirname(exclude), { recursive: true });
|
|
28854
|
+
const held = fs15.existsSync(exclude) ? fs15.readFileSync(exclude, "utf8") : "";
|
|
28855
|
+
fs15.writeFileSync(exclude, `${held}${held && !held.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
|
|
28010
28856
|
`);
|
|
28011
28857
|
}
|
|
28012
28858
|
function installKanbanSkill(dir) {
|
|
@@ -28021,9 +28867,9 @@ function installKanbanSkill(dir) {
|
|
|
28021
28867
|
|
|
28022
28868
|
// src/runtimes.ts
|
|
28023
28869
|
import { spawn as spawn5 } from "node:child_process";
|
|
28024
|
-
import
|
|
28870
|
+
import fs22 from "node:fs";
|
|
28025
28871
|
import os5 from "node:os";
|
|
28026
|
-
import
|
|
28872
|
+
import path25 from "node:path";
|
|
28027
28873
|
|
|
28028
28874
|
// ../cli/src/lib/agent/argv.ts
|
|
28029
28875
|
function splitCommand(command) {
|
|
@@ -28057,8 +28903,8 @@ function splitCommand(command) {
|
|
|
28057
28903
|
|
|
28058
28904
|
// ../cli/src/lib/agent/harnesses/types.ts
|
|
28059
28905
|
import { createHash } from "node:crypto";
|
|
28060
|
-
import
|
|
28061
|
-
import
|
|
28906
|
+
import fs16 from "node:fs";
|
|
28907
|
+
import path18 from "node:path";
|
|
28062
28908
|
var SKILL_SENTENCE = "Use the kanban skill";
|
|
28063
28909
|
function namesFlag(argv, flags) {
|
|
28064
28910
|
return argv.some((tok) => flags.some((flag) => tok === flag || tok.startsWith(`${flag}=`)));
|
|
@@ -28079,15 +28925,15 @@ var MCP_CONFIG = {
|
|
|
28079
28925
|
placeholder: "/path/to/mcp.json",
|
|
28080
28926
|
help: "A JSON file of `mcpServers`, as Claude Code's --mcp-config takes. Empty opens no servers."
|
|
28081
28927
|
};
|
|
28082
|
-
function machineFile(name,
|
|
28083
|
-
const suffix = createHash("sha256").update(
|
|
28084
|
-
const file2 =
|
|
28928
|
+
function machineFile(name, text3) {
|
|
28929
|
+
const suffix = createHash("sha256").update(text3).digest("hex").slice(0, 16);
|
|
28930
|
+
const file2 = path18.join(machineHome(), "prompts", `${path18.parse(name).name}-${suffix}${path18.extname(name)}`);
|
|
28085
28931
|
try {
|
|
28086
|
-
if (
|
|
28932
|
+
if (fs16.readFileSync(file2, "utf8") === text3) return file2;
|
|
28087
28933
|
} catch {
|
|
28088
28934
|
}
|
|
28089
|
-
|
|
28090
|
-
|
|
28935
|
+
fs16.mkdirSync(path18.dirname(file2), { recursive: true });
|
|
28936
|
+
fs16.writeFileSync(file2, text3);
|
|
28091
28937
|
return file2;
|
|
28092
28938
|
}
|
|
28093
28939
|
|
|
@@ -28169,13 +29015,13 @@ function checkHarnesses(harnesses) {
|
|
|
28169
29015
|
}
|
|
28170
29016
|
|
|
28171
29017
|
// ../cli/src/lib/agent/harnesses/claude-code.ts
|
|
28172
|
-
import
|
|
29018
|
+
import path22 from "node:path";
|
|
28173
29019
|
|
|
28174
29020
|
// ../cli/src/lib/agent/locate.ts
|
|
28175
29021
|
import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
|
|
28176
|
-
import
|
|
29022
|
+
import fs18 from "node:fs";
|
|
28177
29023
|
import os4 from "node:os";
|
|
28178
|
-
import
|
|
29024
|
+
import path20 from "node:path";
|
|
28179
29025
|
|
|
28180
29026
|
// ../cli/src/lib/agent/installed.ts
|
|
28181
29027
|
var WINDOWS = process.platform === "win32";
|
|
@@ -28184,8 +29030,8 @@ function commandBinary(command) {
|
|
|
28184
29030
|
}
|
|
28185
29031
|
|
|
28186
29032
|
// ../cli/src/lib/agent/spawnable.ts
|
|
28187
|
-
import
|
|
28188
|
-
import
|
|
29033
|
+
import fs17 from "node:fs";
|
|
29034
|
+
import path19 from "node:path";
|
|
28189
29035
|
var META = /([()\][%!^"`<>&|;, *?])/g;
|
|
28190
29036
|
function cmdArg(arg) {
|
|
28191
29037
|
const quoted = `"${arg.replace(/\r?\n|\r/g, " ").replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1")}"`;
|
|
@@ -28194,22 +29040,22 @@ function cmdArg(arg) {
|
|
|
28194
29040
|
function cmdLine(file2, args) {
|
|
28195
29041
|
return `"${[file2.replace(META, "^$1"), ...args.map(cmdArg)].join(" ")}"`;
|
|
28196
29042
|
}
|
|
28197
|
-
function shimTarget(
|
|
28198
|
-
const dir =
|
|
28199
|
-
const found = /"%(?:~dp0|dp0%)\\?([^"%]+)"\s+%\*/i.exec(
|
|
28200
|
-
if (!found || !/\\node\.exe"/i.test(
|
|
28201
|
-
const script =
|
|
28202
|
-
const local =
|
|
28203
|
-
const nodePath = /SET "NODE_PATH=([^"]*)"/i.exec(
|
|
28204
|
-
return { script, node:
|
|
29043
|
+
function shimTarget(text3, file2) {
|
|
29044
|
+
const dir = path19.win32.dirname(file2);
|
|
29045
|
+
const found = /"%(?:~dp0|dp0%)\\?([^"%]+)"\s+%\*/i.exec(text3);
|
|
29046
|
+
if (!found || !/\\node\.exe"/i.test(text3)) return null;
|
|
29047
|
+
const script = path19.win32.resolve(dir, found[1].replace(/\//g, "\\"));
|
|
29048
|
+
const local = path19.win32.join(dir, "node.exe");
|
|
29049
|
+
const nodePath = /SET "NODE_PATH=([^"]*)"/i.exec(text3)?.[1];
|
|
29050
|
+
return { script, node: fs17.existsSync(local) ? local : "node", env: nodePath ? { NODE_PATH: nodePath } : {} };
|
|
28205
29051
|
}
|
|
28206
29052
|
function onWindowsPath(name, env2) {
|
|
28207
29053
|
const exts = (env2.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
28208
29054
|
const key = Object.keys(env2).find((k) => k.toUpperCase() === "PATH") ?? "PATH";
|
|
28209
29055
|
for (const dir of (env2[key] ?? "").split(";").filter(Boolean)) {
|
|
28210
29056
|
for (const ext of exts) {
|
|
28211
|
-
const file2 =
|
|
28212
|
-
if (
|
|
29057
|
+
const file2 = path19.win32.join(dir, `${name}${ext.toLowerCase()}`);
|
|
29058
|
+
if (fs17.existsSync(file2)) return file2;
|
|
28213
29059
|
}
|
|
28214
29060
|
}
|
|
28215
29061
|
return void 0;
|
|
@@ -28217,16 +29063,16 @@ function onWindowsPath(name, env2) {
|
|
|
28217
29063
|
function spawnable(command, args, options = {}, platform = process.platform) {
|
|
28218
29064
|
if (platform !== "win32") return { command, args, options };
|
|
28219
29065
|
const env2 = options.env ?? process.env;
|
|
28220
|
-
const file2 =
|
|
28221
|
-
const ext =
|
|
29066
|
+
const file2 = path19.extname(command) || /[\\/]/.test(command) ? command : onWindowsPath(command, env2) ?? command;
|
|
29067
|
+
const ext = path19.extname(file2).toLowerCase();
|
|
28222
29068
|
const hidden = { ...options, windowsHide: true, shell: false };
|
|
28223
29069
|
if (ext !== ".cmd" && ext !== ".bat") return { command: file2, args, options: hidden };
|
|
28224
|
-
let
|
|
29070
|
+
let text3 = "";
|
|
28225
29071
|
try {
|
|
28226
|
-
|
|
29072
|
+
text3 = fs17.readFileSync(file2, "utf8");
|
|
28227
29073
|
} catch {
|
|
28228
29074
|
}
|
|
28229
|
-
const shim = shimTarget(
|
|
29075
|
+
const shim = shimTarget(text3, file2);
|
|
28230
29076
|
if (shim) {
|
|
28231
29077
|
return { command: shim.node, args: [shim.script, ...args], options: { ...hidden, env: { ...env2, ...shim.env } } };
|
|
28232
29078
|
}
|
|
@@ -28268,33 +29114,33 @@ function compareVersions(a, b) {
|
|
|
28268
29114
|
}
|
|
28269
29115
|
function newest(copies) {
|
|
28270
29116
|
let best = copies[0] ?? null;
|
|
28271
|
-
for (const
|
|
28272
|
-
if (!
|
|
29117
|
+
for (const copy2 of copies) {
|
|
29118
|
+
if (!copy2.version) return null;
|
|
28273
29119
|
for (const other of copies) {
|
|
28274
|
-
if (!other.version || compareVersions(
|
|
29120
|
+
if (!other.version || compareVersions(copy2.version, other.version) === null) return null;
|
|
28275
29121
|
}
|
|
28276
|
-
if (compareVersions(
|
|
29122
|
+
if (compareVersions(copy2.version, best.version) > 0) best = copy2;
|
|
28277
29123
|
}
|
|
28278
29124
|
return best;
|
|
28279
29125
|
}
|
|
28280
29126
|
function pick(copies) {
|
|
28281
|
-
const live = copies.filter((
|
|
28282
|
-
if (!live.length) return copies.find((
|
|
28283
|
-
const entry2 = live.find((
|
|
29127
|
+
const live = copies.filter((copy2) => copy2.starts);
|
|
29128
|
+
if (!live.length) return copies.find((copy2) => copy2.entry) ?? copies[0] ?? null;
|
|
29129
|
+
const entry2 = live.find((copy2) => copy2.entry);
|
|
28284
29130
|
const best = newest(live);
|
|
28285
29131
|
if (best) return entry2 && compareVersions(entry2.version, best.version) === 0 ? entry2 : best;
|
|
28286
|
-
return entry2 ?? newest(live.filter((
|
|
29132
|
+
return entry2 ?? newest(live.filter((copy2) => copy2.version)) ?? live[0];
|
|
28287
29133
|
}
|
|
28288
29134
|
function folders(parent) {
|
|
28289
29135
|
try {
|
|
28290
|
-
return
|
|
29136
|
+
return fs18.readdirSync(parent, { withFileTypes: true }).filter((one) => one.isDirectory()).map((one) => one.name);
|
|
28291
29137
|
} catch {
|
|
28292
29138
|
return [];
|
|
28293
29139
|
}
|
|
28294
29140
|
}
|
|
28295
|
-
function byVersion(
|
|
29141
|
+
function byVersion(names2) {
|
|
28296
29142
|
const numbers = (name) => /(\d+(?:\.\d+)+)/.exec(name)?.[1]?.split(".").map(Number) ?? [];
|
|
28297
|
-
return [...
|
|
29143
|
+
return [...names2].sort((a, b) => {
|
|
28298
29144
|
const [x, y] = [numbers(a), numbers(b)];
|
|
28299
29145
|
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
|
28300
29146
|
const step = (y[i] ?? -1) - (x[i] ?? -1);
|
|
@@ -28304,31 +29150,31 @@ function byVersion(names) {
|
|
|
28304
29150
|
});
|
|
28305
29151
|
}
|
|
28306
29152
|
function latestIn(parent, tail = "") {
|
|
28307
|
-
let
|
|
29153
|
+
let names2;
|
|
28308
29154
|
try {
|
|
28309
|
-
|
|
29155
|
+
names2 = fs18.readdirSync(parent);
|
|
28310
29156
|
} catch {
|
|
28311
29157
|
return [];
|
|
28312
29158
|
}
|
|
28313
|
-
return byVersion(
|
|
29159
|
+
return byVersion(names2.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) => path20.join(parent, name, tail));
|
|
28314
29160
|
}
|
|
28315
29161
|
var env = (name) => process.env[name]?.trim() ?? "";
|
|
28316
29162
|
function commonDirs() {
|
|
28317
29163
|
const home3 = os4.homedir();
|
|
28318
|
-
const under = (...parts) =>
|
|
28319
|
-
const nodes = (
|
|
29164
|
+
const under = (...parts) => path20.join(home3, ...parts);
|
|
29165
|
+
const nodes = (root2, tail = []) => root2 ? folders(root2).map((version) => path20.join(root2, version, ...tail)) : [];
|
|
28320
29166
|
if (WINDOWS2) {
|
|
28321
29167
|
const [app, local, data, programs] = [env("APPDATA"), env("LOCALAPPDATA"), env("ProgramData"), env("ProgramFiles")];
|
|
28322
29168
|
return [
|
|
28323
29169
|
under(".local", "bin"),
|
|
28324
29170
|
under(".bun", "bin"),
|
|
28325
29171
|
under("scoop", "shims"),
|
|
28326
|
-
...app ? [
|
|
28327
|
-
...local ? [
|
|
28328
|
-
...data ? [
|
|
28329
|
-
...programs ? [
|
|
29172
|
+
...app ? [path20.join(app, "npm")] : [],
|
|
29173
|
+
...local ? [path20.join(local, "pnpm"), path20.join(local, "Volta", "bin"), path20.join(local, "Microsoft", "WinGet", "Links")] : [],
|
|
29174
|
+
...data ? [path20.join(data, "chocolatey", "bin")] : [],
|
|
29175
|
+
...programs ? [path20.join(programs, "nodejs")] : [],
|
|
28330
29176
|
...nodes(env("NVM_HOME")),
|
|
28331
|
-
...app ? nodes(
|
|
29177
|
+
...app ? nodes(path20.join(app, "fnm", "node-versions"), ["installation"]) : []
|
|
28332
29178
|
];
|
|
28333
29179
|
}
|
|
28334
29180
|
const support = process.platform === "darwin" ? under("Library", "Application Support") : under(".local", "share");
|
|
@@ -28345,22 +29191,22 @@ function commonDirs() {
|
|
|
28345
29191
|
...env("PNPM_HOME") ? [env("PNPM_HOME")] : [],
|
|
28346
29192
|
under("Library", "pnpm"),
|
|
28347
29193
|
under(".local", "share", "pnpm"),
|
|
28348
|
-
|
|
28349
|
-
...nodes(
|
|
28350
|
-
...nodes(
|
|
28351
|
-
...nodes(
|
|
29194
|
+
path20.join(env("VOLTA_HOME") || under(".volta"), "bin"),
|
|
29195
|
+
...nodes(path20.join(env("NVM_DIR") || under(".nvm"), "versions", "node"), ["bin"]),
|
|
29196
|
+
...nodes(path20.join(env("FNM_DIR") || path20.join(support, "fnm"), "node-versions"), ["installation", "bin"]),
|
|
29197
|
+
...nodes(path20.join(env("ASDF_DATA_DIR") || under(".asdf"), "installs", "nodejs"), ["bin"]),
|
|
28352
29198
|
...nodes(under(".local", "share", "mise", "installs", "node"), ["bin"]),
|
|
28353
29199
|
...nodes(under(".nodenv", "versions"), ["bin"]),
|
|
28354
29200
|
...nodes("/usr/local/n/versions/node", ["bin"])
|
|
28355
29201
|
];
|
|
28356
29202
|
}
|
|
28357
29203
|
function onPath(binary) {
|
|
28358
|
-
const
|
|
28359
|
-
return (process.env.PATH ?? "").split(
|
|
29204
|
+
const names2 = WINDOWS2 ? (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((ext) => `${binary}${ext.toLowerCase()}`) : [binary];
|
|
29205
|
+
return (process.env.PATH ?? "").split(path20.delimiter).filter(Boolean).flatMap((dir) => names2.map((name) => path20.join(dir, name)));
|
|
28360
29206
|
}
|
|
28361
29207
|
var isFile = (file2) => {
|
|
28362
29208
|
try {
|
|
28363
|
-
return
|
|
29209
|
+
return fs18.statSync(file2).isFile();
|
|
28364
29210
|
} catch {
|
|
28365
29211
|
return false;
|
|
28366
29212
|
}
|
|
@@ -28369,24 +29215,24 @@ function copyFiles(harness) {
|
|
|
28369
29215
|
const pinned = harness.pinned?.();
|
|
28370
29216
|
if (pinned && isFile(pinned)) return [{ file: pinned, entry: false }];
|
|
28371
29217
|
const binary = commandBinary(harness.command);
|
|
28372
|
-
const exe = (file2) => WINDOWS2 && !
|
|
29218
|
+
const exe = (file2) => WINDOWS2 && !path20.extname(file2) ? [`${file2}.exe`, `${file2}.cmd`] : [file2];
|
|
28373
29219
|
const path_ = onPath(binary).filter(isFile);
|
|
28374
|
-
const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) =>
|
|
29220
|
+
const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) => path20.join(dir, binary))];
|
|
28375
29221
|
const others = elsewhere.flatMap(exe).filter(isFile);
|
|
28376
29222
|
const seen = /* @__PURE__ */ new Set();
|
|
28377
29223
|
return [...path_, ...others].flatMap((file2, i) => {
|
|
28378
|
-
const real =
|
|
29224
|
+
const real = fs18.realpathSync.native(file2);
|
|
28379
29225
|
if (seen.has(real)) return [];
|
|
28380
29226
|
seen.add(real);
|
|
28381
29227
|
return [{ file: file2, entry: i === 0 && path_.length > 0 }];
|
|
28382
29228
|
});
|
|
28383
29229
|
}
|
|
28384
29230
|
var answers;
|
|
28385
|
-
var answersFile = () =>
|
|
29231
|
+
var answersFile = () => path20.join(machineHome(), "agent-copies.json");
|
|
28386
29232
|
function kept2() {
|
|
28387
29233
|
if (answers) return answers;
|
|
28388
29234
|
try {
|
|
28389
|
-
answers = JSON.parse(
|
|
29235
|
+
answers = JSON.parse(fs18.readFileSync(answersFile(), "utf8"));
|
|
28390
29236
|
} catch {
|
|
28391
29237
|
answers = {};
|
|
28392
29238
|
}
|
|
@@ -28395,16 +29241,16 @@ function kept2() {
|
|
|
28395
29241
|
function keep(file2, answer) {
|
|
28396
29242
|
kept2()[file2] = answer;
|
|
28397
29243
|
try {
|
|
28398
|
-
|
|
29244
|
+
fs18.mkdirSync(machineHome(), { recursive: true });
|
|
28399
29245
|
const staged = `${answersFile()}.${process.pid}`;
|
|
28400
|
-
|
|
28401
|
-
|
|
29246
|
+
fs18.writeFileSync(staged, JSON.stringify(answers));
|
|
29247
|
+
fs18.renameSync(staged, answersFile());
|
|
28402
29248
|
} catch {
|
|
28403
29249
|
}
|
|
28404
29250
|
}
|
|
28405
29251
|
function keyOf(file2) {
|
|
28406
|
-
const real =
|
|
28407
|
-
const stat =
|
|
29252
|
+
const real = fs18.realpathSync.native(file2);
|
|
29253
|
+
const stat = fs18.statSync(real);
|
|
28408
29254
|
return `${real}|${stat.size}|${stat.mtimeMs}`;
|
|
28409
29255
|
}
|
|
28410
29256
|
function known(file2, maxAge) {
|
|
@@ -28417,8 +29263,8 @@ function judge(code, status2, stdout, stderr) {
|
|
|
28417
29263
|
return { starts: true, version: status2 === 0 ? versionIn(stdout) ?? versionIn(stderr) : null };
|
|
28418
29264
|
}
|
|
28419
29265
|
function copyEnv(file2, given = process.env) {
|
|
28420
|
-
if (!
|
|
28421
|
-
return { ...given, PATH: [
|
|
29266
|
+
if (!path20.isAbsolute(file2)) return given;
|
|
29267
|
+
return { ...given, PATH: [path20.dirname(file2), given.PATH].filter(Boolean).join(path20.delimiter) };
|
|
28422
29268
|
}
|
|
28423
29269
|
var probeOptions = (file2) => ({ cwd: os4.tmpdir(), env: copyEnv(file2), windowsHide: true, shell: false });
|
|
28424
29270
|
function probe(file2) {
|
|
@@ -28467,13 +29313,13 @@ function chooseCopy(harness, maxAge = KEEP_MS) {
|
|
|
28467
29313
|
const files = copyFiles(harness);
|
|
28468
29314
|
return files.length === 1 ? { ...files[0], starts: true, version: null } : locate(harness, maxAge);
|
|
28469
29315
|
}
|
|
28470
|
-
var spawnName = (
|
|
29316
|
+
var spawnName = (copy2, binary) => copy2 && (!copy2.entry || /\.(cmd|bat)$/i.test(copy2.file)) ? copy2.file : binary;
|
|
28471
29317
|
|
|
28472
29318
|
// ../cli/src/lib/agent/wire/json.ts
|
|
28473
29319
|
function obj(value) {
|
|
28474
29320
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
28475
29321
|
}
|
|
28476
|
-
function
|
|
29322
|
+
function str2(value) {
|
|
28477
29323
|
return typeof value === "string" ? value : "";
|
|
28478
29324
|
}
|
|
28479
29325
|
function num(value) {
|
|
@@ -28487,7 +29333,7 @@ function hint(raw) {
|
|
|
28487
29333
|
function argHint(input, keys) {
|
|
28488
29334
|
const args = obj(input);
|
|
28489
29335
|
for (const key of keys) {
|
|
28490
|
-
const value =
|
|
29336
|
+
const value = str2(args[key]);
|
|
28491
29337
|
if (value.trim()) return hint(value);
|
|
28492
29338
|
}
|
|
28493
29339
|
return "";
|
|
@@ -28495,7 +29341,7 @@ function argHint(input, keys) {
|
|
|
28495
29341
|
|
|
28496
29342
|
// ../cli/src/lib/agent/wire/events.ts
|
|
28497
29343
|
var TOOL_KINDS = ["read", "edit", "delete", "move", "search", "execute", "fetch", "other"];
|
|
28498
|
-
var toolKind = (v) => TOOL_KINDS.includes(
|
|
29344
|
+
var toolKind = (v) => TOOL_KINDS.includes(str2(v)) ? v : "other";
|
|
28499
29345
|
function targetOf(raw) {
|
|
28500
29346
|
const line = raw.split("\n")[0].trim();
|
|
28501
29347
|
if (!line) return void 0;
|
|
@@ -28505,28 +29351,28 @@ function contentText(raw) {
|
|
|
28505
29351
|
const parts = Array.isArray(raw) ? raw : [];
|
|
28506
29352
|
return parts.map((p) => {
|
|
28507
29353
|
const part = obj(p);
|
|
28508
|
-
if (part.type === "diff") return
|
|
28509
|
-
return
|
|
29354
|
+
if (part.type === "diff") return str2(part.path);
|
|
29355
|
+
return str2(obj(part.content).text) || str2(part.text);
|
|
28510
29356
|
}).filter((t2) => t2.trim()).join("\n");
|
|
28511
29357
|
}
|
|
28512
29358
|
function statusOf(raw) {
|
|
28513
|
-
const s =
|
|
29359
|
+
const s = str2(raw).toLowerCase();
|
|
28514
29360
|
if (s.includes("progress")) return "in_progress";
|
|
28515
29361
|
if (/complete|done|cancel/.test(s)) return "completed";
|
|
28516
29362
|
return "pending";
|
|
28517
29363
|
}
|
|
28518
29364
|
function entriesOf(raw) {
|
|
28519
29365
|
return (Array.isArray(raw) ? raw : []).map(obj).flatMap((e) => {
|
|
28520
|
-
const content =
|
|
29366
|
+
const content = str2(e.content).trim();
|
|
28521
29367
|
if (!content) return [];
|
|
28522
|
-
return [{ content, status: statusOf(e.status), ...
|
|
29368
|
+
return [{ content, status: statusOf(e.status), ...str2(e.priority) ? { priority: str2(e.priority) } : {} }];
|
|
28523
29369
|
});
|
|
28524
29370
|
}
|
|
28525
|
-
var isTodoCall = (u) =>
|
|
28526
|
-
var inputTarget = (input) =>
|
|
29371
|
+
var isTodoCall = (u) => str2(u.title) === "todowrite" || str2(obj(u.rawInput)._toolName) === "updateTodos";
|
|
29372
|
+
var inputTarget = (input) => str2(input.command) || str2(input.path) || str2(input.filePath);
|
|
28527
29373
|
var targetIn = (u) => {
|
|
28528
29374
|
const locations = Array.isArray(u.locations) ? u.locations : [];
|
|
28529
|
-
return targetOf(inputTarget(obj(u.rawInput)) ||
|
|
29375
|
+
return targetOf(inputTarget(obj(u.rawInput)) || str2(obj(locations[0]).path) || "");
|
|
28530
29376
|
};
|
|
28531
29377
|
function createEventCollector() {
|
|
28532
29378
|
let queue = [];
|
|
@@ -28539,39 +29385,39 @@ function createEventCollector() {
|
|
|
28539
29385
|
said = "";
|
|
28540
29386
|
};
|
|
28541
29387
|
const release = (id, target) => {
|
|
28542
|
-
const
|
|
28543
|
-
if (!
|
|
29388
|
+
const call2 = held.get(id);
|
|
29389
|
+
if (!call2) return;
|
|
28544
29390
|
held.delete(id);
|
|
28545
|
-
queue.push({ kind: "tool_call", data: { ...
|
|
29391
|
+
queue.push({ kind: "tool_call", data: { ...call2, ...target ? { target } : {} } });
|
|
28546
29392
|
};
|
|
28547
29393
|
return {
|
|
28548
29394
|
/** One ACP `session/update`'s `update`. Thoughts and housekeeping updates yield nothing. */
|
|
28549
29395
|
update(raw) {
|
|
28550
29396
|
const u = obj(raw);
|
|
28551
29397
|
if (u.sessionUpdate === "agent_message_chunk") {
|
|
28552
|
-
said +=
|
|
29398
|
+
said += str2(obj(u.content).text);
|
|
28553
29399
|
return;
|
|
28554
29400
|
}
|
|
28555
|
-
if (!["tool_call", "tool_call_update", "plan"].includes(
|
|
29401
|
+
if (!["tool_call", "tool_call_update", "plan"].includes(str2(u.sessionUpdate))) return;
|
|
28556
29402
|
close();
|
|
28557
29403
|
switch (u.sessionUpdate) {
|
|
28558
29404
|
case "tool_call": {
|
|
28559
|
-
const id =
|
|
29405
|
+
const id = str2(u.toolCallId);
|
|
28560
29406
|
if (isTodoCall(u)) {
|
|
28561
29407
|
todoCalls.add(id);
|
|
28562
29408
|
return;
|
|
28563
29409
|
}
|
|
28564
29410
|
const target = targetIn(u);
|
|
28565
|
-
const data = { toolCallId: id, title:
|
|
29411
|
+
const data = { toolCallId: id, title: str2(u.title) || "tool", kind: toolKind(u.kind), status: str2(u.status) || "pending", ...target ? { target } : {} };
|
|
28566
29412
|
if (u.rawInput !== void 0 && !inputTarget(obj(u.rawInput))) held.set(id, data);
|
|
28567
29413
|
else queue.push({ kind: "tool_call", data });
|
|
28568
29414
|
return;
|
|
28569
29415
|
}
|
|
28570
29416
|
case "tool_call_update": {
|
|
28571
|
-
const id =
|
|
29417
|
+
const id = str2(u.toolCallId);
|
|
28572
29418
|
if (todoCalls.has(id)) {
|
|
28573
29419
|
const list = obj(u.rawInput).todos;
|
|
28574
|
-
if (Array.isArray(list) && !
|
|
29420
|
+
if (Array.isArray(list) && !str2(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list) } });
|
|
28575
29421
|
return;
|
|
28576
29422
|
}
|
|
28577
29423
|
release(id, targetIn(u));
|
|
@@ -28579,7 +29425,7 @@ function createEventCollector() {
|
|
|
28579
29425
|
if (!u.status && !result) return;
|
|
28580
29426
|
queue.push({
|
|
28581
29427
|
kind: "tool_call_update",
|
|
28582
|
-
data: { toolCallId:
|
|
29428
|
+
data: { toolCallId: str2(u.toolCallId), status: str2(u.status) || "in_progress", ...result ? { result } : {} }
|
|
28583
29429
|
});
|
|
28584
29430
|
return;
|
|
28585
29431
|
}
|
|
@@ -28589,9 +29435,9 @@ function createEventCollector() {
|
|
|
28589
29435
|
}
|
|
28590
29436
|
},
|
|
28591
29437
|
/** A whole message, for a source that never sends one in pieces. */
|
|
28592
|
-
message(
|
|
29438
|
+
message(text3) {
|
|
28593
29439
|
close();
|
|
28594
|
-
if (
|
|
29440
|
+
if (text3.trim()) queue.push({ kind: "message", data: { text: text3.trim() } });
|
|
28595
29441
|
},
|
|
28596
29442
|
toolCall(toolCallId, title, kind, target) {
|
|
28597
29443
|
close();
|
|
@@ -28616,7 +29462,7 @@ function createEventCollector() {
|
|
|
28616
29462
|
close();
|
|
28617
29463
|
const items = (Array.isArray(raw) ? raw : []).map(obj).flatMap((e) => {
|
|
28618
29464
|
const [entry2] = entriesOf([e]);
|
|
28619
|
-
return entry2 ? [{ ...entry2, id:
|
|
29465
|
+
return entry2 ? [{ ...entry2, id: str2(e.id) }] : [];
|
|
28620
29466
|
});
|
|
28621
29467
|
const next = merge ? [...todos] : [];
|
|
28622
29468
|
for (const item of items) {
|
|
@@ -28627,13 +29473,13 @@ function createEventCollector() {
|
|
|
28627
29473
|
todos = next;
|
|
28628
29474
|
queue.push({ kind: "plan", data: { entries: todos.map(({ id: _, ...e }) => e) } });
|
|
28629
29475
|
},
|
|
28630
|
-
log(
|
|
29476
|
+
log(text3) {
|
|
28631
29477
|
close();
|
|
28632
|
-
if (
|
|
29478
|
+
if (text3.trim()) queue.push({ kind: "log", data: { text: text3 } });
|
|
28633
29479
|
},
|
|
28634
|
-
error(
|
|
29480
|
+
error(text3) {
|
|
28635
29481
|
close();
|
|
28636
|
-
if (
|
|
29482
|
+
if (text3.trim()) queue.push({ kind: "error", data: { text: text3.trim() } });
|
|
28637
29483
|
},
|
|
28638
29484
|
/** The turn is over: a half-held message is finished off. */
|
|
28639
29485
|
end() {
|
|
@@ -28693,12 +29539,12 @@ var TOOL_KINDS2 = {
|
|
|
28693
29539
|
var SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task"]);
|
|
28694
29540
|
function targetOf2(input) {
|
|
28695
29541
|
const args = obj(input);
|
|
28696
|
-
for (const key of ARG_KEYS) if (
|
|
29542
|
+
for (const key of ARG_KEYS) if (str2(args[key]).trim()) return str2(args[key]);
|
|
28697
29543
|
return "";
|
|
28698
29544
|
}
|
|
28699
29545
|
function resultText(raw) {
|
|
28700
29546
|
if (typeof raw === "string") return raw;
|
|
28701
|
-
return (Array.isArray(raw) ? raw : []).map((b) =>
|
|
29547
|
+
return (Array.isArray(raw) ? raw : []).map((b) => str2(obj(b).text)).filter(Boolean).join("\n");
|
|
28702
29548
|
}
|
|
28703
29549
|
function eventModel(ev) {
|
|
28704
29550
|
if (ev.type === "system" && ev.subtype === "init" && typeof ev.model === "string") {
|
|
@@ -28721,17 +29567,17 @@ var USER_FIXES = [
|
|
|
28721
29567
|
[/usage limit|credit balance is too low|quota/i, "Wait for the usage limit to reset, or add credit, then press Resume."]
|
|
28722
29568
|
];
|
|
28723
29569
|
function failedWith(ev) {
|
|
28724
|
-
const errors = Array.isArray(ev.errors) ? ev.errors.map(
|
|
29570
|
+
const errors = Array.isArray(ev.errors) ? ev.errors.map(str2).filter(Boolean) : [];
|
|
28725
29571
|
if (errors.length) return errors.join("; ");
|
|
28726
|
-
const named =
|
|
29572
|
+
const named = str2(ev.subtype) || str2(ev.terminal_reason);
|
|
28727
29573
|
if (named && named !== "error" && named !== "success") return named;
|
|
28728
|
-
return
|
|
29574
|
+
return str2(ev.result).trim() || "the agent reported the session failed";
|
|
28729
29575
|
}
|
|
28730
29576
|
function denials(ev) {
|
|
28731
29577
|
const list = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
|
|
28732
|
-
const
|
|
28733
|
-
if (!
|
|
28734
|
-
return `[refused] ${list.length} tool call${list.length === 1 ? "" : "s"} were not allowed: ${
|
|
29578
|
+
const names2 = [...new Set(list.map((raw) => str2(obj(raw).tool_name)).filter(Boolean))];
|
|
29579
|
+
if (!names2.length) return "";
|
|
29580
|
+
return `[refused] ${list.length} tool call${list.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
|
|
28735
29581
|
`;
|
|
28736
29582
|
}
|
|
28737
29583
|
function promptSize(raw) {
|
|
@@ -28741,8 +29587,8 @@ function promptSize(raw) {
|
|
|
28741
29587
|
}
|
|
28742
29588
|
function windowOf(raw, model) {
|
|
28743
29589
|
const entries = obj(raw);
|
|
28744
|
-
const
|
|
28745
|
-
const name = model &&
|
|
29590
|
+
const names2 = Object.keys(entries);
|
|
29591
|
+
const name = model && names2.includes(model) ? model : names2.length === 1 ? names2[0] : void 0;
|
|
28746
29592
|
return name ? num(obj(entries[name]).contextWindow) || void 0 : void 0;
|
|
28747
29593
|
}
|
|
28748
29594
|
function createStreamRenderer() {
|
|
@@ -28775,7 +29621,7 @@ function createStreamRenderer() {
|
|
|
28775
29621
|
`;
|
|
28776
29622
|
}
|
|
28777
29623
|
if (model === void 0) model = eventModel(ev);
|
|
28778
|
-
if (
|
|
29624
|
+
if (str2(ev.parent_tool_use_id)) return "";
|
|
28779
29625
|
switch (ev.type) {
|
|
28780
29626
|
case "assistant": {
|
|
28781
29627
|
const msg = ev.message;
|
|
@@ -28795,14 +29641,14 @@ function createStreamRenderer() {
|
|
|
28795
29641
|
`);
|
|
28796
29642
|
if (SUBAGENT_TOOLS.has(b.name)) {
|
|
28797
29643
|
const input = obj(b.input);
|
|
28798
|
-
subagents.set(
|
|
28799
|
-
if (input.run_in_background === true) detached.add(
|
|
28800
|
-
events.subagent(
|
|
29644
|
+
subagents.set(str2(b.id), false);
|
|
29645
|
+
if (input.run_in_background === true) detached.add(str2(b.id));
|
|
29646
|
+
events.subagent(str2(b.id), str2(input.description) || str2(input.subagent_type) || b.name);
|
|
28801
29647
|
} else if (b.name === "TodoWrite") {
|
|
28802
|
-
plans.add(
|
|
29648
|
+
plans.add(str2(b.id));
|
|
28803
29649
|
events.plan(obj(b.input).todos);
|
|
28804
29650
|
} else {
|
|
28805
|
-
events.toolCall(
|
|
29651
|
+
events.toolCall(str2(b.id), b.name, TOOL_KINDS2[b.name] ?? "other", targetOf2(b.input));
|
|
28806
29652
|
}
|
|
28807
29653
|
}
|
|
28808
29654
|
}
|
|
@@ -28812,12 +29658,12 @@ function createStreamRenderer() {
|
|
|
28812
29658
|
const content = obj(ev.message).content;
|
|
28813
29659
|
for (const raw of Array.isArray(content) ? content : []) {
|
|
28814
29660
|
const b = obj(raw);
|
|
28815
|
-
if (b.type !== "tool_result" || plans.has(
|
|
28816
|
-
if (subagents.has(
|
|
28817
|
-
if (!detached.has(
|
|
29661
|
+
if (b.type !== "tool_result" || plans.has(str2(b.tool_use_id))) continue;
|
|
29662
|
+
if (subagents.has(str2(b.tool_use_id))) {
|
|
29663
|
+
if (!detached.has(str2(b.tool_use_id))) endSubagent(str2(b.tool_use_id), b.is_error === true ? "failed" : "completed");
|
|
28818
29664
|
continue;
|
|
28819
29665
|
}
|
|
28820
|
-
events.toolResult(
|
|
29666
|
+
events.toolResult(str2(b.tool_use_id), b.is_error === true ? "failed" : "completed", resultText(b.content));
|
|
28821
29667
|
}
|
|
28822
29668
|
return "";
|
|
28823
29669
|
}
|
|
@@ -28843,12 +29689,12 @@ function createStreamRenderer() {
|
|
|
28843
29689
|
}
|
|
28844
29690
|
case "system":
|
|
28845
29691
|
if (ev.subtype === "background_tasks_changed" && Array.isArray(ev.tasks)) background = ev.tasks.length;
|
|
28846
|
-
if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(
|
|
28847
|
-
if (ev.subtype === "task_notification" && subagents.has(
|
|
28848
|
-
endSubagent(
|
|
29692
|
+
if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(str2(ev.task_id));
|
|
29693
|
+
if (ev.subtype === "task_notification" && subagents.has(str2(ev.tool_use_id))) {
|
|
29694
|
+
endSubagent(str2(ev.tool_use_id), str2(ev.status) === "completed" ? "completed" : "failed");
|
|
28849
29695
|
}
|
|
28850
|
-
if (ev.subtype === "task_notification" && backgrounded.has(
|
|
28851
|
-
return `\u23FA ${
|
|
29696
|
+
if (ev.subtype === "task_notification" && backgrounded.has(str2(ev.task_id)) && str2(ev.summary)) {
|
|
29697
|
+
return `\u23FA ${str2(ev.summary)}
|
|
28852
29698
|
`;
|
|
28853
29699
|
}
|
|
28854
29700
|
return "";
|
|
@@ -28892,7 +29738,7 @@ var addUsage = (a, b) => ({
|
|
|
28892
29738
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
28893
29739
|
import { homedir } from "node:os";
|
|
28894
29740
|
import { join } from "node:path";
|
|
28895
|
-
function
|
|
29741
|
+
function text2(value) {
|
|
28896
29742
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
28897
29743
|
}
|
|
28898
29744
|
function count(value) {
|
|
@@ -28927,34 +29773,34 @@ function contextIn(raw) {
|
|
|
28927
29773
|
if (!used) return void 0;
|
|
28928
29774
|
return { used, limit: count(info.model_context_window) };
|
|
28929
29775
|
}
|
|
28930
|
-
function dayDir(
|
|
29776
|
+
function dayDir(root2, at) {
|
|
28931
29777
|
const day = new Date(at);
|
|
28932
29778
|
const pad = (n) => String(n).padStart(2, "0");
|
|
28933
|
-
return join(
|
|
29779
|
+
return join(root2, String(day.getFullYear()), pad(day.getMonth() + 1), pad(day.getDate()));
|
|
28934
29780
|
}
|
|
28935
29781
|
function findRollout(threadId) {
|
|
28936
29782
|
const home3 = process.env.CODEX_HOME?.trim() || join(homedir(), ".codex");
|
|
28937
|
-
const
|
|
29783
|
+
const root2 = join(home3, "sessions");
|
|
28938
29784
|
const tail = `-${threadId}.jsonl`;
|
|
28939
29785
|
const minted = parseInt(threadId.replace(/-/g, "").slice(0, 12), 16);
|
|
28940
29786
|
const days = /* @__PURE__ */ new Set();
|
|
28941
29787
|
for (const at of [Date.now(), ...Number.isFinite(minted) && minted > 0 ? [minted] : []]) {
|
|
28942
|
-
for (const shift of [0, -1, 1]) days.add(dayDir(
|
|
29788
|
+
for (const shift of [0, -1, 1]) days.add(dayDir(root2, at + shift * 864e5));
|
|
28943
29789
|
}
|
|
28944
29790
|
let newest2;
|
|
28945
29791
|
for (const dir of days) {
|
|
28946
|
-
let
|
|
29792
|
+
let names2;
|
|
28947
29793
|
try {
|
|
28948
|
-
|
|
29794
|
+
names2 = readdirSync(dir);
|
|
28949
29795
|
} catch {
|
|
28950
29796
|
continue;
|
|
28951
29797
|
}
|
|
28952
|
-
for (const name of
|
|
29798
|
+
for (const name of names2) {
|
|
28953
29799
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
28954
|
-
const
|
|
29800
|
+
const path31 = join(dir, name);
|
|
28955
29801
|
try {
|
|
28956
|
-
const at = statSync(
|
|
28957
|
-
if (!newest2 || at > newest2.at) newest2 = { path:
|
|
29802
|
+
const at = statSync(path31).mtimeMs;
|
|
29803
|
+
if (!newest2 || at > newest2.at) newest2 = { path: path31, at };
|
|
28958
29804
|
} catch {
|
|
28959
29805
|
}
|
|
28960
29806
|
}
|
|
@@ -28962,11 +29808,11 @@ function findRollout(threadId) {
|
|
|
28962
29808
|
return newest2?.path;
|
|
28963
29809
|
}
|
|
28964
29810
|
function readCodexRunFacts(threadId) {
|
|
28965
|
-
const
|
|
28966
|
-
if (!
|
|
29811
|
+
const path31 = findRollout(threadId);
|
|
29812
|
+
if (!path31) return void 0;
|
|
28967
29813
|
let raw;
|
|
28968
29814
|
try {
|
|
28969
|
-
raw = readFileSync(
|
|
29815
|
+
raw = readFileSync(path31, "utf8");
|
|
28970
29816
|
} catch {
|
|
28971
29817
|
return void 0;
|
|
28972
29818
|
}
|
|
@@ -28986,8 +29832,8 @@ function readCodexRunFacts(threadId) {
|
|
|
28986
29832
|
}
|
|
28987
29833
|
const payload = entry2.payload;
|
|
28988
29834
|
if (!payload) continue;
|
|
28989
|
-
if (entry2.type === "session_meta") facts.provider ??=
|
|
28990
|
-
if (entry2.type === "turn_context") facts.model =
|
|
29835
|
+
if (entry2.type === "session_meta") facts.provider ??= text2(payload.model_provider);
|
|
29836
|
+
if (entry2.type === "turn_context") facts.model = text2(payload.model) ?? facts.model;
|
|
28991
29837
|
if (payload.type === "token_count") {
|
|
28992
29838
|
facts.context = contextIn(payload.info) ?? facts.context;
|
|
28993
29839
|
const info = payload.info && typeof payload.info === "object" ? payload.info : {};
|
|
@@ -29050,13 +29896,13 @@ function priceUsd(provider, model, usage) {
|
|
|
29050
29896
|
function renderStarted(item) {
|
|
29051
29897
|
switch (item.type) {
|
|
29052
29898
|
case "command_execution":
|
|
29053
|
-
return `\u23FA Command${hint(
|
|
29899
|
+
return `\u23FA Command${hint(str2(item.command))}
|
|
29054
29900
|
`;
|
|
29055
29901
|
case "mcp_tool_call":
|
|
29056
|
-
return `\u23FA ${
|
|
29902
|
+
return `\u23FA ${str2(item.server)}.${str2(item.tool)}
|
|
29057
29903
|
`;
|
|
29058
29904
|
case "web_search":
|
|
29059
|
-
return `\u23FA WebSearch${hint(
|
|
29905
|
+
return `\u23FA WebSearch${hint(str2(item.query))}
|
|
29060
29906
|
`;
|
|
29061
29907
|
default:
|
|
29062
29908
|
return "";
|
|
@@ -29065,7 +29911,7 @@ function renderStarted(item) {
|
|
|
29065
29911
|
function renderCompleted(item) {
|
|
29066
29912
|
switch (item.type) {
|
|
29067
29913
|
case "agent_message": {
|
|
29068
|
-
const said =
|
|
29914
|
+
const said = str2(item.text).trim();
|
|
29069
29915
|
return said ? `${said}
|
|
29070
29916
|
|
|
29071
29917
|
` : "";
|
|
@@ -29074,17 +29920,17 @@ function renderCompleted(item) {
|
|
|
29074
29920
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
29075
29921
|
return changes.map((raw) => {
|
|
29076
29922
|
const change = obj(raw);
|
|
29077
|
-
const
|
|
29078
|
-
return
|
|
29923
|
+
const path31 = str2(change.path);
|
|
29924
|
+
return path31 ? `\u23FA ${str2(change.kind) || "change"}(${path31})
|
|
29079
29925
|
` : "";
|
|
29080
29926
|
}).join("");
|
|
29081
29927
|
}
|
|
29082
29928
|
case "error":
|
|
29083
|
-
return `[error] ${
|
|
29929
|
+
return `[error] ${str2(item.message)}
|
|
29084
29930
|
`;
|
|
29085
29931
|
case "mcp_tool_call": {
|
|
29086
|
-
const error =
|
|
29087
|
-
return error ? `[MCP ${
|
|
29932
|
+
const error = str2(obj(item.error).message);
|
|
29933
|
+
return error ? `[MCP ${str2(item.server)}.${str2(item.tool)}] ${error}
|
|
29088
29934
|
` : "";
|
|
29089
29935
|
}
|
|
29090
29936
|
default:
|
|
@@ -29099,52 +29945,52 @@ function unwrapShell(command) {
|
|
|
29099
29945
|
function callOf(item) {
|
|
29100
29946
|
switch (item.type) {
|
|
29101
29947
|
case "command_execution":
|
|
29102
|
-
return { title: "Command", target: unwrapShell(
|
|
29948
|
+
return { title: "Command", target: unwrapShell(str2(item.command)) };
|
|
29103
29949
|
case "mcp_tool_call":
|
|
29104
|
-
return { title: `${
|
|
29950
|
+
return { title: `${str2(item.server)}.${str2(item.tool)}`, target: "" };
|
|
29105
29951
|
case "web_search":
|
|
29106
|
-
return { title: "WebSearch", target:
|
|
29952
|
+
return { title: "WebSearch", target: str2(item.query) };
|
|
29107
29953
|
default: {
|
|
29108
|
-
const changes = (Array.isArray(item.changes) ? item.changes : []).map((c) =>
|
|
29954
|
+
const changes = (Array.isArray(item.changes) ? item.changes : []).map((c) => str2(obj(c).path)).filter(Boolean);
|
|
29109
29955
|
return { title: "Edit", target: changes.join(", ") };
|
|
29110
29956
|
}
|
|
29111
29957
|
}
|
|
29112
29958
|
}
|
|
29113
29959
|
function callResult(item) {
|
|
29114
|
-
if (item.type === "command_execution") return
|
|
29960
|
+
if (item.type === "command_execution") return str2(item.aggregated_output);
|
|
29115
29961
|
if (item.type === "mcp_tool_call") {
|
|
29116
|
-
const error =
|
|
29962
|
+
const error = str2(obj(item.error).message);
|
|
29117
29963
|
if (error) return error;
|
|
29118
29964
|
const content = obj(item.result).content;
|
|
29119
|
-
return (Array.isArray(content) ? content : []).map((b) =>
|
|
29965
|
+
return (Array.isArray(content) ? content : []).map((b) => str2(obj(b).text)).filter(Boolean).join("\n");
|
|
29120
29966
|
}
|
|
29121
29967
|
if (item.type === "file_change") {
|
|
29122
|
-
return (Array.isArray(item.changes) ? item.changes : []).map((c) => `${
|
|
29968
|
+
return (Array.isArray(item.changes) ? item.changes : []).map((c) => `${str2(obj(c).kind) || "change"} ${str2(obj(c).path)}`).join("\n");
|
|
29123
29969
|
}
|
|
29124
29970
|
return "";
|
|
29125
29971
|
}
|
|
29126
29972
|
function itemEvents(events, started, item, done) {
|
|
29127
|
-
const id =
|
|
29973
|
+
const id = str2(item.id);
|
|
29128
29974
|
if (item.type === "agent_message") {
|
|
29129
|
-
if (done) events.message(
|
|
29975
|
+
if (done) events.message(str2(item.text));
|
|
29130
29976
|
return;
|
|
29131
29977
|
}
|
|
29132
29978
|
if (item.type === "todo_list") {
|
|
29133
29979
|
const items = Array.isArray(item.items) ? item.items : [];
|
|
29134
|
-
events.plan(items.map(obj).map((t2) => ({ content:
|
|
29980
|
+
events.plan(items.map(obj).map((t2) => ({ content: str2(t2.text), status: t2.completed === true ? "completed" : "pending" })));
|
|
29135
29981
|
return;
|
|
29136
29982
|
}
|
|
29137
29983
|
if (item.type === "error") {
|
|
29138
|
-
if (done) events.log(`${
|
|
29984
|
+
if (done) events.log(`${str2(item.message)}
|
|
29139
29985
|
`);
|
|
29140
29986
|
return;
|
|
29141
29987
|
}
|
|
29142
|
-
const kind = CALLS[
|
|
29988
|
+
const kind = CALLS[str2(item.type)];
|
|
29143
29989
|
if (!kind) return;
|
|
29144
29990
|
if (!started.has(id)) {
|
|
29145
29991
|
started.add(id);
|
|
29146
|
-
const
|
|
29147
|
-
events.toolCall(id,
|
|
29992
|
+
const call2 = callOf(item);
|
|
29993
|
+
events.toolCall(id, call2.title, kind, call2.target);
|
|
29148
29994
|
}
|
|
29149
29995
|
if (done) {
|
|
29150
29996
|
const failed = item.status === "failed" || typeof item.exit_code === "number" && item.exit_code !== 0;
|
|
@@ -29168,12 +30014,12 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
29168
30014
|
lookedAt = at;
|
|
29169
30015
|
facts = readCodexRunFacts(threadId) ?? facts;
|
|
29170
30016
|
};
|
|
29171
|
-
const
|
|
30017
|
+
const turn2 = () => {
|
|
29172
30018
|
look(false);
|
|
29173
30019
|
return total && facts?.turns?.filter((t2) => sameUsage(t2.total, total)).pop();
|
|
29174
30020
|
};
|
|
29175
30021
|
const own2 = () => {
|
|
29176
|
-
const t2 =
|
|
30022
|
+
const t2 = turn2();
|
|
29177
30023
|
if (t2) return t2.own;
|
|
29178
30024
|
return carried ? void 0 : total;
|
|
29179
30025
|
};
|
|
@@ -29184,7 +30030,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
29184
30030
|
`;
|
|
29185
30031
|
switch (ev.type) {
|
|
29186
30032
|
case "thread.started":
|
|
29187
|
-
if (!threadId) threadId =
|
|
30033
|
+
if (!threadId) threadId = str2(ev.thread_id).trim() || void 0;
|
|
29188
30034
|
return "";
|
|
29189
30035
|
case "item.started":
|
|
29190
30036
|
itemEvents(events, started, obj(ev.item), false);
|
|
@@ -29196,7 +30042,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
29196
30042
|
const item = obj(ev.item);
|
|
29197
30043
|
itemEvents(events, started, item, true);
|
|
29198
30044
|
if (item.type === "agent_message") {
|
|
29199
|
-
const said =
|
|
30045
|
+
const said = str2(item.text).trim();
|
|
29200
30046
|
if (said) final = said;
|
|
29201
30047
|
}
|
|
29202
30048
|
return renderCompleted(item);
|
|
@@ -29207,14 +30053,14 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
29207
30053
|
return "";
|
|
29208
30054
|
// 最终失败保留;连接提示只在没有后续成功完成时才作为失败。
|
|
29209
30055
|
case "turn.failed": {
|
|
29210
|
-
const said =
|
|
30056
|
+
const said = str2(obj(ev.error).message) || failure2 || "Codex \u6267\u884C\u5931\u8D25";
|
|
29211
30057
|
failure2 = said;
|
|
29212
30058
|
events.error(said);
|
|
29213
30059
|
return `[error] ${said}
|
|
29214
30060
|
`;
|
|
29215
30061
|
}
|
|
29216
30062
|
case "error": {
|
|
29217
|
-
const said =
|
|
30063
|
+
const said = str2(ev.message);
|
|
29218
30064
|
failure2 = said || failure2;
|
|
29219
30065
|
events.log(`[Codex] ${said}
|
|
29220
30066
|
`);
|
|
@@ -29249,7 +30095,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
29249
30095
|
// Worked out here rather than reported: the turn's own tokens at the model's list
|
|
29250
30096
|
// rate, and nothing at all unless both the provider and the model are ones
|
|
29251
30097
|
// whose rates the board knows.
|
|
29252
|
-
costUsd: () => priceUsd(facts?.provider,
|
|
30098
|
+
costUsd: () => priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own2()),
|
|
29253
30099
|
resumeId: () => threadId,
|
|
29254
30100
|
failure: () => failure2,
|
|
29255
30101
|
events: events.events
|
|
@@ -29281,14 +30127,14 @@ function readIndex() {
|
|
|
29281
30127
|
} catch {
|
|
29282
30128
|
continue;
|
|
29283
30129
|
}
|
|
29284
|
-
const sessionId =
|
|
30130
|
+
const sessionId = str2(record.sessionId).trim();
|
|
29285
30131
|
if (!sessionId) continue;
|
|
29286
30132
|
if (record.deleted === true) {
|
|
29287
30133
|
entries.delete(sessionId);
|
|
29288
30134
|
continue;
|
|
29289
30135
|
}
|
|
29290
|
-
const sessionDir =
|
|
29291
|
-
const workDir =
|
|
30136
|
+
const sessionDir = str2(record.sessionDir).trim();
|
|
30137
|
+
const workDir = str2(record.workDir).trim();
|
|
29292
30138
|
if (sessionDir && workDir) entries.set(sessionId, { sessionId, sessionDir, workDir });
|
|
29293
30139
|
}
|
|
29294
30140
|
return entries;
|
|
@@ -29311,13 +30157,13 @@ function findKimiSession(cwd, since) {
|
|
|
29311
30157
|
}
|
|
29312
30158
|
function wireFiles(sessionDir) {
|
|
29313
30159
|
const agents = join2(sessionDir, "agents");
|
|
29314
|
-
let
|
|
30160
|
+
let names2;
|
|
29315
30161
|
try {
|
|
29316
|
-
|
|
30162
|
+
names2 = readdirSync2(agents);
|
|
29317
30163
|
} catch {
|
|
29318
30164
|
return [{ path: join2(sessionDir, "wire.jsonl"), main: true }];
|
|
29319
30165
|
}
|
|
29320
|
-
const ordered =
|
|
30166
|
+
const ordered = names2.sort((a, b) => Number(b === "main") - Number(a === "main"));
|
|
29321
30167
|
return ordered.map((name) => ({ path: join2(agents, name, "wire.jsonl"), main: name === "main" }));
|
|
29322
30168
|
}
|
|
29323
30169
|
function readKimiRunFacts(sessionId) {
|
|
@@ -29326,10 +30172,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
29326
30172
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
29327
30173
|
let model;
|
|
29328
30174
|
let holding = 0;
|
|
29329
|
-
for (const { path:
|
|
30175
|
+
for (const { path: path31, main } of wireFiles(entry2.sessionDir)) {
|
|
29330
30176
|
let raw;
|
|
29331
30177
|
try {
|
|
29332
|
-
raw = readFileSync2(
|
|
30178
|
+
raw = readFileSync2(path31, "utf8");
|
|
29333
30179
|
} catch {
|
|
29334
30180
|
continue;
|
|
29335
30181
|
}
|
|
@@ -29344,7 +30190,7 @@ function readKimiRunFacts(sessionId) {
|
|
|
29344
30190
|
continue;
|
|
29345
30191
|
}
|
|
29346
30192
|
if (record.type !== "usage.record") continue;
|
|
29347
|
-
model ??=
|
|
30193
|
+
model ??= str2(record.model).trim() || void 0;
|
|
29348
30194
|
const usage = obj(record.usage);
|
|
29349
30195
|
total.input += num(usage.inputOther);
|
|
29350
30196
|
total.cacheCreation += num(usage.inputCacheCreation);
|
|
@@ -29368,10 +30214,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
29368
30214
|
// ../cli/src/lib/agent/wire/kimi-stream.ts
|
|
29369
30215
|
var ARG_KEYS2 = ["command", "path", "pattern", "query", "url", "prompt", "prompt_template", "description"];
|
|
29370
30216
|
function callArgs(raw) {
|
|
29371
|
-
const
|
|
29372
|
-
if (!
|
|
30217
|
+
const text3 = str2(raw);
|
|
30218
|
+
if (!text3.trim()) return {};
|
|
29373
30219
|
try {
|
|
29374
|
-
return JSON.parse(
|
|
30220
|
+
return JSON.parse(text3);
|
|
29375
30221
|
} catch {
|
|
29376
30222
|
return {};
|
|
29377
30223
|
}
|
|
@@ -29387,15 +30233,15 @@ var kindOf = (name) => TOOL_KINDS3.find(([re]) => re.test(name))?.[1] ?? "other"
|
|
|
29387
30233
|
function toolCalls(row) {
|
|
29388
30234
|
const calls = Array.isArray(row.tool_calls) ? row.tool_calls : [];
|
|
29389
30235
|
return calls.map((raw) => {
|
|
29390
|
-
const
|
|
29391
|
-
const fn = obj(
|
|
29392
|
-
const name =
|
|
30236
|
+
const call2 = obj(raw);
|
|
30237
|
+
const fn = obj(call2.function);
|
|
30238
|
+
const name = str2(fn.name) || "tool";
|
|
29393
30239
|
return `\u23FA ${name}${argHint(callArgs(fn.arguments), ARG_KEYS2)}
|
|
29394
30240
|
`;
|
|
29395
30241
|
}).join("");
|
|
29396
30242
|
}
|
|
29397
30243
|
function retry(row) {
|
|
29398
|
-
const why =
|
|
30244
|
+
const why = str2(row.error_message) || str2(row.error_name) || "the provider failed";
|
|
29399
30245
|
const attempt = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
|
|
29400
30246
|
return `[retry ${attempt}] ${why}
|
|
29401
30247
|
`;
|
|
@@ -29423,18 +30269,18 @@ function createKimiStreamRenderer(cwd) {
|
|
|
29423
30269
|
`;
|
|
29424
30270
|
switch (row.role) {
|
|
29425
30271
|
case "assistant": {
|
|
29426
|
-
const said =
|
|
30272
|
+
const said = str2(row.content).trim();
|
|
29427
30273
|
if (said) final = said;
|
|
29428
30274
|
if (said) events.message(said);
|
|
29429
30275
|
for (const raw of Array.isArray(row.tool_calls) ? row.tool_calls : []) {
|
|
29430
|
-
const
|
|
29431
|
-
const name =
|
|
29432
|
-
const args = obj(callArgs(obj(
|
|
30276
|
+
const call2 = obj(raw);
|
|
30277
|
+
const name = str2(obj(call2.function).name) || "tool";
|
|
30278
|
+
const args = obj(callArgs(obj(call2.function).arguments));
|
|
29433
30279
|
if (name === "Agent") {
|
|
29434
|
-
subagents.add(
|
|
29435
|
-
events.subagent(
|
|
30280
|
+
subagents.add(str2(call2.id));
|
|
30281
|
+
events.subagent(str2(call2.id), str2(args.description) || name);
|
|
29436
30282
|
} else {
|
|
29437
|
-
events.toolCall(
|
|
30283
|
+
events.toolCall(str2(call2.id), name, kindOf(name), ARG_KEYS2.map((k) => str2(args[k])).find((v) => v.trim()));
|
|
29438
30284
|
}
|
|
29439
30285
|
}
|
|
29440
30286
|
return `${said ? `${said}
|
|
@@ -29442,13 +30288,13 @@ function createKimiStreamRenderer(cwd) {
|
|
|
29442
30288
|
` : ""}${toolCalls(row)}`;
|
|
29443
30289
|
}
|
|
29444
30290
|
case "meta":
|
|
29445
|
-
if (row.type === "session.resume_hint") sessionId ??=
|
|
30291
|
+
if (row.type === "session.resume_hint") sessionId ??= str2(row.session_id).trim() || void 0;
|
|
29446
30292
|
return row.type === "turn.step.retrying" ? retry(row) : "";
|
|
29447
30293
|
case "tool": {
|
|
29448
|
-
const id =
|
|
29449
|
-
const
|
|
29450
|
-
if (subagents.delete(id)) events.toolResult(id, /^status: completed$/m.test(
|
|
29451
|
-
else events.toolResult(id, "completed",
|
|
30294
|
+
const id = str2(row.tool_call_id);
|
|
30295
|
+
const text3 = str2(row.content);
|
|
30296
|
+
if (subagents.delete(id)) events.toolResult(id, /^status: completed$/m.test(text3) ? "completed" : "failed", "");
|
|
30297
|
+
else events.toolResult(id, "completed", text3);
|
|
29452
30298
|
return "";
|
|
29453
30299
|
}
|
|
29454
30300
|
default:
|
|
@@ -29485,7 +30331,7 @@ function createKimiStreamRenderer(cwd) {
|
|
|
29485
30331
|
}
|
|
29486
30332
|
|
|
29487
30333
|
// ../cli/src/lib/agent/wire/acp.ts
|
|
29488
|
-
import
|
|
30334
|
+
import fs19 from "node:fs";
|
|
29489
30335
|
|
|
29490
30336
|
// ../cli/src/lib/agent/wire/rpc.ts
|
|
29491
30337
|
var RpcError = class extends Error {
|
|
@@ -29536,7 +30382,7 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
29536
30382
|
if (!pending) continue;
|
|
29537
30383
|
waiting2.delete(String(msg.id));
|
|
29538
30384
|
if (msg.error) {
|
|
29539
|
-
const said = [
|
|
30385
|
+
const said = [str2(msg.error.message), str2(obj(msg.error.data).message)].filter(Boolean).join(": ");
|
|
29540
30386
|
pending.fail(new RpcError(said || `the agent refused (${msg.error.code ?? "no code"})`, msg.error.code));
|
|
29541
30387
|
} else pending.ok(obj(msg.result));
|
|
29542
30388
|
}
|
|
@@ -29599,9 +30445,9 @@ function createTail(log) {
|
|
|
29599
30445
|
log(chunk);
|
|
29600
30446
|
},
|
|
29601
30447
|
/** One line about something that isn't the agent talking. */
|
|
29602
|
-
line(
|
|
30448
|
+
line(text3) {
|
|
29603
30449
|
close();
|
|
29604
|
-
log(`${
|
|
30450
|
+
log(`${text3}
|
|
29605
30451
|
`);
|
|
29606
30452
|
},
|
|
29607
30453
|
/** End of the turn: whatever is half-written is finished off. */
|
|
@@ -29615,8 +30461,8 @@ function createTail(log) {
|
|
|
29615
30461
|
// ../cli/package.json
|
|
29616
30462
|
var package_default = {
|
|
29617
30463
|
name: "wildcrane",
|
|
29618
|
-
version: "0.11.
|
|
29619
|
-
akbContract:
|
|
30464
|
+
version: "0.11.39",
|
|
30465
|
+
akbContract: 10,
|
|
29620
30466
|
description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
|
|
29621
30467
|
keywords: [
|
|
29622
30468
|
"kanban",
|
|
@@ -29687,33 +30533,33 @@ var CLIENT_CAPABILITIES = {
|
|
|
29687
30533
|
};
|
|
29688
30534
|
function whereHint(update3, title) {
|
|
29689
30535
|
const locations = Array.isArray(update3.locations) ? update3.locations : [];
|
|
29690
|
-
const
|
|
29691
|
-
return
|
|
30536
|
+
const path31 = str2(obj(locations[0]).path);
|
|
30537
|
+
return path31 && !title.includes(path31) ? hint(path31) : "";
|
|
29692
30538
|
}
|
|
29693
30539
|
function saidBy(update3) {
|
|
29694
30540
|
const content = Array.isArray(update3.content) ? update3.content : [];
|
|
29695
30541
|
for (const raw of content) {
|
|
29696
30542
|
const part = obj(raw);
|
|
29697
|
-
const
|
|
29698
|
-
if (
|
|
30543
|
+
const text3 = str2(obj(part.content).text) || str2(part.text);
|
|
30544
|
+
if (text3.trim()) return text3.trim();
|
|
29699
30545
|
}
|
|
29700
30546
|
return "";
|
|
29701
30547
|
}
|
|
29702
30548
|
function modelOf(answer) {
|
|
29703
|
-
const current2 =
|
|
30549
|
+
const current2 = str2(obj(answer.models).currentModelId).trim();
|
|
29704
30550
|
if (current2) return modelsIn(answer).find((m) => m.modelId === current2)?.name ?? current2;
|
|
29705
30551
|
const list = Array.isArray(answer.configOptions) ? answer.configOptions : [];
|
|
29706
30552
|
for (const raw of list) {
|
|
29707
30553
|
const option = obj(raw);
|
|
29708
|
-
if (option.id === "model") return
|
|
30554
|
+
if (option.id === "model") return str2(option.currentValue).trim() || void 0;
|
|
29709
30555
|
}
|
|
29710
30556
|
return void 0;
|
|
29711
30557
|
}
|
|
29712
30558
|
function modelsIn(answer) {
|
|
29713
30559
|
const list = obj(answer.models).availableModels;
|
|
29714
30560
|
return (Array.isArray(list) ? list : []).map(obj).flatMap((m) => {
|
|
29715
|
-
const modelId =
|
|
29716
|
-
return modelId ? [{ modelId, name:
|
|
30561
|
+
const modelId = str2(m.modelId);
|
|
30562
|
+
return modelId ? [{ modelId, name: str2(m.name) || modelId }] : [];
|
|
29717
30563
|
});
|
|
29718
30564
|
}
|
|
29719
30565
|
function pickedModel(answer, wanted) {
|
|
@@ -29742,7 +30588,7 @@ function sessionGone(e) {
|
|
|
29742
30588
|
var RESTARTED = "[board] that conversation is gone \u2014 the task was restarted in a new session\n";
|
|
29743
30589
|
async function newSession(rpc, cwd, mcpServers) {
|
|
29744
30590
|
const opened = await rpc.call("session/new", { cwd, mcpServers });
|
|
29745
|
-
const sessionId =
|
|
30591
|
+
const sessionId = str2(opened.sessionId);
|
|
29746
30592
|
if (!sessionId) throw new Error("the agent opened a session without giving it an id");
|
|
29747
30593
|
return { opened, sessionId };
|
|
29748
30594
|
}
|
|
@@ -29758,12 +30604,12 @@ var STOPPED = {
|
|
|
29758
30604
|
cancelled: "the turn was cancelled"
|
|
29759
30605
|
};
|
|
29760
30606
|
function mcpServersIn(file2) {
|
|
29761
|
-
const servers = obj(obj(JSON.parse(
|
|
30607
|
+
const servers = obj(obj(JSON.parse(fs19.readFileSync(file2, "utf8"))).mcpServers);
|
|
29762
30608
|
return Object.entries(servers).map(([name, raw]) => {
|
|
29763
30609
|
const s = obj(raw);
|
|
29764
30610
|
return {
|
|
29765
30611
|
name,
|
|
29766
|
-
command:
|
|
30612
|
+
command: str2(s.command),
|
|
29767
30613
|
args: Array.isArray(s.args) ? s.args.map(String) : [],
|
|
29768
30614
|
env: Object.entries(obj(s.env)).map(([key, value]) => ({ name: key, value: String(value) }))
|
|
29769
30615
|
};
|
|
@@ -29857,7 +30703,7 @@ async function oneTurn(io, options) {
|
|
|
29857
30703
|
});
|
|
29858
30704
|
const result = tail.end();
|
|
29859
30705
|
events.end();
|
|
29860
|
-
const stopReason =
|
|
30706
|
+
const stopReason = str2(done.stopReason);
|
|
29861
30707
|
const spent = obj(obj(done._meta).usage);
|
|
29862
30708
|
const usage = usageOf2(done.usage) ?? usageOf2(spent, true);
|
|
29863
30709
|
costUsd ??= ticksUsd(spent.costUsdTicks);
|
|
@@ -29885,20 +30731,20 @@ function update2(raw, tail, gotCost, gotContext) {
|
|
|
29885
30731
|
const change = obj(raw);
|
|
29886
30732
|
switch (change.sessionUpdate) {
|
|
29887
30733
|
case "agent_message_chunk":
|
|
29888
|
-
tail.text(
|
|
30734
|
+
tail.text(str2(obj(change.content).text));
|
|
29889
30735
|
return;
|
|
29890
30736
|
case "agent_thought_chunk":
|
|
29891
|
-
tail.thought(
|
|
30737
|
+
tail.thought(str2(obj(change.content).text));
|
|
29892
30738
|
return;
|
|
29893
30739
|
case "tool_call": {
|
|
29894
|
-
const title =
|
|
30740
|
+
const title = str2(change.title) || str2(change.name) || "tool";
|
|
29895
30741
|
tail.line(`\u23FA ${title}${whereHint(change, title)}`);
|
|
29896
30742
|
return;
|
|
29897
30743
|
}
|
|
29898
30744
|
case "tool_call_update": {
|
|
29899
30745
|
if (change.status !== "failed") return;
|
|
29900
30746
|
const why = saidBy(change);
|
|
29901
|
-
tail.line(`[error] ${
|
|
30747
|
+
tail.line(`[error] ${str2(change.title) || "that tool call"} failed${why ? `: ${why}` : ""}`);
|
|
29902
30748
|
return;
|
|
29903
30749
|
}
|
|
29904
30750
|
case "usage_update": {
|
|
@@ -29907,7 +30753,7 @@ function update2(raw, tail, gotCost, gotContext) {
|
|
|
29907
30753
|
if (used > 0) gotContext({ used, ...size > 0 ? { limit: size } : {} });
|
|
29908
30754
|
const cost = obj(change.cost);
|
|
29909
30755
|
const amount = cost.amount;
|
|
29910
|
-
if (
|
|
30756
|
+
if (str2(cost.currency).toUpperCase() === "USD" && typeof amount === "number" && Number.isFinite(amount) && amount > 0) {
|
|
29911
30757
|
gotCost(amount);
|
|
29912
30758
|
}
|
|
29913
30759
|
return;
|
|
@@ -29918,8 +30764,8 @@ function update2(raw, tail, gotCost, gotContext) {
|
|
|
29918
30764
|
}
|
|
29919
30765
|
function decide(params, tail, events) {
|
|
29920
30766
|
const options = Array.isArray(params.options) ? params.options : [];
|
|
29921
|
-
const no = options.map(obj).find((option) =>
|
|
29922
|
-
const title =
|
|
30767
|
+
const no = options.map(obj).find((option) => str2(option.kind).startsWith("reject"));
|
|
30768
|
+
const title = str2(obj(params.toolCall).title) || "that";
|
|
29923
30769
|
const said = `[refused] ${title} \u2014 a run reaches no further than this project`;
|
|
29924
30770
|
tail.line(said);
|
|
29925
30771
|
events.log(`${said}
|
|
@@ -29929,11 +30775,11 @@ function decide(params, tail, events) {
|
|
|
29929
30775
|
}
|
|
29930
30776
|
|
|
29931
30777
|
// ../cli/src/lib/agent/wire/zcode.ts
|
|
29932
|
-
import
|
|
30778
|
+
import path21 from "node:path";
|
|
29933
30779
|
function whereHint2(input, title) {
|
|
29934
30780
|
const named = obj(input);
|
|
29935
30781
|
for (const key of ["command", "file_path", "path", "url", "pattern"]) {
|
|
29936
|
-
const value =
|
|
30782
|
+
const value = str2(named[key]).trim();
|
|
29937
30783
|
if (value && !title.includes(value)) return hint(value);
|
|
29938
30784
|
}
|
|
29939
30785
|
return "";
|
|
@@ -29957,20 +30803,20 @@ var STOPPED2 = {
|
|
|
29957
30803
|
};
|
|
29958
30804
|
function modelOf2(ref) {
|
|
29959
30805
|
const model = obj(ref);
|
|
29960
|
-
const id =
|
|
30806
|
+
const id = str2(model.modelId);
|
|
29961
30807
|
if (!id) return "";
|
|
29962
|
-
const provider =
|
|
30808
|
+
const provider = str2(model.providerId);
|
|
29963
30809
|
return provider ? `${provider}/${id}` : id;
|
|
29964
30810
|
}
|
|
29965
30811
|
function createParts(tail) {
|
|
29966
30812
|
const written = /* @__PURE__ */ new Map();
|
|
29967
30813
|
const tools = /* @__PURE__ */ new Set();
|
|
29968
30814
|
const named = /* @__PURE__ */ new Map();
|
|
29969
|
-
const say = (partId, kind,
|
|
30815
|
+
const say = (partId, kind, text3) => {
|
|
29970
30816
|
const before = written.get(partId) ?? "";
|
|
29971
|
-
const fresh =
|
|
30817
|
+
const fresh = text3.startsWith(before) ? text3.slice(before.length) : text3;
|
|
29972
30818
|
if (!fresh) return;
|
|
29973
|
-
written.set(partId,
|
|
30819
|
+
written.set(partId, text3);
|
|
29974
30820
|
if (kind === "reasoning" || kind === "thought") tail.thought(fresh);
|
|
29975
30821
|
else tail.text(fresh);
|
|
29976
30822
|
};
|
|
@@ -29978,32 +30824,32 @@ function createParts(tail) {
|
|
|
29978
30824
|
/** A whole part, as `part.started` or `part.upserted` sends it. */
|
|
29979
30825
|
upsert(raw) {
|
|
29980
30826
|
const part = obj(raw);
|
|
29981
|
-
const type =
|
|
29982
|
-
const partId =
|
|
30827
|
+
const type = str2(part.type);
|
|
30828
|
+
const partId = str2(part.partId);
|
|
29983
30829
|
if (type === "text" || type === "reasoning" || type === "thought") {
|
|
29984
|
-
if (partId) say(partId, type,
|
|
29985
|
-
else tail.text(
|
|
30830
|
+
if (partId) say(partId, type, str2(part.text));
|
|
30831
|
+
else tail.text(str2(part.text));
|
|
29986
30832
|
return;
|
|
29987
30833
|
}
|
|
29988
30834
|
if (type !== "tool") return;
|
|
29989
30835
|
const state = obj(part.state);
|
|
29990
|
-
const callId =
|
|
29991
|
-
const title =
|
|
30836
|
+
const callId = str2(part.callId) || partId;
|
|
30837
|
+
const title = str2(state.title) || str2(part.tool) || "tool";
|
|
29992
30838
|
if (callId && !tools.has(callId)) {
|
|
29993
30839
|
tools.add(callId);
|
|
29994
30840
|
tail.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
|
|
29995
30841
|
}
|
|
29996
|
-
if (
|
|
29997
|
-
const why =
|
|
30842
|
+
if (str2(state.status) === "error") {
|
|
30843
|
+
const why = str2(state.error).trim();
|
|
29998
30844
|
tail.line(`[error] ${title} failed${why ? `: ${why}` : ""}`);
|
|
29999
30845
|
}
|
|
30000
30846
|
},
|
|
30001
30847
|
/** A piece of one part, as `part.delta` sends it. */
|
|
30002
30848
|
delta(event2) {
|
|
30003
|
-
const field =
|
|
30849
|
+
const field = str2(event2.field) || "text";
|
|
30004
30850
|
if (field !== "text" && field !== "reasoning") return;
|
|
30005
|
-
const partId =
|
|
30006
|
-
const delta =
|
|
30851
|
+
const partId = str2(event2.partId);
|
|
30852
|
+
const delta = str2(event2.delta);
|
|
30007
30853
|
if (!delta) return;
|
|
30008
30854
|
written.set(partId, (written.get(partId) ?? "") + delta);
|
|
30009
30855
|
if (field === "reasoning") tail.thought(delta);
|
|
@@ -30011,12 +30857,12 @@ function createParts(tail) {
|
|
|
30011
30857
|
},
|
|
30012
30858
|
/** A piece of the turn, as `model.streaming` sends it. */
|
|
30013
30859
|
streaming(payload) {
|
|
30014
|
-
const kind =
|
|
30015
|
-
if (kind === "text_delta") return tail.text(
|
|
30016
|
-
if (kind === "reasoning_delta") return tail.thought(
|
|
30860
|
+
const kind = str2(payload.kind);
|
|
30861
|
+
if (kind === "text_delta") return tail.text(str2(payload.delta));
|
|
30862
|
+
if (kind === "reasoning_delta") return tail.thought(str2(payload.delta));
|
|
30017
30863
|
if (kind !== "tool_call") return;
|
|
30018
|
-
const callId =
|
|
30019
|
-
const name =
|
|
30864
|
+
const callId = str2(payload.toolCallId);
|
|
30865
|
+
const name = str2(payload.toolName) || "tool";
|
|
30020
30866
|
named.set(callId, name);
|
|
30021
30867
|
if (callId && tools.has(callId)) return;
|
|
30022
30868
|
tools.add(callId);
|
|
@@ -30026,9 +30872,9 @@ function createParts(tail) {
|
|
|
30026
30872
|
* `batch` are progress on a call that already has its line; only `error` is worth a
|
|
30027
30873
|
* second one. */
|
|
30028
30874
|
toolUpdate(payload) {
|
|
30029
|
-
if (
|
|
30030
|
-
const name = named.get(
|
|
30031
|
-
const why =
|
|
30875
|
+
if (str2(payload.kind) !== "error") return;
|
|
30876
|
+
const name = named.get(str2(payload.toolCallId)) ?? "tool";
|
|
30877
|
+
const why = str2(obj(payload.error).message).split("\n")[0].trim();
|
|
30032
30878
|
tail.line(`[error] ${name} failed${why ? `: ${why.slice(0, 200)}` : ""}`);
|
|
30033
30879
|
}
|
|
30034
30880
|
};
|
|
@@ -30066,7 +30912,7 @@ async function oneTurn2(io, options) {
|
|
|
30066
30912
|
(msg) => {
|
|
30067
30913
|
if (msg.method === "session/event") {
|
|
30068
30914
|
const envelope = obj(msg.params);
|
|
30069
|
-
if (
|
|
30915
|
+
if (str2(envelope.sessionId) === sessionId) event(envelope, parts, tail, live, ended);
|
|
30070
30916
|
return;
|
|
30071
30917
|
}
|
|
30072
30918
|
if (msg.id === void 0) return;
|
|
@@ -30095,7 +30941,7 @@ async function oneTurn2(io, options) {
|
|
|
30095
30941
|
{ stringIds: true }
|
|
30096
30942
|
);
|
|
30097
30943
|
try {
|
|
30098
|
-
const workspacePath =
|
|
30944
|
+
const workspacePath = path21.resolve(io.cwd);
|
|
30099
30945
|
const workspace = { workspacePath, workspaceKey: workspacePath };
|
|
30100
30946
|
let opened;
|
|
30101
30947
|
if (io.resumeId) {
|
|
@@ -30113,13 +30959,13 @@ async function oneTurn2(io, options) {
|
|
|
30113
30959
|
// The session's name is the board's business, not a model call of its own.
|
|
30114
30960
|
titleGenerationEnabled: false
|
|
30115
30961
|
});
|
|
30116
|
-
sessionId =
|
|
30962
|
+
sessionId = str2(obj(opened.session).sessionId);
|
|
30117
30963
|
if (!sessionId) throw new Error("the agent opened a session without giving it an id");
|
|
30118
30964
|
io.gotResumeId(sessionId);
|
|
30119
30965
|
}
|
|
30120
30966
|
let model = modelOf2(obj(opened.session).model);
|
|
30121
30967
|
if (options.model) {
|
|
30122
|
-
const wanted = options.model.includes("/") ? { providerId: options.model.split("/")[0], modelId: options.model.split("/").slice(1).join("/") } : { providerId:
|
|
30968
|
+
const wanted = options.model.includes("/") ? { providerId: options.model.split("/")[0], modelId: options.model.split("/").slice(1).join("/") } : { providerId: str2(obj(obj(opened.session).model).providerId) || "zai", modelId: options.model };
|
|
30123
30969
|
await rpc.call("session/setModel", { sessionId, model: wanted });
|
|
30124
30970
|
model = modelOf2(wanted);
|
|
30125
30971
|
}
|
|
@@ -30169,7 +31015,7 @@ async function contextOf(rpc, sessionId) {
|
|
|
30169
31015
|
}
|
|
30170
31016
|
function event(envelope, parts, tail, live, ended) {
|
|
30171
31017
|
const payload = obj(envelope.payload);
|
|
30172
|
-
switch (
|
|
31018
|
+
switch (str2(envelope.type)) {
|
|
30173
31019
|
case "part.started":
|
|
30174
31020
|
case "part.upserted":
|
|
30175
31021
|
if (live) parts.upsert(payload.part);
|
|
@@ -30185,23 +31031,23 @@ function event(envelope, parts, tail, live, ended) {
|
|
|
30185
31031
|
return;
|
|
30186
31032
|
case "turn.completed": {
|
|
30187
31033
|
const usage = usageOf3(obj(payload.usage));
|
|
30188
|
-
const response =
|
|
30189
|
-
const how =
|
|
31034
|
+
const response = str2(payload.response);
|
|
31035
|
+
const how = str2(payload.resultType) || "success";
|
|
30190
31036
|
if (how === "success") return ended({ ok: true, response, usage });
|
|
30191
31037
|
return ended({ ok: false, error: STOPPED2[how] ?? `the agent stopped: ${how}`, response, usage });
|
|
30192
31038
|
}
|
|
30193
31039
|
case "turn.failed": {
|
|
30194
31040
|
const error = obj(payload.error);
|
|
30195
|
-
return ended({ ok: false, error:
|
|
31041
|
+
return ended({ ok: false, error: str2(error.message) || "the turn failed" });
|
|
30196
31042
|
}
|
|
30197
31043
|
case "session.closed":
|
|
30198
|
-
return ended({ ok: false, error:
|
|
31044
|
+
return ended({ ok: false, error: str2(payload.reason) || "the agent closed the session" });
|
|
30199
31045
|
default:
|
|
30200
31046
|
return;
|
|
30201
31047
|
}
|
|
30202
31048
|
}
|
|
30203
31049
|
function decide2(params, tail) {
|
|
30204
|
-
const tool =
|
|
31050
|
+
const tool = str2(params.toolName) || "that";
|
|
30205
31051
|
tail.line(`[refused] ${tool} \u2014 your own ZCode rules ask before this one, and a run has nobody to ask`);
|
|
30206
31052
|
return { decision: "deny", reason: "this board run can't answer a permission question" };
|
|
30207
31053
|
}
|
|
@@ -30219,7 +31065,7 @@ function obj2(value) {
|
|
|
30219
31065
|
function arr(value) {
|
|
30220
31066
|
return Array.isArray(value) ? value : [];
|
|
30221
31067
|
}
|
|
30222
|
-
function
|
|
31068
|
+
function str3(value) {
|
|
30223
31069
|
return typeof value === "string" ? value : "";
|
|
30224
31070
|
}
|
|
30225
31071
|
function num2(value) {
|
|
@@ -30230,23 +31076,23 @@ function uniqueIds(list) {
|
|
|
30230
31076
|
}
|
|
30231
31077
|
var cached = /* @__PURE__ */ new Map();
|
|
30232
31078
|
function modelsIn2(file2, pick2, salt = "") {
|
|
30233
|
-
let
|
|
31079
|
+
let stamp2;
|
|
30234
31080
|
try {
|
|
30235
31081
|
const stat = statSync3(file2);
|
|
30236
|
-
|
|
31082
|
+
stamp2 = `${stat.mtimeMs}:${stat.size}:${salt}`;
|
|
30237
31083
|
} catch {
|
|
30238
31084
|
cached.delete(file2);
|
|
30239
31085
|
return [];
|
|
30240
31086
|
}
|
|
30241
31087
|
const hit = cached.get(file2);
|
|
30242
|
-
if (hit?.stamp ===
|
|
31088
|
+
if (hit?.stamp === stamp2) return hit.found;
|
|
30243
31089
|
let found = [];
|
|
30244
31090
|
try {
|
|
30245
31091
|
found = uniqueIds(pick2(JSON.parse(readFileSync3(file2, "utf8"))));
|
|
30246
31092
|
} catch {
|
|
30247
31093
|
found = [];
|
|
30248
31094
|
}
|
|
30249
|
-
cached.set(file2, { stamp, found });
|
|
31095
|
+
cached.set(file2, { stamp: stamp2, found });
|
|
30250
31096
|
return found;
|
|
30251
31097
|
}
|
|
30252
31098
|
|
|
@@ -30273,22 +31119,22 @@ var PASSING = [
|
|
|
30273
31119
|
];
|
|
30274
31120
|
var RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
|
|
30275
31121
|
var REASON_MAX = 140;
|
|
30276
|
-
function reasonLine(
|
|
30277
|
-
const line =
|
|
31122
|
+
function reasonLine(text3, rule) {
|
|
31123
|
+
const line = text3.split("\n").find((l) => rule.test(l.toLowerCase())) ?? text3;
|
|
30278
31124
|
const said = line.trim().replace(/\s+/g, " ");
|
|
30279
31125
|
return said.length > REASON_MAX ? `${said.slice(0, REASON_MAX - 1)}\u2026` : said;
|
|
30280
31126
|
}
|
|
30281
31127
|
function providerBlip(...said) {
|
|
30282
|
-
for (const
|
|
30283
|
-
if (!
|
|
30284
|
-
const lower =
|
|
31128
|
+
for (const text3 of said) {
|
|
31129
|
+
if (!text3?.trim()) continue;
|
|
31130
|
+
const lower = text3.toLowerCase();
|
|
30285
31131
|
if (MANUAL.some((rule) => rule.test(lower))) return void 0;
|
|
30286
31132
|
const hit = PASSING.find((rule) => rule.test(lower));
|
|
30287
31133
|
if (!hit) continue;
|
|
30288
|
-
const asked = RETRY_AFTER.exec(
|
|
31134
|
+
const asked = RETRY_AFTER.exec(text3);
|
|
30289
31135
|
const seconds = asked ? Number(asked[1]) : NaN;
|
|
30290
31136
|
return {
|
|
30291
|
-
reason: reasonLine(
|
|
31137
|
+
reason: reasonLine(text3, hit),
|
|
30292
31138
|
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
30293
31139
|
};
|
|
30294
31140
|
}
|
|
@@ -30307,15 +31153,15 @@ var userMessage = (prompt) => `${JSON.stringify({ type: "user", message: { role:
|
|
|
30307
31153
|
`;
|
|
30308
31154
|
function claudeOnWindows() {
|
|
30309
31155
|
const [local, roaming] = [process.env.LOCALAPPDATA?.trim(), process.env.APPDATA?.trim()];
|
|
30310
|
-
const packages = local ?
|
|
31156
|
+
const packages = local ? path22.join(local, "Packages") : "";
|
|
30311
31157
|
const data = [
|
|
30312
|
-
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) =>
|
|
30313
|
-
...roaming ? [
|
|
31158
|
+
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path22.join(packages, name, "LocalCache", "Roaming", "Claude")),
|
|
31159
|
+
...roaming ? [path22.join(roaming, "Claude")] : []
|
|
30314
31160
|
];
|
|
30315
31161
|
return data.flatMap(
|
|
30316
|
-
(dir) => latestIn(
|
|
30317
|
-
|
|
30318
|
-
...folders(version).map((build) =>
|
|
31162
|
+
(dir) => latestIn(path22.join(dir, "claude-code")).flatMap((version) => [
|
|
31163
|
+
path22.join(version, "claude.exe"),
|
|
31164
|
+
...folders(version).map((build) => path22.join(version, build, "claude.exe"))
|
|
30319
31165
|
])
|
|
30320
31166
|
);
|
|
30321
31167
|
}
|
|
@@ -30348,11 +31194,11 @@ var CLAUDE_CODE = {
|
|
|
30348
31194
|
return [...claudeStreamArgs(argv), "--resume", resumeId, "--fork-session", "--session-id", sessionId];
|
|
30349
31195
|
},
|
|
30350
31196
|
// 默认快照会忽略续跑传入的新规则;仅显式关闭快照的会话支持更新。
|
|
30351
|
-
systemPrompt(
|
|
31197
|
+
systemPrompt(text3, argv) {
|
|
30352
31198
|
if (namesFlag(argv, ["--append-system-prompt", "--append-system-prompt-file"])) return {};
|
|
30353
31199
|
const snapshot = argv.flatMap((arg, i) => arg === "--system-prompt-snapshot" ? [argv[i + 1]] : arg.startsWith("--system-prompt-snapshot=") ? [arg.slice("--system-prompt-snapshot=".length)] : []).at(-1);
|
|
30354
31200
|
if (namesFlag(argv, ["--resume", "-r", "--continue", "-c"]) && snapshot !== "off") return {};
|
|
30355
|
-
return { args: ["--append-system-prompt",
|
|
31201
|
+
return { args: ["--append-system-prompt", text3] };
|
|
30356
31202
|
},
|
|
30357
31203
|
// What Claude Code takes: who pays for the run, where that run goes, a model id, and how
|
|
30358
31204
|
// hard that model thinks. The provider comes first because it decides the rest — which
|
|
@@ -30488,7 +31334,7 @@ var CLAUDE_CODE = {
|
|
|
30488
31334
|
...MODEL_ALIASES,
|
|
30489
31335
|
...modelsIn2(
|
|
30490
31336
|
home2(".claude.json"),
|
|
30491
|
-
(data) => arr(obj2(data).additionalModelOptionsCache).map((option) =>
|
|
31337
|
+
(data) => arr(obj2(data).additionalModelOptionsCache).map((option) => str3(obj2(option).value))
|
|
30492
31338
|
)
|
|
30493
31339
|
];
|
|
30494
31340
|
},
|
|
@@ -30573,116 +31419,15 @@ var CLAUDE_CODE = {
|
|
|
30573
31419
|
...latestIn(home2(".local", "share", "claude", "versions")),
|
|
30574
31420
|
// The copy Claude Desktop carries.
|
|
30575
31421
|
...process.platform === "win32" ? claudeOnWindows() : latestIn(home2("Library", "Application Support", "Claude", "claude-code")).flatMap(
|
|
30576
|
-
(version) => folders(version).map((build) =>
|
|
31422
|
+
(version) => folders(version).map((build) => path22.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
|
|
30577
31423
|
)
|
|
30578
31424
|
],
|
|
30579
31425
|
install: "npm install -g @anthropic-ai/claude-code"
|
|
30580
31426
|
};
|
|
30581
31427
|
|
|
30582
31428
|
// ../cli/src/lib/agent/harnesses/codex.ts
|
|
30583
|
-
import
|
|
30584
|
-
import
|
|
30585
|
-
|
|
30586
|
-
// ../cli/src/lib/paths.ts
|
|
30587
|
-
import path17 from "node:path";
|
|
30588
|
-
var REPO_ROOT = "";
|
|
30589
|
-
var KANBAN = "";
|
|
30590
|
-
var TODO = "";
|
|
30591
|
-
var ARCHIVE = "";
|
|
30592
|
-
var ARCHIVE_MD = "";
|
|
30593
|
-
var README = "";
|
|
30594
|
-
var MODULES_MD = "";
|
|
30595
|
-
var CONFIG = "";
|
|
30596
|
-
var KANBAN_GITIGNORE = "";
|
|
30597
|
-
var RELEASES = "";
|
|
30598
|
-
var RELEASE_SUMMARIES = "";
|
|
30599
|
-
var AGENTS = "";
|
|
30600
|
-
var WORKFLOWS = "";
|
|
30601
|
-
var LEGACY_AGENTS = "";
|
|
30602
|
-
var ASSETS = "";
|
|
30603
|
-
var BOARD_STATE = "";
|
|
30604
|
-
var MOCKUPS = "";
|
|
30605
|
-
var MEMORY = "";
|
|
30606
|
-
var AGENT_MEMORY = "";
|
|
30607
|
-
var PROJECT_MD = "";
|
|
30608
|
-
var LOCK = "";
|
|
30609
|
-
var UI_CONFIG = "";
|
|
30610
|
-
var LEGACY_UI_CONFIG = "";
|
|
30611
|
-
var LOCAL_CONFIG = "";
|
|
30612
|
-
var ENV_FILE = "";
|
|
30613
|
-
var SESSIONS = "";
|
|
30614
|
-
var SESSIONS_DIR = "";
|
|
30615
|
-
var SESSIONS_LOCK2 = "";
|
|
30616
|
-
var INDEX_LOCK2 = "";
|
|
30617
|
-
var DELIVERIES = "";
|
|
30618
|
-
var PLANS = "";
|
|
30619
|
-
var PLANS_ARCHIVE = "";
|
|
30620
|
-
var RULES = "";
|
|
30621
|
-
var TRIAGE = "";
|
|
30622
|
-
var SIGNALS_ARCHIVED = "";
|
|
30623
|
-
var SIGNALS_DISMISSED = "";
|
|
30624
|
-
var SIGNALS_FILES = "";
|
|
30625
|
-
var SIGNALS_OLD_INBOX = "";
|
|
30626
|
-
var SIGNALS_OLD_HANDLED = "";
|
|
30627
|
-
var AKB_DIR = "";
|
|
30628
|
-
var ROOT_GITIGNORE = "";
|
|
30629
|
-
function boardLockName(kanban, root) {
|
|
30630
|
-
const from = path17.relative(root, kanban);
|
|
30631
|
-
const name = from && !from.startsWith("..") ? from : path17.basename(kanban);
|
|
30632
|
-
return `${name.split(path17.sep).join("-")}.lock`;
|
|
30633
|
-
}
|
|
30634
|
-
var BOARD_FLAG = "";
|
|
30635
|
-
function setBoard(kanban, root, flag) {
|
|
30636
|
-
REPO_ROOT = path17.resolve(root);
|
|
30637
|
-
KANBAN = path17.resolve(kanban);
|
|
30638
|
-
BOARD_FLAG = flag;
|
|
30639
|
-
TODO = path17.join(KANBAN, "todo");
|
|
30640
|
-
ARCHIVE = path17.join(KANBAN, ".archive");
|
|
30641
|
-
ARCHIVE_MD = path17.join(KANBAN, "archive.md");
|
|
30642
|
-
README = path17.join(TODO, "README.md");
|
|
30643
|
-
MODULES_MD = path17.join(KANBAN, "modules.md");
|
|
30644
|
-
CONFIG = path17.join(KANBAN, "config.md");
|
|
30645
|
-
KANBAN_GITIGNORE = path17.join(KANBAN, ".gitignore");
|
|
30646
|
-
RELEASES = path17.join(KANBAN, "releases.md");
|
|
30647
|
-
RELEASE_SUMMARIES = path17.join(KANBAN, ".release-summaries");
|
|
30648
|
-
AGENTS = path17.join(KANBAN, "agents");
|
|
30649
|
-
WORKFLOWS = path17.join(KANBAN, "workflows");
|
|
30650
|
-
LEGACY_AGENTS = path17.join(KANBAN, "skills");
|
|
30651
|
-
MEMORY = path17.join(KANBAN, "memory");
|
|
30652
|
-
AGENT_MEMORY = path17.join(MEMORY, "agents");
|
|
30653
|
-
PROJECT_MD = path17.join(MEMORY, "project.md");
|
|
30654
|
-
LEGACY_UI_CONFIG = path17.join(KANBAN, UI_CONFIG_FILE);
|
|
30655
|
-
LOCAL_CONFIG = path17.join(KANBAN, ".local.json");
|
|
30656
|
-
ENV_FILE = path17.join(KANBAN, ".env");
|
|
30657
|
-
const machine = projectStateDir(KANBAN, REPO_ROOT);
|
|
30658
|
-
BOARD_STATE = machine;
|
|
30659
|
-
UI_CONFIG = path17.join(machine, UI_CONFIG_FILE);
|
|
30660
|
-
ASSETS = path17.join(machine, ASSETS_FOLDER);
|
|
30661
|
-
MOCKUPS = path17.join(machine, MOCKUPS_FOLDER);
|
|
30662
|
-
SESSIONS = path17.join(machine, SESSIONS_FILE);
|
|
30663
|
-
SESSIONS_DIR = path17.join(machine, SESSIONS_FOLDER);
|
|
30664
|
-
SESSIONS_LOCK2 = path17.join(machine, SESSIONS_LOCK);
|
|
30665
|
-
INDEX_LOCK2 = path17.join(machine, INDEX_LOCK);
|
|
30666
|
-
DELIVERIES = path17.join(KANBAN, "deliveries");
|
|
30667
|
-
RULES = path17.join(KANBAN, "rules");
|
|
30668
|
-
PLANS = path17.join(machine, "plans");
|
|
30669
|
-
PLANS_ARCHIVE = path17.join(PLANS, "archive");
|
|
30670
|
-
TRIAGE = path17.join(KANBAN, "triage");
|
|
30671
|
-
SIGNALS_ARCHIVED = path17.join(TRIAGE, "archived");
|
|
30672
|
-
SIGNALS_DISMISSED = path17.join(TRIAGE, "dismissed");
|
|
30673
|
-
SIGNALS_FILES = path17.join(TRIAGE, "files");
|
|
30674
|
-
SIGNALS_OLD_INBOX = path17.join(TRIAGE, "inbox");
|
|
30675
|
-
SIGNALS_OLD_HANDLED = path17.join(TRIAGE, "handled.md");
|
|
30676
|
-
AKB_DIR = path17.join(REPO_ROOT, ".akb");
|
|
30677
|
-
ROOT_GITIGNORE = path17.join(REPO_ROOT, ".gitignore");
|
|
30678
|
-
LOCK = path17.join(AKB_DIR, boardLockName(KANBAN, REPO_ROOT));
|
|
30679
|
-
return REPO_ROOT;
|
|
30680
|
-
}
|
|
30681
|
-
function setBoardRoot(root, named = false) {
|
|
30682
|
-
const project = path17.resolve(root);
|
|
30683
|
-
return setBoard(path17.join(project, "docs", "kanban"), project, named ? ` --dir ${project}` : "");
|
|
30684
|
-
}
|
|
30685
|
-
setBoardRoot(process.cwd());
|
|
31429
|
+
import fs20 from "node:fs";
|
|
31430
|
+
import path23 from "node:path";
|
|
30686
31431
|
|
|
30687
31432
|
// ../cli/src/lib/agent/worktree.ts
|
|
30688
31433
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
@@ -30729,10 +31474,10 @@ function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
|
30729
31474
|
}
|
|
30730
31475
|
const flags = [...argv, ...extra];
|
|
30731
31476
|
const workspaceWrite = flags.some((arg, i) => arg === "--full-auto" || arg === "--sandbox=workspace-write" || (arg === "--sandbox" || arg === "-s") && flags[i + 1] === "workspace-write");
|
|
30732
|
-
if (workspaceWrite &&
|
|
31477
|
+
if (workspaceWrite && path23.resolve(cwd) !== path23.resolve(REPO_ROOT)) {
|
|
30733
31478
|
for (const dir of [KANBAN, AKB_DIR]) {
|
|
30734
|
-
const relative =
|
|
30735
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
31479
|
+
const relative = path23.relative(cwd, dir);
|
|
31480
|
+
if (relative === ".." || relative.startsWith(`..${path23.sep}`) || path23.isAbsolute(relative)) {
|
|
30736
31481
|
extra.push("--add-dir", dir);
|
|
30737
31482
|
}
|
|
30738
31483
|
}
|
|
@@ -30755,7 +31500,7 @@ function envRoot(name) {
|
|
|
30755
31500
|
}
|
|
30756
31501
|
function modified(file2) {
|
|
30757
31502
|
try {
|
|
30758
|
-
return
|
|
31503
|
+
return fs20.statSync(file2).mtimeMs;
|
|
30759
31504
|
} catch {
|
|
30760
31505
|
return 0;
|
|
30761
31506
|
}
|
|
@@ -30781,28 +31526,28 @@ function codexOnWindows() {
|
|
|
30781
31526
|
const local = envRoot("LOCALAPPDATA");
|
|
30782
31527
|
const profile = envRoot("USERPROFILE");
|
|
30783
31528
|
const programs = envRoot("ProgramFiles");
|
|
30784
|
-
const cache = local ?
|
|
30785
|
-
const releases = profile ?
|
|
30786
|
-
const packages = programs ?
|
|
31529
|
+
const cache = local ? path23.join(local, "OpenAI", "Codex", "bin") : "";
|
|
31530
|
+
const releases = profile ? path23.join(profile, ".codex", "packages", "standalone", "releases") : "";
|
|
31531
|
+
const packages = programs ? path23.join(programs, "WindowsApps") : "";
|
|
30787
31532
|
return [
|
|
30788
31533
|
// Desktop's relocated CLI cache: a folder per build hash, newest file first.
|
|
30789
|
-
...byNewest(folders(cache).map((name) =>
|
|
31534
|
+
...byNewest(folders(cache).map((name) => path23.join(cache, name, "codex.exe"))),
|
|
30790
31535
|
// The separate standalone launcher, at a path with nothing variable in it.
|
|
30791
|
-
...local ? [
|
|
31536
|
+
...local ? [path23.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
|
|
30792
31537
|
// That launcher's release payload: a folder per version and target.
|
|
30793
31538
|
...byVersion(folders(releases).filter(ourArch)).map(
|
|
30794
|
-
(name) =>
|
|
31539
|
+
(name) => path23.join(releases, name, "bin", "codex.exe")
|
|
30795
31540
|
),
|
|
30796
31541
|
// Desktop's own MSIX package.
|
|
30797
31542
|
...byVersion(folders(packages).filter((name) => name.startsWith("OpenAI.Codex_")).filter(ourArch)).map(
|
|
30798
|
-
(name) =>
|
|
31543
|
+
(name) => path23.join(packages, name, "app", "resources", "codex.exe")
|
|
30799
31544
|
)
|
|
30800
31545
|
];
|
|
30801
31546
|
}
|
|
30802
31547
|
function codexInstalls() {
|
|
30803
31548
|
const chosen = process.env.CODEX_INSTALL_DIR?.trim();
|
|
30804
31549
|
return [
|
|
30805
|
-
...chosen ? [
|
|
31550
|
+
...chosen ? [path23.join(chosen, "codex")] : [],
|
|
30806
31551
|
...process.platform === "win32" ? codexOnWindows() : [
|
|
30807
31552
|
// macOS, where Codex now lives in the merged app — `codex-cli/bin/` since 26.928…
|
|
30808
31553
|
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex",
|
|
@@ -30844,14 +31589,14 @@ var CODEX = {
|
|
|
30844
31589
|
return [...codexExtraArgs(argv, cwd), "fork", resumeId];
|
|
30845
31590
|
},
|
|
30846
31591
|
// 自设系统指令保持原样;无法追加时由调用方明确提示。
|
|
30847
|
-
systemPrompt(
|
|
31592
|
+
systemPrompt(text3, argv) {
|
|
30848
31593
|
if (namesFlag(argv, ["developer_instructions", "model_instructions_file"])) return {};
|
|
30849
31594
|
try {
|
|
30850
|
-
const config =
|
|
31595
|
+
const config = fs20.readFileSync(path23.join(process.env.CODEX_HOME || home2(".codex"), "config.toml"), "utf8");
|
|
30851
31596
|
if (/^\s*(?:developer_instructions|model_instructions_file)\s*=/m.test(config)) return {};
|
|
30852
31597
|
} catch {
|
|
30853
31598
|
}
|
|
30854
|
-
return { args: ["-c", `developer_instructions=${JSON.stringify(
|
|
31599
|
+
return { args: ["-c", `developer_instructions=${JSON.stringify(text3)}`] };
|
|
30855
31600
|
},
|
|
30856
31601
|
// What Codex takes, in the order Claude Code's dialog draws the same four: who pays for
|
|
30857
31602
|
// the run and where it goes, that endpoint's address, the key, a model, and how hard that
|
|
@@ -30969,7 +31714,7 @@ var CODEX = {
|
|
|
30969
31714
|
models() {
|
|
30970
31715
|
return modelsIn2(
|
|
30971
31716
|
home2(".codex", "models_cache.json"),
|
|
30972
|
-
(data) => arr(obj2(data).models).map(obj2).filter((model) =>
|
|
31717
|
+
(data) => arr(obj2(data).models).map(obj2).filter((model) => str3(model.visibility) !== "hide").sort((a, b) => num2(a.priority) - num2(b.priority)).map((model) => str3(model.slug))
|
|
30973
31718
|
);
|
|
30974
31719
|
},
|
|
30975
31720
|
// Nothing extra. Claude Code gets CLAUDE_CODE_MAX_RETRIES=0 so a rate limit fails at
|
|
@@ -31093,24 +31838,24 @@ var CURSOR = {
|
|
|
31093
31838
|
};
|
|
31094
31839
|
|
|
31095
31840
|
// ../cli/src/lib/agent/harnesses/dsh.ts
|
|
31096
|
-
import
|
|
31097
|
-
import
|
|
31841
|
+
import fs21 from "node:fs";
|
|
31842
|
+
import path24 from "node:path";
|
|
31098
31843
|
function dshHome(argv) {
|
|
31099
31844
|
const binary = argv[0];
|
|
31100
31845
|
if (!binary) return void 0;
|
|
31101
|
-
const
|
|
31102
|
-
const candidates2 = binary.includes("/") || binary.includes("\\") ?
|
|
31846
|
+
const names2 = process.platform === "win32" && !path24.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
|
|
31847
|
+
const candidates2 = binary.includes("/") || binary.includes("\\") ? names2 : (process.env.PATH ?? "").split(path24.delimiter).filter(Boolean).flatMap((dir2) => names2.map((name) => path24.join(dir2, name)));
|
|
31103
31848
|
let dir;
|
|
31104
31849
|
try {
|
|
31105
|
-
const found = candidates2.find((candidate) =>
|
|
31850
|
+
const found = candidates2.find((candidate) => fs21.existsSync(candidate));
|
|
31106
31851
|
if (!found) return void 0;
|
|
31107
|
-
const script = /\.cmd$/i.test(found) ? shimTarget(
|
|
31108
|
-
dir =
|
|
31852
|
+
const script = /\.cmd$/i.test(found) ? shimTarget(fs21.readFileSync(found, "utf8"), found)?.script : void 0;
|
|
31853
|
+
dir = path24.dirname(fs21.realpathSync(script ?? found));
|
|
31109
31854
|
} catch {
|
|
31110
31855
|
return void 0;
|
|
31111
31856
|
}
|
|
31112
|
-
for (let up =
|
|
31113
|
-
if (
|
|
31857
|
+
for (let up = path24.dirname(dir); dir !== up; up = path24.dirname(dir)) {
|
|
31858
|
+
if (fs21.existsSync(path24.join(dir, "package.json"))) return dir;
|
|
31114
31859
|
dir = up;
|
|
31115
31860
|
}
|
|
31116
31861
|
return void 0;
|
|
@@ -31174,11 +31919,11 @@ var DSH = {
|
|
|
31174
31919
|
// dsh-acp's persona IS its system prompt, so the ask is added to the one in effect: the
|
|
31175
31920
|
// user's own `DSH_SYSTEM_PROMPT`, else the bridge's default. A `--persona` on the command
|
|
31176
31921
|
// line outranks both, and is left alone.
|
|
31177
|
-
systemPrompt(
|
|
31922
|
+
systemPrompt(text3, argv, env2) {
|
|
31178
31923
|
if (namesFlag(argv, ["--persona"])) return {};
|
|
31179
31924
|
return { env: { DSH_SYSTEM_PROMPT: `${env2.DSH_SYSTEM_PROMPT || DSH_PERSONA}
|
|
31180
31925
|
|
|
31181
|
-
${
|
|
31926
|
+
${text3}` } };
|
|
31182
31927
|
},
|
|
31183
31928
|
// ACP carries all three in the conversation itself (agent/wire/acp.ts), so a dsh run shows a
|
|
31184
31929
|
// price, its tokens and the model the session opened on.
|
|
@@ -31229,8 +31974,8 @@ var GROK = {
|
|
|
31229
31974
|
return [];
|
|
31230
31975
|
},
|
|
31231
31976
|
// `--rules` appends to Grok's system prompt. A top-level option, so it goes before `agent`.
|
|
31232
|
-
systemPrompt(
|
|
31233
|
-
return namesFlag(argv, ["--rules"]) ? {} : { args: ["--rules",
|
|
31977
|
+
systemPrompt(text3, argv) {
|
|
31978
|
+
return namesFlag(argv, ["--rules"]) ? {} : { args: ["--rules", text3] };
|
|
31234
31979
|
},
|
|
31235
31980
|
// What Grok takes: a model, and the xAI key. Both boxes can stay empty — someone already
|
|
31236
31981
|
// set up with grok has a login in `~/.grok` and a default model in its own
|
|
@@ -31337,7 +32082,7 @@ var KIMI = {
|
|
|
31337
32082
|
},
|
|
31338
32083
|
// An agent file wrapping Kimi's own prompt in `${base_prompt}`. Only a new session takes one;
|
|
31339
32084
|
// a resumed one keeps the agent it opened with, and Kimi refuses the flag beside `--session`.
|
|
31340
|
-
systemPrompt(
|
|
32085
|
+
systemPrompt(text3, argv) {
|
|
31341
32086
|
if (namesFlag(argv, ["--session", "-S", "--resume", "-r", "--continue", "-C", "--agent", "--agent-file"])) return {};
|
|
31342
32087
|
const file2 = machineFile("kimi-language.md", `---
|
|
31343
32088
|
name: akb-language
|
|
@@ -31346,7 +32091,7 @@ description: Kimi's default agent, told which language to write in
|
|
|
31346
32091
|
|
|
31347
32092
|
\${base_prompt}
|
|
31348
32093
|
|
|
31349
|
-
${
|
|
32094
|
+
${text3}
|
|
31350
32095
|
`);
|
|
31351
32096
|
return { args: ["--agent-file", file2] };
|
|
31352
32097
|
},
|
|
@@ -31567,8 +32312,8 @@ var OPENCODE = {
|
|
|
31567
32312
|
env: () => ({ ...process.env }),
|
|
31568
32313
|
// `instructions` files join the system prompt, and OpenCode adds this config's list to the
|
|
31569
32314
|
// user's own rather than replacing it.
|
|
31570
|
-
systemPrompt(
|
|
31571
|
-
const file2 = machineFile("opencode-language.md", `${
|
|
32315
|
+
systemPrompt(text3, _argv, env2) {
|
|
32316
|
+
const file2 = machineFile("opencode-language.md", `${text3}
|
|
31572
32317
|
`);
|
|
31573
32318
|
let own2 = {};
|
|
31574
32319
|
try {
|
|
@@ -31743,11 +32488,11 @@ async function detectRuntimes(quick = false, only) {
|
|
|
31743
32488
|
const harness = HARNESSES2[name];
|
|
31744
32489
|
const settings = harness.settings.map(declOf);
|
|
31745
32490
|
await warm(harness);
|
|
31746
|
-
const
|
|
31747
|
-
if (!
|
|
31748
|
-
const loggedIn = harness.login ? await probeLogin(spawnName(
|
|
32491
|
+
const copy2 = locate(harness);
|
|
32492
|
+
if (!copy2) return { name, installed: false, settings };
|
|
32493
|
+
const loggedIn = harness.login ? await probeLogin(spawnName(copy2, splitCommand(harness.command)[0]), harness) : void 0;
|
|
31749
32494
|
const models = loggedIn === false || quick && SLOW.has(name) ? [] : await readModels(name);
|
|
31750
|
-
return { name, installed: true, ...
|
|
32495
|
+
return { name, installed: true, ...copy2.version ? { version: copy2.version } : {}, ...loggedIn === void 0 ? {} : { loggedIn }, ...models.length ? { models } : {}, settings };
|
|
31751
32496
|
})
|
|
31752
32497
|
);
|
|
31753
32498
|
}
|
|
@@ -31756,14 +32501,14 @@ var listed = (harness) => async () => (harness.models?.() ?? []).map((id) => ({
|
|
|
31756
32501
|
var readModels = (name) => (MODELS[name] ?? listed(HARNESSES2[name]))().catch(() => []);
|
|
31757
32502
|
var MODELS = {
|
|
31758
32503
|
"claude-code": async () => {
|
|
31759
|
-
const cached2 = claudeModels(
|
|
32504
|
+
const cached2 = claudeModels(path25.join(process.env.CLAUDE_CONFIG_DIR || path25.join(os5.homedir(), ".claude"), "cache", "model-catalog"));
|
|
31760
32505
|
return cached2.length ? cached2 : [
|
|
31761
32506
|
{ id: "opus", name: "Opus" },
|
|
31762
32507
|
{ id: "sonnet", name: "Sonnet" },
|
|
31763
32508
|
{ id: "haiku", name: "Haiku" }
|
|
31764
32509
|
];
|
|
31765
32510
|
},
|
|
31766
|
-
codex: async () => codexModels(
|
|
32511
|
+
codex: async () => codexModels(path25.join(process.env.CODEX_HOME || path25.join(os5.homedir(), ".codex"), "models_cache.json")),
|
|
31767
32512
|
opencode: async () => opencodeModels(await output(commandOf(HARNESSES2.opencode)[0], ["models"])),
|
|
31768
32513
|
cursor: () => cursorModels()
|
|
31769
32514
|
};
|
|
@@ -31794,8 +32539,8 @@ function cursorModels() {
|
|
|
31794
32539
|
function acpModels(opened) {
|
|
31795
32540
|
const list = obj(opened.models).availableModels;
|
|
31796
32541
|
return (Array.isArray(list) ? list : []).map(obj).flatMap((m) => {
|
|
31797
|
-
const id =
|
|
31798
|
-
return id && id !== "default[]" ? [{ id, name:
|
|
32542
|
+
const id = str2(m.modelId);
|
|
32543
|
+
return id && id !== "default[]" ? [{ id, name: str2(m.name) || id }] : [];
|
|
31799
32544
|
});
|
|
31800
32545
|
}
|
|
31801
32546
|
function output(command, args) {
|
|
@@ -31819,7 +32564,7 @@ function output(command, args) {
|
|
|
31819
32564
|
}
|
|
31820
32565
|
function codexModels(file2) {
|
|
31821
32566
|
try {
|
|
31822
|
-
const cache = JSON.parse(
|
|
32567
|
+
const cache = JSON.parse(fs22.readFileSync(file2, "utf8"));
|
|
31823
32568
|
if (!Array.isArray(cache.models)) return [];
|
|
31824
32569
|
return cache.models.flatMap(
|
|
31825
32570
|
(m) => m.visibility === "list" && typeof m.slug === "string" && m.slug ? [{ id: m.slug, name: typeof m.display_name === "string" && m.display_name ? m.display_name : m.slug }] : []
|
|
@@ -31831,15 +32576,15 @@ function codexModels(file2) {
|
|
|
31831
32576
|
function claudeModels(dir) {
|
|
31832
32577
|
let files;
|
|
31833
32578
|
try {
|
|
31834
|
-
files =
|
|
32579
|
+
files = fs22.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
31835
32580
|
} catch {
|
|
31836
32581
|
return [];
|
|
31837
32582
|
}
|
|
31838
32583
|
const catalogs = files.flatMap((f) => {
|
|
31839
32584
|
try {
|
|
31840
|
-
const data = obj(JSON.parse(
|
|
32585
|
+
const data = obj(JSON.parse(fs22.readFileSync(path25.join(dir, f), "utf8")));
|
|
31841
32586
|
const catalog = obj(data.catalog);
|
|
31842
|
-
const surface =
|
|
32587
|
+
const surface = str2(catalog.surface);
|
|
31843
32588
|
return surface === "cc" || surface === "ccd" ? [{ surface, at: Number(data.fetchedAt) || 0, config: obj(catalog.config) }] : [];
|
|
31844
32589
|
} catch {
|
|
31845
32590
|
return [];
|
|
@@ -31850,11 +32595,11 @@ function claudeModels(dir) {
|
|
|
31850
32595
|
const aliases = obj(newest2.config.provider_alias_targets);
|
|
31851
32596
|
const models = Array.isArray(newest2.config.models) ? newest2.config.models : [];
|
|
31852
32597
|
return models.map(obj).flatMap((m) => {
|
|
31853
|
-
const id =
|
|
32598
|
+
const id = str2(m.id);
|
|
31854
32599
|
if (!id || m.section !== "main") return [];
|
|
31855
|
-
const family =
|
|
31856
|
-
const alias = family &&
|
|
31857
|
-
return [{ id: alias || id, name:
|
|
32600
|
+
const family = str2(obj(m.runtime).family);
|
|
32601
|
+
const alias = family && str2(obj(aliases[family]).default) === id ? family : "";
|
|
32602
|
+
return [{ id: alias || id, name: str2(m.short_name) || str2(m.name) || id }];
|
|
31858
32603
|
});
|
|
31859
32604
|
}
|
|
31860
32605
|
function probeLogin(binary, harness) {
|
|
@@ -31880,55 +32625,55 @@ function probeLogin(binary, harness) {
|
|
|
31880
32625
|
}
|
|
31881
32626
|
|
|
31882
32627
|
// src/akb.ts
|
|
31883
|
-
import
|
|
31884
|
-
import
|
|
31885
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
31886
|
-
var akbHome = () =>
|
|
32628
|
+
import fs23 from "node:fs";
|
|
32629
|
+
import path26 from "node:path";
|
|
32630
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
32631
|
+
var akbHome = () => path26.join(runnerHome(), "bin", "akb");
|
|
31887
32632
|
var BUNDLED_SHIM = `bundled-${AKB_VERSION}`;
|
|
31888
|
-
var HERE =
|
|
32633
|
+
var HERE = path26.dirname(fileURLToPath2(import.meta.url));
|
|
31889
32634
|
function akbArgs(entry2, dist = HERE) {
|
|
31890
|
-
const preload =
|
|
31891
|
-
return
|
|
32635
|
+
const preload = path26.join(dist, "akb-proxy.mjs");
|
|
32636
|
+
return fs23.existsSync(preload) ? ["--import", pathToFileURL(preload).href, entry2] : [entry2];
|
|
31892
32637
|
}
|
|
31893
32638
|
var bundledAkb = (dist = HERE) => ({
|
|
31894
32639
|
command: process.execPath,
|
|
31895
|
-
args: akbArgs(
|
|
32640
|
+
args: akbArgs(path26.join(dist, "akb", "bin", "ai4kanban.mjs"), dist),
|
|
31896
32641
|
version: AKB_VERSION,
|
|
31897
|
-
shim:
|
|
32642
|
+
shim: path26.join(akbHome(), BUNDLED_SHIM)
|
|
31898
32643
|
});
|
|
31899
32644
|
var quote = (s) => /^[\w./:@=-]+$/.test(s) ? s : `"${s}"`;
|
|
31900
32645
|
function shimDir(akb) {
|
|
31901
32646
|
const dir = akb.shim;
|
|
31902
32647
|
const line = [akb.command, ...akb.args].map(quote).join(" ");
|
|
31903
|
-
const [file2,
|
|
31904
|
-
`] : [
|
|
32648
|
+
const [file2, text3] = process.platform === "win32" ? [path26.join(dir, "akb.cmd"), `@${line} %*\r
|
|
32649
|
+
`] : [path26.join(dir, "akb"), `#!/bin/sh
|
|
31905
32650
|
exec ${line} "$@"
|
|
31906
32651
|
`];
|
|
31907
32652
|
if (process.platform === "win32") {
|
|
31908
|
-
|
|
32653
|
+
fs23.mkdirSync(dir, { recursive: true });
|
|
31909
32654
|
const shellLine = [akb.command, ...akb.args].map((s) => `'${s.replaceAll("\\", "/").replaceAll("'", "'\\''")}'`).join(" ");
|
|
31910
|
-
|
|
32655
|
+
fs23.writeFileSync(path26.join(dir, "akb"), `#!/bin/sh
|
|
31911
32656
|
exec ${shellLine} "$@"
|
|
31912
32657
|
`, { mode: 493 });
|
|
31913
32658
|
}
|
|
31914
32659
|
try {
|
|
31915
|
-
if (
|
|
32660
|
+
if (fs23.readFileSync(file2, "utf8") === text3) return dir;
|
|
31916
32661
|
} catch {
|
|
31917
32662
|
}
|
|
31918
|
-
|
|
31919
|
-
|
|
32663
|
+
fs23.mkdirSync(dir, { recursive: true });
|
|
32664
|
+
fs23.writeFileSync(file2, text3, { mode: 493 });
|
|
31920
32665
|
return dir;
|
|
31921
32666
|
}
|
|
31922
32667
|
var KEEP2 = 256 * 1024;
|
|
31923
32668
|
|
|
31924
32669
|
// src/lock.ts
|
|
31925
|
-
import
|
|
32670
|
+
import crypto7 from "node:crypto";
|
|
31926
32671
|
import net from "node:net";
|
|
31927
|
-
import
|
|
32672
|
+
import path27 from "node:path";
|
|
31928
32673
|
function lockPath() {
|
|
31929
32674
|
const home3 = runnerHome();
|
|
31930
|
-
if (process.platform === "win32") return `\\\\.\\pipe\\wildcrane-${
|
|
31931
|
-
return
|
|
32675
|
+
if (process.platform === "win32") return `\\\\.\\pipe\\wildcrane-${crypto7.createHash("sha256").update(home3).digest("hex").slice(0, 16)}`;
|
|
32676
|
+
return path27.join(home3, "runner.sock");
|
|
31932
32677
|
}
|
|
31933
32678
|
function runnerSettingsSupport() {
|
|
31934
32679
|
return new Promise((resolve2) => {
|
|
@@ -31958,31 +32703,31 @@ function runnerSettingsSupport() {
|
|
|
31958
32703
|
|
|
31959
32704
|
// src/signin.ts
|
|
31960
32705
|
import { spawn as spawn6 } from "node:child_process";
|
|
31961
|
-
import
|
|
32706
|
+
import crypto8 from "node:crypto";
|
|
31962
32707
|
import http2 from "node:http";
|
|
31963
32708
|
|
|
31964
32709
|
// src/settings-control.ts
|
|
31965
|
-
import
|
|
31966
|
-
import
|
|
31967
|
-
var directory = () =>
|
|
31968
|
-
var epochFile = () =>
|
|
32710
|
+
import fs24 from "node:fs";
|
|
32711
|
+
import path28 from "node:path";
|
|
32712
|
+
var directory = () => path28.join(runnerHome(), "executors");
|
|
32713
|
+
var epochFile = () => path28.join(runnerHome(), "account-generation");
|
|
31969
32714
|
function accountGeneration() {
|
|
31970
32715
|
try {
|
|
31971
|
-
return
|
|
32716
|
+
return fs24.readFileSync(epochFile(), "utf8");
|
|
31972
32717
|
} catch {
|
|
31973
32718
|
return "";
|
|
31974
32719
|
}
|
|
31975
32720
|
}
|
|
31976
32721
|
async function stopExecutors() {
|
|
31977
|
-
|
|
31978
|
-
|
|
32722
|
+
fs24.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
|
|
32723
|
+
fs24.writeFileSync(epochFile(), `${Date.now()}-${process.pid}`, { mode: 384 });
|
|
31979
32724
|
for (let n = 0; n < 160; n++) {
|
|
31980
|
-
const active =
|
|
32725
|
+
const active = fs24.existsSync(directory()) ? fs24.readdirSync(directory()).filter((name) => {
|
|
31981
32726
|
try {
|
|
31982
32727
|
process.kill(Number(name.split(".")[0]), 0);
|
|
31983
32728
|
return true;
|
|
31984
32729
|
} catch {
|
|
31985
|
-
|
|
32730
|
+
fs24.rmSync(path28.join(directory(), name), { force: true });
|
|
31986
32731
|
return false;
|
|
31987
32732
|
}
|
|
31988
32733
|
}) : [];
|
|
@@ -31999,6 +32744,19 @@ var CREST = "M44.97 27.45C44.61 26.89 46.57 25.76 47.87 25.76C48.72 25.76 50.6 2
|
|
|
31999
32744
|
var COPY = {
|
|
32000
32745
|
zh: {
|
|
32001
32746
|
choose: ["\u767B\u5F55 WildCrane", "\u9009\u62E9\u767B\u5F55\u65B9\u5F0F\uFF0C\u5B8C\u6210\u540E\u56DE\u5230 WildCrane\u3002"],
|
|
32747
|
+
email: "name@company.com",
|
|
32748
|
+
send: "\u53D1\u9001\u9A8C\u8BC1\u7801",
|
|
32749
|
+
sending: "\u6B63\u5728\u53D1\u9001\u2026",
|
|
32750
|
+
or: "\u6216",
|
|
32751
|
+
sent: "\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 ",
|
|
32752
|
+
code: "6 \u4F4D\u9A8C\u8BC1\u7801",
|
|
32753
|
+
submit: "\u767B\u5F55",
|
|
32754
|
+
verifying: "\u6B63\u5728\u767B\u5F55\u2026",
|
|
32755
|
+
change: "\u6362\u4E2A\u90AE\u7BB1",
|
|
32756
|
+
badEmail: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u3002",
|
|
32757
|
+
badCode: "\u9A8C\u8BC1\u7801\u9519\u8BEF\u6216\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u6216\u91CD\u65B0\u53D1\u9001\u3002",
|
|
32758
|
+
tooMany: "\u8BF7\u6C42\u592A\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
32759
|
+
error: "\u767B\u5F55\u6CA1\u6709\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
32002
32760
|
github: "\u7528 GitHub \u767B\u5F55",
|
|
32003
32761
|
google: "\u7528 Google \u767B\u5F55",
|
|
32004
32762
|
ok: ["\u5DF2\u767B\u5F55 WildCrane", "\u53EF\u4EE5\u5173\u95ED\u6B64\u9875\u9762\uFF0C\u56DE\u5230 WildCrane \u7EE7\u7EED\u3002"],
|
|
@@ -32007,6 +32765,19 @@ var COPY = {
|
|
|
32007
32765
|
},
|
|
32008
32766
|
en: {
|
|
32009
32767
|
choose: ["Sign in to WildCrane", "Choose how to sign in, then return to WildCrane."],
|
|
32768
|
+
email: "name@company.com",
|
|
32769
|
+
send: "Send code",
|
|
32770
|
+
sending: "Sending\u2026",
|
|
32771
|
+
or: "or",
|
|
32772
|
+
sent: "We sent a code to ",
|
|
32773
|
+
code: "6-digit code",
|
|
32774
|
+
submit: "Sign in",
|
|
32775
|
+
verifying: "Signing in\u2026",
|
|
32776
|
+
change: "Use a different email",
|
|
32777
|
+
badEmail: "Enter a valid email.",
|
|
32778
|
+
badCode: "That code is wrong or has expired. Try again or resend it.",
|
|
32779
|
+
tooMany: "Too many attempts. Try again in a moment.",
|
|
32780
|
+
error: "Sign-in didn't finish. Try again.",
|
|
32010
32781
|
github: "Sign in with GitHub",
|
|
32011
32782
|
google: "Sign in with Google",
|
|
32012
32783
|
ok: ["Signed in to WildCrane", "You can close this page and return to WildCrane."],
|
|
@@ -32017,18 +32788,29 @@ var COPY = {
|
|
|
32017
32788
|
var langOf = (accept) => /^\s*zh\b/i.test(accept ?? "") ? "zh" : "en";
|
|
32018
32789
|
var GITHUB_ICON = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"/></svg>';
|
|
32019
32790
|
var GOOGLE_ICON = '<svg viewBox="0 0 48 48" width="17" height="17" aria-hidden="true"><path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/><path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/><path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/><path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/></svg>';
|
|
32791
|
+
var EMAIL_SCRIPT = (c) => `(()=>{const t=${JSON.stringify({
|
|
32792
|
+
send: c.send,
|
|
32793
|
+
sending: c.sending,
|
|
32794
|
+
sent: c.sent,
|
|
32795
|
+
submit: c.submit,
|
|
32796
|
+
verifying: c.verifying,
|
|
32797
|
+
badEmail: c.badEmail,
|
|
32798
|
+
badCode: c.badCode,
|
|
32799
|
+
tooMany: c.tooMany,
|
|
32800
|
+
error: c.error
|
|
32801
|
+
}).replace(/</g, "\\u003c")};const $=(i)=>document.getElementById(i),f=$('f'),e=$('e'),c=$('c'),b=$('b'),m=$('m'),x=$('x');let to='';const say=(s,bad)=>{m.textContent=s;m.className=bad?'bad':''};const step=(code)=>{to=code?e.value.trim():'';e.hidden=!!code;c.hidden=!code;x.hidden=!code;b.textContent=code?t.submit:t.send;if(code){say(t.sent+to);c.value='';c.focus()}else{say('');e.focus()}};x.onclick=()=>step(false);f.onsubmit=async(ev)=>{ev.preventDefault();const verify=!!to;if(!verify&&!/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(e.value.trim()))return say(t.badEmail,true);b.disabled=true;b.textContent=verify?t.verifying:t.sending;let r={error:'failed'};try{r=await (await fetch(verify?'/verify':'/send',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(verify?{email:to,code:c.value.trim()}:{email:e.value.trim()})})).json()}catch{}b.disabled=false;if(r.ok){if(!verify)return step(true);document.open();document.write(r.page);return document.close()}b.textContent=verify?t.submit:t.send;say(r.error==='bad_code'?t.badCode:r.error==='too_many'?t.tooMany:t.error,true)}})()`;
|
|
32020
32802
|
var PAGE = (outcome, lang, links) => {
|
|
32021
32803
|
const c = COPY[lang];
|
|
32022
32804
|
const [title, body] = c[outcome];
|
|
32023
32805
|
const ok = outcome === "ok";
|
|
32024
32806
|
const icon = ok ? '<polyline points="20 6 9 17 4 12"/>' : '<path d="M18 6 6 18M6 6l12 12"/>';
|
|
32025
|
-
const top = links ? `<h1>${title}</h1><p>${body}</p><
|
|
32026
|
-
return `<!doctype html><html lang="${lang === "zh" ? "zh-CN" : "en"}"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title} \xB7 WildCrane</title><style>*{margin:0;box-sizing:border-box}body{display:flex;flex-direction:column;min-height:100dvh;background:#fff;color:#24231f;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}header{padding:16px 36px 0}main{flex:1;display:flex;align-items:center;justify-content:center;padding:0 36px 64px;text-align:center}.icon{display:flex;margin:0 auto;width:44px;height:44px;border-radius:50%;align-items:center;justify-content:center;background:${ok ? "#e4f3ea" : "#f7ddce"};color:${ok ? "#2f6b46" : "#b83a12"}}h1{font-size:24px;font-weight:850;line-height:1.25;letter-spacing:-0.02em}h1.below{margin-top:16px}p{margin:8px auto 0;max-width:38ch;font-size:13px;line-height:19px;color:#565550}main>div.choose{width:100%;max-width:320px}nav{margin-top:28px;display:flex;flex-direction:column;gap:12px}nav a{display:flex;height:44px;align-items:center;justify-content:center;gap:8px;border-radius:10px;font-size:14.5px;font-weight:600;color:#24231f;text-decoration:none;background:#fff;border:1px solid rgba(36,35,31,0.14)}nav a.dark{background:#24231f;color:#fff;border-color:#24231f}</style><header><svg viewBox="2 4 56 52" width="23.7" height="22" aria-hidden="true"><path d="${CRANE}" fill="#24231f"/><path d="${CREST}" fill="#dd4f1e"/></svg></header><main><div${links ? ' class="choose"' : ""}>${top}</div></main></html>`;
|
|
32807
|
+
const top = links ? `<h1>${title}</h1><p>${body}</p><form id="f" novalidate><input id="e" type="email" autocomplete="email" placeholder="${c.email}" required><input id="c" inputmode="numeric" autocomplete="one-time-code" maxlength="10" placeholder="${c.code}" hidden><button id="b" class="dark">${c.send}</button><small id="m"></small><button id="x" type="button" class="link" hidden>${c.change}</button></form><div class="or">${c.or}</div><nav><a href="${links.github}">${GITHUB_ICON}${c.github}</a><a href="${links.google}">${GOOGLE_ICON}${c.google}</a></nav><script>${EMAIL_SCRIPT(c)}</script>` : `<span class="icon"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${icon}</svg></span><h1 class="below">${title}</h1><p>${body}</p>`;
|
|
32808
|
+
return `<!doctype html><html lang="${lang === "zh" ? "zh-CN" : "en"}"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title} \xB7 WildCrane</title><style>*{margin:0;box-sizing:border-box}body{display:flex;flex-direction:column;min-height:100dvh;background:#fff;color:#24231f;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}header{padding:16px 36px 0}main{flex:1;display:flex;align-items:center;justify-content:center;padding:0 36px 64px;text-align:center}.icon{display:flex;margin:0 auto;width:44px;height:44px;border-radius:50%;align-items:center;justify-content:center;background:${ok ? "#e4f3ea" : "#f7ddce"};color:${ok ? "#2f6b46" : "#b83a12"}}h1{font-size:24px;font-weight:850;line-height:1.25;letter-spacing:-0.02em}h1.below{margin-top:16px}p{margin:8px auto 0;max-width:38ch;font-size:13px;line-height:19px;color:#565550}main>div.choose{width:100%;max-width:320px}nav{margin-top:28px;display:flex;flex-direction:column;gap:12px}nav a{display:flex;height:44px;align-items:center;justify-content:center;gap:8px;border-radius:10px;font-size:14.5px;font-weight:600;color:#24231f;text-decoration:none;background:#fff;border:1px solid rgba(36,35,31,0.14)}nav a.dark{background:#24231f;color:#fff;border-color:#24231f}form{margin-top:28px;display:flex;flex-direction:column;gap:12px}input{height:44px;padding:0 14px;border-radius:10px;border:1px solid rgba(36,35,31,0.14);font:inherit;font-size:14.5px}button{height:44px;border-radius:10px;border:0;font:inherit;font-size:14.5px;font-weight:600;cursor:pointer}button.dark{background:#24231f;color:#fff}button:disabled{opacity:.6}button.link{height:auto;background:none;color:#565550;font-size:13px;font-weight:500}small{font-size:13px;line-height:19px;color:#565550}small.bad{color:#b83a12}small:empty{display:none}.or{margin-top:20px;display:flex;align-items:center;gap:12px;font-size:13px;color:#8a8984}.or::before,.or::after{content:"";flex:1;height:1px;background:rgba(36,35,31,0.12)}.or+nav{margin-top:20px}</style><header><svg viewBox="2 4 56 52" width="23.7" height="22" aria-hidden="true"><path d="${CRANE}" fill="#24231f"/><path d="${CREST}" fill="#dd4f1e"/></svg></header><main><div${links ? ' class="choose"' : ""}>${top}</div></main></html>`;
|
|
32027
32809
|
};
|
|
32028
32810
|
async function signIn(options = {}) {
|
|
32029
32811
|
const generation = accountGeneration();
|
|
32030
|
-
const verifier = base64url(
|
|
32031
|
-
const challenge = base64url(
|
|
32812
|
+
const verifier = base64url(crypto8.randomBytes(32));
|
|
32813
|
+
const challenge = base64url(crypto8.createHash("sha256").update(verifier).digest());
|
|
32032
32814
|
let finish = () => {
|
|
32033
32815
|
};
|
|
32034
32816
|
const answered = new Promise((resolve2) => finish = resolve2);
|
|
@@ -32041,6 +32823,18 @@ async function signIn(options = {}) {
|
|
|
32041
32823
|
res.end(PAGE("choose", lang, { github: authorize("github"), google: authorize("google") }));
|
|
32042
32824
|
return;
|
|
32043
32825
|
}
|
|
32826
|
+
if (req.method === "POST" && (asked.pathname === "/send" || asked.pathname === "/verify") && !answering) {
|
|
32827
|
+
const asks = await readJson2(req);
|
|
32828
|
+
const answer = asked.pathname === "/send" ? await sendCode(asks.email ?? "", lang) : await verifyCode(asks.email ?? "", asks.code ?? "", generation, options.signal);
|
|
32829
|
+
const done = answer.ok && asked.pathname === "/verify";
|
|
32830
|
+
res.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
|
|
32831
|
+
res.end(JSON.stringify(done ? { ...answer, page: PAGE("ok", lang) } : answer));
|
|
32832
|
+
if (done) {
|
|
32833
|
+
answering = true;
|
|
32834
|
+
finish(null);
|
|
32835
|
+
}
|
|
32836
|
+
return;
|
|
32837
|
+
}
|
|
32044
32838
|
if (asked.pathname !== "/signed-in" || answering) {
|
|
32045
32839
|
res.writeHead(404).end();
|
|
32046
32840
|
return;
|
|
@@ -32084,14 +32878,9 @@ async function signIn(options = {}) {
|
|
|
32084
32878
|
return failure2;
|
|
32085
32879
|
}
|
|
32086
32880
|
async function exchange(code, verifier, generation, signal) {
|
|
32087
|
-
const { supabaseUrl, anonKey } = cloudEndpoints();
|
|
32088
32881
|
let response;
|
|
32089
32882
|
try {
|
|
32090
|
-
response = await
|
|
32091
|
-
method: "POST",
|
|
32092
|
-
headers: { apikey: anonKey, "content-type": "application/json" },
|
|
32093
|
-
body: JSON.stringify({ auth_code: code, code_verifier: verifier })
|
|
32094
|
-
});
|
|
32883
|
+
response = await authCall("token?grant_type=pkce", { auth_code: code, code_verifier: verifier });
|
|
32095
32884
|
} catch (e) {
|
|
32096
32885
|
return { why: "unreachable", detail: e instanceof Error ? e.message : String(e) };
|
|
32097
32886
|
}
|
|
@@ -32101,6 +32890,50 @@ async function exchange(code, verifier, generation, signal) {
|
|
|
32101
32890
|
writeSession(session);
|
|
32102
32891
|
return null;
|
|
32103
32892
|
}
|
|
32893
|
+
var authCall = (path31, body) => {
|
|
32894
|
+
const { api, anonKey } = cloudEndpoints();
|
|
32895
|
+
return fetch(`${api}/auth/v1/${path31}`, {
|
|
32896
|
+
method: "POST",
|
|
32897
|
+
headers: { apikey: anonKey, "content-type": "application/json" },
|
|
32898
|
+
body: JSON.stringify(body),
|
|
32899
|
+
signal: AbortSignal.timeout(2e4)
|
|
32900
|
+
});
|
|
32901
|
+
};
|
|
32902
|
+
var refusal2 = (status2) => ({ ok: false, error: status2 === 429 ? "too_many" : status2 === 400 || status2 === 401 || status2 === 403 ? "bad_code" : "failed" });
|
|
32903
|
+
async function sendCode(email, lang) {
|
|
32904
|
+
try {
|
|
32905
|
+
const response = await authCall("otp", { email: email.trim(), create_user: true, data: { lang } });
|
|
32906
|
+
return response.ok ? { ok: true } : { ok: false, error: response.status === 429 ? "too_many" : "failed" };
|
|
32907
|
+
} catch {
|
|
32908
|
+
return { ok: false, error: "failed" };
|
|
32909
|
+
}
|
|
32910
|
+
}
|
|
32911
|
+
async function verifyCode(email, code, generation, signal) {
|
|
32912
|
+
let response;
|
|
32913
|
+
try {
|
|
32914
|
+
response = await authCall("verify", { type: "email", email: email.trim(), token: code.trim() });
|
|
32915
|
+
} catch {
|
|
32916
|
+
return { ok: false, error: "failed" };
|
|
32917
|
+
}
|
|
32918
|
+
if (!response.ok) return refusal2(response.status);
|
|
32919
|
+
const session = sessionFrom(await response.json().catch(() => ({})));
|
|
32920
|
+
if (!session) return { ok: false, error: "failed" };
|
|
32921
|
+
if (signal?.aborted || accountGeneration() !== generation) return { ok: false, error: "failed" };
|
|
32922
|
+
writeSession(session);
|
|
32923
|
+
return { ok: true };
|
|
32924
|
+
}
|
|
32925
|
+
async function readJson2(req) {
|
|
32926
|
+
let text3 = "";
|
|
32927
|
+
for await (const chunk of req) {
|
|
32928
|
+
text3 += chunk;
|
|
32929
|
+
if (text3.length > 1e4) break;
|
|
32930
|
+
}
|
|
32931
|
+
try {
|
|
32932
|
+
return JSON.parse(text3);
|
|
32933
|
+
} catch {
|
|
32934
|
+
return {};
|
|
32935
|
+
}
|
|
32936
|
+
}
|
|
32104
32937
|
function openBrowser2(url) {
|
|
32105
32938
|
const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
|
|
32106
32939
|
try {
|
|
@@ -32109,18 +32942,18 @@ function openBrowser2(url) {
|
|
|
32109
32942
|
} catch {
|
|
32110
32943
|
}
|
|
32111
32944
|
}
|
|
32112
|
-
var base64url = (
|
|
32945
|
+
var base64url = (bytes2) => bytes2.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
32113
32946
|
|
|
32114
32947
|
// src/settings.ts
|
|
32115
|
-
var failure = (
|
|
32948
|
+
var failure = (call2) => ({ error: call2.code ?? "offline", message: call2.error });
|
|
32116
32949
|
var signing = null;
|
|
32117
32950
|
var signAbort = null;
|
|
32118
32951
|
var stopping = false;
|
|
32119
32952
|
var callback = () => {
|
|
32120
32953
|
};
|
|
32121
32954
|
var notify = () => {
|
|
32122
|
-
|
|
32123
|
-
|
|
32955
|
+
fs25.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
|
|
32956
|
+
fs25.writeFileSync(path29.join(runnerHome(), "settings-refresh"), crypto9.randomUUID(), { mode: 384 });
|
|
32124
32957
|
callback();
|
|
32125
32958
|
};
|
|
32126
32959
|
var onSettingsChange = (next) => {
|
|
@@ -32162,7 +32995,7 @@ async function folderOf(cwd) {
|
|
|
32162
32995
|
if (!list.ok) return { ...failure(list), folders: [], folder: null };
|
|
32163
32996
|
const real = (dir) => {
|
|
32164
32997
|
try {
|
|
32165
|
-
return
|
|
32998
|
+
return fs25.realpathSync(dir);
|
|
32166
32999
|
} catch {
|
|
32167
33000
|
return dir;
|
|
32168
33001
|
}
|
|
@@ -32175,13 +33008,13 @@ async function addFolder2(dir, bind, strict = false) {
|
|
|
32175
33008
|
const subject = readSession().subject;
|
|
32176
33009
|
const why = refusal(dir);
|
|
32177
33010
|
if (why) return { error: why };
|
|
32178
|
-
const real =
|
|
33011
|
+
const real = fs25.realpathSync(dir);
|
|
32179
33012
|
const found = await folderOf(real);
|
|
32180
33013
|
if ("error" in found) return found;
|
|
32181
33014
|
let project = found.folder?.project;
|
|
32182
33015
|
if (found.folder && (bind ? bind !== project : strict)) return { error: "folder_taken", message: "taken", name: found.folder.name };
|
|
32183
33016
|
if (!project) {
|
|
32184
|
-
const added = await addFolder(machineId(),
|
|
33017
|
+
const added = await addFolder(machineId(), path29.basename(real) || real, real, bind);
|
|
32185
33018
|
if (!added.ok) return failure(added);
|
|
32186
33019
|
project = added.value.folder.project;
|
|
32187
33020
|
}
|
|
@@ -32216,7 +33049,7 @@ async function removeFolder2(project) {
|
|
|
32216
33049
|
}
|
|
32217
33050
|
function akbFile() {
|
|
32218
33051
|
try {
|
|
32219
|
-
return
|
|
33052
|
+
return path29.join(shimDir(bundledAkb()), process.platform === "win32" ? "akb.cmd" : "akb");
|
|
32220
33053
|
} catch {
|
|
32221
33054
|
return null;
|
|
32222
33055
|
}
|
|
@@ -32267,7 +33100,7 @@ async function settingsState(context) {
|
|
|
32267
33100
|
account,
|
|
32268
33101
|
connected: runner.ok && runner.value.runner?.connected,
|
|
32269
33102
|
workspaces: workspaces.value,
|
|
32270
|
-
projects: folders2.value.folders.map((f) => ({ ...f, ...metadata(f.project), busy: kept(f.path), missing: !
|
|
33103
|
+
projects: folders2.value.folders.map((f) => ({ ...f, ...metadata(f.project), busy: kept(f.path), missing: !fs25.existsSync(f.path) })),
|
|
32271
33104
|
elsewhere: projects.filter((p) => !p.general && !folders2.value.folders.some((f) => f.project === p.id)).map((p) => ({ project: p.id, name: p.name, ...metadata(p.id) })),
|
|
32272
33105
|
...context.project && !projects.some((p) => p.id === context.project) ? { error: "not_found" } : {}
|
|
32273
33106
|
};
|
|
@@ -32299,9 +33132,9 @@ async function settingsAction(action, body, context) {
|
|
|
32299
33132
|
if (!dir) return { cancelled: true };
|
|
32300
33133
|
const why = refusal(dir);
|
|
32301
33134
|
if (why) return { error: why };
|
|
32302
|
-
const real =
|
|
33135
|
+
const real = fs25.realpathSync(dir);
|
|
32303
33136
|
selected.set(context, { path: real, subject: readSession().subject });
|
|
32304
|
-
return { path: real, name:
|
|
33137
|
+
return { path: real, name: path29.basename(real) };
|
|
32305
33138
|
} catch {
|
|
32306
33139
|
return { error: "picker_unavailable" };
|
|
32307
33140
|
}
|
|
@@ -32328,7 +33161,7 @@ async function settingsAction(action, body, context) {
|
|
|
32328
33161
|
if ("error" in found) return found;
|
|
32329
33162
|
if (found.folder) return { error: "folder_taken" };
|
|
32330
33163
|
if (choice.subject !== readSession()?.subject) return { error: "signed_out" };
|
|
32331
|
-
if (!choice.creation || choice.creation.name !== name || choice.creation.workspace !== body.workspace) choice.creation = { key:
|
|
33164
|
+
if (!choice.creation || choice.creation.name !== name || choice.creation.workspace !== body.workspace) choice.creation = { key: crypto9.randomUUID(), name, workspace: body.workspace };
|
|
32332
33165
|
const created = choice.creation.project ? { ok: true, value: { id: choice.creation.project } } : await createProject(name, body.workspace, choice.creation.key);
|
|
32333
33166
|
if (!created.ok) return failure(created);
|
|
32334
33167
|
project = created.value.id;
|
|
@@ -32375,7 +33208,7 @@ async function terminalSettings(entry2) {
|
|
|
32375
33208
|
|
|
32376
33209
|
// src/launcher-main.ts
|
|
32377
33210
|
useRunnerHome();
|
|
32378
|
-
var entry =
|
|
33211
|
+
var entry = path30.join(path30.dirname(fileURLToPath3(import.meta.url)), "runner.mjs");
|
|
32379
33212
|
if (process.argv.includes("--settings")) {
|
|
32380
33213
|
terminalSettings(entry).catch(() => {
|
|
32381
33214
|
process.stderr.write("\u65E0\u6CD5\u6253\u5F00\u672C\u673A\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002\n");
|