@revealui/ai 0.3.0 → 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.
- package/README.md +200 -26
- package/dist/a2a/handler.d.ts +3 -1
- package/dist/a2a/handler.d.ts.map +1 -1
- package/dist/a2a/handler.js +24 -7
- package/dist/a2a/task-store.d.ts.map +1 -1
- package/dist/a2a/task-store.js +5 -1
- package/dist/client/hooks/useAgentStream.d.ts +84 -1
- package/dist/client/hooks/useAgentStream.d.ts.map +1 -1
- package/dist/client/hooks/useAgentStream.js +106 -10
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -15
- package/dist/llm/client.d.ts +33 -4
- package/dist/llm/client.d.ts.map +1 -1
- package/dist/llm/client.js +70 -21
- package/dist/llm/key-validator.d.ts.map +1 -1
- package/dist/llm/key-validator.js +0 -27
- package/dist/llm/providers/inference-snaps.d.ts +7 -5
- package/dist/llm/providers/inference-snaps.d.ts.map +1 -1
- package/dist/llm/providers/inference-snaps.js +7 -5
- package/dist/llm/providers/openai-compat.d.ts +1 -1
- package/dist/llm/providers/openai-compat.js +1 -1
- package/dist/llm/response-cache.d.ts +1 -2
- package/dist/llm/response-cache.d.ts.map +1 -1
- package/dist/llm/response-cache.js +1 -2
- package/dist/llm/server.d.ts +1 -1
- package/dist/llm/server.d.ts.map +1 -1
- package/dist/llm/server.js +3 -1
- package/dist/memory/services/index.d.ts +2 -0
- package/dist/memory/services/index.d.ts.map +1 -1
- package/dist/memory/services/index.js +1 -0
- package/dist/memory/services/reconciliation-service.d.ts +64 -0
- package/dist/memory/services/reconciliation-service.d.ts.map +1 -0
- package/dist/memory/services/reconciliation-service.js +127 -0
- package/dist/memory/utils/sql-helpers.d.ts +19 -25
- package/dist/memory/utils/sql-helpers.d.ts.map +1 -1
- package/dist/memory/utils/sql-helpers.js +34 -81
- package/dist/memory/vector/vector-memory-service.d.ts.map +1 -1
- package/dist/memory/vector/vector-memory-service.js +6 -1
- package/dist/orchestration/runtime.d.ts +30 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +20 -3
- package/dist/orchestration/streaming-runtime.d.ts +48 -1
- package/dist/orchestration/streaming-runtime.d.ts.map +1 -1
- package/dist/orchestration/ticket-agent.d.ts +10 -1
- package/dist/orchestration/ticket-agent.d.ts.map +1 -1
- package/dist/orchestration/ticket-agent.js +11 -2
- package/dist/tools/mcp-adapter.d.ts +192 -1
- package/dist/tools/mcp-adapter.d.ts.map +1 -1
- package/dist/tools/mcp-adapter.js +434 -1
- package/dist/tools/mcp-elicitation.d.ts +128 -0
- package/dist/tools/mcp-elicitation.d.ts.map +1 -0
- package/dist/tools/mcp-elicitation.js +121 -0
- package/dist/tools/mcp-events.d.ts +270 -0
- package/dist/tools/mcp-events.d.ts.map +1 -0
- package/dist/tools/mcp-events.js +165 -0
- package/dist/tools/mcp-sampling.d.ts +155 -0
- package/dist/tools/mcp-sampling.d.ts.map +1 -0
- package/dist/tools/mcp-sampling.js +171 -0
- package/dist/tools/ticket-tools.d.ts +35 -2
- package/dist/tools/ticket-tools.d.ts.map +1 -1
- package/dist/tools/ticket-tools.js +32 -2
- package/package.json +13 -11
- package/dist/llm/providers/vultr.d.ts +0 -18
- package/dist/llm/providers/vultr.d.ts.map +0 -1
- package/dist/llm/providers/vultr.js +0 -169
- package/dist/memory/utils/deep-clone.d.ts +0 -10
- package/dist/memory/utils/deep-clone.d.ts.map +0 -1
- package/dist/memory/utils/deep-clone.js +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vultr.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/vultr.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,OAAO,EAER,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAgBD,qBAAa,aAAc,YAAW,WAAW;IAC/C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,mBAAmB;IAKjC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IA2DzE,KAAK,CACT,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;IAwC5B,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC;CAkExF"}
|
|
@@ -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';
|