@botbotgo/agent-harness 0.0.268 → 0.0.269

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 (38) hide show
  1. package/dist/acp.js +2 -2
  2. package/dist/api.d.ts +6 -11
  3. package/dist/api.js +20 -23
  4. package/dist/contracts/runtime.d.ts +38 -70
  5. package/dist/flow/build-flow-graph.js +29 -45
  6. package/dist/flow/types.d.ts +0 -6
  7. package/dist/package-version.d.ts +1 -1
  8. package/dist/package-version.js +1 -1
  9. package/dist/persistence/file-store.js +24 -17
  10. package/dist/persistence/sqlite-run-context-store.js +2 -2
  11. package/dist/persistence/sqlite-store.js +18 -16
  12. package/dist/protocol/a2a/http.js +48 -46
  13. package/dist/protocol/ag-ui/http.js +9 -9
  14. package/dist/runtime/adapter/invocation-result.js +2 -2
  15. package/dist/runtime/harness/events/listener-runtime.d.ts +2 -2
  16. package/dist/runtime/harness/events/streaming.d.ts +8 -8
  17. package/dist/runtime/harness/events/streaming.js +10 -10
  18. package/dist/runtime/harness/events/timeline.js +4 -4
  19. package/dist/runtime/harness/run/helpers.js +2 -2
  20. package/dist/runtime/harness/run/recovery.js +20 -20
  21. package/dist/runtime/harness/run/resume.js +3 -3
  22. package/dist/runtime/harness/run/run-lifecycle.js +5 -5
  23. package/dist/runtime/harness/run/run-operations.d.ts +2 -2
  24. package/dist/runtime/harness/run/run-operations.js +21 -21
  25. package/dist/runtime/harness/run/start-run.d.ts +3 -3
  26. package/dist/runtime/harness/run/start-run.js +3 -3
  27. package/dist/runtime/harness/run/startup-runtime.js +1 -1
  28. package/dist/runtime/harness/run/stream-run.js +37 -27
  29. package/dist/runtime/harness/run/thread-records.js +12 -33
  30. package/dist/runtime/harness/system/mem0-ingestion-sync.js +2 -2
  31. package/dist/runtime/harness/system/runtime-memory-manager.js +4 -4
  32. package/dist/runtime/harness/system/runtime-memory-records.js +6 -6
  33. package/dist/runtime/harness/system/runtime-memory-sync.js +6 -4
  34. package/dist/runtime/harness/system/thread-memory-sync.js +7 -5
  35. package/dist/runtime/harness.d.ts +2 -2
  36. package/dist/runtime/harness.js +161 -156
  37. package/dist/runtime/support/harness-support.js +4 -4
  38. package/package.json +1 -1
