@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineEntity,
|
|
3
|
+
defineEntityEnum,
|
|
4
|
+
field,
|
|
5
|
+
index,
|
|
6
|
+
} from '@contractspec/lib.schema';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool category enum for entities.
|
|
10
|
+
*/
|
|
11
|
+
export const ToolCategoryEntityEnum = defineEntityEnum({
|
|
12
|
+
name: 'ToolCategory',
|
|
13
|
+
values: [
|
|
14
|
+
'RETRIEVAL',
|
|
15
|
+
'COMPUTATION',
|
|
16
|
+
'COMMUNICATION',
|
|
17
|
+
'INTEGRATION',
|
|
18
|
+
'UTILITY',
|
|
19
|
+
'CUSTOM',
|
|
20
|
+
],
|
|
21
|
+
description: 'Category of tool',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tool status enum for entities.
|
|
26
|
+
*/
|
|
27
|
+
export const ToolStatusEntityEnum = defineEntityEnum({
|
|
28
|
+
name: 'ToolStatus',
|
|
29
|
+
values: ['DRAFT', 'ACTIVE', 'DEPRECATED', 'DISABLED'],
|
|
30
|
+
description: 'Status of tool',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Implementation type enum for entities.
|
|
35
|
+
*/
|
|
36
|
+
export const ImplementationTypeEntityEnum = defineEntityEnum({
|
|
37
|
+
name: 'ImplementationType',
|
|
38
|
+
values: ['http', 'function', 'workflow'],
|
|
39
|
+
description: 'How the tool is implemented',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Tool entity - Represents an AI tool definition.
|
|
44
|
+
*/
|
|
45
|
+
export const ToolEntity = defineEntity({
|
|
46
|
+
name: 'Tool',
|
|
47
|
+
schema: 'agent_console',
|
|
48
|
+
description: 'An AI tool that can be used by agents.',
|
|
49
|
+
fields: {
|
|
50
|
+
id: field.id(),
|
|
51
|
+
organizationId: field.string({
|
|
52
|
+
description: 'Organization that owns this tool',
|
|
53
|
+
}),
|
|
54
|
+
name: field.string({ description: 'Tool name' }),
|
|
55
|
+
slug: field.string({ description: 'URL-safe identifier' }),
|
|
56
|
+
description: field.string({ description: 'Tool description' }),
|
|
57
|
+
category: field.enum('ToolCategory', { default: 'CUSTOM' }),
|
|
58
|
+
status: field.enum('ToolStatus', { default: 'DRAFT' }),
|
|
59
|
+
parametersSchema: field.json({
|
|
60
|
+
description: 'JSON Schema for tool parameters',
|
|
61
|
+
}),
|
|
62
|
+
outputSchema: field.json({
|
|
63
|
+
isOptional: true,
|
|
64
|
+
description: 'JSON Schema for tool output',
|
|
65
|
+
}),
|
|
66
|
+
implementationType: field.enum('ImplementationType'),
|
|
67
|
+
implementationConfig: field.json({
|
|
68
|
+
description: 'Implementation configuration',
|
|
69
|
+
}),
|
|
70
|
+
maxInvocationsPerMinute: field.int({
|
|
71
|
+
isOptional: true,
|
|
72
|
+
description: 'Rate limit',
|
|
73
|
+
}),
|
|
74
|
+
timeoutMs: field.int({ default: 30000, description: 'Execution timeout' }),
|
|
75
|
+
version: field.string({ default: '1.0.0', description: 'Tool version' }),
|
|
76
|
+
tags: field.string({
|
|
77
|
+
isArray: true,
|
|
78
|
+
isOptional: true,
|
|
79
|
+
description: 'Tags for categorization',
|
|
80
|
+
}),
|
|
81
|
+
createdAt: field.createdAt(),
|
|
82
|
+
updatedAt: field.updatedAt(),
|
|
83
|
+
createdById: field.string({
|
|
84
|
+
isOptional: true,
|
|
85
|
+
description: 'User who created this tool',
|
|
86
|
+
}),
|
|
87
|
+
agents: field.hasMany('Agent', { description: 'Agents using this tool' }),
|
|
88
|
+
},
|
|
89
|
+
indexes: [
|
|
90
|
+
index.unique(['organizationId', 'slug']),
|
|
91
|
+
index.on(['organizationId', 'category']),
|
|
92
|
+
index.on(['organizationId', 'status']),
|
|
93
|
+
],
|
|
94
|
+
enums: [
|
|
95
|
+
ToolCategoryEntityEnum,
|
|
96
|
+
ToolStatusEntityEnum,
|
|
97
|
+
ImplementationTypeEntityEnum,
|
|
98
|
+
],
|
|
99
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineEnum } from '@contractspec/lib.schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tool category enum.
|
|
5
|
+
*/
|
|
6
|
+
export const ToolCategoryEnum = defineEnum('ToolCategory', [
|
|
7
|
+
'RETRIEVAL',
|
|
8
|
+
'COMPUTATION',
|
|
9
|
+
'COMMUNICATION',
|
|
10
|
+
'INTEGRATION',
|
|
11
|
+
'UTILITY',
|
|
12
|
+
'CUSTOM',
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Tool status enum.
|
|
17
|
+
*/
|
|
18
|
+
export const ToolStatusEnum = defineEnum('ToolStatus', [
|
|
19
|
+
'DRAFT',
|
|
20
|
+
'ACTIVE',
|
|
21
|
+
'DEPRECATED',
|
|
22
|
+
'DISABLED',
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Implementation type enum.
|
|
27
|
+
*/
|
|
28
|
+
export const ImplementationTypeEnum = defineEnum('ImplementationType', [
|
|
29
|
+
'http',
|
|
30
|
+
'function',
|
|
31
|
+
'workflow',
|
|
32
|
+
]);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineEvent, defineSchemaModel } from '@contractspec/lib.contracts';
|
|
2
|
+
import { ScalarTypeEnum } from '@contractspec/lib.schema';
|
|
3
|
+
|
|
4
|
+
const OWNERS = ['@agent-console-team'] as const;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Payload for tool created event.
|
|
8
|
+
*/
|
|
9
|
+
const ToolCreatedPayload = defineSchemaModel({
|
|
10
|
+
name: 'ToolCreatedPayload',
|
|
11
|
+
description: 'Payload for tool created event',
|
|
12
|
+
fields: {
|
|
13
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
organizationId: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false,
|
|
17
|
+
},
|
|
18
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
19
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
implementationType: {
|
|
22
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
23
|
+
isOptional: false,
|
|
24
|
+
},
|
|
25
|
+
createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
26
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ToolCreatedEvent - A new tool was created.
|
|
32
|
+
*/
|
|
33
|
+
export const ToolCreatedEvent = defineEvent({
|
|
34
|
+
meta: {
|
|
35
|
+
key: 'agent.tool.created',
|
|
36
|
+
version: '1.0.0',
|
|
37
|
+
description: 'A new AI tool was created.',
|
|
38
|
+
stability: 'stable',
|
|
39
|
+
owners: [...OWNERS],
|
|
40
|
+
tags: ['tool', 'created'],
|
|
41
|
+
},
|
|
42
|
+
payload: ToolCreatedPayload,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Payload for tool updated event.
|
|
47
|
+
*/
|
|
48
|
+
const ToolUpdatedPayload = defineSchemaModel({
|
|
49
|
+
name: 'ToolUpdatedPayload',
|
|
50
|
+
description: 'Payload for tool updated event',
|
|
51
|
+
fields: {
|
|
52
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
53
|
+
organizationId: {
|
|
54
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
55
|
+
isOptional: false,
|
|
56
|
+
},
|
|
57
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
58
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
59
|
+
updatedFields: {
|
|
60
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
61
|
+
isArray: true,
|
|
62
|
+
isOptional: false,
|
|
63
|
+
},
|
|
64
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* ToolUpdatedEvent - A tool was updated.
|
|
70
|
+
*/
|
|
71
|
+
export const ToolUpdatedEvent = defineEvent({
|
|
72
|
+
meta: {
|
|
73
|
+
key: 'agent.tool.updated',
|
|
74
|
+
version: '1.0.0',
|
|
75
|
+
description: 'An AI tool configuration was updated.',
|
|
76
|
+
stability: 'stable',
|
|
77
|
+
owners: [...OWNERS],
|
|
78
|
+
tags: ['tool', 'updated'],
|
|
79
|
+
},
|
|
80
|
+
payload: ToolUpdatedPayload,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Payload for tool status changed event.
|
|
85
|
+
*/
|
|
86
|
+
const ToolStatusChangedPayload = defineSchemaModel({
|
|
87
|
+
name: 'ToolStatusChangedPayload',
|
|
88
|
+
description: 'Payload for tool status changed event',
|
|
89
|
+
fields: {
|
|
90
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
91
|
+
organizationId: {
|
|
92
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
93
|
+
isOptional: false,
|
|
94
|
+
},
|
|
95
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
96
|
+
previousStatus: {
|
|
97
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
98
|
+
isOptional: false,
|
|
99
|
+
},
|
|
100
|
+
newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
101
|
+
changedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* ToolStatusChangedEvent - A tool's status was changed.
|
|
107
|
+
*/
|
|
108
|
+
export const ToolStatusChangedEvent = defineEvent({
|
|
109
|
+
meta: {
|
|
110
|
+
key: 'agent.tool.statusChanged',
|
|
111
|
+
version: '1.0.0',
|
|
112
|
+
description:
|
|
113
|
+
'An AI tool status was changed (activated, deprecated, disabled).',
|
|
114
|
+
stability: 'stable',
|
|
115
|
+
owners: [...OWNERS],
|
|
116
|
+
tags: ['tool', 'status'],
|
|
117
|
+
},
|
|
118
|
+
payload: ToolStatusChangedPayload,
|
|
119
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock handlers for Tool contracts.
|
|
3
|
+
*/
|
|
4
|
+
import { MOCK_TOOLS } from '../shared/mock-tools';
|
|
5
|
+
|
|
6
|
+
export interface ListToolsInput {
|
|
7
|
+
organizationId: string;
|
|
8
|
+
category?:
|
|
9
|
+
| 'RETRIEVAL'
|
|
10
|
+
| 'COMPUTATION'
|
|
11
|
+
| 'COMMUNICATION'
|
|
12
|
+
| 'INTEGRATION'
|
|
13
|
+
| 'UTILITY'
|
|
14
|
+
| 'CUSTOM';
|
|
15
|
+
status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
|
|
16
|
+
search?: string;
|
|
17
|
+
limit?: number;
|
|
18
|
+
offset?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ToolSummary {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
slug: string;
|
|
25
|
+
description: string;
|
|
26
|
+
category:
|
|
27
|
+
| 'RETRIEVAL'
|
|
28
|
+
| 'COMPUTATION'
|
|
29
|
+
| 'COMMUNICATION'
|
|
30
|
+
| 'INTEGRATION'
|
|
31
|
+
| 'UTILITY'
|
|
32
|
+
| 'CUSTOM';
|
|
33
|
+
status: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
|
|
34
|
+
version: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ListToolsOutput {
|
|
39
|
+
items: ToolSummary[];
|
|
40
|
+
total: number;
|
|
41
|
+
hasMore: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Mock handler for ListToolsQuery.
|
|
46
|
+
*/
|
|
47
|
+
export async function mockListToolsHandler(
|
|
48
|
+
input: ListToolsInput
|
|
49
|
+
): Promise<ListToolsOutput> {
|
|
50
|
+
const {
|
|
51
|
+
organizationId,
|
|
52
|
+
category,
|
|
53
|
+
status,
|
|
54
|
+
search,
|
|
55
|
+
limit = 20,
|
|
56
|
+
offset = 0,
|
|
57
|
+
} = input;
|
|
58
|
+
|
|
59
|
+
let filtered = MOCK_TOOLS.filter((t) => t.organizationId === organizationId);
|
|
60
|
+
if (category) filtered = filtered.filter((t) => t.category === category);
|
|
61
|
+
if (status) filtered = filtered.filter((t) => t.status === status);
|
|
62
|
+
if (search) {
|
|
63
|
+
const q = search.toLowerCase();
|
|
64
|
+
filtered = filtered.filter(
|
|
65
|
+
(t) =>
|
|
66
|
+
t.name.toLowerCase().includes(q) ||
|
|
67
|
+
t.description.toLowerCase().includes(q)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const total = filtered.length;
|
|
72
|
+
const items = filtered.slice(offset, offset + limit).map((t) => ({
|
|
73
|
+
id: t.id,
|
|
74
|
+
name: t.name,
|
|
75
|
+
slug: t.slug,
|
|
76
|
+
description: t.description,
|
|
77
|
+
category: t.category,
|
|
78
|
+
status: t.status,
|
|
79
|
+
version: t.version,
|
|
80
|
+
createdAt: t.createdAt,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
return { items, total, hasMore: offset + limit < total };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Mock handler for GetToolQuery.
|
|
88
|
+
*/
|
|
89
|
+
export async function mockGetToolHandler(input: { toolId: string }) {
|
|
90
|
+
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
91
|
+
if (!tool) throw new Error('TOOL_NOT_FOUND');
|
|
92
|
+
return tool;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Mock handler for CreateToolCommand.
|
|
97
|
+
*/
|
|
98
|
+
export async function mockCreateToolHandler(input: {
|
|
99
|
+
organizationId: string;
|
|
100
|
+
name: string;
|
|
101
|
+
slug: string;
|
|
102
|
+
description: string;
|
|
103
|
+
implementationType: 'http' | 'function' | 'workflow';
|
|
104
|
+
}) {
|
|
105
|
+
const exists = MOCK_TOOLS.some(
|
|
106
|
+
(t) => t.organizationId === input.organizationId && t.slug === input.slug
|
|
107
|
+
);
|
|
108
|
+
if (exists) throw new Error('SLUG_EXISTS');
|
|
109
|
+
return {
|
|
110
|
+
id: `tool-${Date.now()}`,
|
|
111
|
+
name: input.name,
|
|
112
|
+
slug: input.slug,
|
|
113
|
+
status: 'DRAFT' as const,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Mock handler for UpdateToolCommand.
|
|
119
|
+
*/
|
|
120
|
+
export async function mockUpdateToolHandler(input: {
|
|
121
|
+
toolId: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
|
|
124
|
+
}) {
|
|
125
|
+
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
126
|
+
if (!tool) throw new Error('TOOL_NOT_FOUND');
|
|
127
|
+
return {
|
|
128
|
+
id: tool.id,
|
|
129
|
+
name: input.name ?? tool.name,
|
|
130
|
+
status: input.status ?? tool.status,
|
|
131
|
+
updatedAt: new Date(),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Mock handler for TestToolCommand.
|
|
137
|
+
*/
|
|
138
|
+
export async function mockTestToolHandler(input: {
|
|
139
|
+
toolId: string;
|
|
140
|
+
testInput: Record<string, unknown>;
|
|
141
|
+
}) {
|
|
142
|
+
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
143
|
+
if (!tool) throw new Error('TOOL_NOT_FOUND');
|
|
144
|
+
|
|
145
|
+
// Simulate tool execution
|
|
146
|
+
const startTime = Date.now();
|
|
147
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
success: true,
|
|
151
|
+
output: { result: 'Test successful', input: input.testInput },
|
|
152
|
+
durationMs: Date.now() - startTime,
|
|
153
|
+
};
|
|
154
|
+
}
|