@23blocks/block-jarvis 1.0.3 → 1.0.4

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 (84) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.esm.js +591 -0
  3. package/dist/src/index.d.ts +7 -0
  4. package/dist/src/index.d.ts.map +1 -0
  5. package/dist/src/lib/jarvis.block.d.ts +16 -0
  6. package/dist/src/lib/jarvis.block.d.ts.map +1 -0
  7. package/dist/src/lib/mappers/agent.mapper.d.ts +4 -0
  8. package/dist/src/lib/mappers/agent.mapper.d.ts.map +1 -0
  9. package/dist/src/lib/mappers/conversation.mapper.d.ts +4 -0
  10. package/dist/src/lib/mappers/conversation.mapper.d.ts.map +1 -0
  11. package/dist/src/lib/mappers/execution.mapper.d.ts +4 -0
  12. package/dist/src/lib/mappers/execution.mapper.d.ts.map +1 -0
  13. package/dist/{lib/mappers/index.js → src/lib/mappers/index.d.ts} +1 -2
  14. package/dist/src/lib/mappers/index.d.ts.map +1 -0
  15. package/dist/src/lib/mappers/prompt.mapper.d.ts +4 -0
  16. package/dist/src/lib/mappers/prompt.mapper.d.ts.map +1 -0
  17. package/dist/src/lib/mappers/utils.d.ts +37 -0
  18. package/dist/src/lib/mappers/utils.d.ts.map +1 -0
  19. package/dist/src/lib/mappers/workflow.mapper.d.ts +4 -0
  20. package/dist/src/lib/mappers/workflow.mapper.d.ts.map +1 -0
  21. package/dist/src/lib/services/agents.service.d.ts +15 -0
  22. package/dist/src/lib/services/agents.service.d.ts.map +1 -0
  23. package/dist/src/lib/services/conversations.service.d.ts +14 -0
  24. package/dist/src/lib/services/conversations.service.d.ts.map +1 -0
  25. package/dist/src/lib/services/executions.service.d.ts +13 -0
  26. package/dist/src/lib/services/executions.service.d.ts.map +1 -0
  27. package/dist/{lib/services/index.js → src/lib/services/index.d.ts} +1 -2
  28. package/dist/src/lib/services/index.d.ts.map +1 -0
  29. package/dist/src/lib/services/prompts.service.d.ts +15 -0
  30. package/dist/src/lib/services/prompts.service.d.ts.map +1 -0
  31. package/dist/src/lib/services/workflows.service.d.ts +16 -0
  32. package/dist/src/lib/services/workflows.service.d.ts.map +1 -0
  33. package/dist/src/lib/types/agent.d.ts +70 -0
  34. package/dist/src/lib/types/agent.d.ts.map +1 -0
  35. package/dist/src/lib/types/conversation.d.ts +43 -0
  36. package/dist/src/lib/types/conversation.d.ts.map +1 -0
  37. package/dist/src/lib/types/execution.d.ts +25 -0
  38. package/dist/src/lib/types/execution.d.ts.map +1 -0
  39. package/dist/{lib/types/index.js → src/lib/types/index.d.ts} +1 -2
  40. package/dist/src/lib/types/index.d.ts.map +1 -0
  41. package/dist/src/lib/types/prompt.d.ts +63 -0
  42. package/dist/src/lib/types/prompt.d.ts.map +1 -0
  43. package/dist/src/lib/types/workflow.d.ts +57 -0
  44. package/dist/src/lib/types/workflow.d.ts.map +1 -0
  45. package/package.json +10 -8
  46. package/dist/index.js +0 -7
  47. package/dist/index.js.map +0 -1
  48. package/dist/lib/jarvis.block.js +0 -24
  49. package/dist/lib/jarvis.block.js.map +0 -1
  50. package/dist/lib/mappers/agent.mapper.js +0 -23
  51. package/dist/lib/mappers/agent.mapper.js.map +0 -1
  52. package/dist/lib/mappers/conversation.mapper.js +0 -29
  53. package/dist/lib/mappers/conversation.mapper.js.map +0 -1
  54. package/dist/lib/mappers/execution.mapper.js +0 -23
  55. package/dist/lib/mappers/execution.mapper.js.map +0 -1
  56. package/dist/lib/mappers/index.js.map +0 -1
  57. package/dist/lib/mappers/prompt.mapper.js +0 -22
  58. package/dist/lib/mappers/prompt.mapper.js.map +0 -1
  59. package/dist/lib/mappers/utils.js +0 -93
  60. package/dist/lib/mappers/utils.js.map +0 -1
  61. package/dist/lib/mappers/workflow.mapper.js +0 -20
  62. package/dist/lib/mappers/workflow.mapper.js.map +0 -1
  63. package/dist/lib/services/agents.service.js +0 -94
  64. package/dist/lib/services/agents.service.js.map +0 -1
  65. package/dist/lib/services/conversations.service.js +0 -79
  66. package/dist/lib/services/conversations.service.js.map +0 -1
  67. package/dist/lib/services/executions.service.js +0 -51
  68. package/dist/lib/services/executions.service.js.map +0 -1
  69. package/dist/lib/services/index.js.map +0 -1
  70. package/dist/lib/services/prompts.service.js +0 -88
  71. package/dist/lib/services/prompts.service.js.map +0 -1
  72. package/dist/lib/services/workflows.service.js +0 -79
  73. package/dist/lib/services/workflows.service.js.map +0 -1
  74. package/dist/lib/types/agent.js +0 -3
  75. package/dist/lib/types/agent.js.map +0 -1
  76. package/dist/lib/types/conversation.js +0 -3
  77. package/dist/lib/types/conversation.js.map +0 -1
  78. package/dist/lib/types/execution.js +0 -4
  79. package/dist/lib/types/execution.js.map +0 -1
  80. package/dist/lib/types/index.js.map +0 -1
  81. package/dist/lib/types/prompt.js +0 -3
  82. package/dist/lib/types/prompt.js.map +0 -1
  83. package/dist/lib/types/workflow.js +0 -3
  84. package/dist/lib/types/workflow.js.map +0 -1
