@contractspec/example.agent-console 1.44.0

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.
Files changed (168) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +133 -0
  2. package/.turbo/turbo-build.log +134 -0
  3. package/CHANGELOG.md +212 -0
  4. package/LICENSE +21 -0
  5. package/README.md +86 -0
  6. package/dist/agent/agent.entity.d.ts +55 -0
  7. package/dist/agent/agent.entity.d.ts.map +1 -0
  8. package/dist/agent/agent.entity.js +136 -0
  9. package/dist/agent/agent.entity.js.map +1 -0
  10. package/dist/agent/agent.enum.d.ts +18 -0
  11. package/dist/agent/agent.enum.d.ts.map +1 -0
  12. package/dist/agent/agent.enum.js +34 -0
  13. package/dist/agent/agent.enum.js.map +1 -0
  14. package/dist/agent/agent.event.d.ts +128 -0
  15. package/dist/agent/agent.event.d.ts.map +1 -0
  16. package/dist/agent/agent.event.js +210 -0
  17. package/dist/agent/agent.event.js.map +1 -0
  18. package/dist/agent/agent.handler.d.ts +100 -0
  19. package/dist/agent/agent.handler.d.ts.map +1 -0
  20. package/dist/agent/agent.handler.js +84 -0
  21. package/dist/agent/agent.handler.js.map +1 -0
  22. package/dist/agent/agent.operation.d.ts +471 -0
  23. package/dist/agent/agent.operation.d.ts.map +1 -0
  24. package/dist/agent/agent.operation.js +486 -0
  25. package/dist/agent/agent.operation.js.map +1 -0
  26. package/dist/agent/agent.presentation.d.ts +19 -0
  27. package/dist/agent/agent.presentation.d.ts.map +1 -0
  28. package/dist/agent/agent.presentation.js +89 -0
  29. package/dist/agent/agent.presentation.js.map +1 -0
  30. package/dist/agent/agent.schema.d.ts +401 -0
  31. package/dist/agent/agent.schema.d.ts.map +1 -0
  32. package/dist/agent/agent.schema.js +406 -0
  33. package/dist/agent/agent.schema.js.map +1 -0
  34. package/dist/agent/index.d.ts +8 -0
  35. package/dist/agent/index.js +9 -0
  36. package/dist/agent.feature.d.ts +12 -0
  37. package/dist/agent.feature.d.ts.map +1 -0
  38. package/dist/agent.feature.js +303 -0
  39. package/dist/agent.feature.js.map +1 -0
  40. package/dist/docs/agent-console.docblock.d.ts +1 -0
  41. package/dist/docs/agent-console.docblock.js +113 -0
  42. package/dist/docs/agent-console.docblock.js.map +1 -0
  43. package/dist/docs/index.d.ts +1 -0
  44. package/dist/docs/index.js +1 -0
  45. package/dist/example.d.ts +40 -0
  46. package/dist/example.d.ts.map +1 -0
  47. package/dist/example.js +51 -0
  48. package/dist/example.js.map +1 -0
  49. package/dist/handlers/index.d.ts +4 -0
  50. package/dist/handlers/index.js +5 -0
  51. package/dist/index.d.ts +30 -0
  52. package/dist/index.js +32 -0
  53. package/dist/presentations/index.d.ts +4 -0
  54. package/dist/presentations/index.js +5 -0
  55. package/dist/run/index.d.ts +8 -0
  56. package/dist/run/index.js +9 -0
  57. package/dist/run/run.entity.d.ts +82 -0
  58. package/dist/run/run.entity.d.ts.map +1 -0
  59. package/dist/run/run.entity.js +205 -0
  60. package/dist/run/run.entity.js.map +1 -0
  61. package/dist/run/run.enum.d.ts +22 -0
  62. package/dist/run/run.enum.d.ts.map +1 -0
  63. package/dist/run/run.enum.js +45 -0
  64. package/dist/run/run.enum.js.map +1 -0
  65. package/dist/run/run.event.d.ts +290 -0
  66. package/dist/run/run.event.d.ts.map +1 -0
  67. package/dist/run/run.event.js +434 -0
  68. package/dist/run/run.event.js.map +1 -0
  69. package/dist/run/run.handler.d.ts +203 -0
  70. package/dist/run/run.handler.d.ts.map +1 -0
  71. package/dist/run/run.handler.js +83 -0
  72. package/dist/run/run.handler.js.map +1 -0
  73. package/dist/run/run.operation.d.ts +720 -0
  74. package/dist/run/run.operation.d.ts.map +1 -0
  75. package/dist/run/run.operation.js +626 -0
  76. package/dist/run/run.operation.js.map +1 -0
  77. package/dist/run/run.presentation.d.ts +15 -0
  78. package/dist/run/run.presentation.d.ts.map +1 -0
  79. package/dist/run/run.presentation.js +65 -0
  80. package/dist/run/run.presentation.js.map +1 -0
  81. package/dist/run/run.schema.d.ts +416 -0
  82. package/dist/run/run.schema.d.ts.map +1 -0
  83. package/dist/run/run.schema.js +338 -0
  84. package/dist/run/run.schema.js.map +1 -0
  85. package/dist/shared/index.d.ts +4 -0
  86. package/dist/shared/index.js +5 -0
  87. package/dist/shared/mock-agents.d.ts +88 -0
  88. package/dist/shared/mock-agents.d.ts.map +1 -0
  89. package/dist/shared/mock-agents.js +94 -0
  90. package/dist/shared/mock-agents.js.map +1 -0
  91. package/dist/shared/mock-runs.d.ts +120 -0
  92. package/dist/shared/mock-runs.d.ts.map +1 -0
  93. package/dist/shared/mock-runs.js +118 -0
  94. package/dist/shared/mock-runs.js.map +1 -0
  95. package/dist/shared/mock-tools.d.ts +244 -0
  96. package/dist/shared/mock-tools.d.ts.map +1 -0
  97. package/dist/shared/mock-tools.js +181 -0
  98. package/dist/shared/mock-tools.js.map +1 -0
  99. package/dist/tool/index.d.ts +8 -0
  100. package/dist/tool/index.js +9 -0
  101. package/dist/tool/tool.entity.d.ts +42 -0
  102. package/dist/tool/tool.entity.d.ts.map +1 -0
  103. package/dist/tool/tool.entity.js +105 -0
  104. package/dist/tool/tool.entity.js.map +1 -0
  105. package/dist/tool/tool.enum.d.ts +18 -0
  106. package/dist/tool/tool.enum.d.ts.map +1 -0
  107. package/dist/tool/tool.enum.js +35 -0
  108. package/dist/tool/tool.enum.js.map +1 -0
  109. package/dist/tool/tool.event.d.ts +103 -0
  110. package/dist/tool/tool.event.d.ts.map +1 -0
  111. package/dist/tool/tool.event.js +159 -0
  112. package/dist/tool/tool.event.js.map +1 -0
  113. package/dist/tool/tool.handler.d.ts +315 -0
  114. package/dist/tool/tool.handler.d.ts.map +1 -0
  115. package/dist/tool/tool.handler.js +87 -0
  116. package/dist/tool/tool.handler.js.map +1 -0
  117. package/dist/tool/tool.operation.d.ts +411 -0
  118. package/dist/tool/tool.operation.d.ts.map +1 -0
  119. package/dist/tool/tool.operation.js +406 -0
  120. package/dist/tool/tool.operation.js.map +1 -0
  121. package/dist/tool/tool.presentation.d.ts +15 -0
  122. package/dist/tool/tool.presentation.d.ts.map +1 -0
  123. package/dist/tool/tool.presentation.js +65 -0
  124. package/dist/tool/tool.presentation.js.map +1 -0
  125. package/dist/tool/tool.schema.d.ts +218 -0
  126. package/dist/tool/tool.schema.d.ts.map +1 -0
  127. package/dist/tool/tool.schema.js +236 -0
  128. package/dist/tool/tool.schema.js.map +1 -0
  129. package/example.ts +1 -0
  130. package/package.json +123 -0
  131. package/src/agent/agent.entity.ts +137 -0
  132. package/src/agent/agent.enum.ts +31 -0
  133. package/src/agent/agent.event.ts +142 -0
  134. package/src/agent/agent.handler.ts +178 -0
  135. package/src/agent/agent.operation.ts +444 -0
  136. package/src/agent/agent.presentation.ts +81 -0
  137. package/src/agent/agent.schema.ts +214 -0
  138. package/src/agent/index.ts +67 -0
  139. package/src/agent.feature.ts +146 -0
  140. package/src/docs/agent-console.docblock.ts +97 -0
  141. package/src/docs/index.ts +1 -0
  142. package/src/example.ts +34 -0
  143. package/src/handlers/index.ts +27 -0
  144. package/src/index.ts +27 -0
  145. package/src/presentations/index.ts +26 -0
  146. package/src/run/index.ts +68 -0
  147. package/src/run/run.entity.ts +175 -0
  148. package/src/run/run.enum.ts +43 -0
  149. package/src/run/run.event.ts +264 -0
  150. package/src/run/run.handler.ts +138 -0
  151. package/src/run/run.operation.ts +524 -0
  152. package/src/run/run.presentation.ts +55 -0
  153. package/src/run/run.schema.ts +169 -0
  154. package/src/shared/index.ts +6 -0
  155. package/src/shared/mock-agents.ts +81 -0
  156. package/src/shared/mock-runs.ts +107 -0
  157. package/src/shared/mock-tools.ts +145 -0
  158. package/src/tool/index.ts +60 -0
  159. package/src/tool/tool.entity.ts +99 -0
  160. package/src/tool/tool.enum.ts +32 -0
  161. package/src/tool/tool.event.ts +119 -0
  162. package/src/tool/tool.handler.ts +154 -0
  163. package/src/tool/tool.operation.ts +366 -0
  164. package/src/tool/tool.presentation.ts +56 -0
  165. package/src/tool/tool.schema.ts +133 -0
  166. package/tsconfig.json +10 -0
  167. package/tsconfig.tsbuildinfo +1 -0
  168. package/tsdown.config.js +7 -0
