@byok-sdk/core 0.33.0 → 0.34.0

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
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- var CORE_ERROR_CODES={routine_schedule_invalid:"routine_schedule_invalid",retention_input_invalid:"retention_input_invalid",retention_collect_failed:"retention_collect_failed",tenant_id_invalid:"tenant_id_invalid",content_hash_invalid:"content_hash_invalid",timestamp_not_canonical:"timestamp_not_canonical",capability_declaration_invalid:"capability_declaration_invalid",capability_unavailable:"capability_unavailable",proof_envelope_invalid:"proof_envelope_invalid",proof_canonicalization_failed:"proof_canonicalization_failed",assertion_envelope_invalid:"assertion_envelope_invalid",webcrypto_unavailable:"webcrypto_unavailable",sealed_secret_invalid:"sealed_secret_invalid",sealed_secret_open_failed:"sealed_secret_open_failed",provider_provisioning_request_invalid:"provider_provisioning_request_invalid",mailbox_message_not_found:"mailbox_message_not_found",mailbox_cursor_regression:"mailbox_cursor_regression",mailbox_cursor_ahead_of_delivery:"mailbox_cursor_ahead_of_delivery",mailbox_stream_closed:"mailbox_stream_closed",board_item_not_found:"board_item_not_found",board_item_exists:"board_item_exists",board_transition_invalid:"board_transition_invalid",board_status_conflict:"board_status_conflict",board_claim_conflict:"board_claim_conflict",board_not_held:"board_not_held",truth_record_not_found:"truth_record_not_found",terminal_conflict:"terminal_conflict",truth_revision_conflict:"truth_revision_conflict",activity_capacity_invalid:"activity_capacity_invalid",activity_batch_invalid:"activity_batch_invalid",hint_ttl_invalid:"hint_ttl_invalid",hint_rate_limited:"hint_rate_limited",object_key_prefix_invalid:"object_key_prefix_invalid",object_not_found:"object_not_found",object_state_invalid:"object_state_invalid",storage_entitlement_missing:"storage_entitlement_missing",storage_entitlement_version_conflict:"storage_entitlement_version_conflict",storage_reservation_not_found:"storage_reservation_not_found",storage_object_too_large:"storage_object_too_large",storage_quota_exceeded:"storage_quota_exceeded",storage_reservation_expired:"storage_reservation_expired",storage_integrity_mismatch:"storage_integrity_mismatch",storage_write_suspended:"storage_write_suspended",skill_pack_manifest_invalid:"skill_pack_manifest_invalid",skill_pack_frontmatter_invalid:"skill_pack_frontmatter_invalid"};var ByokCoreError=class extends Error{code;constructor(code,message,options){super(message,options);this.name="ByokCoreError";this.code=code;}};var CoreConflictError=class extends ByokCoreError{current;observedAt;constructor(code,message,current,observedAt,options){super(code,message,options);this.name="CoreConflictError";this.current=current;this.observedAt=observedAt;}};function isCoreError(value,code){if(!(value instanceof ByokCoreError))return false;return code===void 0||value.code===code}function isCoreConflictError(value,code){if(!(value instanceof CoreConflictError))return false;return code===void 0||value.code===code}var TENANT_ID_MAX_LENGTH=200;var TENANT_KEY_SEPARATOR="\0";function tenantId(value){const candidate=value;if(typeof candidate!=="string"){throw new ByokCoreError("tenant_id_invalid",`Tenant id must be a string, received ${typeof candidate}.`)}if(candidate.length===0){throw new ByokCoreError("tenant_id_invalid","Tenant id must not be empty.")}if(candidate.trim()!==candidate){throw new ByokCoreError("tenant_id_invalid","Tenant id must not have leading or trailing whitespace.")}if(candidate.length>TENANT_ID_MAX_LENGTH){throw new ByokCoreError("tenant_id_invalid",`Tenant id must be at most ${TENANT_ID_MAX_LENGTH} characters.`)}if(candidate.includes(TENANT_KEY_SEPARATOR)){throw new ByokCoreError("tenant_id_invalid","Tenant id must not contain a NUL character.")}return candidate}function isTenantId(value){if(typeof value!=="string")return false;return value.length>0&&value.trim()===value&&value.length<=TENANT_ID_MAX_LENGTH&&!value.includes(TENANT_KEY_SEPARATOR)}function tenantKey(tenant,...parts){return [tenant,...parts].join(TENANT_KEY_SEPARATOR)}var PRINCIPAL_KINDS=["device","control-plane"];function isDevicePrincipal(principal){return principal.kind==="device"}function isControlPlanePrincipal(principal){return principal.kind==="control-plane"}function principalTenant(principal){return principal.tenantId}var CANONICAL_TIMESTAMP_PATTERN=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function isCanonicalTimestamp(value){if(typeof value!=="string")return false;if(!CANONICAL_TIMESTAMP_PATTERN.test(value))return false;const parsed=Date.parse(value);if(!Number.isFinite(parsed))return false;return new Date(parsed).toISOString()===value}function assertCanonicalTimestamp(value,field){if(!isCanonicalTimestamp(value)){throw new ByokCoreError("timestamp_not_canonical",`${field} must be a canonical ISO-8601 UTC instant (YYYY-MM-DDTHH:mm:ss.sssZ), received ${JSON.stringify(value)}.`)}return value}var MAILBOX_MESSAGE_STATES=["pending","acked","expired"];var MAILBOX_STREAM_CLOSE_CAUSES=["device_revoked","device_superseded"];var MailboxStreamClosedError=class extends ByokCoreError{deviceId;closeCause;constructor(deviceId,closeCause,options){super("mailbox_stream_closed",`The mailbox stream of device ${deviceId} is closed (${closeCause}).`,options);this.name="MailboxStreamClosedError";this.deviceId=deviceId;this.closeCause=closeCause;}};var BOARD_STATUSES=["todo","in_progress","in_review","done","closed"];var BOARD_TRANSITIONS={todo:["in_progress","closed"],in_progress:["todo","in_review","closed"],in_review:["in_progress","done","closed"],done:[],closed:[]};function isLegalBoardTransition(from,to){return BOARD_TRANSITIONS[from].includes(to)}var TRUTH_RECORD_KINDS=["task.terminal","profile","memory"];var PRESENCE_LEVELS=["online","thinking","working","error","offline"];function definedFlags(source,keys){const flags={};for(const key of keys)if(source[key]!==void 0)flags[key]=source[key];return flags}function freezePresenceRuntimeFact(runtime){const capabilities=runtime.capabilities;return Object.freeze({id:runtime.id,...runtime.version===void 0?{}:{version:runtime.version},...runtime.authPresent===void 0?{}:{authPresent:runtime.authPresent},...capabilities===void 0?{}:{capabilities:Object.freeze({...definedFlags(capabilities,["steer","resume","approvalInteractive","mcpToolsets","messageDraft","toolAuthorizationAuto","durablePi","preparedLane"]),...capabilities.isolation===void 0?{}:{isolation:Object.freeze(definedFlags(capabilities.isolation,["userContext","userMcpServers","sessionPersistence"]))}})}})}var CONTENT_HASH_PATTERN=/^sha256:[0-9a-f]{64}$/;function contentHash(value){if(!CONTENT_HASH_PATTERN.test(value)){throw new ByokCoreError("content_hash_invalid",`Content hash must match ${CONTENT_HASH_PATTERN.source}, received ${JSON.stringify(value)}.`)}return value}function isContentHash(value){return typeof value==="string"&&CONTENT_HASH_PATTERN.test(value)}var OBJECT_KEY_PREFIX_PATTERN=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/;function objectKeyPrefix(value){if(!OBJECT_KEY_PREFIX_PATTERN.test(value)){throw new ByokCoreError("object_key_prefix_invalid",`Object key prefix must match ${OBJECT_KEY_PREFIX_PATTERN.source}, received ${JSON.stringify(value)}.`)}return value}function tenantObjectKey(tenant,hash,prefix){const hex2=hash.slice("sha256:".length);const key=`tenants/${tenant}/objects/sha256/${hex2}`;return prefix===void 0?key:`${prefix}/${key}`}var OBJECT_STATES=["pending","committed","delete_pending","deleted"];var OBJECT_STATE_TRANSITIONS={pending:["committed","delete_pending"],committed:["delete_pending"],delete_pending:["deleted","committed"],deleted:[]};function isLegalObjectTransition(from,to){return OBJECT_STATE_TRANSITIONS[from].includes(to)}var STORAGE_WRITE_KINDS=["object","inline"];var STORAGE_RESERVATION_STATES=["reserved","committed","aborted","expired"];var STORAGE_WRITE_POSTURES=["normal","warning","blocked","suspended"];var STORAGE_ERROR_CODES=["storage_object_too_large","storage_quota_exceeded","storage_reservation_expired","storage_integrity_mismatch","storage_write_suspended"];var STORAGE_ERROR_HTTP_STATUS={storage_object_too_large:413,storage_quota_exceeded:507,storage_reservation_expired:409,storage_integrity_mismatch:422,storage_write_suspended:423};var CAPABILITY_DECLARATION_SCHEMA_ID="byok-capabilities-v1";var CAPABILITY_NAME_PATTERN=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;var CapabilityDeclarationSchema=z.object({schema:z.literal(CAPABILITY_DECLARATION_SCHEMA_ID),version:z.number().int().nonnegative(),capabilities:z.array(z.string().regex(CAPABILITY_NAME_PATTERN))}).superRefine((declaration,ctx)=>{const seen=new Set;for(const[index,name]of declaration.capabilities.entries()){if(seen.has(name)){ctx.addIssue({code:"custom",path:["capabilities",index],message:`Duplicate capability ${JSON.stringify(name)}.`});}seen.add(name);}});function parseCapabilityDeclaration(input){const result=CapabilityDeclarationSchema.safeParse(input);if(!result.success){throw new ByokCoreError("capability_declaration_invalid",`Invalid capability declaration: ${result.error.issues.map(issue=>`${issue.path.join(".")||"<root>"}: ${issue.message}`).join("; ")}`,{cause:result.error})}return result.data}function hasCapability(declaration,capability){return declaration.capabilities.includes(capability)}function assertCapability(declaration,capability){if(!hasCapability(declaration,capability)){throw new ByokCoreError("capability_unavailable",`Capability ${JSON.stringify(capability)} is not declared by this deployment.`)}}var SKILL_PACK_MANIFEST_SCHEMA_ID="byok-skill-pack-v1";var SKILL_PACK_NAME_PATTERN=/^[a-z0-9][a-z0-9._-]*$/;var SKILL_PACK_NAME_MAX_LENGTH=64;var SKILL_PACK_DESCRIPTION_MAX_LENGTH=1024;var SKILL_PACK_VERSION_PATTERN=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;var SKILL_PACK_FILE_PATH_PATTERN=/^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;var SKILL_PACK_FILE_PATH_MAX_LENGTH=200;var SKILL_PACK_ENTRY_PATH="SKILL.md";var SKILL_PACK_FILE_MAX_BYTES=262144;var SKILL_PACK_MAX_BYTES=1048576;var SKILL_PACK_MAX_FILES=64;var SKILL_PACK_FORBIDDEN_FIELDS=["exec","command","entrypoint","run","script","shell","env","environment","credential","credentials","secret","secrets","token","apiKey","api_key","allowedTools","allowed-tools","hooks","preinstall","postinstall"];var ContentHashSchema=z.string().regex(CONTENT_HASH_PATTERN).transform(value=>contentHash(value));var SkillPackFileSchema=z.strictObject({path:z.string().min(1).max(SKILL_PACK_FILE_PATH_MAX_LENGTH).regex(SKILL_PACK_FILE_PATH_PATTERN),contentHash:ContentHashSchema,byteSize:z.number().int().nonnegative().max(SKILL_PACK_FILE_MAX_BYTES)});var SkillPackManifestSchema=z.strictObject({schema:z.literal(SKILL_PACK_MANIFEST_SCHEMA_ID),name:z.string().min(1).max(SKILL_PACK_NAME_MAX_LENGTH).regex(SKILL_PACK_NAME_PATTERN),version:z.string().regex(SKILL_PACK_VERSION_PATTERN),description:z.string().min(1).max(SKILL_PACK_DESCRIPTION_MAX_LENGTH),files:z.array(SkillPackFileSchema).min(1).max(SKILL_PACK_MAX_FILES),contentHash:ContentHashSchema});function parseSkillPackManifest(input){if(typeof input==="object"&&input!==null){const present=SKILL_PACK_FORBIDDEN_FIELDS.filter(field=>Object.prototype.hasOwnProperty.call(input,field));if(present.length>0){throw new ByokCoreError("skill_pack_manifest_invalid",`A skill pack manifest carries no executable or credential surface; refusing ${present.map(field=>JSON.stringify(field)).join(", ")}.`)}}const result=SkillPackManifestSchema.safeParse(input);if(!result.success){throw new ByokCoreError("skill_pack_manifest_invalid",`Invalid skill pack manifest: ${result.error.issues.map(issue=>`${issue.path.join(".")||"<root>"}: ${issue.message}`).join("; ")}`,{cause:result.error})}return result.data}function skillPackContentHashInput(manifest){const rows=[...manifest.files].sort((left,right)=>left.path<right.path?-1:left.path>right.path?1:0).map(file=>`${file.path}
3
+ var CORE_ERROR_CODES={routine_schedule_invalid:"routine_schedule_invalid",retention_input_invalid:"retention_input_invalid",retention_collect_failed:"retention_collect_failed",tenant_id_invalid:"tenant_id_invalid",content_hash_invalid:"content_hash_invalid",timestamp_not_canonical:"timestamp_not_canonical",capability_declaration_invalid:"capability_declaration_invalid",capability_unavailable:"capability_unavailable",proof_envelope_invalid:"proof_envelope_invalid",proof_canonicalization_failed:"proof_canonicalization_failed",assertion_envelope_invalid:"assertion_envelope_invalid",webcrypto_unavailable:"webcrypto_unavailable",sealed_secret_invalid:"sealed_secret_invalid",sealed_secret_open_failed:"sealed_secret_open_failed",provider_provisioning_request_invalid:"provider_provisioning_request_invalid",mailbox_message_not_found:"mailbox_message_not_found",mailbox_cursor_regression:"mailbox_cursor_regression",mailbox_cursor_ahead_of_delivery:"mailbox_cursor_ahead_of_delivery",mailbox_stream_closed:"mailbox_stream_closed",board_item_not_found:"board_item_not_found",board_item_exists:"board_item_exists",board_transition_invalid:"board_transition_invalid",board_status_conflict:"board_status_conflict",board_claim_conflict:"board_claim_conflict",board_not_held:"board_not_held",truth_record_not_found:"truth_record_not_found",terminal_conflict:"terminal_conflict",truth_revision_conflict:"truth_revision_conflict",activity_capacity_invalid:"activity_capacity_invalid",activity_batch_invalid:"activity_batch_invalid",hint_ttl_invalid:"hint_ttl_invalid",hint_rate_limited:"hint_rate_limited",object_key_prefix_invalid:"object_key_prefix_invalid",object_not_found:"object_not_found",object_state_invalid:"object_state_invalid",storage_entitlement_missing:"storage_entitlement_missing",storage_entitlement_version_conflict:"storage_entitlement_version_conflict",storage_reservation_not_found:"storage_reservation_not_found",storage_object_too_large:"storage_object_too_large",storage_quota_exceeded:"storage_quota_exceeded",storage_reservation_expired:"storage_reservation_expired",storage_integrity_mismatch:"storage_integrity_mismatch",storage_write_suspended:"storage_write_suspended",skill_pack_manifest_invalid:"skill_pack_manifest_invalid",skill_pack_frontmatter_invalid:"skill_pack_frontmatter_invalid"};var ByokCoreError=class extends Error{code;constructor(code,message,options){super(message,options);this.name="ByokCoreError";this.code=code;}};var CoreConflictError=class extends ByokCoreError{current;observedAt;constructor(code,message,current,observedAt,options){super(code,message,options);this.name="CoreConflictError";this.current=current;this.observedAt=observedAt;}};function isCoreError(value,code){if(!(value instanceof ByokCoreError))return false;return code===void 0||value.code===code}function isCoreConflictError(value,code){if(!(value instanceof CoreConflictError))return false;return code===void 0||value.code===code}var TENANT_ID_MAX_LENGTH=200;var TENANT_KEY_SEPARATOR="\0";function tenantId(value){const candidate=value;if(typeof candidate!=="string"){throw new ByokCoreError("tenant_id_invalid",`Tenant id must be a string, received ${typeof candidate}.`)}if(candidate.length===0){throw new ByokCoreError("tenant_id_invalid","Tenant id must not be empty.")}if(candidate.trim()!==candidate){throw new ByokCoreError("tenant_id_invalid","Tenant id must not have leading or trailing whitespace.")}if(candidate.length>TENANT_ID_MAX_LENGTH){throw new ByokCoreError("tenant_id_invalid",`Tenant id must be at most ${TENANT_ID_MAX_LENGTH} characters.`)}if(candidate.includes(TENANT_KEY_SEPARATOR)){throw new ByokCoreError("tenant_id_invalid","Tenant id must not contain a NUL character.")}return candidate}function isTenantId(value){if(typeof value!=="string")return false;return value.length>0&&value.trim()===value&&value.length<=TENANT_ID_MAX_LENGTH&&!value.includes(TENANT_KEY_SEPARATOR)}function tenantKey(tenant,...parts){return [tenant,...parts].join(TENANT_KEY_SEPARATOR)}var PRINCIPAL_KINDS=["device","control-plane"];function isDevicePrincipal(principal){return principal.kind==="device"}function isControlPlanePrincipal(principal){return principal.kind==="control-plane"}function principalTenant(principal){return principal.tenantId}var CANONICAL_TIMESTAMP_PATTERN=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function isCanonicalTimestamp(value){if(typeof value!=="string")return false;if(!CANONICAL_TIMESTAMP_PATTERN.test(value))return false;const parsed=Date.parse(value);if(!Number.isFinite(parsed))return false;return new Date(parsed).toISOString()===value}function assertCanonicalTimestamp(value,field){if(!isCanonicalTimestamp(value)){throw new ByokCoreError("timestamp_not_canonical",`${field} must be a canonical ISO-8601 UTC instant (YYYY-MM-DDTHH:mm:ss.sssZ), received ${JSON.stringify(value)}.`)}return value}var MAILBOX_MESSAGE_STATES=["pending","acked","expired"];var MAILBOX_STREAM_CLOSE_CAUSES=["device_revoked","device_superseded"];var MailboxStreamClosedError=class extends ByokCoreError{deviceId;closeCause;constructor(deviceId,closeCause,options){super("mailbox_stream_closed",`The mailbox stream of device ${deviceId} is closed (${closeCause}).`,options);this.name="MailboxStreamClosedError";this.deviceId=deviceId;this.closeCause=closeCause;}};var BOARD_STATUSES=["todo","in_progress","in_review","done","closed"];var BOARD_TRANSITIONS={todo:["in_progress","closed"],in_progress:["todo","in_review","closed"],in_review:["in_progress","done","closed"],done:[],closed:[]};function isLegalBoardTransition(from,to){return BOARD_TRANSITIONS[from].includes(to)}var TRUTH_RECORD_KINDS=["task.terminal","profile","memory"];var PRESENCE_LEVELS=["online","thinking","working","error","offline"];function definedFlags(source,keys){const flags={};for(const key of keys)if(source[key]!==void 0)flags[key]=source[key];return flags}function freezePresenceRuntimeFact(runtime){const capabilities=runtime.capabilities;return Object.freeze({id:runtime.id,...runtime.version===void 0?{}:{version:runtime.version},...runtime.authPresent===void 0?{}:{authPresent:runtime.authPresent},...capabilities===void 0?{}:{capabilities:Object.freeze({...definedFlags(capabilities,["steer","resume","approvalInteractive","mcpToolsets","messageDraft","toolAuthorizationAuto","durableLane","preparedLane"]),...capabilities.isolation===void 0?{}:{isolation:Object.freeze(definedFlags(capabilities.isolation,["userContext","userMcpServers","sessionPersistence"]))}})}})}var CONTENT_HASH_PATTERN=/^sha256:[0-9a-f]{64}$/;function contentHash(value){if(!CONTENT_HASH_PATTERN.test(value)){throw new ByokCoreError("content_hash_invalid",`Content hash must match ${CONTENT_HASH_PATTERN.source}, received ${JSON.stringify(value)}.`)}return value}function isContentHash(value){return typeof value==="string"&&CONTENT_HASH_PATTERN.test(value)}var OBJECT_KEY_PREFIX_PATTERN=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/;function objectKeyPrefix(value){if(!OBJECT_KEY_PREFIX_PATTERN.test(value)){throw new ByokCoreError("object_key_prefix_invalid",`Object key prefix must match ${OBJECT_KEY_PREFIX_PATTERN.source}, received ${JSON.stringify(value)}.`)}return value}function tenantObjectKey(tenant,hash,prefix){const hex2=hash.slice("sha256:".length);const key=`tenants/${tenant}/objects/sha256/${hex2}`;return prefix===void 0?key:`${prefix}/${key}`}var OBJECT_STATES=["pending","committed","delete_pending","deleted"];var OBJECT_STATE_TRANSITIONS={pending:["committed","delete_pending"],committed:["delete_pending"],delete_pending:["deleted","committed"],deleted:[]};function isLegalObjectTransition(from,to){return OBJECT_STATE_TRANSITIONS[from].includes(to)}var STORAGE_WRITE_KINDS=["object","inline"];var STORAGE_RESERVATION_STATES=["reserved","committed","aborted","expired"];var STORAGE_WRITE_POSTURES=["normal","warning","blocked","suspended"];var STORAGE_ERROR_CODES=["storage_object_too_large","storage_quota_exceeded","storage_reservation_expired","storage_integrity_mismatch","storage_write_suspended"];var STORAGE_ERROR_HTTP_STATUS={storage_object_too_large:413,storage_quota_exceeded:507,storage_reservation_expired:409,storage_integrity_mismatch:422,storage_write_suspended:423};var CAPABILITY_DECLARATION_SCHEMA_ID="byok-capabilities-v1";var CAPABILITY_NAME_PATTERN=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;var CapabilityDeclarationSchema=z.object({schema:z.literal(CAPABILITY_DECLARATION_SCHEMA_ID),version:z.number().int().nonnegative(),capabilities:z.array(z.string().regex(CAPABILITY_NAME_PATTERN))}).superRefine((declaration,ctx)=>{const seen=new Set;for(const[index,name]of declaration.capabilities.entries()){if(seen.has(name)){ctx.addIssue({code:"custom",path:["capabilities",index],message:`Duplicate capability ${JSON.stringify(name)}.`});}seen.add(name);}});function parseCapabilityDeclaration(input){const result=CapabilityDeclarationSchema.safeParse(input);if(!result.success){throw new ByokCoreError("capability_declaration_invalid",`Invalid capability declaration: ${result.error.issues.map(issue=>`${issue.path.join(".")||"<root>"}: ${issue.message}`).join("; ")}`,{cause:result.error})}return result.data}function hasCapability(declaration,capability){return declaration.capabilities.includes(capability)}function assertCapability(declaration,capability){if(!hasCapability(declaration,capability)){throw new ByokCoreError("capability_unavailable",`Capability ${JSON.stringify(capability)} is not declared by this deployment.`)}}var SKILL_PACK_MANIFEST_SCHEMA_ID="byok-skill-pack-v1";var SKILL_PACK_NAME_PATTERN=/^[a-z0-9][a-z0-9._-]*$/;var SKILL_PACK_NAME_MAX_LENGTH=64;var SKILL_PACK_DESCRIPTION_MAX_LENGTH=1024;var SKILL_PACK_VERSION_PATTERN=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;var SKILL_PACK_FILE_PATH_PATTERN=/^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;var SKILL_PACK_FILE_PATH_MAX_LENGTH=200;var SKILL_PACK_ENTRY_PATH="SKILL.md";var SKILL_PACK_FILE_MAX_BYTES=262144;var SKILL_PACK_MAX_BYTES=1048576;var SKILL_PACK_MAX_FILES=64;var SKILL_PACK_FORBIDDEN_FIELDS=["exec","command","entrypoint","run","script","shell","env","environment","credential","credentials","secret","secrets","token","apiKey","api_key","allowedTools","allowed-tools","hooks","preinstall","postinstall"];var ContentHashSchema=z.string().regex(CONTENT_HASH_PATTERN).transform(value=>contentHash(value));var SkillPackFileSchema=z.strictObject({path:z.string().min(1).max(SKILL_PACK_FILE_PATH_MAX_LENGTH).regex(SKILL_PACK_FILE_PATH_PATTERN),contentHash:ContentHashSchema,byteSize:z.number().int().nonnegative().max(SKILL_PACK_FILE_MAX_BYTES)});var SkillPackManifestSchema=z.strictObject({schema:z.literal(SKILL_PACK_MANIFEST_SCHEMA_ID),name:z.string().min(1).max(SKILL_PACK_NAME_MAX_LENGTH).regex(SKILL_PACK_NAME_PATTERN),version:z.string().regex(SKILL_PACK_VERSION_PATTERN),description:z.string().min(1).max(SKILL_PACK_DESCRIPTION_MAX_LENGTH),files:z.array(SkillPackFileSchema).min(1).max(SKILL_PACK_MAX_FILES),contentHash:ContentHashSchema});function parseSkillPackManifest(input){if(typeof input==="object"&&input!==null){const present=SKILL_PACK_FORBIDDEN_FIELDS.filter(field=>Object.prototype.hasOwnProperty.call(input,field));if(present.length>0){throw new ByokCoreError("skill_pack_manifest_invalid",`A skill pack manifest carries no executable or credential surface; refusing ${present.map(field=>JSON.stringify(field)).join(", ")}.`)}}const result=SkillPackManifestSchema.safeParse(input);if(!result.success){throw new ByokCoreError("skill_pack_manifest_invalid",`Invalid skill pack manifest: ${result.error.issues.map(issue=>`${issue.path.join(".")||"<root>"}: ${issue.message}`).join("; ")}`,{cause:result.error})}return result.data}function skillPackContentHashInput(manifest){const rows=[...manifest.files].sort((left,right)=>left.path<right.path?-1:left.path>right.path?1:0).map(file=>`${file.path}
4
4
  ${file.contentHash}
5
5
  ${file.byteSize}
6
6
  `);return [`${SKILL_PACK_MANIFEST_SCHEMA_ID}