@exaudeus/workrail 3.64.0 → 3.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/console-ui/assets/{index-DGM664Gr.js → index-BynU38Vu.js} +9 -9
  2. package/dist/console-ui/assets/{index-DGj8EsFR.css → index-DHrKiMCf.css} +1 -1
  3. package/dist/console-ui/index.html +2 -2
  4. package/dist/manifest.json +44 -36
  5. package/dist/mcp/handlers/v2-advance-core/outcome-success.js +65 -0
  6. package/dist/mcp/handlers/v2-advance-events.d.ts +11 -0
  7. package/dist/mcp/handlers/v2-advance-events.js +19 -0
  8. package/dist/mcp/output-schemas.d.ts +4 -4
  9. package/dist/types/workflow-definition.d.ts +1 -0
  10. package/dist/v2/durable-core/constants.d.ts +1 -0
  11. package/dist/v2/durable-core/constants.js +1 -0
  12. package/dist/v2/durable-core/domain/prompt-renderer.d.ts +1 -0
  13. package/dist/v2/durable-core/domain/prompt-renderer.js +40 -0
  14. package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +294 -0
  15. package/dist/v2/durable-core/schemas/session/events.d.ts +90 -0
  16. package/dist/v2/durable-core/schemas/session/events.js +16 -0
  17. package/dist/v2/projections/session-metrics.d.ts +15 -0
  18. package/dist/v2/projections/session-metrics.js +102 -0
  19. package/dist/v2/usecases/console-routes.js +59 -0
  20. package/dist/v2/usecases/console-service.js +18 -4
  21. package/dist/v2/usecases/console-types.d.ts +5 -0
  22. package/docs/authoring-v2.md +30 -7
  23. package/docs/authoring.md +28 -0
  24. package/package.json +1 -1
  25. package/spec/authoring-spec.json +37 -0
  26. package/spec/workflow.schema.json +5 -0
  27. package/workflows/adaptive-ticket-creation.json +2 -1
  28. package/workflows/architecture-scalability-audit.json +1 -0
  29. package/workflows/bug-investigation.agentic.v2.json +1 -0
  30. package/workflows/classify-task-workflow.json +1 -0
  31. package/workflows/coding-task-workflow-agentic.json +1 -0
  32. package/workflows/cross-platform-code-conversion.v2.json +8 -7
  33. package/workflows/document-creation-workflow.json +2 -1
  34. package/workflows/documentation-update-workflow.json +2 -1
  35. package/workflows/intelligent-test-case-generation.json +2 -1
  36. package/workflows/learner-centered-course-workflow.json +2 -1
  37. package/workflows/mr-review-workflow.agentic.v2.json +1 -0
  38. package/workflows/personal-learning-materials-creation-branched.json +1 -0
  39. package/workflows/presentation-creation.json +2 -1
  40. package/workflows/production-readiness-audit.json +1 -0
  41. package/workflows/relocation-workflow-us.json +1 -0
  42. package/workflows/routines/context-gathering.json +2 -1
  43. package/workflows/routines/design-review.json +1 -0
  44. package/workflows/routines/execution-simulation.json +2 -1
  45. package/workflows/routines/feature-implementation.json +4 -3
  46. package/workflows/routines/final-verification.json +1 -0
  47. package/workflows/routines/hypothesis-challenge.json +13 -3
  48. package/workflows/routines/ideation.json +1 -1
  49. package/workflows/routines/parallel-work-partitioning.json +1 -0
  50. package/workflows/routines/philosophy-alignment.json +2 -1
  51. package/workflows/routines/plan-analysis.json +2 -1
  52. package/workflows/routines/plan-generation.json +2 -1
  53. package/workflows/routines/tension-driven-design.json +1 -0
  54. package/workflows/scoped-documentation-workflow.json +2 -1
  55. package/workflows/test-artifact-loop-control.json +8 -2
  56. package/workflows/test-session-persistence.json +1 -0
  57. package/workflows/ui-ux-design-workflow.json +1 -0
  58. package/workflows/workflow-diagnose-environment.json +1 -0
  59. package/workflows/workflow-for-workflows.json +1 -0
  60. package/workflows/workflow-for-workflows.v2.json +28 -0
  61. package/workflows/wr.discovery.json +1 -0
  62. package/workflows/wr.shaping.json +21 -6
