@23blocks/block-jarvis 3.3.0 → 4.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 (114) hide show
  1. package/dist/index.esm.js +1195 -1092
  2. package/dist/src/lib/jarvis.block.d.ts +6 -36
  3. package/dist/src/lib/jarvis.block.d.ts.map +1 -1
  4. package/dist/src/lib/mappers/agent-tool-assignment.mapper.d.ts +4 -0
  5. package/dist/src/lib/mappers/agent-tool-assignment.mapper.d.ts.map +1 -0
  6. package/dist/src/lib/mappers/agent-tool.mapper.d.ts +4 -0
  7. package/dist/src/lib/mappers/agent-tool.mapper.d.ts.map +1 -0
  8. package/dist/src/lib/mappers/agent.mapper.d.ts.map +1 -1
  9. package/dist/src/lib/mappers/ai-model.mapper.d.ts.map +1 -1
  10. package/dist/src/lib/mappers/cluster.mapper.d.ts.map +1 -1
  11. package/dist/src/lib/mappers/comment.mapper.d.ts.map +1 -1
  12. package/dist/src/lib/mappers/condition.mapper.d.ts +4 -0
  13. package/dist/src/lib/mappers/condition.mapper.d.ts.map +1 -0
  14. package/dist/src/lib/mappers/conversation.mapper.d.ts.map +1 -1
  15. package/dist/src/lib/mappers/entity.mapper.d.ts.map +1 -1
  16. package/dist/src/lib/mappers/execution.mapper.d.ts.map +1 -1
  17. package/dist/src/lib/mappers/index.d.ts +5 -0
  18. package/dist/src/lib/mappers/index.d.ts.map +1 -1
  19. package/dist/src/lib/mappers/mail-template.mapper.d.ts.map +1 -1
  20. package/dist/src/lib/mappers/prompt.mapper.d.ts.map +1 -1
  21. package/dist/src/lib/mappers/step-transition.mapper.d.ts +4 -0
  22. package/dist/src/lib/mappers/step-transition.mapper.d.ts.map +1 -0
  23. package/dist/src/lib/mappers/tool.mapper.d.ts +4 -0
  24. package/dist/src/lib/mappers/tool.mapper.d.ts.map +1 -0
  25. package/dist/src/lib/mappers/user.mapper.d.ts.map +1 -1
  26. package/dist/src/lib/mappers/workflow-instance.mapper.d.ts.map +1 -1
  27. package/dist/src/lib/mappers/workflow-participant.mapper.d.ts.map +1 -1
  28. package/dist/src/lib/mappers/workflow-step.mapper.d.ts.map +1 -1
  29. package/dist/src/lib/mappers/workflow.mapper.d.ts.map +1 -1
  30. package/dist/src/lib/services/agent-runtime.service.d.ts +3 -53
  31. package/dist/src/lib/services/agent-runtime.service.d.ts.map +1 -1
  32. package/dist/src/lib/services/agent-tool-assignments.service.d.ts +13 -0
  33. package/dist/src/lib/services/agent-tool-assignments.service.d.ts.map +1 -0
  34. package/dist/src/lib/services/agent-tools.service.d.ts +13 -0
  35. package/dist/src/lib/services/agent-tools.service.d.ts.map +1 -0
  36. package/dist/src/lib/services/agents.service.d.ts +4 -30
  37. package/dist/src/lib/services/agents.service.d.ts.map +1 -1
  38. package/dist/src/lib/services/ai-models.service.d.ts +0 -19
  39. package/dist/src/lib/services/ai-models.service.d.ts.map +1 -1
  40. package/dist/src/lib/services/clusters.service.d.ts +4 -52
  41. package/dist/src/lib/services/clusters.service.d.ts.map +1 -1
  42. package/dist/src/lib/services/conditions.service.d.ts +13 -0
  43. package/dist/src/lib/services/conditions.service.d.ts.map +1 -0
  44. package/dist/src/lib/services/conversations.service.d.ts +2 -26
  45. package/dist/src/lib/services/conversations.service.d.ts.map +1 -1
  46. package/dist/src/lib/services/entities.service.d.ts +7 -48
  47. package/dist/src/lib/services/entities.service.d.ts.map +1 -1
  48. package/dist/src/lib/services/execution-comments.service.d.ts +0 -29
  49. package/dist/src/lib/services/execution-comments.service.d.ts.map +1 -1
  50. package/dist/src/lib/services/index.d.ts +5 -0
  51. package/dist/src/lib/services/index.d.ts.map +1 -1
  52. package/dist/src/lib/services/mail-templates.service.d.ts +2 -34
  53. package/dist/src/lib/services/mail-templates.service.d.ts.map +1 -1
  54. package/dist/src/lib/services/prompt-comments.service.d.ts +0 -29
  55. package/dist/src/lib/services/prompt-comments.service.d.ts.map +1 -1
  56. package/dist/src/lib/services/prompts.service.d.ts +1 -33
  57. package/dist/src/lib/services/prompts.service.d.ts.map +1 -1
  58. package/dist/src/lib/services/step-transitions.service.d.ts +13 -0
  59. package/dist/src/lib/services/step-transitions.service.d.ts.map +1 -0
  60. package/dist/src/lib/services/tools.service.d.ts +13 -0
  61. package/dist/src/lib/services/tools.service.d.ts.map +1 -0
  62. package/dist/src/lib/services/users.service.d.ts +3 -60
  63. package/dist/src/lib/services/users.service.d.ts.map +1 -1
  64. package/dist/src/lib/services/workflow-instances.service.d.ts +4 -30
  65. package/dist/src/lib/services/workflow-instances.service.d.ts.map +1 -1
  66. package/dist/src/lib/services/workflow-participants.service.d.ts +0 -19
  67. package/dist/src/lib/services/workflow-participants.service.d.ts.map +1 -1
  68. package/dist/src/lib/services/workflow-steps.service.d.ts +0 -21
  69. package/dist/src/lib/services/workflow-steps.service.d.ts.map +1 -1
  70. package/dist/src/lib/services/workflows.service.d.ts +5 -35
  71. package/dist/src/lib/services/workflows.service.d.ts.map +1 -1
  72. package/dist/src/lib/types/agent-runtime.d.ts +35 -47
  73. package/dist/src/lib/types/agent-runtime.d.ts.map +1 -1
  74. package/dist/src/lib/types/agent-tool-assignment.d.ts +30 -0
  75. package/dist/src/lib/types/agent-tool-assignment.d.ts.map +1 -0
  76. package/dist/src/lib/types/agent-tool.d.ts +42 -0
  77. package/dist/src/lib/types/agent-tool.d.ts.map +1 -0
  78. package/dist/src/lib/types/agent.d.ts +83 -51
  79. package/dist/src/lib/types/agent.d.ts.map +1 -1
  80. package/dist/src/lib/types/ai-model.d.ts +17 -23
  81. package/dist/src/lib/types/ai-model.d.ts.map +1 -1
  82. package/dist/src/lib/types/cluster.d.ts +35 -47
  83. package/dist/src/lib/types/cluster.d.ts.map +1 -1
  84. package/dist/src/lib/types/comment.d.ts +42 -39
  85. package/dist/src/lib/types/comment.d.ts.map +1 -1
  86. package/dist/src/lib/types/condition.d.ts +39 -0
  87. package/dist/src/lib/types/condition.d.ts.map +1 -0
  88. package/dist/src/lib/types/conversation.d.ts +9 -10
  89. package/dist/src/lib/types/conversation.d.ts.map +1 -1
  90. package/dist/src/lib/types/entity.d.ts +60 -56
  91. package/dist/src/lib/types/entity.d.ts.map +1 -1
  92. package/dist/src/lib/types/execution.d.ts +7 -6
  93. package/dist/src/lib/types/execution.d.ts.map +1 -1
  94. package/dist/src/lib/types/index.d.ts +5 -0
  95. package/dist/src/lib/types/index.d.ts.map +1 -1
  96. package/dist/src/lib/types/mail-template.d.ts +36 -45
  97. package/dist/src/lib/types/mail-template.d.ts.map +1 -1
  98. package/dist/src/lib/types/prompt.d.ts +24 -125
  99. package/dist/src/lib/types/prompt.d.ts.map +1 -1
  100. package/dist/src/lib/types/step-transition.d.ts +36 -0
  101. package/dist/src/lib/types/step-transition.d.ts.map +1 -0
  102. package/dist/src/lib/types/tool.d.ts +41 -0
  103. package/dist/src/lib/types/tool.d.ts.map +1 -0
  104. package/dist/src/lib/types/user.d.ts +26 -57
  105. package/dist/src/lib/types/user.d.ts.map +1 -1
  106. package/dist/src/lib/types/workflow-instance.d.ts +24 -14
  107. package/dist/src/lib/types/workflow-instance.d.ts.map +1 -1
  108. package/dist/src/lib/types/workflow-participant.d.ts +9 -16
  109. package/dist/src/lib/types/workflow-participant.d.ts.map +1 -1
  110. package/dist/src/lib/types/workflow-step.d.ts +36 -22
  111. package/dist/src/lib/types/workflow-step.d.ts.map +1 -1
  112. package/dist/src/lib/types/workflow.d.ts +25 -42
  113. package/dist/src/lib/types/workflow.d.ts.map +1 -1
  114. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { _ } from '@swc/helpers/_/_extends';
1
2
  import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
2
3
 
3
4
  /**
@@ -35,17 +36,6 @@ import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
35
36
  }
36
37
  return false;
37
38
  }
38
- /**
39
- * Parse an array of strings
40
- */ function parseStringArray(value) {
41
- if (value === null || value === undefined) {
42
- return undefined;
43
- }
44
- if (Array.isArray(value)) {
45
- return value.map(String);
46
- }
47
- return undefined;
48
- }
49
39
  /**
50
40
  * Parse an optional number value
51
41
  */ function parseOptionalNumber(value) {
@@ -64,46 +54,95 @@ import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
64
54
  }
65
55
  return 'active';
66
56
  }
67
- /**
68
- * Parse execution status
69
- */ function parseExecutionStatus(value) {
70
- const status = parseString(value);
71
- if (status === 'pending' || status === 'running' || status === 'completed' || status === 'failed') {
72
- return status;
73
- }
74
- return 'pending';
75
- }
76
- /**
77
- * Parse message role
78
- */ function parseMessageRole(value) {
79
- const role = parseString(value);
80
- if (role === 'user' || role === 'assistant' || role === 'system') {
81
- return role;
82
- }
83
- return 'user';
84
- }
85
57
 
86
58
  const agentMapper = {
87
59
  type: 'Agent',
88
60
  map: (resource)=>({
89
61
  id: resource.id,
90
- uniqueId: parseString(resource.attributes['unique_id']),
91
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
92
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
93
- code: parseString(resource.attributes['code']) || '',
62
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
94
63
  name: parseString(resource.attributes['name']) || '',
95
64
  description: parseString(resource.attributes['description']),
96
- systemPrompt: parseString(resource.attributes['system_prompt']),
65
+ instructions: parseString(resource.attributes['instructions']),
97
66
  model: parseString(resource.attributes['model']),
98
- temperature: parseOptionalNumber(resource.attributes['temperature']),
99
- maxTokens: parseOptionalNumber(resource.attributes['max_tokens']),
100
- tools: parseStringArray(resource.attributes['tools']),
101
- status: parseStatus(resource.attributes['status']),
102
- enabled: parseBoolean(resource.attributes['enabled']),
103
- payload: resource.attributes['payload']
67
+ source: parseString(resource.attributes['source']),
68
+ sourceId: parseString(resource.attributes['source_id']),
69
+ sourceType: parseString(resource.attributes['source_type']),
70
+ sourceAlias: parseString(resource.attributes['source_alias']),
71
+ contentUrl: parseString(resource.attributes['content_url']),
72
+ imageUrl: parseString(resource.attributes['image_url']),
73
+ videoUrl: parseString(resource.attributes['video_url']),
74
+ agentIdentifier: parseString(resource.attributes['agent_identifier']),
75
+ ragEnabled: resource.attributes['rag_enabled'] != null ? parseBoolean(resource.attributes['rag_enabled']) : undefined,
76
+ contextWindow: parseOptionalNumber(resource.attributes['context_window']),
77
+ encryptionKey: parseString(resource.attributes['encryption_key']),
78
+ rateLimitPerHour: parseOptionalNumber(resource.attributes['rate_limit_per_hour']),
79
+ communicationEnabled: resource.attributes['communication_enabled'] != null ? parseBoolean(resource.attributes['communication_enabled']) : undefined,
80
+ email: parseString(resource.attributes['email']),
81
+ emailProcessorUrl: parseString(resource.attributes['email_processor_url']),
82
+ allowedDomains: parseString(resource.attributes['allowed_domains']),
83
+ phoneNumber: parseString(resource.attributes['phone_number']),
84
+ smsProcessorUrl: parseString(resource.attributes['sms_processor_url']),
85
+ integrationServicesEnabled: resource.attributes['integration_services_enabled'] != null ? parseBoolean(resource.attributes['integration_services_enabled']) : undefined,
86
+ webhookUrl: parseString(resource.attributes['webhook_url']),
87
+ webhookSecret: parseString(resource.attributes['webhook_secret']),
88
+ apiUrl: parseString(resource.attributes['api_url']),
89
+ imEnabled: resource.attributes['im_enabled'] != null ? parseBoolean(resource.attributes['im_enabled']) : undefined,
90
+ imAppsConfig: parseString(resource.attributes['im_apps_config']),
91
+ supervisorEnabled: resource.attributes['supervisor_enabled'] != null ? parseBoolean(resource.attributes['supervisor_enabled']) : undefined,
92
+ supervisorEmail: parseString(resource.attributes['supervisor_email']),
93
+ supervisorPhoneNumber: parseString(resource.attributes['supervisor_phone_number']),
94
+ lastActivityAt: parseDate(resource.attributes['last_activity_at']),
95
+ totalMessagesProcessed: parseOptionalNumber(resource.attributes['total_messages_processed']),
96
+ averageResponseTime: parseOptionalNumber(resource.attributes['average_response_time']),
97
+ errorCount: parseOptionalNumber(resource.attributes['error_count']),
98
+ successRate: parseOptionalNumber(resource.attributes['success_rate']),
99
+ status: parseString(resource.attributes['status']) || 'active',
100
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
101
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
102
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
104
103
  })
105
104
  };
106
105
 
