@muhkoo/connect 0.15.0-alpha.4 → 0.15.0-alpha.6

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/connect.d.ts CHANGED
@@ -1099,6 +1099,59 @@ declare class BroadcastChannel {
1099
1099
  private handleInboundFrame;
1100
1100
  }
1101
1101
 
1102
+ /**
1103
+ * `HttpError` — thrown for any non-2xx accelerator response.
1104
+ *
1105
+ * In a module of its own so that `PaymentRequiredError` can extend it while
1106
+ * `HttpClient`, which throws both, imports `PaymentRequiredError`: with the
1107
+ * class in `HttpClient.ts`, the two modules would import each other, and
1108
+ * whichever loaded second would extend a class not yet defined. `HttpClient`
1109
+ * re-exports it, so `import { HttpError } from "./HttpClient"` still works.
1110
+ */
1111
+ /** Thrown for any non-2xx accelerator response. Carries the HTTP status. */
1112
+ declare class HttpError extends Error {
1113
+ readonly status: number;
1114
+ readonly body?: unknown | undefined;
1115
+ constructor(message: string, status: number, body?: unknown | undefined);
1116
+ }
1117
+
1118
+ /**
1119
+ * `PaymentRequiredError` — a write the accelerator refused for payment
1120
+ * (accelerator spec 2026-10-06-paid-accounts-and-past-due, "Interfaces and
1121
+ * contracts").
1122
+ *
1123
+ * The accelerator answers such a write with a 402 whose body carries one of
1124
+ * three codes:
1125
+ * - `user_plan_required`: the app takes paid Muhkoo plans only, and the
1126
+ * signed-in user is on Free;
1127
+ * - `user_payment_past_due`: the user's own Muhkoo payment is past due. Only
1128
+ * first-party apps are told this; every other app is told
1129
+ * `user_plan_required` instead;
1130
+ * - `owner_payment_past_due`: the app owner's payment is past due, so the
1131
+ * app stores nothing new for anyone.
1132
+ * Reads, sign-in and deletes still work in all three cases.
1133
+ *
1134
+ * Every other 402 — the Free-tier refusals that carry `quotaExceeded`,
1135
+ * `requiresPaidTier` or `freeTierFull` — has no `code`, and stays a plain
1136
+ * `HttpError`, as before.
1137
+ */
1138
+
1139
+ /** Why a write was refused for payment. A wire contract: these strings never change. */
1140
+ type PaymentRequiredCode = "user_plan_required" | "user_payment_past_due" | "owner_payment_past_due";
1141
+ /** Thrown for a 402 whose body carries one of the three {@link PaymentRequiredCode}s. */
1142
+ declare class PaymentRequiredError extends HttpError {
1143
+ /** Why the write was refused. */
1144
+ readonly code: PaymentRequiredCode;
1145
+ /**
1146
+ * Where to send the user: the portal's upgrade page or its billing page,
1147
+ * as an absolute URL. Set only when the server sent an absolute http(s)
1148
+ * URL. The relative `upgradeUrl` of the Free-tier refusals is never here:
1149
+ * those are not this error.
1150
+ */
1151
+ readonly upgradeUrl?: string;
1152
+ constructor(message: string, code: PaymentRequiredCode, body?: unknown, upgradeUrl?: string);
1153
+ }
1154
+
1102
1155
  /**
1103
1156
  * Cloudflare-Workers-compatible Groth16 ZK proof verifier.
1104
1157
  *
@@ -2416,6 +2469,15 @@ interface ShardClientOptions {
2416
2469
  * Provided so callers can inject retries / auth / instrumentation.
2417
2470
  */
2418
2471
  fetch?: typeof fetch;
2472
+ /**
2473
+ * The same fetch with the client's silent re-authentication
2474
+ * (`HttpClient.fetchWithRecovery`), used for uploads only. A paid-only
2475
+ * app refuses a PUT made with a dead session with `401 session_required`;
2476
+ * through this, the session is re-established once and the PUT sent
2477
+ * again, which is safe because its bytes can be sent twice. Reads keep
2478
+ * {@link fetch}. Defaults to {@link fetch}.
2479
+ */
2480
+ fetchWithRecovery?: typeof fetch;
2419
2481
  /**
2420
2482
  * Optional offline byte cache. When present, GETs are served cache-first and
2421
2483
  * populated on success, and PUTs write the cache before the network so a
@@ -2462,6 +2524,8 @@ declare class ShardClient {
2462
2524
  private readonly baseUrl;
2463
2525
  private readonly pathPrefix;
2464
2526
  private readonly fetchFn;
2527
+ /** What a PUT goes through: {@link ShardClientOptions.fetchWithRecovery} when given, else {@link fetchFn}. */
2528
+ private readonly putFn;
2465
2529
  private readonly cache?;
2466
2530
  /** Hashes waiting for the next batch, each with everyone awaiting it and its size if a caller gave it. */
2467
2531
  private pendingShards;
@@ -2725,6 +2789,25 @@ declare class FileStorage {
2725
2789
  * origin) and per-chunk auth as {@link readFileFromShards}.
2726
2790
  */
2727
2791
  readChunksFromShards(manifest: FileManifest): AsyncGenerator<Uint8Array>;
