@revealui/ai 0.7.0 → 0.8.1
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 +25 -12
- package/dist/client/hooks/useAgentStream.d.ts.map +1 -1
- package/dist/client/hooks/useAgentStream.js +1 -29
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/inference/context-assembly.d.ts.map +1 -1
- package/dist/inference/context-assembly.js +1 -3
- package/dist/inference/overflow-compressor.d.ts.map +1 -1
- package/dist/inference/overflow-compressor.js +1 -3
- package/dist/ingestion/pipeline.d.ts.map +1 -1
- package/dist/ingestion/pipeline.js +1 -3
- package/dist/ingestion/text-splitter.d.ts.map +1 -1
- package/dist/ingestion/text-splitter.js +1 -3
- package/dist/internal/token-estimate.d.ts +6 -0
- package/dist/internal/token-estimate.d.ts.map +1 -0
- package/dist/internal/token-estimate.js +7 -0
- package/dist/llm/client.d.ts +6 -4
- package/dist/llm/client.d.ts.map +1 -1
- package/dist/llm/client.js +25 -5
- package/dist/llm/local-ai-profile.d.ts +39 -0
- package/dist/llm/local-ai-profile.d.ts.map +1 -0
- package/dist/llm/local-ai-profile.js +165 -0
- package/dist/llm/providers/inference-snaps.d.ts +24 -13
- package/dist/llm/providers/inference-snaps.d.ts.map +1 -1
- package/dist/llm/providers/inference-snaps.js +21 -17
- package/dist/llm/providers/us-origin-snaps.d.ts +79 -0
- package/dist/llm/providers/us-origin-snaps.d.ts.map +1 -0
- package/dist/llm/providers/us-origin-snaps.js +108 -0
- package/dist/llm/providers/xai.d.ts +29 -0
- package/dist/llm/providers/xai.d.ts.map +1 -0
- package/dist/llm/providers/xai.js +44 -0
- package/dist/observability/export.d.ts +78 -0
- package/dist/observability/export.d.ts.map +1 -0
- package/dist/observability/export.js +229 -0
- package/dist/observability/index.d.ts +19 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +16 -0
- package/dist/observability/instrumentation.d.ts +68 -0
- package/dist/observability/instrumentation.d.ts.map +1 -0
- package/dist/observability/instrumentation.js +219 -0
- package/dist/observability/storage.d.ts +39 -0
- package/dist/observability/storage.d.ts.map +1 -0
- package/dist/observability/storage.js +184 -0
- package/dist/orchestration/runtime.d.ts +7 -0
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +9 -2
- package/dist/orchestration/ticket-agent.d.ts +10 -0
- package/dist/orchestration/ticket-agent.d.ts.map +1 -1
- package/dist/orchestration/ticket-agent.js +7 -1
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +4 -0
- package/dist/skills/integration/agent-skill-provider.d.ts +0 -5
- package/dist/skills/integration/agent-skill-provider.d.ts.map +1 -1
- package/dist/skills/integration/agent-skill-provider.js +3 -9
- package/dist/tools/admin/factory.d.ts +6 -0
- package/dist/tools/admin/factory.d.ts.map +1 -1
- package/dist/tools/admin/factory.js +3 -2
- package/dist/tools/coding/index.d.ts +6 -0
- package/dist/tools/coding/index.d.ts.map +1 -1
- package/dist/tools/coding/index.js +7 -2
- package/dist/tools/governance.d.ts +37 -0
- package/dist/tools/governance.d.ts.map +1 -0
- package/dist/tools/governance.js +42 -0
- package/dist/tools/integrity-audit.d.ts +27 -0
- package/dist/tools/integrity-audit.d.ts.map +1 -0
- package/dist/tools/integrity-audit.js +64 -0
- package/dist/tools/mcp-adapter.d.ts +23 -3
- package/dist/tools/mcp-adapter.d.ts.map +1 -1
- package/dist/tools/mcp-adapter.js +189 -132
- package/dist/tools/mcp-sampling.d.ts +3 -3
- package/dist/tools/mcp-sampling.js +3 -3
- package/dist/tools/web/duck-duck-go.d.ts.map +1 -1
- package/dist/tools/web/duck-duck-go.js +1 -4
- package/dist/tools/web/exa.d.ts.map +1 -1
- package/dist/tools/web/exa.js +1 -4
- package/dist/tools/web/tavily.d.ts.map +1 -1
- package/dist/tools/web/tavily.js +1 -4
- package/package.json +69 -34
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool integrity audit wrapper (GAP-355 Stage 5 S5-4).
|
|
3
|
+
*
|
|
4
|
+
* Same fail-closed contract as `createToolsFromMcpClient({ onToolAudit })`:
|
|
5
|
+
* after a successful tool execution, await the audit hook and rethrow so an
|
|
6
|
+
* unrecorded success cannot complete. On tool failure, prefer the tool error
|
|
7
|
+
* if a secondary audit write fails.
|
|
8
|
+
*
|
|
9
|
+
* Used for admin CMS + coding tools that are not MCP server tools.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Wrap a tool so each `execute` emits an integrity audit event.
|
|
13
|
+
* Returns a new tool object; does not mutate the input.
|
|
14
|
+
*/
|
|
15
|
+
export function wrapToolWithIntegrityAudit(tool, onToolAudit) {
|
|
16
|
+
return {
|
|
17
|
+
...tool,
|
|
18
|
+
async execute(params) {
|
|
19
|
+
const started = Date.now();
|
|
20
|
+
let result;
|
|
21
|
+
try {
|
|
22
|
+
result = await tool.execute(params);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const errorText = error instanceof Error ? error.message : String(error);
|
|
26
|
+
try {
|
|
27
|
+
await onToolAudit({
|
|
28
|
+
toolName: tool.name,
|
|
29
|
+
success: false,
|
|
30
|
+
duration_ms: Date.now() - started,
|
|
31
|
+
error: errorText,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Prefer the original tool exception over a secondary audit failure.
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
const event = {
|
|
40
|
+
toolName: tool.name,
|
|
41
|
+
success: result.success,
|
|
42
|
+
duration_ms: Date.now() - started,
|
|
43
|
+
...(result.error !== undefined ? { error: result.error } : {}),
|
|
44
|
+
};
|
|
45
|
+
if (result.success) {
|
|
46
|
+
await onToolAudit(event);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
await onToolAudit(event);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Prefer the tool failure over a secondary audit failure.
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Map over a tool list when a handler is provided; otherwise return as-is. */
|
|
60
|
+
export function maybeWrapToolsWithIntegrityAudit(tools, onToolAudit) {
|
|
61
|
+
if (!onToolAudit)
|
|
62
|
+
return tools;
|
|
63
|
+
return tools.map((tool) => wrapToolWithIntegrityAudit(tool, onToolAudit));
|
|
64
|
+
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* `McpClientLike` / `MCPToolSource` with whichever client they construct.
|
|
22
22
|
*/
|
|
23
23
|
import type { Tool } from './base.js';
|
|
24
|
-
import { type McpEventSink } from './mcp-events.js';
|
|
24
|
+
import { type McpEventSink, type McpToolCallEvent } from './mcp-events.js';
|
|
25
25
|
export interface MCPTool {
|
|
26
26
|
name: string;
|
|
27
27
|
description: string;
|
|
@@ -176,6 +176,14 @@ export interface CreateToolsFromMcpClientOptions {
|
|
|
176
176
|
* Safe to pass a throwing sink — adapter swallows sink errors.
|
|
177
177
|
*/
|
|
178
178
|
onEvent?: McpEventSink;
|
|
179
|
+
/**
|
|
180
|
+
* Integrity audit hook (GAP-355 Stage 5). Fires once per server tool **and**
|
|
181
|
+
* resource/prompt meta-tool call with the `mcp.tool.call` summary shape
|
|
182
|
+
* (`toolName` is the bare primitive name, e.g. `read_resource`). Unlike
|
|
183
|
+
* `onEvent`, this is **awaited** and **rethrows** so a failed audit write
|
|
184
|
+
* fails the tool execution (fail-closed).
|
|
185
|
+
*/
|
|
186
|
+
onToolAudit?: (event: McpToolCallEvent) => void | Promise<void>;
|
|
179
187
|
}
|
|
180
188
|
/** Spec-shaped `Progress` notification subset. */
|
|
181
189
|
export interface McpProgressLike {
|
|
@@ -236,6 +244,15 @@ export declare function registerMCPTools(mcpClient: MCPClient, registry: {
|
|
|
236
244
|
* - Circular references → replaced with "[Circular]"
|
|
237
245
|
*/
|
|
238
246
|
export declare function serializeMCPResult(value: unknown): unknown;
|
|
247
|
+
/** Options for the legacy hypervisor discovery path (GAP-355 integrity). */
|
|
248
|
+
export interface DiscoverMCPToolsOptions {
|
|
249
|
+
/**
|
|
250
|
+
* Integrity audit hook (awaited, fail-closed on success). Same contract as
|
|
251
|
+
* `createToolsFromMcpClient({ onToolAudit })`. `namespace` on the event is
|
|
252
|
+
* the MCP server name from the hypervisor source.
|
|
253
|
+
*/
|
|
254
|
+
onToolAudit?: (event: McpToolCallEvent) => void | Promise<void>;
|
|
255
|
+
}
|
|
239
256
|
/**
|
|
240
257
|
* Discover all tools from a running MCPHypervisor (or any MCPToolSource)
|
|
241
258
|
* and return them as RevealUI Tool instances.
|
|
@@ -243,15 +260,18 @@ export declare function serializeMCPResult(value: unknown): unknown;
|
|
|
243
260
|
* Tool names use the hypervisor's namespacing (@@mcp_{server}_{tool}) so
|
|
244
261
|
* collisions across servers are impossible.
|
|
245
262
|
*
|
|
263
|
+
* @deprecated Prefer `createToolsFromMcpClient` (Stage 5.1a). Kept for
|
|
264
|
+
* AgentRuntime `mcpToolSource` compatibility.
|
|
265
|
+
*
|
|
246
266
|
* @example
|
|
247
267
|
* ```typescript
|
|
248
268
|
* import { MCPHypervisor } from '@revealui/mcp'
|
|
249
269
|
* import { discoverMCPTools } from '@revealui/ai'
|
|
250
270
|
*
|
|
251
271
|
* const hypervisor = MCPHypervisor.getInstance()
|
|
252
|
-
* const tools = discoverMCPTools(hypervisor)
|
|
272
|
+
* const tools = discoverMCPTools(hypervisor, { onToolAudit })
|
|
253
273
|
* agent.tools.push(...tools)
|
|
254
274
|
* ```
|
|
255
275
|
*/
|
|
256
|
-
export declare function discoverMCPTools(source: MCPToolSource): Tool[];
|
|
276
|
+
export declare function discoverMCPTools(source: MCPToolSource, options?: DiscoverMCPToolsOptions): Tool[];
|
|
257
277
|
//# sourceMappingURL=mcp-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-adapter.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,WAAW,CAAC;AAClD,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-adapter.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,WAAW,CAAC;AAClD,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEzF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,IAAI,KAAK,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpF,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CA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E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI,EAAE,CAgEjG"}
|
|
@@ -60,6 +60,7 @@ export async function createToolsFromMcpClient(client, options) {
|
|
|
60
60
|
...(options.onProgress !== undefined ? { onProgress: options.onProgress } : {}),
|
|
61
61
|
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
62
62
|
...(options.onEvent !== undefined ? { onEvent: options.onEvent } : {}),
|
|
63
|
+
...(options.onToolAudit !== undefined ? { onToolAudit: options.onToolAudit } : {}),
|
|
63
64
|
};
|
|
64
65
|
const tools = [];
|
|
65
66
|
// --- Server tools (Stage 5.1a) -----------------------------------------
|
|
@@ -81,6 +82,36 @@ export async function createToolsFromMcpClient(client, options) {
|
|
|
81
82
|
}
|
|
82
83
|
return tools;
|
|
83
84
|
}
|
|
85
|
+
/** Await integrity audit; rethrow so unrecorded tool success cannot complete. */
|
|
86
|
+
async function awaitToolAudit(ctx, event) {
|
|
87
|
+
if (!ctx.onToolAudit)
|
|
88
|
+
return;
|
|
89
|
+
await ctx.onToolAudit(event);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Build an integrity event and await it. Success path rethrows audit failures;
|
|
93
|
+
* failure path prefers the original tool/meta-tool error.
|
|
94
|
+
*/
|
|
95
|
+
async function finishToolIntegrity(ctx, toolName, started, success, error) {
|
|
96
|
+
const event = {
|
|
97
|
+
kind: 'mcp.tool.call',
|
|
98
|
+
namespace: ctx.namespace,
|
|
99
|
+
toolName,
|
|
100
|
+
duration_ms: Date.now() - started,
|
|
101
|
+
success,
|
|
102
|
+
...(error !== undefined ? { error } : {}),
|
|
103
|
+
};
|
|
104
|
+
if (success) {
|
|
105
|
+
await awaitToolAudit(ctx, event);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await awaitToolAudit(ctx, event);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// Prefer the tool / meta-tool failure over a secondary audit failure.
|
|
113
|
+
}
|
|
114
|
+
}
|
|
84
115
|
/**
|
|
85
116
|
* Build the request-options object passed to `client.callTool()` /
|
|
86
117
|
* `readResource()` / etc. Wraps the ctx's `onProgress` with the
|
|
@@ -107,42 +138,43 @@ function buildServerTool(client, descriptor, ctx) {
|
|
|
107
138
|
async execute(params) {
|
|
108
139
|
const validated = zodSchema.parse(params);
|
|
109
140
|
const started = Date.now();
|
|
141
|
+
let toolSucceeded = false;
|
|
142
|
+
let errorText;
|
|
143
|
+
let payload;
|
|
110
144
|
try {
|
|
111
145
|
const result = await client.callTool(descriptor.name, validated, buildRequestOptions(ctx, descriptor.name));
|
|
112
146
|
if (result.isError) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
duration_ms: Date.now() - started,
|
|
119
|
-
success: false,
|
|
120
|
-
error: errorText,
|
|
121
|
-
});
|
|
122
|
-
return { success: false, error: errorText };
|
|
147
|
+
errorText = extractErrorText(result);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
toolSucceeded = true;
|
|
151
|
+
payload = result.structuredContent ?? result.content;
|
|
123
152
|
}
|
|
124
|
-
emitMcpEvent(ctx.onEvent, {
|
|
125
|
-
kind: 'mcp.tool.call',
|
|
126
|
-
namespace: ctx.namespace,
|
|
127
|
-
toolName: descriptor.name,
|
|
128
|
-
duration_ms: Date.now() - started,
|
|
129
|
-
success: true,
|
|
130
|
-
});
|
|
131
|
-
const payload = result.structuredContent ?? result.content;
|
|
132
|
-
return { success: true, data: serializeMCPResult(payload) };
|
|
133
153
|
}
|
|
134
154
|
catch (error) {
|
|
135
|
-
|
|
136
|
-
emitMcpEvent(ctx.onEvent, {
|
|
137
|
-
kind: 'mcp.tool.call',
|
|
138
|
-
namespace: ctx.namespace,
|
|
139
|
-
toolName: descriptor.name,
|
|
140
|
-
duration_ms: Date.now() - started,
|
|
141
|
-
success: false,
|
|
142
|
-
error: message,
|
|
143
|
-
});
|
|
144
|
-
return { success: false, error: message };
|
|
155
|
+
errorText = error instanceof Error ? error.message : String(error);
|
|
145
156
|
}
|
|
157
|
+
const event = {
|
|
158
|
+
kind: 'mcp.tool.call',
|
|
159
|
+
namespace: ctx.namespace,
|
|
160
|
+
toolName: descriptor.name,
|
|
161
|
+
duration_ms: Date.now() - started,
|
|
162
|
+
success: toolSucceeded,
|
|
163
|
+
...(errorText !== undefined ? { error: errorText } : {}),
|
|
164
|
+
};
|
|
165
|
+
emitMcpEvent(ctx.onEvent, event);
|
|
166
|
+
if (toolSucceeded) {
|
|
167
|
+
// Integrity: unrecorded success must not complete as success.
|
|
168
|
+
await awaitToolAudit(ctx, event);
|
|
169
|
+
return { success: true, data: serializeMCPResult(payload) };
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
await awaitToolAudit(ctx, event);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
// Prefer the tool failure over a secondary audit failure.
|
|
176
|
+
}
|
|
177
|
+
return { success: false, error: errorText ?? 'Tool failed' };
|
|
146
178
|
},
|
|
147
179
|
getMetadata() {
|
|
148
180
|
return { category: ctx.category, version: '1.0.0', mcpNamespace: ctx.namespace };
|
|
@@ -157,28 +189,29 @@ function buildListResourcesTool(client, ctx) {
|
|
|
157
189
|
parameters: z.object({}),
|
|
158
190
|
async execute() {
|
|
159
191
|
const started = Date.now();
|
|
192
|
+
let ok = false;
|
|
193
|
+
let errorText;
|
|
194
|
+
let resources = [];
|
|
160
195
|
try {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
namespace: ctx.namespace,
|
|
165
|
-
duration_ms: Date.now() - started,
|
|
166
|
-
success: true,
|
|
167
|
-
resourceCount: resources.length,
|
|
168
|
-
});
|
|
169
|
-
return { success: true, data: serializeMCPResult(resources) };
|
|
196
|
+
resources =
|
|
197
|
+
(await client.listResources?.(buildRequestOptions(ctx, 'list_resources'))) ?? [];
|
|
198
|
+
ok = true;
|
|
170
199
|
}
|
|
171
200
|
catch (error) {
|
|
172
|
-
|
|
173
|
-
emitMcpEvent(ctx.onEvent, {
|
|
174
|
-
kind: 'mcp.resource.list',
|
|
175
|
-
namespace: ctx.namespace,
|
|
176
|
-
duration_ms: Date.now() - started,
|
|
177
|
-
success: false,
|
|
178
|
-
error: message,
|
|
179
|
-
});
|
|
180
|
-
return { success: false, error: message };
|
|
201
|
+
errorText = error instanceof Error ? error.message : String(error);
|
|
181
202
|
}
|
|
203
|
+
emitMcpEvent(ctx.onEvent, {
|
|
204
|
+
kind: 'mcp.resource.list',
|
|
205
|
+
namespace: ctx.namespace,
|
|
206
|
+
duration_ms: Date.now() - started,
|
|
207
|
+
success: ok,
|
|
208
|
+
...(ok ? { resourceCount: resources.length } : {}),
|
|
209
|
+
...(errorText !== undefined ? { error: errorText } : {}),
|
|
210
|
+
});
|
|
211
|
+
await finishToolIntegrity(ctx, 'list_resources', started, ok, errorText);
|
|
212
|
+
if (ok)
|
|
213
|
+
return { success: true, data: serializeMCPResult(resources) };
|
|
214
|
+
return { success: false, error: errorText ?? 'list_resources failed' };
|
|
182
215
|
},
|
|
183
216
|
getMetadata() {
|
|
184
217
|
return {
|
|
@@ -202,34 +235,34 @@ function buildReadResourceTool(client, ctx) {
|
|
|
202
235
|
async execute(params) {
|
|
203
236
|
const { uri } = paramsSchema.parse(params);
|
|
204
237
|
const started = Date.now();
|
|
238
|
+
let ok = false;
|
|
239
|
+
let errorText;
|
|
240
|
+
let contents = [];
|
|
205
241
|
try {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
namespace: ctx.namespace,
|
|
210
|
-
uri,
|
|
211
|
-
duration_ms: Date.now() - started,
|
|
212
|
-
success: true,
|
|
213
|
-
});
|
|
214
|
-
const joinedText = flattenResourceText(contents);
|
|
215
|
-
const base = {
|
|
216
|
-
success: true,
|
|
217
|
-
data: serializeMCPResult(contents),
|
|
218
|
-
};
|
|
219
|
-
return joinedText !== undefined ? { ...base, content: joinedText } : base;
|
|
242
|
+
contents =
|
|
243
|
+
(await client.readResource?.(uri, buildRequestOptions(ctx, 'read_resource'))) ?? [];
|
|
244
|
+
ok = true;
|
|
220
245
|
}
|
|
221
246
|
catch (error) {
|
|
222
|
-
|
|
223
|
-
emitMcpEvent(ctx.onEvent, {
|
|
224
|
-
kind: 'mcp.resource.read',
|
|
225
|
-
namespace: ctx.namespace,
|
|
226
|
-
uri,
|
|
227
|
-
duration_ms: Date.now() - started,
|
|
228
|
-
success: false,
|
|
229
|
-
error: message,
|
|
230
|
-
});
|
|
231
|
-
return { success: false, error: message };
|
|
247
|
+
errorText = error instanceof Error ? error.message : String(error);
|
|
232
248
|
}
|
|
249
|
+
emitMcpEvent(ctx.onEvent, {
|
|
250
|
+
kind: 'mcp.resource.read',
|
|
251
|
+
namespace: ctx.namespace,
|
|
252
|
+
uri,
|
|
253
|
+
duration_ms: Date.now() - started,
|
|
254
|
+
success: ok,
|
|
255
|
+
...(errorText !== undefined ? { error: errorText } : {}),
|
|
256
|
+
});
|
|
257
|
+
await finishToolIntegrity(ctx, 'read_resource', started, ok, errorText);
|
|
258
|
+
if (!ok)
|
|
259
|
+
return { success: false, error: errorText ?? 'read_resource failed' };
|
|
260
|
+
const joinedText = flattenResourceText(contents);
|
|
261
|
+
const base = {
|
|
262
|
+
success: true,
|
|
263
|
+
data: serializeMCPResult(contents),
|
|
264
|
+
};
|
|
265
|
+
return joinedText !== undefined ? { ...base, content: joinedText } : base;
|
|
233
266
|
},
|
|
234
267
|
getMetadata() {
|
|
235
268
|
return {
|
|
@@ -249,28 +282,28 @@ function buildListPromptsTool(client, ctx) {
|
|
|
249
282
|
parameters: z.object({}),
|
|
250
283
|
async execute() {
|
|
251
284
|
const started = Date.now();
|
|
285
|
+
let ok = false;
|
|
286
|
+
let errorText;
|
|
287
|
+
let prompts = [];
|
|
252
288
|
try {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
kind: 'mcp.prompt.list',
|
|
256
|
-
namespace: ctx.namespace,
|
|
257
|
-
duration_ms: Date.now() - started,
|
|
258
|
-
success: true,
|
|
259
|
-
promptCount: prompts.length,
|
|
260
|
-
});
|
|
261
|
-
return { success: true, data: serializeMCPResult(prompts) };
|
|
289
|
+
prompts = (await client.listPrompts?.(buildRequestOptions(ctx, 'list_prompts'))) ?? [];
|
|
290
|
+
ok = true;
|
|
262
291
|
}
|
|
263
292
|
catch (error) {
|
|
264
|
-
|
|
265
|
-
emitMcpEvent(ctx.onEvent, {
|
|
266
|
-
kind: 'mcp.prompt.list',
|
|
267
|
-
namespace: ctx.namespace,
|
|
268
|
-
duration_ms: Date.now() - started,
|
|
269
|
-
success: false,
|
|
270
|
-
error: message,
|
|
271
|
-
});
|
|
272
|
-
return { success: false, error: message };
|
|
293
|
+
errorText = error instanceof Error ? error.message : String(error);
|
|
273
294
|
}
|
|
295
|
+
emitMcpEvent(ctx.onEvent, {
|
|
296
|
+
kind: 'mcp.prompt.list',
|
|
297
|
+
namespace: ctx.namespace,
|
|
298
|
+
duration_ms: Date.now() - started,
|
|
299
|
+
success: ok,
|
|
300
|
+
...(ok ? { promptCount: prompts.length } : {}),
|
|
301
|
+
...(errorText !== undefined ? { error: errorText } : {}),
|
|
302
|
+
});
|
|
303
|
+
await finishToolIntegrity(ctx, 'list_prompts', started, ok, errorText);
|
|
304
|
+
if (ok)
|
|
305
|
+
return { success: true, data: serializeMCPResult(prompts) };
|
|
306
|
+
return { success: false, error: errorText ?? 'list_prompts failed' };
|
|
274
307
|
},
|
|
275
308
|
getMetadata() {
|
|
276
309
|
return {
|
|
@@ -298,46 +331,39 @@ function buildGetPromptTool(client, ctx) {
|
|
|
298
331
|
async execute(params) {
|
|
299
332
|
const { name, args } = paramsSchema.parse(params);
|
|
300
333
|
const started = Date.now();
|
|
334
|
+
let ok = false;
|
|
335
|
+
let errorText;
|
|
336
|
+
let result;
|
|
301
337
|
try {
|
|
302
|
-
|
|
338
|
+
result = await client.getPrompt?.(name, args, buildRequestOptions(ctx, 'get_prompt'));
|
|
303
339
|
if (!result) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
promptName: name,
|
|
309
|
-
duration_ms: Date.now() - started,
|
|
310
|
-
success: false,
|
|
311
|
-
error: msg,
|
|
312
|
-
});
|
|
313
|
-
return { success: false, error: msg };
|
|
340
|
+
errorText = 'client does not implement getPrompt';
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
ok = true;
|
|
314
344
|
}
|
|
315
|
-
emitMcpEvent(ctx.onEvent, {
|
|
316
|
-
kind: 'mcp.prompt.get',
|
|
317
|
-
namespace: ctx.namespace,
|
|
318
|
-
promptName: name,
|
|
319
|
-
duration_ms: Date.now() - started,
|
|
320
|
-
success: true,
|
|
321
|
-
});
|
|
322
|
-
const joinedText = flattenPromptMessages(result.messages);
|
|
323
|
-
const base = {
|
|
324
|
-
success: true,
|
|
325
|
-
data: serializeMCPResult(result),
|
|
326
|
-
};
|
|
327
|
-
return joinedText !== undefined ? { ...base, content: joinedText } : base;
|
|
328
345
|
}
|
|
329
346
|
catch (error) {
|
|
330
|
-
|
|
331
|
-
emitMcpEvent(ctx.onEvent, {
|
|
332
|
-
kind: 'mcp.prompt.get',
|
|
333
|
-
namespace: ctx.namespace,
|
|
334
|
-
promptName: name,
|
|
335
|
-
duration_ms: Date.now() - started,
|
|
336
|
-
success: false,
|
|
337
|
-
error: message,
|
|
338
|
-
});
|
|
339
|
-
return { success: false, error: message };
|
|
347
|
+
errorText = error instanceof Error ? error.message : String(error);
|
|
340
348
|
}
|
|
349
|
+
emitMcpEvent(ctx.onEvent, {
|
|
350
|
+
kind: 'mcp.prompt.get',
|
|
351
|
+
namespace: ctx.namespace,
|
|
352
|
+
promptName: name,
|
|
353
|
+
duration_ms: Date.now() - started,
|
|
354
|
+
success: ok,
|
|
355
|
+
...(errorText !== undefined ? { error: errorText } : {}),
|
|
356
|
+
});
|
|
357
|
+
await finishToolIntegrity(ctx, 'get_prompt', started, ok, errorText);
|
|
358
|
+
if (!(ok && result)) {
|
|
359
|
+
return { success: false, error: errorText ?? 'get_prompt failed' };
|
|
360
|
+
}
|
|
361
|
+
const joinedText = flattenPromptMessages(result.messages);
|
|
362
|
+
const base = {
|
|
363
|
+
success: true,
|
|
364
|
+
data: serializeMCPResult(result),
|
|
365
|
+
};
|
|
366
|
+
return joinedText !== undefined ? { ...base, content: joinedText } : base;
|
|
341
367
|
},
|
|
342
368
|
getMetadata() {
|
|
343
369
|
return {
|
|
@@ -476,17 +502,20 @@ export function serializeMCPResult(value) {
|
|
|
476
502
|
* Tool names use the hypervisor's namespacing (@@mcp_{server}_{tool}) so
|
|
477
503
|
* collisions across servers are impossible.
|
|
478
504
|
*
|
|
505
|
+
* @deprecated Prefer `createToolsFromMcpClient` (Stage 5.1a). Kept for
|
|
506
|
+
* AgentRuntime `mcpToolSource` compatibility.
|
|
507
|
+
*
|
|
479
508
|
* @example
|
|
480
509
|
* ```typescript
|
|
481
510
|
* import { MCPHypervisor } from '@revealui/mcp'
|
|
482
511
|
* import { discoverMCPTools } from '@revealui/ai'
|
|
483
512
|
*
|
|
484
513
|
* const hypervisor = MCPHypervisor.getInstance()
|
|
485
|
-
* const tools = discoverMCPTools(hypervisor)
|
|
514
|
+
* const tools = discoverMCPTools(hypervisor, { onToolAudit })
|
|
486
515
|
* agent.tools.push(...tools)
|
|
487
516
|
* ```
|
|
488
517
|
*/
|
|
489
|
-
export function discoverMCPTools(source) {
|
|
518
|
+
export function discoverMCPTools(source, options) {
|
|
490
519
|
return source.getAllTools().map(({ namespacedName, serverName, tool }) => {
|
|
491
520
|
const zodSchema = jsonSchemaToZod(tool.inputSchema);
|
|
492
521
|
const agentTool = {
|
|
@@ -496,19 +525,47 @@ export function discoverMCPTools(source) {
|
|
|
496
525
|
async execute(params) {
|
|
497
526
|
// Validate params against the schema
|
|
498
527
|
const validated = zodSchema.parse(params);
|
|
528
|
+
const started = Date.now();
|
|
529
|
+
let toolSucceeded = false;
|
|
530
|
+
let payload;
|
|
531
|
+
let errorText;
|
|
499
532
|
try {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
success: true,
|
|
503
|
-
data: serializeMCPResult(callResult),
|
|
504
|
-
};
|
|
533
|
+
payload = await source.callTool(serverName, tool.name, validated);
|
|
534
|
+
toolSucceeded = true;
|
|
505
535
|
}
|
|
506
536
|
catch (error) {
|
|
537
|
+
errorText = error instanceof Error ? error.message : String(error);
|
|
538
|
+
}
|
|
539
|
+
const event = {
|
|
540
|
+
kind: 'mcp.tool.call',
|
|
541
|
+
namespace: serverName,
|
|
542
|
+
toolName: tool.name,
|
|
543
|
+
duration_ms: Date.now() - started,
|
|
544
|
+
success: toolSucceeded,
|
|
545
|
+
...(errorText !== undefined ? { error: errorText } : {}),
|
|
546
|
+
};
|
|
547
|
+
if (toolSucceeded) {
|
|
548
|
+
// Integrity outside the RPC try so audit throws fail closed.
|
|
549
|
+
if (options?.onToolAudit) {
|
|
550
|
+
await options.onToolAudit(event);
|
|
551
|
+
}
|
|
507
552
|
return {
|
|
508
|
-
success:
|
|
509
|
-
|
|
553
|
+
success: true,
|
|
554
|
+
data: serializeMCPResult(payload),
|
|
510
555
|
};
|
|
511
556
|
}
|
|
557
|
+
if (options?.onToolAudit) {
|
|
558
|
+
try {
|
|
559
|
+
await options.onToolAudit(event);
|
|
560
|
+
}
|
|
561
|
+
catch {
|
|
562
|
+
// Prefer the tool failure over a secondary audit failure.
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return {
|
|
566
|
+
success: false,
|
|
567
|
+
error: errorText ?? 'Tool failed',
|
|
568
|
+
};
|
|
512
569
|
},
|
|
513
570
|
getMetadata() {
|
|
514
571
|
return { category: 'mcp', version: '1.0.0' };
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* const llm = new InferenceSnapsProvider({
|
|
23
23
|
* baseURL: 'http://localhost:9090/v1',
|
|
24
|
-
* model: '
|
|
24
|
+
* model: 'nemotron-3-nano',
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* const client = new McpClient({
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
* transport: { kind: 'streamable-http', url: 'https://example.com/mcp' },
|
|
30
30
|
* samplingHandler: createSamplingHandler({
|
|
31
31
|
* llm,
|
|
32
|
-
* defaultModel: '
|
|
33
|
-
* allowedModels: ['
|
|
32
|
+
* defaultModel: 'nemotron-3-nano',
|
|
33
|
+
* allowedModels: ['nemotron-3-nano', 'gemma4', 'gemma3'],
|
|
34
34
|
* }),
|
|
35
35
|
* });
|
|
36
36
|
* await client.connect();
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* const llm = new InferenceSnapsProvider({
|
|
23
23
|
* baseURL: 'http://localhost:9090/v1',
|
|
24
|
-
* model: '
|
|
24
|
+
* model: 'nemotron-3-nano',
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* const client = new McpClient({
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
* transport: { kind: 'streamable-http', url: 'https://example.com/mcp' },
|
|
30
30
|
* samplingHandler: createSamplingHandler({
|
|
31
31
|
* llm,
|
|
32
|
-
* defaultModel: '
|
|
33
|
-
* allowedModels: ['
|
|
32
|
+
* defaultModel: 'nemotron-3-nano',
|
|
33
|
+
* allowedModels: ['nemotron-3-nano', 'gemma4', 'gemma3'],
|
|
34
34
|
* }),
|
|
35
35
|
* });
|
|
36
36
|
* await client.connect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duck-duck-go.d.ts","sourceRoot":"","sources":["../../../src/tools/web/duck-duck-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"duck-duck-go.d.ts","sourceRoot":"","sources":["../../../src/tools/web/duck-duck-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAC;AAqBxF;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,iBAAiB;IAC1D,QAAQ,CAAC,IAAI,gBAAgB;IAEvB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAwD5E;AAiBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CA8CrE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAE,IA+C3B,CAAC"}
|
|
@@ -8,11 +8,8 @@
|
|
|
8
8
|
* WebSearchProvider interface used by future Tavily/Exa backends (P4-3).
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod/v4';
|
|
11
|
+
import { estimateTokens } from '../../internal/token-estimate.js';
|
|
11
12
|
const DDG_API_URL = 'https://api.duckduckgo.com/';
|
|
12
|
-
/** Approximate token count for a string (4 chars ≈ 1 token). */
|
|
13
|
-
function estimateTokens(text) {
|
|
14
|
-
return Math.ceil(text.length / 4);
|
|
15
|
-
}
|
|
16
13
|
// =============================================================================
|
|
17
14
|
// Provider
|
|
18
15
|
// =============================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exa.d.ts","sourceRoot":"","sources":["../../../src/tools/web/exa.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"exa.d.ts","sourceRoot":"","sources":["../../../src/tools/web/exa.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAC;AAiBxF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAY,YAAW,iBAAiB;IACnD,QAAQ,CAAC,IAAI,SAAS;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,EAAE,MAAM;IAKpB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA+C5E"}
|
package/dist/tools/web/exa.js
CHANGED
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://docs.exa.ai/reference/search
|
|
9
9
|
*/
|
|
10
|
+
import { estimateTokens } from '../../internal/token-estimate.js';
|
|
10
11
|
const EXA_API_URL = 'https://api.exa.ai/search';
|
|
11
|
-
/** Approximate token count for a string (4 chars ≈ 1 token). */
|
|
12
|
-
function estimateTokens(text) {
|
|
13
|
-
return Math.ceil(text.length / 4);
|
|
14
|
-
}
|
|
15
12
|
/**
|
|
16
13
|
* Exa neural search provider - BYOK, requires `EXA_API_KEY`.
|
|
17
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tavily.d.ts","sourceRoot":"","sources":["../../../src/tools/web/tavily.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"tavily.d.ts","sourceRoot":"","sources":["../../../src/tools/web/tavily.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAC;AAiBxF;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,YAAW,iBAAiB;IACtD,QAAQ,CAAC,IAAI,YAAY;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,EAAE,MAAM;IAKpB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA0C5E"}
|
package/dist/tools/web/tavily.js
CHANGED
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://docs.tavily.com/docs/tavily-api/rest_api
|
|
9
9
|
*/
|
|
10
|
+
import { estimateTokens } from '../../internal/token-estimate.js';
|
|
10
11
|
const TAVILY_API_URL = 'https://api.tavily.com/search';
|
|
11
|
-
/** Approximate token count for a string (4 chars ≈ 1 token). */
|
|
12
|
-
function estimateTokens(text) {
|
|
13
|
-
return Math.ceil(text.length / 4);
|
|
14
|
-
}
|
|
15
12
|
/**
|
|
16
13
|
* Tavily search provider - BYOK, requires `TAVILY_API_KEY`.
|
|
17
14
|
*
|