@23blocks/block-jarvis 5.2.0 → 5.3.1

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 (58) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/index.esm.js +552 -45
  3. package/dist/src/index.d.ts +4 -4
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/lib/jarvis.block.d.ts +7 -1
  6. package/dist/src/lib/jarvis.block.d.ts.map +1 -1
  7. package/dist/src/lib/mappers/agent-test.mapper.d.ts +5 -0
  8. package/dist/src/lib/mappers/agent-test.mapper.d.ts.map +1 -0
  9. package/dist/src/lib/mappers/company-key.mapper.d.ts +4 -0
  10. package/dist/src/lib/mappers/company-key.mapper.d.ts.map +1 -0
  11. package/dist/src/lib/mappers/index.d.ts +7 -0
  12. package/dist/src/lib/mappers/index.d.ts.map +1 -1
  13. package/dist/src/lib/mappers/llm-provider.mapper.d.ts +4 -0
  14. package/dist/src/lib/mappers/llm-provider.mapper.d.ts.map +1 -0
  15. package/dist/src/lib/mappers/openai-model.mapper.d.ts +4 -0
  16. package/dist/src/lib/mappers/openai-model.mapper.d.ts.map +1 -0
  17. package/dist/src/lib/mappers/prompt-template.mapper.d.ts +4 -0
  18. package/dist/src/lib/mappers/prompt-template.mapper.d.ts.map +1 -0
  19. package/dist/src/lib/mappers/prompt-test.mapper.d.ts +6 -0
  20. package/dist/src/lib/mappers/prompt-test.mapper.d.ts.map +1 -0
  21. package/dist/src/lib/mappers/run-execution.mapper.d.ts +4 -0
  22. package/dist/src/lib/mappers/run-execution.mapper.d.ts.map +1 -0
  23. package/dist/src/lib/services/agent-runtime.service.d.ts +1 -0
  24. package/dist/src/lib/services/agent-runtime.service.d.ts.map +1 -1
  25. package/dist/src/lib/services/agent-tests.service.d.ts +18 -0
  26. package/dist/src/lib/services/agent-tests.service.d.ts.map +1 -0
  27. package/dist/src/lib/services/ai-models.service.d.ts +5 -0
  28. package/dist/src/lib/services/ai-models.service.d.ts.map +1 -1
  29. package/dist/src/lib/services/company-keys.service.d.ts +14 -0
  30. package/dist/src/lib/services/company-keys.service.d.ts.map +1 -0
  31. package/dist/src/lib/services/executions.service.d.ts +2 -0
  32. package/dist/src/lib/services/executions.service.d.ts.map +1 -1
  33. package/dist/src/lib/services/index.d.ts +5 -0
  34. package/dist/src/lib/services/index.d.ts.map +1 -1
  35. package/dist/src/lib/services/llm-providers.service.d.ts +11 -0
  36. package/dist/src/lib/services/llm-providers.service.d.ts.map +1 -0
  37. package/dist/src/lib/services/prompt-templates.service.d.ts +10 -0
  38. package/dist/src/lib/services/prompt-templates.service.d.ts.map +1 -0
  39. package/dist/src/lib/services/prompt-tests.service.d.ts +32 -0
  40. package/dist/src/lib/services/prompt-tests.service.d.ts.map +1 -0
  41. package/dist/src/lib/services/prompts.service.d.ts +4 -1
  42. package/dist/src/lib/services/prompts.service.d.ts.map +1 -1
  43. package/dist/src/lib/services/workflow-instances.service.d.ts.map +1 -1
  44. package/dist/src/lib/types/agent-test.d.ts +56 -0
  45. package/dist/src/lib/types/agent-test.d.ts.map +1 -0
  46. package/dist/src/lib/types/company-key.d.ts +16 -0
  47. package/dist/src/lib/types/company-key.d.ts.map +1 -0
  48. package/dist/src/lib/types/execution.d.ts +1 -0
  49. package/dist/src/lib/types/execution.d.ts.map +1 -1
  50. package/dist/src/lib/types/index.d.ts +5 -0
  51. package/dist/src/lib/types/index.d.ts.map +1 -1
  52. package/dist/src/lib/types/llm-provider.d.ts +20 -0
  53. package/dist/src/lib/types/llm-provider.d.ts.map +1 -0
  54. package/dist/src/lib/types/prompt-template.d.ts +17 -0
  55. package/dist/src/lib/types/prompt-template.d.ts.map +1 -0
  56. package/dist/src/lib/types/prompt-test.d.ts +79 -0
  57. package/dist/src/lib/types/prompt-test.d.ts.map +1 -0
  58. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { _ } from '@swc/helpers/_/_extends';
2
- import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
2
+ import { decodeOne, decodePageResult, decodeMany } from '@23blocks/jsonapi-codec';
3
3
 
