@rivet-dev/agentos-runtime-core 0.2.19 → 0.2.20
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/commands/bash +0 -0
- package/commands/rg +0 -0
- package/commands/sh +0 -0
- package/commands/ssh +0 -0
- package/commands/unzip +0 -0
- package/commands/zip +0 -0
- package/dist/generated/SqliteLimitsConfig.d.ts +0 -2
- package/dist/process.d.ts +13 -1
- package/dist/process.js +65 -3
- package/package.json +2 -2
package/commands/bash
CHANGED
|
Binary file
|
package/commands/rg
CHANGED
|
Binary file
|
package/commands/sh
CHANGED
|
Binary file
|
package/commands/ssh
CHANGED
|
Binary file
|
package/commands/unzip
CHANGED
|
Binary file
|
package/commands/zip
CHANGED
|
Binary file
|
package/dist/process.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ export declare class StdioSidecarProcess {
|
|
|
12
12
|
readonly child: ChildProcessWithoutNullStreams;
|
|
13
13
|
readonly control: Duplex | null;
|
|
14
14
|
readonly combinedStdio: boolean;
|
|
15
|
-
|
|
15
|
+
/** First bytes of sidecar stderr; the root cause usually appears here. */
|
|
16
|
+
private readonly stderrHead;
|
|
17
|
+
private stderrHeadBytes;
|
|
18
|
+
/** Most recent bytes of sidecar stderr; the fatal error appears here. */
|
|
19
|
+
private readonly stderrTail;
|
|
20
|
+
private stderrTailBytes;
|
|
21
|
+
private stderrDroppedBytes;
|
|
16
22
|
private readonly exitListeners;
|
|
17
23
|
private readonly errorListeners;
|
|
18
24
|
private constructor();
|
|
@@ -20,6 +26,12 @@ export declare class StdioSidecarProcess {
|
|
|
20
26
|
static fromChild(child: ChildProcessWithoutNullStreams, control?: Duplex | null): StdioSidecarProcess;
|
|
21
27
|
onExit(handler: (error: SidecarProcessExited) => void): () => void;
|
|
22
28
|
onError(handler: (error: SidecarProcessError) => void): () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Retain the first STDERR_HEAD_MAX_BYTES and the most recent
|
|
31
|
+
* STDERR_TAIL_MAX_BYTES of sidecar stderr, counting everything in between
|
|
32
|
+
* as dropped.
|
|
33
|
+
*/
|
|
34
|
+
private retainStderr;
|
|
23
35
|
stderrText(): string;
|
|
24
36
|
currentExitError(): SidecarProcessExited | null;
|
|
25
37
|
waitForExit(timeoutMs: number): Promise<number | null>;
|
package/dist/process.js
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
export { SidecarProcessError, SidecarProcessExited, } from "./sidecar-errors.js";
|
|
3
3
|
import { SidecarProcessError, SidecarProcessExited } from "./sidecar-errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* Bounds on the sidecar stderr excerpt retained for SidecarProcessExited and
|
|
6
|
+
* SidecarProcessError. Live stderr is always forwarded to host stderr, so these
|
|
7
|
+
* bound only the postmortem copy. Sidecar diagnostics can be guest-triggered,
|
|
8
|
+
* so the retained copy must never grow without limit.
|
|
9
|
+
*/
|
|
10
|
+
const STDERR_HEAD_MAX_BYTES = 16 * 1024;
|
|
11
|
+
const STDERR_TAIL_MAX_BYTES = 48 * 1024;
|
|
4
12
|
export class StdioSidecarProcess {
|
|
5
13
|
child;
|
|
6
14
|
control;
|
|
7
15
|
combinedStdio;
|
|
8
|
-
|
|
16
|
+
/** First bytes of sidecar stderr; the root cause usually appears here. */
|
|
17
|
+
stderrHead = [];
|
|
18
|
+
stderrHeadBytes = 0;
|
|
19
|
+
/** Most recent bytes of sidecar stderr; the fatal error appears here. */
|
|
20
|
+
stderrTail = [];
|
|
21
|
+
stderrTailBytes = 0;
|
|
22
|
+
stderrDroppedBytes = 0;
|
|
9
23
|
exitListeners = new Set();
|
|
10
24
|
errorListeners = new Set();
|
|
11
25
|
constructor(child, control) {
|
|
12
26
|
this.child = child;
|
|
13
27
|
this.control = control;
|
|
14
28
|
this.combinedStdio = control === null;
|
|
29
|
+
// Forward live sidecar stderr so warnings from a sidecar that survives a
|
|
30
|
+
// guest-triggered failure stay host-visible. This matches the Rust
|
|
31
|
+
// client, which spawns the sidecar with inherited stderr. Only a bounded
|
|
32
|
+
// excerpt is retained for exit/error reports.
|
|
15
33
|
this.child.stderr.on("data", (chunk) => {
|
|
16
|
-
|
|
34
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : Buffer.from(chunk);
|
|
35
|
+
process.stderr.write(buffer);
|
|
36
|
+
this.retainStderr(buffer);
|
|
17
37
|
});
|
|
18
38
|
this.child.on("exit", (code, signal) => {
|
|
19
39
|
const error = new SidecarProcessExited({
|
|
@@ -67,8 +87,50 @@ export class StdioSidecarProcess {
|
|
|
67
87
|
this.errorListeners.delete(handler);
|
|
68
88
|
};
|
|
69
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Retain the first STDERR_HEAD_MAX_BYTES and the most recent
|
|
92
|
+
* STDERR_TAIL_MAX_BYTES of sidecar stderr, counting everything in between
|
|
93
|
+
* as dropped.
|
|
94
|
+
*/
|
|
95
|
+
retainStderr(buffer) {
|
|
96
|
+
let rest = buffer;
|
|
97
|
+
const headRoom = STDERR_HEAD_MAX_BYTES - this.stderrHeadBytes;
|
|
98
|
+
if (headRoom > 0) {
|
|
99
|
+
const take = rest.subarray(0, headRoom);
|
|
100
|
+
this.stderrHead.push(take);
|
|
101
|
+
this.stderrHeadBytes += take.length;
|
|
102
|
+
rest = rest.subarray(take.length);
|
|
103
|
+
}
|
|
104
|
+
if (rest.length === 0)
|
|
105
|
+
return;
|
|
106
|
+
this.stderrTail.push(rest);
|
|
107
|
+
this.stderrTailBytes += rest.length;
|
|
108
|
+
while (this.stderrTailBytes > STDERR_TAIL_MAX_BYTES) {
|
|
109
|
+
const oldest = this.stderrTail[0];
|
|
110
|
+
const excess = this.stderrTailBytes - STDERR_TAIL_MAX_BYTES;
|
|
111
|
+
if (oldest.length <= excess) {
|
|
112
|
+
this.stderrTail.shift();
|
|
113
|
+
this.stderrTailBytes -= oldest.length;
|
|
114
|
+
this.stderrDroppedBytes += oldest.length;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Trim within the chunk so the bound holds for any chunking.
|
|
118
|
+
this.stderrTail[0] = oldest.subarray(excess);
|
|
119
|
+
this.stderrTailBytes -= excess;
|
|
120
|
+
this.stderrDroppedBytes += excess;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
70
124
|
stderrText() {
|
|
71
|
-
|
|
125
|
+
const head = Buffer.concat(this.stderrHead).toString("utf8");
|
|
126
|
+
const tail = Buffer.concat(this.stderrTail).toString("utf8");
|
|
127
|
+
const gap = this.stderrDroppedBytes > 0
|
|
128
|
+
? `\n... [${this.stderrDroppedBytes} bytes of sidecar stderr dropped; ` +
|
|
129
|
+
`retained the first ${STDERR_HEAD_MAX_BYTES} and last ` +
|
|
130
|
+
`${STDERR_TAIL_MAX_BYTES} bytes; the full output was forwarded ` +
|
|
131
|
+
`to host stderr] ...\n`
|
|
132
|
+
: "";
|
|
133
|
+
return `${head}${gap}${tail}`.trim();
|
|
72
134
|
}
|
|
73
135
|
currentExitError() {
|
|
74
136
|
if (this.child.exitCode === null && this.child.signalCode === null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos-runtime-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"test:npm-workflows": "AGENTOS_NPM_WORKFLOWS_E2E=1 vitest run tests/integration/e2e-npm-*.nightly.test.ts tests/integration/e2e-npx-and-pipes.nightly.test.ts tests/integration/e2e-concurrently.nightly.test.ts tests/integration/e2e-nextjs-build.nightly.test.ts --reporter=verbose"
|
|
198
198
|
},
|
|
199
199
|
"dependencies": {
|
|
200
|
-
"@rivet-dev/agentos-runtime-sidecar": "0.2.
|
|
200
|
+
"@rivet-dev/agentos-runtime-sidecar": "0.2.20",
|
|
201
201
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
202
202
|
"zod": "^4.1.11"
|
|
203
203
|
},
|