@contractspec/example.agent-console 3.8.9 → 3.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +225 -222
- package/CHANGELOG.md +18 -0
- package/dist/agent/agent.entity.js +1 -127
- package/dist/agent/agent.enum.js +1 -25
- package/dist/agent/agent.event.js +1 -116
- package/dist/agent/agent.handler.js +1 -1030
- package/dist/agent/agent.operation.js +1 -735
- package/dist/agent/agent.presentation.js +1 -282
- package/dist/agent/agent.schema.js +1 -215
- package/dist/agent/agent.test-spec.js +1 -58
- package/dist/agent/index.js +1 -1248
- package/dist/agent.capability.js +1 -19
- package/dist/agent.feature.js +1 -305
- package/dist/browser/agent/agent.entity.js +1 -127
- package/dist/browser/agent/agent.enum.js +1 -25
- package/dist/browser/agent/agent.event.js +1 -116
- package/dist/browser/agent/agent.handler.js +1 -1030
- package/dist/browser/agent/agent.operation.js +1 -735
- package/dist/browser/agent/agent.presentation.js +1 -282
- package/dist/browser/agent/agent.schema.js +1 -215
- package/dist/browser/agent/agent.test-spec.js +1 -58
- package/dist/browser/agent/index.js +1 -1248
- package/dist/browser/agent.capability.js +1 -19
- package/dist/browser/agent.feature.js +1 -305
- package/dist/browser/docs/agent-console.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/example.js +1 -41
- package/dist/browser/handlers/agent.handlers.js +6 -2143
- package/dist/browser/handlers/index.js +6 -2943
- package/dist/browser/index.js +14 -6828
- package/dist/browser/presentations/index.js +1 -693
- package/dist/browser/run/index.js +1 -1363
- package/dist/browser/run/run.entity.js +1 -160
- package/dist/browser/run/run.enum.js +1 -34
- package/dist/browser/run/run.event.js +1 -217
- package/dist/browser/run/run.handler.js +1 -919
- package/dist/browser/run/run.operation.js +1 -667
- package/dist/browser/run/run.presentation.js +1 -223
- package/dist/browser/run/run.schema.js +1 -179
- package/dist/browser/run/run.test-spec.js +1 -58
- package/dist/browser/seeders/index.js +2 -21
- package/dist/browser/shared/index.js +1 -626
- package/dist/browser/shared/mock-agents.js +1 -82
- package/dist/browser/shared/mock-runs.js +1 -113
- package/dist/browser/shared/mock-tools.js +1 -146
- package/dist/browser/tool/index.js +1 -949
- package/dist/browser/tool/tool.entity.js +1 -90
- package/dist/browser/tool/tool.enum.js +1 -26
- package/dist/browser/tool/tool.event.js +1 -99
- package/dist/browser/tool/tool.handler.js +1 -699
- package/dist/browser/tool/tool.operation.js +1 -482
- package/dist/browser/tool/tool.presentation.js +1 -188
- package/dist/browser/tool/tool.schema.js +1 -141
- package/dist/browser/tool/tool.test-spec.js +1 -58
- package/dist/browser/ui/AgentDashboard.js +1 -2527
- package/dist/browser/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/browser/ui/AgentRunList.js +1 -482
- package/dist/browser/ui/AgentToolRegistry.js +1 -212
- package/dist/browser/ui/ExecutionConsoleHost.js +1 -0
- package/dist/browser/ui/hooks/index.js +1 -740
- package/dist/browser/ui/hooks/useAgentList.js +1 -55
- package/dist/browser/ui/hooks/useAgentMutations.js +1 -530
- package/dist/browser/ui/hooks/useRunList.js +1 -70
- package/dist/browser/ui/hooks/useToolList.js +1 -85
- package/dist/browser/ui/index.js +5 -3018
- package/dist/browser/ui/modals/AgentActionsModal.js +1 -304
- package/dist/browser/ui/modals/CreateAgentModal.js +1 -243
- package/dist/browser/ui/modals/index.js +1 -546
- package/dist/browser/ui/overlays/demo-overlays.js +1 -64
- package/dist/browser/ui/overlays/index.js +1 -64
- package/dist/browser/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/browser/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/browser/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/browser/ui/renderers/index.js +5 -642
- package/dist/browser/ui/renderers/run-list.markdown.js +2 -50
- package/dist/browser/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/browser/ui/views/AgentListView.js +1 -165
- package/dist/browser/ui/views/RunDataTable.js +1 -326
- package/dist/browser/ui/views/RunListView.js +1 -479
- package/dist/browser/ui/views/ToolRegistryView.js +1 -209
- package/dist/browser/ui/views/index.js +1 -851
- package/dist/browser/ui/views/run-data-table.columns.js +1 -271
- package/dist/browser/ui/views/run-list.shared.js +1 -177
- package/dist/browser/visualizations/catalog.js +1 -134
- package/dist/browser/visualizations/index.js +1 -187
- package/dist/browser/visualizations/selectors.js +1 -181
- package/dist/docs/agent-console.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/example.js +1 -41
- package/dist/handlers/agent.handlers.js +6 -2143
- package/dist/handlers/index.js +6 -2943
- package/dist/index.js +14 -6828
- package/dist/node/agent/agent.entity.js +1 -127
- package/dist/node/agent/agent.enum.js +1 -25
- package/dist/node/agent/agent.event.js +1 -116
- package/dist/node/agent/agent.handler.js +1 -1030
- package/dist/node/agent/agent.operation.js +1 -735
- package/dist/node/agent/agent.presentation.js +1 -282
- package/dist/node/agent/agent.schema.js +1 -215
- package/dist/node/agent/agent.test-spec.js +1 -58
- package/dist/node/agent/index.js +1 -1248
- package/dist/node/agent.capability.js +1 -19
- package/dist/node/agent.feature.js +1 -305
- package/dist/node/docs/agent-console.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/example.js +1 -41
- package/dist/node/handlers/agent.handlers.js +6 -2143
- package/dist/node/handlers/index.js +6 -2943
- package/dist/node/index.js +14 -6828
- package/dist/node/presentations/index.js +1 -693
- package/dist/node/run/index.js +1 -1363
- package/dist/node/run/run.entity.js +1 -160
- package/dist/node/run/run.enum.js +1 -34
- package/dist/node/run/run.event.js +1 -217
- package/dist/node/run/run.handler.js +1 -919
- package/dist/node/run/run.operation.js +1 -667
- package/dist/node/run/run.presentation.js +1 -223
- package/dist/node/run/run.schema.js +1 -179
- package/dist/node/run/run.test-spec.js +1 -58
- package/dist/node/seeders/index.js +2 -21
- package/dist/node/shared/index.js +1 -626
- package/dist/node/shared/mock-agents.js +1 -82
- package/dist/node/shared/mock-runs.js +1 -113
- package/dist/node/shared/mock-tools.js +1 -146
- package/dist/node/tool/index.js +1 -949
- package/dist/node/tool/tool.entity.js +1 -90
- package/dist/node/tool/tool.enum.js +1 -26
- package/dist/node/tool/tool.event.js +1 -99
- package/dist/node/tool/tool.handler.js +1 -699
- package/dist/node/tool/tool.operation.js +1 -482
- package/dist/node/tool/tool.presentation.js +1 -188
- package/dist/node/tool/tool.schema.js +1 -141
- package/dist/node/tool/tool.test-spec.js +1 -58
- package/dist/node/ui/AgentDashboard.js +1 -2527
- package/dist/node/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/node/ui/AgentRunList.js +1 -482
- package/dist/node/ui/AgentToolRegistry.js +1 -212
- package/dist/node/ui/ExecutionConsoleHost.js +1 -0
- package/dist/node/ui/hooks/index.js +1 -740
- package/dist/node/ui/hooks/useAgentList.js +1 -55
- package/dist/node/ui/hooks/useAgentMutations.js +1 -530
- package/dist/node/ui/hooks/useRunList.js +1 -70
- package/dist/node/ui/hooks/useToolList.js +1 -85
- package/dist/node/ui/index.js +5 -3018
- package/dist/node/ui/modals/AgentActionsModal.js +1 -304
- package/dist/node/ui/modals/CreateAgentModal.js +1 -243
- package/dist/node/ui/modals/index.js +1 -546
- package/dist/node/ui/overlays/demo-overlays.js +1 -64
- package/dist/node/ui/overlays/index.js +1 -64
- package/dist/node/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/node/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/node/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/node/ui/renderers/index.js +5 -642
- package/dist/node/ui/renderers/run-list.markdown.js +2 -50
- package/dist/node/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/node/ui/views/AgentListView.js +1 -165
- package/dist/node/ui/views/RunDataTable.js +1 -326
- package/dist/node/ui/views/RunListView.js +1 -479
- package/dist/node/ui/views/ToolRegistryView.js +1 -209
- package/dist/node/ui/views/index.js +1 -851
- package/dist/node/ui/views/run-data-table.columns.js +1 -271
- package/dist/node/ui/views/run-list.shared.js +1 -177
- package/dist/node/visualizations/catalog.js +1 -134
- package/dist/node/visualizations/index.js +1 -187
- package/dist/node/visualizations/selectors.js +1 -181
- package/dist/presentations/index.js +1 -693
- package/dist/run/index.js +1 -1363
- package/dist/run/run.entity.js +1 -160
- package/dist/run/run.enum.js +1 -34
- package/dist/run/run.event.js +1 -217
- package/dist/run/run.handler.js +1 -919
- package/dist/run/run.operation.js +1 -667
- package/dist/run/run.presentation.js +1 -223
- package/dist/run/run.schema.js +1 -179
- package/dist/run/run.test-spec.js +1 -58
- package/dist/seeders/index.js +2 -21
- package/dist/shared/index.js +1 -626
- package/dist/shared/mock-agents.js +1 -82
- package/dist/shared/mock-runs.js +1 -113
- package/dist/shared/mock-tools.js +1 -146
- package/dist/tool/index.js +1 -949
- package/dist/tool/tool.entity.js +1 -90
- package/dist/tool/tool.enum.js +1 -26
- package/dist/tool/tool.event.js +1 -99
- package/dist/tool/tool.handler.js +1 -699
- package/dist/tool/tool.operation.js +1 -482
- package/dist/tool/tool.presentation.js +1 -188
- package/dist/tool/tool.schema.js +1 -141
- package/dist/tool/tool.test-spec.js +1 -58
- package/dist/ui/AgentDashboard.js +1 -2527
- package/dist/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/ui/AgentRunList.js +1 -482
- package/dist/ui/AgentToolRegistry.js +1 -212
- package/dist/ui/ExecutionConsoleHost.d.ts +1 -0
- package/dist/ui/ExecutionConsoleHost.js +2 -0
- package/dist/ui/ExecutionConsoleHost.test.d.ts +1 -0
- package/dist/ui/hooks/index.js +1 -740
- package/dist/ui/hooks/useAgentList.js +1 -55
- package/dist/ui/hooks/useAgentMutations.js +1 -530
- package/dist/ui/hooks/useRunList.js +1 -70
- package/dist/ui/hooks/useToolList.js +1 -85
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +5 -3018
- package/dist/ui/modals/AgentActionsModal.js +1 -304
- package/dist/ui/modals/CreateAgentModal.js +1 -243
- package/dist/ui/modals/index.js +1 -546
- package/dist/ui/overlays/demo-overlays.js +1 -64
- package/dist/ui/overlays/index.js +1 -64
- package/dist/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/ui/renderers/index.js +5 -642
- package/dist/ui/renderers/run-list.markdown.js +2 -50
- package/dist/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/ui/views/AgentListView.js +1 -165
- package/dist/ui/views/RunDataTable.js +1 -326
- package/dist/ui/views/RunListView.js +1 -479
- package/dist/ui/views/ToolRegistryView.js +1 -209
- package/dist/ui/views/index.js +1 -851
- package/dist/ui/views/run-data-table.columns.js +1 -271
- package/dist/ui/views/run-list.shared.js +1 -177
- package/dist/visualizations/catalog.js +1 -134
- package/dist/visualizations/index.js +1 -187
- package/dist/visualizations/selectors.js +1 -181
- package/package.json +26 -10
- package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
- package/src/ui/ExecutionConsoleHost.tsx +14 -0
- package/src/ui/index.ts +1 -1
|
@@ -1,1031 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/agent/agent.enum.ts
|
|
3
|
-
import { defineEnum } from "@contractspec/lib.schema";
|
|
4
|
-
var AgentStatusEnum = defineEnum("AgentStatus", [
|
|
5
|
-
"DRAFT",
|
|
6
|
-
"ACTIVE",
|
|
7
|
-
"PAUSED",
|
|
8
|
-
"ARCHIVED"
|
|
9
|
-
]);
|
|
10
|
-
var ModelProviderEnum = defineEnum("ModelProvider", [
|
|
11
|
-
"OPENAI",
|
|
12
|
-
"ANTHROPIC",
|
|
13
|
-
"GOOGLE",
|
|
14
|
-
"MISTRAL",
|
|
15
|
-
"CUSTOM"
|
|
16
|
-
]);
|
|
17
|
-
var ToolChoiceEnum = defineEnum("ToolChoice", [
|
|
18
|
-
"auto",
|
|
19
|
-
"required",
|
|
20
|
-
"none"
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
// src/agent/agent.event.ts
|
|
24
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
25
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
26
|
-
var OWNERS = ["@agent-console-team"];
|
|
27
|
-
var AgentCreatedPayload = defineSchemaModel({
|
|
28
|
-
name: "AgentCreatedPayload",
|
|
29
|
-
description: "Payload for agent created event",
|
|
30
|
-
fields: {
|
|
31
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
32
|
-
organizationId: {
|
|
33
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
34
|
-
isOptional: false
|
|
35
|
-
},
|
|
36
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
37
|
-
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
38
|
-
modelProvider: {
|
|
39
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
40
|
-
isOptional: false
|
|
41
|
-
},
|
|
42
|
-
modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
43
|
-
toolCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
44
|
-
createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
45
|
-
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
var AgentCreatedEvent = defineEvent({
|
|
49
|
-
meta: {
|
|
50
|
-
key: "agent-console.agent.created",
|
|
51
|
-
version: "1.0.0",
|
|
52
|
-
description: "A new AI agent was configured.",
|
|
53
|
-
stability: "stable",
|
|
54
|
-
owners: [...OWNERS],
|
|
55
|
-
tags: ["agent", "created"]
|
|
56
|
-
},
|
|
57
|
-
payload: AgentCreatedPayload
|
|
58
|
-
});
|
|
59
|
-
var AgentUpdatedPayload = defineSchemaModel({
|
|
60
|
-
name: "AgentUpdatedPayload",
|
|
61
|
-
description: "Payload for agent updated event",
|
|
62
|
-
fields: {
|
|
63
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
64
|
-
organizationId: {
|
|
65
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
66
|
-
isOptional: false
|
|
67
|
-
},
|
|
68
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
69
|
-
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
70
|
-
updatedFields: {
|
|
71
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
72
|
-
isArray: true,
|
|
73
|
-
isOptional: false
|
|
74
|
-
},
|
|
75
|
-
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
var AgentUpdatedEvent = defineEvent({
|
|
79
|
-
meta: {
|
|
80
|
-
key: "agent-console.agent.updated",
|
|
81
|
-
version: "1.0.0",
|
|
82
|
-
description: "An AI agent configuration was updated.",
|
|
83
|
-
stability: "stable",
|
|
84
|
-
owners: [...OWNERS],
|
|
85
|
-
tags: ["agent", "updated"]
|
|
86
|
-
},
|
|
87
|
-
payload: AgentUpdatedPayload
|
|
88
|
-
});
|
|
89
|
-
var AgentToolAssignedPayload = defineSchemaModel({
|
|
90
|
-
name: "AgentToolAssignedPayload",
|
|
91
|
-
description: "Payload for agent tool assigned event",
|
|
92
|
-
fields: {
|
|
93
|
-
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
94
|
-
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
95
|
-
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
96
|
-
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
97
|
-
assignedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
var AgentToolAssignedEvent = defineEvent({
|
|
101
|
-
meta: {
|
|
102
|
-
key: "agent-console.agent.toolAssigned",
|
|
103
|
-
version: "1.0.0",
|
|
104
|
-
description: "A tool was assigned to an agent.",
|
|
105
|
-
stability: "stable",
|
|
106
|
-
owners: [...OWNERS],
|
|
107
|
-
tags: ["agent", "tool", "assigned"]
|
|
108
|
-
},
|
|
109
|
-
payload: AgentToolAssignedPayload
|
|
110
|
-
});
|
|
111
|
-
var AgentToolRemovedPayload = defineSchemaModel({
|
|
112
|
-
name: "AgentToolRemovedPayload",
|
|
113
|
-
description: "Payload for agent tool removed event",
|
|
114
|
-
fields: {
|
|
115
|
-
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
116
|
-
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
117
|
-
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
118
|
-
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
119
|
-
removedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
var AgentToolRemovedEvent = defineEvent({
|
|
123
|
-
meta: {
|
|
124
|
-
key: "agent-console.agent.toolRemoved",
|
|
125
|
-
version: "1.0.0",
|
|
126
|
-
description: "A tool was removed from an agent.",
|
|
127
|
-
stability: "stable",
|
|
128
|
-
owners: [...OWNERS],
|
|
129
|
-
tags: ["agent", "tool", "removed"]
|
|
130
|
-
},
|
|
131
|
-
payload: AgentToolRemovedPayload
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// src/shared/mock-agents.ts
|
|
135
|
-
var MOCK_AGENTS = [
|
|
136
|
-
{
|
|
137
|
-
id: "agent-1",
|
|
138
|
-
organizationId: "demo-org",
|
|
139
|
-
name: "Customer Support Bot",
|
|
140
|
-
slug: "customer-support-bot",
|
|
141
|
-
description: "Handles tier-1 customer inquiries and routes complex issues.",
|
|
142
|
-
status: "ACTIVE",
|
|
143
|
-
modelProvider: "OPENAI",
|
|
144
|
-
modelName: "gpt-4o-mini",
|
|
145
|
-
modelConfig: { temperature: 0.7 },
|
|
146
|
-
systemPrompt: "You are a helpful customer support assistant.",
|
|
147
|
-
toolChoice: "auto",
|
|
148
|
-
maxIterations: 10,
|
|
149
|
-
timeoutMs: 120000,
|
|
150
|
-
version: "1.0.0",
|
|
151
|
-
tags: ["support", "tier-1"],
|
|
152
|
-
createdAt: new Date("2024-01-15T10:00:00Z"),
|
|
153
|
-
updatedAt: new Date("2024-03-20T14:30:00Z")
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
id: "agent-2",
|
|
157
|
-
organizationId: "demo-org",
|
|
158
|
-
name: "Code Review Assistant",
|
|
159
|
-
slug: "code-review-assistant",
|
|
160
|
-
description: "Reviews pull requests and provides actionable feedback.",
|
|
161
|
-
status: "ACTIVE",
|
|
162
|
-
modelProvider: "ANTHROPIC",
|
|
163
|
-
modelName: "claude-sonnet-4-20250514",
|
|
164
|
-
modelConfig: { temperature: 0.3 },
|
|
165
|
-
systemPrompt: "You are a code review expert.",
|
|
166
|
-
toolChoice: "auto",
|
|
167
|
-
maxIterations: 15,
|
|
168
|
-
timeoutMs: 180000,
|
|
169
|
-
version: "2.1.0",
|
|
170
|
-
tags: ["code", "review", "dev"],
|
|
171
|
-
createdAt: new Date("2024-02-10T09:00:00Z"),
|
|
172
|
-
updatedAt: new Date("2024-04-05T11:15:00Z")
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
id: "agent-3",
|
|
176
|
-
organizationId: "demo-org",
|
|
177
|
-
name: "Data Analyst",
|
|
178
|
-
slug: "data-analyst",
|
|
179
|
-
description: "Queries databases and generates insights from data.",
|
|
180
|
-
status: "PAUSED",
|
|
181
|
-
modelProvider: "OPENAI",
|
|
182
|
-
modelName: "gpt-4o",
|
|
183
|
-
modelConfig: { temperature: 0.5 },
|
|
184
|
-
systemPrompt: "You are a data analyst expert in SQL and analytics.",
|
|
185
|
-
toolChoice: "required",
|
|
186
|
-
maxIterations: 20,
|
|
187
|
-
timeoutMs: 300000,
|
|
188
|
-
version: "1.2.0",
|
|
189
|
-
tags: ["data", "analytics", "sql"],
|
|
190
|
-
createdAt: new Date("2024-03-01T08:00:00Z"),
|
|
191
|
-
updatedAt: new Date("2024-04-10T16:45:00Z")
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: "agent-4",
|
|
195
|
-
organizationId: "demo-org",
|
|
196
|
-
name: "Meeting Scheduler",
|
|
197
|
-
slug: "meeting-scheduler",
|
|
198
|
-
description: "Schedules meetings and manages calendar conflicts.",
|
|
199
|
-
status: "DRAFT",
|
|
200
|
-
modelProvider: "GOOGLE",
|
|
201
|
-
modelName: "gemini-2.0-flash",
|
|
202
|
-
modelConfig: { temperature: 0.2 },
|
|
203
|
-
systemPrompt: "You help schedule and organize meetings efficiently.",
|
|
204
|
-
toolChoice: "auto",
|
|
205
|
-
maxIterations: 5,
|
|
206
|
-
timeoutMs: 60000,
|
|
207
|
-
version: "0.1.0",
|
|
208
|
-
tags: ["calendar", "scheduling"],
|
|
209
|
-
createdAt: new Date("2024-04-01T12:00:00Z"),
|
|
210
|
-
updatedAt: new Date("2024-04-01T12:00:00Z")
|
|
211
|
-
}
|
|
212
|
-
];
|
|
213
|
-
|
|
214
|
-
// src/shared/mock-tools.ts
|
|
215
|
-
var MOCK_TOOLS = [
|
|
216
|
-
{
|
|
217
|
-
id: "tool-1",
|
|
218
|
-
organizationId: "demo-org",
|
|
219
|
-
name: "Web Search",
|
|
220
|
-
slug: "web-search",
|
|
221
|
-
description: "Search the web for real-time information using Brave API.",
|
|
222
|
-
category: "RETRIEVAL",
|
|
223
|
-
status: "ACTIVE",
|
|
224
|
-
parametersSchema: {
|
|
225
|
-
type: "object",
|
|
226
|
-
properties: {
|
|
227
|
-
query: { type: "string", description: "Search query" },
|
|
228
|
-
numResults: { type: "number", default: 10 }
|
|
229
|
-
},
|
|
230
|
-
required: ["query"]
|
|
231
|
-
},
|
|
232
|
-
outputSchema: { type: "array", items: { type: "object" } },
|
|
233
|
-
implementationType: "http",
|
|
234
|
-
implementationConfig: {
|
|
235
|
-
url: "https://api.brave.com/search",
|
|
236
|
-
method: "GET"
|
|
237
|
-
},
|
|
238
|
-
maxInvocationsPerMinute: 60,
|
|
239
|
-
timeoutMs: 30000,
|
|
240
|
-
version: "1.0.0",
|
|
241
|
-
tags: ["search", "web"],
|
|
242
|
-
createdAt: new Date("2024-01-01T00:00:00Z"),
|
|
243
|
-
updatedAt: new Date("2024-02-15T10:00:00Z")
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
id: "tool-2",
|
|
247
|
-
organizationId: "demo-org",
|
|
248
|
-
name: "SQL Query",
|
|
249
|
-
slug: "sql-query",
|
|
250
|
-
description: "Execute read-only SQL queries against the data warehouse.",
|
|
251
|
-
category: "RETRIEVAL",
|
|
252
|
-
status: "ACTIVE",
|
|
253
|
-
parametersSchema: {
|
|
254
|
-
type: "object",
|
|
255
|
-
properties: {
|
|
256
|
-
query: { type: "string", description: "SQL query" },
|
|
257
|
-
maxRows: { type: "number", default: 100 }
|
|
258
|
-
},
|
|
259
|
-
required: ["query"]
|
|
260
|
-
},
|
|
261
|
-
outputSchema: { type: "object" },
|
|
262
|
-
implementationType: "function",
|
|
263
|
-
implementationConfig: { handler: "executeSqlQuery" },
|
|
264
|
-
maxInvocationsPerMinute: 30,
|
|
265
|
-
timeoutMs: 60000,
|
|
266
|
-
version: "1.1.0",
|
|
267
|
-
tags: ["sql", "database"],
|
|
268
|
-
createdAt: new Date("2024-01-05T00:00:00Z"),
|
|
269
|
-
updatedAt: new Date("2024-03-10T14:00:00Z")
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
id: "tool-3",
|
|
273
|
-
organizationId: "demo-org",
|
|
274
|
-
name: "Email Sender",
|
|
275
|
-
slug: "email-sender",
|
|
276
|
-
description: "Send emails via SMTP or API.",
|
|
277
|
-
category: "COMMUNICATION",
|
|
278
|
-
status: "ACTIVE",
|
|
279
|
-
parametersSchema: {
|
|
280
|
-
type: "object",
|
|
281
|
-
properties: {
|
|
282
|
-
to: { type: "string" },
|
|
283
|
-
subject: { type: "string" },
|
|
284
|
-
body: { type: "string" }
|
|
285
|
-
},
|
|
286
|
-
required: ["to", "subject", "body"]
|
|
287
|
-
},
|
|
288
|
-
implementationType: "http",
|
|
289
|
-
implementationConfig: { url: "/api/send-email", method: "POST" },
|
|
290
|
-
maxInvocationsPerMinute: 10,
|
|
291
|
-
timeoutMs: 30000,
|
|
292
|
-
version: "1.0.0",
|
|
293
|
-
tags: ["email", "communication"],
|
|
294
|
-
createdAt: new Date("2024-02-01T00:00:00Z"),
|
|
295
|
-
updatedAt: new Date("2024-02-01T00:00:00Z")
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
id: "tool-4",
|
|
299
|
-
organizationId: "demo-org",
|
|
300
|
-
name: "GitHub Integration",
|
|
301
|
-
slug: "github-integration",
|
|
302
|
-
description: "Interact with GitHub repositories, PRs, and issues.",
|
|
303
|
-
category: "INTEGRATION",
|
|
304
|
-
status: "ACTIVE",
|
|
305
|
-
parametersSchema: {
|
|
306
|
-
type: "object",
|
|
307
|
-
properties: {
|
|
308
|
-
action: {
|
|
309
|
-
type: "string",
|
|
310
|
-
enum: ["list_prs", "get_pr", "create_comment"]
|
|
311
|
-
},
|
|
312
|
-
repo: { type: "string" },
|
|
313
|
-
params: { type: "object" }
|
|
314
|
-
},
|
|
315
|
-
required: ["action", "repo"]
|
|
316
|
-
},
|
|
317
|
-
implementationType: "http",
|
|
318
|
-
implementationConfig: { url: "https://api.github.com", auth: "token" },
|
|
319
|
-
maxInvocationsPerMinute: 100,
|
|
320
|
-
timeoutMs: 15000,
|
|
321
|
-
version: "2.0.0",
|
|
322
|
-
tags: ["github", "integration", "code"],
|
|
323
|
-
createdAt: new Date("2024-02-20T00:00:00Z"),
|
|
324
|
-
updatedAt: new Date("2024-04-01T09:00:00Z")
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
id: "tool-5",
|
|
328
|
-
organizationId: "demo-org",
|
|
329
|
-
name: "Calculator",
|
|
330
|
-
slug: "calculator",
|
|
331
|
-
description: "Perform mathematical calculations.",
|
|
332
|
-
category: "COMPUTATION",
|
|
333
|
-
status: "ACTIVE",
|
|
334
|
-
parametersSchema: {
|
|
335
|
-
type: "object",
|
|
336
|
-
properties: {
|
|
337
|
-
expression: {
|
|
338
|
-
type: "string",
|
|
339
|
-
description: "Math expression to evaluate"
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
required: ["expression"]
|
|
343
|
-
},
|
|
344
|
-
outputSchema: {
|
|
345
|
-
type: "object",
|
|
346
|
-
properties: { result: { type: "number" } }
|
|
347
|
-
},
|
|
348
|
-
implementationType: "function",
|
|
349
|
-
implementationConfig: { handler: "evaluateMath" },
|
|
350
|
-
timeoutMs: 5000,
|
|
351
|
-
version: "1.0.0",
|
|
352
|
-
tags: ["math", "utility"],
|
|
353
|
-
createdAt: new Date("2024-01-10T00:00:00Z"),
|
|
354
|
-
updatedAt: new Date("2024-01-10T00:00:00Z")
|
|
355
|
-
}
|
|
356
|
-
];
|
|
357
|
-
|
|
358
|
-
// src/agent/agent.schema.ts
|
|
359
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
360
|
-
var AgentModel = defineSchemaModel2({
|
|
361
|
-
name: "Agent",
|
|
362
|
-
description: "AI agent configuration",
|
|
363
|
-
fields: {
|
|
364
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
365
|
-
organizationId: {
|
|
366
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
367
|
-
isOptional: false
|
|
368
|
-
},
|
|
369
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
370
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
371
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
372
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
373
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
374
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
375
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
376
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
377
|
-
userPromptTemplate: {
|
|
378
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
379
|
-
isOptional: true
|
|
380
|
-
},
|
|
381
|
-
toolIds: {
|
|
382
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
383
|
-
isArray: true,
|
|
384
|
-
isOptional: true
|
|
385
|
-
},
|
|
386
|
-
toolChoice: {
|
|
387
|
-
type: ToolChoiceEnum,
|
|
388
|
-
isOptional: false,
|
|
389
|
-
defaultValue: "auto"
|
|
390
|
-
},
|
|
391
|
-
maxIterations: {
|
|
392
|
-
type: ScalarTypeEnum2.Int_unsecure(),
|
|
393
|
-
isOptional: false,
|
|
394
|
-
defaultValue: 10
|
|
395
|
-
},
|
|
396
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
397
|
-
timeoutMs: {
|
|
398
|
-
type: ScalarTypeEnum2.Int_unsecure(),
|
|
399
|
-
isOptional: false,
|
|
400
|
-
defaultValue: 120000
|
|
401
|
-
},
|
|
402
|
-
version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
403
|
-
tags: {
|
|
404
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
405
|
-
isArray: true,
|
|
406
|
-
isOptional: true
|
|
407
|
-
},
|
|
408
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
409
|
-
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
var AgentSummaryModel = defineSchemaModel2({
|
|
413
|
-
name: "AgentSummary",
|
|
414
|
-
description: "Summary of an agent for list views",
|
|
415
|
-
fields: {
|
|
416
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
417
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
418
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
419
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
420
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
421
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
422
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
423
|
-
version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
424
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
var AgentToolRefModel = defineSchemaModel2({
|
|
428
|
-
name: "AgentToolRef",
|
|
429
|
-
description: "Tool reference in agent context",
|
|
430
|
-
fields: {
|
|
431
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
432
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
433
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
434
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
435
|
-
category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
var AgentWithToolsModel = defineSchemaModel2({
|
|
439
|
-
name: "AgentWithTools",
|
|
440
|
-
description: "Agent with associated tools",
|
|
441
|
-
fields: {
|
|
442
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
443
|
-
organizationId: {
|
|
444
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
445
|
-
isOptional: false
|
|
446
|
-
},
|
|
447
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
448
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
449
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
450
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
451
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
452
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
453
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
454
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
455
|
-
userPromptTemplate: {
|
|
456
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
457
|
-
isOptional: true
|
|
458
|
-
},
|
|
459
|
-
toolIds: {
|
|
460
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
461
|
-
isArray: true,
|
|
462
|
-
isOptional: true
|
|
463
|
-
},
|
|
464
|
-
toolChoice: { type: ToolChoiceEnum, isOptional: false },
|
|
465
|
-
maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
466
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
467
|
-
timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
468
|
-
version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
469
|
-
tags: {
|
|
470
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
471
|
-
isArray: true,
|
|
472
|
-
isOptional: true
|
|
473
|
-
},
|
|
474
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
475
|
-
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
476
|
-
tools: { type: AgentToolRefModel, isArray: true, isOptional: true }
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
var CreateAgentInputModel = defineSchemaModel2({
|
|
480
|
-
name: "CreateAgentInput",
|
|
481
|
-
description: "Input for creating an agent",
|
|
482
|
-
fields: {
|
|
483
|
-
organizationId: {
|
|
484
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
485
|
-
isOptional: false
|
|
486
|
-
},
|
|
487
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
488
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
489
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
490
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
491
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
492
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
493
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
494
|
-
userPromptTemplate: {
|
|
495
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
496
|
-
isOptional: true
|
|
497
|
-
},
|
|
498
|
-
toolIds: {
|
|
499
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
500
|
-
isArray: true,
|
|
501
|
-
isOptional: true
|
|
502
|
-
},
|
|
503
|
-
toolChoice: { type: ToolChoiceEnum, isOptional: true },
|
|
504
|
-
maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
505
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
506
|
-
timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
507
|
-
tags: {
|
|
508
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
509
|
-
isArray: true,
|
|
510
|
-
isOptional: true
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
var UpdateAgentInputModel = defineSchemaModel2({
|
|
515
|
-
name: "UpdateAgentInput",
|
|
516
|
-
description: "Input for updating an agent",
|
|
517
|
-
fields: {
|
|
518
|
-
agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
519
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: true },
|
|
520
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
521
|
-
status: { type: AgentStatusEnum, isOptional: true },
|
|
522
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
523
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
524
|
-
userPromptTemplate: {
|
|
525
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
526
|
-
isOptional: true
|
|
527
|
-
},
|
|
528
|
-
toolIds: {
|
|
529
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
530
|
-
isArray: true,
|
|
531
|
-
isOptional: true
|
|
532
|
-
},
|
|
533
|
-
toolChoice: { type: ToolChoiceEnum, isOptional: true },
|
|
534
|
-
maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
535
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
536
|
-
timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
537
|
-
tags: {
|
|
538
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
539
|
-
isArray: true,
|
|
540
|
-
isOptional: true
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
// src/agent/agent.operation.ts
|
|
546
|
-
import {
|
|
547
|
-
defineCommand,
|
|
548
|
-
defineQuery
|
|
549
|
-
} from "@contractspec/lib.contracts-spec/operations";
|
|
550
|
-
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
551
|
-
var OWNERS2 = ["@agent-console-team"];
|
|
552
|
-
var CreateAgentCommand = defineCommand({
|
|
553
|
-
meta: {
|
|
554
|
-
key: "agent-console.agent.create",
|
|
555
|
-
version: "1.0.0",
|
|
556
|
-
stability: "stable",
|
|
557
|
-
owners: [...OWNERS2],
|
|
558
|
-
tags: ["agent", "create"],
|
|
559
|
-
description: "Creates a new AI agent configuration.",
|
|
560
|
-
goal: "Allow users to define new AI agents with specific models and tools.",
|
|
561
|
-
context: "Called from the agent builder UI when creating a new agent."
|
|
562
|
-
},
|
|
563
|
-
io: {
|
|
564
|
-
input: CreateAgentInputModel,
|
|
565
|
-
output: defineSchemaModel3({
|
|
566
|
-
name: "CreateAgentOutput",
|
|
567
|
-
fields: {
|
|
568
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
569
|
-
name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
|
|
570
|
-
slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
571
|
-
status: { type: AgentStatusEnum, isOptional: false }
|
|
572
|
-
}
|
|
573
|
-
}),
|
|
574
|
-
errors: {
|
|
575
|
-
SLUG_EXISTS: {
|
|
576
|
-
description: "An agent with this slug already exists in the organization",
|
|
577
|
-
http: 409,
|
|
578
|
-
gqlCode: "SLUG_EXISTS",
|
|
579
|
-
when: "Slug is already taken"
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
},
|
|
583
|
-
policy: { auth: "user" },
|
|
584
|
-
sideEffects: {
|
|
585
|
-
emits: [
|
|
586
|
-
{
|
|
587
|
-
ref: AgentCreatedEvent.meta,
|
|
588
|
-
when: "Agent is successfully created"
|
|
589
|
-
}
|
|
590
|
-
],
|
|
591
|
-
audit: ["agent-console.agent.created"]
|
|
592
|
-
},
|
|
593
|
-
acceptance: {
|
|
594
|
-
scenarios: [
|
|
595
|
-
{
|
|
596
|
-
key: "create-agent-happy-path",
|
|
597
|
-
given: ["User is authenticated", "Organization exists"],
|
|
598
|
-
when: ["User submits valid agent configuration"],
|
|
599
|
-
then: [
|
|
600
|
-
"New agent is created with DRAFT status",
|
|
601
|
-
"AgentCreated event is emitted"
|
|
602
|
-
]
|
|
603
|
-
},
|
|
604
|
-
{
|
|
605
|
-
key: "create-agent-slug-conflict",
|
|
606
|
-
given: ["User is authenticated", "Agent with same slug exists"],
|
|
607
|
-
when: ["User submits agent with duplicate slug"],
|
|
608
|
-
then: ["SLUG_EXISTS error is returned with 409 status"]
|
|
609
|
-
}
|
|
610
|
-
],
|
|
611
|
-
examples: [
|
|
612
|
-
{
|
|
613
|
-
key: "basic-create",
|
|
614
|
-
input: {
|
|
615
|
-
name: "Support Assistant",
|
|
616
|
-
slug: "support-assistant",
|
|
617
|
-
modelProvider: "openai",
|
|
618
|
-
modelId: "gpt-4"
|
|
619
|
-
},
|
|
620
|
-
output: {
|
|
621
|
-
id: "agent-123",
|
|
622
|
-
name: "Support Assistant",
|
|
623
|
-
slug: "support-assistant",
|
|
624
|
-
status: "draft"
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
]
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
var UpdateAgentCommand = defineCommand({
|
|
631
|
-
meta: {
|
|
632
|
-
key: "agent-console.agent.update",
|
|
633
|
-
version: "1.0.0",
|
|
634
|
-
stability: "stable",
|
|
635
|
-
owners: [...OWNERS2],
|
|
636
|
-
tags: ["agent", "update"],
|
|
637
|
-
description: "Updates an existing AI agent configuration.",
|
|
638
|
-
goal: "Allow users to modify agent settings and configuration.",
|
|
639
|
-
context: "Called from the agent settings UI."
|
|
640
|
-
},
|
|
641
|
-
io: {
|
|
642
|
-
input: UpdateAgentInputModel,
|
|
643
|
-
output: defineSchemaModel3({
|
|
644
|
-
name: "UpdateAgentOutput",
|
|
645
|
-
fields: {
|
|
646
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
647
|
-
name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
|
|
648
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
649
|
-
updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
650
|
-
}
|
|
651
|
-
}),
|
|
652
|
-
errors: {
|
|
653
|
-
AGENT_NOT_FOUND: {
|
|
654
|
-
description: "The specified agent does not exist",
|
|
655
|
-
http: 404,
|
|
656
|
-
gqlCode: "AGENT_NOT_FOUND",
|
|
657
|
-
when: "Agent ID is invalid"
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
policy: { auth: "user" },
|
|
662
|
-
sideEffects: {
|
|
663
|
-
emits: [
|
|
664
|
-
{
|
|
665
|
-
key: "agent.updated",
|
|
666
|
-
version: "1.0.0",
|
|
667
|
-
stability: "stable",
|
|
668
|
-
owners: [...OWNERS2],
|
|
669
|
-
tags: ["agent", "updated"],
|
|
670
|
-
when: "Agent is updated",
|
|
671
|
-
payload: AgentSummaryModel
|
|
672
|
-
}
|
|
673
|
-
],
|
|
674
|
-
audit: ["agent.updated"]
|
|
675
|
-
},
|
|
676
|
-
acceptance: {
|
|
677
|
-
scenarios: [
|
|
678
|
-
{
|
|
679
|
-
key: "update-agent-happy-path",
|
|
680
|
-
given: ["Agent exists", "User owns the agent"],
|
|
681
|
-
when: ["User submits updated configuration"],
|
|
682
|
-
then: ["Agent is updated", "AgentUpdated event is emitted"]
|
|
683
|
-
},
|
|
684
|
-
{
|
|
685
|
-
key: "update-agent-not-found",
|
|
686
|
-
given: ["Agent does not exist"],
|
|
687
|
-
when: ["User attempts to update"],
|
|
688
|
-
then: ["AGENT_NOT_FOUND error is returned"]
|
|
689
|
-
}
|
|
690
|
-
],
|
|
691
|
-
examples: [
|
|
692
|
-
{
|
|
693
|
-
key: "update-name",
|
|
694
|
-
input: {
|
|
695
|
-
agentId: "agent-123",
|
|
696
|
-
name: "Updated Assistant",
|
|
697
|
-
systemPrompt: "You are a helpful assistant."
|
|
698
|
-
},
|
|
699
|
-
output: {
|
|
700
|
-
id: "agent-123",
|
|
701
|
-
name: "Updated Assistant",
|
|
702
|
-
status: "draft",
|
|
703
|
-
updatedAt: "2025-01-01T00:00:00Z"
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
]
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
|
-
var GetAgentQuery = defineQuery({
|
|
710
|
-
meta: {
|
|
711
|
-
key: "agent-console.agent.get",
|
|
712
|
-
version: "1.0.0",
|
|
713
|
-
stability: "stable",
|
|
714
|
-
owners: [...OWNERS2],
|
|
715
|
-
tags: ["agent", "get"],
|
|
716
|
-
description: "Retrieves an agent by its ID.",
|
|
717
|
-
goal: "View detailed agent configuration.",
|
|
718
|
-
context: "Called when viewing agent details or editing."
|
|
719
|
-
},
|
|
720
|
-
io: {
|
|
721
|
-
input: defineSchemaModel3({
|
|
722
|
-
name: "GetAgentInput",
|
|
723
|
-
fields: {
|
|
724
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
725
|
-
includeTools: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
|
|
726
|
-
}
|
|
727
|
-
}),
|
|
728
|
-
output: AgentWithToolsModel,
|
|
729
|
-
errors: {
|
|
730
|
-
AGENT_NOT_FOUND: {
|
|
731
|
-
description: "The specified agent does not exist",
|
|
732
|
-
http: 404,
|
|
733
|
-
gqlCode: "AGENT_NOT_FOUND",
|
|
734
|
-
when: "Agent ID is invalid"
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
},
|
|
738
|
-
policy: { auth: "user" },
|
|
739
|
-
acceptance: {
|
|
740
|
-
scenarios: [
|
|
741
|
-
{
|
|
742
|
-
key: "get-agent-happy-path",
|
|
743
|
-
given: ["Agent exists"],
|
|
744
|
-
when: ["User requests agent by ID"],
|
|
745
|
-
then: ["Agent details are returned"]
|
|
746
|
-
},
|
|
747
|
-
{
|
|
748
|
-
key: "get-agent-with-tools",
|
|
749
|
-
given: ["Agent exists with assigned tools"],
|
|
750
|
-
when: ["User requests agent with includeTools=true"],
|
|
751
|
-
then: ["Agent details with tools list are returned"]
|
|
752
|
-
}
|
|
753
|
-
],
|
|
754
|
-
examples: [
|
|
755
|
-
{
|
|
756
|
-
key: "get-basic",
|
|
757
|
-
input: { agentId: "agent-123", includeTools: false },
|
|
758
|
-
output: {
|
|
759
|
-
id: "agent-123",
|
|
760
|
-
name: "Support Assistant",
|
|
761
|
-
status: "active",
|
|
762
|
-
tools: []
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
]
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
var ListAgentsQuery = defineQuery({
|
|
769
|
-
meta: {
|
|
770
|
-
key: "agent-console.agent.list",
|
|
771
|
-
version: "1.0.0",
|
|
772
|
-
stability: "stable",
|
|
773
|
-
owners: [...OWNERS2],
|
|
774
|
-
tags: ["agent", "list"],
|
|
775
|
-
description: "Lists agents for an organization with optional filtering.",
|
|
776
|
-
goal: "Browse and search available agents.",
|
|
777
|
-
context: "Agent list/dashboard view."
|
|
778
|
-
},
|
|
779
|
-
io: {
|
|
780
|
-
input: defineSchemaModel3({
|
|
781
|
-
name: "ListAgentsInput",
|
|
782
|
-
fields: {
|
|
783
|
-
organizationId: {
|
|
784
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
785
|
-
isOptional: false
|
|
786
|
-
},
|
|
787
|
-
status: { type: AgentStatusEnum, isOptional: true },
|
|
788
|
-
modelProvider: { type: ModelProviderEnum, isOptional: true },
|
|
789
|
-
search: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
790
|
-
limit: {
|
|
791
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
792
|
-
isOptional: true,
|
|
793
|
-
defaultValue: 20
|
|
794
|
-
},
|
|
795
|
-
offset: {
|
|
796
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
797
|
-
isOptional: true,
|
|
798
|
-
defaultValue: 0
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}),
|
|
802
|
-
output: defineSchemaModel3({
|
|
803
|
-
name: "ListAgentsOutput",
|
|
804
|
-
fields: {
|
|
805
|
-
items: { type: AgentSummaryModel, isArray: true, isOptional: false },
|
|
806
|
-
total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
|
|
807
|
-
hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
|
|
808
|
-
}
|
|
809
|
-
})
|
|
810
|
-
},
|
|
811
|
-
policy: { auth: "user" },
|
|
812
|
-
acceptance: {
|
|
813
|
-
scenarios: [
|
|
814
|
-
{
|
|
815
|
-
key: "list-agents-happy-path",
|
|
816
|
-
given: ["Organization has agents"],
|
|
817
|
-
when: ["User lists agents"],
|
|
818
|
-
then: ["Paginated list of agents is returned"]
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
key: "list-agents-filter-by-status",
|
|
822
|
-
given: ["Organization has agents with mixed statuses"],
|
|
823
|
-
when: ["User filters by status=active"],
|
|
824
|
-
then: ["Only active agents are returned"]
|
|
825
|
-
}
|
|
826
|
-
],
|
|
827
|
-
examples: [
|
|
828
|
-
{
|
|
829
|
-
key: "list-basic",
|
|
830
|
-
input: { organizationId: "org-123", limit: 10, offset: 0 },
|
|
831
|
-
output: { items: [], total: 0, hasMore: false }
|
|
832
|
-
}
|
|
833
|
-
]
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
var AssignToolToAgentCommand = defineCommand({
|
|
837
|
-
meta: {
|
|
838
|
-
key: "agent-console.agent.assignTool",
|
|
839
|
-
version: "1.0.0",
|
|
840
|
-
stability: "stable",
|
|
841
|
-
owners: [...OWNERS2],
|
|
842
|
-
tags: ["agent", "tool", "assign"],
|
|
843
|
-
description: "Assigns a tool to an agent with optional configuration.",
|
|
844
|
-
goal: "Enable agents to use specific tools.",
|
|
845
|
-
context: "Agent configuration UI - tool selection."
|
|
846
|
-
},
|
|
847
|
-
io: {
|
|
848
|
-
input: defineSchemaModel3({
|
|
849
|
-
name: "AssignToolToAgentInput",
|
|
850
|
-
fields: {
|
|
851
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
852
|
-
toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
853
|
-
config: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
|
|
854
|
-
order: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true }
|
|
855
|
-
}
|
|
856
|
-
}),
|
|
857
|
-
output: defineSchemaModel3({
|
|
858
|
-
name: "AssignToolToAgentOutput",
|
|
859
|
-
fields: {
|
|
860
|
-
agentToolId: {
|
|
861
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
862
|
-
isOptional: false
|
|
863
|
-
},
|
|
864
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
865
|
-
toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
866
|
-
}
|
|
867
|
-
}),
|
|
868
|
-
errors: {
|
|
869
|
-
TOOL_ALREADY_ASSIGNED: {
|
|
870
|
-
description: "This tool is already assigned to the agent",
|
|
871
|
-
http: 409,
|
|
872
|
-
gqlCode: "TOOL_ALREADY_ASSIGNED",
|
|
873
|
-
when: "Tool assignment already exists"
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
},
|
|
877
|
-
policy: { auth: "user" },
|
|
878
|
-
sideEffects: { audit: ["agent.tool.assigned"] },
|
|
879
|
-
acceptance: {
|
|
880
|
-
scenarios: [
|
|
881
|
-
{
|
|
882
|
-
key: "assign-tool-happy-path",
|
|
883
|
-
given: ["Agent exists", "Tool exists and is not assigned"],
|
|
884
|
-
when: ["User assigns tool to agent"],
|
|
885
|
-
then: ["Tool is assigned", "Assignment ID is returned"]
|
|
886
|
-
},
|
|
887
|
-
{
|
|
888
|
-
key: "assign-tool-already-assigned",
|
|
889
|
-
given: ["Tool is already assigned to agent"],
|
|
890
|
-
when: ["User attempts to assign again"],
|
|
891
|
-
then: ["TOOL_ALREADY_ASSIGNED error is returned"]
|
|
892
|
-
}
|
|
893
|
-
],
|
|
894
|
-
examples: [
|
|
895
|
-
{
|
|
896
|
-
key: "assign-basic",
|
|
897
|
-
input: { agentId: "agent-123", toolId: "tool-456" },
|
|
898
|
-
output: {
|
|
899
|
-
agentToolId: "at-789",
|
|
900
|
-
agentId: "agent-123",
|
|
901
|
-
toolId: "tool-456"
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
]
|
|
905
|
-
}
|
|
906
|
-
});
|
|
907
|
-
var RemoveToolFromAgentCommand = defineCommand({
|
|
908
|
-
meta: {
|
|
909
|
-
key: "agent-console.agent.removeTool",
|
|
910
|
-
version: "1.0.0",
|
|
911
|
-
stability: "stable",
|
|
912
|
-
owners: [...OWNERS2],
|
|
913
|
-
tags: ["agent", "tool", "remove"],
|
|
914
|
-
description: "Removes a tool assignment from an agent.",
|
|
915
|
-
goal: "Disable specific tools for an agent.",
|
|
916
|
-
context: "Agent configuration UI - tool management."
|
|
917
|
-
},
|
|
918
|
-
io: {
|
|
919
|
-
input: defineSchemaModel3({
|
|
920
|
-
name: "RemoveToolFromAgentInput",
|
|
921
|
-
fields: {
|
|
922
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
923
|
-
toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
924
|
-
}
|
|
925
|
-
}),
|
|
926
|
-
output: defineSchemaModel3({
|
|
927
|
-
name: "RemoveToolFromAgentOutput",
|
|
928
|
-
fields: {
|
|
929
|
-
success: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
|
|
930
|
-
}
|
|
931
|
-
})
|
|
932
|
-
},
|
|
933
|
-
policy: { auth: "user" },
|
|
934
|
-
sideEffects: { audit: ["agent.tool.removed"] },
|
|
935
|
-
acceptance: {
|
|
936
|
-
scenarios: [
|
|
937
|
-
{
|
|
938
|
-
key: "remove-tool-happy-path",
|
|
939
|
-
given: ["Agent exists", "Tool is assigned to agent"],
|
|
940
|
-
when: ["User removes tool from agent"],
|
|
941
|
-
then: ["Tool is unassigned", "Success is returned"]
|
|
942
|
-
}
|
|
943
|
-
],
|
|
944
|
-
examples: [
|
|
945
|
-
{
|
|
946
|
-
key: "remove-basic",
|
|
947
|
-
input: { agentId: "agent-123", toolId: "tool-456" },
|
|
948
|
-
output: { success: true }
|
|
949
|
-
}
|
|
950
|
-
]
|
|
951
|
-
}
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
// src/agent/agent.handler.ts
|
|
955
|
-
var nextMockAgentId = MOCK_AGENTS.length + 1;
|
|
956
|
-
async function mockListAgentsHandler(input) {
|
|
957
|
-
const {
|
|
958
|
-
organizationId,
|
|
959
|
-
status,
|
|
960
|
-
modelProvider,
|
|
961
|
-
search,
|
|
962
|
-
limit = 20,
|
|
963
|
-
offset = 0
|
|
964
|
-
} = input;
|
|
965
|
-
let filtered = MOCK_AGENTS.filter((a) => a.organizationId === organizationId);
|
|
966
|
-
if (status)
|
|
967
|
-
filtered = filtered.filter((a) => a.status === status);
|
|
968
|
-
if (modelProvider)
|
|
969
|
-
filtered = filtered.filter((a) => a.modelProvider === modelProvider);
|
|
970
|
-
if (search) {
|
|
971
|
-
const q = search.toLowerCase();
|
|
972
|
-
filtered = filtered.filter((a) => a.name.toLowerCase().includes(q) || a.description?.toLowerCase().includes(q) || a.tags?.some((t) => t.toLowerCase().includes(q)));
|
|
973
|
-
}
|
|
974
|
-
const total = filtered.length;
|
|
975
|
-
const items = filtered.slice(offset, offset + limit).map((a) => ({
|
|
976
|
-
id: a.id,
|
|
977
|
-
name: a.name,
|
|
978
|
-
slug: a.slug,
|
|
979
|
-
description: a.description,
|
|
980
|
-
status: a.status,
|
|
981
|
-
modelProvider: a.modelProvider,
|
|
982
|
-
modelName: a.modelName,
|
|
983
|
-
version: a.version,
|
|
984
|
-
createdAt: a.createdAt
|
|
985
|
-
}));
|
|
986
|
-
return { items, total, hasMore: offset + limit < total };
|
|
987
|
-
}
|
|
988
|
-
async function mockGetAgentHandler(input) {
|
|
989
|
-
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
990
|
-
if (!agent)
|
|
991
|
-
throw new Error("AGENT_NOT_FOUND");
|
|
992
|
-
const result = { ...agent, toolIds: ["tool-1", "tool-2"] };
|
|
993
|
-
if (input.includeTools) {
|
|
994
|
-
result.tools = MOCK_TOOLS.slice(0, 2).map((t) => ({
|
|
995
|
-
id: t.id,
|
|
996
|
-
name: t.name,
|
|
997
|
-
slug: t.slug,
|
|
998
|
-
description: t.description,
|
|
999
|
-
category: t.category
|
|
1000
|
-
}));
|
|
1001
|
-
}
|
|
1002
|
-
return result;
|
|
1003
|
-
}
|
|
1004
|
-
async function mockCreateAgentHandler(input) {
|
|
1005
|
-
const exists = MOCK_AGENTS.some((a) => a.organizationId === input.organizationId && a.slug === input.slug);
|
|
1006
|
-
if (exists)
|
|
1007
|
-
throw new Error("SLUG_EXISTS");
|
|
1008
|
-
return {
|
|
1009
|
-
id: `agent-${nextMockAgentId++}`,
|
|
1010
|
-
name: input.name,
|
|
1011
|
-
slug: input.slug,
|
|
1012
|
-
status: "DRAFT"
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
async function mockUpdateAgentHandler(input) {
|
|
1016
|
-
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
1017
|
-
if (!agent)
|
|
1018
|
-
throw new Error("AGENT_NOT_FOUND");
|
|
1019
|
-
return {
|
|
1020
|
-
id: agent.id,
|
|
1021
|
-
name: input.name ?? agent.name,
|
|
1022
|
-
status: input.status ?? agent.status,
|
|
1023
|
-
updatedAt: new Date
|
|
1024
|
-
};
|
|
1025
|
-
}
|
|
1026
|
-
export {
|
|
1027
|
-
mockUpdateAgentHandler,
|
|
1028
|
-
mockListAgentsHandler,
|
|
1029
|
-
mockGetAgentHandler,
|
|
1030
|
-
mockCreateAgentHandler
|
|
1031
|
-
};
|
|
2
|
+
import{defineEnum as C}from"@contractspec/lib.schema";var d=C("AgentStatus",["DRAFT","ACTIVE","PAUSED","ARCHIVED"]),D=C("ModelProvider",["OPENAI","ANTHROPIC","GOOGLE","MISTRAL","CUSTOM"]),v=C("ToolChoice",["auto","required","none"]);import{defineEvent as h}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as P,ScalarTypeEnum as s}from"@contractspec/lib.schema";var j=["@agent-console-team"],R=P({name:"AgentCreatedPayload",description:"Payload for agent created event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},slug:{type:s.String_unsecure(),isOptional:!1},modelProvider:{type:s.String_unsecure(),isOptional:!1},modelName:{type:s.String_unsecure(),isOptional:!1},toolCount:{type:s.Int_unsecure(),isOptional:!1},createdById:{type:s.String_unsecure(),isOptional:!0},createdAt:{type:s.DateTime(),isOptional:!1}}}),B=h({meta:{key:"agent-console.agent.created",version:"1.0.0",description:"A new AI agent was configured.",stability:"stable",owners:[...j],tags:["agent","created"]},payload:R}),U=P({name:"AgentUpdatedPayload",description:"Payload for agent updated event",fields:{id:{type:s.String_unsecure(),isOptional:!1},organizationId:{type:s.String_unsecure(),isOptional:!1},name:{type:s.String_unsecure(),isOptional:!1},status:{type:s.String_unsecure(),isOptional:!1},updatedFields:{type:s.String_unsecure(),isArray:!0,isOptional:!1},updatedAt:{type:s.DateTime(),isOptional:!1}}}),y=h({meta:{key:"agent-console.agent.updated",version:"1.0.0",description:"An AI agent configuration was updated.",stability:"stable",owners:[...j],tags:["agent","updated"]},payload:U}),_=P({name:"AgentToolAssignedPayload",description:"Payload for agent tool assigned event",fields:{agentId:{type:s.String_unsecure(),isOptional:!1},toolId:{type:s.String_unsecure(),isOptional:!1},agentName:{type:s.String_unsecure(),isOptional:!1},toolName:{type:s.String_unsecure(),isOptional:!1},assignedAt:{type:s.DateTime(),isOptional:!1}}}),l=h({meta:{key:"agent-console.agent.toolAssigned",version:"1.0.0",description:"A tool was assigned to an agent.",stability:"stable",owners:[...j],tags:["agent","tool","assigned"]},payload:_}),N=P({name:"AgentToolRemovedPayload",description:"Payload for agent tool removed event",fields:{agentId:{type:s.String_unsecure(),isOptional:!1},toolId:{type:s.String_unsecure(),isOptional:!1},agentName:{type:s.String_unsecure(),isOptional:!1},toolName:{type:s.String_unsecure(),isOptional:!1},removedAt:{type:s.DateTime(),isOptional:!1}}}),T=h({meta:{key:"agent-console.agent.toolRemoved",version:"1.0.0",description:"A tool was removed from an agent.",stability:"stable",owners:[...j],tags:["agent","tool","removed"]},payload:N});var Z=[{id:"agent-1",organizationId:"demo-org",name:"Customer Support Bot",slug:"customer-support-bot",description:"Handles tier-1 customer inquiries and routes complex issues.",status:"ACTIVE",modelProvider:"OPENAI",modelName:"gpt-4o-mini",modelConfig:{temperature:0.7},systemPrompt:"You are a helpful customer support assistant.",toolChoice:"auto",maxIterations:10,timeoutMs:120000,version:"1.0.0",tags:["support","tier-1"],createdAt:new Date("2024-01-15T10:00:00Z"),updatedAt:new Date("2024-03-20T14:30:00Z")},{id:"agent-2",organizationId:"demo-org",name:"Code Review Assistant",slug:"code-review-assistant",description:"Reviews pull requests and provides actionable feedback.",status:"ACTIVE",modelProvider:"ANTHROPIC",modelName:"claude-sonnet-4-20250514",modelConfig:{temperature:0.3},systemPrompt:"You are a code review expert.",toolChoice:"auto",maxIterations:15,timeoutMs:180000,version:"2.1.0",tags:["code","review","dev"],createdAt:new Date("2024-02-10T09:00:00Z"),updatedAt:new Date("2024-04-05T11:15:00Z")},{id:"agent-3",organizationId:"demo-org",name:"Data Analyst",slug:"data-analyst",description:"Queries databases and generates insights from data.",status:"PAUSED",modelProvider:"OPENAI",modelName:"gpt-4o",modelConfig:{temperature:0.5},systemPrompt:"You are a data analyst expert in SQL and analytics.",toolChoice:"required",maxIterations:20,timeoutMs:300000,version:"1.2.0",tags:["data","analytics","sql"],createdAt:new Date("2024-03-01T08:00:00Z"),updatedAt:new Date("2024-04-10T16:45:00Z")},{id:"agent-4",organizationId:"demo-org",name:"Meeting Scheduler",slug:"meeting-scheduler",description:"Schedules meetings and manages calendar conflicts.",status:"DRAFT",modelProvider:"GOOGLE",modelName:"gemini-2.0-flash",modelConfig:{temperature:0.2},systemPrompt:"You help schedule and organize meetings efficiently.",toolChoice:"auto",maxIterations:5,timeoutMs:60000,version:"0.1.0",tags:["calendar","scheduling"],createdAt:new Date("2024-04-01T12:00:00Z"),updatedAt:new Date("2024-04-01T12:00:00Z")}];var F=[{id:"tool-1",organizationId:"demo-org",name:"Web Search",slug:"web-search",description:"Search the web for real-time information using Brave API.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},numResults:{type:"number",default:10}},required:["query"]},outputSchema:{type:"array",items:{type:"object"}},implementationType:"http",implementationConfig:{url:"https://api.brave.com/search",method:"GET"},maxInvocationsPerMinute:60,timeoutMs:30000,version:"1.0.0",tags:["search","web"],createdAt:new Date("2024-01-01T00:00:00Z"),updatedAt:new Date("2024-02-15T10:00:00Z")},{id:"tool-2",organizationId:"demo-org",name:"SQL Query",slug:"sql-query",description:"Execute read-only SQL queries against the data warehouse.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"SQL query"},maxRows:{type:"number",default:100}},required:["query"]},outputSchema:{type:"object"},implementationType:"function",implementationConfig:{handler:"executeSqlQuery"},maxInvocationsPerMinute:30,timeoutMs:60000,version:"1.1.0",tags:["sql","database"],createdAt:new Date("2024-01-05T00:00:00Z"),updatedAt:new Date("2024-03-10T14:00:00Z")},{id:"tool-3",organizationId:"demo-org",name:"Email Sender",slug:"email-sender",description:"Send emails via SMTP or API.",category:"COMMUNICATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{to:{type:"string"},subject:{type:"string"},body:{type:"string"}},required:["to","subject","body"]},implementationType:"http",implementationConfig:{url:"/api/send-email",method:"POST"},maxInvocationsPerMinute:10,timeoutMs:30000,version:"1.0.0",tags:["email","communication"],createdAt:new Date("2024-02-01T00:00:00Z"),updatedAt:new Date("2024-02-01T00:00:00Z")},{id:"tool-4",organizationId:"demo-org",name:"GitHub Integration",slug:"github-integration",description:"Interact with GitHub repositories, PRs, and issues.",category:"INTEGRATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{action:{type:"string",enum:["list_prs","get_pr","create_comment"]},repo:{type:"string"},params:{type:"object"}},required:["action","repo"]},implementationType:"http",implementationConfig:{url:"https://api.github.com",auth:"token"},maxInvocationsPerMinute:100,timeoutMs:15000,version:"2.0.0",tags:["github","integration","code"],createdAt:new Date("2024-02-20T00:00:00Z"),updatedAt:new Date("2024-04-01T09:00:00Z")},{id:"tool-5",organizationId:"demo-org",name:"Calculator",slug:"calculator",description:"Perform mathematical calculations.",category:"COMPUTATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{expression:{type:"string",description:"Math expression to evaluate"}},required:["expression"]},outputSchema:{type:"object",properties:{result:{type:"number"}}},implementationType:"function",implementationConfig:{handler:"evaluateMath"},timeoutMs:5000,version:"1.0.0",tags:["math","utility"],createdAt:new Date("2024-01-10T00:00:00Z"),updatedAt:new Date("2024-01-10T00:00:00Z")}];import{defineSchemaModel as q,ScalarTypeEnum as t}from"@contractspec/lib.schema";var it=q({name:"Agent",description:"AI agent configuration",fields:{id:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},status:{type:d,isOptional:!1},modelProvider:{type:D,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!1},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:v,isOptional:!1,defaultValue:"auto"},maxIterations:{type:t.Int_unsecure(),isOptional:!1,defaultValue:10},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!1,defaultValue:120000},version:{type:t.NonEmptyString(),isOptional:!1},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1},updatedAt:{type:t.DateTime(),isOptional:!1}}}),L=q({name:"AgentSummary",description:"Summary of an agent for list views",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},status:{type:d,isOptional:!1},modelProvider:{type:D,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},version:{type:t.NonEmptyString(),isOptional:!1},createdAt:{type:t.DateTime(),isOptional:!1}}}),K=q({name:"AgentToolRef",description:"Tool reference in agent context",fields:{id:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!1},category:{type:t.String_unsecure(),isOptional:!1}}}),G=q({name:"AgentWithTools",description:"Agent with associated tools",fields:{id:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},status:{type:d,isOptional:!1},modelProvider:{type:D,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!1},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:v,isOptional:!1},maxIterations:{type:t.Int_unsecure(),isOptional:!1},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!1},version:{type:t.NonEmptyString(),isOptional:!1},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1},updatedAt:{type:t.DateTime(),isOptional:!1},tools:{type:K,isArray:!0,isOptional:!0}}}),k=q({name:"CreateAgentInput",description:"Input for creating an agent",fields:{organizationId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!1},slug:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},modelProvider:{type:D,isOptional:!1},modelName:{type:t.NonEmptyString(),isOptional:!1},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!1},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:v,isOptional:!0},maxIterations:{type:t.Int_unsecure(),isOptional:!0},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!0},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0}}}),J=q({name:"UpdateAgentInput",description:"Input for updating an agent",fields:{agentId:{type:t.String_unsecure(),isOptional:!1},name:{type:t.NonEmptyString(),isOptional:!0},description:{type:t.String_unsecure(),isOptional:!0},status:{type:d,isOptional:!0},modelConfig:{type:t.JSONObject(),isOptional:!0},systemPrompt:{type:t.String_unsecure(),isOptional:!0},userPromptTemplate:{type:t.String_unsecure(),isOptional:!0},toolIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},toolChoice:{type:v,isOptional:!0},maxIterations:{type:t.Int_unsecure(),isOptional:!0},maxTokensPerRun:{type:t.Int_unsecure(),isOptional:!0},timeoutMs:{type:t.Int_unsecure(),isOptional:!0},tags:{type:t.String_unsecure(),isArray:!0,isOptional:!0}}});import{defineCommand as A,defineQuery as X}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as w,ScalarTypeEnum as o}from"@contractspec/lib.schema";var x=["@agent-console-team"],O=A({meta:{key:"agent-console.agent.create",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","create"],description:"Creates a new AI agent configuration.",goal:"Allow users to define new AI agents with specific models and tools.",context:"Called from the agent builder UI when creating a new agent."},io:{input:k,output:w({name:"CreateAgentOutput",fields:{id:{type:o.String_unsecure(),isOptional:!1},name:{type:o.NonEmptyString(),isOptional:!1},slug:{type:o.String_unsecure(),isOptional:!1},status:{type:d,isOptional:!1}}}),errors:{SLUG_EXISTS:{description:"An agent with this slug already exists in the organization",http:409,gqlCode:"SLUG_EXISTS",when:"Slug is already taken"}}},policy:{auth:"user"},sideEffects:{emits:[{ref:B.meta,when:"Agent is successfully created"}],audit:["agent-console.agent.created"]},acceptance:{scenarios:[{key:"create-agent-happy-path",given:["User is authenticated","Organization exists"],when:["User submits valid agent configuration"],then:["New agent is created with DRAFT status","AgentCreated event is emitted"]},{key:"create-agent-slug-conflict",given:["User is authenticated","Agent with same slug exists"],when:["User submits agent with duplicate slug"],then:["SLUG_EXISTS error is returned with 409 status"]}],examples:[{key:"basic-create",input:{name:"Support Assistant",slug:"support-assistant",modelProvider:"openai",modelId:"gpt-4"},output:{id:"agent-123",name:"Support Assistant",slug:"support-assistant",status:"draft"}}]}}),W=A({meta:{key:"agent-console.agent.update",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","update"],description:"Updates an existing AI agent configuration.",goal:"Allow users to modify agent settings and configuration.",context:"Called from the agent settings UI."},io:{input:J,output:w({name:"UpdateAgentOutput",fields:{id:{type:o.String_unsecure(),isOptional:!1},name:{type:o.NonEmptyString(),isOptional:!1},status:{type:d,isOptional:!1},updatedAt:{type:o.DateTime(),isOptional:!1}}}),errors:{AGENT_NOT_FOUND:{description:"The specified agent does not exist",http:404,gqlCode:"AGENT_NOT_FOUND",when:"Agent ID is invalid"}}},policy:{auth:"user"},sideEffects:{emits:[{key:"agent.updated",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","updated"],when:"Agent is updated",payload:L}],audit:["agent.updated"]},acceptance:{scenarios:[{key:"update-agent-happy-path",given:["Agent exists","User owns the agent"],when:["User submits updated configuration"],then:["Agent is updated","AgentUpdated event is emitted"]},{key:"update-agent-not-found",given:["Agent does not exist"],when:["User attempts to update"],then:["AGENT_NOT_FOUND error is returned"]}],examples:[{key:"update-name",input:{agentId:"agent-123",name:"Updated Assistant",systemPrompt:"You are a helpful assistant."},output:{id:"agent-123",name:"Updated Assistant",status:"draft",updatedAt:"2025-01-01T00:00:00Z"}}]}}),M=X({meta:{key:"agent-console.agent.get",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","get"],description:"Retrieves an agent by its ID.",goal:"View detailed agent configuration.",context:"Called when viewing agent details or editing."},io:{input:w({name:"GetAgentInput",fields:{agentId:{type:o.String_unsecure(),isOptional:!1},includeTools:{type:o.Boolean(),isOptional:!0}}}),output:G,errors:{AGENT_NOT_FOUND:{description:"The specified agent does not exist",http:404,gqlCode:"AGENT_NOT_FOUND",when:"Agent ID is invalid"}}},policy:{auth:"user"},acceptance:{scenarios:[{key:"get-agent-happy-path",given:["Agent exists"],when:["User requests agent by ID"],then:["Agent details are returned"]},{key:"get-agent-with-tools",given:["Agent exists with assigned tools"],when:["User requests agent with includeTools=true"],then:["Agent details with tools list are returned"]}],examples:[{key:"get-basic",input:{agentId:"agent-123",includeTools:!1},output:{id:"agent-123",name:"Support Assistant",status:"active",tools:[]}}]}}),f=X({meta:{key:"agent-console.agent.list",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","list"],description:"Lists agents for an organization with optional filtering.",goal:"Browse and search available agents.",context:"Agent list/dashboard view."},io:{input:w({name:"ListAgentsInput",fields:{organizationId:{type:o.String_unsecure(),isOptional:!1},status:{type:d,isOptional:!0},modelProvider:{type:D,isOptional:!0},search:{type:o.String_unsecure(),isOptional:!0},limit:{type:o.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:o.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:w({name:"ListAgentsOutput",fields:{items:{type:L,isArray:!0,isOptional:!1},total:{type:o.Int_unsecure(),isOptional:!1},hasMore:{type:o.Boolean(),isOptional:!1}}})},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-agents-happy-path",given:["Organization has agents"],when:["User lists agents"],then:["Paginated list of agents is returned"]},{key:"list-agents-filter-by-status",given:["Organization has agents with mixed statuses"],when:["User filters by status=active"],then:["Only active agents are returned"]}],examples:[{key:"list-basic",input:{organizationId:"org-123",limit:10,offset:0},output:{items:[],total:0,hasMore:!1}}]}}),bt=A({meta:{key:"agent-console.agent.assignTool",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","tool","assign"],description:"Assigns a tool to an agent with optional configuration.",goal:"Enable agents to use specific tools.",context:"Agent configuration UI - tool selection."},io:{input:w({name:"AssignToolToAgentInput",fields:{agentId:{type:o.String_unsecure(),isOptional:!1},toolId:{type:o.String_unsecure(),isOptional:!1},config:{type:o.JSONObject(),isOptional:!0},order:{type:o.Int_unsecure(),isOptional:!0}}}),output:w({name:"AssignToolToAgentOutput",fields:{agentToolId:{type:o.String_unsecure(),isOptional:!1},agentId:{type:o.String_unsecure(),isOptional:!1},toolId:{type:o.String_unsecure(),isOptional:!1}}}),errors:{TOOL_ALREADY_ASSIGNED:{description:"This tool is already assigned to the agent",http:409,gqlCode:"TOOL_ALREADY_ASSIGNED",when:"Tool assignment already exists"}}},policy:{auth:"user"},sideEffects:{audit:["agent.tool.assigned"]},acceptance:{scenarios:[{key:"assign-tool-happy-path",given:["Agent exists","Tool exists and is not assigned"],when:["User assigns tool to agent"],then:["Tool is assigned","Assignment ID is returned"]},{key:"assign-tool-already-assigned",given:["Tool is already assigned to agent"],when:["User attempts to assign again"],then:["TOOL_ALREADY_ASSIGNED error is returned"]}],examples:[{key:"assign-basic",input:{agentId:"agent-123",toolId:"tool-456"},output:{agentToolId:"at-789",agentId:"agent-123",toolId:"tool-456"}}]}}),Dt=A({meta:{key:"agent-console.agent.removeTool",version:"1.0.0",stability:"stable",owners:[...x],tags:["agent","tool","remove"],description:"Removes a tool assignment from an agent.",goal:"Disable specific tools for an agent.",context:"Agent configuration UI - tool management."},io:{input:w({name:"RemoveToolFromAgentInput",fields:{agentId:{type:o.String_unsecure(),isOptional:!1},toolId:{type:o.String_unsecure(),isOptional:!1}}}),output:w({name:"RemoveToolFromAgentOutput",fields:{success:{type:o.Boolean(),isOptional:!1}}})},policy:{auth:"user"},sideEffects:{audit:["agent.tool.removed"]},acceptance:{scenarios:[{key:"remove-tool-happy-path",given:["Agent exists","Tool is assigned to agent"],when:["User removes tool from agent"],then:["Tool is unassigned","Success is returned"]}],examples:[{key:"remove-basic",input:{agentId:"agent-123",toolId:"tool-456"},output:{success:!0}}]}});var n=Z.length+1;async function ht(e){let{organizationId:g,status:r,modelProvider:I,search:H,limit:Y=20,offset:z=0}=e,b=Z.filter((i)=>i.organizationId===g);if(r)b=b.filter((i)=>i.status===r);if(I)b=b.filter((i)=>i.modelProvider===I);if(H){let i=H.toLowerCase();b=b.filter((V)=>V.name.toLowerCase().includes(i)||V.description?.toLowerCase().includes(i)||V.tags?.some(($)=>$.toLowerCase().includes(i)))}let Q=b.length;return{items:b.slice(z,z+Y).map((i)=>({id:i.id,name:i.name,slug:i.slug,description:i.description,status:i.status,modelProvider:i.modelProvider,modelName:i.modelName,version:i.version,createdAt:i.createdAt})),total:Q,hasMore:z+Y<Q}}async function Pt(e){let g=Z.find((I)=>I.id===e.agentId);if(!g)throw Error("AGENT_NOT_FOUND");let r={...g,toolIds:["tool-1","tool-2"]};if(e.includeTools)r.tools=F.slice(0,2).map((I)=>({id:I.id,name:I.name,slug:I.slug,description:I.description,category:I.category}));return r}async function jt(e){if(Z.some((r)=>r.organizationId===e.organizationId&&r.slug===e.slug))throw Error("SLUG_EXISTS");return{id:`agent-${n++}`,name:e.name,slug:e.slug,status:"DRAFT"}}async function At(e){let g=Z.find((r)=>r.id===e.agentId);if(!g)throw Error("AGENT_NOT_FOUND");return{id:g.id,name:e.name??g.name,status:e.status??g.status,updatedAt:new Date}}export{At as mockUpdateAgentHandler,ht as mockListAgentsHandler,Pt as mockGetAgentHandler,jt as mockCreateAgentHandler};
|