@hasna/skills 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk/index.js CHANGED
@@ -7173,9 +7173,9 @@ var require_transport = __commonJS((exports) => {
7173
7173
  }
7174
7174
  return true;
7175
7175
  };
7176
- function isValidHostname(hostname) {
7176
+ function isValidHostname(hostname2) {
7177
7177
  const hostPattern = /^[a-z0-9][a-z0-9.-]*[a-z0-9]$/;
7178
- return hostPattern.test(hostname);
7178
+ return hostPattern.test(hostname2);
7179
7179
  }
7180
7180
  var normalizeProvider = (input) => {
7181
7181
  if (typeof input === "function")
@@ -7208,13 +7208,13 @@ var require_transport = __commonJS((exports) => {
7208
7208
  if (typeof url === "string") {
7209
7209
  return parseUrl(new URL(url));
7210
7210
  }
7211
- const { hostname, pathname, port, protocol, search } = url;
7211
+ const { hostname: hostname2, pathname, port, protocol, search } = url;
7212
7212
  let query;
7213
7213
  if (search) {
7214
7214
  query = parseQueryString(search);
7215
7215
  }
7216
7216
  return {
7217
- hostname,
7217
+ hostname: hostname2,
7218
7218
  port: port ? parseInt(port) : undefined,
7219
7219
  protocol,
7220
7220
  path: pathname,
@@ -9399,11 +9399,11 @@ var require_config = __commonJS((exports) => {
9399
9399
  }
9400
9400
  const useDualstackEndpoint = await input.useDualstackEndpoint();
9401
9401
  const useFipsEndpoint = await input.useFipsEndpoint();
9402
- const { hostname } = await input.regionInfoProvider(region, { useDualstackEndpoint, useFipsEndpoint }) ?? {};
9403
- if (!hostname) {
9402
+ const { hostname: hostname2 } = await input.regionInfoProvider(region, { useDualstackEndpoint, useFipsEndpoint }) ?? {};
9403
+ if (!hostname2) {
9404
9404
  throw new Error("Cannot resolve hostname from client config");
9405
9405
  }
9406
- return input.urlParser(`${tls ? "https:" : "http:"}//${hostname}`);
9406
+ return input.urlParser(`${tls ? "https:" : "http:"}//${hostname2}`);
9407
9407
  };
9408
9408
  var resolveEndpointsConfig = (input) => {
9409
9409
  const useDualstackEndpoint = normalizeProvider(input.useDualstackEndpoint ?? false);
@@ -9566,12 +9566,12 @@ var require_config = __commonJS((exports) => {
9566
9566
  var getHostnameFromVariants = (variants = [], { useFipsEndpoint, useDualstackEndpoint }) => variants.find(({ tags }) => useFipsEndpoint === tags.includes("fips") && useDualstackEndpoint === tags.includes("dualstack"))?.hostname;
9567
9567
  var getResolvedHostname = (resolvedRegion, { regionHostname, partitionHostname }) => regionHostname ? regionHostname : partitionHostname ? partitionHostname.replace("{region}", resolvedRegion) : undefined;
9568
9568
  var getResolvedPartition = (region, { partitionHash }) => Object.keys(partitionHash || {}).find((key) => partitionHash[key].regions.includes(region)) ?? "aws";
9569
- var getResolvedSigningRegion = (hostname, { signingRegion, regionRegex, useFipsEndpoint }) => {
9569
+ var getResolvedSigningRegion = (hostname2, { signingRegion, regionRegex, useFipsEndpoint }) => {
9570
9570
  if (signingRegion) {
9571
9571
  return signingRegion;
9572
9572
  } else if (useFipsEndpoint) {
9573
9573
  const regionRegexJs = regionRegex.replace("\\\\", "\\").replace(/^\^/g, "\\.").replace(/\$$/g, "\\.");
9574
- const regionRegexmatchArray = hostname.match(regionRegexJs);
9574
+ const regionRegexmatchArray = hostname2.match(regionRegexJs);
9575
9575
  if (regionRegexmatchArray) {
9576
9576
  return regionRegexmatchArray[0].slice(1, -1);
9577
9577
  }
@@ -9583,11 +9583,11 @@ var require_config = __commonJS((exports) => {
9583
9583
  const hostnameOptions = { useFipsEndpoint, useDualstackEndpoint };
9584
9584
  const regionHostname = getHostnameFromVariants(regionHash[resolvedRegion]?.variants, hostnameOptions);
9585
9585
  const partitionHostname = getHostnameFromVariants(partitionHash[partition]?.variants, hostnameOptions);
9586
- const hostname = getResolvedHostname(resolvedRegion, { regionHostname, partitionHostname });
9587
- if (hostname === undefined) {
9586
+ const hostname2 = getResolvedHostname(resolvedRegion, { regionHostname, partitionHostname });
9587
+ if (hostname2 === undefined) {
9588
9588
  throw new Error(`Endpoint resolution failed for: ${{ resolvedRegion, useFipsEndpoint, useDualstackEndpoint }}`);
9589
9589
  }
9590
- const signingRegion = getResolvedSigningRegion(hostname, {
9590
+ const signingRegion = getResolvedSigningRegion(hostname2, {
9591
9591
  signingRegion: regionHash[resolvedRegion]?.signingRegion,
9592
9592
  regionRegex: partitionHash[partition].regionRegex,
9593
9593
  useFipsEndpoint
@@ -9595,7 +9595,7 @@ var require_config = __commonJS((exports) => {
9595
9595
  return {
9596
9596
  partition,
9597
9597
  signingService,
9598
- hostname,
9598
+ hostname: hostname2,
9599
9599
  ...signingRegion && { signingRegion },
9600
9600
  ...regionHash[resolvedRegion]?.signingService && {
9601
9601
  signingService: regionHash[resolvedRegion].signingService
@@ -9820,8 +9820,8 @@ var require_endpoints = __commonJS((exports) => {
9820
9820
  return endpoint.url.href;
9821
9821
  }
9822
9822
  if ("hostname" in endpoint) {
9823
- const { protocol, hostname, port, path } = endpoint;
9824
- return `${protocol}//${hostname}${port ? ":" + port : ""}${path}`;
9823
+ const { protocol, hostname: hostname2, port, path } = endpoint;
9824
+ return `${protocol}//${hostname2}${port ? ":" + port : ""}${path}`;
9825
9825
  }
9826
9826
  }
9827
9827
  return endpoint;
@@ -10128,8 +10128,8 @@ var require_endpoints = __commonJS((exports) => {
10128
10128
  return value;
10129
10129
  }
10130
10130
  if (typeof value === "object" && "hostname" in value) {
10131
- const { hostname: hostname2, port, protocol: protocol2 = "", path = "", query = {} } = value;
10132
- const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path}`);
10131
+ const { hostname: hostname3, port, protocol: protocol2 = "", path = "", query = {} } = value;
10132
+ const url = new URL(`${protocol2}//${hostname3}${port ? `:${port}` : ""}${path}`);
10133
10133
  url.search = Object.entries(query).map(([k, v]) => `${k}=${v}`).join("&");
10134
10134
  return url;
10135
10135
  }
@@ -10143,7 +10143,7 @@ var require_endpoints = __commonJS((exports) => {
10143
10143
  return null;
10144
10144
  }
10145
10145
  const urlString = whatwgURL.href;
10146
- const { host, hostname, pathname, protocol, search } = whatwgURL;
10146
+ const { host, hostname: hostname2, pathname, protocol, search } = whatwgURL;
10147
10147
  if (search) {
10148
10148
  return null;
10149
10149
  }
@@ -10151,7 +10151,7 @@ var require_endpoints = __commonJS((exports) => {
10151
10151
  if (!Object.values(EndpointURLScheme).includes(scheme)) {
10152
10152
  return null;
10153
10153
  }
10154
- const isIp = isIpAddress(hostname);
10154
+ const isIp = isIpAddress(hostname2);
10155
10155
  const inputContainsDefaultPort = urlString.includes(`${host}:${DEFAULT_PORTS[scheme]}`) || typeof value === "string" && value.includes(`${host}:${DEFAULT_PORTS[scheme]}`);
10156
10156
  const authority2 = `${host}${inputContainsDefaultPort ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
10157
10157
  return {
@@ -14232,14 +14232,14 @@ var require_protocols = __commonJS((exports) => {
14232
14232
  this.context = context;
14233
14233
  }
14234
14234
  async build() {
14235
- const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
14235
+ const { hostname: hostname2, protocol = "https", port, path: basePath } = await this.context.endpoint();
14236
14236
  this.path = basePath;
14237
14237
  for (const resolvePath of this.resolvePathStack) {
14238
14238
  resolvePath(this.path);
14239
14239
  }
14240
14240
  return new HttpRequest({
14241
14241
  protocol,
14242
- hostname: this.hostname || hostname,
14242
+ hostname: this.hostname || hostname2,
14243
14243
  port,
14244
14244
  method: this.method,
14245
14245
  path: this.path,
@@ -14248,8 +14248,8 @@ var require_protocols = __commonJS((exports) => {
14248
14248
  headers: this.headers
14249
14249
  });
14250
14250
  }
14251
- hn(hostname) {
14252
- this.hostname = hostname;
14251
+ hn(hostname2) {
14252
+ this.hostname = hostname2;
14253
14253
  return this;
14254
14254
  }
14255
14255
  bp(uriLabel) {
@@ -18564,12 +18564,12 @@ var require_util = __commonJS((exports) => {
18564
18564
  };
18565
18565
  function formatUrl(request2) {
18566
18566
  const { port, query } = request2;
18567
- let { protocol, path, hostname } = request2;
18567
+ let { protocol, path, hostname: hostname2 } = request2;
18568
18568
  if (protocol && protocol.slice(-1) !== ":") {
18569
18569
  protocol += ":";
18570
18570
  }
18571
18571
  if (port) {
18572
- hostname += `:${port}`;
18572
+ hostname2 += `:${port}`;
18573
18573
  }
18574
18574
  if (path && path.charAt(0) !== "/") {
18575
18575
  path = `/${path}`;
@@ -18588,7 +18588,7 @@ var require_util = __commonJS((exports) => {
18588
18588
  if (request2.fragment) {
18589
18589
  fragment = `#${request2.fragment}`;
18590
18590
  }
18591
- return `${protocol}//${auth}${hostname}${path}${queryString}${fragment}`;
18591
+ return `${protocol}//${auth}${hostname2}${path}${queryString}${fragment}`;
18592
18592
  }
18593
18593
  exports.build = build;
18594
18594
  exports.formatUrl = formatUrl;
@@ -19477,10 +19477,10 @@ var require_cbor = __commonJS((exports) => {
19477
19477
  };
19478
19478
  var buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
19479
19479
  const endpoint = await context.endpoint();
19480
- const { hostname, protocol = "https", port, path: basePath } = endpoint;
19480
+ const { hostname: hostname2, protocol = "https", port, path: basePath } = endpoint;
19481
19481
  const contents = {
19482
19482
  protocol,
19483
- hostname,
19483
+ hostname: hostname2,
19484
19484
  port,
19485
19485
  method: "POST",
19486
19486
  path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
@@ -25338,15 +25338,15 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
25338
25338
  if (request2.fragment) {
25339
25339
  path += `#${request2.fragment}`;
25340
25340
  }
25341
- let hostname = request2.hostname ?? "";
25342
- if (hostname[0] === "[" && hostname.endsWith("]")) {
25343
- hostname = request2.hostname.slice(1, -1);
25341
+ let hostname2 = request2.hostname ?? "";
25342
+ if (hostname2[0] === "[" && hostname2.endsWith("]")) {
25343
+ hostname2 = request2.hostname.slice(1, -1);
25344
25344
  } else {
25345
- hostname = request2.hostname;
25345
+ hostname2 = request2.hostname;
25346
25346
  }
25347
25347
  const nodeHttpsOptions = {
25348
25348
  headers: request2.headers,
25349
- host: hostname,
25349
+ host: hostname2,
25350
25350
  method: request2.method,
25351
25351
  path,
25352
25352
  port: request2.port,
@@ -25738,14 +25738,14 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
25738
25738
  reject(abortError);
25739
25739
  return;
25740
25740
  }
25741
- const { hostname, method, port, protocol, query } = request2;
25741
+ const { hostname: hostname2, method, port, protocol, query } = request2;
25742
25742
  let auth = "";
25743
25743
  if (request2.username != null || request2.password != null) {
25744
25744
  const username = request2.username ?? "";
25745
25745
  const password = request2.password ?? "";
25746
25746
  auth = `${username}:${password}@`;
25747
25747
  }
25748
- const authority2 = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
25748
+ const authority2 = `${protocol}//${auth}${hostname2}${port ? `:${port}` : ""}`;
25749
25749
  const requestContext = { destination: new URL(authority2) };
25750
25750
  const connectConfig = {
25751
25751
  requestTimeout: this.config?.sessionTimeout,
@@ -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 readFileSync21 } from "fs";
30949
+ import { readFileSync as readFileSync22 } 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] ?? readFileSync21(webIdentityTokenFile, { encoding: "ascii" }),
30962
+ webIdentityToken: import_config32.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync22(webIdentityTokenFile, { encoding: "ascii" }),
30963
30963
  roleArn,
30964
30964
  roleSessionName
30965
30965
  })(awsIdentityProperties);
@@ -31530,42 +31530,42 @@ function isPrivateAddress(address) {
31530
31530
  return true;
31531
31531
  }
31532
31532
  async function resolveWebhookTarget(url, policy = {}) {
31533
- const hostname = normalizeHostname(url.hostname);
31533
+ const hostname2 = normalizeHostname(url.hostname);
31534
31534
  const allowlist = (policy.allowPrivateHosts ?? []).map((entry) => normalizeHostname(entry.toLowerCase()));
31535
- if (allowlist.includes(hostname)) {
31536
- const version22 = isIP3(hostname);
31535
+ if (allowlist.includes(hostname2)) {
31536
+ const version22 = isIP3(hostname2);
31537
31537
  if (version22 === 4 || version22 === 6) {
31538
- return { hostname, addresses: [hostname] };
31538
+ return { hostname: hostname2, addresses: [hostname2] };
31539
31539
  }
31540
31540
  const lookup2 = policy.lookup ?? defaultTargetLookup;
31541
31541
  let resolved2;
31542
31542
  try {
31543
- resolved2 = await lookup2(hostname);
31543
+ resolved2 = await lookup2(hostname2);
31544
31544
  } catch {
31545
- throw new Error(`Webhook target ${hostname} could not be resolved`);
31545
+ throw new Error(`Webhook target ${hostname2} could not be resolved`);
31546
31546
  }
31547
31547
  if (!Array.isArray(resolved2) || resolved2.length === 0) {
31548
- throw new Error(`Webhook target ${hostname} resolved to no addresses`);
31548
+ throw new Error(`Webhook target ${hostname2} resolved to no addresses`);
31549
31549
  }
31550
31550
  const addresses = resolved2.map((entry) => normalizeHostname(entry.address));
31551
- return { hostname, addresses };
31551
+ return { hostname: hostname2, addresses };
31552
31552
  }
31553
- const version2 = isIP3(hostname);
31553
+ const version2 = isIP3(hostname2);
31554
31554
  if (version2 === 4 || version2 === 6) {
31555
- if (isPrivateAddress(hostname)) {
31556
- throw new Error(`Webhook target ${hostname} is a private or special-use address`);
31555
+ if (isPrivateAddress(hostname2)) {
31556
+ throw new Error(`Webhook target ${hostname2} is a private or special-use address`);
31557
31557
  }
31558
- return { hostname, addresses: [hostname] };
31558
+ return { hostname: hostname2, addresses: [hostname2] };
31559
31559
  }
31560
31560
  const lookup = policy.lookup ?? defaultTargetLookup;
31561
31561
  let resolved;
31562
31562
  try {
31563
- resolved = await lookup(hostname);
31563
+ resolved = await lookup(hostname2);
31564
31564
  } catch {
31565
- throw new Error(`Webhook target ${hostname} could not be resolved`);
31565
+ throw new Error(`Webhook target ${hostname2} could not be resolved`);
31566
31566
  }
31567
31567
  if (!Array.isArray(resolved) || resolved.length === 0) {
31568
- throw new Error(`Webhook target ${hostname} resolved to no addresses`);
31568
+ throw new Error(`Webhook target ${hostname2} resolved to no addresses`);
31569
31569
  }
31570
31570
  const allowed = [];
31571
31571
  for (const entry of resolved) {
@@ -31575,14 +31575,14 @@ async function resolveWebhookTarget(url, policy = {}) {
31575
31575
  allowed.push(address);
31576
31576
  continue;
31577
31577
  }
31578
- throw new Error(`Webhook target ${hostname} resolves to private or special-use address ${address}`);
31578
+ throw new Error(`Webhook target ${hostname2} resolves to private or special-use address ${address}`);
31579
31579
  }
31580
31580
  allowed.push(address);
31581
31581
  }
31582
31582
  if (allowed.length === 0) {
31583
- throw new Error(`Webhook target ${hostname} resolved to no public addresses`);
31583
+ throw new Error(`Webhook target ${hostname2} resolved to no public addresses`);
31584
31584
  }
31585
- return { hostname, addresses: allowed };
31585
+ return { hostname: hostname2, addresses: allowed };
31586
31586
  }
31587
31587
  function normalizeMaxRedirects(value) {
31588
31588
  if (value === undefined)
@@ -31591,8 +31591,8 @@ function normalizeMaxRedirects(value) {
31591
31591
  throw new Error("webhookTargetPolicy.maxRedirects must be a non-negative integer");
31592
31592
  return value;
31593
31593
  }
31594
- function normalizeHostname(hostname) {
31595
- const lower = hostname.toLowerCase();
31594
+ function normalizeHostname(hostname2) {
31595
+ const lower = hostname2.toLowerCase();
31596
31596
  if (lower.startsWith("[") && lower.endsWith("]"))
31597
31597
  return lower.slice(1, -1);
31598
31598
  return lower;
@@ -31785,7 +31785,7 @@ async function pinnedNativeRequest(target, addresses, method, headers, body4, si
31785
31785
  method,
31786
31786
  headers,
31787
31787
  ...tls?.ca ? { ca: tls.ca } : {},
31788
- lookup: (hostname, _options, callback) => {
31788
+ lookup: (hostname2, _options, callback) => {
31789
31789
  const entries = addresses.map((address) => ({
31790
31790
  address,
31791
31791
  family: address.includes(":") ? 6 : 4
@@ -32291,8 +32291,8 @@ function normalizeRetryPolicy(policy) {
32291
32291
  multiplier: Math.max(1, policy?.multiplier ?? 2)
32292
32292
  };
32293
32293
  }
32294
- var PATHS_RESOLVER_KIND_ENV, PATHS_RESOLVER_APP_SLUG_RE3, HASNA_EVENTS_DIR_ENV = "HASNA_EVENTS_DIR", HASNA_EVENTS_HOME_ENV = "HASNA_EVENTS_HOME", EVENTS_STORE_SENTINEL_FILE = "events.json", LOCAL_JSON_EVENT_CURSOR_PREFIX = "local-json-v1:", DEFAULT_EVENT_PAGE_LIMIT = 100, MAX_EVENT_PAGE_LIMIT = 1000, DEFAULT_SIGNATURE_TOLERANCE_MS, DEFAULT_MAX_REDIRECTS = 5, IPV4_PRIVATE_RANGES, IPV6_SPECIAL_PREFIXES, defaultTargetLookup = async (hostname) => {
32295
- return dnsLookup(hostname, { all: true, verbatim: false });
32294
+ var PATHS_RESOLVER_KIND_ENV, PATHS_RESOLVER_APP_SLUG_RE3, HASNA_EVENTS_DIR_ENV = "HASNA_EVENTS_DIR", HASNA_EVENTS_HOME_ENV = "HASNA_EVENTS_HOME", EVENTS_STORE_SENTINEL_FILE = "events.json", LOCAL_JSON_EVENT_CURSOR_PREFIX = "local-json-v1:", DEFAULT_EVENT_PAGE_LIMIT = 100, MAX_EVENT_PAGE_LIMIT = 1000, DEFAULT_SIGNATURE_TOLERANCE_MS, DEFAULT_MAX_REDIRECTS = 5, IPV4_PRIVATE_RANGES, IPV6_SPECIAL_PREFIXES, defaultTargetLookup = async (hostname2) => {
32295
+ return dnsLookup(hostname2, { all: true, verbatim: false });
32296
32296
  }, EventValidationError, defaultEventTypeCatalog, APP_EVENT_V1_MAX_DATA_BYTES;
32297
32297
  var init_dist = __esm(() => {
32298
32298
  PATHS_RESOLVER_KIND_ENV = {
@@ -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.0",
32376
+ version: "0.10.2",
32377
32377
  description: "Skills library for AI coding agents",
32378
32378
  type: "module",
32379
32379
  bin: {
@@ -33390,9 +33390,17 @@ var AUTHORITY_OVERRIDE_HEADERS = new Set([
33390
33390
 
33391
33391
  // src/lib/instance-credentials.ts
33392
33392
  import { closeSync as closeSync3, constants, fstatSync as fstatSync3, lstatSync as lstatSync2, openSync as openSync3, readSync } from "fs";
33393
+
33394
+ // src/lib/cli-credential-profile.ts
33395
+ var cliCredentialProfile;
33396
+ function selectedCliSkillsCredentialProfile() {
33397
+ return cliCredentialProfile;
33398
+ }
33399
+
33400
+ // src/lib/instance-credentials.ts
33393
33401
  var SKILLS_BOUND_API_URL = "HASNA_SKILLS_BOUND_API_URL";
33394
33402
  function selectedSkillsProfile(env, explicit) {
33395
- const selected = explicit ?? env.HASNA_PROFILE;
33403
+ const selected = explicit ?? selectedCliSkillsCredentialProfile() ?? env.HASNA_PROFILE;
33396
33404
  if (selected === undefined)
33397
33405
  return null;
33398
33406
  const profile = selected.trim();
@@ -33640,11 +33648,13 @@ function snapshotSkillsEnvironment(env) {
33640
33648
  return Object.freeze(snapshot);
33641
33649
  }
33642
33650
  function snapshotSkillsOptions(env, options) {
33651
+ const profile = options.credentials?.profile ?? selectedCliSkillsCredentialProfile();
33652
+ const credentials = profile === undefined ? options.credentials : { ...options.credentials, profile };
33643
33653
  if (env !== process.env)
33644
- return options;
33645
- return { ...options, credentials: { ...options.credentials, keychain: {
33646
- ...options.credentials?.keychain,
33647
- enabled: options.credentials?.keychain?.enabled ?? true
33654
+ return credentials === options.credentials ? options : { ...options, credentials };
33655
+ return { ...options, credentials: { ...credentials, keychain: {
33656
+ ...credentials?.keychain,
33657
+ enabled: credentials?.keychain?.enabled ?? true
33648
33658
  } } };
33649
33659
  }
33650
33660
  function resolveSkillsFleetOrThrow(env, options) {
@@ -33732,8 +33742,9 @@ async function resolveSkillsApiKey(env = process.env, options = {}) {
33732
33742
  }
33733
33743
  async function resolveSkillsConnection(env = process.env, options = {}) {
33734
33744
  const snapshotEnv = snapshotSkillsEnvironment(env);
33735
- const assertFilesUnchanged = selectsSkillsLocalMode(snapshotEnv) ? () => {} : captureSkillsCredentialFiles(skillsProfileCredentialFiles(snapshotEnv, options.credentials?.profile));
33736
- const fleet = resolveSkillsFleet(snapshotEnv, snapshotSkillsOptions(env, options));
33745
+ const resolvedOptions = snapshotSkillsOptions(env, options);
33746
+ const assertFilesUnchanged = selectsSkillsLocalMode(snapshotEnv) ? () => {} : captureSkillsCredentialFiles(skillsProfileCredentialFiles(snapshotEnv, resolvedOptions.credentials?.profile));
33747
+ const fleet = resolveSkillsFleet(snapshotEnv, resolvedOptions);
33737
33748
  if (fleet.mode === "local" && env === process.env)
33738
33749
  noticeLocalSkillsMode();
33739
33750
  if (fleet.mode !== "hosted")
@@ -33963,7 +33974,9 @@ import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
33963
33974
 
33964
33975
  // src/lib/selection-cache.ts
33965
33976
  import { createHash as createHash3, randomUUID } from "crypto";
33966
- import { closeSync as closeSync5, constants as constants2, fstatSync as fstatSync5, fsyncSync, lstatSync as lstatSync3, mkdirSync as mkdirSync2, openSync as openSync5, readSync as readSync2, renameSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
33977
+ import { spawnSync as spawnSync2 } from "child_process";
33978
+ import { closeSync as closeSync5, constants as constants2, fstatSync as fstatSync5, fsyncSync, lstatSync as lstatSync3, mkdirSync as mkdirSync2, openSync as openSync5, readFileSync as readFileSync6, readlinkSync, readSync as readSync2, renameSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
33979
+ import { hostname } from "os";
33967
33980
  import { dirname as dirname3, join as join7, parse, resolve as resolve2 } from "path";
33968
33981
  import { isDeepStrictEqual } from "util";
33969
33982
 
@@ -35178,6 +35191,166 @@ function readSkillSessionSnapshot(sessionId, options = {}) {
35178
35191
  function skillSessionSnapshotBinding(snapshot) {
35179
35192
  return { sessionId: snapshot.sessionId, generation: snapshot.generation, receiptSha256: snapshot.receiptSha256 };
35180
35193
  }
35194
+ var SESSION_LOCK_MAX_BYTES = 4096;
35195
+ var SESSION_LOCK_MIN_AGE_MS = 30000;
35196
+ function localBootId() {
35197
+ try {
35198
+ if (process.platform === "linux") {
35199
+ const value = readFileSync6("/proc/sys/kernel/random/boot_id", "utf8").trim();
35200
+ return /^[a-f0-9-]{36}$/i.test(value) ? value : null;
35201
+ }
35202
+ if (process.platform === "darwin") {
35203
+ const result = spawnSync2("/usr/sbin/sysctl", ["-n", "kern.boottime"], { encoding: "utf8", timeout: 3000, env: { LC_ALL: "C" } });
35204
+ if (result.status !== 0 || result.error)
35205
+ return null;
35206
+ const seconds = /\bsec\s*=\s*(\d+)\b/.exec(result.stdout)?.[1];
35207
+ return seconds ? `darwin:${seconds}` : null;
35208
+ }
35209
+ } catch {}
35210
+ return null;
35211
+ }
35212
+ function processStart(pid) {
35213
+ if (!Number.isSafeInteger(pid) || pid <= 0)
35214
+ return { state: "unknown" };
35215
+ if (process.platform === "linux") {
35216
+ try {
35217
+ const stat = readFileSync6(`/proc/${pid}/stat`, "utf8");
35218
+ const close = stat.lastIndexOf(")");
35219
+ const start = close < 0 ? undefined : stat.slice(close + 2).trim().split(/\s+/)[19];
35220
+ return start && /^\d+$/.test(start) ? { state: "alive", start: `linux:${start}` } : { state: "unknown" };
35221
+ } catch (error) {
35222
+ return { state: error.code === "ENOENT" ? "absent" : "unknown" };
35223
+ }
35224
+ }
35225
+ if (process.platform === "darwin") {
35226
+ const result = spawnSync2("/bin/ps", ["-p", String(pid), "-o", "lstart="], { encoding: "utf8", timeout: 3000, env: { LC_ALL: "C" } });
35227
+ if (result.error || result.signal)
35228
+ return { state: "unknown" };
35229
+ const start = result.stdout.trim();
35230
+ if (result.status === 1 && !start && !result.stderr.trim())
35231
+ return { state: "absent" };
35232
+ return result.status === 0 && start ? { state: "alive", start: `darwin:${start}` } : { state: "unknown" };
35233
+ }
35234
+ return { state: "unknown" };
35235
+ }
35236
+ function localLockIdentity() {
35237
+ const bootId = localBootId(), owner = processStart(process.pid);
35238
+ if (!bootId || owner.state !== "alive")
35239
+ return null;
35240
+ let pidNamespace;
35241
+ if (process.platform === "linux") {
35242
+ try {
35243
+ pidNamespace = readlinkSync("/proc/self/ns/pid");
35244
+ } catch {
35245
+ return null;
35246
+ }
35247
+ if (!/^pid:\[\d+\]$/.test(pidNamespace))
35248
+ return null;
35249
+ }
35250
+ return { host: hostname(), bootId, pidNamespace, processStart: owner.start };
35251
+ }
35252
+ function readSessionLock(sessionId, options) {
35253
+ const path = `${sessionReceiptPath(sessionId, options)}.write-lock`;
35254
+ const before = lstatSync3(path, { throwIfNoEntry: false });
35255
+ if (!before)
35256
+ return null;
35257
+ if (!before.isFile() || before.nlink !== 1 || process.getuid && before.uid !== process.getuid()) {
35258
+ throw new SkillSelectionError("SESSION_WRITE_LOCKED", "The session lock is not a private regular file; recovery requires review.");
35259
+ }
35260
+ const bytes = readRegularFile(path, SESSION_LOCK_MAX_BYTES);
35261
+ const after = lstatSync3(path, { throwIfNoEntry: false });
35262
+ if (!bytes || !after?.isFile() || before.dev !== after.dev || before.ino !== after.ino || before.mtimeMs !== after.mtimeMs) {
35263
+ throw new SkillSelectionError("SESSION_WRITE_LOCKED", "The session lock changed during inspection; recovery requires review.");
35264
+ }
35265
+ let marker;
35266
+ try {
35267
+ marker = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
35268
+ } catch {
35269
+ throw new SkillSelectionError("SESSION_WRITE_LOCKED", "The session lock is unreadable; recovery requires review.");
35270
+ }
35271
+ if (!marker || ![1, 2].includes(marker.schemaVersion) || marker.sessionId !== sessionId || !/^[a-f0-9-]{36}$/i.test(marker.operationId) || !Number.isSafeInteger(marker.pid) || marker.pid <= 0 || marker.schemaVersion === 2 && (!marker.host || !marker.bootId || !marker.processStart || process.platform === "linux" && !marker.pidNamespace)) {
35272
+ throw new SkillSelectionError("SESSION_WRITE_LOCKED", "The session lock has invalid ownership metadata; recovery requires review.");
35273
+ }
35274
+ return { path, bytes, marker, sha256: sha256Hex(bytes), dev: after.dev, ino: after.ino, mtimeMs: after.mtimeMs };
35275
+ }
35276
+ function writerIsGone(lock, explicitLocalHost) {
35277
+ if (Date.now() - lock.mtimeMs < SESSION_LOCK_MIN_AGE_MS)
35278
+ return false;
35279
+ const owner = processStart(lock.marker.pid);
35280
+ if (owner.state === "unknown")
35281
+ return false;
35282
+ if (lock.marker.schemaVersion === 1)
35283
+ return explicitLocalHost && owner.state === "absent";
35284
+ const local = localLockIdentity();
35285
+ if (!local || lock.marker.host !== local.host || lock.marker.bootId !== local.bootId || lock.marker.pidNamespace !== local.pidNamespace)
35286
+ return false;
35287
+ return owner.state === "absent" || owner.state === "alive" && owner.start !== lock.marker.processStart;
35288
+ }
35289
+ function archiveSessionLock(lock, receipt, explicitLocalHost) {
35290
+ const guardPath = `${lock.path}.recovery-guard`;
35291
+ let guardFd;
35292
+ try {
35293
+ guardFd = openSync5(guardPath, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
35294
+ } catch (error) {
35295
+ if (error.code === "EEXIST")
35296
+ return null;
35297
+ throw error;
35298
+ }
35299
+ const guardStat = fstatSync5(guardFd);
35300
+ try {
35301
+ writeFileSync2(guardFd, `${JSON.stringify({ schemaVersion: 1, pid: process.pid, operationId: randomUUID() })}
35302
+ `);
35303
+ fsyncSync(guardFd);
35304
+ const cacheOptions = { cacheDir: dirname3(dirname3(lock.path)) };
35305
+ const current = readSessionLock(lock.marker.sessionId, cacheOptions);
35306
+ if (!current || current.dev !== lock.dev || current.ino !== lock.ino || current.sha256 !== lock.sha256 || current.mtimeMs !== lock.mtimeMs || !writerIsGone(current, explicitLocalHost))
35307
+ return null;
35308
+ const currentReceipt = readSkillSessionSnapshotIfExists(lock.marker.sessionId, cacheOptions);
35309
+ if (currentReceipt?.sha256 !== receipt?.sha256 || currentReceipt?.generation !== receipt?.generation)
35310
+ return null;
35311
+ const directory = join7(dirname3(dirname3(lock.path)), "session-lock-recoveries", randomUUID());
35312
+ const archivePath = join7(directory, "original.write-lock");
35313
+ const recordPath = join7(directory, "recovery.json");
35314
+ assertRegularPath(archivePath, true);
35315
+ archiveBytes(recordPath, Buffer.from(`${JSON.stringify({
35316
+ schemaVersion: 1,
35317
+ sessionId: lock.marker.sessionId,
35318
+ originalPath: lock.path,
35319
+ lockSha256: lock.sha256,
35320
+ lockMtime: new Date(lock.mtimeMs).toISOString(),
35321
+ lockPid: lock.marker.pid,
35322
+ receiptSha256: receipt?.sha256 ?? null,
35323
+ receiptGeneration: receipt?.generation ?? null,
35324
+ status: "prepared"
35325
+ })}
35326
+ `));
35327
+ syncDirectory(directory);
35328
+ syncDirectory(dirname3(directory));
35329
+ const finalLock = readSessionLock(lock.marker.sessionId, cacheOptions);
35330
+ if (!finalLock || finalLock.dev !== lock.dev || finalLock.ino !== lock.ino || finalLock.sha256 !== lock.sha256 || readSkillSessionSnapshotIfExists(lock.marker.sessionId, cacheOptions)?.sha256 !== receipt?.sha256)
35331
+ return null;
35332
+ let moved = false;
35333
+ try {
35334
+ renameSync(lock.path, archivePath);
35335
+ moved = true;
35336
+ syncDirectory(directory);
35337
+ syncDirectory(dirname3(lock.path));
35338
+ if (sha256Hex(readRegularFile(archivePath, SESSION_LOCK_MAX_BYTES)) !== lock.sha256) {
35339
+ throw new Error("Archived lock bytes changed");
35340
+ }
35341
+ } catch (error) {
35342
+ if (moved)
35343
+ throw new SkillSelectionError("SESSION_LOCK_RECOVERY_INCOMPLETE", "The lock moved, but durable recovery could not be confirmed; inspect the preserved recovery directory and session receipt.");
35344
+ throw error;
35345
+ }
35346
+ return archivePath;
35347
+ } finally {
35348
+ closeSync5(guardFd);
35349
+ const current = lstatSync3(guardPath, { throwIfNoEntry: false });
35350
+ if (current?.isFile() && current.dev === guardStat.dev && current.ino === guardStat.ino)
35351
+ unlinkSync(guardPath);
35352
+ }
35353
+ }
35181
35354
  function withSessionWriteLocks(sessionIds, options, action) {
35182
35355
  const operationId = randomUUID();
35183
35356
  const locks = [...new Set(sessionIds)].map((sessionId) => ({ sessionId, path: `${sessionReceiptPath(sessionId, options)}.write-lock` })).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
@@ -35197,13 +35370,30 @@ function withSessionWriteLocks(sessionIds, options, action) {
35197
35370
  try {
35198
35371
  fd = openSync5(lock.path, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
35199
35372
  } catch (error) {
35200
- if (error.code === "EEXIST")
35201
- throw new SkillSelectionError("SESSION_WRITE_LOCKED", "Another Skills process owns a required session write lock; retry after it completes. A surviving lock requires explicit recovery review.");
35202
- throw error;
35373
+ if (error.code !== "EEXIST")
35374
+ throw error;
35375
+ try {
35376
+ const stale = readSessionLock(lock.sessionId, options);
35377
+ const receipt = stale && readSkillSessionSnapshotIfExists(lock.sessionId, options);
35378
+ if (stale?.marker.schemaVersion === 2 && writerIsGone(stale, false)) {
35379
+ archiveSessionLock(stale, receipt, false);
35380
+ }
35381
+ } catch (recoveryError) {
35382
+ if (recoveryError instanceof SkillSelectionError && recoveryError.code === "SESSION_LOCK_RECOVERY_INCOMPLETE")
35383
+ throw recoveryError;
35384
+ }
35385
+ try {
35386
+ fd = openSync5(lock.path, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
35387
+ } catch (retryError) {
35388
+ if (retryError.code === "EEXIST")
35389
+ throw new SkillSelectionError("SESSION_WRITE_LOCKED", "Another Skills process owns a required session write lock; retry after it completes. A surviving legacy lock requires explicit recovery review.");
35390
+ throw retryError;
35391
+ }
35203
35392
  }
35204
35393
  const stat = fstatSync5(fd);
35205
35394
  owned.push({ path: lock.path, fd, dev: stat.dev, ino: stat.ino });
35206
- writeFileSync2(fd, `${JSON.stringify({ schemaVersion: 1, operationId, sessionId: lock.sessionId, pid: process.pid })}
35395
+ const identity = localLockIdentity();
35396
+ writeFileSync2(fd, `${JSON.stringify({ schemaVersion: identity ? 2 : 1, operationId, sessionId: lock.sessionId, pid: process.pid, ...identity })}
35207
35397
  `);
35208
35398
  }
35209
35399
  return action(assertOwned);
@@ -35330,8 +35520,8 @@ import { hostname as stationHostname } from "os";
35330
35520
 
35331
35521
  // node_modules/@hasna/secrets/dist/sdk.js
35332
35522
  import { isIP as isIP2 } from "net";
35333
- import { spawnSync as spawnSync2 } from "child_process";
35334
- import { closeSync as closeSync6, fstatSync as fstatSync6, openSync as openSync6, readFileSync as readFileSync6 } from "fs";
35523
+ import { spawnSync as spawnSync3 } from "child_process";
35524
+ import { closeSync as closeSync6, fstatSync as fstatSync6, openSync as openSync6, readFileSync as readFileSync7 } from "fs";
35335
35525
  import { O_NOFOLLOW as O_NOFOLLOW3, O_NONBLOCK as O_NONBLOCK3, O_RDONLY as O_RDONLY3 } from "constants";
35336
35526
  import { createRequire as createRequire2 } from "module";
35337
35527
  import { hostname as osHostname2 } from "os";
@@ -35458,7 +35648,7 @@ function readAppConfigFile2(path) {
35458
35648
  unsafe("the file is not owned by the current user");
35459
35649
  if (before.size > MAX_CREDENTIAL_FILE_BYTES2)
35460
35650
  unsafe("the file exceeds the size limit");
35461
- const bytes = readFileSync6(fd);
35651
+ const bytes = readFileSync7(fd);
35462
35652
  const after = fstatSync6(fd);
35463
35653
  if (!configFileReadsCoherent2(before, after)) {
35464
35654
  unsafe("the file changed while being read");
@@ -35606,7 +35796,7 @@ function isAmbientEnvironment2(env) {
35606
35796
  return env === process.env || env[AMBIENT_ENVIRONMENT2] === true;
35607
35797
  }
35608
35798
  function defaultKeychainRunner2(argv) {
35609
- const result = spawnSync2(KEYCHAIN_SECURITY_BIN2, [...argv], {
35799
+ const result = spawnSync3(KEYCHAIN_SECURITY_BIN2, [...argv], {
35610
35800
  encoding: "utf8",
35611
35801
  stdio: ["ignore", "pipe", "pipe"],
35612
35802
  timeout: KEYCHAIN_SPAWN_TIMEOUT_MS2
@@ -37252,7 +37442,7 @@ import { dirname as dirname19, join as join31, resolve as resolve17 } from "path
37252
37442
  import { tmpdir, hostname as stationHostname2 } from "os";
37253
37443
 
37254
37444
  // src/lib/dependency-preparation.ts
37255
- import { constants as constants4, closeSync as closeSync8, fstatSync as fstatSync8, lstatSync as lstatSync4, mkdirSync as mkdirSync3, openSync as openSync8, readFileSync as readFileSync7, readdirSync as readdirSync2, rmdirSync, unlinkSync as unlinkSync2, ftruncateSync, writeSync } from "fs";
37445
+ import { constants as constants4, closeSync as closeSync8, fstatSync as fstatSync8, lstatSync as lstatSync4, mkdirSync as mkdirSync3, openSync as openSync8, readFileSync as readFileSync8, readdirSync as readdirSync2, rmdirSync, unlinkSync as unlinkSync2, ftruncateSync, writeSync } from "fs";
37256
37446
  import { join as join9 } from "path";
37257
37447
 
37258
37448
  // src/lib/preparation-process.ts
@@ -37326,7 +37516,7 @@ function claimPreparation(skillPath) {
37326
37516
  return;
37327
37517
  if (!lstatSync4(state).isFile() || lstatSync4(state).isSymbolicLink() || lstatSync4(state).size > 1024)
37328
37518
  return;
37329
- const previous = JSON.parse(readFileSync7(state, "utf8"));
37519
+ const previous = JSON.parse(readFileSync8(state, "utf8"));
37330
37520
  if (previous.version !== 1 || previous.status !== "failed" || Object.keys(previous).length !== 2)
37331
37521
  return;
37332
37522
  }
@@ -37459,11 +37649,11 @@ async function prepareSkillDependencies(skillPath, env, timeoutMs = DEFAULT_PREP
37459
37649
  }
37460
37650
 
37461
37651
  // src/lib/skillinfo.ts
37462
- import { existsSync as existsSync14, readFileSync as readFileSync20 } from "fs";
37652
+ import { existsSync as existsSync14, readFileSync as readFileSync21 } from "fs";
37463
37653
  import { join as join30 } from "path";
37464
37654
 
37465
37655
  // src/lib/installer.ts
37466
- import { existsSync as existsSync13, readFileSync as readFileSync19, rmSync as rmSync4 } from "fs";
37656
+ import { existsSync as existsSync13, readFileSync as readFileSync20, rmSync as rmSync4 } from "fs";
37467
37657
  import { join as join29 } from "path";
37468
37658
  import { homedir as homedir6 } from "os";
37469
37659
 
@@ -37474,7 +37664,7 @@ import {
37474
37664
  lstatSync as lstatSync21,
37475
37665
  mkdirSync as mkdirSync8,
37476
37666
  mkdtempSync as mkdtempSync2,
37477
- readFileSync as readFileSync16,
37667
+ readFileSync as readFileSync17,
37478
37668
  readdirSync as readdirSync10,
37479
37669
  renameSync as renameSync5,
37480
37670
  rmSync as rmSync3,
@@ -37505,7 +37695,7 @@ var NATIVE_SKILL_ROOTS = [
37505
37695
 
37506
37696
  // src/lib/agent-integration.ts
37507
37697
  import { createHash as createHash16, randomUUID as randomUUID3 } from "crypto";
37508
- import { existsSync as existsSync6, lstatSync as lstatSync18, statSync as statSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync13, readdirSync as readdirSync7, opendirSync as opendirSync5, readlinkSync as readlinkSync2, realpathSync as realpathSync4, renameSync as renameSync3, rmdirSync as rmdirSync3, writeFileSync as writeFileSync4, unlinkSync as unlinkSync4, chmodSync, openSync as openSync16, closeSync as closeSync16, fsyncSync as fsyncSync4, fstatSync as fstatSync16, readSync as readSync11, constants as constants12, linkSync as linkSync2 } from "fs";
37698
+ import { existsSync as existsSync6, lstatSync as lstatSync18, statSync as statSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync14, readdirSync as readdirSync7, opendirSync as opendirSync5, readlinkSync as readlinkSync3, realpathSync as realpathSync4, renameSync as renameSync3, rmdirSync as rmdirSync3, writeFileSync as writeFileSync4, unlinkSync as unlinkSync4, chmodSync, openSync as openSync16, closeSync as closeSync16, fsyncSync as fsyncSync4, fstatSync as fstatSync16, readSync as readSync11, constants as constants12, linkSync as linkSync2 } from "fs";
37509
37699
  import { dirname as dirname14, join as join21, resolve as resolve14, relative as relative3, isAbsolute as isAbsolute15, sep as sep4 } from "path";
37510
37700
  import { homedir as homedir3 } from "os";
37511
37701
 
@@ -37694,7 +37884,7 @@ function requiresCliSkillLoading(dataDir2 = getDataDirReadOnly()) {
37694
37884
 
37695
37885
  // src/lib/agent-bridge.ts
37696
37886
  import { createHash as createHash5 } from "crypto";
37697
- import { lstatSync as lstatSync6, readFileSync as readFileSync8, readdirSync as readdirSync3 } from "fs";
37887
+ import { lstatSync as lstatSync6, readFileSync as readFileSync9, readdirSync as readdirSync3 } from "fs";
37698
37888
  import { join as join11 } from "path";
37699
37889
  var CLI_BRIDGE_NAME = "skills-cli";
37700
37890
  var CLI_BRIDGE_VERSION = 1;
@@ -37728,7 +37918,7 @@ function isOwnedCliBridge(path, expectedPaths) {
37728
37918
  return false;
37729
37919
  return Object.entries(CLI_BRIDGE_FILES).every(([name, content]) => {
37730
37920
  const file = join11(path, name), stat = lstatSync6(file);
37731
- return stat.isFile() && !stat.isSymbolicLink() && stat.size === Buffer.byteLength(content) && readFileSync8(file, "utf8") === content;
37921
+ return stat.isFile() && !stat.isSymbolicLink() && stat.size === Buffer.byteLength(content) && readFileSync9(file, "utf8") === content;
37732
37922
  });
37733
37923
  } catch {
37734
37924
  return false;
@@ -37737,7 +37927,7 @@ function isOwnedCliBridge(path, expectedPaths) {
37737
37927
 
37738
37928
  // src/lib/agent-discovery.ts
37739
37929
  import { createHash as createHash15 } from "crypto";
37740
- import { lstatSync as lstatSync17, readFileSync as readFileSync12, readdirSync as readdirSync6, realpathSync as realpathSync3 } from "fs";
37930
+ import { lstatSync as lstatSync17, readFileSync as readFileSync13, readdirSync as readdirSync6, realpathSync as realpathSync3 } from "fs";
37741
37931
  import { basename as basename6, dirname as dirname13, isAbsolute as isAbsolute14, join as join20, resolve as resolve13, sep as sep3 } from "path";
37742
37932
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
37743
37933
 
@@ -37789,7 +37979,7 @@ var $visitAsync = visit.visitAsync;
37789
37979
 
37790
37980
  // src/lib/agent-hermes.ts
37791
37981
  import { dirname as dirname4, isAbsolute as isAbsolute4, join as join12, resolve as resolve4 } from "path";
37792
- import { lstatSync as lstatSync7, readFileSync as readFileSync9, opendirSync } from "fs";
37982
+ import { lstatSync as lstatSync7, readFileSync as readFileSync10, opendirSync } from "fs";
37793
37983
  var HERMES_OPT_OUT = ".no-bundled-skills";
37794
37984
  var EVENTS = ["pre_llm_call", "pre_tool_call"];
37795
37985
  function object3(value) {
@@ -37879,7 +38069,7 @@ function read(path) {
37879
38069
  return null;
37880
38070
  if (!stat.isFile() || stat.size > 1024 * 1024)
37881
38071
  throw new Error("NATIVE_SKILL_DRIFT: invalid Hermes protection input");
37882
- return readFileSync9(path, "utf8");
38072
+ return readFileSync10(path, "utf8");
37883
38073
  }
37884
38074
  function assertHermesProtection(home, config, command, profile, supervisor) {
37885
38075
  assertHermesEnvironment(home);
@@ -38135,7 +38325,7 @@ function hashRawDiscoveryFile(path, budget, changes) {
38135
38325
 
38136
38326
  // src/lib/agent-discovery-path-bytes.ts
38137
38327
  import { createHash as createHash8 } from "crypto";
38138
- import { lstatSync as lstatSync10, readlinkSync } from "fs";
38328
+ import { lstatSync as lstatSync10, readlinkSync as readlinkSync2 } from "fs";
38139
38329
  import { dirname as dirname7, isAbsolute as isAbsolute7, join as join14, parse as parse2, resolve as resolve7, sep as sep2 } from "path";
38140
38330
  function identity2(stat, mutable = false) {
38141
38331
  return {
@@ -38191,7 +38381,7 @@ function trace(path) {
38191
38381
  if (stat.isSymbolicLink()) {
38192
38382
  if (++links > AGENT_POLICY_LIMITS.discoveryPathLinks || stat.size > BigInt(AGENT_POLICY_LIMITS.pathCharacters))
38193
38383
  throw new Error("Discovery path link limit exceeded");
38194
- const rawTarget = readlinkSync(candidate, { encoding: "buffer" }), target = rawTarget.toString("utf8"), after = lstatSync10(candidate, { bigint: true });
38384
+ const rawTarget = readlinkSync2(candidate, { encoding: "buffer" }), target = rawTarget.toString("utf8"), after = lstatSync10(candidate, { bigint: true });
38195
38385
  if (!rawTarget.equals(Buffer.from(target, "utf8")))
38196
38386
  throw new Error("Unsupported non-UTF8 discovery link target");
38197
38387
  if (!target || target.includes("\x00") || Buffer.byteLength(target) > AGENT_POLICY_LIMITS.pathCharacters || !after.isSymbolicLink() || JSON.stringify(identity2(stat, true)) !== JSON.stringify(identity2(after, true)))
@@ -38821,11 +39011,11 @@ function pluginExecutableDigest(path) {
38821
39011
  }
38822
39012
 
38823
39013
  // src/lib/skill-validation.ts
38824
- import { existsSync as existsSync5, lstatSync as lstatSync12, readFileSync as readFileSync11, readdirSync as readdirSync5, statSync as statSync4 } from "fs";
39014
+ import { existsSync as existsSync5, lstatSync as lstatSync12, readFileSync as readFileSync12, readdirSync as readdirSync5, statSync as statSync4 } from "fs";
38825
39015
  import { isAbsolute as isAbsolute9, join as join17, normalize } from "path";
38826
39016
 
38827
39017
  // src/lib/hosted-skill-set.ts
38828
- import { existsSync as existsSync4, readFileSync as readFileSync10, readdirSync as readdirSync4, statSync as statSync3 } from "fs";
39018
+ import { existsSync as existsSync4, readFileSync as readFileSync11, readdirSync as readdirSync4, statSync as statSync3 } from "fs";
38829
39019
  import { join as join16 } from "path";
38830
39020
  var HOSTED_RUNTIMES = new Set(["hosted"]);
38831
39021
  var HOSTED_SOURCES = new Set(["remote", "private-hosted"]);
@@ -38843,7 +39033,7 @@ function isHostedMetadataSkillDir(skillDir) {
38843
39033
  if (!existsSync4(pkgPath))
38844
39034
  return false;
38845
39035
  try {
38846
- return isHostedMetadataPackage(JSON.parse(readFileSync10(pkgPath, "utf8")));
39036
+ return isHostedMetadataPackage(JSON.parse(readFileSync11(pkgPath, "utf8")));
38847
39037
  } catch {
38848
39038
  return false;
38849
39039
  }
@@ -38917,7 +39107,7 @@ function add(target, code, message) {
38917
39107
  target.push({ code, message });
38918
39108
  }
38919
39109
  function readJsonFile(path) {
38920
- return JSON.parse(readFileSync11(path, "utf-8"));
39110
+ return JSON.parse(readFileSync12(path, "utf-8"));
38921
39111
  }
38922
39112
  function asRecord(value) {
38923
39113
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
@@ -39075,7 +39265,7 @@ function validateSkillDirectory(name, skillPath, registryMeta) {
39075
39265
  }
39076
39266
  const skillMdPath = join17(skillPath, "SKILL.md");
39077
39267
  if (existsSync5(skillMdPath)) {
39078
- const frontmatter = parseSkillFrontmatter(readFileSync11(skillMdPath, "utf-8"));
39268
+ const frontmatter = parseSkillFrontmatter(readFileSync12(skillMdPath, "utf-8"));
39079
39269
  if (!frontmatter) {
39080
39270
  add(warnings, "skill.frontmatter_missing", "SKILL.md has no YAML frontmatter");
39081
39271
  } else {
@@ -40376,7 +40566,7 @@ function read2(path, changes) {
40376
40566
  return null;
40377
40567
  if (!stat2.isFile() || stat2.size > 16 * 1024 * 1024)
40378
40568
  throw new Error(`Unsupported or oversized native discovery input: ${path}`);
40379
- return readFileSync12(path, "utf8");
40569
+ return readFileSync13(path, "utf8");
40380
40570
  }
40381
40571
  function projected(source, changes, budget = discoveryByteBudget()) {
40382
40572
  if (source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || source.hashMode === "claude-settings-v3") {
@@ -40882,7 +41072,7 @@ function readRootAlias(home, agent) {
40882
41072
  const stat2 = lstatSync18(alias, { throwIfNoEntry: false, bigint: true });
40883
41073
  if (!stat2?.isSymbolicLink())
40884
41074
  throw new Error(`Agent root alias changed after planning: ${alias}`);
40885
- const link = readlinkSync2(alias), targetPath = resolve14(dirname14(alias), link);
41075
+ const link = readlinkSync3(alias), targetPath = resolve14(dirname14(alias), link);
40886
41076
  assertSafePath(targetPath);
40887
41077
  const targetStat = lstatSync18(targetPath, { throwIfNoEntry: false });
40888
41078
  if (!targetStat?.isDirectory())
@@ -41035,7 +41225,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
41035
41225
  throw new Error("Native skill discovery metadata limit exceeded");
41036
41226
  }
41037
41227
  function emptySiblingCacheAlias(path, parent) {
41038
- const link = readlinkSync2(path), target = resolve14(parent, link);
41228
+ const link = readlinkSync3(path), target = resolve14(parent, link);
41039
41229
  if (dirname14(target) !== parent || (isAbsolute15(link) ? link !== target : dirname14(link) !== "."))
41040
41230
  return false;
41041
41231
  if (!lstatSync18(target, { throwIfNoEntry: false })?.isDirectory())
@@ -41064,7 +41254,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
41064
41254
  const marker = join21(path, ".hasna-skills.json");
41065
41255
  if (existsSync6(marker)) {
41066
41256
  try {
41067
- managed = JSON.parse(readFileSync13(marker, "utf8")).managedBy === "@hasna/skills";
41257
+ managed = JSON.parse(readFileSync14(marker, "utf8")).managedBy === "@hasna/skills";
41068
41258
  } catch {}
41069
41259
  }
41070
41260
  const bridge = !vendor && isOwnedCliBridge(path, bridgePaths);
@@ -41137,7 +41327,7 @@ function inventoryNativeSkills(home = homedir3(), options = {}) {
41137
41327
  }
41138
41328
  function readOptional(path) {
41139
41329
  assertSafePath(path);
41140
- return existsSync6(path) ? readFileSync13(path, "utf8") : null;
41330
+ return existsSync6(path) ? readFileSync14(path, "utf8") : null;
41141
41331
  }
41142
41332
  function jsonObject(text2, path) {
41143
41333
  if (text2 === null)
@@ -41851,7 +42041,7 @@ var SKILLS = [];
41851
42041
 
41852
42042
  // src/lib/skill-hash.ts
41853
42043
  import { createHash as createHash17 } from "crypto";
41854
- import { existsSync as existsSync7, readdirSync as readdirSync8, readFileSync as readFileSync14, statSync as statSync6 } from "fs";
42044
+ import { existsSync as existsSync7, readdirSync as readdirSync8, readFileSync as readFileSync15, statSync as statSync6 } from "fs";
41855
42045
  import { join as join22, sep as sep5 } from "path";
41856
42046
  var CONTENT_HASH_ALGORITHM = "sha256";
41857
42047
  var HASH_EXCLUDE_DIRS = new Set([".git", "node_modules", "dist", "build", ".turbo"]);
@@ -41948,7 +42138,7 @@ function collectDirectory(files, dir, rel) {
41948
42138
  }
41949
42139
  }
41950
42140
  function collectFile(files, absolute, rel) {
41951
- const buffer = readFileSync14(absolute);
42141
+ const buffer = readFileSync15(absolute);
41952
42142
  files.push(normalizeBundleFile(rel.split(sep5).join("/"), buffer));
41953
42143
  }
41954
42144
  function normalizeBundleFile(rel, buffer) {
@@ -42365,7 +42555,7 @@ import {
42365
42555
  existsSync as existsSync8,
42366
42556
  lstatSync as lstatSync19,
42367
42557
  mkdirSync as mkdirSync6,
42368
- readFileSync as readFileSync15,
42558
+ readFileSync as readFileSync16,
42369
42559
  realpathSync as realpathSync5,
42370
42560
  writeFileSync as writeFileSync5
42371
42561
  } from "fs";
@@ -42430,7 +42620,7 @@ function readManifest(skillPath, fallbackName, normalizeName) {
42430
42620
  const skillMdPath = join23(skillPath, "SKILL.md");
42431
42621
  const pkgPath = join23(skillPath, "package.json");
42432
42622
  const jsonManifest = existsSync8(skillJsonPath) ? readJsonObject(skillJsonPath) : undefined;
42433
- const frontmatter = existsSync8(skillMdPath) ? parseSkillFrontmatter(readFileSync15(skillMdPath, "utf-8")) ?? undefined : undefined;
42623
+ const frontmatter = existsSync8(skillMdPath) ? parseSkillFrontmatter(readFileSync16(skillMdPath, "utf-8")) ?? undefined : undefined;
42434
42624
  const pkg = existsSync8(pkgPath) ? readJsonObject(pkgPath) : undefined;
42435
42625
  const name = normalizeName(stringField(jsonManifest, "name") ?? frontmatter?.name ?? stringValue(pkg?.name) ?? fallbackName);
42436
42626
  const description = stringField(jsonManifest, "description") ?? frontmatter?.description ?? stringValue(pkg?.description) ?? `${name} skill`;
@@ -42464,7 +42654,7 @@ function readDeclaredSkillVersion(skillPath) {
42464
42654
  const skillMdPath = join23(skillPath, "SKILL.md");
42465
42655
  const pkgPath = join23(skillPath, "package.json");
42466
42656
  const jsonManifest = existsSync8(skillJsonPath) ? readJsonObject(skillJsonPath) : undefined;
42467
- const frontmatter = existsSync8(skillMdPath) ? parseSkillFrontmatter(readFileSync15(skillMdPath, "utf-8")) ?? undefined : undefined;
42657
+ const frontmatter = existsSync8(skillMdPath) ? parseSkillFrontmatter(readFileSync16(skillMdPath, "utf-8")) ?? undefined : undefined;
42468
42658
  const pkg = existsSync8(pkgPath) ? readJsonObject(pkgPath) : undefined;
42469
42659
  return stringField(jsonManifest, "version") ?? frontmatter?.version ?? stringValue(pkg?.version);
42470
42660
  }
@@ -42585,7 +42775,7 @@ function readExistingSkillJson(skillPath) {
42585
42775
  if (!existsSync8(path))
42586
42776
  return {};
42587
42777
  try {
42588
- const parsed = JSON.parse(readFileSync15(path, "utf-8"));
42778
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
42589
42779
  return isRecord2(parsed) ? parsed : {};
42590
42780
  } catch {
42591
42781
  return {};
@@ -42622,7 +42812,7 @@ function ensurePortableSkillFiles(skillPath, manifest) {
42622
42812
  if (!existsSync8(join23(skillPath, "SKILL.md")))
42623
42813
  writeFileSync5(join23(skillPath, "SKILL.md"), renderSkillMd(next));
42624
42814
  else
42625
- writeFileSync5(join23(skillPath, "SKILL.md"), ensureSkillMdFrontmatter(readFileSync15(join23(skillPath, "SKILL.md"), "utf-8"), next));
42815
+ writeFileSync5(join23(skillPath, "SKILL.md"), ensureSkillMdFrontmatter(readFileSync16(join23(skillPath, "SKILL.md"), "utf-8"), next));
42626
42816
  if (!existsSync8(join23(skillPath, "AGENTS.md")))
42627
42817
  writeFileSync5(join23(skillPath, "AGENTS.md"), renderAgentsMd(next));
42628
42818
  ensurePackageJson(skillPath, next);
@@ -42683,7 +42873,7 @@ function ensureInstructionSkillFiles(skillPath, manifest) {
42683
42873
  writeFileSync5(join23(skillPath, "SKILL.md"), renderSkillMd(next));
42684
42874
  } else {
42685
42875
  const path = join23(skillPath, "SKILL.md");
42686
- const content = readFileSync15(path, "utf8");
42876
+ const content = readFileSync16(path, "utf8");
42687
42877
  const declaredName = parseSkillFrontmatter(content)?.name;
42688
42878
  if (declaredName && declaredName !== next.name) {
42689
42879
  writeFileSync5(path, renameInstructionFrontmatter(content, next.name));
@@ -42975,7 +43165,7 @@ function inferRuntimeFromCommands(commands) {
42975
43165
  return { ...defaultRuntimeContract(entrypoint), runtime: "python3" };
42976
43166
  }
42977
43167
  function readJsonObject(path) {
42978
- const parsed = JSON.parse(readFileSync15(path, "utf-8"));
43168
+ const parsed = JSON.parse(readFileSync16(path, "utf-8"));
42979
43169
  if (!isRecord2(parsed))
42980
43170
  throw new Error(`${basename7(path)} must contain a JSON object`);
42981
43171
  return parsed;
@@ -43574,7 +43764,7 @@ function hasSkillsOwnershipMarker(dir) {
43574
43764
  try {
43575
43765
  if (!lstatSync21(path).isFile())
43576
43766
  return false;
43577
- const marker = JSON.parse(readFileSync16(path, "utf8"));
43767
+ const marker = JSON.parse(readFileSync17(path, "utf8"));
43578
43768
  return isSkillsOwnershipMarker(marker);
43579
43769
  } catch {
43580
43770
  return false;
@@ -43783,7 +43973,7 @@ function writeManagedSkillDir(dir, skillMd, options) {
43783
43973
  if (dirExists && managed && hasSkillMd && !options.force && isPointerSkillMd(skillMd)) {
43784
43974
  let existingIsStub = false;
43785
43975
  try {
43786
- existingIsStub = isPointerSkillMd(readFileSync16(skillMdPath, "utf-8"));
43976
+ existingIsStub = isPointerSkillMd(readFileSync17(skillMdPath, "utf-8"));
43787
43977
  } catch {
43788
43978
  existingIsStub = false;
43789
43979
  }
@@ -43863,7 +44053,7 @@ function sourceSkillMd(skillPath, name, description, kind, preferBundledDocs = f
43863
44053
  if (kind === undefined || kind === "instruction" || preferBundledDocs) {
43864
44054
  const skillMdPath = join26(skillPath, "SKILL.md");
43865
44055
  if (existsSync10(skillMdPath))
43866
- return readFileSync16(skillMdPath, "utf-8");
44056
+ return readFileSync17(skillMdPath, "utf-8");
43867
44057
  }
43868
44058
  return pointerSkillMd(name, description);
43869
44059
  }
@@ -43893,7 +44083,7 @@ function normalizeSkillName(name) {
43893
44083
  }
43894
44084
 
43895
44085
  // src/lib/registry.ts
43896
- import { existsSync as existsSync11, readFileSync as readFileSync17, readdirSync as readdirSync11 } from "fs";
44086
+ import { existsSync as existsSync11, readFileSync as readFileSync18, readdirSync as readdirSync11 } from "fs";
43897
44087
  import { join as join27 } from "path";
43898
44088
 
43899
44089
  // src/lib/registry-merge.ts
@@ -44109,7 +44299,7 @@ function discoverSkillsInDir(dir, source = "custom") {
44109
44299
  continue;
44110
44300
  let content;
44111
44301
  try {
44112
- content = readFileSync17(skillMdPath, "utf-8");
44302
+ content = readFileSync18(skillMdPath, "utf-8");
44113
44303
  } catch {
44114
44304
  continue;
44115
44305
  }
@@ -44146,7 +44336,7 @@ function findExtensionSkillPath(name) {
44146
44336
  continue;
44147
44337
  let content;
44148
44338
  try {
44149
- content = readFileSync17(skillMdPath, "utf-8");
44339
+ content = readFileSync18(skillMdPath, "utf-8");
44150
44340
  } catch {
44151
44341
  continue;
44152
44342
  }
@@ -44211,7 +44401,7 @@ function getAllTags() {
44211
44401
  }
44212
44402
 
44213
44403
  // src/lib/project-state.ts
44214
- import { existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "fs";
44404
+ import { existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync19, writeFileSync as writeFileSync8 } from "fs";
44215
44405
  import { join as join28 } from "path";
44216
44406
  var VALID_PIN_SOURCES = [
44217
44407
  "official",
@@ -44237,7 +44427,7 @@ function loadProjectConfig(targetDir = process.cwd()) {
44237
44427
  if (!existsSync12(path))
44238
44428
  return null;
44239
44429
  try {
44240
- return normalizeProjectConfig(JSON.parse(readFileSync18(path, "utf-8")));
44430
+ return normalizeProjectConfig(JSON.parse(readFileSync19(path, "utf-8")));
44241
44431
  } catch {
44242
44432
  return null;
44243
44433
  }
@@ -44424,7 +44614,7 @@ function createLocalSkillManifest(name, generateSkillMd) {
44424
44614
  let skillMd = "";
44425
44615
  const skillMdPath = join29(sourcePath, "SKILL.md");
44426
44616
  if (existsSync13(skillMdPath)) {
44427
- skillMd = readFileSync19(skillMdPath, "utf-8");
44617
+ skillMd = readFileSync20(skillMdPath, "utf-8");
44428
44618
  } else if (generateSkillMd) {
44429
44619
  skillMd = generateSkillMd(name) ?? "";
44430
44620
  } else {
@@ -44543,7 +44733,7 @@ function resolveAgentSkillMd(name, generateSkillMd) {
44543
44733
  const sourcePath = getSkillPath(name);
44544
44734
  const skillMdPath = join29(sourcePath, "SKILL.md");
44545
44735
  if (existsSync13(skillMdPath))
44546
- return readFileSync19(skillMdPath, "utf-8");
44736
+ return readFileSync20(skillMdPath, "utf-8");
44547
44737
  if (generateSkillMd)
44548
44738
  return generateSkillMd(name);
44549
44739
  return generateMinimalSkillMd(name);
@@ -44599,14 +44789,14 @@ function readBundledSkillVersion(name) {
44599
44789
  if (!existsSync13(pkgPath))
44600
44790
  return "unknown";
44601
44791
  try {
44602
- const pkg = JSON.parse(readFileSync19(pkgPath, "utf-8"));
44792
+ const pkg = JSON.parse(readFileSync20(pkgPath, "utf-8"));
44603
44793
  return pkg.version || "unknown";
44604
44794
  } catch {
44605
44795
  return "unknown";
44606
44796
  }
44607
44797
  }
44608
44798
  function readFileIfExists(path) {
44609
- return existsSync13(path) ? readFileSync19(path, "utf-8") : null;
44799
+ return existsSync13(path) ? readFileSync20(path, "utf-8") : null;
44610
44800
  }
44611
44801
  function loadProjectConfigCompat(targetDir) {
44612
44802
  return loadProjectConfig(targetDir);
@@ -44654,7 +44844,7 @@ function isInstructionSkillDir(skillPath, meta) {
44654
44844
  if (!existsSync14(skillMdPath))
44655
44845
  return false;
44656
44846
  try {
44657
- return parseSkillFrontmatter(readFileSync20(skillMdPath, "utf-8"))?.kind === "instruction";
44847
+ return parseSkillFrontmatter(readFileSync21(skillMdPath, "utf-8"))?.kind === "instruction";
44658
44848
  } catch {
44659
44849
  return false;
44660
44850
  }
@@ -44705,7 +44895,7 @@ function getSkillRequirements(name) {
44705
44895
  const meta = getSkill(name);
44706
44896
  let dependencies = {};
44707
44897
  try {
44708
- dependencies = JSON.parse(readFileSync20(join30(skillPath, "package.json"), "utf8")).dependencies || {};
44898
+ dependencies = JSON.parse(readFileSync21(join30(skillPath, "package.json"), "utf8")).dependencies || {};
44709
44899
  } catch {}
44710
44900
  return getSkillRequirementsFromContent(name, texts, dependencies, meta);
44711
44901
  }
@@ -44773,7 +44963,7 @@ async function runSkill(name, args, options = {}) {
44773
44963
  }
44774
44964
  let entryPoint2;
44775
44965
  try {
44776
- const pkg = JSON.parse(readFileSync20(pkgPath, "utf-8"));
44966
+ const pkg = JSON.parse(readFileSync21(pkgPath, "utf-8"));
44777
44967
  if (pkg.bin) {
44778
44968
  const binValues = Object.values(pkg.bin);
44779
44969
  entryPoint2 = binValues[0];
@@ -44876,7 +45066,7 @@ function generateSkillMd(name) {
44876
45066
  const pkgPath = join30(skillPath, "package.json");
44877
45067
  if (existsSync14(pkgPath)) {
44878
45068
  try {
44879
- const pkg = JSON.parse(readFileSync20(pkgPath, "utf-8"));
45069
+ const pkg = JSON.parse(readFileSync21(pkgPath, "utf-8"));
44880
45070
  if (pkg.bin) {
44881
45071
  const binKeys = Object.keys(pkg.bin);
44882
45072
  if (binKeys.length > 0)
@@ -44952,7 +45142,7 @@ function extractEnvVars(text2) {
44952
45142
  function readIfExists(path) {
44953
45143
  try {
44954
45144
  if (existsSync14(path)) {
44955
- return readFileSync20(path, "utf-8");
45145
+ return readFileSync21(path, "utf-8");
44956
45146
  }
44957
45147
  } catch {}
44958
45148
  return null;
@@ -55561,7 +55751,7 @@ class PostgresSkillSelectionStore {
55561
55751
 
55562
55752
  // src/server/sqlite-store.ts
55563
55753
  import { randomUUID as randomUUID7 } from "crypto";
55564
- import { mkdirSync as mkdirSync11, readFileSync as readFileSync22, readdirSync as readdirSync12 } from "fs";
55754
+ import { mkdirSync as mkdirSync11, readFileSync as readFileSync23, readdirSync as readdirSync12 } from "fs";
55565
55755
  import { dirname as dirname22, join as join35 } from "path";
55566
55756
 
55567
55757
  // src/server/auth.ts
@@ -56615,7 +56805,7 @@ function applySqliteMigrations(db, migrationsDir = resolveMigrationsDir("sqlite"
56615
56805
  const appliedNow = [];
56616
56806
  for (const file of files) {
56617
56807
  const version2 = file.replace(/\.sql$/, "");
56618
- const text2 = readFileSync22(join35(migrationsDir, file), "utf8");
56808
+ const text2 = readFileSync23(join35(migrationsDir, file), "utf8");
56619
56809
  const apply = db.transaction(() => {
56620
56810
  const already = db.query("SELECT 1 AS present FROM schema_migrations WHERE version = ? LIMIT 1").get(version2);
56621
56811
  if (already)
@@ -63244,15 +63434,11 @@ function resolveServerConfig(env = process.env) {
63244
63434
  requestBodyLimitBytes: parsePositiveInt(env.HASNA_SKILLS_REQUEST_BODY_LIMIT_BYTES, 1e6),
63245
63435
  skillBundleLimitBytes: parsePositiveInt(env.HASNA_SKILLS_BUNDLE_LIMIT_BYTES, 25000000),
63246
63436
  tombstoneWindowMs: parsePositiveInt(env.HASNA_SKILLS_TOMBSTONE_WINDOW_MS, 7 * 24 * 60 * 60 * 1000),
63247
- publicBaseUrl: (env.SKILLS_PUBLIC_BASE_URL || localOrigin(host, port)).replace(/\/+$/, ""),
63437
+ publicBaseUrl: (env.SKILLS_PUBLIC_BASE_URL || "").replace(/\/+$/, ""),
63248
63438
  nodeEnv,
63249
63439
  allowEphemeralStore: env.HASNA_SKILLS_ALLOW_EPHEMERAL_STORE === "1"
63250
63440
  };
63251
63441
  }
63252
- function localOrigin(host, port) {
63253
- const hostname = host === "0.0.0.0" || host === "::" ? "localhost" : host;
63254
- return `http://${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
63255
- }
63256
63442
  function parsePositiveInt(value, fallback) {
63257
63443
  const parsed = Number.parseInt(value ?? "", 10);
63258
63444
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
@@ -64522,6 +64708,9 @@ async function createSkillsFetchHandler(options = {}) {
64522
64708
  const config = { ...resolveServerConfig(), ...options.config };
64523
64709
  if (!options.store)
64524
64710
  assertDurableTarget(resolveDatabaseTarget(config.databaseUrl), config);
64711
+ if (!config.publicBaseUrl) {
64712
+ throw new Error("refusing to start: set SKILLS_PUBLIC_BASE_URL to this Skills server's public API origin; a bound socket is not an authority for client receipts.");
64713
+ }
64525
64714
  const store = options.store ?? await createStore({
64526
64715
  databaseUrl: config.databaseUrl,
64527
64716
  bootstrapApiKey: config.bootstrapApiKey
@@ -69437,7 +69626,7 @@ __export(exports_external2, {
69437
69626
  input: () => input,
69438
69627
  includes: () => _includes,
69439
69628
  httpUrl: () => httpUrl,
69440
- hostname: () => hostname2,
69629
+ hostname: () => hostname3,
69441
69630
  hex: () => hex2,
69442
69631
  hash: () => hash3,
69443
69632
  guid: () => guid2,
@@ -71223,7 +71412,7 @@ __export(exports_regexes, {
71223
71412
  idnEmail: () => idnEmail,
71224
71413
  httpProtocol: () => httpProtocol,
71225
71414
  html5Email: () => html5Email,
71226
- hostname: () => hostname,
71415
+ hostname: () => hostname2,
71227
71416
  hex: () => hex,
71228
71417
  guid: () => guid,
71229
71418
  extendedDuration: () => extendedDuration,
@@ -71285,7 +71474,7 @@ var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]
71285
71474
  var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
71286
71475
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
71287
71476
  var base64url = /^[A-Za-z0-9_-]*$/;
71288
- var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
71477
+ var hostname2 = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
71289
71478
  var domain = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
71290
71479
  var httpProtocol = /^https?$/;
71291
71480
  var e164 = /^\+[1-9]\d{6,14}$/;
@@ -72122,9 +72311,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
72122
72311
  function stripTabAndNewline(value) {
72123
72312
  return value.replace(asciiTabOrNewline, "");
72124
72313
  }
72125
- function urlHostnameOk(url, hostname2) {
72126
- hostname2.lastIndex = 0;
72127
- return hostname2.test(url.hostname);
72314
+ function urlHostnameOk(url, hostname3) {
72315
+ hostname3.lastIndex = 0;
72316
+ return hostname3.test(url.hostname);
72128
72317
  }
72129
72318
  function urlProtocolOk(url, protocol) {
72130
72319
  protocol.lastIndex = 0;
@@ -85512,7 +85701,7 @@ __export(exports_schemas2, {
85512
85701
  int: () => int,
85513
85702
  instanceof: () => _instanceof,
85514
85703
  httpUrl: () => httpUrl,
85515
- hostname: () => hostname2,
85704
+ hostname: () => hostname3,
85516
85705
  hex: () => hex2,
85517
85706
  hash: () => hash3,
85518
85707
  guid: () => guid2,
@@ -86222,7 +86411,7 @@ var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat"
86222
86411
  function stringFormat(format, fnOrRegex, _params = {}) {
86223
86412
  return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
86224
86413
  }
86225
- function hostname2(_params) {
86414
+ function hostname3(_params) {
86226
86415
  return _stringFormat(ZodCustomStringFormat, "hostname", exports_regexes.hostname, _params);
86227
86416
  }
86228
86417
  function hex2(_params) {