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
162
163
164
165
166
167
168
169
170
171
172
173
174
//! Platform abstraction layer for clawft.
//!
//! Provides traits for all platform-dependent operations (HTTP, filesystem,
//! environment, process spawning) so the core engine can be platform-agnostic
//! and WASM-compatible.
//!
//! # Architecture
//!
//! The [`Platform`] trait bundles all platform capabilities via accessor methods.
//! Each sub-capability has its own trait ([`http::HttpClient`], [`fs::FileSystem`],
//! [`env::Environment`], [`process::ProcessSpawner`]) with a corresponding native
//! implementation.
//!
//! [`ProcessSpawner`](process::ProcessSpawner) is intentionally excluded from the
//! [`Platform`] bundle because it is unavailable in WASM environments. It is
//! accessible via [`Platform::process`] which returns `Option`.
//!
//! # Example
//!
//! ```rust,no_run
//! use clawft_platform::{Platform, NativePlatform};
//! use clawft_platform::http::HttpClient;
//! use std::collections::HashMap;
//!
//! # async fn example() {
//! let platform = NativePlatform::new();
//! let response = platform.http()
//! .get("https://example.com", &HashMap::new())
//! .await
//! .unwrap();
//! assert!(response.is_success());
//! # }
//! ```
//!
//! ## Crate Ecosystem
//!
//! WeftOS is built from these crates:
//!
//! | Crate | Role |
//! |-------|------|
//! | [`weftos`](https://crates.io/crates/weftos) | Product facade -- re-exports kernel, core, types |
//! | [`clawft-kernel`](https://crates.io/crates/clawft-kernel) | Kernel: processes, services, governance, mesh, ExoChain |
//! | [`clawft-core`](https://crates.io/crates/clawft-core) | Agent framework: pipeline, context, tools, skills |
//! | [`clawft-types`](https://crates.io/crates/clawft-types) | Shared type definitions |
//! | [`clawft-platform`](https://crates.io/crates/clawft-platform) | Platform abstraction (native/WASM/browser) |
//! | [`clawft-plugin`](https://crates.io/crates/clawft-plugin) | Plugin SDK for tools, channels, and extensions |
//! | [`clawft-llm`](https://crates.io/crates/clawft-llm) | LLM provider abstraction (11 providers + local) |
//! | [`exo-resource-tree`](https://crates.io/crates/exo-resource-tree) | Hierarchical resource namespace with Merkle integrity |
//!
//! Source: <https://github.com/weave-logic-ai/weftos>
pub use BrowserPlatform;
use async_trait;
/// Bundle of all platform capabilities.
///
/// Implementors provide concrete implementations of all platform traits.
/// The native implementation ([`NativePlatform`]) uses reqwest, tokio::fs,
/// std::env, and tokio::process. A WASM implementation would use the fetch
/// API, WASI filesystem, and an in-memory environment.
///
/// The `async_trait` bound differs based on target:
/// - Native: `Send + Sync` required (multi-threaded tokio runtime).
/// - Browser: `?Send` (single-threaded WASM runtime).
/// Native platform implementation using std, tokio, and reqwest.
///
/// This is the standard platform for server-side and CLI usage. It provides:
/// - HTTP via [`reqwest`] with connection pooling and TLS.
/// - Filesystem via [`tokio::fs`].
/// - Environment via [`std::env`].
/// - Process spawning via [`tokio::process`].