@agent-inspect/viewer 6.31.12 → 6.31.14
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/index.cjs +56 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +56 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3941,18 +3941,16 @@ var TreeBuilder = class {
|
|
|
3941
3941
|
inc(confidenceBreakdown, e.confidence);
|
|
3942
3942
|
kinds[e.kind] = (kinds[e.kind] ?? 0) + 1;
|
|
3943
3943
|
}
|
|
3944
|
-
const startedAt = sorted.length > 0 ? sorted[0].timestamp : void 0;
|
|
3945
|
-
const endedAt = sorted.length > 0 ? sorted[sorted.length - 1].timestamp : void 0;
|
|
3946
|
-
const status = computeRunStatus(sorted);
|
|
3947
|
-
const durationMs = startedAt !== void 0 && endedAt !== void 0 && Number.isFinite(startedAt) && Number.isFinite(endedAt) && endedAt >= startedAt && status !== "running" ? endedAt - startedAt : void 0;
|
|
3948
3944
|
const name = sorted.find((e) => e.kind === "RUN")?.name;
|
|
3945
|
+
const status = computeRunStatus(sorted);
|
|
3946
|
+
const timing = resolveRunTiming(sorted, status);
|
|
3949
3947
|
out.push({
|
|
3950
3948
|
runId,
|
|
3951
3949
|
name,
|
|
3952
3950
|
status,
|
|
3953
|
-
startedAt,
|
|
3954
|
-
endedAt:
|
|
3955
|
-
durationMs,
|
|
3951
|
+
startedAt: timing.startedAt,
|
|
3952
|
+
endedAt: timing.endedAt,
|
|
3953
|
+
durationMs: timing.durationMs,
|
|
3956
3954
|
children: roots,
|
|
3957
3955
|
metadata: {
|
|
3958
3956
|
totalEvents: sorted.length,
|
|
@@ -3966,6 +3964,57 @@ var TreeBuilder = class {
|
|
|
3966
3964
|
return out;
|
|
3967
3965
|
}
|
|
3968
3966
|
};
|
|
3967
|
+
function resolveRunTiming(sorted, status) {
|
|
3968
|
+
let startedAtMs;
|
|
3969
|
+
let endedAtMs;
|
|
3970
|
+
let explicitDurationMs;
|
|
3971
|
+
for (const event of sorted) {
|
|
3972
|
+
if (event.kind !== "RUN") continue;
|
|
3973
|
+
const attrs = event.attributes ?? {};
|
|
3974
|
+
if (typeof attrs.startedAtMs === "number" && Number.isFinite(attrs.startedAtMs)) {
|
|
3975
|
+
startedAtMs = startedAtMs === void 0 ? attrs.startedAtMs : Math.min(startedAtMs, attrs.startedAtMs);
|
|
3976
|
+
}
|
|
3977
|
+
if (typeof attrs.endedAtMs === "number" && Number.isFinite(attrs.endedAtMs)) {
|
|
3978
|
+
endedAtMs = endedAtMs === void 0 ? attrs.endedAtMs : Math.max(endedAtMs, attrs.endedAtMs);
|
|
3979
|
+
}
|
|
3980
|
+
if ((event.status === "ok" || event.status === "error") && typeof event.durationMs === "number" && Number.isFinite(event.durationMs) && event.durationMs >= 0) {
|
|
3981
|
+
explicitDurationMs = event.durationMs;
|
|
3982
|
+
if (endedAtMs === void 0 && startedAtMs !== void 0) {
|
|
3983
|
+
endedAtMs = startedAtMs + event.durationMs;
|
|
3984
|
+
} else if (endedAtMs === void 0 && Number.isFinite(event.timestamp)) {
|
|
3985
|
+
endedAtMs = event.timestamp + event.durationMs;
|
|
3986
|
+
if (startedAtMs === void 0) {
|
|
3987
|
+
startedAtMs = event.timestamp;
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
if (startedAtMs === void 0 && event.status === "running" && Number.isFinite(event.timestamp)) {
|
|
3992
|
+
startedAtMs = event.timestamp;
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
if (startedAtMs !== void 0 && endedAtMs !== void 0 && Number.isFinite(startedAtMs) && Number.isFinite(endedAtMs) && endedAtMs >= startedAtMs && status !== "running") {
|
|
3996
|
+
return {
|
|
3997
|
+
startedAt: startedAtMs,
|
|
3998
|
+
endedAt: endedAtMs,
|
|
3999
|
+
durationMs: endedAtMs - startedAtMs
|
|
4000
|
+
};
|
|
4001
|
+
}
|
|
4002
|
+
if (startedAtMs !== void 0 && explicitDurationMs !== void 0 && status !== "running") {
|
|
4003
|
+
return {
|
|
4004
|
+
startedAt: startedAtMs,
|
|
4005
|
+
endedAt: startedAtMs + explicitDurationMs,
|
|
4006
|
+
durationMs: explicitDurationMs
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
const startedAt = sorted.length > 0 ? sorted[0].timestamp : void 0;
|
|
4010
|
+
const endedAt = sorted.length > 0 ? sorted[sorted.length - 1].timestamp : void 0;
|
|
4011
|
+
const durationMs = startedAt !== void 0 && endedAt !== void 0 && Number.isFinite(startedAt) && Number.isFinite(endedAt) && endedAt >= startedAt && status !== "running" ? endedAt - startedAt : void 0;
|
|
4012
|
+
return {
|
|
4013
|
+
startedAt,
|
|
4014
|
+
endedAt: status === "running" ? void 0 : endedAt,
|
|
4015
|
+
durationMs
|
|
4016
|
+
};
|
|
4017
|
+
}
|
|
3969
4018
|
|
|
3970
4019
|
// packages/core/src/persisted/to-inspect-event.ts
|
|
3971
4020
|
function compactAttributes2(entries) {
|