@rivetkit/rivetkit-napi 0.0.0-feat-workflows-public-host-apis.1550fe4 → 0.0.0-feat-sqlite-sync.18dce02

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 +137 -8
  2. package/index.js +8 -1
  3. package/package.json +9 -9
package/index.d.ts CHANGED
@@ -8,6 +8,18 @@ export interface JsActorKeySegment {
8
8
  stringValue?: string
9
9
  numberValue?: number
10
10
  }
11
+ /** Active actor invocation correlation exposed to the TypeScript runtime adapter. */
12
+ export interface JsActorInvocationTraceContext {
13
+ rayId?: string
14
+ span?: JsActorInvocationSpanContext
15
+ }
16
+ /** W3C span context of the current invocation span, present only when tracing is active. */
17
+ export interface JsActorInvocationSpanContext {
18
+ traceId: string
19
+ spanId: string
20
+ traceFlags: number
21
+ tracestate?: string
22
+ }
11
23
  export interface JsHttpRequest {
12
24
  method: string
13
25
  uri: string
@@ -44,11 +56,6 @@ export interface JsInspectorSnapshot {
44
56
  export interface JsActorRuntimeSocketEndpointInfo {
45
57
  path: string
46
58
  }
47
- export interface JsHttpResponse {
48
- status?: number
49
- headers?: Record<string, string>
50
- body?: Buffer
51
- }
52
59
  export interface JsQueueSendResult {
53
60
  status: string
54
61
  response?: Buffer
@@ -76,11 +83,38 @@ export interface JsInspectorTabEntry {
76
83
  /** Set to true for HideBuiltin entries. */
77
84
  hidden?: boolean
78
85
  }
86
+ /**
87
+ * Experimental SQLite profiling configuration. This entire configuration
88
+ * surface is subject to change without notice.
89
+ */
90
+ export interface JsSqliteProfilingConfig {
91
+ enabled?: boolean
92
+ maxTrackedStatementFingerprints?: number
93
+ maxTrackedTransactionFingerprints?: number
94
+ maxPrometheusSeries?: number
95
+ maxStatementsPerTransactionTrace?: number
96
+ maxGetPagesRequestsPerTrace?: number
97
+ maxTransactionNameBytes?: number
98
+ slowOperationThresholdMs?: number
99
+ baselineSampleRate?: number
100
+ maxDiagnosticEventsPerMinute?: number
101
+ diagnosticEventQueueCapacity?: number
102
+ }
103
+ /** Per-actor trace sample rates, from 0 to 1. */
104
+ export interface JsActorTracingConfig {
105
+ sampler?: number
106
+ /** Keyed by flattened, dot-separated action name. */
107
+ actions?: Record<string, number>
108
+ }
79
109
  export interface JsActorConfig {
80
110
  name?: string
81
111
  icon?: string
82
112
  hasDatabase?: boolean
83
113
  remoteSqlite?: boolean
114
+ /** Internal. Set by rivetkit when the actor's database provider opts into deferred commits. */
115
+ sqliteDeferredCommits?: boolean
116
+ sqliteProfiling?: JsSqliteProfilingConfig
117
+ tracing?: JsActorTracingConfig
84
118
  enableActorRuntimeSocket?: boolean
85
119
  hasState?: boolean
86
120
  canHibernateWebsocket?: boolean
@@ -146,6 +180,12 @@ export interface JsSqliteVfsMetrics {
146
180
  writeBufferDirtyPages: number
147
181
  dbSizePages: number
148
182
  }
183
+ export interface JsHttpResponse {
184
+ status?: number
185
+ headers?: Record<string, string>
186
+ body?: Buffer
187
+ stream?: boolean
188
+ }
149
189
  export interface JsQueueNextOptions {
150
190
  names?: Array<string>
151
191
  timeoutMs?: number
@@ -189,6 +229,8 @@ export interface JsServeConfig {
189
229
  namespace: string
190
230
  poolName: string
191
231
  engineBinaryPath?: string
232
+ startServices?: boolean
233
+ servicesBinaryPath?: string
192
234
  engineHost?: string
193
235
  enginePort?: number
194
236
  handleInspectorHttpInRuntime?: boolean
@@ -223,7 +265,8 @@ export interface JsServerlessResponseHead {
223
265
  export interface JsApplicationResponse {
224
266
  status: number
225
267
  headers: Record<string, string>
226
- body: Buffer
268
+ body?: Buffer
269
+ stream?: boolean
227
270
  }
228
271
  export interface JsRegistryRouteResponse {
229
272
  status: number
@@ -277,6 +320,13 @@ export interface JsKvEntry {
277
320
  key: Buffer
278
321
  value: Buffer
279
322
  }
323
+ /**
324
+ * Routes the OpenTelemetry SDK's own warnings, such as dropped spans, to the
325
+ * JavaScript logger. Each call replaces the previous sink. The sink is
326
+ * released by `shutdownTelemetry`.
327
+ */
328
+ export declare function setTelemetryLogSink(callback: (...args: any[]) => any): void
329
+ export declare function shutdownTelemetry(): Promise<void>
280
330
  /** N-API wrapper around `rivetkit-core::ActorContext`. */
281
331
  export declare class ActorContext {
282
332
  state(): Buffer
@@ -284,6 +334,22 @@ export declare class ActorContext {
284
334
  endOnStateChange(): void
285
335
  kv(): Kv
286
336
  sql(): JsNativeDatabase
337
+ sameActorInstance(other: ActorContext): boolean
338
+ /**
339
+ * Returns a handle for the same invocation whose Core spans parent to the
340
+ * application span active in JavaScript, given as W3C headers.
341
+ */
342
+ withApplicationSpan(traceparent?: string | undefined | null, tracestate?: string | undefined | null): ActorContext
343
+ invocationTraceContext(): JsActorInvocationTraceContext | null
344
+ /**
345
+ * Opens the span covering one call out to another actor. Returns nothing
346
+ * when this handle serves no invocation or tracing is disabled, in which
347
+ * case the caller sends its own context as before.
348
+ */
349
+ startCallSpan(actorName: string, actionName: string): OutboundCall | null
350
+ startWorkflowSpan(): Promise<WorkflowSpan>
351
+ /** Returns nothing outside a workflow run or when tracing is off. */
352
+ startWorkflowStepSpan(stepName: string, attempt: number): WorkflowStepSpan | null
287
353
  provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
288
354
  schedule(): Schedule
289
355
  queue(): Queue
@@ -333,6 +399,42 @@ export declare class ActorContext {
333
399
  runtimeState(): object
334
400
  clearRuntimeState(): void
335
401
  }
402
+ /**
403
+ * One open call out to another actor.
404
+ *
405
+ * The call spans a request made by the host runtime, so it is opened and closed
406
+ * by two separate calls. Letting this be collected without finishing records
407
+ * the call as cancelled rather than silently losing it.
408
+ */
409
+ export declare class OutboundCall {
410
+ /**
411
+ * W3C context of this call's span, to send to the callee so it parents to
412
+ * the call rather than to the invocation that made it.
413
+ */
414
+ spanContext(): JsActorInvocationSpanContext | null
415
+ /**
416
+ * Records the call's outcome. `error` is the failure as the bridge encodes
417
+ * it, so a structured error keeps its group and code while anything else
418
+ * stays unstructured for Core to classify.
419
+ */
420
+ finish(error?: string | undefined | null): void
421
+ }
422
+ /**
423
+ * One open workflow run. Collecting it without `finish` records the run as
424
+ * abandoned.
425
+ */
426
+ export declare class WorkflowSpan {
427
+ /** The context workflow code runs under. */
428
+ ctx(): ActorContext
429
+ finish(outcome: string): Promise<void>
430
+ }
431
+ /** One open attempt at one workflow step. */
432
+ export declare class WorkflowStepSpan {
433
+ /** The context the step's callback runs under. */
434
+ ctx(): ActorContext
435
+ /** `error` is what the step threw, as the bridge encodes it. */
436
+ finish(outcome: string, error?: string | undefined | null): void
437
+ }
336
438
  export declare class NapiActorFactory {
337
439
  constructor(callbacks: object, config?: JsActorConfig | undefined | null)
338
440
  }
@@ -360,20 +462,47 @@ export declare class JsNativeDatabase {
360
462
  executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
361
463
  exec(sql: string): Promise<QueryResult>
362
464
  close(): Promise<void>
363
- beginTransaction(timeoutMs?: number | undefined | null): Promise<JsSqliteTransaction>
465
+ /** Opens the database so later synchronous calls never fetch its first pages. */
466
+ open(): Promise<void>
467
+ executeSync(sql: string, params?: Array<JsBindParam> | undefined | null): NativeExecuteResult
468
+ execSync(sql: string): QueryResult
469
+ beginTransactionSync(timeoutMs?: number | undefined | null, name?: string | undefined | null): JsSqliteTransaction
470
+ /**
471
+ * Returns the latest local commit as a ticket. Tickets stay below 2^53 for any
472
+ * realistic generation, so they cross to JavaScript as numbers.
473
+ */
474
+ commitTicket(): number
475
+ abortGeneration(reason: string): void
476
+ whenDurable(ticket: number): Promise<void>
477
+ beginTransaction(timeoutMs?: number | undefined | null, name?: string | undefined | null): Promise<JsSqliteTransaction>
364
478
  }
365
479
  export declare class JsSqliteTransaction {
366
480
  execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
367
481
  exec(sql: string): Promise<QueryResult>
368
482
  commit(): Promise<void>
369
483
  rollback(): Promise<void>
484
+ executeSync(sql: string, params?: Array<JsBindParam> | undefined | null): NativeExecuteResult
485
+ execSync(sql: string): QueryResult
486
+ commitSync(): void
487
+ rollbackSync(): void
370
488
  }
371
489
  export declare class JsActorStateTransaction {
372
490
  execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
373
- exec(sql: string): Promise<QueryResult>
374
491
  commit(payload: StateDeltaPayload): Promise<void>
375
492
  rollback(): Promise<void>
376
493
  }
494
+ /** JavaScript-facing writer for a streaming actor HTTP response. */
495
+ export declare class HttpResponseBodyStream {
496
+ cancelled(): Promise<void>
497
+ write(chunk: Buffer): Promise<void>
498
+ end(): Promise<void>
499
+ error(message: string): Promise<void>
500
+ }
501
+ /** JavaScript-facing reader for a streaming actor HTTP request. */
502
+ export declare class HttpRequestBodyStream {
503
+ read(): Promise<Buffer | null>
504
+ cancel(): Promise<void>
505
+ }
377
506
  export declare class Kv {
378
507
  get(key: Buffer): Promise<Buffer | null>
379
508
  put(key: Buffer, value: Buffer): Promise<void>
package/index.js CHANGED
@@ -310,20 +310,27 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { ActorContext, decodeInspectorRequest, encodeInspectorResponse, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, JsSqliteTransaction, JsActorStateTransaction, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket } = nativeBinding
313
+ const { ActorContext, decodeInspectorRequest, encodeInspectorResponse, OutboundCall, WorkflowSpan, WorkflowStepSpan, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, JsSqliteTransaction, JsActorStateTransaction, HttpResponseBodyStream, HttpRequestBodyStream, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket, setTelemetryLogSink, shutdownTelemetry } = nativeBinding
314
314
 
315
315
  module.exports.ActorContext = ActorContext
316
316
  module.exports.decodeInspectorRequest = decodeInspectorRequest
317
317
  module.exports.encodeInspectorResponse = encodeInspectorResponse
318
+ module.exports.OutboundCall = OutboundCall
319
+ module.exports.WorkflowSpan = WorkflowSpan
320
+ module.exports.WorkflowStepSpan = WorkflowStepSpan
318
321
  module.exports.NapiActorFactory = NapiActorFactory
319
322
  module.exports.CancellationToken = CancellationToken
320
323
  module.exports.ConnHandle = ConnHandle
321
324
  module.exports.JsNativeDatabase = JsNativeDatabase
322
325
  module.exports.JsSqliteTransaction = JsSqliteTransaction
323
326
  module.exports.JsActorStateTransaction = JsActorStateTransaction
327
+ module.exports.HttpResponseBodyStream = HttpResponseBodyStream
328
+ module.exports.HttpRequestBodyStream = HttpRequestBodyStream
324
329
  module.exports.Kv = Kv
325
330
  module.exports.Queue = Queue
326
331
  module.exports.QueueMessage = QueueMessage
327
332
  module.exports.CoreRegistry = CoreRegistry
328
333
  module.exports.Schedule = Schedule
329
334
  module.exports.WebSocket = WebSocket
335
+ module.exports.setTelemetryLogSink = setTelemetryLogSink
336
+ module.exports.shutdownTelemetry = shutdownTelemetry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/rivetkit-napi",
3
- "version": "0.0.0-feat-workflows-public-host-apis.1550fe4",
3
+ "version": "0.0.0-feat-sqlite-sync.18dce02",
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,19 +44,19 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@napi-rs/cli": "^2.18.4",
47
- "@rivetkit/engine-envoy-protocol": "0.0.0-feat-workflows-public-host-apis.1550fe4"
47
+ "@rivetkit/engine-envoy-protocol": "0.0.0-feat-sqlite-sync.18dce02"
48
48
  },
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "https://github.com/rivet-dev/actors.git",
51
+ "url": "https://github.com/rivet-dev/rivet.git",
52
52
  "directory": "rivetkit-typescript/packages/rivetkit-napi"
53
53
  },
54
54
  "optionalDependencies": {
55
- "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-feat-workflows-public-host-apis.1550fe4",
56
- "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-feat-workflows-public-host-apis.1550fe4",
57
- "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-feat-workflows-public-host-apis.1550fe4",
58
- "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-feat-workflows-public-host-apis.1550fe4",
59
- "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-feat-workflows-public-host-apis.1550fe4",
60
- "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-feat-workflows-public-host-apis.1550fe4"
55
+ "@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-feat-sqlite-sync.18dce02",
56
+ "@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-feat-sqlite-sync.18dce02",
57
+ "@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-feat-sqlite-sync.18dce02",
58
+ "@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-feat-sqlite-sync.18dce02",
59
+ "@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-feat-sqlite-sync.18dce02",
60
+ "@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-feat-sqlite-sync.18dce02"
61
61
  }
62
62
  }