@hasna/skills 0.8.11 → 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/bin/index.js +672 -435
- package/bin/mcp.js +62 -2
- package/bin/migrate.js +1 -1
- package/bin/server.js +1 -1
- package/bin/worker.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +412 -177
- package/dist/lib/agent-discovery.d.ts +1 -1
- package/dist/lib/claude-settings-witness.d.ts +19 -0
- package/dist/sdk/index.js +499 -265
- package/docs/plugin-admission.md +67 -0
- package/package.json +1 -1
package/dist/sdk/index.js
CHANGED
|
@@ -8209,7 +8209,7 @@ var require_client = __commonJS((exports) => {
|
|
|
8209
8209
|
};
|
|
8210
8210
|
};
|
|
8211
8211
|
var sleep = (seconds) => {
|
|
8212
|
-
return new Promise((
|
|
8212
|
+
return new Promise((resolve17) => setTimeout(resolve17, seconds * 1000));
|
|
8213
8213
|
};
|
|
8214
8214
|
var waiterServiceDefaults = {
|
|
8215
8215
|
minDelay: 2,
|
|
@@ -8338,8 +8338,8 @@ var require_client = __commonJS((exports) => {
|
|
|
8338
8338
|
};
|
|
8339
8339
|
var abortTimeout = (abortSignal) => {
|
|
8340
8340
|
let onAbort;
|
|
8341
|
-
const promise = new Promise((
|
|
8342
|
-
onAbort = () =>
|
|
8341
|
+
const promise = new Promise((resolve17) => {
|
|
8342
|
+
onAbort = () => resolve17({ state: WaiterState.ABORTED });
|
|
8343
8343
|
if (typeof abortSignal.addEventListener === "function") {
|
|
8344
8344
|
abortSignal.addEventListener("abort", onAbort);
|
|
8345
8345
|
} else {
|
|
@@ -9004,7 +9004,7 @@ var require_client = __commonJS((exports) => {
|
|
|
9004
9004
|
var require_config = __commonJS((exports) => {
|
|
9005
9005
|
var { homedir: homedir6 } = __require("os");
|
|
9006
9006
|
var { sep: sep7, join: join4 } = __require("path");
|
|
9007
|
-
var { createHash:
|
|
9007
|
+
var { createHash: createHash17 } = __require("crypto");
|
|
9008
9008
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
9009
9009
|
var { IniSectionType } = require_dist_cjs();
|
|
9010
9010
|
var { normalizeProvider } = require_client();
|
|
@@ -9159,7 +9159,7 @@ var require_config = __commonJS((exports) => {
|
|
|
9159
9159
|
var DEFAULT_PROFILE = "default";
|
|
9160
9160
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
9161
9161
|
var getSSOTokenFilepath = (id2) => {
|
|
9162
|
-
const hasher =
|
|
9162
|
+
const hasher = createHash17("sha1");
|
|
9163
9163
|
const cacheName = hasher.update(id2).digest("hex");
|
|
9164
9164
|
return join4(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
9165
9165
|
};
|
|
@@ -9311,11 +9311,11 @@ var require_config = __commonJS((exports) => {
|
|
|
9311
9311
|
};
|
|
9312
9312
|
function getSelectorName(functionString) {
|
|
9313
9313
|
try {
|
|
9314
|
-
const
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
return [...
|
|
9314
|
+
const constants12 = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? []));
|
|
9315
|
+
constants12.delete("CONFIG");
|
|
9316
|
+
constants12.delete("CONFIG_PREFIX_SEPARATOR");
|
|
9317
|
+
constants12.delete("ENV");
|
|
9318
|
+
return [...constants12].join(", ");
|
|
9319
9319
|
} catch (ignored) {
|
|
9320
9320
|
return functionString;
|
|
9321
9321
|
}
|
|
@@ -9477,7 +9477,7 @@ var require_config = __commonJS((exports) => {
|
|
|
9477
9477
|
};
|
|
9478
9478
|
var imdsRequest = async (options) => {
|
|
9479
9479
|
const { request: request2 } = __require("http");
|
|
9480
|
-
return new Promise((
|
|
9480
|
+
return new Promise((resolve17, reject) => {
|
|
9481
9481
|
const req = request2({
|
|
9482
9482
|
hostname: options.hostname,
|
|
9483
9483
|
port: options.port,
|
|
@@ -9505,7 +9505,7 @@ var require_config = __commonJS((exports) => {
|
|
|
9505
9505
|
const chunks = [];
|
|
9506
9506
|
res.on("data", (chunk) => chunks.push(chunk));
|
|
9507
9507
|
res.on("end", () => {
|
|
9508
|
-
|
|
9508
|
+
resolve17(Buffer.concat(chunks));
|
|
9509
9509
|
req.destroy();
|
|
9510
9510
|
});
|
|
9511
9511
|
});
|
|
@@ -10511,10 +10511,10 @@ var require_endpoints = __commonJS((exports) => {
|
|
|
10511
10511
|
|
|
10512
10512
|
// node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
10513
10513
|
var require_serde = __commonJS((exports) => {
|
|
10514
|
-
var { createHmac: createHmac2, createHash:
|
|
10514
|
+
var { createHmac: createHmac2, createHash: createHash17, getRandomValues } = __require("crypto");
|
|
10515
10515
|
var { hasOwn: hasOwn2, HttpResponse } = require_transport();
|
|
10516
10516
|
exports.hasOwn = hasOwn2;
|
|
10517
|
-
var { ReadStream, lstatSync:
|
|
10517
|
+
var { ReadStream, lstatSync: lstatSync20, fstatSync: fstatSync4 } = __require("fs");
|
|
10518
10518
|
var { toEndpointV1 } = require_endpoints();
|
|
10519
10519
|
var { Readable, Writable, PassThrough } = __require("stream");
|
|
10520
10520
|
var isArrayBuffer = (arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
@@ -11280,7 +11280,7 @@ var require_serde = __commonJS((exports) => {
|
|
|
11280
11280
|
return body.end + 1 - body.start;
|
|
11281
11281
|
} else if (body instanceof ReadStream) {
|
|
11282
11282
|
if (body.path != null) {
|
|
11283
|
-
return
|
|
11283
|
+
return lstatSync20(body.path).size;
|
|
11284
11284
|
} else if (typeof body.fd === "number") {
|
|
11285
11285
|
return fstatSync4(body.fd).size;
|
|
11286
11286
|
}
|
|
@@ -11416,7 +11416,7 @@ var require_serde = __commonJS((exports) => {
|
|
|
11416
11416
|
return Promise.resolve(this.hash.digest());
|
|
11417
11417
|
}
|
|
11418
11418
|
reset() {
|
|
11419
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
11419
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash17(this.algorithmIdentifier);
|
|
11420
11420
|
}
|
|
11421
11421
|
}
|
|
11422
11422
|
function castSourceData(toCast, encoding) {
|
|
@@ -11861,7 +11861,7 @@ ${value}\r
|
|
|
11861
11861
|
if (isReadableStream(stream)) {
|
|
11862
11862
|
return headStream$1(stream, bytes);
|
|
11863
11863
|
}
|
|
11864
|
-
return new Promise((
|
|
11864
|
+
return new Promise((resolve17, reject) => {
|
|
11865
11865
|
const collector = new Collector$1;
|
|
11866
11866
|
collector.limit = bytes;
|
|
11867
11867
|
stream.pipe(collector);
|
|
@@ -11872,7 +11872,7 @@ ${value}\r
|
|
|
11872
11872
|
collector.on("error", reject);
|
|
11873
11873
|
collector.on("finish", function() {
|
|
11874
11874
|
const bytes2 = concatBytes(this.buffers);
|
|
11875
|
-
|
|
11875
|
+
resolve17(bytes2);
|
|
11876
11876
|
});
|
|
11877
11877
|
});
|
|
11878
11878
|
};
|
|
@@ -11986,7 +11986,7 @@ ${value}\r
|
|
|
11986
11986
|
if (isReadableStream(stream)) {
|
|
11987
11987
|
return collectReadableStream(stream);
|
|
11988
11988
|
}
|
|
11989
|
-
return new Promise((
|
|
11989
|
+
return new Promise((resolve17, reject) => {
|
|
11990
11990
|
const collector = new Collector;
|
|
11991
11991
|
const nodeStream = stream;
|
|
11992
11992
|
nodeStream.pipe(collector);
|
|
@@ -11997,7 +11997,7 @@ ${value}\r
|
|
|
11997
11997
|
collector.on("error", reject);
|
|
11998
11998
|
collector.on("finish", function() {
|
|
11999
11999
|
const bytes = concatBytes(this.bufferedBytes);
|
|
12000
|
-
|
|
12000
|
+
resolve17(bytes);
|
|
12001
12001
|
});
|
|
12002
12002
|
});
|
|
12003
12003
|
};
|
|
@@ -12155,7 +12155,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12155
12155
|
var { createReadStream } = __require("fs");
|
|
12156
12156
|
var { Writable } = __require("stream");
|
|
12157
12157
|
var { toUint8Array, concatBytes } = require_serde();
|
|
12158
|
-
var { createHash:
|
|
12158
|
+
var { createHash: createHash17, createHmac: createHmac2 } = __require("crypto");
|
|
12159
12159
|
var zlib = __require("zlib");
|
|
12160
12160
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
12161
12161
|
const size = blob.size;
|
|
@@ -12189,7 +12189,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12189
12189
|
callback();
|
|
12190
12190
|
}
|
|
12191
12191
|
}
|
|
12192
|
-
var fileStreamHasher = (hashCtor, fileStream) => new Promise((
|
|
12192
|
+
var fileStreamHasher = (hashCtor, fileStream) => new Promise((resolve17, reject) => {
|
|
12193
12193
|
if (!isReadStream(fileStream)) {
|
|
12194
12194
|
reject(new Error("Unable to calculate hash for non-file streams."));
|
|
12195
12195
|
return;
|
|
@@ -12207,7 +12207,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12207
12207
|
});
|
|
12208
12208
|
hashCalculator.on("error", reject);
|
|
12209
12209
|
hashCalculator.on("finish", function() {
|
|
12210
|
-
hash2.digest().then(
|
|
12210
|
+
hash2.digest().then(resolve17).catch(reject);
|
|
12211
12211
|
});
|
|
12212
12212
|
});
|
|
12213
12213
|
var isReadStream = (stream) => typeof stream.path === "string";
|
|
@@ -12218,14 +12218,14 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12218
12218
|
const hash2 = new hashCtor;
|
|
12219
12219
|
const hashCalculator = new HashCalculator(hash2);
|
|
12220
12220
|
readableStream.pipe(hashCalculator);
|
|
12221
|
-
return new Promise((
|
|
12221
|
+
return new Promise((resolve17, reject) => {
|
|
12222
12222
|
readableStream.on("error", (err) => {
|
|
12223
12223
|
hashCalculator.end();
|
|
12224
12224
|
reject(err);
|
|
12225
12225
|
});
|
|
12226
12226
|
hashCalculator.on("error", reject);
|
|
12227
12227
|
hashCalculator.on("finish", () => {
|
|
12228
|
-
hash2.digest().then(
|
|
12228
|
+
hash2.digest().then(resolve17).catch(reject);
|
|
12229
12229
|
});
|
|
12230
12230
|
});
|
|
12231
12231
|
};
|
|
@@ -12320,7 +12320,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12320
12320
|
}
|
|
12321
12321
|
var hasNativeCrypto$1 = (() => {
|
|
12322
12322
|
try {
|
|
12323
|
-
|
|
12323
|
+
createHash17("md5");
|
|
12324
12324
|
return true;
|
|
12325
12325
|
} catch {
|
|
12326
12326
|
return false;
|
|
@@ -12330,7 +12330,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12330
12330
|
function buildNativeClass$2() {
|
|
12331
12331
|
return class Md5Node2 {
|
|
12332
12332
|
digestLength = 16;
|
|
12333
|
-
hash =
|
|
12333
|
+
hash = createHash17("md5");
|
|
12334
12334
|
update(data) {
|
|
12335
12335
|
this.hash.update(toUint8Array(data));
|
|
12336
12336
|
}
|
|
@@ -12339,7 +12339,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12339
12339
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
12340
12340
|
}
|
|
12341
12341
|
reset() {
|
|
12342
|
-
this.hash =
|
|
12342
|
+
this.hash = createHash17("md5");
|
|
12343
12343
|
}
|
|
12344
12344
|
};
|
|
12345
12345
|
}
|
|
@@ -12629,7 +12629,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12629
12629
|
]);
|
|
12630
12630
|
var hasNativeCrypto = (() => {
|
|
12631
12631
|
try {
|
|
12632
|
-
|
|
12632
|
+
createHash17("sha256");
|
|
12633
12633
|
return true;
|
|
12634
12634
|
} catch {
|
|
12635
12635
|
return false;
|
|
@@ -12669,7 +12669,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12669
12669
|
this.finished = false;
|
|
12670
12670
|
}
|
|
12671
12671
|
createHash() {
|
|
12672
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
12672
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash17("sha256");
|
|
12673
12673
|
}
|
|
12674
12674
|
};
|
|
12675
12675
|
}
|
|
@@ -13334,7 +13334,7 @@ var require_event_streams = __commonJS((exports) => {
|
|
|
13334
13334
|
streamEnded = true;
|
|
13335
13335
|
});
|
|
13336
13336
|
while (!generationEnded) {
|
|
13337
|
-
const value = await new Promise((
|
|
13337
|
+
const value = await new Promise((resolve17) => setTimeout(() => resolve17(records.shift()), 0));
|
|
13338
13338
|
if (value) {
|
|
13339
13339
|
yield value;
|
|
13340
13340
|
}
|
|
@@ -14852,7 +14852,7 @@ var require_retry = __commonJS((exports) => {
|
|
|
14852
14852
|
}
|
|
14853
14853
|
};
|
|
14854
14854
|
}
|
|
14855
|
-
var cooldown = (ms) => new Promise((
|
|
14855
|
+
var cooldown = (ms) => new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
14856
14856
|
var isRetryStrategyV2 = (retryStrategy) => typeof retryStrategy.acquireInitialRetryToken !== "undefined" && typeof retryStrategy.refreshRetryTokenForRetry !== "undefined" && typeof retryStrategy.recordSuccess !== "undefined";
|
|
14857
14857
|
var getRetryErrorInfo = (error, logger) => {
|
|
14858
14858
|
const errorInfo = {
|
|
@@ -14951,7 +14951,7 @@ var require_retry = __commonJS((exports) => {
|
|
|
14951
14951
|
this.refillTokenBucket();
|
|
14952
14952
|
while (amount > this.availableTokens) {
|
|
14953
14953
|
const delay = (amount - this.availableTokens) / this.fillRate * 1000;
|
|
14954
|
-
await new Promise((
|
|
14954
|
+
await new Promise((resolve17) => DefaultRateLimiter.setTimeoutFn(resolve17, delay));
|
|
14955
14955
|
this.refillTokenBucket();
|
|
14956
14956
|
}
|
|
14957
14957
|
this.availableTokens = this.availableTokens - amount;
|
|
@@ -15293,7 +15293,7 @@ var require_retry = __commonJS((exports) => {
|
|
|
15293
15293
|
const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
|
|
15294
15294
|
const delay = Math.max(delayFromResponse || 0, delayFromDecider);
|
|
15295
15295
|
totalDelay += delay;
|
|
15296
|
-
await new Promise((
|
|
15296
|
+
await new Promise((resolve17) => setTimeout(resolve17, delay));
|
|
15297
15297
|
continue;
|
|
15298
15298
|
}
|
|
15299
15299
|
if (!err.$metadata) {
|
|
@@ -17515,8 +17515,8 @@ More information can be found at: https://a.co/c895JFp`);
|
|
|
17515
17515
|
};
|
|
17516
17516
|
var createUserAgentStringParsingProvider = ({ serviceId, clientVersion }) => async (config) => {
|
|
17517
17517
|
const module2 = require_es5();
|
|
17518
|
-
const
|
|
17519
|
-
const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ?
|
|
17518
|
+
const parse7 = module2.parse ?? module2.default.parse ?? (() => "");
|
|
17519
|
+
const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ? parse7(window.navigator.userAgent) : undefined;
|
|
17520
17520
|
const sections = [
|
|
17521
17521
|
["aws-sdk-js", clientVersion],
|
|
17522
17522
|
["ua", "2.1"],
|
|
@@ -18166,7 +18166,7 @@ ${toHex(hashedRequest)}`;
|
|
|
18166
18166
|
return hash2.digest();
|
|
18167
18167
|
};
|
|
18168
18168
|
var getCanonicalHeaders = ({ headers }, unsignableHeaders, signableHeaders) => {
|
|
18169
|
-
const
|
|
18169
|
+
const canonical4 = {};
|
|
18170
18170
|
for (const headerName of Object.keys(headers).sort()) {
|
|
18171
18171
|
if (headers[headerName] == undefined) {
|
|
18172
18172
|
continue;
|
|
@@ -18177,9 +18177,9 @@ ${toHex(hashedRequest)}`;
|
|
|
18177
18177
|
continue;
|
|
18178
18178
|
}
|
|
18179
18179
|
}
|
|
18180
|
-
|
|
18180
|
+
canonical4[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
|
|
18181
18181
|
}
|
|
18182
|
-
return
|
|
18182
|
+
return canonical4;
|
|
18183
18183
|
};
|
|
18184
18184
|
var getPayloadHash = async ({ headers, body }, hashConstructor) => {
|
|
18185
18185
|
for (const headerName in headers) {
|
|
@@ -18542,7 +18542,7 @@ var require_dist_cjs4 = __commonJS((exports) => {
|
|
|
18542
18542
|
var require_util = __commonJS((exports) => {
|
|
18543
18543
|
var { buildQueryString } = require_protocols();
|
|
18544
18544
|
var validate = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
|
|
18545
|
-
var
|
|
18545
|
+
var parse7 = (arn) => {
|
|
18546
18546
|
const segments = arn.split(":");
|
|
18547
18547
|
if (segments.length < 6 || segments[0] !== "arn")
|
|
18548
18548
|
throw new Error("Malformed ARN");
|
|
@@ -18592,7 +18592,7 @@ var require_util = __commonJS((exports) => {
|
|
|
18592
18592
|
}
|
|
18593
18593
|
exports.build = build;
|
|
18594
18594
|
exports.formatUrl = formatUrl;
|
|
18595
|
-
exports.parse =
|
|
18595
|
+
exports.parse = parse7;
|
|
18596
18596
|
exports.validate = validate;
|
|
18597
18597
|
});
|
|
18598
18598
|
|
|
@@ -21700,12 +21700,12 @@ var require_protocols2 = __commonJS((exports) => {
|
|
|
21700
21700
|
return expandToDecimal(numericString) === expandToDecimal(String(value));
|
|
21701
21701
|
}
|
|
21702
21702
|
const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
21703
|
-
const
|
|
21704
|
-
if (normalized ===
|
|
21703
|
+
const canonical4 = String(value);
|
|
21704
|
+
if (normalized === canonical4) {
|
|
21705
21705
|
return true;
|
|
21706
21706
|
}
|
|
21707
|
-
if (/[eE]/.test(
|
|
21708
|
-
return normalized === expandToDecimal(
|
|
21707
|
+
if (/[eE]/.test(canonical4)) {
|
|
21708
|
+
return normalized === expandToDecimal(canonical4);
|
|
21709
21709
|
}
|
|
21710
21710
|
return false;
|
|
21711
21711
|
}
|
|
@@ -24646,7 +24646,7 @@ var init_node_http = () => {};
|
|
|
24646
24646
|
|
|
24647
24647
|
// node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/httpRequest.js
|
|
24648
24648
|
function httpRequest(options) {
|
|
24649
|
-
return new Promise((
|
|
24649
|
+
return new Promise((resolve17, reject) => {
|
|
24650
24650
|
const req = node_http.request({
|
|
24651
24651
|
method: "GET",
|
|
24652
24652
|
...options,
|
|
@@ -24671,7 +24671,7 @@ function httpRequest(options) {
|
|
|
24671
24671
|
chunks.push(chunk);
|
|
24672
24672
|
});
|
|
24673
24673
|
res.on("end", () => {
|
|
24674
|
-
|
|
24674
|
+
resolve17(Buffer.concat(chunks));
|
|
24675
24675
|
req.destroy();
|
|
24676
24676
|
});
|
|
24677
24677
|
});
|
|
@@ -25168,21 +25168,21 @@ var require_dist_cjs6 = __commonJS((exports) => {
|
|
|
25168
25168
|
let sendBody = true;
|
|
25169
25169
|
if (!externalAgent && expect === "100-continue") {
|
|
25170
25170
|
sendBody = await Promise.race([
|
|
25171
|
-
new Promise((
|
|
25172
|
-
timeoutId = Number(timing.setTimeout(() =>
|
|
25171
|
+
new Promise((resolve17) => {
|
|
25172
|
+
timeoutId = Number(timing.setTimeout(() => resolve17(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
25173
25173
|
}),
|
|
25174
|
-
new Promise((
|
|
25174
|
+
new Promise((resolve17) => {
|
|
25175
25175
|
httpRequest2.on("continue", () => {
|
|
25176
25176
|
timing.clearTimeout(timeoutId);
|
|
25177
|
-
|
|
25177
|
+
resolve17(true);
|
|
25178
25178
|
});
|
|
25179
25179
|
httpRequest2.on("response", () => {
|
|
25180
25180
|
timing.clearTimeout(timeoutId);
|
|
25181
|
-
|
|
25181
|
+
resolve17(false);
|
|
25182
25182
|
});
|
|
25183
25183
|
httpRequest2.on("error", () => {
|
|
25184
25184
|
timing.clearTimeout(timeoutId);
|
|
25185
|
-
|
|
25185
|
+
resolve17(false);
|
|
25186
25186
|
});
|
|
25187
25187
|
})
|
|
25188
25188
|
]);
|
|
@@ -25259,13 +25259,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25259
25259
|
return socketWarningTimestamp;
|
|
25260
25260
|
}
|
|
25261
25261
|
constructor(options) {
|
|
25262
|
-
this.configProvider = new Promise((
|
|
25262
|
+
this.configProvider = new Promise((resolve17, reject) => {
|
|
25263
25263
|
if (typeof options === "function") {
|
|
25264
25264
|
options().then((_options) => {
|
|
25265
|
-
|
|
25265
|
+
resolve17(this.resolveDefaultConfig(_options));
|
|
25266
25266
|
}).catch(reject);
|
|
25267
25267
|
} else {
|
|
25268
|
-
|
|
25268
|
+
resolve17(this.resolveDefaultConfig(options));
|
|
25269
25269
|
}
|
|
25270
25270
|
});
|
|
25271
25271
|
}
|
|
@@ -25297,7 +25297,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25297
25297
|
timing.clearTimeout(socketTimeoutId);
|
|
25298
25298
|
timing.clearTimeout(keepAliveTimeoutId);
|
|
25299
25299
|
};
|
|
25300
|
-
const
|
|
25300
|
+
const resolve17 = async (arg) => {
|
|
25301
25301
|
await writeRequestBodyPromise;
|
|
25302
25302
|
clearTimeouts();
|
|
25303
25303
|
_resolve(arg);
|
|
@@ -25361,7 +25361,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25361
25361
|
headers: getTransformedHeaders(res.headers),
|
|
25362
25362
|
body: res
|
|
25363
25363
|
});
|
|
25364
|
-
|
|
25364
|
+
resolve17({ response: httpResponse });
|
|
25365
25365
|
});
|
|
25366
25366
|
req.on("error", (err) => {
|
|
25367
25367
|
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
@@ -25679,7 +25679,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25679
25679
|
return this.connectOptions === undefined ? http2.connect(url) : http2.connect(url, this.connectOptions);
|
|
25680
25680
|
}
|
|
25681
25681
|
}
|
|
25682
|
-
var { constants:
|
|
25682
|
+
var { constants: constants12 } = http2;
|
|
25683
25683
|
|
|
25684
25684
|
class NodeHttp2Handler {
|
|
25685
25685
|
config;
|
|
@@ -25693,13 +25693,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25693
25693
|
return new NodeHttp2Handler(instanceOrOptions);
|
|
25694
25694
|
}
|
|
25695
25695
|
constructor(options) {
|
|
25696
|
-
this.configProvider = new Promise((
|
|
25696
|
+
this.configProvider = new Promise((resolve17, reject) => {
|
|
25697
25697
|
if (typeof options === "function") {
|
|
25698
25698
|
options().then((opts) => {
|
|
25699
|
-
|
|
25699
|
+
resolve17(opts || {});
|
|
25700
25700
|
}).catch(reject);
|
|
25701
25701
|
} else {
|
|
25702
|
-
|
|
25702
|
+
resolve17(options || {});
|
|
25703
25703
|
}
|
|
25704
25704
|
});
|
|
25705
25705
|
}
|
|
@@ -25724,7 +25724,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25724
25724
|
return new Promise((_resolve, _reject) => {
|
|
25725
25725
|
let fulfilled = false;
|
|
25726
25726
|
let writeRequestBodyPromise = undefined;
|
|
25727
|
-
const
|
|
25727
|
+
const resolve17 = async (arg) => {
|
|
25728
25728
|
await writeRequestBodyPromise;
|
|
25729
25729
|
_resolve(arg);
|
|
25730
25730
|
};
|
|
@@ -25770,8 +25770,8 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25770
25770
|
}
|
|
25771
25771
|
const clientHttp2Stream = session.request({
|
|
25772
25772
|
...request2.headers,
|
|
25773
|
-
[
|
|
25774
|
-
[
|
|
25773
|
+
[constants12.HTTP2_HEADER_PATH]: path,
|
|
25774
|
+
[constants12.HTTP2_HEADER_METHOD]: method
|
|
25775
25775
|
});
|
|
25776
25776
|
if (effectiveRequestTimeout) {
|
|
25777
25777
|
clientHttp2Stream.setTimeout(effectiveRequestTimeout, () => {
|
|
@@ -25809,7 +25809,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25809
25809
|
body: clientHttp2Stream
|
|
25810
25810
|
});
|
|
25811
25811
|
fulfilled = true;
|
|
25812
|
-
|
|
25812
|
+
resolve17({ response: httpResponse });
|
|
25813
25813
|
if (useIsolatedSession) {
|
|
25814
25814
|
session.close();
|
|
25815
25815
|
clientHttp2Stream.on("end", () => {
|
|
@@ -25942,7 +25942,7 @@ var retryWrapper = (toRetry, maxRetries, delayMs) => {
|
|
|
25942
25942
|
try {
|
|
25943
25943
|
return await toRetry();
|
|
25944
25944
|
} catch (e3) {
|
|
25945
|
-
await new Promise((
|
|
25945
|
+
await new Promise((resolve17) => setTimeout(resolve17, delayMs));
|
|
25946
25946
|
}
|
|
25947
25947
|
}
|
|
25948
25948
|
return await toRetry();
|
|
@@ -29443,10 +29443,10 @@ var require_signin = __commonJS((exports) => {
|
|
|
29443
29443
|
});
|
|
29444
29444
|
|
|
29445
29445
|
// node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
|
|
29446
|
-
import { createHash as
|
|
29446
|
+
import { createHash as createHash17, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
29447
29447
|
import { promises as fs2 } from "fs";
|
|
29448
29448
|
import { homedir as homedir6 } from "os";
|
|
29449
|
-
import { dirname as
|
|
29449
|
+
import { dirname as dirname18, join as join31 } from "path";
|
|
29450
29450
|
var import_config27, import_protocols3, LoginCredentialsFetcher;
|
|
29451
29451
|
var init_LoginCredentialsFetcher = __esm(() => {
|
|
29452
29452
|
import_config27 = __toESM(require_config(), 1);
|
|
@@ -29606,7 +29606,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29606
29606
|
}
|
|
29607
29607
|
async saveToken(token) {
|
|
29608
29608
|
const tokenFilePath = this.getTokenFilePath();
|
|
29609
|
-
const directory =
|
|
29609
|
+
const directory = dirname18(tokenFilePath);
|
|
29610
29610
|
try {
|
|
29611
29611
|
await fs2.mkdir(directory, { recursive: true });
|
|
29612
29612
|
} catch (error) {}
|
|
@@ -29615,7 +29615,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29615
29615
|
getTokenFilePath() {
|
|
29616
29616
|
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join31(homedir6(), ".aws", "login", "cache");
|
|
29617
29617
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
29618
|
-
const loginSessionSha256 =
|
|
29618
|
+
const loginSessionSha256 = createHash17("sha256").update(loginSessionBytes).digest("hex");
|
|
29619
29619
|
return join31(directory, `${loginSessionSha256}.json`);
|
|
29620
29620
|
}
|
|
29621
29621
|
derToRawSignature(derSignature) {
|
|
@@ -31067,7 +31067,7 @@ import { existsSync as existsSync22 } from "fs";
|
|
|
31067
31067
|
import { join as join210 } from "path";
|
|
31068
31068
|
import { existsSync as existsSync16 } from "fs";
|
|
31069
31069
|
import { homedir as homedir7 } from "os";
|
|
31070
|
-
import { join as join35, resolve as
|
|
31070
|
+
import { join as join35, resolve as resolve17 } from "path";
|
|
31071
31071
|
import { homedir as pathsResolverHomedir2 } from "os";
|
|
31072
31072
|
import { join as pathsResolverJoin2 } from "path";
|
|
31073
31073
|
import { createHmac as createHmac4, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
@@ -31251,9 +31251,9 @@ function exactEventsHome() {
|
|
|
31251
31251
|
function getEventsHome() {
|
|
31252
31252
|
const exact = exactEventsHome();
|
|
31253
31253
|
if (exact)
|
|
31254
|
-
return
|
|
31254
|
+
return resolve17(exact);
|
|
31255
31255
|
const resolved = resolverHome();
|
|
31256
|
-
return adoptResolverHome(resolved) ?
|
|
31256
|
+
return adoptResolverHome(resolved) ? resolve17(resolved) : resolve17(legacyHomeDir());
|
|
31257
31257
|
}
|
|
31258
31258
|
function getEventsDataDir(override) {
|
|
31259
31259
|
return override || getEventsHome();
|
|
@@ -36704,7 +36704,7 @@ async function resolveExecutionGrant(input) {
|
|
|
36704
36704
|
// package.json
|
|
36705
36705
|
var package_default = {
|
|
36706
36706
|
name: "@hasna/skills",
|
|
36707
|
-
version: "0.8.
|
|
36707
|
+
version: "0.8.12",
|
|
36708
36708
|
description: "Skills library for AI coding agents",
|
|
36709
36709
|
type: "module",
|
|
36710
36710
|
bin: {
|
|
@@ -37066,10 +37066,10 @@ async function reconcileSkillSession(input, options = {}) {
|
|
|
37066
37066
|
return { applied: true, plan, planDigest, ...result };
|
|
37067
37067
|
}
|
|
37068
37068
|
// src/lib/selected-run.ts
|
|
37069
|
-
import { createHash as
|
|
37069
|
+
import { createHash as createHash16 } from "crypto";
|
|
37070
37070
|
import { spawn } from "child_process";
|
|
37071
37071
|
import { mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, writeFileSync as writeFileSync8, realpathSync as realpathSync7 } from "fs";
|
|
37072
|
-
import { dirname as
|
|
37072
|
+
import { dirname as dirname17, join as join30, resolve as resolve16 } from "path";
|
|
37073
37073
|
import { tmpdir, hostname as stationHostname2 } from "os";
|
|
37074
37074
|
|
|
37075
37075
|
// src/lib/dependency-preparation.ts
|
|
@@ -37292,7 +37292,7 @@ import { homedir as homedir5 } from "os";
|
|
|
37292
37292
|
import {
|
|
37293
37293
|
cpSync as cpSync2,
|
|
37294
37294
|
existsSync as existsSync10,
|
|
37295
|
-
lstatSync as
|
|
37295
|
+
lstatSync as lstatSync19,
|
|
37296
37296
|
mkdirSync as mkdirSync8,
|
|
37297
37297
|
mkdtempSync as mkdtempSync2,
|
|
37298
37298
|
readFileSync as readFileSync16,
|
|
@@ -37303,12 +37303,12 @@ import {
|
|
|
37303
37303
|
writeFileSync as writeFileSync6
|
|
37304
37304
|
} from "fs";
|
|
37305
37305
|
import { homedir as homedir4 } from "os";
|
|
37306
|
-
import { basename as
|
|
37306
|
+
import { basename as basename9, dirname as dirname16, join as join25 } from "path";
|
|
37307
37307
|
|
|
37308
37308
|
// src/lib/agent-integration.ts
|
|
37309
|
-
import { createHash as
|
|
37310
|
-
import { existsSync as existsSync6, lstatSync as
|
|
37311
|
-
import { dirname as
|
|
37309
|
+
import { createHash as createHash14, randomUUID as randomUUID3 } from "crypto";
|
|
37310
|
+
import { existsSync as existsSync6, lstatSync as lstatSync17, statSync as statSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync13, readdirSync as readdirSync7, opendirSync as opendirSync5, readlinkSync as readlinkSync2, realpathSync as realpathSync4, renameSync as renameSync3, rmdirSync as rmdirSync3, writeFileSync as writeFileSync3, unlinkSync as unlinkSync4, chmodSync, openSync as openSync15, closeSync as closeSync15, fsyncSync as fsyncSync3, fstatSync as fstatSync15, readSync as readSync10, constants as constants11, linkSync as linkSync2 } from "fs";
|
|
37311
|
+
import { dirname as dirname13, join as join21, resolve as resolve14, relative as relative3, isAbsolute as isAbsolute15, sep as sep4 } from "path";
|
|
37312
37312
|
import { homedir as homedir3 } from "os";
|
|
37313
37313
|
|
|
37314
37314
|
// src/lib/managed-policy.ts
|
|
@@ -37382,7 +37382,9 @@ function assertAgentPolicyCollections(policy) {
|
|
|
37382
37382
|
text(source.path);
|
|
37383
37383
|
requireBound(source.sha256 === null || typeof source.sha256 === "string" && /^[a-f0-9]{64}$/.test(source.sha256));
|
|
37384
37384
|
if (source.hashMode !== undefined)
|
|
37385
|
-
requireBound(["bytes", "path-bytes", "claude-plugin-registry", "claude-marketplace-registry"].includes(source.hashMode) && source.format === undefined && source.fields === undefined && (source.hashMode === "bytes" || source.sha256 !== null));
|
|
37385
|
+
requireBound(["bytes", "path-bytes", "claude-plugin-registry", "claude-marketplace-registry", "claude-settings-v1"].includes(source.hashMode) && source.format === undefined && source.fields === undefined && (source.hashMode === "bytes" || source.sha256 !== null));
|
|
37386
|
+
if (source.hashMode === "claude-settings-v1")
|
|
37387
|
+
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute3(source.path) && resolve3(source.path) === source.path && basename2(source.path) === "settings.json");
|
|
37386
37388
|
if (source.hashMode === "claude-marketplace-registry")
|
|
37387
37389
|
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute3(source.path) && resolve3(source.path) === source.path && basename2(source.path) === "known_marketplaces.json");
|
|
37388
37390
|
if (source.hashMode === "claude-plugin-registry") {
|
|
@@ -37536,9 +37538,9 @@ function isOwnedCliBridge(path, expectedPaths) {
|
|
|
37536
37538
|
}
|
|
37537
37539
|
|
|
37538
37540
|
// src/lib/agent-discovery.ts
|
|
37539
|
-
import { createHash as
|
|
37540
|
-
import { lstatSync as
|
|
37541
|
-
import { dirname as
|
|
37541
|
+
import { createHash as createHash13 } from "crypto";
|
|
37542
|
+
import { lstatSync as lstatSync16, readFileSync as readFileSync12, readdirSync as readdirSync6, realpathSync as realpathSync3 } from "fs";
|
|
37543
|
+
import { basename as basename6, dirname as dirname12, isAbsolute as isAbsolute14, join as join20, resolve as resolve13, sep as sep3 } from "path";
|
|
37542
37544
|
|
|
37543
37545
|
// node_modules/yaml/dist/index.js
|
|
37544
37546
|
var composer = require_composer();
|
|
@@ -39718,8 +39720,228 @@ function captureClaudeMarketplaceRegistry(path, budget = { remaining: 256 * 1024
|
|
|
39718
39720
|
return { path, hashMode: "claude-marketplace-registry", sha256: sha2562 };
|
|
39719
39721
|
}
|
|
39720
39722
|
|
|
39723
|
+
// src/lib/claude-settings-witness.ts
|
|
39724
|
+
import { createHash as createHash12 } from "crypto";
|
|
39725
|
+
import { closeSync as closeSync14, constants as constants10, fstatSync as fstatSync14, lstatSync as lstatSync15, openSync as openSync14, readSync as readSync9 } from "fs";
|
|
39726
|
+
import { basename as basename5, dirname as dirname11, isAbsolute as isAbsolute13, resolve as resolve12 } from "path";
|
|
39727
|
+
var CLAUDE_SETTINGS_WITNESS_LIMITS = Object.freeze({ bytes: 1024 * 1024, rows: 1024, depth: 32, nodes: 65536, stringCharacters: 16384, pathCharacters: 4096 });
|
|
39728
|
+
function need3(value, reason) {
|
|
39729
|
+
if (!value)
|
|
39730
|
+
throw new Error(`Claude settings witness ${reason}`);
|
|
39731
|
+
}
|
|
39732
|
+
function absolutePath2(value) {
|
|
39733
|
+
need3(typeof value === "string" && value.length > 0 && value.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.pathCharacters && !/[\x00-\x1f\x7f]/.test(value) && isAbsolute13(value) && resolve12(value) === value, "requires a normalized absolute path");
|
|
39734
|
+
}
|
|
39735
|
+
var sameFile2 = (a, b) => a.dev === b.dev && a.ino === b.ino && a.mode === b.mode && a.uid === b.uid && a.gid === b.gid && a.nlink === b.nlink && a.size === b.size && a.mtimeNs === b.mtimeNs && a.ctimeNs === b.ctimeNs;
|
|
39736
|
+
function parents2(path) {
|
|
39737
|
+
const result = [];
|
|
39738
|
+
for (let at = dirname11(path);; at = dirname11(at)) {
|
|
39739
|
+
const stat2 = lstatSync15(at, { bigint: true });
|
|
39740
|
+
need3(stat2.isDirectory() && !stat2.isSymbolicLink(), "path traverses a symlink or non-directory");
|
|
39741
|
+
result.push([at, stat2]);
|
|
39742
|
+
if (at === dirname11(at))
|
|
39743
|
+
return result;
|
|
39744
|
+
}
|
|
39745
|
+
}
|
|
39746
|
+
function readSettings(path, budget) {
|
|
39747
|
+
absolutePath2(path);
|
|
39748
|
+
need3(basename5(path) === "settings.json", "requires settings.json");
|
|
39749
|
+
need3(Number.isSafeInteger(budget.remaining) && budget.remaining >= 0, "has an invalid byte budget");
|
|
39750
|
+
const ancestors2 = parents2(path), initial = lstatSync15(path, { bigint: true });
|
|
39751
|
+
need3(initial.isFile() && !initial.isSymbolicLink() && initial.size <= BigInt(CLAUDE_SETTINGS_WITNESS_LIMITS.bytes), "is not a bounded regular file");
|
|
39752
|
+
need3(initial.size <= BigInt(budget.remaining), "exceeds its aggregate byte limit");
|
|
39753
|
+
const fd = openSync14(path, constants10.O_RDONLY | constants10.O_NOFOLLOW | constants10.O_NONBLOCK);
|
|
39754
|
+
try {
|
|
39755
|
+
const opened = fstatSync14(fd, { bigint: true });
|
|
39756
|
+
need3(opened.isFile() && sameFile2(initial, opened), "changed during open");
|
|
39757
|
+
const bytes = Buffer.alloc(Number(opened.size) + 1);
|
|
39758
|
+
let length = 0;
|
|
39759
|
+
while (length < bytes.length) {
|
|
39760
|
+
const count = readSync9(fd, bytes, length, bytes.length - length, null);
|
|
39761
|
+
if (!count)
|
|
39762
|
+
break;
|
|
39763
|
+
length += count;
|
|
39764
|
+
}
|
|
39765
|
+
const after = fstatSync14(fd, { bigint: true }), current = lstatSync15(path, { bigint: true });
|
|
39766
|
+
need3(current.isFile() && sameFile2(opened, after) && sameFile2(after, current) && BigInt(length) === opened.size, "changed during read");
|
|
39767
|
+
for (const [ancestor, before] of ancestors2) {
|
|
39768
|
+
const now = lstatSync15(ancestor, { bigint: true });
|
|
39769
|
+
need3(now.isDirectory() && before.dev === now.dev && before.ino === now.ino && before.mode === now.mode, "parent changed during read");
|
|
39770
|
+
}
|
|
39771
|
+
budget.remaining -= length;
|
|
39772
|
+
try {
|
|
39773
|
+
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes.subarray(0, length));
|
|
39774
|
+
} catch {
|
|
39775
|
+
throw new Error("Claude settings witness is not strict UTF-8");
|
|
39776
|
+
}
|
|
39777
|
+
} finally {
|
|
39778
|
+
closeSync14(fd);
|
|
39779
|
+
}
|
|
39780
|
+
}
|
|
39781
|
+
function parse6(text2) {
|
|
39782
|
+
let at = 0, nodes = 0;
|
|
39783
|
+
const numberPattern = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;
|
|
39784
|
+
const space = () => {
|
|
39785
|
+
while (at < text2.length && /[\x20\t\r\n]/.test(text2[at]))
|
|
39786
|
+
at++;
|
|
39787
|
+
};
|
|
39788
|
+
function string() {
|
|
39789
|
+
need3(text2[at] === '"', "contains invalid JSON");
|
|
39790
|
+
const start = at++;
|
|
39791
|
+
while (at < text2.length) {
|
|
39792
|
+
const character = text2[at++];
|
|
39793
|
+
if (character === '"') {
|
|
39794
|
+
let value2;
|
|
39795
|
+
try {
|
|
39796
|
+
value2 = JSON.parse(text2.slice(start, at));
|
|
39797
|
+
} catch {
|
|
39798
|
+
throw new Error("Claude settings witness contains invalid JSON string");
|
|
39799
|
+
}
|
|
39800
|
+
need3(value2.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.stringCharacters, "exceeds its string limit");
|
|
39801
|
+
return value2;
|
|
39802
|
+
}
|
|
39803
|
+
if (character === "\\")
|
|
39804
|
+
at++;
|
|
39805
|
+
}
|
|
39806
|
+
throw new Error("Claude settings witness contains an unterminated JSON string");
|
|
39807
|
+
}
|
|
39808
|
+
function value(depth) {
|
|
39809
|
+
need3(depth <= CLAUDE_SETTINGS_WITNESS_LIMITS.depth && ++nodes <= CLAUDE_SETTINGS_WITNESS_LIMITS.nodes, "exceeds its nesting or node limit");
|
|
39810
|
+
space();
|
|
39811
|
+
const character = text2[at];
|
|
39812
|
+
if (character === '"')
|
|
39813
|
+
return { kind: "string", value: string() };
|
|
39814
|
+
if (character === "{" || character === "[") {
|
|
39815
|
+
at++;
|
|
39816
|
+
space();
|
|
39817
|
+
const object4 = character === "{", end = object4 ? "}" : "]", entries = [], items = [], keys2 = new Set;
|
|
39818
|
+
if (text2[at] !== end)
|
|
39819
|
+
while (true) {
|
|
39820
|
+
if (object4) {
|
|
39821
|
+
space();
|
|
39822
|
+
const key = string();
|
|
39823
|
+
need3(!keys2.has(key), "contains a duplicate JSON key");
|
|
39824
|
+
keys2.add(key);
|
|
39825
|
+
space();
|
|
39826
|
+
need3(text2[at++] === ":", "contains invalid JSON");
|
|
39827
|
+
entries.push([key, value(depth + 1)]);
|
|
39828
|
+
} else
|
|
39829
|
+
items.push(value(depth + 1));
|
|
39830
|
+
space();
|
|
39831
|
+
if (text2[at] === end)
|
|
39832
|
+
break;
|
|
39833
|
+
need3(text2[at++] === ",", "contains invalid JSON");
|
|
39834
|
+
}
|
|
39835
|
+
at++;
|
|
39836
|
+
return object4 ? { kind: "object", entries } : { kind: "array", items };
|
|
39837
|
+
}
|
|
39838
|
+
for (const literal of ["true", "false", "null"])
|
|
39839
|
+
if (text2.startsWith(literal, at)) {
|
|
39840
|
+
at += literal.length;
|
|
39841
|
+
return { kind: "literal", value: literal };
|
|
39842
|
+
}
|
|
39843
|
+
numberPattern.lastIndex = at;
|
|
39844
|
+
const number = numberPattern.exec(text2);
|
|
39845
|
+
need3(number, "contains invalid JSON");
|
|
39846
|
+
at += number[0].length;
|
|
39847
|
+
return { kind: "number", value: number[0] };
|
|
39848
|
+
}
|
|
39849
|
+
const root2 = value(0);
|
|
39850
|
+
space();
|
|
39851
|
+
need3(at === text2.length && root2.kind === "object", "requires a JSON object without trailing content");
|
|
39852
|
+
need3(root2.entries.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.rows, "exceeds its settings field limit");
|
|
39853
|
+
return root2;
|
|
39854
|
+
}
|
|
39855
|
+
var BOOLEAN_PREFERENCES = new Set([
|
|
39856
|
+
"autoScrollEnabled",
|
|
39857
|
+
"axScreenReader",
|
|
39858
|
+
"emojiCompletionEnabled",
|
|
39859
|
+
"prefersReducedMotion",
|
|
39860
|
+
"showTurnDuration",
|
|
39861
|
+
"spinnerTipsEnabled",
|
|
39862
|
+
"syntaxHighlightingDisabled",
|
|
39863
|
+
"terminalProgressBarEnabled",
|
|
39864
|
+
"terminalTitleFromRename",
|
|
39865
|
+
"verbose",
|
|
39866
|
+
"wheelScrollAccelerationEnabled"
|
|
39867
|
+
]);
|
|
39868
|
+
var ENUM_PREFERENCES = Object.freeze({
|
|
39869
|
+
editorMode: ["normal", "vim"],
|
|
39870
|
+
tui: ["default", "fullscreen"],
|
|
39871
|
+
viewMode: ["default", "verbose", "focus"]
|
|
39872
|
+
});
|
|
39873
|
+
var BUILTIN_MODEL_SELECTIONS = new Set([
|
|
39874
|
+
"default",
|
|
39875
|
+
"best",
|
|
39876
|
+
"fable",
|
|
39877
|
+
"fable[1m]",
|
|
39878
|
+
"sonnet",
|
|
39879
|
+
"sonnet[1m]",
|
|
39880
|
+
"opus",
|
|
39881
|
+
"opus[1m]",
|
|
39882
|
+
"haiku",
|
|
39883
|
+
"opusplan",
|
|
39884
|
+
"claude-fable-5-1",
|
|
39885
|
+
"claude-fable-5",
|
|
39886
|
+
"claude-fable-5[1m]",
|
|
39887
|
+
"claude-opus-5",
|
|
39888
|
+
"claude-sonnet-5",
|
|
39889
|
+
"claude-haiku-4-5-20251001",
|
|
39890
|
+
"claude-opus-4-6",
|
|
39891
|
+
"claude-sonnet-4-5",
|
|
39892
|
+
"claude-sonnet-4-5-20250929",
|
|
39893
|
+
"claude-opus-4-8",
|
|
39894
|
+
"claude-opus-4-8[1m]",
|
|
39895
|
+
"claude-opus-4-7",
|
|
39896
|
+
"claude-sonnet-4-6",
|
|
39897
|
+
"claude-opus-4-5-20251101",
|
|
39898
|
+
"claude-opus-4-5",
|
|
39899
|
+
"claude-haiku-4-5",
|
|
39900
|
+
"claude-fable-5-1[1m]",
|
|
39901
|
+
"claude-opus-5[1m]",
|
|
39902
|
+
"claude-opus-4-7[1m]",
|
|
39903
|
+
"claude-opus-4-6[1m]",
|
|
39904
|
+
"claude-sonnet-4-6[1m]"
|
|
39905
|
+
]);
|
|
39906
|
+
function canonical3(value) {
|
|
39907
|
+
if (value.kind === "object")
|
|
39908
|
+
return { kind: "object", entries: value.entries.map(([key, child]) => [key, canonical3(child)]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0) };
|
|
39909
|
+
if (value.kind === "array")
|
|
39910
|
+
return { kind: "array", items: value.items.map(canonical3) };
|
|
39911
|
+
return value;
|
|
39912
|
+
}
|
|
39913
|
+
function settingsDigest(text2) {
|
|
39914
|
+
const value = parse6(text2);
|
|
39915
|
+
value.entries = value.entries.filter(([key, child]) => {
|
|
39916
|
+
if (key === "model") {
|
|
39917
|
+
need3(child.kind === "string", "contains an invalid model selection");
|
|
39918
|
+
return !BUILTIN_MODEL_SELECTIONS.has(child.value);
|
|
39919
|
+
}
|
|
39920
|
+
if (BOOLEAN_PREFERENCES.has(key)) {
|
|
39921
|
+
need3(child.kind === "literal" && (child.value === "true" || child.value === "false"), "contains an invalid display preference");
|
|
39922
|
+
return false;
|
|
39923
|
+
}
|
|
39924
|
+
if (Object.hasOwn(ENUM_PREFERENCES, key)) {
|
|
39925
|
+
need3(child.kind === "string" && ENUM_PREFERENCES[key].includes(child.value), "contains an invalid display preference");
|
|
39926
|
+
return false;
|
|
39927
|
+
}
|
|
39928
|
+
return true;
|
|
39929
|
+
});
|
|
39930
|
+
return createHash12("sha256").update("hasna.skills.claude-settings.v1\x00").update(JSON.stringify(canonical3(value))).digest("hex");
|
|
39931
|
+
}
|
|
39932
|
+
function hashClaudeSettingsReplacement(text2, budget) {
|
|
39933
|
+
need3(typeof text2 === "string", "requires settings text");
|
|
39934
|
+
const bytes = Buffer.byteLength(text2);
|
|
39935
|
+
need3(bytes <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes && Number.isSafeInteger(budget.remaining) && budget.remaining >= bytes, "exceeds its byte limit");
|
|
39936
|
+
budget.remaining -= bytes;
|
|
39937
|
+
return settingsDigest(text2);
|
|
39938
|
+
}
|
|
39939
|
+
function captureClaudeSettings(path, budget = { remaining: 256 * 1024 * 1024 }) {
|
|
39940
|
+
return { path, hashMode: "claude-settings-v1", sha256: settingsDigest(readSettings(path, budget)) };
|
|
39941
|
+
}
|
|
39942
|
+
|
|
39721
39943
|
// src/lib/agent-discovery.ts
|
|
39722
|
-
var digest2 = (text2) =>
|
|
39944
|
+
var digest2 = (text2) => createHash13("sha256").update(text2).digest("hex");
|
|
39723
39945
|
function parseConfig(text2, path, toml = false) {
|
|
39724
39946
|
try {
|
|
39725
39947
|
const value = toml ? Bun.TOML.parse(text2) : JSON.parse(text2);
|
|
@@ -39731,12 +39953,12 @@ function parseConfig(text2, path, toml = false) {
|
|
|
39731
39953
|
}
|
|
39732
39954
|
}
|
|
39733
39955
|
function safe4(path) {
|
|
39734
|
-
if (!
|
|
39956
|
+
if (!isAbsolute14(path) || path.includes("\x00"))
|
|
39735
39957
|
throw new Error("Expected an absolute native discovery path");
|
|
39736
|
-
for (let cursor = path;; cursor =
|
|
39737
|
-
if (
|
|
39958
|
+
for (let cursor = path;; cursor = dirname12(cursor)) {
|
|
39959
|
+
if (lstatSync16(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
39738
39960
|
throw new Error(`Refusing symlink native discovery input: ${cursor}`);
|
|
39739
|
-
if (
|
|
39961
|
+
if (dirname12(cursor) === cursor)
|
|
39740
39962
|
break;
|
|
39741
39963
|
}
|
|
39742
39964
|
}
|
|
@@ -39744,7 +39966,7 @@ function read(path, changes) {
|
|
|
39744
39966
|
safe4(path);
|
|
39745
39967
|
if (changes?.has(path))
|
|
39746
39968
|
return changes.get(path);
|
|
39747
|
-
const stat2 =
|
|
39969
|
+
const stat2 = lstatSync16(path, { throwIfNoEntry: false });
|
|
39748
39970
|
if (!stat2)
|
|
39749
39971
|
return null;
|
|
39750
39972
|
if (!stat2.isFile() || stat2.size > 16 * 1024 * 1024)
|
|
@@ -39752,6 +39974,14 @@ function read(path, changes) {
|
|
|
39752
39974
|
return readFileSync12(path, "utf8");
|
|
39753
39975
|
}
|
|
39754
39976
|
function projected(source, changes, budget = discoveryByteBudget()) {
|
|
39977
|
+
if (source.hashMode === "claude-settings-v1") {
|
|
39978
|
+
if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256))
|
|
39979
|
+
throw new Error("Claude settings witnesses require exact typed metadata");
|
|
39980
|
+
const current = captureClaudeSettings(source.path, budget).sha256;
|
|
39981
|
+
if (current !== source.sha256)
|
|
39982
|
+
throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
|
|
39983
|
+
return changes?.has(source.path) ? hashClaudeSettingsReplacement(changes.get(source.path), budget) : current;
|
|
39984
|
+
}
|
|
39755
39985
|
if (source.hashMode === "claude-marketplace-registry") {
|
|
39756
39986
|
if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256) || changes?.has(source.path))
|
|
39757
39987
|
throw new Error("Claude marketplace witnesses require an exact reviewed registry without synthetic changes");
|
|
@@ -39809,6 +40039,8 @@ function verifyAgentDiscovery(binding) {
|
|
|
39809
40039
|
safe4(root2);
|
|
39810
40040
|
}
|
|
39811
40041
|
function assertMarketplaceBinding(binding, source) {
|
|
40042
|
+
if (source.hashMode === "claude-settings-v1" && (binding.agent !== "claude" || binding.method !== "reviewed" || basename6(source.path) !== "settings.json"))
|
|
40043
|
+
throw new Error("Claude settings witnesses require explicit reviewed Claude configuration");
|
|
39812
40044
|
if (source.hashMode === "claude-marketplace-registry" && (binding.agent !== "claude" || binding.method !== "reviewed"))
|
|
39813
40045
|
throw new Error("Claude marketplace witnesses require explicit reviewed Claude discovery");
|
|
39814
40046
|
}
|
|
@@ -39832,10 +40064,10 @@ function captureDiscoveryPathSources(paths) {
|
|
|
39832
40064
|
return paths.map((path) => ({ path, hashMode: "path-bytes", sha256: hashDiscoveryPathFile(path, budget) }));
|
|
39833
40065
|
}
|
|
39834
40066
|
function resolveAgentDiscovery(options) {
|
|
39835
|
-
const
|
|
40067
|
+
const canonical4 = options.canonical ?? resolve13, home = resolve13(options.home), agent = options.agent;
|
|
39836
40068
|
const sources = [], roots = new Set, builtinNames = [];
|
|
39837
40069
|
const witness = (path, format, fields) => {
|
|
39838
|
-
const source = { path:
|
|
40070
|
+
const source = { path: canonical4(path), sha256: null, ...format ? { format, fields } : {} };
|
|
39839
40071
|
source.sha256 = projected(source);
|
|
39840
40072
|
sources.push(source);
|
|
39841
40073
|
return read(source.path);
|
|
@@ -39863,7 +40095,7 @@ function resolveAgentDiscovery(options) {
|
|
|
39863
40095
|
continue;
|
|
39864
40096
|
if (normalized.startsWith("~") && normalized !== "~" && !normalized.startsWith("~/"))
|
|
39865
40097
|
unresolved("user-specific tilde expansion requires a separate discovery adapter");
|
|
39866
|
-
const path = normalized === "~" ? home : normalized.startsWith("~/") ? join20(home, normalized.slice(2)) :
|
|
40098
|
+
const path = normalized === "~" ? home : normalized.startsWith("~/") ? join20(home, normalized.slice(2)) : resolve13(home, ".hermes", normalized);
|
|
39867
40099
|
safe4(path);
|
|
39868
40100
|
roots.add(path);
|
|
39869
40101
|
}
|
|
@@ -39872,21 +40104,21 @@ function resolveAgentDiscovery(options) {
|
|
|
39872
40104
|
const executable = Bun.which("gemini");
|
|
39873
40105
|
if (executable) {
|
|
39874
40106
|
let packageRoot;
|
|
39875
|
-
for (let directory =
|
|
40107
|
+
for (let directory = dirname12(realpathSync3(executable)), depth = 0;depth < 8; directory = dirname12(directory), depth++) {
|
|
39876
40108
|
const path = join20(directory, "package.json"), raw = read(path);
|
|
39877
40109
|
if (raw !== null && parseConfig(raw, path).name === "@google/gemini-cli") {
|
|
39878
40110
|
packageRoot = directory;
|
|
39879
40111
|
witness(path);
|
|
39880
40112
|
break;
|
|
39881
40113
|
}
|
|
39882
|
-
if (
|
|
40114
|
+
if (dirname12(directory) === directory)
|
|
39883
40115
|
break;
|
|
39884
40116
|
}
|
|
39885
40117
|
if (!packageRoot)
|
|
39886
40118
|
unresolved("installed Gemini package layout is not recognized");
|
|
39887
40119
|
const builtinRoot = join20(packageRoot, "bundle/builtin");
|
|
39888
40120
|
safe4(builtinRoot);
|
|
39889
|
-
if (!
|
|
40121
|
+
if (!lstatSync16(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
|
|
39890
40122
|
unresolved("installed Gemini builtin root is missing");
|
|
39891
40123
|
for (const name of readdirSync6(builtinRoot).sort()) {
|
|
39892
40124
|
const text2 = witness(join20(builtinRoot, name, "SKILL.md"));
|
|
@@ -39907,12 +40139,14 @@ function resolveAgentDiscovery(options) {
|
|
|
39907
40139
|
if (review.sources.some((source) => source.format !== undefined || source.fields !== undefined))
|
|
39908
40140
|
throw new Error("Explicit discovery reviews require full source-file hashes");
|
|
39909
40141
|
verifyAgentDiscovery(supplied);
|
|
39910
|
-
if (
|
|
40142
|
+
if (review.sources.some((source) => source.hashMode === "claude-settings-v1" && source.path !== canonical4(configPath)))
|
|
40143
|
+
throw new Error("Semantic settings witnesses must name the configured Claude configuration source");
|
|
40144
|
+
if (!review.sources.some((source) => source.path === canonical4(configPath)))
|
|
39911
40145
|
throw new Error("Discovery review must include the agent configuration source");
|
|
39912
40146
|
return { ...supplied, roots: [...new Set([...roots, ...supplied.roots])].sort(), sources: [...sources, ...review.sources], ...agent === "gemini" ? { builtinNames } : {} };
|
|
39913
40147
|
}
|
|
39914
40148
|
function plugin(root2) {
|
|
39915
|
-
root2 =
|
|
40149
|
+
root2 = canonical4(root2);
|
|
39916
40150
|
safe4(root2);
|
|
39917
40151
|
const manifestPath = join20(root2, agent === "claude" ? ".claude-plugin/plugin.json" : ".codex-plugin/plugin.json");
|
|
39918
40152
|
const raw = witness(manifestPath);
|
|
@@ -39924,7 +40158,7 @@ function resolveAgentDiscovery(options) {
|
|
|
39924
40158
|
unresolved("plugin hooks require a separate no-skill-injection review");
|
|
39925
40159
|
const commands = join20(root2, "commands");
|
|
39926
40160
|
safe4(commands);
|
|
39927
|
-
if (agent === "claude" && (manifest.commands !== undefined ||
|
|
40161
|
+
if (agent === "claude" && (manifest.commands !== undefined || lstatSync16(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync6(commands).length))
|
|
39928
40162
|
unresolved("legacy command discovery requires retirement or a dedicated format adapter");
|
|
39929
40163
|
const rootSkill = witness(join20(root2, "SKILL.md"));
|
|
39930
40164
|
if (rootSkill !== null)
|
|
@@ -39935,18 +40169,18 @@ function resolveAgentDiscovery(options) {
|
|
|
39935
40169
|
if (agent === "claude")
|
|
39936
40170
|
roots.add(join20(root2, "skills"));
|
|
39937
40171
|
for (const value of declared) {
|
|
39938
|
-
const path =
|
|
40172
|
+
const path = resolve13(root2, value);
|
|
39939
40173
|
if (path !== root2 && !path.startsWith(root2 + sep3))
|
|
39940
40174
|
unresolved("plugin skill path escapes its root");
|
|
39941
|
-
roots.add(path.endsWith(`${sep3}SKILL.md`) ?
|
|
40175
|
+
roots.add(path.endsWith(`${sep3}SKILL.md`) ? dirname12(path) : path);
|
|
39942
40176
|
}
|
|
39943
40177
|
}
|
|
39944
40178
|
if (agent === "claude") {
|
|
39945
40179
|
const registrations = witness(join20(home, ".claude/plugins/installed_plugins.json"));
|
|
39946
40180
|
const installed = registrations === null ? {} : parseConfig(registrations, join20(home, ".claude/plugins/installed_plugins.json")).plugins;
|
|
39947
|
-
const commands =
|
|
40181
|
+
const commands = canonical4(join20(home, ".claude/commands"));
|
|
39948
40182
|
safe4(commands);
|
|
39949
|
-
if (
|
|
40183
|
+
if (lstatSync16(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync6(commands).length)
|
|
39950
40184
|
unresolved("legacy home command discovery requires a dedicated format adapter");
|
|
39951
40185
|
for (const [id2, enabled] of Object.entries(config.enabledPlugins ?? {})) {
|
|
39952
40186
|
if (enabled === false)
|
|
@@ -39966,7 +40200,7 @@ function resolveAgentDiscovery(options) {
|
|
|
39966
40200
|
unresolved("unsupported plugin enablement");
|
|
39967
40201
|
const split = id2.lastIndexOf("@"), name = id2.slice(0, split), marketplace = id2.slice(split + 1);
|
|
39968
40202
|
const market = config.marketplaces?.[marketplace] ?? (marketplace === "personal" ? { source_type: "local", source: home } : undefined);
|
|
39969
|
-
if (split < 1 || market?.source_type !== "local" || typeof market.source !== "string" || !
|
|
40203
|
+
if (split < 1 || market?.source_type !== "local" || typeof market.source !== "string" || !isAbsolute14(market.source))
|
|
39970
40204
|
unresolved("enabled plugin marketplace is not an explicit local source");
|
|
39971
40205
|
const catalogText = witness(join20(market.source, ".agents/plugins/marketplace.json"));
|
|
39972
40206
|
if (catalogText === null)
|
|
@@ -39974,7 +40208,7 @@ function resolveAgentDiscovery(options) {
|
|
|
39974
40208
|
const catalog = parseConfig(catalogText, join20(market.source, ".agents/plugins/marketplace.json")), matches = Array.isArray(catalog.plugins) ? catalog.plugins.filter((item) => item.name === name) : [];
|
|
39975
40209
|
if (matches.length !== 1 || matches[0]?.source?.source !== "local" || typeof matches[0]?.source?.path !== "string")
|
|
39976
40210
|
unresolved("plugin catalog source is missing or ambiguous");
|
|
39977
|
-
plugin(
|
|
40211
|
+
plugin(resolve13(market.source, matches[0].source.path));
|
|
39978
40212
|
}
|
|
39979
40213
|
} else if (agent === "opencode") {
|
|
39980
40214
|
if (witness(join20(home, ".config/opencode/opencode.jsonc")) !== null || witness(join20(home, ".config/opencode/config.json")) !== null)
|
|
@@ -39982,18 +40216,18 @@ function resolveAgentDiscovery(options) {
|
|
|
39982
40216
|
if ((config.plugin?.length ?? 0) > 0 || config.skills?.urls?.length)
|
|
39983
40217
|
unresolved("external plugin or remote skill source");
|
|
39984
40218
|
for (const path of config.skills?.paths ?? []) {
|
|
39985
|
-
if (typeof path !== "string" || !
|
|
40219
|
+
if (typeof path !== "string" || !isAbsolute14(path))
|
|
39986
40220
|
unresolved("relative or malformed added skill root");
|
|
39987
40221
|
roots.add(path);
|
|
39988
40222
|
}
|
|
39989
40223
|
const localPlugins = join20(home, ".config/opencode/plugins");
|
|
39990
40224
|
safe4(localPlugins);
|
|
39991
|
-
if (
|
|
40225
|
+
if (lstatSync16(localPlugins, { throwIfNoEntry: false }) && readdirSync6(localPlugins).some((name) => name !== "skills-cli.js"))
|
|
39992
40226
|
unresolved("additional local plugin hooks require review");
|
|
39993
40227
|
} else if (agent === "hermes") {
|
|
39994
40228
|
for (const directory of [join20(home, ".hermes/plugins"), join20(home, ".hermes/hermes-agent")]) {
|
|
39995
40229
|
safe4(directory);
|
|
39996
|
-
if (
|
|
40230
|
+
if (lstatSync16(directory, { throwIfNoEntry: false }))
|
|
39997
40231
|
unresolved("installed runtime/plugin discovery requires reviewed source bindings");
|
|
39998
40232
|
}
|
|
39999
40233
|
if (Bun.which("hermes") || Object.keys(config.plugins ?? {}).length)
|
|
@@ -40003,11 +40237,11 @@ function resolveAgentDiscovery(options) {
|
|
|
40003
40237
|
unresolved("custom extension or skill paths");
|
|
40004
40238
|
const directory = join20(home, ".gemini/extensions");
|
|
40005
40239
|
safe4(directory);
|
|
40006
|
-
if (
|
|
40240
|
+
if (lstatSync16(directory, { throwIfNoEntry: false }))
|
|
40007
40241
|
for (const name of readdirSync6(directory)) {
|
|
40008
40242
|
const root2 = join20(directory, name);
|
|
40009
40243
|
safe4(root2);
|
|
40010
|
-
if (!
|
|
40244
|
+
if (!lstatSync16(root2)?.isDirectory())
|
|
40011
40245
|
continue;
|
|
40012
40246
|
const raw = witness(join20(root2, "gemini-extension.json"));
|
|
40013
40247
|
if (raw === null)
|
|
@@ -40018,7 +40252,7 @@ function resolveAgentDiscovery(options) {
|
|
|
40018
40252
|
roots.add(join20(root2, "skills"));
|
|
40019
40253
|
}
|
|
40020
40254
|
}
|
|
40021
|
-
return { agent, roots: [...roots].sort(), sources, method: "automatic", ...agent === "gemini" ? { builtinNames } : {}, ...agent === "hermes" ? { directories: captureDiscoveryDirectories([join20(home, ".hermes/plugins"), join20(home, ".hermes/hermes-agent")].map((path) =>
|
|
40255
|
+
return { agent, roots: [...roots].sort(), sources, method: "automatic", ...agent === "gemini" ? { builtinNames } : {}, ...agent === "hermes" ? { directories: captureDiscoveryDirectories([join20(home, ".hermes/plugins"), join20(home, ".hermes/hermes-agent")].map((path) => canonical4(path))) } : {} };
|
|
40022
40256
|
}
|
|
40023
40257
|
|
|
40024
40258
|
// src/lib/agent-adapters.ts
|
|
@@ -40162,7 +40396,7 @@ function disableCodexBundledSkills(text2) {
|
|
|
40162
40396
|
}
|
|
40163
40397
|
|
|
40164
40398
|
// src/lib/agent-integration.ts
|
|
40165
|
-
var sha = (data) =>
|
|
40399
|
+
var sha = (data) => createHash14("sha256").update(data).digest("hex");
|
|
40166
40400
|
var ROOTS = [
|
|
40167
40401
|
["claude", ".claude/skills"],
|
|
40168
40402
|
["codex", ".codex/skills"],
|
|
@@ -40181,11 +40415,11 @@ var ROOTS = [
|
|
|
40181
40415
|
["copilot", ".github/skills"]
|
|
40182
40416
|
];
|
|
40183
40417
|
function assertSafePath(path) {
|
|
40184
|
-
let cursor =
|
|
40418
|
+
let cursor = resolve14(path);
|
|
40185
40419
|
while (true) {
|
|
40186
|
-
if (
|
|
40420
|
+
if (lstatSync17(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
40187
40421
|
throw new Error(`Refusing symlink path: ${cursor}`);
|
|
40188
|
-
const parent =
|
|
40422
|
+
const parent = dirname13(cursor);
|
|
40189
40423
|
if (parent === cursor)
|
|
40190
40424
|
return;
|
|
40191
40425
|
cursor = parent;
|
|
@@ -40194,16 +40428,16 @@ function assertSafePath(path) {
|
|
|
40194
40428
|
function readRootAlias(home, agent) {
|
|
40195
40429
|
assertSafePath(home);
|
|
40196
40430
|
const realHome = realpathSync4(home), alias = join21(realHome, `.${agent}`);
|
|
40197
|
-
const stat2 =
|
|
40431
|
+
const stat2 = lstatSync17(alias, { throwIfNoEntry: false, bigint: true });
|
|
40198
40432
|
if (!stat2?.isSymbolicLink())
|
|
40199
40433
|
throw new Error(`Agent root alias changed after planning: ${alias}`);
|
|
40200
|
-
const link = readlinkSync2(alias), targetPath =
|
|
40434
|
+
const link = readlinkSync2(alias), targetPath = resolve14(dirname13(alias), link);
|
|
40201
40435
|
assertSafePath(targetPath);
|
|
40202
|
-
const targetStat =
|
|
40436
|
+
const targetStat = lstatSync17(targetPath, { throwIfNoEntry: false });
|
|
40203
40437
|
if (!targetStat?.isDirectory())
|
|
40204
40438
|
throw new Error(`Agent root alias must target an existing directory: ${alias}`);
|
|
40205
40439
|
const target = realpathSync4(targetPath), inside = relative3(realHome, target);
|
|
40206
|
-
if (!inside || inside === ".." || inside.startsWith(`..${sep4}`) ||
|
|
40440
|
+
if (!inside || inside === ".." || inside.startsWith(`..${sep4}`) || isAbsolute15(inside))
|
|
40207
40441
|
throw new Error(`Agent root alias target must be inside the real home: ${alias}`);
|
|
40208
40442
|
return { agent, home: realHome, alias, target, link, aliasIdentity: `${stat2.dev}:${stat2.ino}:${stat2.ctimeNs}`, targetIdentity: `${targetStat.dev}:${targetStat.ino}` };
|
|
40209
40443
|
}
|
|
@@ -40212,14 +40446,14 @@ function rootAliases(home, allowed = false) {
|
|
|
40212
40446
|
return [];
|
|
40213
40447
|
const result = [];
|
|
40214
40448
|
for (const agent of ["claude", "codex"])
|
|
40215
|
-
if (
|
|
40449
|
+
if (lstatSync17(join21(home, `.${agent}`), { throwIfNoEntry: false })?.isSymbolicLink())
|
|
40216
40450
|
result.push(readRootAlias(home, agent));
|
|
40217
40451
|
if (result.some((item, index) => result.slice(index + 1).some((other) => item.target === other.target || item.target.startsWith(other.target + sep4) || other.target.startsWith(item.target + sep4))))
|
|
40218
40452
|
throw new Error("Agent root alias targets must not overlap");
|
|
40219
40453
|
return result;
|
|
40220
40454
|
}
|
|
40221
40455
|
function canonicalAgentPath(path, aliases) {
|
|
40222
|
-
const absolute =
|
|
40456
|
+
const absolute = resolve14(path), binding = aliases.find((item) => absolute === item.alias || absolute.startsWith(item.alias + sep4));
|
|
40223
40457
|
return binding ? join21(binding.target, relative3(binding.alias, absolute)) : absolute;
|
|
40224
40458
|
}
|
|
40225
40459
|
function recheckRootAliases(aliases) {
|
|
@@ -40233,35 +40467,35 @@ function recheckRootAliases(aliases) {
|
|
|
40233
40467
|
}
|
|
40234
40468
|
function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
|
|
40235
40469
|
assertSafePath(path);
|
|
40236
|
-
const before =
|
|
40470
|
+
const before = lstatSync17(path);
|
|
40237
40471
|
if (!before.isFile() || before.size > maximum)
|
|
40238
40472
|
throw new Error("Unsupported or oversized native skill file");
|
|
40239
|
-
const descriptor =
|
|
40473
|
+
const descriptor = openSync15(path, constants11.O_RDONLY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
|
|
40240
40474
|
try {
|
|
40241
|
-
const opened =
|
|
40475
|
+
const opened = fstatSync15(descriptor);
|
|
40242
40476
|
if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino || opened.size !== before.size)
|
|
40243
40477
|
throw new Error("Native skill file changed while reading");
|
|
40244
40478
|
const bytes = Buffer.allocUnsafe(before.size + 1);
|
|
40245
40479
|
let length = 0;
|
|
40246
40480
|
while (length < bytes.length) {
|
|
40247
|
-
const count =
|
|
40481
|
+
const count = readSync10(descriptor, bytes, length, bytes.length - length, null);
|
|
40248
40482
|
if (!count)
|
|
40249
40483
|
break;
|
|
40250
40484
|
length += count;
|
|
40251
40485
|
}
|
|
40252
|
-
const after =
|
|
40486
|
+
const after = fstatSync15(descriptor);
|
|
40253
40487
|
if (length !== before.size || after.size !== before.size || after.mtimeMs !== opened.mtimeMs || after.ctimeMs !== opened.ctimeMs)
|
|
40254
40488
|
throw new Error("Native skill file changed while reading");
|
|
40255
40489
|
return bytes.subarray(0, length);
|
|
40256
40490
|
} finally {
|
|
40257
|
-
|
|
40491
|
+
closeSync15(descriptor);
|
|
40258
40492
|
}
|
|
40259
40493
|
}
|
|
40260
40494
|
function treeHash(root2) {
|
|
40261
|
-
const hash2 =
|
|
40495
|
+
const hash2 = createHash14("sha256");
|
|
40262
40496
|
let bytes = 0, files = 0;
|
|
40263
40497
|
function visit2(path) {
|
|
40264
|
-
const stat2 =
|
|
40498
|
+
const stat2 = lstatSync17(path);
|
|
40265
40499
|
if (stat2.isSymbolicLink())
|
|
40266
40500
|
throw new Error(`Refusing symlink in skill: ${path}`);
|
|
40267
40501
|
const rel = relative3(root2, path);
|
|
@@ -40287,11 +40521,11 @@ function treeHash(root2) {
|
|
|
40287
40521
|
function projectAncestorDirectories(projects) {
|
|
40288
40522
|
const directories = new Set;
|
|
40289
40523
|
for (const project of projects) {
|
|
40290
|
-
for (let path =
|
|
40524
|
+
for (let path = resolve14(project), depth = 0;; depth++) {
|
|
40291
40525
|
if (depth >= 100)
|
|
40292
40526
|
throw new Error("NATIVE_SKILL_DRIFT: project ancestor discovery limit exceeded");
|
|
40293
40527
|
directories.add(path);
|
|
40294
|
-
const parent =
|
|
40528
|
+
const parent = dirname13(path);
|
|
40295
40529
|
if (parent === path)
|
|
40296
40530
|
break;
|
|
40297
40531
|
path = parent;
|
|
@@ -40318,10 +40552,10 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40318
40552
|
throw new Error("Native skill discovery metadata limit exceeded");
|
|
40319
40553
|
}
|
|
40320
40554
|
function emptySiblingCacheAlias(path, parent) {
|
|
40321
|
-
const link = readlinkSync2(path), target =
|
|
40322
|
-
if (
|
|
40555
|
+
const link = readlinkSync2(path), target = resolve14(parent, link);
|
|
40556
|
+
if (dirname13(target) !== parent || (isAbsolute15(link) ? link !== target : dirname13(link) !== "."))
|
|
40323
40557
|
return false;
|
|
40324
|
-
if (!
|
|
40558
|
+
if (!lstatSync17(target, { throwIfNoEntry: false })?.isDirectory())
|
|
40325
40559
|
return false;
|
|
40326
40560
|
const scan = cacheScans.get(target);
|
|
40327
40561
|
return Boolean(scan?.complete && !scan.hasSkills && scan.entries <= maxAliasProofEntries);
|
|
@@ -40333,7 +40567,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40333
40567
|
assertSafePath(path);
|
|
40334
40568
|
if (!existsSync6(path))
|
|
40335
40569
|
return scan;
|
|
40336
|
-
const stat2 =
|
|
40570
|
+
const stat2 = lstatSync17(path);
|
|
40337
40571
|
if (stat2.isFile())
|
|
40338
40572
|
return scan;
|
|
40339
40573
|
if (!stat2.isDirectory())
|
|
@@ -40352,7 +40586,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40352
40586
|
}
|
|
40353
40587
|
const bridge = !vendor && isOwnedCliBridge(path, bridgePaths);
|
|
40354
40588
|
const rootAlias = aliases.find((item) => path === item.target || path.startsWith(item.target + sep4));
|
|
40355
|
-
entries.push({ agent, path, hash: treeHash(path), managed, vendor, ...agent === "codex" && path.startsWith(canonicalAgentPath(join21(home, ".codex", "skills", ".system"), aliases) + sep4) ? { system: true } : {}, ...bridge ? { bridge: true, bridgeHome:
|
|
40589
|
+
entries.push({ agent, path, hash: treeHash(path), managed, vendor, ...agent === "codex" && path.startsWith(canonicalAgentPath(join21(home, ".codex", "skills", ".system"), aliases) + sep4) ? { system: true } : {}, ...bridge ? { bridge: true, bridgeHome: resolve14(home) } : {}, ...rootAlias ? { rootAlias } : {} });
|
|
40356
40590
|
return scan;
|
|
40357
40591
|
}
|
|
40358
40592
|
if (depth > (vendor ? 32 : 3))
|
|
@@ -40379,7 +40613,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40379
40613
|
if (isVendor && !options.includeVendor)
|
|
40380
40614
|
continue;
|
|
40381
40615
|
const child = join21(path, name);
|
|
40382
|
-
if (isVendor &&
|
|
40616
|
+
if (isVendor && lstatSync17(child, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
40383
40617
|
const target = statSync5(child, { throwIfNoEntry: false });
|
|
40384
40618
|
if (target?.isFile() || pluginCache && target?.isDirectory() && emptySiblingCacheAlias(child, path)) {
|
|
40385
40619
|
scan.entries++;
|
|
@@ -40501,7 +40735,7 @@ function configureHooks(config, agent, command, profileId, nativeReady) {
|
|
|
40501
40735
|
function disableCodexSkills(text2, skills, aliases, bridgePath) {
|
|
40502
40736
|
const bundled = disableCodexBundledSkills(text2);
|
|
40503
40737
|
let result = bundled;
|
|
40504
|
-
const bridgeSelector = (entry) => typeof entry.name === "string" && entry.name.trim() === CLI_BRIDGE_NAME || typeof entry.path === "string" && [
|
|
40738
|
+
const bridgeSelector = (entry) => typeof entry.name === "string" && entry.name.trim() === CLI_BRIDGE_NAME || typeof entry.path === "string" && [resolve14(bridgePath), resolve14(join21(bridgePath, "SKILL.md"))].includes(canonicalAgentPath(entry.path, aliases));
|
|
40505
40739
|
const previousConfig = Bun.TOML.parse(bundled).skills?.config;
|
|
40506
40740
|
if (previousConfig !== undefined && (!Array.isArray(previousConfig) || previousConfig.some((entry) => !entry || typeof entry !== "object" || entry.path !== undefined && entry.name !== undefined)))
|
|
40507
40741
|
throw new Error("Codex skill controls require one path or name selector per [[skills.config]] entry; review ambiguous entries before running skills hook install");
|
|
@@ -40513,7 +40747,7 @@ function disableCodexSkills(text2, skills, aliases, bridgePath) {
|
|
|
40513
40747
|
result = result.replace(CODEX_SKILL_CONFIG_SECTIONS, (section) => {
|
|
40514
40748
|
const parsed = Bun.TOML.parse(section);
|
|
40515
40749
|
const declared = parsed.skills?.config?.[0];
|
|
40516
|
-
if (!declared || !(skill.enabled && bridgeSelector(declared)) && !(typeof declared.path === "string" && [
|
|
40750
|
+
if (!declared || !(skill.enabled && bridgeSelector(declared)) && !(typeof declared.path === "string" && [resolve14(path), resolve14(skill.path)].includes(canonicalAgentPath(declared.path, aliases))))
|
|
40517
40751
|
return section;
|
|
40518
40752
|
found = true;
|
|
40519
40753
|
return /^\s*enabled\s*=/m.test(section) ? section.replace(/^\s*enabled\s*=.*$/m, `enabled = ${skill.enabled}`) : `${section.trimEnd()}
|
|
@@ -40631,7 +40865,7 @@ function planAgentIntegration(options) {
|
|
|
40631
40865
|
version: CLI_BRIDGE_VERSION,
|
|
40632
40866
|
digest: CLI_BRIDGE_DIGEST,
|
|
40633
40867
|
agents: [...new Set([...priorAgents, ...options.agents])].sort(),
|
|
40634
|
-
home:
|
|
40868
|
+
home: resolve14(home),
|
|
40635
40869
|
includeVendor: true,
|
|
40636
40870
|
...options.agents.includes("hermes") ? { supervisors: { ...policy.bridge?.supervisors, hermes: { path: join21(dataDir2, "agent-hooks", "hermes.js"), runtime: process.execPath, sha256: sha(renderHermesSupervisor(bindings.get("hermes").command, bindings.get("hermes").profileId)) } } } : {},
|
|
40637
40871
|
commands: { ...policy.bridge?.commands, ...Object.fromEntries([...bindings].map(([agent, binding]) => [agent, binding.command])) },
|
|
@@ -40648,7 +40882,7 @@ function planAgentIntegration(options) {
|
|
|
40648
40882
|
}
|
|
40649
40883
|
function atomicWrite2(path, content) {
|
|
40650
40884
|
assertSafePath(path);
|
|
40651
|
-
mkdirSync5(
|
|
40885
|
+
mkdirSync5(dirname13(path), { recursive: true, mode: 448 });
|
|
40652
40886
|
const temporary = `${path}.skills-${randomUUID3()}`;
|
|
40653
40887
|
try {
|
|
40654
40888
|
writeFileSync3(temporary, content, { mode: 384, flag: "wx" });
|
|
@@ -40661,10 +40895,10 @@ function atomicWrite2(path, content) {
|
|
|
40661
40895
|
function applyAgentIntegration(plan) {
|
|
40662
40896
|
const policyPath = join21(plan.dataDir, "agent-policy.json");
|
|
40663
40897
|
assertSafePath(policyPath);
|
|
40664
|
-
const currentText = (path) =>
|
|
40898
|
+
const currentText = (path) => resolve14(path) === resolve14(policyPath) ? readManagedSkillPolicySnapshot(plan.dataDir)?.text ?? null : readOptional(path);
|
|
40665
40899
|
readManagedSkillPolicySnapshot(plan.dataDir);
|
|
40666
40900
|
for (const change of plan.changes)
|
|
40667
|
-
if (
|
|
40901
|
+
if (resolve14(change.path) === resolve14(policyPath))
|
|
40668
40902
|
parseManagedSkillPolicy(change.after);
|
|
40669
40903
|
const aliases = plan.rootAliases ?? [];
|
|
40670
40904
|
recheckRootAliases(aliases);
|
|
@@ -40694,7 +40928,7 @@ function applyAgentIntegration(plan) {
|
|
|
40694
40928
|
recheckRootAliases(aliases);
|
|
40695
40929
|
if (currentText(change.path) !== change.before)
|
|
40696
40930
|
throw new Error(`Configuration changed after planning: ${change.path}`);
|
|
40697
|
-
for (let directory =
|
|
40931
|
+
for (let directory = dirname13(change.path);!existsSync6(directory); directory = dirname13(directory))
|
|
40698
40932
|
createdDirectories.add(directory);
|
|
40699
40933
|
const after = change.after;
|
|
40700
40934
|
atomicWrite2(change.path, after);
|
|
@@ -40734,11 +40968,11 @@ function applyAgentIntegration(plan) {
|
|
|
40734
40968
|
}
|
|
40735
40969
|
function syncArchiveDirectory(path) {
|
|
40736
40970
|
assertSafePath(path);
|
|
40737
|
-
const descriptor =
|
|
40971
|
+
const descriptor = openSync15(path, constants11.O_RDONLY | constants11.O_DIRECTORY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
|
|
40738
40972
|
try {
|
|
40739
40973
|
fsyncSync3(descriptor);
|
|
40740
40974
|
} finally {
|
|
40741
|
-
|
|
40975
|
+
closeSync15(descriptor);
|
|
40742
40976
|
}
|
|
40743
40977
|
}
|
|
40744
40978
|
function writeArchiveJournal(path, value) {
|
|
@@ -40746,18 +40980,18 @@ function writeArchiveJournal(path, value) {
|
|
|
40746
40980
|
const temporary = `${path}.skills-${randomUUID3()}`;
|
|
40747
40981
|
let descriptor;
|
|
40748
40982
|
try {
|
|
40749
|
-
descriptor =
|
|
40983
|
+
descriptor = openSync15(temporary, constants11.O_WRONLY | constants11.O_CREAT | constants11.O_EXCL | constants11.O_NOFOLLOW, 384);
|
|
40750
40984
|
writeFileSync3(descriptor, `${JSON.stringify(value)}
|
|
40751
40985
|
`);
|
|
40752
40986
|
fsyncSync3(descriptor);
|
|
40753
|
-
|
|
40987
|
+
closeSync15(descriptor);
|
|
40754
40988
|
descriptor = undefined;
|
|
40755
40989
|
renameSync3(temporary, path);
|
|
40756
|
-
syncArchiveDirectory(
|
|
40990
|
+
syncArchiveDirectory(dirname13(path));
|
|
40757
40991
|
} finally {
|
|
40758
40992
|
if (descriptor !== undefined)
|
|
40759
|
-
|
|
40760
|
-
if (
|
|
40993
|
+
closeSync15(descriptor);
|
|
40994
|
+
if (lstatSync17(temporary, { throwIfNoEntry: false }))
|
|
40761
40995
|
unlinkSync4(temporary);
|
|
40762
40996
|
}
|
|
40763
40997
|
}
|
|
@@ -40790,7 +41024,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
40790
41024
|
const moved = [];
|
|
40791
41025
|
const verifyArchive = (entry) => {
|
|
40792
41026
|
assertSafePath(entry.archive);
|
|
40793
|
-
const stat2 =
|
|
41027
|
+
const stat2 = lstatSync17(entry.archive);
|
|
40794
41028
|
if (entry.discoveryOnly ? !stat2.isFile() : !stat2.isDirectory())
|
|
40795
41029
|
throw new Error("Archive type changed");
|
|
40796
41030
|
if ((entry.discoveryOnly ? sha(readNativeBytes(entry.archive)) : treeHash(entry.archive)) !== entry.hash)
|
|
@@ -40798,14 +41032,14 @@ function archiveNativeSkills(inventory, options) {
|
|
|
40798
41032
|
};
|
|
40799
41033
|
assertSafePath(archiveRoot);
|
|
40800
41034
|
const created = [];
|
|
40801
|
-
for (let path = archiveRoot;!existsSync6(path); path =
|
|
41035
|
+
for (let path = archiveRoot;!existsSync6(path); path = dirname13(path))
|
|
40802
41036
|
created.push(path);
|
|
40803
41037
|
mkdirSync5(archiveRoot, { recursive: true, mode: 448 });
|
|
40804
41038
|
try {
|
|
40805
41039
|
for (const directory of created)
|
|
40806
41040
|
syncArchiveDirectory(directory);
|
|
40807
41041
|
if (created.length)
|
|
40808
|
-
syncArchiveDirectory(
|
|
41042
|
+
syncArchiveDirectory(dirname13(created.at(-1)));
|
|
40809
41043
|
writeArchiveJournal(receiptPath, journal);
|
|
40810
41044
|
for (const [index, entry] of selected.entries()) {
|
|
40811
41045
|
recheckRootAliases(aliases);
|
|
@@ -40817,7 +41051,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
40817
41051
|
writeArchiveJournal(receiptPath, journal);
|
|
40818
41052
|
renameSync3(move.source, move.archive);
|
|
40819
41053
|
moved.push(move);
|
|
40820
|
-
syncArchiveDirectory(
|
|
41054
|
+
syncArchiveDirectory(dirname13(move.source));
|
|
40821
41055
|
syncArchiveDirectory(archiveRoot);
|
|
40822
41056
|
verifyArchive(move);
|
|
40823
41057
|
move.status = "archived";
|
|
@@ -40838,7 +41072,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
40838
41072
|
recheckRootAliases(aliases);
|
|
40839
41073
|
assertSafePath(entry.source);
|
|
40840
41074
|
assertSafePath(entry.archive);
|
|
40841
|
-
if (
|
|
41075
|
+
if (lstatSync17(entry.source, { throwIfNoEntry: false })) {
|
|
40842
41076
|
entry.status = "recovery-required";
|
|
40843
41077
|
entry.conflict = "source-occupied";
|
|
40844
41078
|
continue;
|
|
@@ -40852,10 +41086,10 @@ function archiveNativeSkills(inventory, options) {
|
|
|
40852
41086
|
}
|
|
40853
41087
|
if (entry.discoveryOnly) {
|
|
40854
41088
|
linkSync2(entry.archive, entry.source);
|
|
40855
|
-
syncArchiveDirectory(
|
|
41089
|
+
syncArchiveDirectory(dirname13(entry.source));
|
|
40856
41090
|
unlinkSync4(entry.archive);
|
|
40857
41091
|
} else {
|
|
40858
|
-
if (
|
|
41092
|
+
if (lstatSync17(entry.source, { throwIfNoEntry: false })) {
|
|
40859
41093
|
entry.status = "recovery-required";
|
|
40860
41094
|
entry.conflict = "source-occupied";
|
|
40861
41095
|
continue;
|
|
@@ -40863,7 +41097,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
40863
41097
|
renameSync3(entry.archive, entry.source);
|
|
40864
41098
|
}
|
|
40865
41099
|
entry.status = "restored";
|
|
40866
|
-
syncArchiveDirectory(
|
|
41100
|
+
syncArchiveDirectory(dirname13(entry.source));
|
|
40867
41101
|
syncArchiveDirectory(archiveRoot);
|
|
40868
41102
|
} catch {
|
|
40869
41103
|
entry.status = "recovery-required";
|
|
@@ -40899,13 +41133,13 @@ import {
|
|
|
40899
41133
|
statSync as statSync8,
|
|
40900
41134
|
writeFileSync as writeFileSync5
|
|
40901
41135
|
} from "fs";
|
|
40902
|
-
import { basename as
|
|
41136
|
+
import { basename as basename8, dirname as dirname15, isAbsolute as isAbsolute16, join as join24, normalize as normalize2, relative as relative5, resolve as resolve15, sep as sep6 } from "path";
|
|
40903
41137
|
|
|
40904
41138
|
// src/lib/registry-data/index.ts
|
|
40905
41139
|
var SKILLS = [];
|
|
40906
41140
|
|
|
40907
41141
|
// src/lib/skill-hash.ts
|
|
40908
|
-
import { createHash as
|
|
41142
|
+
import { createHash as createHash15 } from "crypto";
|
|
40909
41143
|
import { existsSync as existsSync7, readdirSync as readdirSync8, readFileSync as readFileSync14, statSync as statSync6 } from "fs";
|
|
40910
41144
|
import { join as join22, sep as sep5 } from "path";
|
|
40911
41145
|
var CONTENT_HASH_ALGORITHM = "sha256";
|
|
@@ -41029,13 +41263,13 @@ function* bundleHashParts(files) {
|
|
|
41029
41263
|
yield new TextEncoder().encode("\x00");
|
|
41030
41264
|
}
|
|
41031
41265
|
function hashBundleFiles(files) {
|
|
41032
|
-
const hash2 =
|
|
41266
|
+
const hash2 = createHash15(CONTENT_HASH_ALGORITHM);
|
|
41033
41267
|
for (const part of bundleHashParts(files))
|
|
41034
41268
|
hash2.update(part);
|
|
41035
41269
|
return hash2.digest("hex");
|
|
41036
41270
|
}
|
|
41037
41271
|
async function hashBundleFilesCooperatively(files, check) {
|
|
41038
|
-
const hash2 =
|
|
41272
|
+
const hash2 = createHash15(CONTENT_HASH_ALGORITHM);
|
|
41039
41273
|
let bytesSinceYield = 0;
|
|
41040
41274
|
for (const part of bundleHashParts(files)) {
|
|
41041
41275
|
for (let offset = 0;offset < part.byteLength; offset += 64 * 1024) {
|
|
@@ -41044,7 +41278,7 @@ async function hashBundleFilesCooperatively(files, check) {
|
|
|
41044
41278
|
hash2.update(chunk);
|
|
41045
41279
|
bytesSinceYield += chunk.byteLength;
|
|
41046
41280
|
if (bytesSinceYield >= 256 * 1024) {
|
|
41047
|
-
await new Promise((
|
|
41281
|
+
await new Promise((resolve15) => setImmediate(resolve15));
|
|
41048
41282
|
bytesSinceYield = 0;
|
|
41049
41283
|
}
|
|
41050
41284
|
}
|
|
@@ -41197,7 +41431,7 @@ async function hashContentEntries(entries, options) {
|
|
|
41197
41431
|
const normalized = [];
|
|
41198
41432
|
let normalizedBytes = 0;
|
|
41199
41433
|
let manifest;
|
|
41200
|
-
await new Promise((
|
|
41434
|
+
await new Promise((resolve15) => setImmediate(resolve15));
|
|
41201
41435
|
for (const entry of snapshot) {
|
|
41202
41436
|
check();
|
|
41203
41437
|
if (!coveredContentPath(entry.path))
|
|
@@ -41210,7 +41444,7 @@ async function hashContentEntries(entries, options) {
|
|
|
41210
41444
|
contentLimit("Content hash normalized byte limit exceeded");
|
|
41211
41445
|
normalizedBytes += file.content.byteLength;
|
|
41212
41446
|
normalized.push(file);
|
|
41213
|
-
await new Promise((
|
|
41447
|
+
await new Promise((resolve15) => setImmediate(resolve15));
|
|
41214
41448
|
}
|
|
41215
41449
|
normalized.sort((a, b) => a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0);
|
|
41216
41450
|
check();
|
|
@@ -41418,13 +41652,13 @@ function validateRuntimeContract(manifest, issues, strict) {
|
|
|
41418
41652
|
import {
|
|
41419
41653
|
cpSync,
|
|
41420
41654
|
existsSync as existsSync8,
|
|
41421
|
-
lstatSync as
|
|
41655
|
+
lstatSync as lstatSync18,
|
|
41422
41656
|
mkdirSync as mkdirSync6,
|
|
41423
41657
|
readFileSync as readFileSync15,
|
|
41424
41658
|
realpathSync as realpathSync5,
|
|
41425
41659
|
writeFileSync as writeFileSync4
|
|
41426
41660
|
} from "fs";
|
|
41427
|
-
import { basename as
|
|
41661
|
+
import { basename as basename7, dirname as dirname14, join as join23, relative as relative4 } from "path";
|
|
41428
41662
|
var ANY_SEGMENT_COPY_EXCLUDES = new Set([
|
|
41429
41663
|
".git",
|
|
41430
41664
|
".DS_Store",
|
|
@@ -41474,11 +41708,11 @@ function normalizeNewPortableSkillName(name) {
|
|
|
41474
41708
|
throw new Error(`Invalid skill name '${name}'. Include letters or numbers.`);
|
|
41475
41709
|
return normalized;
|
|
41476
41710
|
}
|
|
41477
|
-
function readPortableSkillManifest(skillPath, fallbackName =
|
|
41711
|
+
function readPortableSkillManifest(skillPath, fallbackName = basename7(skillPath)) {
|
|
41478
41712
|
return readManifest(skillPath, fallbackName, normalizePortableSkillName);
|
|
41479
41713
|
}
|
|
41480
41714
|
function readPortableSkillManifestForImport(skillPath) {
|
|
41481
|
-
return readManifest(skillPath,
|
|
41715
|
+
return readManifest(skillPath, basename7(skillPath), normalizeNewPortableSkillName);
|
|
41482
41716
|
}
|
|
41483
41717
|
function readManifest(skillPath, fallbackName, normalizeName) {
|
|
41484
41718
|
const skillJsonPath = join23(skillPath, "skill.json");
|
|
@@ -41671,7 +41905,7 @@ function ensurePortableSkillFiles(skillPath, manifest) {
|
|
|
41671
41905
|
};
|
|
41672
41906
|
const entry = next.commands[0]?.entry ?? "src/index.ts";
|
|
41673
41907
|
if (entry && !existsSync8(join23(skillPath, entry))) {
|
|
41674
|
-
mkdirSync6(
|
|
41908
|
+
mkdirSync6(dirname14(join23(skillPath, entry)), { recursive: true });
|
|
41675
41909
|
writeFileSync4(join23(skillPath, entry), renderEntrypoint(next));
|
|
41676
41910
|
}
|
|
41677
41911
|
if (!existsSync8(join23(skillPath, "SKILL.md")))
|
|
@@ -41776,7 +42010,7 @@ function renameInstructionFrontmatter(content, name) {
|
|
|
41776
42010
|
return renamed + content.slice(frontmatter[0].length);
|
|
41777
42011
|
}
|
|
41778
42012
|
function copySkillDirectory(source, destination) {
|
|
41779
|
-
const resolvedSource =
|
|
42013
|
+
const resolvedSource = lstatSync18(source).isSymbolicLink() ? realpathSync5(source) : source;
|
|
41780
42014
|
mkdirSync6(destination, { recursive: true });
|
|
41781
42015
|
cpSync(resolvedSource, destination, {
|
|
41782
42016
|
recursive: true,
|
|
@@ -41789,7 +42023,7 @@ function copySkillDirectory(source, destination) {
|
|
|
41789
42023
|
if (isExcludedCopyEntry(segments[i], i === 0))
|
|
41790
42024
|
return false;
|
|
41791
42025
|
}
|
|
41792
|
-
if (
|
|
42026
|
+
if (lstatSync18(src).isSymbolicLink())
|
|
41793
42027
|
return false;
|
|
41794
42028
|
return true;
|
|
41795
42029
|
}
|
|
@@ -42026,7 +42260,7 @@ function inferPackageCommands(pkg, fallbackName) {
|
|
|
42026
42260
|
function readJsonObject(path) {
|
|
42027
42261
|
const parsed = JSON.parse(readFileSync15(path, "utf-8"));
|
|
42028
42262
|
if (!isRecord2(parsed))
|
|
42029
|
-
throw new Error(`${
|
|
42263
|
+
throw new Error(`${basename7(path)} must contain a JSON object`);
|
|
42030
42264
|
return parsed;
|
|
42031
42265
|
}
|
|
42032
42266
|
function hasPackageDependencies(pkgPath) {
|
|
@@ -42200,11 +42434,11 @@ function isSkillCandidate(dir) {
|
|
|
42200
42434
|
return existsSync9(join24(dir, "SKILL.md")) || existsSync9(join24(dir, "skill.json")) || existsSync9(join24(dir, "package.json"));
|
|
42201
42435
|
}
|
|
42202
42436
|
function physicalImportPath(path) {
|
|
42203
|
-
let ancestor =
|
|
42437
|
+
let ancestor = resolve15(path);
|
|
42204
42438
|
const suffix = [];
|
|
42205
42439
|
while (!existsSync9(ancestor)) {
|
|
42206
|
-
suffix.unshift(
|
|
42207
|
-
ancestor =
|
|
42440
|
+
suffix.unshift(basename8(ancestor));
|
|
42441
|
+
ancestor = dirname15(ancestor);
|
|
42208
42442
|
}
|
|
42209
42443
|
return join24(realpathSync6(ancestor), ...suffix);
|
|
42210
42444
|
}
|
|
@@ -42213,7 +42447,7 @@ function assertDisjointImportPaths(source, destination) {
|
|
|
42213
42447
|
const destinationPath = physicalImportPath(destination);
|
|
42214
42448
|
const contains = (parent, child) => {
|
|
42215
42449
|
const path = relative5(parent, child);
|
|
42216
|
-
return path === "" || !
|
|
42450
|
+
return path === "" || !isAbsolute16(path) && path !== ".." && !path.startsWith(`..${sep6}`);
|
|
42217
42451
|
};
|
|
42218
42452
|
if (contains(sourcePath, destinationPath) || contains(destinationPath, sourcePath)) {
|
|
42219
42453
|
throw new Error("Source and destination skill directories must not overlap");
|
|
@@ -42228,8 +42462,8 @@ function portPortableSkill(sourcePath, options = {}) {
|
|
|
42228
42462
|
const explicitName = options.name != null;
|
|
42229
42463
|
const skillName = normalizeNewPortableSkillName(options.name ?? inferred.name);
|
|
42230
42464
|
if (isOfficialSkillName(skillName) && !options.allowShadow) {
|
|
42231
|
-
const sourceSlug = safeNormalizeName(
|
|
42232
|
-
const via = explicitName ? `Name '${skillName}' matches a bundled official skill.` : `Inferred name '${skillName}'${sourceSlug && sourceSlug !== skillName ? ` (from source folder '${
|
|
42465
|
+
const sourceSlug = safeNormalizeName(basename8(absoluteSource));
|
|
42466
|
+
const via = explicitName ? `Name '${skillName}' matches a bundled official skill.` : `Inferred name '${skillName}'${sourceSlug && sourceSlug !== skillName ? ` (from source folder '${basename8(absoluteSource)}')` : ""} matches a bundled official skill.`;
|
|
42233
42467
|
throw new Error(`${via} Importing it would shadow the official '${skillName}'. ` + `Pass --name to choose a different name, or --allow-shadow to override deliberately.`);
|
|
42234
42468
|
}
|
|
42235
42469
|
assertDisjointImportPaths(absoluteSource, join24(resolvePortableSkillsRoot(options, false), skillName));
|
|
@@ -42241,7 +42475,7 @@ function portPortableSkill(sourcePath, options = {}) {
|
|
|
42241
42475
|
throw new Error(`Skill '${skillName}' already exists at ${destination}`);
|
|
42242
42476
|
rmSync2(destination, { recursive: true, force: true });
|
|
42243
42477
|
}
|
|
42244
|
-
mkdirSync7(
|
|
42478
|
+
mkdirSync7(dirname15(destination), { recursive: true });
|
|
42245
42479
|
copySkillDirectory(absoluteSource, destination);
|
|
42246
42480
|
const base = {
|
|
42247
42481
|
...inferred,
|
|
@@ -42485,7 +42719,7 @@ function safeIsDirectory(path) {
|
|
|
42485
42719
|
}
|
|
42486
42720
|
}
|
|
42487
42721
|
function isSafeRelativePath2(value) {
|
|
42488
|
-
if (!value.trim() ||
|
|
42722
|
+
if (!value.trim() || isAbsolute16(value))
|
|
42489
42723
|
return false;
|
|
42490
42724
|
const normalized = normalize2(value).replace(/\\/g, "/");
|
|
42491
42725
|
return normalized !== ".." && !normalized.startsWith("../") && !normalized.includes("/../");
|
|
@@ -42512,7 +42746,7 @@ function isSkillsOwnershipMarker(marker) {
|
|
|
42512
42746
|
function hasSkillsOwnershipMarker(dir) {
|
|
42513
42747
|
const path = join25(dir, SYNC_MARKER_FILE);
|
|
42514
42748
|
try {
|
|
42515
|
-
if (!
|
|
42749
|
+
if (!lstatSync19(path).isFile())
|
|
42516
42750
|
return false;
|
|
42517
42751
|
const marker = JSON.parse(readFileSync16(path, "utf8"));
|
|
42518
42752
|
return isSkillsOwnershipMarker(marker);
|
|
@@ -42738,9 +42972,9 @@ function writeManagedSkillDir(dir, skillMd, options) {
|
|
|
42738
42972
|
const action = dirExists ? "update" : "create";
|
|
42739
42973
|
if (options.dryRun)
|
|
42740
42974
|
return { action, path: skillMdPath };
|
|
42741
|
-
const parentDir =
|
|
42975
|
+
const parentDir = dirname16(dir);
|
|
42742
42976
|
mkdirSync8(parentDir, { recursive: true });
|
|
42743
|
-
const transactionDir = mkdtempSync2(join25(parentDir, `.hasna-skills-write-${
|
|
42977
|
+
const transactionDir = mkdtempSync2(join25(parentDir, `.hasna-skills-write-${basename9(dir)}-`));
|
|
42744
42978
|
const candidateDir = join25(transactionDir, "candidate");
|
|
42745
42979
|
const backupDir = join25(transactionDir, "backup");
|
|
42746
42980
|
const candidateSkillMdPath = join25(candidateDir, "SKILL.md");
|
|
@@ -44104,11 +44338,11 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
44104
44338
|
throw new SkillSelectionError("INVALID_BUNDLE_PATH", "The execution bundle path exceeds its limit.");
|
|
44105
44339
|
});
|
|
44106
44340
|
const destination = join30(runDirectory, entry.path);
|
|
44107
|
-
mkdirSync10(
|
|
44341
|
+
mkdirSync10(dirname17(destination), { recursive: true, mode: 448 });
|
|
44108
44342
|
writeFileSync8(destination, entry.bytes, { flag: "wx", mode: entry.mode & 511 });
|
|
44109
44343
|
}
|
|
44110
44344
|
env.SKILLS_INPUT_JSON = input;
|
|
44111
|
-
env.SKILLS_WORKSPACE_DIR =
|
|
44345
|
+
env.SKILLS_WORKSPACE_DIR = resolve16(options.cwd ?? process.cwd());
|
|
44112
44346
|
env.SKILLS_RUN_DIR = runDirectory;
|
|
44113
44347
|
if (runtime.version) {
|
|
44114
44348
|
const version = await subprocess([executable, ...runtimeName === "bun" ? ["--no-env-file"] : [], "--version"], runDirectory, env, "", Math.min(timeoutMs, 5000));
|
|
@@ -44138,7 +44372,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
44138
44372
|
selection: selection2,
|
|
44139
44373
|
target: "local",
|
|
44140
44374
|
runtime: runtimeName,
|
|
44141
|
-
inputDigest: `sha256:${
|
|
44375
|
+
inputDigest: `sha256:${createHash16("sha256").update(input).digest("hex")}`,
|
|
44142
44376
|
runDirectory,
|
|
44143
44377
|
...executionGrant ? { executionGrant } : {},
|
|
44144
44378
|
...bindings ? { secretBinding: { schema: bindings.schema, selection: bindings.selection, consumer: bindings.consumer, secretsAuthority: bindings.secretsAuthority, bindings: bindings.bindings } } : {},
|
|
@@ -44664,7 +44898,7 @@ var { booleanSelector, SelectorType: SelectorType2 } = require_config();
|
|
|
44664
44898
|
var { setFeature: setFeature2 } = require_client2();
|
|
44665
44899
|
var { httpSigningMiddlewareOptions } = require_dist_cjs2();
|
|
44666
44900
|
var { Readable } = __require("stream");
|
|
44667
|
-
var { validate, parse:
|
|
44901
|
+
var { validate, parse: parse7 } = require_util();
|
|
44668
44902
|
var { AwsRestXmlProtocol } = require_protocols2();
|
|
44669
44903
|
var { NormalizedSchema } = require_schema4();
|
|
44670
44904
|
var CONTENT_LENGTH_HEADER = "content-length";
|
|
@@ -53428,7 +53662,7 @@ var import_node_http_handler2 = __toESM(require_dist_cjs6(), 1);
|
|
|
53428
53662
|
|
|
53429
53663
|
// node_modules/@aws-sdk/checksums/dist-cjs/submodules/sha/index.js
|
|
53430
53664
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde();
|
|
53431
|
-
var { createHmac: createHmac2, createHash:
|
|
53665
|
+
var { createHmac: createHmac2, createHash: createHash18 } = __require("crypto");
|
|
53432
53666
|
var { Sha256: Sha2562, Sha256Js, Sha256Node } = require_checksum();
|
|
53433
53667
|
var BLOCK2 = 64;
|
|
53434
53668
|
var DIGEST_LENGTH = 20;
|
|
@@ -53597,7 +53831,7 @@ class Sha1Js {
|
|
|
53597
53831
|
}
|
|
53598
53832
|
var hasNativeCrypto = (() => {
|
|
53599
53833
|
try {
|
|
53600
|
-
|
|
53834
|
+
createHash18("sha1");
|
|
53601
53835
|
return true;
|
|
53602
53836
|
} catch {
|
|
53603
53837
|
return false;
|
|
@@ -53637,7 +53871,7 @@ function buildNativeClass() {
|
|
|
53637
53871
|
this.finished = false;
|
|
53638
53872
|
}
|
|
53639
53873
|
createHash() {
|
|
53640
|
-
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) :
|
|
53874
|
+
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) : createHash18("sha1");
|
|
53641
53875
|
}
|
|
53642
53876
|
};
|
|
53643
53877
|
}
|
|
@@ -54206,10 +54440,10 @@ function assertReservationCents(value, field2) {
|
|
|
54206
54440
|
import { Database as Database2 } from "bun:sqlite";
|
|
54207
54441
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
54208
54442
|
import { mkdirSync as mkdirSync12 } from "fs";
|
|
54209
|
-
import { dirname as
|
|
54443
|
+
import { dirname as dirname21 } from "path";
|
|
54210
54444
|
|
|
54211
54445
|
// src/server/database-url.ts
|
|
54212
|
-
import { isAbsolute as
|
|
54446
|
+
import { isAbsolute as isAbsolute17, join as join32 } from "path";
|
|
54213
54447
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
54214
54448
|
var DEFAULT_SQLITE_FILENAME2 = "server.db";
|
|
54215
54449
|
var SQLITE_MEMORY_PATH = ":memory:";
|
|
@@ -54245,7 +54479,7 @@ function resolveDatabaseTarget(raw) {
|
|
|
54245
54479
|
throw new Error(`unsupported database scheme "${scheme}:". Supported: postgres://, postgresql://, sqlite:, file:, ` + `an absolute or relative path to a .db/.sqlite file, ":memory:", or "memory:" (non-durable, tests only). ` + `Leave the setting empty to use the default SQLite database at ${defaultSqlitePath()}.`);
|
|
54246
54480
|
}
|
|
54247
54481
|
if (looksLikeSqlitePath(value)) {
|
|
54248
|
-
const path =
|
|
54482
|
+
const path = isAbsolute17(value) ? value : join32(process.cwd(), value);
|
|
54249
54483
|
return { kind: "sqlite", path, durable: true, label: `sqlite (${path})` };
|
|
54250
54484
|
}
|
|
54251
54485
|
throw new Error(`could not resolve a database backend from "${value}". Use postgres://\u2026, sqlite:\u2026, an absolute or ` + `relative path ending in ${SQLITE_EXTENSIONS.join("/")}, ":memory:", or leave it empty for the ` + `default SQLite database at ${defaultSqlitePath()}.`);
|
|
@@ -54269,7 +54503,7 @@ function sqlitePathFromUrl(value, scheme) {
|
|
|
54269
54503
|
}
|
|
54270
54504
|
return rest.slice(2).replace(/^\/\/+/, "/");
|
|
54271
54505
|
}
|
|
54272
|
-
return
|
|
54506
|
+
return isAbsolute17(rest) ? rest : join32(process.cwd(), rest);
|
|
54273
54507
|
}
|
|
54274
54508
|
function looksLikeSqlitePath(value) {
|
|
54275
54509
|
if (value.includes("/"))
|
|
@@ -54477,12 +54711,12 @@ class PostgresSkillSelectionStore {
|
|
|
54477
54711
|
// src/server/sqlite-store.ts
|
|
54478
54712
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
54479
54713
|
import { mkdirSync as mkdirSync11, readFileSync as readFileSync22, readdirSync as readdirSync12 } from "fs";
|
|
54480
|
-
import { dirname as
|
|
54714
|
+
import { dirname as dirname20, join as join34 } from "path";
|
|
54481
54715
|
|
|
54482
54716
|
// src/server/auth.ts
|
|
54483
|
-
import { createHash as
|
|
54717
|
+
import { createHash as createHash19 } from "crypto";
|
|
54484
54718
|
function hashApiKey(token) {
|
|
54485
|
-
return
|
|
54719
|
+
return createHash19("sha256").update(token).digest("hex");
|
|
54486
54720
|
}
|
|
54487
54721
|
function bearerToken(request2) {
|
|
54488
54722
|
const header = request2.headers.get("authorization") || "";
|
|
@@ -54536,7 +54770,7 @@ function permitsSkillsRoute(principal, method, resource) {
|
|
|
54536
54770
|
|
|
54537
54771
|
// src/server/migrations-dir.ts
|
|
54538
54772
|
import { existsSync as existsSync15 } from "fs";
|
|
54539
|
-
import { dirname as
|
|
54773
|
+
import { dirname as dirname19, join as join33 } from "path";
|
|
54540
54774
|
var MIGRATION_DIALECTS = ["postgres", "sqlite"];
|
|
54541
54775
|
var MAX_WALK_UP = 6;
|
|
54542
54776
|
function findMigrationsRoot(startDirs = defaultStartDirs()) {
|
|
@@ -54546,7 +54780,7 @@ function findMigrationsRoot(startDirs = defaultStartDirs()) {
|
|
|
54546
54780
|
const candidate2 = join33(dir, "migrations");
|
|
54547
54781
|
if (MIGRATION_DIALECTS.some((dialect) => existsSync15(join33(candidate2, dialect))))
|
|
54548
54782
|
return candidate2;
|
|
54549
|
-
const parent =
|
|
54783
|
+
const parent = dirname19(dir);
|
|
54550
54784
|
if (parent === dir)
|
|
54551
54785
|
break;
|
|
54552
54786
|
dir = parent;
|
|
@@ -54773,10 +55007,10 @@ class SkillVersionExistsError extends Error {
|
|
|
54773
55007
|
}
|
|
54774
55008
|
|
|
54775
55009
|
// src/lib/revision.ts
|
|
54776
|
-
import { createHash as
|
|
55010
|
+
import { createHash as createHash20 } from "crypto";
|
|
54777
55011
|
var REVISION_ID_PATTERN = /^[0-9a-f]{64}$/;
|
|
54778
55012
|
function revisionIdOf(content) {
|
|
54779
|
-
const
|
|
55013
|
+
const canonical4 = JSON.stringify({
|
|
54780
55014
|
slug: content.slug,
|
|
54781
55015
|
displayName: content.displayName,
|
|
54782
55016
|
description: content.description,
|
|
@@ -54789,7 +55023,7 @@ function revisionIdOf(content) {
|
|
|
54789
55023
|
bundleSha256: content.bundleSha256 ?? null,
|
|
54790
55024
|
bundleByteSize: content.bundleByteSize ?? null
|
|
54791
55025
|
});
|
|
54792
|
-
return
|
|
55026
|
+
return createHash20("sha256").update(canonical4).digest("hex");
|
|
54793
55027
|
}
|
|
54794
55028
|
function revisionIdOfRecord(record3) {
|
|
54795
55029
|
return revisionIdOf(record3);
|
|
@@ -54814,7 +55048,7 @@ class SqliteSkillsStore {
|
|
|
54814
55048
|
constructor(path = SQLITE_MEMORY_PATH, options = {}) {
|
|
54815
55049
|
const inMemory = path === SQLITE_MEMORY_PATH;
|
|
54816
55050
|
if (!inMemory)
|
|
54817
|
-
mkdirSync11(
|
|
55051
|
+
mkdirSync11(dirname20(path), { recursive: true });
|
|
54818
55052
|
this.db = openDatabase(path);
|
|
54819
55053
|
this.db.exec(`PRAGMA busy_timeout = ${Math.max(0, options.busyTimeoutMs ?? 5000)}`);
|
|
54820
55054
|
if (!inMemory)
|
|
@@ -55521,7 +55755,7 @@ class SqliteGovernanceStore {
|
|
|
55521
55755
|
closed = false;
|
|
55522
55756
|
constructor(path = SQLITE_MEMORY_PATH, options = {}) {
|
|
55523
55757
|
if (path !== SQLITE_MEMORY_PATH)
|
|
55524
|
-
mkdirSync12(
|
|
55758
|
+
mkdirSync12(dirname21(path), { recursive: true });
|
|
55525
55759
|
this.db = new Database2(path, { create: true, readwrite: true });
|
|
55526
55760
|
this.db.exec("PRAGMA busy_timeout = 5000");
|
|
55527
55761
|
this.db.exec("PRAGMA foreign_keys = ON");
|
|
@@ -55754,7 +55988,7 @@ function nextMonthPrefix(monthPrefix) {
|
|
|
55754
55988
|
}
|
|
55755
55989
|
|
|
55756
55990
|
// src/server/skills-api.ts
|
|
55757
|
-
import { createHash as
|
|
55991
|
+
import { createHash as createHash21 } from "crypto";
|
|
55758
55992
|
var SLUG_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
55759
55993
|
var SHA256_HEX2 = /^[0-9a-f]{64}$/;
|
|
55760
55994
|
var MAX_SLUG_LENGTH = 128;
|
|
@@ -55931,7 +56165,7 @@ async function parsePublishRequest(request2, config) {
|
|
|
55931
56165
|
if (bundleBytes.byteLength === 0) {
|
|
55932
56166
|
throw new SkillRequestError(400, "BUNDLE_EMPTY", "the uploaded bundle is empty");
|
|
55933
56167
|
}
|
|
55934
|
-
const sha2562 =
|
|
56168
|
+
const sha2562 = createHash21("sha256").update(bundleBytes).digest("hex");
|
|
55935
56169
|
const claimed = optionalString(manifest.bundleSha256);
|
|
55936
56170
|
if (claimed)
|
|
55937
56171
|
assertSha2562(claimed);
|
|
@@ -56046,7 +56280,7 @@ async function readPublishedBundle(store, artifactStorage, principal, slug) {
|
|
|
56046
56280
|
if (!bytes) {
|
|
56047
56281
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
56048
56282
|
}
|
|
56049
|
-
const actual =
|
|
56283
|
+
const actual = createHash21("sha256").update(bytes).digest("hex");
|
|
56050
56284
|
if (actual !== record3.bundleSha256) {
|
|
56051
56285
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}' hashes to ${actual} but was published as ${record3.bundleSha256}`);
|
|
56052
56286
|
}
|
|
@@ -56194,7 +56428,7 @@ async function readSkillVersionBundle(store, artifactStorage, principal, slug, v
|
|
|
56194
56428
|
const bytes = await artifactStorage.readBundle(bundle2);
|
|
56195
56429
|
if (!bytes)
|
|
56196
56430
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
56197
|
-
const actual =
|
|
56431
|
+
const actual = createHash21("sha256").update(bytes).digest("hex");
|
|
56198
56432
|
if (actual !== found.bundleSha256) {
|
|
56199
56433
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}@${version2}' hashes to ${actual} but was published as ${found.bundleSha256}`);
|
|
56200
56434
|
}
|
|
@@ -56594,7 +56828,7 @@ async function handleProfileApi(store, principal, request2, parts, config) {
|
|
|
56594
56828
|
// src/server/runtime-store.ts
|
|
56595
56829
|
import { Database as Database3 } from "bun:sqlite";
|
|
56596
56830
|
import { mkdirSync as mkdirSync13 } from "fs";
|
|
56597
|
-
import { dirname as
|
|
56831
|
+
import { dirname as dirname22 } from "path";
|
|
56598
56832
|
|
|
56599
56833
|
// src/sdk/execution/types.ts
|
|
56600
56834
|
var EXECUTION_PROTOCOL_VERSION = REMOTE_SKILL_RUN_CONTRACT_VERSION;
|
|
@@ -56650,7 +56884,7 @@ class RuntimeExecutionStore {
|
|
|
56650
56884
|
}
|
|
56651
56885
|
const path = target.kind === "sqlite" ? target.path : ":memory:";
|
|
56652
56886
|
if (path !== ":memory:")
|
|
56653
|
-
mkdirSync13(
|
|
56887
|
+
mkdirSync13(dirname22(path), { recursive: true });
|
|
56654
56888
|
const db = new Database3(path);
|
|
56655
56889
|
db.run("PRAGMA busy_timeout=5000");
|
|
56656
56890
|
db.run("PRAGMA journal_mode=WAL");
|
|
@@ -56890,7 +57124,7 @@ class RuntimeExecutionStore {
|
|
|
56890
57124
|
}
|
|
56891
57125
|
|
|
56892
57126
|
// src/sdk/execution/admission.ts
|
|
56893
|
-
import { createHash as
|
|
57127
|
+
import { createHash as createHash23 } from "crypto";
|
|
56894
57128
|
|
|
56895
57129
|
// src/sdk/execution/image-profile.ts
|
|
56896
57130
|
class ImageProfileResolutionError extends Error {
|
|
@@ -57488,11 +57722,11 @@ function ownedAdmission(admission) {
|
|
|
57488
57722
|
};
|
|
57489
57723
|
}
|
|
57490
57724
|
function digestInput(input) {
|
|
57491
|
-
return
|
|
57725
|
+
return createHash23("sha256").update(canonicalJson2(input)).digest("hex");
|
|
57492
57726
|
}
|
|
57493
57727
|
|
|
57494
57728
|
// src/sdk/execution/dispatchers/ecs.ts
|
|
57495
|
-
import { createHash as
|
|
57729
|
+
import { createHash as createHash24 } from "crypto";
|
|
57496
57730
|
|
|
57497
57731
|
// src/sdk/execution/state-machine.ts
|
|
57498
57732
|
var LEGAL_TRANSITIONS = {
|
|
@@ -60891,13 +61125,13 @@ function observedTask(states, taskArn) {
|
|
|
60891
61125
|
return state2.lastStatus === "STOPPED" || LIVE_TASK_STATUSES.has(state2.lastStatus) ? state2 : undefined;
|
|
60892
61126
|
}
|
|
60893
61127
|
function clientTokenFor(runId2, attemptId) {
|
|
60894
|
-
return
|
|
61128
|
+
return createHash24("sha256").update(`${runId2}\x00${attemptId}`).digest("hex").slice(0, CLIENT_TOKEN_BYTES * 2);
|
|
60895
61129
|
}
|
|
60896
61130
|
function startedByFor(runId2, attemptNumber) {
|
|
60897
61131
|
return `skills-exec/${runId2}/a${attemptNumber}`;
|
|
60898
61132
|
}
|
|
60899
61133
|
function requestDigestFor(admission, attemptId) {
|
|
60900
|
-
return
|
|
61134
|
+
return createHash24("sha256").update(canonicalJson2({ admission, attemptId })).digest("hex");
|
|
60901
61135
|
}
|
|
60902
61136
|
|
|
60903
61137
|
class EcsDispatcher {
|
|
@@ -61193,7 +61427,7 @@ function validText(value) {
|
|
|
61193
61427
|
}
|
|
61194
61428
|
|
|
61195
61429
|
// src/server/runtime-policy.ts
|
|
61196
|
-
import { createHash as
|
|
61430
|
+
import { createHash as createHash25, createHmac as createHmac3, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
61197
61431
|
var RUNTIME_MAX_INPUT_BYTES = 1e5;
|
|
61198
61432
|
var RUNTIME_MAX_BUNDLE_BYTES = 1e6;
|
|
61199
61433
|
var RUNTIME_MAX_ARTIFACT_BYTES = 2000000;
|
|
@@ -61265,7 +61499,7 @@ function verifyRuntimeToken(token, key, admission, attempt, now = Date.now()) {
|
|
|
61265
61499
|
const actual = Buffer.from(token);
|
|
61266
61500
|
return actual.length === expected.length && timingSafeEqual2(actual, expected);
|
|
61267
61501
|
}
|
|
61268
|
-
var hashBytes = (bytes) =>
|
|
61502
|
+
var hashBytes = (bytes) => createHash25("sha256").update(bytes).digest("hex");
|
|
61269
61503
|
|
|
61270
61504
|
// src/server/runtime-api.ts
|
|
61271
61505
|
async function createRuntimeService(options) {
|
|
@@ -67247,7 +67481,7 @@ var localRunExecutor = {
|
|
|
67247
67481
|
// src/sdk/storage.ts
|
|
67248
67482
|
var artifactStorageSeam = ArtifactStorage;
|
|
67249
67483
|
// src/sdk/outputs.ts
|
|
67250
|
-
import { createHash as
|
|
67484
|
+
import { createHash as createHash26 } from "crypto";
|
|
67251
67485
|
class DatabaseOnlyObjectStore {
|
|
67252
67486
|
usesS3 = false;
|
|
67253
67487
|
async materialize(run, artifact, body4) {
|
|
@@ -67294,7 +67528,7 @@ function createGovernedArtifactWriter(options) {
|
|
|
67294
67528
|
const stamped = {
|
|
67295
67529
|
...meta,
|
|
67296
67530
|
byteSize: outputBytes,
|
|
67297
|
-
sha256:
|
|
67531
|
+
sha256: createHash26("sha256").update(persistedBytes).digest("hex"),
|
|
67298
67532
|
visibility: options.visibility ?? config.defaultVisibility,
|
|
67299
67533
|
...config.artifactTtlSeconds !== undefined ? { expiresAt: expiresAtFor(createdAt, config.artifactTtlSeconds) } : {}
|
|
67300
67534
|
};
|
|
@@ -67535,7 +67769,7 @@ __export(exports_external2, {
|
|
|
67535
67769
|
pipe: () => pipe,
|
|
67536
67770
|
partialRecord: () => partialRecord,
|
|
67537
67771
|
parseAsync: () => parseAsync2,
|
|
67538
|
-
parse: () =>
|
|
67772
|
+
parse: () => parse10,
|
|
67539
67773
|
overwrite: () => _overwrite,
|
|
67540
67774
|
output: () => output,
|
|
67541
67775
|
optional: () => optional,
|
|
@@ -67755,7 +67989,7 @@ __export(exports_core2, {
|
|
|
67755
67989
|
prettifyError: () => prettifyError,
|
|
67756
67990
|
parseURLObject: () => parseURLObject,
|
|
67757
67991
|
parseAsync: () => parseAsync,
|
|
67758
|
-
parse: () =>
|
|
67992
|
+
parse: () => parse8,
|
|
67759
67993
|
meta: () => meta,
|
|
67760
67994
|
mergeValues: () => mergeValues2,
|
|
67761
67995
|
memoizer: () => memoizer,
|
|
@@ -69209,7 +69443,7 @@ var _parse = (_Err) => {
|
|
|
69209
69443
|
};
|
|
69210
69444
|
return fn;
|
|
69211
69445
|
};
|
|
69212
|
-
var
|
|
69446
|
+
var parse8 = /* @__PURE__ */ _parse($ZodRealError);
|
|
69213
69447
|
var _parseAsync = (_Err) => {
|
|
69214
69448
|
const fn = async (schema, value, _ctx, params) => {
|
|
69215
69449
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
@@ -69280,18 +69514,18 @@ var validateAsync = async (schema, value, _ctx) => {
|
|
|
69280
69514
|
return result.issues.length === 0;
|
|
69281
69515
|
};
|
|
69282
69516
|
var _encode = (_Err) => {
|
|
69283
|
-
const
|
|
69517
|
+
const parse9 = _parse(_Err);
|
|
69284
69518
|
const fn = (schema, value, _ctx, _params) => {
|
|
69285
69519
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
69286
|
-
return
|
|
69520
|
+
return parse9(schema, value, ctx, finalizeParams(fn, _params));
|
|
69287
69521
|
};
|
|
69288
69522
|
return fn;
|
|
69289
69523
|
};
|
|
69290
69524
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
69291
69525
|
var _decode = (_Err) => {
|
|
69292
|
-
const
|
|
69526
|
+
const parse9 = _parse(_Err);
|
|
69293
69527
|
const fn = (schema, value, _ctx, _params) => {
|
|
69294
|
-
return
|
|
69528
|
+
return parse9(schema, value, _ctx, finalizeParams(fn, _params));
|
|
69295
69529
|
};
|
|
69296
69530
|
return fn;
|
|
69297
69531
|
};
|
|
@@ -72214,10 +72448,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
72214
72448
|
throw new Error("implement() must be called with a function");
|
|
72215
72449
|
}
|
|
72216
72450
|
return Object.defineProperty(function(...args) {
|
|
72217
|
-
const parsedArgs = inst._def.input ?
|
|
72451
|
+
const parsedArgs = inst._def.input ? parse8(inst._def.input, args) : args;
|
|
72218
72452
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
72219
72453
|
if (inst._def.output) {
|
|
72220
|
-
return
|
|
72454
|
+
return parse8(inst._def.output, result);
|
|
72221
72455
|
}
|
|
72222
72456
|
return result;
|
|
72223
72457
|
}, "_zod", { value: inst._zod, enumerable: false });
|
|
@@ -83855,7 +84089,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, undefi
|
|
|
83855
84089
|
});
|
|
83856
84090
|
|
|
83857
84091
|
// node_modules/zod/v4/classic/parse.js
|
|
83858
|
-
var
|
|
84092
|
+
var parse10 = /* @__PURE__ */ _parse(ZodRealError);
|
|
83859
84093
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
83860
84094
|
var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
83861
84095
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -83991,7 +84225,7 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
83991
84225
|
exports_util.own(this, "~standard", value);
|
|
83992
84226
|
},
|
|
83993
84227
|
parse: function _parse2(data, params) {
|
|
83994
|
-
return
|
|
84228
|
+
return parse10(this, data, params, { callee: _parse2 });
|
|
83995
84229
|
},
|
|
83996
84230
|
parseAsync: async function _parseAsync2(data, params) {
|
|
83997
84231
|
return await parseAsync2(this, data, params, { callee: _parseAsync2 });
|
|
@@ -86061,7 +86295,7 @@ function date4(params) {
|
|
|
86061
86295
|
return _coercedDate(ZodDate2, params);
|
|
86062
86296
|
}
|
|
86063
86297
|
// src/lib/canonical-json.ts
|
|
86064
|
-
import { createHash as
|
|
86298
|
+
import { createHash as createHash27 } from "crypto";
|
|
86065
86299
|
function canonicalJson3(value, maximumBytes = 2 * 1024 * 1024) {
|
|
86066
86300
|
return canonicalJsonAtDepth(value, maximumBytes, 64);
|
|
86067
86301
|
}
|
|
@@ -86105,7 +86339,7 @@ function canonicalJsonAtDepth(value, maximumBytes, maximumDepth) {
|
|
|
86105
86339
|
return visit3(value, 0);
|
|
86106
86340
|
}
|
|
86107
86341
|
function canonicalJsonSha256(value, maximumBytes) {
|
|
86108
|
-
return
|
|
86342
|
+
return createHash27("sha256").update(canonicalJson3(value, maximumBytes)).digest("hex");
|
|
86109
86343
|
}
|
|
86110
86344
|
|
|
86111
86345
|
// src/lib/remote-recurring-contract.ts
|
|
@@ -87022,10 +87256,10 @@ async function readQuoteUnavailableCode(response) {
|
|
|
87022
87256
|
let timer;
|
|
87023
87257
|
let deadlineExceeded = false;
|
|
87024
87258
|
const expired = Symbol("quote body deadline");
|
|
87025
|
-
const deadline = new Promise((
|
|
87259
|
+
const deadline = new Promise((resolve18) => {
|
|
87026
87260
|
timer = setTimeout(() => {
|
|
87027
87261
|
deadlineExceeded = true;
|
|
87028
|
-
|
|
87262
|
+
resolve18(expired);
|
|
87029
87263
|
reader.cancel().catch(() => {});
|
|
87030
87264
|
}, 1500);
|
|
87031
87265
|
});
|
|
@@ -88144,7 +88378,7 @@ async function requestInvitationEmail(origin, action, input2) {
|
|
|
88144
88378
|
}
|
|
88145
88379
|
|
|
88146
88380
|
// src/lib/remote-private-publications.ts
|
|
88147
|
-
import { createHash as
|
|
88381
|
+
import { createHash as createHash28 } from "crypto";
|
|
88148
88382
|
var PRIVATE_PUBLICATION_MAX_BYTES = 16 * 1024 * 1024;
|
|
88149
88383
|
var failures2 = {
|
|
88150
88384
|
INVALID_REQUEST: [400, "The publication request is invalid."],
|
|
@@ -88191,7 +88425,7 @@ var hash3 = (v2) => typeof v2 === "string" && /^[a-f0-9]{64}$/.test(v2);
|
|
|
88191
88425
|
var record9 = (v2) => !!v2 && typeof v2 === "object" && !Array.isArray(v2);
|
|
88192
88426
|
var exact = (v2, keys2) => record9(v2) && Object.keys(v2).sort().join(",") === keys2.sort().join(",");
|
|
88193
88427
|
var date5 = (v2) => typeof v2 === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v2) && Number.isFinite(Date.parse(v2));
|
|
88194
|
-
var publicationSha256 = (bytes) =>
|
|
88428
|
+
var publicationSha256 = (bytes) => createHash28("sha256").update(bytes).digest("hex");
|
|
88195
88429
|
function checkedPublicationDeclaration(value) {
|
|
88196
88430
|
if (!exact(value, ["idempotencyKey", "version", "expectedCurrentVersionId", "manifestText", "archiveSha256", "archiveByteSize"]) || !publicationUuid(value.idempotencyKey) || !(value.expectedCurrentVersionId === null || publicationUuid(value.expectedCurrentVersionId)) || typeof value.version !== "string" || !value.version || value.version.length > 128 || /[\p{Cc}\p{Cs}]/u.test(value.version) || typeof value.manifestText !== "string" || Buffer.byteLength(value.manifestText) > 16384 || !hash3(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES)
|
|
88197
88431
|
return bad();
|
|
@@ -88436,12 +88670,12 @@ class RemotePrivatePublicationsClient {
|
|
|
88436
88670
|
previous = view;
|
|
88437
88671
|
if (!["queued", "verifying"].includes(view.state) || Date.now() >= until)
|
|
88438
88672
|
return view;
|
|
88439
|
-
await new Promise((
|
|
88673
|
+
await new Promise((resolve18) => {
|
|
88440
88674
|
const timer = setTimeout(done, Math.min(1000, until - Date.now()));
|
|
88441
88675
|
function done() {
|
|
88442
88676
|
clearTimeout(timer);
|
|
88443
88677
|
options.signal?.removeEventListener("abort", done);
|
|
88444
|
-
|
|
88678
|
+
resolve18();
|
|
88445
88679
|
}
|
|
88446
88680
|
options.signal?.addEventListener("abort", done, { once: true });
|
|
88447
88681
|
});
|
|
@@ -88673,23 +88907,23 @@ class RemoteSkillsAuthClient {
|
|
|
88673
88907
|
}
|
|
88674
88908
|
}
|
|
88675
88909
|
// src/lib/private-publication-recovery.ts
|
|
88676
|
-
import { constants as
|
|
88677
|
-
import { dirname as
|
|
88910
|
+
import { constants as constants12, closeSync as closeSync16, fsyncSync as fsyncSync4, fstatSync as fstatSync16, lstatSync as lstatSync20, mkdirSync as mkdirSync14, openSync as openSync16, readSync as readSync11, realpathSync as realpathSync8, renameSync as renameSync6, unlinkSync as unlinkSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
88911
|
+
import { dirname as dirname23, isAbsolute as isAbsolute18, join as join36, resolve as resolve18 } from "path";
|
|
88678
88912
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
88679
88913
|
var fail = () => {
|
|
88680
88914
|
throw new PrivatePublicationError("PUBLICATION_RECOVERY_INVALID", "The recovery directory is invalid or changed. Preserve it and inspect the existing intent; do not start a replacement automatically.");
|
|
88681
88915
|
};
|
|
88682
88916
|
function safeDirectory(directory) {
|
|
88683
|
-
if (!
|
|
88917
|
+
if (!isAbsolute18(directory) || directory !== resolve18(directory) || realpathSync8(directory) !== directory)
|
|
88684
88918
|
return fail();
|
|
88685
|
-
for (let path2 = directory;; path2 =
|
|
88686
|
-
const stat2 =
|
|
88919
|
+
for (let path2 = directory;; path2 = dirname23(path2)) {
|
|
88920
|
+
const stat2 = lstatSync20(path2);
|
|
88687
88921
|
if (!stat2.isDirectory() || stat2.isSymbolicLink())
|
|
88688
88922
|
return fail();
|
|
88689
|
-
if (path2 ===
|
|
88923
|
+
if (path2 === dirname23(path2))
|
|
88690
88924
|
break;
|
|
88691
88925
|
}
|
|
88692
|
-
const own2 =
|
|
88926
|
+
const own2 = lstatSync20(directory);
|
|
88693
88927
|
if ((own2.mode & 63) !== 0 || process.getuid && own2.uid !== process.getuid())
|
|
88694
88928
|
return fail();
|
|
88695
88929
|
return { dev: own2.dev, ino: own2.ino };
|
|
@@ -88701,35 +88935,35 @@ function unchangedDirectory(directory, identity3) {
|
|
|
88701
88935
|
}
|
|
88702
88936
|
function readOwned(directory, name, max) {
|
|
88703
88937
|
const identity3 = safeDirectory(directory), file2 = join36(directory, name);
|
|
88704
|
-
const fd =
|
|
88938
|
+
const fd = openSync16(file2, constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
88705
88939
|
try {
|
|
88706
|
-
const stat2 =
|
|
88940
|
+
const stat2 = fstatSync16(fd);
|
|
88707
88941
|
if (!stat2.isFile() || stat2.nlink !== 1 || stat2.size > max || stat2.size < 1 || (stat2.mode & 63) !== 0 || process.getuid && stat2.uid !== process.getuid())
|
|
88708
88942
|
return fail();
|
|
88709
88943
|
const buffer = Buffer.alloc(Math.min(max, stat2.size) + 1);
|
|
88710
88944
|
let length = 0;
|
|
88711
88945
|
while (length < buffer.length) {
|
|
88712
|
-
const count =
|
|
88946
|
+
const count = readSync11(fd, buffer, length, buffer.length - length, length);
|
|
88713
88947
|
if (count === 0)
|
|
88714
88948
|
break;
|
|
88715
88949
|
length += count;
|
|
88716
88950
|
}
|
|
88717
|
-
const bytes = buffer.subarray(0, length), after =
|
|
88951
|
+
const bytes = buffer.subarray(0, length), after = fstatSync16(fd);
|
|
88718
88952
|
unchangedDirectory(directory, identity3);
|
|
88719
88953
|
if (bytes.length !== stat2.size || stat2.size !== after.size || stat2.mtimeMs !== after.mtimeMs || stat2.ctimeMs !== after.ctimeMs)
|
|
88720
88954
|
return fail();
|
|
88721
88955
|
return bytes;
|
|
88722
88956
|
} finally {
|
|
88723
|
-
|
|
88957
|
+
closeSync16(fd);
|
|
88724
88958
|
}
|
|
88725
88959
|
}
|
|
88726
88960
|
function writeOwned(directory, name, bytes) {
|
|
88727
|
-
const fd =
|
|
88961
|
+
const fd = openSync16(join36(directory, name), constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | constants12.O_NOFOLLOW, 384);
|
|
88728
88962
|
try {
|
|
88729
88963
|
writeFileSync9(fd, bytes);
|
|
88730
88964
|
fsyncSync4(fd);
|
|
88731
88965
|
} finally {
|
|
88732
|
-
|
|
88966
|
+
closeSync16(fd);
|
|
88733
88967
|
}
|
|
88734
88968
|
}
|
|
88735
88969
|
function save(directory, value) {
|
|
@@ -88738,11 +88972,11 @@ function save(directory, value) {
|
|
|
88738
88972
|
`);
|
|
88739
88973
|
unchangedDirectory(directory, identity3);
|
|
88740
88974
|
renameSync6(join36(directory, temporary), join36(directory, "receipt.json"));
|
|
88741
|
-
const fd =
|
|
88975
|
+
const fd = openSync16(directory, constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
88742
88976
|
try {
|
|
88743
88977
|
fsyncSync4(fd);
|
|
88744
88978
|
} finally {
|
|
88745
|
-
|
|
88979
|
+
closeSync16(fd);
|
|
88746
88980
|
}
|
|
88747
88981
|
}
|
|
88748
88982
|
function bind(client2, receipt) {
|
|
@@ -88753,20 +88987,20 @@ async function locked(directory, action) {
|
|
|
88753
88987
|
const identity3 = safeDirectory(directory), file2 = join36(directory, "operation.lock");
|
|
88754
88988
|
let fd;
|
|
88755
88989
|
try {
|
|
88756
|
-
fd =
|
|
88990
|
+
fd = openSync16(file2, constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | constants12.O_NOFOLLOW, 384);
|
|
88757
88991
|
} catch {
|
|
88758
88992
|
throw new PrivatePublicationError("PUBLICATION_RECOVERY_BUSY", "Another operation holds this recovery directory. If it crashed, confirm that process has stopped before explicitly removing operation.lock and resuming.");
|
|
88759
88993
|
}
|
|
88760
|
-
const lock =
|
|
88994
|
+
const lock = fstatSync16(fd);
|
|
88761
88995
|
try {
|
|
88762
88996
|
writeFileSync9(fd, JSON.stringify({ pid: process.pid }) + `
|
|
88763
88997
|
`);
|
|
88764
88998
|
fsyncSync4(fd);
|
|
88765
88999
|
return await action();
|
|
88766
89000
|
} finally {
|
|
88767
|
-
|
|
89001
|
+
closeSync16(fd);
|
|
88768
89002
|
unchangedDirectory(directory, identity3);
|
|
88769
|
-
const now2 =
|
|
89003
|
+
const now2 = lstatSync20(file2);
|
|
88770
89004
|
if (now2.dev !== lock.dev || now2.ino !== lock.ino || !now2.isFile() || now2.isSymbolicLink())
|
|
88771
89005
|
fail();
|
|
88772
89006
|
unlinkSync5(file2);
|
|
@@ -88818,15 +89052,15 @@ async function preparePrivatePublication(client2, sourceDirectory, recoveryDirec
|
|
|
88818
89052
|
phase: "prepared",
|
|
88819
89053
|
intent: null
|
|
88820
89054
|
};
|
|
88821
|
-
if (!
|
|
89055
|
+
if (!isAbsolute18(recoveryDirectory) || resolve18(recoveryDirectory) !== recoveryDirectory || realpathSync8(dirname23(recoveryDirectory)) !== dirname23(recoveryDirectory))
|
|
88822
89056
|
return fail();
|
|
88823
89057
|
mkdirSync14(recoveryDirectory, { mode: 448 });
|
|
88824
89058
|
safeDirectory(recoveryDirectory);
|
|
88825
|
-
const parent =
|
|
89059
|
+
const parent = openSync16(dirname23(recoveryDirectory), constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
88826
89060
|
try {
|
|
88827
89061
|
fsyncSync4(parent);
|
|
88828
89062
|
} finally {
|
|
88829
|
-
|
|
89063
|
+
closeSync16(parent);
|
|
88830
89064
|
}
|
|
88831
89065
|
writeOwned(recoveryDirectory, "bundle.tgz", packed.bytes);
|
|
88832
89066
|
save(recoveryDirectory, receipt);
|