@lssm/example.agent-console 0.0.0-canary-20251206160926

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 (175) hide show
  1. package/.turbo/turbo-build.log +202 -0
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +83 -0
  4. package/dist/contracts/agent.d.ts +886 -0
  5. package/dist/contracts/agent.js +1 -0
  6. package/dist/contracts/index.d.ts +4 -0
  7. package/dist/contracts/index.js +1 -0
  8. package/dist/contracts/run.d.ts +1106 -0
  9. package/dist/contracts/run.js +1 -0
  10. package/dist/contracts/tool.d.ts +607 -0
  11. package/dist/contracts/tool.js +1 -0
  12. package/dist/entities/agent.d.ts +54 -0
  13. package/dist/entities/agent.js +1 -0
  14. package/dist/entities/index.d.ts +4 -0
  15. package/dist/entities/index.js +1 -0
  16. package/dist/entities/log.d.ts +31 -0
  17. package/dist/entities/log.js +1 -0
  18. package/dist/entities/run.d.ts +85 -0
  19. package/dist/entities/run.js +1 -0
  20. package/dist/entities/tool.d.ts +36 -0
  21. package/dist/entities/tool.js +1 -0
  22. package/dist/events.d.ts +965 -0
  23. package/dist/events.js +1 -0
  24. package/dist/feature.d.ts +11 -0
  25. package/dist/feature.js +1 -0
  26. package/dist/handlers/agent.handlers.d.ts +99 -0
  27. package/dist/handlers/agent.handlers.js +1 -0
  28. package/dist/handlers/index.d.ts +5 -0
  29. package/dist/handlers/index.js +1 -0
  30. package/dist/handlers/mock-data.d.ts +533 -0
  31. package/dist/handlers/mock-data.js +1 -0
  32. package/dist/handlers/run.handlers.d.ts +145 -0
  33. package/dist/handlers/run.handlers.js +1 -0
  34. package/dist/handlers/tool.handlers.d.ts +86 -0
  35. package/dist/handlers/tool.handlers.js +1 -0
  36. package/dist/index.d.ts +18 -0
  37. package/dist/index.js +1 -0
  38. package/dist/libs/contracts/dist/capabilities/openbanking.js +1 -0
  39. package/dist/libs/contracts/dist/client/index.js +1 -0
  40. package/dist/libs/contracts/dist/client/react/feature-render.js +1 -0
  41. package/dist/libs/contracts/dist/client/react/form-render.js +1 -0
  42. package/dist/libs/contracts/dist/client/react/index.js +1 -0
  43. package/dist/libs/contracts/dist/events.js +1 -0
  44. package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
  45. package/dist/libs/contracts/dist/graphql-federation/dist/index.js +1 -0
  46. package/dist/libs/contracts/dist/index.js +1 -0
  47. package/dist/libs/contracts/dist/install.js +1 -0
  48. package/dist/libs/contracts/dist/integrations/contracts.js +1 -0
  49. package/dist/libs/contracts/dist/integrations/index.js +1 -0
  50. package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +1 -0
  51. package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +1 -0
  52. package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +1 -0
  53. package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +1 -0
  54. package/dist/libs/contracts/dist/integrations/openbanking/models.js +1 -0
  55. package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +1 -0
  56. package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +1 -0
  57. package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +1 -0
  58. package/dist/libs/contracts/dist/integrations/providers/gmail.js +1 -0
  59. package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +1 -0
  60. package/dist/libs/contracts/dist/integrations/providers/impls/elevenlabs-voice.js +1 -0
  61. package/dist/libs/contracts/dist/integrations/providers/impls/gcs-storage.js +1 -0
  62. package/dist/libs/contracts/dist/integrations/providers/impls/gmail-inbound.js +1 -0
  63. package/dist/libs/contracts/dist/integrations/providers/impls/gmail-outbound.js +1 -0
  64. package/dist/libs/contracts/dist/integrations/providers/impls/google-calendar.js +1 -0
  65. package/dist/libs/contracts/dist/integrations/providers/impls/index.js +1 -0
  66. package/dist/libs/contracts/dist/integrations/providers/impls/mistral-embedding.js +1 -0
  67. package/dist/libs/contracts/dist/integrations/providers/impls/mistral-llm.js +1 -0
  68. package/dist/libs/contracts/dist/integrations/providers/impls/postmark-email.js +1 -0
  69. package/dist/libs/contracts/dist/integrations/providers/impls/powens-client.js +1 -0
  70. package/dist/libs/contracts/dist/integrations/providers/impls/powens-openbanking.js +1 -0
  71. package/dist/libs/contracts/dist/integrations/providers/impls/provider-factory.js +1 -0
  72. package/dist/libs/contracts/dist/integrations/providers/impls/qdrant-vector.js +1 -0
  73. package/dist/libs/contracts/dist/integrations/providers/impls/stripe-payments.js +1 -0
  74. package/dist/libs/contracts/dist/integrations/providers/impls/twilio-sms.js +1 -0
  75. package/dist/libs/contracts/dist/integrations/providers/index.js +1 -0
  76. package/dist/libs/contracts/dist/integrations/providers/mistral.js +1 -0
  77. package/dist/libs/contracts/dist/integrations/providers/postmark.js +1 -0
  78. package/dist/libs/contracts/dist/integrations/providers/powens.js +1 -0
  79. package/dist/libs/contracts/dist/integrations/providers/qdrant.js +1 -0
  80. package/dist/libs/contracts/dist/integrations/providers/stripe.js +1 -0
  81. package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +1 -0
  82. package/dist/libs/contracts/dist/integrations/runtime.js +1 -0
  83. package/dist/libs/contracts/dist/integrations/secrets/env-secret-provider.js +1 -0
  84. package/dist/libs/contracts/dist/integrations/secrets/gcp-secret-manager.js +1 -0
  85. package/dist/libs/contracts/dist/integrations/secrets/index.js +1 -0
  86. package/dist/libs/contracts/dist/integrations/secrets/manager.js +1 -0
  87. package/dist/libs/contracts/dist/integrations/secrets/provider.js +1 -0
  88. package/dist/libs/contracts/dist/jsonschema.js +1 -0
  89. package/dist/libs/contracts/dist/knowledge/contracts.js +1 -0
  90. package/dist/libs/contracts/dist/knowledge/index.js +1 -0
  91. package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +1 -0
  92. package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +1 -0
  93. package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +1 -0
  94. package/dist/libs/contracts/dist/knowledge/spaces/index.js +1 -0
  95. package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +1 -0
  96. package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +1 -0
  97. package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +1 -0
  98. package/dist/libs/contracts/dist/onboarding-base.js +1 -0
  99. package/dist/libs/contracts/dist/ownership.js +1 -0
  100. package/dist/libs/contracts/dist/presentations.js +1 -0
  101. package/dist/libs/contracts/dist/presentations.v2.js +1 -0
  102. package/dist/libs/contracts/dist/prompt.js +1 -0
  103. package/dist/libs/contracts/dist/promptRegistry.js +1 -0
  104. package/dist/libs/contracts/dist/regenerator/index.js +1 -0
  105. package/dist/libs/contracts/dist/regenerator/service.js +1 -0
  106. package/dist/libs/contracts/dist/registry.js +1 -0
  107. package/dist/libs/contracts/dist/resources.js +1 -0
  108. package/dist/libs/contracts/dist/schema/dist/EnumType.js +1 -0
  109. package/dist/libs/contracts/dist/schema/dist/FieldType.js +1 -0
  110. package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +1 -0
  111. package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +1 -0
  112. package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
  113. package/dist/libs/contracts/dist/schema/dist/entity/index.js +1 -0
  114. package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
  115. package/dist/libs/contracts/dist/schema/dist/index.js +1 -0
  116. package/dist/libs/contracts/dist/server/graphql-pothos.js +1 -0
  117. package/dist/libs/contracts/dist/server/graphql-schema-export.js +1 -0
  118. package/dist/libs/contracts/dist/server/index.js +1 -0
  119. package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
  120. package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
  121. package/dist/libs/contracts/dist/server/rest-express.js +1 -0
  122. package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
  123. package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
  124. package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
  125. package/dist/libs/contracts/dist/spec.js +1 -0
  126. package/dist/libs/contracts/dist/telemetry/index.js +1 -0
  127. package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
  128. package/dist/libs/contracts/dist/tests/index.js +1 -0
  129. package/dist/libs/contracts/dist/tests/runner.js +1 -0
  130. package/dist/libs/contracts/dist/workflow/index.js +1 -0
  131. package/dist/libs/contracts/dist/workflow/runner.js +1 -0
  132. package/dist/libs/schema/dist/EnumType.js +1 -0
  133. package/dist/libs/schema/dist/FieldType.js +1 -0
  134. package/dist/libs/schema/dist/ScalarTypeEnum.js +1 -0
  135. package/dist/libs/schema/dist/SchemaModel.js +1 -0
  136. package/dist/libs/schema/dist/entity/defineEntity.js +1 -0
  137. package/dist/libs/schema/dist/entity/index.js +1 -0
  138. package/dist/libs/schema/dist/entity/types.js +1 -0
  139. package/dist/libs/schema/dist/index.js +1 -0
  140. package/dist/presentations/agent-list.d.ts +15 -0
  141. package/dist/presentations/agent-list.js +1 -0
  142. package/dist/presentations/dashboard.d.ts +11 -0
  143. package/dist/presentations/dashboard.js +1 -0
  144. package/dist/presentations/index.d.ts +11 -0
  145. package/dist/presentations/index.js +1 -0
  146. package/dist/presentations/run-list.d.ts +18 -0
  147. package/dist/presentations/run-list.js +1 -0
  148. package/dist/presentations/tool-registry.d.ts +14 -0
  149. package/dist/presentations/tool-registry.js +1 -0
  150. package/package.json +86 -0
  151. package/src/contracts/agent.ts +501 -0
  152. package/src/contracts/index.ts +29 -0
  153. package/src/contracts/run.ts +561 -0
  154. package/src/contracts/tool.ts +392 -0
  155. package/src/entities/agent.ts +151 -0
  156. package/src/entities/index.ts +20 -0
  157. package/src/entities/log.ts +76 -0
  158. package/src/entities/run.ts +240 -0
  159. package/src/entities/tool.ts +105 -0
  160. package/src/events.ts +419 -0
  161. package/src/feature.ts +144 -0
  162. package/src/handlers/agent.handlers.ts +203 -0
  163. package/src/handlers/index.ts +55 -0
  164. package/src/handlers/mock-data.ts +413 -0
  165. package/src/handlers/run.handlers.ts +331 -0
  166. package/src/handlers/tool.handlers.ts +188 -0
  167. package/src/index.ts +34 -0
  168. package/src/presentations/agent-list.ts +55 -0
  169. package/src/presentations/dashboard.ts +29 -0
  170. package/src/presentations/index.ts +48 -0
  171. package/src/presentations/run-list.ts +76 -0
  172. package/src/presentations/tool-registry.ts +52 -0
  173. package/tsconfig.json +10 -0
  174. package/tsconfig.tsbuildinfo +1 -0
  175. package/tsdown.config.js +7 -0
