@rivetkit/rivetkit-napi 0.0.0-feat-dylib-actor-plugin.8633327 → 0.0.0-feat-workflows-public-host-apis.0ff6164

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 (3) hide show
  1. package/index.d.ts +105 -19
  2. package/index.js +5 -1
  3. package/package.json +8 -8
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>
@@ -72,6 +81,7 @@ export interface JsActorConfig {
72
81
  icon?: string
73
82
  hasDatabase?: boolean
74
83
  remoteSqlite?: boolean
84
+ enableActorRuntimeSocket?: boolean
75
85
  hasState?: boolean
76
86
  canHibernateWebsocket?: boolean
77
87
  stateSaveIntervalMs?: number
@@ -92,20 +102,13 @@ export interface JsActorConfig {
92
102
  connectionLivenessTimeoutMs?: number
93
103
  connectionLivenessIntervalMs?: number
94
104
  maxQueueSize?: number
105
+ maxSchedules?: number
95
106
  maxQueueMessageSize?: number
96
107
  maxIncomingMessageSize?: number
97
108
  maxOutgoingMessageSize?: number
98
- preloadMaxWorkflowBytes?: number
99
- preloadMaxConnectionsBytes?: number
100
109
  actions?: Array<JsActionDefinition>
101
110
  inspectorTabs?: Array<JsInspectorTabEntry>
102
111
  }
103
- /** Options for loading a native actor plugin (`cdylib`) by path. */
104
- export interface NapiNativePluginOptions {
105
- pluginPath: string
106
- configJson?: string
107
- sidecarPath?: string
108
- }
109
112
  export interface JsBindParam {
110
113
  kind: string
111
114
  intValue?: number
@@ -126,6 +129,10 @@ export interface NativeExecuteResult {
126
129
  changes: number
127
130
  lastInsertRowId?: number
128
131
  }
132
+ export interface JsSqliteBatchStatement {
133
+ sql: string
134
+ params?: Array<JsBindParam>
135
+ }
129
136
  export interface JsSqliteVfsMetrics {
130
137
  requestBuildNs: number
131
138
  serializeNs: number
@@ -213,6 +220,11 @@ export interface JsServerlessResponseHead {
213
220
  status: number
214
221
  headers: Record<string, string>
215
222
  }
223
+ export interface JsApplicationResponse {
224
+ status: number
225
+ headers: Record<string, string>
226
+ body: Buffer
227
+ }
216
228
  export interface JsRegistryRouteResponse {
217
229
  status: number
218
230
  headers: Record<string, string>
@@ -223,6 +235,38 @@ export interface JsServerlessStreamError {
223
235
  code: string
224
236
  message: string
225
237
  }
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
+ }
226
270
  /** Options for KV list operations. */
227
271
  export interface JsKvListOptions {
228
272
  reverse?: boolean
@@ -233,14 +277,19 @@ export interface JsKvEntry {
233
277
  key: Buffer
234
278
  value: Buffer
235
279
  }
280
+ export interface WorkflowStorageEntry {
281
+ key: Buffer
282
+ value: Buffer
283
+ }
236
284
  /** N-API wrapper around `rivetkit-core::ActorContext`. */
237
285
  export declare class ActorContext {
238
- constructor(actorId: string, name: string, region: string)
239
286
  state(): Buffer
240
287
  beginOnStateChange(): void
241
288
  endOnStateChange(): void
242
289
  kv(): Kv
290
+ workflowStorage(): WorkflowStorage
243
291
  sql(): JsNativeDatabase
292
+ provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
244
293
  schedule(): Schedule
245
294
  queue(): Queue
246
295
  setAlarm(timestampMs?: number | undefined | null): void
@@ -255,6 +304,7 @@ export declare class ActorContext {
255
304
  takePendingHibernationChanges(): Array<string>
256
305
  dirtyHibernatableConns(): Array<ConnHandle>
257
306
  saveState(payload: StateDeltaPayload): Promise<void>
307
+ saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
258
308
  actorId(): string
259
309
  name(): string
260
310
  key(): Array<JsActorKeySegment>
@@ -268,6 +318,7 @@ export declare class ActorContext {
268
318
  aborted(): boolean
269
319
  runHandlerActive(): boolean
270
320
  restartRunHandler(): void
321
+ setRunWakeAt(timestampMs?: number | undefined | null): Promise<void>
271
322
  beginKeepAwake(): number
272
323
  endKeepAwake(regionId: number): void
273
324
  keepAwake(promise: Promise<any>): void
@@ -288,13 +339,6 @@ export declare class ActorContext {
288
339
  }
289
340
  export declare class NapiActorFactory {
290
341
  constructor(callbacks: object, config?: JsActorConfig | undefined | null)
291
- /**
292
- * Static constructor that loads a native actor plugin (`cdylib`) by path and
293
- * adapts it through the generic `rivet-actor-plugin-abi`. RivetKit holds no
294
- * plugin-specific knowledge: `config_json` is an opaque envelope the plugin
295
- * parses itself, and `sidecar_path` is forwarded verbatim.
296
- */
297
- static fromNativePlugin(options: NapiNativePluginOptions): NapiActorFactory
298
342
  }
299
343
  export declare class CancellationToken {
300
344
  constructor()
@@ -317,8 +361,16 @@ export declare class JsNativeDatabase {
317
361
  run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
318
362
  query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
319
363
  execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
364
+ executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
320
365
  exec(sql: string): Promise<QueryResult>
321
366
  close(): Promise<void>
367
+ beginTransaction(timeoutMs?: number | undefined | null): Promise<JsSqliteTransaction>
368
+ }
369
+ export declare class JsSqliteTransaction {
370
+ execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
371
+ exec(sql: string): Promise<QueryResult>
372
+ commit(): Promise<void>
373
+ rollback(): Promise<void>
322
374
  }
323
375
  export declare class Kv {
324
376
  get(key: Buffer): Promise<Buffer | null>
@@ -337,10 +389,13 @@ export declare class Queue {
337
389
  nextBatch(options?: JsQueueNextBatchOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Array<QueueMessage>>
338
390
  waitForNames(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage>
339
391
  waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<void>
392
+ verifyPersistedIdentity(messageId: bigint, expectedName: string): Promise<string | null>
393
+ completePersisted(messageId: bigint, expectedName: string, response?: Buffer | undefined | null): Promise<boolean>
340
394
  enqueueAndWait(name: string, body: Buffer, options?: JsQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Buffer | null>
341
395
  tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
342
396
  tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
343
397
  maxSize(): number
398
+ reset(): Promise<void>
344
399
  inspectMessages(): Promise<Array<JsQueueInspectMessage>>
345
400
  }
346
401
  export declare class QueueMessage {
@@ -355,6 +410,13 @@ export declare class CoreRegistry {
355
410
  constructor()
356
411
  register(name: string, factory: NapiActorFactory): void
357
412
  serve(config: JsServeConfig): Promise<void>
413
+ /**
414
+ * Wait until the serverful envoy has completed its Engine registration.
415
+ *
416
+ * Readiness is the envoy client's `ToEnvoyInit` signal, not HTTP health or
417
+ * merely constructing the envoy handle.
418
+ */
419
+ waitReady(): Promise<void>
358
420
  /**
359
421
  * Trip the shutdown token and tear down any live serverless runtime.
360
422
  *
@@ -367,15 +429,39 @@ export declare class CoreRegistry {
367
429
  health(): Promise<JsRegistryRouteResponse>
368
430
  metadata(): JsRegistryRouteResponse
369
431
  metrics(): JsRegistryRouteResponse
370
- serveListener(listener: JsListenerConfig, config: JsServeConfig): Promise<void>
432
+ serveApplicationListener(listener: JsListenerConfig, application: (...args: any[]) => any, config: JsServeConfig): Promise<void>
433
+ serveListener(listener: JsListenerConfig, config: JsServeConfig, application?: (...args: any[]) => any | undefined | null): Promise<void>
371
434
  handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
372
435
  }
373
436
  export declare class Schedule {
374
- after(durationMs: number, actionName: string, args: Buffer): void
375
- at(timestampMs: number, actionName: string, args: Buffer): void
437
+ after(durationMs: number, actionName: string, args: Buffer): Promise<string>
438
+ at(timestampMs: number, actionName: string, args: Buffer): Promise<string>
439
+ cancel(id: string): Promise<boolean>
440
+ get(id: string): Promise<JsScheduledEventInfo | null>
441
+ list(): Promise<Array<JsScheduledEventInfo>>
442
+ cronSet(name: string, expression: string, timezone: string | undefined | null, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
443
+ cronEvery(name: string, intervalMs: number, actionName: string, args: Buffer, maxHistory?: number | undefined | null): Promise<void>
444
+ cronGet(name: string): Promise<JsCronJobInfo | null>
445
+ cronList(): Promise<Array<JsCronJobInfo>>
446
+ cronDelete(name: string): Promise<boolean>
447
+ cronHistory(name: string, limit?: number | undefined | null): Promise<Array<JsCronFire>>
376
448
  }
377
449
  export declare class WebSocket {
378
450
  send(data: Buffer, binary: boolean): void
379
451
  close(code?: number | undefined | null, reason?: string | undefined | null): Promise<void>
380
452
  setEventCallback(callback: (...args: any[]) => any): void
381
453
  }
454
+ /**
455
+ * N-API binding for RivetKit's closed workflow-storage capability. It exposes
456
+ * byte operations only; physical table and namespace details stay in core.
457
+ */
458
+ export declare class WorkflowStorage {
459
+ get(key: Buffer): Promise<Buffer | null>
460
+ set(key: Buffer, value: Buffer): Promise<void>
461
+ delete(key: Buffer): Promise<void>
462
+ deletePrefix(prefix: Buffer): Promise<void>
463
+ deleteRange(start: Buffer, end: Buffer): Promise<void>
464
+ list(prefix: Buffer): Promise<Array<WorkflowStorageEntry>>
465
+ batch(entries: Array<WorkflowStorageEntry>): Promise<void>
466
+ flushWithState(writes: Array<WorkflowKvWritePayload>): Promise<void>
467
+ }
package/index.js CHANGED
@@ -310,16 +310,20 @@ 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, Schedule, WebSocket } = nativeBinding
313
+ const { ActorContext, decodeInspectorRequest, encodeInspectorResponse, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, JsSqliteTransaction, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket, WorkflowStorage } = 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
327
  module.exports.Schedule = Schedule
325
328
  module.exports.WebSocket = WebSocket
329
+ module.exports.WorkflowStorage = WorkflowStorage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/rivetkit-napi",
3
- "version": "0.0.0-feat-dylib-actor-plugin.8633327",
3
+ "version": "0.0.0-feat-workflows-public-host-apis.0ff6164",
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",
@@ -44,14 +44,14 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@napi-rs/cli": "^2.18.4",
47
- "@rivetkit/engine-envoy-protocol": "0.0.0-feat-dylib-actor-plugin.8633327"
47
+ "@rivetkit/engine-envoy-protocol": "0.0.0-feat-workflows-public-host-apis.0ff6164"
48
48
  },
49
49
  "optionalDependencies": {
50
- "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-feat-dylib-actor-plugin.8633327",
51
- "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-feat-dylib-actor-plugin.8633327",
52
- "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-feat-dylib-actor-plugin.8633327",
53
- "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-feat-dylib-actor-plugin.8633327",
54
- "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-feat-dylib-actor-plugin.8633327",
55
- "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-feat-dylib-actor-plugin.8633327"
50
+ "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-feat-workflows-public-host-apis.0ff6164",
51
+ "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-feat-workflows-public-host-apis.0ff6164",
52
+ "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-feat-workflows-public-host-apis.0ff6164",
53
+ "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-feat-workflows-public-host-apis.0ff6164",
54
+ "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-feat-workflows-public-host-apis.0ff6164",
55
+ "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-feat-workflows-public-host-apis.0ff6164"
56
56
  }
57
57
  }