rivetkit 0.0.0-sqlite-query-metrics-v2.f5d3605 → 0.0.0-sqlite-sync-3-0-1-release.95f6e2d

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 (139) hide show
  1. package/dist/browser/client.d.ts +99 -59
  2. package/dist/browser/client.js +228 -34
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -2
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-3URZ4UV5.js → chunk-2HWY7FZU.js} +2 -2
  7. package/dist/tsup/{chunk-PJ5EXY6F.js → chunk-62WFU3BQ.js} +223 -42
  8. package/dist/tsup/chunk-62WFU3BQ.js.map +1 -0
  9. package/dist/tsup/{chunk-JI6GZ2C2.js → chunk-A2CF6PFH.js} +18 -1
  10. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  11. package/dist/tsup/{chunk-KDT56V3Y.cjs → chunk-AQWZWR2P.cjs} +10 -11
  12. package/dist/tsup/chunk-AQWZWR2P.cjs.map +1 -0
  13. package/dist/tsup/{chunk-L3Z3W44Q.cjs → chunk-E4KDQJCR.cjs} +3 -3
  14. package/dist/tsup/{chunk-L3Z3W44Q.cjs.map → chunk-E4KDQJCR.cjs.map} +1 -1
  15. package/dist/tsup/{chunk-DHL2M2E2.cjs → chunk-E6HKVCPA.cjs} +3 -3
  16. package/dist/tsup/{chunk-DHL2M2E2.cjs.map → chunk-E6HKVCPA.cjs.map} +1 -1
  17. package/dist/tsup/{chunk-DDS7OOVF.cjs → chunk-EQBUH25O.cjs} +362 -181
  18. package/dist/tsup/chunk-EQBUH25O.cjs.map +1 -0
  19. package/dist/tsup/{chunk-USKGKQZM.js → chunk-HQHTTJW5.js} +10 -11
  20. package/dist/tsup/chunk-HQHTTJW5.js.map +1 -0
  21. package/dist/tsup/{chunk-JW2WPE6Z.cjs → chunk-M5SQGPRJ.cjs} +4 -4
  22. package/dist/tsup/{chunk-JW2WPE6Z.cjs.map → chunk-M5SQGPRJ.cjs.map} +1 -1
  23. package/dist/tsup/{chunk-FYDB45YU.cjs → chunk-MYWNJP55.cjs} +10 -10
  24. package/dist/tsup/{chunk-FYDB45YU.cjs.map → chunk-MYWNJP55.cjs.map} +1 -1
  25. package/dist/tsup/{chunk-F7IGTKGM.js → chunk-OWZ76NSH.js} +2 -2
  26. package/dist/tsup/{chunk-KSP3NXGY.js → chunk-QE5MTZHB.js} +3 -3
  27. package/dist/tsup/{chunk-D4G35VTO.js → chunk-QFZY2CK3.js} +4 -4
  28. package/dist/tsup/{chunk-E2CUROR3.js → chunk-QIIIRYN7.js} +2 -2
  29. package/dist/tsup/{chunk-MYWZCDML.cjs → chunk-RTWH3AX3.cjs} +19 -2
  30. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  31. package/dist/tsup/{chunk-HO76AEDH.cjs → chunk-UHMB5FFB.cjs} +3 -3
  32. package/dist/tsup/{chunk-HO76AEDH.cjs.map → chunk-UHMB5FFB.cjs.map} +1 -1
  33. package/dist/tsup/{chunk-QR6EAWEC.cjs → chunk-VKXEBB3Z.cjs} +7 -7
  34. package/dist/tsup/{chunk-QR6EAWEC.cjs.map → chunk-VKXEBB3Z.cjs.map} +1 -1
  35. package/dist/tsup/{chunk-EPRA2TCT.js → chunk-ZMVYZ7ZI.js} +2 -2
  36. package/dist/tsup/client/mod.cjs +6 -6
  37. package/dist/tsup/client/mod.d.cts +15 -3
  38. package/dist/tsup/client/mod.d.ts +15 -3
  39. package/dist/tsup/client/mod.js +5 -5
  40. package/dist/tsup/common/log.cjs +2 -2
  41. package/dist/tsup/common/log.js +1 -1
  42. package/dist/tsup/common/websocket.cjs +3 -3
  43. package/dist/tsup/common/websocket.js +2 -2
  44. package/dist/tsup/{config-Cw_BwH_G.d.ts → config-B4erdavw.d.ts} +58 -12
  45. package/dist/tsup/{config-D4clT6mq.d.ts → config-BfG1qpYz.d.cts} +34 -52
  46. package/dist/tsup/{config-D4clT6mq.d.cts → config-BfG1qpYz.d.ts} +34 -52
  47. package/dist/tsup/{config-CkmVg2fG.d.cts → config-DK144OAw.d.cts} +58 -12
  48. package/dist/tsup/{context-_xIcgBnE.d.cts → context-Cvnf3BRe.d.cts} +2 -2
  49. package/dist/tsup/{context-BYOKTQJi.d.ts → context-Oxi6YWcG.d.ts} +2 -2
  50. package/dist/tsup/db/drizzle.cjs +2 -2
  51. package/dist/tsup/db/drizzle.d.cts +1 -1
  52. package/dist/tsup/db/drizzle.d.ts +1 -1
  53. package/dist/tsup/db/drizzle.js +1 -1
  54. package/dist/tsup/db/mod.cjs +3 -3
  55. package/dist/tsup/db/mod.d.cts +2 -2
  56. package/dist/tsup/db/mod.d.ts +2 -2
  57. package/dist/tsup/db/mod.js +2 -2
  58. package/dist/tsup/dynamic/mod.d.cts +2 -2
  59. package/dist/tsup/dynamic/mod.d.ts +2 -2
  60. package/dist/tsup/inspector/mod.cjs +5 -5
  61. package/dist/tsup/inspector/mod.js +4 -4
  62. package/dist/tsup/inspector/workflow.cjs +4 -4
  63. package/dist/tsup/inspector/workflow.js +3 -3
  64. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  65. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  66. package/dist/tsup/mod.cjs +553 -202
  67. package/dist/tsup/mod.cjs.map +1 -1
  68. package/dist/tsup/mod.d.cts +4 -4
  69. package/dist/tsup/mod.d.ts +4 -4
  70. package/dist/tsup/mod.js +467 -116
  71. package/dist/tsup/mod.js.map +1 -1
  72. package/dist/tsup/test/mod.cjs +7 -7
  73. package/dist/tsup/test/mod.d.cts +2 -2
  74. package/dist/tsup/test/mod.d.ts +2 -2
  75. package/dist/tsup/test/mod.js +5 -5
  76. package/dist/tsup/unstable/migrations.d.cts +1 -1
  77. package/dist/tsup/unstable/migrations.d.ts +1 -1
  78. package/dist/tsup/utils.cjs +2 -2
  79. package/dist/tsup/utils.js +1 -1
  80. package/dist/tsup/workflow/mod.cjs +22 -19
  81. package/dist/tsup/workflow/mod.cjs.map +1 -1
  82. package/dist/tsup/workflow/mod.d.cts +4 -4
  83. package/dist/tsup/workflow/mod.d.ts +4 -4
  84. package/dist/tsup/workflow/mod.js +10 -7
  85. package/dist/tsup/workflow/mod.js.map +1 -1
  86. package/package.json +9 -10
  87. package/src/actor/keys.ts +86 -0
  88. package/src/client/actor-conn.ts +136 -24
  89. package/src/client/actor-handle.ts +21 -3
  90. package/src/client/client.ts +6 -0
  91. package/src/client/config.ts +12 -1
  92. package/src/client/lifecycle-errors.ts +35 -2
  93. package/src/client/retry-budget.ts +78 -0
  94. package/src/client/utils.ts +13 -2
  95. package/src/common/database/config.ts +46 -52
  96. package/src/common/database/native-database.ts +247 -27
  97. package/src/common/router.ts +1 -1
  98. package/src/db/mod.ts +0 -1
  99. package/src/engine-api/actors.ts +3 -3
  100. package/src/engine-client/actor-websocket-client.ts +4 -2
  101. package/src/engine-client/api-endpoints.ts +44 -14
  102. package/src/engine-client/mod.ts +2 -2
  103. package/src/registry/config/envoy.ts +1 -1
  104. package/src/registry/config/index.ts +29 -31
  105. package/src/registry/index.ts +66 -21
  106. package/src/registry/napi-runtime.ts +82 -3
  107. package/src/registry/native.ts +184 -52
  108. package/src/registry/runtime.ts +79 -10
  109. package/src/registry/wasm-runtime.ts +94 -3
  110. package/src/utils/env-vars.ts +15 -10
  111. package/src/workflow/driver.ts +5 -3
  112. package/dist/tsup/chunk-DDS7OOVF.cjs.map +0 -1
  113. package/dist/tsup/chunk-JI6GZ2C2.js.map +0 -1
  114. package/dist/tsup/chunk-KDT56V3Y.cjs.map +0 -1
  115. package/dist/tsup/chunk-MYWZCDML.cjs.map +0 -1
  116. package/dist/tsup/chunk-PJ5EXY6F.js.map +0 -1
  117. package/dist/tsup/chunk-USKGKQZM.js.map +0 -1
  118. package/src/actor/config.test.ts +0 -78
  119. package/src/actor/keys.test.ts +0 -275
  120. package/src/actor/utils.test.ts +0 -48
  121. package/src/client/test.ts +0 -44
  122. package/src/client/token-provider.test.ts +0 -86
  123. package/src/common/database/mod.test.ts +0 -364
  124. package/src/common/database/native-database.test.ts +0 -220
  125. package/src/common/inline-websocket-adapter.test.ts +0 -51
  126. package/src/db/drizzle.test.ts +0 -164
  127. package/src/registry/config/index.test.ts +0 -25
  128. package/src/registry/run-handler-coordinator.test.ts +0 -252
  129. package/src/registry/runtime.test.ts +0 -124
  130. package/src/unstable/migrations.test.ts +0 -170
  131. package/src/utils/endpoint-parser.test.ts +0 -206
  132. package/src/utils.test.ts +0 -34
  133. package/src/workflow/driver.test.ts +0 -62
  134. /package/dist/tsup/{chunk-3URZ4UV5.js.map → chunk-2HWY7FZU.js.map} +0 -0
  135. /package/dist/tsup/{chunk-F7IGTKGM.js.map → chunk-OWZ76NSH.js.map} +0 -0
  136. /package/dist/tsup/{chunk-KSP3NXGY.js.map → chunk-QE5MTZHB.js.map} +0 -0
  137. /package/dist/tsup/{chunk-D4G35VTO.js.map → chunk-QFZY2CK3.js.map} +0 -0
  138. /package/dist/tsup/{chunk-E2CUROR3.js.map → chunk-QIIIRYN7.js.map} +0 -0
  139. /package/dist/tsup/{chunk-EPRA2TCT.js.map → chunk-ZMVYZ7ZI.js.map} +0 -0
