@celestia-island/plana-types 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +38 -0
- package/bindings/FileAnchor.ts +3 -0
- package/bindings/engine.ts +277 -0
- package/bindings/enums.ts +31 -0
- package/bindings/httpTypes.ts +197 -0
- package/bindings/index.ts +47 -0
- package/bindings/mcp/aporia.ts +61 -0
- package/bindings/mcp/eleos.ts +18 -0
- package/bindings/mcp/epieikeia.ts +48 -0
- package/bindings/mcp/haplotes.ts +47 -0
- package/bindings/mcp/hubris.ts +41 -0
- package/bindings/mcp/index.ts +13 -0
- package/bindings/mcp/kalos.ts +47 -0
- package/bindings/mcp/neikos.ts +76 -0
- package/bindings/mcp/orexis.ts +64 -0
- package/bindings/mcp/philia.ts +57 -0
- package/bindings/mcp/polemos.ts +55 -0
- package/bindings/mcp/skemma.ts +58 -0
- package/bindings/mcp/skopeo.ts +56 -0
- package/bindings/mcp/webAutomation.ts +31 -0
- package/bindings/model.ts +240 -0
- package/bindings/package.json +16 -0
- package/bindings/region.ts +3 -0
- package/bindings/serde_json/JsonValue.ts +3 -0
- package/bindings/ws/agentLifecycle.ts +41 -0
- package/bindings/ws/auth.ts +15 -0
- package/bindings/ws/baseMessages.ts +7 -0
- package/bindings/ws/bridgeNetwork.ts +71 -0
- package/bindings/ws/core.ts +51 -0
- package/bindings/ws/fileBrowsing.ts +57 -0
- package/bindings/ws/handshake.ts +23 -0
- package/bindings/ws/industrial.ts +72 -0
- package/bindings/ws/knowledgeBase.ts +10 -0
- package/bindings/ws/layer2.ts +25 -0
- package/bindings/ws/llmProvider.ts +74 -0
- package/bindings/ws/logs.ts +11 -0
- package/bindings/ws/malkuth.ts +62 -0
- package/bindings/ws/noa.ts +17 -0
- package/bindings/ws/stateSync.ts +19 -0
- package/bindings/ws/systemUi.ts +5 -0
- package/bindings/ws/tasks.ts +6 -0
- package/bindings/ws/views.ts +163 -0
- package/bindings/ws/workspace.ts +11 -0
- package/bindings/ws/yolo.ts +32 -0
- package/examples/schema_dump.rs +51 -0
- package/package.json +6 -0
- package/pnpm-workspace.yaml +2 -0
- package/src/engine.rs +602 -0
- package/src/enums.rs +334 -0
- package/src/external_mcp.rs +132 -0
- package/src/http.rs +1077 -0
- package/src/identity.rs +160 -0
- package/src/lib.rs +1215 -0
- package/src/malkuth.rs +145 -0
- package/src/mcp/aporia.rs +272 -0
- package/src/mcp/eleos.rs +210 -0
- package/src/mcp/epieikeia.rs +194 -0
- package/src/mcp/haplotes.rs +310 -0
- package/src/mcp/hubris.rs +377 -0
- package/src/mcp/kalos.rs +251 -0
- package/src/mcp/mod.rs +23 -0
- package/src/mcp/neikos.rs +533 -0
- package/src/mcp/orexis.rs +493 -0
- package/src/mcp/philia.rs +267 -0
- package/src/mcp/polemos.rs +241 -0
- package/src/mcp/skemma.rs +442 -0
- package/src/mcp/skopeo.rs +282 -0
- package/src/mcp/web_automation.rs +122 -0
- package/src/model.rs +421 -0
- package/src/protocol/base_messages.rs +125 -0
- package/src/protocol/handshake.rs +364 -0
- package/src/protocol/jsonrpc.rs +888 -0
- package/src/protocol/mod.rs +10 -0
- package/src/rbac.rs +786 -0
- package/src/region.rs +362 -0
- package/src/tracing_helpers.rs +9 -0
- package/src/ws/agent/agent_lifecycle.rs +221 -0
- package/src/ws/agent/layer2.rs +126 -0
- package/src/ws/agent/mod.rs +9 -0
- package/src/ws/agent/state_sync.rs +111 -0
- package/src/ws/agent/tasks.rs +43 -0
- package/src/ws/agent/yolo.rs +161 -0
- package/src/ws/mod.rs +10 -0
- package/src/ws/services/auth.rs +99 -0
- package/src/ws/services/industrial.rs +647 -0
- package/src/ws/services/knowledge_base.rs +59 -0
- package/src/ws/services/llm_provider.rs +371 -0
- package/src/ws/services/mod.rs +7 -0
- package/src/ws/ui/bridge_network.rs +96 -0
- package/src/ws/ui/file_browsing.rs +88 -0
- package/src/ws/ui/logs.rs +55 -0
- package/src/ws/ui/mod.rs +11 -0
- package/src/ws/ui/noa.rs +105 -0
- package/src/ws/ui/system_ui.rs +27 -0
- package/src/ws/ui/views.rs +159 -0
- package/src/ws/ui/workspace.rs +73 -0
package/src/malkuth.rs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
//! malkuth supervision protocol types.
|
|
2
|
+
//!
|
|
3
|
+
//! Wire types for the restart-authorization gate and worker lifecycle
|
|
4
|
+
//! management across the celestia-island supervision tree.
|
|
5
|
+
//!
|
|
6
|
+
//! ## Phase 0: authorization gate
|
|
7
|
+
//! - RestartProposal: generated after a repo rebuild completes
|
|
8
|
+
//! - RestartGateDecision: OreXis audit result (allow/review/block)
|
|
9
|
+
//! - GateDecision: enum for the three-state gate
|
|
10
|
+
//!
|
|
11
|
+
//! ## Phase 1: worker lifecycle
|
|
12
|
+
//! - DrainRequest / WorkerRegistration / WorkerStatus / HealthResponse
|
|
13
|
+
|
|
14
|
+
use schemars::JsonSchema;
|
|
15
|
+
use serde::{Deserialize, Serialize};
|
|
16
|
+
use ts_rs::TS;
|
|
17
|
+
|
|
18
|
+
/// A rebuild has completed and restart is proposed for a supervised worker.
|
|
19
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
20
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
21
|
+
pub struct RestartProposal {
|
|
22
|
+
pub proposal_id: String,
|
|
23
|
+
pub worker_id: String,
|
|
24
|
+
pub repo_path: String,
|
|
25
|
+
pub git_diff_summary: String,
|
|
26
|
+
pub affected_services: Vec<String>,
|
|
27
|
+
pub risk_estimate: RestartRisk,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)]
|
|
31
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
32
|
+
#[serde(rename_all = "snake_case")]
|
|
33
|
+
pub enum RestartRisk {
|
|
34
|
+
Low,
|
|
35
|
+
Medium,
|
|
36
|
+
High,
|
|
37
|
+
Critical,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// OreXis LAYER3_PREFLIGHT_GUARD gate decision for a restart proposal.
|
|
41
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
42
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
43
|
+
pub struct RestartGateDecision {
|
|
44
|
+
pub proposal_id: String,
|
|
45
|
+
pub decision: GateDecision,
|
|
46
|
+
pub findings: Vec<String>,
|
|
47
|
+
pub reason: String,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)]
|
|
51
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
52
|
+
#[serde(rename_all = "snake_case")]
|
|
53
|
+
pub enum GateDecision {
|
|
54
|
+
/// Proceed with restart.
|
|
55
|
+
Allow,
|
|
56
|
+
/// Escalate to human for review.
|
|
57
|
+
Review,
|
|
58
|
+
/// Block restart — security risk detected.
|
|
59
|
+
Block,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ═══════════════════════════════════════════════════════════════
|
|
63
|
+
// Phase 1 — worker lifecycle wire types
|
|
64
|
+
// ═══════════════════════════════════════════════════════════════
|
|
65
|
+
|
|
66
|
+
/// External request to drain (gracefully shut down) a supervised worker.
|
|
67
|
+
/// Sent to malkuth daemon after a restart proposal has been approved.
|
|
68
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
69
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
70
|
+
pub struct DrainRequest {
|
|
71
|
+
/// Which worker to drain.
|
|
72
|
+
pub worker_id: String,
|
|
73
|
+
/// Authorization: must match a previously approved GateDecision.proposal_id.
|
|
74
|
+
pub proposal_id: String,
|
|
75
|
+
/// Optional drain budget in seconds (default derived from worker config).
|
|
76
|
+
pub drain_budget_secs: Option<u64>,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// Registers a new worker with the malkuth supervisor.
|
|
80
|
+
/// Sent by a worker at startup to announce its presence and capabilities.
|
|
81
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
82
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
83
|
+
pub struct WorkerRegistration {
|
|
84
|
+
pub worker_id: String,
|
|
85
|
+
pub worker_kind: String,
|
|
86
|
+
pub repo_path: String,
|
|
87
|
+
pub connections: Vec<ConnectionEndpoint>,
|
|
88
|
+
pub health_check_path: Option<String>,
|
|
89
|
+
pub drain_budget_secs: u64,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// Describes how clients connect to a supervised worker.
|
|
93
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
94
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
95
|
+
pub struct ConnectionEndpoint {
|
|
96
|
+
pub protocol: ConnectionProtocol,
|
|
97
|
+
pub address: String,
|
|
98
|
+
pub port: u16,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)]
|
|
102
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
103
|
+
#[serde(rename_all = "snake_case")]
|
|
104
|
+
pub enum ConnectionProtocol {
|
|
105
|
+
Http,
|
|
106
|
+
Ws,
|
|
107
|
+
Ipc,
|
|
108
|
+
Tcp,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// Current status of a supervised worker returned by malkuth when queried.
|
|
112
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
113
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
114
|
+
pub struct WorkerStatus {
|
|
115
|
+
pub worker_id: String,
|
|
116
|
+
pub state: WorkerState,
|
|
117
|
+
pub pid: Option<u32>,
|
|
118
|
+
pub restart_count: u32,
|
|
119
|
+
pub last_restart_at: Option<String>,
|
|
120
|
+
pub connections: Vec<ConnectionEndpoint>,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS, JsonSchema)]
|
|
124
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
125
|
+
#[serde(rename_all = "snake_case")]
|
|
126
|
+
pub enum WorkerState {
|
|
127
|
+
Running,
|
|
128
|
+
/// Worker is accepting /readyz but not new work (drain in progress).
|
|
129
|
+
Draining,
|
|
130
|
+
Stopped,
|
|
131
|
+
Crashed,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// Health probe response returned by each worker at `/healthz` or `/readyz`.
|
|
135
|
+
#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)]
|
|
136
|
+
#[ts(export, export_to = "ws/malkuth.ts")]
|
|
137
|
+
pub struct HealthResponse {
|
|
138
|
+
pub worker_id: String,
|
|
139
|
+
pub healthy: bool,
|
|
140
|
+
pub ready: bool,
|
|
141
|
+
/// If not ready, the reason (e.g. "draining", "starting").
|
|
142
|
+
pub not_ready_reason: Option<String>,
|
|
143
|
+
pub uptime_secs: u64,
|
|
144
|
+
pub version: String,
|
|
145
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
use uuid::Uuid;
|
|
2
|
+
|
|
3
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
4
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
5
|
+
pub struct RagDbWriteResult {
|
|
6
|
+
pub doc_id: Uuid,
|
|
7
|
+
pub embedding_dim: usize,
|
|
8
|
+
pub content: String,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
12
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
13
|
+
pub struct RagDocResult {
|
|
14
|
+
pub doc_id: Uuid,
|
|
15
|
+
pub similarity: f64,
|
|
16
|
+
pub content: String,
|
|
17
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
18
|
+
pub source: Option<String>,
|
|
19
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
20
|
+
#[ts(type = "Record<string, unknown> | null")]
|
|
21
|
+
pub metadata: Option<serde_json::Value>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
25
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
26
|
+
pub struct RagDbReadResult {
|
|
27
|
+
pub count: usize,
|
|
28
|
+
pub results: Vec<RagDocResult>,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
32
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
33
|
+
pub struct RagDbDeleteResult {
|
|
34
|
+
pub doc_id: Uuid,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
38
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
39
|
+
pub struct LlmChatResult {
|
|
40
|
+
pub model: String,
|
|
41
|
+
pub tokens: String,
|
|
42
|
+
pub response: String,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
46
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
47
|
+
pub struct TranslateReportResult {
|
|
48
|
+
pub target_language: String,
|
|
49
|
+
pub original_length: usize,
|
|
50
|
+
pub translated_length: usize,
|
|
51
|
+
pub translation: String,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
55
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
56
|
+
pub struct MediaAssetRegisterResult {
|
|
57
|
+
pub asset_id: Uuid,
|
|
58
|
+
pub asset_type: String,
|
|
59
|
+
pub source_url: String,
|
|
60
|
+
pub tags: Vec<String>,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
64
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
65
|
+
pub struct MediaAssetItem {
|
|
66
|
+
pub asset_id: Uuid,
|
|
67
|
+
pub asset_type: String,
|
|
68
|
+
pub source_url: String,
|
|
69
|
+
#[ts(type = "Record<string, unknown>")]
|
|
70
|
+
pub metadata: serde_json::Value,
|
|
71
|
+
pub tags: Vec<String>,
|
|
72
|
+
pub created_at: String,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
76
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
77
|
+
pub struct MediaAssetRetrieveResult {
|
|
78
|
+
pub count: usize,
|
|
79
|
+
pub assets: Vec<MediaAssetItem>,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
83
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
84
|
+
pub struct WorkspaceIndexResult {
|
|
85
|
+
pub total_files: usize,
|
|
86
|
+
pub total_chunks: usize,
|
|
87
|
+
pub total_bytes: usize,
|
|
88
|
+
pub duration_ms: u64,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
92
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
93
|
+
pub struct WorkspaceSearchDoc {
|
|
94
|
+
pub doc_id: Uuid,
|
|
95
|
+
pub file_path: String,
|
|
96
|
+
pub start_line: usize,
|
|
97
|
+
pub end_line: usize,
|
|
98
|
+
pub language: String,
|
|
99
|
+
pub similarity: f64,
|
|
100
|
+
pub snippet: String,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
104
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
105
|
+
pub struct WorkspaceSearchResult {
|
|
106
|
+
pub count: usize,
|
|
107
|
+
pub results: Vec<WorkspaceSearchDoc>,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
111
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
112
|
+
pub struct WorkspaceStatusResult {
|
|
113
|
+
pub total_files: usize,
|
|
114
|
+
pub total_chunks: usize,
|
|
115
|
+
pub total_bytes: usize,
|
|
116
|
+
pub last_indexed: Option<String>,
|
|
117
|
+
pub is_indexing: bool,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
121
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
122
|
+
pub struct RagDbStatsResult {
|
|
123
|
+
pub total_documents: usize,
|
|
124
|
+
pub total_media_assets: usize,
|
|
125
|
+
pub embedding_dimensions: Option<usize>,
|
|
126
|
+
pub storage_backend: String,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ── Tool result structs (analysis) ──
|
|
130
|
+
|
|
131
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
132
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
133
|
+
pub struct CorrelationInfo {
|
|
134
|
+
pub variable: String,
|
|
135
|
+
pub correlation: f64,
|
|
136
|
+
pub lag: usize,
|
|
137
|
+
pub direction: String,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
141
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
142
|
+
pub struct Hypothesis {
|
|
143
|
+
pub cause: String,
|
|
144
|
+
pub effect: String,
|
|
145
|
+
pub strength: f64,
|
|
146
|
+
pub reasoning: String,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
150
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
151
|
+
pub struct CausalReasonResult {
|
|
152
|
+
pub correlations: Vec<CorrelationInfo>,
|
|
153
|
+
pub hypotheses: Vec<Hypothesis>,
|
|
154
|
+
pub recommended_actions: Vec<String>,
|
|
155
|
+
pub confidence: f64,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
159
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
160
|
+
pub struct AnomalyInfo {
|
|
161
|
+
pub index: usize,
|
|
162
|
+
pub value: f64,
|
|
163
|
+
pub expected: f64,
|
|
164
|
+
pub deviation: f64,
|
|
165
|
+
pub timestamp: Option<i64>,
|
|
166
|
+
pub severity: String,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
170
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
171
|
+
pub struct AnomalyResult {
|
|
172
|
+
pub anomalies: Vec<AnomalyInfo>,
|
|
173
|
+
pub total_points: usize,
|
|
174
|
+
pub anomaly_count: usize,
|
|
175
|
+
pub anomaly_ratio: f64,
|
|
176
|
+
pub method: String,
|
|
177
|
+
pub threshold: f64,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
181
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
182
|
+
pub struct RagDbWriteParams {
|
|
183
|
+
pub content: String,
|
|
184
|
+
#[serde(default)]
|
|
185
|
+
pub embedding: Option<Vec<f64>>,
|
|
186
|
+
#[serde(default)]
|
|
187
|
+
#[ts(type = "Record<string, unknown> | null")]
|
|
188
|
+
pub metadata: Option<serde_json::Value>,
|
|
189
|
+
#[serde(default)]
|
|
190
|
+
pub source: Option<String>,
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
194
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
195
|
+
pub struct RagDbReadParams {
|
|
196
|
+
pub query_embedding: Vec<f64>,
|
|
197
|
+
#[serde(default)]
|
|
198
|
+
pub limit: Option<usize>,
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
202
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
203
|
+
pub struct RagDbDeleteParams {
|
|
204
|
+
pub id: String,
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
208
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
209
|
+
pub struct AnomalyDetectParams {
|
|
210
|
+
pub values: Vec<f64>,
|
|
211
|
+
#[serde(default)]
|
|
212
|
+
pub method: Option<String>,
|
|
213
|
+
#[serde(default)]
|
|
214
|
+
pub threshold: Option<f64>,
|
|
215
|
+
#[serde(default)]
|
|
216
|
+
pub timestamps: Option<Vec<i64>>,
|
|
217
|
+
#[serde(default)]
|
|
218
|
+
pub window_size: Option<usize>,
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
222
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
223
|
+
pub struct CausalReasonParams {
|
|
224
|
+
pub target: String,
|
|
225
|
+
pub target_values: Vec<f64>,
|
|
226
|
+
#[serde(default)]
|
|
227
|
+
pub candidates: Option<std::collections::HashMap<String, Vec<f64>>>,
|
|
228
|
+
#[serde(default)]
|
|
229
|
+
pub max_lag: Option<usize>,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
233
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
234
|
+
pub struct WorkspaceIndexParams {
|
|
235
|
+
pub workspace_root: String,
|
|
236
|
+
#[serde(default)]
|
|
237
|
+
pub full_rebuild: Option<bool>,
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
241
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
242
|
+
pub struct WorkspaceSearchParams {
|
|
243
|
+
pub query: String,
|
|
244
|
+
#[serde(default)]
|
|
245
|
+
pub limit: Option<usize>,
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
249
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
250
|
+
pub struct LlmChatParams {
|
|
251
|
+
pub prompt: String,
|
|
252
|
+
#[serde(default)]
|
|
253
|
+
pub model: Option<String>,
|
|
254
|
+
#[serde(default)]
|
|
255
|
+
pub system_prompt: Option<String>,
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
259
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
260
|
+
pub struct TranslateReportParams {
|
|
261
|
+
pub content: String,
|
|
262
|
+
#[serde(default)]
|
|
263
|
+
pub target_language: Option<String>,
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
267
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
268
|
+
pub struct RagDbStatsParams {}
|
|
269
|
+
|
|
270
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
271
|
+
#[ts(export, export_to = "mcp/aporia.ts")]
|
|
272
|
+
pub struct WorkspaceStatusParams {}
|
package/src/mcp/eleos.rs
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
use crate::enums::WebSearchEngine;
|
|
2
|
+
|
|
3
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
4
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
5
|
+
pub struct WebSearchItem {
|
|
6
|
+
pub url: String,
|
|
7
|
+
pub title: String,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
11
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
12
|
+
pub struct WebSearchResult {
|
|
13
|
+
pub query: String,
|
|
14
|
+
pub engine: WebSearchEngine,
|
|
15
|
+
pub count: usize,
|
|
16
|
+
pub results: Vec<WebSearchItem>,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
20
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
21
|
+
pub struct WebFetchResult {
|
|
22
|
+
pub url: String,
|
|
23
|
+
pub title: String,
|
|
24
|
+
pub status_code: u16,
|
|
25
|
+
pub headers: String,
|
|
26
|
+
pub content: String,
|
|
27
|
+
pub content_preview: String,
|
|
28
|
+
pub content_length: usize,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
32
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
33
|
+
pub struct RemoteRefEntry {
|
|
34
|
+
pub ref_id: String,
|
|
35
|
+
pub url: String,
|
|
36
|
+
pub title: String,
|
|
37
|
+
pub ref_type: String,
|
|
38
|
+
pub registered_at: String,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
42
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
43
|
+
pub struct QueryRemoteRefsResult {
|
|
44
|
+
pub count: usize,
|
|
45
|
+
pub refs: Vec<RemoteRefEntry>,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
49
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
50
|
+
pub struct RegisterRemoteRefsResult {
|
|
51
|
+
pub ref_id: String,
|
|
52
|
+
pub url: String,
|
|
53
|
+
pub registered: bool,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── Tool parameter structs (for .d.ts API signature generation) ──
|
|
57
|
+
|
|
58
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
59
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
60
|
+
pub struct WebFetchParams {
|
|
61
|
+
pub url: String,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ts_rs::TS)]
|
|
65
|
+
#[ts(export, export_to = "mcp/eleos.ts")]
|
|
66
|
+
pub struct WebSearchParams {
|
|
67
|
+
pub query: String,
|
|
68
|
+
pub engine: Option<String>,
|
|
69
|
+
pub limit: Option<u64>,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#[cfg(test)]
|
|
73
|
+
mod tests {
|
|
74
|
+
use super::*;
|
|
75
|
+
use crate::enums::WebSearchEngine;
|
|
76
|
+
use serde_json::json;
|
|
77
|
+
|
|
78
|
+
#[test]
|
|
79
|
+
fn web_search_result_round_trip() {
|
|
80
|
+
let r = WebSearchResult {
|
|
81
|
+
query: "rust async runtime".into(),
|
|
82
|
+
engine: WebSearchEngine::Duckduckgo,
|
|
83
|
+
count: 2,
|
|
84
|
+
results: vec![
|
|
85
|
+
WebSearchItem {
|
|
86
|
+
url: "https://tokio.rs".into(),
|
|
87
|
+
title: "Tokio".into(),
|
|
88
|
+
},
|
|
89
|
+
WebSearchItem {
|
|
90
|
+
url: "https://async.rs".into(),
|
|
91
|
+
title: "async-std".into(),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
let v = serde_json::to_value(&r).unwrap();
|
|
96
|
+
// WebSearchEngine serializes as PascalCase variant name.
|
|
97
|
+
assert_eq!(v["engine"], "Duckduckgo");
|
|
98
|
+
assert_eq!(v["count"], 2);
|
|
99
|
+
assert_eq!(v["results"][0]["url"], "https://tokio.rs");
|
|
100
|
+
let back: WebSearchResult = serde_json::from_value(v).unwrap();
|
|
101
|
+
assert_eq!(back.results.len(), 2);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#[test]
|
|
105
|
+
fn web_search_result_empty() {
|
|
106
|
+
let r = WebSearchResult {
|
|
107
|
+
query: "nothing".into(),
|
|
108
|
+
engine: WebSearchEngine::Duckduckgo,
|
|
109
|
+
count: 0,
|
|
110
|
+
results: vec![],
|
|
111
|
+
};
|
|
112
|
+
let v = serde_json::to_value(&r).unwrap();
|
|
113
|
+
assert_eq!(v["results"], json!([]));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#[test]
|
|
117
|
+
fn web_fetch_result_round_trip() {
|
|
118
|
+
let r = WebFetchResult {
|
|
119
|
+
url: "https://example.com".into(),
|
|
120
|
+
title: "Example".into(),
|
|
121
|
+
status_code: 200,
|
|
122
|
+
headers: "content-type: text/html".into(),
|
|
123
|
+
content: "<html>...</html>".into(),
|
|
124
|
+
content_preview: "<html>...".into(),
|
|
125
|
+
content_length: 1024,
|
|
126
|
+
};
|
|
127
|
+
let v = serde_json::to_value(&r).unwrap();
|
|
128
|
+
assert_eq!(v["status_code"], 200);
|
|
129
|
+
assert_eq!(v["content_length"], 1024);
|
|
130
|
+
let back: WebFetchResult = serde_json::from_value(v).unwrap();
|
|
131
|
+
assert_eq!(back.status_code, 200);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#[test]
|
|
135
|
+
fn remote_ref_entry_round_trip() {
|
|
136
|
+
let r = RemoteRefEntry {
|
|
137
|
+
ref_id: "ref-001".into(),
|
|
138
|
+
url: "https://docs.rs".into(),
|
|
139
|
+
title: "Rust Docs".into(),
|
|
140
|
+
ref_type: "documentation".into(),
|
|
141
|
+
registered_at: "2026-07-07T00:00:00Z".into(),
|
|
142
|
+
};
|
|
143
|
+
let v = serde_json::to_value(&r).unwrap();
|
|
144
|
+
assert_eq!(v["ref_type"], "documentation");
|
|
145
|
+
let back: RemoteRefEntry = serde_json::from_value(v).unwrap();
|
|
146
|
+
assert_eq!(back.ref_id, "ref-001");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#[test]
|
|
150
|
+
fn query_remote_refs_result_round_trip() {
|
|
151
|
+
let r = QueryRemoteRefsResult {
|
|
152
|
+
count: 1,
|
|
153
|
+
refs: vec![RemoteRefEntry {
|
|
154
|
+
ref_id: "r1".into(),
|
|
155
|
+
url: "https://x.com".into(),
|
|
156
|
+
title: "X".into(),
|
|
157
|
+
ref_type: "article".into(),
|
|
158
|
+
registered_at: "2026-01-01".into(),
|
|
159
|
+
}],
|
|
160
|
+
};
|
|
161
|
+
let v = serde_json::to_value(&r).unwrap();
|
|
162
|
+
assert_eq!(v["count"], 1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#[test]
|
|
166
|
+
fn register_remote_refs_result_round_trip() {
|
|
167
|
+
let r = RegisterRemoteRefsResult {
|
|
168
|
+
ref_id: "ref-002".into(),
|
|
169
|
+
url: "https://new.url".into(),
|
|
170
|
+
registered: true,
|
|
171
|
+
};
|
|
172
|
+
let v = serde_json::to_value(&r).unwrap();
|
|
173
|
+
assert_eq!(v["registered"], true);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#[test]
|
|
177
|
+
fn web_search_params_minimal() {
|
|
178
|
+
let p = WebSearchParams {
|
|
179
|
+
query: "test".into(),
|
|
180
|
+
engine: None,
|
|
181
|
+
limit: None,
|
|
182
|
+
};
|
|
183
|
+
let v = serde_json::to_value(&p).unwrap();
|
|
184
|
+
assert_eq!(v["query"], "test");
|
|
185
|
+
assert_eq!(v["engine"], serde_json::Value::Null);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#[test]
|
|
189
|
+
fn web_search_params_with_all_fields() {
|
|
190
|
+
let p = WebSearchParams {
|
|
191
|
+
query: "test".into(),
|
|
192
|
+
engine: Some("duckduckgo".into()),
|
|
193
|
+
limit: Some(10),
|
|
194
|
+
};
|
|
195
|
+
let v = serde_json::to_value(&p).unwrap();
|
|
196
|
+
assert_eq!(v["limit"], 10);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#[test]
|
|
200
|
+
fn web_search_engine_enum_round_trip() {
|
|
201
|
+
let e = WebSearchEngine::Duckduckgo;
|
|
202
|
+
let s = serde_json::to_string(&e).unwrap();
|
|
203
|
+
// serde uses PascalCase variant name; as_str() returns the wire value.
|
|
204
|
+
assert_eq!(s, r#""Duckduckgo""#);
|
|
205
|
+
let back: WebSearchEngine = serde_json::from_str(&s).unwrap();
|
|
206
|
+
assert_eq!(back, e);
|
|
207
|
+
// as_str() gives the lowercase domain vocabulary string.
|
|
208
|
+
assert_eq!(e.as_str(), "duckduckgo");
|
|
209
|
+
}
|
|
210
|
+
}
|