@lanonasis/ai-sdk 0.1.0 → 0.2.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 +166 -12
- package/dist/client.d.ts +79 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +420 -0
- package/dist/client.js.map +1 -0
- package/dist/http/client.d.ts +66 -0
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/client.js +243 -0
- package/dist/http/client.js.map +1 -0
- package/dist/index.d.ts +47 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -17
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +64 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +231 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/types/index.d.ts +257 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +46 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +53 -7
package/dist/client.js
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LanonasisAI - Main SDK Client
|
|
3
|
+
*
|
|
4
|
+
* Drop-in AI SDK that integrates with existing Lanonasis infrastructure:
|
|
5
|
+
* - @lanonasis/memory-sdk for persistent memory and context
|
|
6
|
+
* - vortexai-l0 for local orchestration
|
|
7
|
+
* - Backend API for chat completions
|
|
8
|
+
*/
|
|
9
|
+
import MemoryClient from '@lanonasis/memory-sdk-standalone';
|
|
10
|
+
import { L0Orchestrator } from 'vortexai-l0';
|
|
11
|
+
import { HttpClient } from './http/client.js';
|
|
12
|
+
const DEFAULT_BASE_URL = 'https://api.lanonasis.com';
|
|
13
|
+
const DEFAULT_TIMEOUT = 30000;
|
|
14
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
15
|
+
export class LanonasisAI {
|
|
16
|
+
http;
|
|
17
|
+
localOrchestrator = null;
|
|
18
|
+
eventHandlers = new Map();
|
|
19
|
+
/** Memory client from @lanonasis/memory-sdk */
|
|
20
|
+
memory;
|
|
21
|
+
/** SDK configuration */
|
|
22
|
+
config;
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this.config = {
|
|
25
|
+
apiKey: config.apiKey,
|
|
26
|
+
baseUrl: config.baseUrl || DEFAULT_BASE_URL,
|
|
27
|
+
memoryUrl: config.memoryUrl || config.baseUrl || DEFAULT_BASE_URL,
|
|
28
|
+
timeout: config.timeout || DEFAULT_TIMEOUT,
|
|
29
|
+
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
30
|
+
debug: config.debug || false,
|
|
31
|
+
headers: config.headers || {},
|
|
32
|
+
organizationId: config.organizationId || '',
|
|
33
|
+
useLocalOrchestration: config.useLocalOrchestration || false,
|
|
34
|
+
memory: config.memory,
|
|
35
|
+
};
|
|
36
|
+
// Initialize HTTP client for chat API
|
|
37
|
+
this.http = new HttpClient({
|
|
38
|
+
baseUrl: this.config.baseUrl,
|
|
39
|
+
apiKey: this.config.apiKey,
|
|
40
|
+
timeout: this.config.timeout,
|
|
41
|
+
maxRetries: this.config.maxRetries,
|
|
42
|
+
headers: this.config.headers,
|
|
43
|
+
debug: this.config.debug,
|
|
44
|
+
organizationId: this.config.organizationId,
|
|
45
|
+
});
|
|
46
|
+
// Initialize memory client from @lanonasis/memory-sdk
|
|
47
|
+
const memoryConfig = {
|
|
48
|
+
apiUrl: this.config.memoryUrl,
|
|
49
|
+
apiKey: this.config.apiKey,
|
|
50
|
+
timeout: this.config.timeout,
|
|
51
|
+
};
|
|
52
|
+
this.memory = new MemoryClient(memoryConfig);
|
|
53
|
+
// Initialize local orchestrator if enabled
|
|
54
|
+
if (this.config.useLocalOrchestration) {
|
|
55
|
+
this.localOrchestrator = new L0Orchestrator();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// Event System
|
|
60
|
+
// ============================================================================
|
|
61
|
+
on(event, handler) {
|
|
62
|
+
if (!this.eventHandlers.has(event)) {
|
|
63
|
+
this.eventHandlers.set(event, new Set());
|
|
64
|
+
}
|
|
65
|
+
this.eventHandlers.get(event).add(handler);
|
|
66
|
+
return () => this.off(event, handler);
|
|
67
|
+
}
|
|
68
|
+
off(event, handler) {
|
|
69
|
+
this.eventHandlers.get(event)?.delete(handler);
|
|
70
|
+
}
|
|
71
|
+
emit(type, data) {
|
|
72
|
+
const event = { type, timestamp: Date.now(), data };
|
|
73
|
+
this.eventHandlers.get(type)?.forEach(handler => {
|
|
74
|
+
try {
|
|
75
|
+
handler(event);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.error('Event handler error:', e);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Chat API
|
|
84
|
+
// ============================================================================
|
|
85
|
+
/**
|
|
86
|
+
* Send a chat message with optional memory context
|
|
87
|
+
*/
|
|
88
|
+
async chat(request) {
|
|
89
|
+
this.emit('request:start', { type: 'chat', request });
|
|
90
|
+
try {
|
|
91
|
+
let messages = [...request.messages];
|
|
92
|
+
// Build context from memory if enabled
|
|
93
|
+
if (request.includeMemory !== false && this.config.memory?.enabled !== false) {
|
|
94
|
+
const context = await this.buildMemoryContext(request);
|
|
95
|
+
if (context) {
|
|
96
|
+
messages = this.injectContext(messages, context);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Add system prompt if provided
|
|
100
|
+
if (request.systemPrompt && !messages.some(m => m.role === 'system')) {
|
|
101
|
+
messages.unshift({ role: 'system', content: request.systemPrompt });
|
|
102
|
+
}
|
|
103
|
+
const response = await this.http.post('/v1/chat/completions', {
|
|
104
|
+
messages,
|
|
105
|
+
model: request.model || 'lanonasis-v1',
|
|
106
|
+
temperature: request.temperature,
|
|
107
|
+
max_tokens: request.maxTokens,
|
|
108
|
+
functions: request.functions,
|
|
109
|
+
tools: request.tools,
|
|
110
|
+
stop: request.stop,
|
|
111
|
+
user: request.user,
|
|
112
|
+
stream: false,
|
|
113
|
+
metadata: request.metadata,
|
|
114
|
+
});
|
|
115
|
+
const result = response.data;
|
|
116
|
+
result.conversationId = request.conversationId;
|
|
117
|
+
// Auto-save to memory if enabled
|
|
118
|
+
if (this.config.memory?.autoSave !== false && request.conversationId) {
|
|
119
|
+
await this.saveToMemory(request, result);
|
|
120
|
+
result.memoryUpdated = true;
|
|
121
|
+
}
|
|
122
|
+
this.emit('request:success', { type: 'chat', response: result });
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
this.emit('request:error', { type: 'chat', error });
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Simple message send (convenience method)
|
|
132
|
+
*/
|
|
133
|
+
async send(message, options) {
|
|
134
|
+
const response = await this.chat({
|
|
135
|
+
messages: [{ role: 'user', content: message }],
|
|
136
|
+
...options,
|
|
137
|
+
});
|
|
138
|
+
return response.choices[0]?.message?.content || '';
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Stream chat response
|
|
142
|
+
*/
|
|
143
|
+
async *chatStream(request) {
|
|
144
|
+
this.emit('stream:start', { request });
|
|
145
|
+
let messages = [...request.messages];
|
|
146
|
+
if (request.includeMemory !== false && this.config.memory?.enabled !== false) {
|
|
147
|
+
const context = await this.buildMemoryContext(request);
|
|
148
|
+
if (context) {
|
|
149
|
+
messages = this.injectContext(messages, context);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const stream = this.http.stream({
|
|
153
|
+
method: 'POST',
|
|
154
|
+
path: '/v1/chat/completions',
|
|
155
|
+
body: {
|
|
156
|
+
messages,
|
|
157
|
+
model: request.model || 'lanonasis-v1',
|
|
158
|
+
temperature: request.temperature,
|
|
159
|
+
max_tokens: request.maxTokens,
|
|
160
|
+
stream: true,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
let fullContent = '';
|
|
164
|
+
for await (const chunk of stream) {
|
|
165
|
+
try {
|
|
166
|
+
const parsed = JSON.parse(chunk);
|
|
167
|
+
this.emit('stream:chunk', { chunk: parsed });
|
|
168
|
+
const delta = parsed.choices[0]?.delta?.content;
|
|
169
|
+
if (delta) {
|
|
170
|
+
fullContent += delta;
|
|
171
|
+
}
|
|
172
|
+
yield parsed;
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
// Skip invalid chunks
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Save complete message to memory
|
|
179
|
+
if (fullContent && this.config.memory?.autoSave !== false && request.conversationId) {
|
|
180
|
+
await this.memory.createMemory({
|
|
181
|
+
title: `Conversation ${request.conversationId}`,
|
|
182
|
+
content: fullContent,
|
|
183
|
+
memory_type: 'conversation',
|
|
184
|
+
tags: ['ai-response', 'streaming'],
|
|
185
|
+
metadata: { conversationId: request.conversationId },
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
this.emit('stream:end', { conversationId: request.conversationId });
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Stream with callback (alternative API)
|
|
192
|
+
*/
|
|
193
|
+
async streamChat(request, onChunk) {
|
|
194
|
+
let result = null;
|
|
195
|
+
let fullContent = '';
|
|
196
|
+
for await (const chunk of this.chatStream(request)) {
|
|
197
|
+
onChunk(chunk);
|
|
198
|
+
const delta = chunk.choices[0]?.delta?.content;
|
|
199
|
+
if (delta) {
|
|
200
|
+
fullContent += delta;
|
|
201
|
+
}
|
|
202
|
+
if (chunk.choices[0]?.finishReason) {
|
|
203
|
+
result = {
|
|
204
|
+
id: chunk.id,
|
|
205
|
+
object: 'chat.completion',
|
|
206
|
+
created: chunk.created,
|
|
207
|
+
model: chunk.model,
|
|
208
|
+
choices: [{
|
|
209
|
+
index: 0,
|
|
210
|
+
message: { role: 'assistant', content: fullContent },
|
|
211
|
+
finishReason: chunk.choices[0].finishReason,
|
|
212
|
+
}],
|
|
213
|
+
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!result) {
|
|
218
|
+
throw new Error('Stream ended without completion');
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
// ============================================================================
|
|
223
|
+
// Orchestration API
|
|
224
|
+
// ============================================================================
|
|
225
|
+
/**
|
|
226
|
+
* Orchestrate a complex request
|
|
227
|
+
* Uses local vortexai-l0 or remote API based on config
|
|
228
|
+
*/
|
|
229
|
+
async orchestrate(request) {
|
|
230
|
+
this.emit('request:start', { type: 'orchestrate', request });
|
|
231
|
+
try {
|
|
232
|
+
const req = typeof request === 'string'
|
|
233
|
+
? { query: request }
|
|
234
|
+
: request;
|
|
235
|
+
// Build context from memory if requested
|
|
236
|
+
if (req.includeMemory !== false && this.config.memory?.enabled !== false) {
|
|
237
|
+
const memoryContext = await this.buildMemoryContext({
|
|
238
|
+
messages: [{ role: 'user', content: req.query }],
|
|
239
|
+
conversationId: req.sessionId,
|
|
240
|
+
});
|
|
241
|
+
if (memoryContext) {
|
|
242
|
+
req.context = {
|
|
243
|
+
...req.context,
|
|
244
|
+
memoryContext,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Use local orchestrator if enabled
|
|
249
|
+
if (this.config.useLocalOrchestration && this.localOrchestrator) {
|
|
250
|
+
const l0Response = await this.localOrchestrator.query(req.query, req.parameters);
|
|
251
|
+
const result = this.convertL0Response(l0Response, req);
|
|
252
|
+
this.emit('request:success', { type: 'orchestrate', response: result });
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
// Otherwise use remote API
|
|
256
|
+
const response = await this.http.post('/v1/orchestrate', req);
|
|
257
|
+
this.emit('request:success', { type: 'orchestrate', response: response.data });
|
|
258
|
+
return response.data;
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
this.emit('request:error', { type: 'orchestrate', error });
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Convert L0Orchestrator response to OrchestrateResponse format
|
|
267
|
+
*/
|
|
268
|
+
convertL0Response(l0, req) {
|
|
269
|
+
return {
|
|
270
|
+
id: `orch_${Date.now()}`,
|
|
271
|
+
status: 'success',
|
|
272
|
+
message: l0.message,
|
|
273
|
+
workflow: l0.workflow ? {
|
|
274
|
+
id: `wf_${Date.now()}`,
|
|
275
|
+
name: 'L0 Orchestration',
|
|
276
|
+
steps: l0.workflow.map((step, i) => ({
|
|
277
|
+
id: `step_${i}`,
|
|
278
|
+
name: step,
|
|
279
|
+
status: 'completed',
|
|
280
|
+
duration: 0,
|
|
281
|
+
})),
|
|
282
|
+
output: l0.data,
|
|
283
|
+
duration: 0,
|
|
284
|
+
} : undefined,
|
|
285
|
+
agents: l0.agents?.map((agent, i) => ({
|
|
286
|
+
id: `agent_${i}`,
|
|
287
|
+
name: agent,
|
|
288
|
+
action: 'executed',
|
|
289
|
+
result: null,
|
|
290
|
+
confidence: 1.0,
|
|
291
|
+
})),
|
|
292
|
+
data: l0.data,
|
|
293
|
+
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
294
|
+
metadata: {
|
|
295
|
+
requestId: `req_${Date.now()}`,
|
|
296
|
+
processingTime: 0,
|
|
297
|
+
model: 'vortexai-l0-local',
|
|
298
|
+
pluginsUsed: req.plugins || [],
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
// ============================================================================
|
|
303
|
+
// Memory Integration (using @lanonasis/memory-sdk)
|
|
304
|
+
// ============================================================================
|
|
305
|
+
/**
|
|
306
|
+
* Build context from memory using memory-sdk's searchWithContext
|
|
307
|
+
*/
|
|
308
|
+
async buildMemoryContext(request) {
|
|
309
|
+
if (!request.conversationId)
|
|
310
|
+
return null;
|
|
311
|
+
try {
|
|
312
|
+
const userMessage = request.messages.find(m => m.role === 'user')?.content;
|
|
313
|
+
if (!userMessage)
|
|
314
|
+
return null;
|
|
315
|
+
const result = await this.memory.searchWithContext(userMessage, {
|
|
316
|
+
strategy: this.config.memory?.contextStrategy || 'relevance',
|
|
317
|
+
maxTokens: this.config.memory?.maxContextTokens || 4000,
|
|
318
|
+
limit: 10,
|
|
319
|
+
});
|
|
320
|
+
if (result.error || !result.data?.context) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
this.emit('memory:load', { query: userMessage, context: result.data });
|
|
324
|
+
return result.data.context;
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
this.debug('Failed to build memory context', error);
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Inject context into messages
|
|
333
|
+
*/
|
|
334
|
+
injectContext(messages, context) {
|
|
335
|
+
const contextMessage = {
|
|
336
|
+
role: 'system',
|
|
337
|
+
content: `[Relevant context from memory]\n${context}\n[End of context]`,
|
|
338
|
+
};
|
|
339
|
+
// Insert after system message or at beginning
|
|
340
|
+
const systemIdx = messages.findIndex(m => m.role === 'system');
|
|
341
|
+
if (systemIdx >= 0) {
|
|
342
|
+
return [
|
|
343
|
+
...messages.slice(0, systemIdx + 1),
|
|
344
|
+
contextMessage,
|
|
345
|
+
...messages.slice(systemIdx + 1),
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
return [contextMessage, ...messages];
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Save conversation to memory
|
|
352
|
+
*/
|
|
353
|
+
async saveToMemory(request, response) {
|
|
354
|
+
if (!request.conversationId)
|
|
355
|
+
return;
|
|
356
|
+
try {
|
|
357
|
+
const userMessage = request.messages.find(m => m.role === 'user')?.content || '';
|
|
358
|
+
const assistantMessage = response.choices[0]?.message?.content || '';
|
|
359
|
+
await this.memory.createMemory({
|
|
360
|
+
title: `Conversation: ${request.conversationId}`,
|
|
361
|
+
content: `User: ${userMessage}\n\nAssistant: ${assistantMessage}`,
|
|
362
|
+
memory_type: 'conversation',
|
|
363
|
+
tags: ['ai-conversation', request.model || 'lanonasis-v1'],
|
|
364
|
+
metadata: {
|
|
365
|
+
conversationId: request.conversationId,
|
|
366
|
+
model: response.model,
|
|
367
|
+
usage: response.usage,
|
|
368
|
+
timestamp: new Date().toISOString(),
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
this.emit('memory:save', { conversationId: request.conversationId });
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
this.debug('Failed to save to memory', error);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
// ============================================================================
|
|
378
|
+
// API Key & Utility Methods
|
|
379
|
+
// ============================================================================
|
|
380
|
+
async validateKey() {
|
|
381
|
+
const response = await this.http.get('/v1/keys/validate');
|
|
382
|
+
return response.data;
|
|
383
|
+
}
|
|
384
|
+
async getUsage() {
|
|
385
|
+
const response = await this.http.get('/v1/keys/usage');
|
|
386
|
+
return response.data.usage;
|
|
387
|
+
}
|
|
388
|
+
getRateLimitStatus() {
|
|
389
|
+
return this.http.getRateLimitStatus();
|
|
390
|
+
}
|
|
391
|
+
async healthCheck() {
|
|
392
|
+
const start = Date.now();
|
|
393
|
+
try {
|
|
394
|
+
await this.http.get('/v1/health');
|
|
395
|
+
return { status: 'ok', latency: Date.now() - start };
|
|
396
|
+
}
|
|
397
|
+
catch {
|
|
398
|
+
return { status: 'error', latency: Date.now() - start };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
async memoryHealth() {
|
|
402
|
+
const result = await this.memory.getHealth();
|
|
403
|
+
return { status: result.data?.status === 'ok' ? 'ok' : 'error' };
|
|
404
|
+
}
|
|
405
|
+
withConfig(overrides) {
|
|
406
|
+
return new LanonasisAI({
|
|
407
|
+
...this.config,
|
|
408
|
+
...overrides,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
debug(message, data) {
|
|
412
|
+
if (this.config.debug) {
|
|
413
|
+
console.log(`[Lanonasis AI SDK] ${message}`, data || '');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
export function createClient(config) {
|
|
418
|
+
return new LanonasisAI(config);
|
|
419
|
+
}
|
|
420
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,YAAyD,MAAM,kCAAkC,CAAC;AACzG,OAAO,EAAE,cAAc,EAAwC,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiB9C,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAM,OAAO,WAAW;IACd,IAAI,CAAa;IACjB,iBAAiB,GAA0B,IAAI,CAAC;IAChD,aAAa,GAAsC,IAAI,GAAG,EAAE,CAAC;IAErE,+CAA+C;IAC/B,MAAM,CAAe;IAErC,wBAAwB;IACR,MAAM,CAAoF;IAE1G,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,gBAAgB;YAC3C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,IAAI,gBAAgB;YACjE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,eAAe;YAC1C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,mBAAmB;YACpD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;YAC5B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;YAC7B,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,EAAE;YAC3C,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,IAAI,KAAK;YAC5D,MAAM,EAAE,MAAM,CAAC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,GAAG,CAAC,YAAY,CAAC,CAAC;YAClC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACnE,CAAC;IAED,UAAU,CAAC,SAAmC;QAC5C,OAAO,IAAI,WAAW,CAAC;YACrB,GAAG,IAAI,CAAC,MAAM;YACd,GAAG,SAAS;SACb,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,OAAe,EAAE,IAAc;QAC3C,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,sBAAsB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,MAAuB;IAClD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe HTTP Client for Lanonasis AI API
|
|
3
|
+
* Handles chat completions and orchestration endpoints
|
|
4
|
+
* Memory operations are handled by @lanonasis/memory-sdk
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpClientConfig {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
timeout: number;
|
|
10
|
+
maxRetries: number;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
organizationId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RequestOptions {
|
|
16
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
17
|
+
path: string;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
stream?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface HttpResponse<T = unknown> {
|
|
24
|
+
data: T;
|
|
25
|
+
status: number;
|
|
26
|
+
headers: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export declare class HttpClient {
|
|
29
|
+
private config;
|
|
30
|
+
private rateLimitRemaining;
|
|
31
|
+
private rateLimitReset;
|
|
32
|
+
constructor(config: HttpClientConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Validate API key format
|
|
35
|
+
* Supports lano_ (primary), lnss_, vx_, and onasis_ (legacy) prefixes
|
|
36
|
+
* Aligned with auth-gateway api-key.service.ts
|
|
37
|
+
*/
|
|
38
|
+
private validateApiKey;
|
|
39
|
+
/**
|
|
40
|
+
* Build request headers
|
|
41
|
+
*/
|
|
42
|
+
private buildHeaders;
|
|
43
|
+
private sleep;
|
|
44
|
+
private getRetryDelay;
|
|
45
|
+
private isRetryable;
|
|
46
|
+
private parseError;
|
|
47
|
+
private updateRateLimitInfo;
|
|
48
|
+
private debug;
|
|
49
|
+
/**
|
|
50
|
+
* Make HTTP request with retries
|
|
51
|
+
*/
|
|
52
|
+
request<T = unknown>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
53
|
+
/**
|
|
54
|
+
* Make streaming request (for chat completions)
|
|
55
|
+
*/
|
|
56
|
+
stream(options: RequestOptions): AsyncGenerator<string, void, unknown>;
|
|
57
|
+
get<T = unknown>(path: string, headers?: Record<string, string>): Promise<HttpResponse<T>>;
|
|
58
|
+
post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<HttpResponse<T>>;
|
|
59
|
+
put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<HttpResponse<T>>;
|
|
60
|
+
delete<T = unknown>(path: string, headers?: Record<string, string>): Promise<HttpResponse<T>>;
|
|
61
|
+
getRateLimitStatus(): {
|
|
62
|
+
remaining: number;
|
|
63
|
+
reset: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,qBAAa,UAAU;IACrB,OAAO,C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