@contractspec/example.agent-console 3.7.6 → 3.7.7

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 +18 -18
  2. package/AGENTS.md +50 -31
  3. package/README.md +69 -77
  4. package/dist/agent/agent.event.js +1 -1
  5. package/dist/agent/agent.operation.js +1 -1
  6. package/dist/agent/index.d.ts +5 -5
  7. package/dist/agent/index.js +1 -1
  8. package/dist/browser/agent/agent.event.js +1 -1
  9. package/dist/browser/agent/agent.operation.js +1 -1
  10. package/dist/browser/agent/index.js +1 -1
  11. package/dist/browser/index.js +2145 -2145
  12. package/dist/browser/presentations/index.js +4 -4
  13. package/dist/browser/run/index.js +536 -536
  14. package/dist/browser/run/run.event.js +2 -2
  15. package/dist/browser/run/run.presentation.js +2 -2
  16. package/dist/browser/tool/index.js +260 -260
  17. package/dist/browser/tool/tool.event.js +1 -1
  18. package/dist/browser/tool/tool.presentation.js +2 -2
  19. package/dist/browser/ui/AgentDashboard.js +956 -956
  20. package/dist/browser/ui/AgentRunList.js +16 -16
  21. package/dist/browser/ui/AgentToolRegistry.js +9 -9
  22. package/dist/browser/ui/hooks/index.js +153 -153
  23. package/dist/browser/ui/hooks/useAgentList.js +1 -1
  24. package/dist/browser/ui/hooks/useAgentMutations.js +1 -1
  25. package/dist/browser/ui/hooks/useRunList.js +1 -1
  26. package/dist/browser/ui/hooks/useToolList.js +1 -1
  27. package/dist/browser/ui/index.js +1222 -1222
  28. package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
  29. package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
  30. package/dist/browser/ui/modals/index.js +297 -297
  31. package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
  32. package/dist/browser/ui/renderers/index.js +157 -157
  33. package/dist/browser/ui/views/AgentListView.js +7 -7
  34. package/dist/browser/ui/views/RunListView.js +16 -16
  35. package/dist/browser/ui/views/ToolRegistryView.js +9 -9
  36. package/dist/browser/ui/views/index.js +97 -97
  37. package/dist/handlers/index.d.ts +1 -1
  38. package/dist/index.d.ts +4 -4
  39. package/dist/index.js +2145 -2145
  40. package/dist/node/agent/agent.event.js +1 -1
  41. package/dist/node/agent/agent.operation.js +1 -1
  42. package/dist/node/agent/index.js +1 -1
  43. package/dist/node/index.js +2145 -2145
  44. package/dist/node/presentations/index.js +4 -4
  45. package/dist/node/run/index.js +536 -536
  46. package/dist/node/run/run.event.js +2 -2
  47. package/dist/node/run/run.presentation.js +2 -2
  48. package/dist/node/tool/index.js +260 -260
  49. package/dist/node/tool/tool.event.js +1 -1
  50. package/dist/node/tool/tool.presentation.js +2 -2
  51. package/dist/node/ui/AgentDashboard.js +956 -956
  52. package/dist/node/ui/AgentRunList.js +16 -16
  53. package/dist/node/ui/AgentToolRegistry.js +9 -9
  54. package/dist/node/ui/hooks/index.js +153 -153
  55. package/dist/node/ui/hooks/useAgentList.js +1 -1
  56. package/dist/node/ui/hooks/useAgentMutations.js +1 -1
  57. package/dist/node/ui/hooks/useRunList.js +1 -1
  58. package/dist/node/ui/hooks/useToolList.js +1 -1
  59. package/dist/node/ui/index.js +1222 -1222
  60. package/dist/node/ui/modals/AgentActionsModal.js +13 -13
  61. package/dist/node/ui/modals/CreateAgentModal.js +15 -15
  62. package/dist/node/ui/modals/index.js +297 -297
  63. package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
  64. package/dist/node/ui/renderers/index.js +157 -157
  65. package/dist/node/ui/views/AgentListView.js +7 -7
  66. package/dist/node/ui/views/RunListView.js +16 -16
  67. package/dist/node/ui/views/ToolRegistryView.js +9 -9
  68. package/dist/node/ui/views/index.js +97 -97
  69. package/dist/presentations/index.d.ts +3 -5
  70. package/dist/presentations/index.js +4 -4
  71. package/dist/run/index.d.ts +7 -7
  72. package/dist/run/index.js +536 -536
  73. package/dist/run/run.event.js +2 -2
  74. package/dist/run/run.handler.d.ts +3 -0
  75. package/dist/run/run.presentation.js +2 -2
  76. package/dist/shared/index.d.ts +1 -1
  77. package/dist/tool/index.d.ts +7 -7
  78. package/dist/tool/index.js +260 -260
  79. package/dist/tool/tool.event.js +1 -1
  80. package/dist/tool/tool.handler.d.ts +1 -1
  81. package/dist/tool/tool.presentation.js +2 -2
  82. package/dist/ui/AgentDashboard.js +956 -956
  83. package/dist/ui/AgentRunList.js +16 -16
  84. package/dist/ui/AgentToolRegistry.js +9 -9
  85. package/dist/ui/hooks/index.d.ts +4 -4
  86. package/dist/ui/hooks/index.js +153 -153
  87. package/dist/ui/hooks/useAgentList.d.ts +5 -0
  88. package/dist/ui/hooks/useAgentList.js +1 -1
  89. package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
  90. package/dist/ui/hooks/useAgentMutations.js +1 -1
  91. package/dist/ui/hooks/useRunList.d.ts +5 -0
  92. package/dist/ui/hooks/useRunList.js +1 -1
  93. package/dist/ui/hooks/useToolList.d.ts +5 -0
  94. package/dist/ui/hooks/useToolList.js +1 -1
  95. package/dist/ui/index.d.ts +3 -3
  96. package/dist/ui/index.js +1222 -1222
  97. package/dist/ui/modals/AgentActionsModal.js +13 -13
  98. package/dist/ui/modals/CreateAgentModal.js +15 -15
  99. package/dist/ui/modals/index.d.ts +1 -1
  100. package/dist/ui/modals/index.js +297 -297
  101. package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
  102. package/dist/ui/renderers/agent-list.renderer.js +7 -7
  103. package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
  104. package/dist/ui/renderers/index.d.ts +2 -2
  105. package/dist/ui/renderers/index.js +157 -157
  106. package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
  107. package/dist/ui/renderers/tool-registry.markdown.d.ts +5 -0
  108. package/dist/ui/views/AgentListView.js +7 -7
  109. package/dist/ui/views/RunListView.js +16 -16
  110. package/dist/ui/views/ToolRegistryView.js +9 -9
  111. package/dist/ui/views/index.js +97 -97
  112. package/package.json +6 -6
  113. package/src/agent/agent.entity.ts +111 -111
  114. package/src/agent/agent.enum.ts +12 -12
  115. package/src/agent/agent.event.ts +91 -91
  116. package/src/agent/agent.handler.ts +123 -123
  117. package/src/agent/agent.operation.ts +400 -400
  118. package/src/agent/agent.presentation.ts +62 -62
  119. package/src/agent/agent.schema.ts +175 -175
  120. package/src/agent/agent.test-spec.ts +48 -48
  121. package/src/agent/index.ts +46 -51
  122. package/src/agent.capability.ts +11 -11
  123. package/src/agent.feature.ts +131 -131
  124. package/src/docs/agent-console.docblock.ts +42 -42
  125. package/src/example.ts +35 -35
  126. package/src/handlers/agent.handlers.ts +522 -521
  127. package/src/handlers/index.ts +12 -12
  128. package/src/index.ts +8 -9
  129. package/src/presentations/index.ts +11 -13
  130. package/src/run/index.ts +49 -54
  131. package/src/run/run.entity.ts +137 -137
  132. package/src/run/run.enum.ts +18 -18
  133. package/src/run/run.event.ts +174 -174
  134. package/src/run/run.handler.ts +92 -91
  135. package/src/run/run.operation.ts +474 -474
  136. package/src/run/run.presentation.ts +42 -42
  137. package/src/run/run.schema.ts +126 -126
  138. package/src/run/run.test-spec.ts +48 -48
  139. package/src/seeders/index.ts +21 -21
  140. package/src/shared/index.ts +1 -1
  141. package/src/shared/mock-agents.ts +76 -76
  142. package/src/shared/mock-runs.ts +102 -102
  143. package/src/shared/mock-tools.ts +140 -140
  144. package/src/shared/overlay-types.ts +23 -23
  145. package/src/tool/index.ts +39 -44
  146. package/src/tool/tool.entity.ts +73 -73
  147. package/src/tool/tool.enum.ts +13 -13
  148. package/src/tool/tool.event.ts +80 -80
  149. package/src/tool/tool.handler.ts +102 -102
  150. package/src/tool/tool.operation.ts +328 -328
  151. package/src/tool/tool.presentation.ts +43 -43
  152. package/src/tool/tool.schema.ts +106 -106
  153. package/src/tool/tool.test-spec.ts +48 -48
  154. package/src/ui/AgentDashboard.tsx +348 -348
  155. package/src/ui/hooks/index.ts +7 -7
  156. package/src/ui/hooks/useAgentList.ts +57 -56
  157. package/src/ui/hooks/useAgentMutations.ts +160 -159
  158. package/src/ui/hooks/useRunList.ts +58 -57
  159. package/src/ui/hooks/useToolList.ts +102 -101
  160. package/src/ui/index.ts +6 -9
  161. package/src/ui/modals/AgentActionsModal.tsx +262 -262
  162. package/src/ui/modals/CreateAgentModal.tsx +232 -232
  163. package/src/ui/modals/index.ts +1 -1
  164. package/src/ui/overlays/demo-overlays.ts +52 -52
  165. package/src/ui/renderers/agent-list.markdown.ts +61 -60
  166. package/src/ui/renderers/agent-list.renderer.tsx +14 -14
  167. package/src/ui/renderers/dashboard.markdown.ts +140 -139
  168. package/src/ui/renderers/index.ts +3 -4
  169. package/src/ui/renderers/run-list.markdown.ts +48 -47
  170. package/src/ui/renderers/tool-registry.markdown.ts +66 -65
  171. package/src/ui/views/AgentListView.tsx +90 -90
  172. package/src/ui/views/RunListView.tsx +141 -141
  173. package/src/ui/views/ToolRegistryView.tsx +113 -113
  174. package/tsconfig.json +7 -8
  175. package/tsdown.config.js +7 -3
