@23blocks/block-jarvis 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +570 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/jarvis.block.d.ts +16 -0
- package/dist/src/lib/jarvis.block.d.ts.map +1 -0
- package/dist/src/lib/mappers/agent.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/agent.mapper.d.ts.map +1 -0
- package/dist/src/lib/mappers/conversation.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/conversation.mapper.d.ts.map +1 -0
- package/dist/src/lib/mappers/execution.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/execution.mapper.d.ts.map +1 -0
- package/dist/{lib/mappers/index.js → src/lib/mappers/index.d.ts} +1 -2
- package/dist/src/lib/mappers/index.d.ts.map +1 -0
- package/dist/src/lib/mappers/prompt.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/prompt.mapper.d.ts.map +1 -0
- package/dist/src/lib/mappers/utils.d.ts +37 -0
- package/dist/src/lib/mappers/utils.d.ts.map +1 -0
- package/dist/src/lib/mappers/workflow.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/workflow.mapper.d.ts.map +1 -0
- package/dist/src/lib/services/agents.service.d.ts +15 -0
- package/dist/src/lib/services/agents.service.d.ts.map +1 -0
- package/dist/src/lib/services/conversations.service.d.ts +14 -0
- package/dist/src/lib/services/conversations.service.d.ts.map +1 -0
- package/dist/src/lib/services/executions.service.d.ts +13 -0
- package/dist/src/lib/services/executions.service.d.ts.map +1 -0
- package/dist/{lib/services/index.js → src/lib/services/index.d.ts} +1 -2
- package/dist/src/lib/services/index.d.ts.map +1 -0
- package/dist/src/lib/services/prompts.service.d.ts +15 -0
- package/dist/src/lib/services/prompts.service.d.ts.map +1 -0
- package/dist/src/lib/services/workflows.service.d.ts +16 -0
- package/dist/src/lib/services/workflows.service.d.ts.map +1 -0
- package/dist/src/lib/types/agent.d.ts +70 -0
- package/dist/src/lib/types/agent.d.ts.map +1 -0
- package/dist/src/lib/types/conversation.d.ts +43 -0
- package/dist/src/lib/types/conversation.d.ts.map +1 -0
- package/dist/src/lib/types/execution.d.ts +25 -0
- package/dist/src/lib/types/execution.d.ts.map +1 -0
- package/dist/{lib/types/index.js → src/lib/types/index.d.ts} +1 -2
- package/dist/src/lib/types/index.d.ts.map +1 -0
- package/dist/src/lib/types/prompt.d.ts +63 -0
- package/dist/src/lib/types/prompt.d.ts.map +1 -0
- package/dist/src/lib/types/workflow.d.ts +57 -0
- package/dist/src/lib/types/workflow.d.ts.map +1 -0
- package/package.json +10 -8
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/lib/jarvis.block.js +0 -24
- package/dist/lib/jarvis.block.js.map +0 -1
- package/dist/lib/mappers/agent.mapper.js +0 -23
- package/dist/lib/mappers/agent.mapper.js.map +0 -1
- package/dist/lib/mappers/conversation.mapper.js +0 -29
- package/dist/lib/mappers/conversation.mapper.js.map +0 -1
- package/dist/lib/mappers/execution.mapper.js +0 -23
- package/dist/lib/mappers/execution.mapper.js.map +0 -1
- package/dist/lib/mappers/index.js.map +0 -1
- package/dist/lib/mappers/prompt.mapper.js +0 -22
- package/dist/lib/mappers/prompt.mapper.js.map +0 -1
- package/dist/lib/mappers/utils.js +0 -93
- package/dist/lib/mappers/utils.js.map +0 -1
- package/dist/lib/mappers/workflow.mapper.js +0 -20
- package/dist/lib/mappers/workflow.mapper.js.map +0 -1
- package/dist/lib/services/agents.service.js +0 -94
- package/dist/lib/services/agents.service.js.map +0 -1
- package/dist/lib/services/conversations.service.js +0 -79
- package/dist/lib/services/conversations.service.js.map +0 -1
- package/dist/lib/services/executions.service.js +0 -51
- package/dist/lib/services/executions.service.js.map +0 -1
- package/dist/lib/services/index.js.map +0 -1
- package/dist/lib/services/prompts.service.js +0 -88
- package/dist/lib/services/prompts.service.js.map +0 -1
- package/dist/lib/services/workflows.service.js +0 -79
- package/dist/lib/services/workflows.service.js.map +0 -1
- package/dist/lib/types/agent.js +0 -3
- package/dist/lib/types/agent.js.map +0 -1
- package/dist/lib/types/conversation.js +0 -3
- package/dist/lib/types/conversation.js.map +0 -1
- package/dist/lib/types/execution.js +0 -4
- package/dist/lib/types/execution.js.map +0 -1
- package/dist/lib/types/index.js.map +0 -1
- package/dist/lib/types/prompt.js +0 -3
- package/dist/lib/types/prompt.js.map +0 -1
- package/dist/lib/types/workflow.js +0 -3
- package/dist/lib/types/workflow.js.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parse a string value, returning undefined for empty/undefined
|
|
5
|
+
*/ function parseString(value) {
|
|
6
|
+
if (value === null || value === undefined) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const str = String(value);
|
|
10
|
+
return str.length > 0 ? str : undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parse a date value
|
|
14
|
+
*/ function parseDate(value) {
|
|
15
|
+
if (value === null || value === undefined) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
if (value instanceof Date) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
22
|
+
const date = new Date(value);
|
|
23
|
+
return isNaN(date.getTime()) ? undefined : date;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse a boolean value
|
|
29
|
+
*/ function parseBoolean(value) {
|
|
30
|
+
if (typeof value === 'boolean') {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
if (value === 'true' || value === '1' || value === 1) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
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
|
+
/**
|
|
50
|
+
* Parse an optional number value
|
|
51
|
+
*/ function parseOptionalNumber(value) {
|
|
52
|
+
if (value === null || value === undefined) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const num = Number(value);
|
|
56
|
+
return isNaN(num) ? undefined : num;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse entity status
|
|
60
|
+
*/ function parseStatus(value) {
|
|
61
|
+
const status = parseString(value);
|
|
62
|
+
if (status === 'active' || status === 'inactive' || status === 'pending' || status === 'archived' || status === 'deleted') {
|
|
63
|
+
return status;
|
|
64
|
+
}
|
|
65
|
+
return 'active';
|
|
66
|
+
}
|
|
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
|
+
|
|
86
|
+
const agentMapper = {
|
|
87
|
+
type: 'Agent',
|
|
88
|
+
map: (resource)=>({
|
|
89
|
+
id: resource.id,
|
|
90
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.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']) || '',
|
|
94
|
+
name: parseString(resource.attributes['name']) || '',
|
|
95
|
+
description: parseString(resource.attributes['description']),
|
|
96
|
+
systemPrompt: parseString(resource.attributes['system_prompt']),
|
|
97
|
+
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']
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function createAgentsService(transport, _config) {
|
|
108
|
+
return {
|
|
109
|
+
async list (params) {
|
|
110
|
+
const queryParams = {};
|
|
111
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
112
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
113
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
114
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
115
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
116
|
+
const response = await transport.get('/agents', {
|
|
117
|
+
params: queryParams
|
|
118
|
+
});
|
|
119
|
+
return decodePageResult(response, agentMapper);
|
|
120
|
+
},
|
|
121
|
+
async get (uniqueId) {
|
|
122
|
+
const response = await transport.get(`/agents/${uniqueId}`);
|
|
123
|
+
return decodeOne(response, agentMapper);
|
|
124
|
+
},
|
|
125
|
+
async create (data) {
|
|
126
|
+
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
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return decodeOne(response, agentMapper);
|
|
140
|
+
},
|
|
141
|
+
async update (uniqueId, data) {
|
|
142
|
+
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
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return decodeOne(response, agentMapper);
|
|
157
|
+
},
|
|
158
|
+
async delete (uniqueId) {
|
|
159
|
+
await transport.delete(`/agents/${uniqueId}`);
|
|
160
|
+
},
|
|
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
|
|
167
|
+
});
|
|
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
|
+
};
|
|
175
|
+
},
|
|
176
|
+
async complete (uniqueId, data) {
|
|
177
|
+
const response = await transport.post(`/agents/${uniqueId}/complete`, {
|
|
178
|
+
input: data.input,
|
|
179
|
+
payload: data.payload
|
|
180
|
+
});
|
|
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
|
+
};
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const promptMapper = {
|
|
193
|
+
type: 'Prompt',
|
|
194
|
+
map: (resource)=>({
|
|
195
|
+
id: resource.id,
|
|
196
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
197
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
198
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
199
|
+
agentUniqueId: parseString(resource.attributes['agent_unique_id']),
|
|
200
|
+
code: parseString(resource.attributes['code']) || '',
|
|
201
|
+
name: parseString(resource.attributes['name']) || '',
|
|
202
|
+
description: parseString(resource.attributes['description']),
|
|
203
|
+
template: parseString(resource.attributes['template']) || '',
|
|
204
|
+
variables: parseStringArray(resource.attributes['variables']),
|
|
205
|
+
version: parseOptionalNumber(resource.attributes['version']),
|
|
206
|
+
status: parseStatus(resource.attributes['status']),
|
|
207
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
208
|
+
payload: resource.attributes['payload']
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
function createPromptsService(transport, _config) {
|
|
213
|
+
return {
|
|
214
|
+
async list (params) {
|
|
215
|
+
const queryParams = {};
|
|
216
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
217
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
218
|
+
if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
|
|
219
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
220
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
221
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
222
|
+
const response = await transport.get('/prompts', {
|
|
223
|
+
params: queryParams
|
|
224
|
+
});
|
|
225
|
+
return decodePageResult(response, promptMapper);
|
|
226
|
+
},
|
|
227
|
+
async get (uniqueId) {
|
|
228
|
+
const response = await transport.get(`/prompts/${uniqueId}`);
|
|
229
|
+
return decodeOne(response, promptMapper);
|
|
230
|
+
},
|
|
231
|
+
async create (data) {
|
|
232
|
+
const response = await transport.post('/prompts', {
|
|
233
|
+
prompt: {
|
|
234
|
+
agent_unique_id: data.agentUniqueId,
|
|
235
|
+
code: data.code,
|
|
236
|
+
name: data.name,
|
|
237
|
+
description: data.description,
|
|
238
|
+
template: data.template,
|
|
239
|
+
variables: data.variables,
|
|
240
|
+
payload: data.payload
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return decodeOne(response, promptMapper);
|
|
244
|
+
},
|
|
245
|
+
async update (uniqueId, data) {
|
|
246
|
+
const response = await transport.put(`/prompts/${uniqueId}`, {
|
|
247
|
+
prompt: {
|
|
248
|
+
name: data.name,
|
|
249
|
+
description: data.description,
|
|
250
|
+
template: data.template,
|
|
251
|
+
variables: data.variables,
|
|
252
|
+
enabled: data.enabled,
|
|
253
|
+
status: data.status,
|
|
254
|
+
payload: data.payload
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
return decodeOne(response, promptMapper);
|
|
258
|
+
},
|
|
259
|
+
async delete (uniqueId) {
|
|
260
|
+
await transport.delete(`/prompts/${uniqueId}`);
|
|
261
|
+
},
|
|
262
|
+
async execute (uniqueId, data) {
|
|
263
|
+
const response = await transport.post(`/prompts/${uniqueId}/execute`, {
|
|
264
|
+
agent_unique_id: data.agentUniqueId,
|
|
265
|
+
variables: data.variables,
|
|
266
|
+
payload: data.payload
|
|
267
|
+
});
|
|
268
|
+
return {
|
|
269
|
+
output: response.output,
|
|
270
|
+
executionUniqueId: response.execution_unique_id,
|
|
271
|
+
tokens: response.tokens,
|
|
272
|
+
cost: response.cost,
|
|
273
|
+
duration: response.duration
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
async test (data) {
|
|
277
|
+
const response = await transport.post('/prompts/test', {
|
|
278
|
+
template: data.template,
|
|
279
|
+
variables: data.variables,
|
|
280
|
+
agent_unique_id: data.agentUniqueId
|
|
281
|
+
});
|
|
282
|
+
return {
|
|
283
|
+
renderedPrompt: response.rendered_prompt,
|
|
284
|
+
isValid: response.is_valid,
|
|
285
|
+
errors: response.errors
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const workflowMapper = {
|
|
292
|
+
type: 'Workflow',
|
|
293
|
+
map: (resource)=>({
|
|
294
|
+
id: resource.id,
|
|
295
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
296
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
297
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
298
|
+
code: parseString(resource.attributes['code']) || '',
|
|
299
|
+
name: parseString(resource.attributes['name']) || '',
|
|
300
|
+
description: parseString(resource.attributes['description']),
|
|
301
|
+
steps: resource.attributes['steps'] || [],
|
|
302
|
+
triggers: resource.attributes['triggers'],
|
|
303
|
+
status: parseStatus(resource.attributes['status']),
|
|
304
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
305
|
+
payload: resource.attributes['payload']
|
|
306
|
+
})
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
function createWorkflowsService(transport, _config) {
|
|
310
|
+
return {
|
|
311
|
+
async list (params) {
|
|
312
|
+
const queryParams = {};
|
|
313
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
314
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
315
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
316
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
317
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
318
|
+
const response = await transport.get('/workflows', {
|
|
319
|
+
params: queryParams
|
|
320
|
+
});
|
|
321
|
+
return decodePageResult(response, workflowMapper);
|
|
322
|
+
},
|
|
323
|
+
async get (uniqueId) {
|
|
324
|
+
const response = await transport.get(`/workflows/${uniqueId}`);
|
|
325
|
+
return decodeOne(response, workflowMapper);
|
|
326
|
+
},
|
|
327
|
+
async create (data) {
|
|
328
|
+
const response = await transport.post('/workflows', {
|
|
329
|
+
workflow: {
|
|
330
|
+
code: data.code,
|
|
331
|
+
name: data.name,
|
|
332
|
+
description: data.description,
|
|
333
|
+
steps: data.steps,
|
|
334
|
+
triggers: data.triggers,
|
|
335
|
+
payload: data.payload
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
return decodeOne(response, workflowMapper);
|
|
339
|
+
},
|
|
340
|
+
async update (uniqueId, data) {
|
|
341
|
+
const response = await transport.put(`/workflows/${uniqueId}`, {
|
|
342
|
+
workflow: {
|
|
343
|
+
name: data.name,
|
|
344
|
+
description: data.description,
|
|
345
|
+
steps: data.steps,
|
|
346
|
+
triggers: data.triggers,
|
|
347
|
+
enabled: data.enabled,
|
|
348
|
+
status: data.status,
|
|
349
|
+
payload: data.payload
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return decodeOne(response, workflowMapper);
|
|
353
|
+
},
|
|
354
|
+
async delete (uniqueId) {
|
|
355
|
+
await transport.delete(`/workflows/${uniqueId}`);
|
|
356
|
+
},
|
|
357
|
+
async run (uniqueId, data) {
|
|
358
|
+
const response = await transport.post(`/workflows/${uniqueId}/run`, {
|
|
359
|
+
input: data.input,
|
|
360
|
+
payload: data.payload
|
|
361
|
+
});
|
|
362
|
+
return {
|
|
363
|
+
executionUniqueId: response.execution_unique_id,
|
|
364
|
+
status: response.status,
|
|
365
|
+
output: response.output
|
|
366
|
+
};
|
|
367
|
+
},
|
|
368
|
+
async pause (uniqueId) {
|
|
369
|
+
const response = await transport.post(`/workflows/${uniqueId}/pause`, {});
|
|
370
|
+
return decodeOne(response, workflowMapper);
|
|
371
|
+
},
|
|
372
|
+
async resume (uniqueId) {
|
|
373
|
+
const response = await transport.post(`/workflows/${uniqueId}/resume`, {});
|
|
374
|
+
return decodeOne(response, workflowMapper);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const executionMapper = {
|
|
380
|
+
type: 'Execution',
|
|
381
|
+
map: (resource)=>({
|
|
382
|
+
id: resource.id,
|
|
383
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
384
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
385
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
386
|
+
agentUniqueId: parseString(resource.attributes['agent_unique_id']),
|
|
387
|
+
promptUniqueId: parseString(resource.attributes['prompt_unique_id']),
|
|
388
|
+
input: parseString(resource.attributes['input']),
|
|
389
|
+
output: parseString(resource.attributes['output']),
|
|
390
|
+
tokens: parseOptionalNumber(resource.attributes['tokens']),
|
|
391
|
+
cost: parseOptionalNumber(resource.attributes['cost']),
|
|
392
|
+
duration: parseOptionalNumber(resource.attributes['duration']),
|
|
393
|
+
status: parseExecutionStatus(resource.attributes['status']),
|
|
394
|
+
startedAt: parseDate(resource.attributes['started_at']),
|
|
395
|
+
completedAt: parseDate(resource.attributes['completed_at']),
|
|
396
|
+
payload: resource.attributes['payload']
|
|
397
|
+
})
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
function createExecutionsService(transport, _config) {
|
|
401
|
+
return {
|
|
402
|
+
async list (params) {
|
|
403
|
+
const queryParams = {};
|
|
404
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
405
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
406
|
+
if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
|
|
407
|
+
if (params == null ? void 0 : params.promptUniqueId) queryParams['prompt_unique_id'] = params.promptUniqueId;
|
|
408
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
409
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
410
|
+
const response = await transport.get('/executions', {
|
|
411
|
+
params: queryParams
|
|
412
|
+
});
|
|
413
|
+
return decodePageResult(response, executionMapper);
|
|
414
|
+
},
|
|
415
|
+
async get (uniqueId) {
|
|
416
|
+
const response = await transport.get(`/executions/${uniqueId}`);
|
|
417
|
+
return decodeOne(response, executionMapper);
|
|
418
|
+
},
|
|
419
|
+
async listByAgent (agentUniqueId, params) {
|
|
420
|
+
const queryParams = {};
|
|
421
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
422
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
423
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
424
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
425
|
+
const response = await transport.get(`/agents/${agentUniqueId}/executions`, {
|
|
426
|
+
params: queryParams
|
|
427
|
+
});
|
|
428
|
+
return decodePageResult(response, executionMapper);
|
|
429
|
+
},
|
|
430
|
+
async listByPrompt (promptUniqueId, params) {
|
|
431
|
+
const queryParams = {};
|
|
432
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
433
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
434
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
435
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
436
|
+
const response = await transport.get(`/prompts/${promptUniqueId}/executions`, {
|
|
437
|
+
params: queryParams
|
|
438
|
+
});
|
|
439
|
+
return decodePageResult(response, executionMapper);
|
|
440
|
+
},
|
|
441
|
+
async cancel (uniqueId) {
|
|
442
|
+
const response = await transport.post(`/executions/${uniqueId}/cancel`, {});
|
|
443
|
+
return decodeOne(response, executionMapper);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const conversationMapper = {
|
|
449
|
+
type: 'Conversation',
|
|
450
|
+
map: (resource)=>({
|
|
451
|
+
id: resource.id,
|
|
452
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
453
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
454
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
455
|
+
agentUniqueId: parseString(resource.attributes['agent_unique_id']),
|
|
456
|
+
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
457
|
+
title: parseString(resource.attributes['title']),
|
|
458
|
+
messages: parseMessages(resource.attributes['messages']),
|
|
459
|
+
status: parseStatus(resource.attributes['status']),
|
|
460
|
+
payload: resource.attributes['payload']
|
|
461
|
+
})
|
|
462
|
+
};
|
|
463
|
+
function parseMessages(value) {
|
|
464
|
+
if (!Array.isArray(value)) {
|
|
465
|
+
return [];
|
|
466
|
+
}
|
|
467
|
+
return value.map((msg)=>({
|
|
468
|
+
role: parseMessageRole(msg.role),
|
|
469
|
+
content: parseString(msg.content) || '',
|
|
470
|
+
timestamp: parseDate(msg.timestamp) || new Date(),
|
|
471
|
+
payload: msg.payload
|
|
472
|
+
}));
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function createConversationsService(transport, _config) {
|
|
476
|
+
return {
|
|
477
|
+
async list (params) {
|
|
478
|
+
const queryParams = {};
|
|
479
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
480
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
481
|
+
if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
|
|
482
|
+
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
483
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
484
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
485
|
+
const response = await transport.get('/conversations', {
|
|
486
|
+
params: queryParams
|
|
487
|
+
});
|
|
488
|
+
return decodePageResult(response, conversationMapper);
|
|
489
|
+
},
|
|
490
|
+
async get (uniqueId) {
|
|
491
|
+
const response = await transport.get(`/conversations/${uniqueId}`);
|
|
492
|
+
return decodeOne(response, conversationMapper);
|
|
493
|
+
},
|
|
494
|
+
async create (data) {
|
|
495
|
+
const response = await transport.post('/conversations', {
|
|
496
|
+
conversation: {
|
|
497
|
+
agent_unique_id: data.agentUniqueId,
|
|
498
|
+
user_unique_id: data.userUniqueId,
|
|
499
|
+
title: data.title,
|
|
500
|
+
payload: data.payload
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
return decodeOne(response, conversationMapper);
|
|
504
|
+
},
|
|
505
|
+
async sendMessage (uniqueId, data) {
|
|
506
|
+
const response = await transport.post(`/conversations/${uniqueId}/messages`, {
|
|
507
|
+
message: data.message,
|
|
508
|
+
role: data.role,
|
|
509
|
+
payload: data.payload
|
|
510
|
+
});
|
|
511
|
+
return {
|
|
512
|
+
message: {
|
|
513
|
+
role: response.message.role,
|
|
514
|
+
content: response.message.content,
|
|
515
|
+
timestamp: new Date(response.message.timestamp),
|
|
516
|
+
payload: response.message.payload
|
|
517
|
+
},
|
|
518
|
+
response: response.response ? {
|
|
519
|
+
role: response.response.role,
|
|
520
|
+
content: response.response.content,
|
|
521
|
+
timestamp: new Date(response.response.timestamp),
|
|
522
|
+
payload: response.response.payload
|
|
523
|
+
} : undefined,
|
|
524
|
+
executionUniqueId: response.execution_unique_id,
|
|
525
|
+
tokens: response.tokens,
|
|
526
|
+
cost: response.cost
|
|
527
|
+
};
|
|
528
|
+
},
|
|
529
|
+
async listByUser (userUniqueId, params) {
|
|
530
|
+
const queryParams = {};
|
|
531
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
532
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
533
|
+
if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
|
|
534
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
535
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
536
|
+
const response = await transport.get(`/users/${userUniqueId}/conversations`, {
|
|
537
|
+
params: queryParams
|
|
538
|
+
});
|
|
539
|
+
return decodePageResult(response, conversationMapper);
|
|
540
|
+
},
|
|
541
|
+
async clear (uniqueId) {
|
|
542
|
+
const response = await transport.post(`/conversations/${uniqueId}/clear`, {});
|
|
543
|
+
return decodeOne(response, conversationMapper);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function createJarvisBlock(transport, config) {
|
|
549
|
+
return {
|
|
550
|
+
agents: createAgentsService(transport),
|
|
551
|
+
prompts: createPromptsService(transport),
|
|
552
|
+
workflows: createWorkflowsService(transport),
|
|
553
|
+
executions: createExecutionsService(transport),
|
|
554
|
+
conversations: createConversationsService(transport)
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
const jarvisBlockMetadata = {
|
|
558
|
+
name: 'jarvis',
|
|
559
|
+
version: '0.1.0',
|
|
560
|
+
description: 'AI agents, prompts, workflows, executions, and conversation management',
|
|
561
|
+
resourceTypes: [
|
|
562
|
+
'Agent',
|
|
563
|
+
'Prompt',
|
|
564
|
+
'Workflow',
|
|
565
|
+
'Execution',
|
|
566
|
+
'Conversation'
|
|
567
|
+
]
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
export { agentMapper, conversationMapper, createAgentsService, createConversationsService, createExecutionsService, createJarvisBlock, createPromptsService, createWorkflowsService, executionMapper, jarvisBlockMetadata, promptMapper, workflowMapper };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createJarvisBlock, jarvisBlockMetadata } from './lib/jarvis.block';
|
|
2
|
+
export type { JarvisBlock, JarvisBlockConfig } from './lib/jarvis.block';
|
|
3
|
+
export type { Agent, CreateAgentRequest, UpdateAgentRequest, ListAgentsParams, ChatRequest, ChatResponse, CompleteRequest, CompleteResponse, Prompt, CreatePromptRequest, UpdatePromptRequest, ListPromptsParams, ExecutePromptRequest, ExecutePromptResponse, TestPromptRequest, TestPromptResponse, Workflow, WorkflowStep, WorkflowTrigger, CreateWorkflowRequest, UpdateWorkflowRequest, ListWorkflowsParams, RunWorkflowRequest, RunWorkflowResponse, Execution, ExecutionStatus, ListExecutionsParams, Conversation, ConversationMessage, CreateConversationRequest, SendMessageRequest, SendMessageResponse, ListConversationsParams, } from './lib/types';
|
|
4
|
+
export type { AgentsService, PromptsService, WorkflowsService, ExecutionsService, ConversationsService, } from './lib/services';
|
|
5
|
+
export { createAgentsService, createPromptsService, createWorkflowsService, createExecutionsService, createConversationsService, } from './lib/services';
|
|
6
|
+
export { agentMapper, promptMapper, workflowMapper, executionMapper, conversationMapper, } from './lib/mappers';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGzE,YAAY,EAEV,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAEhB,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAElB,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EAEnB,SAAS,EACT,eAAe,EACf,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Transport, BlockConfig, BlockMetadata } from '@23blocks/contracts';
|
|
2
|
+
import { type AgentsService, type PromptsService, type WorkflowsService, type ExecutionsService, type ConversationsService } from './services';
|
|
3
|
+
export interface JarvisBlockConfig extends BlockConfig {
|
|
4
|
+
appId: string;
|
|
5
|
+
tenantId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface JarvisBlock {
|
|
8
|
+
agents: AgentsService;
|
|
9
|
+
prompts: PromptsService;
|
|
10
|
+
workflows: WorkflowsService;
|
|
11
|
+
executions: ExecutionsService;
|
|
12
|
+
conversations: ConversationsService;
|
|
13
|
+
}
|
|
14
|
+
export declare function createJarvisBlock(transport: Transport, config: JarvisBlockConfig): JarvisBlock;
|
|
15
|
+
export declare const jarvisBlockMetadata: BlockMetadata;
|
|
16
|
+
//# sourceMappingURL=jarvis.block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jarvis.block.d.ts","sourceRoot":"","sources":["../../../src/lib/jarvis.block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,EAAE,oBAAoB,CAAC;CACrC;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,iBAAiB,GACxB,WAAW,CAQb;AAED,eAAO,MAAM,mBAAmB,EAAE,aAWjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.mapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/agent.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5C,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,KAAK,CAoB7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.mapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/conversation.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,uBAAuB,CAAC;AAG/E,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CAe3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.mapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/execution.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,SAAS,CAoBrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.mapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/prompt.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,MAAM,CAmB/C,CAAC"}
|