1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//! Omegon Extension SDK
//!
//! This crate provides a safe, versioned interface for building extensions for Omegon.
//! Extension developers depend on this crate with a locked version matching their
//! target Omegon release. The version constraint ensures compatibility.
//!
//! # Getting Started
//!
//! The fastest path to a working extension:
//!
//! ```bash
//! omegon extension init my-extension
//! cd my-extension
//! cargo build --release
//! omegon extension install .
//! ```
//!
//! This scaffolds a v1 extension with one tool and a manifest. Start there,
//! then read on for the full SDK surface.
//!
//! # Which Protocol Version?
//!
//! - **v1** — start here. Your extension responds to requests from Omegon.
//! One trait, one `serve()` call. Covers tools, widgets, and resources.
//! - **v2** — use this when your extension needs to talk *back* to the host:
//! progress notifications, sampling requests, or reading host state.
//! Adds [`HostProxy`] and [`serve_v2()`].
//!
//! If you're unsure, use v1. You can migrate to v2 later by adding
//! `on_initialized()` and switching `serve()` to `serve_v2()`.
//!
//! # Safety Model
//!
//! Extensions run in isolated processes (either native binaries or OCI containers).
//! An extension crash does not crash Omegon. The extension protocol:
//!
//! 1. **Version checking** — omegon validates extension SDK version at install time
//! 2. **Manifest validation** — schema and capability checks before instantiation
//! 3. **RPC isolation** — all communication is via JSON-RPC over stdin/stdout
//! 4. **Timeout enforcement** — RPC calls have hard timeouts
//! 5. **Type safety** — Rust serde validation on every message
//!
//! # Building a v1 Extension
//!
//! ```ignore
//! use omegon_extension::{Extension, serve};
//!
//! #[derive(Default)]
//! struct MyExtension;
//!
//! #[async_trait::async_trait]
//! impl Extension for MyExtension {
//! fn name(&self) -> &str { "my-extension" }
//! fn version(&self) -> &str { env!("CARGO_PKG_VERSION") }
//!
//! async fn handle_rpc(&self, method: &str, params: serde_json::Value) -> omegon_extension::Result<serde_json::Value> {
//! match method {
//! "get_tools" => Ok(serde_json::json!([])),
//! _ => Err(omegon_extension::Error::method_not_found(method)),
//! }
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() {
//! serve(MyExtension::default()).await.expect("failed to serve");
//! }
//! ```
//!
//! # Building a v2 Extension (bidirectional)
//!
//! ```ignore
//! use omegon_extension::{Extension, HostProxy, serve_v2};
//!
//! #[derive(Default)]
//! struct MyExtension {
//! host: std::sync::OnceLock<HostProxy>,
//! }
//!
//! #[async_trait::async_trait]
//! impl Extension for MyExtension {
//! fn name(&self) -> &str { "my-extension" }
//! fn version(&self) -> &str { env!("CARGO_PKG_VERSION") }
//!
//! async fn handle_rpc(&self, method: &str, params: serde_json::Value) -> omegon_extension::Result<serde_json::Value> {
//! match method {
//! "get_tools" => Ok(serde_json::json!([])),
//! _ => Err(omegon_extension::Error::method_not_found(method)),
//! }
//! }
//!
//! async fn on_initialized(&self, host: HostProxy) {
//! let _ = self.host.set(host);
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() {
//! serve_v2(MyExtension::default()).await.expect("failed to serve");
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Convenience type for RPC method results.
pub type RpcResult = ;
/// Serve an extension instance over RPC (stdin/stdout) — v1 protocol.
///
/// Simple request/response loop. Extension cannot send notifications or
/// requests back to the host. Blocks until the extension shuts down.
pub async
/// Serve an extension instance over RPC (stdin/stdout) — v2 protocol.
///
/// Bidirectional message router. Extension receives a [`HostProxy`] via
/// [`Extension::on_initialized()`] and can use it to send notifications
/// and requests back to the host. Blocks until the extension shuts down.
pub async