@hasna/hooks 0.13.0 → 0.13.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/index.js CHANGED
@@ -166,7 +166,7 @@ function up(db) {
166
166
  db.exec(idx);
167
167
  }
168
168
  }
169
- var init__001_initial = __esm(() => {
169
+ var init_001_initial = __esm(() => {
170
170
  init_schema();
171
171
  });
172
172
 
@@ -195,7 +195,7 @@ function up2(db) {
195
195
  throw err;
196
196
  }
197
197
  }
198
- var init__002_session_events = __esm(() => {
198
+ var init_002_session_events = __esm(() => {
199
199
  init_schema();
200
200
  });
201
201
 
@@ -224,7 +224,7 @@ function up3(db) {
224
224
  throw err;
225
225
  }
226
226
  }
227
- var init__003_user_prompt_submit_event = __esm(() => {
227
+ var init_003_user_prompt_submit_event = __esm(() => {
228
228
  init_schema();
229
229
  });
230
230
 
@@ -248,7 +248,7 @@ var CREATE_HOOKS_TABLE = `
248
248
  last_verified_at TEXT
249
249
  )
250
250
  `, CREATE_HOOKS_INDEXES;
251
- var init__004_hooks_table = __esm(() => {
251
+ var init_004_hooks_table = __esm(() => {
252
252
  CREATE_HOOKS_INDEXES = [
253
253
  `CREATE INDEX IF NOT EXISTS idx_hooks_name ON hooks (name)`
254
254
  ];
@@ -279,7 +279,7 @@ function up5(db) {
279
279
  throw err;
280
280
  }
281
281
  }
282
- var init__005_subagent_start_event = __esm(() => {
282
+ var init_005_subagent_start_event = __esm(() => {
283
283
  init_schema();
284
284
  });
285
285
 
@@ -311,11 +311,11 @@ function runMigrations(db) {
311
311
  }
312
312
  var MIGRATIONS;
313
313
  var init_migrations = __esm(() => {
314
- init__001_initial();
315
- init__002_session_events();
316
- init__003_user_prompt_submit_event();
317
- init__004_hooks_table();
318
- init__005_subagent_start_event();
314
+ init_001_initial();
315
+ init_002_session_events();
316
+ init_003_user_prompt_submit_event();
317
+ init_004_hooks_table();
318
+ init_005_subagent_start_event();
319
319
  MIGRATIONS = [
320
320
  { version: "001_initial", up },
321
321
  { version: "002_session_events", up: up2 },
@@ -581,7 +581,7 @@ var init_redact = __esm(() => {
581
581
  ];
582
582
  });
583
583
 
584
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
584
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
585
585
  var util, objectUtil, ZodParsedType, getParsedType = (data) => {
586
586
  const t = typeof data;
587
587
  switch (t) {
@@ -712,7 +712,7 @@ var init_util = __esm(() => {
712
712
  ]);
713
713
  });
714
714
 
715
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
715
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
716
716
  var ZodIssueCode, quotelessJson = (obj) => {
717
717
  const json = JSON.stringify(obj, null, 2);
718
718
  return json.replace(/"([^"]+)":/g, "$1:");
@@ -833,7 +833,7 @@ var init_ZodError = __esm(() => {
833
833
  };
834
834
  });
835
835
 
836
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
836
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
837
837
  var errorMap = (issue, _ctx) => {
838
838
  let message;
839
839
  switch (issue.code) {
@@ -940,7 +940,7 @@ var init_en = __esm(() => {
940
940
  en_default = errorMap;
941
941
  });
942
942
 
943
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
943
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
944
944
  function setErrorMap(map) {
945
945
  overrideErrorMap = map;
946
946
  }
@@ -953,7 +953,7 @@ var init_errors = __esm(() => {
953
953
  overrideErrorMap = en_default;
954
954
  });
955
955
 
956
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
956
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
957
957
  function addIssueToContext(ctx, issueData) {
958
958
  const overrideMap = getErrorMap();
959
959
  const issue = makeIssue({
@@ -1058,10 +1058,10 @@ var init_parseUtil = __esm(() => {
1058
1058
  });
1059
1059
  });
1060
1060
 
1061
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js
1061
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js
1062
1062
  var init_typeAliases = () => {};
1063
1063
 
1064
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
1064
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
1065
1065
  var errorUtil;
1066
1066
  var init_errorUtil = __esm(() => {
1067
1067
  (function(errorUtil2) {
@@ -1070,7 +1070,7 @@ var init_errorUtil = __esm(() => {
1070
1070
  })(errorUtil || (errorUtil = {}));
1071
1071
  });
1072
1072
 
1073
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
1073
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
1074
1074
  class ParseInputLazyPath {
1075
1075
  constructor(parent, value, path, key) {
1076
1076
  this._cachedPath = [];
@@ -4421,116 +4421,116 @@ var init_types = __esm(() => {
4421
4421
  NEVER = INVALID;
4422
4422
  });
4423
4423
 
4424
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
4424
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
4425
4425
  var exports_external = {};
4426
4426
  __export(exports_external, {
4427
- BRAND: () => BRAND,
4428
- DIRTY: () => DIRTY,
4429
- EMPTY_PATH: () => EMPTY_PATH,
4430
- INVALID: () => INVALID,
4431
- NEVER: () => NEVER,
4432
- OK: () => OK,
4433
- ParseStatus: () => ParseStatus,
4434
- Schema: () => ZodType,
4435
- ZodAny: () => ZodAny,
4436
- ZodArray: () => ZodArray,
4437
- ZodBigInt: () => ZodBigInt,
4438
- ZodBoolean: () => ZodBoolean,
4439
- ZodBranded: () => ZodBranded,
4440
- ZodCatch: () => ZodCatch,
4441
- ZodDate: () => ZodDate,
4442
- ZodDefault: () => ZodDefault,
4443
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
4444
- ZodEffects: () => ZodEffects,
4445
- ZodEnum: () => ZodEnum,
4446
- ZodError: () => ZodError,
4447
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
4448
- ZodFunction: () => ZodFunction,
4449
- ZodIntersection: () => ZodIntersection,
4450
- ZodIssueCode: () => ZodIssueCode,
4451
- ZodLazy: () => ZodLazy,
4452
- ZodLiteral: () => ZodLiteral,
4453
- ZodMap: () => ZodMap,
4454
- ZodNaN: () => ZodNaN,
4455
- ZodNativeEnum: () => ZodNativeEnum,
4456
- ZodNever: () => ZodNever,
4457
- ZodNull: () => ZodNull,
4458
- ZodNullable: () => ZodNullable,
4459
- ZodNumber: () => ZodNumber,
4460
- ZodObject: () => ZodObject,
4461
- ZodOptional: () => ZodOptional,
4462
- ZodParsedType: () => ZodParsedType,
4463
- ZodPipeline: () => ZodPipeline,
4464
- ZodPromise: () => ZodPromise,
4465
- ZodReadonly: () => ZodReadonly,
4466
- ZodRecord: () => ZodRecord,
4467
- ZodSchema: () => ZodType,
4468
- ZodSet: () => ZodSet,
4469
- ZodString: () => ZodString,
4470
- ZodSymbol: () => ZodSymbol,
4471
- ZodTransformer: () => ZodEffects,
4472
- ZodTuple: () => ZodTuple,
4473
- ZodType: () => ZodType,
4474
- ZodUndefined: () => ZodUndefined,
4475
- ZodUnion: () => ZodUnion,
4476
- ZodUnknown: () => ZodUnknown,
4477
- ZodVoid: () => ZodVoid,
4478
- addIssueToContext: () => addIssueToContext,
4479
- any: () => anyType,
4480
- array: () => arrayType,
4481
- bigint: () => bigIntType,
4482
- boolean: () => booleanType,
4483
- coerce: () => coerce,
4484
- custom: () => custom,
4485
- date: () => dateType,
4486
- datetimeRegex: () => datetimeRegex,
4487
- defaultErrorMap: () => en_default,
4488
- discriminatedUnion: () => discriminatedUnionType,
4489
- effect: () => effectsType,
4490
- enum: () => enumType,
4491
- function: () => functionType,
4492
- getErrorMap: () => getErrorMap,
4493
- getParsedType: () => getParsedType,
4494
- instanceof: () => instanceOfType,
4495
- intersection: () => intersectionType,
4496
- isAborted: () => isAborted,
4497
- isAsync: () => isAsync,
4498
- isDirty: () => isDirty,
4499
- isValid: () => isValid,
4500
- late: () => late,
4501
- lazy: () => lazyType,
4502
- literal: () => literalType,
4503
- makeIssue: () => makeIssue,
4504
- map: () => mapType,
4505
- nan: () => nanType,
4506
- nativeEnum: () => nativeEnumType,
4507
- never: () => neverType,
4508
- null: () => nullType,
4509
- nullable: () => nullableType,
4510
- number: () => numberType,
4511
- object: () => objectType,
4512
- objectUtil: () => objectUtil,
4513
- oboolean: () => oboolean,
4514
- onumber: () => onumber,
4515
- optional: () => optionalType,
4516
- ostring: () => ostring,
4517
- pipeline: () => pipelineType,
4518
- preprocess: () => preprocessType,
4519
- promise: () => promiseType,
4520
- quotelessJson: () => quotelessJson,
4521
- record: () => recordType,
4522
- set: () => setType,
4523
- setErrorMap: () => setErrorMap,
4524
- strictObject: () => strictObjectType,
4525
- string: () => stringType,
4526
- symbol: () => symbolType,
4527
- transformer: () => effectsType,
4528
- tuple: () => tupleType,
4529
- undefined: () => undefinedType,
4530
- union: () => unionType,
4531
- unknown: () => unknownType,
4427
+ void: () => voidType,
4532
4428
  util: () => util,
4533
- void: () => voidType
4429
+ unknown: () => unknownType,
4430
+ union: () => unionType,
4431
+ undefined: () => undefinedType,
4432
+ tuple: () => tupleType,
4433
+ transformer: () => effectsType,
4434
+ symbol: () => symbolType,
4435
+ string: () => stringType,
4436
+ strictObject: () => strictObjectType,
4437
+ setErrorMap: () => setErrorMap,
4438
+ set: () => setType,
4439
+ record: () => recordType,
4440
+ quotelessJson: () => quotelessJson,
4441
+ promise: () => promiseType,
4442
+ preprocess: () => preprocessType,
4443
+ pipeline: () => pipelineType,
4444
+ ostring: () => ostring,
4445
+ optional: () => optionalType,
4446
+ onumber: () => onumber,
4447
+ oboolean: () => oboolean,
4448
+ objectUtil: () => objectUtil,
4449
+ object: () => objectType,
4450
+ number: () => numberType,
4451
+ nullable: () => nullableType,
4452
+ null: () => nullType,
4453
+ never: () => neverType,
4454
+ nativeEnum: () => nativeEnumType,
4455
+ nan: () => nanType,
4456
+ map: () => mapType,
4457
+ makeIssue: () => makeIssue,
4458
+ literal: () => literalType,
4459
+ lazy: () => lazyType,
4460
+ late: () => late,
4461
+ isValid: () => isValid,
4462
+ isDirty: () => isDirty,
4463
+ isAsync: () => isAsync,
4464
+ isAborted: () => isAborted,
4465
+ intersection: () => intersectionType,
4466
+ instanceof: () => instanceOfType,
4467
+ getParsedType: () => getParsedType,
4468
+ getErrorMap: () => getErrorMap,
4469
+ function: () => functionType,
4470
+ enum: () => enumType,
4471
+ effect: () => effectsType,
4472
+ discriminatedUnion: () => discriminatedUnionType,
4473
+ defaultErrorMap: () => en_default,
4474
+ datetimeRegex: () => datetimeRegex,
4475
+ date: () => dateType,
4476
+ custom: () => custom,
4477
+ coerce: () => coerce,
4478
+ boolean: () => booleanType,
4479
+ bigint: () => bigIntType,
4480
+ array: () => arrayType,
4481
+ any: () => anyType,
4482
+ addIssueToContext: () => addIssueToContext,
4483
+ ZodVoid: () => ZodVoid,
4484
+ ZodUnknown: () => ZodUnknown,
4485
+ ZodUnion: () => ZodUnion,
4486
+ ZodUndefined: () => ZodUndefined,
4487
+ ZodType: () => ZodType,
4488
+ ZodTuple: () => ZodTuple,
4489
+ ZodTransformer: () => ZodEffects,
4490
+ ZodSymbol: () => ZodSymbol,
4491
+ ZodString: () => ZodString,
4492
+ ZodSet: () => ZodSet,
4493
+ ZodSchema: () => ZodType,
4494
+ ZodRecord: () => ZodRecord,
4495
+ ZodReadonly: () => ZodReadonly,
4496
+ ZodPromise: () => ZodPromise,
4497
+ ZodPipeline: () => ZodPipeline,
4498
+ ZodParsedType: () => ZodParsedType,
4499
+ ZodOptional: () => ZodOptional,
4500
+ ZodObject: () => ZodObject,
4501
+ ZodNumber: () => ZodNumber,
4502
+ ZodNullable: () => ZodNullable,
4503
+ ZodNull: () => ZodNull,
4504
+ ZodNever: () => ZodNever,
4505
+ ZodNativeEnum: () => ZodNativeEnum,
4506
+ ZodNaN: () => ZodNaN,
4507
+ ZodMap: () => ZodMap,
4508
+ ZodLiteral: () => ZodLiteral,
4509
+ ZodLazy: () => ZodLazy,
4510
+ ZodIssueCode: () => ZodIssueCode,
4511
+ ZodIntersection: () => ZodIntersection,
4512
+ ZodFunction: () => ZodFunction,
4513
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
4514
+ ZodError: () => ZodError,
4515
+ ZodEnum: () => ZodEnum,
4516
+ ZodEffects: () => ZodEffects,
4517
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
4518
+ ZodDefault: () => ZodDefault,
4519
+ ZodDate: () => ZodDate,
4520
+ ZodCatch: () => ZodCatch,
4521
+ ZodBranded: () => ZodBranded,
4522
+ ZodBoolean: () => ZodBoolean,
4523
+ ZodBigInt: () => ZodBigInt,
4524
+ ZodArray: () => ZodArray,
4525
+ ZodAny: () => ZodAny,
4526
+ Schema: () => ZodType,
4527
+ ParseStatus: () => ParseStatus,
4528
+ OK: () => OK,
4529
+ NEVER: () => NEVER,
4530
+ INVALID: () => INVALID,
4531
+ EMPTY_PATH: () => EMPTY_PATH,
4532
+ DIRTY: () => DIRTY,
4533
+ BRAND: () => BRAND
4534
4534
  });
4535
4535
  var init_external = __esm(() => {
4536
4536
  init_errors();
@@ -4541,7 +4541,7 @@ var init_external = __esm(() => {
4541
4541
  init_ZodError();
4542
4542
  });
4543
4543
 
4544
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/index.js
4544
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/zod@3.25.76/node_modules/zod/index.js
4545
4545
  var init_zod = __esm(() => {
4546
4546
  init_external();
4547
4547
  init_external();
@@ -4624,21 +4624,21 @@ var init_semver = __esm(() => {
4624
4624
  // src/lib/manifest.ts
4625
4625
  var exports_manifest = {};
4626
4626
  __export(exports_manifest, {
4627
- HOOK_NAME_RE: () => HOOK_NAME_RE,
4628
- HookIdentityError: () => HookIdentityError,
4629
- ScriptContainmentError: () => ScriptContainmentError,
4630
- assertContained: () => assertContained,
4631
- customHookDir: () => customHookDir,
4632
- isInlineScript: () => isInlineScript,
4633
- listCustomHooks: () => listCustomHooks,
4634
- manifestSchema: () => manifestSchema,
4635
- normalizeManifestName: () => normalizeManifestName,
4636
- parseManifest: () => parseManifest,
4637
- readCustomManifest: () => readCustomManifest,
4638
- resolveScript: () => resolveScript,
4639
- scriptRelFor: () => scriptRelFor,
4627
+ writeCustomHook: () => writeCustomHook,
4640
4628
  shortManifestName: () => shortManifestName,
4641
- writeCustomHook: () => writeCustomHook
4629
+ scriptRelFor: () => scriptRelFor,
4630
+ resolveScript: () => resolveScript,
4631
+ readCustomManifest: () => readCustomManifest,
4632
+ parseManifest: () => parseManifest,
4633
+ normalizeManifestName: () => normalizeManifestName,
4634
+ manifestSchema: () => manifestSchema,
4635
+ listCustomHooks: () => listCustomHooks,
4636
+ isInlineScript: () => isInlineScript,
4637
+ customHookDir: () => customHookDir,
4638
+ assertContained: () => assertContained,
4639
+ ScriptContainmentError: () => ScriptContainmentError,
4640
+ HookIdentityError: () => HookIdentityError,
4641
+ HOOK_NAME_RE: () => HOOK_NAME_RE
4642
4642
  });
4643
4643
  import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, realpathSync, writeFileSync } from "fs";
4644
4644
  import { basename, dirname, isAbsolute, join as join5, normalize, resolve as resolve2, sep } from "path";
@@ -4855,24 +4855,24 @@ var init_registry_artifact = __esm(() => {
4855
4855
  // src/lib/store.ts
4856
4856
  var exports_store = {};
4857
4857
  __export(exports_store, {
4858
- LockFileError: () => LockFileError,
4859
- checkScriptHash: () => checkScriptHash,
4860
- getHookRecord: () => getHookRecord,
4861
- getPinnedHook: () => getPinnedHook,
4862
- listHookRecords: () => listHookRecords,
4863
- markRegistryManaged: () => markRegistryManaged,
4864
- pinInstalledHook: () => pinInstalledHook,
4865
- readLock: () => readLock,
4866
- removeHookFromStore: () => removeHookFromStore,
4867
- removeHookRecord: () => removeHookRecord,
4868
- removePinnedHook: () => removePinnedHook,
4869
- retrustHook: () => retrustHook,
4870
- setPinnedHook: () => setPinnedHook,
4871
- sha256File: () => sha256File,
4872
- sha256Of: () => sha256Of,
4873
- upsertHookRecord: () => upsertHookRecord,
4858
+ writeLock: () => writeLock,
4874
4859
  verifyScriptHash: () => verifyScriptHash,
4875
- writeLock: () => writeLock
4860
+ upsertHookRecord: () => upsertHookRecord,
4861
+ sha256Of: () => sha256Of,
4862
+ sha256File: () => sha256File,
4863
+ setPinnedHook: () => setPinnedHook,
4864
+ retrustHook: () => retrustHook,
4865
+ removePinnedHook: () => removePinnedHook,
4866
+ removeHookRecord: () => removeHookRecord,
4867
+ removeHookFromStore: () => removeHookFromStore,
4868
+ readLock: () => readLock,
4869
+ pinInstalledHook: () => pinInstalledHook,
4870
+ markRegistryManaged: () => markRegistryManaged,
4871
+ listHookRecords: () => listHookRecords,
4872
+ getPinnedHook: () => getPinnedHook,
4873
+ getHookRecord: () => getHookRecord,
4874
+ checkScriptHash: () => checkScriptHash,
4875
+ LockFileError: () => LockFileError
4876
4876
  });
4877
4877
  import { createHash as createHash4 } from "crypto";
4878
4878
  import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2, renameSync, lstatSync as lstatSync3 } from "fs";
@@ -5132,17 +5132,17 @@ var init_store = __esm(() => {
5132
5132
  // src/lib/profiles.ts
5133
5133
  var exports_profiles = {};
5134
5134
  __export(exports_profiles, {
5135
- createProfile: () => createProfile,
5136
- deleteProfile: () => deleteProfile,
5137
- exportProfiles: () => exportProfiles,
5138
- getProfile: () => getProfile,
5139
- getProfilesDir: () => getProfilesDir,
5140
- importProfiles: () => importProfiles,
5141
- listProfiles: () => listProfiles,
5135
+ updateProfile: () => updateProfile,
5142
5136
  touchProfile: () => touchProfile,
5143
- updateProfile: () => updateProfile
5137
+ listProfiles: () => listProfiles,
5138
+ importProfiles: () => importProfiles,
5139
+ getProfilesDir: () => getProfilesDir,
5140
+ getProfile: () => getProfile,
5141
+ exportProfiles: () => exportProfiles,
5142
+ deleteProfile: () => deleteProfile,
5143
+ createProfile: () => createProfile
5144
5144
  });
5145
- import { existsSync as existsSync12, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync7, readdirSync as readdirSync3, rmSync as rmSync3, cpSync as cpSync2 } from "fs";
5145
+ import { existsSync as existsSync12, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync7, readdirSync as readdirSync4, rmSync as rmSync3, cpSync as cpSync2 } from "fs";
5146
5146
  import { join as join20 } from "path";
5147
5147
  function getProfilesDir() {
5148
5148
  const newDir = join20(getEffectiveDataRoot(), "profiles");
@@ -5198,7 +5198,7 @@ function listProfiles() {
5198
5198
  if (!existsSync12(dir))
5199
5199
  return [];
5200
5200
  try {
5201
- const files = readdirSync3(dir).filter((f) => f.endsWith(".json"));
5201
+ const files = readdirSync4(dir).filter((f) => f.endsWith(".json"));
5202
5202
  const profiles = [];
5203
5203
  for (const file2 of files) {
5204
5204
  try {
@@ -5441,10 +5441,10 @@ function credentialDiskSources(name, env) {
5441
5441
  function profileDiskSources(name, env, profile) {
5442
5442
  return credentialDiskSourceList(name, env, profile).map((s) => s.path);
5443
5443
  }
5444
- function parseEnvFile(text2) {
5444
+ function parseEnvFile(text3) {
5445
5445
  const values = new Map;
5446
5446
  const unusable = new Set;
5447
- for (const rawLine of text2.split(/\r?\n/)) {
5447
+ for (const rawLine of text3.split(/\r?\n/)) {
5448
5448
  const line = rawLine.trim();
5449
5449
  if (line.length === 0 || line.startsWith("#"))
5450
5450
  continue;
@@ -5669,8 +5669,8 @@ function keychainAccount(env, options) {
5669
5669
  const user = env.USER?.trim();
5670
5670
  return user || null;
5671
5671
  }
5672
- function keychainFailureHint(text2) {
5673
- const line = text2.split(/\r?\n/).find((entry) => entry.trim().length > 0)?.trim() ?? "";
5672
+ function keychainFailureHint(text3) {
5673
+ const line = text3.split(/\r?\n/).find((entry) => entry.trim().length > 0)?.trim() ?? "";
5674
5674
  const clean = line.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 200);
5675
5675
  return clean ? `: ${clean}` : "";
5676
5676
  }
@@ -6297,12 +6297,12 @@ var init_local_opt_in = __esm(() => {
6297
6297
  // src/lib/db-writer.ts
6298
6298
  var exports_db_writer = {};
6299
6299
  __export(exports_db_writer, {
6300
- __resetHookEventSinkNotice: () => __resetHookEventSinkNotice,
6301
- normalizeEventType: () => normalizeEventType,
6302
- recordHookRun: () => recordHookRun,
6303
- resolveEventType: () => resolveEventType,
6300
+ writeHookEvent: () => writeHookEvent,
6304
6301
  resolveHookEventSink: () => resolveHookEventSink,
6305
- writeHookEvent: () => writeHookEvent
6302
+ resolveEventType: () => resolveEventType,
6303
+ recordHookRun: () => recordHookRun,
6304
+ normalizeEventType: () => normalizeEventType,
6305
+ __resetHookEventSinkNotice: () => __resetHookEventSinkNotice
6306
6306
  });
6307
6307
  function resolveHookEventSink(env = process.env) {
6308
6308
  if (isLocalStoreRefused())
@@ -6662,9 +6662,9 @@ var init_hook_env = __esm(() => {
6662
6662
  // src/lib/run.ts
6663
6663
  var exports_run = {};
6664
6664
  __export(exports_run, {
6665
- BUN_ISOLATION_FLAGS: () => BUN_ISOLATION_FLAGS,
6665
+ executeVerifiedScript: () => executeVerifiedScript,
6666
6666
  HookTimeoutError: () => HookTimeoutError,
6667
- executeVerifiedScript: () => executeVerifiedScript
6667
+ BUN_ISOLATION_FLAGS: () => BUN_ISOLATION_FLAGS
6668
6668
  });
6669
6669
  import { randomBytes as randomBytes3 } from "crypto";
6670
6670
  import { rmSync as rmSync6, writeFileSync as writeFileSync15 } from "fs";
@@ -7923,7 +7923,7 @@ function getHook(name) {
7923
7923
  return HOOKS.find((h) => h.name === name);
7924
7924
  }
7925
7925
  // src/lib/installer.ts
7926
- import { existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync13, readdirSync as readdirSync8, realpathSync as realpathSync4, rmdirSync as rmdirSync4, unlinkSync as unlinkSync6, writeFileSync as writeFileSync10 } from "fs";
7926
+ import { existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync13, readdirSync as readdirSync12, realpathSync as realpathSync4, rmdirSync as rmdirSync4, unlinkSync as unlinkSync6, writeFileSync as writeFileSync10 } from "fs";
7927
7927
  import { join as join24, dirname as dirname16, basename as basename12, resolve as resolve28 } from "path";
7928
7928
  import { homedir as homedir8 } from "os";
7929
7929
  import { fileURLToPath as fileURLToPath3 } from "url";
@@ -8891,12 +8891,15 @@ import { existsSync as existsSync11, lstatSync as lstatSync9 } from "fs";
8891
8891
  import { homedir as homedir7 } from "os";
8892
8892
  import { join as join17, resolve as resolve9 } from "path";
8893
8893
 
8894
- // ../../node_modules/.bun/@hasna+skills@0.10.78+a00d3064559565bb/node_modules/@hasna/skills/dist/index.js
8894
+ // ../../../../../../home/hasna/.hasna/scratchpad/scratch/baf4a176-62b7-49a5-aab3-8dcbe08e5fc2/apps-copy/node_modules/.bun/@hasna+skills@0.10.78+a00d3064559565bb/node_modules/@hasna/skills/dist/index.js
8895
8895
  import { existsSync as existsSync10 } from "fs";
8896
8896
  import { homedir as homedir6 } from "os";
8897
8897
  import { join as join11, resolve as resolve4 } from "path";
8898
8898
  import { homedir as pathsResolverHomedir2 } from "os";
8899
8899
  import { join as pathsResolverJoin2 } from "path";
8900
+ import { createHash as createHash6 } from "crypto";
8901
+ import { existsSync as existsSync52, readdirSync as readdirSync3, readFileSync as readFileSync42, statSync as statSync4 } from "fs";
8902
+ import { join as join52, sep as sep2 } from "path";
8900
8903
  import { createHash as createHash32 } from "crypto";
8901
8904
  import { createHash as createHash22 } from "crypto";
8902
8905
  import { closeSync as closeSync22, constants as constants22, fstatSync as fstatSync22, lstatSync as lstatSync42, openSync as openSync22, readSync } from "fs";
@@ -8906,14 +8909,14 @@ import { createHash as createHash42 } from "crypto";
8906
8909
  import { basename as basename3, dirname as dirname42, isAbsolute as isAbsolute32, resolve as resolve32 } from "path";
8907
8910
  import { createHash as createHash52 } from "crypto";
8908
8911
  import { closeSync as closeSync32, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync5, openSync as openSync32, readSync as readSync2 } from "fs";
8909
- import { basename as basename4, dirname as dirname52, isAbsolute as isAbsolute4, resolve as resolve42, sep as sep2 } from "path";
8912
+ import { basename as basename4, dirname as dirname52, isAbsolute as isAbsolute4, resolve as resolve42, sep as sep22 } from "path";
8910
8913
  import { createHash as createHash30 } from "crypto";
8911
8914
  import { lstatSync as lstatSync32, readFileSync as readFileSync26, readdirSync as readdirSync13, realpathSync as realpathSync13 } from "fs";
8912
8915
  import { basename as basename15, dirname as dirname26, isAbsolute as isAbsolute28, join as join38, relative as relative10, resolve as resolve27, sep as sep15 } from "path";
8913
8916
  import { isDeepStrictEqual as isDeepStrictEqual9 } from "util";
8914
8917
  import { dirname as dirname62, isAbsolute as isAbsolute6, join as join82, resolve as resolve6 } from "path";
8915
8918
  import { lstatSync as lstatSync6, readFileSync as readFileSync62, opendirSync } from "fs";
8916
- import { createHash as createHash6 } from "crypto";
8919
+ import { createHash as createHash62 } from "crypto";
8917
8920
  import { lstatSync as lstatSync7, opendirSync as opendirSync2 } from "fs";
8918
8921
  import { dirname as dirname7, isAbsolute as isAbsolute7, join as join92, resolve as resolve7 } from "path";
8919
8922
  import { createHash as createHash7 } from "crypto";
@@ -8988,6 +8991,7 @@ import { closeSync as closeSync19, constants as constants20, fstatSync as fstatS
8988
8991
  import { basename as basename14, dirname as dirname25, isAbsolute as isAbsolute27, resolve as resolve26 } from "path";
8989
8992
  import { createHash as createHash29 } from "crypto";
8990
8993
  import { isAbsolute as isAbsolute30 } from "path";
8994
+ import { createHash as createHash34 } from "crypto";
8991
8995
  var __defProp2 = Object.defineProperty;
8992
8996
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8993
8997
  var __returnValue2 = (v) => v;
@@ -15964,7 +15968,132 @@ class SkillEntryPaths {
15964
15968
  this.files.add(key);
15965
15969
  }
15966
15970
  }
15971
+ var CONTENT_HASH_ALGORITHM = "sha256";
15967
15972
  var HASH_EXCLUDE_DIRS = new Set([".git", "node_modules", "dist", "build", ".turbo"]);
15973
+ function excludedHashEntry(name, directory) {
15974
+ return name.startsWith(".") || directory && HASH_EXCLUDE_DIRS.has(name);
15975
+ }
15976
+ var HASH_COVERAGE = [
15977
+ "SKILL.md",
15978
+ "skill.json",
15979
+ "AGENTS.md",
15980
+ "package.json",
15981
+ "tsconfig.json",
15982
+ "src",
15983
+ "scripts",
15984
+ "assets",
15985
+ "references"
15986
+ ];
15987
+ function normalizeLineEndings(content) {
15988
+ return content.replace(/\r\n/g, `
15989
+ `).replace(/\r/g, `
15990
+ `);
15991
+ }
15992
+ function canonicalizeManifest(raw) {
15993
+ let parsed;
15994
+ try {
15995
+ parsed = JSON.parse(raw);
15996
+ } catch {
15997
+ return normalizeLineEndings(raw);
15998
+ }
15999
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
16000
+ return normalizeLineEndings(raw);
16001
+ }
16002
+ const record = parsed;
16003
+ delete record.content_hash;
16004
+ if (record.provenance && typeof record.provenance === "object" && !Array.isArray(record.provenance)) {
16005
+ delete record.provenance.content_hash;
16006
+ }
16007
+ return `${JSON.stringify(sortObjectKeys(record), null, 2)}
16008
+ `;
16009
+ }
16010
+ function sortObjectKeys(value) {
16011
+ if (Array.isArray(value))
16012
+ return value.map((item) => sortObjectKeys(item));
16013
+ if (typeof value === "object" && value !== null) {
16014
+ const record = value;
16015
+ const sorted = Object.create(null);
16016
+ for (const key of Object.keys(record).sort())
16017
+ sorted[key] = sortObjectKeys(record[key]);
16018
+ return sorted;
16019
+ }
16020
+ return value;
16021
+ }
16022
+ function looksLikeText(buffer) {
16023
+ return !buffer.includes(0);
16024
+ }
16025
+ function collectBundleFiles(skillPath) {
16026
+ const files = [];
16027
+ const seen = new Set;
16028
+ for (const entry of HASH_COVERAGE) {
16029
+ if (seen.has(entry))
16030
+ continue;
16031
+ seen.add(entry);
16032
+ const absolute = join52(skillPath, entry);
16033
+ if (!existsSync52(absolute))
16034
+ continue;
16035
+ if (statSync4(absolute).isDirectory())
16036
+ collectDirectory(files, absolute, entry);
16037
+ else
16038
+ collectFile(files, absolute, entry);
16039
+ }
16040
+ return files.sort((a, b) => a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0);
16041
+ }
16042
+ function collectDirectory(files, dir, rel) {
16043
+ for (const entry of readdirSync3(dir).sort()) {
16044
+ if (entry.startsWith("."))
16045
+ continue;
16046
+ const absolute = join52(dir, entry);
16047
+ const childRel = `${rel}/${entry}`;
16048
+ let stats;
16049
+ try {
16050
+ stats = statSync4(absolute);
16051
+ } catch {
16052
+ continue;
16053
+ }
16054
+ if (stats.isSymbolicLink())
16055
+ continue;
16056
+ if (stats.isDirectory()) {
16057
+ if (excludedHashEntry(entry, true))
16058
+ continue;
16059
+ collectDirectory(files, absolute, childRel);
16060
+ } else if (stats.isFile()) {
16061
+ collectFile(files, absolute, childRel);
16062
+ }
16063
+ }
16064
+ }
16065
+ function collectFile(files, absolute, rel) {
16066
+ const buffer = readFileSync42(absolute);
16067
+ files.push(normalizeBundleFile(rel.split(sep2).join("/"), buffer));
16068
+ }
16069
+ function normalizeBundleFile(rel, buffer) {
16070
+ if (rel === "skill.json") {
16071
+ return { rel, content: new TextEncoder().encode(canonicalizeManifest(new TextDecoder().decode(buffer))) };
16072
+ }
16073
+ if (looksLikeText(buffer)) {
16074
+ const normalized = normalizeLineEndings(new TextDecoder().decode(buffer));
16075
+ return { rel, content: new TextEncoder().encode(normalized) };
16076
+ }
16077
+ return { rel, content: buffer };
16078
+ }
16079
+ function computeContentHash(skillPath) {
16080
+ return hashBundleFiles(collectBundleFiles(skillPath));
16081
+ }
16082
+ function* bundleHashParts(files) {
16083
+ for (const file of files) {
16084
+ yield new TextEncoder().encode(file.rel);
16085
+ yield new TextEncoder().encode(`\x00${file.content.length}\x00`);
16086
+ yield file.content;
16087
+ yield new TextEncoder().encode("\x00");
16088
+ }
16089
+ yield new TextEncoder().encode("\x00");
16090
+ }
16091
+ function hashBundleFiles(files) {
16092
+ const hash = createHash6(CONTENT_HASH_ALGORITHM);
16093
+ for (const part of bundleHashParts(files))
16094
+ hash.update(part);
16095
+ return hash.digest("hex");
16096
+ }
15968
16097
  var CONTENT_HASH_LIMITS = Object.freeze({
15969
16098
  entries: 1024,
15970
16099
  rawBytes: 64 * 1024 * 1024,
@@ -15979,6 +16108,173 @@ var CONTENT_HASH_LIMITS = Object.freeze({
15979
16108
  var typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
15980
16109
  var byteLengthOf = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get;
15981
16110
  var bufferOf = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
16111
+ function verifyContentHash(skillPath, manifest) {
16112
+ const declaredHash = manifest?.provenance?.content_hash?.trim() || undefined;
16113
+ if (!declaredHash)
16114
+ return { declared: false, valid: false };
16115
+ if (!/^[a-f0-9]{64}$/.test(declaredHash)) {
16116
+ return { declared: true, valid: false, declaredHash };
16117
+ }
16118
+ const computedHash = computeContentHash(skillPath);
16119
+ return {
16120
+ declared: true,
16121
+ valid: computedHash === declaredHash,
16122
+ declaredHash,
16123
+ computedHash
16124
+ };
16125
+ }
16126
+ var PORTABLE_SKILL_STANDARD = "hasna.skill.v1";
16127
+ var SKILL_RUNTIMES = ["bun", "node", "python3"];
16128
+ var SKILL_SANDBOX_MODES = ["readonly-fs", "workspace-write", "full"];
16129
+ var SKILL_SYSTEM_DEPS_ALLOWLIST = [
16130
+ "ffmpeg",
16131
+ "ffprobe",
16132
+ "imagemagick",
16133
+ "convert",
16134
+ "curl",
16135
+ "wget",
16136
+ "git",
16137
+ "gh",
16138
+ "jq",
16139
+ "python3",
16140
+ "pip3",
16141
+ "node",
16142
+ "bun",
16143
+ "npm",
16144
+ "rsync",
16145
+ "pdftotext",
16146
+ "tesseract",
16147
+ "7z",
16148
+ "unzip",
16149
+ "zip"
16150
+ ];
16151
+ var SEMVER_PATTERN2 = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$";
16152
+ var CONTENT_HASH_PATTERN = "^[a-f0-9]{64}$";
16153
+ var ENV_REFERENCE_PATTERN = "^[A-Z0-9_]+$";
16154
+ var MAX_RUNTIME_TIMEOUT_SECONDS = 900;
16155
+ function add2(target, code, message) {
16156
+ target.push({ code, message });
16157
+ }
16158
+ function isRecord(value) {
16159
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16160
+ }
16161
+ function isNonEmptyString(value) {
16162
+ return typeof value === "string" && value.trim().length > 0;
16163
+ }
16164
+ function validatePortableManifestContract(manifest, options = {}) {
16165
+ const issues = [];
16166
+ if (!manifest) {
16167
+ add2(issues, "contract.manifest_missing", "No portable manifest to validate");
16168
+ return issues;
16169
+ }
16170
+ if (manifest.standard !== PORTABLE_SKILL_STANDARD) {
16171
+ add2(issues, "contract.standard_invalid", `standard must be '${PORTABLE_SKILL_STANDARD}'`);
16172
+ }
16173
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(manifest.name)) {
16174
+ add2(issues, "contract.name_invalid", `name '${manifest.name}' must be a lowercase slug (letters, numbers, dots, underscores, hyphens)`);
16175
+ }
16176
+ if (!isNonEmptyString(manifest.description)) {
16177
+ add2(issues, "contract.description_missing", "description is required");
16178
+ }
16179
+ if (!isNonEmptyString(manifest.version)) {
16180
+ add2(issues, "contract.version_missing", "version is required");
16181
+ } else if (!new RegExp(SEMVER_PATTERN2).test(manifest.version)) {
16182
+ add2(issues, "contract.version_invalid", `version '${manifest.version}' is not valid semver`);
16183
+ }
16184
+ validateRuntimeContract(manifest, issues, options.strict === true);
16185
+ const provenance = manifest.provenance;
16186
+ if (provenance && !isRecord(provenance)) {
16187
+ add2(issues, "contract.provenance_invalid", "provenance must be an object");
16188
+ } else {
16189
+ const sourceCommit = provenance?.source_commit;
16190
+ if (sourceCommit !== undefined && sourceCommit !== null && !isNonEmptyString(sourceCommit)) {
16191
+ add2(issues, "contract.source_commit_invalid", "provenance.source_commit must be a string");
16192
+ }
16193
+ const changelog = provenance?.changelog;
16194
+ if (changelog !== undefined && changelog !== null && !isNonEmptyString(changelog)) {
16195
+ add2(issues, "contract.changelog_invalid", "provenance.changelog must be a string");
16196
+ }
16197
+ const declaredHash = provenance?.content_hash;
16198
+ if (options.strict && !isNonEmptyString(declaredHash)) {
16199
+ add2(issues, "contract.content_hash_missing", "provenance.content_hash is required: a portable manifest must carry its canonical content hash");
16200
+ } else if (isNonEmptyString(declaredHash) && !new RegExp(CONTENT_HASH_PATTERN).test(declaredHash)) {
16201
+ add2(issues, "contract.content_hash_invalid", "provenance.content_hash must be a 64-character lowercase hex SHA-256");
16202
+ } else if (options.skillPath && isNonEmptyString(declaredHash)) {
16203
+ const verification = verifyContentHash(options.skillPath, manifest);
16204
+ if (!verification.valid) {
16205
+ add2(issues, "contract.content_hash_mismatch", `provenance.content_hash does not match the bundle: declared ${verification.declaredHash}, computed ${verification.computedHash}. Content changed without re-hashing (a content change requires a version bump too).`);
16206
+ }
16207
+ }
16208
+ }
16209
+ return issues;
16210
+ }
16211
+ function validateRuntimeContract(manifest, issues, strict) {
16212
+ const runtime = manifest.runtime;
16213
+ if (runtime === undefined) {
16214
+ if (strict && manifest.kind !== "instruction") {
16215
+ add2(issues, "contract.runtime_missing", "runtime contract is required: { runtime, entrypoint?, timeout?, needs_network?, env?, sandbox?, system_deps?, artifacts? }");
16216
+ }
16217
+ return;
16218
+ }
16219
+ if (!isRecord(runtime)) {
16220
+ add2(issues, "contract.runtime_invalid", "runtime must be an object");
16221
+ return;
16222
+ }
16223
+ const runtimeName = runtime.runtime;
16224
+ if (!SKILL_RUNTIMES.includes(runtimeName)) {
16225
+ add2(issues, "contract.runtime_invalid", `runtime.runtime must be one of: ${SKILL_RUNTIMES.join(", ")}`);
16226
+ }
16227
+ if (runtime.version !== undefined && runtime.version !== null && !isNonEmptyString(runtime.version)) {
16228
+ add2(issues, "contract.runtime_version_invalid", "runtime.version must be a string");
16229
+ }
16230
+ if (runtime.entrypoint !== undefined && runtime.entrypoint !== null && !isNonEmptyString(runtime.entrypoint)) {
16231
+ add2(issues, "contract.entrypoint_invalid", "runtime.entrypoint must be a relative path string");
16232
+ }
16233
+ if (runtime.timeout !== undefined && runtime.timeout !== null) {
16234
+ if (typeof runtime.timeout !== "number" || !Number.isInteger(runtime.timeout) || runtime.timeout < 1 || runtime.timeout > MAX_RUNTIME_TIMEOUT_SECONDS) {
16235
+ add2(issues, "contract.timeout_invalid", `runtime.timeout must be an integer between 1 and ${MAX_RUNTIME_TIMEOUT_SECONDS} seconds`);
16236
+ }
16237
+ }
16238
+ if (runtime.needs_network !== undefined && runtime.needs_network !== null && typeof runtime.needs_network !== "boolean") {
16239
+ add2(issues, "contract.needs_network_invalid", "runtime.needs_network must be a boolean");
16240
+ }
16241
+ if (runtime.env !== undefined && runtime.env !== null) {
16242
+ if (!Array.isArray(runtime.env)) {
16243
+ add2(issues, "contract.env_invalid", "runtime.env must be an array of secret REFERENCE names");
16244
+ } else {
16245
+ for (const reference of runtime.env) {
16246
+ if (typeof reference !== "string" || !new RegExp(ENV_REFERENCE_PATTERN).test(reference)) {
16247
+ add2(issues, "contract.env_invalid", `runtime.env entry '${String(reference)}' must be an uppercase identifier (e.g. OPENAI_API_KEY) \u2014 names only, never values`);
16248
+ }
16249
+ }
16250
+ }
16251
+ }
16252
+ if (runtime.sandbox !== undefined && runtime.sandbox !== null && !SKILL_SANDBOX_MODES.includes(runtime.sandbox)) {
16253
+ add2(issues, "contract.sandbox_invalid", `runtime.sandbox must be one of: ${SKILL_SANDBOX_MODES.join(", ")}`);
16254
+ }
16255
+ if (runtime.system_deps !== undefined && runtime.system_deps !== null) {
16256
+ if (!Array.isArray(runtime.system_deps)) {
16257
+ add2(issues, "contract.system_deps_invalid", "runtime.system_deps must be an array");
16258
+ } else {
16259
+ for (const dep of runtime.system_deps) {
16260
+ if (!SKILL_SYSTEM_DEPS_ALLOWLIST.includes(dep)) {
16261
+ add2(issues, "contract.system_dep_not_allowed", `runtime.system_deps entry '${dep}' is not on the allowlist: ${SKILL_SYSTEM_DEPS_ALLOWLIST.join(", ")}`);
16262
+ }
16263
+ }
16264
+ }
16265
+ }
16266
+ if (runtime.artifacts !== undefined && runtime.artifacts !== null) {
16267
+ if (!Array.isArray(runtime.artifacts)) {
16268
+ add2(issues, "contract.artifacts_invalid", "runtime.artifacts must be an array of glob patterns");
16269
+ } else {
16270
+ for (const glob of runtime.artifacts) {
16271
+ if (!isNonEmptyString(glob)) {
16272
+ add2(issues, "contract.artifacts_invalid", "runtime.artifacts entries must be non-empty glob strings");
16273
+ }
16274
+ }
16275
+ }
16276
+ }
16277
+ }
15982
16278
  var ANY_SEGMENT_COPY_EXCLUDES = new Set([
15983
16279
  ".git",
15984
16280
  ".DS_Store",
@@ -16668,14 +16964,14 @@ function captureClaudeMarketplaceEntry(path, marketplace, plugin, budget2 = { re
16668
16964
  return { path, hashMode: CLAUDE_MARKETPLACE_ENTRY_HASH_MODE, marketplace, plugin, sha256: hashClaudeMarketplaceEntry(text, { marketplace, plugin }) };
16669
16965
  }
16670
16966
  var CLAUDE_ORPHAN_MARKER_MODE = "claude-plugin-orphaned-at-v1";
16671
- var CACHE = `${sep2}.claude${sep2}plugins${sep2}cache${sep2}`;
16967
+ var CACHE = `${sep22}.claude${sep22}plugins${sep22}cache${sep22}`;
16672
16968
  function isClaudePluginCacheOrphanMarker(path) {
16673
16969
  if (typeof path !== "string" || basename4(path) !== ".orphaned_at" || !isAbsolute4(path) || resolve42(path) !== path || path.includes("\x00"))
16674
16970
  return false;
16675
16971
  const at = path.indexOf(CACHE);
16676
16972
  if (at < 0 || path.indexOf(CACHE, at + 1) >= 0)
16677
16973
  return false;
16678
- const parts = path.slice(at + CACHE.length).split(sep2);
16974
+ const parts = path.slice(at + CACHE.length).split(sep22);
16679
16975
  return parts.length === 4 && parts.every((part) => part && part !== "." && part !== "..");
16680
16976
  }
16681
16977
  function same(left, right) {
@@ -17287,7 +17583,7 @@ function capture(path, budget2, excludedRoots, omittedRoots = [], rows) {
17287
17583
  if (!root)
17288
17584
  return { path, sha256: null };
17289
17585
  need3(root.isDirectory(), "Unsupported native discovery directory input");
17290
- const hash = createHash6("sha256");
17586
+ const hash = createHash62("sha256");
17291
17587
  function walk(current2, relative2, before, depth) {
17292
17588
  need3(depth <= 64, "Native discovery directory depth limit exceeded");
17293
17589
  const names = [], directory = opendirSync2(current2);
@@ -17339,7 +17635,7 @@ function verifyDiscoveryDirectoryProjection(directories, omittedRoots, tolerance
17339
17635
  const expected = directories.map((directory) => {
17340
17636
  safe2(directory.path);
17341
17637
  need3(Array.isArray(directory.entries), "Missing reviewed directory membership inventory");
17342
- const hash = createHash6("sha256");
17638
+ const hash = createHash62("sha256");
17343
17639
  const kept = [];
17344
17640
  for (const row of directory.entries) {
17345
17641
  need3(typeof row === "string" && ++count <= AGENT_POLICY_LIMITS.discoveryDirectoryEntries, "Invalid reviewed directory membership rows");
@@ -17355,7 +17651,7 @@ function verifyDiscoveryDirectoryProjection(directories, omittedRoots, tolerance
17355
17651
  }
17356
17652
  need3(directory.sha256 === null ? directory.entries.length === 0 : hash.digest("hex") === directory.sha256, "Reviewed directory inventory does not match its fingerprint");
17357
17653
  const absent = omittedRoots.some((root) => directory.path === root || directory.path.startsWith(root + "/"));
17358
- return { path: directory.path, sha256: absent || directory.sha256 === null ? null : createHash6("sha256").update(kept.join("")).digest("hex") };
17654
+ return { path: directory.path, sha256: absent || directory.sha256 === null ? null : createHash62("sha256").update(kept.join("")).digest("hex") };
17359
17655
  });
17360
17656
  const current2 = captureDiscoveryDirectoryProjection(directories.map((item) => item.path), omittedRoots);
17361
17657
  for (let i = 0;i < current2.length; i++)
@@ -17443,6 +17739,7 @@ function hashRawDiscoveryFile(path, budget2, changes) {
17443
17739
  closeSync4(fd);
17444
17740
  }
17445
17741
  }
17742
+ var BLOCK = 512;
17446
17743
  var ANY_SEGMENT_EXCLUDES = new Set([
17447
17744
  ".git",
17448
17745
  ".ds_store",
@@ -17572,6 +17869,136 @@ var SKILL_BUNDLE_INSPECTION_LIMITS = Object.freeze({
17572
17869
  pathBytes: 100,
17573
17870
  timeoutMs: 5000
17574
17871
  });
17872
+
17873
+ class SkillBundleInspectionError extends Error {
17874
+ code;
17875
+ constructor(code, message) {
17876
+ super(message);
17877
+ this.code = code;
17878
+ this.name = "SkillBundleInspectionError";
17879
+ }
17880
+ }
17881
+ function invalidBundle(message) {
17882
+ throw new SkillBundleInspectionError("BUNDLE_INVALID", message);
17883
+ }
17884
+ class BoundedTarReader {
17885
+ limits;
17886
+ check;
17887
+ header = new Uint8Array(BLOCK);
17888
+ headerOffset = 0;
17889
+ pending;
17890
+ bodyOffset = 0;
17891
+ padding = 0;
17892
+ zeroBlocks = 0;
17893
+ entries = [];
17894
+ paths = new SkillEntryPaths;
17895
+ fileBytes = 0;
17896
+ constructor(limits, check) {
17897
+ this.limits = limits;
17898
+ this.check = check;
17899
+ }
17900
+ push(chunk) {
17901
+ let offset = 0;
17902
+ while (offset < chunk.byteLength) {
17903
+ this.check();
17904
+ if (this.pending) {
17905
+ const count = Math.min(this.pending.bytes.byteLength - this.bodyOffset, chunk.byteLength - offset);
17906
+ this.pending.bytes.set(chunk.subarray(offset, offset + count), this.bodyOffset);
17907
+ offset += count;
17908
+ this.bodyOffset += count;
17909
+ if (this.bodyOffset === this.pending.bytes.byteLength) {
17910
+ this.entries.push(this.pending);
17911
+ this.pending = undefined;
17912
+ }
17913
+ } else if (this.padding) {
17914
+ const count = Math.min(this.padding, chunk.byteLength - offset);
17915
+ if (chunk.subarray(offset, offset + count).some((byte) => byte !== 0))
17916
+ invalidBundle("Nonzero tar body padding");
17917
+ offset += count;
17918
+ this.padding -= count;
17919
+ } else {
17920
+ const count = Math.min(BLOCK - this.headerOffset, chunk.byteLength - offset);
17921
+ this.header.set(chunk.subarray(offset, offset + count), this.headerOffset);
17922
+ offset += count;
17923
+ this.headerOffset += count;
17924
+ if (this.headerOffset === BLOCK) {
17925
+ this.readHeader();
17926
+ this.headerOffset = 0;
17927
+ }
17928
+ }
17929
+ }
17930
+ }
17931
+ finish() {
17932
+ this.check();
17933
+ if (this.pending || this.padding || this.headerOffset || this.zeroBlocks < 2)
17934
+ invalidBundle("Truncated tar bundle");
17935
+ return this.entries;
17936
+ }
17937
+ readHeader() {
17938
+ this.check();
17939
+ const h = this.header;
17940
+ if (h.every((byte) => byte === 0)) {
17941
+ this.zeroBlocks++;
17942
+ return;
17943
+ }
17944
+ if (this.zeroBlocks)
17945
+ invalidBundle("Nonzero tar data after terminator");
17946
+ if (this.entries.length >= this.limits.entries)
17947
+ throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Bundle entry limit exceeded");
17948
+ let checksum = 0;
17949
+ for (let i = 0;i < BLOCK; i++)
17950
+ checksum += i >= 148 && i < 156 ? 32 : h[i];
17951
+ if (tarOctal(h.subarray(148, 156)) !== checksum)
17952
+ invalidBundle("Invalid tar header checksum");
17953
+ if (new TextDecoder().decode(h.subarray(257, 265)) !== "ustar\x00" + "00")
17954
+ invalidBundle("Unsupported tar format");
17955
+ if (h[156] !== 48 && h[156] !== 0 || h.subarray(157, 257).some((b) => b !== 0) || h.subarray(345).some((b) => b !== 0))
17956
+ invalidBundle("Unsupported tar entry or path prefix");
17957
+ const mode = tarOctal(h.subarray(100, 108));
17958
+ if (mode > 511)
17959
+ invalidBundle("Unsupported tar permission bits");
17960
+ tarOctal(h.subarray(108, 116));
17961
+ tarOctal(h.subarray(116, 124));
17962
+ tarOctal(h.subarray(136, 148));
17963
+ const size = tarOctal(h.subarray(124, 136));
17964
+ if (size > this.limits.fileBytes || this.fileBytes + size > this.limits.decompressedBytes) {
17965
+ throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Bundle file byte limit exceeded");
17966
+ }
17967
+ const name = h.subarray(0, 100);
17968
+ const end = name.indexOf(0);
17969
+ if (end !== -1 && name.subarray(end).some((b) => b !== 0))
17970
+ invalidBundle("Invalid tar path padding");
17971
+ const raw = end === -1 ? name : name.subarray(0, end);
17972
+ if (raw.byteLength > this.limits.pathBytes)
17973
+ throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Bundle path byte limit exceeded");
17974
+ let path;
17975
+ try {
17976
+ path = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(raw);
17977
+ } catch {
17978
+ return invalidBundle("Invalid UTF-8 bundle path");
17979
+ }
17980
+ this.paths.add(path, this.limits.pathBytes, invalidBundle, () => {
17981
+ throw new SkillBundleInspectionError("BUNDLE_LIMIT", "Bundle path byte limit exceeded");
17982
+ });
17983
+ this.fileBytes += size;
17984
+ this.pending = { path, mode, bytes: new Uint8Array(new ArrayBuffer(size)) };
17985
+ this.bodyOffset = 0;
17986
+ this.padding = (BLOCK - size % BLOCK) % BLOCK;
17987
+ if (!size) {
17988
+ this.entries.push(this.pending);
17989
+ this.pending = undefined;
17990
+ }
17991
+ }
17992
+ }
17993
+ function tarOctal(field2) {
17994
+ const text2 = new TextDecoder().decode(field2);
17995
+ if (!/^[0-7]+[\0 ]*$/.test(text2))
17996
+ invalidBundle("Invalid tar octal field");
17997
+ const value = Number.parseInt(text2, 8);
17998
+ if (!Number.isSafeInteger(value))
17999
+ invalidBundle("Tar integer is out of range");
18000
+ return value;
18001
+ }
17575
18002
  var SKILL_VERSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/;
17576
18003
  function isValidSkillVersion(value) {
17577
18004
  return typeof value === "string" && SKILL_VERSION_PATTERN.test(value) && !/^\.+$/.test(value) && !value.includes("..");
@@ -20798,6 +21225,50 @@ var SKILLS_API_URL_ENV_KEYS = ENV_KEYS.apiUrlKeys;
20798
21225
  var SKILLS_API_KEY_ENV_KEYS = ENV_KEYS.apiKeyKeys;
20799
21226
  var SKILLS_API_URL_ENV = SKILLS_API_URL_ENV_KEYS[0];
20800
21227
  var SKILLS_API_KEY_ENV = SKILLS_API_KEY_ENV_KEYS[0];
21228
+
21229
+ class SkillsFleetCredentialError extends Error {
21230
+ code;
21231
+ next;
21232
+ constructor(message, code = "MISSING_API_CREDENTIAL", next) {
21233
+ super(message);
21234
+ this.name = "SkillsFleetCredentialError";
21235
+ this.code = code;
21236
+ if (next)
21237
+ this.next = next;
21238
+ }
21239
+ }
21240
+ function normalizeSkillsApiOrigin(apiUrl) {
21241
+ const url = new URL(apiUrl);
21242
+ if (url.username || url.password || url.search || url.hash || url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) {
21243
+ throw new SkillsFleetCredentialError("A Skills API URL must use HTTPS (or loopback HTTP), without credentials, query or fragment", "INVALID_API_URL");
21244
+ }
21245
+ const pathname = url.pathname.replace(/\/+$/, "");
21246
+ if (url.origin === "https://api.hasna.com" && pathname === "/skills/v1") {
21247
+ url.pathname = "/skills";
21248
+ } else if (pathname === "/api" || pathname === "/api/v1") {
21249
+ url.pathname = "/";
21250
+ } else if (pathname.endsWith("/api/v1")) {
21251
+ url.pathname = pathname.slice(0, -"/api/v1".length) || "/";
21252
+ } else if (pathname.endsWith("/api")) {
21253
+ url.pathname = pathname.slice(0, -"/api".length) || "/";
21254
+ }
21255
+ return url.toString().replace(/\/+$/, "");
21256
+ }
21257
+ function skillsApiRequestUrl(apiUrl, route) {
21258
+ const origin = normalizeSkillsApiOrigin(apiUrl);
21259
+ if (!route.startsWith("/api/") || route.includes("#") || route.includes("\\")) {
21260
+ throw new SkillsFleetCredentialError("Invalid Skills API route", "INVALID_API_URL");
21261
+ }
21262
+ if (origin === "https://api.hasna.com/skills") {
21263
+ if (route === "/api/auth/whoami")
21264
+ return `${origin}/v1/auth/whoami`;
21265
+ if (!route.startsWith("/api/v1/")) {
21266
+ throw new SkillsFleetCredentialError("The internal Skills gateway has no established login contract yet. Select an explicitly configured instance with supported authentication.", "GATEWAY_AUTH_UNAVAILABLE");
21267
+ }
21268
+ return `${origin}${route.slice("/api".length)}`;
21269
+ }
21270
+ return `${origin}${route}`;
21271
+ }
20801
21272
  var MAX_REMOTE_FILE_BYTES = 64 * 1024 * 1024;
20802
21273
  var CODEX_NATIVE_POLICY_CAPABILITY = "host-path-allowlist-v1";
20803
21274
  var CODEX_NATIVE_POLICY_RECEIPT_SCHEMA = "skills.codex-native-policy-acceptance/v1";
@@ -44717,6 +45188,46 @@ var revocation = exports_external2.object({
44717
45188
  });
44718
45189
  var page = (item) => exports_external2.object({ contractVersion: exports_external2.literal(1), items: exports_external2.array(item).max(100), nextCursor: exports_external2.string().min(1).max(2048).nullable() });
44719
45190
  var results = { preview, draft: preview.nullable(), activate: exports_external2.object({ replayed: exports_external2.boolean(), consent }), list: page(consent), get: consent.nullable(), occurrences: page(occurrence), revoke: revocation };
45191
+ var record7 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
45192
+ var uuid8 = (v) => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v);
45193
+ var text2 = (v, max = 1024) => typeof v === "string" && !!v.trim() && v.length <= max && !/[\p{Cc}\p{Cs}\u2028\u2029]/u.test(v);
45194
+ var role2 = (v) => typeof v === "string" && ["owner", "admin", "member", "viewer"].includes(v);
45195
+ var invalidWorkspaceResult = "The server returned an invalid workspace selection result.";
45196
+ class WorkspaceIdentityMismatchError extends Error {
45197
+ constructor() {
45198
+ super("The verified account does not match the requested workspace context.");
45199
+ this.name = "WorkspaceIdentityMismatchError";
45200
+ }
45201
+ }
45202
+ function invalid3() {
45203
+ throw new Error(invalidWorkspaceResult);
45204
+ }
45205
+ function organization(v) {
45206
+ if (!record7(v) || !uuid8(v.id) || !text2(v.slug) || !text2(v.name))
45207
+ return invalid3();
45208
+ return { id: v.id, slug: v.slug, name: v.name };
45209
+ }
45210
+ function parseWorkspaceIdentity(value, expectedUserId) {
45211
+ if (!record7(value))
45212
+ return invalid3();
45213
+ const user = value.user;
45214
+ if (!record7(user) || !uuid8(user.id) || !uuid8(user.membershipId) || !text2(user.email, 320) || !(user.displayName === null || text2(user.displayName)) || !role2(user.role))
45215
+ return invalid3();
45216
+ if (user.id !== expectedUserId)
45217
+ throw new WorkspaceIdentityMismatchError;
45218
+ return { user: { id: user.id, membershipId: user.membershipId, email: user.email, displayName: user.displayName, role: user.role }, organization: organization(value.organization) };
45219
+ }
45220
+ function sessionToken(value) {
45221
+ if (typeof value !== "string" || !value || value.length > 8192 || /[^\x21-\x7e]/.test(value) || value.startsWith("sk_"))
45222
+ return invalid3();
45223
+ return value;
45224
+ }
45225
+ function parseWorkspaceSession(value, expected) {
45226
+ const identity5 = parseWorkspaceIdentity(value, expected.userId);
45227
+ if (identity5.user.membershipId !== expected.membershipId)
45228
+ throw new WorkspaceIdentityMismatchError;
45229
+ return { token: sessionToken(value.token), ...identity5 };
45230
+ }
44720
45231
  var SKILLS_API_KEY_REF = credentialPointerEnvKey("skills");
44721
45232
  var quoteUnavailableMessages = Object.freeze({
44722
45233
  HOSTED_PROVIDER_UNAVAILABLE: "Hosted execution is temporarily unavailable on this Skills instance.",
@@ -44728,6 +45239,353 @@ var quoteUnavailableMessages = Object.freeze({
44728
45239
  });
44729
45240
  var KNOWN_SKILL_LIFECYCLE_CODES = new Set(["SKILL_ARCHIVE_PROFILE_CONFLICT", "LIFECYCLE_ROLE_REQUIRED"]);
44730
45241
  var PRIVATE_PUBLICATION_MAX_BYTES = 16 * 1024 * 1024;
45242
+ var skillCreateFailures = {
45243
+ INVALID_SLUG: [400, "Provide a lowercase kebab-case skill slug."],
45244
+ INVALID_DISPLAY_NAME: [400, "Provide a nonempty skill display name."],
45245
+ INVALID_VISIBILITY: [400, "Use private or team visibility for source publication."],
45246
+ SESSION_EXPIRED: [401, "Sign in again before creating a private skill."],
45247
+ INTERACTIVE_SESSION_REQUIRED: [403, "An interactive account session is required to create a private skill."],
45248
+ ACCOUNT_UNAVAILABLE: [403, "The current account membership cannot create a private skill."],
45249
+ PLAN_REQUIRED: [403, "Private and team skills require the Pro plan."],
45250
+ SLUG_CONFLICT: [409, "This skill slug already exists. Inspect the existing skill before publishing."]
45251
+ };
45252
+ var failures2 = {
45253
+ INVALID_REQUEST: [400, "The publication request is invalid."],
45254
+ SESSION_EXPIRED: [401, "Sign in again to manage this publication."],
45255
+ ACCOUNT_UNAVAILABLE: [403, "The account is unavailable."],
45256
+ INTERACTIVE_SESSION_REQUIRED: [403, "An interactive account session is required."],
45257
+ PUBLICATION_FORBIDDEN: [403, "This session cannot manage the publication."],
45258
+ PUBLICATION_ENTITLEMENT_REQUIRED: [403, "The workspace is not entitled to publish private skills."],
45259
+ PUBLICATION_UNAVAILABLE: [404, "The publication is unavailable to this session."],
45260
+ MANIFEST_NAME_MISMATCH: [409, "The manifest name does not match the selected skill."],
45261
+ IDEMPOTENCY_CONFLICT: [409, "This request key already identifies different publication bytes. Use the saved recovery directory."],
45262
+ CURRENT_VERSION_CHANGED: [409, "The current version changed. Inspect it before explicitly starting another publication."],
45263
+ VERSION_EXISTS: [409, "This version already exists."],
45264
+ VERSION_RESERVED: [409, "This version is reserved by another publication."],
45265
+ PUBLICATION_COMMITTED: [409, "The publication is already committed."],
45266
+ PUBLICATION_UPLOAD_UNAVAILABLE: [409, "This publication cannot receive another upload."],
45267
+ PUBLICATION_LIMIT: [429, "The workspace publication limit has been reached."],
45268
+ PUBLICATION_BUSY: [503, "The publication is busy. Reconcile the saved intent before retrying."],
45269
+ PUBLICATION_UNCERTAIN: [503, "The publication outcome is uncertain. Reconcile the saved intent."],
45270
+ PUBLICATION_CAPABILITY_UNAVAILABLE: [503, "Private publishing is not enabled on this server."],
45271
+ PUBLICATION_SIGNING_UNAVAILABLE: [503, "Upload authorization is temporarily unavailable. Keep the same intent."]
45272
+ };
45273
+
45274
+ class PrivatePublicationError extends Error {
45275
+ code;
45276
+ uncertain;
45277
+ status;
45278
+ constructor(code, message, uncertain = false, status) {
45279
+ super(message);
45280
+ this.code = code;
45281
+ this.uncertain = uncertain;
45282
+ this.status = status;
45283
+ this.name = "PrivatePublicationError";
45284
+ }
45285
+ }
45286
+ var bad = () => {
45287
+ throw new PrivatePublicationError("INVALID_PUBLICATION_INPUT", "Invalid publication input or recovery data.");
45288
+ };
45289
+ var invalid4 = () => {
45290
+ throw new PrivatePublicationError("INVALID_PUBLICATION_RESPONSE", "The server returned an invalid publication result.");
45291
+ };
45292
+ var publicationUuid = (v) => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v);
45293
+ var hash4 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v);
45294
+ var record11 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
45295
+ var exact = (v, keys2) => record11(v) && Object.keys(v).sort().join(",") === keys2.sort().join(",");
45296
+ var date5 = (v) => typeof v === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v) && Number.isFinite(Date.parse(v));
45297
+ var publicationSha256 = (bytes) => createHash34("sha256").update(bytes).digest("hex");
45298
+ function checkedPrivateSkillCreate(value) {
45299
+ const refuse6 = (field3, accepted) => {
45300
+ throw new PrivatePublicationError("INVALID_SKILL_CREATE_INPUT", `Invalid ${field3}. ${accepted}`);
45301
+ };
45302
+ if (!record11(value) || !Object.keys(value).every((key2) => ["slug", "displayName", "description", "visibility", "confirm"].includes(key2)))
45303
+ return refuse6("create input", "Provide only slug, displayName, description, visibility and confirm.");
45304
+ if (value.confirm !== true)
45305
+ throw new PrivatePublicationError("SKILL_CREATE_CONFIRM_REQUIRED", "Explicit confirmation is required to create this skill.");
45306
+ if (typeof value.slug !== "string" || value.slug.length > 128 || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value.slug))
45307
+ return refuse6("slug", "Use lowercase kebab-case, at most 128 characters.");
45308
+ if (typeof value.displayName !== "string" || !value.displayName.trim() || value.displayName.length > 256 || /[\p{Cc}\p{Cs}\u2028\u2029]/u.test(value.displayName))
45309
+ return refuse6("displayName", "Use nonempty text, at most 256 characters, without control characters.");
45310
+ if (value.description !== undefined && (typeof value.description !== "string" || Buffer.byteLength(value.description) > 8192 || /[\p{Cc}\p{Cs}]/u.test(value.description.replace(/[\r\n\t]/g, ""))))
45311
+ return refuse6("description", "Use text of at most 8192 UTF-8 bytes, without control characters other than tabs and newlines.");
45312
+ if (value.visibility !== undefined && value.visibility !== "private" && value.visibility !== "team")
45313
+ return refuse6("visibility", "Use private or team.");
45314
+ return Object.freeze({ slug: value.slug, displayName: value.displayName.trim(), description: value.description ?? "", visibility: value.visibility ?? "private" });
45315
+ }
45316
+ function checkedPublicationDeclaration(value) {
45317
+ 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)
45318
+ return bad();
45319
+ try {
45320
+ const manifest = JSON.parse(value.manifestText);
45321
+ if (!record11(manifest) || manifest.version !== value.version || validatePortableManifestContract(manifest, { strict: true }).length || !hash4(manifest.provenance?.content_hash))
45322
+ return bad();
45323
+ } catch {
45324
+ return bad();
45325
+ }
45326
+ return Object.freeze({ ...value });
45327
+ }
45328
+ function checkedPublicationView(value, skillId, intentId, declaration) {
45329
+ if (!exact(value, ["id", "skillId", "version", "expectedCurrentVersionId", "archiveSha256", "archiveByteSize", "state", "expiresAt", "createdAt", "versionId"]) || !publicationUuid(value.id) || value.skillId !== skillId || intentId !== undefined && value.id !== intentId || typeof value.version !== "string" || !value.version || value.version.length > 128 || /[\p{Cc}\p{Cs}]/u.test(value.version) || !(value.expectedCurrentVersionId === null || publicationUuid(value.expectedCurrentVersionId)) || !hash4(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES || typeof value.state !== "string" || !["awaiting_upload", "queued", "verifying", "needs_attention", "committed", "rejected", "cancelled", "expired"].includes(value.state) || !date5(value.expiresAt) || !date5(value.createdAt) || !(value.versionId === null || publicationUuid(value.versionId)) || value.state === "committed" && value.versionId === null)
45330
+ return invalid4();
45331
+ if (declaration && ["version", "expectedCurrentVersionId", "archiveSha256", "archiveByteSize"].some((k) => value[k] !== declaration[k]))
45332
+ return invalid4();
45333
+ return Object.freeze({ ...value });
45334
+ }
45335
+ async function boundedJson(url2, init, token, mutation, budget3 = 15000, signal, create = false) {
45336
+ const controller = new AbortController;
45337
+ let reader;
45338
+ let response;
45339
+ const timeout2 = new PrivatePublicationError(create ? "SKILL_CREATE_UNCONFIRMED" : "PUBLICATION_UNCONFIRMED", create ? "Skill creation could not be confirmed. Inspect the workspace for this slug before another create; do not retry automatically." : "No confirmed publication result. Inspect the saved intent before retrying.", mutation);
45340
+ let timer;
45341
+ let abort;
45342
+ try {
45343
+ return await Promise.race([(async () => {
45344
+ if (signal?.aborted)
45345
+ throw timeout2;
45346
+ response = await fetch(url2, {
45347
+ ...init,
45348
+ redirect: "error",
45349
+ credentials: "omit",
45350
+ signal: controller.signal,
45351
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` }
45352
+ });
45353
+ const length = response.headers.get("content-length");
45354
+ if (length !== null && (!/^\d+$/.test(length) || Number(length) > 65536))
45355
+ return invalid4();
45356
+ reader = response.body?.getReader();
45357
+ const chunks = [];
45358
+ let size = 0;
45359
+ if (reader)
45360
+ while (true) {
45361
+ const part = await reader.read();
45362
+ if (part.done)
45363
+ break;
45364
+ size += part.value.byteLength;
45365
+ if (size > 65536)
45366
+ return invalid4();
45367
+ chunks.push(part.value);
45368
+ }
45369
+ if (controller.signal.aborted)
45370
+ throw timeout2;
45371
+ const bytes = Buffer.concat(chunks);
45372
+ let body;
45373
+ try {
45374
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
45375
+ } catch {
45376
+ return invalid4();
45377
+ }
45378
+ if (!response.ok) {
45379
+ const known = create ? skillCreateFailures : failures2;
45380
+ const code = record11(body) && typeof body.code === "string" && Object.hasOwn(known, body.code) ? body.code : null;
45381
+ if (code && known[code][0] === response.status)
45382
+ throw new PrivatePublicationError(code, known[code][1], mutation && code === "PUBLICATION_UNCERTAIN", response.status);
45383
+ if (create) {
45384
+ if (response.status >= 500)
45385
+ throw timeout2;
45386
+ throw new PrivatePublicationError("SKILL_CREATE_REQUEST_FAILED", "The server refused skill creation.", false, response.status);
45387
+ }
45388
+ throw new PrivatePublicationError("PUBLICATION_REQUEST_FAILED", "The publication request was refused. Inspect its status before retrying.", mutation && response.status >= 500, response.status);
45389
+ }
45390
+ if (create && response.status !== 201)
45391
+ return invalid4();
45392
+ return body;
45393
+ })(), new Promise((_, reject) => {
45394
+ abort = () => {
45395
+ controller.abort();
45396
+ reject(timeout2);
45397
+ };
45398
+ timer = setTimeout(abort, Math.max(1, Math.min(15000, budget3)));
45399
+ signal?.addEventListener("abort", abort, { once: true });
45400
+ })]);
45401
+ } catch (error61) {
45402
+ if (error61 instanceof PrivatePublicationError) {
45403
+ if (mutation && error61.code === "INVALID_PUBLICATION_RESPONSE")
45404
+ throw timeout2;
45405
+ throw error61;
45406
+ }
45407
+ throw timeout2;
45408
+ } finally {
45409
+ if (timer)
45410
+ clearTimeout(timer);
45411
+ if (abort)
45412
+ signal?.removeEventListener("abort", abort);
45413
+ controller.abort();
45414
+ if (reader)
45415
+ reader.cancel().catch(() => {});
45416
+ else
45417
+ response?.body?.cancel().catch(() => {});
45418
+ }
45419
+ }
45420
+
45421
+ class RemotePrivatePublicationsClient {
45422
+ apiOrigin;
45423
+ organizationId;
45424
+ userId;
45425
+ membershipId;
45426
+ #token;
45427
+ constructor(apiUrl, session) {
45428
+ const checked = parseWorkspaceSession(session, { userId: session?.user?.id, membershipId: session?.user?.membershipId });
45429
+ if (checked.user.role === "viewer")
45430
+ throw new PrivatePublicationError("PUBLICATION_FORBIDDEN", failures2.PUBLICATION_FORBIDDEN[1]);
45431
+ this.apiOrigin = normalizeSkillsApiOrigin(apiUrl);
45432
+ this.#token = checked.token;
45433
+ this.organizationId = checked.organization.id;
45434
+ this.userId = checked.user.id;
45435
+ this.membershipId = checked.user.membershipId;
45436
+ Object.freeze(this);
45437
+ }
45438
+ async createSkill(input2, options = {}) {
45439
+ const body = checkedPrivateSkillCreate(input2);
45440
+ if (options.timeoutMs !== undefined && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 1 || options.timeoutMs > 15000))
45441
+ throw new PrivatePublicationError("INVALID_SKILL_CREATE_INPUT", "Invalid timeoutMs. Use an integer from 1 to 15000.");
45442
+ const value = await boundedJson(skillsApiRequestUrl(this.apiOrigin, "/api/v1/skills"), { method: "POST", body: JSON.stringify(body) }, this.#token, true, options.timeoutMs, options.signal, true);
45443
+ if (!record11(value) || !publicationUuid(value.id) || value.slug !== body.slug || value.displayName !== body.displayName || value.description !== body.description || value.visibility !== body.visibility || value.sourceType !== "private_hosted" || !record11(value.metadata) || value.metadata.ownerOrganizationId !== this.organizationId)
45444
+ throw new PrivatePublicationError("SKILL_CREATE_UNCONFIRMED", "Skill creation returned an unbound result. Inspect the workspace for this slug before another create; do not retry automatically.", true);
45445
+ return Object.freeze({ id: value.id, slug: body.slug, visibility: body.visibility, sourceType: "private_hosted", ownerOrganizationId: this.organizationId });
45446
+ }
45447
+ async getCapability(options = {}) {
45448
+ if (options.timeoutMs !== undefined && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 1 || options.timeoutMs > 15000))
45449
+ return bad();
45450
+ const response = await boundedJson(skillsApiRequestUrl(this.apiOrigin, "/api/v1/capabilities"), {}, this.#token, false, options.timeoutMs, options.signal);
45451
+ const p = record11(response) && response.privatePublishing;
45452
+ if (!record11(response) || response.contractVersion !== 1 || response.apiVersion !== 1 || !exact(p, ["contractVersion", "enabled", "authentication", "maxArchiveBytes", "uploadMaxTtlSeconds", "executionEnabled"]) || p.contractVersion !== 1 || typeof p.enabled !== "boolean" || p.authentication !== "interactive-session" || p.maxArchiveBytes !== PRIVATE_PUBLICATION_MAX_BYTES || p.uploadMaxTtlSeconds !== 300 || typeof p.executionEnabled !== "boolean")
45453
+ throw new PrivatePublicationError("PUBLICATION_CONTRACT_UNAVAILABLE", "This server does not support the hosted private publication contract.");
45454
+ return Object.freeze({ ...p });
45455
+ }
45456
+ async#gate(enabled, options = {}) {
45457
+ if (!(await this.getCapability(options)).enabled && enabled)
45458
+ throw new PrivatePublicationError("PUBLICATION_CAPABILITY_UNAVAILABLE", failures2.PUBLICATION_CAPABILITY_UNAVAILABLE[1]);
45459
+ }
45460
+ #path(skillId, intentId) {
45461
+ if (!publicationUuid(skillId) || intentId !== undefined && !publicationUuid(intentId))
45462
+ return bad();
45463
+ return skillsApiRequestUrl(this.apiOrigin, `/api/v1/skills/${skillId}/publication-uploads${intentId ? `/${intentId}` : ""}`);
45464
+ }
45465
+ async#view(path, method, skillId, intentId, declaration, options = {}) {
45466
+ const value = await boundedJson(path, { method, ...method === "GET" ? {} : { body: JSON.stringify(declaration ?? {}) } }, this.#token, method !== "GET", options.timeoutMs, options.signal);
45467
+ try {
45468
+ if (!record11(value) || !Object.keys(value).every((k) => k === "upload" || k === "changed") || value.changed !== undefined && typeof value.changed !== "boolean")
45469
+ return invalid4();
45470
+ return checkedPublicationView(value.upload, skillId, intentId, declaration);
45471
+ } catch (error61) {
45472
+ if (method !== "GET")
45473
+ throw new PrivatePublicationError("PUBLICATION_UNCONFIRMED", "The publication result could not be confirmed. Reconcile the saved intent before another action.", true);
45474
+ throw error61;
45475
+ }
45476
+ }
45477
+ async begin(skillId, input2) {
45478
+ const path = this.#path(skillId), declaration = checkedPublicationDeclaration(input2);
45479
+ await this.#gate(true);
45480
+ return this.#view(path, "POST", skillId, undefined, declaration);
45481
+ }
45482
+ async get(skillId, intentId, options = {}) {
45483
+ const path = this.#path(skillId, intentId), until = Date.now() + (options.timeoutMs ?? 15000);
45484
+ await this.#gate(false, options);
45485
+ return this.#view(path, "GET", skillId, intentId, undefined, { ...options, timeoutMs: Math.max(1, until - Date.now()) });
45486
+ }
45487
+ async finalize(skillId, intentId) {
45488
+ const path = this.#path(skillId, intentId);
45489
+ await this.#gate(true);
45490
+ return this.#view(`${path}/finalize`, "POST", skillId, intentId);
45491
+ }
45492
+ async cancel(skillId, intentId) {
45493
+ const path = this.#path(skillId, intentId);
45494
+ await this.#gate(false);
45495
+ return this.#view(path, "DELETE", skillId, intentId);
45496
+ }
45497
+ async upload(skillId, intent, bytes) {
45498
+ const captured = checkedPublicationView(intent, skillId), path = this.#path(skillId, captured.id);
45499
+ if (!(bytes instanceof Uint8Array) || bytes.byteLength !== captured.archiveByteSize)
45500
+ return bad();
45501
+ const owned = Buffer.from(bytes);
45502
+ if (captured.state !== "awaiting_upload" || owned.byteLength !== captured.archiveByteSize || publicationSha256(owned) !== captured.archiveSha256)
45503
+ return bad();
45504
+ await this.#gate(true);
45505
+ const value = await boundedJson(`${path}/upload-url`, { method: "POST", body: "{}" }, this.#token, false);
45506
+ const upload = this.#upload(value, captured);
45507
+ const controller = new AbortController;
45508
+ let timer;
45509
+ const uncertain = () => new PrivatePublicationError("PUBLICATION_UPLOAD_UNCONFIRMED", "Upload acceptance is uncertain. Resume this saved intent to finalize and inspect it; do not upload again.", true);
45510
+ try {
45511
+ await Promise.race([(async () => {
45512
+ const response = await fetch(upload.uploadUrl, { method: "PUT", headers: upload.headers, body: owned, redirect: "error", credentials: "omit", signal: controller.signal });
45513
+ response.body?.cancel().catch(() => {});
45514
+ if (response.status !== 200 || controller.signal.aborted)
45515
+ throw uncertain();
45516
+ })(), new Promise((_, reject) => {
45517
+ timer = setTimeout(() => {
45518
+ controller.abort();
45519
+ reject(uncertain());
45520
+ }, 30000);
45521
+ })]);
45522
+ } catch {
45523
+ throw uncertain();
45524
+ } finally {
45525
+ if (timer)
45526
+ clearTimeout(timer);
45527
+ controller.abort();
45528
+ }
45529
+ }
45530
+ #upload(value, intent) {
45531
+ if (!exact(value, ["upload"]) || !exact(value.upload, ["method", "uploadUrl", "headers", "expiresAt"]))
45532
+ return invalid4();
45533
+ const p = value.upload;
45534
+ if (p.method !== "PUT" || typeof p.uploadUrl !== "string" || p.uploadUrl.length > 8192 || /[\x00-\x20\x7f]/.test(p.uploadUrl) || !date5(p.expiresAt) || Date.parse(p.expiresAt) - Date.now() < 1000 || Date.parse(p.expiresAt) - Date.now() > 300000 || Date.parse(p.expiresAt) > Date.parse(intent.expiresAt) || !exact(p.headers, ["content-type", "content-length", "x-amz-checksum-sha256", "x-amz-expected-bucket-owner"]) || p.headers["content-type"] !== "application/gzip" || p.headers["content-length"] !== String(intent.archiveByteSize) || p.headers["x-amz-checksum-sha256"] !== Buffer.from(intent.archiveSha256, "hex").toString("base64") || typeof p.headers["x-amz-expected-bucket-owner"] !== "string" || !/^\d{12}$/.test(p.headers["x-amz-expected-bucket-owner"]))
45535
+ return invalid4();
45536
+ let url2;
45537
+ try {
45538
+ url2 = new URL(p.uploadUrl);
45539
+ } catch {
45540
+ return invalid4();
45541
+ }
45542
+ if (url2.protocol !== "https:" || url2.port || url2.username || url2.password || url2.hash || !/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]\.s3\.[a-z]{2}(?:-[a-z]+)+-[1-9]\.amazonaws\.com$/.test(url2.hostname) || url2.pathname !== `/private-publication-staging/${this.organizationId}/${intent.id}/bundle.tgz` || !url2.search || url2.searchParams.get("X-Amz-Algorithm") !== "AWS4-HMAC-SHA256" || url2.searchParams.get("X-Amz-SignedHeaders") !== "content-length;content-type;host;x-amz-checksum-sha256;x-amz-expected-bucket-owner" || !/^[a-f0-9]{64}$/.test(url2.searchParams.get("X-Amz-Signature") ?? ""))
45543
+ return invalid4();
45544
+ const queryKeys = ["X-Amz-Algorithm", "X-Amz-Credential", "X-Amz-Date", "X-Amz-Expires", "X-Amz-Security-Token", "X-Amz-Signature", "X-Amz-SignedHeaders"];
45545
+ if ([...url2.searchParams.keys()].sort().join(",") !== queryKeys.sort().join(","))
45546
+ return invalid4();
45547
+ const issued = url2.searchParams.get("X-Amz-Date"), ttl = url2.searchParams.get("X-Amz-Expires"), credential = url2.searchParams.get("X-Amz-Credential");
45548
+ const timestamp3 = /^(\d{4})(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)Z$/.exec(issued);
45549
+ const region = url2.hostname.split(".s3.")[1].split(".amazonaws.com")[0];
45550
+ if (!timestamp3 || !/^[1-9]\d{0,2}$/.test(ttl) || Number(ttl) > 300 || !/^[A-Z0-9]{16,128}\//.test(credential) || credential.split("/").slice(1).join("/") !== `${issued.slice(0, 8)}/${region}/s3/aws4_request` || !/^[\x21-\x7e]{1,4096}$/.test(url2.searchParams.get("X-Amz-Security-Token")))
45551
+ return invalid4();
45552
+ const issuedAt = Date.parse(`${timestamp3[1]}-${timestamp3[2]}-${timestamp3[3]}T${timestamp3[4]}:${timestamp3[5]}:${timestamp3[6]}Z`);
45553
+ if (!Number.isFinite(issuedAt) || issuedAt > Date.now() + 1000 || issuedAt + Number(ttl) * 1000 !== Date.parse(p.expiresAt))
45554
+ return invalid4();
45555
+ return { method: "PUT", uploadUrl: url2.href, expiresAt: p.expiresAt, headers: Object.freeze({ ...p.headers }) };
45556
+ }
45557
+ async wait(skillId, intentId, options = {}) {
45558
+ const timeout2 = options.timeoutMs ?? 60000;
45559
+ if (!Number.isSafeInteger(timeout2) || timeout2 < 0 || timeout2 > 300000)
45560
+ return bad();
45561
+ const until = Date.now() + timeout2;
45562
+ let previous;
45563
+ while (true) {
45564
+ if (options.signal?.aborted)
45565
+ throw new PrivatePublicationError("PUBLICATION_WAIT_ABORTED", "Stopped waiting. The server publication continues; inspect the saved intent.");
45566
+ let view;
45567
+ try {
45568
+ view = await this.get(skillId, intentId, { timeoutMs: timeout2 === 0 ? 15000 : Math.max(1, Math.min(15000, until - Date.now())), signal: options.signal });
45569
+ } catch (error61) {
45570
+ if (previous && Date.now() >= until && !options.signal?.aborted)
45571
+ return previous;
45572
+ throw error61;
45573
+ }
45574
+ previous = view;
45575
+ if (!["queued", "verifying"].includes(view.state) || Date.now() >= until)
45576
+ return view;
45577
+ await new Promise((resolve30) => {
45578
+ const timer = setTimeout(done, Math.min(1000, until - Date.now()));
45579
+ function done() {
45580
+ clearTimeout(timer);
45581
+ options.signal?.removeEventListener("abort", done);
45582
+ resolve30();
45583
+ }
45584
+ options.signal?.addEventListener("abort", done, { once: true });
45585
+ });
45586
+ }
45587
+ }
45588
+ }
44731
45589
  var uuid12 = exports_external2.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/);
44732
45590
  var sha6 = exports_external2.string().regex(/^[a-f0-9]{64}$/);
44733
45591
  var common = exports_external2.object({
@@ -46008,7 +46866,7 @@ function coordinateClaudeSettings(before, replacement, options, beforeWrite) {
46008
46866
  // src/lib/target-adapters.ts
46009
46867
  init_profiles();
46010
46868
  import { spawnSync } from "child_process";
46011
- import { chmodSync as chmodSync2, existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync8, readdirSync as readdirSync4, rmdirSync as rmdirSync2, statSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync9, renameSync as renameSync5 } from "fs";
46869
+ import { chmodSync as chmodSync2, existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync8, readdirSync as readdirSync8, rmdirSync as rmdirSync2, statSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync9, renameSync as renameSync5 } from "fs";
46012
46870
  import { tmpdir } from "os";
46013
46871
  import { basename as basename9, dirname as dirname9, join as join22 } from "path";
46014
46872
  import { randomUUID as randomUUID5 } from "crypto";
@@ -46047,8 +46905,8 @@ function adapterPath(target, options, hook) {
46047
46905
  throw new Error(`No capability record for target '${target}'`);
46048
46906
  return capabilities.configPath;
46049
46907
  }
46050
- function redactedDiagnostic(text2) {
46051
- const line = (text2.split(`
46908
+ function redactedDiagnostic(text3) {
46909
+ const line = (text3.split(`
46052
46910
  `).find((entry) => entry.trim()) ?? "").trim();
46053
46911
  return line.slice(0, 300).replace(/[A-Za-z0-9_\-]{24,}/g, "<redacted>");
46054
46912
  }
@@ -46059,16 +46917,16 @@ function messageOf(error61) {
46059
46917
  return error61 instanceof Error ? error61.message : String(error61);
46060
46918
  }
46061
46919
  function readJsonObject(path) {
46062
- let text2;
46920
+ let text3;
46063
46921
  try {
46064
- text2 = readFileSync8(path, "utf-8");
46922
+ text3 = readFileSync8(path, "utf-8");
46065
46923
  } catch (error61) {
46066
46924
  if (error61?.code === "ENOENT")
46067
46925
  return { status: "absent" };
46068
46926
  return { status: "unreadable", kind: "file", reason: `cannot read ${path} (${redactedDiagnostic(messageOf(error61))})` };
46069
46927
  }
46070
46928
  try {
46071
- const value = JSON.parse(text2);
46929
+ const value = JSON.parse(text3);
46072
46930
  if (!value || typeof value !== "object" || Array.isArray(value)) {
46073
46931
  return { status: "unreadable", kind: "content", reason: `${path} is not a JSON object` };
46074
46932
  }
@@ -46102,11 +46960,11 @@ function tomlStringValue(raw) {
46102
46960
  }
46103
46961
  var TOML_HEADER_RE = /^\s*\[\[?[^\]]/;
46104
46962
  var KIMI_HOOK_HEADER_RE = /^\s*\[\[hooks\]\]\s*$/;
46105
- function splitToml(text2) {
46963
+ function splitToml(text3) {
46106
46964
  const preamble = [];
46107
46965
  const chunks = [];
46108
46966
  let current2 = null;
46109
- for (const line of text2.split(`
46967
+ for (const line of text3.split(`
46110
46968
  `)) {
46111
46969
  if (TOML_HEADER_RE.test(line)) {
46112
46970
  if (current2)
@@ -46123,20 +46981,20 @@ function splitToml(text2) {
46123
46981
  return { preamble, chunks };
46124
46982
  }
46125
46983
  function chunkCommand(chunk) {
46126
- const text2 = chunk.lines.join(`
46984
+ const text3 = chunk.lines.join(`
46127
46985
  `);
46128
- const basic = text2.match(/^\s*command\s*=\s*"((?:[^"\\]|\\.)*)"/m);
46986
+ const basic = text3.match(/^\s*command\s*=\s*"((?:[^"\\]|\\.)*)"/m);
46129
46987
  if (basic)
46130
46988
  return tomlStringValue(basic[1]);
46131
- const literal2 = text2.match(/^\s*command\s*=\s*'([^']*)'/m);
46989
+ const literal2 = text3.match(/^\s*command\s*=\s*'([^']*)'/m);
46132
46990
  return literal2 ? literal2[1] : undefined;
46133
46991
  }
46134
46992
  function isKimiHookChunk(chunk) {
46135
46993
  return KIMI_HOOK_HEADER_RE.test(chunk.header);
46136
46994
  }
46137
- function kimiRegistrations(text2) {
46995
+ function kimiRegistrations(text3) {
46138
46996
  const out = [];
46139
- for (const chunk of splitToml(text2).chunks) {
46997
+ for (const chunk of splitToml(text3).chunks) {
46140
46998
  if (!isKimiHookChunk(chunk))
46141
46999
  continue;
46142
47000
  const command = chunkCommand(chunk);
@@ -46155,8 +47013,8 @@ function kimiBlock(command, timeoutSeconds) {
46155
47013
  ].join(`
46156
47014
  `);
46157
47015
  }
46158
- function removeKimiChunk(text2, hook) {
46159
- const { preamble, chunks } = splitToml(text2);
47016
+ function removeKimiChunk(text3, hook) {
47017
+ const { preamble, chunks } = splitToml(text3);
46160
47018
  const kept = [...preamble];
46161
47019
  let removed = false;
46162
47020
  for (const chunk of chunks) {
@@ -46371,7 +47229,7 @@ function museBundles(options) {
46371
47229
  if (!existsSync13(root))
46372
47230
  return [];
46373
47231
  const out = [];
46374
- for (const entry of readdirSync4(root)) {
47232
+ for (const entry of readdirSync8(root)) {
46375
47233
  const manifestPath = join22(root, entry, ".muse-plugin", "plugin.json");
46376
47234
  if (!existsSync13(manifestPath))
46377
47235
  continue;
@@ -46595,11 +47453,11 @@ function removeFromAdapter(target, hook, options) {
46595
47453
  if (existing.status === "unreadable") {
46596
47454
  return { removed: false, reason: `${existing.reason}, so Hooks cannot tell whether '${hook}' is registered; nothing was removed` };
46597
47455
  }
46598
- const { text: text2, removed } = removeKimiChunk(existing.status === "verified" ? existing.text : "", hook);
47456
+ const { text: text3, removed } = removeKimiChunk(existing.status === "verified" ? existing.text : "", hook);
46599
47457
  if (!removed)
46600
47458
  return { removed: false, reason: `no '${hook}' entry in ${path}` };
46601
- writeText(path, text2.endsWith(`
46602
- `) ? text2 : `${text2}
47459
+ writeText(path, text3.endsWith(`
47460
+ `) ? text3 : `${text3}
46603
47461
  `);
46604
47462
  return { removed: true };
46605
47463
  }
@@ -46797,13 +47655,13 @@ function readSettings(scope = "global", target = "claude") {
46797
47655
  let reason2 = "cannot be read";
46798
47656
  try {
46799
47657
  if (existsSync14(path)) {
46800
- const text2 = readFileSync13(path, "utf-8");
47658
+ const text3 = readFileSync13(path, "utf-8");
46801
47659
  reason2 = "is not valid JSON";
46802
- const value = JSON.parse(text2);
47660
+ const value = JSON.parse(text3);
46803
47661
  reason2 = "does not hold a JSON object";
46804
47662
  if (!value || typeof value !== "object" || Array.isArray(value))
46805
47663
  throw new TypeError(reason2);
46806
- settingsPreimages.set(value, { path, text: text2 });
47664
+ settingsPreimages.set(value, { path, text: text3 });
46807
47665
  return value;
46808
47666
  }
46809
47667
  } catch (error61) {
@@ -47510,7 +48368,7 @@ function codewithHasHookEntry(name, scope = "global") {
47510
48368
  }
47511
48369
  }
47512
48370
  function removeStoreDirFailClosed(dir) {
47513
- const entries = readdirSync8(dir, { withFileTypes: true });
48371
+ const entries = readdirSync12(dir, { withFileTypes: true });
47514
48372
  for (const entry of entries) {
47515
48373
  if (entry.isDirectory()) {
47516
48374
  removeStoreDirFailClosed(join24(dir, entry.name));
@@ -47918,8 +48776,8 @@ init_db();
47918
48776
  init_store();
47919
48777
  init_manifest();
47920
48778
  init_registry_artifact();
47921
- function sha256OfText(text2) {
47922
- return createHash18("sha256").update(text2).digest("hex");
48779
+ function sha256OfText(text3) {
48780
+ return createHash18("sha256").update(text3).digest("hex");
47923
48781
  }
47924
48782
  function sha256OfPath(path) {
47925
48783
  return createHash18("sha256").update(readFileSync21(path)).digest("hex");
@@ -49593,7 +50451,7 @@ async function registryReady() {
49593
50451
  function json2(body, status = 200, headers = {}) {
49594
50452
  return new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json", "cache-control": "no-store", ...headers } });
49595
50453
  }
49596
- async function boundedJson(request) {
50454
+ async function boundedJson2(request) {
49597
50455
  if (!request.body)
49598
50456
  throw new RegistryError(400, "REGISTRY_BODY_REQUIRED");
49599
50457
  const reader = request.body.getReader(), chunks = [];
@@ -49636,7 +50494,7 @@ async function handleRegistryRequest(request, key2, registry2) {
49636
50494
  if (path === "/v1/lock" && request.method === "GET")
49637
50495
  return json2(await owner2.selection(url2.searchParams.get("profile") ?? "fleet"));
49638
50496
  if (path === "/v1/hooks" && request.method === "PUT")
49639
- return json2(await owner2.publish(await boundedJson(request)));
50497
+ return json2(await owner2.publish(await boundedJson2(request)));
49640
50498
  const artifact = /^\/v1\/hooks\/([^/]+)\/([^/]+)$/.exec(path);
49641
50499
  if (artifact && request.method === "GET") {
49642
50500
  const { body, row, format, portable } = await owner2.artifactWire(decodeURIComponent(artifact[1]), decodeURIComponent(artifact[2]));
@@ -49648,7 +50506,7 @@ async function handleRegistryRequest(request, key2, registry2) {
49648
50506
  if (request.method === "GET")
49649
50507
  return json2(await owner2.selection(profile));
49650
50508
  if (request.method === "PUT")
49651
- return json2(await owner2.select(profile, await boundedJson(request)));
50509
+ return json2(await owner2.select(profile, await boundedJson2(request)));
49652
50510
  }
49653
50511
  return json2({ error: "REGISTRY_ROUTE_NOT_FOUND" }, 404);
49654
50512
  } catch (error61) {
@@ -50013,8 +50871,8 @@ function canonicalHome(home) {
50013
50871
  safeDirectory(home);
50014
50872
  return resolve31(home);
50015
50873
  }
50016
- function parseRecord(text2, home) {
50017
- const record6 = JSON.parse(text2);
50874
+ function parseRecord(text3, home) {
50875
+ const record6 = JSON.parse(text3);
50018
50876
  if (!record6 || Array.isArray(record6) || Object.keys(record6).sort().join() !== "command,harness,schema" || record6.schema !== "hasna.hooks.native-safety.v1" || record6.harness !== "sumi" || typeof record6.command !== "string")
50019
50877
  throw new NativeSafetyError("binding_invalid");
50020
50878
  const binding = nativeSafetyCommandBinding(record6.command);
@@ -50674,7 +51532,7 @@ async function verifyClaudeSafetyConfiguration(options = {}, dependencies = {})
50674
51532
  };
50675
51533
  }
50676
51534
  // src/lib/native-safety-registration.ts
50677
- import { createHash as createHash34, randomUUID as randomUUID9 } from "crypto";
51535
+ import { createHash as createHash35, randomUUID as randomUUID9 } from "crypto";
50678
51536
  import { constants as constants24, closeSync as closeSync24, fstatSync as fstatSync24, fsyncSync as fsyncSync8, lstatSync as lstatSync36, mkdirSync as mkdirSync17, openSync as openSync24, readFileSync as readFileSync31, realpathSync as realpathSync18, writeFileSync as writeFileSync14 } from "fs";
50679
51537
  import { basename as basename18, dirname as dirname36, isAbsolute as isAbsolute33, join as join44, relative as relative7, resolve as resolve36 } from "path";
50680
51538
  import { homedir as homedir12 } from "os";
@@ -50694,7 +51552,7 @@ var need15 = (value, code2) => {
50694
51552
  if (!value)
50695
51553
  throw new NativeRegistrationError(code2);
50696
51554
  };
50697
- var sha10 = (value) => createHash34("sha256").update(value).digest("hex");
51555
+ var sha10 = (value) => createHash35("sha256").update(value).digest("hex");
50698
51556
  function canonical11(value) {
50699
51557
  if (Array.isArray(value))
50700
51558
  return "[" + value.map(canonical11).join(",") + "]";
@@ -50771,8 +51629,8 @@ function read5(path) {
50771
51629
  function assertLosslessJson(raw) {
50772
51630
  const tokens = /"(?:\\[\s\S]|[^"\\])*"|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?|true|false|null|[{}\[\],:]/g;
50773
51631
  const stack = [];
50774
- function decimal(text2) {
50775
- const match = /^(-?)([0-9]+)(?:\.([0-9]+))?(?:[eE]([+-]?[0-9]+))?$/.exec(text2);
51632
+ function decimal(text3) {
51633
+ const match = /^(-?)([0-9]+)(?:\.([0-9]+))?(?:[eE]([+-]?[0-9]+))?$/.exec(text3);
50776
51634
  need15((match[4]?.replace(/^[+-]/, "").length ?? 0) <= 6, "settings_invalid");
50777
51635
  let digits = (match[2] + (match[3] ?? "")).replace(/^0+/, "");
50778
51636
  if (!digits)
@@ -51107,122 +51965,122 @@ async function runHook(name, input2, options = {}) {
51107
51965
  return { output: output2, stderr: stderrText, exitCode };
51108
51966
  }
51109
51967
  export {
51110
- CATEGORIES,
51111
- ClaudeSafetyError,
51112
- CodexTrustError,
51113
- DEFAULT_SERVE_PORT,
51114
- HOOKS,
51115
- HOOKS_LOCAL_OPT_IN_ENV_KEYS,
51116
- HOOKS_STORAGE_BACKEND_ENV,
51117
- HOOKS_STORAGE_BACKEND_FALLBACK_ENV,
51118
- HOOKS_STORAGE_ENV,
51119
- HOOKS_STORAGE_FALLBACK_ENV,
51120
- HOOKS_STORAGE_TABLES,
51121
- HOOK_EVENTS,
51122
- NativeRegistrationError,
51123
- RETIRED_STORAGE_MODE_ENV,
51124
- STORAGE_BACKENDS,
51125
- STORAGE_BACKEND_ENV,
51126
- STORAGE_DATABASE_ENV,
51127
- STORAGE_TABLES,
51128
- allowLocalStore,
51129
- applyCodexSafetyTrust,
51130
- applyNativeSafetyRegistration,
51131
- buildCodewithTomlFragment,
51132
- checkScriptHash,
51133
- createProfile,
51134
- deleteProfile,
51135
- exportProfiles,
51136
- fetchPinnedHook,
51137
- getCustomHooksDir,
51138
- getHook,
51139
- getHookEvents,
51140
- getHookPath,
51141
- getHookRecord,
51142
- getHooksByCategory,
51143
- getHooksDataDir,
51144
- getInstalledHooks,
51145
- getLockPath,
51146
- getPinnedHook,
51147
- getProfile,
51148
- getProfilesDir,
51149
- getRegisteredHooks,
51150
- getRegisteredHooksForTarget,
51151
- getSettingsPath,
51152
- getStorageBackend,
51153
- getStorageDatabaseEnv,
51154
- getStorageDatabaseEnvName,
51155
- getStorageDatabaseUrl,
51156
- getStoragePg,
51157
- getStorageStatus,
51158
- getSyncMetaAll,
51159
- handleServeRequest,
51160
- hasHooksEnvAuthorityIntent,
51161
- hookExists,
51162
- hooksEventSinkRefusal,
51163
- hooksFailClosedLine,
51164
- hooksHostedRouteLocalStoreRefusal,
51165
- hooksRegistryOrigin,
51166
- importProfiles,
51167
- installCustomSource,
51168
- installHook,
51169
- installHookForProject,
51170
- installHooks,
51171
- installHooksForProject,
51172
- installPinnedFromBundled,
51173
- isCustomSource,
51174
- isEventSupported,
51175
- isHooksLocalOptIn,
51176
- isLocalStoreRefused,
51177
- listCustomHooks,
51178
- listHookRecords,
51179
- listProfiles,
51180
- listProjectHooks,
51181
- parseManifest,
51182
- parseStorageTables,
51183
- pinInstalledHook,
51184
- planCodexSafetyTrust,
51185
- planNativeSafetyRegistration,
51186
- planSync,
51187
- provisionCloudflareResources,
51188
- readCustomManifest,
51189
- readLock,
51190
- refuseLocalStore,
51191
- removeHook,
51192
- removeHookFromStore,
51193
- removeHookRecord,
51194
- removePinnedHook,
51195
- removeProjectHook,
51196
- resolveHook,
51197
- resolveHookDir,
51198
- resolveHookEventSink,
51199
- resolveHookMeta,
51200
- resolveHooksRequestAuthority,
51201
- resolveHooksServePublishKey,
51202
- resolveHooksServePublishKeyAsync,
51203
- resolveHooksTransport,
51204
- resolveScript,
51205
- resolveScriptPath,
51206
- resolveTables,
51207
- retrustHook,
51208
- runHook,
51209
- runStorageMigrations,
51210
- searchHooks,
51211
- selectsHooksLocalStore,
51212
- setPinnedHook,
51213
- sha256File,
51214
- sha256Of,
51215
- startServeServer,
51216
- storagePull,
51217
- storagePush,
51218
- storageSync,
51219
- syncHooks,
51220
- touchProfile,
51221
- uninstallHook,
51222
- updateProfile,
51223
- upsertHookRecord,
51224
- verifyClaudeSafetyConfiguration,
51225
- verifyScriptHash,
51968
+ writeLock,
51226
51969
  writeCustomHook,
51227
- writeLock
51970
+ verifyScriptHash,
51971
+ verifyClaudeSafetyConfiguration,
51972
+ upsertHookRecord,
51973
+ updateProfile,
51974
+ uninstallHook,
51975
+ touchProfile,
51976
+ syncHooks,
51977
+ storageSync,
51978
+ storagePush,
51979
+ storagePull,
51980
+ startServeServer,
51981
+ sha256Of,
51982
+ sha256File,
51983
+ setPinnedHook,
51984
+ selectsHooksLocalStore,
51985
+ searchHooks,
51986
+ runStorageMigrations,
51987
+ runHook,
51988
+ retrustHook,
51989
+ resolveTables,
51990
+ resolveScriptPath,
51991
+ resolveScript,
51992
+ resolveHooksTransport,
51993
+ resolveHooksServePublishKeyAsync,
51994
+ resolveHooksServePublishKey,
51995
+ resolveHooksRequestAuthority,
51996
+ resolveHookMeta,
51997
+ resolveHookEventSink,
51998
+ resolveHookDir,
51999
+ resolveHook,
52000
+ removeProjectHook,
52001
+ removePinnedHook,
52002
+ removeHookRecord,
52003
+ removeHookFromStore,
52004
+ removeHook,
52005
+ refuseLocalStore,
52006
+ readLock,
52007
+ readCustomManifest,
52008
+ provisionCloudflareResources,
52009
+ planSync,
52010
+ planNativeSafetyRegistration,
52011
+ planCodexSafetyTrust,
52012
+ pinInstalledHook,
52013
+ parseStorageTables,
52014
+ parseManifest,
52015
+ listProjectHooks,
52016
+ listProfiles,
52017
+ listHookRecords,
52018
+ listCustomHooks,
52019
+ isLocalStoreRefused,
52020
+ isHooksLocalOptIn,
52021
+ isEventSupported,
52022
+ isCustomSource,
52023
+ installPinnedFromBundled,
52024
+ installHooksForProject,
52025
+ installHooks,
52026
+ installHookForProject,
52027
+ installHook,
52028
+ installCustomSource,
52029
+ importProfiles,
52030
+ hooksRegistryOrigin,
52031
+ hooksHostedRouteLocalStoreRefusal,
52032
+ hooksFailClosedLine,
52033
+ hooksEventSinkRefusal,
52034
+ hookExists,
52035
+ hasHooksEnvAuthorityIntent,
52036
+ handleServeRequest,
52037
+ getSyncMetaAll,
52038
+ getStorageStatus,
52039
+ getStoragePg,
52040
+ getStorageDatabaseUrl,
52041
+ getStorageDatabaseEnvName,
52042
+ getStorageDatabaseEnv,
52043
+ getStorageBackend,
52044
+ getSettingsPath,
52045
+ getRegisteredHooksForTarget,
52046
+ getRegisteredHooks,
52047
+ getProfilesDir,
52048
+ getProfile,
52049
+ getPinnedHook,
52050
+ getLockPath,
52051
+ getInstalledHooks,
52052
+ getHooksDataDir,
52053
+ getHooksByCategory,
52054
+ getHookRecord,
52055
+ getHookPath,
52056
+ getHookEvents,
52057
+ getHook,
52058
+ getCustomHooksDir,
52059
+ fetchPinnedHook,
52060
+ exportProfiles,
52061
+ deleteProfile,
52062
+ createProfile,
52063
+ checkScriptHash,
52064
+ buildCodewithTomlFragment,
52065
+ applyNativeSafetyRegistration,
52066
+ applyCodexSafetyTrust,
52067
+ allowLocalStore,
52068
+ STORAGE_TABLES,
52069
+ STORAGE_DATABASE_ENV,
52070
+ STORAGE_BACKEND_ENV,
52071
+ STORAGE_BACKENDS,
52072
+ RETIRED_STORAGE_MODE_ENV,
52073
+ NativeRegistrationError,
52074
+ HOOK_EVENTS,
52075
+ HOOKS_STORAGE_TABLES,
52076
+ HOOKS_STORAGE_FALLBACK_ENV,
52077
+ HOOKS_STORAGE_ENV,
52078
+ HOOKS_STORAGE_BACKEND_FALLBACK_ENV,
52079
+ HOOKS_STORAGE_BACKEND_ENV,
52080
+ HOOKS_LOCAL_OPT_IN_ENV_KEYS,
52081
+ HOOKS,
52082
+ DEFAULT_SERVE_PORT,
52083
+ CodexTrustError,
52084
+ ClaudeSafetyError,
52085
+ CATEGORIES
51228
52086
  };