@revealui/ai 0.10.1 → 1.0.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.
Files changed (58) hide show
  1. package/README.md +10 -10
  2. package/dist/client/hooks/useAgentStream.d.ts +2 -0
  3. package/dist/client/hooks/useAgentStream.d.ts.map +1 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -0
  7. package/dist/llm/artifact-provenance.d.ts +73 -0
  8. package/dist/llm/artifact-provenance.d.ts.map +1 -0
  9. package/dist/llm/artifact-provenance.js +189 -0
  10. package/dist/llm/cache-utils.d.ts +0 -9
  11. package/dist/llm/cache-utils.d.ts.map +1 -1
  12. package/dist/llm/cache-utils.js +0 -17
  13. package/dist/llm/client.d.ts +16 -9
  14. package/dist/llm/client.d.ts.map +1 -1
  15. package/dist/llm/client.js +113 -61
  16. package/dist/llm/inference-route.d.ts +46 -0
  17. package/dist/llm/inference-route.d.ts.map +1 -0
  18. package/dist/llm/inference-route.js +154 -0
  19. package/dist/llm/local-ai-profile.d.ts.map +1 -1
  20. package/dist/llm/local-ai-profile.js +3 -3
  21. package/dist/llm/providers/groq.d.ts +1 -1
  22. package/dist/llm/providers/groq.d.ts.map +1 -1
  23. package/dist/llm/providers/groq.js +6 -3
  24. package/dist/llm/providers/inference-snaps.d.ts +6 -5
  25. package/dist/llm/providers/inference-snaps.d.ts.map +1 -1
  26. package/dist/llm/providers/inference-snaps.js +6 -5
  27. package/dist/llm/providers/ollama.d.ts +1 -1
  28. package/dist/llm/providers/ollama.d.ts.map +1 -1
  29. package/dist/llm/providers/ollama.js +3 -2
  30. package/dist/llm/providers/us-origin-snaps.d.ts +21 -11
  31. package/dist/llm/providers/us-origin-snaps.d.ts.map +1 -1
  32. package/dist/llm/providers/us-origin-snaps.js +23 -13
  33. package/dist/llm/resolve.d.ts.map +1 -1
  34. package/dist/llm/resolve.js +9 -2
  35. package/dist/llm/token-counter.d.ts.map +1 -1
  36. package/dist/llm/token-counter.js +4 -1
  37. package/dist/llm/tool-json-schema.d.ts +16 -0
  38. package/dist/llm/tool-json-schema.d.ts.map +1 -0
  39. package/dist/llm/tool-json-schema.js +64 -0
  40. package/dist/llm/workspace-provider-config.d.ts.map +1 -1
  41. package/dist/llm/workspace-provider-config.js +9 -2
  42. package/dist/orchestration/runtime.d.ts +3 -17
  43. package/dist/orchestration/runtime.d.ts.map +1 -1
  44. package/dist/orchestration/runtime.js +4 -15
  45. package/dist/orchestration/streaming-runtime.d.ts.map +1 -1
  46. package/dist/orchestration/streaming-runtime.js +2 -2
  47. package/dist/tools/admin/factory.d.ts +6 -0
  48. package/dist/tools/admin/factory.d.ts.map +1 -1
  49. package/dist/tools/admin/factory.js +6 -1
  50. package/dist/tools/admin/user-tools.js +2 -2
  51. package/dist/tools/mcp-adapter.d.ts +10 -94
  52. package/dist/tools/mcp-adapter.d.ts.map +1 -1
  53. package/dist/tools/mcp-adapter.js +10 -146
  54. package/dist/tools/mcp-sampling.d.ts +3 -3
  55. package/dist/tools/mcp-sampling.js +3 -3
  56. package/dist/tools/registry.d.ts.map +1 -1
  57. package/dist/tools/registry.js +2 -1
  58. package/package.json +29 -4