2792
+ /**
2793
+ * Each chunk's plaintext, in order, with the next {@link READ_AHEAD_CHUNKS}
2794
+ * already being fetched.
2795
+ *
2796
+ * One chunk at a time, a large file cost a full round trip per 4 MB chunk
2797
+ * with nothing overlapping it: a 33 MB file was eight serial requests,
2798
+ * each mostly waiting. Within a chunk the shard reads were already
2799
+ * parallel; this overlaps the chunks too.
2800
+ *
2801
+ * Bounded on purpose: while the caller holds a yielded chunk, at most
2802
+ * `1 + READ_AHEAD_CHUNKS` more are in flight, and nothing new starts until
2803
+ * it asks for the next — a slow consumer of the stream is not run away
2804
+ * from. A failure surfaces at its own chunk, in order; reads already
2805
+ * started past it are let finish, their failures swallowed rather than
2806
+ * left unhandled. If the caller stops early (`break` or `return()`), no
2807
+ * further read starts and the ones in flight settle on their own; they are
2808
+ * not awaited, so `return()` is not delayed by a slow shard.
2809
+ */
2810
+ private chunksInOrder;
2728
2811
  /** As {@link writeFileToShards}, plus POSTs the manifest to `input.spaceId`. */
2729
2812
  writeFile(input: WriteFileInput): Promise<FileStat>;
2730
2813
  /** As {@link readFileFromShards}, but fetches the manifest from a space first. */
@@ -3895,12 +3978,7 @@ interface HttpClientOptions {
3895
3978
  */
3896
3979
  onUnauthorized?: () => Promise<boolean>;
3897
3980
  }
