@lacneu/atrium-mcp 0.30.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/README.md +160 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +220 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +59 -0
- package/dist/config.js +103 -0
- package/dist/config.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +250 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +341 -0
- package/dist/tools.js +389 -0
- package/dist/tools.js.map +1 -0
- package/package.json +40 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* atrium MCP server (stdio).
|
|
4
|
+
*
|
|
5
|
+
* A thin proxy over our /api/v1 observability surface. It carries an `oc_live_`
|
|
6
|
+
* Bearer key (from OPENCLAW_WEBCHAT_API_KEY) against the deployment `.site`
|
|
7
|
+
* origin (OPENCLAW_WEBCHAT_API_BASE) and exposes traces/KPIs/OpenClaw queries/
|
|
8
|
+
* anomalies as MCP tools for OpenClaw agents.
|
|
9
|
+
*
|
|
10
|
+
* It imports NOTHING from the Convex app — HTTP only. Each tool maps 1:1 to a
|
|
11
|
+
* permission enforced server-side (`requirePermission`), so a scoped key simply
|
|
12
|
+
* gets a 403 for tools it isn't allowed to call. A tool whose route is not yet
|
|
13
|
+
* deployed returns the API's response/error gracefully rather than crashing.
|
|
14
|
+
*/
|
|
15
|
+
import { createRequire } from "node:module";
|
|
16
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
18
|
+
import { ApiError, resolveConfig } from "./config.js";
|
|
19
|
+
import { getChatState, getChatStateInput, getFeedbackReport, getFeedbackReportInput, getCompactionHistory, getCompactionHistoryInput, getTraceEnrichment, getTraceEnrichmentInput, diagnoseChat, diagnoseChatInput, reconcileChat, reconcileChatInput, getCompat, bridgeStatus, syncInstance, syncInstanceInput, getIntegrations, getKpi, getKpiInput, getSchema, getSchemaInput, health, listAnomalies, listAnomaliesInput, listSchemas, listTraces, listTracesInput, queryOpenClaw, queryOpenClawInput, reportAnomaly, reportAnomalyInput, startDeliveryRecord, stopDeliveryRecord, getDeliveryReport, getDeliveryReportInput, listDeliverySessions, deleteDeliverySessions, deleteDeliverySessionsInput, } from "./tools.js";
|
|
20
|
+
// The MCP server's own version, read from package.json at startup. createRequire
|
|
21
|
+
// (not a static JSON import) because tsconfig.build.json roots at src/ and a
|
|
22
|
+
// static import of ../package.json would escape rootDir — same idiom as the bridge
|
|
23
|
+
// (bridge/src/compat.ts). Lockstep with the repo's single version, stamped from the
|
|
24
|
+
// git tag at release time (scripts/set-version.mjs); "0.0.0" only as a last resort.
|
|
25
|
+
const pkg = createRequire(import.meta.url)("../package.json");
|
|
26
|
+
const MCP_VERSION = typeof pkg.version === "string" && pkg.version.length > 0
|
|
27
|
+
? pkg.version
|
|
28
|
+
: "0.0.0";
|
|
29
|
+
/** Wrap a tool call: stringify JSON on success, surface ApiError as text. */
|
|
30
|
+
async function run(fn) {
|
|
31
|
+
try {
|
|
32
|
+
const value = await fn();
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (err instanceof ApiError) {
|
|
39
|
+
const bodyText = typeof err.body === "string"
|
|
40
|
+
? err.body
|
|
41
|
+
: JSON.stringify(err.body, null, 2);
|
|
42
|
+
return {
|
|
43
|
+
content: [
|
|
44
|
+
{ type: "text", text: `API error ${err.status}: ${bodyText}` },
|
|
45
|
+
],
|
|
46
|
+
isError: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
52
|
+
isError: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function main() {
|
|
57
|
+
// Resolve config up front so a missing key fails fast with a clear message
|
|
58
|
+
// (the message names the env var, never its value).
|
|
59
|
+
const config = resolveConfig();
|
|
60
|
+
const server = new McpServer({
|
|
61
|
+
name: "atrium-observability",
|
|
62
|
+
version: MCP_VERSION,
|
|
63
|
+
});
|
|
64
|
+
server.registerTool("health", {
|
|
65
|
+
title: "API health",
|
|
66
|
+
description: "Liveness probe for the /api/v1 surface (GET /health).",
|
|
67
|
+
inputSchema: {},
|
|
68
|
+
}, async () => run(() => health(config)));
|
|
69
|
+
server.registerTool("get_compat", {
|
|
70
|
+
title: "Bridge compatibility snapshot",
|
|
71
|
+
description: "Bridge version + per-instance gateway versions/capabilities (GET /compat). " +
|
|
72
|
+
"Requires bridge.read. Diagnoses 'version gateway inconnue': empty targets " +
|
|
73
|
+
"or a null gatewayVersion gates AgentFiles/ChatDefaults off.",
|
|
74
|
+
inputSchema: {},
|
|
75
|
+
}, async () => run(() => getCompat(config)));
|
|
76
|
+
server.registerTool("bridge_status", {
|
|
77
|
+
title: "Per-instance bridge/gateway health",
|
|
78
|
+
description: "A CLEAR per-instance bridge<->gateway health view (GET /bridge-status). " +
|
|
79
|
+
"Requires bridge.read. Per instance: bridgeUrlConfigured, a health verdict " +
|
|
80
|
+
"(ok|error|stale|unknown|no_bridge_url, from THIS instance's own signals — not the " +
|
|
81
|
+
"global bridge state) + degraded, gatewayVersion + gatewayState/lastErrorCode, " +
|
|
82
|
+
"agentCount + discovery freshness. The fast 'what's wrong with my instances' check " +
|
|
83
|
+
"— e.g. bridgeUrlConfigured:false is exactly why a sync returns no_bridge_url.",
|
|
84
|
+
inputSchema: {},
|
|
85
|
+
}, async () => run(() => bridgeStatus(config)));
|
|
86
|
+
server.registerTool("get_integrations", {
|
|
87
|
+
title: "Observability integration status (Opik / Langfuse)",
|
|
88
|
+
description: "Per-vendor configured/enabled + non-secret effective endpoints + shipping " +
|
|
89
|
+
"cursors (lastAt/failureCount/error code), NEVER a key (GET /integrations). " +
|
|
90
|
+
"Requires traces.read. Use FIRST when self-diagnosing: it tells an agent " +
|
|
91
|
+
"whether enriched Opik/Langfuse trace data is available and shipping is healthy.",
|
|
92
|
+
inputSchema: {},
|
|
93
|
+
}, async () => run(() => getIntegrations(config)));
|
|
94
|
+
server.registerTool("get_feedback_report", {
|
|
95
|
+
title: "Read a user-submitted report",
|
|
96
|
+
description: "One feedback report by its shareable reference (GET /feedback-report). " +
|
|
97
|
+
"Key must have traces.read. Returns the FROZEN forensic snapshot the " +
|
|
98
|
+
"reporter volunteered (message text/parts, prompt, bounded context, " +
|
|
99
|
+
"session settings) + chatExists/messageExists flags — the report " +
|
|
100
|
+
"survives deletion of its message or chat.",
|
|
101
|
+
inputSchema: getFeedbackReportInput,
|
|
102
|
+
}, async (args) => run(() => getFeedbackReport(config, args)));
|
|
103
|
+
server.registerTool("get_chat_state", {
|
|
104
|
+
title: "Inspect chat state",
|
|
105
|
+
description: "Per-message lifecycle of one chat (GET /chat-state). Key must have " +
|
|
106
|
+
"traces.read. METADATA ONLY (no message text). Exposes a stuck-streaming " +
|
|
107
|
+
"turn: a message with status 'streaming' + large ageSeconds " +
|
|
108
|
+
"(stuckStreaming:true) = the bridge never relayed its finalize frame. Each " +
|
|
109
|
+
"provenance part carries a SOC2-safe `structure` (per-item kind " +
|
|
110
|
+
"document|context|memory + hasFileName/hasScore booleans, itemCount, " +
|
|
111
|
+
"hasExcerpts, allowlisted source/retrievalRoute) — diagnose a Sources panel " +
|
|
112
|
+
"issue ('documents show no score/excerpt' = a bare lightrag attribution turn: " +
|
|
113
|
+
"kind document + hasScore:false) without any content.",
|
|
114
|
+
inputSchema: getChatStateInput,
|
|
115
|
+
}, async (args) => run(() => getChatState(config, args)));
|
|
116
|
+
server.registerTool("get_compaction_history", {
|
|
117
|
+
title: "Gateway compaction history",
|
|
118
|
+
description: "The gateway's compaction checkpoints for one chat's session (GET " +
|
|
119
|
+
"/compaction-history). Key must have traces.read. LAZY read (on-demand " +
|
|
120
|
+
"gateway RPC — never on the turn path). CONTENT-FREE: per checkpoint " +
|
|
121
|
+
"{checkpointId, createdAt, reason, tokensBefore, tokensAfter}; the stored " +
|
|
122
|
+
"summary text never crosses the API. Pair with list_traces " +
|
|
123
|
+
"kind=chat.gateway_pressure (per-turn fill ratio + compaction flag) to see " +
|
|
124
|
+
"WHEN a session filled up and WHAT each compaction condensed.",
|
|
125
|
+
inputSchema: getCompactionHistoryInput,
|
|
126
|
+
}, async (args) => run(() => getCompactionHistory(config, args)));
|
|
127
|
+
server.registerTool("list_schemas", {
|
|
128
|
+
title: "List published contract schemas",
|
|
129
|
+
description: "The machine-readable CONTRACT schemas an integration author can conform to " +
|
|
130
|
+
"(GET /schemas). Metadata only (id, title, version, category) — provenance/v1 " +
|
|
131
|
+
"today, more as the surface grows. PUBLIC (no key required). Use get_schema to " +
|
|
132
|
+
"fetch one.",
|
|
133
|
+
inputSchema: {},
|
|
134
|
+
}, async () => run(() => listSchemas(config)));
|
|
135
|
+
server.registerTool("get_schema", {
|
|
136
|
+
title: "Get a published contract schema",
|
|
137
|
+
description: "One contract schema's JSON by registry id (GET /schemas/:id), e.g. " +
|
|
138
|
+
"\"provenance.v1\" — validate a plugin's emitted reports against it. PUBLIC " +
|
|
139
|
+
"(no key required). 404 for an unknown id.",
|
|
140
|
+
inputSchema: getSchemaInput,
|
|
141
|
+
}, async (args) => run(() => getSchema(config, args)));
|
|
142
|
+
server.registerTool("get_trace_enrichment", {
|
|
143
|
+
title: "Enriched trace structure (Opik / Langfuse)",
|
|
144
|
+
description: "SOC2-safe STRUCTURE of a turn's trace (keyed by its correlationId) " +
|
|
145
|
+
"fetched from the configured Opik/Langfuse: span " +
|
|
146
|
+
"names/types/lifecycle/timing/parent tree, NEVER input/output/message " +
|
|
147
|
+
"text (GET /trace-enrichment). Requires traces.read. Get the correlationId " +
|
|
148
|
+
"from list_traces/list_anomalies, then use this to see the REAL OpenClaw " +
|
|
149
|
+
"message structure behind an anomaly without seeing regulated data. Pass " +
|
|
150
|
+
"chatId too to also surface OTHER traces on the same chat session " +
|
|
151
|
+
"(content-free). Call get_integrations first to confirm a vendor is wired.",
|
|
152
|
+
inputSchema: getTraceEnrichmentInput,
|
|
153
|
+
}, async (args) => run(() => getTraceEnrichment(config, args)));
|
|
154
|
+
server.registerTool("diagnose_chat", {
|
|
155
|
+
title: "Diagnose a chat (assessment + suggested fix)",
|
|
156
|
+
description: "ONE actionable assessment of a chat (GET /diagnose): SOC2-safe chat-state " +
|
|
157
|
+
"+ bridge availability, classified (stuck_stream | dispatch_error | " +
|
|
158
|
+
"attachment_problem | bridge_unavailable | bridge_degraded | healthy) with a " +
|
|
159
|
+
"`suggestedAction` and, when safe, a `suggestedTool` (e.g. reconcile_chat). " +
|
|
160
|
+
"Requires traces.read. Read-only. CALL THIS FIRST on a user report, then act " +
|
|
161
|
+
"on the suggestion.",
|
|
162
|
+
inputSchema: diagnoseChatInput,
|
|
163
|
+
}, async (args) => run(() => diagnoseChat(config, args)));
|
|
164
|
+
server.registerTool("reconcile_chat", {
|
|
165
|
+
title: "Self-correct: release a chat's stuck stream",
|
|
166
|
+
description: "BOUNDED corrective (POST /reconcile-chat): flip this chat's stuck " +
|
|
167
|
+
"'streaming' message(s) to error (preserving text) so the hung UI releases " +
|
|
168
|
+
"and the user can retry. Requires `selfheal` (a sensitive write). Audited. " +
|
|
169
|
+
"Only touches messages already streaming past a short cutoff. Use when " +
|
|
170
|
+
"diagnose_chat returns class 'stuck_stream' / suggestedTool 'reconcile_chat'.",
|
|
171
|
+
inputSchema: reconcileChatInput,
|
|
172
|
+
}, async (args) => run(() => reconcileChat(config, args)));
|
|
173
|
+
server.registerTool("sync_instance", {
|
|
174
|
+
title: "Force an instance sync (resolve creds + pull agents)",
|
|
175
|
+
description: "Force-sync ONE instance (POST /instances/sync): poke the bridge (resolve creds " +
|
|
176
|
+
"+ connect -> pairing) then pull that instance's agents into Atrium NOW, instead " +
|
|
177
|
+
"of waiting for the discovery cron. Requires `selfheal` (admin + agent service " +
|
|
178
|
+
"roles). Returns { status, agents, detail }: status is the exact outcome (synced " +
|
|
179
|
+
"| no_agents | no_bridge_url | unreachable | unauthorized | not_served | " +
|
|
180
|
+
"deploy_misconfigured) and detail is a plain-English explanation to act on.",
|
|
181
|
+
inputSchema: syncInstanceInput,
|
|
182
|
+
}, async (args) => run(() => syncInstance(config, args)));
|
|
183
|
+
server.registerTool("list_traces", {
|
|
184
|
+
title: "List recent traces",
|
|
185
|
+
description: "Recent trace events (GET /traces). Key must have traces.read.",
|
|
186
|
+
inputSchema: listTracesInput,
|
|
187
|
+
}, async (args) => run(() => listTraces(config, args)));
|
|
188
|
+
server.registerTool("get_kpi", {
|
|
189
|
+
title: "Get KPI rollups",
|
|
190
|
+
description: "KPI rollups (GET /kpi). Key must have kpi.read.",
|
|
191
|
+
inputSchema: getKpiInput,
|
|
192
|
+
}, async (args) => run(() => getKpi(config, args)));
|
|
193
|
+
server.registerTool("query_openclaw", {
|
|
194
|
+
title: "Query OpenClaw",
|
|
195
|
+
description: "Query OpenClaw via the bridge (POST /openclaw/query). " +
|
|
196
|
+
"Key must have openclaw.query.",
|
|
197
|
+
inputSchema: queryOpenClawInput,
|
|
198
|
+
}, async (args) => run(() => queryOpenClaw(config, args)));
|
|
199
|
+
server.registerTool("list_anomalies", {
|
|
200
|
+
title: "List anomalies",
|
|
201
|
+
description: "Detected anomalies (GET /anomalies). Key must have anomalies.read.",
|
|
202
|
+
inputSchema: listAnomaliesInput,
|
|
203
|
+
}, async (args) => run(() => listAnomalies(config, args)));
|
|
204
|
+
server.registerTool("report_anomaly", {
|
|
205
|
+
title: "Report an anomaly",
|
|
206
|
+
description: "Report an anomaly / self-repair signal (POST /anomalies). " +
|
|
207
|
+
"Key must have anomalies.report.",
|
|
208
|
+
inputSchema: reportAnomalyInput,
|
|
209
|
+
}, async (args) => run(() => reportAnomaly(config, args)));
|
|
210
|
+
server.registerTool("start_delivery_record", {
|
|
211
|
+
title: "Start delivery-latency recording",
|
|
212
|
+
description: "Start a delivery-latency recording session (POST /delivery-record/start). " +
|
|
213
|
+
"Measures the bridge->Convex->frontend streaming pipeline per delta, content-free. " +
|
|
214
|
+
"Requires selfheal (activation is a privileged write). Returns { sessionId, " +
|
|
215
|
+
"autoStopAt }; auto-stops after ~10 min. Run a chat turn while active, then " +
|
|
216
|
+
"get_delivery_report.",
|
|
217
|
+
inputSchema: {},
|
|
218
|
+
}, async () => run(() => startDeliveryRecord(config)));
|
|
219
|
+
server.registerTool("stop_delivery_record", {
|
|
220
|
+
title: "Stop delivery-latency recording",
|
|
221
|
+
description: "Stop the active delivery-latency recording (POST /delivery-record/stop). " +
|
|
222
|
+
"Requires selfheal.",
|
|
223
|
+
inputSchema: {},
|
|
224
|
+
}, async () => run(() => stopDeliveryRecord(config)));
|
|
225
|
+
server.registerTool("get_delivery_report", {
|
|
226
|
+
title: "Delivery-latency report",
|
|
227
|
+
description: "Skew-corrected per-segment latency for a recording session (GET /delivery-report): " +
|
|
228
|
+
"A=bridge->Convex, B=Convex exec, C=Convex->frontend, each p50/p95/max + count. " +
|
|
229
|
+
"C.count <= A.count by design (the client only observes coalesced states). " +
|
|
230
|
+
"Requires traces.read. Omit sessionId for the active/latest session.",
|
|
231
|
+
inputSchema: getDeliveryReportInput,
|
|
232
|
+
}, async (args) => run(() => getDeliveryReport(config, args)));
|
|
233
|
+
server.registerTool("list_delivery_sessions", {
|
|
234
|
+
title: "List delivery-latency recording sessions",
|
|
235
|
+
description: "List recent delivery-latency recording sessions (GET /delivery-sessions): " +
|
|
236
|
+
"sessionId, startedAt, stoppedAt, startedBy, active. Requires traces.read. " +
|
|
237
|
+
"Pick a sessionId for get_delivery_report or delete_delivery_sessions.",
|
|
238
|
+
inputSchema: {},
|
|
239
|
+
}, async () => run(() => listDeliverySessions(config)));
|
|
240
|
+
server.registerTool("delete_delivery_sessions", {
|
|
241
|
+
title: "Delete delivery-latency recording sessions",
|
|
242
|
+
description: "Delete recording sessions and their timing rows (POST /delivery-record/delete). " +
|
|
243
|
+
"Requires selfheal. Deleting the active session also stops recording.",
|
|
244
|
+
inputSchema: deleteDeliverySessionsInput,
|
|
245
|
+
}, async (args) => run(() => deleteDeliverySessions(config, args)));
|
|
246
|
+
const transport = new StdioServerTransport();
|
|
247
|
+
void server.connect(transport);
|
|
248
|
+
}
|
|
249
|
+
main();
|
|
250
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,MAAM,EACN,WAAW,EACX,SAAS,EACT,cAAc,EACd,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,6EAA6E;A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K,EAAE,yBAAyB;QAChC,WAAW,EACT,qFAAqF;YACrF,iFAAiF;YACjF,4EAA4E;YAC5E,qEAAqE;QACvE,WAAW,EAAE,sBAAsB;KACpC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAC3D,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,0CAA0C;QACjD,WAAW,EACT,4EAA4E;YAC5E,4EAA4E;YAC5E,uEAAuE;QACzE,WAAW,EAAE,EAAE;KAChB,EACD,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CACpD,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,4CAA4C;QACnD,WAAW,EACT,kFAAkF;YAClF,sEAAsE;QACxE,WAAW,EAAE,2BAA2B;KACzC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAChE,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,KAAK,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared tool logic for both the MCP server and the CLI.
|
|
3
|
+
*
|
|
4
|
+
* Each function here maps 1:1 to one /api/v1 route. The package is a thin proxy:
|
|
5
|
+
* whether a route is deployed is a *runtime* concern — a not-yet-deployed route
|
|
6
|
+
* returns the API's own response/error (e.g. 404) which we surface, rather than
|
|
7
|
+
* crashing the server.
|
|
8
|
+
*
|
|
9
|
+
* Server-side `requirePermission` enforces the key's scope, so a tool call to a
|
|
10
|
+
* route the key lacks permission for naturally returns 403.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { type ApiFetchOptions, type Config } from "./config.js";
|
|
14
|
+
export interface ListTracesArgs {
|
|
15
|
+
limit?: number;
|
|
16
|
+
/** Case-insensitive substring over kind/principalId/roleKey/route/correlationId. */
|
|
17
|
+
q?: string;
|
|
18
|
+
/** Lower time bound: epoch ms OR Grafana relative token (e.g. `now-24h`). */
|
|
19
|
+
from?: string;
|
|
20
|
+
/** Upper time bound: epoch ms OR Grafana relative token (e.g. `now`). */
|
|
21
|
+
to?: string;
|
|
22
|
+
kind?: string;
|
|
23
|
+
/** Exact HTTP status code (e.g. 404). */
|
|
24
|
+
status?: number;
|
|
25
|
+
/** HTTP status class. */
|
|
26
|
+
statusClass?: "2xx" | "4xx" | "5xx";
|
|
27
|
+
direction?: string;
|
|
28
|
+
principalType?: string;
|
|
29
|
+
roleKey?: string;
|
|
30
|
+
correlationId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface GetKpiArgs {
|
|
33
|
+
metric?: string;
|
|
34
|
+
since?: string;
|
|
35
|
+
/** Lower time bound: epoch ms OR Grafana relative token (e.g. `now-24h`). */
|
|
36
|
+
from?: string;
|
|
37
|
+
/** Upper time bound: epoch ms OR Grafana relative token (e.g. `now`). */
|
|
38
|
+
to?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface QueryOpenClawArgs {
|
|
41
|
+
/** Matches the server contract: POST /api/v1/openclaw/query reads `question`. */
|
|
42
|
+
question?: string;
|
|
43
|
+
/** Free-form passthrough the route forwards to the bridge action. */
|
|
44
|
+
payload?: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface ListAnomaliesArgs {
|
|
47
|
+
limit?: number;
|
|
48
|
+
since?: string;
|
|
49
|
+
/** Case-insensitive substring over message/kind/correlationId. */
|
|
50
|
+
q?: string;
|
|
51
|
+
/** Lower time bound: epoch ms OR Grafana relative token (e.g. `now-24h`). */
|
|
52
|
+
from?: string;
|
|
53
|
+
/** Upper time bound: epoch ms OR Grafana relative token (e.g. `now`). */
|
|
54
|
+
to?: string;
|
|
55
|
+
/** Anomaly status (maps to anomalyStatus, e.g. 'open'|'acknowledged'). */
|
|
56
|
+
status?: string;
|
|
57
|
+
severity?: string;
|
|
58
|
+
source?: string;
|
|
59
|
+
kind?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ReportAnomalyArgs {
|
|
62
|
+
kind: string;
|
|
63
|
+
/** Server accepts only info|warn|critical (400 otherwise). */
|
|
64
|
+
severity: "info" | "warn" | "critical";
|
|
65
|
+
message: string;
|
|
66
|
+
correlationId?: string;
|
|
67
|
+
/** Maps to the server's `evidence` field (non-PHI structured context). */
|
|
68
|
+
evidence?: unknown;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Shared MCP input schemas, kept here (not in server.ts) so they can be unit
|
|
72
|
+
* tested without importing server.ts/cli.ts — both of which call `main()` at
|
|
73
|
+
* module load. server.ts spreads these into `registerTool({ inputSchema })`.
|
|
74
|
+
*/
|
|
75
|
+
export declare const queryOpenClawInput: {
|
|
76
|
+
readonly question: z.ZodOptional<z.ZodString>;
|
|
77
|
+
readonly payload: z.ZodOptional<z.ZodUnknown>;
|
|
78
|
+
};
|
|
79
|
+
export declare const reportAnomalyInput: {
|
|
80
|
+
readonly kind: z.ZodString;
|
|
81
|
+
readonly severity: z.ZodEnum<{
|
|
82
|
+
info: "info";
|
|
83
|
+
warn: "warn";
|
|
84
|
+
critical: "critical";
|
|
85
|
+
}>;
|
|
86
|
+
readonly message: z.ZodString;
|
|
87
|
+
readonly correlationId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
readonly evidence: z.ZodOptional<z.ZodUnknown>;
|
|
89
|
+
};
|
|
90
|
+
export declare const getDeliveryReportInput: {
|
|
91
|
+
readonly sessionId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
};
|
|
93
|
+
export declare const deleteDeliverySessionsInput: {
|
|
94
|
+
readonly sessionIds: z.ZodArray<z.ZodString>;
|
|
95
|
+
};
|
|
96
|
+
export declare const listTracesInput: {
|
|
97
|
+
readonly limit: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
readonly q: z.ZodOptional<z.ZodString>;
|
|
99
|
+
readonly from: z.ZodOptional<z.ZodString>;
|
|
100
|
+
readonly to: z.ZodOptional<z.ZodString>;
|
|
101
|
+
readonly kind: z.ZodOptional<z.ZodString>;
|
|
102
|
+
readonly status: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
readonly statusClass: z.ZodOptional<z.ZodEnum<{
|
|
104
|
+
"2xx": "2xx";
|
|
105
|
+
"4xx": "4xx";
|
|
106
|
+
"5xx": "5xx";
|
|
107
|
+
}>>;
|
|
108
|
+
readonly direction: z.ZodOptional<z.ZodString>;
|
|
109
|
+
readonly principalType: z.ZodOptional<z.ZodString>;
|
|
110
|
+
readonly roleKey: z.ZodOptional<z.ZodString>;
|
|
111
|
+
readonly correlationId: z.ZodOptional<z.ZodString>;
|
|
112
|
+
};
|
|
113
|
+
export declare const getKpiInput: {
|
|
114
|
+
readonly metric: z.ZodOptional<z.ZodString>;
|
|
115
|
+
readonly since: z.ZodOptional<z.ZodString>;
|
|
116
|
+
readonly from: z.ZodOptional<z.ZodString>;
|
|
117
|
+
readonly to: z.ZodOptional<z.ZodString>;
|
|
118
|
+
};
|
|
119
|
+
export declare const listAnomaliesInput: {
|
|
120
|
+
readonly limit: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
readonly since: z.ZodOptional<z.ZodString>;
|
|
122
|
+
readonly q: z.ZodOptional<z.ZodString>;
|
|
123
|
+
readonly from: z.ZodOptional<z.ZodString>;
|
|
124
|
+
readonly to: z.ZodOptional<z.ZodString>;
|
|
125
|
+
readonly status: z.ZodOptional<z.ZodString>;
|
|
126
|
+
readonly severity: z.ZodOptional<z.ZodString>;
|
|
127
|
+
readonly source: z.ZodOptional<z.ZodString>;
|
|
128
|
+
readonly kind: z.ZodOptional<z.ZodString>;
|
|
129
|
+
};
|
|
130
|
+
export declare const getFeedbackReportInput: {
|
|
131
|
+
feedbackId: z.ZodString;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* GET /api/v1/feedback-report — one user-submitted report by its shareable
|
|
135
|
+
* REFERENCE. Returns the frozen forensic snapshot (message text/parts, prompt,
|
|
136
|
+
* context window, session settings — volunteered by the reporter) + survival
|
|
137
|
+
* flags (chatExists/messageExists: the report OUTLIVES message/chat deletion).
|
|
138
|
+
* Requires `traces.read`.
|
|
139
|
+
*/
|
|
140
|
+
export declare function getFeedbackReport(config: Config, args: {
|
|
141
|
+
feedbackId: string;
|
|
142
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
143
|
+
export declare const getChatStateInput: {
|
|
144
|
+
readonly chatId: z.ZodString;
|
|
145
|
+
};
|
|
146
|
+
export declare const getCompactionHistoryInput: {
|
|
147
|
+
readonly chatId: z.ZodString;
|
|
148
|
+
};
|
|
149
|
+
export declare const getSchemaInput: {
|
|
150
|
+
readonly id: z.ZodString;
|
|
151
|
+
};
|
|
152
|
+
export declare const getTraceEnrichmentInput: {
|
|
153
|
+
readonly correlationId: z.ZodString;
|
|
154
|
+
readonly chatId: z.ZodOptional<z.ZodString>;
|
|
155
|
+
readonly at: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
};
|
|
157
|
+
export interface GetTraceEnrichmentArgs {
|
|
158
|
+
correlationId: string;
|
|
159
|
+
chatId?: string;
|
|
160
|
+
at?: number;
|
|
161
|
+
}
|
|
162
|
+
export declare const diagnoseChatInput: {
|
|
163
|
+
readonly chatId: z.ZodString;
|
|
164
|
+
};
|
|
165
|
+
export declare const reconcileChatInput: {
|
|
166
|
+
readonly chatId: z.ZodString;
|
|
167
|
+
};
|
|
168
|
+
export declare const syncInstanceInput: {
|
|
169
|
+
readonly instance: z.ZodString;
|
|
170
|
+
};
|
|
171
|
+
/** GET /api/v1/health — liveness probe (no auth needed, but we send the key). */
|
|
172
|
+
export declare function health(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
173
|
+
/**
|
|
174
|
+
* GET /api/v1/compat — the bridge compatibility snapshot (reachable,
|
|
175
|
+
* bridgeVersion, per-instance targets + their gatewayVersion). Requires
|
|
176
|
+
* `bridge.read`. Diagnoses the "version gateway inconnue" gating: empty
|
|
177
|
+
* `targets` (or a `gatewayVersion: null` target) is what gates AgentFiles /
|
|
178
|
+
* ChatDefaults off.
|
|
179
|
+
*/
|
|
180
|
+
export declare function getCompat(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
181
|
+
/**
|
|
182
|
+
* GET /api/v1/bridge-status — a CLEAR per-instance bridge<->gateway health view: per
|
|
183
|
+
* instance `bridgeUrlConfigured`, `available`/`degraded` + `reason`, `gatewayVersion` +
|
|
184
|
+
* `gatewayState`/`lastErrorCode`, `agentCount` + discovery freshness. Requires
|
|
185
|
+
* `bridge.read`. The fast "what's wrong with my instances" check — e.g. an instance with
|
|
186
|
+
* `bridgeUrlConfigured:false` is exactly why a sync returns `no_bridge_url`.
|
|
187
|
+
*/
|
|
188
|
+
export declare function bridgeStatus(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
189
|
+
/**
|
|
190
|
+
* GET /api/v1/integrations — Opik/Langfuse integration status: per vendor
|
|
191
|
+
* `configured`/`enabled` + the NON-SECRET effective endpoints + the shipping
|
|
192
|
+
* cursors (lastAt/failureCount/error code). NEVER a key. Requires `traces.read`.
|
|
193
|
+
* The self-correction loop's first step: an agent learns whether enriched
|
|
194
|
+
* observability data is available (and shipping is healthy) before asking for it.
|
|
195
|
+
*/
|
|
196
|
+
export declare function getIntegrations(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
197
|
+
/**
|
|
198
|
+
* GET /api/v1/chat-state — per-message lifecycle of one chat (METADATA ONLY: no
|
|
199
|
+
* text). Requires `traces.read`. Exposes the stuck-streaming signal: a message
|
|
200
|
+
* `status:"streaming"` with a large `ageSeconds` (`stuckStreaming:true`) is a
|
|
201
|
+
* turn whose finalize frame the bridge never relayed. A provenance part also
|
|
202
|
+
* carries a SOC2-safe `structure` (per-item kind + hasFileName/hasScore booleans,
|
|
203
|
+
* counts, allowlisted source/route) for diagnosing the Sources panel content-free.
|
|
204
|
+
*
|
|
205
|
+
* TURN RECONSTRUCTION (content-free): per message, `outbox:{outboxId,status}` is
|
|
206
|
+
* the dispatch JOIN KEY — `chatId:outboxId` is the correlationId of that turn's
|
|
207
|
+
* chat.send / openclaw.dispatch (and openclaw.rehydrate) traces, so list_traces
|
|
208
|
+
* stitches a message to its dispatch chain. NOTE on `outbox:null`: it means EITHER
|
|
209
|
+
* no outbox row (an assistant message — only user turns dispatch) OR a user message
|
|
210
|
+
* older than the per-status read cap; when top-level `outboxTruncated` is true, read
|
|
211
|
+
* null on an OLDER user message as "beyond the cap", NOT as "never dispatched". The
|
|
212
|
+
* most-recent user turns are always covered. Per message, `routedInstanceName` /
|
|
213
|
+
* `routedAgentId` give the per-turn routed agent (null = the chat's primary).
|
|
214
|
+
* Chat-level `routing` (perTurnRouting + lastRouted* + the opaque `routingSegment`)
|
|
215
|
+
* shows whether/where the chat fans turns to specialists. `subAgents` is the
|
|
216
|
+
* content-free delegation summary: `byStatus` counts + capped `failedSample` /
|
|
217
|
+
* `runningSample` (each = childIdShort + status enum + errorCategory enum +
|
|
218
|
+
* hasTaskName bool + ageSeconds — NEVER the task/result/error text or phase).
|
|
219
|
+
*/
|
|
220
|
+
export declare function getChatState(config: Config, args: {
|
|
221
|
+
chatId: string;
|
|
222
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
223
|
+
/**
|
|
224
|
+
* GET /api/v1/compaction-history — the gateway's compaction checkpoints for one
|
|
225
|
+
* chat's session (LAZY: the only caller of the gateway's sessions.compaction.list,
|
|
226
|
+
* never on the turn path). Requires `traces.read`. CONTENT-FREE: each checkpoint =
|
|
227
|
+
* {checkpointId, createdAt, reason, tokensBefore, tokensAfter} — the stored summary
|
|
228
|
+
* (conversation content) never crosses this API. Correlate with the per-turn
|
|
229
|
+
* `chat.gateway_pressure` traces (list_traces kind=chat.gateway_pressure): pressure
|
|
230
|
+
* shows WHEN the session filled up + which turn compacted; this shows what each
|
|
231
|
+
* compaction condensed (e.g. reason "auto-threshold", 19698 -> 1050 tokens).
|
|
232
|
+
*/
|
|
233
|
+
export declare function getCompactionHistory(config: Config, args: {
|
|
234
|
+
chatId: string;
|
|
235
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
236
|
+
/**
|
|
237
|
+
* GET /api/v1/schemas — the published CONTRACT schemas an integration author can
|
|
238
|
+
* conform to (provenance/v1 today; more as the surface grows). Metadata list (id,
|
|
239
|
+
* title, version, category). PUBLIC (no key required). The discovery step before
|
|
240
|
+
* fetching one schema with get_schema.
|
|
241
|
+
*/
|
|
242
|
+
export declare function listSchemas(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
243
|
+
/**
|
|
244
|
+
* GET /api/v1/schemas/:id — one published contract schema's JSON (e.g.
|
|
245
|
+
* "provenance.v1"), to validate a plugin's emitted reports against. PUBLIC (no key
|
|
246
|
+
* required). 404 for an unknown id.
|
|
247
|
+
*/
|
|
248
|
+
export declare function getSchema(config: Config, args: {
|
|
249
|
+
id: string;
|
|
250
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
251
|
+
/**
|
|
252
|
+
* GET /api/v1/trace-enrichment — the SOC2-safe STRUCTURE of a turn's trace (keyed
|
|
253
|
+
* by its correlationId) from the configured Opik/Langfuse: span
|
|
254
|
+
* names/types/lifecycle/timing/parent tree, NEVER input/output/message
|
|
255
|
+
* text/metadata. Requires `traces.read`. The self-correction loop's deep read: an
|
|
256
|
+
* agent sees the REAL OpenClaw message structure behind an anomaly without ever
|
|
257
|
+
* seeing regulated data.
|
|
258
|
+
*/
|
|
259
|
+
export declare function getTraceEnrichment(config: Config, args: GetTraceEnrichmentArgs, options?: ApiFetchOptions): Promise<unknown>;
|
|
260
|
+
/**
|
|
261
|
+
* GET /api/v1/diagnose — ONE actionable assessment of a chat for the
|
|
262
|
+
* self-correction loop: SOC2-safe chat-state + bridge availability, classified
|
|
263
|
+
* (stuck_stream | dispatch_error | attachment_problem | subagent_stuck |
|
|
264
|
+
* subagent_failure | bridge_unavailable | bridge_degraded | healthy) with a
|
|
265
|
+
* `suggestedAction` and, when a safe corrective exists, a `suggestedTool`.
|
|
266
|
+
* `subagent_stuck` (a delegated sub-agent running far too long — a main turn
|
|
267
|
+
* awaiting it can hang) and `subagent_failure` (a recent failed delegation) read
|
|
268
|
+
* the new chat-state `subAgents` summary. Requires `traces.read`. Read-only. Call
|
|
269
|
+
* FIRST on a user report, then act on the suggestion.
|
|
270
|
+
*/
|
|
271
|
+
export declare function diagnoseChat(config: Config, args: {
|
|
272
|
+
chatId: string;
|
|
273
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
274
|
+
/**
|
|
275
|
+
* POST /api/v1/reconcile-chat — the BOUNDED corrective `diagnose` may recommend:
|
|
276
|
+
* flip this chat's stuck 'streaming' message(s) to error (preserving text),
|
|
277
|
+
* releasing the hung UI so the user can retry. Requires `selfheal` (a sensitive
|
|
278
|
+
* write). Audited. Only touches messages already streaming past a short cutoff.
|
|
279
|
+
*/
|
|
280
|
+
export declare function reconcileChat(config: Config, args: {
|
|
281
|
+
chatId: string;
|
|
282
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
283
|
+
/**
|
|
284
|
+
* POST /api/v1/instances/sync — force an instance sync: poke the bridge (resolve creds +
|
|
285
|
+
* connect -> pairing) then pull THAT instance's agents into Atrium NOW, instead of waiting
|
|
286
|
+
* for the discovery cron. Requires `selfheal` (the admin + agent service-account roles).
|
|
287
|
+
* Returns `{ status, agents, detail }` — `status` is the exact outcome (synced | no_agents
|
|
288
|
+
* | no_bridge_url | unreachable | unauthorized | not_served | deploy_misconfigured) and
|
|
289
|
+
* `detail` is a plain-English explanation an agent can act on.
|
|
290
|
+
*/
|
|
291
|
+
export declare function syncInstance(config: Config, args: {
|
|
292
|
+
instance: string;
|
|
293
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
294
|
+
/**
|
|
295
|
+
* POST /api/v1/delivery-record/start — start a delivery-latency recording session
|
|
296
|
+
* (measures the bridge->Convex->frontend streaming pipeline, per delta, content-free).
|
|
297
|
+
* Requires `selfheal` (activation is a privileged write). Returns { sessionId,
|
|
298
|
+
* autoStopAt }; the session auto-stops after ~10 min.
|
|
299
|
+
*/
|
|
300
|
+
export declare function startDeliveryRecord(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
301
|
+
/** POST /api/v1/delivery-record/stop — stop the active recording. Requires `selfheal`. */
|
|
302
|
+
export declare function stopDeliveryRecord(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
303
|
+
/**
|
|
304
|
+
* GET /api/v1/delivery-report — skew-corrected per-segment latency for a recording
|
|
305
|
+
* session: A=bridge->Convex, B=Convex exec, C=Convex->frontend (p50/p95/max + counts;
|
|
306
|
+
* C.count <= A.count by design, since the client only observes coalesced states).
|
|
307
|
+
* Requires `traces.read`. Omit sessionId for the active (or most recent) session.
|
|
308
|
+
*/
|
|
309
|
+
export declare function getDeliveryReport(config: Config, args: {
|
|
310
|
+
sessionId?: string;
|
|
311
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
312
|
+
/**
|
|
313
|
+
* GET /api/v1/delivery-sessions — list recent recording sessions (sessionId,
|
|
314
|
+
* startedAt, stoppedAt, startedBy, active). Requires `traces.read`. Use to pick a
|
|
315
|
+
* sessionId for get_delivery_report or delete_delivery_sessions.
|
|
316
|
+
*/
|
|
317
|
+
export declare function listDeliverySessions(config: Config, options?: ApiFetchOptions): Promise<unknown>;
|
|
318
|
+
/**
|
|
319
|
+
* POST /api/v1/delivery-record/delete — delete recording sessions and their timing
|
|
320
|
+
* rows. Requires `selfheal`. Deleting the active session also stops recording.
|
|
321
|
+
*/
|
|
322
|
+
export declare function deleteDeliverySessions(config: Config, args: {
|
|
323
|
+
sessionIds: string[];
|
|
324
|
+
}, options?: ApiFetchOptions): Promise<unknown>;
|
|
325
|
+
/** GET /api/v1/traces — recent trace events. Requires `traces.read`. */
|
|
326
|
+
export declare function listTraces(config: Config, args?: ListTracesArgs, options?: ApiFetchOptions): Promise<unknown>;
|
|
327
|
+
/** GET /api/v1/kpi — KPI rollups. Requires `kpi.read`. */
|
|
328
|
+
export declare function getKpi(config: Config, args?: GetKpiArgs, options?: ApiFetchOptions): Promise<unknown>;
|
|
329
|
+
/**
|
|
330
|
+
* POST /api/v1/openclaw/query — query OpenClaw via the bridge.
|
|
331
|
+
* Requires `openclaw.query`. Sends `{ question, payload }` (the only keys the
|
|
332
|
+
* server route reads; it 400s when both are undefined).
|
|
333
|
+
*/
|
|
334
|
+
export declare function queryOpenClaw(config: Config, args?: QueryOpenClawArgs, options?: ApiFetchOptions): Promise<unknown>;
|
|
335
|
+
/** GET /api/v1/anomalies — detected anomalies. Requires `anomalies.read`. */
|
|
336
|
+
export declare function listAnomalies(config: Config, args?: ListAnomaliesArgs, options?: ApiFetchOptions): Promise<unknown>;
|
|
337
|
+
/**
|
|
338
|
+
* POST /api/v1/anomalies — report an anomaly. Requires
|
|
339
|
+
* `anomalies.report`. Sends `evidence` (the server's field name), not `details`.
|
|
340
|
+
*/
|
|
341
|
+
export declare function reportAnomaly(config: Config, args: ReportAnomalyArgs, options?: ApiFetchOptions): Promise<unknown>;
|