@@ -1,65 +1,22 @@
1
1
  /**
2
2
  * MCP Tool Adapter
3
3
  *
4
- * Bridges MCP (Model Context Protocol) servers to the tool system.
4
+ * Bridges MCP (Model Context Protocol) servers to the agent tool system.
5
5
  *
6
- * Two paths:
6
+ * Consumers construct an `McpClient` from `@revealui/mcp/client` against stdio
7
+ * or Streamable HTTP, and pass it to `createToolsFromMcpClient()` (or to
8
+ * `AgentRuntime` via `mcpClients`). That is the only agent-side mount: tools,
9
+ * resources, prompts, sampling, elicitation.
7
10
  *
8
- * 1. **Standard MCP client** (Stage 5.1a, preferred) consumers construct an
9
- * `McpClient` from `@revealui/mcp/client` against stdio or Streamable HTTP,
10
- * and pass it to `createToolsFromMcpClient()` (or to `AgentRuntime` via
11
- * `mcpClients`). This is the full-protocol path: future stages will extend
12
- * this to resources, prompts, sampling, elicitation, etc.
11
+ * Structurally typed `@revealui/ai` has no runtime dependency on
12
+ * `@revealui/mcp`. Consumers satisfy `McpClientLike`.
13
13
  *
14
- * 2. **Hypervisor** (legacy, pre-5.1a) consumers pass an `MCPHypervisor` (or
15
- * any `MCPToolSource`) to `discoverMCPTools()`. Kept for backwards compat;
16
- * deprecated in favor of path (1). The hypervisor still owns server-side
17
- * subprocess + tenant-scoping concerns and isn't going away.
18
- *
19
- * Both paths are deliberately **structurally typed** — `@revealui/ai` has no
20
- * runtime dependency on `@revealui/mcp`. Consumers satisfy the shapes
21
- * `McpClientLike` / `MCPToolSource` with whichever client they construct.
14
+ * Process-local MCP server spawn and tenant scoping live on `MCPHypervisor`
15
+ * in `@revealui/mcp`. That is not an agent tool adapter: connect those
16
+ * processes with a real `McpClient` and call `createToolsFromMcpClient`.
22
17
  */
23
18
  import type { Tool } from './base.js';
24
19
  import { type McpEventSink, type McpToolCallEvent } from './mcp-events.js';
25
- export declare function warnHypervisorMcpPathDeprecated(site: string): void;
26
- /** Test-only: reset the one-time deprecation warn latch. */
27
- export declare function resetHypervisorMcpPathWarningForTests(): void;
28
- export interface MCPTool {
29
- name: string;
30
- description: string;
31
- inputSchema: {
32
- type: 'object';
33
- properties: Record<string, unknown>;
34
- required?: string[];
35
- };
36
- }
37
- export interface MCPClient {
38
- listTools(): Promise<MCPTool[]>;
39
- callTool(name: string, args: unknown): Promise<unknown>;
40
- }
41
- /**
42
- * Interface for an MCP tool source (e.g. MCPHypervisor from @revealui/mcp).
43
- * Using an interface here keeps @revealui/ai decoupled from @revealui/mcp.
44
- *
45
- * @deprecated Prefer `McpClientLike` + `createToolsFromMcpClient()` (Stage 5.1a).
46
- * The hypervisor path doesn't expose the full MCP protocol surface (resources,
47
- * prompts, sampling, elicitation). The typed-client path does.
48
- *
49
- * **Removal owner:** product AI runtime (agent-stream already uses `mcpClients`).
50
- * **REMOVE-BY:** `@revealui/ai` 1.0.0 — delete `MCPToolSource`, `discoverMCPTools`,
51
- * and `AgentRuntime` `mcpToolSource` once no external kit still calls them
52
- * (grep product + published examples in the same PR). Until then this path is
53
- * retained for external SDK compatibility only.
54
- */
55
- export interface MCPToolSource {
56
- getAllTools(): Array<{
57
- namespacedName: string;
58
- serverName: string;
59
- tool: MCPTool;
60
- }>;
61
- callTool(serverName: string, toolName: string, args: unknown): Promise<unknown>;
62
- }
63
20
  /**
64
21
  * Structural shape of an `McpClient` from `@revealui/mcp/client`. Declared
65
22
  * here (rather than imported) to keep `@revealui/ai` decoupled from
@@ -237,51 +194,10 @@ export interface McpProgressEvent {
237
194
  * ```
238
195
  */