@@ -2261,11 +2261,11 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
2261
2261
  runId: string;
2262
2262
  workflowId: string;
2263
2263
  confidence: "strong" | "weak" | "medium";
2264
+ gitBranch: string | null;
2264
2265
  isComplete: boolean;
2265
2266
  pendingStepId: string | null;
2266
2267
  sessionTitle: string | null;
2267
2268
  lastModifiedMs: number | null;
2268
- gitBranch: string | null;
2269
2269
  nextCall: {
2270
2270
  params: {
2271
2271
  intent: "rehydrate";
@@ -2282,11 +2282,11 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
2282
2282
  runId: string;
2283
2283
  workflowId: string;
2284
2284
  confidence: "strong" | "weak" | "medium";
2285
+ gitBranch: string | null;
2285
2286
  isComplete: boolean;
2286
2287
  pendingStepId: string | null;
2287
2288
  sessionTitle: string | null;
2288
2289
  lastModifiedMs: number | null;
2289
- gitBranch: string | null;
2290
2290
  nextCall: {
2291
2291
  params: {
2292
2292
  intent: "rehydrate";
@@ -2306,11 +2306,11 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
2306
2306
  runId: string;
2307
2307
  workflowId: string;
2308
2308
  confidence: "strong" | "weak" | "medium";
2309
+ gitBranch: string | null;
2309
2310
  isComplete: boolean;
2310
2311
  pendingStepId: string | null;
2311
2312
  sessionTitle: string | null;
2312
2313
  lastModifiedMs: number | null;
2313
- gitBranch: string | null;
2314
2314
  nextCall: {
2315
2315
  params: {
2316
2316
  intent: "rehydrate";
@@ -2330,11 +2330,11 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
2330
2330
  runId: string;
2331
2331
  workflowId: string;
2332
2332
  confidence: "strong" | "weak" | "medium";
2333
+ gitBranch: string | null;
2333
2334
  isComplete: boolean;
2334
2335
  pendingStepId: string | null;
2335
2336
  sessionTitle: string | null;
2336
2337
  lastModifiedMs: number | null;
2337
- gitBranch: string | null;
2338
2338
  nextCall: {
2339
2339
  params: {
2340
2340
  intent: "rehydrate";
@@ -138,6 +138,7 @@ export interface WorkflowDefinition {
138
138
  readonly validatedAgainstSpecVersion?: number;
139
139
  readonly about?: string;
140
140
  readonly examples?: readonly string[];
141
+ readonly metricsProfile?: 'coding' | 'review' | 'research' | 'design' | 'ticket' | 'none';
141
142
  }
142
143
  export declare function isLoopStepDefinition(step: WorkflowStepDefinition | LoopStepDefinition): step is LoopStepDefinition;
143
144
  export declare function isWorkflowStepDefinition(step: WorkflowStepDefinition | LoopStepDefinition): step is WorkflowStepDefinition;
@@ -37,6 +37,7 @@ export declare const EVENT_KIND: {
37
37
  readonly CONTEXT_SET: "context_set";
38
38
  readonly DIVERGENCE_RECORDED: "divergence_recorded";
39
39
  readonly DECISION_TRACE_APPENDED: "decision_trace_appended";
40
+ readonly RUN_COMPLETED: "run_completed";
40
41
  };
41
42
  export type EventKindV1 = typeof EVENT_KIND[keyof typeof EVENT_KIND];
42
43
  export declare const OUTPUT_CHANNEL: {
@@ -40,6 +40,7 @@ exports.EVENT_KIND = {
40
40
  CONTEXT_SET: 'context_set',
41
41
  DIVERGENCE_RECORDED: 'divergence_recorded',
42
42
  DECISION_TRACE_APPENDED: 'decision_trace_appended',
43
+ RUN_COMPLETED: 'run_completed',
43
44
  };
44
45
  exports.OUTPUT_CHANNEL = {
45
46
  RECAP: 'recap',
@@ -9,6 +9,7 @@ export type PromptRenderError = {
9
9
  readonly message: string;
10
10
  };
11
11
  export declare function formatAssessmentRequirementsForTest(assessments: readonly Pick<AssessmentDefinition, 'id' | 'purpose' | 'dimensions'>[]): readonly string[];
12
+ export declare function buildMetricsSection(profile: 'coding' | 'review' | 'research' | 'design' | 'ticket' | 'none' | undefined, isLastStep: boolean, cleanFormat: boolean): string;
12
13
  export declare function assembleFragmentedPrompt(fragments: readonly PromptFragment[], context: Record<string, unknown>): string;
13
14
  export interface StepMetadata {
14
15
  readonly stepId: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatAssessmentRequirementsForTest = formatAssessmentRequirementsForTest;
4
+ exports.buildMetricsSection = buildMetricsSection;
4
5
  exports.assembleFragmentedPrompt = assembleFragmentedPrompt;
5
6
  exports.renderPendingPrompt = renderPendingPrompt;
6
7
  const neverthrow_1 = require("neverthrow");
@@ -204,6 +205,39 @@ function formatAssessmentRequirements(assessments) {
204
205
  }
205
206
  return requirements;
206
207
  }
208
+ function buildMetricsSection(profile, isLastStep, cleanFormat) {
209
+ if (!profile || profile === 'none')
210
+ return '';
211
+ switch (profile) {
212
+ case 'coding': {
213
+ const shaFooter = cleanFormat
214
+ ? '\n\nMetrics: update context.metrics_commit_shas with the FULL accumulated SHA list (shallow merge -- partial lists lose earlier commits).'
215
+ : '\n\n**METRICS (System):** This is a coding workflow. After each commit, update `context.metrics_commit_shas` with the FULL accumulated list of commit SHAs from this session -- not just the current step\'s commits. Context uses shallow merge: sending only new SHAs permanently loses earlier ones.\n\nCall `continue_workflow` with:\n- `context: { metrics_commit_shas: ["<sha1>", "<sha2>", ...] }` -- full list, every step that has commits';
216
+ if (!isLastStep)
217
+ return shaFooter;
218
+ const finalFooter = cleanFormat
219
+ ? '\n\nMetrics (final): also set metrics_outcome, metrics_pr_numbers, metrics_files_changed, metrics_lines_added, metrics_lines_removed in context.'
220
+ : '\n\n**METRICS (System):** This is the final step. Also report:\n- `metrics_outcome`: `"success"` | `"partial"` | `"abandoned"` | `"error"`\n- `metrics_pr_numbers`: array of integer PR numbers (not URLs)\n- `metrics_files_changed`: integer count\n- `metrics_lines_added`: integer count\n- `metrics_lines_removed`: integer count\n\nCall `continue_workflow` with all of the above in `context: { metrics_commit_shas: [...], metrics_outcome: "success", ... }`.';
221
+ return shaFooter + finalFooter;
222
+ }
223
+ case 'review': {
224
+ if (!isLastStep)
225
+ return '';
226
+ return cleanFormat
227
+ ? '\n\nMetrics (final): set metrics_pr_numbers (integer array) and metrics_outcome in context.'
228
+ : '\n\n**METRICS (System):** This is the final step of a review workflow. Report:\n- `metrics_pr_numbers`: array of integer PR numbers reviewed (not URLs)\n- `metrics_outcome`: `"success"` | `"partial"` | `"abandoned"` | `"error"`\n\nCall `continue_workflow` with `context: { metrics_pr_numbers: [123], metrics_outcome: "success" }`.';
229
+ }
230
+ case 'research':
231
+ case 'design':
232
+ case 'ticket': {
233
+ if (!isLastStep)
234
+ return '';
235
+ return cleanFormat
236
+ ? '\n\nMetrics (final): set metrics_outcome in context.'
237
+ : '\n\n**METRICS (System):** This is the final step. Report:\n- `metrics_outcome`: `"success"` | `"partial"` | `"abandoned"` | `"error"`\n\nCall `continue_workflow` with `context: { metrics_outcome: "success" }`.';
238
+ }
239
+ }
240
+ }
207
241
  function assembleFragmentedPrompt(fragments, context) {
208
242
  return fragments
209
243
  .filter(f => (0, condition_evaluator_js_1.evaluateCondition)(f.when, context))
@@ -336,6 +370,11 @@ function renderPendingPrompt(args) {
336
370
  const fragmentSuffix = promptFragments && promptFragments.length > 0
337
371
  ? assembleFragmentedPrompt(promptFragments, renderContext)
338
372
  : '';
373
+ const lastTopLevelStepId = args.workflow.definition.steps.at(-1)?.id;
374
+ const isLastTopLevelStep = args.stepId === lastTopLevelStepId;
375
+ const isLastExitStep = isExitStep && resolveParentLoopStep(args.workflow, args.stepId)?.id === lastTopLevelStepId;
376
+ const isLastStep = isLastTopLevelStep || isLastExitStep;
377
+ const metricsSection = buildMetricsSection(args.workflow.definition.metricsProfile, isLastStep, cleanResponseFormat);
339
378
  const enhancedPrompt = [
340
379
  loopBanner,
341
380
  basePrompt,
@@ -344,6 +383,7 @@ function renderPendingPrompt(args) {
344
383
  assessmentSection,
345
384
  notesSection,
346
385
  fragmentSuffix ? '\n\n' + fragmentSuffix : '',
386
+ metricsSection,
347
387
  ].join('');
348
388
  if (!args.rehydrateOnly) {
349
389
  return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: enhancedPrompt, agentRole, requireConfirmation });
@@ -2472,6 +2472,96 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
2472
2472
  traceId: string;
2473
2473
  };
2474
2474
  timestampMs: number;
2475
+ }>, z.ZodObject<{
2476
+ v: z.ZodLiteral<1>;
2477
+ eventId: z.ZodString;
2478
+ eventIndex: z.ZodNumber;
2479
+ sessionId: z.ZodString;
2480
+ dedupeKey: z.ZodString;
2481
+ timestampMs: z.ZodNumber;
2482
+ } & {
2483
+ kind: z.ZodLiteral<"run_completed">;
2484
+ scope: z.ZodObject<{
2485
+ runId: z.ZodString;
2486
+ }, "strip", z.ZodTypeAny, {
2487
+ runId: string;
2488
+ }, {
2489
+ runId: string;
2490
+ }>;
2491
+ data: z.ZodEffects<z.ZodObject<{
2492
+ startGitSha: z.ZodNullable<z.ZodString>;
2493
+ endGitSha: z.ZodNullable<z.ZodString>;
2494
+ gitBranch: z.ZodNullable<z.ZodString>;
2495
+ agentCommitShas: z.ZodArray<z.ZodString, "many">;
2496
+ captureConfidence: z.ZodEnum<["high", "none"]>;
2497
+ durationMs: z.ZodOptional<z.ZodNumber>;
2498
+ }, "strip", z.ZodTypeAny, {
2499
+ startGitSha: string | null;
2500
+ endGitSha: string | null;
2501
+ gitBranch: string | null;
2502
+ agentCommitShas: string[];
2503
+ captureConfidence: "high" | "none";
2504
+ durationMs?: number | undefined;
2505
+ }, {
2506
+ startGitSha: string | null;
2507
+ endGitSha: string | null;
2508
+ gitBranch: string | null;
2509
+ agentCommitShas: string[];
2510
+ captureConfidence: "high" | "none";
2511
+ durationMs?: number | undefined;
2512
+ }>, {
2513
+ startGitSha: string | null;
2514
+ endGitSha: string | null;
2515
+ gitBranch: string | null;
2516
+ agentCommitShas: string[];
2517
+ captureConfidence: "high" | "none";
2518
+ durationMs?: number | undefined;
2519
+ }, {
2520
+ startGitSha: string | null;
2521
+ endGitSha: string | null;
2522
+ gitBranch: string | null;
2523
+ agentCommitShas: string[];
2524
+ captureConfidence: "high" | "none";
2525
+ durationMs?: number | undefined;
2526
+ }>;
2527
+ }, "strip", z.ZodTypeAny, {
2528
+ kind: "run_completed";
2529
+ v: 1;
2530
+ sessionId: string;
2531
+ eventIndex: number;
2532
+ eventId: string;
2533
+ dedupeKey: string;
2534
+ scope: {
2535
+ runId: string;
2536
+ };
2537
+ data: {
2538
+ startGitSha: string | null;
2539
+ endGitSha: string | null;
2540
+ gitBranch: string | null;
2541
+ agentCommitShas: string[];
2542
+ captureConfidence: "high" | "none";
2543
+ durationMs?: number | undefined;
2544
+ };
2545
+ timestampMs: number;
2546
+ }, {
2547
+ kind: "run_completed";
2548
+ v: 1;
2549
+ sessionId: string;
2550
+ eventIndex: number;
2551
+ eventId: string;
2552
+ dedupeKey: string;
2553
+ scope: {
2554
+ runId: string;
2555
+ };
2556
+ data: {
2557
+ startGitSha: string | null;
2558
+ endGitSha: string | null;
2559
+ gitBranch: string | null;
2560
+ agentCommitShas: string[];
2561
+ captureConfidence: "high" | "none";
2562
+ durationMs?: number | undefined;
2563
+ };
2564
+ timestampMs: number;
2475
2565
  }>]>, "many">;
2476
2566
  manifest: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
2477
2567
  v: z.ZodLiteral<1>;
@@ -5196,6 +5286,25 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
5196
5286
  traceId: string;
5197
5287
  };
5198
5288
  timestampMs: number;
5289
+ } | {
5290
+ kind: "run_completed";
5291
+ v: 1;
5292
+ sessionId: string;
5293
+ eventIndex: number;
5294
+ eventId: string;
5295
+ dedupeKey: string;
5296
+ scope: {
5297
+ runId: string;
5298
+ };
5299
+ data: {
5300
+ startGitSha: string | null;
5301
+ endGitSha: string | null;
5302
+ gitBranch: string | null;
5303
+ agentCommitShas: string[];
5304
+ captureConfidence: "high" | "none";
5305
+ durationMs?: number | undefined;
5306
+ };
5307
+ timestampMs: number;
5199
5308
  })[];
5200
5309
  manifest: ({
5201
5310
  kind: "segment_closed";
@@ -5790,6 +5899,25 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
5790
5899
  traceId: string;
5791
5900
  };
5792
5901
  timestampMs: number;
5902
+ } | {
5903
+ kind: "run_completed";
5904
+ v: 1;
5905
+ sessionId: string;
5906
+ eventIndex: number;
5907
+ eventId: string;
5908
+ dedupeKey: string;
5909
+ scope: {
5910
+ runId: string;
5911
+ };
5912
+ data: {
5913
+ startGitSha: string | null;
5914
+ endGitSha: string | null;
5915
+ gitBranch: string | null;
5916
+ agentCommitShas: string[];
5917
+ captureConfidence: "high" | "none";
5918
+ durationMs?: number | undefined;
5919
+ };
5920
+ timestampMs: number;
5793
5921
  })[];
5794
5922
  manifest: ({
5795
5923
  kind: "segment_closed";
@@ -8274,6 +8402,96 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
8274
8402
  traceId: string;
8275
8403
  };
8276
8404
  timestampMs: number;
8405
+ }>, z.ZodObject<{
8406
+ v: z.ZodLiteral<1>;
8407
+ eventId: z.ZodString;
8408
+ eventIndex: z.ZodNumber;
8409
+ sessionId: z.ZodString;
8410
+ dedupeKey: z.ZodString;
8411
+ timestampMs: z.ZodNumber;
8412
+ } & {
8413
+ kind: z.ZodLiteral<"run_completed">;
8414
+ scope: z.ZodObject<{
8415
+ runId: z.ZodString;
8416
+ }, "strip", z.ZodTypeAny, {
8417
+ runId: string;
8418
+ }, {
8419
+ runId: string;
8420
+ }>;
8421
+ data: z.ZodEffects<z.ZodObject<{
8422
+ startGitSha: z.ZodNullable<z.ZodString>;
8423
+ endGitSha: z.ZodNullable<z.ZodString>;
8424
+ gitBranch: z.ZodNullable<z.ZodString>;
8425
+ agentCommitShas: z.ZodArray<z.ZodString, "many">;
8426
+ captureConfidence: z.ZodEnum<["high", "none"]>;
8427
+ durationMs: z.ZodOptional<z.ZodNumber>;
8428
+ }, "strip", z.ZodTypeAny, {
8429
+ startGitSha: string | null;
8430
+ endGitSha: string | null;
8431
+ gitBranch: string | null;
8432
+ agentCommitShas: string[];
8433
+ captureConfidence: "high" | "none";
8434
+ durationMs?: number | undefined;
8435
+ }, {
8436
+ startGitSha: string | null;
8437
+ endGitSha: string | null;
8438
+ gitBranch: string | null;
8439
+ agentCommitShas: string[];
8440
+ captureConfidence: "high" | "none";
8441
+ durationMs?: number | undefined;
8442
+ }>, {
8443
+ startGitSha: string | null;
8444
+ endGitSha: string | null;
8445
+ gitBranch: string | null;
8446
+ agentCommitShas: string[];
8447
+ captureConfidence: "high" | "none";
8448
+ durationMs?: number | undefined;
8449
+ }, {
8450
+ startGitSha: string | null;
8451
+ endGitSha: string | null;
8452
+ gitBranch: string | null;
8453
+ agentCommitShas: string[];
8454
+ captureConfidence: "high" | "none";
8455
+ durationMs?: number | undefined;
8456
+ }>;
8457
+ }, "strip", z.ZodTypeAny, {
8458
+ kind: "run_completed";
8459
+ v: 1;
8460
+ sessionId: string;
8461
+ eventIndex: number;
8462
+ eventId: string;
8463
+ dedupeKey: string;
8464
+ scope: {
8465
+ runId: string;
8466
+ };
8467
+ data: {
8468
+ startGitSha: string | null;
8469
+ endGitSha: string | null;
8470
+ gitBranch: string | null;
8471
+ agentCommitShas: string[];
8472
+ captureConfidence: "high" | "none";
8473
+ durationMs?: number | undefined;
8474
+ };
8475
+ timestampMs: number;
8476
+ }, {
8477
+ kind: "run_completed";
8478
+ v: 1;
8479
+ sessionId: string;
8480
+ eventIndex: number;
8481
+ eventId: string;
8482
+ dedupeKey: string;
8483
+ scope: {
8484
+ runId: string;
8485
+ };
8486
+ data: {
8487
+ startGitSha: string | null;
8488
+ endGitSha: string | null;
8489
+ gitBranch: string | null;
8490
+ agentCommitShas: string[];
8491
+ captureConfidence: "high" | "none";
8492
+ durationMs?: number | undefined;
8493
+ };
8494
+ timestampMs: number;
8277
8495
  }>]>, "many">;
8278
8496
  manifest: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
8279
8497
  v: z.ZodLiteral<1>;
@@ -10998,6 +11216,25 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
10998
11216
  traceId: string;
10999
11217
  };
11000
11218
  timestampMs: number;
11219
+ } | {
11220
+ kind: "run_completed";
11221
+ v: 1;
11222
+ sessionId: string;
11223
+ eventIndex: number;
11224
+ eventId: string;
11225
+ dedupeKey: string;
11226
+ scope: {
11227
+ runId: string;
11228
+ };
11229
+ data: {
11230
+ startGitSha: string | null;
11231
+ endGitSha: string | null;
11232
+ gitBranch: string | null;
11233
+ agentCommitShas: string[];
11234
+ captureConfidence: "high" | "none";
11235
+ durationMs?: number | undefined;
11236
+ };
11237
+ timestampMs: number;
11001
11238
  })[];
11002
11239
  manifest: ({
11003
11240
  kind: "segment_closed";
@@ -11592,6 +11829,25 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
11592
11829
  traceId: string;
11593
11830
  };
11594
11831
  timestampMs: number;
11832
+ } | {
11833
+ kind: "run_completed";
11834
+ v: 1;
11835
+ sessionId: string;
11836
+ eventIndex: number;
11837
+ eventId: string;
11838
+ dedupeKey: string;
11839
+ scope: {
11840
+ runId: string;
11841
+ };
11842
+ data: {
11843
+ startGitSha: string | null;
11844
+ endGitSha: string | null;
11845
+ gitBranch: string | null;
11846
+ agentCommitShas: string[];
11847
+ captureConfidence: "high" | "none";
11848
+ durationMs?: number | undefined;
11849
+ };
11850
+ timestampMs: number;
11595
11851
  })[];
