wildcrane-runner 0.6.116 → 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 +13662 -13226
- 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 +1442 -953
- package/dist/launcher.mjs +533 -422
- package/dist/plugin.mjs +38805 -38692
- package/dist/runner.mjs +1614 -1097
- package/dist/settings.mjs +627 -514
- 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;
|
|
@@ -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)
|
|
@@ -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";
|
|
@@ -152581,34 +152601,673 @@ __export(api_exports, {
|
|
|
152581
152601
|
uploadReplyImage: () => uploadReplyImage
|
|
152582
152602
|
});
|
|
152583
152603
|
|
|
152584
|
-
// ../cli/src/lib/shared/
|
|
152585
|
-
|
|
152586
|
-
|
|
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;
|
|
152587
152690
|
}
|
|
152588
152691
|
|
|
152589
|
-
// ../cli/src/lib/
|
|
152590
|
-
var
|
|
152591
|
-
|
|
152592
|
-
|
|
152593
|
-
|
|
152594
|
-
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") };
|
|
152595
152697
|
}
|
|
152596
|
-
|
|
152597
|
-
|
|
152598
|
-
|
|
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);
|
|
152599
152727
|
}
|
|
152600
|
-
function
|
|
152601
|
-
|
|
152602
|
-
|
|
152603
|
-
|
|
152604
|
-
const
|
|
152605
|
-
const
|
|
152606
|
-
|
|
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)}`;
|
|
152607
153266
|
}
|
|
152608
153267
|
|
|
152609
153268
|
// src/protocol.ts
|
|
152610
|
-
var AKB_VERSION = true ? "0.11.
|
|
152611
|
-
var AKB_CONTRACT = true ?
|
|
153269
|
+
var AKB_VERSION = true ? "0.11.99" : "0.0.0";
|
|
153270
|
+
var AKB_CONTRACT = true ? 33 : 0;
|
|
152612
153271
|
|
|
152613
153272
|
// src/secrets.ts
|
|
152614
153273
|
import fs20 from "node:fs";
|
|
@@ -153171,12 +153830,12 @@ function mergeRetryHistory(...histories) {
|
|
|
153171
153830
|
return [...new Map(records.map((record2) => [JSON.stringify(record2), record2])).values()].sort((a2, b2) => a2.at.localeCompare(b2.at));
|
|
153172
153831
|
}
|
|
153173
153832
|
async function waitForRetry(at2, stopped2) {
|
|
153174
|
-
const
|
|
153175
|
-
if (!
|
|
153833
|
+
const delay4 = Math.max(0, at2 - Date.now());
|
|
153834
|
+
if (!delay4) return;
|
|
153176
153835
|
let timer;
|
|
153177
153836
|
try {
|
|
153178
153837
|
await Promise.race([new Promise((resolve2) => {
|
|
153179
|
-
timer = setTimeout(resolve2,
|
|
153838
|
+
timer = setTimeout(resolve2, delay4);
|
|
153180
153839
|
}), ...stopped2 ? [stopped2] : []]);
|
|
153181
153840
|
} finally {
|
|
153182
153841
|
clearTimeout(timer);
|
|
@@ -153247,10 +153906,10 @@ function planRetry(failure2, attempt, now = Date.now(), backoff = backoffMs, tas
|
|
|
153247
153906
|
return { pause: "authorization" };
|
|
153248
153907
|
}
|
|
153249
153908
|
if (attempt > of) return { pause: "limit" };
|
|
153250
|
-
const
|
|
153251
|
-
const valid =
|
|
153909
|
+
const delay4 = failure2.retryAfterMs;
|
|
153910
|
+
const valid = delay4 !== void 0 && !Number.isNaN(delay4) && delay4 >= 0;
|
|
153252
153911
|
const immediate = failure2.source === "validation";
|
|
153253
|
-
const wait3 = valid ?
|
|
153912
|
+
const wait3 = valid ? delay4 : immediate ? 0 : backoff(attempt + 1);
|
|
153254
153913
|
const cap = task && failure2.code === "rate_limited" && valid ? 24 * 60 * 6e4 : CAP_MS;
|
|
153255
153914
|
if (wait3 > cap) return { pause: "wait_too_long" };
|
|
153256
153915
|
return { plan: { at: now + wait3, of, failure: failure2 } };
|
|
@@ -153490,12 +154149,12 @@ function bounded(work, ms, reason) {
|
|
|
153490
154149
|
}
|
|
153491
154150
|
|
|
153492
154151
|
// ../cli/src/lib/shared/reply-parts.ts
|
|
153493
|
-
function imageMime(
|
|
153494
|
-
const at2 = (...v) => v.every((n, i) =>
|
|
153495
|
-
const text4 = (a2, b2) => String.fromCharCode(...
|
|
153496
|
-
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";
|
|
153497
154156
|
if (at2(255, 216, 255)) return "image/jpeg";
|
|
153498
|
-
if (
|
|
154157
|
+
if (bytes.length >= 13 && ["GIF87a", "GIF89a"].includes(text4(0, 6)) && (bytes[6] || bytes[7]) && (bytes[8] || bytes[9])) return "image/gif";
|
|
153499
154158
|
if (text4(0, 4) === "RIFF" && text4(8, 12) === "WEBP") return "image/webp";
|
|
153500
154159
|
return void 0;
|
|
153501
154160
|
}
|
|
@@ -153820,8 +154479,8 @@ function createTail(log) {
|
|
|
153820
154479
|
// ../cli/package.json
|
|
153821
154480
|
var package_default = {
|
|
153822
154481
|
name: "wildcrane",
|
|
153823
|
-
version: "0.11.
|
|
153824
|
-
akbContract:
|
|
154482
|
+
version: "0.11.99",
|
|
154483
|
+
akbContract: 33,
|
|
153825
154484
|
canonicalCommands: true,
|
|
153826
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.",
|
|
153827
154486
|
keywords: [
|
|
@@ -154114,9 +154773,9 @@ async function oneTurn(io, options) {
|
|
|
154114
154773
|
const images = [];
|
|
154115
154774
|
const files = [];
|
|
154116
154775
|
for (const file2 of io.imageFiles ?? []) {
|
|
154117
|
-
const
|
|
154118
|
-
const mimeType =
|
|
154119
|
-
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") });
|
|
154120
154779
|
else files.push(file2);
|
|
154121
154780
|
}
|
|
154122
154781
|
if (Date.now() >= preparingUntil) throw Error("ACP preparation timed out.");
|
|
@@ -154295,30 +154954,30 @@ import { existsSync } from "node:fs";
|
|
|
154295
154954
|
function antigravityConversationFile(session) {
|
|
154296
154955
|
if (/^[a-f0-9-]{36}$/i.test(session)) return home(".gemini", "antigravity-cli", "conversations", `${session}.db`);
|
|
154297
154956
|
}
|
|
154298
|
-
function varint(
|
|
154957
|
+
function varint(bytes, offset) {
|
|
154299
154958
|
let value = 0;
|
|
154300
|
-
for (let shift = 0; shift < 70 && offset.value <
|
|
154301
|
-
const byte =
|
|
154959
|
+
for (let shift = 0; shift < 70 && offset.value < bytes.length; shift += 7) {
|
|
154960
|
+
const byte = bytes[offset.value++];
|
|
154302
154961
|
value += (byte & 127) * 2 ** shift;
|
|
154303
154962
|
if (byte < 128) return value;
|
|
154304
154963
|
}
|
|
154305
154964
|
throw new Error("Invalid Antigravity conversation metadata");
|
|
154306
154965
|
}
|
|
154307
|
-
function* fields(
|
|
154966
|
+
function* fields(bytes) {
|
|
154308
154967
|
const offset = { value: 0 };
|
|
154309
|
-
while (offset.value <
|
|
154310
|
-
const tag = varint(
|
|
154968
|
+
while (offset.value < bytes.length) {
|
|
154969
|
+
const tag = varint(bytes, offset);
|
|
154311
154970
|
const number4 = Math.floor(tag / 8);
|
|
154312
154971
|
const wire = tag % 8;
|
|
154313
154972
|
if (number4 < 1 || number4 >= 2 ** 29) throw new Error("Invalid Antigravity conversation metadata");
|
|
154314
154973
|
if (wire === 0) {
|
|
154315
|
-
yield [number4, varint(
|
|
154974
|
+
yield [number4, varint(bytes, offset)];
|
|
154316
154975
|
continue;
|
|
154317
154976
|
}
|
|
154318
|
-
const size = wire === 2 ? varint(
|
|
154977
|
+
const size = wire === 2 ? varint(bytes, offset) : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
154319
154978
|
const end2 = offset.value + size;
|
|
154320
|
-
if (size < 0 || end2 >
|
|
154321
|
-
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)];
|
|
154322
154981
|
offset.value = end2;
|
|
154323
154982
|
}
|
|
154324
154983
|
}
|
|
@@ -154350,7 +155009,7 @@ function recordedContextLimit(data) {
|
|
|
154350
155009
|
const limit = varintField(bytesField(bytesField(bytesField(data, 1), 9), 10), 4);
|
|
154351
155010
|
return limit !== void 0 && Number.isSafeInteger(limit) && limit > 0 ? limit : void 0;
|
|
154352
155011
|
}
|
|
154353
|
-
var utf8 = (
|
|
155012
|
+
var utf8 = (bytes) => bytes && Buffer.from(bytes).toString("utf8");
|
|
154354
155013
|
function stepUuid(stepRow, index) {
|
|
154355
155014
|
if (!Number.isSafeInteger(index) || index < 0) return;
|
|
154356
155015
|
const id2 = bytesField(stepRow.get(index)?.metadata, 12);
|
|
@@ -155603,9 +156262,9 @@ function readIndex() {
|
|
|
155603
156262
|
entries.delete(sessionId);
|
|
155604
156263
|
continue;
|
|
155605
156264
|
}
|
|
155606
|
-
const
|
|
156265
|
+
const sessionDir2 = str2(record2.sessionDir).trim();
|
|
155607
156266
|
const workDir = str2(record2.workDir).trim();
|
|
155608
|
-
if (
|
|
156267
|
+
if (sessionDir2 && workDir) entries.set(sessionId, { sessionId, sessionDir: sessionDir2, workDir });
|
|
155609
156268
|
}
|
|
155610
156269
|
return entries;
|
|
155611
156270
|
}
|
|
@@ -155625,13 +156284,13 @@ function findKimiSession(cwd, since) {
|
|
|
155625
156284
|
}
|
|
155626
156285
|
return newest2?.id;
|
|
155627
156286
|
}
|
|
155628
|
-
function wireFiles(
|
|
155629
|
-
const agents = join3(
|
|
156287
|
+
function wireFiles(sessionDir2) {
|
|
156288
|
+
const agents = join3(sessionDir2, "agents");
|
|
155630
156289
|
let names2;
|
|
155631
156290
|
try {
|
|
155632
156291
|
names2 = readdirSync2(agents);
|
|
155633
156292
|
} catch {
|
|
155634
|
-
return [{ path: join3(
|
|
156293
|
+
return [{ path: join3(sessionDir2, "wire.jsonl"), main: true }];
|
|
155635
156294
|
}
|
|
155636
156295
|
const ordered = names2.sort((a2, b2) => Number(b2 === "main") - Number(a2 === "main"));
|
|
155637
156296
|
return ordered.map((name) => ({ path: join3(agents, name, "wire.jsonl"), main: name === "main" }));
|
|
@@ -156211,19 +156870,19 @@ var settle_background_default = "Wait for and collect needed results from this t
|
|
|
156211
156870
|
|
|
156212
156871
|
// ../cli/src/lib/agent/wire/codex-background.ts
|
|
156213
156872
|
var CODEX_SETTLE_MS = { turn: 6e4, verify: 1e4 };
|
|
156214
|
-
function summary(text4,
|
|
156215
|
-
if (Buffer.byteLength(text4) <=
|
|
156216
|
-
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]";
|
|
156217
156876
|
}
|
|
156218
156877
|
function batch(work) {
|
|
156219
156878
|
const result = [];
|
|
156220
|
-
let
|
|
156879
|
+
let bytes = 0;
|
|
156221
156880
|
for (const entry of work) {
|
|
156222
156881
|
const size = Buffer.byteLength(JSON.stringify(entry));
|
|
156223
156882
|
if (size > 15e3) throw Error("A Codex background identifier exceeds the snapshot limit.");
|
|
156224
|
-
if (
|
|
156883
|
+
if (bytes + size > 15e3) break;
|
|
156225
156884
|
result.push(entry);
|
|
156226
|
-
|
|
156885
|
+
bytes += size;
|
|
156227
156886
|
}
|
|
156228
156887
|
return result;
|
|
156229
156888
|
}
|
|
@@ -158426,23 +159085,23 @@ async function request(method, route, body, signedIn = true) {
|
|
|
158426
159085
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
158427
159086
|
}
|
|
158428
159087
|
var FILE_TIMEOUT_MS = 10 * 6e4;
|
|
158429
|
-
async function download(route) {
|
|
158430
|
-
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);
|
|
158431
159090
|
if (!sent.ok) return sent;
|
|
158432
159091
|
if (!sent.value.ok) return answerOf(sent.value);
|
|
158433
159092
|
try {
|
|
158434
|
-
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) };
|
|
158435
159094
|
} catch (e2) {
|
|
158436
159095
|
return { ok: false, error: e2 instanceof Error ? e2.message : String(e2) };
|
|
158437
159096
|
}
|
|
158438
159097
|
}
|
|
158439
|
-
async function upload(route,
|
|
158440
|
-
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);
|
|
158441
159100
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
158442
159101
|
}
|
|
158443
|
-
async function uploadReplyImage(machine, job, key,
|
|
159102
|
+
async function uploadReplyImage(machine, job, key, bytes, mime) {
|
|
158444
159103
|
const route = `/v1/runner/jobs/${encodeURIComponent(job)}/images/${key}?machine=${encodeURIComponent(machine)}`;
|
|
158445
|
-
const sent = await send("PUT", route,
|
|
159104
|
+
const sent = await send("PUT", route, bytes, true, 9e4, mime);
|
|
158446
159105
|
return sent.ok ? answerOf(sent.value) : sent;
|
|
158447
159106
|
}
|
|
158448
159107
|
var register = (r2) => request("POST", "/v1/runner", { ...r2, secrets: secretsSet(), protocol: PROTOCOL, akbContract: AKB_CONTRACT });
|
|
@@ -158553,31 +159212,11 @@ import fs25 from "node:fs";
|
|
|
158553
159212
|
import path26 from "node:path";
|
|
158554
159213
|
|
|
158555
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";
|
|
158556
159217
|
import fs24 from "node:fs";
|
|
158557
159218
|
import path25 from "node:path";
|
|
158558
159219
|
|
|
158559
|
-
// ../cli/src/lib/yaml.ts
|
|
158560
|
-
function yamlScalar(s) {
|
|
158561
|
-
const text4 = String(s);
|
|
158562
|
-
if (text4 === "") return '""';
|
|
158563
|
-
if (/^[-?:,[\]{}#&*!|>'"%@`]/.test(text4) || /:\s/.test(text4) || /[\n"]/.test(text4) || /^\s|\s$/.test(text4)) {
|
|
158564
|
-
return JSON.stringify(text4);
|
|
158565
|
-
}
|
|
158566
|
-
return text4;
|
|
158567
|
-
}
|
|
158568
|
-
function unquote(v) {
|
|
158569
|
-
const text4 = String(v).trim();
|
|
158570
|
-
if (text4.startsWith('"') && text4.endsWith('"')) {
|
|
158571
|
-
try {
|
|
158572
|
-
return JSON.parse(text4);
|
|
158573
|
-
} catch {
|
|
158574
|
-
return text4.slice(1, -1);
|
|
158575
|
-
}
|
|
158576
|
-
}
|
|
158577
|
-
if (text4.startsWith("'") && text4.endsWith("'")) return text4.slice(1, -1);
|
|
158578
|
-
return text4;
|
|
158579
|
-
}
|
|
158580
|
-
|
|
158581
159220
|
// ../cli/src/lib/question-block.ts
|
|
158582
159221
|
var MODES = ["single", "multi"];
|
|
158583
159222
|
var withoutTag = (text4) => text4.replace(/^\[user\]\s+/, "");
|
|
@@ -158864,471 +159503,49 @@ function cardFront(body) {
|
|
|
158864
159503
|
}
|
|
158865
159504
|
|
|
158866
159505
|
// ../official/pack.ts
|
|
158867
|
-
import
|
|
159506
|
+
import crypto2 from "node:crypto";
|
|
158868
159507
|
import fs22 from "node:fs";
|
|
158869
159508
|
import path23 from "node:path";
|
|
158870
159509
|
import { fileURLToPath } from "node:url";
|
|
158871
159510
|
|
|
158872
|
-
// ../cli/src/lib/agent/studio-def.ts
|
|
158873
|
-
var import_ajv = __toESM(require_ajv(), 1);
|
|
158874
|
-
var import_yaml3 = __toESM(require_dist(), 1);
|
|
158875
|
-
|
|
158876
|
-
// ../cli/src/lib/agents/icon.ts
|
|
158877
|
-
var ICON_NAMES = [
|
|
158878
|
-
"file",
|
|
158879
|
-
"text",
|
|
158880
|
-
"article",
|
|
158881
|
-
"outline",
|
|
158882
|
-
"script",
|
|
158883
|
-
"prompt",
|
|
158884
|
-
"email",
|
|
158885
|
-
"image",
|
|
158886
|
-
"post-image",
|
|
158887
|
-
"social-image",
|
|
158888
|
-
"cover",
|
|
158889
|
-
"carousel",
|
|
158890
|
-
"carousel-outline",
|
|
158891
|
-
"slides",
|
|
158892
|
-
"wireframe",
|
|
158893
|
-
"screen",
|
|
158894
|
-
"video",
|
|
158895
|
-
"storyboard",
|
|
158896
|
-
"template",
|
|
158897
|
-
"shots",
|
|
158898
|
-
"api",
|
|
158899
|
-
"schema",
|
|
158900
|
-
"compare",
|
|
158901
|
-
"stack",
|
|
158902
|
-
"studio",
|
|
158903
|
-
"code",
|
|
158904
|
-
"checklist",
|
|
158905
|
-
"card",
|
|
158906
|
-
"plan",
|
|
158907
|
-
"proposal",
|
|
158908
|
-
"dismissed",
|
|
158909
|
-
"inbox",
|
|
158910
|
-
"notebook",
|
|
158911
|
-
"squeeze",
|
|
158912
|
-
"folder",
|
|
158913
|
-
"reply",
|
|
158914
|
-
"feedback",
|
|
158915
|
-
"software",
|
|
158916
|
-
"product-video",
|
|
158917
|
-
"social-post",
|
|
158918
|
-
"blog",
|
|
158919
|
-
"deck",
|
|
158920
|
-
"video-clone",
|
|
158921
|
-
"studio-kit"
|
|
158922
|
-
];
|
|
158923
|
-
var ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
|
|
158924
|
-
var PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
|
|
158925
|
-
var isColor = (v) => ICON_COLORS.includes(v);
|
|
158926
|
-
function readIcon(raw) {
|
|
158927
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
158928
|
-
if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
|
|
158929
|
-
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" };
|
|
158930
|
-
const parts = [];
|
|
158931
|
-
for (const [i, item] of raw.entries()) {
|
|
158932
|
-
const at2 = `part ${i + 1}`;
|
|
158933
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at2} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
|
|
158934
|
-
const { d: d2, f: f2, o: o3, s, w: w2, ...extra } = item;
|
|
158935
|
-
if (Object.keys(extra).length) return { problem: `${at2} has \`${Object.keys(extra).join("`, `")}\`` };
|
|
158936
|
-
if (typeof d2 !== "string" || !PATH.test(d2)) return { problem: `${at2} has no \`d\` of SVG path commands and numbers` };
|
|
158937
|
-
const part = { d: d2.trim() };
|
|
158938
|
-
for (const [key, value] of [["f", f2], ["s", s]]) {
|
|
158939
|
-
if (value === void 0) continue;
|
|
158940
|
-
if (typeof value !== "string" || !isColor(value)) return { problem: `${at2} colours \`${key}\` with "${String(value)}"` };
|
|
158941
|
-
part[key] = value;
|
|
158942
|
-
}
|
|
158943
|
-
if (o3 !== void 0) {
|
|
158944
|
-
if (o3 !== "true") return { problem: `${at2} has \`o: ${String(o3)}\`, not \`true\`` };
|
|
158945
|
-
part.o = true;
|
|
158946
|
-
}
|
|
158947
|
-
if (w2 !== void 0) {
|
|
158948
|
-
const width = typeof w2 === "string" ? Number(w2) : NaN;
|
|
158949
|
-
if (!(width > 0 && width <= 3)) return { problem: `${at2} has \`w: ${String(w2)}\`, not above 0 and up to 3` };
|
|
158950
|
-
part.w = width;
|
|
158951
|
-
}
|
|
158952
|
-
parts.push(part);
|
|
158953
|
-
}
|
|
158954
|
-
return parts;
|
|
158955
|
-
}
|
|
158956
|
-
|
|
158957
|
-
// ../cli/src/lib/shared/preview-blocks.ts
|
|
158958
|
-
var PREVIEW_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
158959
|
-
function sourcePosition(source2, offset) {
|
|
158960
|
-
const before = source2.slice(0, offset);
|
|
158961
|
-
return { line: before.split("\n").length, column: offset - before.lastIndexOf("\n") };
|
|
158962
|
-
}
|
|
158963
|
-
function withoutCode(source2) {
|
|
158964
|
-
const blank2 = (s) => s.replace(/[^\n\r]/g, " ");
|
|
158965
|
-
let fence;
|
|
158966
|
-
let indented = false, afterBlank = true, inList = false;
|
|
158967
|
-
return source2.split(/(?<=\n)/).map((line) => {
|
|
158968
|
-
const marker = /^ {0,3}(`{3,}|~{3,})(.*)/.exec(line);
|
|
158969
|
-
if (fence) {
|
|
158970
|
-
if (marker && marker[1][0] === fence.char && marker[1].length >= fence.length && !marker[2].trim()) fence = void 0;
|
|
158971
|
-
return blank2(line);
|
|
158972
|
-
}
|
|
158973
|
-
if (marker) {
|
|
158974
|
-
fence = { char: marker[1][0], length: marker[1].length };
|
|
158975
|
-
return blank2(line);
|
|
158976
|
-
}
|
|
158977
|
-
if (!line.trim()) {
|
|
158978
|
-
afterBlank = true;
|
|
158979
|
-
return line;
|
|
158980
|
-
}
|
|
158981
|
-
const hasIndent = /^(?: {4}|\t)/.test(line);
|
|
158982
|
-
if (!hasIndent) indented = false;
|
|
158983
|
-
if (/^ {0,3}(?:[-+*]|\d+[.)])\s/.test(line)) inList = true;
|
|
158984
|
-
else if (/^\S/.test(line)) inList = false;
|
|
158985
|
-
if (hasIndent && (indented || afterBlank && !inList)) {
|
|
158986
|
-
indented = true;
|
|
158987
|
-
return blank2(line);
|
|
158988
|
-
}
|
|
158989
|
-
afterBlank = false;
|
|
158990
|
-
return line;
|
|
158991
|
-
}).join("").replace(/(`+)([^]*?)\1(?!`)/g, blank2);
|
|
158992
|
-
}
|
|
158993
|
-
function agentSectionOffset(source2) {
|
|
158994
|
-
return /^<!--[ \t]*agent[ \t]*-->/m.exec(withoutCode(source2))?.index ?? source2.length;
|
|
158995
|
-
}
|
|
158996
|
-
function parsePreviewBlocks(source2, file2 = "STUDIO.md") {
|
|
158997
|
-
const blocks = [], problems = [];
|
|
158998
|
-
const masked = withoutCode(source2);
|
|
158999
|
-
let open2;
|
|
159000
|
-
const seen = /* @__PURE__ */ new Set();
|
|
159001
|
-
const fail = (offset, id2, code, message, hint2) => problems.push({ file: file2, ...sourcePosition(source2, offset), path: id2 ? `previews.${id2}` : "previews", code, message, hint: hint2 });
|
|
159002
|
-
for (const tag of masked.matchAll(/<\/?Preview\b[^>]*(?:>|$)/g)) {
|
|
159003
|
-
const offset = tag.index, text4 = tag[0];
|
|
159004
|
-
const closing = /^<\/Preview\s*>$/.test(text4);
|
|
159005
|
-
if (closing) {
|
|
159006
|
-
if (!open2) fail(offset, "", "preview-unexpected-close", "Preview has no opening tag", "Remove it or restore its opening tag.");
|
|
159007
|
-
else {
|
|
159008
|
-
const instructions = source2.slice(open2.content, offset).trim();
|
|
159009
|
-
if (!instructions) fail(open2.start, open2.id, "preview-empty", `Preview ${open2.id} is empty`, "Describe the requested output inside the block.");
|
|
159010
|
-
blocks.push({ id: open2.id, instructions, start: open2.start, end: offset + text4.length });
|
|
159011
|
-
open2 = void 0;
|
|
159012
|
-
}
|
|
159013
|
-
continue;
|
|
159014
|
-
}
|
|
159015
|
-
const opening = /^<Preview\s+id=(?:"([^"]*)"|'([^']*)')\s*>$/.exec(text4);
|
|
159016
|
-
if (!opening || open2) {
|
|
159017
|
-
fail(offset, open2?.id ?? "", "preview-tag", "Malformed or nested Preview tag", 'Use one non-nested <Preview id="stable-id"> block with only id.');
|
|
159018
|
-
continue;
|
|
159019
|
-
}
|
|
159020
|
-
const id2 = opening[1] ?? opening[2];
|
|
159021
|
-
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.");
|
|
159022
|
-
seen.add(id2);
|
|
159023
|
-
open2 = { id: id2, start: offset, content: offset + text4.length };
|
|
159024
|
-
}
|
|
159025
|
-
if (open2) fail(open2.start, open2.id, "preview-unclosed", `Preview ${open2.id} is not closed`, "Add </Preview> after this block.");
|
|
159026
|
-
return { blocks, problems };
|
|
159027
|
-
}
|
|
159028
|
-
|
|
159029
|
-
// ../cli/src/lib/agent/studio-def.ts
|
|
159030
|
-
var STUDIO_ID = PREVIEW_ID;
|
|
159031
|
-
var titles = { type: "object", minProperties: 1, propertyNames: { pattern: "^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$" }, additionalProperties: { type: "string", minLength: 1, pattern: "\\S" } };
|
|
159032
|
-
var icon = { anyOf: [
|
|
159033
|
-
{ type: "string", enum: ICON_NAMES },
|
|
159034
|
-
{ type: "array", minItems: 1, maxItems: 12, items: { type: "object", required: ["d"], additionalProperties: false, properties: {
|
|
159035
|
-
d: { type: "string", minLength: 1, pattern: "^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$" },
|
|
159036
|
-
f: { enum: ICON_COLORS },
|
|
159037
|
-
o: { const: true },
|
|
159038
|
-
s: { enum: ICON_COLORS },
|
|
159039
|
-
w: { type: "number", exclusiveMinimum: 0, maximum: 3 }
|
|
159040
|
-
} } }
|
|
159041
|
-
] };
|
|
159042
|
-
var STUDIO_SCHEMA = {
|
|
159043
|
-
type: "object",
|
|
159044
|
-
required: ["name"],
|
|
159045
|
-
additionalProperties: false,
|
|
159046
|
-
properties: {
|
|
159047
|
-
name: { type: "string", minLength: 1, pattern: "\\S" },
|
|
159048
|
-
names: titles,
|
|
159049
|
-
description: { type: "string" },
|
|
159050
|
-
summaries: titles,
|
|
159051
|
-
entrypoints: { type: "array", minItems: 1, maxItems: 10, uniqueItems: true, items: { type: "string", pattern: PREVIEW_ID.source } },
|
|
159052
|
-
needsArtifact: { type: "boolean" },
|
|
159053
|
-
icon,
|
|
159054
|
-
previews: { type: "object", propertyNames: { pattern: PREVIEW_ID.source }, additionalProperties: {
|
|
159055
|
-
type: "object",
|
|
159056
|
-
additionalProperties: false,
|
|
159057
|
-
properties: { title: titles, description: titles, icon }
|
|
159058
|
-
} }
|
|
159059
|
-
}
|
|
159060
|
-
};
|
|
159061
|
-
var validate = new import_ajv.Ajv({ allErrors: true, meta: false, validateSchema: false }).compile(STUDIO_SCHEMA);
|
|
159062
|
-
var comments = /<!--[^]*?(?:-->|$)/g;
|
|
159063
|
-
var blank = (text4) => text4.replace(/[^\r\n]/g, " ");
|
|
159064
|
-
var headingsOf = (body) => [...withoutCode(body).replace(comments, blank).matchAll(/^ {0,3}#{1,2}(?=[ \t\r\n]|$)[^\r\n]*/gm)];
|
|
159065
|
-
function studioSetup(body) {
|
|
159066
|
-
const headings = headingsOf(body);
|
|
159067
|
-
const index = headings.findIndex((h3) => /^ {0,3}##[ \t]+Setup(?:[ \t]+#+)?[ \t]*$/.test(body.slice(h3.index, h3.index + h3[0].length)));
|
|
159068
|
-
if (index === -1) return "";
|
|
159069
|
-
const heading = headings[index];
|
|
159070
|
-
const section = body.slice(heading.index + heading[0].length, headings[index + 1]?.index).trim();
|
|
159071
|
-
return section.replace(comments, "").trim() ? section : "";
|
|
159072
|
-
}
|
|
159073
|
-
function landSections(body, previews) {
|
|
159074
|
-
let visible = "", at2 = 0;
|
|
159075
|
-
for (const { start, end: end2 } of previews) {
|
|
159076
|
-
visible += body.slice(at2, start) + blank(body.slice(start, end2));
|
|
159077
|
-
at2 = end2;
|
|
159078
|
-
}
|
|
159079
|
-
visible += body.slice(at2);
|
|
159080
|
-
const headings = headingsOf(visible);
|
|
159081
|
-
return headings.flatMap((heading, index) => {
|
|
159082
|
-
const start = heading.index;
|
|
159083
|
-
const end2 = start + heading[0].length;
|
|
159084
|
-
if (!/^ {0,3}##[ \t]+Land(?:[ \t]+#+)?[ \t]*$/.test(visible.slice(start, end2))) return [];
|
|
159085
|
-
return [{
|
|
159086
|
-
offset: start + heading[0].indexOf("#"),
|
|
159087
|
-
empty: !visible.slice(end2, headings[index + 1]?.index).replace(comments, "").trim()
|
|
159088
|
-
}];
|
|
159089
|
-
});
|
|
159090
|
-
}
|
|
159091
|
-
function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
|
|
159092
|
-
const problems = [];
|
|
159093
|
-
const fail = (offset, path76, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path76, code, message, hint: hint2 });
|
|
159094
|
-
const result = () => ({ problem: problems.map((p2) => `${p2.file}:${p2.line}:${p2.column} ${p2.path}: ${p2.code} \u2014 ${p2.message}. ${p2.hint}`).join("\n"), problems });
|
|
159095
|
-
if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
|
|
159096
|
-
const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
|
|
159097
|
-
if (!front) {
|
|
159098
|
-
fail(0, "", "yaml-syntax", "Missing YAML frontmatter", "Enclose metadata between --- lines.");
|
|
159099
|
-
return result();
|
|
159100
|
-
}
|
|
159101
|
-
const metaOffset = source2.indexOf("\n") + 1, bodyOffset = front[0].length;
|
|
159102
|
-
const counter = new import_yaml3.LineCounter();
|
|
159103
|
-
const document = (0, import_yaml3.parseDocument)(front[1], { lineCounter: counter, uniqueKeys: true, strict: true });
|
|
159104
|
-
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.");
|
|
159105
|
-
if (problems.length) return result();
|
|
159106
|
-
let raw;
|
|
159107
|
-
try {
|
|
159108
|
-
raw = document.toJS({ maxAliasCount: 0 });
|
|
159109
|
-
} catch {
|
|
159110
|
-
fail(metaOffset, "", "yaml-syntax", "YAML aliases are not supported", "Write metadata explicitly.");
|
|
159111
|
-
return result();
|
|
159112
|
-
}
|
|
159113
|
-
if (!validate(raw)) {
|
|
159114
|
-
for (const error62 of validate.errors ?? []) {
|
|
159115
|
-
const parts = error62.instancePath.split("/").slice(1);
|
|
159116
|
-
const key = error62.params.additionalProperty ?? error62.params.missingProperty;
|
|
159117
|
-
if (key) parts.push(String(key));
|
|
159118
|
-
const node2 = parts.length ? document.getIn(parts, true) : document.contents;
|
|
159119
|
-
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.");
|
|
159120
|
-
}
|
|
159121
|
-
}
|
|
159122
|
-
const body = source2.slice(bodyOffset);
|
|
159123
|
-
const parsed = parsePreviewBlocks(body, from);
|
|
159124
|
-
problems.push(...parsed.problems.map((p2) => ({ ...p2, line: p2.line + source2.slice(0, bodyOffset).split("\n").length - 1 })));
|
|
159125
|
-
if (problems.length) return result();
|
|
159126
|
-
const map3 = raw.previews ?? {};
|
|
159127
|
-
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.");
|
|
159128
|
-
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.");
|
|
159129
|
-
if (requirePreviewCopy) for (const block of parsed.blocks) {
|
|
159130
|
-
const metadata = Object.hasOwn(map3, block.id) ? map3[block.id] : void 0;
|
|
159131
|
-
if (!metadata) continue;
|
|
159132
|
-
for (const field2 of ["title", "description"]) for (const lang of ["en", "zh"]) {
|
|
159133
|
-
if (metadata[field2]?.[lang]) continue;
|
|
159134
|
-
fail(
|
|
159135
|
-
bodyOffset + block.start,
|
|
159136
|
-
`previews.${block.id}.${field2}.${lang}`,
|
|
159137
|
-
"preview-display-missing",
|
|
159138
|
-
`Preview ${block.id} needs a ${lang} ${field2}`,
|
|
159139
|
-
"Add non-blank en and zh display text in the Preview metadata."
|
|
159140
|
-
);
|
|
159141
|
-
}
|
|
159142
|
-
}
|
|
159143
|
-
if (requireLand) {
|
|
159144
|
-
const sections = landSections(body, parsed.blocks);
|
|
159145
|
-
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.");
|
|
159146
|
-
for (const [index, { offset, empty }] of sections.entries()) {
|
|
159147
|
-
if (index) fail(bodyOffset + offset, "Land", "studio-land-duplicate", "Repeated ## Land section", "Combine delivery instructions under one ## Land heading.");
|
|
159148
|
-
if (empty) fail(bodyOffset + offset, "Land", "studio-land-empty", "The ## Land section is empty", "Describe delivery, checks and what to record under ## Land.");
|
|
159149
|
-
}
|
|
159150
|
-
}
|
|
159151
|
-
if (problems.length) return result();
|
|
159152
|
-
let rules = "", at2 = 0;
|
|
159153
|
-
for (const block of parsed.blocks) {
|
|
159154
|
-
rules += body.slice(at2, block.start);
|
|
159155
|
-
at2 = block.end;
|
|
159156
|
-
}
|
|
159157
|
-
rules += body.slice(at2);
|
|
159158
|
-
return { def: {
|
|
159159
|
-
id: id2,
|
|
159160
|
-
name: raw.name.trim(),
|
|
159161
|
-
...raw.names ? { names: raw.names } : {},
|
|
159162
|
-
description: raw.description ?? "",
|
|
159163
|
-
needsArtifact: raw.needsArtifact ?? false,
|
|
159164
|
-
...raw.summaries ? { summaries: raw.summaries } : {},
|
|
159165
|
-
...raw.entrypoints ? { entrypoints: raw.entrypoints } : {},
|
|
159166
|
-
...raw.icon ? { icon: raw.icon } : {},
|
|
159167
|
-
previews: parsed.blocks.map((b2) => ({ id: b2.id, instructions: b2.instructions, ...map3[b2.id] })),
|
|
159168
|
-
rules: rules.trim()
|
|
159169
|
-
} };
|
|
159170
|
-
}
|
|
159171
|
-
|
|
159172
159511
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
159173
159512
|
import fs21 from "node:fs";
|
|
159174
159513
|
import path22 from "node:path";
|
|
159175
|
-
|
|
159176
|
-
// ../cli/src/lib/shared/studio-files.ts
|
|
159177
|
-
var import_yaml5 = __toESM(require_dist(), 1);
|
|
159178
|
-
|
|
159179
|
-
// ../cli/src/lib/shared/guide-topics.ts
|
|
159180
|
-
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"];
|
|
159181
|
-
|
|
159182
|
-
// ../cli/src/lib/shared/studio-files.ts
|
|
159183
|
-
var STUDIO_FILE = "STUDIO.md";
|
|
159184
|
-
var MCP_FILE = "mcp.json";
|
|
159185
|
-
var CARD_TEMPLATE_FILE = "CARD.md";
|
|
159186
|
-
var VERSION_FILE = "version.json";
|
|
159187
|
-
var KB = 1024;
|
|
159188
|
-
var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
|
|
159189
|
-
var officialId = (folder2) => `wf_builtin_${folder2.replace(/-/g, "_")}`;
|
|
159190
|
-
var hashInput = (files) => JSON.stringify(Object.entries(files).sort(([a2], [b2]) => a2 < b2 ? -1 : 1));
|
|
159191
|
-
var landsOf = (_def) => ({ lands: true });
|
|
159192
|
-
var SEGMENT = /^[\w.-]+$/;
|
|
159193
|
-
var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
|
|
159194
|
-
var bytes = (text4) => new TextEncoder().encode(text4).length;
|
|
159195
|
-
var isSharedFile = (file2) => {
|
|
159196
|
-
const parts = file2.split("/");
|
|
159197
|
-
return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p2) => SEGMENT.test(p2) && p2 !== "." && p2 !== "..");
|
|
159198
|
-
};
|
|
159199
|
-
function folderPath(file2, top) {
|
|
159200
|
-
const parts = file2.split("/");
|
|
159201
|
-
if (parts.length < 3 || parts[0] !== top || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(parts[1])) return null;
|
|
159202
|
-
if (parts.slice(2).some((p2) => !SEGMENT.test(p2) || p2 === "." || p2 === "..")) return null;
|
|
159203
|
-
return [parts[1], parts.slice(2).join("/")];
|
|
159204
|
-
}
|
|
159205
|
-
function mcpProblem(text4) {
|
|
159206
|
-
let read5;
|
|
159207
|
-
try {
|
|
159208
|
-
read5 = JSON.parse(text4);
|
|
159209
|
-
} catch {
|
|
159210
|
-
return "is not JSON";
|
|
159211
|
-
}
|
|
159212
|
-
const servers = read5?.mcpServers;
|
|
159213
|
-
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
|
|
159214
|
-
for (const [name, server] of Object.entries(servers)) {
|
|
159215
|
-
const { command, args: args2, ...rest } = server ?? {};
|
|
159216
|
-
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return `names a server \`${name}\`; use lowercase letters, digits and dashes`;
|
|
159217
|
-
if (typeof command !== "string" || !command) return `server \`${name}\` needs a \`command\``;
|
|
159218
|
-
if (args2 !== void 0 && !(Array.isArray(args2) && args2.every((a2) => typeof a2 === "string"))) return `server \`${name}\`: \`args\` must be a list of strings`;
|
|
159219
|
-
if (Object.keys(rest).length) return `server \`${name}\` takes only \`command\` and \`args\``;
|
|
159220
|
-
}
|
|
159221
|
-
return null;
|
|
159222
|
-
}
|
|
159223
|
-
function formatStudioProblem({ file: file2, line, column, reason, hint: hint2 }) {
|
|
159224
|
-
const location = line === void 0 ? file2 : `${file2}:${line}:${column ?? 1}`;
|
|
159225
|
-
return `${location}: ${reason}${hint2 ? `. ${hint2}` : ""}`;
|
|
159226
|
-
}
|
|
159227
|
-
function checkStudioFiles(value, official = false, checks = {}) {
|
|
159228
|
-
const read5 = inspect(value, official, checks);
|
|
159229
|
-
const first = read5.problems[0];
|
|
159230
|
-
return first ? { ok: false, ...first, problems: read5.problems } : { ok: true, def: read5.def, files: read5.files };
|
|
159231
|
-
}
|
|
159232
|
-
function inspect(value, official, { allowLegacyPreviewCopy, allowLegacyLand } = {}) {
|
|
159233
|
-
const problems = [];
|
|
159234
|
-
const fail = (file2, reason, tooLarge = false) => {
|
|
159235
|
-
problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
|
|
159236
|
-
return { problems };
|
|
159237
|
-
};
|
|
159238
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
|
|
159239
|
-
const files = Object.fromEntries(Object.entries(value).filter(([file2]) => file2 !== VERSION_FILE));
|
|
159240
|
-
const entries = Object.entries(files);
|
|
159241
|
-
if (entries.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
|
|
159242
|
-
let total = 0;
|
|
159243
|
-
const skills = /* @__PURE__ */ new Set();
|
|
159244
|
-
for (const [file2, text4] of entries) {
|
|
159245
|
-
if (typeof text4 !== "string" || text4.includes("\0")) {
|
|
159246
|
-
fail(file2, "is not a text file");
|
|
159247
|
-
continue;
|
|
159248
|
-
}
|
|
159249
|
-
if (file2.length > FILE_LIMITS.path) {
|
|
159250
|
-
fail(file2, `the path is longer than ${FILE_LIMITS.path} characters`);
|
|
159251
|
-
continue;
|
|
159252
|
-
}
|
|
159253
|
-
const size = bytes(text4);
|
|
159254
|
-
if (size > FILE_LIMITS.file) return fail(file2, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
|
|
159255
|
-
total += size;
|
|
159256
|
-
if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
|
|
159257
|
-
if (file2 === STUDIO_FILE || file2 === CARD_TEMPLATE_FILE) continue;
|
|
159258
|
-
if (official && file2 === MCP_FILE) {
|
|
159259
|
-
const problem2 = mcpProblem(text4);
|
|
159260
|
-
if (problem2) fail(file2, problem2);
|
|
159261
|
-
continue;
|
|
159262
|
-
}
|
|
159263
|
-
if (official && isAboutFile(file2)) continue;
|
|
159264
|
-
if (official && file2.startsWith("skills/")) {
|
|
159265
|
-
if (!folderPath(file2, "skills")) fail(file2, "is not inside skills/<name>/");
|
|
159266
|
-
else skills.add(file2.split("/")[1]);
|
|
159267
|
-
continue;
|
|
159268
|
-
}
|
|
159269
|
-
if (isSharedFile(file2)) continue;
|
|
159270
|
-
if (/^(?:references|scripts)\//.test(file2) && file2.split("/").every((p2) => SEGMENT.test(p2) && p2 !== "." && p2 !== "..")) continue;
|
|
159271
|
-
fail(file2, `use ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, references/, scripts/ or shared/`);
|
|
159272
|
-
}
|
|
159273
|
-
for (const name of skills) {
|
|
159274
|
-
if (files[`skills/${name}/SKILL.md`] === void 0) fail(`skills/${name}/SKILL.md`, "is missing");
|
|
159275
|
-
}
|
|
159276
|
-
const source2 = files[STUDIO_FILE];
|
|
159277
|
-
const read5 = typeof source2 === "string" ? parseStudioFile("studio", source2, STUDIO_FILE, { requirePreviewCopy: !official && !allowLegacyPreviewCopy, requireLand: !allowLegacyLand }) : null;
|
|
159278
|
-
if (!read5) fail(STUDIO_FILE, "is missing");
|
|
159279
|
-
else if ("problem" in read5) for (const problem2 of read5.problems) problems.push({ ...problem2, reason: problem2.message });
|
|
159280
|
-
if (!read5 || "problem" in read5) return { problems };
|
|
159281
|
-
const def = read5.def;
|
|
159282
|
-
for (const [file2, text4] of Object.entries(files)) {
|
|
159283
|
-
if (typeof text4 !== "string" || !file2.endsWith(".md")) continue;
|
|
159284
|
-
const masked = withoutCode(text4);
|
|
159285
|
-
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." });
|
|
159286
|
-
for (const match of masked.matchAll(/!?\[[^\]]*\]\(([^\s)]+)(?:\s+[^)]*)?\)/g)) {
|
|
159287
|
-
const link = match[1].replace(/^<|>$/g, "");
|
|
159288
|
-
if (/^(?:https?:|mailto:|#)/i.test(link)) continue;
|
|
159289
|
-
let decoded;
|
|
159290
|
-
try {
|
|
159291
|
-
decoded = decodeURIComponent(link.split(/[?#]/)[0]);
|
|
159292
|
-
} catch {
|
|
159293
|
-
reference(match.index, link, "Invalid resource URL");
|
|
159294
|
-
continue;
|
|
159295
|
-
}
|
|
159296
|
-
if (/^(?:[a-z][\w+.-]*:|[/\\])|\\/i.test(decoded) || decoded.split("/").includes("..")) {
|
|
159297
|
-
reference(match.index, link, "Unsafe resource path");
|
|
159298
|
-
continue;
|
|
159299
|
-
}
|
|
159300
|
-
const target = [...file2.split("/").slice(0, -1), ...decoded.split("/").filter((p2) => p2 !== ".")].join("/");
|
|
159301
|
-
if (!Object.hasOwn(files, target)) reference(match.index, link, `Missing resource ${target}`);
|
|
159302
|
-
}
|
|
159303
|
-
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]}`);
|
|
159304
|
-
}
|
|
159305
|
-
return { problems, def, files };
|
|
159306
|
-
}
|
|
159307
|
-
function previewCatalog(files) {
|
|
159308
|
-
const read5 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
159309
|
-
if ("problem" in read5) throw new Error(read5.problem);
|
|
159310
|
-
return read5.def.previews;
|
|
159311
|
-
}
|
|
159312
|
-
|
|
159313
|
-
// ../cli/src/lib/agent/studio-folder.ts
|
|
159314
159514
|
var MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
159315
159515
|
function filesOf(dir, base = dir) {
|
|
159316
|
-
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) => {
|
|
159317
159517
|
const full = path22.join(dir, e2.name);
|
|
159318
|
-
if (e2.
|
|
159518
|
+
if (!e2.isFile() && !e2.isDirectory()) throw new Error(full + ": only regular files and directories are allowed");
|
|
159319
159519
|
return e2.isDirectory() ? filesOf(full, base) : [path22.relative(base, full).split(path22.sep).join("/")];
|
|
159320
159520
|
});
|
|
159321
159521
|
}
|
|
159322
159522
|
function readStudioFile(dir, file2) {
|
|
159323
159523
|
const full = path22.join(dir, file2);
|
|
159324
|
-
|
|
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
|
+
}));
|
|
159325
159543
|
}
|
|
159326
|
-
var readStudioFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readStudioFile(dir, f2)]));
|
|
159327
159544
|
|
|
159328
159545
|
// ../official/pack.ts
|
|
159329
159546
|
var OFFICIAL = path23.dirname(fileURLToPath(import.meta.url));
|
|
159330
159547
|
var dirs = (dir) => fs22.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
159331
|
-
var hashOf = (files) =>
|
|
159548
|
+
var hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
159332
159549
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
159333
159550
|
const studiosDir = path23.join(root2, "studios");
|
|
159334
159551
|
return dirs(studiosDir).map((folder2) => {
|
|
@@ -159360,7 +159577,7 @@ function workspaceTask() {
|
|
|
159360
159577
|
const id2 = process.env[TASK_ENV];
|
|
159361
159578
|
return id2 && id2.trim() ? id2.trim() : null;
|
|
159362
159579
|
}
|
|
159363
|
-
async function call(method, route, body, key, { allowResultError = false } = {}) {
|
|
159580
|
+
async function call(method, route, body, key, { allowResultError = false, downloadBytes } = {}) {
|
|
159364
159581
|
if (!cloudConfigured()) return { ok: false, error: NOT_CONFIGURED, code: "bad_request" };
|
|
159365
159582
|
const token = await accessToken();
|
|
159366
159583
|
if (!token.ok) {
|
|
@@ -159381,6 +159598,13 @@ async function call(method, route, body, key, { allowResultError = false } = {})
|
|
|
159381
159598
|
} catch (e2) {
|
|
159382
159599
|
return { ok: false, error: `Cloud could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}`, code: "unreachable", retryable: true };
|
|
159383
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
|
+
}
|
|
159384
159608
|
const parsed = await readCloudJson(response);
|
|
159385
159609
|
const problem2 = (response.ok && allowResultError ? null : cloudProblem(response, parsed)) ?? (isRecord(parsed) ? null : invalidResponse("a valid JSON response"));
|
|
159386
159610
|
if (problem2) return { ok: false, ...problem2, error: problem2.message };
|
|
@@ -159407,12 +159631,16 @@ function linkedProject(board, root2) {
|
|
|
159407
159631
|
}
|
|
159408
159632
|
|
|
159409
159633
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
159634
|
+
var STUDIO_SNAPSHOT_ENV = "AI4KANBAN_STUDIO_SNAPSHOT";
|
|
159410
159635
|
var DEV = "AI4KANBAN_STUDIOS";
|
|
159411
159636
|
var root = () => path25.join(machineHome(), "studios");
|
|
159412
159637
|
var safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
159413
159638
|
var versionFile = (id2, version2) => path25.join(root(), "versions", `${safe(id2)}@${version2}.json`);
|
|
159414
159639
|
var listFile = (project) => path25.join(root(), "lists", `${safe(project)}.json`);
|
|
159415
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);
|
|
159416
159644
|
function readJson(file2) {
|
|
159417
159645
|
try {
|
|
159418
159646
|
return JSON.parse(fs24.readFileSync(file2, "utf8"));
|
|
@@ -159422,12 +159650,19 @@ function readJson(file2) {
|
|
|
159422
159650
|
}
|
|
159423
159651
|
function writeJson(file2, value) {
|
|
159424
159652
|
fs24.mkdirSync(path25.dirname(file2), { recursive: true });
|
|
159425
|
-
const tmp = `${file2}.${
|
|
159426
|
-
|
|
159427
|
-
|
|
159428
|
-
|
|
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
|
+
}
|
|
159429
159660
|
}
|
|
159430
|
-
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
|
+
};
|
|
159431
159666
|
function heldStudioName(name) {
|
|
159432
159667
|
let files;
|
|
159433
159668
|
try {
|
|
@@ -159442,15 +159677,149 @@ function heldStudioName(name) {
|
|
|
159442
159677
|
}
|
|
159443
159678
|
function saveVersion(held5) {
|
|
159444
159679
|
const file2 = versionFile(held5.id, held5.version);
|
|
159445
|
-
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 });
|
|
159446
159681
|
}
|
|
159447
|
-
function savePin(task, held5) {
|
|
159448
|
-
saveVersion(held5);
|
|
159682
|
+
function savePin(task, held5, saved = false) {
|
|
159683
|
+
if (!saved) saveVersion(held5);
|
|
159449
159684
|
writeJson(pinFile(task), { studio: held5.id, version: held5.version, historicalPreviews: held5.historicalPreviews });
|
|
159450
159685
|
}
|
|
159451
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
|
+
}
|
|
159452
159730
|
var boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
159453
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);
|
|
159454
159823
|
var flowOf = (held5) => {
|
|
159455
159824
|
const id2 = studioName(held5.id);
|
|
159456
159825
|
const read5 = parseStudioFile(id2, held5.files["STUDIO.md"] ?? "", `the \`${id2}\` studio`);
|
|
@@ -159470,17 +159839,23 @@ function readFlows() {
|
|
|
159470
159839
|
return held5 ? flowOf(held5) ?? [] : [];
|
|
159471
159840
|
});
|
|
159472
159841
|
const task = workspaceTask();
|
|
159473
|
-
const pin = task ?
|
|
159842
|
+
const pin = task ? activeStudioPin(task) : null;
|
|
159474
159843
|
const pinned = pin && readVersion2(pin.studio, pin.version);
|
|
159475
159844
|
const mine = pinned && flowOf(pinned);
|
|
159476
|
-
if (!mine) return flows2;
|
|
159845
|
+
if (!mine) return pin ? flows2.filter((flow) => flow.cloudId !== pin.studio) : flows2;
|
|
159477
159846
|
return [mine, ...flows2.filter((f2) => f2.cloudId !== mine.cloudId)];
|
|
159478
159847
|
}
|
|
159479
159848
|
var sources = () => {
|
|
159480
159849
|
if (devFolder()) return [devFolder()];
|
|
159481
159850
|
const project = boardProject();
|
|
159482
159851
|
const task = workspaceTask();
|
|
159483
|
-
|
|
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
|
+
];
|
|
159484
159859
|
};
|
|
159485
159860
|
var flows = memoByFiles(sources, readFlows);
|
|
159486
159861
|
var cloudStudioSources = sources;
|
|
@@ -159489,7 +159864,7 @@ function cloudAgentFiles() {
|
|
|
159489
159864
|
const files = {};
|
|
159490
159865
|
const official = /* @__PURE__ */ new Set();
|
|
159491
159866
|
const owner2 = /* @__PURE__ */ new Map();
|
|
159492
|
-
for (const flow of cloudFlows()) {
|
|
159867
|
+
for (const flow of devFolder() ? cloudFlows() : []) {
|
|
159493
159868
|
for (const [name, text4] of Object.entries(flow.files)) {
|
|
159494
159869
|
const at2 = /^agents\/([^/]+)\/(.+)$/.exec(name);
|
|
159495
159870
|
if (!at2) continue;
|
|
@@ -159794,7 +160169,7 @@ function matcher(entry) {
|
|
|
159794
160169
|
}
|
|
159795
160170
|
|
|
159796
160171
|
// ../cli/src/lib/shared/board-conflicts.ts
|
|
159797
|
-
import
|
|
160172
|
+
import crypto3 from "node:crypto";
|
|
159798
160173
|
import fs26 from "node:fs";
|
|
159799
160174
|
import path27 from "node:path";
|
|
159800
160175
|
|
|
@@ -159880,7 +160255,7 @@ var fileOf = (board, id2) => {
|
|
|
159880
160255
|
};
|
|
159881
160256
|
function atomicJson(file2, data) {
|
|
159882
160257
|
fs26.mkdirSync(path27.dirname(file2), { recursive: true });
|
|
159883
|
-
const temp = `${file2}.${
|
|
160258
|
+
const temp = `${file2}.${crypto3.randomUUID()}.tmp`;
|
|
159884
160259
|
const fd = fs26.openSync(temp, "wx", 384);
|
|
159885
160260
|
try {
|
|
159886
160261
|
fs26.writeFileSync(fd, JSON.stringify(data));
|
|
@@ -159939,7 +160314,7 @@ function conflictPrompt(board, work = "Continue the original work from its saved
|
|
|
159939
160314
|
function captureConflict(board, project, files) {
|
|
159940
160315
|
const pending = pendingConflicts(board)[0];
|
|
159941
160316
|
if (pending) return pending;
|
|
159942
|
-
const record2 = { id: `c_${
|
|
160317
|
+
const record2 = { id: `c_${crypto3.randomUUID().replaceAll("-", "")}`, project, state: "open", files, receipt: null };
|
|
159943
160318
|
save(board, record2);
|
|
159944
160319
|
return record2;
|
|
159945
160320
|
}
|
|
@@ -159959,7 +160334,7 @@ async function withSyncLock(board, work) {
|
|
|
159959
160334
|
}
|
|
159960
160335
|
|
|
159961
160336
|
// src/cache.ts
|
|
159962
|
-
import
|
|
160337
|
+
import crypto4 from "node:crypto";
|
|
159963
160338
|
import fs28 from "node:fs";
|
|
159964
160339
|
import path29 from "node:path";
|
|
159965
160340
|
|
|
@@ -160015,7 +160390,7 @@ function markUnsent(dir, unsent2) {
|
|
|
160015
160390
|
}
|
|
160016
160391
|
var holds = /* @__PURE__ */ new Map();
|
|
160017
160392
|
var holdsDir = () => path29.join(runnerHome(), "holds");
|
|
160018
|
-
var holdFile = (dir) => path29.join(holdsDir(), `${
|
|
160393
|
+
var holdFile = (dir) => path29.join(holdsDir(), `${crypto4.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
|
|
160019
160394
|
function hold(dir) {
|
|
160020
160395
|
fs28.mkdirSync(holdsDir(), { recursive: true, mode: 448 });
|
|
160021
160396
|
fs28.writeFileSync(holdFile(dir), "", { mode: 384 });
|
|
@@ -161141,6 +161516,7 @@ function parseStore() {
|
|
|
161141
161516
|
runs.push({
|
|
161142
161517
|
sessionId: entry.sessionId,
|
|
161143
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,
|
|
161144
161520
|
pendingWrites: entry.pendingWrites === true || void 0,
|
|
161145
161521
|
submitted: entry.submitted === true || void 0,
|
|
161146
161522
|
cardId: typeof entry.cardId === "number" ? entry.cardId : null,
|
|
@@ -162231,7 +162607,7 @@ var TAG2 = /^<Storyboard\b([^<>]*?)\/>$/;
|
|
|
162231
162607
|
var attr = (name) => new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`);
|
|
162232
162608
|
var SRC_ATTR = attr("src");
|
|
162233
162609
|
var LABEL_ATTR = attr("label");
|
|
162234
|
-
var
|
|
162610
|
+
var SEGMENT = /^(?!\.)[^/\\]+$/;
|
|
162235
162611
|
function storyboardAttrs(raw) {
|
|
162236
162612
|
const m = TAG2.exec(raw.trim());
|
|
162237
162613
|
if (!m) return null;
|
|
@@ -162272,7 +162648,7 @@ function assetName(src, cardId, exts, nested = false) {
|
|
|
162272
162648
|
const parts = src.split("/");
|
|
162273
162649
|
if (parts[0] !== ".assets" || parts.length < 3 || !nested && parts.length !== 3) return { expected, actual: JSON.stringify(src) };
|
|
162274
162650
|
if (parts[1] !== String(cardId)) return { expected, actual: `another card's folder ${JSON.stringify(parts[1])}` };
|
|
162275
|
-
if (!parts.slice(2).every((part) =>
|
|
162651
|
+
if (!parts.slice(2).every((part) => SEGMENT.test(part))) return { expected, actual: JSON.stringify(src) };
|
|
162276
162652
|
const name = parts.slice(2).join("/");
|
|
162277
162653
|
const ext = name.split(".").pop().toLowerCase();
|
|
162278
162654
|
if (exts.length && (!name.includes(".") || !exts.includes(ext))) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
|
|
@@ -162341,7 +162717,7 @@ var tiled_default = `{
|
|
|
162341
162717
|
var video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
|
|
162342
162718
|
|
|
162343
162719
|
// ../artifact-sdk/src/builtin/studio.json
|
|
162344
|
-
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';
|
|
162345
162721
|
|
|
162346
162722
|
// ../artifact-sdk/src/builtin/index.ts
|
|
162347
162723
|
var read2 = (m) => typeof m === "string" ? JSON.parse(m) : m;
|
|
@@ -162584,9 +162960,9 @@ function kindOf2(ext) {
|
|
|
162584
162960
|
var text3 = (v) => typeof v === "string" && v.length > 0;
|
|
162585
162961
|
var source = (v) => text3(v) && !/^(?:[a-z][\w+.-]*:|\/|#)|\\|[\u0000-\u001f]/i.test(v);
|
|
162586
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));
|
|
162587
|
-
var relativePath = (v) =>
|
|
162963
|
+
var relativePath = (v) => text3(v) && !/^(?:[a-z][\w+.-]*:|\/)|\\|[\u0000-\u001f]/i.test(v) && v.split("/").every((p2) => p2 && p2 !== "." && p2 !== "..");
|
|
162588
162964
|
var optionalText = (v, keys) => keys.every((k2) => v[k2] === void 0 || typeof v[k2] === "string");
|
|
162589
|
-
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));
|
|
162590
162966
|
function resultProblem(value, agents) {
|
|
162591
162967
|
if (!Array.isArray(value) || value.length > 500) return "/results";
|
|
162592
162968
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -162611,7 +162987,7 @@ function reviewProblem(v) {
|
|
|
162611
162987
|
const paths = /* @__PURE__ */ new Set();
|
|
162612
162988
|
for (const f2 of v.files) {
|
|
162613
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";
|
|
162614
|
-
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";
|
|
162615
162991
|
paths.add(f2.path);
|
|
162616
162992
|
}
|
|
162617
162993
|
return v.results === void 0 ? null : resultProblem(v.results, agents);
|
|
@@ -164098,6 +164474,13 @@ function cmdAgentFile(askedName, askedFile) {
|
|
|
164098
164474
|
|
|
164099
164475
|
// ../cli/src/lib/agent/studio-shared.ts
|
|
164100
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
|
+
}
|
|
164101
164484
|
const flow = cloudFlows().find((f2) => f2.def.id === studio2 || f2.cloudId === studio2);
|
|
164102
164485
|
if (flow) return flow.files;
|
|
164103
164486
|
return null;
|
|
@@ -164109,14 +164492,21 @@ function cmdStudioFile(askedStudio, askedFile) {
|
|
|
164109
164492
|
const files = studioFiles(studio2);
|
|
164110
164493
|
if (!files) die(`no studio ${studio2}`, { kind: "no-such-studio", studio: studio2 });
|
|
164111
164494
|
const file2 = askedFile.trim().replace(/^\.\//, "");
|
|
164112
|
-
const readable = Object.keys(files).filter((f2) => f2
|
|
164113
|
-
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)) {
|
|
164114
164497
|
die(`${studio2} has no ${file2}. It has: ${readable.join(", ")}.`, { kind: "no-such-studio-file", studio: studio2, file: file2 });
|
|
164115
164498
|
}
|
|
164116
164499
|
const text4 = files[file2];
|
|
164117
164500
|
say(text4);
|
|
164118
164501
|
return { studio: studio2, file: file2, text: text4 };
|
|
164119
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
|
+
}
|
|
164120
164510
|
|
|
164121
164511
|
// ../cli/src/lib/memories.ts
|
|
164122
164512
|
import fs50 from "node:fs";
|
|
@@ -164332,6 +164722,7 @@ var MOVES = {
|
|
|
164332
164722
|
reject: ({ args: args2, opts }) => cmdRemove(Number(args2[0]), "rejected", as(opts)),
|
|
164333
164723
|
"agent-file": ({ args: args2 }) => cmdAgentFile(args2[0] ?? "", args2[1] ?? ""),
|
|
164334
164724
|
file: ({ args: args2 }) => cmdStudioFile(args2[0] ?? "", args2[1] ?? ""),
|
|
164725
|
+
skills: ({ args: args2 }) => cmdStudioSkills(args2[0] ?? ""),
|
|
164335
164726
|
"memory-file": ({ args: args2 }) => cmdMemoryFile(args2[0] ?? "")
|
|
164336
164727
|
};
|
|
164337
164728
|
var BOARD_MOVES = new Set(Object.keys(MOVES));
|
|
@@ -165826,16 +166217,16 @@ function cleanEnum(obj3) {
|
|
|
165826
166217
|
}
|
|
165827
166218
|
function base64ToUint8Array(base643) {
|
|
165828
166219
|
const binaryString = atob(base643);
|
|
165829
|
-
const
|
|
166220
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
165830
166221
|
for (let i = 0; i < binaryString.length; i++) {
|
|
165831
|
-
|
|
166222
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
165832
166223
|
}
|
|
165833
|
-
return
|
|
166224
|
+
return bytes;
|
|
165834
166225
|
}
|
|
165835
|
-
function uint8ArrayToBase64(
|
|
166226
|
+
function uint8ArrayToBase64(bytes) {
|
|
165836
166227
|
let binaryString = "";
|
|
165837
|
-
for (let i = 0; i <
|
|
165838
|
-
binaryString += String.fromCharCode(
|
|
166228
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
166229
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
165839
166230
|
}
|
|
165840
166231
|
return btoa(binaryString);
|
|
165841
166232
|
}
|
|
@@ -165844,22 +166235,22 @@ function base64urlToUint8Array(base64url3) {
|
|
|
165844
166235
|
const padding = "=".repeat((4 - base643.length % 4) % 4);
|
|
165845
166236
|
return base64ToUint8Array(base643 + padding);
|
|
165846
166237
|
}
|
|
165847
|
-
function uint8ArrayToBase64url(
|
|
165848
|
-
return uint8ArrayToBase64(
|
|
166238
|
+
function uint8ArrayToBase64url(bytes) {
|
|
166239
|
+
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
165849
166240
|
}
|
|
165850
166241
|
function hexToUint8Array(hex3) {
|
|
165851
166242
|
const cleanHex = hex3.replace(/^0x/, "");
|
|
165852
166243
|
if (cleanHex.length % 2 !== 0) {
|
|
165853
166244
|
throw new Error("Invalid hex string length");
|
|
165854
166245
|
}
|
|
165855
|
-
const
|
|
166246
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
165856
166247
|
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
165857
|
-
|
|
166248
|
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
165858
166249
|
}
|
|
165859
|
-
return
|
|
166250
|
+
return bytes;
|
|
165860
166251
|
}
|
|
165861
|
-
function uint8ArrayToHex(
|
|
165862
|
-
return Array.from(
|
|
166252
|
+
function uint8ArrayToHex(bytes) {
|
|
166253
|
+
return Array.from(bytes).map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
165863
166254
|
}
|
|
165864
166255
|
var Class = class {
|
|
165865
166256
|
constructor(..._args) {
|
|
@@ -184393,7 +184784,7 @@ function documentPreviewKey(artifact, version2) {
|
|
|
184393
184784
|
var TEXT_LIMIT = 1024 * 1024;
|
|
184394
184785
|
|
|
184395
184786
|
// ../cli/src/components/Asset.md
|
|
184396
|
-
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';
|
|
184397
184788
|
|
|
184398
184789
|
// ../cli/src/components/Compare.md
|
|
184399
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';
|
|
@@ -184519,7 +184910,7 @@ exec ${shellLine} "$@"
|
|
|
184519
184910
|
}
|
|
184520
184911
|
function akbEnv(akb, board, task, language2, base = process.env) {
|
|
184521
184912
|
const env2 = {};
|
|
184522
|
-
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];
|
|
184523
184914
|
for (const [k2, v] of Object.entries({ ...proxyEnv(), ...base })) if (!k2.startsWith("KANBAN_") && !dropped.includes(k2)) env2[k2] = v;
|
|
184524
184915
|
const key = Object.keys(env2).find((k2) => k2.toUpperCase() === "PATH") ?? "PATH";
|
|
184525
184916
|
env2[key] = [shimDir(akb), env2[key]].filter(Boolean).join(path54.delimiter);
|
|
@@ -184582,7 +184973,7 @@ function answerOf2(ran) {
|
|
|
184582
184973
|
|
|
184583
184974
|
// src/runtimes.ts
|
|
184584
184975
|
import { spawn as spawn3 } from "node:child_process";
|
|
184585
|
-
import { randomUUID as
|
|
184976
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
184586
184977
|
import fs54 from "node:fs";
|
|
184587
184978
|
import os6 from "node:os";
|
|
184588
184979
|
import path55 from "node:path";
|
|
@@ -184674,7 +185065,7 @@ var takesImageArgs = (runtime) => HARNESSES2[runtime].images?.as === "args";
|
|
|
184674
185065
|
function plan(runtime, prompt, cwd, resume, model, given = {}, fork = false, language2 = null, images = [], discussionImages) {
|
|
184675
185066
|
const harness = HARNESSES2[runtime];
|
|
184676
185067
|
const { argv, note } = installedCommand(harness);
|
|
184677
|
-
const id2 =
|
|
185068
|
+
const id2 = randomUUID5();
|
|
184678
185069
|
const session = fork ? resume && harness.forkArgs ? { id: id2, resume, fork: true } : { id: id2 } : resume ? { resume } : { id: id2 };
|
|
184679
185070
|
const launch2 = planLaunch(harness, argv, {
|
|
184680
185071
|
cwd,
|
|
@@ -184926,8 +185317,8 @@ function writeRemoval(board, task, removal) {
|
|
|
184926
185317
|
|
|
184927
185318
|
// src/task-folder.ts
|
|
184928
185319
|
init_file_limits();
|
|
184929
|
-
import { setTimeout as
|
|
184930
|
-
import
|
|
185320
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
185321
|
+
import crypto5 from "node:crypto";
|
|
184931
185322
|
import fs58 from "node:fs";
|
|
184932
185323
|
import path60 from "node:path";
|
|
184933
185324
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -185234,8 +185625,8 @@ function logSync(event2, fields2 = {}) {
|
|
|
185234
185625
|
if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
|
|
185235
185626
|
}
|
|
185236
185627
|
if (syncDebug) {
|
|
185237
|
-
const
|
|
185238
|
-
|
|
185628
|
+
const delay4 = monitorEventLoopDelay({ resolution: 20 });
|
|
185629
|
+
delay4.enable();
|
|
185239
185630
|
let cpu = process.cpuUsage();
|
|
185240
185631
|
let at2 = performance.now();
|
|
185241
185632
|
setInterval(() => {
|
|
@@ -185243,14 +185634,14 @@ if (syncDebug) {
|
|
|
185243
185634
|
const used = process.cpuUsage(cpu);
|
|
185244
185635
|
logSync("health", {
|
|
185245
185636
|
cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
|
|
185246
|
-
delayMaxMs: Math.round(
|
|
185247
|
-
delayP99Ms: Math.round(
|
|
185637
|
+
delayMaxMs: Math.round(delay4.max / 1e6),
|
|
185638
|
+
delayP99Ms: Math.round(delay4.percentile(99) / 1e6),
|
|
185248
185639
|
...counts
|
|
185249
185640
|
});
|
|
185250
185641
|
for (const name of Object.keys(counts)) delete counts[name];
|
|
185251
185642
|
cpu = process.cpuUsage();
|
|
185252
185643
|
at2 = now;
|
|
185253
|
-
|
|
185644
|
+
delay4.reset();
|
|
185254
185645
|
}, 5e3).unref();
|
|
185255
185646
|
}
|
|
185256
185647
|
|
|
@@ -185457,7 +185848,7 @@ function writeBase(ws, base) {
|
|
|
185457
185848
|
fs58.writeFileSync(`${file2}.tmp`, JSON.stringify(base));
|
|
185458
185849
|
fs58.renameSync(`${file2}.tmp`, file2);
|
|
185459
185850
|
}
|
|
185460
|
-
var hashOf2 = (
|
|
185851
|
+
var hashOf2 = (bytes) => crypto5.createHash("sha256").update(bytes).digest("hex");
|
|
185461
185852
|
function hashFile(file2) {
|
|
185462
185853
|
try {
|
|
185463
185854
|
return hashOf2(fs58.readFileSync(file2));
|
|
@@ -185465,9 +185856,9 @@ function hashFile(file2) {
|
|
|
185465
185856
|
return null;
|
|
185466
185857
|
}
|
|
185467
185858
|
}
|
|
185468
|
-
function write(file2,
|
|
185859
|
+
function write(file2, bytes) {
|
|
185469
185860
|
fs58.mkdirSync(path60.dirname(file2), { recursive: true });
|
|
185470
|
-
fs58.writeFileSync(file2,
|
|
185861
|
+
fs58.writeFileSync(file2, bytes);
|
|
185471
185862
|
}
|
|
185472
185863
|
function readText(file2) {
|
|
185473
185864
|
try {
|
|
@@ -185516,53 +185907,79 @@ var localFiles = (ws, base) => {
|
|
|
185516
185907
|
const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path60.join(ws.board, assetsFile(ws.task))))]);
|
|
185517
185908
|
return filesUnder(ws.board, ws.board, path60.join(ws.board, "deliveries")).filter((p2) => kept3(p2) && !assets.has(p2));
|
|
185518
185909
|
};
|
|
185519
|
-
|
|
185520
|
-
|
|
185521
|
-
|
|
185522
|
-
|
|
185523
|
-
const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs58.existsSync(path60.join(ws.cwd, root2, skill)));
|
|
185524
|
-
const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
|
|
185525
|
-
const skills = {};
|
|
185526
|
-
for (const [name, text4] of Object.entries(files)) {
|
|
185527
|
-
const at2 = SKILL_PATH.exec(name);
|
|
185528
|
-
if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
|
|
185529
|
-
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;
|
|
185530
185914
|
for (const root2 of SKILL_ROOTS) {
|
|
185531
|
-
const
|
|
185532
|
-
|
|
185533
|
-
|
|
185534
|
-
|
|
185535
|
-
|
|
185536
|
-
|
|
185537
|
-
|
|
185538
|
-
|
|
185539
|
-
|
|
185540
|
-
fs58.rmSync(
|
|
185541
|
-
|
|
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
|
+
}
|
|
185542
185932
|
}
|
|
185543
185933
|
}
|
|
185544
|
-
|
|
185545
|
-
|
|
185546
|
-
let mcp = {};
|
|
185934
|
+
}
|
|
185935
|
+
function studioMcp(files) {
|
|
185547
185936
|
try {
|
|
185548
|
-
|
|
185937
|
+
return JSON.parse(files["mcp.json"] ?? "{}").mcpServers ?? {};
|
|
185549
185938
|
} catch {
|
|
185939
|
+
return {};
|
|
185550
185940
|
}
|
|
185551
|
-
record2.tools = { skills, mcp };
|
|
185552
185941
|
}
|
|
185553
|
-
var mcpServersOf = (ws) =>
|
|
185554
|
-
|
|
185555
|
-
const
|
|
185556
|
-
|
|
185557
|
-
|
|
185558
|
-
|
|
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 };
|
|
185559
185973
|
}
|
|
185560
185974
|
async function pullStudio(ws, record2) {
|
|
185561
185975
|
if (ws.cloudTask === ws.task) {
|
|
185562
185976
|
record2.builtin = ws.studio?.startsWith("wf_builtin_") ?? false;
|
|
185563
|
-
const files = await studioFiles2(ws
|
|
185564
|
-
if (!files.ok && files.code !== "not_found") return files;
|
|
185565
|
-
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
|
+
}
|
|
185566
185983
|
}
|
|
185567
185984
|
dropPlacedAgents(ws);
|
|
185568
185985
|
for (const name of Object.keys(record2.agents ?? {})) fs58.rmSync(path60.join(ws.board, name), { force: true });
|
|
@@ -185974,14 +186391,14 @@ async function pullAssets(ws, record2, assets, preserve = false, stopped2) {
|
|
|
185974
186391
|
out[name] = { ...held5, kind };
|
|
185975
186392
|
continue;
|
|
185976
186393
|
}
|
|
185977
|
-
const
|
|
185978
|
-
if (!
|
|
185979
|
-
if (!
|
|
186394
|
+
const bytes = await readAsset(ref.artifact, version2);
|
|
186395
|
+
if (!bytes.ok && unavailable2(bytes)) continue;
|
|
186396
|
+
if (!bytes.ok && bytes.code === "not_found") {
|
|
185980
186397
|
if (held5) out[name] = held5;
|
|
185981
186398
|
continue;
|
|
185982
186399
|
}
|
|
185983
|
-
if (!
|
|
185984
|
-
let local =
|
|
186400
|
+
if (!bytes.ok) return bytes;
|
|
186401
|
+
let local = bytes.value;
|
|
185985
186402
|
const dependencies = [];
|
|
185986
186403
|
const manifest = fileManifest(kind, name);
|
|
185987
186404
|
let data;
|
|
@@ -186035,7 +186452,7 @@ async function pullAssets(ws, record2, assets, preserve = false, stopped2) {
|
|
|
186035
186452
|
continue;
|
|
186036
186453
|
}
|
|
186037
186454
|
write(target, local);
|
|
186038
|
-
const hash2 = hashOf2(typeof data === "string" ? local :
|
|
186455
|
+
const hash2 = hashOf2(typeof data === "string" ? local : bytes.value);
|
|
186039
186456
|
out[name] = { ...held5, kind, dependencies: [...new Set(dependencies)], artifact: ref.artifact, version: version2, hash: hash2, localHash: hashOf2(local) };
|
|
186040
186457
|
}
|
|
186041
186458
|
record2.assets = out;
|
|
@@ -186096,19 +186513,19 @@ function undrawn(ws, reason) {
|
|
|
186096
186513
|
}
|
|
186097
186514
|
return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
|
|
186098
186515
|
}
|
|
186099
|
-
async function uploadAsset(artifact, { bytes
|
|
186100
|
-
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));
|
|
186101
186518
|
if (!upload2.ok) return upload2;
|
|
186102
186519
|
const { id: id2, url: url2, parts } = upload2.value;
|
|
186103
186520
|
if (parts) {
|
|
186104
186521
|
for (let part = 1; part <= parts.count; part++) {
|
|
186105
|
-
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);
|
|
186106
186523
|
if (!put.ok) return put;
|
|
186107
186524
|
}
|
|
186108
186525
|
const done = await completeUpload(url2 ?? `/v1/uploads/${encodeURIComponent(id2)}/complete`);
|
|
186109
186526
|
if (!done.ok) return done;
|
|
186110
186527
|
} else {
|
|
186111
|
-
const put = await upload(url2 ?? `/v1/uploads/${encodeURIComponent(id2)}`,
|
|
186528
|
+
const put = await upload(url2 ?? `/v1/uploads/${encodeURIComponent(id2)}`, bytes, type);
|
|
186112
186529
|
if (!put.ok) return put;
|
|
186113
186530
|
}
|
|
186114
186531
|
return { ok: true, value: id2 };
|
|
@@ -186134,19 +186551,19 @@ async function pushDocumentPreview(ws, record2, key, ext, source2) {
|
|
|
186134
186551
|
record2.pendingVersions ??= {};
|
|
186135
186552
|
let pending = record2.pendingVersions[key];
|
|
186136
186553
|
if (!pending) {
|
|
186137
|
-
let
|
|
186554
|
+
let bytes;
|
|
186138
186555
|
try {
|
|
186139
186556
|
const { renderOfficePdf: renderOfficePdf2 } = await Promise.resolve().then(() => (init_document_preview(), document_preview_exports));
|
|
186140
|
-
|
|
186557
|
+
bytes = await renderOfficePdf2(source2, ext);
|
|
186141
186558
|
} catch (error62) {
|
|
186142
186559
|
logSync("assets.documentPreviewUnavailable", { project: ws.project, task: ws.task, reason: error62 instanceof Error ? error62.message : String(error62) });
|
|
186143
186560
|
return { ok: true, value: void 0 };
|
|
186144
186561
|
}
|
|
186145
186562
|
const made = await createArtifact(ws.cloudTask, key, "asset", artifactKey(ws.cloudTask, key, "asset"));
|
|
186146
186563
|
if (!made.ok) return made;
|
|
186147
|
-
const sent = await uploadAsset(made.value.id, { bytes
|
|
186564
|
+
const sent = await uploadAsset(made.value.id, { bytes, type: PDF, kind: "asset" });
|
|
186148
186565
|
if (!sent.ok) return sent;
|
|
186149
|
-
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 };
|
|
186150
186567
|
writeRecord(ws, record2);
|
|
186151
186568
|
}
|
|
186152
186569
|
const version2 = await finishAssetVersion(ws, record2, key, pending);
|
|
@@ -186391,7 +186808,7 @@ async function whenPrepared(ws, cancelled, work, stopped2 = () => false) {
|
|
|
186391
186808
|
if (!busy(preparationKey(ws))) return { value: await work() };
|
|
186392
186809
|
});
|
|
186393
186810
|
if (result) return result.value;
|
|
186394
|
-
await
|
|
186811
|
+
await delay3(100);
|
|
186395
186812
|
}
|
|
186396
186813
|
return cancelled;
|
|
186397
186814
|
}
|
|
@@ -186912,12 +187329,16 @@ async function reconcileArchives(ws, base, archives, pending, machine) {
|
|
|
186912
187329
|
}
|
|
186913
187330
|
function taskStudio(ws) {
|
|
186914
187331
|
if (!ws.cloudTask) return null;
|
|
186915
|
-
const pin = readPin(ws.cloudTask), held5 = pin && readVersion2(pin.studio, pin.version);
|
|
186916
|
-
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.");
|
|
186917
187334
|
const read5 = parseStudioFile(studioName(held5.id), held5.files["STUDIO.md"] ?? "", "STUDIO.md");
|
|
186918
187335
|
if ("problem" in read5) throw new Error(read5.problem);
|
|
186919
187336
|
return { held: held5, def: read5.def };
|
|
186920
187337
|
}
|
|
187338
|
+
function taskStudioSkills(ws) {
|
|
187339
|
+
const studio2 = taskStudio(ws);
|
|
187340
|
+
return studio2 ? cachedStudioSkillBlock(studio2.held) : "";
|
|
187341
|
+
}
|
|
186921
187342
|
var taskStudioPreviews = (ws) => taskStudio(ws)?.def.previews;
|
|
186922
187343
|
var taskConfig = (ws, id2, setup) => studioConfigContext(id2, setup, (file2) => readText(path60.join(ws.board, file2)) ?? void 0);
|
|
186923
187344
|
function taskSetupContext(ws) {
|
|
@@ -186974,6 +187395,8 @@ function syncRefusal(job, failure2) {
|
|
|
186974
187395
|
return zh ? "\u6BCF\u65E5\u5199\u5165\u989D\u5EA6\u4E8E UTC \u96F6\u70B9\u6062\u590D\u3002" : "The daily write allowance resets at midnight UTC.";
|
|
186975
187396
|
case "bad_request":
|
|
186976
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;
|
|
186977
187400
|
case "board_content_conflict":
|
|
186978
187401
|
case "version_conflict":
|
|
186979
187402
|
return zh ? "\u8BF7\u5904\u7406\u770B\u677F\u540C\u6B65\u51B2\u7A81\u3002" : "Resolve the board sync conflict.";
|
|
@@ -187014,7 +187437,7 @@ function sourceOf(pins, source2, owner2) {
|
|
|
187014
187437
|
async function stageSavedPreviews(directory3, ws, review, inputs, stopped2) {
|
|
187015
187438
|
const sections = [];
|
|
187016
187439
|
const contexts = /* @__PURE__ */ new Set();
|
|
187017
|
-
const
|
|
187440
|
+
const invalid2 = (name) => {
|
|
187018
187441
|
const error62 = `Missing or invalid saved review evidence: ${name}`;
|
|
187019
187442
|
return { ok: false, code: "bad_request", error: error62, failure: makeFailure("validation", error62) };
|
|
187020
187443
|
};
|
|
@@ -187038,7 +187461,7 @@ async function stageSavedPreviews(directory3, ws, review, inputs, stopped2) {
|
|
|
187038
187461
|
};
|
|
187039
187462
|
if (error62 || status === "pending" || status === "failed" || typeof artifact !== "string" || !artifactId.test(artifact) || typeof version2 !== "number" || !Number.isSafeInteger(version2) || version2 < 1) {
|
|
187040
187463
|
const missingEvidence = review.plan?.length && types.length && !local2 && (error62 || status === "pending" || status === "failed" || !artifact);
|
|
187041
|
-
if (conflicting.has(source2) || missingEvidence) return
|
|
187464
|
+
if (conflicting.has(source2) || missingEvidence) return invalid2(`${title} \xB7 ${source2}`);
|
|
187042
187465
|
return saved(typeof error62 === "string" ? error62 : artifact ? "Missing approved asset version." : "Missing asset record.");
|
|
187043
187466
|
}
|
|
187044
187467
|
const extension = path61.posix.extname(splitFileReference(source2)[0]).toLowerCase();
|
|
@@ -187047,18 +187470,18 @@ async function stageSavedPreviews(directory3, ws, review, inputs, stopped2) {
|
|
|
187047
187470
|
let kind = types.includes("tiled") ? "tiled" : !extension ? localPin?.kind ?? detected : detected;
|
|
187048
187471
|
const matches = local2 && localPin?.version === version2;
|
|
187049
187472
|
const issue2 = ws.materialIssues?.[source2];
|
|
187050
|
-
const
|
|
187051
|
-
if (!
|
|
187052
|
-
if (["unauthenticated", "forbidden", "unauthorized", "permission_denied"].includes(
|
|
187053
|
-
if (conflicting.has(source2)) return
|
|
187054
|
-
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);
|
|
187055
187478
|
}
|
|
187056
187479
|
const basename = path61.posix.basename(splitFileReference(source2)[0]).replace(/[^\w. -]/g, "_");
|
|
187057
187480
|
const name = extension ? basename : basename + ({ html: ".html", storyboard: ".json", spritesheet: ".json", studio: ".json" }[kind] ?? "");
|
|
187058
187481
|
const copy2 = path61.join(folder2, `${files.size + 1}-${name.replace(/\.tsx$/i, kind === "html" ? ".html" : ".tsx")}`);
|
|
187059
187482
|
const entry = { file: matches ? local2.file : copy2, note: "" };
|
|
187060
187483
|
files.set(source2, entry);
|
|
187061
|
-
let content =
|
|
187484
|
+
let content = bytes.value;
|
|
187062
187485
|
const knownManifest = fileManifest(kind, source2);
|
|
187063
187486
|
let data = knownManifest?.references || extension === ".json" || !extension && types.length ? Buffer.from(content).toString() : void 0;
|
|
187064
187487
|
if (extension === ".json" || !extension && types.length) {
|
|
@@ -187133,7 +187556,7 @@ ${body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : "
|
|
|
187133
187556
|
const stages = new Map(review.stages.map((stage) => [stage.id, stage]));
|
|
187134
187557
|
for (const node2 of review.plan) {
|
|
187135
187558
|
const stage = stages.get(node2.id);
|
|
187136
|
-
if (!stage || !["approved", "done"].includes(stage.status)) return
|
|
187559
|
+
if (!stage || !["approved", "done"].includes(stage.status)) return invalid2(node2.id);
|
|
187137
187560
|
const snapshot = stage.snapshot;
|
|
187138
187561
|
if (!snapshot && !node2.previews.length) continue;
|
|
187139
187562
|
const evidence = object2(snapshot?.evidence);
|
|
@@ -187151,7 +187574,7 @@ ${body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : "
|
|
|
187151
187574
|
for (const id2 of node2.previews) {
|
|
187152
187575
|
const section = object2(own2(content, id2));
|
|
187153
187576
|
const saved = typeof section.body === "string" ? section.body : blocks.find((block) => block.id === id2)?.instructions;
|
|
187154
|
-
if (!saved?.trim()) return
|
|
187577
|
+
if (!saved?.trim()) return invalid2(`${title} \xB7 ${id2}`);
|
|
187155
187578
|
const legacyPins = object2(frozen.find((preview) => preview.id === id2)?.assets);
|
|
187156
187579
|
add2(`${title} \xB7 ${id2}`, saved, { ...legacyPins, ...pins }, section.sources);
|
|
187157
187580
|
}
|
|
@@ -187208,9 +187631,9 @@ import fs60 from "node:fs";
|
|
|
187208
187631
|
import path62 from "node:path";
|
|
187209
187632
|
|
|
187210
187633
|
// ../cli/src/lib/signals/identity.ts
|
|
187211
|
-
import { createHash as
|
|
187634
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
187212
187635
|
var DERIVED = "derived-";
|
|
187213
|
-
var derivedSourceId = (seed) => `${DERIVED}${
|
|
187636
|
+
var derivedSourceId = (seed) => `${DERIVED}${createHash6("sha256").update(seed).digest("hex").slice(0, 16)}`;
|
|
187214
187637
|
|
|
187215
187638
|
// src/triage.ts
|
|
187216
187639
|
var triageDir = (board) => path62.join(board, "triage");
|
|
@@ -187480,6 +187903,7 @@ function boardAkb(job, ws, deps, io, task) {
|
|
|
187480
187903
|
AI4KANBAN_SYNC_DIAGNOSTIC: io.diagnostic,
|
|
187481
187904
|
AI4KANBAN_REVIEW_STAGES: job.flow?.review_stages ? JSON.stringify(job.flow.review_stages) : void 0,
|
|
187482
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,
|
|
187483
187907
|
AI4KANBAN_EXECUTION: JSON.stringify({ job: job.id, machine: deps.machineId })
|
|
187484
187908
|
}
|
|
187485
187909
|
});
|
|
@@ -188385,7 +188809,7 @@ function replySpent(checkpoint, runtime) {
|
|
|
188385
188809
|
}
|
|
188386
188810
|
|
|
188387
188811
|
// src/jobs.ts
|
|
188388
|
-
import { createHash as
|
|
188812
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
188389
188813
|
|
|
188390
188814
|
// src/conversation-progress.ts
|
|
188391
188815
|
function conversationProgress(attempt, send3, valid, unconfirmed) {
|
|
@@ -188508,7 +188932,7 @@ import fs65 from "node:fs";
|
|
|
188508
188932
|
import path67 from "node:path";
|
|
188509
188933
|
import os8 from "node:os";
|
|
188510
188934
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
188511
|
-
import { createHash as
|
|
188935
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
188512
188936
|
init_file_limits();
|
|
188513
188937
|
var inside2 = (root2, file2) => {
|
|
188514
188938
|
const p2 = path67.relative(root2, file2);
|
|
@@ -188546,10 +188970,10 @@ function collectReplyImages(parts, cwd) {
|
|
|
188546
188970
|
}));
|
|
188547
188971
|
const image = (p2) => {
|
|
188548
188972
|
const read5 = () => {
|
|
188549
|
-
let
|
|
188973
|
+
let bytes;
|
|
188550
188974
|
if (p2.data !== void 0) {
|
|
188551
188975
|
if (p2.data.length > ASSET_FILE_LIMIT * 4 / 3 + 4 || !/^[A-Za-z0-9+/]*={0,2}$/.test(p2.data)) throw Error();
|
|
188552
|
-
|
|
188976
|
+
bytes = Buffer.from(p2.data, "base64");
|
|
188553
188977
|
} else {
|
|
188554
188978
|
if (!p2.path) throw Error();
|
|
188555
188979
|
const source2 = p2.path.startsWith("file:") ? fileURLToPath4(p2.path) : decodeURIComponent(p2.path);
|
|
@@ -188561,18 +188985,18 @@ function collectReplyImages(parts, cwd) {
|
|
|
188561
188985
|
try {
|
|
188562
188986
|
const stat2 = fs65.fstatSync(fd);
|
|
188563
188987
|
if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) throw Error();
|
|
188564
|
-
|
|
188988
|
+
bytes = fs65.readFileSync(fd);
|
|
188565
188989
|
} finally {
|
|
188566
188990
|
fs65.closeSync(fd);
|
|
188567
188991
|
}
|
|
188568
188992
|
}
|
|
188569
|
-
return
|
|
188993
|
+
return bytes;
|
|
188570
188994
|
};
|
|
188571
188995
|
try {
|
|
188572
|
-
const
|
|
188573
|
-
const mime = imageMime(
|
|
188574
|
-
if (!mime || p2.mime && p2.mime !== mime ||
|
|
188575
|
-
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")}`;
|
|
188576
189000
|
if (!files.has(id2)) files.set(id2, { read: read5, mime });
|
|
188577
189001
|
return { type: "image", id: id2, mime, status: "saved" };
|
|
188578
189002
|
} catch {
|
|
@@ -188624,15 +189048,15 @@ async function saveReplyImages(parts, cwd, upload2) {
|
|
|
188624
189048
|
if (!read5.parts.some((p2) => p2.type === "image")) return void 0;
|
|
188625
189049
|
const saved = /* @__PURE__ */ new Map();
|
|
188626
189050
|
for (const [key, f2] of read5.files) {
|
|
188627
|
-
let
|
|
189051
|
+
let bytes;
|
|
188628
189052
|
try {
|
|
188629
|
-
|
|
188630
|
-
if (`rim_${
|
|
189053
|
+
bytes = f2.read();
|
|
189054
|
+
if (`rim_${createHash7("sha256").update(bytes).digest("hex")}` !== key || imageMime(bytes) !== f2.mime) continue;
|
|
188631
189055
|
} catch {
|
|
188632
189056
|
continue;
|
|
188633
189057
|
}
|
|
188634
189058
|
try {
|
|
188635
|
-
saved.set(key, await upload2(key.slice(4),
|
|
189059
|
+
saved.set(key, await upload2(key.slice(4), bytes, f2.mime));
|
|
188636
189060
|
} catch {
|
|
188637
189061
|
}
|
|
188638
189062
|
}
|
|
@@ -188644,10 +189068,10 @@ async function saveReplyImages(parts, cwd, upload2) {
|
|
|
188644
189068
|
}
|
|
188645
189069
|
|
|
188646
189070
|
// src/reply-input.ts
|
|
188647
|
-
import { createHash as
|
|
189071
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
188648
189072
|
import fs66 from "node:fs";
|
|
188649
189073
|
import path68 from "node:path";
|
|
188650
|
-
var fingerprint = (text4) =>
|
|
189074
|
+
var fingerprint = (text4) => createHash8("sha256").update(text4).digest("hex");
|
|
188651
189075
|
var CARD_CHAT_GUIDE = "Follow `akb guide card-chat`.";
|
|
188652
189076
|
function replyPrompt(input2, turn2) {
|
|
188653
189077
|
const parts = [...turn2.diagnostics];
|
|
@@ -188658,6 +189082,7 @@ function replyPrompt(input2, turn2) {
|
|
|
188658
189082
|
const { task, initialize } = turn2;
|
|
188659
189083
|
if (initialize) {
|
|
188660
189084
|
parts.push(task ? CARD_CHAT_GUIDE : "Follow `akb guide discuss-goal` for this Goal discussion.");
|
|
189085
|
+
if (turn2.skills) parts.push(turn2.skills);
|
|
188661
189086
|
if (task) parts.push(`Task card: ${task.card}`);
|
|
188662
189087
|
if (turn2.historyFile) parts.push(`Consult the ${task ? "chat" : "discussion"} history at \`${turn2.historyFile}\` as needed.`);
|
|
188663
189088
|
if (turn2.goals) parts.push(replyGoals(turn2.goals));
|
|
@@ -188714,7 +189139,7 @@ function replyGoals(goals) {
|
|
|
188714
189139
|
|
|
188715
189140
|
// src/handoff.ts
|
|
188716
189141
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
188717
|
-
import
|
|
189142
|
+
import crypto6 from "node:crypto";
|
|
188718
189143
|
import fs67 from "node:fs";
|
|
188719
189144
|
import path69 from "node:path";
|
|
188720
189145
|
var gitRead = (cwd, args2) => {
|
|
@@ -188729,7 +189154,7 @@ var gitRead = (cwd, args2) => {
|
|
|
188729
189154
|
return null;
|
|
188730
189155
|
}
|
|
188731
189156
|
};
|
|
188732
|
-
var digest = (value) =>
|
|
189157
|
+
var digest = (value) => crypto6.createHash("sha256").update(value).digest("hex");
|
|
188733
189158
|
function authorizedFolder(folder2) {
|
|
188734
189159
|
if (!folder2) return null;
|
|
188735
189160
|
try {
|
|
@@ -188857,9 +189282,9 @@ import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
|
188857
189282
|
|
|
188858
189283
|
// src/reply-approval.ts
|
|
188859
189284
|
import http from "node:http";
|
|
188860
|
-
import
|
|
189285
|
+
import crypto7 from "node:crypto";
|
|
188861
189286
|
async function replyApprovalBridge(task, number4, approve) {
|
|
188862
|
-
const token =
|
|
189287
|
+
const token = crypto7.randomBytes(32).toString("hex");
|
|
188863
189288
|
let serial = Promise.resolve();
|
|
188864
189289
|
const server = http.createServer((req, res) => {
|
|
188865
189290
|
const answer = (status, body) => {
|
|
@@ -189046,14 +189471,14 @@ import path73 from "node:path";
|
|
|
189046
189471
|
|
|
189047
189472
|
// ../cli/src/lib/goal-draft.ts
|
|
189048
189473
|
import fs71 from "node:fs";
|
|
189049
|
-
import { randomUUID as
|
|
189474
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
189050
189475
|
function readGoalDraft(file2) {
|
|
189051
189476
|
const draft = JSON.parse(fs71.readFileSync(file2, "utf8"));
|
|
189052
189477
|
if (!Array.isArray(draft?.goals)) throw new Error("The goals array is missing or invalid.");
|
|
189053
189478
|
return draft;
|
|
189054
189479
|
}
|
|
189055
189480
|
function writeGoalDraft(file2, draft) {
|
|
189056
|
-
const temporary = `${file2}.${
|
|
189481
|
+
const temporary = `${file2}.${randomUUID6()}.tmp`;
|
|
189057
189482
|
try {
|
|
189058
189483
|
fs71.writeFileSync(temporary, `${JSON.stringify(draft, null, 2)}
|
|
189059
189484
|
`, { mode: 384, flag: "wx" });
|
|
@@ -189617,11 +190042,11 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189617
190042
|
let report2 = before ? { ...before, ...said2 } : said2;
|
|
189618
190043
|
if (reply && checkpoint.replyParts && report2) {
|
|
189619
190044
|
const stream2 = watching();
|
|
189620
|
-
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) => {
|
|
189621
190046
|
const saved = checkpoint.replyImages?.job === id2 ? checkpoint.replyImages.files[key] : void 0;
|
|
189622
190047
|
if (saved) return saved;
|
|
189623
190048
|
if (outcome !== "done" || report2?.stopped || checkpoint.syncFailure || stream2.asked() || stream2.lost()) return { status: "not_saved" };
|
|
189624
|
-
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));
|
|
189625
190050
|
if (!uploaded.ok) return { status: "not_saved" };
|
|
189626
190051
|
if (checkpoint.replyImages?.job !== id2) checkpoint.replyImages = { job: id2, files: {} };
|
|
189627
190052
|
checkpoint.replyImages.files[key] = uploaded.value;
|
|
@@ -189634,7 +190059,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
189634
190059
|
}
|
|
189635
190060
|
if (outcome === "failed" && checkpoint.syncFailure) {
|
|
189636
190061
|
const { failure: failure3, pause, safe: safe3 } = checkpoint.syncFailure;
|
|
189637
|
-
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);
|
|
189638
190063
|
report2 = { ...report2, failure: buildFailureDetail(failure3, pause, safe3), ...recovery2 ? { recovery: recovery2 } : {} };
|
|
189639
190064
|
if (pause === "limit" && job.flow) reason = "task_retry_exhausted: " + failure3.summary;
|
|
189640
190065
|
else reason = failure3.summary;
|
|
@@ -190157,11 +190582,13 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
190157
190582
|
const stream2 = watching();
|
|
190158
190583
|
return sendBack(publishingJob, deps, ws, completed, sync, stream2, finishClaimed, landed, async (pushed) => {
|
|
190159
190584
|
const records = pushed.conflict ? pendingConflicts(ws.board) : [];
|
|
190160
|
-
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");
|
|
190161
190586
|
const failRepair = async (reason) => {
|
|
190162
190587
|
if (!stream2.asked()) stream2.event({ kind: "error", data: { text: reason } });
|
|
190163
190588
|
await stream2.end();
|
|
190164
|
-
if (
|
|
190589
|
+
if (stream2.lost()) return;
|
|
190590
|
+
if (stream2.asked()) return finishClaimed("stopped", "", completed);
|
|
190591
|
+
return finishClaimed("failed", reason, writebackRecovery(job, completed));
|
|
190165
190592
|
};
|
|
190166
190593
|
if (pushed.conflict && !records.length) {
|
|
190167
190594
|
console.error(JSON.stringify({ code: "board_conflict_missing", phase: "publish-result", job: id2, task: job.task, project: job.project }));
|
|
@@ -190253,6 +190680,13 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190253
190680
|
}
|
|
190254
190681
|
} else if (task) {
|
|
190255
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
|
+
};
|
|
190256
190690
|
cwd = ws.cwd;
|
|
190257
190691
|
keep2(cwd);
|
|
190258
190692
|
if (usesBoardRun(job, checkpoint) && !verification && !await recoverBoard(ws)) {
|
|
@@ -190350,6 +190784,7 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190350
190784
|
const assembled = replyPrompt(replyInput, {
|
|
190351
190785
|
initialize,
|
|
190352
190786
|
historyFile,
|
|
190787
|
+
skills: !continuing && fresh && ws && job.chat ? taskStudioSkills(ws) : "",
|
|
190353
190788
|
...ws && job.chat ? { task: { card: cardFile3(ws), review: job.taskReview, setup: continuing ? null : taskSetupContext(ws) } } : {},
|
|
190354
190789
|
goals: discussion && (discussion.goals.length || historyFile || replay || job.sessionFallback || job.resume) ? discussion.goals : void 0,
|
|
190355
190790
|
diagnostics: [syncDiagnostic, conflicts],
|
|
@@ -190368,7 +190803,7 @@ The original session is unavailable. Saved work was preserved.`);
|
|
|
190368
190803
|
|
|
190369
190804
|
This task came out of a discussion. Read it for what the card leaves out: ${file2}` : "";
|
|
190370
190805
|
const previews = ws && !job.agent && job.taskReview?.preview_definitions?.length ? taskStudioPreviews(ws) : void 0;
|
|
190371
|
-
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) : "");
|
|
190372
190807
|
const submitted = recoveringTurn && checkpoint.submitted === true;
|
|
190373
190808
|
const body = recoveringTurn ? [submitted ? "" : job.prompt, recovery2].filter(Boolean).join("\n\n") : job.prompt;
|
|
190374
190809
|
const withHead = (text4) => text4.trim() ? `${text4.trim()}
|
|
@@ -190387,7 +190822,7 @@ ${body}` : body;
|
|
|
190387
190822
|
if (ws) p2 = { ...p2, env: akbEnv(deps.akb, ws.board, ws.cloudTask ?? void 0, cloudLanguage(job), p2.env) };
|
|
190388
190823
|
if (scope.bridge) p2 = { ...p2, env: { ...p2.env, AI4KANBAN_REPLY_APPROVAL: scope.bridge.env } };
|
|
190389
190824
|
if (goalFile) p2 = { ...p2, env: { ...akbEnv(deps.akb, discussed, void 0, cloudLanguage(job), p2.env), KANBAN_GOALS: goalFile } };
|
|
190390
|
-
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) };
|
|
190391
190826
|
const fallback = p2.fallback;
|
|
190392
190827
|
return { ...p2, env: env2, fallback: fallback && (() => configure(fallback())) };
|
|
190393
190828
|
};
|
|
@@ -190503,6 +190938,12 @@ ${body}` : body;
|
|
|
190503
190938
|
const progressValid = () => !stream.asked() && !stream.lost() && readSession()?.subject === account && accountGeneration() === generation;
|
|
190504
190939
|
const subagents = trackSubagents();
|
|
190505
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
|
+
};
|
|
190506
190947
|
const remember = (event2) => {
|
|
190507
190948
|
idleWatch?.event(event2);
|
|
190508
190949
|
if (stream.lost()) return;
|
|
@@ -190521,7 +190962,10 @@ ${body}` : body;
|
|
|
190521
190962
|
checkpoint.partialReply = messages.join("\n\n");
|
|
190522
190963
|
}
|
|
190523
190964
|
const session = run3?.session();
|
|
190524
|
-
if (session && (!job.fork || session !== forkSource))
|
|
190965
|
+
if (session && (!job.fork || session !== forkSource)) {
|
|
190966
|
+
checkpoint.session = session;
|
|
190967
|
+
bindStudioSession(session);
|
|
190968
|
+
}
|
|
190525
190969
|
if (attempt && !run3?.converse) measure(report(job, run3));
|
|
190526
190970
|
persist();
|
|
190527
190971
|
stream.event(event2);
|
|
@@ -190560,6 +191004,7 @@ ${body}` : body;
|
|
|
190560
191004
|
if (outcome === "failed" && stream.lost()) return;
|
|
190561
191005
|
checkpoint.completed = { outcome, report: report2, reason };
|
|
190562
191006
|
checkpoint.session = report2.session ?? checkpoint.session;
|
|
191007
|
+
bindStudioSession(report2.session);
|
|
190563
191008
|
persist();
|
|
190564
191009
|
};
|
|
190565
191010
|
const told = (report2) => {
|
|
@@ -191031,11 +191476,17 @@ var held4 = (deps, lease) => {
|
|
|
191031
191476
|
if (Math.max(Date.now() - lease.at, performance.now() - lease.monotonic) >= deps.leaseMs) lease.lost = true;
|
|
191032
191477
|
return !lease.lost;
|
|
191033
191478
|
};
|
|
191479
|
+
function writebackRecovery(job, report2) {
|
|
191480
|
+
return job.chat && !job.flow ? { ...report2, recovery: { safe: false, stopped: true, resumable: true, writeback: true } } : report2;
|
|
191481
|
+
}
|
|
191034
191482
|
async function sendBack(job, deps, ws, report2, sync, stream, finish, landed, repair, confirm) {
|
|
191035
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;
|
|
191036
191485
|
const result = await sync("publish", async () => {
|
|
191037
191486
|
const pushed2 = await push(ws, { id: job.id, machineId: deps.machineId }, () => stream.asked() || stream.lost());
|
|
191038
|
-
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
|
+
}
|
|
191039
191490
|
if (!pushed2.ok && writeBlock(pushed2)) return pushed2;
|
|
191040
191491
|
return !pushed2.ok && pushed2.offline ? { ok: false, error: pushed2.error, code: "service_unavailable" } : { ok: true, value: pushed2 };
|
|
191041
191492
|
});
|
|
@@ -191054,10 +191505,15 @@ async function sendBack(job, deps, ws, report2, sync, stream, finish, landed, re
|
|
|
191054
191505
|
if (stream.asked()) return finish("stopped", "", report2);
|
|
191055
191506
|
if (denied) {
|
|
191056
191507
|
console.error("runner: task sync refused", { job: job.id, code: denied.code, error: denied.error });
|
|
191057
|
-
return finish("failed", syncRefusal(job, denied), report2);
|
|
191508
|
+
return finish("failed", syncRefusal(job, denied), writebackRecovery(job, report2));
|
|
191058
191509
|
}
|
|
191059
191510
|
const archive = closesTask && report2.deliveryId ? syncedArchive(ws) : void 0;
|
|
191060
|
-
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);
|
|
191061
191517
|
}
|
|
191062
191518
|
var settingsOf = (job) => ({ settings: job.settings, secrets: secretsOf(job.runtimeId) });
|
|
191063
191519
|
async function runSecret(job, deps) {
|
|
@@ -191176,6 +191632,7 @@ ${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
|
|
|
191176
191632
|
}
|
|
191177
191633
|
|
|
191178
191634
|
// src/flow-worker.ts
|
|
191635
|
+
var CLAIM_BACKOFF_MS = [1e3, 2e3, 5e3, 1e4, 3e4];
|
|
191179
191636
|
var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
|
|
191180
191637
|
var directory2 = () => path75.join(runnerHome(), "flow-workers");
|
|
191181
191638
|
var fileOf3 = (id2) => path75.join(directory2(), `${encodeURIComponent(id2)}.json`);
|
|
@@ -191237,10 +191694,10 @@ async function reclaimFlowWorkerAfterExit(id2, machine, given, token) {
|
|
|
191237
191694
|
}
|
|
191238
191695
|
}
|
|
191239
191696
|
var reclaiming;
|
|
191240
|
-
async function reclaimFlowWorkers(machine, given, only) {
|
|
191697
|
+
async function reclaimFlowWorkers(machine, given, only, retryWaiting = false) {
|
|
191241
191698
|
if (reclaiming) {
|
|
191242
191699
|
await reclaiming;
|
|
191243
|
-
if (only) return reclaimFlowWorkers(machine, given, only);
|
|
191700
|
+
if (only) return reclaimFlowWorkers(machine, given, only, retryWaiting);
|
|
191244
191701
|
return;
|
|
191245
191702
|
}
|
|
191246
191703
|
const account = readSession()?.subject;
|
|
@@ -191260,7 +191717,7 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191260
191717
|
const file2 = path75.join(directory2(), name);
|
|
191261
191718
|
const original = fs74.readFileSync(file2, "utf8");
|
|
191262
191719
|
const worker = JSON.parse(original);
|
|
191263
|
-
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;
|
|
191264
191721
|
if (!writerStopped(worker)) {
|
|
191265
191722
|
if (!only) void reclaimFlowWorkerAfterExit(worker.id, machine, given);
|
|
191266
191723
|
continue;
|
|
@@ -191275,10 +191732,18 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191275
191732
|
if (!valid()) break;
|
|
191276
191733
|
if (!remote3.ok || remote3.value.job.id !== worker.id || !canKeepFlow(remote3.value.job)) continue;
|
|
191277
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;
|
|
191278
191744
|
if (worker.generation === generation && (job.state === "claimed" || job.state === "interrupted")) {
|
|
191279
191745
|
const runner = await readRunner();
|
|
191280
191746
|
if (!runner.ok || runner.value.runner?.machineId && runner.value.runner.machineId !== machine || !valid()) continue;
|
|
191281
|
-
const checkpoint = readCheckpoint(worker.id);
|
|
191282
191747
|
const deps = given ?? defaultDeps(machine);
|
|
191283
191748
|
const folder2 = job.projectDir ? folderFor(job) : null;
|
|
191284
191749
|
if (folder2 && "refused" in folder2) continue;
|
|
@@ -191289,10 +191754,12 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191289
191754
|
checkpoint.flowRun = evidence.run;
|
|
191290
191755
|
stopped2 = evidence.stopped;
|
|
191291
191756
|
}
|
|
191292
|
-
if (!valid() || !writerStopped(worker)) continue;
|
|
191293
|
-
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);
|
|
191294
191761
|
if (!recovered?.resumed && !recovered?.finished) continue;
|
|
191295
|
-
} else if (job.state !== "finished" && !(job.state === "waiting" &&
|
|
191762
|
+
} else if (job.state !== "finished" && !retry2 && !(job.state === "waiting" && updating)) continue;
|
|
191296
191763
|
if (!worker.markedAt) {
|
|
191297
191764
|
const job2 = remote3.value.job;
|
|
191298
191765
|
const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path75.join(runnerHome(), "work", job2.id) };
|
|
@@ -191313,14 +191780,24 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191313
191780
|
job2,
|
|
191314
191781
|
{ ...deps, machineId: machine, akb: deps.akb() }
|
|
191315
191782
|
)) continue;
|
|
191316
|
-
const
|
|
191317
|
-
if (
|
|
191783
|
+
const saved = readCheckpoint(worker.id);
|
|
191784
|
+
if (saved && (!saved.mark || !processesStopped(saved.mark, saved.process))) continue;
|
|
191318
191785
|
}
|
|
191319
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
|
+
}
|
|
191320
191796
|
fs74.rmSync(`${file2}.log`, { force: true });
|
|
191321
191797
|
fs74.rmSync(`${file2}.stop`, { force: true });
|
|
191322
191798
|
fs74.unlinkSync(file2);
|
|
191323
191799
|
if (job.state === "finished" && job.outcome === "done") clearCheckpoint(job.id);
|
|
191800
|
+
if (retry2) return retry2;
|
|
191324
191801
|
} finally {
|
|
191325
191802
|
release2();
|
|
191326
191803
|
}
|
|
@@ -191331,7 +191808,7 @@ async function reclaimFlowWorkers(machine, given, only) {
|
|
|
191331
191808
|
reclaiming = sweep().finally(() => {
|
|
191332
191809
|
reclaiming = void 0;
|
|
191333
191810
|
});
|
|
191334
|
-
|
|
191811
|
+
return reclaiming;
|
|
191335
191812
|
}
|
|
191336
191813
|
async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
|
|
191337
191814
|
const worker = read4(id2);
|
|
@@ -191362,7 +191839,19 @@ async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
|
|
|
191362
191839
|
}, 100);
|
|
191363
191840
|
try {
|
|
191364
191841
|
const base = given ?? defaultDeps(worker.machine);
|
|
191365
|
-
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) => {
|
|
191366
191855
|
const runner = await readRunner();
|
|
191367
191856
|
if (runner.ok && runner.value.runner?.machineId && runner.value.runner.machineId !== worker.machine) {
|
|
191368
191857
|
return { ok: true, value: { renewed: false } };
|