n8n-nodes-vercel-ai-sdk-universal-temp 0.3.1 → 0.3.3
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/dist/nodes/UniversalAI/helpers/inputBuilder.js +1 -1
- package/dist/nodes/UniversalAI/helpers/inputBuilder.js.map +1 -1
- package/dist/nodes/UniversalAgent/UniversalAgent.node.d.ts +7 -2
- package/dist/nodes/UniversalAgent/UniversalAgent.node.js +580 -62
- package/dist/nodes/UniversalAgent/UniversalAgent.node.js.map +1 -1
- package/dist/nodes/shared/descriptions.js +367 -4
- package/dist/nodes/shared/descriptions.js.map +1 -1
- package/dist/nodes/shared/letta/client.d.ts +23 -0
- package/dist/nodes/shared/letta/client.js +208 -1
- package/dist/nodes/shared/letta/client.js.map +1 -1
- package/dist/nodes/shared/letta/load-options.js +2 -2
- package/dist/nodes/shared/letta/load-options.js.map +1 -1
- package/package.json +1 -1
|
@@ -168,8 +168,8 @@ class UniversalAgent {
|
|
|
168
168
|
throw new Error('No response received from Letta API');
|
|
169
169
|
}
|
|
170
170
|
let text = '';
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
const finishReason = response.stopReason || response.stop_reason;
|
|
172
|
+
const usage = response.usage;
|
|
173
173
|
if (response.messages) {
|
|
174
174
|
text = UniversalAgent.extractTextFromLettaMessages(response.messages);
|
|
175
175
|
}
|
|
@@ -193,20 +193,13 @@ class UniversalAgent {
|
|
|
193
193
|
},
|
|
194
194
|
];
|
|
195
195
|
}
|
|
196
|
-
static async processStreamedChatResponse(stream, index) {
|
|
197
|
-
const chunks = [];
|
|
198
|
-
for await (const chunk of stream) {
|
|
199
|
-
chunks.push({ json: chunk, pairedItem: { item: index } });
|
|
200
|
-
}
|
|
201
|
-
return chunks;
|
|
202
|
-
}
|
|
203
196
|
async execute() {
|
|
204
197
|
const items = this.getInputData();
|
|
205
198
|
const returnData = [];
|
|
206
199
|
const operation = this.getNodeParameter('operation', 0);
|
|
207
200
|
for (let i = 0; i < items.length; i++) {
|
|
208
201
|
try {
|
|
209
|
-
const result = await UniversalAgent.processItem(this, i, operation);
|
|
202
|
+
const result = await UniversalAgent.processItem(this, i, operation, items[i]);
|
|
210
203
|
returnData.push(...result);
|
|
211
204
|
}
|
|
212
205
|
catch (error) {
|
|
@@ -221,25 +214,37 @@ class UniversalAgent {
|
|
|
221
214
|
}
|
|
222
215
|
return [returnData];
|
|
223
216
|
}
|
|
224
|
-
static async processItem(exec, index, operation) {
|
|
217
|
+
static async processItem(exec, index, operation, item) {
|
|
225
218
|
const provider = exec.getNodeParameter('provider', index);
|
|
226
219
|
if (provider !== 'letta') {
|
|
227
220
|
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), 'UniversalAgent node only supports Letta provider');
|
|
228
221
|
}
|
|
229
222
|
switch (operation) {
|
|
230
223
|
case 'chat':
|
|
231
|
-
return await UniversalAgent.handleChatOperation(exec, index);
|
|
224
|
+
return await UniversalAgent.handleChatOperation(exec, index, item);
|
|
232
225
|
case 'createAgent':
|
|
233
|
-
return await UniversalAgent.handleCreateAgentOperation(exec, index);
|
|
226
|
+
return await UniversalAgent.handleCreateAgentOperation(exec, index, item);
|
|
234
227
|
case 'manageAgent':
|
|
235
|
-
return await UniversalAgent.handleManageAgentOperation(exec, index);
|
|
228
|
+
return await UniversalAgent.handleManageAgentOperation(exec, index, item);
|
|
229
|
+
case 'listAgents':
|
|
230
|
+
return await UniversalAgent.handleListAgentsOperation(exec, index, item);
|
|
236
231
|
case 'manageIdentity':
|
|
237
|
-
return await UniversalAgent.handleManageIdentityOperation(exec, index);
|
|
232
|
+
return await UniversalAgent.handleManageIdentityOperation(exec, index, item);
|
|
233
|
+
case 'tools':
|
|
234
|
+
return await UniversalAgent.handleToolsOperation(exec, index, item);
|
|
235
|
+
case 'blocks':
|
|
236
|
+
return await UniversalAgent.handleBlocksOperation(exec, index, item);
|
|
237
|
+
case 'folders':
|
|
238
|
+
return await UniversalAgent.handleFoldersOperation(exec, index, item);
|
|
239
|
+
case 'mcpServers':
|
|
240
|
+
return await UniversalAgent.handleMcpServersOperation(exec, index, item);
|
|
241
|
+
case 'models':
|
|
242
|
+
return await UniversalAgent.handleModelsOperation(exec, index, item);
|
|
238
243
|
default:
|
|
239
|
-
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `
|
|
244
|
+
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Operation not yet implemented: ${operation}. Currently supported: chat, createAgent, manageAgent, listAgents, manageIdentity, tools, blocks, folders, mcpServers, models`);
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
|
-
static async handleChatOperation(exec, index) {
|
|
247
|
+
static async handleChatOperation(exec, index, item) {
|
|
243
248
|
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
244
249
|
const message = UniversalAgent.extractMessageFromInput(exec, index);
|
|
245
250
|
if (!message) {
|
|
@@ -251,16 +256,10 @@ class UniversalAgent {
|
|
|
251
256
|
if (chatOptions.background) {
|
|
252
257
|
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), 'Background mode is not supported for chat operations. Please disable background processing.');
|
|
253
258
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return await UniversalAgent.processStreamedChatResponse(stream, index);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
const response = await client.sendMessage(agentIds, message, identity, chatOptions);
|
|
260
|
-
return UniversalAgent.processChatResponse(response, index);
|
|
261
|
-
}
|
|
259
|
+
const response = await client.sendMessage(agentIds, message, identity, chatOptions);
|
|
260
|
+
return UniversalAgent.processChatResponse(response, index);
|
|
262
261
|
}
|
|
263
|
-
static async handleCreateAgentOperation(exec, index) {
|
|
262
|
+
static async handleCreateAgentOperation(exec, index, item) {
|
|
264
263
|
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
265
264
|
const useJson = exec.getNodeParameter('createAgentJsonConfigMode', index, false);
|
|
266
265
|
let agentConfig;
|
|
@@ -321,7 +320,7 @@ class UniversalAgent {
|
|
|
321
320
|
},
|
|
322
321
|
];
|
|
323
322
|
}
|
|
324
|
-
static async handleManageAgentOperation(exec, index) {
|
|
323
|
+
static async handleManageAgentOperation(exec, index, item) {
|
|
325
324
|
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
326
325
|
const operation = exec.getNodeParameter('manageAgentOperation', index);
|
|
327
326
|
const agentId = exec.getNodeParameter('manageAgentId', index);
|
|
@@ -329,7 +328,7 @@ class UniversalAgent {
|
|
|
329
328
|
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), 'Agent ID is required for manage agent operation');
|
|
330
329
|
}
|
|
331
330
|
switch (operation) {
|
|
332
|
-
case 'get':
|
|
331
|
+
case 'get': {
|
|
333
332
|
const agent = await client.getAgent(agentId);
|
|
334
333
|
return [
|
|
335
334
|
{
|
|
@@ -345,7 +344,7 @@ class UniversalAgent {
|
|
|
345
344
|
pairedItem: { item: index },
|
|
346
345
|
},
|
|
347
346
|
];
|
|
348
|
-
|
|
347
|
+
}
|
|
349
348
|
case 'update': {
|
|
350
349
|
const useJson = exec.getNodeParameter('updateAgentJsonConfigMode', index, false);
|
|
351
350
|
let updateConfig;
|
|
@@ -361,37 +360,24 @@ class UniversalAgent {
|
|
|
361
360
|
else {
|
|
362
361
|
const simpleConfig = exec.getNodeParameter('updateAgentConfig', index);
|
|
363
362
|
updateConfig = {
|
|
364
|
-
name: simpleConfig.name,
|
|
365
|
-
model: simpleConfig.model,
|
|
366
|
-
embedding: simpleConfig.embedding,
|
|
367
|
-
system: simpleConfig.system,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
.map((s) => s.trim())
|
|
382
|
-
.filter(Boolean) || undefined,
|
|
383
|
-
memory_blocks: simpleConfig.memoryBlocks?.block?.map((b) => ({
|
|
384
|
-
label: b.label,
|
|
385
|
-
value: b.value,
|
|
386
|
-
})) || undefined,
|
|
387
|
-
secrets: simpleConfig.secrets?.secret?.reduce((acc, s) => {
|
|
388
|
-
if (s.key) {
|
|
389
|
-
acc[s.key] = s.value;
|
|
390
|
-
}
|
|
391
|
-
return acc;
|
|
392
|
-
}, {}) || undefined,
|
|
363
|
+
...(simpleConfig.name && { name: simpleConfig.name }),
|
|
364
|
+
...(simpleConfig.model && { model: simpleConfig.model }),
|
|
365
|
+
...(simpleConfig.embedding && { embedding: simpleConfig.embedding }),
|
|
366
|
+
...(simpleConfig.system && { system: simpleConfig.system }),
|
|
367
|
+
...(simpleConfig.tags && {
|
|
368
|
+
tags: simpleConfig.tags
|
|
369
|
+
.split(',')
|
|
370
|
+
.map((t) => t.trim())
|
|
371
|
+
.filter(Boolean),
|
|
372
|
+
}),
|
|
373
|
+
...(simpleConfig.memoryBlocks?.block && {
|
|
374
|
+
memory_blocks: simpleConfig.memoryBlocks.block.map((b) => ({
|
|
375
|
+
label: b.label,
|
|
376
|
+
value: b.value,
|
|
377
|
+
...(b.description && { description: b.description }),
|
|
378
|
+
})),
|
|
379
|
+
}),
|
|
393
380
|
};
|
|
394
|
-
updateConfig = Object.fromEntries(Object.entries(updateConfig).filter(([, v]) => v !== '' && v !== undefined && (!Array.isArray(v) || v.length > 0)));
|
|
395
381
|
}
|
|
396
382
|
const updatedAgent = await client.updateAgent(agentId, updateConfig);
|
|
397
383
|
return [
|
|
@@ -407,14 +393,51 @@ class UniversalAgent {
|
|
|
407
393
|
},
|
|
408
394
|
];
|
|
409
395
|
}
|
|
410
|
-
case 'delete':
|
|
396
|
+
case 'delete': {
|
|
411
397
|
await client.deleteAgent(agentId);
|
|
412
|
-
return [
|
|
398
|
+
return [
|
|
399
|
+
{
|
|
400
|
+
json: {
|
|
401
|
+
deleted: true,
|
|
402
|
+
agentId,
|
|
403
|
+
},
|
|
404
|
+
pairedItem: { item: index },
|
|
405
|
+
},
|
|
406
|
+
];
|
|
407
|
+
}
|
|
413
408
|
default:
|
|
414
409
|
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported manage agent operation: ${operation}`);
|
|
415
410
|
}
|
|
416
411
|
}
|
|
417
|
-
static async
|
|
412
|
+
static async handleListAgentsOperation(exec, index, item) {
|
|
413
|
+
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
414
|
+
const tags = exec.getNodeParameter('listAgentsTags', index, '');
|
|
415
|
+
const tagArray = tags
|
|
416
|
+
? tags
|
|
417
|
+
.split(',')
|
|
418
|
+
.map((t) => t.trim())
|
|
419
|
+
.filter(Boolean)
|
|
420
|
+
: undefined;
|
|
421
|
+
const agents = await client.listAgents(tagArray);
|
|
422
|
+
return [
|
|
423
|
+
{
|
|
424
|
+
json: {
|
|
425
|
+
agents: agents.map((agent) => ({
|
|
426
|
+
id: agent.id,
|
|
427
|
+
name: agent.name,
|
|
428
|
+
model: agent.llmConfig?.model,
|
|
429
|
+
embedding: agent.embeddingConfig?.embeddingModel,
|
|
430
|
+
tags: agent.tags,
|
|
431
|
+
createdAt: agent.createdAt,
|
|
432
|
+
updatedAt: agent.updatedAt,
|
|
433
|
+
})),
|
|
434
|
+
total: agents.length,
|
|
435
|
+
},
|
|
436
|
+
pairedItem: { item: index },
|
|
437
|
+
},
|
|
438
|
+
];
|
|
439
|
+
}
|
|
440
|
+
static async handleManageIdentityOperation(exec, index, item) {
|
|
418
441
|
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
419
442
|
const operation = exec.getNodeParameter('manageIdentityOperation', index);
|
|
420
443
|
const identifierKey = exec.getNodeParameter('identityKey', index);
|
|
@@ -458,6 +481,501 @@ class UniversalAgent {
|
|
|
458
481
|
}
|
|
459
482
|
return [];
|
|
460
483
|
}
|
|
484
|
+
static async handleToolsOperation(exec, index, item) {
|
|
485
|
+
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
486
|
+
const operation = exec.getNodeParameter('toolsOperation', index);
|
|
487
|
+
switch (operation) {
|
|
488
|
+
case 'list': {
|
|
489
|
+
const tools = await client.listTools();
|
|
490
|
+
return [
|
|
491
|
+
{
|
|
492
|
+
json: {
|
|
493
|
+
tools: tools.map((tool) => ({
|
|
494
|
+
id: tool.id,
|
|
495
|
+
name: tool.name,
|
|
496
|
+
description: tool.description,
|
|
497
|
+
sourceCode: tool.source_code,
|
|
498
|
+
tags: tool.tags,
|
|
499
|
+
})),
|
|
500
|
+
total: tools.length,
|
|
501
|
+
},
|
|
502
|
+
pairedItem: { item: index },
|
|
503
|
+
},
|
|
504
|
+
];
|
|
505
|
+
}
|
|
506
|
+
case 'create': {
|
|
507
|
+
const name = exec.getNodeParameter('toolName', index);
|
|
508
|
+
const description = exec.getNodeParameter('toolDescription', index);
|
|
509
|
+
const sourceCode = exec.getNodeParameter('toolSourceCode', index);
|
|
510
|
+
const tags = exec.getNodeParameter('toolTags', index, '');
|
|
511
|
+
const tagArray = tags
|
|
512
|
+
? tags
|
|
513
|
+
.split(',')
|
|
514
|
+
.map((t) => t.trim())
|
|
515
|
+
.filter(Boolean)
|
|
516
|
+
: [];
|
|
517
|
+
const tool = await client.createTool({
|
|
518
|
+
name,
|
|
519
|
+
description,
|
|
520
|
+
source_code: sourceCode,
|
|
521
|
+
tags: tagArray,
|
|
522
|
+
});
|
|
523
|
+
return [
|
|
524
|
+
{
|
|
525
|
+
json: {
|
|
526
|
+
toolId: tool.id,
|
|
527
|
+
name: tool.name,
|
|
528
|
+
description: tool.description,
|
|
529
|
+
tags: tool.tags,
|
|
530
|
+
},
|
|
531
|
+
pairedItem: { item: index },
|
|
532
|
+
},
|
|
533
|
+
];
|
|
534
|
+
}
|
|
535
|
+
case 'get': {
|
|
536
|
+
const toolId = exec.getNodeParameter('toolId', index);
|
|
537
|
+
const tool = await client.getTool(toolId);
|
|
538
|
+
return [
|
|
539
|
+
{
|
|
540
|
+
json: {
|
|
541
|
+
toolId: tool.id,
|
|
542
|
+
name: tool.name,
|
|
543
|
+
description: tool.description,
|
|
544
|
+
sourceCode: tool.source_code,
|
|
545
|
+
tags: tool.tags,
|
|
546
|
+
},
|
|
547
|
+
pairedItem: { item: index },
|
|
548
|
+
},
|
|
549
|
+
];
|
|
550
|
+
}
|
|
551
|
+
case 'update': {
|
|
552
|
+
const toolId = exec.getNodeParameter('toolId', index);
|
|
553
|
+
const name = exec.getNodeParameter('toolName', index);
|
|
554
|
+
const description = exec.getNodeParameter('toolDescription', index);
|
|
555
|
+
const sourceCode = exec.getNodeParameter('toolSourceCode', index);
|
|
556
|
+
const tags = exec.getNodeParameter('toolTags', index, '');
|
|
557
|
+
const tagArray = tags
|
|
558
|
+
? tags
|
|
559
|
+
.split(',')
|
|
560
|
+
.map((t) => t.trim())
|
|
561
|
+
.filter(Boolean)
|
|
562
|
+
: [];
|
|
563
|
+
const tool = await client.updateTool(toolId, {
|
|
564
|
+
name,
|
|
565
|
+
description,
|
|
566
|
+
source_code: sourceCode,
|
|
567
|
+
tags: tagArray,
|
|
568
|
+
});
|
|
569
|
+
return [
|
|
570
|
+
{
|
|
571
|
+
json: {
|
|
572
|
+
toolId: tool.id,
|
|
573
|
+
name: tool.name,
|
|
574
|
+
description: tool.description,
|
|
575
|
+
tags: tool.tags,
|
|
576
|
+
},
|
|
577
|
+
pairedItem: { item: index },
|
|
578
|
+
},
|
|
579
|
+
];
|
|
580
|
+
}
|
|
581
|
+
case 'delete': {
|
|
582
|
+
const toolId = exec.getNodeParameter('toolId', index);
|
|
583
|
+
await client.deleteTool(toolId);
|
|
584
|
+
return [
|
|
585
|
+
{
|
|
586
|
+
json: {
|
|
587
|
+
deleted: true,
|
|
588
|
+
toolId,
|
|
589
|
+
},
|
|
590
|
+
pairedItem: { item: index },
|
|
591
|
+
},
|
|
592
|
+
];
|
|
593
|
+
}
|
|
594
|
+
case 'upsert': {
|
|
595
|
+
const name = exec.getNodeParameter('toolName', index);
|
|
596
|
+
const description = exec.getNodeParameter('toolDescription', index);
|
|
597
|
+
const sourceCode = exec.getNodeParameter('toolSourceCode', index);
|
|
598
|
+
const tags = exec.getNodeParameter('toolTags', index, '');
|
|
599
|
+
const tagArray = tags
|
|
600
|
+
? tags
|
|
601
|
+
.split(',')
|
|
602
|
+
.map((t) => t.trim())
|
|
603
|
+
.filter(Boolean)
|
|
604
|
+
: [];
|
|
605
|
+
const tool = await client.upsertTool({
|
|
606
|
+
name,
|
|
607
|
+
description,
|
|
608
|
+
source_code: sourceCode,
|
|
609
|
+
tags: tagArray,
|
|
610
|
+
});
|
|
611
|
+
return [
|
|
612
|
+
{
|
|
613
|
+
json: {
|
|
614
|
+
toolId: tool.id,
|
|
615
|
+
name: tool.name,
|
|
616
|
+
description: tool.description,
|
|
617
|
+
tags: tool.tags,
|
|
618
|
+
created: tool.created,
|
|
619
|
+
},
|
|
620
|
+
pairedItem: { item: index },
|
|
621
|
+
},
|
|
622
|
+
];
|
|
623
|
+
}
|
|
624
|
+
case 'upsertBase': {
|
|
625
|
+
const result = await client.upsertBaseTools();
|
|
626
|
+
return [
|
|
627
|
+
{
|
|
628
|
+
json: {
|
|
629
|
+
baseToolsUpserted: true,
|
|
630
|
+
result,
|
|
631
|
+
},
|
|
632
|
+
pairedItem: { item: index },
|
|
633
|
+
},
|
|
634
|
+
];
|
|
635
|
+
}
|
|
636
|
+
default:
|
|
637
|
+
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported tools operation: ${operation}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
static async handleBlocksOperation(exec, index, item) {
|
|
641
|
+
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
642
|
+
const operation = exec.getNodeParameter('blocksOperation', index);
|
|
643
|
+
switch (operation) {
|
|
644
|
+
case 'list': {
|
|
645
|
+
const limit = exec.getNodeParameter('limit', index, 100);
|
|
646
|
+
const blocks = await client.listBlocks(limit);
|
|
647
|
+
return [
|
|
648
|
+
{
|
|
649
|
+
json: {
|
|
650
|
+
blocks: blocks.map((block) => ({
|
|
651
|
+
id: block.id,
|
|
652
|
+
label: block.label,
|
|
653
|
+
value: block.value,
|
|
654
|
+
description: block.description,
|
|
655
|
+
limit: block.limit,
|
|
656
|
+
})),
|
|
657
|
+
total: blocks.length,
|
|
658
|
+
},
|
|
659
|
+
pairedItem: { item: index },
|
|
660
|
+
},
|
|
661
|
+
];
|
|
662
|
+
}
|
|
663
|
+
case 'create': {
|
|
664
|
+
const label = exec.getNodeParameter('blockLabel', index);
|
|
665
|
+
const value = exec.getNodeParameter('blockValue', index);
|
|
666
|
+
const description = exec.getNodeParameter('blockDescription', index, '');
|
|
667
|
+
const block = await client.createBlock({
|
|
668
|
+
label,
|
|
669
|
+
value,
|
|
670
|
+
description: description || undefined,
|
|
671
|
+
});
|
|
672
|
+
return [
|
|
673
|
+
{
|
|
674
|
+
json: {
|
|
675
|
+
blockId: block.id,
|
|
676
|
+
label: block.label,
|
|
677
|
+
value: block.value,
|
|
678
|
+
description: block.description,
|
|
679
|
+
},
|
|
680
|
+
pairedItem: { item: index },
|
|
681
|
+
},
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
case 'get': {
|
|
685
|
+
const blockId = exec.getNodeParameter('blockId', index);
|
|
686
|
+
const block = await client.getBlock(blockId);
|
|
687
|
+
return [
|
|
688
|
+
{
|
|
689
|
+
json: {
|
|
690
|
+
blockId: block.id,
|
|
691
|
+
label: block.label,
|
|
692
|
+
value: block.value,
|
|
693
|
+
description: block.description,
|
|
694
|
+
limit: block.limit,
|
|
695
|
+
},
|
|
696
|
+
pairedItem: { item: index },
|
|
697
|
+
},
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
case 'update': {
|
|
701
|
+
const blockId = exec.getNodeParameter('blockId', index);
|
|
702
|
+
const label = exec.getNodeParameter('blockLabel', index);
|
|
703
|
+
const value = exec.getNodeParameter('blockValue', index);
|
|
704
|
+
const description = exec.getNodeParameter('blockDescription', index, '');
|
|
705
|
+
const block = await client.updateBlock(blockId, {
|
|
706
|
+
label,
|
|
707
|
+
value,
|
|
708
|
+
description: description || undefined,
|
|
709
|
+
});
|
|
710
|
+
return [
|
|
711
|
+
{
|
|
712
|
+
json: {
|
|
713
|
+
blockId: block.id,
|
|
714
|
+
label: block.label,
|
|
715
|
+
value: block.value,
|
|
716
|
+
description: block.description,
|
|
717
|
+
},
|
|
718
|
+
pairedItem: { item: index },
|
|
719
|
+
},
|
|
720
|
+
];
|
|
721
|
+
}
|
|
722
|
+
case 'delete': {
|
|
723
|
+
const blockId = exec.getNodeParameter('blockId', index);
|
|
724
|
+
await client.deleteBlock(blockId);
|
|
725
|
+
return [
|
|
726
|
+
{
|
|
727
|
+
json: {
|
|
728
|
+
deleted: true,
|
|
729
|
+
blockId,
|
|
730
|
+
},
|
|
731
|
+
pairedItem: { item: index },
|
|
732
|
+
},
|
|
733
|
+
];
|
|
734
|
+
}
|
|
735
|
+
default:
|
|
736
|
+
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported blocks operation: ${operation}`);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
static async handleFoldersOperation(exec, index, item) {
|
|
740
|
+
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
741
|
+
const operation = exec.getNodeParameter('foldersOperation', index);
|
|
742
|
+
switch (operation) {
|
|
743
|
+
case 'list': {
|
|
744
|
+
const folders = await client.listFolders();
|
|
745
|
+
return [
|
|
746
|
+
{
|
|
747
|
+
json: {
|
|
748
|
+
folders: folders.map((folder) => ({
|
|
749
|
+
id: folder.id,
|
|
750
|
+
name: folder.name,
|
|
751
|
+
embeddingConfig: folder.embedding_config,
|
|
752
|
+
})),
|
|
753
|
+
total: folders.length,
|
|
754
|
+
},
|
|
755
|
+
pairedItem: { item: index },
|
|
756
|
+
},
|
|
757
|
+
];
|
|
758
|
+
}
|
|
759
|
+
case 'create': {
|
|
760
|
+
const name = exec.getNodeParameter('folderName', index);
|
|
761
|
+
const embeddingConfig = exec.getNodeParameter('embeddingConfig', index, {});
|
|
762
|
+
const folder = await client.createFolder({
|
|
763
|
+
name,
|
|
764
|
+
embedding_config: embeddingConfig,
|
|
765
|
+
});
|
|
766
|
+
return [
|
|
767
|
+
{
|
|
768
|
+
json: {
|
|
769
|
+
folderId: folder.id,
|
|
770
|
+
name: folder.name,
|
|
771
|
+
embeddingConfig: folder.embedding_config,
|
|
772
|
+
},
|
|
773
|
+
pairedItem: { item: index },
|
|
774
|
+
},
|
|
775
|
+
];
|
|
776
|
+
}
|
|
777
|
+
case 'get': {
|
|
778
|
+
const folderId = exec.getNodeParameter('folderId', index);
|
|
779
|
+
const folder = await client.getFolder(folderId);
|
|
780
|
+
return [
|
|
781
|
+
{
|
|
782
|
+
json: {
|
|
783
|
+
folderId: folder.id,
|
|
784
|
+
name: folder.name,
|
|
785
|
+
embeddingConfig: folder.embedding_config,
|
|
786
|
+
},
|
|
787
|
+
pairedItem: { item: index },
|
|
788
|
+
},
|
|
789
|
+
];
|
|
790
|
+
}
|
|
791
|
+
case 'update': {
|
|
792
|
+
const folderId = exec.getNodeParameter('folderId', index);
|
|
793
|
+
const name = exec.getNodeParameter('folderName', index);
|
|
794
|
+
const embeddingConfig = exec.getNodeParameter('embeddingConfig', index, {});
|
|
795
|
+
const folder = await client.updateFolder(folderId, {
|
|
796
|
+
name,
|
|
797
|
+
embedding_config: embeddingConfig,
|
|
798
|
+
});
|
|
799
|
+
return [
|
|
800
|
+
{
|
|
801
|
+
json: {
|
|
802
|
+
folderId: folder.id,
|
|
803
|
+
name: folder.name,
|
|
804
|
+
embeddingConfig: folder.embedding_config,
|
|
805
|
+
},
|
|
806
|
+
pairedItem: { item: index },
|
|
807
|
+
},
|
|
808
|
+
];
|
|
809
|
+
}
|
|
810
|
+
case 'delete': {
|
|
811
|
+
const folderId = exec.getNodeParameter('folderId', index);
|
|
812
|
+
await client.deleteFolder(folderId);
|
|
813
|
+
return [
|
|
814
|
+
{
|
|
815
|
+
json: {
|
|
816
|
+
deleted: true,
|
|
817
|
+
folderId,
|
|
818
|
+
},
|
|
819
|
+
pairedItem: { item: index },
|
|
820
|
+
},
|
|
821
|
+
];
|
|
822
|
+
}
|
|
823
|
+
default:
|
|
824
|
+
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported folders operation: ${operation}`);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
static async handleMcpServersOperation(exec, index, item) {
|
|
828
|
+
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
829
|
+
const operation = exec.getNodeParameter('mcpServersOperation', index);
|
|
830
|
+
switch (operation) {
|
|
831
|
+
case 'list': {
|
|
832
|
+
const servers = await client.listMcpServers();
|
|
833
|
+
return [
|
|
834
|
+
{
|
|
835
|
+
json: {
|
|
836
|
+
servers: servers.map((server) => ({
|
|
837
|
+
id: server.id,
|
|
838
|
+
name: server.name,
|
|
839
|
+
command: server.command,
|
|
840
|
+
status: server.status,
|
|
841
|
+
})),
|
|
842
|
+
total: servers.length,
|
|
843
|
+
},
|
|
844
|
+
pairedItem: { item: index },
|
|
845
|
+
},
|
|
846
|
+
];
|
|
847
|
+
}
|
|
848
|
+
case 'create': {
|
|
849
|
+
const name = exec.getNodeParameter('serverName', index);
|
|
850
|
+
const command = exec.getNodeParameter('serverCommand', index);
|
|
851
|
+
const server = await client.createMcpServer({
|
|
852
|
+
name,
|
|
853
|
+
command,
|
|
854
|
+
});
|
|
855
|
+
return [
|
|
856
|
+
{
|
|
857
|
+
json: {
|
|
858
|
+
serverId: server.id,
|
|
859
|
+
name: server.name,
|
|
860
|
+
command: server.command,
|
|
861
|
+
status: server.status,
|
|
862
|
+
},
|
|
863
|
+
pairedItem: { item: index },
|
|
864
|
+
},
|
|
865
|
+
];
|
|
866
|
+
}
|
|
867
|
+
case 'get': {
|
|
868
|
+
const serverId = exec.getNodeParameter('serverId', index);
|
|
869
|
+
const server = await client.getMcpServer(serverId);
|
|
870
|
+
return [
|
|
871
|
+
{
|
|
872
|
+
json: {
|
|
873
|
+
serverId: server.id,
|
|
874
|
+
name: server.name,
|
|
875
|
+
command: server.command,
|
|
876
|
+
status: server.status,
|
|
877
|
+
},
|
|
878
|
+
pairedItem: { item: index },
|
|
879
|
+
},
|
|
880
|
+
];
|
|
881
|
+
}
|
|
882
|
+
case 'update': {
|
|
883
|
+
const serverId = exec.getNodeParameter('serverId', index);
|
|
884
|
+
const name = exec.getNodeParameter('serverName', index);
|
|
885
|
+
const command = exec.getNodeParameter('serverCommand', index);
|
|
886
|
+
const server = await client.updateMcpServer(serverId, {
|
|
887
|
+
name,
|
|
888
|
+
command,
|
|
889
|
+
});
|
|
890
|
+
return [
|
|
891
|
+
{
|
|
892
|
+
json: {
|
|
893
|
+
serverId: server.id,
|
|
894
|
+
name: server.name,
|
|
895
|
+
command: server.command,
|
|
896
|
+
status: server.status,
|
|
897
|
+
},
|
|
898
|
+
pairedItem: { item: index },
|
|
899
|
+
},
|
|
900
|
+
];
|
|
901
|
+
}
|
|
902
|
+
case 'delete': {
|
|
903
|
+
const serverId = exec.getNodeParameter('serverId', index);
|
|
904
|
+
await client.deleteMcpServer(serverId);
|
|
905
|
+
return [
|
|
906
|
+
{
|
|
907
|
+
json: {
|
|
908
|
+
deleted: true,
|
|
909
|
+
serverId,
|
|
910
|
+
},
|
|
911
|
+
pairedItem: { item: index },
|
|
912
|
+
},
|
|
913
|
+
];
|
|
914
|
+
}
|
|
915
|
+
case 'refresh': {
|
|
916
|
+
const serverId = exec.getNodeParameter('serverId', index);
|
|
917
|
+
const server = await client.refreshMcpServer(serverId);
|
|
918
|
+
return [
|
|
919
|
+
{
|
|
920
|
+
json: {
|
|
921
|
+
serverId: server.id,
|
|
922
|
+
name: server.name,
|
|
923
|
+
command: server.command,
|
|
924
|
+
status: server.status,
|
|
925
|
+
refreshed: true,
|
|
926
|
+
},
|
|
927
|
+
pairedItem: { item: index },
|
|
928
|
+
},
|
|
929
|
+
];
|
|
930
|
+
}
|
|
931
|
+
default:
|
|
932
|
+
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported MCP servers operation: ${operation}`);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
static async handleModelsOperation(exec, index, item) {
|
|
936
|
+
const client = await (0, letta_1.getLettaProvider)(exec, index);
|
|
937
|
+
const operation = exec.getNodeParameter('modelsOperation', index);
|
|
938
|
+
switch (operation) {
|
|
939
|
+
case 'llm': {
|
|
940
|
+
const models = await client.listLlmModels();
|
|
941
|
+
return [
|
|
942
|
+
{
|
|
943
|
+
json: {
|
|
944
|
+
models: models.map((model) => ({
|
|
945
|
+
id: model.id,
|
|
946
|
+
name: model.name,
|
|
947
|
+
contextWindow: model.context_window,
|
|
948
|
+
maxOutputLength: model.max_output_length,
|
|
949
|
+
})),
|
|
950
|
+
total: models.length,
|
|
951
|
+
type: 'llm',
|
|
952
|
+
},
|
|
953
|
+
pairedItem: { item: index },
|
|
954
|
+
},
|
|
955
|
+
];
|
|
956
|
+
}
|
|
957
|
+
case 'embedding': {
|
|
958
|
+
const models = await client.listEmbeddingModels();
|
|
959
|
+
return [
|
|
960
|
+
{
|
|
961
|
+
json: {
|
|
962
|
+
models: models.map((model) => ({
|
|
963
|
+
id: model.id,
|
|
964
|
+
name: model.name,
|
|
965
|
+
dimensions: model.dimensions,
|
|
966
|
+
maxInputLength: model.max_input_length,
|
|
967
|
+
})),
|
|
968
|
+
total: models.length,
|
|
969
|
+
type: 'embedding',
|
|
970
|
+
},
|
|
971
|
+
pairedItem: { item: index },
|
|
972
|
+
},
|
|
973
|
+
];
|
|
974
|
+
}
|
|
975
|
+
default:
|
|
976
|
+
throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported models operation: ${operation}`);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
461
979
|
}
|
|
462
980
|
exports.UniversalAgent = UniversalAgent;
|
|
463
981
|
//# sourceMappingURL=UniversalAgent.node.js.map
|