11596
11852
  manifest: ({
11597
11853
  kind: "segment_closed";
@@ -12215,6 +12471,25 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
12215
12471
  traceId: string;
12216
12472
  };
12217
12473
  timestampMs: number;
12474
+ } | {
12475
+ kind: "run_completed";
12476
+ v: 1;
12477
+ sessionId: string;
12478
+ eventIndex: number;
12479
+ eventId: string;
12480
+ dedupeKey: string;
12481
+ scope: {
12482
+ runId: string;
12483
+ };
12484
+ data: {
12485
+ startGitSha: string | null;
12486
+ endGitSha: string | null;
12487
+ gitBranch: string | null;
12488
+ agentCommitShas: string[];
12489
+ captureConfidence: "high" | "none";
12490
+ durationMs?: number | undefined;
12491
+ };
12492
+ timestampMs: number;
12218
12493
  })[];
12219
12494
  manifest: ({
12220
12495
  kind: "segment_closed";
@@ -12826,6 +13101,25 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
12826
13101
  traceId: string;
12827
13102
  };
12828
13103
  timestampMs: number;
13104
+ } | {
13105
+ kind: "run_completed";
13106
+ v: 1;
13107
+ sessionId: string;
13108
+ eventIndex: number;
13109
+ eventId: string;
13110
+ dedupeKey: string;
13111
+ scope: {
13112
+ runId: string;
13113
+ };
13114
+ data: {
13115
+ startGitSha: string | null;
13116
+ endGitSha: string | null;
13117
+ gitBranch: string | null;
13118
+ agentCommitShas: string[];
13119
+ captureConfidence: "high" | "none";
13120
+ durationMs?: number | undefined;
13121
+ };
13122
+ timestampMs: number;
12829
13123
  })[];
