@revealui/ai 0.2.9 → 0.4.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 (82) hide show
  1. package/README.md +200 -26
  2. package/dist/a2a/handler.d.ts +3 -1
  3. package/dist/a2a/handler.d.ts.map +1 -1
  4. package/dist/a2a/handler.js +24 -7
  5. package/dist/a2a/task-store.d.ts.map +1 -1
  6. package/dist/a2a/task-store.js +5 -1
  7. package/dist/client/hooks/useAgentStream.d.ts +84 -1
  8. package/dist/client/hooks/useAgentStream.d.ts.map +1 -1
  9. package/dist/client/hooks/useAgentStream.js +106 -10
  10. package/dist/index.d.ts +4 -6
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -15
  13. package/dist/ingestion/admin-indexer.js +1 -1
  14. package/dist/ingestion/pipeline.d.ts +1 -1
  15. package/dist/ingestion/pipeline.d.ts.map +1 -1
  16. package/dist/llm/client.d.ts +33 -10
  17. package/dist/llm/client.d.ts.map +1 -1
  18. package/dist/llm/client.js +70 -57
  19. package/dist/llm/key-validator.d.ts.map +1 -1
  20. package/dist/llm/key-validator.js +0 -27
  21. package/dist/llm/providers/inference-snaps.d.ts +7 -5
  22. package/dist/llm/providers/inference-snaps.d.ts.map +1 -1
  23. package/dist/llm/providers/inference-snaps.js +7 -5
  24. package/dist/llm/providers/openai-compat.d.ts +1 -1
  25. package/dist/llm/providers/openai-compat.js +1 -1
  26. package/dist/llm/response-cache.d.ts +1 -2
  27. package/dist/llm/response-cache.d.ts.map +1 -1
  28. package/dist/llm/response-cache.js +1 -2
  29. package/dist/llm/server.d.ts +1 -1
  30. package/dist/llm/server.d.ts.map +1 -1
  31. package/dist/llm/server.js +3 -1
  32. package/dist/memory/crdt/lww-register.js +1 -1
  33. package/dist/memory/preferences/user-preferences-manager.d.ts.map +1 -1
  34. package/dist/memory/preferences/user-preferences-manager.js +1 -1
  35. package/dist/memory/services/index.d.ts +2 -0
  36. package/dist/memory/services/index.d.ts.map +1 -1
  37. package/dist/memory/services/index.js +1 -0
  38. package/dist/memory/services/reconciliation-service.d.ts +64 -0
  39. package/dist/memory/services/reconciliation-service.d.ts.map +1 -0
  40. package/dist/memory/services/reconciliation-service.js +127 -0
  41. package/dist/memory/stores/working-memory.d.ts.map +1 -1
  42. package/dist/memory/stores/working-memory.js +1 -1
  43. package/dist/memory/utils/index.d.ts +1 -2
  44. package/dist/memory/utils/index.d.ts.map +1 -1
  45. package/dist/memory/utils/index.js +1 -2
  46. package/dist/memory/utils/sql-helpers.d.ts +21 -66
  47. package/dist/memory/utils/sql-helpers.d.ts.map +1 -1
  48. package/dist/memory/utils/sql-helpers.js +34 -169
  49. package/dist/memory/vector/vector-memory-service.d.ts.map +1 -1
  50. package/dist/memory/vector/vector-memory-service.js +6 -1
  51. package/dist/orchestration/runtime.d.ts +30 -1
  52. package/dist/orchestration/runtime.d.ts.map +1 -1
  53. package/dist/orchestration/runtime.js +20 -3
  54. package/dist/orchestration/streaming-runtime.d.ts +48 -1
  55. package/dist/orchestration/streaming-runtime.d.ts.map +1 -1
  56. package/dist/orchestration/ticket-agent.d.ts +10 -1
  57. package/dist/orchestration/ticket-agent.d.ts.map +1 -1
  58. package/dist/orchestration/ticket-agent.js +11 -2
  59. package/dist/skills/catalog/vercel-catalog.d.ts.map +1 -1
  60. package/dist/skills/catalog/vercel-catalog.js +13 -7
  61. package/dist/tools/mcp-adapter.d.ts +192 -1
  62. package/dist/tools/mcp-adapter.d.ts.map +1 -1
  63. package/dist/tools/mcp-adapter.js +434 -1
  64. package/dist/tools/mcp-elicitation.d.ts +128 -0
  65. package/dist/tools/mcp-elicitation.d.ts.map +1 -0
  66. package/dist/tools/mcp-elicitation.js +121 -0
  67. package/dist/tools/mcp-events.d.ts +270 -0
  68. package/dist/tools/mcp-events.d.ts.map +1 -0
  69. package/dist/tools/mcp-events.js +165 -0
  70. package/dist/tools/mcp-sampling.d.ts +155 -0
  71. package/dist/tools/mcp-sampling.d.ts.map +1 -0
  72. package/dist/tools/mcp-sampling.js +171 -0
  73. package/dist/tools/ticket-tools.d.ts +35 -2
  74. package/dist/tools/ticket-tools.d.ts.map +1 -1
  75. package/dist/tools/ticket-tools.js +32 -2
  76. package/package.json +38 -12
  77. package/dist/llm/providers/vultr.d.ts +0 -18
  78. package/dist/llm/providers/vultr.d.ts.map +0 -1
  79. package/dist/llm/providers/vultr.js +0 -169
  80. package/dist/memory/utils/deep-clone.d.ts +0 -10
  81. package/dist/memory/utils/deep-clone.d.ts.map +0 -1
  82. package/dist/memory/utils/deep-clone.js +0 -9
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { getRestClient, getVectorClient } from '@revealui/db/client';
16
16
  import { agentMemories } from '@revealui/db/schema';