@@ -0,0 +1,561 @@
1
+ import { defineCommand, defineQuery } from '@lssm/lib.contracts/spec';
2
+ import {
3
+ defineSchemaModel,
4
+ ScalarTypeEnum,
5
+ defineEnum,
6
+ } from '@lssm/lib.schema';
7
+
8
+ const OWNERS = ['agent-console-team'] as const;
9
+
10
+ // ============ Enums ============
11
+
12
+ export const RunStatusEnum = defineEnum('RunStatus', [
13
+ 'QUEUED',
14
+ 'IN_PROGRESS',
15
+ 'COMPLETED',
16
+ 'FAILED',
17
+ 'CANCELLED',
18
+ 'EXPIRED',
19
+ ]);
20
+
21
+ export const RunStepTypeEnum = defineEnum('RunStepType', [
22
+ 'MESSAGE_CREATION',
23
+ 'TOOL_CALL',
24
+ 'TOOL_RESULT',
25
+ 'ERROR',
26
+ ]);
27
+
28
+ export const LogLevelEnum = defineEnum('LogLevel', [
29
+ 'DEBUG',
30
+ 'INFO',
31
+ 'WARN',
32
+ 'ERROR',
33
+ ]);
34
+
35
+ export const GranularityEnum = defineEnum('Granularity', [
36
+ 'hour',
37
+ 'day',
38
+ 'week',
39
+ 'month',
40
+ ]);
41
+
42
+ // ============ Schemas ============
43
+
44
+ export const RunInputModel = defineSchemaModel({
45
+ name: 'RunInput',
46
+ description: 'Input data for agent execution',
47
+ fields: {
48
+ message: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
49
+ context: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
50
+ },
51
+ });
52
+
53
+ export const RunStepModel = defineSchemaModel({
54
+ name: 'RunStep',
55
+ description: 'Individual step within a run',
56
+ fields: {
57
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ stepNumber: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
59
+ type: { type: RunStepTypeEnum, isOptional: false },
60
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
61
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
62
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
63
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
64
+ status: { type: RunStatusEnum, isOptional: false },
65
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
66
+ tokensUsed: {
67
+ type: ScalarTypeEnum.Int_unsecure(),
68
+ isOptional: false,
69
+ defaultValue: 0,
70
+ },
71
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
72
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
73
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
74
+ },
75
+ });
76
+
77
+ export const RunLogModel = defineSchemaModel({
78
+ name: 'RunLog',
79
+ description: 'Execution log entry',
80
+ fields: {
81
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
83
+ level: { type: LogLevelEnum, isOptional: false },
84
+ message: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
85
+ data: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
86
+ source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
87
+ traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
88
+ spanId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
89
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },
90
+ },
91
+ });
92
+
93
+ export const RunAgentRefModel = defineSchemaModel({
94
+ name: 'RunAgentRef',
95
+ description: 'Agent reference in a run',
96
+ fields: {
97
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
98
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
99
+ modelProvider: {
100
+ type: ScalarTypeEnum.String_unsecure(),
101
+ isOptional: false,
102
+ },
103
+ modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
104
+ },
105
+ });
106
+
107
+ export const RunModel = defineSchemaModel({
108
+ name: 'Run',
109
+ description: 'Agent execution instance',
110
+ fields: {
111
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
112
+ organizationId: {
113
+ type: ScalarTypeEnum.String_unsecure(),
114
+ isOptional: false,
115
+ },
116
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
117
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
118
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
119
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
120
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
121
+ status: { type: RunStatusEnum, isOptional: false },
122
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
123
+ errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
124
+ totalTokens: {
125
+ type: ScalarTypeEnum.Int_unsecure(),
126
+ isOptional: false,
127
+ defaultValue: 0,
128
+ },
129
+ promptTokens: {
130
+ type: ScalarTypeEnum.Int_unsecure(),
131
+ isOptional: false,
132
+ defaultValue: 0,
133
+ },
134
+ completionTokens: {
135
+ type: ScalarTypeEnum.Int_unsecure(),
136
+ isOptional: false,
137
+ defaultValue: 0,
138
+ },
139
+ totalIterations: {
140
+ type: ScalarTypeEnum.Int_unsecure(),
141
+ isOptional: false,
142
+ defaultValue: 0,
143
+ },
144
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
145
+ estimatedCostUsd: {
146
+ type: ScalarTypeEnum.Float_unsecure(),
147
+ isOptional: true,
148
+ },
149
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
150
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
151
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
152
+ metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
153
+ steps: { type: RunStepModel, isArray: true, isOptional: true },
154
+ logs: { type: RunLogModel, isArray: true, isOptional: true },
155
+ agent: { type: RunAgentRefModel, isOptional: true },
156
+ },
157
+ });
158
+
159
+ export const RunSummaryModel = defineSchemaModel({
160
+ name: 'RunSummary',
161
+ description: 'Summary of a run for list views',
162
+ fields: {
163
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
164
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
165
+ agentName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
166
+ status: { type: RunStatusEnum, isOptional: false },
167
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
168
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
169
+ estimatedCostUsd: {
170
+ type: ScalarTypeEnum.Float_unsecure(),
171
+ isOptional: true,
172
+ },
173
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
174
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
175
+ },
176
+ });
177
+
178
+ export const TimelineDataPointModel = defineSchemaModel({
179
+ name: 'TimelineDataPoint',
180
+ description: 'Timeline data point for metrics',
181
+ fields: {
182
+ period: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
183
+ runs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
184
+ tokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
185
+ costUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
186
+ avgDurationMs: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
187
+ },
188
+ });
189
+
190
+ // ============ Contracts ============
191
+
192
+ /**
193
+ * ExecuteAgentCommand - Starts a new agent run
194
+ */
195
+ export const ExecuteAgentCommand = defineCommand({
196
+ meta: {
197
+ name: 'agent.run.execute',
198
+ version: 1,
199
+ stability: 'stable',
200
+ owners: [...OWNERS],
201
+ tags: ['run', 'execute'],
202
+ description: 'Starts a new agent run with the given input.',
203
+ goal: 'Execute an AI agent with user input.',
204
+ context: 'Called from chat interface or API.',
205
+ },
206
+ io: {
207
+ input: defineSchemaModel({
208
+ name: 'ExecuteAgentInput',
209
+ fields: {
210
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
211
+ input: { type: RunInputModel, isOptional: false },
212
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
213
+ metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
214
+ stream: { type: ScalarTypeEnum.Boolean(), isOptional: true },
215
+ maxIterations: {
216
+ type: ScalarTypeEnum.Int_unsecure(),
217
+ isOptional: true,
218
+ },
219
+ timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
220
+ },
221
+ }),
222
+ output: defineSchemaModel({
223
+ name: 'ExecuteAgentOutput',
224
+ fields: {
225
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
226
+ status: { type: RunStatusEnum, isOptional: false },
227
+ estimatedWaitMs: {
228
+ type: ScalarTypeEnum.Int_unsecure(),
229
+ isOptional: true,
230
+ },
231
+ },
232
+ }),
233
+ errors: {
234
+ AGENT_NOT_FOUND: {
235
+ description: 'The specified agent does not exist',
236
+ http: 404,
237
+ gqlCode: 'AGENT_NOT_FOUND',
238
+ when: 'Agent ID is invalid',
239
+ },
240
+ AGENT_NOT_ACTIVE: {
241
+ description: 'The specified agent is not active',
242
+ http: 400,
243
+ gqlCode: 'AGENT_NOT_ACTIVE',
244
+ when: 'Agent is in draft/paused/archived state',
245
+ },
246
+ },
247
+ },
248
+ policy: {
249
+ auth: 'user',
250
+ },
251
+ sideEffects: {
252
+ emits: [
253
+ {
254
+ name: 'run.started',
255
+ version: 1,
256
+ when: 'Run is queued',
257
+ payload: RunSummaryModel,
258
+ },
259
+ ],
260
+ audit: ['run.started'],
261
+ },
262
+ });
263
+
264
+ /**
265
+ * CancelRunCommand - Cancels an in-progress run
266
+ */
267
+ export const CancelRunCommand = defineCommand({
268
+ meta: {
269
+ name: 'agent.run.cancel',
270
+ version: 1,
271
+ stability: 'stable',
272
+ owners: [...OWNERS],
273
+ tags: ['run', 'cancel'],
274
+ description: 'Cancels an in-progress agent run.',
275
+ goal: 'Stop a running agent execution.',
276
+ context: 'Called when user wants to abort a long-running task.',
277
+ },
278
+ io: {
279
+ input: defineSchemaModel({
280
+ name: 'CancelRunInput',
281
+ fields: {
282
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
283
+ reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
284
+ },
285
+ }),
286
+ output: defineSchemaModel({
287
+ name: 'CancelRunOutput',
288
+ fields: {
289
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
290
+ status: { type: RunStatusEnum, isOptional: false },
291
+ },
292
+ }),
293
+ errors: {
294
+ RUN_NOT_FOUND: {
295
+ description: 'The specified run does not exist',
296
+ http: 404,
297
+ gqlCode: 'RUN_NOT_FOUND',
298
+ when: 'Run ID is invalid',
299
+ },
300
+ RUN_NOT_CANCELLABLE: {
301
+ description: 'The run cannot be cancelled',
302
+ http: 400,
303
+ gqlCode: 'RUN_NOT_CANCELLABLE',
304
+ when: 'Run is already completed/failed/cancelled',
305
+ },
306
+ },
307
+ },
308
+ policy: {
309
+ auth: 'user',
310
+ },
311
+ sideEffects: {
312
+ emits: [
313
+ {
314
+ name: 'run.cancelled',
315
+ version: 1,
316
+ when: 'Run is cancelled',
317
+ payload: RunSummaryModel,
318
+ },
319
+ ],
320
+ audit: ['run.cancelled'],
321
+ },
322
+ });
323
+
324
+ /**
325
+ * GetRunQuery - Retrieves a run by ID
326
+ */
327
+ export const GetRunQuery = defineQuery({
328
+ meta: {
329
+ name: 'agent.run.get',
330
+ version: 1,
331
+ stability: 'stable',
332
+ owners: [...OWNERS],
333
+ tags: ['run', 'get'],
334
+ description: 'Retrieves a run by its ID with optional details.',
335
+ goal: 'View detailed run information.',
336
+ context: 'Run details page or monitoring.',
337
+ },
338
+ io: {
339
+ input: defineSchemaModel({
340
+ name: 'GetRunInput',
341
+ fields: {
342
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
343
+ includeSteps: { type: ScalarTypeEnum.Boolean(), isOptional: true },
344
+ includeLogs: { type: ScalarTypeEnum.Boolean(), isOptional: true },
345
+ },
346
+ }),
347
+ output: RunModel,
348
+ errors: {
349
+ RUN_NOT_FOUND: {
350
+ description: 'The specified run does not exist',
351
+ http: 404,
352
+ gqlCode: 'RUN_NOT_FOUND',
353
+ when: 'Run ID is invalid',
354
+ },
355
+ },
356
+ },
357
+ policy: {
358
+ auth: 'user',
359
+ },
360
+ });
361
+
362
+ /**
363
+ * ListRunsQuery - Lists runs for an organization or agent
364
+ */
365
+ export const ListRunsQuery = defineQuery({
366
+ meta: {
367
+ name: 'agent.run.list',
368
+ version: 1,
369
+ stability: 'stable',
370
+ owners: [...OWNERS],
371
+ tags: ['run', 'list'],
372
+ description: 'Lists runs with optional filtering.',
373
+ goal: 'Browse and search run history.',
374
+ context: 'Run history/dashboard view.',
375
+ },
376
+ io: {
377
+ input: defineSchemaModel({
378
+ name: 'ListRunsInput',
379
+ fields: {
380
+ organizationId: {
381
+ type: ScalarTypeEnum.String_unsecure(),
382
+ isOptional: true,
383
+ },
384
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
385
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
386
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
387
+ status: { type: RunStatusEnum, isOptional: true },
388
+ startDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
389
+ endDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
390
+ limit: {
391
+ type: ScalarTypeEnum.Int_unsecure(),
392
+ isOptional: true,
393
+ defaultValue: 20,
394
+ },
395
+ offset: {
396
+ type: ScalarTypeEnum.Int_unsecure(),
397
+ isOptional: true,
398
+ defaultValue: 0,
399
+ },
400
+ },
401
+ }),
402
+ output: defineSchemaModel({
403
+ name: 'ListRunsOutput',
404
+ fields: {
405
+ items: { type: RunSummaryModel, isArray: true, isOptional: false },
406
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
407
+ hasMore: { type: ScalarTypeEnum.Boolean(), isOptional: false },
408
+ },
409
+ }),
410
+ },
411
+ policy: {
412
+ auth: 'user',
413
+ },
414
+ });
415
+
416
+ /**
417
+ * GetRunStepsQuery - Retrieves steps for a run
418
+ */
419
+ export const GetRunStepsQuery = defineQuery({
420
+ meta: {
421
+ name: 'agent.run.getSteps',
422
+ version: 1,
423
+ stability: 'stable',
424
+ owners: [...OWNERS],
425
+ tags: ['run', 'steps'],
426
+ description: 'Retrieves all steps for a specific run.',
427
+ goal: 'View step-by-step execution details.',
428
+ context: 'Run details page - steps tab.',
429
+ },
430
+ io: {
431
+ input: defineSchemaModel({
432
+ name: 'GetRunStepsInput',
433
+ fields: {
434
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
435
+ },
436
+ }),
437
+ output: defineSchemaModel({
438
+ name: 'GetRunStepsOutput',
439
+ fields: {
440
+ steps: { type: RunStepModel, isArray: true, isOptional: false },
441
+ },
442
+ }),
443
+ },
444
+ policy: {
445
+ auth: 'user',
446
+ },
447
+ });
448
+
449
+ /**
450
+ * GetRunLogsQuery - Retrieves logs for a run
451
+ */
452
+ export const GetRunLogsQuery = defineQuery({
453
+ meta: {
454
+ name: 'agent.run.getLogs',
455
+ version: 1,
456
+ stability: 'stable',
457
+ owners: [...OWNERS],
458
+ tags: ['run', 'logs'],
459
+ description: 'Retrieves all logs for a specific run.',
460
+ goal: 'Debug and audit run execution.',
461
+ context: 'Run details page - logs tab.',
462
+ },
463
+ io: {
464
+ input: defineSchemaModel({
465
+ name: 'GetRunLogsInput',
466
+ fields: {
467
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
468
+ level: { type: LogLevelEnum, isOptional: true },
469
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
470
+ limit: {
471
+ type: ScalarTypeEnum.Int_unsecure(),
472
+ isOptional: true,
473
+ defaultValue: 100,
474
+ },
475
+ offset: {
476
+ type: ScalarTypeEnum.Int_unsecure(),
477
+ isOptional: true,
478
+ defaultValue: 0,
479
+ },
480
+ },
481
+ }),
482
+ output: defineSchemaModel({
483
+ name: 'GetRunLogsOutput',
484
+ fields: {
485
+ items: { type: RunLogModel, isArray: true, isOptional: false },
486
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
487
+ hasMore: { type: ScalarTypeEnum.Boolean(), isOptional: false },
488
+ },
489
+ }),
490
+ },
491
+ policy: {
492
+ auth: 'user',
493
+ },
494
+ });
495
+
496
+ /**
497
+ * GetRunMetricsQuery - Retrieves aggregated metrics for runs
498
+ */
499
+ export const GetRunMetricsQuery = defineQuery({
500
+ meta: {
501
+ name: 'agent.run.getMetrics',
502
+ version: 1,
503
+ stability: 'stable',
504
+ owners: [...OWNERS],
505
+ tags: ['run', 'metrics'],
506
+ description: 'Retrieves aggregated metrics for runs within a time period.',
507
+ goal: 'Monitor and analyze agent usage.',
508
+ context: 'Analytics dashboard.',
509
+ },
510
+ io: {
511
+ input: defineSchemaModel({
512
+ name: 'GetRunMetricsInput',
513
+ fields: {
514
+ organizationId: {
515
+ type: ScalarTypeEnum.String_unsecure(),
516
+ isOptional: false,
517
+ },
518
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
519
+ startDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },
520
+ endDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },
521
+ granularity: {
522
+ type: GranularityEnum,
523
+ isOptional: true,
524
+ defaultValue: 'day',
525
+ },
526
+ },
527
+ }),
528
+ output: defineSchemaModel({
529
+ name: 'GetRunMetricsOutput',
530
+ fields: {
531
+ totalRuns: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
532
+ completedRuns: {
533
+ type: ScalarTypeEnum.Int_unsecure(),
534
+ isOptional: false,
535
+ },
536
+ failedRuns: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
537
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
538
+ totalCostUsd: {
539
+ type: ScalarTypeEnum.Float_unsecure(),
540
+ isOptional: false,
541
+ },
542
+ averageDurationMs: {
543
+ type: ScalarTypeEnum.Float_unsecure(),
544
+ isOptional: false,
545
+ },
546
+ successRate: {
547
+ type: ScalarTypeEnum.Float_unsecure(),
548
+ isOptional: false,
549
+ },
550
+ timeline: {
551
+ type: TimelineDataPointModel,
552
+ isArray: true,
553
+ isOptional: false,
554
+ },
555
+ },
556
+ }),
557
+ },
558
+ policy: {
559
+ auth: 'user',
560
+ },
561
+ });