@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
package/dist/tool/index.js
CHANGED
|
@@ -143,164 +143,6 @@ var MOCK_TOOLS = [
|
|
|
143
143
|
}
|
|
144
144
|
];
|
|
145
145
|
|
|
146
|
-
// src/tool/tool.handler.ts
|
|
147
|
-
async function mockListToolsHandler(input) {
|
|
148
|
-
const {
|
|
149
|
-
organizationId,
|
|
150
|
-
category,
|
|
151
|
-
status,
|
|
152
|
-
search,
|
|
153
|
-
limit = 20,
|
|
154
|
-
offset = 0
|
|
155
|
-
} = input;
|
|
156
|
-
let filtered = MOCK_TOOLS.filter((t) => t.organizationId === organizationId);
|
|
157
|
-
if (category)
|
|
158
|
-
filtered = filtered.filter((t) => t.category === category);
|
|
159
|
-
if (status)
|
|
160
|
-
filtered = filtered.filter((t) => t.status === status);
|
|
161
|
-
if (search) {
|
|
162
|
-
const q = search.toLowerCase();
|
|
163
|
-
filtered = filtered.filter((t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q));
|
|
164
|
-
}
|
|
165
|
-
const total = filtered.length;
|
|
166
|
-
const items = filtered.slice(offset, offset + limit).map((t) => ({
|
|
167
|
-
id: t.id,
|
|
168
|
-
name: t.name,
|
|
169
|
-
slug: t.slug,
|
|
170
|
-
description: t.description,
|
|
171
|
-
category: t.category,
|
|
172
|
-
status: t.status,
|
|
173
|
-
version: t.version,
|
|
174
|
-
createdAt: t.createdAt
|
|
175
|
-
}));
|
|
176
|
-
return { items, total, hasMore: offset + limit < total };
|
|
177
|
-
}
|
|
178
|
-
async function mockGetToolHandler(input) {
|
|
179
|
-
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
180
|
-
if (!tool)
|
|
181
|
-
throw new Error("TOOL_NOT_FOUND");
|
|
182
|
-
return tool;
|
|
183
|
-
}
|
|
184
|
-
async function mockCreateToolHandler(input) {
|
|
185
|
-
const exists = MOCK_TOOLS.some((t) => t.organizationId === input.organizationId && t.slug === input.slug);
|
|
186
|
-
if (exists)
|
|
187
|
-
throw new Error("SLUG_EXISTS");
|
|
188
|
-
return {
|
|
189
|
-
id: `tool-${Date.now()}`,
|
|
190
|
-
name: input.name,
|
|
191
|
-
slug: input.slug,
|
|
192
|
-
status: "DRAFT"
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
async function mockUpdateToolHandler(input) {
|
|
196
|
-
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
197
|
-
if (!tool)
|
|
198
|
-
throw new Error("TOOL_NOT_FOUND");
|
|
199
|
-
return {
|
|
200
|
-
id: tool.id,
|
|
201
|
-
name: input.name ?? tool.name,
|
|
202
|
-
status: input.status ?? tool.status,
|
|
203
|
-
updatedAt: new Date
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
async function mockTestToolHandler(input) {
|
|
207
|
-
const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
|
|
208
|
-
if (!tool)
|
|
209
|
-
throw new Error("TOOL_NOT_FOUND");
|
|
210
|
-
const startTime = Date.now();
|
|
211
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
212
|
-
return {
|
|
213
|
-
success: true,
|
|
214
|
-
output: { result: "Test successful", input: input.testInput },
|
|
215
|
-
durationMs: Date.now() - startTime
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// src/tool/tool.entity.ts
|
|
220
|
-
import {
|
|
221
|
-
defineEntity,
|
|
222
|
-
defineEntityEnum,
|
|
223
|
-
field,
|
|
224
|
-
index
|
|
225
|
-
} from "@contractspec/lib.schema";
|
|
226
|
-
var ToolCategoryEntityEnum = defineEntityEnum({
|
|
227
|
-
name: "ToolCategory",
|
|
228
|
-
values: [
|
|
229
|
-
"RETRIEVAL",
|
|
230
|
-
"COMPUTATION",
|
|
231
|
-
"COMMUNICATION",
|
|
232
|
-
"INTEGRATION",
|
|
233
|
-
"UTILITY",
|
|
234
|
-
"CUSTOM"
|
|
235
|
-
],
|
|
236
|
-
description: "Category of tool"
|
|
237
|
-
});
|
|
238
|
-
var ToolStatusEntityEnum = defineEntityEnum({
|
|
239
|
-
name: "ToolStatus",
|
|
240
|
-
values: ["DRAFT", "ACTIVE", "DEPRECATED", "DISABLED"],
|
|
241
|
-
description: "Status of tool"
|
|
242
|
-
});
|
|
243
|
-
var ImplementationTypeEntityEnum = defineEntityEnum({
|
|
244
|
-
name: "ImplementationType",
|
|
245
|
-
values: ["http", "function", "workflow"],
|
|
246
|
-
description: "How the tool is implemented"
|
|
247
|
-
});
|
|
248
|
-
var ToolEntity = defineEntity({
|
|
249
|
-
name: "Tool",
|
|
250
|
-
schema: "agent_console",
|
|
251
|
-
description: "An AI tool that can be used by agents.",
|
|
252
|
-
fields: {
|
|
253
|
-
id: field.id(),
|
|
254
|
-
organizationId: field.string({
|
|
255
|
-
description: "Organization that owns this tool"
|
|
256
|
-
}),
|
|
257
|
-
name: field.string({ description: "Tool name" }),
|
|
258
|
-
slug: field.string({ description: "URL-safe identifier" }),
|
|
259
|
-
description: field.string({ description: "Tool description" }),
|
|
260
|
-
category: field.enum("ToolCategory", { default: "CUSTOM" }),
|
|
261
|
-
status: field.enum("ToolStatus", { default: "DRAFT" }),
|
|
262
|
-
parametersSchema: field.json({
|
|
263
|
-
description: "JSON Schema for tool parameters"
|
|
264
|
-
}),
|
|
265
|
-
outputSchema: field.json({
|
|
266
|
-
isOptional: true,
|
|
267
|
-
description: "JSON Schema for tool output"
|
|
268
|
-
}),
|
|
269
|
-
implementationType: field.enum("ImplementationType"),
|
|
270
|
-
implementationConfig: field.json({
|
|
271
|
-
description: "Implementation configuration"
|
|
272
|
-
}),
|
|
273
|
-
maxInvocationsPerMinute: field.int({
|
|
274
|
-
isOptional: true,
|
|
275
|
-
description: "Rate limit"
|
|
276
|
-
}),
|
|
277
|
-
timeoutMs: field.int({ default: 30000, description: "Execution timeout" }),
|
|
278
|
-
version: field.string({ default: "1.0.0", description: "Tool version" }),
|
|
279
|
-
tags: field.string({
|
|
280
|
-
isArray: true,
|
|
281
|
-
isOptional: true,
|
|
282
|
-
description: "Tags for categorization"
|
|
283
|
-
}),
|
|
284
|
-
createdAt: field.createdAt(),
|
|
285
|
-
updatedAt: field.updatedAt(),
|
|
286
|
-
createdById: field.string({
|
|
287
|
-
isOptional: true,
|
|
288
|
-
description: "User who created this tool"
|
|
289
|
-
}),
|
|
290
|
-
agents: field.hasMany("Agent", { description: "Agents using this tool" })
|
|
291
|
-
},
|
|
292
|
-
indexes: [
|
|
293
|
-
index.unique(["organizationId", "slug"]),
|
|
294
|
-
index.on(["organizationId", "category"]),
|
|
295
|
-
index.on(["organizationId", "status"])
|
|
296
|
-
],
|
|
297
|
-
enums: [
|
|
298
|
-
ToolCategoryEntityEnum,
|
|
299
|
-
ToolStatusEntityEnum,
|
|
300
|
-
ImplementationTypeEntityEnum
|
|
301
|
-
]
|
|
302
|
-
});
|
|
303
|
-
|
|
304
146
|
// src/tool/tool.enum.ts
|
|
305
147
|
import { defineEnum } from "@contractspec/lib.schema";
|
|
306
148
|
var ToolCategoryEnum = defineEnum("ToolCategory", [
|
|
@@ -323,209 +165,114 @@ var ImplementationTypeEnum = defineEnum("ImplementationType", [
|
|
|
323
165
|
"workflow"
|
|
324
166
|
]);
|
|
325
167
|
|
|
326
|
-
// src/tool/tool.
|
|
327
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
168
|
+
// src/tool/tool.schema.ts
|
|
328
169
|
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
description: "Payload for tool created event",
|
|
170
|
+
var ToolModel = defineSchemaModel({
|
|
171
|
+
name: "Tool",
|
|
172
|
+
description: "AI tool definition",
|
|
333
173
|
fields: {
|
|
334
174
|
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
335
175
|
organizationId: {
|
|
336
176
|
type: ScalarTypeEnum.String_unsecure(),
|
|
337
177
|
isOptional: false
|
|
338
178
|
},
|
|
339
|
-
name: { type: ScalarTypeEnum.
|
|
179
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
340
180
|
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
341
|
-
|
|
342
|
-
implementationType: {
|
|
343
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
344
|
-
isOptional: false
|
|
345
|
-
},
|
|
346
|
-
createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
347
|
-
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
var ToolCreatedEvent = defineEvent({
|
|
351
|
-
meta: {
|
|
352
|
-
key: "agent.tool.created",
|
|
353
|
-
version: "1.0.0",
|
|
354
|
-
description: "A new AI tool was created.",
|
|
355
|
-
stability: "stable",
|
|
356
|
-
owners: [...OWNERS],
|
|
357
|
-
tags: ["tool", "created"]
|
|
358
|
-
},
|
|
359
|
-
payload: ToolCreatedPayload
|
|
360
|
-
});
|
|
361
|
-
var ToolUpdatedPayload = defineSchemaModel({
|
|
362
|
-
name: "ToolUpdatedPayload",
|
|
363
|
-
description: "Payload for tool updated event",
|
|
364
|
-
fields: {
|
|
365
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
366
|
-
organizationId: {
|
|
367
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
368
|
-
isOptional: false
|
|
369
|
-
},
|
|
370
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
371
|
-
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
372
|
-
updatedFields: {
|
|
373
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
374
|
-
isArray: true,
|
|
375
|
-
isOptional: false
|
|
376
|
-
},
|
|
377
|
-
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
var ToolUpdatedEvent = defineEvent({
|
|
381
|
-
meta: {
|
|
382
|
-
key: "agent.tool.updated",
|
|
383
|
-
version: "1.0.0",
|
|
384
|
-
description: "An AI tool configuration was updated.",
|
|
385
|
-
stability: "stable",
|
|
386
|
-
owners: [...OWNERS],
|
|
387
|
-
tags: ["tool", "updated"]
|
|
388
|
-
},
|
|
389
|
-
payload: ToolUpdatedPayload
|
|
390
|
-
});
|
|
391
|
-
var ToolStatusChangedPayload = defineSchemaModel({
|
|
392
|
-
name: "ToolStatusChangedPayload",
|
|
393
|
-
description: "Payload for tool status changed event",
|
|
394
|
-
fields: {
|
|
395
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
396
|
-
organizationId: {
|
|
397
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
398
|
-
isOptional: false
|
|
399
|
-
},
|
|
400
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
401
|
-
previousStatus: {
|
|
402
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
403
|
-
isOptional: false
|
|
404
|
-
},
|
|
405
|
-
newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
406
|
-
changedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
var ToolStatusChangedEvent = defineEvent({
|
|
410
|
-
meta: {
|
|
411
|
-
key: "agent.tool.statusChanged",
|
|
412
|
-
version: "1.0.0",
|
|
413
|
-
description: "An AI tool status was changed (activated, deprecated, disabled).",
|
|
414
|
-
stability: "stable",
|
|
415
|
-
owners: [...OWNERS],
|
|
416
|
-
tags: ["tool", "status"]
|
|
417
|
-
},
|
|
418
|
-
payload: ToolStatusChangedPayload
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// src/tool/tool.schema.ts
|
|
422
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
423
|
-
var ToolModel = defineSchemaModel2({
|
|
424
|
-
name: "Tool",
|
|
425
|
-
description: "AI tool definition",
|
|
426
|
-
fields: {
|
|
427
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
428
|
-
organizationId: {
|
|
429
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
430
|
-
isOptional: false
|
|
431
|
-
},
|
|
432
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
433
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
434
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
181
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
435
182
|
category: { type: ToolCategoryEnum, isOptional: false },
|
|
436
183
|
status: { type: ToolStatusEnum, isOptional: false },
|
|
437
|
-
parametersSchema: { type:
|
|
438
|
-
outputSchema: { type:
|
|
184
|
+
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
185
|
+
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
439
186
|
implementationType: { type: ImplementationTypeEnum, isOptional: false },
|
|
440
187
|
implementationConfig: {
|
|
441
|
-
type:
|
|
188
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
442
189
|
isOptional: false
|
|
443
190
|
},
|
|
444
191
|
maxInvocationsPerMinute: {
|
|
445
|
-
type:
|
|
192
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
446
193
|
isOptional: true
|
|
447
194
|
},
|
|
448
195
|
timeoutMs: {
|
|
449
|
-
type:
|
|
196
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
450
197
|
isOptional: false,
|
|
451
198
|
defaultValue: 30000
|
|
452
199
|
},
|
|
453
|
-
version: { type:
|
|
200
|
+
version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
454
201
|
tags: {
|
|
455
|
-
type:
|
|
202
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
456
203
|
isArray: true,
|
|
457
204
|
isOptional: true
|
|
458
205
|
},
|
|
459
|
-
createdAt: { type:
|
|
460
|
-
updatedAt: { type:
|
|
206
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
207
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
461
208
|
}
|
|
462
209
|
});
|
|
463
|
-
var ToolSummaryModel =
|
|
210
|
+
var ToolSummaryModel = defineSchemaModel({
|
|
464
211
|
name: "ToolSummary",
|
|
465
212
|
description: "Summary of a tool for list views",
|
|
466
213
|
fields: {
|
|
467
|
-
id: { type:
|
|
468
|
-
name: { type:
|
|
469
|
-
slug: { type:
|
|
470
|
-
description: { type:
|
|
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 },
|
|
471
218
|
category: { type: ToolCategoryEnum, isOptional: false },
|
|
472
219
|
status: { type: ToolStatusEnum, isOptional: false },
|
|
473
|
-
version: { type:
|
|
474
|
-
createdAt: { type:
|
|
220
|
+
version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
221
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
475
222
|
}
|
|
476
223
|
});
|
|
477
|
-
var CreateToolInputModel =
|
|
224
|
+
var CreateToolInputModel = defineSchemaModel({
|
|
478
225
|
name: "CreateToolInput",
|
|
479
226
|
description: "Input for creating a tool",
|
|
480
227
|
fields: {
|
|
481
228
|
organizationId: {
|
|
482
|
-
type:
|
|
229
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
483
230
|
isOptional: false
|
|
484
231
|
},
|
|
485
|
-
name: { type:
|
|
486
|
-
slug: { type:
|
|
487
|
-
description: { type:
|
|
232
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
233
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
234
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
488
235
|
category: { type: ToolCategoryEnum, isOptional: true },
|
|
489
|
-
parametersSchema: { type:
|
|
490
|
-
outputSchema: { type:
|
|
236
|
+
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
|
|
237
|
+
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
491
238
|
implementationType: { type: ImplementationTypeEnum, isOptional: false },
|
|
492
239
|
implementationConfig: {
|
|
493
|
-
type:
|
|
240
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
494
241
|
isOptional: false
|
|
495
242
|
},
|
|
496
243
|
maxInvocationsPerMinute: {
|
|
497
|
-
type:
|
|
244
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
498
245
|
isOptional: true
|
|
499
246
|
},
|
|
500
|
-
timeoutMs: { type:
|
|
247
|
+
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
501
248
|
tags: {
|
|
502
|
-
type:
|
|
249
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
503
250
|
isArray: true,
|
|
504
251
|
isOptional: true
|
|
505
252
|
}
|
|
506
253
|
}
|
|
507
254
|
});
|
|
508
|
-
var UpdateToolInputModel =
|
|
255
|
+
var UpdateToolInputModel = defineSchemaModel({
|
|
509
256
|
name: "UpdateToolInput",
|
|
510
257
|
description: "Input for updating a tool",
|
|
511
258
|
fields: {
|
|
512
|
-
toolId: { type:
|
|
513
|
-
name: { type:
|
|
514
|
-
description: { type:
|
|
259
|
+
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
260
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: true },
|
|
261
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
515
262
|
status: { type: ToolStatusEnum, isOptional: true },
|
|
516
|
-
parametersSchema: { type:
|
|
517
|
-
outputSchema: { type:
|
|
263
|
+
parametersSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
264
|
+
outputSchema: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
|
|
518
265
|
implementationConfig: {
|
|
519
|
-
type:
|
|
266
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
520
267
|
isOptional: true
|
|
521
268
|
},
|
|
522
269
|
maxInvocationsPerMinute: {
|
|
523
|
-
type:
|
|
270
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
524
271
|
isOptional: true
|
|
525
272
|
},
|
|
526
|
-
timeoutMs: { type:
|
|
273
|
+
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
527
274
|
tags: {
|
|
528
|
-
type:
|
|
275
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
529
276
|
isArray: true,
|
|
530
277
|
isOptional: true
|
|
531
278
|
}
|
|
@@ -537,14 +284,14 @@ import {
|
|
|
537
284
|
defineCommand,
|
|
538
285
|
defineQuery
|
|
539
286
|
} from "@contractspec/lib.contracts-spec/operations";
|
|
540
|
-
import { defineSchemaModel as
|
|
541
|
-
var
|
|
287
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
288
|
+
var OWNERS = ["@agent-console-team"];
|
|
542
289
|
var CreateToolCommand = defineCommand({
|
|
543
290
|
meta: {
|
|
544
291
|
key: "agent.tool.create",
|
|
545
292
|
version: "1.0.0",
|
|
546
293
|
stability: "stable",
|
|
547
|
-
owners: [...
|
|
294
|
+
owners: [...OWNERS],
|
|
548
295
|
tags: ["tool", "create"],
|
|
549
296
|
description: "Creates a new AI tool definition.",
|
|
550
297
|
goal: "Allow users to define new tools that agents can use.",
|
|
@@ -552,12 +299,12 @@ var CreateToolCommand = defineCommand({
|
|
|
552
299
|
},
|
|
553
300
|
io: {
|
|
554
301
|
input: CreateToolInputModel,
|
|
555
|
-
output:
|
|
302
|
+
output: defineSchemaModel2({
|
|
556
303
|
name: "CreateToolOutput",
|
|
557
304
|
fields: {
|
|
558
|
-
id: { type:
|
|
559
|
-
name: { type:
|
|
560
|
-
slug: { type:
|
|
305
|
+
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
306
|
+
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
307
|
+
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
561
308
|
status: { type: ToolStatusEnum, isOptional: false }
|
|
562
309
|
}
|
|
563
310
|
}),
|
|
@@ -577,7 +324,7 @@ var CreateToolCommand = defineCommand({
|
|
|
577
324
|
key: "tool.created",
|
|
578
325
|
version: "1.0.0",
|
|
579
326
|
stability: "stable",
|
|
580
|
-
owners: [...
|
|
327
|
+
owners: [...OWNERS],
|
|
581
328
|
tags: ["tool", "created"],
|
|
582
329
|
when: "Tool is successfully created",
|
|
583
330
|
payload: ToolSummaryModel
|
|
@@ -624,7 +371,7 @@ var UpdateToolCommand = defineCommand({
|
|
|
624
371
|
key: "agent.tool.update",
|
|
625
372
|
version: "1.0.0",
|
|
626
373
|
stability: "stable",
|
|
627
|
-
owners: [...
|
|
374
|
+
owners: [...OWNERS],
|
|
628
375
|
tags: ["tool", "update"],
|
|
629
376
|
description: "Updates an existing AI tool definition.",
|
|
630
377
|
goal: "Allow users to modify tool settings and configuration.",
|
|
@@ -632,13 +379,13 @@ var UpdateToolCommand = defineCommand({
|
|
|
632
379
|
},
|
|
633
380
|
io: {
|
|
634
381
|
input: UpdateToolInputModel,
|
|
635
|
-
output:
|
|
382
|
+
output: defineSchemaModel2({
|
|
636
383
|
name: "UpdateToolOutput",
|
|
637
384
|
fields: {
|
|
638
|
-
id: { type:
|
|
639
|
-
name: { type:
|
|
385
|
+
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
386
|
+
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
640
387
|
status: { type: ToolStatusEnum, isOptional: false },
|
|
641
|
-
updatedAt: { type:
|
|
388
|
+
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
642
389
|
}
|
|
643
390
|
}),
|
|
644
391
|
errors: {
|
|
@@ -657,7 +404,7 @@ var UpdateToolCommand = defineCommand({
|
|
|
657
404
|
key: "tool.updated",
|
|
658
405
|
version: "1.0.0",
|
|
659
406
|
stability: "stable",
|
|
660
|
-
owners: [...
|
|
407
|
+
owners: [...OWNERS],
|
|
661
408
|
tags: ["tool", "updated"],
|
|
662
409
|
when: "Tool is updated",
|
|
663
410
|
payload: ToolSummaryModel
|
|
@@ -693,17 +440,17 @@ var GetToolQuery = defineQuery({
|
|
|
693
440
|
key: "agent.tool.get",
|
|
694
441
|
version: "1.0.0",
|
|
695
442
|
stability: "stable",
|
|
696
|
-
owners: [...
|
|
443
|
+
owners: [...OWNERS],
|
|
697
444
|
tags: ["tool", "get"],
|
|
698
445
|
description: "Retrieves a tool by its ID.",
|
|
699
446
|
goal: "View detailed tool configuration.",
|
|
700
447
|
context: "Called when viewing tool details or editing."
|
|
701
448
|
},
|
|
702
449
|
io: {
|
|
703
|
-
input:
|
|
450
|
+
input: defineSchemaModel2({
|
|
704
451
|
name: "GetToolInput",
|
|
705
452
|
fields: {
|
|
706
|
-
toolId: { type:
|
|
453
|
+
toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
707
454
|
}
|
|
708
455
|
}),
|
|
709
456
|
output: ToolModel,
|
|
@@ -745,41 +492,41 @@ var ListToolsQuery = defineQuery({
|
|
|
745
492
|
key: "agent.tool.list",
|
|
746
493
|
version: "1.0.0",
|
|
747
494
|
stability: "stable",
|
|
748
|
-
owners: [...
|
|
495
|
+
owners: [...OWNERS],
|
|
749
496
|
tags: ["tool", "list"],
|
|
750
497
|
description: "Lists tools for an organization with optional filtering.",
|
|
751
498
|
goal: "Browse and search available tools.",
|
|
752
499
|
context: "Tool list/dashboard view."
|
|
753
500
|
},
|
|
754
501
|
io: {
|
|
755
|
-
input:
|
|
502
|
+
input: defineSchemaModel2({
|
|
756
503
|
name: "ListToolsInput",
|
|
757
504
|
fields: {
|
|
758
505
|
organizationId: {
|
|
759
|
-
type:
|
|
506
|
+
type: ScalarTypeEnum2.String_unsecure(),
|
|
760
507
|
isOptional: false
|
|
761
508
|
},
|
|
762
509
|
category: { type: ToolCategoryEnum, isOptional: true },
|
|
763
510
|
status: { type: ToolStatusEnum, isOptional: true },
|
|
764
|
-
search: { type:
|
|
511
|
+
search: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
765
512
|
limit: {
|
|
766
|
-
type:
|
|
513
|
+
type: ScalarTypeEnum2.Int_unsecure(),
|
|
767
514
|
isOptional: true,
|
|
768
515
|
defaultValue: 20
|
|
769
516
|
},
|
|
770
517
|
offset: {
|
|
771
|
-
type:
|
|
518
|
+
type: ScalarTypeEnum2.Int_unsecure(),
|
|
772
519
|
isOptional: true,
|
|
773
520
|
defaultValue: 0
|
|
774
521
|
}
|
|
775
522
|
}
|
|
776
523
|
}),
|
|
777
|
-
output:
|
|
524
|
+
output: defineSchemaModel2({
|
|
778
525
|
name: "ListToolsOutput",
|
|
779
526
|
fields: {
|
|
780
527
|
items: { type: ToolSummaryModel, isArray: true, isOptional: false },
|
|
781
|
-
total: { type:
|
|
782
|
-
hasMore: { type:
|
|
528
|
+
total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
529
|
+
hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
|
|
783
530
|
}
|
|
784
531
|
})
|
|
785
532
|
},
|
|
@@ -807,27 +554,27 @@ var TestToolCommand = defineCommand({
|
|
|
807
554
|
key: "agent.tool.test",
|
|
808
555
|
version: "1.0.0",
|
|
809
556
|
stability: "stable",
|
|
810
|
-
owners: [...
|
|
557
|
+
owners: [...OWNERS],
|
|
811
558
|
tags: ["tool", "test"],
|
|
812
559
|
description: "Tests a tool with sample input to verify it works correctly.",
|
|
813
560
|
goal: "Validate tool configuration before deployment.",
|
|
814
561
|
context: "Tool builder UI - test panel."
|
|
815
562
|
},
|
|
816
563
|
io: {
|
|
817
|
-
input:
|
|
564
|
+
input: defineSchemaModel2({
|
|
818
565
|
name: "TestToolInput",
|
|
819
566
|
fields: {
|
|
820
|
-
toolId: { type:
|
|
821
|
-
testInput: { type:
|
|
567
|
+
toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
568
|
+
testInput: { type: ScalarTypeEnum2.JSONObject(), isOptional: false }
|
|
822
569
|
}
|
|
823
570
|
}),
|
|
824
|
-
output:
|
|
571
|
+
output: defineSchemaModel2({
|
|
825
572
|
name: "TestToolOutput",
|
|
826
573
|
fields: {
|
|
827
|
-
success: { type:
|
|
828
|
-
output: { type:
|
|
829
|
-
error: { type:
|
|
830
|
-
durationMs: { type:
|
|
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 }
|
|
831
578
|
}
|
|
832
579
|
}),
|
|
833
580
|
errors: {
|
|
@@ -872,6 +619,259 @@ var TestToolCommand = defineCommand({
|
|
|
872
619
|
}
|
|
873
620
|
});
|
|
874
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
875
|
// src/tool/tool.presentation.ts
|
|
876
876
|
import {
|
|
877
877
|
definePresentation,
|