@usearete/sdk 0.2.0 → 0.4.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.
Files changed (39) hide show
  1. package/README.md +118 -0
  2. package/dist/index.cjs +7393 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.ts +802 -129
  5. package/dist/index.esm.js +3447 -526
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/ssr/handlers.cjs +794 -0
  8. package/dist/ssr/handlers.cjs.map +1 -0
  9. package/dist/ssr/handlers.esm.js +523 -4
  10. package/dist/ssr/handlers.esm.js.map +1 -1
  11. package/dist/ssr/index.cjs +795 -0
  12. package/dist/ssr/index.cjs.map +1 -0
  13. package/dist/ssr/index.esm.js +523 -4
  14. package/dist/ssr/index.esm.js.map +1 -1
  15. package/dist/ssr/nextjs-app.cjs +859 -0
  16. package/dist/ssr/nextjs-app.cjs.map +1 -0
  17. package/dist/ssr/nextjs-app.esm.js +523 -4
  18. package/dist/ssr/nextjs-app.esm.js.map +1 -1
  19. package/dist/ssr/tanstack-start.cjs +881 -0
  20. package/dist/ssr/tanstack-start.cjs.map +1 -0
  21. package/dist/ssr/tanstack-start.esm.js +523 -4
  22. package/dist/ssr/tanstack-start.esm.js.map +1 -1
  23. package/dist/ssr/vite.cjs +887 -0
  24. package/dist/ssr/vite.cjs.map +1 -0
  25. package/dist/ssr/vite.esm.js +523 -4
  26. package/dist/ssr/vite.esm.js.map +1 -1
  27. package/package.json +10 -8
  28. package/dist/index.js +0 -4448
  29. package/dist/index.js.map +0 -1
  30. package/dist/ssr/handlers.js +0 -294
  31. package/dist/ssr/handlers.js.map +0 -1
  32. package/dist/ssr/index.js +0 -295
  33. package/dist/ssr/index.js.map +0 -1
  34. package/dist/ssr/nextjs-app.js +0 -359
  35. package/dist/ssr/nextjs-app.js.map +0 -1
  36. package/dist/ssr/tanstack-start.js +0 -381
  37. package/dist/ssr/tanstack-start.js.map +0 -1
  38. package/dist/ssr/vite.js +0 -387
  39. package/dist/ssr/vite.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,3 +1,78 @@
1
+ import { Buffer } from 'buffer';
2
+
3
+ type TransactionCommitment = 'processed' | 'confirmed' | 'finalized';
4
+ type TransactionAuthScope = 'transaction:inspect' | 'transaction:send';
5
+ interface TransactionRequestContext {
6
+ commitment?: TransactionCommitment;
7
+ minContextSlot?: bigint;
8
+ }
9
+ interface LatestBlockhashResult {
10
+ blockhash: string;
11
+ contextSlot: bigint;
12
+ lastValidBlockHeight: bigint;
13
+ }
14
+ interface TransactionFeeResult {
15
+ feeLamports: bigint | null;
16
+ contextSlot: bigint;
17
+ }
18
+ interface TransactionSimulationOptions extends TransactionRequestContext {
19
+ accounts?: readonly string[];
20
+ innerInstructions?: boolean;
21
+ replaceRecentBlockhash?: boolean;
22
+ }
23
+ interface TransactionSimulationResult {
24
+ contextSlot: bigint;
25
+ err: unknown | null;
26
+ logs: readonly string[] | null;
27
+ unitsConsumed?: bigint;
28
+ accounts?: readonly unknown[] | null;
29
+ }
30
+ interface TransactionSendOptions {
31
+ skipPreflight?: boolean;
32
+ preflightCommitment?: TransactionCommitment;
33
+ minContextSlot?: bigint;
34
+ }
35
+ interface TransactionSendResult {
36
+ signature: string;
37
+ }
38
+ interface TransactionSignatureStatus {
39
+ signature: string;
40
+ slot: bigint | null;
41
+ confirmationStatus: TransactionCommitment | null;
42
+ err: unknown | null;
43
+ }
44
+ interface TransactionTransportErrorBody {
45
+ code: string;
46
+ message: string;
47
+ retryable: boolean;
48
+ request_id?: string;
49
+ submission_state?: 'not_submitted' | 'unknown';
50
+ signature?: string;
51
+ details?: unknown;
52
+ }
53
+ declare class TransactionTransportError extends Error {
54
+ readonly code: string;
55
+ readonly retryable: boolean;
56
+ readonly requestId?: string;
57
+ readonly submissionState?: 'not_submitted' | 'unknown';
58
+ readonly signature?: string;
59
+ readonly details?: unknown;
60
+ readonly status: number;
61
+ constructor(status: number, body: TransactionTransportErrorBody);
62
+ }
63
+ interface TransactionTransport {
64
+ getLatestBlockhash(options?: TransactionRequestContext): Promise<LatestBlockhashResult>;
65
+ getFeeForMessage(message: string, options?: TransactionRequestContext): Promise<TransactionFeeResult>;
66
+ simulateTransaction(transaction: string, options?: TransactionSimulationOptions): Promise<TransactionSimulationResult>;
67
+ sendTransaction(transaction: string, options?: TransactionSendOptions): Promise<TransactionSendResult>;
68
+ getSignatureStatus(signature: string, options?: TransactionRequestContext & {
69
+ searchTransactionHistory?: boolean;
70
+ }): Promise<TransactionSignatureStatus | null>;
71
+ getBlockHeight(options?: TransactionRequestContext): Promise<bigint>;
72
+ }
73
+ type AuthenticatedTransactionFetch = (input: string, init: RequestInit, scope: TransactionAuthScope, allowAuthReplay: boolean) => Promise<Response>;
74
+ declare function createTransactionTransport(baseUrl: string, authenticatedFetch: AuthenticatedTransactionFetch): TransactionTransport;
75
+
1
76
  /**
2
77
  * Wallet adapter boundary for the Arete SDK.
3
78
  *
@@ -7,6 +82,7 @@
7
82
  * boundary, implemented by adapters that wrap the Solana library of your choice
8
83
  * (@solana/web3.js, @solana/kit, a raw Keypair signer for scripts, etc.).
9
84
  */
85
+
10
86
  /**
11
87
  * A single account reference within a built instruction.
12
88
  */
@@ -70,6 +146,35 @@ interface SendResult {
70
146
  /** Slot in which the transaction landed, if the adapter reports it */
71
147
  slot?: number;
72
148
  }
149
+ /**
150
+ * Adapter-specific options for unsigned transaction inspection.
151
+ *
152
+ * Inspection must not sign or submit the transaction. Concrete adapters may
153
+ * accept additional simulation options through this passthrough object.
154
+ */
155
+ interface TransactionInspectionOptions {
156
+ [key: string]: unknown;
157
+ }
158
+ /**
159
+ * Unsigned transaction inspection returned by a capable wallet adapter.
160
+ */
161
+ interface TransactionInspectionResult {
162
+ /** Estimated transaction fee in lamports, when available. */
163
+ feeLamports?: number;
164
+ /** Program logs produced by simulation, when available. */
165
+ logs?: readonly string[];
166
+ /** Compute units consumed by simulation, when available. */
167
+ computeUnitsConsumed?: number;
168
+ /** RPC context slot for the inspection, when available. */
169
+ contextSlot?: number;
170
+ /** Raw simulation failure, if the inspected transaction would fail. */
171
+ error?: unknown;
172
+ /** Adapter-specific inspection fields. */
173
+ [key: string]: unknown;
174
+ }
175
+ interface WalletExecutionContext {
176
+ transactionTransport?: TransactionTransport;
177
+ }
73
178
  /**
74
179
  * Wallet adapter interface for signing and sending transactions.
75
180
  *
@@ -93,7 +198,14 @@ interface WalletAdapter {
93
198
  * @param options - Adapter-specific send/confirmation options
94
199
  * @returns The transaction signature (and slot, if known)
95
200
  */
96
- signAndSend(instructions: readonly BuiltInstruction[], options?: SendOptions): Promise<SendResult>;
201
+ signAndSend(instructions: readonly BuiltInstruction[], options?: SendOptions, context?: WalletExecutionContext): Promise<SendResult>;
202
+ /**
203
+ * Inspect a transaction without signing, submitting, or prompting a wallet.
204
+ *
205
+ * This capability is optional because not every adapter has an RPC-backed
206
+ * unsigned simulation implementation.
207
+ */
208
+ inspectTransaction?(instructions: readonly BuiltInstruction[], options?: TransactionInspectionOptions, context?: WalletExecutionContext): Promise<TransactionInspectionResult>;
97
209
  }
98
210
  /**
99
211
  * Wallet connection state
@@ -272,6 +384,7 @@ declare function createPublicKeySeed(address: string): Uint8Array;
272
384
  * This module handles serializing instruction arguments into the binary format
273
385
  * expected by Solana programs using Borsh serialization.
274
386
  */
387
+
275
388
  /**
276
389
  * Instruction argument schema for serialization.
277
390
  */
@@ -352,6 +465,46 @@ interface ErrorMetadata {
352
465
  name: string;
353
466
  msg: string;
354
467
  }
468
+ type TransactionFailureStatus = 'not-submitted' | 'submitted-unknown' | 'chain-failed';
469
+ type TransactionFailurePhase = 'build' | 'wallet' | 'send' | 'confirmation' | 'chain';
470
+ interface ConfirmedTransactionOutcome {
471
+ readonly status: 'confirmed';
472
+ readonly phase: 'confirmation';
473
+ readonly signature: string;
474
+ readonly slot?: number;
475
+ }
476
+ interface NotSubmittedTransactionOutcome {
477
+ readonly status: 'not-submitted';
478
+ readonly phase: 'build' | 'wallet' | 'send';
479
+ readonly cause: unknown;
480
+ }
481
+ interface SubmittedUnknownTransactionOutcome {
482
+ readonly status: 'submitted-unknown';
483
+ readonly phase: 'send' | 'confirmation';
484
+ readonly signature: string;
485
+ readonly slot?: number;
486
+ readonly cause: unknown;
487
+ }
488
+ interface ChainFailedTransactionOutcome {
489
+ readonly status: 'chain-failed';
490
+ readonly phase: 'confirmation' | 'chain';
491
+ readonly signature?: string;
492
+ readonly slot?: number;
493
+ readonly programError?: ProgramError;
494
+ readonly cause: unknown;
495
+ }
496
+ type TransactionFailureOutcome = NotSubmittedTransactionOutcome | SubmittedUnknownTransactionOutcome | ChainFailedTransactionOutcome;
497
+ type TransactionOutcome = ConfirmedTransactionOutcome | TransactionFailureOutcome;
498
+ /**
499
+ * Structured transaction failure thrown by adapters and the core executor.
500
+ */
501
+ declare class TransactionExecutionError extends Error {
502
+ readonly outcome: TransactionFailureOutcome;
503
+ readonly cause: unknown;
504
+ readonly signature?: string;
505
+ readonly slot?: number;
506
+ constructor(outcome: TransactionFailureOutcome, message?: string);
507
+ }
355
508
  /**
356
509
  * Parses an error returned from a Solana transaction.
357
510
  *
@@ -359,7 +512,7 @@ interface ErrorMetadata {
359
512
  * @param errorMetadata - Error definitions from the IDL
360
513
  * @returns Parsed program error or null if not a program error
361
514
  */
362
- declare function parseInstructionError(error: unknown, errorMetadata: ErrorMetadata[]): ProgramError | null;
515
+ declare function parseInstructionError(error: unknown, errorMetadata: readonly ErrorMetadata[]): ProgramError | null;
363
516
  /**
364
517
  * Formats an error for display.
365
518
  *
@@ -376,8 +529,18 @@ declare class InstructionError extends Error {
376
529
  readonly programError: ProgramError | null;
377
530
  /** The original underlying error from the wallet adapter / RPC. */
378
531
  readonly cause: unknown;