12830
13124
  manifest: ({
12831
13125
  kind: "segment_closed";
@@ -2460,5 +2460,95 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
2460
2460
  traceId: string;
2461
2461
  };
2462
2462
  timestampMs: number;
2463
+ }>, z.ZodObject<{
2464
+ v: z.ZodLiteral<1>;
2465
+ eventId: z.ZodString;
2466
+ eventIndex: z.ZodNumber;
2467
+ sessionId: z.ZodString;
2468
+ dedupeKey: z.ZodString;
2469
+ timestampMs: z.ZodNumber;
2470
+ } & {
2471
+ kind: z.ZodLiteral<"run_completed">;
2472
+ scope: z.ZodObject<{
2473
+ runId: z.ZodString;
2474
+ }, "strip", z.ZodTypeAny, {
2475
+ runId: string;
2476
+ }, {
2477
+ runId: string;
2478
+ }>;
2479
+ data: z.ZodEffects<z.ZodObject<{
2480
+ startGitSha: z.ZodNullable<z.ZodString>;
2481
+ endGitSha: z.ZodNullable<z.ZodString>;
2482
+ gitBranch: z.ZodNullable<z.ZodString>;
2483
+ agentCommitShas: z.ZodArray<z.ZodString, "many">;
2484
+ captureConfidence: z.ZodEnum<["high", "none"]>;
2485
+ durationMs: z.ZodOptional<z.ZodNumber>;
2486
+ }, "strip", z.ZodTypeAny, {
2487
+ startGitSha: string | null;
2488
+ endGitSha: string | null;
2489
+ gitBranch: string | null;
2490
+ agentCommitShas: string[];
2491
+ captureConfidence: "high" | "none";
2492
+ durationMs?: number | undefined;
2493
+ }, {
2494
+ startGitSha: string | null;
2495
+ endGitSha: string | null;
2496
+ gitBranch: string | null;
2497
+ agentCommitShas: string[];
2498
+ captureConfidence: "high" | "none";
2499
+ durationMs?: number | undefined;
2500
+ }>, {
2501
+ startGitSha: string | null;
2502
+ endGitSha: string | null;
2503
+ gitBranch: string | null;
2504
+ agentCommitShas: string[];
2505
+ captureConfidence: "high" | "none";
2506
+ durationMs?: number | undefined;
2507
+ }, {
2508
+ startGitSha: string | null;
2509
+ endGitSha: string | null;
2510
+ gitBranch: string | null;
2511
+ agentCommitShas: string[];
2512
+ captureConfidence: "high" | "none";
2513
+ durationMs?: number | undefined;
2514
+ }>;
2515
+ }, "strip", z.ZodTypeAny, {
2516
+ kind: "run_completed";
2517
+ v: 1;
2518
+ sessionId: string;
2519
+ eventIndex: number;
2520
+ eventId: string;
2521
+ dedupeKey: string;
2522
+ scope: {
2523
+ runId: string;
2524
+ };
2525
+ data: {
2526
+ startGitSha: string | null;
2527
+ endGitSha: string | null;
2528
+ gitBranch: string | null;
2529
+ agentCommitShas: string[];
2530
+ captureConfidence: "high" | "none";
2531
+ durationMs?: number | undefined;
2532
+ };
2533
+ timestampMs: number;
2534
+ }, {
2535
+ kind: "run_completed";
2536
+ v: 1;
2537
+ sessionId: string;
2538
+ eventIndex: number;
2539
+ eventId: string;
2540
+ dedupeKey: string;
2541
+ scope: {
2542
+ runId: string;
2543
+ };
2544
+ data: {
2545
+ startGitSha: string | null;
2546
+ endGitSha: string | null;
2547
+ gitBranch: string | null;
2548
+ agentCommitShas: string[];
2549
+ captureConfidence: "high" | "none";
2550
+ durationMs?: number | undefined;
2551
+ };
2552
+ timestampMs: number;
2463
2553
  }>]>;
