agent-relay-runner 0.65.2 → 0.66.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay-runner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"description": "Unified provider lifecycle runner for Agent Relay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"directory": "runner"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"agent-relay-sdk": "0.2.
|
|
23
|
+
"agent-relay-sdk": "0.2.43"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/bun": "latest",
|
|
@@ -4,6 +4,8 @@ import type { OutboxRecord } from "./outbox";
|
|
|
4
4
|
const CONTINUATION_ARCHIVE_MAX_POST_BODY_BYTES = 64 * 1024;
|
|
5
5
|
const CONTINUATION_ARCHIVE_CHUNK_TARGET_BYTES = 56 * 1024;
|
|
6
6
|
const CONTINUATION_ARCHIVE_MAX_GENERATION_BYTES = 8 * 1024 * 1024;
|
|
7
|
+
const encoder = new TextEncoder();
|
|
8
|
+
const fatalUtf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
7
9
|
|
|
8
10
|
interface ContinuationArchiveOutboxPayload {
|
|
9
11
|
agentId: string;
|
|
@@ -18,11 +20,12 @@ interface ContinuationArchiveResponse {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export function boundContinuationArchiveSegment(segment: string): { segment: string; keptBytes: number; droppedBytes: number } {
|
|
21
|
-
const
|
|
23
|
+
const encoded = encoder.encode(segment);
|
|
24
|
+
const bytes = encoded.byteLength;
|
|
22
25
|
if (bytes <= CONTINUATION_ARCHIVE_MAX_GENERATION_BYTES) {
|
|
23
26
|
return { segment, keptBytes: bytes, droppedBytes: 0 };
|
|
24
27
|
}
|
|
25
|
-
const bounded =
|
|
28
|
+
const bounded = decodeUtf8Prefix(encoded, CONTINUATION_ARCHIVE_MAX_GENERATION_BYTES);
|
|
26
29
|
const keptBytes = utf8Bytes(bounded);
|
|
27
30
|
return { segment: bounded.trimEnd(), keptBytes, droppedBytes: bytes - keptBytes };
|
|
28
31
|
}
|
|
@@ -159,18 +162,18 @@ function archiveGeneration(response: ContinuationArchiveResponse): number | unde
|
|
|
159
162
|
return typeof generation === "number" && Number.isSafeInteger(generation) && generation >= 0 ? generation : undefined;
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
function
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
function decodeUtf8Prefix(bytes: Uint8Array, maxBytes: number): string {
|
|
166
|
+
let end = Math.min(maxBytes, bytes.byteLength);
|
|
167
|
+
while (end > 0) {
|
|
168
|
+
try {
|
|
169
|
+
return fatalUtf8Decoder.decode(bytes.subarray(0, end));
|
|
170
|
+
} catch {
|
|
171
|
+
end -= 1;
|
|
172
|
+
}
|
|
170
173
|
}
|
|
171
|
-
return
|
|
174
|
+
return "";
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
function utf8Bytes(value: string): number {
|
|
175
|
-
return
|
|
178
|
+
return encoder.encode(value).byteLength;
|
|
176
179
|
}
|