17
- import { safeVectorInsert } from '@revealui/db/validation';
17
+ import { assertCrossDbRefs, safeVectorInsert } from '@revealui/db/validation';
18
18
  import { and, eq, sql } from 'drizzle-orm';
19
19
  /**
20
20
  * Vector Memory Service for semantic search operations.
@@ -257,6 +257,11 @@ export class VectorMemoryService {
257
257
  if (updates.metadata?.custom?.agentId !== undefined) {
258
258
  updateData.agentId = updates.metadata.custom.agentId || null;
259
259
  }
260
+ // Validate cross-DB references if siteId is changing
261
+ const newSiteId = updateData.siteId;
262
+ if (newSiteId) {
263
+ await assertCrossDbRefs(this.restDb, { siteId: newSiteId });
264
+ }
260
265
  const result = await this.db
261
266
  .update(agentMemories)
262
267
  .set(updateData)
@@ -6,7 +6,7 @@
6
6
  import type { LLMClient } from '../llm/client.js';
7
7
  import type { AgentSkillProvider } from '../skills/integration/agent-skill-provider.js';
8
8
  import type { ApprovalCallback } from '../tools/base.js';
9
- import type { MCPToolSource } from '../tools/mcp-adapter.js';
9
+ import type { MCPToolSource, McpClientLike } from '../tools/mcp-adapter.js';
10
10
  import type { Agent, AgentResult, Task } from './agent.js';
11
11
  /**
12
12
  * Controls how much of the model's token budget is allocated to internal reasoning.
@@ -39,8 +39,37 @@ export interface RuntimeConfig {
39
39
  * Optional MCP Hypervisor (or any MCPToolSource). When provided, tools from
40
40
  * all healthy MCP servers are merged into the agent's tool set before each
41
41
  * task execution. Pass an MCPHypervisor from @revealui/mcp.
42
+ *
43
+ * @deprecated Prefer `mcpClients` (Stage 5.1a). The hypervisor path doesn't
44
+ * expose the full MCP protocol surface (resources, prompts, sampling,
45
+ * elicitation). Standard `McpClient` instances do. This field stays for
46
+ * backwards compatibility and will keep working until a future major.
42
47
  */