2464
2554
  export type DomainEventV1 = z.infer<typeof DomainEventV1Schema>;
@@ -257,4 +257,20 @@ exports.DomainEventV1Schema = zod_1.z.discriminatedUnion('kind', [
257
257
  return totalBytes <= constants_js_1.MAX_DECISION_TRACE_TOTAL_BYTES;
258
258
  }, { message: `Decision trace total bytes exceeds ${constants_js_1.MAX_DECISION_TRACE_TOTAL_BYTES}` }),
259
259
  }),
260
+ exports.DomainEventEnvelopeV1Schema.extend({
261
+ kind: zod_1.z.literal('run_completed'),
262
+ scope: zod_1.z.object({ runId: zod_1.z.string().min(1) }),
263
+ data: zod_1.z.object({
264
+ startGitSha: zod_1.z.string().nullable(),
265
+ endGitSha: zod_1.z.string().nullable(),
266
+ gitBranch: zod_1.z.string().nullable(),
267
+ agentCommitShas: zod_1.z.array(zod_1.z.string()),
268
+ captureConfidence: zod_1.z.enum(['high', 'none']),
269
+ durationMs: zod_1.z.number().optional(),
270
+ }).superRefine((d, ctx) => {
271
+ if (d.captureConfidence === 'high' && d.agentCommitShas.length === 0) {
272
+ ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message: "captureConfidence 'high' requires at least one agentCommitSha" });
273
+ }
274
+ }),
275
+ }),
260
276
  ]);
@@ -0,0 +1,15 @@
1
+ import type { DomainEventV1 } from '../durable-core/schemas/session/index.js';
2
+ export interface SessionMetricsV2 {
3
+ readonly startGitSha: string | null;
4
+ readonly endGitSha: string | null;
5
+ readonly gitBranch: string | null;
6
+ readonly agentCommitShas: readonly string[];
7
+ readonly captureConfidence: 'high' | 'medium' | 'none';
8
+ readonly durationMs: number | undefined;
9
+ readonly outcome: 'success' | 'partial' | 'abandoned' | 'error' | null;
10
+ readonly prNumbers: readonly number[];
11
+ readonly filesChanged: number | null;
12
+ readonly linesAdded: number | null;
13
+ readonly linesRemoved: number | null;
14
+ }
15
+ export declare function projectSessionMetricsV2(events: readonly DomainEventV1[]): SessionMetricsV2 | null;