@hasna/skills 0.8.2 → 0.8.3
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 +70 -2
- package/bin/index.js +585 -282
- package/bin/mcp.js +255 -109
- package/bin/migrate.js +82 -24
- package/bin/server.js +1222 -430
- package/bin/worker.js +395 -87
- package/dist/cli/commands/grants.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/lib/execution-grant-client.d.ts +5 -0
- package/dist/lib/execution-grants.d.ts +49 -0
- package/dist/lib/selected-manifest.d.ts +6 -0
- package/dist/lib/selected-run.d.ts +9 -0
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +9205 -8724
- package/dist/server/execution-grant-store.d.ts +29 -0
- package/dist/server/execution-grants-api.d.ts +4 -0
- package/dist/server/sqlite-store.d.ts +2 -0
- package/dist/server/store.d.ts +3 -0
- package/dist/server/types.d.ts +2 -0
- package/migrations/postgres/0009_execution_grants.sql +15 -0
- package/migrations/sqlite/0009_execution_grants.sql +15 -0
- package/package.json +1 -1
package/bin/server.js
CHANGED
|
@@ -2064,7 +2064,7 @@ var require_client = __commonJS((exports) => {
|
|
|
2064
2064
|
var require_config = __commonJS((exports) => {
|
|
2065
2065
|
var { homedir } = __require("os");
|
|
2066
2066
|
var { sep, join } = __require("path");
|
|
2067
|
-
var { createHash } = __require("crypto");
|
|
2067
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
2068
2068
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
2069
2069
|
var { IniSectionType } = require_dist_cjs();
|
|
2070
2070
|
var { normalizeProvider } = require_client();
|
|
@@ -2219,7 +2219,7 @@ var require_config = __commonJS((exports) => {
|
|
|
2219
2219
|
var DEFAULT_PROFILE = "default";
|
|
2220
2220
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
2221
2221
|
var getSSOTokenFilepath = (id) => {
|
|
2222
|
-
const hasher =
|
|
2222
|
+
const hasher = createHash2("sha1");
|
|
2223
2223
|
const cacheName = hasher.update(id).digest("hex");
|
|
2224
2224
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
2225
2225
|
};
|
|
@@ -3571,7 +3571,7 @@ var require_endpoints = __commonJS((exports) => {
|
|
|
3571
3571
|
|
|
3572
3572
|
// node_modules/@aws-sdk/core/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
3573
3573
|
var require_serde = __commonJS((exports) => {
|
|
3574
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
3574
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
3575
3575
|
var { hasOwn, HttpResponse } = require_transport();
|
|
3576
3576
|
exports.hasOwn = hasOwn;
|
|
3577
3577
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -4476,7 +4476,7 @@ var require_serde = __commonJS((exports) => {
|
|
|
4476
4476
|
return Promise.resolve(this.hash.digest());
|
|
4477
4477
|
}
|
|
4478
4478
|
reset() {
|
|
4479
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
4479
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
4480
4480
|
}
|
|
4481
4481
|
}
|
|
4482
4482
|
function castSourceData(toCast, encoding) {
|
|
@@ -5215,7 +5215,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
5215
5215
|
var { createReadStream } = __require("fs");
|
|
5216
5216
|
var { Writable } = __require("stream");
|
|
5217
5217
|
var { toUint8Array, concatBytes } = require_serde();
|
|
5218
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
5218
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
5219
5219
|
var zlib = __require("zlib");
|
|
5220
5220
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
5221
5221
|
const size = blob.size;
|
|
@@ -5380,7 +5380,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
5380
5380
|
}
|
|
5381
5381
|
var hasNativeCrypto$1 = (() => {
|
|
5382
5382
|
try {
|
|
5383
|
-
|
|
5383
|
+
createHash2("md5");
|
|
5384
5384
|
return true;
|
|
5385
5385
|
} catch {
|
|
5386
5386
|
return false;
|
|
@@ -5390,7 +5390,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
5390
5390
|
function buildNativeClass$2() {
|
|
5391
5391
|
return class Md5Node2 {
|
|
5392
5392
|
digestLength = 16;
|
|
5393
|
-
hash =
|
|
5393
|
+
hash = createHash2("md5");
|
|
5394
5394
|
update(data) {
|
|
5395
5395
|
this.hash.update(toUint8Array(data));
|
|
5396
5396
|
}
|
|
@@ -5399,7 +5399,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
5399
5399
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
5400
5400
|
}
|
|
5401
5401
|
reset() {
|
|
5402
|
-
this.hash =
|
|
5402
|
+
this.hash = createHash2("md5");
|
|
5403
5403
|
}
|
|
5404
5404
|
};
|
|
5405
5405
|
}
|
|
@@ -5689,7 +5689,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
5689
5689
|
]);
|
|
5690
5690
|
var hasNativeCrypto = (() => {
|
|
5691
5691
|
try {
|
|
5692
|
-
|
|
5692
|
+
createHash2("sha256");
|
|
5693
5693
|
return true;
|
|
5694
5694
|
} catch {
|
|
5695
5695
|
return false;
|
|
@@ -5729,7 +5729,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
5729
5729
|
this.finished = false;
|
|
5730
5730
|
}
|
|
5731
5731
|
createHash() {
|
|
5732
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
5732
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
5733
5733
|
}
|
|
5734
5734
|
};
|
|
5735
5735
|
}
|
|
@@ -12683,7 +12683,7 @@ var require_client3 = __commonJS((exports) => {
|
|
|
12683
12683
|
var require_config2 = __commonJS((exports) => {
|
|
12684
12684
|
var { homedir } = __require("os");
|
|
12685
12685
|
var { sep, join } = __require("path");
|
|
12686
|
-
var { createHash } = __require("crypto");
|
|
12686
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
12687
12687
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
12688
12688
|
var { IniSectionType } = require_dist_cjs();
|
|
12689
12689
|
var { normalizeProvider } = require_client3();
|
|
@@ -12838,7 +12838,7 @@ var require_config2 = __commonJS((exports) => {
|
|
|
12838
12838
|
var DEFAULT_PROFILE = "default";
|
|
12839
12839
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
12840
12840
|
var getSSOTokenFilepath = (id) => {
|
|
12841
|
-
const hasher =
|
|
12841
|
+
const hasher = createHash2("sha1");
|
|
12842
12842
|
const cacheName = hasher.update(id).digest("hex");
|
|
12843
12843
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
12844
12844
|
};
|
|
@@ -14190,7 +14190,7 @@ var require_endpoints2 = __commonJS((exports) => {
|
|
|
14190
14190
|
|
|
14191
14191
|
// node_modules/@aws-sdk/checksums/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
14192
14192
|
var require_serde2 = __commonJS((exports) => {
|
|
14193
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
14193
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
14194
14194
|
var { hasOwn, HttpResponse } = require_transport2();
|
|
14195
14195
|
exports.hasOwn = hasOwn;
|
|
14196
14196
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -15095,7 +15095,7 @@ var require_serde2 = __commonJS((exports) => {
|
|
|
15095
15095
|
return Promise.resolve(this.hash.digest());
|
|
15096
15096
|
}
|
|
15097
15097
|
reset() {
|
|
15098
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
15098
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
15099
15099
|
}
|
|
15100
15100
|
}
|
|
15101
15101
|
function castSourceData(toCast, encoding) {
|
|
@@ -15834,7 +15834,7 @@ var require_checksum2 = __commonJS((exports) => {
|
|
|
15834
15834
|
var { createReadStream } = __require("fs");
|
|
15835
15835
|
var { Writable } = __require("stream");
|
|
15836
15836
|
var { toUint8Array, concatBytes } = require_serde2();
|
|
15837
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
15837
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
15838
15838
|
var zlib = __require("zlib");
|
|
15839
15839
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
15840
15840
|
const size = blob.size;
|
|
@@ -15999,7 +15999,7 @@ var require_checksum2 = __commonJS((exports) => {
|
|
|
15999
15999
|
}
|
|
16000
16000
|
var hasNativeCrypto$1 = (() => {
|
|
16001
16001
|
try {
|
|
16002
|
-
|
|
16002
|
+
createHash2("md5");
|
|
16003
16003
|
return true;
|
|
16004
16004
|
} catch {
|
|
16005
16005
|
return false;
|
|
@@ -16009,7 +16009,7 @@ var require_checksum2 = __commonJS((exports) => {
|
|
|
16009
16009
|
function buildNativeClass$2() {
|
|
16010
16010
|
return class Md5Node2 {
|
|
16011
16011
|
digestLength = 16;
|
|
16012
|
-
hash =
|
|
16012
|
+
hash = createHash2("md5");
|
|
16013
16013
|
update(data) {
|
|
16014
16014
|
this.hash.update(toUint8Array(data));
|
|
16015
16015
|
}
|
|
@@ -16018,7 +16018,7 @@ var require_checksum2 = __commonJS((exports) => {
|
|
|
16018
16018
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
16019
16019
|
}
|
|
16020
16020
|
reset() {
|
|
16021
|
-
this.hash =
|
|
16021
|
+
this.hash = createHash2("md5");
|
|
16022
16022
|
}
|
|
16023
16023
|
};
|
|
16024
16024
|
}
|
|
@@ -16308,7 +16308,7 @@ var require_checksum2 = __commonJS((exports) => {
|
|
|
16308
16308
|
]);
|
|
16309
16309
|
var hasNativeCrypto = (() => {
|
|
16310
16310
|
try {
|
|
16311
|
-
|
|
16311
|
+
createHash2("sha256");
|
|
16312
16312
|
return true;
|
|
16313
16313
|
} catch {
|
|
16314
16314
|
return false;
|
|
@@ -16348,7 +16348,7 @@ var require_checksum2 = __commonJS((exports) => {
|
|
|
16348
16348
|
this.finished = false;
|
|
16349
16349
|
}
|
|
16350
16350
|
createHash() {
|
|
16351
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
16351
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
16352
16352
|
}
|
|
16353
16353
|
};
|
|
16354
16354
|
}
|
|
@@ -20424,7 +20424,7 @@ var require_client4 = __commonJS((exports) => {
|
|
|
20424
20424
|
var require_config3 = __commonJS((exports) => {
|
|
20425
20425
|
var { homedir } = __require("os");
|
|
20426
20426
|
var { sep, join } = __require("path");
|
|
20427
|
-
var { createHash } = __require("crypto");
|
|
20427
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
20428
20428
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
20429
20429
|
var { IniSectionType } = require_dist_cjs();
|
|
20430
20430
|
var { normalizeProvider: normalizeProvider2 } = require_client4();
|
|
@@ -20579,7 +20579,7 @@ var require_config3 = __commonJS((exports) => {
|
|
|
20579
20579
|
var DEFAULT_PROFILE = "default";
|
|
20580
20580
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
20581
20581
|
var getSSOTokenFilepath = (id) => {
|
|
20582
|
-
const hasher =
|
|
20582
|
+
const hasher = createHash2("sha1");
|
|
20583
20583
|
const cacheName = hasher.update(id).digest("hex");
|
|
20584
20584
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
20585
20585
|
};
|
|
@@ -21931,7 +21931,7 @@ var require_endpoints3 = __commonJS((exports) => {
|
|
|
21931
21931
|
|
|
21932
21932
|
// node_modules/@aws-sdk/middleware-sdk-s3/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
21933
21933
|
var require_serde3 = __commonJS((exports) => {
|
|
21934
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
21934
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
21935
21935
|
var { hasOwn, HttpResponse } = require_transport3();
|
|
21936
21936
|
exports.hasOwn = hasOwn;
|
|
21937
21937
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -22836,7 +22836,7 @@ var require_serde3 = __commonJS((exports) => {
|
|
|
22836
22836
|
return Promise.resolve(this.hash.digest());
|
|
22837
22837
|
}
|
|
22838
22838
|
reset() {
|
|
22839
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
22839
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
22840
22840
|
}
|
|
22841
22841
|
}
|
|
22842
22842
|
function castSourceData(toCast, encoding) {
|
|
@@ -23575,7 +23575,7 @@ var require_checksum3 = __commonJS((exports) => {
|
|
|
23575
23575
|
var { createReadStream } = __require("fs");
|
|
23576
23576
|
var { Writable } = __require("stream");
|
|
23577
23577
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde3();
|
|
23578
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
23578
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
23579
23579
|
var zlib = __require("zlib");
|
|
23580
23580
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
23581
23581
|
const size = blob.size;
|
|
@@ -23740,7 +23740,7 @@ var require_checksum3 = __commonJS((exports) => {
|
|
|
23740
23740
|
}
|
|
23741
23741
|
var hasNativeCrypto$1 = (() => {
|
|
23742
23742
|
try {
|
|
23743
|
-
|
|
23743
|
+
createHash2("md5");
|
|
23744
23744
|
return true;
|
|
23745
23745
|
} catch {
|
|
23746
23746
|
return false;
|
|
@@ -23750,7 +23750,7 @@ var require_checksum3 = __commonJS((exports) => {
|
|
|
23750
23750
|
function buildNativeClass$2() {
|
|
23751
23751
|
return class Md5Node2 {
|
|
23752
23752
|
digestLength = 16;
|
|
23753
|
-
hash =
|
|
23753
|
+
hash = createHash2("md5");
|
|
23754
23754
|
update(data) {
|
|
23755
23755
|
this.hash.update(toUint8Array2(data));
|
|
23756
23756
|
}
|
|
@@ -23759,7 +23759,7 @@ var require_checksum3 = __commonJS((exports) => {
|
|
|
23759
23759
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
23760
23760
|
}
|
|
23761
23761
|
reset() {
|
|
23762
|
-
this.hash =
|
|
23762
|
+
this.hash = createHash2("md5");
|
|
23763
23763
|
}
|
|
23764
23764
|
};
|
|
23765
23765
|
}
|
|
@@ -24049,7 +24049,7 @@ var require_checksum3 = __commonJS((exports) => {
|
|
|
24049
24049
|
]);
|
|
24050
24050
|
var hasNativeCrypto = (() => {
|
|
24051
24051
|
try {
|
|
24052
|
-
|
|
24052
|
+
createHash2("sha256");
|
|
24053
24053
|
return true;
|
|
24054
24054
|
} catch {
|
|
24055
24055
|
return false;
|
|
@@ -24089,7 +24089,7 @@ var require_checksum3 = __commonJS((exports) => {
|
|
|
24089
24089
|
this.finished = false;
|
|
24090
24090
|
}
|
|
24091
24091
|
createHash() {
|
|
24092
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
24092
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
24093
24093
|
}
|
|
24094
24094
|
};
|
|
24095
24095
|
}
|
|
@@ -28008,7 +28008,7 @@ var require_client5 = __commonJS((exports) => {
|
|
|
28008
28008
|
var require_config4 = __commonJS((exports) => {
|
|
28009
28009
|
var { homedir } = __require("os");
|
|
28010
28010
|
var { sep, join } = __require("path");
|
|
28011
|
-
var { createHash } = __require("crypto");
|
|
28011
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
28012
28012
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
28013
28013
|
var { IniSectionType } = require_dist_cjs();
|
|
28014
28014
|
var { normalizeProvider: normalizeProvider2 } = require_client5();
|
|
@@ -28163,7 +28163,7 @@ var require_config4 = __commonJS((exports) => {
|
|
|
28163
28163
|
var DEFAULT_PROFILE = "default";
|
|
28164
28164
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
28165
28165
|
var getSSOTokenFilepath = (id) => {
|
|
28166
|
-
const hasher =
|
|
28166
|
+
const hasher = createHash2("sha1");
|
|
28167
28167
|
const cacheName = hasher.update(id).digest("hex");
|
|
28168
28168
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
28169
28169
|
};
|
|
@@ -29515,7 +29515,7 @@ var require_endpoints4 = __commonJS((exports) => {
|
|
|
29515
29515
|
|
|
29516
29516
|
// node_modules/@smithy/signature-v4/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
29517
29517
|
var require_serde4 = __commonJS((exports) => {
|
|
29518
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
29518
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
29519
29519
|
var { hasOwn, HttpResponse } = require_transport4();
|
|
29520
29520
|
exports.hasOwn = hasOwn;
|
|
29521
29521
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -30420,7 +30420,7 @@ var require_serde4 = __commonJS((exports) => {
|
|
|
30420
30420
|
return Promise.resolve(this.hash.digest());
|
|
30421
30421
|
}
|
|
30422
30422
|
reset() {
|
|
30423
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
30423
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
30424
30424
|
}
|
|
30425
30425
|
}
|
|
30426
30426
|
function castSourceData(toCast, encoding) {
|
|
@@ -31159,7 +31159,7 @@ var require_checksum4 = __commonJS((exports) => {
|
|
|
31159
31159
|
var { createReadStream } = __require("fs");
|
|
31160
31160
|
var { Writable } = __require("stream");
|
|
31161
31161
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde4();
|
|
31162
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
31162
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
31163
31163
|
var zlib = __require("zlib");
|
|
31164
31164
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
31165
31165
|
const size = blob.size;
|
|
@@ -31324,7 +31324,7 @@ var require_checksum4 = __commonJS((exports) => {
|
|
|
31324
31324
|
}
|
|
31325
31325
|
var hasNativeCrypto$1 = (() => {
|
|
31326
31326
|
try {
|
|
31327
|
-
|
|
31327
|
+
createHash2("md5");
|
|
31328
31328
|
return true;
|
|
31329
31329
|
} catch {
|
|
31330
31330
|
return false;
|
|
@@ -31334,7 +31334,7 @@ var require_checksum4 = __commonJS((exports) => {
|
|
|
31334
31334
|
function buildNativeClass$2() {
|
|
31335
31335
|
return class Md5Node2 {
|
|
31336
31336
|
digestLength = 16;
|
|
31337
|
-
hash =
|
|
31337
|
+
hash = createHash2("md5");
|
|
31338
31338
|
update(data) {
|
|
31339
31339
|
this.hash.update(toUint8Array2(data));
|
|
31340
31340
|
}
|
|
@@ -31343,7 +31343,7 @@ var require_checksum4 = __commonJS((exports) => {
|
|
|
31343
31343
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
31344
31344
|
}
|
|
31345
31345
|
reset() {
|
|
31346
|
-
this.hash =
|
|
31346
|
+
this.hash = createHash2("md5");
|
|
31347
31347
|
}
|
|
31348
31348
|
};
|
|
31349
31349
|
}
|
|
@@ -31633,7 +31633,7 @@ var require_checksum4 = __commonJS((exports) => {
|
|
|
31633
31633
|
]);
|
|
31634
31634
|
var hasNativeCrypto = (() => {
|
|
31635
31635
|
try {
|
|
31636
|
-
|
|
31636
|
+
createHash2("sha256");
|
|
31637
31637
|
return true;
|
|
31638
31638
|
} catch {
|
|
31639
31639
|
return false;
|
|
@@ -31673,7 +31673,7 @@ var require_checksum4 = __commonJS((exports) => {
|
|
|
31673
31673
|
this.finished = false;
|
|
31674
31674
|
}
|
|
31675
31675
|
createHash() {
|
|
31676
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
31676
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
31677
31677
|
}
|
|
31678
31678
|
};
|
|
31679
31679
|
}
|
|
@@ -42321,7 +42321,7 @@ var require_client6 = __commonJS((exports) => {
|
|
|
42321
42321
|
var require_config5 = __commonJS((exports) => {
|
|
42322
42322
|
var { homedir } = __require("os");
|
|
42323
42323
|
var { sep, join } = __require("path");
|
|
42324
|
-
var { createHash } = __require("crypto");
|
|
42324
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
42325
42325
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
42326
42326
|
var { IniSectionType } = require_dist_cjs();
|
|
42327
42327
|
var { normalizeProvider: normalizeProvider2 } = require_client6();
|
|
@@ -42476,7 +42476,7 @@ var require_config5 = __commonJS((exports) => {
|
|
|
42476
42476
|
var DEFAULT_PROFILE = "default";
|
|
42477
42477
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
42478
42478
|
var getSSOTokenFilepath = (id) => {
|
|
42479
|
-
const hasher =
|
|
42479
|
+
const hasher = createHash2("sha1");
|
|
42480
42480
|
const cacheName = hasher.update(id).digest("hex");
|
|
42481
42481
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
42482
42482
|
};
|
|
@@ -43828,7 +43828,7 @@ var require_endpoints5 = __commonJS((exports) => {
|
|
|
43828
43828
|
|
|
43829
43829
|
// node_modules/@aws-sdk/client-s3/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
43830
43830
|
var require_serde5 = __commonJS((exports) => {
|
|
43831
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
43831
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
43832
43832
|
var { hasOwn, HttpResponse: HttpResponse2 } = require_transport5();
|
|
43833
43833
|
exports.hasOwn = hasOwn;
|
|
43834
43834
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -44733,7 +44733,7 @@ var require_serde5 = __commonJS((exports) => {
|
|
|
44733
44733
|
return Promise.resolve(this.hash.digest());
|
|
44734
44734
|
}
|
|
44735
44735
|
reset() {
|
|
44736
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
44736
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
44737
44737
|
}
|
|
44738
44738
|
}
|
|
44739
44739
|
function castSourceData(toCast, encoding) {
|
|
@@ -45472,7 +45472,7 @@ var require_checksum5 = __commonJS((exports) => {
|
|
|
45472
45472
|
var { createReadStream } = __require("fs");
|
|
45473
45473
|
var { Writable } = __require("stream");
|
|
45474
45474
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde5();
|
|
45475
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
45475
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
45476
45476
|
var zlib = __require("zlib");
|
|
45477
45477
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
45478
45478
|
const size = blob.size;
|
|
@@ -45637,7 +45637,7 @@ var require_checksum5 = __commonJS((exports) => {
|
|
|
45637
45637
|
}
|
|
45638
45638
|
var hasNativeCrypto$1 = (() => {
|
|
45639
45639
|
try {
|
|
45640
|
-
|
|
45640
|
+
createHash2("md5");
|
|
45641
45641
|
return true;
|
|
45642
45642
|
} catch {
|
|
45643
45643
|
return false;
|
|
@@ -45647,7 +45647,7 @@ var require_checksum5 = __commonJS((exports) => {
|
|
|
45647
45647
|
function buildNativeClass$2() {
|
|
45648
45648
|
return class Md5Node2 {
|
|
45649
45649
|
digestLength = 16;
|
|
45650
|
-
hash =
|
|
45650
|
+
hash = createHash2("md5");
|
|
45651
45651
|
update(data) {
|
|
45652
45652
|
this.hash.update(toUint8Array2(data));
|
|
45653
45653
|
}
|
|
@@ -45656,7 +45656,7 @@ var require_checksum5 = __commonJS((exports) => {
|
|
|
45656
45656
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
45657
45657
|
}
|
|
45658
45658
|
reset() {
|
|
45659
|
-
this.hash =
|
|
45659
|
+
this.hash = createHash2("md5");
|
|
45660
45660
|
}
|
|
45661
45661
|
};
|
|
45662
45662
|
}
|
|
@@ -45946,7 +45946,7 @@ var require_checksum5 = __commonJS((exports) => {
|
|
|
45946
45946
|
]);
|
|
45947
45947
|
var hasNativeCrypto = (() => {
|
|
45948
45948
|
try {
|
|
45949
|
-
|
|
45949
|
+
createHash2("sha256");
|
|
45950
45950
|
return true;
|
|
45951
45951
|
} catch {
|
|
45952
45952
|
return false;
|
|
@@ -45986,7 +45986,7 @@ var require_checksum5 = __commonJS((exports) => {
|
|
|
45986
45986
|
this.finished = false;
|
|
45987
45987
|
}
|
|
45988
45988
|
createHash() {
|
|
45989
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
45989
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
45990
45990
|
}
|
|
45991
45991
|
};
|
|
45992
45992
|
}
|
|
@@ -50235,7 +50235,7 @@ var require_client7 = __commonJS((exports) => {
|
|
|
50235
50235
|
var require_config6 = __commonJS((exports) => {
|
|
50236
50236
|
var { homedir } = __require("os");
|
|
50237
50237
|
var { sep, join } = __require("path");
|
|
50238
|
-
var { createHash } = __require("crypto");
|
|
50238
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
50239
50239
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
50240
50240
|
var { IniSectionType } = require_dist_cjs();
|
|
50241
50241
|
var { normalizeProvider: normalizeProvider4 } = require_client7();
|
|
@@ -50390,7 +50390,7 @@ var require_config6 = __commonJS((exports) => {
|
|
|
50390
50390
|
var DEFAULT_PROFILE = "default";
|
|
50391
50391
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
50392
50392
|
var getSSOTokenFilepath = (id) => {
|
|
50393
|
-
const hasher =
|
|
50393
|
+
const hasher = createHash2("sha1");
|
|
50394
50394
|
const cacheName = hasher.update(id).digest("hex");
|
|
50395
50395
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
50396
50396
|
};
|
|
@@ -52895,7 +52895,7 @@ var require_client8 = __commonJS((exports) => {
|
|
|
52895
52895
|
var require_config7 = __commonJS((exports) => {
|
|
52896
52896
|
var { homedir } = __require("os");
|
|
52897
52897
|
var { sep, join } = __require("path");
|
|
52898
|
-
var { createHash } = __require("crypto");
|
|
52898
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
52899
52899
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
52900
52900
|
var { IniSectionType } = require_dist_cjs();
|
|
52901
52901
|
var { normalizeProvider: normalizeProvider4 } = require_client8();
|
|
@@ -53050,7 +53050,7 @@ var require_config7 = __commonJS((exports) => {
|
|
|
53050
53050
|
var DEFAULT_PROFILE = "default";
|
|
53051
53051
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
53052
53052
|
var getSSOTokenFilepath = (id) => {
|
|
53053
|
-
const hasher =
|
|
53053
|
+
const hasher = createHash2("sha1");
|
|
53054
53054
|
const cacheName = hasher.update(id).digest("hex");
|
|
53055
53055
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
53056
53056
|
};
|
|
@@ -54552,7 +54552,7 @@ var require_endpoints6 = __commonJS((exports) => {
|
|
|
54552
54552
|
|
|
54553
54553
|
// node_modules/@smithy/credential-provider-imds/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
54554
54554
|
var require_serde6 = __commonJS((exports) => {
|
|
54555
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
54555
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
54556
54556
|
var { hasOwn: hasOwn3, HttpResponse: HttpResponse3 } = require_transport7();
|
|
54557
54557
|
exports.hasOwn = hasOwn3;
|
|
54558
54558
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -55457,7 +55457,7 @@ var require_serde6 = __commonJS((exports) => {
|
|
|
55457
55457
|
return Promise.resolve(this.hash.digest());
|
|
55458
55458
|
}
|
|
55459
55459
|
reset() {
|
|
55460
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
55460
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
55461
55461
|
}
|
|
55462
55462
|
}
|
|
55463
55463
|
function castSourceData(toCast, encoding) {
|
|
@@ -58376,7 +58376,7 @@ var require_client9 = __commonJS((exports) => {
|
|
|
58376
58376
|
var require_config8 = __commonJS((exports) => {
|
|
58377
58377
|
var { homedir } = __require("os");
|
|
58378
58378
|
var { sep, join } = __require("path");
|
|
58379
|
-
var { createHash } = __require("crypto");
|
|
58379
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
58380
58380
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
58381
58381
|
var { IniSectionType } = require_dist_cjs();
|
|
58382
58382
|
var { normalizeProvider: normalizeProvider4 } = require_client9();
|
|
@@ -58531,7 +58531,7 @@ var require_config8 = __commonJS((exports) => {
|
|
|
58531
58531
|
var DEFAULT_PROFILE = "default";
|
|
58532
58532
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
58533
58533
|
var getSSOTokenFilepath = (id) => {
|
|
58534
|
-
const hasher =
|
|
58534
|
+
const hasher = createHash2("sha1");
|
|
58535
58535
|
const cacheName = hasher.update(id).digest("hex");
|
|
58536
58536
|
return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
58537
58537
|
};
|
|
@@ -59883,7 +59883,7 @@ var require_endpoints7 = __commonJS((exports) => {
|
|
|
59883
59883
|
|
|
59884
59884
|
// node_modules/@smithy/node-http-handler/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
59885
59885
|
var require_serde7 = __commonJS((exports) => {
|
|
59886
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
59886
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
59887
59887
|
var { hasOwn: hasOwn4, HttpResponse: HttpResponse4 } = require_transport8();
|
|
59888
59888
|
exports.hasOwn = hasOwn4;
|
|
59889
59889
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -60788,7 +60788,7 @@ var require_serde7 = __commonJS((exports) => {
|
|
|
60788
60788
|
return Promise.resolve(this.hash.digest());
|
|
60789
60789
|
}
|
|
60790
60790
|
reset() {
|
|
60791
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
60791
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
60792
60792
|
}
|
|
60793
60793
|
}
|
|
60794
60794
|
function castSourceData(toCast, encoding) {
|
|
@@ -61527,7 +61527,7 @@ var require_checksum6 = __commonJS((exports) => {
|
|
|
61527
61527
|
var { createReadStream } = __require("fs");
|
|
61528
61528
|
var { Writable } = __require("stream");
|
|
61529
61529
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde7();
|
|
61530
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
61530
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
61531
61531
|
var zlib = __require("zlib");
|
|
61532
61532
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
61533
61533
|
const size = blob.size;
|
|
@@ -61692,7 +61692,7 @@ var require_checksum6 = __commonJS((exports) => {
|
|
|
61692
61692
|
}
|
|
61693
61693
|
var hasNativeCrypto$1 = (() => {
|
|
61694
61694
|
try {
|
|
61695
|
-
|
|
61695
|
+
createHash2("md5");
|
|
61696
61696
|
return true;
|
|
61697
61697
|
} catch {
|
|
61698
61698
|
return false;
|
|
@@ -61702,7 +61702,7 @@ var require_checksum6 = __commonJS((exports) => {
|
|
|
61702
61702
|
function buildNativeClass$2() {
|
|
61703
61703
|
return class Md5Node2 {
|
|
61704
61704
|
digestLength = 16;
|
|
61705
|
-
hash =
|
|
61705
|
+
hash = createHash2("md5");
|
|
61706
61706
|
update(data) {
|
|
61707
61707
|
this.hash.update(toUint8Array2(data));
|
|
61708
61708
|
}
|
|
@@ -61711,7 +61711,7 @@ var require_checksum6 = __commonJS((exports) => {
|
|
|
61711
61711
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
61712
61712
|
}
|
|
61713
61713
|
reset() {
|
|
61714
|
-
this.hash =
|
|
61714
|
+
this.hash = createHash2("md5");
|
|
61715
61715
|
}
|
|
61716
61716
|
};
|
|
61717
61717
|
}
|
|
@@ -62001,7 +62001,7 @@ var require_checksum6 = __commonJS((exports) => {
|
|
|
62001
62001
|
]);
|
|
62002
62002
|
var hasNativeCrypto = (() => {
|
|
62003
62003
|
try {
|
|
62004
|
-
|
|
62004
|
+
createHash2("sha256");
|
|
62005
62005
|
return true;
|
|
62006
62006
|
} catch {
|
|
62007
62007
|
return false;
|
|
@@ -62041,7 +62041,7 @@ var require_checksum6 = __commonJS((exports) => {
|
|
|
62041
62041
|
this.finished = false;
|
|
62042
62042
|
}
|
|
62043
62043
|
createHash() {
|
|
62044
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
62044
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
62045
62045
|
}
|
|
62046
62046
|
};
|
|
62047
62047
|
}
|
|
@@ -65710,7 +65710,7 @@ var require_endpoints8 = __commonJS((exports) => {
|
|
|
65710
65710
|
|
|
65711
65711
|
// node_modules/@aws-sdk/credential-provider-node/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
65712
65712
|
var require_serde8 = __commonJS((exports) => {
|
|
65713
|
-
var { createHmac: createHmac2, createHash, getRandomValues } = __require("crypto");
|
|
65713
|
+
var { createHmac: createHmac2, createHash: createHash2, getRandomValues } = __require("crypto");
|
|
65714
65714
|
var { hasOwn: hasOwn4, HttpResponse: HttpResponse4 } = require_transport6();
|
|
65715
65715
|
exports.hasOwn = hasOwn4;
|
|
65716
65716
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -66615,7 +66615,7 @@ var require_serde8 = __commonJS((exports) => {
|
|
|
66615
66615
|
return Promise.resolve(this.hash.digest());
|
|
66616
66616
|
}
|
|
66617
66617
|
reset() {
|
|
66618
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
66618
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash2(this.algorithmIdentifier);
|
|
66619
66619
|
}
|
|
66620
66620
|
}
|
|
66621
66621
|
function castSourceData(toCast, encoding) {
|
|
@@ -67354,7 +67354,7 @@ var require_checksum7 = __commonJS((exports) => {
|
|
|
67354
67354
|
var { createReadStream } = __require("fs");
|
|
67355
67355
|
var { Writable } = __require("stream");
|
|
67356
67356
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde8();
|
|
67357
|
-
var { createHash, createHmac: createHmac2 } = __require("crypto");
|
|
67357
|
+
var { createHash: createHash2, createHmac: createHmac2 } = __require("crypto");
|
|
67358
67358
|
var zlib = __require("zlib");
|
|
67359
67359
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
67360
67360
|
const size = blob.size;
|
|
@@ -67519,7 +67519,7 @@ var require_checksum7 = __commonJS((exports) => {
|
|
|
67519
67519
|
}
|
|
67520
67520
|
var hasNativeCrypto$1 = (() => {
|
|
67521
67521
|
try {
|
|
67522
|
-
|
|
67522
|
+
createHash2("md5");
|
|
67523
67523
|
return true;
|
|
67524
67524
|
} catch {
|
|
67525
67525
|
return false;
|
|
@@ -67529,7 +67529,7 @@ var require_checksum7 = __commonJS((exports) => {
|
|
|
67529
67529
|
function buildNativeClass$2() {
|
|
67530
67530
|
return class Md5Node2 {
|
|
67531
67531
|
digestLength = 16;
|
|
67532
|
-
hash =
|
|
67532
|
+
hash = createHash2("md5");
|
|
67533
67533
|
update(data) {
|
|
67534
67534
|
this.hash.update(toUint8Array2(data));
|
|
67535
67535
|
}
|
|
@@ -67538,7 +67538,7 @@ var require_checksum7 = __commonJS((exports) => {
|
|
|
67538
67538
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
67539
67539
|
}
|
|
67540
67540
|
reset() {
|
|
67541
|
-
this.hash =
|
|
67541
|
+
this.hash = createHash2("md5");
|
|
67542
67542
|
}
|
|
67543
67543
|
};
|
|
67544
67544
|
}
|
|
@@ -67828,7 +67828,7 @@ var require_checksum7 = __commonJS((exports) => {
|
|
|
67828
67828
|
]);
|
|
67829
67829
|
var hasNativeCrypto = (() => {
|
|
67830
67830
|
try {
|
|
67831
|
-
|
|
67831
|
+
createHash2("sha256");
|
|
67832
67832
|
return true;
|
|
67833
67833
|
} catch {
|
|
67834
67834
|
return false;
|
|
@@ -67868,7 +67868,7 @@ var require_checksum7 = __commonJS((exports) => {
|
|
|
67868
67868
|
this.finished = false;
|
|
67869
67869
|
}
|
|
67870
67870
|
createHash() {
|
|
67871
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
67871
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash2("sha256");
|
|
67872
67872
|
}
|
|
67873
67873
|
};
|
|
67874
67874
|
}
|
|
@@ -74546,7 +74546,7 @@ var require_signin = __commonJS((exports) => {
|
|
|
74546
74546
|
});
|
|
74547
74547
|
|
|
74548
74548
|
// node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
|
|
74549
|
-
import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
74549
|
+
import { createHash as createHash2, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
74550
74550
|
import { promises as fs2 } from "fs";
|
|
74551
74551
|
import { homedir } from "os";
|
|
74552
74552
|
import { dirname, join } from "path";
|
|
@@ -74718,7 +74718,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
74718
74718
|
getTokenFilePath() {
|
|
74719
74719
|
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
|
|
74720
74720
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
74721
|
-
const loginSessionSha256 =
|
|
74721
|
+
const loginSessionSha256 = createHash2("sha256").update(loginSessionBytes).digest("hex");
|
|
74722
74722
|
return join(directory, `${loginSessionSha256}.json`);
|
|
74723
74723
|
}
|
|
74724
74724
|
derToRawSignature(derSignature) {
|
|
@@ -76352,8 +76352,8 @@ var require_schema9 = __commonJS((exports) => {
|
|
|
76352
76352
|
input,
|
|
76353
76353
|
output
|
|
76354
76354
|
});
|
|
76355
|
-
var schemaDeserializationMiddleware = (config) => (
|
|
76356
|
-
const { response } = await
|
|
76355
|
+
var schemaDeserializationMiddleware = (config) => (next2, context) => async (args) => {
|
|
76356
|
+
const { response } = await next2(args);
|
|
76357
76357
|
const { operationSchema } = getSmithyContext5(context);
|
|
76358
76358
|
const [, ns, n2, t2, i3, o2] = operationSchema ?? [];
|
|
76359
76359
|
try {
|
|
@@ -76410,7 +76410,7 @@ var require_schema9 = __commonJS((exports) => {
|
|
|
76410
76410
|
return k3.match(pattern);
|
|
76411
76411
|
}) || [undefined, undefined])[1];
|
|
76412
76412
|
};
|
|
76413
|
-
var schemaSerializationMiddleware = (config) => (
|
|
76413
|
+
var schemaSerializationMiddleware = (config) => (next2, context) => async (args) => {
|
|
76414
76414
|
const { operationSchema } = getSmithyContext5(context);
|
|
76415
76415
|
const [, ns, n2, t2, i3, o2] = operationSchema ?? [];
|
|
76416
76416
|
const endpoint = context.endpointV2 ? async () => toEndpointV1(context.endpointV2) : config.endpoint;
|
|
@@ -76419,7 +76419,7 @@ var require_schema9 = __commonJS((exports) => {
|
|
|
76419
76419
|
...context,
|
|
76420
76420
|
endpoint
|
|
76421
76421
|
});
|
|
76422
|
-
return
|
|
76422
|
+
return next2({
|
|
76423
76423
|
...args,
|
|
76424
76424
|
request
|
|
76425
76425
|
});
|
|
@@ -78089,7 +78089,7 @@ var require_client10 = __commonJS((exports) => {
|
|
|
78089
78089
|
var require_config9 = __commonJS((exports) => {
|
|
78090
78090
|
var { homedir: homedir3 } = __require("os");
|
|
78091
78091
|
var { sep, join: join6 } = __require("path");
|
|
78092
|
-
var { createHash:
|
|
78092
|
+
var { createHash: createHash9 } = __require("crypto");
|
|
78093
78093
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
78094
78094
|
var { IniSectionType } = require_dist_cjs();
|
|
78095
78095
|
var { normalizeProvider: normalizeProvider5 } = require_client10();
|
|
@@ -78244,7 +78244,7 @@ var require_config9 = __commonJS((exports) => {
|
|
|
78244
78244
|
var DEFAULT_PROFILE = "default";
|
|
78245
78245
|
var getProfileName7 = (init) => init.profile || process.env[ENV_PROFILE2] || DEFAULT_PROFILE;
|
|
78246
78246
|
var getSSOTokenFilepath2 = (id) => {
|
|
78247
|
-
const hasher =
|
|
78247
|
+
const hasher = createHash9("sha1");
|
|
78248
78248
|
const cacheName = hasher.update(id).digest("hex");
|
|
78249
78249
|
return join6(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
78250
78250
|
};
|
|
@@ -78987,7 +78987,7 @@ var require_endpoints9 = __commonJS((exports) => {
|
|
|
78987
78987
|
function bindEndpointMiddleware(getEndpointFromConfig2) {
|
|
78988
78988
|
const getEndpointFromInstructions2 = bindGetEndpointFromInstructions(getEndpointFromConfig2);
|
|
78989
78989
|
return ({ config, instructions }) => {
|
|
78990
|
-
return (
|
|
78990
|
+
return (next2, context) => async (args) => {
|
|
78991
78991
|
if (config.isCustomEndpoint) {
|
|
78992
78992
|
setFeature3(context, "ENDPOINT_OVERRIDE", "N");
|
|
78993
78993
|
}
|
|
@@ -79014,7 +79014,7 @@ var require_endpoints9 = __commonJS((exports) => {
|
|
|
79014
79014
|
}, authScheme.properties);
|
|
79015
79015
|
}
|
|
79016
79016
|
}
|
|
79017
|
-
return
|
|
79017
|
+
return next2({
|
|
79018
79018
|
...args
|
|
79019
79019
|
});
|
|
79020
79020
|
};
|
|
@@ -79100,10 +79100,10 @@ var require_endpoints9 = __commonJS((exports) => {
|
|
|
79100
79100
|
}
|
|
79101
79101
|
if (!this.data.has(key)) {
|
|
79102
79102
|
if (this.data.size > this.capacity + 10) {
|
|
79103
|
-
const
|
|
79103
|
+
const keys2 = this.data.keys();
|
|
79104
79104
|
let i3 = 0;
|
|
79105
79105
|
while (true) {
|
|
79106
|
-
const { value, done } =
|
|
79106
|
+
const { value, done } = keys2.next();
|
|
79107
79107
|
this.data.delete(value);
|
|
79108
79108
|
if (done || ++i3 > 10) {
|
|
79109
79109
|
break;
|
|
@@ -79238,10 +79238,10 @@ var require_endpoints9 = __commonJS((exports) => {
|
|
|
79238
79238
|
}
|
|
79239
79239
|
const isIp = isIpAddress(hostname);
|
|
79240
79240
|
const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) || typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`);
|
|
79241
|
-
const
|
|
79241
|
+
const authority2 = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
|
|
79242
79242
|
return {
|
|
79243
79243
|
scheme,
|
|
79244
|
-
authority,
|
|
79244
|
+
authority: authority2,
|
|
79245
79245
|
path: pathname,
|
|
79246
79246
|
normalizedPath: pathname.endsWith("/") ? pathname : `${pathname}/`,
|
|
79247
79247
|
isIp
|
|
@@ -79596,7 +79596,7 @@ var require_endpoints9 = __commonJS((exports) => {
|
|
|
79596
79596
|
|
|
79597
79597
|
// node_modules/@aws-sdk/client-ecs/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
79598
79598
|
var require_serde9 = __commonJS((exports) => {
|
|
79599
|
-
var { createHmac: createHmac3, createHash:
|
|
79599
|
+
var { createHmac: createHmac3, createHash: createHash9, getRandomValues } = __require("crypto");
|
|
79600
79600
|
var { hasOwn: hasOwn4, HttpResponse: HttpResponse4 } = require_transport9();
|
|
79601
79601
|
exports.hasOwn = hasOwn4;
|
|
79602
79602
|
var { ReadStream, lstatSync, fstatSync } = __require("fs");
|
|
@@ -80351,26 +80351,26 @@ var require_serde9 = __commonJS((exports) => {
|
|
|
80351
80351
|
}
|
|
80352
80352
|
return out;
|
|
80353
80353
|
}
|
|
80354
|
-
var calculateBodyLength3 = (
|
|
80355
|
-
if (!
|
|
80354
|
+
var calculateBodyLength3 = (body3) => {
|
|
80355
|
+
if (!body3) {
|
|
80356
80356
|
return 0;
|
|
80357
80357
|
}
|
|
80358
|
-
if (typeof
|
|
80359
|
-
return Buffer.byteLength(
|
|
80360
|
-
} else if (typeof
|
|
80361
|
-
return
|
|
80362
|
-
} else if (typeof
|
|
80363
|
-
return
|
|
80364
|
-
} else if (typeof
|
|
80365
|
-
return
|
|
80366
|
-
} else if (
|
|
80367
|
-
if (
|
|
80368
|
-
return lstatSync(
|
|
80369
|
-
} else if (typeof
|
|
80370
|
-
return fstatSync(
|
|
80358
|
+
if (typeof body3 === "string") {
|
|
80359
|
+
return Buffer.byteLength(body3);
|
|
80360
|
+
} else if (typeof body3.byteLength === "number") {
|
|
80361
|
+
return body3.byteLength;
|
|
80362
|
+
} else if (typeof body3.size === "number") {
|
|
80363
|
+
return body3.size;
|
|
80364
|
+
} else if (typeof body3.start === "number" && typeof body3.end === "number") {
|
|
80365
|
+
return body3.end + 1 - body3.start;
|
|
80366
|
+
} else if (body3 instanceof ReadStream) {
|
|
80367
|
+
if (body3.path != null) {
|
|
80368
|
+
return lstatSync(body3.path).size;
|
|
80369
|
+
} else if (typeof body3.fd === "number") {
|
|
80370
|
+
return fstatSync(body3.fd).size;
|
|
80371
80371
|
}
|
|
80372
80372
|
}
|
|
80373
|
-
throw new Error(`Body Length computation failed for ${
|
|
80373
|
+
throw new Error(`Body Length computation failed for ${body3}`);
|
|
80374
80374
|
};
|
|
80375
80375
|
var toUint8Array3 = (data) => {
|
|
80376
80376
|
if (data instanceof Uint8Array) {
|
|
@@ -80399,8 +80399,8 @@ var require_serde9 = __commonJS((exports) => {
|
|
|
80399
80399
|
}
|
|
80400
80400
|
return result;
|
|
80401
80401
|
}
|
|
80402
|
-
var deserializerMiddleware = (options, deserializer) => (
|
|
80403
|
-
const { response } = await
|
|
80402
|
+
var deserializerMiddleware = (options, deserializer) => (next2, context) => async (args) => {
|
|
80403
|
+
const { response } = await next2(args);
|
|
80404
80404
|
try {
|
|
80405
80405
|
const parsed = await deserializer(response, options);
|
|
80406
80406
|
return {
|
|
@@ -80452,14 +80452,14 @@ var require_serde9 = __commonJS((exports) => {
|
|
|
80452
80452
|
return k3.match(pattern);
|
|
80453
80453
|
}) || [undefined, undefined])[1];
|
|
80454
80454
|
};
|
|
80455
|
-
var serializerMiddleware = (options, serializer) => (
|
|
80455
|
+
var serializerMiddleware = (options, serializer) => (next2, context) => async (args) => {
|
|
80456
80456
|
const endpointConfig = options;
|
|
80457
80457
|
const endpoint = context.endpointV2 ? async () => toEndpointV1(context.endpointV2) : endpointConfig.endpoint;
|
|
80458
80458
|
if (!endpoint) {
|
|
80459
80459
|
throw new Error("No valid endpoint provider available.");
|
|
80460
80460
|
}
|
|
80461
80461
|
const request = await serializer(args.input, { ...options, endpoint });
|
|
80462
|
-
return
|
|
80462
|
+
return next2({
|
|
80463
80463
|
...args,
|
|
80464
80464
|
request
|
|
80465
80465
|
});
|
|
@@ -80501,7 +80501,7 @@ var require_serde9 = __commonJS((exports) => {
|
|
|
80501
80501
|
return Promise.resolve(this.hash.digest());
|
|
80502
80502
|
}
|
|
80503
80503
|
reset() {
|
|
80504
|
-
this.hash = this.secret ? createHmac3(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
80504
|
+
this.hash = this.secret ? createHmac3(this.algorithmIdentifier, castSourceData(this.secret)) : createHash9(this.algorithmIdentifier);
|
|
80505
80505
|
}
|
|
80506
80506
|
}
|
|
80507
80507
|
function castSourceData(toCast, encoding) {
|
|
@@ -81240,7 +81240,7 @@ var require_checksum8 = __commonJS((exports) => {
|
|
|
81240
81240
|
var { createReadStream } = __require("fs");
|
|
81241
81241
|
var { Writable } = __require("stream");
|
|
81242
81242
|
var { toUint8Array: toUint8Array3, concatBytes: concatBytes2 } = require_serde9();
|
|
81243
|
-
var { createHash:
|
|
81243
|
+
var { createHash: createHash9, createHmac: createHmac3 } = __require("crypto");
|
|
81244
81244
|
var zlib = __require("zlib");
|
|
81245
81245
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
81246
81246
|
const size = blob.size;
|
|
@@ -81405,7 +81405,7 @@ var require_checksum8 = __commonJS((exports) => {
|
|
|
81405
81405
|
}
|
|
81406
81406
|
var hasNativeCrypto$1 = (() => {
|
|
81407
81407
|
try {
|
|
81408
|
-
|
|
81408
|
+
createHash9("md5");
|
|
81409
81409
|
return true;
|
|
81410
81410
|
} catch {
|
|
81411
81411
|
return false;
|
|
@@ -81415,7 +81415,7 @@ var require_checksum8 = __commonJS((exports) => {
|
|
|
81415
81415
|
function buildNativeClass$2() {
|
|
81416
81416
|
return class Md5Node2 {
|
|
81417
81417
|
digestLength = 16;
|
|
81418
|
-
hash =
|
|
81418
|
+
hash = createHash9("md5");
|
|
81419
81419
|
update(data) {
|
|
81420
81420
|
this.hash.update(toUint8Array3(data));
|
|
81421
81421
|
}
|
|
@@ -81424,7 +81424,7 @@ var require_checksum8 = __commonJS((exports) => {
|
|
|
81424
81424
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
81425
81425
|
}
|
|
81426
81426
|
reset() {
|
|
81427
|
-
this.hash =
|
|
81427
|
+
this.hash = createHash9("md5");
|
|
81428
81428
|
}
|
|
81429
81429
|
};
|
|
81430
81430
|
}
|
|
@@ -81714,7 +81714,7 @@ var require_checksum8 = __commonJS((exports) => {
|
|
|
81714
81714
|
]);
|
|
81715
81715
|
var hasNativeCrypto2 = (() => {
|
|
81716
81716
|
try {
|
|
81717
|
-
|
|
81717
|
+
createHash9("sha256");
|
|
81718
81718
|
return true;
|
|
81719
81719
|
} catch {
|
|
81720
81720
|
return false;
|
|
@@ -81754,7 +81754,7 @@ var require_checksum8 = __commonJS((exports) => {
|
|
|
81754
81754
|
this.finished = false;
|
|
81755
81755
|
}
|
|
81756
81756
|
createHash() {
|
|
81757
|
-
return this.secret ? createHmac3("sha256", toBuffer2(this.secret)) :
|
|
81757
|
+
return this.secret ? createHmac3("sha256", toBuffer2(this.secret)) : createHash9("sha256");
|
|
81758
81758
|
}
|
|
81759
81759
|
};
|
|
81760
81760
|
}
|
|
@@ -82158,9 +82158,9 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82158
82158
|
}
|
|
82159
82159
|
};
|
|
82160
82160
|
}
|
|
82161
|
-
encode({ headers: rawHeaders, body:
|
|
82161
|
+
encode({ headers: rawHeaders, body: body3 }) {
|
|
82162
82162
|
const headers = this.headerMarshaller.format(rawHeaders);
|
|
82163
|
-
const length = headers.byteLength +
|
|
82163
|
+
const length = headers.byteLength + body3.byteLength + 16;
|
|
82164
82164
|
const out = new Uint8Array(length);
|
|
82165
82165
|
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
82166
82166
|
const checksum = new Crc322;
|
|
@@ -82169,14 +82169,14 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82169
82169
|
checksum.update(out.subarray(0, 8));
|
|
82170
82170
|
view.setUint32(8, checksum.digestSync(), false);
|
|
82171
82171
|
out.set(headers, 12);
|
|
82172
|
-
out.set(
|
|
82172
|
+
out.set(body3, headers.byteLength + 12);
|
|
82173
82173
|
checksum.update(out.subarray(8, length - 4));
|
|
82174
82174
|
view.setUint32(length - 4, checksum.digestSync(), false);
|
|
82175
82175
|
return out;
|
|
82176
82176
|
}
|
|
82177
82177
|
decode(message) {
|
|
82178
|
-
const { headers, body:
|
|
82179
|
-
return { headers: this.headerMarshaller.parse(headers), body:
|
|
82178
|
+
const { headers, body: body3 } = splitMessage(message);
|
|
82179
|
+
return { headers: this.headerMarshaller.parse(headers), body: body3 };
|
|
82180
82180
|
}
|
|
82181
82181
|
formatHeaders(rawHeaders) {
|
|
82182
82182
|
return this.headerMarshaller.format(rawHeaders);
|
|
@@ -82366,8 +82366,8 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82366
82366
|
this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
|
|
82367
82367
|
this.utfEncoder = utf8Encoder;
|
|
82368
82368
|
}
|
|
82369
|
-
deserialize(
|
|
82370
|
-
const inputStream = getChunkedStream(
|
|
82369
|
+
deserialize(body3, deserializer) {
|
|
82370
|
+
const inputStream = getChunkedStream(body3);
|
|
82371
82371
|
return new SmithyMessageDecoderStream({
|
|
82372
82372
|
messageStream: new MessageDecoderStream({ inputStream, decoder: this.eventStreamCodec }),
|
|
82373
82373
|
deserializer: getMessageUnmarshaller(deserializer, this.utfEncoder)
|
|
@@ -82391,8 +82391,8 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82391
82391
|
utf8Encoder
|
|
82392
82392
|
});
|
|
82393
82393
|
}
|
|
82394
|
-
deserialize(
|
|
82395
|
-
const bodyIterable = typeof
|
|
82394
|
+
deserialize(body3, deserializer) {
|
|
82395
|
+
const bodyIterable = typeof body3[Symbol.asyncIterator] === "function" ? body3 : readableToIterable(body3);
|
|
82396
82396
|
return this.universalMarshaller.deserialize(bodyIterable, deserializer);
|
|
82397
82397
|
}
|
|
82398
82398
|
serialize(input, serializer) {
|
|
@@ -82488,11 +82488,11 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82488
82488
|
":content-type": { type: "string", value: defaultContentType }
|
|
82489
82489
|
};
|
|
82490
82490
|
serializer.write(requestSchema, initialRequest);
|
|
82491
|
-
const
|
|
82491
|
+
const body3 = serializer.flush();
|
|
82492
82492
|
yield {
|
|
82493
82493
|
[initialRequestMarker]: true,
|
|
82494
82494
|
headers,
|
|
82495
|
-
body:
|
|
82495
|
+
body: body3
|
|
82496
82496
|
};
|
|
82497
82497
|
}
|
|
82498
82498
|
for await (const page of eventStream) {
|
|
@@ -82516,7 +82516,7 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82516
82516
|
break;
|
|
82517
82517
|
}
|
|
82518
82518
|
}
|
|
82519
|
-
const { additionalHeaders, body:
|
|
82519
|
+
const { additionalHeaders, body: body3, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
|
82520
82520
|
const headers = {
|
|
82521
82521
|
":event-type": { type: "string", value: eventType },
|
|
82522
82522
|
":message-type": { type: "string", value: "event" },
|
|
@@ -82525,7 +82525,7 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82525
82525
|
};
|
|
82526
82526
|
return {
|
|
82527
82527
|
headers,
|
|
82528
|
-
body:
|
|
82528
|
+
body: body3
|
|
82529
82529
|
};
|
|
82530
82530
|
});
|
|
82531
82531
|
}
|
|
@@ -82545,9 +82545,9 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82545
82545
|
break;
|
|
82546
82546
|
}
|
|
82547
82547
|
}
|
|
82548
|
-
const
|
|
82548
|
+
const body3 = event[unionMember].body;
|
|
82549
82549
|
if (unionMember === (initialMessageType ?? "initial-response")) {
|
|
82550
|
-
const dataObject = await this.deserializer.read(responseSchema,
|
|
82550
|
+
const dataObject = await this.deserializer.read(responseSchema, body3);
|
|
82551
82551
|
delete dataObject[eventStreamMember];
|
|
82552
82552
|
return {
|
|
82553
82553
|
[initialResponseMarker]: true,
|
|
@@ -82563,11 +82563,11 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82563
82563
|
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
|
82564
82564
|
if (eventPayload) {
|
|
82565
82565
|
if (member.isBlobSchema()) {
|
|
82566
|
-
out[name] =
|
|
82566
|
+
out[name] = body3;
|
|
82567
82567
|
} else if (member.isStringSchema()) {
|
|
82568
|
-
out[name] = (this.serdeContext?.utf8Encoder ?? toUtf84)(
|
|
82568
|
+
out[name] = (this.serdeContext?.utf8Encoder ?? toUtf84)(body3);
|
|
82569
82569
|
} else if (member.isStructSchema()) {
|
|
82570
|
-
out[name] = await this.deserializer.read(member,
|
|
82570
|
+
out[name] = await this.deserializer.read(member, body3);
|
|
82571
82571
|
}
|
|
82572
82572
|
} else if (eventHeader) {
|
|
82573
82573
|
const value = event[unionMember].headers[name]?.value;
|
|
@@ -82585,11 +82585,11 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82585
82585
|
}
|
|
82586
82586
|
}
|
|
82587
82587
|
return {
|
|
82588
|
-
[unionMember]: await this.readEventMember(eventStreamSchema,
|
|
82588
|
+
[unionMember]: await this.readEventMember(eventStreamSchema, body3, hasBindings, out)
|
|
82589
82589
|
};
|
|
82590
82590
|
}
|
|
82591
82591
|
return {
|
|
82592
|
-
[unionMember]: await this.deserializer.read(eventStreamSchema,
|
|
82592
|
+
[unionMember]: await this.deserializer.read(eventStreamSchema, body3)
|
|
82593
82593
|
};
|
|
82594
82594
|
} else {
|
|
82595
82595
|
return {
|
|
@@ -82627,7 +82627,7 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82627
82627
|
}
|
|
82628
82628
|
};
|
|
82629
82629
|
}
|
|
82630
|
-
async readEventMember(eventStreamSchema,
|
|
82630
|
+
async readEventMember(eventStreamSchema, body3, hasBindings, out) {
|
|
82631
82631
|
let ErrCtor;
|
|
82632
82632
|
const staticStructuralSchema = eventStreamSchema.getSchema();
|
|
82633
82633
|
if (Array.isArray(staticStructuralSchema) && staticStructuralSchema[0] === -3) {
|
|
@@ -82636,7 +82636,7 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82636
82636
|
this.compositeErrorRegistry?.copyFrom(nsRegistry);
|
|
82637
82637
|
ErrCtor = (this.compositeErrorRegistry ?? nsRegistry)?.getErrorCtor(staticStructuralSchema);
|
|
82638
82638
|
}
|
|
82639
|
-
const dataObject = hasBindings ? out :
|
|
82639
|
+
const dataObject = hasBindings ? out : body3.byteLength === 0 ? {} : await this.deserializer.read(eventStreamSchema, body3);
|
|
82640
82640
|
if (ErrCtor) {
|
|
82641
82641
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
82642
82642
|
const metadata = {};
|
|
@@ -82714,9 +82714,9 @@ var require_event_streams8 = __commonJS((exports) => {
|
|
|
82714
82714
|
}
|
|
82715
82715
|
}
|
|
82716
82716
|
const messageSerialization = serializer.flush() ?? new Uint8Array;
|
|
82717
|
-
const
|
|
82717
|
+
const body3 = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf84)(messageSerialization) : messageSerialization;
|
|
82718
82718
|
return {
|
|
82719
|
-
body:
|
|
82719
|
+
body: body3,
|
|
82720
82720
|
eventType,
|
|
82721
82721
|
explicitPayloadContentType,
|
|
82722
82722
|
additionalHeaders
|
|
@@ -83357,8 +83357,8 @@ var require_protocols9 = __commonJS((exports) => {
|
|
|
83357
83357
|
this.query = query;
|
|
83358
83358
|
return this;
|
|
83359
83359
|
}
|
|
83360
|
-
b(
|
|
83361
|
-
this.body =
|
|
83360
|
+
b(body3) {
|
|
83361
|
+
this.body = body3;
|
|
83362
83362
|
return this;
|
|
83363
83363
|
}
|
|
83364
83364
|
m(method) {
|
|
@@ -83666,13 +83666,13 @@ var require_protocols9 = __commonJS((exports) => {
|
|
|
83666
83666
|
};
|
|
83667
83667
|
var CONTENT_LENGTH_HEADER2 = "content-length";
|
|
83668
83668
|
function contentLengthMiddleware(bodyLengthChecker) {
|
|
83669
|
-
return (
|
|
83669
|
+
return (next2) => async (args) => {
|
|
83670
83670
|
const request = args.request;
|
|
83671
83671
|
if (HttpRequest8.isInstance(request)) {
|
|
83672
|
-
const { body:
|
|
83673
|
-
if (
|
|
83672
|
+
const { body: body3, headers } = request;
|
|
83673
|
+
if (body3 && Object.keys(headers).map((str) => str.toLowerCase()).indexOf(CONTENT_LENGTH_HEADER2) === -1) {
|
|
83674
83674
|
try {
|
|
83675
|
-
const length = bodyLengthChecker(
|
|
83675
|
+
const length = bodyLengthChecker(body3);
|
|
83676
83676
|
if (length != null) {
|
|
83677
83677
|
request.headers = {
|
|
83678
83678
|
...request.headers,
|
|
@@ -83682,7 +83682,7 @@ var require_protocols9 = __commonJS((exports) => {
|
|
|
83682
83682
|
} catch (ignored) {}
|
|
83683
83683
|
}
|
|
83684
83684
|
}
|
|
83685
|
-
return
|
|
83685
|
+
return next2({
|
|
83686
83686
|
...args,
|
|
83687
83687
|
request
|
|
83688
83688
|
});
|
|
@@ -83749,7 +83749,7 @@ var require_protocols9 = __commonJS((exports) => {
|
|
|
83749
83749
|
// package.json
|
|
83750
83750
|
var package_default = {
|
|
83751
83751
|
name: "@hasna/skills",
|
|
83752
|
-
version: "0.8.
|
|
83752
|
+
version: "0.8.3",
|
|
83753
83753
|
description: "Skills library for AI coding agents",
|
|
83754
83754
|
type: "module",
|
|
83755
83755
|
bin: {
|
|
@@ -83882,6 +83882,10 @@ var REMOTE_SKILL_RUN_CONTRACT_VERSION = 1;
|
|
|
83882
83882
|
// src/lib/skill-bundles.ts
|
|
83883
83883
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
83884
83884
|
|
|
83885
|
+
// src/lib/skill-bundle.ts
|
|
83886
|
+
import { createHash } from "crypto";
|
|
83887
|
+
import { createGunzip } from "zlib";
|
|
83888
|
+
|
|
83885
83889
|
// src/lib/skill-entry-path.ts
|
|
83886
83890
|
class SkillEntryPaths {
|
|
83887
83891
|
files = new Set;
|
|
@@ -84043,6 +84047,9 @@ function ownBytes(view) {
|
|
|
84043
84047
|
out.set(source);
|
|
84044
84048
|
return out;
|
|
84045
84049
|
}
|
|
84050
|
+
function sha256Hex(bytes) {
|
|
84051
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
84052
|
+
}
|
|
84046
84053
|
var SKILL_BUNDLE_INSPECTION_LIMITS = Object.freeze({
|
|
84047
84054
|
compressedBytes: 16 * 1024 * 1024,
|
|
84048
84055
|
decompressedBytes: 64 * 1024 * 1024,
|
|
@@ -84063,6 +84070,89 @@ class SkillBundleInspectionError extends Error {
|
|
|
84063
84070
|
function invalidBundle(message) {
|
|
84064
84071
|
throw new SkillBundleInspectionError("BUNDLE_INVALID", message);
|
|
84065
84072
|
}
|
|
84073
|
+
function inspectionLimits(options) {
|
|
84074
|
+
const limits = { ...SKILL_BUNDLE_INSPECTION_LIMITS };
|
|
84075
|
+
for (const key of Object.keys(options.limits ?? {})) {
|
|
84076
|
+
if (!Object.hasOwn(limits, key))
|
|
84077
|
+
throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Unknown bundle limit");
|
|
84078
|
+
const field = key;
|
|
84079
|
+
const value = options.limits[field];
|
|
84080
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > limits[field]) {
|
|
84081
|
+
throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Bundle limits must be positive integers within the hard ceilings");
|
|
84082
|
+
}
|
|
84083
|
+
limits[field] = value;
|
|
84084
|
+
}
|
|
84085
|
+
return limits;
|
|
84086
|
+
}
|
|
84087
|
+
async function inspectSkillBundle(bundle, options = {}) {
|
|
84088
|
+
const signal = options.signal;
|
|
84089
|
+
const limits = inspectionLimits(options);
|
|
84090
|
+
const deadline = performance.now() + limits.timeoutMs;
|
|
84091
|
+
const check = () => {
|
|
84092
|
+
if (signal?.aborted)
|
|
84093
|
+
throw new SkillBundleInspectionError("BUNDLE_ABORTED", "Bundle inspection aborted");
|
|
84094
|
+
if (performance.now() >= deadline)
|
|
84095
|
+
throw new SkillBundleInspectionError("BUNDLE_TIMEOUT", "Bundle inspection deadline exceeded");
|
|
84096
|
+
};
|
|
84097
|
+
check();
|
|
84098
|
+
if (bundle.byteLength > limits.compressedBytes)
|
|
84099
|
+
throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Compressed bundle exceeds byte limit");
|
|
84100
|
+
const snapshot = ownBytes(bundle);
|
|
84101
|
+
check();
|
|
84102
|
+
const sha256 = sha256Hex(snapshot);
|
|
84103
|
+
check();
|
|
84104
|
+
const parser = new BoundedTarReader(limits, check);
|
|
84105
|
+
const streamOptions = { chunkSize: 16 * 1024, highWaterMark: 16 * 1024 };
|
|
84106
|
+
const decoder = createGunzip(streamOptions);
|
|
84107
|
+
let terminalError;
|
|
84108
|
+
const stop = (code) => {
|
|
84109
|
+
terminalError ??= new SkillBundleInspectionError(code, code === "BUNDLE_ABORTED" ? "Bundle inspection aborted" : "Bundle inspection deadline exceeded");
|
|
84110
|
+
decoder.destroy(terminalError);
|
|
84111
|
+
};
|
|
84112
|
+
const onAbort = () => stop("BUNDLE_ABORTED");
|
|
84113
|
+
const timer = setTimeout(() => stop("BUNDLE_TIMEOUT"), Math.max(1, deadline - performance.now()));
|
|
84114
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
84115
|
+
let decompressedByteSize = 0;
|
|
84116
|
+
let bytesSinceYield = 0;
|
|
84117
|
+
try {
|
|
84118
|
+
check();
|
|
84119
|
+
decoder.end(snapshot);
|
|
84120
|
+
for await (const chunk of decoder) {
|
|
84121
|
+
check();
|
|
84122
|
+
decompressedByteSize += chunk.byteLength;
|
|
84123
|
+
if (decompressedByteSize > limits.decompressedBytes)
|
|
84124
|
+
throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Decompressed bundle exceeds byte limit");
|
|
84125
|
+
parser.push(chunk);
|
|
84126
|
+
bytesSinceYield += chunk.byteLength;
|
|
84127
|
+
if (bytesSinceYield >= 256 * 1024) {
|
|
84128
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
84129
|
+
bytesSinceYield = 0;
|
|
84130
|
+
check();
|
|
84131
|
+
}
|
|
84132
|
+
}
|
|
84133
|
+
check();
|
|
84134
|
+
const entries = parser.finish();
|
|
84135
|
+
return {
|
|
84136
|
+
entries,
|
|
84137
|
+
sha256,
|
|
84138
|
+
compressedByteSize: snapshot.byteLength,
|
|
84139
|
+
decompressedByteSize,
|
|
84140
|
+
unpackedByteSize: parser.fileBytes,
|
|
84141
|
+
fileCount: entries.length
|
|
84142
|
+
};
|
|
84143
|
+
} catch (error) {
|
|
84144
|
+
if (terminalError)
|
|
84145
|
+
throw terminalError;
|
|
84146
|
+
if (error instanceof SkillBundleInspectionError)
|
|
84147
|
+
throw error;
|
|
84148
|
+
throw new SkillBundleInspectionError("BUNDLE_INVALID", "Invalid or truncated gzip bundle");
|
|
84149
|
+
} finally {
|
|
84150
|
+
clearTimeout(timer);
|
|
84151
|
+
signal?.removeEventListener("abort", onAbort);
|
|
84152
|
+
decoder.destroy();
|
|
84153
|
+
}
|
|
84154
|
+
}
|
|
84155
|
+
|
|
84066
84156
|
class BoundedTarReader {
|
|
84067
84157
|
limits;
|
|
84068
84158
|
check;
|
|
@@ -94200,7 +94290,7 @@ var import_node_http_handler2 = __toESM(require_dist_cjs7(), 1);
|
|
|
94200
94290
|
|
|
94201
94291
|
// node_modules/@aws-sdk/checksums/dist-cjs/submodules/sha/index.js
|
|
94202
94292
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde2();
|
|
94203
|
-
var { createHmac: createHmac2, createHash:
|
|
94293
|
+
var { createHmac: createHmac2, createHash: createHash3 } = __require("crypto");
|
|
94204
94294
|
var { Sha256: Sha2562, Sha256Js, Sha256Node } = require_checksum2();
|
|
94205
94295
|
var BLOCK2 = 64;
|
|
94206
94296
|
var DIGEST_LENGTH = 20;
|
|
@@ -94369,7 +94459,7 @@ class Sha1Js {
|
|
|
94369
94459
|
}
|
|
94370
94460
|
var hasNativeCrypto = (() => {
|
|
94371
94461
|
try {
|
|
94372
|
-
|
|
94462
|
+
createHash3("sha1");
|
|
94373
94463
|
return true;
|
|
94374
94464
|
} catch {
|
|
94375
94465
|
return false;
|
|
@@ -94409,7 +94499,7 @@ function buildNativeClass() {
|
|
|
94409
94499
|
this.finished = false;
|
|
94410
94500
|
}
|
|
94411
94501
|
createHash() {
|
|
94412
|
-
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) :
|
|
94502
|
+
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) : createHash3("sha1");
|
|
94413
94503
|
}
|
|
94414
94504
|
};
|
|
94415
94505
|
}
|
|
@@ -94971,7 +95061,7 @@ function assertReservationCents(value, field) {
|
|
|
94971
95061
|
|
|
94972
95062
|
// src/sdk/governance-store.ts
|
|
94973
95063
|
import { Database as Database2 } from "bun:sqlite";
|
|
94974
|
-
import { randomUUID as
|
|
95064
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
94975
95065
|
import { mkdirSync as mkdirSync3 } from "fs";
|
|
94976
95066
|
import { dirname as dirname4 } from "path";
|
|
94977
95067
|
|
|
@@ -95163,11 +95253,82 @@ function looksLikeSqlitePath(value) {
|
|
|
95163
95253
|
return SQLITE_EXTENSIONS.some((extension) => value.toLowerCase().endsWith(extension));
|
|
95164
95254
|
}
|
|
95165
95255
|
|
|
95256
|
+
// src/server/execution-grant-store.ts
|
|
95257
|
+
import { randomUUID } from "crypto";
|
|
95258
|
+
function next(p2, id, grants, expected) {
|
|
95259
|
+
return {
|
|
95260
|
+
schema: "hasna.skills-execution-grants.v1",
|
|
95261
|
+
profileId: id,
|
|
95262
|
+
workspaceId: p2.orgId,
|
|
95263
|
+
revision: randomUUID(),
|
|
95264
|
+
previousRevision: expected,
|
|
95265
|
+
updatedAt: new Date().toISOString(),
|
|
95266
|
+
actorId: p2.userId,
|
|
95267
|
+
grants: structuredClone(grants)
|
|
95268
|
+
};
|
|
95269
|
+
}
|
|
95270
|
+
function document(row) {
|
|
95271
|
+
return row ? typeof row.document_json === "string" ? JSON.parse(row.document_json) : structuredClone(row.document_json) : null;
|
|
95272
|
+
}
|
|
95273
|
+
|
|
95274
|
+
class MemoryExecutionGrantStore {
|
|
95275
|
+
current = new Map;
|
|
95276
|
+
history = new Map;
|
|
95277
|
+
async get(p2, id, revision) {
|
|
95278
|
+
return structuredClone((revision ? this.history.get(JSON.stringify([p2.orgId, id, revision])) : this.current.get(JSON.stringify([p2.orgId, id]))) ?? null);
|
|
95279
|
+
}
|
|
95280
|
+
async save(p2, id, grants, expected) {
|
|
95281
|
+
const key = JSON.stringify([p2.orgId, id]);
|
|
95282
|
+
if ((this.current.get(key)?.revision ?? null) !== expected)
|
|
95283
|
+
return null;
|
|
95284
|
+
const value = next(p2, id, grants, expected);
|
|
95285
|
+
this.current.set(key, value);
|
|
95286
|
+
this.history.set(JSON.stringify([p2.orgId, id, value.revision]), value);
|
|
95287
|
+
return structuredClone(value);
|
|
95288
|
+
}
|
|
95289
|
+
}
|
|
95290
|
+
|
|
95291
|
+
class SqliteExecutionGrantStore {
|
|
95292
|
+
db;
|
|
95293
|
+
constructor(db) {
|
|
95294
|
+
this.db = db;
|
|
95295
|
+
}
|
|
95296
|
+
async get(p2, id, revision) {
|
|
95297
|
+
return document(revision ? this.db.query("SELECT document_json FROM skills_execution_grant_revisions WHERE org_id=? AND profile_id=? AND revision=?").get(p2.orgId, id, revision) : this.db.query("SELECT document_json FROM skills_execution_grants WHERE org_id=? AND profile_id=?").get(p2.orgId, id));
|
|
95298
|
+
}
|
|
95299
|
+
async save(p2, id, grants, expected) {
|
|
95300
|
+
return this.db.transaction(() => {
|
|
95301
|
+
const value = next(p2, id, grants, expected), json = JSON.stringify(value);
|
|
95302
|
+
const row = expected === null ? this.db.query("INSERT INTO skills_execution_grants(org_id,profile_id,revision,document_json) VALUES(?,?,?,?) ON CONFLICT(org_id,profile_id) DO NOTHING RETURNING document_json").get(p2.orgId, id, value.revision, json) : this.db.query("UPDATE skills_execution_grants SET revision=?,document_json=? WHERE org_id=? AND profile_id=? AND revision=? RETURNING document_json").get(value.revision, json, p2.orgId, id, expected);
|
|
95303
|
+
if (!row)
|
|
95304
|
+
return null;
|
|
95305
|
+
this.db.query("INSERT INTO skills_execution_grant_revisions(org_id,profile_id,revision,document_json) VALUES(?,?,?,?)").run(p2.orgId, id, value.revision, json);
|
|
95306
|
+
return document(row);
|
|
95307
|
+
})();
|
|
95308
|
+
}
|
|
95309
|
+
}
|
|
95310
|
+
|
|
95311
|
+
class PostgresExecutionGrantStore {
|
|
95312
|
+
sql;
|
|
95313
|
+
constructor(sql) {
|
|
95314
|
+
this.sql = sql;
|
|
95315
|
+
}
|
|
95316
|
+
async get(p2, id, revision) {
|
|
95317
|
+
const rows = revision ? await this.sql`SELECT document_json FROM skills_execution_grant_revisions WHERE org_id=${p2.orgId} AND profile_id=${id} AND revision=${revision}` : await this.sql`SELECT document_json FROM skills_execution_grants WHERE org_id=${p2.orgId} AND profile_id=${id}`;
|
|
95318
|
+
return document(rows[0]);
|
|
95319
|
+
}
|
|
95320
|
+
async save(p2, id, grants, expected) {
|
|
95321
|
+
const value = next(p2, id, grants, expected), json = JSON.stringify(value);
|
|
95322
|
+
const rows = expected === null ? await this.sql`WITH changed AS (INSERT INTO skills_execution_grants(org_id,profile_id,revision,document_json) VALUES(${p2.orgId},${id},${value.revision},${json}::jsonb) ON CONFLICT(org_id,profile_id) DO NOTHING RETURNING *) INSERT INTO skills_execution_grant_revisions(org_id,profile_id,revision,document_json) SELECT org_id,profile_id,revision,document_json FROM changed RETURNING document_json` : await this.sql`WITH changed AS (UPDATE skills_execution_grants SET revision=${value.revision},document_json=${json}::jsonb WHERE org_id=${p2.orgId} AND profile_id=${id} AND revision=${expected} RETURNING *) INSERT INTO skills_execution_grant_revisions(org_id,profile_id,revision,document_json) SELECT org_id,profile_id,revision,document_json FROM changed RETURNING document_json`;
|
|
95323
|
+
return document(rows[0]);
|
|
95324
|
+
}
|
|
95325
|
+
}
|
|
95326
|
+
|
|
95166
95327
|
// src/server/sqlite-store.ts
|
|
95167
95328
|
import { Database } from "bun:sqlite";
|
|
95168
95329
|
|
|
95169
95330
|
// src/server/selection-store.ts
|
|
95170
|
-
import { randomUUID } from "crypto";
|
|
95331
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
95171
95332
|
function selections(value) {
|
|
95172
95333
|
return typeof value === "string" ? JSON.parse(value) : structuredClone(value);
|
|
95173
95334
|
}
|
|
@@ -95208,15 +95369,15 @@ class MemorySkillSelectionStore {
|
|
|
95208
95369
|
const key = this.key(p2.orgId, id), previous = this.profiles.get(key);
|
|
95209
95370
|
if ((previous?.revision ?? null) !== expected)
|
|
95210
95371
|
return null;
|
|
95211
|
-
const
|
|
95372
|
+
const next2 = {
|
|
95212
95373
|
id,
|
|
95213
95374
|
workspaceId: p2.orgId,
|
|
95214
|
-
revision:
|
|
95375
|
+
revision: randomUUID2(),
|
|
95215
95376
|
selections: structuredClone(selected),
|
|
95216
95377
|
updatedAt: new Date().toISOString()
|
|
95217
95378
|
};
|
|
95218
|
-
this.profiles.set(key,
|
|
95219
|
-
return structuredClone(
|
|
95379
|
+
this.profiles.set(key, next2);
|
|
95380
|
+
return structuredClone(next2);
|
|
95220
95381
|
}
|
|
95221
95382
|
async getStationState(p2, id) {
|
|
95222
95383
|
return structuredClone(this.states.get(this.key(p2.orgId, p2.userId, id)) ?? null);
|
|
@@ -95224,15 +95385,15 @@ class MemorySkillSelectionStore {
|
|
|
95224
95385
|
async saveStationState(p2, id, input) {
|
|
95225
95386
|
if (this.profiles.get(this.key(p2.orgId, input.profileId))?.revision !== input.profileRevision)
|
|
95226
95387
|
return null;
|
|
95227
|
-
const
|
|
95388
|
+
const next2 = {
|
|
95228
95389
|
...structuredClone(input),
|
|
95229
95390
|
stationId: id,
|
|
95230
95391
|
workspaceId: p2.orgId,
|
|
95231
95392
|
actorId: p2.userId,
|
|
95232
95393
|
appliedAt: new Date().toISOString()
|
|
95233
95394
|
};
|
|
95234
|
-
this.states.set(this.key(p2.orgId, p2.userId, id),
|
|
95235
|
-
return structuredClone(
|
|
95395
|
+
this.states.set(this.key(p2.orgId, p2.userId, id), next2);
|
|
95396
|
+
return structuredClone(next2);
|
|
95236
95397
|
}
|
|
95237
95398
|
}
|
|
95238
95399
|
|
|
@@ -95246,7 +95407,7 @@ class SqliteSkillSelectionStore {
|
|
|
95246
95407
|
return row ? profile(row) : null;
|
|
95247
95408
|
}
|
|
95248
95409
|
async saveProfile(p2, id, selected, expected) {
|
|
95249
|
-
const revision =
|
|
95410
|
+
const revision = randomUUID2(), timestamp = new Date().toISOString();
|
|
95250
95411
|
const row = expected === null ? this.db.query("INSERT INTO skills_profiles(org_id,profile_id,revision,selections_json,updated_at) VALUES(?,?,?,?,?) ON CONFLICT(org_id,profile_id) DO NOTHING RETURNING *").get(p2.orgId, id, revision, JSON.stringify(selected), timestamp) : this.db.query("UPDATE skills_profiles SET revision=?,selections_json=?,updated_at=? WHERE org_id=? AND profile_id=? AND revision=? RETURNING *").get(revision, JSON.stringify(selected), timestamp, p2.orgId, id, expected);
|
|
95251
95412
|
return row ? profile(row) : null;
|
|
95252
95413
|
}
|
|
@@ -95272,7 +95433,7 @@ class PostgresSkillSelectionStore {
|
|
|
95272
95433
|
return rows[0] ? profile(rows[0]) : null;
|
|
95273
95434
|
}
|
|
95274
95435
|
async saveProfile(p2, id, selected, expected) {
|
|
95275
|
-
const revision =
|
|
95436
|
+
const revision = randomUUID2(), timestamp = new Date().toISOString();
|
|
95276
95437
|
const rows = expected === null ? await this.sql`INSERT INTO skills_profiles(org_id,profile_id,revision,selections_json,updated_at) VALUES(${p2.orgId},${id},${revision},${JSON.stringify(selected)}::jsonb,${timestamp}) ON CONFLICT(org_id,profile_id) DO NOTHING RETURNING *` : await this.sql`UPDATE skills_profiles SET revision=${revision},selections_json=${JSON.stringify(selected)}::jsonb,updated_at=${timestamp} WHERE org_id=${p2.orgId} AND profile_id=${id} AND revision=${expected} RETURNING *`;
|
|
95277
95438
|
return rows[0] ? profile(rows[0]) : null;
|
|
95278
95439
|
}
|
|
@@ -95290,14 +95451,14 @@ class PostgresSkillSelectionStore {
|
|
|
95290
95451
|
}
|
|
95291
95452
|
|
|
95292
95453
|
// src/server/sqlite-store.ts
|
|
95293
|
-
import { randomUUID as
|
|
95454
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
95294
95455
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, readdirSync } from "fs";
|
|
95295
95456
|
import { dirname as dirname3, join as join5 } from "path";
|
|
95296
95457
|
|
|
95297
95458
|
// src/server/auth.ts
|
|
95298
|
-
import { createHash as
|
|
95459
|
+
import { createHash as createHash4 } from "crypto";
|
|
95299
95460
|
function hashApiKey(token) {
|
|
95300
|
-
return
|
|
95461
|
+
return createHash4("sha256").update(token).digest("hex");
|
|
95301
95462
|
}
|
|
95302
95463
|
function bearerToken(request) {
|
|
95303
95464
|
const header = request.headers.get("authorization") || "";
|
|
@@ -95325,6 +95486,13 @@ function publicPrincipal(partial = {}) {
|
|
|
95325
95486
|
}
|
|
95326
95487
|
function permitsSkillsRoute(principal, method, resource) {
|
|
95327
95488
|
const scopes = new Set(principal.scopes);
|
|
95489
|
+
if (resource === "execution-grants") {
|
|
95490
|
+
const read2 = method === "GET" || method === "HEAD";
|
|
95491
|
+
if (!read2 && method !== "POST" && !["owner", "admin"].includes(principal.role))
|
|
95492
|
+
return false;
|
|
95493
|
+
const allowed2 = read2 ? ["*", "execution-grants:*", "execution-grants:read"] : method === "POST" ? ["*", "execution-grants:*", "execution-grants:resolve", "skills:read", "skills:*"] : ["*", "execution-grants:*", "execution-grants:write"];
|
|
95494
|
+
return allowed2.some((scope) => scopes.has(scope));
|
|
95495
|
+
}
|
|
95328
95496
|
if (scopes.has("*"))
|
|
95329
95497
|
return true;
|
|
95330
95498
|
const read = method === "GET" || method === "HEAD";
|
|
@@ -95381,7 +95549,7 @@ function defaultStartDirs() {
|
|
|
95381
95549
|
}
|
|
95382
95550
|
|
|
95383
95551
|
// src/server/rows.ts
|
|
95384
|
-
import { randomUUID as
|
|
95552
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
95385
95553
|
function nowIso() {
|
|
95386
95554
|
return new Date().toISOString();
|
|
95387
95555
|
}
|
|
@@ -95389,7 +95557,7 @@ function normalizeLimit(limit) {
|
|
|
95389
95557
|
return Number.isFinite(limit) ? Math.max(0, Math.trunc(limit)) : 0;
|
|
95390
95558
|
}
|
|
95391
95559
|
function runId() {
|
|
95392
|
-
return `run_${Date.now().toString(36)}_${
|
|
95560
|
+
return `run_${Date.now().toString(36)}_${randomUUID3().slice(0, 8)}`;
|
|
95393
95561
|
}
|
|
95394
95562
|
function rowToRun(row) {
|
|
95395
95563
|
return {
|
|
@@ -95581,7 +95749,7 @@ class SkillVersionExistsError extends Error {
|
|
|
95581
95749
|
}
|
|
95582
95750
|
|
|
95583
95751
|
// src/lib/revision.ts
|
|
95584
|
-
import { createHash as
|
|
95752
|
+
import { createHash as createHash5 } from "crypto";
|
|
95585
95753
|
var REVISION_ID_PATTERN = /^[0-9a-f]{64}$/;
|
|
95586
95754
|
function revisionIdOf(content) {
|
|
95587
95755
|
const canonical = JSON.stringify({
|
|
@@ -95597,7 +95765,7 @@ function revisionIdOf(content) {
|
|
|
95597
95765
|
bundleSha256: content.bundleSha256 ?? null,
|
|
95598
95766
|
bundleByteSize: content.bundleByteSize ?? null
|
|
95599
95767
|
});
|
|
95600
|
-
return
|
|
95768
|
+
return createHash5("sha256").update(canonical).digest("hex");
|
|
95601
95769
|
}
|
|
95602
95770
|
function revisionIdOfRecord(record) {
|
|
95603
95771
|
return revisionIdOf(record);
|
|
@@ -95613,6 +95781,9 @@ class SqliteSkillsStore {
|
|
|
95613
95781
|
get selectionStore() {
|
|
95614
95782
|
return new SqliteSkillSelectionStore(this.db);
|
|
95615
95783
|
}
|
|
95784
|
+
get executionGrantStore() {
|
|
95785
|
+
return new SqliteExecutionGrantStore(this.db);
|
|
95786
|
+
}
|
|
95616
95787
|
backend;
|
|
95617
95788
|
db;
|
|
95618
95789
|
closed = false;
|
|
@@ -95714,7 +95885,7 @@ class SqliteSkillsStore {
|
|
|
95714
95885
|
JSON.stringify(input.input),
|
|
95715
95886
|
JSON.stringify(input.args),
|
|
95716
95887
|
input.idempotencyKey ?? null,
|
|
95717
|
-
|
|
95888
|
+
randomUUID4(),
|
|
95718
95889
|
nowIso()
|
|
95719
95890
|
]);
|
|
95720
95891
|
return rowToRun(row);
|
|
@@ -96024,21 +96195,21 @@ class SqliteSkillsStore {
|
|
|
96024
96195
|
if (expectedRevisionId !== current.revisionId) {
|
|
96025
96196
|
throw new SkillRevisionConflictError(slug, expectedRevisionId, current.revisionId);
|
|
96026
96197
|
}
|
|
96027
|
-
const
|
|
96198
|
+
const next2 = { ...current, ...patch };
|
|
96028
96199
|
return this.db.transaction(() => {
|
|
96029
|
-
const revisionId = revisionIdOfRecord(
|
|
96200
|
+
const revisionId = revisionIdOfRecord(next2);
|
|
96030
96201
|
const row = this.get(`UPDATE skills_registry
|
|
96031
96202
|
SET display_name = ?, description = ?, category = ?, tags_json = ?, kind = ?, version = ?, skill_md = ?,
|
|
96032
96203
|
revision_id = ?, revision_number = revision_number + 1, updated_at = ?
|
|
96033
96204
|
WHERE org_id = ? AND slug = ? AND tombstoned_at IS NULL AND revision_id = ?
|
|
96034
96205
|
RETURNING *`, [
|
|
96035
|
-
|
|
96036
|
-
|
|
96037
|
-
|
|
96038
|
-
JSON.stringify(
|
|
96039
|
-
|
|
96040
|
-
|
|
96041
|
-
|
|
96206
|
+
next2.displayName,
|
|
96207
|
+
next2.description,
|
|
96208
|
+
next2.category,
|
|
96209
|
+
JSON.stringify(next2.tags),
|
|
96210
|
+
next2.kind,
|
|
96211
|
+
next2.version ?? null,
|
|
96212
|
+
next2.skillMd ?? null,
|
|
96042
96213
|
revisionId,
|
|
96043
96214
|
nowIso(),
|
|
96044
96215
|
principal.orgId,
|
|
@@ -96058,7 +96229,7 @@ class SqliteSkillsStore {
|
|
|
96058
96229
|
}
|
|
96059
96230
|
this.db.run("DELETE FROM skills_tags WHERE org_id = ? AND slug = ?", [principal.orgId, slug]);
|
|
96060
96231
|
const insertTag = this.db.prepare("INSERT OR IGNORE INTO skills_tags (org_id, slug, tag) VALUES (?, ?, ?)");
|
|
96061
|
-
for (const tag of
|
|
96232
|
+
for (const tag of next2.tags) {
|
|
96062
96233
|
if (!tag.trim())
|
|
96063
96234
|
continue;
|
|
96064
96235
|
insertTag.run(principal.orgId, slug, tag);
|
|
@@ -96236,10 +96407,10 @@ function parseScopes(value) {
|
|
|
96236
96407
|
|
|
96237
96408
|
// src/sdk/governance-store.ts
|
|
96238
96409
|
function receiptId() {
|
|
96239
|
-
return `rcpt_${Date.now().toString(36)}_${
|
|
96410
|
+
return `rcpt_${Date.now().toString(36)}_${randomUUID5().replace(/-/g, "").slice(0, 10)}`;
|
|
96240
96411
|
}
|
|
96241
96412
|
function reservationId() {
|
|
96242
|
-
return `res_${Date.now().toString(36)}_${
|
|
96413
|
+
return `res_${Date.now().toString(36)}_${randomUUID5().replace(/-/g, "").slice(0, 10)}`;
|
|
96243
96414
|
}
|
|
96244
96415
|
var EXPIRED_ARTIFACT_SQL = `
|
|
96245
96416
|
SELECT a.* FROM skills_artifacts a
|
|
@@ -96274,10 +96445,10 @@ class SqliteGovernanceStore {
|
|
|
96274
96445
|
return this.db;
|
|
96275
96446
|
}
|
|
96276
96447
|
async appendReceipt(receipt) {
|
|
96277
|
-
const
|
|
96448
|
+
const next2 = { ...receipt, id: receiptId(), createdAt: nowIso() };
|
|
96278
96449
|
this.db.run(`INSERT INTO skills_lifecycle_receipts (id, kind, org_id, run_id, artifact_id, requested_by, metadata_json, created_at)
|
|
96279
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
96280
|
-
return
|
|
96450
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [next2.id, next2.kind, next2.orgId, next2.runId, next2.artifactId ?? null, next2.requestedBy, JSON.stringify(next2.metadata), next2.createdAt]);
|
|
96451
|
+
return next2;
|
|
96281
96452
|
}
|
|
96282
96453
|
async listReceipts(orgId, runId2) {
|
|
96283
96454
|
const rows = this.db.query("SELECT * FROM skills_lifecycle_receipts WHERE org_id = ? AND run_id = ? ORDER BY created_at ASC, rowid ASC").all(orgId, runId2);
|
|
@@ -96368,12 +96539,12 @@ class PostgresGovernanceStore {
|
|
|
96368
96539
|
});
|
|
96369
96540
|
}
|
|
96370
96541
|
async appendReceipt(receipt) {
|
|
96371
|
-
const
|
|
96542
|
+
const next2 = { ...receipt, id: receiptId(), createdAt: nowIso() };
|
|
96372
96543
|
await this.sql`
|
|
96373
96544
|
INSERT INTO skills_lifecycle_receipts (id, kind, org_id, run_id, artifact_id, requested_by, metadata_json)
|
|
96374
|
-
VALUES (${
|
|
96545
|
+
VALUES (${next2.id}, ${next2.kind}, ${next2.orgId}, ${next2.runId}, ${next2.artifactId ?? null}, ${next2.requestedBy}, ${JSON.stringify(next2.metadata)}::jsonb)
|
|
96375
96546
|
`;
|
|
96376
|
-
return
|
|
96547
|
+
return next2;
|
|
96377
96548
|
}
|
|
96378
96549
|
async listReceipts(orgId, runId2) {
|
|
96379
96550
|
const rows = await this.sql`
|
|
@@ -96489,8 +96660,506 @@ function nextMonthPrefix(monthPrefix) {
|
|
|
96489
96660
|
return month === 12 ? `${year + 1}-01` : `${year}-${String(month + 1).padStart(2, "0")}`;
|
|
96490
96661
|
}
|
|
96491
96662
|
|
|
96492
|
-
//
|
|
96663
|
+
// src/lib/execution-grants.ts
|
|
96664
|
+
import { posix, win32 } from "path";
|
|
96665
|
+
|
|
96666
|
+
// node_modules/@hasna/secrets/dist/sdk.js
|
|
96493
96667
|
import { createRequire } from "module";
|
|
96668
|
+
import { createRequire as createRequire2 } from "module";
|
|
96669
|
+
var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
96670
|
+
var CredentialResolutionError;
|
|
96671
|
+
var CredentialFileUnsafeError;
|
|
96672
|
+
var MAX_CREDENTIAL_FILE_BYTES;
|
|
96673
|
+
var SAFE_APP_SLUG;
|
|
96674
|
+
var SAFE_PROFILE;
|
|
96675
|
+
var ILLEGAL_IN_HEADER_VALUE;
|
|
96676
|
+
var VAULT_POINTER_SHAPE;
|
|
96677
|
+
var CREDENTIAL_SHAPED_KEY;
|
|
96678
|
+
var INSPECT_CUSTOM;
|
|
96679
|
+
var CREDENTIAL_SEAL;
|
|
96680
|
+
var AMBIENT_ENVIRONMENT;
|
|
96681
|
+
var SECRETS_PACKAGE_SPECIFIER;
|
|
96682
|
+
var requireSecretsSdk;
|
|
96683
|
+
var ASCII_CONTROL_PATTERN;
|
|
96684
|
+
var DNS_LABEL_PATTERN;
|
|
96685
|
+
var ClientTransportConfigurationError;
|
|
96686
|
+
var HasnaHttpError;
|
|
96687
|
+
var DEFAULT_RETRY_STATUSES;
|
|
96688
|
+
var IDEMPOTENT_METHODS;
|
|
96689
|
+
var AUTHORITY_OVERRIDE_HEADERS;
|
|
96690
|
+
var init_transport = __esm2(() => {
|
|
96691
|
+
CredentialResolutionError = class CredentialResolutionError2 extends Error {
|
|
96692
|
+
appName;
|
|
96693
|
+
attempted;
|
|
96694
|
+
constructor(appName, message, attempted) {
|
|
96695
|
+
super(message);
|
|
96696
|
+
this.name = "CredentialResolutionError";
|
|
96697
|
+
this.appName = appName;
|
|
96698
|
+
this.attempted = attempted;
|
|
96699
|
+
}
|
|
96700
|
+
};
|
|
96701
|
+
CredentialFileUnsafeError = class CredentialFileUnsafeError2 extends Error {
|
|
96702
|
+
path;
|
|
96703
|
+
constructor(path, reason) {
|
|
96704
|
+
super(`Refusing unsafe credential/config file ${path}: ${reason}.`);
|
|
96705
|
+
this.name = "CredentialFileUnsafeError";
|
|
96706
|
+
this.path = path;
|
|
96707
|
+
}
|
|
96708
|
+
};
|
|
96709
|
+
MAX_CREDENTIAL_FILE_BYTES = 64 * 1024;
|
|
96710
|
+
SAFE_APP_SLUG = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
96711
|
+
SAFE_PROFILE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
96712
|
+
ILLEGAL_IN_HEADER_VALUE = /[^\t\x20-\x7e]/;
|
|
96713
|
+
VAULT_POINTER_SHAPE = /^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-_.]*){2,}$/;
|
|
96714
|
+
CREDENTIAL_SHAPED_KEY = /(?:^|_)(?:API_KEY|KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIAL|AUTH)(?:_|$)/;
|
|
96715
|
+
INSPECT_CUSTOM = Symbol.for("nodejs.util.inspect.custom");
|
|
96716
|
+
CREDENTIAL_SEAL = Symbol.for("hasna:contracts:sealedCredential");
|
|
96717
|
+
AMBIENT_ENVIRONMENT = Symbol.for("hasna:contracts:ambientClientEnvironment");
|
|
96718
|
+
SECRETS_PACKAGE_SPECIFIER = "@hasna/" + "secrets";
|
|
96719
|
+
requireSecretsSdk = createRequire(import.meta.url);
|
|
96720
|
+
ASCII_CONTROL_PATTERN = /[\u0000-\u001f\u007f]/;
|
|
96721
|
+
DNS_LABEL_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
96722
|
+
ClientTransportConfigurationError = class ClientTransportConfigurationError2 extends Error {
|
|
96723
|
+
appName;
|
|
96724
|
+
sources;
|
|
96725
|
+
constructor(appName, message, sources = []) {
|
|
96726
|
+
super(message);
|
|
96727
|
+
this.name = "ClientTransportConfigurationError";
|
|
96728
|
+
this.appName = appName;
|
|
96729
|
+
this.sources = Object.freeze([...sources]);
|
|
96730
|
+
}
|
|
96731
|
+
};
|
|
96732
|
+
HasnaHttpError = class HasnaHttpError2 extends Error {
|
|
96733
|
+
status;
|
|
96734
|
+
method;
|
|
96735
|
+
path;
|
|
96736
|
+
credentialSource;
|
|
96737
|
+
credentialTier;
|
|
96738
|
+
constructor(method, path, status, body, credential) {
|
|
96739
|
+
const guidance = credential ? `. ${credential.guidance}` : "";
|
|
96740
|
+
super(`Hasna cloud request failed: ${method} ${path} -> ${status}${guidance}`);
|
|
96741
|
+
this.name = "HasnaHttpError";
|
|
96742
|
+
this.status = status;
|
|
96743
|
+
this.method = method;
|
|
96744
|
+
this.path = path;
|
|
96745
|
+
Object.defineProperty(this, "body", {
|
|
96746
|
+
value: body,
|
|
96747
|
+
enumerable: status !== 401 && status !== 403,
|
|
96748
|
+
writable: false,
|
|
96749
|
+
configurable: false
|
|
96750
|
+
});
|
|
96751
|
+
this.credentialSource = credential?.source ?? null;
|
|
96752
|
+
this.credentialTier = credential?.tier ?? null;
|
|
96753
|
+
}
|
|
96754
|
+
};
|
|
96755
|
+
DEFAULT_RETRY_STATUSES = [408, 425, 429, 500, 502, 503, 504];
|
|
96756
|
+
IDEMPOTENT_METHODS = new Set(["GET", "HEAD", "PUT", "DELETE", "OPTIONS"]);
|
|
96757
|
+
AUTHORITY_OVERRIDE_HEADERS = new Set([
|
|
96758
|
+
"host",
|
|
96759
|
+
":authority",
|
|
96760
|
+
"forwarded",
|
|
96761
|
+
"x-forwarded-host",
|
|
96762
|
+
"x-original-host"
|
|
96763
|
+
]);
|
|
96764
|
+
});
|
|
96765
|
+
var MAX_CREDENTIAL_FILE_BYTES2;
|
|
96766
|
+
var INSPECT_CUSTOM2;
|
|
96767
|
+
var CREDENTIAL_SEAL2;
|
|
96768
|
+
var AMBIENT_ENVIRONMENT2;
|
|
96769
|
+
var SECRETS_PACKAGE_SPECIFIER2;
|
|
96770
|
+
var requireSecretsSdk2;
|
|
96771
|
+
var IDEMPOTENT_METHODS2;
|
|
96772
|
+
var AUTHORITY_OVERRIDE_HEADERS2;
|
|
96773
|
+
var init_storage = __esm2(() => {
|
|
96774
|
+
MAX_CREDENTIAL_FILE_BYTES2 = 64 * 1024;
|
|
96775
|
+
INSPECT_CUSTOM2 = Symbol.for("nodejs.util.inspect.custom");
|
|
96776
|
+
CREDENTIAL_SEAL2 = Symbol.for("hasna:contracts:sealedCredential");
|
|
96777
|
+
AMBIENT_ENVIRONMENT2 = Symbol.for("hasna:contracts:ambientClientEnvironment");
|
|
96778
|
+
SECRETS_PACKAGE_SPECIFIER2 = "@hasna/" + "secrets";
|
|
96779
|
+
requireSecretsSdk2 = createRequire2(import.meta.url);
|
|
96780
|
+
IDEMPOTENT_METHODS2 = new Set(["GET", "HEAD", "PUT", "DELETE", "OPTIONS"]);
|
|
96781
|
+
AUTHORITY_OVERRIDE_HEADERS2 = new Set([
|
|
96782
|
+
"host",
|
|
96783
|
+
":authority",
|
|
96784
|
+
"forwarded",
|
|
96785
|
+
"x-forwarded-host",
|
|
96786
|
+
"x-original-host"
|
|
96787
|
+
]);
|
|
96788
|
+
});
|
|
96789
|
+
var PATHS_RESOLVER_APP_SLUG_RE2;
|
|
96790
|
+
var SQLITE_SIDECAR_FILES;
|
|
96791
|
+
var LEGACY_SERVICE_FILES;
|
|
96792
|
+
var init_data_dir = __esm2(() => {
|
|
96793
|
+
PATHS_RESOLVER_APP_SLUG_RE2 = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
96794
|
+
SQLITE_SIDECAR_FILES = ["vault.db-wal", "vault.db-shm", "vault.db-journal"];
|
|
96795
|
+
LEGACY_SERVICE_FILES = [
|
|
96796
|
+
"vault.key",
|
|
96797
|
+
"vault.key.enc",
|
|
96798
|
+
"kms.json",
|
|
96799
|
+
"aws.json",
|
|
96800
|
+
".serve-token"
|
|
96801
|
+
];
|
|
96802
|
+
});
|
|
96803
|
+
var SecretsTestIsolationError;
|
|
96804
|
+
var TEST_ENTRYPOINT_RE;
|
|
96805
|
+
var init_test_isolation = __esm2(() => {
|
|
96806
|
+
init_data_dir();
|
|
96807
|
+
SecretsTestIsolationError = class SecretsTestIsolationError2 extends Error {
|
|
96808
|
+
constructor(message) {
|
|
96809
|
+
super(message);
|
|
96810
|
+
this.name = "SecretsTestIsolationError";
|
|
96811
|
+
}
|
|
96812
|
+
};
|
|
96813
|
+
TEST_ENTRYPOINT_RE = /\.(test|spec)\.[cm]?[jt]sx?$/;
|
|
96814
|
+
});
|
|
96815
|
+
var init_client = __esm2(() => {
|
|
96816
|
+
init_transport();
|
|
96817
|
+
init_storage();
|
|
96818
|
+
init_test_isolation();
|
|
96819
|
+
init_transport();
|
|
96820
|
+
});
|
|
96821
|
+
init_client();
|
|
96822
|
+
init_client();
|
|
96823
|
+
|
|
96824
|
+
// src/lib/skill-version.ts
|
|
96825
|
+
var SKILL_VERSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/;
|
|
96826
|
+
function isValidSkillVersion(value) {
|
|
96827
|
+
return typeof value === "string" && SKILL_VERSION_PATTERN.test(value) && !/^\.+$/.test(value) && !value.includes("..");
|
|
96828
|
+
}
|
|
96829
|
+
var SKILL_VERSION_RULE = "1-128 characters: letters, digits, '.', '_', '+', '-'; must start with a letter or digit; no '..'";
|
|
96830
|
+
|
|
96831
|
+
// src/lib/selection-aliases.ts
|
|
96832
|
+
function selectionAliasError(selections2) {
|
|
96833
|
+
const names = new Set(selections2.map((selection) => selection.slug));
|
|
96834
|
+
for (const selection of selections2) {
|
|
96835
|
+
if (selection.aliases === undefined)
|
|
96836
|
+
continue;
|
|
96837
|
+
if (!Array.isArray(selection.aliases) || selection.aliases.length > 32)
|
|
96838
|
+
return "Selection aliases must be an array of at most 32 names.";
|
|
96839
|
+
for (const alias of selection.aliases) {
|
|
96840
|
+
if (typeof alias !== "string" || alias.length > 128 || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(alias))
|
|
96841
|
+
return "Selection aliases must be bounded kebab-case names.";
|
|
96842
|
+
if (names.has(alias))
|
|
96843
|
+
return "Selection aliases must be unique and cannot shadow a selected canonical name.";
|
|
96844
|
+
names.add(alias);
|
|
96845
|
+
}
|
|
96846
|
+
}
|
|
96847
|
+
}
|
|
96848
|
+
|
|
96849
|
+
// src/lib/profile-limits.ts
|
|
96850
|
+
var MAX_PROFILE_SELECTIONS = 4096;
|
|
96851
|
+
var MAX_PROFILE_DOCUMENT_BYTES = 8 * 1024 * 1024;
|
|
96852
|
+
var MAX_SKILL_SESSION_ID_CHARS = 256;
|
|
96853
|
+
var PROFILE_SESSION_ENVELOPE_BYTES = MAX_PROFILE_SELECTIONS * 67 + MAX_SKILL_SESSION_ID_CHARS * 6 + 256;
|
|
96854
|
+
var MAX_RESOLVED_PROFILE_BYTES = MAX_PROFILE_DOCUMENT_BYTES - PROFILE_SESSION_ENVELOPE_BYTES;
|
|
96855
|
+
function profileDocumentBytes(value) {
|
|
96856
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
96857
|
+
}
|
|
96858
|
+
function resolvedProfileSnapshot(profile2, authority) {
|
|
96859
|
+
return {
|
|
96860
|
+
profileId: profile2.id,
|
|
96861
|
+
workspaceId: profile2.workspaceId,
|
|
96862
|
+
profileRevision: profile2.revision,
|
|
96863
|
+
authority,
|
|
96864
|
+
selections: profile2.selections.map((selection) => ({ ...selection, authority, workspaceId: profile2.workspaceId, profileRevision: profile2.revision }))
|
|
96865
|
+
};
|
|
96866
|
+
}
|
|
96867
|
+
|
|
96868
|
+
// src/lib/selection-cache.ts
|
|
96869
|
+
class SkillSelectionError extends Error {
|
|
96870
|
+
code;
|
|
96871
|
+
constructor(code, message) {
|
|
96872
|
+
super(message);
|
|
96873
|
+
this.code = code;
|
|
96874
|
+
this.name = "SkillSelectionError";
|
|
96875
|
+
}
|
|
96876
|
+
}
|
|
96877
|
+
var MAX_CACHED_PROFILE_AGE_MS = 24 * 60 * 60 * 1000;
|
|
96878
|
+
|
|
96879
|
+
// src/lib/execution-secrets.ts
|
|
96880
|
+
function refuse(code, message) {
|
|
96881
|
+
throw new SkillSelectionError(code, message);
|
|
96882
|
+
}
|
|
96883
|
+
function declaredSecretNames(value) {
|
|
96884
|
+
if (value === undefined)
|
|
96885
|
+
return [];
|
|
96886
|
+
if (!Array.isArray(value) || value.length > 32 || value.some((name) => typeof name !== "string" || !/^[A-Z][A-Z0-9_]{0,127}$/.test(name)) || new Set(value).size !== value.length) {
|
|
96887
|
+
return refuse("INVALID_SKILL_MANIFEST", "Runtime environment references must be unique uppercase identifiers (at most 32).");
|
|
96888
|
+
}
|
|
96889
|
+
if (value.some((name) => /^(?:PATH|HOME|TMPDIR|TEMP|TMP|LANG|LC_ALL|TERM|SHELL|ENV|BASH_ENV|IFS|NODE_OPTIONS|NODE_PATH)$/.test(name) || /^(?:SKILLS_|BUN_|PYTHON|LD_|DYLD_)/.test(name))) {
|
|
96890
|
+
return refuse("INVALID_SKILL_MANIFEST", "Runtime environment references cannot override execution controls.");
|
|
96891
|
+
}
|
|
96892
|
+
return value;
|
|
96893
|
+
}
|
|
96894
|
+
|
|
96895
|
+
// src/lib/execution-grants.ts
|
|
96896
|
+
var MAX_EXECUTION_GRANTS = 256;
|
|
96897
|
+
var MAX_EXECUTION_GRANT_BYTES = 2 * 1024 * 1024;
|
|
96898
|
+
function grantIdentifier(v2) {
|
|
96899
|
+
return typeof v2 === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(v2) && !v2.includes("..");
|
|
96900
|
+
}
|
|
96901
|
+
function grantRecord(v2) {
|
|
96902
|
+
return !!v2 && typeof v2 === "object" && !Array.isArray(v2);
|
|
96903
|
+
}
|
|
96904
|
+
function keys(v2, required, optional = []) {
|
|
96905
|
+
return required.every((k3) => Object.hasOwn(v2, k3)) && Object.keys(v2).every((k3) => required.includes(k3) || optional.includes(k3));
|
|
96906
|
+
}
|
|
96907
|
+
function invalid() {
|
|
96908
|
+
throw new Error("Invalid execution grant policy: use exact selections, named actors and consumers, and vault reference names only.");
|
|
96909
|
+
}
|
|
96910
|
+
function authority(v2) {
|
|
96911
|
+
if (typeof v2 !== "string" || v2.length > 2048 || /[\x00-\x20\x7f]/.test(v2))
|
|
96912
|
+
return false;
|
|
96913
|
+
try {
|
|
96914
|
+
const u2 = new URL(v2);
|
|
96915
|
+
return (u2.protocol === "https:" || u2.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(u2.hostname)) && !u2.username && !u2.password && !u2.search && !u2.hash && u2.pathname.endsWith("/v1") && u2.href === v2;
|
|
96916
|
+
} catch {
|
|
96917
|
+
return false;
|
|
96918
|
+
}
|
|
96919
|
+
}
|
|
96920
|
+
function pathFlavor(value) {
|
|
96921
|
+
return value.startsWith("/") ? posix : win32;
|
|
96922
|
+
}
|
|
96923
|
+
function grantWorkspace(v2) {
|
|
96924
|
+
if (typeof v2 !== "string" || !v2 || v2.length > 4096 || /[\x00-\x1f\x7f]/.test(v2))
|
|
96925
|
+
return false;
|
|
96926
|
+
const flavor = pathFlavor(v2);
|
|
96927
|
+
if (flavor === win32 && !/^(?:[A-Za-z]:\\|\\\\[^\\]+\\[^\\]+)/.test(v2))
|
|
96928
|
+
return false;
|
|
96929
|
+
return flavor.isAbsolute(v2) && flavor.normalize(v2) === v2;
|
|
96930
|
+
}
|
|
96931
|
+
function grantDirectoryContains(root3, directory, descendants = false) {
|
|
96932
|
+
if (!grantWorkspace(root3) || !grantWorkspace(directory) || pathFlavor(root3) !== pathFlavor(directory))
|
|
96933
|
+
return false;
|
|
96934
|
+
if (root3 === directory)
|
|
96935
|
+
return true;
|
|
96936
|
+
const flavor = pathFlavor(root3), relative = flavor.relative(root3, directory);
|
|
96937
|
+
return descendants && !!relative && relative !== ".." && !relative.startsWith(`..${flavor.sep}`) && !flavor.isAbsolute(relative);
|
|
96938
|
+
}
|
|
96939
|
+
function selection(v2) {
|
|
96940
|
+
return grantRecord(v2) && keys(v2, ["slug", "version", "bundleDigest"]) && grantIdentifier(v2.slug) && isValidSkillVersion(v2.version) && typeof v2.bundleDigest === "string" && /^sha256:[a-f0-9]{64}$/.test(v2.bundleDigest);
|
|
96941
|
+
}
|
|
96942
|
+
function validateExecutionGrants(value) {
|
|
96943
|
+
if (!Array.isArray(value) || value.length > MAX_EXECUTION_GRANTS)
|
|
96944
|
+
invalid();
|
|
96945
|
+
const ids = new Set;
|
|
96946
|
+
for (const g3 of value) {
|
|
96947
|
+
if (!grantRecord(g3) || !keys(g3, [
|
|
96948
|
+
"id",
|
|
96949
|
+
"target",
|
|
96950
|
+
"selection",
|
|
96951
|
+
"actors",
|
|
96952
|
+
"consumers",
|
|
96953
|
+
"secretsAuthority",
|
|
96954
|
+
"bindings"
|
|
96955
|
+
], ["expiresAt"]) || !grantIdentifier(g3.id) || ids.has(g3.id) || g3.target !== "local" || !selection(g3.selection) || !authority(g3.secretsAuthority))
|
|
96956
|
+
invalid();
|
|
96957
|
+
ids.add(g3.id);
|
|
96958
|
+
if (!Array.isArray(g3.actors) || !g3.actors.length || g3.actors.length > 256 || !g3.actors.every(grantIdentifier) || new Set(g3.actors).size !== g3.actors.length)
|
|
96959
|
+
invalid();
|
|
96960
|
+
if (!Array.isArray(g3.consumers) || !g3.consumers.length || g3.consumers.length > 256)
|
|
96961
|
+
invalid();
|
|
96962
|
+
const consumers = new Set;
|
|
96963
|
+
for (const c3 of g3.consumers) {
|
|
96964
|
+
if (!grantRecord(c3) || !keys(c3, ["stationId", "workspaceDirectory"], ["includeDescendants"]) || !grantIdentifier(c3.stationId) || !grantWorkspace(c3.workspaceDirectory) || c3.includeDescendants !== undefined && typeof c3.includeDescendants !== "boolean")
|
|
96965
|
+
invalid();
|
|
96966
|
+
const key = JSON.stringify([
|
|
96967
|
+
c3.stationId,
|
|
96968
|
+
c3.workspaceDirectory,
|
|
96969
|
+
c3.includeDescendants === true
|
|
96970
|
+
]);
|
|
96971
|
+
if (consumers.has(key))
|
|
96972
|
+
invalid();
|
|
96973
|
+
consumers.add(key);
|
|
96974
|
+
}
|
|
96975
|
+
if (!grantRecord(g3.bindings) || !Object.keys(g3.bindings).length)
|
|
96976
|
+
invalid();
|
|
96977
|
+
try {
|
|
96978
|
+
declaredSecretNames(Object.keys(g3.bindings));
|
|
96979
|
+
} catch {
|
|
96980
|
+
invalid();
|
|
96981
|
+
}
|
|
96982
|
+
for (const ref of Object.values(g3.bindings))
|
|
96983
|
+
if (typeof ref !== "string" || ref.length > 2048 || !/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(ref) || ref.split("/").some((p2) => !p2 || p2 === "." || p2 === ".."))
|
|
96984
|
+
invalid();
|
|
96985
|
+
if (g3.expiresAt !== undefined && (typeof g3.expiresAt !== "string" || !Number.isFinite(Date.parse(g3.expiresAt)) || new Date(g3.expiresAt).toISOString() !== g3.expiresAt))
|
|
96986
|
+
invalid();
|
|
96987
|
+
}
|
|
96988
|
+
if (Buffer.byteLength(JSON.stringify(value)) > MAX_EXECUTION_GRANT_BYTES - 2048)
|
|
96989
|
+
invalid();
|
|
96990
|
+
return structuredClone(value);
|
|
96991
|
+
}
|
|
96992
|
+
function validateExecutionGrantRequest(value) {
|
|
96993
|
+
if (!grantRecord(value) || !keys(value, ["selection", "consumer"]) || !grantRecord(value.selection) || !keys(value.selection, [
|
|
96994
|
+
"authority",
|
|
96995
|
+
"workspaceId",
|
|
96996
|
+
"profileId",
|
|
96997
|
+
"profileRevision",
|
|
96998
|
+
"slug",
|
|
96999
|
+
"version",
|
|
97000
|
+
"bundleDigest"
|
|
97001
|
+
]) || !grantRecord(value.consumer) || !keys(value.consumer, ["stationId", "workspaceDirectory"]))
|
|
97002
|
+
invalid();
|
|
97003
|
+
const { selection: s2, consumer: c3 } = value;
|
|
97004
|
+
if (!selection({
|
|
97005
|
+
slug: s2.slug,
|
|
97006
|
+
version: s2.version,
|
|
97007
|
+
bundleDigest: s2.bundleDigest
|
|
97008
|
+
}) || !authority(s2.authority) || ![s2.workspaceId, s2.profileId, s2.profileRevision, c3.stationId].every(grantIdentifier) || !grantWorkspace(c3.workspaceDirectory))
|
|
97009
|
+
invalid();
|
|
97010
|
+
return structuredClone(value);
|
|
97011
|
+
}
|
|
97012
|
+
function executionGrantMatches(g3, r3, actorId, now = Date.now()) {
|
|
97013
|
+
return g3.target === "local" && g3.actors.includes(actorId) && (!g3.expiresAt || Date.parse(g3.expiresAt) > now) && g3.selection.slug === r3.selection.slug && g3.selection.version === r3.selection.version && g3.selection.bundleDigest === r3.selection.bundleDigest && g3.consumers.some((c3) => c3.stationId === r3.consumer.stationId && grantDirectoryContains(c3.workspaceDirectory, r3.consumer.workspaceDirectory, c3.includeDescendants));
|
|
97014
|
+
}
|
|
97015
|
+
|
|
97016
|
+
// src/lib/hosted-skill-set.ts
|
|
97017
|
+
var HOSTED_RUNTIMES = new Set(["hosted"]);
|
|
97018
|
+
var HOSTED_SOURCES = new Set(["remote", "private-hosted"]);
|
|
97019
|
+
var HOSTED_METADATA_SET_EMPTY_ERROR = [
|
|
97020
|
+
"The hosted metadata skill set is empty, but the packaging guards that depend on it",
|
|
97021
|
+
"only mean anything while it is non-empty: an empty set makes every one of them pass",
|
|
97022
|
+
"vacuously and silently removes the protection that keeps hosted implementation source",
|
|
97023
|
+
"out of the published package.",
|
|
97024
|
+
"",
|
|
97025
|
+
"If emptying the set is intentional (every hosted skill was deleted or converted to a",
|
|
97026
|
+
"runnable in-repo skill), retire the derived guards in the SAME change \u2014 do not let them",
|
|
97027
|
+
"stay green and empty."
|
|
97028
|
+
].join(`
|
|
97029
|
+
`);
|
|
97030
|
+
var SLUG = "[^,{}/]+";
|
|
97031
|
+
var BRACE_SOURCE_EXCLUSION = new RegExp(`^!skills/\\{(${SLUG}(?:,${SLUG})+)\\}/src$`);
|
|
97032
|
+
var SINGLE_SOURCE_EXCLUSION = new RegExp(`^!skills/(${SLUG})/src$`);
|
|
97033
|
+
|
|
97034
|
+
// src/lib/skill-validation.ts
|
|
97035
|
+
var RESERVED_SKILL_ENTRIES = new Set([
|
|
97036
|
+
".env",
|
|
97037
|
+
".npmrc",
|
|
97038
|
+
".pypirc",
|
|
97039
|
+
".netrc",
|
|
97040
|
+
"id_rsa",
|
|
97041
|
+
"id_ed25519"
|
|
97042
|
+
]);
|
|
97043
|
+
var KNOWN_TOP_LEVEL_ENTRIES = new Set([
|
|
97044
|
+
".claude",
|
|
97045
|
+
".env.example",
|
|
97046
|
+
".gitignore",
|
|
97047
|
+
".skills",
|
|
97048
|
+
"CLAUDE.md",
|
|
97049
|
+
"AGENTS.md",
|
|
97050
|
+
"LICENSE",
|
|
97051
|
+
"PROJECT_OVERVIEW.md",
|
|
97052
|
+
"QUICKSTART.md",
|
|
97053
|
+
"README.md",
|
|
97054
|
+
"SKILL.md",
|
|
97055
|
+
"api-docs-list.json",
|
|
97056
|
+
"auth.ts",
|
|
97057
|
+
"bun.lock",
|
|
97058
|
+
"bunfig.toml",
|
|
97059
|
+
"data",
|
|
97060
|
+
"dist",
|
|
97061
|
+
"examples",
|
|
97062
|
+
"exports",
|
|
97063
|
+
"http-client.ts",
|
|
97064
|
+
"index.ts",
|
|
97065
|
+
"install.sh",
|
|
97066
|
+
"installer.ts",
|
|
97067
|
+
"logs",
|
|
97068
|
+
"node_modules",
|
|
97069
|
+
"package.json",
|
|
97070
|
+
"scripts",
|
|
97071
|
+
"skill-install.ts",
|
|
97072
|
+
"skill.json",
|
|
97073
|
+
"src",
|
|
97074
|
+
"tests",
|
|
97075
|
+
"references",
|
|
97076
|
+
"assets",
|
|
97077
|
+
"tsconfig.json",
|
|
97078
|
+
"vision.ts"
|
|
97079
|
+
]);
|
|
97080
|
+
var VALID_PROVENANCE_SOURCES = new Set(["official", "custom", "remote", "private", "private-hosted", "upstream", "extension"]);
|
|
97081
|
+
function frontmatterString(raw) {
|
|
97082
|
+
if (raw.startsWith('"') && raw.endsWith('"')) {
|
|
97083
|
+
try {
|
|
97084
|
+
const decoded = JSON.parse(raw);
|
|
97085
|
+
if (typeof decoded === "string")
|
|
97086
|
+
return decoded;
|
|
97087
|
+
} catch {}
|
|
97088
|
+
}
|
|
97089
|
+
return raw.replace(/^["']|["']$/g, "");
|
|
97090
|
+
}
|
|
97091
|
+
function parseSkillFrontmatter(content) {
|
|
97092
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
97093
|
+
if (!match)
|
|
97094
|
+
return null;
|
|
97095
|
+
const result = {};
|
|
97096
|
+
const lines = match[1].split(/\r?\n/);
|
|
97097
|
+
for (let i3 = 0;i3 < lines.length; i3++) {
|
|
97098
|
+
const line = lines[i3];
|
|
97099
|
+
const colon = line.indexOf(":");
|
|
97100
|
+
if (colon === -1)
|
|
97101
|
+
continue;
|
|
97102
|
+
const key = line.slice(0, colon).trim();
|
|
97103
|
+
const rawValue = line.slice(colon + 1).trim();
|
|
97104
|
+
if (!key)
|
|
97105
|
+
continue;
|
|
97106
|
+
if (key === "tags" && rawValue === "") {
|
|
97107
|
+
const tags = [];
|
|
97108
|
+
while (i3 + 1 < lines.length && /^\s+-\s+/.test(lines[i3 + 1])) {
|
|
97109
|
+
i3++;
|
|
97110
|
+
tags.push(frontmatterString(lines[i3].replace(/^\s+-\s+/, "").trim()));
|
|
97111
|
+
}
|
|
97112
|
+
result.tags = tags;
|
|
97113
|
+
continue;
|
|
97114
|
+
}
|
|
97115
|
+
const value = frontmatterString(rawValue);
|
|
97116
|
+
if (!value)
|
|
97117
|
+
continue;
|
|
97118
|
+
if (key === "name")
|
|
97119
|
+
result.name = value;
|
|
97120
|
+
else if (key === "description")
|
|
97121
|
+
result.description = value;
|
|
97122
|
+
else if (key === "displayName" || key === "display_name")
|
|
97123
|
+
result.displayName = value;
|
|
97124
|
+
else if (key === "category")
|
|
97125
|
+
result.category = value;
|
|
97126
|
+
else if (key === "version")
|
|
97127
|
+
result.version = value;
|
|
97128
|
+
else if (key === "source")
|
|
97129
|
+
result.source = value;
|
|
97130
|
+
else if (key === "kind")
|
|
97131
|
+
result.kind = value;
|
|
97132
|
+
else if (key === "tags") {
|
|
97133
|
+
result.tags = value.replace(/[\[\]]/g, "").split(",").map((tag) => tag.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
97134
|
+
}
|
|
97135
|
+
}
|
|
97136
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
97137
|
+
}
|
|
97138
|
+
|
|
97139
|
+
// src/lib/selected-manifest.ts
|
|
97140
|
+
function jsonEntry(entries, path) {
|
|
97141
|
+
const entry = entries.find((candidate) => candidate.path === path);
|
|
97142
|
+
if (!entry)
|
|
97143
|
+
return {};
|
|
97144
|
+
try {
|
|
97145
|
+
const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(entry.bytes));
|
|
97146
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
97147
|
+
throw new Error;
|
|
97148
|
+
return value;
|
|
97149
|
+
} catch {
|
|
97150
|
+
throw new SkillSelectionError("INVALID_SKILL_MANIFEST", "The selected skill has an invalid execution manifest.");
|
|
97151
|
+
}
|
|
97152
|
+
}
|
|
97153
|
+
function describeEntries(entries) {
|
|
97154
|
+
const manifest = jsonEntry(entries, "skill.json"), packageJson = jsonEntry(entries, "package.json");
|
|
97155
|
+
const docs = entries.find((entry) => entry.path === "SKILL.md");
|
|
97156
|
+
const frontmatter = docs ? parseSkillFrontmatter(new TextDecoder().decode(docs.bytes)) : null;
|
|
97157
|
+
const kind = frontmatter?.kind === "instruction" || manifest.kind === "instruction" || packageJson.skills?.kind === "instruction" ? "instruction" : "executable";
|
|
97158
|
+
return { kind, manifest, packageJson };
|
|
97159
|
+
}
|
|
97160
|
+
|
|
97161
|
+
// node_modules/@hasna/contracts/dist/client/transport.js
|
|
97162
|
+
import { createRequire as createRequire3 } from "module";
|
|
96494
97163
|
function envToken(name) {
|
|
96495
97164
|
return name.toUpperCase().replace(/-/g, "_");
|
|
96496
97165
|
}
|
|
@@ -96502,13 +97171,13 @@ function clientTransportEnvKeys(name) {
|
|
|
96502
97171
|
};
|
|
96503
97172
|
}
|
|
96504
97173
|
var MAX_PACKAGE_BYTES = 1024 * 1024;
|
|
96505
|
-
var
|
|
96506
|
-
var
|
|
96507
|
-
var
|
|
96508
|
-
var
|
|
96509
|
-
var
|
|
96510
|
-
var
|
|
96511
|
-
var
|
|
97174
|
+
var MAX_CREDENTIAL_FILE_BYTES3 = 64 * 1024;
|
|
97175
|
+
var INSPECT_CUSTOM3 = Symbol.for("nodejs.util.inspect.custom");
|
|
97176
|
+
var CREDENTIAL_SEAL3 = Symbol.for("hasna:contracts:sealedCredential");
|
|
97177
|
+
var AMBIENT_ENVIRONMENT3 = Symbol.for("hasna:contracts:ambientClientEnvironment");
|
|
97178
|
+
var requireSecretsSdk3 = createRequire3(import.meta.url);
|
|
97179
|
+
var IDEMPOTENT_METHODS3 = new Set(["GET", "HEAD", "PUT", "DELETE", "OPTIONS"]);
|
|
97180
|
+
var AUTHORITY_OVERRIDE_HEADERS3 = new Set([
|
|
96512
97181
|
"host",
|
|
96513
97182
|
":authority",
|
|
96514
97183
|
"forwarded",
|
|
@@ -96565,15 +97234,8 @@ function skillsApiRequestUrl(apiUrl, route) {
|
|
|
96565
97234
|
return `${origin}${route}`;
|
|
96566
97235
|
}
|
|
96567
97236
|
|
|
96568
|
-
// src/lib/skill-version.ts
|
|
96569
|
-
var SKILL_VERSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/;
|
|
96570
|
-
function isValidSkillVersion(value) {
|
|
96571
|
-
return typeof value === "string" && SKILL_VERSION_PATTERN.test(value) && !/^\.+$/.test(value) && !value.includes("..");
|
|
96572
|
-
}
|
|
96573
|
-
var SKILL_VERSION_RULE = "1-128 characters: letters, digits, '.', '_', '+', '-'; must start with a letter or digit; no '..'";
|
|
96574
|
-
|
|
96575
97237
|
// src/server/skills-api.ts
|
|
96576
|
-
import { createHash as
|
|
97238
|
+
import { createHash as createHash6 } from "crypto";
|
|
96577
97239
|
var SLUG_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
96578
97240
|
var SHA256_HEX2 = /^[0-9a-f]{64}$/;
|
|
96579
97241
|
var MAX_SLUG_LENGTH = 128;
|
|
@@ -96750,7 +97412,7 @@ async function parsePublishRequest(request, config) {
|
|
|
96750
97412
|
if (bundleBytes.byteLength === 0) {
|
|
96751
97413
|
throw new SkillRequestError(400, "BUNDLE_EMPTY", "the uploaded bundle is empty");
|
|
96752
97414
|
}
|
|
96753
|
-
const sha256 =
|
|
97415
|
+
const sha256 = createHash6("sha256").update(bundleBytes).digest("hex");
|
|
96754
97416
|
const claimed = optionalString(manifest.bundleSha256);
|
|
96755
97417
|
if (claimed)
|
|
96756
97418
|
assertSha2562(claimed);
|
|
@@ -96865,7 +97527,7 @@ async function readPublishedBundle(store, artifactStorage, principal, slug) {
|
|
|
96865
97527
|
if (!bytes) {
|
|
96866
97528
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
96867
97529
|
}
|
|
96868
|
-
const actual =
|
|
97530
|
+
const actual = createHash6("sha256").update(bytes).digest("hex");
|
|
96869
97531
|
if (actual !== record.bundleSha256) {
|
|
96870
97532
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}' hashes to ${actual} but was published as ${record.bundleSha256}`);
|
|
96871
97533
|
}
|
|
@@ -97013,7 +97675,7 @@ async function readSkillVersionBundle(store, artifactStorage, principal, slug, v
|
|
|
97013
97675
|
const bytes = await artifactStorage.readBundle(bundle);
|
|
97014
97676
|
if (!bytes)
|
|
97015
97677
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
97016
|
-
const actual =
|
|
97678
|
+
const actual = createHash6("sha256").update(bytes).digest("hex");
|
|
97017
97679
|
if (actual !== found.bundleSha256) {
|
|
97018
97680
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}@${version2}' hashes to ${actual} but was published as ${found.bundleSha256}`);
|
|
97019
97681
|
}
|
|
@@ -97029,41 +97691,159 @@ function publishVersionOf(manifest) {
|
|
|
97029
97691
|
return version2;
|
|
97030
97692
|
}
|
|
97031
97693
|
|
|
97032
|
-
// src/
|
|
97033
|
-
function
|
|
97034
|
-
|
|
97035
|
-
|
|
97036
|
-
|
|
97037
|
-
|
|
97038
|
-
|
|
97039
|
-
|
|
97040
|
-
|
|
97041
|
-
|
|
97042
|
-
|
|
97043
|
-
|
|
97044
|
-
|
|
97045
|
-
|
|
97694
|
+
// src/server/execution-grants-api.ts
|
|
97695
|
+
function refuse2(status, code, message) {
|
|
97696
|
+
throw new SkillRequestError(status, code, message);
|
|
97697
|
+
}
|
|
97698
|
+
function invalid2() {
|
|
97699
|
+
return refuse2(400, "INVALID_EXECUTION_GRANT", "Invalid execution grant document or consumer scope.");
|
|
97700
|
+
}
|
|
97701
|
+
function json(value, status = 200, revision) {
|
|
97702
|
+
return Response.json(value, {
|
|
97703
|
+
status,
|
|
97704
|
+
headers: {
|
|
97705
|
+
"Cache-Control": "no-store",
|
|
97706
|
+
...revision ? { ETag: `"${revision}"` } : {}
|
|
97707
|
+
}
|
|
97708
|
+
});
|
|
97709
|
+
}
|
|
97710
|
+
async function body(request, limit) {
|
|
97711
|
+
if (!request.body)
|
|
97712
|
+
invalid2();
|
|
97713
|
+
const reader = request.body.getReader(), chunks = [];
|
|
97714
|
+
let size = 0;
|
|
97715
|
+
try {
|
|
97716
|
+
while (true) {
|
|
97717
|
+
const { done, value } = await reader.read();
|
|
97718
|
+
if (done)
|
|
97719
|
+
break;
|
|
97720
|
+
size += value.byteLength;
|
|
97721
|
+
if (size > limit) {
|
|
97722
|
+
await reader.cancel();
|
|
97723
|
+
refuse2(413, "BODY_TOO_LARGE", "Execution grant request exceeds its size limit.");
|
|
97724
|
+
}
|
|
97725
|
+
chunks.push(value);
|
|
97046
97726
|
}
|
|
97727
|
+
} finally {
|
|
97728
|
+
reader.releaseLock();
|
|
97729
|
+
}
|
|
97730
|
+
try {
|
|
97731
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)));
|
|
97732
|
+
} catch {
|
|
97733
|
+
return invalid2();
|
|
97047
97734
|
}
|
|
97048
97735
|
}
|
|
97049
|
-
|
|
97050
|
-
|
|
97051
|
-
|
|
97052
|
-
|
|
97053
|
-
|
|
97054
|
-
var PROFILE_SESSION_ENVELOPE_BYTES = MAX_PROFILE_SELECTIONS * 67 + MAX_SKILL_SESSION_ID_CHARS * 6 + 256;
|
|
97055
|
-
var MAX_RESOLVED_PROFILE_BYTES = MAX_PROFILE_DOCUMENT_BYTES - PROFILE_SESSION_ENVELOPE_BYTES;
|
|
97056
|
-
function profileDocumentBytes(value) {
|
|
97057
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
97736
|
+
function currentSelection(profile2, grant) {
|
|
97737
|
+
const selected = profile2.selections.find((s2) => s2.slug === grant.slug);
|
|
97738
|
+
if (!selected || selected.version !== grant.version || selected.bundleDigest !== grant.bundleDigest) {
|
|
97739
|
+
refuse2(409, "EXECUTION_SELECTION_MISMATCH", "The exact executable version and digest must still be selected in the current profile.");
|
|
97740
|
+
}
|
|
97058
97741
|
}
|
|
97059
|
-
function
|
|
97060
|
-
|
|
97061
|
-
|
|
97062
|
-
|
|
97063
|
-
|
|
97064
|
-
|
|
97065
|
-
|
|
97066
|
-
|
|
97742
|
+
async function validatePublishedGrant(store, artifacts, principal, grant) {
|
|
97743
|
+
const bundle = await readSkillVersionBundle(store, artifacts, principal, grant.selection.slug, grant.selection.version);
|
|
97744
|
+
if (`sha256:${bundle.version.bundleSha256}` !== grant.selection.bundleDigest) {
|
|
97745
|
+
refuse2(409, "EXECUTION_SELECTION_MISMATCH", "Execution grant digest does not match the published version.");
|
|
97746
|
+
}
|
|
97747
|
+
let names;
|
|
97748
|
+
try {
|
|
97749
|
+
const { entries } = await inspectSkillBundle(bundle.bytes);
|
|
97750
|
+
const { kind, manifest } = describeEntries(entries);
|
|
97751
|
+
if (kind !== "executable")
|
|
97752
|
+
invalid2();
|
|
97753
|
+
names = declaredSecretNames(manifest.runtime?.env);
|
|
97754
|
+
} catch {
|
|
97755
|
+
return invalid2();
|
|
97756
|
+
}
|
|
97757
|
+
if (!names.length || names.length !== Object.keys(grant.bindings).length || names.some((name) => !Object.hasOwn(grant.bindings, name)))
|
|
97758
|
+
invalid2();
|
|
97759
|
+
}
|
|
97760
|
+
async function handleExecutionGrantApi(store, principal, request, parts, config, artifacts) {
|
|
97761
|
+
const [resource, id, child, revision] = parts;
|
|
97762
|
+
if (resource !== "execution-grants")
|
|
97763
|
+
return null;
|
|
97764
|
+
if (!grantIdentifier(id))
|
|
97765
|
+
invalid2();
|
|
97766
|
+
const { executionGrantStore: policies, selectionStore: profiles } = store;
|
|
97767
|
+
if (!policies || !profiles)
|
|
97768
|
+
refuse2(503, "EXECUTION_GRANTS_UNAVAILABLE", "This store does not support execution grants.");
|
|
97769
|
+
const historical = parts.length === 4 && child === "versions" && grantIdentifier(revision);
|
|
97770
|
+
if (request.method === "GET" && (parts.length === 2 || historical)) {
|
|
97771
|
+
const policy = await policies.get(principal, id, historical ? revision : undefined);
|
|
97772
|
+
if (!policy)
|
|
97773
|
+
refuse2(404, "EXECUTION_GRANTS_NOT_FOUND", "Execution grant policy not found.");
|
|
97774
|
+
return json(policy, 200, policy.revision);
|
|
97775
|
+
}
|
|
97776
|
+
if (request.method === "PUT" && parts.length === 2) {
|
|
97777
|
+
const match = request.headers.get("if-match"), create = request.headers.get("if-none-match");
|
|
97778
|
+
if (!match && create !== "*" || match && create) {
|
|
97779
|
+
refuse2(428, "EXECUTION_GRANT_PRECONDITION_REQUIRED", "Use If-None-Match: * to create or If-Match with the current policy revision to update.");
|
|
97780
|
+
}
|
|
97781
|
+
const expected = match ? /^"([a-zA-Z0-9-]{1,128})"$/.exec(match)?.[1] : null;
|
|
97782
|
+
if (match && !expected)
|
|
97783
|
+
invalid2();
|
|
97784
|
+
const input = await body(request, Math.min(config.requestBodyLimitBytes, MAX_EXECUTION_GRANT_BYTES));
|
|
97785
|
+
if (!grantRecord(input) || Object.keys(input).length !== 1 || !Object.hasOwn(input, "grants"))
|
|
97786
|
+
invalid2();
|
|
97787
|
+
let grants;
|
|
97788
|
+
try {
|
|
97789
|
+
grants = validateExecutionGrants(input.grants);
|
|
97790
|
+
} catch {
|
|
97791
|
+
return invalid2();
|
|
97792
|
+
}
|
|
97793
|
+
const profile2 = await profiles.getProfile(principal, id);
|
|
97794
|
+
if (!profile2)
|
|
97795
|
+
refuse2(404, "PROFILE_NOT_FOUND", "Profile not found.");
|
|
97796
|
+
for (const grant of grants) {
|
|
97797
|
+
currentSelection(profile2, grant.selection);
|
|
97798
|
+
await validatePublishedGrant(store, artifacts, principal, grant);
|
|
97799
|
+
}
|
|
97800
|
+
if ((await profiles.getProfile(principal, id))?.revision !== profile2.revision) {
|
|
97801
|
+
refuse2(409, "PROFILE_REVISION_CONFLICT", "Profile changed while validating grants; resolve it again.");
|
|
97802
|
+
}
|
|
97803
|
+
const saved = await policies.save(principal, id, grants, expected ?? null);
|
|
97804
|
+
if (!saved)
|
|
97805
|
+
refuse2(409, "EXECUTION_GRANT_REVISION_CONFLICT", "Execution grant policy changed; read it before retrying.");
|
|
97806
|
+
return json(saved, create ? 201 : 200, saved.revision);
|
|
97807
|
+
}
|
|
97808
|
+
if (request.method === "POST" && parts.length === 3 && child === "resolve") {
|
|
97809
|
+
const input = await body(request, Math.min(config.requestBodyLimitBytes, 16384));
|
|
97810
|
+
let consumer;
|
|
97811
|
+
try {
|
|
97812
|
+
consumer = validateExecutionGrantRequest(input);
|
|
97813
|
+
} catch {
|
|
97814
|
+
return invalid2();
|
|
97815
|
+
}
|
|
97816
|
+
const authority2 = skillsApiRequestUrl(normalizeSkillsApiOrigin(config.publicBaseUrl), "/api/v1/").replace(/\/+$/, "");
|
|
97817
|
+
if (consumer.selection.authority !== authority2 || consumer.selection.workspaceId !== principal.orgId || consumer.selection.profileId !== id) {
|
|
97818
|
+
refuse2(403, "EXECUTION_GRANT_SCOPE_MISMATCH", "The requested execution authority, workspace or profile does not match this request.");
|
|
97819
|
+
}
|
|
97820
|
+
const profile2 = await profiles.getProfile(principal, id);
|
|
97821
|
+
if (!profile2)
|
|
97822
|
+
refuse2(404, "PROFILE_NOT_FOUND", "Profile not found.");
|
|
97823
|
+
if (profile2.revision !== consumer.selection.profileRevision)
|
|
97824
|
+
refuse2(409, "PROFILE_REVISION_CONFLICT", "Resolve the current profile before requesting execution grants.");
|
|
97825
|
+
currentSelection(profile2, consumer.selection);
|
|
97826
|
+
const policy = await policies.get(principal, id);
|
|
97827
|
+
const matches = policy?.grants.filter((grant2) => executionGrantMatches(grant2, consumer, principal.userId)) ?? [];
|
|
97828
|
+
if (matches.length !== 1)
|
|
97829
|
+
refuse2(403, "EXECUTION_GRANT_DENIED", "No unique current execution grant permits this actor, executable and consumer.");
|
|
97830
|
+
const grant = matches[0];
|
|
97831
|
+
await validatePublishedGrant(store, artifacts, principal, grant);
|
|
97832
|
+
if ((await profiles.getProfile(principal, id))?.revision !== profile2.revision || (await policies.get(principal, id))?.revision !== policy.revision || !executionGrantMatches(grant, consumer, principal.userId)) {
|
|
97833
|
+
refuse2(409, "EXECUTION_GRANT_REVISION_CONFLICT", "Execution authorization changed; resolve it again.");
|
|
97834
|
+
}
|
|
97835
|
+
return json({
|
|
97836
|
+
policyRevision: policy.revision,
|
|
97837
|
+
grantId: grant.id,
|
|
97838
|
+
bindings: {
|
|
97839
|
+
schema: "hasna.skills-secret-bindings.v1",
|
|
97840
|
+
...consumer,
|
|
97841
|
+
secretsAuthority: grant.secretsAuthority,
|
|
97842
|
+
bindings: grant.bindings
|
|
97843
|
+
}
|
|
97844
|
+
});
|
|
97845
|
+
}
|
|
97846
|
+
return null;
|
|
97067
97847
|
}
|
|
97068
97848
|
|
|
97069
97849
|
// src/server/profile-api.ts
|
|
@@ -97075,36 +97855,36 @@ function object(value) {
|
|
|
97075
97855
|
function identifier(value) {
|
|
97076
97856
|
return typeof value === "string" && ID.test(value) && !value.includes("..");
|
|
97077
97857
|
}
|
|
97078
|
-
function
|
|
97858
|
+
function invalid3(message) {
|
|
97079
97859
|
throw new SkillRequestError(400, "INVALID_SELECTION", message);
|
|
97080
97860
|
}
|
|
97081
97861
|
function selected(value) {
|
|
97082
97862
|
if (!Array.isArray(value) || value.length > MAX_PROFILE_SELECTIONS)
|
|
97083
|
-
|
|
97863
|
+
invalid3(`selections must be an array with at most ${MAX_PROFILE_SELECTIONS} entries`);
|
|
97084
97864
|
const seen = new Set;
|
|
97085
97865
|
const selections2 = value.map((item) => {
|
|
97086
97866
|
if (!object(item) || typeof item.slug !== "string" || !isValidSkillVersion(item.version) || typeof item.bundleDigest !== "string" || !DIGEST.test(item.bundleDigest))
|
|
97087
|
-
|
|
97867
|
+
invalid3("Each selection requires slug, exact version, and sha256 bundleDigest");
|
|
97088
97868
|
assertPublishableSlug(item.slug);
|
|
97089
97869
|
if (seen.has(item.slug))
|
|
97090
|
-
|
|
97870
|
+
invalid3("A profile may select each skill only once");
|
|
97091
97871
|
seen.add(item.slug);
|
|
97092
97872
|
let triggers;
|
|
97093
97873
|
if (item.triggers !== undefined) {
|
|
97094
97874
|
if (!object(item.triggers) || Object.keys(item.triggers).some((key) => !["keywords", "paths", "always"].includes(key)))
|
|
97095
|
-
|
|
97875
|
+
invalid3("Invalid selection triggers");
|
|
97096
97876
|
triggers = {};
|
|
97097
97877
|
for (const key of ["keywords", "paths"]) {
|
|
97098
97878
|
const terms = item.triggers[key];
|
|
97099
97879
|
if (terms !== undefined) {
|
|
97100
97880
|
if (!Array.isArray(terms) || terms.length > 32 || terms.some((term) => typeof term !== "string" || !term.trim() || term.length > 256))
|
|
97101
|
-
|
|
97881
|
+
invalid3("Trigger terms must be bounded nonempty strings");
|
|
97102
97882
|
triggers[key] = terms;
|
|
97103
97883
|
}
|
|
97104
97884
|
}
|
|
97105
97885
|
if (item.triggers.always !== undefined) {
|
|
97106
97886
|
if (typeof item.triggers.always !== "boolean")
|
|
97107
|
-
|
|
97887
|
+
invalid3("always must be boolean");
|
|
97108
97888
|
triggers.always = item.triggers.always;
|
|
97109
97889
|
}
|
|
97110
97890
|
}
|
|
@@ -97118,38 +97898,38 @@ function selected(value) {
|
|
|
97118
97898
|
}).sort((a3, b3) => a3.slug < b3.slug ? -1 : a3.slug > b3.slug ? 1 : 0);
|
|
97119
97899
|
const aliasError = selectionAliasError(selections2);
|
|
97120
97900
|
if (aliasError)
|
|
97121
|
-
|
|
97901
|
+
invalid3(aliasError);
|
|
97122
97902
|
return selections2;
|
|
97123
97903
|
}
|
|
97124
97904
|
async function validatePublished(store, principal, selections2) {
|
|
97125
|
-
for (const
|
|
97126
|
-
const current = await store.getSkill(principal,
|
|
97905
|
+
for (const selection2 of selections2) {
|
|
97906
|
+
const current = await store.getSkill(principal, selection2.slug);
|
|
97127
97907
|
if (!current || current.tombstonedAt)
|
|
97128
|
-
throw new SkillRequestError(current?.tombstonedAt ? 410 : 404, "SELECTION_UNAVAILABLE", `Selected skill '${
|
|
97129
|
-
const version2 = await store.getSkillVersion(principal,
|
|
97130
|
-
if (!version2 || `sha256:${version2.bundleSha256}` !==
|
|
97131
|
-
throw new SkillRequestError(409, "SELECTION_VERSION_MISMATCH", `Selected version of '${
|
|
97908
|
+
throw new SkillRequestError(current?.tombstonedAt ? 410 : 404, "SELECTION_UNAVAILABLE", `Selected skill '${selection2.slug}' is unavailable`);
|
|
97909
|
+
const version2 = await store.getSkillVersion(principal, selection2.slug, selection2.version);
|
|
97910
|
+
if (!version2 || `sha256:${version2.bundleSha256}` !== selection2.bundleDigest)
|
|
97911
|
+
throw new SkillRequestError(409, "SELECTION_VERSION_MISMATCH", `Selected version of '${selection2.slug}' does not match its published digest`);
|
|
97132
97912
|
if (!await store.getSkillBundle(principal, version2.bundleSha256))
|
|
97133
97913
|
throw new SkillRequestError(503, "SELECTION_BUNDLE_UNAVAILABLE", "Selected bundle is unavailable");
|
|
97134
97914
|
}
|
|
97135
97915
|
}
|
|
97136
|
-
async function
|
|
97916
|
+
async function body2(request, limit) {
|
|
97137
97917
|
if (!request.body)
|
|
97138
|
-
|
|
97918
|
+
invalid3("JSON body required");
|
|
97139
97919
|
const reader = request.body.getReader();
|
|
97140
97920
|
let size = 0;
|
|
97141
97921
|
const chunks = [];
|
|
97142
97922
|
try {
|
|
97143
97923
|
while (true) {
|
|
97144
|
-
const
|
|
97145
|
-
if (
|
|
97924
|
+
const next2 = await reader.read();
|
|
97925
|
+
if (next2.done)
|
|
97146
97926
|
break;
|
|
97147
|
-
size +=
|
|
97927
|
+
size += next2.value.byteLength;
|
|
97148
97928
|
if (size > limit) {
|
|
97149
97929
|
await reader.cancel();
|
|
97150
97930
|
throw new SkillRequestError(413, "BODY_TOO_LARGE", "Request body too large");
|
|
97151
97931
|
}
|
|
97152
|
-
chunks.push(
|
|
97932
|
+
chunks.push(next2.value);
|
|
97153
97933
|
}
|
|
97154
97934
|
} finally {
|
|
97155
97935
|
reader.releaseLock();
|
|
@@ -97164,13 +97944,13 @@ async function body(request, limit) {
|
|
|
97164
97944
|
}
|
|
97165
97945
|
parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
97166
97946
|
} catch {
|
|
97167
|
-
|
|
97947
|
+
invalid3("Malformed JSON body");
|
|
97168
97948
|
}
|
|
97169
97949
|
if (!object(parsed))
|
|
97170
|
-
|
|
97950
|
+
invalid3("JSON object required");
|
|
97171
97951
|
return parsed;
|
|
97172
97952
|
}
|
|
97173
|
-
function
|
|
97953
|
+
function json2(value, status = 200, revision) {
|
|
97174
97954
|
if (profileDocumentBytes(value) > MAX_PROFILE_DOCUMENT_BYTES)
|
|
97175
97955
|
throw new SkillRequestError(413, "PROFILE_TOO_LARGE", "Profile document exceeds its size limit");
|
|
97176
97956
|
return Response.json(value, {
|
|
@@ -97184,7 +97964,7 @@ function json(value, status = 200, revision) {
|
|
|
97184
97964
|
async function handleProfileApi(store, principal, request, parts, config) {
|
|
97185
97965
|
const [resource, id, child] = parts;
|
|
97186
97966
|
if (resource === "capabilities" && request.method === "GET" && parts.length === 1)
|
|
97187
|
-
return
|
|
97967
|
+
return json2({
|
|
97188
97968
|
contractVersion: 1,
|
|
97189
97969
|
apiVersion: 1,
|
|
97190
97970
|
service: "skills",
|
|
@@ -97192,8 +97972,10 @@ async function handleProfileApi(store, principal, request, parts, config) {
|
|
|
97192
97972
|
capabilities: [
|
|
97193
97973
|
"skills.registry",
|
|
97194
97974
|
"skills.versions",
|
|
97975
|
+
...store.selectionStore && store.executionGrantStore ? ["skills.execution-grants"] : [],
|
|
97195
97976
|
...store.selectionStore ? ["skills.profiles", "skills.station-state"] : []
|
|
97196
97977
|
],
|
|
97978
|
+
executionGrants: Boolean(store.selectionStore && store.executionGrantStore),
|
|
97197
97979
|
profileResolution: Boolean(store.selectionStore),
|
|
97198
97980
|
selectionAliases: Boolean(store.selectionStore),
|
|
97199
97981
|
profileLimits: {
|
|
@@ -97207,6 +97989,9 @@ async function handleProfileApi(store, principal, request, parts, config) {
|
|
|
97207
97989
|
incrementalSync: false,
|
|
97208
97990
|
scopes: [...principal.scopes].sort(),
|
|
97209
97991
|
permissions: {
|
|
97992
|
+
executionGrantsRead: permitsSkillsRoute(principal, "GET", "execution-grants"),
|
|
97993
|
+
executionGrantsWrite: permitsSkillsRoute(principal, "PUT", "execution-grants"),
|
|
97994
|
+
executionGrantsResolve: permitsSkillsRoute(principal, "POST", "execution-grants"),
|
|
97210
97995
|
read: permitsSkillsRoute(principal, "GET", "skills"),
|
|
97211
97996
|
publish: permitsSkillsRoute(principal, "POST", "skills"),
|
|
97212
97997
|
profilesWrite: permitsSkillsRoute(principal, "PUT", "profiles"),
|
|
@@ -97222,16 +98007,16 @@ async function handleProfileApi(store, principal, request, parts, config) {
|
|
|
97222
98007
|
if (!adapter)
|
|
97223
98008
|
throw new SkillRequestError(503, "PROFILES_UNAVAILABLE", "This store does not support profiles");
|
|
97224
98009
|
if (resource === "profiles" && parts.length === 2 && request.method === "PUT") {
|
|
97225
|
-
const input = await
|
|
98010
|
+
const input = await body2(request, Math.min(config.requestBodyLimitBytes, MAX_PROFILE_DOCUMENT_BYTES)), selections2 = selected(input.selections);
|
|
97226
98011
|
const match = request.headers.get("if-match"), create = request.headers.get("if-none-match");
|
|
97227
98012
|
if (!match && create !== "*" || match && create)
|
|
97228
98013
|
throw new SkillRequestError(428, "PROFILE_PRECONDITION_REQUIRED", "Use If-None-Match: * to create or If-Match with the current revision to update");
|
|
97229
98014
|
const expected = match ? /^"([a-zA-Z0-9-]{1,128})"$/.exec(match)?.[1] : null;
|
|
97230
98015
|
if (match && !expected)
|
|
97231
98016
|
throw new SkillRequestError(400, "INVALID_PRECONDITION", "A quoted revision ETag is required");
|
|
97232
|
-
const
|
|
98017
|
+
const authority2 = skillsApiRequestUrl(normalizeSkillsApiOrigin(config.publicBaseUrl), "/api/v1/").replace(/\/+$/, "");
|
|
97233
98018
|
const revision = "x".repeat(128);
|
|
97234
|
-
const projected = resolvedProfileSnapshot({ id, workspaceId: principal.orgId, revision, selections: selections2 },
|
|
98019
|
+
const projected = resolvedProfileSnapshot({ id, workspaceId: principal.orgId, revision, selections: selections2 }, authority2);
|
|
97235
98020
|
if (profileDocumentBytes(projected) > MAX_RESOLVED_PROFILE_BYTES || profileDocumentBytes({ profileId: id, profileRevision: revision, selections: selections2 }) > Math.min(config.requestBodyLimitBytes, MAX_PROFILE_DOCUMENT_BYTES)) {
|
|
97236
98021
|
throw new SkillRequestError(413, "PROFILE_TOO_LARGE", "The complete resolved profile and station/session receipts must fit the advertised profile limits");
|
|
97237
98022
|
}
|
|
@@ -97239,7 +98024,7 @@ async function handleProfileApi(store, principal, request, parts, config) {
|
|
|
97239
98024
|
const saved = await adapter.saveProfile(principal, id, selections2, expected ?? null);
|
|
97240
98025
|
if (!saved)
|
|
97241
98026
|
throw new SkillRequestError(409, "PROFILE_REVISION_CONFLICT", "Profile changed; read it before retrying");
|
|
97242
|
-
return
|
|
98027
|
+
return json2(saved, create ? 201 : 200, saved.revision);
|
|
97243
98028
|
}
|
|
97244
98029
|
if (resource === "profiles" && request.method === "GET" && (parts.length === 2 || parts.length === 3 && child === "resolve")) {
|
|
97245
98030
|
const profile2 = await adapter.getProfile(principal, id);
|
|
@@ -97248,25 +98033,25 @@ async function handleProfileApi(store, principal, request, parts, config) {
|
|
|
97248
98033
|
if (profile2.selections.length > MAX_PROFILE_SELECTIONS)
|
|
97249
98034
|
throw new SkillRequestError(413, "PROFILE_TOO_LARGE", "Profile exceeds the advertised selection limit");
|
|
97250
98035
|
if (!child)
|
|
97251
|
-
return
|
|
97252
|
-
const
|
|
97253
|
-
const result = resolvedProfileSnapshot(profile2,
|
|
98036
|
+
return json2(profile2, 200, profile2.revision);
|
|
98037
|
+
const authority2 = skillsApiRequestUrl(normalizeSkillsApiOrigin(config.publicBaseUrl), "/api/v1/").replace(/\/+$/, "");
|
|
98038
|
+
const result = resolvedProfileSnapshot(profile2, authority2);
|
|
97254
98039
|
if (result.selections.length > MAX_PROFILE_SELECTIONS || profileDocumentBytes(result) > MAX_RESOLVED_PROFILE_BYTES)
|
|
97255
98040
|
throw new SkillRequestError(413, "PROFILE_TOO_LARGE", "Resolved profile exceeds the advertised profile limits");
|
|
97256
98041
|
await validatePublished(store, principal, profile2.selections);
|
|
97257
|
-
return
|
|
98042
|
+
return json2(result, 200, profile2.revision);
|
|
97258
98043
|
}
|
|
97259
98044
|
if (resource === "stations" && parts.length === 3 && child === "state") {
|
|
97260
98045
|
if (request.method === "GET") {
|
|
97261
98046
|
const state2 = await adapter.getStationState(principal, id);
|
|
97262
98047
|
if (!state2)
|
|
97263
98048
|
throw new SkillRequestError(404, "STATION_STATE_NOT_FOUND", "No station state reported");
|
|
97264
|
-
return
|
|
98049
|
+
return json2(state2);
|
|
97265
98050
|
}
|
|
97266
98051
|
if (request.method === "PUT") {
|
|
97267
|
-
const input = await
|
|
98052
|
+
const input = await body2(request, Math.min(config.requestBodyLimitBytes, MAX_PROFILE_DOCUMENT_BYTES));
|
|
97268
98053
|
if (!identifier(input.profileId) || !identifier(input.profileRevision))
|
|
97269
|
-
|
|
98054
|
+
invalid3("profileId and profileRevision are required");
|
|
97270
98055
|
const receipt = {
|
|
97271
98056
|
profileId: input.profileId,
|
|
97272
98057
|
profileRevision: input.profileRevision,
|
|
@@ -97281,7 +98066,7 @@ async function handleProfileApi(store, principal, request, parts, config) {
|
|
|
97281
98066
|
const saved = await adapter.saveStationState(principal, id, receipt);
|
|
97282
98067
|
if (!saved)
|
|
97283
98068
|
throw new SkillRequestError(409, "PROFILE_REVISION_CONFLICT", "Profile changed while reporting state");
|
|
97284
|
-
return
|
|
98069
|
+
return json2(saved);
|
|
97285
98070
|
}
|
|
97286
98071
|
}
|
|
97287
98072
|
return null;
|
|
@@ -97583,7 +98368,7 @@ class RuntimeExecutionStore {
|
|
|
97583
98368
|
}
|
|
97584
98369
|
|
|
97585
98370
|
// src/sdk/execution/admission.ts
|
|
97586
|
-
import { createHash as
|
|
98371
|
+
import { createHash as createHash8 } from "crypto";
|
|
97587
98372
|
|
|
97588
98373
|
// src/sdk/execution/image-profile.ts
|
|
97589
98374
|
class ImageProfileResolutionError extends Error {
|
|
@@ -97730,15 +98515,15 @@ class MemoryRunExecutionStore {
|
|
|
97730
98515
|
if (attempt.leaseGeneration !== input.expectedLeaseGeneration) {
|
|
97731
98516
|
return { ok: false, reason: "STALE_GENERATION" };
|
|
97732
98517
|
}
|
|
97733
|
-
const
|
|
98518
|
+
const next2 = {
|
|
97734
98519
|
...attempt,
|
|
97735
98520
|
leaseGeneration: attempt.leaseGeneration + 1,
|
|
97736
98521
|
workerId: input.workerId,
|
|
97737
98522
|
claimedAt: new Date().toISOString(),
|
|
97738
98523
|
status: "leased"
|
|
97739
98524
|
};
|
|
97740
|
-
this.attempts.set(attempt.attemptId,
|
|
97741
|
-
return { ok: true, attempt:
|
|
98525
|
+
this.attempts.set(attempt.attemptId, next2);
|
|
98526
|
+
return { ok: true, attempt: next2, leaseGeneration: next2.leaseGeneration };
|
|
97742
98527
|
}
|
|
97743
98528
|
async recordLaunchIntent(input) {
|
|
97744
98529
|
const run = this.runs.get(input.runId);
|
|
@@ -97750,28 +98535,28 @@ class MemoryRunExecutionStore {
|
|
|
97750
98535
|
return { ok: false, reason: "NO_SUCH_ATTEMPT" };
|
|
97751
98536
|
if (attempt.status === "terminal")
|
|
97752
98537
|
return { ok: false, reason: "ATTEMPT_TERMINAL" };
|
|
97753
|
-
const
|
|
98538
|
+
const next2 = {
|
|
97754
98539
|
...attempt,
|
|
97755
98540
|
clientToken: input.clientToken,
|
|
97756
98541
|
requestDigest: input.requestDigest,
|
|
97757
98542
|
startedBy: input.startedBy,
|
|
97758
98543
|
launchState: "launching"
|
|
97759
98544
|
};
|
|
97760
|
-
this.attempts.set(attempt.attemptId,
|
|
98545
|
+
this.attempts.set(attempt.attemptId, next2);
|
|
97761
98546
|
this.runs.set(input.runId, { ...run, currentAttemptId: attempt.attemptId, updatedAt: new Date().toISOString() });
|
|
97762
|
-
return { ok: true, attempt:
|
|
98547
|
+
return { ok: true, attempt: next2 };
|
|
97763
98548
|
}
|
|
97764
98549
|
async recordLaunchState(input) {
|
|
97765
98550
|
const attempt = this.attempts.get(input.attemptId);
|
|
97766
98551
|
if (!attempt)
|
|
97767
98552
|
return null;
|
|
97768
|
-
const
|
|
98553
|
+
const next2 = {
|
|
97769
98554
|
...attempt,
|
|
97770
98555
|
launchState: input.launchState,
|
|
97771
98556
|
...input.taskId === undefined ? {} : { taskId: input.taskId }
|
|
97772
98557
|
};
|
|
97773
|
-
this.attempts.set(attempt.attemptId,
|
|
97774
|
-
return
|
|
98558
|
+
this.attempts.set(attempt.attemptId, next2);
|
|
98559
|
+
return next2;
|
|
97775
98560
|
}
|
|
97776
98561
|
async recordTransition(transition) {
|
|
97777
98562
|
this.transitions.push(transition);
|
|
@@ -97780,9 +98565,9 @@ class MemoryRunExecutionStore {
|
|
|
97780
98565
|
const attempt = this.attempts.get(attemptId);
|
|
97781
98566
|
if (!attempt)
|
|
97782
98567
|
return null;
|
|
97783
|
-
const
|
|
97784
|
-
this.attempts.set(attemptId,
|
|
97785
|
-
return
|
|
98568
|
+
const next2 = { ...attempt, status: "terminal" };
|
|
98569
|
+
this.attempts.set(attemptId, next2);
|
|
98570
|
+
return next2;
|
|
97786
98571
|
}
|
|
97787
98572
|
async writeReceipt(receipt) {
|
|
97788
98573
|
this.receipts.set(receipt.runId + "\x00" + receipt.attemptId, receipt);
|
|
@@ -97800,22 +98585,22 @@ class MemoryRunExecutionStore {
|
|
|
97800
98585
|
this.attempts.set(attemptId, { ...attempt, status: "terminal" });
|
|
97801
98586
|
}
|
|
97802
98587
|
}
|
|
97803
|
-
const
|
|
98588
|
+
const next2 = {
|
|
97804
98589
|
...run,
|
|
97805
98590
|
status,
|
|
97806
98591
|
terminalReceiptId: receiptId2,
|
|
97807
98592
|
updatedAt: new Date().toISOString()
|
|
97808
98593
|
};
|
|
97809
|
-
this.runs.set(runId2,
|
|
97810
|
-
return
|
|
98594
|
+
this.runs.set(runId2, next2);
|
|
98595
|
+
return next2;
|
|
97811
98596
|
}
|
|
97812
98597
|
async setRunStatus(runId2, status) {
|
|
97813
98598
|
const run = this.runs.get(runId2);
|
|
97814
98599
|
if (!run)
|
|
97815
98600
|
return null;
|
|
97816
|
-
const
|
|
97817
|
-
this.runs.set(runId2,
|
|
97818
|
-
return
|
|
98601
|
+
const next2 = { ...run, status, updatedAt: new Date().toISOString() };
|
|
98602
|
+
this.runs.set(runId2, next2);
|
|
98603
|
+
return next2;
|
|
97819
98604
|
}
|
|
97820
98605
|
}
|
|
97821
98606
|
function isMemoryTerminal(status) {
|
|
@@ -97898,11 +98683,11 @@ function ownedAdmission(admission) {
|
|
|
97898
98683
|
};
|
|
97899
98684
|
}
|
|
97900
98685
|
function digestInput(input) {
|
|
97901
|
-
return
|
|
98686
|
+
return createHash8("sha256").update(canonicalJson(input)).digest("hex");
|
|
97902
98687
|
}
|
|
97903
98688
|
|
|
97904
98689
|
// src/sdk/execution/dispatchers/ecs.ts
|
|
97905
|
-
import { createHash as
|
|
98690
|
+
import { createHash as createHash9 } from "crypto";
|
|
97906
98691
|
|
|
97907
98692
|
// src/sdk/execution/state-machine.ts
|
|
97908
98693
|
var LEGAL_TRANSITIONS = {
|
|
@@ -97931,8 +98716,8 @@ function createRunStateMachine(store) {
|
|
|
97931
98716
|
if (!LEGAL_TRANSITIONS[from].includes(to)) {
|
|
97932
98717
|
return { ok: false, reason: "INVALID_TRANSITION" };
|
|
97933
98718
|
}
|
|
97934
|
-
const
|
|
97935
|
-
if (!
|
|
98719
|
+
const next2 = await store.setRunStatus(runId2, to);
|
|
98720
|
+
if (!next2)
|
|
97936
98721
|
return { ok: false, reason: "NO_SUCH_RUN" };
|
|
97937
98722
|
const record = {
|
|
97938
98723
|
runId: runId2,
|
|
@@ -98100,7 +98885,7 @@ function convertHttpAuthSchemesToMap2(httpAuthSchemes) {
|
|
|
98100
98885
|
}
|
|
98101
98886
|
return map;
|
|
98102
98887
|
}
|
|
98103
|
-
var httpAuthSchemeMiddleware2 = (config, mwOptions) => (
|
|
98888
|
+
var httpAuthSchemeMiddleware2 = (config, mwOptions) => (next2, context) => async (args) => {
|
|
98104
98889
|
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
|
|
98105
98890
|
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
|
|
98106
98891
|
const resolvedOptions = resolveAuthOptions2(options, authSchemePreference);
|
|
@@ -98132,7 +98917,7 @@ var httpAuthSchemeMiddleware2 = (config, mwOptions) => (next, context) => async
|
|
|
98132
98917
|
throw new Error(failureReasons.join(`
|
|
98133
98918
|
`));
|
|
98134
98919
|
}
|
|
98135
|
-
return
|
|
98920
|
+
return next2(args);
|
|
98136
98921
|
};
|
|
98137
98922
|
var httpAuthSchemeEndpointRuleSetMiddlewareOptions2 = {
|
|
98138
98923
|
step: "serialize",
|
|
@@ -98154,9 +98939,9 @@ var defaultErrorHandler3 = (signingProperties) => (error) => {
|
|
|
98154
98939
|
throw error;
|
|
98155
98940
|
};
|
|
98156
98941
|
var defaultSuccessHandler3 = (httpResponse, signingProperties) => {};
|
|
98157
|
-
var httpSigningMiddleware2 = (config) => (
|
|
98942
|
+
var httpSigningMiddleware2 = (config) => (next2, context) => async (args) => {
|
|
98158
98943
|
if (!HttpRequest8.isInstance(args.request)) {
|
|
98159
|
-
return
|
|
98944
|
+
return next2(args);
|
|
98160
98945
|
}
|
|
98161
98946
|
const smithyContext = getSmithyContext5(context);
|
|
98162
98947
|
const scheme = smithyContext.selectedHttpAuthScheme;
|
|
@@ -98164,7 +98949,7 @@ var httpSigningMiddleware2 = (config) => (next, context) => async (args) => {
|
|
|
98164
98949
|
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
|
|
98165
98950
|
}
|
|
98166
98951
|
const { httpAuthOption: { signingProperties = {} }, identity, signer } = scheme;
|
|
98167
|
-
const output = await
|
|
98952
|
+
const output = await next2({
|
|
98168
98953
|
...args,
|
|
98169
98954
|
request: await signer.sign(args.request, identity, signingProperties)
|
|
98170
98955
|
}).catch((signer.errorHandler || defaultErrorHandler3)(signingProperties));
|
|
@@ -98213,7 +98998,7 @@ var $getHttpSigningPlugin2 = getHttpSigningPlugin3;
|
|
|
98213
98998
|
|
|
98214
98999
|
// node_modules/@aws-sdk/client-ecs/dist-es/ECSClient.js
|
|
98215
99000
|
var import_client37 = __toESM(require_client10(), 1);
|
|
98216
|
-
var
|
|
99001
|
+
var import_config33 = __toESM(require_config9(), 1);
|
|
98217
99002
|
var import_endpoints8 = __toESM(require_endpoints9(), 1);
|
|
98218
99003
|
var import_protocols10 = __toESM(require_protocols9(), 1);
|
|
98219
99004
|
|
|
@@ -98345,7 +99130,7 @@ var asSdkError2 = (error) => {
|
|
|
98345
99130
|
return new Error(`AWS SDK error wrapper for ${error}`);
|
|
98346
99131
|
};
|
|
98347
99132
|
function bindRetryMiddleware2(isStreamingPayload3) {
|
|
98348
|
-
return (options) => (
|
|
99133
|
+
return (options) => (next2, context) => async (args) => {
|
|
98349
99134
|
let retryStrategy = await options.retryStrategy();
|
|
98350
99135
|
const maxAttempts = await options.maxAttempts();
|
|
98351
99136
|
if (isRetryStrategyV22(retryStrategy)) {
|
|
@@ -98364,7 +99149,7 @@ function bindRetryMiddleware2(isStreamingPayload3) {
|
|
|
98364
99149
|
if (isRequest) {
|
|
98365
99150
|
request.headers[REQUEST_HEADER2] = `attempt=${attempts + 1}; max=${maxAttempts}`;
|
|
98366
99151
|
}
|
|
98367
|
-
const { response, output } = await
|
|
99152
|
+
const { response, output } = await next2(args);
|
|
98368
99153
|
retryStrategy.recordSuccess(retryToken);
|
|
98369
99154
|
output.$metadata.attempts = attempts + 1;
|
|
98370
99155
|
output.$metadata.totalRetryDelay = totalRetryDelay;
|
|
@@ -98399,7 +99184,7 @@ function bindRetryMiddleware2(isStreamingPayload3) {
|
|
|
98399
99184
|
if (retryStrategy?.mode) {
|
|
98400
99185
|
context.userAgent = [...context.userAgent || [], ["cfg/retry-mode", retryStrategy.mode]];
|
|
98401
99186
|
}
|
|
98402
|
-
return retryStrategy.retry(
|
|
99187
|
+
return retryStrategy.retry(next2, args);
|
|
98403
99188
|
}
|
|
98404
99189
|
};
|
|
98405
99190
|
}
|
|
@@ -98794,7 +99579,7 @@ class StandardRetryStrategy4 {
|
|
|
98794
99579
|
}
|
|
98795
99580
|
return maxAttempts;
|
|
98796
99581
|
}
|
|
98797
|
-
async retry(
|
|
99582
|
+
async retry(next2, args, options) {
|
|
98798
99583
|
let retryTokenAmount;
|
|
98799
99584
|
let attempts = 0;
|
|
98800
99585
|
let totalDelay = 0;
|
|
@@ -98811,7 +99596,7 @@ class StandardRetryStrategy4 {
|
|
|
98811
99596
|
if (options?.beforeRequest) {
|
|
98812
99597
|
await options.beforeRequest();
|
|
98813
99598
|
}
|
|
98814
|
-
const { response, output } = await
|
|
99599
|
+
const { response, output } = await next2(args);
|
|
98815
99600
|
if (options?.afterRequest) {
|
|
98816
99601
|
options.afterRequest(response);
|
|
98817
99602
|
}
|
|
@@ -99054,7 +99839,7 @@ var package_default3 = {
|
|
|
99054
99839
|
var import_client32 = __toESM(require_client2(), 1);
|
|
99055
99840
|
var import_httpAuthSchemes6 = __toESM(require_httpAuthSchemes(), 1);
|
|
99056
99841
|
var import_client33 = __toESM(require_client10(), 1);
|
|
99057
|
-
var
|
|
99842
|
+
var import_config32 = __toESM(require_config9(), 1);
|
|
99058
99843
|
var import_serde6 = __toESM(require_serde9(), 1);
|
|
99059
99844
|
var import_node_http_handler3 = __toESM(require_dist_cjs7(), 1);
|
|
99060
99845
|
|
|
@@ -101995,7 +102780,7 @@ var getRuntimeConfig4 = (config) => {
|
|
|
101995
102780
|
// node_modules/@aws-sdk/client-ecs/dist-es/runtimeConfig.js
|
|
101996
102781
|
var getRuntimeConfig5 = (config) => {
|
|
101997
102782
|
import_client33.emitWarningIfUnsupportedVersion(process.version);
|
|
101998
|
-
const defaultsMode =
|
|
102783
|
+
const defaultsMode = import_config32.resolveDefaultsModeConfig(config);
|
|
101999
102784
|
const defaultConfigProvider = () => defaultsMode().then(import_client33.loadConfigsForDefaultMode);
|
|
102000
102785
|
const clientSharedValues = getRuntimeConfig4(config);
|
|
102001
102786
|
import_client32.emitWarningIfUnsupportedVersion(process.version);
|
|
@@ -102008,21 +102793,21 @@ var getRuntimeConfig5 = (config) => {
|
|
|
102008
102793
|
...config,
|
|
102009
102794
|
runtime: "node",
|
|
102010
102795
|
defaultsMode,
|
|
102011
|
-
authSchemePreference: config?.authSchemePreference ??
|
|
102796
|
+
authSchemePreference: config?.authSchemePreference ?? import_config32.loadConfig(import_httpAuthSchemes6.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
|
|
102012
102797
|
bodyLengthChecker: config?.bodyLengthChecker ?? import_serde6.calculateBodyLength,
|
|
102013
102798
|
credentialDefaultProvider: config?.credentialDefaultProvider ?? defaultProvider,
|
|
102014
102799
|
defaultUserAgentProvider: config?.defaultUserAgentProvider ?? import_client32.createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: package_default3.version }),
|
|
102015
|
-
maxAttempts: config?.maxAttempts ??
|
|
102016
|
-
region: config?.region ??
|
|
102800
|
+
maxAttempts: config?.maxAttempts ?? import_config32.loadConfig($NODE_MAX_ATTEMPT_CONFIG_OPTIONS2, config),
|
|
102801
|
+
region: config?.region ?? import_config32.loadConfig(import_config32.NODE_REGION_CONFIG_OPTIONS, { ...import_config32.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
|
|
102017
102802
|
requestHandler: import_node_http_handler3.NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
|
|
102018
|
-
retryMode: config?.retryMode ??
|
|
102803
|
+
retryMode: config?.retryMode ?? import_config32.loadConfig({
|
|
102019
102804
|
...$NODE_RETRY_MODE_CONFIG_OPTIONS2,
|
|
102020
102805
|
default: async () => (await defaultConfigProvider()).retryMode || $DEFAULT_RETRY_MODE2
|
|
102021
102806
|
}, config),
|
|
102022
102807
|
streamCollector: config?.streamCollector ?? import_node_http_handler3.streamCollector,
|
|
102023
|
-
useDualstackEndpoint: config?.useDualstackEndpoint ??
|
|
102024
|
-
useFipsEndpoint: config?.useFipsEndpoint ??
|
|
102025
|
-
userAgentAppId: config?.userAgentAppId ??
|
|
102808
|
+
useDualstackEndpoint: config?.useDualstackEndpoint ?? import_config32.loadConfig(import_config32.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
102809
|
+
useFipsEndpoint: config?.useFipsEndpoint ?? import_config32.loadConfig(import_config32.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
102810
|
+
userAgentAppId: config?.userAgentAppId ?? import_config32.loadConfig(import_client32.NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
|
|
102026
102811
|
};
|
|
102027
102812
|
};
|
|
102028
102813
|
|
|
@@ -102087,7 +102872,7 @@ class ECSClient extends import_client37.Client {
|
|
|
102087
102872
|
const _config_1 = resolveClientEndpointParameters3(_config_0);
|
|
102088
102873
|
const _config_2 = import_client36.resolveUserAgentConfig(_config_1);
|
|
102089
102874
|
const _config_3 = $resolveRetryConfig2(_config_2);
|
|
102090
|
-
const _config_4 =
|
|
102875
|
+
const _config_4 = import_config33.resolveRegionConfig(_config_3);
|
|
102091
102876
|
const _config_5 = import_client36.resolveHostHeaderConfig(_config_4);
|
|
102092
102877
|
const _config_6 = import_endpoints8.resolveEndpointConfig(_config_5);
|
|
102093
102878
|
const _config_7 = resolveHttpAuthSchemeConfig3(_config_6);
|
|
@@ -102146,13 +102931,13 @@ function observedTask(states, taskArn) {
|
|
|
102146
102931
|
return state2.lastStatus === "STOPPED" || LIVE_TASK_STATUSES.has(state2.lastStatus) ? state2 : undefined;
|
|
102147
102932
|
}
|
|
102148
102933
|
function clientTokenFor(runId2, attemptId) {
|
|
102149
|
-
return
|
|
102934
|
+
return createHash9("sha256").update(`${runId2}\x00${attemptId}`).digest("hex").slice(0, CLIENT_TOKEN_BYTES * 2);
|
|
102150
102935
|
}
|
|
102151
102936
|
function startedByFor(runId2, attemptNumber) {
|
|
102152
102937
|
return `skills-exec/${runId2}/a${attemptNumber}`;
|
|
102153
102938
|
}
|
|
102154
102939
|
function requestDigestFor(admission, attemptId) {
|
|
102155
|
-
return
|
|
102940
|
+
return createHash9("sha256").update(canonicalJson({ admission, attemptId })).digest("hex");
|
|
102156
102941
|
}
|
|
102157
102942
|
|
|
102158
102943
|
class EcsDispatcher {
|
|
@@ -102379,10 +103164,10 @@ function createAwsEcsClient(region, options = {}) {
|
|
|
102379
103164
|
const client = options.transport ?? new ECSClient({ region });
|
|
102380
103165
|
let boundCluster = options.cluster;
|
|
102381
103166
|
const cluster = (requested) => {
|
|
102382
|
-
const
|
|
102383
|
-
if (!validText(
|
|
103167
|
+
const next2 = requested ?? boundCluster ?? "default";
|
|
103168
|
+
if (!validText(next2) || boundCluster !== undefined && next2 !== boundCluster)
|
|
102384
103169
|
throw Error("ECS client cluster binding changed");
|
|
102385
|
-
return boundCluster ??=
|
|
103170
|
+
return boundCluster ??= next2;
|
|
102386
103171
|
};
|
|
102387
103172
|
const response = (value) => {
|
|
102388
103173
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -102448,7 +103233,7 @@ function validText(value) {
|
|
|
102448
103233
|
}
|
|
102449
103234
|
|
|
102450
103235
|
// src/server/runtime-policy.ts
|
|
102451
|
-
import { createHash as
|
|
103236
|
+
import { createHash as createHash10, createHmac as createHmac3, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
102452
103237
|
var RUNTIME_MAX_INPUT_BYTES = 1e5;
|
|
102453
103238
|
var RUNTIME_MAX_BUNDLE_BYTES = 1e6;
|
|
102454
103239
|
var RUNTIME_MAX_ARTIFACT_BYTES = 2000000;
|
|
@@ -102520,7 +103305,7 @@ function verifyRuntimeToken(token, key, admission, attempt, now = Date.now()) {
|
|
|
102520
103305
|
const actual = Buffer.from(token);
|
|
102521
103306
|
return actual.length === expected.length && timingSafeEqual2(actual, expected);
|
|
102522
103307
|
}
|
|
102523
|
-
var hashBytes = (bytes) =>
|
|
103308
|
+
var hashBytes = (bytes) => createHash10("sha256").update(bytes).digest("hex");
|
|
102524
103309
|
|
|
102525
103310
|
// src/server/runtime-api.ts
|
|
102526
103311
|
async function createRuntimeService(options) {
|
|
@@ -102574,12 +103359,12 @@ async function createRuntimeService(options) {
|
|
|
102574
103359
|
}
|
|
102575
103360
|
return service;
|
|
102576
103361
|
}
|
|
102577
|
-
var
|
|
102578
|
-
var refusal3 = (code, status, error = code) =>
|
|
103362
|
+
var json3 = (body3, status = 200) => Response.json(body3, { status, headers: { "cache-control": "no-store" } });
|
|
103363
|
+
var refusal3 = (code, status, error = code) => json3({ code, error }, status);
|
|
102579
103364
|
function path(request) {
|
|
102580
103365
|
return new URL(request.url).pathname.replace(/^\/skills\/v1(?=\/|$)/, "/api/v1").replace(/^\/v1(?=\/|$)/, "/api/v1").split("/").filter(Boolean);
|
|
102581
103366
|
}
|
|
102582
|
-
async function
|
|
103367
|
+
async function body3(request, max) {
|
|
102583
103368
|
if (!request.body)
|
|
102584
103369
|
throw Error("Request body is required");
|
|
102585
103370
|
const reader = request.body.getReader();
|
|
@@ -102633,7 +103418,7 @@ async function handleRuntimeApiRequest(request, principal, service) {
|
|
|
102633
103418
|
return refusal3("INVALID_EXECUTION_PATH", 400);
|
|
102634
103419
|
try {
|
|
102635
103420
|
if (request.method === "POST" && !sub) {
|
|
102636
|
-
const raw = await
|
|
103421
|
+
const raw = await body3(request, 150000);
|
|
102637
103422
|
if (id !== "pdf-generate" || typeof raw.version !== "string" || !/^\d+\.\d+\.\d+$/.test(raw.version))
|
|
102638
103423
|
return refusal3("REVIEWED_VERSION_REQUIRED", 400);
|
|
102639
103424
|
if (Object.keys(raw).some((k4) => ![
|
|
@@ -102710,7 +103495,7 @@ async function handleRuntimeApiRequest(request, principal, service) {
|
|
|
102710
103495
|
const job2 = await service.store.job(run.runId);
|
|
102711
103496
|
if (!job2)
|
|
102712
103497
|
throw Error("Execution admission disappeared");
|
|
102713
|
-
return
|
|
103498
|
+
return json3({
|
|
102714
103499
|
...publicJob(job2),
|
|
102715
103500
|
...dispatched ? { dispatch: { accepted: dispatched.accepted } } : {}
|
|
102716
103501
|
}, 202);
|
|
@@ -102720,7 +103505,7 @@ async function handleRuntimeApiRequest(request, principal, service) {
|
|
|
102720
103505
|
return refusal3("EXECUTION_NOT_FOUND", 404);
|
|
102721
103506
|
if (request.method === "POST" && sub === "cancel" && segments.length === 5) {
|
|
102722
103507
|
const result = await service.dispatcher.cancel(id);
|
|
102723
|
-
return
|
|
103508
|
+
return json3({
|
|
102724
103509
|
...publicJob(await service.store.job(id)),
|
|
102725
103510
|
cancelAccepted: result.accepted
|
|
102726
103511
|
}, result.accepted ? 200 : 202);
|
|
@@ -102762,17 +103547,17 @@ async function handleRuntimeApiRequest(request, principal, service) {
|
|
|
102762
103547
|
if (!isTerminalStatus(job.execution.status) && Date.now() - Date.parse(job.execution.admission.createdAt) > 20 * 60 * 1000) {
|
|
102763
103548
|
const stopped = await service.dispatcher.cancel(id);
|
|
102764
103549
|
if (!stopped.accepted)
|
|
102765
|
-
return
|
|
103550
|
+
return json3({ ...publicJob(job), reconciliationRequired: true });
|
|
102766
103551
|
}
|
|
102767
|
-
return
|
|
103552
|
+
return json3(publicJob(await service.store.job(id)));
|
|
102768
103553
|
}
|
|
102769
103554
|
if (sub === "logs" && segments.length === 5)
|
|
102770
|
-
return
|
|
103555
|
+
return json3({
|
|
102771
103556
|
stdout: job.result?.stdout ?? "",
|
|
102772
103557
|
stderr: job.result?.stderr ?? ""
|
|
102773
103558
|
});
|
|
102774
103559
|
if (sub === "artifacts" && segments.length === 5)
|
|
102775
|
-
return
|
|
103560
|
+
return json3((job.result?.artifacts ?? []).map(({ base64, ...meta }) => meta));
|
|
102776
103561
|
if (sub === "artifacts" && segments.length === 6) {
|
|
102777
103562
|
const a4 = job.result?.artifacts.find((a5) => a5.name === segments[5]);
|
|
102778
103563
|
if (!a4)
|
|
@@ -102811,7 +103596,7 @@ async function handleRuntimeWorkerRequest(request, service) {
|
|
|
102811
103596
|
if (isTerminalStatus(job.execution.status) || !job.input || !job.bundleBase64)
|
|
102812
103597
|
return refusal3("EXECUTION_NOT_RUNNABLE", 409);
|
|
102813
103598
|
await service.store.setRunStatus(s2[3], "running");
|
|
102814
|
-
return
|
|
103599
|
+
return json3({
|
|
102815
103600
|
admission: job.execution.admission,
|
|
102816
103601
|
input: job.input,
|
|
102817
103602
|
bundleBase64: job.bundleBase64
|
|
@@ -102819,7 +103604,7 @@ async function handleRuntimeWorkerRequest(request, service) {
|
|
|
102819
103604
|
}
|
|
102820
103605
|
if (request.method === "POST" && s2[4] === "complete") {
|
|
102821
103606
|
try {
|
|
102822
|
-
const result = validatedResult(await
|
|
103607
|
+
const result = validatedResult(await body3(request, 3000000));
|
|
102823
103608
|
await service.store.mutate(s2[3], (j4) => {
|
|
102824
103609
|
if (j4.execution.status === "cancelled")
|
|
102825
103610
|
throw Error("Execution cancelled");
|
|
@@ -102849,7 +103634,7 @@ async function handleRuntimeWorkerRequest(request, service) {
|
|
|
102849
103634
|
});
|
|
102850
103635
|
latest.status = "terminal";
|
|
102851
103636
|
});
|
|
102852
|
-
return
|
|
103637
|
+
return json3({ ok: true });
|
|
102853
103638
|
} catch {
|
|
102854
103639
|
return refusal3("RUNTIME_COMPLETION_REJECTED", 409);
|
|
102855
103640
|
}
|
|
@@ -102972,7 +103757,7 @@ var LEGACY_EXECUTION_RETIRED = "LEGACY_EXECUTION_RETIRED";
|
|
|
102972
103757
|
var LEGACY_EXECUTION_GUIDANCE = "Unversioned runs have been retired. Publish and select a versioned executable, then use skills run <name>@<version> --target cloud.";
|
|
102973
103758
|
|
|
102974
103759
|
// src/server/store.ts
|
|
102975
|
-
import { randomUUID as
|
|
103760
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
102976
103761
|
function recordFieldsOf(input, carriedBundle, carriedSkillMd) {
|
|
102977
103762
|
return {
|
|
102978
103763
|
slug: input.slug,
|
|
@@ -103015,6 +103800,7 @@ function instantiateStore(target, sqliteOptions) {
|
|
|
103015
103800
|
|
|
103016
103801
|
class MemorySkillsStore {
|
|
103017
103802
|
selectionStore = new MemorySkillSelectionStore;
|
|
103803
|
+
executionGrantStore = new MemoryExecutionGrantStore;
|
|
103018
103804
|
backend = { kind: "memory", durable: false, label: "memory (non-durable)" };
|
|
103019
103805
|
apiKeys = new Map;
|
|
103020
103806
|
runs = new Map;
|
|
@@ -103059,7 +103845,7 @@ class MemorySkillsStore {
|
|
|
103059
103845
|
input: input.input,
|
|
103060
103846
|
args: input.args,
|
|
103061
103847
|
...idemKey ? { idempotencyKey: idemKey } : {},
|
|
103062
|
-
correlationId:
|
|
103848
|
+
correlationId: randomUUID6(),
|
|
103063
103849
|
costCents: 0,
|
|
103064
103850
|
leaseGeneration: 0,
|
|
103065
103851
|
createdAt: now
|
|
@@ -103108,11 +103894,11 @@ class MemorySkillsStore {
|
|
|
103108
103894
|
return run ? [...this.logs.get(runId2) ?? []] : [];
|
|
103109
103895
|
}
|
|
103110
103896
|
async addArtifact(artifact) {
|
|
103111
|
-
const
|
|
103897
|
+
const next2 = { ...artifact, createdAt: nowIso() };
|
|
103112
103898
|
const artifacts = this.artifacts.get(artifact.runId) ?? [];
|
|
103113
|
-
artifacts.push(
|
|
103899
|
+
artifacts.push(next2);
|
|
103114
103900
|
this.artifacts.set(artifact.runId, artifacts);
|
|
103115
|
-
return
|
|
103901
|
+
return next2;
|
|
103116
103902
|
}
|
|
103117
103903
|
async listArtifacts(principal, runId2) {
|
|
103118
103904
|
const run = await this.getRun(principal, runId2);
|
|
@@ -103218,15 +104004,15 @@ class MemorySkillsStore {
|
|
|
103218
104004
|
if (latest.revisionId !== current.revisionId) {
|
|
103219
104005
|
throw new SkillRevisionConflictError(slug, expectedRevisionId, latest.revisionId);
|
|
103220
104006
|
}
|
|
103221
|
-
const
|
|
104007
|
+
const next2 = {
|
|
103222
104008
|
...latest,
|
|
103223
104009
|
...patch,
|
|
103224
104010
|
updatedAt: nowIso(),
|
|
103225
104011
|
revisionId: revisionIdOfRecord({ ...latest, ...patch }),
|
|
103226
104012
|
revisionNumber: latest.revisionNumber + 1
|
|
103227
104013
|
};
|
|
103228
|
-
this.skills.set(skillKey(principal.orgId, slug),
|
|
103229
|
-
return
|
|
104014
|
+
this.skills.set(skillKey(principal.orgId, slug), next2);
|
|
104015
|
+
return next2;
|
|
103230
104016
|
}
|
|
103231
104017
|
async deleteSkill(principal, slug, tombstoneWindowMs) {
|
|
103232
104018
|
const current = await this.getSkill(principal, slug);
|
|
@@ -103235,9 +104021,9 @@ class MemorySkillsStore {
|
|
|
103235
104021
|
if (!current.tombstonedAt) {
|
|
103236
104022
|
const tombstoned = nowIso();
|
|
103237
104023
|
const purgeAfter = new Date(Date.now() + tombstoneWindowMs).toISOString();
|
|
103238
|
-
const
|
|
103239
|
-
this.skills.set(skillKey(principal.orgId, slug),
|
|
103240
|
-
return
|
|
104024
|
+
const next2 = { ...current, tombstonedAt: tombstoned, tombstonePurgeAfter: purgeAfter, updatedAt: tombstoned };
|
|
104025
|
+
this.skills.set(skillKey(principal.orgId, slug), next2);
|
|
104026
|
+
return next2;
|
|
103241
104027
|
}
|
|
103242
104028
|
return current;
|
|
103243
104029
|
}
|
|
@@ -103309,9 +104095,9 @@ class MemorySkillsStore {
|
|
|
103309
104095
|
const run = this.runs.get(runId2);
|
|
103310
104096
|
if (!run)
|
|
103311
104097
|
return null;
|
|
103312
|
-
const
|
|
103313
|
-
this.runs.set(runId2,
|
|
103314
|
-
return
|
|
104098
|
+
const next2 = { ...run, ...patch };
|
|
104099
|
+
this.runs.set(runId2, next2);
|
|
104100
|
+
return next2;
|
|
103315
104101
|
}
|
|
103316
104102
|
}
|
|
103317
104103
|
function skillKey(orgId, slug) {
|
|
@@ -103328,6 +104114,9 @@ class PostgresSkillsStore {
|
|
|
103328
104114
|
get selectionStore() {
|
|
103329
104115
|
return new PostgresSkillSelectionStore(this.sql);
|
|
103330
104116
|
}
|
|
104117
|
+
get executionGrantStore() {
|
|
104118
|
+
return new PostgresExecutionGrantStore(this.sql);
|
|
104119
|
+
}
|
|
103331
104120
|
backend = { kind: "postgres", durable: true, label: "postgres" };
|
|
103332
104121
|
sql;
|
|
103333
104122
|
constructor(databaseUrl) {
|
|
@@ -103427,7 +104216,7 @@ class PostgresSkillsStore {
|
|
|
103427
104216
|
const id = runId();
|
|
103428
104217
|
const rows = await tx`
|
|
103429
104218
|
INSERT INTO skills_runs (id, org_id, user_id, skill_slug, requested_slug, status, input_json, args_json, idempotency_key, correlation_id)
|
|
103430
|
-
VALUES (${id}, ${input.principal.orgId}, ${input.principal.userId}, ${input.slug}, ${input.slug}, ${"queued"}, ${JSON.stringify(input.input)}::jsonb, ${JSON.stringify(input.args)}::jsonb, ${input.idempotencyKey ?? null}, ${
|
|
104219
|
+
VALUES (${id}, ${input.principal.orgId}, ${input.principal.userId}, ${input.slug}, ${input.slug}, ${"queued"}, ${JSON.stringify(input.input)}::jsonb, ${JSON.stringify(input.args)}::jsonb, ${input.idempotencyKey ?? null}, ${randomUUID6()})
|
|
103431
104220
|
RETURNING *
|
|
103432
104221
|
`;
|
|
103433
104222
|
return rowToRun(rows[0]);
|
|
@@ -103733,14 +104522,14 @@ class PostgresSkillsStore {
|
|
|
103733
104522
|
if (expectedRevisionId !== current.revisionId) {
|
|
103734
104523
|
throw new SkillRevisionConflictError(slug, expectedRevisionId, current.revisionId);
|
|
103735
104524
|
}
|
|
103736
|
-
const
|
|
104525
|
+
const next2 = { ...current, ...patch };
|
|
103737
104526
|
return await this.sql.begin(async (tx) => {
|
|
103738
|
-
const revisionId = revisionIdOfRecord(
|
|
104527
|
+
const revisionId = revisionIdOfRecord(next2);
|
|
103739
104528
|
const updated = await tx`
|
|
103740
104529
|
UPDATE skills_registry
|
|
103741
|
-
SET display_name = ${
|
|
103742
|
-
tags_json = ${JSON.stringify(
|
|
103743
|
-
skill_md = ${
|
|
104530
|
+
SET display_name = ${next2.displayName}, description = ${next2.description}, category = ${next2.category},
|
|
104531
|
+
tags_json = ${JSON.stringify(next2.tags)}::jsonb, kind = ${next2.kind}, version = ${next2.version ?? null},
|
|
104532
|
+
skill_md = ${next2.skillMd ?? null}, revision_id = ${revisionId}, revision_number = revision_number + 1, updated_at = now()
|
|
103744
104533
|
WHERE org_id = ${principal.orgId} AND slug = ${slug} AND tombstoned_at IS NULL AND revision_id = ${current.revisionId}
|
|
103745
104534
|
RETURNING *
|
|
103746
104535
|
`;
|
|
@@ -103755,7 +104544,7 @@ class PostgresSkillsStore {
|
|
|
103755
104544
|
return null;
|
|
103756
104545
|
}
|
|
103757
104546
|
await tx`DELETE FROM skills_tags WHERE org_id = ${principal.orgId} AND slug = ${slug}`;
|
|
103758
|
-
for (const tag of
|
|
104547
|
+
for (const tag of next2.tags) {
|
|
103759
104548
|
if (!tag.trim())
|
|
103760
104549
|
continue;
|
|
103761
104550
|
await tx`
|
|
@@ -103961,40 +104750,40 @@ async function createSkillsFetchHandler(options = {}) {
|
|
|
103961
104750
|
if (callback)
|
|
103962
104751
|
return callback;
|
|
103963
104752
|
if (request.method === "GET" && url.pathname === "/health") {
|
|
103964
|
-
return
|
|
104753
|
+
return json4({ ok: true, service: "skills", time: new Date().toISOString() });
|
|
103965
104754
|
}
|
|
103966
104755
|
if (request.method === "GET" && url.pathname === "/ready") {
|
|
103967
|
-
return
|
|
104756
|
+
return json4({ ok: true, service: "skills" });
|
|
103968
104757
|
}
|
|
103969
104758
|
if (request.method === "GET" && url.pathname === "/version") {
|
|
103970
|
-
return
|
|
104759
|
+
return json4({ ok: true, service: "skills", version: package_default.version });
|
|
103971
104760
|
}
|
|
103972
104761
|
if (url.pathname.startsWith("/api/")) {
|
|
103973
104762
|
const principal = await authenticateRequest(store, request);
|
|
103974
104763
|
if (!principal)
|
|
103975
|
-
return
|
|
104764
|
+
return json4({ error: "authentication required", code: "AUTH_REQUIRED" }, { status: 401 });
|
|
103976
104765
|
const execution = await handleRuntimeApiRequest(request, principal, runtime);
|
|
103977
104766
|
if (execution)
|
|
103978
104767
|
return execution;
|
|
103979
104768
|
if (request.method === "GET" && url.pathname === "/api/v1/capabilities") {
|
|
103980
104769
|
const response = await handleProfileApi(store, principal, request, ["capabilities"], config);
|
|
103981
104770
|
const payload = await response.json();
|
|
103982
|
-
return
|
|
104771
|
+
return json4({ ...payload, cloudExecution: Boolean(runtime), capabilities: [...payload.capabilities, ...runtime ? ["skills.cloud-execution"] : []] });
|
|
103983
104772
|
}
|
|
103984
104773
|
if (request.method === "GET" && url.pathname === "/api/auth/whoami") {
|
|
103985
|
-
return
|
|
104774
|
+
return json4(identityPayload(principal));
|
|
103986
104775
|
}
|
|
103987
104776
|
if (segments[0] === "api" && segments[1] === "v1") {
|
|
103988
104777
|
return await handleApiV1(store, governanceStore, principal, request, segments.slice(2), config, artifactStorage);
|
|
103989
104778
|
}
|
|
103990
104779
|
}
|
|
103991
|
-
return
|
|
104780
|
+
return json4({ error: "not found", code: "NOT_FOUND" }, { status: 404 });
|
|
103992
104781
|
} catch (error) {
|
|
103993
104782
|
if (error instanceof SkillRequestError) {
|
|
103994
|
-
return
|
|
104783
|
+
return json4({ error: error.message, code: error.code }, { status: error.status });
|
|
103995
104784
|
}
|
|
103996
104785
|
if (error instanceof SkillVersionExistsError) {
|
|
103997
|
-
return
|
|
104786
|
+
return json4({
|
|
103998
104787
|
error: error.message,
|
|
103999
104788
|
code: "SKILL_VERSION_EXISTS",
|
|
104000
104789
|
slug: error.slug,
|
|
@@ -104004,14 +104793,14 @@ async function createSkillsFetchHandler(options = {}) {
|
|
|
104004
104793
|
}, { status: 409 });
|
|
104005
104794
|
}
|
|
104006
104795
|
if (error instanceof SkillRevisionConflictError) {
|
|
104007
|
-
return
|
|
104796
|
+
return json4({
|
|
104008
104797
|
error: error.message,
|
|
104009
104798
|
code: "REVISION_CONFLICT",
|
|
104010
104799
|
slug: error.slug,
|
|
104011
104800
|
...error.currentRevisionId ? { currentRevisionId: error.currentRevisionId } : {}
|
|
104012
104801
|
}, { status: 409 });
|
|
104013
104802
|
}
|
|
104014
|
-
return
|
|
104803
|
+
return json4({ error: "internal server error", detail: error.message }, { status: 500 });
|
|
104015
104804
|
}
|
|
104016
104805
|
};
|
|
104017
104806
|
let closed = false;
|
|
@@ -104039,11 +104828,14 @@ var BODY_LIMIT_HEADROOM_BYTES = 1e6;
|
|
|
104039
104828
|
async function handleApiV1(store, governanceStore, principal, request, parts, config, artifactStorage) {
|
|
104040
104829
|
const [resource, id, subresource, childId] = parts;
|
|
104041
104830
|
if (parts.some(segmentEscapesPath)) {
|
|
104042
|
-
return
|
|
104831
|
+
return json4({ error: "invalid path segment", code: "INVALID_PATH" }, { status: 400 });
|
|
104043
104832
|
}
|
|
104044
104833
|
if (!permitsSkillsRoute(principal, request.method, resource ?? "")) {
|
|
104045
|
-
return
|
|
104834
|
+
return json4({ error: "The API key does not allow this operation", code: "INSUFFICIENT_SCOPE" }, { status: 403 });
|
|
104046
104835
|
}
|
|
104836
|
+
const grantResponse = await handleExecutionGrantApi(store, principal, request, parts, config, artifactStorage);
|
|
104837
|
+
if (grantResponse)
|
|
104838
|
+
return grantResponse;
|
|
104047
104839
|
const profileResponse = await handleProfileApi(store, principal, request, parts, config);
|
|
104048
104840
|
if (profileResponse)
|
|
104049
104841
|
return profileResponse;
|
|
@@ -104051,30 +104843,30 @@ async function handleApiV1(store, governanceStore, principal, request, parts, co
|
|
|
104051
104843
|
if (request.method === "GET" && !id) {
|
|
104052
104844
|
const tag = new URL(request.url).searchParams.get("tag");
|
|
104053
104845
|
if (tag !== null && tag !== "")
|
|
104054
|
-
return
|
|
104055
|
-
return
|
|
104846
|
+
return json4(await listMergedSkillsByTag(store, principal, tag));
|
|
104847
|
+
return json4(await listMergedSkills(store, principal));
|
|
104056
104848
|
}
|
|
104057
104849
|
if (request.method === "POST" && !id) {
|
|
104058
104850
|
const expectedRevisionId = parseIfMatch(request.headers.get("if-match"));
|
|
104059
104851
|
const parsed = await parsePublishRequest(request, config);
|
|
104060
104852
|
const { record, alreadyPublished } = await storePublishedSkill(store, artifactStorage, principal, parsed, expectedRevisionId);
|
|
104061
|
-
return
|
|
104853
|
+
return json4(publishedPayload(record, { alreadyPublished }), { status: 201, headers: { ETag: revisionEtag(record.revisionId) } });
|
|
104062
104854
|
}
|
|
104063
104855
|
if (request.method === "GET" && id && subresource === "skill.md") {
|
|
104064
104856
|
const resolved = await resolvePublishedSkill(store, artifactStorage, principal, id);
|
|
104065
104857
|
if (resolved.kind === "tombstone") {
|
|
104066
|
-
return
|
|
104858
|
+
return json4({ error: "skill was deleted", ...resolved.payload }, { status: 410 });
|
|
104067
104859
|
}
|
|
104068
104860
|
const docs = await getMergedSkillMd(store, artifactStorage, principal, id);
|
|
104069
|
-
return docs ? new Response(docs, { headers: { "Content-Type": "text/markdown; charset=utf-8", "Cache-Control": "no-store" } }) :
|
|
104861
|
+
return docs ? new Response(docs, { headers: { "Content-Type": "text/markdown; charset=utf-8", "Cache-Control": "no-store" } }) : json4({ error: "skill not found", code: "SKILL_NOT_FOUND" }, { status: 404 });
|
|
104070
104862
|
}
|
|
104071
104863
|
if (request.method === "GET" && id && subresource === "versions" && !childId) {
|
|
104072
|
-
return
|
|
104864
|
+
return json4(await listSkillVersionsPayload(store, principal, id));
|
|
104073
104865
|
}
|
|
104074
104866
|
if (request.method === "GET" && id && subresource === "versions" && childId && !parts[4]) {
|
|
104075
104867
|
const version2 = await readSkillVersion(store, principal, id, childId);
|
|
104076
104868
|
const current = (await store.getSkill(principal, id))?.bundleSha256;
|
|
104077
|
-
return
|
|
104869
|
+
return json4(skillVersionPayload(version2, current));
|
|
104078
104870
|
}
|
|
104079
104871
|
if (request.method === "GET" && id && subresource === "versions" && childId && parts[4] === "bundle" && !parts[5]) {
|
|
104080
104872
|
const { version: version2, bytes } = await readSkillVersionBundle(store, artifactStorage, principal, id, childId);
|
|
@@ -104094,10 +104886,10 @@ async function handleApiV1(store, governanceStore, principal, request, parts, co
|
|
|
104094
104886
|
if (request.method === "GET" && id && subresource === "bundle") {
|
|
104095
104887
|
const resolved = await resolvePublishedSkill(store, artifactStorage, principal, id);
|
|
104096
104888
|
if (resolved.kind === "tombstone") {
|
|
104097
|
-
return
|
|
104889
|
+
return json4({ error: "skill was deleted", ...resolved.payload }, { status: 410 });
|
|
104098
104890
|
}
|
|
104099
104891
|
if (resolved.kind === "absent") {
|
|
104100
|
-
return
|
|
104892
|
+
return json4({ error: "skill not found", code: "SKILL_NOT_FOUND" }, { status: 404 });
|
|
104101
104893
|
}
|
|
104102
104894
|
const { record, bytes } = await readPublishedBundle(store, artifactStorage, principal, id);
|
|
104103
104895
|
const headers = {
|
|
@@ -104118,90 +104910,90 @@ async function handleApiV1(store, governanceStore, principal, request, parts, co
|
|
|
104118
104910
|
if (request.method === "GET" && id && !subresource) {
|
|
104119
104911
|
const resolved = await resolvePublishedSkill(store, artifactStorage, principal, id);
|
|
104120
104912
|
if (resolved.kind === "tombstone") {
|
|
104121
|
-
return
|
|
104913
|
+
return json4({ error: "skill was deleted", ...resolved.payload }, { status: 410 });
|
|
104122
104914
|
}
|
|
104123
104915
|
if (resolved.kind === "published") {
|
|
104124
|
-
return
|
|
104916
|
+
return json4(publishedPayload(resolved.record), { headers: { ETag: revisionEtag(resolved.record.revisionId) } });
|
|
104125
104917
|
}
|
|
104126
104918
|
const skill = await getMergedSkill(store, artifactStorage, principal, id);
|
|
104127
|
-
return skill ?
|
|
104919
|
+
return skill ? json4(skill) : json4({ error: "skill not found", code: "SKILL_NOT_FOUND" }, { status: 404 });
|
|
104128
104920
|
}
|
|
104129
104921
|
if ((request.method === "PUT" || request.method === "PATCH") && id && !subresource) {
|
|
104130
104922
|
const expectedRevisionId = parseIfMatch(request.headers.get("if-match"));
|
|
104131
|
-
const
|
|
104132
|
-
const updated = await store.updateSkill(principal, id, skillPatch(
|
|
104133
|
-
return updated ?
|
|
104923
|
+
const body4 = await readJson(request, config.requestBodyLimitBytes);
|
|
104924
|
+
const updated = await store.updateSkill(principal, id, skillPatch(body4), expectedRevisionId);
|
|
104925
|
+
return updated ? json4(publishedPayload(updated), { headers: { ETag: revisionEtag(updated.revisionId) } }) : json4({ error: "published skill not found", code: "SKILL_NOT_FOUND" }, { status: 404 });
|
|
104134
104926
|
}
|
|
104135
104927
|
if (request.method === "DELETE" && id && !subresource) {
|
|
104136
104928
|
const removed = await deletePublishedSkill(store, artifactStorage, principal, id, config.tombstoneWindowMs);
|
|
104137
|
-
return removed ?
|
|
104929
|
+
return removed ? json4({
|
|
104138
104930
|
deleted: true,
|
|
104139
104931
|
slug: id,
|
|
104140
104932
|
...removed.tombstonedAt ? { tombstonedAt: removed.tombstonedAt, tombstonePurgeAfter: removed.tombstonePurgeAfter } : {}
|
|
104141
|
-
}) :
|
|
104933
|
+
}) : json4({ error: "published skill not found", code: "SKILL_NOT_FOUND" }, { status: 404 });
|
|
104142
104934
|
}
|
|
104143
104935
|
}
|
|
104144
104936
|
if (resource === "pins") {
|
|
104145
104937
|
if (request.method === "GET" && !id) {
|
|
104146
104938
|
const tag = new URL(request.url).searchParams.get("tag");
|
|
104147
104939
|
if (tag !== null && tag !== "")
|
|
104148
|
-
return
|
|
104149
|
-
return
|
|
104940
|
+
return json4(await listPinsByTag(store, principal, tag));
|
|
104941
|
+
return json4((await store.listPins(principal)).map(pinPayload));
|
|
104150
104942
|
}
|
|
104151
104943
|
if (request.method === "PUT" && id && !subresource) {
|
|
104152
104944
|
assertPublishableSlug(id);
|
|
104153
|
-
const
|
|
104154
|
-
const pin = await store.pinSkill(principal, id, pinMetadataField(
|
|
104155
|
-
return
|
|
104945
|
+
const body4 = await readJson(request, config.requestBodyLimitBytes);
|
|
104946
|
+
const pin = await store.pinSkill(principal, id, pinMetadataField(body4));
|
|
104947
|
+
return json4(pinPayload(pin));
|
|
104156
104948
|
}
|
|
104157
104949
|
if (request.method === "DELETE" && id && !subresource) {
|
|
104158
104950
|
assertPublishableSlug(id);
|
|
104159
104951
|
const removed = await store.unpinSkill(principal, id);
|
|
104160
|
-
return removed ?
|
|
104952
|
+
return removed ? json4({ deleted: true, slug: id }) : json4({ error: "pin not found", code: "PIN_NOT_FOUND" }, { status: 404 });
|
|
104161
104953
|
}
|
|
104162
104954
|
}
|
|
104163
104955
|
if (resource === "tags") {
|
|
104164
104956
|
if (request.method === "GET" && !id) {
|
|
104165
|
-
return
|
|
104957
|
+
return json4(await listOrgTags(store, principal));
|
|
104166
104958
|
}
|
|
104167
104959
|
if (request.method === "GET" && id && subresource === "skills") {
|
|
104168
|
-
return
|
|
104960
|
+
return json4((await listMergedSkillsByTag(store, principal, id)).map(skillSummary));
|
|
104169
104961
|
}
|
|
104170
104962
|
}
|
|
104171
104963
|
if (resource === "runs") {
|
|
104172
104964
|
if (request.method === "GET" && !id) {
|
|
104173
104965
|
const limit = clampInt(new URL(request.url).searchParams.get("limit"), 20, 100);
|
|
104174
|
-
return
|
|
104966
|
+
return json4((await store.listRuns(principal, limit)).map(runPayload));
|
|
104175
104967
|
}
|
|
104176
104968
|
if (request.method === "POST" && id && !subresource) {
|
|
104177
|
-
return
|
|
104969
|
+
return json4({ error: LEGACY_EXECUTION_GUIDANCE, code: LEGACY_EXECUTION_RETIRED }, { status: 410 });
|
|
104178
104970
|
}
|
|
104179
104971
|
if (request.method === "GET" && id && !subresource) {
|
|
104180
104972
|
const run = await store.getRun(principal, id);
|
|
104181
|
-
return run ?
|
|
104973
|
+
return run ? json4(runPayload(run)) : json4({ error: "run not found", code: "RUN_NOT_FOUND" }, { status: 404 });
|
|
104182
104974
|
}
|
|
104183
104975
|
if (request.method === "GET" && id && subresource === "logs") {
|
|
104184
104976
|
const run = await store.getRun(principal, id);
|
|
104185
104977
|
if (!run)
|
|
104186
|
-
return
|
|
104187
|
-
return
|
|
104978
|
+
return json4({ error: "run not found", code: "RUN_NOT_FOUND" }, { status: 404 });
|
|
104979
|
+
return json4(await store.listLogs(principal, id));
|
|
104188
104980
|
}
|
|
104189
104981
|
if (request.method === "GET" && id && subresource === "artifacts" && !childId) {
|
|
104190
104982
|
const run = await store.getRun(principal, id);
|
|
104191
104983
|
if (!run)
|
|
104192
|
-
return
|
|
104984
|
+
return json4({ error: "run not found", code: "RUN_NOT_FOUND" }, { status: 404 });
|
|
104193
104985
|
const artifacts = await store.listArtifacts(principal, id);
|
|
104194
|
-
return
|
|
104986
|
+
return json4(artifacts.map(({ bodyText, ...artifact }) => artifact));
|
|
104195
104987
|
}
|
|
104196
104988
|
if (request.method === "GET" && id && subresource === "artifacts" && childId) {
|
|
104197
104989
|
const artifact = await store.getArtifact(principal, id, childId);
|
|
104198
104990
|
if (!artifact)
|
|
104199
|
-
return
|
|
104200
|
-
const
|
|
104201
|
-
if (
|
|
104202
|
-
return
|
|
104991
|
+
return json4({ error: "artifact not found", code: "ARTIFACT_NOT_FOUND" }, { status: 404 });
|
|
104992
|
+
const body4 = await artifactStorage.readText(artifact);
|
|
104993
|
+
if (body4 === null) {
|
|
104994
|
+
return json4({ error: "artifact storage backend unavailable", code: "ARTIFACT_BACKEND_UNAVAILABLE" }, { status: 503 });
|
|
104203
104995
|
}
|
|
104204
|
-
return new Response(
|
|
104996
|
+
return new Response(body4, {
|
|
104205
104997
|
headers: {
|
|
104206
104998
|
"Content-Type": artifact.contentType,
|
|
104207
104999
|
"Content-Disposition": `attachment; filename="${artifact.fileName.replace(/"/g, "")}"`
|
|
@@ -104211,22 +105003,22 @@ async function handleApiV1(store, governanceStore, principal, request, parts, co
|
|
|
104211
105003
|
if (request.method === "POST" && id && subresource === "cancel") {
|
|
104212
105004
|
const run = await store.getRun(principal, id);
|
|
104213
105005
|
if (!run)
|
|
104214
|
-
return
|
|
105006
|
+
return json4({ error: "run not found", code: "RUN_NOT_FOUND" }, { status: 404 });
|
|
104215
105007
|
try {
|
|
104216
105008
|
const outcome = await createCancelService({ store, governanceStore, storage: artifactStorage }).cancel(principal, id, principal.email);
|
|
104217
|
-
return
|
|
105009
|
+
return json4(runPayload(outcome.run));
|
|
104218
105010
|
} catch (error) {
|
|
104219
105011
|
if (error instanceof GovernanceError && error.code === GOVERNANCE_ERROR_CODES.STALE_LEASE_GENERATION) {
|
|
104220
|
-
return
|
|
105012
|
+
return json4({ error: error.message, code: error.code }, { status: 409 });
|
|
104221
105013
|
}
|
|
104222
105014
|
if (error instanceof StaleLeaseGenerationError) {
|
|
104223
|
-
return
|
|
105015
|
+
return json4({ error: error.message, code: GOVERNANCE_ERROR_CODES.STALE_LEASE_GENERATION }, { status: 409 });
|
|
104224
105016
|
}
|
|
104225
105017
|
throw error;
|
|
104226
105018
|
}
|
|
104227
105019
|
}
|
|
104228
105020
|
}
|
|
104229
|
-
return
|
|
105021
|
+
return json4({ error: "not found", code: "NOT_FOUND" }, { status: 404 });
|
|
104230
105022
|
}
|
|
104231
105023
|
function identityPayload(principal) {
|
|
104232
105024
|
return {
|
|
@@ -104252,22 +105044,22 @@ function runPayload(run) {
|
|
|
104252
105044
|
...run.errorMessage ? { errorMessage: run.errorMessage, error: run.errorMessage } : {}
|
|
104253
105045
|
};
|
|
104254
105046
|
}
|
|
104255
|
-
function skillPatch(
|
|
105047
|
+
function skillPatch(body4) {
|
|
104256
105048
|
const patch = {};
|
|
104257
|
-
if (typeof
|
|
104258
|
-
patch.displayName =
|
|
104259
|
-
if (typeof
|
|
104260
|
-
patch.description =
|
|
104261
|
-
if (typeof
|
|
104262
|
-
patch.category =
|
|
104263
|
-
if (Array.isArray(
|
|
104264
|
-
patch.tags =
|
|
104265
|
-
if (typeof
|
|
104266
|
-
patch.version =
|
|
104267
|
-
if (typeof
|
|
104268
|
-
patch.skillMd =
|
|
104269
|
-
if (
|
|
104270
|
-
patch.kind =
|
|
105049
|
+
if (typeof body4.displayName === "string")
|
|
105050
|
+
patch.displayName = body4.displayName;
|
|
105051
|
+
if (typeof body4.description === "string")
|
|
105052
|
+
patch.description = body4.description;
|
|
105053
|
+
if (typeof body4.category === "string")
|
|
105054
|
+
patch.category = body4.category;
|
|
105055
|
+
if (Array.isArray(body4.tags))
|
|
105056
|
+
patch.tags = body4.tags.filter((tag) => typeof tag === "string");
|
|
105057
|
+
if (typeof body4.version === "string")
|
|
105058
|
+
patch.version = body4.version;
|
|
105059
|
+
if (typeof body4.skillMd === "string")
|
|
105060
|
+
patch.skillMd = body4.skillMd;
|
|
105061
|
+
if (body4.kind === "executable" || body4.kind === "instruction")
|
|
105062
|
+
patch.kind = body4.kind;
|
|
104271
105063
|
return patch;
|
|
104272
105064
|
}
|
|
104273
105065
|
async function readJson(request, limitBytes) {
|
|
@@ -104295,7 +105087,7 @@ function decodeSegment(segment) {
|
|
|
104295
105087
|
function segmentEscapesPath(segment) {
|
|
104296
105088
|
return segment.includes("/") || segment.includes("\\") || segment.includes("..");
|
|
104297
105089
|
}
|
|
104298
|
-
function
|
|
105090
|
+
function json4(payload, init = {}) {
|
|
104299
105091
|
return Response.json(payload, {
|
|
104300
105092
|
...init,
|
|
104301
105093
|
headers: { "Cache-Control": "no-store", ...init.headers }
|