@hasna/skills 0.10.48 → 0.10.49
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 +34 -0
- package/bin/index.js +1090 -648
- package/bin/maintenance.js +18 -0
- package/bin/mcp.js +64 -1
- package/bin/migrate.js +19 -1
- package/bin/server.js +19 -1
- package/bin/worker.js +19 -1
- package/dist/cli/commands/runtime-launcher.d.ts +102 -0
- package/dist/cli/commands/runtime.d.ts +7 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/index.js +413 -261
- package/dist/lib/launch-cwd-apply.d.ts +1 -0
- package/dist/lib/launch-cwd.d.ts +5 -0
- package/dist/lib/self-spawn.d.ts +21 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/sdk/index.js +396 -244
- package/dist/server/index.d.ts +1 -1
- package/dist/server/maintenance.d.ts +1 -1
- package/dist/server/migrate.d.ts +17 -0
- package/dist/server/worker.d.ts +1 -0
- package/package.json +1 -1
package/dist/sdk/index.js
CHANGED
|
@@ -9004,7 +9004,7 @@ var require_client = __commonJS((exports) => {
|
|
|
9004
9004
|
var require_config = __commonJS((exports) => {
|
|
9005
9005
|
var { homedir: homedir7 } = __require("os");
|
|
9006
9006
|
var { sep: sep11, join: join4 } = __require("path");
|
|
9007
|
-
var { createHash:
|
|
9007
|
+
var { createHash: createHash27 } = __require("crypto");
|
|
9008
9008
|
var { readFile: readFile$1 } = __require("fs/promises");
|
|
9009
9009
|
var { IniSectionType } = require_dist_cjs();
|
|
9010
9010
|
var { normalizeProvider } = require_client();
|
|
@@ -9159,7 +9159,7 @@ var require_config = __commonJS((exports) => {
|
|
|
9159
9159
|
var DEFAULT_PROFILE = "default";
|
|
9160
9160
|
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
9161
9161
|
var getSSOTokenFilepath = (id2) => {
|
|
9162
|
-
const hasher =
|
|
9162
|
+
const hasher = createHash27("sha1");
|
|
9163
9163
|
const cacheName = hasher.update(id2).digest("hex");
|
|
9164
9164
|
return join4(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
9165
9165
|
};
|
|
@@ -9311,11 +9311,11 @@ var require_config = __commonJS((exports) => {
|
|
|
9311
9311
|
};
|
|
9312
9312
|
function getSelectorName(functionString) {
|
|
9313
9313
|
try {
|
|
9314
|
-
const
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
return [...
|
|
9314
|
+
const constants16 = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? []));
|
|
9315
|
+
constants16.delete("CONFIG");
|
|
9316
|
+
constants16.delete("CONFIG_PREFIX_SEPARATOR");
|
|
9317
|
+
constants16.delete("ENV");
|
|
9318
|
+
return [...constants16].join(", ");
|
|
9319
9319
|
} catch (ignored) {
|
|
9320
9320
|
return functionString;
|
|
9321
9321
|
}
|
|
@@ -10511,10 +10511,10 @@ var require_endpoints = __commonJS((exports) => {
|
|
|
10511
10511
|
|
|
10512
10512
|
// node_modules/@smithy/core/dist-cjs/submodules/serde/index.js
|
|
10513
10513
|
var require_serde = __commonJS((exports) => {
|
|
10514
|
-
var { createHmac: createHmac2, createHash:
|
|
10514
|
+
var { createHmac: createHmac2, createHash: createHash27, getRandomValues } = __require("crypto");
|
|
10515
10515
|
var { hasOwn: hasOwn2, HttpResponse } = require_transport();
|
|
10516
10516
|
exports.hasOwn = hasOwn2;
|
|
10517
|
-
var { ReadStream, lstatSync:
|
|
10517
|
+
var { ReadStream, lstatSync: lstatSync27, fstatSync: fstatSync4 } = __require("fs");
|
|
10518
10518
|
var { toEndpointV1 } = require_endpoints();
|
|
10519
10519
|
var { Readable, Writable, PassThrough } = __require("stream");
|
|
10520
10520
|
var isArrayBuffer = (arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
@@ -11280,7 +11280,7 @@ var require_serde = __commonJS((exports) => {
|
|
|
11280
11280
|
return body.end + 1 - body.start;
|
|
11281
11281
|
} else if (body instanceof ReadStream) {
|
|
11282
11282
|
if (body.path != null) {
|
|
11283
|
-
return
|
|
11283
|
+
return lstatSync27(body.path).size;
|
|
11284
11284
|
} else if (typeof body.fd === "number") {
|
|
11285
11285
|
return fstatSync4(body.fd).size;
|
|
11286
11286
|
}
|
|
@@ -11416,7 +11416,7 @@ var require_serde = __commonJS((exports) => {
|
|
|
11416
11416
|
return Promise.resolve(this.hash.digest());
|
|
11417
11417
|
}
|
|
11418
11418
|
reset() {
|
|
11419
|
-
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) :
|
|
11419
|
+
this.hash = this.secret ? createHmac2(this.algorithmIdentifier, castSourceData(this.secret)) : createHash27(this.algorithmIdentifier);
|
|
11420
11420
|
}
|
|
11421
11421
|
}
|
|
11422
11422
|
function castSourceData(toCast, encoding) {
|
|
@@ -12155,7 +12155,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12155
12155
|
var { createReadStream } = __require("fs");
|
|
12156
12156
|
var { Writable } = __require("stream");
|
|
12157
12157
|
var { toUint8Array, concatBytes } = require_serde();
|
|
12158
|
-
var { createHash:
|
|
12158
|
+
var { createHash: createHash27, createHmac: createHmac2 } = __require("crypto");
|
|
12159
12159
|
var zlib = __require("zlib");
|
|
12160
12160
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
12161
12161
|
const size = blob.size;
|
|
@@ -12320,7 +12320,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12320
12320
|
}
|
|
12321
12321
|
var hasNativeCrypto$1 = (() => {
|
|
12322
12322
|
try {
|
|
12323
|
-
|
|
12323
|
+
createHash27("md5");
|
|
12324
12324
|
return true;
|
|
12325
12325
|
} catch {
|
|
12326
12326
|
return false;
|
|
@@ -12330,7 +12330,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12330
12330
|
function buildNativeClass$2() {
|
|
12331
12331
|
return class Md5Node2 {
|
|
12332
12332
|
digestLength = 16;
|
|
12333
|
-
hash =
|
|
12333
|
+
hash = createHash27("md5");
|
|
12334
12334
|
update(data) {
|
|
12335
12335
|
this.hash.update(toUint8Array(data));
|
|
12336
12336
|
}
|
|
@@ -12339,7 +12339,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12339
12339
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
12340
12340
|
}
|
|
12341
12341
|
reset() {
|
|
12342
|
-
this.hash =
|
|
12342
|
+
this.hash = createHash27("md5");
|
|
12343
12343
|
}
|
|
12344
12344
|
};
|
|
12345
12345
|
}
|
|
@@ -12629,7 +12629,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12629
12629
|
]);
|
|
12630
12630
|
var hasNativeCrypto = (() => {
|
|
12631
12631
|
try {
|
|
12632
|
-
|
|
12632
|
+
createHash27("sha256");
|
|
12633
12633
|
return true;
|
|
12634
12634
|
} catch {
|
|
12635
12635
|
return false;
|
|
@@ -12669,7 +12669,7 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12669
12669
|
this.finished = false;
|
|
12670
12670
|
}
|
|
12671
12671
|
createHash() {
|
|
12672
|
-
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) :
|
|
12672
|
+
return this.secret ? createHmac2("sha256", toBuffer(this.secret)) : createHash27("sha256");
|
|
12673
12673
|
}
|
|
12674
12674
|
};
|
|
12675
12675
|
}
|
|
@@ -12730,9 +12730,9 @@ var require_checksum = __commonJS((exports) => {
|
|
|
12730
12730
|
const hash2 = await subtle.digest("SHA-256", data);
|
|
12731
12731
|
return new Uint8Array(hash2);
|
|
12732
12732
|
}
|
|
12733
|
-
const
|
|
12734
|
-
|
|
12735
|
-
return
|
|
12733
|
+
const sha2563 = new Sha256Js(this.secret);
|
|
12734
|
+
sha2563.update(data);
|
|
12735
|
+
return sha2563.digest();
|
|
12736
12736
|
}
|
|
12737
12737
|
reset() {
|
|
12738
12738
|
this.pending = [];
|
|
@@ -18071,9 +18071,9 @@ var require_dist_cjs3 = __commonJS((exports) => {
|
|
|
18071
18071
|
sha256;
|
|
18072
18072
|
uriEscapePath;
|
|
18073
18073
|
applyChecksum;
|
|
18074
|
-
constructor({ applyChecksum, credentials, region, service, sha256:
|
|
18074
|
+
constructor({ applyChecksum, credentials, region, service, sha256: sha2563, uriEscapePath = true }) {
|
|
18075
18075
|
this.service = service;
|
|
18076
|
-
this.sha256 =
|
|
18076
|
+
this.sha256 = sha2563;
|
|
18077
18077
|
this.uriEscapePath = uriEscapePath;
|
|
18078
18078
|
this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true;
|
|
18079
18079
|
this.regionProvider = normalizeProvider2(region);
|
|
@@ -18240,13 +18240,13 @@ ${toHex(hashedRequest)}`;
|
|
|
18240
18240
|
|
|
18241
18241
|
class SignatureV4 extends SignatureV4Base {
|
|
18242
18242
|
headerFormatter = new HeaderFormatter;
|
|
18243
|
-
constructor({ applyChecksum, credentials, region, service, sha256:
|
|
18243
|
+
constructor({ applyChecksum, credentials, region, service, sha256: sha2563, uriEscapePath = true }) {
|
|
18244
18244
|
super({
|
|
18245
18245
|
applyChecksum,
|
|
18246
18246
|
credentials,
|
|
18247
18247
|
region,
|
|
18248
18248
|
service,
|
|
18249
|
-
sha256:
|
|
18249
|
+
sha256: sha2563,
|
|
18250
18250
|
uriEscapePath
|
|
18251
18251
|
});
|
|
18252
18252
|
}
|
|
@@ -24474,7 +24474,7 @@ var require_httpAuthSchemes = __commonJS((exports) => {
|
|
|
24474
24474
|
configurable: true
|
|
24475
24475
|
});
|
|
24476
24476
|
config.credentials = inputCredentials;
|
|
24477
|
-
const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256:
|
|
24477
|
+
const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256: sha2563 } = config;
|
|
24478
24478
|
let signer;
|
|
24479
24479
|
if (config.signer) {
|
|
24480
24480
|
signer = normalizeProvider2(config.signer);
|
|
@@ -24494,7 +24494,7 @@ var require_httpAuthSchemes = __commonJS((exports) => {
|
|
|
24494
24494
|
credentials: config.credentials,
|
|
24495
24495
|
region: config.signingRegion,
|
|
24496
24496
|
service: config.signingName,
|
|
24497
|
-
sha256:
|
|
24497
|
+
sha256: sha2563,
|
|
24498
24498
|
uriEscapePath: signingEscapePath
|
|
24499
24499
|
};
|
|
24500
24500
|
const SignerCtor = config.signerConstructor || SignatureV4;
|
|
@@ -24517,7 +24517,7 @@ var require_httpAuthSchemes = __commonJS((exports) => {
|
|
|
24517
24517
|
credentials: config.credentials,
|
|
24518
24518
|
region: config.signingRegion,
|
|
24519
24519
|
service: config.signingName,
|
|
24520
|
-
sha256:
|
|
24520
|
+
sha256: sha2563,
|
|
24521
24521
|
uriEscapePath: signingEscapePath
|
|
24522
24522
|
};
|
|
24523
24523
|
const SignerCtor = config.signerConstructor || SignatureV4;
|
|
@@ -25679,7 +25679,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25679
25679
|
return this.connectOptions === undefined ? http2.connect(url) : http2.connect(url, this.connectOptions);
|
|
25680
25680
|
}
|
|
25681
25681
|
}
|
|
25682
|
-
var { constants:
|
|
25682
|
+
var { constants: constants16 } = http2;
|
|
25683
25683
|
|
|
25684
25684
|
class NodeHttp2Handler {
|
|
25685
25685
|
config;
|
|
@@ -25770,8 +25770,8 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
25770
25770
|
}
|
|
25771
25771
|
const clientHttp2Stream = session.request({
|
|
25772
25772
|
...request2.headers,
|
|
25773
|
-
[
|
|
25774
|
-
[
|
|
25773
|
+
[constants16.HTTP2_HEADER_PATH]: path,
|
|
25774
|
+
[constants16.HTTP2_HEADER_METHOD]: method
|
|
25775
25775
|
});
|
|
25776
25776
|
if (effectiveRequestTimeout) {
|
|
25777
25777
|
clientHttp2Stream.setTimeout(effectiveRequestTimeout, () => {
|
|
@@ -29443,7 +29443,7 @@ var require_signin = __commonJS((exports) => {
|
|
|
29443
29443
|
});
|
|
29444
29444
|
|
|
29445
29445
|
// node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
|
|
29446
|
-
import { createHash as
|
|
29446
|
+
import { createHash as createHash27, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
29447
29447
|
import { promises as fs2 } from "fs";
|
|
29448
29448
|
import { homedir as homedir7 } from "os";
|
|
29449
29449
|
import { dirname as dirname23, join as join38 } from "path";
|
|
@@ -29615,7 +29615,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
29615
29615
|
getTokenFilePath() {
|
|
29616
29616
|
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join38(homedir7(), ".aws", "login", "cache");
|
|
29617
29617
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
29618
|
-
const loginSessionSha256 =
|
|
29618
|
+
const loginSessionSha256 = createHash27("sha256").update(loginSessionBytes).digest("hex");
|
|
29619
29619
|
return join38(directory, `${loginSessionSha256}.json`);
|
|
29620
29620
|
}
|
|
29621
29621
|
derToRawSignature(derSignature) {
|
|
@@ -30946,7 +30946,7 @@ var fromWebToken = (init) => async (awsIdentityProperties) => {
|
|
|
30946
30946
|
};
|
|
30947
30947
|
|
|
30948
30948
|
// node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
|
|
30949
|
-
import { readFileSync as
|
|
30949
|
+
import { readFileSync as readFileSync25 } from "fs";
|
|
30950
30950
|
var import_client19, import_config32, ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE", ENV_ROLE_ARN = "AWS_ROLE_ARN", ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME", fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
|
30951
30951
|
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
|
30952
30952
|
const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
|
|
@@ -30959,7 +30959,7 @@ var import_client19, import_config32, ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_F
|
|
|
30959
30959
|
}
|
|
30960
30960
|
const credentials = await fromWebToken({
|
|
30961
30961
|
...init,
|
|
30962
|
-
webIdentityToken: import_config32.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
|
|
30962
|
+
webIdentityToken: import_config32.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync25(webIdentityTokenFile, { encoding: "ascii" }),
|
|
30963
30963
|
roleArn,
|
|
30964
30964
|
roleSessionName
|
|
30965
30965
|
})(awsIdentityProperties);
|
|
@@ -32373,7 +32373,7 @@ var init_event_sink = __esm(() => {
|
|
|
32373
32373
|
// package.json
|
|
32374
32374
|
var package_default = {
|
|
32375
32375
|
name: "@hasna/skills",
|
|
32376
|
-
version: "0.10.
|
|
32376
|
+
version: "0.10.49",
|
|
32377
32377
|
description: "Skills library for AI coding agents",
|
|
32378
32378
|
type: "module",
|
|
32379
32379
|
bin: {
|
|
@@ -37554,9 +37554,9 @@ async function reconcileSkillSession(input, options = {}) {
|
|
|
37554
37554
|
return { applied: true, plan, planDigest, ...result };
|
|
37555
37555
|
}
|
|
37556
37556
|
// src/lib/selected-run.ts
|
|
37557
|
-
import { createHash as
|
|
37557
|
+
import { createHash as createHash26 } from "crypto";
|
|
37558
37558
|
import { spawn as spawn2 } from "child_process";
|
|
37559
|
-
import { mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync3, writeFileSync as writeFileSync10, realpathSync as
|
|
37559
|
+
import { mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync3, writeFileSync as writeFileSync10, realpathSync as realpathSync15 } from "fs";
|
|
37560
37560
|
import { dirname as dirname22, join as join37, resolve as resolve21 } from "path";
|
|
37561
37561
|
import { tmpdir, hostname as stationHostname2 } from "os";
|
|
37562
37562
|
|
|
@@ -37768,7 +37768,7 @@ async function prepareSkillDependencies(skillPath, env, timeoutMs = DEFAULT_PREP
|
|
|
37768
37768
|
}
|
|
37769
37769
|
|
|
37770
37770
|
// src/lib/skillinfo.ts
|
|
37771
|
-
import { existsSync as existsSync15, readFileSync as
|
|
37771
|
+
import { existsSync as existsSync15, readFileSync as readFileSync24 } from "fs";
|
|
37772
37772
|
import { join as join36 } from "path";
|
|
37773
37773
|
|
|
37774
37774
|
// src/lib/codex-corpus-write.ts
|
|
@@ -37933,7 +37933,7 @@ function withCodexCorpusWrite(roots, run, options = {}) {
|
|
|
37933
37933
|
}
|
|
37934
37934
|
|
|
37935
37935
|
// src/lib/installer.ts
|
|
37936
|
-
import { existsSync as existsSync14, readFileSync as
|
|
37936
|
+
import { existsSync as existsSync14, readFileSync as readFileSync23, rmSync as rmSync4 } from "fs";
|
|
37937
37937
|
import { join as join35 } from "path";
|
|
37938
37938
|
import { homedir as homedir6 } from "os";
|
|
37939
37939
|
|
|
@@ -37941,10 +37941,10 @@ import { homedir as homedir6 } from "os";
|
|
|
37941
37941
|
import {
|
|
37942
37942
|
cpSync as cpSync2,
|
|
37943
37943
|
existsSync as existsSync11,
|
|
37944
|
-
lstatSync as
|
|
37944
|
+
lstatSync as lstatSync26,
|
|
37945
37945
|
mkdirSync as mkdirSync9,
|
|
37946
37946
|
mkdtempSync as mkdtempSync2,
|
|
37947
|
-
readFileSync as
|
|
37947
|
+
readFileSync as readFileSync20,
|
|
37948
37948
|
readdirSync as readdirSync11,
|
|
37949
37949
|
renameSync as renameSync6,
|
|
37950
37950
|
rmSync as rmSync3,
|
|
@@ -40252,10 +40252,10 @@ var NATIVE_SKILL_ROOTS = [
|
|
|
40252
40252
|
];
|
|
40253
40253
|
|
|
40254
40254
|
// src/lib/agent-integration.ts
|
|
40255
|
-
import { createHash as
|
|
40255
|
+
import { createHash as createHash24, randomUUID as randomUUID4 } from "crypto";
|
|
40256
40256
|
import { isDeepStrictEqual as isDeepStrictEqual8 } from "util";
|
|
40257
|
-
import { existsSync as existsSync7, lstatSync as
|
|
40258
|
-
import { dirname as dirname17, join as join27, resolve as resolve18, relative as relative5, isAbsolute as
|
|
40257
|
+
import { existsSync as existsSync7, lstatSync as lstatSync23, statSync as statSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync17, readdirSync as readdirSync8, opendirSync as opendirSync5, readlinkSync as readlinkSync6, realpathSync as realpathSync11, renameSync as renameSync4, rmdirSync as rmdirSync3, writeFileSync as writeFileSync5, unlinkSync as unlinkSync5, chmodSync, openSync as openSync18, closeSync as closeSync18, fsyncSync as fsyncSync6, fstatSync as fstatSync18, readSync as readSync12, constants as constants15, linkSync as linkSync3 } from "fs";
|
|
40258
|
+
import { dirname as dirname17, join as join27, resolve as resolve18, relative as relative5, isAbsolute as isAbsolute20, sep as sep7 } from "path";
|
|
40259
40259
|
import { homedir as homedir3 } from "os";
|
|
40260
40260
|
|
|
40261
40261
|
// src/lib/managed-policy.ts
|
|
@@ -44188,8 +44188,144 @@ function disableCodexBundledSkills(text2) {
|
|
|
44188
44188
|
return [...candidates][0];
|
|
44189
44189
|
}
|
|
44190
44190
|
|
|
44191
|
+
// src/cli/commands/runtime-launcher.ts
|
|
44192
|
+
import { createHash as createHash23 } from "crypto";
|
|
44193
|
+
import { closeSync as closeSync17, constants as constants14, fchmodSync as fchmodSync2, fstatSync as fstatSync17, fsyncSync as fsyncSync5, lstatSync as lstatSync22, openSync as openSync17, readFileSync as readFileSync16, readlinkSync as readlinkSync5, realpathSync as realpathSync10, symlinkSync, writeSync as writeSync3 } from "fs";
|
|
44194
|
+
import { isAbsolute as isAbsolute19 } from "path";
|
|
44195
|
+
var PINNED_LAUNCHER_SCHEMA = "hasna-skills-pinned-launcher-v1";
|
|
44196
|
+
var LAUNCH_CWD_VARIABLE = "HASNA_SKILLS_LAUNCH_CWD";
|
|
44197
|
+
var PINNED_LAUNCHER_BUN_FLAGS = ["--config=/dev/null", "--no-env-file", "--no-macros", "--no-install"];
|
|
44198
|
+
var PINNED_LAUNCHER_ENV_NAMES = [
|
|
44199
|
+
"HOME",
|
|
44200
|
+
"PATH",
|
|
44201
|
+
"TMPDIR",
|
|
44202
|
+
"TERM",
|
|
44203
|
+
"TERM_PROGRAM",
|
|
44204
|
+
"TERM_PROGRAM_VERSION",
|
|
44205
|
+
"COLORTERM",
|
|
44206
|
+
"LANG",
|
|
44207
|
+
"USER",
|
|
44208
|
+
"LOGNAME",
|
|
44209
|
+
"SHELL",
|
|
44210
|
+
"TZ",
|
|
44211
|
+
"NO_COLOR",
|
|
44212
|
+
"FORCE_COLOR",
|
|
44213
|
+
"CI",
|
|
44214
|
+
"COLUMNS",
|
|
44215
|
+
"LINES",
|
|
44216
|
+
"EDITOR",
|
|
44217
|
+
"VISUAL",
|
|
44218
|
+
"PAGER",
|
|
44219
|
+
"SSH_AUTH_SOCK",
|
|
44220
|
+
"DATABASE_URL",
|
|
44221
|
+
"TERMINAL_CWD",
|
|
44222
|
+
"CODEX_HOME",
|
|
44223
|
+
"HERMES_HOME",
|
|
44224
|
+
"HERMES_ENABLE_PROJECT_PLUGINS",
|
|
44225
|
+
"HOST",
|
|
44226
|
+
"PORT",
|
|
44227
|
+
"NODE_ENV",
|
|
44228
|
+
"AGENT_ID",
|
|
44229
|
+
"ECS_CONTAINER_METADATA_URI_V4"
|
|
44230
|
+
];
|
|
44231
|
+
var PINNED_LAUNCHER_ENV_PREFIXES = ["HASNA", "SKILLS", "SKILL", "MCP", "XDG", "LC", "AWS"];
|
|
44232
|
+
var ENV_PREFIX = new RegExp(`^(${PINNED_LAUNCHER_ENV_PREFIXES.join("|")})_`);
|
|
44233
|
+
var ENV_EXACT = new Set(PINNED_LAUNCHER_ENV_NAMES);
|
|
44234
|
+
function sha2562(bytes) {
|
|
44235
|
+
return createHash23("sha256").update(bytes).digest("hex");
|
|
44236
|
+
}
|
|
44237
|
+
function assertLauncherPath(value, code) {
|
|
44238
|
+
if (typeof value !== "string" || !isAbsolute19(value) || /['\x00-\x1f\x7f]/.test(value))
|
|
44239
|
+
throw new Error(code);
|
|
44240
|
+
}
|
|
44241
|
+
function renderPinnedLauncher(binding) {
|
|
44242
|
+
assertLauncherPath(binding.runtime, "LAUNCHER_RUNTIME_PATH_INVALID");
|
|
44243
|
+
assertLauncherPath(binding.cwd, "LAUNCHER_CWD_PATH_INVALID");
|
|
44244
|
+
assertLauncherPath(binding.entry, "LAUNCHER_ENTRY_PATH_INVALID");
|
|
44245
|
+
const names = PINNED_LAUNCHER_ENV_NAMES.join(" ");
|
|
44246
|
+
const prefixes = PINNED_LAUNCHER_ENV_PREFIXES.join("|");
|
|
44247
|
+
return [
|
|
44248
|
+
"#!/bin/sh -p",
|
|
44249
|
+
`# ${PINNED_LAUNCHER_SCHEMA}`,
|
|
44250
|
+
"# Written by `skills self-update`; rewrite it with `skills self-update`, do not edit by hand.",
|
|
44251
|
+
"# Runs the exact Skills entry below under one exact Bun from one trusted directory with",
|
|
44252
|
+
"# no working-directory configuration (no bunfig.toml, no .env, no macros, no auto-install)",
|
|
44253
|
+
"# and only the environment names allowed here. Everything else, BUN_* and NODE_OPTIONS",
|
|
44254
|
+
"# included, never reaches the runtime. The CLI returns to the caller's directory itself.",
|
|
44255
|
+
"# `-p` keeps the caller's exported functions and shell options out of this shell.",
|
|
44256
|
+
"set -eu",
|
|
44257
|
+
`${LAUNCH_CWD_VARIABLE}=$(pwd -P 2>/dev/null || :)`,
|
|
44258
|
+
`export ${LAUNCH_CWD_VARIABLE}`,
|
|
44259
|
+
`set -- '${binding.runtime}' ${PINNED_LAUNCHER_BUN_FLAGS.join(" ")} '--cwd=${binding.cwd}' '${binding.entry}' "$@"`,
|
|
44260
|
+
"hasna_skills_env=$(LC_ALL=C /usr/bin/awk 'BEGIN {",
|
|
44261
|
+
` n = split("${names}", exact, " ")`,
|
|
44262
|
+
" for (i = 1; i <= n; i++) allow[exact[i]] = 1",
|
|
44263
|
+
" for (name in ENVIRON) {",
|
|
44264
|
+
" if (name !~ /^[A-Za-z_][A-Za-z0-9_]*$/) continue",
|
|
44265
|
+
` if (name == "LC_ALL" || (!(name in allow) && name !~ /^(${prefixes})_/)) continue`,
|
|
44266
|
+
' value = ENVIRON[name]; quoted = ""',
|
|
44267
|
+
' while ((k = index(value, "\\047")) > 0) { quoted = quoted substr(value, 1, k - 1) "\\047\\\\\\047\\047"; value = substr(value, k + 1) }',
|
|
44268
|
+
' printf "\\047%s=%s\\047 ", name, quoted value',
|
|
44269
|
+
" }",
|
|
44270
|
+
"}')",
|
|
44271
|
+
'eval "set -- $hasna_skills_env \\"\\$@\\""',
|
|
44272
|
+
'if [ "${LC_ALL+x}" = x ]; then set -- "LC_ALL=$LC_ALL" "$@"; fi',
|
|
44273
|
+
'exec /usr/bin/env -i "$@"',
|
|
44274
|
+
""
|
|
44275
|
+
].join(`
|
|
44276
|
+
`);
|
|
44277
|
+
}
|
|
44278
|
+
var COMMAND_LINE = new RegExp(`^set -- '([^']+)' ${PINNED_LAUNCHER_BUN_FLAGS.join(" ")} '--cwd=([^']+)' '([^']+)' "\\$@"$`, "m");
|
|
44279
|
+
function parsePinnedLauncher(text2) {
|
|
44280
|
+
const match = COMMAND_LINE.exec(text2);
|
|
44281
|
+
if (!match)
|
|
44282
|
+
return null;
|
|
44283
|
+
const binding = { runtime: match[1], cwd: match[2], entry: match[3] };
|
|
44284
|
+
try {
|
|
44285
|
+
if (renderPinnedLauncher(binding) !== text2)
|
|
44286
|
+
return null;
|
|
44287
|
+
} catch {
|
|
44288
|
+
return null;
|
|
44289
|
+
}
|
|
44290
|
+
return binding;
|
|
44291
|
+
}
|
|
44292
|
+
var PINNED_LAUNCHER_MAX_BYTES = 16 * 1024;
|
|
44293
|
+
function resolveLauncherCommand(path) {
|
|
44294
|
+
const physical = realpathSync10(path);
|
|
44295
|
+
const stat2 = lstatSync22(physical);
|
|
44296
|
+
if (stat2.isFile() && stat2.size <= PINNED_LAUNCHER_MAX_BYTES) {
|
|
44297
|
+
const text2 = readFileSync16(physical, "utf8");
|
|
44298
|
+
const binding = parsePinnedLauncher(text2);
|
|
44299
|
+
if (binding) {
|
|
44300
|
+
let entry;
|
|
44301
|
+
try {
|
|
44302
|
+
entry = realpathSync10(binding.entry);
|
|
44303
|
+
} catch {
|
|
44304
|
+
throw new Error("LAUNCHER_ENTRY_UNREADABLE");
|
|
44305
|
+
}
|
|
44306
|
+
if (entry !== binding.entry)
|
|
44307
|
+
throw new Error("LAUNCHER_ENTRY_NOT_PHYSICAL");
|
|
44308
|
+
return { physical, entry, pinned: { ...binding, sha256: sha2562(text2) } };
|
|
44309
|
+
}
|
|
44310
|
+
}
|
|
44311
|
+
return { physical, entry: physical, pinned: null };
|
|
44312
|
+
}
|
|
44313
|
+
function assertPinnedLauncherRuntimeSafe(runtime) {
|
|
44314
|
+
assertLauncherPath(runtime, "LAUNCHER_RUNTIME_PATH_INVALID");
|
|
44315
|
+
let stat2;
|
|
44316
|
+
try {
|
|
44317
|
+
stat2 = lstatSync22(runtime);
|
|
44318
|
+
} catch {
|
|
44319
|
+
throw new Error("LAUNCHER_RUNTIME_UNSAFE");
|
|
44320
|
+
}
|
|
44321
|
+
const uid2 = process.getuid?.() ?? -1;
|
|
44322
|
+
if (!stat2.isFile() || stat2.isSymbolicLink() || ![0, uid2].includes(stat2.uid) || (stat2.mode & 18) !== 0 || (stat2.mode & 64) === 0) {
|
|
44323
|
+
throw new Error("LAUNCHER_RUNTIME_UNSAFE");
|
|
44324
|
+
}
|
|
44325
|
+
}
|
|
44326
|
+
|
|
44191
44327
|
// src/lib/agent-integration.ts
|
|
44192
|
-
var sha4 = (data) =>
|
|
44328
|
+
var sha4 = (data) => createHash24("sha256").update(data).digest("hex");
|
|
44193
44329
|
var ROOTS = NATIVE_SKILL_ROOTS;
|
|
44194
44330
|
function hasTrustedDarwinAcl(fd, allowDenyOnly = false) {
|
|
44195
44331
|
try {
|
|
@@ -44240,11 +44376,11 @@ function isSystemRootAlias(path) {
|
|
|
44240
44376
|
const target = `/private${path}`, link = `private${path}`;
|
|
44241
44377
|
const identity5 = (stat2) => `${stat2.dev}:${stat2.ino}:${stat2.ctimeNs}:${stat2.uid}:${stat2.mode}`;
|
|
44242
44378
|
try {
|
|
44243
|
-
const before =
|
|
44244
|
-
if (!before.isSymbolicLink() || before.uid !== 0n ||
|
|
44379
|
+
const before = lstatSync23(path, { bigint: true });
|
|
44380
|
+
if (!before.isSymbolicLink() || before.uid !== 0n || readlinkSync6(path) !== link)
|
|
44245
44381
|
return false;
|
|
44246
44382
|
const directories = ["/", "/private", target].map((directory) => {
|
|
44247
|
-
const stat2 =
|
|
44383
|
+
const stat2 = lstatSync23(directory, { bigint: true });
|
|
44248
44384
|
if (!stat2.isDirectory() || stat2.uid !== 0n)
|
|
44249
44385
|
throw new Error("Untrusted system alias directory");
|
|
44250
44386
|
if (directory !== "/private/tmp") {
|
|
@@ -44252,23 +44388,23 @@ function isSystemRootAlias(path) {
|
|
|
44252
44388
|
throw new Error("Writable system alias directory");
|
|
44253
44389
|
} else if ((stat2.mode & 0o1000n) === 0n)
|
|
44254
44390
|
throw new Error("Unprotected system temporary directory");
|
|
44255
|
-
const fd =
|
|
44391
|
+
const fd = openSync18(directory, constants15.O_RDONLY | constants15.O_DIRECTORY | constants15.O_NOFOLLOW);
|
|
44256
44392
|
try {
|
|
44257
|
-
if (identity5(
|
|
44393
|
+
if (identity5(fstatSync18(fd, { bigint: true })) !== identity5(stat2) || !hasTrustedDarwinAcl(fd) || identity5(fstatSync18(fd, { bigint: true })) !== identity5(stat2))
|
|
44258
44394
|
throw new Error("Unverified system alias directory ACL");
|
|
44259
44395
|
} finally {
|
|
44260
|
-
|
|
44396
|
+
closeSync18(fd);
|
|
44261
44397
|
}
|
|
44262
44398
|
return { directory, identity: identity5(stat2) };
|
|
44263
44399
|
});
|
|
44264
|
-
return
|
|
44400
|
+
return realpathSync11(path) === target && readlinkSync6(path) === link && identity5(lstatSync23(path, { bigint: true })) === identity5(before) && directories.every((item) => identity5(lstatSync23(item.directory, { bigint: true })) === item.identity);
|
|
44265
44401
|
} catch {
|
|
44266
44402
|
return false;
|
|
44267
44403
|
}
|
|
44268
44404
|
}
|
|
44269
44405
|
function canonicalSystemPath(path) {
|
|
44270
44406
|
const absolute = resolve18(path), root2 = `/${absolute.split(sep7)[1]}`;
|
|
44271
|
-
if (process.platform !== "darwin" || !["/var", "/tmp", "/etc"].includes(root2) || !
|
|
44407
|
+
if (process.platform !== "darwin" || !["/var", "/tmp", "/etc"].includes(root2) || !lstatSync23(root2, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
44272
44408
|
return absolute;
|
|
44273
44409
|
if (!isSystemRootAlias(root2))
|
|
44274
44410
|
throw new Error(`Refusing symlink path: ${root2}`);
|
|
@@ -44277,7 +44413,7 @@ function canonicalSystemPath(path) {
|
|
|
44277
44413
|
function assertSafePath(path) {
|
|
44278
44414
|
let cursor = resolve18(path);
|
|
44279
44415
|
while (true) {
|
|
44280
|
-
if (
|
|
44416
|
+
if (lstatSync23(cursor, { throwIfNoEntry: false })?.isSymbolicLink() && !isSystemRootAlias(cursor))
|
|
44281
44417
|
throw new Error(`Refusing symlink path: ${cursor}`);
|
|
44282
44418
|
const parent = dirname17(cursor);
|
|
44283
44419
|
if (parent === cursor)
|
|
@@ -44287,17 +44423,17 @@ function assertSafePath(path) {
|
|
|
44287
44423
|
}
|
|
44288
44424
|
function readRootAlias(home, agent) {
|
|
44289
44425
|
assertSafePath(home);
|
|
44290
|
-
const realHome =
|
|
44291
|
-
const stat2 =
|
|
44426
|
+
const realHome = realpathSync11(home), alias = join27(realHome, `.${agent}`);
|
|
44427
|
+
const stat2 = lstatSync23(alias, { throwIfNoEntry: false, bigint: true });
|
|
44292
44428
|
if (!stat2?.isSymbolicLink())
|
|
44293
44429
|
throw new Error(`Agent root alias changed after planning: ${alias}`);
|
|
44294
|
-
const link =
|
|
44430
|
+
const link = readlinkSync6(alias), targetPath = resolve18(dirname17(alias), link);
|
|
44295
44431
|
assertSafePath(targetPath);
|
|
44296
|
-
const targetStat =
|
|
44432
|
+
const targetStat = lstatSync23(targetPath, { throwIfNoEntry: false });
|
|
44297
44433
|
if (!targetStat?.isDirectory())
|
|
44298
44434
|
throw new Error(`Agent root alias must target an existing directory: ${alias}`);
|
|
44299
|
-
const target =
|
|
44300
|
-
if (!inside || inside === ".." || inside.startsWith(`..${sep7}`) ||
|
|
44435
|
+
const target = realpathSync11(targetPath), inside = relative5(realHome, target);
|
|
44436
|
+
if (!inside || inside === ".." || inside.startsWith(`..${sep7}`) || isAbsolute20(inside))
|
|
44301
44437
|
throw new Error(`Agent root alias target must be inside the real home: ${alias}`);
|
|
44302
44438
|
return { agent, home: realHome, alias, target, link, aliasIdentity: `${stat2.dev}:${stat2.ino}:${stat2.ctimeNs}`, targetIdentity: `${targetStat.dev}:${targetStat.ino}` };
|
|
44303
44439
|
}
|
|
@@ -44306,7 +44442,7 @@ function rootAliases(home, allowed = false) {
|
|
|
44306
44442
|
return [];
|
|
44307
44443
|
const result = [];
|
|
44308
44444
|
for (const agent of ["claude", "codex"])
|
|
44309
|
-
if (
|
|
44445
|
+
if (lstatSync23(join27(home, `.${agent}`), { throwIfNoEntry: false })?.isSymbolicLink())
|
|
44310
44446
|
result.push(readRootAlias(home, agent));
|
|
44311
44447
|
if (result.some((item, index) => result.slice(index + 1).some((other) => item.target === other.target || item.target.startsWith(other.target + sep7) || other.target.startsWith(item.target + sep7))))
|
|
44312
44448
|
throw new Error("Agent root alias targets must not overlap");
|
|
@@ -44323,17 +44459,17 @@ function disabledCodexSkillPaths(config, aliases) {
|
|
|
44323
44459
|
const rows = skills.config;
|
|
44324
44460
|
if (!Array.isArray(rows))
|
|
44325
44461
|
return [];
|
|
44326
|
-
if (rows.some((entry) => !entry || typeof entry !== "object" || Array.isArray(entry) || typeof entry.enabled !== "boolean" || entry.path !== undefined === (entry.name !== undefined) || entry.path !== undefined && (typeof entry.path !== "string" || !
|
|
44462
|
+
if (rows.some((entry) => !entry || typeof entry !== "object" || Array.isArray(entry) || typeof entry.enabled !== "boolean" || entry.path !== undefined === (entry.name !== undefined) || entry.path !== undefined && (typeof entry.path !== "string" || !isAbsolute20(entry.path)) || entry.name !== undefined && (typeof entry.name !== "string" || !entry.name.trim())))
|
|
44327
44463
|
return [];
|
|
44328
44464
|
if (rows.some((entry) => entry.name !== undefined && entry.enabled !== false))
|
|
44329
44465
|
return [];
|
|
44330
44466
|
const settings = new Map;
|
|
44331
44467
|
for (const entry of rows) {
|
|
44332
|
-
if (typeof entry.path !== "string" || !
|
|
44468
|
+
if (typeof entry.path !== "string" || !isAbsolute20(entry.path))
|
|
44333
44469
|
continue;
|
|
44334
44470
|
let document2;
|
|
44335
44471
|
try {
|
|
44336
|
-
document2 =
|
|
44472
|
+
document2 = realpathSync11(canonicalAgentPath(entry.path, aliases));
|
|
44337
44473
|
} catch {
|
|
44338
44474
|
continue;
|
|
44339
44475
|
}
|
|
@@ -44354,16 +44490,16 @@ function recheckRootAliases(aliases) {
|
|
|
44354
44490
|
}
|
|
44355
44491
|
function nativeSourceDigest(path) {
|
|
44356
44492
|
assertSafePath(path);
|
|
44357
|
-
return
|
|
44493
|
+
return lstatSync23(path, { throwIfNoEntry: false }) ? sha4(readNativeBytes(path, 1024 * 1024)) : null;
|
|
44358
44494
|
}
|
|
44359
44495
|
function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
|
|
44360
44496
|
assertSafePath(path);
|
|
44361
|
-
const before =
|
|
44497
|
+
const before = lstatSync23(path);
|
|
44362
44498
|
if (!before.isFile() || before.size > maximum)
|
|
44363
44499
|
throw new Error("Unsupported or oversized native skill file");
|
|
44364
|
-
const descriptor =
|
|
44500
|
+
const descriptor = openSync18(path, constants15.O_RDONLY | constants15.O_NOFOLLOW | constants15.O_NONBLOCK);
|
|
44365
44501
|
try {
|
|
44366
|
-
const opened =
|
|
44502
|
+
const opened = fstatSync18(descriptor);
|
|
44367
44503
|
if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino || opened.size !== before.size)
|
|
44368
44504
|
throw new Error("Native skill file changed while reading");
|
|
44369
44505
|
const bytes = Buffer.allocUnsafe(before.size + 1);
|
|
@@ -44374,19 +44510,19 @@ function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
|
|
|
44374
44510
|
break;
|
|
44375
44511
|
length += count;
|
|
44376
44512
|
}
|
|
44377
|
-
const after =
|
|
44513
|
+
const after = fstatSync18(descriptor), current = lstatSync23(path);
|
|
44378
44514
|
if (current.dev !== opened.dev || current.ino !== opened.ino || current.size !== after.size || current.mtimeMs !== after.mtimeMs || current.ctimeMs !== after.ctimeMs || length !== before.size || after.size !== before.size || after.mtimeMs !== opened.mtimeMs || after.ctimeMs !== opened.ctimeMs)
|
|
44379
44515
|
throw new Error("Native skill file changed while reading");
|
|
44380
44516
|
return bytes.subarray(0, length);
|
|
44381
44517
|
} finally {
|
|
44382
|
-
|
|
44518
|
+
closeSync18(descriptor);
|
|
44383
44519
|
}
|
|
44384
44520
|
}
|
|
44385
44521
|
function treeHash(root2) {
|
|
44386
|
-
const hash2 =
|
|
44522
|
+
const hash2 = createHash24("sha256");
|
|
44387
44523
|
let bytes = 0, files = 0;
|
|
44388
44524
|
function visit2(path) {
|
|
44389
|
-
const stat2 =
|
|
44525
|
+
const stat2 = lstatSync23(path);
|
|
44390
44526
|
if (stat2.isSymbolicLink())
|
|
44391
44527
|
throw new Error(`Refusing symlink in skill: ${path}`);
|
|
44392
44528
|
const rel = relative5(root2, path);
|
|
@@ -44415,13 +44551,13 @@ function selectNativeMigrationTargets(inventory, manifest) {
|
|
|
44415
44551
|
const identities = new Set;
|
|
44416
44552
|
const selected = [];
|
|
44417
44553
|
for (const target of manifest.targets) {
|
|
44418
|
-
if (!
|
|
44554
|
+
if (!isAbsolute20(target.projectRoot) || resolve18(target.projectRoot) !== target.projectRoot)
|
|
44419
44555
|
throw new Error(`Native migration target project root must be an existing absolute directory: ${target.projectRoot}`);
|
|
44420
44556
|
const projectRoot = canonicalSystemPath(target.projectRoot), normalized = relative5(projectRoot, resolve18(projectRoot, target.path));
|
|
44421
|
-
if (!existsSync7(projectRoot) || !
|
|
44557
|
+
if (!existsSync7(projectRoot) || !lstatSync23(projectRoot).isDirectory())
|
|
44422
44558
|
throw new Error(`Native migration target project root must be an existing absolute directory: ${target.projectRoot}`);
|
|
44423
44559
|
assertSafePath(projectRoot);
|
|
44424
|
-
if (
|
|
44560
|
+
if (isAbsolute20(target.path) || target.path.includes("\\") || target.path.includes("\x00") || !normalized || normalized === ".." || normalized.startsWith(`..${sep7}`) || normalized !== target.path || !/^[0-9a-f]{64}$/.test(target.treeSha256))
|
|
44425
44561
|
throw new Error(`Invalid native migration target: ${target.path}`);
|
|
44426
44562
|
const identity5 = `${target.agent}\x00${canonicalSystemPath(projectRoot)}\x00${normalized}`;
|
|
44427
44563
|
if (identities.has(identity5))
|
|
@@ -44464,9 +44600,9 @@ function isCodexSkillDiscoveryInput(path) {
|
|
|
44464
44600
|
}
|
|
44465
44601
|
function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
44466
44602
|
home = canonicalSystemPath(home);
|
|
44467
|
-
if (options.reviewedCacheAlias !== undefined && (!options.includeVendor || !
|
|
44603
|
+
if (options.reviewedCacheAlias !== undefined && (!options.includeVendor || !isAbsolute20(options.reviewedCacheAlias) || resolve18(options.reviewedCacheAlias) !== options.reviewedCacheAlias))
|
|
44468
44604
|
throw new Error("A reviewed cache alias requires vendor inventory and an exact absolute path");
|
|
44469
|
-
if (options.disabledVendorPaths?.some((path) => !
|
|
44605
|
+
if (options.disabledVendorPaths?.some((path) => !isAbsolute20(path) || resolve18(path) !== path))
|
|
44470
44606
|
throw new Error("Disabled vendor paths must be exact absolute paths");
|
|
44471
44607
|
const reviewedCacheAlias = options.reviewedCacheAlias === undefined ? undefined : canonicalSystemPath(options.reviewedCacheAlias);
|
|
44472
44608
|
const disabledVendorPaths = new Set((options.disabledVendorPaths ?? []).map(canonicalSystemPath));
|
|
@@ -44485,7 +44621,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
44485
44621
|
roots.push(["sumi", canonicalAgentPath(join27(project, directory, name), aliases)]);
|
|
44486
44622
|
}
|
|
44487
44623
|
const installationInputs = options.codexInstallationInputRoots ?? [];
|
|
44488
|
-
if (installationInputs.some((input) => resolve18(input) !== input ||
|
|
44624
|
+
if (installationInputs.some((input) => resolve18(input) !== input || realpathSync11(input) !== input || roots.some(([agent, path]) => agent === "codex" && (path === input || path.startsWith(input + sep7) || input.startsWith(path + sep7)))))
|
|
44489
44625
|
throw new Error("Native installation input overlaps an unconditional skill-loading root");
|
|
44490
44626
|
const entries = [], seen = new Set;
|
|
44491
44627
|
const cacheScans = new Map, maxAliasProofEntries = 1e4;
|
|
@@ -44499,13 +44635,13 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
44499
44635
|
}
|
|
44500
44636
|
let reviewedCacheAliasFound = false;
|
|
44501
44637
|
function verifiedSiblingCacheAlias(agent, path, parent) {
|
|
44502
|
-
const link =
|
|
44503
|
-
if (
|
|
44638
|
+
const link = readlinkSync6(path), lexicalTarget = resolve18(parent, link);
|
|
44639
|
+
if (isAbsolute20(link) ? link !== lexicalTarget : dirname17(link) !== ".")
|
|
44504
44640
|
return false;
|
|
44505
44641
|
const target = canonicalSystemPath(lexicalTarget);
|
|
44506
44642
|
if (dirname17(target) !== parent)
|
|
44507
44643
|
return false;
|
|
44508
|
-
if (!
|
|
44644
|
+
if (!lstatSync23(target, { throwIfNoEntry: false })?.isDirectory())
|
|
44509
44645
|
return false;
|
|
44510
44646
|
const scan = cacheScans.get(target);
|
|
44511
44647
|
if (!scan?.complete || scan.entries > maxAliasProofEntries)
|
|
@@ -44530,7 +44666,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
44530
44666
|
return scan;
|
|
44531
44667
|
if (!existsSync7(path))
|
|
44532
44668
|
return scan;
|
|
44533
|
-
const stat2 =
|
|
44669
|
+
const stat2 = lstatSync23(path);
|
|
44534
44670
|
if (stat2.isFile()) {
|
|
44535
44671
|
if (agent === "sumi" && depth === 1 && path.endsWith(".md"))
|
|
44536
44672
|
throw new Error("NATIVE_SKILL_DRIFT: flat Sumi skill documents require a dedicated migration adapter");
|
|
@@ -44547,7 +44683,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
44547
44683
|
const marker = join27(path, ".hasna-skills.json");
|
|
44548
44684
|
if (existsSync7(marker)) {
|
|
44549
44685
|
try {
|
|
44550
|
-
managed = JSON.parse(
|
|
44686
|
+
managed = JSON.parse(readFileSync17(marker, "utf8")).managedBy === "@hasna/skills";
|
|
44551
44687
|
} catch {}
|
|
44552
44688
|
}
|
|
44553
44689
|
const bridge = (!vendor || agent === "sumi") && isOwnedCliBridge(path, bridgePaths);
|
|
@@ -44579,7 +44715,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
44579
44715
|
if (isVendor && !options.includeVendor)
|
|
44580
44716
|
continue;
|
|
44581
44717
|
const child = join27(path, name);
|
|
44582
|
-
if (isVendor &&
|
|
44718
|
+
if (isVendor && lstatSync23(child, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
44583
44719
|
const target = statSync7(child, { throwIfNoEntry: false });
|
|
44584
44720
|
if (target?.isFile() || pluginCache && target?.isDirectory() && verifiedSiblingCacheAlias(agent, child, path)) {
|
|
44585
44721
|
scan.entries++;
|
|
@@ -44622,7 +44758,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
|
|
|
44622
44758
|
}
|
|
44623
44759
|
function readOptional(path) {
|
|
44624
44760
|
assertSafePath(path);
|
|
44625
|
-
return existsSync7(path) ?
|
|
44761
|
+
return existsSync7(path) ? readFileSync17(path, "utf8") : null;
|
|
44626
44762
|
}
|
|
44627
44763
|
function jsonObject(text2, path) {
|
|
44628
44764
|
if (text2 === null)
|
|
@@ -44954,23 +45090,23 @@ function projectedHookAcl(path, observed) {
|
|
|
44954
45090
|
if (process.platform !== "darwin")
|
|
44955
45091
|
return;
|
|
44956
45092
|
const identity5 = (stat2) => `${stat2.dev}:${stat2.ino}:${stat2.ctimeNs}:${stat2.uid}:${stat2.mode}:${stat2.nlink}:${stat2.size}:${stat2.mtimeNs}`;
|
|
44957
|
-
const fd =
|
|
45093
|
+
const fd = openSync18(path, constants15.O_RDONLY | constants15.O_NOFOLLOW | constants15.O_NONBLOCK | (observed.isDirectory() ? constants15.O_DIRECTORY : 0));
|
|
44958
45094
|
try {
|
|
44959
|
-
if (identity5(
|
|
45095
|
+
if (identity5(fstatSync18(fd, { bigint: true })) !== identity5(observed) || !hasTrustedDarwinAcl(fd, true) || identity5(fstatSync18(fd, { bigint: true })) !== identity5(observed) || identity5(lstatSync23(path, { bigint: true })) !== identity5(observed))
|
|
44960
45096
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
44961
45097
|
} finally {
|
|
44962
|
-
|
|
45098
|
+
closeSync18(fd);
|
|
44963
45099
|
}
|
|
44964
45100
|
}
|
|
44965
45101
|
function projectedHookExecutable(command, expectedResolved) {
|
|
44966
45102
|
try {
|
|
44967
|
-
if (!
|
|
45103
|
+
if (!isAbsolute20(command) || /[\0\r\n]/.test(command) || resolve18(command) !== command)
|
|
44968
45104
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
44969
45105
|
command = canonicalSystemPath(command);
|
|
44970
45106
|
const parents3 = (file = command) => {
|
|
44971
45107
|
const result = [];
|
|
44972
45108
|
for (let path = dirname17(file);; path = dirname17(path)) {
|
|
44973
|
-
const stat2 =
|
|
45109
|
+
const stat2 = lstatSync23(path, { bigint: true });
|
|
44974
45110
|
if (!stat2.isDirectory() || (stat2.mode & 0o022n) !== 0n && !(stat2.uid === 0n && (stat2.mode & 0o1000n) !== 0n))
|
|
44975
45111
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
44976
45112
|
projectedHookAcl(path, stat2);
|
|
@@ -44980,13 +45116,22 @@ function projectedHookExecutable(command, expectedResolved) {
|
|
|
44980
45116
|
}
|
|
44981
45117
|
return result;
|
|
44982
45118
|
};
|
|
44983
|
-
const parentIdentity = parents3(), link =
|
|
45119
|
+
const parentIdentity = parents3(), link = lstatSync23(command, { bigint: true });
|
|
44984
45120
|
if (link.uid !== BigInt(process.getuid()) || !link.isFile() && !link.isSymbolicLink())
|
|
44985
45121
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
44986
45122
|
const linkIdentity = (stat2) => `${stat2.dev}:${stat2.ino}:${stat2.mode}:${stat2.uid}:${stat2.ctimeNs}`;
|
|
44987
|
-
const
|
|
45123
|
+
const target = resolveLauncherCommand(command), resolved = target.entry;
|
|
44988
45124
|
if (expectedResolved !== undefined && resolved !== expectedResolved)
|
|
44989
45125
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
45126
|
+
let launcher, launcherParentIdentity;
|
|
45127
|
+
if (target.pinned) {
|
|
45128
|
+
launcherParentIdentity = parents3(target.physical);
|
|
45129
|
+
launcher = snapshot(target.physical, false);
|
|
45130
|
+
projectedHookAcl(launcher.file, launcher.stat);
|
|
45131
|
+
if (launcher.sha256 !== target.pinned.sha256 || (launcher.stat.mode & 0o100n) === 0n)
|
|
45132
|
+
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
45133
|
+
assertPinnedLauncherRuntimeSafe(target.pinned.runtime);
|
|
45134
|
+
}
|
|
44990
45135
|
const resolvedParentIdentity = parents3(resolved);
|
|
44991
45136
|
const manifest = snapshot(join27(dirname17(dirname17(resolved)), "package.json"), false, { readOnlyPackage: true });
|
|
44992
45137
|
projectedHookAcl(manifest.file, manifest.stat);
|
|
@@ -44999,8 +45144,15 @@ function projectedHookExecutable(command, expectedResolved) {
|
|
|
44999
45144
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
45000
45145
|
const recheck = () => {
|
|
45001
45146
|
try {
|
|
45002
|
-
|
|
45147
|
+
const again = resolveLauncherCommand(command);
|
|
45148
|
+
if (again.entry !== resolved || again.physical !== target.physical || linkIdentity(lstatSync23(command, { bigint: true })) !== linkIdentity(link) || !isDeepStrictEqual8(parents3(), parentIdentity) || !isDeepStrictEqual8(parents3(resolved), resolvedParentIdentity))
|
|
45003
45149
|
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
45150
|
+
if (launcher) {
|
|
45151
|
+
if (!isDeepStrictEqual8(parents3(target.physical), launcherParentIdentity))
|
|
45152
|
+
hookProjectionRefusal("EXECUTABLE_UNVERIFIED");
|
|
45153
|
+
projectedHookAcl(launcher.file, launcher.stat);
|
|
45154
|
+
unchanged2(launcher);
|
|
45155
|
+
}
|
|
45004
45156
|
projectedHookAcl(cli.file, cli.stat);
|
|
45005
45157
|
projectedHookAcl(manifest.file, manifest.stat);
|
|
45006
45158
|
unchanged2(cli);
|
|
@@ -45122,7 +45274,7 @@ function claudeSettingsConsumers(home, path, discoveries, aliases) {
|
|
|
45122
45274
|
const canonical7 = (value) => canonicalAgentPath(value, aliases);
|
|
45123
45275
|
const containsSettings = (root2) => {
|
|
45124
45276
|
const distance = relative5(canonical7(root2), path);
|
|
45125
|
-
return distance === "" || distance !== ".." && !distance.startsWith(`..${sep7}`) && !
|
|
45277
|
+
return distance === "" || distance !== ".." && !distance.startsWith(`..${sep7}`) && !isAbsolute20(distance);
|
|
45126
45278
|
};
|
|
45127
45279
|
return discoveries.filter((binding) => binding.agent === "claude" || binding.agent === "opencode" || canonical7(join27(home, AGENT_ADAPTERS[binding.agent].config)) === path || binding.sources.some((source) => canonical7(source.path) === path) || binding.roots.some(containsSettings) || binding.directories?.some((directory) => containsSettings(directory.path))).map((binding) => binding.agent);
|
|
45128
45280
|
}
|
|
@@ -45155,7 +45307,7 @@ function planClaudeHookEventsUpdate(options) {
|
|
|
45155
45307
|
recheckRootAliases(aliases);
|
|
45156
45308
|
const path = canonicalAgentPath(join27(home, ".claude", "settings.json"), aliases);
|
|
45157
45309
|
assertSafePath(path);
|
|
45158
|
-
const before =
|
|
45310
|
+
const before = lstatSync23(path, { throwIfNoEntry: false }) ? new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readNativeBytes(path, 1024 * 1024)) : null;
|
|
45159
45311
|
if ((before === null ? "absent" : sha4(before)) !== options.expectedSettingsSha256)
|
|
45160
45312
|
throw new Error("Claude settings preimage changed");
|
|
45161
45313
|
assertClaudeHookEventsReplacement(before, options.replacement, options.events);
|
|
@@ -45346,7 +45498,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
|
|
|
45346
45498
|
if (change.before !== null) {
|
|
45347
45499
|
const backup = join27(backupRoot, `${index}-${sha4(change.path).slice(0, 12)}.backup`);
|
|
45348
45500
|
writeFileSync5(backup, change.before, { mode: 384, flag: "wx" });
|
|
45349
|
-
if (
|
|
45501
|
+
if (readFileSync17(backup, "utf8") !== change.before)
|
|
45350
45502
|
throw new Error("Native configuration preservation readback failed");
|
|
45351
45503
|
backups.push(backup);
|
|
45352
45504
|
}
|
|
@@ -45409,11 +45561,11 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
|
|
|
45409
45561
|
}
|
|
45410
45562
|
function syncArchiveDirectory(path) {
|
|
45411
45563
|
assertSafePath(path);
|
|
45412
|
-
const descriptor =
|
|
45564
|
+
const descriptor = openSync18(path, constants15.O_RDONLY | constants15.O_DIRECTORY | constants15.O_NOFOLLOW | constants15.O_NONBLOCK);
|
|
45413
45565
|
try {
|
|
45414
|
-
|
|
45566
|
+
fsyncSync6(descriptor);
|
|
45415
45567
|
} finally {
|
|
45416
|
-
|
|
45568
|
+
closeSync18(descriptor);
|
|
45417
45569
|
}
|
|
45418
45570
|
}
|
|
45419
45571
|
function writeArchiveJournal(path, value) {
|
|
@@ -45421,18 +45573,18 @@ function writeArchiveJournal(path, value) {
|
|
|
45421
45573
|
const temporary = `${path}.skills-${randomUUID4()}`;
|
|
45422
45574
|
let descriptor;
|
|
45423
45575
|
try {
|
|
45424
|
-
descriptor =
|
|
45576
|
+
descriptor = openSync18(temporary, constants15.O_WRONLY | constants15.O_CREAT | constants15.O_EXCL | constants15.O_NOFOLLOW, 384);
|
|
45425
45577
|
writeFileSync5(descriptor, `${JSON.stringify(value)}
|
|
45426
45578
|
`);
|
|
45427
|
-
|
|
45428
|
-
|
|
45579
|
+
fsyncSync6(descriptor);
|
|
45580
|
+
closeSync18(descriptor);
|
|
45429
45581
|
descriptor = undefined;
|
|
45430
45582
|
renameSync4(temporary, path);
|
|
45431
45583
|
syncArchiveDirectory(dirname17(path));
|
|
45432
45584
|
} finally {
|
|
45433
45585
|
if (descriptor !== undefined)
|
|
45434
|
-
|
|
45435
|
-
if (
|
|
45586
|
+
closeSync18(descriptor);
|
|
45587
|
+
if (lstatSync23(temporary, { throwIfNoEntry: false }))
|
|
45436
45588
|
unlinkSync5(temporary);
|
|
45437
45589
|
}
|
|
45438
45590
|
}
|
|
@@ -45478,7 +45630,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
45478
45630
|
const moved = [];
|
|
45479
45631
|
const verifyArchive = (entry) => {
|
|
45480
45632
|
assertSafePath(entry.archive);
|
|
45481
|
-
const stat2 =
|
|
45633
|
+
const stat2 = lstatSync23(entry.archive);
|
|
45482
45634
|
if (entry.discoveryOnly ? !stat2.isFile() : !stat2.isDirectory())
|
|
45483
45635
|
throw new Error("Archive type changed");
|
|
45484
45636
|
if ((entry.discoveryOnly ? sha4(readNativeBytes(entry.archive)) : treeHash(entry.archive)) !== entry.hash)
|
|
@@ -45529,7 +45681,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
45529
45681
|
recheckRootAliases(aliases);
|
|
45530
45682
|
assertSafePath(entry.source);
|
|
45531
45683
|
assertSafePath(entry.archive);
|
|
45532
|
-
if (
|
|
45684
|
+
if (lstatSync23(entry.source, { throwIfNoEntry: false })) {
|
|
45533
45685
|
entry.status = "recovery-required";
|
|
45534
45686
|
entry.conflict = "source-occupied";
|
|
45535
45687
|
continue;
|
|
@@ -45546,7 +45698,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
45546
45698
|
syncArchiveDirectory(dirname17(entry.source));
|
|
45547
45699
|
unlinkSync5(entry.archive);
|
|
45548
45700
|
} else {
|
|
45549
|
-
if (
|
|
45701
|
+
if (lstatSync23(entry.source, { throwIfNoEntry: false })) {
|
|
45550
45702
|
entry.status = "recovery-required";
|
|
45551
45703
|
entry.conflict = "source-occupied";
|
|
45552
45704
|
continue;
|
|
@@ -45579,12 +45731,12 @@ function isInertCodexPluginCacheCopy(entry, cache, allowedHostPaths, read3) {
|
|
|
45579
45731
|
return false;
|
|
45580
45732
|
const document2 = join27(entry.path, "SKILL.md");
|
|
45581
45733
|
const inside = relative5(cache, entry.path);
|
|
45582
|
-
if (!inside ||
|
|
45734
|
+
if (!inside || isAbsolute20(inside) || inside.split(sep7).some((segment) => segment === ".."))
|
|
45583
45735
|
return false;
|
|
45584
45736
|
assertSafePath(entry.path);
|
|
45585
|
-
if (!
|
|
45737
|
+
if (!lstatSync23(cache).isDirectory() || !lstatSync23(entry.path).isDirectory() || !lstatSync23(document2).isFile())
|
|
45586
45738
|
return false;
|
|
45587
|
-
if (
|
|
45739
|
+
if (realpathSync11.native(cache) !== cache || realpathSync11.native(entry.path) !== entry.path || realpathSync11.native(document2) !== document2)
|
|
45588
45740
|
return false;
|
|
45589
45741
|
if (!classifyCodexPluginCacheDocument(document2, cache, read3))
|
|
45590
45742
|
return false;
|
|
@@ -45752,20 +45904,20 @@ import {
|
|
|
45752
45904
|
mkdirSync as mkdirSync8,
|
|
45753
45905
|
mkdtempSync,
|
|
45754
45906
|
readdirSync as readdirSync10,
|
|
45755
|
-
realpathSync as
|
|
45907
|
+
realpathSync as realpathSync14,
|
|
45756
45908
|
renameSync as renameSync5,
|
|
45757
45909
|
rmSync as rmSync2,
|
|
45758
45910
|
statSync as statSync10,
|
|
45759
45911
|
writeFileSync as writeFileSync7
|
|
45760
45912
|
} from "fs";
|
|
45761
|
-
import { basename as basename11, dirname as dirname20, isAbsolute as
|
|
45913
|
+
import { basename as basename11, dirname as dirname20, isAbsolute as isAbsolute21, join as join31, normalize as normalize4, relative as relative7, resolve as resolve20, sep as sep10 } from "path";
|
|
45762
45914
|
|
|
45763
45915
|
// src/lib/registry-data/index.ts
|
|
45764
45916
|
var SKILLS = [];
|
|
45765
45917
|
|
|
45766
45918
|
// src/lib/skill-hash.ts
|
|
45767
|
-
import { createHash as
|
|
45768
|
-
import { existsSync as existsSync8, readdirSync as readdirSync9, readFileSync as
|
|
45919
|
+
import { createHash as createHash25 } from "crypto";
|
|
45920
|
+
import { existsSync as existsSync8, readdirSync as readdirSync9, readFileSync as readFileSync18, statSync as statSync8 } from "fs";
|
|
45769
45921
|
import { join as join28, sep as sep8 } from "path";
|
|
45770
45922
|
var CONTENT_HASH_ALGORITHM = "sha256";
|
|
45771
45923
|
var HASH_EXCLUDE_DIRS = new Set([".git", "node_modules", "dist", "build", ".turbo"]);
|
|
@@ -45862,7 +46014,7 @@ function collectDirectory(files, dir, rel) {
|
|
|
45862
46014
|
}
|
|
45863
46015
|
}
|
|
45864
46016
|
function collectFile(files, absolute, rel) {
|
|
45865
|
-
const buffer =
|
|
46017
|
+
const buffer = readFileSync18(absolute);
|
|
45866
46018
|
files.push(normalizeBundleFile(rel.split(sep8).join("/"), buffer));
|
|
45867
46019
|
}
|
|
45868
46020
|
function normalizeBundleFile(rel, buffer) {
|
|
@@ -45888,13 +46040,13 @@ function* bundleHashParts(files) {
|
|
|
45888
46040
|
yield new TextEncoder().encode("\x00");
|
|
45889
46041
|
}
|
|
45890
46042
|
function hashBundleFiles(files) {
|
|
45891
|
-
const hash2 =
|
|
46043
|
+
const hash2 = createHash25(CONTENT_HASH_ALGORITHM);
|
|
45892
46044
|
for (const part of bundleHashParts(files))
|
|
45893
46045
|
hash2.update(part);
|
|
45894
46046
|
return hash2.digest("hex");
|
|
45895
46047
|
}
|
|
45896
46048
|
async function hashBundleFilesCooperatively(files, check) {
|
|
45897
|
-
const hash2 =
|
|
46049
|
+
const hash2 = createHash25(CONTENT_HASH_ALGORITHM);
|
|
45898
46050
|
let bytesSinceYield = 0;
|
|
45899
46051
|
for (const part of bundleHashParts(files)) {
|
|
45900
46052
|
for (let offset = 0;offset < part.byteLength; offset += 64 * 1024) {
|
|
@@ -46277,10 +46429,10 @@ function validateRuntimeContract(manifest, issues, strict) {
|
|
|
46277
46429
|
import {
|
|
46278
46430
|
cpSync,
|
|
46279
46431
|
existsSync as existsSync9,
|
|
46280
|
-
lstatSync as
|
|
46432
|
+
lstatSync as lstatSync24,
|
|
46281
46433
|
mkdirSync as mkdirSync7,
|
|
46282
|
-
readFileSync as
|
|
46283
|
-
realpathSync as
|
|
46434
|
+
readFileSync as readFileSync19,
|
|
46435
|
+
realpathSync as realpathSync12,
|
|
46284
46436
|
writeFileSync as writeFileSync6
|
|
46285
46437
|
} from "fs";
|
|
46286
46438
|
import { basename as basename9, dirname as dirname18, join as join29, relative as relative6 } from "path";
|
|
@@ -46344,7 +46496,7 @@ function readManifest(skillPath, fallbackName, normalizeName) {
|
|
|
46344
46496
|
const skillMdPath = join29(skillPath, "SKILL.md");
|
|
46345
46497
|
const pkgPath = join29(skillPath, "package.json");
|
|
46346
46498
|
const jsonManifest = existsSync9(skillJsonPath) ? readJsonObject(skillJsonPath) : undefined;
|
|
46347
|
-
const frontmatter = existsSync9(skillMdPath) ? parseSkillFrontmatter(
|
|
46499
|
+
const frontmatter = existsSync9(skillMdPath) ? parseSkillFrontmatter(readFileSync19(skillMdPath, "utf-8")) ?? undefined : undefined;
|
|
46348
46500
|
const pkg = existsSync9(pkgPath) ? readJsonObject(pkgPath) : undefined;
|
|
46349
46501
|
const name = normalizeName(stringField(jsonManifest, "name") ?? frontmatter?.name ?? stringValue(pkg?.name) ?? fallbackName);
|
|
46350
46502
|
const description = stringField(jsonManifest, "description") ?? frontmatter?.description ?? stringValue(pkg?.description) ?? `${name} skill`;
|
|
@@ -46378,7 +46530,7 @@ function readDeclaredSkillVersion(skillPath) {
|
|
|
46378
46530
|
const skillMdPath = join29(skillPath, "SKILL.md");
|
|
46379
46531
|
const pkgPath = join29(skillPath, "package.json");
|
|
46380
46532
|
const jsonManifest = existsSync9(skillJsonPath) ? readJsonObject(skillJsonPath) : undefined;
|
|
46381
|
-
const frontmatter = existsSync9(skillMdPath) ? parseSkillFrontmatter(
|
|
46533
|
+
const frontmatter = existsSync9(skillMdPath) ? parseSkillFrontmatter(readFileSync19(skillMdPath, "utf-8")) ?? undefined : undefined;
|
|
46382
46534
|
const pkg = existsSync9(pkgPath) ? readJsonObject(pkgPath) : undefined;
|
|
46383
46535
|
return stringField(jsonManifest, "version") ?? frontmatter?.version ?? stringValue(pkg?.version);
|
|
46384
46536
|
}
|
|
@@ -46499,7 +46651,7 @@ function readExistingSkillJson(skillPath) {
|
|
|
46499
46651
|
if (!existsSync9(path))
|
|
46500
46652
|
return {};
|
|
46501
46653
|
try {
|
|
46502
|
-
const parsed = JSON.parse(
|
|
46654
|
+
const parsed = JSON.parse(readFileSync19(path, "utf-8"));
|
|
46503
46655
|
return isRecord3(parsed) ? parsed : {};
|
|
46504
46656
|
} catch {
|
|
46505
46657
|
return {};
|
|
@@ -46536,7 +46688,7 @@ function ensurePortableSkillFiles(skillPath, manifest) {
|
|
|
46536
46688
|
if (!existsSync9(join29(skillPath, "SKILL.md")))
|
|
46537
46689
|
writeFileSync6(join29(skillPath, "SKILL.md"), renderSkillMd(next));
|
|
46538
46690
|
else
|
|
46539
|
-
writeFileSync6(join29(skillPath, "SKILL.md"), ensureSkillMdFrontmatter(
|
|
46691
|
+
writeFileSync6(join29(skillPath, "SKILL.md"), ensureSkillMdFrontmatter(readFileSync19(join29(skillPath, "SKILL.md"), "utf-8"), next));
|
|
46540
46692
|
if (!existsSync9(join29(skillPath, "AGENTS.md")))
|
|
46541
46693
|
writeFileSync6(join29(skillPath, "AGENTS.md"), renderAgentsMd(next));
|
|
46542
46694
|
ensurePackageJson(skillPath, next);
|
|
@@ -46597,7 +46749,7 @@ function ensureInstructionSkillFiles(skillPath, manifest) {
|
|
|
46597
46749
|
writeFileSync6(join29(skillPath, "SKILL.md"), renderSkillMd(next));
|
|
46598
46750
|
} else {
|
|
46599
46751
|
const path = join29(skillPath, "SKILL.md");
|
|
46600
|
-
const content =
|
|
46752
|
+
const content = readFileSync19(path, "utf8");
|
|
46601
46753
|
const declaredName = parseSkillFrontmatter(content)?.name;
|
|
46602
46754
|
if (declaredName && declaredName !== next.name) {
|
|
46603
46755
|
writeFileSync6(path, renameInstructionFrontmatter(content, next.name));
|
|
@@ -46635,7 +46787,7 @@ function renameInstructionFrontmatter(content, name) {
|
|
|
46635
46787
|
return renamed + content.slice(frontmatter[0].length);
|
|
46636
46788
|
}
|
|
46637
46789
|
function copySkillDirectory(source, destination) {
|
|
46638
|
-
const resolvedSource =
|
|
46790
|
+
const resolvedSource = lstatSync24(source).isSymbolicLink() ? realpathSync12(source) : source;
|
|
46639
46791
|
mkdirSync7(destination, { recursive: true });
|
|
46640
46792
|
cpSync(resolvedSource, destination, {
|
|
46641
46793
|
recursive: true,
|
|
@@ -46648,7 +46800,7 @@ function copySkillDirectory(source, destination) {
|
|
|
46648
46800
|
if (isExcludedCopyEntry(segments[i], i === 0))
|
|
46649
46801
|
return false;
|
|
46650
46802
|
}
|
|
46651
|
-
if (
|
|
46803
|
+
if (lstatSync24(src).isSymbolicLink())
|
|
46652
46804
|
return false;
|
|
46653
46805
|
return true;
|
|
46654
46806
|
}
|
|
@@ -46889,7 +47041,7 @@ function inferRuntimeFromCommands(commands) {
|
|
|
46889
47041
|
return { ...defaultRuntimeContract(entrypoint), runtime: "python3" };
|
|
46890
47042
|
}
|
|
46891
47043
|
function readJsonObject(path) {
|
|
46892
|
-
const parsed = JSON.parse(
|
|
47044
|
+
const parsed = JSON.parse(readFileSync19(path, "utf-8"));
|
|
46893
47045
|
if (!isRecord3(parsed))
|
|
46894
47046
|
throw new Error(`${basename9(path)} must contain a JSON object`);
|
|
46895
47047
|
return parsed;
|
|
@@ -46927,7 +47079,7 @@ function escapeJsString(value) {
|
|
|
46927
47079
|
}
|
|
46928
47080
|
|
|
46929
47081
|
// src/lib/authoring-path.ts
|
|
46930
|
-
import { lstatSync as
|
|
47082
|
+
import { lstatSync as lstatSync25, realpathSync as realpathSync13 } from "fs";
|
|
46931
47083
|
import { homedir as homedir4 } from "os";
|
|
46932
47084
|
import { basename as basename10, dirname as dirname19, join as join30, resolve as resolve19, sep as sep9 } from "path";
|
|
46933
47085
|
var NATIVE_DISCOVERY_ROOTS = NATIVE_SKILL_ROOTS.map(([, path]) => path.split("/"));
|
|
@@ -46948,14 +47100,14 @@ function nativeRootMatch(path) {
|
|
|
46948
47100
|
function physicalPath(path) {
|
|
46949
47101
|
let cursor = resolve19(path);
|
|
46950
47102
|
const suffix = [];
|
|
46951
|
-
while (!
|
|
47103
|
+
while (!lstatSync25(cursor, { throwIfNoEntry: false })) {
|
|
46952
47104
|
suffix.unshift(basename10(cursor));
|
|
46953
47105
|
const parent = dirname19(cursor);
|
|
46954
47106
|
if (parent === cursor)
|
|
46955
47107
|
return resolve19(path);
|
|
46956
47108
|
cursor = parent;
|
|
46957
47109
|
}
|
|
46958
|
-
return resolve19(
|
|
47110
|
+
return resolve19(realpathSync13(cursor), ...suffix);
|
|
46959
47111
|
}
|
|
46960
47112
|
function contains(root2, path) {
|
|
46961
47113
|
return path === root2 || path.startsWith(root2 + sep9);
|
|
@@ -46993,7 +47145,7 @@ function configuredRoots(home, explicitHome) {
|
|
|
46993
47145
|
continue;
|
|
46994
47146
|
}
|
|
46995
47147
|
const nativeHome = join30(home, agent === "opencode" ? ".config/opencode" : `.${agent}`);
|
|
46996
|
-
if (!
|
|
47148
|
+
if (!lstatSync25(nativeHome, { throwIfNoEntry: false }))
|
|
46997
47149
|
continue;
|
|
46998
47150
|
roots.push(...resolveAgentDiscovery({ home, agent, canonical: physicalPath }).roots);
|
|
46999
47151
|
}
|
|
@@ -47171,14 +47323,14 @@ function physicalImportPath(path) {
|
|
|
47171
47323
|
suffix.unshift(basename11(ancestor));
|
|
47172
47324
|
ancestor = dirname20(ancestor);
|
|
47173
47325
|
}
|
|
47174
|
-
return join31(
|
|
47326
|
+
return join31(realpathSync14(ancestor), ...suffix);
|
|
47175
47327
|
}
|
|
47176
47328
|
function assertDisjointImportPaths(source, destination) {
|
|
47177
|
-
const sourcePath =
|
|
47329
|
+
const sourcePath = realpathSync14(source);
|
|
47178
47330
|
const destinationPath = physicalImportPath(destination);
|
|
47179
47331
|
const contains2 = (parent, child) => {
|
|
47180
47332
|
const path = relative7(parent, child);
|
|
47181
|
-
return path === "" || !
|
|
47333
|
+
return path === "" || !isAbsolute21(path) && path !== ".." && !path.startsWith(`..${sep10}`);
|
|
47182
47334
|
};
|
|
47183
47335
|
if (contains2(sourcePath, destinationPath) || contains2(destinationPath, sourcePath)) {
|
|
47184
47336
|
throw new Error("Source and destination skill directories must not overlap");
|
|
@@ -47459,7 +47611,7 @@ function safeIsDirectory(path) {
|
|
|
47459
47611
|
}
|
|
47460
47612
|
}
|
|
47461
47613
|
function isSafeRelativePath2(value) {
|
|
47462
|
-
if (!value.trim() ||
|
|
47614
|
+
if (!value.trim() || isAbsolute21(value))
|
|
47463
47615
|
return false;
|
|
47464
47616
|
const normalized = normalize4(value).replace(/\\/g, "/");
|
|
47465
47617
|
return normalized !== ".." && !normalized.startsWith("../") && !normalized.includes("/../");
|
|
@@ -47486,9 +47638,9 @@ function isSkillsOwnershipMarker(marker) {
|
|
|
47486
47638
|
function hasSkillsOwnershipMarker(dir) {
|
|
47487
47639
|
const path = join32(dir, SYNC_MARKER_FILE);
|
|
47488
47640
|
try {
|
|
47489
|
-
if (!
|
|
47641
|
+
if (!lstatSync26(path).isFile())
|
|
47490
47642
|
return false;
|
|
47491
|
-
const marker = JSON.parse(
|
|
47643
|
+
const marker = JSON.parse(readFileSync20(path, "utf8"));
|
|
47492
47644
|
return isSkillsOwnershipMarker(marker);
|
|
47493
47645
|
} catch {
|
|
47494
47646
|
return false;
|
|
@@ -47705,7 +47857,7 @@ function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
|
47705
47857
|
if (dirExists && managed && hasSkillMd && !options.force && isPointerSkillMd(skillMd)) {
|
|
47706
47858
|
let existingIsStub = false;
|
|
47707
47859
|
try {
|
|
47708
|
-
existingIsStub = isPointerSkillMd(
|
|
47860
|
+
existingIsStub = isPointerSkillMd(readFileSync20(skillMdPath, "utf-8"));
|
|
47709
47861
|
} catch {
|
|
47710
47862
|
existingIsStub = false;
|
|
47711
47863
|
}
|
|
@@ -47755,7 +47907,7 @@ function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
|
47755
47907
|
assertCurrent();
|
|
47756
47908
|
renameDirectory(candidateDir, dir);
|
|
47757
47909
|
assertCurrent();
|
|
47758
|
-
if (
|
|
47910
|
+
if (readFileSync20(skillMdPath, "utf8") !== (skillMd.endsWith(`
|
|
47759
47911
|
`) ? skillMd : `${skillMd}
|
|
47760
47912
|
`))
|
|
47761
47913
|
throw new Error("Managed skill readback failed");
|
|
@@ -47799,7 +47951,7 @@ function sourceSkillMd(skillPath, name, description, kind, preferBundledDocs = f
|
|
|
47799
47951
|
if (kind === undefined || kind === "instruction" || preferBundledDocs) {
|
|
47800
47952
|
const skillMdPath = join32(skillPath, "SKILL.md");
|
|
47801
47953
|
if (existsSync11(skillMdPath))
|
|
47802
|
-
return
|
|
47954
|
+
return readFileSync20(skillMdPath, "utf-8");
|
|
47803
47955
|
}
|
|
47804
47956
|
return pointerSkillMd(name, description);
|
|
47805
47957
|
}
|
|
@@ -47829,7 +47981,7 @@ function normalizeSkillName(name) {
|
|
|
47829
47981
|
}
|
|
47830
47982
|
|
|
47831
47983
|
// src/lib/registry.ts
|
|
47832
|
-
import { existsSync as existsSync12, readFileSync as
|
|
47984
|
+
import { existsSync as existsSync12, readFileSync as readFileSync21, readdirSync as readdirSync12 } from "fs";
|
|
47833
47985
|
import { join as join33 } from "path";
|
|
47834
47986
|
|
|
47835
47987
|
// src/lib/registry-merge.ts
|
|
@@ -48045,7 +48197,7 @@ function discoverSkillsInDir(dir, source = "custom") {
|
|
|
48045
48197
|
continue;
|
|
48046
48198
|
let content;
|
|
48047
48199
|
try {
|
|
48048
|
-
content =
|
|
48200
|
+
content = readFileSync21(skillMdPath, "utf-8");
|
|
48049
48201
|
} catch {
|
|
48050
48202
|
continue;
|
|
48051
48203
|
}
|
|
@@ -48082,7 +48234,7 @@ function findExtensionSkillPath(name) {
|
|
|
48082
48234
|
continue;
|
|
48083
48235
|
let content;
|
|
48084
48236
|
try {
|
|
48085
|
-
content =
|
|
48237
|
+
content = readFileSync21(skillMdPath, "utf-8");
|
|
48086
48238
|
} catch {
|
|
48087
48239
|
continue;
|
|
48088
48240
|
}
|
|
@@ -48147,7 +48299,7 @@ function getAllTags(catalog) {
|
|
|
48147
48299
|
}
|
|
48148
48300
|
|
|
48149
48301
|
// src/lib/project-state.ts
|
|
48150
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as
|
|
48302
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync9 } from "fs";
|
|
48151
48303
|
import { join as join34 } from "path";
|
|
48152
48304
|
var VALID_PIN_SOURCES = [
|
|
48153
48305
|
"official",
|
|
@@ -48173,7 +48325,7 @@ function loadProjectConfig(targetDir = process.cwd()) {
|
|
|
48173
48325
|
if (!existsSync13(path))
|
|
48174
48326
|
return null;
|
|
48175
48327
|
try {
|
|
48176
|
-
return normalizeProjectConfig(JSON.parse(
|
|
48328
|
+
return normalizeProjectConfig(JSON.parse(readFileSync22(path, "utf-8")));
|
|
48177
48329
|
} catch {
|
|
48178
48330
|
return null;
|
|
48179
48331
|
}
|
|
@@ -48360,7 +48512,7 @@ function createLocalSkillManifest(name, generateSkillMd) {
|
|
|
48360
48512
|
let skillMd = "";
|
|
48361
48513
|
const skillMdPath = join35(sourcePath, "SKILL.md");
|
|
48362
48514
|
if (existsSync14(skillMdPath)) {
|
|
48363
|
-
skillMd =
|
|
48515
|
+
skillMd = readFileSync23(skillMdPath, "utf-8");
|
|
48364
48516
|
} else if (generateSkillMd) {
|
|
48365
48517
|
skillMd = generateSkillMd(name) ?? "";
|
|
48366
48518
|
} else {
|
|
@@ -48486,7 +48638,7 @@ function resolveAgentSkillMd(name, generateSkillMd) {
|
|
|
48486
48638
|
const sourcePath = getSkillPath(name);
|
|
48487
48639
|
const skillMdPath = join35(sourcePath, "SKILL.md");
|
|
48488
48640
|
if (existsSync14(skillMdPath))
|
|
48489
|
-
return
|
|
48641
|
+
return readFileSync23(skillMdPath, "utf-8");
|
|
48490
48642
|
if (generateSkillMd)
|
|
48491
48643
|
return generateSkillMd(name);
|
|
48492
48644
|
return generateMinimalSkillMd(name);
|
|
@@ -48542,14 +48694,14 @@ function readBundledSkillVersion(name) {
|
|
|
48542
48694
|
if (!existsSync14(pkgPath))
|
|
48543
48695
|
return "unknown";
|
|
48544
48696
|
try {
|
|
48545
|
-
const pkg = JSON.parse(
|
|
48697
|
+
const pkg = JSON.parse(readFileSync23(pkgPath, "utf-8"));
|
|
48546
48698
|
return pkg.version || "unknown";
|
|
48547
48699
|
} catch {
|
|
48548
48700
|
return "unknown";
|
|
48549
48701
|
}
|
|
48550
48702
|
}
|
|
48551
48703
|
function readFileIfExists(path) {
|
|
48552
|
-
return existsSync14(path) ?
|
|
48704
|
+
return existsSync14(path) ? readFileSync23(path, "utf-8") : null;
|
|
48553
48705
|
}
|
|
48554
48706
|
function loadProjectConfigCompat(targetDir) {
|
|
48555
48707
|
return loadProjectConfig(targetDir);
|
|
@@ -48597,7 +48749,7 @@ function isInstructionSkillDir(skillPath, meta) {
|
|
|
48597
48749
|
if (!existsSync15(skillMdPath))
|
|
48598
48750
|
return false;
|
|
48599
48751
|
try {
|
|
48600
|
-
return parseSkillFrontmatter(
|
|
48752
|
+
return parseSkillFrontmatter(readFileSync24(skillMdPath, "utf-8"))?.kind === "instruction";
|
|
48601
48753
|
} catch {
|
|
48602
48754
|
return false;
|
|
48603
48755
|
}
|
|
@@ -48648,7 +48800,7 @@ function getSkillRequirements(name) {
|
|
|
48648
48800
|
const meta = getSkill(name);
|
|
48649
48801
|
let dependencies = {};
|
|
48650
48802
|
try {
|
|
48651
|
-
dependencies = JSON.parse(
|
|
48803
|
+
dependencies = JSON.parse(readFileSync24(join36(skillPath, "package.json"), "utf8")).dependencies || {};
|
|
48652
48804
|
} catch {}
|
|
48653
48805
|
return getSkillRequirementsFromContent(name, texts, dependencies, meta);
|
|
48654
48806
|
}
|
|
@@ -48716,7 +48868,7 @@ async function runSkill(name, args, options = {}) {
|
|
|
48716
48868
|
}
|
|
48717
48869
|
let entryPoint2;
|
|
48718
48870
|
try {
|
|
48719
|
-
const pkg = JSON.parse(
|
|
48871
|
+
const pkg = JSON.parse(readFileSync24(pkgPath, "utf-8"));
|
|
48720
48872
|
if (pkg.bin) {
|
|
48721
48873
|
const binValues = Object.values(pkg.bin);
|
|
48722
48874
|
entryPoint2 = binValues[0];
|
|
@@ -48819,7 +48971,7 @@ function generateSkillMd(name) {
|
|
|
48819
48971
|
const pkgPath = join36(skillPath, "package.json");
|
|
48820
48972
|
if (existsSync15(pkgPath)) {
|
|
48821
48973
|
try {
|
|
48822
|
-
const pkg = JSON.parse(
|
|
48974
|
+
const pkg = JSON.parse(readFileSync24(pkgPath, "utf-8"));
|
|
48823
48975
|
if (pkg.bin) {
|
|
48824
48976
|
const binKeys = Object.keys(pkg.bin);
|
|
48825
48977
|
if (binKeys.length > 0)
|
|
@@ -48895,7 +49047,7 @@ function extractEnvVars(text2) {
|
|
|
48895
49047
|
function readIfExists(path) {
|
|
48896
49048
|
try {
|
|
48897
49049
|
if (existsSync15(path)) {
|
|
48898
|
-
return
|
|
49050
|
+
return readFileSync24(path, "utf-8");
|
|
48899
49051
|
}
|
|
48900
49052
|
} catch {}
|
|
48901
49053
|
return null;
|
|
@@ -49126,7 +49278,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
49126
49278
|
const { authority: authority2, workspaceId, profileRevision, slug, version, bundleDigest } = selection2;
|
|
49127
49279
|
const request2 = {
|
|
49128
49280
|
selection: { authority: authority2, workspaceId, profileId, profileRevision, slug, version, bundleDigest },
|
|
49129
|
-
consumer: { stationId: process.env.HASNA_STATION || stationHostname2(), workspaceDirectory:
|
|
49281
|
+
consumer: { stationId: process.env.HASNA_STATION || stationHostname2(), workspaceDirectory: realpathSync15(options.cwd ?? process.cwd()) }
|
|
49130
49282
|
};
|
|
49131
49283
|
const grant = await (options.resolveExecutionGrant ?? resolveExecutionGrant)(request2);
|
|
49132
49284
|
if (!grant || !grantIdentifier(grant.policyRevision) || !grantIdentifier(grant.grantId))
|
|
@@ -49143,7 +49295,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
49143
49295
|
selection: selection2,
|
|
49144
49296
|
target: "local",
|
|
49145
49297
|
runtime: runtimeName,
|
|
49146
|
-
inputDigest: `sha256:${
|
|
49298
|
+
inputDigest: `sha256:${createHash26("sha256").update(input).digest("hex")}`,
|
|
49147
49299
|
runDirectory,
|
|
49148
49300
|
...executionGrant ? { executionGrant } : {},
|
|
49149
49301
|
...bindings ? { secretBinding: { schema: bindings.schema, selection: bindings.selection, consumer: bindings.consumer, secretsAuthority: bindings.secretsAuthority, bindings: bindings.bindings } } : {},
|
|
@@ -58433,7 +58585,7 @@ var import_node_http_handler2 = __toESM(require_dist_cjs6(), 1);
|
|
|
58433
58585
|
|
|
58434
58586
|
// node_modules/@aws-sdk/checksums/dist-cjs/submodules/sha/index.js
|
|
58435
58587
|
var { toUint8Array: toUint8Array2, concatBytes } = require_serde();
|
|
58436
|
-
var { createHmac: createHmac2, createHash:
|
|
58588
|
+
var { createHmac: createHmac2, createHash: createHash28 } = __require("crypto");
|
|
58437
58589
|
var { Sha256: Sha2562, Sha256Js, Sha256Node } = require_checksum();
|
|
58438
58590
|
var BLOCK2 = 64;
|
|
58439
58591
|
var DIGEST_LENGTH = 20;
|
|
@@ -58602,7 +58754,7 @@ class Sha1Js {
|
|
|
58602
58754
|
}
|
|
58603
58755
|
var hasNativeCrypto = (() => {
|
|
58604
58756
|
try {
|
|
58605
|
-
|
|
58757
|
+
createHash28("sha1");
|
|
58606
58758
|
return true;
|
|
58607
58759
|
} catch {
|
|
58608
58760
|
return false;
|
|
@@ -58642,7 +58794,7 @@ function buildNativeClass() {
|
|
|
58642
58794
|
this.finished = false;
|
|
58643
58795
|
}
|
|
58644
58796
|
createHash() {
|
|
58645
|
-
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) :
|
|
58797
|
+
return this.secret ? createHmac2("sha1", toBuffer(this.secret)) : createHash28("sha1");
|
|
58646
58798
|
}
|
|
58647
58799
|
};
|
|
58648
58800
|
}
|
|
@@ -58917,11 +59069,11 @@ class ArtifactStorage {
|
|
|
58917
59069
|
}));
|
|
58918
59070
|
return await bodyToText(response.Body);
|
|
58919
59071
|
}
|
|
58920
|
-
async putBundle(orgId,
|
|
58921
|
-
assertSha256(
|
|
59072
|
+
async putBundle(orgId, sha2563, bytes, contentType = "application/gzip") {
|
|
59073
|
+
assertSha256(sha2563);
|
|
58922
59074
|
if (!this.bucket)
|
|
58923
59075
|
return { storageKind: "db", bytes };
|
|
58924
|
-
const key = this.bundleKeyFor(orgId,
|
|
59076
|
+
const key = this.bundleKeyFor(orgId, sha2563);
|
|
58925
59077
|
await this.s3.send(new PutObjectCommand({
|
|
58926
59078
|
Bucket: this.bucket,
|
|
58927
59079
|
Key: key,
|
|
@@ -58941,11 +59093,11 @@ class ArtifactStorage {
|
|
|
58941
59093
|
}));
|
|
58942
59094
|
return await bodyToBytes(response.Body);
|
|
58943
59095
|
}
|
|
58944
|
-
async deleteBundle(orgId,
|
|
59096
|
+
async deleteBundle(orgId, sha2563) {
|
|
58945
59097
|
if (!this.bucket || !this.s3)
|
|
58946
59098
|
return;
|
|
58947
|
-
assertSha256(
|
|
58948
|
-
await this.s3.send(new DeleteObjectCommand({ Bucket: this.bucket, Key: this.bundleKeyFor(orgId,
|
|
59099
|
+
assertSha256(sha2563);
|
|
59100
|
+
await this.s3.send(new DeleteObjectCommand({ Bucket: this.bucket, Key: this.bundleKeyFor(orgId, sha2563) }));
|
|
58949
59101
|
}
|
|
58950
59102
|
async deleteObject(artifact) {
|
|
58951
59103
|
if (!this.bucket || !this.s3)
|
|
@@ -58992,8 +59144,8 @@ class ArtifactStorage {
|
|
|
58992
59144
|
versionKeyFor(orgId, slug, version2, file) {
|
|
58993
59145
|
return `${this.prefix}/skills/${encodeURIComponent(orgId)}/${encodeURIComponent(slug)}/${encodeURIComponent(version2)}/${file}`;
|
|
58994
59146
|
}
|
|
58995
|
-
bundleKeyFor(orgId,
|
|
58996
|
-
return `${this.prefix}/bundles/${encodeURIComponent(orgId)}/${
|
|
59147
|
+
bundleKeyFor(orgId, sha2563) {
|
|
59148
|
+
return `${this.prefix}/bundles/${encodeURIComponent(orgId)}/${sha2563}.tar.gz`;
|
|
58997
59149
|
}
|
|
58998
59150
|
}
|
|
58999
59151
|
function assertSha256(value) {
|
|
@@ -59214,7 +59366,7 @@ import { mkdirSync as mkdirSync13 } from "fs";
|
|
|
59214
59366
|
import { dirname as dirname26 } from "path";
|
|
59215
59367
|
|
|
59216
59368
|
// src/server/database-url.ts
|
|
59217
|
-
import { isAbsolute as
|
|
59369
|
+
import { isAbsolute as isAbsolute22, join as join39 } from "path";
|
|
59218
59370
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
59219
59371
|
var DEFAULT_SQLITE_FILENAME2 = "server.db";
|
|
59220
59372
|
var SQLITE_MEMORY_PATH = ":memory:";
|
|
@@ -59250,7 +59402,7 @@ function resolveDatabaseTarget(raw) {
|
|
|
59250
59402
|
throw new Error(`unsupported database scheme "${scheme}:". Supported: postgres://, postgresql://, sqlite:, file:, ` + `an absolute or relative path to a .db/.sqlite file, ":memory:", or "memory:" (non-durable, tests only). ` + `Leave the setting empty to use the default SQLite database at ${defaultSqlitePath()}.`);
|
|
59251
59403
|
}
|
|
59252
59404
|
if (looksLikeSqlitePath(value)) {
|
|
59253
|
-
const path =
|
|
59405
|
+
const path = isAbsolute22(value) ? value : join39(process.cwd(), value);
|
|
59254
59406
|
return { kind: "sqlite", path, durable: true, label: `sqlite (${path})` };
|
|
59255
59407
|
}
|
|
59256
59408
|
throw new Error(`could not resolve a database backend from "${value}". Use postgres://\u2026, sqlite:\u2026, an absolute or ` + `relative path ending in ${SQLITE_EXTENSIONS.join("/")}, ":memory:", or leave it empty for the ` + `default SQLite database at ${defaultSqlitePath()}.`);
|
|
@@ -59274,7 +59426,7 @@ function sqlitePathFromUrl(value, scheme) {
|
|
|
59274
59426
|
}
|
|
59275
59427
|
return rest.slice(2).replace(/^\/\/+/, "/");
|
|
59276
59428
|
}
|
|
59277
|
-
return
|
|
59429
|
+
return isAbsolute22(rest) ? rest : join39(process.cwd(), rest);
|
|
59278
59430
|
}
|
|
59279
59431
|
function looksLikeSqlitePath(value) {
|
|
59280
59432
|
if (value.includes("/"))
|
|
@@ -59506,13 +59658,13 @@ class PostgresSkillSelectionStore {
|
|
|
59506
59658
|
|
|
59507
59659
|
// src/server/sqlite-store.ts
|
|
59508
59660
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
59509
|
-
import { mkdirSync as mkdirSync12, readFileSync as
|
|
59661
|
+
import { mkdirSync as mkdirSync12, readFileSync as readFileSync26, readdirSync as readdirSync13 } from "fs";
|
|
59510
59662
|
import { dirname as dirname25, join as join41 } from "path";
|
|
59511
59663
|
|
|
59512
59664
|
// src/server/auth.ts
|
|
59513
|
-
import { createHash as
|
|
59665
|
+
import { createHash as createHash29 } from "crypto";
|
|
59514
59666
|
function hashApiKey(token) {
|
|
59515
|
-
return
|
|
59667
|
+
return createHash29("sha256").update(token).digest("hex");
|
|
59516
59668
|
}
|
|
59517
59669
|
function bearerToken(request2) {
|
|
59518
59670
|
const header = request2.headers.get("authorization") || "";
|
|
@@ -59836,7 +59988,7 @@ function validOperatorScopeEnrollmentInput(input) {
|
|
|
59836
59988
|
}
|
|
59837
59989
|
|
|
59838
59990
|
// src/lib/revision.ts
|
|
59839
|
-
import { createHash as
|
|
59991
|
+
import { createHash as createHash30 } from "crypto";
|
|
59840
59992
|
var REVISION_ID_PATTERN = /^[0-9a-f]{64}$/;
|
|
59841
59993
|
function revisionIdOf(content) {
|
|
59842
59994
|
const canonicalContent = {
|
|
@@ -59858,7 +60010,7 @@ function revisionIdOf(content) {
|
|
|
59858
60010
|
canonicalContent.replacementSlug = content.replacementSlug ?? null;
|
|
59859
60011
|
}
|
|
59860
60012
|
const canonical7 = JSON.stringify(canonicalContent);
|
|
59861
|
-
return
|
|
60013
|
+
return createHash30("sha256").update(canonical7).digest("hex");
|
|
59862
60014
|
}
|
|
59863
60015
|
function revisionIdOfRecord(record4) {
|
|
59864
60016
|
return revisionIdOf(record4);
|
|
@@ -60467,8 +60619,8 @@ class SqliteSkillsStore {
|
|
|
60467
60619
|
return purged;
|
|
60468
60620
|
})();
|
|
60469
60621
|
}
|
|
60470
|
-
async getSkillBundle(principal,
|
|
60471
|
-
const row = this.get("SELECT * FROM skills_bundles WHERE org_id = ? AND sha256 = ? LIMIT 1", [principal.orgId,
|
|
60622
|
+
async getSkillBundle(principal, sha2563) {
|
|
60623
|
+
const row = this.get("SELECT * FROM skills_bundles WHERE org_id = ? AND sha256 = ? LIMIT 1", [principal.orgId, sha2563]);
|
|
60472
60624
|
return row ? rowToSkillBundle(row) : null;
|
|
60473
60625
|
}
|
|
60474
60626
|
async listSkillVersions(principal, slug) {
|
|
@@ -60532,11 +60684,11 @@ class SqliteSkillsStore {
|
|
|
60532
60684
|
async listPublishedSlugs(principal) {
|
|
60533
60685
|
return this.all("SELECT slug FROM skills_registry WHERE org_id = ? AND tombstoned_at IS NULL ORDER BY slug ASC", [principal.orgId]).map((row) => String(row.slug));
|
|
60534
60686
|
}
|
|
60535
|
-
collectOrphanBundle(orgId,
|
|
60536
|
-
const referenced = this.get("SELECT 1 AS present FROM skills_registry WHERE org_id = ? AND bundle_sha256 = ? LIMIT 1", [orgId,
|
|
60687
|
+
collectOrphanBundle(orgId, sha2563) {
|
|
60688
|
+
const referenced = this.get("SELECT 1 AS present FROM skills_registry WHERE org_id = ? AND bundle_sha256 = ? LIMIT 1", [orgId, sha2563]) ?? this.get("SELECT 1 AS present FROM skills_versions WHERE org_id = ? AND bundle_sha256 = ? LIMIT 1", [orgId, sha2563]);
|
|
60537
60689
|
if (referenced)
|
|
60538
60690
|
return;
|
|
60539
|
-
this.db.run("DELETE FROM skills_bundles WHERE org_id = ? AND sha256 = ?", [orgId,
|
|
60691
|
+
this.db.run("DELETE FROM skills_bundles WHERE org_id = ? AND sha256 = ?", [orgId, sha2563]);
|
|
60540
60692
|
}
|
|
60541
60693
|
get(sql, params) {
|
|
60542
60694
|
return this.db.query(sql).get(...params) ?? null;
|
|
@@ -60562,7 +60714,7 @@ function applySqliteMigrations(db, migrationsDir = resolveMigrationsDir("sqlite"
|
|
|
60562
60714
|
const appliedNow = [];
|
|
60563
60715
|
for (const file of files) {
|
|
60564
60716
|
const version2 = file.replace(/\.sql$/, "");
|
|
60565
|
-
const text2 =
|
|
60717
|
+
const text2 = readFileSync26(join41(migrationsDir, file), "utf8");
|
|
60566
60718
|
const apply = db.transaction(() => {
|
|
60567
60719
|
const already = db.query("SELECT 1 AS present FROM schema_migrations WHERE version = ? LIMIT 1").get(version2);
|
|
60568
60720
|
if (already)
|
|
@@ -60942,7 +61094,7 @@ function nextMonthPrefix(monthPrefix) {
|
|
|
60942
61094
|
}
|
|
60943
61095
|
|
|
60944
61096
|
// src/server/skills-api.ts
|
|
60945
|
-
import { createHash as
|
|
61097
|
+
import { createHash as createHash31 } from "crypto";
|
|
60946
61098
|
var SLUG_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
60947
61099
|
var SHA256_HEX2 = /^[0-9a-f]{64}$/;
|
|
60948
61100
|
var MAX_SLUG_LENGTH = 128;
|
|
@@ -61132,19 +61284,19 @@ async function parsePublishRequest(request2, config) {
|
|
|
61132
61284
|
if (bundleBytes.byteLength === 0) {
|
|
61133
61285
|
throw new SkillRequestError(400, "BUNDLE_EMPTY", "the uploaded bundle is empty");
|
|
61134
61286
|
}
|
|
61135
|
-
const
|
|
61287
|
+
const sha2563 = createHash31("sha256").update(bundleBytes).digest("hex");
|
|
61136
61288
|
const claimed = optionalString(manifest.bundleSha256);
|
|
61137
61289
|
if (claimed)
|
|
61138
61290
|
assertSha2562(claimed);
|
|
61139
|
-
if (claimed && claimed !==
|
|
61140
|
-
throw new SkillRequestError(400, "BUNDLE_DIGEST_MISMATCH", `bundle digest ${
|
|
61291
|
+
if (claimed && claimed !== sha2563) {
|
|
61292
|
+
throw new SkillRequestError(400, "BUNDLE_DIGEST_MISMATCH", `bundle digest ${sha2563} does not match the declared ${claimed}`);
|
|
61141
61293
|
}
|
|
61142
61294
|
const input = buildPublishInput(manifest);
|
|
61143
61295
|
return {
|
|
61144
61296
|
input: {
|
|
61145
61297
|
...input,
|
|
61146
61298
|
bundle: {
|
|
61147
|
-
sha256:
|
|
61299
|
+
sha256: sha2563,
|
|
61148
61300
|
byteSize: bundleBytes.byteLength,
|
|
61149
61301
|
contentType: optionalString(manifest.bundleContentType) ?? "application/gzip",
|
|
61150
61302
|
storageKind: "db"
|
|
@@ -61229,10 +61381,10 @@ async function storePublishedSkill(store, artifactStorage, principal, parsed, ex
|
|
|
61229
61381
|
async function deletePublishedSkill(store, artifactStorage, principal, slug, tombstoneWindowMs) {
|
|
61230
61382
|
return store.deleteSkill(principal, slug, tombstoneWindowMs);
|
|
61231
61383
|
}
|
|
61232
|
-
async function discardCollectedObject(store, artifactStorage, principal,
|
|
61233
|
-
if (await store.getSkillBundle(principal,
|
|
61384
|
+
async function discardCollectedObject(store, artifactStorage, principal, sha2563) {
|
|
61385
|
+
if (await store.getSkillBundle(principal, sha2563))
|
|
61234
61386
|
return;
|
|
61235
|
-
await artifactStorage.deleteBundle(principal.orgId,
|
|
61387
|
+
await artifactStorage.deleteBundle(principal.orgId, sha2563);
|
|
61236
61388
|
}
|
|
61237
61389
|
async function readPublishedBundle(store, artifactStorage, principal, slug) {
|
|
61238
61390
|
const record4 = await store.getSkill(principal, slug);
|
|
@@ -61247,7 +61399,7 @@ async function readPublishedBundle(store, artifactStorage, principal, slug) {
|
|
|
61247
61399
|
if (!bytes) {
|
|
61248
61400
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
61249
61401
|
}
|
|
61250
|
-
const actual =
|
|
61402
|
+
const actual = createHash31("sha256").update(bytes).digest("hex");
|
|
61251
61403
|
if (actual !== record4.bundleSha256) {
|
|
61252
61404
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}' hashes to ${actual} but was published as ${record4.bundleSha256}`);
|
|
61253
61405
|
}
|
|
@@ -61395,7 +61547,7 @@ async function readSkillVersionBundle(store, artifactStorage, principal, slug, v
|
|
|
61395
61547
|
const bytes = await artifactStorage.readBundle(bundle2);
|
|
61396
61548
|
if (!bytes)
|
|
61397
61549
|
throw new SkillRequestError(503, "BUNDLE_BACKEND_UNAVAILABLE", "bundle storage backend unavailable");
|
|
61398
|
-
const actual =
|
|
61550
|
+
const actual = createHash31("sha256").update(bytes).digest("hex");
|
|
61399
61551
|
if (actual !== found.bundleSha256) {
|
|
61400
61552
|
throw new SkillRequestError(500, "BUNDLE_DIGEST_DRIFT", `stored bundle for '${slug}@${version2}' hashes to ${actual} but was published as ${found.bundleSha256}`);
|
|
61401
61553
|
}
|
|
@@ -62111,7 +62263,7 @@ class RuntimeExecutionStore {
|
|
|
62111
62263
|
}
|
|
62112
62264
|
|
|
62113
62265
|
// src/sdk/execution/admission.ts
|
|
62114
|
-
import { createHash as
|
|
62266
|
+
import { createHash as createHash33 } from "crypto";
|
|
62115
62267
|
|
|
62116
62268
|
// src/sdk/execution/image-profile.ts
|
|
62117
62269
|
class ImageProfileResolutionError extends Error {
|
|
@@ -62723,11 +62875,11 @@ function ownedAdmission(admission) {
|
|
|
62723
62875
|
};
|
|
62724
62876
|
}
|
|
62725
62877
|
function digestInput(input) {
|
|
62726
|
-
return
|
|
62878
|
+
return createHash33("sha256").update(canonicalJson2(input)).digest("hex");
|
|
62727
62879
|
}
|
|
62728
62880
|
|
|
62729
62881
|
// src/sdk/execution/dispatchers/ecs.ts
|
|
62730
|
-
import { createHash as
|
|
62882
|
+
import { createHash as createHash34 } from "crypto";
|
|
62731
62883
|
|
|
62732
62884
|
// src/sdk/execution/state-machine.ts
|
|
62733
62885
|
var LEGAL_TRANSITIONS = {
|
|
@@ -66127,13 +66279,13 @@ function observedTask(states, taskArn) {
|
|
|
66127
66279
|
return state2.lastStatus === "STOPPED" || LIVE_TASK_STATUSES.has(state2.lastStatus) ? state2 : undefined;
|
|
66128
66280
|
}
|
|
66129
66281
|
function clientTokenFor(runId3, attemptId) {
|
|
66130
|
-
return
|
|
66282
|
+
return createHash34("sha256").update(`${runId3}\x00${attemptId}`).digest("hex").slice(0, CLIENT_TOKEN_BYTES * 2);
|
|
66131
66283
|
}
|
|
66132
66284
|
function startedByFor(runId3, attemptNumber) {
|
|
66133
66285
|
return `skills-exec/${runId3}/a${attemptNumber}`;
|
|
66134
66286
|
}
|
|
66135
66287
|
function requestDigestFor(admission, attemptId) {
|
|
66136
|
-
return
|
|
66288
|
+
return createHash34("sha256").update(canonicalJson2({ admission, attemptId })).digest("hex");
|
|
66137
66289
|
}
|
|
66138
66290
|
|
|
66139
66291
|
class EcsDispatcher {
|
|
@@ -66429,10 +66581,10 @@ function validText(value) {
|
|
|
66429
66581
|
}
|
|
66430
66582
|
|
|
66431
66583
|
// src/server/runtime-policy.ts
|
|
66432
|
-
import { createHash as
|
|
66584
|
+
import { createHash as createHash36, createHmac as createHmac3, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
66433
66585
|
|
|
66434
66586
|
// src/server/runtime-pure-contract.ts
|
|
66435
|
-
import { createHash as
|
|
66587
|
+
import { createHash as createHash35 } from "crypto";
|
|
66436
66588
|
var PURE_DESCRIPTOR = Object.freeze({
|
|
66437
66589
|
id: "regex-test.v1",
|
|
66438
66590
|
runtime: "bun",
|
|
@@ -66456,7 +66608,7 @@ var PURE_LIMITS = Object.freeze({
|
|
|
66456
66608
|
maxArtifactsBytes: 0,
|
|
66457
66609
|
maxConcurrency: 1
|
|
66458
66610
|
});
|
|
66459
|
-
var hash2 = (bytes) =>
|
|
66611
|
+
var hash2 = (bytes) => createHash35("sha256").update(bytes).digest("hex");
|
|
66460
66612
|
var object7 = (v2) => {
|
|
66461
66613
|
if (!v2 || typeof v2 !== "object" || Array.isArray(v2))
|
|
66462
66614
|
throw Error("Pure contract requires an object");
|
|
@@ -66685,7 +66837,7 @@ function verifyRuntimeToken(token, key, admission, attempt, now = Date.now()) {
|
|
|
66685
66837
|
const actual = Buffer.from(token);
|
|
66686
66838
|
return actual.length === expected.length && timingSafeEqual2(actual, expected);
|
|
66687
66839
|
}
|
|
66688
|
-
var hashBytes = (bytes) =>
|
|
66840
|
+
var hashBytes = (bytes) => createHash36("sha256").update(bytes).digest("hex");
|
|
66689
66841
|
|
|
66690
66842
|
// src/server/runtime-api.ts
|
|
66691
66843
|
async function createRuntimeService(options) {
|
|
@@ -66786,8 +66938,8 @@ function publicJob(job) {
|
|
|
66786
66938
|
artifacts: (job.result?.artifacts ?? []).map(({ base64, ...meta }) => meta)
|
|
66787
66939
|
};
|
|
66788
66940
|
}
|
|
66789
|
-
function findReview(service, tenant, slug, version2,
|
|
66790
|
-
return service.config.reviewedBundles.find((b4) => b4.slug === slug && b4.version === version2 && b4.sha256 ===
|
|
66941
|
+
function findReview(service, tenant, slug, version2, sha2563) {
|
|
66942
|
+
return service.config.reviewedBundles.find((b4) => b4.slug === slug && b4.version === version2 && b4.sha256 === sha2563 && (!b4.executionContract || b4.tenantId === tenant && b4.imageDigest === service.config.imageDigest));
|
|
66791
66943
|
}
|
|
66792
66944
|
function sameContract(admission, contract, image) {
|
|
66793
66945
|
return digestInput(admission.executionContract ?? null) === digestInput(contract ?? null) && (!contract || admission.runtimeImageDigest === image);
|
|
@@ -67641,8 +67793,8 @@ class MemorySkillsStore {
|
|
|
67641
67793
|
}
|
|
67642
67794
|
return purged;
|
|
67643
67795
|
}
|
|
67644
|
-
async getSkillBundle(principal,
|
|
67645
|
-
const bundle2 = this.bundles.get(skillKey(principal.orgId,
|
|
67796
|
+
async getSkillBundle(principal, sha2563) {
|
|
67797
|
+
const bundle2 = this.bundles.get(skillKey(principal.orgId, sha2563));
|
|
67646
67798
|
return bundle2 && bundle2.orgId === principal.orgId ? bundle2 : null;
|
|
67647
67799
|
}
|
|
67648
67800
|
async pinSkill(principal, slug, metadata = {}) {
|
|
@@ -67685,10 +67837,10 @@ class MemorySkillsStore {
|
|
|
67685
67837
|
async listPublishedSlugs(principal) {
|
|
67686
67838
|
return Array.from(this.skills.values()).filter((skill) => skill.orgId === principal.orgId && !skill.tombstonedAt).map((skill) => skill.slug).sort();
|
|
67687
67839
|
}
|
|
67688
|
-
collectOrphanBundle(orgId,
|
|
67689
|
-
const referenced = Array.from(this.skills.values()).some((skill) => skill.orgId === orgId && skill.bundleSha256 ===
|
|
67840
|
+
collectOrphanBundle(orgId, sha2563) {
|
|
67841
|
+
const referenced = Array.from(this.skills.values()).some((skill) => skill.orgId === orgId && skill.bundleSha256 === sha2563) || Array.from(this.versions.values()).some((v2) => v2.orgId === orgId && v2.bundleSha256 === sha2563);
|
|
67690
67842
|
if (!referenced)
|
|
67691
|
-
this.bundles.delete(skillKey(orgId,
|
|
67843
|
+
this.bundles.delete(skillKey(orgId, sha2563));
|
|
67692
67844
|
}
|
|
67693
67845
|
patchRun(runId3, patch) {
|
|
67694
67846
|
const run = this.runs.get(runId3);
|
|
@@ -68349,8 +68501,8 @@ class PostgresSkillsStore {
|
|
|
68349
68501
|
return purged;
|
|
68350
68502
|
});
|
|
68351
68503
|
}
|
|
68352
|
-
async getSkillBundle(principal,
|
|
68353
|
-
const rows = await this.sql`SELECT * FROM skills_bundles WHERE org_id = ${principal.orgId} AND sha256 = ${
|
|
68504
|
+
async getSkillBundle(principal, sha2563) {
|
|
68505
|
+
const rows = await this.sql`SELECT * FROM skills_bundles WHERE org_id = ${principal.orgId} AND sha256 = ${sha2563} LIMIT 1`;
|
|
68354
68506
|
return rows[0] ? rowToSkillBundle(rows[0]) : null;
|
|
68355
68507
|
}
|
|
68356
68508
|
async listSkillVersions(principal, slug) {
|
|
@@ -68444,12 +68596,12 @@ class PostgresSkillsStore {
|
|
|
68444
68596
|
`;
|
|
68445
68597
|
return rows.map((row) => String(row.slug));
|
|
68446
68598
|
}
|
|
68447
|
-
async collectOrphanBundle(orgId,
|
|
68599
|
+
async collectOrphanBundle(orgId, sha2563) {
|
|
68448
68600
|
await this.sql`
|
|
68449
68601
|
DELETE FROM skills_bundles
|
|
68450
|
-
WHERE org_id = ${orgId} AND sha256 = ${
|
|
68451
|
-
AND NOT EXISTS (SELECT 1 FROM skills_registry WHERE org_id = ${orgId} AND bundle_sha256 = ${
|
|
68452
|
-
AND NOT EXISTS (SELECT 1 FROM skills_versions WHERE org_id = ${orgId} AND bundle_sha256 = ${
|
|
68602
|
+
WHERE org_id = ${orgId} AND sha256 = ${sha2563}
|
|
68603
|
+
AND NOT EXISTS (SELECT 1 FROM skills_registry WHERE org_id = ${orgId} AND bundle_sha256 = ${sha2563})
|
|
68604
|
+
AND NOT EXISTS (SELECT 1 FROM skills_versions WHERE org_id = ${orgId} AND bundle_sha256 = ${sha2563})
|
|
68453
68605
|
`;
|
|
68454
68606
|
}
|
|
68455
68607
|
}
|
|
@@ -73061,7 +73213,7 @@ var localRunExecutor = {
|
|
|
73061
73213
|
// src/sdk/storage.ts
|
|
73062
73214
|
var artifactStorageSeam = ArtifactStorage;
|
|
73063
73215
|
// src/sdk/outputs.ts
|
|
73064
|
-
import { createHash as
|
|
73216
|
+
import { createHash as createHash37 } from "crypto";
|
|
73065
73217
|
class DatabaseOnlyObjectStore {
|
|
73066
73218
|
usesS3 = false;
|
|
73067
73219
|
async materialize(run, artifact, body4) {
|
|
@@ -73108,7 +73260,7 @@ function createGovernedArtifactWriter(options) {
|
|
|
73108
73260
|
const stamped = {
|
|
73109
73261
|
...meta,
|
|
73110
73262
|
byteSize: outputBytes,
|
|
73111
|
-
sha256:
|
|
73263
|
+
sha256: createHash37("sha256").update(persistedBytes).digest("hex"),
|
|
73112
73264
|
visibility: options.visibility ?? config.defaultVisibility,
|
|
73113
73265
|
...config.artifactTtlSeconds !== undefined ? { expiresAt: expiresAtFor(createdAt, config.artifactTtlSeconds) } : {}
|
|
73114
73266
|
};
|
|
@@ -91875,7 +92027,7 @@ function date4(params) {
|
|
|
91875
92027
|
return _coercedDate(ZodDate2, params);
|
|
91876
92028
|
}
|
|
91877
92029
|
// src/lib/canonical-json.ts
|
|
91878
|
-
import { createHash as
|
|
92030
|
+
import { createHash as createHash38 } from "crypto";
|
|
91879
92031
|
function canonicalJson3(value, maximumBytes = 2 * 1024 * 1024) {
|
|
91880
92032
|
return canonicalJsonAtDepth(value, maximumBytes, 64);
|
|
91881
92033
|
}
|
|
@@ -91919,7 +92071,7 @@ function canonicalJsonAtDepth(value, maximumBytes, maximumDepth) {
|
|
|
91919
92071
|
return visit3(value, 0);
|
|
91920
92072
|
}
|
|
91921
92073
|
function canonicalJsonSha256(value, maximumBytes) {
|
|
91922
|
-
return
|
|
92074
|
+
return createHash38("sha256").update(canonicalJson3(value, maximumBytes)).digest("hex");
|
|
91923
92075
|
}
|
|
91924
92076
|
|
|
91925
92077
|
// src/lib/remote-recurring-contract.ts
|
|
@@ -94033,7 +94185,7 @@ async function requestInvitationEmail(origin, action, input2) {
|
|
|
94033
94185
|
}
|
|
94034
94186
|
|
|
94035
94187
|
// src/lib/remote-private-publications.ts
|
|
94036
|
-
import { createHash as
|
|
94188
|
+
import { createHash as createHash39 } from "crypto";
|
|
94037
94189
|
var PRIVATE_PUBLICATION_MAX_BYTES = 16 * 1024 * 1024;
|
|
94038
94190
|
var failures2 = {
|
|
94039
94191
|
INVALID_REQUEST: [400, "The publication request is invalid."],
|
|
@@ -94080,7 +94232,7 @@ var hash4 = (v2) => typeof v2 === "string" && /^[a-f0-9]{64}$/.test(v2);
|
|
|
94080
94232
|
var record10 = (v2) => !!v2 && typeof v2 === "object" && !Array.isArray(v2);
|
|
94081
94233
|
var exact = (v2, keys3) => record10(v2) && Object.keys(v2).sort().join(",") === keys3.sort().join(",");
|
|
94082
94234
|
var date5 = (v2) => typeof v2 === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v2) && Number.isFinite(Date.parse(v2));
|
|
94083
|
-
var publicationSha256 = (bytes) =>
|
|
94235
|
+
var publicationSha256 = (bytes) => createHash39("sha256").update(bytes).digest("hex");
|
|
94084
94236
|
function checkedPublicationDeclaration(value) {
|
|
94085
94237
|
if (!exact(value, ["idempotencyKey", "version", "expectedCurrentVersionId", "manifestText", "archiveSha256", "archiveByteSize"]) || !publicationUuid(value.idempotencyKey) || !(value.expectedCurrentVersionId === null || publicationUuid(value.expectedCurrentVersionId)) || typeof value.version !== "string" || !value.version || value.version.length > 128 || /[\p{Cc}\p{Cs}]/u.test(value.version) || typeof value.manifestText !== "string" || Buffer.byteLength(value.manifestText) > 16384 || !hash4(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES)
|
|
94086
94238
|
return bad();
|
|
@@ -94562,23 +94714,23 @@ class RemoteSkillsAuthClient {
|
|
|
94562
94714
|
}
|
|
94563
94715
|
}
|
|
94564
94716
|
// src/lib/private-publication-recovery.ts
|
|
94565
|
-
import { constants as
|
|
94566
|
-
import { dirname as dirname28, isAbsolute as
|
|
94717
|
+
import { constants as constants16, closeSync as closeSync19, fsyncSync as fsyncSync7, fstatSync as fstatSync19, lstatSync as lstatSync27, mkdirSync as mkdirSync15, openSync as openSync19, readSync as readSync13, realpathSync as realpathSync16, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync11 } from "fs";
|
|
94718
|
+
import { dirname as dirname28, isAbsolute as isAbsolute23, join as join43, resolve as resolve23 } from "path";
|
|
94567
94719
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
94568
94720
|
var fail2 = () => {
|
|
94569
94721
|
throw new PrivatePublicationError("PUBLICATION_RECOVERY_INVALID", "The recovery directory is invalid or changed. Preserve it and inspect the existing intent; do not start a replacement automatically.");
|
|
94570
94722
|
};
|
|
94571
94723
|
function safeDirectory(directory) {
|
|
94572
|
-
if (!
|
|
94724
|
+
if (!isAbsolute23(directory) || directory !== resolve23(directory) || realpathSync16(directory) !== directory)
|
|
94573
94725
|
return fail2();
|
|
94574
94726
|
for (let path2 = directory;; path2 = dirname28(path2)) {
|
|
94575
|
-
const stat2 =
|
|
94727
|
+
const stat2 = lstatSync27(path2);
|
|
94576
94728
|
if (!stat2.isDirectory() || stat2.isSymbolicLink())
|
|
94577
94729
|
return fail2();
|
|
94578
94730
|
if (path2 === dirname28(path2))
|
|
94579
94731
|
break;
|
|
94580
94732
|
}
|
|
94581
|
-
const own2 =
|
|
94733
|
+
const own2 = lstatSync27(directory);
|
|
94582
94734
|
if ((own2.mode & 63) !== 0 || process.getuid && own2.uid !== process.getuid())
|
|
94583
94735
|
return fail2();
|
|
94584
94736
|
return { dev: own2.dev, ino: own2.ino };
|
|
@@ -94590,9 +94742,9 @@ function unchangedDirectory(directory, identity5) {
|
|
|
94590
94742
|
}
|
|
94591
94743
|
function readOwned(directory, name, max) {
|
|
94592
94744
|
const identity5 = safeDirectory(directory), file2 = join43(directory, name);
|
|
94593
|
-
const fd =
|
|
94745
|
+
const fd = openSync19(file2, constants16.O_RDONLY | constants16.O_NOFOLLOW);
|
|
94594
94746
|
try {
|
|
94595
|
-
const stat2 =
|
|
94747
|
+
const stat2 = fstatSync19(fd);
|
|
94596
94748
|
if (!stat2.isFile() || stat2.nlink !== 1 || stat2.size > max || stat2.size < 1 || (stat2.mode & 63) !== 0 || process.getuid && stat2.uid !== process.getuid())
|
|
94597
94749
|
return fail2();
|
|
94598
94750
|
const buffer = Buffer.alloc(Math.min(max, stat2.size) + 1);
|
|
@@ -94603,22 +94755,22 @@ function readOwned(directory, name, max) {
|
|
|
94603
94755
|
break;
|
|
94604
94756
|
length += count;
|
|
94605
94757
|
}
|
|
94606
|
-
const bytes = buffer.subarray(0, length), after =
|
|
94758
|
+
const bytes = buffer.subarray(0, length), after = fstatSync19(fd);
|
|
94607
94759
|
unchangedDirectory(directory, identity5);
|
|
94608
94760
|
if (bytes.length !== stat2.size || stat2.size !== after.size || stat2.mtimeMs !== after.mtimeMs || stat2.ctimeMs !== after.ctimeMs)
|
|
94609
94761
|
return fail2();
|
|
94610
94762
|
return bytes;
|
|
94611
94763
|
} finally {
|
|
94612
|
-
|
|
94764
|
+
closeSync19(fd);
|
|
94613
94765
|
}
|
|
94614
94766
|
}
|
|
94615
94767
|
function writeOwned(directory, name, bytes) {
|
|
94616
|
-
const fd =
|
|
94768
|
+
const fd = openSync19(join43(directory, name), constants16.O_WRONLY | constants16.O_CREAT | constants16.O_EXCL | constants16.O_NOFOLLOW, 384);
|
|
94617
94769
|
try {
|
|
94618
94770
|
writeFileSync11(fd, bytes);
|
|
94619
|
-
|
|
94771
|
+
fsyncSync7(fd);
|
|
94620
94772
|
} finally {
|
|
94621
|
-
|
|
94773
|
+
closeSync19(fd);
|
|
94622
94774
|
}
|
|
94623
94775
|
}
|
|
94624
94776
|
function save(directory, value) {
|
|
@@ -94627,11 +94779,11 @@ function save(directory, value) {
|
|
|
94627
94779
|
`);
|
|
94628
94780
|
unchangedDirectory(directory, identity5);
|
|
94629
94781
|
renameSync7(join43(directory, temporary), join43(directory, "receipt.json"));
|
|
94630
|
-
const fd =
|
|
94782
|
+
const fd = openSync19(directory, constants16.O_RDONLY | constants16.O_NOFOLLOW);
|
|
94631
94783
|
try {
|
|
94632
|
-
|
|
94784
|
+
fsyncSync7(fd);
|
|
94633
94785
|
} finally {
|
|
94634
|
-
|
|
94786
|
+
closeSync19(fd);
|
|
94635
94787
|
}
|
|
94636
94788
|
}
|
|
94637
94789
|
function bind(client2, receipt) {
|
|
@@ -94642,20 +94794,20 @@ async function locked(directory, action) {
|
|
|
94642
94794
|
const identity5 = safeDirectory(directory), file2 = join43(directory, "operation.lock");
|
|
94643
94795
|
let fd;
|
|
94644
94796
|
try {
|
|
94645
|
-
fd =
|
|
94797
|
+
fd = openSync19(file2, constants16.O_WRONLY | constants16.O_CREAT | constants16.O_EXCL | constants16.O_NOFOLLOW, 384);
|
|
94646
94798
|
} catch {
|
|
94647
94799
|
throw new PrivatePublicationError("PUBLICATION_RECOVERY_BUSY", "Another operation holds this recovery directory. If it crashed, confirm that process has stopped before explicitly removing operation.lock and resuming.");
|
|
94648
94800
|
}
|
|
94649
|
-
const lock =
|
|
94801
|
+
const lock = fstatSync19(fd);
|
|
94650
94802
|
try {
|
|
94651
94803
|
writeFileSync11(fd, JSON.stringify({ pid: process.pid }) + `
|
|
94652
94804
|
`);
|
|
94653
|
-
|
|
94805
|
+
fsyncSync7(fd);
|
|
94654
94806
|
return await action();
|
|
94655
94807
|
} finally {
|
|
94656
|
-
|
|
94808
|
+
closeSync19(fd);
|
|
94657
94809
|
unchangedDirectory(directory, identity5);
|
|
94658
|
-
const now2 =
|
|
94810
|
+
const now2 = lstatSync27(file2);
|
|
94659
94811
|
if (now2.dev !== lock.dev || now2.ino !== lock.ino || !now2.isFile() || now2.isSymbolicLink())
|
|
94660
94812
|
fail2();
|
|
94661
94813
|
unlinkSync6(file2);
|
|
@@ -94707,15 +94859,15 @@ async function preparePrivatePublication(client2, sourceDirectory, recoveryDirec
|
|
|
94707
94859
|
phase: "prepared",
|
|
94708
94860
|
intent: null
|
|
94709
94861
|
};
|
|
94710
|
-
if (!
|
|
94862
|
+
if (!isAbsolute23(recoveryDirectory) || resolve23(recoveryDirectory) !== recoveryDirectory || realpathSync16(dirname28(recoveryDirectory)) !== dirname28(recoveryDirectory))
|
|
94711
94863
|
return fail2();
|
|
94712
94864
|
mkdirSync15(recoveryDirectory, { mode: 448 });
|
|
94713
94865
|
safeDirectory(recoveryDirectory);
|
|
94714
|
-
const parent =
|
|
94866
|
+
const parent = openSync19(dirname28(recoveryDirectory), constants16.O_RDONLY | constants16.O_NOFOLLOW);
|
|
94715
94867
|
try {
|
|
94716
|
-
|
|
94868
|
+
fsyncSync7(parent);
|
|
94717
94869
|
} finally {
|
|
94718
|
-
|
|
94870
|
+
closeSync19(parent);
|
|
94719
94871
|
}
|
|
94720
94872
|
writeOwned(recoveryDirectory, "bundle.tgz", packed.bytes);
|
|
94721
94873
|
save(recoveryDirectory, receipt);
|