4
4
  /**
5
5
  * Parse a string value, returning undefined for empty/undefined
@@ -298,7 +298,7 @@ function buildPromptBody(data) {
298
298
  if (data.templateData) body['template_data'] = data.templateData;
299
299
  return body;
300
300
  }
301
- function createPromptsService(transport, _config) {
301
+ function createPromptsService(transport, _config, sseUrl) {
302
302
  return {
303
303
  async list (params) {
304
304
  const queryParams = {};
@@ -345,6 +345,44 @@ function createPromptsService(transport, _config) {
345
345
  duration: response.duration
346
346
  };
347
347
  },
348
+ async publish (uniqueId, versionUniqueId) {
349
+ const response = await transport.post(`/prompts/${uniqueId}/versions/${versionUniqueId}/publish`, {});
350
+ return decodeOne(response, promptMapper);
351
+ },
352
+ async executeStream (uniqueId, data) {
353
+ const response = await transport.post(`/prompts/${uniqueId}/execute/stream`, {
354
+ agent_unique_id: data.agentUniqueId,
355
+ variables: data.variables
356
+ }, _({
357
+ responseType: 'stream',
358
+ headers: {
359
+ Accept: 'text/event-stream'
360
+ }
361
+ }, sseUrl ? {
362
+ baseUrl: sseUrl
363
+ } : {}));
364
+ if (response.body) {
365
+ return response.body.pipeThrough(new TextDecoderStream());
366
+ }
367
+ throw new Error('Streaming not supported');
368
+ },
369
+ async executeVersionStream (uniqueId, versionUniqueId, data) {
370
+ const response = await transport.post(`/prompts/${uniqueId}/versions/${versionUniqueId}/execute/stream`, {
371
+ agent_unique_id: data.agentUniqueId,
372
+ variables: data.variables
373
+ }, _({
374
+ responseType: 'stream',
375
+ headers: {
376
+ Accept: 'text/event-stream'
377
+ }
378
+ }, sseUrl ? {
379
+ baseUrl: sseUrl
380
+ } : {}));
381
+ if (response.body) {
382
+ return response.body.pipeThrough(new TextDecoderStream());
383
+ }
384
+ throw new Error('Streaming not supported');
385
+ },
348
386
  async render (uniqueId, data) {
349
387
  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;
350
388
  const response = await transport.post(`/prompts/${uniqueId}/render`, {
@@ -540,6 +578,7 @@ function createExecutionsService(transport, _config) {
540
578
  if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
541
579
  if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
542
580
  if (params == null ? void 0 : params.promptUniqueId) queryParams['prompt_unique_id'] = params.promptUniqueId;
581
+ if (params == null ? void 0 : params.runUniqueId) queryParams['run_unique_id'] = params.runUniqueId;
543
582
  if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
544
583
  if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
545
584
  const response = await transport.get('/executions', {
@@ -566,6 +605,7 @@ function createExecutionsService(transport, _config) {
566
605
  const queryParams = {};
567
606
  if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
568
607
  if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
608
+ if (params == null ? void 0 : params.runUniqueId) queryParams['run_unique_id'] = params.runUniqueId;
569
609
  if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
570
610
  if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
571
611
  const response = await transport.get(`/prompts/${promptUniqueId}/executions`, {
@@ -576,6 +616,22 @@ function createExecutionsService(transport, _config) {
576
616
  async cancel (uniqueId) {
577
617
  const response = await transport.post(`/executions/${uniqueId}/cancel`, {});
578
618
  return decodeOne(response, executionMapper);
619
+ },
620
+ async listByPromptVersion (promptUniqueId, versionUniqueId, params) {
621
+ const queryParams = {};
622
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
623
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
624
+ if (params == null ? void 0 : params.runUniqueId) queryParams['run_unique_id'] = params.runUniqueId;
625
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
626
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
627
+ const response = await transport.get(`/prompts/${promptUniqueId}/versions/${versionUniqueId}/executions`, {
628
+ params: queryParams
629
+ });
630
+ return decodePageResult(response, executionMapper);
631
+ },
632
+ async getByPrompt (promptUniqueId, executionUniqueId) {
633
+ const response = await transport.get(`/prompts/${promptUniqueId}/executions/${executionUniqueId}`);
634
+ return decodeOne(response, executionMapper);
579
635
  }
580
636
  };
581
637
  }
@@ -699,6 +755,14 @@ const aiModelMapper = {
699
755
  })
700
756
  };
701
757
 
758
+ const openaiModelMapper = {
759
+ type: 'openai_model',
760
+ map: (resource)=>({
761
+ id: parseString(resource.attributes['name']) || resource.id,
762
+ name: parseString(resource.attributes['name']) || resource.id
763
+ })
764
+ };
765
+
702
766
  function buildAIModelBody(data) {
703
767
  const body = {};
704
768
  if (data.name) body['name'] = data.name;
@@ -746,6 +810,10 @@ function createAIModelsService(transport, _config) {
746
810
  },
747
811
  async delete (uniqueId) {
748
812
  await transport.delete(`/ai_models/${uniqueId}`);
813
+ },
814
+ async openaiAvailable () {
815
+ const response = await transport.get('/vendors/openai/models');
816
+ return decodeMany(response, openaiModelMapper);
749
817
  }
750
818
  };
751
819
  }
@@ -1285,22 +1353,28 @@ function createWorkflowInstancesService(transport, _config) {
1285
1353
  return decodeOne(response, workflowInstanceMapper);
1286
1354
  },
1287
1355
  async getDetails (workflowUniqueId, instanceUniqueId) {
1288
- var _response_workflow, _response_workflow1;
1356
+ var _doc_data;
1289
1357
  const response = await transport.get(`/workflows/${workflowUniqueId}/instances/${instanceUniqueId}/details`);
1358
+ const doc = response;
1359
+ const instance = decodeOne(response, workflowInstanceMapper);
1360
+ // Workflow and steps metadata are included as top-level attributes in the JSON:API resource
1361
+ const attrs = ((_doc_data = doc.data) == null ? void 0 : _doc_data.attributes) || {};
1362
+ const workflow = attrs['workflow'] || {};
1363
+ const steps = attrs['steps'] || [];
1290
1364
  return {
1291
- instance: decodeOne(response.instance || response, workflowInstanceMapper),
1365
+ instance,
1292
1366
  workflow: {
1293
- uniqueId: (_response_workflow = response.workflow) == null ? void 0 : _response_workflow.unique_id,
1294
- name: (_response_workflow1 = response.workflow) == null ? void 0 : _response_workflow1.name
1367
+ uniqueId: workflow.unique_id || instance.workflowUniqueId,
1368
+ name: workflow.name || ''
1295
1369
  },
1296
- steps: (response.steps || []).map((s)=>({
1297
- stepUniqueId: s.step_unique_id,
1298
- stepName: s.step_name,
1299
- order: s.order,
1300
- status: s.status,
1301
- startedAt: s.started_at ? new Date(s.started_at) : undefined,
1302
- completedAt: s.completed_at ? new Date(s.completed_at) : undefined
1303
- }))
1370
+ steps: Array.isArray(steps) ? steps.map((s)=>({
1371
+ stepUniqueId: String(s['step_unique_id'] || ''),
1372
+ stepName: String(s['step_name'] || ''),
1373
+ order: Number(s['order'] || 0),
1374
+ status: String(s['status'] || ''),
1375
+ startedAt: s['started_at'] ? new Date(s['started_at']) : undefined,
1376
+ completedAt: s['completed_at'] ? new Date(s['completed_at']) : undefined
1377
+ })) : []
1304
1378
  };
1305
1379
  },
1306
1380
  async step (workflowUniqueId, instanceUniqueId, data) {
@@ -1343,6 +1417,26 @@ function createWorkflowInstancesService(transport, _config) {
1343
1417
  };
1344
1418
  }
1345
1419
 
1420
+ const runExecutionMapper = {
1421
+ type: 'run_execution',
1422
+ map: (resource)=>({
1423
+ id: resource.id,
1424
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
1425
+ agentUniqueId: parseString(resource.attributes['agent_unique_id']) || '',
1426
+ runId: parseString(resource.attributes['run_id']) || undefined,
1427
+ threadId: parseString(resource.attributes['thread_id']) || undefined,
1428
+ status: parseString(resource.attributes['status']) || 'pending',
1429
+ input: parseString(resource.attributes['input']) || undefined,
1430
+ output: parseString(resource.attributes['output']) || undefined,
1431
+ tokens: parseOptionalNumber(resource.attributes['tokens']),
1432
+ cost: parseOptionalNumber(resource.attributes['cost']),
1433
+ duration: parseOptionalNumber(resource.attributes['duration']),
1434
+ error: parseString(resource.attributes['error']) || undefined,
1435
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
1436
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
1437
+ })
1438
+ };
1439
+
1346
1440
  function buildRuntimeMessageBody(data) {
1347
1441
  const body = {};
1348
1442
  if (data.role) body['role'] = data.role;
@@ -1476,7 +1570,6 @@ function createAgentRuntimeService(transport, _config, sseUrl) {
1476
1570
  return (response.messages || response || []).map(parseAgentMessage);
1477
1571
  },
1478
1572
  async listExecutions (agentUniqueId, params) {
1479
- var _response_meta, _response_meta1, _response_meta2, _response_meta3;
1480
1573
  const queryParams = {};
1481
1574
  if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
1482
1575
  if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
@@ -1485,40 +1578,20 @@ function createAgentRuntimeService(transport, _config, sseUrl) {
1485
1578
  const response = await transport.get(`/agents/${agentUniqueId}/executions`, {
1486
1579
  params: queryParams
1487
1580
  });
1488
- const data = response.data || [];
1489
- return {
1490
- data: data.map((e)=>({
1491
- id: e.id,
1492
- uniqueId: e.unique_id,
1493
- agentUniqueId: e.agent_unique_id,
1494
- runId: e.run_id,
1495
- threadId: e.thread_id,
1496
- status: e.status,
1497
- input: e.input,
1498
- output: e.output,
1499
- tokens: e.tokens,
1500
- cost: e.cost,
1501
- duration: e.duration,
1502
- error: e.error,
1503
- createdAt: new Date(e.created_at),
1504
- updatedAt: new Date(e.updated_at)
1505
- })),
1506
- meta: {
1507
- totalCount: ((_response_meta = response.meta) == null ? void 0 : _response_meta.total_count) || data.length,
1508
- currentPage: ((_response_meta1 = response.meta) == null ? void 0 : _response_meta1.current_page) || 1,
1509
- perPage: ((_response_meta2 = response.meta) == null ? void 0 : _response_meta2.per_page) || data.length,
1510
- totalPages: ((_response_meta3 = response.meta) == null ? void 0 : _response_meta3.total_pages) || 1
1511
- }
1512
- };
1581
+ return decodePageResult(response, runExecutionMapper);
1513
1582
  },
1514
1583
  async getExecution (agentUniqueId, executionUniqueId) {
1515
1584
  const response = await transport.get(`/agents/${agentUniqueId}/executions/${executionUniqueId}`);
1585
+ return decodeOne(response, runExecutionMapper);
1586
+ },
1587
+ async getRunStatus (agentUniqueId, threadId, runId) {
1588
+ const response = await transport.get(`/agents/${agentUniqueId}/threads/${threadId}/runs/${runId}`);
1516
1589
  return {
1517
1590
  id: response.id,
1518
1591
  uniqueId: response.unique_id,
1519
1592
  agentUniqueId: response.agent_unique_id,
1520
- runId: response.run_id,
1521
- threadId: response.thread_id,
1593
+ runId: response.run_id || runId,
1594
+ threadId: response.thread_id || threadId,
1522
1595
  status: response.status,
1523
1596
  input: response.input,
1524
1597
  output: response.output,
@@ -2381,10 +2454,430 @@ function createAnalyticsService(transport, _config) {
2381
2454
  };
2382
2455
  }
2383
2456
 
2457
+ const promptTestMapper = {
2458
+ type: 'prompt_test',
2459
+ map: (resource)=>({
2460
+ id: resource.id,
2461
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2462
+ promptUniqueId: parseString(resource.attributes['prompt_unique_id']) || '',
2463
+ name: parseString(resource.attributes['name']) || '',
2464
+ description: parseString(resource.attributes['description']) || undefined,
2465
+ input: parseString(resource.attributes['input']) || undefined,
2466
+ expectedOutput: parseString(resource.attributes['expected_output']) || undefined,
2467
+ variables: resource.attributes['variables'],
2468
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
2469
+ status: parseString(resource.attributes['status']) || 'active',
2470
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2471
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2472
+ })
2473
+ };
2474
+ const promptTestResultMapper = {
2475
+ type: 'prompt_test_result',
2476
+ map: (resource)=>({
2477
+ id: resource.id,
2478
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2479
+ testUniqueId: parseString(resource.attributes['test_unique_id']) || '',
2480
+ promptUniqueId: parseString(resource.attributes['prompt_unique_id']) || '',
2481
+ versionUniqueId: parseString(resource.attributes['version_unique_id']) || undefined,
2482
+ input: parseString(resource.attributes['input']) || undefined,
2483
+ expectedOutput: parseString(resource.attributes['expected_output']) || undefined,
2484
+ actualOutput: parseString(resource.attributes['actual_output']) || undefined,
2485
+ passed: resource.attributes['passed'] != null ? parseBoolean(resource.attributes['passed']) : undefined,
2486
+ score: parseOptionalNumber(resource.attributes['score']),
2487
+ tokens: parseOptionalNumber(resource.attributes['tokens']),
2488
+ cost: parseOptionalNumber(resource.attributes['cost']),
2489
+ duration: parseOptionalNumber(resource.attributes['duration']),
2490
+ error: parseString(resource.attributes['error']) || undefined,
2491
+ status: parseString(resource.attributes['status']) || 'pending',
2492
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2493
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2494
+ })
2495
+ };
2496
+ const promptTestEvaluationMapper = {
2497
+ type: 'prompt_test_evaluation',
2498
+ map: (resource)=>({
2499
+ id: resource.id,
2500
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2501
+ name: parseString(resource.attributes['name']) || undefined,
2502
+ description: parseString(resource.attributes['description']) || undefined,
2503
+ status: parseString(resource.attributes['status']) || 'active',
2504
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2505
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2506
+ })
2507
+ };
2508
+
2509
+ function buildPromptTestBody(data) {
2510
+ const body = {};
2511
+ if (data.name) body['name'] = data.name;
2512
+ if (data.description) body['description'] = data.description;
2513
+ if (data.input) body['input'] = data.input;
2514
+ if (data.expectedOutput) body['expected_output'] = data.expectedOutput;
2515
+ if (data.variables) body['variables'] = data.variables;
2516
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
2517
+ return body;
2518
+ }
2519
+ function createPromptTestsService(transport, _config) {
2520
+ return {
2521
+ async list (promptUniqueId, params) {
2522
+ const queryParams = {};
2523
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2524
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2525
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2526
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
2527
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2528
+ const response = await transport.get(`/prompts/${promptUniqueId}/tests`, {
2529
+ params: queryParams
2530
+ });
2531
+ return decodePageResult(response, promptTestMapper);
2532
+ },
2533
+ async get (promptUniqueId, testUniqueId) {
2534
+ const response = await transport.get(`/prompts/${promptUniqueId}/tests/${testUniqueId}`);
2535
+ return decodeOne(response, promptTestMapper);
2536
+ },
2537
+ async create (promptUniqueId, data) {
2538
+ const response = await transport.post(`/prompts/${promptUniqueId}/tests`, {
2539
+ prompt_test: buildPromptTestBody(data)
2540
+ });
2541
+ return decodeOne(response, promptTestMapper);
2542
+ },
2543
+ async update (promptUniqueId, testUniqueId, data) {
2544
+ const response = await transport.put(`/prompts/${promptUniqueId}/tests/${testUniqueId}`, {
2545
+ prompt_test: buildPromptTestBody(data)
2546
+ });
2547
+ return decodeOne(response, promptTestMapper);
2548
+ },
2549
+ async delete (promptUniqueId, testUniqueId) {
2550
+ await transport.delete(`/prompts/${promptUniqueId}/tests/${testUniqueId}`);
2551
+ },
2552
+ async run (promptUniqueId, testUniqueId) {
2553
+ const response = await transport.post(`/prompts/${promptUniqueId}/tests/${testUniqueId}/run`, {});
2554
+ return decodeOne(response, promptTestResultMapper);
2555
+ },
2556
+ async runAgainstVersion (promptUniqueId, versionUniqueId, testUniqueId) {
2557
+ const response = await transport.post(`/prompts/${promptUniqueId}/versions/${versionUniqueId}/tests/${testUniqueId}/run`, {});
2558
+ return decodeOne(response, promptTestResultMapper);
2559
+ },
2560
+ async runAll (promptUniqueId) {
2561
+ const response = await transport.post(`/prompts/${promptUniqueId}/tests/run-all`, {});
2562
+ const raw = response;
2563
+ const data = raw.data || raw;
2564
+ if (Array.isArray(data)) {
2565
+ return data.map((item)=>decodeOne({
2566
+ data: item
2567
+ }, promptTestResultMapper));
2568
+ }
2569
+ return [];
2570
+ },
2571
+ async listResults (promptUniqueId, testUniqueId, params) {
2572
+ const queryParams = {};
2573
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2574
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2575
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2576
+ const response = await transport.get(`/prompts/${promptUniqueId}/tests/${testUniqueId}/results`, {
2577
+ params: queryParams
2578
+ });
2579
+ return decodePageResult(response, promptTestResultMapper);
2580
+ },
2581
+ async getResult (promptUniqueId, testUniqueId, resultUniqueId) {
2582
+ const response = await transport.get(`/prompts/${promptUniqueId}/tests/${testUniqueId}/results/${resultUniqueId}`);
2583
+ return decodeOne(response, promptTestResultMapper);
2584
+ },
2585
+ async listVersionResults (promptUniqueId, versionUniqueId, params) {
2586
+ const queryParams = {};
2587
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2588
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2589
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2590
+ const response = await transport.get(`/prompts/${promptUniqueId}/versions/${versionUniqueId}/test-results`, {
2591
+ params: queryParams
2592
+ });
2593
+ return decodePageResult(response, promptTestResultMapper);
2594
+ }
2595
+ };
2596
+ }
2597
+ function createPromptTestEvaluationsService(transport, _config) {
2598
+ return {
2599
+ async list (params) {
2600
+ const queryParams = {};
2601
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2602
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2603
+ const response = await transport.get('/prompt-test-evaluations', {
2604
+ params: queryParams
2605
+ });
2606
+ return decodePageResult(response, promptTestEvaluationMapper);
2607
+ },
2608
+ async get (uniqueId) {
2609
+ const response = await transport.get(`/prompt-test-evaluations/${uniqueId}`);
2610
+ return decodeOne(response, promptTestEvaluationMapper);
2611
+ },
2612
+ async create (data) {
2613
+ const response = await transport.post('/prompt-test-evaluations', {
2614
+ prompt_test_evaluation: data
2615
+ });
2616
+ return decodeOne(response, promptTestEvaluationMapper);
2617
+ },
2618
+ async run (uniqueId) {
2619
+ const response = await transport.post(`/prompt-test-evaluations/${uniqueId}/run`, {});
2620
+ return decodeOne(response, promptTestEvaluationMapper);
2621
+ },
2622
+ async compareVersions (data) {
2623
+ const response = await transport.post('/prompt-test-evaluations/compare-versions', {
2624
+ version_a: data.versionA,
2625
+ version_b: data.versionB
2626
+ });
2627
+ return {
2628
+ versionA: response.version_a || data.versionA,
2629
+ versionB: response.version_b || data.versionB,
2630
+ results: response.results || []
2631
+ };
2632
+ }
2633
+ };
2634
+ }
2635
+
2636
+ const agentTestMapper = {
2637
+ type: 'agent_test',
2638
+ map: (resource)=>({
2639
+ id: resource.id,
2640
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2641
+ agentUniqueId: parseString(resource.attributes['agent_unique_id']) || '',
2642
+ name: parseString(resource.attributes['name']) || '',
2643
+ description: parseString(resource.attributes['description']) || undefined,
2644
+ input: parseString(resource.attributes['input']) || undefined,
2645
+ expectedOutput: parseString(resource.attributes['expected_output']) || undefined,
2646
+ variables: resource.attributes['variables'],
2647
+ enabled: resource.attributes['enabled'] != null ? parseBoolean(resource.attributes['enabled']) : undefined,
2648
+ status: parseString(resource.attributes['status']) || 'active',
2649
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2650
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2651
+ })
2652
+ };
2653
+ const agentTestResultMapper = {
2654
+ type: 'agent_test_result',
2655
+ map: (resource)=>({
2656
+ id: resource.id,
2657
+ uniqueId: parseString(resource.attributes['unique_id']) || '',
2658
+ testUniqueId: parseString(resource.attributes['test_unique_id']) || '',
2659
+ agentUniqueId: parseString(resource.attributes['agent_unique_id']) || '',
2660
+ input: parseString(resource.attributes['input']) || undefined,
2661
+ expectedOutput: parseString(resource.attributes['expected_output']) || undefined,
2662
+ actualOutput: parseString(resource.attributes['actual_output']) || undefined,
2663
+ passed: resource.attributes['passed'] != null ? parseBoolean(resource.attributes['passed']) : undefined,
2664
+ score: parseOptionalNumber(resource.attributes['score']),
2665
+ tokens: parseOptionalNumber(resource.attributes['tokens']),
2666
+ cost: parseOptionalNumber(resource.attributes['cost']),
2667
+ duration: parseOptionalNumber(resource.attributes['duration']),
2668
+ error: parseString(resource.attributes['error']) || undefined,
2669
+ status: parseString(resource.attributes['status']) || 'pending',
2670
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2671
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2672
+ })
2673
+ };
2674
+
2675
+ function buildAgentTestBody(data) {
2676
+ const body = {};
2677
+ if (data.name) body['name'] = data.name;
2678
+ if (data.description) body['description'] = data.description;
2679
+ if (data.input) body['input'] = data.input;
2680
+ if (data.expectedOutput) body['expected_output'] = data.expectedOutput;
2681
+ if (data.variables) body['variables'] = data.variables;
2682
+ if (data.enabled !== undefined) body['enabled'] = data.enabled;
2683
+ return body;
2684
+ }
2685
+ function createAgentTestsService(transport, _config) {
2686
+ return {
2687
+ async list (agentUniqueId, params) {
2688
+ const queryParams = {};
2689
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2690
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2691
+ if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
2692
+ if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
2693
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2694
+ const response = await transport.get(`/agents/${agentUniqueId}/tests`, {
2695
+ params: queryParams
2696
+ });
2697
+ return decodePageResult(response, agentTestMapper);
2698
+ },
2699
+ async get (agentUniqueId, testUniqueId) {
2700
+ const response = await transport.get(`/agents/${agentUniqueId}/tests/${testUniqueId}`);
2701
+ return decodeOne(response, agentTestMapper);
2702
+ },
2703
+ async create (agentUniqueId, data) {
2704
+ const response = await transport.post(`/agents/${agentUniqueId}/tests`, {
2705
+ agent_test: buildAgentTestBody(data)
2706
+ });
2707
+ return decodeOne(response, agentTestMapper);
2708
+ },
2709
+ async update (agentUniqueId, testUniqueId, data) {
2710
+ const response = await transport.put(`/agents/${agentUniqueId}/tests/${testUniqueId}`, {
2711
+ agent_test: buildAgentTestBody(data)
2712
+ });
2713
+ return decodeOne(response, agentTestMapper);
2714
+ },
2715
+ async delete (agentUniqueId, testUniqueId) {
2716
+ await transport.delete(`/agents/${agentUniqueId}/tests/${testUniqueId}`);
2717
+ },
2718
+ async run (agentUniqueId, testUniqueId) {
2719
+ const response = await transport.post(`/agents/${agentUniqueId}/tests/${testUniqueId}/run`, {});
2720
+ return decodeOne(response, agentTestResultMapper);
2721
+ },
2722
+ async runAll (agentUniqueId) {
2723
+ const response = await transport.post(`/agents/${agentUniqueId}/tests/run-all`, {});
2724
+ const raw = response;
2725
+ const data = raw.data || raw;
2726
+ if (Array.isArray(data)) {
2727
+ return data.map((item)=>decodeOne({
2728
+ data: item
2729
+ }, agentTestResultMapper));
2730
+ }
2731
+ return [];
2732
+ },
2733
+ async listResults (agentUniqueId, testUniqueId, params) {
2734
+ const queryParams = {};
2735
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2736
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2737
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2738
+ const response = await transport.get(`/agents/${agentUniqueId}/tests/${testUniqueId}/results`, {
2739
+ params: queryParams
2740
+ });
2741
+ return decodePageResult(response, agentTestResultMapper);
2742
+ },
2743
+ async getResult (agentUniqueId, testUniqueId, resultUniqueId) {
2744
+ const response = await transport.get(`/agents/${agentUniqueId}/tests/${testUniqueId}/results/${resultUniqueId}`);
2745
+ return decodeOne(response, agentTestResultMapper);
2746
+ },
2747
+ async listAgentResults (agentUniqueId, params) {
2748
+ const queryParams = {};
2749
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2750
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2751
+ if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
2752
+ const response = await transport.get(`/agents/${agentUniqueId}/test-results`, {
2753
+ params: queryParams
2754
+ });
2755
+ return decodePageResult(response, agentTestResultMapper);
2756
+ }
2757
+ };
2758
+ }
2759
+
2760
+ const promptTemplateMapper = {
2761
+ type: 'prompt_template',
2762
+ map: (resource)=>({
2763
+ id: resource.id,
2764
+ uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
2765
+ name: parseString(resource.attributes['name']) || '',
2766
+ description: parseString(resource.attributes['description']) || undefined,
2767
+ schema: resource.attributes['schema'],
2768
+ formDefinition: resource.attributes['form_definition'],
2769
+ status: parseString(resource.attributes['status']) || 'active',
2770
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2771
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2772
+ })
2773
+ };
2774
+
2775
+ function createPromptTemplatesService(transport, _config) {
2776
+ return {
2777
+ async list (params) {
2778
+ const queryParams = {};
2779
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2780
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2781
+ if (params == null ? void 0 : params.includeSchema) queryParams['include_schema'] = 'true';
2782
+ const response = await transport.get('/prompt_templates', {
2783
+ params: queryParams
2784
+ });
2785
+ return decodePageResult(response, promptTemplateMapper);
2786
+ },
2787
+ async get (id) {
2788
+ const response = await transport.get(`/prompt_templates/${id}`);
2789
+ return decodeOne(response, promptTemplateMapper);
2790
+ }
2791
+ };
2792
+ }
2793
+
2794
+ const companyKeyMapper = {
2795
+ type: 'company_key',
2796
+ map: (resource)=>({
2797
+ id: resource.id,
2798
+ uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
2799
+ name: parseString(resource.attributes['name']) || undefined,
2800
+ keyValue: parseString(resource.attributes['key_value']) || undefined,
2801
+ provider: parseString(resource.attributes['provider']) || undefined,
2802
+ status: parseString(resource.attributes['status']) || 'active',
2803
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2804
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2805
+ })
2806
+ };
2807
+
2808
+ function createCompanyKeysService(transport, _config) {
2809
+ return {
2810
+ async list (urlId, params) {
2811
+ const queryParams = {};
2812
+ if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
2813
+ if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
2814
+ const response = await transport.get(`/companies/${urlId}/keys`, {
2815
+ params: queryParams
2816
+ });
2817
+ return decodePageResult(response, companyKeyMapper);
2818
+ },
2819
+ async create (urlId, data) {
2820
+ const body = {};
2821
+ if (data.name) body['name'] = data.name;
2822
+ body['key_value'] = data.keyValue;
2823
+ if (data.provider) body['provider'] = data.provider;
2824
+ const response = await transport.post(`/companies/${urlId}/keys`, {
2825
+ key: body
2826
+ });
2827
+ return decodeOne(response, companyKeyMapper);
2828
+ },
2829
+ async delete (urlId, keyUniqueId) {
2830
+ await transport.delete(`/companies/${urlId}/keys/${keyUniqueId}`);
2831
+ }
2832
+ };
2833
+ }
2834
+
2835
+ const llmProviderMapper = {
2836
+ type: 'llm_provider',
2837
+ map: (resource)=>({
2838
+ id: resource.id,
2839
+ uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
2840
+ name: parseString(resource.attributes['name']) || '',
2841
+ providerType: parseString(resource.attributes['provider_type']) || undefined,
2842
+ apiUrl: parseString(resource.attributes['api_url']) || undefined,
2843
+ status: parseString(resource.attributes['status']) || 'active',
2844
+ createdAt: parseDate(resource.attributes['created_at']) || new Date(),
2845
+ updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
2846
+ })
2847
+ };
2848
+
2849
+ function createLlmProvidersService(transport, _config) {
2850
+ return {
2851
+ async list () {
2852
+ const response = await transport.get('/llm-providers');
2853
+ return decodePageResult(response, llmProviderMapper);
2854
+ },
2855
+ async validate () {
2856
+ const response = await transport.get('/llm-providers/validate');
2857
+ return {
2858
+ valid: !!response.valid,
2859
+ message: response.message
2860
+ };
2861
+ },
2862
+ async models (provider) {
2863
+ const response = await transport.get(`/llm-providers/${provider}/models`);
2864
+ const data = response.data || response;
2865
+ if (Array.isArray(data)) {
2866
+ return data.map((m)=>({
2867
+ id: m.id || m.name,
2868
+ name: m.name || m.id,
2869
+ provider: m.provider || provider
2870
+ }));
2871
+ }
2872
+ return [];
2873
+ }
2874
+ };
2875
+ }
2876
+
2384
2877
  function createJarvisBlock(transport, config) {
2385
2878
  return {
2386
2879
  agents: createAgentsService(transport),
2387
- prompts: createPromptsService(transport),
2880
+ prompts: createPromptsService(transport, config, config.sseUrl),
2388
2881
  workflows: createWorkflowsService(transport),
2389
2882
  executions: createExecutionsService(transport),
2390
2883
  conversations: createConversationsService(transport),
@@ -2406,6 +2899,12 @@ function createJarvisBlock(transport, config) {
2406
2899
  conditions: createConditionsService(transport),
2407
2900
  stepTransitions: createStepTransitionsService(transport),
2408
2901
  analytics: createAnalyticsService(transport),
2902
+ promptTests: createPromptTestsService(transport),
2903
+ promptTestEvaluations: createPromptTestEvaluationsService(transport),
2904
+ agentTests: createAgentTestsService(transport),
2905
+ promptTemplates: createPromptTemplatesService(transport),
2906
+ companyKeys: createCompanyKeysService(transport),
2907
+ llmProviders: createLlmProvidersService(transport),
2409
2908
  health: ()=>transport.get('/health')
2410
2909
  };
2411
2910
  }
@@ -2418,8 +2917,16 @@ const jarvisBlockMetadata = {
2418
2917
  'Prompt',
2419
2918
  'Workflow',
2420
2919
  'Execution',
2421
- 'Conversation'
2920
+ 'Conversation',
2921
+ 'PromptTest',
2922
+ 'PromptTestResult',
2923
+ 'PromptTestEvaluation',
2924
+ 'AgentTest',
2925
+ 'AgentTestResult',
2926
+ 'PromptTemplate',
2927
+ 'CompanyKey',
2928
+ 'LlmProvider'
2422
2929
  ]
2423
2930
  };
2424
2931
 
2425
- export { agentMapper, agentToolAssignmentMapper, agentToolMapper, aiModelMapper, clusterMapper, conditionMapper, conversationMapper, createAIModelsService, createAgentRuntimeService, createAgentToolAssignmentsService, createAgentToolsService, createAgentsService, createAnalyticsService, createClustersService, createConditionsService, createConversationsService, createEntitiesService, createExecutionCommentsService, createExecutionsService, createJarvisBlock, createJarvisUsersService, createMailTemplatesService, createMarvinChatService, createPromptCommentsService, createPromptsService, createStepTransitionsService, createToolsService, createWorkflowInstancesService, createWorkflowParticipantsService, createWorkflowStepsService, createWorkflowsService, entityMapper, executionCommentMapper, executionMapper, jarvisBlockMetadata, jarvisUserMapper, mailTemplateMapper, promptCommentMapper, promptMapper, stepTransitionMapper, toolMapper, workflowInstanceMapper, workflowMapper, workflowParticipantMapper, workflowStepMapper };
2932
+ export { agentMapper, agentTestMapper, agentTestResultMapper, agentToolAssignmentMapper, agentToolMapper, aiModelMapper, clusterMapper, companyKeyMapper, conditionMapper, conversationMapper, createAIModelsService, createAgentRuntimeService, createAgentTestsService, createAgentToolAssignmentsService, createAgentToolsService, createAgentsService, createAnalyticsService, createClustersService, createCompanyKeysService, createConditionsService, createConversationsService, createEntitiesService, createExecutionCommentsService, createExecutionsService, createJarvisBlock, createJarvisUsersService, createLlmProvidersService, createMailTemplatesService, createMarvinChatService, createPromptCommentsService, createPromptTemplatesService, createPromptTestEvaluationsService, createPromptTestsService, createPromptsService, createStepTransitionsService, createToolsService, createWorkflowInstancesService, createWorkflowParticipantsService, createWorkflowStepsService, createWorkflowsService, entityMapper, executionCommentMapper, executionMapper, jarvisBlockMetadata, jarvisUserMapper, llmProviderMapper, mailTemplateMapper, openaiModelMapper, promptCommentMapper, promptMapper, promptTemplateMapper, promptTestEvaluationMapper, promptTestMapper, promptTestResultMapper, runExecutionMapper, stepTransitionMapper, toolMapper, workflowInstanceMapper, workflowMapper, workflowParticipantMapper, workflowStepMapper };