@rivet-dev/agentos-core 0.0.0-agentos-dylib-plugin.f065be7 → 0.0.0-chdir-fix.3d9feab
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 +8 -11
- package/dist/agent-os.d.ts +185 -43
- package/dist/agent-os.js +834 -536
- package/dist/agentos-package.d.ts +29 -0
- package/dist/agentos-package.js +88 -0
- package/dist/base-filesystem.d.ts +2 -15
- package/dist/base-filesystem.js +23 -171
- package/dist/cron/cron-manager.js +1 -4
- package/dist/cron/types.d.ts +1 -1
- package/dist/default-software.d.ts +8 -0
- package/dist/default-software.js +10 -0
- 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/host-tools-zod.js +27 -7
- package/dist/host-tools.js +9 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/layers.d.ts +3 -3
- package/dist/layers.js +22 -13
- package/dist/options-schema.d.ts +453 -0
- package/dist/options-schema.js +268 -0
- package/dist/packages.d.ts +17 -116
- package/dist/packages.js +35 -322
- package/dist/runtime-compat.d.ts +27 -7
- package/dist/runtime-compat.js +133 -147
- package/dist/runtime.d.ts +37 -7
- package/dist/sandbox.d.ts +112 -0
- package/dist/sandbox.js +264 -0
- package/dist/sidecar/{agent-os-protocol.d.ts → agentos-protocol.d.ts} +99 -1
- package/dist/sidecar/{agent-os-protocol.js → agentos-protocol.js} +156 -19
- package/dist/sidecar/native-process-client.d.ts +6 -2
- package/dist/sidecar/native-process-client.js +8 -1
- package/dist/sidecar/permissions.d.ts +1 -1
- package/dist/sidecar/permissions.js +4 -4
- package/dist/sidecar/rpc-client.d.ts +87 -6
- package/dist/sidecar/rpc-client.js +433 -93
- package/dist/test/sandbox-agent.js +1 -1
- package/dist/types.d.ts +10 -3
- package/package.json +42 -35
- package/dist/agents.d.ts +0 -63
- package/dist/agents.js +0 -42
- package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
|
@@ -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
|
};
|
|
@@ -60,6 +80,21 @@ export type AcpResumeSessionRequest = {
|
|
|
60
80
|
};
|
|
61
81
|
export declare function readAcpResumeSessionRequest(bc: bare.ByteCursor): AcpResumeSessionRequest;
|
|
62
82
|
export declare function writeAcpResumeSessionRequest(bc: bare.ByteCursor, x: AcpResumeSessionRequest): void;
|
|
83
|
+
/**
|
|
84
|
+
* Browser RESUMABLE path only (AGENTOS-WEB-ASYNC-AGENTS.md §3.2.1): the kernel
|
|
85
|
+
* worker feeds a chunk of the agent's stdout into the in-flight create_session /
|
|
86
|
+
* session/prompt handshake. The synchronous sidecar would block inside one
|
|
87
|
+
* pushFrame; the resumable browser path returns between steps so the worker can
|
|
88
|
+
* service the agent's own syscalls (incl. pi's net call for inference) on fresh,
|
|
89
|
+
* non-nested pushFrames. `processId` is the handshake handle returned in the
|
|
90
|
+
* AcpPendingResponse for the originating create/prompt request.
|
|
91
|
+
*/
|
|
92
|
+
export type AcpDeliverAgentOutputRequest = {
|
|
93
|
+
readonly processId: string;
|
|
94
|
+
readonly chunk: ArrayBuffer;
|
|
95
|
+
};
|
|
96
|
+
export declare function readAcpDeliverAgentOutputRequest(bc: bare.ByteCursor): AcpDeliverAgentOutputRequest;
|
|
97
|
+
export declare function writeAcpDeliverAgentOutputRequest(bc: bare.ByteCursor, x: AcpDeliverAgentOutputRequest): void;
|
|
63
98
|
export type AcpRequest = {
|
|
64
99
|
readonly tag: "AcpCreateSessionRequest";
|
|
65
100
|
readonly val: AcpCreateSessionRequest;
|
|
@@ -75,6 +110,12 @@ export type AcpRequest = {
|
|
|
75
110
|
} | {
|
|
76
111
|
readonly tag: "AcpResumeSessionRequest";
|
|
77
112
|
readonly val: AcpResumeSessionRequest;
|
|
113
|
+
} | {
|
|
114
|
+
readonly tag: "AcpDeliverAgentOutputRequest";
|
|
115
|
+
readonly val: AcpDeliverAgentOutputRequest;
|
|
116
|
+
} | {
|
|
117
|
+
readonly tag: "AcpListAgentsRequest";
|
|
118
|
+
readonly val: AcpListAgentsRequest;
|
|
78
119
|
};
|
|
79
120
|
export declare function readAcpRequest(bc: bare.ByteCursor): AcpRequest;
|
|
80
121
|
export declare function writeAcpRequest(bc: bare.ByteCursor, x: AcpRequest): void;
|
|
@@ -134,6 +175,18 @@ export type AcpErrorResponse = {
|
|
|
134
175
|
};
|
|
135
176
|
export declare function readAcpErrorResponse(bc: bare.ByteCursor): AcpErrorResponse;
|
|
136
177
|
export declare function writeAcpErrorResponse(bc: bare.ByteCursor, x: AcpErrorResponse): void;
|
|
178
|
+
/**
|
|
179
|
+
* Browser RESUMABLE path: the create_session / session/prompt request (and each
|
|
180
|
+
* AcpDeliverAgentOutputRequest that has not yet completed the handshake) returns
|
|
181
|
+
* this, carrying the `processId` handle the kernel worker drives the interaction
|
|
182
|
+
* with. The real result (AcpSessionCreatedResponse / AcpSessionRpcResponse) is
|
|
183
|
+
* delivered as the response to the AcpDeliverAgentOutputRequest that completes it.
|
|
184
|
+
*/
|
|
185
|
+
export type AcpPendingResponse = {
|
|
186
|
+
readonly processId: string;
|
|
187
|
+
};
|
|
188
|
+
export declare function readAcpPendingResponse(bc: bare.ByteCursor): AcpPendingResponse;
|
|
189
|
+
export declare function writeAcpPendingResponse(bc: bare.ByteCursor, x: AcpPendingResponse): void;
|
|
137
190
|
export type AcpResponse = {
|
|
138
191
|
readonly tag: "AcpSessionCreatedResponse";
|
|
139
192
|
readonly val: AcpSessionCreatedResponse;
|
|
@@ -152,6 +205,12 @@ export type AcpResponse = {
|
|
|
152
205
|
} | {
|
|
153
206
|
readonly tag: "AcpErrorResponse";
|
|
154
207
|
readonly val: AcpErrorResponse;
|
|
208
|
+
} | {
|
|
209
|
+
readonly tag: "AcpPendingResponse";
|
|
210
|
+
readonly val: AcpPendingResponse;
|
|
211
|
+
} | {
|
|
212
|
+
readonly tag: "AcpListAgentsResponse";
|
|
213
|
+
readonly val: AcpListAgentsResponse;
|
|
155
214
|
};
|
|
156
215
|
export declare function readAcpResponse(bc: bare.ByteCursor): AcpResponse;
|
|
157
216
|
export declare function writeAcpResponse(bc: bare.ByteCursor, x: AcpResponse): void;
|
|
@@ -163,9 +222,48 @@ export type AcpSessionEvent = {
|
|
|
163
222
|
};
|
|
164
223
|
export declare function readAcpSessionEvent(bc: bare.ByteCursor): AcpSessionEvent;
|
|
165
224
|
export declare function writeAcpSessionEvent(bc: bare.ByteCursor, x: AcpSessionEvent): void;
|
|
225
|
+
export type AcpAgentStderrEvent = {
|
|
226
|
+
readonly sessionId: string;
|
|
227
|
+
readonly agentType: string;
|
|
228
|
+
readonly processId: string;
|
|
229
|
+
readonly chunk: ArrayBuffer;
|
|
230
|
+
};
|
|
231
|
+
export declare function readAcpAgentStderrEvent(bc: bare.ByteCursor): AcpAgentStderrEvent;
|
|
232
|
+
export declare function writeAcpAgentStderrEvent(bc: bare.ByteCursor, x: AcpAgentStderrEvent): void;
|
|
233
|
+
/**
|
|
234
|
+
* Emitted when the ACP adapter process exits without an explicit close_session —
|
|
235
|
+
* a crash from the host's perspective (any spontaneous exit, including code 0).
|
|
236
|
+
* `restart` reports the sidecar's bounded auto-restart outcome:
|
|
237
|
+
* "restarted" — adapter respawned and the session was natively re-attached
|
|
238
|
+
* (session/load | session/resume) under the same sessionId;
|
|
239
|
+
* the session stays live.
|
|
240
|
+
* "unsupported" — the respawned adapter does not advertise a native resume
|
|
241
|
+
* capability; the session record was evicted.
|
|
242
|
+
* "failed" — the respawn or the native re-attach errored; evicted.
|
|
243
|
+
* "exhausted" — maxRestarts was already spent for this session; evicted.
|
|
244
|
+
* `exitCode` is absent when the exit was observed indirectly (e.g. a write to
|
|
245
|
+
* the adapter's stdin failed because the process was already gone).
|
|
246
|
+
*/
|
|
247
|
+
export type AcpAgentExitedEvent = {
|
|
248
|
+
readonly sessionId: string;
|
|
249
|
+
readonly agentType: string;
|
|
250
|
+
readonly processId: string;
|
|
251
|
+
readonly exitCode: i32 | null;
|
|
252
|
+
readonly restart: string;
|
|
253
|
+
readonly restartCount: u32;
|
|
254
|
+
readonly maxRestarts: u32;
|
|
255
|
+
};
|
|
256
|
+
export declare function readAcpAgentExitedEvent(bc: bare.ByteCursor): AcpAgentExitedEvent;
|
|
257
|
+
export declare function writeAcpAgentExitedEvent(bc: bare.ByteCursor, x: AcpAgentExitedEvent): void;
|
|
166
258
|
export type AcpEvent = {
|
|
167
259
|
readonly tag: "AcpSessionEvent";
|
|
168
260
|
readonly val: AcpSessionEvent;
|
|
261
|
+
} | {
|
|
262
|
+
readonly tag: "AcpAgentStderrEvent";
|
|
263
|
+
readonly val: AcpAgentStderrEvent;
|
|
264
|
+
} | {
|
|
265
|
+
readonly tag: "AcpAgentExitedEvent";
|
|
266
|
+
readonly val: AcpAgentExitedEvent;
|
|
169
267
|
};
|
|
170
268
|
export declare function readAcpEvent(bc: bare.ByteCursor): AcpEvent;
|
|
171
269
|
export declare function writeAcpEvent(bc: bare.ByteCursor, x: AcpEvent): void;
|