rivetkit 2.3.8 → 2.3.10
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 +6 -34
- package/dist/browser/client.js +14 -33
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/agent-os/index.cjs +1 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +6 -34
- package/dist/tsup/agent-os/index.d.ts +6 -34
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-YFXQ7DBH.js → chunk-6UHZLL6S.js} +3 -3
- package/dist/tsup/{chunk-BL6ERZQO.js → chunk-DPM73GAL.js} +18 -39
- package/dist/tsup/chunk-DPM73GAL.js.map +1 -0
- package/dist/tsup/{chunk-MY6BRV3S.js → chunk-E6IEX6AP.js} +3 -3
- package/dist/tsup/{chunk-IJMVVULS.cjs → chunk-G6XA2OSW.cjs} +4 -4
- package/dist/tsup/{chunk-IJMVVULS.cjs.map → chunk-G6XA2OSW.cjs.map} +1 -1
- package/dist/tsup/{chunk-F6GCLL5Z.cjs → chunk-INXPYXN6.cjs} +7 -7
- package/dist/tsup/{chunk-F6GCLL5Z.cjs.map → chunk-INXPYXN6.cjs.map} +1 -1
- package/dist/tsup/{chunk-5MJPN3QU.cjs → chunk-LCWHS6K7.cjs} +152 -173
- package/dist/tsup/chunk-LCWHS6K7.cjs.map +1 -0
- package/dist/tsup/{chunk-7TNEDX3Y.cjs → chunk-PCJSDS7N.cjs} +3 -3
- package/dist/tsup/{chunk-7TNEDX3Y.cjs.map → chunk-PCJSDS7N.cjs.map} +1 -1
- package/dist/tsup/{chunk-V7PJYBA5.js → chunk-Q5H37KNQ.js} +2 -2
- package/dist/tsup/{chunk-TMTJPSHQ.cjs → chunk-U2A3Y7OK.cjs} +9 -9
- package/dist/tsup/{chunk-TMTJPSHQ.cjs.map → chunk-U2A3Y7OK.cjs.map} +1 -1
- package/dist/tsup/{chunk-ZKDZW5DQ.js → chunk-X7XY6NCU.js} +3 -6
- package/dist/tsup/chunk-X7XY6NCU.js.map +1 -0
- package/dist/tsup/{chunk-HWBISPRP.js → chunk-XSPAARQ5.js} +2 -2
- package/dist/tsup/{chunk-NUMGL52R.cjs → chunk-Z2ESFE5Z.cjs} +3 -6
- package/dist/tsup/chunk-Z2ESFE5Z.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-CUymbyM6.d.ts → config-BRpVbJCD.d.ts} +7 -35
- package/dist/tsup/{config-CpB-e4I9.d.cts → config-BobvQpex.d.cts} +7 -35
- package/dist/tsup/{context-YBUBTwTS.d.ts → context-Cj-DFyiy.d.ts} +1 -1
- package/dist/tsup/{context-c-6G4mjk.d.cts → context-YEBNJrws.d.cts} +1 -1
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +1 -1
- package/dist/tsup/inspector/mod.cjs +4 -4
- package/dist/tsup/inspector/mod.js +3 -3
- package/dist/tsup/inspector-tab/mod.d.cts +2 -2
- package/dist/tsup/inspector-tab/mod.d.ts +2 -2
- package/dist/tsup/mod.cjs +124 -449
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +3 -3
- package/dist/tsup/mod.d.ts +3 -3
- package/dist/tsup/mod.js +63 -388
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +6 -6
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +3 -3
- package/package.json +8 -8
- package/src/client/actor-handle.ts +1 -3
- package/src/client/raw-utils.ts +2 -11
- package/src/common/actor-router-consts.ts +0 -1
- package/src/common/encoding.ts +1 -4
- package/src/engine-client/actor-http-client.ts +22 -6
- package/src/registry/index.ts +14 -159
- package/src/registry/napi-runtime.ts +0 -74
- package/src/registry/native.ts +63 -111
- package/src/registry/runtime.ts +0 -35
- package/src/registry/wasm-runtime.ts +0 -11
- package/dist/tsup/chunk-5MJPN3QU.cjs.map +0 -1
- package/dist/tsup/chunk-BL6ERZQO.js.map +0 -1
- package/dist/tsup/chunk-NUMGL52R.cjs.map +0 -1
- package/dist/tsup/chunk-ZKDZW5DQ.js.map +0 -1
- package/src/common/fetch-like.ts +0 -49
- package/src/registry/native-http.ts +0 -208
- /package/dist/tsup/{chunk-YFXQ7DBH.js.map → chunk-6UHZLL6S.js.map} +0 -0
- /package/dist/tsup/{chunk-MY6BRV3S.js.map → chunk-E6IEX6AP.js.map} +0 -0
- /package/dist/tsup/{chunk-V7PJYBA5.js.map → chunk-Q5H37KNQ.js.map} +0 -0
- /package/dist/tsup/{chunk-HWBISPRP.js.map → chunk-XSPAARQ5.js.map} +0 -0
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import type { ResponseLike } from "@/common/fetch-like";
|
|
2
|
-
import { HEADER_ORIGINAL_REQUEST_URL } from "@/common/actor-router-consts";
|
|
3
|
-
import { stringifyError } from "@/common/utils";
|
|
4
|
-
import { logger } from "./log";
|
|
5
|
-
import type { RuntimeBytes, RuntimeHttpResponse } from "./runtime";
|
|
6
|
-
|
|
7
|
-
const HTTP_BODY_CHUNK_SIZE = 64 * 1024;
|
|
8
|
-
|
|
9
|
-
// Structural types keep the HTTP adapter independent of the N-API package.
|
|
10
|
-
export interface NativeHttpResponseBodyStream {
|
|
11
|
-
cancelled(): Promise<void>;
|
|
12
|
-
write(chunk: Uint8Array): Promise<void>;
|
|
13
|
-
end(): Promise<void>;
|
|
14
|
-
error(message: string): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface NativeHttpRequestBodyStream {
|
|
18
|
-
read(): Promise<Uint8Array | null | undefined>;
|
|
19
|
-
cancel(): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface NativeHttpRequestInit {
|
|
23
|
-
method: string;
|
|
24
|
-
uri: string;
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
body?: RuntimeBytes;
|
|
27
|
-
bodyStream?: NativeHttpRequestBodyStream;
|
|
28
|
-
signal?: AbortSignal;
|
|
29
|
-
abortController?: AbortController;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface NativeHttpResponseConversion {
|
|
33
|
-
response: RuntimeHttpResponse;
|
|
34
|
-
// Keeps request-scoped actor resources alive until the response body closes.
|
|
35
|
-
bodyCompletion?: Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function runtimeBytesToArrayBuffer(value: RuntimeBytes): ArrayBuffer {
|
|
39
|
-
return value.buffer.slice(
|
|
40
|
-
value.byteOffset,
|
|
41
|
-
value.byteOffset + value.byteLength,
|
|
42
|
-
) as ArrayBuffer;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function buildNativeHttpRequest(init: NativeHttpRequestInit): Request {
|
|
46
|
-
const headers = new Headers(init.headers);
|
|
47
|
-
const originalUrl = headers.get(HEADER_ORIGINAL_REQUEST_URL);
|
|
48
|
-
headers.delete(HEADER_ORIGINAL_REQUEST_URL);
|
|
49
|
-
const url =
|
|
50
|
-
originalUrl ??
|
|
51
|
-
(init.uri.startsWith("http")
|
|
52
|
-
? init.uri
|
|
53
|
-
: new URL(init.uri, "http://127.0.0.1").toString());
|
|
54
|
-
const method = init.method.toUpperCase();
|
|
55
|
-
const bodyForbidden = method === "GET" || method === "HEAD";
|
|
56
|
-
const body = bodyForbidden
|
|
57
|
-
? undefined
|
|
58
|
-
: init.bodyStream
|
|
59
|
-
? new ReadableStream<Uint8Array>({
|
|
60
|
-
async pull(controller) {
|
|
61
|
-
try {
|
|
62
|
-
if (init.body && init.body.length > 0) {
|
|
63
|
-
controller.enqueue(new Uint8Array(init.body));
|
|
64
|
-
init.body = undefined;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const chunk = await init.bodyStream?.read();
|
|
68
|
-
if (!chunk) {
|
|
69
|
-
controller.close();
|
|
70
|
-
} else {
|
|
71
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
init.abortController?.abort(error);
|
|
75
|
-
controller.error(error);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
async cancel() {
|
|
79
|
-
await init.bodyStream?.cancel();
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
: init.body && init.body.length > 0
|
|
83
|
-
? runtimeBytesToArrayBuffer(init.body)
|
|
84
|
-
: undefined;
|
|
85
|
-
const streamInit =
|
|
86
|
-
init.bodyStream && !bodyForbidden ? { duplex: "half" } : {};
|
|
87
|
-
return new Request(url, {
|
|
88
|
-
method,
|
|
89
|
-
headers,
|
|
90
|
-
body,
|
|
91
|
-
signal: init.abortController?.signal ?? init.signal,
|
|
92
|
-
...streamInit,
|
|
93
|
-
} as RequestInit);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function cancelNativeHttpRequestBody(
|
|
97
|
-
bodyStream?: NativeHttpRequestBodyStream,
|
|
98
|
-
) {
|
|
99
|
-
await bodyStream?.cancel();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function writeResponseChunk(
|
|
103
|
-
stream: NativeHttpResponseBodyStream,
|
|
104
|
-
chunk: Uint8Array,
|
|
105
|
-
) {
|
|
106
|
-
for (
|
|
107
|
-
let offset = 0;
|
|
108
|
-
offset < chunk.byteLength;
|
|
109
|
-
offset += HTTP_BODY_CHUNK_SIZE
|
|
110
|
-
) {
|
|
111
|
-
await stream.write(
|
|
112
|
-
chunk.subarray(offset, offset + HTTP_BODY_CHUNK_SIZE),
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async function pumpResponseBody(
|
|
118
|
-
reader: ReadableStreamDefaultReader<Uint8Array>,
|
|
119
|
-
stream: NativeHttpResponseBodyStream,
|
|
120
|
-
) {
|
|
121
|
-
// Awaiting each write applies native-side backpressure. Racing the next read
|
|
122
|
-
// against cancellation also stops an otherwise unbounded SSE response when
|
|
123
|
-
// its downstream receiver disappears.
|
|
124
|
-
const cancelled = stream
|
|
125
|
-
.cancelled()
|
|
126
|
-
.then(() => ({ cancelled: true }) as const);
|
|
127
|
-
try {
|
|
128
|
-
for (;;) {
|
|
129
|
-
const read = reader
|
|
130
|
-
.read()
|
|
131
|
-
.then((next) => ({ cancelled: false, next }) as const);
|
|
132
|
-
const result = await Promise.race([read, cancelled]);
|
|
133
|
-
if (result.cancelled) {
|
|
134
|
-
await reader.cancel(
|
|
135
|
-
new Error("native http response stream receiver dropped"),
|
|
136
|
-
);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const { next } = result;
|
|
140
|
-
if (next.done) {
|
|
141
|
-
await stream.end();
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (next.value?.byteLength) {
|
|
145
|
-
await writeResponseChunk(stream, next.value);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
} catch (error) {
|
|
149
|
-
try {
|
|
150
|
-
await stream.error(stringifyError(error));
|
|
151
|
-
} catch (streamError) {
|
|
152
|
-
logger().debug({
|
|
153
|
-
msg: "failed to report native http response stream error",
|
|
154
|
-
error: streamError,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
try {
|
|
158
|
-
await reader.cancel(error);
|
|
159
|
-
} catch {
|
|
160
|
-
// Reader may already be closed after a native-side disconnect.
|
|
161
|
-
}
|
|
162
|
-
} finally {
|
|
163
|
-
reader.releaseLock();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export async function convertNativeHttpResponse(
|
|
168
|
-
response: ResponseLike,
|
|
169
|
-
responseBodyStream?: NativeHttpResponseBodyStream,
|
|
170
|
-
): Promise<NativeHttpResponseConversion> {
|
|
171
|
-
const headers = Object.fromEntries(response.headers.entries());
|
|
172
|
-
if (!response.body) {
|
|
173
|
-
return {
|
|
174
|
-
response: {
|
|
175
|
-
status: response.status,
|
|
176
|
-
headers,
|
|
177
|
-
body: new Uint8Array(),
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (responseBodyStream) {
|
|
183
|
-
const reader = response.body.getReader();
|
|
184
|
-
const bodyCompletion = pumpResponseBody(reader, responseBodyStream);
|
|
185
|
-
return {
|
|
186
|
-
response: {
|
|
187
|
-
status: response.status,
|
|
188
|
-
headers,
|
|
189
|
-
stream: true,
|
|
190
|
-
},
|
|
191
|
-
bodyCompletion,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
response: {
|
|
197
|
-
status: response.status,
|
|
198
|
-
headers,
|
|
199
|
-
body: new Uint8Array(await response.arrayBuffer()),
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export const nativeHttpTestInternals = {
|
|
205
|
-
buildRequest: buildNativeHttpRequest,
|
|
206
|
-
cancelRequestBody: cancelNativeHttpRequestBody,
|
|
207
|
-
convertRuntimeHttpResponse: convertNativeHttpResponse,
|
|
208
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|