Skip to main content

agentos_client/
lib.rs

1#![forbid(unsafe_code)]
2
3//! # agentos-client
4//!
5//! High-level Rust client SDK for the Agent OS native sidecar. This is a 1:1 port of the TypeScript
6//! `AgentOs` client (`packages/core/src/agent-os.ts`): every public method, option type, return
7//! type, event, and error maps across with identical semantics.
8//!
9//! The client spawns the native `agentos-sidecar` binary and speaks the existing framed BARE
10//! protocol over its stdio (see [`transport`]). It does NOT embed the kernel in-process and does NOT
11//! define a new sidecar wire protocol. The generated Secure Exec schema surface comes from
12//! `secure_exec_client::wire`; Agent OS layers ACP/session semantics on top of those generated wire
13//! frames through the wrapper client.
14//!
15//! See the companion design docs in `~/.agents/specs/rust-client-sdk/` (ADR-001, spec, reference,
16//! checklist) for the architecture, type-mapping, error taxonomy, and streaming model.
17
18pub mod agent_os;
19pub(crate) mod command_line;
20pub mod config;
21pub mod cron;
22pub mod error;
23pub mod fs;
24pub mod json_rpc;
25pub mod net;
26pub mod process;
27pub mod session;
28pub mod sidecar;
29pub mod stream;
30pub mod transport;
31
32// ---------------------------------------------------------------------------
33// Centralized constants (ADR-001 §6 / spec.md §7)
34// ---------------------------------------------------------------------------
35
36/// ACP protocol version negotiated on session creation.
37pub const ACP_PROTOCOL_VERSION: u64 = 1;
38
39/// Per-request permission timeout (milliseconds).
40pub const PERMISSION_TIMEOUT_MS: u64 = 120_000;
41
42/// Bounded closed-session-id set capacity (for `close_session` idempotence).
43pub const CLOSED_SESSION_ID_RETENTION_LIMIT: usize = 2048;
44
45/// Two-phase shell-drain timeout during dispose (milliseconds).
46pub const SHELL_DISPOSE_TIMEOUT_MS: u64 = 5_000;
47
48/// VM lifecycle ready timeout during `create` (milliseconds).
49pub const VM_READY_TIMEOUT_MS: u64 = 10_000;
50
51/// Maximum scheduled cron jobs per VM.
52pub const CRON_JOB_LIMIT: usize = 1024;
53
54// ---------------------------------------------------------------------------
55// Public re-exports
56// ---------------------------------------------------------------------------
57
58pub use agent_os::AgentOs;
59pub use error::{ClientError, ClientResult};
60pub use sidecar::{
61    AgentOsSidecar, AgentOsSidecarDescription, AgentOsSidecarPlacement, SidecarState,
62};
63pub use stream::{ByteStream, Subscription};
64
65pub use config::{
66    AcpLimits, AgentOsConfig, AgentOsConfigBuilder, AgentOsLimits, AgentOsSidecarConfig,
67    FsPermissionRule, FsPermissions, HostTool, HttpLimits, JsRuntimeLimits, MountConfig,
68    MountPlugin, OverlayMountConfig, PatternPermissionRule, PatternPermissions, PermissionMode,
69    Permissions, PluginLimits, PythonLimits, ResourceLimits, RootFilesystemConfig,
70    RootFilesystemKind, RootFilesystemMode, RootLowerInput, RulePermissions, ScheduleCallback,
71    ScheduleDriver, ScheduleEntry, ScheduleHandle, SidecarJsBridgeCall, SidecarJsBridgeCallback,
72    SoftwareInput, SoftwareKind, TimerScheduleDriver, ToolCallback, ToolKit, ToolLimits,
73    WasmLimits,
74};
75
76pub use process::{
77    ExecOptions, ExecResult, ProcessInfo, ProcessStatus, ProcessTreeNode, SpawnHandle,
78    SpawnOptions, SpawnStdio, SpawnedProcessInfo, StdinInput, TimingMitigation,
79};
80
81pub use fs::{
82    BatchReadResult, BatchWriteEntry, BatchWriteResult, DeleteOptions, DirEntry, DirEntryType,
83    FileContent, FilesystemEntry, FilesystemEntryEncoding, FilesystemSnapshotEntries,
84    FilesystemSnapshotExport, MkdirOptions, MountFsOptions, ReaddirRecursiveOptions,
85    RootSnapshotExport, SnapshotExportKind, VirtualDirEntry, VirtualFileSystem, VirtualStat,
86};
87
88pub use shell::{ConnectTerminalOptions, OpenShellOptions, ShellHandle};
89
90pub use session::{
91    AgentCapabilities, AgentInfo, AgentRegistryEntry, ConfigAllowedValue, CreateSessionOptions,
92    McpServerConfig, PermissionReply, PermissionRequest, PromptCapabilities, PromptResult,
93    ResumeSessionOptions, ResumeSessionResult, SessionConfigOption, SessionId, SessionInfo,
94    SessionInitData, SessionMode, SessionModeState,
95};
96
97pub use json_rpc::{
98    is_unknown_session, AcpTimeoutErrorData, JsonRpcError, JsonRpcId, JsonRpcNotification,
99    JsonRpcResponse, UnknownSessionErrorData,
100};
101
102pub use cron::{
103    CronAction, CronEvent, CronJobHandle, CronJobInfo, CronJobOptions, CronManager, CronOverlap,
104};
105
106// `shell` is declared here because its methods live in a sibling module to keep `lib.rs` re-exports
107// flat; the module file itself is `shell.rs`.
108pub mod shell;