@contractspec/example.agent-console 3.7.7 → 3.8.4
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 +126 -105
- package/AGENTS.md +3 -1
- package/CHANGELOG.md +57 -0
- package/README.md +46 -9
- package/dist/agent/agent.handler.d.ts +3 -0
- package/dist/agent/agent.handler.js +730 -1
- package/dist/agent/index.js +73 -72
- package/dist/agent.feature.js +179 -0
- package/dist/browser/agent/agent.handler.js +730 -1
- package/dist/browser/agent/index.js +73 -72
- package/dist/browser/agent.feature.js +179 -0
- package/dist/browser/docs/agent-console.docblock.js +11 -8
- package/dist/browser/docs/index.js +11 -8
- package/dist/browser/example.js +2 -3
- package/dist/browser/handlers/agent.handlers.js +1883 -2
- package/dist/browser/handlers/index.js +2142 -8
- package/dist/browser/index.js +3347 -2433
- package/dist/browser/presentations/index.js +49 -49
- package/dist/browser/run/index.js +818 -812
- package/dist/browser/run/run.handler.js +666 -1
- package/dist/browser/shared/index.js +293 -1
- package/dist/browser/shared/mock-runs.js +5 -0
- package/dist/browser/tool/index.js +331 -331
- package/dist/browser/tool/tool.handler.js +479 -3
- package/dist/browser/ui/AgentDashboard.js +1204 -319
- package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/browser/ui/AgentRunList.js +359 -127
- package/dist/browser/ui/hooks/index.js +468 -18
- package/dist/browser/ui/hooks/useAgentMutations.js +443 -8
- package/dist/browser/ui/hooks/useRunList.js +25 -10
- package/dist/browser/ui/index.js +1293 -390
- package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/browser/ui/renderers/index.js +245 -49
- package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
- package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/browser/ui/views/RunDataTable.js +326 -0
- package/dist/browser/ui/views/RunListView.js +359 -127
- package/dist/browser/ui/views/index.js +406 -174
- package/dist/browser/ui/views/run-data-table.columns.js +271 -0
- package/dist/browser/ui/views/run-list.shared.js +177 -0
- package/dist/browser/visualizations/catalog.js +134 -0
- package/dist/browser/visualizations/index.js +187 -0
- package/dist/browser/visualizations/selectors.js +181 -0
- package/dist/docs/agent-console.docblock.js +11 -8
- package/dist/docs/index.js +11 -8
- package/dist/example.js +2 -3
- package/dist/example.test.d.ts +1 -0
- package/dist/handlers/agent.handlers.d.ts +2 -0
- package/dist/handlers/agent.handlers.js +1883 -2
- package/dist/handlers/index.d.ts +1 -3
- package/dist/handlers/index.js +2142 -8
- package/dist/handlers/mock-handlers.test.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3347 -2433
- package/dist/node/agent/agent.handler.js +730 -1
- package/dist/node/agent/index.js +73 -72
- package/dist/node/agent.feature.js +179 -0
- package/dist/node/docs/agent-console.docblock.js +11 -8
- package/dist/node/docs/index.js +11 -8
- package/dist/node/example.js +2 -3
- package/dist/node/handlers/agent.handlers.js +1883 -2
- package/dist/node/handlers/index.js +2142 -8
- package/dist/node/index.js +3347 -2433
- package/dist/node/presentations/index.js +49 -49
- package/dist/node/run/index.js +818 -812
- package/dist/node/run/run.handler.js +666 -1
- package/dist/node/shared/index.js +293 -1
- package/dist/node/shared/mock-runs.js +5 -0
- package/dist/node/tool/index.js +331 -331
- package/dist/node/tool/tool.handler.js +479 -3
- package/dist/node/ui/AgentDashboard.js +1204 -319
- package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/node/ui/AgentRunList.js +359 -127
- package/dist/node/ui/hooks/index.js +468 -18
- package/dist/node/ui/hooks/useAgentMutations.js +443 -8
- package/dist/node/ui/hooks/useRunList.js +25 -10
- package/dist/node/ui/index.js +1293 -390
- package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/node/ui/renderers/index.js +245 -49
- package/dist/node/ui/renderers/run-list.markdown.js +9 -4
- package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/node/ui/views/RunDataTable.js +326 -0
- package/dist/node/ui/views/RunListView.js +359 -127
- package/dist/node/ui/views/index.js +406 -174
- package/dist/node/ui/views/run-data-table.columns.js +271 -0
- package/dist/node/ui/views/run-list.shared.js +177 -0
- package/dist/node/visualizations/catalog.js +134 -0
- package/dist/node/visualizations/index.js +187 -0
- package/dist/node/visualizations/selectors.js +181 -0
- package/dist/presentations/index.js +49 -49
- package/dist/proof/index.d.ts +2 -0
- package/dist/proof/meetup-proof.d.ts +10 -0
- package/dist/proof/meetup-proof.runtime.d.ts +22 -0
- package/dist/proof/meetup-proof.scenario.d.ts +2 -0
- package/dist/proof/meetup-proof.suite.d.ts +1 -0
- package/dist/proof/meetup-proof.test.d.ts +1 -0
- package/dist/run/index.js +818 -812
- package/dist/run/run.handler.d.ts +4 -0
- package/dist/run/run.handler.js +666 -1
- package/dist/shared/demo-dashboard-data.d.ts +16 -0
- package/dist/shared/demo-runtime-seed.d.ts +17 -0
- package/dist/shared/demo-runtime.d.ts +8 -0
- package/dist/shared/demo-runtime.test.d.ts +1 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.js +293 -1
- package/dist/shared/mock-runs.d.ts +4 -0
- package/dist/shared/mock-runs.js +5 -0
- package/dist/tool/index.js +331 -331
- package/dist/tool/tool.handler.d.ts +4 -1
- package/dist/tool/tool.handler.js +479 -3
- package/dist/ui/AgentDashboard.js +1204 -319
- package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
- package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
- package/dist/ui/AgentDashboard.visualizations.js +218 -0
- package/dist/ui/AgentRunList.js +359 -127
- package/dist/ui/hooks/index.js +468 -18
- package/dist/ui/hooks/useAgentMutations.js +443 -8
- package/dist/ui/hooks/useRunList.d.ts +8 -2
- package/dist/ui/hooks/useRunList.js +25 -10
- package/dist/ui/index.js +1293 -390
- package/dist/ui/renderers/agent-list.markdown.d.ts +1 -1
- package/dist/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/ui/renderers/agent-list.renderer.d.ts +1 -1
- package/dist/ui/renderers/dashboard.markdown.d.ts +1 -1
- package/dist/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/ui/renderers/index.js +245 -49
- package/dist/ui/renderers/run-list.markdown.d.ts +1 -1
- package/dist/ui/renderers/run-list.markdown.js +9 -4
- package/dist/ui/renderers/tool-registry.markdown.d.ts +2 -2
- package/dist/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/ui/views/RunDataTable.d.ts +18 -0
- package/dist/ui/views/RunDataTable.js +327 -0
- package/dist/ui/views/RunListView.js +359 -127
- package/dist/ui/views/index.js +406 -174
- package/dist/ui/views/run-data-table.columns.d.ts +3 -0
- package/dist/ui/views/run-data-table.columns.js +272 -0
- package/dist/ui/views/run-list.shared.d.ts +14 -0
- package/dist/ui/views/run-list.shared.js +178 -0
- package/dist/visualizations/catalog.d.ts +10 -0
- package/dist/visualizations/catalog.js +135 -0
- package/dist/visualizations/index.d.ts +2 -0
- package/dist/visualizations/index.js +188 -0
- package/dist/visualizations/selectors.d.ts +3 -0
- package/dist/visualizations/selectors.js +182 -0
- package/dist/visualizations/selectors.test.d.ts +1 -0
- package/package.json +114 -11
- package/proofs/agent-console-meetup.replay.json +220 -0
- package/src/agent/agent.handler.ts +18 -1
- package/src/agent.feature.ts +3 -0
- package/src/docs/agent-console.docblock.ts +11 -8
- package/src/example.test.ts +75 -0
- package/src/example.ts +2 -3
- package/src/handlers/agent.handlers.ts +55 -2
- package/src/handlers/index.ts +18 -2
- package/src/handlers/mock-handlers.test.ts +77 -0
- package/src/index.ts +2 -0
- package/src/proof/index.ts +2 -0
- package/src/proof/meetup-proof.runtime.ts +196 -0
- package/src/proof/meetup-proof.scenario.ts +99 -0
- package/src/proof/meetup-proof.suite.ts +29 -0
- package/src/proof/meetup-proof.test.ts +28 -0
- package/src/proof/meetup-proof.ts +130 -0
- package/src/run/run.handler.ts +17 -1
- package/src/shared/demo-dashboard-data.ts +58 -0
- package/src/shared/demo-runtime-seed.ts +139 -0
- package/src/shared/demo-runtime.test.ts +169 -0
- package/src/shared/demo-runtime.ts +260 -0
- package/src/shared/index.ts +11 -0
- package/src/shared/mock-runs.ts +5 -0
- package/src/tool/tool.handler.ts +21 -4
- package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
- package/src/ui/AgentDashboard.tsx +4 -1
- package/src/ui/AgentDashboard.visualizations.tsx +35 -0
- package/src/ui/hooks/useAgentMutations.ts +19 -11
- package/src/ui/hooks/useRunList.ts +41 -9
- package/src/ui/renderers/agent-list.markdown.ts +32 -13
- package/src/ui/renderers/agent-list.renderer.tsx +1 -1
- package/src/ui/renderers/dashboard.markdown.ts +38 -43
- package/src/ui/renderers/run-list.markdown.ts +17 -9
- package/src/ui/renderers/tool-registry.markdown.ts +22 -10
- package/src/ui/views/RunDataTable.tsx +74 -0
- package/src/ui/views/RunListView.tsx +37 -111
- package/src/ui/views/run-data-table.columns.tsx +102 -0
- package/src/ui/views/run-list.shared.tsx +139 -0
- package/src/visualizations/catalog.ts +132 -0
- package/src/visualizations/index.ts +2 -0
- package/src/visualizations/selectors.test.ts +12 -0
- package/src/visualizations/selectors.ts +70 -0
- package/tsdown.config.js +17 -0
|
@@ -142,7 +142,484 @@ var MOCK_TOOLS = [
|
|
|
142
142
|
}
|
|
143
143
|
];
|
|
144
144
|
|
|
145
|
+
// src/tool/tool.enum.ts
|
|
146
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
147
|
+
var ToolCategoryEnum = defineEnum("ToolCategory", [
|
|
148
|
+
"RETRIEVAL",
|
|
149
|
+
"COMPUTATION",
|
|
150
|
+
"COMMUNICATION",
|
|
151
|
+
"INTEGRATION",
|
|
152
|
+
"UTILITY",
|
|
153
|
+
"CUSTOM"
|
|
154
|
+
]);
|
|
155
|
+
var ToolStatusEnum = defineEnum("ToolStatus", [
|
|
156
|
+
"DRAFT",
|
|
157
|
+
"ACTIVE",
|
|
158
|
+
"DEPRECATED",
|
|
159
|
+
"DISABLED"
|
|
160
|
+
]);
|
|
161
|
+
var ImplementationTypeEnum = defineEnum("ImplementationType", [
|
|
162
|
+
"http",
|
|
163
|
+
"function",
|
|
164
|
+
"workflow"
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
// src/tool/tool.schema.ts
|
|
168
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
169
|
+
var ToolModel = defineSchemaModel({
|
|
170
|
+
name: "Tool",
|
|
171
|
+
description: "AI tool definition",
|
|
172
|
+
fields: {
|
|
173
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
174
|
+
organizationId: {
|
|
175
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
176
|
+
isOptional: false
|
|
177
|
+
},
|
|
178
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
179
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
180
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
181
|
+
category: { type: ToolCategoryEnum, isOptional: false },
|
|
182
|
+
status: { type: ToolStatusEnum, isOptional: false },
|
|
183
|
+
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
184
|
+
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
185
|
+
implementationType: { type: ImplementationTypeEnum, isOptional: false },
|
|
186
|
+
implementationConfig: {
|
|
187
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
188
|
+
isOptional: false
|
|
189
|
+
},
|
|
190
|
+
maxInvocationsPerMinute: {
|
|
191
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
192
|
+
isOptional: true
|
|
193
|
+
},
|
|
194
|
+
timeoutMs: {
|
|
195
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
196
|
+
isOptional: false,
|
|
197
|
+
defaultValue: 30000
|
|
198
|
+
},
|
|
199
|
+
version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
200
|
+
tags: {
|
|
201
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
202
|
+
isArray: true,
|
|
203
|
+
isOptional: true
|
|
204
|
+
},
|
|
205
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
206
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
var ToolSummaryModel = defineSchemaModel({
|
|
210
|
+
name: "ToolSummary",
|
|
211
|
+
description: "Summary of a tool for list views",
|
|
212
|
+
fields: {
|
|
213
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
214
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
215
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
216
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
217
|
+
category: { type: ToolCategoryEnum, isOptional: false },
|
|
218
|
+
status: { type: ToolStatusEnum, isOptional: false },
|
|
219
|
+
version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
220
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
var CreateToolInputModel = defineSchemaModel({
|
|
224
|
+
name: "CreateToolInput",
|
|
225
|
+
description: "Input for creating a tool",
|
|
226
|
+
fields: {
|
|
227
|
+
organizationId: {
|
|
228
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
229
|
+
isOptional: false
|
|
230
|
+
},
|
|
231
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
232
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
233
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
234
|
+
category: { type: ToolCategoryEnum, isOptional: true },
|
|
235
|
+
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
236
|
+
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
237
|
+
implementationType: { type: ImplementationTypeEnum, isOptional: false },
|
|
238
|
+
implementationConfig: {
|
|
239
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
240
|
+
isOptional: false
|
|
241
|
+
},
|
|
242
|
+
maxInvocationsPerMinute: {
|
|
243
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
244
|
+
isOptional: true
|
|
245
|
+
},
|
|
246
|
+
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
247
|
+
tags: {
|
|
248
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
249
|
+
isArray: true,
|
|
250
|
+
isOptional: true
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
var UpdateToolInputModel = defineSchemaModel({
|
|
255
|
+
name: "UpdateToolInput",
|
|
256
|
+
description: "Input for updating a tool",
|
|
257
|
+
fields: {
|
|
258
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
259
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: true },
|
|
260
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
261
|
+
status: { type: ToolStatusEnum, isOptional: true },
|
|
262
|
+
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
263
|
+
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
264
|
+
implementationConfig: {
|
|
265
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
266
|
+
isOptional: true
|
|
267
|
+
},
|
|
268
|
+
maxInvocationsPerMinute: {
|
|
269
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
270
|
+
isOptional: true
|
|
271
|
+
},
|
|
272
|
+
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
273
|
+
tags: {
|
|
274
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
275
|
+
isArray: true,
|
|
276
|
+
isOptional: true
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// src/tool/tool.operation.ts
|
|
282
|
+
import {
|
|
283
|
+
defineCommand,
|
|
284
|
+
defineQuery
|
|
285
|
+
} from "@contractspec/lib.contracts-spec/operations";
|
|
286
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
287
|
+
var OWNERS = ["@agent-console-team"];
|
|
288
|
+
var CreateToolCommand = defineCommand({
|
|
289
|
+
meta: {
|
|
290
|
+
key: "agent.tool.create",
|
|
291
|
+
version: "1.0.0",
|
|
292
|
+
stability: "stable",
|
|
293
|
+
owners: [...OWNERS],
|
|
294
|
+
tags: ["tool", "create"],
|
|
295
|
+
description: "Creates a new AI tool definition.",
|
|
296
|
+
goal: "Allow users to define new tools that agents can use.",
|
|
297
|
+
context: "Called from the tool builder UI when creating a new tool."
|
|
298
|
+
},
|
|
299
|
+
io: {
|
|
300
|
+
input: CreateToolInputModel,
|
|
301
|
+
output: defineSchemaModel2({
|
|
302
|
+
name: "CreateToolOutput",
|
|
303
|
+
fields: {
|
|
304
|
+
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
305
|
+
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
306
|
+
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
307
|
+
status: { type: ToolStatusEnum, isOptional: false }
|
|
308
|
+
}
|
|
309
|
+
}),
|
|
310
|
+
errors: {
|
|
311
|
+
SLUG_EXISTS: {
|
|
312
|
+
description: "A tool with this slug already exists in the organization",
|
|
313
|
+
http: 409,
|
|
314
|
+
gqlCode: "SLUG_EXISTS",
|
|
315
|
+
when: "Slug is already taken"
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
policy: { auth: "user" },
|
|
320
|
+
sideEffects: {
|
|
321
|
+
emits: [
|
|
322
|
+
{
|
|
323
|
+
key: "tool.created",
|
|
324
|
+
version: "1.0.0",
|
|
325
|
+
stability: "stable",
|
|
326
|
+
owners: [...OWNERS],
|
|
327
|
+
tags: ["tool", "created"],
|
|
328
|
+
when: "Tool is successfully created",
|
|
329
|
+
payload: ToolSummaryModel
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
audit: ["tool.created"]
|
|
333
|
+
},
|
|
334
|
+
acceptance: {
|
|
335
|
+
scenarios: [
|
|
336
|
+
{
|
|
337
|
+
key: "create-tool-happy-path",
|
|
338
|
+
given: ["User is authenticated", "Organization exists"],
|
|
339
|
+
when: ["User submits valid tool configuration"],
|
|
340
|
+
then: ["New tool is created", "ToolCreated event is emitted"]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
key: "create-tool-slug-conflict",
|
|
344
|
+
given: ["Tool with same slug exists"],
|
|
345
|
+
when: ["User submits tool with duplicate slug"],
|
|
346
|
+
then: ["SLUG_EXISTS error is returned"]
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
examples: [
|
|
350
|
+
{
|
|
351
|
+
key: "create-api-tool",
|
|
352
|
+
input: {
|
|
353
|
+
name: "Weather API",
|
|
354
|
+
slug: "weather-api",
|
|
355
|
+
category: "api",
|
|
356
|
+
description: "Fetches weather data"
|
|
357
|
+
},
|
|
358
|
+
output: {
|
|
359
|
+
id: "tool-123",
|
|
360
|
+
name: "Weather API",
|
|
361
|
+
slug: "weather-api",
|
|
362
|
+
status: "draft"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
var UpdateToolCommand = defineCommand({
|
|
369
|
+
meta: {
|
|
370
|
+
key: "agent.tool.update",
|
|
371
|
+
version: "1.0.0",
|
|
372
|
+
stability: "stable",
|
|
373
|
+
owners: [...OWNERS],
|
|
374
|
+
tags: ["tool", "update"],
|
|
375
|
+
description: "Updates an existing AI tool definition.",
|
|
376
|
+
goal: "Allow users to modify tool settings and configuration.",
|
|
377
|
+
context: "Called from the tool settings UI."
|
|
378
|
+
},
|
|
379
|
+
io: {
|
|
380
|
+
input: UpdateToolInputModel,
|
|
381
|
+
output: defineSchemaModel2({
|
|
382
|
+
name: "UpdateToolOutput",
|
|
383
|
+
fields: {
|
|
384
|
+
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
385
|
+
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
386
|
+
status: { type: ToolStatusEnum, isOptional: false },
|
|
387
|
+
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
388
|
+
}
|
|
389
|
+
}),
|
|
390
|
+
errors: {
|
|
391
|
+
TOOL_NOT_FOUND: {
|
|
392
|
+
description: "The specified tool does not exist",
|
|
393
|
+
http: 404,
|
|
394
|
+
gqlCode: "TOOL_NOT_FOUND",
|
|
395
|
+
when: "Tool ID is invalid"
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
policy: { auth: "user" },
|
|
400
|
+
sideEffects: {
|
|
401
|
+
emits: [
|
|
402
|
+
{
|
|
403
|
+
key: "tool.updated",
|
|
404
|
+
version: "1.0.0",
|
|
405
|
+
stability: "stable",
|
|
406
|
+
owners: [...OWNERS],
|
|
407
|
+
tags: ["tool", "updated"],
|
|
408
|
+
when: "Tool is updated",
|
|
409
|
+
payload: ToolSummaryModel
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
audit: ["tool.updated"]
|
|
413
|
+
},
|
|
414
|
+
acceptance: {
|
|
415
|
+
scenarios: [
|
|
416
|
+
{
|
|
417
|
+
key: "update-tool-happy-path",
|
|
418
|
+
given: ["Tool exists", "User owns the tool"],
|
|
419
|
+
when: ["User submits updated configuration"],
|
|
420
|
+
then: ["Tool is updated", "ToolUpdated event is emitted"]
|
|
421
|
+
}
|
|
422
|
+
],
|
|
423
|
+
examples: [
|
|
424
|
+
{
|
|
425
|
+
key: "update-description",
|
|
426
|
+
input: { toolId: "tool-123", description: "Updated weather API tool" },
|
|
427
|
+
output: {
|
|
428
|
+
id: "tool-123",
|
|
429
|
+
name: "Weather API",
|
|
430
|
+
status: "draft",
|
|
431
|
+
updatedAt: "2025-01-01T00:00:00Z"
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
]
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
var GetToolQuery = defineQuery({
|
|
438
|
+
meta: {
|
|
439
|
+
key: "agent.tool.get",
|
|
440
|
+
version: "1.0.0",
|
|
441
|
+
stability: "stable",
|
|
442
|
+
owners: [...OWNERS],
|
|
443
|
+
tags: ["tool", "get"],
|
|
444
|
+
description: "Retrieves a tool by its ID.",
|
|
445
|
+
goal: "View detailed tool configuration.",
|
|
446
|
+
context: "Called when viewing tool details or editing."
|
|
447
|
+
},
|
|
448
|
+
io: {
|
|
449
|
+
input: defineSchemaModel2({
|
|
450
|
+
name: "GetToolInput",
|
|
451
|
+
fields: {
|
|
452
|
+
toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
453
|
+
}
|
|
454
|
+
}),
|
|
455
|
+
output: ToolModel,
|
|
456
|
+
errors: {
|
|
457
|
+
TOOL_NOT_FOUND: {
|
|
458
|
+
description: "The specified tool does not exist",
|
|
459
|
+
http: 404,
|
|
460
|
+
gqlCode: "TOOL_NOT_FOUND",
|
|
461
|
+
when: "Tool ID is invalid"
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
policy: { auth: "user" },
|
|
466
|
+
acceptance: {
|
|
467
|
+
scenarios: [
|
|
468
|
+
{
|
|
469
|
+
key: "get-tool-happy-path",
|
|
470
|
+
given: ["Tool exists"],
|
|
471
|
+
when: ["User requests tool by ID"],
|
|
472
|
+
then: ["Tool details are returned"]
|
|
473
|
+
}
|
|
474
|
+
],
|
|
475
|
+
examples: [
|
|
476
|
+
{
|
|
477
|
+
key: "get-basic",
|
|
478
|
+
input: { toolId: "tool-123" },
|
|
479
|
+
output: {
|
|
480
|
+
id: "tool-123",
|
|
481
|
+
name: "Weather API",
|
|
482
|
+
status: "active",
|
|
483
|
+
category: "api"
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
var ListToolsQuery = defineQuery({
|
|
490
|
+
meta: {
|
|
491
|
+
key: "agent.tool.list",
|
|
492
|
+
version: "1.0.0",
|
|
493
|
+
stability: "stable",
|
|
494
|
+
owners: [...OWNERS],
|
|
495
|
+
tags: ["tool", "list"],
|
|
496
|
+
description: "Lists tools for an organization with optional filtering.",
|
|
497
|
+
goal: "Browse and search available tools.",
|
|
498
|
+
context: "Tool list/dashboard view."
|
|
499
|
+
},
|
|
500
|
+
io: {
|
|
501
|
+
input: defineSchemaModel2({
|
|
502
|
+
name: "ListToolsInput",
|
|
503
|
+
fields: {
|
|
504
|
+
organizationId: {
|
|
505
|
+
type: ScalarTypeEnum2.String_unsecure(),
|
|
506
|
+
isOptional: false
|
|
507
|
+
},
|
|
508
|
+
category: { type: ToolCategoryEnum, isOptional: true },
|
|
509
|
+
status: { type: ToolStatusEnum, isOptional: true },
|
|
510
|
+
search: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
511
|
+
limit: {
|
|
512
|
+
type: ScalarTypeEnum2.Int_unsecure(),
|
|
513
|
+
isOptional: true,
|
|
514
|
+
defaultValue: 20
|
|
515
|
+
},
|
|
516
|
+
offset: {
|
|
517
|
+
type: ScalarTypeEnum2.Int_unsecure(),
|
|
518
|
+
isOptional: true,
|
|
519
|
+
defaultValue: 0
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}),
|
|
523
|
+
output: defineSchemaModel2({
|
|
524
|
+
name: "ListToolsOutput",
|
|
525
|
+
fields: {
|
|
526
|
+
items: { type: ToolSummaryModel, isArray: true, isOptional: false },
|
|
527
|
+
total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
528
|
+
hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
|
|
529
|
+
}
|
|
530
|
+
})
|
|
531
|
+
},
|
|
532
|
+
policy: { auth: "user" },
|
|
533
|
+
acceptance: {
|
|
534
|
+
scenarios: [
|
|
535
|
+
{
|
|
536
|
+
key: "list-tools-happy-path",
|
|
537
|
+
given: ["Organization has tools"],
|
|
538
|
+
when: ["User lists tools"],
|
|
539
|
+
then: ["Paginated list of tools is returned"]
|
|
540
|
+
}
|
|
541
|
+
],
|
|
542
|
+
examples: [
|
|
543
|
+
{
|
|
544
|
+
key: "list-by-category",
|
|
545
|
+
input: { organizationId: "org-123", category: "api", limit: 10 },
|
|
546
|
+
output: { items: [], total: 0, hasMore: false }
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
var TestToolCommand = defineCommand({
|
|
552
|
+
meta: {
|
|
553
|
+
key: "agent.tool.test",
|
|
554
|
+
version: "1.0.0",
|
|
555
|
+
stability: "stable",
|
|
556
|
+
owners: [...OWNERS],
|
|
557
|
+
tags: ["tool", "test"],
|
|
558
|
+
description: "Tests a tool with sample input to verify it works correctly.",
|
|
559
|
+
goal: "Validate tool configuration before deployment.",
|
|
560
|
+
context: "Tool builder UI - test panel."
|
|
561
|
+
},
|
|
562
|
+
io: {
|
|
563
|
+
input: defineSchemaModel2({
|
|
564
|
+
name: "TestToolInput",
|
|
565
|
+
fields: {
|
|
566
|
+
toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
567
|
+
testInput: { type: ScalarTypeEnum2.JSONObject(), isOptional: false }
|
|
568
|
+
}
|
|
569
|
+
}),
|
|
570
|
+
output: defineSchemaModel2({
|
|
571
|
+
name: "TestToolOutput",
|
|
572
|
+
fields: {
|
|
573
|
+
success: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
574
|
+
output: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
575
|
+
error: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
576
|
+
durationMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false }
|
|
577
|
+
}
|
|
578
|
+
}),
|
|
579
|
+
errors: {
|
|
580
|
+
TOOL_NOT_FOUND: {
|
|
581
|
+
description: "The specified tool does not exist",
|
|
582
|
+
http: 404,
|
|
583
|
+
gqlCode: "TOOL_NOT_FOUND",
|
|
584
|
+
when: "Tool ID is invalid"
|
|
585
|
+
},
|
|
586
|
+
TOOL_EXECUTION_ERROR: {
|
|
587
|
+
description: "Tool execution failed",
|
|
588
|
+
http: 500,
|
|
589
|
+
gqlCode: "TOOL_EXECUTION_ERROR",
|
|
590
|
+
when: "Tool returns an error"
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
policy: { auth: "user" },
|
|
595
|
+
sideEffects: { audit: ["tool.tested"] },
|
|
596
|
+
acceptance: {
|
|
597
|
+
scenarios: [
|
|
598
|
+
{
|
|
599
|
+
key: "test-tool-success",
|
|
600
|
+
given: ["Tool exists", "Tool is configured correctly"],
|
|
601
|
+
when: ["User runs test with valid input"],
|
|
602
|
+
then: ["Tool executes successfully", "Output is returned"]
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
key: "test-tool-failure",
|
|
606
|
+
given: ["Tool exists", "Tool has configuration error"],
|
|
607
|
+
when: ["User runs test"],
|
|
608
|
+
then: ["TOOL_EXECUTION_ERROR is returned"]
|
|
609
|
+
}
|
|
610
|
+
],
|
|
611
|
+
examples: [
|
|
612
|
+
{
|
|
613
|
+
key: "test-weather-api",
|
|
614
|
+
input: { toolId: "tool-123", testInput: { city: "Paris" } },
|
|
615
|
+
output: { success: true, output: { temperature: 22 }, durationMs: 150 }
|
|
616
|
+
}
|
|
617
|
+
]
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
|
|
145
621
|
// src/tool/tool.handler.ts
|
|
622
|
+
var nextMockToolId = MOCK_TOOLS.length + 1;
|
|
146
623
|
async function mockListToolsHandler(input) {
|
|
147
624
|
const {
|
|
148
625
|
organizationId,
|
|
@@ -185,7 +662,7 @@ async function mockCreateToolHandler(input) {
|
|
|
185
662
|
if (exists)
|
|
186
663
|
throw new Error("SLUG_EXISTS");
|
|
187
664
|
return {
|
|
188
|
-
id: `tool-${
|
|
665
|
+
id: `tool-${nextMockToolId++}`,
|
|
189
666
|
name: input.name,
|
|
190
667
|
slug: input.slug,
|
|
191
668
|
status: "DRAFT"
|
|
@@ -206,12 +683,11 @@ async function mockTestToolHandler(input) {
|
|
|
206
683
|
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
207
684
|
if (!tool)
|
|
208
685
|
throw new Error("TOOL_NOT_FOUND");
|
|
209
|
-
const startTime = Date.now();
|
|
210
686
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
211
687
|
return {
|
|
212
688
|
success: true,
|
|
213
689
|
output: { result: "Test successful", input: input.testInput },
|
|
214
|
-
durationMs:
|
|
690
|
+
durationMs: 100
|
|
215
691
|
};
|
|
216
692
|
}
|
|
217
693
|
export {
|