package/dist/acp.js CHANGED
@@ -31,8 +31,8 @@ function toNotification(event) {
31
31
  eventId: event.eventId,
32
32
  eventType: event.eventType,
33
33
  timestamp: event.timestamp,
34
- sessionId: event.threadId,
35
- requestId: event.runId,
34
+ sessionId: event.sessionId,
35
+ requestId: event.requestId,
36
36
  sequence: event.sequence,
37
37
  source: event.source,
38
38
  payload: event.payload,
package/dist/api.d.ts CHANGED
@@ -55,7 +55,7 @@ export type Approval = {
55
55
  allowedDecisions: Array<"approve" | "edit" | "reject">;
56
56
  inputPreview: Record<string, unknown>;
57
57
  };
58
- export type RequestArtifactListing = Omit<ArtifactListing, "threadId" | "runId"> & {
58
+ export type RequestArtifactListing = Omit<ArtifactListing, "sessionId" | "requestId"> & {
59
59
  sessionId: string;
60
60
  requestId: string;
61
61
  };
@@ -97,17 +97,17 @@ type PublicApprovalFilter = {
97
97
  sessionId?: string;
98
98
  requestId?: string;
99
99
  };
100
- type PublicRequestStartOptions = Omit<RunStartOptions, "threadId" | "listeners"> & {
100
+ type PublicRequestStartOptions = Omit<RunStartOptions, "sessionId" | "listeners"> & {
101
101
  sessionId?: string;
102
102
  listeners?: PublicRunListeners;
103
103
  };
104
- type PublicRequestDecisionOptions = Omit<RunDecisionOptions, "threadId" | "runId" | "listeners"> & {
104
+ type PublicRequestDecisionOptions = Omit<RunDecisionOptions, "sessionId" | "requestId" | "listeners"> & {
105
105
  sessionId: string;
106
106
  requestId?: string;
107
107
  listeners?: PublicRunListeners;
108
108
  };
109
109
  type PublicRequestOptions = PublicRequestStartOptions | PublicRequestDecisionOptions;
110
- type PublicRequestResult = Omit<RunResult, "threadId" | "runId"> & {
110
+ type PublicRequestResult = Omit<RunResult, "sessionId" | "requestId"> & {
111
111
  sessionId: string;
112
112
  requestId: string;
113
113
  };
@@ -188,13 +188,8 @@ export declare function describeInventory(runtime: AgentHarnessRuntime, options?
188
188
  workspaceRoot: string;
189
189
  agents: InventoryAgentRecord[];
190
190
  };
191
- export declare function resolveApproval(runtime: AgentHarnessRuntime, options: ResumeOptions & {
192
- sessionId?: string;
193
- requestId?: string;
194
- }): Promise<PublicRunResult>;
195
- export declare function cancelRun(runtime: AgentHarnessRuntime, options: CancelOptions & {
196
- requestId?: string;
197
- }): Promise<PublicRunResult>;
191
+ export declare function resolveApproval(runtime: AgentHarnessRuntime, options: ResumeOptions): Promise<PublicRunResult>;
192
+ export declare function cancelRun(runtime: AgentHarnessRuntime, options: CancelOptions): Promise<PublicRunResult>;
198
193
  export declare function stop(runtime: AgentHarnessRuntime): Promise<void>;
199
194
  export declare function createToolMcpServer(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
200
195
  export declare function serveToolsOverStdio(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
package/dist/api.js CHANGED
@@ -15,8 +15,8 @@ function toApprovalRecord(record) {
15
15
  return {
16
16
  approvalId: record.approvalId,
17
17
  pendingActionId: record.pendingActionId,
18
- sessionId: record.threadId,
19
- requestId: record.runId,
18
+ sessionId: record.sessionId,
19
+ requestId: record.requestId,
20
20
  toolName: record.toolName,
21
21
  ...(record.approvalReason ? { approvalReason: record.approvalReason } : {}),
22
22
  status: record.status,
@@ -47,8 +47,8 @@ function toPublicEvent(event) {
47
47
  eventId: event.eventId,
48
48
  eventType: toPublicEventType(event.eventType),
49
49
  timestamp: event.timestamp,
50
- sessionId: event.threadId,
51
- requestId: event.runId,
50
+ sessionId: event.sessionId,
51
+ requestId: event.requestId,
52
52
  sequence: event.sequence,
53
53
  source: event.source,
54
54
  payload: event.payload,
@@ -77,8 +77,8 @@ function toPublicRunListeners(listeners) {
77
77
  onUpstreamEvent: listeners.onUpstreamEvent,
78
78
  onTraceItem: listeners.onTraceItem
79
79
  ? async (item) => listeners.onTraceItem({
80
- sessionId: item.threadId,
81
- requestId: item.runId,
80
+ sessionId: item.sessionId,
81
+ requestId: item.requestId,
82
82
  surfaceItem: item.surfaceItem,
83
83
  event: item.event,
84
84
  })
@@ -87,8 +87,8 @@ function toPublicRunListeners(listeners) {
87
87
  }
88
88
  function toRequestArtifactListing(listing) {
89
89
  return {
90
- sessionId: listing.threadId,
91
- requestId: listing.runId,
90
+ sessionId: listing.sessionId,
91
+ requestId: listing.requestId,
92
92
  items: listing.items,
93
93
  };
94
94
  }
@@ -106,8 +106,8 @@ function toRequestPackage(pkg) {
106
106
  }
107
107
  function toPublicRunResult(result) {
108
108
  return {
109
- sessionId: result.threadId,
110
- requestId: result.runId,
109
+ sessionId: result.sessionId,
110
+ requestId: result.requestId,
111
111
  state: result.state,
112
112
  output: result.output,
113
113
  finalMessageText: result.finalMessageText,
@@ -130,8 +130,8 @@ function toInternalRunOptions(options) {
130
130
  decision: options.decision,
131
131
  editedInput: options.editedInput,
132
132
  listeners: toPublicRunListeners(options.listeners),
133
- runId: options.requestId,
134
- threadId: options.sessionId,
133
+ requestId: options.requestId,
134
+ sessionId: options.sessionId,
135
135
  };
136
136
  }
137
137
  return {
@@ -140,7 +140,7 @@ function toInternalRunOptions(options) {
140
140
  invocation: options.invocation,
141
141
  listeners: toPublicRunListeners(options.listeners),
142
142
  priority: options.priority,
143
- threadId: options.sessionId,
143
+ sessionId: options.sessionId,
144
144
  };
145
145
  }
146
146
  function toInternalResumeOptions(options) {
@@ -148,14 +148,14 @@ function toInternalResumeOptions(options) {
148
148
  approvalId: options.approvalId,
149
149
  decision: options.decision,
150
150
  editedInput: options.editedInput,
151
- runId: options.requestId ?? options.runId,
152
- threadId: options.sessionId ?? options.threadId,
151
+ requestId: options.requestId,
152
+ sessionId: options.sessionId,
153
153
  };
154
154
  }
155
155
  function toPublicRequestSummary(run) {
156
156
  return {
157
- requestId: run.runId,
158
- sessionId: run.threadId,
157
+ requestId: run.requestId,
158
+ sessionId: run.sessionId,
159
159
  agentId: run.agentId,
160
160
  parentRunId: run.parentRunId,
161
161
  executionMode: run.executionMode,
@@ -270,9 +270,9 @@ export async function deleteSession(runtime, sessionId) {
270
270
  }
271
271
  export async function listApprovals(runtime, filter) {
272
272
  return (await runtime.listApprovals({
273
- runId: filter?.requestId,
273
+ requestId: filter?.requestId,
274
274
  status: filter?.status,
275
- threadId: filter?.sessionId,
275
+ sessionId: filter?.sessionId,
276
276
  })).map(toApprovalRecord);
277
277
  }
278
278
  export async function getApproval(runtime, approvalId) {
@@ -363,10 +363,7 @@ export async function resolveApproval(runtime, options) {
363
363
  return toPublicRunResult(await runtime.resume(toInternalResumeOptions(options)));
364
364
  }
365
365
  export async function cancelRun(runtime, options) {
366
- return toPublicRunResult(await runtime.cancelRun({
367
- ...options,
368
- runId: options.requestId ?? options.runId,
369
- }));
366
+ return toPublicRunResult(await runtime.cancelRun(options));
370
367
  }
371
368
  export async function stop(runtime) {
372
369
  return runtime.stop();
@@ -25,17 +25,8 @@ export type SessionListSummary = SessionSummary & {
25
25
  title?: string;
26
26
  snippet?: string;
27
27
  };
28
- /**
29
- * Backward-compatible alias for older thread/run terminology.
30
- */
31
- export type ThreadSummary = Omit<SessionSummary, "sessionId" | "latestRequestId"> & {
32
- threadId: string;
33
- latestRunId: string;
34
- };
35
- export type ThreadListSummary = Omit<SessionListSummary, "sessionId" | "latestRequestId"> & {
36
- threadId: string;
37
- latestRunId: string;
38
- };
28
+ export type ThreadSummary = SessionSummary;
29
+ export type ThreadListSummary = SessionListSummary;
39
30
  export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
40
31
  export type HarnessEventType = KnownHarnessEventType | (string & {});
41
32
  /**
@@ -47,8 +38,8 @@ export type HarnessEvent = {
47
38
  eventId: string;
48
39
  eventType: HarnessEventType;
49
40
  timestamp: string;
50
- threadId: string;
51
- runId: string;
41
+ sessionId: string;
42
+ requestId: string;
52
43
  sequence: number;
53
44
  source: "runtime" | "policy" | "surface" | "worker";
54
45
  payload: Record<string, unknown>;
@@ -65,8 +56,8 @@ export type HarnessEventProjection = {
65
56
  */
66
57
  export type RuntimeTimelineItem = {
67
58
  eventId: string;
68
- threadId: string;
69
- runId: string;
59
+ sessionId: string;
60
+ requestId: string;
70
61
  eventType: HarnessEventType;
71
62
  timestamp: string;
72
63
  sequence: number;
@@ -75,8 +66,8 @@ export type RuntimeTimelineItem = {
75
66
  payload: Record<string, unknown>;
76
67
  };
77
68
  export type RuntimeTimelineProjectionOptions = {
78
- threadId?: string;
79
- runId?: string;
69
+ sessionId?: string;
70
+ requestId?: string;
80
71
  };
81
72
  /**
82
73
  * Ordered upstream/runtime execution trace projected from persisted upstream events.
@@ -281,8 +272,6 @@ export type MemorizeInput = {
281
272
  records: MemorizeInputRecord[];
282
273
  sessionId?: string;
283
274
  requestId?: string;
284
- threadId?: string;
285
- runId?: string;
286
275
  agentId?: string;
287
276
  userId?: string;
288
277
  projectId?: string;
@@ -299,7 +288,6 @@ export type RecallInput = {
299
288
  topK?: number;
300
289
  includeStale?: boolean;
301
290
  sessionId?: string;
302
- threadId?: string;
303
291
  agentId?: string;
304
292
  workspaceId?: string;
305
293
  userId?: string;
@@ -313,7 +301,6 @@ export type ListMemoriesInput = {
313
301
  kinds?: MemoryKind[];
314
302
  status?: MemoryRecordStatus[];
315
303
  sessionId?: string;
316
- threadId?: string;
317
304
  agentId?: string;
318
305
  workspaceId?: string;
319
306
  userId?: string;
@@ -411,8 +398,8 @@ export type RuntimeHealthSnapshot = {
411
398
  };
412
399
  };
413
400
  export type RunResult = {
414
- threadId: string;
415
- runId: string;
401
+ sessionId: string;
402
+ requestId: string;
416
403
  state: RunState;
417
404
  output: string;
418
405
  finalMessageText?: string;
@@ -429,8 +416,8 @@ export type RunResult = {
429
416
  };
430
417
  export type UpstreamRuntimeEvent = unknown;
431
418
  export type UpstreamRuntimeEventItem = {
432
- threadId: string;
433
- runId: string;
419
+ sessionId: string;
420
+ requestId: string;
434
421
  surfaceItem: RuntimeSurfaceItem;
435
422
  event: UpstreamRuntimeEvent;
436
423
  };
@@ -457,14 +444,14 @@ export type InvocationEnvelope = {
457
444
  export type RunStartOptions = {
458
445
  agentId?: string;
459
446
  input: MessageContent;
460
- threadId?: string;
447
+ sessionId?: string;
461
448
  priority?: number;
462
449
  invocation?: InvocationEnvelope;
463
450
  listeners?: RunListeners;
464
451
  };
465
452
  export type RunDecisionOptions = {
466
- threadId: string;
467
- runId?: string;
453
+ sessionId: string;
454
+ requestId?: string;
468
455
  approvalId?: string;
469
456
  decision: "approve" | "edit" | "reject";
470
457
  editedInput?: Record<string, unknown>;
@@ -476,28 +463,28 @@ export type HarnessStreamItem = {
476
463
  event: HarnessEvent;
477
464
  } | {
478
465
  type: "content";
479
- threadId: string;
480
- runId: string;
466
+ sessionId: string;
467
+ requestId: string;
481
468
  agentId: string;
482
469
  content: string;
483
470
  } | {
484
471
  type: "content-blocks";
485
- threadId: string;
486
- runId: string;
472
+ sessionId: string;
473
+ requestId: string;
487
474
  agentId: string;
488
475
  contentBlocks: unknown[];
489
476
  } | {
490
477
  type: "tool-result";
491
- threadId: string;
492
- runId: string;
478
+ sessionId: string;
479
+ requestId: string;
493
480
  agentId: string;
494
481
  toolName: string;
495
482
  output: unknown;
496
483
  isError?: boolean;
497
484
  } | {
498
485
  type: "upstream-event";
499
- threadId: string;
500
- runId: string;
486
+ sessionId: string;
487
+ requestId: string;
501
488
  surfaceItem?: RuntimeSurfaceItem;
502
489
  event: UpstreamRuntimeEvent;
503
490
  } | {
@@ -507,12 +494,12 @@ export type HarnessStreamItem = {
507
494
  export type TranscriptMessage = {
508
495
  role: "user" | "assistant";
509
496
  content: MessageContent;
510
- runId: string;
497
+ requestId: string;
511
498
  createdAt: string;
512
499
  };
513
500
  export type ThreadRunRecord = {
514
- runId: string;
515
- threadId: string;
501
+ requestId: string;
502
+ sessionId: string;
516
503
  agentId: string;
517
504
  parentRunId?: string;
518
505
  executionMode: string;
@@ -533,25 +520,13 @@ export type ThreadRunRecord = {
533
520
  * Persisted request summary projected from upstream execution state plus runtime lifecycle metadata.
534
521
  * This is the canonical runtime-facing execution record.
535
522
  */
536
- export type RequestSummary = Omit<ThreadRunRecord, "threadId" | "runId"> & {
537
- sessionId: string;
538
- requestId: string;
539
- };
523
+ export type RequestSummary = ThreadRunRecord;
540
524
  export type RequestRecord = RequestSummary & {
541
525
  traceItems?: unknown[];
542
526
  runtimeTimeline?: RuntimeTimelineItem[];
543
527
  };
544
- /**
545
- * Backward-compatible alias for older thread/run terminology.
546
- */
547
- export type RunSummary = Omit<RequestSummary, "sessionId" | "requestId"> & {
548
- threadId: string;
549
- runId: string;
550
- };
551
- export type RunRecord = RunSummary & {
552
- traceItems?: unknown[];
553
- runtimeTimeline?: RuntimeTimelineItem[];
554
- };
528
+ export type RunSummary = RequestSummary;
529
+ export type RunRecord = RequestRecord;
555
530
  /**
556
531
  * Persisted session inspection record assembled from runtime records.
557
532
  * This is an inspectable projection, not a second session semantic model.
@@ -574,27 +549,20 @@ export type SessionRecord = {
574
549
  requestedAt: string;
575
550
  };
576
551
  };
577
- /**
578
- * Backward-compatible alias for older thread/run terminology.
579
- */
580
- export type ThreadRecord = Omit<SessionRecord, "sessionId" | "latestRequestId" | "requests"> & {
581
- threadId: string;
582
- latestRunId: string;
583
- runs: RunRecord[];
584
- };
552
+ export type ThreadRecord = SessionRecord;
585
553
  export type ResumeOptions = {
586
- threadId?: string;
587
- runId?: string;
554
+ sessionId?: string;
555
+ requestId?: string;
588
556
  approvalId?: string;
589
557
  decision?: "approve" | "edit" | "reject";
590
558
  editedInput?: Record<string, unknown>;
591
559
  };
592
560
  export type CancelOptions = {
593
- runId: string;
561
+ requestId: string;
594
562
  reason?: string;
595
563
  };
596
564
  export type RestartConversationOptions = {
597
- threadId: string;
565
+ sessionId: string;
598
566
  mode: "restart-in-thread" | "restart-new-thread";
599
567
  input: string;
600
568
  };
@@ -606,8 +574,8 @@ export type RestartConversationOptions = {
606
574
  export type ApprovalRecord = {
607
575
  approvalId: string;
608
576
  pendingActionId: string;
609
- threadId: string;
610
- runId: string;
577
+ sessionId: string;
578
+ requestId: string;
611
579
  toolName: string;
612
580
  approvalReason?: string;
613
581
  status: "pending" | "approved" | "edited" | "rejected" | "expired";
@@ -628,8 +596,8 @@ export type ArtifactRecord = {
628
596
  createdAt: string;
629
597
  };
630
598
  export type ArtifactListing = {
631
- threadId: string;
632
- runId: string;
599
+ sessionId: string;
600
+ requestId: string;
633
601
  items: ArtifactRecord[];
634
602
  };
635
603
  export type RuntimeToolResolver = (toolIds: string[], binding?: CompiledAgentBinding) => unknown[];
@@ -46,14 +46,14 @@ function normalizeRuntimeEventType(eventType) {
46
46
  function normalizeRuntimeEvents(events) {
47
47
  return events.map((event) => {
48
48
  const typed = event;
49
- const threadId = readString(typed.threadId) ?? readString(typed.sessionId) ?? "";
50
- const runId = readString(typed.runId) ?? readString(typed.requestId) ?? "";
49
+ const sessionId = readString(typed.sessionId) ?? "";
50
+ const requestId = readString(typed.requestId) ?? "";
51
51
  return {
52
52
  eventId: String(event.eventId),
53
53
  eventType: normalizeRuntimeEventType(String(event.eventType)),
54
54
  timestamp: String(event.timestamp),
55
- threadId,
56
- runId,
55
+ sessionId,
56
+ requestId,
57
57
  sequence: Number(event.sequence),
58
58
  source: event.source,
59
59
  payload: event.payload ?? {},
@@ -103,10 +103,10 @@ function normalizeLabel(value) {
103
103
  return value.replace(/\s+/g, " ").trim();
104
104
  }
105
105
  function readSessionId(input) {
106
- return input.sessionId ?? input.threadId;
106
+ return input.sessionId;
107
107
  }
108
108
  function readRequestId(input) {
109
- return input.requestId ?? input.runId;
109
+ return input.requestId;
110
110
  }
111
111
  function readProjectionLabel(projection) {
112
112
  if (projection.type === "step") {
@@ -241,15 +241,13 @@ function buildRuntimeNodes(timeline) {
241
241
  for (const item of timeline) {
242
242
  const mapped = deriveRuntimeNode(item);
243
243
  const node = {
244
- id: `rt:${item.runId}:${item.sequence}:${slugify(item.eventType)}`,
244
+ id: `rt:${item.requestId}:${item.sequence}:${slugify(item.eventType)}`,
245
245
  layer: "runtime",
246
246
  kind: mapped.kind,
247
247
  label: mapped.label,
248
248
  status: mapped.status,
249
- sessionId: item.threadId,
250
- requestId: item.runId,
251
- threadId: item.threadId,
252
- runId: item.runId,
249
+ sessionId: item.sessionId,
250
+ requestId: item.requestId,
253
251
  startedAt: item.timestamp,
254
252
  endedAt: item.timestamp,
255
253
  sequenceStart: item.sequence,
@@ -277,7 +275,7 @@ function buildRuntimeNodes(timeline) {
277
275
  if (item.eventType === "run.created" || item.eventType === "run.dequeued" || item.eventType === "run.resumed") {
278
276
  segmentOrdinal += 1;
279
277
  activeExecutionGroup = {
280
- id: `group:${item.runId}:segment:${segmentOrdinal}`,
278
+ id: `group:${item.requestId}:segment:${segmentOrdinal}`,
281
279
  kind: "segment",
282
280
  label: item.eventType === "run.created"
283
281
  ? `Execution segment ${segmentOrdinal}`
@@ -296,7 +294,7 @@ function buildRuntimeNodes(timeline) {
296
294
  if (item.eventType === "approval.requested") {
297
295
  approvalOrdinal += 1;
298
296
  activeApprovalGroup = {
299
- id: `group:${item.runId}:approval:${approvalOrdinal}`,
297
+ id: `group:${item.requestId}:approval:${approvalOrdinal}`,
300
298
  kind: "approval-window",
301
299
  label: `Approval window ${approvalOrdinal}`,
302
300
  nodeIds: [node.id],
@@ -311,7 +309,7 @@ function buildRuntimeNodes(timeline) {
311
309
  if (!activeApprovalGroup) {
312
310
  approvalOrdinal += 1;
313
311
  activeApprovalGroup = {
314
- id: `group:${item.runId}:approval:${approvalOrdinal}`,
312
+ id: `group:${item.requestId}:approval:${approvalOrdinal}`,
315
313
  kind: "approval-window",
316
314
  label: `Approval window ${approvalOrdinal}`,
317
315
  nodeIds: [],
@@ -444,8 +442,6 @@ function createDelegationNodeFromSurfaceItem(surfaceItem, fallbackAgentId, fallb
444
442
  status: surfaceItem.status === "failed" ? "failed" : surfaceItem.status === "started" ? "started" : "completed",
445
443
  sessionId: "",
446
444
  requestId: "",
447
- threadId: "",
448
- runId: "",
449
445
  agentId: toAgentId,
450
446
  agentName: toAgentName,
451
447
  sourceEventIds: [sourceEventId],
@@ -554,8 +550,6 @@ function convertUpstreamEventsWithAgents(upstreamEvents, initialAgentId) {
554
550
  status: "completed",
555
551
  sessionId: "",
556
552
  requestId: "",
557
- threadId: "",
558
- runId: "",
559
553
  agentId: delegatedAgentId,
560
554
  agentName: delegatedAgentName,
561
555
  sourceEventIds: [sourceEventId],
@@ -574,7 +568,7 @@ function convertUpstreamEventsWithAgents(upstreamEvents, initialAgentId) {
574
568
  function selectInitialGroup(groups) {
575
569
  return groups.find((group) => group.kind === "segment") ?? groups[0] ?? null;
576
570
  }
577
- function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, threadId, runId) {
571
+ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, sessionId, requestId) {
578
572
  const nodes = [];
579
573
  const edges = [];
580
574
  const groups = [];
@@ -601,7 +595,7 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
601
595
  function createAttempt(kind, label, projection, agentId, agentName) {
602
596
  ordinal += 1;
603
597
  const attempt = {
604
- id: `attempt:${runId}:${slugify(kind)}:${slugify(label)}:${ordinal}`,
598
+ id: `attempt:${requestId}:${slugify(kind)}:${slugify(label)}:${ordinal}`,
605
599
  kind,
606
600
  label,
607
601
  status: deriveStatusFromProjection(projection),
@@ -647,10 +641,8 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
647
641
  delegationIndex += 1;
648
642
  pendingDelegationNode = {
649
643
  ...sourceNode,
650
- sessionId: threadId,
651
- requestId: runId,
652
- threadId,
653
- runId,
644
+ sessionId,
645
+ requestId,
654
646
  groupId: currentGroup?.id,
655
647
  };
656
648
  nodes.push(pendingDelegationNode);
@@ -685,10 +677,8 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
685
677
  delegationIndex += 1;
686
678
  pendingDelegationNode = {
687
679
  ...sourceNode,
688
- sessionId: threadId,
689
- requestId: runId,
690
- threadId,
691
- runId,
680
+ sessionId,
681
+ requestId,
692
682
  groupId: currentGroup?.id,
693
683
  };
694
684
  nodes.push(pendingDelegationNode);
@@ -705,15 +695,13 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
705
695
  if (projection.type === "thinking") {
706
696
  ordinal += 1;
707
697
  const detailNode = {
708
- id: `detail:${runId}:thinking:${ordinal}`,
698
+ id: `detail:${requestId}:thinking:${ordinal}`,
709
699
  layer: "detail",
710
700
  kind: "thinking",
711
701
  label: "Model reasoning",
712
702
  status: "completed",
713
- sessionId: threadId,
714
- requestId: runId,
715
- threadId,
716
- runId,
703
+ sessionId,
704
+ requestId,
717
705
  groupId: currentGroup?.id,
718
706
  sourceEventIds: [],
719
707
  detail: { text: projection.text },
@@ -785,7 +773,7 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
785
773
  }
786
774
  if (!attemptSetGroups.has(`${kind}:${currentGroup?.id ?? "ungrouped"}`)) {
787
775
  attemptSetGroups.set(`${kind}:${currentGroup?.id ?? "ungrouped"}`, {
788
- id: `group:${runId}:attempt-set:${slugify(kind)}:${attemptSetGroups.size + 1}`,
776
+ id: `group:${requestId}:attempt-set:${slugify(kind)}:${attemptSetGroups.size + 1}`,
789
777
  kind: "attempt-set",
790
778
  label: `${titleCase(kind)} attempts`,
791
779
  nodeIds: [],
@@ -838,10 +826,8 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
838
826
  kind: attempt.kind,
839
827
  label: attempt.label,
840
828
  status: attempt.status,
841
- sessionId: threadId,
842
- requestId: runId,
843
- threadId,
844
- runId,
829
+ sessionId,
830
+ requestId,
845
831
  agentId: attempt.agentId,
846
832
  agentName: attempt.agentName,
847
833
  groupId: attempt.groupId,
@@ -865,21 +851,21 @@ function resolveContext(input, runtimeTimeline, projections) {
865
851
  }
866
852
  if (timelineHead) {
867
853
  return {
868
- sessionId: inputSessionId ?? timelineHead.threadId,
869
- requestId: inputRequestId ?? timelineHead.runId,
854
+ sessionId: inputSessionId ?? timelineHead.sessionId,
855
+ requestId: inputRequestId ?? timelineHead.requestId,
870
856
  };
871
857
  }
872
858
  const firstProjection = projections[0];
873
859
  if (!inputSessionId || !inputRequestId) {
874
- throw new Error(`buildFlowGraph requires sessionId and requestId when runtime timeline data is absent${firstProjection ? "" : " or empty"}; legacy threadId/runId inputs are still accepted.`);
860
+ throw new Error(`buildFlowGraph requires sessionId and requestId when runtime timeline data is absent${firstProjection ? "" : " or empty"}.`);
875
861
  }
876
862
  return { sessionId: inputSessionId, requestId: inputRequestId };
877
863
  }
878
864
  export function buildFlowGraph(input) {
879
865
  const runtimeData = input.runtimeTimeline
880
866
  ?? (input.runtimeEvents ? projectRuntimeTimeline(normalizeRuntimeEvents(input.runtimeEvents), {
881
- ...(readSessionId(input) ? { threadId: readSessionId(input) } : {}),
882
- ...(readRequestId(input) ? { runId: readRequestId(input) } : {}),
867
+ ...(readSessionId(input) ? { sessionId: readSessionId(input) } : {}),
868
+ ...(readRequestId(input) ? { requestId: readRequestId(input) } : {}),
883
869
  }) : []);
884
870
  const initialAgentId = deriveInitialAgentId(input, runtimeData);
885
871
  const upstreamContext = input.upstreamEvents
@@ -932,8 +918,6 @@ export function buildFlowGraph(input) {
932
918
  scope: input.scope ?? "run",
933
919
  sessionId,
934
920
  requestId,
935
- threadId: sessionId,
936
- runId: requestId,
937
921
  nodes: [...runtimeNodes, ...attemptNodes],
938
922
  edges: [...runtimeEdges, ...attemptEdges],
939
923
  groups: [...runtimeGroups, ...attemptGroups],
@@ -23,8 +23,6 @@ export type FlowNode = {
23
23
  status: FlowNodeStatus;
24
24
  sessionId: string;
25
25
  requestId: string;
26
- threadId: string;
27
- runId: string;
28
26
  agentId?: string;
29
27
  agentName?: string;
30
28
  startedAt?: string;
@@ -59,8 +57,6 @@ export type FlowGraph = {
59
57
  scope: "run" | "thread";
60
58
  sessionId: string;
61
59
  requestId: string;
62
- threadId: string;
63
- runId: string;
64
60
  nodes: FlowNode[];
65
61
  edges: FlowEdge[];
66
62
  groups: FlowGroup[];
@@ -69,8 +65,6 @@ export type FlowGraph = {
69
65
  export type BuildFlowGraphInput = {
70
66
  sessionId?: string;
71
67
  requestId?: string;
72
- threadId?: string;
73
- runId?: string;
74
68
  scope?: FlowGraph["scope"];
75
69
  runtimeEvents?: readonly BuildFlowGraphRuntimeEvent[];
76
70
  runtimeTimeline?: readonly RuntimeTimelineItem[];
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.267";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.268";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.267";
1
+ export const AGENT_HARNESS_VERSION = "0.0.268";