rivetkit 2.3.0-rc.9 → 2.3.0
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/dist/browser/client.d.ts +498 -62
- package/dist/browser/client.js +227 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +496 -69
- package/dist/tsup/agent-os/index.d.ts +496 -69
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
- package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
- package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +730 -336
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +633 -239
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +58 -56
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +154 -74
- package/src/registry/napi-runtime.ts +13 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +367 -181
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +41 -1
- package/src/registry/wasm-runtime.ts +18 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
- package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
- package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
- package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
- package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
- package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
- package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
- package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
- package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
- /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AnyActorDefinition } from "@/actor/definition";
|
|
2
2
|
import type { ActorSpecifier } from "@/actor/errors";
|
|
3
|
-
import type { Encoding } from "@/common/encoding";
|
|
4
3
|
import {
|
|
5
4
|
HEADER_CONN_PARAMS,
|
|
6
5
|
HEADER_ENCODING,
|
|
@@ -12,7 +11,6 @@ import {
|
|
|
12
11
|
HTTP_ACTION_RESPONSE_VERSIONED,
|
|
13
12
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
14
13
|
} from "@/common/client-protocol-versioned";
|
|
15
|
-
import { AsyncMutex } from "@/common/database/shared";
|
|
16
14
|
import {
|
|
17
15
|
type HttpActionRequest as HttpActionRequestJson,
|
|
18
16
|
HttpActionRequestSchema,
|
|
@@ -21,16 +19,22 @@ import {
|
|
|
21
19
|
type HttpResponseError as HttpResponseErrorJson,
|
|
22
20
|
HttpResponseErrorSchema,
|
|
23
21
|
} from "@/common/client-protocol-zod";
|
|
22
|
+
import { AsyncMutex } from "@/common/database/shared";
|
|
23
|
+
import type { Encoding, JsonCompatValue } from "@/common/encoding";
|
|
24
24
|
import { deconstructError } from "@/common/utils";
|
|
25
25
|
import type { EngineControlClient } from "@/engine-client/driver";
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
decodeCborCompat,
|
|
28
|
+
deserializeWithEncoding,
|
|
29
|
+
encodeCborCompat,
|
|
30
|
+
} from "@/serde";
|
|
27
31
|
import { bufferToArrayBuffer } from "@/utils";
|
|
28
32
|
import type {
|
|
29
33
|
ActorActionOptions,
|
|
30
34
|
ActorConnectOptions,
|
|
31
35
|
ActorDefinitionActions,
|
|
32
|
-
ActorFetchInit,
|
|
33
36
|
ActorDefinitionQueueSend,
|
|
37
|
+
ActorFetchInit,
|
|
34
38
|
ActorGatewayOptions,
|
|
35
39
|
ActorWebSocketOptions,
|
|
36
40
|
} from "./actor-common";
|
|
@@ -147,7 +151,8 @@ export class ActorHandleRaw {
|
|
|
147
151
|
useQueryTarget,
|
|
148
152
|
gatewayOptions,
|
|
149
153
|
);
|
|
150
|
-
actorId =
|
|
154
|
+
actorId =
|
|
155
|
+
"directId" in target ? target.directId : undefined;
|
|
151
156
|
|
|
152
157
|
return await createQueueSender({
|
|
153
158
|
encoding: this.#encoding,
|
|
@@ -161,10 +166,8 @@ export class ActorHandleRaw {
|
|
|
161
166
|
},
|
|
162
167
|
}).send(name, body, options as any);
|
|
163
168
|
} catch (err) {
|
|
164
|
-
const { group, code, message, metadata, actor } =
|
|
165
|
-
err,
|
|
166
|
-
true,
|
|
167
|
-
);
|
|
169
|
+
const { group, code, message, metadata, actor } =
|
|
170
|
+
deconstructError(err, true);
|
|
168
171
|
|
|
169
172
|
if (
|
|
170
173
|
this.#shouldRetryQueueDispatchOverload(
|
|
@@ -207,19 +210,25 @@ export class ActorHandleRaw {
|
|
|
207
210
|
continue;
|
|
208
211
|
}
|
|
209
212
|
|
|
210
|
-
const invalidated = this.#invalidateResolvedActorId(
|
|
213
|
+
const invalidated = this.#invalidateResolvedActorId(
|
|
214
|
+
group,
|
|
215
|
+
code,
|
|
216
|
+
);
|
|
211
217
|
if (invalidated && attempt < maxAttempts - 1) {
|
|
212
218
|
useQueryTarget =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
code === "starting" ||
|
|
220
|
+
code === "stopping" ||
|
|
221
|
+
code.startsWith("destroyed_");
|
|
216
222
|
if (useQueryTarget) {
|
|
217
223
|
await this.#waitForRetryWindow();
|
|
218
224
|
}
|
|
219
225
|
continue;
|
|
220
226
|
}
|
|
221
227
|
|
|
222
|
-
throw new ActorError(group, code, message, {
|
|
228
|
+
throw new ActorError(group, code, message, {
|
|
229
|
+
metadata,
|
|
230
|
+
actor,
|
|
231
|
+
});
|
|
223
232
|
}
|
|
224
233
|
}
|
|
225
234
|
|
|
@@ -234,13 +243,12 @@ export class ActorHandleRaw {
|
|
|
234
243
|
* @template Args - The type of arguments to pass to the action function.
|
|
235
244
|
* @template Response - The type of the response returned by the action function.
|
|
236
245
|
*/
|
|
237
|
-
async action<
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
} & ActorActionOptions): Promise<Response> {
|
|
246
|
+
async action<Args extends Array<unknown> = unknown[], Response = unknown>(
|
|
247
|
+
opts: {
|
|
248
|
+
name: string;
|
|
249
|
+
args: Args;
|
|
250
|
+
} & ActorActionOptions,
|
|
251
|
+
): Promise<Response> {
|
|
244
252
|
if (
|
|
245
253
|
typeof opts === "string" ||
|
|
246
254
|
typeof opts !== "object" ||
|
|
@@ -259,10 +267,12 @@ export class ActorHandleRaw {
|
|
|
259
267
|
return await retryOnLifecycleBoundary(run, { signal: opts.signal });
|
|
260
268
|
}
|
|
261
269
|
|
|
262
|
-
async #sendActionNow(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
270
|
+
async #sendActionNow(
|
|
271
|
+
opts: {
|
|
272
|
+
name: string;
|
|
273
|
+
args: unknown[];
|
|
274
|
+
} & ActorActionOptions,
|
|
275
|
+
): Promise<unknown> {
|
|
266
276
|
const maxAttempts = this.#getDynamicQueryMaxAttempts();
|
|
267
277
|
let useQueryTarget = false;
|
|
268
278
|
const gatewayOptions = resolveActorGatewayOptions(
|
|
@@ -325,16 +335,20 @@ export class ActorHandleRaw {
|
|
|
325
335
|
requestVersion: CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
326
336
|
requestVersionedDataHandler: HTTP_ACTION_REQUEST_VERSIONED,
|
|
327
337
|
responseVersion: CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
328
|
-
responseVersionedDataHandler:
|
|
338
|
+
responseVersionedDataHandler:
|
|
339
|
+
HTTP_ACTION_RESPONSE_VERSIONED,
|
|
329
340
|
requestZodSchema: HttpActionRequestSchema,
|
|
330
341
|
responseZodSchema: HttpActionResponseSchema,
|
|
331
342
|
requestToJson: (args): HttpActionRequestJson => ({
|
|
332
343
|
args,
|
|
333
344
|
}),
|
|
334
345
|
requestToBare: (args): protocol.HttpActionRequest => ({
|
|
335
|
-
args: bufferToArrayBuffer(
|
|
346
|
+
args: bufferToArrayBuffer(
|
|
347
|
+
encodeCborCompat(args as JsonCompatValue),
|
|
348
|
+
),
|
|
336
349
|
}),
|
|
337
|
-
responseFromJson: (json): Response =>
|
|
350
|
+
responseFromJson: (json): Response =>
|
|
351
|
+
json.output as Response,
|
|
338
352
|
responseFromBare: (bare): Response =>
|
|
339
353
|
decodeCborCompat(new Uint8Array(bare.output)),
|
|
340
354
|
});
|
|
@@ -343,10 +357,8 @@ export class ActorHandleRaw {
|
|
|
343
357
|
}
|
|
344
358
|
return output;
|
|
345
359
|
} catch (err) {
|
|
346
|
-
const { group, code, message, metadata, actor } =
|
|
347
|
-
err,
|
|
348
|
-
true,
|
|
349
|
-
);
|
|
360
|
+
const { group, code, message, metadata, actor } =
|
|
361
|
+
deconstructError(err, true);
|
|
350
362
|
|
|
351
363
|
if (
|
|
352
364
|
await this.#shouldRetrySchedulingError(
|
|
@@ -390,14 +402,19 @@ export class ActorHandleRaw {
|
|
|
390
402
|
);
|
|
391
403
|
}
|
|
392
404
|
|
|
393
|
-
const invalidated = this.#invalidateResolvedActorId(
|
|
405
|
+
const invalidated = this.#invalidateResolvedActorId(
|
|
406
|
+
group,
|
|
407
|
+
code,
|
|
408
|
+
);
|
|
394
409
|
if (invalidated && attempt < maxAttempts - 1) {
|
|
395
410
|
if (
|
|
396
411
|
group === "actor" &&
|
|
397
412
|
(code === "starting" || code === "stopping")
|
|
398
413
|
) {
|
|
399
414
|
useQueryTarget = true;
|
|
400
|
-
await new Promise((resolve) =>
|
|
415
|
+
await new Promise((resolve) =>
|
|
416
|
+
setTimeout(resolve, 100),
|
|
417
|
+
);
|
|
401
418
|
}
|
|
402
419
|
continue;
|
|
403
420
|
}
|
|
@@ -662,10 +679,8 @@ export class ActorHandleRaw {
|
|
|
662
679
|
}
|
|
663
680
|
return response;
|
|
664
681
|
} catch (err) {
|
|
665
|
-
const { group, code, message, metadata, actor } =
|
|
666
|
-
err,
|
|
667
|
-
true,
|
|
668
|
-
);
|
|
682
|
+
const { group, code, message, metadata, actor } =
|
|
683
|
+
deconstructError(err, true);
|
|
669
684
|
|
|
670
685
|
if (
|
|
671
686
|
await this.#shouldRetrySchedulingError(
|
|
@@ -695,12 +710,15 @@ export class ActorHandleRaw {
|
|
|
695
710
|
continue;
|
|
696
711
|
}
|
|
697
712
|
|
|
698
|
-
const invalidated = this.#invalidateResolvedActorId(
|
|
713
|
+
const invalidated = this.#invalidateResolvedActorId(
|
|
714
|
+
group,
|
|
715
|
+
code,
|
|
716
|
+
);
|
|
699
717
|
if (invalidated && attempt < maxAttempts - 1) {
|
|
700
718
|
useQueryTarget =
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
719
|
+
code === "starting" ||
|
|
720
|
+
code === "stopping" ||
|
|
721
|
+
code.startsWith("destroyed_");
|
|
704
722
|
if (useQueryTarget) {
|
|
705
723
|
await this.#waitForRetryWindow();
|
|
706
724
|
}
|
|
@@ -719,13 +737,10 @@ export class ActorHandleRaw {
|
|
|
719
737
|
actorId: string | undefined,
|
|
720
738
|
attempt: number,
|
|
721
739
|
maxAttempts: number,
|
|
722
|
-
): Promise<
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
}
|
|
727
|
-
| null
|
|
728
|
-
> {
|
|
740
|
+
): Promise<{
|
|
741
|
+
useQueryTarget: boolean;
|
|
742
|
+
waitForRetryWindow: boolean;
|
|
743
|
+
} | null> {
|
|
729
744
|
if (response.ok || !isDynamicActorQuery(this.#actorResolutionState)) {
|
|
730
745
|
return null;
|
|
731
746
|
}
|
|
@@ -857,8 +872,9 @@ export class ActorHandleRaw {
|
|
|
857
872
|
this.#gatewayOptions,
|
|
858
873
|
options,
|
|
859
874
|
);
|
|
875
|
+
const useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
|
|
860
876
|
const target = await this.#resolveGatewayRequestTarget(
|
|
861
|
-
|
|
877
|
+
useQueryTarget,
|
|
862
878
|
gatewayOptions,
|
|
863
879
|
);
|
|
864
880
|
return await rawWebSocket(
|
|
@@ -884,7 +900,9 @@ export class ActorHandleRaw {
|
|
|
884
900
|
return target.directId;
|
|
885
901
|
}
|
|
886
902
|
|
|
887
|
-
throw new Error(
|
|
903
|
+
throw new Error(
|
|
904
|
+
"dynamic actor resolution did not produce a direct actor id",
|
|
905
|
+
);
|
|
888
906
|
}
|
|
889
907
|
|
|
890
908
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as errors from "@/actor/errors";
|
|
2
|
+
import type { ActorQuery } from "@/client/query";
|
|
2
3
|
import { stringifyError } from "@/common/utils";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type {
|
|
5
|
+
EngineControlClient,
|
|
6
|
+
GatewayTarget,
|
|
6
7
|
} from "@/engine-client/driver";
|
|
7
|
-
import type
|
|
8
|
-
import { actorSchedulingError, type ActorSchedulingError } from "./errors";
|
|
8
|
+
import { type ActorSchedulingError, actorSchedulingError } from "./errors";
|
|
9
9
|
import { logger } from "./log";
|
|
10
10
|
|
|
11
11
|
/**
|
package/src/client/errors.ts
CHANGED
|
@@ -162,6 +162,7 @@ function classifyActorError(
|
|
|
162
162
|
function isRetryableGuardGatewayHttpError(code: string): boolean {
|
|
163
163
|
return (
|
|
164
164
|
code === "service_unavailable" ||
|
|
165
|
+
code === "actor_wake_retries_exceeded" ||
|
|
165
166
|
code === "actor_stopped_while_waiting" ||
|
|
166
167
|
code === "tunnel_request_aborted" ||
|
|
167
168
|
code === "tunnel_message_timeout" ||
|
|
@@ -299,10 +300,7 @@ export async function retryOnLifecycleBoundary<T>(
|
|
|
299
300
|
break;
|
|
300
301
|
}
|
|
301
302
|
|
|
302
|
-
const delayMs = Math.min(
|
|
303
|
-
initialDelayMs * 2 ** attempt,
|
|
304
|
-
maxDelayMs,
|
|
305
|
-
);
|
|
303
|
+
const delayMs = Math.min(initialDelayMs * 2 ** attempt, maxDelayMs);
|
|
306
304
|
await waitWithSignal(delayMs, opts?.signal);
|
|
307
305
|
}
|
|
308
306
|
}
|
package/src/client/query.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
|
-
import { EncodingSchema } from "@/common/encoding";
|
|
3
2
|
import {
|
|
4
3
|
HEADER_ACTOR_ID,
|
|
5
4
|
HEADER_ACTOR_QUERY,
|
|
6
5
|
HEADER_CONN_PARAMS,
|
|
7
6
|
HEADER_ENCODING,
|
|
8
7
|
} from "@/common/actor-router-consts";
|
|
8
|
+
import { EncodingSchema } from "@/common/encoding";
|
|
9
9
|
|
|
10
10
|
// Maximum size of a key component in bytes
|
|
11
11
|
// Set to 128 bytes to allow for separators and escape characters in the full key
|
package/src/client/queue.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
HEADER_CONN_PARAMS,
|
|
3
|
+
HEADER_ENCODING,
|
|
4
|
+
} from "@/common/actor-router-consts";
|
|
3
5
|
import type * as protocol from "@/common/client-protocol";
|
|
4
6
|
import {
|
|
5
7
|
CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
type HttpQueueSendResponse as HttpQueueSendResponseJson,
|
|
13
15
|
HttpQueueSendResponseSchema,
|
|
14
16
|
} from "@/common/client-protocol-zod";
|
|
17
|
+
import type { Encoding, JsonCompatValue } from "@/common/encoding";
|
|
15
18
|
import { decodeCborCompat, encodeCborCompat } from "@/serde";
|
|
16
19
|
import { bufferToArrayBuffer } from "@/utils";
|
|
17
20
|
import { sendHttpRequest } from "./utils";
|
|
@@ -111,7 +114,9 @@ export function createQueueSender(
|
|
|
111
114
|
}),
|
|
112
115
|
requestToBare: (value): protocol.HttpQueueSendRequest => ({
|
|
113
116
|
name: value.name ?? name,
|
|
114
|
-
body: bufferToArrayBuffer(
|
|
117
|
+
body: bufferToArrayBuffer(
|
|
118
|
+
encodeCborCompat(value.body as JsonCompatValue),
|
|
119
|
+
),
|
|
115
120
|
wait: value.wait ?? false,
|
|
116
121
|
timeout:
|
|
117
122
|
value.timeout !== undefined ? BigInt(value.timeout) : null,
|
package/src/client/raw-utils.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { PATH_WEBSOCKET_PREFIX } from "@/common/actor-router-consts";
|
|
2
|
-
import { deconstructError } from "@/common/utils";
|
|
3
1
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
HEADER_CONN_PARAMS,
|
|
3
|
+
PATH_WEBSOCKET_PREFIX,
|
|
4
|
+
} from "@/common/actor-router-consts";
|
|
5
|
+
import { deconstructError } from "@/common/utils";
|
|
6
|
+
import type {
|
|
7
|
+
EngineControlClient,
|
|
8
|
+
GatewayRequestOptions,
|
|
9
|
+
GatewayTarget,
|
|
7
10
|
} from "@/engine-client/driver";
|
|
8
|
-
import { HEADER_CONN_PARAMS } from "@/common/actor-router-consts";
|
|
9
11
|
import { ActorError } from "./errors";
|
|
10
12
|
import { logger } from "./log";
|
|
11
13
|
|
package/src/client/utils.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
2
|
import type { VersionedDataHandler } from "vbare";
|
|
3
3
|
import type { z } from "zod/v4";
|
|
4
|
+
import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/common/client-protocol-versioned";
|
|
5
|
+
import { HttpResponseErrorSchema } from "@/common/client-protocol-zod";
|
|
4
6
|
import type { Encoding } from "@/common/encoding";
|
|
5
7
|
import { assertUnreachable } from "@/common/utils";
|
|
6
|
-
import type { HttpResponseError } from "@/common/client-protocol";
|
|
7
|
-
import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/common/client-protocol-versioned";
|
|
8
|
-
import {
|
|
9
|
-
type HttpResponseError as HttpResponseErrorJson,
|
|
10
|
-
HttpResponseErrorSchema,
|
|
11
|
-
} from "@/common/client-protocol-zod";
|
|
12
8
|
import {
|
|
13
9
|
contentTypeForEncoding,
|
|
14
10
|
decodeCborCompat,
|
|
15
11
|
deserializeWithEncoding,
|
|
16
|
-
encodingIsBinary,
|
|
17
12
|
serializeWithEncoding,
|
|
18
13
|
} from "@/serde";
|
|
19
14
|
import { httpUserAgent } from "@/utils";
|
|
@@ -30,7 +30,9 @@ export function parseWebSocketProtocols(
|
|
|
30
30
|
let ackHookTokenRaw: string | undefined;
|
|
31
31
|
|
|
32
32
|
if (protocols) {
|
|
33
|
-
for (const protocol of protocols
|
|
33
|
+
for (const protocol of protocols
|
|
34
|
+
.split(",")
|
|
35
|
+
.map((value) => value.trim())) {
|
|
34
36
|
if (protocol.startsWith(WS_PROTOCOL_ENCODING)) {
|
|
35
37
|
encodingRaw = protocol.substring(WS_PROTOCOL_ENCODING.length);
|
|
36
38
|
} else if (protocol.startsWith(WS_PROTOCOL_CONN_PARAMS)) {
|