rivetkit 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.ea644f1
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 +561 -89
- package/dist/browser/client.js +1063 -430
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +22 -2
- package/dist/browser/inspector/client.js +1036 -232
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +6 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +2232 -2082
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +556 -85
- package/dist/tsup/agent-os/index.d.ts +556 -85
- package/dist/tsup/agent-os/index.js +2234 -2084
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-7MRGNVSR.js → chunk-3GLNEWGY.js} +78 -6
- package/dist/tsup/chunk-3GLNEWGY.js.map +1 -0
- package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-4FC7TVS6.cjs} +35 -10
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
- package/dist/tsup/{chunk-XNZR7UD2.cjs → chunk-7DDQA6KN.cjs} +90 -65
- package/dist/tsup/chunk-7DDQA6KN.cjs.map +1 -0
- package/dist/tsup/{chunk-NFC5VU36.cjs → chunk-AESHILFV.cjs} +18 -10
- package/dist/tsup/chunk-AESHILFV.cjs.map +1 -0
- package/dist/tsup/{chunk-D4TSTM6C.js → chunk-EFQCNJ23.js} +83 -58
- package/dist/tsup/chunk-EFQCNJ23.js.map +1 -0
- package/dist/tsup/{chunk-OIKOPSXQ.js → chunk-FUS4OFX5.js} +12 -4
- package/dist/tsup/chunk-FUS4OFX5.js.map +1 -0
- package/dist/tsup/{chunk-IOYKCB6Y.cjs → chunk-GUCITCR3.cjs} +44 -9
- package/dist/tsup/chunk-GUCITCR3.cjs.map +1 -0
- package/dist/tsup/{chunk-3BFYSYRU.js → chunk-HXUEHHJF.js} +3 -2
- package/dist/tsup/chunk-HXUEHHJF.js.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-KSG2COSQ.js → chunk-KYBAXJRA.js} +6 -6
- package/dist/tsup/chunk-KYBAXJRA.js.map +1 -0
- package/dist/tsup/{chunk-LNMB25HW.js → chunk-LMUEIJUM.js} +780 -183
- package/dist/tsup/chunk-LMUEIJUM.js.map +1 -0
- package/dist/tsup/{chunk-RZEJJJKU.js → chunk-LTMSYD2A.js} +42 -7
- package/dist/tsup/chunk-LTMSYD2A.js.map +1 -0
- package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-OAPVVVTX.cjs} +79 -7
- package/dist/tsup/chunk-OAPVVVTX.cjs.map +1 -0
- package/dist/tsup/{chunk-D2TLG75Y.cjs → chunk-TIUL6FNF.cjs} +10 -10
- package/dist/tsup/chunk-TIUL6FNF.cjs.map +1 -0
- package/dist/tsup/{chunk-POTPHU3P.cjs → chunk-UYT2CIWO.cjs} +3 -3
- package/dist/tsup/{chunk-POTPHU3P.cjs.map → chunk-UYT2CIWO.cjs.map} +1 -1
- package/dist/tsup/{chunk-TPBHXFB2.cjs → chunk-VDTC257X.cjs} +138 -24
- package/dist/tsup/chunk-VDTC257X.cjs.map +1 -0
- package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-VE2X4KMG.cjs} +3 -2
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +1 -0
- package/dist/tsup/{chunk-22XU3BVY.cjs → chunk-VWOA7DRK.cjs} +925 -328
- package/dist/tsup/chunk-VWOA7DRK.cjs.map +1 -0
- package/dist/tsup/{chunk-4ZIWB4CQ.js → chunk-VYQASICJ.js} +2 -2
- package/dist/tsup/{chunk-W54QCENI.js → chunk-X4BXYDTG.js} +134 -20
- package/dist/tsup/chunk-X4BXYDTG.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/{chunk-K34B3OVG.js → chunk-ZZ3WBRPD.js} +34 -9
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +8 -9
- package/dist/tsup/client/mod.d.ts +8 -9
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-CRdGwwbr.d.cts → config-CxG53eQo.d.cts} +577 -36
- package/dist/tsup/{config-kxXbtrJU.d.ts → config-DLOxy81E.d.cts} +5 -5
- package/dist/tsup/{config-kxXbtrJU.d.cts → config-DLOxy81E.d.ts} +5 -5
- package/dist/tsup/{config-DIpBWm5C.d.ts → config-Ds6DCRhV.d.ts} +577 -36
- package/dist/tsup/context-8KlcOYIs.d.cts +129 -0
- package/dist/tsup/context-Cfbm4QLr.d.ts +129 -0
- package/dist/tsup/db/drizzle.cjs +164 -78
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +4 -2
- package/dist/tsup/db/drizzle.d.ts +4 -2
- package/dist/tsup/db/drizzle.js +164 -78
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +93 -24
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +92 -23
- package/dist/tsup/db/mod.js.map +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 +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +37 -15
- package/dist/tsup/inspector/mod.d.ts +37 -15
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector-tab/mod.cjs +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +240 -0
- package/dist/tsup/inspector-tab/mod.d.ts +240 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +1078 -479
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -6
- package/dist/tsup/mod.d.ts +5 -6
- package/dist/tsup/mod.js +996 -397
- 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 -5
- package/dist/tsup/test/mod.d.ts +4 -5
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
- package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
- 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 +386 -322
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +8 -9
- package/dist/tsup/workflow/mod.d.ts +8 -9
- package/dist/tsup/workflow/mod.js +363 -299
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +35 -14
- package/src/actor/config.ts +188 -59
- 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 +70 -7
- package/src/actor/instance/mod.ts +39 -56
- package/src/actor/keys.ts +2 -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 +88 -62
- package/src/client/actor-conn.ts +58 -63
- package/src/client/actor-handle.ts +125 -71
- package/src/client/actor-query.ts +5 -5
- package/src/client/config.ts +3 -3
- package/src/client/errors.ts +2 -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 +10 -10
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +34 -10
- package/src/common/actor-router-consts.ts +7 -4
- 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/generated/actor-uds-protocol/v1.ts +802 -0
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +176 -67
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/config.ts +16 -5
- package/src/common/database/mod.test.ts +137 -16
- package/src/common/database/mod.ts +100 -30
- package/src/common/database/native-database.test.ts +35 -22
- package/src/common/database/native-database.ts +26 -10
- 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 +15 -8
- package/src/common/router.ts +49 -23
- package/src/common/utils.ts +10 -202
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.ts +194 -95
- 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 +76 -73
- 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 +6 -9
- package/src/engine-client/actor-websocket-client.ts +14 -13
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +3 -4
- package/src/engine-client/mod.ts +17 -10
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +66 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector-tab/mod.ts +300 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +46 -20
- package/src/registry/index.ts +364 -87
- package/src/registry/napi-runtime.ts +97 -8
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +592 -343
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +85 -6
- package/src/registry/wasm-runtime.ts +72 -3
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +19 -8
- package/src/test/mod.ts +11 -8
- package/src/utils/crypto.ts +14 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +37 -0
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +703 -240
- package/src/workflow/driver.ts +23 -12
- package/src/workflow/inspector.ts +12 -3
- package/src/workflow/mod.ts +37 -23
- package/dist/tsup/chunk-22XU3BVY.cjs.map +0 -1
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
- package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
- package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
- package/dist/tsup/chunk-D2TLG75Y.cjs.map +0 -1
- package/dist/tsup/chunk-D4TSTM6C.js.map +0 -1
- package/dist/tsup/chunk-IOYKCB6Y.cjs.map +0 -1
- package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
- package/dist/tsup/chunk-KSG2COSQ.js.map +0 -1
- package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
- package/dist/tsup/chunk-LNMB25HW.js.map +0 -1
- package/dist/tsup/chunk-NFC5VU36.cjs.map +0 -1
- package/dist/tsup/chunk-OIKOPSXQ.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-RZEJJJKU.js.map +0 -1
- package/dist/tsup/chunk-TPBHXFB2.cjs.map +0 -1
- package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
- package/dist/tsup/chunk-W54QCENI.js.map +0 -1
- package/dist/tsup/chunk-XNZR7UD2.cjs.map +0 -1
- package/dist/tsup/context-B7G6sk7x.d.ts +0 -92
- package/dist/tsup/context-DzMRHkjC.d.cts +0 -92
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- package/src/utils/serve.ts +0 -217
- /package/dist/tsup/{chunk-4ZIWB4CQ.js.map → chunk-VYQASICJ.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
BaseActorDefinition,
|
|
3
2
|
AnyActorDefinition,
|
|
3
|
+
BaseActorDefinition,
|
|
4
4
|
} from "@/actor/definition";
|
|
5
5
|
import type {
|
|
6
6
|
EventSchemaConfig,
|
|
@@ -31,8 +31,37 @@ export type ActorActionFunction<
|
|
|
31
31
|
...args: Args extends [unknown, ...infer Rest] ? Rest : Args
|
|
32
32
|
) => Promise<Response>;
|
|
33
33
|
|
|
34
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
35
|
+
|
|
36
|
+
type LooseEventSubscribe = (
|
|
37
|
+
eventName: string,
|
|
38
|
+
callback: (...args: any[]) => void,
|
|
39
|
+
) => () => void;
|
|
40
|
+
|
|
41
|
+
type ActorActionMap<R> = {
|
|
42
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (
|
|
43
|
+
...args: infer Args
|
|
44
|
+
) => infer Return
|
|
45
|
+
? ActorActionFunction<Args, Awaited<Return>>
|
|
46
|
+
: never;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type ActionsOf<AD extends AnyActorDefinition> =
|
|
50
|
+
AD extends BaseActorDefinition<
|
|
51
|
+
any,
|
|
52
|
+
any,
|
|
53
|
+
any,
|
|
54
|
+
any,
|
|
55
|
+
any,
|
|
56
|
+
any,
|
|
57
|
+
any,
|
|
58
|
+
any,
|
|
59
|
+
infer R
|
|
60
|
+
>
|
|
61
|
+
? R
|
|
62
|
+
: never;
|
|
63
|
+
|
|
34
64
|
export interface ActorGatewayOptions {
|
|
35
|
-
bypassConnectable?: boolean;
|
|
36
65
|
skipReadyWait?: boolean;
|
|
37
66
|
}
|
|
38
67
|
|
|
@@ -42,16 +71,11 @@ export function resolveActorGatewayOptions(
|
|
|
42
71
|
defaults: ActorGatewayOptions = {},
|
|
43
72
|
overrides?: ActorGatewayOptions,
|
|
44
73
|
): ResolvedActorGatewayOptions {
|
|
45
|
-
const
|
|
46
|
-
overrides?.
|
|
47
|
-
overrides?.skipReadyWait ??
|
|
48
|
-
defaults.bypassConnectable ??
|
|
49
|
-
defaults.skipReadyWait ??
|
|
50
|
-
false;
|
|
74
|
+
const skipReadyWait =
|
|
75
|
+
overrides?.skipReadyWait ?? defaults.skipReadyWait ?? false;
|
|
51
76
|
|
|
52
77
|
return {
|
|
53
|
-
|
|
54
|
-
skipReadyWait: bypassConnectable,
|
|
78
|
+
skipReadyWait,
|
|
55
79
|
};
|
|
56
80
|
}
|
|
57
81
|
|
|
@@ -70,25 +94,9 @@ export type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
70
94
|
*/
|
|
71
95
|
export type ActorDefinitionActions<AD extends AnyActorDefinition> =
|
|
72
96
|
// biome-ignore lint/suspicious/noExplicitAny: safe to use any here
|
|
73
|
-
AD extends
|
|
74
|
-
any,
|
|
75
|
-
|
|
76
|
-
any,
|
|
77
|
-
any,
|
|
78
|
-
any,
|
|
79
|
-
any,
|
|
80
|
-
any,
|
|
81
|
-
any,
|
|
82
|
-
infer R
|
|
83
|
-
>
|
|
84
|
-
? {
|
|
85
|
-
[K in keyof R]: R[K] extends (
|
|
86
|
-
...args: infer Args
|
|
87
|
-
) => infer Return
|
|
88
|
-
? ActorActionFunction<Args, Return>
|
|
89
|
-
: never;
|
|
90
|
-
}
|
|
91
|
-
: never;
|
|
97
|
+
IsAny<AD> extends true
|
|
98
|
+
? Record<string, ActorActionFunction<any[], any>>
|
|
99
|
+
: ActorActionMap<ActionsOf<AD>>;
|
|
92
100
|
|
|
93
101
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
94
102
|
<K extends keyof TQueues & string>(
|
|
@@ -126,39 +134,57 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
|
126
134
|
|
|
127
135
|
export type ActorDefinitionQueueSend<AD extends AnyActorDefinition> =
|
|
128
136
|
// biome-ignore lint/suspicious/noExplicitAny: safe to use any here
|
|
129
|
-
AD extends
|
|
130
|
-
any
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
IsAny<AD> extends true
|
|
138
|
+
? { send: ActorQueueSend<Record<string, any>> }
|
|
139
|
+
: AD extends { config: { queues?: infer Q } }
|
|
140
|
+
? Q extends QueueSchemaConfig
|
|
141
|
+
? { send: ActorQueueSend<Q> }
|
|
142
|
+
: {}
|
|
143
|
+
: AD extends BaseActorDefinition<
|
|
144
|
+
any,
|
|
145
|
+
any,
|
|
146
|
+
any,
|
|
147
|
+
any,
|
|
148
|
+
any,
|
|
149
|
+
any,
|
|
150
|
+
any,
|
|
151
|
+
infer Q,
|
|
152
|
+
any
|
|
153
|
+
>
|
|
154
|
+
? Q extends QueueSchemaConfig
|
|
155
|
+
? { send: ActorQueueSend<Q> }
|
|
156
|
+
: {}
|
|
157
|
+
: {};
|
|
144
158
|
|
|
145
159
|
export type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> =
|
|
146
160
|
// biome-ignore lint/suspicious/noExplicitAny: safe to use any here
|
|
147
|
-
AD extends
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
IsAny<AD> extends true
|
|
162
|
+
? {
|
|
163
|
+
on: LooseEventSubscribe;
|
|
164
|
+
once: LooseEventSubscribe;
|
|
165
|
+
}
|
|
166
|
+
: AD extends { config: { events?: infer E } }
|
|
167
|
+
? E extends EventSchemaConfig
|
|
168
|
+
? {
|
|
169
|
+
on: ActorEventSubscribe<E>;
|
|
170
|
+
once: ActorEventSubscribe<E>;
|
|
171
|
+
}
|
|
172
|
+
: {}
|
|
173
|
+
: AD extends BaseActorDefinition<
|
|
174
|
+
any,
|
|
175
|
+
any,
|
|
176
|
+
any,
|
|
177
|
+
any,
|
|
178
|
+
any,
|
|
179
|
+
any,
|
|
180
|
+
infer E,
|
|
181
|
+
any,
|
|
182
|
+
any
|
|
183
|
+
>
|
|
184
|
+
? E extends EventSchemaConfig
|
|
185
|
+
? {
|
|
186
|
+
on: ActorEventSubscribe<E>;
|
|
187
|
+
once: ActorEventSubscribe<E>;
|
|
188
|
+
}
|
|
189
|
+
: {}
|
|
190
|
+
: {};
|
package/src/client/actor-conn.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type ToServer as ToServerJson,
|
|
15
15
|
ToServerSchema,
|
|
16
16
|
} from "@/common/client-protocol-zod";
|
|
17
|
+
import type { JsonCompatValue } from "@/common/encoding";
|
|
17
18
|
import {
|
|
18
19
|
type Encoding,
|
|
19
20
|
inputDataToBuffer,
|
|
@@ -56,7 +57,6 @@ import {
|
|
|
56
57
|
type QueueSendResult,
|
|
57
58
|
type QueueSendWaitOptions,
|
|
58
59
|
} from "./queue";
|
|
59
|
-
import { resolveGatewayTarget } from "./resolve-gateway-target";
|
|
60
60
|
import {
|
|
61
61
|
type WebSocketMessage as ConnMessage,
|
|
62
62
|
messageLength,
|
|
@@ -94,8 +94,6 @@ interface EventSubscriptions<Args extends Array<unknown>> {
|
|
|
94
94
|
once: boolean;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
const DEFAULT_MAX_INCOMING_MESSAGE_SIZE = 65_536;
|
|
98
|
-
|
|
99
97
|
/**
|
|
100
98
|
* A function that unsubscribes from an event.
|
|
101
99
|
*
|
|
@@ -217,6 +215,9 @@ export class ActorConnRaw {
|
|
|
217
215
|
this.#encoding = encoding;
|
|
218
216
|
this.#actorResolutionState = actorResolutionState;
|
|
219
217
|
this.#gatewayOptions = resolveActorGatewayOptions(gatewayOptions);
|
|
218
|
+
if ("getForId" in actorResolutionState) {
|
|
219
|
+
this.#actorId = actorResolutionState.getForId.actorId;
|
|
220
|
+
}
|
|
220
221
|
this.#readyPromise = promiseWithResolvers((reason) =>
|
|
221
222
|
logger().warn({
|
|
222
223
|
msg: "unhandled ready promise rejection",
|
|
@@ -578,9 +579,7 @@ export class ActorConnRaw {
|
|
|
578
579
|
|
|
579
580
|
async #connectWebSocket() {
|
|
580
581
|
const params = await this.#resolveConnectionParams();
|
|
581
|
-
const target = this.#
|
|
582
|
-
? await this.#resolveGatewayTargetForBypass()
|
|
583
|
-
: getGatewayTarget(this.#actorResolutionState);
|
|
582
|
+
const target = getGatewayTarget(this.#actorResolutionState);
|
|
584
583
|
const ws = await this.#driver.openWebSocket(
|
|
585
584
|
PATH_CONNECT,
|
|
586
585
|
target,
|
|
@@ -634,25 +633,6 @@ export class ActorConnRaw {
|
|
|
634
633
|
});
|
|
635
634
|
}
|
|
636
635
|
|
|
637
|
-
async #resolveGatewayTargetForBypass() {
|
|
638
|
-
if ("getForId" in this.#actorResolutionState) {
|
|
639
|
-
return {
|
|
640
|
-
directId: this.#actorResolutionState.getForId.actorId,
|
|
641
|
-
} as const;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
if (this.#actorId) {
|
|
645
|
-
return { directId: this.#actorId } as const;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
return {
|
|
649
|
-
directId: await resolveGatewayTarget(
|
|
650
|
-
this.#driver,
|
|
651
|
-
this.#actorResolutionState,
|
|
652
|
-
),
|
|
653
|
-
} as const;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
636
|
/** Called by the onopen event from drivers. */
|
|
657
637
|
#handleOnOpen() {
|
|
658
638
|
// Connection was disposed before Init message arrived - close the websocket to avoid leak
|
|
@@ -754,7 +734,7 @@ export class ActorConnRaw {
|
|
|
754
734
|
this.#handleOnOpen();
|
|
755
735
|
} else if (response.body.tag === "Error") {
|
|
756
736
|
// Connection error
|
|
757
|
-
const { group, code, message, metadata, actionId } =
|
|
737
|
+
const { group, code, message, metadata, actionId, actor } =
|
|
758
738
|
response.body.val;
|
|
759
739
|
|
|
760
740
|
if (actionId !== null) {
|
|
@@ -769,10 +749,16 @@ export class ActorConnRaw {
|
|
|
769
749
|
code,
|
|
770
750
|
message,
|
|
771
751
|
metadata,
|
|
752
|
+
actorId: actor?.actorId,
|
|
753
|
+
generation: actor?.generation,
|
|
754
|
+
actorKey: actor?.key,
|
|
772
755
|
});
|
|
773
756
|
|
|
774
757
|
inFlight.reject(
|
|
775
|
-
new errors.ActorError(group, code, message,
|
|
758
|
+
new errors.ActorError(group, code, message, {
|
|
759
|
+
metadata,
|
|
760
|
+
actor,
|
|
761
|
+
}),
|
|
776
762
|
);
|
|
777
763
|
} else {
|
|
778
764
|
logger().warn({
|
|
@@ -781,23 +767,27 @@ export class ActorConnRaw {
|
|
|
781
767
|
code,
|
|
782
768
|
message,
|
|
783
769
|
metadata,
|
|
770
|
+
actorId: actor?.actorId,
|
|
771
|
+
generation: actor?.generation,
|
|
772
|
+
actorKey: actor?.key,
|
|
784
773
|
});
|
|
785
774
|
|
|
786
775
|
if (this.#shouldReconnectForStaleActor(group, code)) {
|
|
787
776
|
this.#clearResolvedActorIdentity();
|
|
788
777
|
this.#onOpenPromise?.reject(
|
|
789
|
-
new errors.ActorError(group, code, message,
|
|
778
|
+
new errors.ActorError(group, code, message, {
|
|
779
|
+
metadata,
|
|
780
|
+
actor,
|
|
781
|
+
}),
|
|
790
782
|
);
|
|
791
783
|
return;
|
|
792
784
|
}
|
|
793
785
|
|
|
794
786
|
// Check if this is an actor scheduling error and try to get more details
|
|
795
|
-
let errorToThrow = new errors.ActorError(
|
|
796
|
-
group,
|
|
797
|
-
code,
|
|
798
|
-
message,
|
|
787
|
+
let errorToThrow = new errors.ActorError(group, code, message, {
|
|
799
788
|
metadata,
|
|
800
|
-
|
|
789
|
+
actor,
|
|
790
|
+
});
|
|
801
791
|
if (errors.isSchedulingError(group, code) && this.#actorId) {
|
|
802
792
|
const schedulingError = await checkForSchedulingError(
|
|
803
793
|
group,
|
|
@@ -1279,7 +1269,8 @@ export class ActorConnRaw {
|
|
|
1279
1269
|
name: msg.body.val.name,
|
|
1280
1270
|
args: bufferToArrayBuffer(
|
|
1281
1271
|
encodeCborCompat(
|
|
1282
|
-
msg.body.val
|
|
1272
|
+
msg.body.val
|
|
1273
|
+
.args as JsonCompatValue,
|
|
1283
1274
|
),
|
|
1284
1275
|
),
|
|
1285
1276
|
},
|
|
@@ -1290,34 +1281,8 @@ export class ActorConnRaw {
|
|
|
1290
1281
|
}
|
|
1291
1282
|
},
|
|
1292
1283
|
);
|
|
1293
|
-
const serializedLength = messageLength(messageSerialized);
|
|
1294
|
-
if (
|
|
1295
|
-
serializedLength > DEFAULT_MAX_INCOMING_MESSAGE_SIZE &&
|
|
1296
|
-
message.body.tag === "ActionRequest"
|
|
1297
|
-
) {
|
|
1298
|
-
const actionId = Number(message.body.val.id);
|
|
1299
|
-
const inFlight = this.#takeActionInFlight(actionId);
|
|
1300
|
-
const error = new errors.ActorError(
|
|
1301
|
-
"message",
|
|
1302
|
-
"incoming_too_long",
|
|
1303
|
-
"Incoming message too long",
|
|
1304
|
-
{
|
|
1305
|
-
maxSize: DEFAULT_MAX_INCOMING_MESSAGE_SIZE,
|
|
1306
|
-
actualSize: serializedLength,
|
|
1307
|
-
},
|
|
1308
|
-
);
|
|
1309
|
-
logger().warn({
|
|
1310
|
-
msg: "rejecting oversized connection action request",
|
|
1311
|
-
actionId,
|
|
1312
|
-
actionName: inFlight.name,
|
|
1313
|
-
actualSize: serializedLength,
|
|
1314
|
-
maxSize: DEFAULT_MAX_INCOMING_MESSAGE_SIZE,
|
|
1315
|
-
});
|
|
1316
|
-
inFlight.reject(error);
|
|
1317
|
-
this.#dispatchActorError(error);
|
|
1318
|
-
return;
|
|
1319
|
-
}
|
|
1320
1284
|
this.#websocket.send(messageSerialized);
|
|
1285
|
+
const serializedLength = messageLength(messageSerialized);
|
|
1321
1286
|
logger().trace({
|
|
1322
1287
|
msg: "sent websocket message",
|
|
1323
1288
|
len: serializedLength,
|
|
@@ -1368,6 +1333,7 @@ export class ActorConnRaw {
|
|
|
1368
1333
|
message: string;
|
|
1369
1334
|
metadata: unknown;
|
|
1370
1335
|
actionId: bigint | null;
|
|
1336
|
+
actor?: errors.ActorSpecifier;
|
|
1371
1337
|
};
|
|
1372
1338
|
}
|
|
1373
1339
|
| { tag: "ActionResponse"; val: { id: bigint; output: unknown } }
|
|
@@ -1382,8 +1348,26 @@ export class ActorConnRaw {
|
|
|
1382
1348
|
buffer,
|
|
1383
1349
|
CLIENT_PROTOCOL_TO_CLIENT,
|
|
1384
1350
|
ToClientSchema,
|
|
1385
|
-
// JSON:
|
|
1386
|
-
(msg):
|
|
1351
|
+
// JSON/CBOR: normalize actor generation to the public number shape.
|
|
1352
|
+
(msg): any => {
|
|
1353
|
+
if (msg.body.tag !== "Error" || !msg.body.val.actor) {
|
|
1354
|
+
return msg as ToClientJson;
|
|
1355
|
+
}
|
|
1356
|
+
return {
|
|
1357
|
+
body: {
|
|
1358
|
+
tag: "Error",
|
|
1359
|
+
val: {
|
|
1360
|
+
...msg.body.val,
|
|
1361
|
+
actor: {
|
|
1362
|
+
...msg.body.val.actor,
|
|
1363
|
+
generation: Number(
|
|
1364
|
+
msg.body.val.actor.generation,
|
|
1365
|
+
),
|
|
1366
|
+
},
|
|
1367
|
+
},
|
|
1368
|
+
},
|
|
1369
|
+
};
|
|
1370
|
+
},
|
|
1387
1371
|
// BARE: need to decode ArrayBuffer fields back to unknown
|
|
1388
1372
|
(msg): any => {
|
|
1389
1373
|
if (msg.body.tag === "Error") {
|
|
@@ -1402,6 +1386,17 @@ export class ActorConnRaw {
|
|
|
1402
1386
|
)
|
|
1403
1387
|
: null,
|
|
1404
1388
|
actionId: msg.body.val.actionId,
|
|
1389
|
+
actor: msg.body.val.actor
|
|
1390
|
+
? {
|
|
1391
|
+
actorId: msg.body.val.actor.actorId,
|
|
1392
|
+
generation: Number(
|
|
1393
|
+
msg.body.val.actor.generation,
|
|
1394
|
+
),
|
|
1395
|
+
key:
|
|
1396
|
+
msg.body.val.actor.key ??
|
|
1397
|
+
undefined,
|
|
1398
|
+
}
|
|
1399
|
+
: undefined,
|
|
1405
1400
|
},
|
|
1406
1401
|
},
|
|
1407
1402
|
};
|