@contractspec/example.agent-console 3.8.8 → 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 +34 -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 +29 -13
- package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
- package/src/ui/ExecutionConsoleHost.tsx +14 -0
- package/src/ui/index.ts +1 -1
|
@@ -1,700 +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
|
-
export {
|
|
695
|
-
mockUpdateToolHandler,
|
|
696
|
-
mockTestToolHandler,
|
|
697
|
-
mockListToolsHandler,
|
|
698
|
-
mockGetToolHandler,
|
|
699
|
-
mockCreateToolHandler
|
|
700
|
-
};
|
|
2
|
+
var b=[{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 w=P("ToolCategory",["RETRIEVAL","COMPUTATION","COMMUNICATION","INTEGRATION","UTILITY","CUSTOM"]),A=P("ToolStatus",["DRAFT","ACTIVE","DEPRECATED","DISABLED"]),x=P("ImplementationType",["http","function","workflow"]);import{defineSchemaModel as q,ScalarTypeEnum as t}from"@contractspec/lib.schema";var H=q({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:w,isOptional:!1},status:{type:A,isOptional:!1},parametersSchema:{type:t.JSONObject(),isOptional:!1},outputSchema:{type:t.JSONObject(),isOptional:!0},implementationType:{type:x,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}}}),v=q({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:w,isOptional:!1},status:{type:A,isOptional:!1},version:{type:t.NonEmptyString(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1}}}),B=q({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:w,isOptional:!0},parametersSchema:{type:t.JSONObject(),isOptional:!1},outputSchema:{type:t.JSONObject(),isOptional:!0},implementationType:{type:x,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}}}),Q=q({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:A,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 D,defineQuery as R}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as I,ScalarTypeEnum as s}from"@contractspec/lib.schema";var h=["@agent-console-team"],F=D({meta:{key:"agent.tool.create",version:"1.0.0",stability:"stable",owners:[...h],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:B,output:I({name:"CreateToolOutput",fields:{id:{type:s.String_unsecure(),isOptional:!1},name:{type:s.NonEmptyString(),isOptional:!1},slug:{type:s.String_unsecure(),isOptional:!1},status:{type:A,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:[...h],tags:["tool","created"],when:"Tool is successfully created",payload:v}],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"}}]}}),J=D({meta:{key:"agent.tool.update",version:"1.0.0",stability:"stable",owners:[...h],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:Q,output:I({name:"UpdateToolOutput",fields:{id:{type:s.String_unsecure(),isOptional:!1},name:{type:s.NonEmptyString(),isOptional:!1},status:{type:A,isOptional:!1},updatedAt:{type:s.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:[...h],tags:["tool","updated"],when:"Tool is updated",payload:v}],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"}}]}}),U=R({meta:{key:"agent.tool.get",version:"1.0.0",stability:"stable",owners:[...h],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:I({name:"GetToolInput",fields:{toolId:{type:s.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"}}]}}),X=R({meta:{key:"agent.tool.list",version:"1.0.0",stability:"stable",owners:[...h],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:I({name:"ListToolsInput",fields:{organizationId:{type:s.String_unsecure(),isOptional:!1},category:{type:w,isOptional:!0},status:{type:A,isOptional:!0},search:{type:s.String_unsecure(),isOptional:!0},limit:{type:s.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:s.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:I({name:"ListToolsOutput",fields:{items:{type:v,isArray:!0,isOptional:!1},total:{type:s.Int_unsecure(),isOptional:!1},hasMore:{type:s.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}}]}}),Y=D({meta:{key:"agent.tool.test",version:"1.0.0",stability:"stable",owners:[...h],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:I({name:"TestToolInput",fields:{toolId:{type:s.String_unsecure(),isOptional:!1},testInput:{type:s.JSONObject(),isOptional:!1}}}),output:I({name:"TestToolOutput",fields:{success:{type:s.Boolean(),isOptional:!1},output:{type:s.JSONObject(),isOptional:!0},error:{type:s.String_unsecure(),isOptional:!0},durationMs:{type:s.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 $=b.length+1;async function y(e){let{organizationId:r,category:g,status:Z,search:V,limit:d=20,offset:j=0}=e,o=b.filter((i)=>i.organizationId===r);if(g)o=o.filter((i)=>i.category===g);if(Z)o=o.filter((i)=>i.status===Z);if(V){let i=V.toLowerCase();o=o.filter((G)=>G.name.toLowerCase().includes(i)||G.description.toLowerCase().includes(i))}let z=o.length;return{items:o.slice(j,j+d).map((i)=>({id:i.id,name:i.name,slug:i.slug,description:i.description,category:i.category,status:i.status,version:i.version,createdAt:i.createdAt})),total:z,hasMore:j+d<z}}async function u(e){let r=b.find((g)=>g.id===e.toolId);if(!r)throw Error("TOOL_NOT_FOUND");return r}async function m(e){if(b.some((g)=>g.organizationId===e.organizationId&&g.slug===e.slug))throw Error("SLUG_EXISTS");return{id:`tool-${$++}`,name:e.name,slug:e.slug,status:"DRAFT"}}async function T(e){let r=b.find((g)=>g.id===e.toolId);if(!r)throw Error("TOOL_NOT_FOUND");return{id:r.id,name:e.name??r.name,status:e.status??r.status,updatedAt:new Date}}async function E(e){if(!b.find((g)=>g.id===e.toolId))throw Error("TOOL_NOT_FOUND");return await new Promise((g)=>setTimeout(g,100)),{success:!0,output:{result:"Test successful",input:e.testInput},durationMs:100}}export{T as mockUpdateToolHandler,E as mockTestToolHandler,y as mockListToolsHandler,u as mockGetToolHandler,m as mockCreateToolHandler};
|