Skip to main content

forge_primitives/
lib.rs

1//! `forge-primitives` - types-only crate shared across forge crates.
2//!
3//! The workspace base crate. Holds every wire-shape type that
4//! crosses any forge-* crate boundary, with **no** logic, I/O, or
5//! async. Other crates depend on this; this depends on nothing
6//! forge-shaped.
7//!
8//! Module map:
9//!
10//! - [`command`] - `Command` enum (UI → agent channel envelope) + IDs.
11//! - [`ids`] - `SessionId`, `ToolUseId`.
12//! - [`image`] - `ImageAttachment` + clipboard validation helpers.
13//! - [`messages`] - top-level stream-json shapes (`Message`,
14//!   `AssistantEnvelope`, `Usage`, `RateLimit*`, `StopReason`,
15//!   task-lifecycle variants).
16//! - [`content`] - wire-side `ContentBlock` (Text, Thinking, ToolUse,
17//!   ToolResult, server-tool, Image).
18//! - [`public_types`] - public wire types: `AccountInfo`,
19//!   `McpServer*`, `McpStatusResponse`, `ContextUsage*`,
20//!   `SDKSessionInfo`, `SessionMessage*`, `Sandbox*`,
21//!   `StreamEvent`.
22//! - [`hooks`] - hook event data (`HookKind`, `HookContext`, all 12
23//!   `*Input` structs, the two `*HookSpecificOutput` wrappers).
24//! - [`permissions`] - permission decision data (`PermissionDecision`,
25//!   `ToolPermissionContext`, `PermissionUpdate*`, `Permission*`).
26//! - [`options`] - option-config enums shared between the SDK's
27//!   `Options` builder and consumers (`PermissionMode`,
28//!   `SystemPromptKind`, `SdkPluginConfig`).
29//! - [`subagents`] - `SubagentDefinition` + nested types.
30//! - [`runtime`] - live runtime state: mode/model state, available
31//!   commands/agents/models, rate-limit views, retry classification,
32//!   terminal reasons.
33//! - [`session_update`] - wire-side support types for streaming session events
34//!   (chunks, tool calls, tool-call updates, plan entries, output
35//!   metadata).
36//! - [`permission_interaction`] - the shapes one permission interaction
37//!   is made of: the request the CLI raises, the options it offers, and
38//!   the answer a person gives (distinct from the wire-side decisions in
39//!   [`permissions`]).
40//! - [`question`] - `AskUserQuestion` request/response shapes.
41//! - [`mcp_ui_sync`] - MCP UI events (`McpOperationError`).
42//! - [`session_meta`] - `PromptChunk`.
43//! - [`project_key`] - `ProjectKey`, the canonical on-disk project
44//!   identity.
45//! - [`handoff`] - one session swap: the record the swap signal carries, the
46//!   brief a successor is given, and the numbers kept for tuning the trigger.
47//! - [`settings`] - the effective-config document a server pushes: the
48//!   areas, every key's value, and when an edit to it takes effect.
49//! - [`wire`] - the socket's binary frame tags shared by the server and the
50//!   shell.
51//! - [`biometric`] - one device's enrolment as a view draws it, its purposes,
52//!   and the opaque blob a release hands back.
53//!
54//! Add a type here when 2+ forge crates need it. Never reach for
55//! cross-crate `pub use` chains as a substitute.
56
57pub mod account;
58pub mod background;
59pub mod biometric;
60pub mod browser;
61pub mod call_output;
62pub mod client;
63pub mod cloud;
64pub mod command;
65pub mod content;
66pub mod cron;
67pub mod document;
68pub mod error;
69pub mod git;
70pub mod git_diff;
71pub mod gotify;
72pub mod handoff;
73pub mod hooks;
74pub mod ids;
75pub mod image;
76pub mod mcp_ui_sync;
77pub mod messages;
78pub mod options;
79pub mod permission;
80pub mod permission_interaction;
81pub mod permissions;
82pub mod plugins;
83pub mod project_key;
84pub mod public_types;
85pub mod question;
86pub mod review;
87pub mod runtime;
88pub mod server;
89pub mod session_meta;
90pub mod session_slot;
91pub mod session_update;
92pub mod settings;
93pub mod slack;
94pub mod subagents;
95pub mod tasks;
96pub mod terminal;
97pub mod token_usage;
98pub mod turn_error;
99pub mod usage;
100pub mod vault;
101pub mod wire;
102pub mod workers;
103
104pub use call_output::CallOutput;
105pub use client::ClientConfig;
106pub use command::AgentCommand;
107pub use content::ContentBlock;
108pub use cron::{CronEntry, CronId, CronKind};
109pub use error::AppError;
110pub use gotify::{GotifyConfig, GotifyMessage, GotifySubscription};
111pub use handoff::{
112    HandoffBrief, HandoffCycle, HandoffGitState, HandoffReason, HandoffRecord, HandoffSection,
113    HandoffSuccessor,
114};
115pub use hooks::{
116    BaseHookInput, HookContext, HookKind, NotificationInput, PermissionRequestInput,
117    PostToolUseFailureInput, PostToolUseInput, PreCompactInput, PreToolUseHookSpecificOutput,
118    PreToolUseInput, StopInput, SubagentContext, SubagentStartInput, SubagentStopInput,
119    UserPromptSubmitHookSpecificOutput, UserPromptSubmitInput,
120};
121pub use ids::{SessionId, ToolUseId};
122pub use image::{
123    ImageAttachment, SUPPORTED_IMAGE_MIME_TYPES, display_blocks, is_supported_image_type,
124    is_valid_base64, payload_bytes, validate_image,
125};
126pub use mcp_ui_sync::McpOperationError;
127pub use messages::StopHookInfo;
128pub use messages::WorkflowProgressEvent;
129pub use messages::{
130    AssistantEnvelope, AssistantMessageError, Message, RateLimitInfo, RateLimitStatus,
131    RateLimitType, StopReason, TaskNotificationStatus, TaskUsage, Usage, UserEnvelope,
132    names_a_dispatch,
133};
134pub use options::{SdkPluginConfig, SystemPromptKind};
135pub use permission::PermissionMode;
136pub use permission_interaction::{
137    PermissionDisplay, PermissionOption, PermissionOutcome, PermissionRequest,
138};
139pub use permissions::{
140    PermissionBehavior, PermissionDecision, PermissionRuleValue, PermissionUpdate,
141    PermissionUpdateDestination, ToolPermissionContext,
142};
143pub use project_key::ProjectKey;
144pub use public_types::{
145    AccountInfo, ContextUsageResponse, ConversationHistory, ForgeAccountIdentity, McpServerConfig,
146    McpServerConnectionStatus, McpServerInfo, McpServerStatus, McpSetServersResponse,
147    McpStatusResponse, McpToolAnnotations, McpToolInfo, SDKSessionInfo, SessionHistory,
148    SessionMessage, SessionMessageKind, StreamEvent, TranscriptAnchor, TranscriptSpan,
149};
150pub use question::{
151    QuestionAnnotation, QuestionOption, QuestionOutcome, QuestionPrompt, QuestionRequest,
152};
153pub use review::{
154    ReviewAnchor, ReviewAuthor, ReviewComment, ReviewSet, ReviewSide, ReviewStatus, ReviewThread,
155};
156pub use runtime::{
157    ApiRetryError, ApiRetryUpdate, AvailableAgent, AvailableCommand, AvailableModel, CurrentModel,
158    EffortLevel, ModeInfo, ModeState, MonitorRecord, MonitorStatus, RateLimitUpdate,
159    RuntimeSessionState, SessionLifecycleState, SessionTurnState, SettingsParseErrorUpdate,
160    TerminalReason,
161};
162pub use server::{DEFAULT_SERVER_PORT, ServerConfig};
163pub use session_meta::PromptChunk;
164pub use session_slot::SessionSlot;
165pub use session_update::{
166    BashOutputMetadata, ChunkContent, TaskMetadata, ToolCall, ToolCallContent, ToolCallLocation,
167    ToolCallStatus, ToolCallUpdate, ToolCallUpdateFields, ToolKind, ToolOutputMetadata,
168};
169pub use settings::{
170    EditKind, EffectClass, SettingKind, SettingsArea, SettingsDocument, SettingsEdit,
171    SettingsEditOp, SettingsEditRequest, SettingsKey, SettingsTotals,
172};
173pub use subagents::{EffortPreset, SubagentDefinition, SubagentMcpServerRef, SubagentMemory};
174pub use tasks::{Task, TaskId, TaskStatus};
175pub use turn_error::TurnErrorClass;
176pub use workers::{FORGE_WORKER_TAG_PREFIX, LEAD_LABEL, WorkerLiveness, WorkerStatus, worker_tag};