239
196
  export declare function createToolsFromMcpClient(client: McpClientLike, options: CreateToolsFromMcpClientOptions): Promise<Tool[]>;
240
- /**
241
- * Create a Tool from an MCP tool definition
242
- */
243
- export declare function createToolFromMCP(mcpTool: MCPTool, mcpClient: MCPClient): Tool;
244
- /**
245
- * Register all MCP tools in the registry
246
- */
247
- export declare function registerMCPTools(mcpClient: MCPClient, registry: {
248
- register(tool: Tool): void;
249
- }): Promise<void>;
250
197
  /**
251
198
  * Serialize an MCP tool result safely:
252
199
  * - bigint values → string (JSON.stringify fails on bigint)
253
200
  * - Circular references → replaced with "[Circular]"
254
201
  */
255
202
  export declare function serializeMCPResult(value: unknown): unknown;
256
- /** Options for the legacy hypervisor discovery path (GAP-355 integrity). */
257
- export interface DiscoverMCPToolsOptions {
258
- /**
259
- * Integrity audit hook (awaited, fail-closed on success). Same contract as
260
- * `createToolsFromMcpClient({ onToolAudit })`. `namespace` on the event is
261
- * the MCP server name from the hypervisor source.
262
- */
263
- onToolAudit?: (event: McpToolCallEvent) => void | Promise<void>;
264
- }
265
- /**
266
- * Discover all tools from a running MCPHypervisor (or any MCPToolSource)
267
- * and return them as RevealUI Tool instances.
268
- *
269
- * Tool names use the hypervisor's namespacing (@@mcp_{server}_{tool}) so
270
- * collisions across servers are impossible.
271
- *
272
- * @deprecated Prefer `createToolsFromMcpClient` (Stage 5.1a). Kept for
273
- * AgentRuntime `mcpToolSource` compatibility.
274
- * **REMOVE-BY:** `@revealui/ai` 1.0.0 (same train as `MCPToolSource`).
275
- *
276
- * @example
277
- * ```typescript
278
- * import { MCPHypervisor } from '@revealui/mcp'
279
- * import { discoverMCPTools } from '@revealui/ai'
280
- *
281
- * const hypervisor = MCPHypervisor.getInstance()
282
- * const tools = discoverMCPTools(hypervisor, { onToolAudit })
283
- * agent.tools.push(...tools)
284
- * ```
285
- */
286
- export declare function discoverMCPTools(source: MCPToolSource, options?: DiscoverMCPToolsOptions): Tool[];
287
203
  //# 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,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKzF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CASlE;AAED,4DAA4D;AAC5D,wBAAgB,qCAAqC,IAAI,IAAI,CAE5D;AAED,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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;;;;;;;;;;;;GAuBG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,IAAI,EAAE,CAAC,CA2CjB;AAqZD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAa1D"}
