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