@23blocks/block-jarvis 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/jarvis.block.js +24 -0
- package/dist/lib/jarvis.block.js.map +1 -0
- package/dist/lib/mappers/agent.mapper.js +23 -0
- package/dist/lib/mappers/agent.mapper.js.map +1 -0
- package/dist/lib/mappers/conversation.mapper.js +29 -0
- package/dist/lib/mappers/conversation.mapper.js.map +1 -0
- package/dist/lib/mappers/execution.mapper.js +23 -0
- package/dist/lib/mappers/execution.mapper.js.map +1 -0
- package/dist/lib/mappers/index.js +8 -0
- package/dist/lib/mappers/index.js.map +1 -0
- package/dist/lib/mappers/prompt.mapper.js +22 -0
- package/dist/lib/mappers/prompt.mapper.js.map +1 -0
- package/dist/lib/mappers/utils.js +93 -0
- package/dist/lib/mappers/utils.js.map +1 -0
- package/dist/lib/mappers/workflow.mapper.js +20 -0
- package/dist/lib/mappers/workflow.mapper.js.map +1 -0
- package/dist/lib/services/agents.service.js +94 -0
- package/dist/lib/services/agents.service.js.map +1 -0
- package/dist/lib/services/conversations.service.js +79 -0
- package/dist/lib/services/conversations.service.js.map +1 -0
- package/dist/lib/services/executions.service.js +51 -0
- package/dist/lib/services/executions.service.js.map +1 -0
- package/dist/lib/services/index.js +7 -0
- package/dist/lib/services/index.js.map +1 -0
- package/dist/lib/services/prompts.service.js +88 -0
- package/dist/lib/services/prompts.service.js.map +1 -0
- package/dist/lib/services/workflows.service.js +79 -0
- package/dist/lib/services/workflows.service.js.map +1 -0
- package/dist/lib/types/agent.js +3 -0
- package/dist/lib/types/agent.js.map +1 -0
- package/dist/lib/types/conversation.js +3 -0
- package/dist/lib/types/conversation.js.map +1 -0
- package/dist/lib/types/execution.js +4 -0
- package/dist/lib/types/execution.js.map +1 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/prompt.js +3 -0
- package/dist/lib/types/prompt.js.map +1 -0
- package/dist/lib/types/workflow.js +3 -0
- package/dist/lib/types/workflow.js.map +1 -0
- package/package.json +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Block factory and metadata
|
|
2
|
+
export { createJarvisBlock, jarvisBlockMetadata } from './lib/jarvis.block';
|
|
3
|
+
export { createAgentsService, createPromptsService, createWorkflowsService, createExecutionsService, createConversationsService } from './lib/services';
|
|
4
|
+
// Mappers (for advanced use cases)
|
|
5
|
+
export { agentMapper, promptMapper, workflowMapper, executionMapper, conversationMapper } from './lib/mappers';
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Block factory and metadata\nexport { createJarvisBlock, jarvisBlockMetadata } from './lib/jarvis.block';\nexport type { JarvisBlock, JarvisBlockConfig } from './lib/jarvis.block';\n\n// Types\nexport type {\n // Agent types\n Agent,\n CreateAgentRequest,\n UpdateAgentRequest,\n ListAgentsParams,\n ChatRequest,\n ChatResponse,\n CompleteRequest,\n CompleteResponse,\n // Prompt types\n Prompt,\n CreatePromptRequest,\n UpdatePromptRequest,\n ListPromptsParams,\n ExecutePromptRequest,\n ExecutePromptResponse,\n TestPromptRequest,\n TestPromptResponse,\n // Workflow types\n Workflow,\n WorkflowStep,\n WorkflowTrigger,\n CreateWorkflowRequest,\n UpdateWorkflowRequest,\n ListWorkflowsParams,\n RunWorkflowRequest,\n RunWorkflowResponse,\n // Execution types\n Execution,\n ExecutionStatus,\n ListExecutionsParams,\n // Conversation types\n Conversation,\n ConversationMessage,\n CreateConversationRequest,\n SendMessageRequest,\n SendMessageResponse,\n ListConversationsParams,\n} from './lib/types';\n\n// Services\nexport type {\n AgentsService,\n PromptsService,\n WorkflowsService,\n ExecutionsService,\n ConversationsService,\n} from './lib/services';\n\nexport {\n createAgentsService,\n createPromptsService,\n createWorkflowsService,\n createExecutionsService,\n createConversationsService,\n} from './lib/services';\n\n// Mappers (for advanced use cases)\nexport {\n agentMapper,\n promptMapper,\n workflowMapper,\n executionMapper,\n conversationMapper,\n} from './lib/mappers';\n"],"names":["createJarvisBlock","jarvisBlockMetadata","createAgentsService","createPromptsService","createWorkflowsService","createExecutionsService","createConversationsService","agentMapper","promptMapper","workflowMapper","executionMapper","conversationMapper"],"rangeMappings":";;;;","mappings":"AAAA,6BAA6B;AAC7B,SAASA,iBAAiB,EAAEC,mBAAmB,QAAQ,qBAAqB;AAsD5E,SACEC,mBAAmB,EACnBC,oBAAoB,EACpBC,sBAAsB,EACtBC,uBAAuB,EACvBC,0BAA0B,QACrB,iBAAiB;AAExB,mCAAmC;AACnC,SACEC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,eAAe,EACfC,kBAAkB,QACb,gBAAgB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createAgentsService, createPromptsService, createWorkflowsService, createExecutionsService, createConversationsService } from './services';
|
|
2
|
+
export function createJarvisBlock(transport, config) {
|
|
3
|
+
return {
|
|
4
|
+
agents: createAgentsService(transport, config),
|
|
5
|
+
prompts: createPromptsService(transport, config),
|
|
6
|
+
workflows: createWorkflowsService(transport, config),
|
|
7
|
+
executions: createExecutionsService(transport, config),
|
|
8
|
+
conversations: createConversationsService(transport, config)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export const jarvisBlockMetadata = {
|
|
12
|
+
name: 'jarvis',
|
|
13
|
+
version: '0.1.0',
|
|
14
|
+
description: 'AI agents, prompts, workflows, executions, and conversation management',
|
|
15
|
+
resourceTypes: [
|
|
16
|
+
'Agent',
|
|
17
|
+
'Prompt',
|
|
18
|
+
'Workflow',
|
|
19
|
+
'Execution',
|
|
20
|
+
'Conversation'
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=jarvis.block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/jarvis.block.ts"],"sourcesContent":["import type { Transport, BlockConfig, BlockMetadata } from '@23blocks/contracts';\nimport {\n createAgentsService,\n createPromptsService,\n createWorkflowsService,\n createExecutionsService,\n createConversationsService,\n type AgentsService,\n type PromptsService,\n type WorkflowsService,\n type ExecutionsService,\n type ConversationsService,\n} from './services';\n\nexport interface JarvisBlockConfig extends BlockConfig {\n appId: string;\n tenantId?: string;\n}\n\nexport interface JarvisBlock {\n agents: AgentsService;\n prompts: PromptsService;\n workflows: WorkflowsService;\n executions: ExecutionsService;\n conversations: ConversationsService;\n}\n\nexport function createJarvisBlock(\n transport: Transport,\n config: JarvisBlockConfig\n): JarvisBlock {\n return {\n agents: createAgentsService(transport, config),\n prompts: createPromptsService(transport, config),\n workflows: createWorkflowsService(transport, config),\n executions: createExecutionsService(transport, config),\n conversations: createConversationsService(transport, config),\n };\n}\n\nexport const jarvisBlockMetadata: BlockMetadata = {\n name: 'jarvis',\n version: '0.1.0',\n description: 'AI agents, prompts, workflows, executions, and conversation management',\n resourceTypes: [\n 'Agent',\n 'Prompt',\n 'Workflow',\n 'Execution',\n 'Conversation',\n ],\n};\n"],"names":["createAgentsService","createPromptsService","createWorkflowsService","createExecutionsService","createConversationsService","createJarvisBlock","transport","config","agents","prompts","workflows","executions","conversations","jarvisBlockMetadata","name","version","description","resourceTypes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SACEA,mBAAmB,EACnBC,oBAAoB,EACpBC,sBAAsB,EACtBC,uBAAuB,EACvBC,0BAA0B,QAMrB,aAAa;AAepB,OAAO,SAASC,kBACdC,SAAoB,EACpBC,MAAyB;IAEzB,OAAO;QACLC,QAAQR,oBAAoBM,WAAWC;QACvCE,SAASR,qBAAqBK,WAAWC;QACzCG,WAAWR,uBAAuBI,WAAWC;QAC7CI,YAAYR,wBAAwBG,WAAWC;QAC/CK,eAAeR,2BAA2BE,WAAWC;IACvD;AACF;AAEA,OAAO,MAAMM,sBAAqC;IAChDC,MAAM;IACNC,SAAS;IACTC,aAAa;IACbC,eAAe;QACb;QACA;QACA;QACA;QACA;KACD;AACH,EAAE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';
|
|
2
|
+
export const agentMapper = {
|
|
3
|
+
type: 'Agent',
|
|
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
|
+
systemPrompt: parseString(resource.attributes['system_prompt']),
|
|
13
|
+
model: parseString(resource.attributes['model']),
|
|
14
|
+
temperature: parseOptionalNumber(resource.attributes['temperature']),
|
|
15
|
+
maxTokens: parseOptionalNumber(resource.attributes['max_tokens']),
|
|
16
|
+
tools: parseStringArray(resource.attributes['tools']),
|
|
17
|
+
status: parseStatus(resource.attributes['status']),
|
|
18
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
19
|
+
payload: resource.attributes['payload']
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=agent.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/agent.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Agent } from '../types/agent';\nimport { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';\n\nexport const agentMapper: ResourceMapper<Agent> = {\n type: 'Agent',\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 systemPrompt: parseString(resource.attributes['system_prompt']),\n model: parseString(resource.attributes['model']),\n temperature: parseOptionalNumber(resource.attributes['temperature']),\n maxTokens: parseOptionalNumber(resource.attributes['max_tokens']),\n tools: parseStringArray(resource.attributes['tools']),\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","agentMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","code","name","description","systemPrompt","model","temperature","maxTokens","tools","status","enabled","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,UAAU;AAEnH,OAAO,MAAMC,cAAqC;IAChDC,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,MAAMhB,YAAYS,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDK,MAAMjB,YAAYS,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDM,aAAalB,YAAYS,SAASG,UAAU,CAAC,cAAc;YAC3DO,cAAcnB,YAAYS,SAASG,UAAU,CAAC,gBAAgB;YAC9DQ,OAAOpB,YAAYS,SAASG,UAAU,CAAC,QAAQ;YAC/CS,aAAalB,oBAAoBM,SAASG,UAAU,CAAC,cAAc;YACnEU,WAAWnB,oBAAoBM,SAASG,UAAU,CAAC,aAAa;YAChEW,OAAOlB,iBAAiBI,SAASG,UAAU,CAAC,QAAQ;YACpDY,QAAQpB,YAAYK,SAASG,UAAU,CAAC,SAAS;YACjDa,SAASvB,aAAaO,SAASG,UAAU,CAAC,UAAU;YACpDc,SAASjB,SAASG,UAAU,CAAC,UAAU;QACzC,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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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;QACzC,OAAOA;IACT;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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,WAAW,MAAMZ,UAAUa,GAAG,CAAU,WAAW;gBAAEV,QAAQC;YAAY;YAC/E,OAAOP,iBAAiBe,UAAUd;QACpC;QAEA,MAAMe,KAAIC,QAAgB;YACxB,MAAMF,WAAW,MAAMZ,UAAUa,GAAG,CAAU,CAAC,QAAQ,EAAEC,SAAS,CAAC;YACn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,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"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,0BAA0B;AAQtE,SAASC,kBAAkB,QAAQ,iCAAiC;AAWpE,OAAO,SAASC,2BAA2BC,SAAoB,EAAEC,OAA0B;IACzF,OAAO;QACL,MAAMC,MAAKC,MAAgC;YACzC,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,YAAY,EAAEL,WAAW,CAAC,iBAAiB,GAAGD,OAAOM,YAAY;YAC7E,IAAIN,0BAAAA,OAAQO,MAAM,EAAEN,WAAW,CAAC,SAAS,GAAGD,OAAOO,MAAM;YACzD,IAAIP,0BAAAA,O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.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
|
|
@@ -0,0 +1 @@
|
|
|
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,SA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C7B;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/prompts.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Prompt,\n CreatePromptRequest,\n UpdatePromptRequest,\n ListPromptsParams,\n ExecutePromptRequest,\n ExecutePromptResponse,\n TestPromptRequest,\n TestPromptResponse,\n} from '../types/prompt';\nimport { promptMapper } from '../mappers/prompt.mapper';\n\nexport interface PromptsService {\n list(params?: ListPromptsParams): Promise<PageResult<Prompt>>;\n get(uniqueId: string): Promise<Prompt>;\n create(data: CreatePromptRequest): Promise<Prompt>;\n update(uniqueId: string, data: UpdatePromptRequest): Promise<Prompt>;\n delete(uniqueId: string): Promise<void>;\n execute(uniqueId: string, data: ExecutePromptRequest): Promise<ExecutePromptResponse>;\n test(data: TestPromptRequest): Promise<TestPromptResponse>;\n}\n\nexport function createPromptsService(transport: Transport, _config: { appId: string }): PromptsService {\n return {\n async list(params?: ListPromptsParams): Promise<PageResult<Prompt>> {\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?.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>('/prompts', { params: queryParams });\n return decodePageResult(response, promptMapper);\n },\n\n async get(uniqueId: string): Promise<Prompt> {\n const response = await transport.get<unknown>(`/prompts/${uniqueId}`);\n return decodeOne(response, promptMapper);\n },\n\n async create(data: CreatePromptRequest): Promise<Prompt> {\n const response = await transport.post<unknown>('/prompts', {\n data: {\n type: 'Prompt',\n attributes: {\n agent_unique_id: data.agentUniqueId,\n code: data.code,\n name: data.name,\n description: data.description,\n template: data.template,\n variables: data.variables,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, promptMapper);\n },\n\n async update(uniqueId: string, data: UpdatePromptRequest): Promise<Prompt> {\n const response = await transport.put<unknown>(`/prompts/${uniqueId}`, {\n data: {\n type: 'Prompt',\n attributes: {\n name: data.name,\n description: data.description,\n template: data.template,\n variables: data.variables,\n enabled: data.enabled,\n status: data.status,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, promptMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/prompts/${uniqueId}`);\n },\n\n async execute(uniqueId: string, data: ExecutePromptRequest): Promise<ExecutePromptResponse> {\n const response = await transport.post<any>(`/prompts/${uniqueId}/execute`, {\n agent_unique_id: data.agentUniqueId,\n variables: data.variables,\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 async test(data: TestPromptRequest): Promise<TestPromptResponse> {\n const response = await transport.post<any>('/prompts/test', {\n template: data.template,\n variables: data.variables,\n agent_unique_id: data.agentUniqueId,\n });\n\n return {\n renderedPrompt: response.rendered_prompt,\n isValid: response.is_valid,\n errors: response.errors,\n };\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","promptMapper","createPromptsService","transport","_config","list","params","queryParams","page","String","perPage","agentUniqueId","status","search","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","agent_unique_id","code","name","description","template","variables","payload","update","put","enabled","delete","execute","output","executionUniqueId","execution_unique_id","tokens","cost","duration","test","renderedPrompt","rendered_prompt","isValid","is_valid","errors"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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I,CAAM,iBAAiB;gBAC1DO,UAAUR,KAAKQ,QAAQ;gBACvBC,WAAWT,KAAKS,SAAS;gBACzBL,iBAAiBJ,KAAKT,aAAa;YACrC;YAEA,OAAO;gBACLgC,gBAAgB3B,SAAS4B,eAAe;gBACxCC,SAAS7B,SAAS8B,QAAQ;gBAC1BC,QAAQ/B,SAAS+B,MAAM;YACzB;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
|
|
2
|
+
import { workflowMapper } from '../mappers/workflow.mapper';
|
|
3
|
+
export function createWorkflowsService(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('/workflows', {
|
|
13
|
+
params: queryParams
|
|
14
|
+
});
|
|
15
|
+
return decodePageResult(response, workflowMapper);
|
|
16
|
+
},
|
|
17
|
+
async get (uniqueId) {
|
|
18
|
+
const response = await transport.get(`/workflows/${uniqueId}`);
|
|
19
|
+
return decodeOne(response, workflowMapper);
|
|
20
|
+
},
|
|
21
|
+
async create (data) {
|
|
22
|
+
const response = await transport.post('/workflows', {
|
|
23
|
+
data: {
|
|
24
|
+
type: 'Workflow',
|
|
25
|
+
attributes: {
|
|
26
|
+
code: data.code,
|
|
27
|
+
name: data.name,
|
|
28
|
+
description: data.description,
|
|
29
|
+
steps: data.steps,
|
|
30
|
+
triggers: data.triggers,
|
|
31
|
+
payload: data.payload
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return decodeOne(response, workflowMapper);
|
|
36
|
+
},
|
|
37
|
+
async update (uniqueId, data) {
|
|
38
|
+
const response = await transport.put(`/workflows/${uniqueId}`, {
|
|
39
|
+
data: {
|
|
40
|
+
type: 'Workflow',
|
|
41
|
+
attributes: {
|
|
42
|
+
name: data.name,
|
|
43
|
+
description: data.description,
|
|
44
|
+
steps: data.steps,
|
|
45
|
+
triggers: data.triggers,
|
|
46
|
+
enabled: data.enabled,
|
|
47
|
+
status: data.status,
|
|
48
|
+
payload: data.payload
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return decodeOne(response, workflowMapper);
|
|
53
|
+
},
|
|
54
|
+
async delete (uniqueId) {
|
|
55
|
+
await transport.delete(`/workflows/${uniqueId}`);
|
|
56
|
+
},
|
|
57
|
+
async run (uniqueId, data) {
|
|
58
|
+
const response = await transport.post(`/workflows/${uniqueId}/run`, {
|
|
59
|
+
input: data.input,
|
|
60
|
+
payload: data.payload
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
executionUniqueId: response.execution_unique_id,
|
|
64
|
+
status: response.status,
|
|
65
|
+
output: response.output
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
async pause (uniqueId) {
|
|
69
|
+
const response = await transport.post(`/workflows/${uniqueId}/pause`, {});
|
|
70
|
+
return decodeOne(response, workflowMapper);
|
|
71
|
+
},
|
|
72
|
+
async resume (uniqueId) {
|
|
73
|
+
const response = await transport.post(`/workflows/${uniqueId}/resume`, {});
|
|
74
|
+
return decodeOne(response, workflowMapper);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=workflows.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/workflows.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Workflow,\n CreateWorkflowRequest,\n UpdateWorkflowRequest,\n ListWorkflowsParams,\n RunWorkflowRequest,\n RunWorkflowResponse,\n} from '../types/workflow';\nimport { workflowMapper } from '../mappers/workflow.mapper';\n\nexport interface WorkflowsService {\n list(params?: ListWorkflowsParams): Promise<PageResult<Workflow>>;\n get(uniqueId: string): Promise<Workflow>;\n create(data: CreateWorkflowRequest): Promise<Workflow>;\n update(uniqueId: string, data: UpdateWorkflowRequest): Promise<Workflow>;\n delete(uniqueId: string): Promise<void>;\n run(uniqueId: string, data: RunWorkflowRequest): Promise<RunWorkflowResponse>;\n pause(uniqueId: string): Promise<Workflow>;\n resume(uniqueId: string): Promise<Workflow>;\n}\n\nexport function createWorkflowsService(transport: Transport, _config: { appId: string }): WorkflowsService {\n return {\n async list(params?: ListWorkflowsParams): Promise<PageResult<Workflow>> {\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>('/workflows', { params: queryParams });\n return decodePageResult(response, workflowMapper);\n },\n\n async get(uniqueId: string): Promise<Workflow> {\n const response = await transport.get<unknown>(`/workflows/${uniqueId}`);\n return decodeOne(response, workflowMapper);\n },\n\n async create(data: CreateWorkflowRequest): Promise<Workflow> {\n const response = await transport.post<unknown>('/workflows', {\n data: {\n type: 'Workflow',\n attributes: {\n code: data.code,\n name: data.name,\n description: data.description,\n steps: data.steps,\n triggers: data.triggers,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, workflowMapper);\n },\n\n async update(uniqueId: string, data: UpdateWorkflowRequest): Promise<Workflow> {\n const response = await transport.put<unknown>(`/workflows/${uniqueId}`, {\n data: {\n type: 'Workflow',\n attributes: {\n name: data.name,\n description: data.description,\n steps: data.steps,\n triggers: data.triggers,\n enabled: data.enabled,\n status: data.status,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, workflowMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/workflows/${uniqueId}`);\n },\n\n async run(uniqueId: string, data: RunWorkflowRequest): Promise<RunWorkflowResponse> {\n const response = await transport.post<any>(`/workflows/${uniqueId}/run`, {\n input: data.input,\n payload: data.payload,\n });\n\n return {\n executionUniqueId: response.execution_unique_id,\n status: response.status,\n output: response.output,\n };\n },\n\n async pause(uniqueId: string): Promise<Workflow> {\n const response = await transport.post<unknown>(`/workflows/${uniqueId}/pause`, {});\n return decodeOne(response, workflowMapper);\n },\n\n async resume(uniqueId: string): Promise<Workflow> {\n const response = await transport.post<unknown>(`/workflows/${uniqueId}/resume`, {});\n return decodeOne(response, workflowMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","workflowMapper","createWorkflowsService","transport","_config","list","params","queryParams","page","String","perPage","status","search","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","code","name","description","steps","triggers","payload","update","put","enabled","delete","run","input","executionUniqueId","execution_unique_id","output","pause","resume"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,0BAA0B;AAStE,SAASC,cAAc,QAAQ,6BAA6B;AAa5D,OAAO,SAASC,uBAAuBC,SAAoB,EAAEC,OAA0B;IACrF,OAAO;QACL,MAAMC,MAAKC,MAA4B;YACrC,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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AASZ,KAAKY,OAAO;wBACrBpB,QAAQQ,KAAKR,MAAM;wBACnBiB,SAAST,KAAKS,OAAO;oBACvB;gBACF;YACF;YACA,OAAO7B,UAAUgB,UAAUd;QAC7B;QAEA,MAAM+B,QAAOf,QAAgB;YAC3B,MAAMd,UAAU6B,MAAM,CAAC,CAAC,WAAW,EAAEf,SAAS,CAAC;QACjD;QAEA,MAAMgB,KAAIhB,QAAgB,EAAEE,IAAwB;YAClD,MAAMJ,WAAW,MAAMZ,UAAUiB,IAAI,CAAM,CAAC,WAAW,EAAEH,SAAS,IAAI,CAAC,EAAE;gBACvEiB,OAAOf,KAAKe,KAAK;gBACjBN,SAAST,KAAKS,OAAO;YACvB;YAEA,OAAO;gBACLO,mBAAmBpB,SAASqB,mBAAmB;gBAC/CzB,QAAQI,SAASJ,MAAM;gBACvB0B,QAAQtB,SAASsB,MAAM;YACzB;QACF;QAEA,MAAMC,OAAMrB,QAAgB;YAC1B,MAAMF,WAAW,MAAMZ,UAAUiB,IAAI,CAAU,CAAC,WAAW,EAAEH,SAAS,MAAM,CAAC,EAAE,CAAC;YAChF,OAAOlB,UAAUgB,UAAUd;QAC7B;QAEA,MAAMsC,QAAOtB,QAAgB;YAC3B,MAAMF,WAAW,MAAMZ,UAAUiB,IAAI,CAAU,CAAC,WAAW,EAAEH,SAAS,OAAO,CAAC,EAAE,CAAC;YACjF,OAAOlB,UAAUgB,UAAUd;QAC7B;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/agent.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface Agent extends IdentityCore {\n code: string;\n name: string;\n description?: string;\n systemPrompt?: string;\n model?: string;\n temperature?: number;\n maxTokens?: number;\n tools?: string[];\n status: EntityStatus;\n enabled: boolean;\n payload?: Record<string, unknown>;\n}\n\n// Request types\nexport interface CreateAgentRequest {\n code: string;\n name: string;\n description?: string;\n systemPrompt?: string;\n model?: string;\n temperature?: number;\n maxTokens?: number;\n tools?: string[];\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdateAgentRequest {\n name?: string;\n description?: string;\n systemPrompt?: string;\n model?: string;\n temperature?: number;\n maxTokens?: number;\n tools?: string[];\n enabled?: boolean;\n status?: EntityStatus;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListAgentsParams {\n page?: number;\n perPage?: number;\n status?: EntityStatus;\n search?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n\nexport interface ChatRequest {\n message: string;\n conversationUniqueId?: string;\n userUniqueId?: string;\n payload?: Record<string, unknown>;\n}\n\nexport interface ChatResponse {\n response: string;\n conversationUniqueId: string;\n executionUniqueId?: string;\n tokens?: number;\n cost?: number;\n}\n\nexport interface CompleteRequest {\n input: string;\n payload?: Record<string, unknown>;\n}\n\nexport interface CompleteResponse {\n output: string;\n executionUniqueId?: string;\n tokens?: number;\n cost?: number;\n duration?: number;\n}\n"],"names":[],"rangeMappings":"","mappings":"AAuEA,WAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/conversation.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface ConversationMessage {\n role: 'user' | 'assistant' | 'system';\n content: string;\n timestamp: Date;\n payload?: Record<string, unknown>;\n}\n\nexport interface Conversation extends IdentityCore {\n agentUniqueId?: string;\n userUniqueId?: string;\n title?: string;\n messages: ConversationMessage[];\n status: EntityStatus;\n payload?: Record<string, unknown>;\n}\n\n// Request types\nexport interface CreateConversationRequest {\n agentUniqueId?: string;\n userUniqueId?: string;\n title?: string;\n payload?: Record<string, unknown>;\n}\n\nexport interface SendMessageRequest {\n message: string;\n role?: 'user' | 'assistant' | 'system';\n payload?: Record<string, unknown>;\n}\n\nexport interface SendMessageResponse {\n message: ConversationMessage;\n response?: ConversationMessage;\n executionUniqueId?: string;\n tokens?: number;\n cost?: number;\n}\n\nexport interface ListConversationsParams {\n page?: number;\n perPage?: number;\n agentUniqueId?: string;\n userUniqueId?: string;\n status?: EntityStatus;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n"],"names":[],"rangeMappings":"","mappings":"AAwCA,WAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/execution.ts"],"sourcesContent":["import type { IdentityCore } from '@23blocks/contracts';\n\nexport type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed';\n\nexport interface Execution extends IdentityCore {\n agentUniqueId?: string;\n promptUniqueId?: string;\n input?: string;\n output?: string;\n tokens?: number;\n cost?: number;\n duration?: number;\n status: ExecutionStatus;\n startedAt?: Date;\n completedAt?: Date;\n payload?: Record<string, unknown>;\n}\n\n// Request types\nexport interface ListExecutionsParams {\n page?: number;\n perPage?: number;\n agentUniqueId?: string;\n promptUniqueId?: string;\n status?: ExecutionStatus;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n"],"names":[],"rangeMappings":";","mappings":"AAkBA,gBAAgB;AAChB,WAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/index.ts"],"sourcesContent":["export * from './agent';\nexport * from './prompt';\nexport * from './workflow';\nexport * from './execution';\nexport * from './conversation';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/prompt.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface Prompt extends IdentityCore {\n agentUniqueId?: string;\n code: string;\n name: string;\n description?: string;\n template: string;\n variables?: string[];\n version?: number;\n status: EntityStatus;\n enabled: boolean;\n payload?: Record<string, unknown>;\n}\n\n// Request types\nexport interface CreatePromptRequest {\n agentUniqueId?: string;\n code: string;\n name: string;\n description?: string;\n template: string;\n variables?: string[];\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdatePromptRequest {\n name?: string;\n description?: string;\n template?: string;\n variables?: string[];\n enabled?: boolean;\n status?: EntityStatus;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListPromptsParams {\n page?: number;\n perPage?: number;\n agentUniqueId?: string;\n status?: EntityStatus;\n search?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n\nexport interface ExecutePromptRequest {\n agentUniqueId?: string;\n variables?: Record<string, string>;\n payload?: Record<string, unknown>;\n}\n\nexport interface ExecutePromptResponse {\n output: string;\n executionUniqueId?: string;\n tokens?: number;\n cost?: number;\n duration?: number;\n}\n\nexport interface TestPromptRequest {\n template: string;\n variables?: Record<string, string>;\n agentUniqueId?: string;\n}\n\nexport interface TestPromptResponse {\n renderedPrompt: string;\n isValid: boolean;\n errors?: string[];\n}\n"],"names":[],"rangeMappings":"","mappings":"AAkEA,WAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/workflow.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface WorkflowStep {\n id: string;\n type: string;\n name: string;\n config?: Record<string, unknown>;\n nextSteps?: string[];\n}\n\nexport interface WorkflowTrigger {\n type: string;\n config?: Record<string, unknown>;\n}\n\nexport interface Workflow extends IdentityCore {\n code: string;\n name: string;\n description?: string;\n steps: WorkflowStep[];\n triggers?: WorkflowTrigger[];\n status: EntityStatus;\n enabled: boolean;\n payload?: Record<string, unknown>;\n}\n\n// Request types\nexport interface CreateWorkflowRequest {\n code: string;\n name: string;\n description?: string;\n steps: WorkflowStep[];\n triggers?: WorkflowTrigger[];\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdateWorkflowRequest {\n name?: string;\n description?: string;\n steps?: WorkflowStep[];\n triggers?: WorkflowTrigger[];\n enabled?: boolean;\n status?: EntityStatus;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListWorkflowsParams {\n page?: number;\n perPage?: number;\n status?: EntityStatus;\n search?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n\nexport interface RunWorkflowRequest {\n input?: Record<string, unknown>;\n payload?: Record<string, unknown>;\n}\n\nexport interface RunWorkflowResponse {\n executionUniqueId: string;\n status: 'pending' | 'running' | 'completed' | 'failed';\n output?: Record<string, unknown>;\n}\n"],"names":[],"rangeMappings":"","mappings":"AA4DA,WAIC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@23blocks/block-jarvis",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Jarvis AI block for 23blocks SDK - agents, prompts, workflows, executions, conversations",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "23blocks <hello@23blocks.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/23blocks-OS/frontend-sdk.git",
|
|
10
|
+
"directory": "packages/block-jarvis"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/23blocks-OS/frontend-sdk/tree/main/packages/block-jarvis",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/23blocks-OS/frontend-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"23blocks",
|
|
18
|
+
"sdk",
|
|
19
|
+
"jarvis",
|
|
20
|
+
"ai",
|
|
21
|
+
"agent",
|
|
22
|
+
"prompt",
|
|
23
|
+
"workflow",
|
|
24
|
+
"llm",
|
|
25
|
+
"conversation"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
"./package.json": "./package.json",
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"!**/*.tsbuildinfo"
|
|
42
|
+
],
|
|
43
|
+
"nx": {
|
|
44
|
+
"sourceRoot": "packages/block-jarvis/src",
|
|
45
|
+
"targets": {
|
|
46
|
+
"build": {
|
|
47
|
+
"executor": "@nx/js:swc",
|
|
48
|
+
"outputs": [
|
|
49
|
+
"{options.outputPath}"
|
|
50
|
+
],
|
|
51
|
+
"options": {
|
|
52
|
+
"outputPath": "packages/block-jarvis/dist",
|
|
53
|
+
"main": "packages/block-jarvis/src/index.ts",
|
|
54
|
+
"tsConfig": "packages/block-jarvis/tsconfig.lib.json",
|
|
55
|
+
"skipTypeCheck": true,
|
|
56
|
+
"stripLeadingPaths": true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@23blocks/contracts": "*",
|
|
63
|
+
"@23blocks/jsonapi-codec": "*",
|
|
64
|
+
"@swc/helpers": "~0.5.11"
|
|
65
|
+
}
|
|
66
|
+
}
|