@@ -1,40 +1,22 @@
1
1
  /**
2
2
  * MCP Tool Adapter
3
3
  *
4
- * Bridges MCP (Model Context Protocol) servers to the tool system.
4
+ * Bridges MCP (Model Context Protocol) servers to the agent tool system.
5
5
  *
6
- * Two paths:
6
+ * Consumers construct an `McpClient` from `@revealui/mcp/client` against stdio
7
+ * or Streamable HTTP, and pass it to `createToolsFromMcpClient()` (or to
8
+ * `AgentRuntime` via `mcpClients`). That is the only agent-side mount: tools,
9
+ * resources, prompts, sampling, elicitation.
7
10
  *
8
- * 1. **Standard MCP client** (Stage 5.1a, preferred) consumers construct an
9
- * `McpClient` from `@revealui/mcp/client` against stdio or Streamable HTTP,
10
- * and pass it to `createToolsFromMcpClient()` (or to `AgentRuntime` via
11
- * `mcpClients`). This is the full-protocol path: future stages will extend
12
- * this to resources, prompts, sampling, elicitation, etc.
11
+ * Structurally typed `@revealui/ai` has no runtime dependency on
12
+ * `@revealui/mcp`. Consumers satisfy `McpClientLike`.
13
13
  *
14
- * 2. **Hypervisor** (legacy, pre-5.1a) consumers pass an `MCPHypervisor` (or
15
- * any `MCPToolSource`) to `discoverMCPTools()`. Kept for backwards compat;
16
- * deprecated in favor of path (1). The hypervisor still owns server-side
17
- * subprocess + tenant-scoping concerns and isn't going away.
18
- *
19
- * Both paths are deliberately **structurally typed** — `@revealui/ai` has no
20
- * runtime dependency on `@revealui/mcp`. Consumers satisfy the shapes
21
- * `McpClientLike` / `MCPToolSource` with whichever client they construct.
14
+ * Process-local MCP server spawn and tenant scoping live on `MCPHypervisor`
15
+ * in `@revealui/mcp`. That is not an agent tool adapter: connect those
16
+ * processes with a real `McpClient` and call `createToolsFromMcpClient`.
22
17
  */
23
18
  import { z } from 'zod/v4';
24
19
  import { emitMcpEvent } from './mcp-events.js';
