inspect-ai 0.3.93__py3-none-any.whl → 0.3.94__py3-none-any.whl
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.
- inspect_ai/_display/textual/widgets/samples.py +3 -3
- inspect_ai/_display/textual/widgets/transcript.py +3 -29
- inspect_ai/_eval/task/run.py +10 -7
- inspect_ai/_util/answer.py +26 -0
- inspect_ai/_util/constants.py +0 -1
- inspect_ai/_util/local_server.py +51 -21
- inspect_ai/_view/www/dist/assets/index.css +14 -13
- inspect_ai/_view/www/dist/assets/index.js +400 -84
- inspect_ai/_view/www/log-schema.json +375 -0
- inspect_ai/_view/www/src/@types/log.d.ts +90 -12
- inspect_ai/_view/www/src/app/samples/transcript/SandboxEventView.module.css +2 -1
- inspect_ai/_view/www/src/app/samples/transcript/SpanEventView.tsx +174 -0
- inspect_ai/_view/www/src/app/samples/transcript/ToolEventView.tsx +8 -8
- inspect_ai/_view/www/src/app/samples/transcript/TranscriptView.tsx +12 -2
- inspect_ai/_view/www/src/app/samples/transcript/TranscriptVirtualListComponent.module.css +1 -1
- inspect_ai/_view/www/src/app/samples/transcript/event/EventPanel.tsx +0 -3
- inspect_ai/_view/www/src/app/samples/transcript/transform/fixups.ts +87 -25
- inspect_ai/_view/www/src/app/samples/transcript/transform/treeify.ts +229 -17
- inspect_ai/_view/www/src/app/samples/transcript/transform/utils.ts +11 -0
- inspect_ai/_view/www/src/app/samples/transcript/types.ts +5 -1
- inspect_ai/agent/_as_solver.py +3 -1
- inspect_ai/agent/_as_tool.py +6 -4
- inspect_ai/agent/_handoff.py +5 -1
- inspect_ai/agent/_react.py +4 -3
- inspect_ai/agent/_run.py +6 -1
- inspect_ai/agent/_types.py +9 -0
- inspect_ai/dataset/_dataset.py +6 -3
- inspect_ai/log/__init__.py +10 -0
- inspect_ai/log/_convert.py +4 -9
- inspect_ai/log/_samples.py +14 -17
- inspect_ai/log/_transcript.py +77 -35
- inspect_ai/log/_tree.py +118 -0
- inspect_ai/model/_call_tools.py +42 -34
- inspect_ai/model/_model.py +45 -40
- inspect_ai/model/_providers/hf.py +27 -1
- inspect_ai/model/_providers/sglang.py +8 -2
- inspect_ai/model/_providers/vllm.py +6 -2
- inspect_ai/scorer/_choice.py +1 -2
- inspect_ai/solver/_chain.py +1 -1
- inspect_ai/solver/_fork.py +1 -1
- inspect_ai/solver/_multiple_choice.py +5 -22
- inspect_ai/solver/_plan.py +2 -2
- inspect_ai/solver/_transcript.py +6 -7
- inspect_ai/tool/_mcp/_mcp.py +6 -5
- inspect_ai/tool/_tools/_execute.py +4 -1
- inspect_ai/util/__init__.py +4 -0
- inspect_ai/util/_anyio.py +11 -0
- inspect_ai/util/_collect.py +50 -0
- inspect_ai/util/_span.py +58 -0
- inspect_ai/util/_subtask.py +27 -42
- {inspect_ai-0.3.93.dist-info → inspect_ai-0.3.94.dist-info}/METADATA +1 -1
- {inspect_ai-0.3.93.dist-info → inspect_ai-0.3.94.dist-info}/RECORD +56 -51
- {inspect_ai-0.3.93.dist-info → inspect_ai-0.3.94.dist-info}/WHEEL +1 -1
- inspect_ai/_display/core/group.py +0 -79
- {inspect_ai-0.3.93.dist-info → inspect_ai-0.3.94.dist-info}/entry_points.txt +0 -0
- {inspect_ai-0.3.93.dist-info → inspect_ai-0.3.94.dist-info}/licenses/LICENSE +0 -0
- {inspect_ai-0.3.93.dist-info → inspect_ai-0.3.94.dist-info}/top_level.txt +0 -0
@@ -51205,8 +51205,7 @@ self.onmessage = function (e) {
|
|
51205
51205
|
text: text2,
|
51206
51206
|
icon: icon2,
|
51207
51207
|
collapse,
|
51208
|
-
children: children2
|
51209
|
-
running: running2
|
51208
|
+
children: children2
|
51210
51209
|
}) => {
|
51211
51210
|
const [isCollapsed, setCollapsed] = useProperty(id, "collapsed", {
|
51212
51211
|
defaultValue: !!collapse
|
@@ -51302,35 +51301,32 @@ self.onmessage = function (e) {
|
|
51302
51301
|
]
|
51303
51302
|
}
|
51304
51303
|
) : "";
|
51305
|
-
const card2 = /* @__PURE__ */ jsxRuntimeExports.
|
51306
|
-
|
51307
|
-
|
51308
|
-
|
51309
|
-
|
51310
|
-
|
51311
|
-
|
51312
|
-
|
51313
|
-
|
51314
|
-
|
51315
|
-
|
51316
|
-
|
51317
|
-
|
51318
|
-
|
51319
|
-
|
51320
|
-
|
51321
|
-
|
51322
|
-
|
51323
|
-
|
51324
|
-
|
51325
|
-
|
51326
|
-
|
51327
|
-
|
51328
|
-
|
51329
|
-
|
51330
|
-
|
51331
|
-
] }),
|
51332
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ProgressBar, { animating: !!running2 })
|
51333
|
-
] });
|
51304
|
+
const card2 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { id, className: clsx(className2, styles$s.card), children: [
|
51305
|
+
titleEl,
|
51306
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
51307
|
+
"div",
|
51308
|
+
{
|
51309
|
+
className: clsx(
|
51310
|
+
"tab-content",
|
51311
|
+
styles$s.cardContent,
|
51312
|
+
hasCollapse && isCollapsed ? styles$s.hidden : void 0
|
51313
|
+
),
|
51314
|
+
children: filteredArrChildren == null ? void 0 : filteredArrChildren.map((child, index2) => {
|
51315
|
+
const id2 = pillId(index2);
|
51316
|
+
const isSelected = id2 === selectedNav;
|
51317
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
51318
|
+
"div",
|
51319
|
+
{
|
51320
|
+
id: id2,
|
51321
|
+
className: clsx("tab-pane", "show", isSelected ? "active" : ""),
|
51322
|
+
children: child
|
51323
|
+
},
|
51324
|
+
`children-${id2}-${index2}`
|
51325
|
+
);
|
51326
|
+
})
|
51327
|
+
}
|
51328
|
+
)
|
51329
|
+
] }) });
|
51334
51330
|
return card2;
|
51335
51331
|
};
|
51336
51332
|
function hasDataDefault(node2) {
|
@@ -51839,11 +51835,11 @@ self.onmessage = function (e) {
|
|
51839
51835
|
const icon2 = resolve_icon(event.type);
|
51840
51836
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(EventPanel, { id, title: title2, icon: icon2, className: className2, children: event.message });
|
51841
51837
|
};
|
51842
|
-
const twoColumn = "
|
51843
|
-
const exec = "
|
51844
|
-
const result = "
|
51845
|
-
const fileLabel = "
|
51846
|
-
const wrapPre = "
|
51838
|
+
const twoColumn = "_twoColumn_1irga_9";
|
51839
|
+
const exec = "_exec_1irga_15";
|
51840
|
+
const result = "_result_1irga_19";
|
51841
|
+
const fileLabel = "_fileLabel_1irga_23";
|
51842
|
+
const wrapPre = "_wrapPre_1irga_28";
|
51847
51843
|
const styles$l = {
|
51848
51844
|
twoColumn,
|
51849
51845
|
exec,
|
@@ -59404,6 +59400,13 @@ ${events}
|
|
59404
59400
|
function initializeObject(current2) {
|
59405
59401
|
return current2 ?? {};
|
59406
59402
|
}
|
59403
|
+
const ET_STEP = "step";
|
59404
|
+
const ACTION_BEGIN = "begin";
|
59405
|
+
const ET_SPAN_BEGIN = "span_begin";
|
59406
|
+
const ET_SPAN_END = "span_end";
|
59407
|
+
const hasSpans = (events) => {
|
59408
|
+
return events.some((event) => event.event === ET_SPAN_BEGIN);
|
59409
|
+
};
|
59407
59410
|
const kSandboxSignalName = "53787D8A-D3FC-426D-B383-9F880B70E4AA";
|
59408
59411
|
const fixupEventStream = (events, filterPending = true) => {
|
59409
59412
|
const collapsed = processPendingEvents(events, filterPending);
|
@@ -59426,44 +59429,65 @@ ${events}
|
|
59426
59429
|
}, []);
|
59427
59430
|
};
|
59428
59431
|
const collapseSampleInit = (events) => {
|
59432
|
+
const hasSpans2 = events.some((e) => {
|
59433
|
+
return e.event === "span_begin" || e.event === "span_end";
|
59434
|
+
});
|
59435
|
+
if (hasSpans2) {
|
59436
|
+
return events;
|
59437
|
+
}
|
59429
59438
|
const hasInitStep = events.findIndex((e) => {
|
59430
59439
|
return e.event === "step" && e.name === "init";
|
59431
59440
|
}) !== -1;
|
59441
|
+
if (hasInitStep) {
|
59442
|
+
return events;
|
59443
|
+
}
|
59432
59444
|
const initEventIndex = events.findIndex((e) => {
|
59433
59445
|
return e.event === "sample_init";
|
59434
59446
|
});
|
59435
59447
|
const initEvent = events[initEventIndex];
|
59436
|
-
|
59437
|
-
|
59438
|
-
fixedUp.splice(initEventIndex, 0, {
|
59439
|
-
timestamp: initEvent.timestamp,
|
59440
|
-
event: "step",
|
59441
|
-
action: "begin",
|
59442
|
-
type: null,
|
59443
|
-
name: "sample_init",
|
59444
|
-
pending: false,
|
59445
|
-
working_start: 0
|
59446
|
-
});
|
59447
|
-
fixedUp.splice(initEventIndex + 2, 0, {
|
59448
|
-
timestamp: initEvent.timestamp,
|
59449
|
-
event: "step",
|
59450
|
-
action: "end",
|
59451
|
-
type: null,
|
59452
|
-
name: "sample_init",
|
59453
|
-
pending: false,
|
59454
|
-
working_start: 0
|
59455
|
-
});
|
59448
|
+
if (!initEvent) {
|
59449
|
+
return events;
|
59456
59450
|
}
|
59451
|
+
const fixedUp = [...events];
|
59452
|
+
fixedUp.splice(initEventIndex, 0, {
|
59453
|
+
timestamp: initEvent.timestamp,
|
59454
|
+
event: "step",
|
59455
|
+
action: "begin",
|
59456
|
+
type: null,
|
59457
|
+
name: "sample_init",
|
59458
|
+
pending: false,
|
59459
|
+
working_start: 0,
|
59460
|
+
span_id: initEvent.span_id
|
59461
|
+
});
|
59462
|
+
fixedUp.splice(initEventIndex + 2, 0, {
|
59463
|
+
timestamp: initEvent.timestamp,
|
59464
|
+
event: "step",
|
59465
|
+
action: "end",
|
59466
|
+
type: null,
|
59467
|
+
name: "sample_init",
|
59468
|
+
pending: false,
|
59469
|
+
working_start: 0,
|
59470
|
+
span_id: initEvent.span_id
|
59471
|
+
});
|
59457
59472
|
return fixedUp;
|
59458
59473
|
};
|
59459
59474
|
const groupSandboxEvents = (events) => {
|
59460
59475
|
const result2 = [];
|
59461
59476
|
const pendingSandboxEvents = [];
|
59477
|
+
const useSpans = hasSpans(events);
|
59462
59478
|
const pushPendingSandboxEvents = () => {
|
59463
59479
|
const timestamp = pendingSandboxEvents[pendingSandboxEvents.length - 1].timestamp;
|
59464
|
-
|
59480
|
+
if (useSpans) {
|
59481
|
+
result2.push(createSpanBegin(kSandboxSignalName, timestamp, null));
|
59482
|
+
} else {
|
59483
|
+
result2.push(createStepEvent(kSandboxSignalName, timestamp, "begin"));
|
59484
|
+
}
|
59465
59485
|
result2.push(...pendingSandboxEvents);
|
59466
|
-
|
59486
|
+
if (useSpans) {
|
59487
|
+
result2.push(createSpanEnd(kSandboxSignalName, timestamp));
|
59488
|
+
} else {
|
59489
|
+
result2.push(createStepEvent(kSandboxSignalName, timestamp, "end"));
|
59490
|
+
}
|
59467
59491
|
pendingSandboxEvents.length = 0;
|
59468
59492
|
};
|
59469
59493
|
for (const event of events) {
|
@@ -59488,8 +59512,32 @@ ${events}
|
|
59488
59512
|
type: null,
|
59489
59513
|
name: name2,
|
59490
59514
|
pending: false,
|
59491
|
-
working_start: 0
|
59515
|
+
working_start: 0,
|
59516
|
+
span_id: null
|
59492
59517
|
});
|
59518
|
+
const createSpanBegin = (name2, timestamp, parent_id) => {
|
59519
|
+
return {
|
59520
|
+
name: name2,
|
59521
|
+
id: `${name2}-begin`,
|
59522
|
+
span_id: name2,
|
59523
|
+
parent_id,
|
59524
|
+
timestamp,
|
59525
|
+
event: "span_begin",
|
59526
|
+
type: null,
|
59527
|
+
pending: false,
|
59528
|
+
working_start: 0
|
59529
|
+
};
|
59530
|
+
};
|
59531
|
+
const createSpanEnd = (name2, timestamp) => {
|
59532
|
+
return {
|
59533
|
+
id: `${name2}-end`,
|
59534
|
+
timestamp,
|
59535
|
+
event: "span_end",
|
59536
|
+
pending: false,
|
59537
|
+
working_start: 0,
|
59538
|
+
span_id: name2
|
59539
|
+
};
|
59540
|
+
};
|
59493
59541
|
const StepEventView = ({
|
59494
59542
|
id,
|
59495
59543
|
event,
|
@@ -59498,7 +59546,7 @@ ${events}
|
|
59498
59546
|
}) => {
|
59499
59547
|
const descriptor = stepDescriptor(event);
|
59500
59548
|
const title2 = descriptor.name || `${event.type ? event.type + ": " : "Step: "}${event.name}`;
|
59501
|
-
const text2 = summarize(children2);
|
59549
|
+
const text2 = summarize$1(children2);
|
59502
59550
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
59503
59551
|
EventPanel,
|
59504
59552
|
{
|
@@ -59519,7 +59567,7 @@ ${events}
|
|
59519
59567
|
}
|
59520
59568
|
);
|
59521
59569
|
};
|
59522
|
-
const summarize = (children2) => {
|
59570
|
+
const summarize$1 = (children2) => {
|
59523
59571
|
if (children2.length === 0) {
|
59524
59572
|
return "(no events)";
|
59525
59573
|
}
|
@@ -59736,7 +59784,7 @@ ${events}
|
|
59736
59784
|
const ToolEventView = ({
|
59737
59785
|
id,
|
59738
59786
|
event,
|
59739
|
-
|
59787
|
+
children: children2,
|
59740
59788
|
className: className2
|
59741
59789
|
}) => {
|
59742
59790
|
var _a2, _b2;
|
@@ -59794,20 +59842,157 @@ ${events}
|
|
59794
59842
|
) : "",
|
59795
59843
|
event.pending ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$f.progress), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PulsingDots, { subtle: false, size: "medium" }) }) : void 0
|
59796
59844
|
] }),
|
59797
|
-
|
59798
|
-
|
59845
|
+
children2.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
59846
|
+
TranscriptComponent,
|
59799
59847
|
{
|
59800
|
-
id: `${id}-subtask`,
|
59801
59848
|
"data-name": "Transcript",
|
59802
|
-
|
59803
|
-
|
59804
|
-
|
59849
|
+
id: `${id}-subtask`,
|
59850
|
+
eventNodes: children2,
|
59851
|
+
"data-default": event.failed || event.agent ? true : null
|
59805
59852
|
}
|
59806
59853
|
) : ""
|
59807
59854
|
]
|
59808
59855
|
}
|
59809
59856
|
);
|
59810
59857
|
};
|
59858
|
+
const SpanEventView = ({
|
59859
|
+
id,
|
59860
|
+
event,
|
59861
|
+
children: children2,
|
59862
|
+
className: className2
|
59863
|
+
}) => {
|
59864
|
+
const descriptor = spanDescriptor(event);
|
59865
|
+
const title2 = descriptor.name || `${event.type ? event.type + ": " : "Step: "}${event.name}`;
|
59866
|
+
const text2 = summarize(children2);
|
59867
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
59868
|
+
EventPanel,
|
59869
|
+
{
|
59870
|
+
id: `span-${event.name}-${id}`,
|
59871
|
+
className: clsx("transcript-span", className2),
|
59872
|
+
title: title2,
|
59873
|
+
subTitle: formatDateTime(new Date(event.timestamp)),
|
59874
|
+
text: text2,
|
59875
|
+
collapse: descriptor.collapse,
|
59876
|
+
icon: descriptor.icon,
|
59877
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
59878
|
+
TranscriptComponent,
|
59879
|
+
{
|
59880
|
+
id: `span|${event.name}|${id}`,
|
59881
|
+
eventNodes: children2
|
59882
|
+
}
|
59883
|
+
)
|
59884
|
+
}
|
59885
|
+
);
|
59886
|
+
};
|
59887
|
+
const summarize = (children2) => {
|
59888
|
+
if (children2.length === 0) {
|
59889
|
+
return "(no events)";
|
59890
|
+
}
|
59891
|
+
const formatEvent = (event, count) => {
|
59892
|
+
if (count === 1) {
|
59893
|
+
return `${count} ${event} event`;
|
59894
|
+
} else {
|
59895
|
+
return `${count} ${event} events`;
|
59896
|
+
}
|
59897
|
+
};
|
59898
|
+
const typeCount = {};
|
59899
|
+
children2.forEach((child) => {
|
59900
|
+
const currentCount = typeCount[child.event.event] || 0;
|
59901
|
+
typeCount[child.event.event] = currentCount + 1;
|
59902
|
+
});
|
59903
|
+
const numberOfTypes = Object.keys(typeCount).length;
|
59904
|
+
if (numberOfTypes < 3) {
|
59905
|
+
return Object.keys(typeCount).map((key2) => {
|
59906
|
+
return formatEvent(key2, typeCount[key2]);
|
59907
|
+
}).join(", ");
|
59908
|
+
}
|
59909
|
+
if (children2.length === 1) {
|
59910
|
+
return "1 event";
|
59911
|
+
} else {
|
59912
|
+
return `${children2.length} events`;
|
59913
|
+
}
|
59914
|
+
};
|
59915
|
+
const spanDescriptor = (event) => {
|
59916
|
+
const rootStepDescriptor = {
|
59917
|
+
endSpace: true
|
59918
|
+
};
|
59919
|
+
if (event.type === "solver") {
|
59920
|
+
switch (event.name) {
|
59921
|
+
case "chain_of_thought":
|
59922
|
+
return {
|
59923
|
+
...rootStepDescriptor,
|
59924
|
+
collapse: false
|
59925
|
+
};
|
59926
|
+
case "generate":
|
59927
|
+
return {
|
59928
|
+
...rootStepDescriptor,
|
59929
|
+
collapse: false
|
59930
|
+
};
|
59931
|
+
case "self_critique":
|
59932
|
+
return {
|
59933
|
+
...rootStepDescriptor,
|
59934
|
+
collapse: false
|
59935
|
+
};
|
59936
|
+
case "system_message":
|
59937
|
+
return {
|
59938
|
+
...rootStepDescriptor,
|
59939
|
+
collapse: true
|
59940
|
+
};
|
59941
|
+
case "use_tools":
|
59942
|
+
return {
|
59943
|
+
...rootStepDescriptor,
|
59944
|
+
collapse: false
|
59945
|
+
};
|
59946
|
+
case "multiple_choice":
|
59947
|
+
return {
|
59948
|
+
...rootStepDescriptor,
|
59949
|
+
collapse: false
|
59950
|
+
};
|
59951
|
+
default:
|
59952
|
+
return {
|
59953
|
+
...rootStepDescriptor,
|
59954
|
+
collapse: false
|
59955
|
+
};
|
59956
|
+
}
|
59957
|
+
} else if (event.type === "scorer") {
|
59958
|
+
return {
|
59959
|
+
...rootStepDescriptor,
|
59960
|
+
collapse: false
|
59961
|
+
};
|
59962
|
+
} else if (event.event === "span_begin") {
|
59963
|
+
if (event.span_id === kSandboxSignalName) {
|
59964
|
+
return {
|
59965
|
+
...rootStepDescriptor,
|
59966
|
+
name: "Sandbox Events",
|
59967
|
+
collapse: true
|
59968
|
+
};
|
59969
|
+
} else if (event.name === "init") {
|
59970
|
+
return {
|
59971
|
+
...rootStepDescriptor,
|
59972
|
+
name: "Init",
|
59973
|
+
collapse: true
|
59974
|
+
};
|
59975
|
+
} else {
|
59976
|
+
return {
|
59977
|
+
...rootStepDescriptor,
|
59978
|
+
collapse: false
|
59979
|
+
};
|
59980
|
+
}
|
59981
|
+
} else {
|
59982
|
+
switch (event.name) {
|
59983
|
+
case "sample_init":
|
59984
|
+
return {
|
59985
|
+
...rootStepDescriptor,
|
59986
|
+
name: "Sample Init",
|
59987
|
+
collapse: true
|
59988
|
+
};
|
59989
|
+
default:
|
59990
|
+
return {
|
59991
|
+
endSpace: false
|
59992
|
+
};
|
59993
|
+
}
|
59994
|
+
}
|
59995
|
+
};
|
59811
59996
|
const transcriptComponent = "_transcriptComponent_171gc_19";
|
59812
59997
|
const eventNode = "_eventNode_171gc_25";
|
59813
59998
|
const darkenBg = "_darkenBg_171gc_29";
|
@@ -59824,10 +60009,10 @@ ${events}
|
|
59824
60009
|
noBottom,
|
59825
60010
|
attached: attached$1
|
59826
60011
|
};
|
59827
|
-
const darkenedBg = "
|
59828
|
-
const normalBg = "
|
59829
|
-
const node = "
|
59830
|
-
const attached = "
|
60012
|
+
const darkenedBg = "_darkenedBg_u9na2_1";
|
60013
|
+
const normalBg = "_normalBg_u9na2_5";
|
60014
|
+
const node = "_node_u9na2_9";
|
60015
|
+
const attached = "_attached_u9na2_14";
|
59831
60016
|
const styles$d = {
|
59832
60017
|
darkenedBg,
|
59833
60018
|
normalBg,
|
@@ -59873,9 +60058,11 @@ ${events}
|
|
59873
60058
|
}
|
59874
60059
|
}
|
59875
60060
|
function treeifyEvents(events, depth) {
|
60061
|
+
const useSpans = hasSpans(events);
|
60062
|
+
const treeFn = useSpans ? treeifyFnSpan : treeifyFnStep;
|
59876
60063
|
const rootNodes = [];
|
59877
60064
|
const stack2 = [];
|
59878
|
-
const
|
60065
|
+
const addNode = (event) => {
|
59879
60066
|
const node2 = new EventNode(event, stack2.length + depth);
|
59880
60067
|
if (stack2.length > 0) {
|
59881
60068
|
const parentNode = stack2[stack2.length - 1];
|
@@ -59885,20 +60072,139 @@ ${events}
|
|
59885
60072
|
}
|
59886
60073
|
return node2;
|
59887
60074
|
};
|
60075
|
+
const pushStack = (node2) => {
|
60076
|
+
stack2.push(node2);
|
60077
|
+
};
|
60078
|
+
const popStack = () => {
|
60079
|
+
if (stack2.length > 0) {
|
60080
|
+
stack2.pop();
|
60081
|
+
}
|
60082
|
+
};
|
59888
60083
|
events.forEach((event) => {
|
59889
|
-
|
59890
|
-
|
59891
|
-
|
59892
|
-
|
59893
|
-
|
59894
|
-
|
60084
|
+
treeFn(event, addNode, pushStack, popStack);
|
60085
|
+
});
|
60086
|
+
if (useSpans) {
|
60087
|
+
return transformTree(rootNodes);
|
60088
|
+
} else {
|
60089
|
+
return rootNodes;
|
60090
|
+
}
|
60091
|
+
}
|
60092
|
+
const treeifyFnStep = (event, addNode, pushStack, popStack) => {
|
60093
|
+
switch (event.event) {
|
60094
|
+
case ET_STEP:
|
60095
|
+
if (event.action === ACTION_BEGIN) {
|
60096
|
+
const node2 = addNode(event);
|
60097
|
+
pushStack(node2);
|
60098
|
+
} else {
|
60099
|
+
popStack();
|
60100
|
+
}
|
60101
|
+
break;
|
60102
|
+
case ET_SPAN_BEGIN: {
|
60103
|
+
break;
|
60104
|
+
}
|
60105
|
+
case ET_SPAN_END: {
|
60106
|
+
break;
|
60107
|
+
}
|
60108
|
+
default:
|
60109
|
+
addNode(event);
|
60110
|
+
break;
|
60111
|
+
}
|
60112
|
+
};
|
60113
|
+
const treeifyFnSpan = (event, addNode, pushStack, popStack) => {
|
60114
|
+
switch (event.event) {
|
60115
|
+
case ET_STEP:
|
60116
|
+
break;
|
60117
|
+
case ET_SPAN_BEGIN: {
|
60118
|
+
const node2 = addNode(event);
|
60119
|
+
pushStack(node2);
|
60120
|
+
break;
|
60121
|
+
}
|
60122
|
+
case ET_SPAN_END: {
|
60123
|
+
popStack();
|
60124
|
+
break;
|
60125
|
+
}
|
60126
|
+
default:
|
60127
|
+
addNode(event);
|
60128
|
+
break;
|
60129
|
+
}
|
60130
|
+
};
|
60131
|
+
const treeNodeTransformers = [
|
60132
|
+
{
|
60133
|
+
name: "unwrap_tools",
|
60134
|
+
matches: (node2) => node2.event.event === "span_begin" && node2.event.type === "tool",
|
60135
|
+
process: (node2) => elevateChildNode(node2, "tool") || node2
|
60136
|
+
},
|
60137
|
+
{
|
60138
|
+
name: "unwrap_subtasks",
|
60139
|
+
matches: (node2) => node2.event.event === "span_begin" && node2.event.type === "subtask",
|
60140
|
+
process: (node2) => elevateChildNode(node2, "subtask") || node2
|
60141
|
+
},
|
60142
|
+
{
|
60143
|
+
name: "unwrap_agent_solver",
|
60144
|
+
matches: (node2) => node2.event.event === "span_begin" && node2.event["type"] === "solver" && node2.children.length === 2 && node2.children[0].event.event === "span_begin" && node2.children[0].event.type === "agent" && node2.children[1].event.event === "state",
|
60145
|
+
process: (node2) => skipFirstChildNode(node2)
|
60146
|
+
},
|
60147
|
+
{
|
60148
|
+
name: "unwrap_agent_solver w/store",
|
60149
|
+
matches: (node2) => node2.event.event === "span_begin" && node2.event["type"] === "solver" && node2.children.length === 3 && node2.children[0].event.event === "span_begin" && node2.children[0].event.type === "agent" && node2.children[1].event.event === "state" && node2.children[2].event.event === "store",
|
60150
|
+
process: (node2) => skipFirstChildNode(node2)
|
60151
|
+
},
|
60152
|
+
{
|
60153
|
+
name: "unwrap_handoff",
|
60154
|
+
matches: (node2) => node2.event.event === "span_begin" && node2.event["type"] === "handoff" && node2.children.length === 2 && node2.children[0].event.event === "tool" && node2.children[1].event.event === "store" && node2.children[0].children.length === 2 && node2.children[0].children[0].event.event === "span_begin" && node2.children[0].children[0].event.type === "agent",
|
60155
|
+
process: (node2) => skipThisNode(node2)
|
60156
|
+
}
|
60157
|
+
];
|
60158
|
+
const transformTree = (roots) => {
|
60159
|
+
const visitNode = (node2) => {
|
60160
|
+
let processedNode = node2;
|
60161
|
+
processedNode.children = processedNode.children.map(visitNode);
|
60162
|
+
for (const transformer of treeNodeTransformers) {
|
60163
|
+
if (transformer.matches(processedNode)) {
|
60164
|
+
processedNode = transformer.process(processedNode);
|
60165
|
+
break;
|
59895
60166
|
}
|
59896
|
-
} else {
|
59897
|
-
pushNode(event);
|
59898
60167
|
}
|
60168
|
+
return processedNode;
|
60169
|
+
};
|
60170
|
+
return roots.map(visitNode);
|
60171
|
+
};
|
60172
|
+
const elevateChildNode = (node2, childEventType) => {
|
60173
|
+
const targetIndex = node2.children.findIndex(
|
60174
|
+
(child) => child.event.event === childEventType
|
60175
|
+
);
|
60176
|
+
if (targetIndex === -1) {
|
60177
|
+
console.log(
|
60178
|
+
`No ${childEventType} event found in a span, this is very unexpected.`
|
60179
|
+
);
|
60180
|
+
return null;
|
60181
|
+
}
|
60182
|
+
const targetNode = { ...node2.children[targetIndex] };
|
60183
|
+
const remainingChildren = node2.children.filter((_, i2) => i2 !== targetIndex);
|
60184
|
+
targetNode.depth = node2.depth;
|
60185
|
+
targetNode.children = reduceDepth(remainingChildren);
|
60186
|
+
return targetNode;
|
60187
|
+
};
|
60188
|
+
const skipFirstChildNode = (node2) => {
|
60189
|
+
const agentSpan = node2.children.splice(0, 1)[0];
|
60190
|
+
node2.children.unshift(...reduceDepth(agentSpan.children));
|
60191
|
+
return node2;
|
60192
|
+
};
|
60193
|
+
const skipThisNode = (node2) => {
|
60194
|
+
const newNode = { ...node2.children[0] };
|
60195
|
+
newNode.depth = node2.depth;
|
60196
|
+
newNode.children = reduceDepth(newNode.children[0].children, 2);
|
60197
|
+
return newNode;
|
60198
|
+
};
|
60199
|
+
const reduceDepth = (nodes, depth = 1) => {
|
60200
|
+
return nodes.map((node2) => {
|
60201
|
+
if (node2.children.length > 0) {
|
60202
|
+
node2.children = reduceDepth(node2.children, 1);
|
60203
|
+
}
|
60204
|
+
node2.depth = node2.depth - depth;
|
60205
|
+
return node2;
|
59899
60206
|
});
|
59900
|
-
|
59901
|
-
}
|
60207
|
+
};
|
59902
60208
|
const TranscriptView = ({
|
59903
60209
|
id,
|
59904
60210
|
events,
|
@@ -60016,6 +60322,16 @@ ${events}
|
|
60016
60322
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ScoreEventView, { id, event: node2.event, className: className2 });
|
60017
60323
|
case "state":
|
60018
60324
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(StateEventView, { id, event: node2.event, className: className2 });
|
60325
|
+
case "span_begin":
|
60326
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
60327
|
+
SpanEventView,
|
60328
|
+
{
|
60329
|
+
id,
|
60330
|
+
event: node2.event,
|
60331
|
+
children: node2.children,
|
60332
|
+
className: className2
|
60333
|
+
}
|
60334
|
+
);
|
60019
60335
|
case "step":
|
60020
60336
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
60021
60337
|
StepEventView,
|
@@ -60053,7 +60369,7 @@ ${events}
|
|
60053
60369
|
id,
|
60054
60370
|
event: node2.event,
|
60055
60371
|
className: className2,
|
60056
|
-
|
60372
|
+
children: node2.children
|
60057
60373
|
}
|
60058
60374
|
);
|
60059
60375
|
case "input":
|