@rivetkit/rivetkit-napi 2.3.18 → 2.3.19

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 +71 -0
  2. package/index.js +6 -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
@@ -299,6 +311,13 @@ export interface JsKvEntry {
299
311
  key: Buffer
300
312
  value: Buffer
301
313
  }
314
+ /**
315
+ * Routes the OpenTelemetry SDK's own warnings, such as dropped spans, to the
316
+ * JavaScript logger. Each call replaces the previous sink. The sink is
317
+ * released by `shutdownTelemetry`.
318
+ */
319
+ export declare function setTelemetryLogSink(callback: (...args: any[]) => any): void
320
+ export declare function shutdownTelemetry(): Promise<void>
302
321
  /** N-API wrapper around `rivetkit-core::ActorContext`. */
303
322
  export declare class ActorContext {
304
323
  state(): Buffer
@@ -306,6 +325,22 @@ export declare class ActorContext {
306
325
  endOnStateChange(): void
307
326
  kv(): Kv
308
327
  sql(): JsNativeDatabase
328
+ sameActorInstance(other: ActorContext): boolean
329
+ /**
330
+ * Returns a handle for the same invocation whose Core spans parent to the
331
+ * application span active in JavaScript, given as W3C headers.
332
+ */
333
+ withApplicationSpan(traceparent?: string | undefined | null, tracestate?: string | undefined | null): ActorContext
334
+ invocationTraceContext(): JsActorInvocationTraceContext | null
335
+ /**
336
+ * Opens the span covering one call out to another actor. Returns nothing
337
+ * when this handle serves no invocation or tracing is disabled, in which
338
+ * case the caller sends its own context as before.
339
+ */
340
+ startCallSpan(actorName: string, actionName: string): OutboundCall | null
341
+ startWorkflowSpan(): Promise<WorkflowSpan>
342
+ /** Returns nothing outside a workflow run or when tracing is off. */
343
+ startWorkflowStepSpan(stepName: string, attempt: number): WorkflowStepSpan | null
309
344
  provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
310
345
  schedule(): Schedule
311
346
  queue(): Queue
@@ -355,6 +390,42 @@ export declare class ActorContext {
355
390
  runtimeState(): object
356
391
  clearRuntimeState(): void
357
392
  }
393
+ /**
394
+ * One open call out to another actor.
395
+ *
396
+ * The call spans a request made by the host runtime, so it is opened and closed
397
+ * by two separate calls. Letting this be collected without finishing records
398
+ * the call as cancelled rather than silently losing it.
399
+ */
400
+ export declare class OutboundCall {
401
+ /**
402
+ * W3C context of this call's span, to send to the callee so it parents to
403
+ * the call rather than to the invocation that made it.
404
+ */
405
+ spanContext(): JsActorInvocationSpanContext | null
406
+ /**
407
+ * Records the call's outcome. `error` is the failure as the bridge encodes
408
+ * it, so a structured error keeps its group and code while anything else
409
+ * stays unstructured for Core to classify.
410
+ */
411
+ finish(error?: string | undefined | null): void
412
+ }
413
+ /**
414
+ * One open workflow run. Collecting it without `finish` records the run as
415
+ * abandoned.
416
+ */
417
+ export declare class WorkflowSpan {
418
+ /** The context workflow code runs under. */
419
+ ctx(): ActorContext
420
+ finish(outcome: string): Promise<void>
421
+ }
422
+ /** One open attempt at one workflow step. */
423
+ export declare class WorkflowStepSpan {
424
+ /** The context the step's callback runs under. */
425
+ ctx(): ActorContext
426
+ /** `error` is what the step threw, as the bridge encodes it. */
427
+ finish(outcome: string, error?: string | undefined | null): void
428
+ }
358
429
  export declare class NapiActorFactory {
359
430
  constructor(callbacks: object, config?: JsActorConfig | undefined | null)
360
431
  }
package/index.js CHANGED
@@ -310,11 +310,14 @@ 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, HttpResponseBodyStream, HttpRequestBodyStream, 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
@@ -329,3 +332,5 @@ module.exports.QueueMessage = QueueMessage
329
332
  module.exports.CoreRegistry = CoreRegistry
330
333
  module.exports.Schedule = Schedule
331
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": "2.3.18",
3
+ "version": "2.3.19",
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,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@napi-rs/cli": "^2.18.4",
47
- "@rivetkit/engine-envoy-protocol": "2.3.18"
47
+ "@rivetkit/engine-envoy-protocol": "2.3.19"
48
48
  },
49
49
  "repository": {
50
50
  "type": "git",
@@ -52,12 +52,12 @@
52
52
  "directory": "rivetkit-typescript/packages/rivetkit-napi"
53
53
  },
54
54
  "optionalDependencies": {
55
- "@rivetkit/rivetkit-napi-darwin-arm64": "2.3.18",
56
- "@rivetkit/rivetkit-napi-darwin-x64": "2.3.18",
57
- "@rivetkit/rivetkit-napi-linux-arm64-gnu": "2.3.18",
58
- "@rivetkit/rivetkit-napi-linux-arm64-musl": "2.3.18",
59
- "@rivetkit/rivetkit-napi-linux-x64-gnu": "2.3.18",
60
- "@rivetkit/rivetkit-napi-linux-x64-musl": "2.3.18",
61
- "@rivetkit/rivetkit-napi-win32-x64-msvc": "2.3.18"
55
+ "@rivetkit/rivetkit-napi-darwin-arm64": "2.3.19",
56
+ "@rivetkit/rivetkit-napi-darwin-x64": "2.3.19",
57
+ "@rivetkit/rivetkit-napi-linux-arm64-gnu": "2.3.19",
58
+ "@rivetkit/rivetkit-napi-linux-arm64-musl": "2.3.19",
59
+ "@rivetkit/rivetkit-napi-linux-x64-gnu": "2.3.19",
60
+ "@rivetkit/rivetkit-napi-linux-x64-musl": "2.3.19",
61
+ "@rivetkit/rivetkit-napi-win32-x64-msvc": "2.3.19"
62
62
  }
63
63
  }