3898
- /** Thrown for any non-2xx accelerator response. Carries the HTTP status. */
3899
- declare class HttpError extends Error {
3900
- readonly status: number;
3901
- readonly body?: unknown | undefined;
3902
- constructor(message: string, status: number, body?: unknown | undefined);
3903
- }
3981
+
3904
3982
  declare class HttpClient {
3905
3983
  readonly baseUrl: string;
3906
3984
  /** Origin of {@link baseUrl} — credentials are only attached same-origin. */
@@ -4052,6 +4130,14 @@ interface QueueEntry {
4052
4130
  method: string;
4053
4131
  /** Serializable arguments captured at enqueue time. */
4054
4132
  args: unknown;
4133
+ /**
4134
+ * Whose write it is: the commitment of the user signed in when it was
4135
+ * queued, stamped by `OutboundQueue.enqueue`. A drain sends only the
4136
+ * signed-in user's entries, because every replayer builds its request
4137
+ * from the session signed in when it runs. Absent on entries an older
4138
+ * SDK queued, which any drain sends, as before.
4139
+ */
4140
+ commitment?: string;
4055
4141
  }
4056
4142
  interface OfflineEntry<T> {
4057
4143
  key: string;
@@ -4091,9 +4177,14 @@ interface OfflineStore {
4091
4177
  * mutation by re-invoking the real namespace method (with an `isReplay` flag so
4092
4178
  * it doesn't re-enqueue). `drain()` replays entries in HLC order:
4093
4179
  * - success → remove the entry;
4094
- * - permanent failure (4xx, or a Space whose member list refuses this user)
4095
- * → drop it and surface a `SYNC_ERROR` (a write the server will never
4096
- * accept must not wedge the queue forever);
4180
+ * - refused for payment (`PaymentRequiredError`: the app takes paid plans
4181
+ * only, or someone's payment is past due) → keep it and everything after
4182
+ * it, stop, and surface a `SYNC_ERROR` with `dropped: false`. The server
4183
+ * accepts it once the user or the app owner pays, so it waits for the next
4184
+ * reconnect, or for `client.app.access()` to report the app allowed;
4185
+ * - permanent failure (any other 4xx, or a Space whose member list refuses
4186
+ * this user) → drop it and surface a `SYNC_ERROR` (a write the server will
4187
+ * never accept must not wedge the queue forever);
4097
4188
  * - transient/network failure → stop draining and leave the rest for the next
4098
4189
  * reconnect.
4099
4190
  *
@@ -4121,7 +4212,11 @@ interface OutboundQueueOptions {
4121
4212
  * tests), every drain runs, as before.
4122
4213
  */
4123
4214
  tryLock?: TryLock;
4124
- /** Whose drain lock to take: the signed-in user's. With no one signed in, the drain runs unlocked. */
4215
+ /**
4216
+ * The signed-in user: stamps each enqueued write, picks which writes a
4217
+ * drain sends, and names the drain lock. With no one signed in, writes are
4218
+ * unstamped and the drain runs unlocked.
4219
+ */
4125
4220
  commitment?: () => string | null;
4126
4221
  }
4127
4222
  declare class OutboundQueue {
@@ -4132,10 +4227,25 @@ declare class OutboundQueue {
4132
4227
  constructor(store: OfflineStore, opts?: OutboundQueueOptions);
4133
4228
  /** A domain registers how to replay its mutations. */
4134
4229
  register(domain: QueueEntry["domain"], replayer: Replayer): void;
4135
- /** Record a mutation for later replay; resolves with its assigned seq. */
4230
+ /**
4231
+ * Record a mutation for later replay; resolves with its assigned seq.
4232
+ * Stamped with the signed-in user's commitment, so that it is only ever
4233
+ * sent under their session (see {@link waiting}).
4234
+ */
4136
4235
  enqueue(entry: Omit<QueueEntry, "seq">): Promise<number>;
4137
- /** Number of writes still awaiting sync. */
4236
+ /** Number of writes still awaiting sync, every user's. */
4138
4237
  pending(): Promise<number>;
4238
+ /**
4239
+ * The writes a drain would send now, in order: the signed-in user's, and
4240
+ * any an older SDK queued without saying whose they are. Every tab of an
4241
+ * origin shares this queue, and every replayer builds its request from
4242
+ * the session signed in when it runs, so another user's write sent now
4243
+ * would land in this user's space, or overwrite their data. It stays
4244
+ * queued, as it is, until its own user signs in on this device again.
4245
+ */
4246
+ waiting(): Promise<QueueEntry[]>;
4247
+ /** True for an entry this drain may send: the signed-in user's, or one with no user. */
4248
+ private sendable;
4139
4249
  /**
4140
4250
  * Replay queued mutations in HLC order. Coalesces concurrent calls into a
4141
4251
  * single in-flight drain. Stops on the first transient failure, leaving the
@@ -4149,6 +4259,10 @@ declare class OutboundQueue {
4149
4259
  * a drain after it finds only what it left.
4150
4260
  */
4151
4261
  private drainOnce;
4262
+ /**
4263
+ * One pass over the queue. False when a write refused for payment stopped
4264
+ * it, which leaves that write and everything after it queued.
4265
+ */
4152
4266
  private runDrain;
4153
4267
  }
4154
4268
 
@@ -4307,6 +4421,16 @@ declare class OfflineManager {
4307
4421
  * replayer re-PUTs from the cache on reconnect.
4308
4422
  */
4309
4423
  deferShardUpload(hash: string): Promise<void>;
4424
+ /**
4425
+ * Replay the queue now, as a reconnect does, if anything is waiting in it.
4426
+ * `client.app.access()` calls this each time it reports the app allowed,
4427
+ * so writes kept after a refusal for payment go out once the user or the
4428
+ * app owner has paid, without waiting for the next reconnect. One drain per
4429
+ * call, never on a timer. With nothing of the signed-in user's queued it
4430
+ * does not drain at all, so the app sees no "syncing". A drain also runs the
4431
+ * catch-up tasks (Space history paging), as a reconnect does.
4432
+ */
4433
+ resume(): Promise<void>;
4310
4434
  /** Resolve once the clock + node id are loaded. */
4311
4435
  ready(): Promise<void>;
4312
4436
  /** Current connectivity state (`online` | `offline` | `syncing`). */
@@ -5447,6 +5571,12 @@ interface SpaceDeps {
5447
5571
  httpBaseUrl: string;
5448
5572
  /** Header-injecting fetch from the client's HttpClient. */
5449
5573
  fetch: typeof fetch;
5574
+ /**
5575
+ * The same fetch with the client's silent 401 recovery (`HttpClient.fetchWithRecovery`). File uploads
5576
+ * use it, so a PUT made with a dead session re-establishes the session once instead of failing.
5577
+ * Defaults to {@link fetch}.
5578
+ */
5579
+ fetchWithRecovery?: typeof fetch;
5450
5580
  /** Resolves the user id used for the ratchet / member id (signed-in username). */
5451
5581
  myId: () => string;
5452
5582
  /** Resolves a short-lived WS upgrade ticket (or null when keyless). */
@@ -6583,6 +6713,68 @@ declare class AccessTokensNamespace {
6583
6713
  private path;
6584
6714
  }
6585
6715
 
6716
+ /**
6717
+ * `client.app` — what the signed-in user may do in this app (accelerator spec
6718
+ * 2026-10-06-paid-accounts-and-past-due, B6 and B8).
6719
+ *
6720
+ * An app's owner can turn on "Paid Muhkoo accounts only" in the portal. The
6721
+ * accelerator then refuses a Free user's writes that add data, with a 402 the
6722
+ * SDK throws as `PaymentRequiredError`. Reads, sign-in and deletes still work.
6723
+ * The same refusal reaches every user of an app whose owner's payment is past
6724
+ * due, whether or not the setting is on.
6725
+ *
6726
+ * `access()` asks up front, so an app can show the right screen before the
6727
+ * first refusal.
6728
+ */
6729
+
6730
+ /** The answer of `GET /api/app/access`. */
6731
+ interface AppAccess {
6732
+ /** The owner has turned on "Paid Muhkoo accounts only" for this app. */
6733
+ paidAccountsOnly: boolean;
6734
+ /** The signed-in user may add data in this app now. */
6735
+ allowed: boolean;
6736
+ /**
6737
+ * Why not: the code a refused write carries. Read only when `allowed` is
6738
+ * false, and only when it is one of the three codes.
6739
+ */
6740
+ reason?: PaymentRequiredCode;
6741
+ /**
6742
+ * Where to send the user, as an absolute URL: the portal's upgrade page
6743
+ * for `user_plan_required`, with a way back to this app when the request
6744
+ * came from one of its registered redirect URIs, or its billing page for
6745
+ * `user_payment_past_due`. The accelerator sends it only for those two
6746
+ * reasons: the user can do nothing about the owner's payment. Read only
6747
+ * when `allowed` is false, and only when it is an absolute http(s) URL.
6748
+ */
6749
+ upgradeUrl?: string;
6750
+ }
6751
+ interface AppNamespaceDeps {
6752
+ http: HttpClient;
6753
+ /**
6754
+ * Called each time `access()` answers `allowed: true`. The Client sends
6755
+ * the writes its offline queue kept after a refusal for payment
6756
+ * (`OfflineManager.resume`). A throw or a rejection is logged and ignored.
6757
+ */
6758
+ onAllowed?: () => Promise<void>;
6759
+ }
6760
+ declare class AppNamespace {
6761
+ private readonly deps;
6762
+ constructor(deps: AppNamespaceDeps);
6763
+ /**
6764
+ * Whether the signed-in user may add data in this app and, if not, why
6765
+ * and where to send them. Needs the app key and a session; a stale session
6766
+ * is re-established once, as for every request. The route is never
6767
+ * refused for payment. Throws `HttpError` for anything else, among them a
6768
+ * 401 without a session and a 404 from an accelerator older than the
6769
+ * route.
6770
+ *
6771
+ * Each `allowed: true` also sends any writes the offline queue kept after
6772
+ * a refusal for payment, without waiting for them. Call it after sign-in,
6773
+ * and again when the user comes back from the portal.
6774
+ */
6775
+ access(): Promise<AppAccess>;
6776
+ }
6777
+
6586
6778
  /**
6587
6779
  * Wire types for the VFS metadata layer.
6588
6780
  *
@@ -8207,6 +8399,8 @@ declare class Client {
8207
8399
  readonly functions: FunctionsNamespace;
8208
8400
  /** Access tokens — `client.accessTokens.create(appId, …)`, etc. */
8209
8401
  readonly accessTokens: AccessTokensNamespace;
8402
+ /** This app — `client.app.access()`: may the signed-in user add data here? */
8403
+ readonly app: AppNamespace;
8210
8404
  /** Offline cache + sync — `client.offline.status`, `client.offline.snapshot`, etc. */
8211
8405
  readonly offline: OfflineManager;
8212
8406
  private readonly session;
@@ -9493,7 +9687,7 @@ declare function getId(row: {
9493
9687
  * expect (and isn't serving a stale cached bundle). Keep this in sync with
9494
9688
  * `package.json` `version`.
9495
9689
  */
9496
- declare const VERSION = "0.15.0-alpha.4";
9690
+ declare const VERSION = "0.15.0-alpha.6";
9497
9691
 
9498
9692
  /**
9499
9693
  * The SDK's process-global logger.
@@ -9525,5 +9719,5 @@ declare global {
9525
9719
  }
9526
9720
  declare const appLogger: InstanceType<typeof Logger>;
9527
9721
 
9528
- export { ACCESS_TOKEN_SCOPES, AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, AccessTokensNamespace, AdmissionDeniedError, AgentsNamespace, AuthClient, AuthHttpError, AuthNamespace, AuthPublicInput, Authenticator, BlockEngine, BroadcastChannel, BroadcastChannelEvents, ChannelExistsError, ChannelNotFoundError, ChunkCipher, CircuitIntegrityError, Client, ConnectivityManager, DEFAULT_AUTH_BASE_URL, DEFAULT_BASE_URL, DEFAULT_BRANCH, DEFAULT_FN_HOST_SUFFIX, DEVICE_IDENTITY_STORAGE_KEY, DEVICE_KEY_DB_NAME, DbCache, DbNamespace, DbTable, DevicePairingError, DeviceRevokedError, DeviceStoreUnavailableError, DoubleRatchet, DoubleRatchetCipher, DoubleRatchetManager, EncryptedSession, EventCore, EventCoreEvents, Field, Field as FieldElement, FileStorage, FunctionsNamespace, HLC, HashKnowledge, HostedAuth, HttpClient, HttpError, IdentityLockedError, IdentityUnavailableError, IndexedDbStore, KEEPER_MEMBER_ID, KeyStore, KeyringClient, KeyringHttpError, KvCache, KvNamespace, LocalEngineHost, LocalStorageSessionStore, Logger, MemorySessionStore, Message, Message as MessageDefault, MessageNamespace, MuhkooAgent, MuhkooDB, MuhkooFunction, MuhkooSpace, NOT_MEMBER_CLOSE_CODE, NOT_MEMBER_RECHECK_MS, NoopStore, OfflineLockedError, OfflineManager, OutboundQueue, P2P_SUBJECT, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH, PBKDF2_DEFAULT_ITERATIONS, PINNED_CIRCUIT_DIGESTS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PasskeyOriginError, PeerExchange, PeerNetwork, PersonalSpaceClient, Poseidon, PreimagePoK, ROOT_ID, Ready, ReauthRequiredError, ReedSolomonCodec, Repo, Retry, Space as Room, SerializeMessage, SessionState, ShardCache, ShardClient, SharedSpaceClient, SnapshotNamespace, Space, SpaceCache, SpaceKeyring, SpaceNamespace, SpacePacketCipher, SpaceSignaler, SpaceTrustError, StorageNamespace, SyncEngine, VERSION, VFS_ROOT_INFO, VaultProtocolMismatchError, VaultUnavailableError, VcsError, VcsNamespace, VfsConflictError, VfsCorruptRecordError, VfsLimitError, VfsLockedError, VfsNamespace, VfsNotFoundError, WSTransport, WebRtcTransport, WorkerEngineHost, ZERO_HLC, ZkAuth, _accountId, _formatBytes, _messageId, _objectId, _packetId, _socketId, _userId, appLogger, assertType, base58Decode, base58Encode, buildCommitment, canonicalUserCode, clearDeviceIdentity, compareHlc, compilePrograms, concatBytes, configureDeviceStore, createPasskeyWithPrf, decodeFromHex, decorators, decryptAesGcm, defaultCircuitUrls, defaultRpId, defaultSessionStore, deleteBeatsWrite, deleteRegister, deriveAesKeyFromPassphrase, deriveBitsHkdf, deriveIdentity, deriveIdentityFromSeed, deriveMasterSeedFromPassword, deserialize, deviceFingerprint, deviceIdentityIsEphemeral, deviceIdentityKey, dirKey, ejectAgentPrompt, ejectAgentTools, emptyMap, emptyRegister, encodeToHex, encryptAesGcm, evaluatePasskeyPrf, exportPublicKeyBase64, exportPublicKeyHex, formatUserCode, fromBase64, fromBase64Url, fromHex, generateAuthProof, generateChecksum, generateDevicePairingKeypair, generateId, generatePkce, getIPAddress, getId, getMuhkooAppDescriptor, getSubtle, hasDeviceIdentity, headKey, historyKey, initBn128Wasm, initRsWasm, initializeCircuits, isNewer, isNumber, isOfflineCapable, isP2pCapable, isProvisional, isSameOriginPath, loadDeviceIdentity, log, manifestToStat, materializeRow, merge3, merge3Text, mergeKey, mergeMap, mergeMessage, mergeRegister, messageKey, objectKey, pack, padHandle, pairingVerificationCode, passkeyPrfCapable, passkeySupported, passkeyUsableFromOrigin, persistDeviceIdentity, poseidonHash, protocol, provisionalHandle, quickVerify, randomBytes, randomState, refKey, refsIndexKey, rpIdUsableForOrigin, sealSeed, sealSeedToDevice, serialize, shardHash, signMessage, stableStringify, toBase64, toBase64Url, toField, toHex, tombstoneRow, unpack, unsealSeed, unsealSeedFromDevice, unwrapWithPassphrase, utf8Decode, utf8Encode, verify, verifyChecksum, verifyGroth16, verifyHashKnowledge, verifyPreimagePoK, wrapWithPassphrase, writeBeatsTombstone, writeColumns, writeRegister };
9529
- export type { ACL, ACLEntry, AccessTokenInfo, AccessTokensNamespaceDeps, AdmissionState, AgentConfig, AgentCreateInput, AgentDbToolMode, AgentProvisioned, AgentScopeOpts, AgentSkill, AgentToolsConfig, AgentTrigger, AgentTriggerType, AgentUpdateInput, AgentsNamespaceDeps, AttachedPeerNetwork, AuthClientOptions, AuthKeyPair, AuthSuccess, AuthToken, AuthType, AuthUser, BlockStore, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, CachedSpaceMessage, Change, ChannelLike, ChatKeyCert, ChunkKeyMaterial, ChunkManifest, CipherFrame, CipherMessage, CipherMessageHeader, CircuitBufferConfig, CircuitIntegrity, CircuitUrls, ClientOptions, Commit, Conflict, ConnectivityOptions, ConnectivityState, CreateAccessTokenInput, CreatedAccessToken, DbFilterOp, DbNamespaceDeps, DbQuery, DbQueryPage, DbQueryResult, DbWhereCondition, DehydratedKeypair, DehydratedKeys, DeviceBlobStore, DeviceKeyVault, DevicePairingErrorReason, DevicePairingKeypair, DevicePairingPoll, DevicePairingRequest, DevicePairingSession, DirEntry, DirNode, DoubleRatchetCipherDeps, ECDHCurve, EncodeResult, EngineHandle, EngineHost, Entry, EphemeralEvent, EpochKeyProvider, FileEntry, FileManifest, FileNamespaceDeps, FileStat, FileStorageOptions, FunctionCaps, FunctionConfig, FunctionDeployInput, FunctionInvokeOptions, FunctionScopeOpts, FunctionTrigger, FunctionTriggerType, FunctionTriggers, FunctionUpdateInput, FunctionsNamespaceDeps, Groth16Proof, Hasher, Head, HistoryRecord, HlcParts, HlcState, HostedAuthDeps, HttpClientOptions, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, KeyringClientDeps, KeyringTransport, KvEntry, KvNamespaceDeps, LogEntry, LoginOptions, LwwMap, LwwRegister, MemberView, MembershipEntry, Merge3Result, MergeRegionConflict, MergeResult, MessageBody, MessageDeletedEvent, MessageEntry, MessageEvent, MessageHeaders, MessageNamespaceDeps, MessageOp, MessageOptions, MessageSubscription, MuhkooAgentMeta, MuhkooAgentToolsConfig, MuhkooAppDescriptor, MuhkooDBAccess, MuhkooDBMeta, MuhkooFunctionMeta, MuhkooKeystoreBridge, MuhkooMessageEvent, MuhkooSpaceMeta, OAuthProvider, OfflineEntry, OfflineManagerDeps, OfflineStore, OutSink, PacketCipher, PacketHeaders, PacketOptions, PairedDevice, Participant, PasskeyEnrollment, PeerBlockSource, PeerExchangeOptions, PeerId, PeerNetworkOptions, PeerTransport, Permission, PermissionCheckRequest, PermissionCheckResult, PersistedDeviceIdentity, PersonalSpaceClientOptions, Pkce, PublicKeyJWK, QueueEntry, RatchetState, ReceiveResult, RegisterParams, Replayer, Role$1 as Role, SpaceDeps as RoomDeps, SpaceFileMetadata as RoomFileMetadata, Scope, SealedHandoff, SealedHeaders, SealedRecord, Session, SessionOptions, SessionStore, SetOptions, ShardByteCache, ShardClientOptions, SharedSpaceClientOptions, SignalEnvelope, SignalKind, SignalingSpace, SnapshotNamespaceDeps, SnarkProof, SpaceChannelLike, SpaceCursor, SpaceDeps, SpaceFileMetadata, SpaceKeyCache, SpaceKeyringDeps, SpaceMessageEvent, SpaceNamespaceDeps, SpaceOfflineAdapter, SpaceTrustCode, StartDevicePairingOptions, StorageChangeEvent, StoreName, StoredSession, Subscription, Tree, TreeDir, TreeEntry, TreeFile, UserIdentity, VaultFactor, VcsNamespaceDeps, VcsNamespaceOptions, VerificationKey, VfsContentStore, VfsNamespaceDeps, VfsStat, VfsStore, WSMessage, WSMessageType, WSTransportOptions, WaitForDevicePairingOptions, WebRtcTransportOptions, WrappedPayload, WriteFileInput, WriteFileOptions, WriteToShardsInput, ZkAuthDeps, ZkAuthenticateRequest, ZkChallengeResponse, ZkCompiled, ZkIdentity, ZkRegisterRequest, ZkRegisterResponse };
9722
+ export { ACCESS_TOKEN_SCOPES, AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, AccessTokensNamespace, AdmissionDeniedError, AgentsNamespace, AppNamespace, AuthClient, AuthHttpError, AuthNamespace, AuthPublicInput, Authenticator, BlockEngine, BroadcastChannel, BroadcastChannelEvents, ChannelExistsError, ChannelNotFoundError, ChunkCipher, CircuitIntegrityError, Client, ConnectivityManager, DEFAULT_AUTH_BASE_URL, DEFAULT_BASE_URL, DEFAULT_BRANCH, DEFAULT_FN_HOST_SUFFIX, DEVICE_IDENTITY_STORAGE_KEY, DEVICE_KEY_DB_NAME, DbCache, DbNamespace, DbTable, DevicePairingError, DeviceRevokedError, DeviceStoreUnavailableError, DoubleRatchet, DoubleRatchetCipher, DoubleRatchetManager, EncryptedSession, EventCore, EventCoreEvents, Field, Field as FieldElement, FileStorage, FunctionsNamespace, HLC, HashKnowledge, HostedAuth, HttpClient, HttpError, IdentityLockedError, IdentityUnavailableError, IndexedDbStore, KEEPER_MEMBER_ID, KeyStore, KeyringClient, KeyringHttpError, KvCache, KvNamespace, LocalEngineHost, LocalStorageSessionStore, Logger, MemorySessionStore, Message, Message as MessageDefault, MessageNamespace, MuhkooAgent, MuhkooDB, MuhkooFunction, MuhkooSpace, NOT_MEMBER_CLOSE_CODE, NOT_MEMBER_RECHECK_MS, NoopStore, OfflineLockedError, OfflineManager, OutboundQueue, P2P_SUBJECT, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH, PBKDF2_DEFAULT_ITERATIONS, PINNED_CIRCUIT_DIGESTS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PasskeyOriginError, PaymentRequiredError, PeerExchange, PeerNetwork, PersonalSpaceClient, Poseidon, PreimagePoK, ROOT_ID, Ready, ReauthRequiredError, ReedSolomonCodec, Repo, Retry, Space as Room, SerializeMessage, SessionState, ShardCache, ShardClient, SharedSpaceClient, SnapshotNamespace, Space, SpaceCache, SpaceKeyring, SpaceNamespace, SpacePacketCipher, SpaceSignaler, SpaceTrustError, StorageNamespace, SyncEngine, VERSION, VFS_ROOT_INFO, VaultProtocolMismatchError, VaultUnavailableError, VcsError, VcsNamespace, VfsConflictError, VfsCorruptRecordError, VfsLimitError, VfsLockedError, VfsNamespace, VfsNotFoundError, WSTransport, WebRtcTransport, WorkerEngineHost, ZERO_HLC, ZkAuth, _accountId, _formatBytes, _messageId, _objectId, _packetId, _socketId, _userId, appLogger, assertType, base58Decode, base58Encode, buildCommitment, canonicalUserCode, clearDeviceIdentity, compareHlc, compilePrograms, concatBytes, configureDeviceStore, createPasskeyWithPrf, decodeFromHex, decorators, decryptAesGcm, defaultCircuitUrls, defaultRpId, defaultSessionStore, deleteBeatsWrite, deleteRegister, deriveAesKeyFromPassphrase, deriveBitsHkdf, deriveIdentity, deriveIdentityFromSeed, deriveMasterSeedFromPassword, deserialize, deviceFingerprint, deviceIdentityIsEphemeral, deviceIdentityKey, dirKey, ejectAgentPrompt, ejectAgentTools, emptyMap, emptyRegister, encodeToHex, encryptAesGcm, evaluatePasskeyPrf, exportPublicKeyBase64, exportPublicKeyHex, formatUserCode, fromBase64, fromBase64Url, fromHex, generateAuthProof, generateChecksum, generateDevicePairingKeypair, generateId, generatePkce, getIPAddress, getId, getMuhkooAppDescriptor, getSubtle, hasDeviceIdentity, headKey, historyKey, initBn128Wasm, initRsWasm, initializeCircuits, isNewer, isNumber, isOfflineCapable, isP2pCapable, isProvisional, isSameOriginPath, loadDeviceIdentity, log, manifestToStat, materializeRow, merge3, merge3Text, mergeKey, mergeMap, mergeMessage, mergeRegister, messageKey, objectKey, pack, padHandle, pairingVerificationCode, passkeyPrfCapable, passkeySupported, passkeyUsableFromOrigin, persistDeviceIdentity, poseidonHash, protocol, provisionalHandle, quickVerify, randomBytes, randomState, refKey, refsIndexKey, rpIdUsableForOrigin, sealSeed, sealSeedToDevice, serialize, shardHash, signMessage, stableStringify, toBase64, toBase64Url, toField, toHex, tombstoneRow, unpack, unsealSeed, unsealSeedFromDevice, unwrapWithPassphrase, utf8Decode, utf8Encode, verify, verifyChecksum, verifyGroth16, verifyHashKnowledge, verifyPreimagePoK, wrapWithPassphrase, writeBeatsTombstone, writeColumns, writeRegister };
9723
+ export type { ACL, ACLEntry, AccessTokenInfo, AccessTokensNamespaceDeps, AdmissionState, AgentConfig, AgentCreateInput, AgentDbToolMode, AgentProvisioned, AgentScopeOpts, AgentSkill, AgentToolsConfig, AgentTrigger, AgentTriggerType, AgentUpdateInput, AgentsNamespaceDeps, AppAccess, AppNamespaceDeps, AttachedPeerNetwork, AuthClientOptions, AuthKeyPair, AuthSuccess, AuthToken, AuthType, AuthUser, BlockStore, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, CachedSpaceMessage, Change, ChannelLike, ChatKeyCert, ChunkKeyMaterial, ChunkManifest, CipherFrame, CipherMessage, CipherMessageHeader, CircuitBufferConfig, CircuitIntegrity, CircuitUrls, ClientOptions, Commit, Conflict, ConnectivityOptions, ConnectivityState, CreateAccessTokenInput, CreatedAccessToken, DbFilterOp, DbNamespaceDeps, DbQuery, DbQueryPage, DbQueryResult, DbWhereCondition, DehydratedKeypair, DehydratedKeys, DeviceBlobStore, DeviceKeyVault, DevicePairingErrorReason, DevicePairingKeypair, DevicePairingPoll, DevicePairingRequest, DevicePairingSession, DirEntry, DirNode, DoubleRatchetCipherDeps, ECDHCurve, EncodeResult, EngineHandle, EngineHost, Entry, EphemeralEvent, EpochKeyProvider, FileEntry, FileManifest, FileNamespaceDeps, FileStat, FileStorageOptions, FunctionCaps, FunctionConfig, FunctionDeployInput, FunctionInvokeOptions, FunctionScopeOpts, FunctionTrigger, FunctionTriggerType, FunctionTriggers, FunctionUpdateInput, FunctionsNamespaceDeps, Groth16Proof, Hasher, Head, HistoryRecord, HlcParts, HlcState, HostedAuthDeps, HttpClientOptions, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, KeyringClientDeps, KeyringTransport, KvEntry, KvNamespaceDeps, LogEntry, LoginOptions, LwwMap, LwwRegister, MemberView, MembershipEntry, Merge3Result, MergeRegionConflict, MergeResult, MessageBody, MessageDeletedEvent, MessageEntry, MessageEvent, MessageHeaders, MessageNamespaceDeps, MessageOp, MessageOptions, MessageSubscription, MuhkooAgentMeta, MuhkooAgentToolsConfig, MuhkooAppDescriptor, MuhkooDBAccess, MuhkooDBMeta, MuhkooFunctionMeta, MuhkooKeystoreBridge, MuhkooMessageEvent, MuhkooSpaceMeta, OAuthProvider, OfflineEntry, OfflineManagerDeps, OfflineStore, OutSink, PacketCipher, PacketHeaders, PacketOptions, PairedDevice, Participant, PasskeyEnrollment, PaymentRequiredCode, PeerBlockSource, PeerExchangeOptions, PeerId, PeerNetworkOptions, PeerTransport, Permission, PermissionCheckRequest, PermissionCheckResult, PersistedDeviceIdentity, PersonalSpaceClientOptions, Pkce, PublicKeyJWK, QueueEntry, RatchetState, ReceiveResult, RegisterParams, Replayer, Role$1 as Role, SpaceDeps as RoomDeps, SpaceFileMetadata as RoomFileMetadata, Scope, SealedHandoff, SealedHeaders, SealedRecord, Session, SessionOptions, SessionStore, SetOptions, ShardByteCache, ShardClientOptions, SharedSpaceClientOptions, SignalEnvelope, SignalKind, SignalingSpace, SnapshotNamespaceDeps, SnarkProof, SpaceChannelLike, SpaceCursor, SpaceDeps, SpaceFileMetadata, SpaceKeyCache, SpaceKeyringDeps, SpaceMessageEvent, SpaceNamespaceDeps, SpaceOfflineAdapter, SpaceTrustCode, StartDevicePairingOptions, StorageChangeEvent, StoreName, StoredSession, Subscription, Tree, TreeDir, TreeEntry, TreeFile, UserIdentity, VaultFactor, VcsNamespaceDeps, VcsNamespaceOptions, VerificationKey, VfsContentStore, VfsNamespaceDeps, VfsStat, VfsStore, WSMessage, WSMessageType, WSTransportOptions, WaitForDevicePairingOptions, WebRtcTransportOptions, WrappedPayload, WriteFileInput, WriteFileOptions, WriteToShardsInput, ZkAuthDeps, ZkAuthenticateRequest, ZkChallengeResponse, ZkCompiled, ZkIdentity, ZkRegisterRequest, ZkRegisterResponse };
@@ -1179,6 +1179,59 @@ declare class BroadcastChannel {
1179
1179
  private handleInboundFrame;
1180
1180
  }
1181
1181
 
1182
+ /**
1183
+ * `HttpError` — thrown for any non-2xx accelerator response.
1184
+ *
1185
+ * In a module of its own so that `PaymentRequiredError` can extend it while
1186
+ * `HttpClient`, which throws both, imports `PaymentRequiredError`: with the
1187
+ * class in `HttpClient.ts`, the two modules would import each other, and
1188
+ * whichever loaded second would extend a class not yet defined. `HttpClient`
1189
+ * re-exports it, so `import { HttpError } from "./HttpClient"` still works.
1190
+ */
1191
+ /** Thrown for any non-2xx accelerator response. Carries the HTTP status. */
1192
+ declare class HttpError extends Error {
1193
+ readonly status: number;
1194
+ readonly body?: unknown | undefined;
1195
+ constructor(message: string, status: number, body?: unknown | undefined);
1196
+ }
1197
+
1198
+ /**
1199
+ * `PaymentRequiredError` — a write the accelerator refused for payment
1200
+ * (accelerator spec 2026-10-06-paid-accounts-and-past-due, "Interfaces and
1201
+ * contracts").
1202
+ *
1203
+ * The accelerator answers such a write with a 402 whose body carries one of
1204
+ * three codes:
1205
+ * - `user_plan_required`: the app takes paid Muhkoo plans only, and the
1206
+ * signed-in user is on Free;
1207
+ * - `user_payment_past_due`: the user's own Muhkoo payment is past due. Only
1208
+ * first-party apps are told this; every other app is told
1209
+ * `user_plan_required` instead;
1210
+ * - `owner_payment_past_due`: the app owner's payment is past due, so the
1211
+ * app stores nothing new for anyone.
1212
+ * Reads, sign-in and deletes still work in all three cases.
1213
+ *
1214
+ * Every other 402 — the Free-tier refusals that carry `quotaExceeded`,
1215
+ * `requiresPaidTier` or `freeTierFull` — has no `code`, and stays a plain
1216
+ * `HttpError`, as before.
1217
+ */
1218
+
1219
+ /** Why a write was refused for payment. A wire contract: these strings never change. */
1220
+ type PaymentRequiredCode = "user_plan_required" | "user_payment_past_due" | "owner_payment_past_due";
1221
+ /** Thrown for a 402 whose body carries one of the three {@link PaymentRequiredCode}s. */
1222
+ declare class PaymentRequiredError extends HttpError {
1223
+ /** Why the write was refused. */
1224
+ readonly code: PaymentRequiredCode;
1225
+ /**
1226
+ * Where to send the user: the portal's upgrade page or its billing page,
1227
+ * as an absolute URL. Set only when the server sent an absolute http(s)
1228
+ * URL. The relative `upgradeUrl` of the Free-tier refusals is never here:
1229
+ * those are not this error.
1230
+ */
1231
+ readonly upgradeUrl?: string;
1232
+ constructor(message: string, code: PaymentRequiredCode, body?: unknown, upgradeUrl?: string);
1233
+ }
1234
+
1182
1235
  /**
1183
1236
  * Cloudflare-Workers-compatible Groth16 ZK proof verifier.
1184
1237
  *
@@ -1221,5 +1274,5 @@ declare function initBn128Wasm(wasmModule?: WebAssembly.Module): Promise<Bn128Wa
1221
1274
  */
1222
1275
  declare function verifyGroth16(wasmInstance: WebAssembly.Instance, memory: WebAssembly.Memory, initialPFree: number, verificationKey: VerificationKey, proof: Groth16Proof, publicSignals: string[]): Promise<boolean>;
1223
1276
 
1224
- export { AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, BroadcastChannel, BroadcastChannelEvents, ChunkCipher, DoubleRatchet, EncryptedSession, EventCore, EventCoreEvents, KeyStore, Message, Message as MessageDefault, PBKDF2_DEFAULT_ITERATIONS, PREIMAGE_POK_VERIFICATION_KEY, Packet, SerializeMessage, WSTransport, decorators, decryptAesGcm, deriveAesKeyFromPassphrase, deriveBitsHkdf, encryptAesGcm, getSubtle, initBn128Wasm, randomBytes, unwrapWithPassphrase, verifyGroth16, wrapWithPassphrase };
1225
- export type { ACL, ACLEntry, AuthKeyPair, AuthType, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, ChunkKeyMaterial, CipherFrame, CipherMessage, CipherMessageHeader, DehydratedKeypair, DehydratedKeys, ECDHCurve, Groth16Proof, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, MessageBody, MessageEvent, MessageHeaders, MessageOptions, OAuthProvider, PacketOptions, Participant, Permission, PermissionCheckRequest, PermissionCheckResult, PublicKeyJWK, RatchetState, ReceiveResult, Role, Session, SessionOptions, Subscription, UserIdentity, VerificationKey, WSMessage, WSMessageType, WSTransportOptions, WrappedPayload };
1277
+ export { AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, BroadcastChannel, BroadcastChannelEvents, ChunkCipher, DoubleRatchet, EncryptedSession, EventCore, EventCoreEvents, KeyStore, Message, Message as MessageDefault, PBKDF2_DEFAULT_ITERATIONS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PaymentRequiredError, SerializeMessage, WSTransport, decorators, decryptAesGcm, deriveAesKeyFromPassphrase, deriveBitsHkdf, encryptAesGcm, getSubtle, initBn128Wasm, randomBytes, unwrapWithPassphrase, verifyGroth16, wrapWithPassphrase };
1278
+ export type { ACL, ACLEntry, AuthKeyPair, AuthType, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, ChunkKeyMaterial, CipherFrame, CipherMessage, CipherMessageHeader, DehydratedKeypair, DehydratedKeys, ECDHCurve, Groth16Proof, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, MessageBody, MessageEvent, MessageHeaders, MessageOptions, OAuthProvider, PacketOptions, Participant, PaymentRequiredCode, Permission, PermissionCheckRequest, PermissionCheckResult, PublicKeyJWK, RatchetState, ReceiveResult, Role, Session, SessionOptions, Subscription, UserIdentity, VerificationKey, WSMessage, WSMessageType, WSTransportOptions, WrappedPayload };