rivetkit 2.0.6 → 2.0.7-rc.1

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 (170) hide show
  1. package/dist/schemas/actor-persist/v1.ts +0 -6
  2. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.cts +28 -0
  3. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.ts +28 -0
  4. package/dist/tsup/{chunk-MRRT2CZD.cjs → chunk-3MBP4WNC.cjs} +7 -7
  5. package/dist/tsup/{chunk-MRRT2CZD.cjs.map → chunk-3MBP4WNC.cjs.map} +1 -1
  6. package/dist/tsup/{chunk-TWGATZ3X.cjs → chunk-3Y45CIF4.cjs} +922 -872
  7. package/dist/tsup/chunk-3Y45CIF4.cjs.map +1 -0
  8. package/dist/tsup/chunk-4GP7BZSR.js +102 -0
  9. package/dist/tsup/chunk-4GP7BZSR.js.map +1 -0
  10. package/dist/tsup/{chunk-UFWAK3X2.cjs → chunk-5ZOHIKWG.cjs} +660 -385
  11. package/dist/tsup/chunk-5ZOHIKWG.cjs.map +1 -0
  12. package/dist/tsup/{chunk-5JBFVV4C.cjs → chunk-6EUWRXLT.cjs} +21 -7
  13. package/dist/tsup/chunk-6EUWRXLT.cjs.map +1 -0
  14. package/dist/tsup/{chunk-UTI5NCES.cjs → chunk-6OVKCDSH.cjs} +6 -6
  15. package/dist/tsup/{chunk-UTI5NCES.cjs.map → chunk-6OVKCDSH.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-VPV4MWXR.js → chunk-7N56ZUC7.js} +3 -3
  17. package/dist/tsup/{chunk-DIAYNQTE.cjs → chunk-B3TLRM4Q.cjs} +12 -12
  18. package/dist/tsup/{chunk-DIAYNQTE.cjs.map → chunk-B3TLRM4Q.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-4CKHQRXG.js → chunk-BW5DPM6Z.js} +515 -240
  20. package/dist/tsup/chunk-BW5DPM6Z.js.map +1 -0
  21. package/dist/tsup/{chunk-NTCUGYSD.cjs → chunk-DFS77KAA.cjs} +34 -31
  22. package/dist/tsup/chunk-DFS77KAA.cjs.map +1 -0
  23. package/dist/tsup/{chunk-VCEHU56K.js → chunk-E4UVJKSV.js} +2 -2
  24. package/dist/tsup/chunk-G4ABMAQY.cjs +102 -0
  25. package/dist/tsup/chunk-G4ABMAQY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-ZYLTS2EM.js → chunk-GZVBFXBI.js} +2 -2
  27. package/dist/tsup/{chunk-W6LN7AF5.js → chunk-HPT3I7UU.js} +866 -816
  28. package/dist/tsup/chunk-HPT3I7UU.js.map +1 -0
  29. package/dist/tsup/{chunk-7OUKNSTU.js → chunk-JD54PXWP.js} +17 -14
  30. package/dist/tsup/chunk-JD54PXWP.js.map +1 -0
  31. package/dist/tsup/{chunk-KG3C7MKR.cjs → chunk-K4ENQCC4.cjs} +3 -3
  32. package/dist/tsup/{chunk-KG3C7MKR.cjs.map → chunk-K4ENQCC4.cjs.map} +1 -1
  33. package/dist/tsup/{chunk-WC2PSJWN.js → chunk-PUSQNDJG.js} +2 -2
  34. package/dist/tsup/{chunk-RGQR2J7S.js → chunk-RVP5RUSC.js} +20 -6
  35. package/dist/tsup/chunk-RVP5RUSC.js.map +1 -0
  36. package/dist/tsup/{chunk-TCUI5JFE.cjs → chunk-SAZCNSVY.cjs} +45 -18
  37. package/dist/tsup/chunk-SAZCNSVY.cjs.map +1 -0
  38. package/dist/tsup/{chunk-G75SVQON.js → chunk-SBKRVQS2.js} +9 -5
  39. package/dist/tsup/chunk-SBKRVQS2.js.map +1 -0
  40. package/dist/tsup/{chunk-6P6RA47N.cjs → chunk-TZGUSEIJ.cjs} +14 -10
  41. package/dist/tsup/chunk-TZGUSEIJ.cjs.map +1 -0
  42. package/dist/tsup/{chunk-2K3JMDAN.js → chunk-YQ4XQYPM.js} +40 -13
  43. package/dist/tsup/chunk-YQ4XQYPM.js.map +1 -0
  44. package/dist/tsup/client/mod.cjs +9 -9
  45. package/dist/tsup/client/mod.d.cts +7 -8
  46. package/dist/tsup/client/mod.d.ts +7 -8
  47. package/dist/tsup/client/mod.js +8 -8
  48. package/dist/tsup/common/log.cjs +3 -3
  49. package/dist/tsup/common/log.js +2 -2
  50. package/dist/tsup/common/websocket.cjs +4 -4
  51. package/dist/tsup/common/websocket.js +3 -3
  52. package/dist/tsup/{connection-BLemxi4f.d.ts → conn-DCSQgIlw.d.ts} +1605 -1353
  53. package/dist/tsup/{connection-CpDIydXf.d.cts → conn-DdzHTm2E.d.cts} +1605 -1353
  54. package/dist/tsup/driver-helpers/mod.cjs +31 -5
  55. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  56. package/dist/tsup/driver-helpers/mod.d.cts +7 -8
  57. package/dist/tsup/driver-helpers/mod.d.ts +7 -8
  58. package/dist/tsup/driver-helpers/mod.js +33 -7
  59. package/dist/tsup/driver-test-suite/mod.cjs +317 -222
  60. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  61. package/dist/tsup/driver-test-suite/mod.d.cts +7 -7
  62. package/dist/tsup/driver-test-suite/mod.d.ts +7 -7
  63. package/dist/tsup/driver-test-suite/mod.js +582 -487
  64. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  65. package/dist/tsup/inspector/mod.cjs +16 -6
  66. package/dist/tsup/inspector/mod.cjs.map +1 -1
  67. package/dist/tsup/inspector/mod.d.cts +34 -7
  68. package/dist/tsup/inspector/mod.d.ts +34 -7
  69. package/dist/tsup/inspector/mod.js +17 -7
  70. package/dist/tsup/mod.cjs +10 -20
  71. package/dist/tsup/mod.cjs.map +1 -1
  72. package/dist/tsup/mod.d.cts +9 -7
  73. package/dist/tsup/mod.d.ts +9 -7
  74. package/dist/tsup/mod.js +9 -19
  75. package/dist/tsup/test/mod.cjs +11 -11
  76. package/dist/tsup/test/mod.d.cts +6 -7
  77. package/dist/tsup/test/mod.d.ts +6 -7
  78. package/dist/tsup/test/mod.js +10 -10
  79. package/dist/tsup/utils.cjs +4 -2
  80. package/dist/tsup/utils.cjs.map +1 -1
  81. package/dist/tsup/utils.d.cts +11 -1
  82. package/dist/tsup/utils.d.ts +11 -1
  83. package/dist/tsup/utils.js +3 -1
  84. package/package.json +8 -4
  85. package/src/actor/action.ts +1 -1
  86. package/src/actor/config.ts +1 -1
  87. package/src/actor/conn-drivers.ts +205 -0
  88. package/src/actor/conn-socket.ts +6 -0
  89. package/src/actor/{connection.ts → conn.ts} +78 -84
  90. package/src/actor/context.ts +1 -1
  91. package/src/actor/driver.ts +4 -43
  92. package/src/actor/instance.ts +162 -86
  93. package/src/actor/mod.ts +1 -11
  94. package/src/actor/persisted.ts +2 -5
  95. package/src/actor/protocol/old.ts +1 -1
  96. package/src/actor/router-endpoints.ts +142 -106
  97. package/src/actor/router.ts +81 -45
  98. package/src/actor/utils.ts +5 -1
  99. package/src/client/actor-conn.ts +154 -23
  100. package/src/client/client.ts +1 -1
  101. package/src/client/config.ts +7 -0
  102. package/src/common/actor-router-consts.ts +29 -8
  103. package/src/common/router.ts +2 -1
  104. package/src/common/versioned-data.ts +5 -5
  105. package/src/driver-helpers/mod.ts +14 -1
  106. package/src/driver-test-suite/mod.ts +11 -2
  107. package/src/driver-test-suite/test-inline-client-driver.ts +36 -18
  108. package/src/driver-test-suite/tests/actor-conn-state.ts +66 -22
  109. package/src/driver-test-suite/tests/actor-conn.ts +65 -126
  110. package/src/driver-test-suite/tests/actor-reconnect.ts +160 -0
  111. package/src/driver-test-suite/tests/actor-sleep.ts +0 -1
  112. package/src/driver-test-suite/tests/raw-websocket.ts +0 -35
  113. package/src/driver-test-suite/utils.ts +3 -3
  114. package/src/drivers/default.ts +8 -7
  115. package/src/drivers/engine/actor-driver.ts +53 -31
  116. package/src/drivers/engine/config.ts +4 -0
  117. package/src/drivers/file-system/actor.ts +0 -6
  118. package/src/drivers/file-system/global-state.ts +3 -14
  119. package/src/drivers/file-system/manager.ts +12 -8
  120. package/src/inspector/actor.ts +4 -3
  121. package/src/inspector/config.ts +10 -1
  122. package/src/inspector/mod.ts +1 -0
  123. package/src/inspector/utils.ts +23 -4
  124. package/src/manager/driver.ts +11 -1
  125. package/src/manager/gateway.ts +407 -0
  126. package/src/manager/router.ts +269 -468
  127. package/src/manager-api/actors.ts +61 -0
  128. package/src/manager-api/common.ts +4 -0
  129. package/src/mod.ts +1 -1
  130. package/src/registry/mod.ts +119 -10
  131. package/src/remote-manager-driver/actor-http-client.ts +30 -19
  132. package/src/remote-manager-driver/actor-websocket-client.ts +43 -16
  133. package/src/remote-manager-driver/api-endpoints.ts +19 -21
  134. package/src/remote-manager-driver/api-utils.ts +10 -1
  135. package/src/remote-manager-driver/mod.ts +51 -48
  136. package/src/remote-manager-driver/ws-proxy.ts +2 -9
  137. package/src/test/mod.ts +6 -2
  138. package/src/utils.ts +21 -2
  139. package/dist/tsup/actor-router-consts-BK6arfy8.d.cts +0 -17
  140. package/dist/tsup/actor-router-consts-BK6arfy8.d.ts +0 -17
  141. package/dist/tsup/chunk-2K3JMDAN.js.map +0 -1
  142. package/dist/tsup/chunk-42I3OZ3Q.js +0 -15
  143. package/dist/tsup/chunk-42I3OZ3Q.js.map +0 -1
  144. package/dist/tsup/chunk-4CKHQRXG.js.map +0 -1
  145. package/dist/tsup/chunk-5JBFVV4C.cjs.map +0 -1
  146. package/dist/tsup/chunk-6P6RA47N.cjs.map +0 -1
  147. package/dist/tsup/chunk-7OUKNSTU.js.map +0 -1
  148. package/dist/tsup/chunk-G75SVQON.js.map +0 -1
  149. package/dist/tsup/chunk-KUPQZYUQ.cjs +0 -15
  150. package/dist/tsup/chunk-KUPQZYUQ.cjs.map +0 -1
  151. package/dist/tsup/chunk-NTCUGYSD.cjs.map +0 -1
  152. package/dist/tsup/chunk-RGQR2J7S.js.map +0 -1
  153. package/dist/tsup/chunk-TCUI5JFE.cjs.map +0 -1
  154. package/dist/tsup/chunk-TWGATZ3X.cjs.map +0 -1
  155. package/dist/tsup/chunk-UFWAK3X2.cjs.map +0 -1
  156. package/dist/tsup/chunk-W6LN7AF5.js.map +0 -1
  157. package/dist/tsup/common-CXCe7s6i.d.cts +0 -218
  158. package/dist/tsup/common-CXCe7s6i.d.ts +0 -218
  159. package/src/actor/generic-conn-driver.ts +0 -246
  160. package/src/common/fake-event-source.ts +0 -267
  161. package/src/manager-api/routes/actors-create.ts +0 -16
  162. package/src/manager-api/routes/actors-delete.ts +0 -4
  163. package/src/manager-api/routes/actors-get-by-id.ts +0 -7
  164. package/src/manager-api/routes/actors-get-or-create-by-id.ts +0 -29
  165. package/src/manager-api/routes/actors-get.ts +0 -7
  166. package/src/manager-api/routes/common.ts +0 -18
  167. /package/dist/tsup/{chunk-VPV4MWXR.js.map → chunk-7N56ZUC7.js.map} +0 -0
  168. /package/dist/tsup/{chunk-VCEHU56K.js.map → chunk-E4UVJKSV.js.map} +0 -0
  169. /package/dist/tsup/{chunk-ZYLTS2EM.js.map → chunk-GZVBFXBI.js.map} +0 -0
  170. /package/dist/tsup/{chunk-WC2PSJWN.js.map → chunk-PUSQNDJG.js.map} +0 -0
