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