agent-inspect 6.31.30 → 6.31.31
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/package.json +2 -2
- package/packages/cli/dist/index.cjs +86 -23
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +87 -24
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/exporters.cjs +85 -22
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +85 -22
- package/packages/core/dist/exporters.mjs.map +1 -1
|
@@ -423,6 +423,16 @@ function stepIdOf(event) {
|
|
|
423
423
|
const value = event.attributes?.stepId;
|
|
424
424
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
425
425
|
}
|
|
426
|
+
function attemptIdOf(event) {
|
|
427
|
+
const direct = event.attributes?.attemptId;
|
|
428
|
+
if (typeof direct === "string" && direct.trim() !== "") return direct;
|
|
429
|
+
const meta = event.attributes?.metadata;
|
|
430
|
+
if (meta && typeof meta === "object" && !Array.isArray(meta)) {
|
|
431
|
+
const nested = meta.attemptId;
|
|
432
|
+
if (typeof nested === "string" && nested.trim() !== "") return nested;
|
|
433
|
+
}
|
|
434
|
+
return void 0;
|
|
435
|
+
}
|
|
426
436
|
function lifecycleKey(event) {
|
|
427
437
|
if (event.kind === "RUN") return `run:${event.runId}`;
|
|
428
438
|
const stepId = stepIdOf(event);
|
|
@@ -432,6 +442,9 @@ function lifecycleKey(event) {
|
|
|
432
442
|
function isTerminal(status) {
|
|
433
443
|
return status === "ok" || status === "error";
|
|
434
444
|
}
|
|
445
|
+
function eventTime(event) {
|
|
446
|
+
return typeof event.timestamp === "number" ? event.timestamp : 0;
|
|
447
|
+
}
|
|
435
448
|
function cloneNode(node) {
|
|
436
449
|
return {
|
|
437
450
|
event: {
|
|
@@ -442,37 +455,87 @@ function cloneNode(node) {
|
|
|
442
455
|
depth: node.depth
|
|
443
456
|
};
|
|
444
457
|
}
|
|
458
|
+
function joinOnePair(start, terminal) {
|
|
459
|
+
const childMap = /* @__PURE__ */ new Map();
|
|
460
|
+
if (start) {
|
|
461
|
+
for (const child of start.children) {
|
|
462
|
+
childMap.set(child.event.eventId, child);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
for (const child of terminal.children) {
|
|
466
|
+
childMap.set(child.event.eventId, child);
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
event: {
|
|
470
|
+
...terminal.event,
|
|
471
|
+
name: start?.event.name ?? terminal.event.name,
|
|
472
|
+
kind: start?.event.kind ?? terminal.event.kind,
|
|
473
|
+
...start && attemptIdOf(terminal.event) === void 0 && attemptIdOf(start.event) ? {
|
|
474
|
+
attributes: {
|
|
475
|
+
...terminal.event.attributes,
|
|
476
|
+
attemptId: attemptIdOf(start.event)
|
|
477
|
+
}
|
|
478
|
+
} : {}
|
|
479
|
+
},
|
|
480
|
+
children: presentSiblingNodes([...childMap.values()]),
|
|
481
|
+
depth: terminal.depth
|
|
482
|
+
};
|
|
483
|
+
}
|
|
445
484
|
function joinSiblingGroup(group) {
|
|
446
485
|
if (group.length <= 1) return group;
|
|
447
|
-
const terminals = group.filter((n) => isTerminal(n.event.status));
|
|
448
|
-
const runnings = group.filter((n) => n.event.status === "running");
|
|
486
|
+
const terminals = group.filter((n) => isTerminal(n.event.status)).sort((a, b) => eventTime(a.event) - eventTime(b.event));
|
|
487
|
+
const runnings = group.filter((n) => n.event.status === "running").sort((a, b) => eventTime(a.event) - eventTime(b.event));
|
|
488
|
+
const others = group.filter(
|
|
489
|
+
(n) => !isTerminal(n.event.status) && n.event.status !== "running"
|
|
490
|
+
);
|
|
449
491
|
const terminalStatuses = new Set(terminals.map((n) => n.event.status));
|
|
450
492
|
if (terminalStatuses.size > 1) {
|
|
451
493
|
return group;
|
|
452
494
|
}
|
|
453
|
-
if (terminals.length
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
495
|
+
if (terminals.length > 1 && terminals.every((t) => attemptIdOf(t.event) === void 0) && runnings.every((r) => attemptIdOf(r.event) === void 0)) {
|
|
496
|
+
return group;
|
|
497
|
+
}
|
|
498
|
+
const usedRunning = /* @__PURE__ */ new Set();
|
|
499
|
+
const out = [];
|
|
500
|
+
for (const terminal of terminals) {
|
|
501
|
+
const terminalAttempt = attemptIdOf(terminal.event);
|
|
502
|
+
const terminalTs = eventTime(terminal.event);
|
|
503
|
+
const candidate = runnings.find((r) => {
|
|
504
|
+
if (usedRunning.has(r.event.eventId)) return false;
|
|
505
|
+
if (eventTime(r.event) > terminalTs) return false;
|
|
506
|
+
const runningAttempt = attemptIdOf(r.event);
|
|
507
|
+
if (terminalAttempt !== void 0) {
|
|
508
|
+
return runningAttempt === terminalAttempt;
|
|
460
509
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
{
|
|
464
|
-
event: {
|
|
465
|
-
...terminal.event,
|
|
466
|
-
name: start?.event.name ?? terminal.event.name,
|
|
467
|
-
kind: start?.event.kind ?? terminal.event.kind,
|
|
468
|
-
...start?.event.timestamp !== void 0 && terminal.event.durationMs === void 0 ? {} : {}
|
|
469
|
-
},
|
|
470
|
-
children: presentSiblingNodes([...childMap.values()]),
|
|
471
|
-
depth: terminal.depth
|
|
510
|
+
if (runningAttempt !== void 0) {
|
|
511
|
+
return true;
|
|
472
512
|
}
|
|
473
|
-
|
|
513
|
+
return true;
|
|
514
|
+
});
|
|
515
|
+
if (candidate) {
|
|
516
|
+
usedRunning.add(candidate.event.eventId);
|
|
517
|
+
out.push(joinOnePair(candidate, terminal));
|
|
518
|
+
} else {
|
|
519
|
+
out.push({
|
|
520
|
+
...terminal,
|
|
521
|
+
children: presentSiblingNodes(terminal.children)
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
for (const running of runnings) {
|
|
526
|
+
if (usedRunning.has(running.event.eventId)) continue;
|
|
527
|
+
out.push({
|
|
528
|
+
...running,
|
|
529
|
+
children: presentSiblingNodes(running.children)
|
|
530
|
+
});
|
|
474
531
|
}
|
|
475
|
-
|
|
532
|
+
for (const other of others) {
|
|
533
|
+
out.push({
|
|
534
|
+
...other,
|
|
535
|
+
children: presentSiblingNodes(other.children)
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return out;
|
|
476
539
|
}
|
|
477
540
|
function presentSiblingNodes(nodes) {
|
|
478
541
|
const prepared = nodes.map((n) => ({
|