rivetkit 0.0.0-sqlite-sync-3-0-1-release.95f6e2d → 0.0.0-sqlite-query-metrics-v3.1dff84f

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 (114) hide show
  1. package/dist/browser/client.d.ts +58 -48
  2. package/dist/browser/client.js +67 -7
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +4 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-UHMB5FFB.cjs → chunk-22S5RCCJ.cjs} +3 -3
  7. package/dist/tsup/{chunk-UHMB5FFB.cjs.map → chunk-22S5RCCJ.cjs.map} +1 -1
  8. package/dist/tsup/{chunk-ZMVYZ7ZI.js → chunk-2CTZU7GL.js} +2 -2
  9. package/dist/tsup/{chunk-VKXEBB3Z.cjs → chunk-CWN7N5AF.cjs} +7 -7
  10. package/dist/tsup/{chunk-VKXEBB3Z.cjs.map → chunk-CWN7N5AF.cjs.map} +1 -1
  11. package/dist/tsup/{chunk-2HWY7FZU.js → chunk-D7DWNYEO.js} +2 -2
  12. package/dist/tsup/{chunk-OWZ76NSH.js → chunk-F5PWAGS7.js} +2 -2
  13. package/dist/tsup/{chunk-QIIIRYN7.js → chunk-FT6VRK4C.js} +2 -2
  14. package/dist/tsup/{chunk-MYWNJP55.cjs → chunk-HFGXV2CC.cjs} +10 -10
  15. package/dist/tsup/{chunk-MYWNJP55.cjs.map → chunk-HFGXV2CC.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-QFZY2CK3.js → chunk-HRKFVQPS.js} +4 -4
  17. package/dist/tsup/{chunk-E6HKVCPA.cjs → chunk-HXJ5U2ZI.cjs} +3 -3
  18. package/dist/tsup/{chunk-E6HKVCPA.cjs.map → chunk-HXJ5U2ZI.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-E4KDQJCR.cjs → chunk-JJUSO7GJ.cjs} +3 -3
  20. package/dist/tsup/{chunk-E4KDQJCR.cjs.map → chunk-JJUSO7GJ.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-EQBUH25O.cjs → chunk-NG5CUXMM.cjs} +203 -146
  22. package/dist/tsup/chunk-NG5CUXMM.cjs.map +1 -0
  23. package/dist/tsup/{chunk-HQHTTJW5.js → chunk-NNCL4IBC.js} +9 -3
  24. package/dist/tsup/chunk-NNCL4IBC.js.map +1 -0
  25. package/dist/tsup/{chunk-62WFU3BQ.js → chunk-QQIFRR3B.js} +69 -12
  26. package/dist/tsup/chunk-QQIFRR3B.js.map +1 -0
  27. package/dist/tsup/{chunk-HDVZ6YZG.cjs → chunk-SSF2XC33.cjs} +1 -1
  28. package/dist/tsup/chunk-SSF2XC33.cjs.map +1 -0
  29. package/dist/tsup/{chunk-QE5MTZHB.js → chunk-SW33HMM5.js} +3 -3
  30. package/dist/tsup/{chunk-6FEYCVZC.js → chunk-UXDASKP6.js} +1 -1
  31. package/dist/tsup/chunk-UXDASKP6.js.map +1 -0
  32. package/dist/tsup/{chunk-AQWZWR2P.cjs → chunk-Y4QLVCCS.cjs} +9 -3
  33. package/dist/tsup/chunk-Y4QLVCCS.cjs.map +1 -0
  34. package/dist/tsup/{chunk-M5SQGPRJ.cjs → chunk-Y5CFDGPA.cjs} +4 -4
  35. package/dist/tsup/{chunk-M5SQGPRJ.cjs.map → chunk-Y5CFDGPA.cjs.map} +1 -1
  36. package/dist/tsup/client/mod.cjs +5 -5
  37. package/dist/tsup/client/mod.d.cts +3 -3
  38. package/dist/tsup/client/mod.d.ts +3 -3
  39. package/dist/tsup/client/mod.js +4 -4
  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-B4erdavw.d.ts → config-BiiS5T5M.d.ts} +3 -16
  45. package/dist/tsup/{config-DK144OAw.d.cts → config-BnMhcPHl.d.cts} +3 -16
  46. package/dist/tsup/{config-BfG1qpYz.d.cts → config-CBTr4IhE.d.cts} +50 -34
  47. package/dist/tsup/{config-BfG1qpYz.d.ts → config-CBTr4IhE.d.ts} +50 -34
  48. package/dist/tsup/{context-Cvnf3BRe.d.cts → context-DVE8XMm1.d.cts} +2 -2
  49. package/dist/tsup/{context-Oxi6YWcG.d.ts → context-iMxXq_Lt.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.cjs +2 -2
  59. package/dist/tsup/dynamic/mod.d.cts +2 -2
  60. package/dist/tsup/dynamic/mod.d.ts +2 -2
  61. package/dist/tsup/dynamic/mod.js +1 -1
  62. package/dist/tsup/inspector/mod.cjs +5 -5
  63. package/dist/tsup/inspector/mod.js +4 -4
  64. package/dist/tsup/inspector/workflow.cjs +4 -4
  65. package/dist/tsup/inspector/workflow.js +3 -3
  66. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  67. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  68. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  69. package/dist/tsup/inspector-tab/mod.js +1 -1
  70. package/dist/tsup/mod.cjs +166 -417
  71. package/dist/tsup/mod.cjs.map +1 -1
  72. package/dist/tsup/mod.d.cts +4 -4
  73. package/dist/tsup/mod.d.ts +4 -4
  74. package/dist/tsup/mod.js +67 -318
  75. package/dist/tsup/mod.js.map +1 -1
  76. package/dist/tsup/test/mod.cjs +6 -6
  77. package/dist/tsup/test/mod.d.cts +2 -2
  78. package/dist/tsup/test/mod.d.ts +2 -2
  79. package/dist/tsup/test/mod.js +4 -4
  80. package/dist/tsup/unstable/migrations.d.cts +1 -1
  81. package/dist/tsup/unstable/migrations.d.ts +1 -1
  82. package/dist/tsup/utils.cjs +2 -2
  83. package/dist/tsup/utils.js +1 -1
  84. package/dist/tsup/workflow/mod.cjs +10 -10
  85. package/dist/tsup/workflow/mod.cjs.map +1 -1
  86. package/dist/tsup/workflow/mod.d.cts +4 -4
  87. package/dist/tsup/workflow/mod.d.ts +4 -4
  88. package/dist/tsup/workflow/mod.js +5 -5
  89. package/package.json +12 -9
  90. package/src/actor/config.ts +2 -0
  91. package/src/client/actor-handle.ts +43 -7
  92. package/src/client/raw-utils.ts +17 -3
  93. package/src/client/utils.ts +4 -0
  94. package/src/common/database/config.ts +50 -46
  95. package/src/common/database/native-database.ts +21 -230
  96. package/src/db/mod.ts +1 -0
  97. package/src/registry/config/index.ts +7 -5
  98. package/src/registry/napi-runtime.ts +0 -78
  99. package/src/registry/native.ts +41 -74
  100. package/src/registry/runtime.ts +1 -53
  101. package/src/registry/wasm-runtime.ts +0 -88
  102. package/src/utils/env-vars.ts +4 -2
  103. package/dist/tsup/chunk-62WFU3BQ.js.map +0 -1
  104. package/dist/tsup/chunk-6FEYCVZC.js.map +0 -1
  105. package/dist/tsup/chunk-AQWZWR2P.cjs.map +0 -1
  106. package/dist/tsup/chunk-EQBUH25O.cjs.map +0 -1
  107. package/dist/tsup/chunk-HDVZ6YZG.cjs.map +0 -1
  108. package/dist/tsup/chunk-HQHTTJW5.js.map +0 -1
  109. /package/dist/tsup/{chunk-ZMVYZ7ZI.js.map → chunk-2CTZU7GL.js.map} +0 -0
  110. /package/dist/tsup/{chunk-2HWY7FZU.js.map → chunk-D7DWNYEO.js.map} +0 -0
  111. /package/dist/tsup/{chunk-OWZ76NSH.js.map → chunk-F5PWAGS7.js.map} +0 -0
  112. /package/dist/tsup/{chunk-QIIIRYN7.js.map → chunk-FT6VRK4C.js.map} +0 -0
  113. /package/dist/tsup/{chunk-QFZY2CK3.js.map → chunk-HRKFVQPS.js.map} +0 -0
  114. /package/dist/tsup/{chunk-QE5MTZHB.js.map → chunk-SW33HMM5.js.map} +0 -0
@@ -251,8 +251,8 @@ export const RegistryConfigSchema = z
251
251
  .default(() => getRivetRunEngineVersion() ?? VERSION),
252
252
  /**
253
253
  * Starts the first-party Services actor host when RivetKit manages
254
- * a local engine. Disabled by default. Set RIVET_RUN_SERVICES=1
255
- * or startServices: true to enable it.
254
+ * a local engine. Enabled by default for a managed local Engine. Set
255
+ * RIVET_RUN_SERVICES=0 or startServices: false to disable it.
256
256
  */
257
257
  startServices: z.boolean().optional(),
258
258
  /**
@@ -369,7 +369,9 @@ export const RegistryConfigSchema = z
369
369
  ? localEngineEndpoint
370
370
  : (parsedEndpoint?.endpoint ??
371
371
  (isDevEnv ? localEngineEndpoint : undefined));
372
- const startServices = config.startServices ?? getRivetRunServices();
372
+ const engineSpawn = !parsedEndpoint && Boolean(endpoint);
373
+ const startServices =
374
+ config.startServices ?? getRivetRunServices() ?? engineSpawn;
373
375
  const validateServerlessEndpoint = Boolean(
374
376
  config.startEngine || parsedEndpoint,
375
377
  );
@@ -419,7 +421,7 @@ export const RegistryConfigSchema = z
419
421
  ...config,
420
422
  sqlite,
421
423
  endpoint,
422
- engineSpawn: !parsedEndpoint && Boolean(endpoint),
424
+ engineSpawn,
423
425
  startServices,
424
426
  namespace,
425
427
  token,
@@ -656,7 +658,7 @@ export const DocRegistryConfigSchema = z
656
658
  .boolean()
657
659
  .optional()
658
660
  .describe(
659
- "Starts Services when RivetKit manages a local Engine. Disabled by default. Set RIVET_RUN_SERVICES=1 or startServices: true to enable.",
661
+ "Starts Services when RivetKit manages a local Engine. Enabled by default for a managed local Engine. Set RIVET_RUN_SERVICES=0 or startServices: false to disable.",
660
662
  ),
661
663
  configurePool: DocConfigurePoolSchema.describe(
662
664
  "Automatically configure serverless nodes in the engine.",
@@ -860,13 +860,6 @@ export class NapiCoreRuntime implements CoreRuntime {
860
860
  return await this.#actorSql(ctx).exec(sql);
861
861
  }
862
862
 
863
- actorSqlExecSync(
864
- ctx: ActorContextHandle,
865
- sql: string,
866
- ): RuntimeSqlExecResult {
867
- return this.#actorSql(ctx).execSync(sql);
868
- }
869
-
870
863
  async actorSqlExecute(
871
864
  ctx: ActorContextHandle,
872
865
  sql: string,
@@ -879,18 +872,6 @@ export class NapiCoreRuntime implements CoreRuntime {
879
872
  return normalizeRuntimeSqlExecuteResult(result);
880
873
  }
881
874
 
882
- actorSqlExecuteSync(
883
- ctx: ActorContextHandle,
884
- sql: string,
885
- params?: RuntimeSqlBindParams,
886
- ): RuntimeSqlExecuteResult {
887
- const result = this.#actorSql(ctx).executeSync(
888
- sql,
889
- toNapiSqlBindParams(params),
890
- );
891
- return normalizeRuntimeSqlExecuteResult(result);
892
- }
893
-
894
875
  async actorSqlExecuteBatch(
895
876
  ctx: ActorContextHandle,
896
877
  statements: RuntimeSqlBatchStatement[],
@@ -912,17 +893,6 @@ export class NapiCoreRuntime implements CoreRuntime {
912
893
  )) as unknown as SqliteTransactionHandle;
913
894
  }
914
895
 
915
- actorSqlBeginTransactionSync(
916
- ctx: ActorContextHandle,
917
- timeoutMs?: number,
918
- name?: string,
919
- ): SqliteTransactionHandle {
920
- return this.#actorSql(ctx).beginTransactionSync(
921
- timeoutMs,
922
- name,
923
- ) as unknown as SqliteTransactionHandle;
924
- }
925
-
926
896
  async actorSqlTransactionExec(
927
897
  transaction: SqliteTransactionHandle,
928
898
  sql: string,
@@ -930,13 +900,6 @@ export class NapiCoreRuntime implements CoreRuntime {
930
900
  return await asNativeSqlTransaction(transaction).exec(sql);
931
901
  }
932
902
 
933
- actorSqlTransactionExecSync(
934
- transaction: SqliteTransactionHandle,
935
- sql: string,
936
- ): RuntimeSqlExecResult {
937
- return asNativeSqlTransaction(transaction).execSync(sql);
938
- }
939
-
940
903
  async actorSqlTransactionExecute(
941
904
  transaction: SqliteTransactionHandle,
942
905
  sql: string,
@@ -949,39 +912,17 @@ export class NapiCoreRuntime implements CoreRuntime {
949
912
  return normalizeRuntimeSqlExecuteResult(result);
950
913
  }
951
914
 
952
- actorSqlTransactionExecuteSync(
953
- transaction: SqliteTransactionHandle,
954
- sql: string,
955
- params?: RuntimeSqlBindParams,
956
- ): RuntimeSqlExecuteResult {
957
- const result = asNativeSqlTransaction(transaction).executeSync(
958
- sql,
959
- toNapiSqlBindParams(params),
960
- );
961
- return normalizeRuntimeSqlExecuteResult(result);
962
- }
963
-
964
915
  async actorSqlTransactionCommit(
965
916
  transaction: SqliteTransactionHandle,
966
917
  ): Promise<void> {
967
918
  await asNativeSqlTransaction(transaction).commit();
968
919
  }
969
920
 
970
- actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void {
971
- asNativeSqlTransaction(transaction).commitSync();
972
- }
973
-
974
921
  async actorSqlTransactionRollback(
975
922
  transaction: SqliteTransactionHandle,
976
923
  ): Promise<void> {
977
924
  await asNativeSqlTransaction(transaction).rollback();
978
925
  }
979
-
980
- actorSqlTransactionRollbackSync(
981
- transaction: SqliteTransactionHandle,
982
- ): void {
983
- asNativeSqlTransaction(transaction).rollbackSync();
984
- }
985
926
  async actorBeginStateTransaction(
986
927
  ctx: ActorContextHandle,
987
928
  timeoutMs?: number,
@@ -1045,25 +986,6 @@ export class NapiCoreRuntime implements CoreRuntime {
1045
986
  return this.#actorSql(ctx).takeLastKvError?.() ?? null;
1046
987
  }
1047
988
 
1048
- async actorSqlOpen(ctx: ActorContextHandle): Promise<void> {
1049
- await this.#actorSql(ctx).open();
1050
- }
1051
-
1052
- actorSqlCommitTicket(ctx: ActorContextHandle): number {
1053
- return this.#actorSql(ctx).commitTicket();
1054
- }
1055
-
1056
- actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void {
1057
- this.#actorSql(ctx).abortGeneration(reason);
1058
- }
1059
-
1060
- async actorSqlWhenDurable(
1061
- ctx: ActorContextHandle,
1062
- ticket: number,
1063
- ): Promise<void> {
1064
- await this.#actorSql(ctx).whenDurable(ticket);
1065
- }
1066
-
1067
989
  async actorSqlClose(ctx: ActorContextHandle): Promise<void> {
1068
990
  const nativeCtx = asNativeActorContext(ctx);
1069
991
  if (!this.#sqlOpened.delete(nativeCtx)) {
@@ -61,11 +61,7 @@ import {
61
61
  db as defaultDb,
62
62
  registerNativeStateTransactionOpener,
63
63
  } from "@/common/database/mod";
64
- import {
65
- type JsNativeDatabaseLike,
66
- type JsNativeSynchronousTransactionLike,
67
- wrapJsNativeDatabase,
68
- } from "@/common/database/native-database";
64
+ import { wrapJsNativeDatabase } from "@/common/database/native-database";
69
65
  import { assertJsonCompatValue, type JsonCompatValue } from "@/common/encoding";
70
66
  import { isResponseLike } from "@/common/fetch-like";
71
67
  import {
@@ -129,7 +125,6 @@ import type {
129
125
  RuntimeScheduledFireInfo,
130
126
  RuntimeServeConfig,
131
127
  RuntimeStateDeltaPayload,
132
- SqliteTransactionHandle,
133
128
  WebSocketHandle,
134
129
  } from "./runtime";
135
130
  import { servicesBinaryUnavailable } from "./runtime";
@@ -660,26 +655,6 @@ async function closeNativeDatabaseClient(
660
655
  }
661
656
  }
662
657
 
663
- function createNativeSqlTransaction(
664
- runtime: CoreRuntime,
665
- transaction: SqliteTransactionHandle,
666
- ): JsNativeSynchronousTransactionLike {
667
- return {
668
- exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
669
- execSync: (sql) =>
670
- runtime.actorSqlTransactionExecSync(transaction, sql),
671
- execute: (sql, params) =>
672
- runtime.actorSqlTransactionExecute(transaction, sql, params),
673
- executeSync: (sql, params) =>
674
- runtime.actorSqlTransactionExecuteSync(transaction, sql, params),
675
- commit: () => runtime.actorSqlTransactionCommit(transaction),
676
- commitSync: () => runtime.actorSqlTransactionCommitSync(transaction),
677
- rollback: () => runtime.actorSqlTransactionRollback(transaction),
678
- rollbackSync: () =>
679
- runtime.actorSqlTransactionRollbackSync(transaction),
680
- };
681
- }
682
-
683
658
  function getOrCreateNativeSqlDatabase(
684
659
  runtime: CoreRuntime,
685
660
  ctx: ActorContextHandle,
@@ -690,12 +665,9 @@ function getOrCreateNativeSqlDatabase(
690
665
  return cachedDatabase;
691
666
  }
692
667
 
693
- const bindings: JsNativeDatabaseLike = {
668
+ const database = wrapJsNativeDatabase({
694
669
  exec: (sql) => runtime.actorSqlExec(ctx, sql),
695
- execSync: (sql) => runtime.actorSqlExecSync(ctx, sql),
696
670
  execute: (sql, params) => runtime.actorSqlExecute(ctx, sql, params),
697
- executeSync: (sql, params) =>
698
- runtime.actorSqlExecuteSync(ctx, sql, params),
699
671
  executeBatch: (statements) =>
700
672
  runtime.actorSqlExecuteBatch(ctx, statements),
701
673
  beginTransaction: async (timeoutMs, name) => {
@@ -704,15 +676,19 @@ function getOrCreateNativeSqlDatabase(
704
676
  timeoutMs,
705
677
  name,
706
678
  );
707
- return createNativeSqlTransaction(runtime, transaction);
708
- },
709
- beginTransactionSync: (timeoutMs, name) => {
710
- const transaction = runtime.actorSqlBeginTransactionSync(
711
- ctx,
712
- timeoutMs,
713
- name,
714
- );
715
- return createNativeSqlTransaction(runtime, transaction);
679
+ return {
680
+ exec: (sql) =>
681
+ runtime.actorSqlTransactionExec(transaction, sql),
682
+ execute: (sql, params) =>
683
+ runtime.actorSqlTransactionExecute(
684
+ transaction,
685
+ sql,
686
+ params,
687
+ ),
688
+ commit: () => runtime.actorSqlTransactionCommit(transaction),
689
+ rollback: () =>
690
+ runtime.actorSqlTransactionRollback(transaction),
691
+ };
716
692
  },
717
693
  beginStateTransaction: async (timeoutMs, context) => {
718
694
  const scope = context as NativeStateTransactionScope | undefined;
@@ -752,14 +728,8 @@ function getOrCreateNativeSqlDatabase(
752
728
  run: (sql, params) => runtime.actorSqlRun(ctx, sql, params),
753
729
  metrics: () => runtime.actorSqlMetrics(ctx),
754
730
  takeLastKvError: () => runtime.actorSqlTakeLastKvError(ctx),
755
- open: () => runtime.actorSqlOpen(ctx),
756
- commitTicket: () => runtime.actorSqlCommitTicket(ctx),
757
- whenDurable: (ticket) => runtime.actorSqlWhenDurable(ctx, ticket),
758
- abortGeneration: (reason) =>
759
- runtime.actorSqlAbortGeneration(ctx, reason),
760
731
  close: () => runtime.actorSqlClose(ctx),
761
- };
762
- const database = wrapJsNativeDatabase(bindings);
732
+ });
763
733
  runtimeState.sql = database;
764
734
  return database;
765
735
  }
@@ -3215,12 +3185,10 @@ export class ActorContextHandleAdapter {
3215
3185
  {
3216
3186
  open: async (requestedActorId) => {
3217
3187
  void requestedActorId;
3218
- const database = getOrCreateNativeSqlDatabase(
3188
+ return getOrCreateNativeSqlDatabase(
3219
3189
  this.#runtime,
3220
3190
  this.#ctx,
3221
3191
  );
3222
- await database.open();
3223
- return database;
3224
3192
  },
3225
3193
  },
3226
3194
  async (timeoutMs, context) =>
@@ -4017,8 +3985,6 @@ function buildActorTracingConfig(
4017
3985
  };
4018
3986
  }
4019
3987
 
4020
- const SQLITE_DEFERRED_COMMITS = Symbol.for("rivetkit.sqlite.deferredCommits");
4021
-
4022
3988
  function buildActorConfig(
4023
3989
  definition: AnyActorDefinition,
4024
3990
  registryConfig: RegistryConfig,
@@ -4032,18 +3998,12 @@ function buildActorConfig(
4032
3998
  const sqliteProfiling = (
4033
3999
  config.db as { sqliteProfiling?: SqliteProfilingOptions } | undefined
4034
4000
  )?.sqliteProfiling;
4035
- // Internal opt-in for embedders, such as Open Orange, that gate outputs on `whenDurable`.
4036
- const sqliteDeferredCommits =
4037
- (config.db as Record<symbol, unknown> | undefined)?.[
4038
- SQLITE_DEFERRED_COMMITS
4039
- ] === true;
4040
4001
 
4041
4002
  return {
4042
4003
  name: options.name as string | undefined,
4043
4004
  icon: options.icon as string | undefined,
4044
4005
  hasDatabase: true,
4045
4006
  remoteSqlite: usesRemoteSqlite,
4046
- sqliteDeferredCommits: sqliteDeferredCommits || undefined,
4047
4007
  sqliteProfiling,
4048
4008
  tracing: buildActorTracingConfig(
4049
4009
  definition.config.actions,
@@ -5552,6 +5512,11 @@ export function buildNativeFactory(
5552
5512
  conn != null
5553
5513
  ? makeConnCtx(ctx, conn, undefined, cancelToken)
5554
5514
  : makeActorCtx(ctx, undefined, cancelToken);
5515
+ if (scheduledFire) {
5516
+ Object.defineProperty(actorCtx, "scheduledFire", {
5517
+ value: scheduledFire,
5518
+ });
5519
+ }
5555
5520
  const runAction = async () => {
5556
5521
  try {
5557
5522
  return encodeValue(
@@ -5720,7 +5685,7 @@ export function buildNativeFactory(
5720
5685
 
5721
5686
  export async function buildServeConfig(
5722
5687
  config: RegistryConfig,
5723
- resolveServicesBinary = true,
5688
+ resolveNativeBinaries = true,
5724
5689
  ): Promise<RuntimeServeConfig> {
5725
5690
  if (!config.endpoint) {
5726
5691
  throw nativeEndpointNotConfiguredError();
@@ -5733,7 +5698,7 @@ export async function buildServeConfig(
5733
5698
  token: config.token,
5734
5699
  namespace: config.namespace,
5735
5700
  poolName: config.node.poolName,
5736
- startServices: resolveServicesBinary && config.startServices,
5701
+ startServices: resolveNativeBinaries && config.startServices,
5737
5702
  handleInspectorHttpInRuntime: true,
5738
5703
  serverlessBasePath: config.serverless.basePath,
5739
5704
  serverlessPackageVersion: VERSION,
@@ -5744,28 +5709,30 @@ export async function buildServeConfig(
5744
5709
  serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes,
5745
5710
  };
5746
5711
 
5747
- // Always best-effort resolve the npm-installed engine binary and hand its
5748
- // path to the core. The core alone decides whether to actually spawn a local
5712
+ // For native runtimes, best-effort resolve the npm-installed engine binary
5713
+ // and hand its path to the core. The core decides whether to spawn a local
5749
5714
  // engine using the resolved spawn decision, so
5750
5715
  // JS must not duplicate that decision here. Only JS knows the npm
5751
5716
  // `node_modules` layout, so it resolves the path; if no binary is available
5752
5717
  // (remote-only install, unsupported platform, optional deps skipped), leave
5753
5718
  // it unset and let the core report `engine.binary_unavailable` if it actually
5754
5719
  // needs one.
5755
- try {
5756
- const { getEnginePath } = await loadEngineCli();
5757
- serveConfig.engineBinaryPath = getEnginePath();
5758
- } catch (error) {
5759
- // The npm-installed engine binary could not be resolved. The core still
5760
- // decides whether it needs to spawn a local engine; if it does, it will
5761
- // fail with engine.binary_unavailable (auto-download is off in the napi
5762
- // runtime). Warn so the cause is actionable.
5763
- logger().warn({
5764
- msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable — set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
5765
- error: stringifyError(error),
5766
- });
5720
+ if (resolveNativeBinaries) {
5721
+ try {
5722
+ const { getEnginePath } = await loadEngineCli();
5723
+ serveConfig.engineBinaryPath = getEnginePath();
5724
+ } catch (error) {
5725
+ // The npm-installed engine binary could not be resolved. The core still
5726
+ // decides whether it needs to spawn a local engine; if it does, it will
5727
+ // fail with engine.binary_unavailable (auto-download is off in the napi
5728
+ // runtime). Warn so the cause is actionable.
5729
+ logger().warn({
5730
+ msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable — set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
5731
+ error: stringifyError(error),
5732
+ });
5733
+ }
5767
5734
  }
5768
- if (resolveServicesBinary && config.startServices) {
5735
+ if (resolveNativeBinaries && config.startServices) {
5769
5736
  const servicesBinary = getEnvUniversal("RIVET_SERVICES_BINARY");
5770
5737
  if (servicesBinary) {
5771
5738
  serveConfig.servicesBinaryPath = servicesBinary;
@@ -284,15 +284,10 @@ export interface RuntimeSqlRunResult {
284
284
 
285
285
  export interface RuntimeSqlDatabase {
286
286
  exec(sql: string): Promise<RuntimeSqlExecResult>;
287
- execSync(sql: string): RuntimeSqlExecResult;
288
287
  execute(
289
288
  sql: string,
290
289
  params?: RuntimeSqlBindParams,
291
290
  ): Promise<RuntimeSqlExecuteResult>;
292
- executeSync(
293
- sql: string,
294
- params?: RuntimeSqlBindParams,
295
- ): RuntimeSqlExecuteResult;
296
291
  executeBatch(
297
292
  statements: RuntimeSqlBatchStatement[],
298
293
  ): Promise<RuntimeSqlExecuteResult[]>;
@@ -308,33 +303,19 @@ export interface RuntimeSqlDatabase {
308
303
  timeoutMs?: number,
309
304
  name?: string,
310
305
  ): Promise<RuntimeSqlTransactionDatabase>;
311
- beginTransactionSync(
312
- timeoutMs?: number,
313
- name?: string,
314
- ): RuntimeSqlTransactionDatabase;
315
306
  metrics?(): SqliteNativeMetrics | null;
316
307
  takeLastKvError?(): string | null;
317
- open(): Promise<void>;
318
- commitTicket(): number;
319
- whenDurable(ticket: number): Promise<void>;
320
308
  close(): Promise<void>;
321
309
  }
322
310
 
323
311
  export interface RuntimeSqlTransactionDatabase {
324
312
  exec(sql: string): Promise<RuntimeSqlExecResult>;
325
- execSync(sql: string): RuntimeSqlExecResult;
326
313
  execute(
327
314
  sql: string,
328
315
  params?: RuntimeSqlBindParams,
329
316
  ): Promise<RuntimeSqlExecuteResult>;
330
- executeSync(
331
- sql: string,
332
- params?: RuntimeSqlBindParams,
333
- ): RuntimeSqlExecuteResult;
334
317
  commit(): Promise<void>;
335
- commitSync(): void;
336
318
  rollback(): Promise<void>;
337
- rollbackSync(): void;
338
319
  }
339
320
 
340
321
  /** Sample rates for the traces an actor starts, in the shape core takes. */
@@ -349,7 +330,6 @@ export interface RuntimeActorConfig {
349
330
  icon?: string;
350
331
  hasDatabase?: boolean;
351
332
  remoteSqlite?: boolean;
352
- sqliteDeferredCommits?: boolean;
353
333
  sqliteProfiling?: SqliteProfilingOptions;
354
334
  tracing?: RuntimeActorTracingConfig;
355
335
  enableActorRuntimeSocket?: boolean;
@@ -716,20 +696,11 @@ export interface CoreRuntime {
716
696
  ctx: ActorContextHandle,
717
697
  sql: string,
718
698
  ): Promise<RuntimeSqlExecResult>;
719
- actorSqlExecSync(
720
- ctx: ActorContextHandle,
721
- sql: string,
722
- ): RuntimeSqlExecResult;
723
699
  actorSqlExecute(
724
700
  ctx: ActorContextHandle,
725
701
  sql: string,
726
702
  params?: RuntimeSqlBindParams,
727
703
  ): Promise<RuntimeSqlExecuteResult>;
728
- actorSqlExecuteSync(
729
- ctx: ActorContextHandle,
730
- sql: string,
731
- params?: RuntimeSqlBindParams,
732
- ): RuntimeSqlExecuteResult;
733
704
  actorSqlExecuteBatch(
734
705
  ctx: ActorContextHandle,
735
706
  statements: RuntimeSqlBatchStatement[],
@@ -739,37 +710,21 @@ export interface CoreRuntime {
739
710
  timeoutMs?: number,
740
711
  name?: string,
741
712
  ): Promise<SqliteTransactionHandle>;
742
- actorSqlBeginTransactionSync(
743
- ctx: ActorContextHandle,
744
- timeoutMs?: number,
745
- name?: string,
746
- ): SqliteTransactionHandle;
747
713
  actorSqlTransactionExec(
748
714
  transaction: SqliteTransactionHandle,
749
715
  sql: string,
750
716
  ): Promise<RuntimeSqlExecResult>;
751
- actorSqlTransactionExecSync(
752
- transaction: SqliteTransactionHandle,
753
- sql: string,
754
- ): RuntimeSqlExecResult;
755
717
  actorSqlTransactionExecute(
756
718
  transaction: SqliteTransactionHandle,
757
719
  sql: string,
758
720
  params?: RuntimeSqlBindParams,
759
721
  ): Promise<RuntimeSqlExecuteResult>;
760
- actorSqlTransactionExecuteSync(
761
- transaction: SqliteTransactionHandle,
762
- sql: string,
763
- params?: RuntimeSqlBindParams,
764
- ): RuntimeSqlExecuteResult;
765
722
  actorSqlTransactionCommit(
766
723
  transaction: SqliteTransactionHandle,
767
724
  ): Promise<void>;
768
- actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
769
725
  actorSqlTransactionRollback(
770
726
  transaction: SqliteTransactionHandle,
771
727
  ): Promise<void>;
772
- actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
773
728
  actorBeginStateTransaction(
774
729
  ctx: ActorContextHandle,
775
730
  timeoutMs?: number,
@@ -798,13 +753,6 @@ export interface CoreRuntime {
798
753
  ): Promise<RuntimeSqlRunResult>;
799
754
  actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
800
755
  actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
801
- /** Opens the actor database so later synchronous calls never fetch its first pages. */
802
- actorSqlOpen(ctx: ActorContextHandle): Promise<void>;
803
- /** Returns the ticket of the latest local commit. */
804
- actorSqlCommitTicket(ctx: ActorContextHandle): number;
805
- /** Resolves once the commit `ticket` names and every earlier commit are durable. */
806
- actorSqlWhenDurable(ctx: ActorContextHandle, ticket: number): Promise<void>;
807
- actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void;
808
756
  actorSqlClose(ctx: ActorContextHandle): Promise<void>;
809
757
  actorRuntimeSocketProvision(
810
758
  ctx: ActorContextHandle,
@@ -937,7 +885,7 @@ export interface RuntimeBundle {
937
885
 
938
886
  export function servicesBinaryUnavailable(cause: unknown): Error {
939
887
  return new Error(
940
- "services.binary_unavailable: Install @rivet-dev/services yourself to run local Services, or set RIVET_SERVICES_BINARY to its executable path.",
888
+ "services.binary_unavailable: Install @rivet-dev/services to run local Services, set RIVET_SERVICES_BINARY to its executable path, or set RIVET_RUN_SERVICES=0 to disable Services.",
941
889
  { cause },
942
890
  );
943
891
  }
@@ -150,18 +150,6 @@ function wasmNumber(value: number | bigint): number {
150
150
  return typeof value === "bigint" ? Number(value) : value;
151
151
  }
152
152
 
153
- function synchronousSqliteUnavailable(): never {
154
- throw new RivetError(
155
- "sqlite",
156
- "sync_unsupported",
157
- "Synchronous SQLite is unavailable because the actor runs on the wasm runtime.",
158
- {
159
- public: true,
160
- metadata: { runtime: "wasm" },
161
- },
162
- );
163
- }
164
-
165
153
  function normalizeKvEntry(entry: RuntimeKvEntry): RuntimeKvEntry {
166
154
  return {
167
155
  key: toBytes(entry.key),
@@ -379,14 +367,6 @@ export class WasmCoreRuntime implements CoreRuntime {
379
367
  callbacks: object,
380
368
  config?: RuntimeActorConfig | undefined | null,
381
369
  ): ActorFactoryHandle {
382
- if (config?.sqliteDeferredCommits) {
383
- throw new RivetError(
384
- "sqlite",
385
- "deferred_commits_unsupported",
386
- "SQLite deferred commits require local native SQLite, but the wasm runtime uses remote SQLite.",
387
- { metadata: { runtime: "wasm" } },
388
- );
389
- }
390
370
  return callWasmSync(() =>
391
371
  asActorFactoryHandle(
392
372
  new this.#constructors.ActorFactory(callbacks, config),
@@ -820,13 +800,6 @@ export class WasmCoreRuntime implements CoreRuntime {
820
800
  return await callWasm(() => this.#actorSql(ctx).exec(sql));
821
801
  }
822
802
 
823
- actorSqlExecSync(
824
- _ctx: ActorContextHandle,
825
- _sql: string,
826
- ): RuntimeSqlExecResult {
827
- return synchronousSqliteUnavailable();
828
- }
829
-
830
803
  async actorSqlExecute(
831
804
  ctx: ActorContextHandle,
832
805
  sql: string,
@@ -838,14 +811,6 @@ export class WasmCoreRuntime implements CoreRuntime {
838
811
  return normalizeRuntimeSqlExecuteResult(result);
839
812
  }
840
813
 
841
- actorSqlExecuteSync(
842
- _ctx: ActorContextHandle,
843
- _sql: string,
844
- _params?: RuntimeSqlBindParams,
845
- ): RuntimeSqlExecuteResult {
846
- return synchronousSqliteUnavailable();
847
- }
848
-
849
814
  async actorSqlExecuteBatch(
850
815
  ctx: ActorContextHandle,
851
816
  statements: RuntimeSqlBatchStatement[],
@@ -866,14 +831,6 @@ export class WasmCoreRuntime implements CoreRuntime {
866
831
  )) as unknown as SqliteTransactionHandle;
867
832
  }
868
833
 
869
- actorSqlBeginTransactionSync(
870
- _ctx: ActorContextHandle,
871
- _timeoutMs?: number,
872
- _name?: string,
873
- ): SqliteTransactionHandle {
874
- return synchronousSqliteUnavailable();
875
- }
876
-
877
834
  async actorSqlTransactionExec(
878
835
  transaction: SqliteTransactionHandle,
879
836
  sql: string,
@@ -887,13 +844,6 @@ export class WasmCoreRuntime implements CoreRuntime {
887
844
  );
888
845
  }
889
846
 
890
- actorSqlTransactionExecSync(
891
- _transaction: SqliteTransactionHandle,
892
- _sql: string,
893
- ): RuntimeSqlExecResult {
894
- return synchronousSqliteUnavailable();
895
- }
896
-
897
847
  async actorSqlTransactionExecute(
898
848
  transaction: SqliteTransactionHandle,
899
849
  sql: string,
@@ -912,14 +862,6 @@ export class WasmCoreRuntime implements CoreRuntime {
912
862
  return normalizeRuntimeSqlExecuteResult(result);
913
863
  }
914
864
 
915
- actorSqlTransactionExecuteSync(
916
- _transaction: SqliteTransactionHandle,
917
- _sql: string,
918
- _params?: RuntimeSqlBindParams,
919
- ): RuntimeSqlExecuteResult {
920
- return synchronousSqliteUnavailable();
921
- }
922
-
923
865
  async actorSqlTransactionCommit(
924
866
  transaction: SqliteTransactionHandle,
925
867
  ): Promise<void> {
@@ -928,10 +870,6 @@ export class WasmCoreRuntime implements CoreRuntime {
928
870
  );
929
871
  }
930
872
 
931
- actorSqlTransactionCommitSync(_transaction: SqliteTransactionHandle): void {
932
- synchronousSqliteUnavailable();
933
- }
934
-
935
873
  async actorSqlTransactionRollback(
936
874
  transaction: SqliteTransactionHandle,
937
875
  ): Promise<void> {
@@ -941,13 +879,6 @@ export class WasmCoreRuntime implements CoreRuntime {
941
879
  ).rollback(),
942
880
  );
943
881
  }
944
-
945
- actorSqlTransactionRollbackSync(
946
- _transaction: SqliteTransactionHandle,
947
- ): void {
948
- synchronousSqliteUnavailable();
949
- }
950
-
951
882
  async actorBeginStateTransaction(
952
883
  ctx: ActorContextHandle,
953
884
  timeoutMs?: number,
@@ -1028,25 +959,6 @@ export class WasmCoreRuntime implements CoreRuntime {
1028
959
  return this.#actorSql(ctx).takeLastKvError?.() ?? null;
1029
960
  }
1030
961
 
1031
- async actorSqlOpen(_ctx: ActorContextHandle): Promise<void> {
1032
- // Remote SQLite opens on the engine side with each request.
1033
- }
1034
-
1035
- actorSqlCommitTicket(_ctx: ActorContextHandle): number {
1036
- return synchronousSqliteUnavailable();
1037
- }
1038
-
1039
- actorSqlAbortGeneration(_ctx: ActorContextHandle, _reason: string): void {
1040
- synchronousSqliteUnavailable();
1041
- }
1042
-
1043
- async actorSqlWhenDurable(
1044
- _ctx: ActorContextHandle,
1045
- _ticket: number,
1046
- ): Promise<void> {
1047
- synchronousSqliteUnavailable();
1048
- }
1049
-
1050
962
  async actorSqlClose(ctx: ActorContextHandle): Promise<void> {
1051
963
  const wasmCtx = asWasmActorContext(ctx);
1052
964
  const database = this.#sql.get(wasmCtx);
@@ -30,8 +30,10 @@ export const getRivetRunEnginePort = (): number | undefined => {
30
30
  };
31
31
  export const getRivetRunEngineVersion = (): string | undefined =>
32
32
  getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
33
- export const getRivetRunServices = (): boolean =>
34
- getEnvUniversal("RIVET_RUN_SERVICES") === "1";
33
+ export const getRivetRunServices = (): boolean | undefined => {
34
+ const value = getEnvUniversal("RIVET_RUN_SERVICES");
35
+ return value === undefined ? undefined : value === "1";
36
+ };
35
37
  export const getRivetEnvoyKind = (): string | undefined =>
36
38
  getEnvUniversal("RIVET_NODE_KIND") ?? getEnvUniversal("RIVET_ENVOY_KIND");
37
39
  export const getRivetEnvoyVersion = (): number | undefined => {