@rivetkit/rivetkit-napi 0.0.0-2-3-0-rc-rollback.f0e199e → 0.0.0-ci-publish-node-24.62afe63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -23,10 +23,16 @@ export interface StateDeltaPayload {
23
23
  connHibernation: Array<StateDeltaConnHibernationEntry>
24
24
  connHibernationRemoved: Array<string>
25
25
  }
26
+ export interface WorkflowKvWritePayload {
27
+ key: Buffer
28
+ value: Buffer
29
+ }
26
30
  export interface JsRequestSaveOpts {
27
31
  immediate?: boolean
28
32
  maxWaitMs?: number
29
33
  }
34
+ export declare function decodeInspectorRequest(bytes: Buffer, advertisedVersion: number): Buffer
35
+ export declare function encodeInspectorResponse(bytes: Buffer, targetVersion: number): Buffer
30
36
  export interface JsInspectorSnapshot {
31
37
  stateRevision: number
32
38
  connectionsRevision: number
@@ -35,6 +41,9 @@ export interface JsInspectorSnapshot {
35
41
  queueSize: number
36
42
  connectedClients: number
37
43
  }
44
+ export interface JsActorRuntimeSocketEndpointInfo {
45
+ path: string
46
+ }
38
47
  export interface JsHttpResponse {
39
48
  status?: number
40
49
  headers?: Record<string, string>
@@ -47,11 +56,32 @@ export interface JsQueueSendResult {
47
56
  export interface JsActionDefinition {
48
57
  name: string
49
58
  }
59
+ /**
60
+ * One entry in the actor's `inspector.tabs[]` declaration. Either a
61
+ * custom-tab descriptor (id + label + source dir) or a built-in modifier
62
+ * (id + hidden=true). Validation already happened on the TS side; the
63
+ * runtime just splits the discriminator.
64
+ */
65
+ export interface JsInspectorTabEntry {
66
+ id: string
67
+ /** Required for custom entries; omitted for HideBuiltin. */
68
+ label?: string
69
+ /** Required for custom entries — absolute path to the source directory. */
70
+ source?: string
71
+ /**
72
+ * Optional icon id for custom entries. Dashboard maps strings to
73
+ * glyphs; unknown ids fall back to a generic icon.
74
+ */
75
+ icon?: string
76
+ /** Set to true for HideBuiltin entries. */
77
+ hidden?: boolean
78
+ }
50
79
  export interface JsActorConfig {
51
80
  name?: string
52
81
  icon?: string
53
82
  hasDatabase?: boolean
54
83
  remoteSqlite?: boolean
84
+ enableActorRuntimeSocket?: boolean
55
85
  hasState?: boolean
56
86
  canHibernateWebsocket?: boolean
57
87
  stateSaveIntervalMs?: number
@@ -72,12 +102,12 @@ export interface JsActorConfig {
72
102
  connectionLivenessTimeoutMs?: number
73
103
  connectionLivenessIntervalMs?: number
74
104
  maxQueueSize?: number
105
+ maxSchedules?: number
75
106
  maxQueueMessageSize?: number
76
107
  maxIncomingMessageSize?: number
77
108
  maxOutgoingMessageSize?: number
78
- preloadMaxWorkflowBytes?: number
79
- preloadMaxConnectionsBytes?: number
80
109
  actions?: Array<JsActionDefinition>
110
+ inspectorTabs?: Array<JsInspectorTabEntry>
81
111
  }
82
112
  export interface JsBindParam {
83
113
  kind: string
@@ -99,6 +129,10 @@ export interface NativeExecuteResult {
99
129
  changes: number
100
130
  lastInsertRowId?: number
101
131
  }
132
+ export interface JsSqliteBatchStatement {
133
+ sql: string
134
+ params?: Array<JsBindParam>
135
+ }
102
136
  export interface JsSqliteVfsMetrics {
103
137
  requestBuildNs: number
104
138
  serializeNs: number
@@ -155,6 +189,8 @@ export interface JsServeConfig {
155
189
  namespace: string
156
190
  poolName: string
157
191
  engineBinaryPath?: string
192
+ engineHost?: string
193
+ enginePort?: number
158
194
  handleInspectorHttpInRuntime?: boolean
159
195
  serverlessBasePath?: string
160
196
  serverlessPackageVersion: string
@@ -164,6 +200,16 @@ export interface JsServeConfig {
164
200
  serverlessValidateEndpoint: boolean
165
201
  serverlessMaxStartPayloadBytes: number
166
202
  }
203
+ export interface JsListenerConfig {
204
+ /** Host to bind. Defaults to `0.0.0.0` when not provided. */
205
+ host?: string
206
+ port: number
207
+ /**
208
+ * Optional static file root mounted as a fallback below the framework
209
+ * routes.
210
+ */
211
+ publicDir?: string
212
+ }
167
213
  export interface JsServerlessRequest {
168
214
  method: string
169
215
  url: string
@@ -174,24 +220,53 @@ export interface JsServerlessResponseHead {
174
220
  status: number
175
221
  headers: Record<string, string>
176
222
  }
177
- export interface JsRegistryDiagnostics {
178
- mode: string
179
- envoyActiveActorCount?: number
223
+ export interface JsApplicationResponse {
224
+ status: number
225
+ headers: Record<string, string>
226
+ body: Buffer
227
+ }
228
+ export interface JsRegistryRouteResponse {
229
+ status: number
230
+ headers: Record<string, string>
231
+ body: Buffer
180
232
  }
181
233
  export interface JsServerlessStreamError {
182
234
  group: string
183
235
  code: string
184
236
  message: string
185
237
  }
186
- export declare function jsSetEventloopLagQuantile(quantile: string, seconds: number): void
187
- export declare function jsSetEventloopUtilization(value: number): void
188
- export declare function jsSetEventloopHeartbeatTsMs(epochMs: number): void
189
- export declare function jsAddProcessCpuSeconds(mode: string, seconds: number): void
190
- export declare function jsSetProcessResidentMemoryBytes(bytes: number): void
191
- export declare function jsSetHeapBytes(state: string, bytes: number): void
192
- export declare function jsObserveGcDuration(kind: string, seconds: number): void
193
- export declare function jsSetActiveHandles(count: number): void
194
- export declare function jsSetActiveRequests(count: number): void
238
+ export interface JsScheduledEventInfo {
239
+ id: string
240
+ action: string
241
+ args: Buffer
242
+ runAt: number
243
+ }
244
+ export interface JsCronJobInfo {
245
+ name: string
246
+ kind: string
247
+ action: string
248
+ args: Buffer
249
+ nextRunAt: number
250
+ lastRunAt?: number
251
+ expression?: string
252
+ timezone?: string
253
+ intervalMs?: number
254
+ maxHistory: number
255
+ }
256
+ export interface JsScheduleErrorInfo {
257
+ group: string
258
+ code: string
259
+ message: string
260
+ metadata?: any
261
+ }
262
+ export interface JsCronFire {
263
+ action: string
264
+ scheduledAt: number
265
+ firedAt: number
266
+ finishedAt?: number
267
+ result: string
268
+ error?: JsScheduleErrorInfo
269
+ }
195
270
  /** Options for KV list operations. */
196
271
  export interface JsKvListOptions {
197
272
  reverse?: boolean
@@ -204,12 +279,12 @@ export interface JsKvEntry {
204
279
  }
205
280
  /** N-API wrapper around `rivetkit-core::ActorContext`. */
206
281
  export declare class ActorContext {
207
- constructor(actorId: string, name: string, region: string)
208
282
  state(): Buffer
209
283
  beginOnStateChange(): void
210
284
  endOnStateChange(): void
211
285
  kv(): Kv
212
286
  sql(): JsNativeDatabase
287
+ provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
213
288
  schedule(): Schedule
214
289
  queue(): Queue
215
290
  setAlarm(timestampMs?: number | undefined | null): void
@@ -224,6 +299,7 @@ export declare class ActorContext {
224
299
  takePendingHibernationChanges(): Array<string>
225
300
  dirtyHibernatableConns(): Array<ConnHandle>
226
301
  saveState(payload: StateDeltaPayload): Promise<void>
302
+ saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
227
303
  actorId(): string
228
304
  name(): string
229
305
  key(): Array<JsActorKeySegment>
@@ -250,6 +326,7 @@ export declare class ActorContext {
250
326
  broadcast(name: string, args: Buffer): void
251
327
  waitUntil(promise: Promise<any>): void
252
328
  waitForTrackedShutdownWork(): Promise<boolean>
329
+ waitForTrackedShutdownWorkUnbounded(): Promise<void>
253
330
  registerTask(promise: Promise<any>): void
254
331
  runtimeState(): object
255
332
  clearRuntimeState(): void
@@ -278,8 +355,16 @@ export declare class JsNativeDatabase {
278
355
  run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
279
356
  query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
280
357
  execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
358
+ executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
281
359
  exec(sql: string): Promise<QueryResult>
282
360
  close(): Promise<void>
361
+ beginTransaction(timeoutMs?: number | undefined | null): Promise<JsSqliteTransaction>
362
+ }
363
+ export declare class JsSqliteTransaction {
364
+ execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
365
+ exec(sql: string): Promise<QueryResult>
366
+ commit(): Promise<void>
367
+ rollback(): Promise<void>
283
368
  }
284
369
  export declare class Kv {
285
370
  get(key: Buffer): Promise<Buffer | null>
@@ -297,11 +382,12 @@ export declare class Queue {
297
382
  next(options?: JsQueueNextOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage | null>
298
383
  nextBatch(options?: JsQueueNextBatchOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Array<QueueMessage>>
299
384
  waitForNames(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage>
300
- waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null): Promise<void>
385
+ waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<void>
301
386
  enqueueAndWait(name: string, body: Buffer, options?: JsQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Buffer | null>
302
387
  tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
303
388
  tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
304
389
  maxSize(): number
390
+ reset(): Promise<void>
305
391
  inspectMessages(): Promise<Array<JsQueueInspectMessage>>
306
392
  }
307
393
  export declare class QueueMessage {
@@ -316,6 +402,13 @@ export declare class CoreRegistry {
316
402
  constructor()
317
403
  register(name: string, factory: NapiActorFactory): void
318
404
  serve(config: JsServeConfig): Promise<void>
405
+ /**
406
+ * Wait until the serverful envoy has completed its Engine registration.
407
+ *
408
+ * Readiness is the envoy client's `ToEnvoyInit` signal, not HTTP health or
409
+ * merely constructing the envoy handle.
410
+ */
411
+ waitReady(): Promise<void>
319
412
  /**
320
413
  * Trip the shutdown token and tear down any live serverless runtime.
321
414
  *
@@ -325,12 +418,25 @@ export declare class CoreRegistry {
325
418
  */
326
419
  shutdown(): Promise<void>
327
420
  actorStopThresholdMs(): Promise<number | null>
328
- diagnostics(): Promise<JsRegistryDiagnostics>
421
+ health(): Promise<JsRegistryRouteResponse>
422
+ metadata(): JsRegistryRouteResponse
423
+ metrics(): JsRegistryRouteResponse
424
+ serveApplicationListener(listener: JsListenerConfig, application: (...args: any[]) => any, config: JsServeConfig): Promise<void>
425
+ serveListener(listener: JsListenerConfig, config: JsServeConfig, application?: (...args: any[]) => any | undefined | null): Promise<void>
329
426
  handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
330
427
  }
331
428
  export declare class Schedule {
332
- after(durationMs: number, actionName: string, args: Buffer): void
333
- at(timestampMs: number, actionName: string, args: Buffer): void
429
+ after(durationMs: number, actionName: string, args: Buffer): Promise<string>
430
+ at(timestampMs: number, actionName: string, args: Buffer): Promise<string>
431
+ cancel(id: string): Promise<boolean>
432
+ get(id: string): Promise<JsScheduledEventInfo | null>
433
+ list(): Promise<Array<JsScheduledEventInfo>>
434
+ cronSet(name: string, expression: string, timezone: string | undefined | null, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
435
+ cronEvery(name: string, intervalMs: number, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
436
+ cronGet(name: string): Promise<JsCronJobInfo | null>
437
+ cronList(): Promise<Array<JsCronJobInfo>>
438
+ cronDelete(name: string): Promise<boolean>
439
+ cronHistory(name: string, limit?: number | undefined | null): Promise<Array<JsCronFire>>
334
440
  }
335
441
  export declare class WebSocket {
336
442
  send(data: Buffer, binary: boolean): void
package/index.js CHANGED
@@ -310,25 +310,19 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { ActorContext, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, Kv, Queue, QueueMessage, CoreRegistry, jsSetEventloopLagQuantile, jsSetEventloopUtilization, jsSetEventloopHeartbeatTsMs, jsAddProcessCpuSeconds, jsSetProcessResidentMemoryBytes, jsSetHeapBytes, jsObserveGcDuration, jsSetActiveHandles, jsSetActiveRequests, Schedule, WebSocket } = nativeBinding
313
+ const { ActorContext, decodeInspectorRequest, encodeInspectorResponse, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, JsSqliteTransaction, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket } = nativeBinding
314
314
 
315
315
  module.exports.ActorContext = ActorContext
316
+ module.exports.decodeInspectorRequest = decodeInspectorRequest
317
+ module.exports.encodeInspectorResponse = encodeInspectorResponse
316
318
  module.exports.NapiActorFactory = NapiActorFactory
317
319
  module.exports.CancellationToken = CancellationToken
318
320
  module.exports.ConnHandle = ConnHandle
319
321
  module.exports.JsNativeDatabase = JsNativeDatabase
322
+ module.exports.JsSqliteTransaction = JsSqliteTransaction
320
323
  module.exports.Kv = Kv
321
324
  module.exports.Queue = Queue
322
325
  module.exports.QueueMessage = QueueMessage
323
326
  module.exports.CoreRegistry = CoreRegistry
324
- module.exports.jsSetEventloopLagQuantile = jsSetEventloopLagQuantile
325
- module.exports.jsSetEventloopUtilization = jsSetEventloopUtilization
326
- module.exports.jsSetEventloopHeartbeatTsMs = jsSetEventloopHeartbeatTsMs
327
- module.exports.jsAddProcessCpuSeconds = jsAddProcessCpuSeconds
328
- module.exports.jsSetProcessResidentMemoryBytes = jsSetProcessResidentMemoryBytes
329
- module.exports.jsSetHeapBytes = jsSetHeapBytes
330
- module.exports.jsObserveGcDuration = jsObserveGcDuration
331
- module.exports.jsSetActiveHandles = jsSetActiveHandles
332
- module.exports.jsSetActiveRequests = jsSetActiveRequests
333
327
  module.exports.Schedule = Schedule
334
328
  module.exports.WebSocket = WebSocket
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/rivetkit-napi",
3
- "version": "0.0.0-2-3-0-rc-rollback.f0e199e",
3
+ "version": "0.0.0-ci-publish-node-24.62afe63",
4
4
  "description": "Native N-API addon for RivetKit providing envoy client and SQLite access",
5
5
  "license": "Apache-2.0",
6
6
  "main": "index.js",
@@ -39,19 +39,24 @@
39
39
  "build": "node scripts/build.mjs",
40
40
  "build:release": "node scripts/build.mjs --release",
41
41
  "build:force": "node scripts/build.mjs --force",
42
- "build:force:release": "node scripts/build.mjs --force --release"
42
+ "build:force:release": "node scripts/build.mjs --force --release",
43
+ "build:embed": "node scripts/build.mjs"
43
44
  },
44
45
  "dependencies": {
45
46
  "@napi-rs/cli": "^2.18.4",
46
- "@rivetkit/engine-envoy-protocol": "0.0.0-2-3-0-rc-rollback.f0e199e"
47
+ "@rivetkit/engine-envoy-protocol": "0.0.0-ci-publish-node-24.62afe63"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/rivet-dev/actors.git",
52
+ "directory": "rivetkit-typescript/packages/rivetkit-napi"
47
53
  },
48
54
  "optionalDependencies": {
49
- "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-2-3-0-rc-rollback.f0e199e",
50
- "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-2-3-0-rc-rollback.f0e199e",
51
- "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-2-3-0-rc-rollback.f0e199e",
52
- "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-2-3-0-rc-rollback.f0e199e",
53
- "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-2-3-0-rc-rollback.f0e199e",
54
- "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-2-3-0-rc-rollback.f0e199e",
55
- "@rivetkit/rivetkit-napi-win32-x64-msvc": "0.0.0-2-3-0-rc-rollback.f0e199e"
55
+ "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-ci-publish-node-24.62afe63",
56
+ "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-ci-publish-node-24.62afe63",
57
+ "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-ci-publish-node-24.62afe63",
58
+ "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-ci-publish-node-24.62afe63",
59
+ "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-ci-publish-node-24.62afe63",
60
+ "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-ci-publish-node-24.62afe63"
56
61
  }
57
62
  }
package/scripts/build.mjs CHANGED
@@ -16,6 +16,14 @@ if (process.env.SKIP_NAPI_BUILD === "1") {
16
16
  process.exit(0);
17
17
  }
18
18
 
19
+ // The per-actor inspector UI (frontend/dist/inspector-ui, embedded into
20
+ // rivetkit-core by its build.rs) must be built before this napi build runs.
21
+ // It is NOT built here: rivetkit-core's embed needs rivetkit/inspector-tab,
22
+ // which is downstream of this package in the build graph, so building it from
23
+ // the napi build would invert the dependency order. CI builds it via
24
+ // `turbo build:inspector-ui` in docker/build/*.Dockerfile before `napi build`;
25
+ // for local builds run `pnpm -F @rivetkit/engine-frontend build:inspector-ui`
26
+ // (or `turbo build:inspector-ui`) first.
19
27
  const cmd = ["build", "--platform", ...extraFlags];
20
28
  console.log(`[rivetkit-napi/build] running: napi ${cmd.join(" ")}`);
21
29
  execFileSync("napi", cmd, { stdio: "inherit" });