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//! `agentos_sidecar_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 net;
25pub mod process;
26pub mod session;
27pub mod sidecar;
28pub mod stream;
29pub mod transport;
30
31// ---------------------------------------------------------------------------
32// Centralized constants (ADR-001 §6 / spec.md §7)
33// ---------------------------------------------------------------------------
34
35/// ACP protocol version negotiated on session creation.
36pub const ACP_PROTOCOL_VERSION: u64 = 1;
37
38/// Bounded exited-shell exit-code retention (for `wait_shell` after exit).
39pub const CLOSED_SHELL_EXIT_CODE_RETENTION_LIMIT: usize = 2048;
40
41/// Two-phase shell-drain timeout during dispose (milliseconds).
42pub const SHELL_DISPOSE_TIMEOUT_MS: u64 = 5_000;
43
44/// VM lifecycle ready timeout during `create` (milliseconds).
45pub const VM_READY_TIMEOUT_MS: u64 = 10_000;
46
47/// Maximum scheduled cron jobs per VM.
48pub const CRON_JOB_LIMIT: usize = 1024;
49
50// ---------------------------------------------------------------------------
51// Public re-exports
52// ---------------------------------------------------------------------------
53
54pub use agent_os::{AgentOs, PackageDescriptor, ProjectedAgent, SoftwareInfo};
55pub use error::{ClientError, ClientResult, ResourceLimitDetails};
56pub use sidecar::{
57    AgentOsSidecar, AgentOsSidecarDescription, AgentOsSidecarPlacement, SidecarState,
58};
59pub use stream::{ByteStream, Subscription};
60
61pub use config::{
62    node_modules_mount, AcpLimits, AgentOsConfig, AgentOsConfigBuilder, AgentOsLimits,
63    AgentOsSidecarConfig, Binding, BindingCallback, BindingLimits, Bindings, FsPermissionRule,
64    FsPermissions, HttpLimits, JsRuntimeLimits, MountConfig, MountPlugin, OverlayMountConfig,
65    PackageRef, PatternPermissionRule, PatternPermissions, PermissionMode, Permissions,
66    PluginLimits, PythonLimits, ResourceLimits, RootFilesystemConfig, RootFilesystemKind,
67    RootFilesystemMode, RootLowerInput, RulePermissions, ScheduleCallback, ScheduleDriver,
68    ScheduleEntry, ScheduleHandle, SidecarJsBridgeCall, SidecarJsBridgeCallback, SoftwareInput,
69    SoftwareKind, TimerScheduleDriver, VmGroupConfig, VmUserAccountConfig, VmUserConfig,
70    WasmLimits,
71};
72
73pub use process::{
74    ExecOptions, ExecResult, ProcessExit, ProcessInfo, ProcessOutput, ProcessStatus, ProcessStream,
75    ProcessTreeNode, SpawnHandle, SpawnOptions, SpawnStdio, SpawnedProcessInfo, StdinInput,
76    TimingMitigation,
77};
78
79pub use net::{HttpRequest, HttpResponse};
80
81pub use fs::{
82    BatchReadResult, BatchWriteEntry, BatchWriteResult, DirEntry, DirEntryType,
83    DynamicMountDescriptor, FileContent, FilesystemEntry, FilesystemEntryEncoding,
84    FilesystemSnapshotEntries, FilesystemSnapshotExport, MkdirOptions, MountInfo,
85    ReaddirRecursiveOptions, RemoveOptions, RootSnapshotExport, SnapshotExportKind,
86    VirtualDirEntry, VirtualFileSystem, VirtualStat,
87};
88
89pub use shell::{ConnectTerminalOptions, OpenShellOptions, ShellData, ShellExit, ShellHandle};
90
91pub use session::{
92    AgentExitEvent, AgentExitStream, AgentExitSubscription, AgentMessage, AgentRegistryEntry,
93    AgentRestartOutcome, CancelPromptStatus, ContentBlock, DurableEventKind, DurableSessionEvent,
94    DurableSessionEventEntry, DurableSessionEventStream, DurableSessionEventSubscription,
95    EphemeralEventKind, EphemeralSessionEvent, EphemeralSessionEventEntry, HistoryPage,
96    ListSessionsInput, McpServerConfig, OpenSessionInput, PendingPermissionRequest,
97    PermissionEventStatus, PermissionPolicy, PermissionResponseStatus, PermissionTerminalReason,
98    PromptInput, PromptResult, ReadHistoryInput, SessionCapabilities, SessionConfig,
99    SessionConfigOption, SessionConfigValue, SessionInfo, SessionPage, SessionState,
100    SessionStreamEntry, SessionSubscriptionError, SessionUpdate, StopReason,
101};
102
103pub use cron::{
104    CronAction, CronActionInfo, CronEvent, CronJobHandle, CronJobInfo, CronJobOptions, CronManager,
105    CronOverlap, CronSessionOptions,
106};
107
108// `shell` is declared here because its methods live in a sibling module to keep `lib.rs` re-exports
109// flat; the module file itself is `shell.rs`.
110pub mod shell;