/** * The one error taxonomy for `@byok-sdk/core`. * * Two rules the rest of the package is built around: * * 1. **One class, code-based branching.** Consumers switch on `error.code`, not * on class identity — the same idiom `@byok-sdk/keys` uses. A composition that * maps core errors onto HTTP does it with a code table, so adding a code is * an additive change instead of a new `instanceof` chain everywhere. * 2. **Every conflict carries the current snapshot.** A CAS failure that * reports only "conflict" forces the caller into a second round trip and * invites last-write-wins retries. {@link CoreConflictError} therefore * carries `current` — the authoritative state the caller lost to — plus the * `observedAt` instant it was read at. * * This module imports nothing. It is the graph sink: `quota.ts` narrows * {@link StorageErrorCode} out of this union and maps it to HTTP status, and * every port module documents which codes it can raise. That keeps the code * list in one place while letting each domain own its own status mapping. */ /** * Every error code this package can raise. * * Codes are stable strings. Two groups are additionally **wire-stable** — a * composition is expected to surface them verbatim to clients, so renaming one * is a breaking change: * * - `terminal_conflict` (§12.6.4, HTTP 409) * - the five `storage_*` codes (§12.7.7, see `quota.ts`) */ export declare const CORE_ERROR_CODES: { readonly routine_schedule_invalid: 'routine_schedule_invalid'; readonly retention_input_invalid: 'retention_input_invalid'; readonly retention_collect_failed: 'retention_collect_failed'; readonly tenant_id_invalid: 'tenant_id_invalid'; readonly content_hash_invalid: 'content_hash_invalid'; readonly timestamp_not_canonical: 'timestamp_not_canonical'; readonly capability_declaration_invalid: 'capability_declaration_invalid'; readonly capability_unavailable: 'capability_unavailable'; readonly proof_envelope_invalid: 'proof_envelope_invalid'; readonly proof_canonicalization_failed: 'proof_canonicalization_failed'; readonly assertion_envelope_invalid: 'assertion_envelope_invalid'; readonly webcrypto_unavailable: 'webcrypto_unavailable'; readonly sealed_secret_invalid: 'sealed_secret_invalid'; readonly sealed_secret_open_failed: 'sealed_secret_open_failed'; readonly provider_provisioning_request_invalid: 'provider_provisioning_request_invalid'; readonly mailbox_message_not_found: 'mailbox_message_not_found'; readonly mailbox_cursor_regression: 'mailbox_cursor_regression'; readonly mailbox_cursor_ahead_of_delivery: 'mailbox_cursor_ahead_of_delivery'; readonly board_item_not_found: 'board_item_not_found'; readonly board_item_exists: 'board_item_exists'; readonly board_transition_invalid: 'board_transition_invalid'; readonly board_status_conflict: 'board_status_conflict'; readonly board_claim_conflict: 'board_claim_conflict'; readonly board_not_held: 'board_not_held'; readonly truth_record_not_found: 'truth_record_not_found'; readonly terminal_conflict: 'terminal_conflict'; readonly truth_revision_conflict: 'truth_revision_conflict'; readonly activity_capacity_invalid: 'activity_capacity_invalid'; readonly activity_batch_invalid: 'activity_batch_invalid'; readonly hint_ttl_invalid: 'hint_ttl_invalid'; readonly hint_rate_limited: 'hint_rate_limited'; readonly object_key_prefix_invalid: 'object_key_prefix_invalid'; readonly object_not_found: 'object_not_found'; readonly object_state_invalid: 'object_state_invalid'; readonly storage_entitlement_missing: 'storage_entitlement_missing'; readonly storage_entitlement_version_conflict: 'storage_entitlement_version_conflict'; readonly storage_reservation_not_found: 'storage_reservation_not_found'; readonly storage_object_too_large: 'storage_object_too_large'; readonly storage_quota_exceeded: 'storage_quota_exceeded'; readonly storage_reservation_expired: 'storage_reservation_expired'; readonly storage_integrity_mismatch: 'storage_integrity_mismatch'; readonly storage_write_suspended: 'storage_write_suspended'; readonly skill_pack_manifest_invalid: 'skill_pack_manifest_invalid'; readonly skill_pack_frontmatter_invalid: 'skill_pack_frontmatter_invalid'; }; export type CoreErrorCode = (typeof CORE_ERROR_CODES)[keyof typeof CORE_ERROR_CODES]; /** Base error for every failure this package raises. */ export declare class ByokCoreError extends Error { readonly code: CoreErrorCode; constructor(code: CoreErrorCode, message: string, options?: ErrorOptions); } /** * A compare-and-set failure. * * `current` is the authoritative state at the moment the write was rejected — * the board item whose status moved, the terminal record already committed, the * entitlement row at a newer version. The caller re-decides against it; the * store never merges (§12.3: "不做 silent last-write-wins", §12.6.4: 不覆写第一份事实). */ export declare class CoreConflictError extends ByokCoreError { readonly current: TCurrent; readonly observedAt: string; constructor(code: CoreErrorCode, message: string, current: TCurrent, observedAt: string, options?: ErrorOptions); } /** Narrows an unknown thrown value to a core error, optionally to one code. */ export declare function isCoreError(value: unknown, code?: CoreErrorCode): value is ByokCoreError; /** Narrows an unknown thrown value to a conflict error carrying a snapshot. */ export declare function isCoreConflictError(value: unknown, code?: CoreErrorCode): value is CoreConflictError;