langflow-mcp-server 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +90 -2
  2. package/dist/__tests__/fixtures/advanced-execution.d.ts +22 -0
  3. package/dist/__tests__/fixtures/advanced-execution.d.ts.map +1 -0
  4. package/dist/__tests__/fixtures/advanced-execution.js +77 -0
  5. package/dist/__tests__/fixtures/advanced-execution.js.map +1 -0
  6. package/dist/__tests__/fixtures/api-keys.d.ts +8 -0
  7. package/dist/__tests__/fixtures/api-keys.d.ts.map +1 -0
  8. package/dist/__tests__/fixtures/api-keys.js +38 -0
  9. package/dist/__tests__/fixtures/api-keys.js.map +1 -0
  10. package/dist/__tests__/fixtures/auth.d.ts +9 -0
  11. package/dist/__tests__/fixtures/auth.d.ts.map +1 -0
  12. package/dist/__tests__/fixtures/auth.js +26 -0
  13. package/dist/__tests__/fixtures/auth.js.map +1 -0
  14. package/dist/__tests__/fixtures/custom-components.d.ts +5 -0
  15. package/dist/__tests__/fixtures/custom-components.d.ts.map +1 -0
  16. package/dist/__tests__/fixtures/custom-components.js +49 -0
  17. package/dist/__tests__/fixtures/custom-components.js.map +1 -0
  18. package/dist/__tests__/fixtures/files.d.ts +14 -0
  19. package/dist/__tests__/fixtures/files.d.ts.map +1 -0
  20. package/dist/__tests__/fixtures/files.js +41 -0
  21. package/dist/__tests__/fixtures/files.js.map +1 -0
  22. package/dist/__tests__/fixtures/misc.d.ts +18 -0
  23. package/dist/__tests__/fixtures/misc.d.ts.map +1 -0
  24. package/dist/__tests__/fixtures/misc.js +101 -0
  25. package/dist/__tests__/fixtures/misc.js.map +1 -0
  26. package/dist/__tests__/fixtures/monitoring.d.ts +13 -0
  27. package/dist/__tests__/fixtures/monitoring.d.ts.map +1 -0
  28. package/dist/__tests__/fixtures/monitoring.js +88 -0
  29. package/dist/__tests__/fixtures/monitoring.js.map +1 -0
  30. package/dist/__tests__/fixtures/store.d.ts +18 -0
  31. package/dist/__tests__/fixtures/store.d.ts.map +1 -0
  32. package/dist/__tests__/fixtures/store.js +96 -0
  33. package/dist/__tests__/fixtures/store.js.map +1 -0
  34. package/dist/__tests__/fixtures/users.d.ts +9 -0
  35. package/dist/__tests__/fixtures/users.d.ts.map +1 -0
  36. package/dist/__tests__/fixtures/users.js +55 -0
  37. package/dist/__tests__/fixtures/users.js.map +1 -0
  38. package/dist/__tests__/fixtures/validation.d.ts +10 -0
  39. package/dist/__tests__/fixtures/validation.d.ts.map +1 -0
  40. package/dist/__tests__/fixtures/validation.js +43 -0
  41. package/dist/__tests__/fixtures/validation.js.map +1 -0
  42. package/dist/__tests__/fixtures/vertices.d.ts +29 -0
  43. package/dist/__tests__/fixtures/vertices.d.ts.map +1 -0
  44. package/dist/__tests__/fixtures/vertices.js +51 -0
  45. package/dist/__tests__/fixtures/vertices.js.map +1 -0
  46. package/dist/mcp/server.d.ts +2 -0
  47. package/dist/mcp/server.d.ts.map +1 -1
  48. package/dist/mcp/server.js +344 -5
  49. package/dist/mcp/server.js.map +1 -1
  50. package/dist/mcp/tools.d.ts.map +1 -1
  51. package/dist/mcp/tools.js +1218 -0
  52. package/dist/mcp/tools.js.map +1 -1
  53. package/dist/mcp/validation.d.ts +241 -0
  54. package/dist/mcp/validation.d.ts.map +1 -1
  55. package/dist/mcp/validation.js +211 -2
  56. package/dist/mcp/validation.js.map +1 -1
  57. package/dist/services/langflow-client.d.ts +131 -1
  58. package/dist/services/langflow-client.d.ts.map +1 -1
  59. package/dist/services/langflow-client.js +843 -1
  60. package/dist/services/langflow-client.js.map +1 -1
  61. package/dist/types/index.d.ts +226 -0
  62. package/dist/types/index.d.ts.map +1 -1
  63. package/package.json +2 -1
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LangflowClient = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
+ const form_data_1 = __importDefault(require("form-data"));
8
9
  class LangflowClient {
9
10
  constructor(config) {
10
11
  this.config = config;
@@ -349,6 +350,526 @@ class LangflowClient {
349
350
  throw this.handleError(error, 'Failed to bulk delete knowledge bases');
350
351
  }
351
352
  }
353
+ async uploadFile(params) {
354
+ try {
355
+ const formData = new form_data_1.default();
356
+ formData.append('file', params.file, params.file_name);
357
+ const response = await this.client.post(`/files/upload/${params.flow_id}`, formData, {
358
+ headers: {
359
+ ...formData.getHeaders()
360
+ }
361
+ });
362
+ return response.data;
363
+ }
364
+ catch (error) {
365
+ throw this.handleError(error, `Failed to upload file to flow ${params.flow_id}`);
366
+ }
367
+ }
368
+ async downloadFile(params) {
369
+ try {
370
+ const response = await this.client.get(`/files/download/${params.flow_id}/${params.file_name}`, {
371
+ responseType: 'arraybuffer'
372
+ });
373
+ return response.data;
374
+ }
375
+ catch (error) {
376
+ throw this.handleError(error, `Failed to download file ${params.file_name} from flow ${params.flow_id}`);
377
+ }
378
+ }
379
+ async listFiles(params) {
380
+ try {
381
+ const response = await this.client.get(`/files/list/${params.flow_id}`);
382
+ return response.data;
383
+ }
384
+ catch (error) {
385
+ throw this.handleError(error, `Failed to list files for flow ${params.flow_id}`);
386
+ }
387
+ }
388
+ async deleteFile(params) {
389
+ try {
390
+ const response = await this.client.delete(`/files/delete/${params.flow_id}/${params.file_name}`);
391
+ return response.data;
392
+ }
393
+ catch (error) {
394
+ throw this.handleError(error, `Failed to delete file ${params.file_name} from flow ${params.flow_id}`);
395
+ }
396
+ }
397
+ async getFileImage(params) {
398
+ try {
399
+ const response = await this.client.get(`/files/images/${params.flow_id}/${params.file_name}`, {
400
+ responseType: 'arraybuffer'
401
+ });
402
+ return response.data;
403
+ }
404
+ catch (error) {
405
+ throw this.handleError(error, `Failed to get image ${params.file_name} from flow ${params.flow_id}`);
406
+ }
407
+ }
408
+ async listProfilePictures() {
409
+ try {
410
+ const response = await this.client.get('/files/profile_pictures/list');
411
+ return response.data;
412
+ }
413
+ catch (error) {
414
+ throw this.handleError(error, 'Failed to list profile pictures');
415
+ }
416
+ }
417
+ async getProfilePicture(folderName, fileName) {
418
+ try {
419
+ const response = await this.client.get(`/files/profile_pictures/${folderName}/${fileName}`, {
420
+ responseType: 'arraybuffer'
421
+ });
422
+ return response.data;
423
+ }
424
+ catch (error) {
425
+ throw this.handleError(error, `Failed to get profile picture ${folderName}/${fileName}`);
426
+ }
427
+ }
428
+ async validateCode(code) {
429
+ try {
430
+ const response = await this.client.post('/validate/code', { code });
431
+ return response.data;
432
+ }
433
+ catch (error) {
434
+ throw this.handleError(error, 'Failed to validate code');
435
+ }
436
+ }
437
+ async validatePrompt(prompt) {
438
+ try {
439
+ const response = await this.client.post('/validate/prompt', { prompt });
440
+ return response.data;
441
+ }
442
+ catch (error) {
443
+ throw this.handleError(error, 'Failed to validate prompt');
444
+ }
445
+ }
446
+ async checkStore() {
447
+ try {
448
+ const response = await this.client.get('/store/check/');
449
+ return response.data;
450
+ }
451
+ catch (error) {
452
+ throw this.handleError(error, 'Failed to check store availability');
453
+ }
454
+ }
455
+ async checkStoreApiKey(apiKey) {
456
+ try {
457
+ const response = await this.client.get('/store/check/api_key', {
458
+ headers: {
459
+ 'x-store-api-key': apiKey
460
+ }
461
+ });
462
+ return response.data;
463
+ }
464
+ catch (error) {
465
+ throw this.handleError(error, 'Failed to check store API key');
466
+ }
467
+ }
468
+ async listStoreComponents(params) {
469
+ try {
470
+ const response = await this.client.get('/store/components/', { params });
471
+ return response.data;
472
+ }
473
+ catch (error) {
474
+ throw this.handleError(error, 'Failed to list store components');
475
+ }
476
+ }
477
+ async getStoreComponent(componentId) {
478
+ try {
479
+ const response = await this.client.get(`/store/components/${componentId}`);
480
+ return response.data;
481
+ }
482
+ catch (error) {
483
+ throw this.handleError(error, `Failed to get store component ${componentId}`);
484
+ }
485
+ }
486
+ async listStoreTags() {
487
+ try {
488
+ const response = await this.client.get('/store/tags');
489
+ return response.data;
490
+ }
491
+ catch (error) {
492
+ throw this.handleError(error, 'Failed to list store tags');
493
+ }
494
+ }
495
+ async getUserLikes() {
496
+ try {
497
+ const response = await this.client.get('/store/users/likes');
498
+ return response.data;
499
+ }
500
+ catch (error) {
501
+ throw this.handleError(error, 'Failed to get user likes');
502
+ }
503
+ }
504
+ async runFlowAdvanced(flowId, request, stream = false) {
505
+ try {
506
+ const response = await this.client.post(`/run/advanced/${flowId}`, {
507
+ ...request,
508
+ stream
509
+ });
510
+ return response.data;
511
+ }
512
+ catch (error) {
513
+ throw this.handleError(error, `Failed to run flow ${flowId} (advanced)`);
514
+ }
515
+ }
516
+ async processFlow(flowId, request) {
517
+ try {
518
+ const response = await this.client.post(`/process/${flowId}`, request);
519
+ return response.data;
520
+ }
521
+ catch (error) {
522
+ throw this.handleError(error, `Failed to process flow ${flowId}`);
523
+ }
524
+ }
525
+ async predictFlow(flowId, request) {
526
+ try {
527
+ const response = await this.client.post(`/predict/${flowId}`, request);
528
+ return response.data;
529
+ }
530
+ catch (error) {
531
+ throw this.handleError(error, `Failed to predict flow ${flowId}`);
532
+ }
533
+ }
534
+ async getMonitorBuilds(params) {
535
+ try {
536
+ const response = await this.client.get('/monitor/builds', { params });
537
+ return response.data;
538
+ }
539
+ catch (error) {
540
+ throw this.handleError(error, `Failed to get monitor builds for flow ${params.flow_id}`);
541
+ }
542
+ }
543
+ async getMonitorMessages(params) {
544
+ try {
545
+ const response = await this.client.get('/monitor/messages', { params });
546
+ return response.data;
547
+ }
548
+ catch (error) {
549
+ throw this.handleError(error, 'Failed to get monitor messages');
550
+ }
551
+ }
552
+ async getMonitorMessage(messageId) {
553
+ try {
554
+ const response = await this.client.get(`/monitor/messages/${messageId}`);
555
+ return response.data;
556
+ }
557
+ catch (error) {
558
+ throw this.handleError(error, `Failed to get monitor message ${messageId}`);
559
+ }
560
+ }
561
+ async getMonitorSessions(params) {
562
+ try {
563
+ const response = await this.client.get('/monitor/messages/sessions', { params });
564
+ return response.data;
565
+ }
566
+ catch (error) {
567
+ throw this.handleError(error, 'Failed to get monitor sessions');
568
+ }
569
+ }
570
+ async getMonitorSessionMessages(sessionId) {
571
+ try {
572
+ const response = await this.client.get(`/monitor/messages/session/${sessionId}`);
573
+ return response.data;
574
+ }
575
+ catch (error) {
576
+ throw this.handleError(error, `Failed to get session messages for ${sessionId}`);
577
+ }
578
+ }
579
+ async migrateMonitorSession(params) {
580
+ try {
581
+ const response = await this.client.patch(`/monitor/messages/session/${params.old_session_id}`, null, { params: { new_session_id: params.new_session_id } });
582
+ return response.data;
583
+ }
584
+ catch (error) {
585
+ throw this.handleError(error, `Failed to migrate session ${params.old_session_id}`);
586
+ }
587
+ }
588
+ async getMonitorTransactions(params) {
589
+ try {
590
+ const response = await this.client.get('/monitor/transactions', { params });
591
+ return response.data;
592
+ }
593
+ catch (error) {
594
+ throw this.handleError(error, 'Failed to get monitor transactions');
595
+ }
596
+ }
597
+ async deleteMonitorBuilds(flowId) {
598
+ try {
599
+ await this.client.delete('/monitor/builds', {
600
+ params: { flow_id: flowId }
601
+ });
602
+ }
603
+ catch (error) {
604
+ throw this.handleError(error, `Failed to delete monitor builds for flow ${flowId}`);
605
+ }
606
+ }
607
+ async deleteMonitorMessages(messageIds) {
608
+ try {
609
+ const response = await this.client.delete('/monitor/messages', { data: messageIds });
610
+ return response.data;
611
+ }
612
+ catch (error) {
613
+ throw this.handleError(error, 'Failed to delete monitor messages');
614
+ }
615
+ }
616
+ async buildVertices(flowId, request) {
617
+ try {
618
+ const response = await this.client.post(`/build/${flowId}/vertices`, request || {});
619
+ return response.data;
620
+ }
621
+ catch (error) {
622
+ throw this.handleError(error, `Failed to build vertices for flow ${flowId}`);
623
+ }
624
+ }
625
+ async getVertex(params) {
626
+ try {
627
+ const response = await this.client.get(`/build/${params.flow_id}/vertices/${params.vertex_id}`);
628
+ return response.data;
629
+ }
630
+ catch (error) {
631
+ throw this.handleError(error, `Failed to get vertex ${params.vertex_id}`);
632
+ }
633
+ }
634
+ async streamVertexBuild(params) {
635
+ try {
636
+ const response = await this.client.get(`/build/${params.flow_id}/${params.vertex_id}/stream`);
637
+ return response.data;
638
+ }
639
+ catch (error) {
640
+ throw this.handleError(error, `Failed to stream vertex build ${params.vertex_id}`);
641
+ }
642
+ }
643
+ async getVersion() {
644
+ try {
645
+ const response = await this.client.get('/version');
646
+ return response.data;
647
+ }
648
+ catch (error) {
649
+ throw this.handleError(error, 'Failed to get version');
650
+ }
651
+ }
652
+ async listUsers(params) {
653
+ try {
654
+ const response = await this.client.get('/users/', { params });
655
+ return response.data;
656
+ }
657
+ catch (error) {
658
+ throw this.handleError(error, 'Failed to list users');
659
+ }
660
+ }
661
+ async getCurrentUser() {
662
+ try {
663
+ const response = await this.client.get('/users/whoami');
664
+ return response.data;
665
+ }
666
+ catch (error) {
667
+ throw this.handleError(error, 'Failed to get current user');
668
+ }
669
+ }
670
+ async getUser(userId) {
671
+ try {
672
+ const response = await this.client.get(`/users/${userId}`);
673
+ return response.data;
674
+ }
675
+ catch (error) {
676
+ throw this.handleError(error, `Failed to get user ${userId}`);
677
+ }
678
+ }
679
+ async updateUser(userId, updates) {
680
+ try {
681
+ const response = await this.client.patch(`/users/${userId}`, updates);
682
+ return response.data;
683
+ }
684
+ catch (error) {
685
+ throw this.handleError(error, `Failed to update user ${userId}`);
686
+ }
687
+ }
688
+ async resetUserPassword(userId, newPassword) {
689
+ try {
690
+ const response = await this.client.patch(`/users/${userId}/reset-password`, {
691
+ password: newPassword
692
+ });
693
+ return response.data;
694
+ }
695
+ catch (error) {
696
+ throw this.handleError(error, `Failed to reset password for user ${userId}`);
697
+ }
698
+ }
699
+ async listApiKeys() {
700
+ try {
701
+ const response = await this.client.get('/api_key/');
702
+ return response.data;
703
+ }
704
+ catch (error) {
705
+ throw this.handleError(error, 'Failed to list API keys');
706
+ }
707
+ }
708
+ async createApiKey(name) {
709
+ try {
710
+ const response = await this.client.post('/api_key/', { name });
711
+ return response.data;
712
+ }
713
+ catch (error) {
714
+ throw this.handleError(error, 'Failed to create API key');
715
+ }
716
+ }
717
+ async deleteApiKey(apiKeyId) {
718
+ try {
719
+ await this.client.delete(`/api_key/${apiKeyId}`);
720
+ }
721
+ catch (error) {
722
+ throw this.handleError(error, `Failed to delete API key ${apiKeyId}`);
723
+ }
724
+ }
725
+ async listCustomComponents() {
726
+ try {
727
+ const response = await this.client.get('/custom_component');
728
+ return response.data;
729
+ }
730
+ catch (error) {
731
+ throw this.handleError(error, 'Failed to list custom components');
732
+ }
733
+ }
734
+ async createCustomComponent(component) {
735
+ try {
736
+ const response = await this.client.post('/custom_component', component);
737
+ return response.data;
738
+ }
739
+ catch (error) {
740
+ throw this.handleError(error, 'Failed to create custom component');
741
+ }
742
+ }
743
+ async login(username, password) {
744
+ try {
745
+ const formData = new URLSearchParams();
746
+ formData.append('username', username);
747
+ formData.append('password', password);
748
+ const response = await this.client.post('/login', formData, {
749
+ headers: {
750
+ 'Content-Type': 'application/x-www-form-urlencoded'
751
+ }
752
+ });
753
+ return response.data;
754
+ }
755
+ catch (error) {
756
+ throw this.handleError(error, 'Failed to login');
757
+ }
758
+ }
759
+ async autoLogin() {
760
+ try {
761
+ const response = await this.client.get('/auto_login');
762
+ return response.data;
763
+ }
764
+ catch (error) {
765
+ throw this.handleError(error, 'Failed to auto login');
766
+ }
767
+ }
768
+ async refreshToken() {
769
+ try {
770
+ const response = await this.client.post('/refresh');
771
+ return response.data;
772
+ }
773
+ catch (error) {
774
+ throw this.handleError(error, 'Failed to refresh token');
775
+ }
776
+ }
777
+ async logout() {
778
+ try {
779
+ const response = await this.client.post('/logout');
780
+ return response.data;
781
+ }
782
+ catch (error) {
783
+ throw this.handleError(error, 'Failed to logout');
784
+ }
785
+ }
786
+ async getPublicFlow(flowId) {
787
+ try {
788
+ const response = await this.client.get(`/flows/public_flow/${flowId}`);
789
+ return response.data;
790
+ }
791
+ catch (error) {
792
+ throw this.handleError(error, `Failed to get public flow ${flowId}`);
793
+ }
794
+ }
795
+ async batchCreateFlows(flows) {
796
+ try {
797
+ const response = await this.client.post('/flows/batch/', flows);
798
+ return response.data;
799
+ }
800
+ catch (error) {
801
+ throw this.handleError(error, 'Failed to batch create flows');
802
+ }
803
+ }
804
+ async getTaskStatus(taskId) {
805
+ try {
806
+ const response = await this.client.get(`/task/${taskId}`);
807
+ return response.data;
808
+ }
809
+ catch (error) {
810
+ throw this.handleError(error, `Failed to get task status ${taskId}`);
811
+ }
812
+ }
813
+ async downloadFolder(folderId) {
814
+ try {
815
+ const response = await this.client.get(`/folders/download/${folderId}`, {
816
+ responseType: 'arraybuffer'
817
+ });
818
+ return response.data;
819
+ }
820
+ catch (error) {
821
+ throw this.handleError(error, `Failed to download folder ${folderId}`);
822
+ }
823
+ }
824
+ async uploadFolder(fileContent, fileName) {
825
+ try {
826
+ const formData = new form_data_1.default();
827
+ formData.append('file', fileContent, fileName);
828
+ const response = await this.client.post('/folders/upload/', formData, {
829
+ headers: {
830
+ ...formData.getHeaders()
831
+ }
832
+ });
833
+ return response.data;
834
+ }
835
+ catch (error) {
836
+ throw this.handleError(error, 'Failed to upload folder');
837
+ }
838
+ }
839
+ async listStarterProjects() {
840
+ try {
841
+ const response = await this.client.get('/starter-projects/');
842
+ return response.data;
843
+ }
844
+ catch (error) {
845
+ throw this.handleError(error, 'Failed to list starter projects');
846
+ }
847
+ }
848
+ async uploadKnowledgeBase(kbName, fileContent, fileName) {
849
+ try {
850
+ const formData = new form_data_1.default();
851
+ formData.append('file', fileContent, fileName);
852
+ const response = await this.client.post('/knowledge_bases/', formData, {
853
+ params: { kb_name: kbName },
854
+ headers: {
855
+ ...formData.getHeaders()
856
+ }
857
+ });
858
+ return response.data;
859
+ }
860
+ catch (error) {
861
+ throw this.handleError(error, `Failed to upload knowledge base ${kbName}`);
862
+ }
863
+ }
864
+ async listElevenLabsVoices() {
865
+ try {
866
+ const response = await this.client.get('/voice/elevenlabs/voice_ids');
867
+ return response.data;
868
+ }
869
+ catch (error) {
870
+ throw this.handleError(error, 'Failed to list ElevenLabs voices');
871
+ }
872
+ }
352
873
  async healthCheck() {
353
874
  try {
354
875
  await this.client.get('/health');
@@ -358,12 +879,333 @@ class LangflowClient {
358
879
  return false;
359
880
  }
360
881
  }
882
+ async getLogs(stream = false) {
883
+ try {
884
+ const endpoint = stream ? '/logs-stream' : '/logs';
885
+ const response = await this.client.get(endpoint, {
886
+ responseType: stream ? 'stream' : 'json'
887
+ });
888
+ return response.data;
889
+ }
890
+ catch (error) {
891
+ throw this.handleError(error, 'Failed to get logs');
892
+ }
893
+ }
894
+ async getMonitorMessageById(messageId) {
895
+ try {
896
+ const response = await this.client.get(`/monitor/messages/${messageId}`);
897
+ return response.data;
898
+ }
899
+ catch (error) {
900
+ throw this.handleError(error, 'Failed to get monitor message');
901
+ }
902
+ }
903
+ async getMonitorTransactionById(transactionId) {
904
+ try {
905
+ const response = await this.client.get(`/monitor/transactions/${transactionId}`);
906
+ return response.data;
907
+ }
908
+ catch (error) {
909
+ throw this.handleError(error, 'Failed to get monitor transaction');
910
+ }
911
+ }
912
+ async getMonitorVertexBuilds(params) {
913
+ try {
914
+ const response = await this.client.get('/monitor/vertices/builds', { params });
915
+ return response.data;
916
+ }
917
+ catch (error) {
918
+ throw this.handleError(error, 'Failed to get monitor vertex builds');
919
+ }
920
+ }
921
+ async getMonitorVertexBuildById(vertexBuildId) {
922
+ try {
923
+ const response = await this.client.get(`/monitor/vertices/builds/${vertexBuildId}`);
924
+ return response.data;
925
+ }
926
+ catch (error) {
927
+ throw this.handleError(error, 'Failed to get monitor vertex build');
928
+ }
929
+ }
930
+ async uploadTextData(params) {
931
+ try {
932
+ const response = await this.client.post(`/files/upload/${params.flow_id}/text`, {
933
+ text: params.text_data,
934
+ file_name: params.file_name
935
+ });
936
+ return response.data;
937
+ }
938
+ catch (error) {
939
+ throw this.handleError(error, `Failed to upload text data to flow ${params.flow_id}`);
940
+ }
941
+ }
942
+ async installStoreComponent(componentId) {
943
+ try {
944
+ const response = await this.client.post(`/store/components/${componentId}/install`);
945
+ return response.data;
946
+ }
947
+ catch (error) {
948
+ throw this.handleError(error, `Failed to install store component ${componentId}`);
949
+ }
950
+ }
951
+ async updateCustomComponent(componentId, updates) {
952
+ try {
953
+ const response = await this.client.patch(`/custom_component/${componentId}`, updates);
954
+ return response.data;
955
+ }
956
+ catch (error) {
957
+ throw this.handleError(error, `Failed to update custom component ${componentId}`);
958
+ }
959
+ }
960
+ async deleteCustomComponent(componentId) {
961
+ try {
962
+ await this.client.delete(`/custom_component/${componentId}`);
963
+ }
964
+ catch (error) {
965
+ throw this.handleError(error, `Failed to delete custom component ${componentId}`);
966
+ }
967
+ }
968
+ async deleteUser(userId) {
969
+ try {
970
+ await this.client.delete(`/users/${userId}`);
971
+ }
972
+ catch (error) {
973
+ throw this.handleError(error, `Failed to delete user ${userId}`);
974
+ }
975
+ }
976
+ async getConfig() {
977
+ try {
978
+ const response = await this.client.get('/config');
979
+ return response.data;
980
+ }
981
+ catch (error) {
982
+ throw this.handleError(error, 'Failed to get configuration');
983
+ }
984
+ }
985
+ async updateConfig(config) {
986
+ try {
987
+ const response = await this.client.patch('/config', config);
988
+ return response.data;
989
+ }
990
+ catch (error) {
991
+ throw this.handleError(error, 'Failed to update configuration');
992
+ }
993
+ }
994
+ async getStats() {
995
+ try {
996
+ const response = await this.client.get('/stats');
997
+ return response.data;
998
+ }
999
+ catch (error) {
1000
+ throw this.handleError(error, 'Failed to get statistics');
1001
+ }
1002
+ }
1003
+ async exportFlow(flowId) {
1004
+ try {
1005
+ const response = await this.client.get(`/flows/${flowId}/export`);
1006
+ return response.data;
1007
+ }
1008
+ catch (error) {
1009
+ throw this.handleError(error, `Failed to export flow ${flowId}`);
1010
+ }
1011
+ }
1012
+ async importFlow(flowData) {
1013
+ try {
1014
+ const response = await this.client.post('/flows/import', flowData);
1015
+ return response.data;
1016
+ }
1017
+ catch (error) {
1018
+ throw this.handleError(error, 'Failed to import flow');
1019
+ }
1020
+ }
1021
+ async cloneFlow(flowId, name) {
1022
+ try {
1023
+ const response = await this.client.post(`/flows/${flowId}/clone`, { name });
1024
+ return response.data;
1025
+ }
1026
+ catch (error) {
1027
+ throw this.handleError(error, `Failed to clone flow ${flowId}`);
1028
+ }
1029
+ }
1030
+ async getFlowDependencies(flowId) {
1031
+ try {
1032
+ const response = await this.client.get(`/flows/${flowId}/dependencies`);
1033
+ return response.data;
1034
+ }
1035
+ catch (error) {
1036
+ throw this.handleError(error, `Failed to get flow dependencies ${flowId}`);
1037
+ }
1038
+ }
1039
+ async getAiNodes() {
1040
+ try {
1041
+ const response = await this.client.get('/ai_nodes');
1042
+ return response.data;
1043
+ }
1044
+ catch (error) {
1045
+ throw this.handleError(error, 'Failed to get AI nodes');
1046
+ }
1047
+ }
1048
+ async buildVertex(params) {
1049
+ try {
1050
+ const response = await this.client.post(`/build/${params.flow_id}/vertices/${params.vertex_id}`, params.inputs || {});
1051
+ return response.data;
1052
+ }
1053
+ catch (error) {
1054
+ throw this.handleError(error, `Failed to build vertex ${params.vertex_id}`);
1055
+ }
1056
+ }
1057
+ async cancelExecution(params) {
1058
+ try {
1059
+ const response = await this.client.post(`/executions/${params.execution_id}/cancel`);
1060
+ return response.data;
1061
+ }
1062
+ catch (error) {
1063
+ throw this.handleError(error, `Failed to cancel execution ${params.execution_id}`);
1064
+ }
1065
+ }
1066
+ async getExecutionResult(params) {
1067
+ try {
1068
+ const response = await this.client.get(`/executions/${params.execution_id}/result`);
1069
+ return response.data;
1070
+ }
1071
+ catch (error) {
1072
+ throw this.handleError(error, `Failed to get execution result ${params.execution_id}`);
1073
+ }
1074
+ }
1075
+ async getFileMetadata(params) {
1076
+ try {
1077
+ const response = await this.client.get(`/files/${params.flow_id}/${params.file_name}/metadata`);
1078
+ return response.data;
1079
+ }
1080
+ catch (error) {
1081
+ throw this.handleError(error, `Failed to get file metadata ${params.file_name}`);
1082
+ }
1083
+ }
1084
+ async getHealth() {
1085
+ try {
1086
+ const response = await this.client.get('/health');
1087
+ return response.data;
1088
+ }
1089
+ catch (error) {
1090
+ throw this.handleError(error, 'Failed to get health status');
1091
+ }
1092
+ }
1093
+ async getUserById(userId) {
1094
+ try {
1095
+ const response = await this.client.get(`/users/${userId}`);
1096
+ return response.data;
1097
+ }
1098
+ catch (error) {
1099
+ throw this.handleError(error, `Failed to get user ${userId}`);
1100
+ }
1101
+ }
1102
+ async listFilesDetailed(params) {
1103
+ try {
1104
+ const response = await this.client.get(`/files/${params.flow_id}/detailed`);
1105
+ return response.data;
1106
+ }
1107
+ catch (error) {
1108
+ throw this.handleError(error, `Failed to get detailed file list for flow ${params.flow_id}`);
1109
+ }
1110
+ }
1111
+ async register(username, password, email) {
1112
+ try {
1113
+ const response = await this.client.post('/register', {
1114
+ username,
1115
+ password,
1116
+ email
1117
+ });
1118
+ return response.data;
1119
+ }
1120
+ catch (error) {
1121
+ throw this.handleError(error, 'Failed to register user');
1122
+ }
1123
+ }
1124
+ async runAdvancedExecution(params) {
1125
+ try {
1126
+ const { flow_id, ...request } = params;
1127
+ const response = await this.client.post(`/executions/${flow_id}/advanced`, request);
1128
+ return response.data;
1129
+ }
1130
+ catch (error) {
1131
+ throw this.handleError(error, `Failed to execute advanced flow ${params.flow_id}`);
1132
+ }
1133
+ }
1134
+ async searchStoreComponents(query, params) {
1135
+ try {
1136
+ const response = await this.client.get('/store/components/search', {
1137
+ params: { q: query, ...params }
1138
+ });
1139
+ return response.data;
1140
+ }
1141
+ catch (error) {
1142
+ throw this.handleError(error, 'Failed to search store components');
1143
+ }
1144
+ }
1145
+ async uninstallStoreComponent(componentId) {
1146
+ try {
1147
+ const response = await this.client.delete(`/store/components/${componentId}/uninstall`);
1148
+ return response.data;
1149
+ }
1150
+ catch (error) {
1151
+ throw this.handleError(error, `Failed to uninstall store component ${componentId}`);
1152
+ }
1153
+ }
1154
+ async updateStoreComponent(componentId, updates) {
1155
+ try {
1156
+ const response = await this.client.patch(`/store/components/${componentId}`, updates);
1157
+ return response.data;
1158
+ }
1159
+ catch (error) {
1160
+ throw this.handleError(error, `Failed to update store component ${componentId}`);
1161
+ }
1162
+ }
1163
+ async validateConnection(connectionData) {
1164
+ try {
1165
+ const response = await this.client.post('/validate/connection', connectionData);
1166
+ return response.data;
1167
+ }
1168
+ catch (error) {
1169
+ throw this.handleError(error, 'Failed to validate connection');
1170
+ }
1171
+ }
1172
+ async validateFlow(params) {
1173
+ try {
1174
+ const response = await this.client.post(`/flows/${params.flow_id}/validate`);
1175
+ return response.data;
1176
+ }
1177
+ catch (error) {
1178
+ throw this.handleError(error, `Failed to validate flow ${params.flow_id}`);
1179
+ }
1180
+ }
361
1181
  handleError(error, message) {
362
1182
  if (axios_1.default.isAxiosError(error)) {
363
1183
  const axiosError = error;
364
1184
  const status = axiosError.response?.status;
365
1185
  const data = axiosError.response?.data;
366
- return new Error(`${message}: ${status ? `HTTP ${status}` : 'Network error'} - ${data ? JSON.stringify(data) : axiosError.message}`);
1186
+ const sanitize = (val, depth = 0, seen = new WeakSet()) => {
1187
+ const MAX_DEPTH = 10;
1188
+ const SENSITIVE_KEYS = new Set([
1189
+ 'authorization', 'api_key', 'x-api-key', 'password', 'new_password', 'token',
1190
+ 'access_token', 'refresh_token', 'secret', 'api-key',
1191
+ 'bearer', 'private_key', 'session_id', 'cookie', 'set-cookie',
1192
+ 'x-store-api-key'
1193
+ ]);
1194
+ if (!val || typeof val !== 'object')
1195
+ return val;
1196
+ if (depth > MAX_DEPTH)
1197
+ return '[max depth exceeded]';
1198
+ if (Buffer.isBuffer(val) || val instanceof ArrayBuffer)
1199
+ return '[binary data]';
1200
+ if (seen.has(val))
1201
+ return '[circular reference]';
1202
+ seen.add(val);
1203
+ if (Array.isArray(val))
1204
+ return val.map(v => sanitize(v, depth + 1, seen));
1205
+ return Object.fromEntries(Object.entries(val).map(([k, v]) => [k, SENSITIVE_KEYS.has(k.toLowerCase()) ? '***REDACTED***' : sanitize(v, depth + 1, seen)]));
1206
+ };
1207
+ const safeData = data ? sanitize(data) : undefined;
1208
+ return new Error(`${message}: ${status ? `HTTP ${status}` : 'Network error'} - ${safeData ? JSON.stringify(safeData) : axiosError.message}`);
367
1209
  }
368
1210
  if (error instanceof Error) {
369
1211
  return new Error(`${message}: ${error.message}`);