@contractspec/example.agent-console 3.8.9 → 3.8.10
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 +225 -222
- package/CHANGELOG.md +18 -0
- package/dist/agent/agent.entity.js +1 -127
- package/dist/agent/agent.enum.js +1 -25
- package/dist/agent/agent.event.js +1 -116
- package/dist/agent/agent.handler.js +1 -1030
- package/dist/agent/agent.operation.js +1 -735
- package/dist/agent/agent.presentation.js +1 -282
- package/dist/agent/agent.schema.js +1 -215
- package/dist/agent/agent.test-spec.js +1 -58
- package/dist/agent/index.js +1 -1248
- package/dist/agent.capability.js +1 -19
- package/dist/agent.feature.js +1 -305
- package/dist/browser/agent/agent.entity.js +1 -127
- package/dist/browser/agent/agent.enum.js +1 -25
- package/dist/browser/agent/agent.event.js +1 -116
- package/dist/browser/agent/agent.handler.js +1 -1030
- package/dist/browser/agent/agent.operation.js +1 -735
- package/dist/browser/agent/agent.presentation.js +1 -282
- package/dist/browser/agent/agent.schema.js +1 -215
- package/dist/browser/agent/agent.test-spec.js +1 -58
- package/dist/browser/agent/index.js +1 -1248
- package/dist/browser/agent.capability.js +1 -19
- package/dist/browser/agent.feature.js +1 -305
- package/dist/browser/docs/agent-console.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/example.js +1 -41
- package/dist/browser/handlers/agent.handlers.js +6 -2143
- package/dist/browser/handlers/index.js +6 -2943
- package/dist/browser/index.js +14 -6828
- package/dist/browser/presentations/index.js +1 -693
- package/dist/browser/run/index.js +1 -1363
- package/dist/browser/run/run.entity.js +1 -160
- package/dist/browser/run/run.enum.js +1 -34
- package/dist/browser/run/run.event.js +1 -217
- package/dist/browser/run/run.handler.js +1 -919
- package/dist/browser/run/run.operation.js +1 -667
- package/dist/browser/run/run.presentation.js +1 -223
- package/dist/browser/run/run.schema.js +1 -179
- package/dist/browser/run/run.test-spec.js +1 -58
- package/dist/browser/seeders/index.js +2 -21
- package/dist/browser/shared/index.js +1 -626
- package/dist/browser/shared/mock-agents.js +1 -82
- package/dist/browser/shared/mock-runs.js +1 -113
- package/dist/browser/shared/mock-tools.js +1 -146
- package/dist/browser/tool/index.js +1 -949
- package/dist/browser/tool/tool.entity.js +1 -90
- package/dist/browser/tool/tool.enum.js +1 -26
- package/dist/browser/tool/tool.event.js +1 -99
- package/dist/browser/tool/tool.handler.js +1 -699
- package/dist/browser/tool/tool.operation.js +1 -482
- package/dist/browser/tool/tool.presentation.js +1 -188
- package/dist/browser/tool/tool.schema.js +1 -141
- package/dist/browser/tool/tool.test-spec.js +1 -58
- package/dist/browser/ui/AgentDashboard.js +1 -2527
- package/dist/browser/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/browser/ui/AgentRunList.js +1 -482
- package/dist/browser/ui/AgentToolRegistry.js +1 -212
- package/dist/browser/ui/ExecutionConsoleHost.js +1 -0
- package/dist/browser/ui/hooks/index.js +1 -740
- package/dist/browser/ui/hooks/useAgentList.js +1 -55
- package/dist/browser/ui/hooks/useAgentMutations.js +1 -530
- package/dist/browser/ui/hooks/useRunList.js +1 -70
- package/dist/browser/ui/hooks/useToolList.js +1 -85
- package/dist/browser/ui/index.js +5 -3018
- package/dist/browser/ui/modals/AgentActionsModal.js +1 -304
- package/dist/browser/ui/modals/CreateAgentModal.js +1 -243
- package/dist/browser/ui/modals/index.js +1 -546
- package/dist/browser/ui/overlays/demo-overlays.js +1 -64
- package/dist/browser/ui/overlays/index.js +1 -64
- package/dist/browser/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/browser/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/browser/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/browser/ui/renderers/index.js +5 -642
- package/dist/browser/ui/renderers/run-list.markdown.js +2 -50
- package/dist/browser/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/browser/ui/views/AgentListView.js +1 -165
- package/dist/browser/ui/views/RunDataTable.js +1 -326
- package/dist/browser/ui/views/RunListView.js +1 -479
- package/dist/browser/ui/views/ToolRegistryView.js +1 -209
- package/dist/browser/ui/views/index.js +1 -851
- package/dist/browser/ui/views/run-data-table.columns.js +1 -271
- package/dist/browser/ui/views/run-list.shared.js +1 -177
- package/dist/browser/visualizations/catalog.js +1 -134
- package/dist/browser/visualizations/index.js +1 -187
- package/dist/browser/visualizations/selectors.js +1 -181
- package/dist/docs/agent-console.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/example.js +1 -41
- package/dist/handlers/agent.handlers.js +6 -2143
- package/dist/handlers/index.js +6 -2943
- package/dist/index.js +14 -6828
- package/dist/node/agent/agent.entity.js +1 -127
- package/dist/node/agent/agent.enum.js +1 -25
- package/dist/node/agent/agent.event.js +1 -116
- package/dist/node/agent/agent.handler.js +1 -1030
- package/dist/node/agent/agent.operation.js +1 -735
- package/dist/node/agent/agent.presentation.js +1 -282
- package/dist/node/agent/agent.schema.js +1 -215
- package/dist/node/agent/agent.test-spec.js +1 -58
- package/dist/node/agent/index.js +1 -1248
- package/dist/node/agent.capability.js +1 -19
- package/dist/node/agent.feature.js +1 -305
- package/dist/node/docs/agent-console.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/example.js +1 -41
- package/dist/node/handlers/agent.handlers.js +6 -2143
- package/dist/node/handlers/index.js +6 -2943
- package/dist/node/index.js +14 -6828
- package/dist/node/presentations/index.js +1 -693
- package/dist/node/run/index.js +1 -1363
- package/dist/node/run/run.entity.js +1 -160
- package/dist/node/run/run.enum.js +1 -34
- package/dist/node/run/run.event.js +1 -217
- package/dist/node/run/run.handler.js +1 -919
- package/dist/node/run/run.operation.js +1 -667
- package/dist/node/run/run.presentation.js +1 -223
- package/dist/node/run/run.schema.js +1 -179
- package/dist/node/run/run.test-spec.js +1 -58
- package/dist/node/seeders/index.js +2 -21
- package/dist/node/shared/index.js +1 -626
- package/dist/node/shared/mock-agents.js +1 -82
- package/dist/node/shared/mock-runs.js +1 -113
- package/dist/node/shared/mock-tools.js +1 -146
- package/dist/node/tool/index.js +1 -949
- package/dist/node/tool/tool.entity.js +1 -90
- package/dist/node/tool/tool.enum.js +1 -26
- package/dist/node/tool/tool.event.js +1 -99
- package/dist/node/tool/tool.handler.js +1 -699
- package/dist/node/tool/tool.operation.js +1 -482
- package/dist/node/tool/tool.presentation.js +1 -188
- package/dist/node/tool/tool.schema.js +1 -141
- package/dist/node/tool/tool.test-spec.js +1 -58
- package/dist/node/ui/AgentDashboard.js +1 -2527
- package/dist/node/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/node/ui/AgentRunList.js +1 -482
- package/dist/node/ui/AgentToolRegistry.js +1 -212
- package/dist/node/ui/ExecutionConsoleHost.js +1 -0
- package/dist/node/ui/hooks/index.js +1 -740
- package/dist/node/ui/hooks/useAgentList.js +1 -55
- package/dist/node/ui/hooks/useAgentMutations.js +1 -530
- package/dist/node/ui/hooks/useRunList.js +1 -70
- package/dist/node/ui/hooks/useToolList.js +1 -85
- package/dist/node/ui/index.js +5 -3018
- package/dist/node/ui/modals/AgentActionsModal.js +1 -304
- package/dist/node/ui/modals/CreateAgentModal.js +1 -243
- package/dist/node/ui/modals/index.js +1 -546
- package/dist/node/ui/overlays/demo-overlays.js +1 -64
- package/dist/node/ui/overlays/index.js +1 -64
- package/dist/node/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/node/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/node/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/node/ui/renderers/index.js +5 -642
- package/dist/node/ui/renderers/run-list.markdown.js +2 -50
- package/dist/node/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/node/ui/views/AgentListView.js +1 -165
- package/dist/node/ui/views/RunDataTable.js +1 -326
- package/dist/node/ui/views/RunListView.js +1 -479
- package/dist/node/ui/views/ToolRegistryView.js +1 -209
- package/dist/node/ui/views/index.js +1 -851
- package/dist/node/ui/views/run-data-table.columns.js +1 -271
- package/dist/node/ui/views/run-list.shared.js +1 -177
- package/dist/node/visualizations/catalog.js +1 -134
- package/dist/node/visualizations/index.js +1 -187
- package/dist/node/visualizations/selectors.js +1 -181
- package/dist/presentations/index.js +1 -693
- package/dist/run/index.js +1 -1363
- package/dist/run/run.entity.js +1 -160
- package/dist/run/run.enum.js +1 -34
- package/dist/run/run.event.js +1 -217
- package/dist/run/run.handler.js +1 -919
- package/dist/run/run.operation.js +1 -667
- package/dist/run/run.presentation.js +1 -223
- package/dist/run/run.schema.js +1 -179
- package/dist/run/run.test-spec.js +1 -58
- package/dist/seeders/index.js +2 -21
- package/dist/shared/index.js +1 -626
- package/dist/shared/mock-agents.js +1 -82
- package/dist/shared/mock-runs.js +1 -113
- package/dist/shared/mock-tools.js +1 -146
- package/dist/tool/index.js +1 -949
- package/dist/tool/tool.entity.js +1 -90
- package/dist/tool/tool.enum.js +1 -26
- package/dist/tool/tool.event.js +1 -99
- package/dist/tool/tool.handler.js +1 -699
- package/dist/tool/tool.operation.js +1 -482
- package/dist/tool/tool.presentation.js +1 -188
- package/dist/tool/tool.schema.js +1 -141
- package/dist/tool/tool.test-spec.js +1 -58
- package/dist/ui/AgentDashboard.js +1 -2527
- package/dist/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/ui/AgentRunList.js +1 -482
- package/dist/ui/AgentToolRegistry.js +1 -212
- package/dist/ui/ExecutionConsoleHost.d.ts +1 -0
- package/dist/ui/ExecutionConsoleHost.js +2 -0
- package/dist/ui/ExecutionConsoleHost.test.d.ts +1 -0
- package/dist/ui/hooks/index.js +1 -740
- package/dist/ui/hooks/useAgentList.js +1 -55
- package/dist/ui/hooks/useAgentMutations.js +1 -530
- package/dist/ui/hooks/useRunList.js +1 -70
- package/dist/ui/hooks/useToolList.js +1 -85
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +5 -3018
- package/dist/ui/modals/AgentActionsModal.js +1 -304
- package/dist/ui/modals/CreateAgentModal.js +1 -243
- package/dist/ui/modals/index.js +1 -546
- package/dist/ui/overlays/demo-overlays.js +1 -64
- package/dist/ui/overlays/index.js +1 -64
- package/dist/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/ui/renderers/index.js +5 -642
- package/dist/ui/renderers/run-list.markdown.js +2 -50
- package/dist/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/ui/views/AgentListView.js +1 -165
- package/dist/ui/views/RunDataTable.js +1 -326
- package/dist/ui/views/RunListView.js +1 -479
- package/dist/ui/views/ToolRegistryView.js +1 -209
- package/dist/ui/views/index.js +1 -851
- package/dist/ui/views/run-data-table.columns.js +1 -271
- package/dist/ui/views/run-list.shared.js +1 -177
- package/dist/visualizations/catalog.js +1 -134
- package/dist/visualizations/index.js +1 -187
- package/dist/visualizations/selectors.js +1 -181
- package/package.json +26 -10
- package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
- package/src/ui/ExecutionConsoleHost.tsx +14 -0
- package/src/ui/index.ts +1 -1
package/dist/tool/index.js
CHANGED
|
@@ -1,950 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/shared/mock-tools.ts
|
|
3
|
-
var MOCK_TOOLS = [
|
|
4
|
-
{
|
|
5
|
-
id: "tool-1",
|
|
6
|
-
organizationId: "demo-org",
|
|
7
|
-
name: "Web Search",
|
|
8
|
-
slug: "web-search",
|
|
9
|
-
description: "Search the web for real-time information using Brave API.",
|
|
10
|
-
category: "RETRIEVAL",
|
|
11
|
-
status: "ACTIVE",
|
|
12
|
-
parametersSchema: {
|
|
13
|
-
type: "object",
|
|
14
|
-
properties: {
|
|
15
|
-
query: { type: "string", description: "Search query" },
|
|
16
|
-
numResults: { type: "number", default: 10 }
|
|
17
|
-
},
|
|
18
|
-
required: ["query"]
|
|
19
|
-
},
|
|
20
|
-
outputSchema: { type: "array", items: { type: "object" } },
|
|
21
|
-
implementationType: "http",
|
|
22
|
-
implementationConfig: {
|
|
23
|
-
url: "https://api.brave.com/search",
|
|
24
|
-
method: "GET"
|
|
25
|
-
},
|
|
26
|
-
maxInvocationsPerMinute: 60,
|
|
27
|
-
timeoutMs: 30000,
|
|
28
|
-
version: "1.0.0",
|
|
29
|
-
tags: ["search", "web"],
|
|
30
|
-
createdAt: new Date("2024-01-01T00:00:00Z"),
|
|
31
|
-
updatedAt: new Date("2024-02-15T10:00:00Z")
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: "tool-2",
|
|
35
|
-
organizationId: "demo-org",
|
|
36
|
-
name: "SQL Query",
|
|
37
|
-
slug: "sql-query",
|
|
38
|
-
description: "Execute read-only SQL queries against the data warehouse.",
|
|
39
|
-
category: "RETRIEVAL",
|
|
40
|
-
status: "ACTIVE",
|
|
41
|
-
parametersSchema: {
|
|
42
|
-
type: "object",
|
|
43
|
-
properties: {
|
|
44
|
-
query: { type: "string", description: "SQL query" },
|
|
45
|
-
maxRows: { type: "number", default: 100 }
|
|
46
|
-
},
|
|
47
|
-
required: ["query"]
|
|
48
|
-
},
|
|
49
|
-
outputSchema: { type: "object" },
|
|
50
|
-
implementationType: "function",
|
|
51
|
-
implementationConfig: { handler: "executeSqlQuery" },
|
|
52
|
-
maxInvocationsPerMinute: 30,
|
|
53
|
-
timeoutMs: 60000,
|
|
54
|
-
version: "1.1.0",
|
|
55
|
-
tags: ["sql", "database"],
|
|
56
|
-
createdAt: new Date("2024-01-05T00:00:00Z"),
|
|
57
|
-
updatedAt: new Date("2024-03-10T14:00:00Z")
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: "tool-3",
|
|
61
|
-
organizationId: "demo-org",
|
|
62
|
-
name: "Email Sender",
|
|
63
|
-
slug: "email-sender",
|
|
64
|
-
description: "Send emails via SMTP or API.",
|
|
65
|
-
category: "COMMUNICATION",
|
|
66
|
-
status: "ACTIVE",
|
|
67
|
-
parametersSchema: {
|
|
68
|
-
type: "object",
|
|
69
|
-
properties: {
|
|
70
|
-
to: { type: "string" },
|
|
71
|
-
subject: { type: "string" },
|
|
72
|
-
body: { type: "string" }
|
|
73
|
-
},
|
|
74
|
-
required: ["to", "subject", "body"]
|
|
75
|
-
},
|
|
76
|
-
implementationType: "http",
|
|
77
|
-
implementationConfig: { url: "/api/send-email", method: "POST" },
|
|
78
|
-
maxInvocationsPerMinute: 10,
|
|
79
|
-
timeoutMs: 30000,
|
|
80
|
-
version: "1.0.0",
|
|
81
|
-
tags: ["email", "communication"],
|
|
82
|
-
createdAt: new Date("2024-02-01T00:00:00Z"),
|
|
83
|
-
updatedAt: new Date("2024-02-01T00:00:00Z")
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: "tool-4",
|
|
87
|
-
organizationId: "demo-org",
|
|
88
|
-
name: "GitHub Integration",
|
|
89
|
-
slug: "github-integration",
|
|
90
|
-
description: "Interact with GitHub repositories, PRs, and issues.",
|
|
91
|
-
category: "INTEGRATION",
|
|
92
|
-
status: "ACTIVE",
|
|
93
|
-
parametersSchema: {
|
|
94
|
-
type: "object",
|
|
95
|
-
properties: {
|
|
96
|
-
action: {
|
|
97
|
-
type: "string",
|
|
98
|
-
enum: ["list_prs", "get_pr", "create_comment"]
|
|
99
|
-
},
|
|
100
|
-
repo: { type: "string" },
|
|
101
|
-
params: { type: "object" }
|
|
102
|
-
},
|
|
103
|
-
required: ["action", "repo"]
|
|
104
|
-
},
|
|
105
|
-
implementationType: "http",
|
|
106
|
-
implementationConfig: { url: "https://api.github.com", auth: "token" },
|
|
107
|
-
maxInvocationsPerMinute: 100,
|
|
108
|
-
timeoutMs: 15000,
|
|
109
|
-
version: "2.0.0",
|
|
110
|
-
tags: ["github", "integration", "code"],
|
|
111
|
-
createdAt: new Date("2024-02-20T00:00:00Z"),
|
|
112
|
-
updatedAt: new Date("2024-04-01T09:00:00Z")
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
id: "tool-5",
|
|
116
|
-
organizationId: "demo-org",
|
|
117
|
-
name: "Calculator",
|
|
118
|
-
slug: "calculator",
|
|
119
|
-
description: "Perform mathematical calculations.",
|
|
120
|
-
category: "COMPUTATION",
|
|
121
|
-
status: "ACTIVE",
|
|
122
|
-
parametersSchema: {
|
|
123
|
-
type: "object",
|
|
124
|
-
properties: {
|
|
125
|
-
expression: {
|
|
126
|
-
type: "string",
|
|
127
|
-
description: "Math expression to evaluate"
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
required: ["expression"]
|
|
131
|
-
},
|
|
132
|
-
outputSchema: {
|
|
133
|
-
type: "object",
|
|
134
|
-
properties: { result: { type: "number" } }
|
|
135
|
-
},
|
|
136
|
-
implementationType: "function",
|
|
137
|
-
implementationConfig: { handler: "evaluateMath" },
|
|
138
|
-
timeoutMs: 5000,
|
|
139
|
-
version: "1.0.0",
|
|
140
|
-
tags: ["math", "utility"],
|
|
141
|
-
createdAt: new Date("2024-01-10T00:00:00Z"),
|
|
142
|
-
updatedAt: new Date("2024-01-10T00:00:00Z")
|
|
143
|
-
}
|
|
144
|
-
];
|
|
145
|
-
|
|
146
|
-
// src/tool/tool.enum.ts
|
|
147
|
-
import { defineEnum } from "@contractspec/lib.schema";
|
|
148
|
-
var ToolCategoryEnum = defineEnum("ToolCategory", [
|
|
149
|
-
"RETRIEVAL",
|
|
150
|
-
"COMPUTATION",
|
|
151
|
-
"COMMUNICATION",
|
|
152
|
-
"INTEGRATION",
|
|
153
|
-
"UTILITY",
|
|
154
|
-
"CUSTOM"
|
|
155
|
-
]);
|
|
156
|
-
var ToolStatusEnum = defineEnum("ToolStatus", [
|
|
157
|
-
"DRAFT",
|
|
158
|
-
"ACTIVE",
|
|
159
|
-
"DEPRECATED",
|
|
160
|
-
"DISABLED"
|
|
161
|
-
]);
|
|
162
|
-
var ImplementationTypeEnum = defineEnum("ImplementationType", [
|
|
163
|
-
"http",
|
|
164
|
-
"function",
|
|
165
|
-
"workflow"
|
|
166
|
-
]);
|
|
167
|
-
|
|
168
|
-
// src/tool/tool.schema.ts
|
|
169
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
170
|
-
var ToolModel = defineSchemaModel({
|
|
171
|
-
name: "Tool",
|
|
172
|
-
description: "AI tool definition",
|
|
173
|
-
fields: {
|
|
174
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
175
|
-
organizationId: {
|
|
176
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
177
|
-
isOptional: false
|
|
178
|
-
},
|
|
179
|
-
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
180
|
-
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
181
|
-
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
182
|
-
category: { type: ToolCategoryEnum, isOptional: false },
|
|
183
|
-
status: { type: ToolStatusEnum, isOptional: false },
|
|
184
|
-
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
185
|
-
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
186
|
-
implementationType: { type: ImplementationTypeEnum, isOptional: false },
|
|
187
|
-
implementationConfig: {
|
|
188
|
-
type: ScalarTypeEnum.JSONObject(),
|
|
189
|
-
isOptional: false
|
|
190
|
-
},
|
|
191
|
-
maxInvocationsPerMinute: {
|
|
192
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
193
|
-
isOptional: true
|
|
194
|
-
},
|
|
195
|
-
timeoutMs: {
|
|
196
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
197
|
-
isOptional: false,
|
|
198
|
-
defaultValue: 30000
|
|
199
|
-
},
|
|
200
|
-
version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
201
|
-
tags: {
|
|
202
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
203
|
-
isArray: true,
|
|
204
|
-
isOptional: true
|
|
205
|
-
},
|
|
206
|
-
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
207
|
-
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
var ToolSummaryModel = defineSchemaModel({
|
|
211
|
-
name: "ToolSummary",
|
|
212
|
-
description: "Summary of a tool for list views",
|
|
213
|
-
fields: {
|
|
214
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
215
|
-
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
216
|
-
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
217
|
-
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
218
|
-
category: { type: ToolCategoryEnum, isOptional: false },
|
|
219
|
-
status: { type: ToolStatusEnum, isOptional: false },
|
|
220
|
-
version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
221
|
-
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
var CreateToolInputModel = defineSchemaModel({
|
|
225
|
-
name: "CreateToolInput",
|
|
226
|
-
description: "Input for creating a tool",
|
|
227
|
-
fields: {
|
|
228
|
-
organizationId: {
|
|
229
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
230
|
-
isOptional: false
|
|
231
|
-
},
|
|
232
|
-
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
233
|
-
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
234
|
-
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
235
|
-
category: { type: ToolCategoryEnum, isOptional: true },
|
|
236
|
-
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
237
|
-
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
238
|
-
implementationType: { type: ImplementationTypeEnum, isOptional: false },
|
|
239
|
-
implementationConfig: {
|
|
240
|
-
type: ScalarTypeEnum.JSONObject(),
|
|
241
|
-
isOptional: false
|
|
242
|
-
},
|
|
243
|
-
maxInvocationsPerMinute: {
|
|
244
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
245
|
-
isOptional: true
|
|
246
|
-
},
|
|
247
|
-
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
248
|
-
tags: {
|
|
249
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
250
|
-
isArray: true,
|
|
251
|
-
isOptional: true
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
var UpdateToolInputModel = defineSchemaModel({
|
|
256
|
-
name: "UpdateToolInput",
|
|
257
|
-
description: "Input for updating a tool",
|
|
258
|
-
fields: {
|
|
259
|
-
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
260
|
-
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: true },
|
|
261
|
-
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
262
|
-
status: { type: ToolStatusEnum, isOptional: true },
|
|
263
|
-
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
264
|
-
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
265
|
-
implementationConfig: {
|
|
266
|
-
type: ScalarTypeEnum.JSONObject(),
|
|
267
|
-
isOptional: true
|
|
268
|
-
},
|
|
269
|
-
maxInvocationsPerMinute: {
|
|
270
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
271
|
-
isOptional: true
|
|
272
|
-
},
|
|
273
|
-
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
274
|
-
tags: {
|
|
275
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
276
|
-
isArray: true,
|
|
277
|
-
isOptional: true
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// src/tool/tool.operation.ts
|
|
283
|
-
import {
|
|
284
|
-
defineCommand,
|
|
285
|
-
defineQuery
|
|
286
|
-
} from "@contractspec/lib.contracts-spec/operations";
|
|
287
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
288
|
-
var OWNERS = ["@agent-console-team"];
|
|
289
|
-
var CreateToolCommand = defineCommand({
|
|
290
|
-
meta: {
|
|
291
|
-
key: "agent.tool.create",
|
|
292
|
-
version: "1.0.0",
|
|
293
|
-
stability: "stable",
|
|
294
|
-
owners: [...OWNERS],
|
|
295
|
-
tags: ["tool", "create"],
|
|
296
|
-
description: "Creates a new AI tool definition.",
|
|
297
|
-
goal: "Allow users to define new tools that agents can use.",
|
|
298
|
-
context: "Called from the tool builder UI when creating a new tool."
|
|
299
|
-
},
|
|
300
|
-
io: {
|
|
301
|
-
input: CreateToolInputModel,
|
|
302
|
-
output: defineSchemaModel2({
|
|
303
|
-
name: "CreateToolOutput",
|
|
304
|
-
fields: {
|
|
305
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
306
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
307
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
308
|
-
status: { type: ToolStatusEnum, isOptional: false }
|
|
309
|
-
}
|
|
310
|
-
}),
|
|
311
|
-
errors: {
|
|
312
|
-
SLUG_EXISTS: {
|
|
313
|
-
description: "A tool with this slug already exists in the organization",
|
|
314
|
-
http: 409,
|
|
315
|
-
gqlCode: "SLUG_EXISTS",
|
|
316
|
-
when: "Slug is already taken"
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
policy: { auth: "user" },
|
|
321
|
-
sideEffects: {
|
|
322
|
-
emits: [
|
|
323
|
-
{
|
|
324
|
-
key: "tool.created",
|
|
325
|
-
version: "1.0.0",
|
|
326
|
-
stability: "stable",
|
|
327
|
-
owners: [...OWNERS],
|
|
328
|
-
tags: ["tool", "created"],
|
|
329
|
-
when: "Tool is successfully created",
|
|
330
|
-
payload: ToolSummaryModel
|
|
331
|
-
}
|
|
332
|
-
],
|
|
333
|
-
audit: ["tool.created"]
|
|
334
|
-
},
|
|
335
|
-
acceptance: {
|
|
336
|
-
scenarios: [
|
|
337
|
-
{
|
|
338
|
-
key: "create-tool-happy-path",
|
|
339
|
-
given: ["User is authenticated", "Organization exists"],
|
|
340
|
-
when: ["User submits valid tool configuration"],
|
|
341
|
-
then: ["New tool is created", "ToolCreated event is emitted"]
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
key: "create-tool-slug-conflict",
|
|
345
|
-
given: ["Tool with same slug exists"],
|
|
346
|
-
when: ["User submits tool with duplicate slug"],
|
|
347
|
-
then: ["SLUG_EXISTS error is returned"]
|
|
348
|
-
}
|
|
349
|
-
],
|
|
350
|
-
examples: [
|
|
351
|
-
{
|
|
352
|
-
key: "create-api-tool",
|
|
353
|
-
input: {
|
|
354
|
-
name: "Weather API",
|
|
355
|
-
slug: "weather-api",
|
|
356
|
-
category: "api",
|
|
357
|
-
description: "Fetches weather data"
|
|
358
|
-
},
|
|
359
|
-
output: {
|
|
360
|
-
id: "tool-123",
|
|
361
|
-
name: "Weather API",
|
|
362
|
-
slug: "weather-api",
|
|
363
|
-
status: "draft"
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
]
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
var UpdateToolCommand = defineCommand({
|
|
370
|
-
meta: {
|
|
371
|
-
key: "agent.tool.update",
|
|
372
|
-
version: "1.0.0",
|
|
373
|
-
stability: "stable",
|
|
374
|
-
owners: [...OWNERS],
|
|
375
|
-
tags: ["tool", "update"],
|
|
376
|
-
description: "Updates an existing AI tool definition.",
|
|
377
|
-
goal: "Allow users to modify tool settings and configuration.",
|
|
378
|
-
context: "Called from the tool settings UI."
|
|
379
|
-
},
|
|
380
|
-
io: {
|
|
381
|
-
input: UpdateToolInputModel,
|
|
382
|
-
output: defineSchemaModel2({
|
|
383
|
-
name: "UpdateToolOutput",
|
|
384
|
-
fields: {
|
|
385
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
386
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
387
|
-
status: { type: ToolStatusEnum, isOptional: false },
|
|
388
|
-
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
389
|
-
}
|
|
390
|
-
}),
|
|
391
|
-
errors: {
|
|
392
|
-
TOOL_NOT_FOUND: {
|
|
393
|
-
description: "The specified tool does not exist",
|
|
394
|
-
http: 404,
|
|
395
|
-
gqlCode: "TOOL_NOT_FOUND",
|
|
396
|
-
when: "Tool ID is invalid"
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
},
|
|
400
|
-
policy: { auth: "user" },
|
|
401
|
-
sideEffects: {
|
|
402
|
-
emits: [
|
|
403
|
-
{
|
|
404
|
-
key: "tool.updated",
|
|
405
|
-
version: "1.0.0",
|
|
406
|
-
stability: "stable",
|
|
407
|
-
owners: [...OWNERS],
|
|
408
|
-
tags: ["tool", "updated"],
|
|
409
|
-
when: "Tool is updated",
|
|
410
|
-
payload: ToolSummaryModel
|
|
411
|
-
}
|
|
412
|
-
],
|
|
413
|
-
audit: ["tool.updated"]
|
|
414
|
-
},
|
|
415
|
-
acceptance: {
|
|
416
|
-
scenarios: [
|
|
417
|
-
{
|
|
418
|
-
key: "update-tool-happy-path",
|
|
419
|
-
given: ["Tool exists", "User owns the tool"],
|
|
420
|
-
when: ["User submits updated configuration"],
|
|
421
|
-
then: ["Tool is updated", "ToolUpdated event is emitted"]
|
|
422
|
-
}
|
|
423
|
-
],
|
|
424
|
-
examples: [
|
|
425
|
-
{
|
|
426
|
-
key: "update-description",
|
|
427
|
-
input: { toolId: "tool-123", description: "Updated weather API tool" },
|
|
428
|
-
output: {
|
|
429
|
-
id: "tool-123",
|
|
430
|
-
name: "Weather API",
|
|
431
|
-
status: "draft",
|
|
432
|
-
updatedAt: "2025-01-01T00:00:00Z"
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
]
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
var GetToolQuery = defineQuery({
|
|
439
|
-
meta: {
|
|
440
|
-
key: "agent.tool.get",
|
|
441
|
-
version: "1.0.0",
|
|
442
|
-
stability: "stable",
|
|
443
|
-
owners: [...OWNERS],
|
|
444
|
-
tags: ["tool", "get"],
|
|
445
|
-
description: "Retrieves a tool by its ID.",
|
|
446
|
-
goal: "View detailed tool configuration.",
|
|
447
|
-
context: "Called when viewing tool details or editing."
|
|
448
|
-
},
|
|
449
|
-
io: {
|
|
450
|
-
input: defineSchemaModel2({
|
|
451
|
-
name: "GetToolInput",
|
|
452
|
-
fields: {
|
|
453
|
-
toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
454
|
-
}
|
|
455
|
-
}),
|
|
456
|
-
output: ToolModel,
|
|
457
|
-
errors: {
|
|
458
|
-
TOOL_NOT_FOUND: {
|
|
459
|
-
description: "The specified tool does not exist",
|
|
460
|
-
http: 404,
|
|
461
|
-
gqlCode: "TOOL_NOT_FOUND",
|
|
462
|
-
when: "Tool ID is invalid"
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
policy: { auth: "user" },
|
|
467
|
-
acceptance: {
|
|
468
|
-
scenarios: [
|
|
469
|
-
{
|
|
470
|
-
key: "get-tool-happy-path",
|
|
471
|
-
given: ["Tool exists"],
|
|
472
|
-
when: ["User requests tool by ID"],
|
|
473
|
-
then: ["Tool details are returned"]
|
|
474
|
-
}
|
|
475
|
-
],
|
|
476
|
-
examples: [
|
|
477
|
-
{
|
|
478
|
-
key: "get-basic",
|
|
479
|
-
input: { toolId: "tool-123" },
|
|
480
|
-
output: {
|
|
481
|
-
id: "tool-123",
|
|
482
|
-
name: "Weather API",
|
|
483
|
-
status: "active",
|
|
484
|
-
category: "api"
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
]
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
var ListToolsQuery = defineQuery({
|
|
491
|
-
meta: {
|
|
492
|
-
key: "agent.tool.list",
|
|
493
|
-
version: "1.0.0",
|
|
494
|
-
stability: "stable",
|
|
495
|
-
owners: [...OWNERS],
|
|
496
|
-
tags: ["tool", "list"],
|
|
497
|
-
description: "Lists tools for an organization with optional filtering.",
|
|
498
|
-
goal: "Browse and search available tools.",
|
|
499
|
-
context: "Tool list/dashboard view."
|
|
500
|
-
},
|
|
501
|
-
io: {
|
|
502
|
-
input: defineSchemaModel2({
|
|
503
|
-
name: "ListToolsInput",
|
|
504
|
-
fields: {
|
|
505
|
-
organizationId: {
|
|
506
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
507
|
-
isOptional: false
|
|
508
|
-
},
|
|
509
|
-
category: { type: ToolCategoryEnum, isOptional: true },
|
|
510
|
-
status: { type: ToolStatusEnum, isOptional: true },
|
|
511
|
-
search: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
512
|
-
limit: {
|
|
513
|
-
type: ScalarTypeEnum2.Int_unsecure(),
|
|
514
|
-
isOptional: true,
|
|
515
|
-
defaultValue: 20
|
|
516
|
-
},
|
|
517
|
-
offset: {
|
|
518
|
-
type: ScalarTypeEnum2.Int_unsecure(),
|
|
519
|
-
isOptional: true,
|
|
520
|
-
defaultValue: 0
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}),
|
|
524
|
-
output: defineSchemaModel2({
|
|
525
|
-
name: "ListToolsOutput",
|
|
526
|
-
fields: {
|
|
527
|
-
items: { type: ToolSummaryModel, isArray: true, isOptional: false },
|
|
528
|
-
total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
529
|
-
hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
|
|
530
|
-
}
|
|
531
|
-
})
|
|
532
|
-
},
|
|
533
|
-
policy: { auth: "user" },
|
|
534
|
-
acceptance: {
|
|
535
|
-
scenarios: [
|
|
536
|
-
{
|
|
537
|
-
key: "list-tools-happy-path",
|
|
538
|
-
given: ["Organization has tools"],
|
|
539
|
-
when: ["User lists tools"],
|
|
540
|
-
then: ["Paginated list of tools is returned"]
|
|
541
|
-
}
|
|
542
|
-
],
|
|
543
|
-
examples: [
|
|
544
|
-
{
|
|
545
|
-
key: "list-by-category",
|
|
546
|
-
input: { organizationId: "org-123", category: "api", limit: 10 },
|
|
547
|
-
output: { items: [], total: 0, hasMore: false }
|
|
548
|
-
}
|
|
549
|
-
]
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
var TestToolCommand = defineCommand({
|
|
553
|
-
meta: {
|
|
554
|
-
key: "agent.tool.test",
|
|
555
|
-
version: "1.0.0",
|
|
556
|
-
stability: "stable",
|
|
557
|
-
owners: [...OWNERS],
|
|
558
|
-
tags: ["tool", "test"],
|
|
559
|
-
description: "Tests a tool with sample input to verify it works correctly.",
|
|
560
|
-
goal: "Validate tool configuration before deployment.",
|
|
561
|
-
context: "Tool builder UI - test panel."
|
|
562
|
-
},
|
|
563
|
-
io: {
|
|
564
|
-
input: defineSchemaModel2({
|
|
565
|
-
name: "TestToolInput",
|
|
566
|
-
fields: {
|
|
567
|
-
toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
568
|
-
testInput: { type: ScalarTypeEnum2.JSONObject(), isOptional: false }
|
|
569
|
-
}
|
|
570
|
-
}),
|
|
571
|
-
output: defineSchemaModel2({
|
|
572
|
-
name: "TestToolOutput",
|
|
573
|
-
fields: {
|
|
574
|
-
success: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
575
|
-
output: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
576
|
-
error: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
577
|
-
durationMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false }
|
|
578
|
-
}
|
|
579
|
-
}),
|
|
580
|
-
errors: {
|
|
581
|
-
TOOL_NOT_FOUND: {
|
|
582
|
-
description: "The specified tool does not exist",
|
|
583
|
-
http: 404,
|
|
584
|
-
gqlCode: "TOOL_NOT_FOUND",
|
|
585
|
-
when: "Tool ID is invalid"
|
|
586
|
-
},
|
|
587
|
-
TOOL_EXECUTION_ERROR: {
|
|
588
|
-
description: "Tool execution failed",
|
|
589
|
-
http: 500,
|
|
590
|
-
gqlCode: "TOOL_EXECUTION_ERROR",
|
|
591
|
-
when: "Tool returns an error"
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
},
|
|
595
|
-
policy: { auth: "user" },
|
|
596
|
-
sideEffects: { audit: ["tool.tested"] },
|
|
597
|
-
acceptance: {
|
|
598
|
-
scenarios: [
|
|
599
|
-
{
|
|
600
|
-
key: "test-tool-success",
|
|
601
|
-
given: ["Tool exists", "Tool is configured correctly"],
|
|
602
|
-
when: ["User runs test with valid input"],
|
|
603
|
-
then: ["Tool executes successfully", "Output is returned"]
|
|
604
|
-
},
|
|
605
|
-
{
|
|
606
|
-
key: "test-tool-failure",
|
|
607
|
-
given: ["Tool exists", "Tool has configuration error"],
|
|
608
|
-
when: ["User runs test"],
|
|
609
|
-
then: ["TOOL_EXECUTION_ERROR is returned"]
|
|
610
|
-
}
|
|
611
|
-
],
|
|
612
|
-
examples: [
|
|
613
|
-
{
|
|
614
|
-
key: "test-weather-api",
|
|
615
|
-
input: { toolId: "tool-123", testInput: { city: "Paris" } },
|
|
616
|
-
output: { success: true, output: { temperature: 22 }, durationMs: 150 }
|
|
617
|
-
}
|
|
618
|
-
]
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
// src/tool/tool.handler.ts
|
|
623
|
-
var nextMockToolId = MOCK_TOOLS.length + 1;
|
|
624
|
-
async function mockListToolsHandler(input) {
|
|
625
|
-
const {
|
|
626
|
-
organizationId,
|
|
627
|
-
category,
|
|
628
|
-
status,
|
|
629
|
-
search,
|
|
630
|
-
limit = 20,
|
|
631
|
-
offset = 0
|
|
632
|
-
} = input;
|
|
633
|
-
let filtered = MOCK_TOOLS.filter((t) => t.organizationId === organizationId);
|
|
634
|
-
if (category)
|
|
635
|
-
filtered = filtered.filter((t) => t.category === category);
|
|
636
|
-
if (status)
|
|
637
|
-
filtered = filtered.filter((t) => t.status === status);
|
|
638
|
-
if (search) {
|
|
639
|
-
const q = search.toLowerCase();
|
|
640
|
-
filtered = filtered.filter((t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q));
|
|
641
|
-
}
|
|
642
|
-
const total = filtered.length;
|
|
643
|
-
const items = filtered.slice(offset, offset + limit).map((t) => ({
|
|
644
|
-
id: t.id,
|
|
645
|
-
name: t.name,
|
|
646
|
-
slug: t.slug,
|
|
647
|
-
description: t.description,
|
|
648
|
-
category: t.category,
|
|
649
|
-
status: t.status,
|
|
650
|
-
version: t.version,
|
|
651
|
-
createdAt: t.createdAt
|
|
652
|
-
}));
|
|
653
|
-
return { items, total, hasMore: offset + limit < total };
|
|
654
|
-
}
|
|
655
|
-
async function mockGetToolHandler(input) {
|
|
656
|
-
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
657
|
-
if (!tool)
|
|
658
|
-
throw new Error("TOOL_NOT_FOUND");
|
|
659
|
-
return tool;
|
|
660
|
-
}
|
|
661
|
-
async function mockCreateToolHandler(input) {
|
|
662
|
-
const exists = MOCK_TOOLS.some((t) => t.organizationId === input.organizationId && t.slug === input.slug);
|
|
663
|
-
if (exists)
|
|
664
|
-
throw new Error("SLUG_EXISTS");
|
|
665
|
-
return {
|
|
666
|
-
id: `tool-${nextMockToolId++}`,
|
|
667
|
-
name: input.name,
|
|
668
|
-
slug: input.slug,
|
|
669
|
-
status: "DRAFT"
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
async function mockUpdateToolHandler(input) {
|
|
673
|
-
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
674
|
-
if (!tool)
|
|
675
|
-
throw new Error("TOOL_NOT_FOUND");
|
|
676
|
-
return {
|
|
677
|
-
id: tool.id,
|
|
678
|
-
name: input.name ?? tool.name,
|
|
679
|
-
status: input.status ?? tool.status,
|
|
680
|
-
updatedAt: new Date
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
async function mockTestToolHandler(input) {
|
|
684
|
-
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
685
|
-
if (!tool)
|
|
686
|
-
throw new Error("TOOL_NOT_FOUND");
|
|
687
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
688
|
-
return {
|
|
689
|
-
success: true,
|
|
690
|
-
output: { result: "Test successful", input: input.testInput },
|
|
691
|
-
durationMs: 100
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
// src/tool/tool.entity.ts
|
|
696
|
-
import {
|
|
697
|
-
defineEntity,
|
|
698
|
-
defineEntityEnum,
|
|
699
|
-
field,
|
|
700
|
-
index
|
|
701
|
-
} from "@contractspec/lib.schema";
|
|
702
|
-
var ToolCategoryEntityEnum = defineEntityEnum({
|
|
703
|
-
name: "ToolCategory",
|
|
704
|
-
values: [
|
|
705
|
-
"RETRIEVAL",
|
|
706
|
-
"COMPUTATION",
|
|
707
|
-
"COMMUNICATION",
|
|
708
|
-
"INTEGRATION",
|
|
709
|
-
"UTILITY",
|
|
710
|
-
"CUSTOM"
|
|
711
|
-
],
|
|
712
|
-
description: "Category of tool"
|
|
713
|
-
});
|
|
714
|
-
var ToolStatusEntityEnum = defineEntityEnum({
|
|
715
|
-
name: "ToolStatus",
|
|
716
|
-
values: ["DRAFT", "ACTIVE", "DEPRECATED", "DISABLED"],
|
|
717
|
-
description: "Status of tool"
|
|
718
|
-
});
|
|
719
|
-
var ImplementationTypeEntityEnum = defineEntityEnum({
|
|
720
|
-
name: "ImplementationType",
|
|
721
|
-
values: ["http", "function", "workflow"],
|
|
722
|
-
description: "How the tool is implemented"
|
|
723
|
-
});
|
|
724
|
-
var ToolEntity = defineEntity({
|
|
725
|
-
name: "Tool",
|
|
726
|
-
schema: "agent_console",
|
|
727
|
-
description: "An AI tool that can be used by agents.",
|
|
728
|
-
fields: {
|
|
729
|
-
id: field.id(),
|
|
730
|
-
organizationId: field.string({
|
|
731
|
-
description: "Organization that owns this tool"
|
|
732
|
-
}),
|
|
733
|
-
name: field.string({ description: "Tool name" }),
|
|
734
|
-
slug: field.string({ description: "URL-safe identifier" }),
|
|
735
|
-
description: field.string({ description: "Tool description" }),
|
|
736
|
-
category: field.enum("ToolCategory", { default: "CUSTOM" }),
|
|
737
|
-
status: field.enum("ToolStatus", { default: "DRAFT" }),
|
|
738
|
-
parametersSchema: field.json({
|
|
739
|
-
description: "JSON Schema for tool parameters"
|
|
740
|
-
}),
|
|
741
|
-
outputSchema: field.json({
|
|
742
|
-
isOptional: true,
|
|
743
|
-
description: "JSON Schema for tool output"
|
|
744
|
-
}),
|
|
745
|
-
implementationType: field.enum("ImplementationType"),
|
|
746
|
-
implementationConfig: field.json({
|
|
747
|
-
description: "Implementation configuration"
|
|
748
|
-
}),
|
|
749
|
-
maxInvocationsPerMinute: field.int({
|
|
750
|
-
isOptional: true,
|
|
751
|
-
description: "Rate limit"
|
|
752
|
-
}),
|
|
753
|
-
timeoutMs: field.int({ default: 30000, description: "Execution timeout" }),
|
|
754
|
-
version: field.string({ default: "1.0.0", description: "Tool version" }),
|
|
755
|
-
tags: field.string({
|
|
756
|
-
isArray: true,
|
|
757
|
-
isOptional: true,
|
|
758
|
-
description: "Tags for categorization"
|
|
759
|
-
}),
|
|
760
|
-
createdAt: field.createdAt(),
|
|
761
|
-
updatedAt: field.updatedAt(),
|
|
762
|
-
createdById: field.string({
|
|
763
|
-
isOptional: true,
|
|
764
|
-
description: "User who created this tool"
|
|
765
|
-
}),
|
|
766
|
-
agents: field.hasMany("Agent", { description: "Agents using this tool" })
|
|
767
|
-
},
|
|
768
|
-
indexes: [
|
|
769
|
-
index.unique(["organizationId", "slug"]),
|
|
770
|
-
index.on(["organizationId", "category"]),
|
|
771
|
-
index.on(["organizationId", "status"])
|
|
772
|
-
],
|
|
773
|
-
enums: [
|
|
774
|
-
ToolCategoryEntityEnum,
|
|
775
|
-
ToolStatusEntityEnum,
|
|
776
|
-
ImplementationTypeEntityEnum
|
|
777
|
-
]
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
// src/tool/tool.event.ts
|
|
781
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
782
|
-
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
783
|
-
var OWNERS2 = ["@agent-console-team"];
|
|
784
|
-
var ToolCreatedPayload = defineSchemaModel3({
|
|
785
|
-
name: "ToolCreatedPayload",
|
|
786
|
-
description: "Payload for tool created event",
|
|
787
|
-
fields: {
|
|
788
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
789
|
-
organizationId: {
|
|
790
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
791
|
-
isOptional: false
|
|
792
|
-
},
|
|
793
|
-
name: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
794
|
-
slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
795
|
-
category: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
796
|
-
implementationType: {
|
|
797
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
798
|
-
isOptional: false
|
|
799
|
-
},
|
|
800
|
-
createdById: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
801
|
-
createdAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
var ToolCreatedEvent = defineEvent({
|
|
805
|
-
meta: {
|
|
806
|
-
key: "agent.tool.created",
|
|
807
|
-
version: "1.0.0",
|
|
808
|
-
description: "A new AI tool was created.",
|
|
809
|
-
stability: "stable",
|
|
810
|
-
owners: [...OWNERS2],
|
|
811
|
-
tags: ["tool", "created"]
|
|
812
|
-
},
|
|
813
|
-
payload: ToolCreatedPayload
|
|
814
|
-
});
|
|
815
|
-
var ToolUpdatedPayload = defineSchemaModel3({
|
|
816
|
-
name: "ToolUpdatedPayload",
|
|
817
|
-
description: "Payload for tool updated event",
|
|
818
|
-
fields: {
|
|
819
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
820
|
-
organizationId: {
|
|
821
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
822
|
-
isOptional: false
|
|
823
|
-
},
|
|
824
|
-
name: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
825
|
-
status: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
826
|
-
updatedFields: {
|
|
827
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
828
|
-
isArray: true,
|
|
829
|
-
isOptional: false
|
|
830
|
-
},
|
|
831
|
-
updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
var ToolUpdatedEvent = defineEvent({
|
|
835
|
-
meta: {
|
|
836
|
-
key: "agent.tool.updated",
|
|
837
|
-
version: "1.0.0",
|
|
838
|
-
description: "An AI tool configuration was updated.",
|
|
839
|
-
stability: "stable",
|
|
840
|
-
owners: [...OWNERS2],
|
|
841
|
-
tags: ["tool", "updated"]
|
|
842
|
-
},
|
|
843
|
-
payload: ToolUpdatedPayload
|
|
844
|
-
});
|
|
845
|
-
var ToolStatusChangedPayload = defineSchemaModel3({
|
|
846
|
-
name: "ToolStatusChangedPayload",
|
|
847
|
-
description: "Payload for tool status changed event",
|
|
848
|
-
fields: {
|
|
849
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
850
|
-
organizationId: {
|
|
851
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
852
|
-
isOptional: false
|
|
853
|
-
},
|
|
854
|
-
name: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
855
|
-
previousStatus: {
|
|
856
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
857
|
-
isOptional: false
|
|
858
|
-
},
|
|
859
|
-
newStatus: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
860
|
-
changedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
var ToolStatusChangedEvent = defineEvent({
|
|
864
|
-
meta: {
|
|
865
|
-
key: "agent.tool.statusChanged",
|
|
866
|
-
version: "1.0.0",
|
|
867
|
-
description: "An AI tool status was changed (activated, deprecated, disabled).",
|
|
868
|
-
stability: "stable",
|
|
869
|
-
owners: [...OWNERS2],
|
|
870
|
-
tags: ["tool", "status"]
|
|
871
|
-
},
|
|
872
|
-
payload: ToolStatusChangedPayload
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// src/tool/tool.presentation.ts
|
|
876
|
-
import {
|
|
877
|
-
definePresentation,
|
|
878
|
-
StabilityEnum
|
|
879
|
-
} from "@contractspec/lib.contracts-spec";
|
|
880
|
-
var ToolListPresentation = definePresentation({
|
|
881
|
-
meta: {
|
|
882
|
-
key: "agent-console.tool.list",
|
|
883
|
-
version: "1.0.0",
|
|
884
|
-
title: "Tool List",
|
|
885
|
-
description: "List view of AI tools with category, status, and version info",
|
|
886
|
-
goal: "Provide an overview of all available tools for agents.",
|
|
887
|
-
context: "Tool management dashboard.",
|
|
888
|
-
domain: "agent-console",
|
|
889
|
-
owners: ["@agent-console-team"],
|
|
890
|
-
tags: ["tool", "list", "dashboard"],
|
|
891
|
-
stability: StabilityEnum.Experimental
|
|
892
|
-
},
|
|
893
|
-
source: {
|
|
894
|
-
type: "component",
|
|
895
|
-
framework: "react",
|
|
896
|
-
componentKey: "ToolListView",
|
|
897
|
-
props: ToolSummaryModel
|
|
898
|
-
},
|
|
899
|
-
targets: ["react", "markdown", "application/json"],
|
|
900
|
-
policy: { flags: ["agent-console.enabled"] }
|
|
901
|
-
});
|
|
902
|
-
var ToolDetailPresentation = definePresentation({
|
|
903
|
-
meta: {
|
|
904
|
-
key: "agent-console.tool.detail",
|
|
905
|
-
version: "1.0.0",
|
|
906
|
-
title: "Tool Details",
|
|
907
|
-
description: "Detailed view of an AI tool with configuration and test panel",
|
|
908
|
-
goal: "Allow users to inspect and test a specific tool.",
|
|
909
|
-
context: "Detailed view of a tool.",
|
|
910
|
-
domain: "agent-console",
|
|
911
|
-
owners: ["@agent-console-team"],
|
|
912
|
-
tags: ["tool", "detail"],
|
|
913
|
-
stability: StabilityEnum.Experimental
|
|
914
|
-
},
|
|
915
|
-
source: {
|
|
916
|
-
type: "component",
|
|
917
|
-
framework: "react",
|
|
918
|
-
componentKey: "ToolDetailView"
|
|
919
|
-
},
|
|
920
|
-
targets: ["react", "markdown"],
|
|
921
|
-
policy: { flags: ["agent-console.enabled"] }
|
|
922
|
-
});
|
|
923
|
-
export {
|
|
924
|
-
mockUpdateToolHandler,
|
|
925
|
-
mockTestToolHandler,
|
|
926
|
-
mockListToolsHandler,
|
|
927
|
-
mockGetToolHandler,
|
|
928
|
-
mockCreateToolHandler,
|
|
929
|
-
UpdateToolInputModel,
|
|
930
|
-
UpdateToolCommand,
|
|
931
|
-
ToolUpdatedEvent,
|
|
932
|
-
ToolSummaryModel,
|
|
933
|
-
ToolStatusEnum,
|
|
934
|
-
ToolStatusEntityEnum,
|
|
935
|
-
ToolStatusChangedEvent,
|
|
936
|
-
ToolModel,
|
|
937
|
-
ToolListPresentation,
|
|
938
|
-
ToolEntity,
|
|
939
|
-
ToolDetailPresentation,
|
|
940
|
-
ToolCreatedEvent,
|
|
941
|
-
ToolCategoryEnum,
|
|
942
|
-
ToolCategoryEntityEnum,
|
|
943
|
-
TestToolCommand,
|
|
944
|
-
ListToolsQuery,
|
|
945
|
-
ImplementationTypeEnum,
|
|
946
|
-
ImplementationTypeEntityEnum,
|
|
947
|
-
GetToolQuery,
|
|
948
|
-
CreateToolInputModel,
|
|
949
|
-
CreateToolCommand
|
|
950
|
-
};
|
|
2
|
+
var w=[{id:"tool-1",organizationId:"demo-org",name:"Web Search",slug:"web-search",description:"Search the web for real-time information using Brave API.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},numResults:{type:"number",default:10}},required:["query"]},outputSchema:{type:"array",items:{type:"object"}},implementationType:"http",implementationConfig:{url:"https://api.brave.com/search",method:"GET"},maxInvocationsPerMinute:60,timeoutMs:30000,version:"1.0.0",tags:["search","web"],createdAt:new Date("2024-01-01T00:00:00Z"),updatedAt:new Date("2024-02-15T10:00:00Z")},{id:"tool-2",organizationId:"demo-org",name:"SQL Query",slug:"sql-query",description:"Execute read-only SQL queries against the data warehouse.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"SQL query"},maxRows:{type:"number",default:100}},required:["query"]},outputSchema:{type:"object"},implementationType:"function",implementationConfig:{handler:"executeSqlQuery"},maxInvocationsPerMinute:30,timeoutMs:60000,version:"1.1.0",tags:["sql","database"],createdAt:new Date("2024-01-05T00:00:00Z"),updatedAt:new Date("2024-03-10T14:00:00Z")},{id:"tool-3",organizationId:"demo-org",name:"Email Sender",slug:"email-sender",description:"Send emails via SMTP or API.",category:"COMMUNICATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{to:{type:"string"},subject:{type:"string"},body:{type:"string"}},required:["to","subject","body"]},implementationType:"http",implementationConfig:{url:"/api/send-email",method:"POST"},maxInvocationsPerMinute:10,timeoutMs:30000,version:"1.0.0",tags:["email","communication"],createdAt:new Date("2024-02-01T00:00:00Z"),updatedAt:new Date("2024-02-01T00:00:00Z")},{id:"tool-4",organizationId:"demo-org",name:"GitHub Integration",slug:"github-integration",description:"Interact with GitHub repositories, PRs, and issues.",category:"INTEGRATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{action:{type:"string",enum:["list_prs","get_pr","create_comment"]},repo:{type:"string"},params:{type:"object"}},required:["action","repo"]},implementationType:"http",implementationConfig:{url:"https://api.github.com",auth:"token"},maxInvocationsPerMinute:100,timeoutMs:15000,version:"2.0.0",tags:["github","integration","code"],createdAt:new Date("2024-02-20T00:00:00Z"),updatedAt:new Date("2024-04-01T09:00:00Z")},{id:"tool-5",organizationId:"demo-org",name:"Calculator",slug:"calculator",description:"Perform mathematical calculations.",category:"COMPUTATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{expression:{type:"string",description:"Math expression to evaluate"}},required:["expression"]},outputSchema:{type:"object",properties:{result:{type:"number"}}},implementationType:"function",implementationConfig:{handler:"evaluateMath"},timeoutMs:5000,version:"1.0.0",tags:["math","utility"],createdAt:new Date("2024-01-10T00:00:00Z"),updatedAt:new Date("2024-01-10T00:00:00Z")}];import{defineEnum as P}from"@contractspec/lib.schema";var q=P("ToolCategory",["RETRIEVAL","COMPUTATION","COMMUNICATION","INTEGRATION","UTILITY","CUSTOM"]),I=P("ToolStatus",["DRAFT","ACTIVE","DEPRECATED","DISABLED"]),D=P("ImplementationType",["http","function","workflow"]);import{defineSchemaModel as h,ScalarTypeEnum as t}from"@contractspec/lib.schema";var H=h({name:"Tool",description:"AI tool definition",fields:{id:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!1},category:{type:q,isOptional:!1},status:{type:I,isOptional:!1},parametersSchema:{type:t.JSONObject(),isOptional:!1},outputSchema:{type:t.JSONObject(),isOptional:!0},implementationType:{type:D,isOptional:!1},implementationConfig:{type:t.JSONObject(),isOptional:!1},maxInvocationsPerMinute:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!1,defaultValue:30000},version:{type:t.NonEmptyString(),isOptional:!1},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1},updatedAt:{type:t.DateTime(),isOptional:!1}}}),x=h({name:"ToolSummary",description:"Summary of a tool for list views",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!1},category:{type:q,isOptional:!1},status:{type:I,isOptional:!1},version:{type:t.NonEmptyString(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1}}}),V=h({name:"CreateToolInput",description:"Input for creating a tool",fields:{organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!1},category:{type:q,isOptional:!0},parametersSchema:{type:t.JSONObject(),isOptional:!1},outputSchema:{type:t.JSONObject(),isOptional:!0},implementationType:{type:D,isOptional:!1},implementationConfig:{type:t.JSONObject(),isOptional:!1},maxInvocationsPerMinute:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!0},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0}}}),G=h({name:"UpdateToolInput",description:"Input for updating a tool",fields:{toolId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0},status:{type:I,isOptional:!0},parametersSchema:{type:t.JSONObject(),isOptional:!0},outputSchema:{type:t.JSONObject(),isOptional:!0},implementationConfig:{type:t.JSONObject(),isOptional:!0},maxInvocationsPerMinute:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!0},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0}}});import{defineCommand as k,defineQuery as $}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as v,ScalarTypeEnum as o}from"@contractspec/lib.schema";var j=["@agent-console-team"],_=k({meta:{key:"agent.tool.create",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","create"],description:"Creates a new AI tool definition.",goal:"Allow users to define new tools that agents can use.",context:"Called from the tool builder UI when creating a new tool."},io:{input:V,output:v({name:"CreateToolOutput",fields:{id:{type:o.String_unsecure(),isOptional:!1},name:{type:o.NonEmptyString(),isOptional:!1},slug:{type:o.String_unsecure(),isOptional:!1},status:{type:I,isOptional:!1}}}),errors:{SLUG_EXISTS:{description:"A tool with this slug already exists in the organization",http:409,gqlCode:"SLUG_EXISTS",when:"Slug is already taken"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"tool.created",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","created"],when:"Tool is successfully created",payload:x}],audit:["tool.created"]},acceptance:{scenarios:[{key:"create-tool-happy-path",given:["User is authenticated","Organization exists"],when:["User submits valid tool configuration"],then:["New tool is created","ToolCreated event is emitted"]},{key:"create-tool-slug-conflict",given:["Tool with same slug exists"],when:["User submits tool with duplicate slug"],then:["SLUG_EXISTS error is returned"]}],examples:[{key:"create-api-tool",input:{name:"Weather API",slug:"weather-api",category:"api",description:"Fetches weather data"},output:{id:"tool-123",name:"Weather API",slug:"weather-api",status:"draft"}}]}}),R=k({meta:{key:"agent.tool.update",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","update"],description:"Updates an existing AI tool definition.",goal:"Allow users to modify tool settings and configuration.",context:"Called from the tool settings UI."},io:{input:G,output:v({name:"UpdateToolOutput",fields:{id:{type:o.String_unsecure(),isOptional:!1},name:{type:o.NonEmptyString(),isOptional:!1},status:{type:I,isOptional:!1},updatedAt:{type:o.DateTime(),isOptional:!1}}}),errors:{TOOL_NOT_FOUND:{description:"The specified tool does not exist",http:404,gqlCode:"TOOL_NOT_FOUND",when:"Tool ID is invalid"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"tool.updated",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","updated"],when:"Tool is updated",payload:x}],audit:["tool.updated"]},acceptance:{scenarios:[{key:"update-tool-happy-path",given:["Tool exists","User owns the tool"],when:["User submits updated configuration"],then:["Tool is updated","ToolUpdated event is emitted"]}],examples:[{key:"update-description",input:{toolId:"tool-123",description:"Updated weather API tool"},output:{id:"tool-123",name:"Weather API",status:"draft",updatedAt:"2025-01-01T00:00:00Z"}}]}}),K=$({meta:{key:"agent.tool.get",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","get"],description:"Retrieves a tool by its ID.",goal:"View detailed tool configuration.",context:"Called when viewing tool details or editing."},io:{input:v({name:"GetToolInput",fields:{toolId:{type:o.String_unsecure(),isOptional:!1}}}),output:H,errors:{TOOL_NOT_FOUND:{description:"The specified tool does not exist",http:404,gqlCode:"TOOL_NOT_FOUND",when:"Tool ID is invalid"}}},policy:{auth:"user"},acceptance:{scenarios:[{key:"get-tool-happy-path",given:["Tool exists"],when:["User requests tool by ID"],then:["Tool details are returned"]}],examples:[{key:"get-basic",input:{toolId:"tool-123"},output:{id:"tool-123",name:"Weather API",status:"active",category:"api"}}]}}),N=$({meta:{key:"agent.tool.list",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","list"],description:"Lists tools for an organization with optional filtering.",goal:"Browse and search available tools.",context:"Tool list/dashboard view."},io:{input:v({name:"ListToolsInput",fields:{organizationId:{type:o.String_unsecure(),isOptional:!1},category:{type:q,isOptional:!0},status:{type:I,isOptional:!0},search:{type:o.String_unsecure(),isOptional:!0},limit:{type:o.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:o.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:v({name:"ListToolsOutput",fields:{items:{type:x,isArray:!0,isOptional:!1},total:{type:o.Int_unsecure(),isOptional:!1},hasMore:{type:o.Boolean(),isOptional:!1}}})},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-tools-happy-path",given:["Organization has tools"],when:["User lists tools"],then:["Paginated list of tools is returned"]}],examples:[{key:"list-by-category",input:{organizationId:"org-123",category:"api",limit:10},output:{items:[],total:0,hasMore:!1}}]}}),M=k({meta:{key:"agent.tool.test",version:"1.0.0",stability:"stable",owners:[...j],tags:["tool","test"],description:"Tests a tool with sample input to verify it works correctly.",goal:"Validate tool configuration before deployment.",context:"Tool builder UI - test panel."},io:{input:v({name:"TestToolInput",fields:{toolId:{type:o.String_unsecure(),isOptional:!1},testInput:{type:o.JSONObject(),isOptional:!1}}}),output:v({name:"TestToolOutput",fields:{success:{type:o.Boolean(),isOptional:!1},output:{type:o.JSONObject(),isOptional:!0},error:{type:o.String_unsecure(),isOptional:!0},durationMs:{type:o.Int_unsecure(),isOptional:!1}}}),errors:{TOOL_NOT_FOUND:{description:"The specified tool does not exist",http:404,gqlCode:"TOOL_NOT_FOUND",when:"Tool ID is invalid"},TOOL_EXECUTION_ERROR:{description:"Tool execution failed",http:500,gqlCode:"TOOL_EXECUTION_ERROR",when:"Tool returns an error"}}},policy:{auth:"user"},sideEffects:{audit:["tool.tested"]},acceptance:{scenarios:[{key:"test-tool-success",given:["Tool exists","Tool is configured correctly"],when:["User runs test with valid input"],then:["Tool executes successfully","Output is returned"]},{key:"test-tool-failure",given:["Tool exists","Tool has configuration error"],when:["User runs test"],then:["TOOL_EXECUTION_ERROR is returned"]}],examples:[{key:"test-weather-api",input:{toolId:"tool-123",testInput:{city:"Paris"}},output:{success:!0,output:{temperature:22},durationMs:150}}]}});var m=w.length+1;async function f(i){let{organizationId:A,category:e,status:B,search:F,limit:J=20,offset:Z=0}=i,b=w.filter((r)=>r.organizationId===A);if(e)b=b.filter((r)=>r.category===e);if(B)b=b.filter((r)=>r.status===B);if(F){let r=F.toLowerCase();b=b.filter((Y)=>Y.name.toLowerCase().includes(r)||Y.description.toLowerCase().includes(r))}let X=b.length;return{items:b.slice(Z,Z+J).map((r)=>({id:r.id,name:r.name,slug:r.slug,description:r.description,category:r.category,status:r.status,version:r.version,createdAt:r.createdAt})),total:X,hasMore:Z+J<X}}async function a(i){let A=w.find((e)=>e.id===i.toolId);if(!A)throw Error("TOOL_NOT_FOUND");return A}async function c(i){if(w.some((e)=>e.organizationId===i.organizationId&&e.slug===i.slug))throw Error("SLUG_EXISTS");return{id:`tool-${m++}`,name:i.name,slug:i.slug,status:"DRAFT"}}async function y(i){let A=w.find((e)=>e.id===i.toolId);if(!A)throw Error("TOOL_NOT_FOUND");return{id:A.id,name:i.name??A.name,status:i.status??A.status,updatedAt:new Date}}async function u(i){if(!w.find((e)=>e.id===i.toolId))throw Error("TOOL_NOT_FOUND");return await new Promise((e)=>setTimeout(e,100)),{success:!0,output:{result:"Test successful",input:i.testInput},durationMs:100}}import{defineEntity as T,defineEntityEnum as L,field as g,index as z}from"@contractspec/lib.schema";var W=L({name:"ToolCategory",values:["RETRIEVAL","COMPUTATION","COMMUNICATION","INTEGRATION","UTILITY","CUSTOM"],description:"Category of tool"}),O=L({name:"ToolStatus",values:["DRAFT","ACTIVE","DEPRECATED","DISABLED"],description:"Status of tool"}),d=L({name:"ImplementationType",values:["http","function","workflow"],description:"How the tool is implemented"}),E=T({name:"Tool",schema:"agent_console",description:"An AI tool that can be used by agents.",fields:{id:g.id(),organizationId:g.string({description:"Organization that owns this tool"}),name:g.string({description:"Tool name"}),slug:g.string({description:"URL-safe identifier"}),description:g.string({description:"Tool description"}),category:g.enum("ToolCategory",{default:"CUSTOM"}),status:g.enum("ToolStatus",{default:"DRAFT"}),parametersSchema:g.json({description:"JSON Schema for tool parameters"}),outputSchema:g.json({isOptional:!0,description:"JSON Schema for tool output"}),implementationType:g.enum("ImplementationType"),implementationConfig:g.json({description:"Implementation configuration"}),maxInvocationsPerMinute:g.int({isOptional:!0,description:"Rate limit"}),timeoutMs:g.int({default:30000,description:"Execution timeout"}),version:g.string({default:"1.0.0",description:"Tool version"}),tags:g.string({isArray:!0,isOptional:!0,description:"Tags for categorization"}),createdAt:g.createdAt(),updatedAt:g.updatedAt(),createdById:g.string({isOptional:!0,description:"User who created this tool"}),agents:g.hasMany("Agent",{description:"Agents using this tool"})},indexes:[z.unique(["organizationId","slug"]),z.on(["organizationId","category"]),z.on(["organizationId","status"])],enums:[W,O,d]});import{defineEvent as C}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as Q,ScalarTypeEnum as s}from"@contractspec/lib.schema";var U=["@agent-console-team"],S=Q({name:"ToolCreatedPayload",description:"Payload for tool created event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},slug:{type:s.String_unsecure(),isOptional:!1},category:{type:s.String_unsecure(),isOptional:!1},implementationType:{type:s.String_unsecure(),isOptional:!1},createdById:{type:s.String_unsecure(),isOptional:!0},createdAt:{type:s.DateTime(),isOptional:!1}}}),l=C({meta:{key:"agent.tool.created",version:"1.0.0",description:"A new AI tool was created.",stability:"stable",owners:[...U],tags:["tool","created"]},payload:S}),tt=Q({name:"ToolUpdatedPayload",description:"Payload for tool updated event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},status:{type:s.String_unsecure(),isOptional:!1},updatedFields:{type:s.String_unsecure(),isArray:!0,isOptional:!1},updatedAt:{type:s.DateTime(),isOptional:!1}}}),st=C({meta:{key:"agent.tool.updated",version:"1.0.0",description:"An AI tool configuration was updated.",stability:"stable",owners:[...U],tags:["tool","updated"]},payload:tt}),ot=Q({name:"ToolStatusChangedPayload",description:"Payload for tool status changed event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},previousStatus:{type:s.String_unsecure(),isOptional:!1},newStatus:{type:s.String_unsecure(),isOptional:!1},changedAt:{type:s.DateTime(),isOptional:!1}}}),gt=C({meta:{key:"agent.tool.statusChanged",version:"1.0.0",description:"An AI tool status was changed (activated, deprecated, disabled).",stability:"stable",owners:[...U],tags:["tool","status"]},payload:ot});import{definePresentation as p,StabilityEnum as n}from"@contractspec/lib.contracts-spec";var rt=p({meta:{key:"agent-console.tool.list",version:"1.0.0",title:"Tool List",description:"List view of AI tools with category, status, and version info",goal:"Provide an overview of all available tools for agents.",context:"Tool management dashboard.",domain:"agent-console",owners:["@agent-console-team"],tags:["tool","list","dashboard"],stability:n.Experimental},source:{type:"component",framework:"react",componentKey:"ToolListView",props:x},targets:["react","markdown","application/json"],policy:{flags:["agent-console.enabled"]}}),it=p({meta:{key:"agent-console.tool.detail",version:"1.0.0",title:"Tool Details",description:"Detailed view of an AI tool with configuration and test panel",goal:"Allow users to inspect and test a specific tool.",context:"Detailed view of a tool.",domain:"agent-console",owners:["@agent-console-team"],tags:["tool","detail"],stability:n.Experimental},source:{type:"component",framework:"react",componentKey:"ToolDetailView"},targets:["react","markdown"],policy:{flags:["agent-console.enabled"]}});export{y as mockUpdateToolHandler,u as mockTestToolHandler,f as mockListToolsHandler,a as mockGetToolHandler,c as mockCreateToolHandler,G as UpdateToolInputModel,R as UpdateToolCommand,st as ToolUpdatedEvent,x as ToolSummaryModel,I as ToolStatusEnum,O as ToolStatusEntityEnum,gt as ToolStatusChangedEvent,H as ToolModel,rt as ToolListPresentation,E as ToolEntity,it as ToolDetailPresentation,l as ToolCreatedEvent,q as ToolCategoryEnum,W as ToolCategoryEntityEnum,M as TestToolCommand,N as ListToolsQuery,D as ImplementationTypeEnum,d as ImplementationTypeEntityEnum,K as GetToolQuery,V as CreateToolInputModel,_ as CreateToolCommand};
|