@evalops/maestro 0.10.29 → 0.10.30

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.
package/dist/cli.js CHANGED
@@ -64435,34 +64435,6 @@ var init_semantic_judge = __esm2(() => {
64435
64435
  init_logger();
64436
64436
  logger50 = createLogger("safety:semantic-judge");
64437
64437
  });
64438
- function normalizeSkillArtifactMetadata(value) {
64439
- if (!value || typeof value !== "object" || Array.isArray(value)) {
64440
- return;
64441
- }
64442
- const candidate = value;
64443
- if (typeof candidate.name !== "string" || candidate.name.trim().length === 0 || typeof candidate.hash !== "string" || candidate.hash.trim().length === 0 || typeof candidate.source !== "string" || candidate.source.trim().length === 0) {
64444
- return;
64445
- }
64446
- return {
64447
- name: candidate.name.trim(),
64448
- hash: candidate.hash.trim(),
64449
- source: candidate.source.trim(),
64450
- ...typeof candidate.artifactId === "string" && candidate.artifactId.trim().length > 0 ? { artifactId: candidate.artifactId.trim() } : {},
64451
- ...typeof candidate.version === "string" && candidate.version.trim().length > 0 ? { version: candidate.version.trim() } : {},
64452
- ...typeof candidate.sourcePath === "string" && candidate.sourcePath.trim().length > 0 ? { sourcePath: candidate.sourcePath.trim() } : {},
64453
- ...typeof candidate.scope === "string" && candidate.scope.trim().length > 0 ? { scope: candidate.scope.trim() } : {},
64454
- ...typeof candidate.workspaceId === "string" && candidate.workspaceId.trim().length > 0 ? { workspaceId: candidate.workspaceId.trim() } : {},
64455
- ...typeof candidate.ownerId === "string" && candidate.ownerId.trim().length > 0 ? { ownerId: candidate.ownerId.trim() } : {}
64456
- };
64457
- }
64458
- function getSkillArtifactMetadataFromDetails(details) {
64459
- if (!details || typeof details !== "object" || Array.isArray(details)) {
64460
- return;
64461
- }
64462
- return normalizeSkillArtifactMetadata(details.skillMetadata);
64463
- }
64464
- var init_artifact_metadata = () => {
64465
- };
64466
64438
  function isReadOnlyTool(toolName, annotations, _source) {
64467
64439
  if (annotations?.readOnlyHint === true) {
64468
64440
  return true;
@@ -72154,6 +72126,95 @@ async function* createProviderStream(model, context2, options, reasoning) {
72154
72126
  }
72155
72127
  throw new Error(`Unsupported API: ${model.api}`);
72156
72128
  }
72129
+ function normalizeSkillArtifactMetadata(value) {
72130
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
72131
+ return;
72132
+ }
72133
+ const candidate = value;
72134
+ if (typeof candidate.name !== "string" || candidate.name.trim().length === 0 || typeof candidate.hash !== "string" || candidate.hash.trim().length === 0 || typeof candidate.source !== "string" || candidate.source.trim().length === 0) {
72135
+ return;
72136
+ }
72137
+ return {
72138
+ name: candidate.name.trim(),
72139
+ hash: candidate.hash.trim(),
72140
+ source: candidate.source.trim(),
72141
+ ...typeof candidate.artifactId === "string" && candidate.artifactId.trim().length > 0 ? { artifactId: candidate.artifactId.trim() } : {},
72142
+ ...typeof candidate.version === "string" && candidate.version.trim().length > 0 ? { version: candidate.version.trim() } : {},
72143
+ ...typeof candidate.sourcePath === "string" && candidate.sourcePath.trim().length > 0 ? { sourcePath: candidate.sourcePath.trim() } : {},
72144
+ ...typeof candidate.scope === "string" && candidate.scope.trim().length > 0 ? { scope: candidate.scope.trim() } : {},
72145
+ ...typeof candidate.workspaceId === "string" && candidate.workspaceId.trim().length > 0 ? { workspaceId: candidate.workspaceId.trim() } : {},
72146
+ ...typeof candidate.ownerId === "string" && candidate.ownerId.trim().length > 0 ? { ownerId: candidate.ownerId.trim() } : {}
72147
+ };
72148
+ }
72149
+ function getSkillArtifactMetadataFromDetails(details) {
72150
+ if (!details || typeof details !== "object" || Array.isArray(details)) {
72151
+ return;
72152
+ }
72153
+ return normalizeSkillArtifactMetadata(details.skillMetadata);
72154
+ }
72155
+ var init_artifact_metadata = () => {
72156
+ };
72157
+ var AgentEventQueue = class {
72158
+ events = [];
72159
+ pending;
72160
+ wake;
72161
+ push(event) {
72162
+ this.events.push(event);
72163
+ if (this.wake) {
72164
+ const wake = this.wake;
72165
+ this.pending = void 0;
72166
+ this.wake = void 0;
72167
+ wake();
72168
+ }
72169
+ }
72170
+ shift() {
72171
+ return this.events.shift();
72172
+ }
72173
+ wait() {
72174
+ if (this.events.length > 0) {
72175
+ return Promise.resolve();
72176
+ }
72177
+ if (!this.pending) {
72178
+ this.pending = new Promise((resolve192) => {
72179
+ this.wake = resolve192;
72180
+ });
72181
+ }
72182
+ return this.pending;
72183
+ }
72184
+ clearPendingWaiter() {
72185
+ this.pending = void 0;
72186
+ this.wake = void 0;
72187
+ }
72188
+ };
72189
+ function isDynamicToolApprovalEvent(event) {
72190
+ return event.type === "action_approval_required" || event.type === "action_approval_resolved";
72191
+ }
72192
+ function getGovernedToolResultEventMetadata(details) {
72193
+ if (!details || typeof details !== "object") {
72194
+ return {};
72195
+ }
72196
+ const governedOutcome = details.governedOutcome;
72197
+ if (!governedOutcome || typeof governedOutcome !== "object") {
72198
+ return {};
72199
+ }
72200
+ const normalized = governedOutcome;
72201
+ const classification = typeof normalized.classification === "string" ? normalized.classification : void 0;
72202
+ const errorCode = typeof normalized.code === "string" && normalized.code.trim().length > 0 ? normalized.code.trim() : classification;
72203
+ const approvalRequestId = typeof normalized.approvalRequestId === "string" && normalized.approvalRequestId.trim().length > 0 ? normalized.approvalRequestId.trim() : void 0;
72204
+ return {
72205
+ errorCode,
72206
+ approvalRequestId,
72207
+ governedOutcome: classification
72208
+ };
72209
+ }
72210
+ function getSkillToolResultEventMetadata(details) {
72211
+ return {
72212
+ skillMetadata: getSkillArtifactMetadataFromDetails(details)
72213
+ };
72214
+ }
72215
+ var init_events = __esm2(() => {
72216
+ init_artifact_metadata();
72217
+ });
72157
72218
  function stripTrailingSlashes2(value) {
72158
72219
  return value.replace(/\/+$/u, "");
72159
72220
  }