43
48
  mcpToolSource?: MCPToolSource;
49
+ /**
50
+ * Optional set of standard MCP clients (Stage 5.1a). When provided, each
51
+ * client's tools are listed and merged into the agent's tool set before
52
+ * each task. Tool names are namespaced as `mcp_<name>__<toolName>` so
53
+ * multiple clients can coexist without collisions. Consumers construct the
54
+ * client (stdio / Streamable HTTP + OAuth) and pre-connect it before
55
+ * passing it here. The runtime does NOT own client lifecycle.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { McpClient } from '@revealui/mcp/client';
60
+ *
61
+ * const contentClient = new McpClient({ ... });
62
+ * await contentClient.connect();
63
+ *
64
+ * const runtime = new AgentRuntime({
65
+ * mcpClients: [{ name: 'content', client: contentClient }],
66
+ * });
67
+ * ```
68
+ */
69
+ mcpClients?: ReadonlyArray<{
70
+ name: string;
71
+ client: McpClientLike;
72
+ }>;
44
73
  /**
45
74
  * Optional skill provider. When set, activated skills are injected into the
46
75
  * system prompt before the first LLM call, giving the agent contextual
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/orchestration/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,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AC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACpE;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,gCAAgC,EAAE,SAAS,CAAC;IAC/D;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,qBAAa,YAAY;IACvB,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAChC,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,cAAc,CAAgD;IACtE,OAAO,CAAC,cAAc,CAAS;gBAEnB,MAAM,GAAE,aAAkB;IA0BtC;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;YAqBzE,OAAO;IAoPrB;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAI7B;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAc9E;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B;;OAEG;IACH,SAAS,IAAI;QACX,cAAc,EAAE,OAAO,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;KACxB;CAOF"}
@@ -7,7 +7,7 @@ import { registerCleanupHandler } from '@revealui/core/monitoring';
7
7
  import { z } from 'zod/v4';
8
8
  import { estimateCost } from '../llm/token-counter.js';
9
9
  import { ToolCallDeduplicator } from '../tools/deduplicator.js';
10
- import { discoverMCPTools } from '../tools/mcp-adapter.js';
10
+ import { createToolsFromMcpClient, discoverMCPTools } from '../tools/mcp-adapter.js';
11
11
  import { createWebSearchTool } from '../tools/web/duck-duck-go.js';
12
12
  const THINKING_BUDGETS = {
13
13
  off: 0,
@@ -30,6 +30,7 @@ export class AgentRuntime {
30
30
  maxRetries: config.maxRetries ?? 3,
31
31
  enableCache: config.enableCache ?? true, // Enable by default for cost savings
32
32
  mcpToolSource: config.mcpToolSource,
33
+ mcpClients: config.mcpClients,
33
34
  skillProvider: config.skillProvider,
34
35
  thinkingLevel: config.thinkingLevel,
35
36
  modelTier: config.modelTier,
@@ -67,8 +68,24 @@ export class AgentRuntime {
67
68
  let iterations = 0;
68
69
  let totalTokens = 0;
69
70
  let totalCostUsd = 0;
70
- // Merge MCP-discovered tools (from healthy servers) into the agent's tool set
71
- const mcpTools = this.config.mcpToolSource ? discoverMCPTools(this.config.mcpToolSource) : [];
71
+ // Merge MCP-discovered tools into the agent's tool set. Two paths:
72
+ // - Standard `McpClient` instances (Stage 5.1a, preferred)
73
+ // - `MCPToolSource` / hypervisor (legacy, deprecated but supported)
74
+ const mcpTools = [];
75
+ if (this.config.mcpToolSource) {
76
+ mcpTools.push(...discoverMCPTools(this.config.mcpToolSource));
77
+ }
78
+ if (this.config.mcpClients && this.config.mcpClients.length > 0) {
79
+ for (const { name, client } of this.config.mcpClients) {
80
+ try {
81
+ const fromClient = await createToolsFromMcpClient(client, { namespace: name });
82
+ mcpTools.push(...fromClient);
83
+ }
84
+ catch {
85
+ // empty-catch-ok: an unhealthy MCP client shouldn't fail the whole task — other clients + base tools still apply
86
+ }
87
+ }
88
+ }
72
89
  // Swap in a custom WebSearchProvider if the agent config specifies one (P4-3)
73
90
  const customProvider = agent.config?.webSearchProvider;
74
91
  let baseTools;
@@ -11,8 +11,32 @@ import type { LLMClient } from '../llm/client.js';
11
11
  import type { ToolResult } from '../tools/base.js';
12
12
  import type { Agent, Task } from './agent.js';
13
13
  import { AgentRuntime, type RuntimeConfig } from './runtime.js';
14
+ /**
15
+ * Chunk types emitted over the agent-stream SSE channel.
16
+ *
17
+ * The generator in `StreamingAgentRuntime.streamTask` emits the core turn
18
+ * events (`text`, `tool_call_start`, `tool_call_result`, `error`, `done`).
19
+ *
20
+ * Side-channel events originate outside the generator — route-level
21
+ * handlers (MCP sampling / elicitation) write them to the SSE stream
22
+ * directly between turns:
23
+ *
24
+ * - `session_info` — emitted once at stream start with the
25
+ * agent-run session id. Clients use the id to POST elicitation
26
+ * responses back via `POST /api/agent-stream/elicit`.
27
+ * - `sampling_request` — fired when a connected MCP server calls
28
+ * `sampling/create`; the handler services the request synchronously
29
+ * and emits this chunk for observability.
30
+ * - `elicitation_request` — fired when a connected MCP server calls
31
+ * `elicitation/create`; the handler pauses waiting for a POST
32
+ * response keyed on `(sessionId, elicitationId)`.
33
+ *
34
+ * A.2b of the post-v1 MCP arc — the side-channel types are defined here
35
+ * so the `useAgentStream` consumer + future UI can narrow on them.
36
+ * A.2b-backend wires the emission; A.2b-frontend renders them.
37
+ */
14
38
  export interface AgentStreamChunk {
15
- type: 'text' | 'tool_call_start' | 'tool_call_result' | 'error' | 'done';
39
+ type: 'text' | 'tool_call_start' | 'tool_call_result' | 'error' | 'done' | 'session_info' | 'sampling_request' | 'elicitation_request';
16
40
  content?: string;
17
41
  toolCall?: {
18
42
  name: string;
@@ -24,6 +48,29 @@ export interface AgentStreamChunk {
24
48
  tokensUsed?: number;
25
49
  executionTime?: number;
26
50
  };
51
+ /**
52
+ * Present on `session_info`, `sampling_request`, `elicitation_request`.
53
+ * Identifies the agent-run session; clients key elicitation POSTs on
54
+ * this.
55
+ */
56
+ sessionId?: string;
57
+ /**
58
+ * Namespace (MCP server id) the side-channel event originated from.
59
+ * Present on `sampling_request` + `elicitation_request`.
60
+ */
61
+ namespace?: string;
62
+ /** Present on `sampling_request` — requested model + shape. */
63
+ sampling?: {
64
+ model: string;
65
+ messageCount: number;
66
+ maxTokens: number;
67
+ };
68
+ /** Present on `elicitation_request` — form payload. */
69
+ elicitation?: {
70
+ elicitationId: string;
71
+ requestedSchema: unknown;
72
+ message?: string;
73
+ };
27
74
  }
28
75
  export declare class StreamingAgentRuntime extends AgentRuntime {
29
76
  constructor(config?: RuntimeConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"streaming-runtime.d.ts","sourceRoot":"","sources":["../../src/orchestration/streaming-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAC;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,qBAAa,qBAAsB,SAAQ,YAAY;gBACzC,MAAM,GAAE,aAAkB;IAItC;;;OAGG;IACI,UAAU,CACf,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,gBAAgB,CAAC;CAsLpC"}
1
+ {"version":3,"file":"streaming-runtime.d.ts","sourceRoot":"","sources":["../../src/orchestration/streaming-runtime.ts"],"names":[],"mappings":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G;IACI,UAAU,CACf,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,gBAAgB,CAAC;CAsLpC"}
@@ -64,7 +64,16 @@ export declare class TicketAgentDispatcher {
64
64
  * - Have access to all admin tools (create/update/delete content, globals, media, users)
65
65
  * - Have access to ticket mutation tools (update status, add comment)
66
66
  * - Run the agentic loop until done or max iterations
67
+ *
68
+ * When `options.dispatchId` is provided, id-generating tool calls
69
+ * (currently `add_ticket_comment`) derive their ids deterministically
70
+ * from (dispatchId, call-ordinal). This makes the dispatch retry-safe:
71
+ * a crash-and-resume re-issues tool calls in the same order and
72
+ * produces the same ids, so the persistence layer's PK constraint
73
+ * dedupes naturally. Pair with the durable work queue's jobId.
67
74
  */
68
- dispatch(ticket: TicketInput): Promise<AgentResult>;
75
+ dispatch(ticket: TicketInput, options?: {
76
+ dispatchId?: string;
77
+ }): Promise<AgentResult>;
69
78
  }
70
79
  //# sourceMappingURL=ticket-agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ticket-agent.d.ts","sourceRoot":"","sources":["../../src/orchestration/ticket-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EAAS,WAAW,EAAQ,MAAM,YAAY,CAAC;AAG3D,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EA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oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EAAS,WAAW,EAAQ,MAAM,YAAY,CAAC;AAG3D,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,0GAA0G;IAC1G,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,SAAS,EAAE,SAAS,CAAC;IAErB,2DAA2D;IAC3D,SAAS,EAAE,cAAc,CAAC;IAE1B,wEAAwE;IACxE,YAAY,EAAE,oBAAoB,CAAC;IAEnC,yEAAyE;IACzE,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC,yCAAyC;IACzC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;IAExB;;;OAGG;IACH,EAAE,CAAC,EAAE,QAAQ,CAAC;IAEd,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAwDD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,YAAY,CAAoB;gBAE5B,MAAM,EAAE,iBAAiB;IAUrC;;;;;;;;;;;;;;;OAeG;IACG,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,WAAW,CAAC;CA0DjG"}
@@ -94,13 +94,22 @@ export class TicketAgentDispatcher {
94
94
  * - Have access to all admin tools (create/update/delete content, globals, media, users)
95
95
  * - Have access to ticket mutation tools (update status, add comment)
96
96
  * - Run the agentic loop until done or max iterations
97
+ *
98
+ * When `options.dispatchId` is provided, id-generating tool calls
99
+ * (currently `add_ticket_comment`) derive their ids deterministically
100
+ * from (dispatchId, call-ordinal). This makes the dispatch retry-safe:
101
+ * a crash-and-resume re-issues tool calls in the same order and
102
+ * produces the same ids, so the persistence layer's PK constraint
103
+ * dedupes naturally. Pair with the durable work queue's jobId.
97
104
  */
98
- async dispatch(ticket) {
105
+ async dispatch(ticket, options = {}) {
99
106
  const { apiClient, ticketClient, collections, globals, memory: sharedMemory, db } = this.config;
100
107
  // Build tool set: admin tools + ticket mutation tools + web scraper + optional summarizer
101
108
  const cmsConfig = { apiClient, collections, globals };
102
109
  const cmsTools = createAdminTools(cmsConfig);
103
- const ticketTools = createTicketTools(ticket.id, ticketClient);
110
+ const ticketTools = createTicketTools(ticket.id, ticketClient, {
111
+ dispatchId: options.dispatchId,
112
+ });
104
113
  const extraTools = db
105
114
  ? [webScraperTool, createDocumentSummarizerTool(db, this.config.llmClient)]
106
115
  : [webScraperTool];
@@ -1 +1 @@
1
- {"version":3,"file":"vercel-catalog.d.ts","sourceRoot":"","sources":["../../../src/skills/catalog/vercel-catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAmB,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAiBD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgC3F;AAkHD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,SAAK,EACV,MAAM,GAAE,aAAkB,GACzB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAO/B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAKzD"}
1
+ {"version":3,"file":"vercel-catalog.d.ts","sourceRoot":"","sources":["../../../src/skills/catalog/vercel-catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAmB,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAiBD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgC3F;AAuHD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,SAAK,EACV,MAAM,GAAE,aAAkB,GACzB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAO/B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAKzD"}
@@ -64,19 +64,25 @@ export async function fetchVercelCatalog(config = {}) {
64
64
  * Load catalog from cache if valid.
65
65
  */
66
66
  function loadFromCache(cachePath, ttl) {
67
- // Read first to avoid TOCTOU between stat and read (file could disappear between calls)
68
- let content;
67
+ let fd;
69
68
  try {
70
- content = fs.readFileSync(cachePath, 'utf-8');
69
+ fd = fs.openSync(cachePath, 'r');
71
70
  }
72
71
  catch {
73
72
  return null;
74
73
  }
75
- const age = Date.now() - fs.statSync(cachePath).mtimeMs;
76
- if (age > ttl) {
77
- return null;
74
+ try {
75
+ const stat = fs.fstatSync(fd);
76
+ const age = Date.now() - stat.mtimeMs;
77
+ if (age > ttl) {
78
+ return null;
79
+ }
80
+ const content = fs.readFileSync(fd, 'utf-8');
81
+ return JSON.parse(content);
82
+ }
83
+ finally {
84
+ fs.closeSync(fd);
78
85
  }
79
- return JSON.parse(content);
80
86
  }
81
87
  /**
82
88
  * Save catalog to cache.
@@ -1,9 +1,27 @@
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 tool system.
5
+ *
6
+ * Two paths:
7
+ *
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.
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.
5
22
  */
6
23
  import type { Tool } from './base.js';
24
+ import { type McpEventSink } from './mcp-events.js';
7
25
  export interface MCPTool {
8
26
  name: string;
9
27
  description: string;
@@ -20,6 +38,10 @@ export interface MCPClient {
20
38
  /**
21
39
  * Interface for an MCP tool source (e.g. MCPHypervisor from @revealui/mcp).
22
40
  * Using an interface here keeps @revealui/ai decoupled from @revealui/mcp.
41
+ *
42
+ * @deprecated Prefer `McpClientLike` + `createToolsFromMcpClient()` (Stage 5.1a).
43
+ * The hypervisor path doesn't expose the full MCP protocol surface (resources,
44
+ * prompts, sampling, elicitation). The typed-client path does.
23
45
  */
24
46
  export interface MCPToolSource {
25
47
  getAllTools(): Array<{
@@ -29,6 +51,175 @@ export interface MCPToolSource {
29
51
  }>;
30
52
  callTool(serverName: string, toolName: string, args: unknown): Promise<unknown>;
31
53
  }
54
+ /**
55
+ * Structural shape of an `McpClient` from `@revealui/mcp/client`. Declared
56
+ * here (rather than imported) to keep `@revealui/ai` decoupled from
57
+ * `@revealui/mcp` at the type level. Consumers pass any object whose
58
+ * `listTools()` + `callTool()` methods match — the real `McpClient`
59
+ * structurally satisfies this shape.
60
+ *
61
+ * Returns / options are loose-typed to the spec-relevant bits; the real
62
+ * `McpClient` returns richer SDK types which we don't need for tool dispatch.
63
+ */
64
+ export interface McpClientLike {
65
+ listTools(options?: unknown): Promise<ReadonlyArray<McpToolDescriptor>>;
66
+ callTool(name: string, args?: Record<string, unknown>, options?: unknown): Promise<McpCallToolResultLike>;
67
+ /**
68
+ * Resources (Stage 5.1b). Optional: when absent on the client, the
69
+ * adapter skips emitting resource meta-tools for the server regardless
70
+ * of `include.resources`.
71
+ */
72
+ listResources?(options?: unknown): Promise<ReadonlyArray<McpResourceDescriptor>>;
73
+ readResource?(uri: string, options?: unknown): Promise<ReadonlyArray<McpResourceContentLike>>;
74
+ /**
75
+ * Prompts (Stage 5.1b). Optional: when absent, prompt meta-tools are
76
+ * skipped for the server.
77
+ */
78
+ listPrompts?(options?: unknown): Promise<ReadonlyArray<McpPromptDescriptor>>;
79
+ getPrompt?(name: string, args?: Record<string, string>, options?: unknown): Promise<McpGetPromptResultLike>;
80
+ }
81
+ /** Subset of the spec `Tool` shape needed for agent-side discovery. */
82
+ export interface McpToolDescriptor {
83
+ name: string;
84
+ description?: string;
85
+ inputSchema: unknown;
86
+ }
87
+ /** Subset of the spec `CallToolResult` shape. */
88
+ export interface McpCallToolResultLike {
89
+ content: ReadonlyArray<unknown>;
90
+ isError?: boolean;
91
+ structuredContent?: unknown;
92
+ }
93
+ /** Subset of the spec `Resource` shape needed for listing. */
94
+ export interface McpResourceDescriptor {
95
+ uri: string;
96
+ name?: string;
97
+ description?: string;
98
+ mimeType?: string;
99
+ }
100
+ /** One element of `readResource`'s response — either a text or a blob content part. */
101
+ export interface McpResourceContentLike {
102
+ uri: string;
103
+ mimeType?: string;
104
+ text?: string;
105
+ blob?: string;
106
+ }
107
+ /** Subset of the spec `Prompt` shape needed for listing. */
108
+ export interface McpPromptDescriptor {
109
+ name: string;
110
+ description?: string;
111
+ arguments?: ReadonlyArray<{
112
+ name: string;
113
+ description?: string;
114
+ required?: boolean;
115
+ }>;
116
+ }
117
+ /** Subset of the spec `GetPromptResult` shape. */
118
+ export interface McpGetPromptResultLike {
119
+ description?: string;
120
+ messages: ReadonlyArray<{
121
+ role: 'user' | 'assistant' | string;
122
+ content: unknown;
123
+ }>;
124
+ }
125
+ export interface CreateToolsFromMcpClientOptions {
126
+ /**
127
+ * Namespace (typically the server's identifier) prepended to each tool
128
+ * name so collisions across multiple MCP clients are impossible.
129
+ * Output tool name: `mcp_<namespace>__<toolName>`.
130
+ */
131
+ namespace: string;
132
+ /**
133
+ * Optional category tag used for tool-level telemetry + UI grouping.
134
+ * Defaults to `'mcp'`.
135
+ */
136
+ category?: string;
137
+ /**
138
+ * Which MCP primitives to expose to the agent as tools (Stage 5.1b).
139
+ *
140
+ * - `tools` (default `true`): wrap every server tool.
141
+ * - `resources` (default `true`): emit two meta-tools per namespace —
142
+ * `mcp_<ns>__list_resources` and `mcp_<ns>__read_resource({ uri })`.
143
+ * Skipped silently when the client doesn't expose `listResources` /
144
+ * `readResource`.
145
+ * - `prompts` (default `true`): emit two meta-tools per namespace —
146
+ * `mcp_<ns>__list_prompts` and `mcp_<ns>__get_prompt({ name, args? })`.
147
+ * Skipped silently when the client doesn't expose `listPrompts` /
148
+ * `getPrompt`.
149
+ */
150
+ include?: {
151
+ tools?: boolean;
152
+ resources?: boolean;
153
+ prompts?: boolean;
154
+ };
155
+ /**
156
+ * Progress observability hook (Stage 5.3). Every server tool call made
157
+ * through the wrapped `Tool.execute()` forwards per-request progress
158
+ * notifications here. Resource + prompt meta-tools don't emit
159
+ * progress (they're single-shot lookups).
160
+ */
161
+ onProgress?: (event: McpProgressEvent) => void;
162
+ /**
163
+ * Optional `AbortSignal` forwarded to every server tool call (Stage
164
+ * 5.3). When the signal aborts, in-flight MCP RPC calls are
165
+ * cancelled via `notifications/cancelled` per the MCP spec. Useful
166
+ * for wiring a consumer-facing cancel button into an active
167
+ * agent run. Resource/prompt meta-tools also receive the signal.
168
+ */
169
+ signal?: AbortSignal;
170
+ /**
171
+ * Protocol-level observability sink (Stage 6.1). Fires exactly once
172
+ * per tool / resource / prompt call with a structured summary
173
+ * (`namespace`, operation, `duration_ms`, `success`, `error?`). See
174
+ * `./mcp-events.ts` for the event shapes and `createCoreLoggerSink()`
175
+ * for the default routing to `@revealui/core/observability/logger`.
176
+ * Safe to pass a throwing sink — adapter swallows sink errors.
177
+ */
178
+ onEvent?: McpEventSink;
179
+ }
180
+ /** Spec-shaped `Progress` notification subset. */
181
+ export interface McpProgressLike {
182
+ /** Monotonically increasing progress token value. */
183
+ progress: number;
184
+ /** Total expected units of work, when the server knows it. */
185
+ total?: number;
186
+ /** Human-readable status message. */
187
+ message?: string;
188
+ }
189
+ /** Event payload forwarded to `onProgress`. */
190
+ export interface McpProgressEvent {
191
+ /** Namespace the tool belongs to (for multi-client agents). */
192
+ namespace: string;
193
+ /** Wrapped tool name that emitted the event (without the `mcp_<ns>__` prefix). */
194
+ toolName: string;
195
+ /** Progress payload as reported by the server. */
196
+ progress: McpProgressLike;
197
+ }
198
+ /**
199
+ * Connect the agent's tool registry to a standard MCP client. Lists tools
200
+ * from the MCP server and returns agent-side `Tool` instances that dispatch
201
+ * calls back through the client. Safe to call multiple times per server —
202
+ * each invocation re-reads the current tool list.
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * import { McpClient } from '@revealui/mcp/client';
207
+ * import { createToolsFromMcpClient } from '@revealui/ai';
208
+ *
209
+ * const client = new McpClient({
210
+ * clientInfo: { name: 'my-agent', version: '1.0.0' },
211
+ * transport: { kind: 'streamable-http', url: 'https://example.com/mcp' },
212
+ * });
213
+ * await client.connect();
214
+ *
215
+ * const tools = await createToolsFromMcpClient(client, {
216
+ * namespace: 'example-server',
217
+ * });
218
+ *
219
+ * agent.tools.push(...tools);
220
+ * ```
221
+ */
222
+ export declare function createToolsFromMcpClient(client: McpClientLike, options: CreateToolsFromMcpClientOptions): Promise<Tool[]>;
32
223
  /**
33
224
  * Create a Tool from an MCP tool definition
34
225
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-adapter.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,WAAW,CAAC;AAElD,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;;;GAGG;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,CAAC,OAAO,CAAC,CAAC;CACjF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO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