@lssm/example.agent-console 0.0.0-canary-20251216031832 → 0.0.0-canary-20251216033905
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 +2 -2
- package/CHANGELOG.md +6 -6
- package/package.json +1 -1
- package/src/agent/agent.entity.ts +74 -21
- package/src/agent/agent.event.ts +17 -6
- package/src/agent/agent.handler.ts +40 -10
- package/src/agent/agent.presentation.ts +4 -3
- package/src/agent/agent.schema.ts +88 -21
- package/src/agent/index.ts +5 -3
- package/src/handlers/index.ts +0 -1
- package/src/presentations/index.ts +0 -1
- package/src/run/index.ts +6 -3
- package/src/run/run.contracts.ts +130 -26
- package/src/run/run.entity.ts +71 -22
- package/src/run/run.enum.ts +0 -2
- package/src/run/run.event.ts +24 -8
- package/src/run/run.handler.ts +45 -10
- package/src/run/run.presentation.ts +2 -3
- package/src/run/run.schema.ts +41 -11
- package/src/shared/mock-agents.ts +0 -2
- package/src/shared/mock-runs.ts +0 -1
- package/src/shared/mock-tools.ts +0 -1
- package/src/tool/index.ts +33 -8
- package/src/tool/tool.contracts.ts +74 -14
- package/src/tool/tool.entity.ts +45 -12
- package/src/tool/tool.enum.ts +0 -2
- package/src/tool/tool.event.ts +27 -9
- package/src/tool/tool.handler.ts +59 -12
- package/src/tool/tool.presentation.ts +4 -4
- package/src/tool/tool.schema.ts +0 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/run/run.contracts.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { defineCommand, defineQuery } from '@lssm/lib.contracts/spec';
|
|
2
2
|
import { defineSchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
|
|
3
3
|
import { RunStatusEnum, LogLevelEnum, GranularityEnum } from './run.enum';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
RunInputModel,
|
|
6
|
+
RunModel,
|
|
7
|
+
RunSummaryModel,
|
|
8
|
+
RunStepModel,
|
|
9
|
+
RunLogModel,
|
|
10
|
+
TimelineDataPointModel,
|
|
11
|
+
} from './run.schema';
|
|
5
12
|
|
|
6
13
|
const OWNERS = ['agent-console-team'] as const;
|
|
7
14
|
|
|
@@ -28,7 +35,10 @@ export const ExecuteAgentCommand = defineCommand({
|
|
|
28
35
|
sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
29
36
|
metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
30
37
|
stream: { type: ScalarTypeEnum.Boolean(), isOptional: true },
|
|
31
|
-
maxIterations: {
|
|
38
|
+
maxIterations: {
|
|
39
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
40
|
+
isOptional: true,
|
|
41
|
+
},
|
|
32
42
|
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
33
43
|
},
|
|
34
44
|
}),
|
|
@@ -37,17 +47,37 @@ export const ExecuteAgentCommand = defineCommand({
|
|
|
37
47
|
fields: {
|
|
38
48
|
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
39
49
|
status: { type: RunStatusEnum, isOptional: false },
|
|
40
|
-
estimatedWaitMs: {
|
|
50
|
+
estimatedWaitMs: {
|
|
51
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
52
|
+
isOptional: true,
|
|
53
|
+
},
|
|
41
54
|
},
|
|
42
55
|
}),
|
|
43
56
|
errors: {
|
|
44
|
-
AGENT_NOT_FOUND: {
|
|
45
|
-
|
|
57
|
+
AGENT_NOT_FOUND: {
|
|
58
|
+
description: 'The specified agent does not exist',
|
|
59
|
+
http: 404,
|
|
60
|
+
gqlCode: 'AGENT_NOT_FOUND',
|
|
61
|
+
when: 'Agent ID is invalid',
|
|
62
|
+
},
|
|
63
|
+
AGENT_NOT_ACTIVE: {
|
|
64
|
+
description: 'The specified agent is not active',
|
|
65
|
+
http: 400,
|
|
66
|
+
gqlCode: 'AGENT_NOT_ACTIVE',
|
|
67
|
+
when: 'Agent is in draft/paused/archived state',
|
|
68
|
+
},
|
|
46
69
|
},
|
|
47
70
|
},
|
|
48
71
|
policy: { auth: 'user' },
|
|
49
72
|
sideEffects: {
|
|
50
|
-
emits: [
|
|
73
|
+
emits: [
|
|
74
|
+
{
|
|
75
|
+
name: 'run.started',
|
|
76
|
+
version: 1,
|
|
77
|
+
when: 'Run is queued',
|
|
78
|
+
payload: RunSummaryModel,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
51
81
|
audit: ['run.started'],
|
|
52
82
|
},
|
|
53
83
|
});
|
|
@@ -82,13 +112,30 @@ export const CancelRunCommand = defineCommand({
|
|
|
82
112
|
},
|
|
83
113
|
}),
|
|
84
114
|
errors: {
|
|
85
|
-
RUN_NOT_FOUND: {
|
|
86
|
-
|
|
115
|
+
RUN_NOT_FOUND: {
|
|
116
|
+
description: 'The specified run does not exist',
|
|
117
|
+
http: 404,
|
|
118
|
+
gqlCode: 'RUN_NOT_FOUND',
|
|
119
|
+
when: 'Run ID is invalid',
|
|
120
|
+
},
|
|
121
|
+
RUN_NOT_CANCELLABLE: {
|
|
122
|
+
description: 'The run cannot be cancelled',
|
|
123
|
+
http: 400,
|
|
124
|
+
gqlCode: 'RUN_NOT_CANCELLABLE',
|
|
125
|
+
when: 'Run is already completed/failed/cancelled',
|
|
126
|
+
},
|
|
87
127
|
},
|
|
88
128
|
},
|
|
89
129
|
policy: { auth: 'user' },
|
|
90
130
|
sideEffects: {
|
|
91
|
-
emits: [
|
|
131
|
+
emits: [
|
|
132
|
+
{
|
|
133
|
+
name: 'run.cancelled',
|
|
134
|
+
version: 1,
|
|
135
|
+
when: 'Run is cancelled',
|
|
136
|
+
payload: RunSummaryModel,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
92
139
|
audit: ['run.cancelled'],
|
|
93
140
|
},
|
|
94
141
|
});
|
|
@@ -117,7 +164,14 @@ export const GetRunQuery = defineQuery({
|
|
|
117
164
|
},
|
|
118
165
|
}),
|
|
119
166
|
output: RunModel,
|
|
120
|
-
errors: {
|
|
167
|
+
errors: {
|
|
168
|
+
RUN_NOT_FOUND: {
|
|
169
|
+
description: 'The specified run does not exist',
|
|
170
|
+
http: 404,
|
|
171
|
+
gqlCode: 'RUN_NOT_FOUND',
|
|
172
|
+
when: 'Run ID is invalid',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
121
175
|
},
|
|
122
176
|
policy: { auth: 'user' },
|
|
123
177
|
});
|
|
@@ -140,15 +194,26 @@ export const ListRunsQuery = defineQuery({
|
|
|
140
194
|
input: defineSchemaModel({
|
|
141
195
|
name: 'ListRunsInput',
|
|
142
196
|
fields: {
|
|
143
|
-
organizationId: {
|
|
197
|
+
organizationId: {
|
|
198
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
199
|
+
isOptional: true,
|
|
200
|
+
},
|
|
144
201
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
145
202
|
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
146
203
|
sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
147
204
|
status: { type: RunStatusEnum, isOptional: true },
|
|
148
205
|
startDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
149
206
|
endDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
150
|
-
limit: {
|
|
151
|
-
|
|
207
|
+
limit: {
|
|
208
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
209
|
+
isOptional: true,
|
|
210
|
+
defaultValue: 20,
|
|
211
|
+
},
|
|
212
|
+
offset: {
|
|
213
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
214
|
+
isOptional: true,
|
|
215
|
+
defaultValue: 0,
|
|
216
|
+
},
|
|
152
217
|
},
|
|
153
218
|
}),
|
|
154
219
|
output: defineSchemaModel({
|
|
@@ -178,8 +243,18 @@ export const GetRunStepsQuery = defineQuery({
|
|
|
178
243
|
context: 'Run details page - steps tab.',
|
|
179
244
|
},
|
|
180
245
|
io: {
|
|
181
|
-
input: defineSchemaModel({
|
|
182
|
-
|
|
246
|
+
input: defineSchemaModel({
|
|
247
|
+
name: 'GetRunStepsInput',
|
|
248
|
+
fields: {
|
|
249
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
250
|
+
},
|
|
251
|
+
}),
|
|
252
|
+
output: defineSchemaModel({
|
|
253
|
+
name: 'GetRunStepsOutput',
|
|
254
|
+
fields: {
|
|
255
|
+
steps: { type: RunStepModel, isArray: true, isOptional: false },
|
|
256
|
+
},
|
|
257
|
+
}),
|
|
183
258
|
},
|
|
184
259
|
policy: { auth: 'user' },
|
|
185
260
|
});
|
|
@@ -205,8 +280,16 @@ export const GetRunLogsQuery = defineQuery({
|
|
|
205
280
|
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
206
281
|
level: { type: LogLevelEnum, isOptional: true },
|
|
207
282
|
stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
208
|
-
limit: {
|
|
209
|
-
|
|
283
|
+
limit: {
|
|
284
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
285
|
+
isOptional: true,
|
|
286
|
+
defaultValue: 100,
|
|
287
|
+
},
|
|
288
|
+
offset: {
|
|
289
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
290
|
+
isOptional: true,
|
|
291
|
+
defaultValue: 0,
|
|
292
|
+
},
|
|
210
293
|
},
|
|
211
294
|
}),
|
|
212
295
|
output: defineSchemaModel({
|
|
@@ -239,28 +322,49 @@ export const GetRunMetricsQuery = defineQuery({
|
|
|
239
322
|
input: defineSchemaModel({
|
|
240
323
|
name: 'GetRunMetricsInput',
|
|
241
324
|
fields: {
|
|
242
|
-
organizationId: {
|
|
325
|
+
organizationId: {
|
|
326
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
327
|
+
isOptional: false,
|
|
328
|
+
},
|
|
243
329
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
244
330
|
startDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
245
331
|
endDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
246
|
-
granularity: {
|
|
332
|
+
granularity: {
|
|
333
|
+
type: GranularityEnum,
|
|
334
|
+
isOptional: true,
|
|
335
|
+
defaultValue: 'day',
|
|
336
|
+
},
|
|
247
337
|
},
|
|
248
338
|
}),
|
|
249
339
|
output: defineSchemaModel({
|
|
250
340
|
name: 'GetRunMetricsOutput',
|
|
251
341
|
fields: {
|
|
252
342
|
totalRuns: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
253
|
-
completedRuns: {
|
|
343
|
+
completedRuns: {
|
|
344
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
345
|
+
isOptional: false,
|
|
346
|
+
},
|
|
254
347
|
failedRuns: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
255
348
|
totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
256
|
-
totalCostUsd: {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
349
|
+
totalCostUsd: {
|
|
350
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
351
|
+
isOptional: false,
|
|
352
|
+
},
|
|
353
|
+
averageDurationMs: {
|
|
354
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
355
|
+
isOptional: false,
|
|
356
|
+
},
|
|
357
|
+
successRate: {
|
|
358
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
359
|
+
isOptional: false,
|
|
360
|
+
},
|
|
361
|
+
timeline: {
|
|
362
|
+
type: TimelineDataPointModel,
|
|
363
|
+
isArray: true,
|
|
364
|
+
isOptional: false,
|
|
365
|
+
},
|
|
260
366
|
},
|
|
261
367
|
}),
|
|
262
368
|
},
|
|
263
369
|
policy: { auth: 'user' },
|
|
264
370
|
});
|
|
265
|
-
|
|
266
|
-
|
package/src/run/run.entity.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
defineEntity,
|
|
3
|
+
defineEntityEnum,
|
|
4
|
+
field,
|
|
5
|
+
index,
|
|
6
|
+
} from '@lssm/lib.schema/entity';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Run status enum for entities.
|
|
5
10
|
*/
|
|
6
11
|
export const RunStatusEntityEnum = defineEntityEnum({
|
|
7
12
|
name: 'RunStatus',
|
|
8
|
-
values: [
|
|
13
|
+
values: [
|
|
14
|
+
'QUEUED',
|
|
15
|
+
'IN_PROGRESS',
|
|
16
|
+
'COMPLETED',
|
|
17
|
+
'FAILED',
|
|
18
|
+
'CANCELLED',
|
|
19
|
+
'EXPIRED',
|
|
20
|
+
],
|
|
9
21
|
description: 'Status of an agent run',
|
|
10
22
|
});
|
|
11
23
|
|
|
@@ -38,23 +50,59 @@ export const RunEntity = defineEntity({
|
|
|
38
50
|
id: field.id(),
|
|
39
51
|
organizationId: field.string({ description: 'Organization ID' }),
|
|
40
52
|
agentId: field.foreignKey({ description: 'Agent being executed' }),
|
|
41
|
-
userId: field.string({
|
|
42
|
-
|
|
53
|
+
userId: field.string({
|
|
54
|
+
isOptional: true,
|
|
55
|
+
description: 'User who initiated the run',
|
|
56
|
+
}),
|
|
57
|
+
sessionId: field.string({
|
|
58
|
+
isOptional: true,
|
|
59
|
+
description: 'Conversation session ID',
|
|
60
|
+
}),
|
|
43
61
|
input: field.json({ description: 'Input data for the run' }),
|
|
44
|
-
output: field.json({
|
|
62
|
+
output: field.json({
|
|
63
|
+
isOptional: true,
|
|
64
|
+
description: 'Output result from the run',
|
|
65
|
+
}),
|
|
45
66
|
status: field.enum('RunStatus', { default: 'QUEUED' }),
|
|
46
|
-
errorMessage: field.string({
|
|
47
|
-
|
|
67
|
+
errorMessage: field.string({
|
|
68
|
+
isOptional: true,
|
|
69
|
+
description: 'Error message if failed',
|
|
70
|
+
}),
|
|
71
|
+
errorCode: field.string({
|
|
72
|
+
isOptional: true,
|
|
73
|
+
description: 'Error code if failed',
|
|
74
|
+
}),
|
|
48
75
|
totalTokens: field.int({ default: 0, description: 'Total tokens used' }),
|
|
49
76
|
promptTokens: field.int({ default: 0, description: 'Prompt tokens used' }),
|
|
50
|
-
completionTokens: field.int({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
completionTokens: field.int({
|
|
78
|
+
default: 0,
|
|
79
|
+
description: 'Completion tokens used',
|
|
80
|
+
}),
|
|
81
|
+
totalIterations: field.int({
|
|
82
|
+
default: 0,
|
|
83
|
+
description: 'Number of iterations',
|
|
84
|
+
}),
|
|
85
|
+
durationMs: field.int({
|
|
86
|
+
isOptional: true,
|
|
87
|
+
description: 'Execution duration in ms',
|
|
88
|
+
}),
|
|
89
|
+
estimatedCostUsd: field.float({
|
|
90
|
+
isOptional: true,
|
|
91
|
+
description: 'Estimated cost in USD',
|
|
92
|
+
}),
|
|
54
93
|
queuedAt: field.dateTime({ description: 'When run was queued' }),
|
|
55
|
-
startedAt: field.dateTime({
|
|
56
|
-
|
|
57
|
-
|
|
94
|
+
startedAt: field.dateTime({
|
|
95
|
+
isOptional: true,
|
|
96
|
+
description: 'When run started executing',
|
|
97
|
+
}),
|
|
98
|
+
completedAt: field.dateTime({
|
|
99
|
+
isOptional: true,
|
|
100
|
+
description: 'When run completed',
|
|
101
|
+
}),
|
|
102
|
+
metadata: field.json({
|
|
103
|
+
isOptional: true,
|
|
104
|
+
description: 'Additional metadata',
|
|
105
|
+
}),
|
|
58
106
|
agent: field.belongsTo('Agent', ['agentId'], ['id']),
|
|
59
107
|
steps: field.hasMany('RunStep', { description: 'Execution steps' }),
|
|
60
108
|
logs: field.hasMany('RunLog', { description: 'Execution logs' }),
|
|
@@ -80,7 +128,10 @@ export const RunStepEntity = defineEntity({
|
|
|
80
128
|
runId: field.foreignKey({ description: 'Parent run' }),
|
|
81
129
|
stepNumber: field.int({ description: 'Step sequence number' }),
|
|
82
130
|
type: field.enum('RunStepType'),
|
|
83
|
-
toolId: field.string({
|
|
131
|
+
toolId: field.string({
|
|
132
|
+
isOptional: true,
|
|
133
|
+
description: 'Tool used in this step',
|
|
134
|
+
}),
|
|
84
135
|
toolName: field.string({ isOptional: true, description: 'Tool name' }),
|
|
85
136
|
input: field.json({ isOptional: true, description: 'Step input' }),
|
|
86
137
|
output: field.json({ isOptional: true, description: 'Step output' }),
|
|
@@ -110,17 +161,15 @@ export const RunLogEntity = defineEntity({
|
|
|
110
161
|
level: field.enum('LogLevel'),
|
|
111
162
|
message: field.string({ description: 'Log message' }),
|
|
112
163
|
data: field.json({ isOptional: true, description: 'Additional log data' }),
|
|
113
|
-
source: field.string({
|
|
164
|
+
source: field.string({
|
|
165
|
+
isOptional: true,
|
|
166
|
+
description: 'Log source component',
|
|
167
|
+
}),
|
|
114
168
|
traceId: field.string({ isOptional: true }),
|
|
115
169
|
spanId: field.string({ isOptional: true }),
|
|
116
170
|
timestamp: field.dateTime(),
|
|
117
171
|
run: field.belongsTo('Run', ['runId'], ['id']),
|
|
118
172
|
},
|
|
119
|
-
indexes: [
|
|
120
|
-
index.on(['runId', 'timestamp']),
|
|
121
|
-
index.on(['runId', 'level']),
|
|
122
|
-
],
|
|
173
|
+
indexes: [index.on(['runId', 'timestamp']), index.on(['runId', 'level'])],
|
|
123
174
|
enums: [LogLevelEntityEnum],
|
|
124
175
|
});
|
|
125
|
-
|
|
126
|
-
|
package/src/run/run.enum.ts
CHANGED
package/src/run/run.event.ts
CHANGED
|
@@ -9,7 +9,10 @@ const RunStartedPayload = defineSchemaModel({
|
|
|
9
9
|
description: 'Payload for run started event',
|
|
10
10
|
fields: {
|
|
11
11
|
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
-
organizationId: {
|
|
12
|
+
organizationId: {
|
|
13
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
14
|
+
isOptional: false,
|
|
15
|
+
},
|
|
13
16
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
17
|
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
15
18
|
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
@@ -37,17 +40,26 @@ const RunCompletedPayload = defineSchemaModel({
|
|
|
37
40
|
description: 'Payload for run completed event',
|
|
38
41
|
fields: {
|
|
39
42
|
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
40
|
-
organizationId: {
|
|
43
|
+
organizationId: {
|
|
44
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
45
|
+
isOptional: false,
|
|
46
|
+
},
|
|
41
47
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
42
48
|
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
43
49
|
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
44
50
|
output: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
45
51
|
totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
46
52
|
promptTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
47
|
-
completionTokens: {
|
|
53
|
+
completionTokens: {
|
|
54
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
55
|
+
isOptional: false,
|
|
56
|
+
},
|
|
48
57
|
totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
49
58
|
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
50
|
-
estimatedCostUsd: {
|
|
59
|
+
estimatedCostUsd: {
|
|
60
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
61
|
+
isOptional: true,
|
|
62
|
+
},
|
|
51
63
|
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
52
64
|
},
|
|
53
65
|
});
|
|
@@ -70,7 +82,10 @@ const RunFailedPayload = defineSchemaModel({
|
|
|
70
82
|
description: 'Payload for run failed event',
|
|
71
83
|
fields: {
|
|
72
84
|
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
73
|
-
organizationId: {
|
|
85
|
+
organizationId: {
|
|
86
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
87
|
+
isOptional: false,
|
|
88
|
+
},
|
|
74
89
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
75
90
|
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
76
91
|
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
@@ -101,7 +116,10 @@ const RunCancelledPayload = defineSchemaModel({
|
|
|
101
116
|
description: 'Payload for run cancelled event',
|
|
102
117
|
fields: {
|
|
103
118
|
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
104
|
-
organizationId: {
|
|
119
|
+
organizationId: {
|
|
120
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
121
|
+
isOptional: false,
|
|
122
|
+
},
|
|
105
123
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
106
124
|
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
107
125
|
cancelledBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
@@ -207,5 +225,3 @@ export const MessageGeneratedEvent = defineEvent({
|
|
|
207
225
|
description: 'An agent generated a message during a run.',
|
|
208
226
|
payload: MessageGeneratedPayload,
|
|
209
227
|
});
|
|
210
|
-
|
|
211
|
-
|
package/src/run/run.handler.ts
CHANGED
|
@@ -9,7 +9,13 @@ export interface ListRunsInput {
|
|
|
9
9
|
agentId?: string;
|
|
10
10
|
userId?: string;
|
|
11
11
|
sessionId?: string;
|
|
12
|
-
status?:
|
|
12
|
+
status?:
|
|
13
|
+
| 'QUEUED'
|
|
14
|
+
| 'IN_PROGRESS'
|
|
15
|
+
| 'COMPLETED'
|
|
16
|
+
| 'FAILED'
|
|
17
|
+
| 'CANCELLED'
|
|
18
|
+
| 'EXPIRED';
|
|
13
19
|
startDate?: Date;
|
|
14
20
|
endDate?: Date;
|
|
15
21
|
limit?: number;
|
|
@@ -20,7 +26,13 @@ export interface RunSummary {
|
|
|
20
26
|
id: string;
|
|
21
27
|
agentId: string;
|
|
22
28
|
agentName: string;
|
|
23
|
-
status:
|
|
29
|
+
status:
|
|
30
|
+
| 'QUEUED'
|
|
31
|
+
| 'IN_PROGRESS'
|
|
32
|
+
| 'COMPLETED'
|
|
33
|
+
| 'FAILED'
|
|
34
|
+
| 'CANCELLED'
|
|
35
|
+
| 'EXPIRED';
|
|
24
36
|
totalTokens: number;
|
|
25
37
|
durationMs?: number;
|
|
26
38
|
estimatedCostUsd?: number;
|
|
@@ -37,7 +49,9 @@ export interface ListRunsOutput {
|
|
|
37
49
|
/**
|
|
38
50
|
* Mock handler for ListRunsQuery.
|
|
39
51
|
*/
|
|
40
|
-
export async function mockListRunsHandler(
|
|
52
|
+
export async function mockListRunsHandler(
|
|
53
|
+
input: ListRunsInput
|
|
54
|
+
): Promise<ListRunsOutput> {
|
|
41
55
|
const { agentId, status, limit = 20, offset = 0 } = input;
|
|
42
56
|
|
|
43
57
|
let filtered = [...MOCK_RUNS];
|
|
@@ -66,14 +80,25 @@ export async function mockListRunsHandler(input: ListRunsInput): Promise<ListRun
|
|
|
66
80
|
/**
|
|
67
81
|
* Mock handler for GetRunQuery.
|
|
68
82
|
*/
|
|
69
|
-
export async function mockGetRunHandler(input: {
|
|
83
|
+
export async function mockGetRunHandler(input: {
|
|
84
|
+
runId: string;
|
|
85
|
+
includeSteps?: boolean;
|
|
86
|
+
includeLogs?: boolean;
|
|
87
|
+
}) {
|
|
70
88
|
const run = MOCK_RUNS.find((r) => r.id === input.runId);
|
|
71
89
|
if (!run) throw new Error('RUN_NOT_FOUND');
|
|
72
90
|
|
|
73
91
|
const agent = MOCK_AGENTS.find((a) => a.id === run.agentId);
|
|
74
92
|
return {
|
|
75
93
|
...run,
|
|
76
|
-
agent: agent
|
|
94
|
+
agent: agent
|
|
95
|
+
? {
|
|
96
|
+
id: agent.id,
|
|
97
|
+
name: agent.name,
|
|
98
|
+
modelProvider: agent.modelProvider,
|
|
99
|
+
modelName: agent.modelName,
|
|
100
|
+
}
|
|
101
|
+
: undefined,
|
|
77
102
|
steps: input.includeSteps ? run.steps : undefined,
|
|
78
103
|
logs: input.includeLogs ? run.logs : undefined,
|
|
79
104
|
};
|
|
@@ -82,22 +107,32 @@ export async function mockGetRunHandler(input: { runId: string; includeSteps?: b
|
|
|
82
107
|
/**
|
|
83
108
|
* Mock handler for ExecuteAgentCommand.
|
|
84
109
|
*/
|
|
85
|
-
export async function mockExecuteAgentHandler(input: {
|
|
110
|
+
export async function mockExecuteAgentHandler(input: {
|
|
111
|
+
agentId: string;
|
|
112
|
+
input: { message: string; context?: Record<string, unknown> };
|
|
113
|
+
}) {
|
|
86
114
|
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
87
115
|
if (!agent) throw new Error('AGENT_NOT_FOUND');
|
|
88
116
|
if (agent.status !== 'ACTIVE') throw new Error('AGENT_NOT_ACTIVE');
|
|
89
117
|
|
|
90
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
runId: `run-${Date.now()}`,
|
|
120
|
+
status: 'QUEUED' as const,
|
|
121
|
+
estimatedWaitMs: 500,
|
|
122
|
+
};
|
|
91
123
|
}
|
|
92
124
|
|
|
93
125
|
/**
|
|
94
126
|
* Mock handler for CancelRunCommand.
|
|
95
127
|
*/
|
|
96
|
-
export async function mockCancelRunHandler(input: {
|
|
128
|
+
export async function mockCancelRunHandler(input: {
|
|
129
|
+
runId: string;
|
|
130
|
+
reason?: string;
|
|
131
|
+
}) {
|
|
97
132
|
const run = MOCK_RUNS.find((r) => r.id === input.runId);
|
|
98
133
|
if (!run) throw new Error('RUN_NOT_FOUND');
|
|
99
|
-
if (!['QUEUED', 'IN_PROGRESS'].includes(run.status))
|
|
134
|
+
if (!['QUEUED', 'IN_PROGRESS'].includes(run.status))
|
|
135
|
+
throw new Error('RUN_NOT_CANCELLABLE');
|
|
100
136
|
|
|
101
137
|
return { success: true, status: 'CANCELLED' as const };
|
|
102
138
|
}
|
|
103
|
-
|
|
@@ -8,7 +8,8 @@ export const RunListPresentation: PresentationDescriptorV2 = {
|
|
|
8
8
|
meta: {
|
|
9
9
|
name: 'agent-console.run.list',
|
|
10
10
|
version: 1,
|
|
11
|
-
description:
|
|
11
|
+
description:
|
|
12
|
+
'List view of agent runs with status, tokens, and duration info',
|
|
12
13
|
domain: 'agent-console',
|
|
13
14
|
owners: ['agent-console-team'],
|
|
14
15
|
tags: ['run', 'list', 'dashboard'],
|
|
@@ -43,5 +44,3 @@ export const RunDetailPresentation: PresentationDescriptorV2 = {
|
|
|
43
44
|
targets: ['react', 'markdown'],
|
|
44
45
|
policy: { flags: ['agent-console.enabled'] },
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
package/src/run/run.schema.ts
CHANGED
|
@@ -29,7 +29,11 @@ export const RunStepModel = defineSchemaModel({
|
|
|
29
29
|
output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
30
30
|
status: { type: RunStatusEnum, isOptional: false },
|
|
31
31
|
errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
32
|
-
tokensUsed: {
|
|
32
|
+
tokensUsed: {
|
|
33
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
34
|
+
isOptional: false,
|
|
35
|
+
defaultValue: 0,
|
|
36
|
+
},
|
|
33
37
|
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
34
38
|
startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
35
39
|
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
@@ -64,7 +68,10 @@ export const RunAgentRefModel = defineSchemaModel({
|
|
|
64
68
|
fields: {
|
|
65
69
|
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
66
70
|
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
67
|
-
modelProvider: {
|
|
71
|
+
modelProvider: {
|
|
72
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
73
|
+
isOptional: false,
|
|
74
|
+
},
|
|
68
75
|
modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
69
76
|
},
|
|
70
77
|
});
|
|
@@ -77,7 +84,10 @@ export const RunModel = defineSchemaModel({
|
|
|
77
84
|
description: 'Agent execution instance',
|
|
78
85
|
fields: {
|
|
79
86
|
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
80
|
-
organizationId: {
|
|
87
|
+
organizationId: {
|
|
88
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
89
|
+
isOptional: false,
|
|
90
|
+
},
|
|
81
91
|
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
82
92
|
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
83
93
|
sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
@@ -86,12 +96,31 @@ export const RunModel = defineSchemaModel({
|
|
|
86
96
|
status: { type: RunStatusEnum, isOptional: false },
|
|
87
97
|
errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
88
98
|
errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
89
|
-
totalTokens: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
totalTokens: {
|
|
100
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
101
|
+
isOptional: false,
|
|
102
|
+
defaultValue: 0,
|
|
103
|
+
},
|
|
104
|
+
promptTokens: {
|
|
105
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
106
|
+
isOptional: false,
|
|
107
|
+
defaultValue: 0,
|
|
108
|
+
},
|
|
109
|
+
completionTokens: {
|
|
110
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
111
|
+
isOptional: false,
|
|
112
|
+
defaultValue: 0,
|
|
113
|
+
},
|
|
114
|
+
totalIterations: {
|
|
115
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
116
|
+
isOptional: false,
|
|
117
|
+
defaultValue: 0,
|
|
118
|
+
},
|
|
93
119
|
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
94
|
-
estimatedCostUsd: {
|
|
120
|
+
estimatedCostUsd: {
|
|
121
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
122
|
+
isOptional: true,
|
|
123
|
+
},
|
|
95
124
|
queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
96
125
|
startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
97
126
|
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
@@ -115,7 +144,10 @@ export const RunSummaryModel = defineSchemaModel({
|
|
|
115
144
|
status: { type: RunStatusEnum, isOptional: false },
|
|
116
145
|
totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
117
146
|
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
118
|
-
estimatedCostUsd: {
|
|
147
|
+
estimatedCostUsd: {
|
|
148
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
149
|
+
isOptional: true,
|
|
150
|
+
},
|
|
119
151
|
queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
120
152
|
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
121
153
|
},
|
|
@@ -135,5 +167,3 @@ export const TimelineDataPointModel = defineSchemaModel({
|
|
|
135
167
|
avgDurationMs: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
136
168
|
},
|
|
137
169
|
});
|
|
138
|
-
|
|
139
|
-
|
package/src/shared/mock-runs.ts
CHANGED