@@ -0,0 +1,214 @@
1
+ import { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';
2
+ import {
3
+ AgentStatusEnum,
4
+ ModelProviderEnum,
5
+ ToolChoiceEnum,
6
+ } from './agent.enum';
7
+
8
+ /**
9
+ * AI agent configuration schema.
10
+ */
11
+ export const AgentModel = defineSchemaModel({
12
+ name: 'Agent',
13
+ description: 'AI agent configuration',
14
+ fields: {
15
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
16
+ organizationId: {
17
+ type: ScalarTypeEnum.String_unsecure(),
18
+ isOptional: false,
19
+ },
20
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
21
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
+ status: { type: AgentStatusEnum, isOptional: false },
24
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
25
+ modelName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
26
+ modelConfig: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
27
+ systemPrompt: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
+ userPromptTemplate: {
29
+ type: ScalarTypeEnum.String_unsecure(),
30
+ isOptional: true,
31
+ },
32
+ toolIds: {
33
+ type: ScalarTypeEnum.String_unsecure(),
34
+ isArray: true,
35
+ isOptional: true,
36
+ },
37
+ toolChoice: {
38
+ type: ToolChoiceEnum,
39
+ isOptional: false,
40
+ defaultValue: 'auto',
41
+ },
42
+ maxIterations: {
43
+ type: ScalarTypeEnum.Int_unsecure(),
44
+ isOptional: false,
45
+ defaultValue: 10,
46
+ },
47
+ maxTokensPerRun: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
48
+ timeoutMs: {
49
+ type: ScalarTypeEnum.Int_unsecure(),
50
+ isOptional: false,
51
+ defaultValue: 120000,
52
+ },
53
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
54
+ tags: {
55
+ type: ScalarTypeEnum.String_unsecure(),
56
+ isArray: true,
57
+ isOptional: true,
58
+ },
59
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
60
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
61
+ },
62
+ });
63
+
64
+ /**
65
+ * Summary of an agent for list views.
66
+ */
67
+ export const AgentSummaryModel = defineSchemaModel({
68
+ name: 'AgentSummary',
69
+ description: 'Summary of an agent for list views',
70
+ fields: {
71
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
72
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
73
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
74
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
75
+ status: { type: AgentStatusEnum, isOptional: false },
76
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
77
+ modelName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
78
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
79
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
80
+ },
81
+ });
82
+
83
+ /**
84
+ * Tool reference in agent context.
85
+ */
86
+ export const AgentToolRefModel = defineSchemaModel({
87
+ name: 'AgentToolRef',
88
+ description: 'Tool reference in agent context',
89
+ fields: {
90
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
91
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
92
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
93
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
94
+ category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
95
+ },
96
+ });
97
+
98
+ /**
99
+ * Agent with associated tools.
100
+ */
101
+ export const AgentWithToolsModel = defineSchemaModel({
102
+ name: 'AgentWithTools',
103
+ description: 'Agent with associated tools',
104
+ fields: {
105
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
106
+ organizationId: {
107
+ type: ScalarTypeEnum.String_unsecure(),
108
+ isOptional: false,
109
+ },
110
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
111
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
112
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
113
+ status: { type: AgentStatusEnum, isOptional: false },
114
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
115
+ modelName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
116
+ modelConfig: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
117
+ systemPrompt: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
118
+ userPromptTemplate: {
119
+ type: ScalarTypeEnum.String_unsecure(),
120
+ isOptional: true,
121
+ },
122
+ toolIds: {
123
+ type: ScalarTypeEnum.String_unsecure(),
124
+ isArray: true,
125
+ isOptional: true,
126
+ },
127
+ toolChoice: { type: ToolChoiceEnum, isOptional: false },
128
+ maxIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
129
+ maxTokensPerRun: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
130
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
131
+ version: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
132
+ tags: {
133
+ type: ScalarTypeEnum.String_unsecure(),
134
+ isArray: true,
135
+ isOptional: true,
136
+ },
137
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
138
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
139
+ tools: { type: AgentToolRefModel, isArray: true, isOptional: true },
140
+ },
141
+ });
142
+
143
+ /**
144
+ * Input for creating an agent.
145
+ */
146
+ export const CreateAgentInputModel = defineSchemaModel({
147
+ name: 'CreateAgentInput',
148
+ description: 'Input for creating an agent',
149
+ fields: {
150
+ organizationId: {
151
+ type: ScalarTypeEnum.String_unsecure(),
152
+ isOptional: false,
153
+ },
154
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
155
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
156
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
157
+ modelProvider: { type: ModelProviderEnum, isOptional: false },
158
+ modelName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
159
+ modelConfig: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
160
+ systemPrompt: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
161
+ userPromptTemplate: {
162
+ type: ScalarTypeEnum.String_unsecure(),
163
+ isOptional: true,
164
+ },
165
+ toolIds: {
166
+ type: ScalarTypeEnum.String_unsecure(),
167
+ isArray: true,
168
+ isOptional: true,
169
+ },
170
+ toolChoice: { type: ToolChoiceEnum, isOptional: true },
171
+ maxIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
172
+ maxTokensPerRun: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
173
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
174
+ tags: {
175
+ type: ScalarTypeEnum.String_unsecure(),
176
+ isArray: true,
177
+ isOptional: true,
178
+ },
179
+ },
180
+ });
181
+
182
+ /**
183
+ * Input for updating an agent.
184
+ */
185
+ export const UpdateAgentInputModel = defineSchemaModel({
186
+ name: 'UpdateAgentInput',
187
+ description: 'Input for updating an agent',
188
+ fields: {
189
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
190
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: true },
191
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
192
+ status: { type: AgentStatusEnum, isOptional: true },
193
+ modelConfig: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
194
+ systemPrompt: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
195
+ userPromptTemplate: {
196
+ type: ScalarTypeEnum.String_unsecure(),
197
+ isOptional: true,
198
+ },
199
+ toolIds: {
200
+ type: ScalarTypeEnum.String_unsecure(),
201
+ isArray: true,
202
+ isOptional: true,
203
+ },
204
+ toolChoice: { type: ToolChoiceEnum, isOptional: true },
205
+ maxIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
206
+ maxTokensPerRun: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
207
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
208
+ tags: {
209
+ type: ScalarTypeEnum.String_unsecure(),
210
+ isArray: true,
211
+ isOptional: true,
212
+ },
213
+ },
214
+ });
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Agent domain - AI agent configuration and management.
3
+ */
4
+
5
+ // Enums
6
+ export {
7
+ AgentStatusEnum,
8
+ ModelProviderEnum,
9
+ ToolChoiceEnum,
10
+ } from './agent.enum';
11
+
12
+ // Schema models
13
+ export {
14
+ AgentModel,
15
+ AgentSummaryModel,
16
+ AgentToolRefModel,
17
+ AgentWithToolsModel,
18
+ CreateAgentInputModel,
19
+ UpdateAgentInputModel,
20
+ } from './agent.schema';
21
+
22
+ // Contracts
23
+ export {
24
+ CreateAgentCommand,
25
+ UpdateAgentCommand,
26
+ GetAgentQuery,
27
+ ListAgentsQuery,
28
+ AssignToolToAgentCommand,
29
+ RemoveToolFromAgentCommand,
30
+ } from './agent.operation';
31
+
32
+ // Events
33
+ export {
34
+ AgentCreatedEvent,
35
+ AgentUpdatedEvent,
36
+ AgentToolAssignedEvent,
37
+ AgentToolRemovedEvent,
38
+ } from './agent.event';
39
+
40
+ // Entities
41
+ export {
42
+ AgentStatusEntityEnum,
43
+ ModelProviderEntityEnum,
44
+ AgentEntity,
45
+ AgentToolEntity,
46
+ } from './agent.entity';
47
+
48
+ // Presentations
49
+ export {
50
+ AgentListPresentation,
51
+ AgentDetailPresentation,
52
+ AgentConsoleDashboardPresentation,
53
+ } from './agent.presentation';
54
+
55
+ // Handlers
56
+ export {
57
+ mockListAgentsHandler,
58
+ mockGetAgentHandler,
59
+ mockCreateAgentHandler,
60
+ mockUpdateAgentHandler,
61
+ type ListAgentsInput,
62
+ type AgentSummary,
63
+ type ListAgentsOutput,
64
+ type GetAgentInput,
65
+ type AgentToolRef,
66
+ type AgentWithTools,
67
+ } from './agent.handler';
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Agent Console Feature Module Specification
3
+ *
4
+ * Defines the feature module for agent orchestration capabilities.
5
+ */
6
+ import type { FeatureModuleSpec } from '@contractspec/lib.contracts';
7
+
8
+ /**
9
+ * Agent Console feature module that bundles all agent, tool, and run
10
+ * operations, events, and presentations into an installable feature.
11
+ */
12
+ export const AgentConsoleFeature: FeatureModuleSpec = {
13
+ meta: {
14
+ key: 'agent-console',
15
+ version: 1,
16
+ title: 'AI Agent Console',
17
+ description: 'AI agent orchestration with tools, runs, and logs management',
18
+ domain: 'ai-ops',
19
+ owners: ['@agent-console-team'],
20
+ tags: ['ai', 'agents', 'orchestration'],
21
+ stability: 'stable',
22
+ },
23
+
24
+ // All contract operations included in this feature
25
+ operations: [
26
+ // Agent operations
27
+ { key: 'agent-console.agent.create', version: 1 },
28
+ { key: 'agent-console.agent.update', version: 1 },
29
+ { key: 'agent-console.agent.get', version: 1 },
30
+ { key: 'agent-console.agent.list', version: 1 },
31
+ { key: 'agent-console.agent.assignTool', version: 1 },
32
+ { key: 'agent-console.agent.removeTool', version: 1 },
33
+
34
+ // Tool operations
35
+ { key: 'agent.tool.create', version: 1 },
36
+ { key: 'agent.tool.update', version: 1 },
37
+ { key: 'agent.tool.get', version: 1 },
38
+ { key: 'agent.tool.list', version: 1 },
39
+ { key: 'agent.tool.test', version: 1 },
40
+
41
+ // Run operations
42
+ { key: 'agent.run.execute', version: 1 },
43
+ { key: 'agent.run.cancel', version: 1 },
44
+ { key: 'agent.run.get', version: 1 },
45
+ { key: 'agent.run.list', version: 1 },
46
+ { key: 'agent.run.getSteps', version: 1 },
47
+ { key: 'agent.run.getLogs', version: 1 },
48
+ { key: 'agent.run.getMetrics', version: 1 },
49
+ ],
50
+
51
+ // Events emitted by this feature
52
+ events: [
53
+ // Agent events
54
+ { key: 'agent-console.agent.created', version: 1 },
55
+ { key: 'agent-console.agent.updated', version: 1 },
56
+ { key: 'agent-console.agent.toolAssigned', version: 1 },
57
+ { key: 'agent-console.agent.toolRemoved', version: 1 },
58
+
59
+ // Tool events
60
+ { key: 'agent.tool.created', version: 1 },
61
+ { key: 'agent.tool.updated', version: 1 },
62
+ { key: 'agent.tool.statusChanged', version: 1 },
63
+
64
+ // Run events
65
+ { key: 'agent.run.started', version: 1 },
66
+ { key: 'agent.run.completed', version: 1 },
67
+ { key: 'agent.run.failed', version: 1 },
68
+ { key: 'agent.run.cancelled', version: 1 },
69
+ { key: 'agent.run.toolInvoked', version: 1 },
70
+ { key: 'agent.run.toolCompleted', version: 1 },
71
+ { key: 'agent.run.messageGenerated', version: 1 },
72
+ ],
73
+
74
+ // Presentations associated with this feature
75
+ presentations: [
76
+ { key: 'agent-console.dashboard', version: 1 },
77
+ { key: 'agent-console.agent.list', version: 1 },
78
+ { key: 'agent-console.agent.detail', version: 1 },
79
+ { key: 'agent-console.run.list', version: 1 },
80
+ { key: 'agent-console.run.detail', version: 1 },
81
+ { key: 'agent-console.tool.list', version: 1 },
82
+ { key: 'agent-console.tool.detail', version: 1 },
83
+ ],
84
+
85
+ // Link operations to their primary presentations
86
+ opToPresentation: [
87
+ {
88
+ op: { key: 'agent-console.agent.list', version: 1 },
89
+ pres: { key: 'agent-console.agent.list', version: 1 },
90
+ },
91
+ {
92
+ op: { key: 'agent-console.agent.get', version: 1 },
93
+ pres: { key: 'agent-console.agent.detail', version: 1 },
94
+ },
95
+ {
96
+ op: { key: 'agent.run.list', version: 1 },
97
+ pres: { key: 'agent-console.run.list', version: 1 },
98
+ },
99
+ {
100
+ op: { key: 'agent.run.get', version: 1 },
101
+ pres: { key: 'agent-console.run.detail', version: 1 },
102
+ },
103
+ {
104
+ op: { key: 'agent.tool.list', version: 1 },
105
+ pres: { key: 'agent-console.tool.list', version: 1 },
106
+ },
107
+ {
108
+ op: { key: 'agent.tool.get', version: 1 },
109
+ pres: { key: 'agent-console.tool.detail', version: 1 },
110
+ },
111
+ ],
112
+
113
+ // Target requirements for multi-surface rendering
114
+ presentationsTargets: [
115
+ {
116
+ key: 'agent-console.dashboard',
117
+ version: 1,
118
+ targets: ['react', 'markdown'],
119
+ },
120
+ {
121
+ key: 'agent-console.agent.list',
122
+ version: 1,
123
+ targets: ['react', 'markdown', 'application/json'],
124
+ },
125
+ {
126
+ key: 'agent-console.run.list',
127
+ version: 1,
128
+ targets: ['react', 'markdown', 'application/json'],
129
+ },
130
+ {
131
+ key: 'agent-console.tool.list',
132
+ version: 1,
133
+ targets: ['react', 'markdown', 'application/json'],
134
+ },
135
+ ],
136
+
137
+ // Capability requirements
138
+ capabilities: {
139
+ requires: [
140
+ { key: 'identity', version: 1 },
141
+ { key: 'audit-trail', version: 1 },
142
+ { key: 'jobs', version: 1 },
143
+ ],
144
+ provides: [{ key: 'agent', version: 1 }],
145
+ },
146
+ };
@@ -0,0 +1,97 @@
1
+ import type { DocBlock } from '@contractspec/lib.contracts/docs';
2
+ import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
3
+
4
+ const agentConsoleDocBlocks: DocBlock[] = [
5
+ {
6
+ id: 'docs.examples.agent-console.goal',
7
+ title: 'Agent Console — Goal',
8
+ summary: 'AI agent ops console: tools, agents, runs, logs, and metrics.',
9
+ kind: 'goal',
10
+ visibility: 'public',
11
+ route: '/docs/examples/agent-console/goal',
12
+ tags: ['ai', 'agents', 'goal'],
13
+ body: `## Why it matters
14
+ - Provides a regenerable agent operations surface with tool registry and run history.
15
+ - Prevents drift between tool schemas, agent configs, and execution logs.
16
+
17
+ ## Business/Product goal
18
+ - Safely manage tools/agents/runs with auditability and observability.
19
+ - Enable staged rollout of tools and metrics via feature flags.
20
+
21
+ ## Success criteria
22
+ - Tool/agent/run specs regenerate UI/API/events cleanly.
23
+ - Logs/metrics stay aligned and PII is scoped.`,
24
+ },
25
+ {
26
+ id: 'docs.examples.agent-console.usage',
27
+ title: 'Agent Console — Usage',
28
+ summary: 'How to operate, extend, and regenerate the agent console safely.',
29
+ kind: 'usage',
30
+ visibility: 'public',
31
+ route: '/docs/examples/agent-console/usage',
32
+ tags: ['ai', 'agents', 'usage'],
33
+ body: `## Setup
34
+ 1) Seed (if available) or create tools and agents; define run configs.
35
+ 2) Configure Notifications for run completion/failure; Audit for changes.
36
+
37
+ ## Extend & regenerate
38
+ 1) Adjust tool schemas (inputs/outputs), agent configs, run metrics in spec.
39
+ 2) Regenerate to sync UI/API/events/logs; mark PII paths for run payloads.
40
+ 3) Use Feature Flags to gate risky tools or execution policies.
41
+
42
+ ## Guardrails
43
+ - Emit events for run lifecycle; store logs with redaction where needed.
44
+ - Enforce tool input validation; avoid unsafe arbitrary code exec in handlers.
45
+ - Keep tenant/user scoping explicit for ops data.`,
46
+ },
47
+ {
48
+ id: 'docs.examples.agent-console.reference',
49
+ title: 'Agent Console — Reference',
50
+ summary:
51
+ 'Entities, contracts, events, and presentations for the agent console.',
52
+ kind: 'reference',
53
+ visibility: 'public',
54
+ route: '/docs/examples/agent-console',
55
+ tags: ['ai', 'agents', 'reference'],
56
+ body: `## Entities
57
+ - Tool, Agent, AgentTool, Run, RunStep, RunLog, RunMetric.
58
+
59
+ ## Contracts
60
+ - tool/create, agent/create, agent/execute, run/get, run/logs, run/metrics.
61
+
62
+ ## Events
63
+ - tool.created, agent.created, run.started/completed/failed, tool.invoked.
64
+
65
+ ## Presentations
66
+ - Tool registry, agent list/detail, run list/detail, metrics dashboards.
67
+
68
+ ## Notes
69
+ - Keep tool schemas explicit; enforce validation in spec.
70
+ - Use Audit Trail for agent/run changes; Notifications for run outcomes.`,
71
+ },
72
+ {
73
+ id: 'docs.examples.agent-console.constraints',
74
+ title: 'Agent Console — Constraints & Safety',
75
+ summary:
76
+ 'Internal guardrails for tool/agent/run safety, PII, and regeneration.',
77
+ kind: 'reference',
78
+ visibility: 'internal',
79
+ route: '/docs/examples/agent-console/constraints',
80
+ tags: ['ai', 'agents', 'constraints', 'internal'],
81
+ body: `## Constraints
82
+ - Tool schemas (inputs/outputs) must be explicit in spec; no arbitrary untyped payloads.
83
+ - Events to emit: tool.created, agent.created, run.started/completed/failed, tool.invoked.
84
+ - Regeneration must not loosen execution policies or logging without explicit spec diff.
85
+
86
+ ## Safety & PII
87
+ - Mark PII in run payloads/logs; redact in markdown/JSON targets.
88
+ - Avoid exposing raw tool outputs to MCP/web without policy checks.
89
+
90
+ ## Verification
91
+ - Add fixtures for tool schema changes and run lifecycle.
92
+ - Ensure Audit/Notifications remain wired for runs; metrics collection unchanged.
93
+ - Use Feature Flags to gate risky tools; default safe/off.`,
94
+ },
95
+ ];
96
+
97
+ registerDocBlocks(agentConsoleDocBlocks);
@@ -0,0 +1 @@
1
+ import './agent-console.docblock';
package/src/example.ts ADDED
@@ -0,0 +1,34 @@
1
+ const example = {
2
+ id: 'agent-console',
3
+ title: 'Agent Console',
4
+ summary:
5
+ 'AI agent ops console: tools, agents, runs, logs, and metrics (spec-first, regenerable).',
6
+ tags: ['ai', 'agents', 'tools', 'orchestration'],
7
+ kind: 'template',
8
+ visibility: 'public',
9
+ docs: {
10
+ rootDocId: 'docs.examples.agent-console.reference',
11
+ goalDocId: 'docs.examples.agent-console.goal',
12
+ usageDocId: 'docs.examples.agent-console.usage',
13
+ constraintsDocId: 'docs.examples.agent-console.constraints',
14
+ },
15
+ entrypoints: {
16
+ packageName: '@contractspec/example.agent-console',
17
+ feature: './feature',
18
+ contracts: './contracts',
19
+ presentations: './presentations',
20
+ handlers: './handlers',
21
+ docs: './docs',
22
+ },
23
+ surfaces: {
24
+ templates: true,
25
+ sandbox: {
26
+ enabled: true,
27
+ modes: ['playground', 'specs', 'builder', 'markdown', 'evolution'],
28
+ },
29
+ studio: { enabled: true, installable: true },
30
+ mcp: { enabled: true },
31
+ },
32
+ } as const;
33
+
34
+ export default example;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Agent Console Handlers - re-exports from domain modules for backward compatibility.
3
+ */
4
+
5
+ // Agent handlers and types
6
+ export {
7
+ mockCreateAgentHandler,
8
+ mockGetAgentHandler,
9
+ mockListAgentsHandler,
10
+ type AgentSummary,
11
+ } from '../agent/agent.handler';
12
+
13
+ // Run handlers and types
14
+ export {
15
+ mockExecuteAgentHandler,
16
+ mockGetRunHandler,
17
+ mockListRunsHandler,
18
+ type RunSummary,
19
+ } from '../run/run.handler';
20
+
21
+ // Tool handlers and types
22
+ export {
23
+ mockCreateToolHandler,
24
+ mockGetToolHandler,
25
+ mockListToolsHandler,
26
+ type ToolSummary,
27
+ } from '../tool/tool.handler';
package/src/index.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Agent Console Example
3
+ *
4
+ * A ContractSpec example demonstrating AI agent orchestration with tools, runs, and logs.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import {
9
+ * ToolEntity,
10
+ * AgentEntity,
11
+ * RunEntity,
12
+ * CreateToolCommand,
13
+ * ExecuteAgentCommand
14
+ * } from '@contractspec/example.agent-console';
15
+ * ```
16
+ */
17
+
18
+ // Domain exports
19
+ export * from './agent';
20
+ export * from './run';
21
+ export * from './tool';
22
+ export * from './shared';
23
+
24
+ // Feature spec export
25
+ export * from './agent.feature';
26
+ export { default as example } from './example';
27
+ import './docs';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Agent Console Presentations - re-exports from domain modules for backward compatibility.
3
+ */
4
+
5
+ // Agent presentations
6
+ export {
7
+ AgentListPresentation,
8
+ AgentDetailPresentation,
9
+ AgentConsoleDashboardPresentation,
10
+ } from '../agent/agent.presentation';
11
+
12
+ // Run presentations
13
+ export {
14
+ RunListPresentation,
15
+ RunDetailPresentation,
16
+ } from '../run/run.presentation';
17
+ // Alias: RunMetricsPresentation -> RunDetailPresentation (for backward compatibility)
18
+ export { RunDetailPresentation as RunMetricsPresentation } from '../run/run.presentation';
19
+
20
+ // Tool presentations
21
+ export {
22
+ ToolListPresentation,
23
+ ToolDetailPresentation,
24
+ } from '../tool/tool.presentation';
25
+ // Alias: ToolRegistryPresentation -> ToolListPresentation (for backward compatibility)
26
+ export { ToolListPresentation as ToolRegistryPresentation } from '../tool/tool.presentation';