wildcrane-runner 0.6.115 → 0.6.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/akb/dist/kanban.mjs +13759 -13245
- 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 +1538 -1030
- package/dist/launcher.mjs +602 -488
- package/dist/plugin.mjs +38887 -38771
- package/dist/runner.mjs +1710 -1174
- package/dist/settings.mjs +696 -580
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.117 — 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;
|
|
@@ -232,9 +232,9 @@ var require_timers = __commonJS({
|
|
|
232
232
|
* before the specified function or code is executed.
|
|
233
233
|
* @param {*} arg
|
|
234
234
|
*/
|
|
235
|
-
constructor(callback,
|
|
235
|
+
constructor(callback, delay4, arg) {
|
|
236
236
|
this._onTimeout = callback;
|
|
237
|
-
this._idleTimeout =
|
|
237
|
+
this._idleTimeout = delay4;
|
|
238
238
|
this._timerArg = arg;
|
|
239
239
|
this.refresh();
|
|
240
240
|
}
|
|
@@ -279,8 +279,8 @@ var require_timers = __commonJS({
|
|
|
279
279
|
* when the timer expires.
|
|
280
280
|
* @returns {NodeJS.Timeout|FastTimer}
|
|
281
281
|
*/
|
|
282
|
-
setTimeout(callback,
|
|
283
|
-
return
|
|
282
|
+
setTimeout(callback, delay4, arg) {
|
|
283
|
+
return delay4 <= RESOLUTION_MS ? setTimeout(callback, delay4, arg) : new FastTimer(callback, delay4, arg);
|
|
284
284
|
},
|
|
285
285
|
/**
|
|
286
286
|
* The clearTimeout method cancels an instantiated Timer previously created
|
|
@@ -306,8 +306,8 @@ var require_timers = __commonJS({
|
|
|
306
306
|
* when the timer expires.
|
|
307
307
|
* @returns {FastTimer}
|
|
308
308
|
*/
|
|
309
|
-
setFastTimeout(callback,
|
|
310
|
-
return new FastTimer(callback,
|
|
309
|
+
setFastTimeout(callback, delay4, arg) {
|
|
310
|
+
return new FastTimer(callback, delay4, arg);
|
|
311
311
|
},
|
|
312
312
|
/**
|
|
313
313
|
* The clearTimeout method cancels an instantiated FastTimer previously
|
|
@@ -333,8 +333,8 @@ var require_timers = __commonJS({
|
|
|
333
333
|
* @deprecated
|
|
334
334
|
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
|
|
335
335
|
*/
|
|
336
|
-
tick(
|
|
337
|
-
fastNow +=
|
|
336
|
+
tick(delay4 = 0) {
|
|
337
|
+
fastNow += delay4 - RESOLUTION_MS + 1;
|
|
338
338
|
onTick();
|
|
339
339
|
onTick();
|
|
340
340
|
},
|
|
@@ -4054,8 +4054,8 @@ var require_infra = __commonJS({
|
|
|
4054
4054
|
assert2(!invalidIsomorphicEncodeValueRegex.test(input2));
|
|
4055
4055
|
return input2;
|
|
4056
4056
|
}
|
|
4057
|
-
function parseJSONFromBytes(
|
|
4058
|
-
return JSON.parse(utf8DecodeBytes(
|
|
4057
|
+
function parseJSONFromBytes(bytes) {
|
|
4058
|
+
return JSON.parse(utf8DecodeBytes(bytes));
|
|
4059
4059
|
}
|
|
4060
4060
|
function removeASCIIWhitespace(str5, leading = true, trailing = true) {
|
|
4061
4061
|
return removeChars(str5, leading, trailing, isASCIIWhitespace);
|
|
@@ -4101,7 +4101,7 @@ var require_data_url = __commonJS({
|
|
|
4101
4101
|
"use strict";
|
|
4102
4102
|
var assert2 = __require("node:assert");
|
|
4103
4103
|
var { forgivingBase64, collectASequenceOfCodePoints, collectASequenceOfCodePointsFast, isomorphicDecode, removeASCIIWhitespace, removeChars } = require_infra();
|
|
4104
|
-
var
|
|
4104
|
+
var encoder3 = new TextEncoder();
|
|
4105
4105
|
var HTTP_TOKEN_CODEPOINTS = /^[-!#$%&'*+.^_|~A-Za-z0-9]+$/u;
|
|
4106
4106
|
var HTTP_WHITESPACE_REGEX = /[\u000A\u000D\u0009\u0020]/u;
|
|
4107
4107
|
var HTTP_QUOTED_STRING_TOKENS = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/u;
|
|
@@ -4155,8 +4155,8 @@ var require_data_url = __commonJS({
|
|
|
4155
4155
|
return serialized;
|
|
4156
4156
|
}
|
|
4157
4157
|
function stringPercentDecode(input2) {
|
|
4158
|
-
const
|
|
4159
|
-
return percentDecode(
|
|
4158
|
+
const bytes = encoder3.encode(input2);
|
|
4159
|
+
return percentDecode(bytes);
|
|
4160
4160
|
}
|
|
4161
4161
|
function isHexCharByte(byte) {
|
|
4162
4162
|
return byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102;
|
|
@@ -4842,10 +4842,10 @@ var require_webidl = __commonJS({
|
|
|
4842
4842
|
if (jsArrayBuffer.detached) {
|
|
4843
4843
|
return new Uint8Array(0);
|
|
4844
4844
|
}
|
|
4845
|
-
const
|
|
4845
|
+
const bytes = new Uint8Array(length);
|
|
4846
4846
|
const view = new Uint8Array(jsArrayBuffer, offset, length);
|
|
4847
|
-
|
|
4848
|
-
return
|
|
4847
|
+
bytes.set(view);
|
|
4848
|
+
return bytes;
|
|
4849
4849
|
};
|
|
4850
4850
|
webidl.converters.DOMString = function(V3, prefix, argument, flags2) {
|
|
4851
4851
|
if (V3 === null && webidl.util.HasFlag(flags2, webidl.attributes.LegacyNullToEmptyString)) {
|
|
@@ -5561,19 +5561,19 @@ var require_util2 = __commonJS({
|
|
|
5561
5561
|
}
|
|
5562
5562
|
async function readAllBytes(reader, successSteps, failureSteps) {
|
|
5563
5563
|
try {
|
|
5564
|
-
const
|
|
5564
|
+
const bytes = [];
|
|
5565
5565
|
let byteLength = 0;
|
|
5566
5566
|
do {
|
|
5567
5567
|
const { done, value: chunk } = await reader.read();
|
|
5568
5568
|
if (done) {
|
|
5569
|
-
successSteps(Buffer.concat(
|
|
5569
|
+
successSteps(Buffer.concat(bytes, byteLength));
|
|
5570
5570
|
return;
|
|
5571
5571
|
}
|
|
5572
5572
|
if (!isUint8Array(chunk)) {
|
|
5573
5573
|
failureSteps(new TypeError("Received non-Uint8Array chunk"));
|
|
5574
5574
|
return;
|
|
5575
5575
|
}
|
|
5576
|
-
|
|
5576
|
+
bytes.push(chunk);
|
|
5577
5577
|
byteLength += chunk.length;
|
|
5578
5578
|
} while (true);
|
|
5579
5579
|
} catch (e2) {
|
|
@@ -6018,7 +6018,7 @@ var require_formdata_parser = __commonJS({
|
|
|
6018
6018
|
var assert2 = __require("node:assert");
|
|
6019
6019
|
var { isomorphicDecode } = require_infra();
|
|
6020
6020
|
var dd = Buffer.from("--");
|
|
6021
|
-
var
|
|
6021
|
+
var decoder2 = new TextDecoder();
|
|
6022
6022
|
var decoderIgnoreBOM = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
6023
6023
|
function isAsciiString(chars) {
|
|
6024
6024
|
for (let i = 0; i < chars.length; ++i) {
|
|
@@ -6150,7 +6150,7 @@ var require_formdata_parser = __commonJS({
|
|
|
6150
6150
|
headerValue[4] !== 56) {
|
|
6151
6151
|
throw parsingError("unknown encoding, expected utf-8''");
|
|
6152
6152
|
}
|
|
6153
|
-
value = decodeURIComponent(
|
|
6153
|
+
value = decodeURIComponent(decoder2.decode(headerValue.subarray(7)));
|
|
6154
6154
|
} else if (input2[position.position] === 34) {
|
|
6155
6155
|
position.position++;
|
|
6156
6156
|
const quotedValue = collectASequenceOfBytes(
|
|
@@ -6163,7 +6163,7 @@ var require_formdata_parser = __commonJS({
|
|
|
6163
6163
|
throw parsingError("Closing quote not found");
|
|
6164
6164
|
}
|
|
6165
6165
|
position.position++;
|
|
6166
|
-
value =
|
|
6166
|
+
value = decoder2.decode(quotedValue).replace(/%0A/ig, "\n").replace(/%0D/ig, "\r").replace(/%22/g, '"');
|
|
6167
6167
|
} else {
|
|
6168
6168
|
const tokenValue = collectASequenceOfBytes(
|
|
6169
6169
|
(char) => isToken(char) && char !== 59,
|
|
@@ -6171,7 +6171,7 @@ var require_formdata_parser = __commonJS({
|
|
|
6171
6171
|
input2,
|
|
6172
6172
|
position
|
|
6173
6173
|
);
|
|
6174
|
-
value =
|
|
6174
|
+
value = decoder2.decode(tokenValue);
|
|
6175
6175
|
}
|
|
6176
6176
|
return { name: attrNameStr, value, extended: isExtended };
|
|
6177
6177
|
}
|
|
@@ -6532,19 +6532,19 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
6532
6532
|
function bodyMixinMethods(instance, getInternalState) {
|
|
6533
6533
|
const methods = {
|
|
6534
6534
|
blob() {
|
|
6535
|
-
return consumeBody(this, (
|
|
6535
|
+
return consumeBody(this, (bytes) => {
|
|
6536
6536
|
let mimeType = bodyMimeType(getInternalState(this));
|
|
6537
6537
|
if (mimeType === null) {
|
|
6538
6538
|
mimeType = "";
|
|
6539
6539
|
} else if (mimeType) {
|
|
6540
6540
|
mimeType = serializeAMimeType(mimeType);
|
|
6541
6541
|
}
|
|
6542
|
-
return new Blob([
|
|
6542
|
+
return new Blob([bytes], { type: mimeType });
|
|
6543
6543
|
}, instance, getInternalState);
|
|
6544
6544
|
},
|
|
6545
6545
|
arrayBuffer() {
|
|
6546
|
-
return consumeBody(this, (
|
|
6547
|
-
return new Uint8Array(
|
|
6546
|
+
return consumeBody(this, (bytes) => {
|
|
6547
|
+
return new Uint8Array(bytes).buffer;
|
|
6548
6548
|
}, instance, getInternalState);
|
|
6549
6549
|
},
|
|
6550
6550
|
text() {
|
|
@@ -6580,8 +6580,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
6580
6580
|
}, instance, getInternalState);
|
|
6581
6581
|
},
|
|
6582
6582
|
bytes() {
|
|
6583
|
-
return consumeBody(this, (
|
|
6584
|
-
return new Uint8Array(
|
|
6583
|
+
return consumeBody(this, (bytes) => {
|
|
6584
|
+
return new Uint8Array(bytes);
|
|
6585
6585
|
}, instance, getInternalState);
|
|
6586
6586
|
}
|
|
6587
6587
|
};
|
|
@@ -6852,21 +6852,21 @@ var require_client_h1 = __commonJS({
|
|
|
6852
6852
|
this.connection = "";
|
|
6853
6853
|
this.maxResponseSize = client[kMaxResponseSize];
|
|
6854
6854
|
}
|
|
6855
|
-
setTimeout(
|
|
6856
|
-
if (
|
|
6855
|
+
setTimeout(delay4, type) {
|
|
6856
|
+
if (delay4 !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) {
|
|
6857
6857
|
if (this.timeout) {
|
|
6858
6858
|
timers.clearTimeout(this.timeout);
|
|
6859
6859
|
this.timeout = null;
|
|
6860
6860
|
}
|
|
6861
|
-
if (
|
|
6861
|
+
if (delay4) {
|
|
6862
6862
|
if (type & USE_FAST_TIMER) {
|
|
6863
|
-
this.timeout = timers.setFastTimeout(onParserTimeout,
|
|
6863
|
+
this.timeout = timers.setFastTimeout(onParserTimeout, delay4, this.timeoutWeakRef);
|
|
6864
6864
|
} else {
|
|
6865
|
-
this.timeout = setTimeout(onParserTimeout,
|
|
6865
|
+
this.timeout = setTimeout(onParserTimeout, delay4, this.timeoutWeakRef);
|
|
6866
6866
|
this.timeout?.unref();
|
|
6867
6867
|
}
|
|
6868
6868
|
}
|
|
6869
|
-
this.timeoutValue =
|
|
6869
|
+
this.timeoutValue = delay4;
|
|
6870
6870
|
} else if (this.timeout) {
|
|
6871
6871
|
if (this.timeout.refresh) {
|
|
6872
6872
|
this.timeout.refresh();
|
|
@@ -13032,7 +13032,7 @@ var require_mock_utils = __commonJS({
|
|
|
13032
13032
|
if (mockDispatch2.data.callback) {
|
|
13033
13033
|
mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
|
|
13034
13034
|
}
|
|
13035
|
-
const { data: { statusCode, data, headers, trailers, error: error62 }, delay:
|
|
13035
|
+
const { data: { statusCode, data, headers, trailers, error: error62 }, delay: delay4, persist } = mockDispatch2;
|
|
13036
13036
|
const { timesInvoked, times } = mockDispatch2;
|
|
13037
13037
|
mockDispatch2.consumed = !persist && timesInvoked >= times;
|
|
13038
13038
|
mockDispatch2.pending = timesInvoked < times;
|
|
@@ -13055,11 +13055,11 @@ var require_mock_utils = __commonJS({
|
|
|
13055
13055
|
handler.onError(err);
|
|
13056
13056
|
}
|
|
13057
13057
|
handler.onConnect?.(abort, null);
|
|
13058
|
-
if (typeof
|
|
13058
|
+
if (typeof delay4 === "number" && delay4 > 0) {
|
|
13059
13059
|
timer = setTimeout(() => {
|
|
13060
13060
|
timer = null;
|
|
13061
13061
|
handleReply(this[kDispatches]);
|
|
13062
|
-
},
|
|
13062
|
+
}, delay4);
|
|
13063
13063
|
} else {
|
|
13064
13064
|
handleReply(this[kDispatches]);
|
|
13065
13065
|
}
|
|
@@ -13896,8 +13896,8 @@ var require_snapshot_utils = __commonJS({
|
|
|
13896
13896
|
match: new Set(matchHeaders.map((header) => caseSensitive ? header : header.toLowerCase()))
|
|
13897
13897
|
};
|
|
13898
13898
|
}
|
|
13899
|
-
var
|
|
13900
|
-
var hashId =
|
|
13899
|
+
var crypto8 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
|
|
13900
|
+
var hashId = crypto8?.hash ? (value) => crypto8.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
|
|
13901
13901
|
function isUndiciHeaders(headers) {
|
|
13902
13902
|
return Array.isArray(headers) && (headers.length & 1) === 0;
|
|
13903
13903
|
}
|
|
@@ -19950,10 +19950,10 @@ var require_response = __commonJS({
|
|
|
19950
19950
|
if (init !== null) {
|
|
19951
19951
|
init = webidl.converters.ResponseInit(init);
|
|
19952
19952
|
}
|
|
19953
|
-
const
|
|
19953
|
+
const bytes = textEncoder.encode(
|
|
19954
19954
|
serializeJavascriptValueToJSONString(data)
|
|
19955
19955
|
);
|
|
19956
|
-
const body = extractBody(
|
|
19956
|
+
const body = extractBody(bytes);
|
|
19957
19957
|
const responseObject = fromInnerResponse(makeResponse({}), "response");
|
|
19958
19958
|
initializeResponse(responseObject, init, { body: body[0], type: "application/json" });
|
|
19959
19959
|
return responseObject;
|
|
@@ -21095,10 +21095,10 @@ var require_subresource_integrity = __commonJS({
|
|
|
21095
21095
|
var { runtimeFeatures } = require_runtime_features();
|
|
21096
21096
|
var { asciiLowercase } = require_infra();
|
|
21097
21097
|
var validSRIHashAlgorithmTokenSet = /* @__PURE__ */ new Map([["sha256", 0], ["sha384", 1], ["sha512", 2]]);
|
|
21098
|
-
var
|
|
21098
|
+
var crypto8;
|
|
21099
21099
|
if (runtimeFeatures.has("crypto")) {
|
|
21100
|
-
|
|
21101
|
-
const cryptoHashes =
|
|
21100
|
+
crypto8 = __require("node:crypto");
|
|
21101
|
+
const cryptoHashes = crypto8.getHashes();
|
|
21102
21102
|
if (cryptoHashes.length === 0) {
|
|
21103
21103
|
validSRIHashAlgorithmTokenSet.clear();
|
|
21104
21104
|
}
|
|
@@ -21117,7 +21117,7 @@ var require_subresource_integrity = __commonJS({
|
|
|
21117
21117
|
)
|
|
21118
21118
|
);
|
|
21119
21119
|
var isValidSRIHashAlgorithm = (algorithm) => validSRIHashAlgorithmTokenSet.has(asciiLowercase(algorithm));
|
|
21120
|
-
var bytesMatch = runtimeFeatures.has("crypto") === false || validSRIHashAlgorithmTokenSet.size === 0 ? () => true : (
|
|
21120
|
+
var bytesMatch = runtimeFeatures.has("crypto") === false || validSRIHashAlgorithmTokenSet.size === 0 ? () => true : (bytes, metadataList) => {
|
|
21121
21121
|
const parsedMetadata = parseMetadata(metadataList);
|
|
21122
21122
|
if (parsedMetadata.length === 0) {
|
|
21123
21123
|
return true;
|
|
@@ -21126,7 +21126,7 @@ var require_subresource_integrity = __commonJS({
|
|
|
21126
21126
|
for (const item of metadata) {
|
|
21127
21127
|
const algorithm = item.alg;
|
|
21128
21128
|
const expectedValue = item.val;
|
|
21129
|
-
const actualValue = applyAlgorithmToBytes(algorithm,
|
|
21129
|
+
const actualValue = applyAlgorithmToBytes(algorithm, bytes);
|
|
21130
21130
|
if (caseSensitiveMatch(actualValue, expectedValue)) {
|
|
21131
21131
|
return true;
|
|
21132
21132
|
}
|
|
@@ -21185,8 +21185,8 @@ var require_subresource_integrity = __commonJS({
|
|
|
21185
21185
|
}
|
|
21186
21186
|
return result;
|
|
21187
21187
|
}
|
|
21188
|
-
var applyAlgorithmToBytes = (algorithm,
|
|
21189
|
-
return
|
|
21188
|
+
var applyAlgorithmToBytes = (algorithm, bytes) => {
|
|
21189
|
+
return crypto8.hash(algorithm, bytes, "base64");
|
|
21190
21190
|
};
|
|
21191
21191
|
function caseSensitiveMatch(actualValue, expectedValue) {
|
|
21192
21192
|
let actualValueLength = actualValue.length;
|
|
@@ -21597,12 +21597,12 @@ var require_fetch = __commonJS({
|
|
|
21597
21597
|
processBodyError(response.error);
|
|
21598
21598
|
return;
|
|
21599
21599
|
}
|
|
21600
|
-
const processBody = (
|
|
21601
|
-
if (!bytesMatch(
|
|
21600
|
+
const processBody = (bytes) => {
|
|
21601
|
+
if (!bytesMatch(bytes, request2.integrity)) {
|
|
21602
21602
|
processBodyError("integrity mismatch");
|
|
21603
21603
|
return;
|
|
21604
21604
|
}
|
|
21605
|
-
response.body = safelyExtractBody(
|
|
21605
|
+
response.body = safelyExtractBody(bytes)[0];
|
|
21606
21606
|
fetchFinale(fetchParams, response);
|
|
21607
21607
|
};
|
|
21608
21608
|
fullyReadBody(response.body, processBody, processBodyError);
|
|
@@ -22045,12 +22045,12 @@ var require_fetch = __commonJS({
|
|
|
22045
22045
|
if (request2.body == null && fetchParams.processRequestEndOfBody) {
|
|
22046
22046
|
queueMicrotask(() => fetchParams.processRequestEndOfBody());
|
|
22047
22047
|
} else if (request2.body != null) {
|
|
22048
|
-
const processBodyChunk = async function* (
|
|
22048
|
+
const processBodyChunk = async function* (bytes) {
|
|
22049
22049
|
if (isCancelled(fetchParams)) {
|
|
22050
22050
|
return;
|
|
22051
22051
|
}
|
|
22052
|
-
yield
|
|
22053
|
-
fetchParams.processRequestBodyChunkLength?.(
|
|
22052
|
+
yield bytes;
|
|
22053
|
+
fetchParams.processRequestBodyChunkLength?.(bytes.byteLength);
|
|
22054
22054
|
};
|
|
22055
22055
|
const processEndOfBody = () => {
|
|
22056
22056
|
if (isCancelled(fetchParams)) {
|
|
@@ -22072,8 +22072,8 @@ var require_fetch = __commonJS({
|
|
|
22072
22072
|
};
|
|
22073
22073
|
requestBody = (async function* () {
|
|
22074
22074
|
try {
|
|
22075
|
-
for await (const
|
|
22076
|
-
yield* processBodyChunk(
|
|
22075
|
+
for await (const bytes of request2.body.stream) {
|
|
22076
|
+
yield* processBodyChunk(bytes);
|
|
22077
22077
|
}
|
|
22078
22078
|
processEndOfBody();
|
|
22079
22079
|
} catch (err) {
|
|
@@ -22121,33 +22121,33 @@ var require_fetch = __commonJS({
|
|
|
22121
22121
|
}
|
|
22122
22122
|
fetchParams.controller.resume = async () => {
|
|
22123
22123
|
while (true) {
|
|
22124
|
-
let
|
|
22124
|
+
let bytes;
|
|
22125
22125
|
let isFailure;
|
|
22126
22126
|
try {
|
|
22127
22127
|
const { done, value } = await fetchParams.controller.next();
|
|
22128
22128
|
if (isAborted(fetchParams)) {
|
|
22129
22129
|
break;
|
|
22130
22130
|
}
|
|
22131
|
-
|
|
22131
|
+
bytes = done ? void 0 : value;
|
|
22132
22132
|
} catch (err) {
|
|
22133
22133
|
if (fetchParams.controller.ended && !timingInfo.encodedBodySize) {
|
|
22134
|
-
|
|
22134
|
+
bytes = void 0;
|
|
22135
22135
|
} else {
|
|
22136
|
-
|
|
22136
|
+
bytes = err;
|
|
22137
22137
|
isFailure = true;
|
|
22138
22138
|
}
|
|
22139
22139
|
}
|
|
22140
|
-
if (
|
|
22140
|
+
if (bytes === void 0) {
|
|
22141
22141
|
readableStreamClose(fetchParams.controller.controller);
|
|
22142
22142
|
finalizeResponse(fetchParams, response);
|
|
22143
22143
|
return;
|
|
22144
22144
|
}
|
|
22145
|
-
timingInfo.decodedBodySize +=
|
|
22145
|
+
timingInfo.decodedBodySize += bytes?.byteLength ?? 0;
|
|
22146
22146
|
if (isFailure) {
|
|
22147
|
-
fetchParams.controller.terminate(
|
|
22147
|
+
fetchParams.controller.terminate(bytes);
|
|
22148
22148
|
return;
|
|
22149
22149
|
}
|
|
22150
|
-
const buffer = new Uint8Array(
|
|
22150
|
+
const buffer = new Uint8Array(bytes);
|
|
22151
22151
|
if (buffer.byteLength) {
|
|
22152
22152
|
fetchParams.controller.controller.enqueue(buffer);
|
|
22153
22153
|
}
|
|
@@ -22287,9 +22287,9 @@ var require_fetch = __commonJS({
|
|
|
22287
22287
|
if (fetchParams.controller.dump) {
|
|
22288
22288
|
return;
|
|
22289
22289
|
}
|
|
22290
|
-
const
|
|
22291
|
-
timingInfo.encodedBodySize +=
|
|
22292
|
-
return this.body.push(
|
|
22290
|
+
const bytes = chunk;
|
|
22291
|
+
timingInfo.encodedBodySize += bytes.byteLength;
|
|
22292
|
+
return this.body.push(bytes);
|
|
22293
22293
|
},
|
|
22294
22294
|
onComplete() {
|
|
22295
22295
|
if (this.abort) {
|
|
@@ -22620,9 +22620,9 @@ var require_cache3 = __commonJS({
|
|
|
22620
22620
|
// 16.
|
|
22621
22621
|
};
|
|
22622
22622
|
operations.push(operation);
|
|
22623
|
-
const
|
|
22623
|
+
const bytes = await bodyReadPromise.promise;
|
|
22624
22624
|
if (clonedResponse.body != null) {
|
|
22625
|
-
clonedResponse.body.source =
|
|
22625
|
+
clonedResponse.body.source = bytes;
|
|
22626
22626
|
}
|
|
22627
22627
|
const cacheJobPromise = createDeferredPromise();
|
|
22628
22628
|
let errorData = null;
|
|
@@ -24174,7 +24174,7 @@ var require_connection = __commonJS({
|
|
|
24174
24174
|
var { WebsocketFrameSend } = require_frame();
|
|
24175
24175
|
var assert2 = __require("node:assert");
|
|
24176
24176
|
var { runtimeFeatures } = require_runtime_features();
|
|
24177
|
-
var
|
|
24177
|
+
var crypto8 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
|
|
24178
24178
|
var warningEmitted = false;
|
|
24179
24179
|
function establishWebSocketConnection(url2, protocols, client, handler, options) {
|
|
24180
24180
|
const requestURL = url2;
|
|
@@ -24194,7 +24194,7 @@ var require_connection = __commonJS({
|
|
|
24194
24194
|
const headersList = getHeadersList(new Headers2(options.headers));
|
|
24195
24195
|
request2.headersList = headersList;
|
|
24196
24196
|
}
|
|
24197
|
-
const keyValue =
|
|
24197
|
+
const keyValue = crypto8.randomBytes(16).toString("base64");
|
|
24198
24198
|
request2.headersList.append("sec-websocket-key", keyValue, true);
|
|
24199
24199
|
request2.headersList.append("sec-websocket-version", "13", true);
|
|
24200
24200
|
for (const protocol of protocols) {
|
|
@@ -24234,7 +24234,7 @@ var require_connection = __commonJS({
|
|
|
24234
24234
|
return;
|
|
24235
24235
|
}
|
|
24236
24236
|
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
24237
|
-
const digest2 =
|
|
24237
|
+
const digest2 = crypto8.hash("sha1", keyValue + uid, "base64");
|
|
24238
24238
|
if (secWSAccept !== digest2) {
|
|
24239
24239
|
failHandshake(handler, response, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
24240
24240
|
return;
|
|
@@ -26696,7 +26696,7 @@ var require_identity = __commonJS({
|
|
|
26696
26696
|
var NODE_TYPE = /* @__PURE__ */ Symbol.for("yaml.node.type");
|
|
26697
26697
|
var isAlias = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === ALIAS;
|
|
26698
26698
|
var isDocument = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === DOC;
|
|
26699
|
-
var
|
|
26699
|
+
var isMap2 = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === MAP;
|
|
26700
26700
|
var isPair = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === PAIR;
|
|
26701
26701
|
var isScalar = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SCALAR;
|
|
26702
26702
|
var isSeq = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === SEQ;
|
|
@@ -26732,7 +26732,7 @@ var require_identity = __commonJS({
|
|
|
26732
26732
|
exports.isAlias = isAlias;
|
|
26733
26733
|
exports.isCollection = isCollection;
|
|
26734
26734
|
exports.isDocument = isDocument;
|
|
26735
|
-
exports.isMap =
|
|
26735
|
+
exports.isMap = isMap2;
|
|
26736
26736
|
exports.isNode = isNode;
|
|
26737
26737
|
exports.isPair = isPair;
|
|
26738
26738
|
exports.isScalar = isScalar;
|
|
@@ -27386,7 +27386,7 @@ var require_Scalar = __commonJS({
|
|
|
27386
27386
|
var Node = require_Node();
|
|
27387
27387
|
var toJS = require_toJS();
|
|
27388
27388
|
var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object";
|
|
27389
|
-
var
|
|
27389
|
+
var Scalar2 = class extends Node.NodeBase {
|
|
27390
27390
|
constructor(value) {
|
|
27391
27391
|
super(identity.SCALAR);
|
|
27392
27392
|
this.value = value;
|
|
@@ -27398,12 +27398,12 @@ var require_Scalar = __commonJS({
|
|
|
27398
27398
|
return String(this.value);
|
|
27399
27399
|
}
|
|
27400
27400
|
};
|
|
27401
|
-
|
|
27402
|
-
|
|
27403
|
-
|
|
27404
|
-
|
|
27405
|
-
|
|
27406
|
-
exports.Scalar =
|
|
27401
|
+
Scalar2.BLOCK_FOLDED = "BLOCK_FOLDED";
|
|
27402
|
+
Scalar2.BLOCK_LITERAL = "BLOCK_LITERAL";
|
|
27403
|
+
Scalar2.PLAIN = "PLAIN";
|
|
27404
|
+
Scalar2.QUOTE_DOUBLE = "QUOTE_DOUBLE";
|
|
27405
|
+
Scalar2.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
27406
|
+
exports.Scalar = Scalar2;
|
|
27407
27407
|
exports.isScalarValue = isScalarValue;
|
|
27408
27408
|
}
|
|
27409
27409
|
});
|
|
@@ -27414,7 +27414,7 @@ var require_createNode = __commonJS({
|
|
|
27414
27414
|
"use strict";
|
|
27415
27415
|
var Alias = require_Alias();
|
|
27416
27416
|
var identity = require_identity();
|
|
27417
|
-
var
|
|
27417
|
+
var Scalar2 = require_Scalar();
|
|
27418
27418
|
var defaultTagPrefix = "tag:yaml.org,2002:";
|
|
27419
27419
|
function findTagObject(value, tagName, tags) {
|
|
27420
27420
|
if (tagName) {
|
|
@@ -27459,7 +27459,7 @@ var require_createNode = __commonJS({
|
|
|
27459
27459
|
value = value.toJSON();
|
|
27460
27460
|
}
|
|
27461
27461
|
if (!value || typeof value !== "object") {
|
|
27462
|
-
const node3 = new
|
|
27462
|
+
const node3 = new Scalar2.Scalar(value);
|
|
27463
27463
|
if (ref)
|
|
27464
27464
|
ref.node = node3;
|
|
27465
27465
|
return node3;
|
|
@@ -27470,7 +27470,7 @@ var require_createNode = __commonJS({
|
|
|
27470
27470
|
onTagObj(tagObj);
|
|
27471
27471
|
delete ctx.onTagObj;
|
|
27472
27472
|
}
|
|
27473
|
-
const node2 = tagObj?.createNode ? tagObj.createNode(ctx.schema, value, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new
|
|
27473
|
+
const node2 = tagObj?.createNode ? tagObj.createNode(ctx.schema, value, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new Scalar2.Scalar(value);
|
|
27474
27474
|
if (tagName)
|
|
27475
27475
|
node2.tag = tagName;
|
|
27476
27476
|
else if (!tagObj.default)
|
|
@@ -27783,7 +27783,7 @@ ${indent}${text4.slice(fold + 1, end3)}`;
|
|
|
27783
27783
|
var require_stringifyString = __commonJS({
|
|
27784
27784
|
"../cli/node_modules/yaml/dist/stringify/stringifyString.js"(exports) {
|
|
27785
27785
|
"use strict";
|
|
27786
|
-
var
|
|
27786
|
+
var Scalar2 = require_Scalar();
|
|
27787
27787
|
var foldFlowLines = require_foldFlowLines();
|
|
27788
27788
|
var getFoldOptions = (ctx, isBlock) => ({
|
|
27789
27789
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
@@ -27926,7 +27926,7 @@ ${indent}`) + "'";
|
|
|
27926
27926
|
return quotedString(value, ctx);
|
|
27927
27927
|
}
|
|
27928
27928
|
const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? " " : "");
|
|
27929
|
-
const literal2 = blockQuote === "literal" ? true : blockQuote === "folded" || type ===
|
|
27929
|
+
const literal2 = blockQuote === "literal" ? true : blockQuote === "folded" || type === Scalar2.Scalar.BLOCK_FOLDED ? false : type === Scalar2.Scalar.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, lineWidth, indent.length);
|
|
27930
27930
|
if (!value)
|
|
27931
27931
|
return literal2 ? "|\n" : ">\n";
|
|
27932
27932
|
let chomp;
|
|
@@ -27981,7 +27981,7 @@ ${indent}`) + "'";
|
|
|
27981
27981
|
const foldedValue = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`);
|
|
27982
27982
|
let literalFallback = false;
|
|
27983
27983
|
const foldOptions = getFoldOptions(ctx, true);
|
|
27984
|
-
if (blockQuote !== "folded" && type !==
|
|
27984
|
+
if (blockQuote !== "folded" && type !== Scalar2.Scalar.BLOCK_FOLDED) {
|
|
27985
27985
|
foldOptions.onOverflow = () => {
|
|
27986
27986
|
literalFallback = true;
|
|
27987
27987
|
};
|
|
@@ -28004,7 +28004,7 @@ ${indent}${start}${value}${end2}`;
|
|
|
28004
28004
|
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
|
|
28005
28005
|
return implicitKey || inFlow || !value.includes("\n") ? quotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep);
|
|
28006
28006
|
}
|
|
28007
|
-
if (!implicitKey && !inFlow && type !==
|
|
28007
|
+
if (!implicitKey && !inFlow && type !== Scalar2.Scalar.PLAIN && value.includes("\n")) {
|
|
28008
28008
|
return blockString(item, ctx, onComment, onChompKeep);
|
|
28009
28009
|
}
|
|
28010
28010
|
if (containsDocumentMarker(value)) {
|
|
@@ -28029,20 +28029,20 @@ ${indent}`);
|
|
|
28029
28029
|
const { implicitKey, inFlow } = ctx;
|
|
28030
28030
|
const ss = typeof item.value === "string" ? item : Object.assign({}, item, { value: String(item.value) });
|
|
28031
28031
|
let { type } = item;
|
|
28032
|
-
if (type !==
|
|
28032
|
+
if (type !== Scalar2.Scalar.QUOTE_DOUBLE) {
|
|
28033
28033
|
if (/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(ss.value))
|
|
28034
|
-
type =
|
|
28034
|
+
type = Scalar2.Scalar.QUOTE_DOUBLE;
|
|
28035
28035
|
}
|
|
28036
28036
|
const _stringify = (_type) => {
|
|
28037
28037
|
switch (_type) {
|
|
28038
|
-
case
|
|
28039
|
-
case
|
|
28038
|
+
case Scalar2.Scalar.BLOCK_FOLDED:
|
|
28039
|
+
case Scalar2.Scalar.BLOCK_LITERAL:
|
|
28040
28040
|
return implicitKey || inFlow ? quotedString(ss.value, ctx) : blockString(ss, ctx, onComment, onChompKeep);
|
|
28041
|
-
case
|
|
28041
|
+
case Scalar2.Scalar.QUOTE_DOUBLE:
|
|
28042
28042
|
return doubleQuotedString(ss.value, ctx);
|
|
28043
|
-
case
|
|
28043
|
+
case Scalar2.Scalar.QUOTE_SINGLE:
|
|
28044
28044
|
return singleQuotedString(ss.value, ctx);
|
|
28045
|
-
case
|
|
28045
|
+
case Scalar2.Scalar.PLAIN:
|
|
28046
28046
|
return plainString(ss, ctx, onComment, onChompKeep);
|
|
28047
28047
|
default:
|
|
28048
28048
|
return null;
|
|
@@ -28191,7 +28191,7 @@ var require_stringifyPair = __commonJS({
|
|
|
28191
28191
|
"../cli/node_modules/yaml/dist/stringify/stringifyPair.js"(exports) {
|
|
28192
28192
|
"use strict";
|
|
28193
28193
|
var identity = require_identity();
|
|
28194
|
-
var
|
|
28194
|
+
var Scalar2 = require_Scalar();
|
|
28195
28195
|
var stringify = require_stringify();
|
|
28196
28196
|
var stringifyComment = require_stringifyComment();
|
|
28197
28197
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
@@ -28206,7 +28206,7 @@ var require_stringifyPair = __commonJS({
|
|
|
28206
28206
|
throw new Error(msg);
|
|
28207
28207
|
}
|
|
28208
28208
|
}
|
|
28209
|
-
let explicitKey = !simpleKeys && (!key || keyComment && value == null && !ctx.inFlow || identity.isCollection(key) || (identity.isScalar(key) ? key.type ===
|
|
28209
|
+
let explicitKey = !simpleKeys && (!key || keyComment && value == null && !ctx.inFlow || identity.isCollection(key) || (identity.isScalar(key) ? key.type === Scalar2.Scalar.BLOCK_FOLDED || key.type === Scalar2.Scalar.BLOCK_LITERAL : typeof key === "object"));
|
|
28210
28210
|
ctx = Object.assign({}, ctx, {
|
|
28211
28211
|
allNullValues: false,
|
|
28212
28212
|
implicitKey: !explicitKey && (simpleKeys || !allNullValues),
|
|
@@ -28346,19 +28346,19 @@ var require_merge = __commonJS({
|
|
|
28346
28346
|
"../cli/node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports) {
|
|
28347
28347
|
"use strict";
|
|
28348
28348
|
var identity = require_identity();
|
|
28349
|
-
var
|
|
28349
|
+
var Scalar2 = require_Scalar();
|
|
28350
28350
|
var MERGE_KEY = "<<";
|
|
28351
28351
|
var merge2 = {
|
|
28352
28352
|
identify: (value) => value === MERGE_KEY || typeof value === "symbol" && value.description === MERGE_KEY,
|
|
28353
28353
|
default: "key",
|
|
28354
28354
|
tag: "tag:yaml.org,2002:merge",
|
|
28355
28355
|
test: /^<<$/,
|
|
28356
|
-
resolve: () => Object.assign(new
|
|
28356
|
+
resolve: () => Object.assign(new Scalar2.Scalar(Symbol(MERGE_KEY)), {
|
|
28357
28357
|
addToJSMap: addMergeToJSMap
|
|
28358
28358
|
}),
|
|
28359
28359
|
stringify: () => MERGE_KEY
|
|
28360
28360
|
};
|
|
28361
|
-
var isMergeKey = (ctx, key) => (merge2.identify(key) || identity.isScalar(key) && (!key.type || key.type ===
|
|
28361
|
+
var isMergeKey = (ctx, key) => (merge2.identify(key) || identity.isScalar(key) && (!key.type || key.type === Scalar2.Scalar.PLAIN) && merge2.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge2.tag && tag.default);
|
|
28362
28362
|
function addMergeToJSMap(ctx, map3, value) {
|
|
28363
28363
|
const source2 = resolveAliasValue(ctx, value);
|
|
28364
28364
|
if (identity.isSeq(source2))
|
|
@@ -28665,7 +28665,7 @@ var require_YAMLMap = __commonJS({
|
|
|
28665
28665
|
var Collection = require_Collection();
|
|
28666
28666
|
var identity = require_identity();
|
|
28667
28667
|
var Pair = require_Pair();
|
|
28668
|
-
var
|
|
28668
|
+
var Scalar2 = require_Scalar();
|
|
28669
28669
|
function findPair(items, key) {
|
|
28670
28670
|
const k2 = identity.isScalar(key) ? key.value : key;
|
|
28671
28671
|
for (const it2 of items) {
|
|
@@ -28732,7 +28732,7 @@ var require_YAMLMap = __commonJS({
|
|
|
28732
28732
|
if (prev) {
|
|
28733
28733
|
if (!overwrite)
|
|
28734
28734
|
throw new Error(`Key ${_pair.key} already set`);
|
|
28735
|
-
if (identity.isScalar(prev.value) &&
|
|
28735
|
+
if (identity.isScalar(prev.value) && Scalar2.isScalarValue(_pair.value))
|
|
28736
28736
|
prev.value.value = _pair.value;
|
|
28737
28737
|
else
|
|
28738
28738
|
prev.value = _pair.value;
|
|
@@ -28830,7 +28830,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
28830
28830
|
var stringifyCollection = require_stringifyCollection();
|
|
28831
28831
|
var Collection = require_Collection();
|
|
28832
28832
|
var identity = require_identity();
|
|
28833
|
-
var
|
|
28833
|
+
var Scalar2 = require_Scalar();
|
|
28834
28834
|
var toJS = require_toJS();
|
|
28835
28835
|
var YAMLSeq = class extends Collection.Collection {
|
|
28836
28836
|
static get tagName() {
|
|
@@ -28887,7 +28887,7 @@ var require_YAMLSeq = __commonJS({
|
|
|
28887
28887
|
if (typeof idx !== "number")
|
|
28888
28888
|
throw new Error(`Expected a valid index, not ${key}.`);
|
|
28889
28889
|
const prev = this.items[idx];
|
|
28890
|
-
if (identity.isScalar(prev) &&
|
|
28890
|
+
if (identity.isScalar(prev) && Scalar2.isScalarValue(value))
|
|
28891
28891
|
prev.value = value;
|
|
28892
28892
|
else
|
|
28893
28893
|
this.items[idx] = value;
|
|
@@ -28983,14 +28983,14 @@ var require_string = __commonJS({
|
|
|
28983
28983
|
var require_null = __commonJS({
|
|
28984
28984
|
"../cli/node_modules/yaml/dist/schema/common/null.js"(exports) {
|
|
28985
28985
|
"use strict";
|
|
28986
|
-
var
|
|
28986
|
+
var Scalar2 = require_Scalar();
|
|
28987
28987
|
var nullTag = {
|
|
28988
28988
|
identify: (value) => value == null,
|
|
28989
|
-
createNode: () => new
|
|
28989
|
+
createNode: () => new Scalar2.Scalar(null),
|
|
28990
28990
|
default: true,
|
|
28991
28991
|
tag: "tag:yaml.org,2002:null",
|
|
28992
28992
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
28993
|
-
resolve: () => new
|
|
28993
|
+
resolve: () => new Scalar2.Scalar(null),
|
|
28994
28994
|
stringify: ({ source: source2 }, ctx) => typeof source2 === "string" && nullTag.test.test(source2) ? source2 : ctx.options.nullStr
|
|
28995
28995
|
};
|
|
28996
28996
|
exports.nullTag = nullTag;
|
|
@@ -29001,13 +29001,13 @@ var require_null = __commonJS({
|
|
|
29001
29001
|
var require_bool = __commonJS({
|
|
29002
29002
|
"../cli/node_modules/yaml/dist/schema/core/bool.js"(exports) {
|
|
29003
29003
|
"use strict";
|
|
29004
|
-
var
|
|
29004
|
+
var Scalar2 = require_Scalar();
|
|
29005
29005
|
var boolTag = {
|
|
29006
29006
|
identify: (value) => typeof value === "boolean",
|
|
29007
29007
|
default: true,
|
|
29008
29008
|
tag: "tag:yaml.org,2002:bool",
|
|
29009
29009
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
29010
|
-
resolve: (str5) => new
|
|
29010
|
+
resolve: (str5) => new Scalar2.Scalar(str5[0] === "t" || str5[0] === "T"),
|
|
29011
29011
|
stringify({ source: source2, value }, ctx) {
|
|
29012
29012
|
if (source2 && boolTag.test.test(source2)) {
|
|
29013
29013
|
const sv = source2[0] === "t" || source2[0] === "T";
|
|
@@ -29052,7 +29052,7 @@ var require_stringifyNumber = __commonJS({
|
|
|
29052
29052
|
var require_float = __commonJS({
|
|
29053
29053
|
"../cli/node_modules/yaml/dist/schema/core/float.js"(exports) {
|
|
29054
29054
|
"use strict";
|
|
29055
|
-
var
|
|
29055
|
+
var Scalar2 = require_Scalar();
|
|
29056
29056
|
var stringifyNumber = require_stringifyNumber();
|
|
29057
29057
|
var floatNaN = {
|
|
29058
29058
|
identify: (value) => typeof value === "number",
|
|
@@ -29080,7 +29080,7 @@ var require_float = __commonJS({
|
|
|
29080
29080
|
tag: "tag:yaml.org,2002:float",
|
|
29081
29081
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
29082
29082
|
resolve(str5) {
|
|
29083
|
-
const node2 = new
|
|
29083
|
+
const node2 = new Scalar2.Scalar(parseFloat(str5));
|
|
29084
29084
|
const dot = str5.indexOf(".");
|
|
29085
29085
|
if (dot !== -1 && str5[str5.length - 1] === "0")
|
|
29086
29086
|
node2.minFractionDigits = str5.length - dot - 1;
|
|
@@ -29171,7 +29171,7 @@ var require_schema = __commonJS({
|
|
|
29171
29171
|
var require_schema2 = __commonJS({
|
|
29172
29172
|
"../cli/node_modules/yaml/dist/schema/json/schema.js"(exports) {
|
|
29173
29173
|
"use strict";
|
|
29174
|
-
var
|
|
29174
|
+
var Scalar2 = require_Scalar();
|
|
29175
29175
|
var map3 = require_map();
|
|
29176
29176
|
var seq = require_seq();
|
|
29177
29177
|
function intIdentify(value) {
|
|
@@ -29188,7 +29188,7 @@ var require_schema2 = __commonJS({
|
|
|
29188
29188
|
},
|
|
29189
29189
|
{
|
|
29190
29190
|
identify: (value) => value == null,
|
|
29191
|
-
createNode: () => new
|
|
29191
|
+
createNode: () => new Scalar2.Scalar(null),
|
|
29192
29192
|
default: true,
|
|
29193
29193
|
tag: "tag:yaml.org,2002:null",
|
|
29194
29194
|
test: /^null$/,
|
|
@@ -29239,7 +29239,7 @@ var require_binary = __commonJS({
|
|
|
29239
29239
|
"../cli/node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports) {
|
|
29240
29240
|
"use strict";
|
|
29241
29241
|
var node_buffer = __require("buffer");
|
|
29242
|
-
var
|
|
29242
|
+
var Scalar2 = require_Scalar();
|
|
29243
29243
|
var stringifyString = require_stringifyString();
|
|
29244
29244
|
var binary = {
|
|
29245
29245
|
identify: (value) => value instanceof Uint8Array,
|
|
@@ -29283,15 +29283,15 @@ var require_binary = __commonJS({
|
|
|
29283
29283
|
} else {
|
|
29284
29284
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
29285
29285
|
}
|
|
29286
|
-
type ?? (type =
|
|
29287
|
-
if (type !==
|
|
29286
|
+
type ?? (type = Scalar2.Scalar.BLOCK_LITERAL);
|
|
29287
|
+
if (type !== Scalar2.Scalar.QUOTE_DOUBLE) {
|
|
29288
29288
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
29289
29289
|
const n = Math.ceil(str5.length / lineWidth);
|
|
29290
29290
|
const lines = new Array(n);
|
|
29291
29291
|
for (let i = 0, o3 = 0; i < n; ++i, o3 += lineWidth) {
|
|
29292
29292
|
lines[i] = str5.substr(o3, lineWidth);
|
|
29293
29293
|
}
|
|
29294
|
-
str5 = lines.join(type ===
|
|
29294
|
+
str5 = lines.join(type === Scalar2.Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
29295
29295
|
}
|
|
29296
29296
|
return stringifyString.stringifyString({ comment, type, value: str5 }, ctx, onComment, onChompKeep);
|
|
29297
29297
|
}
|
|
@@ -29306,7 +29306,7 @@ var require_pairs = __commonJS({
|
|
|
29306
29306
|
"use strict";
|
|
29307
29307
|
var identity = require_identity();
|
|
29308
29308
|
var Pair = require_Pair();
|
|
29309
|
-
var
|
|
29309
|
+
var Scalar2 = require_Scalar();
|
|
29310
29310
|
var YAMLSeq = require_YAMLSeq();
|
|
29311
29311
|
function resolvePairs(seq, onError) {
|
|
29312
29312
|
if (identity.isSeq(seq)) {
|
|
@@ -29317,7 +29317,7 @@ var require_pairs = __commonJS({
|
|
|
29317
29317
|
else if (identity.isMap(item)) {
|
|
29318
29318
|
if (item.items.length > 1)
|
|
29319
29319
|
onError("Each pair must have its own sequence indicator");
|
|
29320
|
-
const pair = item.items[0] || new Pair.Pair(new
|
|
29320
|
+
const pair = item.items[0] || new Pair.Pair(new Scalar2.Scalar(null));
|
|
29321
29321
|
if (item.commentBefore)
|
|
29322
29322
|
pair.key.commentBefore = pair.key.commentBefore ? `${item.commentBefore}
|
|
29323
29323
|
${pair.key.commentBefore}` : item.commentBefore;
|
|
@@ -29460,7 +29460,7 @@ var require_omap = __commonJS({
|
|
|
29460
29460
|
var require_bool2 = __commonJS({
|
|
29461
29461
|
"../cli/node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports) {
|
|
29462
29462
|
"use strict";
|
|
29463
|
-
var
|
|
29463
|
+
var Scalar2 = require_Scalar();
|
|
29464
29464
|
function boolStringify({ value, source: source2 }, ctx) {
|
|
29465
29465
|
const boolObj = value ? trueTag : falseTag;
|
|
29466
29466
|
if (source2 && boolObj.test.test(source2))
|
|
@@ -29472,7 +29472,7 @@ var require_bool2 = __commonJS({
|
|
|
29472
29472
|
default: true,
|
|
29473
29473
|
tag: "tag:yaml.org,2002:bool",
|
|
29474
29474
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
29475
|
-
resolve: () => new
|
|
29475
|
+
resolve: () => new Scalar2.Scalar(true),
|
|
29476
29476
|
stringify: boolStringify
|
|
29477
29477
|
};
|
|
29478
29478
|
var falseTag = {
|
|
@@ -29480,7 +29480,7 @@ var require_bool2 = __commonJS({
|
|
|
29480
29480
|
default: true,
|
|
29481
29481
|
tag: "tag:yaml.org,2002:bool",
|
|
29482
29482
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
29483
|
-
resolve: () => new
|
|
29483
|
+
resolve: () => new Scalar2.Scalar(false),
|
|
29484
29484
|
stringify: boolStringify
|
|
29485
29485
|
};
|
|
29486
29486
|
exports.falseTag = falseTag;
|
|
@@ -29492,7 +29492,7 @@ var require_bool2 = __commonJS({
|
|
|
29492
29492
|
var require_float2 = __commonJS({
|
|
29493
29493
|
"../cli/node_modules/yaml/dist/schema/yaml-1.1/float.js"(exports) {
|
|
29494
29494
|
"use strict";
|
|
29495
|
-
var
|
|
29495
|
+
var Scalar2 = require_Scalar();
|
|
29496
29496
|
var stringifyNumber = require_stringifyNumber();
|
|
29497
29497
|
var floatNaN = {
|
|
29498
29498
|
identify: (value) => typeof value === "number",
|
|
@@ -29520,7 +29520,7 @@ var require_float2 = __commonJS({
|
|
|
29520
29520
|
tag: "tag:yaml.org,2002:float",
|
|
29521
29521
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
29522
29522
|
resolve(str5) {
|
|
29523
|
-
const node2 = new
|
|
29523
|
+
const node2 = new Scalar2.Scalar(parseFloat(str5.replace(/_/g, "")));
|
|
29524
29524
|
const dot = str5.indexOf(".");
|
|
29525
29525
|
if (dot !== -1) {
|
|
29526
29526
|
const f2 = str5.substring(dot + 1).replace(/_/g, "");
|
|
@@ -30844,9 +30844,9 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
30844
30844
|
var blockMsg = "Block collections are not allowed within flow collections";
|
|
30845
30845
|
var isBlock = (token) => token && (token.type === "block-map" || token.type === "block-seq");
|
|
30846
30846
|
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) {
|
|
30847
|
-
const
|
|
30848
|
-
const fcName =
|
|
30849
|
-
const NodeClass = tag?.nodeClass ?? (
|
|
30847
|
+
const isMap2 = fc.start.source === "{";
|
|
30848
|
+
const fcName = isMap2 ? "flow map" : "flow sequence";
|
|
30849
|
+
const NodeClass = tag?.nodeClass ?? (isMap2 ? YAMLMap.YAMLMap : YAMLSeq.YAMLSeq);
|
|
30850
30850
|
const coll = new NodeClass(ctx.schema);
|
|
30851
30851
|
coll.flow = true;
|
|
30852
30852
|
const atRoot = ctx.atRoot;
|
|
@@ -30882,7 +30882,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
30882
30882
|
offset = props.end;
|
|
30883
30883
|
continue;
|
|
30884
30884
|
}
|
|
30885
|
-
if (!
|
|
30885
|
+
if (!isMap2 && ctx.options.strict && utilContainsNewline.containsNewline(key))
|
|
30886
30886
|
onError(
|
|
30887
30887
|
key,
|
|
30888
30888
|
// checked by containsNewline()
|
|
@@ -30922,7 +30922,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
30922
30922
|
}
|
|
30923
30923
|
}
|
|
30924
30924
|
}
|
|
30925
|
-
if (!
|
|
30925
|
+
if (!isMap2 && !sep && !props.found) {
|
|
30926
30926
|
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError);
|
|
30927
30927
|
coll.items.push(valueNode);
|
|
30928
30928
|
offset = valueNode.range[2];
|
|
@@ -30945,7 +30945,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
30945
30945
|
startOnNewline: false
|
|
30946
30946
|
});
|
|
30947
30947
|
if (valueProps.found) {
|
|
30948
|
-
if (!
|
|
30948
|
+
if (!isMap2 && !props.found && ctx.options.strict) {
|
|
30949
30949
|
if (sep)
|
|
30950
30950
|
for (const st2 of sep) {
|
|
30951
30951
|
if (st2 === valueProps.found)
|
|
@@ -30977,7 +30977,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
30977
30977
|
const pair = new Pair.Pair(keyNode, valueNode);
|
|
30978
30978
|
if (ctx.options.keepSourceTokens)
|
|
30979
30979
|
pair.srcToken = collItem;
|
|
30980
|
-
if (
|
|
30980
|
+
if (isMap2) {
|
|
30981
30981
|
const map3 = coll;
|
|
30982
30982
|
if (utilMapIncludes.mapIncludes(ctx, map3.items, keyNode))
|
|
30983
30983
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
@@ -30993,7 +30993,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
30993
30993
|
offset = valueNode ? valueNode.range[2] : valueProps.end;
|
|
30994
30994
|
}
|
|
30995
30995
|
}
|
|
30996
|
-
const expectedEnd =
|
|
30996
|
+
const expectedEnd = isMap2 ? "}" : "]";
|
|
30997
30997
|
const [ce2, ...ee3] = fc.end;
|
|
30998
30998
|
let cePos = offset;
|
|
30999
30999
|
if (ce2?.source === expectedEnd)
|
|
@@ -31028,7 +31028,7 @@ var require_compose_collection = __commonJS({
|
|
|
31028
31028
|
"../cli/node_modules/yaml/dist/compose/compose-collection.js"(exports) {
|
|
31029
31029
|
"use strict";
|
|
31030
31030
|
var identity = require_identity();
|
|
31031
|
-
var
|
|
31031
|
+
var Scalar2 = require_Scalar();
|
|
31032
31032
|
var YAMLMap = require_YAMLMap();
|
|
31033
31033
|
var YAMLSeq = require_YAMLSeq();
|
|
31034
31034
|
var resolveBlockMap = require_resolve_block_map();
|
|
@@ -31077,7 +31077,7 @@ var require_compose_collection = __commonJS({
|
|
|
31077
31077
|
}
|
|
31078
31078
|
const coll = resolveCollection(CN, ctx, token, onError, tagName, tag);
|
|
31079
31079
|
const res = tag.resolve?.(coll, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg), ctx.options) ?? coll;
|
|
31080
|
-
const node2 = identity.isNode(res) ? res : new
|
|
31080
|
+
const node2 = identity.isNode(res) ? res : new Scalar2.Scalar(res);
|
|
31081
31081
|
node2.range = coll.range;
|
|
31082
31082
|
node2.tag = tagName;
|
|
31083
31083
|
if (tag?.format)
|
|
@@ -31092,13 +31092,13 @@ var require_compose_collection = __commonJS({
|
|
|
31092
31092
|
var require_resolve_block_scalar = __commonJS({
|
|
31093
31093
|
"../cli/node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports) {
|
|
31094
31094
|
"use strict";
|
|
31095
|
-
var
|
|
31095
|
+
var Scalar2 = require_Scalar();
|
|
31096
31096
|
function resolveBlockScalar(ctx, scalar, onError) {
|
|
31097
31097
|
const start = scalar.offset;
|
|
31098
31098
|
const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
|
|
31099
31099
|
if (!header)
|
|
31100
31100
|
return { value: "", type: null, comment: "", range: [start, start, start] };
|
|
31101
|
-
const type = header.mode === ">" ?
|
|
31101
|
+
const type = header.mode === ">" ? Scalar2.Scalar.BLOCK_FOLDED : Scalar2.Scalar.BLOCK_LITERAL;
|
|
31102
31102
|
const lines = scalar.source ? splitLines(scalar.source) : [];
|
|
31103
31103
|
let chompStart = lines.length;
|
|
31104
31104
|
for (let i = lines.length - 1; i >= 0; --i) {
|
|
@@ -31160,7 +31160,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
31160
31160
|
onError(offset - content.length - (crlf ? 2 : 1), "BAD_INDENT", message);
|
|
31161
31161
|
indent = "";
|
|
31162
31162
|
}
|
|
31163
|
-
if (type ===
|
|
31163
|
+
if (type === Scalar2.Scalar.BLOCK_LITERAL) {
|
|
31164
31164
|
value += sep + indent.slice(trimIndent) + content;
|
|
31165
31165
|
sep = "\n";
|
|
31166
31166
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
@@ -31275,7 +31275,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
31275
31275
|
var require_resolve_flow_scalar = __commonJS({
|
|
31276
31276
|
"../cli/node_modules/yaml/dist/compose/resolve-flow-scalar.js"(exports) {
|
|
31277
31277
|
"use strict";
|
|
31278
|
-
var
|
|
31278
|
+
var Scalar2 = require_Scalar();
|
|
31279
31279
|
var resolveEnd = require_resolve_end();
|
|
31280
31280
|
function resolveFlowScalar(scalar, strict, onError) {
|
|
31281
31281
|
const { offset, type, source: source2, end: end2 } = scalar;
|
|
@@ -31284,15 +31284,15 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
31284
31284
|
const _onError = (rel3, code, msg) => onError(offset + rel3, code, msg);
|
|
31285
31285
|
switch (type) {
|
|
31286
31286
|
case "scalar":
|
|
31287
|
-
_type =
|
|
31287
|
+
_type = Scalar2.Scalar.PLAIN;
|
|
31288
31288
|
value = plainValue(source2, _onError);
|
|
31289
31289
|
break;
|
|
31290
31290
|
case "single-quoted-scalar":
|
|
31291
|
-
_type =
|
|
31291
|
+
_type = Scalar2.Scalar.QUOTE_SINGLE;
|
|
31292
31292
|
value = singleQuotedValue(source2, _onError);
|
|
31293
31293
|
break;
|
|
31294
31294
|
case "double-quoted-scalar":
|
|
31295
|
-
_type =
|
|
31295
|
+
_type = Scalar2.Scalar.QUOTE_DOUBLE;
|
|
31296
31296
|
value = doubleQuotedValue(source2, _onError);
|
|
31297
31297
|
break;
|
|
31298
31298
|
/* istanbul ignore next should not happen */
|
|
@@ -31497,7 +31497,7 @@ var require_compose_scalar = __commonJS({
|
|
|
31497
31497
|
"../cli/node_modules/yaml/dist/compose/compose-scalar.js"(exports) {
|
|
31498
31498
|
"use strict";
|
|
31499
31499
|
var identity = require_identity();
|
|
31500
|
-
var
|
|
31500
|
+
var Scalar2 = require_Scalar();
|
|
31501
31501
|
var resolveBlockScalar = require_resolve_block_scalar();
|
|
31502
31502
|
var resolveFlowScalar = require_resolve_flow_scalar();
|
|
31503
31503
|
function composeScalar(ctx, token, tagToken, onError) {
|
|
@@ -31515,11 +31515,11 @@ var require_compose_scalar = __commonJS({
|
|
|
31515
31515
|
let scalar;
|
|
31516
31516
|
try {
|
|
31517
31517
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
31518
|
-
scalar = identity.isScalar(res) ? res : new
|
|
31518
|
+
scalar = identity.isScalar(res) ? res : new Scalar2.Scalar(res);
|
|
31519
31519
|
} catch (error62) {
|
|
31520
31520
|
const msg = error62 instanceof Error ? error62.message : String(error62);
|
|
31521
31521
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
31522
|
-
scalar = new
|
|
31522
|
+
scalar = new Scalar2.Scalar(value);
|
|
31523
31523
|
}
|
|
31524
31524
|
scalar.range = range;
|
|
31525
31525
|
scalar.source = value;
|
|
@@ -33894,7 +33894,7 @@ var require_public_api = __commonJS({
|
|
|
33894
33894
|
return docs;
|
|
33895
33895
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
33896
33896
|
}
|
|
33897
|
-
function
|
|
33897
|
+
function parseDocument4(source2, options = {}) {
|
|
33898
33898
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
33899
33899
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
33900
33900
|
const composer$1 = new composer.Composer(options);
|
|
@@ -33920,7 +33920,7 @@ var require_public_api = __commonJS({
|
|
|
33920
33920
|
} else if (options === void 0 && reviver && typeof reviver === "object") {
|
|
33921
33921
|
options = reviver;
|
|
33922
33922
|
}
|
|
33923
|
-
const doc =
|
|
33923
|
+
const doc = parseDocument4(src, options);
|
|
33924
33924
|
if (!doc)
|
|
33925
33925
|
return null;
|
|
33926
33926
|
doc.warnings.forEach((warning) => log.warn(doc.options.logLevel, warning));
|
|
@@ -33956,7 +33956,7 @@ var require_public_api = __commonJS({
|
|
|
33956
33956
|
}
|
|
33957
33957
|
exports.parse = parse4;
|
|
33958
33958
|
exports.parseAllDocuments = parseAllDocuments;
|
|
33959
|
-
exports.parseDocument =
|
|
33959
|
+
exports.parseDocument = parseDocument4;
|
|
33960
33960
|
exports.stringify = stringify;
|
|
33961
33961
|
}
|
|
33962
33962
|
});
|
|
@@ -33972,7 +33972,7 @@ var require_dist = __commonJS({
|
|
|
33972
33972
|
var Alias = require_Alias();
|
|
33973
33973
|
var identity = require_identity();
|
|
33974
33974
|
var Pair = require_Pair();
|
|
33975
|
-
var
|
|
33975
|
+
var Scalar2 = require_Scalar();
|
|
33976
33976
|
var YAMLMap = require_YAMLMap();
|
|
33977
33977
|
var YAMLSeq = require_YAMLSeq();
|
|
33978
33978
|
var cst = require_cst();
|
|
@@ -33997,7 +33997,7 @@ var require_dist = __commonJS({
|
|
|
33997
33997
|
exports.isScalar = identity.isScalar;
|
|
33998
33998
|
exports.isSeq = identity.isSeq;
|
|
33999
33999
|
exports.Pair = Pair.Pair;
|
|
34000
|
-
exports.Scalar =
|
|
34000
|
+
exports.Scalar = Scalar2.Scalar;
|
|
34001
34001
|
exports.YAMLMap = YAMLMap.YAMLMap;
|
|
34002
34002
|
exports.YAMLSeq = YAMLSeq.YAMLSeq;
|
|
34003
34003
|
exports.CST = cst;
|
|
@@ -34013,16 +34013,6 @@ var require_dist = __commonJS({
|
|
|
34013
34013
|
}
|
|
34014
34014
|
});
|
|
34015
34015
|
|
|
34016
|
-
// ../cli/src/lib/shared/file-limits.ts
|
|
34017
|
-
var BOARD_FILE_LIMIT, ASSET_FILE_LIMIT;
|
|
34018
|
-
var init_file_limits = __esm({
|
|
34019
|
-
"../cli/src/lib/shared/file-limits.ts"() {
|
|
34020
|
-
"use strict";
|
|
34021
|
-
BOARD_FILE_LIMIT = 10 * 1024 * 1024;
|
|
34022
|
-
ASSET_FILE_LIMIT = 100 * 1024 * 1024;
|
|
34023
|
-
}
|
|
34024
|
-
});
|
|
34025
|
-
|
|
34026
34016
|
// ../cli/node_modules/ajv/dist/compile/codegen/code.js
|
|
34027
34017
|
var require_code = __commonJS({
|
|
34028
34018
|
"../cli/node_modules/ajv/dist/compile/codegen/code.js"(exports) {
|
|
@@ -39100,8 +39090,8 @@ var require_multipleOf = __commonJS({
|
|
|
39100
39090
|
const { gen, data, schemaCode, it: it2 } = cxt;
|
|
39101
39091
|
const prec = it2.opts.multipleOfPrecision;
|
|
39102
39092
|
const res = gen.let("res");
|
|
39103
|
-
const
|
|
39104
|
-
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${
|
|
39093
|
+
const invalid2 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
|
|
39094
|
+
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid2}))`);
|
|
39105
39095
|
}
|
|
39106
39096
|
};
|
|
39107
39097
|
exports.default = def;
|
|
@@ -40928,6 +40918,16 @@ var require_ajv = __commonJS({
|
|
|
40928
40918
|
}
|
|
40929
40919
|
});
|
|
40930
40920
|
|
|
40921
|
+
// ../cli/src/lib/shared/file-limits.ts
|
|
40922
|
+
var BOARD_FILE_LIMIT, ASSET_FILE_LIMIT;
|
|
40923
|
+
var init_file_limits = __esm({
|
|
40924
|
+
"../cli/src/lib/shared/file-limits.ts"() {
|
|
40925
|
+
"use strict";
|
|
40926
|
+
BOARD_FILE_LIMIT = 10 * 1024 * 1024;
|
|
40927
|
+
ASSET_FILE_LIMIT = 100 * 1024 * 1024;
|
|
40928
|
+
}
|
|
40929
|
+
});
|
|
40930
|
+
|
|
40931
40931
|
// ../cli/src/lib/dress-page.ts
|
|
40932
40932
|
import fs40 from "node:fs";
|
|
40933
40933
|
import path41 from "node:path";
|
|
@@ -43201,9 +43201,9 @@ var require_react_dom_server_legacy_node_production = __commonJS({
|
|
|
43201
43201
|
var isArrayImpl = Array.isArray;
|
|
43202
43202
|
function murmurhash3_32_gc(key, seed) {
|
|
43203
43203
|
var remainder = key.length & 3;
|
|
43204
|
-
var
|
|
43204
|
+
var bytes = key.length - remainder;
|
|
43205
43205
|
var h1 = seed;
|
|
43206
|
-
for (seed = 0; seed <
|
|
43206
|
+
for (seed = 0; seed < bytes; ) {
|
|
43207
43207
|
var k1 = key.charCodeAt(seed) & 255 | (key.charCodeAt(++seed) & 255) << 8 | (key.charCodeAt(++seed) & 255) << 16 | (key.charCodeAt(++seed) & 255) << 24;
|
|
43208
43208
|
++seed;
|
|
43209
43209
|
k1 = 3432918353 * (k1 & 65535) + ((3432918353 * (k1 >>> 16) & 65535) << 16) & 4294967295;
|
|
@@ -48423,7 +48423,7 @@ var require_react_dom_server_node_production = __commonJS({
|
|
|
48423
48423
|
"../cli/node_modules/react-dom/cjs/react-dom-server.node.production.js"(exports) {
|
|
48424
48424
|
"use strict";
|
|
48425
48425
|
var util = __require("util");
|
|
48426
|
-
var
|
|
48426
|
+
var crypto8 = __require("crypto");
|
|
48427
48427
|
var async_hooks = __require("async_hooks");
|
|
48428
48428
|
var React4 = require_react();
|
|
48429
48429
|
var ReactDOM = require_react_dom();
|
|
@@ -51288,7 +51288,7 @@ var require_react_dom_server_node_production = __commonJS({
|
|
|
51288
51288
|
function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex) {
|
|
51289
51289
|
if (void 0 !== permalink) return "p" + permalink;
|
|
51290
51290
|
permalink = JSON.stringify([componentKeyPath, null, hookIndex]);
|
|
51291
|
-
componentKeyPath =
|
|
51291
|
+
componentKeyPath = crypto8.createHash("md5");
|
|
51292
51292
|
componentKeyPath.update(permalink);
|
|
51293
51293
|
return "k" + componentKeyPath.digest("hex");
|
|
51294
51294
|
}
|
|
@@ -54711,9 +54711,9 @@ var require_react_dom_server_legacy_node_development = __commonJS({
|
|
|
54711
54711
|
}
|
|
54712
54712
|
function murmurhash3_32_gc(key, seed) {
|
|
54713
54713
|
var remainder = key.length & 3;
|
|
54714
|
-
var
|
|
54714
|
+
var bytes = key.length - remainder;
|
|
54715
54715
|
var h1 = seed;
|
|
54716
|
-
for (seed = 0; seed <
|
|
54716
|
+
for (seed = 0; seed < bytes; ) {
|
|
54717
54717
|
var k1 = key.charCodeAt(seed) & 255 | (key.charCodeAt(++seed) & 255) << 8 | (key.charCodeAt(++seed) & 255) << 16 | (key.charCodeAt(++seed) & 255) << 24;
|
|
54718
54718
|
++seed;
|
|
54719
54719
|
k1 = 3432918353 * (k1 & 65535) + ((3432918353 * (k1 >>> 16) & 65535) << 16) & 4294967295;
|
|
@@ -65282,7 +65282,7 @@ var require_react_dom_server_node_development = __commonJS({
|
|
|
65282
65282
|
function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex) {
|
|
65283
65283
|
if (void 0 !== permalink) return "p" + permalink;
|
|
65284
65284
|
permalink = JSON.stringify([componentKeyPath, null, hookIndex]);
|
|
65285
|
-
componentKeyPath =
|
|
65285
|
+
componentKeyPath = crypto8.createHash("md5");
|
|
65286
65286
|
componentKeyPath.update(permalink);
|
|
65287
65287
|
return "k" + componentKeyPath.digest("hex");
|
|
65288
65288
|
}
|
|
@@ -68944,7 +68944,7 @@ var require_react_dom_server_node_development = __commonJS({
|
|
|
68944
68944
|
}
|
|
68945
68945
|
};
|
|
68946
68946
|
}
|
|
68947
|
-
var util = __require("util"),
|
|
68947
|
+
var util = __require("util"), crypto8 = __require("crypto"), async_hooks = __require("async_hooks"), React4 = require_react(), ReactDOM = require_react_dom(), stream = __require("stream"), REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_SCOPE_TYPE = /* @__PURE__ */ Symbol.for("react.scope"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), REACT_LEGACY_HIDDEN_TYPE = /* @__PURE__ */ Symbol.for("react.legacy_hidden"), REACT_MEMO_CACHE_SENTINEL = /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), REACT_RECOVERABLE_TYPE = /* @__PURE__ */ Symbol.for("react.recoverable"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, ASYNC_ITERATOR = Symbol.asyncIterator, REACT_OPTIMISTIC_KEY = /* @__PURE__ */ Symbol.for("react.optimistic_key"), isArrayImpl = Array.isArray, jsxPropsParents = /* @__PURE__ */ new WeakMap(), jsxChildrenParents = /* @__PURE__ */ new WeakMap(), CLIENT_REFERENCE_TAG = /* @__PURE__ */ Symbol.for("react.client.reference"), hasOwnProperty = Object.prototype.hasOwnProperty, supportsArrayBufferDetached = hasOwnProperty.call(
|
|
68948
68948
|
ArrayBuffer.prototype,
|
|
68949
68949
|
"detached"
|
|
68950
68950
|
), didWarnAboutMissingArrayBufferDetached = false, scheduleMicrotask = queueMicrotask, currentView = null, writtenBytes = 0, destinationHasCapacity$1 = true, textEncoder = new util.TextEncoder(), assign = Object.assign, VALID_ATTRIBUTE_NAME_REGEX = RegExp(
|
|
@@ -127502,8 +127502,8 @@ var require_lib = __commonJS({
|
|
|
127502
127502
|
this.p = null;
|
|
127503
127503
|
}
|
|
127504
127504
|
};
|
|
127505
|
-
Unzip2.prototype.register = function(
|
|
127506
|
-
this.o[
|
|
127505
|
+
Unzip2.prototype.register = function(decoder2) {
|
|
127506
|
+
this.o[decoder2.compression] = decoder2;
|
|
127507
127507
|
};
|
|
127508
127508
|
return Unzip2;
|
|
127509
127509
|
})();
|
|
@@ -127981,14 +127981,14 @@ var require_base64 = __commonJS({
|
|
|
127981
127981
|
lookup[chars.charCodeAt(i)] = i;
|
|
127982
127982
|
}
|
|
127983
127983
|
var i;
|
|
127984
|
-
exports.encodeToBase64 = function(
|
|
127984
|
+
exports.encodeToBase64 = function(bytes) {
|
|
127985
127985
|
var base643 = "";
|
|
127986
|
-
var len =
|
|
127986
|
+
var len = bytes.length;
|
|
127987
127987
|
for (var i2 = 0; i2 < len; i2 += 3) {
|
|
127988
|
-
base643 += chars[
|
|
127989
|
-
base643 += chars[(
|
|
127990
|
-
base643 += chars[(
|
|
127991
|
-
base643 += chars[
|
|
127988
|
+
base643 += chars[bytes[i2] >> 2];
|
|
127989
|
+
base643 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
|
|
127990
|
+
base643 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
|
|
127991
|
+
base643 += chars[bytes[i2 + 2] & 63];
|
|
127992
127992
|
}
|
|
127993
127993
|
if (len % 3 === 2) {
|
|
127994
127994
|
base643 = base643.substring(0, base643.length - 1) + "=";
|
|
@@ -128012,17 +128012,17 @@ var require_base64 = __commonJS({
|
|
|
128012
128012
|
bufferLength--;
|
|
128013
128013
|
}
|
|
128014
128014
|
}
|
|
128015
|
-
var
|
|
128015
|
+
var bytes = new Uint8Array(bufferLength);
|
|
128016
128016
|
for (i2 = 0; i2 < len; i2 += 4) {
|
|
128017
128017
|
encoded1 = lookup[base643.charCodeAt(i2)];
|
|
128018
128018
|
encoded2 = lookup[base643.charCodeAt(i2 + 1)];
|
|
128019
128019
|
encoded3 = lookup[base643.charCodeAt(i2 + 2)];
|
|
128020
128020
|
encoded4 = lookup[base643.charCodeAt(i2 + 3)];
|
|
128021
|
-
|
|
128022
|
-
|
|
128023
|
-
|
|
128021
|
+
bytes[p2++] = encoded1 << 2 | encoded2 >> 4;
|
|
128022
|
+
bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
|
128023
|
+
bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
|
128024
128024
|
}
|
|
128025
|
-
return
|
|
128025
|
+
return bytes;
|
|
128026
128026
|
};
|
|
128027
128027
|
var DATA_URI_PREFIX_REGEX = /^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i;
|
|
128028
128028
|
exports.decodeFromBase64DataUri = function(dataUri) {
|
|
@@ -128463,17 +128463,17 @@ var require_unicode = __commonJS({
|
|
|
128463
128463
|
return first << 8 | second;
|
|
128464
128464
|
throw new Error("Invalid byteOrder: " + byteOrder);
|
|
128465
128465
|
};
|
|
128466
|
-
var readBOM = function(
|
|
128467
|
-
return hasUtf16BigEndianBOM(
|
|
128466
|
+
var readBOM = function(bytes) {
|
|
128467
|
+
return hasUtf16BigEndianBOM(bytes) ? ByteOrder.BigEndian : hasUtf16LittleEndianBOM(bytes) ? ByteOrder.LittleEndian : ByteOrder.BigEndian;
|
|
128468
128468
|
};
|
|
128469
|
-
var hasUtf16BigEndianBOM = function(
|
|
128470
|
-
return
|
|
128469
|
+
var hasUtf16BigEndianBOM = function(bytes) {
|
|
128470
|
+
return bytes[0] === 254 && bytes[1] === 255;
|
|
128471
128471
|
};
|
|
128472
|
-
var hasUtf16LittleEndianBOM = function(
|
|
128473
|
-
return
|
|
128472
|
+
var hasUtf16LittleEndianBOM = function(bytes) {
|
|
128473
|
+
return bytes[0] === 255 && bytes[1] === 254;
|
|
128474
128474
|
};
|
|
128475
|
-
exports.hasUtf16BOM = function(
|
|
128476
|
-
return hasUtf16BigEndianBOM(
|
|
128475
|
+
exports.hasUtf16BOM = function(bytes) {
|
|
128476
|
+
return hasUtf16BigEndianBOM(bytes) || hasUtf16LittleEndianBOM(bytes);
|
|
128477
128477
|
};
|
|
128478
128478
|
}
|
|
128479
128479
|
});
|
|
@@ -128511,11 +128511,11 @@ var require_numbers = __commonJS({
|
|
|
128511
128511
|
return Math.ceil(n.toString(2).length / 8);
|
|
128512
128512
|
};
|
|
128513
128513
|
exports.bytesFor = function(n) {
|
|
128514
|
-
var
|
|
128515
|
-
for (var i = 1; i <=
|
|
128516
|
-
|
|
128514
|
+
var bytes = new Uint8Array(exports.sizeInBytes(n));
|
|
128515
|
+
for (var i = 1; i <= bytes.length; i++) {
|
|
128516
|
+
bytes[i - 1] = n >> (bytes.length - i) * 8;
|
|
128517
128517
|
}
|
|
128518
|
-
return
|
|
128518
|
+
return bytes;
|
|
128519
128519
|
};
|
|
128520
128520
|
}
|
|
128521
128521
|
});
|
|
@@ -129302,16 +129302,16 @@ var require_crc32 = __commonJS({
|
|
|
129302
129302
|
}
|
|
129303
129303
|
return table;
|
|
129304
129304
|
}
|
|
129305
|
-
var
|
|
129306
|
-
function
|
|
129307
|
-
var t =
|
|
129305
|
+
var crcTable2 = makeTable();
|
|
129306
|
+
function crc322(crc, buf, len, pos) {
|
|
129307
|
+
var t = crcTable2, end2 = pos + len;
|
|
129308
129308
|
crc ^= -1;
|
|
129309
129309
|
for (var i = pos; i < end2; i++) {
|
|
129310
129310
|
crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];
|
|
129311
129311
|
}
|
|
129312
129312
|
return crc ^ -1;
|
|
129313
129313
|
}
|
|
129314
|
-
module.exports =
|
|
129314
|
+
module.exports = crc322;
|
|
129315
129315
|
}
|
|
129316
129316
|
});
|
|
129317
129317
|
|
|
@@ -129349,7 +129349,7 @@ var require_deflate = __commonJS({
|
|
|
129349
129349
|
var utils = require_common();
|
|
129350
129350
|
var trees = require_trees();
|
|
129351
129351
|
var adler32 = require_adler32();
|
|
129352
|
-
var
|
|
129352
|
+
var crc322 = require_crc32();
|
|
129353
129353
|
var msg = require_messages();
|
|
129354
129354
|
var Z_NO_FLUSH = 0;
|
|
129355
129355
|
var Z_PARTIAL_FLUSH = 1;
|
|
@@ -129452,7 +129452,7 @@ var require_deflate = __commonJS({
|
|
|
129452
129452
|
if (strm.state.wrap === 1) {
|
|
129453
129453
|
strm.adler = adler32(strm.adler, buf, len, start);
|
|
129454
129454
|
} else if (strm.state.wrap === 2) {
|
|
129455
|
-
strm.adler =
|
|
129455
|
+
strm.adler = crc322(strm.adler, buf, len, start);
|
|
129456
129456
|
}
|
|
129457
129457
|
strm.next_in += len;
|
|
129458
129458
|
strm.total_in += len;
|
|
@@ -130094,7 +130094,7 @@ var require_deflate = __commonJS({
|
|
|
130094
130094
|
put_byte(s, s.gzhead.extra.length >> 8 & 255);
|
|
130095
130095
|
}
|
|
130096
130096
|
if (s.gzhead.hcrc) {
|
|
130097
|
-
strm.adler =
|
|
130097
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);
|
|
130098
130098
|
}
|
|
130099
130099
|
s.gzindex = 0;
|
|
130100
130100
|
s.status = EXTRA_STATE;
|
|
@@ -130131,7 +130131,7 @@ var require_deflate = __commonJS({
|
|
|
130131
130131
|
while (s.gzindex < (s.gzhead.extra.length & 65535)) {
|
|
130132
130132
|
if (s.pending === s.pending_buf_size) {
|
|
130133
130133
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
130134
|
-
strm.adler =
|
|
130134
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
130135
130135
|
}
|
|
130136
130136
|
flush_pending(strm);
|
|
130137
130137
|
beg = s.pending;
|
|
@@ -130143,7 +130143,7 @@ var require_deflate = __commonJS({
|
|
|
130143
130143
|
s.gzindex++;
|
|
130144
130144
|
}
|
|
130145
130145
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
130146
|
-
strm.adler =
|
|
130146
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
130147
130147
|
}
|
|
130148
130148
|
if (s.gzindex === s.gzhead.extra.length) {
|
|
130149
130149
|
s.gzindex = 0;
|
|
@@ -130159,7 +130159,7 @@ var require_deflate = __commonJS({
|
|
|
130159
130159
|
do {
|
|
130160
130160
|
if (s.pending === s.pending_buf_size) {
|
|
130161
130161
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
130162
|
-
strm.adler =
|
|
130162
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
130163
130163
|
}
|
|
130164
130164
|
flush_pending(strm);
|
|
130165
130165
|
beg = s.pending;
|
|
@@ -130176,7 +130176,7 @@ var require_deflate = __commonJS({
|
|
|
130176
130176
|
put_byte(s, val);
|
|
130177
130177
|
} while (val !== 0);
|
|
130178
130178
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
130179
|
-
strm.adler =
|
|
130179
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
130180
130180
|
}
|
|
130181
130181
|
if (val === 0) {
|
|
130182
130182
|
s.gzindex = 0;
|
|
@@ -130192,7 +130192,7 @@ var require_deflate = __commonJS({
|
|
|
130192
130192
|
do {
|
|
130193
130193
|
if (s.pending === s.pending_buf_size) {
|
|
130194
130194
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
130195
|
-
strm.adler =
|
|
130195
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
130196
130196
|
}
|
|
130197
130197
|
flush_pending(strm);
|
|
130198
130198
|
beg = s.pending;
|
|
@@ -130209,7 +130209,7 @@ var require_deflate = __commonJS({
|
|
|
130209
130209
|
put_byte(s, val);
|
|
130210
130210
|
} while (val !== 0);
|
|
130211
130211
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
130212
|
-
strm.adler =
|
|
130212
|
+
strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
130213
130213
|
}
|
|
130214
130214
|
if (val === 0) {
|
|
130215
130215
|
s.status = HCRC_STATE;
|
|
@@ -131267,7 +131267,7 @@ var require_inflate = __commonJS({
|
|
|
131267
131267
|
"use strict";
|
|
131268
131268
|
var utils = require_common();
|
|
131269
131269
|
var adler32 = require_adler32();
|
|
131270
|
-
var
|
|
131270
|
+
var crc322 = require_crc32();
|
|
131271
131271
|
var inflate_fast = require_inffast();
|
|
131272
131272
|
var inflate_table = require_inftrees();
|
|
131273
131273
|
var CODES = 0;
|
|
@@ -131571,7 +131571,7 @@ var require_inflate = __commonJS({
|
|
|
131571
131571
|
state.check = 0;
|
|
131572
131572
|
hbuf[0] = hold2 & 255;
|
|
131573
131573
|
hbuf[1] = hold2 >>> 8 & 255;
|
|
131574
|
-
state.check =
|
|
131574
|
+
state.check = crc322(state.check, hbuf, 2, 0);
|
|
131575
131575
|
hold2 = 0;
|
|
131576
131576
|
bits = 0;
|
|
131577
131577
|
state.mode = FLAGS;
|
|
@@ -131634,7 +131634,7 @@ var require_inflate = __commonJS({
|
|
|
131634
131634
|
if (state.flags & 512) {
|
|
131635
131635
|
hbuf[0] = hold2 & 255;
|
|
131636
131636
|
hbuf[1] = hold2 >>> 8 & 255;
|
|
131637
|
-
state.check =
|
|
131637
|
+
state.check = crc322(state.check, hbuf, 2, 0);
|
|
131638
131638
|
}
|
|
131639
131639
|
hold2 = 0;
|
|
131640
131640
|
bits = 0;
|
|
@@ -131657,7 +131657,7 @@ var require_inflate = __commonJS({
|
|
|
131657
131657
|
hbuf[1] = hold2 >>> 8 & 255;
|
|
131658
131658
|
hbuf[2] = hold2 >>> 16 & 255;
|
|
131659
131659
|
hbuf[3] = hold2 >>> 24 & 255;
|
|
131660
|
-
state.check =
|
|
131660
|
+
state.check = crc322(state.check, hbuf, 4, 0);
|
|
131661
131661
|
}
|
|
131662
131662
|
hold2 = 0;
|
|
131663
131663
|
bits = 0;
|
|
@@ -131679,7 +131679,7 @@ var require_inflate = __commonJS({
|
|
|
131679
131679
|
if (state.flags & 512) {
|
|
131680
131680
|
hbuf[0] = hold2 & 255;
|
|
131681
131681
|
hbuf[1] = hold2 >>> 8 & 255;
|
|
131682
|
-
state.check =
|
|
131682
|
+
state.check = crc322(state.check, hbuf, 2, 0);
|
|
131683
131683
|
}
|
|
131684
131684
|
hold2 = 0;
|
|
131685
131685
|
bits = 0;
|
|
@@ -131702,7 +131702,7 @@ var require_inflate = __commonJS({
|
|
|
131702
131702
|
if (state.flags & 512) {
|
|
131703
131703
|
hbuf[0] = hold2 & 255;
|
|
131704
131704
|
hbuf[1] = hold2 >>> 8 & 255;
|
|
131705
|
-
state.check =
|
|
131705
|
+
state.check = crc322(state.check, hbuf, 2, 0);
|
|
131706
131706
|
}
|
|
131707
131707
|
hold2 = 0;
|
|
131708
131708
|
bits = 0;
|
|
@@ -131735,7 +131735,7 @@ var require_inflate = __commonJS({
|
|
|
131735
131735
|
);
|
|
131736
131736
|
}
|
|
131737
131737
|
if (state.flags & 512) {
|
|
131738
|
-
state.check =
|
|
131738
|
+
state.check = crc322(state.check, input2, copy2, next);
|
|
131739
131739
|
}
|
|
131740
131740
|
have -= copy2;
|
|
131741
131741
|
next += copy2;
|
|
@@ -131761,7 +131761,7 @@ var require_inflate = __commonJS({
|
|
|
131761
131761
|
}
|
|
131762
131762
|
} while (len && copy2 < have);
|
|
131763
131763
|
if (state.flags & 512) {
|
|
131764
|
-
state.check =
|
|
131764
|
+
state.check = crc322(state.check, input2, copy2, next);
|
|
131765
131765
|
}
|
|
131766
131766
|
have -= copy2;
|
|
131767
131767
|
next += copy2;
|
|
@@ -131787,7 +131787,7 @@ var require_inflate = __commonJS({
|
|
|
131787
131787
|
}
|
|
131788
131788
|
} while (len && copy2 < have);
|
|
131789
131789
|
if (state.flags & 512) {
|
|
131790
|
-
state.check =
|
|
131790
|
+
state.check = crc322(state.check, input2, copy2, next);
|
|
131791
131791
|
}
|
|
131792
131792
|
have -= copy2;
|
|
131793
131793
|
next += copy2;
|
|
@@ -132362,7 +132362,7 @@ var require_inflate = __commonJS({
|
|
|
132362
132362
|
state.total += _out;
|
|
132363
132363
|
if (_out) {
|
|
132364
132364
|
strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
|
|
132365
|
-
state.flags ?
|
|
132365
|
+
state.flags ? crc322(state.check, output3, _out, put - _out) : adler32(state.check, output3, _out, put - _out);
|
|
132366
132366
|
}
|
|
132367
132367
|
_out = left;
|
|
132368
132368
|
if ((state.flags ? hold2 : zswap32(hold2)) !== state.check) {
|
|
@@ -132428,7 +132428,7 @@ var require_inflate = __commonJS({
|
|
|
132428
132428
|
state.total += _out;
|
|
132429
132429
|
if (state.wrap && _out) {
|
|
132430
132430
|
strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
|
|
132431
|
-
state.flags ?
|
|
132431
|
+
state.flags ? crc322(state.check, output3, _out, strm.next_out - _out) : adler32(state.check, output3, _out, strm.next_out - _out);
|
|
132432
132432
|
}
|
|
132433
132433
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
|
132434
132434
|
if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
|
|
@@ -132785,17 +132785,17 @@ var require_utils3 = __commonJS({
|
|
|
132785
132785
|
bufferLength--;
|
|
132786
132786
|
}
|
|
132787
132787
|
}
|
|
132788
|
-
var
|
|
132788
|
+
var bytes = new Uint8Array(bufferLength);
|
|
132789
132789
|
for (i2 = 0; i2 < len; i2 += 4) {
|
|
132790
132790
|
encoded1 = lookup[base643.charCodeAt(i2)];
|
|
132791
132791
|
encoded2 = lookup[base643.charCodeAt(i2 + 1)];
|
|
132792
132792
|
encoded3 = lookup[base643.charCodeAt(i2 + 2)];
|
|
132793
132793
|
encoded4 = lookup[base643.charCodeAt(i2 + 3)];
|
|
132794
|
-
|
|
132795
|
-
|
|
132796
|
-
|
|
132794
|
+
bytes[p2++] = encoded1 << 2 | encoded2 >> 4;
|
|
132795
|
+
bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
|
132796
|
+
bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
|
132797
132797
|
}
|
|
132798
|
-
return
|
|
132798
|
+
return bytes;
|
|
132799
132799
|
};
|
|
132800
132800
|
var arrayToString = function(array2) {
|
|
132801
132801
|
var str5 = "";
|
|
@@ -133341,10 +133341,10 @@ var require_pdfDocEncoding = __commonJS({
|
|
|
133341
133341
|
pdfDocEncodingToUnicode[159] = strings_1.toCharCode("\uFFFD");
|
|
133342
133342
|
pdfDocEncodingToUnicode[160] = strings_1.toCharCode("\u20AC");
|
|
133343
133343
|
pdfDocEncodingToUnicode[173] = strings_1.toCharCode("\uFFFD");
|
|
133344
|
-
exports.pdfDocEncodingDecode = function(
|
|
133345
|
-
var codePoints = new Array(
|
|
133346
|
-
for (var idx2 = 0, len =
|
|
133347
|
-
codePoints[idx2] = pdfDocEncodingToUnicode[
|
|
133344
|
+
exports.pdfDocEncodingDecode = function(bytes) {
|
|
133345
|
+
var codePoints = new Array(bytes.length);
|
|
133346
|
+
for (var idx2 = 0, len = bytes.length; idx2 < len; idx2++) {
|
|
133347
|
+
codePoints[idx2] = pdfDocEncodingToUnicode[bytes[idx2]];
|
|
133348
133348
|
}
|
|
133349
133349
|
return String.fromCodePoint.apply(String, codePoints);
|
|
133350
133350
|
};
|
|
@@ -134300,12 +134300,12 @@ var require_PDFName = __commonJS({
|
|
|
134300
134300
|
return _this;
|
|
134301
134301
|
}
|
|
134302
134302
|
PDFName2.prototype.asBytes = function() {
|
|
134303
|
-
var
|
|
134303
|
+
var bytes = [];
|
|
134304
134304
|
var hex3 = "";
|
|
134305
134305
|
var escaped = false;
|
|
134306
134306
|
var pushByte = function(byte2) {
|
|
134307
134307
|
if (byte2 !== void 0)
|
|
134308
|
-
|
|
134308
|
+
bytes.push(byte2);
|
|
134309
134309
|
escaped = false;
|
|
134310
134310
|
};
|
|
134311
134311
|
for (var idx = 1, len = this.encodedName.length; idx < len; idx++) {
|
|
@@ -134329,11 +134329,11 @@ var require_PDFName = __commonJS({
|
|
|
134329
134329
|
}
|
|
134330
134330
|
}
|
|
134331
134331
|
}
|
|
134332
|
-
return new Uint8Array(
|
|
134332
|
+
return new Uint8Array(bytes);
|
|
134333
134333
|
};
|
|
134334
134334
|
PDFName2.prototype.decodeText = function() {
|
|
134335
|
-
var
|
|
134336
|
-
return String.fromCharCode.apply(String, Array.from(
|
|
134335
|
+
var bytes = this.asBytes();
|
|
134336
|
+
return String.fromCharCode.apply(String, Array.from(bytes));
|
|
134337
134337
|
};
|
|
134338
134338
|
PDFName2.prototype.asString = function() {
|
|
134339
134339
|
return this.encodedName;
|
|
@@ -136403,22 +136403,22 @@ var require_PDFHexString = __commonJS({
|
|
|
136403
136403
|
PDFHexString2.prototype.asBytes = function() {
|
|
136404
136404
|
var hex3 = this.value + (this.value.length % 2 === 1 ? "0" : "");
|
|
136405
136405
|
var hexLength = hex3.length;
|
|
136406
|
-
var
|
|
136406
|
+
var bytes = new Uint8Array(hex3.length / 2);
|
|
136407
136407
|
var hexOffset = 0;
|
|
136408
136408
|
var bytesOffset = 0;
|
|
136409
136409
|
while (hexOffset < hexLength) {
|
|
136410
136410
|
var byte = parseInt(hex3.substring(hexOffset, hexOffset + 2), 16);
|
|
136411
|
-
|
|
136411
|
+
bytes[bytesOffset] = byte;
|
|
136412
136412
|
hexOffset += 2;
|
|
136413
136413
|
bytesOffset += 1;
|
|
136414
136414
|
}
|
|
136415
|
-
return
|
|
136415
|
+
return bytes;
|
|
136416
136416
|
};
|
|
136417
136417
|
PDFHexString2.prototype.decodeText = function() {
|
|
136418
|
-
var
|
|
136419
|
-
if (utils_1.hasUtf16BOM(
|
|
136420
|
-
return utils_1.utf16Decode(
|
|
136421
|
-
return utils_1.pdfDocEncodingDecode(
|
|
136418
|
+
var bytes = this.asBytes();
|
|
136419
|
+
if (utils_1.hasUtf16BOM(bytes))
|
|
136420
|
+
return utils_1.utf16Decode(bytes);
|
|
136421
|
+
return utils_1.pdfDocEncodingDecode(bytes);
|
|
136422
136422
|
};
|
|
136423
136423
|
PDFHexString2.prototype.decodeDate = function() {
|
|
136424
136424
|
var text4 = this.decodeText();
|
|
@@ -136670,12 +136670,12 @@ var require_PDFString = __commonJS({
|
|
|
136670
136670
|
return _this;
|
|
136671
136671
|
}
|
|
136672
136672
|
PDFString2.prototype.asBytes = function() {
|
|
136673
|
-
var
|
|
136673
|
+
var bytes = [];
|
|
136674
136674
|
var octal = "";
|
|
136675
136675
|
var escaped = false;
|
|
136676
136676
|
var pushByte = function(byte2) {
|
|
136677
136677
|
if (byte2 !== void 0)
|
|
136678
|
-
|
|
136678
|
+
bytes.push(byte2);
|
|
136679
136679
|
escaped = false;
|
|
136680
136680
|
};
|
|
136681
136681
|
for (var idx = 0, len = this.value.length; idx < len; idx++) {
|
|
@@ -136719,13 +136719,13 @@ var require_PDFString = __commonJS({
|
|
|
136719
136719
|
}
|
|
136720
136720
|
}
|
|
136721
136721
|
}
|
|
136722
|
-
return new Uint8Array(
|
|
136722
|
+
return new Uint8Array(bytes);
|
|
136723
136723
|
};
|
|
136724
136724
|
PDFString2.prototype.decodeText = function() {
|
|
136725
|
-
var
|
|
136726
|
-
if (utils_1.hasUtf16BOM(
|
|
136727
|
-
return utils_1.utf16Decode(
|
|
136728
|
-
return utils_1.pdfDocEncodingDecode(
|
|
136725
|
+
var bytes = this.asBytes();
|
|
136726
|
+
if (utils_1.hasUtf16BOM(bytes))
|
|
136727
|
+
return utils_1.utf16Decode(bytes);
|
|
136728
|
+
return utils_1.pdfDocEncodingDecode(bytes);
|
|
136729
136729
|
};
|
|
136730
136730
|
PDFString2.prototype.decodeDate = function() {
|
|
136731
136731
|
var text4 = this.decodeText();
|
|
@@ -137074,8 +137074,8 @@ var require_CustomFontSubsetEmbedder = __commonJS({
|
|
|
137074
137074
|
var _this = this;
|
|
137075
137075
|
return new Promise(function(resolve2, reject) {
|
|
137076
137076
|
var parts = [];
|
|
137077
|
-
_this.subset.encodeStream().on("data", function(
|
|
137078
|
-
return parts.push(
|
|
137077
|
+
_this.subset.encodeStream().on("data", function(bytes) {
|
|
137078
|
+
return parts.push(bytes);
|
|
137079
137079
|
}).on("end", function() {
|
|
137080
137080
|
return resolve2(utils_1.mergeUint8Arrays(parts));
|
|
137081
137081
|
}).on("error", function(err) {
|
|
@@ -137121,11 +137121,11 @@ var require_FileEmbedder = __commonJS({
|
|
|
137121
137121
|
this.fileName = fileName;
|
|
137122
137122
|
this.options = options;
|
|
137123
137123
|
}
|
|
137124
|
-
FileEmbedder2.for = function(
|
|
137124
|
+
FileEmbedder2.for = function(bytes, fileName, options) {
|
|
137125
137125
|
if (options === void 0) {
|
|
137126
137126
|
options = {};
|
|
137127
137127
|
}
|
|
137128
|
-
return new FileEmbedder2(
|
|
137128
|
+
return new FileEmbedder2(bytes, fileName, options);
|
|
137129
137129
|
};
|
|
137130
137130
|
FileEmbedder2.prototype.embedIntoContext = function(context, ref) {
|
|
137131
137131
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
@@ -138961,11 +138961,11 @@ var require_Stream = __commonJS({
|
|
|
138961
138961
|
if (forceClamped === void 0) {
|
|
138962
138962
|
forceClamped = false;
|
|
138963
138963
|
}
|
|
138964
|
-
var
|
|
138964
|
+
var bytes = this.bytes;
|
|
138965
138965
|
var pos = this.pos;
|
|
138966
138966
|
var strEnd = this.end;
|
|
138967
138967
|
if (!length) {
|
|
138968
|
-
var subarray =
|
|
138968
|
+
var subarray = bytes.subarray(pos, strEnd);
|
|
138969
138969
|
return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
|
|
138970
138970
|
} else {
|
|
138971
138971
|
var end2 = pos + length;
|
|
@@ -138973,7 +138973,7 @@ var require_Stream = __commonJS({
|
|
|
138973
138973
|
end2 = strEnd;
|
|
138974
138974
|
}
|
|
138975
138975
|
this.pos = end2;
|
|
138976
|
-
var subarray =
|
|
138976
|
+
var subarray = bytes.subarray(pos, end2);
|
|
138977
138977
|
return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
|
|
138978
138978
|
}
|
|
138979
138979
|
};
|
|
@@ -138986,9 +138986,9 @@ var require_Stream = __commonJS({
|
|
|
138986
138986
|
if (forceClamped === void 0) {
|
|
138987
138987
|
forceClamped = false;
|
|
138988
138988
|
}
|
|
138989
|
-
var
|
|
138990
|
-
this.pos -=
|
|
138991
|
-
return
|
|
138989
|
+
var bytes = this.getBytes(length, forceClamped);
|
|
138990
|
+
this.pos -= bytes.length;
|
|
138991
|
+
return bytes;
|
|
138992
138992
|
};
|
|
138993
138993
|
Stream2.prototype.skip = function(n) {
|
|
138994
138994
|
if (!n) {
|
|
@@ -139109,9 +139109,9 @@ var require_DecodeStream = __commonJS({
|
|
|
139109
139109
|
if (forceClamped === void 0) {
|
|
139110
139110
|
forceClamped = false;
|
|
139111
139111
|
}
|
|
139112
|
-
var
|
|
139113
|
-
this.pos -=
|
|
139114
|
-
return
|
|
139112
|
+
var bytes = this.getBytes(length, forceClamped);
|
|
139113
|
+
this.pos -= bytes.length;
|
|
139114
|
+
return bytes;
|
|
139115
139115
|
};
|
|
139116
139116
|
DecodeStream2.prototype.skip = function(n) {
|
|
139117
139117
|
if (!n) {
|
|
@@ -139267,17 +139267,17 @@ var require_AsciiHexStream = __commonJS({
|
|
|
139267
139267
|
}
|
|
139268
139268
|
AsciiHexStream2.prototype.readBlock = function() {
|
|
139269
139269
|
var UPSTREAM_BLOCK_SIZE = 8e3;
|
|
139270
|
-
var
|
|
139271
|
-
if (!
|
|
139270
|
+
var bytes = this.stream.getBytes(UPSTREAM_BLOCK_SIZE);
|
|
139271
|
+
if (!bytes.length) {
|
|
139272
139272
|
this.eof = true;
|
|
139273
139273
|
return;
|
|
139274
139274
|
}
|
|
139275
|
-
var maxDecodeLength =
|
|
139275
|
+
var maxDecodeLength = bytes.length + 1 >> 1;
|
|
139276
139276
|
var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
|
|
139277
139277
|
var bufferLength = this.bufferLength;
|
|
139278
139278
|
var firstDigit = this.firstDigit;
|
|
139279
|
-
for (var i = 0, ii2 =
|
|
139280
|
-
var ch =
|
|
139279
|
+
for (var i = 0, ii2 = bytes.length; i < ii2; i++) {
|
|
139280
|
+
var ch = bytes[i];
|
|
139281
139281
|
var digit = void 0;
|
|
139282
139282
|
if (ch >= 48 && ch <= 57) {
|
|
139283
139283
|
digit = ch & 15;
|
|
@@ -142594,11 +142594,11 @@ var require_BaseParser = __commonJS({
|
|
|
142594
142594
|
var BaseParser = (
|
|
142595
142595
|
/** @class */
|
|
142596
142596
|
(function() {
|
|
142597
|
-
function BaseParser2(
|
|
142597
|
+
function BaseParser2(bytes, capNumbers) {
|
|
142598
142598
|
if (capNumbers === void 0) {
|
|
142599
142599
|
capNumbers = false;
|
|
142600
142600
|
}
|
|
142601
|
-
this.bytes =
|
|
142601
|
+
this.bytes = bytes;
|
|
142602
142602
|
this.capNumbers = capNumbers;
|
|
142603
142603
|
}
|
|
142604
142604
|
BaseParser2.prototype.parseRawInt = function() {
|
|
@@ -142705,11 +142705,11 @@ var require_ByteStream = __commonJS({
|
|
|
142705
142705
|
var ByteStream = (
|
|
142706
142706
|
/** @class */
|
|
142707
142707
|
(function() {
|
|
142708
|
-
function ByteStream2(
|
|
142708
|
+
function ByteStream2(bytes) {
|
|
142709
142709
|
this.idx = 0;
|
|
142710
142710
|
this.line = 0;
|
|
142711
142711
|
this.column = 0;
|
|
142712
|
-
this.bytes =
|
|
142712
|
+
this.bytes = bytes;
|
|
142713
142713
|
this.length = this.bytes.length;
|
|
142714
142714
|
}
|
|
142715
142715
|
ByteStream2.prototype.moveTo = function(offset) {
|
|
@@ -142752,8 +142752,8 @@ var require_ByteStream = __commonJS({
|
|
|
142752
142752
|
ByteStream2.prototype.position = function() {
|
|
142753
142753
|
return { line: this.line, column: this.column, offset: this.idx };
|
|
142754
142754
|
};
|
|
142755
|
-
ByteStream2.of = function(
|
|
142756
|
-
return new ByteStream2(
|
|
142755
|
+
ByteStream2.of = function(bytes) {
|
|
142756
|
+
return new ByteStream2(bytes);
|
|
142757
142757
|
};
|
|
142758
142758
|
ByteStream2.fromPDFRawStream = function(rawStream) {
|
|
142759
142759
|
return ByteStream2.of(decode_1.decodePDFRawStream(rawStream).decode());
|
|
@@ -143060,8 +143060,8 @@ var require_PDFObjectParser = __commonJS({
|
|
|
143060
143060
|
throw new errors_1.PDFStreamParsingError(startPos);
|
|
143061
143061
|
return end2;
|
|
143062
143062
|
};
|
|
143063
|
-
PDFObjectParser2.forBytes = function(
|
|
143064
|
-
return new PDFObjectParser2(ByteStream_1.default.of(
|
|
143063
|
+
PDFObjectParser2.forBytes = function(bytes, context, capNumbers) {
|
|
143064
|
+
return new PDFObjectParser2(ByteStream_1.default.of(bytes), context, capNumbers);
|
|
143065
143065
|
};
|
|
143066
143066
|
PDFObjectParser2.forByteStream = function(byteStream, context, capNumbers) {
|
|
143067
143067
|
if (capNumbers === void 0) {
|
|
@@ -148054,7 +148054,7 @@ var require_PDFDocument = __commonJS({
|
|
|
148054
148054
|
options = {};
|
|
148055
148055
|
}
|
|
148056
148056
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
148057
|
-
var _a4, ignoreEncryption, _b, parseSpeed, _c, throwOnInvalidObject, _d, updateMetadata, _e2, capNumbers,
|
|
148057
|
+
var _a4, ignoreEncryption, _b, parseSpeed, _c, throwOnInvalidObject, _d, updateMetadata, _e2, capNumbers, bytes, context;
|
|
148058
148058
|
return tslib_1.__generator(this, function(_f) {
|
|
148059
148059
|
switch (_f.label) {
|
|
148060
148060
|
case 0:
|
|
@@ -148063,8 +148063,8 @@ var require_PDFDocument = __commonJS({
|
|
|
148063
148063
|
utils_1.assertIs(ignoreEncryption, "ignoreEncryption", ["boolean"]);
|
|
148064
148064
|
utils_1.assertIs(parseSpeed, "parseSpeed", ["number"]);
|
|
148065
148065
|
utils_1.assertIs(throwOnInvalidObject, "throwOnInvalidObject", ["boolean"]);
|
|
148066
|
-
|
|
148067
|
-
return [4, core_1.PDFParser.forBytesWithOptions(
|
|
148066
|
+
bytes = utils_1.toUint8Array(pdf);
|
|
148067
|
+
return [4, core_1.PDFParser.forBytesWithOptions(bytes, parseSpeed, throwOnInvalidObject, capNumbers).parseDocument()];
|
|
148068
148068
|
case 1:
|
|
148069
148069
|
context = _f.sent();
|
|
148070
148070
|
return [2, new PDFDocument3(context, ignoreEncryption, updateMetadata)];
|
|
@@ -148331,7 +148331,7 @@ var require_PDFDocument = __commonJS({
|
|
|
148331
148331
|
options = {};
|
|
148332
148332
|
}
|
|
148333
148333
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
148334
|
-
var
|
|
148334
|
+
var bytes, embedder, ref, embeddedFile;
|
|
148335
148335
|
return tslib_1.__generator(this, function(_a4) {
|
|
148336
148336
|
utils_1.assertIs(attachment, "attachment", ["string", Uint8Array, ArrayBuffer]);
|
|
148337
148337
|
utils_1.assertIs(name, "name", ["string"]);
|
|
@@ -148342,8 +148342,8 @@ var require_PDFDocument = __commonJS({
|
|
|
148342
148342
|
Date
|
|
148343
148343
|
]);
|
|
148344
148344
|
utils_1.assertIsOneOfOrUndefined(options.afRelationship, "options.afRelationship", FileEmbedder_1.AFRelationship);
|
|
148345
|
-
|
|
148346
|
-
embedder = FileEmbedder_1.default.for(
|
|
148345
|
+
bytes = utils_1.toUint8Array(attachment);
|
|
148346
|
+
embedder = FileEmbedder_1.default.for(bytes, name, options);
|
|
148347
148347
|
ref = this.context.nextRef();
|
|
148348
148348
|
embeddedFile = PDFEmbeddedFile_1.default.of(ref, this, embedder);
|
|
148349
148349
|
this.embeddedFiles.push(embeddedFile);
|
|
@@ -148359,7 +148359,7 @@ var require_PDFDocument = __commonJS({
|
|
|
148359
148359
|
options = {};
|
|
148360
148360
|
}
|
|
148361
148361
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
148362
|
-
var _a4, subset, customName, features, embedder,
|
|
148362
|
+
var _a4, subset, customName, features, embedder, bytes, fontkit, _b, ref, pdfFont;
|
|
148363
148363
|
return tslib_1.__generator(this, function(_c) {
|
|
148364
148364
|
switch (_c.label) {
|
|
148365
148365
|
case 0:
|
|
@@ -148371,15 +148371,15 @@ var require_PDFDocument = __commonJS({
|
|
|
148371
148371
|
return [3, 7];
|
|
148372
148372
|
case 1:
|
|
148373
148373
|
if (!utils_1.canBeConvertedToUint8Array(font)) return [3, 6];
|
|
148374
|
-
|
|
148374
|
+
bytes = utils_1.toUint8Array(font);
|
|
148375
148375
|
fontkit = this.assertFontkit();
|
|
148376
148376
|
if (!subset) return [3, 3];
|
|
148377
|
-
return [4, core_1.CustomFontSubsetEmbedder.for(fontkit,
|
|
148377
|
+
return [4, core_1.CustomFontSubsetEmbedder.for(fontkit, bytes, customName, features)];
|
|
148378
148378
|
case 2:
|
|
148379
148379
|
_b = _c.sent();
|
|
148380
148380
|
return [3, 5];
|
|
148381
148381
|
case 3:
|
|
148382
|
-
return [4, core_1.CustomFontEmbedder.for(fontkit,
|
|
148382
|
+
return [4, core_1.CustomFontEmbedder.for(fontkit, bytes, customName, features)];
|
|
148383
148383
|
case 4:
|
|
148384
148384
|
_b = _c.sent();
|
|
148385
148385
|
_c.label = 5;
|
|
@@ -148410,13 +148410,13 @@ var require_PDFDocument = __commonJS({
|
|
|
148410
148410
|
};
|
|
148411
148411
|
PDFDocument3.prototype.embedJpg = function(jpg) {
|
|
148412
148412
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
148413
|
-
var
|
|
148413
|
+
var bytes, embedder, ref, pdfImage;
|
|
148414
148414
|
return tslib_1.__generator(this, function(_a4) {
|
|
148415
148415
|
switch (_a4.label) {
|
|
148416
148416
|
case 0:
|
|
148417
148417
|
utils_1.assertIs(jpg, "jpg", ["string", Uint8Array, ArrayBuffer]);
|
|
148418
|
-
|
|
148419
|
-
return [4, core_1.JpegEmbedder.for(
|
|
148418
|
+
bytes = utils_1.toUint8Array(jpg);
|
|
148419
|
+
return [4, core_1.JpegEmbedder.for(bytes)];
|
|
148420
148420
|
case 1:
|
|
148421
148421
|
embedder = _a4.sent();
|
|
148422
148422
|
ref = this.context.nextRef();
|
|
@@ -148429,13 +148429,13 @@ var require_PDFDocument = __commonJS({
|
|
|
148429
148429
|
};
|
|
148430
148430
|
PDFDocument3.prototype.embedPng = function(png) {
|
|
148431
148431
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
148432
|
-
var
|
|
148432
|
+
var bytes, embedder, ref, pdfImage;
|
|
148433
148433
|
return tslib_1.__generator(this, function(_a4) {
|
|
148434
148434
|
switch (_a4.label) {
|
|
148435
148435
|
case 0:
|
|
148436
148436
|
utils_1.assertIs(png, "png", ["string", Uint8Array, ArrayBuffer]);
|
|
148437
|
-
|
|
148438
|
-
return [4, core_1.PngEmbedder.for(
|
|
148437
|
+
bytes = utils_1.toUint8Array(png);
|
|
148438
|
+
return [4, core_1.PngEmbedder.for(bytes)];
|
|
148439
148439
|
case 1:
|
|
148440
148440
|
embedder = _a4.sent();
|
|
148441
148441
|
ref = this.context.nextRef();
|
|
@@ -148606,7 +148606,7 @@ var require_PDFDocument = __commonJS({
|
|
|
148606
148606
|
options = {};
|
|
148607
148607
|
}
|
|
148608
148608
|
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
148609
|
-
var _a4, dataUri, otherOptions,
|
|
148609
|
+
var _a4, dataUri, otherOptions, bytes, base643;
|
|
148610
148610
|
return tslib_1.__generator(this, function(_b) {
|
|
148611
148611
|
switch (_b.label) {
|
|
148612
148612
|
case 0:
|
|
@@ -148614,8 +148614,8 @@ var require_PDFDocument = __commonJS({
|
|
|
148614
148614
|
utils_1.assertIs(dataUri, "dataUri", ["boolean"]);
|
|
148615
148615
|
return [4, this.save(otherOptions)];
|
|
148616
148616
|
case 1:
|
|
148617
|
-
|
|
148618
|
-
base643 = utils_1.encodeToBase64(
|
|
148617
|
+
bytes = _b.sent();
|
|
148618
|
+
base643 = utils_1.encodeToBase64(bytes);
|
|
148619
148619
|
return [2, dataUri ? "data:application/pdf;base64," + base643 : base643];
|
|
148620
148620
|
}
|
|
148621
148621
|
});
|
|
@@ -151549,11 +151549,11 @@ function installedOffice() {
|
|
|
151549
151549
|
const onPath2 = (process.env.PATH ?? "").split(path59.delimiter).filter(Boolean).map((dir) => path59.join(dir, executable));
|
|
151550
151550
|
return [...onPath2, ...candidates].find((file2) => existsSync2(file2)) ?? executable;
|
|
151551
151551
|
}
|
|
151552
|
-
function checkPackage(
|
|
151552
|
+
function checkPackage(bytes, mainPart) {
|
|
151553
151553
|
let hasMainPart = false;
|
|
151554
151554
|
let expanded = 0;
|
|
151555
151555
|
let relationshipSize = 0;
|
|
151556
|
-
const relationships = (0, import_fflate.unzipSync)(
|
|
151556
|
+
const relationships = (0, import_fflate.unzipSync)(bytes, { filter: (entry) => {
|
|
151557
151557
|
hasMainPart ||= entry.name === mainPart && entry.originalSize > 0;
|
|
151558
151558
|
expanded += entry.originalSize;
|
|
151559
151559
|
if (expanded > 5 * ASSET_FILE_LIMIT) throw Error("Office package exceeds the preview size limit");
|
|
@@ -151600,15 +151600,15 @@ function convert(command, args2, timeout) {
|
|
|
151600
151600
|
});
|
|
151601
151601
|
});
|
|
151602
151602
|
}
|
|
151603
|
-
async function renderOfficePdf(
|
|
151603
|
+
async function renderOfficePdf(bytes, ext, command = installedOffice(), timeout = 3e4) {
|
|
151604
151604
|
const format = formats[ext];
|
|
151605
|
-
checkPackage(
|
|
151605
|
+
checkPackage(bytes, format.part);
|
|
151606
151606
|
const dir = await mkdtemp(path59.join(tmpdir(), "wildcrane-document-"));
|
|
151607
151607
|
try {
|
|
151608
151608
|
const user = path59.join(dir, "profile", "user");
|
|
151609
151609
|
const input2 = path59.join(dir, `source${ext}`);
|
|
151610
151610
|
await mkdir(user, { recursive: true });
|
|
151611
|
-
await Promise.all([writeFile(input2,
|
|
151611
|
+
await Promise.all([writeFile(input2, bytes), writeFile(path59.join(user, "registrymodifications.xcu"), profile)]);
|
|
151612
151612
|
await convert(command, [
|
|
151613
151613
|
`-env:UserInstallation=${pathToFileURL2(path59.dirname(user)).href}`,
|
|
151614
151614
|
"--headless",
|
|
@@ -151830,8 +151830,8 @@ function deferRefresh(session, error62, { after, transport = false } = {}) {
|
|
|
151830
151830
|
const seconds = after?.trim() ? Number(after) : NaN;
|
|
151831
151831
|
const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after ?? "") - Date.now();
|
|
151832
151832
|
const backoff = (transport ? 5e3 : REFRESH_BACKOFF_MS) * 2 ** (attempt - 1);
|
|
151833
|
-
const
|
|
151834
|
-
const retry2 = { key: refreshKey(session), until: Date.now() +
|
|
151833
|
+
const delay4 = Math.max(Math.min(backoff, transport ? 3e4 : 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
|
|
151834
|
+
const retry2 = { key: refreshKey(session), until: Date.now() + delay4, attempt, error: error62 };
|
|
151835
151835
|
if (transport) transportRetry = { ...retry2, file: retryFile() };
|
|
151836
151836
|
else {
|
|
151837
151837
|
const temporary = `${retryFile()}.${process.pid}.tmp`;
|
|
@@ -151986,31 +151986,6 @@ function alive(pid) {
|
|
|
151986
151986
|
}
|
|
151987
151987
|
var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
151988
151988
|
|
|
151989
|
-
// ../cli/src/lib/agent/stop.ts
|
|
151990
|
-
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
151991
|
-
import { randomUUID } from "node:crypto";
|
|
151992
|
-
import fs5 from "node:fs";
|
|
151993
|
-
|
|
151994
|
-
// ../cli/src/lib/agent/env.ts
|
|
151995
|
-
var RUN_ENV = "KANBAN_RUN";
|
|
151996
|
-
var SESSION_COST_ENV = "AI4KANBAN_SESSION_COST";
|
|
151997
|
-
function insideRun() {
|
|
151998
|
-
const id2 = process.env[RUN_ENV];
|
|
151999
|
-
return id2 && id2.trim() ? id2.trim() : null;
|
|
152000
|
-
}
|
|
152001
|
-
var TASK_REQUEST_ENV = "AI4KANBAN_TASK_REQUEST";
|
|
152002
|
-
var SAVED_PREVIEW_FILE_ENV = "AI4KANBAN_SAVED_PREVIEW_FILE";
|
|
152003
|
-
var STOP_ENV = "KANBAN_STOP_ID";
|
|
152004
|
-
var SESSION_VARS = {
|
|
152005
|
-
"claude-code": "CLAUDE_CODE_SESSION_ID",
|
|
152006
|
-
codex: "CODEX_THREAD_ID"
|
|
152007
|
-
};
|
|
152008
|
-
|
|
152009
|
-
// ../cli/src/lib/paths.ts
|
|
152010
|
-
import { spawnSync } from "node:child_process";
|
|
152011
|
-
import fs4 from "node:fs";
|
|
152012
|
-
import path5 from "node:path";
|
|
152013
|
-
|
|
152014
151989
|
// ../cli/src/lib/io.ts
|
|
152015
151990
|
var BoardError = class extends Error {
|
|
152016
151991
|
// `kind` is the machine-readable name of the refusal (card-not-found, no-board,
|
|
@@ -152043,6 +152018,51 @@ function warn(message) {
|
|
|
152043
152018
|
else console.error(`kanban: warning \u2014 ${message}`);
|
|
152044
152019
|
}
|
|
152045
152020
|
|
|
152021
|
+
// ../cli/src/lib/cloud/response.ts
|
|
152022
|
+
var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
152023
|
+
var hasText = (value) => typeof value === "string" && !!value.trim();
|
|
152024
|
+
function temporaryCloudFailure({ code, status }) {
|
|
152025
|
+
if (code && ["unauthenticated", "machine_offline", "quota_exceeded", "daily_write_budget_reached", "storage_limit_reached"].includes(code)) return false;
|
|
152026
|
+
return ["unreachable", "invalid_response", "idempotency_in_progress", "service_unavailable", "artifacts_unavailable"].includes(code ?? "") || status === 408 || (status !== void 0 ? status >= 500 : !code);
|
|
152027
|
+
}
|
|
152028
|
+
var invalidResponse = (expected) => ({ code: "invalid_response", message: `Cloud did not return ${expected}.`, retryable: true });
|
|
152029
|
+
async function readCloudJson(response) {
|
|
152030
|
+
return response.json().catch(() => void 0);
|
|
152031
|
+
}
|
|
152032
|
+
function cloudProblem(response, body) {
|
|
152033
|
+
const error62 = isRecord(body) && isRecord(body.error) ? body.error : null;
|
|
152034
|
+
if (response.ok && !error62) return null;
|
|
152035
|
+
const status = response.status;
|
|
152036
|
+
const code = hasText(error62?.code) ? error62.code : status === 401 ? "unauthenticated" : status >= 500 ? "service_unavailable" : "refused";
|
|
152037
|
+
const message = hasText(error62?.message) ? error62.message : `Cloud answered ${status}.`;
|
|
152038
|
+
return { code, message, status, retryable: temporaryCloudFailure({ code, status }) };
|
|
152039
|
+
}
|
|
152040
|
+
|
|
152041
|
+
// ../cli/src/lib/agent/stop.ts
|
|
152042
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
152043
|
+
import { randomUUID } from "node:crypto";
|
|
152044
|
+
import fs5 from "node:fs";
|
|
152045
|
+
|
|
152046
|
+
// ../cli/src/lib/agent/env.ts
|
|
152047
|
+
var RUN_ENV = "KANBAN_RUN";
|
|
152048
|
+
var SESSION_COST_ENV = "AI4KANBAN_SESSION_COST";
|
|
152049
|
+
function insideRun() {
|
|
152050
|
+
const id2 = process.env[RUN_ENV];
|
|
152051
|
+
return id2 && id2.trim() ? id2.trim() : null;
|
|
152052
|
+
}
|
|
152053
|
+
var TASK_REQUEST_ENV = "AI4KANBAN_TASK_REQUEST";
|
|
152054
|
+
var SAVED_PREVIEW_FILE_ENV = "AI4KANBAN_SAVED_PREVIEW_FILE";
|
|
152055
|
+
var STOP_ENV = "KANBAN_STOP_ID";
|
|
152056
|
+
var SESSION_VARS = {
|
|
152057
|
+
"claude-code": "CLAUDE_CODE_SESSION_ID",
|
|
152058
|
+
codex: "CODEX_THREAD_ID"
|
|
152059
|
+
};
|
|
152060
|
+
|
|
152061
|
+
// ../cli/src/lib/paths.ts
|
|
152062
|
+
import { spawnSync } from "node:child_process";
|
|
152063
|
+
import fs4 from "node:fs";
|
|
152064
|
+
import path5 from "node:path";
|
|
152065
|
+
|
|
152046
152066
|
// ../cli/src/lib/machine/project.ts
|
|
152047
152067
|
import fs3 from "node:fs";
|
|
152048
152068
|
import path4 from "node:path";
|
|
@@ -152560,6 +152580,7 @@ __export(api_exports, {
|
|
|
152560
152580
|
readJob: () => readJob,
|
|
152561
152581
|
readProject: () => readProject,
|
|
152562
152582
|
readRejections: () => readRejections,
|
|
152583
|
+
readReplyHistory: () => readReplyHistory,
|
|
152563
152584
|
readRunner: () => readRunner,
|
|
152564
152585
|
readTask: () => readTask,
|
|
152565
152586
|
readTaskStudio: () => readTaskStudio,
|
|
@@ -152580,34 +152601,673 @@ __export(api_exports, {
|
|
|
152580
152601
|
uploadReplyImage: () => uploadReplyImage
|
|
152581
152602
|
});
|
|
152582
152603
|
|
|
152583
|
-
// ../cli/src/lib/shared/
|
|
152584
|
-
|
|
152585
|
-
|
|
152604
|
+
// ../cli/src/lib/shared/studio-files.ts
|
|
152605
|
+
var import_yaml3 = __toESM(require_dist(), 1);
|
|
152606
|
+
|
|
152607
|
+
// ../cli/src/lib/agent/studio-def.ts
|
|
152608
|
+
var import_ajv = __toESM(require_ajv(), 1);
|
|
152609
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
152610
|
+
|
|
152611
|
+
// ../cli/src/lib/agents/icon.ts
|
|
152612
|
+
var ICON_NAMES = [
|
|
152613
|
+
"file",
|
|
152614
|
+
"text",
|
|
152615
|
+
"article",
|
|
152616
|
+
"outline",
|
|
152617
|
+
"script",
|
|
152618
|
+
"prompt",
|
|
152619
|
+
"email",
|
|
152620
|
+
"image",
|
|
152621
|
+
"post-image",
|
|
152622
|
+
"social-image",
|
|
152623
|
+
"cover",
|
|
152624
|
+
"carousel",
|
|
152625
|
+
"carousel-outline",
|
|
152626
|
+
"slides",
|
|
152627
|
+
"wireframe",
|
|
152628
|
+
"screen",
|
|
152629
|
+
"video",
|
|
152630
|
+
"storyboard",
|
|
152631
|
+
"template",
|
|
152632
|
+
"shots",
|
|
152633
|
+
"api",
|
|
152634
|
+
"schema",
|
|
152635
|
+
"compare",
|
|
152636
|
+
"stack",
|
|
152637
|
+
"studio",
|
|
152638
|
+
"code",
|
|
152639
|
+
"checklist",
|
|
152640
|
+
"card",
|
|
152641
|
+
"plan",
|
|
152642
|
+
"proposal",
|
|
152643
|
+
"dismissed",
|
|
152644
|
+
"inbox",
|
|
152645
|
+
"notebook",
|
|
152646
|
+
"squeeze",
|
|
152647
|
+
"folder",
|
|
152648
|
+
"reply",
|
|
152649
|
+
"feedback",
|
|
152650
|
+
"software",
|
|
152651
|
+
"product-video",
|
|
152652
|
+
"social-post",
|
|
152653
|
+
"blog",
|
|
152654
|
+
"deck",
|
|
152655
|
+
"video-clone",
|
|
152656
|
+
"studio-kit"
|
|
152657
|
+
];
|
|
152658
|
+
var ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
|
|
152659
|
+
var PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
|
|
152660
|
+
var isColor = (v) => ICON_COLORS.includes(v);
|
|
152661
|
+
function readIcon(raw) {
|
|
152662
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
152663
|
+
if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
|
|
152664
|
+
if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
|
|
152665
|
+
const parts = [];
|
|
152666
|
+
for (const [i, item] of raw.entries()) {
|
|
152667
|
+
const at2 = `part ${i + 1}`;
|
|
152668
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at2} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
|
|
152669
|
+
const { d: d2, f: f2, o: o3, s, w: w2, ...extra } = item;
|
|
152670
|
+
if (Object.keys(extra).length) return { problem: `${at2} has \`${Object.keys(extra).join("`, `")}\`` };
|
|
152671
|
+
if (typeof d2 !== "string" || !PATH.test(d2)) return { problem: `${at2} has no \`d\` of SVG path commands and numbers` };
|
|
152672
|
+
const part = { d: d2.trim() };
|
|
152673
|
+
for (const [key, value] of [["f", f2], ["s", s]]) {
|
|
152674
|
+
if (value === void 0) continue;
|
|
152675
|
+
if (typeof value !== "string" || !isColor(value)) return { problem: `${at2} colours \`${key}\` with "${String(value)}"` };
|
|
152676
|
+
part[key] = value;
|
|
152677
|
+
}
|
|
152678
|
+
if (o3 !== void 0) {
|
|
152679
|
+
if (o3 !== "true") return { problem: `${at2} has \`o: ${String(o3)}\`, not \`true\`` };
|
|
152680
|
+
part.o = true;
|
|
152681
|
+
}
|
|
152682
|
+
if (w2 !== void 0) {
|
|
152683
|
+
const width = typeof w2 === "string" ? Number(w2) : NaN;
|
|
152684
|
+
if (!(width > 0 && width <= 3)) return { problem: `${at2} has \`w: ${String(w2)}\`, not above 0 and up to 3` };
|
|
152685
|
+
part.w = width;
|
|
152686
|
+
}
|
|
152687
|
+
parts.push(part);
|
|
152688
|
+
}
|
|
152689
|
+
return parts;
|
|
152586
152690
|
}
|
|
152587
152691
|
|
|
152588
|
-
// ../cli/src/lib/
|
|
152589
|
-
var
|
|
152590
|
-
|
|
152591
|
-
|
|
152592
|
-
|
|
152593
|
-
return ["unreachable", "invalid_response", "idempotency_in_progress", "service_unavailable", "artifacts_unavailable"].includes(code ?? "") || status === 408 || (status !== void 0 ? status >= 500 : !code);
|
|
152692
|
+
// ../cli/src/lib/shared/preview-blocks.ts
|
|
152693
|
+
var PREVIEW_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
152694
|
+
function sourcePosition(source2, offset) {
|
|
152695
|
+
const before = source2.slice(0, offset);
|
|
152696
|
+
return { line: before.split("\n").length, column: offset - before.lastIndexOf("\n") };
|
|
152594
152697
|
}
|
|
152595
|
-
|
|
152596
|
-
|
|
152597
|
-
|
|
152698
|
+
function withoutCode(source2) {
|
|
152699
|
+
const blank2 = (s) => s.replace(/[^\n\r]/g, " ");
|
|
152700
|
+
let fence;
|
|
152701
|
+
let indented = false, afterBlank = true, inList = false;
|
|
152702
|
+
return source2.split(/(?<=\n)/).map((line) => {
|
|
152703
|
+
const marker = /^ {0,3}(`{3,}|~{3,})(.*)/.exec(line);
|
|
152704
|
+
if (fence) {
|
|
152705
|
+
if (marker && marker[1][0] === fence.char && marker[1].length >= fence.length && !marker[2].trim()) fence = void 0;
|
|
152706
|
+
return blank2(line);
|
|
152707
|
+
}
|
|
152708
|
+
if (marker) {
|
|
152709
|
+
fence = { char: marker[1][0], length: marker[1].length };
|
|
152710
|
+
return blank2(line);
|
|
152711
|
+
}
|
|
152712
|
+
if (!line.trim()) {
|
|
152713
|
+
afterBlank = true;
|
|
152714
|
+
return line;
|
|
152715
|
+
}
|
|
152716
|
+
const hasIndent = /^(?: {4}|\t)/.test(line);
|
|
152717
|
+
if (!hasIndent) indented = false;
|
|
152718
|
+
if (/^ {0,3}(?:[-+*]|\d+[.)])\s/.test(line)) inList = true;
|
|
152719
|
+
else if (/^\S/.test(line)) inList = false;
|
|
152720
|
+
if (hasIndent && (indented || afterBlank && !inList)) {
|
|
152721
|
+
indented = true;
|
|
152722
|
+
return blank2(line);
|
|
152723
|
+
}
|
|
152724
|
+
afterBlank = false;
|
|
152725
|
+
return line;
|
|
152726
|
+
}).join("").replace(/(`+)([^]*?)\1(?!`)/g, blank2);
|
|
152598
152727
|
}
|
|
152599
|
-
function
|
|
152600
|
-
|
|
152601
|
-
|
|
152602
|
-
|
|
152603
|
-
const
|
|
152604
|
-
const
|
|
152605
|
-
|
|
152728
|
+
function agentSectionOffset(source2) {
|
|
152729
|
+
return /^<!--[ \t]*agent[ \t]*-->/m.exec(withoutCode(source2))?.index ?? source2.length;
|
|
152730
|
+
}
|
|
152731
|
+
function parsePreviewBlocks(source2, file2 = "STUDIO.md") {
|
|
152732
|
+
const blocks = [], problems = [];
|
|
152733
|
+
const masked = withoutCode(source2);
|
|
152734
|
+
let open2;
|
|
152735
|
+
const seen = /* @__PURE__ */ new Set();
|
|
152736
|
+
const fail = (offset, id2, code, message, hint2) => problems.push({ file: file2, ...sourcePosition(source2, offset), path: id2 ? `previews.${id2}` : "previews", code, message, hint: hint2 });
|
|
152737
|
+
for (const tag of masked.matchAll(/<\/?Preview\b[^>]*(?:>|$)/g)) {
|
|
152738
|
+
const offset = tag.index, text4 = tag[0];
|
|
152739
|
+
const closing = /^<\/Preview\s*>$/.test(text4);
|
|
152740
|
+
if (closing) {
|
|
152741
|
+
if (!open2) fail(offset, "", "preview-unexpected-close", "Preview has no opening tag", "Remove it or restore its opening tag.");
|
|
152742
|
+
else {
|
|
152743
|
+
const instructions = source2.slice(open2.content, offset).trim();
|
|
152744
|
+
if (!instructions) fail(open2.start, open2.id, "preview-empty", `Preview ${open2.id} is empty`, "Describe the requested output inside the block.");
|
|
152745
|
+
blocks.push({ id: open2.id, instructions, start: open2.start, end: offset + text4.length });
|
|
152746
|
+
open2 = void 0;
|
|
152747
|
+
}
|
|
152748
|
+
continue;
|
|
152749
|
+
}
|
|
152750
|
+
const opening = /^<Preview\s+id=(?:"([^"]*)"|'([^']*)')\s*>$/.exec(text4);
|
|
152751
|
+
if (!opening || open2) {
|
|
152752
|
+
fail(offset, open2?.id ?? "", "preview-tag", "Malformed or nested Preview tag", 'Use one non-nested <Preview id="stable-id"> block with only id.');
|
|
152753
|
+
continue;
|
|
152754
|
+
}
|
|
152755
|
+
const id2 = opening[1] ?? opening[2];
|
|
152756
|
+
if (!PREVIEW_ID.test(id2) || seen.has(id2)) fail(offset, id2, "preview-id", `Invalid or repeated Preview ID ${id2}`, "Use a unique lowercase ID with digits and dashes.");
|
|
152757
|
+
seen.add(id2);
|
|
152758
|
+
open2 = { id: id2, start: offset, content: offset + text4.length };
|
|
152759
|
+
}
|
|
152760
|
+
if (open2) fail(open2.start, open2.id, "preview-unclosed", `Preview ${open2.id} is not closed`, "Add </Preview> after this block.");
|
|
152761
|
+
return { blocks, problems };
|
|
152762
|
+
}
|
|
152763
|
+
|
|
152764
|
+
// ../cli/src/lib/yaml.ts
|
|
152765
|
+
function yamlScalar(s) {
|
|
152766
|
+
const text4 = String(s);
|
|
152767
|
+
if (text4 === "") return '""';
|
|
152768
|
+
if (/^[-?:,[\]{}#&*!|>'"%@`]/.test(text4) || /:\s/.test(text4) || /[\n"]/.test(text4) || /^\s|\s$/.test(text4)) {
|
|
152769
|
+
return JSON.stringify(text4);
|
|
152770
|
+
}
|
|
152771
|
+
return text4;
|
|
152772
|
+
}
|
|
152773
|
+
function unquote(v) {
|
|
152774
|
+
const text4 = String(v).trim();
|
|
152775
|
+
if (text4.startsWith('"') && text4.endsWith('"')) {
|
|
152776
|
+
try {
|
|
152777
|
+
return JSON.parse(text4);
|
|
152778
|
+
} catch {
|
|
152779
|
+
return text4.slice(1, -1);
|
|
152780
|
+
}
|
|
152781
|
+
}
|
|
152782
|
+
if (text4.startsWith("'") && text4.endsWith("'")) return text4.slice(1, -1);
|
|
152783
|
+
return text4;
|
|
152784
|
+
}
|
|
152785
|
+
|
|
152786
|
+
// ../cli/src/lib/agent/studio-def.ts
|
|
152787
|
+
var STUDIO_ID = PREVIEW_ID;
|
|
152788
|
+
var titles = { type: "object", minProperties: 1, propertyNames: { pattern: "^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$" }, additionalProperties: { type: "string", minLength: 1, pattern: "\\S" } };
|
|
152789
|
+
var icon = { anyOf: [
|
|
152790
|
+
{ type: "string", enum: ICON_NAMES },
|
|
152791
|
+
{ type: "array", minItems: 1, maxItems: 12, items: { type: "object", required: ["d"], additionalProperties: false, properties: {
|
|
152792
|
+
d: { type: "string", minLength: 1, pattern: "^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$" },
|
|
152793
|
+
f: { enum: ICON_COLORS },
|
|
152794
|
+
o: { const: true },
|
|
152795
|
+
s: { enum: ICON_COLORS },
|
|
152796
|
+
w: { type: "number", exclusiveMinimum: 0, maximum: 3 }
|
|
152797
|
+
} } }
|
|
152798
|
+
] };
|
|
152799
|
+
var STUDIO_SCHEMA = {
|
|
152800
|
+
type: "object",
|
|
152801
|
+
required: ["name"],
|
|
152802
|
+
additionalProperties: false,
|
|
152803
|
+
properties: {
|
|
152804
|
+
name: { type: "string", minLength: 1, pattern: "\\S" },
|
|
152805
|
+
names: titles,
|
|
152806
|
+
description: { type: "string" },
|
|
152807
|
+
summaries: titles,
|
|
152808
|
+
entrypoints: { type: "array", minItems: 1, maxItems: 10, uniqueItems: true, items: { type: "string", pattern: PREVIEW_ID.source } },
|
|
152809
|
+
needsArtifact: { type: "boolean" },
|
|
152810
|
+
icon,
|
|
152811
|
+
previews: { type: "object", propertyNames: { pattern: PREVIEW_ID.source }, additionalProperties: {
|
|
152812
|
+
type: "object",
|
|
152813
|
+
additionalProperties: false,
|
|
152814
|
+
properties: { title: titles, description: titles, icon }
|
|
152815
|
+
} }
|
|
152816
|
+
}
|
|
152817
|
+
};
|
|
152818
|
+
var validate = new import_ajv.Ajv({ allErrors: true, meta: false, validateSchema: false }).compile(STUDIO_SCHEMA);
|
|
152819
|
+
var comments = /<!--[^]*?(?:-->|$)/g;
|
|
152820
|
+
var blank = (text4) => text4.replace(/[^\r\n]/g, " ");
|
|
152821
|
+
var headingsOf = (body) => [...withoutCode(body).replace(comments, blank).matchAll(/^ {0,3}#{1,2}(?=[ \t\r\n]|$)[^\r\n]*/gm)];
|
|
152822
|
+
function studioSetup(body) {
|
|
152823
|
+
const headings = headingsOf(body);
|
|
152824
|
+
const index = headings.findIndex((h3) => /^ {0,3}##[ \t]+Setup(?:[ \t]+#+)?[ \t]*$/.test(body.slice(h3.index, h3.index + h3[0].length)));
|
|
152825
|
+
if (index === -1) return "";
|
|
152826
|
+
const heading = headings[index];
|
|
152827
|
+
const section = body.slice(heading.index + heading[0].length, headings[index + 1]?.index).trim();
|
|
152828
|
+
return section.replace(comments, "").trim() ? section : "";
|
|
152829
|
+
}
|
|
152830
|
+
function landSections(body, previews) {
|
|
152831
|
+
let visible = "", at2 = 0;
|
|
152832
|
+
for (const { start, end: end2 } of previews) {
|
|
152833
|
+
visible += body.slice(at2, start) + blank(body.slice(start, end2));
|
|
152834
|
+
at2 = end2;
|
|
152835
|
+
}
|
|
152836
|
+
visible += body.slice(at2);
|
|
152837
|
+
const headings = headingsOf(visible);
|
|
152838
|
+
return headings.flatMap((heading, index) => {
|
|
152839
|
+
const start = heading.index;
|
|
152840
|
+
const end2 = start + heading[0].length;
|
|
152841
|
+
if (!/^ {0,3}##[ \t]+Land(?:[ \t]+#+)?[ \t]*$/.test(visible.slice(start, end2))) return [];
|
|
152842
|
+
return [{
|
|
152843
|
+
offset: start + heading[0].indexOf("#"),
|
|
152844
|
+
empty: !visible.slice(end2, headings[index + 1]?.index).replace(comments, "").trim()
|
|
152845
|
+
}];
|
|
152846
|
+
});
|
|
152847
|
+
}
|
|
152848
|
+
function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
|
|
152849
|
+
const problems = [];
|
|
152850
|
+
const fail = (offset, path76, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path76, code, message, hint: hint2 });
|
|
152851
|
+
const result = () => ({ problem: problems.map((p2) => `${p2.file}:${p2.line}:${p2.column} ${p2.path}: ${p2.code} \u2014 ${p2.message}. ${p2.hint}`).join("\n"), problems });
|
|
152852
|
+
if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
|
|
152853
|
+
const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
|
|
152854
|
+
if (!front) {
|
|
152855
|
+
fail(0, "", "yaml-syntax", "Missing YAML frontmatter", "Enclose metadata between --- lines.");
|
|
152856
|
+
return result();
|
|
152857
|
+
}
|
|
152858
|
+
const metaOffset = source2.indexOf("\n") + 1, bodyOffset = front[0].length;
|
|
152859
|
+
const counter = new import_yaml.LineCounter();
|
|
152860
|
+
const document = (0, import_yaml.parseDocument)(front[1], { lineCounter: counter, uniqueKeys: true, strict: true });
|
|
152861
|
+
for (const error62 of document.errors) fail(metaOffset + (error62.pos[0] ?? 0), "", error62.code === "DUPLICATE_KEY" ? "yaml-duplicate-key" : "yaml-syntax", error62.message.split("\n")[0], "Correct the indicated YAML location.");
|
|
152862
|
+
if (problems.length) return result();
|
|
152863
|
+
let raw;
|
|
152864
|
+
try {
|
|
152865
|
+
raw = document.toJS({ maxAliasCount: 0 });
|
|
152866
|
+
} catch {
|
|
152867
|
+
fail(metaOffset, "", "yaml-syntax", "YAML aliases are not supported", "Write metadata explicitly.");
|
|
152868
|
+
return result();
|
|
152869
|
+
}
|
|
152870
|
+
if (!validate(raw)) {
|
|
152871
|
+
for (const error62 of validate.errors ?? []) {
|
|
152872
|
+
const parts = error62.instancePath.split("/").slice(1);
|
|
152873
|
+
const key = error62.params.additionalProperty ?? error62.params.missingProperty;
|
|
152874
|
+
if (key) parts.push(String(key));
|
|
152875
|
+
const node2 = parts.length ? document.getIn(parts, true) : document.contents;
|
|
152876
|
+
fail(metaOffset + (node2?.range?.[0] ?? 0), parts.join("."), "studio-schema", `${parts.join(".") || "metadata"} ${error62.message}`, "Use only Studio metadata and previews: {id: {title?, description?, icon?}} with the declared field types.");
|
|
152877
|
+
}
|
|
152878
|
+
}
|
|
152879
|
+
const body = source2.slice(bodyOffset);
|
|
152880
|
+
const parsed = parsePreviewBlocks(body, from);
|
|
152881
|
+
problems.push(...parsed.problems.map((p2) => ({ ...p2, line: p2.line + source2.slice(0, bodyOffset).split("\n").length - 1 })));
|
|
152882
|
+
if (problems.length) return result();
|
|
152883
|
+
const map3 = raw.previews ?? {};
|
|
152884
|
+
for (const block of parsed.blocks) if (!Object.hasOwn(map3, block.id)) fail(bodyOffset + block.start, `previews.${block.id}`, "preview-metadata-missing", `Preview ${block.id} has no metadata entry`, "Add the ID under previews, using {} if needed.");
|
|
152885
|
+
for (const key of Object.keys(map3)) if (!parsed.blocks.some((b2) => b2.id === key)) fail(metaOffset + (document.getIn(["previews", key], true)?.range?.[0] ?? 0), `previews.${key}`, "preview-body-missing", `Preview ${key} has no body`, "Add its block or remove unused metadata.");
|
|
152886
|
+
if (requirePreviewCopy) for (const block of parsed.blocks) {
|
|
152887
|
+
const metadata = Object.hasOwn(map3, block.id) ? map3[block.id] : void 0;
|
|
152888
|
+
if (!metadata) continue;
|
|
152889
|
+
for (const field2 of ["title", "description"]) for (const lang of ["en", "zh"]) {
|
|
152890
|
+
if (metadata[field2]?.[lang]) continue;
|
|
152891
|
+
fail(
|
|
152892
|
+
bodyOffset + block.start,
|
|
152893
|
+
`previews.${block.id}.${field2}.${lang}`,
|
|
152894
|
+
"preview-display-missing",
|
|
152895
|
+
`Preview ${block.id} needs a ${lang} ${field2}`,
|
|
152896
|
+
"Add non-blank en and zh display text in the Preview metadata."
|
|
152897
|
+
);
|
|
152898
|
+
}
|
|
152899
|
+
}
|
|
152900
|
+
if (requireLand) {
|
|
152901
|
+
const sections = landSections(body, parsed.blocks);
|
|
152902
|
+
if (!sections.length) fail(bodyOffset, "Land", "studio-land-missing", "Missing ## Land section", "Add ## Land to the Studio body and describe delivery, checks and what to record.");
|
|
152903
|
+
for (const [index, { offset, empty }] of sections.entries()) {
|
|
152904
|
+
if (index) fail(bodyOffset + offset, "Land", "studio-land-duplicate", "Repeated ## Land section", "Combine delivery instructions under one ## Land heading.");
|
|
152905
|
+
if (empty) fail(bodyOffset + offset, "Land", "studio-land-empty", "The ## Land section is empty", "Describe delivery, checks and what to record under ## Land.");
|
|
152906
|
+
}
|
|
152907
|
+
}
|
|
152908
|
+
if (problems.length) return result();
|
|
152909
|
+
let rules = "", at2 = 0;
|
|
152910
|
+
for (const block of parsed.blocks) {
|
|
152911
|
+
rules += body.slice(at2, block.start);
|
|
152912
|
+
at2 = block.end;
|
|
152913
|
+
}
|
|
152914
|
+
rules += body.slice(at2);
|
|
152915
|
+
return { def: {
|
|
152916
|
+
id: id2,
|
|
152917
|
+
name: raw.name.trim(),
|
|
152918
|
+
...raw.names ? { names: raw.names } : {},
|
|
152919
|
+
description: raw.description ?? "",
|
|
152920
|
+
needsArtifact: raw.needsArtifact ?? false,
|
|
152921
|
+
...raw.summaries ? { summaries: raw.summaries } : {},
|
|
152922
|
+
...raw.entrypoints ? { entrypoints: raw.entrypoints } : {},
|
|
152923
|
+
...raw.icon ? { icon: raw.icon } : {},
|
|
152924
|
+
previews: parsed.blocks.map((b2) => ({ id: b2.id, instructions: b2.instructions, ...map3[b2.id] })),
|
|
152925
|
+
rules: rules.trim()
|
|
152926
|
+
} };
|
|
152927
|
+
}
|
|
152928
|
+
|
|
152929
|
+
// ../cli/src/lib/shared/guide-topics.ts
|
|
152930
|
+
var GUIDE_TOPICS = ["board", "writing", "add-task", "follow-up", "discuss-goal", "troubleshoot", "card-chat", "task-ui-en", "task-ui-zh", "update-studio", "implement", "settle-background", "archive", "update-questions", "refine", "revise", "resolve", "prune-memory", "review-memory", "describe-project", "review-rejections", "reflect", "write-agent", "write-prompt", "module-map"];
|
|
152931
|
+
|
|
152932
|
+
// ../cli/src/lib/shared/studio-files.ts
|
|
152933
|
+
var STUDIO_FILE = "STUDIO.md";
|
|
152934
|
+
var MCP_FILE = "mcp.json";
|
|
152935
|
+
var VERSION_FILE = "version.json";
|
|
152936
|
+
var PUBLICATION_FILE = ".publication.json";
|
|
152937
|
+
var STUDIO_CATALOG_FILE = "catalog.json";
|
|
152938
|
+
var KB = 1024;
|
|
152939
|
+
var FILE_LIMITS = { file: 2 * KB * KB, total: 10 * KB * KB, count: 500, path: 512 };
|
|
152940
|
+
var officialId = (folder2) => `wf_builtin_${folder2.replace(/-/g, "_")}`;
|
|
152941
|
+
var hashInput = (files) => JSON.stringify(Object.entries(files).sort(([a2], [b2]) => a2 < b2 ? -1 : 1));
|
|
152942
|
+
var landsOf = (_def) => ({ lands: true });
|
|
152943
|
+
var encoder = new TextEncoder();
|
|
152944
|
+
var safeStudioPath = (file2) => encoder.encode(file2).length <= FILE_LIMITS.path && !/[<>:"\\|?*\x00-\x1f\x7f]/.test(file2) && file2.split("/").every((part) => !!part && encoder.encode(part).length <= 255 && !/[. ]$/.test(part) && !/^(?:\.git$|(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$))/i.test(part));
|
|
152945
|
+
var SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
152946
|
+
var skillFile = (name) => "skills/" + name + "/SKILL.md";
|
|
152947
|
+
function skillMetadata(source2, directory3) {
|
|
152948
|
+
const front = /^\uFEFF?---[^\S\r\n]*\r?\n([\s\S]*?)^---[^\S\r\n]*(?:\r?\n|$)/m.exec(source2);
|
|
152949
|
+
if (!front || front.index !== 0) return "Start SKILL.md with YAML frontmatter";
|
|
152950
|
+
const doc = (0, import_yaml3.parseDocument)(front[1]);
|
|
152951
|
+
if (doc.errors.length || !(0, import_yaml3.isMap)(doc.contents)) return "Use valid YAML frontmatter with unique keys";
|
|
152952
|
+
let data;
|
|
152953
|
+
try {
|
|
152954
|
+
data = doc.toJS({ maxAliasCount: 0 });
|
|
152955
|
+
} catch {
|
|
152956
|
+
return "Use literal YAML metadata";
|
|
152957
|
+
}
|
|
152958
|
+
const { name, description, license, compatibility, metadata, "allowed-tools": allowedTools, ...extra } = data;
|
|
152959
|
+
if (name !== directory3 || !SKILL_NAME.test(directory3) || directory3.length > 64) return "Set name to match the containing skill directory (1\u201364 lowercase letters, digits and single hyphens)";
|
|
152960
|
+
if (typeof description !== "string" || !description.trim() || [...description].length > 1024) return "Set description to 1\u20131024 characters";
|
|
152961
|
+
if (license !== void 0 && typeof license !== "string") return "Set license to a string";
|
|
152962
|
+
if (compatibility !== void 0 && (typeof compatibility !== "string" || !compatibility.trim() || [...compatibility].length > 500)) return "Set compatibility to 1\u2013500 characters";
|
|
152963
|
+
if (metadata !== void 0 && (!metadata || typeof metadata !== "object" || Array.isArray(metadata) || Object.values(metadata).some((value) => typeof value !== "string"))) return "Set metadata to a map of strings";
|
|
152964
|
+
if (allowedTools !== void 0 && typeof allowedTools !== "string") return "Set allowed-tools to a string";
|
|
152965
|
+
if (Object.keys(extra).length) return "Use standard Agent Skills fields and put custom fields under metadata";
|
|
152966
|
+
return { name: directory3, description: description.trim().replace(/\s+/g, " ") };
|
|
152967
|
+
}
|
|
152968
|
+
function studioSkills(files) {
|
|
152969
|
+
return Object.keys(files).sort().flatMap((file2) => {
|
|
152970
|
+
const match = /^skills\/([^/]+)\/SKILL\.md$/.exec(file2);
|
|
152971
|
+
if (!match) return [];
|
|
152972
|
+
const skill = skillMetadata(files[file2], match[1]);
|
|
152973
|
+
return typeof skill === "string" ? [] : [skill];
|
|
152974
|
+
});
|
|
152975
|
+
}
|
|
152976
|
+
var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
|
|
152977
|
+
var studioScreenshotPrefix = (path76) => "data:" + (path76.endsWith(".png") ? "image/png" : /\.jpe?g$/.test(path76) ? "image/jpeg" : "image/webp") + ";base64,";
|
|
152978
|
+
function studioFileBody(path76, text4) {
|
|
152979
|
+
if (path76.startsWith("screenshots/") && isAboutFile(path76)) {
|
|
152980
|
+
const prefix = studioScreenshotPrefix(path76);
|
|
152981
|
+
if (text4.startsWith(prefix)) {
|
|
152982
|
+
const data = text4.slice(prefix.length);
|
|
152983
|
+
if (/^[A-Za-z0-9+/]*={0,2}$/.test(data) && data.length % 4 === 0) {
|
|
152984
|
+
const raw = atob(data);
|
|
152985
|
+
if (btoa(raw) === data) return { bytes: Uint8Array.from(raw, (c2) => c2.charCodeAt(0)), binary: true };
|
|
152986
|
+
}
|
|
152987
|
+
}
|
|
152988
|
+
}
|
|
152989
|
+
const bytes = encoder.encode(text4);
|
|
152990
|
+
if (new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes) !== text4) throw Error("Invalid UTF-8.");
|
|
152991
|
+
return { bytes, binary: false };
|
|
152992
|
+
}
|
|
152993
|
+
function studioSizeProblem(file2, size, total) {
|
|
152994
|
+
if (size > FILE_LIMITS.file) return { file: file2, reason: "is larger than 2 MiB", tooLarge: true };
|
|
152995
|
+
if (total > FILE_LIMITS.total) return { file: "files", reason: "are larger than 10 MiB together", tooLarge: true };
|
|
152996
|
+
}
|
|
152997
|
+
function mcpProblem(text4) {
|
|
152998
|
+
let read5;
|
|
152999
|
+
try {
|
|
153000
|
+
read5 = JSON.parse(text4);
|
|
153001
|
+
} catch {
|
|
153002
|
+
return "is not JSON";
|
|
153003
|
+
}
|
|
153004
|
+
const servers = read5?.mcpServers;
|
|
153005
|
+
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
|
|
153006
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
153007
|
+
const { command, args: args2, ...rest } = server ?? {};
|
|
153008
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return `names a server \`${name}\`; use lowercase letters, digits and dashes`;
|
|
153009
|
+
if (typeof command !== "string" || !command) return `server \`${name}\` needs a \`command\``;
|
|
153010
|
+
if (args2 !== void 0 && !(Array.isArray(args2) && args2.every((a2) => typeof a2 === "string"))) return `server \`${name}\`: \`args\` must be a list of strings`;
|
|
153011
|
+
if (Object.keys(rest).length) return `server \`${name}\` takes only \`command\` and \`args\``;
|
|
153012
|
+
}
|
|
153013
|
+
return null;
|
|
153014
|
+
}
|
|
153015
|
+
function formatStudioProblem({ file: file2, line, column, reason, hint: hint2 }) {
|
|
153016
|
+
const location = line === void 0 ? file2 : `${file2}:${line}:${column ?? 1}`;
|
|
153017
|
+
return `${location}: ${reason}${hint2 ? `. ${hint2}` : ""}`;
|
|
153018
|
+
}
|
|
153019
|
+
function checkStudioFiles(value, official = false, checks = {}) {
|
|
153020
|
+
const read5 = inspect(value, official, checks);
|
|
153021
|
+
const first = read5.problems[0];
|
|
153022
|
+
return first ? { ok: false, ...first, problems: read5.problems } : { ok: true, def: read5.def, files: read5.files };
|
|
153023
|
+
}
|
|
153024
|
+
function inspect(value, official, { allowLegacyPreviewCopy, allowLegacyLand } = {}) {
|
|
153025
|
+
const problems = [];
|
|
153026
|
+
const fail = (file2, reason, tooLarge = false) => {
|
|
153027
|
+
problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
|
|
153028
|
+
return { problems };
|
|
153029
|
+
};
|
|
153030
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
|
|
153031
|
+
const files = Object.assign(/* @__PURE__ */ Object.create(null), Object.fromEntries(Object.entries(value).filter(([file2]) => file2 !== VERSION_FILE && file2 !== PUBLICATION_FILE)));
|
|
153032
|
+
const entries = Object.entries(files);
|
|
153033
|
+
if (entries.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
|
|
153034
|
+
let total = 0;
|
|
153035
|
+
const skills = /* @__PURE__ */ new Set();
|
|
153036
|
+
const paths = new Map([VERSION_FILE, PUBLICATION_FILE].map((file2) => [file2, { path: file2, file: true }]));
|
|
153037
|
+
const pathProblem = (file2, reason) => problems.push({ file: file2, reason, code: "studio-path", hint: "Use a safe relative file path unique within the Studio." });
|
|
153038
|
+
for (const [file2, text4] of entries) {
|
|
153039
|
+
if (typeof text4 !== "string" || text4.includes("\0")) {
|
|
153040
|
+
fail(file2, "is not a text file");
|
|
153041
|
+
continue;
|
|
153042
|
+
}
|
|
153043
|
+
let size;
|
|
153044
|
+
try {
|
|
153045
|
+
size = studioFileBody(file2, text4).bytes.length;
|
|
153046
|
+
} catch {
|
|
153047
|
+
fail(file2, "is not valid UTF-8");
|
|
153048
|
+
continue;
|
|
153049
|
+
}
|
|
153050
|
+
total += size;
|
|
153051
|
+
const limit = studioSizeProblem(file2, size, total);
|
|
153052
|
+
if (limit) return fail(limit.file, limit.reason, true);
|
|
153053
|
+
if (!safeStudioPath(file2)) {
|
|
153054
|
+
pathProblem(file2, "Unsafe Studio path");
|
|
153055
|
+
continue;
|
|
153056
|
+
}
|
|
153057
|
+
const parts = file2.split("/");
|
|
153058
|
+
for (let i = 1; i <= parts.length; i++) {
|
|
153059
|
+
const at2 = parts.slice(0, i).join("/");
|
|
153060
|
+
const key = at2.normalize("NFC").toLowerCase();
|
|
153061
|
+
const prior = paths.get(key);
|
|
153062
|
+
if (prior && (prior.path !== at2 || prior.file || i === parts.length)) {
|
|
153063
|
+
pathProblem(file2, "Path conflicts with " + prior.path);
|
|
153064
|
+
break;
|
|
153065
|
+
}
|
|
153066
|
+
paths.set(key, { path: at2, file: i === parts.length });
|
|
153067
|
+
}
|
|
153068
|
+
if (file2.toLowerCase() === STUDIO_CATALOG_FILE && (!official || file2 !== STUDIO_CATALOG_FILE)) {
|
|
153069
|
+
pathProblem(file2, "The root catalog.json is reserved for official Studio metadata");
|
|
153070
|
+
}
|
|
153071
|
+
if (file2 === MCP_FILE) {
|
|
153072
|
+
const problem2 = official ? mcpProblem(text4) : "MCP servers are available to official Studios";
|
|
153073
|
+
if (problem2) fail(file2, problem2);
|
|
153074
|
+
}
|
|
153075
|
+
if (parts[0] === "skills") {
|
|
153076
|
+
const name = parts[1];
|
|
153077
|
+
if (parts.length < 3 || !name || !SKILL_NAME.test(name) || name.length > 64) {
|
|
153078
|
+
pathProblem(file2, "Expected skills/<name>/<path> with a valid Agent Skills name");
|
|
153079
|
+
} else skills.add(name);
|
|
153080
|
+
}
|
|
153081
|
+
}
|
|
153082
|
+
for (const name of skills) {
|
|
153083
|
+
const file2 = skillFile(name);
|
|
153084
|
+
const text4 = files[file2];
|
|
153085
|
+
const problem2 = text4 === void 0 ? "SKILL.md is missing" : typeof text4 === "string" ? skillMetadata(text4, name) : null;
|
|
153086
|
+
if (typeof problem2 === "string") problems.push({
|
|
153087
|
+
file: file2,
|
|
153088
|
+
line: 1,
|
|
153089
|
+
column: 1,
|
|
153090
|
+
code: "studio-skill",
|
|
153091
|
+
message: problem2,
|
|
153092
|
+
reason: problem2,
|
|
153093
|
+
hint: "Follow the Agent Skills specification at https://agentskills.io/specification."
|
|
153094
|
+
});
|
|
153095
|
+
}
|
|
153096
|
+
const source2 = files[STUDIO_FILE];
|
|
153097
|
+
const read5 = typeof source2 === "string" ? parseStudioFile("studio", source2, STUDIO_FILE, { requirePreviewCopy: !official && !allowLegacyPreviewCopy, requireLand: !allowLegacyLand }) : null;
|
|
153098
|
+
if (!read5) fail(STUDIO_FILE, "is missing");
|
|
153099
|
+
else if ("problem" in read5) for (const problem2 of read5.problems) problems.push({ ...problem2, reason: problem2.message });
|
|
153100
|
+
if (!read5 || "problem" in read5) return { problems };
|
|
153101
|
+
const def = read5.def;
|
|
153102
|
+
for (const [file2, text4] of Object.entries(files)) {
|
|
153103
|
+
if (typeof text4 !== "string" || !file2.endsWith(".md")) continue;
|
|
153104
|
+
const masked = withoutCode(text4);
|
|
153105
|
+
const reference = (offset, link, message) => problems.push({ file: file2, ...sourcePosition(text4, offset), path: link, code: "studio-reference", message, reason: message, hint: "Use an existing safe relative resource or a shipped AKB Guide." });
|
|
153106
|
+
for (const match of masked.matchAll(/!?\[[^\]]*\]\((<[^>\r\n]+>|[^\s)]+)(?:\s+[^)]*)?\)/g)) {
|
|
153107
|
+
const link = match[1].replace(/^<|>$/g, "");
|
|
153108
|
+
if (/^(?:https?:|mailto:|#)/i.test(link)) continue;
|
|
153109
|
+
let decoded;
|
|
153110
|
+
try {
|
|
153111
|
+
decoded = decodeURIComponent(link.split(/[?#]/)[0]);
|
|
153112
|
+
} catch {
|
|
153113
|
+
reference(match.index, link, "Invalid resource URL");
|
|
153114
|
+
continue;
|
|
153115
|
+
}
|
|
153116
|
+
if (/^(?:[a-z][\w+.-]*:|[/\\])|\\/i.test(decoded) || decoded.split("/").includes("..")) {
|
|
153117
|
+
reference(match.index, link, "Unsafe resource path");
|
|
153118
|
+
continue;
|
|
153119
|
+
}
|
|
153120
|
+
const target = [...file2.split("/").slice(0, -1), ...decoded.split("/").filter((p2) => p2 !== ".")].join("/");
|
|
153121
|
+
if (!Object.hasOwn(files, target)) reference(match.index, link, `Missing resource ${target}`);
|
|
153122
|
+
}
|
|
153123
|
+
for (const match of text4.matchAll(/akb guide ([a-z][a-z-]*)/g)) if (!GUIDE_TOPICS.includes(match[1])) reference(match.index, match[1], `Unknown AKB Guide ${match[1]}`);
|
|
153124
|
+
}
|
|
153125
|
+
return { problems, def, files };
|
|
153126
|
+
}
|
|
153127
|
+
function previewCatalog(files) {
|
|
153128
|
+
const read5 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
153129
|
+
if ("problem" in read5) throw new Error(read5.problem);
|
|
153130
|
+
return read5.def.previews;
|
|
153131
|
+
}
|
|
153132
|
+
|
|
153133
|
+
// ../cli/src/lib/shared/studio-package.ts
|
|
153134
|
+
var LOCAL = 30;
|
|
153135
|
+
var CENTRAL = 46;
|
|
153136
|
+
var END = 22;
|
|
153137
|
+
var UTF8 = 2048;
|
|
153138
|
+
var encoder2 = new TextEncoder();
|
|
153139
|
+
var decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
153140
|
+
var crcTable = Uint32Array.from({ length: 256 }, (_2, byte) => {
|
|
153141
|
+
for (let bit = 0; bit < 8; bit++) byte = byte >>> 1 ^ (byte & 1 ? 3988292384 : 0);
|
|
153142
|
+
return byte;
|
|
153143
|
+
});
|
|
153144
|
+
function crc32(bytes) {
|
|
153145
|
+
let crc = -1;
|
|
153146
|
+
for (const byte of bytes) crc = crc >>> 8 ^ crcTable[(crc ^ byte) & 255];
|
|
153147
|
+
return (crc ^ -1) >>> 0;
|
|
153148
|
+
}
|
|
153149
|
+
var STUDIO_ZIP_LIMIT = FILE_LIMITS.total + FILE_LIMITS.count * (LOCAL + CENTRAL + 2 * FILE_LIMITS.path) + END;
|
|
153150
|
+
var isDigest = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
153151
|
+
var validPath = (name) => name !== VERSION_FILE && safeStudioPath(name);
|
|
153152
|
+
function encodeStudioZip(files) {
|
|
153153
|
+
const names2 = Object.keys(files).sort();
|
|
153154
|
+
if (!names2.length || names2.length > FILE_LIMITS.count || names2.some((name) => !validPath(name))) throw Error("Invalid Studio ZIP paths.");
|
|
153155
|
+
const entries = names2.map((name) => ({ name: encoder2.encode(name), ...studioFileBody(name, files[name]) }));
|
|
153156
|
+
let expandedBytes = 0, localBytes = 0, directoryBytes = 0;
|
|
153157
|
+
for (const { name, bytes } of entries) {
|
|
153158
|
+
expandedBytes += bytes.length;
|
|
153159
|
+
localBytes += LOCAL + name.length + bytes.length;
|
|
153160
|
+
directoryBytes += CENTRAL + name.length;
|
|
153161
|
+
if (bytes.length > FILE_LIMITS.file) throw Error("A Studio file exceeds 2 MiB.");
|
|
153162
|
+
}
|
|
153163
|
+
if (!expandedBytes || expandedBytes > FILE_LIMITS.total) throw Error("Invalid Studio size. The package limit is 10 MiB.");
|
|
153164
|
+
const zip = new Uint8Array(localBytes + directoryBytes + END);
|
|
153165
|
+
const view = new DataView(zip.buffer);
|
|
153166
|
+
const u16 = (at2, value) => view.setUint16(at2, value, true);
|
|
153167
|
+
const u32 = (at2, value) => view.setUint32(at2, value, true);
|
|
153168
|
+
let local = 0, central = localBytes;
|
|
153169
|
+
for (const { name, bytes, binary } of entries) {
|
|
153170
|
+
const sum = crc32(bytes);
|
|
153171
|
+
u32(local, 67324752);
|
|
153172
|
+
u16(local + 4, 20);
|
|
153173
|
+
u16(local + 6, UTF8);
|
|
153174
|
+
u16(local + 12, 33);
|
|
153175
|
+
u32(local + 14, sum);
|
|
153176
|
+
u32(local + 18, bytes.length);
|
|
153177
|
+
u32(local + 22, bytes.length);
|
|
153178
|
+
u16(local + 26, name.length);
|
|
153179
|
+
zip.set(name, local + LOCAL);
|
|
153180
|
+
zip.set(bytes, local + LOCAL + name.length);
|
|
153181
|
+
u32(central, 33639248);
|
|
153182
|
+
u16(central + 4, 20);
|
|
153183
|
+
u16(central + 6, 20);
|
|
153184
|
+
u16(central + 8, UTF8);
|
|
153185
|
+
u16(central + 14, 33);
|
|
153186
|
+
u32(central + 16, sum);
|
|
153187
|
+
u32(central + 20, bytes.length);
|
|
153188
|
+
u32(central + 24, bytes.length);
|
|
153189
|
+
u16(central + 28, name.length);
|
|
153190
|
+
u16(central + 36, binary ? 0 : 1);
|
|
153191
|
+
u32(central + 42, local);
|
|
153192
|
+
zip.set(name, central + CENTRAL);
|
|
153193
|
+
local += LOCAL + name.length + bytes.length;
|
|
153194
|
+
central += CENTRAL + name.length;
|
|
153195
|
+
}
|
|
153196
|
+
u32(central, 101010256);
|
|
153197
|
+
u16(central + 8, entries.length);
|
|
153198
|
+
u16(central + 10, entries.length);
|
|
153199
|
+
u32(central + 12, directoryBytes);
|
|
153200
|
+
u32(central + 16, localBytes);
|
|
153201
|
+
return { zip, expandedBytes };
|
|
153202
|
+
}
|
|
153203
|
+
function decodeStudioZip(zip) {
|
|
153204
|
+
const invalid2 = () => Error("Invalid Studio ZIP.");
|
|
153205
|
+
if (zip.length < END || zip.length > STUDIO_ZIP_LIMIT) throw invalid2();
|
|
153206
|
+
const view = new DataView(zip.buffer, zip.byteOffset, zip.byteLength);
|
|
153207
|
+
const u16 = (at2) => view.getUint16(at2, true);
|
|
153208
|
+
const u32 = (at2) => view.getUint32(at2, true);
|
|
153209
|
+
const end2 = zip.length - END;
|
|
153210
|
+
const count3 = u16(end2 + 10);
|
|
153211
|
+
let central = u32(end2 + 16), local = 0, total = 0, previous = "";
|
|
153212
|
+
const start = central;
|
|
153213
|
+
if (u32(end2) !== 101010256 || !count3 || count3 > FILE_LIMITS.count || start > end2) throw invalid2();
|
|
153214
|
+
const files = [];
|
|
153215
|
+
for (let index = 0; index < count3; index++) {
|
|
153216
|
+
if (central + CENTRAL > end2 || local + LOCAL > start) throw invalid2();
|
|
153217
|
+
const length = u16(central + 28), size = u32(central + 24);
|
|
153218
|
+
const from = local + LOCAL + length;
|
|
153219
|
+
total += size;
|
|
153220
|
+
if (central + CENTRAL + length > end2 || from + size > start || size > FILE_LIMITS.file || total > FILE_LIMITS.total) throw invalid2();
|
|
153221
|
+
const name = decoder.decode(zip.subarray(central + CENTRAL, central + CENTRAL + length));
|
|
153222
|
+
if (!validPath(name) || name <= previous) throw invalid2();
|
|
153223
|
+
const bytes = zip.subarray(from, from + size);
|
|
153224
|
+
const binary = u16(central + 36) === 0;
|
|
153225
|
+
if (binary && !(name.startsWith("screenshots/") && isAboutFile(name))) throw invalid2();
|
|
153226
|
+
let text4 = "";
|
|
153227
|
+
if (binary) {
|
|
153228
|
+
for (let at2 = 0; at2 < bytes.length; at2 += 32768) text4 += String.fromCharCode(...bytes.subarray(at2, at2 + 32768));
|
|
153229
|
+
text4 = studioScreenshotPrefix(name) + btoa(text4);
|
|
153230
|
+
} else {
|
|
153231
|
+
text4 = decoder.decode(bytes);
|
|
153232
|
+
if (text4.includes("\0")) throw invalid2();
|
|
153233
|
+
}
|
|
153234
|
+
files.push([name, text4]);
|
|
153235
|
+
previous = name;
|
|
153236
|
+
central += CENTRAL + length;
|
|
153237
|
+
local = from + size;
|
|
153238
|
+
}
|
|
153239
|
+
const result = Object.fromEntries(files);
|
|
153240
|
+
const canonical = encodeStudioZip(result).zip;
|
|
153241
|
+
if (canonical.length !== zip.length || !canonical.every((byte, i) => zip[i] === byte)) throw invalid2();
|
|
153242
|
+
return result;
|
|
153243
|
+
}
|
|
153244
|
+
async function readStudioDownload(response, size) {
|
|
153245
|
+
if (!response.body || Number(response.headers.get("content-length")) !== size) throw Error("Invalid Studio package length.");
|
|
153246
|
+
const reader = response.body.getReader();
|
|
153247
|
+
const bytes = new Uint8Array(size);
|
|
153248
|
+
let offset = 0;
|
|
153249
|
+
try {
|
|
153250
|
+
for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) {
|
|
153251
|
+
if (offset + chunk.value.length > size) throw Error("Invalid Studio package length.");
|
|
153252
|
+
bytes.set(chunk.value, offset);
|
|
153253
|
+
offset += chunk.value.length;
|
|
153254
|
+
}
|
|
153255
|
+
if (offset !== size) throw Error("Incomplete Studio package.");
|
|
153256
|
+
return bytes;
|
|
153257
|
+
} finally {
|
|
153258
|
+
await reader.cancel().catch(() => {
|
|
153259
|
+
});
|
|
153260
|
+
}
|
|
153261
|
+
}
|
|
153262
|
+
|
|
153263
|
+
// ../cli/src/lib/shared/goal.ts
|
|
153264
|
+
function goalRoute(discussion, goal) {
|
|
153265
|
+
return `/v1/discussions/${encodeURIComponent(discussion)}/goals/${encodeURIComponent(goal)}`;
|
|
152606
153266
|
}
|
|
152607
153267
|
|
|
152608
153268
|
// src/protocol.ts
|
|
152609
|
-
var AKB_VERSION = true ? "0.11.
|
|
152610
|
-
var AKB_CONTRACT = true ?
|
|
153269
|
+
var AKB_VERSION = true ? "0.11.99" : "0.0.0";
|
|
153270
|
+
var AKB_CONTRACT = true ? 33 : 0;
|
|
152611
153271
|
|
|
152612
153272
|
// src/secrets.ts
|
|
152613
153273
|
import fs20 from "node:fs";
|
|
@@ -153170,12 +153830,12 @@ function mergeRetryHistory(...histories) {
|
|
|
153170
153830
|
return [...new Map(records.map((record2) => [JSON.stringify(record2), record2])).values()].sort((a2, b2) => a2.at.localeCompare(b2.at));
|
|
153171
153831
|
}
|
|
153172
153832
|
async function waitForRetry(at2, stopped2) {
|
|
153173
|
-
const
|
|
153174
|
-
if (!
|
|
153833
|
+
const delay4 = Math.max(0, at2 - Date.now());
|
|
153834
|
+
if (!delay4) return;
|
|
153175
153835
|
let timer;
|
|
153176
153836
|
try {
|
|
153177
153837
|
await Promise.race([new Promise((resolve2) => {
|
|
153178
|
-
timer = setTimeout(resolve2,
|
|
153838
|
+
timer = setTimeout(resolve2, delay4);
|
|
153179
153839
|
}), ...stopped2 ? [stopped2] : []]);
|
|
153180
153840
|
} finally {
|
|
153181
153841
|
clearTimeout(timer);
|
|
@@ -153246,10 +153906,10 @@ function planRetry(failure2, attempt, now = Date.now(), backoff = backoffMs, tas
|
|
|
153246
153906
|
return { pause: "authorization" };
|
|
153247
153907
|
}
|
|
153248
153908
|
if (attempt > of) return { pause: "limit" };
|
|
153249
|
-
const
|
|
153250
|
-
const valid =
|
|
153909
|
+
const delay4 = failure2.retryAfterMs;
|
|
153910
|
+
const valid = delay4 !== void 0 && !Number.isNaN(delay4) && delay4 >= 0;
|
|
153251
153911
|
const immediate = failure2.source === "validation";
|
|
153252
|
-
const wait3 = valid ?
|
|
153912
|
+
const wait3 = valid ? delay4 : immediate ? 0 : backoff(attempt + 1);
|
|
153253
153913
|
const cap = task && failure2.code === "rate_limited" && valid ? 24 * 60 * 6e4 : CAP_MS;
|
|
153254
153914
|
if (wait3 > cap) return { pause: "wait_too_long" };
|
|
153255
153915
|
return { plan: { at: now + wait3, of, failure: failure2 } };
|
|
@@ -153489,12 +154149,12 @@ function bounded(work, ms, reason) {
|
|
|
153489
154149
|
}
|
|
153490
154150
|
|
|
153491
154151
|
// ../cli/src/lib/shared/reply-parts.ts
|
|
153492
|
-
function imageMime(
|
|
153493
|
-
const at2 = (...v) => v.every((n, i) =>
|
|
153494
|
-
const text4 = (a2, b2) => String.fromCharCode(...
|
|
153495
|
-
if (
|
|
154152
|
+
function imageMime(bytes) {
|
|
154153
|
+
const at2 = (...v) => v.every((n, i) => bytes[i] === n);
|
|
154154
|
+
const text4 = (a2, b2) => String.fromCharCode(...bytes.slice(a2, b2));
|
|
154155
|
+
if (bytes.length >= 24 && at2(137, 80, 78, 71, 13, 10, 26, 10) && text4(12, 16) === "IHDR" && bytes.slice(16, 20).some(Boolean) && bytes.slice(20, 24).some(Boolean)) return "image/png";
|
|
153496
154156
|
if (at2(255, 216, 255)) return "image/jpeg";
|
|
153497
|
-
if (
|
|
154157
|
+
if (bytes.length >= 13 && ["GIF87a", "GIF89a"].includes(text4(0, 6)) && (bytes[6] || bytes[7]) && (bytes[8] || bytes[9])) return "image/gif";
|
|
153498
154158
|
if (text4(0, 4) === "RIFF" && text4(8, 12) === "WEBP") return "image/webp";
|
|
153499
154159
|
return void 0;
|
|
153500
154160
|
}
|
|
@@ -153819,8 +154479,8 @@ function createTail(log) {
|
|
|
153819
154479
|
// ../cli/package.json
|
|
153820
154480
|
var package_default = {
|
|
153821
154481
|
name: "wildcrane",
|
|
153822
|
-
version: "0.11.
|
|
153823
|
-
akbContract:
|
|
154482
|
+
version: "0.11.99",
|
|
154483
|
+
akbContract: 33,
|
|
153824
154484
|
canonicalCommands: true,
|
|
153825
154485
|
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.",
|
|
153826
154486
|
keywords: [
|
|
@@ -154113,9 +154773,9 @@ async function oneTurn(io, options) {
|
|
|
154113
154773
|
const images = [];
|
|
154114
154774
|
const files = [];
|
|
154115
154775
|
for (const file2 of io.imageFiles ?? []) {
|
|
154116
|
-
const
|
|
154117
|
-
const mimeType =
|
|
154118
|
-
if (mimeType) images.push({ type: "image", mimeType, data:
|
|
154776
|
+
const bytes = caps.image === true ? fs14.readFileSync(file2) : void 0;
|
|
154777
|
+
const mimeType = bytes && imageMime(bytes);
|
|
154778
|
+
if (mimeType) images.push({ type: "image", mimeType, data: bytes.toString("base64") });
|
|
154119
154779
|
else files.push(file2);
|
|
154120
154780
|
}
|
|
154121
154781
|
if (Date.now() >= preparingUntil) throw Error("ACP preparation timed out.");
|
|
@@ -154294,30 +154954,30 @@ import { existsSync } from "node:fs";
|
|
|
154294
154954
|
function antigravityConversationFile(session) {
|
|
154295
154955
|
if (/^[a-f0-9-]{36}$/i.test(session)) return home(".gemini", "antigravity-cli", "conversations", `${session}.db`);
|
|
154296
154956
|
}
|
|
154297
|
-
function varint(
|
|
154957
|
+
function varint(bytes, offset) {
|
|
154298
154958
|
let value = 0;
|
|
154299
|
-
for (let shift = 0; shift < 70 && offset.value <
|
|
154300
|
-
const byte =
|
|
154959
|
+
for (let shift = 0; shift < 70 && offset.value < bytes.length; shift += 7) {
|
|
154960
|
+
const byte = bytes[offset.value++];
|
|
154301
154961
|
value += (byte & 127) * 2 ** shift;
|
|
154302
154962
|
if (byte < 128) return value;
|
|
154303
154963
|
}
|
|
154304
154964
|
throw new Error("Invalid Antigravity conversation metadata");
|
|
154305
154965
|
}
|
|
154306
|
-
function* fields(
|
|
154966
|
+
function* fields(bytes) {
|
|
154307
154967
|
const offset = { value: 0 };
|
|
154308
|
-
while (offset.value <
|
|
154309
|
-
const tag = varint(
|
|
154968
|
+
while (offset.value < bytes.length) {
|
|
154969
|
+
const tag = varint(bytes, offset);
|
|
154310
154970
|
const number4 = Math.floor(tag / 8);
|
|
154311
154971
|
const wire = tag % 8;
|
|
154312
154972
|
if (number4 < 1 || number4 >= 2 ** 29) throw new Error("Invalid Antigravity conversation metadata");
|
|
154313
154973
|
if (wire === 0) {
|
|
154314
|
-
yield [number4, varint(
|
|
154974
|
+
yield [number4, varint(bytes, offset)];
|
|
154315
154975
|
continue;
|
|
154316
154976
|
}
|
|
154317
|
-
const size = wire === 2 ? varint(
|
|
154977
|
+
const size = wire === 2 ? varint(bytes, offset) : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
154318
154978
|
const end2 = offset.value + size;
|
|
154319
|
-
if (size < 0 || end2 >
|
|
154320
|
-
if (wire === 2) yield [number4,
|
|
154979
|
+
if (size < 0 || end2 > bytes.length) throw new Error("Invalid Antigravity conversation metadata");
|
|
154980
|
+
if (wire === 2) yield [number4, bytes.subarray(offset.value, end2)];
|
|
154321
154981
|
offset.value = end2;
|
|
154322
154982
|
}
|
|
154323
154983
|
}
|
|
@@ -154349,7 +155009,7 @@ function recordedContextLimit(data) {
|
|
|
154349
155009
|
const limit = varintField(bytesField(bytesField(bytesField(data, 1), 9), 10), 4);
|
|
154350
155010
|
return limit !== void 0 && Number.isSafeInteger(limit) && limit > 0 ? limit : void 0;
|
|
154351
155011
|
}
|
|
154352
|
-
var utf8 = (
|
|
155012
|
+
var utf8 = (bytes) => bytes && Buffer.from(bytes).toString("utf8");
|
|
154353
155013
|
function stepUuid(stepRow, index) {
|
|
154354
155014
|
if (!Number.isSafeInteger(index) || index < 0) return;
|
|
154355
155015
|
const id2 = bytesField(stepRow.get(index)?.metadata, 12);
|
|
@@ -155602,9 +156262,9 @@ function readIndex() {
|
|
|
155602
156262
|
entries.delete(sessionId);
|
|
155603
156263
|
continue;
|
|
155604
156264
|
}
|
|
155605
|
-
const
|
|
156265
|
+
const sessionDir2 = str2(record2.sessionDir).trim();
|
|
155606
156266
|
const workDir = str2(record2.workDir).trim();
|
|
155607
|
-
if (
|
|
156267
|
+
if (sessionDir2 && workDir) entries.set(sessionId, { sessionId, sessionDir: sessionDir2, workDir });
|
|
155608
156268
|
}
|
|
155609
156269
|
return entries;
|
|
155610
156270
|
}
|
|
@@ -155624,13 +156284,13 @@ function findKimiSession(cwd, since) {
|
|
|
155624
156284
|
}
|
|
155625
156285
|
return newest2?.id;
|
|
155626
156286
|
}
|
|
155627
|
-
function wireFiles(
|
|
155628
|
-
const agents = join3(
|
|
156287
|
+
function wireFiles(sessionDir2) {
|
|
156288
|
+
const agents = join3(sessionDir2, "agents");
|
|
155629
156289
|
let names2;
|
|
155630
156290
|
try {
|
|
155631
156291
|
names2 = readdirSync2(agents);
|
|
155632
156292
|
} catch {
|
|
155633
|
-
return [{ path: join3(
|
|
156293
|
+
return [{ path: join3(sessionDir2, "wire.jsonl"), main: true }];
|
|
155634
156294
|
}
|
|
155635
156295
|
const ordered = names2.sort((a2, b2) => Number(b2 === "main") - Number(a2 === "main"));
|
|
155636
156296
|
return ordered.map((name) => ({ path: join3(agents, name, "wire.jsonl"), main: name === "main" }));
|
|
@@ -156210,19 +156870,19 @@ var settle_background_default = "Wait for and collect needed results from this t
|
|
|
156210
156870
|
|
|
156211
156871
|
// ../cli/src/lib/agent/wire/codex-background.ts
|
|
156212
156872
|
var CODEX_SETTLE_MS = { turn: 6e4, verify: 1e4 };
|
|
156213
|
-
function summary(text4,
|
|
156214
|
-
if (Buffer.byteLength(text4) <=
|
|
156215
|
-
return Buffer.from(text4).subarray(0,
|
|
156873
|
+
function summary(text4, bytes = 1800) {
|
|
156874
|
+
if (Buffer.byteLength(text4) <= bytes) return text4;
|
|
156875
|
+
return Buffer.from(text4).subarray(0, bytes).toString("utf8") + " [truncated; see the original thread item in the run log]";
|
|
156216
156876
|
}
|
|
156217
156877
|
function batch(work) {
|
|
156218
156878
|
const result = [];
|
|
156219
|
-
let
|
|
156879
|
+
let bytes = 0;
|
|
156220
156880
|
for (const entry of work) {
|
|
156221
156881
|
const size = Buffer.byteLength(JSON.stringify(entry));
|
|
156222
156882
|
if (size > 15e3) throw Error("A Codex background identifier exceeds the snapshot limit.");
|
|
156223
|
-
if (
|
|
156883
|
+
if (bytes + size > 15e3) break;
|
|
156224
156884
|
result.push(entry);
|
|
156225
|
-
|
|
156885
|
+
bytes += size;
|
|
156226
156886
|
}
|
|
156227
156887
|
return result;
|
|
156228
156888
|
}
|
|
@@ -158425,23 +159085,23 @@ async function request(method, route, body, signedIn = true) {
|
|
|
158425
159085
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
158426
159086
|
}
|
|
158427
159087
|
var FILE_TIMEOUT_MS = 10 * 6e4;
|
|
158428
|
-
async function download(route) {
|
|
158429
|
-
const sent = await send("GET", route, void 0, true, FILE_TIMEOUT_MS);
|
|
159088
|
+
async function download(route, studioBytes) {
|
|
159089
|
+
const sent = await send("GET", route, void 0, true, studioBytes === void 0 ? FILE_TIMEOUT_MS : 45e3);
|
|
158430
159090
|
if (!sent.ok) return sent;
|
|
158431
159091
|
if (!sent.value.ok) return answerOf(sent.value);
|
|
158432
159092
|
try {
|
|
158433
|
-
return { ok: true, value: new Uint8Array(await sent.value.arrayBuffer()) };
|
|
159093
|
+
return { ok: true, value: studioBytes === void 0 ? new Uint8Array(await sent.value.arrayBuffer()) : await readStudioDownload(sent.value, studioBytes) };
|
|
158434
159094
|
} catch (e2) {
|
|
158435
159095
|
return { ok: false, error: e2 instanceof Error ? e2.message : String(e2) };
|
|
158436
159096
|
}
|
|
158437
159097
|
}
|
|
158438
|
-
async function upload(route,
|
|
158439
|
-
const sent = await send("PUT", route,
|
|
159098
|
+
async function upload(route, bytes, type) {
|
|
159099
|
+
const sent = await send("PUT", route, bytes, true, FILE_TIMEOUT_MS, type);
|
|
158440
159100
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
158441
159101
|
}
|
|
158442
|
-
async function uploadReplyImage(machine, job, key,
|
|
159102
|
+
async function uploadReplyImage(machine, job, key, bytes, mime) {
|
|
158443
159103
|
const route = `/v1/runner/jobs/${encodeURIComponent(job)}/images/${key}?machine=${encodeURIComponent(machine)}`;
|
|
158444
|
-
const sent = await send("PUT", route,
|
|
159104
|
+
const sent = await send("PUT", route, bytes, true, 9e4, mime);
|
|
158445
159105
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
158446
159106
|
}
|
|
158447
159107
|
var register = (r2) => request("POST", "/v1/runner", { ...r2, secrets: secretsSet(), protocol: PROTOCOL, akbContract: AKB_CONTRACT });
|
|
@@ -158455,6 +159115,7 @@ var claimJob = (machineId, job, reply = false) => move(
|
|
|
158455
159115
|
"claim",
|
|
158456
159116
|
{ machineId, ...reply ? { reply: true } : {} }
|
|
158457
159117
|
);
|
|
159118
|
+
var readReplyHistory = (machineId, job) => request("GET", `/v1/runner/jobs/${q(job)}/history?machine=${q(machineId)}`);
|
|
158458
159119
|
var renewJob = (machineId, job, progress) => move(job, "renew", { machineId, ...progress ? { progress } : {} });
|
|
158459
159120
|
async function openLog(machineId, job) {
|
|
158460
159121
|
const token = await accessToken();
|
|
@@ -158544,38 +159205,18 @@ var dropGoal = (id2, goal) => request("DELETE", goalRoute(id2, goal));
|
|
|
158544
159205
|
var startGoal = (id2, goal, expectedVersion, project) => request("POST", `${goalRoute(id2, goal)}/start`, { expectedVersion, ...project ? { project } : {} });
|
|
158545
159206
|
|
|
158546
159207
|
// ../cli/src/lib/shared/board-conflicts.ts
|
|
158547
|
-
var
|
|
159208
|
+
var import_yaml8 = __toESM(require_dist(), 1);
|
|
158548
159209
|
|
|
158549
159210
|
// ../cli/src/lib/agents/shared-memory.ts
|
|
158550
159211
|
import fs25 from "node:fs";
|
|
158551
159212
|
import path26 from "node:path";
|
|
158552
159213
|
|
|
158553
159214
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
159215
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
159216
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
158554
159217
|
import fs24 from "node:fs";
|
|
158555
159218
|
import path25 from "node:path";
|
|
158556
159219
|
|
|
158557
|
-
// ../cli/src/lib/yaml.ts
|
|
158558
|
-
function yamlScalar(s) {
|
|
158559
|
-
const text4 = String(s);
|
|
158560
|
-
if (text4 === "") return '""';
|
|
158561
|
-
if (/^[-?:,[\]{}#&*!|>'"%@`]/.test(text4) || /:\s/.test(text4) || /[\n"]/.test(text4) || /^\s|\s$/.test(text4)) {
|
|
158562
|
-
return JSON.stringify(text4);
|
|
158563
|
-
}
|
|
158564
|
-
return text4;
|
|
158565
|
-
}
|
|
158566
|
-
function unquote(v) {
|
|
158567
|
-
const text4 = String(v).trim();
|
|
158568
|
-
if (text4.startsWith('"') && text4.endsWith('"')) {
|
|
158569
|
-
try {
|
|
158570
|
-
return JSON.parse(text4);
|
|
158571
|
-
} catch {
|
|
158572
|
-
return text4.slice(1, -1);
|
|
158573
|
-
}
|
|
158574
|
-
}
|
|
158575
|
-
if (text4.startsWith("'") && text4.endsWith("'")) return text4.slice(1, -1);
|
|
158576
|
-
return text4;
|
|
158577
|
-
}
|
|
158578
|
-
|
|
158579
159220
|
// ../cli/src/lib/question-block.ts
|
|
158580
159221
|
var MODES = ["single", "multi"];
|
|
158581
159222
|
var withoutTag = (text4) => text4.replace(/^\[user\]\s+/, "");
|
|
@@ -158862,468 +159503,49 @@ function cardFront(body) {
|
|
|
158862
159503
|
}
|
|
158863
159504
|
|
|
158864
159505
|
// ../official/pack.ts
|
|
158865
|
-
import
|
|
159506
|
+
import crypto2 from "node:crypto";
|
|
158866
159507
|
import fs22 from "node:fs";
|
|
158867
159508
|
import path23 from "node:path";
|
|
158868
159509
|
import { fileURLToPath } from "node:url";
|
|
158869
159510
|
|
|
158870
|
-
// ../cli/src/lib/agent/studio-def.ts
|
|
158871
|
-
var import_ajv = __toESM(require_ajv(), 1);
|
|
158872
|
-
var import_yaml3 = __toESM(require_dist(), 1);
|
|
158873
|
-
|
|
158874
|
-
// ../cli/src/lib/agents/icon.ts
|
|
158875
|
-
var ICON_NAMES = [
|
|
158876
|
-
"file",
|
|
158877
|
-
"text",
|
|
158878
|
-
"article",
|
|
158879
|
-
"outline",
|
|
158880
|
-
"script",
|
|
158881
|
-
"prompt",
|
|
158882
|
-
"email",
|
|
158883
|
-
"image",
|
|
158884
|
-
"post-image",
|
|
158885
|
-
"social-image",
|
|
158886
|
-
"cover",
|
|
158887
|
-
"carousel",
|
|
158888
|
-
"carousel-outline",
|
|
158889
|
-
"slides",
|
|
158890
|
-
"wireframe",
|
|
158891
|
-
"screen",
|
|
158892
|
-
"video",
|
|
158893
|
-
"storyboard",
|
|
158894
|
-
"template",
|
|
158895
|
-
"shots",
|
|
158896
|
-
"api",
|
|
158897
|
-
"schema",
|
|
158898
|
-
"compare",
|
|
158899
|
-
"stack",
|
|
158900
|
-
"studio",
|
|
158901
|
-
"code",
|
|
158902
|
-
"checklist",
|
|
158903
|
-
"card",
|
|
158904
|
-
"plan",
|
|
158905
|
-
"proposal",
|
|
158906
|
-
"dismissed",
|
|
158907
|
-
"inbox",
|
|
158908
|
-
"notebook",
|
|
158909
|
-
"squeeze",
|
|
158910
|
-
"folder",
|
|
158911
|
-
"reply",
|
|
158912
|
-
"feedback",
|
|
158913
|
-
"software",
|
|
158914
|
-
"product-video",
|
|
158915
|
-
"social-post",
|
|
158916
|
-
"blog",
|
|
158917
|
-
"deck",
|
|
158918
|
-
"video-clone",
|
|
158919
|
-
"studio-kit"
|
|
158920
|
-
];
|
|
158921
|
-
var ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
|
|
158922
|
-
var PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
|
|
158923
|
-
var isColor = (v) => ICON_COLORS.includes(v);
|
|
158924
|
-
function readIcon(raw) {
|
|
158925
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
158926
|
-
if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
|
|
158927
|
-
if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
|
|
158928
|
-
const parts = [];
|
|
158929
|
-
for (const [i, item] of raw.entries()) {
|
|
158930
|
-
const at2 = `part ${i + 1}`;
|
|
158931
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at2} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
|
|
158932
|
-
const { d: d2, f: f2, o: o3, s, w: w2, ...extra } = item;
|
|
158933
|
-
if (Object.keys(extra).length) return { problem: `${at2} has \`${Object.keys(extra).join("`, `")}\`` };
|
|
158934
|
-
if (typeof d2 !== "string" || !PATH.test(d2)) return { problem: `${at2} has no \`d\` of SVG path commands and numbers` };
|
|
158935
|
-
const part = { d: d2.trim() };
|
|
158936
|
-
for (const [key, value] of [["f", f2], ["s", s]]) {
|
|
158937
|
-
if (value === void 0) continue;
|
|
158938
|
-
if (typeof value !== "string" || !isColor(value)) return { problem: `${at2} colours \`${key}\` with "${String(value)}"` };
|
|
158939
|
-
part[key] = value;
|
|
158940
|
-
}
|
|
158941
|
-
if (o3 !== void 0) {
|
|
158942
|
-
if (o3 !== "true") return { problem: `${at2} has \`o: ${String(o3)}\`, not \`true\`` };
|
|
158943
|
-
part.o = true;
|
|
158944
|
-
}
|
|
158945
|
-
if (w2 !== void 0) {
|
|
158946
|
-
const width = typeof w2 === "string" ? Number(w2) : NaN;
|
|
158947
|
-
if (!(width > 0 && width <= 3)) return { problem: `${at2} has \`w: ${String(w2)}\`, not above 0 and up to 3` };
|
|
158948
|
-
part.w = width;
|
|
158949
|
-
}
|
|
158950
|
-
parts.push(part);
|
|
158951
|
-
}
|
|
158952
|
-
return parts;
|
|
158953
|
-
}
|
|
158954
|
-
|
|
158955
|
-
// ../cli/src/lib/shared/preview-blocks.ts
|
|
158956
|
-
var PREVIEW_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
158957
|
-
function sourcePosition(source2, offset) {
|
|
158958
|
-
const before = source2.slice(0, offset);
|
|
158959
|
-
return { line: before.split("\n").length, column: offset - before.lastIndexOf("\n") };
|
|
158960
|
-
}
|
|
158961
|
-
function withoutCode(source2) {
|
|
158962
|
-
const blank2 = (s) => s.replace(/[^\n\r]/g, " ");
|
|
158963
|
-
let fence;
|
|
158964
|
-
let indented = false, afterBlank = true, inList = false;
|
|
158965
|
-
return source2.split(/(?<=\n)/).map((line) => {
|
|
158966
|
-
const marker = /^ {0,3}(`{3,}|~{3,})(.*)/.exec(line);
|
|
158967
|
-
if (fence) {
|
|
158968
|
-
if (marker && marker[1][0] === fence.char && marker[1].length >= fence.length && !marker[2].trim()) fence = void 0;
|
|
158969
|
-
return blank2(line);
|
|
158970
|
-
}
|
|
158971
|
-
if (marker) {
|
|
158972
|
-
fence = { char: marker[1][0], length: marker[1].length };
|
|
158973
|
-
return blank2(line);
|
|
158974
|
-
}
|
|
158975
|
-
if (!line.trim()) {
|
|
158976
|
-
afterBlank = true;
|
|
158977
|
-
return line;
|
|
158978
|
-
}
|
|
158979
|
-
const hasIndent = /^(?: {4}|\t)/.test(line);
|
|
158980
|
-
if (!hasIndent) indented = false;
|
|
158981
|
-
if (/^ {0,3}(?:[-+*]|\d+[.)])\s/.test(line)) inList = true;
|
|
158982
|
-
else if (/^\S/.test(line)) inList = false;
|
|
158983
|
-
if (hasIndent && (indented || afterBlank && !inList)) {
|
|
158984
|
-
indented = true;
|
|
158985
|
-
return blank2(line);
|
|
158986
|
-
}
|
|
158987
|
-
afterBlank = false;
|
|
158988
|
-
return line;
|
|
158989
|
-
}).join("").replace(/(`+)([^]*?)\1(?!`)/g, blank2);
|
|
158990
|
-
}
|
|
158991
|
-
function agentSectionOffset(source2) {
|
|
158992
|
-
return /^<!--[ \t]*agent[ \t]*-->/m.exec(withoutCode(source2))?.index ?? source2.length;
|
|
158993
|
-
}
|
|
158994
|
-
function parsePreviewBlocks(source2, file2 = "STUDIO.md") {
|
|
158995
|
-
const blocks = [], problems = [];
|
|
158996
|
-
const masked = withoutCode(source2);
|
|
158997
|
-
let open2;
|
|
158998
|
-
const seen = /* @__PURE__ */ new Set();
|
|
158999
|
-
const fail = (offset, id2, code, message, hint2) => problems.push({ file: file2, ...sourcePosition(source2, offset), path: id2 ? `previews.${id2}` : "previews", code, message, hint: hint2 });
|
|
159000
|
-
for (const tag of masked.matchAll(/<\/?Preview\b[^>]*(?:>|$)/g)) {
|
|
159001
|
-
const offset = tag.index, text4 = tag[0];
|
|
159002
|
-
const closing = /^<\/Preview\s*>$/.test(text4);
|
|
159003
|
-
if (closing) {
|
|
159004
|
-
if (!open2) fail(offset, "", "preview-unexpected-close", "Preview has no opening tag", "Remove it or restore its opening tag.");
|
|
159005
|
-
else {
|
|
159006
|
-
const instructions = source2.slice(open2.content, offset).trim();
|
|
159007
|
-
if (!instructions) fail(open2.start, open2.id, "preview-empty", `Preview ${open2.id} is empty`, "Describe the requested output inside the block.");
|
|
159008
|
-
blocks.push({ id: open2.id, instructions, start: open2.start, end: offset + text4.length });
|
|
159009
|
-
open2 = void 0;
|
|
159010
|
-
}
|
|
159011
|
-
continue;
|
|
159012
|
-
}
|
|
159013
|
-
const opening = /^<Preview\s+id=(?:"([^"]*)"|'([^']*)')\s*>$/.exec(text4);
|
|
159014
|
-
if (!opening || open2) {
|
|
159015
|
-
fail(offset, open2?.id ?? "", "preview-tag", "Malformed or nested Preview tag", 'Use one non-nested <Preview id="stable-id"> block with only id.');
|
|
159016
|
-
continue;
|
|
159017
|
-
}
|
|
159018
|
-
const id2 = opening[1] ?? opening[2];
|
|
159019
|
-
if (!PREVIEW_ID.test(id2) || seen.has(id2)) fail(offset, id2, "preview-id", `Invalid or repeated Preview ID ${id2}`, "Use a unique lowercase ID with digits and dashes.");
|
|
159020
|
-
seen.add(id2);
|
|
159021
|
-
open2 = { id: id2, start: offset, content: offset + text4.length };
|
|
159022
|
-
}
|
|
159023
|
-
if (open2) fail(open2.start, open2.id, "preview-unclosed", `Preview ${open2.id} is not closed`, "Add </Preview> after this block.");
|
|
159024
|
-
return { blocks, problems };
|
|
159025
|
-
}
|
|
159026
|
-
|
|
159027
|
-
// ../cli/src/lib/agent/studio-def.ts
|
|
159028
|
-
var STUDIO_ID = PREVIEW_ID;
|
|
159029
|
-
var titles = { type: "object", minProperties: 1, propertyNames: { pattern: "^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$" }, additionalProperties: { type: "string", minLength: 1, pattern: "\\S" } };
|
|
159030
|
-
var icon = { anyOf: [
|
|
159031
|
-
{ type: "string", enum: ICON_NAMES },
|
|
159032
|
-
{ type: "array", minItems: 1, maxItems: 12, items: { type: "object", required: ["d"], additionalProperties: false, properties: {
|
|
159033
|
-
d: { type: "string", minLength: 1, pattern: "^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$" },
|
|
159034
|
-
f: { enum: ICON_COLORS },
|
|
159035
|
-
o: { const: true },
|
|
159036
|
-
s: { enum: ICON_COLORS },
|
|
159037
|
-
w: { type: "number", exclusiveMinimum: 0, maximum: 3 }
|
|
159038
|
-
} } }
|
|
159039
|
-
] };
|
|
159040
|
-
var STUDIO_SCHEMA = {
|
|
159041
|
-
type: "object",
|
|
159042
|
-
required: ["name"],
|
|
159043
|
-
additionalProperties: false,
|
|
159044
|
-
properties: {
|
|
159045
|
-
name: { type: "string", minLength: 1, pattern: "\\S" },
|
|
159046
|
-
names: titles,
|
|
159047
|
-
description: { type: "string" },
|
|
159048
|
-
summaries: titles,
|
|
159049
|
-
entrypoints: { type: "array", minItems: 1, maxItems: 10, uniqueItems: true, items: { type: "string", pattern: PREVIEW_ID.source } },
|
|
159050
|
-
needsArtifact: { type: "boolean" },
|
|
159051
|
-
icon,
|
|
159052
|
-
previews: { type: "object", propertyNames: { pattern: PREVIEW_ID.source }, additionalProperties: {
|
|
159053
|
-
type: "object",
|
|
159054
|
-
additionalProperties: false,
|
|
159055
|
-
properties: { title: titles, description: titles, icon }
|
|
159056
|
-
} }
|
|
159057
|
-
}
|
|
159058
|
-
};
|
|
159059
|
-
var validate = new import_ajv.Ajv({ allErrors: true, meta: false, validateSchema: false }).compile(STUDIO_SCHEMA);
|
|
159060
|
-
var comments = /<!--[^]*?(?:-->|$)/g;
|
|
159061
|
-
var blank = (text4) => text4.replace(/[^\r\n]/g, " ");
|
|
159062
|
-
var headingsOf = (body) => [...withoutCode(body).replace(comments, blank).matchAll(/^ {0,3}#{1,2}(?=[ \t\r\n]|$)[^\r\n]*/gm)];
|
|
159063
|
-
function studioSetup(body) {
|
|
159064
|
-
const headings = headingsOf(body);
|
|
159065
|
-
const index = headings.findIndex((h3) => /^ {0,3}##[ \t]+Setup(?:[ \t]+#+)?[ \t]*$/.test(body.slice(h3.index, h3.index + h3[0].length)));
|
|
159066
|
-
if (index === -1) return "";
|
|
159067
|
-
const heading = headings[index];
|
|
159068
|
-
const section = body.slice(heading.index + heading[0].length, headings[index + 1]?.index).trim();
|
|
159069
|
-
return section.replace(comments, "").trim() ? section : "";
|
|
159070
|
-
}
|
|
159071
|
-
function landSections(body, previews) {
|
|
159072
|
-
let visible = "", at2 = 0;
|
|
159073
|
-
for (const { start, end: end2 } of previews) {
|
|
159074
|
-
visible += body.slice(at2, start) + blank(body.slice(start, end2));
|
|
159075
|
-
at2 = end2;
|
|
159076
|
-
}
|
|
159077
|
-
visible += body.slice(at2);
|
|
159078
|
-
const headings = headingsOf(visible);
|
|
159079
|
-
return headings.flatMap((heading, index) => {
|
|
159080
|
-
const start = heading.index;
|
|
159081
|
-
const end2 = start + heading[0].length;
|
|
159082
|
-
if (!/^ {0,3}##[ \t]+Land(?:[ \t]+#+)?[ \t]*$/.test(visible.slice(start, end2))) return [];
|
|
159083
|
-
return [{
|
|
159084
|
-
offset: start + heading[0].indexOf("#"),
|
|
159085
|
-
empty: !visible.slice(end2, headings[index + 1]?.index).replace(comments, "").trim()
|
|
159086
|
-
}];
|
|
159087
|
-
});
|
|
159088
|
-
}
|
|
159089
|
-
function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
|
|
159090
|
-
const problems = [];
|
|
159091
|
-
const fail = (offset, path76, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path76, code, message, hint: hint2 });
|
|
159092
|
-
const result = () => ({ problem: problems.map((p2) => `${p2.file}:${p2.line}:${p2.column} ${p2.path}: ${p2.code} \u2014 ${p2.message}. ${p2.hint}`).join("\n"), problems });
|
|
159093
|
-
if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
|
|
159094
|
-
const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
|
|
159095
|
-
if (!front) {
|
|
159096
|
-
fail(0, "", "yaml-syntax", "Missing YAML frontmatter", "Enclose metadata between --- lines.");
|
|
159097
|
-
return result();
|
|
159098
|
-
}
|
|
159099
|
-
const metaOffset = source2.indexOf("\n") + 1, bodyOffset = front[0].length;
|
|
159100
|
-
const counter = new import_yaml3.LineCounter();
|
|
159101
|
-
const document = (0, import_yaml3.parseDocument)(front[1], { lineCounter: counter, uniqueKeys: true, strict: true });
|
|
159102
|
-
for (const error62 of document.errors) fail(metaOffset + (error62.pos[0] ?? 0), "", error62.code === "DUPLICATE_KEY" ? "yaml-duplicate-key" : "yaml-syntax", error62.message.split("\n")[0], "Correct the indicated YAML location.");
|
|
159103
|
-
if (problems.length) return result();
|
|
159104
|
-
let raw;
|
|
159105
|
-
try {
|
|
159106
|
-
raw = document.toJS({ maxAliasCount: 0 });
|
|
159107
|
-
} catch {
|
|
159108
|
-
fail(metaOffset, "", "yaml-syntax", "YAML aliases are not supported", "Write metadata explicitly.");
|
|
159109
|
-
return result();
|
|
159110
|
-
}
|
|
159111
|
-
if (!validate(raw)) {
|
|
159112
|
-
for (const error62 of validate.errors ?? []) {
|
|
159113
|
-
const parts = error62.instancePath.split("/").slice(1);
|
|
159114
|
-
const key = error62.params.additionalProperty ?? error62.params.missingProperty;
|
|
159115
|
-
if (key) parts.push(String(key));
|
|
159116
|
-
const node2 = parts.length ? document.getIn(parts, true) : document.contents;
|
|
159117
|
-
fail(metaOffset + (node2?.range?.[0] ?? 0), parts.join("."), "studio-schema", `${parts.join(".") || "metadata"} ${error62.message}`, "Use only Studio metadata and previews: {id: {title?, description?, icon?}} with the declared field types.");
|
|
159118
|
-
}
|
|
159119
|
-
}
|
|
159120
|
-
const body = source2.slice(bodyOffset);
|
|
159121
|
-
const parsed = parsePreviewBlocks(body, from);
|
|
159122
|
-
problems.push(...parsed.problems.map((p2) => ({ ...p2, line: p2.line + source2.slice(0, bodyOffset).split("\n").length - 1 })));
|
|
159123
|
-
if (problems.length) return result();
|
|
159124
|
-
const map3 = raw.previews ?? {};
|
|
159125
|
-
for (const block of parsed.blocks) if (!Object.hasOwn(map3, block.id)) fail(bodyOffset + block.start, `previews.${block.id}`, "preview-metadata-missing", `Preview ${block.id} has no metadata entry`, "Add the ID under previews, using {} if needed.");
|
|
159126
|
-
for (const key of Object.keys(map3)) if (!parsed.blocks.some((b2) => b2.id === key)) fail(metaOffset + (document.getIn(["previews", key], true)?.range?.[0] ?? 0), `previews.${key}`, "preview-body-missing", `Preview ${key} has no body`, "Add its block or remove unused metadata.");
|
|
159127
|
-
if (requirePreviewCopy) for (const block of parsed.blocks) {
|
|
159128
|
-
const metadata = Object.hasOwn(map3, block.id) ? map3[block.id] : void 0;
|
|
159129
|
-
if (!metadata) continue;
|
|
159130
|
-
for (const field2 of ["title", "description"]) for (const lang of ["en", "zh"]) {
|
|
159131
|
-
if (metadata[field2]?.[lang]) continue;
|
|
159132
|
-
fail(
|
|
159133
|
-
bodyOffset + block.start,
|
|
159134
|
-
`previews.${block.id}.${field2}.${lang}`,
|
|
159135
|
-
"preview-display-missing",
|
|
159136
|
-
`Preview ${block.id} needs a ${lang} ${field2}`,
|
|
159137
|
-
"Add non-blank en and zh display text in the Preview metadata."
|
|
159138
|
-
);
|
|
159139
|
-
}
|
|
159140
|
-
}
|
|
159141
|
-
if (requireLand) {
|
|
159142
|
-
const sections = landSections(body, parsed.blocks);
|
|
159143
|
-
if (!sections.length) fail(bodyOffset, "Land", "studio-land-missing", "Missing ## Land section", "Add ## Land to the Studio body and describe delivery, checks and what to record.");
|
|
159144
|
-
for (const [index, { offset, empty }] of sections.entries()) {
|
|
159145
|
-
if (index) fail(bodyOffset + offset, "Land", "studio-land-duplicate", "Repeated ## Land section", "Combine delivery instructions under one ## Land heading.");
|
|
159146
|
-
if (empty) fail(bodyOffset + offset, "Land", "studio-land-empty", "The ## Land section is empty", "Describe delivery, checks and what to record under ## Land.");
|
|
159147
|
-
}
|
|
159148
|
-
}
|
|
159149
|
-
if (problems.length) return result();
|
|
159150
|
-
let rules = "", at2 = 0;
|
|
159151
|
-
for (const block of parsed.blocks) {
|
|
159152
|
-
rules += body.slice(at2, block.start);
|
|
159153
|
-
at2 = block.end;
|
|
159154
|
-
}
|
|
159155
|
-
rules += body.slice(at2);
|
|
159156
|
-
return { def: {
|
|
159157
|
-
id: id2,
|
|
159158
|
-
name: raw.name.trim(),
|
|
159159
|
-
...raw.names ? { names: raw.names } : {},
|
|
159160
|
-
description: raw.description ?? "",
|
|
159161
|
-
needsArtifact: raw.needsArtifact ?? false,
|
|
159162
|
-
...raw.summaries ? { summaries: raw.summaries } : {},
|
|
159163
|
-
...raw.entrypoints ? { entrypoints: raw.entrypoints } : {},
|
|
159164
|
-
...raw.icon ? { icon: raw.icon } : {},
|
|
159165
|
-
previews: parsed.blocks.map((b2) => ({ id: b2.id, instructions: b2.instructions, ...map3[b2.id] })),
|
|
159166
|
-
rules: rules.trim()
|
|
159167
|
-
} };
|
|
159168
|
-
}
|
|
159169
|
-
|
|
159170
159511
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
159171
159512
|
import fs21 from "node:fs";
|
|
159172
159513
|
import path22 from "node:path";
|
|
159173
|
-
|
|
159174
|
-
// ../cli/src/lib/shared/guide-topics.ts
|
|
159175
|
-
var GUIDE_TOPICS = ["board", "writing", "add-task", "follow-up", "discuss-goal", "troubleshoot", "card-chat", "task-ui-en", "task-ui-zh", "update-studio", "implement", "settle-background", "archive", "update-questions", "refine", "revise", "resolve", "prune-memory", "review-memory", "describe-project", "review-rejections", "reflect", "write-agent", "write-prompt", "module-map"];
|
|
159176
|
-
|
|
159177
|
-
// ../cli/src/lib/shared/studio-files.ts
|
|
159178
|
-
var STUDIO_FILE = "STUDIO.md";
|
|
159179
|
-
var MCP_FILE = "mcp.json";
|
|
159180
|
-
var CARD_TEMPLATE_FILE = "CARD.md";
|
|
159181
|
-
var VERSION_FILE = "version.json";
|
|
159182
|
-
var KB = 1024;
|
|
159183
|
-
var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
|
|
159184
|
-
var officialId = (folder2) => `wf_builtin_${folder2.replace(/-/g, "_")}`;
|
|
159185
|
-
var hashInput = (files) => JSON.stringify(Object.entries(files).sort(([a2], [b2]) => a2 < b2 ? -1 : 1));
|
|
159186
|
-
var landsOf = (_def) => ({ lands: true });
|
|
159187
|
-
var SEGMENT = /^[\w.-]+$/;
|
|
159188
|
-
var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
|
|
159189
|
-
var bytes = (text4) => new TextEncoder().encode(text4).length;
|
|
159190
|
-
var isSharedFile = (file2) => {
|
|
159191
|
-
const parts = file2.split("/");
|
|
159192
|
-
return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p2) => SEGMENT.test(p2) && p2 !== "." && p2 !== "..");
|
|
159193
|
-
};
|
|
159194
|
-
function folderPath(file2, top) {
|
|
159195
|
-
const parts = file2.split("/");
|
|
159196
|
-
if (parts.length < 3 || parts[0] !== top || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(parts[1])) return null;
|
|
159197
|
-
if (parts.slice(2).some((p2) => !SEGMENT.test(p2) || p2 === "." || p2 === "..")) return null;
|
|
159198
|
-
return [parts[1], parts.slice(2).join("/")];
|
|
159199
|
-
}
|
|
159200
|
-
function mcpProblem(text4) {
|
|
159201
|
-
let read5;
|
|
159202
|
-
try {
|
|
159203
|
-
read5 = JSON.parse(text4);
|
|
159204
|
-
} catch {
|
|
159205
|
-
return "is not JSON";
|
|
159206
|
-
}
|
|
159207
|
-
const servers = read5?.mcpServers;
|
|
159208
|
-
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
|
|
159209
|
-
for (const [name, server] of Object.entries(servers)) {
|
|
159210
|
-
const { command, args: args2, ...rest } = server ?? {};
|
|
159211
|
-
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return `names a server \`${name}\`; use lowercase letters, digits and dashes`;
|
|
159212
|
-
if (typeof command !== "string" || !command) return `server \`${name}\` needs a \`command\``;
|
|
159213
|
-
if (args2 !== void 0 && !(Array.isArray(args2) && args2.every((a2) => typeof a2 === "string"))) return `server \`${name}\`: \`args\` must be a list of strings`;
|
|
159214
|
-
if (Object.keys(rest).length) return `server \`${name}\` takes only \`command\` and \`args\``;
|
|
159215
|
-
}
|
|
159216
|
-
return null;
|
|
159217
|
-
}
|
|
159218
|
-
function formatStudioProblem({ file: file2, line, column, reason, hint: hint2 }) {
|
|
159219
|
-
const location = line === void 0 ? file2 : `${file2}:${line}:${column ?? 1}`;
|
|
159220
|
-
return `${location}: ${reason}${hint2 ? `. ${hint2}` : ""}`;
|
|
159221
|
-
}
|
|
159222
|
-
function checkStudioFiles(value, official = false, checks = {}) {
|
|
159223
|
-
const read5 = inspect(value, official, checks);
|
|
159224
|
-
const first = read5.problems[0];
|
|
159225
|
-
return first ? { ok: false, ...first, problems: read5.problems } : { ok: true, def: read5.def, files: read5.files };
|
|
159226
|
-
}
|
|
159227
|
-
function inspect(value, official, { allowLegacyPreviewCopy, allowLegacyLand } = {}) {
|
|
159228
|
-
const problems = [];
|
|
159229
|
-
const fail = (file2, reason, tooLarge = false) => {
|
|
159230
|
-
problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
|
|
159231
|
-
return { problems };
|
|
159232
|
-
};
|
|
159233
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
|
|
159234
|
-
const files = Object.fromEntries(Object.entries(value).filter(([file2]) => file2 !== VERSION_FILE));
|
|
159235
|
-
const entries = Object.entries(files);
|
|
159236
|
-
if (entries.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
|
|
159237
|
-
let total = 0;
|
|
159238
|
-
const skills = /* @__PURE__ */ new Set();
|
|
159239
|
-
for (const [file2, text4] of entries) {
|
|
159240
|
-
if (typeof text4 !== "string" || text4.includes("\0")) {
|
|
159241
|
-
fail(file2, "is not a text file");
|
|
159242
|
-
continue;
|
|
159243
|
-
}
|
|
159244
|
-
if (file2.length > FILE_LIMITS.path) {
|
|
159245
|
-
fail(file2, `the path is longer than ${FILE_LIMITS.path} characters`);
|
|
159246
|
-
continue;
|
|
159247
|
-
}
|
|
159248
|
-
const size = bytes(text4);
|
|
159249
|
-
if (size > FILE_LIMITS.file) return fail(file2, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
|
|
159250
|
-
total += size;
|
|
159251
|
-
if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
|
|
159252
|
-
if (file2 === STUDIO_FILE || file2 === CARD_TEMPLATE_FILE) continue;
|
|
159253
|
-
if (official && file2 === MCP_FILE) {
|
|
159254
|
-
const problem2 = mcpProblem(text4);
|
|
159255
|
-
if (problem2) fail(file2, problem2);
|
|
159256
|
-
continue;
|
|
159257
|
-
}
|
|
159258
|
-
if (official && isAboutFile(file2)) continue;
|
|
159259
|
-
if (official && file2.startsWith("skills/")) {
|
|
159260
|
-
if (!folderPath(file2, "skills")) fail(file2, "is not inside skills/<name>/");
|
|
159261
|
-
else skills.add(file2.split("/")[1]);
|
|
159262
|
-
continue;
|
|
159263
|
-
}
|
|
159264
|
-
if (isSharedFile(file2)) continue;
|
|
159265
|
-
if (/^(?:references|scripts)\//.test(file2) && file2.split("/").every((p2) => SEGMENT.test(p2) && p2 !== "." && p2 !== "..")) continue;
|
|
159266
|
-
fail(file2, `use ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, references/, scripts/ or shared/`);
|
|
159267
|
-
}
|
|
159268
|
-
for (const name of skills) {
|
|
159269
|
-
if (files[`skills/${name}/SKILL.md`] === void 0) fail(`skills/${name}/SKILL.md`, "is missing");
|
|
159270
|
-
}
|
|
159271
|
-
const source2 = files[STUDIO_FILE];
|
|
159272
|
-
const read5 = typeof source2 === "string" ? parseStudioFile("studio", source2, STUDIO_FILE, { requirePreviewCopy: !official && !allowLegacyPreviewCopy, requireLand: !allowLegacyLand }) : null;
|
|
159273
|
-
if (!read5) fail(STUDIO_FILE, "is missing");
|
|
159274
|
-
else if ("problem" in read5) for (const problem2 of read5.problems) problems.push({ ...problem2, reason: problem2.message });
|
|
159275
|
-
if (!read5 || "problem" in read5) return { problems };
|
|
159276
|
-
const def = read5.def;
|
|
159277
|
-
for (const [file2, text4] of Object.entries(files)) {
|
|
159278
|
-
if (typeof text4 !== "string" || !file2.endsWith(".md")) continue;
|
|
159279
|
-
const masked = withoutCode(text4);
|
|
159280
|
-
const reference = (offset, link, message) => problems.push({ file: file2, ...sourcePosition(text4, offset), path: link, code: "studio-reference", message, reason: message, hint: "Use an existing safe relative resource or a shipped AKB Guide." });
|
|
159281
|
-
for (const match of masked.matchAll(/!?\[[^\]]*\]\(([^\s)]+)(?:\s+[^)]*)?\)/g)) {
|
|
159282
|
-
const link = match[1].replace(/^<|>$/g, "");
|
|
159283
|
-
if (/^(?:https?:|mailto:|#)/i.test(link)) continue;
|
|
159284
|
-
let decoded;
|
|
159285
|
-
try {
|
|
159286
|
-
decoded = decodeURIComponent(link.split(/[?#]/)[0]);
|
|
159287
|
-
} catch {
|
|
159288
|
-
reference(match.index, link, "Invalid resource URL");
|
|
159289
|
-
continue;
|
|
159290
|
-
}
|
|
159291
|
-
if (/^(?:[a-z][\w+.-]*:|[/\\])|\\/i.test(decoded) || decoded.split("/").includes("..")) {
|
|
159292
|
-
reference(match.index, link, "Unsafe resource path");
|
|
159293
|
-
continue;
|
|
159294
|
-
}
|
|
159295
|
-
const target = [...file2.split("/").slice(0, -1), ...decoded.split("/").filter((p2) => p2 !== ".")].join("/");
|
|
159296
|
-
if (!Object.hasOwn(files, target)) reference(match.index, link, `Missing resource ${target}`);
|
|
159297
|
-
}
|
|
159298
|
-
for (const match of text4.matchAll(/akb guide ([a-z][a-z-]*)/g)) if (!GUIDE_TOPICS.includes(match[1])) reference(match.index, match[1], `Unknown AKB Guide ${match[1]}`);
|
|
159299
|
-
}
|
|
159300
|
-
return { problems, def, files };
|
|
159301
|
-
}
|
|
159302
|
-
function previewCatalog(files) {
|
|
159303
|
-
const read5 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
159304
|
-
if ("problem" in read5) throw new Error(read5.problem);
|
|
159305
|
-
return read5.def.previews;
|
|
159306
|
-
}
|
|
159307
|
-
|
|
159308
|
-
// ../cli/src/lib/agent/studio-folder.ts
|
|
159309
159514
|
var MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
159310
159515
|
function filesOf(dir, base = dir) {
|
|
159311
|
-
return fs21.readdirSync(dir, { withFileTypes: true }).filter((e2) =>
|
|
159516
|
+
return fs21.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.name.toLowerCase() !== ".git" && (dir !== base || e2.name !== PUBLICATION_FILE)).flatMap((e2) => {
|
|
159312
159517
|
const full = path22.join(dir, e2.name);
|
|
159313
|
-
if (e2.
|
|
159518
|
+
if (!e2.isFile() && !e2.isDirectory()) throw new Error(full + ": only regular files and directories are allowed");
|
|
159314
159519
|
return e2.isDirectory() ? filesOf(full, base) : [path22.relative(base, full).split(path22.sep).join("/")];
|
|
159315
159520
|
});
|
|
159316
159521
|
}
|
|
159317
159522
|
function readStudioFile(dir, file2) {
|
|
159318
159523
|
const full = path22.join(dir, file2);
|
|
159319
|
-
|
|
159524
|
+
const bytes = fs21.readFileSync(full);
|
|
159525
|
+
if (isAboutFile(file2) && !file2.endsWith(".md")) return "data:" + MIME[path22.extname(file2)] + ";base64," + bytes.toString("base64");
|
|
159526
|
+
try {
|
|
159527
|
+
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
159528
|
+
} catch {
|
|
159529
|
+
throw new Error(file2 + ": expected a UTF-8 text file");
|
|
159530
|
+
}
|
|
159531
|
+
}
|
|
159532
|
+
function readStudioFolder(dir) {
|
|
159533
|
+
const files = filesOf(dir).sort();
|
|
159534
|
+
if (files.filter((file2) => file2 !== VERSION_FILE).length > FILE_LIMITS.count) throw new Error("Studio file count limit exceeded");
|
|
159535
|
+
let total = 0;
|
|
159536
|
+
return Object.fromEntries(files.map((file2) => {
|
|
159537
|
+
const size = fs21.statSync(path22.join(dir, file2)).size;
|
|
159538
|
+
if (file2 !== VERSION_FILE) total += size;
|
|
159539
|
+
const problem2 = studioSizeProblem(file2, size, total);
|
|
159540
|
+
if (problem2) throw new Error(problem2.file + ": " + problem2.reason);
|
|
159541
|
+
return [file2, readStudioFile(dir, file2)];
|
|
159542
|
+
}));
|
|
159320
159543
|
}
|
|
159321
|
-
var readStudioFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readStudioFile(dir, f2)]));
|
|
159322
159544
|
|
|
159323
159545
|
// ../official/pack.ts
|
|
159324
159546
|
var OFFICIAL = path23.dirname(fileURLToPath(import.meta.url));
|
|
159325
159547
|
var dirs = (dir) => fs22.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
159326
|
-
var hashOf = (files) =>
|
|
159548
|
+
var hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
159327
159549
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
159328
159550
|
const studiosDir = path23.join(root2, "studios");
|
|
159329
159551
|
return dirs(studiosDir).map((folder2) => {
|
|
@@ -159355,7 +159577,7 @@ function workspaceTask() {
|
|
|
159355
159577
|
const id2 = process.env[TASK_ENV];
|
|
159356
159578
|
return id2 && id2.trim() ? id2.trim() : null;
|
|
159357
159579
|
}
|
|
159358
|
-
async function call(method, route, body, key, { allowResultError = false } = {}) {
|
|
159580
|
+
async function call(method, route, body, key, { allowResultError = false, downloadBytes } = {}) {
|
|
159359
159581
|
if (!cloudConfigured()) return { ok: false, error: NOT_CONFIGURED, code: "bad_request" };
|
|
159360
159582
|
const token = await accessToken();
|
|
159361
159583
|
if (!token.ok) {
|
|
@@ -159376,6 +159598,13 @@ async function call(method, route, body, key, { allowResultError = false } = {})
|
|
|
159376
159598
|
} catch (e2) {
|
|
159377
159599
|
return { ok: false, error: `Cloud could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}`, code: "unreachable", retryable: true };
|
|
159378
159600
|
}
|
|
159601
|
+
if (response.ok && downloadBytes !== void 0) {
|
|
159602
|
+
try {
|
|
159603
|
+
return { ok: true, value: await readStudioDownload(response, downloadBytes) };
|
|
159604
|
+
} catch (error62) {
|
|
159605
|
+
return { ok: false, error: error62.message, code: "invalid_response" };
|
|
159606
|
+
}
|
|
159607
|
+
}
|
|
159379
159608
|
const parsed = await readCloudJson(response);
|
|
159380
159609
|
const problem2 = (response.ok && allowResultError ? null : cloudProblem(response, parsed)) ?? (isRecord(parsed) ? null : invalidResponse("a valid JSON response"));
|
|
159381
159610
|
if (problem2) return { ok: false, ...problem2, error: problem2.message };
|
|
@@ -159402,12 +159631,16 @@ function linkedProject(board, root2) {
|
|
|
159402
159631
|
}
|
|
159403
159632
|
|
|
159404
159633
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
159634
|
+
var STUDIO_SNAPSHOT_ENV = "AI4KANBAN_STUDIO_SNAPSHOT";
|
|
159405
159635
|
var DEV = "AI4KANBAN_STUDIOS";
|
|
159406
159636
|
var root = () => path25.join(machineHome(), "studios");
|
|
159407
159637
|
var safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
159408
159638
|
var versionFile = (id2, version2) => path25.join(root(), "versions", `${safe(id2)}@${version2}.json`);
|
|
159409
159639
|
var listFile = (project) => path25.join(root(), "lists", `${safe(project)}.json`);
|
|
159410
159640
|
var pinFile = (task) => path25.join(root(), "tasks", `${safe(task)}.json`);
|
|
159641
|
+
var sessionDir = (task) => path25.join(root(), "sessions", safe(task));
|
|
159642
|
+
var sessionFileOf = (task, session) => path25.join(sessionDir(task), createHash5("sha256").update(session).digest("hex") + ".json");
|
|
159643
|
+
var skillDir = (id2, version2) => path25.join(root(), "bundles", safe(id2) + "@" + version2);
|
|
159411
159644
|
function readJson(file2) {
|
|
159412
159645
|
try {
|
|
159413
159646
|
return JSON.parse(fs24.readFileSync(file2, "utf8"));
|
|
@@ -159417,12 +159650,19 @@ function readJson(file2) {
|
|
|
159417
159650
|
}
|
|
159418
159651
|
function writeJson(file2, value) {
|
|
159419
159652
|
fs24.mkdirSync(path25.dirname(file2), { recursive: true });
|
|
159420
|
-
const tmp = `${file2}.${
|
|
159421
|
-
|
|
159422
|
-
|
|
159423
|
-
|
|
159653
|
+
const tmp = `${file2}.${randomUUID4()}.tmp`;
|
|
159654
|
+
try {
|
|
159655
|
+
fs24.writeFileSync(tmp, JSON.stringify(value) + "\n", { mode: 384 });
|
|
159656
|
+
fs24.renameSync(tmp, file2);
|
|
159657
|
+
} finally {
|
|
159658
|
+
fs24.rmSync(tmp, { force: true });
|
|
159659
|
+
}
|
|
159424
159660
|
}
|
|
159425
|
-
var
|
|
159661
|
+
var filesHash = (files) => createHash5("sha256").update(hashInput(files)).digest("hex");
|
|
159662
|
+
var readVersion2 = (id2, version2) => {
|
|
159663
|
+
const held5 = readJson(versionFile(id2, version2));
|
|
159664
|
+
return held5?.id === id2 && held5.version === version2 && isStudioFiles(held5.files) && (!held5.filesSha256 || filesHash(held5.files) === held5.filesSha256) ? held5 : null;
|
|
159665
|
+
};
|
|
159426
159666
|
function heldStudioName(name) {
|
|
159427
159667
|
let files;
|
|
159428
159668
|
try {
|
|
@@ -159437,15 +159677,149 @@ function heldStudioName(name) {
|
|
|
159437
159677
|
}
|
|
159438
159678
|
function saveVersion(held5) {
|
|
159439
159679
|
const file2 = versionFile(held5.id, held5.version);
|
|
159440
|
-
writeJson(file2, { id: held5.id, version: held5.version, name: held5.name, names: held5.names, files: held5.files });
|
|
159680
|
+
writeJson(file2, { id: held5.id, version: held5.version, name: held5.name, names: held5.names, files: held5.files, filesSha256: held5.filesSha256 });
|
|
159441
159681
|
}
|
|
159442
|
-
function savePin(task, held5) {
|
|
159443
|
-
saveVersion(held5);
|
|
159682
|
+
function savePin(task, held5, saved = false) {
|
|
159683
|
+
if (!saved) saveVersion(held5);
|
|
159444
159684
|
writeJson(pinFile(task), { studio: held5.id, version: held5.version, historicalPreviews: held5.historicalPreviews });
|
|
159445
159685
|
}
|
|
159446
159686
|
var readPin = (task) => readJson(pinFile(task));
|
|
159687
|
+
var readStudioSession = (task, session) => readJson(sessionFileOf(task, session));
|
|
159688
|
+
function saveStudioSession(task, session, pin) {
|
|
159689
|
+
const file2 = sessionFileOf(task, session);
|
|
159690
|
+
if (!fs24.existsSync(file2)) writeJson(file2, pin);
|
|
159691
|
+
}
|
|
159692
|
+
function studioSkillBlock(skills, folder2) {
|
|
159693
|
+
if (!skills.length) return "";
|
|
159694
|
+
return [
|
|
159695
|
+
"When a skill applies, read its listed SKILL.md and resolve its relative references from the skill directory.",
|
|
159696
|
+
"",
|
|
159697
|
+
"## Skills",
|
|
159698
|
+
"",
|
|
159699
|
+
"### Available skills",
|
|
159700
|
+
...skills.map(({ name, description }) => "- " + name + ": " + description + " (file: " + path25.join(folder2, skillFile(name)) + ")")
|
|
159701
|
+
].join("\n");
|
|
159702
|
+
}
|
|
159703
|
+
function cachedStudioSkillBlock(held5) {
|
|
159704
|
+
const skills = studioSkills(held5.files);
|
|
159705
|
+
if (!skills.length) return "";
|
|
159706
|
+
const folder2 = path25.resolve(skillDir(held5.id, held5.version));
|
|
159707
|
+
if (!fs24.existsSync(folder2)) {
|
|
159708
|
+
const parent = path25.dirname(folder2);
|
|
159709
|
+
fs24.mkdirSync(parent, { recursive: true, mode: 448 });
|
|
159710
|
+
const temp = fs24.mkdtempSync(path25.join(parent, ".studio-"));
|
|
159711
|
+
try {
|
|
159712
|
+
const prefixes = new Set(skills.map(({ name }) => "skills/" + name + "/"));
|
|
159713
|
+
for (const [file2, text4] of Object.entries(held5.files)) {
|
|
159714
|
+
if (!safeStudioPath(file2) || !prefixes.has(file2.split("/").slice(0, 2).join("/") + "/")) continue;
|
|
159715
|
+
const target = path25.join(temp, file2);
|
|
159716
|
+
fs24.mkdirSync(path25.dirname(target), { recursive: true });
|
|
159717
|
+
fs24.writeFileSync(target, text4, { flag: "wx", mode: 292 });
|
|
159718
|
+
}
|
|
159719
|
+
try {
|
|
159720
|
+
fs24.renameSync(temp, folder2);
|
|
159721
|
+
} catch (error62) {
|
|
159722
|
+
if (!fs24.existsSync(folder2)) throw error62;
|
|
159723
|
+
}
|
|
159724
|
+
} finally {
|
|
159725
|
+
fs24.rmSync(temp, { recursive: true, force: true });
|
|
159726
|
+
}
|
|
159727
|
+
}
|
|
159728
|
+
return studioSkillBlock(skills, folder2);
|
|
159729
|
+
}
|
|
159447
159730
|
var boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
159448
159731
|
var devFolder = () => process.env[DEV]?.trim() || "";
|
|
159732
|
+
function invalid(expected) {
|
|
159733
|
+
const problem2 = invalidResponse(expected);
|
|
159734
|
+
return { ...problem2, ok: false, error: problem2.message };
|
|
159735
|
+
}
|
|
159736
|
+
var isStudioVersion = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
159737
|
+
function isStudioFiles(value) {
|
|
159738
|
+
return isRecord(value) && hasText(value["STUDIO.md"]) && Object.entries(value).every(([file2, text4]) => typeof text4 === "string" && safeStudioPath(file2));
|
|
159739
|
+
}
|
|
159740
|
+
var downloads = /* @__PURE__ */ new Map();
|
|
159741
|
+
function checkedPackage(pack, version2) {
|
|
159742
|
+
return pack.version === version2 && isDigest(pack.zipSha256) && isDigest(pack.filesSha256) && Number.isSafeInteger(pack.zipBytes) && pack.zipBytes > 0 && pack.zipBytes <= STUDIO_ZIP_LIMIT && typeof pack.downloadUrl === "string" && new RegExp("^/v1/(studios/[A-Za-z0-9_-]+|tasks/[A-Za-z0-9_-]+/studio)/versions/" + version2 + "/package$").test(pack.downloadUrl);
|
|
159743
|
+
}
|
|
159744
|
+
async function cachedPackage(held5, pack, download2) {
|
|
159745
|
+
const file2 = versionFile(held5.id, held5.version);
|
|
159746
|
+
const cached3 = () => {
|
|
159747
|
+
const local = readVersion2(held5.id, held5.version);
|
|
159748
|
+
if (!local) return null;
|
|
159749
|
+
const { [VERSION_FILE]: _stamp, ...files } = local.files;
|
|
159750
|
+
return (local.filesSha256 ?? filesHash(files)) === pack.filesSha256 ? { ...held5, files, filesSha256: pack.filesSha256 } : null;
|
|
159751
|
+
};
|
|
159752
|
+
const existing = cached3();
|
|
159753
|
+
if (existing) return { ok: true, value: existing };
|
|
159754
|
+
const key = file2 + ":" + pack.filesSha256;
|
|
159755
|
+
let work = downloads.get(key);
|
|
159756
|
+
if (!work) {
|
|
159757
|
+
work = (async () => {
|
|
159758
|
+
const deadline = Date.now() + 6e4;
|
|
159759
|
+
let release2;
|
|
159760
|
+
while (!(release2 = tryLock(file2 + ".lock"))) {
|
|
159761
|
+
if (Date.now() >= deadline) return { ok: false, code: "studio_cache_busy", error: "The Studio package is still being downloaded." };
|
|
159762
|
+
await delay2(50);
|
|
159763
|
+
}
|
|
159764
|
+
try {
|
|
159765
|
+
const local = cached3();
|
|
159766
|
+
if (local) return { ok: true, value: local };
|
|
159767
|
+
const read5 = await download2(pack.downloadUrl, pack.zipBytes);
|
|
159768
|
+
if (!read5.ok) return read5;
|
|
159769
|
+
const zip = read5.value;
|
|
159770
|
+
if (zip.length !== pack.zipBytes || createHash5("sha256").update(zip).digest("hex") !== pack.zipSha256) return invalid("the Studio ZIP digest");
|
|
159771
|
+
let files;
|
|
159772
|
+
try {
|
|
159773
|
+
files = decodeStudioZip(zip);
|
|
159774
|
+
} catch {
|
|
159775
|
+
return invalid("a valid Studio ZIP");
|
|
159776
|
+
}
|
|
159777
|
+
if (!isStudioFiles(files) || filesHash(files) !== pack.filesSha256) return invalid("the Studio files digest");
|
|
159778
|
+
const value = { ...held5, files, filesSha256: pack.filesSha256 };
|
|
159779
|
+
saveVersion(value);
|
|
159780
|
+
return { ok: true, value };
|
|
159781
|
+
} finally {
|
|
159782
|
+
release2();
|
|
159783
|
+
}
|
|
159784
|
+
})().finally(() => downloads.delete(key));
|
|
159785
|
+
downloads.set(key, work);
|
|
159786
|
+
}
|
|
159787
|
+
const got = await work;
|
|
159788
|
+
return got.ok ? { ok: true, value: { ...got.value, ...held5 } } : got;
|
|
159789
|
+
}
|
|
159790
|
+
async function loadPublishedStudio(route, read5, download2, pin) {
|
|
159791
|
+
const metadata = await read5(route + "?view=metadata" + (pin ? "&version=" + pin.version : ""));
|
|
159792
|
+
if (!metadata.ok) return metadata;
|
|
159793
|
+
if (!isRecord(metadata.value)) return invalid("Studio metadata");
|
|
159794
|
+
let row = metadata.value;
|
|
159795
|
+
if (row.deleted) return { ok: true, value: null };
|
|
159796
|
+
const pack = row.package;
|
|
159797
|
+
if (!pack && !row.files) {
|
|
159798
|
+
const legacy2 = await read5(route);
|
|
159799
|
+
if (!legacy2.ok) return legacy2;
|
|
159800
|
+
row = legacy2.value;
|
|
159801
|
+
if (row.deleted) return { ok: true, value: null };
|
|
159802
|
+
}
|
|
159803
|
+
const id2 = row.id ?? row.studio;
|
|
159804
|
+
if (!hasText(id2) || !/^wf_[A-Za-z0-9_-]+$/.test(id2)) return invalid("the Studio id");
|
|
159805
|
+
const version2 = row.version ?? 1;
|
|
159806
|
+
if (!isStudioVersion(version2) || pin && (pin.studio !== id2 || pin.version !== version2)) return invalid("the Studio version");
|
|
159807
|
+
const held5 = { id: id2, version: version2, name: row.name ?? id2, names: row.names, historicalPreviews: row.historicalPreviews };
|
|
159808
|
+
if (pack) return checkedPackage(pack, version2) ? cachedPackage(held5, pack, download2) : invalid("the Studio package reference");
|
|
159809
|
+
if (!isStudioFiles(row.files)) return invalid("the Studio files");
|
|
159810
|
+
const value = { ...held5, files: row.files };
|
|
159811
|
+
saveVersion(value);
|
|
159812
|
+
return { ok: true, value };
|
|
159813
|
+
}
|
|
159814
|
+
var missingStudioVersion = (pin) => "Cannot recover Studio " + studioName(pin.studio) + " v" + pin.version + ". Its saved version is missing.";
|
|
159815
|
+
function executionSnapshot() {
|
|
159816
|
+
try {
|
|
159817
|
+
const value = JSON.parse(process.env[STUDIO_SNAPSHOT_ENV] ?? "null");
|
|
159818
|
+
if (hasText(value?.studio) && isStudioVersion(value.version)) return value;
|
|
159819
|
+
} catch {
|
|
159820
|
+
}
|
|
159821
|
+
}
|
|
159822
|
+
var activeStudioPin = (task) => executionSnapshot() ?? readPin(task);
|
|
159449
159823
|
var flowOf = (held5) => {
|
|
159450
159824
|
const id2 = studioName(held5.id);
|
|
159451
159825
|
const read5 = parseStudioFile(id2, held5.files["STUDIO.md"] ?? "", `the \`${id2}\` studio`);
|
|
@@ -159465,17 +159839,23 @@ function readFlows() {
|
|
|
159465
159839
|
return held5 ? flowOf(held5) ?? [] : [];
|
|
159466
159840
|
});
|
|
159467
159841
|
const task = workspaceTask();
|
|
159468
|
-
const pin = task ?
|
|
159842
|
+
const pin = task ? activeStudioPin(task) : null;
|
|
159469
159843
|
const pinned = pin && readVersion2(pin.studio, pin.version);
|
|
159470
159844
|
const mine = pinned && flowOf(pinned);
|
|
159471
|
-
if (!mine) return flows2;
|
|
159845
|
+
if (!mine) return pin ? flows2.filter((flow) => flow.cloudId !== pin.studio) : flows2;
|
|
159472
159846
|
return [mine, ...flows2.filter((f2) => f2.cloudId !== mine.cloudId)];
|
|
159473
159847
|
}
|
|
159474
159848
|
var sources = () => {
|
|
159475
159849
|
if (devFolder()) return [devFolder()];
|
|
159476
159850
|
const project = boardProject();
|
|
159477
159851
|
const task = workspaceTask();
|
|
159478
|
-
|
|
159852
|
+
const pin = task && activeStudioPin(task);
|
|
159853
|
+
return [
|
|
159854
|
+
sessionFile(),
|
|
159855
|
+
...project ? [listFile(project)] : [],
|
|
159856
|
+
...task ? [pinFile(task)] : [],
|
|
159857
|
+
...pin ? [versionFile(pin.studio, pin.version)] : []
|
|
159858
|
+
];
|
|
159479
159859
|
};
|
|
159480
159860
|
var flows = memoByFiles(sources, readFlows);
|
|
159481
159861
|
var cloudStudioSources = sources;
|
|
@@ -159484,7 +159864,7 @@ function cloudAgentFiles() {
|
|
|
159484
159864
|
const files = {};
|
|
159485
159865
|
const official = /* @__PURE__ */ new Set();
|
|
159486
159866
|
const owner2 = /* @__PURE__ */ new Map();
|
|
159487
|
-
for (const flow of cloudFlows()) {
|
|
159867
|
+
for (const flow of devFolder() ? cloudFlows() : []) {
|
|
159488
159868
|
for (const [name, text4] of Object.entries(flow.files)) {
|
|
159489
159869
|
const at2 = /^agents\/([^/]+)\/(.+)$/.exec(name);
|
|
159490
159870
|
if (!at2) continue;
|
|
@@ -159789,7 +160169,7 @@ function matcher(entry) {
|
|
|
159789
160169
|
}
|
|
159790
160170
|
|
|
159791
160171
|
// ../cli/src/lib/shared/board-conflicts.ts
|
|
159792
|
-
import
|
|
160172
|
+
import crypto3 from "node:crypto";
|
|
159793
160173
|
import fs26 from "node:fs";
|
|
159794
160174
|
import path27 from "node:path";
|
|
159795
160175
|
|
|
@@ -159875,7 +160255,7 @@ var fileOf = (board, id2) => {
|
|
|
159875
160255
|
};
|
|
159876
160256
|
function atomicJson(file2, data) {
|
|
159877
160257
|
fs26.mkdirSync(path27.dirname(file2), { recursive: true });
|
|
159878
|
-
const temp = `${file2}.${
|
|
160258
|
+
const temp = `${file2}.${crypto3.randomUUID()}.tmp`;
|
|
159879
160259
|
const fd = fs26.openSync(temp, "wx", 384);
|
|
159880
160260
|
try {
|
|
159881
160261
|
fs26.writeFileSync(fd, JSON.stringify(data));
|
|
@@ -159934,7 +160314,7 @@ function conflictPrompt(board, work = "Continue the original work from its saved
|
|
|
159934
160314
|
function captureConflict(board, project, files) {
|
|
159935
160315
|
const pending = pendingConflicts(board)[0];
|
|
159936
160316
|
if (pending) return pending;
|
|
159937
|
-
const record2 = { id: `c_${
|
|
160317
|
+
const record2 = { id: `c_${crypto3.randomUUID().replaceAll("-", "")}`, project, state: "open", files, receipt: null };
|
|
159938
160318
|
save(board, record2);
|
|
159939
160319
|
return record2;
|
|
159940
160320
|
}
|
|
@@ -159954,7 +160334,7 @@ async function withSyncLock(board, work) {
|
|
|
159954
160334
|
}
|
|
159955
160335
|
|
|
159956
160336
|
// src/cache.ts
|
|
159957
|
-
import
|
|
160337
|
+
import crypto4 from "node:crypto";
|
|
159958
160338
|
import fs28 from "node:fs";
|
|
159959
160339
|
import path29 from "node:path";
|
|
159960
160340
|
|
|
@@ -160010,7 +160390,7 @@ function markUnsent(dir, unsent2) {
|
|
|
160010
160390
|
}
|
|
160011
160391
|
var holds = /* @__PURE__ */ new Map();
|
|
160012
160392
|
var holdsDir = () => path29.join(runnerHome(), "holds");
|
|
160013
|
-
var holdFile = (dir) => path29.join(holdsDir(), `${
|
|
160393
|
+
var holdFile = (dir) => path29.join(holdsDir(), `${crypto4.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
|
|
160014
160394
|
function hold(dir) {
|
|
160015
160395
|
fs28.mkdirSync(holdsDir(), { recursive: true, mode: 448 });
|
|
160016
160396
|
fs28.writeFileSync(holdFile(dir), "", { mode: 384 });
|
|
@@ -161136,6 +161516,7 @@ function parseStore() {
|
|
|
161136
161516
|
runs.push({
|
|
161137
161517
|
sessionId: entry.sessionId,
|
|
161138
161518
|
cloudExecution: executionOf(entry.cloudExecution ?? null),
|
|
161519
|
+
studioPin: typeof entry.studioPin?.studio === "string" && Number.isSafeInteger(entry.studioPin.version) && entry.studioPin.version > 0 ? entry.studioPin : void 0,
|
|
161139
161520
|
pendingWrites: entry.pendingWrites === true || void 0,
|
|
161140
161521
|
submitted: entry.submitted === true || void 0,
|
|
161141
161522
|
cardId: typeof entry.cardId === "number" ? entry.cardId : null,
|
|
@@ -162226,7 +162607,7 @@ var TAG2 = /^<Storyboard\b([^<>]*?)\/>$/;
|
|
|
162226
162607
|
var attr = (name) => new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`);
|
|
162227
162608
|
var SRC_ATTR = attr("src");
|
|
162228
162609
|
var LABEL_ATTR = attr("label");
|
|
162229
|
-
var
|
|
162610
|
+
var SEGMENT = /^(?!\.)[^/\\]+$/;
|
|
162230
162611
|
function storyboardAttrs(raw) {
|
|
162231
162612
|
const m = TAG2.exec(raw.trim());
|
|
162232
162613
|
if (!m) return null;
|
|
@@ -162267,7 +162648,7 @@ function assetName(src, cardId, exts, nested = false) {
|
|
|
162267
162648
|
const parts = src.split("/");
|
|
162268
162649
|
if (parts[0] !== ".assets" || parts.length < 3 || !nested && parts.length !== 3) return { expected, actual: JSON.stringify(src) };
|
|
162269
162650
|
if (parts[1] !== String(cardId)) return { expected, actual: `another card's folder ${JSON.stringify(parts[1])}` };
|
|
162270
|
-
if (!parts.slice(2).every((part) =>
|
|
162651
|
+
if (!parts.slice(2).every((part) => SEGMENT.test(part))) return { expected, actual: JSON.stringify(src) };
|
|
162271
162652
|
const name = parts.slice(2).join("/");
|
|
162272
162653
|
const ext = name.split(".").pop().toLowerCase();
|
|
162273
162654
|
if (exts.length && (!name.includes(".") || !exts.includes(ext))) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
|
|
@@ -162336,7 +162717,7 @@ var tiled_default = `{
|
|
|
162336
162717
|
var video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
|
|
162337
162718
|
|
|
162338
162719
|
// ../artifact-sdk/src/builtin/studio.json
|
|
162339
|
-
var studio_default = '{\n "name": "studio",\n "title": {\n "en": "Studio",\n "zh": "\\u5de5\\u4f5c\\u53f0"\n },\n "types": [\n "studio"\n ],\n "schema": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "rounds",\n "land",\n "scheduled"\n ],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string"\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ]\n }\n }\n }\n }\n },\n "land": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "scheduled": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "version": {\n "enum": [\n 1\n ]\n }\n }\n },\n {\n "type": "object",\n "required": [\n "version",\n "base",\n "fingerprint",\n "files"\n ],\n "properties": {\n "version": {\n "const": 2\n },\n "base": {\n "anyOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "required": [\n "id",\n "version",\n "fingerprint"\n ],\n "properties": {\n "id": {\n "type": "string",\n "minLength": 1\n },\n "version": {\n "type": "integer",\n "minimum": 1\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n ]\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n },\n "agents": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ],\n "properties": {\n "en": {\n "type": "string",\n "minLength": 1\n },\n "zh": {\n "type": "string"\n }\n }\n }\n }\n }\n },\n "files": {\n "type": "array",\n "maxItems": 1000,\n "items": {\n "type": "object",\n "required": [\n "path",\n "before",\n "after"\n ],\n "properties": {\n "path": {\n "type": "string",\n "minLength": 1\n },\n "before": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "after": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "diff": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n "results": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Asset"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "label",\n "items"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Set"\n },\n "label": {\n "type": "string"\n },\n "items": {\n "type": "array",\n "minItems": 1,\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "src"\n ],\n "properties": {\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "a",\n "b"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Compare"\n },\n "a": {\n "type": "string",\n "minLength": 1\n },\n "b": {\n "type": "string",\n "minLength": 1\n },\n "shots": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "a-label": {\n "type": "string"\n },\n "b-label": {\n "type": "string"\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Storyboard"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n }\n }\n }\n ]\n }\n }\n }\n }\n ]\n },\n "references": [\n {\n "json": "/files/*/before"\n },\n {\n "json": "/files/*/after"\n },\n {\n "json": "/files/*/diff"\n },\n {\n "json": "/results/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n }\n ]\n}\n';
|
|
162720
|
+
var studio_default = '{\n "name": "studio",\n "title": {\n "en": "Studio",\n "zh": "\\u5de5\\u4f5c\\u53f0"\n },\n "types": [\n "studio"\n ],\n "schema": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "rounds",\n "land",\n "scheduled"\n ],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string"\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ]\n }\n }\n }\n }\n },\n "land": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "scheduled": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "version": {\n "enum": [\n 1\n ]\n }\n }\n },\n {\n "type": "object",\n "required": [\n "version",\n "base",\n "fingerprint",\n "files"\n ],\n "properties": {\n "version": {\n "const": 2\n },\n "base": {\n "anyOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "required": [\n "id",\n "version",\n "fingerprint"\n ],\n "properties": {\n "id": {\n "type": "string",\n "minLength": 1\n },\n "version": {\n "type": "integer",\n "minimum": 1\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n ]\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n },\n "agents": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ],\n "properties": {\n "en": {\n "type": "string",\n "minLength": 1\n },\n "zh": {\n "type": "string"\n }\n }\n }\n }\n }\n },\n "files": {\n "type": "array",\n "maxItems": 1000,\n "items": {\n "type": "object",\n "required": [\n "path",\n "before",\n "after"\n ],\n "properties": {\n "path": {\n "type": "string",\n "minLength": 1\n },\n "before": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "after": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "diff": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n "results": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Asset"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "playable": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "label",\n "items"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Set"\n },\n "label": {\n "type": "string"\n },\n "items": {\n "type": "array",\n "minItems": 1,\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "src"\n ],\n "properties": {\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "playable": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "a",\n "b"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Compare"\n },\n "a": {\n "type": "string",\n "minLength": 1\n },\n "b": {\n "type": "string",\n "minLength": 1\n },\n "shots": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "a-label": {\n "type": "string"\n },\n "b-label": {\n "type": "string"\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Storyboard"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n }\n }\n }\n ]\n }\n }\n }\n }\n ]\n },\n "references": [\n {\n "json": "/files/*/before"\n },\n {\n "json": "/files/*/after"\n },\n {\n "json": "/files/*/diff"\n },\n {\n "json": "/results/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n }\n ]\n}\n';
|
|
162340
162721
|
|
|
162341
162722
|
// ../artifact-sdk/src/builtin/index.ts
|
|
162342
162723
|
var read2 = (m) => typeof m === "string" ? JSON.parse(m) : m;
|
|
@@ -162579,9 +162960,9 @@ function kindOf2(ext) {
|
|
|
162579
162960
|
var text3 = (v) => typeof v === "string" && v.length > 0;
|
|
162580
162961
|
var source = (v) => text3(v) && !/^(?:[a-z][\w+.-]*:|\/|#)|\\|[\u0000-\u001f]/i.test(v);
|
|
162581
162962
|
var icon2 = (v) => v === void 0 || typeof v === "string" || Array.isArray(v) && v.length > 0 && v.length <= 12 && v.every((p2) => isObject(p2) && text3(p2.d) && /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/.test(p2.d) && ["f", "s"].every((k2) => p2[k2] === void 0 || typeof p2[k2] === "string" && /^[kwcgopsmlry]$/.test(p2[k2])) && (p2.o === void 0 || p2.o === true) && (p2.w === void 0 || typeof p2.w === "number" && p2.w > 0 && p2.w <= 3));
|
|
162582
|
-
var relativePath = (v) =>
|
|
162963
|
+
var relativePath = (v) => text3(v) && !/^(?:[a-z][\w+.-]*:|\/)|\\|[\u0000-\u001f]/i.test(v) && v.split("/").every((p2) => p2 && p2 !== "." && p2 !== "..");
|
|
162583
162964
|
var optionalText = (v, keys) => keys.every((k2) => v[k2] === void 0 || typeof v[k2] === "string");
|
|
162584
|
-
var asset2 = (v) => isObject(v) && source(v.src) && optionalText(v, ["label", "alt"]) && (v.alt === void 0 || !/[<>]/.test(v.alt)) && (v.device === void 0 || v.device === "desktop" || v.device === "mobile") && (v.loop === void 0 || typeof v.loop === "boolean") && (v.variants === void 0 || isObject(v.variants) && Object.values(v.variants).every(source));
|
|
162965
|
+
var asset2 = (v) => isObject(v) && source(v.src) && optionalText(v, ["label", "alt"]) && (v.alt === void 0 || !/[<>]/.test(v.alt)) && (v.device === void 0 || v.device === "desktop" || v.device === "mobile") && (v.loop === void 0 || typeof v.loop === "boolean") && (v.playable === void 0 || typeof v.playable === "boolean") && (v.variants === void 0 || isObject(v.variants) && Object.values(v.variants).every(source));
|
|
162585
162966
|
function resultProblem(value, agents) {
|
|
162586
162967
|
if (!Array.isArray(value) || value.length > 500) return "/results";
|
|
162587
162968
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -162606,7 +162987,7 @@ function reviewProblem(v) {
|
|
|
162606
162987
|
const paths = /* @__PURE__ */ new Set();
|
|
162607
162988
|
for (const f2 of v.files) {
|
|
162608
162989
|
if (!isObject(f2) || !relativePath(f2.path) || paths.has(f2.path) || !(f2.before === null || source(f2.before)) || !(f2.after === null || source(f2.after)) || f2.before === null && f2.after === null || f2.diff !== void 0 && !source(f2.diff) || (f2.before === null || f2.after === null) && !f2.diff) return "/files";
|
|
162609
|
-
if (f2.path.startsWith("agents/") && !agents.has(f2.path.split("/")[1])) return "/files";
|
|
162990
|
+
if (v.agents !== void 0 && f2.path.startsWith("agents/") && !agents.has(f2.path.split("/")[1])) return "/files";
|
|
162610
162991
|
paths.add(f2.path);
|
|
162611
162992
|
}
|
|
162612
162993
|
return v.results === void 0 ? null : resultProblem(v.results, agents);
|
|
@@ -162930,8 +163311,8 @@ function validateSpec(file2, text4, id2, context) {
|
|
|
162930
163311
|
if (/^\s*<Storyboard\b/.test(line) && (storyboardTag(line) === null || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
|
|
162931
163312
|
add2(i + 1, "storyboard-block", 'Put one self-closing <Storyboard src=".assets/<card id>/storyboard.json" /> tag on its own line, with blank lines around it.');
|
|
162932
163313
|
}
|
|
162933
|
-
if (/^\s*<Studio\b/.test(line) && (studioTag(line)
|
|
162934
|
-
add2(i + 1, "studio-block", 'Put one self-closing <Studio src=".assets/<card id>/studio.json"
|
|
163314
|
+
if (/^\s*<Studio\b/.test(line) && (!studioTag(line) || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
|
|
163315
|
+
add2(i + 1, "studio-block", 'Put one self-closing <Studio src=".assets/<card id>/studio-review/review.json" /> tag on its own line, with blank lines around it.');
|
|
162935
163316
|
}
|
|
162936
163317
|
if (/^\s*<Compare\b/.test(line)) {
|
|
162937
163318
|
const attrs = compareAttrs(line);
|
|
@@ -163071,7 +163452,7 @@ function validateStoryboards(file2, id2, text4) {
|
|
|
163071
163452
|
["Studio", studioTag, "studio-src", "Fix the path or freeze the draft with `akb studio preview <card> --folder <draft> --base <baseline>` and use the returned Studio tag."]
|
|
163072
163453
|
]) {
|
|
163073
163454
|
for (const marker of storyboardMarkers(text4, tagOf)) {
|
|
163074
|
-
const named = assetName(marker.src, id2, ["json"]);
|
|
163455
|
+
const named = assetName(marker.src, id2, ["json"], tag === "Studio");
|
|
163075
163456
|
const add2 = (message) => errors.push({ file: rel(file2), line: marker.line, rule, message });
|
|
163076
163457
|
if (!("name" in named)) add2(`${tag} src is ${named.actual}; expected ${named.expected}.`);
|
|
163077
163458
|
else if (!inside(dir, named.name)) add2(`${tag} src ${marker.src} names no file in this card's asset folder. ${fix}`);
|
|
@@ -164093,6 +164474,13 @@ function cmdAgentFile(askedName, askedFile) {
|
|
|
164093
164474
|
|
|
164094
164475
|
// ../cli/src/lib/agent/studio-shared.ts
|
|
164095
164476
|
function studioFiles(studio2) {
|
|
164477
|
+
const task = workspaceTask();
|
|
164478
|
+
const pin = task ? activeStudioPin(task) : null;
|
|
164479
|
+
if (pin && (pin.studio === studio2 || studioName(pin.studio) === studio2)) {
|
|
164480
|
+
const held5 = readVersion2(pin.studio, pin.version);
|
|
164481
|
+
if (!held5) throw new Error(missingStudioVersion(pin));
|
|
164482
|
+
return held5.files;
|
|
164483
|
+
}
|
|
164096
164484
|
const flow = cloudFlows().find((f2) => f2.def.id === studio2 || f2.cloudId === studio2);
|
|
164097
164485
|
if (flow) return flow.files;
|
|
164098
164486
|
return null;
|
|
@@ -164104,14 +164492,21 @@ function cmdStudioFile(askedStudio, askedFile) {
|
|
|
164104
164492
|
const files = studioFiles(studio2);
|
|
164105
164493
|
if (!files) die(`no studio ${studio2}`, { kind: "no-such-studio", studio: studio2 });
|
|
164106
164494
|
const file2 = askedFile.trim().replace(/^\.\//, "");
|
|
164107
|
-
const readable = Object.keys(files).filter((f2) => f2
|
|
164108
|
-
if (!readable.includes(file2)
|
|
164495
|
+
const readable = Object.keys(files).filter((f2) => safeStudioPath(f2) && f2 !== VERSION_FILE && !isAboutFile(f2)).sort();
|
|
164496
|
+
if (!readable.includes(file2)) {
|
|
164109
164497
|
die(`${studio2} has no ${file2}. It has: ${readable.join(", ")}.`, { kind: "no-such-studio-file", studio: studio2, file: file2 });
|
|
164110
164498
|
}
|
|
164111
164499
|
const text4 = files[file2];
|
|
164112
164500
|
say(text4);
|
|
164113
164501
|
return { studio: studio2, file: file2, text: text4 };
|
|
164114
164502
|
}
|
|
164503
|
+
function cmdStudioSkills(studio2) {
|
|
164504
|
+
const files = studioFiles(studio2.trim());
|
|
164505
|
+
if (!files) die("no studio " + studio2, { kind: "no-such-studio", studio: studio2 });
|
|
164506
|
+
const skills = studioSkills(files);
|
|
164507
|
+
for (const { name, description } of skills) say(name + " " + description);
|
|
164508
|
+
return { skills };
|
|
164509
|
+
}
|
|
164115
164510
|
|
|
164116
164511
|
// ../cli/src/lib/memories.ts
|
|
164117
164512
|
import fs50 from "node:fs";
|
|
@@ -164327,6 +164722,7 @@ var MOVES = {
|
|
|
164327
164722
|
reject: ({ args: args2, opts }) => cmdRemove(Number(args2[0]), "rejected", as(opts)),
|
|
164328
164723
|
"agent-file": ({ args: args2 }) => cmdAgentFile(args2[0] ?? "", args2[1] ?? ""),
|
|
164329
164724
|
file: ({ args: args2 }) => cmdStudioFile(args2[0] ?? "", args2[1] ?? ""),
|
|
164725
|
+
skills: ({ args: args2 }) => cmdStudioSkills(args2[0] ?? ""),
|
|
164330
164726
|
"memory-file": ({ args: args2 }) => cmdMemoryFile(args2[0] ?? "")
|
|
164331
164727
|
};
|
|
164332
164728
|
var BOARD_MOVES = new Set(Object.keys(MOVES));
|
|
@@ -165821,16 +166217,16 @@ function cleanEnum(obj3) {
|
|
|
165821
166217
|
}
|
|
165822
166218
|
function base64ToUint8Array(base643) {
|
|
165823
166219
|
const binaryString = atob(base643);
|
|
165824
|
-
const
|
|
166220
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
165825
166221
|
for (let i = 0; i < binaryString.length; i++) {
|
|
165826
|
-
|
|
166222
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
165827
166223
|
}
|
|
165828
|
-
return
|
|
166224
|
+
return bytes;
|
|
165829
166225
|
}
|
|
165830
|
-
function uint8ArrayToBase64(
|
|
166226
|
+
function uint8ArrayToBase64(bytes) {
|
|
165831
166227
|
let binaryString = "";
|
|
165832
|
-
for (let i = 0; i <
|
|
165833
|
-
binaryString += String.fromCharCode(
|
|
166228
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
166229
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
165834
166230
|
}
|
|
165835
166231
|
return btoa(binaryString);
|
|
165836
166232
|
}
|
|
@@ -165839,22 +166235,22 @@ function base64urlToUint8Array(base64url3) {
|
|
|
165839
166235
|
const padding = "=".repeat((4 - base643.length % 4) % 4);
|
|
165840
166236
|
return base64ToUint8Array(base643 + padding);
|
|
165841
166237
|
}
|
|
165842
|
-
function uint8ArrayToBase64url(
|
|
165843
|
-
return uint8ArrayToBase64(
|
|
166238
|
+
function uint8ArrayToBase64url(bytes) {
|
|
166239
|
+
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
165844
166240
|
}
|
|
165845
166241
|
function hexToUint8Array(hex3) {
|
|
165846
166242
|
const cleanHex = hex3.replace(/^0x/, "");
|
|
165847
166243
|
if (cleanHex.length % 2 !== 0) {
|
|
165848
166244
|
throw new Error("Invalid hex string length");
|
|
165849
166245
|
}
|
|
165850
|
-
const
|
|
166246
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
165851
166247
|
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
165852
|
-
|
|
166248
|
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
165853
166249
|
}
|
|
165854
|
-
return
|
|
166250
|
+
return bytes;
|
|
165855
166251
|
}
|
|
165856
|
-
function uint8ArrayToHex(
|
|
165857
|
-
return Array.from(
|
|
166252
|
+
function uint8ArrayToHex(bytes) {
|
|
166253
|
+
return Array.from(bytes).map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
165858
166254
|
}
|
|
165859
166255
|
var Class = class {
|
|
165860
166256
|
constructor(..._args) {
|
|
@@ -184388,7 +184784,7 @@ function documentPreviewKey(artifact, version2) {
|
|
|
184388
184784
|
var TEXT_LIMIT = 1024 * 1024;
|
|
184389
184785
|
|
|
184390
184786
|
// ../cli/src/components/Asset.md
|
|
184391
|
-
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- **Captions**: `captions` binds a UTF-8 SRT or WebVTT file to an audio or video Asset. The timecoded list seeks the player and highlights the current line. Both original files are available in the Asset menu.\n- **Video overlay**: `overlay=".assets/42/overlay.html"` shares a transparent HTML layer across versions. Use a JSON object keyed by exact `variants` labels for separate `.html` or `.htm` files. A missing or failed overlay leaves the video playable.\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- **3D models**: a self-contained `.glb` or a `.blend` with saved meshes opens in a read-only viewer with rotation, zoom, reset, and original-file download.\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\n### Audio and video captions\n\nSave the media and caption files with the task and add an Asset in its Preview. Video captions appear in the timecoded list. An optional `overlay` still controls the video layer.\n\n```html\n<Asset src=".assets/42/interview.mp3" captions=".assets/42/interview.vtt" label="Interview" />\n```\n\nFor `variants`, give `captions` exactly the same labels and a caption path for each version.\n\n```html\n<Asset src=".assets/42/demo.en.mp4" variants=\'{"English":".assets/42/demo.en.mp4","\u4E2D\u6587":".assets/42/demo.zh.mp4"}\' captions=\'{"English":".assets/42/demo.en.srt","\u4E2D\u6587":".assets/42/demo.zh.srt"}\' label="Demo" />\n```\n\n### Video overlay\n\nOverlay HTML and CSS use the video\'s original dimensions. Keep images, stylesheets and fonts at paths relative to the HTML file. Scripts are disabled. Time bounds are in seconds, with the start included and the end excluded. Omit either bound to start at zero or continue through the end. Elements without time bounds are displayed as authored.\n\n```html\n<Asset src=".assets/42/demo.mp4" label="Demo" overlay=".assets/42/overlay.html" />\n```\n\nIn `overlay.html`:\n\n```html\n<div data-overlay-start="1.25" data-overlay-end="3.5"\n style="position:absolute; left:6%; bottom:12%; font-size:48px; color:white">\n <img src="images/star.png" width="48" alt=""> <strong style="color:gold">New</strong> chapter\n</div>\n```\n';
|
|
184787
|
+
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- **Playable**: add `playable` for an interactive HTML game in a 16:9 sandboxed viewport with click-to-focus keyboard capture and fullscreen pointer lock.\n- **Captions**: `captions` binds a UTF-8 SRT or WebVTT file to an audio or video Asset. The timecoded list seeks the player and highlights the current line. Both original files are available in the Asset menu.\n- **Video overlay**: `overlay=".assets/42/overlay.html"` shares a transparent HTML layer across versions. Use a JSON object keyed by exact `variants` labels for separate `.html` or `.htm` files. A missing or failed overlay leaves the video playable.\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- **3D models**: a self-contained `.glb` or a `.blend` with saved meshes opens in a read-only viewer with rotation, zoom, reset, and original-file download.\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\n### Audio and video captions\n\nSave the media and caption files with the task and add an Asset in its Preview. Video captions appear in the timecoded list. An optional `overlay` still controls the video layer.\n\n```html\n<Asset src=".assets/42/interview.mp3" captions=".assets/42/interview.vtt" label="Interview" />\n```\n\nFor `variants`, give `captions` exactly the same labels and a caption path for each version.\n\n```html\n<Asset src=".assets/42/demo.en.mp4" variants=\'{"English":".assets/42/demo.en.mp4","\u4E2D\u6587":".assets/42/demo.zh.mp4"}\' captions=\'{"English":".assets/42/demo.en.srt","\u4E2D\u6587":".assets/42/demo.zh.srt"}\' label="Demo" />\n```\n\n### Video overlay\n\nOverlay HTML and CSS use the video\'s original dimensions. Keep images, stylesheets and fonts at paths relative to the HTML file. Scripts are disabled. Time bounds are in seconds, with the start included and the end excluded. Omit either bound to start at zero or continue through the end. Elements without time bounds are displayed as authored.\n\n```html\n<Asset src=".assets/42/demo.mp4" label="Demo" overlay=".assets/42/overlay.html" />\n```\n\nIn `overlay.html`:\n\n```html\n<div data-overlay-start="1.25" data-overlay-end="3.5"\n style="position:absolute; left:6%; bottom:12%; font-size:48px; color:white">\n <img src="images/star.png" width="48" alt=""> <strong style="color:gold">New</strong> chapter\n</div>\n```\n';
|
|
184392
184788
|
|
|
184393
184789
|
// ../cli/src/components/Compare.md
|
|
184394
184790
|
var Compare_default = '# Compare\n\nShow two files with `<Compare a="<src>" b="<src>" label="..." a-label="..." b-label="..." />` alone in a paragraph; never render a side-by-side file for it. Inline and fenced examples remain text.\n\n- **Sides**: either side may be anything an Asset shows, of different kinds, but not another compare; two images or two videos share one viewer, any other pair shows as two Assets.\n- **Video shots**: add `shots="<src>"`, a JSON list of `{ "id": "S1", "start": 0, "end": 2.25, "name": "..." }` covering video A in order, or a storyboard of A.\n- **Storyboard pairing**: beside video A, B may be a storyboard of it; it shows the shot with the id A is on, beside that shot of a storyboard `shots`.\n- **Data contract**: follow the producing agent\'s file contract and validator for storyboards.\n';
|
|
@@ -184514,7 +184910,7 @@ exec ${shellLine} "$@"
|
|
|
184514
184910
|
}
|
|
184515
184911
|
function akbEnv(akb, board, task, language2, base = process.env) {
|
|
184516
184912
|
const env2 = {};
|
|
184517
|
-
const dropped = ["AI4KANBAN_PREVIEW_BRIDGE", "AI4KANBAN_REPLY_APPROVAL", "AI4KANBAN_BOARD", "AI4KANBAN_TASK", "AI4KANBAN_EXECUTION", "AI4KANBAN_SCHEDULED_AGENTS", LANGUAGE_ENV, SESSION_COST_ENV, EXECUTION_RUNTIMES_ENV];
|
|
184913
|
+
const dropped = ["AI4KANBAN_PREVIEW_BRIDGE", "AI4KANBAN_REPLY_APPROVAL", "AI4KANBAN_BOARD", "AI4KANBAN_TASK", "AI4KANBAN_EXECUTION", "AI4KANBAN_SCHEDULED_AGENTS", STUDIO_SNAPSHOT_ENV, LANGUAGE_ENV, SESSION_COST_ENV, EXECUTION_RUNTIMES_ENV];
|
|
184518
184914
|
for (const [k2, v] of Object.entries({ ...proxyEnv(), ...base })) if (!k2.startsWith("KANBAN_") && !dropped.includes(k2)) env2[k2] = v;
|
|
184519
184915
|
const key = Object.keys(env2).find((k2) => k2.toUpperCase() === "PATH") ?? "PATH";
|
|
184520
184916
|
env2[key] = [shimDir(akb), env2[key]].filter(Boolean).join(path54.delimiter);
|
|
@@ -184577,7 +184973,7 @@ function answerOf2(ran) {
|
|
|
184577
184973
|
|
|
184578
184974
|
// src/runtimes.ts
|
|
184579
184975
|
import { spawn as spawn3 } from "node:child_process";
|
|
184580
|
-
import { randomUUID as
|
|
184976
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
184581
184977
|
import fs54 from "node:fs";
|
|
184582
184978
|
import os6 from "node:os";
|
|
184583
184979
|
import path55 from "node:path";
|
|
@@ -184669,7 +185065,7 @@ var takesImageArgs = (runtime) => HARNESSES2[runtime].images?.as === "args";
|
|
|
184669
185065
|
function plan(runtime, prompt, cwd, resume, model, given = {}, fork = false, language2 = null, images = [], discussionImages) {
|
|
184670
185066
|
const harness = HARNESSES2[runtime];
|
|
184671
185067
|
const { argv, note } = installedCommand(harness);
|
|
184672
|
-
const id2 =
|
|
185068
|
+
const id2 = randomUUID5();
|
|
184673
185069
|
const session = fork ? resume && harness.forkArgs ? { id: id2, resume, fork: true } : { id: id2 } : resume ? { resume } : { id: id2 };
|
|
184674
185070
|
const launch2 = planLaunch(harness, argv, {
|
|
184675
185071
|
cwd,
|
|
@@ -184921,8 +185317,8 @@ function writeRemoval(board, task, removal) {
|
|
|
184921
185317
|
|
|
184922
185318
|
// src/task-folder.ts
|
|
184923
185319
|
init_file_limits();
|
|
184924
|
-
import { setTimeout as
|
|
184925
|
-
import
|
|
185320
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
185321
|
+
import crypto5 from "node:crypto";
|
|
184926
185322
|
import fs58 from "node:fs";
|
|
184927
185323
|
import path60 from "node:path";
|
|
184928
185324
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -185229,8 +185625,8 @@ function logSync(event2, fields2 = {}) {
|
|
|
185229
185625
|
if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
|
|
185230
185626
|
}
|
|
185231
185627
|
if (syncDebug) {
|
|
185232
|
-
const
|
|
185233
|
-
|
|
185628
|
+
const delay4 = monitorEventLoopDelay({ resolution: 20 });
|
|
185629
|
+
delay4.enable();
|
|
185234
185630
|
let cpu = process.cpuUsage();
|
|
185235
185631
|
let at2 = performance.now();
|
|
185236
185632
|
setInterval(() => {
|
|
@@ -185238,14 +185634,14 @@ if (syncDebug) {
|
|
|
185238
185634
|
const used = process.cpuUsage(cpu);
|
|
185239
185635
|
logSync("health", {
|
|
185240
185636
|
cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
|
|
185241
|
-
delayMaxMs: Math.round(
|
|
185242
|
-
delayP99Ms: Math.round(
|
|
185637
|
+
delayMaxMs: Math.round(delay4.max / 1e6),
|
|
185638
|
+
delayP99Ms: Math.round(delay4.percentile(99) / 1e6),
|
|
185243
185639
|
...counts
|
|
185244
185640
|
});
|
|
185245
185641
|
for (const name of Object.keys(counts)) delete counts[name];
|
|
185246
185642
|
cpu = process.cpuUsage();
|
|
185247
185643
|
at2 = now;
|
|
185248
|
-
|
|
185644
|
+
delay4.reset();
|
|
185249
185645
|
}, 5e3).unref();
|
|
185250
185646
|
}
|
|
185251
185647
|
|
|
@@ -185452,7 +185848,7 @@ function writeBase(ws, base) {
|
|
|
185452
185848
|
fs58.writeFileSync(`${file2}.tmp`, JSON.stringify(base));
|
|
185453
185849
|
fs58.renameSync(`${file2}.tmp`, file2);
|
|
185454
185850
|
}
|
|
185455
|
-
var hashOf2 = (
|
|
185851
|
+
var hashOf2 = (bytes) => crypto5.createHash("sha256").update(bytes).digest("hex");
|
|
185456
185852
|
function hashFile(file2) {
|
|
185457
185853
|
try {
|
|
185458
185854
|
return hashOf2(fs58.readFileSync(file2));
|
|
@@ -185460,9 +185856,9 @@ function hashFile(file2) {
|
|
|
185460
185856
|
return null;
|
|
185461
185857
|
}
|
|
185462
185858
|
}
|
|
185463
|
-
function write(file2,
|
|
185859
|
+
function write(file2, bytes) {
|
|
185464
185860
|
fs58.mkdirSync(path60.dirname(file2), { recursive: true });
|
|
185465
|
-
fs58.writeFileSync(file2,
|
|
185861
|
+
fs58.writeFileSync(file2, bytes);
|
|
185466
185862
|
}
|
|
185467
185863
|
function readText(file2) {
|
|
185468
185864
|
try {
|
|
@@ -185511,53 +185907,79 @@ var localFiles = (ws, base) => {
|
|
|
185511
185907
|
const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path60.join(ws.board, assetsFile(ws.task))))]);
|
|
185512
185908
|
return filesUnder(ws.board, ws.board, path60.join(ws.board, "deliveries")).filter((p2) => kept3(p2) && !assets.has(p2));
|
|
185513
185909
|
};
|
|
185514
|
-
|
|
185515
|
-
|
|
185516
|
-
|
|
185517
|
-
|
|
185518
|
-
const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs58.existsSync(path60.join(ws.cwd, root2, skill)));
|
|
185519
|
-
const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
|
|
185520
|
-
const skills = {};
|
|
185521
|
-
for (const [name, text4] of Object.entries(files)) {
|
|
185522
|
-
const at2 = SKILL_PATH.exec(name);
|
|
185523
|
-
if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
|
|
185524
|
-
skills[name] = hashOf2(text4);
|
|
185910
|
+
function removePlacedSkills(ws, held5) {
|
|
185911
|
+
for (const [name, hash2] of Object.entries(held5)) {
|
|
185912
|
+
const [top, skill, ...rest] = name.split("/");
|
|
185913
|
+
if (top !== "skills" || !skill || skill === "kanban" || !rest.length || !safeStudioPath(name)) continue;
|
|
185525
185914
|
for (const root2 of SKILL_ROOTS) {
|
|
185526
|
-
const
|
|
185527
|
-
|
|
185528
|
-
|
|
185529
|
-
|
|
185530
|
-
|
|
185531
|
-
|
|
185532
|
-
|
|
185533
|
-
|
|
185534
|
-
|
|
185535
|
-
fs58.rmSync(
|
|
185536
|
-
|
|
185915
|
+
const boundary = path60.join(ws.cwd, root2);
|
|
185916
|
+
const file2 = path60.join(boundary, skill, ...rest);
|
|
185917
|
+
let current2 = ws.cwd;
|
|
185918
|
+
const safe3 = [...root2.split("/"), skill, ...rest].every((part) => {
|
|
185919
|
+
current2 = path60.join(current2, part);
|
|
185920
|
+
const entry = fs58.lstatSync(current2, { throwIfNoEntry: false });
|
|
185921
|
+
return current2 === file2 ? entry?.isFile() : entry?.isDirectory();
|
|
185922
|
+
});
|
|
185923
|
+
if (!safe3 || hashFile(file2) !== hash2) continue;
|
|
185924
|
+
fs58.rmSync(file2, { force: true });
|
|
185925
|
+
for (let dir = path60.dirname(file2); dir !== boundary; dir = path60.dirname(dir)) {
|
|
185926
|
+
try {
|
|
185927
|
+
fs58.rmdirSync(dir);
|
|
185928
|
+
} catch {
|
|
185929
|
+
break;
|
|
185930
|
+
}
|
|
185931
|
+
}
|
|
185537
185932
|
}
|
|
185538
185933
|
}
|
|
185539
|
-
|
|
185540
|
-
|
|
185541
|
-
let mcp = {};
|
|
185934
|
+
}
|
|
185935
|
+
function studioMcp(files) {
|
|
185542
185936
|
try {
|
|
185543
|
-
|
|
185937
|
+
return JSON.parse(files["mcp.json"] ?? "{}").mcpServers ?? {};
|
|
185544
185938
|
} catch {
|
|
185939
|
+
return {};
|
|
185545
185940
|
}
|
|
185546
|
-
record2.tools = { skills, mcp };
|
|
185547
185941
|
}
|
|
185548
|
-
var mcpServersOf = (ws) =>
|
|
185549
|
-
|
|
185550
|
-
const
|
|
185551
|
-
|
|
185552
|
-
|
|
185553
|
-
|
|
185942
|
+
var mcpServersOf = (ws) => {
|
|
185943
|
+
const pin = ws.studioSnapshot;
|
|
185944
|
+
const held5 = pin && readVersion2(pin.studio, pin.version);
|
|
185945
|
+
return held5 ? studioMcp(held5.files) : readRecord(ws).tools?.mcp ?? {};
|
|
185946
|
+
};
|
|
185947
|
+
async function studioFiles2(ws) {
|
|
185948
|
+
const requested = ws.studioSnapshot;
|
|
185949
|
+
const route = "/v1/tasks/" + encodeURIComponent(ws.task) + "/studio";
|
|
185950
|
+
const read5 = await loadPublishedStudio(route, (route2) => request("GET", route2), download, requested);
|
|
185951
|
+
if (!read5.ok) {
|
|
185952
|
+
if (!requested || !["not_found", "invalid_response"].includes(read5.code ?? "")) return read5;
|
|
185953
|
+
const cached3 = readVersion2(requested.studio, requested.version);
|
|
185954
|
+
if (!cached3) return { ok: false, error: missingStudioVersion(requested), code: "studio_version_missing" };
|
|
185955
|
+
ws.bindStudio?.(requested);
|
|
185956
|
+
return { ok: true, value: cached3.files };
|
|
185957
|
+
}
|
|
185958
|
+
if (!read5.value) {
|
|
185959
|
+
const pin = ws.studioSnapshot ?? readPin(ws.task);
|
|
185960
|
+
const held6 = pin && readVersion2(pin.studio, pin.version);
|
|
185961
|
+
if (requested) {
|
|
185962
|
+
if (!held6) return { ok: false, code: "studio_version_missing", error: missingStudioVersion(requested) };
|
|
185963
|
+
ws.bindStudio?.(requested);
|
|
185964
|
+
}
|
|
185965
|
+
return { ok: true, value: held6?.files ?? {} };
|
|
185966
|
+
}
|
|
185967
|
+
const held5 = read5.value;
|
|
185968
|
+
const snapshot = { studio: held5.id, version: held5.version, historicalPreviews: held5.historicalPreviews };
|
|
185969
|
+
ws.studioSnapshot = snapshot;
|
|
185970
|
+
ws.bindStudio?.(snapshot);
|
|
185971
|
+
if (!requested) savePin(ws.task, held5, true);
|
|
185972
|
+
return { ok: true, value: held5.files };
|
|
185554
185973
|
}
|
|
185555
185974
|
async function pullStudio(ws, record2) {
|
|
185556
185975
|
if (ws.cloudTask === ws.task) {
|
|
185557
185976
|
record2.builtin = ws.studio?.startsWith("wf_builtin_") ?? false;
|
|
185558
|
-
const files = await studioFiles2(ws
|
|
185559
|
-
if (!files.ok && files.code !== "not_found") return files;
|
|
185560
|
-
if (files.ok)
|
|
185977
|
+
const files = await studioFiles2(ws);
|
|
185978
|
+
if (!files.ok && (ws.studioSnapshot || files.code !== "not_found")) return files;
|
|
185979
|
+
if (files.ok) {
|
|
185980
|
+
removePlacedSkills(ws, record2.tools?.skills ?? {});
|
|
185981
|
+
record2.tools = { skills: {}, mcp: studioMcp(files.value) };
|
|
185982
|
+
}
|
|
185561
185983
|
}
|
|
185562
185984
|
dropPlacedAgents(ws);
|
|
185563
185985
|
for (const name of Object.keys(record2.agents ?? {})) fs58.rmSync(path60.join(ws.board, name), { force: true });
|
|
@@ -185969,14 +186391,14 @@ async function pullAssets(ws, record2, assets, preserve = false, stopped2) {
|
|
|
185969
186391
|
out[name] = { ...held5, kind };
|
|
185970
186392
|
continue;
|
|
185971
186393
|
}
|
|
185972
|
-
const
|
|
185973
|
-
if (!
|
|
185974
|
-
if (!
|
|
186394
|
+
const bytes = await readAsset(ref.artifact, version2);
|
|
186395
|
+
if (!bytes.ok && unavailable2(bytes)) continue;
|
|
186396
|
+
if (!bytes.ok && bytes.code === "not_found") {
|
|
185975
186397
|
if (held5) out[name] = held5;
|
|
185976
186398
|
continue;
|
|
185977
186399
|
}
|
|
185978
|
-
if (!
|
|
185979
|
-
let local =
|
|
186400
|
+
if (!bytes.ok) return bytes;
|
|
186401
|
+
let local = bytes.value;
|
|
185980
186402
|
const dependencies = [];
|
|
185981
186403
|
const manifest = fileManifest(kind, name);
|
|
185982
186404
|
let data;
|
|
@@ -186030,7 +186452,7 @@ async function pullAssets(ws, record2, assets, preserve = false, stopped2) {
|
|
|
186030
186452
|
continue;
|
|
186031
186453
|
}
|
|
186032
186454
|
write(target, local);
|
|
186033
|
-
const hash2 = hashOf2(typeof data === "string" ? local :
|
|
186455
|
+
const hash2 = hashOf2(typeof data === "string" ? local : bytes.value);
|
|
186034
186456
|
out[name] = { ...held5, kind, dependencies: [...new Set(dependencies)], artifact: ref.artifact, version: version2, hash: hash2, localHash: hashOf2(local) };
|
|
186035
186457
|
}
|
|
186036
186458
|
record2.assets = out;
|
|
@@ -186091,19 +186513,19 @@ function undrawn(ws, reason) {
|
|
|
186091
186513
|
}
|
|
186092
186514
|
return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
|
|
186093
186515
|
}
|
|
186094
|
-
async function uploadAsset(artifact, { bytes
|
|
186095
|
-
const upload2 = await createUpload(artifact, type, Math.max(
|
|
186516
|
+
async function uploadAsset(artifact, { bytes, type }) {
|
|
186517
|
+
const upload2 = await createUpload(artifact, type, Math.max(bytes.length, 1));
|
|
186096
186518
|
if (!upload2.ok) return upload2;
|
|
186097
186519
|
const { id: id2, url: url2, parts } = upload2.value;
|
|
186098
186520
|
if (parts) {
|
|
186099
186521
|
for (let part = 1; part <= parts.count; part++) {
|
|
186100
|
-
const put = await upload(parts.url.replace("{part}", String(part)),
|
|
186522
|
+
const put = await upload(parts.url.replace("{part}", String(part)), bytes.subarray((part - 1) * parts.size, part * parts.size), type);
|
|
186101
186523
|
if (!put.ok) return put;
|
|
186102
186524
|
}
|
|
186103
186525
|
const done = await completeUpload(url2 ?? `/v1/uploads/${encodeURIComponent(id2)}/complete`);
|
|
186104
186526
|
if (!done.ok) return done;
|
|
186105
186527
|
} else {
|
|
186106
|
-
const put = await upload(url2 ?? `/v1/uploads/${encodeURIComponent(id2)}`,
|
|
186528
|
+
const put = await upload(url2 ?? `/v1/uploads/${encodeURIComponent(id2)}`, bytes, type);
|
|
186107
186529
|
if (!put.ok) return put;
|
|
186108
186530
|
}
|
|
186109
186531
|
return { ok: true, value: id2 };
|
|
@@ -186129,19 +186551,19 @@ async function pushDocumentPreview(ws, record2, key, ext, source2) {
|
|
|
186129
186551
|
record2.pendingVersions ??= {};
|
|
186130
186552
|
let pending = record2.pendingVersions[key];
|
|
186131
186553
|
if (!pending) {
|
|
186132
|
-
let
|
|
186554
|
+
let bytes;
|
|
186133
186555
|
try {
|
|
186134
186556
|
const { renderOfficePdf: renderOfficePdf2 } = await Promise.resolve().then(() => (init_document_preview(), document_preview_exports));
|
|
186135
|
-
|
|
186557
|
+
bytes = await renderOfficePdf2(source2, ext);
|
|
186136
186558
|
} catch (error62) {
|
|
186137
186559
|
logSync("assets.documentPreviewUnavailable", { project: ws.project, task: ws.task, reason: error62 instanceof Error ? error62.message : String(error62) });
|
|
186138
186560
|
return { ok: true, value: void 0 };
|
|
186139
186561
|
}
|
|
186140
186562
|
const made = await createArtifact(ws.cloudTask, key, "asset", artifactKey(ws.cloudTask, key, "asset"));
|
|
186141
186563
|
if (!made.ok) return made;
|
|
186142
|
-
const sent = await uploadAsset(made.value.id, { bytes
|
|
186564
|
+
const sent = await uploadAsset(made.value.id, { bytes, type: PDF, kind: "asset" });
|
|
186143
186565
|
if (!sent.ok) return sent;
|
|
186144
|
-
pending = record2.pendingVersions[key] = { artifact: made.value.id, hash: hashOf2(
|
|
186566
|
+
pending = record2.pendingVersions[key] = { artifact: made.value.id, hash: hashOf2(bytes), upload: sent.value };
|
|
186145
186567
|
writeRecord(ws, record2);
|
|
186146
186568
|
}
|
|
186147
186569
|
const version2 = await finishAssetVersion(ws, record2, key, pending);
|
|
@@ -186386,7 +186808,7 @@ async function whenPrepared(ws, cancelled, work, stopped2 = () => false) {
|
|
|
186386
186808
|
if (!busy(preparationKey(ws))) return { value: await work() };
|
|
186387
186809
|
});
|
|
186388
186810
|
if (result) return result.value;
|
|
186389
|
-
await
|
|
186811
|
+
await delay3(100);
|
|
186390
186812
|
}
|
|
186391
186813
|
return cancelled;
|
|
186392
186814
|
}
|
|
@@ -186907,12 +187329,16 @@ async function reconcileArchives(ws, base, archives, pending, machine) {
|
|
|
186907
187329
|
}
|
|
186908
187330
|
function taskStudio(ws) {
|
|
186909
187331
|
if (!ws.cloudTask) return null;
|
|
186910
|
-
const pin = readPin(ws.cloudTask), held5 = pin && readVersion2(pin.studio, pin.version);
|
|
186911
|
-
if (!held5) throw new Error("The task Studio version is not downloaded.");
|
|
187332
|
+
const pin = ws.studioSnapshot ?? readPin(ws.cloudTask), held5 = pin && readVersion2(pin.studio, pin.version);
|
|
187333
|
+
if (!held5) throw new Error(pin ? missingStudioVersion(pin) : "The task Studio version is not downloaded.");
|
|
186912
187334
|
const read5 = parseStudioFile(studioName(held5.id), held5.files["STUDIO.md"] ?? "", "STUDIO.md");
|
|
186913
187335
|
if ("problem" in read5) throw new Error(read5.problem);
|
|
186914
187336
|
return { held: held5, def: read5.def };
|
|
186915
187337
|
}
|
|
187338
|
+
function taskStudioSkills(ws) {
|
|
187339
|
+
const studio2 = taskStudio(ws);
|
|
187340
|
+
return studio2 ? cachedStudioSkillBlock(studio2.held) : "";
|
|
187341
|
+
}
|
|
186916
187342
|
var taskStudioPreviews = (ws) => taskStudio(ws)?.def.previews;
|
|
186917
187343
|
var taskConfig = (ws, id2, setup) => studioConfigContext(id2, setup, (file2) => readText(path60.join(ws.board, file2)) ?? void 0);
|
|
186918
187344
|
function taskSetupContext(ws) {
|
|
@@ -186969,6 +187395,8 @@ function syncRefusal(job, failure2) {
|
|
|
186969
187395
|
return zh ? "\u6BCF\u65E5\u5199\u5165\u989D\u5EA6\u4E8E UTC \u96F6\u70B9\u6062\u590D\u3002" : "The daily write allowance resets at midnight UTC.";
|
|
186970
187396
|
case "bad_request":
|
|
186971
187397
|
return failure2.failure?.source === "validation" ? failure2.error : zh ? "\u8BF7\u68C0\u67E5\u5361\u7247\u5185\u5BB9\u548C\u9884\u89C8\u9644\u4EF6\u3002" : "Check the card and its preview attachments.";
|
|
187398
|
+
case "review_outdated":
|
|
187399
|
+
return job.chat ? zh ? "\u4FDD\u5B58\u671F\u95F4\u9884\u89C8\u5DF2\u88AB\u518D\u6B21\u4FEE\u8BA2\u3002\u8BF7\u5F00\u542F\u4E00\u8F6E\u65B0\u56DE\u590D\u3002" : "The Preview was revised while this reply was saving. Start a new reply." : failure2.error;
|
|
186972
187400
|
case "board_content_conflict":
|
|
186973
187401
|
case "version_conflict":
|
|
186974
187402
|
return zh ? "\u8BF7\u5904\u7406\u770B\u677F\u540C\u6B65\u51B2\u7A81\u3002" : "Resolve the board sync conflict.";
|
|
@@ -187009,7 +187437,7 @@ function sourceOf(pins, source2, owner2) {
|
|
|
187009
187437
|
async function stageSavedPreviews(directory3, ws, review, inputs, stopped2) {
|
|
187010
187438
|
const sections = [];
|
|
187011
187439
|
const contexts = /* @__PURE__ */ new Set();
|
|
187012
|
-
const
|
|
187440
|
+
const invalid2 = (name) => {
|
|
187013
187441
|
const error62 = `Missing or invalid saved review evidence: ${name}`;
|
|
187014
187442
|
return { ok: false, code: "bad_request", error: error62, failure: makeFailure("validation", error62) };
|
|
187015
187443
|
};
|
|
@@ -187033,7 +187461,7 @@ async function stageSavedPreviews(directory3, ws, review, inputs, stopped2) {
|
|
|
187033
187461
|
};
|
|
187034
187462
|
if (error62 || status === "pending" || status === "failed" || typeof artifact !== "string" || !artifactId.test(artifact) || typeof version2 !== "number" || !Number.isSafeInteger(version2) || version2 < 1) {
|
|
187035
187463
|
const missingEvidence = review.plan?.length && types.length && !local2 && (error62 || status === "pending" || status === "failed" || !artifact);
|
|
187036
|
-
if (conflicting.has(source2) || missingEvidence) return
|
|
187464
|
+
if (conflicting.has(source2) || missingEvidence) return invalid2(`${title} \xB7 ${source2}`);
|
|
187037
187465
|
return saved(typeof error62 === "string" ? error62 : artifact ? "Missing approved asset version." : "Missing asset record.");
|
|
187038
187466
|
}
|
|
187039
187467
|
const extension = path61.posix.extname(splitFileReference(source2)[0]).toLowerCase();
|
|
@@ -187042,18 +187470,18 @@ async function stageSavedPreviews(directory3, ws, review, inputs, stopped2) {
|
|
|
187042
187470
|
let kind = types.includes("tiled") ? "tiled" : !extension ? localPin?.kind ?? detected : detected;
|
|
187043
187471
|
const matches = local2 && localPin?.version === version2;
|
|
187044
187472
|
const issue2 = ws.materialIssues?.[source2];
|
|
187045
|
-
const
|
|
187046
|
-
if (!
|
|
187047
|
-
if (["unauthenticated", "forbidden", "unauthorized", "permission_denied"].includes(
|
|
187048
|
-
if (conflicting.has(source2)) return
|
|
187049
|
-
return saved(
|
|
187473
|
+
const bytes = matches ? { ok: true, value: fs59.readFileSync(local2.file) } : issue2 && !conflicting.has(source2) ? { ok: false, error: issue2, code: void 0 } : await readAsset(artifact, version2, kind === "html" ? "html" : void 0);
|
|
187474
|
+
if (!bytes.ok) {
|
|
187475
|
+
if (["unauthenticated", "forbidden", "unauthorized", "permission_denied"].includes(bytes.code ?? "")) return bytes;
|
|
187476
|
+
if (conflicting.has(source2)) return invalid2(`${title} \xB7 ${source2} (version ${version2}): ${bytes.error}`);
|
|
187477
|
+
return saved(bytes.error);
|
|
187050
187478
|
}
|
|
187051
187479
|
const basename = path61.posix.basename(splitFileReference(source2)[0]).replace(/[^\w. -]/g, "_");
|
|
187052
187480
|
const name = extension ? basename : basename + ({ html: ".html", storyboard: ".json", spritesheet: ".json", studio: ".json" }[kind] ?? "");
|
|
187053
187481
|
const copy2 = path61.join(folder2, `${files.size + 1}-${name.replace(/\.tsx$/i, kind === "html" ? ".html" : ".tsx")}`);
|
|
187054
187482
|
const entry = { file: matches ? local2.file : copy2, note: "" };
|
|
187055
187483
|
files.set(source2, entry);
|
|
187056
|
-
let content =
|
|
187484
|
+
let content = bytes.value;
|
|
187057
187485
|
const knownManifest = fileManifest(kind, source2);
|
|
187058
187486
|
let data = knownManifest?.references || extension === ".json" || !extension && types.length ? Buffer.from(content).toString() : void 0;
|
|
187059
187487
|
if (extension === ".json" || !extension && types.length) {
|
|
@@ -187128,7 +187556,7 @@ ${body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : "
|
|
|
187128
187556
|
const stages = new Map(review.stages.map((stage) => [stage.id, stage]));
|
|
187129
187557
|
for (const node2 of review.plan) {
|
|
187130
187558
|
const stage = stages.get(node2.id);
|
|
187131
|
-
if (!stage || !["approved", "done"].includes(stage.status)) return
|
|
187559
|
+
if (!stage || !["approved", "done"].includes(stage.status)) return invalid2(node2.id);
|
|
187132
187560
|
const snapshot = stage.snapshot;
|
|
187133
187561
|
if (!snapshot && !node2.previews.length) continue;
|
|
187134
187562
|
const evidence = object2(snapshot?.evidence);
|
|
@@ -187146,7 +187574,7 @@ ${body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : "
|
|
|
187146
187574
|
for (const id2 of node2.previews) {
|
|
187147
187575
|
const section = object2(own2(content, id2));
|
|
187148
187576
|
const saved = typeof section.body === "string" ? section.body : blocks.find((block) => block.id === id2)?.instructions;
|
|
187149
|
-
if (!saved?.trim()) return
|
|
187577
|
+
if (!saved?.trim()) return invalid2(`${title} \xB7 ${id2}`);
|
|
187150
187578
|
const legacyPins = object2(frozen.find((preview) => preview.id === id2)?.assets);
|
|
187151
187579
|
add2(`${title} \xB7 ${id2}`, saved, { ...legacyPins, ...pins }, section.sources);
|
|
187152
187580
|
}
|
|
@@ -187203,9 +187631,9 @@ import fs60 from "node:fs";
|
|
|
187203
187631
|
import path62 from "node:path";
|
|
187204
187632
|
|
|
187205
187633
|
// ../cli/src/lib/signals/identity.ts
|
|
187206
|
-
import { createHash as
|
|
187634
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
187207
187635
|
var DERIVED = "derived-";
|
|
187208
|
-
var derivedSourceId = (seed) => `${DERIVED}${
|
|
187636
|
+
var derivedSourceId = (seed) => `${DERIVED}${createHash6("sha256").update(seed).digest("hex").slice(0, 16)}`;
|
|
187209
187637
|
|
|
187210
187638
|
// src/triage.ts
|
|
187211
187639
|
var triageDir = (board) => path62.join(board, "triage");
|
|
@@ -187475,6 +187903,7 @@ function boardAkb(job, ws, deps, io, task) {
|
|
|
187475
187903
|
AI4KANBAN_SYNC_DIAGNOSTIC: io.diagnostic,
|
|
187476
187904
|
AI4KANBAN_REVIEW_STAGES: job.flow?.review_stages ? JSON.stringify(job.flow.review_stages) : void 0,
|
|
187477
187905
|
AI4KANBAN_TASK_REVIEW: job.taskReview ? JSON.stringify(job.taskReview) : void 0,
|
|
187906
|
+
[STUDIO_SNAPSHOT_ENV]: task && ws.studioSnapshot ? JSON.stringify(ws.studioSnapshot) : void 0,
|
|
187478
187907
|
AI4KANBAN_EXECUTION: JSON.stringify({ job: job.id, machine: deps.machineId })
|
|
187479
187908
|
}
|
|
187480
187909
|
});
|
|
@@ -188380,7 +188809,7 @@ function replySpent(checkpoint, runtime) {
|
|
|
188380
188809
|
}
|
|
188381
188810
|
|
|
188382
188811
|
// src/jobs.ts
|
|
188383
|
-
import { createHash as
|
|
188812
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
188384
188813
|
|
|
188385
188814
|
// src/conversation-progress.ts
|
|
188386
188815
|
function conversationProgress(attempt, send3, valid, unconfirmed) {
|
|
@@ -188503,7 +188932,7 @@ import fs65 from "node:fs";
|
|
|
188503
188932
|
import path67 from "node:path";
|
|
188504
188933
|
import os8 from "node:os";
|
|
188505
188934
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
188506
|
-
import { createHash as
|
|
188935
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
188507
188936
|
init_file_limits();
|
|
188508
188937
|
var inside2 = (root2, file2) => {
|
|
188509
188938
|
const p2 = path67.relative(root2, file2);
|
|
@@ -188541,10 +188970,10 @@ function collectReplyImages(parts, cwd) {
|
|
|
188541
188970
|
}));
|
|
188542
188971
|
const image = (p2) => {
|
|
188543
188972
|
const read5 = () => {
|
|
188544
|
-
let
|
|
188973
|
+
let bytes;
|
|
188545
188974
|
if (p2.data !== void 0) {
|
|
188546
188975
|
if (p2.data.length > ASSET_FILE_LIMIT * 4 / 3 + 4 || !/^[A-Za-z0-9+/]*={0,2}$/.test(p2.data)) throw Error();
|
|
188547
|
-
|
|
188976
|
+
bytes = Buffer.from(p2.data, "base64");
|
|
188548
188977
|
} else {
|
|
188549
188978
|
if (!p2.path) throw Error();
|
|
188550
188979
|
const source2 = p2.path.startsWith("file:") ? fileURLToPath4(p2.path) : decodeURIComponent(p2.path);
|
|
@@ -188556,18 +188985,18 @@ function collectReplyImages(parts, cwd) {
|
|
|
188556
188985
|
try {
|
|
188557
188986
|
const stat2 = fs65.fstatSync(fd);
|
|
188558
188987
|
if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) throw Error();
|
|
188559
|
-
|
|
188988
|
+
bytes = fs65.readFileSync(fd);
|
|
188560
188989
|
} finally {
|
|
188561
188990
|
fs65.closeSync(fd);
|
|
188562
188991
|
}
|
|
188563
188992
|
}
|
|
188564
|
-
return
|
|
188993
|
+
return bytes;
|
|
188565
188994
|
};
|
|
188566
188995
|
try {
|
|
188567
|
-
const
|
|
188568
|
-
const mime = imageMime(
|
|
188569
|
-
if (!mime || p2.mime && p2.mime !== mime ||
|
|
188570
|
-
const id2 = `rim_${
|
|
188996
|
+
const bytes = read5();
|
|
188997
|
+
const mime = imageMime(bytes);
|
|
188998
|
+
if (!mime || p2.mime && p2.mime !== mime || bytes.length > ASSET_FILE_LIMIT) throw Error();
|
|
188999
|
+
const id2 = `rim_${createHash7("sha256").update(bytes).digest("hex")}`;
|
|
188571
189000
|
if (!files.has(id2)) files.set(id2, { read: read5, mime });
|
|
188572
189001
|
return { type: "image", id: id2, mime, status: "saved" };
|
|
188573
189002
|
} catch {
|
|
@@ -188619,15 +189048,15 @@ async function saveReplyImages(parts, cwd, upload2) {
|
|
|
188619
189048
|
if (!read5.parts.some((p2) => p2.type === "image")) return void 0;
|
|
188620
189049
|
const saved = /* @__PURE__ */ new Map();
|
|
188621
189050
|
for (const [key, f2] of read5.files) {
|
|
188622
|
-
let
|
|
189051
|
+
let bytes;
|
|
188623
189052
|
try {
|
|
188624
|
-
|
|
188625
|
-
if (`rim_${
|
|
189053
|
+
bytes = f2.read();
|
|
189054
|
+
if (`rim_${createHash7("sha256").update(bytes).digest("hex")}` !== key || imageMime(bytes) !== f2.mime) continue;
|
|
188626
189055
|
} catch {
|
|
188627
189056
|
continue;
|
|
188628
189057
|
}
|
|
188629
189058
|
try {
|
|
188630
|
-
saved.set(key, await upload2(key.slice(4),
|
|
189059
|
+
saved.set(key, await upload2(key.slice(4), bytes, f2.mime));
|
|
188631
189060
|
} catch {
|
|
188632
189061
|
}
|
|
188633
189062
|
}
|
|
@@ -188639,10 +189068,10 @@ async function saveReplyImages(parts, cwd, upload2) {
|
|
|
188639
189068
|
}
|
|
188640
189069
|
|
|
188641
189070
|
// src/reply-input.ts
|
|
188642
|
-
import { createHash as
|
|
189071
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
188643
189072
|
import fs66 from "node:fs";
|
|
188644
189073
|
import path68 from "node:path";
|
|
188645
|
-
var fingerprint = (text4) =>
|
|
189074
|
+
var fingerprint = (text4) => createHash8("sha256").update(text4).digest("hex");
|
|
188646
189075
|
var CARD_CHAT_GUIDE = "Follow `akb guide card-chat`.";
|
|
188647
189076
|
function replyPrompt(input2, turn2) {
|
|
188648
189077
|
const parts = [...turn2.diagnostics];
|
|
@@ -188653,8 +189082,9 @@ function replyPrompt(input2, turn2) {
|
|
|
188653
189082
|
const { task, initialize } = turn2;
|
|
188654
189083
|
if (initialize) {
|
|
188655
189084
|
parts.push(task ? CARD_CHAT_GUIDE : "Follow `akb guide discuss-goal` for this Goal discussion.");
|
|
189085
|
+
if (turn2.skills) parts.push(turn2.skills);
|
|
188656
189086
|
if (task) parts.push(`Task card: ${task.card}`);
|
|
188657
|
-
if (turn2.
|
|
189087
|
+
if (turn2.historyFile) parts.push(`Consult the ${task ? "chat" : "discussion"} history at \`${turn2.historyFile}\` as needed.`);
|
|
188658
189088
|
if (turn2.goals) parts.push(replyGoals(turn2.goals));
|
|
188659
189089
|
}
|
|
188660
189090
|
let context;
|
|
@@ -188680,11 +189110,16 @@ function replyPrompt(input2, turn2) {
|
|
|
188680
189110
|
reviewRevision: task?.review?.revision
|
|
188681
189111
|
};
|
|
188682
189112
|
}
|
|
188683
|
-
function
|
|
189113
|
+
function writeReplyHistory(dir, messages) {
|
|
189114
|
+
const history = typeof messages === "string" ? messages : messages.map(({ role, body, image_names }) => {
|
|
189115
|
+
const pictures2 = image_names?.length ? `[Pictures: ${image_names.join(", ")}]` : "";
|
|
189116
|
+
return `${role === "user" ? "User" : "Agent"}: ${[body, pictures2].filter(Boolean).join("\n\n")}`;
|
|
189117
|
+
}).join("\n\n");
|
|
189118
|
+
if (!history) return;
|
|
188684
189119
|
fs66.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
188685
189120
|
const file2 = path68.join(fs66.mkdtempSync(path68.join(dir, "context-")), "history.md");
|
|
188686
189121
|
fs66.writeFileSync(file2, history + "\n", { mode: 256, flag: "wx" });
|
|
188687
|
-
return
|
|
189122
|
+
return file2;
|
|
188688
189123
|
}
|
|
188689
189124
|
function replyReview(review) {
|
|
188690
189125
|
const starts = new Map(review.approvals?.map((action) => [action.stage, action.starts]));
|
|
@@ -188704,7 +189139,7 @@ function replyGoals(goals) {
|
|
|
188704
189139
|
|
|
188705
189140
|
// src/handoff.ts
|
|
188706
189141
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
188707
|
-
import
|
|
189142
|
+
import crypto6 from "node:crypto";
|
|
188708
189143
|
import fs67 from "node:fs";
|
|
188709
189144
|
import path69 from "node:path";
|
|
188710
189145
|
var gitRead = (cwd, args2) => {
|
|
@@ -188719,7 +189154,7 @@ var gitRead = (cwd, args2) => {
|
|
|
188719
189154
|
return null;
|
|
188720
189155
|
}
|
|
188721
189156
|
};
|
|
188722
|
-
var digest = (value) =>
|
|
189157
|
+
var digest = (value) => crypto6.createHash("sha256").update(value).digest("hex");
|
|
188723
189158
|
function authorizedFolder(folder2) {
|
|
188724
189159
|
if (!folder2) return null;
|
|
188725
189160
|
try {
|
|
@@ -188847,9 +189282,9 @@ import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
|
188847
189282
|
|
|
188848
189283
|
// src/reply-approval.ts
|
|
188849
189284
|
import http from "node:http";
|
|
188850
|
-
import
|
|
189285
|
+
import crypto7 from "node:crypto";
|
|
188851
189286
|
async function replyApprovalBridge(task, number4, approve) {
|
|
188852
|
-
const token =
|
|
189287
|
+
const token = crypto7.randomBytes(32).toString("hex");
|
|
188853
189288
|
let serial = Promise.resolve();
|
|
188854
189289
|
const server = http.createServer((req, res) => {
|
|
188855
189290
|
const answer = (status, body) => {
|
|
@@ -189036,14 +189471,14 @@ import path73 from "node:path";
|
|
|
189036
189471
|
|
|
189037
189472
|
// ../cli/src/lib/goal-draft.ts
|
|
189038
189473
|
import fs71 from "node:fs";
|
|
189039
|
-
import { randomUUID as
|
|
189474
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
189040
189475
|
function readGoalDraft(file2) {
|
|
189041
189476
|
const draft = JSON.parse(fs71.readFileSync(file2, "utf8"));
|
|
189042
189477
|
if (!Array.isArray(draft?.goals)) throw new Error("The goals array is missing or invalid.");
|
|
189043
189478
|
return draft;
|
|
189044
189479
|
}
|
|
189045
189480
|
function writeGoalDraft(file2, draft) {
|
|
189046
|
-
const temporary = `${file2}.${
|
|
189481
|
+
const temporary = `${file2}.${randomUUID6()}.tmp`;
|
|
189047
189482
|
try {
|
|
189048
189483
|
fs71.writeFileSync(temporary, `${JSON.stringify(draft, null, 2)}
|
|
189049
189484
|
`, { mode: 384, flag: "wx" });
|
|
@@ -189607,11 +190042,11 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189607
190042
|
let report2 = before ? { ...before, ...said2 } : said2;
|
|
189608
190043
|
if (reply && checkpoint.replyParts && report2) {
|
|
189609
190044
|
const stream2 = watching();
|
|
189610
|
-
const parts = await saveReplyImages(checkpoint.replyParts.parts, checkpoint.replyParts.cwd, async (key,
|
|
190045
|
+
const parts = await saveReplyImages(checkpoint.replyParts.parts, checkpoint.replyParts.cwd, async (key, bytes, mime) => {
|
|
189611
190046
|
const saved = checkpoint.replyImages?.job === id2 ? checkpoint.replyImages.files[key] : void 0;
|
|
189612
190047
|
if (saved) return saved;
|
|
189613
190048
|
if (outcome !== "done" || report2?.stopped || checkpoint.syncFailure || stream2.asked() || stream2.lost()) return { status: "not_saved" };
|
|
189614
|
-
const uploaded = await sync(`reply-image:${key}`, () => deps.api.uploadReplyImage(deps.machineId, id2, key,
|
|
190049
|
+
const uploaded = await sync(`reply-image:${key}`, () => deps.api.uploadReplyImage(deps.machineId, id2, key, bytes, mime));
|
|
189615
190050
|
if (!uploaded.ok) return { status: "not_saved" };
|
|
189616
190051
|
if (checkpoint.replyImages?.job !== id2) checkpoint.replyImages = { job: id2, files: {} };
|
|
189617
190052
|
checkpoint.replyImages.files[key] = uploaded.value;
|
|
@@ -189624,7 +190059,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189624
190059
|
}
|
|
189625
190060
|
if (outcome === "failed" && checkpoint.syncFailure) {
|
|
189626
190061
|
const { failure: failure3, pause, safe: safe3 } = checkpoint.syncFailure;
|
|
189627
|
-
const recovery2 = reply && safe3 && (checkpoint.completed?.outcome === "done" || checkpoint.ending) ? { safe: false, resumable: true, stopped: true } : reply && safe3 ? replyRecovery(job, checkpoint, true) : void 0;
|
|
190062
|
+
const recovery2 = report2?.recovery ?? (reply && safe3 && (checkpoint.completed?.outcome === "done" || checkpoint.ending) ? { safe: false, resumable: true, stopped: true } : reply && safe3 ? replyRecovery(job, checkpoint, true) : void 0);
|
|
189628
190063
|
report2 = { ...report2, failure: buildFailureDetail(failure3, pause, safe3), ...recovery2 ? { recovery: recovery2 } : {} };
|
|
189629
190064
|
if (pause === "limit" && job.flow) reason = "task_retry_exhausted: " + failure3.summary;
|
|
189630
190065
|
else reason = failure3.summary;
|
|
@@ -190147,11 +190582,13 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
190147
190582
|
const stream2 = watching();
|
|
190148
190583
|
return sendBack(publishingJob, deps, ws, completed, sync, stream2, finishClaimed, landed, async (pushed) => {
|
|
190149
190584
|
const records = pushed.conflict ? pendingConflicts(ws.board) : [];
|
|
190150
|
-
const facts =
|
|
190585
|
+
const facts = createHash9("sha256").update(JSON.stringify(pushed.conflict ? records.map((r2) => ({ id: r2.id, state: r2.state, files: r2.files })) : pushed.failure)).digest("hex");
|
|
190151
190586
|
const failRepair = async (reason) => {
|
|
190152
190587
|
if (!stream2.asked()) stream2.event({ kind: "error", data: { text: reason } });
|
|
190153
190588
|
await stream2.end();
|
|
190154
|
-
if (
|
|
190589
|
+
if (stream2.lost()) return;
|
|
190590
|
+
if (stream2.asked()) return finishClaimed("stopped", "", completed);
|
|
190591
|
+
return finishClaimed("failed", reason, writebackRecovery(job, completed));
|
|
190155
190592
|
};
|
|
190156
190593
|
if (pushed.conflict && !records.length) {
|
|
190157
190594
|
console.error(JSON.stringify({ code: "board_conflict_missing", phase: "publish-result", job: id2, task: job.task, project: job.project }));
|
|
@@ -190243,6 +190680,13 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190243
190680
|
}
|
|
190244
190681
|
} else if (task) {
|
|
190245
190682
|
ws = openTaskFolder({ ...job, task }, folder2?.cwd ?? null);
|
|
190683
|
+
const sessionStudio = job.resume && !job.fork ? readStudioSession(task, job.resume) : null;
|
|
190684
|
+
ws.studioSnapshot = checkpoint.studioSnapshot ?? sessionStudio ?? (priorExecution || job.flow?.resume || job.resume && !job.fork ? readPin(task) ?? void 0 : void 0);
|
|
190685
|
+
ws.bindStudio = (snapshot) => {
|
|
190686
|
+
if (checkpoint.studioSnapshot?.studio === snapshot.studio && checkpoint.studioSnapshot.version === snapshot.version) return;
|
|
190687
|
+
checkpoint.studioSnapshot = snapshot;
|
|
190688
|
+
persist();
|
|
190689
|
+
};
|
|
190246
190690
|
cwd = ws.cwd;
|
|
190247
190691
|
keep2(cwd);
|
|
190248
190692
|
if (usesBoardRun(job, checkpoint) && !verification && !await recoverBoard(ws)) {
|
|
@@ -190312,7 +190756,7 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190312
190756
|
const conflicts = ws && (!checkpoint.boardContinuation || checkpoint.boardContinuation.validation) ? conflictPrompt(ws.board) : "";
|
|
190313
190757
|
const recoveringTurn = recovering && !checkpoint.boardContinuation && !replay && (!forkSource || checkpoint.submitted === true) && (checkpoint.started || job.recoveryOf);
|
|
190314
190758
|
const recovery2 = pendingRetry ? retryContinuePrompt(pendingRetry.failure, checkpoint.retry?.attempt, pendingRetry.of) : recoveryPrompt;
|
|
190315
|
-
const planned = (resume, fork) => {
|
|
190759
|
+
const planned = async (resume, fork) => {
|
|
190316
190760
|
let prompt;
|
|
190317
190761
|
let images;
|
|
190318
190762
|
let discussionImages;
|
|
@@ -190326,13 +190770,23 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190326
190770
|
delete checkpoint.replyReviewRevision;
|
|
190327
190771
|
delete checkpoint.replyContext;
|
|
190328
190772
|
}
|
|
190773
|
+
let historyFile;
|
|
190774
|
+
if (initialize && fresh) {
|
|
190775
|
+
let history = replyInput.history ?? "";
|
|
190776
|
+
if (replyInput.historyOnDemand) {
|
|
190777
|
+
const read5 = await sync("reply-history", () => deps.api.readReplyHistory(deps.machineId, id2));
|
|
190778
|
+
if (!read5.ok) throw new Error(syncRefusal(job, read5));
|
|
190779
|
+
history = read5.value.messages;
|
|
190780
|
+
}
|
|
190781
|
+
historyFile = writeReplyHistory(attachmentsOf(job), history);
|
|
190782
|
+
}
|
|
190329
190783
|
const discussion = job.discussion;
|
|
190330
190784
|
const assembled = replyPrompt(replyInput, {
|
|
190331
190785
|
initialize,
|
|
190332
|
-
|
|
190333
|
-
|
|
190786
|
+
historyFile,
|
|
190787
|
+
skills: !continuing && fresh && ws && job.chat ? taskStudioSkills(ws) : "",
|
|
190334
190788
|
...ws && job.chat ? { task: { card: cardFile3(ws), review: job.taskReview, setup: continuing ? null : taskSetupContext(ws) } } : {},
|
|
190335
|
-
goals: discussion && (discussion.goals.length ||
|
|
190789
|
+
goals: discussion && (discussion.goals.length || historyFile || replay || job.sessionFallback || job.resume) ? discussion.goals : void 0,
|
|
190336
190790
|
diagnostics: [syncDiagnostic, conflicts],
|
|
190337
190791
|
attachments: attachments.text.trimStart(),
|
|
190338
190792
|
continuation: continuing ? recovery2 : void 0
|
|
@@ -190349,7 +190803,7 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190349
190803
|
|
|
190350
190804
|
This task came out of a discussion. Read it for what the card leaves out: ${file2}` : "";
|
|
190351
190805
|
const previews = ws && !job.agent && job.taskReview?.preview_definitions?.length ? taskStudioPreviews(ws) : void 0;
|
|
190352
|
-
const head2 = (syncDiagnostic ? syncDiagnostic + "\n\n" : "") + (job.taskReview ? reviewBoundary(job.taskReview, void 0, previews) + "\n\n" : "") + folderLines(job.agent ? null : ws) + (conflicts ? "\n\n" + conflicts : "") + (ws && !job.agent ? "\n\n" + taskStudioContext(ws, !job.resume, deps.akb.canonicalCommands === true) : "");
|
|
190806
|
+
const head2 = (syncDiagnostic ? syncDiagnostic + "\n\n" : "") + (job.taskReview ? reviewBoundary(job.taskReview, void 0, previews) + "\n\n" : "") + folderLines(job.agent ? null : ws) + (conflicts ? "\n\n" + conflicts : "") + (ws && !job.agent ? "\n\n" + taskStudioContext(ws, !job.resume, deps.akb.canonicalCommands === true) : "") + (ws && !job.agent && (!resume || fork) ? "\n\n" + taskStudioSkills(ws) : "");
|
|
190353
190807
|
const submitted = recoveringTurn && checkpoint.submitted === true;
|
|
190354
190808
|
const body = recoveringTurn ? [submitted ? "" : job.prompt, recovery2].filter(Boolean).join("\n\n") : job.prompt;
|
|
190355
190809
|
const withHead = (text4) => text4.trim() ? `${text4.trim()}
|
|
@@ -190368,7 +190822,7 @@ ${body}` : body;
|
|
|
190368
190822
|
if (ws) p2 = { ...p2, env: akbEnv(deps.akb, ws.board, ws.cloudTask ?? void 0, cloudLanguage(job), p2.env) };
|
|
190369
190823
|
if (scope.bridge) p2 = { ...p2, env: { ...p2.env, AI4KANBAN_REPLY_APPROVAL: scope.bridge.env } };
|
|
190370
190824
|
if (goalFile) p2 = { ...p2, env: { ...akbEnv(deps.akb, discussed, void 0, cloudLanguage(job), p2.env), KANBAN_GOALS: goalFile } };
|
|
190371
|
-
const env2 = { ...p2.env, AI4KANBAN_EXECUTION: JSON.stringify({ job: job.id, machine: deps.machineId }), AI4KANBAN_TASK: job.task ?? "" };
|
|
190825
|
+
const env2 = { ...p2.env, AI4KANBAN_EXECUTION: JSON.stringify({ job: job.id, machine: deps.machineId }), AI4KANBAN_TASK: job.task ?? "", [STUDIO_SNAPSHOT_ENV]: ws?.studioSnapshot && JSON.stringify(ws.studioSnapshot) };
|
|
190372
190826
|
const fallback = p2.fallback;
|
|
190373
190827
|
return { ...p2, env: env2, fallback: fallback && (() => configure(fallback())) };
|
|
190374
190828
|
};
|
|
@@ -190377,13 +190831,13 @@ ${body}` : body;
|
|
|
190377
190831
|
let carried = !!job.resume && (!job.fork || forks(job.runtime));
|
|
190378
190832
|
if (!carried && checkpoint.boardContinuation?.report.deliveryCompleted) throw Error("The original delivery session is unavailable. Saved work was preserved.");
|
|
190379
190833
|
try {
|
|
190380
|
-
run3 = carried ? planned(job.resume, !!job.fork) : planned(null, false);
|
|
190834
|
+
run3 = carried ? await planned(job.resume, !!job.fork) : await planned(null, false);
|
|
190381
190835
|
} catch (error62) {
|
|
190382
190836
|
if (!replyInput || !carried || !replayable(checkpoint) || !(error62 instanceof ExecutionError) || !isSessionMissingFailure(error62.failure)) throw error62;
|
|
190383
190837
|
carried = false;
|
|
190384
190838
|
delete checkpoint.session;
|
|
190385
190839
|
delete checkpoint.forkSource;
|
|
190386
|
-
const replayed = await recover(error62.failure, async () => ({ ok: true, value: planned(null, false) }));
|
|
190840
|
+
const replayed = await recover(error62.failure, async () => ({ ok: true, value: await planned(null, false) }));
|
|
190387
190841
|
if (!replayed.ok) throw new Error(replayed.error);
|
|
190388
190842
|
run3 = replayed.value;
|
|
190389
190843
|
}
|
|
@@ -190484,6 +190938,12 @@ ${body}` : body;
|
|
|
190484
190938
|
const progressValid = () => !stream.asked() && !stream.lost() && readSession()?.subject === account && accountGeneration() === generation;
|
|
190485
190939
|
const subagents = trackSubagents();
|
|
190486
190940
|
let idleWatch;
|
|
190941
|
+
let boundSession;
|
|
190942
|
+
const bindStudioSession = (session) => {
|
|
190943
|
+
if (!session || session === boundSession || !ws?.cloudTask || !ws.studioSnapshot) return;
|
|
190944
|
+
saveStudioSession(ws.cloudTask, session, ws.studioSnapshot);
|
|
190945
|
+
boundSession = session;
|
|
190946
|
+
};
|
|
190487
190947
|
const remember = (event2) => {
|
|
190488
190948
|
idleWatch?.event(event2);
|
|
190489
190949
|
if (stream.lost()) return;
|
|
@@ -190502,7 +190962,10 @@ ${body}` : body;
|
|
|
190502
190962
|
checkpoint.partialReply = messages.join("\n\n");
|
|
190503
190963
|
}
|
|
190504
190964
|
const session = run3?.session();
|
|
190505
|
-
if (session && (!job.fork || session !== forkSource))
|
|
190965
|
+
if (session && (!job.fork || session !== forkSource)) {
|
|
190966
|
+
checkpoint.session = session;
|
|
190967
|
+
bindStudioSession(session);
|
|
190968
|
+
}
|
|
190506
190969
|
if (attempt && !run3?.converse) measure(report(job, run3));
|
|
190507
190970
|
persist();
|
|
190508
190971
|
stream.event(event2);
|
|
@@ -190541,6 +191004,7 @@ ${body}` : body;
|
|
|
190541
191004
|
if (outcome === "failed" && stream.lost()) return;
|
|
190542
191005
|
checkpoint.completed = { outcome, report: report2, reason };
|
|
190543
191006
|
checkpoint.session = report2.session ?? checkpoint.session;
|
|
191007
|
+
bindStudioSession(report2.session);
|
|
190544
191008
|
persist();
|
|
190545
191009
|
};
|
|
190546
191010
|
const told = (report2) => {
|
|
@@ -191012,11 +191476,17 @@ var held4 = (deps, lease) => {
|
|
|
191012
191476
|
if (Math.max(Date.now() - lease.at, performance.now() - lease.monotonic) >= deps.leaseMs) lease.lost = true;
|
|
191013
191477
|
return !lease.lost;
|
|
191014
191478
|
};
|
|
191479
|
+
function writebackRecovery(job, report2) {
|
|
191480
|
+
return job.chat && !job.flow ? { ...report2, recovery: { safe: false, stopped: true, resumable: true, writeback: true } } : report2;
|
|
191481
|
+
}
|
|
191015
191482
|
async function sendBack(job, deps, ws, report2, sync, stream, finish, landed, repair, confirm) {
|
|
191016
191483
|
const closesTask = job.flow && !report2.review && (report2.deliveryCompleted ?? (job.flow.verb === "implement" || job.flow.verb === "create" && job.flow.skip_plan));
|
|
191484
|
+
const taskReply = job.chat && !job.flow;
|
|
191017
191485
|
const result = await sync("publish", async () => {
|
|
191018
191486
|
const pushed2 = await push(ws, { id: job.id, machineId: deps.machineId }, () => stream.asked() || stream.lost());
|
|
191019
|
-
if (pushed2.ok && closesTask && !taskAssetsSynced(ws))
|
|
191487
|
+
if (pushed2.ok && (taskReply || closesTask) && !taskAssetsSynced(ws)) {
|
|
191488
|
+
return { ok: false, code: "service_unavailable", error: "Preview uploads are pending." };
|
|
191489
|
+
}
|
|
191020
191490
|
if (!pushed2.ok && writeBlock(pushed2)) return pushed2;
|
|
191021
191491
|
return !pushed2.ok && pushed2.offline ? { ok: false, error: pushed2.error, code: "service_unavailable" } : { ok: true, value: pushed2 };
|
|
191022
191492
|
});
|
|
@@ -191035,10 +191505,15 @@ async function sendBack(job, deps, ws, report2, sync, stream, finish, landed, re
|
|
|
191035
191505
|
if (stream.asked()) return finish("stopped", "", report2);
|
|
191036
191506
|
if (denied) {
|
|
191037
191507
|
console.error("runner: task sync refused", { job: job.id, code: denied.code, error: denied.error });
|
|
191038
|
-
return finish("failed", syncRefusal(job, denied), report2);
|
|
191508
|
+
return finish("failed", syncRefusal(job, denied), writebackRecovery(job, report2));
|
|
191039
191509
|
}
|
|
191040
191510
|
const archive = closesTask && report2.deliveryId ? syncedArchive(ws) : void 0;
|
|
191041
|
-
return finish("done", "", {
|
|
191511
|
+
return finish("done", "", {
|
|
191512
|
+
...report2,
|
|
191513
|
+
...taskReply ? { replyWriteSynced: true } : {},
|
|
191514
|
+
...archive ? { archive } : {},
|
|
191515
|
+
...readCheckpoint(job.id)?.approvalRequested ? { replyApprovalSynced: report2.replyApprovalSynced !== false && taskAssetsSynced(ws) } : {}
|
|
191516
|
+
}, landed);
|
|
191042
191517
|
}
|
|
191043
191518
|
var settingsOf = (job) => ({ settings: job.settings, secrets: secretsOf(job.runtimeId) });
|
|
191044
191519
|
async function runSecret(job, deps) {
|
|
@@ -191157,6 +191632,7 @@ ${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
|
|
|
191157
191632
|
}
|
|
191158
191633
|
|
|
191159
191634
|
// src/flow-worker.ts
|
|
191635
|
+
var CLAIM_BACKOFF_MS = [1e3, 2e3, 5e3, 1e4, 3e4];
|
|
191160
191636
|
var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
|
|
191161
191637
|
var directory2 = () => path75.join(runnerHome(), "flow-workers");
|
|
191162
191638
|
var fileOf3 = (id2) => path75.join(directory2(), `${encodeURIComponent(id2)}.json`);
|
|
@@ -191218,10 +191694,10 @@ async function reclaimFlowWorkerAfterExit(id2, machine, given, token) {
|
|
|
191218
191694
|
}
|
|
191219
191695
|
}
|
|
191220
191696
|
var reclaiming;
|
|
191221
|
-
async function reclaimFlowWorkers(machine, given, only) {
|
|
191697
|
+
async function reclaimFlowWorkers(machine, given, only, retryWaiting = false) {
|
|
191222
191698
|
if (reclaiming) {
|
|
191223
191699
|
await reclaiming;
|
|
191224
|
-
if (only) return reclaimFlowWorkers(machine, given, only);
|
|
191700
|
+
if (only) return reclaimFlowWorkers(machine, given, only, retryWaiting);
|
|
191225
191701
|
return;
|
|
191226
191702
|
}
|
|
191227
191703
|
const account = readSession()?.subject;
|
|
@@ -191241,7 +191717,7 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191241
191717
|
const file2 = path75.join(directory2(), name);
|
|
191242
191718
|
const original = fs74.readFileSync(file2, "utf8");
|
|
191243
191719
|
const worker = JSON.parse(original);
|
|
191244
|
-
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;
|
|
191720
|
+
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) || worker.claimAttempt !== void 0 && (!Number.isSafeInteger(worker.claimAttempt) || worker.claimAttempt < 1) || worker.claimRetryAt !== void 0 && !Number.isFinite(worker.claimRetryAt)) continue;
|
|
191245
191721
|
if (!writerStopped(worker)) {
|
|
191246
191722
|
if (!only) void reclaimFlowWorkerAfterExit(worker.id, machine, given);
|
|
191247
191723
|
continue;
|
|
@@ -191256,10 +191732,18 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191256
191732
|
if (!valid()) break;
|
|
191257
191733
|
if (!remote3.ok || remote3.value.job.id !== worker.id || !canKeepFlow(remote3.value.job)) continue;
|
|
191258
191734
|
const job = remote3.value.job;
|
|
191735
|
+
const checkpoint = job.state === "finished" ? null : readCheckpoint(worker.id);
|
|
191736
|
+
const updating = checkpoint?.updating && !checkpoint.pending.includes("unknown");
|
|
191737
|
+
const failedClaim = worker.ended && (worker.claimFailure || worker.claimAttempt === void 0 && !checkpoint && "Previous claim result was not recorded.");
|
|
191738
|
+
const attempt = worker.claimAttempt ?? 1;
|
|
191739
|
+
const retry2 = worker.generation === generation && job.state === "waiting" && (!checkpoint || updating) && failedClaim ? {
|
|
191740
|
+
attempt,
|
|
191741
|
+
at: worker.claimRetryAt ?? Date.now() + CLAIM_BACKOFF_MS[Math.min(attempt - 1, CLAIM_BACKOFF_MS.length - 1)],
|
|
191742
|
+
failure: failedClaim
|
|
191743
|
+
} : void 0;
|
|
191259
191744
|
if (worker.generation === generation && (job.state === "claimed" || job.state === "interrupted")) {
|
|
191260
191745
|
const runner = await readRunner();
|
|
191261
191746
|
if (!runner.ok || runner.value.runner?.machineId && runner.value.runner.machineId !== machine || !valid()) continue;
|
|
191262
|
-
const checkpoint = readCheckpoint(worker.id);
|
|
191263
191747
|
const deps = given ?? defaultDeps(machine);
|
|
191264
191748
|
const folder2 = job.projectDir ? folderFor(job) : null;
|
|
191265
191749
|
if (folder2 && "refused" in folder2) continue;
|
|
@@ -191270,10 +191754,12 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191270
191754
|
checkpoint.flowRun = evidence.run;
|
|
191271
191755
|
stopped2 = evidence.stopped;
|
|
191272
191756
|
}
|
|
191273
|
-
if (!valid() || !writerStopped(worker)) continue;
|
|
191274
|
-
const
|
|
191757
|
+
if (!valid() || !writerStopped(worker) || worker.claimFailure && !stopped2 || fs74.readFileSync(file2, "utf8") !== original) continue;
|
|
191758
|
+
const beforeExecution = worker.claimFailure && worker.ended ? { pending: [], started: false } : null;
|
|
191759
|
+
if (beforeExecution) console.info("runner: recovering after a failed job claim", { job: worker.id, attempt, reason: worker.claimFailure });
|
|
191760
|
+
const recovered = await recoverInterruptedJob(machine, job, checkpoint ?? beforeExecution, stopped2, valid);
|
|
191275
191761
|
if (!recovered?.resumed && !recovered?.finished) continue;
|
|
191276
|
-
} else if (job.state !== "finished" && !(job.state === "waiting" &&
|
|
191762
|
+
} else if (job.state !== "finished" && !retry2 && !(job.state === "waiting" && updating)) continue;
|
|
191277
191763
|
if (!worker.markedAt) {
|
|
191278
191764
|
const job2 = remote3.value.job;
|
|
191279
191765
|
const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path75.join(runnerHome(), "work", job2.id) };
|
|
@@ -191294,14 +191780,24 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191294
191780
|
job2,
|
|
191295
191781
|
{ ...deps, machineId: machine, akb: deps.akb() }
|
|
191296
191782
|
)) continue;
|
|
191297
|
-
const
|
|
191298
|
-
if (
|
|
191783
|
+
const saved = readCheckpoint(worker.id);
|
|
191784
|
+
if (saved && (!saved.mark || !processesStopped(saved.mark, saved.process))) continue;
|
|
191299
191785
|
}
|
|
191300
191786
|
if (!writerStopped(worker) || !valid() || fs74.readFileSync(file2, "utf8") !== original) continue;
|
|
191787
|
+
if (retry2 && (worker.claimRetryAt === void 0 || !retryWaiting || retry2.at > Date.now())) {
|
|
191788
|
+
if (worker.claimRetryAt === void 0) {
|
|
191789
|
+
await renewJob(machine, worker.id, { taskRecovery: { code: "claim", attempt: retry2.attempt } });
|
|
191790
|
+
if (!valid() || fs74.readFileSync(file2, "utf8") !== original) continue;
|
|
191791
|
+
save2({ ...worker, claimRetryAt: retry2.at });
|
|
191792
|
+
}
|
|
191793
|
+
if (retryWaiting) return retry2;
|
|
191794
|
+
continue;
|
|
191795
|
+
}
|
|
191301
191796
|
fs74.rmSync(`${file2}.log`, { force: true });
|
|
191302
191797
|
fs74.rmSync(`${file2}.stop`, { force: true });
|
|
191303
191798
|
fs74.unlinkSync(file2);
|
|
191304
191799
|
if (job.state === "finished" && job.outcome === "done") clearCheckpoint(job.id);
|
|
191800
|
+
if (retry2) return retry2;
|
|
191305
191801
|
} finally {
|
|
191306
191802
|
release2();
|
|
191307
191803
|
}
|
|
@@ -191312,7 +191808,7 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191312
191808
|
reclaiming = sweep().finally(() => {
|
|
191313
191809
|
reclaiming = void 0;
|
|
191314
191810
|
});
|
|
191315
|
-
|
|
191811
|
+
return reclaiming;
|
|
191316
191812
|
}
|
|
191317
191813
|
async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
|
|
191318
191814
|
const worker = read4(id2);
|
|
@@ -191343,7 +191839,19 @@ async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
|
|
|
191343
191839
|
}, 100);
|
|
191344
191840
|
try {
|
|
191345
191841
|
const base = given ?? defaultDeps(worker.machine);
|
|
191346
|
-
const deps = { ...base, api: { ...base.api,
|
|
191842
|
+
const deps = { ...base, api: { ...base.api, claimJob: async (...args2) => {
|
|
191843
|
+
let claim2 = await base.api.claimJob(...args2);
|
|
191844
|
+
if (claim2.ok && claim2.value?.claimed !== false && (claim2.value?.claimed !== true || claim2.value.job?.id !== id2)) {
|
|
191845
|
+
const invalid2 = invalidResponse("a claim for this job");
|
|
191846
|
+
claim2 = { ok: false, code: invalid2.code, error: invalid2.message };
|
|
191847
|
+
}
|
|
191848
|
+
const failure2 = !claim2.ok ? [claim2.code, claim2.status, claim2.error].filter(Boolean).join(" ") : claim2.value.claimed === false ? claim2.value.reason || "Cloud did not grant a lease." : void 0;
|
|
191849
|
+
if (failure2) {
|
|
191850
|
+
worker.claimFailure = failure2;
|
|
191851
|
+
console.warn("runner: job claim failed", { job: id2, attempt: worker.claimAttempt ?? 1, reason: failure2 });
|
|
191852
|
+
}
|
|
191853
|
+
return claim2;
|
|
191854
|
+
}, renewJob: async (...args2) => {
|
|
191347
191855
|
const runner = await readRunner();
|
|
191348
191856
|
if (runner.ok && runner.value.runner?.machineId && runner.value.runner.machineId !== worker.machine) {
|
|
191349
191857
|
return { ok: true, value: { renewed: false } };
|