@rivetkit/engine-runner 2.0.26 → 2.0.28

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @rivetkit/engine-runner@2.0.26 build /home/runner/work/rivet/rivet/engine/sdks/typescript/runner
2
+ > @rivetkit/engine-runner@2.0.28 build /home/runner/work/rivet/rivet/engine/sdks/typescript/runner
3
3
  > tsup src/mod.ts
4
4
 
5
5
  CLI Building entry: src/mod.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  CJS Build start
12
12
  ESM Build start
13
- ESM dist/mod.js 93.79 KB
14
- ESM dist/mod.js.map 185.09 KB
15
- ESM ⚡️ Build success in 622ms
13
+ ESM dist/mod.js 93.71 KB
14
+ ESM dist/mod.js.map 184.98 KB
15
+ ESM ⚡️ Build success in 605ms
16
+ CJS dist/mod.cjs 94.95 KB
17
+ CJS dist/mod.cjs.map 157.62 KB
18
+ CJS ⚡️ Build success in 610ms
16
19
  DTS Build start
17
- CJS dist/mod.cjs 95.02 KB
18
- CJS dist/mod.cjs.map 157.67 KB
19
- CJS ⚡️ Build success in 747ms
20
- DTS ⚡️ Build success in 3223ms
20
+ DTS ⚡️ Build success in 3637ms
21
21
  DTS dist/mod.d.cts 14.77 KB
22
22
  DTS dist/mod.d.ts 14.77 KB
