wildcrane-runner 0.6.101 → 0.6.103
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 +1 -1
- package/dist/akb/dist/kanban.mjs +33712 -33586
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +1 -1
- package/dist/codex-retained.mjs +1 -1
- package/dist/flow-worker-main.mjs +827 -897
- package/dist/launcher.mjs +4 -18
- package/dist/plugin.mjs +8 -18
- package/dist/runner.mjs +897 -967
- package/dist/settings.mjs +4 -18
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.103 — 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;
|
|
@@ -1159,14 +1159,14 @@ var require_util = __commonJS({
|
|
|
1159
1159
|
}
|
|
1160
1160
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
1161
1161
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
1162
|
-
let
|
|
1162
|
+
let path54 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
1163
1163
|
if (origin[origin.length - 1] === "/") {
|
|
1164
1164
|
origin = origin.slice(0, origin.length - 1);
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1167
|
-
|
|
1166
|
+
if (path54 && path54[0] !== "/") {
|
|
1167
|
+
path54 = `/${path54}`;
|
|
1168
1168
|
}
|
|
1169
|
-
return new URL(`${origin}${
|
|
1169
|
+
return new URL(`${origin}${path54}`);
|
|
1170
1170
|
}
|
|
1171
1171
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
1172
1172
|
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -2001,9 +2001,9 @@ var require_diagnostics = __commonJS({
|
|
|
2001
2001
|
"undici:client:sendHeaders",
|
|
2002
2002
|
(evt) => {
|
|
2003
2003
|
const {
|
|
2004
|
-
request: { method, path:
|
|
2004
|
+
request: { method, path: path54, origin }
|
|
2005
2005
|
} = evt;
|
|
2006
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
2006
|
+
debugLog("sending request to %s %s%s", method, origin, path54);
|
|
2007
2007
|
}
|
|
2008
2008
|
);
|
|
2009
2009
|
}
|
|
@@ -2021,14 +2021,14 @@ var require_diagnostics = __commonJS({
|
|
|
2021
2021
|
"undici:request:headers",
|
|
2022
2022
|
(evt) => {
|
|
2023
2023
|
const {
|
|
2024
|
-
request: { method, path:
|
|
2024
|
+
request: { method, path: path54, origin },
|
|
2025
2025
|
response: { statusCode }
|
|
2026
2026
|
} = evt;
|
|
2027
2027
|
debugLog(
|
|
2028
2028
|
"received response to %s %s%s - HTTP %d",
|
|
2029
2029
|
method,
|
|
2030
2030
|
origin,
|
|
2031
|
-
|
|
2031
|
+
path54,
|
|
2032
2032
|
statusCode
|
|
2033
2033
|
);
|
|
2034
2034
|
}
|
|
@@ -2037,23 +2037,23 @@ var require_diagnostics = __commonJS({
|
|
|
2037
2037
|
"undici:request:trailers",
|
|
2038
2038
|
(evt) => {
|
|
2039
2039
|
const {
|
|
2040
|
-
request: { method, path:
|
|
2040
|
+
request: { method, path: path54, origin }
|
|
2041
2041
|
} = evt;
|
|
2042
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
2042
|
+
debugLog("trailers received from %s %s%s", method, origin, path54);
|
|
2043
2043
|
}
|
|
2044
2044
|
);
|
|
2045
2045
|
diagnosticsChannel.subscribe(
|
|
2046
2046
|
"undici:request:error",
|
|
2047
2047
|
(evt) => {
|
|
2048
2048
|
const {
|
|
2049
|
-
request: { method, path:
|
|
2049
|
+
request: { method, path: path54, origin },
|
|
2050
2050
|
error: error62
|
|
2051
2051
|
} = evt;
|
|
2052
2052
|
debugLog(
|
|
2053
2053
|
"request to %s %s%s errored - %s",
|
|
2054
2054
|
method,
|
|
2055
2055
|
origin,
|
|
2056
|
-
|
|
2056
|
+
path54,
|
|
2057
2057
|
error62.message
|
|
2058
2058
|
);
|
|
2059
2059
|
}
|
|
@@ -2168,7 +2168,7 @@ var require_request = __commonJS({
|
|
|
2168
2168
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
2169
2169
|
var Request = class {
|
|
2170
2170
|
constructor(origin, {
|
|
2171
|
-
path:
|
|
2171
|
+
path: path54,
|
|
2172
2172
|
method,
|
|
2173
2173
|
body,
|
|
2174
2174
|
headers,
|
|
@@ -2185,11 +2185,11 @@ var require_request = __commonJS({
|
|
|
2185
2185
|
maxRedirections,
|
|
2186
2186
|
typeOfService
|
|
2187
2187
|
}, handler) {
|
|
2188
|
-
if (typeof
|
|
2188
|
+
if (typeof path54 !== "string") {
|
|
2189
2189
|
throw new InvalidArgumentError("path must be a string");
|
|
2190
|
-
} else if (
|
|
2190
|
+
} else if (path54[0] !== "/" && !(path54.startsWith("http://") || path54.startsWith("https://")) && method !== "CONNECT") {
|
|
2191
2191
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
2192
|
-
} else if (invalidPathRegex.test(
|
|
2192
|
+
} else if (invalidPathRegex.test(path54)) {
|
|
2193
2193
|
throw new InvalidArgumentError("invalid request path");
|
|
2194
2194
|
}
|
|
2195
2195
|
if (typeof method !== "string") {
|
|
@@ -2264,7 +2264,7 @@ var require_request = __commonJS({
|
|
|
2264
2264
|
this.completed = false;
|
|
2265
2265
|
this.aborted = false;
|
|
2266
2266
|
this.upgrade = upgrade || null;
|
|
2267
|
-
this.path = query ? serializePathWithQuery(
|
|
2267
|
+
this.path = query ? serializePathWithQuery(path54, query) : path54;
|
|
2268
2268
|
this.origin = origin;
|
|
2269
2269
|
this.protocol = getProtocolFromUrlString(origin);
|
|
2270
2270
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -7508,7 +7508,7 @@ var require_client_h1 = __commonJS({
|
|
|
7508
7508
|
}
|
|
7509
7509
|
}
|
|
7510
7510
|
function writeH1(client, request2) {
|
|
7511
|
-
const { method, path:
|
|
7511
|
+
const { method, path: path54, host, upgrade, blocking, reset } = request2;
|
|
7512
7512
|
let { body, headers, contentLength } = request2;
|
|
7513
7513
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
7514
7514
|
if (util.isFormDataLike(body)) {
|
|
@@ -7584,7 +7584,7 @@ var require_client_h1 = __commonJS({
|
|
|
7584
7584
|
socket[kBlocking] = true;
|
|
7585
7585
|
}
|
|
7586
7586
|
setTypeOfService(socket, request2);
|
|
7587
|
-
let header = `${method} ${
|
|
7587
|
+
let header = `${method} ${path54} HTTP/1.1\r
|
|
7588
7588
|
`;
|
|
7589
7589
|
if (typeof host === "string") {
|
|
7590
7590
|
header += `host: ${host}\r
|
|
@@ -8261,7 +8261,7 @@ var require_client_h2 = __commonJS({
|
|
|
8261
8261
|
const headersTimeout = request2.headersTimeout ?? client[kHeadersTimeout];
|
|
8262
8262
|
const bodyTimeout = request2.bodyTimeout ?? client[kBodyTimeout];
|
|
8263
8263
|
const session = client[kHTTP2Session];
|
|
8264
|
-
const { method, path:
|
|
8264
|
+
const { method, path: path54, host, upgrade, expectContinue, signal: signal2, protocol, headers: reqHeaders } = request2;
|
|
8265
8265
|
let { body } = request2;
|
|
8266
8266
|
if (upgrade != null && upgrade !== "websocket") {
|
|
8267
8267
|
util.errorRequest(client, request2, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -8330,7 +8330,7 @@ var require_client_h2 = __commonJS({
|
|
|
8330
8330
|
}
|
|
8331
8331
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
8332
8332
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
8333
|
-
headers[HTTP2_HEADER_PATH] =
|
|
8333
|
+
headers[HTTP2_HEADER_PATH] = path54;
|
|
8334
8334
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
8335
8335
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
8336
8336
|
} else {
|
|
@@ -8382,7 +8382,7 @@ var require_client_h2 = __commonJS({
|
|
|
8382
8382
|
stream.setTimeout(headersTimeout);
|
|
8383
8383
|
return true;
|
|
8384
8384
|
}
|
|
8385
|
-
headers[HTTP2_HEADER_PATH] =
|
|
8385
|
+
headers[HTTP2_HEADER_PATH] = path54;
|
|
8386
8386
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
8387
8387
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
8388
8388
|
if (body && typeof body.read === "function") {
|
|
@@ -10738,10 +10738,10 @@ var require_proxy_agent = __commonJS({
|
|
|
10738
10738
|
};
|
|
10739
10739
|
const {
|
|
10740
10740
|
origin,
|
|
10741
|
-
path:
|
|
10741
|
+
path: path54 = "/",
|
|
10742
10742
|
headers = {}
|
|
10743
10743
|
} = opts;
|
|
10744
|
-
opts.path = origin +
|
|
10744
|
+
opts.path = origin + path54;
|
|
10745
10745
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
10746
10746
|
const { host } = new URL(origin);
|
|
10747
10747
|
headers.host = host;
|
|
@@ -12901,20 +12901,20 @@ var require_mock_utils = __commonJS({
|
|
|
12901
12901
|
}
|
|
12902
12902
|
return normalizedQp;
|
|
12903
12903
|
}
|
|
12904
|
-
function safeUrl(
|
|
12905
|
-
if (typeof
|
|
12906
|
-
return
|
|
12904
|
+
function safeUrl(path54) {
|
|
12905
|
+
if (typeof path54 !== "string") {
|
|
12906
|
+
return path54;
|
|
12907
12907
|
}
|
|
12908
|
-
const pathSegments =
|
|
12908
|
+
const pathSegments = path54.split("?", 3);
|
|
12909
12909
|
if (pathSegments.length !== 2) {
|
|
12910
|
-
return
|
|
12910
|
+
return path54;
|
|
12911
12911
|
}
|
|
12912
12912
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
12913
12913
|
qp.sort();
|
|
12914
12914
|
return [...pathSegments, qp.toString()].join("?");
|
|
12915
12915
|
}
|
|
12916
|
-
function matchKey(mockDispatch2, { path:
|
|
12917
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
12916
|
+
function matchKey(mockDispatch2, { path: path54, method, body, headers }) {
|
|
12917
|
+
const pathMatch = matchValue(mockDispatch2.path, path54);
|
|
12918
12918
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
12919
12919
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
12920
12920
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -12939,8 +12939,8 @@ var require_mock_utils = __commonJS({
|
|
|
12939
12939
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
12940
12940
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
12941
12941
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
12942
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
12943
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
12942
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path54, ignoreTrailingSlash }) => {
|
|
12943
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path54)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path54), resolvedPath);
|
|
12944
12944
|
});
|
|
12945
12945
|
if (matchedMockDispatches.length === 0) {
|
|
12946
12946
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -12979,19 +12979,19 @@ var require_mock_utils = __commonJS({
|
|
|
12979
12979
|
mockDispatches.splice(index, 1);
|
|
12980
12980
|
}
|
|
12981
12981
|
}
|
|
12982
|
-
function removeTrailingSlash(
|
|
12983
|
-
while (
|
|
12984
|
-
|
|
12982
|
+
function removeTrailingSlash(path54) {
|
|
12983
|
+
while (path54.endsWith("/")) {
|
|
12984
|
+
path54 = path54.slice(0, -1);
|
|
12985
12985
|
}
|
|
12986
|
-
if (
|
|
12987
|
-
|
|
12986
|
+
if (path54.length === 0) {
|
|
12987
|
+
path54 = "/";
|
|
12988
12988
|
}
|
|
12989
|
-
return
|
|
12989
|
+
return path54;
|
|
12990
12990
|
}
|
|
12991
12991
|
function buildKey(opts) {
|
|
12992
|
-
const { path:
|
|
12992
|
+
const { path: path54, method, body, headers, query } = opts;
|
|
12993
12993
|
return {
|
|
12994
|
-
path:
|
|
12994
|
+
path: path54,
|
|
12995
12995
|
method,
|
|
12996
12996
|
body,
|
|
12997
12997
|
headers,
|
|
@@ -13681,10 +13681,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
13681
13681
|
}
|
|
13682
13682
|
format(pendingInterceptors) {
|
|
13683
13683
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
13684
|
-
({ method, path:
|
|
13684
|
+
({ method, path: path54, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
13685
13685
|
Method: method,
|
|
13686
13686
|
Origin: origin,
|
|
13687
|
-
Path:
|
|
13687
|
+
Path: path54,
|
|
13688
13688
|
"Status code": statusCode,
|
|
13689
13689
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
13690
13690
|
Invocations: timesInvoked,
|
|
@@ -13766,9 +13766,9 @@ var require_mock_agent = __commonJS({
|
|
|
13766
13766
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
13767
13767
|
const dispatchOpts = { ...opts };
|
|
13768
13768
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
13769
|
-
const [
|
|
13769
|
+
const [path54, searchParams] = dispatchOpts.path.split("?");
|
|
13770
13770
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
13771
|
-
dispatchOpts.path = `${
|
|
13771
|
+
dispatchOpts.path = `${path54}?${normalizedSearchParams}`;
|
|
13772
13772
|
}
|
|
13773
13773
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
13774
13774
|
}
|
|
@@ -14169,12 +14169,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14169
14169
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
14170
14170
|
*/
|
|
14171
14171
|
async loadSnapshots(filePath) {
|
|
14172
|
-
const
|
|
14173
|
-
if (!
|
|
14172
|
+
const path54 = filePath || this.#snapshotPath;
|
|
14173
|
+
if (!path54) {
|
|
14174
14174
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
14175
14175
|
}
|
|
14176
14176
|
try {
|
|
14177
|
-
const data = await readFile2(resolve2(
|
|
14177
|
+
const data = await readFile2(resolve2(path54), "utf8");
|
|
14178
14178
|
const parsed = JSON.parse(data);
|
|
14179
14179
|
if (Array.isArray(parsed)) {
|
|
14180
14180
|
this.#snapshots.clear();
|
|
@@ -14188,7 +14188,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14188
14188
|
if (error62.code === "ENOENT") {
|
|
14189
14189
|
this.#snapshots.clear();
|
|
14190
14190
|
} else {
|
|
14191
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
14191
|
+
throw new UndiciError(`Failed to load snapshots from ${path54}`, { cause: error62 });
|
|
14192
14192
|
}
|
|
14193
14193
|
}
|
|
14194
14194
|
}
|
|
@@ -14199,11 +14199,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14199
14199
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
14200
14200
|
*/
|
|
14201
14201
|
async saveSnapshots(filePath) {
|
|
14202
|
-
const
|
|
14203
|
-
if (!
|
|
14202
|
+
const path54 = filePath || this.#snapshotPath;
|
|
14203
|
+
if (!path54) {
|
|
14204
14204
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
14205
14205
|
}
|
|
14206
|
-
const resolvedPath = resolve2(
|
|
14206
|
+
const resolvedPath = resolve2(path54);
|
|
14207
14207
|
await mkdir2(dirname(resolvedPath), { recursive: true });
|
|
14208
14208
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
14209
14209
|
hash: hash2,
|
|
@@ -14844,15 +14844,15 @@ var require_redirect_handler = __commonJS({
|
|
|
14844
14844
|
receivedAt: Date.now()
|
|
14845
14845
|
});
|
|
14846
14846
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
14847
|
-
const
|
|
14848
|
-
const redirectUrlString = `${origin}${
|
|
14847
|
+
const path54 = search ? `${pathname}${search}` : pathname;
|
|
14848
|
+
const redirectUrlString = `${origin}${path54}`;
|
|
14849
14849
|
for (const historyUrl of this.history) {
|
|
14850
14850
|
if (historyUrl.toString() === redirectUrlString) {
|
|
14851
14851
|
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.`);
|
|
14852
14852
|
}
|
|
14853
14853
|
}
|
|
14854
14854
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
14855
|
-
this.opts.path =
|
|
14855
|
+
this.opts.path = path54;
|
|
14856
14856
|
this.opts.origin = origin;
|
|
14857
14857
|
this.opts.query = null;
|
|
14858
14858
|
}
|
|
@@ -16669,10 +16669,10 @@ var require_cache_handler = __commonJS({
|
|
|
16669
16669
|
}
|
|
16670
16670
|
return locationUrl.pathname + locationUrl.search;
|
|
16671
16671
|
}
|
|
16672
|
-
function deleteCachedUri(store, cacheKey,
|
|
16672
|
+
function deleteCachedUri(store, cacheKey, path54) {
|
|
16673
16673
|
deleteCachedValue(store, {
|
|
16674
16674
|
...cacheKey,
|
|
16675
|
-
path:
|
|
16675
|
+
path: path54
|
|
16676
16676
|
});
|
|
16677
16677
|
for (let i = 0; i < util.safeHTTPMethods.length; i++) {
|
|
16678
16678
|
const method = util.safeHTTPMethods[i];
|
|
@@ -16680,7 +16680,7 @@ var require_cache_handler = __commonJS({
|
|
|
16680
16680
|
deleteCachedValue(store, {
|
|
16681
16681
|
...cacheKey,
|
|
16682
16682
|
method,
|
|
16683
|
-
path:
|
|
16683
|
+
path: path54
|
|
16684
16684
|
});
|
|
16685
16685
|
}
|
|
16686
16686
|
}
|
|
@@ -16691,9 +16691,9 @@ var require_cache_handler = __commonJS({
|
|
|
16691
16691
|
}
|
|
16692
16692
|
const values = Array.isArray(headerValue) ? headerValue : [headerValue];
|
|
16693
16693
|
for (let i = 0; i < values.length; i++) {
|
|
16694
|
-
const
|
|
16695
|
-
if (
|
|
16696
|
-
deleteCachedUri(store, cacheKey,
|
|
16694
|
+
const path54 = getSameOriginPath(cacheKey, values[i]);
|
|
16695
|
+
if (path54 !== void 0) {
|
|
16696
|
+
deleteCachedUri(store, cacheKey, path54);
|
|
16697
16697
|
}
|
|
16698
16698
|
}
|
|
16699
16699
|
}
|
|
@@ -22181,11 +22181,11 @@ var require_fetch = __commonJS({
|
|
|
22181
22181
|
function dispatch({ body }) {
|
|
22182
22182
|
const url2 = requestCurrentURL(request2);
|
|
22183
22183
|
const agent = fetchParams.controller.dispatcher;
|
|
22184
|
-
const
|
|
22184
|
+
const path54 = url2.pathname + url2.search;
|
|
22185
22185
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
22186
22186
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
22187
22187
|
{
|
|
22188
|
-
path: hasTrailingQuestionMark ? `${
|
|
22188
|
+
path: hasTrailingQuestionMark ? `${path54}?` : path54,
|
|
22189
22189
|
origin: url2.origin,
|
|
22190
22190
|
method: request2.method,
|
|
22191
22191
|
body: agent.isMockActive ? request2.body && (request2.body.source || request2.body.stream) : body,
|
|
@@ -23132,9 +23132,9 @@ var require_util4 = __commonJS({
|
|
|
23132
23132
|
}
|
|
23133
23133
|
}
|
|
23134
23134
|
}
|
|
23135
|
-
function validateCookiePath(
|
|
23136
|
-
for (let i = 0; i <
|
|
23137
|
-
const code =
|
|
23135
|
+
function validateCookiePath(path54) {
|
|
23136
|
+
for (let i = 0; i < path54.length; ++i) {
|
|
23137
|
+
const code = path54.charCodeAt(i);
|
|
23138
23138
|
if (code < 32 || // exclude CTLs (0-31)
|
|
23139
23139
|
code > 126 || // exclude DEL and non-ascii
|
|
23140
23140
|
code === 59) {
|
|
@@ -26570,11 +26570,11 @@ var require_undici = __commonJS({
|
|
|
26570
26570
|
if (typeof opts.path !== "string") {
|
|
26571
26571
|
throw new InvalidArgumentError("invalid opts.path");
|
|
26572
26572
|
}
|
|
26573
|
-
let
|
|
26573
|
+
let path54 = opts.path;
|
|
26574
26574
|
if (!opts.path.startsWith("/")) {
|
|
26575
|
-
|
|
26575
|
+
path54 = `/${path54}`;
|
|
26576
26576
|
}
|
|
26577
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
26577
|
+
url2 = new URL(util.parseOrigin(url2).origin + path54);
|
|
26578
26578
|
} else {
|
|
26579
26579
|
if (!opts) {
|
|
26580
26580
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -26760,17 +26760,17 @@ var require_visit = __commonJS({
|
|
|
26760
26760
|
visit2.BREAK = BREAK;
|
|
26761
26761
|
visit2.SKIP = SKIP;
|
|
26762
26762
|
visit2.REMOVE = REMOVE;
|
|
26763
|
-
function visit_(key, node2, visitor,
|
|
26764
|
-
const ctrl = callVisitor(key, node2, visitor,
|
|
26763
|
+
function visit_(key, node2, visitor, path54) {
|
|
26764
|
+
const ctrl = callVisitor(key, node2, visitor, path54);
|
|
26765
26765
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
26766
|
-
replaceNode(key,
|
|
26767
|
-
return visit_(key, ctrl, visitor,
|
|
26766
|
+
replaceNode(key, path54, ctrl);
|
|
26767
|
+
return visit_(key, ctrl, visitor, path54);
|
|
26768
26768
|
}
|
|
26769
26769
|
if (typeof ctrl !== "symbol") {
|
|
26770
26770
|
if (identity.isCollection(node2)) {
|
|
26771
|
-
|
|
26771
|
+
path54 = Object.freeze(path54.concat(node2));
|
|
26772
26772
|
for (let i = 0; i < node2.items.length; ++i) {
|
|
26773
|
-
const ci2 = visit_(i, node2.items[i], visitor,
|
|
26773
|
+
const ci2 = visit_(i, node2.items[i], visitor, path54);
|
|
26774
26774
|
if (typeof ci2 === "number")
|
|
26775
26775
|
i = ci2 - 1;
|
|
26776
26776
|
else if (ci2 === BREAK)
|
|
@@ -26781,13 +26781,13 @@ var require_visit = __commonJS({
|
|
|
26781
26781
|
}
|
|
26782
26782
|
}
|
|
26783
26783
|
} else if (identity.isPair(node2)) {
|
|
26784
|
-
|
|
26785
|
-
const ck = visit_("key", node2.key, visitor,
|
|
26784
|
+
path54 = Object.freeze(path54.concat(node2));
|
|
26785
|
+
const ck = visit_("key", node2.key, visitor, path54);
|
|
26786
26786
|
if (ck === BREAK)
|
|
26787
26787
|
return BREAK;
|
|
26788
26788
|
else if (ck === REMOVE)
|
|
26789
26789
|
node2.key = null;
|
|
26790
|
-
const cv = visit_("value", node2.value, visitor,
|
|
26790
|
+
const cv = visit_("value", node2.value, visitor, path54);
|
|
26791
26791
|
if (cv === BREAK)
|
|
26792
26792
|
return BREAK;
|
|
26793
26793
|
else if (cv === REMOVE)
|
|
@@ -26808,17 +26808,17 @@ var require_visit = __commonJS({
|
|
|
26808
26808
|
visitAsync.BREAK = BREAK;
|
|
26809
26809
|
visitAsync.SKIP = SKIP;
|
|
26810
26810
|
visitAsync.REMOVE = REMOVE;
|
|
26811
|
-
async function visitAsync_(key, node2, visitor,
|
|
26812
|
-
const ctrl = await callVisitor(key, node2, visitor,
|
|
26811
|
+
async function visitAsync_(key, node2, visitor, path54) {
|
|
26812
|
+
const ctrl = await callVisitor(key, node2, visitor, path54);
|
|
26813
26813
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
26814
|
-
replaceNode(key,
|
|
26815
|
-
return visitAsync_(key, ctrl, visitor,
|
|
26814
|
+
replaceNode(key, path54, ctrl);
|
|
26815
|
+
return visitAsync_(key, ctrl, visitor, path54);
|
|
26816
26816
|
}
|
|
26817
26817
|
if (typeof ctrl !== "symbol") {
|
|
26818
26818
|
if (identity.isCollection(node2)) {
|
|
26819
|
-
|
|
26819
|
+
path54 = Object.freeze(path54.concat(node2));
|
|
26820
26820
|
for (let i = 0; i < node2.items.length; ++i) {
|
|
26821
|
-
const ci2 = await visitAsync_(i, node2.items[i], visitor,
|
|
26821
|
+
const ci2 = await visitAsync_(i, node2.items[i], visitor, path54);
|
|
26822
26822
|
if (typeof ci2 === "number")
|
|
26823
26823
|
i = ci2 - 1;
|
|
26824
26824
|
else if (ci2 === BREAK)
|
|
@@ -26829,13 +26829,13 @@ var require_visit = __commonJS({
|
|
|
26829
26829
|
}
|
|
26830
26830
|
}
|
|
26831
26831
|
} else if (identity.isPair(node2)) {
|
|
26832
|
-
|
|
26833
|
-
const ck = await visitAsync_("key", node2.key, visitor,
|
|
26832
|
+
path54 = Object.freeze(path54.concat(node2));
|
|
26833
|
+
const ck = await visitAsync_("key", node2.key, visitor, path54);
|
|
26834
26834
|
if (ck === BREAK)
|
|
26835
26835
|
return BREAK;
|
|
26836
26836
|
else if (ck === REMOVE)
|
|
26837
26837
|
node2.key = null;
|
|
26838
|
-
const cv = await visitAsync_("value", node2.value, visitor,
|
|
26838
|
+
const cv = await visitAsync_("value", node2.value, visitor, path54);
|
|
26839
26839
|
if (cv === BREAK)
|
|
26840
26840
|
return BREAK;
|
|
26841
26841
|
else if (cv === REMOVE)
|
|
@@ -26862,23 +26862,23 @@ var require_visit = __commonJS({
|
|
|
26862
26862
|
}
|
|
26863
26863
|
return visitor;
|
|
26864
26864
|
}
|
|
26865
|
-
function callVisitor(key, node2, visitor,
|
|
26865
|
+
function callVisitor(key, node2, visitor, path54) {
|
|
26866
26866
|
if (typeof visitor === "function")
|
|
26867
|
-
return visitor(key, node2,
|
|
26867
|
+
return visitor(key, node2, path54);
|
|
26868
26868
|
if (identity.isMap(node2))
|
|
26869
|
-
return visitor.Map?.(key, node2,
|
|
26869
|
+
return visitor.Map?.(key, node2, path54);
|
|
26870
26870
|
if (identity.isSeq(node2))
|
|
26871
|
-
return visitor.Seq?.(key, node2,
|
|
26871
|
+
return visitor.Seq?.(key, node2, path54);
|
|
26872
26872
|
if (identity.isPair(node2))
|
|
26873
|
-
return visitor.Pair?.(key, node2,
|
|
26873
|
+
return visitor.Pair?.(key, node2, path54);
|
|
26874
26874
|
if (identity.isScalar(node2))
|
|
26875
|
-
return visitor.Scalar?.(key, node2,
|
|
26875
|
+
return visitor.Scalar?.(key, node2, path54);
|
|
26876
26876
|
if (identity.isAlias(node2))
|
|
26877
|
-
return visitor.Alias?.(key, node2,
|
|
26877
|
+
return visitor.Alias?.(key, node2, path54);
|
|
26878
26878
|
return void 0;
|
|
26879
26879
|
}
|
|
26880
|
-
function replaceNode(key,
|
|
26881
|
-
const parent =
|
|
26880
|
+
function replaceNode(key, path54, node2) {
|
|
26881
|
+
const parent = path54[path54.length - 1];
|
|
26882
26882
|
if (identity.isCollection(parent)) {
|
|
26883
26883
|
parent.items[key] = node2;
|
|
26884
26884
|
} else if (identity.isPair(parent)) {
|
|
@@ -27490,10 +27490,10 @@ var require_Collection = __commonJS({
|
|
|
27490
27490
|
var createNode = require_createNode();
|
|
27491
27491
|
var identity = require_identity();
|
|
27492
27492
|
var Node = require_Node();
|
|
27493
|
-
function collectionFromPath(schema,
|
|
27493
|
+
function collectionFromPath(schema, path54, value) {
|
|
27494
27494
|
let v = value;
|
|
27495
|
-
for (let i =
|
|
27496
|
-
const k2 =
|
|
27495
|
+
for (let i = path54.length - 1; i >= 0; --i) {
|
|
27496
|
+
const k2 = path54[i];
|
|
27497
27497
|
if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
|
|
27498
27498
|
const a2 = [];
|
|
27499
27499
|
a2[k2] = v;
|
|
@@ -27512,7 +27512,7 @@ var require_Collection = __commonJS({
|
|
|
27512
27512
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
27513
27513
|
});
|
|
27514
27514
|
}
|
|
27515
|
-
var isEmptyPath = (
|
|
27515
|
+
var isEmptyPath = (path54) => path54 == null || typeof path54 === "object" && !!path54[Symbol.iterator]().next().done;
|
|
27516
27516
|
var Collection = class extends Node.NodeBase {
|
|
27517
27517
|
constructor(type, schema) {
|
|
27518
27518
|
super(type);
|
|
@@ -27542,11 +27542,11 @@ var require_Collection = __commonJS({
|
|
|
27542
27542
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
27543
27543
|
* that already exists in the map.
|
|
27544
27544
|
*/
|
|
27545
|
-
addIn(
|
|
27546
|
-
if (isEmptyPath(
|
|
27545
|
+
addIn(path54, value) {
|
|
27546
|
+
if (isEmptyPath(path54))
|
|
27547
27547
|
this.add(value);
|
|
27548
27548
|
else {
|
|
27549
|
-
const [key, ...rest] =
|
|
27549
|
+
const [key, ...rest] = path54;
|
|
27550
27550
|
const node2 = this.get(key, true);
|
|
27551
27551
|
if (identity.isCollection(node2))
|
|
27552
27552
|
node2.addIn(rest, value);
|
|
@@ -27560,8 +27560,8 @@ var require_Collection = __commonJS({
|
|
|
27560
27560
|
* Removes a value from the collection.
|
|
27561
27561
|
* @returns `true` if the item was found and removed.
|
|
27562
27562
|
*/
|
|
27563
|
-
deleteIn(
|
|
27564
|
-
const [key, ...rest] =
|
|
27563
|
+
deleteIn(path54) {
|
|
27564
|
+
const [key, ...rest] = path54;
|
|
27565
27565
|
if (rest.length === 0)
|
|
27566
27566
|
return this.delete(key);
|
|
27567
27567
|
const node2 = this.get(key, true);
|
|
@@ -27575,8 +27575,8 @@ var require_Collection = __commonJS({
|
|
|
27575
27575
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
27576
27576
|
* `true` (collections are always returned intact).
|
|
27577
27577
|
*/
|
|
27578
|
-
getIn(
|
|
27579
|
-
const [key, ...rest] =
|
|
27578
|
+
getIn(path54, keepScalar) {
|
|
27579
|
+
const [key, ...rest] = path54;
|
|
27580
27580
|
const node2 = this.get(key, true);
|
|
27581
27581
|
if (rest.length === 0)
|
|
27582
27582
|
return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
|
|
@@ -27594,8 +27594,8 @@ var require_Collection = __commonJS({
|
|
|
27594
27594
|
/**
|
|
27595
27595
|
* Checks if the collection includes a value with the key `key`.
|
|
27596
27596
|
*/
|
|
27597
|
-
hasIn(
|
|
27598
|
-
const [key, ...rest] =
|
|
27597
|
+
hasIn(path54) {
|
|
27598
|
+
const [key, ...rest] = path54;
|
|
27599
27599
|
if (rest.length === 0)
|
|
27600
27600
|
return this.has(key);
|
|
27601
27601
|
const node2 = this.get(key, true);
|
|
@@ -27605,8 +27605,8 @@ var require_Collection = __commonJS({
|
|
|
27605
27605
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
27606
27606
|
* boolean to add/remove the item from the set.
|
|
27607
27607
|
*/
|
|
27608
|
-
setIn(
|
|
27609
|
-
const [key, ...rest] =
|
|
27608
|
+
setIn(path54, value) {
|
|
27609
|
+
const [key, ...rest] = path54;
|
|
27610
27610
|
if (rest.length === 0) {
|
|
27611
27611
|
this.set(key, value);
|
|
27612
27612
|
} else {
|
|
@@ -30121,9 +30121,9 @@ var require_Document = __commonJS({
|
|
|
30121
30121
|
this.contents.add(value);
|
|
30122
30122
|
}
|
|
30123
30123
|
/** Adds a value to the document. */
|
|
30124
|
-
addIn(
|
|
30124
|
+
addIn(path54, value) {
|
|
30125
30125
|
if (assertCollection(this.contents))
|
|
30126
|
-
this.contents.addIn(
|
|
30126
|
+
this.contents.addIn(path54, value);
|
|
30127
30127
|
}
|
|
30128
30128
|
/**
|
|
30129
30129
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -30198,14 +30198,14 @@ var require_Document = __commonJS({
|
|
|
30198
30198
|
* Removes a value from the document.
|
|
30199
30199
|
* @returns `true` if the item was found and removed.
|
|
30200
30200
|
*/
|
|
30201
|
-
deleteIn(
|
|
30202
|
-
if (Collection.isEmptyPath(
|
|
30201
|
+
deleteIn(path54) {
|
|
30202
|
+
if (Collection.isEmptyPath(path54)) {
|
|
30203
30203
|
if (this.contents == null)
|
|
30204
30204
|
return false;
|
|
30205
30205
|
this.contents = null;
|
|
30206
30206
|
return true;
|
|
30207
30207
|
}
|
|
30208
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
30208
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path54) : false;
|
|
30209
30209
|
}
|
|
30210
30210
|
/**
|
|
30211
30211
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -30220,10 +30220,10 @@ var require_Document = __commonJS({
|
|
|
30220
30220
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
30221
30221
|
* `true` (collections are always returned intact).
|
|
30222
30222
|
*/
|
|
30223
|
-
getIn(
|
|
30224
|
-
if (Collection.isEmptyPath(
|
|
30223
|
+
getIn(path54, keepScalar) {
|
|
30224
|
+
if (Collection.isEmptyPath(path54))
|
|
30225
30225
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
30226
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
30226
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path54, keepScalar) : void 0;
|
|
30227
30227
|
}
|
|
30228
30228
|
/**
|
|
30229
30229
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -30234,10 +30234,10 @@ var require_Document = __commonJS({
|
|
|
30234
30234
|
/**
|
|
30235
30235
|
* Checks if the document includes a value at `path`.
|
|
30236
30236
|
*/
|
|
30237
|
-
hasIn(
|
|
30238
|
-
if (Collection.isEmptyPath(
|
|
30237
|
+
hasIn(path54) {
|
|
30238
|
+
if (Collection.isEmptyPath(path54))
|
|
30239
30239
|
return this.contents !== void 0;
|
|
30240
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
30240
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path54) : false;
|
|
30241
30241
|
}
|
|
30242
30242
|
/**
|
|
30243
30243
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -30254,13 +30254,13 @@ var require_Document = __commonJS({
|
|
|
30254
30254
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
30255
30255
|
* boolean to add/remove the item from the set.
|
|
30256
30256
|
*/
|
|
30257
|
-
setIn(
|
|
30258
|
-
if (Collection.isEmptyPath(
|
|
30257
|
+
setIn(path54, value) {
|
|
30258
|
+
if (Collection.isEmptyPath(path54)) {
|
|
30259
30259
|
this.contents = value;
|
|
30260
30260
|
} else if (this.contents == null) {
|
|
30261
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
30261
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path54), value);
|
|
30262
30262
|
} else if (assertCollection(this.contents)) {
|
|
30263
|
-
this.contents.setIn(
|
|
30263
|
+
this.contents.setIn(path54, value);
|
|
30264
30264
|
}
|
|
30265
30265
|
}
|
|
30266
30266
|
/**
|
|
@@ -32221,9 +32221,9 @@ var require_cst_visit = __commonJS({
|
|
|
32221
32221
|
visit2.BREAK = BREAK;
|
|
32222
32222
|
visit2.SKIP = SKIP;
|
|
32223
32223
|
visit2.REMOVE = REMOVE;
|
|
32224
|
-
visit2.itemAtPath = (cst,
|
|
32224
|
+
visit2.itemAtPath = (cst, path54) => {
|
|
32225
32225
|
let item = cst;
|
|
32226
|
-
for (const [field, index] of
|
|
32226
|
+
for (const [field, index] of path54) {
|
|
32227
32227
|
const tok = item?.[field];
|
|
32228
32228
|
if (tok && "items" in tok) {
|
|
32229
32229
|
item = tok.items[index];
|
|
@@ -32232,23 +32232,23 @@ var require_cst_visit = __commonJS({
|
|
|
32232
32232
|
}
|
|
32233
32233
|
return item;
|
|
32234
32234
|
};
|
|
32235
|
-
visit2.parentCollection = (cst,
|
|
32236
|
-
const parent = visit2.itemAtPath(cst,
|
|
32237
|
-
const field =
|
|
32235
|
+
visit2.parentCollection = (cst, path54) => {
|
|
32236
|
+
const parent = visit2.itemAtPath(cst, path54.slice(0, -1));
|
|
32237
|
+
const field = path54[path54.length - 1][0];
|
|
32238
32238
|
const coll = parent?.[field];
|
|
32239
32239
|
if (coll && "items" in coll)
|
|
32240
32240
|
return coll;
|
|
32241
32241
|
throw new Error("Parent collection not found");
|
|
32242
32242
|
};
|
|
32243
|
-
function _visit(
|
|
32244
|
-
let ctrl = visitor(item,
|
|
32243
|
+
function _visit(path54, item, visitor) {
|
|
32244
|
+
let ctrl = visitor(item, path54);
|
|
32245
32245
|
if (typeof ctrl === "symbol")
|
|
32246
32246
|
return ctrl;
|
|
32247
32247
|
for (const field of ["key", "value"]) {
|
|
32248
32248
|
const token = item[field];
|
|
32249
32249
|
if (token && "items" in token) {
|
|
32250
32250
|
for (let i = 0; i < token.items.length; ++i) {
|
|
32251
|
-
const ci2 = _visit(Object.freeze(
|
|
32251
|
+
const ci2 = _visit(Object.freeze(path54.concat([[field, i]])), token.items[i], visitor);
|
|
32252
32252
|
if (typeof ci2 === "number")
|
|
32253
32253
|
i = ci2 - 1;
|
|
32254
32254
|
else if (ci2 === BREAK)
|
|
@@ -32259,10 +32259,10 @@ var require_cst_visit = __commonJS({
|
|
|
32259
32259
|
}
|
|
32260
32260
|
}
|
|
32261
32261
|
if (typeof ctrl === "function" && field === "key")
|
|
32262
|
-
ctrl = ctrl(item,
|
|
32262
|
+
ctrl = ctrl(item, path54);
|
|
32263
32263
|
}
|
|
32264
32264
|
}
|
|
32265
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
32265
|
+
return typeof ctrl === "function" ? ctrl(item, path54) : ctrl;
|
|
32266
32266
|
}
|
|
32267
32267
|
exports.visit = visit2;
|
|
32268
32268
|
}
|
|
@@ -33564,14 +33564,14 @@ var require_parser = __commonJS({
|
|
|
33564
33564
|
case "scalar":
|
|
33565
33565
|
case "single-quoted-scalar":
|
|
33566
33566
|
case "double-quoted-scalar": {
|
|
33567
|
-
const
|
|
33567
|
+
const fs49 = this.flowScalar(this.type);
|
|
33568
33568
|
if (atNextItem || it2.value) {
|
|
33569
|
-
map3.items.push({ start, key:
|
|
33569
|
+
map3.items.push({ start, key: fs49, sep: [] });
|
|
33570
33570
|
this.onKeyLine = true;
|
|
33571
33571
|
} else if (it2.sep) {
|
|
33572
|
-
this.stack.push(
|
|
33572
|
+
this.stack.push(fs49);
|
|
33573
33573
|
} else {
|
|
33574
|
-
Object.assign(it2, { key:
|
|
33574
|
+
Object.assign(it2, { key: fs49, sep: [] });
|
|
33575
33575
|
this.onKeyLine = true;
|
|
33576
33576
|
}
|
|
33577
33577
|
return;
|
|
@@ -33699,13 +33699,13 @@ var require_parser = __commonJS({
|
|
|
33699
33699
|
case "scalar":
|
|
33700
33700
|
case "single-quoted-scalar":
|
|
33701
33701
|
case "double-quoted-scalar": {
|
|
33702
|
-
const
|
|
33702
|
+
const fs49 = this.flowScalar(this.type);
|
|
33703
33703
|
if (!it2 || it2.value)
|
|
33704
|
-
fc.items.push({ start: [], key:
|
|
33704
|
+
fc.items.push({ start: [], key: fs49, sep: [] });
|
|
33705
33705
|
else if (it2.sep)
|
|
33706
|
-
this.stack.push(
|
|
33706
|
+
this.stack.push(fs49);
|
|
33707
33707
|
else
|
|
33708
|
-
Object.assign(it2, { key:
|
|
33708
|
+
Object.assign(it2, { key: fs49, sep: [] });
|
|
33709
33709
|
return;
|
|
33710
33710
|
}
|
|
33711
33711
|
case "flow-map-end":
|
|
@@ -37252,8 +37252,8 @@ var require_utils2 = __commonJS({
|
|
|
37252
37252
|
}
|
|
37253
37253
|
return ind;
|
|
37254
37254
|
}
|
|
37255
|
-
function removeDotSegments(
|
|
37256
|
-
let input2 =
|
|
37255
|
+
function removeDotSegments(path54) {
|
|
37256
|
+
let input2 = path54;
|
|
37257
37257
|
const output3 = [];
|
|
37258
37258
|
let nextSlash = -1;
|
|
37259
37259
|
let len = 0;
|
|
@@ -37327,11 +37327,11 @@ var require_utils2 = __commonJS({
|
|
|
37327
37327
|
}
|
|
37328
37328
|
return output3.join("");
|
|
37329
37329
|
}
|
|
37330
|
-
function removeDotSegmentsRelative(
|
|
37331
|
-
if (
|
|
37332
|
-
return removeDotSegments(
|
|
37330
|
+
function removeDotSegmentsRelative(path54) {
|
|
37331
|
+
if (path54 === "" || path54[0] === "/") {
|
|
37332
|
+
return removeDotSegments(path54);
|
|
37333
37333
|
}
|
|
37334
|
-
const segments =
|
|
37334
|
+
const segments = path54.split("/");
|
|
37335
37335
|
const last = segments.length - 1;
|
|
37336
37336
|
const output3 = [];
|
|
37337
37337
|
let trailingDirectory = false;
|
|
@@ -37694,8 +37694,8 @@ var require_schemes = __commonJS({
|
|
|
37694
37694
|
}
|
|
37695
37695
|
if (wsComponent.resourceName) {
|
|
37696
37696
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
37697
|
-
const
|
|
37698
|
-
wsComponent.path =
|
|
37697
|
+
const path54 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
37698
|
+
wsComponent.path = path54 && path54 !== "/" ? path54 : void 0;
|
|
37699
37699
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
37700
37700
|
wsComponent.resourceName = void 0;
|
|
37701
37701
|
}
|
|
@@ -40929,16 +40929,16 @@ var require_ajv = __commonJS({
|
|
|
40929
40929
|
});
|
|
40930
40930
|
|
|
40931
40931
|
// ../cli/src/lib/dress-page.ts
|
|
40932
|
-
import
|
|
40933
|
-
import
|
|
40932
|
+
import fs29 from "node:fs";
|
|
40933
|
+
import path34 from "node:path";
|
|
40934
40934
|
function dressPage(file3) {
|
|
40935
|
-
const folder2 =
|
|
40936
|
-
const html =
|
|
40935
|
+
const folder2 = path34.dirname(file3);
|
|
40936
|
+
const html = fs29.readFileSync(file3, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
40937
40937
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
40938
40938
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
40939
|
-
const at3 =
|
|
40940
|
-
if (!at3.startsWith(folder2 +
|
|
40941
|
-
const css =
|
|
40939
|
+
const at3 = path34.resolve(folder2, href);
|
|
40940
|
+
if (!at3.startsWith(folder2 + path34.sep) || !fs29.existsSync(at3)) return tag;
|
|
40941
|
+
const css = fs29.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path34.relative(folder2, path34.resolve(path34.dirname(at3), src)).split(path34.sep).join("/")}${quote2})`);
|
|
40942
40942
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
40943
40943
|
});
|
|
40944
40944
|
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -40951,7 +40951,7 @@ var init_dress_page = __esm({
|
|
|
40951
40951
|
isHtmlFile = (file3) => /\.html?$/i.test(file3);
|
|
40952
40952
|
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
40953
40953
|
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
40954
|
-
referenceText = (file3) => isHtmlFile(file3) ? dressPage(file3) :
|
|
40954
|
+
referenceText = (file3) => isHtmlFile(file3) ? dressPage(file3) : fs29.readFileSync(file3, "utf8");
|
|
40955
40955
|
}
|
|
40956
40956
|
});
|
|
40957
40957
|
|
|
@@ -82162,8 +82162,8 @@ var require_JSXTransformer = __commonJS({
|
|
|
82162
82162
|
}
|
|
82163
82163
|
if (this.isAutomaticRuntime) {
|
|
82164
82164
|
if (this.importProcessor) {
|
|
82165
|
-
for (const [
|
|
82166
|
-
prefix += `var ${resolvedName} = require("${
|
|
82165
|
+
for (const [path54, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
|
|
82166
|
+
prefix += `var ${resolvedName} = require("${path54}");`;
|
|
82167
82167
|
}
|
|
82168
82168
|
} else {
|
|
82169
82169
|
const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
|
|
@@ -82356,11 +82356,11 @@ var require_JSXTransformer = __commonJS({
|
|
|
82356
82356
|
}
|
|
82357
82357
|
claimAutoImportedName(funcName, importPathSuffix) {
|
|
82358
82358
|
if (this.importProcessor) {
|
|
82359
|
-
const
|
|
82360
|
-
if (!this.cjsAutomaticModuleNameResolutions[
|
|
82361
|
-
this.cjsAutomaticModuleNameResolutions[
|
|
82359
|
+
const path54 = this.jsxImportSource + importPathSuffix;
|
|
82360
|
+
if (!this.cjsAutomaticModuleNameResolutions[path54]) {
|
|
82361
|
+
this.cjsAutomaticModuleNameResolutions[path54] = this.importProcessor.getFreeIdentifierForPath(path54);
|
|
82362
82362
|
}
|
|
82363
|
-
return `${this.cjsAutomaticModuleNameResolutions[
|
|
82363
|
+
return `${this.cjsAutomaticModuleNameResolutions[path54]}.${funcName}`;
|
|
82364
82364
|
} else {
|
|
82365
82365
|
if (!this.esmAutomaticImportNameResolutions[funcName]) {
|
|
82366
82366
|
this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
|
|
@@ -82796,7 +82796,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82796
82796
|
*/
|
|
82797
82797
|
pruneTypeOnlyImports() {
|
|
82798
82798
|
this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
|
|
82799
|
-
for (const [
|
|
82799
|
+
for (const [path54, importInfo] of this.importInfoByPath.entries()) {
|
|
82800
82800
|
if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
|
|
82801
82801
|
continue;
|
|
82802
82802
|
}
|
|
@@ -82806,7 +82806,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82806
82806
|
...importInfo.namedImports.map(({ localName }) => localName)
|
|
82807
82807
|
];
|
|
82808
82808
|
if (names2.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
|
|
82809
|
-
this.importsToReplace.set(
|
|
82809
|
+
this.importsToReplace.set(path54, "");
|
|
82810
82810
|
}
|
|
82811
82811
|
}
|
|
82812
82812
|
}
|
|
@@ -82814,7 +82814,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82814
82814
|
return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
|
|
82815
82815
|
}
|
|
82816
82816
|
generateImportReplacements() {
|
|
82817
|
-
for (const [
|
|
82817
|
+
for (const [path54, importInfo] of this.importInfoByPath.entries()) {
|
|
82818
82818
|
const {
|
|
82819
82819
|
defaultNames,
|
|
82820
82820
|
wildcardNames,
|
|
@@ -82824,17 +82824,17 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82824
82824
|
hasStarExport
|
|
82825
82825
|
} = importInfo;
|
|
82826
82826
|
if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
|
|
82827
|
-
this.importsToReplace.set(
|
|
82827
|
+
this.importsToReplace.set(path54, `require('${path54}');`);
|
|
82828
82828
|
continue;
|
|
82829
82829
|
}
|
|
82830
|
-
const primaryImportName = this.getFreeIdentifierForPath(
|
|
82830
|
+
const primaryImportName = this.getFreeIdentifierForPath(path54);
|
|
82831
82831
|
let secondaryImportName;
|
|
82832
82832
|
if (this.enableLegacyTypeScriptModuleInterop) {
|
|
82833
82833
|
secondaryImportName = primaryImportName;
|
|
82834
82834
|
} else {
|
|
82835
|
-
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(
|
|
82835
|
+
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path54);
|
|
82836
82836
|
}
|
|
82837
|
-
let requireCode = `var ${primaryImportName} = require('${
|
|
82837
|
+
let requireCode = `var ${primaryImportName} = require('${path54}');`;
|
|
82838
82838
|
if (wildcardNames.length > 0) {
|
|
82839
82839
|
for (const wildcardName of wildcardNames) {
|
|
82840
82840
|
const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
|
|
@@ -82862,7 +82862,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82862
82862
|
"createStarExport"
|
|
82863
82863
|
)}(${primaryImportName});`;
|
|
82864
82864
|
}
|
|
82865
|
-
this.importsToReplace.set(
|
|
82865
|
+
this.importsToReplace.set(path54, requireCode);
|
|
82866
82866
|
for (const defaultName of defaultNames) {
|
|
82867
82867
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
82868
82868
|
}
|
|
@@ -82871,8 +82871,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82871
82871
|
}
|
|
82872
82872
|
}
|
|
82873
82873
|
}
|
|
82874
|
-
getFreeIdentifierForPath(
|
|
82875
|
-
const components =
|
|
82874
|
+
getFreeIdentifierForPath(path54) {
|
|
82875
|
+
const components = path54.split("/");
|
|
82876
82876
|
const lastComponent = components[components.length - 1];
|
|
82877
82877
|
const baseName = lastComponent.replace(/\W/g, "");
|
|
82878
82878
|
return this.nameManager.claimFreeName(`_${baseName}`);
|
|
@@ -82917,8 +82917,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82917
82917
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
82918
82918
|
throw new Error("Expected string token at the end of import statement.");
|
|
82919
82919
|
}
|
|
82920
|
-
const
|
|
82921
|
-
const importInfo = this.getImportInfo(
|
|
82920
|
+
const path54 = this.tokens.stringValueAtIndex(index);
|
|
82921
|
+
const importInfo = this.getImportInfo(path54);
|
|
82922
82922
|
importInfo.defaultNames.push(...defaultNames);
|
|
82923
82923
|
importInfo.wildcardNames.push(...wildcardNames);
|
|
82924
82924
|
importInfo.namedImports.push(...namedImports);
|
|
@@ -82985,8 +82985,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
82985
82985
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
82986
82986
|
throw new Error("Expected string token at the end of import statement.");
|
|
82987
82987
|
}
|
|
82988
|
-
const
|
|
82989
|
-
const importInfo = this.getImportInfo(
|
|
82988
|
+
const path54 = this.tokens.stringValueAtIndex(index);
|
|
82989
|
+
const importInfo = this.getImportInfo(path54);
|
|
82990
82990
|
importInfo.namedExports.push(...namedImports);
|
|
82991
82991
|
}
|
|
82992
82992
|
preprocessExportStarAtIndex(index) {
|
|
@@ -83001,8 +83001,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
83001
83001
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
83002
83002
|
throw new Error("Expected string token at the end of star export statement.");
|
|
83003
83003
|
}
|
|
83004
|
-
const
|
|
83005
|
-
const importInfo = this.getImportInfo(
|
|
83004
|
+
const path54 = this.tokens.stringValueAtIndex(index);
|
|
83005
|
+
const importInfo = this.getImportInfo(path54);
|
|
83006
83006
|
if (exportedName !== null) {
|
|
83007
83007
|
importInfo.exportStarNames.push(exportedName);
|
|
83008
83008
|
} else {
|
|
@@ -83042,8 +83042,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
83042
83042
|
* Get a mutable import info object for this path, creating one if it doesn't
|
|
83043
83043
|
* exist yet.
|
|
83044
83044
|
*/
|
|
83045
|
-
getImportInfo(
|
|
83046
|
-
const existingInfo = this.importInfoByPath.get(
|
|
83045
|
+
getImportInfo(path54) {
|
|
83046
|
+
const existingInfo = this.importInfoByPath.get(path54);
|
|
83047
83047
|
if (existingInfo) {
|
|
83048
83048
|
return existingInfo;
|
|
83049
83049
|
}
|
|
@@ -83056,7 +83056,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
83056
83056
|
exportStarNames: [],
|
|
83057
83057
|
hasStarExport: false
|
|
83058
83058
|
};
|
|
83059
|
-
this.importInfoByPath.set(
|
|
83059
|
+
this.importInfoByPath.set(path54, newInfo);
|
|
83060
83060
|
return newInfo;
|
|
83061
83061
|
}
|
|
83062
83062
|
addExportBinding(localName, exportedName) {
|
|
@@ -83636,16 +83636,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
83636
83636
|
}
|
|
83637
83637
|
function parseFileUrl(input2) {
|
|
83638
83638
|
const match = fileRegex.exec(input2);
|
|
83639
|
-
const
|
|
83640
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
83639
|
+
const path54 = match[2];
|
|
83640
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path54) ? path54 : "/" + path54, match[3] || "", match[4] || "");
|
|
83641
83641
|
}
|
|
83642
|
-
function makeUrl(scheme, user, host, port,
|
|
83642
|
+
function makeUrl(scheme, user, host, port, path54, query, hash2) {
|
|
83643
83643
|
return {
|
|
83644
83644
|
scheme,
|
|
83645
83645
|
user,
|
|
83646
83646
|
host,
|
|
83647
83647
|
port,
|
|
83648
|
-
path:
|
|
83648
|
+
path: path54,
|
|
83649
83649
|
query,
|
|
83650
83650
|
hash: hash2,
|
|
83651
83651
|
type: 7
|
|
@@ -83675,11 +83675,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
83675
83675
|
url2.type = input2 ? input2.startsWith("?") ? 3 : input2.startsWith("#") ? 2 : 4 : 1;
|
|
83676
83676
|
return url2;
|
|
83677
83677
|
}
|
|
83678
|
-
function stripPathFilename(
|
|
83679
|
-
if (
|
|
83680
|
-
return
|
|
83681
|
-
const index =
|
|
83682
|
-
return
|
|
83678
|
+
function stripPathFilename(path54) {
|
|
83679
|
+
if (path54.endsWith("/.."))
|
|
83680
|
+
return path54;
|
|
83681
|
+
const index = path54.lastIndexOf("/");
|
|
83682
|
+
return path54.slice(0, index + 1);
|
|
83683
83683
|
}
|
|
83684
83684
|
function mergePaths(url2, base) {
|
|
83685
83685
|
normalizePath(base, base.type);
|
|
@@ -83717,14 +83717,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
83717
83717
|
pieces[pointer++] = piece;
|
|
83718
83718
|
positive++;
|
|
83719
83719
|
}
|
|
83720
|
-
let
|
|
83720
|
+
let path54 = "";
|
|
83721
83721
|
for (let i = 1; i < pointer; i++) {
|
|
83722
|
-
|
|
83722
|
+
path54 += "/" + pieces[i];
|
|
83723
83723
|
}
|
|
83724
|
-
if (!
|
|
83725
|
-
|
|
83724
|
+
if (!path54 || addTrailingSlash && !path54.endsWith("/..")) {
|
|
83725
|
+
path54 += "/";
|
|
83726
83726
|
}
|
|
83727
|
-
url2.path =
|
|
83727
|
+
url2.path = path54;
|
|
83728
83728
|
}
|
|
83729
83729
|
function resolve2(input2, base) {
|
|
83730
83730
|
if (!input2 && !base)
|
|
@@ -83765,13 +83765,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
83765
83765
|
case 3:
|
|
83766
83766
|
return queryHash;
|
|
83767
83767
|
case 4: {
|
|
83768
|
-
const
|
|
83769
|
-
if (!
|
|
83768
|
+
const path54 = url2.path.slice(1);
|
|
83769
|
+
if (!path54)
|
|
83770
83770
|
return queryHash || ".";
|
|
83771
|
-
if (isRelative(base || input2) && !isRelative(
|
|
83772
|
-
return "./" +
|
|
83771
|
+
if (isRelative(base || input2) && !isRelative(path54)) {
|
|
83772
|
+
return "./" + path54 + queryHash;
|
|
83773
83773
|
}
|
|
83774
|
-
return
|
|
83774
|
+
return path54 + queryHash;
|
|
83775
83775
|
}
|
|
83776
83776
|
case 5:
|
|
83777
83777
|
return url2.path + queryHash;
|
|
@@ -83870,10 +83870,10 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
83870
83870
|
module2.exports = __toCommonJS2(trace_mapping_exports);
|
|
83871
83871
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
83872
83872
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
83873
|
-
function stripFilename(
|
|
83874
|
-
if (!
|
|
83875
|
-
const index =
|
|
83876
|
-
return
|
|
83873
|
+
function stripFilename(path54) {
|
|
83874
|
+
if (!path54) return "";
|
|
83875
|
+
const index = path54.lastIndexOf("/");
|
|
83876
|
+
return path54.slice(0, index + 1);
|
|
83877
83877
|
}
|
|
83878
83878
|
function resolver(mapUrl, sourceRoot) {
|
|
83879
83879
|
const from = stripFilename(mapUrl);
|
|
@@ -85081,9 +85081,9 @@ var require_util9 = __commonJS({
|
|
|
85081
85081
|
/** @class */
|
|
85082
85082
|
(function(_super) {
|
|
85083
85083
|
__extends2(VError2, _super);
|
|
85084
|
-
function VError2(
|
|
85084
|
+
function VError2(path54, message) {
|
|
85085
85085
|
var _this = _super.call(this, message) || this;
|
|
85086
|
-
_this.path =
|
|
85086
|
+
_this.path = path54;
|
|
85087
85087
|
Object.setPrototypeOf(_this, VError2.prototype);
|
|
85088
85088
|
return _this;
|
|
85089
85089
|
}
|
|
@@ -85143,26 +85143,26 @@ var require_util9 = __commonJS({
|
|
|
85143
85143
|
(_b = this._messages).push.apply(_b, best._messages);
|
|
85144
85144
|
}
|
|
85145
85145
|
};
|
|
85146
|
-
DetailContext2.prototype.getError = function(
|
|
85146
|
+
DetailContext2.prototype.getError = function(path54) {
|
|
85147
85147
|
var msgParts = [];
|
|
85148
85148
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
85149
85149
|
var p2 = this._propNames[i];
|
|
85150
|
-
|
|
85150
|
+
path54 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
85151
85151
|
var m = this._messages[i];
|
|
85152
85152
|
if (m) {
|
|
85153
|
-
msgParts.push(
|
|
85153
|
+
msgParts.push(path54 + " " + m);
|
|
85154
85154
|
}
|
|
85155
85155
|
}
|
|
85156
|
-
return new VError(
|
|
85156
|
+
return new VError(path54, msgParts.join("; "));
|
|
85157
85157
|
};
|
|
85158
|
-
DetailContext2.prototype.getErrorDetail = function(
|
|
85158
|
+
DetailContext2.prototype.getErrorDetail = function(path54) {
|
|
85159
85159
|
var details = [];
|
|
85160
85160
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
85161
85161
|
var p2 = this._propNames[i];
|
|
85162
|
-
|
|
85162
|
+
path54 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
85163
85163
|
var message = this._messages[i];
|
|
85164
85164
|
if (message) {
|
|
85165
|
-
details.push({ path:
|
|
85165
|
+
details.push({ path: path54, message });
|
|
85166
85166
|
}
|
|
85167
85167
|
}
|
|
85168
85168
|
var detail = null;
|
|
@@ -85975,8 +85975,8 @@ var require_dist2 = __commonJS({
|
|
|
85975
85975
|
this.checkerPlain = this.ttype.getChecker(suite, false);
|
|
85976
85976
|
this.checkerStrict = this.ttype.getChecker(suite, true);
|
|
85977
85977
|
}
|
|
85978
|
-
Checker2.prototype.setReportedPath = function(
|
|
85979
|
-
this._path =
|
|
85978
|
+
Checker2.prototype.setReportedPath = function(path54) {
|
|
85979
|
+
this._path = path54;
|
|
85980
85980
|
};
|
|
85981
85981
|
Checker2.prototype.check = function(value) {
|
|
85982
85982
|
return this._doCheck(this.checkerPlain, value);
|
|
@@ -91409,9 +91409,9 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
91409
91409
|
if (shouldElideImport) {
|
|
91410
91410
|
this.tokens.removeToken();
|
|
91411
91411
|
} else {
|
|
91412
|
-
const
|
|
91413
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
91414
|
-
this.tokens.appendCode(this.importProcessor.claimImportCode(
|
|
91412
|
+
const path54 = this.tokens.stringValue();
|
|
91413
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path54));
|
|
91414
|
+
this.tokens.appendCode(this.importProcessor.claimImportCode(path54));
|
|
91415
91415
|
}
|
|
91416
91416
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
91417
91417
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
@@ -91991,8 +91991,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
91991
91991
|
}
|
|
91992
91992
|
if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
|
|
91993
91993
|
this.tokens.removeToken();
|
|
91994
|
-
const
|
|
91995
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
91994
|
+
const path54 = this.tokens.stringValue();
|
|
91995
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path54));
|
|
91996
91996
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
91997
91997
|
} else {
|
|
91998
91998
|
this.tokens.appendCode(exportStatements.join(" "));
|
|
@@ -92006,8 +92006,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
92006
92006
|
while (!this.tokens.matches1(_types.TokenType.string)) {
|
|
92007
92007
|
this.tokens.removeToken();
|
|
92008
92008
|
}
|
|
92009
|
-
const
|
|
92010
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
92009
|
+
const path54 = this.tokens.stringValue();
|
|
92010
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path54));
|
|
92011
92011
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
92012
92012
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
92013
92013
|
this.tokens.removeToken();
|
|
@@ -121861,9 +121861,9 @@ var init_bundle_mjs = __esm({
|
|
|
121861
121861
|
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
121862
121862
|
}
|
|
121863
121863
|
};
|
|
121864
|
-
getPart = (classPartObject,
|
|
121864
|
+
getPart = (classPartObject, path54) => {
|
|
121865
121865
|
let current2 = classPartObject;
|
|
121866
|
-
const parts =
|
|
121866
|
+
const parts = path54.split(CLASS_PART_SEPARATOR);
|
|
121867
121867
|
const len = parts.length;
|
|
121868
121868
|
for (let i = 0; i < len; i++) {
|
|
121869
121869
|
const part = parts[i];
|
|
@@ -125113,8 +125113,8 @@ var init_dist = __esm({
|
|
|
125113
125113
|
});
|
|
125114
125114
|
|
|
125115
125115
|
// ../cli/src/lib/draw-mockup.ts
|
|
125116
|
-
import
|
|
125117
|
-
import
|
|
125116
|
+
import fs31 from "node:fs";
|
|
125117
|
+
import path36 from "node:path";
|
|
125118
125118
|
import vm from "node:vm";
|
|
125119
125119
|
async function loadPackage(id2) {
|
|
125120
125120
|
if (id2 === "react") return import_react3.default;
|
|
@@ -125127,23 +125127,23 @@ async function loadPackage(id2) {
|
|
|
125127
125127
|
return { __esModule: true, ...await load() };
|
|
125128
125128
|
}
|
|
125129
125129
|
function resolveFile(id2, from, folder2) {
|
|
125130
|
-
const at2 =
|
|
125131
|
-
if (at2 !== folder2 && !at2.startsWith(folder2 +
|
|
125132
|
-
const tries =
|
|
125133
|
-
const file3 = tries.find((f2) =>
|
|
125130
|
+
const at2 = path36.resolve(path36.dirname(from), id2);
|
|
125131
|
+
if (at2 !== folder2 && !at2.startsWith(folder2 + path36.sep)) throw new Error(`${id2} is outside the mockup's folder`);
|
|
125132
|
+
const tries = path36.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path36.join(at2, `index${e2}`))];
|
|
125133
|
+
const file3 = tries.find((f2) => fs31.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
125134
125134
|
if (!file3) throw new Error(`no such file: ${id2}`);
|
|
125135
|
-
if (!
|
|
125135
|
+
if (!fs31.realpathSync(file3).startsWith(fs31.realpathSync(folder2) + path36.sep)) throw new Error(`${id2} is outside the mockup's folder`);
|
|
125136
125136
|
return file3;
|
|
125137
125137
|
}
|
|
125138
125138
|
async function readGraph(entry) {
|
|
125139
|
-
const folder2 =
|
|
125139
|
+
const folder2 = path36.dirname(entry);
|
|
125140
125140
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
125141
125141
|
const walk = async (file3) => {
|
|
125142
125142
|
if (graph.code.has(file3)) return;
|
|
125143
125143
|
if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
|
|
125144
125144
|
let location = file3;
|
|
125145
125145
|
try {
|
|
125146
|
-
const js = (0, import_sucrase.transform)(
|
|
125146
|
+
const js = (0, import_sucrase.transform)(fs31.readFileSync(file3, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file3 }).code;
|
|
125147
125147
|
graph.code.set(file3, js);
|
|
125148
125148
|
const link = /* @__PURE__ */ new Map();
|
|
125149
125149
|
graph.links.set(file3, link);
|
|
@@ -125157,7 +125157,7 @@ async function readGraph(entry) {
|
|
|
125157
125157
|
const target = resolveFile(id2, file3, folder2);
|
|
125158
125158
|
link.set(id2, target);
|
|
125159
125159
|
if (!target.endsWith(".css")) await walk(target);
|
|
125160
|
-
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content:
|
|
125160
|
+
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs31.readFileSync(target, "utf8") });
|
|
125161
125161
|
}
|
|
125162
125162
|
} catch (error62) {
|
|
125163
125163
|
throw new Error(`${location}: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
@@ -125174,13 +125174,13 @@ function run2(script, context, name, deadline, lineOffset = 0) {
|
|
|
125174
125174
|
async function tailwindFor(markup, sheets, folder2) {
|
|
125175
125175
|
const source2 = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
125176
125176
|
const compiler = await rc(source2, {
|
|
125177
|
-
base: sheets.length ?
|
|
125177
|
+
base: sheets.length ? path36.dirname(sheets[0].path) : "/",
|
|
125178
125178
|
loadStylesheet: async (id2, from) => {
|
|
125179
125179
|
if (id2 === "tailwindcss" || id2.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
125180
125180
|
if (!id2.startsWith(".")) throw new Error(`a mockup cannot import ${id2}`);
|
|
125181
|
-
const at2 =
|
|
125182
|
-
if (!
|
|
125183
|
-
return { path: at2, base:
|
|
125181
|
+
const at2 = path36.resolve(from, id2);
|
|
125182
|
+
if (!fs31.realpathSync(at2).startsWith(fs31.realpathSync(folder2) + path36.sep)) throw new Error(`${id2} is outside the mockup's folder`);
|
|
125183
|
+
return { path: at2, base: path36.dirname(at2), content: fs31.readFileSync(at2, "utf8") };
|
|
125184
125184
|
}
|
|
125185
125185
|
});
|
|
125186
125186
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
@@ -125229,7 +125229,7 @@ ${graph.code.get(file3)}
|
|
|
125229
125229
|
if (typeof Component !== "function") throw new Error("the mockup has no default export to draw");
|
|
125230
125230
|
sandbox.__draw = () => (0, import_server.renderToStaticMarkup)(import_react3.default.createElement(Component));
|
|
125231
125231
|
const markup = run2("__draw()", context, entry, deadline);
|
|
125232
|
-
const css = (await tailwindFor(markup, graph.sheets,
|
|
125232
|
+
const css = (await tailwindFor(markup, graph.sheets, path36.dirname(entry))).replace(/<\/style/gi, "<\\/style");
|
|
125233
125233
|
return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
|
|
125234
125234
|
}
|
|
125235
125235
|
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES, MOCKUP_IMPORTS;
|
|
@@ -144279,14 +144279,14 @@ var require_svgPath = __commonJS({
|
|
|
144279
144279
|
["Z", 0],
|
|
144280
144280
|
["z", 0]
|
|
144281
144281
|
]);
|
|
144282
|
-
var parse4 = function(
|
|
144282
|
+
var parse4 = function(path54) {
|
|
144283
144283
|
var cmd;
|
|
144284
144284
|
var ret = [];
|
|
144285
144285
|
var args2 = [];
|
|
144286
144286
|
var curArg = "";
|
|
144287
144287
|
var foundDecimal = false;
|
|
144288
144288
|
var params = 0;
|
|
144289
|
-
for (var _i2 = 0, path_1 =
|
|
144289
|
+
for (var _i2 = 0, path_1 = path54; _i2 < path_1.length; _i2++) {
|
|
144290
144290
|
var c2 = path_1[_i2];
|
|
144291
144291
|
if (parameters.has(c2)) {
|
|
144292
144292
|
params = parameters.get(c2);
|
|
@@ -144600,8 +144600,8 @@ var require_svgPath = __commonJS({
|
|
|
144600
144600
|
];
|
|
144601
144601
|
return result;
|
|
144602
144602
|
};
|
|
144603
|
-
exports.svgPathToOperators = function(
|
|
144604
|
-
return apply(parse4(
|
|
144603
|
+
exports.svgPathToOperators = function(path54) {
|
|
144604
|
+
return apply(parse4(path54));
|
|
144605
144605
|
};
|
|
144606
144606
|
}
|
|
144607
144607
|
});
|
|
@@ -144784,7 +144784,7 @@ var require_operations = __commonJS({
|
|
|
144784
144784
|
operators_1.popGraphicsState()
|
|
144785
144785
|
]).filter(Boolean);
|
|
144786
144786
|
};
|
|
144787
|
-
exports.drawSvgPath = function(
|
|
144787
|
+
exports.drawSvgPath = function(path54, options) {
|
|
144788
144788
|
var _a4, _b, _c;
|
|
144789
144789
|
return tslib_1.__spreadArrays([
|
|
144790
144790
|
operators_1.pushGraphicsState(),
|
|
@@ -144798,7 +144798,7 @@ var require_operations = __commonJS({
|
|
|
144798
144798
|
options.borderWidth && operators_1.setLineWidth(options.borderWidth),
|
|
144799
144799
|
options.borderLineCap && operators_1.setLineCap(options.borderLineCap),
|
|
144800
144800
|
operators_1.setDashPattern((_b = options.borderDashArray) !== null && _b !== void 0 ? _b : [], (_c = options.borderDashPhase) !== null && _c !== void 0 ? _c : 0)
|
|
144801
|
-
], svgPath_1.svgPathToOperators(
|
|
144801
|
+
], svgPath_1.svgPathToOperators(path54), [
|
|
144802
144802
|
// prettier-ignore
|
|
144803
144803
|
options.color && options.borderWidth ? operators_1.fillAndStroke() : options.color ? operators_1.fill() : options.borderColor ? operators_1.stroke() : operators_1.closePath(),
|
|
144804
144804
|
operators_1.popGraphicsState()
|
|
@@ -149096,12 +149096,12 @@ var require_PDFPage = __commonJS({
|
|
|
149096
149096
|
graphicsState: graphicsStateKey
|
|
149097
149097
|
}));
|
|
149098
149098
|
};
|
|
149099
|
-
PDFPage2.prototype.drawSvgPath = function(
|
|
149099
|
+
PDFPage2.prototype.drawSvgPath = function(path54, options) {
|
|
149100
149100
|
var _a4, _b, _c, _d, _e2, _f, _g, _h, _j;
|
|
149101
149101
|
if (options === void 0) {
|
|
149102
149102
|
options = {};
|
|
149103
149103
|
}
|
|
149104
|
-
utils_1.assertIs(
|
|
149104
|
+
utils_1.assertIs(path54, "path", ["string"]);
|
|
149105
149105
|
utils_1.assertOrUndefined(options.x, "options.x", ["number"]);
|
|
149106
149106
|
utils_1.assertOrUndefined(options.y, "options.y", ["number"]);
|
|
149107
149107
|
utils_1.assertOrUndefined(options.scale, "options.scale", ["number"]);
|
|
@@ -149130,7 +149130,7 @@ var require_PDFPage = __commonJS({
|
|
|
149130
149130
|
options.borderColor = colors_1.rgb(0, 0, 0);
|
|
149131
149131
|
}
|
|
149132
149132
|
var contentStream = this.getContentStream();
|
|
149133
|
-
contentStream.push.apply(contentStream, operations_1.drawSvgPath(
|
|
149133
|
+
contentStream.push.apply(contentStream, operations_1.drawSvgPath(path54, {
|
|
149134
149134
|
x: (_a4 = options.x) !== null && _a4 !== void 0 ? _a4 : this.x,
|
|
149135
149135
|
y: (_b = options.y) !== null && _b !== void 0 ? _b : this.y,
|
|
149136
149136
|
scale: options.scale,
|
|
@@ -151540,13 +151540,13 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
151540
151540
|
import { existsSync as existsSync2 } from "node:fs";
|
|
151541
151541
|
import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
151542
151542
|
import { tmpdir } from "node:os";
|
|
151543
|
-
import
|
|
151543
|
+
import path37 from "node:path";
|
|
151544
151544
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
151545
151545
|
function installedOffice() {
|
|
151546
151546
|
const programs = [process.env.ProgramFiles, process.env["ProgramFiles(x86)"]];
|
|
151547
|
-
const candidates = process.platform === "darwin" ? ["/Applications/LibreOffice.app/Contents/MacOS/soffice"] : process.platform === "win32" ? programs.flatMap((dir) => dir ? [
|
|
151547
|
+
const candidates = process.platform === "darwin" ? ["/Applications/LibreOffice.app/Contents/MacOS/soffice"] : process.platform === "win32" ? programs.flatMap((dir) => dir ? [path37.join(dir, "LibreOffice", "program", "soffice.com")] : []) : [];
|
|
151548
151548
|
const executable = process.platform === "win32" ? "soffice.com" : "soffice";
|
|
151549
|
-
const onPath2 = (process.env.PATH ?? "").split(
|
|
151549
|
+
const onPath2 = (process.env.PATH ?? "").split(path37.delimiter).filter(Boolean).map((dir) => path37.join(dir, executable));
|
|
151550
151550
|
return [...onPath2, ...candidates].find((file3) => existsSync2(file3)) ?? executable;
|
|
151551
151551
|
}
|
|
151552
151552
|
function checkPackage(bytes2, mainPart) {
|
|
@@ -151603,14 +151603,14 @@ function convert(command, args2, timeout) {
|
|
|
151603
151603
|
async function renderOfficePdf(bytes2, ext, command = installedOffice(), timeout = 3e4) {
|
|
151604
151604
|
const format = formats[ext];
|
|
151605
151605
|
checkPackage(bytes2, format.part);
|
|
151606
|
-
const dir = await mkdtemp(
|
|
151606
|
+
const dir = await mkdtemp(path37.join(tmpdir(), "wildcrane-document-"));
|
|
151607
151607
|
try {
|
|
151608
|
-
const user =
|
|
151609
|
-
const input2 =
|
|
151608
|
+
const user = path37.join(dir, "profile", "user");
|
|
151609
|
+
const input2 = path37.join(dir, `source${ext}`);
|
|
151610
151610
|
await mkdir(user, { recursive: true });
|
|
151611
|
-
await Promise.all([writeFile(input2, bytes2), writeFile(
|
|
151611
|
+
await Promise.all([writeFile(input2, bytes2), writeFile(path37.join(user, "registrymodifications.xcu"), profile)]);
|
|
151612
151612
|
await convert(command, [
|
|
151613
|
-
`-env:UserInstallation=${pathToFileURL2(
|
|
151613
|
+
`-env:UserInstallation=${pathToFileURL2(path37.dirname(user)).href}`,
|
|
151614
151614
|
"--headless",
|
|
151615
151615
|
"--norestore",
|
|
151616
151616
|
`--infilter=${format.input}`,
|
|
@@ -151620,7 +151620,7 @@ async function renderOfficePdf(bytes2, ext, command = installedOffice(), timeout
|
|
|
151620
151620
|
dir,
|
|
151621
151621
|
input2
|
|
151622
151622
|
], timeout);
|
|
151623
|
-
const output3 =
|
|
151623
|
+
const output3 = path37.join(dir, "source.pdf");
|
|
151624
151624
|
const { size } = await stat(output3);
|
|
151625
151625
|
if (!size || size > ASSET_FILE_LIMIT) throw Error("Invalid Office preview size");
|
|
151626
151626
|
const pdf = await readFile(output3);
|
|
@@ -151673,7 +151673,6 @@ try {
|
|
|
151673
151673
|
import fs from "node:fs";
|
|
151674
151674
|
import os2 from "node:os";
|
|
151675
151675
|
import path from "node:path";
|
|
151676
|
-
import { parseEnv } from "node:util";
|
|
151677
151676
|
|
|
151678
151677
|
// src/proxy.ts
|
|
151679
151678
|
var import_undici = __toESM(require_undici(), 1);
|
|
@@ -151759,27 +151758,14 @@ function runnerCwd() {
|
|
|
151759
151758
|
}
|
|
151760
151759
|
function useRunnerHome() {
|
|
151761
151760
|
process.env.AI4KANBAN_HOME = runnerHome();
|
|
151762
|
-
loadProxyFile();
|
|
151763
151761
|
followProxy();
|
|
151764
151762
|
setInterval(followProxy, 6e4).unref();
|
|
151765
151763
|
}
|
|
151766
|
-
function loadProxyFile() {
|
|
151767
|
-
try {
|
|
151768
|
-
const config2 = parseEnv(fs.readFileSync(path.join(runnerHome(), "proxy.env"), "utf8"));
|
|
151769
|
-
for (const key of ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY"]) {
|
|
151770
|
-
const lower = key.toLowerCase();
|
|
151771
|
-
const value = config2[lower] ?? config2[key];
|
|
151772
|
-
if (value !== void 0 && process.env[key] === void 0 && process.env[lower] === void 0) process.env[key] = value;
|
|
151773
|
-
}
|
|
151774
|
-
} catch (error62) {
|
|
151775
|
-
if (error62.code !== "ENOENT") console.error("runner: could not load proxy.env");
|
|
151776
|
-
}
|
|
151777
|
-
}
|
|
151778
151764
|
|
|
151779
151765
|
// src/flow-worker.ts
|
|
151780
151766
|
import { spawn as spawn6 } from "node:child_process";
|
|
151781
|
-
import
|
|
151782
|
-
import
|
|
151767
|
+
import fs48 from "node:fs";
|
|
151768
|
+
import path53 from "node:path";
|
|
151783
151769
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
151784
151770
|
|
|
151785
151771
|
// ../cli/src/lib/cloud/session.ts
|
|
@@ -153280,10 +153266,10 @@ function mergeDefs(...defs) {
|
|
|
153280
153266
|
function cloneDef(schema) {
|
|
153281
153267
|
return mergeDefs(schema._zod.def);
|
|
153282
153268
|
}
|
|
153283
|
-
function getElementAtPath(obj3,
|
|
153284
|
-
if (!
|
|
153269
|
+
function getElementAtPath(obj3, path54) {
|
|
153270
|
+
if (!path54)
|
|
153285
153271
|
return obj3;
|
|
153286
|
-
return
|
|
153272
|
+
return path54.reduce((acc, key) => acc?.[key], obj3);
|
|
153287
153273
|
}
|
|
153288
153274
|
function promiseAllObject(promisesObj) {
|
|
153289
153275
|
const keys = Object.keys(promisesObj);
|
|
@@ -153623,11 +153609,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
153623
153609
|
}
|
|
153624
153610
|
return false;
|
|
153625
153611
|
}
|
|
153626
|
-
function prefixIssues(
|
|
153612
|
+
function prefixIssues(path54, issues) {
|
|
153627
153613
|
return issues.map((iss) => {
|
|
153628
153614
|
var _a4;
|
|
153629
153615
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
153630
|
-
iss.path.unshift(
|
|
153616
|
+
iss.path.unshift(path54);
|
|
153631
153617
|
return iss;
|
|
153632
153618
|
});
|
|
153633
153619
|
}
|
|
@@ -154089,16 +154075,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
154089
154075
|
}
|
|
154090
154076
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
154091
154077
|
const fieldErrors = { _errors: [] };
|
|
154092
|
-
const processError = (error63,
|
|
154078
|
+
const processError = (error63, path54 = []) => {
|
|
154093
154079
|
for (const issue2 of error63.issues) {
|
|
154094
154080
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
154095
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
154081
|
+
issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
|
|
154096
154082
|
} else if (issue2.code === "invalid_key") {
|
|
154097
|
-
processError({ issues: issue2.issues }, [...
|
|
154083
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
154098
154084
|
} else if (issue2.code === "invalid_element") {
|
|
154099
|
-
processError({ issues: issue2.issues }, [...
|
|
154085
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
154100
154086
|
} else {
|
|
154101
|
-
const fullpath = [...
|
|
154087
|
+
const fullpath = [...path54, ...issue2.path];
|
|
154102
154088
|
if (fullpath.length === 0) {
|
|
154103
154089
|
fieldErrors._errors.push(mapper(issue2));
|
|
154104
154090
|
} else {
|
|
@@ -154137,17 +154123,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
154137
154123
|
}
|
|
154138
154124
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
154139
154125
|
const result = { errors: [] };
|
|
154140
|
-
const processError = (error63,
|
|
154126
|
+
const processError = (error63, path54 = []) => {
|
|
154141
154127
|
var _a4;
|
|
154142
154128
|
for (const issue2 of error63.issues) {
|
|
154143
154129
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
154144
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
154130
|
+
issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
|
|
154145
154131
|
} else if (issue2.code === "invalid_key") {
|
|
154146
|
-
processError({ issues: issue2.issues }, [...
|
|
154132
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
154147
154133
|
} else if (issue2.code === "invalid_element") {
|
|
154148
|
-
processError({ issues: issue2.issues }, [...
|
|
154134
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
154149
154135
|
} else {
|
|
154150
|
-
const fullpath = [...
|
|
154136
|
+
const fullpath = [...path54, ...issue2.path];
|
|
154151
154137
|
if (fullpath.length === 0) {
|
|
154152
154138
|
result.errors.push(mapper(issue2));
|
|
154153
154139
|
continue;
|
|
@@ -154186,8 +154172,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
154186
154172
|
}
|
|
154187
154173
|
function toDotPath(_path) {
|
|
154188
154174
|
const segs = [];
|
|
154189
|
-
const
|
|
154190
|
-
for (const seg of
|
|
154175
|
+
const path54 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
154176
|
+
for (const seg of path54) {
|
|
154191
154177
|
if (typeof seg === "number")
|
|
154192
154178
|
segs.push(`[${seg}]`);
|
|
154193
154179
|
else if (typeof seg === "symbol")
|
|
@@ -171325,13 +171311,13 @@ function resolveRef(ref, ctx) {
|
|
|
171325
171311
|
if (!ref.startsWith("#")) {
|
|
171326
171312
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
171327
171313
|
}
|
|
171328
|
-
const
|
|
171329
|
-
if (
|
|
171314
|
+
const path54 = ref.slice(1).split("/").filter(Boolean);
|
|
171315
|
+
if (path54.length === 0) {
|
|
171330
171316
|
return ctx.rootSchema;
|
|
171331
171317
|
}
|
|
171332
171318
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
171333
|
-
if (
|
|
171334
|
-
const key =
|
|
171319
|
+
if (path54[0] === defsKey) {
|
|
171320
|
+
const key = path54[1] === void 0 ? void 0 : decodeJSONPointerSegment(path54[1]);
|
|
171335
171321
|
if (!key || !ctx.defs[key]) {
|
|
171336
171322
|
throw new Error(`Reference not found: ${ref}`);
|
|
171337
171323
|
}
|
|
@@ -172302,7 +172288,7 @@ function goalRoute(discussion, goal, field) {
|
|
|
172302
172288
|
}
|
|
172303
172289
|
|
|
172304
172290
|
// src/protocol.ts
|
|
172305
|
-
var AKB_VERSION = true ? "0.11.
|
|
172291
|
+
var AKB_VERSION = true ? "0.11.83" : "0.0.0";
|
|
172306
172292
|
var AKB_CONTRACT = true ? 27 : 0;
|
|
172307
172293
|
|
|
172308
172294
|
// src/secrets.ts
|
|
@@ -172485,7 +172471,7 @@ var listFolders = (machineId) => request("GET", `/v1/runner/folders?machine=${q(
|
|
|
172485
172471
|
var listElsewhere = (machineId) => request("GET", `/v1/runner/folders?machine=${q(machineId)}&elsewhere=1`);
|
|
172486
172472
|
var listMachineTasks = (machineId) => request("GET", `/v1/runner/tasks?machine=${q(machineId)}`);
|
|
172487
172473
|
var stopTask = (task, how) => request("POST", how === "chat" ? `/v1/tasks/${q(task)}/chat/stop` : `/v1/tasks/${q(task)}/stop`, {});
|
|
172488
|
-
var addFolder = (machineId, name,
|
|
172474
|
+
var addFolder = (machineId, name, path54, project) => request("POST", "/v1/runner/folders", { machineId, name, path: path54, ...project ? { project } : {} });
|
|
172489
172475
|
async function createProject(name, workspace, key) {
|
|
172490
172476
|
const sent = await send("POST", "/v1/projects", { name, workspace }, true, TIMEOUT_MS, void 0, { "idempotency-key": key });
|
|
172491
172477
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
@@ -172565,25 +172551,25 @@ import path12 from "node:path";
|
|
|
172565
172551
|
init_file_limits();
|
|
172566
172552
|
var ROOTS = ["todo/", ".archive/", "memory/", "studios/", "triage/", "assets/", "rules/"];
|
|
172567
172553
|
var SETTINGS = ["modules.md", "config.md"];
|
|
172568
|
-
var isSettingsPath = (
|
|
172569
|
-
function isBoardPath(
|
|
172570
|
-
if (!
|
|
172571
|
-
if (
|
|
172572
|
-
if (
|
|
172573
|
-
if (
|
|
172574
|
-
if (SETTINGS.includes(
|
|
172575
|
-
if (
|
|
172576
|
-
if (
|
|
172577
|
-
return ROOTS.some((root2) =>
|
|
172554
|
+
var isSettingsPath = (path54) => SETTINGS.includes(path54) || /^rules\/(?:studios\/[^/]+|proposer|project-writer|dismissal-reviewer|memory-pruner)\.md$/.test(path54);
|
|
172555
|
+
function isBoardPath(path54) {
|
|
172556
|
+
if (!path54 || path54.length > 500 || path54.startsWith("/") || path54.includes("\\") || path54.includes("\0")) return false;
|
|
172557
|
+
if (path54.split("/").some((part) => !part || part === "." || part === "..")) return false;
|
|
172558
|
+
if (path54 === "todo/README.md" || path54.split("/").includes(".sync")) return false;
|
|
172559
|
+
if (path54.startsWith("studios/")) return true;
|
|
172560
|
+
if (SETTINGS.includes(path54)) return true;
|
|
172561
|
+
if (path54.startsWith("rules/")) return isSettingsPath(path54);
|
|
172562
|
+
if (path54.startsWith("assets/")) return taskOfAssets(path54) !== null;
|
|
172563
|
+
return ROOTS.some((root2) => path54.startsWith(root2)) && path54.endsWith(".md");
|
|
172578
172564
|
}
|
|
172579
172565
|
var CARD = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]*\.md$/;
|
|
172580
172566
|
var ROOT = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]+\/root\.md$/;
|
|
172581
|
-
function numberOfCard(
|
|
172582
|
-
const n = ROOT.exec(
|
|
172567
|
+
function numberOfCard(path54) {
|
|
172568
|
+
const n = ROOT.exec(path54)?.[1] ?? CARD.exec(path54)?.[1];
|
|
172583
172569
|
return n ? Number(n) : null;
|
|
172584
172570
|
}
|
|
172585
172571
|
var assetsFile = (task) => `assets/${task}.json`;
|
|
172586
|
-
var taskOfAssets = (
|
|
172572
|
+
var taskOfAssets = (path54) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path54)?.[1] ?? null;
|
|
172587
172573
|
var studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
172588
172574
|
var studioName = (id2) => id2.startsWith("wf_builtin_") ? id2.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id2);
|
|
172589
172575
|
var studioRuleFile = (id2) => `rules/studios/${studioName(id2)}.md`;
|
|
@@ -172845,7 +172831,7 @@ function landSections(body, previews) {
|
|
|
172845
172831
|
}
|
|
172846
172832
|
function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
|
|
172847
172833
|
const problems = [];
|
|
172848
|
-
const fail = (offset,
|
|
172834
|
+
const fail = (offset, path54, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path54, code, message, hint: hint2 });
|
|
172849
172835
|
const result = () => ({ problem: problems.map((p2) => `${p2.file}:${p2.line}:${p2.column} ${p2.path}: ${p2.code} \u2014 ${p2.message}. ${p2.hint}`).join("\n"), problems });
|
|
172850
172836
|
if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
|
|
172851
172837
|
const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
|
|
@@ -174057,9 +174043,9 @@ async function stopConnection(root2, timeout) {
|
|
|
174057
174043
|
}
|
|
174058
174044
|
|
|
174059
174045
|
// src/flow.ts
|
|
174060
|
-
import
|
|
174046
|
+
import fs36 from "node:fs";
|
|
174061
174047
|
import os6 from "node:os";
|
|
174062
|
-
import
|
|
174048
|
+
import path42 from "node:path";
|
|
174063
174049
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
174064
174050
|
|
|
174065
174051
|
// ../cli/src/lib/agent/approved-ui.ts
|
|
@@ -174893,10 +174879,10 @@ function findRollout(threadId) {
|
|
|
174893
174879
|
}
|
|
174894
174880
|
for (const name of names2) {
|
|
174895
174881
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
174896
|
-
const
|
|
174882
|
+
const path54 = join(dir, name);
|
|
174897
174883
|
try {
|
|
174898
|
-
const at2 = statSync(
|
|
174899
|
-
if (!newest2 || at2 > newest2.at) newest2 = { path:
|
|
174884
|
+
const at2 = statSync(path54).mtimeMs;
|
|
174885
|
+
if (!newest2 || at2 > newest2.at) newest2 = { path: path54, at: at2 };
|
|
174900
174886
|
} catch {
|
|
174901
174887
|
}
|
|
174902
174888
|
}
|
|
@@ -174904,11 +174890,11 @@ function findRollout(threadId) {
|
|
|
174904
174890
|
return newest2?.path;
|
|
174905
174891
|
}
|
|
174906
174892
|
function readCodexRunFacts(threadId) {
|
|
174907
|
-
const
|
|
174908
|
-
if (!
|
|
174893
|
+
const path54 = findRollout(threadId);
|
|
174894
|
+
if (!path54) return void 0;
|
|
174909
174895
|
let raw;
|
|
174910
174896
|
try {
|
|
174911
|
-
raw = readFileSync(
|
|
174897
|
+
raw = readFileSync(path54, "utf8");
|
|
174912
174898
|
} catch {
|
|
174913
174899
|
return void 0;
|
|
174914
174900
|
}
|
|
@@ -175020,8 +175006,8 @@ function renderCompleted(item) {
|
|
|
175020
175006
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
175021
175007
|
return changes.map((raw) => {
|
|
175022
175008
|
const change = obj(raw);
|
|
175023
|
-
const
|
|
175024
|
-
return
|
|
175009
|
+
const path54 = str2(change.path);
|
|
175010
|
+
return path54 ? `\u23FA ${str2(change.kind) || "change"}(${path54})
|
|
175025
175011
|
` : "";
|
|
175026
175012
|
}).join("");
|
|
175027
175013
|
}
|
|
@@ -175339,10 +175325,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
175339
175325
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
175340
175326
|
let model;
|
|
175341
175327
|
let holding = 0;
|
|
175342
|
-
for (const { path:
|
|
175328
|
+
for (const { path: path54, main } of wireFiles(entry.sessionDir)) {
|
|
175343
175329
|
let raw;
|
|
175344
175330
|
try {
|
|
175345
|
-
raw = readFileSync2(
|
|
175331
|
+
raw = readFileSync2(path54, "utf8");
|
|
175346
175332
|
} catch {
|
|
175347
175333
|
continue;
|
|
175348
175334
|
}
|
|
@@ -175680,7 +175666,7 @@ function createTail(log) {
|
|
|
175680
175666
|
// ../cli/package.json
|
|
175681
175667
|
var package_default = {
|
|
175682
175668
|
name: "wildcrane",
|
|
175683
|
-
version: "0.11.
|
|
175669
|
+
version: "0.11.83",
|
|
175684
175670
|
akbContract: 27,
|
|
175685
175671
|
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.",
|
|
175686
175672
|
keywords: [
|
|
@@ -175757,8 +175743,8 @@ var CLIENT_CAPABILITIES = {
|
|
|
175757
175743
|
};
|
|
175758
175744
|
function whereHint(update2, title) {
|
|
175759
175745
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
175760
|
-
const
|
|
175761
|
-
return
|
|
175746
|
+
const path54 = str2(obj(locations[0]).path);
|
|
175747
|
+
return path54 && !title.includes(path54) ? hint(path54) : "";
|
|
175762
175748
|
}
|
|
175763
175749
|
function saidBy(update2) {
|
|
175764
175750
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -176183,14 +176169,14 @@ async function oneTurn2(io, options) {
|
|
|
176183
176169
|
const activeCalls = /* @__PURE__ */ new Set();
|
|
176184
176170
|
let live = false;
|
|
176185
176171
|
let sessionId = "";
|
|
176186
|
-
let
|
|
176172
|
+
let ended;
|
|
176187
176173
|
const finished = new Promise((resolve2) => {
|
|
176188
|
-
|
|
176174
|
+
ended = resolve2;
|
|
176189
176175
|
});
|
|
176190
176176
|
const cancelled = () => {
|
|
176191
176177
|
const response = tail.end();
|
|
176192
176178
|
if (response) io.event?.({ kind: "message", data: { text: response } });
|
|
176193
|
-
|
|
176179
|
+
ended?.({ ok: false, error: "Execution stopped.", response });
|
|
176194
176180
|
};
|
|
176195
176181
|
io.signal?.addEventListener("abort", cancelled, { once: true });
|
|
176196
176182
|
const rpc = connect(
|
|
@@ -176217,7 +176203,7 @@ async function oneTurn2(io, options) {
|
|
|
176217
176203
|
if (id2 && ["completed", "error", "result"].includes(status)) activityEvents.toolResult(id2, status === "error" ? "failed" : "completed", "");
|
|
176218
176204
|
for (const e2 of activityEvents.events()) io.event?.(e2);
|
|
176219
176205
|
}
|
|
176220
|
-
event(envelope, parts, tail, live,
|
|
176206
|
+
event(envelope, parts, tail, live, ended);
|
|
176221
176207
|
}
|
|
176222
176208
|
return;
|
|
176223
176209
|
}
|
|
@@ -176322,7 +176308,7 @@ async function contextOf(rpc, sessionId) {
|
|
|
176322
176308
|
return void 0;
|
|
176323
176309
|
}
|
|
176324
176310
|
}
|
|
176325
|
-
function event(envelope, parts, tail, live,
|
|
176311
|
+
function event(envelope, parts, tail, live, ended) {
|
|
176326
176312
|
const payload = obj(envelope.payload);
|
|
176327
176313
|
switch (str2(envelope.type)) {
|
|
176328
176314
|
case "part.started":
|
|
@@ -176342,16 +176328,16 @@ function event(envelope, parts, tail, live, ended2) {
|
|
|
176342
176328
|
const usage = usageOf3(obj(payload.usage));
|
|
176343
176329
|
const response = str2(payload.response);
|
|
176344
176330
|
const how = str2(payload.resultType) || "success";
|
|
176345
|
-
if (how === "success") return
|
|
176346
|
-
return
|
|
176331
|
+
if (how === "success") return ended({ ok: true, response, usage });
|
|
176332
|
+
return ended({ ok: false, error: STOPPED2[how] ?? `the agent stopped: ${how}`, response, usage });
|
|
176347
176333
|
}
|
|
176348
176334
|
case "turn.failed": {
|
|
176349
176335
|
const error62 = obj(payload.error);
|
|
176350
176336
|
const failure2 = providerFailure(error62, str2(error62.message) || "the turn failed");
|
|
176351
|
-
return
|
|
176337
|
+
return ended({ ok: false, error: failure2.reason, failure: failure2 });
|
|
176352
176338
|
}
|
|
176353
176339
|
case "session.closed":
|
|
176354
|
-
return
|
|
176340
|
+
return ended({ ok: false, error: str2(payload.reason) || "the agent closed the session" });
|
|
176355
176341
|
default:
|
|
176356
176342
|
return;
|
|
176357
176343
|
}
|
|
@@ -176716,7 +176702,7 @@ async function run(io, options, count2) {
|
|
|
176716
176702
|
};
|
|
176717
176703
|
let startupTimer;
|
|
176718
176704
|
const began = () => {
|
|
176719
|
-
if (!submitted || started ||
|
|
176705
|
+
if (!submitted || started || ended) return;
|
|
176720
176706
|
started = true;
|
|
176721
176707
|
clearTimeout(startupTimer);
|
|
176722
176708
|
phase("started");
|
|
@@ -176742,7 +176728,7 @@ async function run(io, options, count2) {
|
|
|
176742
176728
|
let threadId = "";
|
|
176743
176729
|
let active = true;
|
|
176744
176730
|
let timer;
|
|
176745
|
-
let
|
|
176731
|
+
let ended = false;
|
|
176746
176732
|
let checking = false;
|
|
176747
176733
|
let context;
|
|
176748
176734
|
let total;
|
|
@@ -176758,8 +176744,8 @@ async function run(io, options, count2) {
|
|
|
176758
176744
|
for (const event2 of renderer.events?.() ?? []) io.event?.(event2);
|
|
176759
176745
|
};
|
|
176760
176746
|
const end = (error62, classified) => {
|
|
176761
|
-
if (
|
|
176762
|
-
|
|
176747
|
+
if (ended) return;
|
|
176748
|
+
ended = true;
|
|
176763
176749
|
clearTimeout(timer);
|
|
176764
176750
|
clearTimeout(startupTimer);
|
|
176765
176751
|
clearTimeout(settleTimer);
|
|
@@ -176804,7 +176790,7 @@ async function run(io, options, count2) {
|
|
|
176804
176790
|
};
|
|
176805
176791
|
io.signal?.addEventListener("abort", cancelled, { once: true });
|
|
176806
176792
|
const idle = async () => {
|
|
176807
|
-
if (
|
|
176793
|
+
if (ended || idling) return;
|
|
176808
176794
|
idling = true;
|
|
176809
176795
|
const unknownWork = () => [...work.entries.values()].some((item2) => ["running", "unknown", "interrupted"].includes(item2.status));
|
|
176810
176796
|
const uncertain = unknownWork();
|
|
@@ -176820,9 +176806,9 @@ async function run(io, options, count2) {
|
|
|
176820
176806
|
if (uncertain || unknownWork()) throw Error("Codex has operations with unconfirmed results.");
|
|
176821
176807
|
cleanup.idleStop = { threadId, turnId: ownedTurn };
|
|
176822
176808
|
} catch (error62) {
|
|
176823
|
-
if (!
|
|
176809
|
+
if (!ended) note(error62 instanceof Error ? error62.message : String(error62));
|
|
176824
176810
|
}
|
|
176825
|
-
if (!
|
|
176811
|
+
if (!ended) end(IDLE_FAILURE.reason, IDLE_FAILURE);
|
|
176826
176812
|
};
|
|
176827
176813
|
io.idleSignal?.addEventListener("abort", idle, { once: true });
|
|
176828
176814
|
const childUpdates = () => {
|
|
@@ -176839,7 +176825,7 @@ async function run(io, options, count2) {
|
|
|
176839
176825
|
if (report2) for (const { raw, completed } of messages) emit(completed ? "item.completed" : "item.started", { item: { ...raw, type: "agent_message" } });
|
|
176840
176826
|
};
|
|
176841
176827
|
const item = (raw, completed, proof = true) => {
|
|
176842
|
-
if (
|
|
176828
|
+
if (ended) return;
|
|
176843
176829
|
const id2 = str2(raw.id);
|
|
176844
176830
|
if (["collabAgentToolCall", "subAgentActivity"].includes(str2(raw.type))) {
|
|
176845
176831
|
if (proof) began();
|
|
@@ -176873,7 +176859,7 @@ async function run(io, options, count2) {
|
|
|
176873
176859
|
} });
|
|
176874
176860
|
};
|
|
176875
176861
|
const start = async (text3, images = []) => {
|
|
176876
|
-
if (
|
|
176862
|
+
if (ended || io.signal?.aborted) return;
|
|
176877
176863
|
active = true;
|
|
176878
176864
|
submitted = true;
|
|
176879
176865
|
currentTurn2 = "";
|
|
@@ -176884,12 +176870,12 @@ async function run(io, options, count2) {
|
|
|
176884
176870
|
startupTimer = setTimeout(() => {
|
|
176885
176871
|
if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
|
|
176886
176872
|
}, CONVERSATION_MS.start);
|
|
176887
|
-
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((
|
|
176873
|
+
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path54) => ({ type: "localImage", path: path54 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error62) => {
|
|
176888
176874
|
if (!started) throw error62;
|
|
176889
176875
|
});
|
|
176890
176876
|
};
|
|
176891
176877
|
const schedule = () => {
|
|
176892
|
-
if (
|
|
176878
|
+
if (ended || timer) return;
|
|
176893
176879
|
timer = setTimeout(() => {
|
|
176894
176880
|
timer = void 0;
|
|
176895
176881
|
void check2();
|
|
@@ -176898,14 +176884,14 @@ async function run(io, options, count2) {
|
|
|
176898
176884
|
const refresh2 = async (until) => {
|
|
176899
176885
|
let expired = false;
|
|
176900
176886
|
try {
|
|
176901
|
-
await bounded(work.refresh(rpc, () => !
|
|
176887
|
+
await bounded(work.refresh(rpc, () => !ended && !expired), Math.max(0, until - Date.now()), "Codex background verification timed out.");
|
|
176902
176888
|
} finally {
|
|
176903
176889
|
expired = true;
|
|
176904
176890
|
}
|
|
176905
176891
|
childUpdates();
|
|
176906
176892
|
};
|
|
176907
176893
|
const finishManaged = async (until) => {
|
|
176908
|
-
if (
|
|
176894
|
+
if (ended) return;
|
|
176909
176895
|
const kept4 = work.work().filter((w2) => w2.disposition === "keep" && w2.status === "running");
|
|
176910
176896
|
cleanup.kept = kept4.map((w2) => w2.id);
|
|
176911
176897
|
if (host.instance) {
|
|
@@ -176931,7 +176917,7 @@ async function run(io, options, count2) {
|
|
|
176931
176917
|
};
|
|
176932
176918
|
const armCleanup = () => {
|
|
176933
176919
|
const pending = settlement;
|
|
176934
|
-
if (!pending ||
|
|
176920
|
+
if (!pending || ended) return;
|
|
176935
176921
|
const necessary = pending.work.some((w2) => work.entries.get(w2.id)?.status === "running" && (w2.kind === "agent" || pending.polled.has(w2.id)));
|
|
176936
176922
|
if (necessary) {
|
|
176937
176923
|
clearTimeout(settleTimer);
|
|
@@ -176940,7 +176926,7 @@ async function run(io, options, count2) {
|
|
|
176940
176926
|
}
|
|
176941
176927
|
if (settleTimer) return;
|
|
176942
176928
|
settleTimer = setTimeout(() => {
|
|
176943
|
-
if (
|
|
176929
|
+
if (ended) return;
|
|
176944
176930
|
note("Codex cleanup exceeded 60 seconds; operations remain unconfirmed.");
|
|
176945
176931
|
if (currentTurn2) void rpc.call("turn/interrupt", { threadId, turnId: currentTurn2 }).catch(() => {
|
|
176946
176932
|
});
|
|
@@ -176948,12 +176934,12 @@ async function run(io, options, count2) {
|
|
|
176948
176934
|
}, CODEX_SETTLE_MS.turn);
|
|
176949
176935
|
};
|
|
176950
176936
|
const check2 = async () => {
|
|
176951
|
-
if (
|
|
176937
|
+
if (ended || checking || active) return;
|
|
176952
176938
|
checking = true;
|
|
176953
176939
|
try {
|
|
176954
176940
|
const verifyUntil = Date.now() + CODEX_SETTLE_MS.verify;
|
|
176955
176941
|
await refresh2(verifyUntil);
|
|
176956
|
-
if (
|
|
176942
|
+
if (ended) return;
|
|
176957
176943
|
if (settlement) {
|
|
176958
176944
|
clearTimeout(settleTimer);
|
|
176959
176945
|
settleTimer = void 0;
|
|
@@ -176998,11 +176984,11 @@ async function run(io, options, count2) {
|
|
|
176998
176984
|
end(cleanup.detail);
|
|
176999
176985
|
} finally {
|
|
177000
176986
|
checking = false;
|
|
177001
|
-
if (!
|
|
176987
|
+
if (!ended && !active) schedule();
|
|
177002
176988
|
}
|
|
177003
176989
|
};
|
|
177004
176990
|
const rpc = connect(io.stdout, io.stdin, (msg) => {
|
|
177005
|
-
if (
|
|
176991
|
+
if (ended) return;
|
|
177006
176992
|
if (msg.id !== void 0) {
|
|
177007
176993
|
rpc.refuse(msg.id, "WildCrane cannot answer interactive requests in an unattended run.");
|
|
177008
176994
|
end(`Codex requested interaction: ${msg.method}`);
|
|
@@ -177132,7 +177118,7 @@ async function run(io, options, count2) {
|
|
|
177132
177118
|
const params = { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} };
|
|
177133
177119
|
let response;
|
|
177134
177120
|
let waiting = false;
|
|
177135
|
-
while (!
|
|
177121
|
+
while (!ended && !response) {
|
|
177136
177122
|
try {
|
|
177137
177123
|
response = await bounded(rpc.call(method, params), preparingUntil - Date.now(), `Codex ${method} timed out.`);
|
|
177138
177124
|
} catch (error62) {
|
|
@@ -177147,7 +177133,7 @@ async function run(io, options, count2) {
|
|
|
177147
177133
|
preparingUntil = Date.now() + CONVERSATION_MS.prepare;
|
|
177148
177134
|
}
|
|
177149
177135
|
}
|
|
177150
|
-
if (
|
|
177136
|
+
if (ended || !response) return done;
|
|
177151
177137
|
const thread = obj(response.thread);
|
|
177152
177138
|
for (const turn2 of list2(thread.turns)) historicalTurns.add(str2(turn2.id));
|
|
177153
177139
|
threadId = str2(thread.id);
|
|
@@ -180006,103 +179992,9 @@ function probeLogin(binary, harness) {
|
|
|
180006
179992
|
});
|
|
180007
179993
|
}
|
|
180008
179994
|
|
|
180009
|
-
// src/archive-completion.ts
|
|
180010
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
180011
|
-
import fs27 from "node:fs";
|
|
180012
|
-
import path32 from "node:path";
|
|
180013
|
-
|
|
180014
|
-
// ../cli/src/lib/cloud/execution.ts
|
|
180015
|
-
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
180016
|
-
function executionOf(value = process.env.AI4KANBAN_EXECUTION) {
|
|
180017
|
-
try {
|
|
180018
|
-
const held5 = typeof value === "string" ? JSON.parse(value) : value;
|
|
180019
|
-
if (held5 && UUID.test(held5.job) && UUID.test(held5.machine)) return { job: held5.job, machine: held5.machine };
|
|
180020
|
-
} catch {
|
|
180021
|
-
}
|
|
180022
|
-
return void 0;
|
|
180023
|
-
}
|
|
180024
|
-
|
|
180025
179995
|
// ../cli/src/lib/shared/delivery-evidence.ts
|
|
180026
|
-
var APPROVED = [
|
|
180027
|
-
/^##\s+Worth noting\s*$/i,
|
|
180028
|
-
/^##\s+Scope\s*$/i,
|
|
180029
|
-
/^##\s+Scope out\s*$/i,
|
|
180030
|
-
// `skill` is the word a spec section carries now; `agent` is the word it carried before
|
|
180031
|
-
// #403, and a card written by an older release still has to travel whole.
|
|
180032
|
-
/^##\s+By\s+`[^`]+`\s+(skill|agent)\s*$/i
|
|
180033
|
-
];
|
|
180034
|
-
var isApproved = (heading) => APPROVED.some((re3) => re3.test(heading));
|
|
180035
|
-
function approvedCardRequirements(text3) {
|
|
180036
|
-
const { meta: meta3, body } = parseFrontmatter(text3);
|
|
180037
|
-
const out = [];
|
|
180038
|
-
if (meta3?.title) out.push(`# ${meta3.title}`, "");
|
|
180039
|
-
const opening = [];
|
|
180040
|
-
const sections = [];
|
|
180041
|
-
let keeping = false;
|
|
180042
|
-
let started = false;
|
|
180043
|
-
for (const line of body.split("\n")) {
|
|
180044
|
-
if (/^##(?!#)\s/.test(line)) {
|
|
180045
|
-
started = true;
|
|
180046
|
-
keeping = isApproved(line);
|
|
180047
|
-
if (keeping) sections.push("", line);
|
|
180048
|
-
continue;
|
|
180049
|
-
}
|
|
180050
|
-
if (line.trim() === "<!-- agent -->") continue;
|
|
180051
|
-
if (!started) opening.push(line);
|
|
180052
|
-
else if (keeping) sections.push(line);
|
|
180053
|
-
}
|
|
180054
|
-
out.push(opening.join("\n").trim());
|
|
180055
|
-
out.push(sections.join("\n").trim());
|
|
180056
|
-
return out.filter(Boolean).join("\n\n").replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
180057
|
-
}
|
|
180058
179996
|
var ARCHIVE_COMPLETION_BATCH = 100;
|
|
180059
179997
|
|
|
180060
|
-
// src/archive-completion.ts
|
|
180061
|
-
function archivedDeliveries(board, numbers, machine) {
|
|
180062
|
-
const dir = path32.join(board, "deliveries");
|
|
180063
|
-
const deliveries = /* @__PURE__ */ new Map();
|
|
180064
|
-
if (!numbers.size) return deliveries;
|
|
180065
|
-
let files;
|
|
180066
|
-
try {
|
|
180067
|
-
files = fs27.readdirSync(dir);
|
|
180068
|
-
} catch {
|
|
180069
|
-
return deliveries;
|
|
180070
|
-
}
|
|
180071
|
-
for (const name of files) {
|
|
180072
|
-
if (!/^[a-z0-9]{1,64}\.json$/.test(name)) continue;
|
|
180073
|
-
try {
|
|
180074
|
-
const row = JSON.parse(fs27.readFileSync(path32.join(dir, name), "utf8"));
|
|
180075
|
-
if (row.cardId === null || !numbers.has(row.cardId) || row.deliveryId + ".json" !== name || executionOf(row.cloudExecution ?? null)?.machine !== machine || !Number.isFinite(row.startedAt)) continue;
|
|
180076
|
-
if ((deliveries.get(row.cardId)?.startedAt ?? -1) < row.startedAt) deliveries.set(row.cardId, row);
|
|
180077
|
-
} catch {
|
|
180078
|
-
}
|
|
180079
|
-
}
|
|
180080
|
-
return deliveries;
|
|
180081
|
-
}
|
|
180082
|
-
function archiveReceipt(row, archive, content, cwd) {
|
|
180083
|
-
if (row?.status !== "finished" || !row.cloudExecution || !row.approved || row.approved !== approvedCardRequirements(content)) return;
|
|
180084
|
-
const completions = Array.isArray(row.completions) ? row.completions : [];
|
|
180085
|
-
const end = completions.at(-1);
|
|
180086
|
-
const archived = end?.handoff?.archived_to;
|
|
180087
|
-
const target = end?.archiveSource?.kind === "group" && archive.endsWith("/root.md") ? archive.slice(0, -"/root.md".length) : archive;
|
|
180088
|
-
if (!end?.finished || typeof archived !== "string" || !(archived === target || archived.endsWith("/" + target))) return;
|
|
180089
|
-
const code = [...completions].reverse().find((step) => step.commit);
|
|
180090
|
-
const job = row.cloudExecution.job;
|
|
180091
|
-
if (!code?.commit) return row.landing?.commit || row.base && !row.scheduled ? void 0 : { id: row.deliveryId, job };
|
|
180092
|
-
const { commit, branch } = code;
|
|
180093
|
-
if (!branch || branch !== row.targetBranch || row.landing?.commit !== commit || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(commit)) return;
|
|
180094
|
-
try {
|
|
180095
|
-
execFileSync2(
|
|
180096
|
-
"git",
|
|
180097
|
-
["merge-base", "--is-ancestor", commit, "refs/heads/" + branch],
|
|
180098
|
-
{ cwd, stdio: "ignore", timeout: 5e3 }
|
|
180099
|
-
);
|
|
180100
|
-
return { id: row.deliveryId, job, commit, branch };
|
|
180101
|
-
} catch {
|
|
180102
|
-
return;
|
|
180103
|
-
}
|
|
180104
|
-
}
|
|
180105
|
-
|
|
180106
179998
|
// ../cli/src/components/Asset.md
|
|
180107
179999
|
var Asset_default = '# Asset\n\nShow a file as a Preview with `<Asset src=".assets/<card id>/<file>" label="..." />` alone in a paragraph.\nInline and fenced examples remain text.\n\n- **Label**: use a few words; an image\'s optional `alt` is its shipped caption and cannot contain `<`, `>` or its enclosing quote.\n- **Device**: use a separate tag for each device view, with `device="mobile"` or `device="desktop"`; both may reference the same responsive page.\n- **Variants**: versions of the same content on the same device share one tag with `variants=\'{"English": ".assets/<card id>/page.en.html", "\u4E2D\u6587": ".assets/<card id>/page.zh.html"}\'`, with `src` shown first; alternatives stay separate tags.\n- **Loop**: add `loop` for muted, looping video without controls.\n- **Tiled map**: a `.tmx` or `.tmj` `src` draws as a map; keep its `.tsx`/`.tsj` tilesets and images beside it, at the relative paths it names.\n- **Sprite animation**: a TexturePacker JSON (Hash or Array) `src` plays as an animation; keep its sheet image beside it, at the relative path `meta.image` names.\n- **Web page**: an `.html` or `.htm` `src` loads only the relative paths named in its tags and styles.\n- **Mermaid**: a `.mmd` or `.mermaid` `src` draws a diagram and shows its source if it cannot render.\n- **Documents**: PDF, DOCX, and PPTX open in a read-only viewer with page and zoom controls. DOCX and PPTX previews use LibreOffice and the fonts installed on the Runner. The original remains downloadable.\n- **Excel**: a `.xlsx` draws a read-only workbook with sheet tabs, formulas, and saved results.\n- **Text**: code and other text files show as highlighted text; a `.diff` or `.patch` shows its added and removed lines.\n';
|
|
180108
180000
|
|
|
@@ -180131,8 +180023,8 @@ function formatStamp(d2) {
|
|
|
180131
180023
|
}
|
|
180132
180024
|
|
|
180133
180025
|
// ../cli/src/lib/agents/catalog.ts
|
|
180134
|
-
import
|
|
180135
|
-
import
|
|
180026
|
+
import fs27 from "node:fs";
|
|
180027
|
+
import path32 from "node:path";
|
|
180136
180028
|
var specAgentCatalog = memoByFiles(() => [AGENTS, ...cloudStudioSources()], readCatalog);
|
|
180137
180029
|
function readCatalog() {
|
|
180138
180030
|
const agents = [];
|
|
@@ -180191,7 +180083,7 @@ function readBundled(folder2) {
|
|
|
180191
180083
|
function projectFolders(root2) {
|
|
180192
180084
|
let entries;
|
|
180193
180085
|
try {
|
|
180194
|
-
entries =
|
|
180086
|
+
entries = fs27.readdirSync(root2, { withFileTypes: true });
|
|
180195
180087
|
} catch {
|
|
180196
180088
|
return [];
|
|
180197
180089
|
}
|
|
@@ -180199,12 +180091,12 @@ function projectFolders(root2) {
|
|
|
180199
180091
|
}
|
|
180200
180092
|
function agentFileReader(dir) {
|
|
180201
180093
|
return (relative) => {
|
|
180202
|
-
const target =
|
|
180203
|
-
if (target !== dir && !target.startsWith(dir +
|
|
180094
|
+
const target = path32.resolve(dir, relative);
|
|
180095
|
+
if (target !== dir && !target.startsWith(dir + path32.sep)) return null;
|
|
180204
180096
|
try {
|
|
180205
|
-
const real =
|
|
180206
|
-
if (!real.startsWith(
|
|
180207
|
-
return
|
|
180097
|
+
const real = fs27.realpathSync(target);
|
|
180098
|
+
if (!real.startsWith(fs27.realpathSync(dir) + path32.sep)) return null;
|
|
180099
|
+
return fs27.readFileSync(real, "utf8");
|
|
180208
180100
|
} catch {
|
|
180209
180101
|
return null;
|
|
180210
180102
|
}
|
|
@@ -180214,20 +180106,20 @@ var ownFiles = (paths) => paths.filter((p2) => p2 !== "AGENT.md" && !p2.split("/
|
|
|
180214
180106
|
function walkFolder(dir, prefix) {
|
|
180215
180107
|
let entries;
|
|
180216
180108
|
try {
|
|
180217
|
-
entries =
|
|
180109
|
+
entries = fs27.readdirSync(dir, { withFileTypes: true });
|
|
180218
180110
|
} catch {
|
|
180219
180111
|
return [];
|
|
180220
180112
|
}
|
|
180221
180113
|
return entries.flatMap((e2) => {
|
|
180222
180114
|
const here = prefix ? `${prefix}/${e2.name}` : e2.name;
|
|
180223
|
-
return e2.isDirectory() ? walkFolder(
|
|
180115
|
+
return e2.isDirectory() ? walkFolder(path32.join(dir, e2.name), here) : [here];
|
|
180224
180116
|
});
|
|
180225
180117
|
}
|
|
180226
180118
|
function readProject2(root2, folder2) {
|
|
180227
|
-
const dir =
|
|
180119
|
+
const dir = path32.join(root2, folder2);
|
|
180228
180120
|
const file3 = agentFileReader(dir);
|
|
180229
180121
|
const text3 = file3("AGENT.md");
|
|
180230
|
-
const missing = rel(
|
|
180122
|
+
const missing = rel(path32.join(dir, "AGENT.md"));
|
|
180231
180123
|
if (text3 === null) return { problem: `${missing} is missing`, file: missing, missing: true };
|
|
180232
180124
|
const from = missing;
|
|
180233
180125
|
const read5 = parseSpecAgent(text3, from, file3, false, () => ownFiles(walkFolder(dir, "")));
|
|
@@ -180237,8 +180129,8 @@ function readProject2(root2, folder2) {
|
|
|
180237
180129
|
}
|
|
180238
180130
|
|
|
180239
180131
|
// ../cli/src/lib/memory.ts
|
|
180240
|
-
import
|
|
180241
|
-
import
|
|
180132
|
+
import fs28 from "node:fs";
|
|
180133
|
+
import path33 from "node:path";
|
|
180242
180134
|
|
|
180243
180135
|
// ../cli/src/lib/slug.ts
|
|
180244
180136
|
function slugify2(s) {
|
|
@@ -180251,25 +180143,25 @@ var PLANNER = "planner";
|
|
|
180251
180143
|
var PLANNER_MEMORY_FILES = ["decisions.md", "rejected.md", "redesign.md"];
|
|
180252
180144
|
var RESERVED_MODULE_NAMES = PLANNER_MEMORY_FILES.map((name) => name.replace(/\.md$/, ""));
|
|
180253
180145
|
function memoryDirectories(board) {
|
|
180254
|
-
const root2 = board ?
|
|
180146
|
+
const root2 = board ? path33.join(board, "memory") : MEMORY;
|
|
180255
180147
|
const walk = (dir, depth, scoped = true) => {
|
|
180256
180148
|
let entries;
|
|
180257
180149
|
try {
|
|
180258
|
-
entries =
|
|
180150
|
+
entries = fs28.readdirSync(dir, { withFileTypes: true });
|
|
180259
180151
|
} catch {
|
|
180260
180152
|
return [];
|
|
180261
180153
|
}
|
|
180262
180154
|
return entries.filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).flatMap((e2) => {
|
|
180263
|
-
const target =
|
|
180155
|
+
const target = path33.join(dir, e2.name);
|
|
180264
180156
|
return depth === 1 ? !scoped || ["project", "workspace"].includes(e2.name) ? [target] : [] : walk(target, depth - 1, scoped);
|
|
180265
180157
|
});
|
|
180266
180158
|
};
|
|
180267
180159
|
return [
|
|
180268
180160
|
root2,
|
|
180269
|
-
...walk(
|
|
180270
|
-
...walk(
|
|
180271
|
-
|
|
180272
|
-
].filter((dir) =>
|
|
180161
|
+
...walk(path33.join(root2, "previews"), 3),
|
|
180162
|
+
...walk(path33.join(root2, "studios"), 1, false),
|
|
180163
|
+
path33.join(root2, "agents", PLANNER)
|
|
180164
|
+
].filter((dir) => fs28.existsSync(dir)).map((dir) => `${dir}/`);
|
|
180273
180165
|
}
|
|
180274
180166
|
|
|
180275
180167
|
// ../cli/src/lib/agent/flows.ts
|
|
@@ -180700,14 +180592,14 @@ function collectSources(sources3, card, host) {
|
|
|
180700
180592
|
const active = /* @__PURE__ */ new Set();
|
|
180701
180593
|
const out = [];
|
|
180702
180594
|
const visit2 = (src, types, owner2, partial2 = false) => {
|
|
180703
|
-
const
|
|
180595
|
+
const path54 = src.replace(/[?#].*$/, "");
|
|
180704
180596
|
let resolved;
|
|
180705
180597
|
try {
|
|
180706
|
-
resolved = host.resolve(
|
|
180598
|
+
resolved = host.resolve(path54, owner2);
|
|
180707
180599
|
} catch (error62) {
|
|
180708
180600
|
if (owner2 !== card) return { key: null, error: why(error62) };
|
|
180709
180601
|
if (!nodes.has(src)) {
|
|
180710
|
-
const node3 = { key: src, file: null, kind: kindAt(
|
|
180602
|
+
const node3 = { key: src, file: null, kind: kindAt(path54, types), error: why(error62), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
180711
180603
|
nodes.set(src, node3);
|
|
180712
180604
|
out.push(node3);
|
|
180713
180605
|
}
|
|
@@ -180801,8 +180693,8 @@ function documentPreviewKey(artifact, version2) {
|
|
|
180801
180693
|
init_file_limits();
|
|
180802
180694
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
180803
180695
|
import crypto4 from "node:crypto";
|
|
180804
|
-
import
|
|
180805
|
-
import
|
|
180696
|
+
import fs32 from "node:fs";
|
|
180697
|
+
import path38 from "node:path";
|
|
180806
180698
|
import { isDeepStrictEqual } from "node:util";
|
|
180807
180699
|
|
|
180808
180700
|
// node_modules/node-diff3/dist/diff3.mjs
|
|
@@ -181066,8 +180958,8 @@ ${groups.get(id2).join("\n\n")}
|
|
|
181066
180958
|
|
|
181067
180959
|
// ../cli/src/lib/shared/triage-files.ts
|
|
181068
180960
|
var ITEM = /^triage\/(?:(dismissed|archived)\/)?([^/]+)\.md$/;
|
|
181069
|
-
function itemAt(
|
|
181070
|
-
const m = ITEM.exec(
|
|
180961
|
+
function itemAt(path54) {
|
|
180962
|
+
const m = ITEM.exec(path54);
|
|
181071
180963
|
if (!m) return null;
|
|
181072
180964
|
return { state: m[1] === "dismissed" ? "dismissed" : m[1] === "archived" ? "carded" : "open", name: m[2] };
|
|
181073
180965
|
}
|
|
@@ -181097,29 +180989,29 @@ init_dress_page();
|
|
|
181097
180989
|
|
|
181098
180990
|
// src/kanban-skill.ts
|
|
181099
180991
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
181100
|
-
import
|
|
181101
|
-
import
|
|
180992
|
+
import fs30 from "node:fs";
|
|
180993
|
+
import path35 from "node:path";
|
|
181102
180994
|
var SKILL_FOLDERS = [".claude/skills/kanban", ".agents/skills/kanban"];
|
|
181103
180995
|
var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
|
|
181104
180996
|
function removeLegacyKanbanSkill(root2) {
|
|
181105
180997
|
for (const folder2 of SKILL_FOLDERS) {
|
|
181106
180998
|
try {
|
|
181107
180999
|
let at2 = root2;
|
|
181108
|
-
if (!
|
|
181000
|
+
if (!fs30.lstatSync(at2, { throwIfNoEntry: false })?.isDirectory()) continue;
|
|
181109
181001
|
let safe3 = true;
|
|
181110
181002
|
const parts = `${folder2}/SKILL.md`.split("/");
|
|
181111
181003
|
for (const [i, name] of parts.entries()) {
|
|
181112
|
-
at2 =
|
|
181113
|
-
const stat2 =
|
|
181004
|
+
at2 = path35.join(at2, name);
|
|
181005
|
+
const stat2 = fs30.lstatSync(at2, { throwIfNoEntry: false });
|
|
181114
181006
|
if (!stat2 || stat2.isSymbolicLink() || (i < parts.length - 1 ? !stat2.isDirectory() : !stat2.isFile())) {
|
|
181115
181007
|
safe3 = false;
|
|
181116
181008
|
break;
|
|
181117
181009
|
}
|
|
181118
181010
|
}
|
|
181119
|
-
if (!safe3 || !MANAGED.test(
|
|
181120
|
-
|
|
181121
|
-
const dir =
|
|
181122
|
-
if (
|
|
181011
|
+
if (!safe3 || !MANAGED.test(fs30.readFileSync(at2, "utf8"))) continue;
|
|
181012
|
+
fs30.unlinkSync(at2);
|
|
181013
|
+
const dir = path35.dirname(at2);
|
|
181014
|
+
if (fs30.readdirSync(dir).length === 0) fs30.rmdirSync(dir);
|
|
181123
181015
|
} catch (e2) {
|
|
181124
181016
|
process.stderr.write(`wildcrane: \u65E0\u6CD5\u6E05\u7406 ${folder2}\uFF1A${e2 instanceof Error ? e2.message : String(e2)}
|
|
181125
181017
|
`);
|
|
@@ -181132,10 +181024,10 @@ function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
|
|
|
181132
181024
|
if (inside2.status !== 0) return;
|
|
181133
181025
|
const missing = [".akb/", ...folders2.map((f2) => `${f2}/`)].filter((p2) => git2("check-ignore", "-q", p2).status !== 0);
|
|
181134
181026
|
if (!missing.length) return;
|
|
181135
|
-
const exclude =
|
|
181136
|
-
|
|
181137
|
-
const held5 =
|
|
181138
|
-
|
|
181027
|
+
const exclude = path35.resolve(dir, inside2.stdout.trim());
|
|
181028
|
+
fs30.mkdirSync(path35.dirname(exclude), { recursive: true });
|
|
181029
|
+
const held5 = fs30.existsSync(exclude) ? fs30.readFileSync(exclude, "utf8") : "";
|
|
181030
|
+
fs30.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
|
|
181139
181031
|
`);
|
|
181140
181032
|
}
|
|
181141
181033
|
|
|
@@ -181182,16 +181074,16 @@ function openTaskFolder(job, projectDir) {
|
|
|
181182
181074
|
if (!projectDir) throw new Error(NO_FOLDER);
|
|
181183
181075
|
keepOutOfGit(projectDir);
|
|
181184
181076
|
markUsed(projectDir);
|
|
181185
|
-
const board =
|
|
181186
|
-
|
|
181077
|
+
const board = path38.join(projectDir, ".akb", "kanban");
|
|
181078
|
+
fs32.mkdirSync(board, { recursive: true });
|
|
181187
181079
|
return { task, cloudTask: task, board, cwd: projectDir, project: job.project, number: job.number ?? null, studio: job.studio ?? job.flow?.studio ?? null };
|
|
181188
181080
|
}
|
|
181189
181081
|
function openAgentFolder(job, projectDir) {
|
|
181190
181082
|
if (!job.project || !job.agent) throw new Error("This job names no project.");
|
|
181191
181083
|
keepOutOfGit(projectDir);
|
|
181192
181084
|
markUsed(projectDir);
|
|
181193
|
-
const board =
|
|
181194
|
-
|
|
181085
|
+
const board = path38.join(projectDir, ".akb", "kanban");
|
|
181086
|
+
fs32.mkdirSync(board, { recursive: true });
|
|
181195
181087
|
const recordKey = job.agent.studio ? `${job.agent.studio}-${job.agent.name}` : job.agent.name;
|
|
181196
181088
|
return {
|
|
181197
181089
|
task: `agent-${safe2(recordKey)}`,
|
|
@@ -181207,8 +181099,8 @@ function openDiscussionFolder(job, projectDir) {
|
|
|
181207
181099
|
if (!job.project) throw new Error("This job names no project.");
|
|
181208
181100
|
keepOutOfGit(projectDir);
|
|
181209
181101
|
markUsed(projectDir);
|
|
181210
|
-
const board =
|
|
181211
|
-
|
|
181102
|
+
const board = path38.join(projectDir, ".akb", "kanban");
|
|
181103
|
+
fs32.mkdirSync(board, { recursive: true });
|
|
181212
181104
|
return { task: "discussion", cloudTask: null, board, cwd: projectDir, project: job.project, number: null, studio: null };
|
|
181213
181105
|
}
|
|
181214
181106
|
var boardFolder = (ws) => ({ task: "board", cloudTask: null, board: ws.board, cwd: ws.cwd, project: ws.project, number: null, studio: null });
|
|
@@ -181219,7 +181111,7 @@ function inFolder(dir, work) {
|
|
|
181219
181111
|
const started = performance.now();
|
|
181220
181112
|
logSync("board.start", { dir, waitMs: Math.round(started - queued) });
|
|
181221
181113
|
try {
|
|
181222
|
-
return await withSyncLock(
|
|
181114
|
+
return await withSyncLock(path38.join(dir, ".akb", "kanban"), work);
|
|
181223
181115
|
} finally {
|
|
181224
181116
|
logSync("board.end", { dir, ms: Math.round(performance.now() - started) });
|
|
181225
181117
|
}
|
|
@@ -181233,37 +181125,37 @@ function inFolder(dir, work) {
|
|
|
181233
181125
|
}
|
|
181234
181126
|
var safe2 = (name) => name.replace(/[^\w.-]/g, "_") || "default";
|
|
181235
181127
|
var SKILL_ROOTS = [".claude/skills", ".agents/skills"];
|
|
181236
|
-
var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ??
|
|
181128
|
+
var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path38.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
|
|
181237
181129
|
function findCard(board, number4) {
|
|
181238
181130
|
const named = new RegExp(`^${number4}-`);
|
|
181239
181131
|
const walk = (dir) => {
|
|
181240
181132
|
let entries;
|
|
181241
181133
|
try {
|
|
181242
|
-
entries =
|
|
181134
|
+
entries = fs32.readdirSync(dir, { withFileTypes: true });
|
|
181243
181135
|
} catch {
|
|
181244
181136
|
return null;
|
|
181245
181137
|
}
|
|
181246
181138
|
for (const e2 of entries) {
|
|
181247
181139
|
if (!named.test(e2.name)) continue;
|
|
181248
|
-
if (e2.isFile() && e2.name.endsWith(".md")) return
|
|
181249
|
-
const root2 =
|
|
181250
|
-
if (e2.isDirectory() &&
|
|
181140
|
+
if (e2.isFile() && e2.name.endsWith(".md")) return path38.join(dir, e2.name);
|
|
181141
|
+
const root2 = path38.join(dir, e2.name, "root.md");
|
|
181142
|
+
if (e2.isDirectory() && fs32.existsSync(root2)) return root2;
|
|
181251
181143
|
}
|
|
181252
181144
|
for (const e2 of entries) if (e2.isDirectory() && !e2.name.startsWith(".")) {
|
|
181253
|
-
const hit = walk(
|
|
181145
|
+
const hit = walk(path38.join(dir, e2.name));
|
|
181254
181146
|
if (hit) return hit;
|
|
181255
181147
|
}
|
|
181256
181148
|
return null;
|
|
181257
181149
|
};
|
|
181258
|
-
return walk(
|
|
181150
|
+
return walk(path38.join(board, "todo")) ?? walk(path38.join(board, ".archive"));
|
|
181259
181151
|
}
|
|
181260
181152
|
function akbCardOf(ws) {
|
|
181261
181153
|
return ws.number && findCard(ws.board, ws.number) ? ws.number : void 0;
|
|
181262
181154
|
}
|
|
181263
|
-
var recordFile = (ws) =>
|
|
181155
|
+
var recordFile = (ws) => path38.join(ws.board, ".sync", `${ws.task}.json`);
|
|
181264
181156
|
function readRecord(ws) {
|
|
181265
181157
|
try {
|
|
181266
|
-
return { ...EMPTY, ...JSON.parse(
|
|
181158
|
+
return { ...EMPTY, ...JSON.parse(fs32.readFileSync(recordFile(ws), "utf8")) };
|
|
181267
181159
|
} catch {
|
|
181268
181160
|
return structuredClone(EMPTY);
|
|
181269
181161
|
}
|
|
@@ -181274,10 +181166,10 @@ function writeRecord(ws, record2) {
|
|
|
181274
181166
|
if (readText(recordFile(ws)) === content) return;
|
|
181275
181167
|
countSync("recordWrites");
|
|
181276
181168
|
if (syncDebug) countSync("recordBytes", Buffer.byteLength(content));
|
|
181277
|
-
|
|
181169
|
+
fs32.mkdirSync(path38.dirname(recordFile(ws)), { recursive: true });
|
|
181278
181170
|
const file3 = recordFile(ws);
|
|
181279
|
-
|
|
181280
|
-
|
|
181171
|
+
fs32.writeFileSync(`${file3}.tmp`, content);
|
|
181172
|
+
fs32.renameSync(`${file3}.tmp`, file3);
|
|
181281
181173
|
}
|
|
181282
181174
|
async function cleanRecords(ws, base, options = {}) {
|
|
181283
181175
|
const { removed = [], tasks, taskChat } = options;
|
|
@@ -181286,11 +181178,11 @@ async function cleanRecords(ws, base, options = {}) {
|
|
|
181286
181178
|
const removedPaths = new Set(removed);
|
|
181287
181179
|
const numbers = new Set(Object.keys(base.files).filter((p2) => p2.startsWith(root2) && !removedPaths.has(p2)).map((p2) => numberOfCard(p2.slice(root2.length))));
|
|
181288
181180
|
const deleted = new Map(removed.filter((p2) => p2.startsWith(root2 + ".archive/")).map((p2) => [numberOfCard(p2.slice(root2.length)), p2.slice(root2.length)]));
|
|
181289
|
-
for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(
|
|
181181
|
+
for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path38.join(ws.board, ".sync"))) {
|
|
181290
181182
|
if (!name.endsWith(".json") || name.includes("/")) continue;
|
|
181291
181183
|
let record2;
|
|
181292
181184
|
try {
|
|
181293
|
-
record2 = JSON.parse(
|
|
181185
|
+
record2 = JSON.parse(fs32.readFileSync(path38.join(ws.board, ".sync", name), "utf8"));
|
|
181294
181186
|
} catch {
|
|
181295
181187
|
continue;
|
|
181296
181188
|
}
|
|
@@ -181306,7 +181198,7 @@ async function cleanRecords(ws, base, options = {}) {
|
|
|
181306
181198
|
const folder2 = { ...ws, task: record2.task, cloudTask: record2.task, number: record2.number };
|
|
181307
181199
|
const list3 = assetsFile(record2.task);
|
|
181308
181200
|
const before = base.files[root2 + list3]?.content ?? null;
|
|
181309
|
-
if (taskChat && record2.task !== taskChat && !record2.deleted && !deleted.has(record2.number) && readText(
|
|
181201
|
+
if (taskChat && record2.task !== taskChat && !record2.deleted && !deleted.has(record2.number) && readText(path38.join(ws.board, list3)) === before) continue;
|
|
181310
181202
|
const card = findCard(ws.board, record2.number);
|
|
181311
181203
|
if (!record2.deleted && deleted.has(record2.number)) {
|
|
181312
181204
|
record2.deleted = deleted.get(record2.number);
|
|
@@ -181324,13 +181216,13 @@ async function cleanRecords(ws, base, options = {}) {
|
|
|
181324
181216
|
taskIndexes.set(ws.cwd, index);
|
|
181325
181217
|
index.retiring.add(record2.task);
|
|
181326
181218
|
if (card || kept(ws.cwd) || base.pendingAssets?.includes(record2.task)) continue;
|
|
181327
|
-
const here = readText(
|
|
181219
|
+
const here = readText(path38.join(ws.board, list3));
|
|
181328
181220
|
if (here !== null && here !== before) continue;
|
|
181329
181221
|
let changed = false;
|
|
181330
181222
|
for (const [name2, entry] of Object.entries(record2.assets ?? {})) {
|
|
181331
181223
|
let file3;
|
|
181332
181224
|
try {
|
|
181333
|
-
file3 = assetPath(folder2, name2, typeof record2.deleted === "string" ?
|
|
181225
|
+
file3 = assetPath(folder2, name2, typeof record2.deleted === "string" ? path38.join(ws.board, record2.deleted) : cardFile(folder2));
|
|
181334
181226
|
} catch {
|
|
181335
181227
|
changed = true;
|
|
181336
181228
|
break;
|
|
@@ -181343,57 +181235,67 @@ async function cleanRecords(ws, base, options = {}) {
|
|
|
181343
181235
|
}
|
|
181344
181236
|
}
|
|
181345
181237
|
if (!changed) {
|
|
181346
|
-
|
|
181238
|
+
fs32.rmSync(recordFile(folder2), { force: true });
|
|
181347
181239
|
forgetTask(index, record2.task);
|
|
181348
181240
|
}
|
|
181349
181241
|
}
|
|
181350
181242
|
return retired;
|
|
181351
181243
|
}
|
|
181352
|
-
var baseFile = (ws) =>
|
|
181244
|
+
var baseFile = (ws) => path38.join(ws.cwd, ".akb", "base.json");
|
|
181353
181245
|
function readBase(ws) {
|
|
181354
181246
|
try {
|
|
181355
|
-
const base = JSON.parse(
|
|
181247
|
+
const base = JSON.parse(fs32.readFileSync(baseFile(ws), "utf8"));
|
|
181356
181248
|
if (base.layout === "workspace") return base;
|
|
181357
181249
|
} catch {
|
|
181358
181250
|
}
|
|
181359
181251
|
return { layout: "workspace", head_seq: null, files: {} };
|
|
181360
181252
|
}
|
|
181253
|
+
function archiveMeta(content) {
|
|
181254
|
+
const { meta: meta3 } = parseFrontmatter(content);
|
|
181255
|
+
return meta3?.archived && !meta3.rejected ? meta3 : null;
|
|
181256
|
+
}
|
|
181361
181257
|
function writeBase(ws, base) {
|
|
181258
|
+
const root2 = rootOf(ws);
|
|
181259
|
+
for (const [task, version2] of Object.entries(base.reconciledArchives ?? {})) {
|
|
181260
|
+
const archive = base.files[root2 + version2.path];
|
|
181261
|
+
if (!archive || archive.seq !== version2.seq && !archiveMeta(archive.content)) delete base.reconciledArchives[task];
|
|
181262
|
+
}
|
|
181362
181263
|
const file3 = baseFile(ws);
|
|
181363
|
-
|
|
181364
|
-
|
|
181365
|
-
|
|
181264
|
+
fs32.mkdirSync(path38.dirname(file3), { recursive: true });
|
|
181265
|
+
fs32.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
|
|
181266
|
+
fs32.renameSync(`${file3}.tmp`, file3);
|
|
181366
181267
|
}
|
|
181367
181268
|
var hashOf2 = (bytes2) => crypto4.createHash("sha256").update(bytes2).digest("hex");
|
|
181368
181269
|
function hashFile(file3) {
|
|
181369
181270
|
try {
|
|
181370
|
-
return hashOf2(
|
|
181271
|
+
return hashOf2(fs32.readFileSync(file3));
|
|
181371
181272
|
} catch {
|
|
181372
181273
|
return null;
|
|
181373
181274
|
}
|
|
181374
181275
|
}
|
|
181375
181276
|
function write(file3, bytes2) {
|
|
181376
|
-
|
|
181377
|
-
|
|
181277
|
+
fs32.mkdirSync(path38.dirname(file3), { recursive: true });
|
|
181278
|
+
fs32.writeFileSync(file3, bytes2);
|
|
181378
181279
|
}
|
|
181379
181280
|
function readText(file3) {
|
|
181380
181281
|
try {
|
|
181381
|
-
return
|
|
181282
|
+
return fs32.readFileSync(file3, "utf8");
|
|
181382
181283
|
} catch {
|
|
181383
181284
|
return null;
|
|
181384
181285
|
}
|
|
181385
181286
|
}
|
|
181386
|
-
function filesUnder(dir, base = dir) {
|
|
181287
|
+
function filesUnder(dir, base = dir, skipDirectory) {
|
|
181288
|
+
if (dir === skipDirectory) return [];
|
|
181387
181289
|
let entries;
|
|
181388
181290
|
try {
|
|
181389
|
-
entries =
|
|
181291
|
+
entries = fs32.readdirSync(dir, { withFileTypes: true });
|
|
181390
181292
|
} catch {
|
|
181391
181293
|
return [];
|
|
181392
181294
|
}
|
|
181393
181295
|
return entries.flatMap((e2) => {
|
|
181394
|
-
const full =
|
|
181395
|
-
if (e2.isDirectory()) return filesUnder(full, base);
|
|
181396
|
-
return e2.isFile() ? [
|
|
181296
|
+
const full = path38.join(dir, e2.name);
|
|
181297
|
+
if (e2.isDirectory()) return filesUnder(full, base, skipDirectory);
|
|
181298
|
+
return e2.isFile() ? [path38.relative(base, full).split(path38.sep).join("/")] : [];
|
|
181397
181299
|
});
|
|
181398
181300
|
}
|
|
181399
181301
|
var kept3 = (file3) => isBoardPath(file3) && !/^memory\/agents\/(?!planner\/)/.test(file3);
|
|
@@ -181415,18 +181317,18 @@ function assetFiles(ws, list3, card = cardFile(ws)) {
|
|
|
181415
181317
|
return null;
|
|
181416
181318
|
}
|
|
181417
181319
|
};
|
|
181418
|
-
return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) =>
|
|
181320
|
+
return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path38.relative(ws.board, f2).split(path38.sep).join("/")));
|
|
181419
181321
|
}
|
|
181420
181322
|
var assetsListOf = (ws, base) => base.files[rootOf(ws) + assetsFile(ws.task)]?.content;
|
|
181421
181323
|
var localFiles = (ws, base) => {
|
|
181422
|
-
const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(
|
|
181423
|
-
return filesUnder(ws.board).filter((p2) => kept3(p2) && !assets.has(p2));
|
|
181324
|
+
const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path38.join(ws.board, assetsFile(ws.task))))]);
|
|
181325
|
+
return filesUnder(ws.board, ws.board, path38.join(ws.board, "deliveries")).filter((p2) => kept3(p2) && !assets.has(p2));
|
|
181424
181326
|
};
|
|
181425
181327
|
var SKILL_PATH = /^skills\/([a-z0-9]+(?:-[a-z0-9]+)*)\/((?:[\w.-]+\/)*[\w.-]+)$/;
|
|
181426
181328
|
function pullTools(ws, record2, files) {
|
|
181427
181329
|
const held5 = record2.tools?.skills ?? {};
|
|
181428
181330
|
const ours = new Set(Object.keys(held5).map((name) => name.split("/")[1]));
|
|
181429
|
-
const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) =>
|
|
181331
|
+
const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs32.existsSync(path38.join(ws.cwd, root2, skill)));
|
|
181430
181332
|
const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
|
|
181431
181333
|
const skills = {};
|
|
181432
181334
|
for (const [name, text3] of Object.entries(files)) {
|
|
@@ -181434,7 +181336,7 @@ function pullTools(ws, record2, files) {
|
|
|
181434
181336
|
if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
|
|
181435
181337
|
skills[name] = hashOf2(text3);
|
|
181436
181338
|
for (const root2 of SKILL_ROOTS) {
|
|
181437
|
-
const file3 =
|
|
181339
|
+
const file3 = path38.join(ws.cwd, root2, at2[1], at2[2]);
|
|
181438
181340
|
if (held5[name] !== skills[name] || hashFile(file3) !== skills[name]) write(file3, text3);
|
|
181439
181341
|
}
|
|
181440
181342
|
}
|
|
@@ -181443,8 +181345,8 @@ function pullTools(ws, record2, files) {
|
|
|
181443
181345
|
const [, skill, rest] = SKILL_PATH.exec(name) ?? [];
|
|
181444
181346
|
if (!skill || !rest) continue;
|
|
181445
181347
|
for (const root2 of SKILL_ROOTS) {
|
|
181446
|
-
|
|
181447
|
-
if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`)))
|
|
181348
|
+
fs32.rmSync(path38.join(ws.cwd, root2, skill, rest), { force: true });
|
|
181349
|
+
if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs32.rmSync(path38.join(ws.cwd, root2, skill), { recursive: true, force: true });
|
|
181448
181350
|
}
|
|
181449
181351
|
}
|
|
181450
181352
|
const names2 = [...new Set(Object.keys(skills).map((name) => name.split("/")[1]))];
|
|
@@ -181474,46 +181376,46 @@ async function pullStudio(ws, record2) {
|
|
|
181474
181376
|
if (files.ok) pullTools(ws, record2, files.value);
|
|
181475
181377
|
}
|
|
181476
181378
|
dropPlacedAgents(ws);
|
|
181477
|
-
for (const name of Object.keys(record2.agents ?? {}))
|
|
181379
|
+
for (const name of Object.keys(record2.agents ?? {})) fs32.rmSync(path38.join(ws.board, name), { force: true });
|
|
181478
181380
|
record2.agents = {};
|
|
181479
181381
|
return { ok: true, value: void 0 };
|
|
181480
181382
|
}
|
|
181481
|
-
var agentsRecord = (ws) =>
|
|
181383
|
+
var agentsRecord = (ws) => path38.join(ws.board, ".sync", "agents.json");
|
|
181482
181384
|
function readPlaced(ws) {
|
|
181483
181385
|
try {
|
|
181484
|
-
return JSON.parse(
|
|
181386
|
+
return JSON.parse(fs32.readFileSync(agentsRecord(ws), "utf8"));
|
|
181485
181387
|
} catch {
|
|
181486
181388
|
return {};
|
|
181487
181389
|
}
|
|
181488
181390
|
}
|
|
181489
181391
|
function dropPlacedAgents(ws) {
|
|
181490
181392
|
const placed = readPlaced(ws);
|
|
181491
|
-
for (const name of Object.keys(placed)) if (hashFile(
|
|
181492
|
-
|
|
181393
|
+
for (const name of Object.keys(placed)) if (hashFile(path38.join(ws.board, name)) === placed[name]) fs32.rmSync(path38.join(ws.board, name), { force: true });
|
|
181394
|
+
fs32.rmSync(agentsRecord(ws), { force: true });
|
|
181493
181395
|
}
|
|
181494
181396
|
function assetPath(ws, name, owner2) {
|
|
181495
181397
|
if (/^[a-z][\w+.-]*:/i.test(name) || name.startsWith("#") || name.startsWith("//")) return null;
|
|
181496
|
-
if (
|
|
181398
|
+
if (path38.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
|
|
181497
181399
|
const held5 = /^\.assets\//.exec(name);
|
|
181498
181400
|
const state = stateDir(ws);
|
|
181499
|
-
const root2 = held5 && state ?
|
|
181500
|
-
const file3 = held5 && state ?
|
|
181501
|
-
const roots = [ws.board, ...state ? ["assets"].map((folder2) =>
|
|
181502
|
-
const inside2 = (file4, root3) => file4.startsWith(root3 +
|
|
181401
|
+
const root2 = held5 && state ? path38.join(state, "assets") : ws.board;
|
|
181402
|
+
const file3 = held5 && state ? path38.resolve(root2, name.slice(held5[0].length)) : path38.resolve(path38.dirname(owner2), name);
|
|
181403
|
+
const roots = [ws.board, ...state ? ["assets"].map((folder2) => path38.join(state, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
|
|
181404
|
+
const inside2 = (file4, root3) => file4.startsWith(root3 + path38.sep);
|
|
181503
181405
|
if (!roots.some((root3) => inside2(file3, root3))) throw new Error(`outside the board: ${name}`);
|
|
181504
181406
|
let existing = file3;
|
|
181505
|
-
while (!
|
|
181506
|
-
const real =
|
|
181407
|
+
while (!fs32.existsSync(existing) && path38.dirname(existing) !== existing) existing = path38.dirname(existing);
|
|
181408
|
+
const real = path38.join(fs32.realpathSync(existing), path38.relative(existing, file3));
|
|
181507
181409
|
let stateParent = state;
|
|
181508
|
-
while (stateParent && !
|
|
181509
|
-
const realState = state && stateParent ?
|
|
181510
|
-
const realRoots = [
|
|
181410
|
+
while (stateParent && !fs32.existsSync(stateParent) && path38.dirname(stateParent) !== stateParent) stateParent = path38.dirname(stateParent);
|
|
181411
|
+
const realState = state && stateParent ? path38.resolve(fs32.realpathSync(stateParent), path38.relative(stateParent, state)) : null;
|
|
181412
|
+
const realRoots = [fs32.realpathSync(ws.board), ...realState ? ["assets"].map((folder2) => path38.join(realState, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
|
|
181511
181413
|
if (!realRoots.some((root3) => real === root3 || inside2(real, root3))) throw new Error(`link outside the board: ${name}`);
|
|
181512
181414
|
return file3;
|
|
181513
181415
|
}
|
|
181514
181416
|
function cardAssetsDir(ws, id2) {
|
|
181515
181417
|
const state = stateDir(ws);
|
|
181516
|
-
return state &&
|
|
181418
|
+
return state && path38.join(state, "assets", String(id2));
|
|
181517
181419
|
}
|
|
181518
181420
|
function stateDir(ws) {
|
|
181519
181421
|
try {
|
|
@@ -181584,8 +181486,8 @@ async function prepareConflictTask(ws) {
|
|
|
181584
181486
|
const p2 = f2.path.slice(root2.length);
|
|
181585
181487
|
if (!kept3(p2)) continue;
|
|
181586
181488
|
if (!(missing && cards.includes(f2)) && p2 !== assetsFile(ws.task)) continue;
|
|
181587
|
-
if (protectedPaths.has(p2) || readText(
|
|
181588
|
-
write(
|
|
181489
|
+
if (protectedPaths.has(p2) || readText(path38.join(ws.board, p2)) !== null || base.files[f2.path]) continue;
|
|
181490
|
+
write(path38.join(ws.board, p2), f2.content);
|
|
181589
181491
|
base.files[f2.path] = { seq: f2.seq, content: f2.content };
|
|
181590
181492
|
changed = true;
|
|
181591
181493
|
}
|
|
@@ -181594,7 +181496,7 @@ async function prepareConflictTask(ws) {
|
|
|
181594
181496
|
const record2 = readRecord(ws);
|
|
181595
181497
|
const studio = await pullStudio(ws, record2);
|
|
181596
181498
|
if (!studio.ok) return studio;
|
|
181597
|
-
const assets = await pullAssets(ws, record2, assetsOf(readText(
|
|
181499
|
+
const assets = await pullAssets(ws, record2, assetsOf(readText(path38.join(ws.board, assetsFile(ws.task))) ?? assetsListOf(ws, base)), true);
|
|
181598
181500
|
if (!assets.ok) return assets;
|
|
181599
181501
|
writeRecord(ws, record2);
|
|
181600
181502
|
return { ok: true, value: void 0 };
|
|
@@ -181618,16 +181520,16 @@ function applyRestorations(ws, base, files) {
|
|
|
181618
181520
|
if (number4 === null || !stamp3 || base.files[f2.path]?.content === f2.content) continue;
|
|
181619
181521
|
const old = Object.entries(base.files).find(([name]) => name.startsWith(root2) && numberOfCard(name.slice(root2.length)) === number4);
|
|
181620
181522
|
if (old && old[0] === f2.path && /^restored:\s*(.+)$/m.exec(old[1].content)?.[1] === stamp3) continue;
|
|
181621
|
-
for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(
|
|
181523
|
+
for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(path38.join(ws.board, dir), ws.board))) {
|
|
181622
181524
|
if (numberOfCard(local) !== number4) continue;
|
|
181623
|
-
const here = readText(
|
|
181525
|
+
const here = readText(path38.join(ws.board, local));
|
|
181624
181526
|
if (here !== null && here !== base.files[root2 + local]?.content && here !== f2.content) {
|
|
181625
|
-
write(
|
|
181527
|
+
write(path38.join(ws.board, ".sync", "restored", String(f2.seq), local), here);
|
|
181626
181528
|
}
|
|
181627
181529
|
restored.add(local);
|
|
181628
|
-
if (local !== p2)
|
|
181530
|
+
if (local !== p2) fs32.rmSync(path38.join(ws.board, local), { force: true });
|
|
181629
181531
|
}
|
|
181630
|
-
write(
|
|
181532
|
+
write(path38.join(ws.board, p2), f2.content);
|
|
181631
181533
|
restored.add(p2);
|
|
181632
181534
|
}
|
|
181633
181535
|
return restored;
|
|
@@ -181640,7 +181542,7 @@ function observeConflicts(ws, base, files) {
|
|
|
181640
181542
|
const own2 = f2.path.startsWith(root2);
|
|
181641
181543
|
const p2 = own2 ? f2.path.slice(root2.length) : f2.path;
|
|
181642
181544
|
if (pending.has(p2) || !kept3(p2) || (p2.startsWith(MEMORY2) && shared(p2.slice(MEMORY2.length))) !== !own2) return false;
|
|
181643
|
-
return !!mergeFile(base.files[f2.path]?.content ?? null, readText(
|
|
181545
|
+
return !!mergeFile(base.files[f2.path]?.content ?? null, readText(path38.join(ws.board, p2)), f2.content).conflict;
|
|
181644
181546
|
});
|
|
181645
181547
|
if (!conflicting) return false;
|
|
181646
181548
|
const changed = new Map(files.map((f2) => [f2.path, f2]));
|
|
@@ -181650,7 +181552,7 @@ function observeConflicts(ws, base, files) {
|
|
|
181650
181552
|
if (pending.has(p2)) continue;
|
|
181651
181553
|
const remotePath = remoteOf(ws, shared, p2);
|
|
181652
181554
|
const before = base.files[remotePath]?.content ?? null;
|
|
181653
|
-
const here = readText(
|
|
181555
|
+
const here = readText(path38.join(ws.board, p2));
|
|
181654
181556
|
if (here === before) continue;
|
|
181655
181557
|
const there = changed.get(remotePath) ?? { content: before, seq: base.files[remotePath]?.seq ?? base.deleted?.[remotePath] ?? 0 };
|
|
181656
181558
|
const merged = mergeFile(before, here, there.content);
|
|
@@ -181675,7 +181577,7 @@ async function readCloud(ws, preserveAssets, taskChat) {
|
|
|
181675
181577
|
const base = readBase(ws);
|
|
181676
181578
|
const previous = { ...base.files };
|
|
181677
181579
|
const known2 = new Set(Object.keys(base.files));
|
|
181678
|
-
const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(
|
|
181580
|
+
const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path38.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
|
|
181679
181581
|
if (base.workspace === void 0) {
|
|
181680
181582
|
const project = await readProject(ws.project);
|
|
181681
181583
|
if (!project.ok) return project;
|
|
@@ -181685,7 +181587,7 @@ async function readCloud(ws, preserveAssets, taskChat) {
|
|
|
181685
181587
|
if (!read5.ok) return read5;
|
|
181686
181588
|
const restored = applyRestorations(ws, base, read5.value.files);
|
|
181687
181589
|
if (base.head_seq !== null && observeConflicts(ws, base, read5.value.files)) return { ok: false, code: "board_content_conflict", error: "Resolve the saved board content conflicts before refreshing." };
|
|
181688
|
-
const dirty = new Set(base.head_seq === null ? [] : [.../* @__PURE__ */ new Set([...localFiles(ws, base), ...viewOf(ws, base, sharedMemory(ws.board)).keys()])].filter((p2) => !restored.has(p2) && readText(
|
|
181590
|
+
const dirty = new Set(base.head_seq === null ? [] : [.../* @__PURE__ */ new Set([...localFiles(ws, base), ...viewOf(ws, base, sharedMemory(ws.board)).keys()])].filter((p2) => !restored.has(p2) && readText(path38.join(ws.board, p2)) !== (previous[remoteOf(ws, sharedMemory(ws.board), p2)]?.content ?? null)));
|
|
181689
181591
|
for (const p2 of dirty) keepDraft.add(p2);
|
|
181690
181592
|
if (base.head_seq === null) base.files = {};
|
|
181691
181593
|
for (const f2 of read5.value.files) {
|
|
@@ -181703,20 +181605,20 @@ async function readCloud(ws, preserveAssets, taskChat) {
|
|
|
181703
181605
|
const removed = [...known2].filter((p2) => !base.files[p2]);
|
|
181704
181606
|
for (const p2 of removed) {
|
|
181705
181607
|
const local = p2.startsWith(rootOf(ws)) ? p2.slice(rootOf(ws).length) : p2;
|
|
181706
|
-
if (local.startsWith(".archive/") && readText(
|
|
181608
|
+
if (local.startsWith(".archive/") && readText(path38.join(ws.board, local)) !== null && readText(path38.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
|
|
181707
181609
|
}
|
|
181708
181610
|
if (!dirty.size) base.head_seq = read5.value.head_seq;
|
|
181709
181611
|
base.project = ws.project;
|
|
181710
181612
|
writeBase(ws, base);
|
|
181711
181613
|
const reset = (view2) => {
|
|
181712
181614
|
for (const [p2, content] of view2) {
|
|
181713
|
-
const file3 =
|
|
181615
|
+
const file3 = path38.join(ws.board, p2);
|
|
181714
181616
|
if (!keepDraft.has(p2) && kept3(p2) && readText(file3) !== content) write(file3, content);
|
|
181715
181617
|
}
|
|
181716
181618
|
};
|
|
181717
181619
|
const view = viewOf(ws, base, sharedMemory(ws.board));
|
|
181718
181620
|
const first = (p2) => isSettingsPath(p2) && !known2.has(rootOf(ws) + p2);
|
|
181719
|
-
for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2))
|
|
181621
|
+
for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2)) fs32.rmSync(path38.join(ws.board, p2), { force: true });
|
|
181720
181622
|
reset(view);
|
|
181721
181623
|
const retired = await cleanRecords(ws, base, { removed, taskChat });
|
|
181722
181624
|
if (retired.has(ws.task)) {
|
|
@@ -181734,18 +181636,18 @@ async function readCloud(ws, preserveAssets, taskChat) {
|
|
|
181734
181636
|
return { ok: true, value: void 0 };
|
|
181735
181637
|
}
|
|
181736
181638
|
function writeIndex(board) {
|
|
181737
|
-
const todo =
|
|
181639
|
+
const todo = path38.join(board, "todo");
|
|
181738
181640
|
const cards = [];
|
|
181739
181641
|
let entries = [];
|
|
181740
181642
|
try {
|
|
181741
|
-
entries =
|
|
181643
|
+
entries = fs32.readdirSync(todo, { withFileTypes: true });
|
|
181742
181644
|
} catch {
|
|
181743
181645
|
}
|
|
181744
181646
|
for (const e2 of entries) {
|
|
181745
181647
|
const id2 = /^(\d+)-/.exec(e2.name)?.[1];
|
|
181746
181648
|
if (!id2) continue;
|
|
181747
181649
|
const link = e2.isDirectory() ? `${e2.name}/root.md` : e2.name.endsWith(".md") ? e2.name : null;
|
|
181748
|
-
const text4 = link && readText(
|
|
181650
|
+
const text4 = link && readText(path38.join(todo, link));
|
|
181749
181651
|
if (text4 === null || !link) continue;
|
|
181750
181652
|
cards.push({ id: Number(id2), title: cardFront(text4).title ?? e2.name.replace(/\.md$/, ""), link });
|
|
181751
181653
|
}
|
|
@@ -181760,7 +181662,7 @@ the number at the front of a filename is the task id.
|
|
|
181760
181662
|
|
|
181761
181663
|
${list3}
|
|
181762
181664
|
`;
|
|
181763
|
-
if (readText(
|
|
181665
|
+
if (readText(path38.join(todo, "README.md")) !== text3) write(path38.join(todo, "README.md"), text3);
|
|
181764
181666
|
}
|
|
181765
181667
|
var workspaceOf = (ws) => readBase(ws).workspace ?? null;
|
|
181766
181668
|
async function pullAssets(ws, record2, assets, preserve = false) {
|
|
@@ -181848,7 +181750,7 @@ async function pullAssets(ws, record2, assets, preserve = false) {
|
|
|
181848
181750
|
}
|
|
181849
181751
|
if (!child) return src;
|
|
181850
181752
|
dependencies.push(name2);
|
|
181851
|
-
const back = !found.text && /^\.assets\//.test(name2) ? name2 :
|
|
181753
|
+
const back = !found.text && /^\.assets\//.test(name2) ? name2 : path38.relative(path38.dirname(target), child).split(path38.sep).join("/");
|
|
181852
181754
|
if (back !== src) changed = true;
|
|
181853
181755
|
return back;
|
|
181854
181756
|
});
|
|
@@ -181885,20 +181787,20 @@ async function readAsset(artifact, version2) {
|
|
|
181885
181787
|
return { ok: true, value: Buffer.from(typeof content === "string" ? content : JSON.stringify(content)) };
|
|
181886
181788
|
}
|
|
181887
181789
|
async function sentOf(file3, kind) {
|
|
181888
|
-
const ext =
|
|
181790
|
+
const ext = path38.extname(file3).toLowerCase();
|
|
181889
181791
|
if (kind !== "html") {
|
|
181890
181792
|
const office = officeExtension(file3);
|
|
181891
181793
|
const type = office ? OFFICE_TYPES[office] : kind === "tiled" && ext === ".tsx" ? "application/xml" : TYPES[ext];
|
|
181892
|
-
return { bytes:
|
|
181794
|
+
return { bytes: fs32.readFileSync(file3), type: type ?? "application/octet-stream", kind };
|
|
181893
181795
|
}
|
|
181894
181796
|
const page = await (await Promise.resolve().then(() => (init_mockup(), mockup_exports))).drawMockup(file3);
|
|
181895
181797
|
return { bytes: Buffer.from(page), type: "text/html", kind };
|
|
181896
181798
|
}
|
|
181897
|
-
var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(
|
|
181799
|
+
var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path38.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
|
|
181898
181800
|
function undrawn(ws, reason) {
|
|
181899
181801
|
const state = stateDir(ws);
|
|
181900
|
-
for (const [root2, shown] of [...state ? [[
|
|
181901
|
-
reason = reason.split(`file://${root2}${
|
|
181802
|
+
for (const [root2, shown] of [...state ? [[path38.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
|
|
181803
|
+
reason = reason.split(`file://${root2}${path38.sep}`).join(shown && `${shown}/`).split(`${root2}${path38.sep}`).join(shown && `${shown}/`);
|
|
181902
181804
|
}
|
|
181903
181805
|
return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
|
|
181904
181806
|
}
|
|
@@ -181974,14 +181876,14 @@ async function pushAssets(ws, record2, before) {
|
|
|
181974
181876
|
if (body === null) return { ok: true, value: void 0 };
|
|
181975
181877
|
const refs = {};
|
|
181976
181878
|
const canonical = (target) => {
|
|
181977
|
-
const real = (file4) =>
|
|
181879
|
+
const real = (file4) => fs32.existsSync(file4) ? fs32.realpathSync(file4) : path38.dirname(file4) === file4 ? file4 : path38.join(real(path38.dirname(file4)), path38.basename(file4));
|
|
181978
181880
|
target = real(target);
|
|
181979
181881
|
const state = stateDir(ws);
|
|
181980
181882
|
for (const folder2 of ["assets"]) {
|
|
181981
|
-
const root2 = state && real(
|
|
181982
|
-
if (root2 && target.startsWith(root2 +
|
|
181883
|
+
const root2 = state && real(path38.join(state, folder2));
|
|
181884
|
+
if (root2 && target.startsWith(root2 + path38.sep)) return `.${folder2}/${path38.relative(root2, target).split(path38.sep).join("/")}`;
|
|
181983
181885
|
}
|
|
181984
|
-
return
|
|
181886
|
+
return path38.relative(real(path38.dirname(file3)), target).split(path38.sep).join("/");
|
|
181985
181887
|
};
|
|
181986
181888
|
const required2 = new Map(parsePreviewBlocks(body).blocks.flatMap((block) => bodyReferences(block.instructions).filter((ref) => ref.types.length).map((ref) => [ref.src, sourcePosition(body, block.start).line])));
|
|
181987
181889
|
try {
|
|
@@ -181993,11 +181895,11 @@ async function pushAssets(ws, record2, before) {
|
|
|
181993
181895
|
const target = assetPath(ws, src, owner2);
|
|
181994
181896
|
if (!target) return null;
|
|
181995
181897
|
const key = owner2 === file3 && before[src] ? src : canonical(target);
|
|
181996
|
-
if (!
|
|
181898
|
+
if (!fs32.statSync(target, { throwIfNoEntry: false })?.isFile()) {
|
|
181997
181899
|
if (before[key]) return { key, file: null };
|
|
181998
181900
|
throw new Error(`file not found: ${target}`);
|
|
181999
181901
|
}
|
|
182000
|
-
return { key: canonical(
|
|
181902
|
+
return { key: canonical(fs32.realpathSync(target)), file: target };
|
|
182001
181903
|
},
|
|
182002
181904
|
read: referenceText,
|
|
182003
181905
|
retained: (key, types) => {
|
|
@@ -182021,7 +181923,7 @@ async function pushAssets(ws, record2, before) {
|
|
|
182021
181923
|
let why2 = node2.error ?? (partialStudio ? void 0 : [...node2.dependencies.values()].map((key) => refs[key]?.error).find(Boolean));
|
|
182022
181924
|
if (!why2 && node2.file) {
|
|
182023
181925
|
try {
|
|
182024
|
-
if (
|
|
181926
|
+
if (fs32.statSync(node2.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
|
|
182025
181927
|
out = await sentOf(node2.file, kind);
|
|
182026
181928
|
} catch (error62) {
|
|
182027
181929
|
why2 = renderError(error62);
|
|
@@ -182031,7 +181933,7 @@ async function pushAssets(ws, record2, before) {
|
|
|
182031
181933
|
if (why2) {
|
|
182032
181934
|
const key = [...node2.aliases].find((alias) => required2.has(alias));
|
|
182033
181935
|
if (key) {
|
|
182034
|
-
const error62 = `${
|
|
181936
|
+
const error62 = `${path38.relative(ws.board, file3)}:${required2.get(key)} \u2014 ${key}: ${undrawn(ws, why2)}`;
|
|
182035
181937
|
return { ok: false, code: "bad_request", error: error62, failure: validationFailure(error62, "preview_attachment") };
|
|
182036
181938
|
}
|
|
182037
181939
|
let pin = old ? { ...old } : previous?.version ? { artifact: previous.artifact, version: previous.version, ...previous.dependencies ? { dependencies: previous.dependencies } : {} } : null;
|
|
@@ -182087,7 +181989,7 @@ async function pushAssets(ws, record2, before) {
|
|
|
182087
181989
|
const unchanged = restored && previous && (previous.kind ?? out.kind) === out.kind && localHash === (previous.localHash ?? previous.hash) && [...node2.dependencies.values()].every((key) => refs[key]?.artifact === before[key]?.artifact);
|
|
182088
181990
|
if (!entry || !unchanged && entry.hash !== hash2 || entry.kind && entry.kind !== out.kind) {
|
|
182089
181991
|
if (!ws.cloudTask) continue;
|
|
182090
|
-
let artifact = previous && (previous.kind ?? kindOf(
|
|
181992
|
+
let artifact = previous && (previous.kind ?? kindOf(path38.extname(node2.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
|
|
182091
181993
|
if (!artifact) {
|
|
182092
181994
|
const made = await createArtifact(ws.cloudTask, node2.key.slice(0, 200), out.kind, artifactKey(ws.cloudTask, node2.key, out.kind, previous?.artifact));
|
|
182093
181995
|
if (!made.ok) return { ...made, error: `${node2.key}: ${made.error}` };
|
|
@@ -182144,8 +182046,8 @@ function proposeItems(ws, base, paths) {
|
|
|
182144
182046
|
const root2 = rootOf(ws);
|
|
182145
182047
|
for (const p2 of paths ?? localFiles(ws, base)) {
|
|
182146
182048
|
if (itemAt(p2)?.state !== "open" || base.files[root2 + p2]) continue;
|
|
182147
|
-
const file3 =
|
|
182148
|
-
const content =
|
|
182049
|
+
const file3 = path38.join(ws.board, p2);
|
|
182050
|
+
const content = fs32.readFileSync(file3, "utf8");
|
|
182149
182051
|
const said = (key) => new RegExp(`^${key}:`, "m").test(content.split(/\n---/)[0] ?? "");
|
|
182150
182052
|
const fields2 = {
|
|
182151
182053
|
...ws.cloudTask && !said("source_task") ? { source_task: ws.cloudTask } : {},
|
|
@@ -182177,7 +182079,7 @@ var push = (ws, job, stopped2) => inFolder(ws.cwd, async () => {
|
|
|
182177
182079
|
if (busy(preparationKey(ws))) return { ok: false, conflict: false, offline: true, error: "Task content is still being prepared." };
|
|
182178
182080
|
return sendMarked(ws, job);
|
|
182179
182081
|
});
|
|
182180
|
-
var preparationKey = (ws) =>
|
|
182082
|
+
var preparationKey = (ws) => path38.join(projectStateDir(ws.board), "preparing");
|
|
182181
182083
|
async function whenPrepared(ws, cancelled, work, stopped2 = () => false) {
|
|
182182
182084
|
while (!stopped2()) {
|
|
182183
182085
|
const result = await inFolder(ws.cwd, async () => {
|
|
@@ -182226,11 +182128,11 @@ async function sendMarked(ws, job, scope = {}) {
|
|
|
182226
182128
|
return pushed;
|
|
182227
182129
|
}
|
|
182228
182130
|
var boardIdentity = (ws) => {
|
|
182229
|
-
const stat2 =
|
|
182131
|
+
const stat2 = fs32.statSync(ws.board);
|
|
182230
182132
|
return `${stat2.dev}:${stat2.ino}:${stat2.birthtimeMs}`;
|
|
182231
182133
|
};
|
|
182232
182134
|
function rememberDirectories(directories, file3) {
|
|
182233
|
-
for (let dir =
|
|
182135
|
+
for (let dir = path38.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path38.posix.dirname(dir)) directories.add(dir);
|
|
182234
182136
|
}
|
|
182235
182137
|
function newIndex(ws) {
|
|
182236
182138
|
const directories = /* @__PURE__ */ new Set();
|
|
@@ -182259,7 +182161,7 @@ function forgetTask(index, task) {
|
|
|
182259
182161
|
}
|
|
182260
182162
|
function indexTask(ws, record2, card = cardFile(ws)) {
|
|
182261
182163
|
if (!ws.cloudTask || !ws.number) return;
|
|
182262
|
-
const paths = /* @__PURE__ */ new Set([card,
|
|
182164
|
+
const paths = /* @__PURE__ */ new Set([card, path38.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
|
|
182263
182165
|
for (const name of Object.keys(record2.assets)) {
|
|
182264
182166
|
try {
|
|
182265
182167
|
const file3 = assetPath(ws, name, card);
|
|
@@ -182268,7 +182170,7 @@ function indexTask(ws, record2, card = cardFile(ws)) {
|
|
|
182268
182170
|
}
|
|
182269
182171
|
}
|
|
182270
182172
|
for (const file3 of [...paths]) {
|
|
182271
|
-
for (let dir =
|
|
182173
|
+
for (let dir = path38.dirname(file3); dir.startsWith(ws.cwd + path38.sep); dir = path38.dirname(dir)) paths.add(dir);
|
|
182272
182174
|
}
|
|
182273
182175
|
const index = syncIndex(ws) ?? newIndex(ws);
|
|
182274
182176
|
for (const file3 of index.tasks.get(ws.task)?.paths ?? []) {
|
|
@@ -182288,7 +182190,7 @@ function affectedTasks(ws, paths) {
|
|
|
182288
182190
|
const index = syncIndex(ws);
|
|
182289
182191
|
const tasks = new Set(index?.retiring);
|
|
182290
182192
|
for (const p2 of paths) {
|
|
182291
|
-
for (const task2 of index?.files.get(
|
|
182193
|
+
for (const task2 of index?.files.get(path38.resolve(ws.board, p2)) ?? []) tasks.add(task2);
|
|
182292
182194
|
const task = /^\.sync\/([\w-]+)\.json$/.exec(p2)?.[1];
|
|
182293
182195
|
if (task) tasks.add(task);
|
|
182294
182196
|
}
|
|
@@ -182308,13 +182210,13 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182308
182210
|
const retired = await cleanRecords(ws, base, { tasks: names2 ?? void 0, taskChat });
|
|
182309
182211
|
if (retired.has(ws.task)) record2.deleted = true;
|
|
182310
182212
|
const records = ws.cloudTask ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
|
|
182311
|
-
...filesUnder(
|
|
182213
|
+
...filesUnder(path38.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
|
|
182312
182214
|
...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
|
|
182313
182215
|
])];
|
|
182314
182216
|
const tasks = ws.cloudTask ? [{ folder: ws, record: record2 }] : records.flatMap((name) => {
|
|
182315
182217
|
let held5;
|
|
182316
182218
|
try {
|
|
182317
|
-
held5 = JSON.parse(
|
|
182219
|
+
held5 = JSON.parse(fs32.readFileSync(path38.join(ws.board, ".sync", name), "utf8"));
|
|
182318
182220
|
} catch {
|
|
182319
182221
|
const known2 = syncIndex(ws)?.tasks.get(name.replace(/\.json$/, ""));
|
|
182320
182222
|
if (!known2) return [];
|
|
@@ -182335,7 +182237,7 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182335
182237
|
const assetLists = /* @__PURE__ */ new Map();
|
|
182336
182238
|
const generatedAssets = /* @__PURE__ */ new Set();
|
|
182337
182239
|
const cards = !selected && !ws.cloudTask ? new Map(
|
|
182338
|
-
[".archive", "todo"].flatMap((dir) => filesUnder(
|
|
182240
|
+
[".archive", "todo"].flatMap((dir) => filesUnder(path38.join(ws.board, dir), ws.board)).flatMap((p2) => {
|
|
182339
182241
|
const number4 = numberOfCard(p2);
|
|
182340
182242
|
return number4 ? [[number4, p2]] : [];
|
|
182341
182243
|
})
|
|
@@ -182343,8 +182245,8 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182343
182245
|
for (const item of tasks) {
|
|
182344
182246
|
processed.add(item.folder.task);
|
|
182345
182247
|
if (processed.size === 1 || processed.size % 25 === 0) logSync("board.progress", { project: ws.project, processed: processed.size, total: tasks.length });
|
|
182346
|
-
const card = cards?.get(item.folder.number) ??
|
|
182347
|
-
indexTask(item.folder, item.record,
|
|
182248
|
+
const card = cards?.get(item.folder.number) ?? path38.relative(ws.board, cardFile(item.folder)).split(path38.sep).join("/");
|
|
182249
|
+
indexTask(item.folder, item.record, path38.join(ws.board, card));
|
|
182348
182250
|
selected?.add(card);
|
|
182349
182251
|
const before = assetsOf(assetsListOf(item.folder, base));
|
|
182350
182252
|
const newer = Object.entries(before).some(([name, ref]) => {
|
|
@@ -182353,7 +182255,7 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182353
182255
|
});
|
|
182354
182256
|
const clean = () => Object.entries(item.record.assets).every(([name, entry]) => {
|
|
182355
182257
|
try {
|
|
182356
|
-
const file3 = assetPath(item.folder, name,
|
|
182258
|
+
const file3 = assetPath(item.folder, name, path38.join(ws.board, card));
|
|
182357
182259
|
return !file3 || hashFile(file3) === (entry.localHash ?? entry.hash);
|
|
182358
182260
|
} catch {
|
|
182359
182261
|
return false;
|
|
@@ -182361,7 +182263,7 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182361
182263
|
});
|
|
182362
182264
|
const archive = boardSync && card.startsWith(".archive/") && !item.record.deleted;
|
|
182363
182265
|
const listPath = assetsFile(item.folder.task);
|
|
182364
|
-
const archived = !selected && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(
|
|
182266
|
+
const archived = !selected && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(path38.join(ws.board, listPath)) === (base.files[rootOf(ws) + listPath]?.content ?? null) && readText(path38.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
|
|
182365
182267
|
if (!archived && !item.record.deleted) {
|
|
182366
182268
|
const refreshed = newer && clean() ? await pullAssets(item.folder, item.record, before, true) : { ok: true, value: void 0 };
|
|
182367
182269
|
const assets = refreshed.ok ? await pushAssets(item.folder, item.record, before) : refreshed;
|
|
@@ -182370,11 +182272,11 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182370
182272
|
indexTask(item.folder, item.record);
|
|
182371
182273
|
if (archive) archives.set(item.folder.task, card);
|
|
182372
182274
|
const list3 = listPath;
|
|
182373
|
-
const local2 = readText(
|
|
182275
|
+
const local2 = readText(path38.join(ws.board, list3));
|
|
182374
182276
|
if (assets.value && (local2 !== null || Object.keys(assets.value).length)) {
|
|
182375
182277
|
const content = isDeepStrictEqual(assetsOf(local2), assets.value) && local2 !== null ? local2 : assetsText(assets.value);
|
|
182376
182278
|
assetLists.set(list3, { local: local2, content });
|
|
182377
|
-
for (const file3 of assetFiles(item.folder, content,
|
|
182279
|
+
for (const file3 of assetFiles(item.folder, content, path38.join(ws.board, card))) generatedAssets.add(file3);
|
|
182378
182280
|
}
|
|
182379
182281
|
selected?.add(list3);
|
|
182380
182282
|
continue;
|
|
@@ -182391,10 +182293,10 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182391
182293
|
}
|
|
182392
182294
|
if (!ws.cloudTask) syncIndex(ws).ready = true;
|
|
182393
182295
|
const scoped = selected && [...new Set([...selected].flatMap((p2) => {
|
|
182394
|
-
if (!isBoardPath(p2) && !
|
|
182395
|
-
const file3 =
|
|
182396
|
-
return
|
|
182397
|
-
}))].filter((p2) =>
|
|
182296
|
+
if (!isBoardPath(p2) && !fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
|
|
182297
|
+
const file3 = path38.join(ws.board, p2);
|
|
182298
|
+
return fs32.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
|
|
182299
|
+
}))].filter((p2) => fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
|
|
182398
182300
|
for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
|
|
182399
182301
|
proposeItems(ws, base, scoped);
|
|
182400
182302
|
const shared = sharedMemory(ws.board);
|
|
@@ -182426,14 +182328,9 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182426
182328
|
if (changed || refreshDeferred || refreshPending || refreshPreviews) writeBase(ws, base);
|
|
182427
182329
|
if (boardSync) {
|
|
182428
182330
|
for (const task of processed) {
|
|
182429
|
-
|
|
182430
|
-
if (card && !heldPreviews.has(card) && (discoverArchives || selected || pendingArchives.has(task) || changedArchives.has(card) || changedArchives.has(assetsFile(task)))) {
|
|
182431
|
-
pendingArchives.set(task, card);
|
|
182432
|
-
} else if (!assetErrors[task] && !heldPreviews.has(card ?? pendingArchives.get(task) ?? "")) {
|
|
182433
|
-
pendingArchives.delete(task);
|
|
182434
|
-
}
|
|
182331
|
+
if (!archives.has(task) && !assetErrors[task]) pendingArchives.delete(task);
|
|
182435
182332
|
}
|
|
182436
|
-
await reconcileArchives(ws, base,
|
|
182333
|
+
await reconcileArchives(ws, base, archives, pendingArchives, job.machineId);
|
|
182437
182334
|
syncIndex(ws).archivesReady = true;
|
|
182438
182335
|
}
|
|
182439
182336
|
const reported = !ws.number ? previews : previews.filter((p2) => numberOfCard(p2.file) === ws.number);
|
|
@@ -182449,20 +182346,19 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182449
182346
|
const localOf = /* @__PURE__ */ new Map();
|
|
182450
182347
|
const localBefore = /* @__PURE__ */ new Map();
|
|
182451
182348
|
const changes = [];
|
|
182452
|
-
const changedArchives = /* @__PURE__ */ new Set();
|
|
182453
182349
|
const owed = (p2) => !job.id && busy(ws.cwd) && itemAt(p2)?.state === "open" && !base.files[rootOf(ws) + p2];
|
|
182454
182350
|
for (const p2 of local) {
|
|
182455
182351
|
if (defer(p2) || owed(p2) || generatedAssets.has(p2)) continue;
|
|
182456
182352
|
if (selected && tasks.some((item) => assetFiles(item.folder, assetsListOf(item.folder, base)).has(p2))) continue;
|
|
182457
182353
|
const list3 = assetLists.get(p2);
|
|
182458
|
-
const original = list3?.content ??
|
|
182354
|
+
const original = list3?.content ?? fs32.readFileSync(path38.join(ws.board, p2), "utf8");
|
|
182459
182355
|
const remote2 = remoteOf(ws, shared, p2);
|
|
182460
182356
|
const held5 = base.files[remote2];
|
|
182461
182357
|
const content = migratedArchive(p2, original, held5?.content);
|
|
182462
|
-
if (content !== original && readText(
|
|
182463
|
-
const backup =
|
|
182358
|
+
if (content !== original && readText(path38.join(ws.board, p2)) === original) {
|
|
182359
|
+
const backup = path38.join(ws.board, ".sync", "legacy-previews", hashOf2(Buffer.from(original)), p2);
|
|
182464
182360
|
write(backup, original);
|
|
182465
|
-
write(
|
|
182361
|
+
write(path38.join(ws.board, p2), content);
|
|
182466
182362
|
}
|
|
182467
182363
|
localOf.set(remote2, p2);
|
|
182468
182364
|
localBefore.set(remote2, list3 ? list3.local : content);
|
|
@@ -182480,7 +182376,7 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182480
182376
|
}
|
|
182481
182377
|
const previous = selected ? new Set([...selected].flatMap((p2) => {
|
|
182482
182378
|
if (base.files[remoteOf(ws, shared, p2)]) return [p2];
|
|
182483
|
-
if (!syncIndex(ws)?.directories.has(p2) && !
|
|
182379
|
+
if (!syncIndex(ws)?.directories.has(p2) && !fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
|
|
182484
182380
|
return [...viewOf(ws, base, shared).keys()].filter((file3) => file3.startsWith(p2 + "/"));
|
|
182485
182381
|
})) : viewOf(ws, base, shared).keys();
|
|
182486
182382
|
for (const p2 of previous) {
|
|
@@ -182561,7 +182457,7 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182561
182457
|
return conflictFailure(ws);
|
|
182562
182458
|
}
|
|
182563
182459
|
for (const [i, f2] of facts.entries()) changes[i] = { path: f2.remotePath, content: f2.automatic.content, base_seq: f2.remote.seq };
|
|
182564
|
-
if (facts.some((f2) => readText(
|
|
182460
|
+
if (facts.some((f2) => readText(path38.join(ws.board, f2.path)) !== f2.local.content)) return fail("Local files changed during synchronization. Try again.", false, "local_changed");
|
|
182565
182461
|
sent = await commit();
|
|
182566
182462
|
if (sent === null) return success2(false);
|
|
182567
182463
|
if (!sent.ok && sent.files) {
|
|
@@ -182591,58 +182487,61 @@ async function send2(ws, job, { paths, taskChat }) {
|
|
|
182591
182487
|
delete base.deleted[c2.path];
|
|
182592
182488
|
}
|
|
182593
182489
|
const p2 = localOf.get(c2.path);
|
|
182594
|
-
if (p2 &&
|
|
182595
|
-
|
|
182596
|
-
|
|
182597
|
-
else write(path39.join(ws.board, p2), c2.content);
|
|
182490
|
+
if (p2 && readText(path38.join(ws.board, p2)) === localBefore.get(c2.path)) {
|
|
182491
|
+
if (c2.content === null) fs32.rmSync(path38.join(ws.board, p2), { force: true });
|
|
182492
|
+
else write(path38.join(ws.board, p2), c2.content);
|
|
182598
182493
|
}
|
|
182599
182494
|
}
|
|
182600
182495
|
return success2(true);
|
|
182601
182496
|
}
|
|
182602
|
-
async function reconcileArchives(ws, base,
|
|
182497
|
+
async function reconcileArchives(ws, base, archives, pending, machine) {
|
|
182603
182498
|
const root2 = rootOf(ws);
|
|
182499
|
+
const reconciled = base.reconciledArchives ?? {};
|
|
182500
|
+
for (const [task, p2] of archives) {
|
|
182501
|
+
const version2 = reconciled[task];
|
|
182502
|
+
if (version2?.path === p2 && version2.seq === base.files[root2 + p2]?.seq && version2.assets_seq === (base.files[root2 + assetsFile(task)]?.seq ?? 0) && !pending.has(task)) continue;
|
|
182503
|
+
pending.set(task, p2);
|
|
182504
|
+
}
|
|
182604
182505
|
const cards = [];
|
|
182605
|
-
const
|
|
182506
|
+
const held5 = new Set(base.pendingPreviews);
|
|
182507
|
+
const pendingAssets = new Set(base.pendingAssets);
|
|
182606
182508
|
for (const [task, p2] of pending) {
|
|
182607
182509
|
const list3 = assetsFile(task);
|
|
182608
|
-
if (held5.has(p2) || held5.has(list3) ||
|
|
182510
|
+
if (held5.has(p2) || held5.has(list3) || pendingAssets.has(task)) continue;
|
|
182609
182511
|
const archive = base.files[root2 + p2];
|
|
182610
|
-
const local = readText(
|
|
182611
|
-
const meta3 = local === null ? null :
|
|
182612
|
-
if (!meta3
|
|
182512
|
+
const local = readText(path38.join(ws.board, p2));
|
|
182513
|
+
const meta3 = local === null ? null : archiveMeta(local);
|
|
182514
|
+
if (!meta3) {
|
|
182613
182515
|
pending.delete(task);
|
|
182614
182516
|
continue;
|
|
182615
182517
|
}
|
|
182616
182518
|
const manifest = base.files[root2 + list3];
|
|
182617
|
-
if (!archive || archive.content !== local || readText(
|
|
182519
|
+
if (!archive || archive.content !== local || readText(path38.join(ws.board, list3)) !== (manifest?.content ?? null)) continue;
|
|
182618
182520
|
cards.push({ task, path: p2, seq: archive.seq, assets_seq: manifest?.seq ?? 0 });
|
|
182619
|
-
if (!meta3.studio || meta3.studio === "coding") content.set(task, archive.content);
|
|
182620
182521
|
}
|
|
182621
|
-
const save3 = () => {
|
|
182522
|
+
const save3 = (changed) => {
|
|
182622
182523
|
const next = Object.fromEntries(pending);
|
|
182623
|
-
if (isDeepStrictEqual(next, base.pendingArchives ?? {})) return;
|
|
182524
|
+
if (!changed && isDeepStrictEqual(next, base.pendingArchives ?? {})) return;
|
|
182624
182525
|
base.pendingArchives = next;
|
|
182625
182526
|
writeBase(ws, base);
|
|
182626
182527
|
};
|
|
182627
|
-
save3();
|
|
182628
|
-
const receipts = archivedDeliveries(ws.board, new Set(cards.filter((c2) => content.has(c2.task)).map((c2) => numberOfCard(c2.path))), machine);
|
|
182528
|
+
save3(false);
|
|
182629
182529
|
for (let i = 0; i < cards.length; i += ARCHIVE_COMPLETION_BATCH) {
|
|
182630
182530
|
const batch2 = cards.slice(i, i + ARCHIVE_COMPLETION_BATCH);
|
|
182631
|
-
for (const card of batch2) {
|
|
182632
|
-
const body = content.get(card.task);
|
|
182633
|
-
if (!body) continue;
|
|
182634
|
-
const delivery = archiveReceipt(receipts.get(numberOfCard(card.path)), card.path, body, ws.cwd);
|
|
182635
|
-
if (delivery) card.delivery = delivery;
|
|
182636
|
-
}
|
|
182637
182531
|
const result = await completeArchives(ws.project, machine, batch2);
|
|
182638
182532
|
if (!result.ok) {
|
|
182639
182533
|
logSync("board.archive_completion", { project: ws.project, code: result.code, pending: pending.size });
|
|
182640
182534
|
break;
|
|
182641
182535
|
}
|
|
182642
|
-
if (!Array.isArray(result.value
|
|
182536
|
+
if (!Array.isArray(result.value?.retry)) break;
|
|
182643
182537
|
const retry2 = new Set(result.value.retry);
|
|
182644
|
-
for (const
|
|
182645
|
-
|
|
182538
|
+
for (const { task, path: path54, seq, assets_seq } of batch2) {
|
|
182539
|
+
if (retry2.has(task)) continue;
|
|
182540
|
+
reconciled[task] = { path: path54, seq, assets_seq };
|
|
182541
|
+
pending.delete(task);
|
|
182542
|
+
}
|
|
182543
|
+
base.reconciledArchives = reconciled;
|
|
182544
|
+
save3(false);
|
|
182646
182545
|
}
|
|
182647
182546
|
}
|
|
182648
182547
|
function taskStudioContext(ws, docs = true) {
|
|
@@ -182652,7 +182551,7 @@ function taskStudioContext(ws, docs = true) {
|
|
|
182652
182551
|
const read5 = parseStudioFile(studioName(held5.id), held5.files["STUDIO.md"] ?? "", "STUDIO.md");
|
|
182653
182552
|
if ("problem" in read5) throw new Error(read5.problem);
|
|
182654
182553
|
const def = read5.def;
|
|
182655
|
-
const notes = readText(
|
|
182554
|
+
const notes = readText(path38.join(ws.board, studioRuleFile(held5.id)))?.trim();
|
|
182656
182555
|
return [
|
|
182657
182556
|
"<studio>",
|
|
182658
182557
|
def.rules,
|
|
@@ -182671,8 +182570,8 @@ ${notes}
|
|
|
182671
182570
|
}
|
|
182672
182571
|
|
|
182673
182572
|
// src/saved-previews.ts
|
|
182674
|
-
import
|
|
182675
|
-
import
|
|
182573
|
+
import fs33 from "node:fs";
|
|
182574
|
+
import path39 from "node:path";
|
|
182676
182575
|
|
|
182677
182576
|
// src/sync-retry.ts
|
|
182678
182577
|
var SYNC_RETRY_MAX_MS = 5 * 6e4;
|
|
@@ -182735,10 +182634,10 @@ async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 =
|
|
|
182735
182634
|
const version2 = asset2.version;
|
|
182736
182635
|
const bytes2 = await readAsset(asset2.artifact, version2);
|
|
182737
182636
|
if (!bytes2.ok) return { ...bytes2, error: `${source2} (saved version ${version2}): ${bytes2.error}` };
|
|
182738
|
-
const extension =
|
|
182637
|
+
const extension = path39.posix.extname(source2).toLowerCase();
|
|
182739
182638
|
const suffix = extension === ".tsx" && /^\s*(?:<!doctype html|<html)\b/i.test(Buffer.from(bytes2.value.subarray(0, 256)).toString()) ? ".html" : /^\.[a-z0-9]+$/.test(extension) ? extension : "";
|
|
182740
|
-
const file3 =
|
|
182741
|
-
|
|
182639
|
+
const file3 = path39.join(directory3, `${files.size + 1}-${asset2.artifact}-${version2}${suffix}`);
|
|
182640
|
+
fs33.writeFileSync(file3, bytes2.value);
|
|
182742
182641
|
savedFile = { artifact: asset2.artifact, version: version2, file: file3 };
|
|
182743
182642
|
files.set(source2, savedFile);
|
|
182744
182643
|
}
|
|
@@ -182748,14 +182647,14 @@ async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 =
|
|
|
182748
182647
|
|
|
182749
182648
|
${section.body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : ""}`);
|
|
182750
182649
|
}
|
|
182751
|
-
const manifest =
|
|
182752
|
-
|
|
182650
|
+
const manifest = path39.join(directory3, "previews.md");
|
|
182651
|
+
fs33.writeFileSync(manifest, sections.join("\n\n") + "\n");
|
|
182753
182652
|
return { ok: true, value: manifest };
|
|
182754
182653
|
}
|
|
182755
182654
|
|
|
182756
182655
|
// src/triage.ts
|
|
182757
|
-
import
|
|
182758
|
-
import
|
|
182656
|
+
import fs34 from "node:fs";
|
|
182657
|
+
import path40 from "node:path";
|
|
182759
182658
|
|
|
182760
182659
|
// ../cli/src/lib/signals/identity.ts
|
|
182761
182660
|
import { createHash as createHash5 } from "node:crypto";
|
|
@@ -182763,8 +182662,8 @@ var DERIVED = "derived-";
|
|
|
182763
182662
|
var derivedSourceId = (seed) => `${DERIVED}${createHash5("sha256").update(seed).digest("hex").slice(0, 16)}`;
|
|
182764
182663
|
|
|
182765
182664
|
// src/triage.ts
|
|
182766
|
-
var triageDir = (board) =>
|
|
182767
|
-
var rejectedDir = (board) =>
|
|
182665
|
+
var triageDir = (board) => path40.join(board, "triage");
|
|
182666
|
+
var rejectedDir = (board) => path40.join(board, ".archive", REJECTIONS_TO_REVIEW);
|
|
182768
182667
|
var stamp2 = (at2) => formatStamp(at2 ? new Date(at2) : /* @__PURE__ */ new Date());
|
|
182769
182668
|
function slugOf(title) {
|
|
182770
182669
|
return title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "") || "item";
|
|
@@ -182772,7 +182671,7 @@ function slugOf(title) {
|
|
|
182772
182671
|
function freeName(dir, title) {
|
|
182773
182672
|
const stem = slugOf(title);
|
|
182774
182673
|
let name = `${stem}.md`;
|
|
182775
|
-
for (let n = 2;
|
|
182674
|
+
for (let n = 2; fs34.existsSync(path40.join(dir, name)); n++) name = `${stem}-${n}.md`;
|
|
182776
182675
|
return name;
|
|
182777
182676
|
}
|
|
182778
182677
|
function itemText(item, fields2 = {}) {
|
|
@@ -182792,16 +182691,16 @@ ${item.text.trim()}
|
|
|
182792
182691
|
`;
|
|
182793
182692
|
}
|
|
182794
182693
|
function writeItem(dir, item, fields2 = {}) {
|
|
182795
|
-
|
|
182694
|
+
fs34.mkdirSync(dir, { recursive: true });
|
|
182796
182695
|
const name = freeName(dir, item.title);
|
|
182797
|
-
|
|
182696
|
+
fs34.writeFileSync(path40.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields2 } : fields2));
|
|
182798
182697
|
return name;
|
|
182799
182698
|
}
|
|
182800
182699
|
function layOut(board, rejections) {
|
|
182801
182700
|
const dir = rejectedDir(board);
|
|
182802
|
-
|
|
182701
|
+
fs34.mkdirSync(dir, { recursive: true });
|
|
182803
182702
|
for (const t of rejections.tasks) {
|
|
182804
|
-
|
|
182703
|
+
fs34.writeFileSync(path40.join(dir, `${t.number}-${slugify2(t.title)}.md`), [
|
|
182805
182704
|
"---",
|
|
182806
182705
|
`title: ${yamlScalar(t.title)}`,
|
|
182807
182706
|
"status: todo",
|
|
@@ -182816,7 +182715,7 @@ function layOut(board, rejections) {
|
|
|
182816
182715
|
].join("\n"));
|
|
182817
182716
|
}
|
|
182818
182717
|
for (const item of rejections.triage) {
|
|
182819
|
-
const sub =
|
|
182718
|
+
const sub = path40.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
|
|
182820
182719
|
const fields2 = item.state === "dismissed" ? { dismissed_at: stamp2(item.dismissed_at), dismissed_by: "user", ...item.dismissed_reason ? { dismissed_reason: item.dismissed_reason } : {} } : {};
|
|
182821
182720
|
writeItem(sub, item, fields2);
|
|
182822
182721
|
}
|
|
@@ -182825,12 +182724,12 @@ function layOut(board, rejections) {
|
|
|
182825
182724
|
|
|
182826
182725
|
// ../cli/src/lib/skill/hook.ts
|
|
182827
182726
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
182828
|
-
import
|
|
182829
|
-
import
|
|
182727
|
+
import fs35 from "node:fs";
|
|
182728
|
+
import path41 from "node:path";
|
|
182830
182729
|
var MARKER_LINE = /^# ai4kanban commit guard\b/m;
|
|
182831
182730
|
var read3 = (file3) => {
|
|
182832
182731
|
try {
|
|
182833
|
-
return
|
|
182732
|
+
return fs35.readFileSync(file3, "utf8");
|
|
182834
182733
|
} catch {
|
|
182835
182734
|
return null;
|
|
182836
182735
|
}
|
|
@@ -182842,15 +182741,15 @@ function hooksDir(root2) {
|
|
|
182842
182741
|
windowsHide: true
|
|
182843
182742
|
});
|
|
182844
182743
|
if (out.error || out.status !== 0 || !out.stdout.trim()) return null;
|
|
182845
|
-
return
|
|
182744
|
+
return path41.resolve(root2, out.stdout.trim());
|
|
182846
182745
|
}
|
|
182847
182746
|
function installCommitHook(root2, _board) {
|
|
182848
182747
|
const dir = hooksDir(root2);
|
|
182849
182748
|
if (!dir) return {};
|
|
182850
|
-
const file3 =
|
|
182851
|
-
if (
|
|
182749
|
+
const file3 = path41.join(dir, "pre-commit");
|
|
182750
|
+
if (fs35.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
|
|
182852
182751
|
const source2 = read3(file3);
|
|
182853
|
-
if (source2 && MARKER_LINE.test(source2))
|
|
182752
|
+
if (source2 && MARKER_LINE.test(source2)) fs35.unlinkSync(file3);
|
|
182854
182753
|
return {};
|
|
182855
182754
|
}
|
|
182856
182755
|
|
|
@@ -182894,7 +182793,7 @@ function runtimeCosts(runs, job) {
|
|
|
182894
182793
|
}
|
|
182895
182794
|
function reviewOf2(file3, questionsOnly = false) {
|
|
182896
182795
|
try {
|
|
182897
|
-
const meta3 = parseFrontmatter(
|
|
182796
|
+
const meta3 = parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta;
|
|
182898
182797
|
return meta3 && (!questionsOnly || meta3.questions?.length) ? reviewOf(meta3) : null;
|
|
182899
182798
|
} catch {
|
|
182900
182799
|
return null;
|
|
@@ -182902,15 +182801,15 @@ function reviewOf2(file3, questionsOnly = false) {
|
|
|
182902
182801
|
}
|
|
182903
182802
|
function asks(file3) {
|
|
182904
182803
|
try {
|
|
182905
|
-
return (parseFrontmatter(
|
|
182804
|
+
return (parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
|
|
182906
182805
|
} catch {
|
|
182907
182806
|
return false;
|
|
182908
182807
|
}
|
|
182909
182808
|
}
|
|
182910
182809
|
function mcpConfig(servers, file3) {
|
|
182911
182810
|
if (!Object.keys(servers).length) return null;
|
|
182912
|
-
|
|
182913
|
-
|
|
182811
|
+
fs36.mkdirSync(path42.dirname(file3), { recursive: true });
|
|
182812
|
+
fs36.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
|
|
182914
182813
|
`);
|
|
182915
182814
|
return file3;
|
|
182916
182815
|
}
|
|
@@ -182941,16 +182840,16 @@ async function stopRuns(akb, ws, id2, since, ms) {
|
|
|
182941
182840
|
var working = /* @__PURE__ */ new Map();
|
|
182942
182841
|
var workKey = (ws, id2) => `${ws.board}#${id2}`;
|
|
182943
182842
|
function checkoutsOf(ws, id2) {
|
|
182944
|
-
const dir =
|
|
182843
|
+
const dir = path42.join(ws.board, "deliveries");
|
|
182945
182844
|
let names2;
|
|
182946
182845
|
try {
|
|
182947
|
-
names2 =
|
|
182846
|
+
names2 = fs36.readdirSync(dir).filter((n) => n.endsWith(".json"));
|
|
182948
182847
|
} catch {
|
|
182949
182848
|
return [];
|
|
182950
182849
|
}
|
|
182951
182850
|
return names2.flatMap((n) => {
|
|
182952
182851
|
try {
|
|
182953
|
-
const held5 = JSON.parse(
|
|
182852
|
+
const held5 = JSON.parse(fs36.readFileSync(path42.join(dir, n), "utf8"));
|
|
182954
182853
|
return held5.cardId === id2 && held5.deliveryId ? [held5.deliveryId] : [];
|
|
182955
182854
|
} catch {
|
|
182956
182855
|
return [];
|
|
@@ -182964,7 +182863,7 @@ var RESUME_REFUSED = {
|
|
|
182964
182863
|
deliveryRunGoing: "\u4E0A\u6B21\u7684\u8FD0\u884C\u8FD8\u6CA1\u505C\u4E0B\uFF0C\u8BF7\u7A0D\u540E\u518D\u70B9\u300C\u7EED\u8DD1\u300D\u3002",
|
|
182965
182864
|
deliveryCardGone: "\u8FD9\u5F20\u5361\u5DF2\u4E0D\u5728\u770B\u677F\u4E0A\uFF0C\u6CA1\u6709\u53EF\u7EED\u8DD1\u7684\u5185\u5BB9\uFF0C\u8BF7\u70B9\u300C\u91CD\u65B0\u53D1\u8D77\u300D\u3002"
|
|
182966
182865
|
};
|
|
182967
|
-
var isArchived = (ws, id2) =>
|
|
182866
|
+
var isArchived = (ws, id2) => path42.relative(ws.board, findCard(ws.board, id2) ?? ws.board).split(path42.sep)[0] === ".archive";
|
|
182968
182867
|
var refusal2 = (ran) => ran.last.replace(/^akb( raw)?: /, "").slice(0, 300) || "akb stopped with an error.";
|
|
182969
182868
|
var reasonOf = (text3) => (text3 ?? "").split("\n").map((l2) => l2.trim()).filter((l2) => l2 && !/^at\s/.test(l2)).join("\n").slice(0, 300) || void 0;
|
|
182970
182869
|
function logLines(show, event2) {
|
|
@@ -183026,7 +182925,7 @@ async function setUp(job, ws, deps, io) {
|
|
|
183026
182925
|
const runtime = job.runtime;
|
|
183027
182926
|
const missing = io.flowRun?.finished ? void 0 : unavailable(runtime, await deps.runtimes());
|
|
183028
182927
|
if (missing) return missing;
|
|
183029
|
-
if (!
|
|
182928
|
+
if (!fs36.existsSync(path42.join(ws.board, "config.md"))) {
|
|
183030
182929
|
const init = await akb(["raw", "init"]);
|
|
183031
182930
|
if (init.code !== 0) return refusal2(init);
|
|
183032
182931
|
}
|
|
@@ -183043,7 +182942,7 @@ async function setUp(job, ws, deps, io) {
|
|
|
183043
182942
|
const used = await akb(["raw", "agent", "use", runtime]);
|
|
183044
182943
|
if (used.code !== 0) return refusal2(used);
|
|
183045
182944
|
const servers = mcpServersOf(ws);
|
|
183046
|
-
const mcpFile =
|
|
182945
|
+
const mcpFile = path42.join(ws.board, ".sync", `${ws.task}.mcp.json`);
|
|
183047
182946
|
const takes = new Set(settingKeys(runtime));
|
|
183048
182947
|
const given = job.settings ?? {};
|
|
183049
182948
|
const values = valuesOf(runtime, job.model, given, servers, mcpFile);
|
|
@@ -183123,9 +183022,9 @@ async function reviewRejections(job, ws, deps, io, refreshReview) {
|
|
|
183123
183022
|
if (!read5.value.tasks.length && !read5.value.triage.length || stopping(io)) return { runs: [] };
|
|
183124
183023
|
const since = Date.now();
|
|
183125
183024
|
const akb = boardAkb(job, ws, deps, io);
|
|
183126
|
-
const directory3 =
|
|
183127
|
-
|
|
183128
|
-
const scratch =
|
|
183025
|
+
const directory3 = path42.join(ws.board, ".sync");
|
|
183026
|
+
fs36.mkdirSync(directory3, { recursive: true });
|
|
183027
|
+
const scratch = fs36.mkdtempSync(path42.join(directory3, "rejection-review-"));
|
|
183129
183028
|
try {
|
|
183130
183029
|
const laid = layOut(scratch, read5.value);
|
|
183131
183030
|
const denied = await refreshReview?.();
|
|
@@ -183136,7 +183035,7 @@ async function reviewRejections(job, ws, deps, io, refreshReview) {
|
|
|
183136
183035
|
if (ran.code !== 0) return { runs, failure: refusal2(ran) };
|
|
183137
183036
|
return { runs, laid, session: answerOf2(ran)?.agentSession };
|
|
183138
183037
|
} finally {
|
|
183139
|
-
|
|
183038
|
+
fs36.rmSync(scratch, { recursive: true, force: true });
|
|
183140
183039
|
}
|
|
183141
183040
|
}
|
|
183142
183041
|
async function learnRejections(job, ws, deps, io, refreshReview) {
|
|
@@ -183186,19 +183085,19 @@ async function runAgent(job, ws, deps, io) {
|
|
|
183186
183085
|
}
|
|
183187
183086
|
function writeTranscript(job, dir) {
|
|
183188
183087
|
if (!job.transcript) return "";
|
|
183189
|
-
const file3 =
|
|
183190
|
-
|
|
183191
|
-
|
|
183088
|
+
const file3 = path42.join(dir, "discussion.md");
|
|
183089
|
+
fs36.mkdirSync(dir, { recursive: true });
|
|
183090
|
+
fs36.writeFileSync(file3, `${job.transcript}
|
|
183192
183091
|
`);
|
|
183193
183092
|
return file3;
|
|
183194
183093
|
}
|
|
183195
183094
|
function pictures(job, ws, id2) {
|
|
183196
183095
|
const dir = cardAssetsDir(ws, id2);
|
|
183197
183096
|
if (!job.attachments.length || !dir) return "";
|
|
183198
|
-
|
|
183097
|
+
fs36.mkdirSync(dir, { recursive: true });
|
|
183199
183098
|
return job.attachments.map((a2, i) => {
|
|
183200
|
-
const file3 = `${i + 1}-${
|
|
183201
|
-
|
|
183099
|
+
const file3 = `${i + 1}-${path42.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
|
|
183100
|
+
fs36.writeFileSync(path42.join(dir, file3), Buffer.from(a2.content, "base64"));
|
|
183202
183101
|
return `
|
|
183203
183102
|
<Asset src=".assets/${id2}/${file3}" label="${a2.name.replace(/["<>]/g, "") || file3}" />
|
|
183204
183103
|
`;
|
|
@@ -183206,7 +183105,7 @@ function pictures(job, ws, id2) {
|
|
|
183206
183105
|
}
|
|
183207
183106
|
function cardFlags(ws, fields2) {
|
|
183208
183107
|
if (!fields2) return [];
|
|
183209
|
-
const open2 = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(
|
|
183108
|
+
const open2 = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(path42.join(ws.board, "todo") + path42.sep));
|
|
183210
183109
|
const lists = [["--modules", fields2.modules ?? []], ["--related", open2(fields2.related)], ["--blocked-by", open2(fields2.blocked_by)]];
|
|
183211
183110
|
return [
|
|
183212
183111
|
...fields2.priority ? ["--priority", fields2.priority] : [],
|
|
@@ -183260,7 +183159,7 @@ async function runFlow(job, ws, deps, io) {
|
|
|
183260
183159
|
const startsDelivery = ["delivery resume", "run resume", "card implement"].includes(args2.slice(1, 3).join(" "));
|
|
183261
183160
|
if (review && task?.preview_inputs && verb === "implement" && startsDelivery) {
|
|
183262
183161
|
const inputs = task.preview_inputs;
|
|
183263
|
-
previewDirectory ??=
|
|
183162
|
+
previewDirectory ??= fs36.mkdtempSync(path42.join(os6.tmpdir(), "wildcrane-saved-previews-"));
|
|
183264
183163
|
const directory3 = previewDirectory;
|
|
183265
183164
|
const staged = await attemptSync(io, "review", () => stageSavedPreviews(
|
|
183266
183165
|
directory3,
|
|
@@ -183279,16 +183178,16 @@ async function runFlow(job, ws, deps, io) {
|
|
|
183279
183178
|
} else if (review && verb === "implement" && startsDelivery && studioName(ws.studio ?? flow.studio ?? "") === "coding") {
|
|
183280
183179
|
const files = approvedUiPreviews(review);
|
|
183281
183180
|
if (files.length) {
|
|
183282
|
-
previewDirectory ??=
|
|
183181
|
+
previewDirectory ??= fs36.mkdtempSync(path42.join(os6.tmpdir(), "wildcrane-approved-ui-"));
|
|
183283
183182
|
const directory3 = previewDirectory;
|
|
183284
183183
|
const staged = await attemptSync(io, "review", async () => {
|
|
183285
183184
|
for (const file3 of files) {
|
|
183286
183185
|
if (stopping(io)) return syncStopped;
|
|
183287
183186
|
const target = approvedUiFile(directory3, file3);
|
|
183288
|
-
if (
|
|
183187
|
+
if (fs36.existsSync(target)) continue;
|
|
183289
183188
|
const fetched = await readAsset(file3.artifact, file3.version);
|
|
183290
183189
|
if (!fetched.ok) return { ...fetched, error: `${file3.src} (approved revision ${file3.revision}): ${fetched.error}` };
|
|
183291
|
-
|
|
183190
|
+
fs36.writeFileSync(target, fetched.value);
|
|
183292
183191
|
}
|
|
183293
183192
|
return { ok: true, value: void 0 };
|
|
183294
183193
|
});
|
|
@@ -183314,13 +183213,13 @@ async function runFlow(job, ws, deps, io) {
|
|
|
183314
183213
|
said = { title: task.value.title?.trim() ?? "", request: task.value.request?.trim() ?? "" };
|
|
183315
183214
|
}
|
|
183316
183215
|
const title = said.title || "Untitled";
|
|
183317
|
-
const body =
|
|
183318
|
-
|
|
183216
|
+
const body = path42.join(ws.board, ".sync", `${ws.task}.request.md`);
|
|
183217
|
+
fs36.mkdirSync(path42.dirname(body), { recursive: true });
|
|
183319
183218
|
if (!ws.number) return fail("This task has no number yet.");
|
|
183320
183219
|
const created = await withBoard(ws, async () => {
|
|
183321
183220
|
const existing = akbCardOf(ws);
|
|
183322
183221
|
if (existing) return { ok: true, value: existing };
|
|
183323
|
-
|
|
183222
|
+
fs36.writeFileSync(body, `${said.request || title}
|
|
183324
183223
|
${pictures(job, ws, ws.number)}`);
|
|
183325
183224
|
return akb([
|
|
183326
183225
|
"raw",
|
|
@@ -183335,7 +183234,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183335
183234
|
String(ws.number),
|
|
183336
183235
|
...cardFlags(ws, flow.metadata),
|
|
183337
183236
|
"--json"
|
|
183338
|
-
]).then(made).finally(() =>
|
|
183237
|
+
]).then(made).finally(() => fs36.rmSync(body, { force: true }));
|
|
183339
183238
|
}, () => stopping(io));
|
|
183340
183239
|
if (!created || stopping(io)) return fail("");
|
|
183341
183240
|
if (!created.ok) return fail(created.error);
|
|
@@ -183348,9 +183247,9 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183348
183247
|
const result = await send3(claim2);
|
|
183349
183248
|
if (result.ok) return { ok: true, value: void 0 };
|
|
183350
183249
|
if (result.conflict && pendingConflicts(ws.board).length) {
|
|
183351
|
-
const
|
|
183352
|
-
if (
|
|
183353
|
-
return { ok: true, value:
|
|
183250
|
+
const ended = await onCard(card);
|
|
183251
|
+
if (ended.ok && !stopping(io) && !pendingConflicts(ws.board).length) await send3(claim2);
|
|
183252
|
+
return { ok: true, value: ended };
|
|
183354
183253
|
}
|
|
183355
183254
|
return { ok: false, error: result.error, code: result.offline ? void 0 : result.code ?? "refused", failure: result.failure };
|
|
183356
183255
|
}, () => stopping(io)) ?? syncStopped);
|
|
@@ -183427,12 +183326,12 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183427
183326
|
return fail("\u672A\u80FD\u505C\u6B62\u4E0A\u6B21\u8FD0\u884C\uFF0C\u8BF7\u7B49\u5F85\u5176\u505C\u6B62\u540E\u7EED\u8DD1\u3002");
|
|
183428
183327
|
}
|
|
183429
183328
|
if (io.lost()) return fail("");
|
|
183430
|
-
const
|
|
183431
|
-
if (
|
|
183432
|
-
return
|
|
183329
|
+
const ended = await workOn(card, reconciled);
|
|
183330
|
+
if (ended.ok && !coding && flow.verb === "create" && verb === "implement" && job.taskReview && reviewAuthorization(job.taskReview).kind === "unreviewed" && !ended.report.review) ended.report.deliveryCompleted = true;
|
|
183331
|
+
return ended;
|
|
183433
183332
|
} finally {
|
|
183434
|
-
if (previewDirectory)
|
|
183435
|
-
|
|
183333
|
+
if (previewDirectory) fs36.rmSync(previewDirectory, { recursive: true, force: true });
|
|
183334
|
+
fs36.rmSync(path42.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
|
|
183436
183335
|
const left = working.get(key) - 1;
|
|
183437
183336
|
if (left) working.set(key, left);
|
|
183438
183337
|
else working.delete(key);
|
|
@@ -183444,7 +183343,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183444
183343
|
});
|
|
183445
183344
|
const text3 = flow.verb === "create" ? "" : (flow.text ?? "").trim();
|
|
183446
183345
|
const archived = !io.flowRun && flow.resume && isArchived(ws, id3);
|
|
183447
|
-
if (archived && (!coding || parseFrontmatter(
|
|
183346
|
+
if (archived && (!coding || parseFrontmatter(fs36.readFileSync(cardFile(ws), "utf8")).meta?.rejected)) {
|
|
183448
183347
|
return { ok: true, report: { card: id3, ...coding ? { deliveryCompleted: false } : {} } };
|
|
183449
183348
|
}
|
|
183450
183349
|
if (!io.flowRun && flow.resume && verb === "refine" && !hasReview && (!reconciled || reconciled.kind === "none")) {
|
|
@@ -183452,7 +183351,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183452
183351
|
if (review2) return { ok: true, report: { card: id3, ...review2 === true ? {} : { review: review2 } } };
|
|
183453
183352
|
}
|
|
183454
183353
|
let note = verb === "resolve" || verb === "revise" ? text3 : "";
|
|
183455
|
-
|
|
183354
|
+
const isRejected = () => isArchived(ws, id3) && parseFrontmatter(fs36.readFileSync(cardFile(ws), "utf8")).meta?.rejected === true;
|
|
183456
183355
|
let ran;
|
|
183457
183356
|
let continuation;
|
|
183458
183357
|
let expectedDelivery;
|
|
@@ -183518,9 +183417,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183518
183417
|
const resolved = await launch2(["raw", "card", "resolve", String(id3), "--follow", "--events", "--json", "--", text3], true);
|
|
183519
183418
|
if (resolved.reviewRefused) return fail(resolved.reviewRefused);
|
|
183520
183419
|
if (io.lost()) return fail("");
|
|
183521
|
-
|
|
183522
|
-
rejected = !!file3 && path43.relative(ws.board, file3).split(path43.sep)[0] === ".archive" && parseFrontmatter(fs37.readFileSync(file3, "utf8")).meta?.rejected === true;
|
|
183523
|
-
if (rejected) ran = resolved;
|
|
183420
|
+
if (isRejected()) ran = resolved;
|
|
183524
183421
|
else if (resolved.code !== 0) note = text3;
|
|
183525
183422
|
else if (asks(cardFile(ws))) {
|
|
183526
183423
|
const review2 = reviewOf2(cardFile(ws), hasReview);
|
|
@@ -183545,6 +183442,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183545
183442
|
const runs = answerOf2(await akb(["raw", "run", "list", "--card", String(id3), "--all", "--json"]))?.runs ?? [];
|
|
183546
183443
|
const recent = runs.find((r2) => r2.sessionId === last) ?? runs.filter((r2) => !r2.parentId && r2.cloudExecution?.job === job.id).at(-1);
|
|
183547
183444
|
const spent = spentBy([...new Map([...learned, ...runsSpent(runs, since, job, io)].map((run3) => [run3.sessionId, run3])).values()], job);
|
|
183445
|
+
const rejected = isRejected();
|
|
183548
183446
|
if (effectiveVerb === "implement" && !rejected) {
|
|
183549
183447
|
const ending = delivery?.ending;
|
|
183550
183448
|
if (ending?.kind === "stopped") return { ok: false, reason: "", stopped: true };
|
|
@@ -183588,11 +183486,11 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
183588
183486
|
function carryArgs(verb2) {
|
|
183589
183487
|
if (flow.replan) return ["--new-session"];
|
|
183590
183488
|
if (verb2 === "implement" && flow.verb === "create") {
|
|
183591
|
-
const transcript2 = writeTranscript(job,
|
|
183489
|
+
const transcript2 = writeTranscript(job, path42.join(ws.board, ".sync", `${ws.task}.discussion`));
|
|
183592
183490
|
return transcript2 ? ["--transcript", transcript2] : [];
|
|
183593
183491
|
}
|
|
183594
183492
|
if (!["refine", "resolve", "revise"].includes(verb2)) return [];
|
|
183595
|
-
const transcript = writeTranscript(job,
|
|
183493
|
+
const transcript = writeTranscript(job, path42.join(ws.board, ".sync", `${ws.task}.discussion`));
|
|
183596
183494
|
return [
|
|
183597
183495
|
...job.resume ? ["--session", job.resume, ...job.fork ? ["--fork"] : []] : [],
|
|
183598
183496
|
...transcript ? ["--transcript", transcript] : []
|
|
@@ -183651,8 +183549,8 @@ async function flowRunEvidence(ws, job, deps, execution = job.id, prior) {
|
|
|
183651
183549
|
}
|
|
183652
183550
|
|
|
183653
183551
|
// src/recovery.ts
|
|
183654
|
-
import
|
|
183655
|
-
import
|
|
183552
|
+
import fs37 from "node:fs";
|
|
183553
|
+
import path43 from "node:path";
|
|
183656
183554
|
|
|
183657
183555
|
// ../cli/src/lib/agent/wire/codex-background-types.ts
|
|
183658
183556
|
function idleStopConfirmed(cleanup, session) {
|
|
@@ -183661,10 +183559,10 @@ function idleStopConfirmed(cleanup, session) {
|
|
|
183661
183559
|
|
|
183662
183560
|
// src/recovery.ts
|
|
183663
183561
|
var recoveryBlocked = (job) => cloudLanguage(job) === "zh" ? "\u65E0\u6CD5\u6838\u5BF9\u4E0A\u6B21\u6267\u884C\uFF0C\u5DF2\u6709\u6210\u679C\u5DF2\u4FDD\u7559\u3002" : "The previous execution could not be verified. Saved work was preserved.";
|
|
183664
|
-
var fileOf2 = (id2) =>
|
|
183562
|
+
var fileOf2 = (id2) => path43.join(runnerHome(), "checkpoints", `${encodeURIComponent(id2)}.json`);
|
|
183665
183563
|
function readCheckpoint(id2) {
|
|
183666
183564
|
try {
|
|
183667
|
-
const held5 = JSON.parse(
|
|
183565
|
+
const held5 = JSON.parse(fs37.readFileSync(fileOf2(id2), "utf8"));
|
|
183668
183566
|
if (!held5 || !Array.isArray(held5.pending) || !held5.pending.every((id3) => typeof id3 === "string")) throw new Error("\u8FDB\u5EA6\u683C\u5F0F\u9519\u8BEF");
|
|
183669
183567
|
if (held5.syncRetry && (!Number.isSafeInteger(held5.syncRetry.attempt) || held5.syncRetry.attempt < 1 || !Number.isFinite(held5.syncRetry.at))) {
|
|
183670
183568
|
delete held5.syncRetry;
|
|
@@ -183683,12 +183581,12 @@ function readCheckpoint(id2) {
|
|
|
183683
183581
|
}
|
|
183684
183582
|
function saveCheckpoint(id2, checkpoint) {
|
|
183685
183583
|
const file3 = fileOf2(id2);
|
|
183686
|
-
|
|
183687
|
-
|
|
183688
|
-
|
|
183584
|
+
fs37.mkdirSync(path43.dirname(file3), { recursive: true, mode: 448 });
|
|
183585
|
+
fs37.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
|
|
183586
|
+
fs37.renameSync(`${file3}.tmp`, file3);
|
|
183689
183587
|
}
|
|
183690
183588
|
function clearCheckpoint(id2) {
|
|
183691
|
-
|
|
183589
|
+
fs37.rmSync(fileOf2(id2), { force: true });
|
|
183692
183590
|
}
|
|
183693
183591
|
function checkpointEvent(checkpoint, event2) {
|
|
183694
183592
|
if (event2.kind === "phase" && event2.data.phase === "submitted" || event2.kind === "message" && event2.data.text.trim() || event2.kind === "tool_call" || event2.kind === "plan") {
|
|
@@ -183896,32 +183794,32 @@ function conversationProgress(attempt, send3, valid, unconfirmed) {
|
|
|
183896
183794
|
}
|
|
183897
183795
|
|
|
183898
183796
|
// src/settings-control.ts
|
|
183899
|
-
import
|
|
183900
|
-
import
|
|
183797
|
+
import fs38 from "node:fs";
|
|
183798
|
+
import path44 from "node:path";
|
|
183901
183799
|
|
|
183902
183800
|
// src/codex-native.ts
|
|
183903
183801
|
var import_undici2 = __toESM(require_undici(), 1);
|
|
183904
183802
|
|
|
183905
183803
|
// src/settings-control.ts
|
|
183906
|
-
var directory = () =>
|
|
183907
|
-
var epochFile = () =>
|
|
183804
|
+
var directory = () => path44.join(runnerHome(), "executors");
|
|
183805
|
+
var epochFile = () => path44.join(runnerHome(), "account-generation");
|
|
183908
183806
|
function accountGeneration() {
|
|
183909
183807
|
try {
|
|
183910
|
-
return
|
|
183808
|
+
return fs38.readFileSync(epochFile(), "utf8");
|
|
183911
183809
|
} catch {
|
|
183912
183810
|
return "";
|
|
183913
183811
|
}
|
|
183914
183812
|
}
|
|
183915
183813
|
function executorRecord() {
|
|
183916
|
-
|
|
183917
|
-
const file3 =
|
|
183918
|
-
|
|
183919
|
-
return () =>
|
|
183814
|
+
fs38.mkdirSync(directory(), { recursive: true, mode: 448 });
|
|
183815
|
+
const file3 = path44.join(directory(), `${process.pid}.json`);
|
|
183816
|
+
fs38.writeFileSync(file3, "{}", { mode: 384 });
|
|
183817
|
+
return () => fs38.rmSync(file3, { force: true });
|
|
183920
183818
|
}
|
|
183921
183819
|
|
|
183922
183820
|
// src/reply-images.ts
|
|
183923
|
-
import
|
|
183924
|
-
import
|
|
183821
|
+
import fs39 from "node:fs";
|
|
183822
|
+
import path45 from "node:path";
|
|
183925
183823
|
import os7 from "node:os";
|
|
183926
183824
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
183927
183825
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -183940,16 +183838,16 @@ function imageMime(bytes2) {
|
|
|
183940
183838
|
// src/reply-images.ts
|
|
183941
183839
|
init_file_limits();
|
|
183942
183840
|
var inside = (root2, file3) => {
|
|
183943
|
-
const p2 =
|
|
183944
|
-
return p2 !== ".." && !p2.startsWith(`..${
|
|
183841
|
+
const p2 = path45.relative(root2, file3);
|
|
183842
|
+
return p2 !== ".." && !p2.startsWith(`..${path45.sep}`) && !path45.isAbsolute(p2);
|
|
183945
183843
|
};
|
|
183946
183844
|
function collectReplyImages(parts, cwd) {
|
|
183947
183845
|
const files = /* @__PURE__ */ new Map();
|
|
183948
183846
|
const tools = [];
|
|
183949
183847
|
const output3 = [];
|
|
183950
|
-
const roots = [cwd,
|
|
183848
|
+
const roots = [cwd, path45.join(process.env.CODEX_HOME?.trim() || path45.join(os7.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
|
|
183951
183849
|
try {
|
|
183952
|
-
return [
|
|
183850
|
+
return [fs39.realpathSync(p2)];
|
|
183953
183851
|
} catch {
|
|
183954
183852
|
return [];
|
|
183955
183853
|
}
|
|
@@ -183957,17 +183855,17 @@ function collectReplyImages(parts, cwd) {
|
|
|
183957
183855
|
const registered = new Set(parts.flatMap((p2) => {
|
|
183958
183856
|
if (p2.type !== "image" || !p2.registered || !p2.path) return [];
|
|
183959
183857
|
try {
|
|
183960
|
-
const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) :
|
|
183961
|
-
if (!
|
|
183962
|
-
const real =
|
|
183963
|
-
const fd =
|
|
183858
|
+
const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path45.resolve(cwd, p2.path);
|
|
183859
|
+
if (!fs39.lstatSync(file3).isFile()) return [];
|
|
183860
|
+
const real = fs39.realpathSync(file3);
|
|
183861
|
+
const fd = fs39.openSync(real, fs39.constants.O_RDONLY | (fs39.constants.O_NOFOLLOW ?? 0));
|
|
183964
183862
|
try {
|
|
183965
|
-
const stat2 =
|
|
183863
|
+
const stat2 = fs39.fstatSync(fd);
|
|
183966
183864
|
if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) return [];
|
|
183967
|
-
const mime = imageMime(
|
|
183865
|
+
const mime = imageMime(fs39.readFileSync(fd));
|
|
183968
183866
|
return mime && (!p2.mime || p2.mime === mime) ? [real] : [];
|
|
183969
183867
|
} finally {
|
|
183970
|
-
|
|
183868
|
+
fs39.closeSync(fd);
|
|
183971
183869
|
}
|
|
183972
183870
|
} catch {
|
|
183973
183871
|
return [];
|
|
@@ -183983,16 +183881,16 @@ function collectReplyImages(parts, cwd) {
|
|
|
183983
183881
|
if (!p2.path) throw Error();
|
|
183984
183882
|
const source2 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : decodeURIComponent(p2.path);
|
|
183985
183883
|
if (/^[a-z][a-z0-9+.-]*:/i.test(source2) && !/^[A-Za-z]:[\\/]/.test(source2)) throw Error();
|
|
183986
|
-
const real =
|
|
183884
|
+
const real = fs39.realpathSync(path45.resolve(cwd, source2));
|
|
183987
183885
|
if (!/\.(png|jpe?g|gif|webp)$/i.test(source2) && !registered.has(real)) throw Error();
|
|
183988
183886
|
if (!roots.some((root2) => inside(root2, real)) && !registered.has(real)) throw Error();
|
|
183989
|
-
const fd =
|
|
183887
|
+
const fd = fs39.openSync(real, fs39.constants.O_RDONLY | (fs39.constants.O_NOFOLLOW ?? 0));
|
|
183990
183888
|
try {
|
|
183991
|
-
const stat2 =
|
|
183889
|
+
const stat2 = fs39.fstatSync(fd);
|
|
183992
183890
|
if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) throw Error();
|
|
183993
|
-
bytes2 =
|
|
183891
|
+
bytes2 = fs39.readFileSync(fd);
|
|
183994
183892
|
} finally {
|
|
183995
|
-
|
|
183893
|
+
fs39.closeSync(fd);
|
|
183996
183894
|
}
|
|
183997
183895
|
}
|
|
183998
183896
|
return bytes2;
|
|
@@ -184076,13 +183974,13 @@ async function saveReplyImages(parts, cwd, upload2) {
|
|
|
184076
183974
|
}
|
|
184077
183975
|
|
|
184078
183976
|
// src/handoff.ts
|
|
184079
|
-
import { execFileSync as
|
|
183977
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
184080
183978
|
import crypto5 from "node:crypto";
|
|
184081
|
-
import
|
|
184082
|
-
import
|
|
183979
|
+
import fs40 from "node:fs";
|
|
183980
|
+
import path46 from "node:path";
|
|
184083
183981
|
var gitRead = (cwd, args2) => {
|
|
184084
183982
|
try {
|
|
184085
|
-
return
|
|
183983
|
+
return execFileSync2("git", ["-C", cwd, ...args2], {
|
|
184086
183984
|
encoding: "utf8",
|
|
184087
183985
|
timeout: 15e3,
|
|
184088
183986
|
maxBuffer: 16 * 1024 * 1024,
|
|
@@ -184096,8 +183994,8 @@ var digest = (value) => crypto5.createHash("sha256").update(value).digest("hex")
|
|
|
184096
183994
|
function authorizedFolder(folder2) {
|
|
184097
183995
|
if (!folder2) return null;
|
|
184098
183996
|
try {
|
|
184099
|
-
const real =
|
|
184100
|
-
return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 +
|
|
183997
|
+
const real = fs40.realpathSync(folder2);
|
|
183998
|
+
return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path46.sep)) ? real : null;
|
|
184101
183999
|
} catch {
|
|
184102
184000
|
return null;
|
|
184103
184001
|
}
|
|
@@ -184107,9 +184005,9 @@ function progressFolder(job, folder2) {
|
|
|
184107
184005
|
if (!token) return folder2;
|
|
184108
184006
|
if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) return null;
|
|
184109
184007
|
try {
|
|
184110
|
-
const dir =
|
|
184111
|
-
if (!dir.startsWith(
|
|
184112
|
-
const marker = JSON.parse(
|
|
184008
|
+
const dir = fs40.realpathSync(path46.join(folder2, ".akb", "handoffs", token));
|
|
184009
|
+
if (!dir.startsWith(fs40.realpathSync(folder2) + path46.sep)) return null;
|
|
184010
|
+
const marker = JSON.parse(fs40.readFileSync(path46.join(dir, ".akb", "handoff.json"), "utf8"));
|
|
184113
184011
|
return marker.task === job.task && marker.isolation === token ? dir : null;
|
|
184114
184012
|
} catch {
|
|
184115
184013
|
return null;
|
|
@@ -184117,38 +184015,38 @@ function progressFolder(job, folder2) {
|
|
|
184117
184015
|
}
|
|
184118
184016
|
function progressEvidence(job, folder2) {
|
|
184119
184017
|
try {
|
|
184120
|
-
const board =
|
|
184121
|
-
const deliveries =
|
|
184122
|
-
const rows =
|
|
184018
|
+
const board = path46.join(folder2, ".akb", "kanban");
|
|
184019
|
+
const deliveries = path46.join(board, "deliveries");
|
|
184020
|
+
const rows = fs40.readdirSync(deliveries).filter((name) => name.endsWith(".json")).map((name) => JSON.parse(fs40.readFileSync(path46.join(deliveries, name), "utf8"))).filter((row2) => row2.cardId === job.number).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
|
|
184123
184021
|
const row = rows[0];
|
|
184124
184022
|
if (!row?.deliveryId) return null;
|
|
184125
|
-
const tree =
|
|
184126
|
-
if (tree !==
|
|
184023
|
+
const tree = fs40.realpathSync(path46.resolve(folder2, row.worktree ?? "."));
|
|
184024
|
+
if (tree !== fs40.realpathSync(folder2) && !tree.startsWith(fs40.realpathSync(folder2) + path46.sep)) return null;
|
|
184127
184025
|
const inventory = gitRead(tree, ["worktree", "list", "--porcelain"]);
|
|
184128
184026
|
const related = (inventory ?? "").split("\n\n").flatMap((entry) => {
|
|
184129
184027
|
const branch = /^branch refs\/heads\/(.+)$/m.exec(entry)?.[1];
|
|
184130
184028
|
const dir = /^worktree (.+)$/m.exec(entry)?.[1];
|
|
184131
|
-
return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(
|
|
184029
|
+
return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs40.realpathSync(folder2) + path46.sep) ? [dir] : [];
|
|
184132
184030
|
});
|
|
184133
184031
|
const filesIn = (tree2) => {
|
|
184134
184032
|
const changed = [];
|
|
184135
184033
|
const walk = (dir, prefix = "") => {
|
|
184136
|
-
for (const entry of
|
|
184034
|
+
for (const entry of fs40.readdirSync(dir, { withFileTypes: true })) {
|
|
184137
184035
|
if ([".git", ".akb", "node_modules", ".claude", ".agents"].includes(entry.name)) continue;
|
|
184138
184036
|
const name = prefix + entry.name;
|
|
184139
|
-
if (entry.isDirectory()) walk(
|
|
184037
|
+
if (entry.isDirectory()) walk(path46.join(dir, entry.name), name + "/");
|
|
184140
184038
|
else changed.push(name);
|
|
184141
184039
|
}
|
|
184142
184040
|
};
|
|
184143
184041
|
walk(tree2);
|
|
184144
184042
|
changed.sort();
|
|
184145
184043
|
return changed.map((name) => {
|
|
184146
|
-
const file3 =
|
|
184044
|
+
const file3 = path46.join(tree2, name);
|
|
184147
184045
|
try {
|
|
184148
|
-
const stat2 =
|
|
184149
|
-
if (stat2.isSymbolicLink()) return [name, "link", digest(
|
|
184046
|
+
const stat2 = fs40.lstatSync(file3);
|
|
184047
|
+
if (stat2.isSymbolicLink()) return [name, "link", digest(fs40.readlinkSync(file3))];
|
|
184150
184048
|
if (!stat2.isFile()) throw new Error("\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B");
|
|
184151
|
-
return [name, stat2.mode & 511, digest(
|
|
184049
|
+
return [name, stat2.mode & 511, digest(fs40.readFileSync(file3))];
|
|
184152
184050
|
} catch (e2) {
|
|
184153
184051
|
if (e2.code === "ENOENT") return [name, "deleted"];
|
|
184154
184052
|
throw e2;
|
|
@@ -184185,60 +184083,61 @@ function progressEvidence(job, folder2) {
|
|
|
184185
184083
|
function restartFolder(job, folder2) {
|
|
184186
184084
|
const token = job.handoff?.isolation ?? job.id;
|
|
184187
184085
|
if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) throw new Error("\u9694\u79BB\u76EE\u5F55\u7F16\u53F7\u65E0\u6548\u3002");
|
|
184188
|
-
const dir =
|
|
184189
|
-
const marker =
|
|
184190
|
-
for (const parent of [
|
|
184191
|
-
if (
|
|
184086
|
+
const dir = path46.join(folder2, ".akb", "handoffs", token);
|
|
184087
|
+
const marker = path46.join(dir, ".akb", "handoff.json");
|
|
184088
|
+
for (const parent of [path46.join(folder2, ".akb"), path46.dirname(dir), dir]) {
|
|
184089
|
+
if (fs40.lstatSync(parent, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u76EE\u5F55\u4E0D\u80FD\u901A\u8FC7\u7B26\u53F7\u94FE\u63A5\u521B\u5EFA\u3002");
|
|
184192
184090
|
}
|
|
184193
|
-
if (
|
|
184091
|
+
if (fs40.existsSync(dir)) {
|
|
184194
184092
|
if (job.handoff?.recovering) {
|
|
184195
184093
|
try {
|
|
184196
|
-
const saved = JSON.parse(
|
|
184094
|
+
const saved = JSON.parse(fs40.readFileSync(marker, "utf8"));
|
|
184197
184095
|
if (saved.task === job.task && saved.isolation === token) return dir;
|
|
184198
184096
|
} catch {
|
|
184199
184097
|
}
|
|
184200
184098
|
}
|
|
184201
184099
|
throw new Error("\u91CD\u542F\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u3002");
|
|
184202
184100
|
}
|
|
184203
|
-
|
|
184204
|
-
|
|
184205
|
-
for (const entry of
|
|
184101
|
+
fs40.mkdirSync(path46.dirname(dir), { recursive: true });
|
|
184102
|
+
fs40.mkdirSync(dir);
|
|
184103
|
+
for (const entry of fs40.readdirSync(folder2)) {
|
|
184206
184104
|
if ([".akb", ".git", "node_modules", ".claude", ".agents"].includes(entry)) continue;
|
|
184207
|
-
|
|
184105
|
+
fs40.cpSync(path46.join(folder2, entry), path46.join(dir, entry), { recursive: true, verbatimSymlinks: true });
|
|
184208
184106
|
}
|
|
184209
|
-
if (
|
|
184210
|
-
|
|
184211
|
-
|
|
184107
|
+
if (fs40.lstatSync(path46.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
|
|
184108
|
+
fs40.mkdirSync(path46.dirname(marker), { recursive: true });
|
|
184109
|
+
fs40.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
|
|
184212
184110
|
return dir;
|
|
184213
184111
|
}
|
|
184214
184112
|
|
|
184215
184113
|
// src/jobs.ts
|
|
184216
184114
|
import { spawn as spawn5 } from "node:child_process";
|
|
184217
|
-
import
|
|
184218
|
-
import
|
|
184115
|
+
import fs47 from "node:fs";
|
|
184116
|
+
import path52 from "node:path";
|
|
184117
|
+
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
184219
184118
|
|
|
184220
184119
|
// ../cli/src/lib/agent/catalog.ts
|
|
184221
|
-
import
|
|
184222
|
-
import
|
|
184120
|
+
import fs41 from "node:fs";
|
|
184121
|
+
import path47 from "node:path";
|
|
184223
184122
|
var CATALOGUE = "https://models.dev/api.json";
|
|
184224
184123
|
var FRESH_FOR_MS = 24 * 60 * 6e4;
|
|
184225
184124
|
var ANSWER_BY_MS = 2e4;
|
|
184226
184125
|
function cacheFile() {
|
|
184227
|
-
return
|
|
184126
|
+
return path47.join(machineHome(), "models-dev.json");
|
|
184228
184127
|
}
|
|
184229
184128
|
var held3;
|
|
184230
184129
|
function readCache() {
|
|
184231
184130
|
const file3 = cacheFile();
|
|
184232
184131
|
let stamp3;
|
|
184233
184132
|
try {
|
|
184234
|
-
const stat2 =
|
|
184133
|
+
const stat2 = fs41.statSync(file3);
|
|
184235
184134
|
stamp3 = `${stat2.mtimeMs}:${stat2.size}`;
|
|
184236
184135
|
} catch {
|
|
184237
184136
|
return void 0;
|
|
184238
184137
|
}
|
|
184239
184138
|
if (held3?.stamp === stamp3) return held3.cached;
|
|
184240
184139
|
try {
|
|
184241
|
-
const data = JSON.parse(
|
|
184140
|
+
const data = JSON.parse(fs41.readFileSync(file3, "utf8"));
|
|
184242
184141
|
if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
|
|
184243
184142
|
const cached3 = {
|
|
184244
184143
|
fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
|
|
@@ -184277,8 +184176,8 @@ function refreshCatalog() {
|
|
|
184277
184176
|
const limits = limitsIn(await answer.json());
|
|
184278
184177
|
if (Object.keys(limits).length === 0) return;
|
|
184279
184178
|
const file3 = cacheFile();
|
|
184280
|
-
|
|
184281
|
-
|
|
184179
|
+
fs41.mkdirSync(path47.dirname(file3), { recursive: true });
|
|
184180
|
+
fs41.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
|
|
184282
184181
|
} catch {
|
|
184283
184182
|
}
|
|
184284
184183
|
})();
|
|
@@ -184371,14 +184270,14 @@ async function replyApprovalBridge(task, number4, approve) {
|
|
|
184371
184270
|
}
|
|
184372
184271
|
|
|
184373
184272
|
// src/akb-version.ts
|
|
184374
|
-
import
|
|
184375
|
-
import
|
|
184376
|
-
var stateFile = () =>
|
|
184377
|
-
var akbVersionDir = (version2) =>
|
|
184378
|
-
var entryOf = (dir) =>
|
|
184273
|
+
import fs42 from "node:fs";
|
|
184274
|
+
import path48 from "node:path";
|
|
184275
|
+
var stateFile = () => path48.join(akbHome(), "state.json");
|
|
184276
|
+
var akbVersionDir = (version2) => path48.join(akbHome(), version2);
|
|
184277
|
+
var entryOf = (dir) => path48.join(dir, "bin", "ai4kanban.mjs");
|
|
184379
184278
|
function readAkbState() {
|
|
184380
184279
|
try {
|
|
184381
|
-
const held5 = JSON.parse(
|
|
184280
|
+
const held5 = JSON.parse(fs42.readFileSync(stateFile(), "utf8"));
|
|
184382
184281
|
return { current: held5.current ?? null, bad: held5.bad ?? [] };
|
|
184383
184282
|
} catch {
|
|
184384
184283
|
return { current: null, bad: [] };
|
|
@@ -184386,12 +184285,12 @@ function readAkbState() {
|
|
|
184386
184285
|
}
|
|
184387
184286
|
function contractOf(dir) {
|
|
184388
184287
|
try {
|
|
184389
|
-
return JSON.parse(
|
|
184288
|
+
return JSON.parse(fs42.readFileSync(path48.join(dir, "package.json"), "utf8")).akbContract ?? null;
|
|
184390
184289
|
} catch {
|
|
184391
184290
|
return null;
|
|
184392
184291
|
}
|
|
184393
184292
|
}
|
|
184394
|
-
var usable = (dir) =>
|
|
184293
|
+
var usable = (dir) => fs42.existsSync(entryOf(dir)) && contractOf(dir) === AKB_CONTRACT;
|
|
184395
184294
|
function currentAkb() {
|
|
184396
184295
|
const { current: current2 } = readAkbState();
|
|
184397
184296
|
if (!current2) return bundledAkb();
|
|
@@ -184399,32 +184298,32 @@ function currentAkb() {
|
|
|
184399
184298
|
if (!usable(dir)) return bundledAkb();
|
|
184400
184299
|
try {
|
|
184401
184300
|
const now = /* @__PURE__ */ new Date();
|
|
184402
|
-
|
|
184301
|
+
fs42.utimesSync(dir, now, now);
|
|
184403
184302
|
} catch {
|
|
184404
184303
|
}
|
|
184405
|
-
return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim:
|
|
184304
|
+
return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim: path48.join(dir, "shim") };
|
|
184406
184305
|
}
|
|
184407
184306
|
|
|
184408
184307
|
// src/chats.ts
|
|
184409
|
-
import
|
|
184410
|
-
import
|
|
184308
|
+
import fs44 from "node:fs";
|
|
184309
|
+
import path50 from "node:path";
|
|
184411
184310
|
|
|
184412
184311
|
// ../cli/src/lib/shared/chats.ts
|
|
184413
184312
|
var CHAT_KEEP_DAYS = 30;
|
|
184414
184313
|
|
|
184415
184314
|
// ../cli/src/lib/agent/task-chats.ts
|
|
184416
|
-
import
|
|
184417
|
-
import
|
|
184315
|
+
import fs43 from "node:fs";
|
|
184316
|
+
import path49 from "node:path";
|
|
184418
184317
|
var TASK = /^[\w-]{1,100}$/;
|
|
184419
|
-
var taskChatsDir = (home4 = machineHome()) =>
|
|
184318
|
+
var taskChatsDir = (home4 = machineHome()) => path49.join(home4, "chats");
|
|
184420
184319
|
function taskChatFile(task, home4) {
|
|
184421
184320
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
184422
|
-
return
|
|
184321
|
+
return path49.join(taskChatsDir(home4), `${task}.jsonl`);
|
|
184423
184322
|
}
|
|
184424
184323
|
function readTaskChat(task, home4) {
|
|
184425
184324
|
let text3;
|
|
184426
184325
|
try {
|
|
184427
|
-
text3 =
|
|
184326
|
+
text3 = fs43.readFileSync(taskChatFile(task, home4), "utf8");
|
|
184428
184327
|
} catch {
|
|
184429
184328
|
return [];
|
|
184430
184329
|
}
|
|
@@ -184444,18 +184343,18 @@ function readTaskChat(task, home4) {
|
|
|
184444
184343
|
var DAY_MS = 24 * 60 * 6e4;
|
|
184445
184344
|
var KEEP_MS2 = CHAT_KEEP_DAYS * DAY_MS;
|
|
184446
184345
|
var home3 = () => runnerHome();
|
|
184447
|
-
var reviewedFile = () =>
|
|
184346
|
+
var reviewedFile = () => path50.join(taskChatsDir(home3()), "reviewed.json");
|
|
184448
184347
|
function readReviewed() {
|
|
184449
184348
|
try {
|
|
184450
|
-
const held5 = JSON.parse(
|
|
184349
|
+
const held5 = JSON.parse(fs44.readFileSync(reviewedFile(), "utf8"));
|
|
184451
184350
|
return { checkedAt: Number(held5.checkedAt) || 0, tasks: held5.tasks ?? {} };
|
|
184452
184351
|
} catch {
|
|
184453
184352
|
return { checkedAt: 0, tasks: {} };
|
|
184454
184353
|
}
|
|
184455
184354
|
}
|
|
184456
184355
|
function writeReviewed(reviewed) {
|
|
184457
|
-
|
|
184458
|
-
|
|
184356
|
+
fs44.mkdirSync(path50.dirname(reviewedFile()), { recursive: true });
|
|
184357
|
+
fs44.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
|
|
184459
184358
|
`);
|
|
184460
184359
|
}
|
|
184461
184360
|
function keepChat(job, reply, at2 = Date.now()) {
|
|
@@ -184465,16 +184364,16 @@ function keepChat(job, reply, at2 = Date.now()) {
|
|
|
184465
184364
|
{ id: job.id, role: "agent", text: reply, at: at2, runtime: job.runtime, model: job.model ?? null }
|
|
184466
184365
|
];
|
|
184467
184366
|
const file3 = taskChatFile(job.task, home3());
|
|
184468
|
-
|
|
184469
|
-
|
|
184367
|
+
fs44.mkdirSync(path50.dirname(file3), { recursive: true });
|
|
184368
|
+
fs44.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
|
|
184470
184369
|
`).join(""));
|
|
184471
184370
|
}
|
|
184472
184371
|
function keepCloudChat(task, messages) {
|
|
184473
184372
|
const file3 = taskChatFile(task, home3());
|
|
184474
|
-
if (!messages.length) return
|
|
184373
|
+
if (!messages.length) return fs44.rmSync(file3, { force: true });
|
|
184475
184374
|
const lines = messages.map((m) => ({ id: m.id, role: m.role, text: m.body, at: Date.parse(m.created_at) || Date.now() }));
|
|
184476
|
-
|
|
184477
|
-
|
|
184375
|
+
fs44.mkdirSync(path50.dirname(file3), { recursive: true });
|
|
184376
|
+
fs44.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
|
|
184478
184377
|
`).join(""));
|
|
184479
184378
|
}
|
|
184480
184379
|
async function keepDecisions(task, read5) {
|
|
@@ -184492,8 +184391,8 @@ async function keepDecisions(task, read5) {
|
|
|
184492
184391
|
const ids = new Set(comments.map((c2) => c2.id));
|
|
184493
184392
|
const lines = [...readTaskChat(task, home3()).filter((l2) => !ids.has(l2.id)), ...comments].sort((a2, b2) => a2.at - b2.at);
|
|
184494
184393
|
const file3 = taskChatFile(task, home3());
|
|
184495
|
-
|
|
184496
|
-
|
|
184394
|
+
fs44.mkdirSync(path50.dirname(file3), { recursive: true });
|
|
184395
|
+
fs44.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
|
|
184497
184396
|
`).join(""));
|
|
184498
184397
|
return true;
|
|
184499
184398
|
}
|
|
@@ -184508,29 +184407,36 @@ function markReviewed2(marks) {
|
|
|
184508
184407
|
}
|
|
184509
184408
|
|
|
184510
184409
|
// src/goals.ts
|
|
184511
|
-
import
|
|
184512
|
-
import
|
|
184410
|
+
import fs46 from "node:fs";
|
|
184411
|
+
import path51 from "node:path";
|
|
184513
184412
|
|
|
184514
184413
|
// ../cli/src/lib/goal-draft.ts
|
|
184515
|
-
import
|
|
184414
|
+
import fs45 from "node:fs";
|
|
184415
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
184516
184416
|
var goalDraftEnv = (file3) => ({ KANBAN_GOALS: file3, KANBAN_IDEAS: file3 });
|
|
184517
184417
|
function readGoalDraft(file3) {
|
|
184518
|
-
return decodeGoals(JSON.parse(
|
|
184418
|
+
return decodeGoals(JSON.parse(fs45.readFileSync(file3, "utf8")));
|
|
184519
184419
|
}
|
|
184520
184420
|
function writeGoalDraft(file3, { goals, ...draft }, field) {
|
|
184521
184421
|
const entries = field === "goals" ? goals : goals.map(({ task, ...goal }) => ({ ...goal, task: task?.key ? task : task?.id ?? null }));
|
|
184522
|
-
|
|
184523
|
-
|
|
184422
|
+
const temporary = `${file3}.${randomUUID5()}.tmp`;
|
|
184423
|
+
try {
|
|
184424
|
+
fs45.writeFileSync(temporary, `${JSON.stringify({ ...draft, [field]: entries }, null, 2)}
|
|
184425
|
+
`, { mode: 384, flag: "wx" });
|
|
184426
|
+
fs45.renameSync(temporary, file3);
|
|
184427
|
+
} finally {
|
|
184428
|
+
fs45.rmSync(temporary, { force: true });
|
|
184429
|
+
}
|
|
184524
184430
|
}
|
|
184525
184431
|
|
|
184526
184432
|
// src/goals.ts
|
|
184527
|
-
var goalsFileOf = (job) =>
|
|
184433
|
+
var goalsFileOf = (job) => path51.join(runnerHome(), "ideas", `${job.id}.json`);
|
|
184528
184434
|
async function writeGoals(job, list3, preserveGoals = false) {
|
|
184529
184435
|
const file3 = goalsFileOf(job);
|
|
184530
184436
|
try {
|
|
184531
|
-
const goals = preserveGoals &&
|
|
184437
|
+
const goals = preserveGoals && fs46.existsSync(file3) ? readGoalDraft(file3).value.goals : job.discussion.goals;
|
|
184532
184438
|
const studios = await studioSnapshot(job.discussion.workspace, job.discussion.catalog, list3);
|
|
184533
|
-
|
|
184439
|
+
fs46.mkdirSync(path51.dirname(file3), { recursive: true });
|
|
184534
184440
|
writeGoalDraft(file3, { workspace: job.discussion.workspace, studios, goals }, "ideas");
|
|
184535
184441
|
return { file: file3 };
|
|
184536
184442
|
} catch (e2) {
|
|
@@ -184543,7 +184449,7 @@ function readGoals(file3) {
|
|
|
184543
184449
|
} catch {
|
|
184544
184450
|
return void 0;
|
|
184545
184451
|
} finally {
|
|
184546
|
-
|
|
184452
|
+
fs46.rmSync(file3, { force: true });
|
|
184547
184453
|
}
|
|
184548
184454
|
}
|
|
184549
184455
|
var owner = "";
|
|
@@ -184656,32 +184562,32 @@ var defaultDeps = (machineId) => ({
|
|
|
184656
184562
|
akb: currentAkb,
|
|
184657
184563
|
runtimes: detectRuntimes
|
|
184658
184564
|
});
|
|
184659
|
-
var ownFolder = () =>
|
|
184565
|
+
var ownFolder = () => path52.join(runnerHome(), "work");
|
|
184660
184566
|
function folderFor(job) {
|
|
184661
184567
|
if (!job.projectDir) {
|
|
184662
|
-
const cwd =
|
|
184663
|
-
|
|
184568
|
+
const cwd = path52.join(ownFolder(), job.id);
|
|
184569
|
+
fs47.mkdirSync(cwd, { recursive: true });
|
|
184664
184570
|
return { cwd };
|
|
184665
184571
|
}
|
|
184666
184572
|
const real = realpath2(job.projectDir);
|
|
184667
|
-
if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 +
|
|
184573
|
+
if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path52.sep))) return { cwd: real };
|
|
184668
184574
|
return { refused: `This Runner is not allowed to work in ${job.projectDir}.` };
|
|
184669
184575
|
}
|
|
184670
184576
|
function realpath2(p2) {
|
|
184671
184577
|
try {
|
|
184672
|
-
return
|
|
184578
|
+
return fs47.realpathSync(p2);
|
|
184673
184579
|
} catch {
|
|
184674
184580
|
return null;
|
|
184675
184581
|
}
|
|
184676
184582
|
}
|
|
184677
|
-
var attachmentsOf = (job) =>
|
|
184583
|
+
var attachmentsOf = (job) => path52.join(runnerHome(), "attachments", job.id);
|
|
184678
184584
|
function writeAttachments(job) {
|
|
184679
184585
|
if (!job.attachments.length) return { text: "", files: [] };
|
|
184680
184586
|
const dir = attachmentsOf(job);
|
|
184681
|
-
|
|
184587
|
+
fs47.mkdirSync(dir, { recursive: true });
|
|
184682
184588
|
const files = job.attachments.map((a2) => {
|
|
184683
|
-
const file3 =
|
|
184684
|
-
|
|
184589
|
+
const file3 = path52.join(dir, path52.basename(a2.name));
|
|
184590
|
+
fs47.writeFileSync(file3, Buffer.from(a2.content, "base64"));
|
|
184685
184591
|
return file3;
|
|
184686
184592
|
});
|
|
184687
184593
|
return { text: `
|
|
@@ -184728,9 +184634,9 @@ function streamOut(deps, id2, lease) {
|
|
|
184728
184634
|
let closed = false;
|
|
184729
184635
|
let flushedAt = Date.now();
|
|
184730
184636
|
const log = { ws: null, after: null, watched: false, heard: 0, tries: 0, retry: void 0 };
|
|
184731
|
-
let
|
|
184637
|
+
let ended = () => {
|
|
184732
184638
|
};
|
|
184733
|
-
const stored = new Promise((resolve2) =>
|
|
184639
|
+
const stored = new Promise((resolve2) => ended = resolve2);
|
|
184734
184640
|
const children = /* @__PURE__ */ new Set();
|
|
184735
184641
|
const groups = /* @__PURE__ */ new Set();
|
|
184736
184642
|
const connections = /* @__PURE__ */ new Set();
|
|
@@ -184838,7 +184744,7 @@ function streamOut(deps, id2, lease) {
|
|
|
184838
184744
|
} else if (said.type === "watched") {
|
|
184839
184745
|
log.watched = said.on === true;
|
|
184840
184746
|
if (log.watched) flush();
|
|
184841
|
-
} else if (said.type === "ended")
|
|
184747
|
+
} else if (said.type === "ended") ended();
|
|
184842
184748
|
else if (said.type === "stop") ask();
|
|
184843
184749
|
});
|
|
184844
184750
|
ws.addEventListener("close", () => drop(ws));
|
|
@@ -184978,12 +184884,12 @@ async function runJob(id2, deps, track = () => {
|
|
|
184978
184884
|
const releases = [];
|
|
184979
184885
|
try {
|
|
184980
184886
|
const akb = deps.akb();
|
|
184981
|
-
releases.push(hold(
|
|
184887
|
+
releases.push(hold(path52.dirname(akb.shim)));
|
|
184982
184888
|
releases.push(hold(akb.shim));
|
|
184983
184889
|
await runClaimed(job, { ...deps, akb }, track, (dir) => releases.push(hold(dir)), lease);
|
|
184984
184890
|
} finally {
|
|
184985
184891
|
for (const release2 of releases) release2();
|
|
184986
|
-
|
|
184892
|
+
fs47.rmSync(attachmentsOf(job), { recursive: true, force: true });
|
|
184987
184893
|
}
|
|
184988
184894
|
return "changed";
|
|
184989
184895
|
}
|
|
@@ -185009,7 +184915,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
185009
184915
|
if (checkpoint.boardContinuation) job = { ...job, task: job.task ?? job.review?.tasks[0], flow: void 0, review: void 0, handoff: void 0, prompt: checkpoint.boardContinuation.prompt, resume: checkpoint.session, fork: false };
|
|
185010
184916
|
const reply = isReply(job);
|
|
185011
184917
|
const spent = () => reply && checkpoint.attempts?.length && !(job.recoveryOf && !local && checkpoint.completed) ? { session: checkpoint.session, ...replySpent(checkpoint, job.runtime) } : void 0;
|
|
185012
|
-
const finishClaimed = (outcome, reason = "", said2) => {
|
|
184918
|
+
const finishClaimed = async (outcome, reason = "", said2) => {
|
|
185013
184919
|
const before = spent();
|
|
185014
184920
|
let report2 = before ? { ...before, ...said2 } : said2;
|
|
185015
184921
|
if (reply && outcome === "failed" && !report2?.reply && checkpoint.partialReply) {
|
|
@@ -185019,6 +184925,27 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
185019
184925
|
report2 = { ...report2, recovery: replyRecovery(job, checkpoint, true) };
|
|
185020
184926
|
saveCheckpoint(id2, checkpoint);
|
|
185021
184927
|
}
|
|
184928
|
+
const draft = report2;
|
|
184929
|
+
if (job.discussion && draft && (draft.goals !== void 0 || draft.ideas !== void 0)) {
|
|
184930
|
+
const { goals: _goals, ideas: _ideas, goalsVersion: _version, ...rest } = draft;
|
|
184931
|
+
const notice = cloudLanguage(job) === "zh" ? "\u76EE\u6807\u672A\u80FD\u4FDD\u5B58\u5230\u5F53\u524D\u8BA8\u8BBA\u3002" : "The goals could not be saved to this discussion.";
|
|
184932
|
+
const unsaved = {
|
|
184933
|
+
...rest,
|
|
184934
|
+
reply: [notice, rest.reply].filter(Boolean).join("\n\n"),
|
|
184935
|
+
...rest.parts ? { parts: [{ type: "text", text: `${notice}
|
|
184936
|
+
|
|
184937
|
+
` }, ...rest.parts] } : {}
|
|
184938
|
+
};
|
|
184939
|
+
if (outcome === "done" && !draft.stopped) {
|
|
184940
|
+
await finishAndConfirm(deps, id2, lease, outcome, reason, draft, () => {
|
|
184941
|
+
checkpoint.completed = { outcome: "failed", reason: notice, report: unsaved };
|
|
184942
|
+
saveCheckpoint(id2, checkpoint);
|
|
184943
|
+
return finishAndConfirm(deps, id2, lease, "failed", notice, unsaved);
|
|
184944
|
+
});
|
|
184945
|
+
return;
|
|
184946
|
+
}
|
|
184947
|
+
report2 = unsaved;
|
|
184948
|
+
}
|
|
185022
184949
|
if (before && outcome === "failed") {
|
|
185023
184950
|
checkpoint.completed = { outcome, reason, report: report2 };
|
|
185024
184951
|
saveCheckpoint(id2, checkpoint);
|
|
@@ -185572,12 +185499,11 @@ ${prompt}` : prompt;
|
|
|
185572
185499
|
checkpoint.session = report2.session ?? checkpoint.session;
|
|
185573
185500
|
persist();
|
|
185574
185501
|
};
|
|
185575
|
-
let savedGoals;
|
|
185576
185502
|
const told = (report2) => {
|
|
185577
|
-
|
|
185503
|
+
const goals = goalFile ? readGoals(goalFile) : void 0;
|
|
185578
185504
|
const ran = subagents.summary();
|
|
185579
185505
|
const said2 = { ...report2, ...ran ? { subagents: ran } : {}, ...checkpoint.approvalRequested && checkpoint.approvalCancelled ? { replyApprovalSynced: false } : {} };
|
|
185580
|
-
return
|
|
185506
|
+
return goals && !isDeepStrictEqual3(goals, job.discussion?.goals) ? { ...said2, goals, goalsVersion: job.discussion?.version } : said2;
|
|
185581
185507
|
};
|
|
185582
185508
|
track(stream.stop);
|
|
185583
185509
|
const io = {
|
|
@@ -185628,14 +185554,14 @@ ${prompt}` : prompt;
|
|
|
185628
185554
|
checkpoint.reviewMarks = marks;
|
|
185629
185555
|
persist();
|
|
185630
185556
|
const refs = tasks.map((c2) => `${c2.task}:${c2.number}`);
|
|
185631
|
-
const
|
|
185632
|
-
if (
|
|
185633
|
-
if (!
|
|
185557
|
+
const ended2 = refs.length || io.flowRun ? await runReview(job, ws, refs, deps, io) : { ok: true, report: {} };
|
|
185558
|
+
if (ended2.ok) complete("done", ended2.report);
|
|
185559
|
+
if (!ended2.ok) {
|
|
185634
185560
|
await stream.end();
|
|
185635
|
-
if (!stream.lost()) return finishClaimed(stream.asked() ? "stopped" : "failed",
|
|
185561
|
+
if (!stream.lost()) return finishClaimed(stream.asked() ? "stopped" : "failed", ended2.reason);
|
|
185636
185562
|
return;
|
|
185637
185563
|
}
|
|
185638
|
-
return !stream.lost() ? sendResult(
|
|
185564
|
+
return !stream.lost() ? sendResult(ended2.report, () => markReviewed2(marks)) : void 0;
|
|
185639
185565
|
}
|
|
185640
185566
|
if (!run3) {
|
|
185641
185567
|
let result = await runFlow(job, ws, deps, io);
|
|
@@ -185838,17 +185764,17 @@ ${prompt}` : prompt;
|
|
|
185838
185764
|
renderer2.stderr?.(chunk);
|
|
185839
185765
|
stream.out(quietLines(plan3, chunk));
|
|
185840
185766
|
});
|
|
185841
|
-
const
|
|
185767
|
+
const ended2 = await new Promise((resolve2) => {
|
|
185842
185768
|
child.on("error", (e2) => resolve2({ code: null, failure: executionFailure(e2) }));
|
|
185843
185769
|
child.on("close", (code) => resolve2({ code }));
|
|
185844
185770
|
});
|
|
185845
185771
|
idleWatch?.close();
|
|
185846
185772
|
fromAgent(renderer2.flush());
|
|
185847
185773
|
const pending = renderer2.background?.() ? { code: "background_unfinished", level: 3, reason: "The agent exited with unfinished background tasks." } : void 0;
|
|
185848
|
-
return { ...
|
|
185774
|
+
return { ...ended2, failure: ended2.failure ?? backgroundFailure ?? pending };
|
|
185849
185775
|
};
|
|
185850
185776
|
const plan2 = run3;
|
|
185851
|
-
const
|
|
185777
|
+
const ended = await printed(plan2);
|
|
185852
185778
|
let measured = measure(report(job, plan2));
|
|
185853
185779
|
const renderer = plan2.renderer;
|
|
185854
185780
|
if (reply && job.runtime === "codex") {
|
|
@@ -185856,7 +185782,7 @@ ${prompt}` : prompt;
|
|
|
185856
185782
|
renderer.replyParts?.() ?? [{ type: "text", text: measured.reply ?? "" }],
|
|
185857
185783
|
cwd,
|
|
185858
185784
|
async (key, bytes2, mime) => {
|
|
185859
|
-
if (stream.asked() || stream.lost() ||
|
|
185785
|
+
if (stream.asked() || stream.lost() || ended.code !== 0) return { status: "not_saved" };
|
|
185860
185786
|
const result = await uploadReplyImage(deps.machineId, id2, key, bytes2, mime);
|
|
185861
185787
|
if (!result.ok) throw Error("image_upload_failed");
|
|
185862
185788
|
return stream.asked() || stream.lost() ? { status: "not_saved" } : result.value;
|
|
@@ -185864,8 +185790,8 @@ ${prompt}` : prompt;
|
|
|
185864
185790
|
);
|
|
185865
185791
|
if (parts) measured = { ...measured, parts, reply: parts.filter((p2) => p2.type === "text").map((p2) => p2.text).join("") };
|
|
185866
185792
|
}
|
|
185867
|
-
const diagnostic = renderer.failure?.() ?? (
|
|
185868
|
-
const rawFailure =
|
|
185793
|
+
const diagnostic = renderer.failure?.() ?? (ended.code === 0 ? void 0 : `Exited with code ${ended.code}.`);
|
|
185794
|
+
const rawFailure = ended.failure ?? renderer.executionFailure?.() ?? (diagnostic ? { code: "execution_failed", level: 3, reason: diagnostic } : void 0);
|
|
185869
185795
|
measured = retainReply(measured, !!rawFailure);
|
|
185870
185796
|
if (rawFailure?.code === "session_not_found" || rawFailure?.code === "session_mismatch") checkpoint.session = void 0;
|
|
185871
185797
|
if (await retry2(rawFailure)) return;
|
|
@@ -185897,22 +185823,22 @@ async function runAgentJob(job, ws, deps, stream, sync, lease, checkpoint, persi
|
|
|
185897
185823
|
const { outcome, reason, report: report2 } = checkpoint.completed;
|
|
185898
185824
|
return outcome === "done" ? sendResult(report2) : finish(deps, job.id, lease, outcome, reason, report2);
|
|
185899
185825
|
}
|
|
185900
|
-
const
|
|
185826
|
+
const ended = await runAgent(job, ws, deps, { flowRun: checkpoint.flowRun, starting, show: stream.out, event: (event2) => {
|
|
185901
185827
|
if (stream.lost()) return;
|
|
185902
185828
|
checkpointEvent(checkpoint, event2);
|
|
185903
185829
|
persist();
|
|
185904
185830
|
stream.event(event2);
|
|
185905
185831
|
}, track: stream.adopt, onStop: stream.onStop, lost: stream.lost, asked: stream.asked, sync });
|
|
185906
|
-
if (
|
|
185907
|
-
checkpoint.completed = { outcome: "done", report:
|
|
185908
|
-
checkpoint.reviewedRejections =
|
|
185832
|
+
if (ended.ok) {
|
|
185833
|
+
checkpoint.completed = { outcome: "done", report: ended.report };
|
|
185834
|
+
checkpoint.reviewedRejections = ended.reviewed;
|
|
185909
185835
|
persist();
|
|
185910
185836
|
}
|
|
185911
|
-
if (
|
|
185837
|
+
if (ended.ok && !stream.asked() && !stream.lost()) return sendResult(ended.report);
|
|
185912
185838
|
await stream.end();
|
|
185913
185839
|
if (stream.lost()) return;
|
|
185914
185840
|
if (stream.asked()) return finish(deps, job.id, lease, "stopped");
|
|
185915
|
-
if (!
|
|
185841
|
+
if (!ended.ok) return finish(deps, job.id, lease, "failed", ended.reason);
|
|
185916
185842
|
}
|
|
185917
185843
|
var quietLines = (plan2, chunk) => chunk.split("\n").filter((line) => line && !plan2.quiet(line)).map((line) => `${line}
|
|
185918
185844
|
`).join("");
|
|
@@ -185972,18 +185898,22 @@ async function whileOffline(deps, id2, lease, attempt) {
|
|
|
185972
185898
|
}
|
|
185973
185899
|
return null;
|
|
185974
185900
|
}
|
|
185975
|
-
async function
|
|
185901
|
+
async function finishAndConfirm(deps, id2, lease, outcome, reason = "", report2, onRefused) {
|
|
185902
|
+
let saveFailures = 0;
|
|
185976
185903
|
const sent = await whileOffline(deps, id2, lease, async () => {
|
|
185977
185904
|
const done = await deps.api.finishJob(deps.machineId, id2, outcome, reason, report2);
|
|
185978
|
-
|
|
185905
|
+
if (done.ok) return { finished: done.value.finished };
|
|
185906
|
+
const offline = retryableSync(done) && (!onRefused || done.status === void 0 || ++saveFailures < 2);
|
|
185907
|
+
return { offline, refused: !offline };
|
|
185979
185908
|
});
|
|
185980
185909
|
const remote2 = sent?.finished ? null : await readJob(id2);
|
|
185981
185910
|
const settled = sent?.finished || remote2?.ok && remote2.value.job.id === id2 && remote2.value.job.state === "finished" && remote2.value.job.outcome === outcome;
|
|
185982
185911
|
if (settled && (outcome !== "failed" || !report2?.recovery)) clearCheckpoint(id2);
|
|
185912
|
+
if (sent?.refused && onRefused && held4(deps, lease) && !(remote2?.ok && remote2.value.job.state === "finished")) return onRefused();
|
|
185983
185913
|
return !!settled;
|
|
185984
185914
|
}
|
|
185985
185915
|
async function finish(deps, id2, lease, outcome, reason = "", report2) {
|
|
185986
|
-
await
|
|
185916
|
+
await finishAndConfirm(deps, id2, lease, outcome, reason, report2);
|
|
185987
185917
|
}
|
|
185988
185918
|
async function sendBack(job, deps, lease, ws, report2, sync, stream, landed, repair, confirm) {
|
|
185989
185919
|
const result = await sync("publish", async () => {
|
|
@@ -186004,7 +185934,7 @@ async function sendBack(job, deps, lease, ws, report2, sync, stream, landed, rep
|
|
|
186004
185934
|
console.error("runner: task sync refused", { job: job.id, code: denied.code, error: denied.error });
|
|
186005
185935
|
return finish(deps, job.id, lease, "failed", syncRefusal(job, denied), report2);
|
|
186006
185936
|
}
|
|
186007
|
-
if (await
|
|
185937
|
+
if (await finishAndConfirm(deps, job.id, lease, "done", "", { ...report2, ...readCheckpoint(job.id)?.approvalRequested ? { replyApprovalSynced: report2.replyApprovalSynced !== false && replyAssetsSynced(ws) } : {} })) landed();
|
|
186008
185938
|
}
|
|
186009
185939
|
var settingsOf = (job) => ({ settings: job.settings, secrets: secretsOf(job.runtimeId) });
|
|
186010
185940
|
async function runSecret(job, deps) {
|
|
@@ -186018,15 +185948,15 @@ async function runSecret(job, deps) {
|
|
|
186018
185948
|
}
|
|
186019
185949
|
async function runTest(job, deps, lease) {
|
|
186020
185950
|
const finish2 = async (outcome, reason, ms2) => {
|
|
186021
|
-
if (!await
|
|
185951
|
+
if (!await finishAndConfirm(deps, job.id, lease, outcome, reason, ms2 === void 0 ? void 0 : { ms: ms2 })) {
|
|
186022
185952
|
console.error(`runner: connection test ${job.id}: Cloud did not accept the result.`);
|
|
186023
185953
|
}
|
|
186024
185954
|
};
|
|
186025
185955
|
const report2 = (await deps.runtimes()).find((r2) => r2.name === job.runtime);
|
|
186026
185956
|
if (!report2?.installed) return finish2("failed", "not_installed");
|
|
186027
185957
|
if (report2.loggedIn === false) return finish2("failed", "signed_out");
|
|
186028
|
-
const cwd =
|
|
186029
|
-
|
|
185958
|
+
const cwd = path52.join(ownFolder(), "test");
|
|
185959
|
+
fs47.mkdirSync(cwd, { recursive: true });
|
|
186030
185960
|
const run3 = deps.plan(job.runtime, job.prompt, cwd, null, job.model, settingsOf(job));
|
|
186031
185961
|
const startedAt = Date.now();
|
|
186032
185962
|
if (run3.converse) {
|
|
@@ -186115,22 +186045,22 @@ ${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
|
|
|
186115
186045
|
|
|
186116
186046
|
// src/flow-worker.ts
|
|
186117
186047
|
var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
|
|
186118
|
-
var directory2 = () =>
|
|
186119
|
-
var fileOf3 = (id2) =>
|
|
186048
|
+
var directory2 = () => path53.join(runnerHome(), "flow-workers");
|
|
186049
|
+
var fileOf3 = (id2) => path53.join(directory2(), `${encodeURIComponent(id2)}.json`);
|
|
186120
186050
|
var stopFile = (id2) => `${fileOf3(id2)}.stop`;
|
|
186121
186051
|
var flowWorkerEntry = fileURLToPath4(new URL("./flow-worker-main.mjs", import.meta.url));
|
|
186122
186052
|
var canKeepFlow = (job) => !!job.task && !!job.flow && ["create", "refine", "implement", "preview"].includes(job.flow.verb) && !job.agent && !job.review && !job.discussion && !job.test && !job.secret;
|
|
186123
186053
|
function read4(id2) {
|
|
186124
186054
|
try {
|
|
186125
|
-
return JSON.parse(
|
|
186055
|
+
return JSON.parse(fs48.readFileSync(fileOf3(id2), "utf8"));
|
|
186126
186056
|
} catch {
|
|
186127
186057
|
return null;
|
|
186128
186058
|
}
|
|
186129
186059
|
}
|
|
186130
186060
|
function save2(worker) {
|
|
186131
186061
|
const file3 = fileOf3(worker.id);
|
|
186132
|
-
|
|
186133
|
-
|
|
186062
|
+
fs48.writeFileSync(`${file3}.${process.pid}.tmp`, JSON.stringify(worker), { mode: 384 });
|
|
186063
|
+
fs48.renameSync(`${file3}.${process.pid}.tmp`, file3);
|
|
186134
186064
|
}
|
|
186135
186065
|
function writerStopped(worker) {
|
|
186136
186066
|
if (!Number.isSafeInteger(worker.pid) || worker.pid <= 0 || pidAlive(worker.pid)) return false;
|
|
@@ -186187,7 +186117,7 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
186187
186117
|
const sweep = async () => {
|
|
186188
186118
|
let names2;
|
|
186189
186119
|
try {
|
|
186190
|
-
names2 = only ? [`${encodeURIComponent(only)}.json`] :
|
|
186120
|
+
names2 = only ? [`${encodeURIComponent(only)}.json`] : fs48.readdirSync(directory2());
|
|
186191
186121
|
} catch {
|
|
186192
186122
|
return;
|
|
186193
186123
|
}
|
|
@@ -186195,8 +186125,8 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
186195
186125
|
if (!valid()) break;
|
|
186196
186126
|
if (!name.endsWith(".json")) continue;
|
|
186197
186127
|
try {
|
|
186198
|
-
const file3 =
|
|
186199
|
-
const original =
|
|
186128
|
+
const file3 = path53.join(directory2(), name);
|
|
186129
|
+
const original = fs48.readFileSync(file3, "utf8");
|
|
186200
186130
|
const worker = JSON.parse(original);
|
|
186201
186131
|
if (!worker || typeof worker.id !== "string" || name !== `${encodeURIComponent(worker.id)}.json` || typeof worker.token !== "string" || !worker.token || worker.machine !== machine || worker.account !== account || typeof worker.generation !== "string" || !Number.isFinite(worker.at)) continue;
|
|
186202
186132
|
if (!writerStopped(worker)) {
|
|
@@ -186206,8 +186136,8 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
186206
186136
|
const release2 = tryLock(`${file3}.lock`);
|
|
186207
186137
|
if (!release2) continue;
|
|
186208
186138
|
try {
|
|
186209
|
-
if (
|
|
186210
|
-
const queried = tryLock(
|
|
186139
|
+
if (fs48.readFileSync(file3, "utf8") !== original) continue;
|
|
186140
|
+
const queried = tryLock(path53.join(directory2(), ".lookup.lock"));
|
|
186211
186141
|
if (!queried) continue;
|
|
186212
186142
|
const remote2 = await readJob(worker.id).finally(queried);
|
|
186213
186143
|
if (!valid()) break;
|
|
@@ -186233,10 +186163,10 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
186233
186163
|
} else if (job.state !== "finished" && !(job.state === "waiting" && readCheckpoint(job.id)?.updating)) continue;
|
|
186234
186164
|
if (!worker.markedAt) {
|
|
186235
186165
|
const job2 = remote2.value.job;
|
|
186236
|
-
const folder2 = job2.projectDir ? folderFor(job2) : { cwd:
|
|
186166
|
+
const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path53.join(runnerHome(), "work", job2.id) };
|
|
186237
186167
|
if ("refused" in folder2 || !job2.task || !job2.project) continue;
|
|
186238
|
-
const board =
|
|
186239
|
-
if (!
|
|
186168
|
+
const board = path53.join(folder2.cwd, ".akb", "kanban");
|
|
186169
|
+
if (!fs48.existsSync(board)) continue;
|
|
186240
186170
|
const deps = given ?? defaultDeps(machine);
|
|
186241
186171
|
if (!await confirmFlowStopped(
|
|
186242
186172
|
{
|
|
@@ -186254,10 +186184,10 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
186254
186184
|
const checkpoint = readCheckpoint(worker.id);
|
|
186255
186185
|
if (checkpoint && (!checkpoint.mark || !processesStopped(checkpoint.mark, checkpoint.process))) continue;
|
|
186256
186186
|
}
|
|
186257
|
-
if (!writerStopped(worker) || !valid() ||
|
|
186258
|
-
|
|
186259
|
-
|
|
186260
|
-
|
|
186187
|
+
if (!writerStopped(worker) || !valid() || fs48.readFileSync(file3, "utf8") !== original) continue;
|
|
186188
|
+
fs48.rmSync(`${file3}.log`, { force: true });
|
|
186189
|
+
fs48.rmSync(`${file3}.stop`, { force: true });
|
|
186190
|
+
fs48.unlinkSync(file3);
|
|
186261
186191
|
if (job.state === "finished" && job.outcome === "done") clearCheckpoint(job.id);
|
|
186262
186192
|
} finally {
|
|
186263
186193
|
release2();
|
|
@@ -186282,14 +186212,14 @@ async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
|
|
|
186282
186212
|
await halt?.();
|
|
186283
186213
|
};
|
|
186284
186214
|
const release2 = executorRecord();
|
|
186285
|
-
const keepVersion = hold(
|
|
186215
|
+
const keepVersion = hold(path53.resolve(path53.dirname(fileURLToPath4(import.meta.url)), ".."));
|
|
186286
186216
|
worker.pid = process.pid;
|
|
186287
186217
|
worker.processAt = Date.now();
|
|
186288
186218
|
save2(worker);
|
|
186289
186219
|
const timer = setInterval(() => {
|
|
186290
186220
|
let asked = false;
|
|
186291
186221
|
try {
|
|
186292
|
-
asked =
|
|
186222
|
+
asked = fs48.readFileSync(stopFile(id2), "utf8") === token;
|
|
186293
186223
|
} catch {
|
|
186294
186224
|
}
|
|
186295
186225
|
if (!valid() || asked) void stop2();
|