@contractspec/example.agent-console 0.0.0-canary-20260113170453
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$colon$bundle.log +280 -0
- package/.turbo/turbo-build.log +281 -0
- package/CHANGELOG.md +368 -0
- package/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/agent/agent.entity.d.ts +55 -0
- package/dist/agent/agent.entity.d.ts.map +1 -0
- package/dist/agent/agent.entity.js +136 -0
- package/dist/agent/agent.entity.js.map +1 -0
- package/dist/agent/agent.enum.d.ts +18 -0
- package/dist/agent/agent.enum.d.ts.map +1 -0
- package/dist/agent/agent.enum.js +34 -0
- package/dist/agent/agent.enum.js.map +1 -0
- package/dist/agent/agent.event.d.ts +128 -0
- package/dist/agent/agent.event.d.ts.map +1 -0
- package/dist/agent/agent.event.js +210 -0
- package/dist/agent/agent.event.js.map +1 -0
- package/dist/agent/agent.handler.d.ts +100 -0
- package/dist/agent/agent.handler.d.ts.map +1 -0
- package/dist/agent/agent.handler.js +84 -0
- package/dist/agent/agent.handler.js.map +1 -0
- package/dist/agent/agent.operation.d.ts +471 -0
- package/dist/agent/agent.operation.d.ts.map +1 -0
- package/dist/agent/agent.operation.js +486 -0
- package/dist/agent/agent.operation.js.map +1 -0
- package/dist/agent/agent.presentation.d.ts +18 -0
- package/dist/agent/agent.presentation.d.ts.map +1 -0
- package/dist/agent/agent.presentation.js +89 -0
- package/dist/agent/agent.presentation.js.map +1 -0
- package/dist/agent/agent.schema.d.ts +401 -0
- package/dist/agent/agent.schema.d.ts.map +1 -0
- package/dist/agent/agent.schema.js +406 -0
- package/dist/agent/agent.schema.js.map +1 -0
- package/dist/agent/agent.test-spec.d.ts +8 -0
- package/dist/agent/agent.test-spec.d.ts.map +1 -0
- package/dist/agent/agent.test-spec.js +65 -0
- package/dist/agent/agent.test-spec.js.map +1 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.js +9 -0
- package/dist/agent.capability.d.ts +7 -0
- package/dist/agent.capability.d.ts.map +1 -0
- package/dist/agent.capability.js +20 -0
- package/dist/agent.capability.js.map +1 -0
- package/dist/agent.feature.d.ts +12 -0
- package/dist/agent.feature.d.ts.map +1 -0
- package/dist/agent.feature.js +305 -0
- package/dist/agent.feature.js.map +1 -0
- package/dist/docs/agent-console.docblock.d.ts +1 -0
- package/dist/docs/agent-console.docblock.js +113 -0
- package/dist/docs/agent-console.docblock.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +58 -0
- package/dist/example.js.map +1 -0
- package/dist/handlers/agent.handlers.d.ts +135 -0
- package/dist/handlers/agent.handlers.d.ts.map +1 -0
- package/dist/handlers/agent.handlers.js +263 -0
- package/dist/handlers/agent.handlers.js.map +1 -0
- package/dist/handlers/index.d.ts +5 -0
- package/dist/handlers/index.js +6 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +50 -0
- package/dist/presentations/index.d.ts +4 -0
- package/dist/presentations/index.js +5 -0
- package/dist/run/index.d.ts +8 -0
- package/dist/run/index.js +9 -0
- package/dist/run/run.entity.d.ts +82 -0
- package/dist/run/run.entity.d.ts.map +1 -0
- package/dist/run/run.entity.js +205 -0
- package/dist/run/run.entity.js.map +1 -0
- package/dist/run/run.enum.d.ts +22 -0
- package/dist/run/run.enum.d.ts.map +1 -0
- package/dist/run/run.enum.js +45 -0
- package/dist/run/run.enum.js.map +1 -0
- package/dist/run/run.event.d.ts +290 -0
- package/dist/run/run.event.d.ts.map +1 -0
- package/dist/run/run.event.js +434 -0
- package/dist/run/run.event.js.map +1 -0
- package/dist/run/run.handler.d.ts +203 -0
- package/dist/run/run.handler.d.ts.map +1 -0
- package/dist/run/run.handler.js +83 -0
- package/dist/run/run.handler.js.map +1 -0
- package/dist/run/run.operation.d.ts +720 -0
- package/dist/run/run.operation.d.ts.map +1 -0
- package/dist/run/run.operation.js +626 -0
- package/dist/run/run.operation.js.map +1 -0
- package/dist/run/run.presentation.d.ts +14 -0
- package/dist/run/run.presentation.d.ts.map +1 -0
- package/dist/run/run.presentation.js +65 -0
- package/dist/run/run.presentation.js.map +1 -0
- package/dist/run/run.schema.d.ts +416 -0
- package/dist/run/run.schema.d.ts.map +1 -0
- package/dist/run/run.schema.js +338 -0
- package/dist/run/run.schema.js.map +1 -0
- package/dist/run/run.test-spec.d.ts +8 -0
- package/dist/run/run.test-spec.d.ts.map +1 -0
- package/dist/run/run.test-spec.js +65 -0
- package/dist/run/run.test-spec.js.map +1 -0
- package/dist/seeders/index.d.ts +10 -0
- package/dist/seeders/index.d.ts.map +1 -0
- package/dist/seeders/index.js +20 -0
- package/dist/seeders/index.js.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/mock-agents.d.ts +88 -0
- package/dist/shared/mock-agents.d.ts.map +1 -0
- package/dist/shared/mock-agents.js +94 -0
- package/dist/shared/mock-agents.js.map +1 -0
- package/dist/shared/mock-runs.d.ts +120 -0
- package/dist/shared/mock-runs.d.ts.map +1 -0
- package/dist/shared/mock-runs.js +118 -0
- package/dist/shared/mock-runs.js.map +1 -0
- package/dist/shared/mock-tools.d.ts +244 -0
- package/dist/shared/mock-tools.d.ts.map +1 -0
- package/dist/shared/mock-tools.js +181 -0
- package/dist/shared/mock-tools.js.map +1 -0
- package/dist/shared/overlay-types.d.ts +34 -0
- package/dist/shared/overlay-types.d.ts.map +1 -0
- package/dist/shared/overlay-types.js +0 -0
- package/dist/tool/index.d.ts +8 -0
- package/dist/tool/index.js +9 -0
- package/dist/tool/tool.entity.d.ts +42 -0
- package/dist/tool/tool.entity.d.ts.map +1 -0
- package/dist/tool/tool.entity.js +105 -0
- package/dist/tool/tool.entity.js.map +1 -0
- package/dist/tool/tool.enum.d.ts +18 -0
- package/dist/tool/tool.enum.d.ts.map +1 -0
- package/dist/tool/tool.enum.js +35 -0
- package/dist/tool/tool.enum.js.map +1 -0
- package/dist/tool/tool.event.d.ts +103 -0
- package/dist/tool/tool.event.d.ts.map +1 -0
- package/dist/tool/tool.event.js +159 -0
- package/dist/tool/tool.event.js.map +1 -0
- package/dist/tool/tool.handler.d.ts +315 -0
- package/dist/tool/tool.handler.d.ts.map +1 -0
- package/dist/tool/tool.handler.js +87 -0
- package/dist/tool/tool.handler.js.map +1 -0
- package/dist/tool/tool.operation.d.ts +411 -0
- package/dist/tool/tool.operation.d.ts.map +1 -0
- package/dist/tool/tool.operation.js +406 -0
- package/dist/tool/tool.operation.js.map +1 -0
- package/dist/tool/tool.presentation.d.ts +14 -0
- package/dist/tool/tool.presentation.d.ts.map +1 -0
- package/dist/tool/tool.presentation.js +65 -0
- package/dist/tool/tool.presentation.js.map +1 -0
- package/dist/tool/tool.schema.d.ts +218 -0
- package/dist/tool/tool.schema.d.ts.map +1 -0
- package/dist/tool/tool.schema.js +236 -0
- package/dist/tool/tool.schema.js.map +1 -0
- package/dist/tool/tool.test-spec.d.ts +8 -0
- package/dist/tool/tool.test-spec.d.ts.map +1 -0
- package/dist/tool/tool.test-spec.js +65 -0
- package/dist/tool/tool.test-spec.js.map +1 -0
- package/dist/ui/AgentDashboard.d.ts +7 -0
- package/dist/ui/AgentDashboard.d.ts.map +1 -0
- package/dist/ui/AgentDashboard.js +420 -0
- package/dist/ui/AgentDashboard.js.map +1 -0
- package/dist/ui/AgentRunList.d.ts +2 -0
- package/dist/ui/AgentRunList.js +5 -0
- package/dist/ui/AgentToolRegistry.d.ts +2 -0
- package/dist/ui/AgentToolRegistry.js +5 -0
- package/dist/ui/hooks/index.d.ts +6 -0
- package/dist/ui/hooks/index.js +8 -0
- package/dist/ui/hooks/useAgentList.d.ts +28 -0
- package/dist/ui/hooks/useAgentList.d.ts.map +1 -0
- package/dist/ui/hooks/useAgentList.js +66 -0
- package/dist/ui/hooks/useAgentList.js.map +1 -0
- package/dist/ui/hooks/useAgentMutations.d.ts +29 -0
- package/dist/ui/hooks/useAgentMutations.d.ts.map +1 -0
- package/dist/ui/hooks/useAgentMutations.js +124 -0
- package/dist/ui/hooks/useAgentMutations.js.map +1 -0
- package/dist/ui/hooks/useRunList.d.ts +24 -0
- package/dist/ui/hooks/useRunList.d.ts.map +1 -0
- package/dist/ui/hooks/useRunList.js +66 -0
- package/dist/ui/hooks/useRunList.js.map +1 -0
- package/dist/ui/hooks/useToolList.d.ts +40 -0
- package/dist/ui/hooks/useToolList.d.ts.map +1 -0
- package/dist/ui/hooks/useToolList.js +96 -0
- package/dist/ui/hooks/useToolList.js.map +1 -0
- package/dist/ui/index.d.ts +24 -0
- package/dist/ui/index.js +24 -0
- package/dist/ui/modals/AgentActionsModal.d.ts +27 -0
- package/dist/ui/modals/AgentActionsModal.d.ts.map +1 -0
- package/dist/ui/modals/AgentActionsModal.js +262 -0
- package/dist/ui/modals/AgentActionsModal.js.map +1 -0
- package/dist/ui/modals/CreateAgentModal.d.ts +25 -0
- package/dist/ui/modals/CreateAgentModal.d.ts.map +1 -0
- package/dist/ui/modals/CreateAgentModal.js +214 -0
- package/dist/ui/modals/CreateAgentModal.js.map +1 -0
- package/dist/ui/modals/index.d.ts +3 -0
- package/dist/ui/modals/index.js +4 -0
- package/dist/ui/overlays/demo-overlays.d.ts +19 -0
- package/dist/ui/overlays/demo-overlays.d.ts.map +1 -0
- package/dist/ui/overlays/demo-overlays.js +73 -0
- package/dist/ui/overlays/demo-overlays.js.map +1 -0
- package/dist/ui/overlays/index.d.ts +2 -0
- package/dist/ui/overlays/index.js +3 -0
- package/dist/ui/renderers/agent-list.markdown.d.ts +15 -0
- package/dist/ui/renderers/agent-list.markdown.d.ts.map +1 -0
- package/dist/ui/renderers/agent-list.markdown.js +51 -0
- package/dist/ui/renderers/agent-list.markdown.js.map +1 -0
- package/dist/ui/renderers/agent-list.renderer.d.ts +11 -0
- package/dist/ui/renderers/agent-list.renderer.d.ts.map +1 -0
- package/dist/ui/renderers/agent-list.renderer.js +19 -0
- package/dist/ui/renderers/agent-list.renderer.js.map +1 -0
- package/dist/ui/renderers/dashboard.markdown.d.ts +15 -0
- package/dist/ui/renderers/dashboard.markdown.d.ts.map +1 -0
- package/dist/ui/renderers/dashboard.markdown.js +100 -0
- package/dist/ui/renderers/dashboard.markdown.js.map +1 -0
- package/dist/ui/renderers/index.d.ts +6 -0
- package/dist/ui/renderers/index.js +7 -0
- package/dist/ui/renderers/run-list.markdown.d.ts +15 -0
- package/dist/ui/renderers/run-list.markdown.d.ts.map +1 -0
- package/dist/ui/renderers/run-list.markdown.js +44 -0
- package/dist/ui/renderers/run-list.markdown.js.map +1 -0
- package/dist/ui/renderers/tool-registry.markdown.d.ts +15 -0
- package/dist/ui/renderers/tool-registry.markdown.d.ts.map +1 -0
- package/dist/ui/renderers/tool-registry.markdown.js +55 -0
- package/dist/ui/renderers/tool-registry.markdown.js.map +1 -0
- package/dist/ui/views/AgentListView.d.ts +7 -0
- package/dist/ui/views/AgentListView.d.ts.map +1 -0
- package/dist/ui/views/AgentListView.js +93 -0
- package/dist/ui/views/AgentListView.js.map +1 -0
- package/dist/ui/views/RunListView.d.ts +14 -0
- package/dist/ui/views/RunListView.d.ts.map +1 -0
- package/dist/ui/views/RunListView.js +165 -0
- package/dist/ui/views/RunListView.js.map +1 -0
- package/dist/ui/views/ToolRegistryView.d.ts +14 -0
- package/dist/ui/views/ToolRegistryView.d.ts.map +1 -0
- package/dist/ui/views/ToolRegistryView.js +97 -0
- package/dist/ui/views/ToolRegistryView.js.map +1 -0
- package/dist/ui/views/index.d.ts +4 -0
- package/dist/ui/views/index.js +5 -0
- package/example.ts +1 -0
- package/package.json +155 -0
- package/src/agent/agent.entity.ts +137 -0
- package/src/agent/agent.enum.ts +31 -0
- package/src/agent/agent.event.ts +142 -0
- package/src/agent/agent.handler.ts +178 -0
- package/src/agent/agent.operation.ts +444 -0
- package/src/agent/agent.presentation.ts +80 -0
- package/src/agent/agent.schema.ts +214 -0
- package/src/agent/agent.test-spec.ts +55 -0
- package/src/agent/index.ts +67 -0
- package/src/agent.capability.ts +13 -0
- package/src/agent.feature.ts +147 -0
- package/src/docs/agent-console.docblock.ts +97 -0
- package/src/docs/index.ts +1 -0
- package/src/example.ts +41 -0
- package/src/handlers/agent.handlers.ts +572 -0
- package/src/handlers/index.ts +30 -0
- package/src/index.ts +32 -0
- package/src/presentations/index.ts +26 -0
- package/src/run/index.ts +68 -0
- package/src/run/run.entity.ts +175 -0
- package/src/run/run.enum.ts +43 -0
- package/src/run/run.event.ts +264 -0
- package/src/run/run.handler.ts +138 -0
- package/src/run/run.operation.ts +524 -0
- package/src/run/run.presentation.ts +54 -0
- package/src/run/run.schema.ts +169 -0
- package/src/run/run.test-spec.ts +55 -0
- package/src/seeders/index.ts +29 -0
- package/src/shared/index.ts +6 -0
- package/src/shared/mock-agents.ts +81 -0
- package/src/shared/mock-runs.ts +107 -0
- package/src/shared/mock-tools.ts +145 -0
- package/src/shared/overlay-types.ts +39 -0
- package/src/tool/index.ts +60 -0
- package/src/tool/tool.entity.ts +99 -0
- package/src/tool/tool.enum.ts +32 -0
- package/src/tool/tool.event.ts +119 -0
- package/src/tool/tool.handler.ts +154 -0
- package/src/tool/tool.operation.ts +366 -0
- package/src/tool/tool.presentation.ts +55 -0
- package/src/tool/tool.schema.ts +133 -0
- package/src/tool/tool.test-spec.ts +55 -0
- package/src/ui/AgentDashboard.tsx +416 -0
- package/src/ui/AgentRunList.tsx +8 -0
- package/src/ui/AgentToolRegistry.tsx +8 -0
- package/src/ui/hooks/index.ts +14 -0
- package/src/ui/hooks/useAgentList.ts +80 -0
- package/src/ui/hooks/useAgentMutations.ts +156 -0
- package/src/ui/hooks/useRunList.ts +81 -0
- package/src/ui/hooks/useToolList.ts +122 -0
- package/src/ui/index.ts +21 -0
- package/src/ui/modals/AgentActionsModal.tsx +306 -0
- package/src/ui/modals/CreateAgentModal.tsx +257 -0
- package/src/ui/modals/index.ts +2 -0
- package/src/ui/overlays/demo-overlays.ts +77 -0
- package/src/ui/overlays/index.ts +1 -0
- package/src/ui/renderers/agent-list.markdown.ts +84 -0
- package/src/ui/renderers/agent-list.renderer.tsx +27 -0
- package/src/ui/renderers/dashboard.markdown.ts +169 -0
- package/src/ui/renderers/index.ts +12 -0
- package/src/ui/renderers/run-list.markdown.ts +75 -0
- package/src/ui/renderers/tool-registry.markdown.ts +91 -0
- package/src/ui/views/AgentListView.tsx +113 -0
- package/src/ui/views/RunListView.tsx +173 -0
- package/src/ui/views/ToolRegistryView.tsx +140 -0
- package/src/ui/views/index.ts +6 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +7 -0
package/src/run/index.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run domain - Agent execution and monitoring.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Enums
|
|
6
|
+
export {
|
|
7
|
+
RunStatusEnum,
|
|
8
|
+
RunStepTypeEnum,
|
|
9
|
+
LogLevelEnum,
|
|
10
|
+
GranularityEnum,
|
|
11
|
+
} from './run.enum';
|
|
12
|
+
|
|
13
|
+
// Schema models
|
|
14
|
+
export {
|
|
15
|
+
RunInputModel,
|
|
16
|
+
RunStepModel,
|
|
17
|
+
RunLogModel,
|
|
18
|
+
RunAgentRefModel,
|
|
19
|
+
RunModel,
|
|
20
|
+
RunSummaryModel,
|
|
21
|
+
TimelineDataPointModel,
|
|
22
|
+
} from './run.schema';
|
|
23
|
+
|
|
24
|
+
// Contracts
|
|
25
|
+
export {
|
|
26
|
+
ExecuteAgentCommand,
|
|
27
|
+
CancelRunCommand,
|
|
28
|
+
GetRunQuery,
|
|
29
|
+
ListRunsQuery,
|
|
30
|
+
GetRunStepsQuery,
|
|
31
|
+
GetRunLogsQuery,
|
|
32
|
+
GetRunMetricsQuery,
|
|
33
|
+
} from './run.operation';
|
|
34
|
+
|
|
35
|
+
// Events
|
|
36
|
+
export {
|
|
37
|
+
RunStartedEvent,
|
|
38
|
+
RunCompletedEvent,
|
|
39
|
+
RunFailedEvent,
|
|
40
|
+
RunCancelledEvent,
|
|
41
|
+
ToolInvokedEvent,
|
|
42
|
+
ToolCompletedEvent,
|
|
43
|
+
MessageGeneratedEvent,
|
|
44
|
+
} from './run.event';
|
|
45
|
+
|
|
46
|
+
// Entities
|
|
47
|
+
export {
|
|
48
|
+
RunStatusEntityEnum,
|
|
49
|
+
RunStepTypeEntityEnum,
|
|
50
|
+
LogLevelEntityEnum,
|
|
51
|
+
RunEntity,
|
|
52
|
+
RunStepEntity,
|
|
53
|
+
RunLogEntity,
|
|
54
|
+
} from './run.entity';
|
|
55
|
+
|
|
56
|
+
// Presentations
|
|
57
|
+
export { RunListPresentation, RunDetailPresentation } from './run.presentation';
|
|
58
|
+
|
|
59
|
+
// Handlers
|
|
60
|
+
export {
|
|
61
|
+
mockListRunsHandler,
|
|
62
|
+
mockGetRunHandler,
|
|
63
|
+
mockExecuteAgentHandler,
|
|
64
|
+
mockCancelRunHandler,
|
|
65
|
+
type ListRunsInput,
|
|
66
|
+
type RunSummary,
|
|
67
|
+
type ListRunsOutput,
|
|
68
|
+
} from './run.handler';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineEntity,
|
|
3
|
+
defineEntityEnum,
|
|
4
|
+
field,
|
|
5
|
+
index,
|
|
6
|
+
} from '@contractspec/lib.schema';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Run status enum for entities.
|
|
10
|
+
*/
|
|
11
|
+
export const RunStatusEntityEnum = defineEntityEnum({
|
|
12
|
+
name: 'RunStatus',
|
|
13
|
+
values: [
|
|
14
|
+
'QUEUED',
|
|
15
|
+
'IN_PROGRESS',
|
|
16
|
+
'COMPLETED',
|
|
17
|
+
'FAILED',
|
|
18
|
+
'CANCELLED',
|
|
19
|
+
'EXPIRED',
|
|
20
|
+
],
|
|
21
|
+
description: 'Status of an agent run',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Run step type enum for entities.
|
|
26
|
+
*/
|
|
27
|
+
export const RunStepTypeEntityEnum = defineEntityEnum({
|
|
28
|
+
name: 'RunStepType',
|
|
29
|
+
values: ['MESSAGE_CREATION', 'TOOL_CALL', 'TOOL_RESULT', 'ERROR'],
|
|
30
|
+
description: 'Type of run step',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Log level enum for entities.
|
|
35
|
+
*/
|
|
36
|
+
export const LogLevelEntityEnum = defineEntityEnum({
|
|
37
|
+
name: 'LogLevel',
|
|
38
|
+
values: ['DEBUG', 'INFO', 'WARN', 'ERROR'],
|
|
39
|
+
description: 'Log level',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Run entity - Represents an agent execution.
|
|
44
|
+
*/
|
|
45
|
+
export const RunEntity = defineEntity({
|
|
46
|
+
name: 'Run',
|
|
47
|
+
schema: 'agent_console',
|
|
48
|
+
description: 'An execution of an agent with input/output and metrics.',
|
|
49
|
+
fields: {
|
|
50
|
+
id: field.id(),
|
|
51
|
+
organizationId: field.string({ description: 'Organization ID' }),
|
|
52
|
+
agentId: field.foreignKey({ description: 'Agent being executed' }),
|
|
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
|
+
}),
|
|
61
|
+
input: field.json({ description: 'Input data for the run' }),
|
|
62
|
+
output: field.json({
|
|
63
|
+
isOptional: true,
|
|
64
|
+
description: 'Output result from the run',
|
|
65
|
+
}),
|
|
66
|
+
status: field.enum('RunStatus', { default: 'QUEUED' }),
|
|
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
|
+
}),
|
|
75
|
+
totalTokens: field.int({ default: 0, description: 'Total tokens used' }),
|
|
76
|
+
promptTokens: field.int({ default: 0, description: 'Prompt tokens used' }),
|
|
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
|
+
}),
|
|
93
|
+
queuedAt: field.dateTime({ description: 'When run was queued' }),
|
|
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
|
+
}),
|
|
106
|
+
agent: field.belongsTo('Agent', ['agentId'], ['id']),
|
|
107
|
+
steps: field.hasMany('RunStep', { description: 'Execution steps' }),
|
|
108
|
+
logs: field.hasMany('RunLog', { description: 'Execution logs' }),
|
|
109
|
+
},
|
|
110
|
+
indexes: [
|
|
111
|
+
index.on(['organizationId', 'agentId', 'queuedAt']),
|
|
112
|
+
index.on(['organizationId', 'status']),
|
|
113
|
+
index.on(['agentId', 'status']),
|
|
114
|
+
index.on(['sessionId']),
|
|
115
|
+
],
|
|
116
|
+
enums: [RunStatusEntityEnum],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* RunStep entity - Individual step in a run.
|
|
121
|
+
*/
|
|
122
|
+
export const RunStepEntity = defineEntity({
|
|
123
|
+
name: 'RunStep',
|
|
124
|
+
schema: 'agent_console',
|
|
125
|
+
description: 'An individual step in an agent run.',
|
|
126
|
+
fields: {
|
|
127
|
+
id: field.id(),
|
|
128
|
+
runId: field.foreignKey({ description: 'Parent run' }),
|
|
129
|
+
stepNumber: field.int({ description: 'Step sequence number' }),
|
|
130
|
+
type: field.enum('RunStepType'),
|
|
131
|
+
toolId: field.string({
|
|
132
|
+
isOptional: true,
|
|
133
|
+
description: 'Tool used in this step',
|
|
134
|
+
}),
|
|
135
|
+
toolName: field.string({ isOptional: true, description: 'Tool name' }),
|
|
136
|
+
input: field.json({ isOptional: true, description: 'Step input' }),
|
|
137
|
+
output: field.json({ isOptional: true, description: 'Step output' }),
|
|
138
|
+
status: field.enum('RunStatus'),
|
|
139
|
+
errorMessage: field.string({ isOptional: true }),
|
|
140
|
+
tokensUsed: field.int({ default: 0 }),
|
|
141
|
+
durationMs: field.int({ isOptional: true }),
|
|
142
|
+
startedAt: field.dateTime(),
|
|
143
|
+
completedAt: field.dateTime({ isOptional: true }),
|
|
144
|
+
run: field.belongsTo('Run', ['runId'], ['id']),
|
|
145
|
+
},
|
|
146
|
+
indexes: [index.on(['runId', 'stepNumber'])],
|
|
147
|
+
enums: [RunStepTypeEntityEnum],
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* RunLog entity - Log entry for a run.
|
|
152
|
+
*/
|
|
153
|
+
export const RunLogEntity = defineEntity({
|
|
154
|
+
name: 'RunLog',
|
|
155
|
+
schema: 'agent_console',
|
|
156
|
+
description: 'A log entry for an agent run.',
|
|
157
|
+
fields: {
|
|
158
|
+
id: field.id(),
|
|
159
|
+
runId: field.foreignKey({ description: 'Parent run' }),
|
|
160
|
+
stepId: field.string({ isOptional: true, description: 'Related step' }),
|
|
161
|
+
level: field.enum('LogLevel'),
|
|
162
|
+
message: field.string({ description: 'Log message' }),
|
|
163
|
+
data: field.json({ isOptional: true, description: 'Additional log data' }),
|
|
164
|
+
source: field.string({
|
|
165
|
+
isOptional: true,
|
|
166
|
+
description: 'Log source component',
|
|
167
|
+
}),
|
|
168
|
+
traceId: field.string({ isOptional: true }),
|
|
169
|
+
spanId: field.string({ isOptional: true }),
|
|
170
|
+
timestamp: field.dateTime(),
|
|
171
|
+
run: field.belongsTo('Run', ['runId'], ['id']),
|
|
172
|
+
},
|
|
173
|
+
indexes: [index.on(['runId', 'timestamp']), index.on(['runId', 'level'])],
|
|
174
|
+
enums: [LogLevelEntityEnum],
|
|
175
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineEnum } from '@contractspec/lib.schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Run status enum.
|
|
5
|
+
*/
|
|
6
|
+
export const RunStatusEnum = defineEnum('RunStatus', [
|
|
7
|
+
'QUEUED',
|
|
8
|
+
'IN_PROGRESS',
|
|
9
|
+
'COMPLETED',
|
|
10
|
+
'FAILED',
|
|
11
|
+
'CANCELLED',
|
|
12
|
+
'EXPIRED',
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Run step type enum.
|
|
17
|
+
*/
|
|
18
|
+
export const RunStepTypeEnum = defineEnum('RunStepType', [
|
|
19
|
+
'MESSAGE_CREATION',
|
|
20
|
+
'TOOL_CALL',
|
|
21
|
+
'TOOL_RESULT',
|
|
22
|
+
'ERROR',
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Log level enum.
|
|
27
|
+
*/
|
|
28
|
+
export const LogLevelEnum = defineEnum('LogLevel', [
|
|
29
|
+
'DEBUG',
|
|
30
|
+
'INFO',
|
|
31
|
+
'WARN',
|
|
32
|
+
'ERROR',
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Granularity enum for metrics.
|
|
37
|
+
*/
|
|
38
|
+
export const GranularityEnum = defineEnum('Granularity', [
|
|
39
|
+
'hour',
|
|
40
|
+
'day',
|
|
41
|
+
'week',
|
|
42
|
+
'month',
|
|
43
|
+
]);
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { defineEvent, defineSchemaModel } from '@contractspec/lib.contracts';
|
|
2
|
+
import { ScalarTypeEnum, defineEnum } from '@contractspec/lib.schema';
|
|
3
|
+
|
|
4
|
+
const OWNERS = ['@agent-console-team'] as const;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Payload for run started event.
|
|
8
|
+
*/
|
|
9
|
+
const RunStartedPayload = defineSchemaModel({
|
|
10
|
+
name: 'RunStartedPayload',
|
|
11
|
+
description: 'Payload for run started event',
|
|
12
|
+
fields: {
|
|
13
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
organizationId: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false,
|
|
17
|
+
},
|
|
18
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
19
|
+
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
21
|
+
sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
22
|
+
input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
23
|
+
startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* RunStartedEvent - An agent run was started.
|
|
29
|
+
*/
|
|
30
|
+
export const RunStartedEvent = defineEvent({
|
|
31
|
+
meta: {
|
|
32
|
+
key: 'agent.run.started',
|
|
33
|
+
version: '1.0.0',
|
|
34
|
+
description: 'An agent run was started.',
|
|
35
|
+
stability: 'stable',
|
|
36
|
+
owners: [...OWNERS],
|
|
37
|
+
tags: ['run', 'started'],
|
|
38
|
+
},
|
|
39
|
+
payload: RunStartedPayload,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Payload for run completed event.
|
|
44
|
+
*/
|
|
45
|
+
const RunCompletedPayload = defineSchemaModel({
|
|
46
|
+
name: 'RunCompletedPayload',
|
|
47
|
+
description: 'Payload for run completed event',
|
|
48
|
+
fields: {
|
|
49
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
50
|
+
organizationId: {
|
|
51
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
52
|
+
isOptional: false,
|
|
53
|
+
},
|
|
54
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
55
|
+
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
56
|
+
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
57
|
+
output: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
58
|
+
totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
59
|
+
promptTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
60
|
+
completionTokens: {
|
|
61
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
62
|
+
isOptional: false,
|
|
63
|
+
},
|
|
64
|
+
totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
65
|
+
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
66
|
+
estimatedCostUsd: {
|
|
67
|
+
type: ScalarTypeEnum.Float_unsecure(),
|
|
68
|
+
isOptional: true,
|
|
69
|
+
},
|
|
70
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* RunCompletedEvent - An agent run completed successfully.
|
|
76
|
+
*/
|
|
77
|
+
export const RunCompletedEvent = defineEvent({
|
|
78
|
+
meta: {
|
|
79
|
+
key: 'agent.run.completed',
|
|
80
|
+
version: '1.0.0',
|
|
81
|
+
description: 'An agent run completed successfully.',
|
|
82
|
+
stability: 'stable',
|
|
83
|
+
owners: [...OWNERS],
|
|
84
|
+
tags: ['run', 'completed'],
|
|
85
|
+
},
|
|
86
|
+
payload: RunCompletedPayload,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Payload for run failed event.
|
|
91
|
+
*/
|
|
92
|
+
const RunFailedPayload = defineSchemaModel({
|
|
93
|
+
name: 'RunFailedPayload',
|
|
94
|
+
description: 'Payload for run failed event',
|
|
95
|
+
fields: {
|
|
96
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
97
|
+
organizationId: {
|
|
98
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
99
|
+
isOptional: false,
|
|
100
|
+
},
|
|
101
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
102
|
+
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
103
|
+
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
104
|
+
errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
105
|
+
errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
106
|
+
totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
107
|
+
totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
108
|
+
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
109
|
+
failedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* RunFailedEvent - An agent run failed.
|
|
115
|
+
*/
|
|
116
|
+
export const RunFailedEvent = defineEvent({
|
|
117
|
+
meta: {
|
|
118
|
+
key: 'agent.run.failed',
|
|
119
|
+
version: '1.0.0',
|
|
120
|
+
description: 'An agent run encountered an error.',
|
|
121
|
+
stability: 'stable',
|
|
122
|
+
owners: [...OWNERS],
|
|
123
|
+
tags: ['run', 'failed'],
|
|
124
|
+
},
|
|
125
|
+
payload: RunFailedPayload,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Payload for run cancelled event.
|
|
130
|
+
*/
|
|
131
|
+
const RunCancelledPayload = defineSchemaModel({
|
|
132
|
+
name: 'RunCancelledPayload',
|
|
133
|
+
description: 'Payload for run cancelled event',
|
|
134
|
+
fields: {
|
|
135
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
136
|
+
organizationId: {
|
|
137
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
138
|
+
isOptional: false,
|
|
139
|
+
},
|
|
140
|
+
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
141
|
+
userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
142
|
+
cancelledBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
143
|
+
reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
144
|
+
totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
145
|
+
totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
146
|
+
cancelledAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* RunCancelledEvent - An agent run was cancelled.
|
|
152
|
+
*/
|
|
153
|
+
export const RunCancelledEvent = defineEvent({
|
|
154
|
+
meta: {
|
|
155
|
+
key: 'agent.run.cancelled',
|
|
156
|
+
version: '1.0.0',
|
|
157
|
+
description: 'An agent run was cancelled by the user.',
|
|
158
|
+
stability: 'stable',
|
|
159
|
+
owners: [...OWNERS],
|
|
160
|
+
tags: ['run', 'cancelled'],
|
|
161
|
+
},
|
|
162
|
+
payload: RunCancelledPayload,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Payload for tool invoked event.
|
|
167
|
+
*/
|
|
168
|
+
const ToolInvokedPayload = defineSchemaModel({
|
|
169
|
+
name: 'ToolInvokedPayload',
|
|
170
|
+
description: 'Payload for tool invoked event',
|
|
171
|
+
fields: {
|
|
172
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
173
|
+
stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
174
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
175
|
+
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
176
|
+
input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
177
|
+
invokedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* ToolInvokedEvent - A tool was invoked during a run.
|
|
183
|
+
*/
|
|
184
|
+
export const ToolInvokedEvent = defineEvent({
|
|
185
|
+
meta: {
|
|
186
|
+
key: 'agent.run.toolInvoked',
|
|
187
|
+
version: '1.0.0',
|
|
188
|
+
description: 'A tool was invoked during an agent run.',
|
|
189
|
+
stability: 'stable',
|
|
190
|
+
owners: [...OWNERS],
|
|
191
|
+
tags: ['run', 'tool', 'invoked'],
|
|
192
|
+
},
|
|
193
|
+
payload: ToolInvokedPayload,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Payload for tool completed event.
|
|
198
|
+
*/
|
|
199
|
+
const ToolCompletedPayload = defineSchemaModel({
|
|
200
|
+
name: 'ToolCompletedPayload',
|
|
201
|
+
description: 'Payload for tool completed event',
|
|
202
|
+
fields: {
|
|
203
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
204
|
+
stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
205
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
206
|
+
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
207
|
+
success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
208
|
+
output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
209
|
+
errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
210
|
+
durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
211
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* ToolCompletedEvent - A tool invocation completed.
|
|
217
|
+
*/
|
|
218
|
+
export const ToolCompletedEvent = defineEvent({
|
|
219
|
+
meta: {
|
|
220
|
+
key: 'agent.run.toolCompleted',
|
|
221
|
+
version: '1.0.0',
|
|
222
|
+
description: 'A tool invocation completed during an agent run.',
|
|
223
|
+
stability: 'stable',
|
|
224
|
+
owners: [...OWNERS],
|
|
225
|
+
tags: ['run', 'tool', 'completed'],
|
|
226
|
+
},
|
|
227
|
+
payload: ToolCompletedPayload,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Message type enum.
|
|
232
|
+
*/
|
|
233
|
+
const MessageTypeEnum = defineEnum('MessageType', ['assistant', 'system']);
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Payload for message generated event.
|
|
237
|
+
*/
|
|
238
|
+
const MessageGeneratedPayload = defineSchemaModel({
|
|
239
|
+
name: 'MessageGeneratedPayload',
|
|
240
|
+
description: 'Payload for message generated event',
|
|
241
|
+
fields: {
|
|
242
|
+
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
243
|
+
stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
244
|
+
messageType: { type: MessageTypeEnum, isOptional: false },
|
|
245
|
+
content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
246
|
+
tokensUsed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
247
|
+
generatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* MessageGeneratedEvent - Agent generated a message.
|
|
253
|
+
*/
|
|
254
|
+
export const MessageGeneratedEvent = defineEvent({
|
|
255
|
+
meta: {
|
|
256
|
+
key: 'agent.run.messageGenerated',
|
|
257
|
+
version: '1.0.0',
|
|
258
|
+
description: 'An agent generated a message during a run.',
|
|
259
|
+
stability: 'stable',
|
|
260
|
+
owners: [...OWNERS],
|
|
261
|
+
tags: ['run', 'message', 'generated'],
|
|
262
|
+
},
|
|
263
|
+
payload: MessageGeneratedPayload,
|
|
264
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock handlers for Run contracts.
|
|
3
|
+
*/
|
|
4
|
+
import { MOCK_RUNS } from '../shared/mock-runs';
|
|
5
|
+
import { MOCK_AGENTS } from '../shared/mock-agents';
|
|
6
|
+
|
|
7
|
+
export interface ListRunsInput {
|
|
8
|
+
organizationId?: string;
|
|
9
|
+
agentId?: string;
|
|
10
|
+
userId?: string;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
status?:
|
|
13
|
+
| 'QUEUED'
|
|
14
|
+
| 'IN_PROGRESS'
|
|
15
|
+
| 'COMPLETED'
|
|
16
|
+
| 'FAILED'
|
|
17
|
+
| 'CANCELLED'
|
|
18
|
+
| 'EXPIRED';
|
|
19
|
+
startDate?: Date;
|
|
20
|
+
endDate?: Date;
|
|
21
|
+
limit?: number;
|
|
22
|
+
offset?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface RunSummary {
|
|
26
|
+
id: string;
|
|
27
|
+
agentId: string;
|
|
28
|
+
agentName: string;
|
|
29
|
+
status:
|
|
30
|
+
| 'QUEUED'
|
|
31
|
+
| 'IN_PROGRESS'
|
|
32
|
+
| 'COMPLETED'
|
|
33
|
+
| 'FAILED'
|
|
34
|
+
| 'CANCELLED'
|
|
35
|
+
| 'EXPIRED';
|
|
36
|
+
totalTokens: number;
|
|
37
|
+
durationMs?: number;
|
|
38
|
+
estimatedCostUsd?: number;
|
|
39
|
+
queuedAt: Date;
|
|
40
|
+
completedAt?: Date;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ListRunsOutput {
|
|
44
|
+
items: RunSummary[];
|
|
45
|
+
total: number;
|
|
46
|
+
hasMore: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Mock handler for ListRunsQuery.
|
|
51
|
+
*/
|
|
52
|
+
export async function mockListRunsHandler(
|
|
53
|
+
input: ListRunsInput
|
|
54
|
+
): Promise<ListRunsOutput> {
|
|
55
|
+
const { agentId, status, limit = 20, offset = 0 } = input;
|
|
56
|
+
|
|
57
|
+
let filtered = [...MOCK_RUNS];
|
|
58
|
+
if (agentId) filtered = filtered.filter((r) => r.agentId === agentId);
|
|
59
|
+
if (status) filtered = filtered.filter((r) => r.status === status);
|
|
60
|
+
|
|
61
|
+
const total = filtered.length;
|
|
62
|
+
const items = filtered.slice(offset, offset + limit).map((r) => {
|
|
63
|
+
const agent = MOCK_AGENTS.find((a) => a.id === r.agentId);
|
|
64
|
+
return {
|
|
65
|
+
id: r.id,
|
|
66
|
+
agentId: r.agentId,
|
|
67
|
+
agentName: agent?.name ?? 'Unknown',
|
|
68
|
+
status: r.status,
|
|
69
|
+
totalTokens: r.totalTokens,
|
|
70
|
+
durationMs: r.durationMs,
|
|
71
|
+
estimatedCostUsd: r.estimatedCostUsd,
|
|
72
|
+
queuedAt: r.queuedAt,
|
|
73
|
+
completedAt: r.completedAt,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return { items, total, hasMore: offset + limit < total };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Mock handler for GetRunQuery.
|
|
82
|
+
*/
|
|
83
|
+
export async function mockGetRunHandler(input: {
|
|
84
|
+
runId: string;
|
|
85
|
+
includeSteps?: boolean;
|
|
86
|
+
includeLogs?: boolean;
|
|
87
|
+
}) {
|
|
88
|
+
const run = MOCK_RUNS.find((r) => r.id === input.runId);
|
|
89
|
+
if (!run) throw new Error('RUN_NOT_FOUND');
|
|
90
|
+
|
|
91
|
+
const agent = MOCK_AGENTS.find((a) => a.id === run.agentId);
|
|
92
|
+
return {
|
|
93
|
+
...run,
|
|
94
|
+
agent: agent
|
|
95
|
+
? {
|
|
96
|
+
id: agent.id,
|
|
97
|
+
name: agent.name,
|
|
98
|
+
modelProvider: agent.modelProvider,
|
|
99
|
+
modelName: agent.modelName,
|
|
100
|
+
}
|
|
101
|
+
: undefined,
|
|
102
|
+
steps: input.includeSteps ? run.steps : undefined,
|
|
103
|
+
logs: input.includeLogs ? run.logs : undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Mock handler for ExecuteAgentCommand.
|
|
109
|
+
*/
|
|
110
|
+
export async function mockExecuteAgentHandler(input: {
|
|
111
|
+
agentId: string;
|
|
112
|
+
input: { message: string; context?: Record<string, unknown> };
|
|
113
|
+
}) {
|
|
114
|
+
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
115
|
+
if (!agent) throw new Error('AGENT_NOT_FOUND');
|
|
116
|
+
if (agent.status !== 'ACTIVE') throw new Error('AGENT_NOT_ACTIVE');
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
runId: `run-${Date.now()}`,
|
|
120
|
+
status: 'QUEUED' as const,
|
|
121
|
+
estimatedWaitMs: 500,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Mock handler for CancelRunCommand.
|
|
127
|
+
*/
|
|
128
|
+
export async function mockCancelRunHandler(input: {
|
|
129
|
+
runId: string;
|
|
130
|
+
reason?: string;
|
|
131
|
+
}) {
|
|
132
|
+
const run = MOCK_RUNS.find((r) => r.id === input.runId);
|
|
133
|
+
if (!run) throw new Error('RUN_NOT_FOUND');
|
|
134
|
+
if (!['QUEUED', 'IN_PROGRESS'].includes(run.status))
|
|
135
|
+
throw new Error('RUN_NOT_CANCELLABLE');
|
|
136
|
+
|
|
137
|
+
return { success: true, status: 'CANCELLED' as const };
|
|
138
|
+
}
|