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