@botbotgo/agent-harness 0.0.177 → 0.0.178
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.
|
@@ -61,6 +61,12 @@ function titleCase(value) {
|
|
|
61
61
|
function normalizeLabel(value) {
|
|
62
62
|
return value.replace(/\s+/g, " ").trim();
|
|
63
63
|
}
|
|
64
|
+
function readSessionId(input) {
|
|
65
|
+
return input.sessionId ?? input.threadId;
|
|
66
|
+
}
|
|
67
|
+
function readRequestId(input) {
|
|
68
|
+
return input.requestId ?? input.runId;
|
|
69
|
+
}
|
|
64
70
|
function readProjectionLabel(projection) {
|
|
65
71
|
if (projection.type === "step") {
|
|
66
72
|
return projection.step;
|
|
@@ -199,6 +205,8 @@ function buildRuntimeNodes(timeline) {
|
|
|
199
205
|
kind: mapped.kind,
|
|
200
206
|
label: mapped.label,
|
|
201
207
|
status: mapped.status,
|
|
208
|
+
sessionId: item.threadId,
|
|
209
|
+
requestId: item.runId,
|
|
202
210
|
threadId: item.threadId,
|
|
203
211
|
runId: item.runId,
|
|
204
212
|
startedAt: item.timestamp,
|
|
@@ -397,6 +405,8 @@ function convertUpstreamEventsWithAgents(upstreamEvents, initialAgentId) {
|
|
|
397
405
|
kind: "agent",
|
|
398
406
|
label: `Delegate to ${titleCase(nestedAgentId)}`,
|
|
399
407
|
status: "completed",
|
|
408
|
+
sessionId: "",
|
|
409
|
+
requestId: "",
|
|
400
410
|
threadId: "",
|
|
401
411
|
runId: "",
|
|
402
412
|
agentId: nestedAgentId,
|
|
@@ -427,6 +437,8 @@ function convertUpstreamEventsWithAgents(upstreamEvents, initialAgentId) {
|
|
|
427
437
|
kind: "agent",
|
|
428
438
|
label: `Delegate to ${titleCase(delegatedAgentId)}`,
|
|
429
439
|
status: "completed",
|
|
440
|
+
sessionId: "",
|
|
441
|
+
requestId: "",
|
|
430
442
|
threadId: "",
|
|
431
443
|
runId: "",
|
|
432
444
|
agentId: delegatedAgentId,
|
|
@@ -515,6 +527,8 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
|
|
|
515
527
|
delegationIndex += 1;
|
|
516
528
|
pendingDelegationNode = {
|
|
517
529
|
...sourceNode,
|
|
530
|
+
sessionId: threadId,
|
|
531
|
+
requestId: runId,
|
|
518
532
|
threadId,
|
|
519
533
|
runId,
|
|
520
534
|
groupId: currentGroup?.id,
|
|
@@ -538,6 +552,8 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
|
|
|
538
552
|
kind: "thinking",
|
|
539
553
|
label: "Model reasoning",
|
|
540
554
|
status: "completed",
|
|
555
|
+
sessionId: threadId,
|
|
556
|
+
requestId: runId,
|
|
541
557
|
threadId,
|
|
542
558
|
runId,
|
|
543
559
|
groupId: currentGroup?.id,
|
|
@@ -663,6 +679,8 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
|
|
|
663
679
|
kind: attempt.kind,
|
|
664
680
|
label: attempt.label,
|
|
665
681
|
status: attempt.status,
|
|
682
|
+
sessionId: threadId,
|
|
683
|
+
requestId: runId,
|
|
666
684
|
threadId,
|
|
667
685
|
runId,
|
|
668
686
|
agentId: attempt.agentId,
|
|
@@ -680,33 +698,35 @@ function buildAttempts(projectionRecords, delegationNodes, runtimeGroups, thread
|
|
|
680
698
|
}
|
|
681
699
|
function resolveContext(input, runtimeTimeline, projections) {
|
|
682
700
|
const timelineHead = runtimeTimeline[0];
|
|
683
|
-
|
|
684
|
-
|
|
701
|
+
const inputSessionId = readSessionId(input);
|
|
702
|
+
const inputRequestId = readRequestId(input);
|
|
703
|
+
if (inputSessionId && inputRequestId) {
|
|
704
|
+
return { sessionId: inputSessionId, requestId: inputRequestId };
|
|
685
705
|
}
|
|
686
706
|
if (timelineHead) {
|
|
687
707
|
return {
|
|
688
|
-
|
|
689
|
-
|
|
708
|
+
sessionId: inputSessionId ?? timelineHead.threadId,
|
|
709
|
+
requestId: inputRequestId ?? timelineHead.runId,
|
|
690
710
|
};
|
|
691
711
|
}
|
|
692
712
|
const firstProjection = projections[0];
|
|
693
|
-
if (!
|
|
694
|
-
throw new Error(`buildFlowGraph requires
|
|
713
|
+
if (!inputSessionId || !inputRequestId) {
|
|
714
|
+
throw new Error(`buildFlowGraph requires sessionId and requestId when runtime timeline data is absent${firstProjection ? "" : " or empty"}; legacy threadId/runId inputs are still accepted.`);
|
|
695
715
|
}
|
|
696
|
-
return {
|
|
716
|
+
return { sessionId: inputSessionId, requestId: inputRequestId };
|
|
697
717
|
}
|
|
698
718
|
export function buildFlowGraph(input) {
|
|
699
719
|
const runtimeTimeline = input.runtimeTimeline
|
|
700
720
|
?? (input.runtimeEvents ? projectRuntimeTimeline(input.runtimeEvents, {
|
|
701
|
-
...(input
|
|
702
|
-
...(input
|
|
721
|
+
...(readSessionId(input) ? { threadId: readSessionId(input) } : {}),
|
|
722
|
+
...(readRequestId(input) ? { runId: readRequestId(input) } : {}),
|
|
703
723
|
}) : []);
|
|
704
724
|
const initialAgentId = deriveInitialAgentId(input, runtimeTimeline);
|
|
705
725
|
const upstreamContext = input.upstreamEvents
|
|
706
726
|
? convertUpstreamEventsWithAgents(input.upstreamEvents, initialAgentId)
|
|
707
727
|
: { projections: [], delegationNodes: [] };
|
|
708
728
|
const upstreamProjections = input.upstreamProjections ?? upstreamContext.projections.map((record) => record.projection);
|
|
709
|
-
const {
|
|
729
|
+
const { sessionId, requestId } = resolveContext(input, runtimeTimeline, upstreamProjections);
|
|
710
730
|
const { nodes: runtimeNodes, edges: runtimeEdges, groups: runtimeGroups } = buildRuntimeNodes(runtimeTimeline);
|
|
711
731
|
for (const node of runtimeNodes) {
|
|
712
732
|
node.agentId = typeof node.detail.agentId === "string" ? node.detail.agentId : initialAgentId;
|
|
@@ -718,12 +738,14 @@ export function buildFlowGraph(input) {
|
|
|
718
738
|
sourceEventId: "key" in projection ? projection.key : `projection:${index + 1}`,
|
|
719
739
|
}))
|
|
720
740
|
: upstreamContext.projections;
|
|
721
|
-
const { nodes: attemptNodes, edges: attemptEdges, groups: attemptGroups } = buildAttempts(projectionRecords, upstreamContext.delegationNodes, runtimeGroups,
|
|
741
|
+
const { nodes: attemptNodes, edges: attemptEdges, groups: attemptGroups } = buildAttempts(projectionRecords, upstreamContext.delegationNodes, runtimeGroups, sessionId, requestId);
|
|
722
742
|
return {
|
|
723
|
-
graphId: `${
|
|
743
|
+
graphId: `${sessionId}/${requestId}`,
|
|
724
744
|
scope: input.scope ?? "run",
|
|
725
|
-
|
|
726
|
-
|
|
745
|
+
sessionId,
|
|
746
|
+
requestId,
|
|
747
|
+
threadId: sessionId,
|
|
748
|
+
runId: requestId,
|
|
727
749
|
nodes: [...runtimeNodes, ...attemptNodes],
|
|
728
750
|
edges: [...runtimeEdges, ...attemptEdges],
|
|
729
751
|
groups: [...runtimeGroups, ...attemptGroups],
|
package/dist/flow/types.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type FlowNode = {
|
|
|
11
11
|
kind: FlowNodeKind;
|
|
12
12
|
label: string;
|
|
13
13
|
status: FlowNodeStatus;
|
|
14
|
+
sessionId: string;
|
|
15
|
+
requestId: string;
|
|
14
16
|
threadId: string;
|
|
15
17
|
runId: string;
|
|
16
18
|
agentId?: string;
|
|
@@ -44,6 +46,8 @@ export type FlowGroup = {
|
|
|
44
46
|
export type FlowGraph = {
|
|
45
47
|
graphId: string;
|
|
46
48
|
scope: "run" | "thread";
|
|
49
|
+
sessionId: string;
|
|
50
|
+
requestId: string;
|
|
47
51
|
threadId: string;
|
|
48
52
|
runId: string;
|
|
49
53
|
nodes: FlowNode[];
|
|
@@ -52,6 +56,8 @@ export type FlowGraph = {
|
|
|
52
56
|
metadata: Record<string, unknown>;
|
|
53
57
|
};
|
|
54
58
|
export type BuildFlowGraphInput = {
|
|
59
|
+
sessionId?: string;
|
|
60
|
+
requestId?: string;
|
|
55
61
|
threadId?: string;
|
|
56
62
|
runId?: string;
|
|
57
63
|
scope?: FlowGraph["scope"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.177";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.177";
|