@@ -1,267 +0,0 @@
1
- import type { EventListener } from "eventsource";
2
- import type { SSEStreamingApi } from "hono/streaming";
3
- import { getLogger } from "@/common//log";
4
- import type {
5
- UniversalEvent,
6
- UniversalEventSource,
7
- UniversalMessageEvent,
8
- } from "@/common/eventsource-interface";
9
-
10
- export function logger() {
11
- return getLogger("fake-event-source");
12
- }
13
-
14
- /**
15
- * FakeEventSource provides a minimal implementation of an SSE stream
16
- * that handles events for the inline client driver
17
- */
18
- export class FakeEventSource implements UniversalEventSource {
19
- // EventSource readyState values
20
- readonly CONNECTING = 0 as const;
21
- readonly OPEN = 1 as const;
22
- readonly CLOSED = 2 as const;
23
-
24
- url = "http://internal-sse-endpoint";
25
- readyState: 0 | 1 | 2 = 1; // OPEN
26
- withCredentials = false;
27
-
28
- // Event handlers
29
- onopen: ((event: UniversalEvent) => void) | null = null;
30
- onmessage: ((event: UniversalMessageEvent) => void) | null = null;
31
- onerror: ((event: UniversalEvent) => void) | null = null;
32
-
33
- // Private event listeners
34
- #listeners: Record<string, Set<EventListener>> = {
35
- open: new Set(),
36
- message: new Set(),
37
- error: new Set(),
38
- close: new Set(),
39
- };
40
-
41
- // Stream that will be passed to the handler
42
- #stream: SSEStreamingApi;
43
- #onCloseCallback: () => Promise<void>;
44
-
45
- /**
46
- * Creates a new FakeEventSource
47
- */
48
- constructor(onCloseCallback: () => Promise<void>) {
49
- this.#onCloseCallback = onCloseCallback;
50
-
51
- this.#stream = this.#createStreamApi();
52
-
53
- // Trigger open event on next tick
54
- setTimeout(() => {
55
- if (this.readyState === 1) {
56
- this.#dispatchEvent("open");
57
- }
58
- }, 0);
59
-
60
- logger().debug("FakeEventSource created");
61
- }
62
-
63
- // Creates the SSE streaming API implementation
64
- #createStreamApi(): SSEStreamingApi {
65
- // Create self-reference for closures
66
- const self = this;
67
-
68
- const streamApi: SSEStreamingApi = {
69
- write: async (input) => {
70
- const data =
71
- typeof input === "string" ? input : new TextDecoder().decode(input);
72
- self.#dispatchEvent("message", { data });
73
- return streamApi;
74
- },
75
-
76
- writeln: async (input: string) => {
77
- await streamApi.write(input + "\n");
78
- return streamApi;
79
- },
80
-
81
- writeSSE: async (message: {
82
- data: string | Promise<string>;
83
- event?: string;
84
- id?: string;
85
- retry?: number;
86
- }): Promise<void> => {
87
- const data = await message.data;
88
-
89
- if (message.event) {
90
- self.#dispatchEvent(message.event, { data });
91
- } else {
92
- self.#dispatchEvent("message", { data });
93
- }
94
- },
95
-
96
- sleep: async (ms: number) => {
97
- await new Promise((resolve) => setTimeout(resolve, ms));
98
- return streamApi;
99
- },
100
-
101
- close: async () => {
102
- self.close();
103
- },
104
-
105
- pipe: async (_body: ReadableStream) => {
106
- // No-op implementation
107
- },
108
-
109
- onAbort: async (cb: () => void) => {
110
- self.addEventListener("error", () => {
111
- cb();
112
- });
113
- return streamApi;
114
- },
115
-
116
- abort: async () => {
117
- self.#dispatchEvent("error");
118
- return streamApi;
119
- },
120
-
121
- // Additional required properties
122
- get responseReadable() {
123
- return null as unknown as ReadableStream;
124
- },
125
-
126
- get aborted() {
127
- return self.readyState === 2; // CLOSED
128
- },
129
-
130
- get closed() {
131
- return self.readyState === 2; // CLOSED
132
- },
133
- };
134
-
135
- return streamApi;
136
- }
137
-
138
- /**
139
- * Closes the connection
140
- */
141
- close(): void {
142
- if (this.readyState === 2) {
143
- // CLOSED
144
- return;
145
- }
146
-
147
- logger().debug({ msg: "closing FakeEventSource" });
148
- this.readyState = 2; // CLOSED
149
-
150
- // Call the close callback
151
- this.#onCloseCallback().catch((err) => {
152
- logger().error({ msg: "error in onClose callback", error: err });
153
- });
154
-
155
- // Dispatch close event
156
- this.#dispatchEvent("close");
157
- }
158
-
159
- /**
160
- * Get the stream API to pass to the handler
161
- */
162
- getStream(): SSEStreamingApi {
163
- return this.#stream;
164
- }
165
-
166
- // Implementation of EventTarget-like interface
167
- addEventListener(type: string, listener: EventListener): void {
168
- if (!this.#listeners[type]) {
169
- this.#listeners[type] = new Set();
170
- }
171
- this.#listeners[type].add(listener);
172
- }
173
-
174
- removeEventListener(type: string, listener: EventListener): void {
175
- if (this.#listeners[type]) {
176
- this.#listeners[type].delete(listener);
177
- }
178
- }
179
-
180
- dispatchEvent(event: UniversalEvent): boolean {
181
- this.#dispatchEvent(event.type, event);
182
- return true;
183
- }
184
-
185
- // Internal method to dispatch events
186
- #dispatchEvent(type: string, detail?: Record<string, any>): void {
187
- // Create appropriate event object
188
- let event: any;
189
- if (type === "message") {
190
- event = {
191
- type: "message",
192
- target: this,
193
- data: detail?.data || "",
194
- origin: "",
195
- lastEventId: "",
196
- };
197
- } else if (type === "close") {
198
- event = {
199
- type: "close",
200
- target: this,
201
- code: detail?.code || 1000,
202
- reason: detail?.reason || "",
203
- wasClean: detail?.wasClean ?? true,
204
- };
205
- } else if (type === "error") {
206
- event = {
207
- type: "error",
208
- target: this,
209
- error: detail?.error,
210
- };
211
- } else {
212
- event = {
213
- type: type,
214
- target: this,
215
- };
216
- }
217
-
218
- // Call all listeners first
219
- if (this.#listeners[type]) {
220
- for (const listener of this.#listeners[type]) {
221
- try {
222
- listener.call(this, event);
223
- } catch (err) {
224
- logger().error({
225
- msg: `error in ${type} event listener`,
226
- error: err,
227
- });
228
- }
229
- }
230
- }
231
-
232
- // Then call specific handler
233
- switch (type) {
234
- case "open":
235
- if (this.onopen) {
236
- try {
237
- this.onopen.call(this as any, event);
238
- } catch (err) {
239
- logger().error({ msg: "error in onopen handler", error: err });
240
- }
241
- }
242
- break;
243
- case "message":
244
- if (this.onmessage) {
245
- try {
246
- this.onmessage.call(this as any, event);
247
- } catch (err) {
248
- logger().error({ msg: "error in onmessage handler", error: err });
249
- }
250
- }
251
- break;
252
- case "error":
253
- if (this.onerror) {
254
- try {
255
- this.onerror.call(this as any, event);
256
- } catch (err) {
257
- logger().error({ msg: "error in onerror handler", error: err });
258
- }
259
- }
260
- break;
261
- case "close":
262
- // Note: EventSource doesn't have onclose in the standard API
263
- // but we handle it here for consistency
264
- break;
265
- }
266
- }
267
- }
@@ -1,16 +0,0 @@
1
- import { z } from "zod";
2
- import { ActorSchema } from "./common";
3
-
4
- export const ActorsCreateRequestSchema = z.object({
5
- name: z.string(),
6
- runner_name_selector: z.string(),
7
- crash_policy: z.string(),
8
- key: z.string().nullable().optional(),
9
- input: z.string().nullable().optional(),
10
- });
11
- export type ActorsCreateRequest = z.infer<typeof ActorsCreateRequestSchema>;
12
-
13
- export const ActorsCreateResponseSchema = z.object({
14
- actor: ActorSchema,
15
- });
16
- export type ActorsCreateResponse = z.infer<typeof ActorsCreateResponseSchema>;
@@ -1,4 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const ActorsDeleteResponseSchema = z.object({});
4
- export type ActorsDeleteResponse = z.infer<typeof ActorsDeleteResponseSchema>;
@@ -1,7 +0,0 @@
1
- import { z } from "zod";
2
- import { RivetIdSchema } from "./common";
3
-
4
- export const ActorsGetByIdResponseSchema = z.object({
5
- actor_id: RivetIdSchema.nullable().optional(),
6
- });
7
- export type ActorsGetByIdResponse = z.infer<typeof ActorsGetByIdResponseSchema>;
@@ -1,29 +0,0 @@
1
- import { z } from "zod";
2
- import { ActorSchema, RivetIdSchema } from "./common";
3
-
4
- export const ActorsGetOrCreateResponseSchema = z.object({
5
- actor: ActorSchema,
6
- created: z.boolean(),
7
- });
8
- export type ActorsGetOrCreateResponse = z.infer<
9
- typeof ActorsGetOrCreateResponseSchema
10
- >;
11
-
12
- export const ActorsGetOrCreateByIdResponseSchema = z.object({
13
- actor_id: RivetIdSchema,
14
- created: z.boolean(),
15
- });
16
- export type ActorsGetOrCreateByIdResponse = z.infer<
17
- typeof ActorsGetOrCreateByIdResponseSchema
18
- >;
19
-
20
- export const ActorsGetOrCreateByIdRequestSchema = z.object({
21
- name: z.string(),
22
- key: z.string(),
23
- runner_name_selector: z.string(),
24
- crash_policy: z.string(),
25
- input: z.string().nullable().optional(),
26
- });
27
- export type ActorsGetOrCreateByIdRequest = z.infer<
28
- typeof ActorsGetOrCreateByIdRequestSchema
29
- >;
@@ -1,7 +0,0 @@
1
- import { z } from "zod";
2
- import { ActorSchema } from "./common";
3
-
4
- export const ActorsGetResponseSchema = z.object({
5
- actor: ActorSchema,
6
- });
7
- export type ActorsGetResponse = z.infer<typeof ActorsGetResponseSchema>;
@@ -1,18 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const RivetIdSchema = z.string();
4
- export type RivetId = z.infer<typeof RivetIdSchema>;
5
-
6
- export const ActorSchema = z.object({
7
- actor_id: RivetIdSchema,
8
- name: z.string(),
9
- key: z.string(),
10
- namespace_id: RivetIdSchema,
11
- runner_name_selector: z.string(),
12
- create_ts: z.number(),
13
- connectable_ts: z.number().nullable().optional(),
14
- destroy_ts: z.number().nullable().optional(),
15
- sleep_ts: z.number().nullable().optional(),
16
- start_ts: z.number().nullable().optional(),
17
- });
18
- export type Actor = z.infer<typeof ActorSchema>;