@@ -247,6 +247,159 @@ async function mockCancelRunHandler(input) {
247
247
  return { success: true, status: "CANCELLED" };
248
248
  }
249
249
 
250
+ // src/run/run.entity.ts
251
+ import {
252
+ defineEntity,
253
+ defineEntityEnum,
254
+ field,
255
+ index
256
+ } from "@contractspec/lib.schema";
257
+ var RunStatusEntityEnum = defineEntityEnum({
258
+ name: "RunStatus",
259
+ values: [
260
+ "QUEUED",
261
+ "IN_PROGRESS",
262
+ "COMPLETED",
263
+ "FAILED",
264
+ "CANCELLED",
265
+ "EXPIRED"
266
+ ],
267
+ description: "Status of an agent run"
268
+ });
269
+ var RunStepTypeEntityEnum = defineEntityEnum({
270
+ name: "RunStepType",
271
+ values: ["MESSAGE_CREATION", "TOOL_CALL", "TOOL_RESULT", "ERROR"],
272
+ description: "Type of run step"
273
+ });
274
+ var LogLevelEntityEnum = defineEntityEnum({
275
+ name: "LogLevel",
276
+ values: ["DEBUG", "INFO", "WARN", "ERROR"],
277
+ description: "Log level"
278
+ });
279
+ var RunEntity = defineEntity({
280
+ name: "Run",
281
+ schema: "agent_console",
282
+ description: "An execution of an agent with input/output and metrics.",
283
+ fields: {
284
+ id: field.id(),
285
+ organizationId: field.string({ description: "Organization ID" }),
286
+ agentId: field.foreignKey({ description: "Agent being executed" }),
287
+ userId: field.string({
288
+ isOptional: true,
289
+ description: "User who initiated the run"
290
+ }),
291
+ sessionId: field.string({
292
+ isOptional: true,
293
+ description: "Conversation session ID"
294
+ }),
295
+ input: field.json({ description: "Input data for the run" }),
296
+ output: field.json({
297
+ isOptional: true,
298
+ description: "Output result from the run"
299
+ }),
300
+ status: field.enum("RunStatus", { default: "QUEUED" }),
301
+ errorMessage: field.string({
302
+ isOptional: true,
303
+ description: "Error message if failed"
304
+ }),
305
+ errorCode: field.string({
306
+ isOptional: true,
307
+ description: "Error code if failed"
308
+ }),
309
+ totalTokens: field.int({ default: 0, description: "Total tokens used" }),
310
+ promptTokens: field.int({ default: 0, description: "Prompt tokens used" }),
311
+ completionTokens: field.int({
312
+ default: 0,
313
+ description: "Completion tokens used"
314
+ }),
315
+ totalIterations: field.int({
316
+ default: 0,
317
+ description: "Number of iterations"
318
+ }),
319
+ durationMs: field.int({
320
+ isOptional: true,
321
+ description: "Execution duration in ms"
322
+ }),
323
+ estimatedCostUsd: field.float({
324
+ isOptional: true,
325
+ description: "Estimated cost in USD"
326
+ }),
327
+ queuedAt: field.dateTime({ description: "When run was queued" }),
328
+ startedAt: field.dateTime({
329
+ isOptional: true,
330
+ description: "When run started executing"
331
+ }),
332
+ completedAt: field.dateTime({
333
+ isOptional: true,
334
+ description: "When run completed"
335
+ }),
336
+ metadata: field.json({
337
+ isOptional: true,
338
+ description: "Additional metadata"
339
+ }),
340
+ agent: field.belongsTo("Agent", ["agentId"], ["id"]),
341
+ steps: field.hasMany("RunStep", { description: "Execution steps" }),
342
+ logs: field.hasMany("RunLog", { description: "Execution logs" })
343
+ },
344
+ indexes: [
345
+ index.on(["organizationId", "agentId", "queuedAt"]),
346
+ index.on(["organizationId", "status"]),
347
+ index.on(["agentId", "status"]),
348
+ index.on(["sessionId"])
349
+ ],
350
+ enums: [RunStatusEntityEnum]
351
+ });
352
+ var RunStepEntity = defineEntity({
353
+ name: "RunStep",
354
+ schema: "agent_console",
355
+ description: "An individual step in an agent run.",
356
+ fields: {
357
+ id: field.id(),
358
+ runId: field.foreignKey({ description: "Parent run" }),
359
+ stepNumber: field.int({ description: "Step sequence number" }),
360
+ type: field.enum("RunStepType"),
361
+ toolId: field.string({
362
+ isOptional: true,
363
+ description: "Tool used in this step"
364
+ }),
365
+ toolName: field.string({ isOptional: true, description: "Tool name" }),
366
+ input: field.json({ isOptional: true, description: "Step input" }),
367
+ output: field.json({ isOptional: true, description: "Step output" }),
368
+ status: field.enum("RunStatus"),
369
+ errorMessage: field.string({ isOptional: true }),
370
+ tokensUsed: field.int({ default: 0 }),
371
+ durationMs: field.int({ isOptional: true }),
372
+ startedAt: field.dateTime(),
373
+ completedAt: field.dateTime({ isOptional: true }),
374
+ run: field.belongsTo("Run", ["runId"], ["id"])
375
+ },
376
+ indexes: [index.on(["runId", "stepNumber"])],
377
+ enums: [RunStepTypeEntityEnum]
378
+ });
379
+ var RunLogEntity = defineEntity({
380
+ name: "RunLog",
381
+ schema: "agent_console",
382
+ description: "A log entry for an agent run.",
383
+ fields: {
384
+ id: field.id(),
385
+ runId: field.foreignKey({ description: "Parent run" }),
386
+ stepId: field.string({ isOptional: true, description: "Related step" }),
387
+ level: field.enum("LogLevel"),
388
+ message: field.string({ description: "Log message" }),
389
+ data: field.json({ isOptional: true, description: "Additional log data" }),
390
+ source: field.string({
391
+ isOptional: true,
392
+ description: "Log source component"
393
+ }),
394
+ traceId: field.string({ isOptional: true }),
395
+ spanId: field.string({ isOptional: true }),
396
+ timestamp: field.dateTime(),
397
+ run: field.belongsTo("Run", ["runId"], ["id"])
398
+ },
399
+ indexes: [index.on(["runId", "timestamp"]), index.on(["runId", "level"])],
400
+ enums: [LogLevelEntityEnum]
401
+ });
402
+
250
403
  // src/run/run.enum.ts