@@ -51,18 +51,13 @@ interface SqliteTransactionOptions {
51
51
  * to change without notice.
52
52
  */
53
53
  interface SqliteProfilingOptions {
54
- /** Existing v2 switch. Default: true. */
55
- enabled?: boolean;
56
- /** Exact SQL filter. Union with filterQueryFingerprints; both empty means all queries. */
57
- filterQueries?: string[];
58
- /** Fingerprint filter, including transaction fingerprints. Filters metrics, not diagnostic logs. */
59
- filterQueryFingerprints?: string[];
60
- /** Metric defaults apply even when omitted. Disabled metrics allocate no series. */
61
- metrics?: SqliteProfilingMetricsOptions;
62
- /** Duration buckets in seconds. Default [0.01, 0.1, 1]. Positive, finite, strictly increasing.
63
- * All actors in a process enabling the duration histogram must use identical buckets. */
64
- durationHistogramBucketsSeconds?: number[];
65
- /** Maximum distinct statement fingerprints per process. Default: 512. */
54
+ /** Exact SQL statements to give fingerprint labels. Profiling defaults to actor
55
+ * aggregates without fingerprint labels. Profile logs remain enabled.
56
+ * RIVETKIT_SQLITE_PROFILING overrides selection with a JSON object containing
57
+ * queries and/or fingerprints arrays. An empty object clears fingerprint selection. */
58
+ queries?: string[];
59
+ /** Exact query fingerprints to label separately, as reported in profile logs. */
60
+ fingerprints?: string[];
66
61
  maxTrackedStatementFingerprints?: number;
67
62
  maxTrackedTransactionFingerprints?: number;
68
63
  maxPrometheusSeries?: number;
@@ -74,45 +69,6 @@ interface SqliteProfilingOptions {
74
69
  maxDiagnosticEventsPerMinute?: number;
75
70
  diagnosticEventQueueCapacity?: number;
76
71
  }
77
- /** SQLite profiling metrics. Physical-request metrics and gauges have no query labels. */
78
- interface SqliteProfilingMetricsOptions {
79
- /** Execution count and cumulative seconds. Uses histogram count/sum when enabled, otherwise counters. Default: true. */
80
- duration?: boolean;
81
- /** Execution duration histogram. Only applies when duration is enabled. Default: true. */
82
- durationHistogram?: boolean;
83
- /** Outcome counters, including success and errors. Default: true. */
84
- outcomes?: boolean;
85
- /** Per-query timing phase histograms. Default: false. */
86
- phaseDurationHistogram?: boolean;
87
- /** Storage round trips per operation histogram. Default: false. */
88
- getPagesRoundTripsHistogram?: boolean;
89
- /** Statements per transaction histogram. Default: false. */
90
- transactionStatementCountHistogram?: boolean;
91
- /** Per-query pages returned from storage, including returned prefetch pages. Default: true. */
92
- pagesFetched?: boolean;
93
- /** Actor-level page counters by page kind (no query labels). Default: false. */
94
- localPages?: boolean;
95
- /** Actor-level byte counters by byte kind (no query labels). Default: false. */
96
- localBytes?: boolean;
97
- /** Actor-level physical storage request duration histogram. Default: false. */
98
- getPagesDurationHistogram?: boolean;
99
- /** Actor-level pages per storage request histograms, by page kind. Default: false. */
100
- getPagesPagesHistogram?: boolean;
101
- /** Actor-level storage response byte histogram. Default: false. */
102
- getPagesResponseBytesHistogram?: boolean;
103
- /** Actor-level missing response page counter. Default: false. */
104
- getPagesMissingPages?: boolean;
105
- /** Queued SQLite work, aggregated by actor name. Default: true. */
106
- workerQueueDepth?: boolean;
107
- /** Executing SQLite work, aggregated by actor name. Default: true. */
108
- workerInflight?: boolean;
109
- /** Transaction waiters, aggregated by actor name. Default: true. */
110
- coordinatorQueueDepth?: boolean;
111
- /** Counts observations exceeding fingerprint or series limits. Default: true. */
112
- fingerprintOverflow?: boolean;
113
- /** Counts diagnostic events dropped by rate limits or backpressure. Default: true. */
114
- eventDropped?: boolean;
115
- }
116
72
  interface SqliteNativeMetrics {
117
73
  requestBuildNs: number;
118
74
  serializeNs: number;
@@ -128,20 +84,46 @@ interface SqliteNativeMetrics {
128
84
  }
129
85
  interface SqliteDatabase {
130
86
  exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
87
+ execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
131
88
  execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
89
+ executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
132
90
  executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
133
91
  beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
92
+ beginTransactionSync?(timeoutMs?: number, name?: string): SynchronousSqliteTransactionDatabase;
134
93
  run(sql: string, params?: SqliteBindings): Promise<void>;
135
94
  query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
136
95
  nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
96
+ /**
97
+ * Returns the ticket of the latest local commit. Synchronous writes return before they are
98
+ * durable; pass the ticket to `whenDurable` before releasing output that depends on them.
99
+ */
100
+ commitTicket?(): number;
101
+ /**
102
+ * Resolves once the commit `ticket` names and every earlier commit are durable. Rejects with
103
+ * `sqlite.durability_failed` once the database broke and the actor is restarting.
104
+ */
105
+ whenDurable?(ticket: number): Promise<void>;
106
+ /**
107
+ * Restarts the owning actor from durable state. Every later write fails, including the final
108
+ * state save. For native database providers whose in-memory state can no longer be trusted.
109
+ */
110
+ abortGeneration?(reason: string): void;
137
111
  close(): Promise<void>;
138
112
  }
139
113
  interface SqliteTransactionDatabase {
140
114
  exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
115
+ execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
141
116
  execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
117
+ executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
142
118
  commit(): Promise<void>;
143
119
  rollback(): Promise<void>;
144
120
  }
121
+ type SynchronousSqliteTransactionDatabase = SqliteTransactionDatabase & {
122
+ execSync(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
123
+ executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult;
124
+ commitSync(): void;
125
+ rollbackSync(): void;
126
+ };
145
127
  /**
146
128
  * Provider for opening native databases from the active runtime.
147
129
  */
@@ -746,6 +728,7 @@ interface RuntimeActorConfig {
746
728
  icon?: string;
747
729
  hasDatabase?: boolean;
748
730
  remoteSqlite?: boolean;
731
+ sqliteDeferredCommits?: boolean;
749
732
  sqliteProfiling?: SqliteProfilingOptions;
750
733
  tracing?: RuntimeActorTracingConfig;
751
734
  enableActorRuntimeSocket?: boolean;
@@ -803,6 +786,8 @@ interface RuntimeServeConfig {
803
786
  engineBinaryPath?: string;
804
787
  startServices?: boolean;
805
788
  servicesBinaryPath?: string;
789
+ /** Whether config resolution selected a managed local development engine. */
790
+ engineSpawn?: boolean;
806
791
  engineHost?: string;
807
792
  enginePort?: number;
808
793
  handleInspectorHttpInRuntime?: boolean;
@@ -891,7 +876,12 @@ interface CoreRuntime {
891
876
  createCancellationToken(): CancellationTokenHandle;
892
877
  cancellationTokenAborted(token: CancellationTokenHandle): boolean;
893
878
  cancelCancellationToken(token: CancellationTokenHandle): void;
894
- onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
879
+ /**
880
+ * Calls `callback` once when `token` is cancelled. Returns a release
881
+ * function that drops the registration without calling `callback`; call it
882
+ * once cancellation no longer matters so the native listener is freed.
883
+ */
884
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): () => void;
895
885
  actorState(ctx: ActorContextHandle): RuntimeBytes;
896
886
  actorBeginOnStateChange(ctx: ActorContextHandle): void;
897
887
  actorEndOnStateChange(ctx: ActorContextHandle): void;
@@ -965,13 +955,20 @@ interface CoreRuntime {
965
955
  actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
966
956
  actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
967
957
  actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
958
+ actorSqlExecSync(ctx: ActorContextHandle, sql: string): RuntimeSqlExecResult;
968
959
  actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
960
+ actorSqlExecuteSync(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
969
961
  actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
970
962
  actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
963
+ actorSqlBeginTransactionSync(ctx: ActorContextHandle, timeoutMs?: number, name?: string): SqliteTransactionHandle;
971
964
  actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
965
+ actorSqlTransactionExecSync(transaction: SqliteTransactionHandle, sql: string): RuntimeSqlExecResult;
972
966
  actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
967
+ actorSqlTransactionExecuteSync(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
973
968
  actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
969
+ actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
974
970
  actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
971
+ actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
975
972
  actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
976
973
  actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
977
974
  actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
@@ -980,6 +977,13 @@ interface CoreRuntime {
980
977
  actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
981
978
  actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
982
979
  actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
980
+ /** Opens the actor database so later synchronous calls never fetch its first pages. */
981
+ actorSqlOpen(ctx: ActorContextHandle): Promise<void>;
982
+ /** Returns the ticket of the latest local commit. */
983
+ actorSqlCommitTicket(ctx: ActorContextHandle): number;
984
+ /** Resolves once the commit `ticket` names and every earlier commit are durable. */
985
+ actorSqlWhenDurable(ctx: ActorContextHandle, ticket: number): Promise<void>;
986
+ actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void;
983
987
  actorSqlClose(ctx: ActorContextHandle): Promise<void>;
984
988
  actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
985
989
  actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
@@ -1281,6 +1285,27 @@ declare class ActorConnRaw {
1281
1285
  */
1282
1286
  type ActorConn<AD extends AnyActorDefinition> = Omit<ActorConnRaw, "send" | "on" | "once"> & ActorDefinitionQueueSend<AD> & ActorDefinitionEventSubscriptions<AD> & ActorDefinitionActions<AD>;
1283
1287
 
1288
+ /** How many retries a client may spend, as a share of the requests it sends. */
1289
+ interface RetryBudgetOptions {
1290
+ /** Retries allowed per 100 requests (default 10). */
1291
+ percent?: number;
1292
+ /** Retries the client can bank for a burst of refusals; the budget starts full (default 100). */
1293
+ maxTokens?: number;
1294
+ }
1295
+ /**
1296
+ * Bounds the client's retries of refused requests. Each request adds a fraction of a token and
1297
+ * each retry spends one, so retries stay a fixed share of traffic while the service sheds load
1298
+ * instead of multiplying it.
1299
+ */
1300
+ declare class RetryBudget {
1301
+ #private;
1302
+ constructor(options?: RetryBudgetOptions);
1303
+ /** Credits one request sent. */
1304
+ deposit(): void;
1305
+ /** Spends one token. Returns `false` when the budget is spent. */
1306
+ tryWithdraw(): boolean;
1307
+ }
1308
+
1284
1309
  /**
1285
1310
  * Provides underlying functions for stateless {@link ActorHandle} for action calls.
1286
1311
  * Similar to ActorConnRaw but doesn't maintain a connection.
@@ -1296,7 +1321,7 @@ declare class ActorHandleRaw {
1296
1321
  *
1297
1322
  * @protected
1298
1323
  */
1299
- constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal, currentActorInvocation?: CurrentActorInvocation, startCallSpan?: StartCallSpan);
1324
+ constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal, currentActorInvocation?: CurrentActorInvocation, startCallSpan?: StartCallSpan, retryBudget?: RetryBudget);
1300
1325
  send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
1301
1326
  send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
1302
1327
  /**
@@ -1380,6 +1405,10 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
1380
1405
  skipReadyWait: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
1381
1406
  }, z$1.core.$strip>>>;
1382
1407
  getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
1408
+ retryBudget: z$1.ZodOptional<z$1.ZodObject<{
1409
+ percent: z$1.ZodOptional<z$1.ZodNumber>;
1410
+ maxTokens: z$1.ZodOptional<z$1.ZodNumber>;
1411
+ }, z$1.core.$strip>>;
1383
1412
  fetch: z$1.ZodOptional<z$1.ZodCustom<typeof fetch, typeof fetch>>;
1384
1413
  disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
1385
1414
  maxInputSize: z$1.ZodDefault<z$1.ZodNumber>;
@@ -1399,6 +1428,10 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
1399
1428
  devtools: boolean;
1400
1429
  getToken?: GetToken | undefined;
1401
1430
  getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
1431
+ retryBudget?: {
1432
+ percent?: number | undefined;
1433
+ maxTokens?: number | undefined;
1434
+ } | undefined;
1402
1435
  fetch?: typeof fetch | undefined;
1403
1436
  }, {
1404
1437
  endpoint: string;
@@ -1415,6 +1448,10 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
1415
1448
  devtools: boolean;
1416
1449
  getToken?: GetToken | undefined;
1417
1450
  getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
1451
+ retryBudget?: {
1452
+ percent?: number | undefined;
1453
+ maxTokens?: number | undefined;
1454
+ } | undefined;
1418
1455
  fetch?: typeof fetch | undefined;
1419
1456
  }>>;
1420
1457
  type ClientConfigInput = z$1.input<typeof ClientConfigSchema>;
@@ -1563,6 +1600,8 @@ declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
1563
1600
  interface ClientRawOptions {
1564
1601
  encoding?: Encoding;
1565
1602
  gateway?: ActorGatewayOptions;
1603
+ /** Bounds retries of refused requests across every handle of this client. */
1604
+ retryBudget?: RetryBudgetOptions;
1566
1605
  }
1567
1606
  /** Runtime-supplied wiring for clients created inside an actor. Set only by the native runtime. */
1568
1607
  interface ActorClientRuntimeOptions {
@@ -2358,11 +2397,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
2358
2397
  publicEndpoint: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
2359
2398
  publicToken: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
2360
2399
  }, z$2.core.$strip>>>;
2361
- envoy: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
2400
+ node: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
2362
2401
  poolName: z$2.ZodDefault<z$2.ZodString>;
2363
2402
  version: z$2.ZodDefault<z$2.ZodNumber>;
2364
2403
  totalSlots: z$2.ZodDefault<z$2.ZodNumber>;
2365
- envoyKey: z$2.ZodOptional<z$2.ZodString>;
2404
+ nodeKey: z$2.ZodOptional<z$2.ZodString>;
2366
2405
  }, z$2.core.$strip>>>;
2367
2406
  shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
2368
2407
  gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
@@ -2373,6 +2412,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
2373
2412
  backend: "local" | "remote";
2374
2413
  } | undefined;
2375
2414
  endpoint: string | undefined;
2415
+ engineSpawn: boolean;
2376
2416
  startServices: boolean;
2377
2417
  namespace: string;
2378
2418
  token: string | undefined;
@@ -2412,11 +2452,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
2412
2452
  engineHost: string;
2413
2453
  enginePort: number;
2414
2454
  engineVersion: string;
2415
- envoy: {
2455
+ node: {
2416
2456
  poolName: string;
2417
2457
  version: number;
2418
2458
  totalSlots: number;
2419
- envoyKey?: string | undefined;
2459
+ nodeKey?: string | undefined;
2420
2460
  };
2421
2461
  shutdown: {
2422
2462
  disableSignalHandlers: boolean;
@@ -2473,11 +2513,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
2473
2513
  publicEndpoint: string | undefined;
2474
2514
  publicToken: string | undefined;
2475
2515
  };
2476
- envoy: {
2516
+ node: {
2477
2517
  poolName: string;
2478
2518
  version: number;
2479
2519
  totalSlots: number;
2480
- envoyKey?: string | undefined;
2520
+ nodeKey?: string | undefined;
2481
2521
  };
2482
2522
  shutdown: {
2483
2523
  disableSignalHandlers: boolean;