Skip to main content

codex_runtime/runtime/
mod.rs

1pub mod api;
2pub mod approvals;
3pub mod client;
4pub mod core;
5pub mod errors;
6pub mod events;
7pub mod hooks;
8pub(crate) mod id;
9pub mod metrics;
10pub mod rpc;
11pub mod rpc_contract;
12pub(crate) mod runtime_validation;
13pub mod shell_hook;
14pub mod sink;
15pub mod state;
16pub mod transport;
17pub(crate) mod turn_lifecycle;
18pub mod turn_output;
19
20pub use api::{
21    ApprovalPolicy, CommandExecOutputDeltaNotification, CommandExecOutputStream, CommandExecParams,
22    CommandExecResizeParams, CommandExecResizeResponse, CommandExecResponse,
23    CommandExecTerminalSize, CommandExecTerminateParams, CommandExecTerminateResponse,
24    CommandExecWriteParams, CommandExecWriteResponse, Personality, PromptAttachment,
25    PromptRunError, PromptRunParams, PromptRunResult, ReasoningEffort, SandboxPolicy,
26    SandboxPreset, ServiceTier, SkillDependencies, SkillErrorInfo, SkillInterface, SkillMetadata,
27    SkillScope, SkillToolDependency, SkillsListEntry, SkillsListExtraRootsForCwd, SkillsListParams,
28    SkillsListResponse, ThreadAgentMessageItemView, ThreadCommandExecutionItemView,
29    ThreadItemPayloadView, ThreadItemType, ThreadItemView, ThreadListParams, ThreadListResponse,
30    ThreadListSortKey, ThreadLoadedListParams, ThreadLoadedListResponse, ThreadReadParams,
31    ThreadReadResponse, ThreadRollbackParams, ThreadRollbackResponse, ThreadTurnErrorView,
32    ThreadTurnStatus, ThreadTurnView, ThreadView, DEFAULT_REASONING_EFFORT,
33};
34pub use approvals::{ServerRequest, ServerRequestConfig, TimeoutAction};
35pub use client::{
36    Client, ClientConfig, ClientError, CompatibilityGuard, RunProfile, SemVerTriplet, Session,
37    SessionConfig,
38};
39pub use core::{InitializeCapabilities, RestartPolicy, Runtime, RuntimeConfig, SupervisorConfig};
40pub use errors::{RpcError, RpcErrorObject, RuntimeError, SinkError};
41pub use hooks::RuntimeHookConfig;
42pub use metrics::RuntimeMetricsSnapshot;
43pub use rpc_contract::RpcValidationMode;
44pub use shell_hook::ShellCommandHook;
45pub use transport::{StdioProcessSpec, StdioTransportConfig};
46
47pub type ServerRequestRx = tokio::sync::mpsc::Receiver<ServerRequest>;
48
49/// Current time as Unix milliseconds.
50/// Allocation: none. Complexity: O(1).
51pub(crate) fn now_millis() -> i64 {
52    use std::time::{SystemTime, UNIX_EPOCH};
53    match SystemTime::now().duration_since(UNIX_EPOCH) {
54        Ok(d) => d.as_millis() as i64,
55        Err(_) => 0,
56    }
57}