@23blocks/block-jarvis 1.0.4 → 2.1.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 (80) hide show
  1. package/dist/index.esm.js +1610 -80
  2. package/dist/src/index.d.ts +4 -4
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/lib/jarvis.block.d.ts +13 -1
  5. package/dist/src/lib/jarvis.block.d.ts.map +1 -1
  6. package/dist/src/lib/mappers/ai-model.mapper.d.ts +4 -0
  7. package/dist/src/lib/mappers/ai-model.mapper.d.ts.map +1 -0
  8. package/dist/src/lib/mappers/cluster.mapper.d.ts +4 -0
  9. package/dist/src/lib/mappers/cluster.mapper.d.ts.map +1 -0
  10. package/dist/src/lib/mappers/comment.mapper.d.ts +5 -0
  11. package/dist/src/lib/mappers/comment.mapper.d.ts.map +1 -0
  12. package/dist/src/lib/mappers/entity.mapper.d.ts +4 -0
  13. package/dist/src/lib/mappers/entity.mapper.d.ts.map +1 -0
  14. package/dist/src/lib/mappers/index.d.ts +9 -0
  15. package/dist/src/lib/mappers/index.d.ts.map +1 -1
  16. package/dist/src/lib/mappers/mail-template.mapper.d.ts +4 -0
  17. package/dist/src/lib/mappers/mail-template.mapper.d.ts.map +1 -0
  18. package/dist/src/lib/mappers/user.mapper.d.ts +4 -0
  19. package/dist/src/lib/mappers/user.mapper.d.ts.map +1 -0
  20. package/dist/src/lib/mappers/workflow-instance.mapper.d.ts +4 -0
  21. package/dist/src/lib/mappers/workflow-instance.mapper.d.ts.map +1 -0
  22. package/dist/src/lib/mappers/workflow-participant.mapper.d.ts +4 -0
  23. package/dist/src/lib/mappers/workflow-participant.mapper.d.ts.map +1 -0
  24. package/dist/src/lib/mappers/workflow-step.mapper.d.ts +4 -0
  25. package/dist/src/lib/mappers/workflow-step.mapper.d.ts.map +1 -0
  26. package/dist/src/lib/services/agent-runtime.service.d.ts +22 -0
  27. package/dist/src/lib/services/agent-runtime.service.d.ts.map +1 -0
  28. package/dist/src/lib/services/agents.service.d.ts.map +1 -1
  29. package/dist/src/lib/services/ai-models.service.d.ts +13 -0
  30. package/dist/src/lib/services/ai-models.service.d.ts.map +1 -0
  31. package/dist/src/lib/services/clusters.service.d.ts +20 -0
  32. package/dist/src/lib/services/clusters.service.d.ts.map +1 -0
  33. package/dist/src/lib/services/conversations.service.d.ts.map +1 -1
  34. package/dist/src/lib/services/entities.service.d.ts +19 -0
  35. package/dist/src/lib/services/entities.service.d.ts.map +1 -0
  36. package/dist/src/lib/services/execution-comments.service.d.ts +20 -0
  37. package/dist/src/lib/services/execution-comments.service.d.ts.map +1 -0
  38. package/dist/src/lib/services/index.d.ts +12 -0
  39. package/dist/src/lib/services/index.d.ts.map +1 -1
  40. package/dist/src/lib/services/mail-templates.service.d.ts +16 -0
  41. package/dist/src/lib/services/mail-templates.service.d.ts.map +1 -0
  42. package/dist/src/lib/services/marvin-chat.service.d.ts +14 -0
  43. package/dist/src/lib/services/marvin-chat.service.d.ts.map +1 -0
  44. package/dist/src/lib/services/prompt-comments.service.d.ts +20 -0
  45. package/dist/src/lib/services/prompt-comments.service.d.ts.map +1 -0
  46. package/dist/src/lib/services/prompts.service.d.ts.map +1 -1
  47. package/dist/src/lib/services/users.service.d.ts +21 -0
  48. package/dist/src/lib/services/users.service.d.ts.map +1 -0
  49. package/dist/src/lib/services/workflow-instances.service.d.ts +15 -0
  50. package/dist/src/lib/services/workflow-instances.service.d.ts.map +1 -0
  51. package/dist/src/lib/services/workflow-participants.service.d.ts +13 -0
  52. package/dist/src/lib/services/workflow-participants.service.d.ts.map +1 -0
  53. package/dist/src/lib/services/workflow-steps.service.d.ts +14 -0
  54. package/dist/src/lib/services/workflow-steps.service.d.ts.map +1 -0
  55. package/dist/src/lib/services/workflows.service.d.ts.map +1 -1
  56. package/dist/src/lib/types/agent-runtime.d.ts +115 -0
  57. package/dist/src/lib/types/agent-runtime.d.ts.map +1 -0
  58. package/dist/src/lib/types/ai-model.d.ts +48 -0
  59. package/dist/src/lib/types/ai-model.d.ts.map +1 -0
  60. package/dist/src/lib/types/cluster.d.ts +70 -0
  61. package/dist/src/lib/types/cluster.d.ts.map +1 -0
  62. package/dist/src/lib/types/comment.d.ts +83 -0
  63. package/dist/src/lib/types/comment.d.ts.map +1 -0
  64. package/dist/src/lib/types/entity.d.ts +79 -0
  65. package/dist/src/lib/types/entity.d.ts.map +1 -0
  66. package/dist/src/lib/types/index.d.ts +11 -0
  67. package/dist/src/lib/types/index.d.ts.map +1 -1
  68. package/dist/src/lib/types/mail-template.d.ts +69 -0
  69. package/dist/src/lib/types/mail-template.d.ts.map +1 -0
  70. package/dist/src/lib/types/marvin-chat.d.ts +51 -0
  71. package/dist/src/lib/types/marvin-chat.d.ts.map +1 -0
  72. package/dist/src/lib/types/user.d.ts +78 -0
  73. package/dist/src/lib/types/user.d.ts.map +1 -0
  74. package/dist/src/lib/types/workflow-instance.d.ts +61 -0
  75. package/dist/src/lib/types/workflow-instance.d.ts.map +1 -0
  76. package/dist/src/lib/types/workflow-participant.d.ts +38 -0
  77. package/dist/src/lib/types/workflow-participant.d.ts.map +1 -0
  78. package/dist/src/lib/types/workflow-step.d.ts +44 -0
  79. package/dist/src/lib/types/workflow-step.d.ts.map +1 -0
  80. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -124,39 +124,33 @@ function createAgentsService(transport, _config) {
124
124
  },
