@rivet-dev/agentos-core 0.2.5-rc.2 → 0.2.5-rc.4
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 +4 -4
- package/dist/agent-os.d.ts +25 -28
- package/dist/agent-os.js +129 -403
- package/dist/agentos-package.d.ts +3 -3
- package/dist/agentos-package.js +7 -1
- package/dist/cron/types.d.ts +1 -1
- package/dist/default-software.d.ts +6 -46
- package/dist/default-software.js +7 -90
- package/dist/generated/AcpLimitsConfig.d.ts +4 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +26 -0
- package/dist/generated/CreateVmConfig.js +1 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRule.js +1 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +31 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +6 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/ToolLimitsConfig.d.ts +10 -0
- package/dist/generated/ToolLimitsConfig.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +18 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/WasmLimitsConfig.d.ts +7 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/host-dir-mount.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/options-schema.d.ts +14 -1
- package/dist/options-schema.js +27 -21
- package/dist/packages.d.ts +2 -2
- package/dist/packages.js +20 -6
- package/dist/runtime-compat.d.ts +17 -4
- package/dist/runtime-compat.js +51 -88
- package/dist/runtime.d.ts +27 -0
- package/dist/sandbox.d.ts +112 -0
- package/dist/sandbox.js +264 -0
- package/dist/sidecar/agentos-protocol.d.ts +27 -1
- package/dist/sidecar/agentos-protocol.js +77 -20
- package/dist/sidecar/native-process-client.d.ts +5 -4
- package/dist/sidecar/native-process-client.js +4 -4
- package/dist/sidecar/permissions.d.ts +1 -1
- package/dist/sidecar/rpc-client.d.ts +21 -2
- package/dist/sidecar/rpc-client.js +113 -41
- package/dist/types.d.ts +7 -1
- package/package.json +34 -35
- package/dist/agents.d.ts +0 -79
- package/dist/agents.js +0 -48
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { MountConfig, MountConfigJsonObject, NativeMountPluginDescriptor } from "./agent-os.js";
|
|
2
|
+
import type { ToolKit } from "./host-tools.js";
|
|
3
|
+
export interface AgentOsSandboxProcessResult {
|
|
4
|
+
stdout?: string;
|
|
5
|
+
stderr?: string;
|
|
6
|
+
exitCode?: number | null;
|
|
7
|
+
timedOut?: boolean;
|
|
8
|
+
durationMs?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentOsSandboxProcessInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
command?: string;
|
|
13
|
+
args?: string[];
|
|
14
|
+
status?: string;
|
|
15
|
+
exitCode?: number | null;
|
|
16
|
+
pid?: number | null;
|
|
17
|
+
}
|
|
18
|
+
export interface AgentOsSandboxProcessLogs {
|
|
19
|
+
entries: Array<{
|
|
20
|
+
data: string;
|
|
21
|
+
encoding?: "base64" | string;
|
|
22
|
+
stream?: "stdout" | "stderr" | "combined" | string;
|
|
23
|
+
timestampMs?: number;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface AgentOsSandboxClient {
|
|
27
|
+
dispose?(): Promise<void> | void;
|
|
28
|
+
runProcess(options: {
|
|
29
|
+
command: string;
|
|
30
|
+
args?: string[];
|
|
31
|
+
cwd?: string;
|
|
32
|
+
env?: Record<string, string>;
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
}): Promise<AgentOsSandboxProcessResult>;
|
|
35
|
+
createProcess(options: {
|
|
36
|
+
command: string;
|
|
37
|
+
args?: string[];
|
|
38
|
+
cwd?: string;
|
|
39
|
+
env?: Record<string, string>;
|
|
40
|
+
}): Promise<AgentOsSandboxProcessInfo>;
|
|
41
|
+
listProcesses(): Promise<{
|
|
42
|
+
processes: AgentOsSandboxProcessInfo[];
|
|
43
|
+
}>;
|
|
44
|
+
stopProcess(id: string): Promise<AgentOsSandboxProcessInfo>;
|
|
45
|
+
killProcess(id: string): Promise<AgentOsSandboxProcessInfo>;
|
|
46
|
+
getProcessLogs(id: string, options?: {
|
|
47
|
+
stream?: "stdout" | "stderr" | "combined";
|
|
48
|
+
tail?: number;
|
|
49
|
+
}): Promise<AgentOsSandboxProcessLogs>;
|
|
50
|
+
sendProcessInput(id: string, input: {
|
|
51
|
+
data: string;
|
|
52
|
+
encoding: "base64";
|
|
53
|
+
}): Promise<unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface AgentOsSandboxProvider {
|
|
56
|
+
start(): Promise<AgentOsSandboxClient>;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentOsSandboxCommonOptions {
|
|
59
|
+
/** Mount path inside the agentOS VM. Defaults to "/mnt/sandbox". */
|
|
60
|
+
mountPath?: string;
|
|
61
|
+
/** Root path inside the external sandbox provider. Defaults to "/". */
|
|
62
|
+
sandboxRoot?: string;
|
|
63
|
+
/** Per-request timeout for sandbox-agent filesystem calls. */
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
/** Maximum file size allowed for buffered pread/truncate fallbacks. */
|
|
66
|
+
maxFullReadBytes?: number;
|
|
67
|
+
/** Marks the VM mount read-only. Defaults to false. */
|
|
68
|
+
readOnly?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface AgentOsSandboxProviderOptions extends AgentOsSandboxCommonOptions {
|
|
71
|
+
/** Provider used to start a Sandbox Agent client for this VM. */
|
|
72
|
+
provider: AgentOsSandboxProvider;
|
|
73
|
+
}
|
|
74
|
+
export interface AgentOsSandboxClientOptions extends AgentOsSandboxCommonOptions {
|
|
75
|
+
/** Externally provisioned Sandbox Agent-compatible client instance. */
|
|
76
|
+
client: AgentOsSandboxClient;
|
|
77
|
+
/**
|
|
78
|
+
* Advanced lifecycle control. Set true to dispose `client` with the VM, or
|
|
79
|
+
* provide a custom dispose hook. Defaults to false for the object form.
|
|
80
|
+
*/
|
|
81
|
+
dispose?: boolean | (() => void | Promise<void>);
|
|
82
|
+
}
|
|
83
|
+
export type AgentOsSandboxOptions = AgentOsSandboxProviderOptions | AgentOsSandboxClientOptions;
|
|
84
|
+
export type AgentOsSandboxInput = AgentOsSandboxOptions;
|
|
85
|
+
declare const sandboxDisposeHooks: unique symbol;
|
|
86
|
+
type SandboxDisposeHook = () => void | Promise<void>;
|
|
87
|
+
export type AgentOsSandboxExpandedOptions = {
|
|
88
|
+
mounts?: MountConfig[];
|
|
89
|
+
toolKits?: ToolKit[];
|
|
90
|
+
[sandboxDisposeHooks]?: SandboxDisposeHook[];
|
|
91
|
+
};
|
|
92
|
+
type ResolvedSandboxOptions = AgentOsSandboxCommonOptions & {
|
|
93
|
+
client: AgentOsSandboxClient;
|
|
94
|
+
};
|
|
95
|
+
export type SandboxMountPluginConfig = MountConfigJsonObject & {
|
|
96
|
+
baseUrl: string;
|
|
97
|
+
token?: string;
|
|
98
|
+
headers?: Record<string, string>;
|
|
99
|
+
basePath?: string;
|
|
100
|
+
timeoutMs?: number;
|
|
101
|
+
maxFullReadBytes?: number;
|
|
102
|
+
};
|
|
103
|
+
export declare function createSandboxFs(input: ResolvedSandboxOptions | AgentOsSandboxClientOptions): NativeMountPluginDescriptor<SandboxMountPluginConfig>;
|
|
104
|
+
export declare function createSandboxBindings(input: ResolvedSandboxOptions | AgentOsSandboxClientOptions): ToolKit;
|
|
105
|
+
export declare function getSandboxDisposeHooks(options: object | undefined): SandboxDisposeHook[];
|
|
106
|
+
export declare function resolveSandboxOptions<T extends {
|
|
107
|
+
sandbox?: AgentOsSandboxInput;
|
|
108
|
+
}>(options: T): Promise<Omit<T, "sandbox"> & {
|
|
109
|
+
mounts?: MountConfig[];
|
|
110
|
+
toolKits?: ToolKit[];
|
|
111
|
+
}>;
|
|
112
|
+
export {};
|
package/dist/sandbox.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const sandboxDisposeHooks = Symbol("agentos.sandboxDisposeHooks");
|
|
3
|
+
function binding(def) {
|
|
4
|
+
return def;
|
|
5
|
+
}
|
|
6
|
+
function normalizeHeaders(headers) {
|
|
7
|
+
if (!headers) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
if (headers instanceof Headers) {
|
|
11
|
+
return Object.fromEntries(headers.entries());
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(headers)) {
|
|
14
|
+
return Object.fromEntries(headers);
|
|
15
|
+
}
|
|
16
|
+
return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
|
|
17
|
+
}
|
|
18
|
+
function getSerializableClientConfig(client) {
|
|
19
|
+
const serializable = client;
|
|
20
|
+
const baseUrl = serializable.baseUrl?.trim().replace(/\/+$/, "");
|
|
21
|
+
if (!baseUrl) {
|
|
22
|
+
throw new Error("Sandbox client does not expose a serializable baseUrl; connect with a standard SandboxAgent client instance");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
baseUrl,
|
|
26
|
+
...(serializable.token ? { token: serializable.token } : {}),
|
|
27
|
+
...(serializable.defaultHeaders
|
|
28
|
+
? { headers: normalizeHeaders(serializable.defaultHeaders) }
|
|
29
|
+
: {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function createSandboxFs(input) {
|
|
33
|
+
const options = input;
|
|
34
|
+
return {
|
|
35
|
+
id: "sandbox_agent",
|
|
36
|
+
config: {
|
|
37
|
+
...getSerializableClientConfig(options.client),
|
|
38
|
+
...(options.sandboxRoot ? { basePath: options.sandboxRoot } : {}),
|
|
39
|
+
...(options.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}),
|
|
40
|
+
...(options.maxFullReadBytes != null
|
|
41
|
+
? { maxFullReadBytes: options.maxFullReadBytes }
|
|
42
|
+
: {}),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function createSandboxBindings(input) {
|
|
47
|
+
const options = input;
|
|
48
|
+
const { client } = options;
|
|
49
|
+
return {
|
|
50
|
+
name: "sandbox",
|
|
51
|
+
description: "Execute commands and manage processes in a remote sandbox environment.",
|
|
52
|
+
tools: {
|
|
53
|
+
"run-command": binding({
|
|
54
|
+
description: "Run a command synchronously in the sandbox and return its stdout, stderr, and exit code.",
|
|
55
|
+
inputSchema: z.object({
|
|
56
|
+
command: z
|
|
57
|
+
.string()
|
|
58
|
+
.describe("The command to execute (e.g. 'ls', 'python3')."),
|
|
59
|
+
args: z.array(z.string()).optional(),
|
|
60
|
+
cwd: z.string().optional(),
|
|
61
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
62
|
+
timeoutMs: z.number().optional(),
|
|
63
|
+
}),
|
|
64
|
+
timeout: 120_000,
|
|
65
|
+
execute: async (input) => {
|
|
66
|
+
const result = await client.runProcess(input);
|
|
67
|
+
return {
|
|
68
|
+
stdout: result.stdout,
|
|
69
|
+
stderr: result.stderr,
|
|
70
|
+
exitCode: result.exitCode,
|
|
71
|
+
timedOut: result.timedOut,
|
|
72
|
+
durationMs: result.durationMs,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
"create-process": binding({
|
|
77
|
+
description: "Start a long-running background process in the sandbox. Returns a process ID for later management.",
|
|
78
|
+
inputSchema: z.object({
|
|
79
|
+
command: z.string(),
|
|
80
|
+
args: z.array(z.string()).optional(),
|
|
81
|
+
cwd: z.string().optional(),
|
|
82
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
83
|
+
}),
|
|
84
|
+
execute: async (input) => {
|
|
85
|
+
const proc = await client.createProcess(input);
|
|
86
|
+
return {
|
|
87
|
+
id: proc.id,
|
|
88
|
+
command: proc.command,
|
|
89
|
+
args: proc.args,
|
|
90
|
+
status: proc.status,
|
|
91
|
+
pid: proc.pid,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
"list-processes": binding({
|
|
96
|
+
description: "List all processes running in the sandbox.",
|
|
97
|
+
inputSchema: z.object({}),
|
|
98
|
+
execute: async () => {
|
|
99
|
+
const result = await client.listProcesses();
|
|
100
|
+
return {
|
|
101
|
+
processes: result.processes.map((p) => ({
|
|
102
|
+
id: p.id,
|
|
103
|
+
command: p.command,
|
|
104
|
+
args: p.args,
|
|
105
|
+
status: p.status,
|
|
106
|
+
exitCode: p.exitCode,
|
|
107
|
+
pid: p.pid,
|
|
108
|
+
})),
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
"stop-process": binding({
|
|
113
|
+
description: "Gracefully stop a running process in the sandbox.",
|
|
114
|
+
inputSchema: z.object({ id: z.string() }),
|
|
115
|
+
execute: async (input) => {
|
|
116
|
+
const proc = await client.stopProcess(input.id);
|
|
117
|
+
return {
|
|
118
|
+
id: proc.id,
|
|
119
|
+
status: proc.status,
|
|
120
|
+
exitCode: proc.exitCode,
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
"kill-process": binding({
|
|
125
|
+
description: "Forcefully kill a running process in the sandbox.",
|
|
126
|
+
inputSchema: z.object({ id: z.string() }),
|
|
127
|
+
execute: async (input) => {
|
|
128
|
+
const proc = await client.killProcess(input.id);
|
|
129
|
+
return {
|
|
130
|
+
id: proc.id,
|
|
131
|
+
status: proc.status,
|
|
132
|
+
exitCode: proc.exitCode,
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
"get-process-logs": binding({
|
|
137
|
+
description: "Get stdout/stderr logs from a sandbox process.",
|
|
138
|
+
inputSchema: z.object({
|
|
139
|
+
id: z.string(),
|
|
140
|
+
stream: z.enum(["stdout", "stderr", "combined"]).optional(),
|
|
141
|
+
tail: z.number().optional(),
|
|
142
|
+
}),
|
|
143
|
+
execute: async (input) => {
|
|
144
|
+
const result = await client.getProcessLogs(input.id, {
|
|
145
|
+
stream: input.stream,
|
|
146
|
+
tail: input.tail,
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
logs: result.entries.map((e) => {
|
|
150
|
+
const data = e.encoding === "base64"
|
|
151
|
+
? Buffer.from(e.data, "base64").toString("utf-8")
|
|
152
|
+
: e.data;
|
|
153
|
+
return {
|
|
154
|
+
data,
|
|
155
|
+
stream: e.stream,
|
|
156
|
+
timestampMs: e.timestampMs,
|
|
157
|
+
};
|
|
158
|
+
}),
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
}),
|
|
162
|
+
"send-input": binding({
|
|
163
|
+
description: "Send text input to an interactive sandbox process via stdin.",
|
|
164
|
+
inputSchema: z.object({
|
|
165
|
+
id: z.string(),
|
|
166
|
+
data: z.string(),
|
|
167
|
+
}),
|
|
168
|
+
execute: async (input) => {
|
|
169
|
+
await client.sendProcessInput(input.id, {
|
|
170
|
+
data: Buffer.from(input.data, "utf-8").toString("base64"),
|
|
171
|
+
encoding: "base64",
|
|
172
|
+
});
|
|
173
|
+
return { sent: true };
|
|
174
|
+
},
|
|
175
|
+
}),
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function isProviderOptions(input) {
|
|
180
|
+
return "provider" in input;
|
|
181
|
+
}
|
|
182
|
+
function isClientOptions(input) {
|
|
183
|
+
return "client" in input;
|
|
184
|
+
}
|
|
185
|
+
function assertNoLegacySandboxOptions(input) {
|
|
186
|
+
const legacyKeys = ["mount", "bindings", "path", "basePath"];
|
|
187
|
+
for (const key of legacyKeys) {
|
|
188
|
+
if (key in input) {
|
|
189
|
+
const replacement = key === "path" || key === "basePath" ? "sandboxRoot" : undefined;
|
|
190
|
+
throw new Error(replacement
|
|
191
|
+
? `sandbox.${key} has been removed; use sandbox.${replacement} instead.`
|
|
192
|
+
: `sandbox.${key} has been removed; sandbox mounts and bindings are always enabled.`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function normalizeSandboxInput(input) {
|
|
197
|
+
assertNoLegacySandboxOptions(input);
|
|
198
|
+
if (isProviderOptions(input)) {
|
|
199
|
+
if (typeof input.provider?.start !== "function") {
|
|
200
|
+
throw new Error("sandbox.provider must expose a start() function.");
|
|
201
|
+
}
|
|
202
|
+
const client = await input.provider.start();
|
|
203
|
+
return {
|
|
204
|
+
options: { ...input, client },
|
|
205
|
+
dispose: () => client.dispose?.(),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (!isClientOptions(input)) {
|
|
209
|
+
throw new Error("sandbox must be configured with either { provider } or { client }.");
|
|
210
|
+
}
|
|
211
|
+
const dispose = typeof input.dispose === "function"
|
|
212
|
+
? input.dispose
|
|
213
|
+
: input.dispose === true
|
|
214
|
+
? () => input.client.dispose?.()
|
|
215
|
+
: undefined;
|
|
216
|
+
return {
|
|
217
|
+
options: input,
|
|
218
|
+
dispose,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function attachSandboxDisposeHooks(options, hooks) {
|
|
222
|
+
if (hooks.length === 0) {
|
|
223
|
+
return options;
|
|
224
|
+
}
|
|
225
|
+
Object.defineProperty(options, sandboxDisposeHooks, {
|
|
226
|
+
value: hooks,
|
|
227
|
+
enumerable: false,
|
|
228
|
+
configurable: false,
|
|
229
|
+
writable: false,
|
|
230
|
+
});
|
|
231
|
+
return options;
|
|
232
|
+
}
|
|
233
|
+
export function getSandboxDisposeHooks(options) {
|
|
234
|
+
return options
|
|
235
|
+
? (options[sandboxDisposeHooks] ?? [])
|
|
236
|
+
: [];
|
|
237
|
+
}
|
|
238
|
+
export async function resolveSandboxOptions(options) {
|
|
239
|
+
const { sandbox, ...rest } = options;
|
|
240
|
+
if (!sandbox) {
|
|
241
|
+
return rest;
|
|
242
|
+
}
|
|
243
|
+
const normalizedSandbox = await normalizeSandboxInput(sandbox);
|
|
244
|
+
const sandboxOptions = normalizedSandbox.options;
|
|
245
|
+
const expanded = rest;
|
|
246
|
+
const mountPath = sandboxOptions.mountPath ?? "/mnt/sandbox";
|
|
247
|
+
const mounts = [
|
|
248
|
+
...(expanded.mounts ?? []),
|
|
249
|
+
{
|
|
250
|
+
path: mountPath,
|
|
251
|
+
plugin: createSandboxFs(sandboxOptions),
|
|
252
|
+
readOnly: sandboxOptions.readOnly,
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
const toolKits = [
|
|
256
|
+
...(expanded.toolKits ?? []),
|
|
257
|
+
createSandboxBindings(sandboxOptions),
|
|
258
|
+
];
|
|
259
|
+
return attachSandboxDisposeHooks({
|
|
260
|
+
...expanded,
|
|
261
|
+
mounts,
|
|
262
|
+
toolKits,
|
|
263
|
+
}, normalizedSandbox.dispose ? [normalizedSandbox.dispose] : []);
|
|
264
|
+
}
|
|
@@ -14,7 +14,6 @@ export declare function writeAcpRuntimeKind(bc: bare.ByteCursor, x: AcpRuntimeKi
|
|
|
14
14
|
export type AcpCreateSessionRequest = {
|
|
15
15
|
readonly agentType: string;
|
|
16
16
|
readonly runtime: AcpRuntimeKind;
|
|
17
|
-
readonly adapterEntrypoint: string;
|
|
18
17
|
readonly cwd: string;
|
|
19
18
|
readonly args: readonly string[];
|
|
20
19
|
readonly env: ReadonlyMap<string, string>;
|
|
@@ -33,6 +32,27 @@ export type AcpSessionRequest = {
|
|
|
33
32
|
};
|
|
34
33
|
export declare function readAcpSessionRequest(bc: bare.ByteCursor): AcpSessionRequest;
|
|
35
34
|
export declare function writeAcpSessionRequest(bc: bare.ByteCursor, x: AcpSessionRequest): void;
|
|
35
|
+
/**
|
|
36
|
+
* Enumerate the agents available in this VM. The sidecar answers from the already
|
|
37
|
+
* projected `/opt/agentos` packages (client parses no manifests).
|
|
38
|
+
*/
|
|
39
|
+
export type AcpListAgentsRequest = {
|
|
40
|
+
readonly reserved: boolean;
|
|
41
|
+
};
|
|
42
|
+
export declare function readAcpListAgentsRequest(bc: bare.ByteCursor): AcpListAgentsRequest;
|
|
43
|
+
export declare function writeAcpListAgentsRequest(bc: bare.ByteCursor, x: AcpListAgentsRequest): void;
|
|
44
|
+
export type AcpAgentEntry = {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly installed: boolean;
|
|
47
|
+
readonly adapterEntrypoint: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function readAcpAgentEntry(bc: bare.ByteCursor): AcpAgentEntry;
|
|
50
|
+
export declare function writeAcpAgentEntry(bc: bare.ByteCursor, x: AcpAgentEntry): void;
|
|
51
|
+
export type AcpListAgentsResponse = {
|
|
52
|
+
readonly agents: readonly AcpAgentEntry[];
|
|
53
|
+
};
|
|
54
|
+
export declare function readAcpListAgentsResponse(bc: bare.ByteCursor): AcpListAgentsResponse;
|
|
55
|
+
export declare function writeAcpListAgentsResponse(bc: bare.ByteCursor, x: AcpListAgentsResponse): void;
|
|
36
56
|
export type AcpGetSessionStateRequest = {
|
|
37
57
|
readonly sessionId: string;
|
|
38
58
|
};
|
|
@@ -93,6 +113,9 @@ export type AcpRequest = {
|
|
|
93
113
|
} | {
|
|
94
114
|
readonly tag: "AcpDeliverAgentOutputRequest";
|
|
95
115
|
readonly val: AcpDeliverAgentOutputRequest;
|
|
116
|
+
} | {
|
|
117
|
+
readonly tag: "AcpListAgentsRequest";
|
|
118
|
+
readonly val: AcpListAgentsRequest;
|
|
96
119
|
};
|
|
97
120
|
export declare function readAcpRequest(bc: bare.ByteCursor): AcpRequest;
|
|
98
121
|
export declare function writeAcpRequest(bc: bare.ByteCursor, x: AcpRequest): void;
|
|
@@ -185,6 +208,9 @@ export type AcpResponse = {
|
|
|
185
208
|
} | {
|
|
186
209
|
readonly tag: "AcpPendingResponse";
|
|
187
210
|
readonly val: AcpPendingResponse;
|
|
211
|
+
} | {
|
|
212
|
+
readonly tag: "AcpListAgentsResponse";
|
|
213
|
+
readonly val: AcpListAgentsResponse;
|
|
188
214
|
};
|
|
189
215
|
export declare function readAcpResponse(bc: bare.ByteCursor): AcpResponse;
|
|
190
216
|
export declare function writeAcpResponse(bc: bare.ByteCursor, x: AcpResponse): void;
|
|
@@ -96,7 +96,6 @@ export function readAcpCreateSessionRequest(bc) {
|
|
|
96
96
|
return {
|
|
97
97
|
agentType: bare.readString(bc),
|
|
98
98
|
runtime: readAcpRuntimeKind(bc),
|
|
99
|
-
adapterEntrypoint: bare.readString(bc),
|
|
100
99
|
cwd: bare.readString(bc),
|
|
101
100
|
args: read0(bc),
|
|
102
101
|
env: read1(bc),
|
|
@@ -110,7 +109,6 @@ export function readAcpCreateSessionRequest(bc) {
|
|
|
110
109
|
export function writeAcpCreateSessionRequest(bc, x) {
|
|
111
110
|
bare.writeString(bc, x.agentType);
|
|
112
111
|
writeAcpRuntimeKind(bc, x.runtime);
|
|
113
|
-
bare.writeString(bc, x.adapterEntrypoint);
|
|
114
112
|
bare.writeString(bc, x.cwd);
|
|
115
113
|
write0(bc, x.args);
|
|
116
114
|
write1(bc, x.env);
|
|
@@ -141,6 +139,51 @@ export function writeAcpSessionRequest(bc, x) {
|
|
|
141
139
|
bare.writeString(bc, x.method);
|
|
142
140
|
write3(bc, x.params);
|
|
143
141
|
}
|
|
142
|
+
export function readAcpListAgentsRequest(bc) {
|
|
143
|
+
return {
|
|
144
|
+
reserved: bare.readBool(bc),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export function writeAcpListAgentsRequest(bc, x) {
|
|
148
|
+
bare.writeBool(bc, x.reserved);
|
|
149
|
+
}
|
|
150
|
+
export function readAcpAgentEntry(bc) {
|
|
151
|
+
return {
|
|
152
|
+
id: bare.readString(bc),
|
|
153
|
+
installed: bare.readBool(bc),
|
|
154
|
+
adapterEntrypoint: bare.readString(bc),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export function writeAcpAgentEntry(bc, x) {
|
|
158
|
+
bare.writeString(bc, x.id);
|
|
159
|
+
bare.writeBool(bc, x.installed);
|
|
160
|
+
bare.writeString(bc, x.adapterEntrypoint);
|
|
161
|
+
}
|
|
162
|
+
function read4(bc) {
|
|
163
|
+
const len = bare.readUintSafe(bc);
|
|
164
|
+
if (len === 0) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
const result = [readAcpAgentEntry(bc)];
|
|
168
|
+
for (let i = 1; i < len; i++) {
|
|
169
|
+
result[i] = readAcpAgentEntry(bc);
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
function write4(bc, x) {
|
|
174
|
+
bare.writeUintSafe(bc, x.length);
|
|
175
|
+
for (let i = 0; i < x.length; i++) {
|
|
176
|
+
writeAcpAgentEntry(bc, x[i]);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export function readAcpListAgentsResponse(bc) {
|
|
180
|
+
return {
|
|
181
|
+
agents: read4(bc),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
export function writeAcpListAgentsResponse(bc, x) {
|
|
185
|
+
write4(bc, x.agents);
|
|
186
|
+
}
|
|
144
187
|
export function readAcpGetSessionStateRequest(bc) {
|
|
145
188
|
return {
|
|
146
189
|
sessionId: bare.readString(bc),
|
|
@@ -199,6 +242,8 @@ export function readAcpRequest(bc) {
|
|
|
199
242
|
return { tag: "AcpResumeSessionRequest", val: readAcpResumeSessionRequest(bc) };
|
|
200
243
|
case 5:
|
|
201
244
|
return { tag: "AcpDeliverAgentOutputRequest", val: readAcpDeliverAgentOutputRequest(bc) };
|
|
245
|
+
case 6:
|
|
246
|
+
return { tag: "AcpListAgentsRequest", val: readAcpListAgentsRequest(bc) };
|
|
202
247
|
default: {
|
|
203
248
|
bc.offset = offset;
|
|
204
249
|
throw new bare.BareError(offset, "invalid tag");
|
|
@@ -237,6 +282,11 @@ export function writeAcpRequest(bc, x) {
|
|
|
237
282
|
writeAcpDeliverAgentOutputRequest(bc, x.val);
|
|
238
283
|
break;
|
|
239
284
|
}
|
|
285
|
+
case "AcpListAgentsRequest": {
|
|
286
|
+
bare.writeU8(bc, 6);
|
|
287
|
+
writeAcpListAgentsRequest(bc, x.val);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
240
290
|
}
|
|
241
291
|
}
|
|
242
292
|
export function encodeAcpRequest(x, config) {
|
|
@@ -253,16 +303,16 @@ export function decodeAcpRequest(bytes) {
|
|
|
253
303
|
}
|
|
254
304
|
return result;
|
|
255
305
|
}
|
|
256
|
-
function
|
|
306
|
+
function read5(bc) {
|
|
257
307
|
return bare.readBool(bc) ? bare.readU32(bc) : null;
|
|
258
308
|
}
|
|
259
|
-
function
|
|
309
|
+
function write5(bc, x) {
|
|
260
310
|
bare.writeBool(bc, x != null);
|
|
261
311
|
if (x != null) {
|
|
262
312
|
bare.writeU32(bc, x);
|
|
263
313
|
}
|
|
264
314
|
}
|
|
265
|
-
function
|
|
315
|
+
function read6(bc) {
|
|
266
316
|
const len = bare.readUintSafe(bc);
|
|
267
317
|
if (len === 0) {
|
|
268
318
|
return [];
|
|
@@ -273,7 +323,7 @@ function read5(bc) {
|
|
|
273
323
|
}
|
|
274
324
|
return result;
|
|
275
325
|
}
|
|
276
|
-
function
|
|
326
|
+
function write6(bc, x) {
|
|
277
327
|
bare.writeUintSafe(bc, x.length);
|
|
278
328
|
for (let i = 0; i < x.length; i++) {
|
|
279
329
|
writeJsonUtf8(bc, x[i]);
|
|
@@ -282,18 +332,18 @@ function write5(bc, x) {
|
|
|
282
332
|
export function readAcpSessionCreatedResponse(bc) {
|
|
283
333
|
return {
|
|
284
334
|
sessionId: bare.readString(bc),
|
|
285
|
-
pid:
|
|
335
|
+
pid: read5(bc),
|
|
286
336
|
modes: read3(bc),
|
|
287
|
-
configOptions:
|
|
337
|
+
configOptions: read6(bc),
|
|
288
338
|
agentCapabilities: read3(bc),
|
|
289
339
|
agentInfo: read3(bc),
|
|
290
340
|
};
|
|
291
341
|
}
|
|
292
342
|
export function writeAcpSessionCreatedResponse(bc, x) {
|
|
293
343
|
bare.writeString(bc, x.sessionId);
|
|
294
|
-
|
|
344
|
+
write5(bc, x.pid);
|
|
295
345
|
write3(bc, x.modes);
|
|
296
|
-
|
|
346
|
+
write6(bc, x.configOptions);
|
|
297
347
|
write3(bc, x.agentCapabilities);
|
|
298
348
|
write3(bc, x.agentInfo);
|
|
299
349
|
}
|
|
@@ -307,10 +357,10 @@ export function writeAcpSessionRpcResponse(bc, x) {
|
|
|
307
357
|
bare.writeString(bc, x.sessionId);
|
|
308
358
|
writeJsonUtf8(bc, x.response);
|
|
309
359
|
}
|
|
310
|
-
function
|
|
360
|
+
function read7(bc) {
|
|
311
361
|
return bare.readBool(bc) ? bare.readI32(bc) : null;
|
|
312
362
|
}
|
|
313
|
-
function
|
|
363
|
+
function write7(bc, x) {
|
|
314
364
|
bare.writeBool(bc, x != null);
|
|
315
365
|
if (x != null) {
|
|
316
366
|
bare.writeI32(bc, x);
|
|
@@ -321,11 +371,11 @@ export function readAcpSessionStateResponse(bc) {
|
|
|
321
371
|
sessionId: bare.readString(bc),
|
|
322
372
|
agentType: bare.readString(bc),
|
|
323
373
|
processId: bare.readString(bc),
|
|
324
|
-
pid:
|
|
374
|
+
pid: read5(bc),
|
|
325
375
|
closed: bare.readBool(bc),
|
|
326
|
-
exitCode:
|
|
376
|
+
exitCode: read7(bc),
|
|
327
377
|
modes: read3(bc),
|
|
328
|
-
configOptions:
|
|
378
|
+
configOptions: read6(bc),
|
|
329
379
|
agentCapabilities: read3(bc),
|
|
330
380
|
agentInfo: read3(bc),
|
|
331
381
|
};
|
|
@@ -334,11 +384,11 @@ export function writeAcpSessionStateResponse(bc, x) {
|
|
|
334
384
|
bare.writeString(bc, x.sessionId);
|
|
335
385
|
bare.writeString(bc, x.agentType);
|
|
336
386
|
bare.writeString(bc, x.processId);
|
|
337
|
-
|
|
387
|
+
write5(bc, x.pid);
|
|
338
388
|
bare.writeBool(bc, x.closed);
|
|
339
|
-
|
|
389
|
+
write7(bc, x.exitCode);
|
|
340
390
|
write3(bc, x.modes);
|
|
341
|
-
|
|
391
|
+
write6(bc, x.configOptions);
|
|
342
392
|
write3(bc, x.agentCapabilities);
|
|
343
393
|
write3(bc, x.agentInfo);
|
|
344
394
|
}
|
|
@@ -396,6 +446,8 @@ export function readAcpResponse(bc) {
|
|
|
396
446
|
return { tag: "AcpErrorResponse", val: readAcpErrorResponse(bc) };
|
|
397
447
|
case 6:
|
|
398
448
|
return { tag: "AcpPendingResponse", val: readAcpPendingResponse(bc) };
|
|
449
|
+
case 7:
|
|
450
|
+
return { tag: "AcpListAgentsResponse", val: readAcpListAgentsResponse(bc) };
|
|
399
451
|
default: {
|
|
400
452
|
bc.offset = offset;
|
|
401
453
|
throw new bare.BareError(offset, "invalid tag");
|
|
@@ -439,6 +491,11 @@ export function writeAcpResponse(bc, x) {
|
|
|
439
491
|
writeAcpPendingResponse(bc, x.val);
|
|
440
492
|
break;
|
|
441
493
|
}
|
|
494
|
+
case "AcpListAgentsResponse": {
|
|
495
|
+
bare.writeU8(bc, 7);
|
|
496
|
+
writeAcpListAgentsResponse(bc, x.val);
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
442
499
|
}
|
|
443
500
|
}
|
|
444
501
|
export function encodeAcpResponse(x, config) {
|
|
@@ -484,7 +541,7 @@ export function readAcpAgentExitedEvent(bc) {
|
|
|
484
541
|
sessionId: bare.readString(bc),
|
|
485
542
|
agentType: bare.readString(bc),
|
|
486
543
|
processId: bare.readString(bc),
|
|
487
|
-
exitCode:
|
|
544
|
+
exitCode: read7(bc),
|
|
488
545
|
restart: bare.readString(bc),
|
|
489
546
|
restartCount: bare.readU32(bc),
|
|
490
547
|
maxRestarts: bare.readU32(bc),
|
|
@@ -494,7 +551,7 @@ export function writeAcpAgentExitedEvent(bc, x) {
|
|
|
494
551
|
bare.writeString(bc, x.sessionId);
|
|
495
552
|
bare.writeString(bc, x.agentType);
|
|
496
553
|
bare.writeString(bc, x.processId);
|
|
497
|
-
|
|
554
|
+
write7(bc, x.exitCode);
|
|
498
555
|
bare.writeString(bc, x.restart);
|
|
499
556
|
bare.writeU32(bc, x.restartCount);
|
|
500
557
|
bare.writeU32(bc, x.maxRestarts);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import "@
|
|
2
|
-
import { SidecarProcess } from "@
|
|
3
|
-
export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@
|
|
1
|
+
import "@rivet-dev/agentos-runtime-core/native-client";
|
|
2
|
+
import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
3
|
+
export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
4
4
|
export declare const NativeSidecarProcessClient: typeof SidecarProcess;
|
|
5
|
-
export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@
|
|
5
|
+
export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarLinkPackageResult, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedAgent, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
6
|
+
export type { SidecarVmConfiguredResponse as SidecarConfigureVmResult, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Register the native sidecar spawn factory (side effect). After the
|
|
2
|
-
// @
|
|
2
|
+
// @rivet-dev/agentos-runtime-core SidecarProcess refactor, native spawn is provided by a
|
|
3
3
|
// separately-registered factory; importing native-client wires it up so
|
|
4
4
|
// SidecarProcess.spawn works in this native runtime.
|
|
5
|
-
import "@
|
|
6
|
-
import { SidecarProcess } from "@
|
|
7
|
-
export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@
|
|
5
|
+
import "@rivet-dev/agentos-runtime-core/native-client";
|
|
6
|
+
import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
7
|
+
export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
8
8
|
export const NativeSidecarProcessClient = SidecarProcess;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PermissionsPolicy } from "@
|
|
1
|
+
import type { PermissionsPolicy } from "@rivet-dev/agentos-runtime-core/vm-config";
|
|
2
2
|
import type { Permissions } from "../runtime-compat.js";
|
|
3
3
|
export declare function serializePermissionsForSidecar(permissions?: Permissions): PermissionsPolicy;
|