@rivet-dev/agentos-core 0.0.0-main.29b0797 → 0.0.0-main.5ac5a14
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/README.md +10 -199
- package/dist/agent-os.d.ts +332 -54
- package/dist/agent-os.js +1533 -91
- package/dist/agentos-package.d.ts +2 -2
- package/dist/agentos-package.js +2 -2
- package/dist/base-filesystem.js +2 -2
- package/dist/code-execution.d.ts +70 -0
- package/dist/code-execution.js +115 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -1
- package/dist/language-execution.d.ts +170 -0
- package/dist/language-execution.js +1 -0
- package/dist/options-schema.d.ts +19 -3
- package/dist/options-schema.js +17 -2
- package/dist/packages.d.ts +1 -1
- package/dist/runtime-compat.js +19 -7
- package/dist/sandbox.js +33 -20
- package/dist/sidecar/agentos-protocol.d.ts +14 -3
- package/dist/sidecar/agentos-protocol.js +10 -0
- package/dist/sidecar/rpc-client.d.ts +1 -0
- package/dist/sidecar/rpc-client.js +25 -16
- package/dist/types.d.ts +5 -3
- package/package.json +26 -20
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A package is a self-contained directory produced by `@rivet-dev/agentos-toolchain
|
|
5
5
|
* pack`. The HOST no longer projects it: the client forwards only the package
|
|
6
|
-
* directory over the wire and the
|
|
6
|
+
* directory over the wire and the agentos sidecar owns the `/opt/agentos`
|
|
7
7
|
* projection. Package metadata lives in `<dir>/agentos-package.json`.
|
|
8
8
|
*
|
|
9
9
|
* This module is therefore only the client-facing package-dir surface plus the
|
|
@@ -25,7 +25,7 @@ export type SoftwarePackageRef = {
|
|
|
25
25
|
export interface PackageDescriptor {
|
|
26
26
|
path: string;
|
|
27
27
|
}
|
|
28
|
-
/** Discriminate the
|
|
28
|
+
/** Discriminate the path-only package reference. */
|
|
29
29
|
export declare function isPackageDescriptor(value: unknown): value is PackageDescriptor;
|
|
30
30
|
export declare function readAgentosPackageManifest(dir: string): AgentosPackageManifest;
|
|
31
31
|
export declare function tryReadAgentosPackageManifest(dir: string): AgentosPackageManifest | undefined;
|
package/dist/agentos-package.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A package is a self-contained directory produced by `@rivet-dev/agentos-toolchain
|
|
5
5
|
* pack`. The HOST no longer projects it: the client forwards only the package
|
|
6
|
-
* directory over the wire and the
|
|
6
|
+
* directory over the wire and the agentos sidecar owns the `/opt/agentos`
|
|
7
7
|
* projection. Package metadata lives in `<dir>/agentos-package.json`.
|
|
8
8
|
*
|
|
9
9
|
* This module is therefore only the client-facing package-dir surface plus the
|
|
@@ -17,7 +17,7 @@ import { join } from "node:path";
|
|
|
17
17
|
export const OPT_AGENTOS_ROOT = "/opt/agentos";
|
|
18
18
|
/** The symlink farm on `$PATH` (commands link here). */
|
|
19
19
|
export const OPT_AGENTOS_BIN = "/opt/agentos/bin";
|
|
20
|
-
/** Discriminate the
|
|
20
|
+
/** Discriminate the path-only package reference. */
|
|
21
21
|
export function isPackageDescriptor(value) {
|
|
22
22
|
return (typeof value === "object" &&
|
|
23
23
|
value !== null &&
|
package/dist/base-filesystem.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* The base VM environment, baked in as a constant (verbatim from the single
|
|
3
3
|
* `base-filesystem.json` the sidecar embeds). The host no longer reads that JSON
|
|
4
4
|
* — the sidecar owns the base filesystem, and there is exactly one committed copy
|
|
5
|
-
* of it (`
|
|
5
|
+
* of it (`agentos/crates/vfs/assets/base-filesystem.json`). Regenerate both
|
|
6
6
|
* this constant and that file together with the build-tools snapshot script.
|
|
7
7
|
*/
|
|
8
8
|
const BASE_ENVIRONMENT = Object.freeze({
|
|
9
9
|
CHARSET: "UTF-8",
|
|
10
10
|
HOME: "/home/agentos",
|
|
11
|
-
HOSTNAME: "
|
|
11
|
+
HOSTNAME: "agentos",
|
|
12
12
|
LANG: "C.UTF-8",
|
|
13
13
|
LC_COLLATE: "C",
|
|
14
14
|
LOGNAME: "agentos",
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export interface CodeExecutionSpawnOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
env?: Record<string, string>;
|
|
4
|
+
stdin?: string | Uint8Array;
|
|
5
|
+
streamStdin?: boolean;
|
|
6
|
+
captureStdio?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CodeExecutionProcessOutput {
|
|
9
|
+
pid: number;
|
|
10
|
+
stream: "stdout" | "stderr";
|
|
11
|
+
data: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
export interface CodeExecutionVm {
|
|
14
|
+
spawn(command: string, args: string[], options?: CodeExecutionSpawnOptions): {
|
|
15
|
+
pid: number;
|
|
16
|
+
};
|
|
17
|
+
onProcessOutput(pid: number, handler: (event: CodeExecutionProcessOutput) => void): () => void;
|
|
18
|
+
waitProcess(pid: number): Promise<number>;
|
|
19
|
+
writeProcessStdin(pid: number, data: string | Uint8Array): Promise<void>;
|
|
20
|
+
closeProcessStdin(pid: number): Promise<void>;
|
|
21
|
+
killProcess(pid: number): void;
|
|
22
|
+
stopProcess(pid: number): void;
|
|
23
|
+
}
|
|
24
|
+
export interface CodeExecutionOptions {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
argv?: string[];
|
|
28
|
+
stdin?: string | Uint8Array;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
onStdout?: (chunk: string) => void;
|
|
32
|
+
onStderr?: (chunk: string) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface CodeExecutionResult {
|
|
35
|
+
success: boolean;
|
|
36
|
+
exitCode: number;
|
|
37
|
+
stdout: string;
|
|
38
|
+
stderr: string;
|
|
39
|
+
}
|
|
40
|
+
export interface GuestError {
|
|
41
|
+
name: string;
|
|
42
|
+
message: string;
|
|
43
|
+
stack?: string;
|
|
44
|
+
}
|
|
45
|
+
export type CodeEvaluationResult<T> = {
|
|
46
|
+
success: true;
|
|
47
|
+
exitCode: 0;
|
|
48
|
+
value: T;
|
|
49
|
+
stdout: string;
|
|
50
|
+
stderr: string;
|
|
51
|
+
} | {
|
|
52
|
+
success: false;
|
|
53
|
+
exitCode: number;
|
|
54
|
+
error: GuestError;
|
|
55
|
+
stdout: string;
|
|
56
|
+
stderr: string;
|
|
57
|
+
};
|
|
58
|
+
export interface CodeProcess {
|
|
59
|
+
readonly pid: number;
|
|
60
|
+
writeStdin(data: string | Uint8Array): Promise<void>;
|
|
61
|
+
closeStdin(): Promise<void>;
|
|
62
|
+
kill(signal?: "SIGTERM" | "SIGKILL"): void;
|
|
63
|
+
wait(): Promise<CodeExecutionResult>;
|
|
64
|
+
}
|
|
65
|
+
export interface SpawnCodeProcessOptions extends CodeExecutionOptions {
|
|
66
|
+
onComplete?: () => Promise<void>;
|
|
67
|
+
streamStdin?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export declare function spawnCodeProcess(vm: CodeExecutionVm, command: string, args: string[], options?: SpawnCodeProcessOptions): CodeProcess;
|
|
70
|
+
export declare function executeArgv(vm: CodeExecutionVm, command: string, args: string[], options?: SpawnCodeProcessOptions): Promise<CodeExecutionResult>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function toSpawnOptions(options) {
|
|
2
|
+
return {
|
|
3
|
+
cwd: options.cwd,
|
|
4
|
+
env: options.env,
|
|
5
|
+
stdin: options.stdin,
|
|
6
|
+
streamStdin: options.streamStdin ?? true,
|
|
7
|
+
captureStdio: true,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function spawnCodeProcess(vm, command, args, options = {}) {
|
|
11
|
+
if (options.signal?.aborted) {
|
|
12
|
+
throw abortReason(options.signal);
|
|
13
|
+
}
|
|
14
|
+
if (options.timeoutMs !== undefined &&
|
|
15
|
+
(!Number.isFinite(options.timeoutMs) || options.timeoutMs < 0)) {
|
|
16
|
+
throw new RangeError("timeoutMs must be a finite, non-negative number");
|
|
17
|
+
}
|
|
18
|
+
const { pid } = vm.spawn(command, args, toSpawnOptions(options));
|
|
19
|
+
const stdoutDecoder = new TextDecoder();
|
|
20
|
+
const stderrDecoder = new TextDecoder();
|
|
21
|
+
let stdout = "";
|
|
22
|
+
let stderr = "";
|
|
23
|
+
let callbackError;
|
|
24
|
+
let aborted = false;
|
|
25
|
+
let finalized = false;
|
|
26
|
+
let waitPromise;
|
|
27
|
+
const unsubscribeOutput = vm.onProcessOutput(pid, (event) => {
|
|
28
|
+
try {
|
|
29
|
+
if (event.stream === "stdout") {
|
|
30
|
+
const text = stdoutDecoder.decode(event.data, { stream: true });
|
|
31
|
+
stdout += text;
|
|
32
|
+
options.onStdout?.(text);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const text = stderrDecoder.decode(event.data, { stream: true });
|
|
36
|
+
stderr += text;
|
|
37
|
+
options.onStderr?.(text);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
callbackError ??= error;
|
|
42
|
+
vm.killProcess(pid);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const abort = () => {
|
|
46
|
+
aborted = true;
|
|
47
|
+
vm.killProcess(pid);
|
|
48
|
+
};
|
|
49
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
50
|
+
const timeout = options.timeoutMs === undefined
|
|
51
|
+
? undefined
|
|
52
|
+
: setTimeout(() => vm.killProcess(pid), options.timeoutMs);
|
|
53
|
+
const finalize = async () => {
|
|
54
|
+
if (finalized)
|
|
55
|
+
return;
|
|
56
|
+
finalized = true;
|
|
57
|
+
unsubscribeOutput();
|
|
58
|
+
options.signal?.removeEventListener("abort", abort);
|
|
59
|
+
if (timeout !== undefined)
|
|
60
|
+
clearTimeout(timeout);
|
|
61
|
+
stdout += stdoutDecoder.decode();
|
|
62
|
+
stderr += stderrDecoder.decode();
|
|
63
|
+
await options.onComplete?.();
|
|
64
|
+
};
|
|
65
|
+
const wait = () => {
|
|
66
|
+
waitPromise ??= (async () => {
|
|
67
|
+
let exitCode;
|
|
68
|
+
try {
|
|
69
|
+
exitCode = await vm.waitProcess(pid);
|
|
70
|
+
}
|
|
71
|
+
catch (waitError) {
|
|
72
|
+
try {
|
|
73
|
+
await finalize();
|
|
74
|
+
}
|
|
75
|
+
catch (cleanupError) {
|
|
76
|
+
console.error("[agentos] process cleanup also failed after waitProcess rejected:", cleanupError);
|
|
77
|
+
}
|
|
78
|
+
throw waitError;
|
|
79
|
+
}
|
|
80
|
+
await finalize();
|
|
81
|
+
if (aborted && options.signal)
|
|
82
|
+
throw abortReason(options.signal);
|
|
83
|
+
if (callbackError !== undefined)
|
|
84
|
+
throw callbackError;
|
|
85
|
+
return {
|
|
86
|
+
success: exitCode === 0,
|
|
87
|
+
exitCode,
|
|
88
|
+
stdout,
|
|
89
|
+
stderr,
|
|
90
|
+
};
|
|
91
|
+
})();
|
|
92
|
+
return waitPromise;
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
pid,
|
|
96
|
+
writeStdin: (data) => vm.writeProcessStdin(pid, data),
|
|
97
|
+
closeStdin: () => vm.closeProcessStdin(pid),
|
|
98
|
+
kill: (signal) => {
|
|
99
|
+
if (signal === "SIGKILL")
|
|
100
|
+
vm.killProcess(pid);
|
|
101
|
+
else
|
|
102
|
+
vm.stopProcess(pid);
|
|
103
|
+
},
|
|
104
|
+
wait,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function abortReason(signal) {
|
|
108
|
+
return signal.reason ?? new DOMException("Execution aborted", "AbortError");
|
|
109
|
+
}
|
|
110
|
+
export async function executeArgv(vm, command, args, options = {}) {
|
|
111
|
+
return spawnCodeProcess(vm, command, args, {
|
|
112
|
+
...options,
|
|
113
|
+
streamStdin: false,
|
|
114
|
+
}).wait();
|
|
115
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export { AgentOs, AgentOsSidecar } from "./agent-os.js";
|
|
2
|
+
export type * from "./language-execution.js";
|
|
2
3
|
export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriver, } from "./cron/index.js";
|
|
3
4
|
export { createHostDirBackend, nodeModulesMount } from "./host-dir-mount.js";
|
|
4
5
|
export { binding, MAX_BINDING_DESCRIPTION_LENGTH, bindings, validateBindings, } from "./bindings.js";
|
|
6
|
+
export type { Binding, BindingExample, Bindings } from "./bindings.js";
|
|
5
7
|
export { agentOsLimitsSchema, agentOsOptionFieldSchemas, agentOsOptionsSchema, bindingSchema, mountConfigSchema, nativeMountConfigSchema, parseAgentOsOptions, permissionsSchema, rootFilesystemConfigSchema, sharedSidecarConfigSchema, sidecarConfigSchema, bindingsSchema, } from "./options-schema.js";
|
|
6
|
-
export { createSnapshotExport
|
|
8
|
+
export { createSnapshotExport } from "./layers.js";
|
|
7
9
|
export { defineSoftware } from "./packages.js";
|
|
8
10
|
export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
|
|
9
11
|
export { KernelError } from "./runtime-compat.js";
|
|
10
12
|
export type { ExecOptions, ExecResult, ManagedProcess, ProcessInfo, ShellHandle, VirtualDirEntry, VirtualStat, } from "./runtime.js";
|
|
13
|
+
export { createSandboxBindings, createSandboxFs, getSandboxDisposeHooks, resolveSandboxOptions, } from "./sandbox.js";
|
|
11
14
|
export type * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,8 @@ export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriv
|
|
|
4
4
|
export { createHostDirBackend, nodeModulesMount } from "./host-dir-mount.js";
|
|
5
5
|
export { binding, MAX_BINDING_DESCRIPTION_LENGTH, bindings, validateBindings, } from "./bindings.js";
|
|
6
6
|
export { agentOsLimitsSchema, agentOsOptionFieldSchemas, agentOsOptionsSchema, bindingSchema, mountConfigSchema, nativeMountConfigSchema, parseAgentOsOptions, permissionsSchema, rootFilesystemConfigSchema, sharedSidecarConfigSchema, sidecarConfigSchema, bindingsSchema, } from "./options-schema.js";
|
|
7
|
-
export { createSnapshotExport
|
|
7
|
+
export { createSnapshotExport } from "./layers.js";
|
|
8
8
|
export { defineSoftware } from "./packages.js";
|
|
9
9
|
export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
|
|
10
10
|
export { KernelError } from "./runtime-compat.js";
|
|
11
|
+
export { createSandboxBindings, createSandboxFs, getSandboxDisposeHooks, resolveSandboxOptions, } from "./sandbox.js";
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { JsonValue } from "./session-api.js";
|
|
2
|
+
export type ExecutionSignal = "SIGHUP" | "SIGINT" | "SIGQUIT" | "SIGTERM" | "SIGKILL" | "SIGSTOP" | "SIGCONT" | "SIGUSR1" | "SIGUSR2";
|
|
3
|
+
export interface LanguageExecutionOptions {
|
|
4
|
+
contextId?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
env?: Record<string, string>;
|
|
7
|
+
args?: string[];
|
|
8
|
+
stdin?: string | Uint8Array;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
pty?: {
|
|
11
|
+
cols?: number;
|
|
12
|
+
rows?: number;
|
|
13
|
+
};
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
onStdout?: (chunk: Uint8Array) => void;
|
|
16
|
+
onStderr?: (chunk: Uint8Array) => void;
|
|
17
|
+
output?: ExecutionOutputOptions;
|
|
18
|
+
}
|
|
19
|
+
export type OutputCapture = "none" | "stderr" | "all";
|
|
20
|
+
export interface ExecutionOutputOptions {
|
|
21
|
+
capture?: OutputCapture;
|
|
22
|
+
retainEvents?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface InlineExecutionOptions extends LanguageExecutionOptions {
|
|
25
|
+
inputs?: Record<string, JsonValue>;
|
|
26
|
+
}
|
|
27
|
+
export interface JavaScriptExecutionOptions extends InlineExecutionOptions {
|
|
28
|
+
format?: "module" | "commonjs";
|
|
29
|
+
filePath?: string;
|
|
30
|
+
}
|
|
31
|
+
export type JavaScriptEvaluationOptions = JavaScriptExecutionOptions;
|
|
32
|
+
export interface TypeScriptExecutionOptions extends InlineExecutionOptions {
|
|
33
|
+
filePath?: string;
|
|
34
|
+
tsconfigPath?: string;
|
|
35
|
+
compilerOptions?: Record<string, JsonValue>;
|
|
36
|
+
}
|
|
37
|
+
export type TypeScriptEvaluationOptions = TypeScriptExecutionOptions;
|
|
38
|
+
export interface TypeScriptFileExecutionOptions extends LanguageExecutionOptions {
|
|
39
|
+
tsconfigPath?: string;
|
|
40
|
+
compilerOptions?: Record<string, JsonValue>;
|
|
41
|
+
}
|
|
42
|
+
export interface TypeScriptCheckOptions {
|
|
43
|
+
contextId?: string;
|
|
44
|
+
cwd?: string;
|
|
45
|
+
filePath?: string;
|
|
46
|
+
tsconfigPath?: string;
|
|
47
|
+
compilerOptions?: Record<string, JsonValue>;
|
|
48
|
+
timeoutMs?: number;
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
output?: ExecutionOutputOptions;
|
|
51
|
+
}
|
|
52
|
+
export interface NpmProjectInstallOptions extends Omit<LanguageExecutionOptions, "args" | "stdin"> {
|
|
53
|
+
frozen?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface NpmPackageInstallOptions extends Omit<LanguageExecutionOptions, "args" | "stdin"> {
|
|
56
|
+
dev?: boolean;
|
|
57
|
+
global?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface PythonInstallOptions extends Omit<LanguageExecutionOptions, "args" | "stdin"> {
|
|
60
|
+
upgrade?: boolean;
|
|
61
|
+
requirementsFile?: string;
|
|
62
|
+
indexUrl?: string;
|
|
63
|
+
extraIndexUrls?: string[];
|
|
64
|
+
}
|
|
65
|
+
export type ContextState = "idle" | "running" | "resetting" | "deleting" | "failed";
|
|
66
|
+
export type ExecutionOutcome = "succeeded" | "failed" | "cancelled" | "timed_out";
|
|
67
|
+
export interface ContextDescriptor {
|
|
68
|
+
contextId: string;
|
|
69
|
+
state: ContextState;
|
|
70
|
+
language?: "javascript" | "python";
|
|
71
|
+
createdAtMs: number;
|
|
72
|
+
lastStartedAtMs?: number;
|
|
73
|
+
lastCompletedAtMs?: number;
|
|
74
|
+
}
|
|
75
|
+
export interface ProcessDescriptor {
|
|
76
|
+
pid: number;
|
|
77
|
+
state: "running" | "exited";
|
|
78
|
+
language?: "javascript" | "python";
|
|
79
|
+
command?: string;
|
|
80
|
+
startedAtMs: number;
|
|
81
|
+
}
|
|
82
|
+
export interface ProcessExit {
|
|
83
|
+
pid: number;
|
|
84
|
+
outcome: "exited" | "signalled" | "timed_out";
|
|
85
|
+
exitCode?: number;
|
|
86
|
+
signal?: ExecutionSignal;
|
|
87
|
+
}
|
|
88
|
+
export interface SpawnOptions {
|
|
89
|
+
cwd?: string;
|
|
90
|
+
env?: Record<string, string>;
|
|
91
|
+
args?: string[];
|
|
92
|
+
stdin?: string | Uint8Array;
|
|
93
|
+
timeoutMs?: number;
|
|
94
|
+
pty?: {
|
|
95
|
+
cols?: number;
|
|
96
|
+
rows?: number;
|
|
97
|
+
};
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
onStdout?: (chunk: Uint8Array) => void;
|
|
100
|
+
onStderr?: (chunk: Uint8Array) => void;
|
|
101
|
+
output?: {
|
|
102
|
+
retainEvents?: boolean;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export type LanguageSpawnOptions = SpawnOptions;
|
|
106
|
+
export interface ExecutionErrorData {
|
|
107
|
+
code: string;
|
|
108
|
+
name: string;
|
|
109
|
+
message: string;
|
|
110
|
+
stack?: string;
|
|
111
|
+
details?: JsonValue;
|
|
112
|
+
}
|
|
113
|
+
interface CodeExecutionResultBase {
|
|
114
|
+
exitCode?: number;
|
|
115
|
+
stdout?: string;
|
|
116
|
+
stderr?: string;
|
|
117
|
+
stdoutTruncated?: boolean;
|
|
118
|
+
stderrTruncated?: boolean;
|
|
119
|
+
}
|
|
120
|
+
type ExecutionResultOutcome<TIdentity> = (CodeExecutionResultBase & {
|
|
121
|
+
outcome: "succeeded";
|
|
122
|
+
error?: never;
|
|
123
|
+
} & TIdentity) | (CodeExecutionResultBase & {
|
|
124
|
+
outcome: Exclude<ExecutionOutcome, "succeeded">;
|
|
125
|
+
error: ExecutionErrorData;
|
|
126
|
+
} & TIdentity);
|
|
127
|
+
export type CodeExecutionResult = ExecutionResultOutcome<Record<never, never>>;
|
|
128
|
+
export type CodeEvaluationResult<T = JsonValue> = (CodeExecutionResultBase & {
|
|
129
|
+
outcome: "succeeded";
|
|
130
|
+
error?: never;
|
|
131
|
+
value: T;
|
|
132
|
+
}) | (CodeExecutionResultBase & {
|
|
133
|
+
outcome: Exclude<ExecutionOutcome, "succeeded">;
|
|
134
|
+
error: ExecutionErrorData;
|
|
135
|
+
value?: never;
|
|
136
|
+
});
|
|
137
|
+
export interface TypeScriptDiagnostic {
|
|
138
|
+
code: number;
|
|
139
|
+
category: "error" | "warning" | "suggestion" | "message";
|
|
140
|
+
message: string;
|
|
141
|
+
filePath?: string;
|
|
142
|
+
line?: number;
|
|
143
|
+
column?: number;
|
|
144
|
+
}
|
|
145
|
+
export type TypeScriptCheckResult = (CodeExecutionResultBase & {
|
|
146
|
+
outcome: "succeeded";
|
|
147
|
+
error?: never;
|
|
148
|
+
hasErrors: boolean;
|
|
149
|
+
diagnostics: TypeScriptDiagnostic[];
|
|
150
|
+
}) | (CodeExecutionResultBase & {
|
|
151
|
+
outcome: Exclude<ExecutionOutcome, "succeeded">;
|
|
152
|
+
error: ExecutionErrorData;
|
|
153
|
+
hasErrors?: never;
|
|
154
|
+
diagnostics: TypeScriptDiagnostic[];
|
|
155
|
+
});
|
|
156
|
+
export interface ProcessOutputEvent<TChunk = Uint8Array> {
|
|
157
|
+
pid: number;
|
|
158
|
+
sequence: number;
|
|
159
|
+
channel: "stdout" | "stderr" | "pty";
|
|
160
|
+
chunk: TChunk;
|
|
161
|
+
timestampMs: number;
|
|
162
|
+
}
|
|
163
|
+
export interface OutputReplay<TChunk = Uint8Array> {
|
|
164
|
+
pid: number;
|
|
165
|
+
events: ProcessOutputEvent<TChunk>[];
|
|
166
|
+
nextCursor: string;
|
|
167
|
+
hasMore: boolean;
|
|
168
|
+
truncated: boolean;
|
|
169
|
+
}
|
|
170
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/options-schema.d.ts
CHANGED
|
@@ -131,11 +131,14 @@ export declare const agentOsLimitsSchema: z.ZodObject<{
|
|
|
131
131
|
http: z.ZodOptional<z.ZodObject<{
|
|
132
132
|
maxFetchResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
133
133
|
}, z.core.$strict>>;
|
|
134
|
+
tls: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
maxBufferedBytes: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
}, z.core.$strict>>;
|
|
134
137
|
bindings: z.ZodOptional<z.ZodObject<{
|
|
135
138
|
defaultBindingTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
136
139
|
maxBindingTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
137
140
|
maxRegisteredCollections: z.ZodOptional<z.ZodNumber>;
|
|
138
|
-
|
|
141
|
+
maxRegisteredBindingsPerVm: z.ZodOptional<z.ZodNumber>;
|
|
139
142
|
maxBindingsPerCollection: z.ZodOptional<z.ZodNumber>;
|
|
140
143
|
maxBindingSchemaBytes: z.ZodOptional<z.ZodNumber>;
|
|
141
144
|
maxExamplesPerBinding: z.ZodOptional<z.ZodNumber>;
|
|
@@ -193,6 +196,11 @@ export declare const agentOsLimitsSchema: z.ZodObject<{
|
|
|
193
196
|
runnerHeapLimitMb: z.ZodOptional<z.ZodNumber>;
|
|
194
197
|
runnerCpuTimeLimitMs: z.ZodOptional<z.ZodNumber>;
|
|
195
198
|
}, z.core.$strict>>;
|
|
199
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
completedTtlMs: z.ZodOptional<z.ZodNumber>;
|
|
201
|
+
maxCompletedExecutions: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
liveExecutionWarningThreshold: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
}, z.core.$strict>>;
|
|
196
204
|
process: z.ZodOptional<z.ZodObject<{
|
|
197
205
|
maxSpawnFileActions: z.ZodOptional<z.ZodNumber>;
|
|
198
206
|
maxSpawnFileActionBytes: z.ZodOptional<z.ZodNumber>;
|
|
@@ -295,7 +303,6 @@ export declare const agentOsOptionFieldSchemas: {
|
|
|
295
303
|
readonly database: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
296
304
|
type: z.ZodLiteral<"actor_uds">;
|
|
297
305
|
path: z.ZodString;
|
|
298
|
-
token: z.ZodString;
|
|
299
306
|
}, z.core.$strict>, z.ZodObject<{
|
|
300
307
|
type: z.ZodLiteral<"sqlite_file">;
|
|
301
308
|
path: z.ZodString;
|
|
@@ -339,6 +346,7 @@ export declare const agentOsOptionFieldSchemas: {
|
|
|
339
346
|
lowers: z.ZodArray<z.ZodUnknown>;
|
|
340
347
|
}, z.core.$strict>;
|
|
341
348
|
}, z.core.$strict>]>>>;
|
|
349
|
+
readonly sandbox: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
|
|
342
350
|
readonly scheduleDriver: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
|
|
343
351
|
readonly bindings: z.ZodOptional<z.ZodArray<z.ZodType<Bindings, unknown, z.core.$ZodTypeInternals<Bindings, unknown>>>>;
|
|
344
352
|
readonly permissions: z.ZodOptional<z.ZodObject<{
|
|
@@ -478,11 +486,14 @@ export declare const agentOsOptionFieldSchemas: {
|
|
|
478
486
|
http: z.ZodOptional<z.ZodObject<{
|
|
479
487
|
maxFetchResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
480
488
|
}, z.core.$strict>>;
|
|
489
|
+
tls: z.ZodOptional<z.ZodObject<{
|
|
490
|
+
maxBufferedBytes: z.ZodOptional<z.ZodNumber>;
|
|
491
|
+
}, z.core.$strict>>;
|
|
481
492
|
bindings: z.ZodOptional<z.ZodObject<{
|
|
482
493
|
defaultBindingTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
483
494
|
maxBindingTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
484
495
|
maxRegisteredCollections: z.ZodOptional<z.ZodNumber>;
|
|
485
|
-
|
|
496
|
+
maxRegisteredBindingsPerVm: z.ZodOptional<z.ZodNumber>;
|
|
486
497
|
maxBindingsPerCollection: z.ZodOptional<z.ZodNumber>;
|
|
487
498
|
maxBindingSchemaBytes: z.ZodOptional<z.ZodNumber>;
|
|
488
499
|
maxExamplesPerBinding: z.ZodOptional<z.ZodNumber>;
|
|
@@ -540,6 +551,11 @@ export declare const agentOsOptionFieldSchemas: {
|
|
|
540
551
|
runnerHeapLimitMb: z.ZodOptional<z.ZodNumber>;
|
|
541
552
|
runnerCpuTimeLimitMs: z.ZodOptional<z.ZodNumber>;
|
|
542
553
|
}, z.core.$strict>>;
|
|
554
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
555
|
+
completedTtlMs: z.ZodOptional<z.ZodNumber>;
|
|
556
|
+
maxCompletedExecutions: z.ZodOptional<z.ZodNumber>;
|
|
557
|
+
liveExecutionWarningThreshold: z.ZodOptional<z.ZodNumber>;
|
|
558
|
+
}, z.core.$strict>>;
|
|
543
559
|
process: z.ZodOptional<z.ZodObject<{
|
|
544
560
|
maxSpawnFileActions: z.ZodOptional<z.ZodNumber>;
|
|
545
561
|
maxSpawnFileActionBytes: z.ZodOptional<z.ZodNumber>;
|
package/dist/options-schema.js
CHANGED
|
@@ -119,12 +119,16 @@ export const agentOsLimitsSchema = z
|
|
|
119
119
|
.object({ maxFetchResponseBytes: positiveInteger.optional() })
|
|
120
120
|
.strict()
|
|
121
121
|
.optional(),
|
|
122
|
+
tls: z
|
|
123
|
+
.object({ maxBufferedBytes: positiveInteger.optional() })
|
|
124
|
+
.strict()
|
|
125
|
+
.optional(),
|
|
122
126
|
bindings: z
|
|
123
127
|
.object({
|
|
124
128
|
defaultBindingTimeoutMs: nonNegativeInteger.optional(),
|
|
125
129
|
maxBindingTimeoutMs: nonNegativeInteger.optional(),
|
|
126
130
|
maxRegisteredCollections: positiveInteger.optional(),
|
|
127
|
-
|
|
131
|
+
maxRegisteredBindingsPerVm: positiveInteger.optional(),
|
|
128
132
|
maxBindingsPerCollection: positiveInteger.optional(),
|
|
129
133
|
maxBindingSchemaBytes: positiveInteger.optional(),
|
|
130
134
|
maxExamplesPerBinding: nonNegativeInteger.optional(),
|
|
@@ -200,6 +204,14 @@ export const agentOsLimitsSchema = z
|
|
|
200
204
|
})
|
|
201
205
|
.strict()
|
|
202
206
|
.optional(),
|
|
207
|
+
execution: z
|
|
208
|
+
.object({
|
|
209
|
+
completedTtlMs: positiveInteger.optional(),
|
|
210
|
+
maxCompletedExecutions: positiveInteger.optional(),
|
|
211
|
+
liveExecutionWarningThreshold: positiveInteger.optional(),
|
|
212
|
+
})
|
|
213
|
+
.strict()
|
|
214
|
+
.optional(),
|
|
203
215
|
process: z
|
|
204
216
|
.object({
|
|
205
217
|
maxSpawnFileActions: positiveInteger.optional(),
|
|
@@ -340,7 +352,6 @@ export const agentOsOptionFieldSchemas = {
|
|
|
340
352
|
.object({
|
|
341
353
|
type: z.literal("actor_uds"),
|
|
342
354
|
path: z.string().min(1),
|
|
343
|
-
token: z.string().min(1).max(4096),
|
|
344
355
|
})
|
|
345
356
|
.strict(),
|
|
346
357
|
z
|
|
@@ -353,6 +364,10 @@ export const agentOsOptionFieldSchemas = {
|
|
|
353
364
|
.optional(),
|
|
354
365
|
rootFilesystem: rootFilesystemConfigSchema.optional(),
|
|
355
366
|
mounts: z.array(mountConfigSchema).optional(),
|
|
367
|
+
sandbox: z
|
|
368
|
+
.custom((value) => value === undefined ||
|
|
369
|
+
(typeof value === "object" && value !== null && !Array.isArray(value)), { message: "Expected sandbox options object" })
|
|
370
|
+
.optional(),
|
|
356
371
|
scheduleDriver: z
|
|
357
372
|
.custom((value) => typeof value === "object" && value !== null, {
|
|
358
373
|
message: "Expected schedule driver object",
|
package/dist/packages.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SoftwarePackageRef } from "./agentos-package.js";
|
|
2
2
|
/**
|
|
3
3
|
* Input type for the `software` option. Software is a self-contained package
|
|
4
|
-
* directory that the
|
|
4
|
+
* directory that the agentos sidecar materializes into the `/opt/agentos`
|
|
5
5
|
* projection. Accepts a package-dir ref or an array of refs for meta-packages.
|
|
6
6
|
*/
|
|
7
7
|
export type SoftwareEntry = SoftwarePackageRef;
|
package/dist/runtime-compat.js
CHANGED
|
@@ -870,9 +870,13 @@ function createBootstrapEntries() {
|
|
|
870
870
|
...KERNEL_POSIX_BOOTSTRAP_DIRS.map((entryPath) => ({
|
|
871
871
|
path: entryPath,
|
|
872
872
|
kind: "directory",
|
|
873
|
-
mode: entryPath === "/tmp" || entryPath === "/var/tmp"
|
|
874
|
-
|
|
875
|
-
|
|
873
|
+
mode: entryPath === "/tmp" || entryPath === "/var/tmp"
|
|
874
|
+
? 0o1777
|
|
875
|
+
: entryPath === "/home/agentos"
|
|
876
|
+
? 0o2755
|
|
877
|
+
: 0o755,
|
|
878
|
+
uid: entryPath === "/home/agentos" || entryPath === "/workspace" ? 1000 : 0,
|
|
879
|
+
gid: entryPath === "/home/agentos" || entryPath === "/workspace" ? 1000 : 0,
|
|
876
880
|
executable: false,
|
|
877
881
|
})),
|
|
878
882
|
{
|
|
@@ -1187,9 +1191,15 @@ async function syncLiveFilesystemToBoundMethods(live, methods, paths, maxBytes)
|
|
|
1187
1191
|
}
|
|
1188
1192
|
async function snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, maxBytes, knownEntry) {
|
|
1189
1193
|
const stat = knownEntry ??
|
|
1190
|
-
(targetPath === "/"
|
|
1194
|
+
(targetPath === "/"
|
|
1195
|
+
? await live.stat(targetPath)
|
|
1196
|
+
: await live.lstat(targetPath));
|
|
1191
1197
|
if (stat.isSymbolicLink) {
|
|
1192
|
-
snapshot.push({
|
|
1198
|
+
snapshot.push({
|
|
1199
|
+
kind: "symlink",
|
|
1200
|
+
path: targetPath,
|
|
1201
|
+
target: await live.readlink(targetPath),
|
|
1202
|
+
});
|
|
1193
1203
|
return;
|
|
1194
1204
|
}
|
|
1195
1205
|
if (stat.isDirectory) {
|
|
@@ -1221,7 +1231,9 @@ async function snapshotLiveFilesystemPath(live, targetPath, snapshot, usage, max
|
|
|
1221
1231
|
}
|
|
1222
1232
|
async function applyLiveFilesystemSnapshotEntry(methods, entry) {
|
|
1223
1233
|
if (entry.kind === "directory") {
|
|
1224
|
-
await callBoundFilesystemMethod(methods, "mkdir", entry.path, {
|
|
1234
|
+
await callBoundFilesystemMethod(methods, "mkdir", entry.path, {
|
|
1235
|
+
recursive: true,
|
|
1236
|
+
});
|
|
1225
1237
|
return;
|
|
1226
1238
|
}
|
|
1227
1239
|
await ensureBoundParentDirectory(methods, entry.path);
|
|
@@ -1351,7 +1363,7 @@ class NativeKernel {
|
|
|
1351
1363
|
throw new Error("kernel is not ready");
|
|
1352
1364
|
}
|
|
1353
1365
|
const sidecarMounts = commandDirs.map((commandDir, index) => serializeMountConfigForSidecar({
|
|
1354
|
-
path: `/
|
|
1366
|
+
path: `/__agentos/commands/${index}`,
|
|
1355
1367
|
readOnly: true,
|
|
1356
1368
|
plugin: {
|
|
1357
1369
|
id: "host_dir",
|