n8n-nodes-vercel-ai-sdk-universal-temp 0.3.2 → 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.
@@ -223,13 +223,25 @@ class UniversalAgent {
223
223
  case 'chat':
224
224
  return await UniversalAgent.handleChatOperation(exec, index, item);
225
225
  case 'createAgent':
226
- return await UniversalAgent.handleCreateAgentOperation(exec, index);
226
+ return await UniversalAgent.handleCreateAgentOperation(exec, index, item);
227
227
  case 'manageAgent':
228
- 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);
229
231
  case 'manageIdentity':
230
- 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);
231
243
  default:
232
- throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported operation: ${operation}`);
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`);
233
245
  }
234
246
  }
235
247
  static async handleChatOperation(exec, index, item) {
@@ -247,7 +259,7 @@ class UniversalAgent {
247
259
  const response = await client.sendMessage(agentIds, message, identity, chatOptions);
248
260
  return UniversalAgent.processChatResponse(response, index);
249
261
  }
250
- static async handleCreateAgentOperation(exec, index) {
262
+ static async handleCreateAgentOperation(exec, index, item) {
251
263
  const client = await (0, letta_1.getLettaProvider)(exec, index);
252
264
  const useJson = exec.getNodeParameter('createAgentJsonConfigMode', index, false);
253
265
  let agentConfig;
@@ -308,7 +320,7 @@ class UniversalAgent {
308
320
  },
309
321
  ];
310
322
  }
311
- static async handleManageAgentOperation(exec, index) {
323
+ static async handleManageAgentOperation(exec, index, item) {
312
324
  const client = await (0, letta_1.getLettaProvider)(exec, index);
313
325
  const operation = exec.getNodeParameter('manageAgentOperation', index);
314
326
  const agentId = exec.getNodeParameter('manageAgentId', index);
@@ -316,7 +328,7 @@ class UniversalAgent {
316
328
  throw new n8n_workflow_1.NodeOperationError(exec.getNode(), 'Agent ID is required for manage agent operation');
317
329
  }
318
330
  switch (operation) {
319
- case 'get':
331
+ case 'get': {
320
332
  const agent = await client.getAgent(agentId);
321
333
  return [
322
334
  {
@@ -332,7 +344,7 @@ class UniversalAgent {
332
344
  pairedItem: { item: index },
333
345
  },
334
346
  ];
335
- case 'update':
347
+ }
336
348
  case 'update': {
337
349
  const useJson = exec.getNodeParameter('updateAgentJsonConfigMode', index, false);
338
350
  let updateConfig;
@@ -348,37 +360,24 @@ class UniversalAgent {
348
360
  else {
349
361
  const simpleConfig = exec.getNodeParameter('updateAgentConfig', index);
350
362
  updateConfig = {
351
- name: simpleConfig.name,
352
- model: simpleConfig.model,
353
- embedding: simpleConfig.embedding,
354
- system: simpleConfig.system,
355
- agent_type: simpleConfig.agent_type,
356
- description: simpleConfig.description,
357
- include_base_tools: simpleConfig.include_base_tools,
358
- tags: simpleConfig.tags
359
- ?.split(',')
360
- .map((t) => t.trim())
361
- .filter(Boolean) || undefined,
362
- tool_ids: simpleConfig.tool_ids
363
- ?.split(',')
364
- .map((t) => t.trim())
365
- .filter(Boolean) || undefined,
366
- source_ids: simpleConfig.source_ids
367
- ?.split(',')
368
- .map((s) => s.trim())
369
- .filter(Boolean) || undefined,
370
- memory_blocks: simpleConfig.memoryBlocks?.block?.map((b) => ({
371
- label: b.label,
372
- value: b.value,
373
- })) || undefined,
374
- secrets: simpleConfig.secrets?.secret?.reduce((acc, s) => {
375
- if (s.key) {
376
- acc[s.key] = s.value;
377
- }
378
- return acc;
379
- }, {}) || 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
+ }),
380
380
  };
381
- updateConfig = Object.fromEntries(Object.entries(updateConfig).filter(([, v]) => v !== '' && v !== undefined && (!Array.isArray(v) || v.length > 0)));
382
381
  }
383
382
  const updatedAgent = await client.updateAgent(agentId, updateConfig);
384
383
  return [
@@ -394,14 +393,51 @@ class UniversalAgent {
394
393
  },
395
394
  ];
396
395
  }
397
- case 'delete':
396
+ case 'delete': {
398
397
  await client.deleteAgent(agentId);
399
- return [{ json: { agentId, deleted: true }, pairedItem: { item: index } }];
398
+ return [
399
+ {
400
+ json: {
401
+ deleted: true,
402
+ agentId,
403
+ },
404
+ pairedItem: { item: index },
405
+ },
406
+ ];
407
+ }
400
408
  default:
401
409
  throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Unsupported manage agent operation: ${operation}`);
402
410
  }
403
411
  }
404
- static async handleManageIdentityOperation(exec, index) {
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) {
405
441
  const client = await (0, letta_1.getLettaProvider)(exec, index);
406
442
  const operation = exec.getNodeParameter('manageIdentityOperation', index);
407
443
  const identifierKey = exec.getNodeParameter('identityKey', index);
@@ -445,6 +481,501 @@ class UniversalAgent {
445
481
  }
446
482
  return [];
447
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
+ }
448
979
  }
449
980
  exports.UniversalAgent = UniversalAgent;
450
981
  //# sourceMappingURL=UniversalAgent.node.js.map