125
125
  async create (data) {
126
126
  const response = await transport.post('/agents', {
127
- data: {
128
- type: 'Agent',
129
- attributes: {
130
- code: data.code,
131
- name: data.name,
132
- description: data.description,
133
- system_prompt: data.systemPrompt,
134
- model: data.model,
135
- temperature: data.temperature,
136
- max_tokens: data.maxTokens,
137
- tools: data.tools,
138
- payload: data.payload
139
- }
127
+ agent: {
128
+ code: data.code,
129
+ name: data.name,
130
+ description: data.description,
131
+ system_prompt: data.systemPrompt,
132
+ model: data.model,
133
+ temperature: data.temperature,
134
+ max_tokens: data.maxTokens,
135
+ tools: data.tools,
136
+ payload: data.payload
140
137
  }
141
138
  });
142
139
  return decodeOne(response, agentMapper);
143
140
  },
144
141
  async update (uniqueId, data) {
145
142
  const response = await transport.put(`/agents/${uniqueId}`, {
146
- data: {
147
- type: 'Agent',
148
- attributes: {
149
- name: data.name,
150
- description: data.description,
151
- system_prompt: data.systemPrompt,
152
- model: data.model,
153
- temperature: data.temperature,
154
- max_tokens: data.maxTokens,
155
- tools: data.tools,
156
- enabled: data.enabled,
157
- status: data.status,
158
- payload: data.payload
159
- }
143
+ agent: {
144
+ name: data.name,
145
+ description: data.description,
146
+ system_prompt: data.systemPrompt,
147
+ model: data.model,
148
+ temperature: data.temperature,
149
+ max_tokens: data.maxTokens,
150
+ tools: data.tools,
151
+ enabled: data.enabled,
152
+ status: data.status,
153
+ payload: data.payload
160
154
  }
161
155
  });
162
156
  return decodeOne(response, agentMapper);
@@ -236,34 +230,28 @@ function createPromptsService(transport, _config) {
236
230
  },
237
231
  async create (data) {
238
232
  const response = await transport.post('/prompts', {
239
- data: {
240
- type: 'Prompt',
241
- attributes: {
242
- agent_unique_id: data.agentUniqueId,
243
- code: data.code,
244
- name: data.name,
245
- description: data.description,
246
- template: data.template,
247
- variables: data.variables,
248
- payload: data.payload
249
- }
233
+ prompt: {
234
+ agent_unique_id: data.agentUniqueId,
235
+ code: data.code,
236
+ name: data.name,
237
+ description: data.description,
238
+ template: data.template,
239
+ variables: data.variables,
240
+ payload: data.payload
250
241
  }
251
242
  });
252
243
  return decodeOne(response, promptMapper);
253
244
  },
254
245
  async update (uniqueId, data) {
255
246
  const response = await transport.put(`/prompts/${uniqueId}`, {
256
- data: {
257
- type: 'Prompt',
258
- attributes: {
259
- name: data.name,
260
- description: data.description,
261
- template: data.template,
262
- variables: data.variables,
263
- enabled: data.enabled,
264
- status: data.status,
265
- payload: data.payload
266
- }
247
+ prompt: {
248
+ name: data.name,
249
+ description: data.description,
250
+ template: data.template,
251
+ variables: data.variables,
252
+ enabled: data.enabled,
253
+ status: data.status,
254
+ payload: data.payload
267
255
  }
268
256
  });
269
257
  return decodeOne(response, promptMapper);
@@ -338,33 +326,27 @@ function createWorkflowsService(transport, _config) {
338
326
  },
339
327
  async create (data) {
340
328
  const response = await transport.post('/workflows', {
341
- data: {
342
- type: 'Workflow',
343
- attributes: {
344
- code: data.code,
345
- name: data.name,
346
- description: data.description,
347
- steps: data.steps,
348
- triggers: data.triggers,
349
- payload: data.payload
350
- }
329
+ workflow: {
330
+ code: data.code,
331
+ name: data.name,
332
+ description: data.description,
333
+ steps: data.steps,
334
+ triggers: data.triggers,
335
+ payload: data.payload
351
336
  }
352
337
  });
353
338
  return decodeOne(response, workflowMapper);
354
339
  },
355
340
  async update (uniqueId, data) {
356
341
  const response = await transport.put(`/workflows/${uniqueId}`, {
357
- data: {
358
- type: 'Workflow',
359
- attributes: {
360
- name: data.name,
361
- description: data.description,
362
- steps: data.steps,
363
- triggers: data.triggers,
364
- enabled: data.enabled,
365
- status: data.status,
366
- payload: data.payload
367
- }
342
+ workflow: {
343
+ name: data.name,
344
+ description: data.description,
345
+ steps: data.steps,
346
+ triggers: data.triggers,
347
+ enabled: data.enabled,
348
+ status: data.status,
349
+ payload: data.payload
368
350
  }
369
351
  });
370
352
  return decodeOne(response, workflowMapper);
@@ -511,14 +493,11 @@ function createConversationsService(transport, _config) {
511
493
  },
512
494
  async create (data) {
513
495
  const response = await transport.post('/conversations', {
514
- data: {
515
- type: 'Conversation',
516
- attributes: {
517
- agent_unique_id: data.agentUniqueId,
518
- user_unique_id: data.userUniqueId,
519
- title: data.title,
520
- payload: data.payload
521
- }
496
+ conversation: {
497
+ agent_unique_id: data.agentUniqueId,
498
+ user_unique_id: data.userUniqueId,
499
+ title: data.title,
500
+ payload: data.payload
522
501
  }
523
502
  });
524
503
  return decodeOne(response, conversationMapper);
@@ -566,13 +545,1564 @@ function createConversationsService(transport, _config) {
566
545
  };
567
546
  }
568
547
 
548
+ const aiModelMapper = {
549
+ type: 'ai_model',
550
+ map: (resource)=>{
551
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13;
552
+ return {
553
+ id: resource.id,
554
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
555
+ code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
556
+ name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
557
+ provider: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['provider'],
558
+ modelId: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['model_id'],
559
+ description: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['description'],
560
+ inputTokenCost: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['input_token_cost'],
561
+ outputTokenCost: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['output_token_cost'],
562
+ maxTokens: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['max_tokens'],
563
+ enabled: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['enabled'],
564
+ status: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['status'],
565
+ payload: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['payload'],
566
+ createdAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['created_at']),
567
+ updatedAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['updated_at'])
568
+ };
569
+ }
570
+ };
571
+
572
+ function createAIModelsService(transport, _config) {
573
+ return {
574
+ async list (params) {
575
+ const queryParams = {};
576
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
577
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
578
+ if (params == null ? void 0 : params.provider) queryParams['provider'] = params.provider;
579
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
580
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
581
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
582
+ const response = await transport.get('/ai_models', {
583
+ params: queryParams
584
+ });
585
+ return decodePageResult(response, aiModelMapper);
586
+ },
587
+ async get (uniqueId) {
588
+ const response = await transport.get(`/ai_models/${uniqueId}`);
589
+ return decodeOne(response, aiModelMapper);
590
+ },
591
+ async create (data) {
592
+ const response = await transport.post('/ai_models', {
593
+ ai_model: {
594
+ code: data.code,
595
+ name: data.name,
596
+ provider: data.provider,
597
+ model_id: data.modelId,
598
+ description: data.description,
599
+ input_token_cost: data.inputTokenCost,
600
+ output_token_cost: data.outputTokenCost,
601
+ max_tokens: data.maxTokens,
602
+ payload: data.payload
603
+ }
604
+ });
605
+ return decodeOne(response, aiModelMapper);
606
+ },
607
+ async update (uniqueId, data) {
608
+ const response = await transport.put(`/ai_models/${uniqueId}`, {
609
+ ai_model: {
610
+ name: data.name,
611
+ description: data.description,
612
+ input_token_cost: data.inputTokenCost,
613
+ output_token_cost: data.outputTokenCost,
614
+ max_tokens: data.maxTokens,
615
+ enabled: data.enabled,
616
+ status: data.status,
617
+ payload: data.payload
618
+ }
619
+ });
620
+ return decodeOne(response, aiModelMapper);
621
+ },
622
+ async delete (uniqueId) {
623
+ await transport.delete(`/ai_models/${uniqueId}`);
624
+ }
625
+ };
626
+ }
627
+
628
+ const entityMapper = {
629
+ type: 'entity',
630
+ map: (resource)=>{
631
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10;
632
+ return {
633
+ id: resource.id,
634
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
635
+ code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
636
+ name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
637
+ description: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['description'],
638
+ systemPrompt: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['system_prompt'],
639
+ model: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['model'],
640
+ enabled: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['enabled'],
641
+ status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
642
+ payload: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['payload'],
643
+ createdAt: parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['created_at']),
644
+ updatedAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['updated_at'])
645
+ };
646
+ }
647
+ };
648
+
649
+ function createEntitiesService(transport, _config) {
650
+ return {
651
+ async list (params) {
652
+ const queryParams = {};
653
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
654
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
655
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
656
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
657
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
658
+ const response = await transport.get('/entities', {
659
+ params: queryParams
660
+ });
661
+ return decodePageResult(response, entityMapper);
662
+ },
663
+ async get (uniqueId) {
664
+ const response = await transport.get(`/entities/${uniqueId}`);
665
+ return decodeOne(response, entityMapper);
666
+ },
667
+ async register (uniqueId, data) {
668
+ const response = await transport.post(`/entities/${uniqueId}/register`, {
669
+ entity: {
670
+ code: data == null ? void 0 : data.code,
671
+ name: data == null ? void 0 : data.name,
672
+ description: data == null ? void 0 : data.description,
673
+ system_prompt: data == null ? void 0 : data.systemPrompt,
674
+ model: data == null ? void 0 : data.model,
675
+ payload: data == null ? void 0 : data.payload
676
+ }
677
+ });
678
+ return decodeOne(response, entityMapper);
679
+ },
680
+ async update (uniqueId, data) {
681
+ const response = await transport.put(`/entities/${uniqueId}`, {
682
+ entity: {
683
+ name: data.name,
684
+ description: data.description,
685
+ system_prompt: data.systemPrompt,
686
+ model: data.model,
687
+ enabled: data.enabled,
688
+ status: data.status,
689
+ payload: data.payload
690
+ }
691
+ });
692
+ return decodeOne(response, entityMapper);
693
+ },
694
+ async delete (uniqueId) {
695
+ await transport.delete(`/entities/${uniqueId}`);
696
+ },
697
+ async addPrompt (uniqueId, promptUniqueId) {
698
+ await transport.post(`/entities/${uniqueId}/prompts`, {
699
+ prompt_unique_id: promptUniqueId
700
+ });
701
+ },
702
+ async getContext (uniqueId, contextUniqueId) {
703
+ const response = await transport.get(`/entities/${uniqueId}/contexts/${contextUniqueId}`);
704
+ return {
705
+ id: response.id,
706
+ uniqueId: response.unique_id,
707
+ entityUniqueId: response.entity_unique_id,
708
+ messages: (response.messages || []).map((m)=>({
709
+ role: m.role,
710
+ content: m.content,
711
+ timestamp: new Date(m.timestamp),
712
+ payload: m.payload
713
+ })),
714
+ payload: response.payload,
715
+ createdAt: new Date(response.created_at),
716
+ updatedAt: new Date(response.updated_at)
717
+ };
718
+ },
719
+ async createContext (uniqueId, data) {
720
+ const response = await transport.post(`/entities/${uniqueId}/contexts`, {
721
+ system_prompt: data == null ? void 0 : data.systemPrompt,
722
+ payload: data == null ? void 0 : data.payload
723
+ });
724
+ return {
725
+ id: response.id,
726
+ uniqueId: response.unique_id,
727
+ entityUniqueId: response.entity_unique_id,
728
+ messages: [],
729
+ payload: response.payload,
730
+ createdAt: new Date(response.created_at),
731
+ updatedAt: new Date(response.updated_at)
732
+ };
733
+ },
734
+ async getConversation (uniqueId, contextUniqueId) {
735
+ const response = await transport.get(`/entities/${uniqueId}/conversations/${contextUniqueId}`);
736
+ return {
737
+ id: response.id,
738
+ uniqueId: response.unique_id,
739
+ entityUniqueId: response.entity_unique_id,
740
+ messages: (response.messages || []).map((m)=>({
741
+ role: m.role,
742
+ content: m.content,
743
+ timestamp: new Date(m.timestamp),
744
+ payload: m.payload
745
+ })),
746
+ payload: response.payload,
747
+ createdAt: new Date(response.created_at),
748
+ updatedAt: new Date(response.updated_at)
749
+ };
750
+ },
751
+ async sendMessage (uniqueId, contextUniqueId, data) {
752
+ const response = await transport.post(`/entities/${uniqueId}/contexts/${contextUniqueId}/messages`, {
753
+ message: data.message,
754
+ payload: data.payload
755
+ });
756
+ return {
757
+ message: {
758
+ role: response.message.role,
759
+ content: response.message.content,
760
+ timestamp: new Date(response.message.timestamp),
761
+ payload: response.message.payload
762
+ },
763
+ response: response.response ? {
764
+ role: response.response.role,
765
+ content: response.response.content,
766
+ timestamp: new Date(response.response.timestamp),
767
+ payload: response.response.payload
768
+ } : undefined,
769
+ tokens: response.tokens,
770
+ cost: response.cost
771
+ };
772
+ },
773
+ async queryFile (uniqueId, fileUniqueId, data) {
774
+ const response = await transport.post(`/entities/${uniqueId}/files/${fileUniqueId}/query`, {
775
+ query: data.query,
776
+ payload: data.payload
777
+ });
778
+ return {
779
+ answer: response.answer,
780
+ sources: response.sources,
781
+ tokens: response.tokens,
782
+ cost: response.cost
783
+ };
784
+ }
785
+ };
786
+ }
787
+
788
+ const clusterMapper = {
789
+ type: 'cluster',
790
+ map: (resource)=>{
791
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10;
792
+ return {
793
+ id: resource.id,
794
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
795
+ userUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['user_unique_id'],
796
+ code: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['code'],
797
+ name: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['name'],
798
+ description: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['description'],
799
+ members: (((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['members']) || []).map((m)=>({
800
+ entityUniqueId: m.entity_unique_id,
801
+ role: m.role,
802
+ addedAt: parseDate(m.added_at)
803
+ })),
804
+ enabled: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['enabled'],
805
+ status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
806
+ payload: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['payload'],
807
+ createdAt: parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['created_at']),
808
+ updatedAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['updated_at'])
809
+ };
810
+ }
811
+ };
812
+
813
+ function createClustersService(transport, _config) {
814
+ return {
815
+ async list (userUniqueId, params) {
816
+ const queryParams = {};
817
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
818
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
819
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
820
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
821
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
822
+ const response = await transport.get(`/users/${userUniqueId}/clusters`, {
823
+ params: queryParams
824
+ });
825
+ return decodePageResult(response, clusterMapper);
826
+ },
827
+ async get (userUniqueId, uniqueId) {
828
+ const response = await transport.get(`/users/${userUniqueId}/clusters/${uniqueId}`);
829
+ return decodeOne(response, clusterMapper);
830
+ },
831
+ async create (userUniqueId, data) {
832
+ const response = await transport.post(`/users/${userUniqueId}/clusters`, {
833
+ cluster: {
834
+ code: data.code,
835
+ name: data.name,
836
+ description: data.description,
837
+ payload: data.payload
838
+ }
839
+ });
840
+ return decodeOne(response, clusterMapper);
841
+ },
842
+ async update (userUniqueId, uniqueId, data) {
843
+ const response = await transport.put(`/users/${userUniqueId}/clusters/${uniqueId}`, {
844
+ cluster: {
845
+ name: data.name,
846
+ description: data.description,
847
+ enabled: data.enabled,
848
+ status: data.status,
849
+ payload: data.payload
850
+ }
851
+ });
852
+ return decodeOne(response, clusterMapper);
853
+ },
854
+ async delete (userUniqueId, uniqueId) {
855
+ await transport.delete(`/users/${userUniqueId}/clusters/${uniqueId}`);
856
+ },
857
+ async addMember (userUniqueId, uniqueId, entityUniqueId) {
858
+ await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/entities/${entityUniqueId}`, {});
859
+ },
860
+ async removeMember (userUniqueId, uniqueId, entityUniqueId) {
861
+ await transport.delete(`/users/${userUniqueId}/clusters/${uniqueId}/entities/${entityUniqueId}`);
862
+ },
863
+ async addPrompt (userUniqueId, uniqueId, promptUniqueId) {
864
+ await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/prompts`, {
865
+ prompt_unique_id: promptUniqueId
866
+ });
867
+ },
868
+ async getContext (userUniqueId, uniqueId, contextUniqueId) {
869
+ const response = await transport.get(`/users/${userUniqueId}/clusters/${uniqueId}/contexts/${contextUniqueId}`);
870
+ return {
871
+ id: response.id,
872
+ uniqueId: response.unique_id,
873
+ clusterUniqueId: response.cluster_unique_id,
874
+ messages: (response.messages || []).map((m)=>({
875
+ role: m.role,
876
+ content: m.content,
877
+ timestamp: new Date(m.timestamp),
878
+ payload: m.payload
879
+ })),
880
+ payload: response.payload,
881
+ createdAt: new Date(response.created_at),
882
+ updatedAt: new Date(response.updated_at)
883
+ };
884
+ },
885
+ async createContext (userUniqueId, uniqueId, data) {
886
+ const response = await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/contexts`, {
887
+ system_prompt: data == null ? void 0 : data.systemPrompt,
888
+ payload: data == null ? void 0 : data.payload
889
+ });
890
+ return {
891
+ id: response.id,
892
+ uniqueId: response.unique_id,
893
+ clusterUniqueId: response.cluster_unique_id,
894
+ messages: [],
895
+ payload: response.payload,
896
+ createdAt: new Date(response.created_at),
897
+ updatedAt: new Date(response.updated_at)
898
+ };
899
+ },
900
+ async getConversation (userUniqueId, uniqueId, contextUniqueId) {
901
+ const response = await transport.get(`/users/${userUniqueId}/clusters/${uniqueId}/conversations/${contextUniqueId}`);
902
+ return {
903
+ id: response.id,
904
+ uniqueId: response.unique_id,
905
+ clusterUniqueId: response.cluster_unique_id,
906
+ messages: (response.messages || []).map((m)=>({
907
+ role: m.role,
908
+ content: m.content,
909
+ timestamp: new Date(m.timestamp),
910
+ payload: m.payload
911
+ })),
912
+ payload: response.payload,
913
+ createdAt: new Date(response.created_at),
914
+ updatedAt: new Date(response.updated_at)
915
+ };
916
+ },
917
+ async sendMessage (userUniqueId, uniqueId, contextUniqueId, data) {
918
+ const response = await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/contexts/${contextUniqueId}/messages`, {
919
+ message: data.message,
920
+ payload: data.payload
921
+ });
922
+ return {
923
+ message: {
924
+ role: response.message.role,
925
+ content: response.message.content,
926
+ timestamp: new Date(response.message.timestamp),
927
+ payload: response.message.payload
928
+ },
929
+ response: response.response ? {
930
+ role: response.response.role,
931
+ content: response.response.content,
932
+ timestamp: new Date(response.response.timestamp),
933
+ payload: response.response.payload
934
+ } : undefined,
935
+ tokens: response.tokens,
936
+ cost: response.cost
937
+ };
938
+ }
939
+ };
940
+ }
941
+
942
+ const jarvisUserMapper = {
943
+ type: 'user',
944
+ map: (resource)=>{
945
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8;
946
+ return {
947
+ id: resource.id,
948
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
949
+ email: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['email'],
950
+ name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
951
+ username: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['username'],
952
+ avatarUrl: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['avatar_url'],
953
+ status: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['status'],
954
+ payload: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['payload'],
955
+ createdAt: parseDate((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['created_at']),
956
+ updatedAt: parseDate((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['updated_at'])
957
+ };
958
+ }
959
+ };
960
+
961
+ function createJarvisUsersService(transport, _config) {
962
+ return {
963
+ async list (params) {
964
+ const queryParams = {};
965
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
966
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
967
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
968
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
969
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
970
+ const response = await transport.get('/identities', {
971
+ params: queryParams
972
+ });
973
+ return decodePageResult(response, jarvisUserMapper);
974
+ },
975
+ async get (uniqueId) {
976
+ const response = await transport.get(`/identities/${uniqueId}`);
977
+ return decodeOne(response, jarvisUserMapper);
978
+ },
979
+ async register (uniqueId, data) {
980
+ const response = await transport.post(`/identities/${uniqueId}/register`, {
981
+ user: {
982
+ email: data == null ? void 0 : data.email,
983
+ name: data == null ? void 0 : data.name,
984
+ username: data == null ? void 0 : data.username,
985
+ avatar_url: data == null ? void 0 : data.avatarUrl,
986
+ payload: data == null ? void 0 : data.payload
987
+ }
988
+ });
989
+ return decodeOne(response, jarvisUserMapper);
990
+ },
991
+ async update (uniqueId, data) {
992
+ const response = await transport.put(`/identities/${uniqueId}`, {
993
+ user: {
994
+ name: data.name,
995
+ username: data.username,
996
+ avatar_url: data.avatarUrl,
997
+ status: data.status,
998
+ payload: data.payload
999
+ }
1000
+ });
1001
+ return decodeOne(response, jarvisUserMapper);
1002
+ },
1003
+ async addPrompt (uniqueId, promptUniqueId) {
1004
+ await transport.post(`/identities/${uniqueId}/prompts`, {
1005
+ prompt_unique_id: promptUniqueId
1006
+ });
1007
+ },
1008
+ async getContext (uniqueId, contextUniqueId) {
1009
+ const response = await transport.get(`/identities/${uniqueId}/contexts/${contextUniqueId}`);
1010
+ return {
1011
+ id: response.id,
1012
+ uniqueId: response.unique_id,
1013
+ userUniqueId: response.user_unique_id,
1014
+ messages: (response.messages || []).map((m)=>({
1015
+ role: m.role,
1016
+ content: m.content,
1017
+ timestamp: new Date(m.timestamp),
1018
+ payload: m.payload
1019
+ })),
1020
+ payload: response.payload,
1021
+ createdAt: new Date(response.created_at),
1022
+ updatedAt: new Date(response.updated_at)
1023
+ };
1024
+ },
1025
+ async createContext (uniqueId, data) {
1026
+ const response = await transport.post(`/identities/${uniqueId}/contexts`, {
1027
+ system_prompt: data == null ? void 0 : data.systemPrompt,
1028
+ payload: data == null ? void 0 : data.payload
1029
+ });
1030
+ return {
1031
+ id: response.id,
1032
+ uniqueId: response.unique_id,
1033
+ userUniqueId: response.user_unique_id,
1034
+ messages: [],
1035
+ payload: response.payload,
1036
+ createdAt: new Date(response.created_at),
1037
+ updatedAt: new Date(response.updated_at)
1038
+ };
1039
+ },
1040
+ async getConversation (uniqueId, contextUniqueId) {
1041
+ const response = await transport.get(`/identities/${uniqueId}/conversations/${contextUniqueId}`);
1042
+ return {
1043
+ id: response.id,
1044
+ uniqueId: response.unique_id,
1045
+ userUniqueId: response.user_unique_id,
1046
+ messages: (response.messages || []).map((m)=>({
1047
+ role: m.role,
1048
+ content: m.content,
1049
+ timestamp: new Date(m.timestamp),
1050
+ payload: m.payload
1051
+ })),
1052
+ payload: response.payload,
1053
+ createdAt: new Date(response.created_at),
1054
+ updatedAt: new Date(response.updated_at)
1055
+ };
1056
+ },
1057
+ async sendMessage (uniqueId, contextUniqueId, data) {
1058
+ const response = await transport.post(`/identities/${uniqueId}/contexts/${contextUniqueId}/messages`, {
1059
+ message: data.message,
1060
+ payload: data.payload
1061
+ });
1062
+ return {
1063
+ message: {
1064
+ role: response.message.role,
1065
+ content: response.message.content,
1066
+ timestamp: new Date(response.message.timestamp),
1067
+ payload: response.message.payload
1068
+ },
1069
+ response: response.response ? {
1070
+ role: response.response.role,
1071
+ content: response.response.content,
1072
+ timestamp: new Date(response.response.timestamp),
1073
+ payload: response.response.payload
1074
+ } : undefined,
1075
+ tokens: response.tokens,
1076
+ cost: response.cost
1077
+ };
1078
+ },
1079
+ async getContentContext (uniqueId, contentIdentityUniqueId, contextUniqueId) {
1080
+ const response = await transport.get(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/context/${contextUniqueId}`);
1081
+ return {
1082
+ id: response.id,
1083
+ uniqueId: response.unique_id,
1084
+ userUniqueId: response.user_unique_id,
1085
+ messages: (response.messages || []).map((m)=>({
1086
+ role: m.role,
1087
+ content: m.content,
1088
+ timestamp: new Date(m.timestamp),
1089
+ payload: m.payload
1090
+ })),
1091
+ payload: response.payload,
1092
+ createdAt: new Date(response.created_at),
1093
+ updatedAt: new Date(response.updated_at)
1094
+ };
1095
+ },
1096
+ async createContentContext (uniqueId, contentIdentityUniqueId, data) {
1097
+ const response = await transport.post(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/context`, {
1098
+ system_prompt: data == null ? void 0 : data.systemPrompt,
1099
+ payload: data == null ? void 0 : data.payload
1100
+ });
1101
+ return {
1102
+ id: response.id,
1103
+ uniqueId: response.unique_id,
1104
+ userUniqueId: response.user_unique_id,
1105
+ messages: [],
1106
+ payload: response.payload,
1107
+ createdAt: new Date(response.created_at),
1108
+ updatedAt: new Date(response.updated_at)
1109
+ };
1110
+ },
1111
+ async getContentConversation (uniqueId, contentIdentityUniqueId, contextUniqueId) {
1112
+ const response = await transport.get(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/conversations/${contextUniqueId}`);
1113
+ return {
1114
+ id: response.id,
1115
+ uniqueId: response.unique_id,
1116
+ userUniqueId: response.user_unique_id,
1117
+ messages: (response.messages || []).map((m)=>({
1118
+ role: m.role,
1119
+ content: m.content,
1120
+ timestamp: new Date(m.timestamp),
1121
+ payload: m.payload
1122
+ })),
1123
+ payload: response.payload,
1124
+ createdAt: new Date(response.created_at),
1125
+ updatedAt: new Date(response.updated_at)
1126
+ };
1127
+ },
1128
+ async sendContentMessage (uniqueId, contentIdentityUniqueId, contextUniqueId, data) {
1129
+ const response = await transport.post(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/contexts/${contextUniqueId}/messages`, {
1130
+ message: data.message,
1131
+ payload: data.payload
1132
+ });
1133
+ return {
1134
+ message: {
1135
+ role: response.message.role,
1136
+ content: response.message.content,
1137
+ timestamp: new Date(response.message.timestamp),
1138
+ payload: response.message.payload
1139
+ },
1140
+ response: response.response ? {
1141
+ role: response.response.role,
1142
+ content: response.response.content,
1143
+ timestamp: new Date(response.response.timestamp),
1144
+ payload: response.response.payload
1145
+ } : undefined,
1146
+ tokens: response.tokens,
1147
+ cost: response.cost
1148
+ };
1149
+ }
1150
+ };
1151
+ }
1152
+
1153
+ const workflowParticipantMapper = {
1154
+ type: 'workflow_participant',
1155
+ map: (resource)=>{
1156
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10;
1157
+ return {
1158
+ id: resource.id,
1159
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1160
+ workflowUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['workflow_unique_id'],
1161
+ entityType: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['entity_type'],
1162
+ entityUniqueId: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['entity_unique_id'],
1163
+ role: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['role'],
1164
+ permissions: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['permissions'],
1165
+ enabled: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['enabled'],
1166
+ status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
1167
+ payload: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['payload'],
1168
+ createdAt: parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['created_at']),
1169
+ updatedAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['updated_at'])
1170
+ };
1171
+ }
1172
+ };
1173
+
1174
+ function createWorkflowParticipantsService(transport, _config) {
1175
+ return {
1176
+ async list (workflowUniqueId, params) {
1177
+ const queryParams = {};
1178
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1179
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
1180
+ if (params == null ? void 0 : params.entityType) queryParams['entity_type'] = params.entityType;
1181
+ if (params == null ? void 0 : params.role) queryParams['role'] = params.role;
1182
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
1183
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
1184
+ const response = await transport.get(`/workflows/${workflowUniqueId}/participants`, {
1185
+ params: queryParams
1186
+ });
1187
+ return decodePageResult(response, workflowParticipantMapper);
1188
+ },
1189
+ async get (workflowUniqueId, uniqueId) {
1190
+ const response = await transport.get(`/workflows/${workflowUniqueId}/participants/${uniqueId}`);
1191
+ return decodeOne(response, workflowParticipantMapper);
1192
+ },
1193
+ async add (workflowUniqueId, data) {
1194
+ const response = await transport.post(`/workflows/${workflowUniqueId}/participants`, {
1195
+ participant: {
1196
+ entity_type: data.entityType,
1197
+ entity_unique_id: data.entityUniqueId,
1198
+ role: data.role,
1199
+ permissions: data.permissions,
1200
+ payload: data.payload
1201
+ }
1202
+ });
1203
+ return decodeOne(response, workflowParticipantMapper);
1204
+ },
1205
+ async update (workflowUniqueId, uniqueId, data) {
1206
+ const response = await transport.put(`/workflows/${workflowUniqueId}/participants/${uniqueId}`, {
1207
+ participant: {
1208
+ role: data.role,
1209
+ permissions: data.permissions,
1210
+ enabled: data.enabled,
1211
+ status: data.status,
1212
+ payload: data.payload
1213
+ }
1214
+ });
1215
+ return decodeOne(response, workflowParticipantMapper);
1216
+ },
1217
+ async remove (workflowUniqueId, uniqueId) {
1218
+ await transport.delete(`/workflows/${workflowUniqueId}/participants/${uniqueId}`);
1219
+ }
1220
+ };
1221
+ }
1222
+
1223
+ const workflowStepMapper = {
1224
+ type: 'workflow_step',
1225
+ map: (resource)=>{
1226
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13;
1227
+ return {
1228
+ id: resource.id,
1229
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1230
+ workflowUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['workflow_unique_id'],
1231
+ name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
1232
+ description: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['description'],
1233
+ stepType: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['step_type'],
1234
+ order: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['order'],
1235
+ config: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['config'],
1236
+ promptUniqueId: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['prompt_unique_id'],
1237
+ agentUniqueId: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['agent_unique_id'],
1238
+ enabled: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['enabled'],
1239
+ status: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['status'],
1240
+ payload: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['payload'],
1241
+ createdAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['created_at']),
1242
+ updatedAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['updated_at'])
1243
+ };
1244
+ }
1245
+ };
1246
+
1247
+ function createWorkflowStepsService(transport, _config) {
1248
+ return {
1249
+ async get (workflowUniqueId, stepUniqueId) {
1250
+ const response = await transport.get(`/workflows/${workflowUniqueId}/steps/${stepUniqueId}`);
1251
+ return decodeOne(response, workflowStepMapper);
1252
+ },
1253
+ async add (workflowUniqueId, data) {
1254
+ const response = await transport.put(`/workflows/${workflowUniqueId}/steps`, {
1255
+ step: {
1256
+ name: data.name,
1257
+ description: data.description,
1258
+ step_type: data.stepType,
1259
+ order: data.order,
1260
+ config: data.config,
1261
+ payload: data.payload
1262
+ }
1263
+ });
1264
+ return decodeOne(response, workflowStepMapper);
1265
+ },
1266
+ async update (workflowUniqueId, stepUniqueId, data) {
1267
+ const response = await transport.put(`/workflows/${workflowUniqueId}/steps/${stepUniqueId}`, {
1268
+ step: {
1269
+ name: data.name,
1270
+ description: data.description,
1271
+ step_type: data.stepType,
1272
+ order: data.order,
1273
+ config: data.config,
1274
+ enabled: data.enabled,
1275
+ status: data.status,
1276
+ payload: data.payload
1277
+ }
1278
+ });
1279
+ return decodeOne(response, workflowStepMapper);
1280
+ },
1281
+ async remove (workflowUniqueId, stepUniqueId) {
1282
+ await transport.delete(`/workflows/${workflowUniqueId}/steps/${stepUniqueId}`);
1283
+ },
1284
+ async addPrompt (stepUniqueId, data) {
1285
+ await transport.post(`/steps/${stepUniqueId}/prompts`, {
1286
+ prompt_unique_id: data.promptUniqueId,
1287
+ payload: data.payload
1288
+ });
1289
+ },
1290
+ async addAgent (stepUniqueId, data) {
1291
+ await transport.post(`/steps/${stepUniqueId}/agents`, {
1292
+ agent_unique_id: data.agentUniqueId,
1293
+ payload: data.payload
1294
+ });
1295
+ }
1296
+ };
1297
+ }
1298
+
1299
+ const workflowInstanceMapper = {
1300
+ type: 'workflow_instance',
1301
+ map: (resource)=>{
1302
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14;
1303
+ return {
1304
+ id: resource.id,
1305
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1306
+ workflowUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['workflow_unique_id'],
1307
+ currentStepUniqueId: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['current_step_unique_id'],
1308
+ currentStepOrder: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['current_step_order'],
1309
+ input: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['input'],
1310
+ output: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['output'],
1311
+ logs: (((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['logs']) || []).map((log)=>({
1312
+ stepUniqueId: log.step_unique_id,
1313
+ stepName: log.step_name,
1314
+ status: log.status,
1315
+ input: log.input,
1316
+ output: log.output,
1317
+ startedAt: parseDate(log.started_at),
1318
+ completedAt: log.completed_at ? parseDate(log.completed_at) : undefined,
1319
+ error: log.error
1320
+ })),
1321
+ status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
1322
+ startedAt: ((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['started_at']) ? parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['started_at']) : undefined,
1323
+ completedAt: ((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['completed_at']) ? parseDate((_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['completed_at']) : undefined,
1324
+ payload: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['payload'],
1325
+ createdAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['created_at']),
1326
+ updatedAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['updated_at'])
1327
+ };
1328
+ }
1329
+ };
1330
+
1331
+ function createWorkflowInstancesService(transport, _config) {
1332
+ return {
1333
+ async start (workflowUniqueId, data) {
1334
+ const response = await transport.post(`/workflows/${workflowUniqueId}/start`, {
1335
+ input: data == null ? void 0 : data.input,
1336
+ payload: data == null ? void 0 : data.payload
1337
+ });
1338
+ return {
1339
+ instance: decodeOne(response, workflowInstanceMapper)
1340
+ };
1341
+ },
1342
+ async get (workflowUniqueId, instanceUniqueId) {
1343
+ const response = await transport.get(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}`);
1344
+ return decodeOne(response, workflowInstanceMapper);
1345
+ },
1346
+ async getDetails (workflowUniqueId, instanceUniqueId) {
1347
+ var _response_workflow, _response_workflow1;
1348
+ const response = await transport.get(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/details`);
1349
+ return {
1350
+ instance: decodeOne(response.instance || response, workflowInstanceMapper),
1351
+ workflow: {
1352
+ uniqueId: (_response_workflow = response.workflow) == null ? void 0 : _response_workflow.unique_id,
1353
+ name: (_response_workflow1 = response.workflow) == null ? void 0 : _response_workflow1.name
1354
+ },
1355
+ steps: (response.steps || []).map((s)=>({
1356
+ stepUniqueId: s.step_unique_id,
1357
+ stepName: s.step_name,
1358
+ order: s.order,
1359
+ status: s.status,
1360
+ startedAt: s.started_at ? new Date(s.started_at) : undefined,
1361
+ completedAt: s.completed_at ? new Date(s.completed_at) : undefined
1362
+ }))
1363
+ };
1364
+ },
1365
+ async step (workflowUniqueId, instanceUniqueId, data) {
1366
+ const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}`, {
1367
+ input: data == null ? void 0 : data.input,
1368
+ payload: data == null ? void 0 : data.payload
1369
+ });
1370
+ return decodeOne(response, workflowInstanceMapper);
1371
+ },
1372
+ async logStep (workflowUniqueId, instanceUniqueId, data) {
1373
+ const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/log`, {
1374
+ step_unique_id: data.stepUniqueId,
1375
+ status: data.status,
1376
+ output: data.output,
1377
+ error: data.error,
1378
+ payload: data.payload
1379
+ });
1380
+ return decodeOne(response, workflowInstanceMapper);
1381
+ },
1382
+ async suspend (workflowUniqueId, instanceUniqueId) {
1383
+ const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/suspend`, {});
1384
+ return decodeOne(response, workflowInstanceMapper);
1385
+ },
1386
+ async resume (workflowUniqueId, instanceUniqueId) {
1387
+ const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/resume`, {});
1388
+ return decodeOne(response, workflowInstanceMapper);
1389
+ }
1390
+ };
1391
+ }
1392
+
1393
+ function createAgentRuntimeService(transport, _config) {
1394
+ return {
1395
+ async getContext (agentUniqueId, contextUniqueId) {
1396
+ var _response_thread, _response_thread1, _response_thread2, _response_thread3, _response_thread4, _response_thread5, _response_thread6, _response_thread7;
1397
+ const response = await transport.get(`/agents/${agentUniqueId}/context/${contextUniqueId}`);
1398
+ return {
1399
+ thread: {
1400
+ id: (_response_thread = response.thread) == null ? void 0 : _response_thread.id,
1401
+ threadId: (_response_thread1 = response.thread) == null ? void 0 : _response_thread1.thread_id,
1402
+ agentUniqueId: (_response_thread2 = response.thread) == null ? void 0 : _response_thread2.agent_unique_id,
1403
+ contextUniqueId: (_response_thread3 = response.thread) == null ? void 0 : _response_thread3.context_unique_id,
1404
+ status: (_response_thread4 = response.thread) == null ? void 0 : _response_thread4.status,
1405
+ metadata: (_response_thread5 = response.thread) == null ? void 0 : _response_thread5.metadata,
1406
+ createdAt: new Date((_response_thread6 = response.thread) == null ? void 0 : _response_thread6.created_at),
1407
+ updatedAt: new Date((_response_thread7 = response.thread) == null ? void 0 : _response_thread7.updated_at)
1408
+ },
1409
+ conversation: response.conversation ? {
1410
+ uniqueId: response.conversation.unique_id,
1411
+ messages: (response.conversation.messages || []).map((m)=>({
1412
+ id: m.id,
1413
+ threadId: m.thread_id,
1414
+ role: m.role,
1415
+ content: (m.content || []).map((c)=>({
1416
+ type: c.type,
1417
+ text: c.text,
1418
+ imageFile: c.image_file,
1419
+ imageUrl: c.image_url
1420
+ })),
1421
+ metadata: m.metadata,
1422
+ createdAt: new Date(m.created_at)
1423
+ }))
1424
+ } : undefined
1425
+ };
1426
+ },
1427
+ async createContext (agentUniqueId, data) {
1428
+ var _response_thread, _response_thread1, _response_thread2, _response_thread3, _response_thread4, _response_thread5, _response_thread6, _response_thread7;
1429
+ const response = await transport.post(`/agents/${agentUniqueId}/context`, {
1430
+ metadata: data == null ? void 0 : data.metadata
1431
+ });
1432
+ return {
1433
+ thread: {
1434
+ id: (_response_thread = response.thread) == null ? void 0 : _response_thread.id,
1435
+ threadId: (_response_thread1 = response.thread) == null ? void 0 : _response_thread1.thread_id,
1436
+ agentUniqueId: (_response_thread2 = response.thread) == null ? void 0 : _response_thread2.agent_unique_id,
1437
+ contextUniqueId: (_response_thread3 = response.thread) == null ? void 0 : _response_thread3.context_unique_id,
1438
+ status: (_response_thread4 = response.thread) == null ? void 0 : _response_thread4.status,
1439
+ metadata: (_response_thread5 = response.thread) == null ? void 0 : _response_thread5.metadata,
1440
+ createdAt: new Date((_response_thread6 = response.thread) == null ? void 0 : _response_thread6.created_at),
1441
+ updatedAt: new Date((_response_thread7 = response.thread) == null ? void 0 : _response_thread7.updated_at)
1442
+ }
1443
+ };
1444
+ },
1445
+ async getConversation (agentUniqueId, contextUniqueId) {
1446
+ const response = await transport.get(`/agents/${agentUniqueId}/conversations/${contextUniqueId}`);
1447
+ return {
1448
+ messages: (response.messages || []).map((m)=>({
1449
+ id: m.id,
1450
+ threadId: m.thread_id,
1451
+ role: m.role,
1452
+ content: (m.content || []).map((c)=>({
1453
+ type: c.type,
1454
+ text: c.text,
1455
+ imageFile: c.image_file,
1456
+ imageUrl: c.image_url
1457
+ })),
1458
+ metadata: m.metadata,
1459
+ createdAt: new Date(m.created_at)
1460
+ }))
1461
+ };
1462
+ },
1463
+ async getThread (agentUniqueId, threadId) {
1464
+ const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}`);
1465
+ return {
1466
+ id: response.id,
1467
+ threadId: response.thread_id,
1468
+ agentUniqueId: response.agent_unique_id,
1469
+ contextUniqueId: response.context_unique_id,
1470
+ status: response.status,
1471
+ metadata: response.metadata,
1472
+ createdAt: new Date(response.created_at),
1473
+ updatedAt: new Date(response.updated_at)
1474
+ };
1475
+ },
1476
+ async createThread (agentUniqueId, data) {
1477
+ const response = await transport.post(`/agents/${agentUniqueId}/thread`, {
1478
+ metadata: data == null ? void 0 : data.metadata
1479
+ });
1480
+ return {
1481
+ id: response.id,
1482
+ threadId: response.thread_id,
1483
+ agentUniqueId: response.agent_unique_id,
1484
+ contextUniqueId: response.context_unique_id,
1485
+ status: response.status,
1486
+ metadata: response.metadata,
1487
+ createdAt: new Date(response.created_at),
1488
+ updatedAt: new Date(response.updated_at)
1489
+ };
1490
+ },
1491
+ async sendMessage (agentUniqueId, threadId, data) {
1492
+ const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/messages`, {
1493
+ message: data.message,
1494
+ metadata: data.metadata
1495
+ });
1496
+ return {
1497
+ message: {
1498
+ id: response.id,
1499
+ threadId: response.thread_id,
1500
+ role: response.role,
1501
+ content: (response.content || []).map((c)=>({
1502
+ type: c.type,
1503
+ text: c.text,
1504
+ imageFile: c.image_file,
1505
+ imageUrl: c.image_url
1506
+ })),
1507
+ metadata: response.metadata,
1508
+ createdAt: new Date(response.created_at)
1509
+ }
1510
+ };
1511
+ },
1512
+ async sendMessageStream (agentUniqueId, threadId, data) {
1513
+ const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/messages/stream`, {
1514
+ message: data.message,
1515
+ metadata: data.metadata
1516
+ }, {
1517
+ responseType: 'stream'
1518
+ });
1519
+ if (response.body) {
1520
+ return response.body.pipeThrough(new TextDecoderStream());
1521
+ }
1522
+ throw new Error('Streaming not supported');
1523
+ },
1524
+ async runThread (agentUniqueId, threadId, data) {
1525
+ const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/runs`, {
1526
+ instructions: data == null ? void 0 : data.instructions,
1527
+ additional_instructions: data == null ? void 0 : data.additionalInstructions,
1528
+ tools: data == null ? void 0 : data.tools,
1529
+ metadata: data == null ? void 0 : data.metadata
1530
+ });
1531
+ return {
1532
+ run: {
1533
+ id: response.id,
1534
+ runId: response.run_id,
1535
+ threadId: response.thread_id,
1536
+ agentUniqueId: response.agent_unique_id,
1537
+ status: response.status,
1538
+ model: response.model,
1539
+ instructions: response.instructions,
1540
+ tools: response.tools,
1541
+ startedAt: response.started_at ? new Date(response.started_at) : undefined,
1542
+ completedAt: response.completed_at ? new Date(response.completed_at) : undefined,
1543
+ failedAt: response.failed_at ? new Date(response.failed_at) : undefined,
1544
+ cancelledAt: response.cancelled_at ? new Date(response.cancelled_at) : undefined,
1545
+ expiresAt: response.expires_at ? new Date(response.expires_at) : undefined,
1546
+ lastError: response.last_error,
1547
+ usage: response.usage ? {
1548
+ promptTokens: response.usage.prompt_tokens,
1549
+ completionTokens: response.usage.completion_tokens,
1550
+ totalTokens: response.usage.total_tokens
1551
+ } : undefined,
1552
+ metadata: response.metadata,
1553
+ createdAt: new Date(response.created_at)
1554
+ }
1555
+ };
1556
+ },
1557
+ async getRun (agentUniqueId, threadId, runId) {
1558
+ const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}/runs/${runId}`);
1559
+ return {
1560
+ id: response.id,
1561
+ runId: response.run_id,
1562
+ threadId: response.thread_id,
1563
+ agentUniqueId: response.agent_unique_id,
1564
+ status: response.status,
1565
+ model: response.model,
1566
+ instructions: response.instructions,
1567
+ tools: response.tools,
1568
+ startedAt: response.started_at ? new Date(response.started_at) : undefined,
1569
+ completedAt: response.completed_at ? new Date(response.completed_at) : undefined,
1570
+ failedAt: response.failed_at ? new Date(response.failed_at) : undefined,
1571
+ cancelledAt: response.cancelled_at ? new Date(response.cancelled_at) : undefined,
1572
+ expiresAt: response.expires_at ? new Date(response.expires_at) : undefined,
1573
+ lastError: response.last_error,
1574
+ usage: response.usage ? {
1575
+ promptTokens: response.usage.prompt_tokens,
1576
+ completionTokens: response.usage.completion_tokens,
1577
+ totalTokens: response.usage.total_tokens
1578
+ } : undefined,
1579
+ metadata: response.metadata,
1580
+ createdAt: new Date(response.created_at)
1581
+ };
1582
+ },
1583
+ async getMessages (agentUniqueId, threadId) {
1584
+ const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}/messages`);
1585
+ return (response.messages || response || []).map((m)=>({
1586
+ id: m.id,
1587
+ threadId: m.thread_id,
1588
+ role: m.role,
1589
+ content: (m.content || []).map((c)=>({
1590
+ type: c.type,
1591
+ text: c.text,
1592
+ imageFile: c.image_file,
1593
+ imageUrl: c.image_url
1594
+ })),
1595
+ metadata: m.metadata,
1596
+ createdAt: new Date(m.created_at)
1597
+ }));
1598
+ },
1599
+ async listExecutions (agentUniqueId, params) {
1600
+ var _response_meta, _response_meta1, _response_meta2, _response_meta3;
1601
+ const queryParams = {};
1602
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1603
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
1604
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
1605
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
1606
+ const response = await transport.get(`/agents/${agentUniqueId}/executions`, {
1607
+ params: queryParams
1608
+ });
1609
+ const data = response.data || [];
1610
+ return {
1611
+ data: data.map((e)=>({
1612
+ id: e.id,
1613
+ uniqueId: e.unique_id,
1614
+ agentUniqueId: e.agent_unique_id,
1615
+ runId: e.run_id,
1616
+ threadId: e.thread_id,
1617
+ status: e.status,
1618
+ input: e.input,
1619
+ output: e.output,
1620
+ tokens: e.tokens,
1621
+ cost: e.cost,
1622
+ duration: e.duration,
1623
+ error: e.error,
1624
+ createdAt: new Date(e.created_at),
1625
+ updatedAt: new Date(e.updated_at)
1626
+ })),
1627
+ meta: {
1628
+ totalCount: ((_response_meta = response.meta) == null ? void 0 : _response_meta.total_count) || data.length,
1629
+ page: ((_response_meta1 = response.meta) == null ? void 0 : _response_meta1.page) || 1,
1630
+ perPage: ((_response_meta2 = response.meta) == null ? void 0 : _response_meta2.per_page) || data.length,
1631
+ totalPages: ((_response_meta3 = response.meta) == null ? void 0 : _response_meta3.total_pages) || 1
1632
+ }
1633
+ };
1634
+ },
1635
+ async getExecution (agentUniqueId, executionUniqueId) {
1636
+ const response = await transport.get(`/agents/${agentUniqueId}/executions/${executionUniqueId}`);
1637
+ return {
1638
+ id: response.id,
1639
+ uniqueId: response.unique_id,
1640
+ agentUniqueId: response.agent_unique_id,
1641
+ runId: response.run_id,
1642
+ threadId: response.thread_id,
1643
+ status: response.status,
1644
+ input: response.input,
1645
+ output: response.output,
1646
+ tokens: response.tokens,
1647
+ cost: response.cost,
1648
+ duration: response.duration,
1649
+ error: response.error,
1650
+ createdAt: new Date(response.created_at),
1651
+ updatedAt: new Date(response.updated_at)
1652
+ };
1653
+ }
1654
+ };
1655
+ }
1656
+
1657
+ const mailTemplateMapper = {
1658
+ type: 'mail_template',
1659
+ map: (resource)=>{
1660
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13;
1661
+ return {
1662
+ id: resource.id,
1663
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1664
+ code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
1665
+ name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
1666
+ subject: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['subject'],
1667
+ fromEmail: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['from_email'],
1668
+ fromName: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['from_name'],
1669
+ htmlContent: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['html_content'],
1670
+ textContent: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['text_content'],
1671
+ mandrillSlug: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['mandrill_slug'],
1672
+ enabled: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['enabled'],
1673
+ status: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['status'],
1674
+ payload: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['payload'],
1675
+ createdAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['created_at']),
1676
+ updatedAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['updated_at'])
1677
+ };
1678
+ }
1679
+ };
1680
+
1681
+ function createMailTemplatesService(transport, _config) {
1682
+ return {
1683
+ async list (params) {
1684
+ const queryParams = {};
1685
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1686
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
1687
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
1688
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
1689
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
1690
+ const response = await transport.get('/mailtemplates', {
1691
+ params: queryParams
1692
+ });
1693
+ return decodePageResult(response, mailTemplateMapper);
1694
+ },
1695
+ async get (uniqueId) {
1696
+ const response = await transport.get(`/mailtemplates/${uniqueId}`);
1697
+ return decodeOne(response, mailTemplateMapper);
1698
+ },
1699
+ async create (data) {
1700
+ const response = await transport.post('/mailtemplates', {
1701
+ mail_template: {
1702
+ code: data.code,
1703
+ name: data.name,
1704
+ subject: data.subject,
1705
+ from_email: data.fromEmail,
1706
+ from_name: data.fromName,
1707
+ html_content: data.htmlContent,
1708
+ text_content: data.textContent,
1709
+ payload: data.payload
1710
+ }
1711
+ });
1712
+ return decodeOne(response, mailTemplateMapper);
1713
+ },
1714
+ async update (uniqueId, data) {
1715
+ const response = await transport.put(`/mailtemplates/${uniqueId}`, {
1716
+ mail_template: {
1717
+ name: data.name,
1718
+ subject: data.subject,
1719
+ from_email: data.fromEmail,
1720
+ from_name: data.fromName,
1721
+ html_content: data.htmlContent,
1722
+ text_content: data.textContent,
1723
+ enabled: data.enabled,
1724
+ status: data.status,
1725
+ payload: data.payload
1726
+ }
1727
+ });
1728
+ return decodeOne(response, mailTemplateMapper);
1729
+ },
1730
+ async createMandrillTemplate (uniqueId, data) {
1731
+ const response = await transport.post(`/mailtemplates/${uniqueId}/mandrill`, {
1732
+ slug: data == null ? void 0 : data.slug,
1733
+ labels: data == null ? void 0 : data.labels,
1734
+ payload: data == null ? void 0 : data.payload
1735
+ });
1736
+ return decodeOne(response, mailTemplateMapper);
1737
+ },
1738
+ async updateMandrillTemplate (uniqueId, data) {
1739
+ const response = await transport.put(`/mailtemplates/${uniqueId}/mandrill`, {
1740
+ slug: data == null ? void 0 : data.slug,
1741
+ labels: data == null ? void 0 : data.labels,
1742
+ payload: data == null ? void 0 : data.payload
1743
+ });
1744
+ return decodeOne(response, mailTemplateMapper);
1745
+ },
1746
+ async publishMandrill (uniqueId) {
1747
+ const response = await transport.put(`/mailtemplates/${uniqueId}/mandrill/publish`, {});
1748
+ return decodeOne(response, mailTemplateMapper);
1749
+ },
1750
+ async getMandrillStats (uniqueId) {
1751
+ const response = await transport.get(`/mailtemplates/${uniqueId}/mandrill/stats`);
1752
+ return {
1753
+ slug: response.slug,
1754
+ sentCount: response.sent_count,
1755
+ openCount: response.open_count,
1756
+ clickCount: response.click_count,
1757
+ hardBounceCount: response.hard_bounce_count,
1758
+ softBounceCount: response.soft_bounce_count,
1759
+ rejectCount: response.reject_count,
1760
+ spamCount: response.spam_count,
1761
+ unsubCount: response.unsub_count,
1762
+ lastSentAt: response.last_sent_at ? new Date(response.last_sent_at) : undefined
1763
+ };
1764
+ }
1765
+ };
1766
+ }
1767
+
1768
+ function createMarvinChatService(transport, _config) {
1769
+ return {
1770
+ async chat (data) {
1771
+ const response = await transport.post('/marvin/conversations', {
1772
+ message: data.message,
1773
+ context_unique_id: data.contextUniqueId,
1774
+ model: data.model,
1775
+ temperature: data.temperature,
1776
+ max_tokens: data.maxTokens,
1777
+ system_prompt: data.systemPrompt,
1778
+ payload: data.payload
1779
+ });
1780
+ return {
1781
+ response: response.response,
1782
+ contextUniqueId: response.context_unique_id,
1783
+ tokens: response.tokens,
1784
+ cost: response.cost,
1785
+ model: response.model
1786
+ };
1787
+ },
1788
+ async chatV2 (data) {
1789
+ const response = await transport.post('/jarvis/v2/conversations', {
1790
+ message: data.message,
1791
+ context_unique_id: data.contextUniqueId,
1792
+ model: data.model,
1793
+ temperature: data.temperature,
1794
+ max_tokens: data.maxTokens,
1795
+ system_prompt: data.systemPrompt,
1796
+ payload: data.payload
1797
+ });
1798
+ return {
1799
+ response: response.response,
1800
+ contextUniqueId: response.context_unique_id,
1801
+ tokens: response.tokens,
1802
+ cost: response.cost,
1803
+ model: response.model
1804
+ };
1805
+ },
1806
+ async chatV3 (data) {
1807
+ const response = await transport.post('/jarvis/v3/conversations', {
1808
+ message: data.message,
1809
+ context_unique_id: data.contextUniqueId,
1810
+ model: data.model,
1811
+ temperature: data.temperature,
1812
+ max_tokens: data.maxTokens,
1813
+ system_prompt: data.systemPrompt,
1814
+ payload: data.payload
1815
+ });
1816
+ return {
1817
+ response: response.response,
1818
+ contextUniqueId: response.context_unique_id,
1819
+ tokens: response.tokens,
1820
+ cost: response.cost,
1821
+ model: response.model
1822
+ };
1823
+ },
1824
+ async getContext (uniqueId) {
1825
+ const response = await transport.get(`/marvin/contexts/${uniqueId}`);
1826
+ return {
1827
+ id: response.id,
1828
+ uniqueId: response.unique_id,
1829
+ messages: (response.messages || []).map((m)=>({
1830
+ role: m.role,
1831
+ content: m.content,
1832
+ timestamp: new Date(m.timestamp),
1833
+ tokens: m.tokens,
1834
+ payload: m.payload
1835
+ })),
1836
+ model: response.model,
1837
+ temperature: response.temperature,
1838
+ systemPrompt: response.system_prompt,
1839
+ payload: response.payload,
1840
+ createdAt: new Date(response.created_at),
1841
+ updatedAt: new Date(response.updated_at)
1842
+ };
1843
+ },
1844
+ async createContext (data) {
1845
+ const response = await transport.post('/marvin/contexts', {
1846
+ model: data == null ? void 0 : data.model,
1847
+ temperature: data == null ? void 0 : data.temperature,
1848
+ system_prompt: data == null ? void 0 : data.systemPrompt,
1849
+ payload: data == null ? void 0 : data.payload
1850
+ });
1851
+ return {
1852
+ id: response.id,
1853
+ uniqueId: response.unique_id,
1854
+ messages: [],
1855
+ model: response.model,
1856
+ temperature: response.temperature,
1857
+ systemPrompt: response.system_prompt,
1858
+ payload: response.payload,
1859
+ createdAt: new Date(response.created_at),
1860
+ updatedAt: new Date(response.updated_at)
1861
+ };
1862
+ },
1863
+ async sendMessage (contextUniqueId, data) {
1864
+ const response = await transport.post(`/marvin/contexts/${contextUniqueId}/messages`, {
1865
+ message: data.message,
1866
+ payload: data.payload
1867
+ });
1868
+ return {
1869
+ message: {
1870
+ role: 'user',
1871
+ content: data.message,
1872
+ timestamp: new Date(),
1873
+ payload: data.payload
1874
+ },
1875
+ response: {
1876
+ role: 'assistant',
1877
+ content: response.response,
1878
+ timestamp: new Date(response.timestamp),
1879
+ tokens: response.tokens,
1880
+ payload: response.payload
1881
+ },
1882
+ tokens: response.tokens,
1883
+ cost: response.cost
1884
+ };
1885
+ }
1886
+ };
1887
+ }
1888
+
1889
+ const promptCommentMapper = {
1890
+ type: 'comment',
1891
+ map: (resource)=>{
1892
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14;
1893
+ return {
1894
+ id: resource.id,
1895
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1896
+ promptUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['prompt_unique_id'],
1897
+ parentUniqueId: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['parent_unique_id'],
1898
+ userUniqueId: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['user_unique_id'],
1899
+ content: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['content'],
1900
+ likesCount: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['likes_count'],
1901
+ repliesCount: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['replies_count'],
1902
+ isLiked: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['is_liked'],
1903
+ isFollowed: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['is_followed'],
1904
+ isSaved: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['is_saved'],
1905
+ enabled: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['enabled'],
1906
+ status: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['status'],
1907
+ payload: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['payload'],
1908
+ createdAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['created_at']),
1909
+ updatedAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['updated_at'])
1910
+ };
1911
+ }
1912
+ };
1913
+ const executionCommentMapper = {
1914
+ type: 'execution_comment',
1915
+ map: (resource)=>{
1916
+ var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14, _resource_attributes15;
1917
+ return {
1918
+ id: resource.id,
1919
+ uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1920
+ promptUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['prompt_unique_id'],
1921
+ executionUniqueId: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['execution_unique_id'],
1922
+ parentUniqueId: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['parent_unique_id'],
1923
+ userUniqueId: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['user_unique_id'],
1924
+ content: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['content'],
1925
+ likesCount: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['likes_count'],
1926
+ repliesCount: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['replies_count'],
1927
+ isLiked: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['is_liked'],
1928
+ isFollowed: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['is_followed'],
1929
+ isSaved: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['is_saved'],
1930
+ enabled: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['enabled'],
1931
+ status: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['status'],
1932
+ payload: (_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['payload'],
1933
+ createdAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['created_at']),
1934
+ updatedAt: parseDate((_resource_attributes15 = resource.attributes) == null ? void 0 : _resource_attributes15['updated_at'])
1935
+ };
1936
+ }
1937
+ };
1938
+
1939
+ function createPromptCommentsService(transport, _config) {
1940
+ return {
1941
+ async list (promptUniqueId, params) {
1942
+ const queryParams = {};
1943
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1944
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
1945
+ if (params == null ? void 0 : params.parentUniqueId) queryParams['parent_unique_id'] = params.parentUniqueId;
1946
+ if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
1947
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
1948
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
1949
+ const response = await transport.get(`/prompts/${promptUniqueId}/comments`, {
1950
+ params: queryParams
1951
+ });
1952
+ return decodePageResult(response, promptCommentMapper);
1953
+ },
1954
+ async get (promptUniqueId, uniqueId) {
1955
+ const response = await transport.get(`/prompts/${promptUniqueId}/comments/${uniqueId}`);
1956
+ return decodeOne(response, promptCommentMapper);
1957
+ },
1958
+ async create (promptUniqueId, data) {
1959
+ const response = await transport.post(`/prompts/${promptUniqueId}/comments`, {
1960
+ comment: {
1961
+ content: data.content,
1962
+ user_unique_id: data.userUniqueId,
1963
+ payload: data.payload
1964
+ }
1965
+ });
1966
+ return decodeOne(response, promptCommentMapper);
1967
+ },
1968
+ async update (promptUniqueId, uniqueId, data) {
1969
+ const response = await transport.put(`/prompts/${promptUniqueId}/comments/${uniqueId}`, {
1970
+ comment: {
1971
+ content: data.content,
1972
+ enabled: data.enabled,
1973
+ status: data.status,
1974
+ payload: data.payload
1975
+ }
1976
+ });
1977
+ return decodeOne(response, promptCommentMapper);
1978
+ },
1979
+ async delete (promptUniqueId, uniqueId) {
1980
+ await transport.delete(`/prompts/${promptUniqueId}/comments/${uniqueId}`);
1981
+ },
1982
+ async like (promptUniqueId, uniqueId) {
1983
+ await transport.put(`/prompts/${promptUniqueId}/comments/${uniqueId}/like`, {});
1984
+ },
1985
+ async dislike (promptUniqueId, uniqueId) {
1986
+ await transport.delete(`/prompts/${promptUniqueId}/comments/${uniqueId}/dislike`);
1987
+ },
1988
+ async reply (promptUniqueId, uniqueId, data) {
1989
+ const response = await transport.post(`/prompts/${promptUniqueId}/comments/${uniqueId}/reply`, {
1990
+ comment: {
1991
+ content: data.content,
1992
+ user_unique_id: data.userUniqueId,
1993
+ payload: data.payload
1994
+ }
1995
+ });
1996
+ return decodeOne(response, promptCommentMapper);
1997
+ },
1998
+ async follow (promptUniqueId, uniqueId) {
1999
+ await transport.put(`/prompts/${promptUniqueId}/comments/${uniqueId}/follow`, {});
2000
+ },
2001
+ async unfollow (promptUniqueId, uniqueId) {
2002
+ await transport.delete(`/prompts/${promptUniqueId}/comments/${uniqueId}/unfollow`);
2003
+ },
2004
+ async save (promptUniqueId, uniqueId) {
2005
+ await transport.put(`/prompts/${promptUniqueId}/comments/${uniqueId}/save`, {});
2006
+ },
2007
+ async unsave (promptUniqueId, uniqueId) {
2008
+ await transport.delete(`/prompts/${promptUniqueId}/comments/${uniqueId}/unsave`);
2009
+ }
2010
+ };
2011
+ }
2012
+
2013
+ function createExecutionCommentsService(transport, _config) {
2014
+ return {
2015
+ async list (promptUniqueId, executionUniqueId, params) {
2016
+ const queryParams = {};
2017
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2018
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2019
+ if (params == null ? void 0 : params.parentUniqueId) queryParams['parent_unique_id'] = params.parentUniqueId;
2020
+ if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
2021
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2022
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2023
+ const response = await transport.get(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments`, {
2024
+ params: queryParams
2025
+ });
2026
+ return decodePageResult(response, executionCommentMapper);
2027
+ },
2028
+ async get (promptUniqueId, executionUniqueId, uniqueId) {
2029
+ const response = await transport.get(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}`);
2030
+ return decodeOne(response, executionCommentMapper);
2031
+ },
2032
+ async create (promptUniqueId, executionUniqueId, data) {
2033
+ const response = await transport.post(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments`, {
2034
+ comment: {
2035
+ content: data.content,
2036
+ user_unique_id: data.userUniqueId,
2037
+ payload: data.payload
2038
+ }
2039
+ });
2040
+ return decodeOne(response, executionCommentMapper);
2041
+ },
2042
+ async update (promptUniqueId, executionUniqueId, uniqueId, data) {
2043
+ const response = await transport.put(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}`, {
2044
+ comment: {
2045
+ content: data.content,
2046
+ enabled: data.enabled,
2047
+ status: data.status,
2048
+ payload: data.payload
2049
+ }
2050
+ });
2051
+ return decodeOne(response, executionCommentMapper);
2052
+ },
2053
+ async delete (promptUniqueId, executionUniqueId, uniqueId) {
2054
+ await transport.delete(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}`);
2055
+ },
2056
+ async like (promptUniqueId, executionUniqueId, uniqueId) {
2057
+ await transport.put(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/like`, {});
2058
+ },
2059
+ async dislike (promptUniqueId, executionUniqueId, uniqueId) {
2060
+ await transport.delete(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/dislike`);
2061
+ },
2062
+ async reply (promptUniqueId, executionUniqueId, uniqueId, data) {
2063
+ const response = await transport.post(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/reply`, {
2064
+ comment: {
2065
+ content: data.content,
2066
+ user_unique_id: data.userUniqueId,
2067
+ payload: data.payload
2068
+ }
2069
+ });
2070
+ return decodeOne(response, executionCommentMapper);
2071
+ },
2072
+ async follow (promptUniqueId, executionUniqueId, uniqueId) {
2073
+ await transport.put(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/follow`, {});
2074
+ },
2075
+ async unfollow (promptUniqueId, executionUniqueId, uniqueId) {
2076
+ await transport.delete(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/unfollow`);
2077
+ },
2078
+ async save (promptUniqueId, executionUniqueId, uniqueId) {
2079
+ await transport.put(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/save`, {});
2080
+ },
2081
+ async unsave (promptUniqueId, executionUniqueId, uniqueId) {
2082
+ await transport.delete(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/unsave`);
2083
+ }
2084
+ };
2085
+ }
2086
+
569
2087
  function createJarvisBlock(transport, config) {
570
2088
  return {
571
2089
  agents: createAgentsService(transport),
572
2090
  prompts: createPromptsService(transport),
573
2091
  workflows: createWorkflowsService(transport),
574
2092
  executions: createExecutionsService(transport),
575
- conversations: createConversationsService(transport)
2093
+ conversations: createConversationsService(transport),
2094
+ aiModels: createAIModelsService(transport),
2095
+ entities: createEntitiesService(transport),
2096
+ clusters: createClustersService(transport),
2097
+ users: createJarvisUsersService(transport),
2098
+ workflowParticipants: createWorkflowParticipantsService(transport),
2099
+ workflowSteps: createWorkflowStepsService(transport),
2100
+ workflowInstances: createWorkflowInstancesService(transport),
2101
+ agentRuntime: createAgentRuntimeService(transport),
2102
+ mailTemplates: createMailTemplatesService(transport),
2103
+ marvinChat: createMarvinChatService(transport),
2104
+ promptComments: createPromptCommentsService(transport),
2105
+ executionComments: createExecutionCommentsService(transport)
576
2106
  };
577
2107
  }
578
2108
  const jarvisBlockMetadata = {
@@ -588,4 +2118,4 @@ const jarvisBlockMetadata = {
588
2118
  ]
589
2119
  };
590
2120
 
591
- export { agentMapper, conversationMapper, createAgentsService, createConversationsService, createExecutionsService, createJarvisBlock, createPromptsService, createWorkflowsService, executionMapper, jarvisBlockMetadata, promptMapper, workflowMapper };
2121
+ export { agentMapper, aiModelMapper, clusterMapper, conversationMapper, createAIModelsService, createAgentRuntimeService, createAgentsService, createClustersService, createConversationsService, createEntitiesService, createExecutionCommentsService, createExecutionsService, createJarvisBlock, createJarvisUsersService, createMailTemplatesService, createMarvinChatService, createPromptCommentsService, createPromptsService, createWorkflowInstancesService, createWorkflowParticipantsService, createWorkflowStepsService, createWorkflowsService, entityMapper, executionCommentMapper, executionMapper, jarvisBlockMetadata, jarvisUserMapper, mailTemplateMapper, promptCommentMapper, promptMapper, workflowInstanceMapper, workflowMapper, workflowParticipantMapper, workflowStepMapper };