25
- /** One-time process warning for the hypervisor MCP tool path (REMOVE-BY ai@1.0.0). */
26
- let hypervisorPathWarned = false;
27
- export function warnHypervisorMcpPathDeprecated(site) {
28
- if (hypervisorPathWarned)
29
- return;
30
- hypervisorPathWarned = true;
31
- process.emitWarning(`@revealui/ai: ${site} is deprecated. Prefer mcpClients / createToolsFromMcpClient (Stage 5.1a). ` +
32
- 'REMOVE-BY: @revealui/ai 1.0.0. See packages/ai/src/tools/mcp-adapter.ts.', 'DeprecationWarning', 'REVEALUI_AI_MCP_HYPERVISOR_DEPRECATED');
33
- }
34
- /** Test-only: reset the one-time deprecation warn latch. */
35
- export function resetHypervisorMcpPathWarningForTests() {
36
- hypervisorPathWarned = false;
37
- }
38
20
  /**
39
21
  * Connect the agent's tool registry to a standard MCP client. Lists tools
40
22
  * from the MCP server and returns agent-side `Tool` instances that dispatch
@@ -452,43 +434,6 @@ function extractErrorText(result) {
452
434
  }
453
435
  return texts.length > 0 ? texts.join('\n') : 'Tool reported error (no detail)';
454
436
  }
455
- /**
456
- * Create a Tool from an MCP tool definition
457
- */
458
- export function createToolFromMCP(mcpTool, mcpClient) {
459
- // Convert JSON Schema to Zod schema (simplified)
460
- const zodSchema = jsonSchemaToZod(mcpTool.inputSchema);
461
- return {
462
- name: mcpTool.name,
463
- description: mcpTool.description,
464
- parameters: zodSchema,
465
- execute: async (params) => {
466
- try {
467
- const result = await mcpClient.callTool(mcpTool.name, params);
468
- return {
469
- success: true,
470
- data: result,
471
- };
472
- }
473
- catch (error) {
474
- return {
475
- success: false,
476
- error: error instanceof Error ? error.message : String(error),
477
- };
478
- }
479
- },
480
- };
481
- }
482
- /**
483
- * Register all MCP tools in the registry
484
- */
485
- export async function registerMCPTools(mcpClient, registry) {
486
- const tools = await mcpClient.listTools();
487
- for (const mcpTool of tools) {
488
- const tool = createToolFromMCP(mcpTool, mcpClient);
489
- registry.register(tool);
490
- }
491
- }
492
437
  /**
493
438
  * Serialize an MCP tool result safely:
494
439
  * - bigint values → string (JSON.stringify fails on bigint)
@@ -508,87 +453,6 @@ export function serializeMCPResult(value) {
508
453
  }
509
454
  return JSON.parse(JSON.stringify(value, replacer));
510
455
  }
511
- /**
512
- * Discover all tools from a running MCPHypervisor (or any MCPToolSource)
513
- * and return them as RevealUI Tool instances.
514
- *
515
- * Tool names use the hypervisor's namespacing (@@mcp_{server}_{tool}) so
516
- * collisions across servers are impossible.
517
- *
518
- * @deprecated Prefer `createToolsFromMcpClient` (Stage 5.1a). Kept for
519
- * AgentRuntime `mcpToolSource` compatibility.
520
- * **REMOVE-BY:** `@revealui/ai` 1.0.0 (same train as `MCPToolSource`).
521
- *
522
- * @example
523
- * ```typescript
524
- * import { MCPHypervisor } from '@revealui/mcp'
525
- * import { discoverMCPTools } from '@revealui/ai'
526
- *
527
- * const hypervisor = MCPHypervisor.getInstance()
528
- * const tools = discoverMCPTools(hypervisor, { onToolAudit })
529
- * agent.tools.push(...tools)
530
- * ```
531
- */
532
- export function discoverMCPTools(source, options) {
533
- warnHypervisorMcpPathDeprecated('discoverMCPTools() / MCPToolSource');
534
- return source.getAllTools().map(({ namespacedName, serverName, tool }) => {
535
- const zodSchema = jsonSchemaToZod(tool.inputSchema);
536
- const agentTool = {
537
- name: namespacedName,
538
- description: tool.description,
539
- parameters: zodSchema,
540
- async execute(params) {
541
- // Validate params against the schema
542
- const validated = zodSchema.parse(params);
543
- const started = Date.now();
544
- let toolSucceeded = false;
545
- let payload;
546
- let errorText;
547
- try {
548
- payload = await source.callTool(serverName, tool.name, validated);
549
- toolSucceeded = true;
550
- }
551
- catch (error) {
552
- errorText = error instanceof Error ? error.message : String(error);
553
- }
554
- const event = {
555
- kind: 'mcp.tool.call',
556
- namespace: serverName,
557
- toolName: tool.name,
558
- duration_ms: Date.now() - started,
559
- success: toolSucceeded,
560
- ...(errorText !== undefined ? { error: errorText } : {}),
561
- };
562
- if (toolSucceeded) {
563
- // Integrity outside the RPC try so audit throws fail closed.
564
- if (options?.onToolAudit) {
565
- await options.onToolAudit(event);
566
- }
567
- return {
568
- success: true,
569
- data: serializeMCPResult(payload),
570
- };
571
- }
572
- if (options?.onToolAudit) {
573
- try {
574
- await options.onToolAudit(event);
575
- }
576
- catch {
577
- // Prefer the tool failure over a secondary audit failure.
578
- }
579
- }
580
- return {
581
- success: false,
582
- error: errorText ?? 'Tool failed',
583
- };
584
- },
585
- getMetadata() {
586
- return { category: 'mcp', version: '1.0.0' };
587
- },
588
- };
589
- return agentTool;
590
- });
591
- }
592
456
  /**
593
457
  * Narrow an untyped `inputSchema` from a spec `Tool` into the shape
594
458
  * `jsonSchemaToZod` understands, then delegate. Falls back to a permissive
@@ -21,7 +21,7 @@
21
21
  *
22
22
  * const llm = new InferenceSnapsProvider({
23
23
  * baseURL: 'http://localhost:9090/v1',
24
- * model: 'nemotron-3-nano',
24
+ * model: 'gemma3',
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: 'nemotron-3-nano',
33
- * allowedModels: ['nemotron-3-nano', 'gemma4', 'gemma3'],
32
+ * defaultModel: 'gemma3',
33
+ * allowedModels: ['gemma3', 'gemma4', 'nemotron-3-nano'],
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: 'nemotron-3-nano',
24
+ * model: 'gemma3',
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: 'nemotron-3-nano',
33
- * allowedModels: ['nemotron-3-nano', 'gemma4', 'gemma3'],
32
+ * defaultModel: 'gemma3',
33
+ * allowedModels: ['gemma3', 'gemma4', 'nemotron-3-nano'],
34
34
  * }),
35
35
  * });
36
36
  * await client.connect();
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAgC;IAE7C,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAO1B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAInC,MAAM,IAAI,IAAI,EAAE;IAIhB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,kBAAkB,IAAI,cAAc,EAAE;IAWhC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAgBlE;AAED,eAAO,MAAM,kBAAkB,cAAqB,CAAC"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAgC;IAE7C,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAO1B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAInC,MAAM,IAAI,IAAI,EAAE;IAIhB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,kBAAkB,IAAI,cAAc,EAAE;IAWhC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAgBlE;AAED,eAAO,MAAM,kBAAkB,cAAqB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { toolParametersToJsonSchema } from '../llm/tool-json-schema.js';
1
2
  export class ToolRegistry {
2
3
  tools = new Map();
3
4
  register(tool) {
@@ -24,7 +25,7 @@ export class ToolRegistry {
24
25
  function: {
25
26
  name: tool.name,
26
27
  description: tool.description,
27
- parameters: tool.parameters.toJSONSchema(), // Native Zod v4 method
28
+ parameters: toolParametersToJsonSchema(tool.parameters),
28
29
  },
29
30
  }));
30
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revealui/ai",
3
- "version": "0.10.1",
3
+ "version": "1.0.0",
4
4
  "description": "AI runtime for agent-driven products — agents, memory, LLM providers (Inference Snaps, Ollama, OpenAI-compatible), tools, and orchestration. Anthropic-SDK-free.",
5
5
  "keywords": [
6
6
  "agent",
@@ -25,8 +25,8 @@
25
25
  "dependencies": {
26
26
  "lru-cache": "^11.5.1",
27
27
  "zod": "^4.4.3",
28
- "@revealui/contracts": "0.8.2",
29
- "@revealui/core": "0.13.1",
28
+ "@revealui/contracts": "0.8.3",
29
+ "@revealui/core": "0.14.0",
30
30
  "@revealui/db": "0.10.0",
31
31
  "@revealui/resilience": "0.2.4"
32
32
  },
@@ -37,7 +37,7 @@
37
37
  "jsdom": "29.1.1",
38
38
  "react": "19.2.8",
39
39
  "react-dom": "19.2.8",
40
- "typescript": "^6.0.3",
40
+ "typescript": "6.0.3",
41
41
  "vitest": "^4.1.10",
42
42
  "@revealui/dev": "0.1.0"
43
43
  },
@@ -135,6 +135,31 @@
135
135
  "import": "./dist/llm/providers/base.js",
136
136
  "default": "./dist/llm/providers/base.js"
137
137
  },
138
+ "./llm/providers/groq": {
139
+ "types": "./dist/llm/providers/groq.d.ts",
140
+ "import": "./dist/llm/providers/groq.js",
141
+ "default": "./dist/llm/providers/groq.js"
142
+ },
143
+ "./llm/providers/xai": {
144
+ "types": "./dist/llm/providers/xai.d.ts",
145
+ "import": "./dist/llm/providers/xai.js",
146
+ "default": "./dist/llm/providers/xai.js"
147
+ },
148
+ "./llm/providers/openai": {
149
+ "types": "./dist/llm/providers/openai.d.ts",
150
+ "import": "./dist/llm/providers/openai.js",
151
+ "default": "./dist/llm/providers/openai.js"
152
+ },
153
+ "./llm/providers/anthropic": {
154
+ "types": "./dist/llm/providers/anthropic.d.ts",
155
+ "import": "./dist/llm/providers/anthropic.js",
156
+ "default": "./dist/llm/providers/anthropic.js"
157
+ },
158
+ "./llm/providers/openai-compat": {
159
+ "types": "./dist/llm/providers/openai-compat.d.ts",
160
+ "import": "./dist/llm/providers/openai-compat.js",
161
+ "default": "./dist/llm/providers/openai-compat.js"
162
+ },
138
163
  "./llm/response-cache": {
139
164
  "types": "./dist/llm/response-cache.d.ts",
140
165
  "import": "./dist/llm/response-cache.js",