379
- constructor(message: string, programError: ProgramError | null, cause: unknown);
532
+ /** Structured chain-failure outcome, including signature and slot when known. */
533
+ readonly outcome: ChainFailedTransactionOutcome;
534
+ readonly signature?: string;
535
+ readonly slot?: number;
536
+ constructor(message: string, programError: ProgramError | null, cause: unknown, outcome?: ChainFailedTransactionOutcome);
380
537
  }
538
+ /** Find a structured transaction failure through nested error causes. */
539
+ declare function getTransactionFailureOutcome(error: unknown): TransactionFailureOutcome | null;
540
+ /**
541
+ * Normalize an adapter/host exception without retrying or resubmitting.
542
+ */
543
+ declare function normalizeTransactionError(cause: unknown, errorMetadata?: readonly ErrorMetadata[], fallbackPhase?: 'wallet' | 'send'): InstructionError | TransactionExecutionError;
381
544
 
382
545
  /**
383
546
  * Resolved accounts map passed to a handler's build function.
@@ -546,6 +709,9 @@ type Update<T> = {
546
709
  type: 'patch';
547
710
  key: string;
548
711
  data: Partial<T>;
712
+ } | {
713
+ type: 'remove';
714
+ key: string;
549
715
  } | {
550
716
  type: 'delete';
551
717
  key: string;
@@ -560,15 +726,23 @@ type RichUpdate<T> = {
560
726
  before: T;
561
727
  after: T;
562
728
  patch?: unknown;
729
+ } | {
730
+ type: 'removed';
731
+ key: string;
732
+ lastKnown?: T;
563
733
  } | {
564
734
  type: 'deleted';
565
735
  key: string;
566
736
  lastKnown?: T;
567
737
  };
568
- interface ViewDef<T, TMode extends 'state' | 'list'> {
738
+ type ViewKeyValue = string | number | bigint;
739
+ type ViewKeyFields<TKey> = unknown extends TKey ? readonly string[] : TKey extends object ? readonly Extract<keyof TKey, string>[] : readonly string[];
740
+ interface ViewDef<T, TMode extends 'state' | 'list', TKey = unknown> {
569
741
  readonly mode: TMode;
570
742
  readonly view: string;
743
+ readonly keyFields?: ViewKeyFields<TKey>;
571
744
  readonly _entity?: T;
745
+ readonly _key?: TKey;
572
746
  }
573
747
  interface StackEndpoints {
574
748
  readonly ws: string;
@@ -577,10 +751,26 @@ interface StackEndpoints {
577
751
  type ReadTransportMethod = 'GET' | 'POST';
578
752
  interface ProgramAccountReadDefinition<T> {
579
753
  readonly account: string;
580
- readonly path: string;
581
754
  readonly schema?: Schema<T>;
582
755
  readonly _result?: T;
583
756
  }
757
+ type ProgramAccountBatchItem<T> = {
758
+ readonly address: string;
759
+ readonly status: 'ok';
760
+ readonly value: T;
761
+ } | {
762
+ readonly address: string;
763
+ readonly status: 'missing';
764
+ } | {
765
+ readonly address: string;
766
+ readonly status: 'error';
767
+ readonly error: {
768
+ readonly code: string;
769
+ };
770
+ };
771
+ interface ProgramAccountBatchResult<T> {
772
+ readonly items: readonly ProgramAccountBatchItem<T>[];
773
+ }
584
774
  interface ProgramQueryDefinition<TParams = unknown, TResult = unknown> {
585
775
  readonly name: string;
586
776
  readonly path: string;
@@ -600,6 +790,11 @@ interface StackQueryDefinition<TParams = unknown, TResult = unknown> {
600
790
  interface ProgramSdkDefinition {
601
791
  readonly name: string;
602
792
  readonly programId?: string;
793
+ /** Typed identity of the generated program behavior and compiler provenance. */
794
+ readonly sdkDefinitionHash?: string;
795
+ readonly programSpecHash?: string;
796
+ readonly idlContentHash?: string;
797
+ readonly normalizedIdlHash?: string;
603
798
  readonly schemas?: Record<string, Schema<unknown>>;
604
799
  readonly pdas?: Record<string, unknown>;
605
800
  readonly accounts?: Record<string, ProgramAccountReadDefinition<unknown>>;
@@ -610,33 +805,140 @@ interface ProgramSdkDefinition {
610
805
  readonly defaults?: unknown;
611
806
  readonly math?: unknown;
612
807
  }