@@ -83730,64 +83791,6 @@ async function waitForNextExecutionOrUpdate(pendingExecutions, updateQueue) {
83730
83791
  }
83731
83792
  return next;
83732
83793
  }
83733
- var AgentEventQueue = class {
83734
- events = [];
83735
- pending;
83736
- wake;
83737
- push(event) {
83738
- this.events.push(event);
83739
- if (this.wake) {
83740
- const wake = this.wake;
83741
- this.pending = void 0;
83742
- this.wake = void 0;
83743
- wake();
83744
- }
83745
- }
83746
- shift() {
83747
- return this.events.shift();
83748
- }
83749
- wait() {
83750
- if (this.events.length > 0) {
83751
- return Promise.resolve();
83752
- }
83753
- if (!this.pending) {
83754
- this.pending = new Promise((resolve202) => {
83755
- this.wake = resolve202;
83756
- });
83757
- }
83758
- return this.pending;
83759
- }
83760
- clearPendingWaiter() {
83761
- this.pending = void 0;
83762
- this.wake = void 0;
83763
- }
83764
- };
83765
- function isDynamicToolApprovalEvent(event) {
83766
- return event.type === "action_approval_required" || event.type === "action_approval_resolved";
83767
- }
83768
- function getGovernedToolResultEventMetadata(details) {
83769
- if (!details || typeof details !== "object") {
83770
- return {};
83771
- }
83772
- const governedOutcome = details.governedOutcome;
83773
- if (!governedOutcome || typeof governedOutcome !== "object") {
83774
- return {};
83775
- }
83776
- const normalized = governedOutcome;
83777
- const classification = typeof normalized.classification === "string" ? normalized.classification : void 0;
83778
- const errorCode = typeof normalized.code === "string" && normalized.code.trim().length > 0 ? normalized.code.trim() : classification;
83779
- const approvalRequestId = typeof normalized.approvalRequestId === "string" && normalized.approvalRequestId.trim().length > 0 ? normalized.approvalRequestId.trim() : void 0;
83780
- return {
83781
- errorCode,
83782
- approvalRequestId,
83783
- governedOutcome: classification
83784
- };
83785
- }
83786
- function getSkillToolResultEventMetadata(details) {
83787
- return {
83788
- skillMetadata: getSkillArtifactMetadataFromDetails(details)
83789
- };
83790
- }
83791
83794
  var ProviderTransport = class _ProviderTransport {
83792
83795
  options;
83793
83796
  workflowState = new WorkflowStateTracker();
@@ -85352,11 +85355,11 @@ var init_transport = __esm2(() => {
85352
85355
  init_safety_middleware();
85353
85356
  init_semantic_judge();
85354
85357
  init_workflow_state();
85355
- init_artifact_metadata();
85356
85358
  init_parallel_execution();
85357
85359
  init_cost_tracker();
85358
85360
  init_training();
85359
85361
  init_keys();
85362
+ init_events();
85360
85363
  init_reusable_tool_results();
85361
85364
  init_tool_execution();
85362
85365
  init_tool_safety_pipeline();
@@ -196854,6 +196857,32 @@ function waitTypeForEntry(kind, timelineItem) {
196854
196857
  return "AGENT_RUN_WAIT_TYPE_INPUT";
196855
196858
  return "AGENT_RUN_WAIT_TYPE_APPROVAL";
196856
196859
  }
196860
+ function firstEvidenceIdForEvent(event, kind) {
196861
+ return event.evidence.find((anchor) => anchor.kind === kind)?.id;
196862
+ }
196863
+ function hasCorrelation(correlation) {
196864
+ return Object.values(correlation).some((value) => typeof value === "string" && value.length > 0);
196865
+ }
196866
+ function correlationForEvent(event, timelineItem) {
196867
+ const pendingRequestId = timelineItem?.pendingRequestId ?? firstEvidenceIdForEvent(event, "pending_request");
196868
+ const approvalRequestId = timelineItem?.approvalRequestId ?? firstEvidenceIdForEvent(event, "approval_request");
196869
+ const toolExecutionId = timelineItem?.toolExecutionId ?? firstEvidenceIdForEvent(event, "tool_execution");
196870
+ const artifactId = timelineItem?.artifactId ?? firstEvidenceIdForEvent(event, "artifact");
196871
+ const agentRunId = timelineItem?.agentRunId ?? firstEvidenceIdForEvent(event, "agent_run");
196872
+ const parentAgentRunId = timelineItem?.parentAgentRunId ?? firstEvidenceIdForEvent(event, "parent_agent_run");
196873
+ const childAgentRunId = timelineItem?.childAgentRunId ?? firstEvidenceIdForEvent(event, "child_agent_run");
196874
+ const correlation = {
196875
+ ...pendingRequestId ? { pendingRequestId } : {},
196876
+ ...timelineItem?.pendingRequestKind ? { pendingRequestKind: timelineItem.pendingRequestKind } : {},
196877
+ ...approvalRequestId ? { approvalRequestId } : {},
196878
+ ...toolExecutionId ? { toolExecutionId } : {},
196879
+ ...artifactId ? { artifactId } : {},
196880
+ ...agentRunId ? { agentRunId } : {},
196881
+ ...parentAgentRunId ? { parentAgentRunId } : {},
196882
+ ...childAgentRunId ? { childAgentRunId } : {}
196883
+ };
196884
+ return hasCorrelation(correlation) ? correlation : void 0;
196885
+ }
196857
196886
  function buildLedgerEntries(timeline, trajectory) {
196858
196887
  const timelineItemsById = new Map(timeline.items.map((item) => [item.id, item]));
196859
196888
  return trajectory.events.map((event) => {
@@ -196862,6 +196891,7 @@ function buildLedgerEntries(timeline, trajectory) {
196862
196891
  const timelineItemId = timelineIdForEvent(event);
196863
196892
  const timelineItem = timelineItemId ? timelineItemsById.get(timelineItemId) : void 0;
196864
196893
  const waitType = waitTypeForEntry(kind, timelineItem);
196894
+ const correlation = correlationForEvent(event, timelineItem);
196865
196895
  return {
196866
196896
  id: `ledger:${event.id}`,
196867
196897
  sequence: event.sequence,
@@ -196880,6 +196910,7 @@ function buildLedgerEntries(timeline, trajectory) {
196880
196910
  ...event.summary ? { summary: event.summary } : {},
196881
196911
  relatedIds: event.relatedIds ?? [],
196882
196912
  evidence: event.evidence,
196913
+ ...correlation ? { correlation } : {},
196883
196914
  platformShape: {
196884
196915
  stepKind: stepKindForEntry(kind, event),
196885
196916
  workItemKind: workItemKindForEntry(kind),
@@ -196961,7 +196992,8 @@ function workItemPayloadForEntry(sessionId, entry2) {
196961
196992
  ...entry2.timelineItemId ? { timelineItemId: entry2.timelineItemId } : {},
196962
196993
  ...entry2.toolName ? { toolName: entry2.toolName } : {},
196963
196994
  ...entry2.summary ? { summary: entry2.summary } : {},
196964
- ...entry2.relatedIds.length > 0 ? { relatedIds: entry2.relatedIds } : {}
196995
+ ...entry2.relatedIds.length > 0 ? { relatedIds: entry2.relatedIds } : {},
196996
+ ...entry2.correlation ? { correlation: entry2.correlation } : {}
196965
196997
  };
196966
196998
  }
196967
196999
  function terminalEntry(entries) {
@@ -196988,6 +197020,11 @@ function terminalOperation(runId, entries) {
196988
197020
  payload: {
196989
197021
  state: succeeded ? "succeeded" : "failed",
196990
197022
  timestamp: terminal.timestamp,
197023
+ ledgerEntryId: terminal.id,
197024
+ trajectoryEventId: terminal.trajectoryEventId,
197025
+ eventType: terminal.type,
197026
+ title: terminal.title,
197027
+ evidenceRefs: evidenceRefsForEntry(terminal),
196991
197028
  ...succeeded ? {} : {
196992
197029
  reason: `Terminal ledger entry ended in ${terminal.state} state.`
196993
197030
  }
@@ -197023,7 +197060,8 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
197023
197060
  }
197024
197061
  ];
197025
197062
  for (const entry2 of entries) {
197026
- const toolExecutionId = firstEvidenceId2(entry2, "tool_execution");
197063
+ const correlation = entry2.correlation ?? {};
197064
+ const toolExecutionId = correlation.toolExecutionId ?? firstEvidenceId2(entry2, "tool_execution");
197027
197065
  const evidenceRefs = evidenceRefsForEntry(entry2);
197028
197066
  const waitId = entry2.platformShape.waitType ? entry2.id : void 0;
197029
197067
  operations.push({
@@ -197050,6 +197088,7 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
197050
197088
  title: entry2.title,
197051
197089
  timestamp: entry2.timestamp,
197052
197090
  ...waitId ? { waitId } : {},
197091
+ ...correlation,
197053
197092
  ...toolExecutionId ? { toolExecutionId } : {},
197054
197093
  evidenceRefs,
197055
197094
  completionGate: "maestro_agent_runtime_ledger_recorded",
@@ -197065,7 +197104,8 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
197065
197104
  waitId: entry2.id,
197066
197105
  waitType: entry2.platformShape.waitType,
197067
197106
  title: entry2.title,
197068
- timestamp: entry2.timestamp
197107
+ timestamp: entry2.timestamp,
197108
+ ...correlation
197069
197109
  }
197070
197110
  });
197071
197111
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evalops/contracts",
3
- "version": "0.10.29",
3
+ "version": "0.10.30",
4
4
  "description": "Shared Maestro contracts for frontend/backend integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evalops/tui",
3
- "version": "0.10.29",
3
+ "version": "0.10.30",
4
4
  "description": "Terminal UI library with differential rendering for Maestro",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -7,6 +7,16 @@ export declare const AGENT_RUNTIME_PROMOTION_PLAN_SCHEMA = "evalops.maestro.agen
7
7
  export type AgentRuntimeLedgerEntryKind = "run" | "message" | "model_call" | "tool_call" | "tool_result" | "wait" | "checkpoint" | "artifact" | "evidence" | "governance" | "context" | "child_run" | "runtime";
8
8
  export type AgentRuntimeLedgerState = "pending" | "running" | "waiting" | "blocked" | "succeeded" | "failed" | "cancelled" | "skipped";
9
9
  type AgentRuntimePromotionStepState = Exclude<AgentRuntimeLedgerState, "blocked">;
10
+ export interface AgentRuntimeLedgerCorrelation {
11
+ pendingRequestId?: string;
12
+ pendingRequestKind?: ComposerRunTimelineItem["pendingRequestKind"];
13
+ approvalRequestId?: string;
14
+ toolExecutionId?: string;
15
+ artifactId?: string;
16
+ agentRunId?: string;
17
+ parentAgentRunId?: string;
18
+ childAgentRunId?: string;
19
+ }
10
20
  export interface AgentRuntimeLedgerEntry {
11
21
  id: string;
12
22
  sequence: number;
@@ -25,6 +35,7 @@ export interface AgentRuntimeLedgerEntry {
25
35
  summary?: string;
26
36
  relatedIds: string[];
27
37
  evidence: AgentTrajectoryEvent["evidence"];
38
+ correlation?: AgentRuntimeLedgerCorrelation;
28
39
  platformShape: {
29
40
  stepKind: string;
30
41
  workItemKind: string;
@@ -106,11 +117,10 @@ export type AgentRuntimePromotionOperation = {
106
117
  title: string;
107
118
  timestamp: string;
108
119
  waitId?: string;
109
- toolExecutionId?: string;
110
120
  evidenceRefs?: string[];
111
121
  completionGate?: string;
112
122
  payload?: Record<string, unknown>;
113
- };
123
+ } & AgentRuntimeLedgerCorrelation;
114
124
  } | {
115
125
  operation: "wait_run";
116
126
  id: string;
@@ -120,7 +130,7 @@ export type AgentRuntimePromotionOperation = {
120
130
  waitType: string;
121
131
  title: string;
122
132
  timestamp: string;
123
- };
133
+ } & AgentRuntimeLedgerCorrelation;
124
134
  } | {
125
135
  operation: "complete_run" | "fail_run";
126
136
  id: string;
@@ -128,6 +138,11 @@ export type AgentRuntimePromotionOperation = {
128
138
  state: "succeeded" | "failed";
129
139
  timestamp: string;
130
140
  reason?: string;
141
+ ledgerEntryId: string;
142
+ trajectoryEventId: string;
143
+ eventType: string;
144
+ title: string;
145
+ evidenceRefs: string[];
131
146
  };
132
147
  };
133
148
  export interface BuildAgentRuntimeLedgerOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runtime-ledger.d.ts","sourceRoot":"","sources":["../../src/server/agent-runtime-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,2BAA2B,EAE3B,6BAA6B,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,KAAK,EACX,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,2BAA2B,4CACE,CAAC;AAC3C,eAAO,MAAM,mCAAmC,oDACE,CAAC;AACnD,eAAO,MAAM,mCAAmC,oDACE,CAAC;AAEnD,MAAM,MAAM,2BAA2B,GACpC,KAAK,GACL,SAAS,GACT,YAAY,GACZ,WAAW,GACX,aAAa,GACb,MAAM,GACN,YAAY,GACZ,UAAU,GACV,UAAU,GACV,YAAY,GACZ,SAAS,GACT,WAAW,GACX,SAAS,CAAC;AAEb,MAAM,MAAM,uBAAuB,GAChC,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,WAAW,GACX,SAAS,CAAC;AAEb,KAAK,8BAA8B,GAAG,OAAO,CAC5C,uBAAuB,EACvB,SAAS,CACT,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,2BAA2B,CAAC;IAClC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACrC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,E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B,CAAC;CACD,CAAC;AAEL,MAAM,WAAW,8BAA8B;IAC9C,OAAO,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,QAAQ,EAAE,2BAA2B,CAAC;IACtC,UAAU,EAAE,qBAAqB,CAAC;IAClC,MAAM,EAAE,2BAA2B,CAAC;CACpC;AAoeD,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,8BAA8B,GACrC,wBAAwB,CAyC1B"}
@@ -110,6 +110,39 @@ function waitTypeForEntry(kind, timelineItem) {
110
110
  return "AGENT_RUN_WAIT_TYPE_INPUT";
111
111
  return "AGENT_RUN_WAIT_TYPE_APPROVAL";
112
112
  }
113
+ function firstEvidenceIdForEvent(event, kind) {
114
+ return event.evidence.find((anchor) => anchor.kind === kind)?.id;
115
+ }
116
+ function hasCorrelation(correlation) {
117
+ return Object.values(correlation).some((value) => typeof value === "string" && value.length > 0);
118
+ }
119
+ function correlationForEvent(event, timelineItem) {
120
+ const pendingRequestId = timelineItem?.pendingRequestId ??
121
+ firstEvidenceIdForEvent(event, "pending_request");
122
+ const approvalRequestId = timelineItem?.approvalRequestId ??
123
+ firstEvidenceIdForEvent(event, "approval_request");
124
+ const toolExecutionId = timelineItem?.toolExecutionId ??
125
+ firstEvidenceIdForEvent(event, "tool_execution");
126
+ const artifactId = timelineItem?.artifactId ?? firstEvidenceIdForEvent(event, "artifact");
127
+ const agentRunId = timelineItem?.agentRunId ?? firstEvidenceIdForEvent(event, "agent_run");
128
+ const parentAgentRunId = timelineItem?.parentAgentRunId ??
129
+ firstEvidenceIdForEvent(event, "parent_agent_run");
130
+ const childAgentRunId = timelineItem?.childAgentRunId ??
131
+ firstEvidenceIdForEvent(event, "child_agent_run");
132
+ const correlation = {
133
+ ...(pendingRequestId ? { pendingRequestId } : {}),
134
+ ...(timelineItem?.pendingRequestKind
135
+ ? { pendingRequestKind: timelineItem.pendingRequestKind }
136
+ : {}),
137
+ ...(approvalRequestId ? { approvalRequestId } : {}),
138
+ ...(toolExecutionId ? { toolExecutionId } : {}),
139
+ ...(artifactId ? { artifactId } : {}),
140
+ ...(agentRunId ? { agentRunId } : {}),
141
+ ...(parentAgentRunId ? { parentAgentRunId } : {}),
142
+ ...(childAgentRunId ? { childAgentRunId } : {}),
143
+ };
144
+ return hasCorrelation(correlation) ? correlation : undefined;
145
+ }
113
146
  function buildLedgerEntries(timeline, trajectory) {
114
147
  const timelineItemsById = new Map(timeline.items.map((item) => [item.id, item]));
115
148
  return trajectory.events.map((event) => {
@@ -120,6 +153,7 @@ function buildLedgerEntries(timeline, trajectory) {
120
153
  ? timelineItemsById.get(timelineItemId)
121
154
  : undefined;
122
155
  const waitType = waitTypeForEntry(kind, timelineItem);
156
+ const correlation = correlationForEvent(event, timelineItem);
123
157
  return {
124
158
  id: `ledger:${event.id}`,
125
159
  sequence: event.sequence,
@@ -138,6 +172,7 @@ function buildLedgerEntries(timeline, trajectory) {
138
172
  ...(event.summary ? { summary: event.summary } : {}),
139
173
  relatedIds: event.relatedIds ?? [],
140
174
  evidence: event.evidence,
175
+ ...(correlation ? { correlation } : {}),
141
176
  platformShape: {
142
177
  stepKind: stepKindForEntry(kind, event),
143
178
  workItemKind: workItemKindForEntry(kind),
@@ -231,6 +266,7 @@ function workItemPayloadForEntry(sessionId, entry) {
231
266
  ...(entry.toolName ? { toolName: entry.toolName } : {}),
232
267
  ...(entry.summary ? { summary: entry.summary } : {}),
233
268
  ...(entry.relatedIds.length > 0 ? { relatedIds: entry.relatedIds } : {}),
269
+ ...(entry.correlation ? { correlation: entry.correlation } : {}),
234
270
  };
235
271
  }
236
272
  function terminalEntry(entries) {
@@ -257,6 +293,11 @@ function terminalOperation(runId, entries) {
257
293
  payload: {
258
294
  state: succeeded ? "succeeded" : "failed",
259
295
  timestamp: terminal.timestamp,
296
+ ledgerEntryId: terminal.id,
297
+ trajectoryEventId: terminal.trajectoryEventId,
298
+ eventType: terminal.type,
299
+ title: terminal.title,
300
+ evidenceRefs: evidenceRefsForEntry(terminal),
260
301
  ...(succeeded
261
302
  ? {}
262
303
  : {
@@ -294,7 +335,8 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
294
335
  },
295
336
  ];
296
337
  for (const entry of entries) {
297
- const toolExecutionId = firstEvidenceId(entry, "tool_execution");
338
+ const correlation = entry.correlation ?? {};
339
+ const toolExecutionId = correlation.toolExecutionId ?? firstEvidenceId(entry, "tool_execution");
298
340
  const evidenceRefs = evidenceRefsForEntry(entry);
299
341
  const waitId = entry.platformShape.waitType ? entry.id : undefined;
300
342
  operations.push({
@@ -321,6 +363,7 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
321
363
  title: entry.title,
322
364
  timestamp: entry.timestamp,
323
365
  ...(waitId ? { waitId } : {}),
366
+ ...correlation,
324
367
  ...(toolExecutionId ? { toolExecutionId } : {}),
325
368
  evidenceRefs,
326
369
  completionGate: "maestro_agent_runtime_ledger_recorded",
@@ -337,6 +380,7 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
337
380
  waitType: entry.platformShape.waitType,
338
381
  title: entry.title,
339
382
  timestamp: entry.timestamp,
383
+ ...correlation,
340
384
  },
341
385
  });
342
386
  }