106
+ function buildAgentBody(data) {
107
+ const body = {};
108
+ if (data.name) body['name'] = data.name;
109
+ if (data.description) body['description'] = data.description;
110
+ if (data.instructions) body['instructions'] = data.instructions;
111
+ if (data.model) body['model'] = data.model;
112
+ if (data.source) body['source'] = data.source;
113
+ if (data.sourceId) body['source_id'] = data.sourceId;
114
+ if (data.sourceType) body['source_type'] = data.sourceType;
115
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
116
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
117
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
118
+ if (data.videoUrl) body['video_url'] = data.videoUrl;
119
+ if (data.agentIdentifier) body['agent_identifier'] = data.agentIdentifier;
120
+ if (data.ragEnabled !== undefined) body['rag_enabled'] = data.ragEnabled;
121
+ if (data.contextWindow !== undefined) body['context_window'] = data.contextWindow;
122
+ if (data.encryptionKey) body['encryption_key'] = data.encryptionKey;
123
+ if (data.rateLimitPerHour !== undefined) body['rate_limit_per_hour'] = data.rateLimitPerHour;
124
+ if (data.communicationEnabled !== undefined) body['communication_enabled'] = data.communicationEnabled;
125
+ if (data.email) body['email'] = data.email;
126
+ if (data.emailProcessorUrl) body['email_processor_url'] = data.emailProcessorUrl;
127
+ if (data.allowedDomains) body['allowed_domains'] = data.allowedDomains;
128
+ if (data.phoneNumber) body['phone_number'] = data.phoneNumber;
129
+ if (data.smsProcessorUrl) body['sms_processor_url'] = data.smsProcessorUrl;
130
+ if (data.integrationServicesEnabled !== undefined) body['integration_services_enabled'] = data.integrationServicesEnabled;
131
+ if (data.webhookUrl) body['webhook_url'] = data.webhookUrl;
132
+ if (data.webhookSecret) body['webhook_secret'] = data.webhookSecret;
133
+ if (data.apiUrl) body['api_url'] = data.apiUrl;
134
+ if (data.imEnabled !== undefined) body['im_enabled'] = data.imEnabled;
135
+ if (data.imAppsConfig) body['im_apps_config'] = data.imAppsConfig;
136
+ if (data.supervisorEnabled !== undefined) body['supervisor_enabled'] = data.supervisorEnabled;
137
+ if (data.supervisorEmail) body['supervisor_email'] = data.supervisorEmail;
138
+ if (data.supervisorPhoneNumber) body['supervisor_phone_number'] = data.supervisorPhoneNumber;
139
+ if (data.lastActivityAt) body['last_activity_at'] = data.lastActivityAt;
140
+ if (data.totalMessagesProcessed !== undefined) body['total_messages_processed'] = data.totalMessagesProcessed;
141
+ if (data.averageResponseTime !== undefined) body['average_response_time'] = data.averageResponseTime;
142
+ if (data.errorCount !== undefined) body['error_count'] = data.errorCount;
143
+ if (data.successRate !== undefined) body['success_rate'] = data.successRate;
144
+ return body;
145
+ }
107
146
  function createAgentsService(transport, _config) {
108
147
  return {
109
148
  async list (params) {
@@ -124,121 +163,73 @@ function createAgentsService(transport, _config) {
124
163
  },
125
164
  async create (data) {
126
165
  const response = await transport.post('/agents', {
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
137
- }
166
+ agent: buildAgentBody(data)
138
167
  });
139
168
  return decodeOne(response, agentMapper);
140
169
  },
141
170
  async update (uniqueId, data) {
142
171
  const response = await transport.put(`/agents/${uniqueId}`, {
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
154
- }
172
+ agent: buildAgentBody(data)
155
173
  });
156
174
  return decodeOne(response, agentMapper);
157
175
  },
158
176
  async delete (uniqueId) {
159
177
  await transport.delete(`/agents/${uniqueId}`);
160
178
  },
161
- async chat (uniqueId, data) {
162
- const response = await transport.post(`/agents/${uniqueId}/chat`, {
163
- message: data.message,
164
- conversation_unique_id: data.conversationUniqueId,
165
- user_unique_id: data.userUniqueId,
166
- payload: data.payload
179
+ async addPrompt (uniqueId, data) {
180
+ const response = await transport.post(`/agents/${uniqueId}/add_prompt`, {
181
+ prompt: {
182
+ unique_id: data.uniqueId
183
+ }
167
184
  });
168
- return {
169
- response: response.response,
170
- conversationUniqueId: response.conversation_unique_id,
171
- executionUniqueId: response.execution_unique_id,
172
- tokens: response.tokens,
173
- cost: response.cost
174
- };
185
+ return decodeOne(response, agentMapper);
175
186
  },
176
- async complete (uniqueId, data) {
177
- const response = await transport.post(`/agents/${uniqueId}/complete`, {
178
- input: data.input,
179
- payload: data.payload
187
+ async addEntity (uniqueId, data) {
188
+ const response = await transport.post(`/agents/${uniqueId}/add_entity`, {
189
+ entity: _({
190
+ entity_unique_id: data.entityUniqueId
191
+ }, data.relationType && {
192
+ relation_type: data.relationType
193
+ })
180
194
  });
181
- return {
182
- output: response.output,
183
- executionUniqueId: response.execution_unique_id,
184
- tokens: response.tokens,
185
- cost: response.cost,
186
- duration: response.duration
187
- };
195
+ return decodeOne(response, agentMapper);
196
+ },
197
+ async removeEntity (uniqueId, data) {
198
+ const response = await transport.post(`/agents/${uniqueId}/remove_entity`, {
199
+ entity: _({
200
+ entity_unique_id: data.entityUniqueId
201
+ }, data.relationType && {
202
+ relation_type: data.relationType
203
+ })
204
+ });
205
+ return decodeOne(response, agentMapper);
188
206
  }
189
207
  };
190
208
  }
191
209
 
192
- function parseTemplateInfo(value) {
193
- if (value && typeof value === 'object') {
194
- const obj = value;
195
- return {
196
- name: parseString(obj['name']),
197
- type: parseString(obj['type']),
198
- description: parseString(obj['description'])
199
- };
200
- }
201
- return undefined;
202
- }
203
210
  const promptMapper = {
204
211
  type: 'Prompt',
205
212
  map: (resource)=>({
206
213
  id: resource.id,
207
- uniqueId: parseString(resource.attributes['unique_id']),
214
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
208
215
  createdAt: parseDate(resource.attributes['created_at']) || new Date(),
209
216
  updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
210
- // Core identifiers
211
217
  promptVersionUniqueId: parseString(resource.attributes['prompt_version_unique_id']),
212
218
  agentUniqueId: parseString(resource.attributes['agent_unique_id']),
213
- // Basic info
214
219
  name: parseString(resource.attributes['name']) || '',
215
- code: parseString(resource.attributes['code']),
216
220
  promptType: parseString(resource.attributes['prompt_type']),
217
221
  abstract: parseString(resource.attributes['abstract']),
218
222
  keywords: parseString(resource.attributes['keywords']),
219
- description: parseString(resource.attributes['description']),
220
- // Content
221
223
  content: parseString(resource.attributes['content']),
222
- template: parseString(resource.attributes['template']),
223
- variables: parseStringArray(resource.attributes['variables']),
224
- // Template system
225
- templateData: resource.attributes['template_data'],
226
- templateSchema: resource.attributes['template_schema'],
227
- templateInfo: parseTemplateInfo(resource.attributes['template_info']),
228
- placeholders: parseStringArray(resource.attributes['placeholders']),
229
- provider: parseString(resource.attributes['provider']),
230
- // Media
231
224
  thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
232
225
  imageUrl: parseString(resource.attributes['image_url']),
233
226
  mediaUrl: parseString(resource.attributes['media_url']),
234
227
  contentUrl: parseString(resource.attributes['content_url']),
235
228
  repoUrl: parseString(resource.attributes['repo_url']),
236
- // Publishing
237
229
  publishAt: parseDate(resource.attributes['publish_at']),
238
230
  publishUntil: parseDate(resource.attributes['publish_until']),
239
231
  isPublic: parseBoolean(resource.attributes['is_public']),
240
232
  source: parseString(resource.attributes['source']),
241
- // AI Model Settings
242
233
  model: parseString(resource.attributes['model']),
243
234
  frequencyPenalty: parseOptionalNumber(resource.attributes['frequency_penalty']),
244
235
  maxTokens: parseOptionalNumber(resource.attributes['max_tokens']),
@@ -247,7 +238,6 @@ const promptMapper = {
247
238
  seed: parseOptionalNumber(resource.attributes['seed']),
248
239
  temperature: parseOptionalNumber(resource.attributes['temperature']),
249
240
  topP: parseOptionalNumber(resource.attributes['top_p']),
250
- // Prompt Components
251
241
  user: parseString(resource.attributes['user']),
252
242
  persona: parseString(resource.attributes['persona']),
253
243
  guidelines: parseString(resource.attributes['guidelines']),
@@ -256,24 +246,58 @@ const promptMapper = {
256
246
  sample: parseString(resource.attributes['sample']),
257
247
  outputTemplate: parseString(resource.attributes['output_template']),
258
248
  safeguard: parseString(resource.attributes['safeguard']),
259
- // Versioning & Status
249
+ promptTemplateId: parseString(resource.attributes['prompt_template_id']),
250
+ templateData: resource.attributes['template_data'],
260
251
  version: parseOptionalNumber(resource.attributes['version']),
261
252
  status: parseStatus(resource.attributes['status']),
262
253
  enabled: parseBoolean(resource.attributes['enabled']),
263
- // Engagement
264
254
  likes: parseOptionalNumber(resource.attributes['likes']),
265
255
  dislikes: parseOptionalNumber(resource.attributes['dislikes']),
266
256
  comments: parseOptionalNumber(resource.attributes['comments']),
267
- // Author info
268
257
  userUniqueId: parseString(resource.attributes['user_unique_id']),
269
258
  userName: parseString(resource.attributes['user_name']),
270
259
  userAlias: parseString(resource.attributes['user_alias']),
271
- userAvatarUrl: parseString(resource.attributes['user_avatar_url']),
272
- // Custom data
273
- payload: resource.attributes['payload']
260
+ userAvatarUrl: parseString(resource.attributes['user_avatar_url'])
274
261
  })
275
262
  };
276
263
 
264
+ function buildPromptBody(data) {
265
+ const body = {};
266
+ if (data.name) body['name'] = data.name;
267
+ if (data.promptType) body['prompt_type'] = data.promptType;
268
+ if (data.abstract) body['abstract'] = data.abstract;
269
+ if (data.keywords) body['keywords'] = data.keywords;
270
+ if (data.content) body['content'] = data.content;
271
+ if (data.thumbnailUrl) body['thumbnail_url'] = data.thumbnailUrl;
272
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
273
+ if (data.mediaUrl) body['media_url'] = data.mediaUrl;
274
+ if (data.publishAt) body['publish_at'] = data.publishAt;
275
+ if (data.publishUntil) body['publish_until'] = data.publishUntil;
276
+ if (data.model) body['model'] = data.model;
277
+ if (data.frequencyPenalty !== undefined) body['frequency_penalty'] = data.frequencyPenalty;
278
+ if (data.maxTokens !== undefined) body['max_tokens'] = data.maxTokens;
279
+ if (data.responses !== undefined) body['responses'] = data.responses;
280
+ if (data.responseFormat) body['response_format'] = data.responseFormat;
281
+ if (data.seed !== undefined) body['seed'] = data.seed;
282
+ if (data.temperature !== undefined) body['temperature'] = data.temperature;
283
+ if (data.topP !== undefined) body['top_p'] = data.topP;
284
+ if (data.user) body['user'] = data.user;
285
+ if (data.persona) body['persona'] = data.persona;
286
+ if (data.guidelines) body['guidelines'] = data.guidelines;
287
+ if (data.actions) body['actions'] = data.actions;
288
+ if (data.references) body['references'] = data.references;
289
+ if (data.sample) body['sample'] = data.sample;
290
+ if (data.outputTemplate) body['output_template'] = data.outputTemplate;
291
+ if (data.safeguard) body['safeguard'] = data.safeguard;
292
+ if (data.promptTemplateId) body['prompt_template_id'] = data.promptTemplateId;
293
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
294
+ if (data.repoUrl) body['repo_url'] = data.repoUrl;
295
+ if (data.status) body['status'] = data.status;
296
+ if (data.isPublic !== undefined) body['is_public'] = data.isPublic;
297
+ if (data.source) body['source'] = data.source;
298
+ if (data.templateData) body['template_data'] = data.templateData;
299
+ return body;
300
+ }
277
301
  function createPromptsService(transport, _config) {
278
302
  return {
279
303
  async list (params) {
@@ -295,39 +319,13 @@ function createPromptsService(transport, _config) {
295
319
  },
296
320
  async create (data) {
297
321
  const response = await transport.post('/prompts', {
298
- prompt: {
299
- agent_unique_id: data.agentUniqueId,
300
- code: data.code,
301
- name: data.name,
302
- description: data.description,
303
- template: data.template,
304
- variables: data.variables,
305
- template_data: data.templateData,
306
- template_schema: data.templateSchema,
307
- template_info: data.templateInfo,
308
- placeholders: data.placeholders,
309
- provider: data.provider,
310
- payload: data.payload
311
- }
322
+ prompt: buildPromptBody(data)
312
323
  });
313
324
  return decodeOne(response, promptMapper);
314
325
  },
315
326
  async update (uniqueId, data) {
316
327
  const response = await transport.put(`/prompts/${uniqueId}`, {
317
- prompt: {
318
- name: data.name,
319
- description: data.description,
320
- template: data.template,
321
- variables: data.variables,
322
- template_data: data.templateData,
323
- template_schema: data.templateSchema,
324
- template_info: data.templateInfo,
325
- placeholders: data.placeholders,
326
- provider: data.provider,
327
- enabled: data.enabled,
328
- status: data.status,
329
- payload: data.payload
330
- }
328
+ prompt: buildPromptBody(data)
331
329
  });
332
330
  return decodeOne(response, promptMapper);
333
331
  },
@@ -337,8 +335,7 @@ function createPromptsService(transport, _config) {
337
335
  async execute (uniqueId, data) {
338
336
  const response = await transport.post(`/prompts/${uniqueId}/execute`, {
339
337
  agent_unique_id: data.agentUniqueId,
340
- variables: data.variables,
341
- payload: data.payload
338
+ variables: data.variables
342
339
  });
343
340
  return {
344
341
  output: response.output,
@@ -348,24 +345,11 @@ function createPromptsService(transport, _config) {
348
345
  duration: response.duration
349
346
  };
350
347
  },
351
- async test (data) {
352
- const response = await transport.post('/prompts/test', {
353
- template: data.template,
354
- variables: data.variables,
355
- agent_unique_id: data.agentUniqueId
356
- });
357
- return {
358
- renderedPrompt: response.rendered_prompt,
359
- isValid: response.is_valid,
360
- errors: response.errors
361
- };
362
- },
363
348
  async render (uniqueId, data) {
364
349
  var _response_data, _response_data1, _response_data_meta, _response_data2, _response_meta, _response_data_meta1, _response_data3, _response_meta1, _response_data_meta2, _response_data4, _response_meta2, _response_data_meta3, _response_data5, _response_meta3;
365
350
  const response = await transport.post(`/prompts/${uniqueId}/render`, {
366
351
  placeholders: data.placeholders
367
352
  });
368
- // Parse JSON:API response - the rendered prompt comes in data.attributes
369
353
  const attributes = ((_response_data = response.data) == null ? void 0 : _response_data.attributes) || response;
370
354
  var _response_data_id;
371
355
  return {
@@ -378,7 +362,6 @@ function createPromptsService(transport, _config) {
378
362
  model: attributes.model,
379
363
  temperature: attributes.temperature,
380
364
  maxTokens: attributes.max_tokens || attributes.maxTokens,
381
- provider: attributes.provider,
382
365
  meta: {
383
366
  placeholdersProvided: ((_response_data2 = response.data) == null ? void 0 : (_response_data_meta = _response_data2.meta) == null ? void 0 : _response_data_meta.placeholders_provided) || ((_response_meta = response.meta) == null ? void 0 : _response_meta.placeholders_provided) || [],
384
367
  placeholdersMissing: ((_response_data3 = response.data) == null ? void 0 : (_response_data_meta1 = _response_data3.meta) == null ? void 0 : _response_data_meta1.placeholders_missing) || ((_response_meta1 = response.meta) == null ? void 0 : _response_meta1.placeholders_missing) || [],
@@ -394,20 +377,90 @@ const workflowMapper = {
394
377
  type: 'Workflow',
395
378
  map: (resource)=>({
396
379
  id: resource.id,
397
- uniqueId: parseString(resource.attributes['unique_id']),
380
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
381
+ name: parseString(resource.attributes['name']) || '',
382
+ description: parseString(resource.attributes['description']),
383
+ source: parseString(resource.attributes['source']),
384
+ sourceId: parseString(resource.attributes['source_id']),
385
+ sourceType: parseString(resource.attributes['source_type']),
386
+ sourceAlias: parseString(resource.attributes['source_alias']),
387
+ contentUrl: parseString(resource.attributes['content_url']),
388
+ imageUrl: parseString(resource.attributes['image_url']),
389
+ videoUrl: parseString(resource.attributes['video_url']),
390
+ status: parseString(resource.attributes['status']) || 'active',
391
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
398
392
  createdAt: parseDate(resource.attributes['created_at']) || new Date(),
399
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
400
- code: parseString(resource.attributes['code']) || '',
393
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
394
+ })
395
+ };
396
+
397
+ const workflowStepMapper = {
398
+ type: 'workflow_step',
399
+ map: (resource)=>({
400
+ id: resource.id,
401
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
402
+ workflowUniqueId: parseString(resource.attributes['workflow_unique_id']) || '',
401
403
  name: parseString(resource.attributes['name']) || '',
402
404
  description: parseString(resource.attributes['description']),
403
- steps: resource.attributes['steps'] || [],
404
- triggers: resource.attributes['triggers'],
405
- status: parseStatus(resource.attributes['status']),
406
- enabled: parseBoolean(resource.attributes['enabled']),
407
- payload: resource.attributes['payload']
405
+ source: parseString(resource.attributes['source']),
406
+ sourceId: parseString(resource.attributes['source_id']),
407
+ sourceType: parseString(resource.attributes['source_type']),
408
+ sourceAlias: parseString(resource.attributes['source_alias']),
409
+ order: parseOptionalNumber(resource.attributes['order']),
410
+ stepUrl: parseString(resource.attributes['step_url']),
411
+ stepParams: parseString(resource.attributes['step_params']),
412
+ agentUniqueId: parseString(resource.attributes['agent_unique_id']),
413
+ agentName: parseString(resource.attributes['agent_name']),
414
+ promptUniqueId: parseString(resource.attributes['prompt_unique_id']),
415
+ promptName: parseString(resource.attributes['prompt_name']),
416
+ customPrompt: parseString(resource.attributes['custom_prompt']),
417
+ contentUrl: parseString(resource.attributes['content_url']),
418
+ imageUrl: parseString(resource.attributes['image_url']),
419
+ videoUrl: parseString(resource.attributes['video_url']),
420
+ status: parseString(resource.attributes['status']) || 'active',
421
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
422
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
423
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
408
424
  })
409
425
  };
410
426
 
427
+ function buildWorkflowBody(data) {
428
+ const body = {};
429
+ if (data.name) body['name'] = data.name;
430
+ if (data.description) body['description'] = data.description;
431
+ if (data.source) body['source'] = data.source;
432
+ if (data.sourceId) body['source_id'] = data.sourceId;
433
+ if (data.sourceType) body['source_type'] = data.sourceType;
434
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
435
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
436
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
437
+ if (data.videoUrl) body['video_url'] = data.videoUrl;
438
+ if (data.status) body['status'] = data.status;
439
+ return body;
440
+ }
441
+ function buildStepBody$2(data) {
442
+ const body = {};
443
+ if (data.name) body['name'] = data.name;
444
+ if (data.description) body['description'] = data.description;
445
+ if (data.source) body['source'] = data.source;
446
+ if (data.sourceId) body['source_id'] = data.sourceId;
447
+ if (data.sourceType) body['source_type'] = data.sourceType;
448
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
449
+ if (data.order !== undefined) body['order'] = data.order;
450
+ if (data.stepUrl) body['step_url'] = data.stepUrl;
451
+ if (data.stepParams) body['step_params'] = data.stepParams;
452
+ if (data.agentUniqueId) body['agent_unique_id'] = data.agentUniqueId;
453
+ if (data.agentName) body['agent_name'] = data.agentName;
454
+ if (data.promptUniqueId) body['prompt_unique_id'] = data.promptUniqueId;
455
+ if (data.promptName) body['prompt_name'] = data.promptName;
456
+ if (data.customPrompt) body['custom_prompt'] = data.customPrompt;
457
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
458
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
459
+ if (data.videoUrl) body['video_url'] = data.videoUrl;
460
+ if (data.status) body['status'] = data.status;
461
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
462
+ return body;
463
+ }
411
464
  function createWorkflowsService(transport, _config) {
412
465
  return {
413
466
  async list (params) {
@@ -428,63 +481,42 @@ function createWorkflowsService(transport, _config) {
428
481
  },
429
482
  async create (data) {
430
483
  const response = await transport.post('/workflows', {
431
- workflow: {
432
- code: data.code,
433
- name: data.name,
434
- description: data.description,
435
- steps: data.steps,
436
- triggers: data.triggers,
437
- payload: data.payload
438
- }
484
+ workflow: buildWorkflowBody(data)
439
485
  });
440
486
  return decodeOne(response, workflowMapper);
441
487
  },
442
488
  async update (uniqueId, data) {
443
489
  const response = await transport.put(`/workflows/${uniqueId}`, {
444
- workflow: {
445
- name: data.name,
446
- description: data.description,
447
- steps: data.steps,
448
- triggers: data.triggers,
449
- enabled: data.enabled,
450
- status: data.status,
451
- payload: data.payload
452
- }
490
+ workflow: buildWorkflowBody(data)
453
491
  });
454
492
  return decodeOne(response, workflowMapper);
455
493
  },
456
494
  async delete (uniqueId) {
457
495
  await transport.delete(`/workflows/${uniqueId}`);
458
496
  },
459
- async run (uniqueId, data) {
460
- const response = await transport.post(`/workflows/${uniqueId}/run`, {
461
- input: data.input,
462
- payload: data.payload
497
+ async addStep (uniqueId, data) {
498
+ const response = await transport.post(`/workflows/${uniqueId}/add_step`, {
499
+ step: buildStepBody$2(data)
463
500
  });
464
- return {
465
- executionUniqueId: response.execution_unique_id,
466
- status: response.status,
467
- output: response.output
468
- };
501
+ return decodeOne(response, workflowStepMapper);
469
502
  },
470
- async pause (uniqueId) {
471
- const response = await transport.post(`/workflows/${uniqueId}/pause`, {});
472
- return decodeOne(response, workflowMapper);
503
+ async updateStep (uniqueId, stepUniqueId, data) {
504
+ const response = await transport.put(`/workflows/${uniqueId}/steps/${stepUniqueId}`, {
505
+ step: buildStepBody$2(data)
506
+ });
507
+ return decodeOne(response, workflowStepMapper);
473
508
  },
474
- async resume (uniqueId) {
475
- const response = await transport.post(`/workflows/${uniqueId}/resume`, {});
476
- return decodeOne(response, workflowMapper);
509
+ async removeStep (uniqueId, stepUniqueId) {
510
+ await transport.delete(`/workflows/${uniqueId}/steps/${stepUniqueId}`);
477
511
  }
478
512
  };
479
513
  }
480
514
 
481
515
  const executionMapper = {
482
- type: 'Execution',
516
+ type: 'execution',
483
517
  map: (resource)=>({
484
518
  id: resource.id,
485
- uniqueId: parseString(resource.attributes['unique_id']),
486
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
487
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
519
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
488
520
  agentUniqueId: parseString(resource.attributes['agent_unique_id']),
489
521
  promptUniqueId: parseString(resource.attributes['prompt_unique_id']),
490
522
  input: parseString(resource.attributes['input']),
@@ -492,10 +524,11 @@ const executionMapper = {
492
524
  tokens: parseOptionalNumber(resource.attributes['tokens']),
493
525
  cost: parseOptionalNumber(resource.attributes['cost']),
494
526
  duration: parseOptionalNumber(resource.attributes['duration']),
495
- status: parseExecutionStatus(resource.attributes['status']),
527
+ status: parseString(resource.attributes['status']) || 'pending',
496
528
  startedAt: parseDate(resource.attributes['started_at']),
497
529
  completedAt: parseDate(resource.attributes['completed_at']),
498
- payload: resource.attributes['payload']
530
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
531
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
499
532
  })
500
533
  };
501
534
 
@@ -548,18 +581,17 @@ function createExecutionsService(transport, _config) {
548
581
  }
549
582
 
550
583
  const conversationMapper = {
551
- type: 'Conversation',
584
+ type: 'conversation',
552
585
  map: (resource)=>({
553
586
  id: resource.id,
554
- uniqueId: parseString(resource.attributes['unique_id']),
555
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
556
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
587
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
557
588
  agentUniqueId: parseString(resource.attributes['agent_unique_id']),
558
589
  userUniqueId: parseString(resource.attributes['user_unique_id']),
559
590
  title: parseString(resource.attributes['title']),
560
591
  messages: parseMessages(resource.attributes['messages']),
561
- status: parseStatus(resource.attributes['status']),
562
- payload: resource.attributes['payload']
592
+ status: parseString(resource.attributes['status']) || 'active',
593
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
594
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
563
595
  })
564
596
  };
565
597
  function parseMessages(value) {
@@ -567,10 +599,9 @@ function parseMessages(value) {
567
599
  return [];
568
600
  }
569
601
  return value.map((msg)=>({
570
- role: parseMessageRole(msg.role),
602
+ role: msg.role || 'user',
571
603
  content: parseString(msg.content) || '',
572
- timestamp: parseDate(msg.timestamp) || new Date(),
573
- payload: msg.payload
604
+ timestamp: parseDate(msg.timestamp) || new Date()
574
605
  }));
575
606
  }
576
607
 
@@ -594,34 +625,33 @@ function createConversationsService(transport, _config) {
594
625
  return decodeOne(response, conversationMapper);
595
626
  },
596
627
  async create (data) {
628
+ const body = {};
629
+ if (data.agentUniqueId) body['agent_unique_id'] = data.agentUniqueId;
630
+ if (data.userUniqueId) body['user_unique_id'] = data.userUniqueId;
631
+ if (data.title) body['title'] = data.title;
597
632
  const response = await transport.post('/conversations', {
598
- conversation: {
599
- agent_unique_id: data.agentUniqueId,
600
- user_unique_id: data.userUniqueId,
601
- title: data.title,
602
- payload: data.payload
603
- }
633
+ conversation: body
604
634
  });
605
635
  return decodeOne(response, conversationMapper);
606
636
  },
607
637
  async sendMessage (uniqueId, data) {
638
+ var _response_message, _response_message1, _response_message2;
639
+ const body = {};
640
+ if (data.message) body['content'] = data.message;
641
+ if (data.role) body['role'] = data.role;
608
642
  const response = await transport.post(`/conversations/${uniqueId}/messages`, {
609
- message: data.message,
610
- role: data.role,
611
- payload: data.payload
643
+ message: body
612
644
  });
613
645
  return {
614
646
  message: {
615
- role: response.message.role,
616
- content: response.message.content,
617
- timestamp: new Date(response.message.timestamp),
618
- payload: response.message.payload
647
+ role: ((_response_message = response.message) == null ? void 0 : _response_message.role) || 'user',
648
+ content: ((_response_message1 = response.message) == null ? void 0 : _response_message1.content) || '',
649
+ timestamp: new Date(((_response_message2 = response.message) == null ? void 0 : _response_message2.timestamp) || Date.now())
619
650
  },
620
651
  response: response.response ? {
621
- role: response.response.role,
622
- content: response.response.content,
623
- timestamp: new Date(response.response.timestamp),
624
- payload: response.response.payload
652
+ role: response.response.role || 'assistant',
653
+ content: response.response.content || '',
654
+ timestamp: new Date(response.response.timestamp || Date.now())
625
655
  } : undefined,
626
656
  executionUniqueId: response.execution_unique_id,
627
657
  tokens: response.tokens,
@@ -649,35 +679,47 @@ function createConversationsService(transport, _config) {
649
679
 
650
680
  const aiModelMapper = {
651
681
  type: 'ai_model',
652
- map: (resource)=>{
653
- 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;
654
- return {
682
+ map: (resource)=>({
655
683
  id: resource.id,
656
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
657
- code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
658
- name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
659
- provider: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['provider'],
660
- modelId: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['model_id'],
661
- description: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['description'],
662
- inputTokenCost: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['input_token_cost'],
663
- outputTokenCost: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['output_token_cost'],
664
- maxTokens: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['max_tokens'],
665
- enabled: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['enabled'],
666
- status: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['status'],
667
- payload: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['payload'],
668
- createdAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['created_at']),
669
- updatedAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['updated_at'])
670
- };
671
- }
684
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
685
+ name: parseString(resource.attributes['name']) || '',
686
+ vendorName: parseString(resource.attributes['vendor_name']),
687
+ vendorUniqueId: parseString(resource.attributes['vendor_unique_id']),
688
+ contentUrl: parseString(resource.attributes['content_url']),
689
+ thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
690
+ imageUrl: parseString(resource.attributes['image_url']),
691
+ videoUrl: parseString(resource.attributes['video_url']),
692
+ inputTokenCost: parseOptionalNumber(resource.attributes['input_token_cost']),
693
+ outputTokenCost: parseOptionalNumber(resource.attributes['output_token_cost']),
694
+ apiUrl: parseString(resource.attributes['api_url']),
695
+ status: parseString(resource.attributes['status']) || 'active',
696
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
697
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
698
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
699
+ })
672
700
  };
673
701
 
702
+ function buildAIModelBody(data) {
703
+ const body = {};
704
+ if (data.name) body['name'] = data.name;
705
+ if (data.vendorName) body['vendor_name'] = data.vendorName;
706
+ if (data.vendorUniqueId) body['vendor_unique_id'] = data.vendorUniqueId;
707
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
708
+ if (data.thumbnailUrl) body['thumbnail_url'] = data.thumbnailUrl;
709
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
710
+ if (data.videoUrl) body['video_url'] = data.videoUrl;
711
+ if (data.inputTokenCost !== undefined) body['input_token_cost'] = data.inputTokenCost;
712
+ if (data.outputTokenCost !== undefined) body['output_token_cost'] = data.outputTokenCost;
713
+ if (data.apiUrl) body['api_url'] = data.apiUrl;
714
+ if (data.status) body['status'] = data.status;
715
+ return body;
716
+ }
674
717
  function createAIModelsService(transport, _config) {
675
718
  return {
676
719
  async list (params) {
677
720
  const queryParams = {};
678
721
  if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
679
722
  if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
680
- if (params == null ? void 0 : params.provider) queryParams['provider'] = params.provider;
681
723
  if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
682
724
  if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
683
725
  if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
@@ -692,32 +734,13 @@ function createAIModelsService(transport, _config) {
692
734
  },
693
735
  async create (data) {
694
736
  const response = await transport.post('/ai_models', {
695
- ai_model: {
696
- code: data.code,
697
- name: data.name,
698
- provider: data.provider,
699
- model_id: data.modelId,
700
- description: data.description,
701
- input_token_cost: data.inputTokenCost,
702
- output_token_cost: data.outputTokenCost,
703
- max_tokens: data.maxTokens,
704
- payload: data.payload
705
- }
737
+ ai_model: buildAIModelBody(data)
706
738
  });
707
739
  return decodeOne(response, aiModelMapper);
708
740
  },
709
741
  async update (uniqueId, data) {
710
742
  const response = await transport.put(`/ai_models/${uniqueId}`, {
711
- ai_model: {
712
- name: data.name,
713
- description: data.description,
714
- input_token_cost: data.inputTokenCost,
715
- output_token_cost: data.outputTokenCost,
716
- max_tokens: data.maxTokens,
717
- enabled: data.enabled,
718
- status: data.status,
719
- payload: data.payload
720
- }
743
+ ai_model: buildAIModelBody(data)
721
744
  });
722
745
  return decodeOne(response, aiModelMapper);
723
746
  },
@@ -729,25 +752,84 @@ function createAIModelsService(transport, _config) {
729
752
 
730
753
  const entityMapper = {
731
754
  type: 'entity',
732
- map: (resource)=>{
733
- var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10;
734
- return {
755
+ map: (resource)=>({
735
756
  id: resource.id,
736
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
737
- code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
738
- name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
739
- description: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['description'],
740
- systemPrompt: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['system_prompt'],
741
- model: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['model'],
742
- enabled: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['enabled'],
743
- status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
744
- payload: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['payload'],
745
- createdAt: parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['created_at']),
746
- updatedAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['updated_at'])
747
- };
748
- }
757
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
758
+ code: parseString(resource.attributes['code']),
759
+ entityType: parseString(resource.attributes['entity_type']),
760
+ entityAlias: parseString(resource.attributes['entity_alias']),
761
+ entitySource: parseString(resource.attributes['entity_source']),
762
+ entityUrl: parseString(resource.attributes['entity_url']),
763
+ content: parseString(resource.attributes['content']),
764
+ stripeId: parseString(resource.attributes['stripe_id']),
765
+ status: parseString(resource.attributes['status']) || 'active',
766
+ timeZone: parseString(resource.attributes['time_zone']),
767
+ preferredLanguage: parseString(resource.attributes['preferred_language']),
768
+ entityAvatarUrl: parseString(resource.attributes['entity_avatar_url']),
769
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
770
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
771
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
772
+ })
749
773
  };
750
774
 
775
+ function buildEntityBody(data) {
776
+ const body = {};
777
+ if (data.code) body['code'] = data.code;
778
+ if (data.entityType) body['entity_type'] = data.entityType;
779
+ if (data.entityAlias) body['entity_alias'] = data.entityAlias;
780
+ if (data.entitySource) body['entity_source'] = data.entitySource;
781
+ if (data.entityUrl) body['entity_url'] = data.entityUrl;
782
+ if (data.content) body['content'] = data.content;
783
+ if (data.stripeId) body['stripe_id'] = data.stripeId;
784
+ if (data.status) body['status'] = data.status;
785
+ if (data.timeZone) body['time_zone'] = data.timeZone;
786
+ if (data.preferredLanguage) body['preferred_language'] = data.preferredLanguage;
787
+ if (data.entityAvatarUrl) body['entity_avatar_url'] = data.entityAvatarUrl;
788
+ return body;
789
+ }
790
+ function buildContextBody(data) {
791
+ const body = {};
792
+ if (data.uniqueId) body['unique_id'] = data.uniqueId;
793
+ if (data.name) body['name'] = data.name;
794
+ if (data.reference) body['reference'] = data.reference;
795
+ if (data.source) body['source'] = data.source;
796
+ if (data.sourceId) body['source_id'] = data.sourceId;
797
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
798
+ if (data.sourceType) body['source_type'] = data.sourceType;
799
+ if (data.members) body['members'] = data.members;
800
+ return body;
801
+ }
802
+ function buildMessageBody(data) {
803
+ const body = {};
804
+ if (data.role) body['role'] = data.role;
805
+ if (data.content) body['content'] = data.content;
806
+ if (data.fileIds) body['file_ids'] = data.fileIds;
807
+ if (data.metadata) body['metadata'] = data.metadata;
808
+ if (data.source) body['source'] = data.source;
809
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
810
+ if (data.sourceId) body['source_id'] = data.sourceId;
811
+ if (data.sourceType) body['source_type'] = data.sourceType;
812
+ if (data.sourceEmail) body['source_email'] = data.sourceEmail;
813
+ if (data.sourcePhone) body['source_phone'] = data.sourcePhone;
814
+ if (data.target) body['target'] = data.target;
815
+ if (data.targetAlias) body['target_alias'] = data.targetAlias;
816
+ if (data.targetId) body['target_id'] = data.targetId;
817
+ if (data.targetType) body['target_type'] = data.targetType;
818
+ if (data.targetEmail) body['target_email'] = data.targetEmail;
819
+ if (data.targetPhone) body['target_phone'] = data.targetPhone;
820
+ if (data.targetDeviceId) body['target_device_id'] = data.targetDeviceId;
821
+ if (data.parentId) body['parent_id'] = data.parentId;
822
+ if (data.value) body['value'] = data.value;
823
+ if (data.dataSource) body['data_source'] = data.dataSource;
824
+ if (data.dataSourceAlias) body['data_source_alias'] = data.dataSourceAlias;
825
+ if (data.dataSourceId) body['data_source_id'] = data.dataSourceId;
826
+ if (data.dataSourceType) body['data_source_type'] = data.dataSourceType;
827
+ if (data.contextId) body['context_id'] = data.contextId;
828
+ if (data.notificationContent) body['notification_content'] = data.notificationContent;
829
+ if (data.notificationUrl) body['notification_url'] = data.notificationUrl;
830
+ if (data.additionalData) body['additional_data'] = data.additionalData;
831
+ return body;
832
+ }
751
833
  function createEntitiesService(transport, _config) {
752
834
  return {
753
835
  async list (params) {
@@ -768,28 +850,13 @@ function createEntitiesService(transport, _config) {
768
850
  },
769
851
  async register (uniqueId, data) {
770
852
  const response = await transport.post(`/entities/${uniqueId}/register`, {
771
- entity: {
772
- code: data == null ? void 0 : data.code,
773
- name: data == null ? void 0 : data.name,
774
- description: data == null ? void 0 : data.description,
775
- system_prompt: data == null ? void 0 : data.systemPrompt,
776
- model: data == null ? void 0 : data.model,
777
- payload: data == null ? void 0 : data.payload
778
- }
853
+ entity: data ? buildEntityBody(data) : {}
779
854
  });
780
855
  return decodeOne(response, entityMapper);
781
856
  },
782
857
  async update (uniqueId, data) {
783
858
  const response = await transport.put(`/entities/${uniqueId}`, {
784
- entity: {
785
- name: data.name,
786
- description: data.description,
787
- system_prompt: data.systemPrompt,
788
- model: data.model,
789
- enabled: data.enabled,
790
- status: data.status,
791
- payload: data.payload
792
- }
859
+ entity: buildEntityBody(data)
793
860
  });
794
861
  return decodeOne(response, entityMapper);
795
862
  },
@@ -797,121 +864,81 @@ function createEntitiesService(transport, _config) {
797
864
  await transport.delete(`/entities/${uniqueId}`);
798
865
  },
799
866
  async addPrompt (uniqueId, promptUniqueId) {
800
- await transport.post(`/entities/${uniqueId}/prompts`, {
801
- prompt_unique_id: promptUniqueId
867
+ await transport.post(`/entities/${uniqueId}/add_prompt`, {
868
+ prompt: {
869
+ unique_id: promptUniqueId
870
+ }
802
871
  });
803
872
  },
804
- async getContext (uniqueId, contextUniqueId) {
805
- const response = await transport.get(`/entities/${uniqueId}/contexts/${contextUniqueId}`);
806
- return {
807
- id: response.id,
808
- uniqueId: response.unique_id,
809
- entityUniqueId: response.entity_unique_id,
810
- messages: (response.messages || []).map((m)=>({
811
- role: m.role,
812
- content: m.content,
813
- timestamp: new Date(m.timestamp),
814
- payload: m.payload
815
- })),
816
- payload: response.payload,
817
- createdAt: new Date(response.created_at),
818
- updatedAt: new Date(response.updated_at)
819
- };
820
- },
821
873
  async createContext (uniqueId, data) {
822
- const response = await transport.post(`/entities/${uniqueId}/contexts`, {
823
- system_prompt: data == null ? void 0 : data.systemPrompt,
824
- payload: data == null ? void 0 : data.payload
874
+ return transport.post(`/entities/${uniqueId}/create_context`, {
875
+ context: data ? buildContextBody(data) : {}
825
876
  });
826
- return {
827
- id: response.id,
828
- uniqueId: response.unique_id,
829
- entityUniqueId: response.entity_unique_id,
830
- messages: [],
831
- payload: response.payload,
832
- createdAt: new Date(response.created_at),
833
- updatedAt: new Date(response.updated_at)
834
- };
835
- },
836
- async getConversation (uniqueId, contextUniqueId) {
837
- const response = await transport.get(`/entities/${uniqueId}/conversations/${contextUniqueId}`);
838
- return {
839
- id: response.id,
840
- uniqueId: response.unique_id,
841
- entityUniqueId: response.entity_unique_id,
842
- messages: (response.messages || []).map((m)=>({
843
- role: m.role,
844
- content: m.content,
845
- timestamp: new Date(m.timestamp),
846
- payload: m.payload
847
- })),
848
- payload: response.payload,
849
- createdAt: new Date(response.created_at),
850
- updatedAt: new Date(response.updated_at)
851
- };
852
877
  },
853
878
  async sendMessage (uniqueId, contextUniqueId, data) {
854
- const response = await transport.post(`/entities/${uniqueId}/contexts/${contextUniqueId}/messages`, {
855
- message: data.message,
856
- payload: data.payload
879
+ return transport.post(`/entities/${uniqueId}/contexts/${contextUniqueId}/send_message`, {
880
+ message: buildMessageBody(data)
857
881
  });
858
- return {
859
- message: {
860
- role: response.message.role,
861
- content: response.message.content,
862
- timestamp: new Date(response.message.timestamp),
863
- payload: response.message.payload
864
- },
865
- response: response.response ? {
866
- role: response.response.role,
867
- content: response.response.content,
868
- timestamp: new Date(response.response.timestamp),
869
- payload: response.response.payload
870
- } : undefined,
871
- tokens: response.tokens,
872
- cost: response.cost
873
- };
874
882
  },
875
- async queryFile (uniqueId, fileUniqueId, data) {
876
- const response = await transport.post(`/entities/${uniqueId}/files/${fileUniqueId}/query`, {
877
- query: data.query,
878
- payload: data.payload
883
+ async sendMessageStream (uniqueId, contextUniqueId, data) {
884
+ return transport.post(`/entities/${uniqueId}/contexts/${contextUniqueId}/send_message_stream`, {
885
+ message: buildMessageBody(data)
879
886
  });
880
- return {
881
- answer: response.answer,
882
- sources: response.sources,
883
- tokens: response.tokens,
884
- cost: response.cost
885
- };
886
887
  }
887
888
  };
888
889
  }
889
890
 
890
891
  const clusterMapper = {
891
892
  type: 'cluster',
892
- map: (resource)=>{
893
- var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10;
894
- return {
893
+ map: (resource)=>({
895
894
  id: resource.id,
896
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
897
- userUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['user_unique_id'],
898
- code: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['code'],
899
- name: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['name'],
900
- description: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['description'],
901
- members: (((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['members']) || []).map((m)=>({
902
- entityUniqueId: m.entity_unique_id,
903
- role: m.role,
904
- addedAt: parseDate(m.added_at)
905
- })),
906
- enabled: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['enabled'],
907
- status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
908
- payload: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['payload'],
909
- createdAt: parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['created_at']),
910
- updatedAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['updated_at'])
911
- };
912
- }
895
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
896
+ name: parseString(resource.attributes['name']) || '',
897
+ reference: parseString(resource.attributes['reference']),
898
+ description: parseString(resource.attributes['description']),
899
+ userUniqueId: parseString(resource.attributes['user_unique_id']),
900
+ abstract: parseString(resource.attributes['abstract']),
901
+ keywords: parseString(resource.attributes['keywords']),
902
+ content: parseString(resource.attributes['content']),
903
+ contentUrl: parseString(resource.attributes['content_url']),
904
+ thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
905
+ imageUrl: parseString(resource.attributes['image_url']),
906
+ mediaUrl: parseString(resource.attributes['media_url']),
907
+ source: parseString(resource.attributes['source']),
908
+ sourceId: parseString(resource.attributes['source_id']),
909
+ sourceType: parseString(resource.attributes['source_type']),
910
+ sourceAlias: parseString(resource.attributes['source_alias']),
911
+ tags: parseString(resource.attributes['tags']),
912
+ members: parseString(resource.attributes['members']),
913
+ status: parseString(resource.attributes['status']) || 'active',
914
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
915
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
916
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
917
+ })
913
918
  };
914
919
 
920
+ function buildClusterBody(data) {
921
+ const body = {};
922
+ if (data.name) body['name'] = data.name;
923
+ if (data.reference) body['reference'] = data.reference;
924
+ if (data.description) body['description'] = data.description;
925
+ if (data.userUniqueId) body['user_unique_id'] = data.userUniqueId;
926
+ if (data.abstract) body['abstract'] = data.abstract;
927
+ if (data.keywords) body['keywords'] = data.keywords;
928
+ if (data.content) body['content'] = data.content;
929
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
930
+ if (data.thumbnailUrl) body['thumbnail_url'] = data.thumbnailUrl;
931
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
932
+ if (data.mediaUrl) body['media_url'] = data.mediaUrl;
933
+ if (data.source) body['source'] = data.source;
934
+ if (data.sourceId) body['source_id'] = data.sourceId;
935
+ if (data.sourceType) body['source_type'] = data.sourceType;
936
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
937
+ if (data.tags) body['tags'] = data.tags;
938
+ if (data.members) body['members'] = data.members;
939
+ if (data.status) body['status'] = data.status;
940
+ return body;
941
+ }
915
942
  function createClustersService(transport, _config) {
916
943
  return {
917
944
  async list (userUniqueId, params) {
@@ -932,134 +959,80 @@ function createClustersService(transport, _config) {
932
959
  },
933
960
  async create (userUniqueId, data) {
934
961
  const response = await transport.post(`/users/${userUniqueId}/clusters`, {
935
- cluster: {
936
- code: data.code,
937
- name: data.name,
938
- description: data.description,
939
- payload: data.payload
940
- }
962
+ cluster: buildClusterBody(data)
941
963
  });
942
964
  return decodeOne(response, clusterMapper);
943
965
  },
944
966
  async update (userUniqueId, uniqueId, data) {
945
967
  const response = await transport.put(`/users/${userUniqueId}/clusters/${uniqueId}`, {
946
- cluster: {
947
- name: data.name,
948
- description: data.description,
949
- enabled: data.enabled,
950
- status: data.status,
951
- payload: data.payload
952
- }
968
+ cluster: buildClusterBody(data)
953
969
  });
954
970
  return decodeOne(response, clusterMapper);
955
971
  },
956
972
  async delete (userUniqueId, uniqueId) {
957
973
  await transport.delete(`/users/${userUniqueId}/clusters/${uniqueId}`);
958
974
  },
959
- async addMember (userUniqueId, uniqueId, entityUniqueId) {
960
- await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/entities/${entityUniqueId}`, {});
961
- },
962
- async removeMember (userUniqueId, uniqueId, entityUniqueId) {
963
- await transport.delete(`/users/${userUniqueId}/clusters/${uniqueId}/entities/${entityUniqueId}`);
964
- },
965
975
  async addPrompt (userUniqueId, uniqueId, promptUniqueId) {
966
- await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/prompts`, {
967
- prompt_unique_id: promptUniqueId
976
+ const response = await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/prompts`, {
977
+ prompt: {
978
+ unique_id: promptUniqueId
979
+ }
968
980
  });
969
- },
970
- async getContext (userUniqueId, uniqueId, contextUniqueId) {
971
- const response = await transport.get(`/users/${userUniqueId}/clusters/${uniqueId}/contexts/${contextUniqueId}`);
972
- return {
973
- id: response.id,
974
- uniqueId: response.unique_id,
975
- clusterUniqueId: response.cluster_unique_id,
976
- messages: (response.messages || []).map((m)=>({
977
- role: m.role,
978
- content: m.content,
979
- timestamp: new Date(m.timestamp),
980
- payload: m.payload
981
- })),
982
- payload: response.payload,
983
- createdAt: new Date(response.created_at),
984
- updatedAt: new Date(response.updated_at)
985
- };
981
+ return decodeOne(response, clusterMapper);
986
982
  },
987
983
  async createContext (userUniqueId, uniqueId, data) {
988
- const response = await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/contexts`, {
989
- system_prompt: data == null ? void 0 : data.systemPrompt,
990
- payload: data == null ? void 0 : data.payload
991
- });
992
- return {
993
- id: response.id,
994
- uniqueId: response.unique_id,
995
- clusterUniqueId: response.cluster_unique_id,
996
- messages: [],
997
- payload: response.payload,
998
- createdAt: new Date(response.created_at),
999
- updatedAt: new Date(response.updated_at)
1000
- };
1001
- },
1002
- async getConversation (userUniqueId, uniqueId, contextUniqueId) {
1003
- const response = await transport.get(`/users/${userUniqueId}/clusters/${uniqueId}/conversations/${contextUniqueId}`);
1004
- return {
1005
- id: response.id,
1006
- uniqueId: response.unique_id,
1007
- clusterUniqueId: response.cluster_unique_id,
1008
- messages: (response.messages || []).map((m)=>({
1009
- role: m.role,
1010
- content: m.content,
1011
- timestamp: new Date(m.timestamp),
1012
- payload: m.payload
1013
- })),
1014
- payload: response.payload,
1015
- createdAt: new Date(response.created_at),
1016
- updatedAt: new Date(response.updated_at)
1017
- };
984
+ return transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/contexts`, data ? {
985
+ context: buildContextBody(data)
986
+ } : {});
1018
987
  },
1019
988
  async sendMessage (userUniqueId, uniqueId, contextUniqueId, data) {
1020
- const response = await transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/contexts/${contextUniqueId}/messages`, {
1021
- message: data.message,
1022
- payload: data.payload
989
+ return transport.post(`/users/${userUniqueId}/clusters/${uniqueId}/contexts/${contextUniqueId}/messages`, {
990
+ message: buildMessageBody(data)
1023
991
  });
1024
- return {
1025
- message: {
1026
- role: response.message.role,
1027
- content: response.message.content,
1028
- timestamp: new Date(response.message.timestamp),
1029
- payload: response.message.payload
1030
- },
1031
- response: response.response ? {
1032
- role: response.response.role,
1033
- content: response.response.content,
1034
- timestamp: new Date(response.response.timestamp),
1035
- payload: response.response.payload
1036
- } : undefined,
1037
- tokens: response.tokens,
1038
- cost: response.cost
1039
- };
1040
992
  }
1041
993
  };
1042
994
  }
1043
995
 
1044
996
  const jarvisUserMapper = {
1045
997
  type: 'user',
1046
- map: (resource)=>{
1047
- var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8;
1048
- return {
998
+ map: (resource)=>({
1049
999
  id: resource.id,
1050
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1051
- email: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['email'],
1052
- name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
1053
- username: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['username'],
1054
- avatarUrl: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['avatar_url'],
1055
- status: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['status'],
1056
- payload: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['payload'],
1057
- createdAt: parseDate((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['created_at']),
1058
- updatedAt: parseDate((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['updated_at'])
1059
- };
1060
- }
1000
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1001
+ name: parseString(resource.attributes['name']),
1002
+ firstName: parseString(resource.attributes['first_name']),
1003
+ lastName: parseString(resource.attributes['last_name']),
1004
+ email: parseString(resource.attributes['email']),
1005
+ phone: parseString(resource.attributes['phone']),
1006
+ avatarUrl: parseString(resource.attributes['avatar_url']),
1007
+ roleName: parseString(resource.attributes['role_name']),
1008
+ roleUniqueId: parseString(resource.attributes['role_unique_id']),
1009
+ timeZone: parseString(resource.attributes['time_zone']),
1010
+ preferredLanguage: parseString(resource.attributes['preferred_language']),
1011
+ maxFileSize: parseOptionalNumber(resource.attributes['max_file_size']),
1012
+ maxStorage: parseOptionalNumber(resource.attributes['max_storage']),
1013
+ status: parseString(resource.attributes['status']) || 'active',
1014
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
1015
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1016
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1017
+ })
1061
1018
  };
1062
1019
 
1020
+ function buildUserBody(data) {
1021
+ const body = {};
1022
+ if (data.name) body['name'] = data.name;
1023
+ if (data.firstName) body['first_name'] = data.firstName;
1024
+ if (data.lastName) body['last_name'] = data.lastName;
1025
+ if (data.email) body['email'] = data.email;
1026
+ if (data.phone) body['phone'] = data.phone;
1027
+ if (data.avatarUrl) body['avatar_url'] = data.avatarUrl;
1028
+ if (data.roleName) body['role_name'] = data.roleName;
1029
+ if (data.roleUniqueId) body['role_unique_id'] = data.roleUniqueId;
1030
+ if (data.timeZone) body['time_zone'] = data.timeZone;
1031
+ if (data.preferredLanguage) body['preferred_language'] = data.preferredLanguage;
1032
+ if (data.maxFileSize !== undefined) body['max_file_size'] = data.maxFileSize;
1033
+ if (data.maxStorage !== undefined) body['max_storage'] = data.maxStorage;
1034
+ return body;
1035
+ }
1063
1036
  function createJarvisUsersService(transport, _config) {
1064
1037
  return {
1065
1038
  async list (params) {
@@ -1080,206 +1053,68 @@ function createJarvisUsersService(transport, _config) {
1080
1053
  },
1081
1054
  async register (uniqueId, data) {
1082
1055
  const response = await transport.post(`/identities/${uniqueId}/register`, {
1083
- user: {
1084
- email: data == null ? void 0 : data.email,
1085
- name: data == null ? void 0 : data.name,
1086
- username: data == null ? void 0 : data.username,
1087
- avatar_url: data == null ? void 0 : data.avatarUrl,
1088
- payload: data == null ? void 0 : data.payload
1089
- }
1056
+ user: data ? buildUserBody(data) : {}
1090
1057
  });
1091
1058
  return decodeOne(response, jarvisUserMapper);
1092
1059
  },
1093
1060
  async update (uniqueId, data) {
1094
1061
  const response = await transport.put(`/identities/${uniqueId}`, {
1095
- user: {
1096
- name: data.name,
1097
- username: data.username,
1098
- avatar_url: data.avatarUrl,
1099
- status: data.status,
1100
- payload: data.payload
1101
- }
1062
+ user: buildUserBody(data)
1102
1063
  });
1103
1064
  return decodeOne(response, jarvisUserMapper);
1104
1065
  },
1105
1066
  async addPrompt (uniqueId, promptUniqueId) {
1106
- await transport.post(`/identities/${uniqueId}/prompts`, {
1107
- prompt_unique_id: promptUniqueId
1067
+ await transport.post(`/identities/${uniqueId}/add_prompt`, {
1068
+ prompt: {
1069
+ unique_id: promptUniqueId
1070
+ }
1108
1071
  });
1109
1072
  },
1110
- async getContext (uniqueId, contextUniqueId) {
1111
- const response = await transport.get(`/identities/${uniqueId}/contexts/${contextUniqueId}`);
1112
- return {
1113
- id: response.id,
1114
- uniqueId: response.unique_id,
1115
- userUniqueId: response.user_unique_id,
1116
- messages: (response.messages || []).map((m)=>({
1117
- role: m.role,
1118
- content: m.content,
1119
- timestamp: new Date(m.timestamp),
1120
- payload: m.payload
1121
- })),
1122
- payload: response.payload,
1123
- createdAt: new Date(response.created_at),
1124
- updatedAt: new Date(response.updated_at)
1125
- };
1126
- },
1127
1073
  async createContext (uniqueId, data) {
1128
- const response = await transport.post(`/identities/${uniqueId}/contexts`, {
1129
- system_prompt: data == null ? void 0 : data.systemPrompt,
1130
- payload: data == null ? void 0 : data.payload
1074
+ return transport.post(`/identities/${uniqueId}/create_context`, {
1075
+ context: data ? buildContextBody(data) : {}
1131
1076
  });
1132
- return {
1133
- id: response.id,
1134
- uniqueId: response.unique_id,
1135
- userUniqueId: response.user_unique_id,
1136
- messages: [],
1137
- payload: response.payload,
1138
- createdAt: new Date(response.created_at),
1139
- updatedAt: new Date(response.updated_at)
1140
- };
1141
- },
1142
- async getConversation (uniqueId, contextUniqueId) {
1143
- const response = await transport.get(`/identities/${uniqueId}/conversations/${contextUniqueId}`);
1144
- return {
1145
- id: response.id,
1146
- uniqueId: response.unique_id,
1147
- userUniqueId: response.user_unique_id,
1148
- messages: (response.messages || []).map((m)=>({
1149
- role: m.role,
1150
- content: m.content,
1151
- timestamp: new Date(m.timestamp),
1152
- payload: m.payload
1153
- })),
1154
- payload: response.payload,
1155
- createdAt: new Date(response.created_at),
1156
- updatedAt: new Date(response.updated_at)
1157
- };
1158
1077
  },
1159
1078
  async sendMessage (uniqueId, contextUniqueId, data) {
1160
- const response = await transport.post(`/identities/${uniqueId}/contexts/${contextUniqueId}/messages`, {
1161
- message: data.message,
1162
- payload: data.payload
1079
+ return transport.post(`/identities/${uniqueId}/contexts/${contextUniqueId}/send_message`, {
1080
+ message: buildMessageBody(data)
1163
1081
  });
1164
- return {
1165
- message: {
1166
- role: response.message.role,
1167
- content: response.message.content,
1168
- timestamp: new Date(response.message.timestamp),
1169
- payload: response.message.payload
1170
- },
1171
- response: response.response ? {
1172
- role: response.response.role,
1173
- content: response.response.content,
1174
- timestamp: new Date(response.response.timestamp),
1175
- payload: response.response.payload
1176
- } : undefined,
1177
- tokens: response.tokens,
1178
- cost: response.cost
1179
- };
1180
- },
1181
- async getContentContext (uniqueId, contentIdentityUniqueId, contextUniqueId) {
1182
- const response = await transport.get(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/context/${contextUniqueId}`);
1183
- return {
1184
- id: response.id,
1185
- uniqueId: response.unique_id,
1186
- userUniqueId: response.user_unique_id,
1187
- messages: (response.messages || []).map((m)=>({
1188
- role: m.role,
1189
- content: m.content,
1190
- timestamp: new Date(m.timestamp),
1191
- payload: m.payload
1192
- })),
1193
- payload: response.payload,
1194
- createdAt: new Date(response.created_at),
1195
- updatedAt: new Date(response.updated_at)
1196
- };
1197
- },
1198
- async createContentContext (uniqueId, contentIdentityUniqueId, data) {
1199
- const response = await transport.post(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/context`, {
1200
- system_prompt: data == null ? void 0 : data.systemPrompt,
1201
- payload: data == null ? void 0 : data.payload
1202
- });
1203
- return {
1204
- id: response.id,
1205
- uniqueId: response.unique_id,
1206
- userUniqueId: response.user_unique_id,
1207
- messages: [],
1208
- payload: response.payload,
1209
- createdAt: new Date(response.created_at),
1210
- updatedAt: new Date(response.updated_at)
1211
- };
1212
- },
1213
- async getContentConversation (uniqueId, contentIdentityUniqueId, contextUniqueId) {
1214
- const response = await transport.get(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/conversations/${contextUniqueId}`);
1215
- return {
1216
- id: response.id,
1217
- uniqueId: response.unique_id,
1218
- userUniqueId: response.user_unique_id,
1219
- messages: (response.messages || []).map((m)=>({
1220
- role: m.role,
1221
- content: m.content,
1222
- timestamp: new Date(m.timestamp),
1223
- payload: m.payload
1224
- })),
1225
- payload: response.payload,
1226
- createdAt: new Date(response.created_at),
1227
- updatedAt: new Date(response.updated_at)
1228
- };
1229
- },
1230
- async sendContentMessage (uniqueId, contentIdentityUniqueId, contextUniqueId, data) {
1231
- const response = await transport.post(`/identities/${uniqueId}/content/${contentIdentityUniqueId}/contexts/${contextUniqueId}/messages`, {
1232
- message: data.message,
1233
- payload: data.payload
1234
- });
1235
- return {
1236
- message: {
1237
- role: response.message.role,
1238
- content: response.message.content,
1239
- timestamp: new Date(response.message.timestamp),
1240
- payload: response.message.payload
1241
- },
1242
- response: response.response ? {
1243
- role: response.response.role,
1244
- content: response.response.content,
1245
- timestamp: new Date(response.response.timestamp),
1246
- payload: response.response.payload
1247
- } : undefined,
1248
- tokens: response.tokens,
1249
- cost: response.cost
1250
- };
1251
1082
  }
1252
1083
  };
1253
1084
  }
1254
1085
 
1255
1086
  const workflowParticipantMapper = {
1256
1087
  type: 'workflow_participant',
1257
- map: (resource)=>{
1258
- var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10;
1259
- return {
1088
+ map: (resource)=>({
1260
1089
  id: resource.id,
1261
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1262
- workflowUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['workflow_unique_id'],
1263
- entityType: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['entity_type'],
1264
- entityUniqueId: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['entity_unique_id'],
1265
- role: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['role'],
1266
- permissions: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['permissions'],
1267
- enabled: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['enabled'],
1268
- status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
1269
- payload: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['payload'],
1270
- createdAt: parseDate((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['created_at']),
1271
- updatedAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['updated_at'])
1272
- };
1273
- }
1090
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1091
+ workflowUniqueId: parseString(resource.attributes['workflow_unique_id']) || '',
1092
+ role: parseString(resource.attributes['role']),
1093
+ roleName: parseString(resource.attributes['role_name']),
1094
+ participantUniqueId: parseString(resource.attributes['participant_unique_id']),
1095
+ participantName: parseString(resource.attributes['participant_name']),
1096
+ status: parseString(resource.attributes['status']) || 'active',
1097
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
1098
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1099
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1100
+ })
1274
1101
  };
1275
1102
 
1103
+ function buildParticipantBody(data) {
1104
+ const body = {};
1105
+ if (data.role) body['role'] = data.role;
1106
+ if (data.roleName) body['role_name'] = data.roleName;
1107
+ if (data.participantUniqueId) body['participant_unique_id'] = data.participantUniqueId;
1108
+ if (data.participantName) body['participant_name'] = data.participantName;
1109
+ if (data.status) body['status'] = data.status;
1110
+ return body;
1111
+ }
1276
1112
  function createWorkflowParticipantsService(transport, _config) {
1277
1113
  return {
1278
1114
  async list (workflowUniqueId, params) {
1279
1115
  const queryParams = {};
1280
1116
  if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1281
1117
  if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
1282
- if (params == null ? void 0 : params.entityType) queryParams['entity_type'] = params.entityType;
1283
1118
  if (params == null ? void 0 : params.role) queryParams['role'] = params.role;
1284
1119
  if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
1285
1120
  if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
@@ -1294,25 +1129,13 @@ function createWorkflowParticipantsService(transport, _config) {
1294
1129
  },
1295
1130
  async add (workflowUniqueId, data) {
1296
1131
  const response = await transport.post(`/workflows/${workflowUniqueId}/participants`, {
1297
- participant: {
1298
- entity_type: data.entityType,
1299
- entity_unique_id: data.entityUniqueId,
1300
- role: data.role,
1301
- permissions: data.permissions,
1302
- payload: data.payload
1303
- }
1132
+ workflow_participant: buildParticipantBody(data)
1304
1133
  });
1305
1134
  return decodeOne(response, workflowParticipantMapper);
1306
1135
  },
1307
1136
  async update (workflowUniqueId, uniqueId, data) {
1308
1137
  const response = await transport.put(`/workflows/${workflowUniqueId}/participants/${uniqueId}`, {
1309
- participant: {
1310
- role: data.role,
1311
- permissions: data.permissions,
1312
- enabled: data.enabled,
1313
- status: data.status,
1314
- payload: data.payload
1315
- }
1138
+ workflow_participant: buildParticipantBody(data)
1316
1139
  });
1317
1140
  return decodeOne(response, workflowParticipantMapper);
1318
1141
  },
@@ -1322,30 +1145,29 @@ function createWorkflowParticipantsService(transport, _config) {
1322
1145
  };
1323
1146
  }
1324
1147
 
1325
- const workflowStepMapper = {
1326
- type: 'workflow_step',
1327
- map: (resource)=>{
1328
- 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;
1329
- return {
1330
- id: resource.id,
1331
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1332
- workflowUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['workflow_unique_id'],
1333
- name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
1334
- description: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['description'],
1335
- stepType: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['step_type'],
1336
- order: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['order'],
1337
- config: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['config'],
1338
- promptUniqueId: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['prompt_unique_id'],
1339
- agentUniqueId: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['agent_unique_id'],
1340
- enabled: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['enabled'],
1341
- status: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['status'],
1342
- payload: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['payload'],
1343
- createdAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['created_at']),
1344
- updatedAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['updated_at'])
1345
- };
1346
- }
1347
- };
1348
-
1148
+ function buildStepBody$1(data) {
1149
+ const body = {};
1150
+ if (data.name) body['name'] = data.name;
1151
+ if (data.description) body['description'] = data.description;
1152
+ if (data.source) body['source'] = data.source;
1153
+ if (data.sourceId) body['source_id'] = data.sourceId;
1154
+ if (data.sourceType) body['source_type'] = data.sourceType;
1155
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
1156
+ if (data.order !== undefined) body['order'] = data.order;
1157
+ if (data.stepUrl) body['step_url'] = data.stepUrl;
1158
+ if (data.stepParams) body['step_params'] = data.stepParams;
1159
+ if (data.agentUniqueId) body['agent_unique_id'] = data.agentUniqueId;
1160
+ if (data.agentName) body['agent_name'] = data.agentName;
1161
+ if (data.promptUniqueId) body['prompt_unique_id'] = data.promptUniqueId;
1162
+ if (data.promptName) body['prompt_name'] = data.promptName;
1163
+ if (data.customPrompt) body['custom_prompt'] = data.customPrompt;
1164
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
1165
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
1166
+ if (data.videoUrl) body['video_url'] = data.videoUrl;
1167
+ if (data.status) body['status'] = data.status;
1168
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
1169
+ return body;
1170
+ }
1349
1171
  function createWorkflowStepsService(transport, _config) {
1350
1172
  return {
1351
1173
  async get (workflowUniqueId, stepUniqueId) {
@@ -1353,30 +1175,14 @@ function createWorkflowStepsService(transport, _config) {
1353
1175
  return decodeOne(response, workflowStepMapper);
1354
1176
  },
1355
1177
  async add (workflowUniqueId, data) {
1356
- const response = await transport.put(`/workflows/${workflowUniqueId}/steps`, {
1357
- step: {
1358
- name: data.name,
1359
- description: data.description,
1360
- step_type: data.stepType,
1361
- order: data.order,
1362
- config: data.config,
1363
- payload: data.payload
1364
- }
1178
+ const response = await transport.post(`/workflows/${workflowUniqueId}/steps`, {
1179
+ step: buildStepBody$1(data)
1365
1180
  });
1366
1181
  return decodeOne(response, workflowStepMapper);
1367
1182
  },
1368
1183
  async update (workflowUniqueId, stepUniqueId, data) {
1369
1184
  const response = await transport.put(`/workflows/${workflowUniqueId}/steps/${stepUniqueId}`, {
1370
- step: {
1371
- name: data.name,
1372
- description: data.description,
1373
- step_type: data.stepType,
1374
- order: data.order,
1375
- config: data.config,
1376
- enabled: data.enabled,
1377
- status: data.status,
1378
- payload: data.payload
1379
- }
1185
+ step: buildStepBody$1(data)
1380
1186
  });
1381
1187
  return decodeOne(response, workflowStepMapper);
1382
1188
  },
@@ -1385,14 +1191,16 @@ function createWorkflowStepsService(transport, _config) {
1385
1191
  },
1386
1192
  async addPrompt (stepUniqueId, data) {
1387
1193
  await transport.post(`/steps/${stepUniqueId}/prompts`, {
1388
- prompt_unique_id: data.promptUniqueId,
1389
- payload: data.payload
1194
+ prompt: {
1195
+ unique_id: data.uniqueId
1196
+ }
1390
1197
  });
1391
1198
  },
1392
1199
  async addAgent (stepUniqueId, data) {
1393
1200
  await transport.post(`/steps/${stepUniqueId}/agents`, {
1394
- agent_unique_id: data.agentUniqueId,
1395
- payload: data.payload
1201
+ agent: {
1202
+ unique_id: data.uniqueId
1203
+ }
1396
1204
  });
1397
1205
  }
1398
1206
  };
@@ -1401,45 +1209,65 @@ function createWorkflowStepsService(transport, _config) {
1401
1209
  const workflowInstanceMapper = {
1402
1210
  type: 'workflow_instance',
1403
1211
  map: (resource)=>{
1404
- 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;
1212
+ var _parseOptionalNumber;
1405
1213
  return {
1406
1214
  id: resource.id,
1407
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1408
- workflowUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['workflow_unique_id'],
1409
- currentStepUniqueId: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['current_step_unique_id'],
1410
- currentStepOrder: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['current_step_order'],
1411
- input: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['input'],
1412
- output: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['output'],
1413
- logs: (((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['logs']) || []).map((log)=>({
1414
- stepUniqueId: log.step_unique_id,
1415
- stepName: log.step_name,
1416
- status: log.status,
1417
- input: log.input,
1418
- output: log.output,
1419
- startedAt: parseDate(log.started_at),
1420
- completedAt: log.completed_at ? parseDate(log.completed_at) : undefined,
1421
- error: log.error
1422
- })),
1423
- status: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['status'],
1424
- 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,
1425
- 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,
1426
- payload: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['payload'],
1427
- createdAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['created_at']),
1428
- updatedAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['updated_at'])
1215
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1216
+ workflowUniqueId: parseString(resource.attributes['workflow_unique_id']) || '',
1217
+ currentStepUniqueId: parseString(resource.attributes['current_step_unique_id']),
1218
+ currentStepOrder: (_parseOptionalNumber = parseOptionalNumber(resource.attributes['current_step_order'])) != null ? _parseOptionalNumber : 0,
1219
+ input: resource.attributes['input'],
1220
+ output: resource.attributes['output'],
1221
+ logs: parseLogs(resource.attributes['logs']),
1222
+ status: parseString(resource.attributes['status']) || 'pending',
1223
+ startedAt: resource.attributes['started_at'] ? parseDate(resource.attributes['started_at']) : undefined,
1224
+ completedAt: resource.attributes['completed_at'] ? parseDate(resource.attributes['completed_at']) : undefined,
1225
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1226
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1429
1227
  };
1430
1228
  }
1431
1229
  };
1230
+ function parseLogs(value) {
1231
+ if (!Array.isArray(value)) return undefined;
1232
+ return value.map((log)=>({
1233
+ stepUniqueId: log.step_unique_id || '',
1234
+ stepName: log.step_name || '',
1235
+ status: log.status || '',
1236
+ input: log.input,
1237
+ output: log.output,
1238
+ startedAt: parseDate(log.started_at) || new Date(),
1239
+ completedAt: log.completed_at ? parseDate(log.completed_at) : undefined,
1240
+ error: log.error
1241
+ }));
1242
+ }
1432
1243
 
1244
+ function buildStepBody(data) {
1245
+ const body = {};
1246
+ if (data.stepUniqueId) body['step_unique_id'] = data.stepUniqueId;
1247
+ if (data.stepParams) body['step_params'] = data.stepParams;
1248
+ if (data.stepStatus) body['step_status'] = data.stepStatus;
1249
+ if (data.source) body['source'] = data.source;
1250
+ if (data.sourceId) body['source_id'] = data.sourceId;
1251
+ if (data.sourceType) body['source_type'] = data.sourceType;
1252
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
1253
+ if (data.redirectUrl) body['redirect_url'] = data.redirectUrl;
1254
+ return body;
1255
+ }
1433
1256
  function createWorkflowInstancesService(transport, _config) {
1434
1257
  return {
1435
1258
  async start (workflowUniqueId, data) {
1436
- const response = await transport.post(`/workflows/${workflowUniqueId}/start`, {
1437
- input: data == null ? void 0 : data.input,
1438
- payload: data == null ? void 0 : data.payload
1439
- });
1440
- return {
1441
- instance: decodeOne(response, workflowInstanceMapper)
1259
+ const body = {};
1260
+ if (data == null ? void 0 : data.userUniqueId) body['user'] = {
1261
+ user_unique_id: data.userUniqueId
1442
1262
  };
1263
+ const dataBody = {};
1264
+ if (data == null ? void 0 : data.source) dataBody['source'] = data.source;
1265
+ if (data == null ? void 0 : data.sourceId) dataBody['source_id'] = data.sourceId;
1266
+ if (data == null ? void 0 : data.sourceType) dataBody['source_type'] = data.sourceType;
1267
+ if (data == null ? void 0 : data.sourceAlias) dataBody['source_alias'] = data.sourceAlias;
1268
+ if (Object.keys(dataBody).length > 0) body['data'] = dataBody;
1269
+ const response = await transport.post(`/workflows/${workflowUniqueId}/start`, body);
1270
+ return decodeOne(response, workflowInstanceMapper);
1443
1271
  },
1444
1272
  async get (workflowUniqueId, instanceUniqueId) {
1445
1273
  const response = await transport.get(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}`);
@@ -1465,22 +1293,34 @@ function createWorkflowInstancesService(transport, _config) {
1465
1293
  };
1466
1294
  },
1467
1295
  async step (workflowUniqueId, instanceUniqueId, data) {
1468
- const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}`, {
1469
- input: data == null ? void 0 : data.input,
1470
- payload: data == null ? void 0 : data.payload
1471
- });
1296
+ const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/step`, data ? {
1297
+ step: buildStepBody(data)
1298
+ } : {});
1472
1299
  return decodeOne(response, workflowInstanceMapper);
1473
1300
  },
1474
1301
  async logStep (workflowUniqueId, instanceUniqueId, data) {
1475
- const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/log`, {
1476
- step_unique_id: data.stepUniqueId,
1477
- status: data.status,
1478
- output: data.output,
1479
- error: data.error,
1480
- payload: data.payload
1302
+ const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/log_step`, {
1303
+ step: buildStepBody(data)
1481
1304
  });
1482
1305
  return decodeOne(response, workflowInstanceMapper);
1483
1306
  },
1307
+ async executeStep (workflowUniqueId, instanceUniqueId, data) {
1308
+ const response = await transport.post(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/execute_step`, (data == null ? void 0 : data.placeholders) ? {
1309
+ execute: {
1310
+ placeholders: data.placeholders
1311
+ }
1312
+ } : {});
1313
+ return decodeOne(response, workflowInstanceMapper);
1314
+ },
1315
+ async executeNextStep (workflowUniqueId, instanceUniqueId, data) {
1316
+ const body = {};
1317
+ if (data == null ? void 0 : data.transitionUniqueId) body['transition_unique_id'] = data.transitionUniqueId;
1318
+ if (data == null ? void 0 : data.placeholders) body['placeholders'] = data.placeholders;
1319
+ const response = await transport.post(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/execute_next_step`, Object.keys(body).length > 0 ? {
1320
+ execute_next: body
1321
+ } : {});
1322
+ return decodeOne(response, workflowInstanceMapper);
1323
+ },
1484
1324
  async suspend (workflowUniqueId, instanceUniqueId) {
1485
1325
  const response = await transport.put(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/suspend`, {});
1486
1326
  return decodeOne(response, workflowInstanceMapper);
@@ -1492,130 +1332,122 @@ function createWorkflowInstancesService(transport, _config) {
1492
1332
  };
1493
1333
  }
1494
1334
 
1335
+ function buildRuntimeMessageBody(data) {
1336
+ const body = {};
1337
+ if (data.role) body['role'] = data.role;
1338
+ if (data.content) body['content'] = data.content;
1339
+ if (data.fileIds) body['file_ids'] = data.fileIds;
1340
+ if (data.metadata) body['metadata'] = data.metadata;
1341
+ if (data.source) body['source'] = data.source;
1342
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
1343
+ if (data.sourceId) body['source_id'] = data.sourceId;
1344
+ if (data.sourceType) body['source_type'] = data.sourceType;
1345
+ if (data.sourceEmail) body['source_email'] = data.sourceEmail;
1346
+ if (data.sourcePhone) body['source_phone'] = data.sourcePhone;
1347
+ if (data.target) body['target'] = data.target;
1348
+ if (data.targetAlias) body['target_alias'] = data.targetAlias;
1349
+ if (data.targetId) body['target_id'] = data.targetId;
1350
+ if (data.targetType) body['target_type'] = data.targetType;
1351
+ if (data.targetEmail) body['target_email'] = data.targetEmail;
1352
+ if (data.targetPhone) body['target_phone'] = data.targetPhone;
1353
+ if (data.targetDeviceId) body['target_device_id'] = data.targetDeviceId;
1354
+ if (data.parentId) body['parent_id'] = data.parentId;
1355
+ if (data.value) body['value'] = data.value;
1356
+ if (data.dataSource) body['data_source'] = data.dataSource;
1357
+ if (data.dataSourceAlias) body['data_source_alias'] = data.dataSourceAlias;
1358
+ if (data.dataSourceId) body['data_source_id'] = data.dataSourceId;
1359
+ if (data.dataSourceType) body['data_source_type'] = data.dataSourceType;
1360
+ if (data.contextId) body['context_id'] = data.contextId;
1361
+ if (data.notificationContent) body['notification_content'] = data.notificationContent;
1362
+ if (data.notificationUrl) body['notification_url'] = data.notificationUrl;
1363
+ if (data.additionalData) body['additional_data'] = data.additionalData;
1364
+ return body;
1365
+ }
1366
+ function parseAgentThread(response) {
1367
+ return {
1368
+ id: response.id,
1369
+ threadId: response.thread_id,
1370
+ agentUniqueId: response.agent_unique_id,
1371
+ contextUniqueId: response.context_unique_id,
1372
+ status: response.status,
1373
+ metadata: response.metadata,
1374
+ createdAt: new Date(response.created_at),
1375
+ updatedAt: new Date(response.updated_at)
1376
+ };
1377
+ }
1378
+ function parseAgentMessage(m) {
1379
+ return {
1380
+ id: m.id,
1381
+ threadId: m.thread_id,
1382
+ role: m.role,
1383
+ content: (m.content || []).map((c)=>({
1384
+ type: c.type,
1385
+ text: c.text,
1386
+ imageFile: c.image_file,
1387
+ imageUrl: c.image_url
1388
+ })),
1389
+ metadata: m.metadata,
1390
+ createdAt: new Date(m.created_at)
1391
+ };
1392
+ }
1495
1393
  function createAgentRuntimeService(transport, _config) {
1496
1394
  return {
1497
1395
  async getContext (agentUniqueId, contextUniqueId) {
1498
- var _response_thread, _response_thread1, _response_thread2, _response_thread3, _response_thread4, _response_thread5, _response_thread6, _response_thread7;
1499
1396
  const response = await transport.get(`/agents/${agentUniqueId}/context/${contextUniqueId}`);
1500
1397
  return {
1501
- thread: {
1502
- id: (_response_thread = response.thread) == null ? void 0 : _response_thread.id,
1503
- threadId: (_response_thread1 = response.thread) == null ? void 0 : _response_thread1.thread_id,
1504
- agentUniqueId: (_response_thread2 = response.thread) == null ? void 0 : _response_thread2.agent_unique_id,
1505
- contextUniqueId: (_response_thread3 = response.thread) == null ? void 0 : _response_thread3.context_unique_id,
1506
- status: (_response_thread4 = response.thread) == null ? void 0 : _response_thread4.status,
1507
- metadata: (_response_thread5 = response.thread) == null ? void 0 : _response_thread5.metadata,
1508
- createdAt: new Date((_response_thread6 = response.thread) == null ? void 0 : _response_thread6.created_at),
1509
- updatedAt: new Date((_response_thread7 = response.thread) == null ? void 0 : _response_thread7.updated_at)
1510
- },
1398
+ thread: parseAgentThread(response.thread || response),
1511
1399
  conversation: response.conversation ? {
1512
1400
  uniqueId: response.conversation.unique_id,
1513
- messages: (response.conversation.messages || []).map((m)=>({
1514
- id: m.id,
1515
- threadId: m.thread_id,
1516
- role: m.role,
1517
- content: (m.content || []).map((c)=>({
1518
- type: c.type,
1519
- text: c.text,
1520
- imageFile: c.image_file,
1521
- imageUrl: c.image_url
1522
- })),
1523
- metadata: m.metadata,
1524
- createdAt: new Date(m.created_at)
1525
- }))
1401
+ messages: (response.conversation.messages || []).map(parseAgentMessage)
1526
1402
  } : undefined
1527
1403
  };
1528
1404
  },
1529
1405
  async createContext (agentUniqueId, data) {
1530
- var _response_thread, _response_thread1, _response_thread2, _response_thread3, _response_thread4, _response_thread5, _response_thread6, _response_thread7;
1531
- const response = await transport.post(`/agents/${agentUniqueId}/context`, {
1532
- metadata: data == null ? void 0 : data.metadata
1533
- });
1406
+ const response = await transport.post(`/agents/${agentUniqueId}/context`, data ? {
1407
+ context: buildContextBody(data)
1408
+ } : {});
1534
1409
  return {
1535
- thread: {
1536
- id: (_response_thread = response.thread) == null ? void 0 : _response_thread.id,
1537
- threadId: (_response_thread1 = response.thread) == null ? void 0 : _response_thread1.thread_id,
1538
- agentUniqueId: (_response_thread2 = response.thread) == null ? void 0 : _response_thread2.agent_unique_id,
1539
- contextUniqueId: (_response_thread3 = response.thread) == null ? void 0 : _response_thread3.context_unique_id,
1540
- status: (_response_thread4 = response.thread) == null ? void 0 : _response_thread4.status,
1541
- metadata: (_response_thread5 = response.thread) == null ? void 0 : _response_thread5.metadata,
1542
- createdAt: new Date((_response_thread6 = response.thread) == null ? void 0 : _response_thread6.created_at),
1543
- updatedAt: new Date((_response_thread7 = response.thread) == null ? void 0 : _response_thread7.updated_at)
1544
- }
1410
+ thread: parseAgentThread(response.thread || response)
1545
1411
  };
1546
1412
  },
1547
1413
  async getConversation (agentUniqueId, contextUniqueId) {
1548
1414
  const response = await transport.get(`/agents/${agentUniqueId}/conversations/${contextUniqueId}`);
1549
1415
  return {
1550
- messages: (response.messages || []).map((m)=>({
1551
- id: m.id,
1552
- threadId: m.thread_id,
1553
- role: m.role,
1554
- content: (m.content || []).map((c)=>({
1555
- type: c.type,
1556
- text: c.text,
1557
- imageFile: c.image_file,
1558
- imageUrl: c.image_url
1559
- })),
1560
- metadata: m.metadata,
1561
- createdAt: new Date(m.created_at)
1562
- }))
1416
+ messages: (response.messages || []).map(parseAgentMessage)
1563
1417
  };
1564
1418
  },
1565
1419
  async getThread (agentUniqueId, threadId) {
1566
1420
  const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}`);
1567
- return {
1568
- id: response.id,
1569
- threadId: response.thread_id,
1570
- agentUniqueId: response.agent_unique_id,
1571
- contextUniqueId: response.context_unique_id,
1572
- status: response.status,
1573
- metadata: response.metadata,
1574
- createdAt: new Date(response.created_at),
1575
- updatedAt: new Date(response.updated_at)
1576
- };
1421
+ return parseAgentThread(response);
1577
1422
  },
1578
1423
  async createThread (agentUniqueId, data) {
1579
- const response = await transport.post(`/agents/${agentUniqueId}/thread`, {
1580
- metadata: data == null ? void 0 : data.metadata
1581
- });
1582
- return {
1583
- id: response.id,
1584
- threadId: response.thread_id,
1585
- agentUniqueId: response.agent_unique_id,
1586
- contextUniqueId: response.context_unique_id,
1587
- status: response.status,
1588
- metadata: response.metadata,
1589
- createdAt: new Date(response.created_at),
1590
- updatedAt: new Date(response.updated_at)
1591
- };
1424
+ const body = {};
1425
+ if (data == null ? void 0 : data.metadata) body['metadata'] = data.metadata;
1426
+ if (data == null ? void 0 : data.fileIds) body['file_ids'] = data.fileIds;
1427
+ const response = await transport.post(`/agents/${agentUniqueId}/thread`, body);
1428
+ return parseAgentThread(response);
1592
1429
  },
1593
1430
  async sendMessage (agentUniqueId, threadId, data) {
1594
- const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/messages`, {
1595
- message: data.message,
1596
- metadata: data.metadata
1597
- });
1598
- return {
1599
- message: {
1600
- id: response.id,
1601
- threadId: response.thread_id,
1602
- role: response.role,
1603
- content: (response.content || []).map((c)=>({
1604
- type: c.type,
1605
- text: c.text,
1606
- imageFile: c.image_file,
1607
- imageUrl: c.image_url
1608
- })),
1609
- metadata: response.metadata,
1610
- createdAt: new Date(response.created_at)
1611
- }
1431
+ const requestBody = {
1432
+ message: buildRuntimeMessageBody(data)
1612
1433
  };
1434
+ if (data.promptUniqueId) {
1435
+ requestBody['prompt'] = {
1436
+ unique_id: data.promptUniqueId
1437
+ };
1438
+ }
1439
+ return transport.post(`/agents/${agentUniqueId}/threads/${threadId}/messages`, requestBody);
1613
1440
  },
1614
1441
  async sendMessageStream (agentUniqueId, threadId, data) {
1615
- const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/messages/stream`, {
1616
- message: data.message,
1617
- metadata: data.metadata
1618
- }, {
1442
+ const requestBody = {
1443
+ message: buildRuntimeMessageBody(data)
1444
+ };
1445
+ if (data.promptUniqueId) {
1446
+ requestBody['prompt'] = {
1447
+ unique_id: data.promptUniqueId
1448
+ };
1449
+ }
1450
+ const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/messages/stream`, requestBody, {
1619
1451
  responseType: 'stream'
1620
1452
  });
1621
1453
  if (response.body) {
@@ -1623,80 +1455,9 @@ function createAgentRuntimeService(transport, _config) {
1623
1455
  }
1624
1456
  throw new Error('Streaming not supported');
1625
1457
  },
1626
- async runThread (agentUniqueId, threadId, data) {
1627
- const response = await transport.post(`/agents/${agentUniqueId}/threads/${threadId}/runs`, {
1628
- instructions: data == null ? void 0 : data.instructions,
1629
- additional_instructions: data == null ? void 0 : data.additionalInstructions,
1630
- tools: data == null ? void 0 : data.tools,
1631
- metadata: data == null ? void 0 : data.metadata
1632
- });
1633
- return {
1634
- run: {
1635
- id: response.id,
1636
- runId: response.run_id,
1637
- threadId: response.thread_id,
1638
- agentUniqueId: response.agent_unique_id,
1639
- status: response.status,
1640
- model: response.model,
1641
- instructions: response.instructions,
1642
- tools: response.tools,
1643
- startedAt: response.started_at ? new Date(response.started_at) : undefined,
1644
- completedAt: response.completed_at ? new Date(response.completed_at) : undefined,
1645
- failedAt: response.failed_at ? new Date(response.failed_at) : undefined,
1646
- cancelledAt: response.cancelled_at ? new Date(response.cancelled_at) : undefined,
1647
- expiresAt: response.expires_at ? new Date(response.expires_at) : undefined,
1648
- lastError: response.last_error,
1649
- usage: response.usage ? {
1650
- promptTokens: response.usage.prompt_tokens,
1651
- completionTokens: response.usage.completion_tokens,
1652
- totalTokens: response.usage.total_tokens
1653
- } : undefined,
1654
- metadata: response.metadata,
1655
- createdAt: new Date(response.created_at)
1656
- }
1657
- };
1658
- },
1659
- async getRun (agentUniqueId, threadId, runId) {
1660
- const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}/runs/${runId}`);
1661
- return {
1662
- id: response.id,
1663
- runId: response.run_id,
1664
- threadId: response.thread_id,
1665
- agentUniqueId: response.agent_unique_id,
1666
- status: response.status,
1667
- model: response.model,
1668
- instructions: response.instructions,
1669
- tools: response.tools,
1670
- startedAt: response.started_at ? new Date(response.started_at) : undefined,
1671
- completedAt: response.completed_at ? new Date(response.completed_at) : undefined,
1672
- failedAt: response.failed_at ? new Date(response.failed_at) : undefined,
1673
- cancelledAt: response.cancelled_at ? new Date(response.cancelled_at) : undefined,
1674
- expiresAt: response.expires_at ? new Date(response.expires_at) : undefined,
1675
- lastError: response.last_error,
1676
- usage: response.usage ? {
1677
- promptTokens: response.usage.prompt_tokens,
1678
- completionTokens: response.usage.completion_tokens,
1679
- totalTokens: response.usage.total_tokens
1680
- } : undefined,
1681
- metadata: response.metadata,
1682
- createdAt: new Date(response.created_at)
1683
- };
1684
- },
1685
1458
  async getMessages (agentUniqueId, threadId) {
1686
1459
  const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}/messages`);
1687
- return (response.messages || response || []).map((m)=>({
1688
- id: m.id,
1689
- threadId: m.thread_id,
1690
- role: m.role,
1691
- content: (m.content || []).map((c)=>({
1692
- type: c.type,
1693
- text: c.text,
1694
- imageFile: c.image_file,
1695
- imageUrl: c.image_url
1696
- })),
1697
- metadata: m.metadata,
1698
- createdAt: new Date(m.created_at)
1699
- }));
1460
+ return (response.messages || response || []).map(parseAgentMessage);
1700
1461
  },
1701
1462
  async listExecutions (agentUniqueId, params) {
1702
1463
  var _response_meta, _response_meta1, _response_meta2, _response_meta3;
@@ -1758,28 +1519,59 @@ function createAgentRuntimeService(transport, _config) {
1758
1519
 
1759
1520
  const mailTemplateMapper = {
1760
1521
  type: 'mail_template',
1761
- map: (resource)=>{
1762
- 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;
1763
- return {
1522
+ map: (resource)=>({
1764
1523
  id: resource.id,
1765
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1766
- code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
1767
- name: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['name'],
1768
- subject: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['subject'],
1769
- fromEmail: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['from_email'],
1770
- fromName: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['from_name'],
1771
- htmlContent: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['html_content'],
1772
- textContent: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['text_content'],
1773
- mandrillSlug: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['mandrill_slug'],
1774
- enabled: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['enabled'],
1775
- status: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['status'],
1776
- payload: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['payload'],
1777
- createdAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['created_at']),
1778
- updatedAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['updated_at'])
1779
- };
1780
- }
1524
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1525
+ eventName: parseString(resource.attributes['event_name']),
1526
+ name: parseString(resource.attributes['name']) || '',
1527
+ source: parseString(resource.attributes['source']),
1528
+ sourceAlias: parseString(resource.attributes['source_alias']),
1529
+ sourceId: parseString(resource.attributes['source_id']),
1530
+ sourceType: parseString(resource.attributes['source_type']),
1531
+ templateName: parseString(resource.attributes['template_name']),
1532
+ templateHtml: parseString(resource.attributes['template_html']),
1533
+ templateText: parseString(resource.attributes['template_text']),
1534
+ fromDomain: parseString(resource.attributes['from_domain']),
1535
+ fromAddress: parseString(resource.attributes['from_address']),
1536
+ fromName: parseString(resource.attributes['from_name']),
1537
+ fromSubject: parseString(resource.attributes['from_subject']),
1538
+ preferredLanguage: parseString(resource.attributes['preferred_language']),
1539
+ provider: parseString(resource.attributes['provider']),
1540
+ status: parseString(resource.attributes['status']) || 'active',
1541
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
1542
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1543
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1544
+ })
1781
1545
  };
1782
1546
 
1547
+ function buildMailTemplateBody(data) {
1548
+ const body = {};
1549
+ if (data.eventName) body['event_name'] = data.eventName;
1550
+ if (data.name) body['name'] = data.name;
1551
+ if (data.source) body['source'] = data.source;
1552
+ if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
1553
+ if (data.sourceId) body['source_id'] = data.sourceId;
1554
+ if (data.sourceType) body['source_type'] = data.sourceType;
1555
+ if (data.templateName) body['template_name'] = data.templateName;
1556
+ if (data.templateHtml) body['template_html'] = data.templateHtml;
1557
+ if (data.templateText) body['template_text'] = data.templateText;
1558
+ if (data.fromDomain) body['from_domain'] = data.fromDomain;
1559
+ if (data.fromAddress) body['from_address'] = data.fromAddress;
1560
+ if (data.fromName) body['from_name'] = data.fromName;
1561
+ if (data.fromSubject) body['from_subject'] = data.fromSubject;
1562
+ if (data.preferredLanguage) body['preferred_language'] = data.preferredLanguage;
1563
+ if (data.provider) body['provider'] = data.provider;
1564
+ return body;
1565
+ }
1566
+ function buildMandrillBody(data) {
1567
+ const body = {};
1568
+ if (data.fromEmail) body['from_email'] = data.fromEmail;
1569
+ if (data.fromName) body['from_name'] = data.fromName;
1570
+ if (data.fromSubject) body['from_subject'] = data.fromSubject;
1571
+ if (data.templateHtml) body['template_html'] = data.templateHtml;
1572
+ if (data.templateText) body['template_text'] = data.templateText;
1573
+ return body;
1574
+ }
1783
1575
  function createMailTemplatesService(transport, _config) {
1784
1576
  return {
1785
1577
  async list (params) {
@@ -1800,49 +1592,26 @@ function createMailTemplatesService(transport, _config) {
1800
1592
  },
1801
1593
  async create (data) {
1802
1594
  const response = await transport.post('/mailtemplates', {
1803
- mail_template: {
1804
- code: data.code,
1805
- name: data.name,
1806
- subject: data.subject,
1807
- from_email: data.fromEmail,
1808
- from_name: data.fromName,
1809
- html_content: data.htmlContent,
1810
- text_content: data.textContent,
1811
- payload: data.payload
1812
- }
1595
+ mail_template: buildMailTemplateBody(data)
1813
1596
  });
1814
1597
  return decodeOne(response, mailTemplateMapper);
1815
1598
  },
1816
1599
  async update (uniqueId, data) {
1817
1600
  const response = await transport.put(`/mailtemplates/${uniqueId}`, {
1818
- mail_template: {
1819
- name: data.name,
1820
- subject: data.subject,
1821
- from_email: data.fromEmail,
1822
- from_name: data.fromName,
1823
- html_content: data.htmlContent,
1824
- text_content: data.textContent,
1825
- enabled: data.enabled,
1826
- status: data.status,
1827
- payload: data.payload
1828
- }
1601
+ mail_template: buildMailTemplateBody(data)
1829
1602
  });
1830
1603
  return decodeOne(response, mailTemplateMapper);
1831
1604
  },
1832
1605
  async createMandrillTemplate (uniqueId, data) {
1833
- const response = await transport.post(`/mailtemplates/${uniqueId}/mandrill`, {
1834
- slug: data == null ? void 0 : data.slug,
1835
- labels: data == null ? void 0 : data.labels,
1836
- payload: data == null ? void 0 : data.payload
1837
- });
1606
+ const response = await transport.post(`/mailtemplates/${uniqueId}/mandrill`, data ? {
1607
+ mandrill: buildMandrillBody(data)
1608
+ } : {});
1838
1609
  return decodeOne(response, mailTemplateMapper);
1839
1610
  },
1840
1611
  async updateMandrillTemplate (uniqueId, data) {
1841
- const response = await transport.put(`/mailtemplates/${uniqueId}/mandrill`, {
1842
- slug: data == null ? void 0 : data.slug,
1843
- labels: data == null ? void 0 : data.labels,
1844
- payload: data == null ? void 0 : data.payload
1845
- });
1612
+ const response = await transport.put(`/mailtemplates/${uniqueId}/mandrill`, data ? {
1613
+ mandrill: buildMandrillBody(data)
1614
+ } : {});
1846
1615
  return decodeOne(response, mailTemplateMapper);
1847
1616
  },
1848
1617
  async publishMandrill (uniqueId) {
@@ -1850,19 +1619,7 @@ function createMailTemplatesService(transport, _config) {
1850
1619
  return decodeOne(response, mailTemplateMapper);
1851
1620
  },
1852
1621
  async getMandrillStats (uniqueId) {
1853
- const response = await transport.get(`/mailtemplates/${uniqueId}/mandrill/stats`);
1854
- return {
1855
- slug: response.slug,
1856
- sentCount: response.sent_count,
1857
- openCount: response.open_count,
1858
- clickCount: response.click_count,
1859
- hardBounceCount: response.hard_bounce_count,
1860
- softBounceCount: response.soft_bounce_count,
1861
- rejectCount: response.reject_count,
1862
- spamCount: response.spam_count,
1863
- unsubCount: response.unsub_count,
1864
- lastSentAt: response.last_sent_at ? new Date(response.last_sent_at) : undefined
1865
- };
1622
+ return transport.get(`/mailtemplates/${uniqueId}/mandrill/stats`);
1866
1623
  }
1867
1624
  };
1868
1625
  }
@@ -1990,54 +1747,74 @@ function createMarvinChatService(transport, _config) {
1990
1747
 
1991
1748
  const promptCommentMapper = {
1992
1749
  type: 'comment',
1993
- map: (resource)=>{
1994
- 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;
1995
- return {
1750
+ map: (resource)=>({
1996
1751
  id: resource.id,
1997
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
1998
- promptUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['prompt_unique_id'],
1999
- parentUniqueId: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['parent_unique_id'],
2000
- userUniqueId: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['user_unique_id'],
2001
- content: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['content'],
2002
- likesCount: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['likes_count'],
2003
- repliesCount: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['replies_count'],
2004
- isLiked: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['is_liked'],
2005
- isFollowed: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['is_followed'],
2006
- isSaved: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['is_saved'],
2007
- enabled: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['enabled'],
2008
- status: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['status'],
2009
- payload: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['payload'],
2010
- createdAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['created_at']),
2011
- updatedAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['updated_at'])
2012
- };
2013
- }
1752
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1753
+ promptUniqueId: parseString(resource.attributes['prompt_unique_id']) || '',
1754
+ parentUniqueId: parseString(resource.attributes['parent_unique_id']),
1755
+ content: parseString(resource.attributes['content']) || '',
1756
+ thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
1757
+ imageUrl: parseString(resource.attributes['image_url']),
1758
+ contentUrl: parseString(resource.attributes['content_url']),
1759
+ mediaUrl: parseString(resource.attributes['media_url']),
1760
+ userUniqueId: parseString(resource.attributes['user_unique_id']),
1761
+ userName: parseString(resource.attributes['user_name']),
1762
+ userAlias: parseString(resource.attributes['user_alias']),
1763
+ userAvatarUrl: parseString(resource.attributes['user_avatar_url']),
1764
+ aiGenerated: resource.attributes['ai_generated'] != null ? parseBoolean(resource.attributes['ai_generated']) : undefined,
1765
+ aiModel: parseString(resource.attributes['ai_model']),
1766
+ likesCount: parseOptionalNumber(resource.attributes['likes_count']),
1767
+ repliesCount: parseOptionalNumber(resource.attributes['replies_count']),
1768
+ status: parseString(resource.attributes['status']) || 'active',
1769
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
1770
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1771
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1772
+ })
2014
1773
  };
2015
1774
  const executionCommentMapper = {
2016
1775
  type: 'execution_comment',
2017
- map: (resource)=>{
2018
- 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;
2019
- return {
1776
+ map: (resource)=>({
2020
1777
  id: resource.id,
2021
- uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
2022
- promptUniqueId: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['prompt_unique_id'],
2023
- executionUniqueId: (_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['execution_unique_id'],
2024
- parentUniqueId: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['parent_unique_id'],
2025
- userUniqueId: (_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['user_unique_id'],
2026
- content: (_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['content'],
2027
- likesCount: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['likes_count'],
2028
- repliesCount: (_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['replies_count'],
2029
- isLiked: (_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['is_liked'],
2030
- isFollowed: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['is_followed'],
2031
- isSaved: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['is_saved'],
2032
- enabled: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['enabled'],
2033
- status: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['status'],
2034
- payload: (_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['payload'],
2035
- createdAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['created_at']),
2036
- updatedAt: parseDate((_resource_attributes15 = resource.attributes) == null ? void 0 : _resource_attributes15['updated_at'])
2037
- };
2038
- }
1778
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1779
+ promptUniqueId: parseString(resource.attributes['prompt_unique_id']) || '',
1780
+ executionUniqueId: parseString(resource.attributes['execution_unique_id']) || '',
1781
+ parentUniqueId: parseString(resource.attributes['parent_unique_id']),
1782
+ content: parseString(resource.attributes['content']) || '',
1783
+ thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
1784
+ imageUrl: parseString(resource.attributes['image_url']),
1785
+ contentUrl: parseString(resource.attributes['content_url']),
1786
+ mediaUrl: parseString(resource.attributes['media_url']),
1787
+ userUniqueId: parseString(resource.attributes['user_unique_id']),
1788
+ userName: parseString(resource.attributes['user_name']),
1789
+ userAlias: parseString(resource.attributes['user_alias']),
1790
+ userAvatarUrl: parseString(resource.attributes['user_avatar_url']),
1791
+ aiGenerated: resource.attributes['ai_generated'] != null ? parseBoolean(resource.attributes['ai_generated']) : undefined,
1792
+ aiModel: parseString(resource.attributes['ai_model']),
1793
+ likesCount: parseOptionalNumber(resource.attributes['likes_count']),
1794
+ repliesCount: parseOptionalNumber(resource.attributes['replies_count']),
1795
+ status: parseString(resource.attributes['status']) || 'active',
1796
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
1797
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1798
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1799
+ })
2039
1800
  };
2040
1801
 
1802
+ function buildCommentBody$1(data) {
1803
+ const body = {};
1804
+ if (data.content) body['content'] = data.content;
1805
+ if (data.thumbnailUrl) body['thumbnail_url'] = data.thumbnailUrl;
1806
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
1807
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
1808
+ if (data.mediaUrl) body['media_url'] = data.mediaUrl;
1809
+ if (data.userUniqueId) body['user_unique_id'] = data.userUniqueId;
1810
+ if (data.userName) body['user_name'] = data.userName;
1811
+ if (data.userAlias) body['user_alias'] = data.userAlias;
1812
+ if (data.userAvatarUrl) body['user_avatar_url'] = data.userAvatarUrl;
1813
+ if (data.status) body['status'] = data.status;
1814
+ if (data.aiGenerated !== undefined) body['ai_generated'] = data.aiGenerated;
1815
+ if (data.aiModel) body['ai_model'] = data.aiModel;
1816
+ return body;
1817
+ }
2041
1818
  function createPromptCommentsService(transport, _config) {
2042
1819
  return {
2043
1820
  async list (promptUniqueId, params) {
@@ -2059,22 +1836,13 @@ function createPromptCommentsService(transport, _config) {
2059
1836
  },
2060
1837
  async create (promptUniqueId, data) {
2061
1838
  const response = await transport.post(`/prompts/${promptUniqueId}/comments`, {
2062
- comment: {
2063
- content: data.content,
2064
- user_unique_id: data.userUniqueId,
2065
- payload: data.payload
2066
- }
1839
+ comment: buildCommentBody$1(data)
2067
1840
  });
2068
1841
  return decodeOne(response, promptCommentMapper);
2069
1842
  },
2070
1843
  async update (promptUniqueId, uniqueId, data) {
2071
1844
  const response = await transport.put(`/prompts/${promptUniqueId}/comments/${uniqueId}`, {
2072
- comment: {
2073
- content: data.content,
2074
- enabled: data.enabled,
2075
- status: data.status,
2076
- payload: data.payload
2077
- }
1845
+ comment: buildCommentBody$1(data)
2078
1846
  });
2079
1847
  return decodeOne(response, promptCommentMapper);
2080
1848
  },
@@ -2089,11 +1857,7 @@ function createPromptCommentsService(transport, _config) {
2089
1857
  },
2090
1858
  async reply (promptUniqueId, uniqueId, data) {
2091
1859
  const response = await transport.post(`/prompts/${promptUniqueId}/comments/${uniqueId}/reply`, {
2092
- comment: {
2093
- content: data.content,
2094
- user_unique_id: data.userUniqueId,
2095
- payload: data.payload
2096
- }
1860
+ comment: buildCommentBody$1(data)
2097
1861
  });
2098
1862
  return decodeOne(response, promptCommentMapper);
2099
1863
  },
@@ -2112,6 +1876,22 @@ function createPromptCommentsService(transport, _config) {
2112
1876
  };
2113
1877
  }
2114
1878
 
1879
+ function buildCommentBody(data) {
1880
+ const body = {};
1881
+ if (data.content) body['content'] = data.content;
1882
+ if (data.thumbnailUrl) body['thumbnail_url'] = data.thumbnailUrl;
1883
+ if (data.imageUrl) body['image_url'] = data.imageUrl;
1884
+ if (data.contentUrl) body['content_url'] = data.contentUrl;
1885
+ if (data.mediaUrl) body['media_url'] = data.mediaUrl;
1886
+ if (data.userUniqueId) body['user_unique_id'] = data.userUniqueId;
1887
+ if (data.userName) body['user_name'] = data.userName;
1888
+ if (data.userAlias) body['user_alias'] = data.userAlias;
1889
+ if (data.userAvatarUrl) body['user_avatar_url'] = data.userAvatarUrl;
1890
+ if (data.status) body['status'] = data.status;
1891
+ if (data.aiGenerated !== undefined) body['ai_generated'] = data.aiGenerated;
1892
+ if (data.aiModel) body['ai_model'] = data.aiModel;
1893
+ return body;
1894
+ }
2115
1895
  function createExecutionCommentsService(transport, _config) {
2116
1896
  return {
2117
1897
  async list (promptUniqueId, executionUniqueId, params) {
@@ -2133,22 +1913,13 @@ function createExecutionCommentsService(transport, _config) {
2133
1913
  },
2134
1914
  async create (promptUniqueId, executionUniqueId, data) {
2135
1915
  const response = await transport.post(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments`, {
2136
- comment: {
2137
- content: data.content,
2138
- user_unique_id: data.userUniqueId,
2139
- payload: data.payload
2140
- }
1916
+ comment: buildCommentBody(data)
2141
1917
  });
2142
1918
  return decodeOne(response, executionCommentMapper);
2143
1919
  },
2144
1920
  async update (promptUniqueId, executionUniqueId, uniqueId, data) {
2145
1921
  const response = await transport.put(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}`, {
2146
- comment: {
2147
- content: data.content,
2148
- enabled: data.enabled,
2149
- status: data.status,
2150
- payload: data.payload
2151
- }
1922
+ comment: buildCommentBody(data)
2152
1923
  });
2153
1924
  return decodeOne(response, executionCommentMapper);
2154
1925
  },
@@ -2163,11 +1934,7 @@ function createExecutionCommentsService(transport, _config) {
2163
1934
  },
2164
1935
  async reply (promptUniqueId, executionUniqueId, uniqueId, data) {
2165
1936
  const response = await transport.post(`/prompts/${promptUniqueId}/executions/${executionUniqueId}/comments/${uniqueId}/reply`, {
2166
- comment: {
2167
- content: data.content,
2168
- user_unique_id: data.userUniqueId,
2169
- payload: data.payload
2170
- }
1937
+ comment: buildCommentBody(data)
2171
1938
  });
2172
1939
  return decodeOne(response, executionCommentMapper);
2173
1940
  },
@@ -2186,15 +1953,346 @@ function createExecutionCommentsService(transport, _config) {
2186
1953
  };
2187
1954
  }
2188
1955
 
2189
- /**
2190
- * Create the Jarvis block.
2191
- *
2192
- * @example
2193
- * ```typescript
2194
- * const block = createJarvisBlock(transport, { appId: 'xxx' });
2195
- * const agents = await block.agents.list({ page: 1 });
2196
- * ```
2197
- */ function createJarvisBlock(transport, config) {
1956
+ const toolMapper = {
1957
+ type: 'tool',
1958
+ map: (resource)=>({
1959
+ id: resource.id,
1960
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1961
+ name: parseString(resource.attributes['name']) || '',
1962
+ description: parseString(resource.attributes['description']),
1963
+ toolType: parseString(resource.attributes['tool_type']),
1964
+ apiMethod: parseString(resource.attributes['api_method']),
1965
+ apiUrl: parseString(resource.attributes['api_url']),
1966
+ requiresAuth: resource.attributes['requires_auth'] != null ? parseBoolean(resource.attributes['requires_auth']) : undefined,
1967
+ responseMapping: parseString(resource.attributes['response_mapping']),
1968
+ parameters: resource.attributes['parameters'],
1969
+ apiHeaders: resource.attributes['api_headers'],
1970
+ status: parseString(resource.attributes['status']) || 'active',
1971
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
1972
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1973
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1974
+ })
1975
+ };
1976
+
1977
+ function buildToolBody(data) {
1978
+ const body = {};
1979
+ if (data.name) body['name'] = data.name;
1980
+ if (data.description) body['description'] = data.description;
1981
+ if (data.toolType) body['tool_type'] = data.toolType;
1982
+ if (data.apiMethod) body['api_method'] = data.apiMethod;
1983
+ if (data.apiUrl) body['api_url'] = data.apiUrl;
1984
+ if (data.requiresAuth !== undefined) body['requires_auth'] = data.requiresAuth;
1985
+ if (data.responseMapping) body['response_mapping'] = data.responseMapping;
1986
+ if (data.parameters) body['parameters'] = data.parameters;
1987
+ if (data.apiHeaders) body['api_headers'] = data.apiHeaders;
1988
+ if (data.status) body['status'] = data.status;
1989
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
1990
+ return body;
1991
+ }
1992
+ function createToolsService(transport, _config) {
1993
+ return {
1994
+ async list (params) {
1995
+ const queryParams = {};
1996
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1997
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
1998
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
1999
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
2000
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2001
+ const response = await transport.get('/tools', {
2002
+ params: queryParams
2003
+ });
2004
+ return decodePageResult(response, toolMapper);
2005
+ },
2006
+ async get (uniqueId) {
2007
+ const response = await transport.get(`/tools/${uniqueId}`);
2008
+ return decodeOne(response, toolMapper);
2009
+ },
2010
+ async create (data) {
2011
+ const response = await transport.post('/tools', {
2012
+ tool: buildToolBody(data)
2013
+ });
2014
+ return decodeOne(response, toolMapper);
2015
+ },
2016
+ async update (uniqueId, data) {
2017
+ const response = await transport.put(`/tools/${uniqueId}`, {
2018
+ tool: buildToolBody(data)
2019
+ });
2020
+ return decodeOne(response, toolMapper);
2021
+ },
2022
+ async delete (uniqueId) {
2023
+ await transport.delete(`/tools/${uniqueId}`);
2024
+ }
2025
+ };
2026
+ }
2027
+
2028
+ const agentToolMapper = {
2029
+ type: 'agent_tool',
2030
+ map: (resource)=>({
2031
+ id: resource.id,
2032
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2033
+ agentUniqueId: parseString(resource.attributes['agent_unique_id']) || '',
2034
+ name: parseString(resource.attributes['name']) || '',
2035
+ description: parseString(resource.attributes['description']),
2036
+ toolType: parseString(resource.attributes['tool_type']),
2037
+ apiMethod: parseString(resource.attributes['api_method']),
2038
+ apiUrl: parseString(resource.attributes['api_url']),
2039
+ requiresAuth: resource.attributes['requires_auth'] != null ? parseBoolean(resource.attributes['requires_auth']) : undefined,
2040
+ responseMapping: parseString(resource.attributes['response_mapping']),
2041
+ parameters: resource.attributes['parameters'],
2042
+ apiHeaders: resource.attributes['api_headers'],
2043
+ status: parseString(resource.attributes['status']) || 'active',
2044
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
2045
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2046
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2047
+ })
2048
+ };
2049
+
2050
+ function buildAgentToolBody(data) {
2051
+ const body = {};
2052
+ if (data.name) body['name'] = data.name;
2053
+ if (data.description) body['description'] = data.description;
2054
+ if (data.toolType) body['tool_type'] = data.toolType;
2055
+ if (data.apiMethod) body['api_method'] = data.apiMethod;
2056
+ if (data.apiUrl) body['api_url'] = data.apiUrl;
2057
+ if (data.requiresAuth !== undefined) body['requires_auth'] = data.requiresAuth;
2058
+ if (data.responseMapping) body['response_mapping'] = data.responseMapping;
2059
+ if (data.parameters) body['parameters'] = data.parameters;
2060
+ if (data.apiHeaders) body['api_headers'] = data.apiHeaders;
2061
+ if (data.status) body['status'] = data.status;
2062
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
2063
+ return body;
2064
+ }
2065
+ function createAgentToolsService(transport, _config) {
2066
+ return {
2067
+ async list (agentUniqueId, params) {
2068
+ const queryParams = {};
2069
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2070
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2071
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2072
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
2073
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2074
+ const response = await transport.get(`/agents/${agentUniqueId}/tools`, {
2075
+ params: queryParams
2076
+ });
2077
+ return decodePageResult(response, agentToolMapper);
2078
+ },
2079
+ async get (agentUniqueId, uniqueId) {
2080
+ const response = await transport.get(`/agents/${agentUniqueId}/tools/${uniqueId}`);
2081
+ return decodeOne(response, agentToolMapper);
2082
+ },
2083
+ async create (agentUniqueId, data) {
2084
+ const response = await transport.post(`/agents/${agentUniqueId}/tools`, {
2085
+ agent_tool: buildAgentToolBody(data)
2086
+ });
2087
+ return decodeOne(response, agentToolMapper);
2088
+ },
2089
+ async update (agentUniqueId, uniqueId, data) {
2090
+ const response = await transport.put(`/agents/${agentUniqueId}/tools/${uniqueId}`, {
2091
+ agent_tool: buildAgentToolBody(data)
2092
+ });
2093
+ return decodeOne(response, agentToolMapper);
2094
+ },
2095
+ async delete (agentUniqueId, uniqueId) {
2096
+ await transport.delete(`/agents/${agentUniqueId}/tools/${uniqueId}`);
2097
+ }
2098
+ };
2099
+ }
2100
+
2101
+ const agentToolAssignmentMapper = {
2102
+ type: 'agent_tool_assignment',
2103
+ map: (resource)=>({
2104
+ id: resource.id,
2105
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2106
+ agentUniqueId: parseString(resource.attributes['agent_unique_id']) || '',
2107
+ toolUniqueId: parseString(resource.attributes['tool_unique_id']) || '',
2108
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
2109
+ priority: parseOptionalNumber(resource.attributes['priority']),
2110
+ status: parseString(resource.attributes['status']) || 'active',
2111
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2112
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2113
+ })
2114
+ };
2115
+
2116
+ function createAgentToolAssignmentsService(transport, _config) {
2117
+ return {
2118
+ async list (agentUniqueId, params) {
2119
+ const queryParams = {};
2120
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2121
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2122
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2123
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2124
+ const response = await transport.get(`/agents/${agentUniqueId}/tool_assignments`, {
2125
+ params: queryParams
2126
+ });
2127
+ return decodePageResult(response, agentToolAssignmentMapper);
2128
+ },
2129
+ async get (agentUniqueId, uniqueId) {
2130
+ const response = await transport.get(`/agents/${agentUniqueId}/tool_assignments/${uniqueId}`);
2131
+ return decodeOne(response, agentToolAssignmentMapper);
2132
+ },
2133
+ async create (agentUniqueId, data) {
2134
+ const body = {};
2135
+ if (data.toolUniqueId) body['tool_unique_id'] = data.toolUniqueId;
2136
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
2137
+ if (data.priority !== undefined) body['priority'] = data.priority;
2138
+ const response = await transport.post(`/agents/${agentUniqueId}/tool_assignments`, {
2139
+ assignment: body
2140
+ });
2141
+ return decodeOne(response, agentToolAssignmentMapper);
2142
+ },
2143
+ async update (agentUniqueId, uniqueId, data) {
2144
+ const body = {};
2145
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
2146
+ if (data.priority !== undefined) body['priority'] = data.priority;
2147
+ const response = await transport.put(`/agents/${agentUniqueId}/tool_assignments/${uniqueId}`, {
2148
+ assignment: body
2149
+ });
2150
+ return decodeOne(response, agentToolAssignmentMapper);
2151
+ },
2152
+ async delete (agentUniqueId, uniqueId) {
2153
+ await transport.delete(`/agents/${agentUniqueId}/tool_assignments/${uniqueId}`);
2154
+ }
2155
+ };
2156
+ }
2157
+
2158
+ const conditionMapper = {
2159
+ type: 'condition',
2160
+ map: (resource)=>({
2161
+ id: resource.id,
2162
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2163
+ name: parseString(resource.attributes['name']) || '',
2164
+ description: parseString(resource.attributes['description']),
2165
+ expressionType: parseString(resource.attributes['expression_type']),
2166
+ promptUniqueId: parseString(resource.attributes['prompt_unique_id']),
2167
+ llmModel: parseString(resource.attributes['llm_model']),
2168
+ llmTemperature: parseOptionalNumber(resource.attributes['llm_temperature']),
2169
+ cacheable: resource.attributes['cacheable'] != null ? parseBoolean(resource.attributes['cacheable']) : undefined,
2170
+ cacheTtlSeconds: parseOptionalNumber(resource.attributes['cache_ttl_seconds']),
2171
+ expression: resource.attributes['expression'],
2172
+ status: parseString(resource.attributes['status']) || 'active',
2173
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
2174
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2175
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2176
+ })
2177
+ };
2178
+
2179
+ function buildConditionBody(data) {
2180
+ const body = {};
2181
+ if (data.name) body['name'] = data.name;
2182
+ if (data.description) body['description'] = data.description;
2183
+ if (data.expressionType) body['expression_type'] = data.expressionType;
2184
+ if (data.promptUniqueId) body['prompt_unique_id'] = data.promptUniqueId;
2185
+ if (data.llmModel) body['llm_model'] = data.llmModel;
2186
+ if (data.llmTemperature !== undefined) body['llm_temperature'] = data.llmTemperature;
2187
+ if (data.cacheable !== undefined) body['cacheable'] = data.cacheable;
2188
+ if (data.cacheTtlSeconds !== undefined) body['cache_ttl_seconds'] = data.cacheTtlSeconds;
2189
+ if (data.expression) body['expression'] = data.expression;
2190
+ return body;
2191
+ }
2192
+ function createConditionsService(transport, _config) {
2193
+ return {
2194
+ async list (params) {
2195
+ const queryParams = {};
2196
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2197
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2198
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2199
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
2200
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2201
+ const response = await transport.get('/conditions', {
2202
+ params: queryParams
2203
+ });
2204
+ return decodePageResult(response, conditionMapper);
2205
+ },
2206
+ async get (uniqueId) {
2207
+ const response = await transport.get(`/conditions/${uniqueId}`);
2208
+ return decodeOne(response, conditionMapper);
2209
+ },
2210
+ async create (data) {
2211
+ const response = await transport.post('/conditions', {
2212
+ condition: buildConditionBody(data)
2213
+ });
2214
+ return decodeOne(response, conditionMapper);
2215
+ },
2216
+ async update (uniqueId, data) {
2217
+ const response = await transport.put(`/conditions/${uniqueId}`, {
2218
+ condition: buildConditionBody(data)
2219
+ });
2220
+ return decodeOne(response, conditionMapper);
2221
+ },
2222
+ async delete (uniqueId) {
2223
+ await transport.delete(`/conditions/${uniqueId}`);
2224
+ }
2225
+ };
2226
+ }
2227
+
2228
+ const stepTransitionMapper = {
2229
+ type: 'step_transition',
2230
+ map: (resource)=>({
2231
+ id: resource.id,
2232
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2233
+ name: parseString(resource.attributes['name']) || '',
2234
+ description: parseString(resource.attributes['description']),
2235
+ transitionType: parseString(resource.attributes['transition_type']),
2236
+ priority: parseOptionalNumber(resource.attributes['priority']),
2237
+ isDefault: resource.attributes['is_default'] != null ? parseBoolean(resource.attributes['is_default']) : undefined,
2238
+ allowsBackward: resource.attributes['allows_backward'] != null ? parseBoolean(resource.attributes['allows_backward']) : undefined,
2239
+ maxIterations: parseOptionalNumber(resource.attributes['max_iterations']),
2240
+ onLoop: parseString(resource.attributes['on_loop']),
2241
+ status: parseString(resource.attributes['status']) || 'active',
2242
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
2243
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2244
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2245
+ })
2246
+ };
2247
+
2248
+ function buildStepTransitionBody(data) {
2249
+ const body = {};
2250
+ if (data.name) body['name'] = data.name;
2251
+ if (data.description) body['description'] = data.description;
2252
+ if (data.transitionType) body['transition_type'] = data.transitionType;
2253
+ if (data.priority !== undefined) body['priority'] = data.priority;
2254
+ if (data.isDefault !== undefined) body['is_default'] = data.isDefault;
2255
+ if (data.allowsBackward !== undefined) body['allows_backward'] = data.allowsBackward;
2256
+ if (data.maxIterations !== undefined) body['max_iterations'] = data.maxIterations;
2257
+ if (data.onLoop) body['on_loop'] = data.onLoop;
2258
+ return body;
2259
+ }
2260
+ function createStepTransitionsService(transport, _config) {
2261
+ return {
2262
+ async list (stepUniqueId, params) {
2263
+ const queryParams = {};
2264
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2265
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2266
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2267
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2268
+ const response = await transport.get(`/steps/${stepUniqueId}/transitions`, {
2269
+ params: queryParams
2270
+ });
2271
+ return decodePageResult(response, stepTransitionMapper);
2272
+ },
2273
+ async get (stepUniqueId, uniqueId) {
2274
+ const response = await transport.get(`/steps/${stepUniqueId}/transitions/${uniqueId}`);
2275
+ return decodeOne(response, stepTransitionMapper);
2276
+ },
2277
+ async create (stepUniqueId, data) {
2278
+ const response = await transport.post(`/steps/${stepUniqueId}/transitions`, {
2279
+ step_transition: buildStepTransitionBody(data)
2280
+ });
2281
+ return decodeOne(response, stepTransitionMapper);
2282
+ },
2283
+ async update (stepUniqueId, uniqueId, data) {
2284
+ const response = await transport.put(`/steps/${stepUniqueId}/transitions/${uniqueId}`, {
2285
+ step_transition: buildStepTransitionBody(data)
2286
+ });
2287
+ return decodeOne(response, stepTransitionMapper);
2288
+ },
2289
+ async delete (stepUniqueId, uniqueId) {
2290
+ await transport.delete(`/steps/${stepUniqueId}/transitions/${uniqueId}`);
2291
+ }
2292
+ };
2293
+ }
2294
+
2295
+ function createJarvisBlock(transport, config) {
2198
2296
  return {
2199
2297
  agents: createAgentsService(transport),
2200
2298
  prompts: createPromptsService(transport),
@@ -2213,6 +2311,11 @@ function createExecutionCommentsService(transport, _config) {
2213
2311
  marvinChat: createMarvinChatService(transport),
2214
2312
  promptComments: createPromptCommentsService(transport),
2215
2313
  executionComments: createExecutionCommentsService(transport),
2314
+ tools: createToolsService(transport),
2315
+ agentTools: createAgentToolsService(transport),
2316
+ agentToolAssignments: createAgentToolAssignmentsService(transport),
2317
+ conditions: createConditionsService(transport),
2318
+ stepTransitions: createStepTransitionsService(transport),
2216
2319
  health: ()=>transport.get('/health')
2217
2320
  };
2218
2321
  }