@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,169 @@
1
+ import { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';
2
+ import { RunStatusEnum, RunStepTypeEnum, LogLevelEnum } from './run.enum';
3
+
4
+ /**
5
+ * Input data for agent execution.
6
+ */
7
+ export const RunInputModel = defineSchemaModel({
8
+ name: 'RunInput',
9
+ description: 'Input data for agent execution',
10
+ fields: {
11
+ message: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
12
+ context: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
13
+ },
14
+ });
15
+
16
+ /**
17
+ * Individual step within a run.
18
+ */
19
+ export const RunStepModel = defineSchemaModel({
20
+ name: 'RunStep',
21
+ description: 'Individual step within a run',
22
+ fields: {
23
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ stepNumber: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
25
+ type: { type: RunStepTypeEnum, isOptional: false },
26
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
27
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
28
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
29
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
30
+ status: { type: RunStatusEnum, isOptional: false },
31
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
32
+ tokensUsed: {
33
+ type: ScalarTypeEnum.Int_unsecure(),
34
+ isOptional: false,
35
+ defaultValue: 0,
36
+ },
37
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
38
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
39
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
40
+ },
41
+ });
42
+
43
+ /**
44
+ * Execution log entry.
45
+ */
46
+ export const RunLogModel = defineSchemaModel({
47
+ name: 'RunLog',
48
+ description: 'Execution log entry',
49
+ fields: {
50
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
52
+ level: { type: LogLevelEnum, isOptional: false },
53
+ message: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
54
+ data: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
55
+ source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
56
+ traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
57
+ spanId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
58
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },
59
+ },
60
+ });
61
+
62
+ /**
63
+ * Agent reference in a run.
64
+ */
65
+ export const RunAgentRefModel = defineSchemaModel({
66
+ name: 'RunAgentRef',
67
+ description: 'Agent reference in a run',
68
+ fields: {
69
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
70
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
71
+ modelProvider: {
72
+ type: ScalarTypeEnum.String_unsecure(),
73
+ isOptional: false,
74
+ },
75
+ modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
76
+ },
77
+ });
78
+
79
+ /**
80
+ * Agent execution instance.
81
+ */
82
+ export const RunModel = defineSchemaModel({
83
+ name: 'Run',
84
+ description: 'Agent execution instance',
85
+ fields: {
86
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
87
+ organizationId: {
88
+ type: ScalarTypeEnum.String_unsecure(),
89
+ isOptional: false,
90
+ },
91
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
92
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
93
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
94
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
95
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
96
+ status: { type: RunStatusEnum, isOptional: false },
97
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
98
+ errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
99
+ totalTokens: {
100
+ type: ScalarTypeEnum.Int_unsecure(),
101
+ isOptional: false,
102
+ defaultValue: 0,
103
+ },
104
+ promptTokens: {
105
+ type: ScalarTypeEnum.Int_unsecure(),
106
+ isOptional: false,
107
+ defaultValue: 0,
108
+ },
109
+ completionTokens: {
110
+ type: ScalarTypeEnum.Int_unsecure(),
111
+ isOptional: false,
112
+ defaultValue: 0,
113
+ },
114
+ totalIterations: {
115
+ type: ScalarTypeEnum.Int_unsecure(),
116
+ isOptional: false,
117
+ defaultValue: 0,
118
+ },
119
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
120
+ estimatedCostUsd: {
121
+ type: ScalarTypeEnum.Float_unsecure(),
122
+ isOptional: true,
123
+ },
124
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
125
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
126
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
127
+ metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
128
+ steps: { type: RunStepModel, isArray: true, isOptional: true },
129
+ logs: { type: RunLogModel, isArray: true, isOptional: true },
130
+ agent: { type: RunAgentRefModel, isOptional: true },
131
+ },
132
+ });
133
+
134
+ /**
135
+ * Summary of a run for list views.
136
+ */
137
+ export const RunSummaryModel = defineSchemaModel({
138
+ name: 'RunSummary',
139
+ description: 'Summary of a run for list views',
140
+ fields: {
141
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
142
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
143
+ agentName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
144
+ status: { type: RunStatusEnum, isOptional: false },
145
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
146
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
147
+ estimatedCostUsd: {
148
+ type: ScalarTypeEnum.Float_unsecure(),
149
+ isOptional: true,
150
+ },
151
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
152
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
153
+ },
154
+ });
155
+
156
+ /**
157
+ * Timeline data point for metrics.
158
+ */
159
+ export const TimelineDataPointModel = defineSchemaModel({
160
+ name: 'TimelineDataPoint',
161
+ description: 'Timeline data point for metrics',
162
+ fields: {
163
+ period: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
164
+ runs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
165
+ tokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
166
+ costUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
167
+ avgDurationMs: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
168
+ },
169
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Shared utilities and mock data.
3
+ */
4
+ export { MOCK_AGENTS } from './mock-agents';
5
+ export { MOCK_TOOLS } from './mock-tools';
6
+ export { MOCK_RUNS } from './mock-runs';
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Mock agent data for testing and demos.
3
+ */
4
+ export const MOCK_AGENTS = [
5
+ {
6
+ id: 'agent-1',
7
+ organizationId: 'demo-org',
8
+ name: 'Customer Support Bot',
9
+ slug: 'customer-support-bot',
10
+ description: 'Handles tier-1 customer inquiries and routes complex issues.',
11
+ status: 'ACTIVE' as const,
12
+ modelProvider: 'OPENAI' as const,
13
+ modelName: 'gpt-4o-mini',
14
+ modelConfig: { temperature: 0.7 },
15
+ systemPrompt: 'You are a helpful customer support assistant.',
16
+ toolChoice: 'auto' as const,
17
+ maxIterations: 10,
18
+ timeoutMs: 120000,
19
+ version: '1.0.0',
20
+ tags: ['support', 'tier-1'],
21
+ createdAt: new Date('2024-01-15T10:00:00Z'),
22
+ updatedAt: new Date('2024-03-20T14:30:00Z'),
23
+ },
24
+ {
25
+ id: 'agent-2',
26
+ organizationId: 'demo-org',
27
+ name: 'Code Review Assistant',
28
+ slug: 'code-review-assistant',
29
+ description: 'Reviews pull requests and provides actionable feedback.',
30
+ status: 'ACTIVE' as const,
31
+ modelProvider: 'ANTHROPIC' as const,
32
+ modelName: 'claude-sonnet-4-20250514',
33
+ modelConfig: { temperature: 0.3 },
34
+ systemPrompt: 'You are a code review expert.',
35
+ toolChoice: 'auto' as const,
36
+ maxIterations: 15,
37
+ timeoutMs: 180000,
38
+ version: '2.1.0',
39
+ tags: ['code', 'review', 'dev'],
40
+ createdAt: new Date('2024-02-10T09:00:00Z'),
41
+ updatedAt: new Date('2024-04-05T11:15:00Z'),
42
+ },
43
+ {
44
+ id: 'agent-3',
45
+ organizationId: 'demo-org',
46
+ name: 'Data Analyst',
47
+ slug: 'data-analyst',
48
+ description: 'Queries databases and generates insights from data.',
49
+ status: 'PAUSED' as const,
50
+ modelProvider: 'OPENAI' as const,
51
+ modelName: 'gpt-4o',
52
+ modelConfig: { temperature: 0.5 },
53
+ systemPrompt: 'You are a data analyst expert in SQL and analytics.',
54
+ toolChoice: 'required' as const,
55
+ maxIterations: 20,
56
+ timeoutMs: 300000,
57
+ version: '1.2.0',
58
+ tags: ['data', 'analytics', 'sql'],
59
+ createdAt: new Date('2024-03-01T08:00:00Z'),
60
+ updatedAt: new Date('2024-04-10T16:45:00Z'),
61
+ },
62
+ {
63
+ id: 'agent-4',
64
+ organizationId: 'demo-org',
65
+ name: 'Meeting Scheduler',
66
+ slug: 'meeting-scheduler',
67
+ description: 'Schedules meetings and manages calendar conflicts.',
68
+ status: 'DRAFT' as const,
69
+ modelProvider: 'GOOGLE' as const,
70
+ modelName: 'gemini-2.0-flash',
71
+ modelConfig: { temperature: 0.2 },
72
+ systemPrompt: 'You help schedule and organize meetings efficiently.',
73
+ toolChoice: 'auto' as const,
74
+ maxIterations: 5,
75
+ timeoutMs: 60000,
76
+ version: '0.1.0',
77
+ tags: ['calendar', 'scheduling'],
78
+ createdAt: new Date('2024-04-01T12:00:00Z'),
79
+ updatedAt: new Date('2024-04-01T12:00:00Z'),
80
+ },
81
+ ];
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Mock run data for testing and demos.
3
+ */
4
+ export const MOCK_RUNS = [
5
+ {
6
+ id: 'run-1',
7
+ organizationId: 'demo-org',
8
+ agentId: 'agent-1',
9
+ agentName: 'Customer Support Bot',
10
+ userId: 'user-1',
11
+ sessionId: 'session-1',
12
+ input: { message: 'How do I reset my password?', context: {} },
13
+ output: { response: 'You can reset your password by clicking...' },
14
+ status: 'COMPLETED' as const,
15
+ totalTokens: 1250,
16
+ promptTokens: 800,
17
+ completionTokens: 450,
18
+ totalIterations: 3,
19
+ durationMs: 4500,
20
+ estimatedCostUsd: 0.0025,
21
+ queuedAt: new Date('2024-04-15T10:00:00Z'),
22
+ startedAt: new Date('2024-04-15T10:00:01Z'),
23
+ completedAt: new Date('2024-04-15T10:00:05Z'),
24
+ steps: [],
25
+ logs: [],
26
+ },
27
+ {
28
+ id: 'run-2',
29
+ organizationId: 'demo-org',
30
+ agentId: 'agent-2',
31
+ agentName: 'Code Review Assistant',
32
+ userId: 'user-2',
33
+ input: { message: 'Review PR #123', context: { prNumber: 123 } },
34
+ status: 'IN_PROGRESS' as const,
35
+ totalTokens: 3500,
36
+ promptTokens: 3000,
37
+ completionTokens: 500,
38
+ totalIterations: 5,
39
+ queuedAt: new Date('2024-04-15T10:30:00Z'),
40
+ startedAt: new Date('2024-04-15T10:30:02Z'),
41
+ steps: [],
42
+ logs: [],
43
+ },
44
+ {
45
+ id: 'run-3',
46
+ organizationId: 'demo-org',
47
+ agentId: 'agent-1',
48
+ agentName: 'Customer Support Bot',
49
+ userId: 'user-1',
50
+ input: { message: 'What are your business hours?' },
51
+ output: { response: 'Our business hours are 9 AM to 5 PM EST...' },
52
+ status: 'COMPLETED' as const,
53
+ totalTokens: 800,
54
+ promptTokens: 500,
55
+ completionTokens: 300,
56
+ totalIterations: 2,
57
+ durationMs: 2100,
58
+ estimatedCostUsd: 0.0012,
59
+ queuedAt: new Date('2024-04-15T09:00:00Z'),
60
+ startedAt: new Date('2024-04-15T09:00:01Z'),
61
+ completedAt: new Date('2024-04-15T09:00:03Z'),
62
+ steps: [],
63
+ logs: [],
64
+ },
65
+ {
66
+ id: 'run-4',
67
+ organizationId: 'demo-org',
68
+ agentId: 'agent-3',
69
+ agentName: 'Data Analyst',
70
+ userId: 'user-3',
71
+ input: { message: 'Generate sales report for Q1' },
72
+ status: 'FAILED' as const,
73
+ errorMessage: 'Database connection timeout',
74
+ errorCode: 'DB_TIMEOUT',
75
+ totalTokens: 2000,
76
+ promptTokens: 1500,
77
+ completionTokens: 500,
78
+ totalIterations: 8,
79
+ durationMs: 45000,
80
+ queuedAt: new Date('2024-04-14T15:00:00Z'),
81
+ startedAt: new Date('2024-04-14T15:00:05Z'),
82
+ completedAt: new Date('2024-04-14T15:00:50Z'),
83
+ steps: [],
84
+ logs: [],
85
+ },
86
+ {
87
+ id: 'run-5',
88
+ organizationId: 'demo-org',
89
+ agentId: 'agent-2',
90
+ agentName: 'Code Review Assistant',
91
+ userId: 'user-2',
92
+ input: { message: 'Review PR #120' },
93
+ output: { response: 'Code review complete. 3 suggestions...' },
94
+ status: 'COMPLETED' as const,
95
+ totalTokens: 5200,
96
+ promptTokens: 4000,
97
+ completionTokens: 1200,
98
+ totalIterations: 7,
99
+ durationMs: 15000,
100
+ estimatedCostUsd: 0.0156,
101
+ queuedAt: new Date('2024-04-14T11:00:00Z'),
102
+ startedAt: new Date('2024-04-14T11:00:03Z'),
103
+ completedAt: new Date('2024-04-14T11:00:18Z'),
104
+ steps: [],
105
+ logs: [],
106
+ },
107
+ ];
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Mock tool data for testing and demos.
3
+ */
4
+ export const MOCK_TOOLS = [
5
+ {
6
+ id: 'tool-1',
7
+ organizationId: 'demo-org',
8
+ name: 'Web Search',
9
+ slug: 'web-search',
10
+ description: 'Search the web for real-time information using Brave API.',
11
+ category: 'RETRIEVAL' as const,
12
+ status: 'ACTIVE' as const,
13
+ parametersSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ query: { type: 'string', description: 'Search query' },
17
+ numResults: { type: 'number', default: 10 },
18
+ },
19
+ required: ['query'],
20
+ },
21
+ outputSchema: { type: 'array', items: { type: 'object' } },
22
+ implementationType: 'http' as const,
23
+ implementationConfig: {
24
+ url: 'https://api.brave.com/search',
25
+ method: 'GET',
26
+ },
27
+ maxInvocationsPerMinute: 60,
28
+ timeoutMs: 30000,
29
+ version: '1.0.0',
30
+ tags: ['search', 'web'],
31
+ createdAt: new Date('2024-01-01T00:00:00Z'),
32
+ updatedAt: new Date('2024-02-15T10:00:00Z'),
33
+ },
34
+ {
35
+ id: 'tool-2',
36
+ organizationId: 'demo-org',
37
+ name: 'SQL Query',
38
+ slug: 'sql-query',
39
+ description: 'Execute read-only SQL queries against the data warehouse.',
40
+ category: 'RETRIEVAL' as const,
41
+ status: 'ACTIVE' as const,
42
+ parametersSchema: {
43
+ type: 'object',
44
+ properties: {
45
+ query: { type: 'string', description: 'SQL query' },
46
+ maxRows: { type: 'number', default: 100 },
47
+ },
48
+ required: ['query'],
49
+ },
50
+ outputSchema: { type: 'object' },
51
+ implementationType: 'function' as const,
52
+ implementationConfig: { handler: 'executeSqlQuery' },
53
+ maxInvocationsPerMinute: 30,
54
+ timeoutMs: 60000,
55
+ version: '1.1.0',
56
+ tags: ['sql', 'database'],
57
+ createdAt: new Date('2024-01-05T00:00:00Z'),
58
+ updatedAt: new Date('2024-03-10T14:00:00Z'),
59
+ },
60
+ {
61
+ id: 'tool-3',
62
+ organizationId: 'demo-org',
63
+ name: 'Email Sender',
64
+ slug: 'email-sender',
65
+ description: 'Send emails via SMTP or API.',
66
+ category: 'COMMUNICATION' as const,
67
+ status: 'ACTIVE' as const,
68
+ parametersSchema: {
69
+ type: 'object',
70
+ properties: {
71
+ to: { type: 'string' },
72
+ subject: { type: 'string' },
73
+ body: { type: 'string' },
74
+ },
75
+ required: ['to', 'subject', 'body'],
76
+ },
77
+ implementationType: 'http' as const,
78
+ implementationConfig: { url: '/api/send-email', method: 'POST' },
79
+ maxInvocationsPerMinute: 10,
80
+ timeoutMs: 30000,
81
+ version: '1.0.0',
82
+ tags: ['email', 'communication'],
83
+ createdAt: new Date('2024-02-01T00:00:00Z'),
84
+ updatedAt: new Date('2024-02-01T00:00:00Z'),
85
+ },
86
+ {
87
+ id: 'tool-4',
88
+ organizationId: 'demo-org',
89
+ name: 'GitHub Integration',
90
+ slug: 'github-integration',
91
+ description: 'Interact with GitHub repositories, PRs, and issues.',
92
+ category: 'INTEGRATION' as const,
93
+ status: 'ACTIVE' as const,
94
+ parametersSchema: {
95
+ type: 'object',
96
+ properties: {
97
+ action: {
98
+ type: 'string',
99
+ enum: ['list_prs', 'get_pr', 'create_comment'],
100
+ },
101
+ repo: { type: 'string' },
102
+ params: { type: 'object' },
103
+ },
104
+ required: ['action', 'repo'],
105
+ },
106
+ implementationType: 'http' as const,
107
+ implementationConfig: { url: 'https://api.github.com', auth: 'token' },
108
+ maxInvocationsPerMinute: 100,
109
+ timeoutMs: 15000,
110
+ version: '2.0.0',
111
+ tags: ['github', 'integration', 'code'],
112
+ createdAt: new Date('2024-02-20T00:00:00Z'),
113
+ updatedAt: new Date('2024-04-01T09:00:00Z'),
114
+ },
115
+ {
116
+ id: 'tool-5',
117
+ organizationId: 'demo-org',
118
+ name: 'Calculator',
119
+ slug: 'calculator',
120
+ description: 'Perform mathematical calculations.',
121
+ category: 'COMPUTATION' as const,
122
+ status: 'ACTIVE' as const,
123
+ parametersSchema: {
124
+ type: 'object',
125
+ properties: {
126
+ expression: {
127
+ type: 'string',
128
+ description: 'Math expression to evaluate',
129
+ },
130
+ },
131
+ required: ['expression'],
132
+ },
133
+ outputSchema: {
134
+ type: 'object',
135
+ properties: { result: { type: 'number' } },
136
+ },
137
+ implementationType: 'function' as const,
138
+ implementationConfig: { handler: 'evaluateMath' },
139
+ timeoutMs: 5000,
140
+ version: '1.0.0',
141
+ tags: ['math', 'utility'],
142
+ createdAt: new Date('2024-01-10T00:00:00Z'),
143
+ updatedAt: new Date('2024-01-10T00:00:00Z'),
144
+ },
145
+ ];
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Tool domain - AI tool definitions and management.
3
+ */
4
+
5
+ // Enums
6
+ export {
7
+ ToolCategoryEnum,
8
+ ToolStatusEnum,
9
+ ImplementationTypeEnum,
10
+ } from './tool.enum';
11
+
12
+ // Schema models
13
+ export {
14
+ ToolModel,
15
+ ToolSummaryModel,
16
+ CreateToolInputModel,
17
+ UpdateToolInputModel,
18
+ } from './tool.schema';
19
+
20
+ // Contracts
21
+ export {
22
+ CreateToolCommand,
23
+ UpdateToolCommand,
24
+ GetToolQuery,
25
+ ListToolsQuery,
26
+ TestToolCommand,
27
+ } from './tool.operation';
28
+
29
+ // Events
30
+ export {
31
+ ToolCreatedEvent,
32
+ ToolUpdatedEvent,
33
+ ToolStatusChangedEvent,
34
+ } from './tool.event';
35
+
36
+ // Entities
37
+ export {
38
+ ToolCategoryEntityEnum,
39
+ ToolStatusEntityEnum,
40
+ ImplementationTypeEntityEnum,
41
+ ToolEntity,
42
+ } from './tool.entity';
43
+
44
+ // Presentations
45
+ export {
46
+ ToolListPresentation,
47
+ ToolDetailPresentation,
48
+ } from './tool.presentation';
49
+
50
+ // Handlers
51
+ export {
52
+ mockListToolsHandler,
53
+ mockGetToolHandler,
54
+ mockCreateToolHandler,
55
+ mockUpdateToolHandler,
56
+ mockTestToolHandler,
57
+ type ListToolsInput,
58
+ type ToolSummary,
59
+ type ListToolsOutput,
60
+ } from './tool.handler';
@@ -0,0 +1,99 @@
1
+ import {
2
+ defineEntity,
3
+ defineEntityEnum,
4
+ field,
5
+ index,
6
+ } from '@contractspec/lib.schema';
7
+
8
+ /**
9
+ * Tool category enum for entities.
10
+ */
11
+ export const ToolCategoryEntityEnum = defineEntityEnum({
12
+ name: 'ToolCategory',
13
+ values: [
14
+ 'RETRIEVAL',
15
+ 'COMPUTATION',
16
+ 'COMMUNICATION',
17
+ 'INTEGRATION',
18
+ 'UTILITY',
19
+ 'CUSTOM',
20
+ ],
21
+ description: 'Category of tool',
22
+ });
23
+
24
+ /**
25
+ * Tool status enum for entities.
26
+ */
27
+ export const ToolStatusEntityEnum = defineEntityEnum({
28
+ name: 'ToolStatus',
29
+ values: ['DRAFT', 'ACTIVE', 'DEPRECATED', 'DISABLED'],
30
+ description: 'Status of tool',
31
+ });
32
+
33
+ /**
34
+ * Implementation type enum for entities.
35
+ */
36
+ export const ImplementationTypeEntityEnum = defineEntityEnum({
37
+ name: 'ImplementationType',
38
+ values: ['http', 'function', 'workflow'],
39
+ description: 'How the tool is implemented',
40
+ });
41
+
42
+ /**
43
+ * Tool entity - Represents an AI tool definition.
44
+ */
45
+ export const ToolEntity = defineEntity({
46
+ name: 'Tool',
47
+ schema: 'agent_console',
48
+ description: 'An AI tool that can be used by agents.',
49
+ fields: {
50
+ id: field.id(),
51
+ organizationId: field.string({
52
+ description: 'Organization that owns this tool',
53
+ }),
54
+ name: field.string({ description: 'Tool name' }),
55
+ slug: field.string({ description: 'URL-safe identifier' }),
56
+ description: field.string({ description: 'Tool description' }),
57
+ category: field.enum('ToolCategory', { default: 'CUSTOM' }),
58
+ status: field.enum('ToolStatus', { default: 'DRAFT' }),
59
+ parametersSchema: field.json({
60
+ description: 'JSON Schema for tool parameters',
61
+ }),
62
+ outputSchema: field.json({
63
+ isOptional: true,
64
+ description: 'JSON Schema for tool output',
65
+ }),
66
+ implementationType: field.enum('ImplementationType'),
67
+ implementationConfig: field.json({
68
+ description: 'Implementation configuration',
69
+ }),
70
+ maxInvocationsPerMinute: field.int({
71
+ isOptional: true,
72
+ description: 'Rate limit',
73
+ }),
74
+ timeoutMs: field.int({ default: 30000, description: 'Execution timeout' }),
75
+ version: field.string({ default: '1.0.0', description: 'Tool version' }),
76
+ tags: field.string({
77
+ isArray: true,
78
+ isOptional: true,
79
+ description: 'Tags for categorization',
80
+ }),
81
+ createdAt: field.createdAt(),
82
+ updatedAt: field.updatedAt(),
83
+ createdById: field.string({
84
+ isOptional: true,
85
+ description: 'User who created this tool',
86
+ }),
87
+ agents: field.hasMany('Agent', { description: 'Agents using this tool' }),
88
+ },
89
+ indexes: [
90
+ index.unique(['organizationId', 'slug']),
91
+ index.on(['organizationId', 'category']),
92
+ index.on(['organizationId', 'status']),
93
+ ],
94
+ enums: [
95
+ ToolCategoryEntityEnum,
96
+ ToolStatusEntityEnum,
97
+ ImplementationTypeEntityEnum,
98
+ ],
99
+ });
@@ -0,0 +1,32 @@
1
+ import { defineEnum } from '@contractspec/lib.schema';
2
+
3
+ /**
4
+ * Tool category enum.
5
+ */
6
+ export const ToolCategoryEnum = defineEnum('ToolCategory', [
7
+ 'RETRIEVAL',
8
+ 'COMPUTATION',
9
+ 'COMMUNICATION',
10
+ 'INTEGRATION',
11
+ 'UTILITY',
12
+ 'CUSTOM',
13
+ ]);
14
+
15
+ /**
16
+ * Tool status enum.
17
+ */
18
+ export const ToolStatusEnum = defineEnum('ToolStatus', [
19
+ 'DRAFT',
20
+ 'ACTIVE',
21
+ 'DEPRECATED',
22
+ 'DISABLED',
23
+ ]);
24
+
25
+ /**
26
+ * Implementation type enum.
27
+ */
28
+ export const ImplementationTypeEnum = defineEnum('ImplementationType', [
29
+ 'http',
30
+ 'function',
31
+ 'workflow',
32
+ ]);