613
- interface StackDefinition {
808
+ interface ProgramReleaseReference {
809
+ readonly programReleaseHash: string;
810
+ readonly programSpecHash: string;
811
+ }
812
+ /** Public, non-secret metadata describing how an HTTP bearer token is acquired. */
813
+ interface HttpAuthMetadata {
814
+ readonly required?: boolean;
815
+ readonly mode?: string;
816
+ readonly sessionEndpoint: string;
817
+ readonly jwksUrl?: string;
818
+ readonly tokenTransport?: string;
819
+ readonly audience?: string;
820
+ readonly targetKind: 'program-read-binding';
821
+ readonly targetId: string;
822
+ readonly scopes?: readonly string[];
823
+ readonly acceptedKeyClasses?: readonly string[];
824
+ }
825
+ interface ProgramReadBinding {
826
+ readonly endpoint: string;
827
+ readonly programReadBindingId: string;
828
+ readonly auth: HttpAuthMetadata;
829
+ }
830
+ type SolanaGatewayAuthScope = 'read' | 'transaction:inspect' | 'transaction:send';
831
+ /** Complete public auth metadata emitted for a hosted Solana gateway binding. */
832
+ interface SolanaGatewayAuthMetadata {
833
+ readonly required: boolean;
834
+ readonly mode: string;
835
+ readonly sessionEndpoint: string;
836
+ readonly jwksUrl: string;
837
+ readonly tokenTransport: string;
838
+ readonly audience: 'arete:solana-gateway';
839
+ readonly targetKind: 'solana-gateway-binding';
840
+ readonly targetId: string;
841
+ readonly scopes: readonly SolanaGatewayAuthScope[];
842
+ readonly acceptedKeyClasses: readonly string[];
843
+ readonly transactionEntitlementRequired: boolean;
844
+ }
845
+ /** One generated, non-inheriting hosted Solana gateway capability binding. */
846
+ interface HostedSolanaGatewayCapabilityBinding {
847
+ readonly endpoint: string;
848
+ readonly authPolicy: string;
849
+ readonly solanaGatewayBindingId: string;
850
+ readonly cluster: string;
851
+ readonly region: string;
852
+ readonly auth: SolanaGatewayAuthMetadata;
853
+ }
854
+ interface HostedSolanaGatewayBindings {
855
+ readonly chain: HostedSolanaGatewayCapabilityBinding;
856
+ readonly transactions: HostedSolanaGatewayCapabilityBinding;
857
+ }
858
+ /** Generated release identity with one explicit, non-inheriting read transport. */
859
+ type ProgramReadDescriptor = {
860
+ readonly release: ProgramReleaseReference;
861
+ readonly transport: {
862
+ readonly kind: 'local-http';
863
+ readonly endpointSource: 'connect-http-url';
864
+ };
865
+ } | {
866
+ readonly release: ProgramReleaseReference;
867
+ readonly transport: {
868
+ readonly kind: 'hosted-binding';
869
+ readonly binding: ProgramReadBinding;
870
+ };
871
+ };
872
+ /** Runtime overrides replace the complete generated descriptor. */
873
+ type ProgramReadOverride = ProgramReadDescriptor;
874
+ type ProgramReadDescriptors<TPrograms extends Record<string, ProgramSdkDefinition> | undefined> = TPrograms extends Record<string, ProgramSdkDefinition> ? {
875
+ readonly [K in keyof TPrograms]: ProgramReadDescriptor;
876
+ } : Record<string, never>;
877
+ type ProgramReadOverrides<TPrograms extends Record<string, ProgramSdkDefinition> | undefined> = TPrograms extends Record<string, ProgramSdkDefinition> ? {
878
+ readonly [K in keyof TPrograms]?: ProgramReadOverride;
879
+ } : Record<string, never>;
880
+ interface StackDefinition<TPrograms extends Record<string, ProgramSdkDefinition> = Record<string, ProgramSdkDefinition>> {
614
881
  readonly name: string;
615
882
  readonly endpoints: StackEndpoints;
616
883
  readonly views: Record<string, ViewGroup>;
617
884
  readonly schemas?: Record<string, Schema<unknown>>;
618
885
  readonly patchSchemas?: Record<string, Schema<unknown>>;
619
886
  readonly queries?: Record<string, StackQueryDefinition<unknown, unknown>>;
620
- readonly programs?: Record<string, ProgramSdkDefinition>;
887
+ readonly programs?: TPrograms;
888
+ /** Release and transport metadata keyed in parallel with `programs`. */
889
+ readonly programReads?: ProgramReadDescriptors<TPrograms>;
621
890
  }
622
891
  interface ViewGroup {
623
- state?: ViewDef<unknown, 'state'>;
624
- list?: ViewDef<unknown, 'list'>;
892
+ state?: ViewDef<any, 'state', any>;
893
+ list?: ViewDef<any, 'list'>;
625
894
  }
626
- interface Subscription {
895
+ interface SubscriptionQuery {
627
896
  view: string;
628
897
  key?: string;
629
898
  partition?: string;
630
- filters?: Record<string, string>;
899
+ filters?: Record<string, unknown>;
631
900
  take?: number;
632
901
  skip?: number;
633
- /** Whether to include initial snapshot (defaults to true for backward compatibility) */
634
- withSnapshot?: boolean;
635
- /** Cursor for resuming from a specific point (_seq value) */
636
902
  after?: string;
637
- /** Maximum number of entities to include in snapshot (pagination hint) */
638
903
  snapshotLimit?: number;
639
904
  }
905
+ interface SubscriptionSnapshotOptions {
906
+ enabled: boolean;
907
+ }
908
+ /** Protocol v2 wire subscription. The client-selected ID remains stable across reconnects. */
909
+ interface Subscription {
910
+ type: 'subscribe';
911
+ protocolVersion: 2;
912
+ subscriptionId: string;
913
+ query: SubscriptionQuery;
914
+ snapshot: SubscriptionSnapshotOptions;
915
+ }
916
+ interface SubscriptionRequest {
917
+ query: SubscriptionQuery;
918
+ snapshot?: Partial<SubscriptionSnapshotOptions>;
919
+ }
920
+ /** Canonical query identity includes every server query field and snapshot behavior. */
921
+ type SubscriptionIdentity = SubscriptionRequest;
922
+ type SubscriptionOptions = SubscriptionSnapshotOptions;
923
+ interface QuerySnapshot<T = unknown> {
924
+ readonly subscriptionId: string;
925
+ readonly query: SubscriptionQuery;
926
+ readonly keys: readonly string[];
927
+ readonly data: readonly T[];
928
+ readonly isLoading: boolean;
929
+ readonly isRefreshing: boolean;
930
+ readonly error?: AreteError;
931
+ }
932
+ interface QueryLease {
933
+ readonly subscription: Subscription;
934
+ readonly queryKey: string;
935
+ getSnapshot<T = unknown>(): QuerySnapshot<T>;
936
+ onChange(callback: () => void): UnsubscribeFn;
937
+ onUpdate<T = unknown>(callback: (update: Update<T>) => void): UnsubscribeFn;
938
+ onRichUpdate<T = unknown>(callback: (update: RichUpdate<T>) => void): UnsubscribeFn;
939
+ refresh(): Promise<void>;
940
+ release(): void;
941
+ }
640
942
  type SchemaResult<T> = {
641
943
  success: true;
642
944
  data: T;
@@ -648,9 +950,10 @@ interface Schema<T> {
648
950
  safeParse: (input: unknown) => SchemaResult<T>;
649
951
  }
650
952
  interface WatchOptions<TSchema = unknown> {
953
+ partition?: string;
651
954
  take?: number;
652
955
  skip?: number;
653
- filters?: Record<string, string>;
956
+ filters?: Record<string, unknown>;
654
957
  schema?: Schema<TSchema>;
655
958
  /** Whether to include initial snapshot (defaults to true) */
656
959
  withSnapshot?: boolean;
@@ -661,6 +964,9 @@ interface WatchOptions<TSchema = unknown> {
661
964
  }
662
965
  interface AreteOptions<TStack extends StackDefinition> {
663
966
  stack: TStack;
967
+ /** Connect immediately when the client is created (defaults to true). */
968
+ autoConnect?: boolean;
969
+ /** Reconnect automatically after an established connection is lost (defaults to true). */
664
970
  autoReconnect?: boolean;
665
971
  reconnectIntervals?: number[];
666
972
  maxReconnectAttempts?: number;
@@ -671,7 +977,29 @@ interface AuthTokenResult {
671
977
  token: string;
672
978
  expiresAt?: number;
673
979
  expires_at?: number;
674
- }
980
+ scopes?: readonly string[];
981
+ }
982
+ interface ProgramReadBindingAuthTarget {
983
+ readonly targetKind: 'program-read-binding';
984
+ readonly targetId: string;
985
+ readonly programReleaseHash: string;
986
+ }
987
+ interface SolanaGatewayBindingAuthTarget {
988
+ readonly targetKind: 'solana-gateway-binding';
989
+ readonly targetId: string;
990
+ readonly programReleaseHash?: never;
991
+ }
992
+ type AuthTokenTarget = ProgramReadBindingAuthTarget | SolanaGatewayBindingAuthTarget;
993
+ type AuthTokenRequest = {
994
+ readonly scopes: readonly string[];
995
+ readonly targetKind?: never;
996
+ readonly targetId?: never;
997
+ readonly programReleaseHash?: never;
998
+ } | ({
999
+ readonly scopes: readonly string[];
1000
+ } & ProgramReadBindingAuthTarget) | ({
1001
+ readonly scopes: readonly string[];
1002
+ } & SolanaGatewayBindingAuthTarget);
675
1003
  interface WebSocketFactoryInit {
676
1004
  headers?: Record<string, string>;
677
1005
  }
@@ -680,7 +1008,7 @@ interface WebSocketFactoryInit {
680
1008
  */
681
1009
  interface AuthConfig {
682
1010
  /** Custom token provider function - called before each connection and during refresh */
683
- getToken?: () => Promise<string | AuthTokenResult>;
1011
+ getToken?: (request?: AuthTokenRequest) => Promise<string | AuthTokenResult>;
684
1012
  /** Arete Cloud token endpoint URL */
685
1013
  tokenEndpoint?: string;
686
1014
  /** Publishable key for Arete Cloud */
@@ -699,24 +1027,29 @@ interface AuthConfig {
699
1027
  interface AreteConfig {
700
1028
  /** WebSocket endpoint. `null`/omitted disables the WebSocket transport (HTTP-only mode). */
701
1029
  websocketUrl?: string | null;
1030
+ /** Reconnect automatically after an established connection is lost (defaults to true). */
1031
+ autoReconnect?: boolean;
702
1032
  reconnectIntervals?: number[];
703
1033
  maxReconnectAttempts?: number;
704
1034
  initialSubscriptions?: Subscription[];
705
1035
  maxEntriesPerView?: number | null;
706
1036
  /** Authentication configuration */
707
1037
  auth?: AuthConfig;
1038
+ /** Fetch implementation used for authentication token requests. */
1039
+ fetch?: typeof fetch;
708
1040
  }
709
1041
  interface SocketIssue {
710
1042
  error: string;
711
1043
  message: string;
712
- code: AuthErrorCode;
1044
+ code: string | AuthErrorCode;
713
1045
  retryable: boolean;
714
1046
  retryAfter?: number;
715
1047
  suggestedAction?: string;
716
1048
  docsUrl?: string;
717
1049
  fatal: boolean;
1050
+ subscriptionId?: string | null;
718
1051
  }
719
- declare const DEFAULT_CONFIG: Required<Pick<AreteConfig, 'reconnectIntervals' | 'maxReconnectAttempts' | 'maxEntriesPerView'>>;
1052
+ declare const DEFAULT_CONFIG: Required<Pick<AreteConfig, 'autoReconnect' | 'reconnectIntervals' | 'maxReconnectAttempts' | 'maxEntriesPerView'>>;
720
1053
  /**
721
1054
  * Machine-readable error codes for authentication and rate limiting failures
722
1055
  *
@@ -732,21 +1065,22 @@ type TypedViews<TViews extends StackDefinition['views']> = {
732
1065
  [K in keyof TViews]: TypedViewGroup<TViews[K]>;
733
1066
  };
734
1067
  type TypedViewGroup<TGroup> = {
735
- [K in keyof TGroup]: TGroup[K] extends ViewDef<infer T, 'state'> ? TypedStateView<T> : TGroup[K] extends ViewDef<infer T, 'list'> ? TypedListView<T> : never;
1068
+ [K in keyof TGroup]: TGroup[K] extends ViewDef<infer T, 'state', infer TKey> ? TypedStateView<T, DefaultViewKey<TKey>> : TGroup[K] extends ViewDef<infer T, 'list'> ? TypedListView<T> : never;
736
1069
  };
737
- interface TypedStateView<T> {
738
- use<TSchema = T>(key: string, options?: WatchOptions<TSchema>): AsyncIterable<TSchema>;
739
- watch(key: string, options?: WatchOptions): AsyncIterable<Update<T>>;
740
- watchRich(key: string, options?: WatchOptions): AsyncIterable<RichUpdate<T>>;
741
- get(key: string): Promise<T | null>;
742
- getSync(key: string): T | null | undefined;
1070
+ type DefaultViewKey<TKey> = unknown extends TKey ? string : TKey;
1071
+ interface TypedStateView<T, TKey = string> {
1072
+ use<TSchema = T>(key: TKey, options?: WatchOptions<TSchema>): AsyncIterable<TSchema>;
1073
+ watch(key: TKey, options?: WatchOptions): AsyncIterable<Update<T>>;
1074
+ watchRich(key: TKey, options?: WatchOptions): AsyncIterable<RichUpdate<T>>;
1075
+ get(key: TKey, options?: WatchOptions): Promise<T | null>;
1076
+ getSync(key: TKey, options?: WatchOptions): T | null | undefined;
743
1077
  }
744
1078
  interface TypedListView<T> {
745
1079
  use<TSchema = T>(options?: WatchOptions<TSchema>): AsyncIterable<TSchema>;
746
1080
  watch(options?: WatchOptions): AsyncIterable<Update<T>>;
747
1081
  watchRich(options?: WatchOptions): AsyncIterable<RichUpdate<T>>;
748
- get(): Promise<T[]>;
749
- getSync(): T[] | undefined;
1082
+ get(options?: WatchOptions): Promise<T[]>;
1083
+ getSync(options?: WatchOptions): T[] | undefined;
750
1084
  }
751
1085
  type SubscribeCallback<T> = (update: Update<T>) => void;
752
1086
  type UnsubscribeFn = () => void;
@@ -754,52 +1088,77 @@ type ConnectionStateCallback = (state: ConnectionState, error?: string) => void;
754
1088
  type SocketIssueCallback = (issue: SocketIssue) => void;
755
1089
 
756
1090
  type FrameMode = 'state' | 'append' | 'list';
757
- type FrameOp = 'create' | 'upsert' | 'patch' | 'delete' | 'snapshot' | 'subscribed';
1091
+ type FrameOp = 'subscribed' | 'unsubscribed' | 'snapshot' | 'upsert' | 'patch' | 'remove' | 'delete';
758
1092
  type SortOrder = 'asc' | 'desc';
759
1093
  interface SortConfig {
760
1094
  field: string[];
761
1095
  order: SortOrder;
762
1096
  }
763
- interface SubscribedFrame {
1097
+ interface IdentifiedFrame {
1098
+ protocolVersion: 2;
1099
+ subscriptionId: string;
1100
+ }
1101
+ interface SubscribedFrame extends IdentifiedFrame {
764
1102
  op: 'subscribed';
765
- view: string;
1103
+ query: SubscriptionQuery;
766
1104
  mode: FrameMode;
767
1105
  sort?: SortConfig;
768
1106
  }
769
- interface EntityFrame<T = unknown> {
1107
+ interface UnsubscribedFrame extends IdentifiedFrame {
1108
+ op: 'unsubscribed';
1109
+ }
1110
+ interface EntityFrame<T = unknown> extends IdentifiedFrame {
770
1111
  mode: FrameMode;
771
1112
  entity: string;
772
- op: FrameOp;
1113
+ op: 'upsert' | 'patch' | 'remove' | 'delete';
773
1114
  key: string;
774
- data: T;
1115
+ data: T | null;
775
1116
  append?: string[];
776
- /** Sequence cursor for ordering and resume capability */
777
1117
  seq?: string;
778
1118
  }
779
1119
  interface SnapshotEntity<T = unknown> {
780
1120
  key: string;
781
1121
  data: T;
782
1122
  }
783
- interface SnapshotFrame<T = unknown> {
1123
+ interface SnapshotFrame<T = unknown> extends IdentifiedFrame {
1124
+ snapshotId: string;
1125
+ authoritative: boolean;
784
1126
  mode: FrameMode;
785
1127
  entity: string;
786
1128
  op: 'snapshot';
1129
+ key?: string;
787
1130
  data: SnapshotEntity<T>[];
788
- /** Indicates if this is the final snapshot batch. When false, more batches will follow. */
789
- complete?: boolean;
1131
+ complete: boolean;
1132
+ }
1133
+ interface ErrorFrame {
1134
+ type: 'error';
1135
+ protocolVersion: 2;
1136
+ subscriptionId: string | null;
1137
+ error?: string;
1138
+ message?: string;
1139
+ code: string;
1140
+ retryable?: boolean;
1141
+ fatal: boolean;
1142
+ retry_after?: number;
1143
+ suggested_action?: string;
1144
+ docs_url?: string;
790
1145
  }
791
- type Frame<T = unknown> = EntityFrame<T> | SnapshotFrame<T> | SubscribedFrame;
1146
+ type Frame<T = unknown> = EntityFrame<T> | SnapshotFrame<T> | SubscribedFrame | UnsubscribedFrame | ErrorFrame;
792
1147
  declare function isSnapshotFrame<T>(frame: Frame<T>): frame is SnapshotFrame<T>;
793
1148
  declare function isSubscribedFrame(frame: Frame): frame is SubscribedFrame;
1149
+ declare function isUnsubscribedFrame(frame: Frame): frame is UnsubscribedFrame;
1150
+ declare function isErrorFrame(frame: Frame): frame is ErrorFrame;
794
1151
  declare function isEntityFrame<T>(frame: Frame<T>): frame is EntityFrame<T>;
795
1152
  declare function parseFrame(data: ArrayBuffer | string): Frame;
796
1153
  declare function parseFrameFromBlob(blob: Blob): Promise<Frame>;
797
1154
  declare function isValidFrame(frame: unknown): frame is Frame;
798
1155
 
799
1156
  type FrameHandler = <T>(frame: Frame<T>) => void;
1157
+ declare function isHostedAreteEndpoint(url: string): boolean;
800
1158
  declare class ConnectionManager {
801
1159
  private ws;
802
1160
  private websocketUrl;
1161
+ private readonly autoReconnect;
803
1162
  private reconnectIntervals;
804
1163
  private maxReconnectAttempts;
805
1164
  private reconnectAttempts;
@@ -807,15 +1166,22 @@ declare class ConnectionManager {
807
1166
  private pingInterval;
808
1167
  private tokenRefreshTimeout;
809
1168
  private tokenRefreshInFlight;
1169
+ private tokenRequestInFlight;
1170
+ private readonly httpAuthTokenStates;
810
1171
  private currentState;
811
1172
  private subscriptionQueue;
812
1173
  private activeSubscriptions;
1174
+ private socketGeneration;
1175
+ private pendingConnect;
813
1176
  private frameHandlers;
814
1177
  private stateHandlers;
815
1178
  private socketIssueHandlers;
816
1179
  private authConfig?;
1180
+ private readonly authFetch;
817
1181
  private currentToken?;
818
1182
  private tokenExpiry?;
1183
+ private tokenScopes;
1184
+ private requestedScopes;
819
1185
  private readonly hostedAreteUrl;
820
1186
  private reconnectForTokenRefresh;
821
1187
  constructor(config: AreteConfig);
@@ -824,9 +1190,17 @@ declare class ConnectionManager {
824
1190
  private hasRefreshableAuth;
825
1191
  private updateTokenState;
826
1192
  private clearTokenState;
1193
+ private tokenCovers;
827
1194
  private getOrRefreshToken;
1195
+ private fetchAuthToken;
1196
+ private requestAuthToken;
1197
+ private updateHttpTokenState;
1198
+ private getTargetedHttpAuthToken;
1199
+ private touchHttpAuthTokenState;
1200
+ private trimHttpAuthTokenStates;
828
1201
  private createTokenEndpointRequestBody;
829
1202
  private fetchTokenFromEndpoint;
1203
+ private isExpiryExpired;
830
1204
  private isTokenExpired;
831
1205
  private scheduleTokenRefresh;
832
1206
  private clearTokenRefreshTimeout;
@@ -840,19 +1214,28 @@ declare class ConnectionManager {
840
1214
  private createWebSocket;
841
1215
  getState(): ConnectionState;
842
1216
  getHttpAuthToken(forceRefresh?: boolean): Promise<string | undefined>;
1217
+ getHttpAuthToken(requiredScopes?: readonly string[], forceRefresh?: boolean): Promise<string | undefined>;
1218
+ getHttpAuthToken(request: AuthTokenRequest, forceRefresh?: boolean): Promise<string | undefined>;
1219
+ getHttpAuthToken(target: AuthTokenTarget, forceRefresh?: boolean): Promise<string | undefined>;
1220
+ getHttpAuthToken(target: AuthTokenTarget, requiredScopes: readonly string[], forceRefresh?: boolean): Promise<string | undefined>;
1221
+ getHttpAuthToken(requiredScopes: readonly string[], target: AuthTokenTarget, forceRefresh?: boolean): Promise<string | undefined>;
1222
+ getHttpAuthToken(requiredScopes: readonly string[], forceRefresh: boolean, target: AuthTokenTarget): Promise<string | undefined>;
843
1223
  clearHttpAuthToken(): void;
1224
+ clearHttpAuthToken(request: AuthTokenRequest): void;
1225
+ clearHttpAuthToken(target: AuthTokenTarget, requiredScopes?: readonly string[]): void;
844
1226
  onFrame(handler: FrameHandler): () => void;
845
1227
  onStateChange(handler: ConnectionStateCallback): () => void;
846
1228
  onSocketIssue(handler: SocketIssueCallback): () => void;
847
1229
  private notifySocketIssue;
848
- connect(): Promise<void>;
1230
+ connect(recovering?: boolean): Promise<void>;
849
1231
  disconnect(): void;
850
1232
  subscribe(subscription: Subscription): void;
851
- unsubscribe(view: string, key?: string): void;
1233
+ unsubscribe(subscriptionId: string): void;
1234
+ refresh(subscription: Subscription): void;
852
1235
  isConnected(): boolean;
853
- private makeSubKey;
854
1236
  private flushSubscriptionQueue;
855
1237
  private resubscribeActive;
1238
+ private addQueuedSubscription;
856
1239
  private updateState;
857
1240
  private notifyFrameHandlers;
858
1241
  private handleReconnect;
@@ -893,16 +1276,169 @@ interface StorageAdapter {
893
1276
  notifyRichUpdate<T>(viewPath: string, key: string, update: RichUpdate<T>): void;
894
1277
  }
895
1278
 
1279
+ declare class QueryStore {
1280
+ private readonly storage;
1281
+ private readonly records;
1282
+ constructor(storage: StorageAdapter);
1283
+ register(subscription: Subscription, queryKey: string): void;
1284
+ unregister(subscriptionId: string): void;
1285
+ getSubscription(subscriptionId: string): Subscription | undefined;
1286
+ getQueryKey(subscriptionId: string): string | undefined;
1287
+ getSnapshot<T>(subscriptionId: string): QuerySnapshot<T> | undefined;
1288
+ onChange(subscriptionId: string, callback: () => void): UnsubscribeFn;
1289
+ onUpdate<T>(subscriptionId: string, callback: (update: Update<T>) => void): UnsubscribeFn;
1290
+ onRichUpdate<T>(subscriptionId: string, callback: (update: RichUpdate<T>) => void): UnsubscribeFn;
1291
+ acknowledge(subscriptionId: string, effectiveQuery: SubscriptionQuery, mode: FrameMode, sort?: SortConfig): void;
1292
+ stageSnapshot(frame: SnapshotFrame, keys: readonly string[]): void;
1293
+ applyLive(subscriptionId: string, key: string, update: Update<unknown>, richUpdate?: RichUpdate<unknown>, sequence?: string): void;
1294
+ deleteGlobal(view: string, key: string, lastKnown?: unknown): void;
1295
+ evict(view: string, key: string): void;
1296
+ failFrame(frame: ErrorFrame): void;
1297
+ beginRefresh(subscriptionId: string, waitForSnapshot?: boolean): Promise<void>;
1298
+ failRefresh(subscriptionId: string, error: AreteError): void;
1299
+ beginReconnect(): void;
1300
+ failRefreshing(error: AreteError): void;
1301
+ clear(): void;
1302
+ private mergeIncremental;
1303
+ private sortKeys;
1304
+ private entitySequence;
1305
+ private fail;
1306
+ private resolveRefresh;
1307
+ private rejectRefresh;
1308
+ private requireRecord;
1309
+ private touch;
1310
+ private emitUpdate;
1311
+ private emitRichUpdate;
1312
+ }
1313
+
1314
+ interface WaitForProcessedSlotOptions {
1315
+ /** Reject if the requested slot has not been processed within this duration. */
1316
+ timeoutMs?: number;
1317
+ /** Abort this wait without affecting frame processing or the connection. */
1318
+ signal?: AbortSignal;
1319
+ }
1320
+ declare class ProcessedSlotTimeoutError extends Error {
1321
+ readonly targetSlot: bigint;
1322
+ readonly processedSlot: bigint | null;
1323
+ constructor(targetSlot: bigint, processedSlot: bigint | null);
1324
+ }
1325
+ interface FrameProcessorConfig {
1326
+ maxEntriesPerView?: number | null;
1327
+ /**
1328
+ * Interval in milliseconds to buffer frames before flushing to storage.
1329
+ * Set to 0 for immediate processing (no buffering).
1330
+ * Default: 0 (immediate)
1331
+ *
1332
+ * For React applications, 16ms (one frame at 60fps) is recommended to
1333
+ * reduce unnecessary re-renders during high-frequency updates.
1334
+ */
1335
+ flushIntervalMs?: number;
1336
+ schemas?: Record<string, Schema<unknown>>;
1337
+ patchSchemas?: Record<string, Schema<unknown>>;
1338
+ queryStore?: QueryStore;
1339
+ /** Whether rejected frames should also be written to `console.warn`. */
1340
+ warnOnValidationError?: boolean;
1341
+ /** Receives structured details whenever a generated schema rejects a frame. */
1342
+ onValidationError?: (diagnostic: FrameValidationDiagnostic) => void;
1343
+ }
1344
+ interface FrameValidationDiagnostic {
1345
+ readonly view: string;
1346
+ readonly key?: string;
1347
+ readonly seq?: string;
1348
+ readonly operation: 'snapshot' | 'upsert' | 'patch';
1349
+ readonly error: unknown;
1350
+ }
1351
+ declare class FrameProcessor {
1352
+ private storage;
1353
+ private maxEntriesPerView;
1354
+ private flushIntervalMs;
1355
+ private schemas?;
1356
+ private patchSchemas?;
1357
+ private queryStore?;
1358
+ private warnOnValidationError;
1359
+ private onValidationError?;
1360
+ private pendingUpdates;
1361
+ private flushTimer;
1362
+ private isProcessing;
1363
+ private latestProcessedSlot;
1364
+ private processedSlotWaiters;
1365
+ constructor(storage: StorageAdapter, config?: FrameProcessorConfig);
1366
+ private getSchema;
1367
+ private normalizeEntity;
1368
+ private hasSchema;
1369
+ private normalizePathSegment;
1370
+ private normalizePath;
1371
+ private normalizeSortConfig;
1372
+ private normalizeAppendPaths;
1373
+ private extractSeq;
1374
+ private getInternalSeq;
1375
+ private compareSeq;
1376
+ private attachInternalSeq;
1377
+ handleFrame<T>(frame: Frame<T>): void;
1378
+ /**
1379
+ * Immediately flush all pending updates.
1380
+ * Useful for ensuring all updates are processed before reading state.
1381
+ */
1382
+ flush(): void;
1383
+ getProcessedSlot(): bigint | null;
1384
+ waitForProcessedSlot(slot: number | bigint, options?: WaitForProcessedSlotOptions): Promise<bigint>;
1385
+ /**
1386
+ * Clean up any pending timers. Call when disposing the processor.
1387
+ */
1388
+ dispose(): void;
1389
+ private scheduleFlush;
1390
+ private flushPendingUpdates;
1391
+ private processFrame;
1392
+ private normalizeSlot;
1393
+ private slotFromSeq;
1394
+ private frameSlot;
1395
+ private markFrameProcessed;
1396
+ private removeProcessedSlotWaiter;
1397
+ private createAbortError;
1398
+ private processFrameWithoutEnforce;
1399
+ private handleSubscribedFrame;
1400
+ private handleSnapshotFrame;
1401
+ private handleSnapshotFrameWithoutEnforce;
1402
+ private handleEntityFrame;
1403
+ private handleEntityFrameWithoutEnforce;
1404
+ private emitRichUpdate;
1405
+ private createRichUpdate;
1406
+ private enforceMaxEntries;
1407
+ }
1408
+
1409
+ interface NormalizedSubscriptionRequest {
1410
+ query: SubscriptionQuery;
1411
+ snapshot: SubscriptionSnapshotOptions;
1412
+ }
1413
+ declare function validateSubscriptionId(subscriptionId: string): void;
1414
+ declare function createSubscriptionId(): string;
1415
+ declare function normalizeSubscriptionQuery(query: SubscriptionQuery): SubscriptionQuery;
1416
+ declare function normalizeSubscriptionRequest(request: SubscriptionRequest): NormalizedSubscriptionRequest;
1417
+ declare function canonicalQueryKey(request: SubscriptionRequest): string;
1418
+ declare function normalizeSubscription(subscription: Subscription): Subscription;
896
1419
  declare class SubscriptionRegistry {
897
- private subscriptions;
898
- private connection;
899
- constructor(connection: ConnectionManager);
900
- subscribe(subscription: Subscription): UnsubscribeFn;
901
- unsubscribe(subscription: Subscription): void;
902
- getRefCount(subscription: Subscription): number;
1420
+ private readonly connection;
1421
+ private readonly queryStore;
1422
+ private readonly subscriptions;
1423
+ private readonly subscriptionsById;
1424
+ constructor(connection: ConnectionManager, queryStore: QueryStore);
1425
+ subscribe(query: SubscriptionQuery, snapshotEnabled?: boolean): QueryLease;
1426
+ refresh(query: SubscriptionQuery, snapshotEnabled?: boolean): Promise<void>;
1427
+ /**
1428
+ * Refresh every active subscription for a view, optionally narrowed to one
1429
+ * serialized key. Resolves immediately when nothing matches — refreshing a
1430
+ * view with no active subscriptions is a no-op, not an error.
1431
+ */
1432
+ refreshView(view: string, key?: string): Promise<void>;
1433
+ getRefCount(query: SubscriptionQuery, snapshotEnabled?: boolean): number;
903
1434
  getActiveSubscriptions(): Subscription[];
1435
+ getSnapshot<T>(query: SubscriptionQuery, snapshotEnabled?: boolean): QuerySnapshot<T> | undefined;
1436
+ handleConnectionState(state: ConnectionState): void;
904
1437
  clear(): void;
905
- private makeSubKey;
1438
+ private createLease;
1439
+ private getTracker;
1440
+ private refreshTracker;
1441
+ private releaseTracker;
906
1442
  }
907
1443
 
908
1444
  interface ChainClock {
@@ -936,6 +1472,19 @@ interface TokenBalanceInfo {
936
1472
  amount: string;
937
1473
  decimals?: number | null;
938
1474
  uiAmountString?: string | null;
1475
+ contextSlot: bigint;
1476
+ }
1477
+ interface NativeBalanceInfo {
1478
+ lamports: bigint;
1479
+ contextSlot: bigint;
1480
+ }
1481
+ interface ContextSlotOptions {
1482
+ minContextSlot?: number | bigint;
1483
+ }
1484
+ interface TokenBalanceInput {
1485
+ owner: string;
1486
+ mint: string;
1487
+ tokenProgram?: string;
939
1488
  }
940
1489
  interface RawAccountInfo {
941
1490
  address: string;
@@ -947,16 +1496,13 @@ interface RawAccountInfo {
947
1496
  interface ChainClient {
948
1497
  exists(address: string): Promise<boolean>;
949
1498
  lamports(address: string): Promise<number>;
1499
+ nativeBalance(address: string, options?: ContextSlotOptions): Promise<NativeBalanceInfo>;
950
1500
  minimumBalanceForRentExemption(space: number): Promise<number>;
951
1501
  clock(): Promise<ChainClock>;
952
1502
  account(address: string): Promise<RawAccountInfo | null>;
953
1503
  mint(address: string): Promise<MintAccountInfo | null>;
954
1504
  tokenAccount(address: string): Promise<TokenAccountInfo | null>;
955
- balance(input: {
956
- owner: string;
957
- mint: string;
958
- tokenProgram?: string;
959
- }): Promise<TokenBalanceInfo>;
1505
+ balance(input: TokenBalanceInput, options?: ContextSlotOptions): Promise<TokenBalanceInfo>;
960
1506
  }
961
1507
  type FetchLike = typeof fetch;
962
1508
  declare function deriveHttpEndpoint(wsUrl: string): string;
@@ -1000,6 +1546,19 @@ interface PreparedOperationDescription {
1000
1546
  }[];
1001
1547
  }[];
1002
1548
  }
1549
+ interface OperationInspection {
1550
+ /** JSON-safe description produced by {@link describePreparedOperation}. */
1551
+ readonly description: PreparedOperationDescription;
1552
+ /** Raw unsigned inspection returned by the adapter. */
1553
+ readonly transaction: TransactionInspectionResult;
1554
+ /** IDL-aware program error parsed from the inspection failure, if any. */
1555
+ readonly programError: ProgramError | null;
1556
+ }
1557
+ interface OperationInspectionOptions {
1558
+ wallet?: WalletAdapter;
1559
+ inspect?: TransactionInspectionOptions;
1560
+ transactionTransport?: TransactionTransport;
1561
+ }
1003
1562
  interface PreparedTransactionBody {
1004
1563
  readonly name: string;
1005
1564
  readonly instructions: NonEmptyReadonlyArray<BuiltInstruction>;
@@ -1079,6 +1638,7 @@ interface SingleTransactionOperationReceipt<TArtifacts> {
1079
1638
  readonly artifacts: TArtifacts;
1080
1639
  readonly signatures: NonEmptyReadonlyArray<string>;
1081
1640
  readonly transaction: OperationTransactionReceipt;
1641
+ readonly callbackErrors?: readonly OperationCallbackError[];
1082
1642
  }
1083
1643
  interface FlowOperationReceipt<TArtifacts> {
1084
1644
  readonly kind: 'flow';
@@ -1086,6 +1646,7 @@ interface FlowOperationReceipt<TArtifacts> {
1086
1646
  readonly artifacts: TArtifacts;
1087
1647
  readonly signatures: NonEmptyReadonlyArray<string>;
1088
1648
  readonly transactions: NonEmptyReadonlyArray<OperationTransactionReceipt>;
1649
+ readonly callbackErrors?: readonly OperationCallbackError[];
1089
1650
  }
1090
1651
  type OperationReceiptFor<TPrepared extends PreparedOperation> = TPrepared extends PreparedFlow<infer TArtifacts> ? FlowOperationReceipt<TArtifacts> : TPrepared extends PreparedInstruction<infer TArtifacts> ? SingleTransactionOperationReceipt<TArtifacts> : TPrepared extends PreparedTransaction<infer TArtifacts> ? SingleTransactionOperationReceipt<TArtifacts> : never;
1091
1652
  interface OperationExecutionEvent<TPrepared extends PreparedOperation = PreparedOperation> {
@@ -1096,14 +1657,18 @@ interface OperationExecutionEvent<TPrepared extends PreparedOperation = Prepared
1096
1657
  interface OperationExecutionSuccessEvent<TPrepared extends PreparedOperation = PreparedOperation> extends OperationExecutionEvent<TPrepared> {
1097
1658
  readonly receipt: OperationTransactionReceipt;
1098
1659
  }
1660
+ type OperationCallbackPhase = 'transaction-start' | 'transaction-success';
1099
1661
  interface OperationExecutionOptions<TSigner = unknown, TPrepared extends PreparedOperation = PreparedOperation> {
1100
1662
  wallet?: WalletAdapter;
1663
+ transactionTransport?: TransactionTransport;
1101
1664
  send?: SendOptions;
1102
1665
  signers?: readonly TSigner[];
1103
1666
  signerRegistry?: SignerRegistry<TSigner>;
1104
1667
  availableSignerAddresses?: readonly string[];
1105
1668
  onTransactionStart?: (event: OperationExecutionEvent<TPrepared>) => void | Promise<void>;
1106
1669
  onTransactionSuccess?: (event: OperationExecutionSuccessEvent<TPrepared>) => void | Promise<void>;
1670
+ /** Receives observer failures without changing the transaction outcome. */
1671
+ onCallbackError?: (error: OperationCallbackError<TPrepared>) => void | Promise<void>;
1107
1672
  }
1108
1673
  interface OperationExecutionHost<TSigner = unknown> {
1109
1674
  readonly wallet?: WalletAdapter;
@@ -1113,28 +1678,60 @@ interface OperationExecutionHost<TSigner = unknown> {
1113
1678
  send?: SendOptions;
1114
1679
  errors?: ErrorMetadata[];
1115
1680
  signers?: readonly TSigner[];
1681
+ transactionTransport?: TransactionTransport;
1116
1682
  }): Promise<{
1117
1683
  signature: string;
1118
1684
  slot?: number;
1119
1685
  }>;
1120
1686
  }
1687
+ declare class OperationCallbackError<TPrepared extends PreparedOperation = PreparedOperation> extends Error {
1688
+ readonly phase: OperationCallbackPhase;
1689
+ readonly operation: TPrepared;
1690
+ readonly transaction: PreparedTransactionBody;
1691
+ readonly transactionIndex: number;
1692
+ readonly receipt?: OperationTransactionReceipt;
1693
+ readonly cause: unknown;
1694
+ constructor(input: {
1695
+ phase: OperationCallbackPhase;
1696
+ operation: TPrepared;
1697
+ transaction: PreparedTransactionBody;
1698
+ transactionIndex: number;
1699
+ receipt?: OperationTransactionReceipt;
1700
+ cause: unknown;
1701
+ });
1702
+ }
1121
1703
  declare class OperationExecutionError<TPrepared extends PreparedOperation = PreparedOperation> extends Error {
1122
1704
  readonly operation: TPrepared;
1123
1705
  readonly failedTransaction: PreparedTransactionBody;
1124
1706
  readonly failedTransactionIndex: number;
1125
1707
  readonly completedReceipts: readonly OperationTransactionReceipt[];
1708
+ readonly callbackErrors: readonly OperationCallbackError<TPrepared>[];
1709
+ readonly outcome: TransactionFailureOutcome;
1710
+ readonly signature?: string;
1711
+ readonly slot?: number;
1126
1712
  readonly cause: unknown;
1127
1713
  constructor(input: {
1128
1714
  operation: TPrepared;
1129
1715
  failedTransaction: PreparedTransactionBody;
1130
1716
  failedTransactionIndex: number;
1131
1717
  completedReceipts: readonly OperationTransactionReceipt[];
1718
+ callbackErrors?: readonly OperationCallbackError<TPrepared>[];
1719
+ outcome?: TransactionFailureOutcome;
1132
1720
  cause: unknown;
1133
1721
  });
1134
1722
  }
1135
1723
  declare function executePreparedOperation<TPrepared extends PreparedOperation, TSigner = unknown>(host: OperationExecutionHost<TSigner>, operation: TPrepared, options?: OperationExecutionOptions<TSigner, TPrepared>): Promise<OperationReceiptFor<TPrepared>>;
1724
+ /**
1725
+ * Recursively unwrap operation context while retaining structured transaction outcomes.
1726
+ */
1727
+ declare function unwrapOperationExecutionError(error: unknown): InstructionError | TransactionFailureOutcome | unknown;
1136
1728
  declare function toJsonValue(value: unknown): JsonValue;
1137
1729
  declare function describePreparedOperation(operation: PreparedOperation): PreparedOperationDescription;
1730
+ /**
1731
+ * Inspect one prepared instruction/transaction without signing or submission.
1732
+ * Multi-transaction flows are intentionally unsupported.
1733
+ */
1734
+ declare function inspectPreparedOperation(wallet: WalletAdapter | undefined, operation: PreparedOperation, options?: TransactionInspectionOptions, context?: WalletExecutionContext): Promise<OperationInspection>;
1138
1735
  declare function formatPreparedOperation(operation: PreparedOperation): string;
1139
1736
 
1140
1737
  interface InstructionOperation<TInput = unknown, TArtifacts = void> {
@@ -1164,6 +1761,16 @@ declare function flowOperation<TInput, TArtifacts>(prepare: (input: TInput) => M
1164
1761
  declare const STACK_RUNTIME_EXTENSIONS: "__areteStackRuntimeExtensions";
1165
1762
  declare const PROGRAM_OPERATION_EXTENSIONS: "__areteProgramOperationExtensions";
1166
1763
  type EmptyRecord = Record<string, never>;
1764
+ /** Fixed arity, or `[required, total]` when a read has optional arguments. */
1765
+ type ReadArgumentCount = number | readonly [required: number, total: number];
1766
+ type RequiredArgumentCount<TArgs extends readonly unknown[], TCount extends readonly unknown[] = []> = TArgs extends readonly [infer THead, ...infer TTail] ? undefined extends THead ? TCount['length'] : RequiredArgumentCount<TTail, readonly [...TCount, unknown]> : TCount['length'];
1767
+ type ReadArgumentCountFor<TRead> = TRead extends (...args: infer TArgs) => unknown ? number extends Required<TArgs>['length'] ? ReadArgumentCount : RequiredArgumentCount<TArgs> extends Required<TArgs>['length'] ? Required<TArgs>['length'] : readonly [
1768
+ required: RequiredArgumentCount<TArgs>,
1769
+ total: Required<TArgs>['length']
1770
+ ] : never;
1771
+ type ReadArgumentCounts<TRead = Record<string, unknown>> = {
1772
+ readonly [K in keyof TRead]: ReadArgumentCountFor<TRead[K]>;
1773
+ };
1167
1774
  type MaybeField<TKey extends string, TValue> = [TValue] extends [never] ? {} : {
1168
1775
  readonly [K in TKey]: TValue;
1169
1776
  };
@@ -1195,7 +1802,7 @@ interface ProgramRuntimeExtensionCarrier<TOperations extends AnyProgramOperation
1195
1802
  }
1196
1803
  type ProgramOperationsOf<TProgram> = TProgram extends ProgramRuntimeExtensionCarrier<infer TOperations> ? TOperations : ProgramOperations;
1197
1804
  type MergeProgramOperations<TBase extends AnyProgramOperations, TExtension extends AnyProgramOperations> = ProgramOperations<Extract<MergeField<InstructionOperationsOf<TBase>, InstructionOperationsOf<TExtension>>, InstructionOperationNamespace | EmptyRecord>, Extract<MergeField<TransactionOperationsOf<TBase>, TransactionOperationsOf<TExtension>>, TransactionOperationNamespace | EmptyRecord>, Extract<MergeField<FlowOperationsOf<TBase>, FlowOperationsOf<TExtension>>, FlowOperationNamespace | EmptyRecord>>;
1198
- type ExtendedProgramDefinition<TBase extends ProgramSdkDefinition, TAddresses = never, TConstants = never, TDefaults = never, TOperations extends AnyProgramOperations = ProgramOperations, TMath = never> = TBase & MaybeField<'addresses', TAddresses> & MaybeField<'constants', TConstants> & MaybeField<'defaults', TDefaults> & MaybeField<'math', TMath> & ProgramRuntimeExtensionCarrier<MergeProgramOperations<ProgramOperationsOf<TBase>, TOperations>>;
1805
+ type ExtendedProgramDefinition<TBase extends ProgramSdkDefinition, TAddresses = never, TConstants = never, TDefaults = never, TOperations extends AnyProgramOperations = ProgramOperations, TMath = never> = Omit<TBase, 'sdkDefinitionHash'> & MaybeField<'addresses', TAddresses> & MaybeField<'constants', TConstants> & MaybeField<'defaults', TDefaults> & MaybeField<'math', TMath> & ProgramRuntimeExtensionCarrier<MergeProgramOperations<ProgramOperationsOf<TBase>, TOperations>>;
1199
1806
  interface ProgramExtensionInput<TAddresses = never, TConstants = never, TDefaults = never, TOperations extends AnyProgramOperations = ProgramOperations, TProgram extends ProgramSdkDefinition = ProgramSdkDefinition, TMath = never> {
1200
1807
  readonly pdas?: Record<string, unknown>;
1201
1808
  readonly accounts?: Record<string, unknown>;
@@ -1222,6 +1829,7 @@ declare function extendPrograms<TPrograms extends Record<string, ProgramSdkDefin
1222
1829
  };
1223
1830
  declare function getProgramRuntimeExtensions<TProgram extends ProgramSdkDefinition>(program: TProgram): ProgramRuntimeExtensions<ProgramOperationsOf<TProgram>, TProgram> | undefined;
1224
1831
  interface StackRuntimeExtensions<TRead = EmptyRecord, TFlows extends FlowOperationNamespace | EmptyRecord = EmptyRecord, TClient = unknown> {
1832
+ readonly readArgCounts?: ReadArgumentCounts<TRead>;
1225
1833
  readonly createRead?: (client: TClient) => TRead;
1226
1834
  readonly createFlows?: (client: TClient) => TFlows;
1227
1835
  }
@@ -1238,16 +1846,22 @@ interface StackExtensionInput<TAddresses = never, TConstants = never, TDefaults
1238
1846
  readonly constants?: TConstants;
1239
1847
  readonly defaults?: TDefaults;
1240
1848
  readonly math?: TMath;
1849
+ readonly readArgCounts?: ReadArgumentCounts<TRead>;
1241
1850
  readonly createRead?: (client: TClient) => TRead;
1242
1851
  readonly createFlows?: (client: TClient) => TFlows;
1243
1852
  }
1853
+ type ReadArgumentCountRequirement<TExtension> = TExtension extends {
1854
+ readonly createRead: (...args: any[]) => infer TRead;
1855
+ } ? {
1856
+ readonly readArgCounts: ReadArgumentCounts<TRead>;
1857
+ } : {};
1244
1858
  type StackExtensionClient<TBase extends StackDefinition, TAddresses = never, TConstants = never, TDefaults = never, TMath = never> = Arete$1<TBase> & MaybeField<'addresses', TAddresses> & MaybeField<'constants', TConstants> & MaybeField<'defaults', TDefaults> & MaybeField<'math', TMath>;
1245
- declare function defineStackExtensions<TBase extends StackDefinition>(): <TExtension extends StackExtensionInput<any, any, any, any, any, FlowOperationNamespace | EmptyRecord, any>>(extensions: TExtension & {
1859
+ declare function defineStackExtensions<TBase extends StackDefinition>(): <const TExtension extends StackExtensionInput<any, any, any, any, any, FlowOperationNamespace | EmptyRecord, any>>(extensions: TExtension & ReadArgumentCountRequirement<TExtension> & {
1246
1860
  readonly createRead?: (client: StackExtensionClient<TBase, any, any, any, any>) => unknown;
1247
1861
  readonly createFlows?: (client: StackExtensionClient<TBase, any, any, any, any>) => FlowOperationNamespace | EmptyRecord;
1248
1862
  }) => TExtension;
1249
- declare function extendStack<TBase extends StackDefinition, TExtension extends StackExtensionInput<any, any, any, any, any, any, any>>(stack: TBase, extensions: TExtension): ExtendedStackDefinition<TBase, MergeField<Field<TBase, 'addresses'>, Field<TExtension, 'addresses'>>, MergeField<Field<TBase, 'constants'>, Field<TExtension, 'constants'>>, MergeField<Field<TBase, 'defaults'>, Field<TExtension, 'defaults'>>, MergeField<Field<TBase, 'math'>, Field<TExtension, 'math'>>, MergeField<StackReadOf<TBase>, FactoryReturn<TExtension, 'createRead'>>, Extract<MergeField<StackFlowsOf<TBase>, FactoryReturn<TExtension, 'createFlows'>>, FlowOperationNamespace | EmptyRecord>>;
1250
- declare function getStackRuntimeExtensions<TStack extends StackDefinition>(stack: TStack): StackRuntimeExtensions | undefined;
1863
+ declare function extendStack<TBase extends StackDefinition, TExtension extends StackExtensionInput<any, any, any, any, any, any, any>>(stack: TBase, extensions: TExtension & ReadArgumentCountRequirement<TExtension>): ExtendedStackDefinition<TBase, MergeField<Field<TBase, 'addresses'>, Field<TExtension, 'addresses'>>, MergeField<Field<TBase, 'constants'>, Field<TExtension, 'constants'>>, MergeField<Field<TBase, 'defaults'>, Field<TExtension, 'defaults'>>, MergeField<Field<TBase, 'math'>, Field<TExtension, 'math'>>, MergeField<StackReadOf<TBase>, FactoryReturn<TExtension, 'createRead'>>, Extract<MergeField<StackFlowsOf<TBase>, FactoryReturn<TExtension, 'createFlows'>>, FlowOperationNamespace | EmptyRecord>>;
1864
+ declare function getStackRuntimeExtensions<TStack extends StackDefinition>(stack: TStack): StackRuntimeExtensions<StackReadOf<TStack>> | undefined;
1251
1865
  declare function applyConnectedStackExtensions<TClient extends object, TStack extends StackDefinition>(client: TClient, stack: TStack): ConnectedStackClient<TClient, TStack>;
1252
1866
 
1253
1867
  type ProgramMap = Record<string, ProgramSdkDefinition>;
@@ -1256,8 +1870,9 @@ type MergeProgramMaps<TStackPrograms, TAttachedPrograms> = Omit<NormalizeProgram
1256
1870
  type StackWithAttachedPrograms<TStack extends StackDefinition, TAttachedPrograms extends ProgramMap | undefined> = Omit<TStack, 'programs'> & {
1257
1871
  programs: MergeProgramMaps<TStack['programs'], TAttachedPrograms>;
1258
1872
  };
1873
+ declare function validateProgramReadDescriptor(programName: string, descriptor: ProgramReadDescriptor): void;
1259
1874
  declare function withPrograms<TStack extends StackDefinition, TAttachedPrograms extends ProgramMap | undefined>(stack: TStack, attachedPrograms: TAttachedPrograms): StackWithAttachedPrograms<TStack, TAttachedPrograms>;
1260
- interface ConnectOptions<TPrograms extends ProgramMap | undefined = undefined> {
1875
+ interface ConnectOptions<TPrograms extends ProgramMap | undefined = undefined, TStackPrograms extends ProgramMap | undefined = ProgramMap> {
1261
1876
  url?: string;
1262
1877
  httpUrl?: string;
1263
1878
  /**
@@ -1268,11 +1883,21 @@ interface ConnectOptions<TPrograms extends ProgramMap | undefined = undefined> {
1268
1883
  transport?: 'ws' | 'http';
1269
1884
  storage?: StorageAdapter;
1270
1885
  maxEntriesPerView?: number | null;
1886
+ /** Connect immediately when the client is created (defaults to true). */
1887
+ autoConnect?: boolean;
1888
+ /** Reconnect automatically after an established connection is lost (defaults to true). */
1271
1889
  autoReconnect?: boolean;
1272
1890
  reconnectIntervals?: number[];
1273
1891
  maxReconnectAttempts?: number;
1274
1892
  flushIntervalMs?: number;
1893
+ /**
1894
+ * Generated schemas are always applied to normalize typed entities. Set this
1895
+ * to `false` to suppress console warnings for rejected frames while keeping
1896
+ * schema normalization and `onFrameValidationError` active.
1897
+ */
1275
1898
  validateFrames?: boolean;
1899
+ /** Observe generated-schema rejections without scraping console warnings. */
1900
+ onFrameValidationError?: (diagnostic: FrameValidationDiagnostic) => void;
1276
1901
  /** Authentication configuration */
1277
1902
  auth?: AuthConfig;
1278
1903
  /** Default wallet adapter used for instruction execution (overridable per call). */
@@ -1281,6 +1906,12 @@ interface ConnectOptions<TPrograms extends ProgramMap | undefined = undefined> {
1281
1906
  fetch?: typeof fetch;
1282
1907
  /** Additional program SDKs exposed under client.programs.<key>. */
1283
1908
  programs?: TPrograms;
1909
+ /** Per-program complete descriptor replacements. */
1910
+ programReads?: ProgramReadOverrides<MergeProgramMaps<TStackPrograms, TPrograms>>;
1911
+ /** Explicit chain transport, used by composition sessions. */
1912
+ chain?: ChainClient;
1913
+ /** Explicit transaction transport, used by composition sessions. */
1914
+ transactions?: TransactionTransport;
1284
1915
  /** Default semantic-operation execution settings. */
1285
1916
  execution?: OperationExecutionOptions<any>;
1286
1917
  }
@@ -1294,9 +1925,13 @@ interface AreteOptionsWithStorage<TStack extends StackDefinition> extends AreteO
1294
1925
  wallet?: WalletAdapter;
1295
1926
  fetch?: typeof fetch;
1296
1927
  execution?: OperationExecutionOptions<any>;
1928
+ chain?: ChainClient;
1929
+ transactions?: TransactionTransport;
1930
+ onFrameValidationError?: (diagnostic: FrameValidationDiagnostic) => void;
1297
1931
  }
1298
1932
  interface TransactionOptions<TSigner = unknown> {
1299
1933
  wallet?: WalletAdapter;
1934
+ transactionTransport?: TransactionTransport;
1300
1935
  send?: SendOptions;
1301
1936
  errors?: ErrorMetadata[];
1302
1937
  signers?: readonly TSigner[];
@@ -1315,7 +1950,7 @@ interface TypedInstruction<TParams, TError> {
1315
1950
  }
1316
1951
  interface TypedAccountReader<T> {
1317
1952
  fetch(address: string): Promise<T | null>;
1318
- fetchMany(addresses: readonly string[]): Promise<Array<T | null>>;
1953
+ fetchMany(addresses: readonly string[]): Promise<ProgramAccountBatchResult<T>>;
1319
1954
  exists(address: string): Promise<boolean>;
1320
1955
  }
1321
1956
  type TypedQueryExecutor<TParams, TResult> = (params: TParams) => Promise<TResult>;
@@ -1365,13 +2000,18 @@ declare class Arete$1<TStack extends StackDefinition> {
1365
2000
  private readonly storage;
1366
2001
  private readonly processor;
1367
2002
  private readonly subscriptionRegistry;
2003
+ private readonly queryStore;
1368
2004
  private readonly _views;
1369
2005
  private readonly _queries;
1370
2006
  private readonly _programs;
1371
2007
  private readonly _chain;
2008
+ private readonly _transactions;
1372
2009
  private readonly stack;
1373
2010
  private readonly httpBaseUrl;
2011
+ private readonly connectHttpUrl;
2012
+ private readonly programReadOverrides;
1374
2013
  private readonly fetchImpl;
2014
+ private readonly auth;
1375
2015
  private readonly executionDefaults?;
1376
2016
  private _wallet?;
1377
2017
  private _aggregatedErrors?;
@@ -1380,18 +2020,21 @@ declare class Arete$1<TStack extends StackDefinition> {
1380
2020
  private buildQueries;
1381
2021
  private buildPrograms;
1382
2022
  private createTypedInstruction;
2023
+ private createProgramTransport;
1383
2024
  private createAccountReader;
1384
2025
  private createQueryExecutor;
1385
2026
  private readJson;
1386
2027
  private authenticatedFetch;
2028
+ private authenticatedStackFetch;
1387
2029
  private resolveReadUrl;
1388
2030
  /** Merge the client's default wallet into call options (call options win). */
1389
2031
  private withWallet;
1390
- static connect<T extends StackDefinition, TPrograms extends ProgramMap | undefined = undefined>(stack: T, options?: ConnectOptions<TPrograms>): Promise<ConnectedArete<StackWithAttachedPrograms<T, TPrograms>, T>>;
2032
+ static connect<T extends StackDefinition, TPrograms extends ProgramMap | undefined = undefined>(stack: T, options?: ConnectOptions<TPrograms, T['programs']>): Promise<ConnectedArete<StackWithAttachedPrograms<T, TPrograms>, T>>;
1391
2033
  get views(): TypedViews<TStack['views']>;
1392
2034
  get queries(): QueriesInterface<TStack['queries']>;
1393
2035
  get programs(): ProgramsInterface<TStack['programs']>;
1394
2036
  get chain(): ChainClient;
2037
+ get transactions(): TransactionTransport;
1395
2038
  /** The default wallet adapter, if one was configured. */
1396
2039
  get wallet(): WalletAdapter | undefined;
1397
2040
  /** The connected wallet address, if a default wallet was configured. */
@@ -1415,11 +2058,20 @@ declare class Arete$1<TStack extends StackDefinition> {
1415
2058
  */
1416
2059
  transaction(instructions: readonly BuiltInstruction[], options?: TransactionOptions): Promise<ExecutionResult>;
1417
2060
  execute<TPrepared extends PreparedOperation, TSigner = unknown>(prepared: TPrepared, options?: OperationExecutionOptions<TSigner, TPrepared>): Promise<OperationReceiptFor<TPrepared>>;
2061
+ /** Inspect one prepared instruction/transaction without signing or submitting it. */
2062
+ inspectOperation(prepared: PreparedOperation, options?: OperationInspectionOptions): Promise<OperationInspection>;
1418
2063
  /** Error metadata from every handler in the stack, deduped by code. */
1419
2064
  private aggregateErrors;
1420
2065
  get connectionState(): ConnectionState;
1421
2066
  get stackName(): string;
1422
2067
  get store(): StorageAdapter;
2068
+ /** Highest Solana slot whose streamed frame has been stored locally. */
2069
+ get processedSlot(): bigint | null;
2070
+ /**
2071
+ * Wait until a frame at or beyond `slot` has been applied to local storage.
2072
+ * Buffered frames satisfy the wait only after their storage batch is flushed.
2073
+ */
2074
+ waitForProcessedSlot(slot: number | bigint, options?: WaitForProcessedSlotOptions): Promise<bigint>;
1423
2075
  onConnectionStateChange(callback: ConnectionStateCallback): UnsubscribeFn;
1424
2076
  onFrame(callback: (frame: Frame) => void): UnsubscribeFn;
1425
2077
  onSocketIssue(callback: SocketIssueCallback): UnsubscribeFn;
@@ -1430,6 +2082,7 @@ declare class Arete$1<TStack extends StackDefinition> {
1430
2082
  getStore(): StorageAdapter;
1431
2083
  getConnection(): ConnectionManager;
1432
2084
  getSubscriptionRegistry(): SubscriptionRegistry;
2085
+ getQueryStore(): QueryStore;
1433
2086
  }
1434
2087
 
1435
2088
  /**
@@ -1440,9 +2093,12 @@ declare class Arete$1<TStack extends StackDefinition> {
1440
2093
  * composition of programs + views, and a standalone program member reuses the
1441
2094
  * exact same machinery as a stack with no views, connected HTTP-only.
1442
2095
  */
1443
- interface SessionDefinition {
2096
+ interface SessionDefinition<TPrograms extends Record<string, ProgramSdkDefinition> = Record<string, ProgramSdkDefinition>> {
2097
+ readonly mode?: 'composition';
1444
2098
  readonly stacks?: Record<string, StackDefinition>;
1445
- readonly programs?: Record<string, ProgramSdkDefinition>;
2099
+ readonly programs?: TPrograms;
2100
+ /** Generated descriptors keyed in parallel with standalone `programs`. */
2101
+ readonly programReads?: ProgramReadDescriptors<TPrograms>;
1446
2102
  }
1447
2103
  type SessionStackPrograms<TDef extends SessionDefinition> = Partial<{
1448
2104
  [K in keyof NonNullable<TDef['stacks']>]: Record<string, ProgramSdkDefinition> | undefined;
@@ -1458,14 +2114,21 @@ interface SessionMemberOptions<TPrograms extends Record<string, ProgramSdkDefini
1458
2114
  transport?: 'ws' | 'http';
1459
2115
  auth?: AuthConfig;
1460
2116
  storage?: StorageAdapter;
2117
+ autoConnect?: boolean;
1461
2118
  autoReconnect?: boolean;
1462
2119
  programs?: TPrograms;
2120
+ /** Override applied to every program owned by this member. */
2121
+ programRead?: ProgramReadOverride;
2122
+ /** Per-program overrides for this member. */
2123
+ programReads?: Readonly<Record<string, ProgramReadOverride>>;
1463
2124
  }
1464
2125
  interface SessionOptions<TDef extends SessionDefinition = SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> {
1465
2126
  /** One wallet governs execution across every member. */
1466
2127
  wallet?: WalletAdapter;
1467
2128
  /** Canonical chain reader shared by the session when explicitly provided. */
1468
2129
  chain?: ChainClient;
2130
+ /** Transaction transport override; defaults to the execution host's authenticated client. */
2131
+ transactions?: TransactionTransport;
1469
2132
  auth?: AuthConfig;
1470
2133
  fetch?: typeof fetch;
1471
2134
  /** Default transport for all members ('ws' unless overridden). */
@@ -1484,7 +2147,18 @@ interface SessionOptions<TDef extends SessionDefinition = SessionDefinition, TSt
1484
2147
  [K in keyof NonNullable<TDef['stacks']>]?: SessionMemberOptions<K extends keyof TStackPrograms ? TStackPrograms[K] : undefined>;
1485
2148
  };
1486
2149
  programs?: Record<string, SessionMemberOptions>;
1487
- }
2150
+ /** Override applied to every program in the session. */
2151
+ programRead?: ProgramReadOverride;
2152
+ /** Session-wide per-program overrides, keyed by program key. */
2153
+ programReads?: Readonly<Record<string, ProgramReadOverride>>;
2154
+ }
2155
+ type CompositionSessionOptions<TDef extends SessionDefinition = SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> = Omit<SessionOptions<TDef, TStackPrograms>, 'chain' | 'transactions' | 'endpoints'> & {
2156
+ /** Chain reads never inherit a live member's HTTP endpoint. */
2157
+ chain: ChainClient;
2158
+ /** Transactions never inherit a live member's HTTP endpoint. */
2159
+ transactions: TransactionTransport;
2160
+ endpoints?: never;
2161
+ };
1488
2162
  type SessionStacks<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> = {
1489
2163
  readonly [K in keyof NonNullable<TDef['stacks']>]: NonNullable<TDef['stacks']>[K] extends StackDefinition ? K extends keyof TStackPrograms ? ConnectedArete<StackWithAttachedPrograms<NonNullable<TDef['stacks']>[K], TStackPrograms[K]>, NonNullable<TDef['stacks']>[K]> : ConnectedArete<NonNullable<TDef['stacks']>[K], NonNullable<TDef['stacks']>[K]> : never;
1490
2164
  };
@@ -1497,19 +2171,38 @@ type PromotedSessionPrograms<TDef extends SessionDefinition, TStackPrograms exte
1497
2171
  type ExplicitSessionPrograms<TDef extends SessionDefinition> = {
1498
2172
  readonly [K in keyof NonNullable<TDef['programs']>]: NonNullable<TDef['programs']>[K] extends ProgramSdkDefinition ? ProgramInterface<NonNullable<TDef['programs']>[K]> : never;
1499
2173
  };
1500
- type SessionPrograms<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> = Omit<PromotedSessionPrograms<TDef, TStackPrograms>, keyof NonNullable<TDef['programs']>> & ExplicitSessionPrograms<TDef>;
2174
+ type SessionPrograms<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> = TDef extends {
2175
+ readonly mode: 'composition';
2176
+ } ? ExplicitSessionPrograms<TDef> : Omit<PromotedSessionPrograms<TDef, TStackPrograms>, keyof NonNullable<TDef['programs']>> & ExplicitSessionPrograms<TDef>;
1501
2177
  interface Session<TDef extends SessionDefinition = SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> {
1502
2178
  readonly stacks: SessionStacks<TDef, TStackPrograms>;
1503
2179
  readonly programs: SessionPrograms<TDef, TStackPrograms>;
1504
2180
  readonly wallet: WalletAdapter | undefined;
1505
2181
  readonly signerRegistry: SignerRegistry<any>;
1506
2182
  readonly chain: ChainClient;
2183
+ readonly transactions: TransactionTransport;
1507
2184
  transaction(instructions: readonly BuiltInstruction[], options?: TransactionOptions): Promise<ExecutionResult>;
1508
2185
  execute<TPrepared extends PreparedOperation, TSigner = unknown>(prepared: TPrepared, options?: OperationExecutionOptions<TSigner, TPrepared>): Promise<OperationReceiptFor<TPrepared>>;
1509
2186
  setWallet(wallet: WalletAdapter | undefined): void;
1510
2187
  close(): void;
1511
2188
  }
1512
- declare function createSession<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}>(definition: TDef, options?: SessionOptions<TDef, TStackPrograms>): Promise<Session<TDef, TStackPrograms>>;
2189
+ declare function createSession<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}>(definition: TDef, ...args: TDef extends {
2190
+ readonly mode: 'composition';
2191
+ } ? [options: CompositionSessionOptions<TDef, TStackPrograms>] : [options?: SessionOptions<TDef, TStackPrograms>]): Promise<Session<TDef, TStackPrograms>>;
2192
+
2193
+ interface HostedSolanaGatewayTransportOptions {
2194
+ readonly auth?: AuthConfig;
2195
+ readonly fetch?: typeof fetch;
2196
+ }
2197
+ interface HostedSolanaGatewayTransports {
2198
+ readonly chain: ChainClient;
2199
+ readonly transactions: TransactionTransport;
2200
+ }
2201
+ /**
2202
+ * Construct explicit hosted chain and transaction transports from generated
2203
+ * gateway descriptors. Tokens are isolated by exact binding target and scope.
2204
+ */
2205
+ declare function createHostedSolanaGatewayTransports(bindings: HostedSolanaGatewayBindings, options?: HostedSolanaGatewayTransportOptions): HostedSolanaGatewayTransports;
1513
2206
 
1514
2207
  interface AccountLoader {
1515
2208
  getAccount(address: string): Promise<{
@@ -1549,6 +2242,8 @@ declare function parseUiAmountToRaw(value: string | number, decimals: number): b
1549
2242
  declare function formatRawToUi(raw: bigint | string | number, decimals: number): string;
1550
2243
  /** Resolve an {@link AmountInput} to raw base units with known decimals. */
1551
2244
  declare function toRawAmount(amount: AmountInput, decimals: number): bigint;
2245
+ /** Convert an amount to raw units without throwing on invalid user input. */
2246
+ declare function safeToRawAmount(amount: AmountInput, decimals: number): SchemaResult<bigint>;
1552
2247
  /** Fetch a mint's decimals via the chain read endpoint, throwing when unavailable. */
1553
2248
  declare function getMintDecimals(chain: ChainClient, mint: string): Promise<number>;
1554
2249
  /**
@@ -1570,6 +2265,24 @@ declare function resolveAmountsToRaw<TInputs extends Record<string, AmountResolu
1570
2265
  [K in keyof TInputs]: bigint;
1571
2266
  }>;
1572
2267
 
2268
+ /**
2269
+ * Recursively convert bigints to their decimal string form.
2270
+ *
2271
+ * Streamed entities contain bigints, which makes them unsafe to pass through
2272
+ * anything that JSON-stringifies (React's dev-mode performance tooling, log
2273
+ * pipelines, `JSON.stringify` persistence). Prefer stack-provided UI fields
2274
+ * (e.g. `deployedPerSquareUi`) when they exist; use this for the remaining
2275
+ * raw values such as account snapshots.
2276
+ *
2277
+ * Arrays and plain objects are converted structurally and the return type
2278
+ * maps every `bigint` to `string`; class instances (PublicKey, Date, …) are
2279
+ * returned untouched.
2280
+ */
2281
+ type StringifiedBigints<T> = T extends bigint ? string : T extends readonly (infer U)[] ? readonly StringifiedBigints<U>[] : T extends object ? {
2282
+ [K in keyof T]: StringifiedBigints<T[K]>;
2283
+ } : T;
2284
+ declare function stringifyBigints<T>(value: T): StringifiedBigints<T>;
2285
+
1573
2286
  declare class ReadRequestError extends Error {
1574
2287
  readonly status: number;
1575
2288
  readonly path: string;
@@ -1584,7 +2297,6 @@ declare class ReadRequestError extends Error {
1584
2297
  }
1585
2298
  declare function programAccountRead<T>(input: {
1586
2299
  account: string;
1587
- path: string;
1588
2300
  schema?: Schema<T>;
1589
2301
  }): ProgramAccountReadDefinition<T>;
1590
2302
  declare function programQuery<TParams = unknown, TResult = unknown>(input: {
@@ -1600,61 +2312,21 @@ declare function stackQuery<TParams = unknown, TResult = unknown>(input: {
1600
2312
  schema?: Schema<TResult>;
1601
2313
  }): StackQueryDefinition<TParams, TResult>;
1602
2314
 
1603
- interface FrameProcessorConfig {
1604
- maxEntriesPerView?: number | null;
1605
- /**
1606
- * Interval in milliseconds to buffer frames before flushing to storage.
1607
- * Set to 0 for immediate processing (no buffering).
1608
- * Default: 0 (immediate)
1609
- *
1610
- * For React applications, 16ms (one frame at 60fps) is recommended to
1611
- * reduce unnecessary re-renders during high-frequency updates.
1612
- */
1613
- flushIntervalMs?: number;
1614
- schemas?: Record<string, Schema<unknown>>;
1615
- patchSchemas?: Record<string, Schema<unknown>>;
1616
- }
1617
- declare class FrameProcessor {
1618
- private storage;
1619
- private maxEntriesPerView;
1620
- private flushIntervalMs;
1621
- private schemas?;
1622
- private patchSchemas?;
1623
- private pendingUpdates;
1624
- private flushTimer;
1625
- private isProcessing;
1626
- constructor(storage: StorageAdapter, config?: FrameProcessorConfig);
1627
- private getSchema;
1628
- private normalizeEntity;
1629
- private hasSchema;
1630
- private normalizePathSegment;
1631
- private normalizePath;
1632
- private normalizeSortConfig;
1633
- private normalizeAppendPaths;
1634
- private extractSeq;
1635
- private getInternalSeq;
1636
- private attachInternalSeq;
1637
- handleFrame<T>(frame: Frame<T>): void;
1638
- /**
1639
- * Immediately flush all pending updates.
1640
- * Useful for ensuring all updates are processed before reading state.
1641
- */
1642
- flush(): void;
1643
- /**
1644
- * Clean up any pending timers. Call when disposing the processor.
1645
- */
1646
- dispose(): void;
1647
- private scheduleFlush;
1648
- private flushPendingUpdates;
1649
- private processFrame;
1650
- private processFrameWithoutEnforce;
1651
- private handleSubscribedFrame;
1652
- private handleSnapshotFrame;
1653
- private handleSnapshotFrameWithoutEnforce;
1654
- private handleEntityFrame;
1655
- private handleEntityFrameWithoutEnforce;
1656
- private emitRichUpdate;
1657
- private enforceMaxEntries;
2315
+ type ProgramReadRequest = {
2316
+ readonly operation: 'fetch';
2317
+ readonly account: string;
2318
+ readonly address: string;
2319
+ } | {
2320
+ readonly operation: 'fetchMany';
2321
+ readonly account: string;
2322
+ readonly addresses: readonly string[];
2323
+ } | {
2324
+ readonly operation: 'exists';
2325
+ readonly account: string;
2326
+ readonly address: string;
2327
+ };
2328
+ interface ProgramReadTransport {
2329
+ read<T>(request: ProgramReadRequest): Promise<T>;
1658
2330
  }
1659
2331
 
1660
2332
  declare class MemoryAdapter implements StorageAdapter {
@@ -1679,11 +2351,12 @@ declare class MemoryAdapter implements StorageAdapter {
1679
2351
  notifyRichUpdate<T>(viewPath: string, key: string, update: RichUpdate<T>): void;
1680
2352
  }
1681
2353
 
1682
- declare function createUpdateStream<T>(storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, subscription: Subscription, keyFilter?: string): AsyncIterable<Update<T>>;
1683
- declare function createEntityStream<T>(storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, subscription: Subscription, options?: WatchOptions<any>, keyFilter?: string): AsyncIterable<T>;
1684
- declare function createRichUpdateStream<T>(storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, subscription: Subscription, keyFilter?: string): AsyncIterable<RichUpdate<T>>;
2354
+ declare function createUpdateStream<T>(_storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, query: SubscriptionQuery, keyFilter?: string, snapshotEnabled?: boolean): AsyncIterable<Update<T>>;
2355
+ declare function createEntityStream<T>(_storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, query: SubscriptionQuery, options?: WatchOptions<any>, keyFilter?: string): AsyncIterable<T>;
2356
+ declare function createRichUpdateStream<T>(_storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, query: SubscriptionQuery, keyFilter?: string, snapshotEnabled?: boolean): AsyncIterable<RichUpdate<T>>;
1685
2357
 
1686
- declare function createTypedStateView<T>(viewDef: ViewDef<T, 'state'>, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedStateView<T>;
2358
+ declare function serializeViewKey<TKey>(viewDef: ViewDef<unknown, 'state', TKey>, key: TKey): string;
2359
+ declare function createTypedStateView<T, TKey = unknown>(viewDef: ViewDef<T, 'state', TKey>, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedStateView<T, DefaultViewKey<TKey>>;
1687
2360
  declare function createTypedListView<T>(viewDef: ViewDef<T, 'list'>, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedListView<T>;
1688
2361
  declare function createTypedViews<TStack extends StackDefinition>(stack: TStack, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedViews<TStack['views']>;
1689
2362
 
@@ -1691,5 +2364,5 @@ declare const Arete: typeof Arete$1 & {
1691
2364
  session: typeof createSession;
1692
2365
  };
1693
2366
 
1694
- export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, chainAccountLoader, createChainClient, createEntityStream, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getProgramRuntimeExtensions, getStackRuntimeExtensions, instructionOperation, isEntityFrame, isSnapshotFrame, isSubscribedFrame, isValidFrame, literal, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, serializeInstructionData, stackQuery, toJsonValue, toRawAmount, transactionOperation, validateAccountResolution, withPrograms };
1695
- export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenResult, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ConfirmationLevel, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, EntityFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, MergeProgramMaps, MintAccountInfo, NonEmptyReadonlyArray, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationKind, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramsInterface, QueriesInterface, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadTransportMethod, ResolvedAccount, ResolvedAccounts, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, SubscribeCallback, SubscribedFrame, Subscription, TokenAccountInfo, TokenBalanceInfo, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, Update, UpdateCallback, ViewDef, ViewGroup, ViewSortConfig, WalletAdapter, WalletConnectOptions, WalletState, WatchOptions, WebSocketFactoryInit };
2367
+ export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OperationCallbackError, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TransactionExecutionError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isSnapshotFrame, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, safeToRawAmount, serializeInstructionData, serializeViewKey, stackQuery, stringifyBigints, toJsonValue, toRawAmount, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withPrograms };
2368
+ export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenRequest, AuthTokenResult, AuthTokenTarget, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ChainFailedTransactionOutcome, CompositionSessionOptions, ConfirmationLevel, ConfirmedTransactionOutcome, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, ContextSlotOptions, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, DefaultViewKey, EntityFrame, ErrorFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, FrameValidationDiagnostic, HostedSolanaGatewayBindings, HostedSolanaGatewayCapabilityBinding, HostedSolanaGatewayTransportOptions, HostedSolanaGatewayTransports, HttpAuthMetadata, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, LatestBlockhashResult, MergeProgramMaps, MintAccountInfo, NativeBalanceInfo, NonEmptyReadonlyArray, NotSubmittedTransactionOutcome, OperationCallbackPhase, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationInspection, OperationInspectionOptions, OperationKind, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountBatchItem, ProgramAccountBatchResult, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramReadBinding, ProgramReadBindingAuthTarget, ProgramReadDescriptor, ProgramReadDescriptors, ProgramReadOverride, ProgramReadOverrides, ProgramReadRequest, ProgramReadTransport, ProgramReleaseReference, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramsInterface, QueriesInterface, QueryLease, QuerySnapshot, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadArgumentCount, ReadArgumentCounts, ReadTransportMethod, ResolvedAccount, ResolvedAccounts, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SolanaGatewayAuthMetadata, SolanaGatewayAuthScope, SolanaGatewayBindingAuthTarget, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, StringifiedBigints, SubmittedUnknownTransactionOutcome, SubscribeCallback, SubscribedFrame, Subscription, SubscriptionIdentity, SubscriptionOptions, SubscriptionQuery, SubscriptionRequest, SubscriptionSnapshotOptions, TokenAccountInfo, TokenBalanceInfo, TokenBalanceInput, TransactionCommitment, TransactionFailureOutcome, TransactionFailurePhase, TransactionFailureStatus, TransactionFeeResult, TransactionInspectionOptions, TransactionInspectionResult, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TransactionOutcome, TransactionRequestContext, TransactionSendOptions, TransactionSendResult, TransactionSignatureStatus, TransactionSimulationOptions, TransactionSimulationResult, TransactionTransport, TransactionTransportErrorBody, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, UnsubscribedFrame, Update, UpdateCallback, ViewDef, ViewGroup, ViewKeyFields, ViewKeyValue, ViewSortConfig, WaitForProcessedSlotOptions, WalletAdapter, WalletConnectOptions, WalletExecutionContext, WalletState, WatchOptions, WebSocketFactoryInit };