@rivet-dev/agentos-core 0.0.0-integrate-dylib-into-main.815fcda → 0.0.0-nathan-binding-workspace.dd41c31
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 +12 -12
- package/dist/{agent-os.d.ts → agentos.d.ts} +30 -85
- package/dist/{agent-os.js → agentos.js} +126 -185
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +1 -1
- package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
- package/dist/{host-tools-zod.js → bindings-zod.js} +16 -16
- package/dist/bindings.d.ts +45 -0
- package/dist/bindings.js +26 -0
- package/dist/cron/cron-manager.d.ts +3 -3
- package/dist/cron/cron-manager.js +1 -1
- package/dist/cron/types.d.ts +1 -1
- package/dist/host-dir-mount.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/json-rpc.d.ts +1 -17
- package/dist/json-rpc.js +0 -8
- package/dist/packages.js +1 -1
- package/dist/runtime-compat.d.ts +2 -2
- package/dist/runtime-compat.js +6 -5
- package/dist/runtime.d.ts +2 -2
- package/dist/sidecar/agentos-protocol.d.ts +0 -36
- package/dist/sidecar/agentos-protocol.js +1 -41
- package/dist/sidecar/native-process-client.d.ts +3 -2
- package/dist/sidecar/native-process-client.js +6 -1
- package/dist/sidecar/permissions.js +4 -4
- package/dist/sidecar/process.d.ts +4 -4
- package/dist/sidecar/process.js +3 -3
- package/dist/sidecar/rpc-client.d.ts +40 -40
- package/dist/sidecar/rpc-client.js +8 -8
- package/dist/test/runtime.d.ts +1 -1
- package/dist/test/runtime.js +1 -1
- package/dist/types.d.ts +3 -3
- package/package.json +6 -5
- package/dist/host-tools.d.ts +0 -45
- package/dist/host-tools.js +0 -26
package/dist/agents.js
CHANGED
|
@@ -22,7 +22,7 @@ export const AGENT_CONFIGS = {
|
|
|
22
22
|
defaultEnv: {
|
|
23
23
|
CLAUDE_AGENT_SDK_CLIENT_APP: "@rivet-dev/agentos",
|
|
24
24
|
CLAUDE_CODE_SIMPLE: "1",
|
|
25
|
-
|
|
25
|
+
CLAUDE_CODE_FORCE_AGENTOS_RIPGREP: "1",
|
|
26
26
|
CLAUDE_CODE_DEFER_GROWTHBOOK_INIT: "1",
|
|
27
27
|
CLAUDE_CODE_DISABLE_CWD_PERSIST: "1",
|
|
28
28
|
CLAUDE_CODE_DISABLE_DEV_NULL_REDIRECT: "1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class BindingSchemaConversionError extends Error {
|
|
3
3
|
readonly path: string;
|
|
4
4
|
readonly zodType: string;
|
|
5
5
|
constructor(path: string, zodType: string, details?: string);
|
|
@@ -14,7 +14,7 @@ const UNSUPPORTED_TYPES = new Set([
|
|
|
14
14
|
"pipe",
|
|
15
15
|
"tuple",
|
|
16
16
|
]);
|
|
17
|
-
export class
|
|
17
|
+
export class BindingSchemaConversionError extends Error {
|
|
18
18
|
path;
|
|
19
19
|
zodType;
|
|
20
20
|
constructor(path, zodType, details) {
|
|
@@ -24,7 +24,7 @@ export class HostToolSchemaConversionError extends Error {
|
|
|
24
24
|
]
|
|
25
25
|
.filter(Boolean)
|
|
26
26
|
.join(" "));
|
|
27
|
-
this.name = "
|
|
27
|
+
this.name = "BindingSchemaConversionError";
|
|
28
28
|
this.path = path;
|
|
29
29
|
this.zodType = zodType;
|
|
30
30
|
}
|
|
@@ -89,24 +89,24 @@ function isCustomRefinement(check) {
|
|
|
89
89
|
}
|
|
90
90
|
function validateChecks(schema, path, typeName) {
|
|
91
91
|
if (getChecks(schema).some(isCustomRefinement)) {
|
|
92
|
-
throw new
|
|
92
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "custom refinements cannot be represented faithfully in JSON Schema");
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
function validateSchema(schema, path) {
|
|
96
96
|
const typeName = normalizeTypeName(schema);
|
|
97
97
|
if (metadataProducesRefs(schema)) {
|
|
98
|
-
throw new
|
|
98
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "metadata that emits $ref/$defs is not supported");
|
|
99
99
|
}
|
|
100
100
|
if (UNSUPPORTED_TYPES.has(typeName)) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName));
|
|
102
102
|
}
|
|
103
103
|
if (typeName === "discriminatedunion") {
|
|
104
|
-
throw new
|
|
104
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName));
|
|
105
105
|
}
|
|
106
106
|
if (TRANSPARENT_WRAPPER_TYPES.has(typeName)) {
|
|
107
107
|
const inner = getInnerSchema(schema);
|
|
108
108
|
if (!inner) {
|
|
109
|
-
throw new
|
|
109
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "wrapper schema is missing its inner schema");
|
|
110
110
|
}
|
|
111
111
|
validateSchema(inner, path);
|
|
112
112
|
return;
|
|
@@ -114,7 +114,7 @@ function validateSchema(schema, path) {
|
|
|
114
114
|
if (typeName === "nullable") {
|
|
115
115
|
const inner = getInnerSchema(schema);
|
|
116
116
|
if (!inner) {
|
|
117
|
-
throw new
|
|
117
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "nullable schema is missing its inner schema");
|
|
118
118
|
}
|
|
119
119
|
validateSchema(inner, path);
|
|
120
120
|
return;
|
|
@@ -133,7 +133,7 @@ function validateSchema(schema, path) {
|
|
|
133
133
|
if (typeName === "array") {
|
|
134
134
|
const itemSchema = getSchemaDef(schema).element;
|
|
135
135
|
if (!itemSchema) {
|
|
136
|
-
throw new
|
|
136
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "array schema is missing its item schema");
|
|
137
137
|
}
|
|
138
138
|
validateSchema(itemSchema, `${path}[]`);
|
|
139
139
|
return;
|
|
@@ -143,11 +143,11 @@ function validateSchema(schema, path) {
|
|
|
143
143
|
const keySchema = def.keyType;
|
|
144
144
|
const valueSchema = def.valueType;
|
|
145
145
|
if (!keySchema || !valueSchema) {
|
|
146
|
-
throw new
|
|
146
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "record schema is missing its key or value schema");
|
|
147
147
|
}
|
|
148
148
|
const keyTypeName = normalizeTypeName(keySchema);
|
|
149
149
|
if (keyTypeName !== "string" || getChecks(keySchema).length > 0) {
|
|
150
|
-
throw new
|
|
150
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "record keys must be unconstrained strings");
|
|
151
151
|
}
|
|
152
152
|
validateSchema(valueSchema, `${path}<record-value>`);
|
|
153
153
|
return;
|
|
@@ -155,7 +155,7 @@ function validateSchema(schema, path) {
|
|
|
155
155
|
if (typeName === "union") {
|
|
156
156
|
const options = getSchemaDef(schema).options;
|
|
157
157
|
if (!Array.isArray(options) || options.length === 0) {
|
|
158
|
-
throw new
|
|
158
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "union schema is missing its options");
|
|
159
159
|
}
|
|
160
160
|
for (let index = 0; index < options.length; index += 1) {
|
|
161
161
|
validateSchema(options[index], `${path}<union:${index}>`);
|
|
@@ -168,7 +168,7 @@ function validateSchema(schema, path) {
|
|
|
168
168
|
const [literalValue] = literalValues;
|
|
169
169
|
if (literalValues.length !== 1 ||
|
|
170
170
|
!("string number boolean".split(" ").includes(typeof literalValue) || literalValue === null)) {
|
|
171
|
-
throw new
|
|
171
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName), "literal values must be JSON primitives");
|
|
172
172
|
}
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
@@ -179,7 +179,7 @@ function validateSchema(schema, path) {
|
|
|
179
179
|
typeName === "nativeenum") {
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
|
-
throw new
|
|
182
|
+
throw new BindingSchemaConversionError(path, displayTypeName(typeName));
|
|
183
183
|
}
|
|
184
184
|
function sanitizeJsonSchema(value) {
|
|
185
185
|
if (Array.isArray(value)) {
|
|
@@ -229,11 +229,11 @@ export function zodToJsonSchema(schema) {
|
|
|
229
229
|
validateSchema(schema, "$");
|
|
230
230
|
const jsonSchema = schema.toJSONSchema?.();
|
|
231
231
|
if (!jsonSchema) {
|
|
232
|
-
throw new
|
|
232
|
+
throw new BindingSchemaConversionError("$", displayTypeName(normalizeTypeName(schema)), "schema does not expose toJSONSchema()");
|
|
233
233
|
}
|
|
234
234
|
const unsupportedKeyword = findUnsupportedGeneratedKeyword(jsonSchema, "$");
|
|
235
235
|
if (unsupportedKeyword) {
|
|
236
|
-
throw new
|
|
236
|
+
throw new BindingSchemaConversionError("$", displayTypeName(normalizeTypeName(schema)), `${unsupportedKeyword.keyword} emitted at ${unsupportedKeyword.path} is not supported`);
|
|
237
237
|
}
|
|
238
238
|
const sanitized = sanitizeJsonSchema(jsonSchema);
|
|
239
239
|
const description = getDescription(schema);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
|
+
/** Maximum length for binding and bindings descriptions (characters). */
|
|
3
|
+
export declare const MAX_TOOL_DESCRIPTION_LENGTH = 200;
|
|
4
|
+
/**
|
|
5
|
+
* A single binding that executes on the host.
|
|
6
|
+
* Mirrors the shape of AI SDK's tool() but with host-execution semantics.
|
|
7
|
+
*/
|
|
8
|
+
export interface Binding<INPUT = any, OUTPUT = any> {
|
|
9
|
+
/** Description shown to the agent in --help and prompt docs. Max 200 characters. */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Zod schema for the input. Drives CLI flag generation and validation. */
|
|
12
|
+
inputSchema: ZodType<INPUT>;
|
|
13
|
+
/** Runs on the host when the agent invokes the binding. */
|
|
14
|
+
execute: (input: INPUT) => Promise<OUTPUT> | OUTPUT;
|
|
15
|
+
/** Examples included in auto-generated prompt docs. */
|
|
16
|
+
examples?: ToolExample<INPUT>[];
|
|
17
|
+
/** Timeout in ms. Default: 30000. */
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ToolExample<INPUT = any> {
|
|
21
|
+
/** Human description of what this example does. */
|
|
22
|
+
description: string;
|
|
23
|
+
/** The input args for the example. */
|
|
24
|
+
input: INPUT;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A named group of bindings. Becomes a CLI binary: agentos-{name}.
|
|
28
|
+
*/
|
|
29
|
+
export interface Bindings {
|
|
30
|
+
/** Bindings name. Must be lowercase alphanumeric + hyphens. Becomes the CLI suffix: agentos-{name}. */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Description shown in `agentos list-tools` and prompt docs. */
|
|
33
|
+
description: string;
|
|
34
|
+
/** The bindings in this group. Keys become subcommands. */
|
|
35
|
+
bindings: Record<string, Binding>;
|
|
36
|
+
}
|
|
37
|
+
/** Helper to create a Binding with type inference. */
|
|
38
|
+
export declare function binding<INPUT, OUTPUT>(def: Binding<INPUT, OUTPUT>): Binding<INPUT, OUTPUT>;
|
|
39
|
+
/** Helper to create a Bindings group. */
|
|
40
|
+
export declare function bindings(def: Bindings): Bindings;
|
|
41
|
+
/**
|
|
42
|
+
* Validate all description lengths in the given bindings groups.
|
|
43
|
+
* Throws if any group or binding description exceeds MAX_TOOL_DESCRIPTION_LENGTH.
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateBindings(bindingGroups: Bindings[]): void;
|
package/dist/bindings.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Maximum length for binding and bindings descriptions (characters). */
|
|
2
|
+
export const MAX_TOOL_DESCRIPTION_LENGTH = 200;
|
|
3
|
+
/** Helper to create a Binding with type inference. */
|
|
4
|
+
export function binding(def) {
|
|
5
|
+
return def;
|
|
6
|
+
}
|
|
7
|
+
/** Helper to create a Bindings group. */
|
|
8
|
+
export function bindings(def) {
|
|
9
|
+
return def;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validate all description lengths in the given bindings groups.
|
|
13
|
+
* Throws if any group or binding description exceeds MAX_TOOL_DESCRIPTION_LENGTH.
|
|
14
|
+
*/
|
|
15
|
+
export function validateBindings(bindingGroups) {
|
|
16
|
+
for (const tk of bindingGroups) {
|
|
17
|
+
if (tk.description.length > MAX_TOOL_DESCRIPTION_LENGTH) {
|
|
18
|
+
throw new Error(`Bindings "${tk.name}" description is ${tk.description.length} characters, max is ${MAX_TOOL_DESCRIPTION_LENGTH}`);
|
|
19
|
+
}
|
|
20
|
+
for (const [bindingName, binding] of Object.entries(tk.bindings)) {
|
|
21
|
+
if (binding.description.length > MAX_TOOL_DESCRIPTION_LENGTH) {
|
|
22
|
+
throw new Error(`Binding "${tk.name}/${bindingName}" description is ${binding.description.length} characters, max is ${MAX_TOOL_DESCRIPTION_LENGTH}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentOS } from "../agentos.js";
|
|
2
2
|
import type { ScheduleDriver } from "./schedule-driver.js";
|
|
3
3
|
import type { CronEventHandler, CronJob, CronJobInfo, CronJobOptions } from "./types.js";
|
|
4
4
|
/**
|
|
5
|
-
* Internal class that bridges ScheduleDriver and
|
|
5
|
+
* Internal class that bridges ScheduleDriver and AgentOS. Owns the job
|
|
6
6
|
* registry, executes actions, and emits lifecycle events.
|
|
7
7
|
*/
|
|
8
8
|
export declare class CronManager {
|
|
@@ -10,7 +10,7 @@ export declare class CronManager {
|
|
|
10
10
|
private driver;
|
|
11
11
|
private vm;
|
|
12
12
|
private listeners;
|
|
13
|
-
constructor(vm:
|
|
13
|
+
constructor(vm: AgentOS, driver: ScheduleDriver);
|
|
14
14
|
schedule(options: CronJobOptions): CronJob;
|
|
15
15
|
cancel(id: string): void;
|
|
16
16
|
list(): CronJobInfo[];
|
|
@@ -9,7 +9,7 @@ function computeNextTime(schedule) {
|
|
|
9
9
|
return resolveSchedule(schedule).nextRun;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Internal class that bridges ScheduleDriver and
|
|
12
|
+
* Internal class that bridges ScheduleDriver and AgentOS. Owns the job
|
|
13
13
|
* registry, executes actions, and emits lifecycle events.
|
|
14
14
|
*/
|
|
15
15
|
export class CronManager {
|
package/dist/cron/types.d.ts
CHANGED
package/dist/host-dir-mount.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface HostDirMountPluginConfig extends MountConfigJsonObject {
|
|
|
16
16
|
* mounts through the native `host_dir` plugin instead of a JS VFS backend.
|
|
17
17
|
*/
|
|
18
18
|
export declare function createHostDirBackend(options: HostDirBackendOptions): NativeMountPluginDescriptor<HostDirMountPluginConfig>;
|
|
19
|
-
/** A native `host_dir` mount, the serializable form `
|
|
19
|
+
/** A native `host_dir` mount, the serializable form `AgentOSOptions.mounts` accepts. */
|
|
20
20
|
export interface NodeModulesMountConfig {
|
|
21
21
|
path: string;
|
|
22
22
|
plugin: NativeMountPluginDescriptor<HostDirMountPluginConfig>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AgentOS, AgentOSSidecar } from "./agentos.js";
|
|
2
2
|
export { AGENT_CONFIGS } from "./agents.js";
|
|
3
3
|
export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriver, } from "./cron/index.js";
|
|
4
4
|
export { createHostDirBackend, nodeModulesMount } from "./host-dir-mount.js";
|
|
5
|
-
export {
|
|
5
|
+
export { binding, bindings, MAX_TOOL_DESCRIPTION_LENGTH, validateBindings, } from "./bindings.js";
|
|
6
6
|
export { createInMemoryLayerStore, createSnapshotExport, } from "./layers.js";
|
|
7
7
|
export { defineSoftware } from "./packages.js";
|
|
8
|
-
export { isAcpTimeoutErrorData
|
|
8
|
+
export { isAcpTimeoutErrorData } from "./json-rpc.js";
|
|
9
9
|
export { createInMemoryFileSystem, KernelError } from "./runtime-compat.js";
|
|
10
10
|
export type * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @rivet-dev/agentos
|
|
2
|
-
export {
|
|
2
|
+
export { AgentOS, AgentOSSidecar } from "./agentos.js";
|
|
3
3
|
export { AGENT_CONFIGS } from "./agents.js";
|
|
4
4
|
export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriver, } from "./cron/index.js";
|
|
5
5
|
export { createHostDirBackend, nodeModulesMount } from "./host-dir-mount.js";
|
|
6
|
-
export {
|
|
6
|
+
export { binding, bindings, MAX_TOOL_DESCRIPTION_LENGTH, validateBindings, } from "./bindings.js";
|
|
7
7
|
export { createInMemoryLayerStore, createSnapshotExport, } from "./layers.js";
|
|
8
8
|
export { defineSoftware } from "./packages.js";
|
|
9
|
-
export { isAcpTimeoutErrorData
|
|
9
|
+
export { isAcpTimeoutErrorData } from "./json-rpc.js";
|
|
10
10
|
export { createInMemoryFileSystem, KernelError } from "./runtime-compat.js";
|
package/dist/json-rpc.d.ts
CHANGED
|
@@ -8,22 +8,7 @@ export interface AcpTimeoutErrorData {
|
|
|
8
8
|
transportState?: string;
|
|
9
9
|
recentActivity: string[];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
* Structured error payload meaning "the session id is not known to the agent" —
|
|
13
|
-
* e.g. a `session/load` / `session/resume` against a session whose on-disk store did
|
|
14
|
-
* not survive a VM teardown. The sidecar normalizes the adapter's native error into
|
|
15
|
-
* this shape so the resume orchestration can distinguish "fall through to a fresh
|
|
16
|
-
* session" from a transport/timeout error (which must propagate). Mirrors the
|
|
17
|
-
* `acp_timeout` convention.
|
|
18
|
-
*/
|
|
19
|
-
export interface UnknownSessionErrorData {
|
|
20
|
-
kind: "unknown_session";
|
|
21
|
-
/** Optional metadata. The discriminator is `kind` alone — the sidecar's
|
|
22
|
-
* normalized error carries only `kind`, so this stays optional to keep the
|
|
23
|
-
* sidecar and client contracts aligned. */
|
|
24
|
-
sessionId?: string;
|
|
25
|
-
}
|
|
26
|
-
export type JsonRpcErrorData = AcpTimeoutErrorData | UnknownSessionErrorData | Record<string, unknown>;
|
|
11
|
+
export type JsonRpcErrorData = AcpTimeoutErrorData | Record<string, unknown>;
|
|
27
12
|
export interface JsonRpcRequest {
|
|
28
13
|
jsonrpc: "2.0";
|
|
29
14
|
id: number | string | null;
|
|
@@ -47,4 +32,3 @@ export interface JsonRpcNotification {
|
|
|
47
32
|
params?: unknown;
|
|
48
33
|
}
|
|
49
34
|
export declare function isAcpTimeoutErrorData(value: unknown): value is AcpTimeoutErrorData;
|
|
50
|
-
export declare function isUnknownSessionErrorData(value: unknown): value is UnknownSessionErrorData;
|
package/dist/json-rpc.js
CHANGED
|
@@ -12,11 +12,3 @@ export function isAcpTimeoutErrorData(value) {
|
|
|
12
12
|
Array.isArray(record.recentActivity) &&
|
|
13
13
|
record.recentActivity.every((entry) => typeof entry === "string"));
|
|
14
14
|
}
|
|
15
|
-
export function isUnknownSessionErrorData(value) {
|
|
16
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const record = value;
|
|
20
|
-
return (record.kind === "unknown_session" &&
|
|
21
|
-
(record.sessionId === undefined || typeof record.sessionId === "string"));
|
|
22
|
-
}
|
package/dist/packages.js
CHANGED
|
@@ -319,7 +319,7 @@ export function processSoftware(software) {
|
|
|
319
319
|
const vmDir = `/root/node_modules/${reqPkg}`;
|
|
320
320
|
pushPackageSoftwareRoot(softwareRoots, seenSoftwareVmPaths, hostDir, vmDir);
|
|
321
321
|
}
|
|
322
|
-
// Tool bin registration is handled by the caller (
|
|
322
|
+
// Tool bin registration is handled by the caller (AgentOS.create)
|
|
323
323
|
// since it requires kernel access.
|
|
324
324
|
break;
|
|
325
325
|
}
|
package/dist/runtime-compat.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export type NetworkPermissions = PermissionMode | RulePermissions<PatternPermiss
|
|
|
81
81
|
export type ChildProcessPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
82
82
|
export type ProcessPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
83
83
|
export type EnvPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
84
|
-
export type
|
|
84
|
+
export type BindingPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
85
85
|
export interface ProcessInfo {
|
|
86
86
|
pid: number;
|
|
87
87
|
ppid: number;
|
|
@@ -168,7 +168,7 @@ export interface Permissions {
|
|
|
168
168
|
childProcess?: ChildProcessPermissions;
|
|
169
169
|
process?: ProcessPermissions;
|
|
170
170
|
env?: EnvPermissions;
|
|
171
|
-
|
|
171
|
+
binding?: BindingPermissions;
|
|
172
172
|
}
|
|
173
173
|
export interface ResourceBudgets {
|
|
174
174
|
maxOutputBytes?: number;
|
package/dist/runtime-compat.js
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import { resolvePublishedSidecarBinary } from "./sidecar/binary.js";
|
|
8
8
|
import { findCargoBinary, resolveCargoBinary } from "./sidecar/cargo.js";
|
|
9
9
|
import { serializePermissionsForSidecar } from "./sidecar/permissions.js";
|
|
10
|
-
import { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarKernelProxy,
|
|
10
|
+
import { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarKernelProxy, NativeSidecarProcessClient, serializeMountConfigForSidecar, } from "./sidecar/rpc-client.js";
|
|
11
11
|
export const AF_INET = 2;
|
|
12
12
|
export const AF_UNIX = 1;
|
|
13
13
|
export const SOCK_STREAM = 1;
|
|
@@ -37,6 +37,7 @@ const KERNEL_POSIX_BOOTSTRAP_DIRS = [
|
|
|
37
37
|
"/media",
|
|
38
38
|
"/home",
|
|
39
39
|
"/home/user",
|
|
40
|
+
"/workspace",
|
|
40
41
|
"/usr",
|
|
41
42
|
"/usr/bin",
|
|
42
43
|
"/usr/games",
|
|
@@ -1632,7 +1633,7 @@ class NativeKernel {
|
|
|
1632
1633
|
constructor(options) {
|
|
1633
1634
|
this.options = options;
|
|
1634
1635
|
this.env = { ...(options.env ?? {}) };
|
|
1635
|
-
this.cwd = options.cwd ?? "/
|
|
1636
|
+
this.cwd = options.cwd ?? "/workspace";
|
|
1636
1637
|
this.socketTable = {
|
|
1637
1638
|
hasHostNetworkAdapter: () => Boolean(options.hostNetworkAdapter),
|
|
1638
1639
|
findListener: (request) => this.proxy?.findListener(request) ?? null,
|
|
@@ -1902,7 +1903,7 @@ class NativeKernel {
|
|
|
1902
1903
|
const requestedPermissions = this.options.permissions;
|
|
1903
1904
|
const bootstrapPermissions = requestedPermissions ? allowAll : undefined;
|
|
1904
1905
|
if (this.loopbackExemptPorts.length > 0) {
|
|
1905
|
-
createVmEnv.
|
|
1906
|
+
createVmEnv.AGENTOS_LOOPBACK_EXEMPT_PORTS = JSON.stringify(this.loopbackExemptPorts);
|
|
1906
1907
|
}
|
|
1907
1908
|
const rootPassthroughPlan = planNodeFilesystemPassthroughMounts(this.options.filesystem, this.pendingLocalMounts);
|
|
1908
1909
|
const snapshotEntries = await snapshotFilesystemEntries(this.options.filesystem, "/", [], {
|
|
@@ -1921,7 +1922,7 @@ class NativeKernel {
|
|
|
1921
1922
|
],
|
|
1922
1923
|
bootstrapEntries: [],
|
|
1923
1924
|
};
|
|
1924
|
-
const client =
|
|
1925
|
+
const client = NativeSidecarProcessClient.spawn({
|
|
1925
1926
|
cwd: REPO_ROOT,
|
|
1926
1927
|
command: ensureNativeSidecarBinary(),
|
|
1927
1928
|
args: [],
|
|
@@ -1987,7 +1988,7 @@ class NativeKernel {
|
|
|
1987
1988
|
vm,
|
|
1988
1989
|
env: this.env,
|
|
1989
1990
|
cwd: this.cwd,
|
|
1990
|
-
defaultExecCwd: this.options.cwd === undefined ? "/
|
|
1991
|
+
defaultExecCwd: this.options.cwd === undefined ? "/workspace" : this.cwd,
|
|
1991
1992
|
localMounts: this.pendingLocalMounts,
|
|
1992
1993
|
commandGuestPaths: new Map(),
|
|
1993
1994
|
onWasmCommandResolved: (command) => {
|
package/dist/runtime.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export type NetworkPermissions = PermissionMode | RulePermissions<PatternPermiss
|
|
|
76
76
|
export type ChildProcessPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
77
77
|
export type ProcessPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
78
78
|
export type EnvPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
79
|
-
export type
|
|
79
|
+
export type BindingPermissions = PermissionMode | RulePermissions<PatternPermissionRule>;
|
|
80
80
|
export interface ProcessInfo {
|
|
81
81
|
pid: number;
|
|
82
82
|
ppid: number;
|
|
@@ -163,7 +163,7 @@ export interface Permissions {
|
|
|
163
163
|
childProcess?: ChildProcessPermissions;
|
|
164
164
|
process?: ProcessPermissions;
|
|
165
165
|
env?: EnvPermissions;
|
|
166
|
-
|
|
166
|
+
binding?: BindingPermissions;
|
|
167
167
|
}
|
|
168
168
|
export interface ResourceBudgets {
|
|
169
169
|
maxOutputBytes?: number;
|
|
@@ -43,23 +43,6 @@ export type AcpCloseSessionRequest = {
|
|
|
43
43
|
};
|
|
44
44
|
export declare function readAcpCloseSessionRequest(bc: bare.ByteCursor): AcpCloseSessionRequest;
|
|
45
45
|
export declare function writeAcpCloseSessionRequest(bc: bare.ByteCursor, x: AcpCloseSessionRequest): void;
|
|
46
|
-
/**
|
|
47
|
-
* Resume a session that exists in durable storage but is not live in the current
|
|
48
|
-
* VM (e.g. after a Rivet actor slept and woke with a fresh VM). The sidecar runs
|
|
49
|
-
* the stateless resume state machine (native session/load when the agent supports
|
|
50
|
-
* it, else a fresh session/new + transcript continuation preamble). `cwd`/`env`
|
|
51
|
-
* describe the fresh adapter launch used by the fallback tier. `transcriptPath`,
|
|
52
|
-
* when present, is a guest-readable path the fallback preamble points the agent at.
|
|
53
|
-
*/
|
|
54
|
-
export type AcpResumeSessionRequest = {
|
|
55
|
-
readonly sessionId: string;
|
|
56
|
-
readonly agentType: string;
|
|
57
|
-
readonly transcriptPath: string | null;
|
|
58
|
-
readonly cwd: string;
|
|
59
|
-
readonly env: ReadonlyMap<string, string>;
|
|
60
|
-
};
|
|
61
|
-
export declare function readAcpResumeSessionRequest(bc: bare.ByteCursor): AcpResumeSessionRequest;
|
|
62
|
-
export declare function writeAcpResumeSessionRequest(bc: bare.ByteCursor, x: AcpResumeSessionRequest): void;
|
|
63
46
|
export type AcpRequest = {
|
|
64
47
|
readonly tag: "AcpCreateSessionRequest";
|
|
65
48
|
readonly val: AcpCreateSessionRequest;
|
|
@@ -72,9 +55,6 @@ export type AcpRequest = {
|
|
|
72
55
|
} | {
|
|
73
56
|
readonly tag: "AcpCloseSessionRequest";
|
|
74
57
|
readonly val: AcpCloseSessionRequest;
|
|
75
|
-
} | {
|
|
76
|
-
readonly tag: "AcpResumeSessionRequest";
|
|
77
|
-
readonly val: AcpResumeSessionRequest;
|
|
78
58
|
};
|
|
79
59
|
export declare function readAcpRequest(bc: bare.ByteCursor): AcpRequest;
|
|
80
60
|
export declare function writeAcpRequest(bc: bare.ByteCursor, x: AcpRequest): void;
|
|
@@ -115,19 +95,6 @@ export type AcpSessionClosedResponse = {
|
|
|
115
95
|
};
|
|
116
96
|
export declare function readAcpSessionClosedResponse(bc: bare.ByteCursor): AcpSessionClosedResponse;
|
|
117
97
|
export declare function writeAcpSessionClosedResponse(bc: bare.ByteCursor, x: AcpSessionClosedResponse): void;
|
|
118
|
-
/**
|
|
119
|
-
* Result of AcpResumeSessionRequest. `sessionId` is the live ACP session id after
|
|
120
|
-
* resume: equal to the requested id for native loads, or the freshly assigned id
|
|
121
|
-
* for the fallback tier (the caller remaps external -> live). `mode` is "native"
|
|
122
|
-
* (session/load|resume succeeded) or "fallback" (a new session was created and the
|
|
123
|
-
* transcript-continuation preamble was armed for the next prompt).
|
|
124
|
-
*/
|
|
125
|
-
export type AcpSessionResumedResponse = {
|
|
126
|
-
readonly sessionId: string;
|
|
127
|
-
readonly mode: string;
|
|
128
|
-
};
|
|
129
|
-
export declare function readAcpSessionResumedResponse(bc: bare.ByteCursor): AcpSessionResumedResponse;
|
|
130
|
-
export declare function writeAcpSessionResumedResponse(bc: bare.ByteCursor, x: AcpSessionResumedResponse): void;
|
|
131
98
|
export type AcpErrorResponse = {
|
|
132
99
|
readonly code: string;
|
|
133
100
|
readonly message: string;
|
|
@@ -146,9 +113,6 @@ export type AcpResponse = {
|
|
|
146
113
|
} | {
|
|
147
114
|
readonly tag: "AcpSessionClosedResponse";
|
|
148
115
|
readonly val: AcpSessionClosedResponse;
|
|
149
|
-
} | {
|
|
150
|
-
readonly tag: "AcpSessionResumedResponse";
|
|
151
|
-
readonly val: AcpSessionResumedResponse;
|
|
152
116
|
} | {
|
|
153
117
|
readonly tag: "AcpErrorResponse";
|
|
154
118
|
readonly val: AcpErrorResponse;
|
|
@@ -157,22 +157,6 @@ export function readAcpCloseSessionRequest(bc) {
|
|
|
157
157
|
export function writeAcpCloseSessionRequest(bc, x) {
|
|
158
158
|
bare.writeString(bc, x.sessionId);
|
|
159
159
|
}
|
|
160
|
-
export function readAcpResumeSessionRequest(bc) {
|
|
161
|
-
return {
|
|
162
|
-
sessionId: bare.readString(bc),
|
|
163
|
-
agentType: bare.readString(bc),
|
|
164
|
-
transcriptPath: read2(bc),
|
|
165
|
-
cwd: bare.readString(bc),
|
|
166
|
-
env: read1(bc),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
export function writeAcpResumeSessionRequest(bc, x) {
|
|
170
|
-
bare.writeString(bc, x.sessionId);
|
|
171
|
-
bare.writeString(bc, x.agentType);
|
|
172
|
-
write2(bc, x.transcriptPath);
|
|
173
|
-
bare.writeString(bc, x.cwd);
|
|
174
|
-
write1(bc, x.env);
|
|
175
|
-
}
|
|
176
160
|
export function readAcpRequest(bc) {
|
|
177
161
|
const offset = bc.offset;
|
|
178
162
|
const tag = bare.readU8(bc);
|
|
@@ -185,8 +169,6 @@ export function readAcpRequest(bc) {
|
|
|
185
169
|
return { tag: "AcpGetSessionStateRequest", val: readAcpGetSessionStateRequest(bc) };
|
|
186
170
|
case 3:
|
|
187
171
|
return { tag: "AcpCloseSessionRequest", val: readAcpCloseSessionRequest(bc) };
|
|
188
|
-
case 4:
|
|
189
|
-
return { tag: "AcpResumeSessionRequest", val: readAcpResumeSessionRequest(bc) };
|
|
190
172
|
default: {
|
|
191
173
|
bc.offset = offset;
|
|
192
174
|
throw new bare.BareError(offset, "invalid tag");
|
|
@@ -215,11 +197,6 @@ export function writeAcpRequest(bc, x) {
|
|
|
215
197
|
writeAcpCloseSessionRequest(bc, x.val);
|
|
216
198
|
break;
|
|
217
199
|
}
|
|
218
|
-
case "AcpResumeSessionRequest": {
|
|
219
|
-
bare.writeU8(bc, 4);
|
|
220
|
-
writeAcpResumeSessionRequest(bc, x.val);
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
200
|
}
|
|
224
201
|
}
|
|
225
202
|
export function encodeAcpRequest(x, config) {
|
|
@@ -333,16 +310,6 @@ export function readAcpSessionClosedResponse(bc) {
|
|
|
333
310
|
export function writeAcpSessionClosedResponse(bc, x) {
|
|
334
311
|
bare.writeString(bc, x.sessionId);
|
|
335
312
|
}
|
|
336
|
-
export function readAcpSessionResumedResponse(bc) {
|
|
337
|
-
return {
|
|
338
|
-
sessionId: bare.readString(bc),
|
|
339
|
-
mode: bare.readString(bc),
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
export function writeAcpSessionResumedResponse(bc, x) {
|
|
343
|
-
bare.writeString(bc, x.sessionId);
|
|
344
|
-
bare.writeString(bc, x.mode);
|
|
345
|
-
}
|
|
346
313
|
export function readAcpErrorResponse(bc) {
|
|
347
314
|
return {
|
|
348
315
|
code: bare.readString(bc),
|
|
@@ -366,8 +333,6 @@ export function readAcpResponse(bc) {
|
|
|
366
333
|
case 3:
|
|
367
334
|
return { tag: "AcpSessionClosedResponse", val: readAcpSessionClosedResponse(bc) };
|
|
368
335
|
case 4:
|
|
369
|
-
return { tag: "AcpSessionResumedResponse", val: readAcpSessionResumedResponse(bc) };
|
|
370
|
-
case 5:
|
|
371
336
|
return { tag: "AcpErrorResponse", val: readAcpErrorResponse(bc) };
|
|
372
337
|
default: {
|
|
373
338
|
bc.offset = offset;
|
|
@@ -397,13 +362,8 @@ export function writeAcpResponse(bc, x) {
|
|
|
397
362
|
writeAcpSessionClosedResponse(bc, x.val);
|
|
398
363
|
break;
|
|
399
364
|
}
|
|
400
|
-
case "AcpSessionResumedResponse": {
|
|
401
|
-
bare.writeU8(bc, 4);
|
|
402
|
-
writeAcpSessionResumedResponse(bc, x.val);
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
365
|
case "AcpErrorResponse": {
|
|
406
|
-
bare.writeU8(bc,
|
|
366
|
+
bare.writeU8(bc, 4);
|
|
407
367
|
writeAcpErrorResponse(bc, x.val);
|
|
408
368
|
break;
|
|
409
369
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import "@secure-exec/core/native-client";
|
|
2
|
+
export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarProcess as NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcessError, SidecarProcessExited, } from "@secure-exec/core/sidecar-client";
|
|
3
|
+
export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarEventSelector, SidecarFsPermissionRule, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarZombieTimerCount, } from "@secure-exec/core/sidecar-client";
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// Register the native sidecar spawn factory (side effect). After the
|
|
2
|
+
// @secure-exec/core SidecarProcess refactor, native spawn is provided by a
|
|
3
|
+
// separately-registered factory; importing native-client wires it up so
|
|
4
|
+
// SidecarProcess.spawn works in this native runtime.
|
|
5
|
+
import "@secure-exec/core/native-client";
|
|
6
|
+
export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarProcess as NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcessError, SidecarProcessExited, } from "@secure-exec/core/sidecar-client";
|
|
@@ -28,7 +28,7 @@ export function serializePermissionsForSidecar(permissions) {
|
|
|
28
28
|
childProcess: "deny",
|
|
29
29
|
process: "deny",
|
|
30
30
|
env: "deny",
|
|
31
|
-
|
|
31
|
+
binding: "deny",
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
@@ -47,8 +47,8 @@ export function serializePermissionsForSidecar(permissions) {
|
|
|
47
47
|
env: typeof permissions.env === "string" || !permissions.env
|
|
48
48
|
? permissions.env
|
|
49
49
|
: serializePatternScope(permissions.env),
|
|
50
|
-
|
|
51
|
-
? permissions.
|
|
52
|
-
: serializePatternScope(permissions.
|
|
50
|
+
binding: typeof permissions.binding === "string" || !permissions.binding
|
|
51
|
+
? permissions.binding
|
|
52
|
+
: serializePatternScope(permissions.binding),
|
|
53
53
|
};
|
|
54
54
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
3
|
-
client:
|
|
1
|
+
import { NativeSidecarProcessClient, type NativeSidecarSpawnOptions } from "./native-process-client.js";
|
|
2
|
+
export interface AgentOSSidecarProcessHandle {
|
|
3
|
+
client: NativeSidecarProcessClient;
|
|
4
4
|
dispose(): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function spawnAgentOSSidecar(options: NativeSidecarSpawnOptions): AgentOSSidecarProcessHandle;
|
package/dist/sidecar/process.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export function
|
|
3
|
-
const client =
|
|
1
|
+
import { NativeSidecarProcessClient, } from "./native-process-client.js";
|
|
2
|
+
export function spawnAgentOSSidecar(options) {
|
|
3
|
+
const client = NativeSidecarProcessClient.spawn(options);
|
|
4
4
|
return {
|
|
5
5
|
client,
|
|
6
6
|
dispose: () => client.dispose(),
|