@@ -1,29 +0,0 @@
1
- import { parseString, parseDate, parseStatus, parseMessageRole } from './utils';
2
- export const conversationMapper = {
3
- type: 'Conversation',
4
- map: (resource)=>({
5
- id: resource.id,
6
- uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
7
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
8
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
9
- agentUniqueId: parseString(resource.attributes['agent_unique_id']),
10
- userUniqueId: parseString(resource.attributes['user_unique_id']),
11
- title: parseString(resource.attributes['title']),
12
- messages: parseMessages(resource.attributes['messages']),
13
- status: parseStatus(resource.attributes['status']),
14
- payload: resource.attributes['payload']
15
- })
16
- };
17
- function parseMessages(value) {
18
- if (!Array.isArray(value)) {
19
- return [];
20
- }
21
- return value.map((msg)=>({
22
- role: parseMessageRole(msg.role),
23
- content: parseString(msg.content) || '',
24
- timestamp: parseDate(msg.timestamp) || new Date(),
25
- payload: msg.payload
26
- }));
27
- }
28
-
29
- //# sourceMappingURL=conversation.mapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mappers/conversation.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Conversation, ConversationMessage } from '../types/conversation';\nimport { parseString, parseDate, parseStatus, parseMessageRole } from './utils';\n\nexport const conversationMapper: ResourceMapper<Conversation> = {\n type: 'Conversation',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n agentUniqueId: parseString(resource.attributes['agent_unique_id']),\n userUniqueId: parseString(resource.attributes['user_unique_id']),\n title: parseString(resource.attributes['title']),\n messages: parseMessages(resource.attributes['messages']),\n status: parseStatus(resource.attributes['status']),\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n }),\n};\n\nfunction parseMessages(value: unknown): ConversationMessage[] {\n if (!Array.isArray(value)) {\n return [];\n }\n\n return value.map((msg: any) => ({\n role: parseMessageRole(msg.role),\n content: parseString(msg.content) || '',\n timestamp: parseDate(msg.timestamp) || new Date(),\n payload: msg.payload as Record<string, unknown> | undefined,\n }));\n}\n"],"names":["parseString","parseDate","parseStatus","parseMessageRole","conversationMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","agentUniqueId","userUniqueId","title","messages","parseMessages","status","payload","value","Array","isArray","msg","role","content","timestamp"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,UAAU;AAEhF,OAAO,MAAMC,qBAAmD;IAC9DC,MAAM;IACNC,KAAK,CAACC,WAAc,CAAA;YAClBC,IAAID,SAASC,EAAE;YACfC,UAAUT,YAAYO,SAASG,UAAU,CAAC,YAAY,KAAKH,SAASC,EAAE;YACtEG,WAAWV,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAC/DC,WAAWZ,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAE/DE,eAAed,YAAYO,SAASG,UAAU,CAAC,kBAAkB;YACjEK,cAAcf,YAAYO,SAASG,UAAU,CAAC,iBAAiB;YAC/DM,OAAOhB,YAAYO,SAASG,UAAU,CAAC,QAAQ;YAC/CO,UAAUC,cAAcX,SAASG,UAAU,CAAC,WAAW;YACvDS,QAAQjB,YAAYK,SAASG,UAAU,CAAC,SAAS;YACjDU,SAASb,SAASG,UAAU,CAAC,UAAU;QACzC,CAAA;AACF,EAAE;AAEF,SAASQ,cAAcG,KAAc;IACnC,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQ;QACzB,OAAO,EAAE;IACX;IAEA,OAAOA,MAAMf,GAAG,CAAC,CAACkB,MAAc,CAAA;YAC9BC,MAAMtB,iBAAiBqB,IAAIC,IAAI;YAC/BC,SAAS1B,YAAYwB,IAAIE,OAAO,KAAK;YACrCC,WAAW1B,UAAUuB,IAAIG,SAAS,KAAK,IAAIf;YAC3CQ,SAASI,IAAIJ,OAAO;QACtB,CAAA;AACF"}
@@ -1,23 +0,0 @@
1
- import { parseString, parseDate, parseOptionalNumber, parseExecutionStatus } from './utils';
2
- export const executionMapper = {
3
- type: 'Execution',
4
- map: (resource)=>({
5
- id: resource.id,
6
- uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
7
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
8
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
9
- agentUniqueId: parseString(resource.attributes['agent_unique_id']),
10
- promptUniqueId: parseString(resource.attributes['prompt_unique_id']),
11
- input: parseString(resource.attributes['input']),
12
- output: parseString(resource.attributes['output']),
13
- tokens: parseOptionalNumber(resource.attributes['tokens']),
14
- cost: parseOptionalNumber(resource.attributes['cost']),
15
- duration: parseOptionalNumber(resource.attributes['duration']),
16
- status: parseExecutionStatus(resource.attributes['status']),
17
- startedAt: parseDate(resource.attributes['started_at']),
18
- completedAt: parseDate(resource.attributes['completed_at']),
19
- payload: resource.attributes['payload']
20
- })
21
- };
22
-
23
- //# sourceMappingURL=execution.mapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mappers/execution.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Execution } from '../types/execution';\nimport { parseString, parseDate, parseOptionalNumber, parseExecutionStatus } from './utils';\n\nexport const executionMapper: ResourceMapper<Execution> = {\n type: 'Execution',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n agentUniqueId: parseString(resource.attributes['agent_unique_id']),\n promptUniqueId: parseString(resource.attributes['prompt_unique_id']),\n input: parseString(resource.attributes['input']),\n output: parseString(resource.attributes['output']),\n tokens: parseOptionalNumber(resource.attributes['tokens']),\n cost: parseOptionalNumber(resource.attributes['cost']),\n duration: parseOptionalNumber(resource.attributes['duration']),\n status: parseExecutionStatus(resource.attributes['status']),\n startedAt: parseDate(resource.attributes['started_at']),\n completedAt: parseDate(resource.attributes['completed_at']),\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n }),\n};\n"],"names":["parseString","parseDate","parseOptionalNumber","parseExecutionStatus","executionMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","agentUniqueId","promptUniqueId","input","output","tokens","cost","duration","status","startedAt","completedAt","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,mBAAmB,EAAEC,oBAAoB,QAAQ,UAAU;AAE5F,OAAO,MAAMC,kBAA6C;IACxDC,MAAM;IACNC,KAAK,CAACC,WAAc,CAAA;YAClBC,IAAID,SAASC,EAAE;YACfC,UAAUT,YAAYO,SAASG,UAAU,CAAC,YAAY,KAAKH,SAASC,EAAE;YACtEG,WAAWV,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAC/DC,WAAWZ,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAE/DE,eAAed,YAAYO,SAASG,UAAU,CAAC,kBAAkB;YACjEK,gBAAgBf,YAAYO,SAASG,UAAU,CAAC,mBAAmB;YACnEM,OAAOhB,YAAYO,SAASG,UAAU,CAAC,QAAQ;YAC/CO,QAAQjB,YAAYO,SAASG,UAAU,CAAC,SAAS;YACjDQ,QAAQhB,oBAAoBK,SAASG,UAAU,CAAC,SAAS;YACzDS,MAAMjB,oBAAoBK,SAASG,UAAU,CAAC,OAAO;YACrDU,UAAUlB,oBAAoBK,SAASG,UAAU,CAAC,WAAW;YAC7DW,QAAQlB,qBAAqBI,SAASG,UAAU,CAAC,SAAS;YAC1DY,WAAWrB,UAAUM,SAASG,UAAU,CAAC,aAAa;YACtDa,aAAatB,UAAUM,SAASG,UAAU,CAAC,eAAe;YAC1Dc,SAASjB,SAASG,UAAU,CAAC,UAAU;QACzC,CAAA;AACF,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mappers/index.ts"],"sourcesContent":["export * from './agent.mapper';\nexport * from './prompt.mapper';\nexport * from './workflow.mapper';\nexport * from './execution.mapper';\nexport * from './conversation.mapper';\nexport * from './utils';\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,UAAU"}
@@ -1,22 +0,0 @@
1
- import { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';
2
- export const promptMapper = {
3
- type: 'Prompt',
4
- map: (resource)=>({
5
- id: resource.id,
6
- uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
7
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
8
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
9
- agentUniqueId: parseString(resource.attributes['agent_unique_id']),
10
- code: parseString(resource.attributes['code']) || '',
11
- name: parseString(resource.attributes['name']) || '',
12
- description: parseString(resource.attributes['description']),
13
- template: parseString(resource.attributes['template']) || '',
14
- variables: parseStringArray(resource.attributes['variables']),
15
- version: parseOptionalNumber(resource.attributes['version']),
16
- status: parseStatus(resource.attributes['status']),
17
- enabled: parseBoolean(resource.attributes['enabled']),
18
- payload: resource.attributes['payload']
19
- })
20
- };
21
-
22
- //# sourceMappingURL=prompt.mapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mappers/prompt.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Prompt } from '../types/prompt';\nimport { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';\n\nexport const promptMapper: ResourceMapper<Prompt> = {\n type: 'Prompt',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n agentUniqueId: parseString(resource.attributes['agent_unique_id']),\n code: parseString(resource.attributes['code']) || '',\n name: parseString(resource.attributes['name']) || '',\n description: parseString(resource.attributes['description']),\n template: parseString(resource.attributes['template']) || '',\n variables: parseStringArray(resource.attributes['variables']),\n version: parseOptionalNumber(resource.attributes['version']),\n status: parseStatus(resource.attributes['status']),\n enabled: parseBoolean(resource.attributes['enabled']),\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n }),\n};\n"],"names":["parseString","parseDate","parseBoolean","parseOptionalNumber","parseStatus","parseStringArray","promptMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","agentUniqueId","code","name","description","template","variables","version","status","enabled","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,UAAU;AAEnH,OAAO,MAAMC,eAAuC;IAClDC,MAAM;IACNC,KAAK,CAACC,WAAc,CAAA;YAClBC,IAAID,SAASC,EAAE;YACfC,UAAUX,YAAYS,SAASG,UAAU,CAAC,YAAY,KAAKH,SAASC,EAAE;YACtEG,WAAWZ,UAAUQ,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAC/DC,WAAWd,UAAUQ,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAE/DE,eAAehB,YAAYS,SAASG,UAAU,CAAC,kBAAkB;YACjEK,MAAMjB,YAAYS,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDM,MAAMlB,YAAYS,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDO,aAAanB,YAAYS,SAASG,UAAU,CAAC,cAAc;YAC3DQ,UAAUpB,YAAYS,SAASG,UAAU,CAAC,WAAW,KAAK;YAC1DS,WAAWhB,iBAAiBI,SAASG,UAAU,CAAC,YAAY;YAC5DU,SAASnB,oBAAoBM,SAASG,UAAU,CAAC,UAAU;YAC3DW,QAAQnB,YAAYK,SAASG,UAAU,CAAC,SAAS;YACjDY,SAAStB,aAAaO,SAASG,UAAU,CAAC,UAAU;YACpDa,SAAShB,SAASG,UAAU,CAAC,UAAU;QACzC,CAAA;AACF,EAAE"}
@@ -1,93 +0,0 @@
1
- /**
2
- * Parse a string value, returning undefined for empty/undefined
3
- */ export function parseString(value) {
4
- if (value === null || value === undefined) {
5
- return undefined;
6
- }
7
- const str = String(value);
8
- return str.length > 0 ? str : undefined;
9
- }
10
- /**
11
- * Parse a date value
12
- */ export function parseDate(value) {
13
- if (value === null || value === undefined) {
14
- return undefined;
15
- }
16
- if (value instanceof Date) {
17
- return value;
18
- }
19
- if (typeof value === 'string' || typeof value === 'number') {
20
- const date = new Date(value);
21
- return isNaN(date.getTime()) ? undefined : date;
22
- }
23
- return undefined;
24
- }
25
- /**
26
- * Parse a boolean value
27
- */ export function parseBoolean(value) {
28
- if (typeof value === 'boolean') {
29
- return value;
30
- }
31
- if (value === 'true' || value === '1' || value === 1) {
32
- return true;
33
- }
34
- return false;
35
- }
36
- /**
37
- * Parse an array of strings
38
- */ export function parseStringArray(value) {
39
- if (value === null || value === undefined) {
40
- return undefined;
41
- }
42
- if (Array.isArray(value)) {
43
- return value.map(String);
44
- }
45
- return undefined;
46
- }
47
- /**
48
- * Parse a number value
49
- */ export function parseNumber(value) {
50
- if (value === null || value === undefined) {
51
- return 0;
52
- }
53
- const num = Number(value);
54
- return isNaN(num) ? 0 : num;
55
- }
56
- /**
57
- * Parse an optional number value
58
- */ export function parseOptionalNumber(value) {
59
- if (value === null || value === undefined) {
60
- return undefined;
61
- }
62
- const num = Number(value);
63
- return isNaN(num) ? undefined : num;
64
- }
65
- /**
66
- * Parse entity status
67
- */ export function parseStatus(value) {
68
- const status = parseString(value);
69
- if (status === 'active' || status === 'inactive' || status === 'pending' || status === 'archived' || status === 'deleted') {
70
- return status;
71
- }
72
- return 'active';
73
- }
74
- /**
75
- * Parse execution status
76
- */ export function parseExecutionStatus(value) {
77
- const status = parseString(value);
78
- if (status === 'pending' || status === 'running' || status === 'completed' || status === 'failed') {
79
- return status;
80
- }
81
- return 'pending';
82
- }
83
- /**
84
- * Parse message role
85
- */ export function parseMessageRole(value) {
86
- const role = parseString(value);
87
- if (role === 'user' || role === 'assistant' || role === 'system') {
88
- return role;
89
- }
90
- return 'user';
91
- }
92
-
93
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mappers/utils.ts"],"sourcesContent":["/**\n * Parse a string value, returning undefined for empty/undefined\n */\nexport function parseString(value: unknown): string | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n const str = String(value);\n return str.length > 0 ? str : undefined;\n}\n\n/**\n * Parse a date value\n */\nexport function parseDate(value: unknown): Date | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value === 'string' || typeof value === 'number') {\n const date = new Date(value);\n return isNaN(date.getTime()) ? undefined : date;\n }\n\n return undefined;\n}\n\n/**\n * Parse a boolean value\n */\nexport function parseBoolean(value: unknown): boolean {\n if (typeof value === 'boolean') {\n return value;\n }\n if (value === 'true' || value === '1' || value === 1) {\n return true;\n }\n return false;\n}\n\n/**\n * Parse an array of strings\n */\nexport function parseStringArray(value: unknown): string[] | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n if (Array.isArray(value)) {\n return value.map(String);\n }\n return undefined;\n}\n\n/**\n * Parse a number value\n */\nexport function parseNumber(value: unknown): number {\n if (value === null || value === undefined) {\n return 0;\n }\n const num = Number(value);\n return isNaN(num) ? 0 : num;\n}\n\n/**\n * Parse an optional number value\n */\nexport function parseOptionalNumber(value: unknown): number | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n const num = Number(value);\n return isNaN(num) ? undefined : num;\n}\n\n/**\n * Parse entity status\n */\nexport function parseStatus(value: unknown): 'active' | 'inactive' | 'pending' | 'archived' | 'deleted' {\n const status = parseString(value);\n if (status === 'active' || status === 'inactive' || status === 'pending' || status === 'archived' || status === 'deleted') {\n return status;\n }\n return 'active';\n}\n\n/**\n * Parse execution status\n */\nexport function parseExecutionStatus(value: unknown): 'pending' | 'running' | 'completed' | 'failed' {\n const status = parseString(value);\n if (status === 'pending' || status === 'running' || status === 'completed' || status === 'failed') {\n return status;\n }\n return 'pending';\n}\n\n/**\n * Parse message role\n */\nexport function parseMessageRole(value: unknown): 'user' | 'assistant' | 'system' {\n const role = parseString(value);\n if (role === 'user' || role === 'assistant' || role === 'system') {\n return role;\n }\n return 'user';\n}\n"],"names":["parseString","value","undefined","str","String","length","parseDate","Date","date","isNaN","getTime","parseBoolean","parseStringArray","Array","isArray","map","parseNumber","num","Number","parseOptionalNumber","parseStatus","status","parseExecutionStatus","parseMessageRole","role"],"rangeMappings":";;;;;;;;;;;;;;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;IACA,MAAMe,MAAMC,OAAOjB;IACnB,OAAOQ,MAAMQ,OAAOf,YAAYe;AAClC;AAEA;;CAEC,GACD,OAAO,SAASG,YAAYnB,KAAc;IACxC,MAAMoB,SAASrB,YAAYC;IAC3B,IAAIoB,WAAW,YAAYA,WAAW,cAAcA,WAAW,aAAaA,WAAW,cAAcA,WAAW,WAAW;QACzH,OAAOA;IACT;IACA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,qBAAqBrB,KAAc;IACjD,MAAMoB,SAASrB,YAAYC;IAC3B,IAAIoB,WAAW,aAAaA,WAAW,aAAaA,WAAW,eAAeA,WAAW,UAAU;QACjG,OAAOA;IACT;IACA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASE,iBAAiBtB,KAAc;IAC7C,MAAMuB,OAAOxB,YAAYC;IACzB,IAAIuB,SAAS,UAAUA,SAAS,eAAeA,SAAS,UAAU;QAChE,OAAOA;IACT;IACA,OAAO;AACT"}
@@ -1,20 +0,0 @@
1
- import { parseString, parseDate, parseBoolean, parseStatus } from './utils';
2
- export const workflowMapper = {
3
- type: 'Workflow',
4
- map: (resource)=>({
5
- id: resource.id,
6
- uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
7
- createdAt: parseDate(resource.attributes['created_at']) || new Date(),
8
- updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
9
- code: parseString(resource.attributes['code']) || '',
10
- name: parseString(resource.attributes['name']) || '',
11
- description: parseString(resource.attributes['description']),
12
- steps: resource.attributes['steps'] || [],
13
- triggers: resource.attributes['triggers'],
14
- status: parseStatus(resource.attributes['status']),
15
- enabled: parseBoolean(resource.attributes['enabled']),
16
- payload: resource.attributes['payload']
17
- })
18
- };
19
-
20
- //# sourceMappingURL=workflow.mapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mappers/workflow.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Workflow, WorkflowStep, WorkflowTrigger } from '../types/workflow';\nimport { parseString, parseDate, parseBoolean, parseStatus } from './utils';\n\nexport const workflowMapper: ResourceMapper<Workflow> = {\n type: 'Workflow',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n code: parseString(resource.attributes['code']) || '',\n name: parseString(resource.attributes['name']) || '',\n description: parseString(resource.attributes['description']),\n steps: (resource.attributes['steps'] as WorkflowStep[]) || [],\n triggers: resource.attributes['triggers'] as WorkflowTrigger[] | undefined,\n status: parseStatus(resource.attributes['status']),\n enabled: parseBoolean(resource.attributes['enabled']),\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n }),\n};\n"],"names":["parseString","parseDate","parseBoolean","parseStatus","workflowMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","code","name","description","steps","triggers","status","enabled","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAEC,WAAW,QAAQ,UAAU;AAE5E,OAAO,MAAMC,iBAA2C;IACtDC,MAAM;IACNC,KAAK,CAACC,WAAc,CAAA;YAClBC,IAAID,SAASC,EAAE;YACfC,UAAUT,YAAYO,SAASG,UAAU,CAAC,YAAY,KAAKH,SAASC,EAAE;YACtEG,WAAWV,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAC/DC,WAAWZ,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAE/DE,MAAMd,YAAYO,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDK,MAAMf,YAAYO,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDM,aAAahB,YAAYO,SAASG,UAAU,CAAC,cAAc;YAC3DO,OAAO,AAACV,SAASG,UAAU,CAAC,QAAQ,IAAuB,EAAE;YAC7DQ,UAAUX,SAASG,UAAU,CAAC,WAAW;YACzCS,QAAQhB,YAAYI,SAASG,UAAU,CAAC,SAAS;YACjDU,SAASlB,aAAaK,SAASG,UAAU,CAAC,UAAU;YACpDW,SAASd,SAASG,UAAU,CAAC,UAAU;QACzC,CAAA;AACF,EAAE"}
@@ -1,94 +0,0 @@
1
- import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
2
- import { agentMapper } from '../mappers/agent.mapper';
3
- export function createAgentsService(transport, _config) {
4
- return {
5
- async list (params) {
6
- const queryParams = {};
7
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
8
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
9
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
10
- if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
11
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
12
- const response = await transport.get('/agents', {
13
- params: queryParams
14
- });
15
- return decodePageResult(response, agentMapper);
16
- },
17
- async get (uniqueId) {
18
- const response = await transport.get(`/agents/${uniqueId}`);
19
- return decodeOne(response, agentMapper);
20
- },
21
- async create (data) {
22
- const response = await transport.post('/agents', {
23
- data: {
24
- type: 'Agent',
25
- attributes: {
26
- code: data.code,
27
- name: data.name,
28
- description: data.description,
29
- system_prompt: data.systemPrompt,
30
- model: data.model,
31
- temperature: data.temperature,
32
- max_tokens: data.maxTokens,
33
- tools: data.tools,
34
- payload: data.payload
35
- }
36
- }
37
- });
38
- return decodeOne(response, agentMapper);
39
- },
40
- async update (uniqueId, data) {
41
- const response = await transport.put(`/agents/${uniqueId}`, {
42
- data: {
43
- type: 'Agent',
44
- attributes: {
45
- name: data.name,
46
- description: data.description,
47
- system_prompt: data.systemPrompt,
48
- model: data.model,
49
- temperature: data.temperature,
50
- max_tokens: data.maxTokens,
51
- tools: data.tools,
52
- enabled: data.enabled,
53
- status: data.status,
54
- payload: data.payload
55
- }
56
- }
57
- });
58
- return decodeOne(response, agentMapper);
59
- },
60
- async delete (uniqueId) {
61
- await transport.delete(`/agents/${uniqueId}`);
62
- },
63
- async chat (uniqueId, data) {
64
- const response = await transport.post(`/agents/${uniqueId}/chat`, {
65
- message: data.message,
66
- conversation_unique_id: data.conversationUniqueId,
67
- user_unique_id: data.userUniqueId,
68
- payload: data.payload
69
- });
70
- return {
71
- response: response.response,
72
- conversationUniqueId: response.conversation_unique_id,
73
- executionUniqueId: response.execution_unique_id,
74
- tokens: response.tokens,
75
- cost: response.cost
76
- };
77
- },
78
- async complete (uniqueId, data) {
79
- const response = await transport.post(`/agents/${uniqueId}/complete`, {
80
- input: data.input,
81
- payload: data.payload
82
- });
83
- return {
84
- output: response.output,
85
- executionUniqueId: response.execution_unique_id,
86
- tokens: response.tokens,
87
- cost: response.cost,
88
- duration: response.duration
89
- };
90
- }
91
- };
92
- }
93
-
94
- //# sourceMappingURL=agents.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/services/agents.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Agent,\n CreateAgentRequest,\n UpdateAgentRequest,\n ListAgentsParams,\n ChatRequest,\n ChatResponse,\n CompleteRequest,\n CompleteResponse,\n} from '../types/agent';\nimport { agentMapper } from '../mappers/agent.mapper';\n\nexport interface AgentsService {\n list(params?: ListAgentsParams): Promise<PageResult<Agent>>;\n get(uniqueId: string): Promise<Agent>;\n create(data: CreateAgentRequest): Promise<Agent>;\n update(uniqueId: string, data: UpdateAgentRequest): Promise<Agent>;\n delete(uniqueId: string): Promise<void>;\n chat(uniqueId: string, data: ChatRequest): Promise<ChatResponse>;\n complete(uniqueId: string, data: CompleteRequest): Promise<CompleteResponse>;\n}\n\nexport function createAgentsService(transport: Transport, _config: { appId: string }): AgentsService {\n return {\n async list(params?: ListAgentsParams): Promise<PageResult<Agent>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.search) queryParams['search'] = params.search;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/agents', { params: queryParams });\n return decodePageResult(response, agentMapper);\n },\n\n async get(uniqueId: string): Promise<Agent> {\n const response = await transport.get<unknown>(`/agents/${uniqueId}`);\n return decodeOne(response, agentMapper);\n },\n\n async create(data: CreateAgentRequest): Promise<Agent> {\n const response = await transport.post<unknown>('/agents', {\n data: {\n type: 'Agent',\n attributes: {\n code: data.code,\n name: data.name,\n description: data.description,\n system_prompt: data.systemPrompt,\n model: data.model,\n temperature: data.temperature,\n max_tokens: data.maxTokens,\n tools: data.tools,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, agentMapper);\n },\n\n async update(uniqueId: string, data: UpdateAgentRequest): Promise<Agent> {\n const response = await transport.put<unknown>(`/agents/${uniqueId}`, {\n data: {\n type: 'Agent',\n attributes: {\n name: data.name,\n description: data.description,\n system_prompt: data.systemPrompt,\n model: data.model,\n temperature: data.temperature,\n max_tokens: data.maxTokens,\n tools: data.tools,\n enabled: data.enabled,\n status: data.status,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, agentMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/agents/${uniqueId}`);\n },\n\n async chat(uniqueId: string, data: ChatRequest): Promise<ChatResponse> {\n const response = await transport.post<any>(`/agents/${uniqueId}/chat`, {\n message: data.message,\n conversation_unique_id: data.conversationUniqueId,\n user_unique_id: data.userUniqueId,\n payload: data.payload,\n });\n\n return {\n response: response.response,\n conversationUniqueId: response.conversation_unique_id,\n executionUniqueId: response.execution_unique_id,\n tokens: response.tokens,\n cost: response.cost,\n };\n },\n\n async complete(uniqueId: string, data: CompleteRequest): Promise<CompleteResponse> {\n const response = await transport.post<any>(`/agents/${uniqueId}/complete`, {\n input: data.input,\n payload: data.payload,\n });\n\n return {\n output: response.output,\n executionUniqueId: response.execution_unique_id,\n tokens: response.tokens,\n cost: response.cost,\n duration: response.duration,\n };\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","agentMapper","createAgentsService","transport","_config","list","params","queryParams","page","String","perPage","status","search","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","code","name","description","system_prompt","systemPrompt","model","temperature","max_tokens","maxTokens","tools","payload","update","put","enabled","delete","chat","message","conversation_unique_id","conversationUniqueId","user_unique_id","userUniqueId","executionUniqueId","execution_unique_id","tokens","cost","complete","input","output","duration"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,0BAA0B;AAWtE,SAASC,WAAW,QAAQ,0BAA0B;AAYtD,OAAO,SAASC,oBAAoBC,SAAoB,EAAEC,OAA0B;IAClF,OAAO;QACL,MAAMC,MAAKC,MAAyB;YAClC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YACnE,IAAIJ,0BAAAA,OAAQK,MAAM,EAAEJ,WAAW,CAAC,SAAS,GAAGD,OAAOK,MAAM;YACzD,IAAIL,0BAAAA,OAAQM,MAAM,EAAEL,WAAW,CAAC,SAAS,GAAGD,OAAOM,MAAM;YACzD,IAAIN,0BAAAA,OAAQO,MAAM,EAAEN,WAAW,CAAC,OAAO,GAAGD,OAAOQ,SAAS,KAAK,SAAS,CAAC,CAAC,EAAER,OAAOO,MAAM,CAAC,CAAC,GAAGP,OAAOO,MAAM;YAE3G,MAAME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B;YAC3B,MAAMd,UAAUkC,MAAM,CAAC,CAAC,QAAQ,EAAEpB,SAAS,CAAC;QAC9C;QAEA,MAAMqB,MAAKrB,QAAgB,EAAEE,IAAiB;YAC5C,MAAMJ,WAAW,MAAMZ,UAAUiB,IAAI,CAAM,CAAC,QAAQ,EAAEH,SAAS,KAAK,CAAC,EAAE;gBACrEsB,SAASpB,KAAKoB,OAAO;gBACrBC,wBAAwBrB,KAAKsB,oBAAoB;gBACjDC,gBAAgBvB,KAAKwB,YAAY;gBACjCV,SAASd,KAAKc,OAAO;YACvB;YAEA,OAAO;gBACLlB,UAAUA,SAASA,QAAQ;gBAC3B0B,sBAAsB1B,SAASyB,sBAAsB;gBACrDI,mBAAmB7B,SAAS8B,mBAAmB;gBAC/CC,QAAQ/B,SAAS+B,MAAM;gBACvBC,MAAMhC,SAASgC,IAAI;YACrB;QACF;QAEA,MAAMC,UAAS/B,QAAgB,EAAEE,IAAqB;YACpD,MAAMJ,WAAW,MAAMZ,UAAUiB,IAAI,CAAM,CAAC,QAAQ,EAAEH,SAAS,SAAS,CAAC,EAAE;gBACzEgC,OAAO9B,KAAK8B,KAAK;gBACjBhB,SAASd,KAAKc,OAAO;YACvB;YAEA,OAAO;gBACLiB,QAAQnC,SAASmC,MAAM;gBACvBN,mBAAmB7B,SAAS8B,mBAAmB;gBAC/CC,QAAQ/B,SAAS+B,MAAM;gBACvBC,MAAMhC,SAASgC,IAAI;gBACnBI,UAAUpC,SAASoC,QAAQ;YAC7B;QACF;IACF;AACF"}
@@ -1,79 +0,0 @@
1
- import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
2
- import { conversationMapper } from '../mappers/conversation.mapper';
3
- export function createConversationsService(transport, _config) {
4
- return {
5
- async list (params) {
6
- const queryParams = {};
7
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
8
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
9
- if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
10
- if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
11
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
12
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
13
- const response = await transport.get('/conversations', {
14
- params: queryParams
15
- });
16
- return decodePageResult(response, conversationMapper);
17
- },
18
- async get (uniqueId) {
19
- const response = await transport.get(`/conversations/${uniqueId}`);
20
- return decodeOne(response, conversationMapper);
21
- },
22
- async create (data) {
23
- const response = await transport.post('/conversations', {
24
- data: {
25
- type: 'Conversation',
26
- attributes: {
27
- agent_unique_id: data.agentUniqueId,
28
- user_unique_id: data.userUniqueId,
29
- title: data.title,
30
- payload: data.payload
31
- }
32
- }
33
- });
34
- return decodeOne(response, conversationMapper);
35
- },
36
- async sendMessage (uniqueId, data) {
37
- const response = await transport.post(`/conversations/${uniqueId}/messages`, {
38
- message: data.message,
39
- role: data.role,
40
- payload: data.payload
41
- });
42
- return {
43
- message: {
44
- role: response.message.role,
45
- content: response.message.content,
46
- timestamp: new Date(response.message.timestamp),
47
- payload: response.message.payload
48
- },
49
- response: response.response ? {
50
- role: response.response.role,
51
- content: response.response.content,
52
- timestamp: new Date(response.response.timestamp),
53
- payload: response.response.payload
54
- } : undefined,
55
- executionUniqueId: response.execution_unique_id,
56
- tokens: response.tokens,
57
- cost: response.cost
58
- };
59
- },
60
- async listByUser (userUniqueId, params) {
61
- const queryParams = {};
62
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
63
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
64
- if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
65
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
66
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
67
- const response = await transport.get(`/users/${userUniqueId}/conversations`, {
68
- params: queryParams
69
- });
70
- return decodePageResult(response, conversationMapper);
71
- },
72
- async clear (uniqueId) {
73
- const response = await transport.post(`/conversations/${uniqueId}/clear`, {});
74
- return decodeOne(response, conversationMapper);
75
- }
76
- };
77
- }
78
-
79
- //# sourceMappingURL=conversations.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/services/conversations.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Conversation,\n CreateConversationRequest,\n SendMessageRequest,\n SendMessageResponse,\n ListConversationsParams,\n} from '../types/conversation';\nimport { conversationMapper } from '../mappers/conversation.mapper';\n\nexport interface ConversationsService {\n list(params?: ListConversationsParams): Promise<PageResult<Conversation>>;\n get(uniqueId: string): Promise<Conversation>;\n create(data: CreateConversationRequest): Promise<Conversation>;\n sendMessage(uniqueId: string, data: SendMessageRequest): Promise<SendMessageResponse>;\n listByUser(userUniqueId: string, params?: ListConversationsParams): Promise<PageResult<Conversation>>;\n clear(uniqueId: string): Promise<Conversation>;\n}\n\nexport function createConversationsService(transport: Transport, _config: { appId: string }): ConversationsService {\n return {\n async list(params?: ListConversationsParams): Promise<PageResult<Conversation>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;\n if (params?.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/conversations', { params: queryParams });\n return decodePageResult(response, conversationMapper);\n },\n\n async get(uniqueId: string): Promise<Conversation> {\n const response = await transport.get<unknown>(`/conversations/${uniqueId}`);\n return decodeOne(response, conversationMapper);\n },\n\n async create(data: CreateConversationRequest): Promise<Conversation> {\n const response = await transport.post<unknown>('/conversations', {\n data: {\n type: 'Conversation',\n attributes: {\n agent_unique_id: data.agentUniqueId,\n user_unique_id: data.userUniqueId,\n title: data.title,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, conversationMapper);\n },\n\n async sendMessage(uniqueId: string, data: SendMessageRequest): Promise<SendMessageResponse> {\n const response = await transport.post<any>(`/conversations/${uniqueId}/messages`, {\n message: data.message,\n role: data.role,\n payload: data.payload,\n });\n\n return {\n message: {\n role: response.message.role,\n content: response.message.content,\n timestamp: new Date(response.message.timestamp),\n payload: response.message.payload,\n },\n response: response.response\n ? {\n role: response.response.role,\n content: response.response.content,\n timestamp: new Date(response.response.timestamp),\n payload: response.response.payload,\n }\n : undefined,\n executionUniqueId: response.execution_unique_id,\n tokens: response.tokens,\n cost: response.cost,\n };\n },\n\n async listByUser(userUniqueId: string, params?: ListConversationsParams): Promise<PageResult<Conversation>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/users/${userUniqueId}/conversations`, { params: queryParams });\n return decodePageResult(response, conversationMapper);\n },\n\n async clear(uniqueId: string): Promise<Conversation> {\n const response = await transport.post<unknown>(`/conversations/${uniqueId}/clear`, {});\n return decodeOne(response, conversationMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","conversationMapper","createConversationsService","transport","_config","list","params","queryParams","page","String","perPage","agentUniqueId","userUniqueId","status","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","agent_unique_id","user_unique_id","title","payload","sendMessage","message","role","content","timestamp","Date","undefined","executionUniqueId","execution_unique_id","tokens","cost","listByUser","clear"],"r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AAIJ,0BAAAA,OAAQK,aAAa,EAAEJ,WAAW,CAAC,kBAAkB,GAAGD,OAAOK,aAAa;YAChF,IAAIL,0BAAAA,OAAQO,MAAM,EAAEN,WAAW,CAAC,SAAS,GAAGD,OAAOO,MAAM;YACzD,IAAIP,0BAAAA,OAAQQ,MAAM,EAAEP,WAAW,CAAC,OAAO,GAAGD,OAAOS,SAAS,KAAK,SAAS,CAAC,CAAC,EAAET,OAAOQ,MAAM,CAAC,CAAC,GAAGR,OAAOQ,MAAM;YAE3G,MAAME,WAAW,MAAMb,UAAUc,GAAG,CAAU,CAAC,OAAO,EAAEL,aAAa,cAAc,CAAC,EAAE;gBAAEN,QAAQC;YAAY;YAC5G,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAMuC,OAAMtB,QAAgB;YAC1B,MAAMF,WAAW,MAAMb,UAAUkB,IAAI,CAAU,CAAC,eAAe,EAAEH,SAAS,MAAM,CAAC,EAAE,CAAC;YACpF,OAAOnB,UAAUiB,UAAUf;QAC7B;IACF;AACF"}
@@ -1,51 +0,0 @@
1
- import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
2
- import { executionMapper } from '../mappers/execution.mapper';
3
- export function createExecutionsService(transport, _config) {
4
- return {
5
- async list (params) {
6
- const queryParams = {};
7
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
8
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
9
- if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
10
- if (params == null ? void 0 : params.promptUniqueId) queryParams['prompt_unique_id'] = params.promptUniqueId;
11
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
12
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
13
- const response = await transport.get('/executions', {
14
- params: queryParams
15
- });
16
- return decodePageResult(response, executionMapper);
17
- },
18
- async get (uniqueId) {
19
- const response = await transport.get(`/executions/${uniqueId}`);
20
- return decodeOne(response, executionMapper);
21
- },
22
- async listByAgent (agentUniqueId, params) {
23
- const queryParams = {};
24
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
25
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
26
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
27
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
28
- const response = await transport.get(`/agents/${agentUniqueId}/executions`, {
29
- params: queryParams
30
- });
31
- return decodePageResult(response, executionMapper);
32
- },
33
- async listByPrompt (promptUniqueId, params) {
34
- const queryParams = {};
35
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
36
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
37
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
38
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
39
- const response = await transport.get(`/prompts/${promptUniqueId}/executions`, {
40
- params: queryParams
41
- });
42
- return decodePageResult(response, executionMapper);
43
- },
44
- async cancel (uniqueId) {
45
- const response = await transport.post(`/executions/${uniqueId}/cancel`, {});
46
- return decodeOne(response, executionMapper);
47
- }
48
- };
49
- }
50
-
51
- //# sourceMappingURL=executions.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/services/executions.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type { Execution, ListExecutionsParams } from '../types/execution';\nimport { executionMapper } from '../mappers/execution.mapper';\n\nexport interface ExecutionsService {\n list(params?: ListExecutionsParams): Promise<PageResult<Execution>>;\n get(uniqueId: string): Promise<Execution>;\n listByAgent(agentUniqueId: string, params?: ListExecutionsParams): Promise<PageResult<Execution>>;\n listByPrompt(promptUniqueId: string, params?: ListExecutionsParams): Promise<PageResult<Execution>>;\n cancel(uniqueId: string): Promise<Execution>;\n}\n\nexport function createExecutionsService(transport: Transport, _config: { appId: string }): ExecutionsService {\n return {\n async list(params?: ListExecutionsParams): Promise<PageResult<Execution>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;\n if (params?.promptUniqueId) queryParams['prompt_unique_id'] = params.promptUniqueId;\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/executions', { params: queryParams });\n return decodePageResult(response, executionMapper);\n },\n\n async get(uniqueId: string): Promise<Execution> {\n const response = await transport.get<unknown>(`/executions/${uniqueId}`);\n return decodeOne(response, executionMapper);\n },\n\n async listByAgent(agentUniqueId: string, params?: ListExecutionsParams): Promise<PageResult<Execution>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/agents/${agentUniqueId}/executions`, { params: queryParams });\n return decodePageResult(response, executionMapper);\n },\n\n async listByPrompt(promptUniqueId: string, params?: ListExecutionsParams): Promise<PageResult<Execution>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/prompts/${promptUniqueId}/executions`, { params: queryParams });\n return decodePageResult(response, executionMapper);\n },\n\n async cancel(uniqueId: string): Promise<Execution> {\n const response = await transport.post<unknown>(`/executions/${uniqueId}/cancel`, {});\n return decodeOne(response, executionMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","executionMapper","createExecutionsService","transport","_config","list","params","queryParams","page","String","perPage","agentUniqueId","promptUniqueId","status","sortBy","sortOrder","response","get","uniqueId","listByAgent","listByPrompt","cancel","post"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,0BAA0B;AAEtE,SAASC,eAAe,QAAQ,8BAA8B;AAU9D,OAAO,SAASC,wBAAwBC,SAAoB,EAAEC,OAA0B;IACtF,OAAO;QACL,MAAMC,MAAKC,MAA6B;YACtC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YACnE,IAAIJ,0BAAAA,OAAQK,aAAa,EAAEJ,WAAW,CAAC,kBAAkB,GAAGD,OAAOK,aAAa;YAChF,IAAIL,0BAAAA,OAAQM,cAAc,EAAEL,WAAW,CAAC,mBAAmB,GAAGD,OAAOM,cAAc;YACnF,IAAIN,0BAAAA,OAAQO,MAAM,EAAEN,WAAW,CAAC,SAAS,GAAGD,OAAOO,MAAM;YACzD,IAAIP,0BAAAA,OAAQQ,MAAM,EAAEP,WAAW,CAAC,OAAO,GAAGD,OAAOS,SAAS,KAAK,SAAS,CAAC,CAAC,EAAET,OAAOQ,MAAM,CAAC,CAAC,GAAGR,OAAOQ,MAAM;YAE3G,MAAME,WAAW,MAAMb,UAAUc,GAAG,CAAU,eAAe;gBAAEX,QAAQC;YAAY;YACnF,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAMgB,KAAIC,QAAgB;YACxB,MAAMF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G,MAAME,WAAW,MAAMb,UAAUc,GAAG,CAAU,CAAC,SAAS,EAAEL,eAAe,WAAW,CAAC,EAAE;gBAAEN,QAAQC;YAAY;YAC7G,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAMoB,QAAOH,QAAgB;YAC3B,MAAMF,WAAW,MAAMb,UAAUmB,IAAI,CAAU,CAAC,YAAY,EAAEJ,SAAS,OAAO,CAAC,EAAE,CAAC;YAClF,OAAOnB,UAAUiB,UAAUf;QAC7B;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/services/index.ts"],"sourcesContent":["export * from './agents.service';\nexport * from './prompts.service';\nexport * from './workflows.service';\nexport * from './executions.service';\nexport * from './conversations.service';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,0BAA0B"}
@@ -1,88 +0,0 @@
1
- import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
2
- import { promptMapper } from '../mappers/prompt.mapper';
3
- export function createPromptsService(transport, _config) {
4
- return {
5
- async list (params) {
6
- const queryParams = {};
7
- if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
8
- if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
9
- if (params == null ? void 0 : params.agentUniqueId) queryParams['agent_unique_id'] = params.agentUniqueId;
10
- if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
11
- if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
12
- if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
13
- const response = await transport.get('/prompts', {
14
- params: queryParams
15
- });
16
- return decodePageResult(response, promptMapper);
17
- },
18
- async get (uniqueId) {
19
- const response = await transport.get(`/prompts/${uniqueId}`);
20
- return decodeOne(response, promptMapper);
21
- },
22
- async create (data) {
23
- const response = await transport.post('/prompts', {
24
- data: {
25
- type: 'Prompt',
26
- attributes: {
27
- agent_unique_id: data.agentUniqueId,
28
- code: data.code,
29
- name: data.name,
30
- description: data.description,
31
- template: data.template,
32
- variables: data.variables,
33
- payload: data.payload
34
- }
35
- }
36
- });
37
- return decodeOne(response, promptMapper);
38
- },
39
- async update (uniqueId, data) {
40
- const response = await transport.put(`/prompts/${uniqueId}`, {
41
- data: {
42
- type: 'Prompt',
43
- attributes: {
44
- name: data.name,
45
- description: data.description,
46
- template: data.template,
47
- variables: data.variables,
48
- enabled: data.enabled,
49
- status: data.status,
50
- payload: data.payload
51
- }
52
- }
53
- });
54
- return decodeOne(response, promptMapper);
55
- },
56
- async delete (uniqueId) {
57
- await transport.delete(`/prompts/${uniqueId}`);
58
- },
59
- async execute (uniqueId, data) {
60
- const response = await transport.post(`/prompts/${uniqueId}/execute`, {
61
- agent_unique_id: data.agentUniqueId,
62
- variables: data.variables,
63
- payload: data.payload
64
- });
65
- return {
66
- output: response.output,
67
- executionUniqueId: response.execution_unique_id,
68
- tokens: response.tokens,
69
- cost: response.cost,
70
- duration: response.duration
71
- };
72
- },
73
- async test (data) {
74
- const response = await transport.post('/prompts/test', {
75
- template: data.template,
76
- variables: data.variables,
77
- agent_unique_id: data.agentUniqueId
78
- });
79
- return {
80
- renderedPrompt: response.rendered_prompt,
81
- isValid: response.is_valid,
82
- errors: response.errors
83
- };
84
- }
85
- };
86
- }
87
-
88
- //# sourceMappingURL=prompts.service.js.map