@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
@@ -1,169 +0,0 @@
1
- /**
2
- * Vultr Inference Provider
3
- *
4
- * Implements the LLMProvider interface for Vultr Serverless Inference API
5
- */
6
- const authorizationHeader = 'Authorization';
7
- const contentTypeHeader = 'Content-Type';
8
- const asRecord = (v) => typeof v === 'object' && v !== null ? v : undefined;
9
- const isFunctionToolCall = (call) => {
10
- const r = asRecord(call);
11
- if (!r)
12
- return false;
13
- return r.type === 'function' && typeof r.id === 'string';
14
- };
15
- export class VultrProvider {
16
- config;
17
- baseURL;
18
- constructor(config) {
19
- this.config = config;
20
- this.baseURL = config.baseURL || 'https://api.vultrinference.com/v1';
21
- }
22
- async chat(messages, options) {
23
- const body = {
24
- model: this.config.model,
25
- messages: messages.map((m) => ({ role: m.role, content: m.content, name: m.name })),
26
- temperature: options?.temperature ?? this.config.temperature ?? 0.7,
27
- max_tokens: options?.maxTokens ?? this.config.maxTokens,
28
- tools: options?.tools,
29
- };
30
- const res = await fetch(`${this.baseURL}/chat/completions`, {
31
- method: 'POST',
32
- headers: {
33
- [contentTypeHeader]: 'application/json',
34
- [authorizationHeader]: `Bearer ${this.config.apiKey}`,
35
- },
36
- body: JSON.stringify(body),
37
- });
38
- if (!res.ok) {
39
- const json = await res.json().catch(() => undefined);
40
- const rec = asRecord(json);
41
- const err = rec && typeof rec.error === 'string' ? rec.error : res.statusText;
42
- throw new Error(`Vultr API error: ${err}`);
43
- }
44
- const data = (await res.json());
45
- const choice = Array.isArray(data.choices) ? data.choices[0] : undefined;
46
- const choiceRec = asRecord(choice);
47
- const message = asRecord(choiceRec?.message);
48
- // Parse tool calls if present
49
- let toolCalls;
50
- if (message && Array.isArray(message.tool_calls || message.toolCalls)) {
51
- const raw = (message.tool_calls || message.toolCalls);
52
- toolCalls = raw.filter(isFunctionToolCall).map((tc) => {
53
- const r = asRecord(tc) ?? {};
54
- const fn = asRecord(r.function);
55
- return {
56
- id: String(r.id),
57
- type: 'function',
58
- function: {
59
- name: typeof fn?.name === 'string' ? fn?.name : '',
60
- arguments: typeof fn?.arguments === 'string'
61
- ? fn?.arguments
62
- : JSON.stringify(fn?.arguments ?? {}),
63
- },
64
- };
65
- });
66
- }
67
- return {
68
- content: typeof message?.content === 'string' ? message.content : '',
69
- role: 'assistant',
70
- toolCalls,
71
- finishReason: undefined,
72
- };
73
- }
74
- async embed(text, options) {
75
- // Vultr may support embeddings on some models. Try /embeddings endpoint if available.
76
- const inputs = Array.isArray(text) ? text : [text];
77
- const model = options?.model || this.config.model;
78
- const res = await fetch(`${this.baseURL}/embeddings`, {
79
- method: 'POST',
80
- headers: {
81
- [contentTypeHeader]: 'application/json',
82
- [authorizationHeader]: `Bearer ${this.config.apiKey}`,
83
- },
84
- // lgtm[js/file-access-to-http] - embedding providers must send text to their API by design
85
- body: JSON.stringify({ model, input: inputs }),
86
- });
87
- if (!res.ok) {
88
- const json = await res.json().catch(() => undefined);
89
- const rec = asRecord(json);
90
- // If embeddings not supported, throw a clear error
91
- if (res.status === 404 || (rec?.error && typeof rec.error === 'string')) {
92
- throw new Error('Vultr embeddings not available for this configuration');
93
- }
94
- throw new Error(`Vultr embeddings API error: ${res.statusText}`);
95
- }
96
- const data = (await res.json());
97
- const items = Array.isArray(data.data) ? data.data : [];
98
- const embeddings = items.map((it) => {
99
- const rec = asRecord(it);
100
- const vector = Array.isArray(rec?.embedding) ? rec?.embedding : [];
101
- return {
102
- vector,
103
- dimension: vector.length,
104
- model: typeof rec?.model === 'string' ? rec?.model : String(model),
105
- };
106
- });
107
- return Array.isArray(text) ? embeddings : embeddings[0];
108
- }
109
- async *stream(messages, options) {
110
- const body = {
111
- model: this.config.model,
112
- messages: messages.map((m) => ({ role: m.role, content: m.content, name: m.name })),
113
- temperature: options?.temperature ?? this.config.temperature ?? 0.7,
114
- max_tokens: options?.maxTokens ?? this.config.maxTokens,
115
- stream: true,
116
- };
117
- const res = await fetch(`${this.baseURL}/chat/completions`, {
118
- method: 'POST',
119
- headers: {
120
- [contentTypeHeader]: 'application/json',
121
- [authorizationHeader]: `Bearer ${this.config.apiKey}`,
122
- },
123
- body: JSON.stringify(body),
124
- });
125
- if (!res.ok) {
126
- const json = await res.json().catch(() => undefined);
127
- const rec = asRecord(json);
128
- const err = rec && typeof rec.error === 'string' ? rec.error : res.statusText;
129
- throw new Error(`Vultr streaming error: ${err}`);
130
- }
131
- const reader = res.body?.getReader();
132
- const decoder = new TextDecoder();
133
- if (!reader) {
134
- throw new Error('Response body is not readable');
135
- }
136
- let buffer = '';
137
- while (true) {
138
- const { done, value } = await reader.read();
139
- if (done) {
140
- yield { content: '', done: true };
141
- break;
142
- }
143
- buffer += decoder.decode(value, { stream: true });
144
- const lines = buffer.split('\n');
145
- buffer = lines.pop() || '';
146
- for (const line of lines) {
147
- if (line.startsWith('data: ')) {
148
- const data = line.slice(6);
149
- if (data === '[DONE]') {
150
- yield { content: '', done: true };
151
- return;
152
- }
153
- try {
154
- const parsed = JSON.parse(data);
155
- const choice = Array.isArray(parsed.choices) ? parsed.choices[0] : undefined;
156
- // Vultr uses OpenAI-compatible SSE format: delta not message
157
- const delta = asRecord(asRecord(choice)?.delta);
158
- if (delta && typeof delta.content === 'string') {
159
- yield { content: delta.content, done: false };
160
- }
161
- }
162
- catch {
163
- // ignore partial JSON
164
- }
165
- }
166
- }
167
- }
168
- }
169
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Deep Clone Utility
3
- *
4
- * @deprecated This file has been moved to @revealui/core/utils/deep-clone.ts
5
- * Re-exporting from core for backward compatibility during migration.
6
- *
7
- * Import directly from '@revealui/core/utils/deep-clone' instead.
8
- */
9
- export { deepClone } from '@revealui/core/utils/deep-clone';
10
- //# sourceMappingURL=deep-clone.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deep-clone.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/deep-clone.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Deep Clone Utility
3
- *
4
- * @deprecated This file has been moved to @revealui/core/utils/deep-clone.ts
5
- * Re-exporting from core for backward compatibility during migration.
6
- *
7
- * Import directly from '@revealui/core/utils/deep-clone' instead.
8
- */
9
- export { deepClone } from '@revealui/core/utils/deep-clone';