agentfootprint-lens 0.16.0 → 0.18.0

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.
@@ -1,13 +1,10 @@
1
1
  import {
2
2
  selectAgentInstances
3
- } from "./chunk-EYEBTJYP.js";
3
+ } from "./chunk-KQOLJKKM.js";
4
4
 
5
5
  // src/core/LensRecorder.ts
6
6
  import { SequenceStore } from "footprintjs/trace";
7
- import {
8
- LiveStateRecorder,
9
- BoundaryRecorder
10
- } from "agentfootprint";
7
+ import { LiveStateRecorder, BoundaryRecorder } from "agentfootprint/observe";
11
8
  import {
12
9
  createTraceRuntimeOverlay
13
10
  } from "footprint-explainable-ui/flowchart";
@@ -448,7 +445,12 @@ var LensRecorder = class {
448
445
  const runner = this.currentRunner;
449
446
  if (!runner) return [];
450
447
  const snap = runner.getLastSnapshot?.();
451
- return snap?.commitLog ?? [];
448
+ const log = snap?.commitLog ?? [];
449
+ return log.map((c) => ({
450
+ runtimeStageId: c.runtimeStageId,
451
+ stageId: c.stageId,
452
+ overwriteKeys: [...Object.keys(c.overwrite ?? {}), ...Object.keys(c.updates ?? {})]
453
+ }));
452
454
  }
453
455
  /**
454
456
  * Live commit-count accessor injected into the BoundaryRecorder.
@@ -1117,6 +1119,7 @@ import {
1117
1119
  selectCommentaryKey
1118
1120
  } from "agentfootprint";
1119
1121
  var defaultHumanizer = (event) => {
1122
+ if (event.type === "agentfootprint.context.evaluated") return null;
1120
1123
  switch (event.type) {
1121
1124
  // Composition
1122
1125
  case "agentfootprint.composition.enter":
@@ -1936,6 +1939,7 @@ function structureGraphFromRunner(runner) {
1936
1939
  const trace = createTraceStructureRecorder();
1937
1940
  const recorder = trace.recorder;
1938
1941
  const spec = runner.getSpec().buildTimeStructure;
1942
+ const subflowSpecs = [];
1939
1943
  for (const item of walkSubflowSpec(spec, "", { recurse: false })) {
1940
1944
  switch (item.kind) {
1941
1945
  case "stage":
@@ -1966,13 +1970,25 @@ function structureGraphFromRunner(runner) {
1966
1970
  subflowSpec: item.subflowSpec,
1967
1971
  subflowPath: item.subflowPath
1968
1972
  });
1973
+ subflowSpecs.push({
1974
+ subflowId: item.subflowId,
1975
+ spec: item.subflowSpec,
1976
+ // Strip any leading slash so qualified ids read `sf-x/stage`, matching
1977
+ // the runtime overlay key (runtimeStageId minus #index has no leading /).
1978
+ path: (typeof item.subflowPath === "string" && item.subflowPath.length > 0 ? item.subflowPath : item.subflowId).replace(/^\/+/, "")
1979
+ });
1969
1980
  break;
1970
1981
  case "subflow-start":
1971
1982
  break;
1972
1983
  }
1973
1984
  }
1974
- const graph = trace.getGraph();
1975
- for (const node of graph.nodes) {
1985
+ const baseGraph = trace.getGraph();
1986
+ const internal = expandSubflowInternals(subflowSpecs);
1987
+ const seenNodes = new Set(baseGraph.nodes.map((n) => n.id));
1988
+ const seenEdges = new Set(baseGraph.edges.map((e) => e.id));
1989
+ const nodes = [...baseGraph.nodes, ...internal.nodes.filter((n) => !seenNodes.has(n.id))];
1990
+ const edges = [...baseGraph.edges, ...internal.edges.filter((e) => !seenEdges.has(e.id))];
1991
+ for (const node of nodes) {
1976
1992
  const role = stageRole(node.id);
1977
1993
  const data = node.data;
1978
1994
  const { localStageId } = splitStageId(node.id);
@@ -1990,7 +2006,60 @@ function structureGraphFromRunner(runner) {
1990
2006
  if (slotKind !== void 0) data.slotKind = slotKind;
1991
2007
  }
1992
2008
  }
1993
- return graph;
2009
+ return { ...baseGraph, nodes, edges };
2010
+ }
2011
+ function expandSubflowInternals(subflows) {
2012
+ const nodes = [];
2013
+ const edges = [];
2014
+ for (const { subflowId, spec, path } of subflows) {
2015
+ const subTrace = createTraceStructureRecorder();
2016
+ const subRec = subTrace.recorder;
2017
+ for (const item of walkSubflowSpec(spec, path, { recurse: false })) {
2018
+ switch (item.kind) {
2019
+ case "stage":
2020
+ subRec.onStageAdded?.({
2021
+ stageId: item.stageId,
2022
+ name: item.name,
2023
+ type: item.type,
2024
+ ...item.isPausable !== void 0 && { isPausable: item.isPausable },
2025
+ spec: item.spec
2026
+ });
2027
+ break;
2028
+ case "edge":
2029
+ subRec.onEdgeAdded?.({
2030
+ from: item.from,
2031
+ to: item.to,
2032
+ kind: item.edgeKind,
2033
+ ...item.label !== void 0 && { label: item.label }
2034
+ });
2035
+ break;
2036
+ case "loop":
2037
+ subRec.onLoopEdgeAdded?.({ from: item.from, to: item.to });
2038
+ break;
2039
+ case "subflow":
2040
+ subRec.onSubflowMounted?.({
2041
+ subflowId: item.subflowId,
2042
+ subflowName: item.subflowName,
2043
+ rootStageId: item.mountStageId,
2044
+ subflowSpec: item.subflowSpec,
2045
+ subflowPath: item.subflowPath
2046
+ });
2047
+ break;
2048
+ case "subflow-start":
2049
+ break;
2050
+ }
2051
+ }
2052
+ const sub = subTrace.getGraph();
2053
+ const prefix = path.endsWith("/") ? path : `${path}/`;
2054
+ const q = (id) => id.startsWith(prefix) ? id : `${prefix}${id}`;
2055
+ for (const n of sub.nodes) {
2056
+ nodes.push({ ...n, id: q(n.id), data: { ...n.data, subflowOf: subflowId } });
2057
+ }
2058
+ for (const e of sub.edges) {
2059
+ edges.push({ ...e, id: `${q(e.source)}->${q(e.target)}`, source: q(e.source), target: q(e.target) });
2060
+ }
2061
+ }
2062
+ return { nodes, edges };
1994
2063
  }
1995
2064
 
1996
2065
  // src/core/render/toReactFlow.ts
@@ -2226,4 +2295,4 @@ export {
2226
2295
  defaultSize,
2227
2296
  layoutLensGraph
2228
2297
  };
2229
- //# sourceMappingURL=chunk-DN6FXRGN.js.map
2298
+ //# sourceMappingURL=chunk-A2ELAEZX.js.map