@lanonasis/ai-sdk 0.1.0 → 0.2.2
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 +255 -12
- package/dist/client.d.ts +79 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +425 -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 +49 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -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,425 @@
|
|
|
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/orchestrator';
|
|
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
|
+
// Handle both OpenAI format and simple {response: "..."} format
|
|
139
|
+
const rawResponse = response;
|
|
140
|
+
if (rawResponse.response) {
|
|
141
|
+
return rawResponse.response;
|
|
142
|
+
}
|
|
143
|
+
return response.choices?.[0]?.message?.content || '';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Stream chat response
|
|
147
|
+
*/
|
|
148
|
+
async *chatStream(request) {
|
|
149
|
+
this.emit('stream:start', { request });
|
|
150
|
+
let messages = [...request.messages];
|
|
151
|
+
if (request.includeMemory !== false && this.config.memory?.enabled !== false) {
|
|
152
|
+
const context = await this.buildMemoryContext(request);
|
|
153
|
+
if (context) {
|
|
154
|
+
messages = this.injectContext(messages, context);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const stream = this.http.stream({
|
|
158
|
+
method: 'POST',
|
|
159
|
+
path: '/v1/chat/completions',
|
|
160
|
+
body: {
|
|
161
|
+
messages,
|
|
162
|
+
model: request.model || 'lanonasis-v1',
|
|
163
|
+
temperature: request.temperature,
|
|
164
|
+
max_tokens: request.maxTokens,
|
|
165
|
+
stream: true,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
let fullContent = '';
|
|
169
|
+
for await (const chunk of stream) {
|
|
170
|
+
try {
|
|
171
|
+
const parsed = JSON.parse(chunk);
|
|
172
|
+
this.emit('stream:chunk', { chunk: parsed });
|
|
173
|
+
const delta = parsed.choices[0]?.delta?.content;
|
|
174
|
+
if (delta) {
|
|
175
|
+
fullContent += delta;
|
|
176
|
+
}
|
|
177
|
+
yield parsed;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// Skip invalid chunks
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Save complete message to memory
|
|
184
|
+
if (fullContent && this.config.memory?.autoSave !== false && request.conversationId) {
|
|
185
|
+
await this.memory.createMemory({
|
|
186
|
+
title: `Conversation ${request.conversationId}`,
|
|
187
|
+
content: fullContent,
|
|
188
|
+
memory_type: 'conversation',
|
|
189
|
+
tags: ['ai-response', 'streaming'],
|
|
190
|
+
metadata: { conversationId: request.conversationId },
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
this.emit('stream:end', { conversationId: request.conversationId });
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Stream with callback (alternative API)
|
|
197
|
+
*/
|
|
198
|
+
async streamChat(request, onChunk) {
|
|
199
|
+
let result = null;
|
|
200
|
+
let fullContent = '';
|
|
201
|
+
for await (const chunk of this.chatStream(request)) {
|
|
202
|
+
onChunk(chunk);
|
|
203
|
+
const delta = chunk.choices[0]?.delta?.content;
|
|
204
|
+
if (delta) {
|
|
205
|
+
fullContent += delta;
|
|
206
|
+
}
|
|
207
|
+
if (chunk.choices[0]?.finishReason) {
|
|
208
|
+
result = {
|
|
209
|
+
id: chunk.id,
|
|
210
|
+
object: 'chat.completion',
|
|
211
|
+
created: chunk.created,
|
|
212
|
+
model: chunk.model,
|
|
213
|
+
choices: [{
|
|
214
|
+
index: 0,
|
|
215
|
+
message: { role: 'assistant', content: fullContent },
|
|
216
|
+
finishReason: chunk.choices[0].finishReason,
|
|
217
|
+
}],
|
|
218
|
+
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (!result) {
|
|
223
|
+
throw new Error('Stream ended without completion');
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// Orchestration API
|
|
229
|
+
// ============================================================================
|
|
230
|
+
/**
|
|
231
|
+
* Orchestrate a complex request
|
|
232
|
+
* Uses local vortexai-l0 or remote API based on config
|
|
233
|
+
*/
|
|
234
|
+
async orchestrate(request) {
|
|
235
|
+
this.emit('request:start', { type: 'orchestrate', request });
|
|
236
|
+
try {
|
|
237
|
+
const req = typeof request === 'string'
|
|
238
|
+
? { query: request }
|
|
239
|
+
: request;
|
|
240
|
+
// Build context from memory if requested
|
|
241
|
+
if (req.includeMemory !== false && this.config.memory?.enabled !== false) {
|
|
242
|
+
const memoryContext = await this.buildMemoryContext({
|
|
243
|
+
messages: [{ role: 'user', content: req.query }],
|
|
244
|
+
conversationId: req.sessionId,
|
|
245
|
+
});
|
|
246
|
+
if (memoryContext) {
|
|
247
|
+
req.context = {
|
|
248
|
+
...req.context,
|
|
249
|
+
memoryContext,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Use local orchestrator if enabled
|
|
254
|
+
if (this.config.useLocalOrchestration && this.localOrchestrator) {
|
|
255
|
+
const l0Response = await this.localOrchestrator.query(req.query, req.parameters);
|
|
256
|
+
const result = this.convertL0Response(l0Response, req);
|
|
257
|
+
this.emit('request:success', { type: 'orchestrate', response: result });
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
// Otherwise use remote API
|
|
261
|
+
const response = await this.http.post('/v1/orchestrate', req);
|
|
262
|
+
this.emit('request:success', { type: 'orchestrate', response: response.data });
|
|
263
|
+
return response.data;
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
this.emit('request:error', { type: 'orchestrate', error });
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Convert L0Orchestrator response to OrchestrateResponse format
|
|
272
|
+
*/
|
|
273
|
+
convertL0Response(l0, req) {
|
|
274
|
+
return {
|
|
275
|
+
id: `orch_${Date.now()}`,
|
|
276
|
+
status: 'success',
|
|
277
|
+
message: l0.message,
|
|
278
|
+
workflow: l0.workflow ? {
|
|
279
|
+
id: `wf_${Date.now()}`,
|
|
280
|
+
name: 'L0 Orchestration',
|
|
281
|
+
steps: l0.workflow.map((step, i) => ({
|
|
282
|
+
id: `step_${i}`,
|
|
283
|
+
name: step,
|
|
284
|
+
status: 'completed',
|
|
285
|
+
duration: 0,
|
|
286
|
+
})),
|
|
287
|
+
output: l0.data,
|
|
288
|
+
duration: 0,
|
|
289
|
+
} : undefined,
|
|
290
|
+
agents: l0.agents?.map((agent, i) => ({
|
|
291
|
+
id: `agent_${i}`,
|
|
292
|
+
name: agent,
|
|
293
|
+
action: 'executed',
|
|
294
|
+
result: null,
|
|
295
|
+
confidence: 1.0,
|
|
296
|
+
})),
|
|
297
|
+
data: l0.data,
|
|
298
|
+
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
299
|
+
metadata: {
|
|
300
|
+
requestId: `req_${Date.now()}`,
|
|
301
|
+
processingTime: 0,
|
|
302
|
+
model: 'vortexai-l0-local',
|
|
303
|
+
pluginsUsed: req.plugins || [],
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
// ============================================================================
|
|
308
|
+
// Memory Integration (using @lanonasis/memory-sdk)
|
|
309
|
+
// ============================================================================
|
|
310
|
+
/**
|
|
311
|
+
* Build context from memory using memory-sdk's searchWithContext
|
|
312
|
+
*/
|
|
313
|
+
async buildMemoryContext(request) {
|
|
314
|
+
if (!request.conversationId)
|
|
315
|
+
return null;
|
|
316
|
+
try {
|
|
317
|
+
const userMessage = request.messages.find(m => m.role === 'user')?.content;
|
|
318
|
+
if (!userMessage)
|
|
319
|
+
return null;
|
|
320
|
+
const result = await this.memory.searchWithContext(userMessage, {
|
|
321
|
+
strategy: this.config.memory?.contextStrategy || 'relevance',
|
|
322
|
+
maxTokens: this.config.memory?.maxContextTokens || 4000,
|
|
323
|
+
limit: 10,
|
|
324
|
+
});
|
|
325
|
+
if (result.error || !result.data?.context) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
this.emit('memory:load', { query: userMessage, context: result.data });
|
|
329
|
+
return result.data.context;
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
this.debug('Failed to build memory context', error);
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Inject context into messages
|
|
338
|
+
*/
|
|
339
|
+
injectContext(messages, context) {
|
|
340
|
+
const contextMessage = {
|
|
341
|
+
role: 'system',
|
|
342
|
+
content: `[Relevant context from memory]\n${context}\n[End of context]`,
|
|
343
|
+
};
|
|
344
|
+
// Insert after system message or at beginning
|
|
345
|
+
const systemIdx = messages.findIndex(m => m.role === 'system');
|
|
346
|
+
if (systemIdx >= 0) {
|
|
347
|
+
return [
|
|
348
|
+
...messages.slice(0, systemIdx + 1),
|
|
349
|
+
contextMessage,
|
|
350
|
+
...messages.slice(systemIdx + 1),
|
|
351
|
+
];
|
|
352
|
+
}
|
|
353
|
+
return [contextMessage, ...messages];
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Save conversation to memory
|
|
357
|
+
*/
|
|
358
|
+
async saveToMemory(request, response) {
|
|
359
|
+
if (!request.conversationId)
|
|
360
|
+
return;
|
|
361
|
+
try {
|
|
362
|
+
const userMessage = request.messages.find(m => m.role === 'user')?.content || '';
|
|
363
|
+
const assistantMessage = response.choices[0]?.message?.content || '';
|
|
364
|
+
await this.memory.createMemory({
|
|
365
|
+
title: `Conversation: ${request.conversationId}`,
|
|
366
|
+
content: `User: ${userMessage}\n\nAssistant: ${assistantMessage}`,
|
|
367
|
+
memory_type: 'conversation',
|
|
368
|
+
tags: ['ai-conversation', request.model || 'lanonasis-v1'],
|
|
369
|
+
metadata: {
|
|
370
|
+
conversationId: request.conversationId,
|
|
371
|
+
model: response.model,
|
|
372
|
+
usage: response.usage,
|
|
373
|
+
timestamp: new Date().toISOString(),
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
this.emit('memory:save', { conversationId: request.conversationId });
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
this.debug('Failed to save to memory', error);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// ============================================================================
|
|
383
|
+
// API Key & Utility Methods
|
|
384
|
+
// ============================================================================
|
|
385
|
+
async validateKey() {
|
|
386
|
+
const response = await this.http.get('/v1/keys/validate');
|
|
387
|
+
return response.data;
|
|
388
|
+
}
|
|
389
|
+
async getUsage() {
|
|
390
|
+
const response = await this.http.get('/v1/keys/usage');
|
|
391
|
+
return response.data.usage;
|
|
392
|
+
}
|
|
393
|
+
getRateLimitStatus() {
|
|
394
|
+
return this.http.getRateLimitStatus();
|
|
395
|
+
}
|
|
396
|
+
async healthCheck() {
|
|
397
|
+
const start = Date.now();
|
|
398
|
+
try {
|
|
399
|
+
await this.http.get('/v1/health');
|
|
400
|
+
return { status: 'ok', latency: Date.now() - start };
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
return { status: 'error', latency: Date.now() - start };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
async memoryHealth() {
|
|
407
|
+
const result = await this.memory.getHealth();
|
|
408
|
+
return { status: result.data?.status === 'ok' ? 'ok' : 'error' };
|
|
409
|
+
}
|
|
410
|
+
withConfig(overrides) {
|
|
411
|
+
return new LanonasisAI({
|
|
412
|
+
...this.config,
|
|
413
|
+
...overrides,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
debug(message, data) {
|
|
417
|
+
if (this.config.debug) {
|
|
418
|
+
console.log(`[Lanonasis AI SDK] ${message}`, data || '');
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
export function createClient(config) {
|
|
423
|
+
return new LanonasisAI(config);
|
|
424
|
+
}
|
|
425
|
+
//# 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,0BAA0B,CAAC;AAChG,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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AC,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,C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