@rivetkit/rivetkit-napi 0.0.0-active-actors-fix-active-count.253e406 → 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 +119 -6
- package/index.js +4 -1
- package/package.json +15 -10
- package/scripts/build.mjs +8 -0
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,6 +220,11 @@ export interface JsServerlessResponseHead {
|
|
|
174
220
|
status: number
|
|
175
221
|
headers: Record<string, string>
|
|
176
222
|
}
|
|
223
|
+
export interface JsApplicationResponse {
|
|
224
|
+
status: number
|
|
225
|
+
headers: Record<string, string>
|
|
226
|
+
body: Buffer
|
|
227
|
+
}
|
|
177
228
|
export interface JsRegistryRouteResponse {
|
|
178
229
|
status: number
|
|
179
230
|
headers: Record<string, string>
|
|
@@ -184,6 +235,38 @@ export interface JsServerlessStreamError {
|
|
|
184
235
|
code: string
|
|
185
236
|
message: string
|
|
186
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
|
+
}
|
|
187
270
|
/** Options for KV list operations. */
|
|
188
271
|
export interface JsKvListOptions {
|
|
189
272
|
reverse?: boolean
|
|
@@ -196,12 +279,12 @@ export interface JsKvEntry {
|
|
|
196
279
|
}
|
|
197
280
|
/** N-API wrapper around `rivetkit-core::ActorContext`. */
|
|
198
281
|
export declare class ActorContext {
|
|
199
|
-
constructor(actorId: string, name: string, region: string)
|
|
200
282
|
state(): Buffer
|
|
201
283
|
beginOnStateChange(): void
|
|
202
284
|
endOnStateChange(): void
|
|
203
285
|
kv(): Kv
|
|
204
286
|
sql(): JsNativeDatabase
|
|
287
|
+
provisionActorRuntimeSocket(): Promise<JsActorRuntimeSocketEndpointInfo>
|
|
205
288
|
schedule(): Schedule
|
|
206
289
|
queue(): Queue
|
|
207
290
|
setAlarm(timestampMs?: number | undefined | null): void
|
|
@@ -216,6 +299,7 @@ export declare class ActorContext {
|
|
|
216
299
|
takePendingHibernationChanges(): Array<string>
|
|
217
300
|
dirtyHibernatableConns(): Array<ConnHandle>
|
|
218
301
|
saveState(payload: StateDeltaPayload): Promise<void>
|
|
302
|
+
saveStateAndWorkflowBatch(writes: Array<WorkflowKvWritePayload>): Promise<void>
|
|
219
303
|
actorId(): string
|
|
220
304
|
name(): string
|
|
221
305
|
key(): Array<JsActorKeySegment>
|
|
@@ -242,6 +326,7 @@ export declare class ActorContext {
|
|
|
242
326
|
broadcast(name: string, args: Buffer): void
|
|
243
327
|
waitUntil(promise: Promise<any>): void
|
|
244
328
|
waitForTrackedShutdownWork(): Promise<boolean>
|
|
329
|
+
waitForTrackedShutdownWorkUnbounded(): Promise<void>
|
|
245
330
|
registerTask(promise: Promise<any>): void
|
|
246
331
|
runtimeState(): object
|
|
247
332
|
clearRuntimeState(): void
|
|
@@ -270,8 +355,16 @@ export declare class JsNativeDatabase {
|
|
|
270
355
|
run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
|
|
271
356
|
query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
|
|
272
357
|
execute(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<NativeExecuteResult>
|
|
358
|
+
executeBatch(statements: Array<JsSqliteBatchStatement>): Promise<Array<NativeExecuteResult>>
|
|
273
359
|
exec(sql: string): Promise<QueryResult>
|
|
274
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>
|
|
275
368
|
}
|
|
276
369
|
export declare class Kv {
|
|
277
370
|
get(key: Buffer): Promise<Buffer | null>
|
|
@@ -289,11 +382,12 @@ export declare class Queue {
|
|
|
289
382
|
next(options?: JsQueueNextOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage | null>
|
|
290
383
|
nextBatch(options?: JsQueueNextBatchOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Array<QueueMessage>>
|
|
291
384
|
waitForNames(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage>
|
|
292
|
-
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>
|
|
293
386
|
enqueueAndWait(name: string, body: Buffer, options?: JsQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Buffer | null>
|
|
294
387
|
tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
|
|
295
388
|
tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
|
|
296
389
|
maxSize(): number
|
|
390
|
+
reset(): Promise<void>
|
|
297
391
|
inspectMessages(): Promise<Array<JsQueueInspectMessage>>
|
|
298
392
|
}
|
|
299
393
|
export declare class QueueMessage {
|
|
@@ -308,6 +402,13 @@ export declare class CoreRegistry {
|
|
|
308
402
|
constructor()
|
|
309
403
|
register(name: string, factory: NapiActorFactory): void
|
|
310
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>
|
|
311
412
|
/**
|
|
312
413
|
* Trip the shutdown token and tear down any live serverless runtime.
|
|
313
414
|
*
|
|
@@ -316,14 +417,26 @@ export declare class CoreRegistry {
|
|
|
316
417
|
* separately to avoid re-entrancy.
|
|
317
418
|
*/
|
|
318
419
|
shutdown(): Promise<void>
|
|
420
|
+
actorStopThresholdMs(): Promise<number | null>
|
|
319
421
|
health(): Promise<JsRegistryRouteResponse>
|
|
320
422
|
metadata(): JsRegistryRouteResponse
|
|
321
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>
|
|
322
426
|
handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
|
|
323
427
|
}
|
|
324
428
|
export declare class Schedule {
|
|
325
|
-
after(durationMs: number, actionName: string, args: Buffer):
|
|
326
|
-
at(timestampMs: number, actionName: string, args: Buffer):
|
|
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>>
|
|
327
440
|
}
|
|
328
441
|
export declare class WebSocket {
|
|
329
442
|
send(data: Buffer, binary: boolean): void
|
package/index.js
CHANGED
|
@@ -310,13 +310,16 @@ 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 } = 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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/rivetkit-napi",
|
|
3
|
-
"version": "0.0.0-
|
|
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-
|
|
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-
|
|
50
|
-
"@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-
|
|
51
|
-
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-
|
|
52
|
-
"@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-
|
|
53
|
-
"@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-
|
|
54
|
-
"@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-
|
|
55
|
-
"@rivetkit/rivetkit-napi-win32-x64-msvc": "0.0.0-active-actors-fix-active-count.253e406"
|
|
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" });
|