251
404
  import { defineEnum } from "@contractspec/lib.schema";
252
405
  var RunStatusEnum = defineEnum("RunStatus", [
@@ -276,145 +429,354 @@ var GranularityEnum = defineEnum("Granularity", [
276
429
  "month"
277
430
  ]);
278
431
 
279
- // src/run/run.schema.ts
280
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
281
- var RunInputModel = defineSchemaModel({
282
- name: "RunInput",
283
- description: "Input data for agent execution",
284
- fields: {
285
- message: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
286
- context: { type: ScalarTypeEnum.JSONObject(), isOptional: true }
287
- }
288
- });
289
- var RunStepModel = defineSchemaModel({
290
- name: "RunStep",
291
- description: "Individual step within a run",
292
- fields: {
293
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
294
- stepNumber: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
295
- type: { type: RunStepTypeEnum, isOptional: false },
296
- toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
297
- toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
298
- input: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
299
- output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
300
- status: { type: RunStatusEnum, isOptional: false },
301
- errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
302
- tokensUsed: {
303
- type: ScalarTypeEnum.Int_unsecure(),
304
- isOptional: false,
305
- defaultValue: 0
306
- },
307
- durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
308
- startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
309
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
310
- }
311
- });
312
- var RunLogModel = defineSchemaModel({
313
- name: "RunLog",
314
- description: "Execution log entry",
315
- fields: {
316
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
317
- stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
318
- level: { type: LogLevelEnum, isOptional: false },
319
- message: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
320
- data: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
321
- source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
322
- traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
323
- spanId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
324
- timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
325
- }
326
- });
327
- var RunAgentRefModel = defineSchemaModel({
328
- name: "RunAgentRef",
329
- description: "Agent reference in a run",
432
+ // src/run/run.event.ts
433
+ import { defineEvent } from "@contractspec/lib.contracts-spec";
434
+ import {
435
+ defineEnum as defineEnum2,
436
+ defineSchemaModel,
437
+ ScalarTypeEnum
438
+ } from "@contractspec/lib.schema";
439
+ var OWNERS = ["@agent-console-team"];
440
+ var RunStartedPayload = defineSchemaModel({
441
+ name: "RunStartedPayload",
442
+ description: "Payload for run started event",
330
443
  fields: {
331
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
332
- name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
333
- modelProvider: {
444
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
445
+ organizationId: {
334
446
  type: ScalarTypeEnum.String_unsecure(),
335
447
  isOptional: false
336
448
  },
337
- modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
449
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
450
+ agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
451
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
452
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
453
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
454
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
338
455
  }
339
456
  });
340
- var RunModel = defineSchemaModel({
341
- name: "Run",
342
- description: "Agent execution instance",
457
+ var RunStartedEvent = defineEvent({
458
+ meta: {
459
+ key: "agent.run.started",
460
+ version: "1.0.0",
461
+ description: "An agent run was started.",
462
+ stability: "stable",
463
+ owners: [...OWNERS],
464
+ tags: ["run", "started"]
465
+ },
466
+ payload: RunStartedPayload
467
+ });
468
+ var RunCompletedPayload = defineSchemaModel({
469
+ name: "RunCompletedPayload",
470
+ description: "Payload for run completed event",
343
471
  fields: {
344
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
472
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
345
473
  organizationId: {
346
474
  type: ScalarTypeEnum.String_unsecure(),
347
475
  isOptional: false
348
476
  },
349
477
  agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
478
+ agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
350
479
  userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
351
- sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
352
- input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
353
- output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
354
- status: { type: RunStatusEnum, isOptional: false },
355
- errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
356
- errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
357
- totalTokens: {
358
- type: ScalarTypeEnum.Int_unsecure(),
359
- isOptional: false,
360
- defaultValue: 0
361
- },
362
- promptTokens: {
363
- type: ScalarTypeEnum.Int_unsecure(),
364
- isOptional: false,
365
- defaultValue: 0
366
- },
480
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
481
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
482
+ promptTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
367
483
  completionTokens: {
368
484
  type: ScalarTypeEnum.Int_unsecure(),
369
- isOptional: false,
370
- defaultValue: 0
371
- },
372
- totalIterations: {
373
- type: ScalarTypeEnum.Int_unsecure(),
374
- isOptional: false,
375
- defaultValue: 0
485
+ isOptional: false
376
486
  },
377
- durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
487
+ totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
488
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
378
489
  estimatedCostUsd: {
379
490
  type: ScalarTypeEnum.Float_unsecure(),
380
491
  isOptional: true
381
492
  },
382
- queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
383
- startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
384
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
385
- metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
386
- steps: { type: RunStepModel, isArray: true, isOptional: true },
387
- logs: { type: RunLogModel, isArray: true, isOptional: true },
388
- agent: { type: RunAgentRefModel, isOptional: true }
493
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
389
494
  }
390
495
  });
391
- var RunSummaryModel = defineSchemaModel({
392
- name: "RunSummary",
393
- description: "Summary of a run for list views",
496
+ var RunCompletedEvent = defineEvent({
497
+ meta: {
498
+ key: "agent.run.completed",
499
+ version: "1.0.0",
500
+ description: "An agent run completed successfully.",
501
+ stability: "stable",
502
+ owners: [...OWNERS],
503
+ tags: ["run", "completed"]
504
+ },
505
+ payload: RunCompletedPayload
506
+ });
507
+ var RunFailedPayload = defineSchemaModel({
508
+ name: "RunFailedPayload",
509
+ description: "Payload for run failed event",
394
510
  fields: {
395
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
396
- agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
397
- agentName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
398
- status: { type: RunStatusEnum, isOptional: false },
511
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
512
+ organizationId: {
513
+ type: ScalarTypeEnum.String_unsecure(),
514
+ isOptional: false
515
+ },
516
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
517
+ agentName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
518
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
519
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
520
+ errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
399
521
  totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
522
+ totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
400
523
  durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
524
+ failedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
525
+ }
526
+ });
527
+ var RunFailedEvent = defineEvent({
528
+ meta: {
529
+ key: "agent.run.failed",
530
+ version: "1.0.0",
531
+ description: "An agent run encountered an error.",
532
+ stability: "stable",
533
+ owners: [...OWNERS],
534
+ tags: ["run", "failed"]
535
+ },
536
+ payload: RunFailedPayload
537
+ });
538
+ var RunCancelledPayload = defineSchemaModel({
539
+ name: "RunCancelledPayload",
540
+ description: "Payload for run cancelled event",
541
+ fields: {
542
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
543
+ organizationId: {
544
+ type: ScalarTypeEnum.String_unsecure(),
545
+ isOptional: false
546
+ },
547
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
548
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
549
+ cancelledBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
550
+ reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
551
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
552
+ totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
553
+ cancelledAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
554
+ }
555
+ });
556
+ var RunCancelledEvent = defineEvent({
557
+ meta: {
558
+ key: "agent.run.cancelled",
559
+ version: "1.0.0",
560
+ description: "An agent run was cancelled by the user.",
561
+ stability: "stable",
562
+ owners: [...OWNERS],
563
+ tags: ["run", "cancelled"]
564
+ },
565
+ payload: RunCancelledPayload
566
+ });
567
+ var ToolInvokedPayload = defineSchemaModel({
568
+ name: "ToolInvokedPayload",
569
+ description: "Payload for tool invoked event",
570
+ fields: {
571
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
572
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
573
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
574
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
575
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
576
+ invokedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
577
+ }
578
+ });
579
+ var ToolInvokedEvent = defineEvent({
580
+ meta: {
581
+ key: "agent.run.toolInvoked",
582
+ version: "1.0.0",
583
+ description: "A tool was invoked during an agent run.",
584
+ stability: "stable",
585
+ owners: [...OWNERS],
586
+ tags: ["run", "tool", "invoked"]
587
+ },
588
+ payload: ToolInvokedPayload
589
+ });
590
+ var ToolCompletedPayload = defineSchemaModel({
591
+ name: "ToolCompletedPayload",
592
+ description: "Payload for tool completed event",
593
+ fields: {
594
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
595
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
596
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
597
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
598
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
599
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
600
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
601
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
602
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
603
+ }
604
+ });
605
+ var ToolCompletedEvent = defineEvent({
606
+ meta: {
607
+ key: "agent.run.toolCompleted",
608
+ version: "1.0.0",
609
+ description: "A tool invocation completed during an agent run.",
610
+ stability: "stable",
611
+ owners: [...OWNERS],
612
+ tags: ["run", "tool", "completed"]
613
+ },
614
+ payload: ToolCompletedPayload
615
+ });
616
+ var MessageTypeEnum = defineEnum2("MessageType", ["assistant", "system"]);
617
+ var MessageGeneratedPayload = defineSchemaModel({
618
+ name: "MessageGeneratedPayload",
619
+ description: "Payload for message generated event",
620
+ fields: {
621
+ runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
622
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
623
+ messageType: { type: MessageTypeEnum, isOptional: false },
624
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
625
+ tokensUsed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
626
+ generatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
627
+ }
628
+ });
629
+ var MessageGeneratedEvent = defineEvent({
630
+ meta: {
631
+ key: "agent.run.messageGenerated",
632
+ version: "1.0.0",
633
+ description: "An agent generated a message during a run.",
634
+ stability: "stable",
635
+ owners: [...OWNERS],
636
+ tags: ["run", "message", "generated"]
637
+ },
638
+ payload: MessageGeneratedPayload
639
+ });
640
+
641
+ // src/run/run.schema.ts
642
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
643
+ var RunInputModel = defineSchemaModel2({
644
+ name: "RunInput",
645
+ description: "Input data for agent execution",
646
+ fields: {
647
+ message: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
648
+ context: { type: ScalarTypeEnum2.JSONObject(), isOptional: true }
649
+ }
650
+ });
651
+ var RunStepModel = defineSchemaModel2({
652
+ name: "RunStep",
653
+ description: "Individual step within a run",
654
+ fields: {
655
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
656
+ stepNumber: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
657
+ type: { type: RunStepTypeEnum, isOptional: false },
658
+ toolId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
659
+ toolName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
660
+ input: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
661
+ output: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
662
+ status: { type: RunStatusEnum, isOptional: false },
663
+ errorMessage: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
664
+ tokensUsed: {
665
+ type: ScalarTypeEnum2.Int_unsecure(),
666
+ isOptional: false,
667
+ defaultValue: 0
668
+ },
669
+ durationMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
670
+ startedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
671
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
672
+ }
673
+ });
674
+ var RunLogModel = defineSchemaModel2({
675
+ name: "RunLog",
676
+ description: "Execution log entry",
677
+ fields: {
678
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
679
+ stepId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
680
+ level: { type: LogLevelEnum, isOptional: false },
681
+ message: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
682
+ data: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
683
+ source: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
684
+ traceId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
685
+ spanId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
686
+ timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
687
+ }
688
+ });
689
+ var RunAgentRefModel = defineSchemaModel2({
690
+ name: "RunAgentRef",
691
+ description: "Agent reference in a run",
692
+ fields: {
693
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
694
+ name: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
695
+ modelProvider: {
696
+ type: ScalarTypeEnum2.String_unsecure(),
697
+ isOptional: false
698
+ },
699
+ modelName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
700
+ }
701
+ });
702
+ var RunModel = defineSchemaModel2({
703
+ name: "Run",
704
+ description: "Agent execution instance",
705
+ fields: {
706
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
707
+ organizationId: {
708
+ type: ScalarTypeEnum2.String_unsecure(),
709
+ isOptional: false
710
+ },
711
+ agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
712
+ userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
713
+ sessionId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
714
+ input: { type: ScalarTypeEnum2.JSONObject(), isOptional: false },
715
+ output: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
716
+ status: { type: RunStatusEnum, isOptional: false },
717
+ errorMessage: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
718
+ errorCode: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
719
+ totalTokens: {
720
+ type: ScalarTypeEnum2.Int_unsecure(),
721
+ isOptional: false,
722
+ defaultValue: 0
723
+ },
724
+ promptTokens: {
725
+ type: ScalarTypeEnum2.Int_unsecure(),
726
+ isOptional: false,
727
+ defaultValue: 0
728
+ },
729
+ completionTokens: {
730
+ type: ScalarTypeEnum2.Int_unsecure(),
731
+ isOptional: false,
732
+ defaultValue: 0
733
+ },
734
+ totalIterations: {
735
+ type: ScalarTypeEnum2.Int_unsecure(),
736
+ isOptional: false,
737
+ defaultValue: 0
738
+ },
739
+ durationMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
401
740
  estimatedCostUsd: {
402
- type: ScalarTypeEnum.Float_unsecure(),
741
+ type: ScalarTypeEnum2.Float_unsecure(),
742
+ isOptional: true
743
+ },
744
+ queuedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
745
+ startedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
746
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
747
+ metadata: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
748
+ steps: { type: RunStepModel, isArray: true, isOptional: true },
749
+ logs: { type: RunLogModel, isArray: true, isOptional: true },
750
+ agent: { type: RunAgentRefModel, isOptional: true }
751
+ }
752
+ });
753
+ var RunSummaryModel = defineSchemaModel2({
754
+ name: "RunSummary",
755
+ description: "Summary of a run for list views",
756
+ fields: {
757
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
758
+ agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
759
+ agentName: { type: ScalarTypeEnum2.NonEmptyString(), isOptional: false },
760
+ status: { type: RunStatusEnum, isOptional: false },
761
+ totalTokens: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
762
+ durationMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
763
+ estimatedCostUsd: {
764
+ type: ScalarTypeEnum2.Float_unsecure(),
403
765
  isOptional: true
404
766
  },
405
- queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
406
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
767
+ queuedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
768
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
407
769
  }
408
770
  });
409
- var TimelineDataPointModel = defineSchemaModel({
771
+ var TimelineDataPointModel = defineSchemaModel2({
410
772
  name: "TimelineDataPoint",
411
773
  description: "Timeline data point for metrics",
412
774
  fields: {
413
- period: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
414
- runs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
415
- tokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
416
- costUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
417
- avgDurationMs: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
775
+ period: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
776
+ runs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
777
+ tokens: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
778
+ costUsd: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
779
+ avgDurationMs: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false }
418
780
  }
419
781
  });
420
782
 
@@ -423,42 +785,42 @@ import {
423
785
  defineCommand,
424
786
  defineQuery
425
787
  } from "@contractspec/lib.contracts-spec/operations";
426
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
427
- var OWNERS = ["@agent-console-team"];
788
+ import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
789
+ var OWNERS2 = ["@agent-console-team"];
428
790
  var ExecuteAgentCommand = defineCommand({
429
791
  meta: {
430
792
  key: "agent.run.execute",
431
793
  version: "1.0.0",
432
794
  stability: "stable",
433
- owners: [...OWNERS],
795
+ owners: [...OWNERS2],
434
796
  tags: ["run", "execute"],
435
797
  description: "Starts a new agent run with the given input.",
436
798
  goal: "Execute an AI agent with user input.",
437
799
  context: "Called from chat interface or API."
438
800
  },
439
801
  io: {
440
- input: defineSchemaModel2({
802
+ input: defineSchemaModel3({
441
803
  name: "ExecuteAgentInput",
442
804
  fields: {
443
- agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
805
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
444
806
  input: { type: RunInputModel, isOptional: false },
445
- sessionId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
446
- metadata: { type: ScalarTypeEnum2.JSONObject(), isOptional: true },
447
- stream: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
807
+ sessionId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
808
+ metadata: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
809
+ stream: { type: ScalarTypeEnum3.Boolean(), isOptional: true },
448
810
  maxIterations: {
449
- type: ScalarTypeEnum2.Int_unsecure(),
811
+ type: ScalarTypeEnum3.Int_unsecure(),
450
812
  isOptional: true
451
813
  },
452
- timeoutMs: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true }
814
+ timeoutMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true }
453
815
  }
454
816
  }),
455
- output: defineSchemaModel2({
817
+ output: defineSchemaModel3({
456
818
  name: "ExecuteAgentOutput",
457
819
  fields: {
458
- runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
820
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
459
821
  status: { type: RunStatusEnum, isOptional: false },
460
822
  estimatedWaitMs: {
461
- type: ScalarTypeEnum2.Int_unsecure(),
823
+ type: ScalarTypeEnum3.Int_unsecure(),
462
824
  isOptional: true
463
825
  }
464
826
  }
@@ -485,7 +847,7 @@ var ExecuteAgentCommand = defineCommand({
485
847
  key: "run.started",
486
848
  version: "1.0.0",
487
849
  stability: "stable",
488
- owners: [...OWNERS],
850
+ owners: [...OWNERS2],
489
851
  tags: ["run", "started"],
490
852
  when: "Run is queued",
491
853
  payload: RunSummaryModel
@@ -522,24 +884,24 @@ var CancelRunCommand = defineCommand({
522
884
  key: "agent.run.cancel",
523
885
  version: "1.0.0",
524
886
  stability: "stable",
525
- owners: [...OWNERS],
887
+ owners: [...OWNERS2],
526
888
  tags: ["run", "cancel"],
527
889
  description: "Cancels an in-progress agent run.",
528
890
  goal: "Stop a running agent execution.",
529
891
  context: "Called when user wants to abort a long-running task."
530
892
  },
531
893
  io: {
532
- input: defineSchemaModel2({
894
+ input: defineSchemaModel3({
533
895
  name: "CancelRunInput",
534
896
  fields: {
535
- runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
536
- reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
897
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
898
+ reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
537
899
  }
538
900
  }),
539
- output: defineSchemaModel2({
901
+ output: defineSchemaModel3({
540
902
  name: "CancelRunOutput",
541
903
  fields: {
542
- success: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
904
+ success: { type: ScalarTypeEnum3.Boolean(), isOptional: false },
543
905
  status: { type: RunStatusEnum, isOptional: false }
544
906
  }
545
907
  }),
@@ -565,7 +927,7 @@ var CancelRunCommand = defineCommand({
565
927
  key: "run.cancelled",
566
928
  version: "1.0.0",
567
929
  stability: "stable",
568
- owners: [...OWNERS],
930
+ owners: [...OWNERS2],
569
931
  tags: ["run", "cancelled"],
570
932
  when: "Run is cancelled",
571
933
  payload: RunSummaryModel
@@ -602,19 +964,19 @@ var GetRunQuery = defineQuery({
602
964
  key: "agent.run.get",
603
965
  version: "1.0.0",
604
966
  stability: "stable",
605
- owners: [...OWNERS],
967
+ owners: [...OWNERS2],
606
968
  tags: ["run", "get"],
607
969
  description: "Retrieves a run by its ID with optional details.",
608
970
  goal: "View detailed run information.",
609
971
  context: "Run details page or monitoring."
610
972
  },
611
973
  io: {
612
- input: defineSchemaModel2({
974
+ input: defineSchemaModel3({
613
975
  name: "GetRunInput",
614
976
  fields: {
615
- runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
616
- includeSteps: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
617
- includeLogs: { type: ScalarTypeEnum2.Boolean(), isOptional: true }
977
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
978
+ includeSteps: { type: ScalarTypeEnum3.Boolean(), isOptional: true },
979
+ includeLogs: { type: ScalarTypeEnum3.Boolean(), isOptional: true }
618
980
  }
619
981
  }),
620
982
  output: RunModel,
@@ -651,44 +1013,44 @@ var ListRunsQuery = defineQuery({
651
1013
  key: "agent.run.list",
652
1014
  version: "1.0.0",
653
1015
  stability: "stable",
654
- owners: [...OWNERS],
1016
+ owners: [...OWNERS2],
655
1017
  tags: ["run", "list"],
656
1018
  description: "Lists runs with optional filtering.",
657
1019
  goal: "Browse and search run history.",
658
1020
  context: "Run history/dashboard view."
659
1021
  },
660
1022
  io: {
661
- input: defineSchemaModel2({
1023
+ input: defineSchemaModel3({
662
1024
  name: "ListRunsInput",
663
1025
  fields: {
664
1026
  organizationId: {
665
- type: ScalarTypeEnum2.String_unsecure(),
1027
+ type: ScalarTypeEnum3.String_unsecure(),
666
1028
  isOptional: true
667
1029
  },
668
- agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
669
- userId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
670
- sessionId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1030
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1031
+ userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1032
+ sessionId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
671
1033
  status: { type: RunStatusEnum, isOptional: true },
672
- startDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
673
- endDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
1034
+ startDate: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
1035
+ endDate: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
674
1036
  limit: {
675
- type: ScalarTypeEnum2.Int_unsecure(),
1037
+ type: ScalarTypeEnum3.Int_unsecure(),
676
1038
  isOptional: true,
677
1039
  defaultValue: 20
678
1040
  },
679
1041
  offset: {
680
- type: ScalarTypeEnum2.Int_unsecure(),
1042
+ type: ScalarTypeEnum3.Int_unsecure(),
681
1043
  isOptional: true,
682
1044
  defaultValue: 0
683
1045
  }
684
1046
  }
685
1047
  }),
686
- output: defineSchemaModel2({
1048
+ output: defineSchemaModel3({
687
1049
  name: "ListRunsOutput",
688
1050
  fields: {
689
1051
  items: { type: RunSummaryModel, isArray: true, isOptional: false },
690
- total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
691
- hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
1052
+ total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1053
+ hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
692
1054
  }
693
1055
  })
694
1056
  },
@@ -716,20 +1078,20 @@ var GetRunStepsQuery = defineQuery({
716
1078
  key: "agent.run.getSteps",
717
1079
  version: "1.0.0",
718
1080
  stability: "stable",
719
- owners: [...OWNERS],
1081
+ owners: [...OWNERS2],
720
1082
  tags: ["run", "steps"],
721
1083
  description: "Retrieves all steps for a specific run.",
722
1084
  goal: "View step-by-step execution details.",
723
1085
  context: "Run details page - steps tab."
724
1086
  },
725
1087
  io: {
726
- input: defineSchemaModel2({
1088
+ input: defineSchemaModel3({
727
1089
  name: "GetRunStepsInput",
728
1090
  fields: {
729
- runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
1091
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false }
730
1092
  }
731
1093
  }),
732
- output: defineSchemaModel2({
1094
+ output: defineSchemaModel3({
733
1095
  name: "GetRunStepsOutput",
734
1096
  fields: {
735
1097
  steps: { type: RunStepModel, isArray: true, isOptional: false }
@@ -760,37 +1122,37 @@ var GetRunLogsQuery = defineQuery({
760
1122
  key: "agent.run.getLogs",
761
1123
  version: "1.0.0",
762
1124
  stability: "stable",
763
- owners: [...OWNERS],
1125
+ owners: [...OWNERS2],
764
1126
  tags: ["run", "logs"],
765
1127
  description: "Retrieves all logs for a specific run.",
766
1128
  goal: "Debug and audit run execution.",
767
1129
  context: "Run details page - logs tab."
768
1130
  },
769
1131
  io: {
770
- input: defineSchemaModel2({
1132
+ input: defineSchemaModel3({
771
1133
  name: "GetRunLogsInput",
772
1134
  fields: {
773
- runId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
1135
+ runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
774
1136
  level: { type: LogLevelEnum, isOptional: true },
775
- stepId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
1137
+ stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
776
1138
  limit: {
777
- type: ScalarTypeEnum2.Int_unsecure(),
1139
+ type: ScalarTypeEnum3.Int_unsecure(),
778
1140
  isOptional: true,
779
1141
  defaultValue: 100
780
1142
  },
781
1143
  offset: {
782
- type: ScalarTypeEnum2.Int_unsecure(),
1144
+ type: ScalarTypeEnum3.Int_unsecure(),
783
1145
  isOptional: true,
784
1146
  defaultValue: 0
785
1147
  }
786
1148
  }
787
1149
  }),
788
- output: defineSchemaModel2({
1150
+ output: defineSchemaModel3({
789
1151
  name: "GetRunLogsOutput",
790
1152
  fields: {
791
1153
  items: { type: RunLogModel, isArray: true, isOptional: false },
792
- total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
793
- hasMore: { type: ScalarTypeEnum2.Boolean(), isOptional: false }
1154
+ total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1155
+ hasMore: { type: ScalarTypeEnum3.Boolean(), isOptional: false }
794
1156
  }
795
1157
  })
796
1158
  },
@@ -818,23 +1180,23 @@ var GetRunMetricsQuery = defineQuery({
818
1180
  key: "agent.run.getMetrics",
819
1181
  version: "1.0.0",
820
1182
  stability: "stable",
821
- owners: [...OWNERS],
1183
+ owners: [...OWNERS2],
822
1184
  tags: ["run", "metrics"],
823
1185
  description: "Retrieves aggregated metrics for runs within a time period.",
824
1186
  goal: "Monitor and analyze agent usage.",
825
1187
  context: "Analytics dashboard."
826
1188
  },
827
1189
  io: {
828
- input: defineSchemaModel2({
1190
+ input: defineSchemaModel3({
829
1191
  name: "GetRunMetricsInput",
830
1192
  fields: {
831
1193
  organizationId: {
832
- type: ScalarTypeEnum2.String_unsecure(),
1194
+ type: ScalarTypeEnum3.String_unsecure(),
833
1195
  isOptional: false
834
1196
  },
835
- agentId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
836
- startDate: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
837
- endDate: { type: ScalarTypeEnum2.DateTime(), isOptional: false },
1197
+ agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1198
+ startDate: { type: ScalarTypeEnum3.DateTime(), isOptional: false },
1199
+ endDate: { type: ScalarTypeEnum3.DateTime(), isOptional: false },
838
1200
  granularity: {
839
1201
  type: GranularityEnum,
840
1202
  isOptional: true,
@@ -842,26 +1204,26 @@ var GetRunMetricsQuery = defineQuery({
842
1204
  }
843
1205
  }
844
1206
  }),
845
- output: defineSchemaModel2({
1207
+ output: defineSchemaModel3({
846
1208
  name: "GetRunMetricsOutput",
847
1209
  fields: {
848
- totalRuns: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
1210
+ totalRuns: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
849
1211
  completedRuns: {
850
- type: ScalarTypeEnum2.Int_unsecure(),
1212
+ type: ScalarTypeEnum3.Int_unsecure(),
851
1213
  isOptional: false
852
1214
  },
853
- failedRuns: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
854
- totalTokens: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
1215
+ failedRuns: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1216
+ totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
855
1217
  totalCostUsd: {
856
- type: ScalarTypeEnum2.Float_unsecure(),
1218
+ type: ScalarTypeEnum3.Float_unsecure(),
857
1219
  isOptional: false
858
1220
  },
859
1221
  averageDurationMs: {
860
- type: ScalarTypeEnum2.Float_unsecure(),
1222
+ type: ScalarTypeEnum3.Float_unsecure(),
861
1223
  isOptional: false
862
1224
  },
863
1225
  successRate: {
864
- type: ScalarTypeEnum2.Float_unsecure(),
1226
+ type: ScalarTypeEnum3.Float_unsecure(),
865
1227
  isOptional: false
866
1228
  },
867
1229
  timeline: {
@@ -906,372 +1268,10 @@ var GetRunMetricsQuery = defineQuery({
906
1268
  }
907
1269
  });
908
1270
 
909
- // src/run/run.event.ts
910
- import { defineEvent } from "@contractspec/lib.contracts-spec";
911
- import {
912
- ScalarTypeEnum as ScalarTypeEnum3,
913
- defineEnum as defineEnum2,
914
- defineSchemaModel as defineSchemaModel3
915
- } from "@contractspec/lib.schema";
916
- var OWNERS2 = ["@agent-console-team"];
917
- var RunStartedPayload = defineSchemaModel3({
918
- name: "RunStartedPayload",
919
- description: "Payload for run started event",
920
- fields: {
921
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
922
- organizationId: {
923
- type: ScalarTypeEnum3.String_unsecure(),
924
- isOptional: false
925
- },
926
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
927
- agentName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
928
- userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
929
- sessionId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
930
- input: { type: ScalarTypeEnum3.JSONObject(), isOptional: false },
931
- startedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
932
- }
933
- });
934
- var RunStartedEvent = defineEvent({
935
- meta: {
936
- key: "agent.run.started",
937
- version: "1.0.0",
938
- description: "An agent run was started.",
939
- stability: "stable",
940
- owners: [...OWNERS2],
941
- tags: ["run", "started"]
942
- },
943
- payload: RunStartedPayload
944
- });
945
- var RunCompletedPayload = defineSchemaModel3({
946
- name: "RunCompletedPayload",
947
- description: "Payload for run completed event",
948
- fields: {
949
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
950
- organizationId: {
951
- type: ScalarTypeEnum3.String_unsecure(),
952
- isOptional: false
953
- },
954
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
955
- agentName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
956
- userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
957
- output: { type: ScalarTypeEnum3.JSONObject(), isOptional: false },
958
- totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
959
- promptTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
960
- completionTokens: {
961
- type: ScalarTypeEnum3.Int_unsecure(),
962
- isOptional: false
963
- },
964
- totalIterations: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
965
- durationMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
966
- estimatedCostUsd: {
967
- type: ScalarTypeEnum3.Float_unsecure(),
968
- isOptional: true
969
- },
970
- completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
971
- }
972
- });
973
- var RunCompletedEvent = defineEvent({
974
- meta: {
975
- key: "agent.run.completed",
976
- version: "1.0.0",
977
- description: "An agent run completed successfully.",
978
- stability: "stable",
979
- owners: [...OWNERS2],
980
- tags: ["run", "completed"]
981
- },
982
- payload: RunCompletedPayload
983
- });
984
- var RunFailedPayload = defineSchemaModel3({
985
- name: "RunFailedPayload",
986
- description: "Payload for run failed event",
987
- fields: {
988
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
989
- organizationId: {
990
- type: ScalarTypeEnum3.String_unsecure(),
991
- isOptional: false
992
- },
993
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
994
- agentName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
995
- userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
996
- errorMessage: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
997
- errorCode: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
998
- totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
999
- totalIterations: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1000
- durationMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true },
1001
- failedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1002
- }
1003
- });
1004
- var RunFailedEvent = defineEvent({
1005
- meta: {
1006
- key: "agent.run.failed",
1007
- version: "1.0.0",
1008
- description: "An agent run encountered an error.",
1009
- stability: "stable",
1010
- owners: [...OWNERS2],
1011
- tags: ["run", "failed"]
1012
- },
1013
- payload: RunFailedPayload
1014
- });
1015
- var RunCancelledPayload = defineSchemaModel3({
1016
- name: "RunCancelledPayload",
1017
- description: "Payload for run cancelled event",
1018
- fields: {
1019
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1020
- organizationId: {
1021
- type: ScalarTypeEnum3.String_unsecure(),
1022
- isOptional: false
1023
- },
1024
- agentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1025
- userId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1026
- cancelledBy: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1027
- reason: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1028
- totalTokens: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1029
- totalIterations: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1030
- cancelledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1031
- }
1032
- });
1033
- var RunCancelledEvent = defineEvent({
1034
- meta: {
1035
- key: "agent.run.cancelled",
1036
- version: "1.0.0",
1037
- description: "An agent run was cancelled by the user.",
1038
- stability: "stable",
1039
- owners: [...OWNERS2],
1040
- tags: ["run", "cancelled"]
1041
- },
1042
- payload: RunCancelledPayload
1043
- });
1044
- var ToolInvokedPayload = defineSchemaModel3({
1045
- name: "ToolInvokedPayload",
1046
- description: "Payload for tool invoked event",
1047
- fields: {
1048
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1049
- stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1050
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1051
- toolName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1052
- input: { type: ScalarTypeEnum3.JSONObject(), isOptional: false },
1053
- invokedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1054
- }
1055
- });
1056
- var ToolInvokedEvent = defineEvent({
1057
- meta: {
1058
- key: "agent.run.toolInvoked",
1059
- version: "1.0.0",
1060
- description: "A tool was invoked during an agent run.",
1061
- stability: "stable",
1062
- owners: [...OWNERS2],
1063
- tags: ["run", "tool", "invoked"]
1064
- },
1065
- payload: ToolInvokedPayload
1066
- });
1067
- var ToolCompletedPayload = defineSchemaModel3({
1068
- name: "ToolCompletedPayload",
1069
- description: "Payload for tool completed event",
1070
- fields: {
1071
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1072
- stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1073
- toolId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1074
- toolName: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1075
- success: { type: ScalarTypeEnum3.Boolean(), isOptional: false },
1076
- output: { type: ScalarTypeEnum3.JSONObject(), isOptional: true },
1077
- errorMessage: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
1078
- durationMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1079
- completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1080
- }
1081
- });
1082
- var ToolCompletedEvent = defineEvent({
1083
- meta: {
1084
- key: "agent.run.toolCompleted",
1085
- version: "1.0.0",
1086
- description: "A tool invocation completed during an agent run.",
1087
- stability: "stable",
1088
- owners: [...OWNERS2],
1089
- tags: ["run", "tool", "completed"]
1090
- },
1091
- payload: ToolCompletedPayload
1092
- });
1093
- var MessageTypeEnum = defineEnum2("MessageType", ["assistant", "system"]);
1094
- var MessageGeneratedPayload = defineSchemaModel3({
1095
- name: "MessageGeneratedPayload",
1096
- description: "Payload for message generated event",
1097
- fields: {
1098
- runId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1099
- stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1100
- messageType: { type: MessageTypeEnum, isOptional: false },
1101
- content: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
1102
- tokensUsed: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
1103
- generatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
1104
- }
1105
- });
1106
- var MessageGeneratedEvent = defineEvent({
1107
- meta: {
1108
- key: "agent.run.messageGenerated",
1109
- version: "1.0.0",
1110
- description: "An agent generated a message during a run.",
1111
- stability: "stable",
1112
- owners: [...OWNERS2],
1113
- tags: ["run", "message", "generated"]
1114
- },
1115
- payload: MessageGeneratedPayload
1116
- });
1117
-
1118
- // src/run/run.entity.ts
1119
- import {
1120
- defineEntity,
1121
- defineEntityEnum,
1122
- field,
1123
- index
1124
- } from "@contractspec/lib.schema";
1125
- var RunStatusEntityEnum = defineEntityEnum({
1126
- name: "RunStatus",
1127
- values: [
1128
- "QUEUED",
1129
- "IN_PROGRESS",
1130
- "COMPLETED",
1131
- "FAILED",
1132
- "CANCELLED",
1133
- "EXPIRED"
1134
- ],
1135
- description: "Status of an agent run"
1136
- });
1137
- var RunStepTypeEntityEnum = defineEntityEnum({
1138
- name: "RunStepType",
1139
- values: ["MESSAGE_CREATION", "TOOL_CALL", "TOOL_RESULT", "ERROR"],
1140
- description: "Type of run step"
1141
- });
1142
- var LogLevelEntityEnum = defineEntityEnum({
1143
- name: "LogLevel",
1144
- values: ["DEBUG", "INFO", "WARN", "ERROR"],
1145
- description: "Log level"
1146
- });
1147
- var RunEntity = defineEntity({
1148
- name: "Run",
1149
- schema: "agent_console",
1150
- description: "An execution of an agent with input/output and metrics.",
1151
- fields: {
1152
- id: field.id(),
1153
- organizationId: field.string({ description: "Organization ID" }),
1154
- agentId: field.foreignKey({ description: "Agent being executed" }),
1155
- userId: field.string({
1156
- isOptional: true,
1157
- description: "User who initiated the run"
1158
- }),
1159
- sessionId: field.string({
1160
- isOptional: true,
1161
- description: "Conversation session ID"
1162
- }),
1163
- input: field.json({ description: "Input data for the run" }),
1164
- output: field.json({
1165
- isOptional: true,
1166
- description: "Output result from the run"
1167
- }),
1168
- status: field.enum("RunStatus", { default: "QUEUED" }),
1169
- errorMessage: field.string({
1170
- isOptional: true,
1171
- description: "Error message if failed"
1172
- }),
1173
- errorCode: field.string({
1174
- isOptional: true,
1175
- description: "Error code if failed"
1176
- }),
1177
- totalTokens: field.int({ default: 0, description: "Total tokens used" }),
1178
- promptTokens: field.int({ default: 0, description: "Prompt tokens used" }),
1179
- completionTokens: field.int({
1180
- default: 0,
1181
- description: "Completion tokens used"
1182
- }),
1183
- totalIterations: field.int({
1184
- default: 0,
1185
- description: "Number of iterations"
1186
- }),
1187
- durationMs: field.int({
1188
- isOptional: true,
1189
- description: "Execution duration in ms"
1190
- }),
1191
- estimatedCostUsd: field.float({
1192
- isOptional: true,
1193
- description: "Estimated cost in USD"
1194
- }),
1195
- queuedAt: field.dateTime({ description: "When run was queued" }),
1196
- startedAt: field.dateTime({
1197
- isOptional: true,
1198
- description: "When run started executing"
1199
- }),
1200
- completedAt: field.dateTime({
1201
- isOptional: true,
1202
- description: "When run completed"
1203
- }),
1204
- metadata: field.json({
1205
- isOptional: true,
1206
- description: "Additional metadata"
1207
- }),
1208
- agent: field.belongsTo("Agent", ["agentId"], ["id"]),
1209
- steps: field.hasMany("RunStep", { description: "Execution steps" }),
1210
- logs: field.hasMany("RunLog", { description: "Execution logs" })
1211
- },
1212
- indexes: [
1213
- index.on(["organizationId", "agentId", "queuedAt"]),
1214
- index.on(["organizationId", "status"]),
1215
- index.on(["agentId", "status"]),
1216
- index.on(["sessionId"])
1217
- ],
1218
- enums: [RunStatusEntityEnum]
1219
- });
1220
- var RunStepEntity = defineEntity({
1221
- name: "RunStep",
1222
- schema: "agent_console",
1223
- description: "An individual step in an agent run.",
1224
- fields: {
1225
- id: field.id(),
1226
- runId: field.foreignKey({ description: "Parent run" }),
1227
- stepNumber: field.int({ description: "Step sequence number" }),
1228
- type: field.enum("RunStepType"),
1229
- toolId: field.string({
1230
- isOptional: true,
1231
- description: "Tool used in this step"
1232
- }),
1233
- toolName: field.string({ isOptional: true, description: "Tool name" }),
1234
- input: field.json({ isOptional: true, description: "Step input" }),
1235
- output: field.json({ isOptional: true, description: "Step output" }),
1236
- status: field.enum("RunStatus"),
1237
- errorMessage: field.string({ isOptional: true }),
1238
- tokensUsed: field.int({ default: 0 }),
1239
- durationMs: field.int({ isOptional: true }),
1240
- startedAt: field.dateTime(),
1241
- completedAt: field.dateTime({ isOptional: true }),
1242
- run: field.belongsTo("Run", ["runId"], ["id"])
1243
- },
1244
- indexes: [index.on(["runId", "stepNumber"])],
1245
- enums: [RunStepTypeEntityEnum]
1246
- });
1247
- var RunLogEntity = defineEntity({
1248
- name: "RunLog",
1249
- schema: "agent_console",
1250
- description: "A log entry for an agent run.",
1251
- fields: {
1252
- id: field.id(),
1253
- runId: field.foreignKey({ description: "Parent run" }),
1254
- stepId: field.string({ isOptional: true, description: "Related step" }),
1255
- level: field.enum("LogLevel"),
1256
- message: field.string({ description: "Log message" }),
1257
- data: field.json({ isOptional: true, description: "Additional log data" }),
1258
- source: field.string({
1259
- isOptional: true,
1260
- description: "Log source component"
1261
- }),
1262
- traceId: field.string({ isOptional: true }),
1263
- spanId: field.string({ isOptional: true }),
1264
- timestamp: field.dateTime(),
1265
- run: field.belongsTo("Run", ["runId"], ["id"])
1266
- },
1267
- indexes: [index.on(["runId", "timestamp"]), index.on(["runId", "level"])],
1268
- enums: [LogLevelEntityEnum]
1269
- });
1270
-
1271
1271
  // src/run/run.presentation.ts
1272
1272
  import {
1273
- StabilityEnum,
1274
- definePresentation
1273
+ definePresentation,
1274
+ StabilityEnum
1275
1275
  } from "@contractspec/lib.contracts-spec";
1276
1276
  var RunListPresentation = definePresentation({
1277
1277
  meta: {