@hasna/skills 0.9.10 → 0.9.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 +80 -0
- package/bin/index.js +16174 -15885
- package/bin/mcp.js +11591 -9834
- package/bin/migrate.js +1 -1
- package/bin/server.js +1 -1
- package/bin/worker.js +1 -1
- package/dist/cli/commands/profile-sync.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8045 -7587
- package/dist/lib/agent-codex-trust.d.ts +28 -10
- package/dist/lib/agent-discovery.d.ts +3 -1
- package/dist/lib/agent-integration.d.ts +17 -0
- package/dist/lib/authoring-path.d.ts +10 -0
- package/dist/lib/claude-settings-witness.d.ts +6 -0
- package/dist/lib/codex-hook-additions-review.d.ts +42 -0
- package/dist/lib/codex-hook-discovery-recovery.d.ts +25 -0
- package/dist/lib/native-discovery-roots.d.ts +2 -0
- package/dist/sdk/index.js +1033 -578
- package/docs/skill-standard.md +7 -1
- 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((resolve18) => setTimeout(resolve18, 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((resolve18) => {
|
|
8342
|
+
onAbort = () => resolve18({ state: WaiterState.ABORTED });
|
|
8343
8343
|
if (typeof abortSignal.addEventListener === "function") {
|
|
8344
8344
|
abortSignal.addEventListener("abort", onAbort);
|
|
8345
8345
|
} else {
|
|
@@ -9002,9 +9002,9 @@ var require_client = __commonJS((exports) => {
|
|
|
9002
9002
|
|
|
9003
9003
|
// node_modules/@smithy/core/dist-cjs/submodules/config/index.js
|
|
9004
9004
|
var require_config = __commonJS((exports) => {
|
|
9005
|
-
var { homedir:
|
|
9006
|
-
var { sep:
|
|
9007
|
-
var { createHash:
|
|
9005
|
+
var { homedir: homedir7 } = __require("os");
|
|
9006
|
+
var { sep: sep8, join: join4 } = __require("path");
|
|
9007
|
+
var { createHash: createHash19 } = __require("crypto");
|
|
9008
9008
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
9009
9009
|
var { IniSectionType } = require_dist_cjs();
|
|
9010
9010
|
var { normalizeProvider } = require_client();
|
|
@@ -9143,7 +9143,7 @@ var require_config = __commonJS((exports) => {
|
|
|
9143
9143
|
return "DEFAULT";
|
|
9144
9144
|
};
|
|
9145
9145
|
var getHomeDir = () => {
|
|
9146
|
-
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${
|
|
9146
|
+
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${sep8}` } = process.env;
|
|
9147
9147
|
if (HOME)
|
|
9148
9148
|
return HOME;
|
|
9149
9149
|
if (USERPROFILE)
|
|
@@ -9152,14 +9152,14 @@ var require_config = __commonJS((exports) => {
|
|
|
9152
9152
|
return `${HOMEDRIVE}${HOMEPATH}`;
|
|
9153
9153
|
const homeDirCacheKey = getHomeDirCacheKey();
|
|
9154
9154
|
if (!homeDirCache[homeDirCacheKey])
|
|
9155
|
-
homeDirCache[homeDirCacheKey] =
|
|
9155
|
+
homeDirCache[homeDirCacheKey] = homedir7();
|
|
9156
9156
|
return homeDirCache[homeDirCacheKey];
|
|
9157
9157
|
};
|
|
9158
9158
|
var ENV_PROFILE = "AWS_PROFILE";
|
|
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 = createHash19("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 constants13 = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? []));
|
|
9315
|
+
constants13.delete("CONFIG");
|
|
9316
|
+
constants13.delete("CONFIG_PREFIX_SEPARATOR");
|
|
9317
|
+
constants13.delete("ENV");
|
|
9318
|
+
return [...constants13].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((resolve18, 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
|
+
resolve18(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: createHash19, getRandomValues } = __require("crypto");
|
|
10515
10515
|
var { hasOwn: hasOwn2, HttpResponse } = require_transport();
|
|
10516
10516
|
exports.hasOwn = hasOwn2;
|
|
10517
|
-
var { ReadStream, lstatSync:
|
|
10517
|
+
var { ReadStream, lstatSync: lstatSync22, 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 lstatSync22(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)) : createHash19(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((resolve18, 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
|
+
resolve18(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((resolve18, 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
|
+
resolve18(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: createHash19, 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((resolve18, 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(resolve18).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((resolve18, 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(resolve18).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
|
+
createHash19("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 = createHash19("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 = createHash19("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
|
+
createHash19("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)) : createHash19("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((resolve18) => setTimeout(() => resolve18(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((resolve18) => setTimeout(resolve18, 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((resolve18) => DefaultRateLimiter.setTimeoutFn(resolve18, 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((resolve18) => setTimeout(resolve18, delay));
|
|
15297
15297
|
continue;
|
|
15298
15298
|
}
|
|
15299
15299
|
if (!err.$metadata) {
|
|
@@ -24586,7 +24586,7 @@ var require_httpAuthSchemes = __commonJS((exports) => {
|
|
|
24586
24586
|
});
|
|
24587
24587
|
|
|
24588
24588
|
// node_modules/@aws-sdk/credential-provider-env/dist-es/fromEnv.js
|
|
24589
|
-
var import_client8,
|
|
24589
|
+
var import_client8, import_config9, ENV_KEY = "AWS_ACCESS_KEY_ID", ENV_SECRET = "AWS_SECRET_ACCESS_KEY", ENV_SESSION = "AWS_SESSION_TOKEN", ENV_EXPIRATION = "AWS_CREDENTIAL_EXPIRATION", ENV_CREDENTIAL_SCOPE = "AWS_CREDENTIAL_SCOPE", ENV_ACCOUNT_ID = "AWS_ACCOUNT_ID", fromEnv = (init) => async () => {
|
|
24590
24590
|
init?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");
|
|
24591
24591
|
const accessKeyId = process.env[ENV_KEY];
|
|
24592
24592
|
const secretAccessKey = process.env[ENV_SECRET];
|
|
@@ -24606,11 +24606,11 @@ var import_client8, import_config8, ENV_KEY = "AWS_ACCESS_KEY_ID", ENV_SECRET =
|
|
|
24606
24606
|
import_client8.setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g");
|
|
24607
24607
|
return credentials;
|
|
24608
24608
|
}
|
|
24609
|
-
throw new
|
|
24609
|
+
throw new import_config9.CredentialsProviderError("Unable to find environment variable credentials.", { logger: init?.logger });
|
|
24610
24610
|
};
|
|
24611
24611
|
var init_fromEnv = __esm(() => {
|
|
24612
24612
|
import_client8 = __toESM(require_client2(), 1);
|
|
24613
|
-
|
|
24613
|
+
import_config9 = __toESM(require_config(), 1);
|
|
24614
24614
|
});
|
|
24615
24615
|
|
|
24616
24616
|
// node_modules/@aws-sdk/credential-provider-env/dist-es/index.js
|
|
@@ -24646,24 +24646,24 @@ 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((resolve18, reject) => {
|
|
24650
24650
|
const req = node_http.request({
|
|
24651
24651
|
method: "GET",
|
|
24652
24652
|
...options,
|
|
24653
24653
|
hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1")
|
|
24654
24654
|
});
|
|
24655
24655
|
req.on("error", (err) => {
|
|
24656
|
-
reject(Object.assign(new
|
|
24656
|
+
reject(Object.assign(new import_config10.ProviderError("Unable to connect to instance metadata service"), err));
|
|
24657
24657
|
req.destroy();
|
|
24658
24658
|
});
|
|
24659
24659
|
req.on("timeout", () => {
|
|
24660
|
-
reject(new
|
|
24660
|
+
reject(new import_config10.ProviderError("TimeoutError from instance metadata service"));
|
|
24661
24661
|
req.destroy();
|
|
24662
24662
|
});
|
|
24663
24663
|
req.on("response", (res) => {
|
|
24664
24664
|
const { statusCode = 400 } = res;
|
|
24665
24665
|
if (statusCode < 200 || 300 <= statusCode) {
|
|
24666
|
-
reject(Object.assign(new
|
|
24666
|
+
reject(Object.assign(new import_config10.ProviderError("Error response received from instance metadata service"), { statusCode }));
|
|
24667
24667
|
req.destroy();
|
|
24668
24668
|
}
|
|
24669
24669
|
const chunks = [];
|
|
@@ -24671,17 +24671,17 @@ function httpRequest(options) {
|
|
|
24671
24671
|
chunks.push(chunk);
|
|
24672
24672
|
});
|
|
24673
24673
|
res.on("end", () => {
|
|
24674
|
-
|
|
24674
|
+
resolve18(Buffer.concat(chunks));
|
|
24675
24675
|
req.destroy();
|
|
24676
24676
|
});
|
|
24677
24677
|
});
|
|
24678
24678
|
req.end();
|
|
24679
24679
|
});
|
|
24680
24680
|
}
|
|
24681
|
-
var
|
|
24681
|
+
var import_config10;
|
|
24682
24682
|
var init_httpRequest = __esm(() => {
|
|
24683
24683
|
init_node_http();
|
|
24684
|
-
|
|
24684
|
+
import_config10 = __toESM(require_config(), 1);
|
|
24685
24685
|
});
|
|
24686
24686
|
|
|
24687
24687
|
// node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/retry.js
|
|
@@ -24694,13 +24694,13 @@ var retry = (toRetry, maxRetries) => {
|
|
|
24694
24694
|
};
|
|
24695
24695
|
|
|
24696
24696
|
// node_modules/@smithy/credential-provider-imds/dist-es/fromContainerMetadata.js
|
|
24697
|
-
var
|
|
24697
|
+
var import_config11, ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI", ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI", ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN", fromContainerMetadata = (init = {}) => {
|
|
24698
24698
|
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
24699
24699
|
return () => retry(async () => {
|
|
24700
24700
|
const requestOptions = await getCmdsUri({ logger: init.logger });
|
|
24701
24701
|
const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
|
|
24702
24702
|
if (!isImdsCredentials(credsResponse)) {
|
|
24703
|
-
throw new
|
|
24703
|
+
throw new import_config11.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
|
24704
24704
|
logger: init.logger
|
|
24705
24705
|
});
|
|
24706
24706
|
}
|
|
@@ -24730,16 +24730,16 @@ var import_config10, ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI", E
|
|
|
24730
24730
|
try {
|
|
24731
24731
|
parsed = new URL(process.env[ENV_CMDS_FULL_URI]);
|
|
24732
24732
|
} catch {
|
|
24733
|
-
throw new
|
|
24733
|
+
throw new import_config11.CredentialsProviderError(`${process.env[ENV_CMDS_FULL_URI]} is not a valid container metadata service URL`, { tryNextLink: false, logger });
|
|
24734
24734
|
}
|
|
24735
24735
|
if (!parsed.hostname || !GREENGRASS_HOSTS.has(parsed.hostname)) {
|
|
24736
|
-
throw new
|
|
24736
|
+
throw new import_config11.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
24737
24737
|
tryNextLink: false,
|
|
24738
24738
|
logger
|
|
24739
24739
|
});
|
|
24740
24740
|
}
|
|
24741
24741
|
if (!parsed.protocol || !GREENGRASS_PROTOCOLS.has(parsed.protocol)) {
|
|
24742
|
-
throw new
|
|
24742
|
+
throw new import_config11.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
24743
24743
|
tryNextLink: false,
|
|
24744
24744
|
logger
|
|
24745
24745
|
});
|
|
@@ -24751,23 +24751,23 @@ var import_config10, ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI", E
|
|
|
24751
24751
|
port: parsed.port ? parseInt(parsed.port, 10) : undefined
|
|
24752
24752
|
};
|
|
24753
24753
|
}
|
|
24754
|
-
throw new
|
|
24754
|
+
throw new import_config11.CredentialsProviderError("The container metadata credential provider cannot be used unless" + ` the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment` + " variable is set", {
|
|
24755
24755
|
tryNextLink: false,
|
|
24756
24756
|
logger
|
|
24757
24757
|
});
|
|
24758
24758
|
};
|
|
24759
24759
|
var init_fromContainerMetadata = __esm(() => {
|
|
24760
24760
|
init_httpRequest();
|
|
24761
|
-
|
|
24761
|
+
import_config11 = __toESM(require_config(), 1);
|
|
24762
24762
|
GREENGRASS_HOSTS = new Set(["localhost", "127.0.0.1"]);
|
|
24763
24763
|
GREENGRASS_PROTOCOLS = new Set(["http:", "https:"]);
|
|
24764
24764
|
});
|
|
24765
24765
|
|
|
24766
24766
|
// node_modules/@smithy/credential-provider-imds/dist-es/error/InstanceMetadataV1FallbackError.js
|
|
24767
|
-
var
|
|
24767
|
+
var import_config12, InstanceMetadataV1FallbackError;
|
|
24768
24768
|
var init_InstanceMetadataV1FallbackError = __esm(() => {
|
|
24769
|
-
|
|
24770
|
-
InstanceMetadataV1FallbackError = class InstanceMetadataV1FallbackError extends
|
|
24769
|
+
import_config12 = __toESM(require_config(), 1);
|
|
24770
|
+
InstanceMetadataV1FallbackError = class InstanceMetadataV1FallbackError extends import_config12.CredentialsProviderError {
|
|
24771
24771
|
tryNextLink;
|
|
24772
24772
|
name = "InstanceMetadataV1FallbackError";
|
|
24773
24773
|
constructor(message, tryNextLink = true) {
|
|
@@ -24818,8 +24818,8 @@ var init_EndpointModeConfigOptions = __esm(() => {
|
|
|
24818
24818
|
});
|
|
24819
24819
|
|
|
24820
24820
|
// node_modules/@smithy/credential-provider-imds/dist-es/utils/getInstanceMetadataEndpoint.js
|
|
24821
|
-
var
|
|
24822
|
-
const endpointMode = await
|
|
24821
|
+
var import_config13, import_protocols, getInstanceMetadataEndpoint = async () => import_protocols.parseUrl(await getFromEndpointConfig() || await getFromEndpointModeConfig()), getFromEndpointConfig = async () => import_config13.loadConfig(ENDPOINT_CONFIG_OPTIONS)(), getFromEndpointModeConfig = async () => {
|
|
24822
|
+
const endpointMode = await import_config13.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
|
|
24823
24823
|
switch (endpointMode) {
|
|
24824
24824
|
case EndpointMode.IPv4:
|
|
24825
24825
|
return Endpoint.IPv4;
|
|
@@ -24834,7 +24834,7 @@ var init_getInstanceMetadataEndpoint = __esm(() => {
|
|
|
24834
24834
|
init_EndpointConfigOptions();
|
|
24835
24835
|
init_EndpointMode();
|
|
24836
24836
|
init_EndpointModeConfigOptions();
|
|
24837
|
-
|
|
24837
|
+
import_config13 = __toESM(require_config(), 1);
|
|
24838
24838
|
import_protocols = __toESM(require_protocols(), 1);
|
|
24839
24839
|
});
|
|
24840
24840
|
|
|
@@ -24884,7 +24884,7 @@ var init_staticStabilityProvider = __esm(() => {
|
|
|
24884
24884
|
});
|
|
24885
24885
|
|
|
24886
24886
|
// node_modules/@smithy/credential-provider-imds/dist-es/fromInstanceMetadata.js
|
|
24887
|
-
var
|
|
24887
|
+
var import_config14, IMDS_PATH = "/latest/meta-data/iam/security-credentials/", IMDS_TOKEN_PATH = "/latest/api/token", AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED", PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled", X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token", fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger }), getInstanceMetadataProvider = (init = {}) => {
|
|
24888
24888
|
let disableFetchToken = false;
|
|
24889
24889
|
const { logger, profile } = init;
|
|
24890
24890
|
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
@@ -24893,12 +24893,12 @@ var import_config13, IMDS_PATH = "/latest/meta-data/iam/security-credentials/",
|
|
|
24893
24893
|
if (isImdsV1Fallback) {
|
|
24894
24894
|
let fallbackBlockedFromProfile = false;
|
|
24895
24895
|
let fallbackBlockedFromProcessEnv = false;
|
|
24896
|
-
const configValue = await
|
|
24896
|
+
const configValue = await import_config14.loadConfig({
|
|
24897
24897
|
environmentVariableSelector: (env) => {
|
|
24898
24898
|
const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
|
|
24899
24899
|
fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
|
|
24900
24900
|
if (envValue === undefined) {
|
|
24901
|
-
throw new
|
|
24901
|
+
throw new import_config14.CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
|
|
24902
24902
|
}
|
|
24903
24903
|
return fallbackBlockedFromProcessEnv;
|
|
24904
24904
|
},
|
|
@@ -24989,7 +24989,7 @@ var import_config13, IMDS_PATH = "/latest/meta-data/iam/security-credentials/",
|
|
|
24989
24989
|
path: IMDS_PATH + profile
|
|
24990
24990
|
})).toString());
|
|
24991
24991
|
if (!isImdsCredentials(credentialsResponse)) {
|
|
24992
|
-
throw new
|
|
24992
|
+
throw new import_config14.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
|
24993
24993
|
logger: init.logger
|
|
24994
24994
|
});
|
|
24995
24995
|
}
|
|
@@ -25000,7 +25000,7 @@ var init_fromInstanceMetadata = __esm(() => {
|
|
|
25000
25000
|
init_httpRequest();
|
|
25001
25001
|
init_getInstanceMetadataEndpoint();
|
|
25002
25002
|
init_staticStabilityProvider();
|
|
25003
|
-
|
|
25003
|
+
import_config14 = __toESM(require_config(), 1);
|
|
25004
25004
|
});
|
|
25005
25005
|
|
|
25006
25006
|
// node_modules/@smithy/credential-provider-imds/dist-es/index.js
|
|
@@ -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((resolve18) => {
|
|
25172
|
+
timeoutId = Number(timing.setTimeout(() => resolve18(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
25173
25173
|
}),
|
|
25174
|
-
new Promise((
|
|
25174
|
+
new Promise((resolve18) => {
|
|
25175
25175
|
httpRequest2.on("continue", () => {
|
|
25176
25176
|
timing.clearTimeout(timeoutId);
|
|
25177
|
-
|
|
25177
|
+
resolve18(true);
|
|
25178
25178
|
});
|
|
25179
25179
|
httpRequest2.on("response", () => {
|
|
25180
25180
|
timing.clearTimeout(timeoutId);
|
|
25181
|
-
|
|
25181
|
+
resolve18(false);
|
|
25182
25182
|
});
|
|
25183
25183
|
httpRequest2.on("error", () => {
|
|
25184
25184
|
timing.clearTimeout(timeoutId);
|
|
25185
|
-
|
|
25185
|
+
resolve18(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((resolve18, reject) => {
|
|
25263
25263
|
if (typeof options === "function") {
|
|
25264
25264
|
options().then((_options) => {
|
|
25265
|
-
|
|
25265
|
+
resolve18(this.resolveDefaultConfig(_options));
|
|
25266
25266
|
}).catch(reject);
|
|
25267
25267
|
} else {
|
|
25268
|
-
|
|
25268
|
+
resolve18(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 resolve18 = 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
|
+
resolve18({ 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: constants13 } = 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((resolve18, reject) => {
|
|
25697
25697
|
if (typeof options === "function") {
|
|
25698
25698
|
options().then((opts) => {
|
|
25699
|
-
|
|
25699
|
+
resolve18(opts || {});
|
|
25700
25700
|
}).catch(reject);
|
|
25701
25701
|
} else {
|
|
25702
|
-
|
|
25702
|
+
resolve18(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 resolve18 = 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
|
+
[constants13.HTTP2_HEADER_PATH]: path,
|
|
25774
|
+
[constants13.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
|
+
resolve18({ response: httpResponse });
|
|
25813
25813
|
if (useIsolatedSession) {
|
|
25814
25814
|
session.close();
|
|
25815
25815
|
clientHttp2Stream.on("end", () => {
|
|
@@ -25853,7 +25853,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25853
25853
|
});
|
|
25854
25854
|
|
|
25855
25855
|
// node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/checkUrl.js
|
|
25856
|
-
var
|
|
25856
|
+
var import_config15, ECS_CONTAINER_HOST = "169.254.170.2", EKS_CONTAINER_HOST_IPv4 = "169.254.170.23", EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]", checkUrl = (url, logger) => {
|
|
25857
25857
|
if (url.protocol === "https:") {
|
|
25858
25858
|
return;
|
|
25859
25859
|
}
|
|
@@ -25877,13 +25877,13 @@ var import_config14, ECS_CONTAINER_HOST = "169.254.170.2", EKS_CONTAINER_HOST_IP
|
|
|
25877
25877
|
return;
|
|
25878
25878
|
}
|
|
25879
25879
|
}
|
|
25880
|
-
throw new
|
|
25880
|
+
throw new import_config15.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
|
25881
25881
|
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
|
25882
25882
|
- ECS container host 169.254.170.2
|
|
25883
25883
|
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
|
|
25884
25884
|
};
|
|
25885
25885
|
var init_checkUrl = __esm(() => {
|
|
25886
|
-
|
|
25886
|
+
import_config15 = __toESM(require_config(), 1);
|
|
25887
25887
|
});
|
|
25888
25888
|
|
|
25889
25889
|
// node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/requestHelpers.js
|
|
@@ -25906,7 +25906,7 @@ async function getCredentials(response, logger) {
|
|
|
25906
25906
|
if (response.statusCode === 200) {
|
|
25907
25907
|
const parsed = JSON.parse(str);
|
|
25908
25908
|
if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
|
|
25909
|
-
throw new
|
|
25909
|
+
throw new import_config16.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " + "{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
|
|
25910
25910
|
}
|
|
25911
25911
|
return {
|
|
25912
25912
|
accessKeyId: parsed.AccessKeyId,
|
|
@@ -25920,16 +25920,16 @@ async function getCredentials(response, logger) {
|
|
|
25920
25920
|
try {
|
|
25921
25921
|
parsedBody = JSON.parse(str);
|
|
25922
25922
|
} catch (e3) {}
|
|
25923
|
-
throw Object.assign(new
|
|
25923
|
+
throw Object.assign(new import_config16.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
|
|
25924
25924
|
Code: parsedBody.Code,
|
|
25925
25925
|
Message: parsedBody.Message
|
|
25926
25926
|
});
|
|
25927
25927
|
}
|
|
25928
|
-
throw new
|
|
25928
|
+
throw new import_config16.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
|
|
25929
25929
|
}
|
|
25930
|
-
var
|
|
25930
|
+
var import_config16, import_protocols2, import_serde, import_serde2;
|
|
25931
25931
|
var init_requestHelpers = __esm(() => {
|
|
25932
|
-
|
|
25932
|
+
import_config16 = __toESM(require_config(), 1);
|
|
25933
25933
|
import_protocols2 = __toESM(require_protocols(), 1);
|
|
25934
25934
|
import_serde = __toESM(require_serde(), 1);
|
|
25935
25935
|
import_serde2 = __toESM(require_serde(), 1);
|
|
@@ -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((resolve18) => setTimeout(resolve18, delayMs));
|
|
25946
25946
|
}
|
|
25947
25947
|
}
|
|
25948
25948
|
return await toRetry();
|
|
@@ -25951,7 +25951,7 @@ var retryWrapper = (toRetry, maxRetries, delayMs) => {
|
|
|
25951
25951
|
|
|
25952
25952
|
// node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
|
|
25953
25953
|
import fs from "fs/promises";
|
|
25954
|
-
var import_client9,
|
|
25954
|
+
var import_client9, import_config17, import_node_http_handler, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI", DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2", AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI", AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE", AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN", fromHttp = (options = {}) => {
|
|
25955
25955
|
options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
|
|
25956
25956
|
let host;
|
|
25957
25957
|
const relative6 = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
|
|
@@ -25972,7 +25972,7 @@ var import_client9, import_config16, import_node_http_handler, AWS_CONTAINER_CRE
|
|
|
25972
25972
|
} else if (full) {
|
|
25973
25973
|
host = full;
|
|
25974
25974
|
} else {
|
|
25975
|
-
throw new
|
|
25975
|
+
throw new import_config17.CredentialsProviderError(`No HTTP credential provider host provided.
|
|
25976
25976
|
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
|
25977
25977
|
}
|
|
25978
25978
|
const url = new URL(host);
|
|
@@ -25990,7 +25990,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
25990
25990
|
const result = await requestHandler.handle(request2, { requestTimeout });
|
|
25991
25991
|
return getCredentials(result.response).then((creds) => import_client9.setCredentialFeature(creds, "CREDENTIALS_HTTP", "z"));
|
|
25992
25992
|
} catch (e3) {
|
|
25993
|
-
throw new
|
|
25993
|
+
throw new import_config17.CredentialsProviderError(String(e3), { logger: options.logger });
|
|
25994
25994
|
}
|
|
25995
25995
|
}, options.maxRetries ?? 3, options.timeout ?? 1000);
|
|
25996
25996
|
return async () => {
|
|
@@ -26003,7 +26003,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
26003
26003
|
}, validateToken = (token) => {
|
|
26004
26004
|
if (token.includes(`\r
|
|
26005
26005
|
`)) {
|
|
26006
|
-
throw new
|
|
26006
|
+
throw new import_config17.CredentialsProviderError("Authorization token contains invalid \\r\\n sequence.");
|
|
26007
26007
|
}
|
|
26008
26008
|
return token;
|
|
26009
26009
|
};
|
|
@@ -26011,7 +26011,7 @@ var init_fromHttp = __esm(() => {
|
|
|
26011
26011
|
init_checkUrl();
|
|
26012
26012
|
init_requestHelpers();
|
|
26013
26013
|
import_client9 = __toESM(require_client2(), 1);
|
|
26014
|
-
|
|
26014
|
+
import_config17 = __toESM(require_config(), 1);
|
|
26015
26015
|
import_node_http_handler = __toESM(require_dist_cjs6(), 1);
|
|
26016
26016
|
});
|
|
26017
26017
|
|
|
@@ -26814,70 +26814,70 @@ var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConf
|
|
|
26814
26814
|
var init_getNewSsoOidcToken = () => {};
|
|
26815
26815
|
|
|
26816
26816
|
// node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js
|
|
26817
|
-
var
|
|
26817
|
+
var import_config19, validateTokenExpiry = (token) => {
|
|
26818
26818
|
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
26819
|
-
throw new
|
|
26819
|
+
throw new import_config19.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
26820
26820
|
}
|
|
26821
26821
|
};
|
|
26822
26822
|
var init_validateTokenExpiry = __esm(() => {
|
|
26823
26823
|
init_constants();
|
|
26824
|
-
|
|
26824
|
+
import_config19 = __toESM(require_config(), 1);
|
|
26825
26825
|
});
|
|
26826
26826
|
|
|
26827
26827
|
// node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js
|
|
26828
|
-
var
|
|
26828
|
+
var import_config20, validateTokenKey = (key, value, forRefresh = false) => {
|
|
26829
26829
|
if (typeof value === "undefined") {
|
|
26830
|
-
throw new
|
|
26830
|
+
throw new import_config20.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
26831
26831
|
}
|
|
26832
26832
|
};
|
|
26833
26833
|
var init_validateTokenKey = __esm(() => {
|
|
26834
26834
|
init_constants();
|
|
26835
|
-
|
|
26835
|
+
import_config20 = __toESM(require_config(), 1);
|
|
26836
26836
|
});
|
|
26837
26837
|
|
|
26838
26838
|
// node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js
|
|
26839
26839
|
import { promises as fsPromises } from "fs";
|
|
26840
|
-
var
|
|
26841
|
-
const tokenFilepath =
|
|
26840
|
+
var import_config21, writeFile, writeSSOTokenToFile = (id2, ssoToken) => {
|
|
26841
|
+
const tokenFilepath = import_config21.getSSOTokenFilepath(id2);
|
|
26842
26842
|
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
26843
26843
|
return writeFile(tokenFilepath, tokenString);
|
|
26844
26844
|
};
|
|
26845
26845
|
var init_writeSSOTokenToFile = __esm(() => {
|
|
26846
|
-
|
|
26846
|
+
import_config21 = __toESM(require_config(), 1);
|
|
26847
26847
|
({ writeFile } = fsPromises);
|
|
26848
26848
|
});
|
|
26849
26849
|
|
|
26850
26850
|
// node_modules/@aws-sdk/token-providers/dist-es/fromSso.js
|
|
26851
|
-
var
|
|
26851
|
+
var import_config22, lastRefreshAttemptTimes, fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
26852
26852
|
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
26853
|
-
const profiles = await
|
|
26854
|
-
const profileName =
|
|
26853
|
+
const profiles = await import_config22.parseKnownFiles(init);
|
|
26854
|
+
const profileName = import_config22.getProfileName({
|
|
26855
26855
|
profile: init.profile ?? callerClientConfig?.profile
|
|
26856
26856
|
});
|
|
26857
26857
|
const profile = profiles[profileName];
|
|
26858
26858
|
if (!profile) {
|
|
26859
|
-
throw new
|
|
26859
|
+
throw new import_config22.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
26860
26860
|
} else if (!profile["sso_session"]) {
|
|
26861
|
-
throw new
|
|
26861
|
+
throw new import_config22.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
26862
26862
|
}
|
|
26863
26863
|
const ssoSessionName = profile["sso_session"];
|
|
26864
|
-
const ssoSessions = await
|
|
26864
|
+
const ssoSessions = await import_config22.loadSsoSessionData(init);
|
|
26865
26865
|
const ssoSession = ssoSessions[ssoSessionName];
|
|
26866
26866
|
if (!ssoSession) {
|
|
26867
|
-
throw new
|
|
26867
|
+
throw new import_config22.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
26868
26868
|
}
|
|
26869
26869
|
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
26870
26870
|
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
26871
|
-
throw new
|
|
26871
|
+
throw new import_config22.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
26872
26872
|
}
|
|
26873
26873
|
}
|
|
26874
26874
|
const ssoStartUrl = ssoSession["sso_start_url"];
|
|
26875
26875
|
const ssoRegion = ssoSession["sso_region"];
|
|
26876
26876
|
let ssoToken;
|
|
26877
26877
|
try {
|
|
26878
|
-
ssoToken = await
|
|
26878
|
+
ssoToken = await import_config22.getSSOTokenFromFile(ssoSessionName);
|
|
26879
26879
|
} catch (e3) {
|
|
26880
|
-
throw new
|
|
26880
|
+
throw new import_config22.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
26881
26881
|
}
|
|
26882
26882
|
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
26883
26883
|
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
@@ -26926,7 +26926,7 @@ var init_fromSso = __esm(() => {
|
|
|
26926
26926
|
init_validateTokenExpiry();
|
|
26927
26927
|
init_validateTokenKey();
|
|
26928
26928
|
init_writeSSOTokenToFile();
|
|
26929
|
-
|
|
26929
|
+
import_config22 = __toESM(require_config(), 1);
|
|
26930
26930
|
lastRefreshAttemptTimes = new Map;
|
|
26931
26931
|
});
|
|
26932
26932
|
|
|
@@ -27394,7 +27394,7 @@ var init_loadSso = __esm(() => {
|
|
|
27394
27394
|
});
|
|
27395
27395
|
|
|
27396
27396
|
// node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js
|
|
27397
|
-
var import_client10,
|
|
27397
|
+
var import_client10, import_config23, SHOULD_FAIL_CREDENTIAL_CHAIN = false, resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger }) => {
|
|
27398
27398
|
let token;
|
|
27399
27399
|
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
27400
27400
|
if (ssoSession) {
|
|
@@ -27413,23 +27413,23 @@ var import_client10, import_config22, SHOULD_FAIL_CREDENTIAL_CHAIN = false, reso
|
|
|
27413
27413
|
expiresAt: new Date(_token.expiration).toISOString()
|
|
27414
27414
|
};
|
|
27415
27415
|
} catch (e4) {
|
|
27416
|
-
throw new
|
|
27416
|
+
throw new import_config23.CredentialsProviderError(e4.message, {
|
|
27417
27417
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
27418
27418
|
logger
|
|
27419
27419
|
});
|
|
27420
27420
|
}
|
|
27421
27421
|
} else {
|
|
27422
27422
|
try {
|
|
27423
|
-
token = await
|
|
27423
|
+
token = await import_config23.getSSOTokenFromFile(ssoStartUrl);
|
|
27424
27424
|
} catch (e4) {
|
|
27425
|
-
throw new
|
|
27425
|
+
throw new import_config23.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
27426
27426
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
27427
27427
|
logger
|
|
27428
27428
|
});
|
|
27429
27429
|
}
|
|
27430
27430
|
}
|
|
27431
27431
|
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
27432
|
-
throw new
|
|
27432
|
+
throw new import_config23.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
27433
27433
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
27434
27434
|
logger
|
|
27435
27435
|
});
|
|
@@ -27449,14 +27449,14 @@ var import_client10, import_config22, SHOULD_FAIL_CREDENTIAL_CHAIN = false, reso
|
|
|
27449
27449
|
accessToken
|
|
27450
27450
|
}));
|
|
27451
27451
|
} catch (e4) {
|
|
27452
|
-
throw new
|
|
27452
|
+
throw new import_config23.CredentialsProviderError(e4, {
|
|
27453
27453
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
27454
27454
|
logger
|
|
27455
27455
|
});
|
|
27456
27456
|
}
|
|
27457
27457
|
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
|
|
27458
27458
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
27459
|
-
throw new
|
|
27459
|
+
throw new import_config23.CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
27460
27460
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
27461
27461
|
logger
|
|
27462
27462
|
});
|
|
@@ -27479,53 +27479,53 @@ var import_client10, import_config22, SHOULD_FAIL_CREDENTIAL_CHAIN = false, reso
|
|
|
27479
27479
|
var init_resolveSSOCredentials = __esm(() => {
|
|
27480
27480
|
init_dist_es4();
|
|
27481
27481
|
import_client10 = __toESM(require_client2(), 1);
|
|
27482
|
-
|
|
27482
|
+
import_config23 = __toESM(require_config(), 1);
|
|
27483
27483
|
});
|
|
27484
27484
|
|
|
27485
27485
|
// node_modules/@aws-sdk/credential-provider-sso/dist-es/validateSsoProfile.js
|
|
27486
|
-
var
|
|
27486
|
+
var import_config24, validateSsoProfile = (profile, logger) => {
|
|
27487
27487
|
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
27488
27488
|
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
27489
|
-
throw new
|
|
27489
|
+
throw new import_config24.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", ` + `"sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
|
|
27490
27490
|
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger });
|
|
27491
27491
|
}
|
|
27492
27492
|
return profile;
|
|
27493
27493
|
};
|
|
27494
27494
|
var init_validateSsoProfile = __esm(() => {
|
|
27495
|
-
|
|
27495
|
+
import_config24 = __toESM(require_config(), 1);
|
|
27496
27496
|
});
|
|
27497
27497
|
|
|
27498
27498
|
// node_modules/@aws-sdk/credential-provider-sso/dist-es/fromSSO.js
|
|
27499
|
-
var
|
|
27499
|
+
var import_config25, fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
27500
27500
|
init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
|
|
27501
27501
|
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
27502
27502
|
const { ssoClient } = init;
|
|
27503
|
-
const profileName =
|
|
27503
|
+
const profileName = import_config25.getProfileName({
|
|
27504
27504
|
profile: init.profile ?? callerClientConfig?.profile
|
|
27505
27505
|
});
|
|
27506
27506
|
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
|
|
27507
|
-
const profiles = await
|
|
27507
|
+
const profiles = await import_config25.parseKnownFiles(init);
|
|
27508
27508
|
const profile = profiles[profileName];
|
|
27509
27509
|
if (!profile) {
|
|
27510
|
-
throw new
|
|
27510
|
+
throw new import_config25.CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
|
|
27511
27511
|
}
|
|
27512
27512
|
if (!isSsoProfile(profile)) {
|
|
27513
|
-
throw new
|
|
27513
|
+
throw new import_config25.CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
|
|
27514
27514
|
logger: init.logger
|
|
27515
27515
|
});
|
|
27516
27516
|
}
|
|
27517
27517
|
if (profile?.sso_session) {
|
|
27518
|
-
const ssoSessions = await
|
|
27518
|
+
const ssoSessions = await import_config25.loadSsoSessionData(init);
|
|
27519
27519
|
const session = ssoSessions[profile.sso_session];
|
|
27520
27520
|
const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
|
|
27521
27521
|
if (ssoRegion && ssoRegion !== session.sso_region) {
|
|
27522
|
-
throw new
|
|
27522
|
+
throw new import_config25.CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
|
|
27523
27523
|
tryNextLink: false,
|
|
27524
27524
|
logger: init.logger
|
|
27525
27525
|
});
|
|
27526
27526
|
}
|
|
27527
27527
|
if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
|
|
27528
|
-
throw new
|
|
27528
|
+
throw new import_config25.CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
|
|
27529
27529
|
tryNextLink: false,
|
|
27530
27530
|
logger: init.logger
|
|
27531
27531
|
});
|
|
@@ -27551,7 +27551,7 @@ var import_config24, fromSSO = (init = {}) => async ({ callerClientConfig } = {}
|
|
|
27551
27551
|
logger: init.logger
|
|
27552
27552
|
});
|
|
27553
27553
|
} else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
|
|
27554
|
-
throw new
|
|
27554
|
+
throw new import_config25.CredentialsProviderError("Incomplete configuration. The fromSSO() argument hash must include " + '"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
|
|
27555
27555
|
} else {
|
|
27556
27556
|
return resolveSSOCredentials({
|
|
27557
27557
|
ssoStartUrl,
|
|
@@ -27574,7 +27574,7 @@ var import_config24, fromSSO = (init = {}) => async ({ callerClientConfig } = {}
|
|
|
27574
27574
|
var init_fromSSO = __esm(() => {
|
|
27575
27575
|
init_resolveSSOCredentials();
|
|
27576
27576
|
init_validateSsoProfile();
|
|
27577
|
-
|
|
27577
|
+
import_config25 = __toESM(require_config(), 1);
|
|
27578
27578
|
});
|
|
27579
27579
|
|
|
27580
27580
|
// node_modules/@aws-sdk/credential-provider-sso/dist-es/index.js
|
|
@@ -27590,13 +27590,13 @@ var init_dist_es5 = __esm(() => {
|
|
|
27590
27590
|
});
|
|
27591
27591
|
|
|
27592
27592
|
// node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
|
|
27593
|
-
var import_client11,
|
|
27593
|
+
var import_client11, import_config26, resolveCredentialSource = (credentialSource, profileName, logger) => {
|
|
27594
27594
|
const sourceProvidersMap = {
|
|
27595
27595
|
EcsContainer: async (options) => {
|
|
27596
27596
|
const { fromHttp: fromHttp2 } = await Promise.resolve().then(() => (init_dist_es3(), exports_dist_es3));
|
|
27597
27597
|
const { fromContainerMetadata: fromContainerMetadata2 } = await Promise.resolve().then(() => (init_dist_es2(), exports_dist_es2));
|
|
27598
27598
|
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
|
27599
|
-
return async () =>
|
|
27599
|
+
return async () => import_config26.chain(fromHttp2(options ?? {}), fromContainerMetadata2(options))().then(setNamedProvider);
|
|
27600
27600
|
},
|
|
27601
27601
|
Ec2InstanceMetadata: async (options) => {
|
|
27602
27602
|
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
|
@@ -27612,12 +27612,12 @@ var import_client11, import_config25, resolveCredentialSource = (credentialSourc
|
|
|
27612
27612
|
if (credentialSource in sourceProvidersMap) {
|
|
27613
27613
|
return sourceProvidersMap[credentialSource];
|
|
27614
27614
|
} else {
|
|
27615
|
-
throw new
|
|
27615
|
+
throw new import_config26.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
|
|
27616
27616
|
}
|
|
27617
27617
|
}, setNamedProvider = (creds) => import_client11.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
|
|
27618
27618
|
var init_resolveCredentialSource = __esm(() => {
|
|
27619
27619
|
import_client11 = __toESM(require_client2(), 1);
|
|
27620
|
-
|
|
27620
|
+
import_config26 = __toESM(require_config(), 1);
|
|
27621
27621
|
});
|
|
27622
27622
|
|
|
27623
27623
|
// node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js
|
|
@@ -28643,7 +28643,7 @@ var require_sts = __commonJS((exports) => {
|
|
|
28643
28643
|
});
|
|
28644
28644
|
|
|
28645
28645
|
// node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
|
|
28646
|
-
var import_client12,
|
|
28646
|
+
var import_client12, import_config27, isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
|
|
28647
28647
|
return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger }));
|
|
28648
28648
|
}, isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
|
|
28649
28649
|
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
@@ -28674,7 +28674,7 @@ var import_client12, import_config26, isAssumeRoleProfile = (arg, { profile = "d
|
|
|
28674
28674
|
}, options.clientPlugins);
|
|
28675
28675
|
}
|
|
28676
28676
|
if (source_profile && source_profile in visitedProfiles) {
|
|
28677
|
-
throw new
|
|
28677
|
+
throw new import_config27.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${import_config27.getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
|
|
28678
28678
|
}
|
|
28679
28679
|
options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
|
|
28680
28680
|
const sourceCredsProvider = source_profile ? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
|
|
@@ -28693,7 +28693,7 @@ var import_client12, import_config26, isAssumeRoleProfile = (arg, { profile = "d
|
|
|
28693
28693
|
const { mfa_serial } = profileData;
|
|
28694
28694
|
if (mfa_serial) {
|
|
28695
28695
|
if (!options.mfaCodeProvider) {
|
|
28696
|
-
throw new
|
|
28696
|
+
throw new import_config27.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
|
|
28697
28697
|
}
|
|
28698
28698
|
params.SerialNumber = mfa_serial;
|
|
28699
28699
|
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
|
@@ -28707,7 +28707,7 @@ var import_client12, import_config26, isAssumeRoleProfile = (arg, { profile = "d
|
|
|
28707
28707
|
var init_resolveAssumeRoleCredentials = __esm(() => {
|
|
28708
28708
|
init_resolveCredentialSource();
|
|
28709
28709
|
import_client12 = __toESM(require_client2(), 1);
|
|
28710
|
-
|
|
28710
|
+
import_config27 = __toESM(require_config(), 1);
|
|
28711
28711
|
});
|
|
28712
28712
|
|
|
28713
28713
|
// node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js
|
|
@@ -29443,13 +29443,13 @@ 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 createHash19, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
29447
29447
|
import { promises as fs2 } from "fs";
|
|
29448
|
-
import { homedir as
|
|
29449
|
-
import { dirname as
|
|
29450
|
-
var
|
|
29448
|
+
import { homedir as homedir7 } from "os";
|
|
29449
|
+
import { dirname as dirname20, join as join32 } from "path";
|
|
29450
|
+
var import_config28, import_protocols3, LoginCredentialsFetcher;
|
|
29451
29451
|
var init_LoginCredentialsFetcher = __esm(() => {
|
|
29452
|
-
|
|
29452
|
+
import_config28 = __toESM(require_config(), 1);
|
|
29453
29453
|
import_protocols3 = __toESM(require_protocols(), 1);
|
|
29454
29454
|
LoginCredentialsFetcher = class LoginCredentialsFetcher {
|
|
29455
29455
|
profileData;
|
|
@@ -29464,7 +29464,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29464
29464
|
async loadCredentials() {
|
|
29465
29465
|
const token = await this.loadToken();
|
|
29466
29466
|
if (!token) {
|
|
29467
|
-
throw new
|
|
29467
|
+
throw new import_config28.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
|
|
29468
29468
|
}
|
|
29469
29469
|
const accessToken = token.accessToken;
|
|
29470
29470
|
const now = Date.now();
|
|
@@ -29531,7 +29531,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29531
29531
|
const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
|
|
29532
29532
|
const { refreshToken, expiresIn } = response.tokenOutput ?? {};
|
|
29533
29533
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
|
|
29534
|
-
throw new
|
|
29534
|
+
throw new import_config28.CredentialsProviderError("Token refresh response missing required fields", {
|
|
29535
29535
|
logger: this.logger,
|
|
29536
29536
|
tryNextLink: false
|
|
29537
29537
|
});
|
|
@@ -29568,7 +29568,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29568
29568
|
default:
|
|
29569
29569
|
message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
|
|
29570
29570
|
}
|
|
29571
|
-
throw new
|
|
29571
|
+
throw new import_config28.CredentialsProviderError(message, {
|
|
29572
29572
|
logger: this.logger,
|
|
29573
29573
|
tryNextLink: false
|
|
29574
29574
|
});
|
|
@@ -29578,7 +29578,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29578
29578
|
this.logger?.warn?.(`Failed to refresh token: ${String(error)}. Using existing token until expiry.`);
|
|
29579
29579
|
return this.toCredentials(freshToken.accessToken);
|
|
29580
29580
|
}
|
|
29581
|
-
throw new
|
|
29581
|
+
throw new import_config28.CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
|
|
29582
29582
|
}
|
|
29583
29583
|
}
|
|
29584
29584
|
async loadToken() {
|
|
@@ -29591,14 +29591,14 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29591
29591
|
missingFields.push("accountId");
|
|
29592
29592
|
}
|
|
29593
29593
|
if (missingFields.length > 0) {
|
|
29594
|
-
throw new
|
|
29594
|
+
throw new import_config28.CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
|
|
29595
29595
|
logger: this.logger,
|
|
29596
29596
|
tryNextLink: false
|
|
29597
29597
|
});
|
|
29598
29598
|
}
|
|
29599
29599
|
return token;
|
|
29600
29600
|
} catch (error) {
|
|
29601
|
-
throw new
|
|
29601
|
+
throw new import_config28.CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
|
|
29602
29602
|
logger: this.logger,
|
|
29603
29603
|
tryNextLink: false
|
|
29604
29604
|
});
|
|
@@ -29606,17 +29606,17 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29606
29606
|
}
|
|
29607
29607
|
async saveToken(token) {
|
|
29608
29608
|
const tokenFilePath = this.getTokenFilePath();
|
|
29609
|
-
const directory =
|
|
29609
|
+
const directory = dirname20(tokenFilePath);
|
|
29610
29610
|
try {
|
|
29611
29611
|
await fs2.mkdir(directory, { recursive: true });
|
|
29612
29612
|
} catch (error) {}
|
|
29613
29613
|
await fs2.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
29614
29614
|
}
|
|
29615
29615
|
getTokenFilePath() {
|
|
29616
|
-
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ??
|
|
29616
|
+
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join32(homedir7(), ".aws", "login", "cache");
|
|
29617
29617
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
29618
|
-
const loginSessionSha256 =
|
|
29619
|
-
return
|
|
29618
|
+
const loginSessionSha256 = createHash19("sha256").update(loginSessionBytes).digest("hex");
|
|
29619
|
+
return join32(directory, `${loginSessionSha256}.json`);
|
|
29620
29620
|
}
|
|
29621
29621
|
derToRawSignature(derSignature) {
|
|
29622
29622
|
let offset = 2;
|
|
@@ -29700,22 +29700,22 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29700
29700
|
const signatureB64 = rawSignature.toString("base64url");
|
|
29701
29701
|
return `${message}.${signatureB64}`;
|
|
29702
29702
|
} catch (error) {
|
|
29703
|
-
throw new
|
|
29703
|
+
throw new import_config28.CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
|
|
29704
29704
|
}
|
|
29705
29705
|
}
|
|
29706
29706
|
};
|
|
29707
29707
|
});
|
|
29708
29708
|
|
|
29709
29709
|
// node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/credential-provider-login/dist-es/fromLoginCredentials.js
|
|
29710
|
-
var import_client13,
|
|
29710
|
+
var import_client13, import_config29, fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
|
|
29711
29711
|
init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
|
|
29712
|
-
const profiles = await
|
|
29713
|
-
const profileName =
|
|
29712
|
+
const profiles = await import_config29.parseKnownFiles(init || {});
|
|
29713
|
+
const profileName = import_config29.getProfileName({
|
|
29714
29714
|
profile: init?.profile ?? callerClientConfig?.profile
|
|
29715
29715
|
});
|
|
29716
29716
|
const profile = profiles[profileName];
|
|
29717
29717
|
if (!profile?.login_session) {
|
|
29718
|
-
throw new
|
|
29718
|
+
throw new import_config29.CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
|
|
29719
29719
|
tryNextLink: true,
|
|
29720
29720
|
logger: init?.logger
|
|
29721
29721
|
});
|
|
@@ -29727,7 +29727,7 @@ var import_client13, import_config28, fromLoginCredentials = (init) => async ({
|
|
|
29727
29727
|
var init_fromLoginCredentials = __esm(() => {
|
|
29728
29728
|
init_LoginCredentialsFetcher();
|
|
29729
29729
|
import_client13 = __toESM(require_client2(), 1);
|
|
29730
|
-
|
|
29730
|
+
import_config29 = __toESM(require_config(), 1);
|
|
29731
29731
|
});
|
|
29732
29732
|
|
|
29733
29733
|
// node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/credential-provider-login/dist-es/index.js
|
|
@@ -29791,12 +29791,12 @@ var init_getValidatedProcessCredentials = __esm(() => {
|
|
|
29791
29791
|
// node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
|
|
29792
29792
|
import { exec } from "child_process";
|
|
29793
29793
|
import { promisify } from "util";
|
|
29794
|
-
var
|
|
29794
|
+
var import_config30, resolveProcessCredentials = async (profileName, profiles, logger) => {
|
|
29795
29795
|
const profile = profiles[profileName];
|
|
29796
29796
|
if (profiles[profileName]) {
|
|
29797
29797
|
const credentialProcess = profile["credential_process"];
|
|
29798
29798
|
if (credentialProcess !== undefined) {
|
|
29799
|
-
const execPromise = promisify(
|
|
29799
|
+
const execPromise = promisify(import_config30.externalDataInterceptor?.getTokenRecord?.().exec ?? exec);
|
|
29800
29800
|
try {
|
|
29801
29801
|
const { stdout } = await execPromise(credentialProcess);
|
|
29802
29802
|
let data;
|
|
@@ -29807,33 +29807,33 @@ var import_config29, resolveProcessCredentials = async (profileName, profiles, l
|
|
|
29807
29807
|
}
|
|
29808
29808
|
return getValidatedProcessCredentials(profileName, data, profiles);
|
|
29809
29809
|
} catch (error) {
|
|
29810
|
-
throw new
|
|
29810
|
+
throw new import_config30.CredentialsProviderError(error.message, { logger });
|
|
29811
29811
|
}
|
|
29812
29812
|
} else {
|
|
29813
|
-
throw new
|
|
29813
|
+
throw new import_config30.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
|
|
29814
29814
|
}
|
|
29815
29815
|
} else {
|
|
29816
|
-
throw new
|
|
29816
|
+
throw new import_config30.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
|
|
29817
29817
|
logger
|
|
29818
29818
|
});
|
|
29819
29819
|
}
|
|
29820
29820
|
};
|
|
29821
29821
|
var init_resolveProcessCredentials = __esm(() => {
|
|
29822
29822
|
init_getValidatedProcessCredentials();
|
|
29823
|
-
|
|
29823
|
+
import_config30 = __toESM(require_config(), 1);
|
|
29824
29824
|
});
|
|
29825
29825
|
|
|
29826
29826
|
// node_modules/@aws-sdk/credential-provider-process/dist-es/fromProcess.js
|
|
29827
|
-
var
|
|
29827
|
+
var import_config31, fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
29828
29828
|
init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
|
|
29829
|
-
const profiles = await
|
|
29830
|
-
return resolveProcessCredentials(
|
|
29829
|
+
const profiles = await import_config31.parseKnownFiles(init);
|
|
29830
|
+
return resolveProcessCredentials(import_config31.getProfileName({
|
|
29831
29831
|
profile: init.profile ?? callerClientConfig?.profile
|
|
29832
29832
|
}), profiles, init.logger);
|
|
29833
29833
|
};
|
|
29834
29834
|
var init_fromProcess = __esm(() => {
|
|
29835
29835
|
init_resolveProcessCredentials();
|
|
29836
|
-
|
|
29836
|
+
import_config31 = __toESM(require_config(), 1);
|
|
29837
29837
|
});
|
|
29838
29838
|
|
|
29839
29839
|
// node_modules/@aws-sdk/credential-provider-process/dist-es/index.js
|
|
@@ -30947,19 +30947,19 @@ var fromWebToken = (init) => async (awsIdentityProperties) => {
|
|
|
30947
30947
|
|
|
30948
30948
|
// node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
|
|
30949
30949
|
import { readFileSync as readFileSync21 } from "fs";
|
|
30950
|
-
var import_client19,
|
|
30950
|
+
var import_client19, import_config32, ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE", ENV_ROLE_ARN = "AWS_ROLE_ARN", ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME", fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
|
30951
30951
|
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
|
30952
30952
|
const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
|
|
30953
30953
|
const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
|
|
30954
30954
|
const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
|
|
30955
30955
|
if (!webIdentityTokenFile || !roleArn) {
|
|
30956
|
-
throw new
|
|
30956
|
+
throw new import_config32.CredentialsProviderError("Web identity configuration not specified", {
|
|
30957
30957
|
logger: init.logger
|
|
30958
30958
|
});
|
|
30959
30959
|
}
|
|
30960
30960
|
const credentials = await fromWebToken({
|
|
30961
30961
|
...init,
|
|
30962
|
-
webIdentityToken:
|
|
30962
|
+
webIdentityToken: import_config32.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync21(webIdentityTokenFile, { encoding: "ascii" }),
|
|
30963
30963
|
roleArn,
|
|
30964
30964
|
roleSessionName
|
|
30965
30965
|
})(awsIdentityProperties);
|
|
@@ -30970,7 +30970,7 @@ var import_client19, import_config31, ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_F
|
|
|
30970
30970
|
};
|
|
30971
30971
|
var init_fromTokenFile = __esm(() => {
|
|
30972
30972
|
import_client19 = __toESM(require_client2(), 1);
|
|
30973
|
-
|
|
30973
|
+
import_config32 = __toESM(require_config(), 1);
|
|
30974
30974
|
});
|
|
30975
30975
|
|
|
30976
30976
|
// node_modules/@aws-sdk/credential-provider-web-identity/dist-es/index.js
|
|
@@ -31003,7 +31003,7 @@ var init_resolveWebIdentityCredentials = __esm(() => {
|
|
|
31003
31003
|
});
|
|
31004
31004
|
|
|
31005
31005
|
// node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
|
|
31006
|
-
var
|
|
31006
|
+
var import_config33, resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
|
|
31007
31007
|
const data = profiles[profileName];
|
|
31008
31008
|
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
|
31009
31009
|
return resolveStaticCredentials(data, options);
|
|
@@ -31026,7 +31026,7 @@ var import_config32, resolveProfileData = async (profileName, profiles, options,
|
|
|
31026
31026
|
if (isLoginProfile(data)) {
|
|
31027
31027
|
return resolveLoginCredentials(profileName, options, callerClientConfig);
|
|
31028
31028
|
}
|
|
31029
|
-
throw new
|
|
31029
|
+
throw new import_config33.CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
|
|
31030
31030
|
};
|
|
31031
31031
|
var init_resolveProfileData = __esm(() => {
|
|
31032
31032
|
init_resolveAssumeRoleCredentials();
|
|
@@ -31035,20 +31035,20 @@ var init_resolveProfileData = __esm(() => {
|
|
|
31035
31035
|
init_resolveSsoCredentials();
|
|
31036
31036
|
init_resolveStaticCredentials();
|
|
31037
31037
|
init_resolveWebIdentityCredentials();
|
|
31038
|
-
|
|
31038
|
+
import_config33 = __toESM(require_config(), 1);
|
|
31039
31039
|
});
|
|
31040
31040
|
|
|
31041
31041
|
// node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
|
|
31042
|
-
var
|
|
31042
|
+
var import_config34, fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
31043
31043
|
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
|
31044
|
-
const profiles = await
|
|
31045
|
-
return resolveProfileData(
|
|
31044
|
+
const profiles = await import_config34.parseKnownFiles(init);
|
|
31045
|
+
return resolveProfileData(import_config34.getProfileName({
|
|
31046
31046
|
profile: init.profile ?? callerClientConfig?.profile
|
|
31047
31047
|
}), profiles, init, callerClientConfig);
|
|
31048
31048
|
};
|
|
31049
31049
|
var init_fromIni = __esm(() => {
|
|
31050
31050
|
init_resolveProfileData();
|
|
31051
|
-
|
|
31051
|
+
import_config34 = __toESM(require_config(), 1);
|
|
31052
31052
|
});
|
|
31053
31053
|
|
|
31054
31054
|
// node_modules/@aws-sdk/credential-provider-ini/dist-es/index.js
|
|
@@ -31066,8 +31066,8 @@ import { Buffer as Buffer2 } from "buffer";
|
|
|
31066
31066
|
import { existsSync as existsSync22 } from "fs";
|
|
31067
31067
|
import { join as join210 } from "path";
|
|
31068
31068
|
import { existsSync as existsSync16 } from "fs";
|
|
31069
|
-
import { homedir as
|
|
31070
|
-
import { join as
|
|
31069
|
+
import { homedir as homedir8 } from "os";
|
|
31070
|
+
import { join as join36, resolve as resolve18 } 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";
|
|
@@ -31225,10 +31225,10 @@ function dataDir2(options) {
|
|
|
31225
31225
|
return pathsResolverResolve("data", options);
|
|
31226
31226
|
}
|
|
31227
31227
|
function effectiveHome2() {
|
|
31228
|
-
return process.env["HOME"] || process.env["USERPROFILE"] ||
|
|
31228
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir8();
|
|
31229
31229
|
}
|
|
31230
31230
|
function legacyHomeDir() {
|
|
31231
|
-
return
|
|
31231
|
+
return join36(effectiveHome2(), ".hasna", "events");
|
|
31232
31232
|
}
|
|
31233
31233
|
function resolverHome() {
|
|
31234
31234
|
return dataDir2({ app: "events", home: effectiveHome2() || undefined });
|
|
@@ -31237,7 +31237,7 @@ function adoptResolverHome(resolved, env = process.env) {
|
|
|
31237
31237
|
const dataOverride = env.HASNA_DATA_HOME;
|
|
31238
31238
|
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
31239
31239
|
return true;
|
|
31240
|
-
return existsSync16(
|
|
31240
|
+
return existsSync16(join36(resolved, EVENTS_STORE_SENTINEL_FILE));
|
|
31241
31241
|
}
|
|
31242
31242
|
function exactEventsHome() {
|
|
31243
31243
|
const dir = process.env[HASNA_EVENTS_DIR_ENV];
|
|
@@ -31251,9 +31251,9 @@ function exactEventsHome() {
|
|
|
31251
31251
|
function getEventsHome() {
|
|
31252
31252
|
const exact = exactEventsHome();
|
|
31253
31253
|
if (exact)
|
|
31254
|
-
return
|
|
31254
|
+
return resolve18(exact);
|
|
31255
31255
|
const resolved = resolverHome();
|
|
31256
|
-
return adoptResolverHome(resolved) ?
|
|
31256
|
+
return adoptResolverHome(resolved) ? resolve18(resolved) : resolve18(legacyHomeDir());
|
|
31257
31257
|
}
|
|
31258
31258
|
function getEventsDataDir(override) {
|
|
31259
31259
|
return override || getEventsHome();
|
|
@@ -32373,7 +32373,7 @@ var init_event_sink = __esm(() => {
|
|
|
32373
32373
|
// package.json
|
|
32374
32374
|
var package_default = {
|
|
32375
32375
|
name: "@hasna/skills",
|
|
32376
|
-
version: "0.9.
|
|
32376
|
+
version: "0.9.12",
|
|
32377
32377
|
description: "Skills library for AI coding agents",
|
|
32378
32378
|
type: "module",
|
|
32379
32379
|
bin: {
|
|
@@ -37210,10 +37210,10 @@ async function reconcileSkillSession(input, options = {}) {
|
|
|
37210
37210
|
return { applied: true, plan, planDigest, ...result };
|
|
37211
37211
|
}
|
|
37212
37212
|
// src/lib/selected-run.ts
|
|
37213
|
-
import { createHash as
|
|
37213
|
+
import { createHash as createHash18 } from "crypto";
|
|
37214
37214
|
import { spawn } from "child_process";
|
|
37215
|
-
import { mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, writeFileSync as
|
|
37216
|
-
import { dirname as
|
|
37215
|
+
import { mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, writeFileSync as writeFileSync9, realpathSync as realpathSync8 } from "fs";
|
|
37216
|
+
import { dirname as dirname19, join as join31, resolve as resolve17 } from "path";
|
|
37217
37217
|
import { tmpdir, hostname as stationHostname2 } from "os";
|
|
37218
37218
|
|
|
37219
37219
|
// src/lib/dependency-preparation.ts
|
|
@@ -37425,18 +37425,18 @@ async function prepareSkillDependencies(skillPath, env, timeoutMs = DEFAULT_PREP
|
|
|
37425
37425
|
|
|
37426
37426
|
// src/lib/skillinfo.ts
|
|
37427
37427
|
import { existsSync as existsSync14, readFileSync as readFileSync20 } from "fs";
|
|
37428
|
-
import { join as
|
|
37428
|
+
import { join as join30 } from "path";
|
|
37429
37429
|
|
|
37430
37430
|
// src/lib/installer.ts
|
|
37431
37431
|
import { existsSync as existsSync13, readFileSync as readFileSync19, rmSync as rmSync4 } from "fs";
|
|
37432
|
-
import { join as
|
|
37433
|
-
import { homedir as
|
|
37432
|
+
import { join as join29 } from "path";
|
|
37433
|
+
import { homedir as homedir6 } from "os";
|
|
37434
37434
|
|
|
37435
37435
|
// src/lib/agent-sync.ts
|
|
37436
37436
|
import {
|
|
37437
37437
|
cpSync as cpSync2,
|
|
37438
37438
|
existsSync as existsSync10,
|
|
37439
|
-
lstatSync as
|
|
37439
|
+
lstatSync as lstatSync21,
|
|
37440
37440
|
mkdirSync as mkdirSync8,
|
|
37441
37441
|
mkdtempSync as mkdtempSync2,
|
|
37442
37442
|
readFileSync as readFileSync16,
|
|
@@ -37444,15 +37444,34 @@ import {
|
|
|
37444
37444
|
renameSync as renameSync5,
|
|
37445
37445
|
rmSync as rmSync3,
|
|
37446
37446
|
statSync as statSync9,
|
|
37447
|
-
writeFileSync as
|
|
37447
|
+
writeFileSync as writeFileSync7
|
|
37448
37448
|
} from "fs";
|
|
37449
|
-
import { homedir as
|
|
37450
|
-
import { basename as
|
|
37449
|
+
import { homedir as homedir5 } from "os";
|
|
37450
|
+
import { basename as basename10, dirname as dirname18, join as join26 } from "path";
|
|
37451
|
+
|
|
37452
|
+
// src/lib/native-discovery-roots.ts
|
|
37453
|
+
var NATIVE_SKILL_ROOTS = [
|
|
37454
|
+
["claude", ".claude/skills"],
|
|
37455
|
+
["codex", ".codex/skills"],
|
|
37456
|
+
["codex", ".agents/skills"],
|
|
37457
|
+
["gemini", ".gemini/skills"],
|
|
37458
|
+
["codewith", ".codewith/skills"],
|
|
37459
|
+
["opencode", ".config/opencode/skills"],
|
|
37460
|
+
["opencode", ".opencode/skills"],
|
|
37461
|
+
["cursor", ".cursor/skills"],
|
|
37462
|
+
["hermes", ".hermes/skills"],
|
|
37463
|
+
["windsurf", ".windsurf/skills"],
|
|
37464
|
+
["pi", ".pi/agent/skills"],
|
|
37465
|
+
["amp", ".amp/skills"],
|
|
37466
|
+
["cline", ".cline/skills"],
|
|
37467
|
+
["roo", ".roo/skills"],
|
|
37468
|
+
["copilot", ".github/skills"]
|
|
37469
|
+
];
|
|
37451
37470
|
|
|
37452
37471
|
// src/lib/agent-integration.ts
|
|
37453
|
-
import { createHash as
|
|
37454
|
-
import { existsSync as existsSync6, lstatSync as
|
|
37455
|
-
import { dirname as
|
|
37472
|
+
import { createHash as createHash16, randomUUID as randomUUID3 } from "crypto";
|
|
37473
|
+
import { existsSync as existsSync6, lstatSync as lstatSync18, 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 writeFileSync4, unlinkSync as unlinkSync4, chmodSync, openSync as openSync16, closeSync as closeSync16, fsyncSync as fsyncSync4, fstatSync as fstatSync16, readSync as readSync11, constants as constants12, linkSync as linkSync2 } from "fs";
|
|
37474
|
+
import { dirname as dirname14, join as join21, resolve as resolve14, relative as relative3, isAbsolute as isAbsolute15, sep as sep4 } from "path";
|
|
37456
37475
|
import { homedir as homedir3 } from "os";
|
|
37457
37476
|
|
|
37458
37477
|
// src/lib/managed-policy.ts
|
|
@@ -37682,9 +37701,9 @@ function isOwnedCliBridge(path, expectedPaths) {
|
|
|
37682
37701
|
}
|
|
37683
37702
|
|
|
37684
37703
|
// src/lib/agent-discovery.ts
|
|
37685
|
-
import { createHash as
|
|
37686
|
-
import { lstatSync as
|
|
37687
|
-
import { basename as basename6, dirname as
|
|
37704
|
+
import { createHash as createHash15 } from "crypto";
|
|
37705
|
+
import { lstatSync as lstatSync17, readFileSync as readFileSync12, readdirSync as readdirSync6, realpathSync as realpathSync3 } from "fs";
|
|
37706
|
+
import { basename as basename6, dirname as dirname13, isAbsolute as isAbsolute14, join as join20, resolve as resolve13, sep as sep3 } from "path";
|
|
37688
37707
|
|
|
37689
37708
|
// node_modules/yaml/dist/index.js
|
|
37690
37709
|
var composer = require_composer();
|
|
@@ -37812,6 +37831,48 @@ function assertHermesEnvironment(home) {
|
|
|
37812
37831
|
if (process.env.HERMES_ENABLE_PROJECT_PLUGINS?.trim() && !["0", "false", "no", "off"].includes(process.env.HERMES_ENABLE_PROJECT_PLUGINS.trim().toLowerCase()))
|
|
37813
37832
|
throw new Error("NATIVE_SKILL_DRIFT: Hermes project plugins require a dedicated discovery review");
|
|
37814
37833
|
}
|
|
37834
|
+
function read(path) {
|
|
37835
|
+
for (let current = path;; current = dirname4(current)) {
|
|
37836
|
+
if (lstatSync7(current, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
37837
|
+
throw new Error("NATIVE_SKILL_DRIFT: symlink Hermes protection input");
|
|
37838
|
+
if (dirname4(current) === current)
|
|
37839
|
+
break;
|
|
37840
|
+
}
|
|
37841
|
+
const stat = lstatSync7(path, { throwIfNoEntry: false });
|
|
37842
|
+
if (!stat)
|
|
37843
|
+
return null;
|
|
37844
|
+
if (!stat.isFile() || stat.size > 1024 * 1024)
|
|
37845
|
+
throw new Error("NATIVE_SKILL_DRIFT: invalid Hermes protection input");
|
|
37846
|
+
return readFileSync9(path, "utf8");
|
|
37847
|
+
}
|
|
37848
|
+
function assertHermesProtection(home, config, command, profile, supervisor) {
|
|
37849
|
+
assertHermesEnvironment(home);
|
|
37850
|
+
if (read(join12(home, ".hermes", HERMES_OPT_OUT)) === null)
|
|
37851
|
+
throw new Error("NATIVE_SKILL_DRIFT: Hermes bundled skill reseeding is not disabled; run skills hook install");
|
|
37852
|
+
if (!supervisor || !isAbsolute4(supervisor.path) || supervisor.runtime !== process.execPath || read(supervisor.path) !== renderHermesSupervisor(command, profile))
|
|
37853
|
+
throw new Error("NATIVE_SKILL_DRIFT: Hermes owned supervisor changed; run skills hook install");
|
|
37854
|
+
const raw = read(join12(home, ".hermes/shell-hooks-allowlist.json"));
|
|
37855
|
+
let trust;
|
|
37856
|
+
try {
|
|
37857
|
+
trust = raw === null ? undefined : JSON.parse(raw);
|
|
37858
|
+
} catch {
|
|
37859
|
+
throw new Error("NATIVE_SKILL_DRIFT: invalid Hermes native hook trust");
|
|
37860
|
+
}
|
|
37861
|
+
for (const [event, entry] of Object.entries(hermesHookDefinitions(supervisor))) {
|
|
37862
|
+
if (!Array.isArray(config.hooks?.[event]) || config.hooks[event].filter((actual) => sameEntry(actual, entry)).length !== 1)
|
|
37863
|
+
throw new Error("NATIVE_SKILL_DRIFT: Hermes required native hooks changed; run skills hook install");
|
|
37864
|
+
if (!Array.isArray(trust?.approvals) || !trust.approvals.some((approval) => object3(approval) && approval.event === event && approval.command === entry.command))
|
|
37865
|
+
throw new Error("NATIVE_SKILL_DRIFT: approve the exact managed commands through Hermes normal native hook trust before starting a session");
|
|
37866
|
+
}
|
|
37867
|
+
if (config.skills?.platform_disabled !== undefined && !object3(config.skills.platform_disabled))
|
|
37868
|
+
throw new Error("NATIVE_SKILL_DRIFT: malformed Hermes platform skill settings");
|
|
37869
|
+
const disabled = config.skills?.disabled;
|
|
37870
|
+
if (disabled !== undefined && (!Array.isArray(disabled) || disabled.some((value) => typeof value !== "string") || disabled.includes("skills-cli")))
|
|
37871
|
+
throw new Error("NATIVE_SKILL_DRIFT: Hermes Skills CLI bridge is disabled or its names are malformed");
|
|
37872
|
+
for (const names of Object.values(config.skills?.platform_disabled ?? {}))
|
|
37873
|
+
if (!Array.isArray(names) || names.some((value) => typeof value !== "string") || names.includes("skills-cli"))
|
|
37874
|
+
throw new Error("NATIVE_SKILL_DRIFT: a Hermes platform disables the Skills CLI bridge");
|
|
37875
|
+
}
|
|
37815
37876
|
function assertNoHermesLegacyShadow(root) {
|
|
37816
37877
|
let entries = 0;
|
|
37817
37878
|
for (let cursor = resolve4(root);; cursor = dirname4(cursor)) {
|
|
@@ -40054,6 +40115,27 @@ function canonical3(value) {
|
|
|
40054
40115
|
return { kind: "array", items: value.items.map(canonical3) };
|
|
40055
40116
|
return value;
|
|
40056
40117
|
}
|
|
40118
|
+
function assertClaudeStopHookReplacement(before, replacement) {
|
|
40119
|
+
function bounded(text2) {
|
|
40120
|
+
need3(typeof text2 === "string" && Buffer.byteLength(text2) <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes, "Stop update exceeds its byte limit");
|
|
40121
|
+
return parse6(text2);
|
|
40122
|
+
}
|
|
40123
|
+
const original = bounded(before ?? "{}"), next = bounded(replacement);
|
|
40124
|
+
const hadHooks = original.entries.some(([key]) => key === "hooks");
|
|
40125
|
+
function withoutStop(value) {
|
|
40126
|
+
const hooks = value.entries.find(([key]) => key === "hooks")?.[1];
|
|
40127
|
+
if (hooks !== undefined) {
|
|
40128
|
+
need3(hooks.kind === "object", "Stop update requires an object of hooks");
|
|
40129
|
+
const stop = hooks.entries.find(([key]) => key === "Stop")?.[1];
|
|
40130
|
+
need3(stop === undefined || stop.kind === "array", "Stop update requires a Stop array");
|
|
40131
|
+
hooks.entries = hooks.entries.filter(([key]) => key !== "Stop");
|
|
40132
|
+
if (!hadHooks && hooks.entries.length === 0)
|
|
40133
|
+
value.entries = value.entries.filter(([key]) => key !== "hooks");
|
|
40134
|
+
}
|
|
40135
|
+
return canonical3(value);
|
|
40136
|
+
}
|
|
40137
|
+
need3(JSON.stringify(withoutStop(original)) === JSON.stringify(withoutStop(next)), "Stop update changed settings outside hooks.Stop");
|
|
40138
|
+
}
|
|
40057
40139
|
function settingsDigest(text2) {
|
|
40058
40140
|
const value = parse6(text2);
|
|
40059
40141
|
value.entries = value.entries.filter(([key, child]) => {
|
|
@@ -40084,8 +40166,76 @@ function captureClaudeSettings(path, budget = { remaining: 256 * 1024 * 1024 })
|
|
|
40084
40166
|
return { path, hashMode: "claude-settings-v1", sha256: settingsDigest(readSettings(path, budget)) };
|
|
40085
40167
|
}
|
|
40086
40168
|
|
|
40169
|
+
// src/lib/codex-hook-discovery-recovery.ts
|
|
40170
|
+
import { createHash as createHash14 } from "crypto";
|
|
40171
|
+
|
|
40172
|
+
// src/lib/codex-hook-trust-files.ts
|
|
40173
|
+
import { closeSync as closeSync15, constants as constants11, fstatSync as fstatSync15, fsyncSync as fsyncSync3, lstatSync as lstatSync16, openSync as openSync15, readSync as readSync10, writeFileSync as writeFileSync3 } from "fs";
|
|
40174
|
+
import { createHash as createHash13 } from "crypto";
|
|
40175
|
+
import { dirname as dirname12 } from "path";
|
|
40176
|
+
function need4(value, code) {
|
|
40177
|
+
if (!value)
|
|
40178
|
+
throw new Error(`CODEX_HOOK_TRUST_${code}`);
|
|
40179
|
+
}
|
|
40180
|
+
var sameStat = (a, b) => ["dev", "ino", "uid", "nlink", "mode", "size", "mtimeNs", "ctimeNs"].every((key) => a[key] === b[key]);
|
|
40181
|
+
function safeParents(file) {
|
|
40182
|
+
for (let p = dirname12(file);; p = dirname12(p)) {
|
|
40183
|
+
const s = lstatSync16(p);
|
|
40184
|
+
need4(s.isDirectory() && !s.isSymbolicLink(), "UNSAFE_PARENT");
|
|
40185
|
+
need4((s.mode & 18) === 0 || s.uid === 0 && (s.mode & 512) !== 0, "UNSAFE_PARENT");
|
|
40186
|
+
if (dirname12(p) === p)
|
|
40187
|
+
break;
|
|
40188
|
+
}
|
|
40189
|
+
}
|
|
40190
|
+
function snapshot(file, privateFile = false, options = {}) {
|
|
40191
|
+
const readOnlyPackage = options.readOnlyPackage === true && !privateFile;
|
|
40192
|
+
safeParents(file);
|
|
40193
|
+
const initial = lstatSync16(file, { bigint: true });
|
|
40194
|
+
need4(initial.isFile() && initial.uid === BigInt(process.getuid()) && (initial.nlink === 1n || readOnlyPackage && initial.nlink > 1n) && (initial.mode & 0o022n) === 0n && (!privateFile || (initial.mode & 0o777n) === 0o600n), "UNSAFE_FILE");
|
|
40195
|
+
need4(initial.size <= 8n * 1024n * 1024n, "FILE_BOUND");
|
|
40196
|
+
const fd = openSync15(file, constants11.O_RDONLY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
|
|
40197
|
+
try {
|
|
40198
|
+
const before = fstatSync15(fd, { bigint: true });
|
|
40199
|
+
need4(sameStat(initial, before), "INPUT_CHANGED");
|
|
40200
|
+
const bytes = Buffer.alloc(Number(before.size) + 1);
|
|
40201
|
+
let length = 0;
|
|
40202
|
+
while (length < bytes.length) {
|
|
40203
|
+
const n2 = readSync10(fd, bytes, length, bytes.length - length, null);
|
|
40204
|
+
if (!n2)
|
|
40205
|
+
break;
|
|
40206
|
+
length += n2;
|
|
40207
|
+
}
|
|
40208
|
+
need4(length === Number(before.size) && sameStat(before, fstatSync15(fd, { bigint: true })) && sameStat(before, lstatSync16(file, { bigint: true })), "INPUT_CHANGED");
|
|
40209
|
+
const content = bytes.subarray(0, length), text2 = new TextDecoder("utf-8", { fatal: true }).decode(content);
|
|
40210
|
+
return { file, privateFile, readOnlyPackage, text: text2, bytes: content, stat: before, sha256: createHash13("sha256").update(content).digest("hex") };
|
|
40211
|
+
} finally {
|
|
40212
|
+
closeSync15(fd);
|
|
40213
|
+
}
|
|
40214
|
+
}
|
|
40215
|
+
function unchanged2(before) {
|
|
40216
|
+
const after = snapshot(before.file, before.privateFile, before.readOnlyPackage ? { readOnlyPackage: true } : {});
|
|
40217
|
+
need4(sameStat(before.stat, after.stat) && after.sha256 === before.sha256, "INPUT_CHANGED");
|
|
40218
|
+
}
|
|
40219
|
+
|
|
40220
|
+
// src/lib/codex-hook-discovery-recovery.ts
|
|
40221
|
+
var sha = (text2) => createHash14("sha256").update(text2).digest("hex");
|
|
40222
|
+
var proofs = new WeakMap;
|
|
40223
|
+
function assertCodexHookDiscoveryRecovery(binding, witness) {
|
|
40224
|
+
const proof = proofs.get(witness);
|
|
40225
|
+
need4(!!proof && binding.agent === "codex" && witness.discoverySha256 === sha(JSON.stringify(binding)), "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
|
|
40226
|
+
unchanged2(proof.before);
|
|
40227
|
+
unchanged2(proof.current);
|
|
40228
|
+
}
|
|
40229
|
+
function verifiesCodexHookDiscoverySource(binding, source, currentDigest, witness) {
|
|
40230
|
+
if (!witness || source.path !== witness.configPath || source.hashMode !== "bytes")
|
|
40231
|
+
return false;
|
|
40232
|
+
assertCodexHookDiscoveryRecovery(binding, witness);
|
|
40233
|
+
need4(source.sha256 === witness.beforeSha256 && currentDigest === witness.currentSha256, "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
|
|
40234
|
+
return true;
|
|
40235
|
+
}
|
|
40236
|
+
|
|
40087
40237
|
// src/lib/agent-discovery.ts
|
|
40088
|
-
var digest2 = (text2) =>
|
|
40238
|
+
var digest2 = (text2) => createHash15("sha256").update(text2).digest("hex");
|
|
40089
40239
|
function parseConfig(text2, path, toml = false) {
|
|
40090
40240
|
try {
|
|
40091
40241
|
const value = toml ? Bun.TOML.parse(text2) : JSON.parse(text2);
|
|
@@ -40099,18 +40249,18 @@ function parseConfig(text2, path, toml = false) {
|
|
|
40099
40249
|
function safe4(path) {
|
|
40100
40250
|
if (!isAbsolute14(path) || path.includes("\x00"))
|
|
40101
40251
|
throw new Error("Expected an absolute native discovery path");
|
|
40102
|
-
for (let cursor = path;; cursor =
|
|
40103
|
-
if (
|
|
40252
|
+
for (let cursor = path;; cursor = dirname13(cursor)) {
|
|
40253
|
+
if (lstatSync17(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
40104
40254
|
throw new Error(`Refusing symlink native discovery input: ${cursor}`);
|
|
40105
|
-
if (
|
|
40255
|
+
if (dirname13(cursor) === cursor)
|
|
40106
40256
|
break;
|
|
40107
40257
|
}
|
|
40108
40258
|
}
|
|
40109
|
-
function
|
|
40259
|
+
function read2(path, changes) {
|
|
40110
40260
|
safe4(path);
|
|
40111
40261
|
if (changes?.has(path))
|
|
40112
40262
|
return changes.get(path);
|
|
40113
|
-
const stat2 =
|
|
40263
|
+
const stat2 = lstatSync17(path, { throwIfNoEntry: false });
|
|
40114
40264
|
if (!stat2)
|
|
40115
40265
|
return null;
|
|
40116
40266
|
if (!stat2.isFile() || stat2.size > 16 * 1024 * 1024)
|
|
@@ -40150,7 +40300,7 @@ function projected(source, changes, budget = discoveryByteBudget()) {
|
|
|
40150
40300
|
return hashDiscoveryPathFile(source.path, budget, changes);
|
|
40151
40301
|
return hashRawDiscoveryFile(source.path, budget, changes);
|
|
40152
40302
|
}
|
|
40153
|
-
const text2 =
|
|
40303
|
+
const text2 = read2(source.path, changes);
|
|
40154
40304
|
if (text2 === null)
|
|
40155
40305
|
return null;
|
|
40156
40306
|
if (!source.format)
|
|
@@ -40160,7 +40310,9 @@ function projected(source, changes, budget = discoveryByteBudget()) {
|
|
|
40160
40310
|
throw new Error("Expected native discovery configuration object");
|
|
40161
40311
|
return digest2(JSON.stringify(Object.fromEntries((source.fields ?? []).map((field2) => [field2, object4[field2] ?? null]))));
|
|
40162
40312
|
}
|
|
40163
|
-
function verifyAgentDiscovery(binding) {
|
|
40313
|
+
function verifyAgentDiscovery(binding, codexRecovery) {
|
|
40314
|
+
if (codexRecovery)
|
|
40315
|
+
assertCodexHookDiscoveryRecovery(binding, codexRecovery);
|
|
40164
40316
|
if (!binding || !Array.isArray(binding.sources) || !Array.isArray(binding.roots) || binding.sources.length > AGENT_POLICY_LIMITS.discoverySources || binding.roots.length > AGENT_POLICY_LIMITS.discoveryRoots)
|
|
40165
40317
|
throw new Error("Invalid native discovery binding");
|
|
40166
40318
|
if (binding.agent === "hermes" && !binding.directories?.length)
|
|
@@ -40176,7 +40328,8 @@ function verifyAgentDiscovery(binding) {
|
|
|
40176
40328
|
throw new Error("Invalid native discovery projection");
|
|
40177
40329
|
if (source.sha256 !== null && !/^[a-f0-9]{64}$/.test(source.sha256))
|
|
40178
40330
|
throw new Error("Invalid native discovery digest");
|
|
40179
|
-
|
|
40331
|
+
const current = projected(source, undefined, budget);
|
|
40332
|
+
if (current !== source.sha256 && !verifiesCodexHookDiscoverySource(binding, source, current, codexRecovery))
|
|
40180
40333
|
throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
|
|
40181
40334
|
}
|
|
40182
40335
|
for (const root2 of binding.roots)
|
|
@@ -40207,6 +40360,49 @@ function captureDiscoveryPathSources(paths) {
|
|
|
40207
40360
|
const budget = discoveryByteBudget();
|
|
40208
40361
|
return paths.map((path) => ({ path, hashMode: "path-bytes", sha256: hashDiscoveryPathFile(path, budget) }));
|
|
40209
40362
|
}
|
|
40363
|
+
function assertProjectDiscovery(agent, directories, home, canonical4 = resolve13, reviewed) {
|
|
40364
|
+
for (const directory of directories) {
|
|
40365
|
+
const isHome = resolve13(directory) === resolve13(home);
|
|
40366
|
+
if (agent === "hermes") {
|
|
40367
|
+
assertHermesEnvironment(home);
|
|
40368
|
+
continue;
|
|
40369
|
+
}
|
|
40370
|
+
if (isHome && agent !== "claude")
|
|
40371
|
+
continue;
|
|
40372
|
+
const paths = agent === "claude" ? [...isHome ? [] : [".claude/settings.json"], ".claude/settings.local.json"] : agent === "codex" ? [".codex/config.toml"] : agent === "gemini" ? [".gemini/settings.json"] : agent === "opencode" ? ["opencode.json", "opencode.jsonc", ".opencode/opencode.json", ".opencode/opencode.jsonc"] : [".cursor/hooks.json"];
|
|
40373
|
+
for (const suffix of paths) {
|
|
40374
|
+
const path = canonical4(join20(directory, suffix)), raw = read2(path);
|
|
40375
|
+
if (raw === null)
|
|
40376
|
+
continue;
|
|
40377
|
+
if (agent === "claude" && suffix === ".claude/settings.json" && path === canonical4(join20(home, suffix)))
|
|
40378
|
+
continue;
|
|
40379
|
+
if (suffix.endsWith(".jsonc"))
|
|
40380
|
+
throw new Error(`NATIVE_SKILL_DRIFT: project JSONC discovery configuration requires review: ${path}`);
|
|
40381
|
+
const config = parseConfig(raw, path, suffix.endsWith(".toml"));
|
|
40382
|
+
const keys2 = agent === "claude" ? ["enabledPlugins", "extraKnownMarketplaces", "skillOverrides"] : agent === "codex" ? ["plugins", "marketplaces", "skills"] : agent === "gemini" ? ["skills", "extensions"] : agent === "opencode" ? ["plugin", "skills"] : ["hooks"];
|
|
40383
|
+
let admittedPlugins = false;
|
|
40384
|
+
if (agent === "claude" && reviewed?.agent === agent && reviewed.method === "reviewed" && config.enabledPlugins && typeof config.enabledPlugins === "object" && !Array.isArray(config.enabledPlugins)) {
|
|
40385
|
+
const exact = reviewed.sources.find((source) => source.path === path && source.format === undefined && source.fields === undefined && (source.hashMode === undefined || source.hashMode === "bytes"));
|
|
40386
|
+
const managed = reviewed.sources.flatMap((source) => source.hashMode === "claude-plugin-registry" ? source.managedPlugins ?? [] : []);
|
|
40387
|
+
if (exact && projected(exact) === exact.sha256 && managed.length) {
|
|
40388
|
+
const bindings = managed.map((item) => readPluginBinding(item.storeRoot, item.bindingId));
|
|
40389
|
+
admittedPlugins = Object.entries(config.enabledPlugins).every(([id2, enabled]) => typeof enabled === "boolean" && bindings.some((binding) => binding.target.pluginId === id2 && binding.target.registrations.some((scope) => scope.scope === "project" && scope.projectPath === canonical4(directory))));
|
|
40390
|
+
}
|
|
40391
|
+
}
|
|
40392
|
+
if (keys2.some((key) => config[key] !== undefined && !(key === "enabledPlugins" && admittedPlugins)) || config.disableAllHooks === true || config.disableBundledSkills === false || config.hooksConfig?.enabled === false || config.permission?.skill !== undefined || config.permissions?.deny?.some((rule) => typeof rule === "string" && /^Skill(?:\(|$)/.test(rule)))
|
|
40393
|
+
throw new Error(`NATIVE_SKILL_DRIFT: higher-precedence project skill or hook configuration requires review: ${path}`);
|
|
40394
|
+
}
|
|
40395
|
+
if (agent === "claude") {
|
|
40396
|
+
const commands = canonical4(join20(directory, ".claude/commands"));
|
|
40397
|
+
safe4(commands);
|
|
40398
|
+
if (lstatSync17(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync6(commands).length)
|
|
40399
|
+
throw new Error("NATIVE_SKILL_DRIFT: legacy project command discovery requires a dedicated format adapter");
|
|
40400
|
+
}
|
|
40401
|
+
}
|
|
40402
|
+
}
|
|
40403
|
+
function agentDiscoveryConfigPath(home, agent) {
|
|
40404
|
+
return join20(home, agent === "hermes" ? ".hermes/config.yaml" : agent === "opencode" ? ".config/opencode/opencode.json" : `.${agent}/${agent === "codex" ? "config.toml" : agent === "cursor" ? "hooks.json" : "settings.json"}`);
|
|
40405
|
+
}
|
|
40210
40406
|
function resolveAgentDiscovery(options) {
|
|
40211
40407
|
const canonical4 = options.canonical ?? resolve13, home = resolve13(options.home), agent = options.agent;
|
|
40212
40408
|
const sources = [], roots = new Set, builtinNames = [];
|
|
@@ -40214,11 +40410,11 @@ function resolveAgentDiscovery(options) {
|
|
|
40214
40410
|
const source = { path: canonical4(path), sha256: null, ...format ? { format, fields } : {} };
|
|
40215
40411
|
source.sha256 = projected(source);
|
|
40216
40412
|
sources.push(source);
|
|
40217
|
-
return
|
|
40413
|
+
return read2(source.path);
|
|
40218
40414
|
};
|
|
40219
40415
|
if (agent === "hermes")
|
|
40220
40416
|
assertHermesEnvironment(home);
|
|
40221
|
-
const configPath =
|
|
40417
|
+
const configPath = agentDiscoveryConfigPath(home, agent);
|
|
40222
40418
|
const configText = witness(configPath, agent === "hermes" ? "yaml" : agent === "codex" ? "toml" : "json", agent === "hermes" ? ["skills", "plugins", "hooks"] : agent === "claude" ? ["enabledPlugins", "extraKnownMarketplaces"] : agent === "codex" ? ["plugins", "marketplaces", "skills"] : agent === "gemini" ? ["skills", "extensions", "security"] : agent === "opencode" ? ["plugin", "skills"] : ["version"]);
|
|
40223
40419
|
const config = configText === null ? {} : agent === "hermes" ? parseHermesConfig(configText) : parseConfig(configText, configPath, agent === "codex");
|
|
40224
40420
|
const unresolved = (detail) => {
|
|
@@ -40248,21 +40444,21 @@ function resolveAgentDiscovery(options) {
|
|
|
40248
40444
|
const executable = Bun.which("gemini");
|
|
40249
40445
|
if (executable) {
|
|
40250
40446
|
let packageRoot;
|
|
40251
|
-
for (let directory =
|
|
40252
|
-
const path = join20(directory, "package.json"), raw =
|
|
40447
|
+
for (let directory = dirname13(realpathSync3(executable)), depth = 0;depth < 8; directory = dirname13(directory), depth++) {
|
|
40448
|
+
const path = join20(directory, "package.json"), raw = read2(path);
|
|
40253
40449
|
if (raw !== null && parseConfig(raw, path).name === "@google/gemini-cli") {
|
|
40254
40450
|
packageRoot = directory;
|
|
40255
40451
|
witness(path);
|
|
40256
40452
|
break;
|
|
40257
40453
|
}
|
|
40258
|
-
if (
|
|
40454
|
+
if (dirname13(directory) === directory)
|
|
40259
40455
|
break;
|
|
40260
40456
|
}
|
|
40261
40457
|
if (!packageRoot)
|
|
40262
40458
|
unresolved("installed Gemini package layout is not recognized");
|
|
40263
40459
|
const builtinRoot = join20(packageRoot, "bundle/builtin");
|
|
40264
40460
|
safe4(builtinRoot);
|
|
40265
|
-
if (!
|
|
40461
|
+
if (!lstatSync17(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
|
|
40266
40462
|
unresolved("installed Gemini builtin root is missing");
|
|
40267
40463
|
for (const name of readdirSync6(builtinRoot).sort()) {
|
|
40268
40464
|
const text2 = witness(join20(builtinRoot, name, "SKILL.md"));
|
|
@@ -40302,7 +40498,7 @@ function resolveAgentDiscovery(options) {
|
|
|
40302
40498
|
unresolved("plugin hooks require a separate no-skill-injection review");
|
|
40303
40499
|
const commands = join20(root2, "commands");
|
|
40304
40500
|
safe4(commands);
|
|
40305
|
-
if (agent === "claude" && (manifest.commands !== undefined ||
|
|
40501
|
+
if (agent === "claude" && (manifest.commands !== undefined || lstatSync17(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync6(commands).length))
|
|
40306
40502
|
unresolved("legacy command discovery requires retirement or a dedicated format adapter");
|
|
40307
40503
|
const rootSkill = witness(join20(root2, "SKILL.md"));
|
|
40308
40504
|
if (rootSkill !== null)
|
|
@@ -40316,7 +40512,7 @@ function resolveAgentDiscovery(options) {
|
|
|
40316
40512
|
const path = resolve13(root2, value);
|
|
40317
40513
|
if (path !== root2 && !path.startsWith(root2 + sep3))
|
|
40318
40514
|
unresolved("plugin skill path escapes its root");
|
|
40319
|
-
roots.add(path.endsWith(`${sep3}SKILL.md`) ?
|
|
40515
|
+
roots.add(path.endsWith(`${sep3}SKILL.md`) ? dirname13(path) : path);
|
|
40320
40516
|
}
|
|
40321
40517
|
}
|
|
40322
40518
|
if (agent === "claude") {
|
|
@@ -40324,7 +40520,7 @@ function resolveAgentDiscovery(options) {
|
|
|
40324
40520
|
const installed = registrations === null ? {} : parseConfig(registrations, join20(home, ".claude/plugins/installed_plugins.json")).plugins;
|
|
40325
40521
|
const commands = canonical4(join20(home, ".claude/commands"));
|
|
40326
40522
|
safe4(commands);
|
|
40327
|
-
if (
|
|
40523
|
+
if (lstatSync17(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync6(commands).length)
|
|
40328
40524
|
unresolved("legacy home command discovery requires a dedicated format adapter");
|
|
40329
40525
|
for (const [id2, enabled] of Object.entries(config.enabledPlugins ?? {})) {
|
|
40330
40526
|
if (enabled === false)
|
|
@@ -40366,12 +40562,12 @@ function resolveAgentDiscovery(options) {
|
|
|
40366
40562
|
}
|
|
40367
40563
|
const localPlugins = join20(home, ".config/opencode/plugins");
|
|
40368
40564
|
safe4(localPlugins);
|
|
40369
|
-
if (
|
|
40565
|
+
if (lstatSync17(localPlugins, { throwIfNoEntry: false }) && readdirSync6(localPlugins).some((name) => name !== "skills-cli.js"))
|
|
40370
40566
|
unresolved("additional local plugin hooks require review");
|
|
40371
40567
|
} else if (agent === "hermes") {
|
|
40372
40568
|
for (const directory of [join20(home, ".hermes/plugins"), join20(home, ".hermes/hermes-agent")]) {
|
|
40373
40569
|
safe4(directory);
|
|
40374
|
-
if (
|
|
40570
|
+
if (lstatSync17(directory, { throwIfNoEntry: false }))
|
|
40375
40571
|
unresolved("installed runtime/plugin discovery requires reviewed source bindings");
|
|
40376
40572
|
}
|
|
40377
40573
|
if (Bun.which("hermes") || Object.keys(config.plugins ?? {}).length)
|
|
@@ -40381,11 +40577,11 @@ function resolveAgentDiscovery(options) {
|
|
|
40381
40577
|
unresolved("custom extension or skill paths");
|
|
40382
40578
|
const directory = join20(home, ".gemini/extensions");
|
|
40383
40579
|
safe4(directory);
|
|
40384
|
-
if (
|
|
40580
|
+
if (lstatSync17(directory, { throwIfNoEntry: false }))
|
|
40385
40581
|
for (const name of readdirSync6(directory)) {
|
|
40386
40582
|
const root2 = join20(directory, name);
|
|
40387
40583
|
safe4(root2);
|
|
40388
|
-
if (!
|
|
40584
|
+
if (!lstatSync17(root2)?.isDirectory())
|
|
40389
40585
|
continue;
|
|
40390
40586
|
const raw = witness(join20(root2, "gemini-extension.json"));
|
|
40391
40587
|
if (raw === null)
|
|
@@ -40540,30 +40736,14 @@ function disableCodexBundledSkills(text2) {
|
|
|
40540
40736
|
}
|
|
40541
40737
|
|
|
40542
40738
|
// src/lib/agent-integration.ts
|
|
40543
|
-
var
|
|
40544
|
-
var ROOTS =
|
|
40545
|
-
["claude", ".claude/skills"],
|
|
40546
|
-
["codex", ".codex/skills"],
|
|
40547
|
-
["codex", ".agents/skills"],
|
|
40548
|
-
["gemini", ".gemini/skills"],
|
|
40549
|
-
["codewith", ".codewith/skills"],
|
|
40550
|
-
["opencode", ".config/opencode/skills"],
|
|
40551
|
-
["opencode", ".opencode/skills"],
|
|
40552
|
-
["cursor", ".cursor/skills"],
|
|
40553
|
-
["hermes", ".hermes/skills"],
|
|
40554
|
-
["windsurf", ".windsurf/skills"],
|
|
40555
|
-
["pi", ".pi/agent/skills"],
|
|
40556
|
-
["amp", ".amp/skills"],
|
|
40557
|
-
["cline", ".cline/skills"],
|
|
40558
|
-
["roo", ".roo/skills"],
|
|
40559
|
-
["copilot", ".github/skills"]
|
|
40560
|
-
];
|
|
40739
|
+
var sha2 = (data) => createHash16("sha256").update(data).digest("hex");
|
|
40740
|
+
var ROOTS = NATIVE_SKILL_ROOTS;
|
|
40561
40741
|
function assertSafePath(path) {
|
|
40562
40742
|
let cursor = resolve14(path);
|
|
40563
40743
|
while (true) {
|
|
40564
|
-
if (
|
|
40744
|
+
if (lstatSync18(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
40565
40745
|
throw new Error(`Refusing symlink path: ${cursor}`);
|
|
40566
|
-
const parent =
|
|
40746
|
+
const parent = dirname14(cursor);
|
|
40567
40747
|
if (parent === cursor)
|
|
40568
40748
|
return;
|
|
40569
40749
|
cursor = parent;
|
|
@@ -40572,12 +40752,12 @@ function assertSafePath(path) {
|
|
|
40572
40752
|
function readRootAlias(home, agent) {
|
|
40573
40753
|
assertSafePath(home);
|
|
40574
40754
|
const realHome = realpathSync4(home), alias = join21(realHome, `.${agent}`);
|
|
40575
|
-
const stat2 =
|
|
40755
|
+
const stat2 = lstatSync18(alias, { throwIfNoEntry: false, bigint: true });
|
|
40576
40756
|
if (!stat2?.isSymbolicLink())
|
|
40577
40757
|
throw new Error(`Agent root alias changed after planning: ${alias}`);
|
|
40578
|
-
const link = readlinkSync2(alias), targetPath = resolve14(
|
|
40758
|
+
const link = readlinkSync2(alias), targetPath = resolve14(dirname14(alias), link);
|
|
40579
40759
|
assertSafePath(targetPath);
|
|
40580
|
-
const targetStat =
|
|
40760
|
+
const targetStat = lstatSync18(targetPath, { throwIfNoEntry: false });
|
|
40581
40761
|
if (!targetStat?.isDirectory())
|
|
40582
40762
|
throw new Error(`Agent root alias must target an existing directory: ${alias}`);
|
|
40583
40763
|
const target = realpathSync4(targetPath), inside = relative3(realHome, target);
|
|
@@ -40590,7 +40770,7 @@ function rootAliases(home, allowed = false) {
|
|
|
40590
40770
|
return [];
|
|
40591
40771
|
const result = [];
|
|
40592
40772
|
for (const agent of ["claude", "codex"])
|
|
40593
|
-
if (
|
|
40773
|
+
if (lstatSync18(join21(home, `.${agent}`), { throwIfNoEntry: false })?.isSymbolicLink())
|
|
40594
40774
|
result.push(readRootAlias(home, agent));
|
|
40595
40775
|
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))))
|
|
40596
40776
|
throw new Error("Agent root alias targets must not overlap");
|
|
@@ -40611,35 +40791,35 @@ function recheckRootAliases(aliases) {
|
|
|
40611
40791
|
}
|
|
40612
40792
|
function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
|
|
40613
40793
|
assertSafePath(path);
|
|
40614
|
-
const before =
|
|
40794
|
+
const before = lstatSync18(path);
|
|
40615
40795
|
if (!before.isFile() || before.size > maximum)
|
|
40616
40796
|
throw new Error("Unsupported or oversized native skill file");
|
|
40617
|
-
const descriptor =
|
|
40797
|
+
const descriptor = openSync16(path, constants12.O_RDONLY | constants12.O_NOFOLLOW | constants12.O_NONBLOCK);
|
|
40618
40798
|
try {
|
|
40619
|
-
const opened =
|
|
40799
|
+
const opened = fstatSync16(descriptor);
|
|
40620
40800
|
if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino || opened.size !== before.size)
|
|
40621
40801
|
throw new Error("Native skill file changed while reading");
|
|
40622
40802
|
const bytes = Buffer.allocUnsafe(before.size + 1);
|
|
40623
40803
|
let length = 0;
|
|
40624
40804
|
while (length < bytes.length) {
|
|
40625
|
-
const count =
|
|
40805
|
+
const count = readSync11(descriptor, bytes, length, bytes.length - length, null);
|
|
40626
40806
|
if (!count)
|
|
40627
40807
|
break;
|
|
40628
40808
|
length += count;
|
|
40629
40809
|
}
|
|
40630
|
-
const after =
|
|
40810
|
+
const after = fstatSync16(descriptor);
|
|
40631
40811
|
if (length !== before.size || after.size !== before.size || after.mtimeMs !== opened.mtimeMs || after.ctimeMs !== opened.ctimeMs)
|
|
40632
40812
|
throw new Error("Native skill file changed while reading");
|
|
40633
40813
|
return bytes.subarray(0, length);
|
|
40634
40814
|
} finally {
|
|
40635
|
-
|
|
40815
|
+
closeSync16(descriptor);
|
|
40636
40816
|
}
|
|
40637
40817
|
}
|
|
40638
40818
|
function treeHash(root2) {
|
|
40639
|
-
const hash2 =
|
|
40819
|
+
const hash2 = createHash16("sha256");
|
|
40640
40820
|
let bytes = 0, files = 0;
|
|
40641
40821
|
function visit2(path) {
|
|
40642
|
-
const stat2 =
|
|
40822
|
+
const stat2 = lstatSync18(path);
|
|
40643
40823
|
if (stat2.isSymbolicLink())
|
|
40644
40824
|
throw new Error(`Refusing symlink in skill: ${path}`);
|
|
40645
40825
|
const rel = relative3(root2, path);
|
|
@@ -40669,7 +40849,7 @@ function selectNativeMigrationTargets(inventory, manifest) {
|
|
|
40669
40849
|
const selected = [];
|
|
40670
40850
|
for (const target of manifest.targets) {
|
|
40671
40851
|
const projectRoot = resolve14(target.projectRoot), normalized = relative3(projectRoot, resolve14(projectRoot, target.path));
|
|
40672
|
-
if (!isAbsolute15(target.projectRoot) || projectRoot !== target.projectRoot || !existsSync6(projectRoot) || !
|
|
40852
|
+
if (!isAbsolute15(target.projectRoot) || projectRoot !== target.projectRoot || !existsSync6(projectRoot) || !lstatSync18(projectRoot).isDirectory())
|
|
40673
40853
|
throw new Error(`Native migration target project root must be an existing absolute directory: ${target.projectRoot}`);
|
|
40674
40854
|
assertSafePath(projectRoot);
|
|
40675
40855
|
if (isAbsolute15(target.path) || target.path.includes("\\") || target.path.includes("\x00") || !normalized || normalized === ".." || normalized.startsWith(`..${sep4}`) || normalized !== target.path || !/^[0-9a-f]{64}$/.test(target.treeSha256))
|
|
@@ -40698,7 +40878,7 @@ function projectAncestorDirectories(projects) {
|
|
|
40698
40878
|
if (depth >= 100)
|
|
40699
40879
|
throw new Error("NATIVE_SKILL_DRIFT: project ancestor discovery limit exceeded");
|
|
40700
40880
|
directories.add(path);
|
|
40701
|
-
const parent =
|
|
40881
|
+
const parent = dirname14(path);
|
|
40702
40882
|
if (parent === path)
|
|
40703
40883
|
break;
|
|
40704
40884
|
path = parent;
|
|
@@ -40729,9 +40909,9 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40729
40909
|
}
|
|
40730
40910
|
function emptySiblingCacheAlias(path, parent) {
|
|
40731
40911
|
const link = readlinkSync2(path), target = resolve14(parent, link);
|
|
40732
|
-
if (
|
|
40912
|
+
if (dirname14(target) !== parent || (isAbsolute15(link) ? link !== target : dirname14(link) !== "."))
|
|
40733
40913
|
return false;
|
|
40734
|
-
if (!
|
|
40914
|
+
if (!lstatSync18(target, { throwIfNoEntry: false })?.isDirectory())
|
|
40735
40915
|
return false;
|
|
40736
40916
|
const scan = cacheScans.get(target);
|
|
40737
40917
|
return Boolean(scan?.complete && !scan.hasSkills && scan.entries <= maxAliasProofEntries);
|
|
@@ -40743,7 +40923,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40743
40923
|
assertSafePath(path);
|
|
40744
40924
|
if (!existsSync6(path))
|
|
40745
40925
|
return scan;
|
|
40746
|
-
const stat2 =
|
|
40926
|
+
const stat2 = lstatSync18(path);
|
|
40747
40927
|
if (stat2.isFile())
|
|
40748
40928
|
return scan;
|
|
40749
40929
|
if (!stat2.isDirectory())
|
|
@@ -40789,7 +40969,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
40789
40969
|
if (isVendor && !options.includeVendor)
|
|
40790
40970
|
continue;
|
|
40791
40971
|
const child = join21(path, name);
|
|
40792
|
-
if (isVendor &&
|
|
40972
|
+
if (isVendor && lstatSync18(child, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
40793
40973
|
const target = statSync5(child, { throwIfNoEntry: false });
|
|
40794
40974
|
if (target?.isFile() || pluginCache && target?.isDirectory() && emptySiblingCacheAlias(child, path)) {
|
|
40795
40975
|
scan.entries++;
|
|
@@ -40854,6 +41034,22 @@ function configureHooks(config, agent, command, profileId, nativeReady) {
|
|
|
40854
41034
|
if (!Array.isArray(existing))
|
|
40855
41035
|
throw new Error(`Expected ${event} hooks array`);
|
|
40856
41036
|
const hookCommand = renderAgentHookCommand(command, agent, profileId, event);
|
|
41037
|
+
if (agent === "codex") {
|
|
41038
|
+
let ownedIndex = -1;
|
|
41039
|
+
for (const [index, entry] of existing.entries()) {
|
|
41040
|
+
if (!entry || !Array.isArray(entry.hooks))
|
|
41041
|
+
throw new Error(`Malformed ${event} hook entry`);
|
|
41042
|
+
const owned = entry.hooks.filter((hook) => hook?.type === "command" && typeof hook.command === "string" && /(?:^|\s)hook user-prompt --agent codex(?: --selection-profile [A-Za-z0-9._-]+)?(?: --event [A-Za-z]+)?$/.test(hook.command));
|
|
41043
|
+
if (!owned.length)
|
|
41044
|
+
continue;
|
|
41045
|
+
if (ownedIndex !== -1 || entry.hooks.length !== 1 || Object.keys(entry).length !== 1)
|
|
41046
|
+
throw new Error(`Review ambiguous ${event} Codex Skills hook groups before installation; unrelated native hook positions must be preserved`);
|
|
41047
|
+
ownedIndex = index;
|
|
41048
|
+
}
|
|
41049
|
+
const replacement = { hooks: [{ type: "command", command: hookCommand, timeout: 15 }] };
|
|
41050
|
+
config.hooks[event] = ownedIndex === -1 ? [...existing, replacement] : existing.map((entry, index) => index === ownedIndex ? replacement : entry);
|
|
41051
|
+
continue;
|
|
41052
|
+
}
|
|
40857
41053
|
const retained = existing.flatMap((entry) => {
|
|
40858
41054
|
if (agent === "cursor") {
|
|
40859
41055
|
if (!entry || typeof entry.command !== "string")
|
|
@@ -40999,7 +41195,7 @@ function planAgentIntegration(options) {
|
|
|
40999
41195
|
throw new Error("Refusing to overwrite an unrecognized Hermes supervisor");
|
|
41000
41196
|
if (supervisorBefore !== supervisorAfter)
|
|
41001
41197
|
changes.push({ path: supervisorPath, before: supervisorBefore, after: supervisorAfter });
|
|
41002
|
-
const supervisor = { path: supervisorPath, runtime: process.execPath, sha256:
|
|
41198
|
+
const supervisor = { path: supervisorPath, runtime: process.execPath, sha256: sha2(supervisorAfter) };
|
|
41003
41199
|
const after2 = configureHermesHooks(before, supervisor, previous);
|
|
41004
41200
|
if (before !== after2)
|
|
41005
41201
|
changes.push({ path, before, after: after2 });
|
|
@@ -41046,7 +41242,7 @@ function planAgentIntegration(options) {
|
|
|
41046
41242
|
agents: [...new Set([...priorAgents, ...options.agents])].sort(),
|
|
41047
41243
|
home: resolve14(home),
|
|
41048
41244
|
includeVendor: true,
|
|
41049
|
-
...options.agents.includes("hermes") ? { supervisors: { ...policy.bridge?.supervisors, hermes: { path: join21(dataDir2, "agent-hooks", "hermes.js"), runtime: process.execPath, sha256:
|
|
41245
|
+
...options.agents.includes("hermes") ? { supervisors: { ...policy.bridge?.supervisors, hermes: { path: join21(dataDir2, "agent-hooks", "hermes.js"), runtime: process.execPath, sha256: sha2(renderHermesSupervisor(bindings.get("hermes").command, bindings.get("hermes").profileId)) } } } : {},
|
|
41050
41246
|
commands: { ...policy.bridge?.commands, ...Object.fromEntries([...bindings].map(([agent, binding]) => [agent, binding.command])) },
|
|
41051
41247
|
profiles: Object.fromEntries([...new Set([...priorAgents, ...options.agents])].sort().map((agent) => [agent, bindings.get(agent)?.profileId ?? policy.bridge?.profiles?.[agent] ?? policy.profileId])),
|
|
41052
41248
|
disabledBuiltins: options.agents.includes("codex") ? nativeSkills.filter((entry) => entry.agent === "codex" && entry.vendor && entry.path.startsWith(canonicalAgentPath(join21(home, ".codex", "skills", ".system"), aliases) + sep4)).map((entry) => ({ path: entry.path, hash: entry.hash })) : policy.bridge?.disabledBuiltins ?? [],
|
|
@@ -41059,12 +41255,68 @@ function planAgentIntegration(options) {
|
|
|
41059
41255
|
recheckRootAliases(aliases);
|
|
41060
41256
|
return { dataDir: dataDir2, profileId, changes, nativeSkills, observedPolicy: { path: policyPath, before: previousPolicy }, discoveryBefore: discoveries, discoveryAfter, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
41061
41257
|
}
|
|
41258
|
+
function planClaudeStopHookUpdate(options) {
|
|
41259
|
+
const home = resolve14(options.home ?? homedir3()), dataDir2 = options.dataDir ?? getDataDirReadOnly();
|
|
41260
|
+
const policyPath = join21(dataDir2, "agent-policy.json");
|
|
41261
|
+
assertSafePath(policyPath);
|
|
41262
|
+
const snapshot2 = readManagedSkillPolicySnapshot(dataDir2);
|
|
41263
|
+
if (!snapshot2)
|
|
41264
|
+
return null;
|
|
41265
|
+
const policy = snapshot2.value, bridge = policy.bridge;
|
|
41266
|
+
if (!bridge || bridge.home !== home || bridge.version !== CLI_BRIDGE_VERSION || bridge.digest !== CLI_BRIDGE_DIGEST || !Array.isArray(bridge.agents) || !bridge.agents.length || bridge.agents.some((agent) => !INTEGRATION_AGENTS.includes(agent)) || new Set(bridge.agents).size !== bridge.agents.length || !bridge.discovery || typeof bridge.discovery !== "object" || Array.isArray(bridge.discovery)) {
|
|
41267
|
+
throw new Error("Invalid managed bridge for Claude settings update");
|
|
41268
|
+
}
|
|
41269
|
+
const aliases = bridge.rootAliases ?? [];
|
|
41270
|
+
recheckRootAliases(aliases);
|
|
41271
|
+
const path = canonicalAgentPath(join21(home, ".claude", "settings.json"), aliases);
|
|
41272
|
+
assertSafePath(path);
|
|
41273
|
+
const before = lstatSync18(path, { throwIfNoEntry: false }) ? new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readNativeBytes(path, 1024 * 1024)) : null;
|
|
41274
|
+
if ((before === null ? "absent" : sha2(before)) !== options.expectedSettingsSha256)
|
|
41275
|
+
throw new Error("Claude settings preimage changed");
|
|
41276
|
+
assertClaudeStopHookReplacement(before, options.replacement);
|
|
41277
|
+
const agents = bridge.agents;
|
|
41278
|
+
const discoveries = Object.entries(bridge.discovery).map(([agent, binding]) => {
|
|
41279
|
+
if (!agents.includes(agent) || binding?.agent !== agent)
|
|
41280
|
+
throw new Error("Invalid managed discovery owner");
|
|
41281
|
+
return binding;
|
|
41282
|
+
});
|
|
41283
|
+
if (discoveries.length !== agents.length)
|
|
41284
|
+
throw new Error("Missing managed discovery coverage");
|
|
41285
|
+
for (const agent of agents)
|
|
41286
|
+
assertManagedAgentBridge(agent, { home, dataDir: dataDir2, projectDir: home });
|
|
41287
|
+
const replacements = new Map(before === options.replacement ? [] : [[path, options.replacement]]);
|
|
41288
|
+
const discoveryAfter = discoveries.map((binding) => rebindAgentDiscovery(binding, replacements));
|
|
41289
|
+
const nextPolicy = { ...policy, bridge: { ...bridge, discovery: Object.fromEntries(discoveryAfter.map((binding) => [binding.agent, binding])) } };
|
|
41290
|
+
const changes = before === options.replacement ? [] : [{ path, before, after: options.replacement }];
|
|
41291
|
+
if (JSON.stringify(nextPolicy) !== JSON.stringify(policy))
|
|
41292
|
+
changes.push({ path: policyPath, before: snapshot2.text, after: serializeManagedSkillPolicy(nextPolicy) });
|
|
41293
|
+
recheckRootAliases(aliases);
|
|
41294
|
+
const nativeSkills = inventoryNativeSkills(home, {
|
|
41295
|
+
agents,
|
|
41296
|
+
projectDir: home,
|
|
41297
|
+
includeVendor: true,
|
|
41298
|
+
guardHermes: agents.includes("hermes"),
|
|
41299
|
+
allowRootAliases: aliases.length > 0,
|
|
41300
|
+
agentRoots: discoveries.flatMap((binding) => binding.roots.map((path2) => ({ agent: binding.agent, path: path2 })))
|
|
41301
|
+
});
|
|
41302
|
+
return {
|
|
41303
|
+
dataDir: dataDir2,
|
|
41304
|
+
profileId: policy.profileId ?? "default",
|
|
41305
|
+
changes,
|
|
41306
|
+
nativeSkills,
|
|
41307
|
+
observedPolicy: { path: policyPath, before: snapshot2.text },
|
|
41308
|
+
discoveryBefore: discoveries,
|
|
41309
|
+
discoveryAfter,
|
|
41310
|
+
rootAliases: aliases,
|
|
41311
|
+
managedAgentChecks: { home, agents: [...agents] }
|
|
41312
|
+
};
|
|
41313
|
+
}
|
|
41062
41314
|
function atomicWrite2(path, content) {
|
|
41063
41315
|
assertSafePath(path);
|
|
41064
|
-
mkdirSync5(
|
|
41316
|
+
mkdirSync5(dirname14(path), { recursive: true, mode: 448 });
|
|
41065
41317
|
const temporary = `${path}.skills-${randomUUID3()}`;
|
|
41066
41318
|
try {
|
|
41067
|
-
|
|
41319
|
+
writeFileSync4(temporary, content, { mode: 384, flag: "wx" });
|
|
41068
41320
|
renameSync3(temporary, path);
|
|
41069
41321
|
} finally {
|
|
41070
41322
|
if (existsSync6(temporary))
|
|
@@ -41081,6 +41333,8 @@ function applyAgentIntegration(plan) {
|
|
|
41081
41333
|
parseManagedSkillPolicy(change.after);
|
|
41082
41334
|
const aliases = plan.rootAliases ?? [];
|
|
41083
41335
|
recheckRootAliases(aliases);
|
|
41336
|
+
for (const agent of plan.managedAgentChecks?.agents ?? [])
|
|
41337
|
+
assertManagedAgentBridge(agent, { home: plan.managedAgentChecks.home, dataDir: plan.dataDir, projectDir: plan.managedAgentChecks.home });
|
|
41084
41338
|
for (const binding of plan.discoveryBefore ?? [])
|
|
41085
41339
|
verifyAgentDiscovery(binding);
|
|
41086
41340
|
if (plan.observedPolicy && currentText(plan.observedPolicy.path) !== plan.observedPolicy.before)
|
|
@@ -41098,8 +41352,8 @@ function applyAgentIntegration(plan) {
|
|
|
41098
41352
|
chmodSync(backupRoot, 448);
|
|
41099
41353
|
for (const [index, change] of plan.changes.entries())
|
|
41100
41354
|
if (change.before !== null) {
|
|
41101
|
-
const backup = join21(backupRoot, `${index}-${
|
|
41102
|
-
|
|
41355
|
+
const backup = join21(backupRoot, `${index}-${sha2(change.path).slice(0, 12)}.backup`);
|
|
41356
|
+
writeFileSync4(backup, change.before, { mode: 384, flag: "wx" });
|
|
41103
41357
|
backups.push(backup);
|
|
41104
41358
|
}
|
|
41105
41359
|
try {
|
|
@@ -41107,7 +41361,7 @@ function applyAgentIntegration(plan) {
|
|
|
41107
41361
|
recheckRootAliases(aliases);
|
|
41108
41362
|
if (currentText(change.path) !== change.before)
|
|
41109
41363
|
throw new Error(`Configuration changed after planning: ${change.path}`);
|
|
41110
|
-
for (let directory =
|
|
41364
|
+
for (let directory = dirname14(change.path);!existsSync6(directory); directory = dirname14(directory))
|
|
41111
41365
|
createdDirectories.add(directory);
|
|
41112
41366
|
const after = change.after;
|
|
41113
41367
|
atomicWrite2(change.path, after);
|
|
@@ -41116,7 +41370,9 @@ function applyAgentIntegration(plan) {
|
|
|
41116
41370
|
recheckRootAliases(aliases);
|
|
41117
41371
|
for (const binding of plan.discoveryAfter ?? [])
|
|
41118
41372
|
verifyAgentDiscovery(binding);
|
|
41119
|
-
|
|
41373
|
+
for (const agent of plan.managedAgentChecks?.agents ?? [])
|
|
41374
|
+
assertManagedAgentBridge(agent, { home: plan.managedAgentChecks.home, dataDir: plan.dataDir, projectDir: plan.managedAgentChecks.home });
|
|
41375
|
+
atomicWrite2(join21(backupRoot, "receipt.json"), JSON.stringify({ version: 1, changes: written.map((change) => ({ path: change.path, beforeHash: change.before === null ? null : sha2(change.before), afterHash: sha2(change.after) })), backups, ...aliases.length ? { rootAliases: aliases } : {} }) + `
|
|
41120
41376
|
`);
|
|
41121
41377
|
} catch (error) {
|
|
41122
41378
|
for (const change of written.reverse()) {
|
|
@@ -41147,11 +41403,11 @@ function applyAgentIntegration(plan) {
|
|
|
41147
41403
|
}
|
|
41148
41404
|
function syncArchiveDirectory(path) {
|
|
41149
41405
|
assertSafePath(path);
|
|
41150
|
-
const descriptor =
|
|
41406
|
+
const descriptor = openSync16(path, constants12.O_RDONLY | constants12.O_DIRECTORY | constants12.O_NOFOLLOW | constants12.O_NONBLOCK);
|
|
41151
41407
|
try {
|
|
41152
|
-
|
|
41408
|
+
fsyncSync4(descriptor);
|
|
41153
41409
|
} finally {
|
|
41154
|
-
|
|
41410
|
+
closeSync16(descriptor);
|
|
41155
41411
|
}
|
|
41156
41412
|
}
|
|
41157
41413
|
function writeArchiveJournal(path, value) {
|
|
@@ -41159,18 +41415,18 @@ function writeArchiveJournal(path, value) {
|
|
|
41159
41415
|
const temporary = `${path}.skills-${randomUUID3()}`;
|
|
41160
41416
|
let descriptor;
|
|
41161
41417
|
try {
|
|
41162
|
-
descriptor =
|
|
41163
|
-
|
|
41418
|
+
descriptor = openSync16(temporary, constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | constants12.O_NOFOLLOW, 384);
|
|
41419
|
+
writeFileSync4(descriptor, `${JSON.stringify(value)}
|
|
41164
41420
|
`);
|
|
41165
|
-
|
|
41166
|
-
|
|
41421
|
+
fsyncSync4(descriptor);
|
|
41422
|
+
closeSync16(descriptor);
|
|
41167
41423
|
descriptor = undefined;
|
|
41168
41424
|
renameSync3(temporary, path);
|
|
41169
|
-
syncArchiveDirectory(
|
|
41425
|
+
syncArchiveDirectory(dirname14(path));
|
|
41170
41426
|
} finally {
|
|
41171
41427
|
if (descriptor !== undefined)
|
|
41172
|
-
|
|
41173
|
-
if (
|
|
41428
|
+
closeSync16(descriptor);
|
|
41429
|
+
if (lstatSync18(temporary, { throwIfNoEntry: false }))
|
|
41174
41430
|
unlinkSync4(temporary);
|
|
41175
41431
|
}
|
|
41176
41432
|
}
|
|
@@ -41195,8 +41451,8 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41195
41451
|
const operationId = randomUUID3(), archiveRoot = join21(options.dataDir ?? getDataDir(), "migration", operationId, "native"), receiptPath = join21(archiveRoot, "receipt.json");
|
|
41196
41452
|
const entries = selected.map((entry, index) => ({
|
|
41197
41453
|
source: entry.vendor ? join21(entry.path, "SKILL.md") : entry.path,
|
|
41198
|
-
archive: join21(archiveRoot, `${index}-${
|
|
41199
|
-
hash: entry.vendor ?
|
|
41454
|
+
archive: join21(archiveRoot, `${index}-${sha2(entry.path).slice(0, 12)}`),
|
|
41455
|
+
hash: entry.vendor ? sha2(readNativeBytes(join21(entry.path, "SKILL.md"))) : entry.hash,
|
|
41200
41456
|
...entry.vendor ? { discoveryOnly: true } : {},
|
|
41201
41457
|
status: "planned"
|
|
41202
41458
|
}));
|
|
@@ -41204,22 +41460,22 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41204
41460
|
const moved = [];
|
|
41205
41461
|
const verifyArchive = (entry) => {
|
|
41206
41462
|
assertSafePath(entry.archive);
|
|
41207
|
-
const stat2 =
|
|
41463
|
+
const stat2 = lstatSync18(entry.archive);
|
|
41208
41464
|
if (entry.discoveryOnly ? !stat2.isFile() : !stat2.isDirectory())
|
|
41209
41465
|
throw new Error("Archive type changed");
|
|
41210
|
-
if ((entry.discoveryOnly ?
|
|
41466
|
+
if ((entry.discoveryOnly ? sha2(readNativeBytes(entry.archive)) : treeHash(entry.archive)) !== entry.hash)
|
|
41211
41467
|
throw new Error("Archive bytes changed");
|
|
41212
41468
|
};
|
|
41213
41469
|
assertSafePath(archiveRoot);
|
|
41214
41470
|
const created = [];
|
|
41215
|
-
for (let path = archiveRoot;!existsSync6(path); path =
|
|
41471
|
+
for (let path = archiveRoot;!existsSync6(path); path = dirname14(path))
|
|
41216
41472
|
created.push(path);
|
|
41217
41473
|
mkdirSync5(archiveRoot, { recursive: true, mode: 448 });
|
|
41218
41474
|
try {
|
|
41219
41475
|
for (const directory of created)
|
|
41220
41476
|
syncArchiveDirectory(directory);
|
|
41221
41477
|
if (created.length)
|
|
41222
|
-
syncArchiveDirectory(
|
|
41478
|
+
syncArchiveDirectory(dirname14(created.at(-1)));
|
|
41223
41479
|
writeArchiveJournal(receiptPath, journal);
|
|
41224
41480
|
for (const [index, entry] of selected.entries()) {
|
|
41225
41481
|
recheckRootAliases(aliases);
|
|
@@ -41231,7 +41487,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41231
41487
|
writeArchiveJournal(receiptPath, journal);
|
|
41232
41488
|
renameSync3(move.source, move.archive);
|
|
41233
41489
|
moved.push(move);
|
|
41234
|
-
syncArchiveDirectory(
|
|
41490
|
+
syncArchiveDirectory(dirname14(move.source));
|
|
41235
41491
|
syncArchiveDirectory(archiveRoot);
|
|
41236
41492
|
verifyArchive(move);
|
|
41237
41493
|
move.status = "archived";
|
|
@@ -41252,7 +41508,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41252
41508
|
recheckRootAliases(aliases);
|
|
41253
41509
|
assertSafePath(entry.source);
|
|
41254
41510
|
assertSafePath(entry.archive);
|
|
41255
|
-
if (
|
|
41511
|
+
if (lstatSync18(entry.source, { throwIfNoEntry: false })) {
|
|
41256
41512
|
entry.status = "recovery-required";
|
|
41257
41513
|
entry.conflict = "source-occupied";
|
|
41258
41514
|
continue;
|
|
@@ -41266,10 +41522,10 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41266
41522
|
}
|
|
41267
41523
|
if (entry.discoveryOnly) {
|
|
41268
41524
|
linkSync2(entry.archive, entry.source);
|
|
41269
|
-
syncArchiveDirectory(
|
|
41525
|
+
syncArchiveDirectory(dirname14(entry.source));
|
|
41270
41526
|
unlinkSync4(entry.archive);
|
|
41271
41527
|
} else {
|
|
41272
|
-
if (
|
|
41528
|
+
if (lstatSync18(entry.source, { throwIfNoEntry: false })) {
|
|
41273
41529
|
entry.status = "recovery-required";
|
|
41274
41530
|
entry.conflict = "source-occupied";
|
|
41275
41531
|
continue;
|
|
@@ -41277,7 +41533,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41277
41533
|
renameSync3(entry.archive, entry.source);
|
|
41278
41534
|
}
|
|
41279
41535
|
entry.status = "restored";
|
|
41280
|
-
syncArchiveDirectory(
|
|
41536
|
+
syncArchiveDirectory(dirname14(entry.source));
|
|
41281
41537
|
syncArchiveDirectory(archiveRoot);
|
|
41282
41538
|
} catch {
|
|
41283
41539
|
entry.status = "recovery-required";
|
|
@@ -41296,6 +41552,97 @@ function archiveNativeSkills(inventory, options) {
|
|
|
41296
41552
|
}
|
|
41297
41553
|
return { entries: entries.map(({ status, conflict, ...entry }) => entry), receiptPath, ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
41298
41554
|
}
|
|
41555
|
+
function assertManagedAgentBridge(agent, options = {}) {
|
|
41556
|
+
const home = resolve14(options.home ?? homedir3()), dataDir2 = options.dataDir ?? getDataDirReadOnly();
|
|
41557
|
+
assertSafePath(join21(dataDir2, "agent-policy.json"));
|
|
41558
|
+
const snapshot2 = readManagedSkillPolicySnapshot(dataDir2);
|
|
41559
|
+
if (!snapshot2)
|
|
41560
|
+
throw new Error("NATIVE_SKILL_DRIFT: install the Skills bridge with skills hook install");
|
|
41561
|
+
const binding = snapshot2.value.bridge;
|
|
41562
|
+
if (!binding || binding.version !== CLI_BRIDGE_VERSION || binding.digest !== CLI_BRIDGE_DIGEST || binding.home !== home || !Array.isArray(binding.agents) || !binding.agents.includes(agent))
|
|
41563
|
+
throw new Error("NATIVE_SKILL_DRIFT: the managed Skills bridge binding is missing or incompatible; run skills hook install");
|
|
41564
|
+
const aliases = binding.rootAliases ?? [];
|
|
41565
|
+
if (!Array.isArray(aliases))
|
|
41566
|
+
throw new Error("NATIVE_SKILL_DRIFT: invalid root alias binding");
|
|
41567
|
+
recheckRootAliases(aliases);
|
|
41568
|
+
const expected = canonicalAgentPath(join21(home, AGENT_ADAPTERS[agent].root, CLI_BRIDGE_NAME), aliases);
|
|
41569
|
+
if (!isOwnedCliBridge(expected, [expected]))
|
|
41570
|
+
throw new Error("NATIVE_SKILL_DRIFT: the native Skills bridge is missing or modified; repair it before continuing");
|
|
41571
|
+
const roots = projectAncestorDirectories([options.projectDir ?? process.cwd(), ...options.projectDirs ?? [], ...agent === "hermes" && process.env.TERMINAL_CWD ? [process.cwd()] : []]);
|
|
41572
|
+
const visible = (entry) => entry.agent === agent || ["codex", "gemini", "opencode", "hermes"].includes(agent) && entry.path.includes(`${sep4}.agents${sep4}skills${sep4}`) || agent === "opencode" && entry.agent === "claude";
|
|
41573
|
+
const discovery = binding.discovery?.[agent];
|
|
41574
|
+
assertProjectDiscovery(agent, [...roots], home, (path) => canonicalAgentPath(path, aliases), discovery);
|
|
41575
|
+
const configPath = canonicalAgentPath(join21(home, AGENT_ADAPTERS[agent].config), aliases), config = agent === "hermes" ? parseHermesConfig(readOptional(configPath)) : jsonObject(readOptional(configPath), configPath);
|
|
41576
|
+
const command = binding.commands?.[agent], profile = binding.profiles?.[agent];
|
|
41577
|
+
if (typeof command !== "string" || typeof profile !== "string")
|
|
41578
|
+
throw new Error("NATIVE_SKILL_DRIFT: the native hook command/profile binding is missing");
|
|
41579
|
+
if (options.profileId !== undefined && options.profileId !== profile)
|
|
41580
|
+
throw new Error("NATIVE_SKILL_DRIFT: the hook selection profile differs from its managed binding; restart the native client after reviewing skills hook install");
|
|
41581
|
+
if (agent === "hermes") {
|
|
41582
|
+
const supervisor = binding.supervisors?.hermes;
|
|
41583
|
+
if (supervisor?.path !== join21(dataDir2, "agent-hooks", "hermes.js") || supervisor?.sha256 !== sha2(renderHermesSupervisor(command, profile)))
|
|
41584
|
+
throw new Error("NATIVE_SKILL_DRIFT: Hermes supervisor binding changed; run skills hook install");
|
|
41585
|
+
assertHermesProtection(home, config, command, profile, supervisor);
|
|
41586
|
+
} else if (agent === "opencode") {
|
|
41587
|
+
if (JSON.stringify(config.permission?.skill) !== JSON.stringify({ "*": "deny", [CLI_BRIDGE_NAME]: "allow" }) || readOptional(join21(home, ".config", "opencode", "plugins", "skills-cli.js")) !== renderOpenCodePlugin(command, profile))
|
|
41588
|
+
throw new Error("NATIVE_SKILL_DRIFT: OpenCode bridge protection changed; run skills hook install");
|
|
41589
|
+
} else {
|
|
41590
|
+
const required = {};
|
|
41591
|
+
configureHooks(required, agent, command, profile, true);
|
|
41592
|
+
for (const [event, entries] of Object.entries(required.hooks))
|
|
41593
|
+
for (const entry of entries) {
|
|
41594
|
+
if (!Array.isArray(config.hooks?.[event]) || config.hooks[event].filter((actual) => JSON.stringify(actual) === JSON.stringify(entry)).length !== 1)
|
|
41595
|
+
throw new Error("NATIVE_SKILL_DRIFT: required native prompt/skill hooks changed; run skills hook install");
|
|
41596
|
+
}
|
|
41597
|
+
if (agent === "claude" && (config.disableBundledSkills !== true || config.disableAllHooks === true || !config.permissions?.allow?.includes(`Skill(${CLI_BRIDGE_NAME})`) || config.permissions?.deny?.includes("Skill")))
|
|
41598
|
+
throw new Error("NATIVE_SKILL_DRIFT: Claude bridge or bundled-skill protection changed; retire copies and run skills hook install");
|
|
41599
|
+
if (agent === "claude" && config.syncClaudeAiSkills !== false)
|
|
41600
|
+
throw new Error("NATIVE_SKILL_DRIFT: Claude account skill synchronization is not disabled (syncClaudeAiSkills); run skills hook install to prevent native copies from returning");
|
|
41601
|
+
if (agent === "gemini" && (config.hooksConfig?.enabled === false || config.skills?.enabled !== true || !["antigravity-support", "skill-creator"].every((name) => config.skills?.disabled?.includes(name)) || config.skills?.disabled?.includes(CLI_BRIDGE_NAME)))
|
|
41602
|
+
throw new Error("NATIVE_SKILL_DRIFT: Gemini bridge or bundled-skill protection changed; run skills hook install");
|
|
41603
|
+
}
|
|
41604
|
+
const codexPath = canonicalAgentPath(join21(home, ".codex", "config.toml"), aliases);
|
|
41605
|
+
if (options.codexDiscoveryRecovery && (agent !== "codex" || options.codexDiscoveryRecovery.configPath !== codexPath))
|
|
41606
|
+
throw new Error("NATIVE_SKILL_DRIFT: Codex trust recovery names a different configuration root");
|
|
41607
|
+
const codexConfig = agent === "codex" ? Bun.TOML.parse(readOptional(codexPath) ?? "") : {};
|
|
41608
|
+
if (agent === "codex" && codexConfig.skills?.bundled?.enabled !== false)
|
|
41609
|
+
throw new Error("NATIVE_SKILL_DRIFT: Codex bundled skill reseeding is not disabled (skills.bundled.enabled); run skills hook install");
|
|
41610
|
+
const setting = (path) => (codexConfig.skills?.config ?? []).filter((entry) => typeof entry.path === "string" && [path, join21(path, "SKILL.md")].includes(canonicalAgentPath(entry.path, aliases)));
|
|
41611
|
+
if (agent === "codex" && [...setting(expected), ...(codexConfig.skills?.config ?? []).filter((entry) => typeof entry.name === "string" && entry.name.trim() === CLI_BRIDGE_NAME)].some((entry) => entry.enabled === false))
|
|
41612
|
+
throw new Error("NATIVE_SKILL_DRIFT: the Codex CLI bridge is disabled; run skills hook install");
|
|
41613
|
+
const disabledBuiltin = (entry) => {
|
|
41614
|
+
if (agent !== "codex" || !entry.vendor || !entry.path.startsWith(canonicalAgentPath(join21(home, ".codex", "skills", ".system"), aliases) + sep4))
|
|
41615
|
+
return false;
|
|
41616
|
+
const matched = Array.isArray(binding.disabledBuiltins) && binding.disabledBuiltins.some((item) => item.path === entry.path && item.hash === entry.hash);
|
|
41617
|
+
const settings = setting(entry.path);
|
|
41618
|
+
return matched && settings.length === 1 && settings[0]?.enabled === false;
|
|
41619
|
+
};
|
|
41620
|
+
if (!discovery || discovery.agent !== agent)
|
|
41621
|
+
throw new Error("NATIVE_SKILL_DRIFT: native discovery coverage is missing; run skills hook install");
|
|
41622
|
+
if (agent === "gemini" && !discovery.builtinNames?.every((name) => config.skills.disabled.includes(name)))
|
|
41623
|
+
throw new Error("NATIVE_SKILL_DRIFT: an installed Gemini builtin is not disabled");
|
|
41624
|
+
try {
|
|
41625
|
+
verifyAgentDiscovery(discovery, options.codexDiscoveryRecovery);
|
|
41626
|
+
if (discovery.method === "automatic") {
|
|
41627
|
+
const current = resolveAgentDiscovery({ home, agent, canonical: (path) => canonicalAgentPath(path, aliases) });
|
|
41628
|
+
if (JSON.stringify(current) !== JSON.stringify(discovery))
|
|
41629
|
+
throw new Error("Configured native discovery roots changed");
|
|
41630
|
+
}
|
|
41631
|
+
} catch (error) {
|
|
41632
|
+
throw new Error(`NATIVE_SKILL_DRIFT: ${error.message}`);
|
|
41633
|
+
}
|
|
41634
|
+
const inventory = inventoryNativeSkills(home, { includeVendor: true, guardHermes: agent === "hermes", agents: [agent], projectDirs: [...roots], agentRoots: discovery.roots.map((path) => ({ agent, path })), allowRootAliases: aliases.length > 0 });
|
|
41635
|
+
const unexpected = inventory.filter((entry) => visible(entry) && !entry.bridge && !disabledBuiltin(entry));
|
|
41636
|
+
if (unexpected.length) {
|
|
41637
|
+
const paths = unexpected.slice(0, 3).map((entry) => {
|
|
41638
|
+
const escaped = JSON.stringify(entry.path).replace(/[\u007f-\u009f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
41639
|
+
return escaped.length > 768 ? `${escaped.slice(0, 384)}...${escaped.slice(-381)}` : escaped;
|
|
41640
|
+
});
|
|
41641
|
+
const remaining = unexpected.length - paths.length;
|
|
41642
|
+
throw new Error(`NATIVE_SKILL_DRIFT: ${unexpected.length} unexpected native skill copies were found: ${paths.join(", ")}${remaining ? `; ${remaining} more` : ""}. Review skills migrate native --project <working-directory> --include-unmanaged --include-vendor --json before continuing; it inventories that directory and its ancestors. Use --apply after reviewing the archive plan.`);
|
|
41643
|
+
}
|
|
41644
|
+
recheckRootAliases(aliases);
|
|
41645
|
+
}
|
|
41299
41646
|
function assertNativeExportAllowed(dataDir2 = getDataDirReadOnly()) {
|
|
41300
41647
|
if (requiresCliSkillLoading(dataDir2))
|
|
41301
41648
|
throw new Error("NATIVE_SKILL_EXPORT_DISABLED: this station loads skills through the Skills CLI; use skills sync --selection-profile <id>");
|
|
@@ -41307,19 +41654,19 @@ import {
|
|
|
41307
41654
|
mkdirSync as mkdirSync7,
|
|
41308
41655
|
mkdtempSync,
|
|
41309
41656
|
readdirSync as readdirSync9,
|
|
41310
|
-
realpathSync as
|
|
41657
|
+
realpathSync as realpathSync7,
|
|
41311
41658
|
renameSync as renameSync4,
|
|
41312
41659
|
rmSync as rmSync2,
|
|
41313
41660
|
statSync as statSync8,
|
|
41314
|
-
writeFileSync as
|
|
41661
|
+
writeFileSync as writeFileSync6
|
|
41315
41662
|
} from "fs";
|
|
41316
|
-
import { basename as
|
|
41663
|
+
import { basename as basename9, dirname as dirname17, isAbsolute as isAbsolute16, join as join25, normalize as normalize2, relative as relative5, resolve as resolve16, sep as sep7 } from "path";
|
|
41317
41664
|
|
|
41318
41665
|
// src/lib/registry-data/index.ts
|
|
41319
41666
|
var SKILLS = [];
|
|
41320
41667
|
|
|
41321
41668
|
// src/lib/skill-hash.ts
|
|
41322
|
-
import { createHash as
|
|
41669
|
+
import { createHash as createHash17 } from "crypto";
|
|
41323
41670
|
import { existsSync as existsSync7, readdirSync as readdirSync8, readFileSync as readFileSync14, statSync as statSync6 } from "fs";
|
|
41324
41671
|
import { join as join22, sep as sep5 } from "path";
|
|
41325
41672
|
var CONTENT_HASH_ALGORITHM = "sha256";
|
|
@@ -41443,13 +41790,13 @@ function* bundleHashParts(files) {
|
|
|
41443
41790
|
yield new TextEncoder().encode("\x00");
|
|
41444
41791
|
}
|
|
41445
41792
|
function hashBundleFiles(files) {
|
|
41446
|
-
const hash2 =
|
|
41793
|
+
const hash2 = createHash17(CONTENT_HASH_ALGORITHM);
|
|
41447
41794
|
for (const part of bundleHashParts(files))
|
|
41448
41795
|
hash2.update(part);
|
|
41449
41796
|
return hash2.digest("hex");
|
|
41450
41797
|
}
|
|
41451
41798
|
async function hashBundleFilesCooperatively(files, check) {
|
|
41452
|
-
const hash2 =
|
|
41799
|
+
const hash2 = createHash17(CONTENT_HASH_ALGORITHM);
|
|
41453
41800
|
let bytesSinceYield = 0;
|
|
41454
41801
|
for (const part of bundleHashParts(files)) {
|
|
41455
41802
|
for (let offset = 0;offset < part.byteLength; offset += 64 * 1024) {
|
|
@@ -41532,7 +41879,7 @@ function snapshotContentEntries(entries, limits, check) {
|
|
|
41532
41879
|
contentLimit("Content hash entry limit exceeded");
|
|
41533
41880
|
if (Reflect.ownKeys(entries).length !== entries.length + 1)
|
|
41534
41881
|
invalidContent("Invalid content hash entry array");
|
|
41535
|
-
const
|
|
41882
|
+
const snapshot2 = [];
|
|
41536
41883
|
const paths = new SkillEntryPaths;
|
|
41537
41884
|
let rawBytes = 0;
|
|
41538
41885
|
for (let index = 0;index < entries.length; index++) {
|
|
@@ -41556,10 +41903,10 @@ function snapshotContentEntries(entries, limits, check) {
|
|
|
41556
41903
|
rawBytes += size;
|
|
41557
41904
|
const bytes = new Uint8Array(new ArrayBuffer(size));
|
|
41558
41905
|
bytes.set(entry.bytes);
|
|
41559
|
-
|
|
41906
|
+
snapshot2.push({ path: entry.path, bytes, mode: entry.mode });
|
|
41560
41907
|
}
|
|
41561
41908
|
check();
|
|
41562
|
-
return
|
|
41909
|
+
return snapshot2;
|
|
41563
41910
|
}
|
|
41564
41911
|
function coveredContentPath(path) {
|
|
41565
41912
|
const segments = path.split("/");
|
|
@@ -41607,12 +41954,12 @@ async function hashContentEntries(entries, options) {
|
|
|
41607
41954
|
try {
|
|
41608
41955
|
signal?.addEventListener("abort", abort, { once: true });
|
|
41609
41956
|
check();
|
|
41610
|
-
const
|
|
41957
|
+
const snapshot2 = snapshotContentEntries(entries, limits, check);
|
|
41611
41958
|
const normalized = [];
|
|
41612
41959
|
let normalizedBytes = 0;
|
|
41613
41960
|
let manifest;
|
|
41614
41961
|
await new Promise((resolve15) => setImmediate(resolve15));
|
|
41615
|
-
for (const entry of
|
|
41962
|
+
for (const entry of snapshot2) {
|
|
41616
41963
|
check();
|
|
41617
41964
|
if (!coveredContentPath(entry.path))
|
|
41618
41965
|
continue;
|
|
@@ -41763,7 +42110,7 @@ function validatePortableManifestContract(manifest, options = {}) {
|
|
|
41763
42110
|
function validateRuntimeContract(manifest, issues, strict) {
|
|
41764
42111
|
const runtime = manifest.runtime;
|
|
41765
42112
|
if (runtime === undefined) {
|
|
41766
|
-
if (strict) {
|
|
42113
|
+
if (strict && manifest.kind !== "instruction") {
|
|
41767
42114
|
add2(issues, "contract.runtime_missing", "runtime contract is required: { runtime, entrypoint?, timeout?, needs_network?, env?, sandbox?, system_deps?, artifacts? }");
|
|
41768
42115
|
}
|
|
41769
42116
|
return;
|
|
@@ -41832,13 +42179,13 @@ function validateRuntimeContract(manifest, issues, strict) {
|
|
|
41832
42179
|
import {
|
|
41833
42180
|
cpSync,
|
|
41834
42181
|
existsSync as existsSync8,
|
|
41835
|
-
lstatSync as
|
|
42182
|
+
lstatSync as lstatSync19,
|
|
41836
42183
|
mkdirSync as mkdirSync6,
|
|
41837
42184
|
readFileSync as readFileSync15,
|
|
41838
42185
|
realpathSync as realpathSync5,
|
|
41839
|
-
writeFileSync as
|
|
42186
|
+
writeFileSync as writeFileSync5
|
|
41840
42187
|
} from "fs";
|
|
41841
|
-
import { basename as basename7, dirname as
|
|
42188
|
+
import { basename as basename7, dirname as dirname15, join as join23, relative as relative4 } from "path";
|
|
41842
42189
|
var ANY_SEGMENT_COPY_EXCLUDES = new Set([
|
|
41843
42190
|
".git",
|
|
41844
42191
|
".DS_Store",
|
|
@@ -41950,13 +42297,12 @@ function createInstructionManifest(name, options) {
|
|
|
41950
42297
|
kind: "instruction",
|
|
41951
42298
|
inputs: [],
|
|
41952
42299
|
commands: [],
|
|
41953
|
-
runtime: defaultRuntimeContract(),
|
|
41954
42300
|
provenance: defaultProvenance()
|
|
41955
42301
|
};
|
|
41956
42302
|
}
|
|
41957
42303
|
function writeInstructionSkillTemplate(skillPath, manifest) {
|
|
41958
42304
|
mkdirSync6(skillPath, { recursive: true });
|
|
41959
|
-
|
|
42305
|
+
writeFileSync5(join23(skillPath, "SKILL.md"), renderInstructionSkillMd(manifest));
|
|
41960
42306
|
writeSkillJsonWithHash(skillPath, manifest);
|
|
41961
42307
|
}
|
|
41962
42308
|
function renderInstructionSkillMd(manifest) {
|
|
@@ -42007,11 +42353,11 @@ function createPortableManifest(name, options) {
|
|
|
42007
42353
|
}
|
|
42008
42354
|
function writePortableSkillTemplate(skillPath, manifest) {
|
|
42009
42355
|
mkdirSync6(join23(skillPath, "src"), { recursive: true });
|
|
42010
|
-
|
|
42011
|
-
|
|
42012
|
-
|
|
42013
|
-
|
|
42014
|
-
|
|
42356
|
+
writeFileSync5(join23(skillPath, "SKILL.md"), renderSkillMd(manifest));
|
|
42357
|
+
writeFileSync5(join23(skillPath, "AGENTS.md"), renderAgentsMd(manifest));
|
|
42358
|
+
writeFileSync5(join23(skillPath, "package.json"), renderPackageJson(manifest));
|
|
42359
|
+
writeFileSync5(join23(skillPath, "tsconfig.json"), renderTsconfig());
|
|
42360
|
+
writeFileSync5(join23(skillPath, "src", "index.ts"), renderEntrypoint(manifest));
|
|
42015
42361
|
writeSkillJsonWithHash(skillPath, manifest);
|
|
42016
42362
|
}
|
|
42017
42363
|
function fillContractDefaults(manifest, entrypoint) {
|
|
@@ -42019,7 +42365,7 @@ function fillContractDefaults(manifest, entrypoint) {
|
|
|
42019
42365
|
return {
|
|
42020
42366
|
...manifest,
|
|
42021
42367
|
standard: PORTABLE_SKILL_STANDARD,
|
|
42022
|
-
runtime: manifest.runtime ?? defaultRuntimeContract(resolvedEntrypoint),
|
|
42368
|
+
...manifest.kind === "instruction" ? {} : { runtime: manifest.runtime ?? defaultRuntimeContract(resolvedEntrypoint) },
|
|
42023
42369
|
provenance: {
|
|
42024
42370
|
...defaultProvenance(),
|
|
42025
42371
|
...manifest.provenance ?? {}
|
|
@@ -42036,7 +42382,7 @@ function writeSkillJsonWithHash(skillPath, manifest) {
|
|
|
42036
42382
|
content_hash: undefined
|
|
42037
42383
|
}
|
|
42038
42384
|
};
|
|
42039
|
-
|
|
42385
|
+
writeFileSync5(join23(skillPath, "skill.json"), `${JSON.stringify({ ...existing, ...renderSkillJsonObject(withoutHash) }, null, 2)}
|
|
42040
42386
|
`);
|
|
42041
42387
|
const hash2 = computeContentHash(skillPath);
|
|
42042
42388
|
const withHash = {
|
|
@@ -42046,7 +42392,7 @@ function writeSkillJsonWithHash(skillPath, manifest) {
|
|
|
42046
42392
|
content_hash: hash2
|
|
42047
42393
|
}
|
|
42048
42394
|
};
|
|
42049
|
-
|
|
42395
|
+
writeFileSync5(join23(skillPath, "skill.json"), `${JSON.stringify({ ...existing, ...renderSkillJsonObject(withHash) }, null, 2)}
|
|
42050
42396
|
`);
|
|
42051
42397
|
return withHash;
|
|
42052
42398
|
}
|
|
@@ -42086,18 +42432,18 @@ function ensurePortableSkillFiles(skillPath, manifest) {
|
|
|
42086
42432
|
};
|
|
42087
42433
|
const entry = next.commands[0]?.entry ?? "src/index.ts";
|
|
42088
42434
|
if (entry && !existsSync8(join23(skillPath, entry))) {
|
|
42089
|
-
mkdirSync6(
|
|
42090
|
-
|
|
42435
|
+
mkdirSync6(dirname15(join23(skillPath, entry)), { recursive: true });
|
|
42436
|
+
writeFileSync5(join23(skillPath, entry), renderEntrypoint(next));
|
|
42091
42437
|
}
|
|
42092
42438
|
if (!existsSync8(join23(skillPath, "SKILL.md")))
|
|
42093
|
-
|
|
42439
|
+
writeFileSync5(join23(skillPath, "SKILL.md"), renderSkillMd(next));
|
|
42094
42440
|
else
|
|
42095
|
-
|
|
42441
|
+
writeFileSync5(join23(skillPath, "SKILL.md"), ensureSkillMdFrontmatter(readFileSync15(join23(skillPath, "SKILL.md"), "utf-8"), next));
|
|
42096
42442
|
if (!existsSync8(join23(skillPath, "AGENTS.md")))
|
|
42097
|
-
|
|
42443
|
+
writeFileSync5(join23(skillPath, "AGENTS.md"), renderAgentsMd(next));
|
|
42098
42444
|
ensurePackageJson(skillPath, next);
|
|
42099
42445
|
if (!existsSync8(join23(skillPath, "tsconfig.json")))
|
|
42100
|
-
|
|
42446
|
+
writeFileSync5(join23(skillPath, "tsconfig.json"), renderTsconfig());
|
|
42101
42447
|
writeSkillJsonWithHash(skillPath, next);
|
|
42102
42448
|
return readPortableSkillManifest(skillPath, next.name);
|
|
42103
42449
|
}
|
|
@@ -42107,7 +42453,7 @@ function ensurePackageJson(skillPath, manifest) {
|
|
|
42107
42453
|
const commandName = normalizePortableSkillName(first.name || manifest.name);
|
|
42108
42454
|
const entry = (first.entry ?? "src/index.ts").replace(/^\.\//, "");
|
|
42109
42455
|
if (!existsSync8(pkgPath)) {
|
|
42110
|
-
|
|
42456
|
+
writeFileSync5(pkgPath, renderPackageJson(manifest));
|
|
42111
42457
|
return;
|
|
42112
42458
|
}
|
|
42113
42459
|
const existing = readJsonObject(pkgPath);
|
|
@@ -42126,7 +42472,7 @@ function ensurePackageJson(skillPath, manifest) {
|
|
|
42126
42472
|
const scripts = isRecord2(existing.scripts) ? { ...existing.scripts } : {};
|
|
42127
42473
|
if (!stringValue(scripts.dev))
|
|
42128
42474
|
scripts.dev = `bun run ${entry}`;
|
|
42129
|
-
|
|
42475
|
+
writeFileSync5(pkgPath, `${JSON.stringify({
|
|
42130
42476
|
...existing,
|
|
42131
42477
|
name: manifest.name,
|
|
42132
42478
|
version: manifest.version,
|
|
@@ -42150,20 +42496,20 @@ function ensureInstructionSkillFiles(skillPath, manifest) {
|
|
|
42150
42496
|
commands: []
|
|
42151
42497
|
};
|
|
42152
42498
|
if (!existsSync8(join23(skillPath, "SKILL.md"))) {
|
|
42153
|
-
|
|
42499
|
+
writeFileSync5(join23(skillPath, "SKILL.md"), renderSkillMd(next));
|
|
42154
42500
|
} else {
|
|
42155
42501
|
const path = join23(skillPath, "SKILL.md");
|
|
42156
42502
|
const content = readFileSync15(path, "utf8");
|
|
42157
42503
|
const declaredName = parseSkillFrontmatter(content)?.name;
|
|
42158
42504
|
if (declaredName && declaredName !== next.name) {
|
|
42159
|
-
|
|
42505
|
+
writeFileSync5(path, renameInstructionFrontmatter(content, next.name));
|
|
42160
42506
|
}
|
|
42161
42507
|
}
|
|
42162
42508
|
const packagePath = join23(skillPath, "package.json");
|
|
42163
42509
|
if (existsSync8(packagePath)) {
|
|
42164
42510
|
const pkg = readJsonObject(packagePath);
|
|
42165
42511
|
if (typeof pkg.name === "string" && pkg.name !== next.name) {
|
|
42166
|
-
|
|
42512
|
+
writeFileSync5(packagePath, `${JSON.stringify({ ...pkg, name: next.name }, null, 2)}
|
|
42167
42513
|
`);
|
|
42168
42514
|
}
|
|
42169
42515
|
}
|
|
@@ -42191,7 +42537,7 @@ function renameInstructionFrontmatter(content, name) {
|
|
|
42191
42537
|
return renamed + content.slice(frontmatter[0].length);
|
|
42192
42538
|
}
|
|
42193
42539
|
function copySkillDirectory(source, destination) {
|
|
42194
|
-
const resolvedSource =
|
|
42540
|
+
const resolvedSource = lstatSync19(source).isSymbolicLink() ? realpathSync5(source) : source;
|
|
42195
42541
|
mkdirSync6(destination, { recursive: true });
|
|
42196
42542
|
cpSync(resolvedSource, destination, {
|
|
42197
42543
|
recursive: true,
|
|
@@ -42204,7 +42550,7 @@ function copySkillDirectory(source, destination) {
|
|
|
42204
42550
|
if (isExcludedCopyEntry(segments[i], i === 0))
|
|
42205
42551
|
return false;
|
|
42206
42552
|
}
|
|
42207
|
-
if (
|
|
42553
|
+
if (lstatSync19(src).isSymbolicLink())
|
|
42208
42554
|
return false;
|
|
42209
42555
|
return true;
|
|
42210
42556
|
}
|
|
@@ -42481,6 +42827,103 @@ function displayName(name) {
|
|
|
42481
42827
|
function escapeJsString(value) {
|
|
42482
42828
|
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\r?\n/g, " ");
|
|
42483
42829
|
}
|
|
42830
|
+
|
|
42831
|
+
// src/lib/authoring-path.ts
|
|
42832
|
+
import { lstatSync as lstatSync20, realpathSync as realpathSync6 } from "fs";
|
|
42833
|
+
import { homedir as homedir4 } from "os";
|
|
42834
|
+
import { basename as basename8, dirname as dirname16, join as join24, resolve as resolve15, sep as sep6 } from "path";
|
|
42835
|
+
var NATIVE_DISCOVERY_ROOTS = NATIVE_SKILL_ROOTS.map(([, path]) => path.split("/"));
|
|
42836
|
+
function pathParts(path) {
|
|
42837
|
+
return resolve15(path).split(sep6).filter(Boolean);
|
|
42838
|
+
}
|
|
42839
|
+
function nativeRootMatch(path) {
|
|
42840
|
+
const parts = pathParts(path);
|
|
42841
|
+
for (let start = 0;start < parts.length; start += 1) {
|
|
42842
|
+
for (const root2 of NATIVE_DISCOVERY_ROOTS) {
|
|
42843
|
+
if (root2.every((part, offset) => parts[start + offset] === part)) {
|
|
42844
|
+
return root2.join("/");
|
|
42845
|
+
}
|
|
42846
|
+
}
|
|
42847
|
+
}
|
|
42848
|
+
return;
|
|
42849
|
+
}
|
|
42850
|
+
function physicalPath(path) {
|
|
42851
|
+
let cursor = resolve15(path);
|
|
42852
|
+
const suffix = [];
|
|
42853
|
+
while (!lstatSync20(cursor, { throwIfNoEntry: false })) {
|
|
42854
|
+
suffix.unshift(basename8(cursor));
|
|
42855
|
+
const parent = dirname16(cursor);
|
|
42856
|
+
if (parent === cursor)
|
|
42857
|
+
return resolve15(path);
|
|
42858
|
+
cursor = parent;
|
|
42859
|
+
}
|
|
42860
|
+
return resolve15(realpathSync6(cursor), ...suffix);
|
|
42861
|
+
}
|
|
42862
|
+
function contains(root2, path) {
|
|
42863
|
+
return path === root2 || path.startsWith(root2 + sep6);
|
|
42864
|
+
}
|
|
42865
|
+
function configuredRoots(home, explicitHome) {
|
|
42866
|
+
const homeData = join24(home, ".hasna", "skills");
|
|
42867
|
+
const homePolicy = readManagedSkillPolicySnapshot(homeData);
|
|
42868
|
+
const configuredPolicy = !explicitHome && resolve15(getDataDirReadOnly()) !== resolve15(homeData) ? readManagedSkillPolicySnapshot(getDataDirReadOnly()) : null;
|
|
42869
|
+
const policy = homePolicy ?? configuredPolicy;
|
|
42870
|
+
const bridge = policy?.value.bridge;
|
|
42871
|
+
if (bridge && (typeof bridge.home !== "string" || physicalPath(bridge.home) !== physicalPath(home))) {
|
|
42872
|
+
throw new Error("Native discovery policy belongs to a different home; refusing portable authoring");
|
|
42873
|
+
}
|
|
42874
|
+
const roots = [];
|
|
42875
|
+
const admitBinding = (binding) => {
|
|
42876
|
+
if (!INTEGRATION_AGENTS.includes(binding.agent) || !binding.sources.some((source) => source.path === physicalPath(agentDiscoveryConfigPath(home, binding.agent)))) {
|
|
42877
|
+
throw new Error("Native discovery policy does not bind the current account configuration");
|
|
42878
|
+
}
|
|
42879
|
+
verifyAgentDiscovery(binding);
|
|
42880
|
+
roots.push(...binding.roots);
|
|
42881
|
+
};
|
|
42882
|
+
if (homePolicy && configuredPolicy?.value.bridge) {
|
|
42883
|
+
if (physicalPath(configuredPolicy.value.bridge.home) !== physicalPath(home))
|
|
42884
|
+
throw new Error("Native discovery policy belongs to a different home; refusing portable authoring");
|
|
42885
|
+
for (const binding of Object.values(configuredPolicy.value.bridge.discovery ?? {})) {
|
|
42886
|
+
admitBinding(binding);
|
|
42887
|
+
}
|
|
42888
|
+
}
|
|
42889
|
+
for (const agent of INTEGRATION_AGENTS) {
|
|
42890
|
+
const binding = bridge?.discovery?.[agent];
|
|
42891
|
+
if (binding !== undefined) {
|
|
42892
|
+
if (binding.agent !== agent)
|
|
42893
|
+
throw new Error("Invalid native discovery policy binding");
|
|
42894
|
+
admitBinding(binding);
|
|
42895
|
+
continue;
|
|
42896
|
+
}
|
|
42897
|
+
const nativeHome = join24(home, agent === "opencode" ? ".config/opencode" : `.${agent}`);
|
|
42898
|
+
if (!lstatSync20(nativeHome, { throwIfNoEntry: false }))
|
|
42899
|
+
continue;
|
|
42900
|
+
roots.push(...resolveAgentDiscovery({ home, agent, canonical: physicalPath }).roots);
|
|
42901
|
+
}
|
|
42902
|
+
return roots;
|
|
42903
|
+
}
|
|
42904
|
+
function assertPortableAuthoringPath(path, options = {}) {
|
|
42905
|
+
if (typeof path !== "string" || !path || path.includes("\x00"))
|
|
42906
|
+
throw new Error("Invalid portable authoring path");
|
|
42907
|
+
const lexical = resolve15(path);
|
|
42908
|
+
const physical = physicalPath(lexical);
|
|
42909
|
+
const candidates = [lexical, physical];
|
|
42910
|
+
let native = candidates.map(nativeRootMatch).find(Boolean);
|
|
42911
|
+
const home = resolve15(options.homeDir ?? homedir4());
|
|
42912
|
+
const defaults = NATIVE_DISCOVERY_ROOTS.map((parts) => join24(home, ...parts));
|
|
42913
|
+
defaults.push(join24(home, ".codex/plugins/cache"), join24(home, ".claude/plugins/cache"), join24(home, ".claude/plugins/synced"), join24(home, ".gemini/extensions"));
|
|
42914
|
+
for (const root2 of defaults) {
|
|
42915
|
+
if (candidates.some((candidate2) => contains(resolve15(root2), candidate2) || contains(physicalPath(root2), candidate2)))
|
|
42916
|
+
native ??= root2;
|
|
42917
|
+
}
|
|
42918
|
+
if (native) {
|
|
42919
|
+
throw new Error(`Refusing portable Skills authoring below native discovery root '${native}': ${lexical}. Set HASNA_SKILLS_DIR to a private authoring corpus outside native roots.`);
|
|
42920
|
+
}
|
|
42921
|
+
for (const root2 of configuredRoots(home, options.homeDir !== undefined)) {
|
|
42922
|
+
if (candidates.some((candidate2) => contains(resolve15(root2), candidate2) || contains(physicalPath(root2), candidate2))) {
|
|
42923
|
+
throw new Error(`Refusing portable Skills authoring below configured native discovery root: ${lexical}`);
|
|
42924
|
+
}
|
|
42925
|
+
}
|
|
42926
|
+
}
|
|
42484
42927
|
// src/lib/portable-skills.ts
|
|
42485
42928
|
function getPortableSkillsRoot(options = {}) {
|
|
42486
42929
|
return resolvePortableSkillsRoot(options, true);
|
|
@@ -42488,15 +42931,15 @@ function getPortableSkillsRoot(options = {}) {
|
|
|
42488
42931
|
function resolvePortableSkillsRoot(options, migrate) {
|
|
42489
42932
|
if (options.rootDir)
|
|
42490
42933
|
return options.rootDir;
|
|
42491
|
-
const appDir = options.homeDir ?
|
|
42492
|
-
const cache =
|
|
42934
|
+
const appDir = options.homeDir ? join25(options.homeDir, ".hasna", "skills") : migrate ? getDataDir() : getDataDirReadOnly();
|
|
42935
|
+
const cache = join25(appDir, SKILLS_CACHE_DIRNAME);
|
|
42493
42936
|
if (isOwnerLayoutMigrated(appDir) && safeIsDirectory(cache))
|
|
42494
42937
|
return cache;
|
|
42495
|
-
const installed =
|
|
42938
|
+
const installed = join25(appDir, INSTALLED_SKILLS_DIRNAME);
|
|
42496
42939
|
return installed;
|
|
42497
42940
|
}
|
|
42498
42941
|
function getPortableSkillPath(name, options = {}) {
|
|
42499
|
-
return
|
|
42942
|
+
return join25(getPortableSkillsRoot(options), normalizePortableSkillName(name));
|
|
42500
42943
|
}
|
|
42501
42944
|
function findPortableSkill(name, options = {}) {
|
|
42502
42945
|
let normalized;
|
|
@@ -42522,7 +42965,7 @@ function listPortableSkills(options = {}) {
|
|
|
42522
42965
|
for (const entry of readdirSync9(root2).sort()) {
|
|
42523
42966
|
if (entry.startsWith("."))
|
|
42524
42967
|
continue;
|
|
42525
|
-
const path =
|
|
42968
|
+
const path = join25(root2, entry);
|
|
42526
42969
|
if (!safeIsDirectory(path))
|
|
42527
42970
|
continue;
|
|
42528
42971
|
try {
|
|
@@ -42555,8 +42998,11 @@ function isOfficialSkillName(name) {
|
|
|
42555
42998
|
}
|
|
42556
42999
|
function scaffoldPortableSkill(name, options = {}) {
|
|
42557
43000
|
const skillName = normalizeNewPortableSkillName(name);
|
|
43001
|
+
const readOnlyRoot = resolvePortableSkillsRoot(options, false);
|
|
43002
|
+
assertPortableAuthoringPath(join25(readOnlyRoot, skillName), options);
|
|
42558
43003
|
const root2 = getPortableSkillsRoot(options);
|
|
42559
|
-
const skillPath =
|
|
43004
|
+
const skillPath = join25(root2, skillName);
|
|
43005
|
+
assertPortableAuthoringPath(skillPath, options);
|
|
42560
43006
|
if (existsSync9(skillPath)) {
|
|
42561
43007
|
if (!options.overwrite)
|
|
42562
43008
|
throw new Error(`Skill '${skillName}' already exists at ${skillPath}`);
|
|
@@ -42589,7 +43035,7 @@ function portPortableSkillDirectory(sourceDir, options = {}) {
|
|
|
42589
43035
|
const skipped = [];
|
|
42590
43036
|
const entries = readdirSync9(absoluteSource, { withFileTypes: true }).map((entry) => entry.name).filter((entryName) => !entryName.startsWith(".")).sort();
|
|
42591
43037
|
for (const entryName of entries) {
|
|
42592
|
-
const childPath =
|
|
43038
|
+
const childPath = join25(absoluteSource, entryName);
|
|
42593
43039
|
if (!safeIsDirectory(childPath))
|
|
42594
43040
|
continue;
|
|
42595
43041
|
if (!isSkillCandidate(childPath)) {
|
|
@@ -42618,25 +43064,25 @@ function portPortableSkillDirectory(sourceDir, options = {}) {
|
|
|
42618
43064
|
};
|
|
42619
43065
|
}
|
|
42620
43066
|
function isSkillCandidate(dir) {
|
|
42621
|
-
return existsSync9(
|
|
43067
|
+
return existsSync9(join25(dir, "SKILL.md")) || existsSync9(join25(dir, "skill.json")) || existsSync9(join25(dir, "package.json"));
|
|
42622
43068
|
}
|
|
42623
43069
|
function physicalImportPath(path) {
|
|
42624
|
-
let ancestor =
|
|
43070
|
+
let ancestor = resolve16(path);
|
|
42625
43071
|
const suffix = [];
|
|
42626
43072
|
while (!existsSync9(ancestor)) {
|
|
42627
|
-
suffix.unshift(
|
|
42628
|
-
ancestor =
|
|
43073
|
+
suffix.unshift(basename9(ancestor));
|
|
43074
|
+
ancestor = dirname17(ancestor);
|
|
42629
43075
|
}
|
|
42630
|
-
return
|
|
43076
|
+
return join25(realpathSync7(ancestor), ...suffix);
|
|
42631
43077
|
}
|
|
42632
43078
|
function assertDisjointImportPaths(source, destination) {
|
|
42633
|
-
const sourcePath =
|
|
43079
|
+
const sourcePath = realpathSync7(source);
|
|
42634
43080
|
const destinationPath = physicalImportPath(destination);
|
|
42635
|
-
const
|
|
43081
|
+
const contains2 = (parent, child) => {
|
|
42636
43082
|
const path = relative5(parent, child);
|
|
42637
|
-
return path === "" || !isAbsolute16(path) && path !== ".." && !path.startsWith(`..${
|
|
43083
|
+
return path === "" || !isAbsolute16(path) && path !== ".." && !path.startsWith(`..${sep7}`);
|
|
42638
43084
|
};
|
|
42639
|
-
if (
|
|
43085
|
+
if (contains2(sourcePath, destinationPath) || contains2(destinationPath, sourcePath)) {
|
|
42640
43086
|
throw new Error("Source and destination skill directories must not overlap");
|
|
42641
43087
|
}
|
|
42642
43088
|
}
|
|
@@ -42649,20 +43095,23 @@ function portPortableSkill(sourcePath, options = {}) {
|
|
|
42649
43095
|
const explicitName = options.name != null;
|
|
42650
43096
|
const skillName = normalizeNewPortableSkillName(options.name ?? inferred.name);
|
|
42651
43097
|
if (isOfficialSkillName(skillName) && !options.allowShadow) {
|
|
42652
|
-
const sourceSlug = safeNormalizeName(
|
|
42653
|
-
const via = explicitName ? `Name '${skillName}' matches a bundled official skill.` : `Inferred name '${skillName}'${sourceSlug && sourceSlug !== skillName ? ` (from source folder '${
|
|
43098
|
+
const sourceSlug = safeNormalizeName(basename9(absoluteSource));
|
|
43099
|
+
const via = explicitName ? `Name '${skillName}' matches a bundled official skill.` : `Inferred name '${skillName}'${sourceSlug && sourceSlug !== skillName ? ` (from source folder '${basename9(absoluteSource)}')` : ""} matches a bundled official skill.`;
|
|
42654
43100
|
throw new Error(`${via} Importing it would shadow the official '${skillName}'. ` + `Pass --name to choose a different name, or --allow-shadow to override deliberately.`);
|
|
42655
43101
|
}
|
|
42656
|
-
|
|
43102
|
+
const readOnlyDestination = join25(resolvePortableSkillsRoot(options, false), skillName);
|
|
43103
|
+
assertPortableAuthoringPath(readOnlyDestination, options);
|
|
43104
|
+
assertDisjointImportPaths(absoluteSource, readOnlyDestination);
|
|
42657
43105
|
const root2 = getPortableSkillsRoot(options);
|
|
42658
|
-
const destination =
|
|
43106
|
+
const destination = join25(root2, skillName);
|
|
43107
|
+
assertPortableAuthoringPath(destination, options);
|
|
42659
43108
|
assertDisjointImportPaths(absoluteSource, destination);
|
|
42660
43109
|
if (existsSync9(destination)) {
|
|
42661
43110
|
if (!options.overwrite)
|
|
42662
43111
|
throw new Error(`Skill '${skillName}' already exists at ${destination}`);
|
|
42663
43112
|
rmSync2(destination, { recursive: true, force: true });
|
|
42664
43113
|
}
|
|
42665
|
-
mkdirSync7(
|
|
43114
|
+
mkdirSync7(dirname17(destination), { recursive: true });
|
|
42666
43115
|
copySkillDirectory(absoluteSource, destination);
|
|
42667
43116
|
const base = {
|
|
42668
43117
|
...inferred,
|
|
@@ -42698,31 +43147,37 @@ function buildCorpusManifest(input, name) {
|
|
|
42698
43147
|
}
|
|
42699
43148
|
function writeCorpusSkill(input, options = {}) {
|
|
42700
43149
|
const name = normalizePortableSkillName(input.name);
|
|
43150
|
+
const readOnlyRoot = resolvePortableSkillsRoot(options, false);
|
|
43151
|
+
assertPortableAuthoringPath(join25(readOnlyRoot, name), options);
|
|
42701
43152
|
const root2 = getPortableSkillsRoot(options);
|
|
42702
|
-
const skillPath =
|
|
43153
|
+
const skillPath = join25(root2, name);
|
|
43154
|
+
assertPortableAuthoringPath(skillPath, options);
|
|
42703
43155
|
const created = !existsSync9(skillPath);
|
|
42704
43156
|
mkdirSync7(skillPath, { recursive: true });
|
|
42705
|
-
|
|
43157
|
+
writeFileSync6(join25(skillPath, "SKILL.md"), input.skillMd);
|
|
42706
43158
|
const manifest = buildCorpusManifest(input, name);
|
|
42707
43159
|
writeSkillJsonWithHash(skillPath, manifest);
|
|
42708
43160
|
return { name, path: skillPath, manifest, created };
|
|
42709
43161
|
}
|
|
42710
43162
|
function installCorpusSkillAtomically(input, options = {}) {
|
|
42711
43163
|
const name = normalizePortableSkillName(input.name);
|
|
43164
|
+
const readOnlyRoot = resolvePortableSkillsRoot(options, false);
|
|
43165
|
+
assertPortableAuthoringPath(join25(readOnlyRoot, name), options);
|
|
42712
43166
|
const root2 = getPortableSkillsRoot(options);
|
|
42713
|
-
const target =
|
|
43167
|
+
const target = join25(root2, name);
|
|
43168
|
+
assertPortableAuthoringPath(target, options);
|
|
42714
43169
|
const created = !existsSync9(target);
|
|
42715
43170
|
mkdirSync7(root2, { recursive: true });
|
|
42716
|
-
const staging = mkdtempSync(
|
|
43171
|
+
const staging = mkdtempSync(join25(root2, `.pull-${name}-`));
|
|
42717
43172
|
let moved = false;
|
|
42718
43173
|
let backup = null;
|
|
42719
43174
|
try {
|
|
42720
|
-
|
|
43175
|
+
writeFileSync6(join25(staging, "SKILL.md"), input.skillMd);
|
|
42721
43176
|
const manifest = buildCorpusManifest(input, name);
|
|
42722
43177
|
writeSkillJsonWithHash(staging, manifest);
|
|
42723
43178
|
if (existsSync9(target)) {
|
|
42724
|
-
backup = mkdtempSync(
|
|
42725
|
-
renameSync4(target,
|
|
43179
|
+
backup = mkdtempSync(join25(root2, `.pull-backup-${name}-`));
|
|
43180
|
+
renameSync4(target, join25(backup, name));
|
|
42726
43181
|
moved = true;
|
|
42727
43182
|
}
|
|
42728
43183
|
renameSync4(staging, target);
|
|
@@ -42731,9 +43186,9 @@ function installCorpusSkillAtomically(input, options = {}) {
|
|
|
42731
43186
|
return { name, path: target, manifest, created };
|
|
42732
43187
|
} catch (error) {
|
|
42733
43188
|
rmSync2(staging, { recursive: true, force: true });
|
|
42734
|
-
if (moved && backup && existsSync9(
|
|
43189
|
+
if (moved && backup && existsSync9(join25(backup, name))) {
|
|
42735
43190
|
try {
|
|
42736
|
-
renameSync4(
|
|
43191
|
+
renameSync4(join25(backup, name), target);
|
|
42737
43192
|
} catch {}
|
|
42738
43193
|
}
|
|
42739
43194
|
throw error;
|
|
@@ -42746,8 +43201,8 @@ function validatePortableSkillDirectory(name, skillPath) {
|
|
|
42746
43201
|
const warnings = [...base.warnings];
|
|
42747
43202
|
let manifest;
|
|
42748
43203
|
if (existsSync9(skillPath)) {
|
|
42749
|
-
const skillJsonPath =
|
|
42750
|
-
const skillMdPath =
|
|
43204
|
+
const skillJsonPath = join25(skillPath, "skill.json");
|
|
43205
|
+
const skillMdPath = join25(skillPath, "SKILL.md");
|
|
42751
43206
|
if (!existsSync9(skillJsonPath) && !existsSync9(skillMdPath)) {
|
|
42752
43207
|
add3(issues, "portable.manifest_missing", "Missing portable manifest: expected SKILL.md frontmatter and/or skill.json");
|
|
42753
43208
|
}
|
|
@@ -42767,7 +43222,7 @@ function validatePortableSkillDirectory(name, skillPath) {
|
|
|
42767
43222
|
add3(issues, "portable.version_missing", "Portable manifest missing version");
|
|
42768
43223
|
}
|
|
42769
43224
|
const contractIssues = validatePortableManifestContract(manifest, {
|
|
42770
|
-
strict: existsSync9(
|
|
43225
|
+
strict: existsSync9(join25(skillPath, "skill.json")),
|
|
42771
43226
|
skillPath
|
|
42772
43227
|
});
|
|
42773
43228
|
for (const issue of contractIssues)
|
|
@@ -42807,7 +43262,7 @@ function validatePortableSkillDirectory(name, skillPath) {
|
|
|
42807
43262
|
add3(issues, "portable.command_entry_unsafe", `Command '${command.name}' entry '${command.entry}' must stay inside the skill directory`);
|
|
42808
43263
|
continue;
|
|
42809
43264
|
}
|
|
42810
|
-
const entryPath =
|
|
43265
|
+
const entryPath = join25(skillPath, command.entry);
|
|
42811
43266
|
if (!existsSync9(entryPath))
|
|
42812
43267
|
add3(issues, "portable.command_entry_missing", `Command '${command.name}' entry '${command.entry}' is missing`);
|
|
42813
43268
|
else if (statSync8(entryPath).isDirectory())
|
|
@@ -42818,7 +43273,7 @@ function validatePortableSkillDirectory(name, skillPath) {
|
|
|
42818
43273
|
} catch (error) {
|
|
42819
43274
|
add3(issues, "portable.manifest_invalid", error.message);
|
|
42820
43275
|
}
|
|
42821
|
-
if (manifest?.kind !== "instruction" && !existsSync9(
|
|
43276
|
+
if (manifest?.kind !== "instruction" && !existsSync9(join25(skillPath, "AGENTS.md"))) {
|
|
42822
43277
|
add3(issues, "portable.agents_missing", "Missing AGENTS.md with build-out instructions for coding agents");
|
|
42823
43278
|
}
|
|
42824
43279
|
}
|
|
@@ -42854,12 +43309,12 @@ async function runPortableSkill(name, args, options = {}) {
|
|
|
42854
43309
|
if (!isSafeRelativePath2(command.entry)) {
|
|
42855
43310
|
return { exitCode: 1, error: `Portable skill '${name}' command entry is unsafe` };
|
|
42856
43311
|
}
|
|
42857
|
-
const entryPath =
|
|
43312
|
+
const entryPath = join25(skill.path, command.entry);
|
|
42858
43313
|
if (!existsSync9(entryPath)) {
|
|
42859
43314
|
return { exitCode: 1, error: `Entry point '${command.entry}' not found in portable skill '${name}'` };
|
|
42860
43315
|
}
|
|
42861
|
-
const pkgPath =
|
|
42862
|
-
const nodeModules =
|
|
43316
|
+
const pkgPath = join25(skill.path, "package.json");
|
|
43317
|
+
const nodeModules = join25(skill.path, "node_modules");
|
|
42863
43318
|
if (existsSync9(pkgPath) && !existsSync9(nodeModules) && hasPackageDependencies(pkgPath)) {
|
|
42864
43319
|
const install = Bun.spawn(["bun", "install", "--no-save"], {
|
|
42865
43320
|
cwd: skill.path,
|
|
@@ -42931,9 +43386,9 @@ function isSkillsOwnershipMarker(marker) {
|
|
|
42931
43386
|
return typeof marker === "object" && marker !== null && Object.hasOwn(marker, "managedBy") && marker.managedBy === SYNC_MARKER_MANAGED_BY;
|
|
42932
43387
|
}
|
|
42933
43388
|
function hasSkillsOwnershipMarker(dir) {
|
|
42934
|
-
const path =
|
|
43389
|
+
const path = join26(dir, SYNC_MARKER_FILE);
|
|
42935
43390
|
try {
|
|
42936
|
-
if (!
|
|
43391
|
+
if (!lstatSync21(path).isFile())
|
|
42937
43392
|
return false;
|
|
42938
43393
|
const marker = JSON.parse(readFileSync16(path, "utf8"));
|
|
42939
43394
|
return isSkillsOwnershipMarker(marker);
|
|
@@ -42952,12 +43407,12 @@ function resolveSyncAgents(arg) {
|
|
|
42952
43407
|
}
|
|
42953
43408
|
return [arg];
|
|
42954
43409
|
}
|
|
42955
|
-
function agentGlobalSkillsDir(agent, homeDir3 =
|
|
43410
|
+
function agentGlobalSkillsDir(agent, homeDir3 = homedir5()) {
|
|
42956
43411
|
switch (agent) {
|
|
42957
43412
|
case "opencode":
|
|
42958
|
-
return
|
|
43413
|
+
return join26(homeDir3, ".config", "opencode", "skills");
|
|
42959
43414
|
default:
|
|
42960
|
-
return
|
|
43415
|
+
return join26(homeDir3, `.${agent}`, "skills");
|
|
42961
43416
|
}
|
|
42962
43417
|
}
|
|
42963
43418
|
function adaptSkillMdForAgent(skillMd, agent) {
|
|
@@ -43016,7 +43471,7 @@ function resolveSyncCorpus(options = {}) {
|
|
|
43016
43471
|
function packageSourceRoots(source) {
|
|
43017
43472
|
const roots = [];
|
|
43018
43473
|
for (const sub of ["skills"]) {
|
|
43019
|
-
const candidate2 =
|
|
43474
|
+
const candidate2 = join26(source, sub);
|
|
43020
43475
|
if (existsSync10(candidate2) && isDirectory(candidate2))
|
|
43021
43476
|
roots.push(candidate2);
|
|
43022
43477
|
}
|
|
@@ -43032,10 +43487,10 @@ function containsSkillDirectories(path) {
|
|
|
43032
43487
|
return false;
|
|
43033
43488
|
}
|
|
43034
43489
|
return entries.some((entry) => {
|
|
43035
|
-
const candidate2 =
|
|
43490
|
+
const candidate2 = join26(path, entry);
|
|
43036
43491
|
if (!isDirectory(candidate2))
|
|
43037
43492
|
return false;
|
|
43038
|
-
return existsSync10(
|
|
43493
|
+
return existsSync10(join26(candidate2, "SKILL.md")) || existsSync10(join26(candidate2, "skill.json")) || existsSync10(join26(candidate2, "package.json"));
|
|
43039
43494
|
});
|
|
43040
43495
|
}
|
|
43041
43496
|
function isDirectory(path) {
|
|
@@ -43049,7 +43504,7 @@ function syncSkillsToAgents(options = {}) {
|
|
|
43049
43504
|
assertNativeExportAllowed();
|
|
43050
43505
|
const requested = normalizeRequested(options.names);
|
|
43051
43506
|
const agents = options.agents?.length ? options.agents : [...SYNC_AGENTS];
|
|
43052
|
-
const homeDir3 = options.homeDir ??
|
|
43507
|
+
const homeDir3 = options.homeDir ?? homedir5();
|
|
43053
43508
|
const { roots, source } = resolveSyncCorpus(options);
|
|
43054
43509
|
const corpus = listPortableSkillsAcrossRoots(roots);
|
|
43055
43510
|
const byName = new Map(corpus.map((skill) => [skill.name, skill]));
|
|
@@ -43075,7 +43530,7 @@ function syncSkillsToAgents(options = {}) {
|
|
|
43075
43530
|
actions.push({
|
|
43076
43531
|
skill: name,
|
|
43077
43532
|
agent,
|
|
43078
|
-
path:
|
|
43533
|
+
path: join26(agentGlobalSkillsDir(agent, homeDir3), name, "SKILL.md"),
|
|
43079
43534
|
action: "skip",
|
|
43080
43535
|
reason: "not found in this machine's corpus"
|
|
43081
43536
|
});
|
|
@@ -43104,8 +43559,8 @@ function syncSkillsToAgents(options = {}) {
|
|
|
43104
43559
|
return { actions };
|
|
43105
43560
|
}
|
|
43106
43561
|
function writeManagedAgentSkill(params) {
|
|
43107
|
-
const homeDir3 = params.homeDir ??
|
|
43108
|
-
const dir =
|
|
43562
|
+
const homeDir3 = params.homeDir ?? homedir5();
|
|
43563
|
+
const dir = join26(agentGlobalSkillsDir(params.agent, homeDir3), params.skill);
|
|
43109
43564
|
const result = writeManagedSkillDir(dir, params.skillMd, {
|
|
43110
43565
|
skill: params.skill,
|
|
43111
43566
|
source: params.source,
|
|
@@ -43122,8 +43577,8 @@ function writeManagedAgentSkill(params) {
|
|
|
43122
43577
|
};
|
|
43123
43578
|
}
|
|
43124
43579
|
function writeManagedSkillDir(dir, skillMd, options) {
|
|
43125
|
-
const skillMdPath =
|
|
43126
|
-
const markerPath =
|
|
43580
|
+
const skillMdPath = join26(dir, "SKILL.md");
|
|
43581
|
+
const markerPath = join26(dir, SYNC_MARKER_FILE);
|
|
43127
43582
|
const dirExists = existsSync10(dir);
|
|
43128
43583
|
const managed = hasSkillsOwnershipMarker(dir);
|
|
43129
43584
|
const hasSkillMd = existsSync10(skillMdPath);
|
|
@@ -43159,13 +43614,13 @@ function writeManagedSkillDir(dir, skillMd, options) {
|
|
|
43159
43614
|
const action = dirExists ? "update" : "create";
|
|
43160
43615
|
if (options.dryRun)
|
|
43161
43616
|
return { action, path: skillMdPath };
|
|
43162
|
-
const parentDir =
|
|
43617
|
+
const parentDir = dirname18(dir);
|
|
43163
43618
|
mkdirSync8(parentDir, { recursive: true });
|
|
43164
|
-
const transactionDir = mkdtempSync2(
|
|
43165
|
-
const candidateDir =
|
|
43166
|
-
const backupDir =
|
|
43167
|
-
const candidateSkillMdPath =
|
|
43168
|
-
const candidateMarkerPath =
|
|
43619
|
+
const transactionDir = mkdtempSync2(join26(parentDir, `.hasna-skills-write-${basename10(dir)}-`));
|
|
43620
|
+
const candidateDir = join26(transactionDir, "candidate");
|
|
43621
|
+
const backupDir = join26(transactionDir, "backup");
|
|
43622
|
+
const candidateSkillMdPath = join26(candidateDir, "SKILL.md");
|
|
43623
|
+
const candidateMarkerPath = join26(candidateDir, SYNC_MARKER_FILE);
|
|
43169
43624
|
const marker = {
|
|
43170
43625
|
managedBy: SYNC_MARKER_MANAGED_BY,
|
|
43171
43626
|
skill: options.skill,
|
|
@@ -43181,10 +43636,10 @@ function writeManagedSkillDir(dir, skillMd, options) {
|
|
|
43181
43636
|
} else {
|
|
43182
43637
|
mkdirSync8(candidateDir, { recursive: true });
|
|
43183
43638
|
}
|
|
43184
|
-
|
|
43639
|
+
writeFileSync7(candidateSkillMdPath, skillMd.endsWith(`
|
|
43185
43640
|
`) ? skillMd : `${skillMd}
|
|
43186
43641
|
`);
|
|
43187
|
-
|
|
43642
|
+
writeFileSync7(candidateMarkerPath, `${JSON.stringify(marker, null, 2)}
|
|
43188
43643
|
`);
|
|
43189
43644
|
if (dirExists) {
|
|
43190
43645
|
originalMoved = true;
|
|
@@ -43213,8 +43668,8 @@ function writeManagedSkillDir(dir, skillMd, options) {
|
|
|
43213
43668
|
}
|
|
43214
43669
|
return { action, path: skillMdPath };
|
|
43215
43670
|
}
|
|
43216
|
-
function removeManagedAgentSkill(skill, agent, homeDir3 =
|
|
43217
|
-
const dir =
|
|
43671
|
+
function removeManagedAgentSkill(skill, agent, homeDir3 = homedir5()) {
|
|
43672
|
+
const dir = join26(agentGlobalSkillsDir(agent, homeDir3), skill);
|
|
43218
43673
|
if (!hasSkillsOwnershipMarker(dir))
|
|
43219
43674
|
return false;
|
|
43220
43675
|
rmSync3(dir, { recursive: true, force: true });
|
|
@@ -43222,7 +43677,7 @@ function removeManagedAgentSkill(skill, agent, homeDir3 = homedir4()) {
|
|
|
43222
43677
|
}
|
|
43223
43678
|
function sourceSkillMd(skillPath, name, description, kind, preferBundledDocs = false) {
|
|
43224
43679
|
if (kind === undefined || kind === "instruction" || preferBundledDocs) {
|
|
43225
|
-
const skillMdPath =
|
|
43680
|
+
const skillMdPath = join26(skillPath, "SKILL.md");
|
|
43226
43681
|
if (existsSync10(skillMdPath))
|
|
43227
43682
|
return readFileSync16(skillMdPath, "utf-8");
|
|
43228
43683
|
}
|
|
@@ -43255,7 +43710,7 @@ function normalizeSkillName(name) {
|
|
|
43255
43710
|
|
|
43256
43711
|
// src/lib/registry.ts
|
|
43257
43712
|
import { existsSync as existsSync11, readFileSync as readFileSync17, readdirSync as readdirSync11 } from "fs";
|
|
43258
|
-
import { join as
|
|
43713
|
+
import { join as join27 } from "path";
|
|
43259
43714
|
|
|
43260
43715
|
// src/lib/registry-merge.ts
|
|
43261
43716
|
var SKILL_SOURCE_PRECEDENCE = {
|
|
@@ -43465,7 +43920,7 @@ function discoverSkillsInDir(dir, source = "custom") {
|
|
|
43465
43920
|
for (const entry of entries) {
|
|
43466
43921
|
if (!entry.isDirectory())
|
|
43467
43922
|
continue;
|
|
43468
|
-
const skillMdPath =
|
|
43923
|
+
const skillMdPath = join27(dir, entry.name, "SKILL.md");
|
|
43469
43924
|
if (!existsSync11(skillMdPath))
|
|
43470
43925
|
continue;
|
|
43471
43926
|
let content;
|
|
@@ -43485,7 +43940,7 @@ function discoverSkillsInDir(dir, source = "custom") {
|
|
|
43485
43940
|
category: fm.category || "Development Tools",
|
|
43486
43941
|
tags: fm.tags || [],
|
|
43487
43942
|
...fm.kind ? { kind: fm.kind } : {},
|
|
43488
|
-
...isHostedMetadataSkillDir(
|
|
43943
|
+
...isHostedMetadataSkillDir(join27(dir, entry.name)) ? { serverOwned: true } : {},
|
|
43489
43944
|
source
|
|
43490
43945
|
});
|
|
43491
43946
|
}
|
|
@@ -43501,8 +43956,8 @@ function findExtensionSkillPath(name) {
|
|
|
43501
43956
|
for (const entry of entries) {
|
|
43502
43957
|
if (!entry.isDirectory())
|
|
43503
43958
|
continue;
|
|
43504
|
-
const skillDir =
|
|
43505
|
-
const skillMdPath =
|
|
43959
|
+
const skillDir = join27(config.extensionsDir, entry.name);
|
|
43960
|
+
const skillMdPath = join27(skillDir, "SKILL.md");
|
|
43506
43961
|
if (!existsSync11(skillMdPath))
|
|
43507
43962
|
continue;
|
|
43508
43963
|
let content;
|
|
@@ -43572,8 +44027,8 @@ function getAllTags() {
|
|
|
43572
44027
|
}
|
|
43573
44028
|
|
|
43574
44029
|
// src/lib/project-state.ts
|
|
43575
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync18, writeFileSync as
|
|
43576
|
-
import { join as
|
|
44030
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "fs";
|
|
44031
|
+
import { join as join28 } from "path";
|
|
43577
44032
|
var VALID_PIN_SOURCES = [
|
|
43578
44033
|
"official",
|
|
43579
44034
|
"custom",
|
|
@@ -43588,10 +44043,10 @@ var SKILLS_PROJECT_DIR = ".skills";
|
|
|
43588
44043
|
var PROJECT_CONFIG_FILE = "project.json";
|
|
43589
44044
|
var DEFAULT_EXPORT_DIR = ".skills/exports";
|
|
43590
44045
|
function getProjectStateDir(targetDir = process.cwd()) {
|
|
43591
|
-
return
|
|
44046
|
+
return join28(targetDir, SKILLS_PROJECT_DIR);
|
|
43592
44047
|
}
|
|
43593
44048
|
function getProjectConfigPath(targetDir = process.cwd()) {
|
|
43594
|
-
return
|
|
44049
|
+
return join28(getProjectStateDir(targetDir), PROJECT_CONFIG_FILE);
|
|
43595
44050
|
}
|
|
43596
44051
|
function loadProjectConfig(targetDir = process.cwd()) {
|
|
43597
44052
|
const path = getProjectConfigPath(targetDir);
|
|
@@ -43621,7 +44076,7 @@ function saveProjectConfig(config, targetDir = process.cwd()) {
|
|
|
43621
44076
|
const dir = getProjectStateDir(targetDir);
|
|
43622
44077
|
mkdirSync9(dir, { recursive: true });
|
|
43623
44078
|
const normalized = normalizeProjectConfig({ ...config, updatedAt: new Date().toISOString() });
|
|
43624
|
-
|
|
44079
|
+
writeFileSync8(getProjectConfigPath(targetDir), JSON.stringify(normalized, null, 2) + `
|
|
43625
44080
|
`);
|
|
43626
44081
|
}
|
|
43627
44082
|
function pinProjectSkill(name, details = {}, targetDir = process.cwd()) {
|
|
@@ -43720,7 +44175,7 @@ function getSkillPath(name) {
|
|
|
43720
44175
|
const extensionPath = findExtensionSkillPath(skillName);
|
|
43721
44176
|
if (extensionPath)
|
|
43722
44177
|
return extensionPath;
|
|
43723
|
-
return
|
|
44178
|
+
return join29(getPortableSkillsRoot(), skillName);
|
|
43724
44179
|
}
|
|
43725
44180
|
function getCanonicalSkillName(name) {
|
|
43726
44181
|
return getSkill(name)?.name ?? resolveSkillAlias(normalizeSkillSlug(name));
|
|
@@ -43783,7 +44238,7 @@ function createLocalSkillManifest(name, generateSkillMd) {
|
|
|
43783
44238
|
if (!existsSync13(sourcePath))
|
|
43784
44239
|
return null;
|
|
43785
44240
|
let skillMd = "";
|
|
43786
|
-
const skillMdPath =
|
|
44241
|
+
const skillMdPath = join29(sourcePath, "SKILL.md");
|
|
43787
44242
|
if (existsSync13(skillMdPath)) {
|
|
43788
44243
|
skillMd = readFileSync19(skillMdPath, "utf-8");
|
|
43789
44244
|
} else if (generateSkillMd) {
|
|
@@ -43857,16 +44312,16 @@ function getAgentSkillsDir(agent, scope = "global", projectDir) {
|
|
|
43857
44312
|
const base = projectDir || process.cwd();
|
|
43858
44313
|
switch (agent) {
|
|
43859
44314
|
case "pi":
|
|
43860
|
-
return scope === "project" ?
|
|
44315
|
+
return scope === "project" ? join29(base, ".pi", "skills") : join29(homedir6(), ".pi", "agent", "skills");
|
|
43861
44316
|
case "opencode":
|
|
43862
|
-
return scope === "project" ?
|
|
44317
|
+
return scope === "project" ? join29(base, ".opencode", "skills") : join29(homedir6(), ".config", "opencode", "skills");
|
|
43863
44318
|
default:
|
|
43864
|
-
return scope === "project" ?
|
|
44319
|
+
return scope === "project" ? join29(base, `.${agent}`, "skills") : join29(homedir6(), `.${agent}`, "skills");
|
|
43865
44320
|
}
|
|
43866
44321
|
}
|
|
43867
44322
|
function getAgentSkillPath(name, agent, scope = "global", projectDir) {
|
|
43868
44323
|
const skillName = normalizeSkillName(getCanonicalSkillName(name));
|
|
43869
|
-
return
|
|
44324
|
+
return join29(getAgentSkillsDir(agent, scope, projectDir), skillName);
|
|
43870
44325
|
}
|
|
43871
44326
|
function installSkillForAgent(name, options, generateSkillMd) {
|
|
43872
44327
|
assertNativeExportAllowed();
|
|
@@ -43902,7 +44357,7 @@ function removeSkillForAgent(name, options) {
|
|
|
43902
44357
|
}
|
|
43903
44358
|
function resolveAgentSkillMd(name, generateSkillMd) {
|
|
43904
44359
|
const sourcePath = getSkillPath(name);
|
|
43905
|
-
const skillMdPath =
|
|
44360
|
+
const skillMdPath = join29(sourcePath, "SKILL.md");
|
|
43906
44361
|
if (existsSync13(skillMdPath))
|
|
43907
44362
|
return readFileSync19(skillMdPath, "utf-8");
|
|
43908
44363
|
if (generateSkillMd)
|
|
@@ -43937,7 +44392,7 @@ function generateMinimalSkillMd(name) {
|
|
|
43937
44392
|
"---",
|
|
43938
44393
|
""
|
|
43939
44394
|
].filter(Boolean);
|
|
43940
|
-
const fallbackDoc = readFileIfExists(
|
|
44395
|
+
const fallbackDoc = readFileIfExists(join29(sourcePath, "README.md")) || readFileIfExists(join29(sourcePath, "CLAUDE.md"));
|
|
43941
44396
|
if (fallbackDoc)
|
|
43942
44397
|
return `${frontmatter.join(`
|
|
43943
44398
|
`)}${fallbackDoc.trim()}
|
|
@@ -43956,7 +44411,7 @@ skills run ${canonicalName}
|
|
|
43956
44411
|
`;
|
|
43957
44412
|
}
|
|
43958
44413
|
function readBundledSkillVersion(name) {
|
|
43959
|
-
const pkgPath =
|
|
44414
|
+
const pkgPath = join29(getSkillPath(name), "package.json");
|
|
43960
44415
|
if (!existsSync13(pkgPath))
|
|
43961
44416
|
return "unknown";
|
|
43962
44417
|
try {
|
|
@@ -44011,7 +44466,7 @@ function selectSkillDoc(docs, file) {
|
|
|
44011
44466
|
function isInstructionSkillDir(skillPath, meta) {
|
|
44012
44467
|
if (meta?.kind === "instruction")
|
|
44013
44468
|
return true;
|
|
44014
|
-
const skillMdPath =
|
|
44469
|
+
const skillMdPath = join30(skillPath, "SKILL.md");
|
|
44015
44470
|
if (!existsSync14(skillMdPath))
|
|
44016
44471
|
return false;
|
|
44017
44472
|
try {
|
|
@@ -44041,9 +44496,9 @@ function getSkillDocs(name) {
|
|
|
44041
44496
|
if (!existsSync14(skillPath))
|
|
44042
44497
|
return null;
|
|
44043
44498
|
return {
|
|
44044
|
-
skillMd: readIfExists(
|
|
44045
|
-
readme: readIfExists(
|
|
44046
|
-
claudeMd: readIfExists(
|
|
44499
|
+
skillMd: readIfExists(join30(skillPath, "SKILL.md")),
|
|
44500
|
+
readme: readIfExists(join30(skillPath, "README.md")),
|
|
44501
|
+
claudeMd: readIfExists(join30(skillPath, "CLAUDE.md"))
|
|
44047
44502
|
};
|
|
44048
44503
|
}
|
|
44049
44504
|
function getSkillBestDoc(name, file) {
|
|
@@ -44059,14 +44514,14 @@ function getSkillRequirements(name) {
|
|
|
44059
44514
|
return null;
|
|
44060
44515
|
const texts = [];
|
|
44061
44516
|
for (const file of ["SKILL.md", "README.md", "CLAUDE.md", ".env.example", ".env.local.example"]) {
|
|
44062
|
-
const content = readIfExists(
|
|
44517
|
+
const content = readIfExists(join30(skillPath, file));
|
|
44063
44518
|
if (content)
|
|
44064
44519
|
texts.push(content);
|
|
44065
44520
|
}
|
|
44066
44521
|
const meta = getSkill(name);
|
|
44067
44522
|
let dependencies = {};
|
|
44068
44523
|
try {
|
|
44069
|
-
dependencies = JSON.parse(readFileSync20(
|
|
44524
|
+
dependencies = JSON.parse(readFileSync20(join30(skillPath, "package.json"), "utf8")).dependencies || {};
|
|
44070
44525
|
} catch {}
|
|
44071
44526
|
return getSkillRequirementsFromContent(name, texts, dependencies, meta);
|
|
44072
44527
|
}
|
|
@@ -44128,7 +44583,7 @@ async function runSkill(name, args, options = {}) {
|
|
|
44128
44583
|
error: `Skill '${name}' is an instruction skill (kind: instruction) and is not runnable. Instruction skills are consumed by coding agents via SKILL.md, not executed with 'skills run'.`
|
|
44129
44584
|
};
|
|
44130
44585
|
}
|
|
44131
|
-
const pkgPath =
|
|
44586
|
+
const pkgPath = join30(skillPath, "package.json");
|
|
44132
44587
|
if (!existsSync14(pkgPath)) {
|
|
44133
44588
|
return { exitCode: 1, error: `No package.json in skill '${name}'` };
|
|
44134
44589
|
}
|
|
@@ -44148,12 +44603,12 @@ async function runSkill(name, args, options = {}) {
|
|
|
44148
44603
|
} catch {
|
|
44149
44604
|
return { exitCode: 1, error: `Failed to parse package.json for skill '${name}'` };
|
|
44150
44605
|
}
|
|
44151
|
-
const entryPath =
|
|
44606
|
+
const entryPath = join30(skillPath, entryPoint2);
|
|
44152
44607
|
if (!existsSync14(entryPath)) {
|
|
44153
44608
|
return { exitCode: 1, error: `Entry point '${entryPoint2}' not found in skill '${name}'` };
|
|
44154
44609
|
}
|
|
44155
44610
|
const env = { ...process.env, ...options.env };
|
|
44156
|
-
if (!existsSync14(
|
|
44611
|
+
if (!existsSync14(join30(skillPath, "node_modules")) || hasDependencyPreparationMarker(skillPath)) {
|
|
44157
44612
|
const failure = await prepareSkillDependencies(skillPath, env, options.preparationTimeoutMs);
|
|
44158
44613
|
if (failure)
|
|
44159
44614
|
return failure;
|
|
@@ -44231,10 +44686,10 @@ function generateSkillMd(name) {
|
|
|
44231
44686
|
"---"
|
|
44232
44687
|
].join(`
|
|
44233
44688
|
`);
|
|
44234
|
-
const readme = readIfExists(
|
|
44235
|
-
const claudeMd = readIfExists(
|
|
44689
|
+
const readme = readIfExists(join30(skillPath, "README.md"));
|
|
44690
|
+
const claudeMd = readIfExists(join30(skillPath, "CLAUDE.md"));
|
|
44236
44691
|
let cliCommand = null;
|
|
44237
|
-
const pkgPath =
|
|
44692
|
+
const pkgPath = join30(skillPath, "package.json");
|
|
44238
44693
|
if (existsSync14(pkgPath)) {
|
|
44239
44694
|
try {
|
|
44240
44695
|
const pkg = JSON.parse(readFileSync20(pkgPath, "utf-8"));
|
|
@@ -44516,7 +44971,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
44516
44971
|
throw new SkillSelectionError("INVALID_SECRET_BINDINGS", "Explicit environment values must be bounded strings without NUL bytes.");
|
|
44517
44972
|
secretEnv[name] = value;
|
|
44518
44973
|
}
|
|
44519
|
-
const runDirectory = mkdtempSync3(
|
|
44974
|
+
const runDirectory = mkdtempSync3(join31(tmpdir(), "skills-execution-"));
|
|
44520
44975
|
const paths = new SkillEntryPaths;
|
|
44521
44976
|
for (const entry of entries) {
|
|
44522
44977
|
paths.add(entry.path, 100, () => {
|
|
@@ -44524,12 +44979,12 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
44524
44979
|
}, () => {
|
|
44525
44980
|
throw new SkillSelectionError("INVALID_BUNDLE_PATH", "The execution bundle path exceeds its limit.");
|
|
44526
44981
|
});
|
|
44527
|
-
const destination =
|
|
44528
|
-
mkdirSync10(
|
|
44529
|
-
|
|
44982
|
+
const destination = join31(runDirectory, entry.path);
|
|
44983
|
+
mkdirSync10(dirname19(destination), { recursive: true, mode: 448 });
|
|
44984
|
+
writeFileSync9(destination, entry.bytes, { flag: "wx", mode: entry.mode & 511 });
|
|
44530
44985
|
}
|
|
44531
44986
|
env.SKILLS_INPUT_JSON = input;
|
|
44532
|
-
env.SKILLS_WORKSPACE_DIR =
|
|
44987
|
+
env.SKILLS_WORKSPACE_DIR = resolve17(options.cwd ?? process.cwd());
|
|
44533
44988
|
env.SKILLS_RUN_DIR = runDirectory;
|
|
44534
44989
|
if (runtime.version) {
|
|
44535
44990
|
const version = await subprocess([executable, ...runtimeName === "bun" ? ["--no-env-file"] : [], "--version"], runDirectory, env, "", Math.min(timeoutMs, 5000));
|
|
@@ -44542,7 +44997,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
44542
44997
|
const { authority: authority2, workspaceId, profileRevision, slug, version, bundleDigest } = selection2;
|
|
44543
44998
|
const request2 = {
|
|
44544
44999
|
selection: { authority: authority2, workspaceId, profileId, profileRevision, slug, version, bundleDigest },
|
|
44545
|
-
consumer: { stationId: process.env.HASNA_STATION || stationHostname2(), workspaceDirectory:
|
|
45000
|
+
consumer: { stationId: process.env.HASNA_STATION || stationHostname2(), workspaceDirectory: realpathSync8(options.cwd ?? process.cwd()) }
|
|
44546
45001
|
};
|
|
44547
45002
|
const grant = await (options.resolveExecutionGrant ?? resolveExecutionGrant)(request2);
|
|
44548
45003
|
if (!grant || !grantIdentifier(grant.policyRevision) || !grantIdentifier(grant.grantId))
|
|
@@ -44552,20 +45007,20 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
44552
45007
|
}
|
|
44553
45008
|
if (bindings)
|
|
44554
45009
|
secretEnv = await resolveSelectedSecrets(bindings, options.createSecretsClient);
|
|
44555
|
-
const result = await subprocess([executable, ...runtimeName === "bun" ? ["--no-env-file"] : [],
|
|
45010
|
+
const result = await subprocess([executable, ...runtimeName === "bun" ? ["--no-env-file"] : [], join31(runDirectory, declaredEntry), ...args], runDirectory, { ...env, ...secretEnv }, input, timeoutMs);
|
|
44556
45011
|
result.stdout = redactExecutionSecrets(result.stdout, secretEnv);
|
|
44557
45012
|
result.stderr = redactExecutionSecrets(result.stderr, secretEnv);
|
|
44558
45013
|
const receipt = {
|
|
44559
45014
|
selection: selection2,
|
|
44560
45015
|
target: "local",
|
|
44561
45016
|
runtime: runtimeName,
|
|
44562
|
-
inputDigest: `sha256:${
|
|
45017
|
+
inputDigest: `sha256:${createHash18("sha256").update(input).digest("hex")}`,
|
|
44563
45018
|
runDirectory,
|
|
44564
45019
|
...executionGrant ? { executionGrant } : {},
|
|
44565
45020
|
...bindings ? { secretBinding: { schema: bindings.schema, selection: bindings.selection, consumer: bindings.consumer, secretsAuthority: bindings.secretsAuthority, bindings: bindings.bindings } } : {},
|
|
44566
45021
|
...result
|
|
44567
45022
|
};
|
|
44568
|
-
|
|
45023
|
+
writeFileSync9(join31(runDirectory, ".execution-receipt.json"), JSON.stringify({ ...receipt, stdout: undefined, stderr: undefined }), { mode: 384 });
|
|
44569
45024
|
return receipt;
|
|
44570
45025
|
}
|
|
44571
45026
|
async function subprocess(command, cwd, env, input, timeoutMs) {
|
|
@@ -45684,7 +46139,7 @@ var $resolveS3Config = resolveS3Config;
|
|
|
45684
46139
|
// node_modules/@aws-sdk/client-s3/dist-es/S3Client.js
|
|
45685
46140
|
var import_core = __toESM(require_dist_cjs2(), 1);
|
|
45686
46141
|
var import_client27 = __toESM(require_client(), 1);
|
|
45687
|
-
var
|
|
46142
|
+
var import_config37 = __toESM(require_config(), 1);
|
|
45688
46143
|
var import_endpoints5 = __toESM(require_endpoints(), 1);
|
|
45689
46144
|
var import_event_streams2 = __toESM(require_event_streams(), 1);
|
|
45690
46145
|
var import_protocols6 = __toESM(require_protocols(), 1);
|
|
@@ -53687,21 +54142,21 @@ var import_httpAuthSchemes3 = __toESM(require_httpAuthSchemes(), 1);
|
|
|
53687
54142
|
|
|
53688
54143
|
// node_modules/@aws-sdk/credential-provider-node/dist-es/defaultProvider.js
|
|
53689
54144
|
init_dist_es();
|
|
53690
|
-
var
|
|
54145
|
+
var import_config35 = __toESM(require_config(), 1);
|
|
53691
54146
|
|
|
53692
54147
|
// node_modules/@aws-sdk/credential-provider-node/dist-es/remoteProvider.js
|
|
53693
|
-
var
|
|
54148
|
+
var import_config18 = __toESM(require_config(), 1);
|
|
53694
54149
|
var ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
|
|
53695
54150
|
var remoteProvider = async (init) => {
|
|
53696
54151
|
const { ENV_CMDS_FULL_URI: ENV_CMDS_FULL_URI2, ENV_CMDS_RELATIVE_URI: ENV_CMDS_RELATIVE_URI2, fromContainerMetadata: fromContainerMetadata2, fromInstanceMetadata: fromInstanceMetadata2 } = await Promise.resolve().then(() => (init_dist_es2(), exports_dist_es2));
|
|
53697
54152
|
if (process.env[ENV_CMDS_RELATIVE_URI2] || process.env[ENV_CMDS_FULL_URI2]) {
|
|
53698
54153
|
init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromHttp/fromContainerMetadata");
|
|
53699
54154
|
const { fromHttp: fromHttp2 } = await Promise.resolve().then(() => (init_dist_es3(), exports_dist_es3));
|
|
53700
|
-
return
|
|
54155
|
+
return import_config18.chain(fromHttp2(init), fromContainerMetadata2(init));
|
|
53701
54156
|
}
|
|
53702
54157
|
if (process.env[ENV_IMDS_DISABLED] && process.env[ENV_IMDS_DISABLED] !== "false") {
|
|
53703
54158
|
return async () => {
|
|
53704
|
-
throw new
|
|
54159
|
+
throw new import_config18.CredentialsProviderError("EC2 Instance Metadata Service access disabled", { logger: init.logger });
|
|
53705
54160
|
};
|
|
53706
54161
|
}
|
|
53707
54162
|
init.logger?.debug("@aws-sdk/credential-provider-node - remoteProvider::fromInstanceMetadata");
|
|
@@ -53776,7 +54231,7 @@ var internalCreateChain = (providers) => async (awsIdentityProperties) => {
|
|
|
53776
54231
|
var multipleCredentialSourceWarningEmitted = false;
|
|
53777
54232
|
var defaultProvider = (init = {}) => memoizeChain([
|
|
53778
54233
|
async () => {
|
|
53779
|
-
const profile = init.profile ?? process.env[
|
|
54234
|
+
const profile = init.profile ?? process.env[import_config35.ENV_PROFILE];
|
|
53780
54235
|
if (profile) {
|
|
53781
54236
|
const envStaticCredentialsAreSet = process.env[ENV_KEY] && process.env[ENV_SECRET];
|
|
53782
54237
|
if (envStaticCredentialsAreSet) {
|
|
@@ -53794,7 +54249,7 @@ var defaultProvider = (init = {}) => memoizeChain([
|
|
|
53794
54249
|
multipleCredentialSourceWarningEmitted = true;
|
|
53795
54250
|
}
|
|
53796
54251
|
}
|
|
53797
|
-
throw new
|
|
54252
|
+
throw new import_config35.CredentialsProviderError("AWS_PROFILE is set, skipping fromEnv provider.", {
|
|
53798
54253
|
logger: init.logger,
|
|
53799
54254
|
tryNextLink: true
|
|
53800
54255
|
});
|
|
@@ -53806,7 +54261,7 @@ var defaultProvider = (init = {}) => memoizeChain([
|
|
|
53806
54261
|
init.logger?.debug("@aws-sdk/credential-provider-node - defaultProvider::fromSSO");
|
|
53807
54262
|
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
53808
54263
|
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
|
|
53809
|
-
throw new
|
|
54264
|
+
throw new import_config35.CredentialsProviderError("Skipping SSO provider in default chain (inputs do not include SSO fields).", { logger: init.logger });
|
|
53810
54265
|
}
|
|
53811
54266
|
const { fromSSO: fromSSO2 } = await Promise.resolve().then(() => (init_dist_es5(), exports_dist_es4));
|
|
53812
54267
|
return fromSSO2(init)(awsIdentityProperties);
|
|
@@ -53831,7 +54286,7 @@ var defaultProvider = (init = {}) => memoizeChain([
|
|
|
53831
54286
|
return (await remoteProvider(init))();
|
|
53832
54287
|
},
|
|
53833
54288
|
async () => {
|
|
53834
|
-
throw new
|
|
54289
|
+
throw new import_config35.CredentialsProviderError("Could not load credentials from any providers", {
|
|
53835
54290
|
tryNextLink: false,
|
|
53836
54291
|
logger: init.logger
|
|
53837
54292
|
});
|
|
@@ -53841,7 +54296,7 @@ var credentialsTreatedAsExpired = (credentials) => credentials?.expiration !== u
|
|
|
53841
54296
|
// node_modules/@aws-sdk/client-s3/dist-es/runtimeConfig.js
|
|
53842
54297
|
var import_checksum2 = __toESM(require_checksum(), 1);
|
|
53843
54298
|
var import_client23 = __toESM(require_client(), 1);
|
|
53844
|
-
var
|
|
54299
|
+
var import_config36 = __toESM(require_config(), 1);
|
|
53845
54300
|
var import_event_streams = __toESM(require_event_streams(), 1);
|
|
53846
54301
|
var import_retry3 = __toESM(require_retry(), 1);
|
|
53847
54302
|
var import_serde4 = __toESM(require_serde(), 1);
|
|
@@ -53849,7 +54304,7 @@ var import_node_http_handler2 = __toESM(require_dist_cjs6(), 1);
|
|
|
53849
54304
|
|
|
53850
54305
|
// node_modules/@aws-sdk/checksums/dist-cjs/submodules/sha/index.js
|
|
53851
54306
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde();
|
|
53852
|
-
var { createHmac: createHmac2, createHash:
|
|
54307
|
+
var { createHmac: createHmac2, createHash: createHash20 } = __require("crypto");
|
|
53853
54308
|
var { Sha256: Sha2562, Sha256Js, Sha256Node } = require_checksum();
|
|
53854
54309
|
var BLOCK2 = 64;
|
|
53855
54310
|
var DIGEST_LENGTH = 20;
|
|
@@ -54018,7 +54473,7 @@ class Sha1Js {
|
|
|
54018
54473
|
}
|
|
54019
54474
|
var hasNativeCrypto = (() => {
|
|
54020
54475
|
try {
|
|
54021
|
-
|
|
54476
|
+
createHash20("sha1");
|
|
54022
54477
|
return true;
|
|
54023
54478
|
} catch {
|
|
54024
54479
|
return false;
|
|
@@ -54058,7 +54513,7 @@ function buildNativeClass() {
|
|
|
54058
54513
|
this.finished = false;
|
|
54059
54514
|
}
|
|
54060
54515
|
createHash() {
|
|
54061
|
-
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) :
|
|
54516
|
+
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) : createHash20("sha1");
|
|
54062
54517
|
}
|
|
54063
54518
|
};
|
|
54064
54519
|
}
|
|
@@ -54131,7 +54586,7 @@ var getRuntimeConfig2 = (config) => {
|
|
|
54131
54586
|
// node_modules/@aws-sdk/client-s3/dist-es/runtimeConfig.js
|
|
54132
54587
|
var getRuntimeConfig3 = (config) => {
|
|
54133
54588
|
import_client23.emitWarningIfUnsupportedVersion(process.version);
|
|
54134
|
-
const defaultsMode =
|
|
54589
|
+
const defaultsMode = import_config36.resolveDefaultsModeConfig(config);
|
|
54135
54590
|
const defaultConfigProvider = () => defaultsMode().then(import_client23.loadConfigsForDefaultMode);
|
|
54136
54591
|
const clientSharedValues = getRuntimeConfig2(config);
|
|
54137
54592
|
import_client22.emitWarningIfUnsupportedVersion(process.version);
|
|
@@ -54144,28 +54599,28 @@ var getRuntimeConfig3 = (config) => {
|
|
|
54144
54599
|
...config,
|
|
54145
54600
|
runtime: "node",
|
|
54146
54601
|
defaultsMode,
|
|
54147
|
-
authSchemePreference: config?.authSchemePreference ??
|
|
54602
|
+
authSchemePreference: config?.authSchemePreference ?? import_config36.loadConfig(import_httpAuthSchemes3.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
|
|
54148
54603
|
bodyLengthChecker: config?.bodyLengthChecker ?? import_serde4.calculateBodyLength,
|
|
54149
54604
|
credentialDefaultProvider: config?.credentialDefaultProvider ?? defaultProvider,
|
|
54150
54605
|
defaultUserAgentProvider: config?.defaultUserAgentProvider ?? import_client22.createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: package_default2.version }),
|
|
54151
|
-
disableS3ExpressSessionAuth: config?.disableS3ExpressSessionAuth ??
|
|
54606
|
+
disableS3ExpressSessionAuth: config?.disableS3ExpressSessionAuth ?? import_config36.loadConfig($NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, loaderConfig),
|
|
54152
54607
|
eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? import_event_streams.eventStreamSerdeProvider,
|
|
54153
|
-
maxAttempts: config?.maxAttempts ??
|
|
54154
|
-
region: config?.region ??
|
|
54155
|
-
requestChecksumCalculation: config?.requestChecksumCalculation ??
|
|
54608
|
+
maxAttempts: config?.maxAttempts ?? import_config36.loadConfig(import_retry3.NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
|
|
54609
|
+
region: config?.region ?? import_config36.loadConfig(import_config36.NODE_REGION_CONFIG_OPTIONS, { ...import_config36.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
|
|
54610
|
+
requestChecksumCalculation: config?.requestChecksumCalculation ?? import_config36.loadConfig($NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS, loaderConfig),
|
|
54156
54611
|
requestHandler: import_node_http_handler2.NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
|
|
54157
|
-
responseChecksumValidation: config?.responseChecksumValidation ??
|
|
54158
|
-
retryMode: config?.retryMode ??
|
|
54612
|
+
responseChecksumValidation: config?.responseChecksumValidation ?? import_config36.loadConfig($NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS, loaderConfig),
|
|
54613
|
+
retryMode: config?.retryMode ?? import_config36.loadConfig({
|
|
54159
54614
|
...import_retry3.NODE_RETRY_MODE_CONFIG_OPTIONS,
|
|
54160
54615
|
default: async () => (await defaultConfigProvider()).retryMode || import_retry3.DEFAULT_RETRY_MODE
|
|
54161
54616
|
}, config),
|
|
54162
|
-
sigv4aSigningRegionSet: config?.sigv4aSigningRegionSet ??
|
|
54617
|
+
sigv4aSigningRegionSet: config?.sigv4aSigningRegionSet ?? import_config36.loadConfig(import_httpAuthSchemes3.NODE_SIGV4A_CONFIG_OPTIONS, loaderConfig),
|
|
54163
54618
|
streamCollector: config?.streamCollector ?? import_node_http_handler2.streamCollector,
|
|
54164
54619
|
streamHasher: config?.streamHasher ?? import_checksum2.readableStreamHasher,
|
|
54165
|
-
useArnRegion: config?.useArnRegion ??
|
|
54166
|
-
useDualstackEndpoint: config?.useDualstackEndpoint ??
|
|
54167
|
-
useFipsEndpoint: config?.useFipsEndpoint ??
|
|
54168
|
-
userAgentAppId: config?.userAgentAppId ??
|
|
54620
|
+
useArnRegion: config?.useArnRegion ?? import_config36.loadConfig($NODE_USE_ARN_REGION_CONFIG_OPTIONS, loaderConfig),
|
|
54621
|
+
useDualstackEndpoint: config?.useDualstackEndpoint ?? import_config36.loadConfig(import_config36.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
54622
|
+
useFipsEndpoint: config?.useFipsEndpoint ?? import_config36.loadConfig(import_config36.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
54623
|
+
userAgentAppId: config?.userAgentAppId ?? import_config36.loadConfig(import_client22.NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
|
|
54169
54624
|
};
|
|
54170
54625
|
};
|
|
54171
54626
|
|
|
@@ -54231,7 +54686,7 @@ class S3Client extends import_client27.Client {
|
|
|
54231
54686
|
const _config_2 = import_client26.resolveUserAgentConfig(_config_1);
|
|
54232
54687
|
const _config_3 = $resolveFlexibleChecksumsConfig(_config_2);
|
|
54233
54688
|
const _config_4 = import_retry4.resolveRetryConfig(_config_3);
|
|
54234
|
-
const _config_5 =
|
|
54689
|
+
const _config_5 = import_config37.resolveRegionConfig(_config_4);
|
|
54235
54690
|
const _config_6 = import_client26.resolveHostHeaderConfig(_config_5);
|
|
54236
54691
|
const _config_7 = import_endpoints5.resolveEndpointConfig(_config_6);
|
|
54237
54692
|
const _config_8 = import_event_streams2.resolveEventStreamSerdeConfig(_config_7);
|
|
@@ -54627,10 +55082,10 @@ function assertReservationCents(value, field2) {
|
|
|
54627
55082
|
import { Database as Database2 } from "bun:sqlite";
|
|
54628
55083
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
54629
55084
|
import { mkdirSync as mkdirSync12 } from "fs";
|
|
54630
|
-
import { dirname as
|
|
55085
|
+
import { dirname as dirname23 } from "path";
|
|
54631
55086
|
|
|
54632
55087
|
// src/server/database-url.ts
|
|
54633
|
-
import { isAbsolute as isAbsolute17, join as
|
|
55088
|
+
import { isAbsolute as isAbsolute17, join as join33 } from "path";
|
|
54634
55089
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
54635
55090
|
var DEFAULT_SQLITE_FILENAME2 = "server.db";
|
|
54636
55091
|
var SQLITE_MEMORY_PATH = ":memory:";
|
|
@@ -54639,7 +55094,7 @@ var SQLITE_SCHEMES = new Set(["sqlite", "sqlite3", "file"]);
|
|
|
54639
55094
|
var MEMORY_SCHEMES = new Set(["memory"]);
|
|
54640
55095
|
var SQLITE_EXTENSIONS = [".db", ".sqlite", ".sqlite3", ".db3"];
|
|
54641
55096
|
function defaultSqlitePath() {
|
|
54642
|
-
return
|
|
55097
|
+
return join33(getDataDir(), DEFAULT_SQLITE_FILENAME2);
|
|
54643
55098
|
}
|
|
54644
55099
|
function resolveDatabaseTarget(raw) {
|
|
54645
55100
|
const value = raw?.trim();
|
|
@@ -54666,7 +55121,7 @@ function resolveDatabaseTarget(raw) {
|
|
|
54666
55121
|
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()}.`);
|
|
54667
55122
|
}
|
|
54668
55123
|
if (looksLikeSqlitePath(value)) {
|
|
54669
|
-
const path = isAbsolute17(value) ? value :
|
|
55124
|
+
const path = isAbsolute17(value) ? value : join33(process.cwd(), value);
|
|
54670
55125
|
return { kind: "sqlite", path, durable: true, label: `sqlite (${path})` };
|
|
54671
55126
|
}
|
|
54672
55127
|
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()}.`);
|
|
@@ -54690,7 +55145,7 @@ function sqlitePathFromUrl(value, scheme) {
|
|
|
54690
55145
|
}
|
|
54691
55146
|
return rest.slice(2).replace(/^\/\/+/, "/");
|
|
54692
55147
|
}
|
|
54693
|
-
return isAbsolute17(rest) ? rest :
|
|
55148
|
+
return isAbsolute17(rest) ? rest : join33(process.cwd(), rest);
|
|
54694
55149
|
}
|
|
54695
55150
|
function looksLikeSqlitePath(value) {
|
|
54696
55151
|
if (value.includes("/"))
|
|
@@ -54923,12 +55378,12 @@ class PostgresSkillSelectionStore {
|
|
|
54923
55378
|
// src/server/sqlite-store.ts
|
|
54924
55379
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
54925
55380
|
import { mkdirSync as mkdirSync11, readFileSync as readFileSync22, readdirSync as readdirSync12 } from "fs";
|
|
54926
|
-
import { dirname as
|
|
55381
|
+
import { dirname as dirname22, join as join35 } from "path";
|
|
54927
55382
|
|
|
54928
55383
|
// src/server/auth.ts
|
|
54929
|
-
import { createHash as
|
|
55384
|
+
import { createHash as createHash21 } from "crypto";
|
|
54930
55385
|
function hashApiKey(token) {
|
|
54931
|
-
return
|
|
55386
|
+
return createHash21("sha256").update(token).digest("hex");
|
|
54932
55387
|
}
|
|
54933
55388
|
function bearerToken(request2) {
|
|
54934
55389
|
const header = request2.headers.get("authorization") || "";
|
|
@@ -54957,24 +55412,24 @@ function publicPrincipal(partial = {}) {
|
|
|
54957
55412
|
function permitsSkillsRoute(principal, method, resource) {
|
|
54958
55413
|
const scopes = new Set(principal.scopes);
|
|
54959
55414
|
if (resource === "execution-grants") {
|
|
54960
|
-
const
|
|
54961
|
-
if (!
|
|
55415
|
+
const read4 = method === "GET" || method === "HEAD";
|
|
55416
|
+
if (!read4 && method !== "POST" && !["owner", "admin"].includes(principal.role))
|
|
54962
55417
|
return false;
|
|
54963
|
-
const allowed2 =
|
|
55418
|
+
const allowed2 = read4 ? ["*", "execution-grants:*", "execution-grants:read"] : method === "POST" ? ["*", "execution-grants:*", "execution-grants:resolve", "skills:read", "skills:*"] : ["*", "execution-grants:*", "execution-grants:write"];
|
|
54964
55419
|
return allowed2.some((scope) => scopes.has(scope));
|
|
54965
55420
|
}
|
|
54966
55421
|
if (scopes.has("*"))
|
|
54967
55422
|
return true;
|
|
54968
|
-
const
|
|
54969
|
-
if (resource === "capabilities" &&
|
|
55423
|
+
const read3 = method === "GET" || method === "HEAD";
|
|
55424
|
+
if (resource === "capabilities" && read3)
|
|
54970
55425
|
return true;
|
|
54971
55426
|
let allowed;
|
|
54972
55427
|
if (resource === "runs" || resource === "executions") {
|
|
54973
|
-
allowed =
|
|
55428
|
+
allowed = read3 ? ["runs:read", "runs:*", "skills:read", "skills:*"] : ["runs:write", "runs:*"];
|
|
54974
55429
|
} else if (resource === "stations") {
|
|
54975
|
-
allowed =
|
|
55430
|
+
allowed = read3 ? ["stations:read", "stations:*", "skills:read", "skills:*"] : ["stations:write", "stations:*", "skills:*"];
|
|
54976
55431
|
} else if (["skills", "pins", "tags", "profiles", "capabilities"].includes(resource)) {
|
|
54977
|
-
allowed =
|
|
55432
|
+
allowed = read3 ? ["skills:read", "skills:*"] : ["skills:write", "skills:publish", "skills:*"];
|
|
54978
55433
|
} else
|
|
54979
55434
|
return true;
|
|
54980
55435
|
return allowed.some((scope) => scopes.has(scope));
|
|
@@ -54982,17 +55437,17 @@ function permitsSkillsRoute(principal, method, resource) {
|
|
|
54982
55437
|
|
|
54983
55438
|
// src/server/migrations-dir.ts
|
|
54984
55439
|
import { existsSync as existsSync15 } from "fs";
|
|
54985
|
-
import { dirname as
|
|
55440
|
+
import { dirname as dirname21, join as join34 } from "path";
|
|
54986
55441
|
var MIGRATION_DIALECTS = ["postgres", "sqlite"];
|
|
54987
55442
|
var MAX_WALK_UP = 6;
|
|
54988
55443
|
function findMigrationsRoot(startDirs = defaultStartDirs()) {
|
|
54989
55444
|
for (const start of startDirs) {
|
|
54990
55445
|
let dir = start;
|
|
54991
55446
|
for (let level = 0;level < MAX_WALK_UP; level += 1) {
|
|
54992
|
-
const candidate2 =
|
|
54993
|
-
if (MIGRATION_DIALECTS.some((dialect) => existsSync15(
|
|
55447
|
+
const candidate2 = join34(dir, "migrations");
|
|
55448
|
+
if (MIGRATION_DIALECTS.some((dialect) => existsSync15(join34(candidate2, dialect))))
|
|
54994
55449
|
return candidate2;
|
|
54995
|
-
const parent =
|
|
55450
|
+
const parent = dirname21(dir);
|
|
54996
55451
|
if (parent === dir)
|
|
54997
55452
|
break;
|
|
54998
55453
|
dir = parent;
|
|
@@ -55004,7 +55459,7 @@ function resolveMigrationsDir(dialect, root4 = findMigrationsRoot()) {
|
|
|
55004
55459
|
if (!root4) {
|
|
55005
55460
|
throw new Error(`could not locate the migrations directory for dialect "${dialect}". ` + `Expected a migrations/${dialect}/ folder alongside the package root.`);
|
|
55006
55461
|
}
|
|
55007
|
-
const dir =
|
|
55462
|
+
const dir = join34(root4, dialect);
|
|
55008
55463
|
if (!existsSync15(dir)) {
|
|
55009
55464
|
throw new Error(`migrations directory not found: ${dir}`);
|
|
55010
55465
|
}
|
|
@@ -55238,7 +55693,7 @@ function validOperatorScopeEnrollmentInput(input) {
|
|
|
55238
55693
|
}
|
|
55239
55694
|
|
|
55240
55695
|
// src/lib/revision.ts
|
|
55241
|
-
import { createHash as
|
|
55696
|
+
import { createHash as createHash22 } from "crypto";
|
|
55242
55697
|
var REVISION_ID_PATTERN = /^[0-9a-f]{64}$/;
|
|
55243
55698
|
function revisionIdOf(content) {
|
|
55244
55699
|
const canonicalContent = {
|
|
@@ -55260,7 +55715,7 @@ function revisionIdOf(content) {
|
|
|
55260
55715
|
canonicalContent.replacementSlug = content.replacementSlug ?? null;
|
|
55261
55716
|
}
|
|
55262
55717
|
const canonical4 = JSON.stringify(canonicalContent);
|
|
55263
|
-
return
|
|
55718
|
+
return createHash22("sha256").update(canonical4).digest("hex");
|
|
55264
55719
|
}
|
|
55265
55720
|
function revisionIdOfRecord(record3) {
|
|
55266
55721
|
return revisionIdOf(record3);
|
|
@@ -55285,7 +55740,7 @@ class SqliteSkillsStore {
|
|
|
55285
55740
|
constructor(path = SQLITE_MEMORY_PATH, options = {}) {
|
|
55286
55741
|
const inMemory = path === SQLITE_MEMORY_PATH;
|
|
55287
55742
|
if (!inMemory)
|
|
55288
|
-
mkdirSync11(
|
|
55743
|
+
mkdirSync11(dirname22(path), { recursive: true });
|
|
55289
55744
|
this.db = openDatabase(path);
|
|
55290
55745
|
this.db.exec(`PRAGMA busy_timeout = ${Math.max(0, options.busyTimeoutMs ?? 5000)}`);
|
|
55291
55746
|
if (!inMemory)
|
|
@@ -55948,7 +56403,7 @@ function applySqliteMigrations(db, migrationsDir = resolveMigrationsDir("sqlite"
|
|
|
55948
56403
|
const appliedNow = [];
|
|
55949
56404
|
for (const file of files) {
|
|
55950
56405
|
const version2 = file.replace(/\.sql$/, "");
|
|
55951
|
-
const text2 = readFileSync22(
|
|
56406
|
+
const text2 = readFileSync22(join35(migrationsDir, file), "utf8");
|
|
55952
56407
|
const apply = db.transaction(() => {
|
|
55953
56408
|
const already = db.query("SELECT 1 AS present FROM schema_migrations WHERE version = ? LIMIT 1").get(version2);
|
|
55954
56409
|
if (already)
|
|
@@ -56095,7 +56550,7 @@ class SqliteGovernanceStore {
|
|
|
56095
56550
|
closed = false;
|
|
56096
56551
|
constructor(path = SQLITE_MEMORY_PATH, options = {}) {
|
|
56097
56552
|
if (path !== SQLITE_MEMORY_PATH)
|
|
56098
|
-
mkdirSync12(
|
|
56553
|
+
mkdirSync12(dirname23(path), { recursive: true });
|
|
56099
56554
|
this.db = new Database2(path, { create: true, readwrite: true });
|
|
56100
56555
|
this.db.exec("PRAGMA busy_timeout = 5000");
|
|
56101
56556
|
this.db.exec("PRAGMA foreign_keys = ON");
|
|
@@ -56328,7 +56783,7 @@ function nextMonthPrefix(monthPrefix) {
|
|
|
56328
56783
|
}
|
|
56329
56784
|
|
|
56330
56785
|
// src/server/skills-api.ts
|
|
56331
|
-
import { createHash as
|
|
56786
|
+
import { createHash as createHash23 } from "crypto";
|
|
56332
56787
|
var SLUG_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
56333
56788
|
var SHA256_HEX2 = /^[0-9a-f]{64}$/;
|
|
56334
56789
|
var MAX_SLUG_LENGTH = 128;
|
|
@@ -56518,7 +56973,7 @@ async function parsePublishRequest(request2, config) {
|
|
|
56518
56973
|
if (bundleBytes.byteLength === 0) {
|
|
56519
56974
|
throw new SkillRequestError(400, "BUNDLE_EMPTY", "the uploaded bundle is empty");
|
|
56520
56975
|
}
|
|
56521
|
-
const sha2562 =
|
|
56976
|
+
const sha2562 = createHash23("sha256").update(bundleBytes).digest("hex");
|
|
56522
56977
|
const claimed = optionalString(manifest.bundleSha256);
|
|
56523
56978
|
if (claimed)
|
|
56524
56979
|
assertSha2562(claimed);
|
|
@@ -56633,7 +57088,7 @@ async function readPublishedBundle(store, artifactStorage, principal, slug) {
|
|
|
56633
57088
|
if (!bytes) {
|
|
56634
57089
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
56635
57090
|
}
|
|
56636
|
-
const actual =
|
|
57091
|
+
const actual = createHash23("sha256").update(bytes).digest("hex");
|
|
56637
57092
|
if (actual !== record3.bundleSha256) {
|
|
56638
57093
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}' hashes to ${actual} but was published as ${record3.bundleSha256}`);
|
|
56639
57094
|
}
|
|
@@ -56781,7 +57236,7 @@ async function readSkillVersionBundle(store, artifactStorage, principal, slug, v
|
|
|
56781
57236
|
const bytes = await artifactStorage.readBundle(bundle2);
|
|
56782
57237
|
if (!bytes)
|
|
56783
57238
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
56784
|
-
const actual =
|
|
57239
|
+
const actual = createHash23("sha256").update(bytes).digest("hex");
|
|
56785
57240
|
if (actual !== found.bundleSha256) {
|
|
56786
57241
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}@${version2}' hashes to ${actual} but was published as ${found.bundleSha256}`);
|
|
56787
57242
|
}
|
|
@@ -57183,7 +57638,7 @@ async function handleProfileApi(store, principal, request2, parts, config) {
|
|
|
57183
57638
|
// src/server/runtime-store.ts
|
|
57184
57639
|
import { Database as Database3 } from "bun:sqlite";
|
|
57185
57640
|
import { mkdirSync as mkdirSync13 } from "fs";
|
|
57186
|
-
import { dirname as
|
|
57641
|
+
import { dirname as dirname24 } from "path";
|
|
57187
57642
|
|
|
57188
57643
|
// src/sdk/execution/types.ts
|
|
57189
57644
|
var EXECUTION_PROTOCOL_VERSION = REMOTE_SKILL_RUN_CONTRACT_VERSION;
|
|
@@ -57239,7 +57694,7 @@ class RuntimeExecutionStore {
|
|
|
57239
57694
|
}
|
|
57240
57695
|
const path = target.kind === "sqlite" ? target.path : ":memory:";
|
|
57241
57696
|
if (path !== ":memory:")
|
|
57242
|
-
mkdirSync13(
|
|
57697
|
+
mkdirSync13(dirname24(path), { recursive: true });
|
|
57243
57698
|
const db = new Database3(path);
|
|
57244
57699
|
db.run("PRAGMA busy_timeout=5000");
|
|
57245
57700
|
db.run("PRAGMA journal_mode=WAL");
|
|
@@ -57479,7 +57934,7 @@ class RuntimeExecutionStore {
|
|
|
57479
57934
|
}
|
|
57480
57935
|
|
|
57481
57936
|
// src/sdk/execution/admission.ts
|
|
57482
|
-
import { createHash as
|
|
57937
|
+
import { createHash as createHash25 } from "crypto";
|
|
57483
57938
|
|
|
57484
57939
|
// src/sdk/execution/image-profile.ts
|
|
57485
57940
|
class ImageProfileResolutionError extends Error {
|
|
@@ -58091,11 +58546,11 @@ function ownedAdmission(admission) {
|
|
|
58091
58546
|
};
|
|
58092
58547
|
}
|
|
58093
58548
|
function digestInput(input) {
|
|
58094
|
-
return
|
|
58549
|
+
return createHash25("sha256").update(canonicalJson2(input)).digest("hex");
|
|
58095
58550
|
}
|
|
58096
58551
|
|
|
58097
58552
|
// src/sdk/execution/dispatchers/ecs.ts
|
|
58098
|
-
import { createHash as
|
|
58553
|
+
import { createHash as createHash26 } from "crypto";
|
|
58099
58554
|
|
|
58100
58555
|
// src/sdk/execution/state-machine.ts
|
|
58101
58556
|
var LEGAL_TRANSITIONS = {
|
|
@@ -58263,7 +58718,7 @@ function createReceiptService(store) {
|
|
|
58263
58718
|
var import_client36 = __toESM(require_client2(), 1);
|
|
58264
58719
|
var import_core2 = __toESM(require_dist_cjs2(), 1);
|
|
58265
58720
|
var import_client37 = __toESM(require_client(), 1);
|
|
58266
|
-
var
|
|
58721
|
+
var import_config40 = __toESM(require_config(), 1);
|
|
58267
58722
|
var import_endpoints8 = __toESM(require_endpoints(), 1);
|
|
58268
58723
|
var import_protocols10 = __toESM(require_protocols(), 1);
|
|
58269
58724
|
var import_retry6 = __toESM(require_retry(), 1);
|
|
@@ -58402,7 +58857,7 @@ var package_default3 = {
|
|
|
58402
58857
|
var import_client32 = __toESM(require_client2(), 1);
|
|
58403
58858
|
var import_httpAuthSchemes6 = __toESM(require_httpAuthSchemes(), 1);
|
|
58404
58859
|
var import_client33 = __toESM(require_client(), 1);
|
|
58405
|
-
var
|
|
58860
|
+
var import_config39 = __toESM(require_config(), 1);
|
|
58406
58861
|
var import_retry5 = __toESM(require_retry(), 1);
|
|
58407
58862
|
var import_serde6 = __toESM(require_serde(), 1);
|
|
58408
58863
|
var import_node_http_handler3 = __toESM(require_dist_cjs6(), 1);
|
|
@@ -61344,7 +61799,7 @@ var getRuntimeConfig4 = (config) => {
|
|
|
61344
61799
|
// node_modules/@aws-sdk/client-ecs/dist-es/runtimeConfig.js
|
|
61345
61800
|
var getRuntimeConfig5 = (config) => {
|
|
61346
61801
|
import_client33.emitWarningIfUnsupportedVersion(process.version);
|
|
61347
|
-
const defaultsMode =
|
|
61802
|
+
const defaultsMode = import_config39.resolveDefaultsModeConfig(config);
|
|
61348
61803
|
const defaultConfigProvider = () => defaultsMode().then(import_client33.loadConfigsForDefaultMode);
|
|
61349
61804
|
const clientSharedValues = getRuntimeConfig4(config);
|
|
61350
61805
|
import_client32.emitWarningIfUnsupportedVersion(process.version);
|
|
@@ -61357,21 +61812,21 @@ var getRuntimeConfig5 = (config) => {
|
|
|
61357
61812
|
...config,
|
|
61358
61813
|
runtime: "node",
|
|
61359
61814
|
defaultsMode,
|
|
61360
|
-
authSchemePreference: config?.authSchemePreference ??
|
|
61815
|
+
authSchemePreference: config?.authSchemePreference ?? import_config39.loadConfig(import_httpAuthSchemes6.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
|
|
61361
61816
|
bodyLengthChecker: config?.bodyLengthChecker ?? import_serde6.calculateBodyLength,
|
|
61362
61817
|
credentialDefaultProvider: config?.credentialDefaultProvider ?? defaultProvider,
|
|
61363
61818
|
defaultUserAgentProvider: config?.defaultUserAgentProvider ?? import_client32.createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: package_default3.version }),
|
|
61364
|
-
maxAttempts: config?.maxAttempts ??
|
|
61365
|
-
region: config?.region ??
|
|
61819
|
+
maxAttempts: config?.maxAttempts ?? import_config39.loadConfig(import_retry5.NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
|
|
61820
|
+
region: config?.region ?? import_config39.loadConfig(import_config39.NODE_REGION_CONFIG_OPTIONS, { ...import_config39.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
|
|
61366
61821
|
requestHandler: import_node_http_handler3.NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
|
|
61367
|
-
retryMode: config?.retryMode ??
|
|
61822
|
+
retryMode: config?.retryMode ?? import_config39.loadConfig({
|
|
61368
61823
|
...import_retry5.NODE_RETRY_MODE_CONFIG_OPTIONS,
|
|
61369
61824
|
default: async () => (await defaultConfigProvider()).retryMode || import_retry5.DEFAULT_RETRY_MODE
|
|
61370
61825
|
}, config),
|
|
61371
61826
|
streamCollector: config?.streamCollector ?? import_node_http_handler3.streamCollector,
|
|
61372
|
-
useDualstackEndpoint: config?.useDualstackEndpoint ??
|
|
61373
|
-
useFipsEndpoint: config?.useFipsEndpoint ??
|
|
61374
|
-
userAgentAppId: config?.userAgentAppId ??
|
|
61827
|
+
useDualstackEndpoint: config?.useDualstackEndpoint ?? import_config39.loadConfig(import_config39.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
61828
|
+
useFipsEndpoint: config?.useFipsEndpoint ?? import_config39.loadConfig(import_config39.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
61829
|
+
userAgentAppId: config?.userAgentAppId ?? import_config39.loadConfig(import_client32.NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
|
|
61375
61830
|
};
|
|
61376
61831
|
};
|
|
61377
61832
|
|
|
@@ -61436,7 +61891,7 @@ class ECSClient extends import_client37.Client {
|
|
|
61436
61891
|
const _config_1 = resolveClientEndpointParameters3(_config_0);
|
|
61437
61892
|
const _config_2 = import_client36.resolveUserAgentConfig(_config_1);
|
|
61438
61893
|
const _config_3 = import_retry6.resolveRetryConfig(_config_2);
|
|
61439
|
-
const _config_4 =
|
|
61894
|
+
const _config_4 = import_config40.resolveRegionConfig(_config_3);
|
|
61440
61895
|
const _config_5 = import_client36.resolveHostHeaderConfig(_config_4);
|
|
61441
61896
|
const _config_6 = import_endpoints8.resolveEndpointConfig(_config_5);
|
|
61442
61897
|
const _config_7 = resolveHttpAuthSchemeConfig3(_config_6);
|
|
@@ -61495,13 +61950,13 @@ function observedTask(states, taskArn) {
|
|
|
61495
61950
|
return state2.lastStatus === "STOPPED" || LIVE_TASK_STATUSES.has(state2.lastStatus) ? state2 : undefined;
|
|
61496
61951
|
}
|
|
61497
61952
|
function clientTokenFor(runId3, attemptId) {
|
|
61498
|
-
return
|
|
61953
|
+
return createHash26("sha256").update(`${runId3}\x00${attemptId}`).digest("hex").slice(0, CLIENT_TOKEN_BYTES * 2);
|
|
61499
61954
|
}
|
|
61500
61955
|
function startedByFor(runId3, attemptNumber) {
|
|
61501
61956
|
return `skills-exec/${runId3}/a${attemptNumber}`;
|
|
61502
61957
|
}
|
|
61503
61958
|
function requestDigestFor(admission, attemptId) {
|
|
61504
|
-
return
|
|
61959
|
+
return createHash26("sha256").update(canonicalJson2({ admission, attemptId })).digest("hex");
|
|
61505
61960
|
}
|
|
61506
61961
|
|
|
61507
61962
|
class EcsDispatcher {
|
|
@@ -61797,10 +62252,10 @@ function validText(value) {
|
|
|
61797
62252
|
}
|
|
61798
62253
|
|
|
61799
62254
|
// src/server/runtime-policy.ts
|
|
61800
|
-
import { createHash as
|
|
62255
|
+
import { createHash as createHash28, createHmac as createHmac3, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
61801
62256
|
|
|
61802
62257
|
// src/server/runtime-pure-contract.ts
|
|
61803
|
-
import { createHash as
|
|
62258
|
+
import { createHash as createHash27 } from "crypto";
|
|
61804
62259
|
var PURE_DESCRIPTOR = Object.freeze({
|
|
61805
62260
|
id: "regex-test.v1",
|
|
61806
62261
|
runtime: "bun",
|
|
@@ -61824,7 +62279,7 @@ var PURE_LIMITS = Object.freeze({
|
|
|
61824
62279
|
maxArtifactsBytes: 0,
|
|
61825
62280
|
maxConcurrency: 1
|
|
61826
62281
|
});
|
|
61827
|
-
var hash2 = (bytes) =>
|
|
62282
|
+
var hash2 = (bytes) => createHash27("sha256").update(bytes).digest("hex");
|
|
61828
62283
|
var object5 = (v2) => {
|
|
61829
62284
|
if (!v2 || typeof v2 !== "object" || Array.isArray(v2))
|
|
61830
62285
|
throw Error("Pure contract requires an object");
|
|
@@ -61935,13 +62390,13 @@ async function inspectPureBundle(bytes, contract) {
|
|
|
61935
62390
|
throw Error("Pure entrypoint integrity failed");
|
|
61936
62391
|
if (entries.some((e5) => e5.path.split("/").includes("node_modules")))
|
|
61937
62392
|
throw Error("Pure bundle cannot supply dependencies");
|
|
61938
|
-
const
|
|
62393
|
+
const read3 = (name) => {
|
|
61939
62394
|
const entry2 = entries.find((e5) => e5.path === name);
|
|
61940
62395
|
if (!entry2)
|
|
61941
62396
|
throw Error("Pure bundle manifest missing");
|
|
61942
62397
|
return object5(uniqueJson(Buffer.from(entry2.bytes).toString("utf8")));
|
|
61943
62398
|
};
|
|
61944
|
-
const manifest =
|
|
62399
|
+
const manifest = read3("skill.json"), runtime = object5(manifest.runtime), pkg = read3("package.json");
|
|
61945
62400
|
if (manifest.kind !== "executable" || runtime.runtime !== "bun" || runtime.entrypoint !== contract.entrypoint || !Array.isArray(runtime.env) || runtime.env.length !== 0 || runtime.system_deps !== undefined && (!Array.isArray(runtime.system_deps) || runtime.system_deps.length !== 0) || runtime.needs_network === true || manifest.needs_network === true)
|
|
61946
62401
|
throw Error("Pure bundle requires a credential-free self-contained Bun entrypoint");
|
|
61947
62402
|
for (const key of ["dependencies", "optionalDependencies", "peerDependencies", "devDependencies", "scripts"])
|
|
@@ -62053,7 +62508,7 @@ function verifyRuntimeToken(token, key, admission, attempt, now = Date.now()) {
|
|
|
62053
62508
|
const actual = Buffer.from(token);
|
|
62054
62509
|
return actual.length === expected.length && timingSafeEqual2(actual, expected);
|
|
62055
62510
|
}
|
|
62056
|
-
var hashBytes = (bytes) =>
|
|
62511
|
+
var hashBytes = (bytes) => createHash28("sha256").update(bytes).digest("hex");
|
|
62057
62512
|
|
|
62058
62513
|
// src/server/runtime-api.ts
|
|
62059
62514
|
async function createRuntimeService(options) {
|
|
@@ -68386,7 +68841,7 @@ var localRunExecutor = {
|
|
|
68386
68841
|
// src/sdk/storage.ts
|
|
68387
68842
|
var artifactStorageSeam = ArtifactStorage;
|
|
68388
68843
|
// src/sdk/outputs.ts
|
|
68389
|
-
import { createHash as
|
|
68844
|
+
import { createHash as createHash29 } from "crypto";
|
|
68390
68845
|
class DatabaseOnlyObjectStore {
|
|
68391
68846
|
usesS3 = false;
|
|
68392
68847
|
async materialize(run, artifact, body4) {
|
|
@@ -68433,7 +68888,7 @@ function createGovernedArtifactWriter(options) {
|
|
|
68433
68888
|
const stamped = {
|
|
68434
68889
|
...meta,
|
|
68435
68890
|
byteSize: outputBytes,
|
|
68436
|
-
sha256:
|
|
68891
|
+
sha256: createHash29("sha256").update(persistedBytes).digest("hex"),
|
|
68437
68892
|
visibility: options.visibility ?? config.defaultVisibility,
|
|
68438
68893
|
...config.artifactTtlSeconds !== undefined ? { expiresAt: expiresAtFor(createdAt, config.artifactTtlSeconds) } : {}
|
|
68439
68894
|
};
|
|
@@ -87200,7 +87655,7 @@ function date4(params) {
|
|
|
87200
87655
|
return _coercedDate(ZodDate2, params);
|
|
87201
87656
|
}
|
|
87202
87657
|
// src/lib/canonical-json.ts
|
|
87203
|
-
import { createHash as
|
|
87658
|
+
import { createHash as createHash30 } from "crypto";
|
|
87204
87659
|
function canonicalJson3(value, maximumBytes = 2 * 1024 * 1024) {
|
|
87205
87660
|
return canonicalJsonAtDepth(value, maximumBytes, 64);
|
|
87206
87661
|
}
|
|
@@ -87244,7 +87699,7 @@ function canonicalJsonAtDepth(value, maximumBytes, maximumDepth) {
|
|
|
87244
87699
|
return visit3(value, 0);
|
|
87245
87700
|
}
|
|
87246
87701
|
function canonicalJsonSha256(value, maximumBytes) {
|
|
87247
|
-
return
|
|
87702
|
+
return createHash30("sha256").update(canonicalJson3(value, maximumBytes)).digest("hex");
|
|
87248
87703
|
}
|
|
87249
87704
|
|
|
87250
87705
|
// src/lib/remote-recurring-contract.ts
|
|
@@ -87387,8 +87842,8 @@ var inputs = {
|
|
|
87387
87842
|
};
|
|
87388
87843
|
function recurringInput(action, raw) {
|
|
87389
87844
|
try {
|
|
87390
|
-
const
|
|
87391
|
-
return inputs[action].parse(
|
|
87845
|
+
const snapshot2 = JSON.parse(canonicalJson3(raw, action === "preview" ? 1048576 : 4096));
|
|
87846
|
+
return inputs[action].parse(snapshot2);
|
|
87392
87847
|
} catch {
|
|
87393
87848
|
throw new RecurringInputError;
|
|
87394
87849
|
}
|
|
@@ -87418,7 +87873,7 @@ function assertRecurringCapability(value, action) {
|
|
|
87418
87873
|
}
|
|
87419
87874
|
function recurringRequest(action, input2) {
|
|
87420
87875
|
const row = input2, base = "/api/v1/recurring-consents";
|
|
87421
|
-
const
|
|
87876
|
+
const read3 = ["draft", "list", "get", "occurrences"].includes(action);
|
|
87422
87877
|
let path2 = action === "preview" ? `${base}/preview` : action === "draft" ? `/api/v1/recurring-consent-drafts/${row.draftId}` : action === "activate" ? `${base}/${row.draftId}/activate` : action === "list" ? base : `${base}/${row.consentId}${action === "get" ? "" : `/${action}`}`;
|
|
87423
87878
|
if (action === "list" || action === "occurrences") {
|
|
87424
87879
|
const query = new URLSearchParams;
|
|
@@ -87429,7 +87884,7 @@ function recurringRequest(action, input2) {
|
|
|
87429
87884
|
if (query.size)
|
|
87430
87885
|
path2 += `?${query}`;
|
|
87431
87886
|
}
|
|
87432
|
-
return { path: path2, read:
|
|
87887
|
+
return { path: path2, read: read3, method: read3 ? "GET" : "POST", body: read3 ? undefined : JSON.stringify(action === "preview" ? input2 : action === "activate" ? row.approval : { contractVersion: 1 }) };
|
|
87433
87888
|
}
|
|
87434
87889
|
var budget = exports_external2.object({ reservedCredits: integer2, settledCredits: integer2, admittedOccurrences: integer2 });
|
|
87435
87890
|
var period = exports_external2.object({ startsAt: instant2, endsAt: instant2 });
|
|
@@ -88161,10 +88616,10 @@ async function readQuoteUnavailableCode(response) {
|
|
|
88161
88616
|
let timer;
|
|
88162
88617
|
let deadlineExceeded = false;
|
|
88163
88618
|
const expired = Symbol("quote body deadline");
|
|
88164
|
-
const deadline = new Promise((
|
|
88619
|
+
const deadline = new Promise((resolve19) => {
|
|
88165
88620
|
timer = setTimeout(() => {
|
|
88166
88621
|
deadlineExceeded = true;
|
|
88167
|
-
|
|
88622
|
+
resolve19(expired);
|
|
88168
88623
|
reader.cancel().catch(() => {});
|
|
88169
88624
|
}, 1500);
|
|
88170
88625
|
});
|
|
@@ -88690,24 +89145,24 @@ class RemoteSkillsClient {
|
|
|
88690
89145
|
const identity3 = parseWorkspaceIdentity(identityValue, target.userId);
|
|
88691
89146
|
if (identity3.user.membershipId !== target.membershipId)
|
|
88692
89147
|
throw new WorkspaceIdentityMismatchError;
|
|
88693
|
-
const request2 = invitationRequest(action, captured),
|
|
89148
|
+
const request2 = invitationRequest(action, captured), read3 = action === "list" || action === "get";
|
|
88694
89149
|
let response, value;
|
|
88695
89150
|
try {
|
|
88696
89151
|
response = await connection.request(request2.path, { method: request2.method, ...request2.body ? { body: request2.body } : {}, credentials: "omit" });
|
|
88697
89152
|
value = JSON.parse(new TextDecoder().decode(await readBoundedResponse(response, response.ok ? 64 * 1024 : 4096)));
|
|
88698
89153
|
} catch {
|
|
88699
|
-
throw
|
|
89154
|
+
throw read3 ? new RemoteWorkspaceInvitationReadError : new RemoteWorkspaceInvitationUnconfirmedError;
|
|
88700
89155
|
}
|
|
88701
89156
|
if (!response.ok) {
|
|
88702
89157
|
const code = invitationFailure(value, response.status);
|
|
88703
89158
|
if (code)
|
|
88704
89159
|
throw new RemoteWorkspaceInvitationError(code);
|
|
88705
|
-
throw
|
|
89160
|
+
throw read3 ? new RemoteWorkspaceInvitationReadError : new RemoteWorkspaceInvitationUnconfirmedError;
|
|
88706
89161
|
}
|
|
88707
89162
|
try {
|
|
88708
89163
|
return parseInvitationResult(action, value, captured, identity3.organization.id);
|
|
88709
89164
|
} catch {
|
|
88710
|
-
throw
|
|
89165
|
+
throw read3 ? new RemoteWorkspaceInvitationReadError : new RemoteWorkspaceInvitationUnconfirmedError;
|
|
88711
89166
|
}
|
|
88712
89167
|
}
|
|
88713
89168
|
previewRecurringConsent(request2, context) {
|
|
@@ -89345,7 +89800,7 @@ async function requestInvitationEmail(origin, action, input2) {
|
|
|
89345
89800
|
}
|
|
89346
89801
|
|
|
89347
89802
|
// src/lib/remote-private-publications.ts
|
|
89348
|
-
import { createHash as
|
|
89803
|
+
import { createHash as createHash31 } from "crypto";
|
|
89349
89804
|
var PRIVATE_PUBLICATION_MAX_BYTES = 16 * 1024 * 1024;
|
|
89350
89805
|
var failures2 = {
|
|
89351
89806
|
INVALID_REQUEST: [400, "The publication request is invalid."],
|
|
@@ -89392,7 +89847,7 @@ var hash4 = (v2) => typeof v2 === "string" && /^[a-f0-9]{64}$/.test(v2);
|
|
|
89392
89847
|
var record9 = (v2) => !!v2 && typeof v2 === "object" && !Array.isArray(v2);
|
|
89393
89848
|
var exact = (v2, keys3) => record9(v2) && Object.keys(v2).sort().join(",") === keys3.sort().join(",");
|
|
89394
89849
|
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));
|
|
89395
|
-
var publicationSha256 = (bytes) =>
|
|
89850
|
+
var publicationSha256 = (bytes) => createHash31("sha256").update(bytes).digest("hex");
|
|
89396
89851
|
function checkedPublicationDeclaration(value) {
|
|
89397
89852
|
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 || !hash4(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES)
|
|
89398
89853
|
return bad();
|
|
@@ -89637,12 +90092,12 @@ class RemotePrivatePublicationsClient {
|
|
|
89637
90092
|
previous = view;
|
|
89638
90093
|
if (!["queued", "verifying"].includes(view.state) || Date.now() >= until)
|
|
89639
90094
|
return view;
|
|
89640
|
-
await new Promise((
|
|
90095
|
+
await new Promise((resolve19) => {
|
|
89641
90096
|
const timer = setTimeout(done, Math.min(1000, until - Date.now()));
|
|
89642
90097
|
function done() {
|
|
89643
90098
|
clearTimeout(timer);
|
|
89644
90099
|
options.signal?.removeEventListener("abort", done);
|
|
89645
|
-
|
|
90100
|
+
resolve19();
|
|
89646
90101
|
}
|
|
89647
90102
|
options.signal?.addEventListener("abort", done, { once: true });
|
|
89648
90103
|
});
|
|
@@ -89874,23 +90329,23 @@ class RemoteSkillsAuthClient {
|
|
|
89874
90329
|
}
|
|
89875
90330
|
}
|
|
89876
90331
|
// src/lib/private-publication-recovery.ts
|
|
89877
|
-
import { constants as
|
|
89878
|
-
import { dirname as
|
|
90332
|
+
import { constants as constants13, closeSync as closeSync17, fsyncSync as fsyncSync5, fstatSync as fstatSync17, lstatSync as lstatSync22, mkdirSync as mkdirSync14, openSync as openSync17, readSync as readSync12, realpathSync as realpathSync9, renameSync as renameSync6, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "fs";
|
|
90333
|
+
import { dirname as dirname25, isAbsolute as isAbsolute18, join as join37, resolve as resolve19 } from "path";
|
|
89879
90334
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
89880
90335
|
var fail = () => {
|
|
89881
90336
|
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.");
|
|
89882
90337
|
};
|
|
89883
90338
|
function safeDirectory(directory) {
|
|
89884
|
-
if (!isAbsolute18(directory) || directory !==
|
|
90339
|
+
if (!isAbsolute18(directory) || directory !== resolve19(directory) || realpathSync9(directory) !== directory)
|
|
89885
90340
|
return fail();
|
|
89886
|
-
for (let path2 = directory;; path2 =
|
|
89887
|
-
const stat2 =
|
|
90341
|
+
for (let path2 = directory;; path2 = dirname25(path2)) {
|
|
90342
|
+
const stat2 = lstatSync22(path2);
|
|
89888
90343
|
if (!stat2.isDirectory() || stat2.isSymbolicLink())
|
|
89889
90344
|
return fail();
|
|
89890
|
-
if (path2 ===
|
|
90345
|
+
if (path2 === dirname25(path2))
|
|
89891
90346
|
break;
|
|
89892
90347
|
}
|
|
89893
|
-
const own2 =
|
|
90348
|
+
const own2 = lstatSync22(directory);
|
|
89894
90349
|
if ((own2.mode & 63) !== 0 || process.getuid && own2.uid !== process.getuid())
|
|
89895
90350
|
return fail();
|
|
89896
90351
|
return { dev: own2.dev, ino: own2.ino };
|
|
@@ -89901,36 +90356,36 @@ function unchangedDirectory(directory, identity3) {
|
|
|
89901
90356
|
return fail();
|
|
89902
90357
|
}
|
|
89903
90358
|
function readOwned(directory, name, max) {
|
|
89904
|
-
const identity3 = safeDirectory(directory), file2 =
|
|
89905
|
-
const fd =
|
|
90359
|
+
const identity3 = safeDirectory(directory), file2 = join37(directory, name);
|
|
90360
|
+
const fd = openSync17(file2, constants13.O_RDONLY | constants13.O_NOFOLLOW);
|
|
89906
90361
|
try {
|
|
89907
|
-
const stat2 =
|
|
90362
|
+
const stat2 = fstatSync17(fd);
|
|
89908
90363
|
if (!stat2.isFile() || stat2.nlink !== 1 || stat2.size > max || stat2.size < 1 || (stat2.mode & 63) !== 0 || process.getuid && stat2.uid !== process.getuid())
|
|
89909
90364
|
return fail();
|
|
89910
90365
|
const buffer = Buffer.alloc(Math.min(max, stat2.size) + 1);
|
|
89911
90366
|
let length = 0;
|
|
89912
90367
|
while (length < buffer.length) {
|
|
89913
|
-
const count =
|
|
90368
|
+
const count = readSync12(fd, buffer, length, buffer.length - length, length);
|
|
89914
90369
|
if (count === 0)
|
|
89915
90370
|
break;
|
|
89916
90371
|
length += count;
|
|
89917
90372
|
}
|
|
89918
|
-
const bytes = buffer.subarray(0, length), after =
|
|
90373
|
+
const bytes = buffer.subarray(0, length), after = fstatSync17(fd);
|
|
89919
90374
|
unchangedDirectory(directory, identity3);
|
|
89920
90375
|
if (bytes.length !== stat2.size || stat2.size !== after.size || stat2.mtimeMs !== after.mtimeMs || stat2.ctimeMs !== after.ctimeMs)
|
|
89921
90376
|
return fail();
|
|
89922
90377
|
return bytes;
|
|
89923
90378
|
} finally {
|
|
89924
|
-
|
|
90379
|
+
closeSync17(fd);
|
|
89925
90380
|
}
|
|
89926
90381
|
}
|
|
89927
90382
|
function writeOwned(directory, name, bytes) {
|
|
89928
|
-
const fd =
|
|
90383
|
+
const fd = openSync17(join37(directory, name), constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL | constants13.O_NOFOLLOW, 384);
|
|
89929
90384
|
try {
|
|
89930
|
-
|
|
89931
|
-
|
|
90385
|
+
writeFileSync10(fd, bytes);
|
|
90386
|
+
fsyncSync5(fd);
|
|
89932
90387
|
} finally {
|
|
89933
|
-
|
|
90388
|
+
closeSync17(fd);
|
|
89934
90389
|
}
|
|
89935
90390
|
}
|
|
89936
90391
|
function save(directory, value) {
|
|
@@ -89938,12 +90393,12 @@ function save(directory, value) {
|
|
|
89938
90393
|
writeOwned(directory, temporary, JSON.stringify(value) + `
|
|
89939
90394
|
`);
|
|
89940
90395
|
unchangedDirectory(directory, identity3);
|
|
89941
|
-
renameSync6(
|
|
89942
|
-
const fd =
|
|
90396
|
+
renameSync6(join37(directory, temporary), join37(directory, "receipt.json"));
|
|
90397
|
+
const fd = openSync17(directory, constants13.O_RDONLY | constants13.O_NOFOLLOW);
|
|
89943
90398
|
try {
|
|
89944
|
-
|
|
90399
|
+
fsyncSync5(fd);
|
|
89945
90400
|
} finally {
|
|
89946
|
-
|
|
90401
|
+
closeSync17(fd);
|
|
89947
90402
|
}
|
|
89948
90403
|
}
|
|
89949
90404
|
function bind(client2, receipt) {
|
|
@@ -89951,23 +90406,23 @@ function bind(client2, receipt) {
|
|
|
89951
90406
|
throw new PrivatePublicationError("PUBLICATION_IDENTITY_CHANGED", "The fresh session does not match the recovery directory's server, account and membership.");
|
|
89952
90407
|
}
|
|
89953
90408
|
async function locked(directory, action) {
|
|
89954
|
-
const identity3 = safeDirectory(directory), file2 =
|
|
90409
|
+
const identity3 = safeDirectory(directory), file2 = join37(directory, "operation.lock");
|
|
89955
90410
|
let fd;
|
|
89956
90411
|
try {
|
|
89957
|
-
fd =
|
|
90412
|
+
fd = openSync17(file2, constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL | constants13.O_NOFOLLOW, 384);
|
|
89958
90413
|
} catch {
|
|
89959
90414
|
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.");
|
|
89960
90415
|
}
|
|
89961
|
-
const lock =
|
|
90416
|
+
const lock = fstatSync17(fd);
|
|
89962
90417
|
try {
|
|
89963
|
-
|
|
90418
|
+
writeFileSync10(fd, JSON.stringify({ pid: process.pid }) + `
|
|
89964
90419
|
`);
|
|
89965
|
-
|
|
90420
|
+
fsyncSync5(fd);
|
|
89966
90421
|
return await action();
|
|
89967
90422
|
} finally {
|
|
89968
|
-
|
|
90423
|
+
closeSync17(fd);
|
|
89969
90424
|
unchangedDirectory(directory, identity3);
|
|
89970
|
-
const now2 =
|
|
90425
|
+
const now2 = lstatSync22(file2);
|
|
89971
90426
|
if (now2.dev !== lock.dev || now2.ino !== lock.ino || !now2.isFile() || now2.isSymbolicLink())
|
|
89972
90427
|
fail();
|
|
89973
90428
|
unlinkSync5(file2);
|
|
@@ -90019,15 +90474,15 @@ async function preparePrivatePublication(client2, sourceDirectory, recoveryDirec
|
|
|
90019
90474
|
phase: "prepared",
|
|
90020
90475
|
intent: null
|
|
90021
90476
|
};
|
|
90022
|
-
if (!isAbsolute18(recoveryDirectory) ||
|
|
90477
|
+
if (!isAbsolute18(recoveryDirectory) || resolve19(recoveryDirectory) !== recoveryDirectory || realpathSync9(dirname25(recoveryDirectory)) !== dirname25(recoveryDirectory))
|
|
90023
90478
|
return fail();
|
|
90024
90479
|
mkdirSync14(recoveryDirectory, { mode: 448 });
|
|
90025
90480
|
safeDirectory(recoveryDirectory);
|
|
90026
|
-
const parent =
|
|
90481
|
+
const parent = openSync17(dirname25(recoveryDirectory), constants13.O_RDONLY | constants13.O_NOFOLLOW);
|
|
90027
90482
|
try {
|
|
90028
|
-
|
|
90483
|
+
fsyncSync5(parent);
|
|
90029
90484
|
} finally {
|
|
90030
|
-
|
|
90485
|
+
closeSync17(parent);
|
|
90031
90486
|
}
|
|
90032
90487
|
writeOwned(recoveryDirectory, "bundle.tgz", packed.bytes);
|
|
90033
90488
|
save(recoveryDirectory, receipt);
|
|
@@ -90135,7 +90590,7 @@ function exact2(value, names) {
|
|
|
90135
90590
|
const keys3 = Object.keys(value).sort(), expected = [...names].sort();
|
|
90136
90591
|
return keys3.length === expected.length && keys3.every((key, index) => key === expected[index]);
|
|
90137
90592
|
}
|
|
90138
|
-
function
|
|
90593
|
+
function snapshot2(value, maximum) {
|
|
90139
90594
|
let nodes4 = 0, bytes = 0;
|
|
90140
90595
|
const parts = [], ancestors2 = new Set;
|
|
90141
90596
|
const append = (part) => {
|
|
@@ -90214,7 +90669,7 @@ function snapshot(value, maximum) {
|
|
|
90214
90669
|
}
|
|
90215
90670
|
function requestSnapshot(input2) {
|
|
90216
90671
|
try {
|
|
90217
|
-
const owned =
|
|
90672
|
+
const owned = snapshot2(input2, SKILL_OPERATION_LIMITS.requestBytes), value = owned.value;
|
|
90218
90673
|
if (!record10(value) || !exact2(value, ["contractVersion", "requestId", "operation", "input"]) || value.contractVersion !== 1 || !validId(value.requestId) || typeof value.operation !== "string" || value.operation.length > 128 || !/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value.operation) || !record10(value.input))
|
|
90219
90674
|
throw Error();
|
|
90220
90675
|
return { ...owned, value };
|
|
@@ -90224,7 +90679,7 @@ function requestSnapshot(input2) {
|
|
|
90224
90679
|
}
|
|
90225
90680
|
function resultSnapshot(input2, requestId) {
|
|
90226
90681
|
try {
|
|
90227
|
-
const value =
|
|
90682
|
+
const value = snapshot2(input2, SKILL_OPERATION_LIMITS.resultBytes).value;
|
|
90228
90683
|
if (!record10(value) || value.contractVersion !== 1 || value.requestId !== requestId)
|
|
90229
90684
|
throw Error();
|
|
90230
90685
|
const fields = ["contractVersion", "requestId", "status"];
|