package/dist/mod.cjs CHANGED
@@ -324,30 +324,29 @@ function stringifyToClientTunnelMessageKind(kind) {
324
324
  function stringifyCommand(command) {
325
325
  switch (command.tag) {
326
326
  case "CommandStartActor": {
327
- const { generation, config, hibernatingRequests } = command.val;
327
+ const { config, hibernatingRequests } = command.val;
328
328
  const keyStr = config.key === null ? "null" : `"${config.key}"`;
329
329
  const inputStr = config.input === null ? "null" : stringifyArrayBuffer(config.input);
330
330
  const hibernatingRequestsStr = hibernatingRequests.length > 0 ? `[${hibernatingRequests.map((hr) => `{gatewayId: ${idToStr(hr.gatewayId)}, requestId: ${idToStr(hr.requestId)}}`).join(", ")}]` : "[]";
331
- return `CommandStartActor{generation: ${generation}, config: {name: "${config.name}", key: ${keyStr}, createTs: ${stringifyBigInt(config.createTs)}, input: ${inputStr}}, hibernatingRequests: ${hibernatingRequestsStr}}`;
331
+ return `CommandStartActor{config: {name: "${config.name}", key: ${keyStr}, createTs: ${stringifyBigInt(config.createTs)}, input: ${inputStr}}, hibernatingRequests: ${hibernatingRequestsStr}}`;
332
332
  }
333
333
  case "CommandStopActor": {
334
- const { generation } = command.val;
335
- return `CommandStopActor{generation: ${generation}}`;
334
+ return `CommandStopActor`;
336
335
  }
337
336
  }
338
337
  }
339
338
  function stringifyCommandWrapper(wrapper) {
340
- return `CommandWrapper{actorId: "${wrapper.checkpoint.actorId}", index: ${stringifyBigInt(wrapper.checkpoint.index)}, inner: ${stringifyCommand(wrapper.inner)}}`;
339
+ return `CommandWrapper{actorId: "${wrapper.checkpoint.actorId}", generation: "${wrapper.checkpoint.generation}", index: ${stringifyBigInt(wrapper.checkpoint.index)}, inner: ${stringifyCommand(wrapper.inner)}}`;
341
340
  }
342
341
  function stringifyEvent(event) {
343
342
  switch (event.tag) {
344
343
  case "EventActorIntent": {
345
- const { actorId, generation, intent } = event.val;
344
+ const { intent } = event.val;
346
345
  const intentStr = intent.tag === "ActorIntentSleep" ? "Sleep" : intent.tag === "ActorIntentStop" ? "Stop" : "Unknown";
347
- return `EventActorIntent{actorId: "${actorId}", generation: ${generation}, intent: ${intentStr}}`;
346
+ return `EventActorIntent{intent: ${intentStr}}`;
348
347
  }
349
348
  case "EventActorStateUpdate": {
350
- const { actorId, generation, state } = event.val;
349
+ const { state } = event.val;
351
350
  let stateStr;
352
351
  if (state.tag === "ActorStateRunning") {
353
352
  stateStr = "Running";
@@ -358,17 +357,17 @@ function stringifyEvent(event) {
358
357
  } else {
359
358
  stateStr = "Unknown";
360
359
  }
361
- return `EventActorStateUpdate{actorId: "${actorId}", generation: ${generation}, state: ${stateStr}}`;
360
+ return `EventActorStateUpdate{state: ${stateStr}}`;
362
361
  }
363
362
  case "EventActorSetAlarm": {
364
- const { actorId, generation, alarmTs } = event.val;
363
+ const { alarmTs } = event.val;
365
364
  const alarmTsStr = alarmTs === null ? "null" : stringifyBigInt(alarmTs);
366
- return `EventActorSetAlarm{actorId: "${actorId}", generation: ${generation}, alarmTs: ${alarmTsStr}}`;
365
+ return `EventActorSetAlarm{alarmTs: ${alarmTsStr}}`;
367
366
  }
368
367
  }
369
368
  }
370
369
  function stringifyEventWrapper(wrapper) {
371
- return `EventWrapper{actorId: ${wrapper.checkpoint.actorId}, index: ${stringifyBigInt(wrapper.checkpoint.index)}, inner: ${stringifyEvent(wrapper.inner)}}`;
370
+ return `EventWrapper{actorId: ${wrapper.checkpoint.actorId}, generation: "${wrapper.checkpoint.generation}", index: ${stringifyBigInt(wrapper.checkpoint.index)}, inner: ${stringifyEvent(wrapper.inner)}}`;
372
371
  }
373
372
  function stringifyToServer(message) {
374
373
  switch (message.tag) {
@@ -1756,7 +1755,7 @@ async function importWebSocket() {
1756
1755
 
1757
1756
  // src/mod.ts
1758
1757
  var KV_EXPIRE = 3e4;
1759
- var PROTOCOL_VERSION = 4;
1758
+ var PROTOCOL_VERSION = 5;
1760
1759
  var EVENT_BACKLOG_WARN_THRESHOLD = 1e4;
1761
1760
  var SIGNAL_HANDLERS = [];
1762
1761
  var RunnerShutdownError = class extends Error {
@@ -1835,7 +1834,11 @@ var Runner = class {
1835
1834
  this.#sendActorIntent(actorId, actor.generation, "stop");
1836
1835
  }
1837
1836
  async forceStopActor(actorId, generation) {
1838
- var _a;
1837
+ var _a, _b;
1838
+ (_a = this.log) == null ? void 0 : _a.debug({
1839
+ msg: "force stopping actor",
1840
+ actorId
1841
+ });
1839
1842
  const actor = this.getActor(actorId, generation);
1840
1843
  if (!actor) return;
1841
1844
  try {
@@ -1843,9 +1846,9 @@ var Runner = class {
1843
1846
  } catch (err) {
1844
1847
  console.error(`Error in onActorStop for actor ${actorId}:`, err);
1845
1848
  }
1846
- (_a = this.#tunnel) == null ? void 0 : _a.closeActiveRequests(actor);
1847
- this.#removeActor(actorId, generation);
1849
+ (_b = this.#tunnel) == null ? void 0 : _b.closeActiveRequests(actor);
1848
1850
  this.#sendActorStateUpdate(actorId, actor.generation, "stopped");
1851
+ this.#removeActor(actorId, generation);
1849
1852
  }
1850
1853
  #handleLost() {
1851
1854
  var _a;
@@ -2383,6 +2386,11 @@ var Runner = class {
2383
2386
  error: stringifyError(err)
2384
2387
  });
2385
2388
  });
2389
+ const actor = this.getActor(
2390
+ commandWrapper.checkpoint.actorId,
2391
+ commandWrapper.checkpoint.generation
2392
+ );
2393
+ if (actor) actor.lastCommandIdx = commandWrapper.checkpoint.index;
2386
2394
  } else if (commandWrapper.inner.tag === "CommandStopActor") {
2387
2395
  this.#handleCommandStopActor(commandWrapper).catch((err) => {
2388
2396
  var _a2;
@@ -2395,11 +2403,6 @@ var Runner = class {
2395
2403
  } else {
2396
2404
  unreachable(commandWrapper.inner);
2397
2405
  }
2398
- const actor = this.getActor(
2399
- commandWrapper.checkpoint.actorId,
2400
- commandWrapper.inner.val.generation
2401
- );
2402
- if (actor) actor.lastCommandIdx = commandWrapper.checkpoint.index;
2403
2406
  }
2404
2407
  }
2405
2408
  #handleAckEvents(ack) {
@@ -2453,7 +2456,7 @@ var Runner = class {
2453
2456
  if (!this.#tunnel) throw new Error("missing tunnel on actor start");
2454
2457
  const startCommand = commandWrapper.inner.val;
2455
2458
  const actorId = commandWrapper.checkpoint.actorId;
2456
- const generation = startCommand.generation;
2459
+ const generation = commandWrapper.checkpoint.generation;
2457
2460
  const config = startCommand.config;
2458
2461
  const actorConfig = {
2459
2462
  name: config.name,
@@ -2512,7 +2515,7 @@ var Runner = class {
2512
2515
  async #handleCommandStopActor(commandWrapper) {
2513
2516
  const stopCommand = commandWrapper.inner.val;
2514
2517
  const actorId = commandWrapper.checkpoint.actorId;
2515
- const generation = stopCommand.generation;
2518
+ const generation = commandWrapper.checkpoint.generation;
2516
2519
  await this.forceStopActor(actorId, generation);
2517
2520
  }
2518
2521
  #sendActorIntent(actorId, generation, intentType) {
@@ -2530,13 +2533,12 @@ var Runner = class {
2530
2533
  unreachable(intentType);
2531
2534
  }
2532
2535
  const intentEvent = {
2533
- actorId,
2534
- generation,
2535
2536
  intent: actorIntent
2536
2537
  };
2537
2538
  const eventWrapper = {
2538
2539
  checkpoint: {
2539
2540
  actorId,
2541
+ generation,
2540
2542
  index: actor.nextEventIdx++
2541
2543
  },
2542
2544
  inner: {
@@ -2568,13 +2570,12 @@ var Runner = class {
2568
2570
  unreachable(stateType);
2569
2571
  }
2570
2572
  const stateUpdateEvent = {
2571
- actorId,
2572
- generation,
2573
2573
  state: actorState
2574
2574
  };
2575
2575
  const eventWrapper = {
2576
2576
  checkpoint: {
2577
2577
  actorId,
2578
+ generation,
2578
2579
  index: actor.nextEventIdx++
2579
2580
  },
2580
2581
  inner: {
@@ -2596,6 +2597,7 @@ var Runner = class {
2596
2597
  }
2597
2598
  lastCommandCheckpoints.push({
2598
2599
  actorId: actor.actorId,
2600
+ generation: actor.generation,
2599
2601
  index: actor.lastCommandIdx
2600
2602
  });
2601
2603
  }
@@ -2832,13 +2834,12 @@ var Runner = class {
2832
2834
  const actor = this.getActor(actorId, generation);
2833
2835
  if (!actor) return;
2834
2836
  const alarmEvent = {
2835
- actorId,
2836
- generation: actor.generation,
2837
2837
  alarmTs: alarmTs !== null ? BigInt(alarmTs) : null
2838
2838
  };
2839
2839
  const eventWrapper = {
2840
2840
  checkpoint: {
2841
2841
  actorId,
2842
+ generation: actor.generation,
2842
2843
  index: actor.nextEventIdx++
2843
2844
  },
2844
2845
  inner: {