@contractspec/example.agent-console 3.8.9 → 3.8.11
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 +30 -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,1248 +1 @@
|
|
|
1
|
-
// src/agent/agent.entity.ts
|
|
2
|
-
import {
|
|
3
|
-
defineEntity,
|
|
4
|
-
defineEntityEnum,
|
|
5
|
-
field,
|
|
6
|
-
index
|
|
7
|
-
} from "@contractspec/lib.schema";
|
|
8
|
-
var AgentStatusEntityEnum = defineEntityEnum({
|
|
9
|
-
name: "AgentStatus",
|
|
10
|
-
values: ["DRAFT", "ACTIVE", "PAUSED", "ARCHIVED"],
|
|
11
|
-
description: "Lifecycle status of the agent"
|
|
12
|
-
});
|
|
13
|
-
var ModelProviderEntityEnum = defineEntityEnum({
|
|
14
|
-
name: "ModelProvider",
|
|
15
|
-
values: ["OPENAI", "ANTHROPIC", "GOOGLE", "MISTRAL", "CUSTOM"],
|
|
16
|
-
description: "AI model provider"
|
|
17
|
-
});
|
|
18
|
-
var AgentEntity = defineEntity({
|
|
19
|
-
name: "Agent",
|
|
20
|
-
schema: "agent_console",
|
|
21
|
-
description: "Represents an AI agent configuration with assigned tools and parameters.",
|
|
22
|
-
fields: {
|
|
23
|
-
id: field.id(),
|
|
24
|
-
organizationId: field.string({
|
|
25
|
-
description: "Organization that owns this agent"
|
|
26
|
-
}),
|
|
27
|
-
name: field.string({ description: "Agent name (1-100 chars)" }),
|
|
28
|
-
slug: field.string({
|
|
29
|
-
description: "URL-safe identifier (lowercase, numbers, hyphens)"
|
|
30
|
-
}),
|
|
31
|
-
description: field.string({
|
|
32
|
-
isOptional: true,
|
|
33
|
-
description: "Agent description (max 1000 chars)"
|
|
34
|
-
}),
|
|
35
|
-
status: field.enum("AgentStatus", { default: "DRAFT" }),
|
|
36
|
-
modelProvider: field.enum("ModelProvider", { default: "OPENAI" }),
|
|
37
|
-
modelName: field.string({
|
|
38
|
-
description: "Model identifier: 'gpt-4', 'claude-3-opus', etc."
|
|
39
|
-
}),
|
|
40
|
-
modelConfig: field.json({
|
|
41
|
-
isOptional: true,
|
|
42
|
-
description: "Model parameters: temperature, max_tokens, etc."
|
|
43
|
-
}),
|
|
44
|
-
systemPrompt: field.string({ description: "System prompt for the agent" }),
|
|
45
|
-
userPromptTemplate: field.string({
|
|
46
|
-
isOptional: true,
|
|
47
|
-
description: "Template for user prompts"
|
|
48
|
-
}),
|
|
49
|
-
toolIds: field.string({
|
|
50
|
-
isArray: true,
|
|
51
|
-
isOptional: true,
|
|
52
|
-
description: "IDs of assigned tools"
|
|
53
|
-
}),
|
|
54
|
-
toolChoice: field.string({
|
|
55
|
-
default: "auto",
|
|
56
|
-
description: "Tool selection mode: 'auto', 'required', 'none'"
|
|
57
|
-
}),
|
|
58
|
-
maxIterations: field.int({
|
|
59
|
-
default: 10,
|
|
60
|
-
description: "Maximum iterations per run"
|
|
61
|
-
}),
|
|
62
|
-
maxTokensPerRun: field.int({
|
|
63
|
-
isOptional: true,
|
|
64
|
-
description: "Maximum tokens per run"
|
|
65
|
-
}),
|
|
66
|
-
timeoutMs: field.int({
|
|
67
|
-
default: 120000,
|
|
68
|
-
description: "Execution timeout in milliseconds"
|
|
69
|
-
}),
|
|
70
|
-
version: field.string({ default: "1.0.0", description: "Agent version" }),
|
|
71
|
-
tags: field.string({
|
|
72
|
-
isArray: true,
|
|
73
|
-
isOptional: true,
|
|
74
|
-
description: "Tags for categorization"
|
|
75
|
-
}),
|
|
76
|
-
createdAt: field.createdAt(),
|
|
77
|
-
updatedAt: field.updatedAt(),
|
|
78
|
-
createdById: field.string({
|
|
79
|
-
isOptional: true,
|
|
80
|
-
description: "User who created this agent"
|
|
81
|
-
}),
|
|
82
|
-
tools: field.hasMany("Tool", {
|
|
83
|
-
description: "Tools assigned to this agent"
|
|
84
|
-
})
|
|
85
|
-
},
|
|
86
|
-
indexes: [
|
|
87
|
-
index.unique(["organizationId", "slug"]),
|
|
88
|
-
index.on(["organizationId", "status"]),
|
|
89
|
-
index.on(["modelProvider", "modelName"])
|
|
90
|
-
],
|
|
91
|
-
enums: [AgentStatusEntityEnum, ModelProviderEntityEnum]
|
|
92
|
-
});
|
|
93
|
-
var AgentToolEntity = defineEntity({
|
|
94
|
-
name: "AgentTool",
|
|
95
|
-
schema: "agent_console",
|
|
96
|
-
description: "Links an agent to its assigned tools with configuration.",
|
|
97
|
-
fields: {
|
|
98
|
-
id: field.id(),
|
|
99
|
-
agentId: field.foreignKey({ description: "Agent ID" }),
|
|
100
|
-
toolId: field.foreignKey({ description: "Tool ID" }),
|
|
101
|
-
config: field.json({
|
|
102
|
-
isOptional: true,
|
|
103
|
-
description: "Tool-specific configuration for this agent"
|
|
104
|
-
}),
|
|
105
|
-
order: field.int({
|
|
106
|
-
default: 0,
|
|
107
|
-
description: "Order of tool in agent tool list"
|
|
108
|
-
}),
|
|
109
|
-
isEnabled: field.boolean({
|
|
110
|
-
default: true,
|
|
111
|
-
description: "Whether tool is enabled for this agent"
|
|
112
|
-
}),
|
|
113
|
-
createdAt: field.createdAt(),
|
|
114
|
-
agent: field.belongsTo("Agent", ["agentId"], ["id"]),
|
|
115
|
-
tool: field.belongsTo("Tool", ["toolId"], ["id"])
|
|
116
|
-
},
|
|
117
|
-
indexes: [
|
|
118
|
-
index.unique(["agentId", "toolId"]),
|
|
119
|
-
index.on(["agentId", "order"])
|
|
120
|
-
]
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// src/agent/agent.enum.ts
|
|
124
|
-
import { defineEnum } from "@contractspec/lib.schema";
|
|
125
|
-
var AgentStatusEnum = defineEnum("AgentStatus", [
|
|
126
|
-
"DRAFT",
|
|
127
|
-
"ACTIVE",
|
|
128
|
-
"PAUSED",
|
|
129
|
-
"ARCHIVED"
|
|
130
|
-
]);
|
|
131
|
-
var ModelProviderEnum = defineEnum("ModelProvider", [
|
|
132
|
-
"OPENAI",
|
|
133
|
-
"ANTHROPIC",
|
|
134
|
-
"GOOGLE",
|
|
135
|
-
"MISTRAL",
|
|
136
|
-
"CUSTOM"
|
|
137
|
-
]);
|
|
138
|
-
var ToolChoiceEnum = defineEnum("ToolChoice", [
|
|
139
|
-
"auto",
|
|
140
|
-
"required",
|
|
141
|
-
"none"
|
|
142
|
-
]);
|
|
143
|
-
|
|
144
|
-
// src/agent/agent.event.ts
|
|
145
|
-
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
146
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
147
|
-
var OWNERS = ["@agent-console-team"];
|
|
148
|
-
var AgentCreatedPayload = defineSchemaModel({
|
|
149
|
-
name: "AgentCreatedPayload",
|
|
150
|
-
description: "Payload for agent created event",
|
|
151
|
-
fields: {
|
|
152
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
153
|
-
organizationId: {
|
|
154
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
155
|
-
isOptional: false
|
|
156
|
-
},
|
|
157
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
158
|
-
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
159
|
-
modelProvider: {
|
|
160
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
161
|
-
isOptional: false
|
|
162
|
-
},
|
|
163
|
-
modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
164
|
-
toolCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
165
|
-
createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
166
|
-
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
var AgentCreatedEvent = defineEvent({
|
|
170
|
-
meta: {
|
|
171
|
-
key: "agent-console.agent.created",
|
|
172
|
-
version: "1.0.0",
|
|
173
|
-
description: "A new AI agent was configured.",
|
|
174
|
-
stability: "stable",
|
|
175
|
-
owners: [...OWNERS],
|
|
176
|
-
tags: ["agent", "created"]
|
|
177
|
-
},
|
|
178
|
-
payload: AgentCreatedPayload
|
|
179
|
-
});
|
|
180
|
-
var AgentUpdatedPayload = defineSchemaModel({
|
|
181
|
-
name: "AgentUpdatedPayload",
|
|
182
|
-
description: "Payload for agent updated event",
|
|
183
|
-
fields: {
|
|
184
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
185
|
-
organizationId: {
|
|
186
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
187
|
-
isOptional: false
|
|
188
|
-
},
|
|
189
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
190
|
-
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
191
|
-
updatedFields: {
|
|
192
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
193
|
-
isArray: true,
|
|
194
|
-
isOptional: false
|
|
195
|
-
},
|
|
196
|
-
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
var AgentUpdatedEvent = defineEvent({
|
|
200
|
-
meta: {
|
|
201
|
-
key: "agent-console.agent.updated",
|
|
202
|
-
version: "1.0.0",
|
|
203
|
-
description: "An AI agent configuration was updated.",
|
|
204
|
-
stability: "stable",
|
|
205
|
-
owners: [...OWNERS],
|
|
206
|
-
tags: ["agent", "updated"]
|
|
207
|
-
},
|
|
208
|
-
payload: AgentUpdatedPayload
|
|
209
|
-
});
|
|
210
|
-
var AgentToolAssignedPayload = defineSchemaModel({
|
|
211
|
-
name: "AgentToolAssignedPayload",
|
|
212
|
-
description: "Payload for agent tool assigned event",
|
|
213
|
-
fields: {
|
|
214
|
-
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
215
|
-
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
216
|
-
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
217
|
-
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
218
|
-
assignedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
var AgentToolAssignedEvent = defineEvent({
|
|
222
|
-
meta: {
|
|
223
|
-
key: "agent-console.agent.toolAssigned",
|
|
224
|
-
version: "1.0.0",
|
|
225
|
-
description: "A tool was assigned to an agent.",
|
|
226
|
-
stability: "stable",
|
|
227
|
-
owners: [...OWNERS],
|
|
228
|
-
tags: ["agent", "tool", "assigned"]
|
|
229
|
-
},
|
|
230
|
-
payload: AgentToolAssignedPayload
|
|
231
|
-
});
|
|
232
|
-
var AgentToolRemovedPayload = defineSchemaModel({
|
|
233
|
-
name: "AgentToolRemovedPayload",
|
|
234
|
-
description: "Payload for agent tool removed event",
|
|
235
|
-
fields: {
|
|
236
|
-
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
237
|
-
toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
238
|
-
agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
239
|
-
toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
240
|
-
removedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
var AgentToolRemovedEvent = defineEvent({
|
|
244
|
-
meta: {
|
|
245
|
-
key: "agent-console.agent.toolRemoved",
|
|
246
|
-
version: "1.0.0",
|
|
247
|
-
description: "A tool was removed from an agent.",
|
|
248
|
-
stability: "stable",
|
|
249
|
-
owners: [...OWNERS],
|
|
250
|
-
tags: ["agent", "tool", "removed"]
|
|
251
|
-
},
|
|
252
|
-
payload: AgentToolRemovedPayload
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// src/shared/mock-agents.ts
|
|
256
|
-
var MOCK_AGENTS = [
|
|
257
|
-
{
|
|
258
|
-
id: "agent-1",
|
|
259
|
-
organizationId: "demo-org",
|
|
260
|
-
name: "Customer Support Bot",
|
|
261
|
-
slug: "customer-support-bot",
|
|
262
|
-
description: "Handles tier-1 customer inquiries and routes complex issues.",
|
|
263
|
-
status: "ACTIVE",
|
|
264
|
-
modelProvider: "OPENAI",
|
|
265
|
-
modelName: "gpt-4o-mini",
|
|
266
|
-
modelConfig: { temperature: 0.7 },
|
|
267
|
-
systemPrompt: "You are a helpful customer support assistant.",
|
|
268
|
-
toolChoice: "auto",
|
|
269
|
-
maxIterations: 10,
|
|
270
|
-
timeoutMs: 120000,
|
|
271
|
-
version: "1.0.0",
|
|
272
|
-
tags: ["support", "tier-1"],
|
|
273
|
-
createdAt: new Date("2024-01-15T10:00:00Z"),
|
|
274
|
-
updatedAt: new Date("2024-03-20T14:30:00Z")
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
id: "agent-2",
|
|
278
|
-
organizationId: "demo-org",
|
|
279
|
-
name: "Code Review Assistant",
|
|
280
|
-
slug: "code-review-assistant",
|
|
281
|
-
description: "Reviews pull requests and provides actionable feedback.",
|
|
282
|
-
status: "ACTIVE",
|
|
283
|
-
modelProvider: "ANTHROPIC",
|
|
284
|
-
modelName: "claude-sonnet-4-20250514",
|
|
285
|
-
modelConfig: { temperature: 0.3 },
|
|
286
|
-
systemPrompt: "You are a code review expert.",
|
|
287
|
-
toolChoice: "auto",
|
|
288
|
-
maxIterations: 15,
|
|
289
|
-
timeoutMs: 180000,
|
|
290
|
-
version: "2.1.0",
|
|
291
|
-
tags: ["code", "review", "dev"],
|
|
292
|
-
createdAt: new Date("2024-02-10T09:00:00Z"),
|
|
293
|
-
updatedAt: new Date("2024-04-05T11:15:00Z")
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
id: "agent-3",
|
|
297
|
-
organizationId: "demo-org",
|
|
298
|
-
name: "Data Analyst",
|
|
299
|
-
slug: "data-analyst",
|
|
300
|
-
description: "Queries databases and generates insights from data.",
|
|
301
|
-
status: "PAUSED",
|
|
302
|
-
modelProvider: "OPENAI",
|
|
303
|
-
modelName: "gpt-4o",
|
|
304
|
-
modelConfig: { temperature: 0.5 },
|
|
305
|
-
systemPrompt: "You are a data analyst expert in SQL and analytics.",
|
|
306
|
-
toolChoice: "required",
|
|
307
|
-
maxIterations: 20,
|
|
308
|
-
timeoutMs: 300000,
|
|
309
|
-
version: "1.2.0",
|
|
310
|
-
tags: ["data", "analytics", "sql"],
|
|
311
|
-
createdAt: new Date("2024-03-01T08:00:00Z"),
|
|
312
|
-
updatedAt: new Date("2024-04-10T16:45:00Z")
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
id: "agent-4",
|
|
316
|
-
organizationId: "demo-org",
|
|
317
|
-
name: "Meeting Scheduler",
|
|
318
|
-
slug: "meeting-scheduler",
|
|
319
|
-
description: "Schedules meetings and manages calendar conflicts.",
|
|
320
|
-
status: "DRAFT",
|
|
321
|
-
modelProvider: "GOOGLE",
|
|
322
|
-
modelName: "gemini-2.0-flash",
|
|
323
|
-
modelConfig: { temperature: 0.2 },
|
|
324
|
-
systemPrompt: "You help schedule and organize meetings efficiently.",
|
|
325
|
-
toolChoice: "auto",
|
|
326
|
-
maxIterations: 5,
|
|
327
|
-
timeoutMs: 60000,
|
|
328
|
-
version: "0.1.0",
|
|
329
|
-
tags: ["calendar", "scheduling"],
|
|
330
|
-
createdAt: new Date("2024-04-01T12:00:00Z"),
|
|
331
|
-
updatedAt: new Date("2024-04-01T12:00:00Z")
|
|
332
|
-
}
|
|
333
|
-
];
|
|
334
|
-
|
|
335
|
-
// src/shared/mock-tools.ts
|
|
336
|
-
var MOCK_TOOLS = [
|
|
337
|
-
{
|
|
338
|
-
id: "tool-1",
|
|
339
|
-
organizationId: "demo-org",
|
|
340
|
-
name: "Web Search",
|
|
341
|
-
slug: "web-search",
|
|
342
|
-
description: "Search the web for real-time information using Brave API.",
|
|
343
|
-
category: "RETRIEVAL",
|
|
344
|
-
status: "ACTIVE",
|
|
345
|
-
parametersSchema: {
|
|
346
|
-
type: "object",
|
|
347
|
-
properties: {
|
|
348
|
-
query: { type: "string", description: "Search query" },
|
|
349
|
-
numResults: { type: "number", default: 10 }
|
|
350
|
-
},
|
|
351
|
-
required: ["query"]
|
|
352
|
-
},
|
|
353
|
-
outputSchema: { type: "array", items: { type: "object" } },
|
|
354
|
-
implementationType: "http",
|
|
355
|
-
implementationConfig: {
|
|
356
|
-
url: "https://api.brave.com/search",
|
|
357
|
-
method: "GET"
|
|
358
|
-
},
|
|
359
|
-
maxInvocationsPerMinute: 60,
|
|
360
|
-
timeoutMs: 30000,
|
|
361
|
-
version: "1.0.0",
|
|
362
|
-
tags: ["search", "web"],
|
|
363
|
-
createdAt: new Date("2024-01-01T00:00:00Z"),
|
|
364
|
-
updatedAt: new Date("2024-02-15T10:00:00Z")
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
id: "tool-2",
|
|
368
|
-
organizationId: "demo-org",
|
|
369
|
-
name: "SQL Query",
|
|
370
|
-
slug: "sql-query",
|
|
371
|
-
description: "Execute read-only SQL queries against the data warehouse.",
|
|
372
|
-
category: "RETRIEVAL",
|
|
373
|
-
status: "ACTIVE",
|
|
374
|
-
parametersSchema: {
|
|
375
|
-
type: "object",
|
|
376
|
-
properties: {
|
|
377
|
-
query: { type: "string", description: "SQL query" },
|
|
378
|
-
maxRows: { type: "number", default: 100 }
|
|
379
|
-
},
|
|
380
|
-
required: ["query"]
|
|
381
|
-
},
|
|
382
|
-
outputSchema: { type: "object" },
|
|
383
|
-
implementationType: "function",
|
|
384
|
-
implementationConfig: { handler: "executeSqlQuery" },
|
|
385
|
-
maxInvocationsPerMinute: 30,
|
|
386
|
-
timeoutMs: 60000,
|
|
387
|
-
version: "1.1.0",
|
|
388
|
-
tags: ["sql", "database"],
|
|
389
|
-
createdAt: new Date("2024-01-05T00:00:00Z"),
|
|
390
|
-
updatedAt: new Date("2024-03-10T14:00:00Z")
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
id: "tool-3",
|
|
394
|
-
organizationId: "demo-org",
|
|
395
|
-
name: "Email Sender",
|
|
396
|
-
slug: "email-sender",
|
|
397
|
-
description: "Send emails via SMTP or API.",
|
|
398
|
-
category: "COMMUNICATION",
|
|
399
|
-
status: "ACTIVE",
|
|
400
|
-
parametersSchema: {
|
|
401
|
-
type: "object",
|
|
402
|
-
properties: {
|
|
403
|
-
to: { type: "string" },
|
|
404
|
-
subject: { type: "string" },
|
|
405
|
-
body: { type: "string" }
|
|
406
|
-
},
|
|
407
|
-
required: ["to", "subject", "body"]
|
|
408
|
-
},
|
|
409
|
-
implementationType: "http",
|
|
410
|
-
implementationConfig: { url: "/api/send-email", method: "POST" },
|
|
411
|
-
maxInvocationsPerMinute: 10,
|
|
412
|
-
timeoutMs: 30000,
|
|
413
|
-
version: "1.0.0",
|
|
414
|
-
tags: ["email", "communication"],
|
|
415
|
-
createdAt: new Date("2024-02-01T00:00:00Z"),
|
|
416
|
-
updatedAt: new Date("2024-02-01T00:00:00Z")
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
id: "tool-4",
|
|
420
|
-
organizationId: "demo-org",
|
|
421
|
-
name: "GitHub Integration",
|
|
422
|
-
slug: "github-integration",
|
|
423
|
-
description: "Interact with GitHub repositories, PRs, and issues.",
|
|
424
|
-
category: "INTEGRATION",
|
|
425
|
-
status: "ACTIVE",
|
|
426
|
-
parametersSchema: {
|
|
427
|
-
type: "object",
|
|
428
|
-
properties: {
|
|
429
|
-
action: {
|
|
430
|
-
type: "string",
|
|
431
|
-
enum: ["list_prs", "get_pr", "create_comment"]
|
|
432
|
-
},
|
|
433
|
-
repo: { type: "string" },
|
|
434
|
-
params: { type: "object" }
|
|
435
|
-
},
|
|
436
|
-
required: ["action", "repo"]
|
|
437
|
-
},
|
|
438
|
-
implementationType: "http",
|
|
439
|
-
implementationConfig: { url: "https://api.github.com", auth: "token" },
|
|
440
|
-
maxInvocationsPerMinute: 100,
|
|
441
|
-
timeoutMs: 15000,
|
|
442
|
-
version: "2.0.0",
|
|
443
|
-
tags: ["github", "integration", "code"],
|
|
444
|
-
createdAt: new Date("2024-02-20T00:00:00Z"),
|
|
445
|
-
updatedAt: new Date("2024-04-01T09:00:00Z")
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
id: "tool-5",
|
|
449
|
-
organizationId: "demo-org",
|
|
450
|
-
name: "Calculator",
|
|
451
|
-
slug: "calculator",
|
|
452
|
-
description: "Perform mathematical calculations.",
|
|
453
|
-
category: "COMPUTATION",
|
|
454
|
-
status: "ACTIVE",
|
|
455
|
-
parametersSchema: {
|
|
456
|
-
type: "object",
|
|
457
|
-
properties: {
|
|
458
|
-
expression: {
|
|
459
|
-
type: "string",
|
|
460
|
-
description: "Math expression to evaluate"
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
required: ["expression"]
|
|
464
|
-
},
|
|
465
|
-
outputSchema: {
|
|
466
|
-
type: "object",
|
|
467
|
-
properties: { result: { type: "number" } }
|
|
468
|
-
},
|
|
469
|
-
implementationType: "function",
|
|
470
|
-
implementationConfig: { handler: "evaluateMath" },
|
|
471
|
-
timeoutMs: 5000,
|
|
472
|
-
version: "1.0.0",
|
|
473
|
-
tags: ["math", "utility"],
|
|
474
|
-
createdAt: new Date("2024-01-10T00:00:00Z"),
|
|
475
|
-
updatedAt: new Date("2024-01-10T00:00:00Z")
|
|
476
|
-
}
|
|
477
|
-
];
|
|
478
|
-
|
|
479
|
-
// src/agent/agent.schema.ts
|
|
480
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
481
|
-
var AgentModel = defineSchemaModel2({
|
|
482
|
-
name: "Agent",
|
|
483
|
-
description: "AI agent configuration",
|
|
484
|
-
fields: {
|
|
485
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
486
|
-
organizationId: {
|
|
487
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
488
|
-
isOptional: false
|
|
489
|
-
},
|
|
490
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
491
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
492
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
493
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
494
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
495
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
496
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
497
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
498
|
-
userPromptTemplate: {
|
|
499
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
500
|
-
isOptional: true
|
|
501
|
-
},
|
|
502
|
-
toolIds: {
|
|
503
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
504
|
-
isArray: true,
|
|
505
|
-
isOptional: true
|
|
506
|
-
},
|
|
507
|
-
toolChoice: {
|
|
508
|
-
type: ToolChoiceEnum,
|
|
509
|
-
isOptional: false,
|
|
510
|
-
defaultValue: "auto"
|
|
511
|
-
},
|
|
512
|
-
maxIterations: {
|
|
513
|
-
type: ScalarTypeEnum2.Int_unsecure(),
|
|
514
|
-
isOptional: false,
|
|
515
|
-
defaultValue: 10
|
|
516
|
-
},
|
|
517
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
518
|
-
timeoutMs: {
|
|
519
|
-
type: ScalarTypeEnum2.Int_unsecure(),
|
|
520
|
-
isOptional: false,
|
|
521
|
-
defaultValue: 120000
|
|
522
|
-
},
|
|
523
|
-
version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
524
|
-
tags: {
|
|
525
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
526
|
-
isArray: true,
|
|
527
|
-
isOptional: true
|
|
528
|
-
},
|
|
529
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
530
|
-
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
var AgentSummaryModel = defineSchemaModel2({
|
|
534
|
-
name: "AgentSummary",
|
|
535
|
-
description: "Summary of an agent for list views",
|
|
536
|
-
fields: {
|
|
537
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
538
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
539
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
540
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
541
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
542
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
543
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
544
|
-
version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
545
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
var AgentToolRefModel = defineSchemaModel2({
|
|
549
|
-
name: "AgentToolRef",
|
|
550
|
-
description: "Tool reference in agent context",
|
|
551
|
-
fields: {
|
|
552
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
553
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
554
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
555
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
556
|
-
category: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
var AgentWithToolsModel = defineSchemaModel2({
|
|
560
|
-
name: "AgentWithTools",
|
|
561
|
-
description: "Agent with associated tools",
|
|
562
|
-
fields: {
|
|
563
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
564
|
-
organizationId: {
|
|
565
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
566
|
-
isOptional: false
|
|
567
|
-
},
|
|
568
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
569
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
570
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
571
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
572
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
573
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
574
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
575
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
576
|
-
userPromptTemplate: {
|
|
577
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
578
|
-
isOptional: true
|
|
579
|
-
},
|
|
580
|
-
toolIds: {
|
|
581
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
582
|
-
isArray: true,
|
|
583
|
-
isOptional: true
|
|
584
|
-
},
|
|
585
|
-
toolChoice: { type: ToolChoiceEnum, isOptional: false },
|
|
586
|
-
maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
587
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
588
|
-
timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
589
|
-
version: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
590
|
-
tags: {
|
|
591
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
592
|
-
isArray: true,
|
|
593
|
-
isOptional: true
|
|
594
|
-
},
|
|
595
|
-
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
596
|
-
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
|
|
597
|
-
tools: { type: AgentToolRefModel, isArray: true, isOptional: true }
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
var CreateAgentInputModel = defineSchemaModel2({
|
|
601
|
-
name: "CreateAgentInput",
|
|
602
|
-
description: "Input for creating an agent",
|
|
603
|
-
fields: {
|
|
604
|
-
organizationId: {
|
|
605
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
606
|
-
isOptional: false
|
|
607
|
-
},
|
|
608
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
609
|
-
slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
610
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
611
|
-
modelProvider: { type: ModelProviderEnum, isOptional: false },
|
|
612
|
-
modelName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
|
|
613
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
614
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
615
|
-
userPromptTemplate: {
|
|
616
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
617
|
-
isOptional: true
|
|
618
|
-
},
|
|
619
|
-
toolIds: {
|
|
620
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
621
|
-
isArray: true,
|
|
622
|
-
isOptional: true
|
|
623
|
-
},
|
|
624
|
-
toolChoice: { type: ToolChoiceEnum, isOptional: true },
|
|
625
|
-
maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
626
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
627
|
-
timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
628
|
-
tags: {
|
|
629
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
630
|
-
isArray: true,
|
|
631
|
-
isOptional: true
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
var UpdateAgentInputModel = defineSchemaModel2({
|
|
636
|
-
name: "UpdateAgentInput",
|
|
637
|
-
description: "Input for updating an agent",
|
|
638
|
-
fields: {
|
|
639
|
-
agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
640
|
-
name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: true },
|
|
641
|
-
description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
642
|
-
status: { type: AgentStatusEnum, isOptional: true },
|
|
643
|
-
modelConfig: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
|
|
644
|
-
systemPrompt: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
645
|
-
userPromptTemplate: {
|
|
646
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
647
|
-
isOptional: true
|
|
648
|
-
},
|
|
649
|
-
toolIds: {
|
|
650
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
651
|
-
isArray: true,
|
|
652
|
-
isOptional: true
|
|
653
|
-
},
|
|
654
|
-
toolChoice: { type: ToolChoiceEnum, isOptional: true },
|
|
655
|
-
maxIterations: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
656
|
-
maxTokensPerRun: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
657
|
-
timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
658
|
-
tags: {
|
|
659
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
660
|
-
isArray: true,
|
|
661
|
-
isOptional: true
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
// src/agent/agent.operation.ts
|
|
667
|
-
import {
|
|
668
|
-
defineCommand,
|
|
669
|
-
defineQuery
|
|
670
|
-
} from "@contractspec/lib.contracts-spec/operations";
|
|
671
|
-
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
672
|
-
var OWNERS2 = ["@agent-console-team"];
|
|
673
|
-
var CreateAgentCommand = defineCommand({
|
|
674
|
-
meta: {
|
|
675
|
-
key: "agent-console.agent.create",
|
|
676
|
-
version: "1.0.0",
|
|
677
|
-
stability: "stable",
|
|
678
|
-
owners: [...OWNERS2],
|
|
679
|
-
tags: ["agent", "create"],
|
|
680
|
-
description: "Creates a new AI agent configuration.",
|
|
681
|
-
goal: "Allow users to define new AI agents with specific models and tools.",
|
|
682
|
-
context: "Called from the agent builder UI when creating a new agent."
|
|
683
|
-
},
|
|
684
|
-
io: {
|
|
685
|
-
input: CreateAgentInputModel,
|
|
686
|
-
output: defineSchemaModel3({
|
|
687
|
-
name: "CreateAgentOutput",
|
|
688
|
-
fields: {
|
|
689
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
690
|
-
name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
|
|
691
|
-
slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
692
|
-
status: { type: AgentStatusEnum, isOptional: false }
|
|
693
|
-
}
|
|
694
|
-
}),
|
|
695
|
-
errors: {
|
|
696
|
-
SLUG_EXISTS: {
|
|
697
|
-
description: "An agent with this slug already exists in the organization",
|
|
698
|
-
http: 409,
|
|
699
|
-
gqlCode: "SLUG_EXISTS",
|
|
700
|
-
when: "Slug is already taken"
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
},
|
|
704
|
-
policy: { auth: "user" },
|
|
705
|
-
sideEffects: {
|
|
706
|
-
emits: [
|
|
707
|
-
{
|
|
708
|
-
ref: AgentCreatedEvent.meta,
|
|
709
|
-
when: "Agent is successfully created"
|
|
710
|
-
}
|
|
711
|
-
],
|
|
712
|
-
audit: ["agent-console.agent.created"]
|
|
713
|
-
},
|
|
714
|
-
acceptance: {
|
|
715
|
-
scenarios: [
|
|
716
|
-
{
|
|
717
|
-
key: "create-agent-happy-path",
|
|
718
|
-
given: ["User is authenticated", "Organization exists"],
|
|
719
|
-
when: ["User submits valid agent configuration"],
|
|
720
|
-
then: [
|
|
721
|
-
"New agent is created with DRAFT status",
|
|
722
|
-
"AgentCreated event is emitted"
|
|
723
|
-
]
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
key: "create-agent-slug-conflict",
|
|
727
|
-
given: ["User is authenticated", "Agent with same slug exists"],
|
|
728
|
-
when: ["User submits agent with duplicate slug"],
|
|
729
|
-
then: ["SLUG_EXISTS error is returned with 409 status"]
|
|
730
|
-
}
|
|
731
|
-
],
|
|
732
|
-
examples: [
|
|
733
|
-
{
|
|
734
|
-
key: "basic-create",
|
|
735
|
-
input: {
|
|
736
|
-
name: "Support Assistant",
|
|
737
|
-
slug: "support-assistant",
|
|
738
|
-
modelProvider: "openai",
|
|
739
|
-
modelId: "gpt-4"
|
|
740
|
-
},
|
|
741
|
-
output: {
|
|
742
|
-
id: "agent-123",
|
|
743
|
-
name: "Support Assistant",
|
|
744
|
-
slug: "support-assistant",
|
|
745
|
-
status: "draft"
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
]
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
var UpdateAgentCommand = defineCommand({
|
|
752
|
-
meta: {
|
|
753
|
-
key: "agent-console.agent.update",
|
|
754
|
-
version: "1.0.0",
|
|
755
|
-
stability: "stable",
|
|
756
|
-
owners: [...OWNERS2],
|
|
757
|
-
tags: ["agent", "update"],
|
|
758
|
-
description: "Updates an existing AI agent configuration.",
|
|
759
|
-
goal: "Allow users to modify agent settings and configuration.",
|
|
760
|
-
context: "Called from the agent settings UI."
|
|
761
|
-
},
|
|
762
|
-
io: {
|
|
763
|
-
input: UpdateAgentInputModel,
|
|
764
|
-
output: defineSchemaModel3({
|
|
765
|
-
name: "UpdateAgentOutput",
|
|
766
|
-
fields: {
|
|
767
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
768
|
-
name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
|
|
769
|
-
status: { type: AgentStatusEnum, isOptional: false },
|
|
770
|
-
updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
771
|
-
}
|
|
772
|
-
}),
|
|
773
|
-
errors: {
|
|
774
|
-
AGENT_NOT_FOUND: {
|
|
775
|
-
description: "The specified agent does not exist",
|
|
776
|
-
http: 404,
|
|
777
|
-
gqlCode: "AGENT_NOT_FOUND",
|
|
778
|
-
when: "Agent ID is invalid"
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
policy: { auth: "user" },
|
|
783
|
-
sideEffects: {
|
|
784
|
-
emits: [
|
|
785
|
-
{
|
|
786
|
-
key: "agent.updated",
|
|
787
|
-
version: "1.0.0",
|
|
788
|
-
stability: "stable",
|
|
789
|
-
owners: [...OWNERS2],
|
|
790
|
-
tags: ["agent", "updated"],
|
|
791
|
-
when: "Agent is updated",
|
|
792
|
-
payload: AgentSummaryModel
|
|
793
|
-
}
|
|
794
|
-
],
|
|
795
|
-
audit: ["agent.updated"]
|
|
796
|
-
},
|
|
797
|
-
acceptance: {
|
|
798
|
-
scenarios: [
|
|
799
|
-
{
|
|
800
|
-
key: "update-agent-happy-path",
|
|
801
|
-
given: ["Agent exists", "User owns the agent"],
|
|
802
|
-
when: ["User submits updated configuration"],
|
|
803
|
-
then: ["Agent is updated", "AgentUpdated event is emitted"]
|
|
804
|
-
},
|
|
805
|
-
{
|
|
806
|
-
key: "update-agent-not-found",
|
|
807
|
-
given: ["Agent does not exist"],
|
|
808
|
-
when: ["User attempts to update"],
|
|
809
|
-
then: ["AGENT_NOT_FOUND error is returned"]
|
|
810
|
-
}
|
|
811
|
-
],
|
|
812
|
-
examples: [
|
|
813
|
-
{
|
|
814
|
-
key: "update-name",
|
|
815
|
-
input: {
|
|
816
|
-
agentId: "agent-123",
|
|
817
|
-
name: "Updated Assistant",
|
|
818
|
-
systemPrompt: "You are a helpful assistant."
|
|
819
|
-
},
|
|
820
|
-
output: {
|
|
821
|
-
id: "agent-123",
|
|
822
|
-
name: "Updated Assistant",
|
|
823
|
-
status: "draft",
|
|
824
|
-
updatedAt: "2025-01-01T00:00:00Z"
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
]
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
var GetAgentQuery = defineQuery({
|
|
831
|
-
meta: {
|
|
832
|
-
key: "agent-console.agent.get",
|
|
833
|
-
version: "1.0.0",
|
|
834
|
-
stability: "stable",
|
|
835
|
-
owners: [...OWNERS2],
|
|
836
|
-
tags: ["agent", "get"],
|
|
837
|
-
description: "Retrieves an agent by its ID.",
|
|
838
|
-
goal: "View detailed agent configuration.",
|
|
839
|
-
context: "Called when viewing agent details or editing."
|
|
840
|
-
},
|
|
841
|
-
io: {
|
|
842
|
-
input: defineSchemaModel3({
|
|
843
|
-
name: "GetAgentInput",
|
|
844
|
-
fields: {
|
|
845
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
846
|
-
includeTools: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
|
|
847
|
-
}
|
|
848
|
-
}),
|
|
849
|
-
output: AgentWithToolsModel,
|
|
850
|
-
errors: {
|
|
851
|
-
AGENT_NOT_FOUND: {
|
|
852
|
-
description: "The specified agent does not exist",
|
|
853
|
-
http: 404,
|
|
854
|
-
gqlCode: "AGENT_NOT_FOUND",
|
|
855
|
-
when: "Agent ID is invalid"
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
},
|
|
859
|
-
policy: { auth: "user" },
|
|
860
|
-
acceptance: {
|
|
861
|
-
scenarios: [
|
|
862
|
-
{
|
|
863
|
-
key: "get-agent-happy-path",
|
|
864
|
-
given: ["Agent exists"],
|
|
865
|
-
when: ["User requests agent by ID"],
|
|
866
|
-
then: ["Agent details are returned"]
|
|
867
|
-
},
|
|
868
|
-
{
|
|
869
|
-
key: "get-agent-with-tools",
|
|
870
|
-
given: ["Agent exists with assigned tools"],
|
|
871
|
-
when: ["User requests agent with includeTools=true"],
|
|
872
|
-
then: ["Agent details with tools list are returned"]
|
|
873
|
-
}
|
|
874
|
-
],
|
|
875
|
-
examples: [
|
|
876
|
-
{
|
|
877
|
-
key: "get-basic",
|
|
878
|
-
input: { agentId: "agent-123", includeTools: false },
|
|
879
|
-
output: {
|
|
880
|
-
id: "agent-123",
|
|
881
|
-
name: "Support Assistant",
|
|
882
|
-
status: "active",
|
|
883
|
-
tools: []
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
]
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
var ListAgentsQuery = defineQuery({
|
|
890
|
-
meta: {
|
|
891
|
-
key: "agent-console.agent.list",
|
|
892
|
-
version: "1.0.0",
|
|
893
|
-
stability: "stable",
|
|
894
|
-
owners: [...OWNERS2],
|
|
895
|
-
tags: ["agent", "list"],
|
|
896
|
-
description: "Lists agents for an organization with optional filtering.",
|
|
897
|
-
goal: "Browse and search available agents.",
|
|
898
|
-
context: "Agent list/dashboard view."
|
|
899
|
-
},
|
|
900
|
-
io: {
|
|
901
|
-
input: defineSchemaModel3({
|
|
902
|
-
name: "ListAgentsInput",
|
|
903
|
-
fields: {
|
|
904
|
-
organizationId: {
|
|
905
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
906
|
-
isOptional: false
|
|
907
|
-
},
|
|
908
|
-
status: { type: AgentStatusEnum, isOptional: true },
|
|
909
|
-
modelProvider: { type: ModelProviderEnum, isOptional: true },
|
|
910
|
-
search: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
911
|
-
limit: {
|
|
912
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
913
|
-
isOptional: true,
|
|
914
|
-
defaultValue: 20
|
|
915
|
-
},
|
|
916
|
-
offset: {
|
|
917
|
-
type: ScalarTypeEnum3.Int_unsecure(),
|
|
918
|
-
isOptional: true,
|
|
919
|
-
defaultValue: 0
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
}),
|
|
923
|
-
output: defineSchemaModel3({
|
|
924
|
-
name: "ListAgentsOutput",
|
|
925
|
-
fields: {
|
|
926
|
-
items: { type: AgentSummaryModel, isArray: true, isOptional: false },
|
|
927
|
-
total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
|
|
928
|
-
hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
|
|
929
|
-
}
|
|
930
|
-
})
|
|
931
|
-
},
|
|
932
|
-
policy: { auth: "user" },
|
|
933
|
-
acceptance: {
|
|
934
|
-
scenarios: [
|
|
935
|
-
{
|
|
936
|
-
key: "list-agents-happy-path",
|
|
937
|
-
given: ["Organization has agents"],
|
|
938
|
-
when: ["User lists agents"],
|
|
939
|
-
then: ["Paginated list of agents is returned"]
|
|
940
|
-
},
|
|
941
|
-
{
|
|
942
|
-
key: "list-agents-filter-by-status",
|
|
943
|
-
given: ["Organization has agents with mixed statuses"],
|
|
944
|
-
when: ["User filters by status=active"],
|
|
945
|
-
then: ["Only active agents are returned"]
|
|
946
|
-
}
|
|
947
|
-
],
|
|
948
|
-
examples: [
|
|
949
|
-
{
|
|
950
|
-
key: "list-basic",
|
|
951
|
-
input: { organizationId: "org-123", limit: 10, offset: 0 },
|
|
952
|
-
output: { items: [], total: 0, hasMore: false }
|
|
953
|
-
}
|
|
954
|
-
]
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
var AssignToolToAgentCommand = defineCommand({
|
|
958
|
-
meta: {
|
|
959
|
-
key: "agent-console.agent.assignTool",
|
|
960
|
-
version: "1.0.0",
|
|
961
|
-
stability: "stable",
|
|
962
|
-
owners: [...OWNERS2],
|
|
963
|
-
tags: ["agent", "tool", "assign"],
|
|
964
|
-
description: "Assigns a tool to an agent with optional configuration.",
|
|
965
|
-
goal: "Enable agents to use specific tools.",
|
|
966
|
-
context: "Agent configuration UI - tool selection."
|
|
967
|
-
},
|
|
968
|
-
io: {
|
|
969
|
-
input: defineSchemaModel3({
|
|
970
|
-
name: "AssignToolToAgentInput",
|
|
971
|
-
fields: {
|
|
972
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
973
|
-
toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
974
|
-
config: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
|
|
975
|
-
order: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true }
|
|
976
|
-
}
|
|
977
|
-
}),
|
|
978
|
-
output: defineSchemaModel3({
|
|
979
|
-
name: "AssignToolToAgentOutput",
|
|
980
|
-
fields: {
|
|
981
|
-
agentToolId: {
|
|
982
|
-
type: ScalarTypeEnum3.String_unsecure(),
|
|
983
|
-
isOptional: false
|
|
984
|
-
},
|
|
985
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
986
|
-
toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
987
|
-
}
|
|
988
|
-
}),
|
|
989
|
-
errors: {
|
|
990
|
-
TOOL_ALREADY_ASSIGNED: {
|
|
991
|
-
description: "This tool is already assigned to the agent",
|
|
992
|
-
http: 409,
|
|
993
|
-
gqlCode: "TOOL_ALREADY_ASSIGNED",
|
|
994
|
-
when: "Tool assignment already exists"
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
},
|
|
998
|
-
policy: { auth: "user" },
|
|
999
|
-
sideEffects: { audit: ["agent.tool.assigned"] },
|
|
1000
|
-
acceptance: {
|
|
1001
|
-
scenarios: [
|
|
1002
|
-
{
|
|
1003
|
-
key: "assign-tool-happy-path",
|
|
1004
|
-
given: ["Agent exists", "Tool exists and is not assigned"],
|
|
1005
|
-
when: ["User assigns tool to agent"],
|
|
1006
|
-
then: ["Tool is assigned", "Assignment ID is returned"]
|
|
1007
|
-
},
|
|
1008
|
-
{
|
|
1009
|
-
key: "assign-tool-already-assigned",
|
|
1010
|
-
given: ["Tool is already assigned to agent"],
|
|
1011
|
-
when: ["User attempts to assign again"],
|
|
1012
|
-
then: ["TOOL_ALREADY_ASSIGNED error is returned"]
|
|
1013
|
-
}
|
|
1014
|
-
],
|
|
1015
|
-
examples: [
|
|
1016
|
-
{
|
|
1017
|
-
key: "assign-basic",
|
|
1018
|
-
input: { agentId: "agent-123", toolId: "tool-456" },
|
|
1019
|
-
output: {
|
|
1020
|
-
agentToolId: "at-789",
|
|
1021
|
-
agentId: "agent-123",
|
|
1022
|
-
toolId: "tool-456"
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
]
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
var RemoveToolFromAgentCommand = defineCommand({
|
|
1029
|
-
meta: {
|
|
1030
|
-
key: "agent-console.agent.removeTool",
|
|
1031
|
-
version: "1.0.0",
|
|
1032
|
-
stability: "stable",
|
|
1033
|
-
owners: [...OWNERS2],
|
|
1034
|
-
tags: ["agent", "tool", "remove"],
|
|
1035
|
-
description: "Removes a tool assignment from an agent.",
|
|
1036
|
-
goal: "Disable specific tools for an agent.",
|
|
1037
|
-
context: "Agent configuration UI - tool management."
|
|
1038
|
-
},
|
|
1039
|
-
io: {
|
|
1040
|
-
input: defineSchemaModel3({
|
|
1041
|
-
name: "RemoveToolFromAgentInput",
|
|
1042
|
-
fields: {
|
|
1043
|
-
agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
1044
|
-
toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
|
|
1045
|
-
}
|
|
1046
|
-
}),
|
|
1047
|
-
output: defineSchemaModel3({
|
|
1048
|
-
name: "RemoveToolFromAgentOutput",
|
|
1049
|
-
fields: {
|
|
1050
|
-
success: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
|
|
1051
|
-
}
|
|
1052
|
-
})
|
|
1053
|
-
},
|
|
1054
|
-
policy: { auth: "user" },
|
|
1055
|
-
sideEffects: { audit: ["agent.tool.removed"] },
|
|
1056
|
-
acceptance: {
|
|
1057
|
-
scenarios: [
|
|
1058
|
-
{
|
|
1059
|
-
key: "remove-tool-happy-path",
|
|
1060
|
-
given: ["Agent exists", "Tool is assigned to agent"],
|
|
1061
|
-
when: ["User removes tool from agent"],
|
|
1062
|
-
then: ["Tool is unassigned", "Success is returned"]
|
|
1063
|
-
}
|
|
1064
|
-
],
|
|
1065
|
-
examples: [
|
|
1066
|
-
{
|
|
1067
|
-
key: "remove-basic",
|
|
1068
|
-
input: { agentId: "agent-123", toolId: "tool-456" },
|
|
1069
|
-
output: { success: true }
|
|
1070
|
-
}
|
|
1071
|
-
]
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
1074
|
-
|
|
1075
|
-
// src/agent/agent.handler.ts
|
|
1076
|
-
var nextMockAgentId = MOCK_AGENTS.length + 1;
|
|
1077
|
-
async function mockListAgentsHandler(input) {
|
|
1078
|
-
const {
|
|
1079
|
-
organizationId,
|
|
1080
|
-
status,
|
|
1081
|
-
modelProvider,
|
|
1082
|
-
search,
|
|
1083
|
-
limit = 20,
|
|
1084
|
-
offset = 0
|
|
1085
|
-
} = input;
|
|
1086
|
-
let filtered = MOCK_AGENTS.filter((a) => a.organizationId === organizationId);
|
|
1087
|
-
if (status)
|
|
1088
|
-
filtered = filtered.filter((a) => a.status === status);
|
|
1089
|
-
if (modelProvider)
|
|
1090
|
-
filtered = filtered.filter((a) => a.modelProvider === modelProvider);
|
|
1091
|
-
if (search) {
|
|
1092
|
-
const q = search.toLowerCase();
|
|
1093
|
-
filtered = filtered.filter((a) => a.name.toLowerCase().includes(q) || a.description?.toLowerCase().includes(q) || a.tags?.some((t) => t.toLowerCase().includes(q)));
|
|
1094
|
-
}
|
|
1095
|
-
const total = filtered.length;
|
|
1096
|
-
const items = filtered.slice(offset, offset + limit).map((a) => ({
|
|
1097
|
-
id: a.id,
|
|
1098
|
-
name: a.name,
|
|
1099
|
-
slug: a.slug,
|
|
1100
|
-
description: a.description,
|
|
1101
|
-
status: a.status,
|
|
1102
|
-
modelProvider: a.modelProvider,
|
|
1103
|
-
modelName: a.modelName,
|
|
1104
|
-
version: a.version,
|
|
1105
|
-
createdAt: a.createdAt
|
|
1106
|
-
}));
|
|
1107
|
-
return { items, total, hasMore: offset + limit < total };
|
|
1108
|
-
}
|
|
1109
|
-
async function mockGetAgentHandler(input) {
|
|
1110
|
-
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
1111
|
-
if (!agent)
|
|
1112
|
-
throw new Error("AGENT_NOT_FOUND");
|
|
1113
|
-
const result = { ...agent, toolIds: ["tool-1", "tool-2"] };
|
|
1114
|
-
if (input.includeTools) {
|
|
1115
|
-
result.tools = MOCK_TOOLS.slice(0, 2).map((t) => ({
|
|
1116
|
-
id: t.id,
|
|
1117
|
-
name: t.name,
|
|
1118
|
-
slug: t.slug,
|
|
1119
|
-
description: t.description,
|
|
1120
|
-
category: t.category
|
|
1121
|
-
}));
|
|
1122
|
-
}
|
|
1123
|
-
return result;
|
|
1124
|
-
}
|
|
1125
|
-
async function mockCreateAgentHandler(input) {
|
|
1126
|
-
const exists = MOCK_AGENTS.some((a) => a.organizationId === input.organizationId && a.slug === input.slug);
|
|
1127
|
-
if (exists)
|
|
1128
|
-
throw new Error("SLUG_EXISTS");
|
|
1129
|
-
return {
|
|
1130
|
-
id: `agent-${nextMockAgentId++}`,
|
|
1131
|
-
name: input.name,
|
|
1132
|
-
slug: input.slug,
|
|
1133
|
-
status: "DRAFT"
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
async function mockUpdateAgentHandler(input) {
|
|
1137
|
-
const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
|
|
1138
|
-
if (!agent)
|
|
1139
|
-
throw new Error("AGENT_NOT_FOUND");
|
|
1140
|
-
return {
|
|
1141
|
-
id: agent.id,
|
|
1142
|
-
name: input.name ?? agent.name,
|
|
1143
|
-
status: input.status ?? agent.status,
|
|
1144
|
-
updatedAt: new Date
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
// src/agent/agent.presentation.ts
|
|
1149
|
-
import {
|
|
1150
|
-
definePresentation,
|
|
1151
|
-
StabilityEnum
|
|
1152
|
-
} from "@contractspec/lib.contracts-spec";
|
|
1153
|
-
var AgentListPresentation = definePresentation({
|
|
1154
|
-
meta: {
|
|
1155
|
-
key: "agent-console.agent.viewList",
|
|
1156
|
-
version: "1.0.0",
|
|
1157
|
-
title: "Agent List",
|
|
1158
|
-
description: "List view of AI agents with status, model provider, and version info",
|
|
1159
|
-
goal: "Provide an overview of all agents in an organization.",
|
|
1160
|
-
context: "Main landing page for agent management.",
|
|
1161
|
-
domain: "agent-console",
|
|
1162
|
-
owners: ["@agent-console-team"],
|
|
1163
|
-
tags: ["agent", "list", "dashboard"],
|
|
1164
|
-
stability: StabilityEnum.Experimental
|
|
1165
|
-
},
|
|
1166
|
-
source: {
|
|
1167
|
-
type: "component",
|
|
1168
|
-
framework: "react",
|
|
1169
|
-
componentKey: "AgentListView",
|
|
1170
|
-
props: AgentSummaryModel
|
|
1171
|
-
},
|
|
1172
|
-
targets: ["react", "markdown", "application/json"],
|
|
1173
|
-
policy: { flags: ["agent-console.enabled"] }
|
|
1174
|
-
});
|
|
1175
|
-
var AgentDetailPresentation = definePresentation({
|
|
1176
|
-
meta: {
|
|
1177
|
-
key: "agent-console.agent.detail",
|
|
1178
|
-
version: "1.0.0",
|
|
1179
|
-
title: "Agent Details",
|
|
1180
|
-
description: "Detailed view of an AI agent with configuration, tools, and recent runs",
|
|
1181
|
-
goal: "Allow users to inspect and configure a specific agent.",
|
|
1182
|
-
context: "Detailed view of an agent.",
|
|
1183
|
-
domain: "agent-console",
|
|
1184
|
-
owners: ["@agent-console-team"],
|
|
1185
|
-
tags: ["agent", "detail"],
|
|
1186
|
-
stability: StabilityEnum.Experimental
|
|
1187
|
-
},
|
|
1188
|
-
source: {
|
|
1189
|
-
type: "component",
|
|
1190
|
-
framework: "react",
|
|
1191
|
-
componentKey: "AgentDetailView"
|
|
1192
|
-
},
|
|
1193
|
-
targets: ["react", "markdown"],
|
|
1194
|
-
policy: { flags: ["agent-console.enabled"] }
|
|
1195
|
-
});
|
|
1196
|
-
var AgentConsoleDashboardPresentation = definePresentation({
|
|
1197
|
-
meta: {
|
|
1198
|
-
key: "agent-console.dashboard",
|
|
1199
|
-
version: "1.0.0",
|
|
1200
|
-
title: "Agent Console Dashboard",
|
|
1201
|
-
description: "Dashboard overview of AI agents, runs, and tools",
|
|
1202
|
-
goal: "Provide a high-level overview of the AI platform health and usage.",
|
|
1203
|
-
context: "Root dashboard of the Agent Console.",
|
|
1204
|
-
domain: "agent-console",
|
|
1205
|
-
owners: ["@agent-console-team"],
|
|
1206
|
-
tags: ["dashboard", "overview"],
|
|
1207
|
-
stability: StabilityEnum.Experimental
|
|
1208
|
-
},
|
|
1209
|
-
source: {
|
|
1210
|
-
type: "component",
|
|
1211
|
-
framework: "react",
|
|
1212
|
-
componentKey: "AgentConsoleDashboard"
|
|
1213
|
-
},
|
|
1214
|
-
targets: ["react", "markdown"],
|
|
1215
|
-
policy: { flags: ["agent-console.enabled"] }
|
|
1216
|
-
});
|
|
1217
|
-
export {
|
|
1218
|
-
mockUpdateAgentHandler,
|
|
1219
|
-
mockListAgentsHandler,
|
|
1220
|
-
mockGetAgentHandler,
|
|
1221
|
-
mockCreateAgentHandler,
|
|
1222
|
-
UpdateAgentInputModel,
|
|
1223
|
-
UpdateAgentCommand,
|
|
1224
|
-
ToolChoiceEnum,
|
|
1225
|
-
RemoveToolFromAgentCommand,
|
|
1226
|
-
ModelProviderEnum,
|
|
1227
|
-
ModelProviderEntityEnum,
|
|
1228
|
-
ListAgentsQuery,
|
|
1229
|
-
GetAgentQuery,
|
|
1230
|
-
CreateAgentInputModel,
|
|
1231
|
-
CreateAgentCommand,
|
|
1232
|
-
AssignToolToAgentCommand,
|
|
1233
|
-
AgentWithToolsModel,
|
|
1234
|
-
AgentUpdatedEvent,
|
|
1235
|
-
AgentToolRemovedEvent,
|
|
1236
|
-
AgentToolRefModel,
|
|
1237
|
-
AgentToolEntity,
|
|
1238
|
-
AgentToolAssignedEvent,
|
|
1239
|
-
AgentSummaryModel,
|
|
1240
|
-
AgentStatusEnum,
|
|
1241
|
-
AgentStatusEntityEnum,
|
|
1242
|
-
AgentModel,
|
|
1243
|
-
AgentListPresentation,
|
|
1244
|
-
AgentEntity,
|
|
1245
|
-
AgentDetailPresentation,
|
|
1246
|
-
AgentCreatedEvent,
|
|
1247
|
-
AgentConsoleDashboardPresentation
|
|
1248
|
-
};
|
|
1
|
+
import{defineEntity as X,defineEntityEnum as $,field as o,index as h}from"@contractspec/lib.schema";var _=$({name:"AgentStatus",values:["DRAFT","ACTIVE","PAUSED","ARCHIVED"],description:"Lifecycle status of the agent"}),N=$({name:"ModelProvider",values:["OPENAI","ANTHROPIC","GOOGLE","MISTRAL","CUSTOM"],description:"AI model provider"}),f=X({name:"Agent",schema:"agent_console",description:"Represents an AI agent configuration with assigned tools and parameters.",fields:{id:o.id(),organizationId:o.string({description:"Organization that owns this agent"}),name:o.string({description:"Agent name (1-100 chars)"}),slug:o.string({description:"URL-safe identifier (lowercase, numbers, hyphens)"}),description:o.string({isOptional:!0,description:"Agent description (max 1000 chars)"}),status:o.enum("AgentStatus",{default:"DRAFT"}),modelProvider:o.enum("ModelProvider",{default:"OPENAI"}),modelName:o.string({description:"Model identifier: 'gpt-4', 'claude-3-opus', etc."}),modelConfig:o.json({isOptional:!0,description:"Model parameters: temperature, max_tokens, etc."}),systemPrompt:o.string({description:"System prompt for the agent"}),userPromptTemplate:o.string({isOptional:!0,description:"Template for user prompts"}),toolIds:o.string({isArray:!0,isOptional:!0,description:"IDs of assigned tools"}),toolChoice:o.string({default:"auto",description:"Tool selection mode: 'auto', 'required', 'none'"}),maxIterations:o.int({default:10,description:"Maximum iterations per run"}),maxTokensPerRun:o.int({isOptional:!0,description:"Maximum tokens per run"}),timeoutMs:o.int({default:120000,description:"Execution timeout in milliseconds"}),version:o.string({default:"1.0.0",description:"Agent version"}),tags:o.string({isArray:!0,isOptional:!0,description:"Tags for categorization"}),createdAt:o.createdAt(),updatedAt:o.updatedAt(),createdById:o.string({isOptional:!0,description:"User who created this agent"}),tools:o.hasMany("Tool",{description:"Tools assigned to this agent"})},indexes:[h.unique(["organizationId","slug"]),h.on(["organizationId","status"]),h.on(["modelProvider","modelName"])],enums:[_,N]}),a=X({name:"AgentTool",schema:"agent_console",description:"Links an agent to its assigned tools with configuration.",fields:{id:o.id(),agentId:o.foreignKey({description:"Agent ID"}),toolId:o.foreignKey({description:"Tool ID"}),config:o.json({isOptional:!0,description:"Tool-specific configuration for this agent"}),order:o.int({default:0,description:"Order of tool in agent tool list"}),isEnabled:o.boolean({default:!0,description:"Whether tool is enabled for this agent"}),createdAt:o.createdAt(),agent:o.belongsTo("Agent",["agentId"],["id"]),tool:o.belongsTo("Tool",["toolId"],["id"])},indexes:[h.unique(["agentId","toolId"]),h.on(["agentId","order"])]});import{defineEnum as Q}from"@contractspec/lib.schema";var w=Q("AgentStatus",["DRAFT","ACTIVE","PAUSED","ARCHIVED"]),b=Q("ModelProvider",["OPENAI","ANTHROPIC","GOOGLE","MISTRAL","CUSTOM"]),C=Q("ToolChoice",["auto","required","none"]);import{defineEvent as P}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as j,ScalarTypeEnum as s}from"@contractspec/lib.schema";var L=["@agent-console-team"],y=j({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}}}),G=P({meta:{key:"agent-console.agent.created",version:"1.0.0",description:"A new AI agent was configured.",stability:"stable",owners:[...L],tags:["agent","created"]},payload:y}),T=j({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}}}),l=P({meta:{key:"agent-console.agent.updated",version:"1.0.0",description:"An AI agent configuration was updated.",stability:"stable",owners:[...L],tags:["agent","updated"]},payload:T}),E=j({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}}}),S=P({meta:{key:"agent-console.agent.toolAssigned",version:"1.0.0",description:"A tool was assigned to an agent.",stability:"stable",owners:[...L],tags:["agent","tool","assigned"]},payload:E}),tt=j({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}}}),ot=P({meta:{key:"agent-console.agent.toolRemoved",version:"1.0.0",description:"A tool was removed from an agent.",stability:"stable",owners:[...L],tags:["agent","tool","removed"]},payload:tt});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 O=[{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 st=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:w,isOptional:!1},modelProvider:{type:b,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:C,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}}}),d=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:w,isOptional:!1},modelProvider:{type:b,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}}}),Y=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:w,isOptional:!1},modelProvider:{type:b,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:C,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:b,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:C,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}}}),R=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:w,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:C,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 z,defineQuery as M}from"@contractspec/lib.contracts-spec/operations";import{defineSchemaModel as D,ScalarTypeEnum as e}from"@contractspec/lib.schema";var x=["@agent-console-team"],W=z({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:D({name:"CreateAgentOutput",fields:{id:{type:e.String_unsecure(),isOptional:!1},name:{type:e.NonEmptyString(),isOptional:!1},slug:{type:e.String_unsecure(),isOptional:!1},status:{type:w,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:G.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"}}]}}),p=z({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:R,output:D({name:"UpdateAgentOutput",fields:{id:{type:e.String_unsecure(),isOptional:!1},name:{type:e.NonEmptyString(),isOptional:!1},status:{type:w,isOptional:!1},updatedAt:{type:e.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:d}],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=M({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:D({name:"GetAgentInput",fields:{agentId:{type:e.String_unsecure(),isOptional:!1},includeTools:{type:e.Boolean(),isOptional:!0}}}),output:Y,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:[]}}]}}),u=M({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:D({name:"ListAgentsInput",fields:{organizationId:{type:e.String_unsecure(),isOptional:!1},status:{type:w,isOptional:!0},modelProvider:{type:b,isOptional:!0},search:{type:e.String_unsecure(),isOptional:!0},limit:{type:e.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:e.Int_unsecure(),isOptional:!0,defaultValue:0}}}),output:D({name:"ListAgentsOutput",fields:{items:{type:d,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1},hasMore:{type:e.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}}]}}),et=z({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:D({name:"AssignToolToAgentInput",fields:{agentId:{type:e.String_unsecure(),isOptional:!1},toolId:{type:e.String_unsecure(),isOptional:!1},config:{type:e.JSONObject(),isOptional:!0},order:{type:e.Int_unsecure(),isOptional:!0}}}),output:D({name:"AssignToolToAgentOutput",fields:{agentToolId:{type:e.String_unsecure(),isOptional:!1},agentId:{type:e.String_unsecure(),isOptional:!1},toolId:{type:e.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"}}]}}),it=z({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:D({name:"RemoveToolFromAgentInput",fields:{agentId:{type:e.String_unsecure(),isOptional:!1},toolId:{type:e.String_unsecure(),isOptional:!1}}}),output:D({name:"RemoveToolFromAgentOutput",fields:{success:{type:e.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 gt=Z.length+1;async function rt(g){let{organizationId:r,status:A,modelProvider:I,search:F,limit:n=20,offset:V=0}=g,v=Z.filter((i)=>i.organizationId===r);if(A)v=v.filter((i)=>i.status===A);if(I)v=v.filter((i)=>i.modelProvider===I);if(F){let i=F.toLowerCase();v=v.filter((H)=>H.name.toLowerCase().includes(i)||H.description?.toLowerCase().includes(i)||H.tags?.some((c)=>c.toLowerCase().includes(i)))}let J=v.length;return{items:v.slice(V,V+n).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:J,hasMore:V+n<J}}async function At(g){let r=Z.find((I)=>I.id===g.agentId);if(!r)throw Error("AGENT_NOT_FOUND");let A={...r,toolIds:["tool-1","tool-2"]};if(g.includeTools)A.tools=O.slice(0,2).map((I)=>({id:I.id,name:I.name,slug:I.slug,description:I.description,category:I.category}));return A}async function It(g){if(Z.some((A)=>A.organizationId===g.organizationId&&A.slug===g.slug))throw Error("SLUG_EXISTS");return{id:`agent-${gt++}`,name:g.name,slug:g.slug,status:"DRAFT"}}async function wt(g){let r=Z.find((A)=>A.id===g.agentId);if(!r)throw Error("AGENT_NOT_FOUND");return{id:r.id,name:g.name??r.name,status:g.status??r.status,updatedAt:new Date}}import{definePresentation as U,StabilityEnum as B}from"@contractspec/lib.contracts-spec";var Dt=U({meta:{key:"agent-console.agent.viewList",version:"1.0.0",title:"Agent List",description:"List view of AI agents with status, model provider, and version info",goal:"Provide an overview of all agents in an organization.",context:"Main landing page for agent management.",domain:"agent-console",owners:["@agent-console-team"],tags:["agent","list","dashboard"],stability:B.Experimental},source:{type:"component",framework:"react",componentKey:"AgentListView",props:d},targets:["react","markdown","application/json"],policy:{flags:["agent-console.enabled"]}}),vt=U({meta:{key:"agent-console.agent.detail",version:"1.0.0",title:"Agent Details",description:"Detailed view of an AI agent with configuration, tools, and recent runs",goal:"Allow users to inspect and configure a specific agent.",context:"Detailed view of an agent.",domain:"agent-console",owners:["@agent-console-team"],tags:["agent","detail"],stability:B.Experimental},source:{type:"component",framework:"react",componentKey:"AgentDetailView"},targets:["react","markdown"],policy:{flags:["agent-console.enabled"]}}),bt=U({meta:{key:"agent-console.dashboard",version:"1.0.0",title:"Agent Console Dashboard",description:"Dashboard overview of AI agents, runs, and tools",goal:"Provide a high-level overview of the AI platform health and usage.",context:"Root dashboard of the Agent Console.",domain:"agent-console",owners:["@agent-console-team"],tags:["dashboard","overview"],stability:B.Experimental},source:{type:"component",framework:"react",componentKey:"AgentConsoleDashboard"},targets:["react","markdown"],policy:{flags:["agent-console.enabled"]}});export{wt as mockUpdateAgentHandler,rt as mockListAgentsHandler,At as mockGetAgentHandler,It as mockCreateAgentHandler,R as UpdateAgentInputModel,p as UpdateAgentCommand,C as ToolChoiceEnum,it as RemoveToolFromAgentCommand,b as ModelProviderEnum,N as ModelProviderEntityEnum,u as ListAgentsQuery,m as GetAgentQuery,k as CreateAgentInputModel,W as CreateAgentCommand,et as AssignToolToAgentCommand,Y as AgentWithToolsModel,l as AgentUpdatedEvent,ot as AgentToolRemovedEvent,K as AgentToolRefModel,a as AgentToolEntity,S as AgentToolAssignedEvent,d as AgentSummaryModel,w as AgentStatusEnum,_ as AgentStatusEntityEnum,st as AgentModel,Dt as AgentListPresentation,f as AgentEntity,vt as AgentDetailPresentation,G as AgentCreatedEvent,bt as AgentConsoleDashboardPresentation};
|