@lssm/example.agent-console 0.0.0-canary-20251215234340 → 0.0.0-canary-20251216024228
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/.turbo/turbo-build.log +38 -28
- package/CHANGELOG.md +6 -6
- package/dist/agent/agent.contracts.js +1 -0
- package/dist/{entities/agent.js → agent/agent.entity.js} +1 -1
- package/dist/agent/agent.enum.js +1 -0
- package/dist/agent/agent.event.js +1 -0
- package/dist/agent/agent.handler.js +1 -0
- package/dist/agent/agent.presentation.js +1 -0
- package/dist/agent/agent.schema.js +1 -0
- package/dist/agent/index.js +1 -0
- package/dist/handlers/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/presentations/index.js +1 -1
- package/dist/run/index.js +1 -0
- package/dist/run/run.contracts.js +1 -0
- package/dist/run/run.entity.js +1 -0
- package/dist/run/run.enum.js +1 -0
- package/dist/run/run.event.js +1 -0
- package/dist/run/run.handler.js +1 -0
- package/dist/run/run.presentation.js +1 -0
- package/dist/run/run.schema.js +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/mock-agents.js +1 -0
- package/dist/shared/mock-runs.js +1 -0
- package/dist/shared/mock-tools.js +1 -0
- package/dist/tool/index.js +1 -0
- package/dist/tool/tool.contracts.js +1 -0
- package/dist/tool/tool.entity.js +1 -0
- package/dist/tool/tool.enum.js +1 -0
- package/dist/tool/tool.event.js +1 -0
- package/dist/tool/tool.handler.js +1 -0
- package/dist/tool/tool.presentation.js +1 -0
- package/dist/tool/tool.schema.js +1 -0
- package/package.json +59 -39
- package/src/agent/agent.contracts.ts +275 -0
- package/src/agent/agent.entity.ts +84 -0
- package/src/agent/agent.enum.ts +31 -0
- package/src/agent/agent.event.ts +109 -0
- package/src/{handlers/agent.handlers.ts → agent/agent.handler.ts} +23 -78
- package/src/{presentations/agent-list.ts → agent/agent.presentation.ts} +26 -14
- package/src/agent/agent.schema.ts +147 -0
- package/src/agent/index.ts +65 -0
- package/src/handlers/index.ts +17 -44
- package/src/index.ts +6 -15
- package/src/presentations/index.ts +13 -34
- package/src/run/index.ts +65 -0
- package/src/run/run.contracts.ts +266 -0
- package/src/run/run.entity.ts +126 -0
- package/src/run/run.enum.ts +45 -0
- package/src/run/run.event.ts +211 -0
- package/src/run/run.handler.ts +103 -0
- package/src/run/run.presentation.ts +47 -0
- package/src/run/run.schema.ts +139 -0
- package/src/shared/index.ts +6 -0
- package/src/shared/mock-agents.ts +83 -0
- package/src/shared/mock-runs.ts +108 -0
- package/src/shared/mock-tools.ts +146 -0
- package/src/tool/index.ts +35 -0
- package/src/tool/tool.contracts.ts +180 -0
- package/src/tool/tool.entity.ts +66 -0
- package/src/tool/tool.enum.ts +34 -0
- package/src/tool/tool.event.ts +84 -0
- package/src/tool/tool.handler.ts +107 -0
- package/src/{presentations/tool-registry.ts → tool/tool.presentation.ts} +12 -17
- package/src/tool/tool.schema.ts +134 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/contracts/agent.js +0 -1
- package/dist/contracts/index.js +0 -1
- package/dist/contracts/run.js +0 -1
- package/dist/contracts/tool.js +0 -1
- package/dist/entities/index.js +0 -1
- package/dist/entities/log.js +0 -1
- package/dist/entities/run.js +0 -1
- package/dist/entities/tool.js +0 -1
- package/dist/events.js +0 -1
- package/dist/handlers/agent.handlers.js +0 -1
- package/dist/handlers/mock-data.js +0 -1
- package/dist/handlers/run.handlers.js +0 -1
- package/dist/handlers/tool.handlers.js +0 -1
- package/dist/presentations/agent-list.js +0 -1
- package/dist/presentations/dashboard.js +0 -1
- package/dist/presentations/run-list.js +0 -1
- package/dist/presentations/tool-registry.js +0 -1
- package/src/contracts/agent.ts +0 -501
- package/src/contracts/index.ts +0 -29
- package/src/contracts/run.ts +0 -561
- package/src/contracts/tool.ts +0 -392
- package/src/entities/agent.ts +0 -151
- package/src/entities/index.ts +0 -20
- package/src/entities/log.ts +0 -76
- package/src/entities/run.ts +0 -240
- package/src/entities/tool.ts +0 -105
- package/src/events.ts +0 -419
- package/src/handlers/mock-data.ts +0 -413
- package/src/handlers/run.handlers.ts +0 -331
- package/src/handlers/tool.handlers.ts +0 -188
- package/src/presentations/dashboard.ts +0 -29
- package/src/presentations/run-list.ts +0 -76
- /package/dist/{feature.js → agent.feature.js} +0 -0
- /package/src/{feature.ts → agent.feature.ts} +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { defineCommand, defineQuery } from '@lssm/lib.contracts/spec';
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
|
|
3
|
+
import { AgentStatusEnum, ModelProviderEnum } from './agent.enum';
|
|
4
|
+
import {
|
|
5
|
+
AgentSummaryModel,
|
|
6
|
+
AgentWithToolsModel,
|
|
7
|
+
CreateAgentInputModel,
|
|
8
|
+
UpdateAgentInputModel,
|
|
9
|
+
} from './agent.schema';
|
|
10
|
+
import { AgentCreatedEvent } from './agent.event';
|
|
11
|
+
|
|
12
|
+
const OWNERS = ['@agent-console-team'] as const;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* CreateAgentCommand - Creates a new agent configuration.
|
|
16
|
+
*/
|
|
17
|
+
export const CreateAgentCommand = defineCommand({
|
|
18
|
+
meta: {
|
|
19
|
+
name: 'agent.agent.create',
|
|
20
|
+
version: 1,
|
|
21
|
+
stability: 'stable',
|
|
22
|
+
owners: [...OWNERS],
|
|
23
|
+
tags: ['agent', 'create'],
|
|
24
|
+
description: 'Creates a new AI agent configuration.',
|
|
25
|
+
goal: 'Allow users to define new AI agents with specific models and tools.',
|
|
26
|
+
context: 'Called from the agent builder UI when creating a new agent.',
|
|
27
|
+
},
|
|
28
|
+
io: {
|
|
29
|
+
input: CreateAgentInputModel,
|
|
30
|
+
output: defineSchemaModel({
|
|
31
|
+
name: 'CreateAgentOutput',
|
|
32
|
+
fields: {
|
|
33
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
34
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
35
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
36
|
+
status: { type: AgentStatusEnum, isOptional: false },
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
errors: {
|
|
40
|
+
SLUG_EXISTS: {
|
|
41
|
+
description:
|
|
42
|
+
'An agent with this slug already exists in the organization',
|
|
43
|
+
http: 409,
|
|
44
|
+
gqlCode: 'SLUG_EXISTS',
|
|
45
|
+
when: 'Slug is already taken',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
policy: { auth: 'user' },
|
|
50
|
+
sideEffects: {
|
|
51
|
+
emits: [
|
|
52
|
+
{
|
|
53
|
+
// name: 'agent.created',
|
|
54
|
+
// version: 1,
|
|
55
|
+
// payload: AgentSummaryModel,
|
|
56
|
+
ref: AgentCreatedEvent,
|
|
57
|
+
when: 'Agent is successfully created',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
audit: ['agent.created'],
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* UpdateAgentCommand - Updates an existing agent.
|
|
66
|
+
*/
|
|
67
|
+
export const UpdateAgentCommand = defineCommand({
|
|
68
|
+
meta: {
|
|
69
|
+
name: 'agent.agent.update',
|
|
70
|
+
version: 1,
|
|
71
|
+
stability: 'stable',
|
|
72
|
+
owners: [...OWNERS],
|
|
73
|
+
tags: ['agent', 'update'],
|
|
74
|
+
description: 'Updates an existing AI agent configuration.',
|
|
75
|
+
goal: 'Allow users to modify agent settings and configuration.',
|
|
76
|
+
context: 'Called from the agent settings UI.',
|
|
77
|
+
},
|
|
78
|
+
io: {
|
|
79
|
+
input: UpdateAgentInputModel,
|
|
80
|
+
output: defineSchemaModel({
|
|
81
|
+
name: 'UpdateAgentOutput',
|
|
82
|
+
fields: {
|
|
83
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
84
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
85
|
+
status: { type: AgentStatusEnum, isOptional: false },
|
|
86
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
errors: {
|
|
90
|
+
AGENT_NOT_FOUND: {
|
|
91
|
+
description: 'The specified agent does not exist',
|
|
92
|
+
http: 404,
|
|
93
|
+
gqlCode: 'AGENT_NOT_FOUND',
|
|
94
|
+
when: 'Agent ID is invalid',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
policy: { auth: 'user' },
|
|
99
|
+
sideEffects: {
|
|
100
|
+
emits: [
|
|
101
|
+
{
|
|
102
|
+
name: 'agent.updated',
|
|
103
|
+
version: 1,
|
|
104
|
+
when: 'Agent is updated',
|
|
105
|
+
payload: AgentSummaryModel,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
audit: ['agent.updated'],
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* GetAgentQuery - Retrieves an agent by ID.
|
|
114
|
+
*/
|
|
115
|
+
export const GetAgentQuery = defineQuery({
|
|
116
|
+
meta: {
|
|
117
|
+
name: 'agent.agent.get',
|
|
118
|
+
version: 1,
|
|
119
|
+
stability: 'stable',
|
|
120
|
+
owners: [...OWNERS],
|
|
121
|
+
tags: ['agent', 'get'],
|
|
122
|
+
description: 'Retrieves an agent by its ID.',
|
|
123
|
+
goal: 'View detailed agent configuration.',
|
|
124
|
+
context: 'Called when viewing agent details or editing.',
|
|
125
|
+
},
|
|
126
|
+
io: {
|
|
127
|
+
input: defineSchemaModel({
|
|
128
|
+
name: 'GetAgentInput',
|
|
129
|
+
fields: {
|
|
130
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
131
|
+
includeTools: { type: ScalarTypeEnum.Boolean(), isOptional: true },
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
output: AgentWithToolsModel,
|
|
135
|
+
errors: {
|
|
136
|
+
AGENT_NOT_FOUND: {
|
|
137
|
+
description: 'The specified agent does not exist',
|
|
138
|
+
http: 404,
|
|
139
|
+
gqlCode: 'AGENT_NOT_FOUND',
|
|
140
|
+
when: 'Agent ID is invalid',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
policy: { auth: 'user' },
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* ListAgentsQuery - Lists agents for an organization.
|
|
149
|
+
*/
|
|
150
|
+
export const ListAgentsQuery = defineQuery({
|
|
151
|
+
meta: {
|
|
152
|
+
name: 'agent.agent.list',
|
|
153
|
+
version: 1,
|
|
154
|
+
stability: 'stable',
|
|
155
|
+
owners: [...OWNERS],
|
|
156
|
+
tags: ['agent', 'list'],
|
|
157
|
+
description: 'Lists agents for an organization with optional filtering.',
|
|
158
|
+
goal: 'Browse and search available agents.',
|
|
159
|
+
context: 'Agent list/dashboard view.',
|
|
160
|
+
},
|
|
161
|
+
io: {
|
|
162
|
+
input: defineSchemaModel({
|
|
163
|
+
name: 'ListAgentsInput',
|
|
164
|
+
fields: {
|
|
165
|
+
organizationId: {
|
|
166
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
167
|
+
isOptional: false,
|
|
168
|
+
},
|
|
169
|
+
status: { type: AgentStatusEnum, isOptional: true },
|
|
170
|
+
modelProvider: { type: ModelProviderEnum, isOptional: true },
|
|
171
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
172
|
+
limit: {
|
|
173
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
174
|
+
isOptional: true,
|
|
175
|
+
defaultValue: 20,
|
|
176
|
+
},
|
|
177
|
+
offset: {
|
|
178
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
179
|
+
isOptional: true,
|
|
180
|
+
defaultValue: 0,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
output: defineSchemaModel({
|
|
185
|
+
name: 'ListAgentsOutput',
|
|
186
|
+
fields: {
|
|
187
|
+
items: { type: AgentSummaryModel, isArray: true, isOptional: false },
|
|
188
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
189
|
+
hasMore: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
},
|
|
193
|
+
policy: { auth: 'user' },
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* AssignToolToAgentCommand - Assigns a tool to an agent.
|
|
198
|
+
*/
|
|
199
|
+
export const AssignToolToAgentCommand = defineCommand({
|
|
200
|
+
meta: {
|
|
201
|
+
name: 'agent.agent.assignTool',
|
|
202
|
+
version: 1,
|
|
203
|
+
stability: 'stable',
|
|
204
|
+
owners: [...OWNERS],
|
|
205
|
+
tags: ['agent', 'tool', 'assign'],
|
|
206
|
+
description: 'Assigns a tool to an agent with optional configuration.',
|
|
207
|
+
goal: 'Enable agents to use specific tools.',
|
|
208
|
+
context: 'Agent configuration UI - tool selection.',
|
|
209
|
+
},
|
|
210
|
+
io: {
|
|
211
|
+
input: defineSchemaModel({
|
|
212
|
+
name: 'AssignToolToAgentInput',
|
|
213
|
+
fields: {
|
|
214
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
215
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
216
|
+
config: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
217
|
+
order: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
218
|
+
},
|
|
219
|
+
}),
|
|
220
|
+
output: defineSchemaModel({
|
|
221
|
+
name: 'AssignToolToAgentOutput',
|
|
222
|
+
fields: {
|
|
223
|
+
agentToolId: {
|
|
224
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
225
|
+
isOptional: false,
|
|
226
|
+
},
|
|
227
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
228
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
229
|
+
},
|
|
230
|
+
}),
|
|
231
|
+
errors: {
|
|
232
|
+
TOOL_ALREADY_ASSIGNED: {
|
|
233
|
+
description: 'This tool is already assigned to the agent',
|
|
234
|
+
http: 409,
|
|
235
|
+
gqlCode: 'TOOL_ALREADY_ASSIGNED',
|
|
236
|
+
when: 'Tool assignment already exists',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
policy: { auth: 'user' },
|
|
241
|
+
sideEffects: { audit: ['agent.tool.assigned'] },
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* RemoveToolFromAgentCommand - Removes a tool from an agent.
|
|
246
|
+
*/
|
|
247
|
+
export const RemoveToolFromAgentCommand = defineCommand({
|
|
248
|
+
meta: {
|
|
249
|
+
name: 'agent.agent.removeTool',
|
|
250
|
+
version: 1,
|
|
251
|
+
stability: 'stable',
|
|
252
|
+
owners: [...OWNERS],
|
|
253
|
+
tags: ['agent', 'tool', 'remove'],
|
|
254
|
+
description: 'Removes a tool assignment from an agent.',
|
|
255
|
+
goal: 'Disable specific tools for an agent.',
|
|
256
|
+
context: 'Agent configuration UI - tool management.',
|
|
257
|
+
},
|
|
258
|
+
io: {
|
|
259
|
+
input: defineSchemaModel({
|
|
260
|
+
name: 'RemoveToolFromAgentInput',
|
|
261
|
+
fields: {
|
|
262
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
263
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
264
|
+
},
|
|
265
|
+
}),
|
|
266
|
+
output: defineSchemaModel({
|
|
267
|
+
name: 'RemoveToolFromAgentOutput',
|
|
268
|
+
fields: {
|
|
269
|
+
success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
270
|
+
},
|
|
271
|
+
}),
|
|
272
|
+
},
|
|
273
|
+
policy: { auth: 'user' },
|
|
274
|
+
sideEffects: { audit: ['agent.tool.removed'] },
|
|
275
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from '@lssm/lib.schema/entity';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Agent status for lifecycle management.
|
|
5
|
+
*/
|
|
6
|
+
export const AgentStatusEntityEnum = defineEntityEnum({
|
|
7
|
+
name: 'AgentStatus',
|
|
8
|
+
values: ['DRAFT', 'ACTIVE', 'PAUSED', 'ARCHIVED'],
|
|
9
|
+
description: 'Lifecycle status of the agent',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Agent model provider.
|
|
14
|
+
*/
|
|
15
|
+
export const ModelProviderEntityEnum = defineEntityEnum({
|
|
16
|
+
name: 'ModelProvider',
|
|
17
|
+
values: ['OPENAI', 'ANTHROPIC', 'GOOGLE', 'MISTRAL', 'CUSTOM'],
|
|
18
|
+
description: 'AI model provider',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Agent entity - Represents an AI agent configuration.
|
|
23
|
+
*/
|
|
24
|
+
export const AgentEntity = defineEntity({
|
|
25
|
+
name: 'Agent',
|
|
26
|
+
schema: 'agent_console',
|
|
27
|
+
description: 'Represents an AI agent configuration with assigned tools and parameters.',
|
|
28
|
+
fields: {
|
|
29
|
+
id: field.id(),
|
|
30
|
+
organizationId: field.string({ description: 'Organization that owns this agent' }),
|
|
31
|
+
name: field.string({ description: 'Agent name (1-100 chars)' }),
|
|
32
|
+
slug: field.string({ description: 'URL-safe identifier (lowercase, numbers, hyphens)' }),
|
|
33
|
+
description: field.string({ isOptional: true, description: 'Agent description (max 1000 chars)' }),
|
|
34
|
+
status: field.enum('AgentStatus', { default: 'DRAFT' }),
|
|
35
|
+
modelProvider: field.enum('ModelProvider', { default: 'OPENAI' }),
|
|
36
|
+
modelName: field.string({ description: "Model identifier: 'gpt-4', 'claude-3-opus', etc." }),
|
|
37
|
+
modelConfig: field.json({ isOptional: true, description: 'Model parameters: temperature, max_tokens, etc.' }),
|
|
38
|
+
systemPrompt: field.string({ description: 'System prompt for the agent' }),
|
|
39
|
+
userPromptTemplate: field.string({ isOptional: true, description: 'Template for user prompts' }),
|
|
40
|
+
toolIds: field.string({ isArray: true, isOptional: true, description: 'IDs of assigned tools' }),
|
|
41
|
+
toolChoice: field.string({ default: 'auto', description: "Tool selection mode: 'auto', 'required', 'none'" }),
|
|
42
|
+
maxIterations: field.int({ default: 10, description: 'Maximum iterations per run' }),
|
|
43
|
+
maxTokensPerRun: field.int({ isOptional: true, description: 'Maximum tokens per run' }),
|
|
44
|
+
timeoutMs: field.int({ default: 120000, description: 'Execution timeout in milliseconds' }),
|
|
45
|
+
version: field.string({ default: '1.0.0', description: 'Agent version' }),
|
|
46
|
+
tags: field.string({ isArray: true, isOptional: true, description: 'Tags for categorization' }),
|
|
47
|
+
createdAt: field.createdAt(),
|
|
48
|
+
updatedAt: field.updatedAt(),
|
|
49
|
+
createdById: field.string({ isOptional: true, description: 'User who created this agent' }),
|
|
50
|
+
tools: field.hasMany('Tool', { description: 'Tools assigned to this agent' }),
|
|
51
|
+
},
|
|
52
|
+
indexes: [
|
|
53
|
+
index.unique(['organizationId', 'slug']),
|
|
54
|
+
index.on(['organizationId', 'status']),
|
|
55
|
+
index.on(['modelProvider', 'modelName']),
|
|
56
|
+
],
|
|
57
|
+
enums: [AgentStatusEntityEnum, ModelProviderEntityEnum],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* AgentTool join entity - Links agents to their assigned tools.
|
|
62
|
+
*/
|
|
63
|
+
export const AgentToolEntity = defineEntity({
|
|
64
|
+
name: 'AgentTool',
|
|
65
|
+
schema: 'agent_console',
|
|
66
|
+
description: 'Links an agent to its assigned tools with configuration.',
|
|
67
|
+
fields: {
|
|
68
|
+
id: field.id(),
|
|
69
|
+
agentId: field.foreignKey({ description: 'Agent ID' }),
|
|
70
|
+
toolId: field.foreignKey({ description: 'Tool ID' }),
|
|
71
|
+
config: field.json({ isOptional: true, description: 'Tool-specific configuration for this agent' }),
|
|
72
|
+
order: field.int({ default: 0, description: 'Order of tool in agent tool list' }),
|
|
73
|
+
isEnabled: field.boolean({ default: true, description: 'Whether tool is enabled for this agent' }),
|
|
74
|
+
createdAt: field.createdAt(),
|
|
75
|
+
agent: field.belongsTo('Agent', ['agentId'], ['id']),
|
|
76
|
+
tool: field.belongsTo('Tool', ['toolId'], ['id']),
|
|
77
|
+
},
|
|
78
|
+
indexes: [
|
|
79
|
+
index.unique(['agentId', 'toolId']),
|
|
80
|
+
index.on(['agentId', 'order']),
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineEnum } from '@lssm/lib.schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Agent status enum.
|
|
5
|
+
*/
|
|
6
|
+
export const AgentStatusEnum = defineEnum('AgentStatus', [
|
|
7
|
+
'DRAFT',
|
|
8
|
+
'ACTIVE',
|
|
9
|
+
'PAUSED',
|
|
10
|
+
'ARCHIVED',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Model provider enum.
|
|
15
|
+
*/
|
|
16
|
+
export const ModelProviderEnum = defineEnum('ModelProvider', [
|
|
17
|
+
'OPENAI',
|
|
18
|
+
'ANTHROPIC',
|
|
19
|
+
'GOOGLE',
|
|
20
|
+
'MISTRAL',
|
|
21
|
+
'CUSTOM',
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tool choice mode enum.
|
|
26
|
+
*/
|
|
27
|
+
export const ToolChoiceEnum = defineEnum('ToolChoice', [
|
|
28
|
+
'auto',
|
|
29
|
+
'required',
|
|
30
|
+
'none',
|
|
31
|
+
]);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { defineEvent, defineSchemaModel } from '@lssm/lib.contracts';
|
|
2
|
+
import { ScalarTypeEnum } from '@lssm/lib.schema';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Payload for agent created event.
|
|
6
|
+
*/
|
|
7
|
+
const AgentCreatedPayload = defineSchemaModel({
|
|
8
|
+
name: 'AgentCreatedPayload',
|
|
9
|
+
description: 'Payload for agent created event',
|
|
10
|
+
fields: {
|
|
11
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
15
|
+
modelProvider: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
16
|
+
modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
17
|
+
toolCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
18
|
+
createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
19
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* AgentCreatedEvent - A new agent was created.
|
|
25
|
+
*/
|
|
26
|
+
export const AgentCreatedEvent = defineEvent({
|
|
27
|
+
name: 'agent.agent.created',
|
|
28
|
+
version: 1,
|
|
29
|
+
description: 'A new AI agent was configured.',
|
|
30
|
+
payload: AgentCreatedPayload,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Payload for agent updated event.
|
|
35
|
+
*/
|
|
36
|
+
const AgentUpdatedPayload = defineSchemaModel({
|
|
37
|
+
name: 'AgentUpdatedPayload',
|
|
38
|
+
description: 'Payload for agent updated event',
|
|
39
|
+
fields: {
|
|
40
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
41
|
+
organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
42
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
43
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
44
|
+
updatedFields: { type: ScalarTypeEnum.String_unsecure(), isArray: true, isOptional: false },
|
|
45
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* AgentUpdatedEvent - An agent was updated.
|
|
51
|
+
*/
|
|
52
|
+
export const AgentUpdatedEvent = defineEvent({
|
|
53
|
+
name: 'agent.agent.updated',
|
|
54
|
+
version: 1,
|
|
55
|
+
description: 'An AI agent configuration was updated.',
|
|
56
|
+
payload: AgentUpdatedPayload,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Payload for agent tool assigned event.
|
|
61
|
+
*/
|
|
62
|
+
const AgentToolAssignedPayload = defineSchemaModel({
|
|
63
|
+
name: 'AgentToolAssignedPayload',
|
|
64
|
+
description: 'Payload for agent tool assigned event',
|
|
65
|
+
fields: {
|
|
66
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
67
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
68
|
+
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
69
|
+
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
70
|
+
assignedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* AgentToolAssignedEvent - A tool was assigned to an agent.
|
|
76
|
+
*/
|
|
77
|
+
export const AgentToolAssignedEvent = defineEvent({
|
|
78
|
+
name: 'agent.agent.toolAssigned',
|
|
79
|
+
version: 1,
|
|
80
|
+
description: 'A tool was assigned to an agent.',
|
|
81
|
+
payload: AgentToolAssignedPayload,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Payload for agent tool removed event.
|
|
86
|
+
*/
|
|
87
|
+
const AgentToolRemovedPayload = defineSchemaModel({
|
|
88
|
+
name: 'AgentToolRemovedPayload',
|
|
89
|
+
description: 'Payload for agent tool removed event',
|
|
90
|
+
fields: {
|
|
91
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
92
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
93
|
+
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
94
|
+
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
95
|
+
removedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* AgentToolRemovedEvent - A tool was removed from an agent.
|
|
101
|
+
*/
|
|
102
|
+
export const AgentToolRemovedEvent = defineEvent({
|
|
103
|
+
name: 'agent.agent.toolRemoved',
|
|
104
|
+
version: 1,
|
|
105
|
+
description: 'A tool was removed from an agent.',
|
|
106
|
+
payload: AgentToolRemovedPayload,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mock handlers for Agent contracts
|
|
2
|
+
* Mock handlers for Agent contracts.
|
|
3
3
|
*/
|
|
4
|
-
import { MOCK_AGENTS
|
|
4
|
+
import { MOCK_AGENTS } from '../shared/mock-agents';
|
|
5
|
+
import { MOCK_TOOLS } from '../shared/mock-tools';
|
|
5
6
|
|
|
6
|
-
// Types inferred from contract schemas
|
|
7
7
|
export interface ListAgentsInput {
|
|
8
8
|
organizationId: string;
|
|
9
9
|
status?: 'DRAFT' | 'ACTIVE' | 'PAUSED' | 'ARCHIVED';
|
|
@@ -69,37 +69,18 @@ export interface AgentWithTools {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Mock handler for ListAgentsQuery
|
|
72
|
+
* Mock handler for ListAgentsQuery.
|
|
73
73
|
*/
|
|
74
|
-
export async function mockListAgentsHandler(
|
|
75
|
-
input
|
|
76
|
-
): Promise<ListAgentsOutput> {
|
|
77
|
-
const {
|
|
78
|
-
organizationId,
|
|
79
|
-
status,
|
|
80
|
-
modelProvider,
|
|
81
|
-
search,
|
|
82
|
-
limit = 20,
|
|
83
|
-
offset = 0,
|
|
84
|
-
} = input;
|
|
74
|
+
export async function mockListAgentsHandler(input: ListAgentsInput): Promise<ListAgentsOutput> {
|
|
75
|
+
const { organizationId, status, modelProvider, search, limit = 20, offset = 0 } = input;
|
|
85
76
|
|
|
86
77
|
let filtered = MOCK_AGENTS.filter((a) => a.organizationId === organizationId);
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
filtered = filtered.filter((a) => a.status === status);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (modelProvider) {
|
|
93
|
-
filtered = filtered.filter((a) => a.modelProvider === modelProvider);
|
|
94
|
-
}
|
|
95
|
-
|
|
78
|
+
if (status) filtered = filtered.filter((a) => a.status === status);
|
|
79
|
+
if (modelProvider) filtered = filtered.filter((a) => a.modelProvider === modelProvider);
|
|
96
80
|
if (search) {
|
|
97
81
|
const q = search.toLowerCase();
|
|
98
82
|
filtered = filtered.filter(
|
|
99
|
-
(a) =>
|
|
100
|
-
a.name.toLowerCase().includes(q) ||
|
|
101
|
-
a.description?.toLowerCase().includes(q) ||
|
|
102
|
-
a.tags?.some((t) => t.toLowerCase().includes(q))
|
|
83
|
+
(a) => a.name.toLowerCase().includes(q) || a.description?.toLowerCase().includes(q) || a.tags?.some((t) => t.toLowerCase().includes(q))
|
|
103
84
|
);
|
|
104
85
|
}
|
|
105
86
|
|
|
@@ -116,30 +97,17 @@ export async function mockListAgentsHandler(
|
|
|
116
97
|
createdAt: a.createdAt,
|
|
117
98
|
}));
|
|
118
99
|
|
|
119
|
-
return {
|
|
120
|
-
items,
|
|
121
|
-
total,
|
|
122
|
-
hasMore: offset + limit < total,
|
|
123
|
-
};
|
|
100
|
+
return { items, total, hasMore: offset + limit < total };
|
|
124
101
|
}
|
|
125
102
|
|
|
126
103
|
/**
|
|
127
|
-
* Mock handler for GetAgentQuery
|
|
104
|
+
* Mock handler for GetAgentQuery.
|
|
128
105
|
*/
|
|
129
|
-
export async function mockGetAgentHandler(
|
|
130
|
-
input: GetAgentInput
|
|
131
|
-
): Promise<AgentWithTools> {
|
|
106
|
+
export async function mockGetAgentHandler(input: GetAgentInput): Promise<AgentWithTools> {
|
|
132
107
|
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
108
|
+
if (!agent) throw new Error('AGENT_NOT_FOUND');
|
|
133
109
|
|
|
134
|
-
|
|
135
|
-
throw new Error('AGENT_NOT_FOUND');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const result: AgentWithTools = {
|
|
139
|
-
...agent,
|
|
140
|
-
toolIds: ['tool-1', 'tool-2'],
|
|
141
|
-
};
|
|
142
|
-
|
|
110
|
+
const result: AgentWithTools = { ...agent, toolIds: ['tool-1', 'tool-2'] };
|
|
143
111
|
if (input.includeTools) {
|
|
144
112
|
result.tools = MOCK_TOOLS.slice(0, 2).map((t) => ({
|
|
145
113
|
id: t.id,
|
|
@@ -149,12 +117,11 @@ export async function mockGetAgentHandler(
|
|
|
149
117
|
category: t.category,
|
|
150
118
|
}));
|
|
151
119
|
}
|
|
152
|
-
|
|
153
120
|
return result;
|
|
154
121
|
}
|
|
155
122
|
|
|
156
123
|
/**
|
|
157
|
-
* Mock handler for CreateAgentCommand
|
|
124
|
+
* Mock handler for CreateAgentCommand.
|
|
158
125
|
*/
|
|
159
126
|
export async function mockCreateAgentHandler(input: {
|
|
160
127
|
organizationId: string;
|
|
@@ -165,39 +132,17 @@ export async function mockCreateAgentHandler(input: {
|
|
|
165
132
|
modelName: string;
|
|
166
133
|
systemPrompt: string;
|
|
167
134
|
}) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
);
|
|
172
|
-
if (exists) {
|
|
173
|
-
throw new Error('SLUG_EXISTS');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
id: `agent-${Date.now()}`,
|
|
178
|
-
name: input.name,
|
|
179
|
-
slug: input.slug,
|
|
180
|
-
status: 'DRAFT' as const,
|
|
181
|
-
};
|
|
135
|
+
const exists = MOCK_AGENTS.some((a) => a.organizationId === input.organizationId && a.slug === input.slug);
|
|
136
|
+
if (exists) throw new Error('SLUG_EXISTS');
|
|
137
|
+
return { id: `agent-${Date.now()}`, name: input.name, slug: input.slug, status: 'DRAFT' as const };
|
|
182
138
|
}
|
|
183
139
|
|
|
184
140
|
/**
|
|
185
|
-
* Mock handler for UpdateAgentCommand
|
|
141
|
+
* Mock handler for UpdateAgentCommand.
|
|
186
142
|
*/
|
|
187
|
-
export async function mockUpdateAgentHandler(input: {
|
|
188
|
-
agentId: string;
|
|
189
|
-
name?: string;
|
|
190
|
-
status?: 'DRAFT' | 'ACTIVE' | 'PAUSED' | 'ARCHIVED';
|
|
191
|
-
}) {
|
|
143
|
+
export async function mockUpdateAgentHandler(input: { agentId: string; name?: string; status?: 'DRAFT' | 'ACTIVE' | 'PAUSED' | 'ARCHIVED' }) {
|
|
192
144
|
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
193
|
-
if (!agent)
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
id: agent.id,
|
|
199
|
-
name: input.name ?? agent.name,
|
|
200
|
-
status: input.status ?? agent.status,
|
|
201
|
-
updatedAt: new Date(),
|
|
202
|
-
};
|
|
145
|
+
if (!agent) throw new Error('AGENT_NOT_FOUND');
|
|
146
|
+
return { id: agent.id, name: input.name ?? agent.name, status: input.status ?? agent.status, updatedAt: new Date() };
|
|
203
147
|
}
|
|
148
|
+
|