agentfootprint 7.7.0 → 7.8.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.
Files changed (205) hide show
  1. package/CLAUDE.md +2 -1
  2. package/dist/adapters/llm/AnthropicProvider.js +5 -4
  3. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  4. package/dist/adapters/llm/BedrockProvider.js +5 -4
  5. package/dist/adapters/llm/BedrockProvider.js.map +1 -1
  6. package/dist/adapters/llm/BrowserAnthropicProvider.js +5 -4
  7. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  8. package/dist/adapters/llm/BrowserOpenAIProvider.js +13 -10
  9. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  10. package/dist/adapters/llm/OpenAIProvider.js +8 -6
  11. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  12. package/dist/core/Agent.js +10 -0
  13. package/dist/core/Agent.js.map +1 -1
  14. package/dist/core/LLMCall.js +10 -1
  15. package/dist/core/LLMCall.js.map +1 -1
  16. package/dist/core/RunnerBase.js +42 -12
  17. package/dist/core/RunnerBase.js.map +1 -1
  18. package/dist/core/agent/buildAgentChart.js +7 -3
  19. package/dist/core/agent/buildAgentChart.js.map +1 -1
  20. package/dist/core/agent/buildAgentMessageApiChart.js +18 -1
  21. package/dist/core/agent/buildAgentMessageApiChart.js.map +1 -1
  22. package/dist/core/agent/buildMessageApiChart.js +4 -1
  23. package/dist/core/agent/buildMessageApiChart.js.map +1 -1
  24. package/dist/core/agent/stages/callLLM.js +18 -2
  25. package/dist/core/agent/stages/callLLM.js.map +1 -1
  26. package/dist/core-flow/Parallel.js +9 -1
  27. package/dist/core-flow/Parallel.js.map +1 -1
  28. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +3 -3
  29. package/dist/esm/adapters/llm/AnthropicProvider.js +5 -4
  30. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  31. package/dist/esm/adapters/llm/BedrockProvider.d.ts +3 -3
  32. package/dist/esm/adapters/llm/BedrockProvider.js +5 -4
  33. package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
  34. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +3 -3
  35. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +5 -4
  36. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  37. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +5 -5
  38. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +13 -10
  39. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  40. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +3 -3
  41. package/dist/esm/adapters/llm/OpenAIProvider.js +8 -6
  42. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  43. package/dist/esm/adapters/types.d.ts +95 -2
  44. package/dist/esm/core/Agent.js +10 -0
  45. package/dist/esm/core/Agent.js.map +1 -1
  46. package/dist/esm/core/LLMCall.js +10 -1
  47. package/dist/esm/core/LLMCall.js.map +1 -1
  48. package/dist/esm/core/RunnerBase.d.ts +22 -1
  49. package/dist/esm/core/RunnerBase.js +42 -12
  50. package/dist/esm/core/RunnerBase.js.map +1 -1
  51. package/dist/esm/core/agent/buildAgentChart.d.ts +7 -3
  52. package/dist/esm/core/agent/buildAgentChart.js +7 -3
  53. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  54. package/dist/esm/core/agent/buildAgentMessageApiChart.js +18 -1
  55. package/dist/esm/core/agent/buildAgentMessageApiChart.js.map +1 -1
  56. package/dist/esm/core/agent/buildMessageApiChart.js +4 -1
  57. package/dist/esm/core/agent/buildMessageApiChart.js.map +1 -1
  58. package/dist/esm/core/agent/stages/callLLM.js +18 -2
  59. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  60. package/dist/esm/core/runner.d.ts +40 -5
  61. package/dist/esm/core-flow/Parallel.js +9 -1
  62. package/dist/esm/core-flow/Parallel.js.map +1 -1
  63. package/dist/esm/index.js +9 -9
  64. package/dist/esm/index.js.map +1 -1
  65. package/dist/esm/lib/context-bisect/types.d.ts +9 -0
  66. package/dist/esm/lib/context-bisect/types.js.map +1 -1
  67. package/dist/esm/lib/recorded-chat/recordedChat.js +10 -1
  68. package/dist/esm/lib/recorded-chat/recordedChat.js.map +1 -1
  69. package/dist/esm/lib/recorded-chat/types.d.ts +10 -0
  70. package/dist/esm/observe.d.ts +3 -1
  71. package/dist/esm/observe.js +13 -1
  72. package/dist/esm/observe.js.map +1 -1
  73. package/dist/esm/providers.d.ts +1 -1
  74. package/dist/esm/recorders/core/EmitBridge.d.ts +9 -3
  75. package/dist/esm/recorders/core/EmitBridge.js +4 -3
  76. package/dist/esm/recorders/core/EmitBridge.js.map +1 -1
  77. package/dist/esm/recorders/core/ResilienceRecorder.d.ts +32 -0
  78. package/dist/esm/recorders/core/ResilienceRecorder.js +41 -0
  79. package/dist/esm/recorders/core/ResilienceRecorder.js.map +1 -0
  80. package/dist/esm/recorders/core/resilienceHooks.d.ts +34 -0
  81. package/dist/esm/recorders/core/resilienceHooks.js +74 -0
  82. package/dist/esm/recorders/core/resilienceHooks.js.map +1 -0
  83. package/dist/esm/recorders/core/typedEmit.d.ts +1 -2
  84. package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +176 -12
  85. package/dist/esm/recorders/observability/BoundaryRecorder.js +119 -8
  86. package/dist/esm/recorders/observability/BoundaryRecorder.js.map +1 -1
  87. package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +13 -2
  88. package/dist/esm/recorders/observability/FlowchartRecorder.js +14 -3
  89. package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
  90. package/dist/esm/recorders/observability/localObservability.d.ts +66 -6
  91. package/dist/esm/recorders/observability/localObservability.js +27 -7
  92. package/dist/esm/recorders/observability/localObservability.js.map +1 -1
  93. package/dist/esm/recorders/observability/recordRun.d.ts +143 -0
  94. package/dist/esm/recorders/observability/recordRun.js +133 -0
  95. package/dist/esm/recorders/observability/recordRun.js.map +1 -0
  96. package/dist/esm/recorders/observability/trace.d.ts +65 -13
  97. package/dist/esm/recorders/observability/trace.js +36 -9
  98. package/dist/esm/recorders/observability/trace.js.map +1 -1
  99. package/dist/esm/reliability/buildReliabilityGateChart.d.ts +23 -9
  100. package/dist/esm/reliability/buildReliabilityGateChart.js +37 -10
  101. package/dist/esm/reliability/buildReliabilityGateChart.js.map +1 -1
  102. package/dist/esm/resilience/withCircuitBreaker.d.ts +15 -5
  103. package/dist/esm/resilience/withCircuitBreaker.js +14 -7
  104. package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
  105. package/dist/esm/resilience/withFallback.d.ts +7 -1
  106. package/dist/esm/resilience/withFallback.js +30 -11
  107. package/dist/esm/resilience/withFallback.js.map +1 -1
  108. package/dist/esm/resilience/withRetry.d.ts +10 -5
  109. package/dist/esm/resilience/withRetry.js +53 -3
  110. package/dist/esm/resilience/withRetry.js.map +1 -1
  111. package/dist/esm/tool-providers/index.js +2 -2
  112. package/dist/esm/tool-providers/index.js.map +1 -1
  113. package/dist/index.js +9 -9
  114. package/dist/index.js.map +1 -1
  115. package/dist/lib/context-bisect/types.js.map +1 -1
  116. package/dist/lib/recorded-chat/recordedChat.js +10 -1
  117. package/dist/lib/recorded-chat/recordedChat.js.map +1 -1
  118. package/dist/observe.js +16 -2
  119. package/dist/observe.js.map +1 -1
  120. package/dist/recorders/core/EmitBridge.js +4 -3
  121. package/dist/recorders/core/EmitBridge.js.map +1 -1
  122. package/dist/recorders/core/ResilienceRecorder.js +45 -0
  123. package/dist/recorders/core/ResilienceRecorder.js.map +1 -0
  124. package/dist/recorders/core/resilienceHooks.js +78 -0
  125. package/dist/recorders/core/resilienceHooks.js.map +1 -0
  126. package/dist/recorders/observability/BoundaryRecorder.js +119 -8
  127. package/dist/recorders/observability/BoundaryRecorder.js.map +1 -1
  128. package/dist/recorders/observability/FlowchartRecorder.js +14 -3
  129. package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
  130. package/dist/recorders/observability/localObservability.js +27 -7
  131. package/dist/recorders/observability/localObservability.js.map +1 -1
  132. package/dist/recorders/observability/recordRun.js +137 -0
  133. package/dist/recorders/observability/recordRun.js.map +1 -0
  134. package/dist/recorders/observability/trace.js +36 -9
  135. package/dist/recorders/observability/trace.js.map +1 -1
  136. package/dist/reliability/buildReliabilityGateChart.js +37 -10
  137. package/dist/reliability/buildReliabilityGateChart.js.map +1 -1
  138. package/dist/resilience/withCircuitBreaker.js +14 -7
  139. package/dist/resilience/withCircuitBreaker.js.map +1 -1
  140. package/dist/resilience/withFallback.js +30 -11
  141. package/dist/resilience/withFallback.js.map +1 -1
  142. package/dist/resilience/withRetry.js +53 -3
  143. package/dist/resilience/withRetry.js.map +1 -1
  144. package/dist/tool-providers/index.js +2 -2
  145. package/dist/tool-providers/index.js.map +1 -1
  146. package/dist/types/adapters/llm/AnthropicProvider.d.ts +3 -3
  147. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  148. package/dist/types/adapters/llm/BedrockProvider.d.ts +3 -3
  149. package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
  150. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +3 -3
  151. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  152. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +5 -5
  153. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  154. package/dist/types/adapters/llm/OpenAIProvider.d.ts +3 -3
  155. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  156. package/dist/types/adapters/types.d.ts +95 -2
  157. package/dist/types/adapters/types.d.ts.map +1 -1
  158. package/dist/types/core/Agent.d.ts.map +1 -1
  159. package/dist/types/core/LLMCall.d.ts.map +1 -1
  160. package/dist/types/core/RunnerBase.d.ts +22 -1
  161. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  162. package/dist/types/core/agent/buildAgentChart.d.ts +7 -3
  163. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  164. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts.map +1 -1
  165. package/dist/types/core/agent/buildMessageApiChart.d.ts.map +1 -1
  166. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  167. package/dist/types/core/runner.d.ts +40 -5
  168. package/dist/types/core/runner.d.ts.map +1 -1
  169. package/dist/types/core-flow/Parallel.d.ts.map +1 -1
  170. package/dist/types/lib/context-bisect/types.d.ts +9 -0
  171. package/dist/types/lib/context-bisect/types.d.ts.map +1 -1
  172. package/dist/types/lib/recorded-chat/recordedChat.d.ts.map +1 -1
  173. package/dist/types/lib/recorded-chat/types.d.ts +10 -0
  174. package/dist/types/lib/recorded-chat/types.d.ts.map +1 -1
  175. package/dist/types/observe.d.ts +3 -1
  176. package/dist/types/observe.d.ts.map +1 -1
  177. package/dist/types/providers.d.ts +1 -1
  178. package/dist/types/providers.d.ts.map +1 -1
  179. package/dist/types/recorders/core/EmitBridge.d.ts +9 -3
  180. package/dist/types/recorders/core/EmitBridge.d.ts.map +1 -1
  181. package/dist/types/recorders/core/ResilienceRecorder.d.ts +33 -0
  182. package/dist/types/recorders/core/ResilienceRecorder.d.ts.map +1 -0
  183. package/dist/types/recorders/core/resilienceHooks.d.ts +35 -0
  184. package/dist/types/recorders/core/resilienceHooks.d.ts.map +1 -0
  185. package/dist/types/recorders/core/typedEmit.d.ts +1 -2
  186. package/dist/types/recorders/core/typedEmit.d.ts.map +1 -1
  187. package/dist/types/recorders/observability/BoundaryRecorder.d.ts +176 -12
  188. package/dist/types/recorders/observability/BoundaryRecorder.d.ts.map +1 -1
  189. package/dist/types/recorders/observability/FlowchartRecorder.d.ts +13 -2
  190. package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
  191. package/dist/types/recorders/observability/localObservability.d.ts +66 -6
  192. package/dist/types/recorders/observability/localObservability.d.ts.map +1 -1
  193. package/dist/types/recorders/observability/recordRun.d.ts +144 -0
  194. package/dist/types/recorders/observability/recordRun.d.ts.map +1 -0
  195. package/dist/types/recorders/observability/trace.d.ts +65 -13
  196. package/dist/types/recorders/observability/trace.d.ts.map +1 -1
  197. package/dist/types/reliability/buildReliabilityGateChart.d.ts +23 -9
  198. package/dist/types/reliability/buildReliabilityGateChart.d.ts.map +1 -1
  199. package/dist/types/resilience/withCircuitBreaker.d.ts +15 -5
  200. package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
  201. package/dist/types/resilience/withFallback.d.ts +7 -1
  202. package/dist/types/resilience/withFallback.d.ts.map +1 -1
  203. package/dist/types/resilience/withRetry.d.ts +10 -5
  204. package/dist/types/resilience/withRetry.d.ts.map +1 -1
  205. package/package.json +1 -1
@@ -0,0 +1,133 @@
1
+ /**
2
+ * recordRun — save a run so a viewer can show it later.
3
+ *
4
+ * A RECORDING is exactly three things, and each one lights a different
5
+ * surface:
6
+ *
7
+ * `events` the typed agentfootprint stream, in the order it fired —
8
+ * the story, the commentary, the summary.
9
+ * `snapshot` the footprintjs run snapshot — shared state, the commit
10
+ * log, and every attached recorder's data (narrative,
11
+ * metrics, boundaries).
12
+ * `structure` the agent's build-time chart — THE CHART. Nothing else
13
+ * can draw it, and no snapshot carries it.
14
+ *
15
+ * Miss one and one surface goes dark. That is why this exists: every
16
+ * integration that assembled the bundle by hand assembled a different,
17
+ * incomplete one, and the piece most often missing was `structure` —
18
+ * because a completed run does not leave it behind. This is also the
19
+ * producer for the shape lens's `observeRecording()` consumes, which
20
+ * until now nothing produced.
21
+ *
22
+ * import { recordRun } from 'agentfootprint/observe';
23
+ *
24
+ * const recorder = recordRun(agent);
25
+ * await agent.run({ message });
26
+ * fs.writeFileSync('run.json', JSON.stringify(recorder.toRecording()));
27
+ *
28
+ * …and in the viewer:
29
+ *
30
+ * const { recorder, runner } = observeRecording(JSON.parse(json)); // lens
31
+ * <Lens recorder={recorder} runner={runner} />
32
+ *
33
+ * WHAT IT WIRES THAT HAND-ROLLING GETS WRONG
34
+ * ──────────────────────────────────────────
35
+ * The boundary recorder — the one that puts stops on the step strip —
36
+ * needs three connections, and each missing one fails differently:
37
+ *
38
+ * attach no boundaries at all (loud: the strip is empty)
39
+ * subscribe boundaries with nothing in them (quiet: no LLM or
40
+ * tool detail behind any stop)
41
+ * getCommitCount every boundary stamped at commit 0 (SILENT: the
42
+ * events look complete, and the strip cannot be
43
+ * rebuilt offline — the commit log records what
44
+ * stages wrote, never when a boundary was crossed,
45
+ * so nothing downstream can repair it)
46
+ *
47
+ * Wire it before the run or not at all — none of the three can be
48
+ * reconstructed from a finished run.
49
+ *
50
+ * WHAT IT DOES NOT DO
51
+ * ───────────────────
52
+ * It attaches no OTHER recorders. `narrative()` and `metrics()` are the
53
+ * consumer's choice — their data rides the snapshot when attached, and
54
+ * each viewer says so when it isn't there (a Gantt with no timings shows
55
+ * execution ORDER and says so; a story panel falls back to "X executed.
56
+ * Wrote: y"). Attaching them behind the consumer's back would make every
57
+ * recording pay for panels most runs never open.
58
+ */
59
+ import { boundaryRecorder } from './BoundaryRecorder.js';
60
+ /** Default retained-event cap — see `RecordRunOptions.maxEvents`. */
61
+ const DEFAULT_MAX_EVENTS = 10_000;
62
+ /**
63
+ * Start recording a runner. Call BEFORE `run()` — a recording is
64
+ * collected as the run happens and cannot be reconstructed after it.
65
+ *
66
+ * @param runner the Agent / composition / pattern to record.
67
+ * @param options event cap and boundary detail level.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const recorder = recordRun(agent);
72
+ * await agent.run({ message: 'Weather in San Francisco?' });
73
+ * const recording = recorder.toRecording();
74
+ * recorder.stop();
75
+ *
76
+ * fs.writeFileSync('run.json', JSON.stringify(recording));
77
+ * ```
78
+ */
79
+ export function recordRun(runner, options = {}) {
80
+ const maxEvents = options.maxEvents ?? DEFAULT_MAX_EVENTS;
81
+ const events = [];
82
+ let dropped = 0;
83
+ // 1. THE TIMELINE. Subscribed before the run so nothing is missed —
84
+ // the dispatcher drops events with no listener rather than queuing
85
+ // them, so a late subscription starts mid-story.
86
+ const offEvents = runner.on('*', (event) => {
87
+ events.push(event);
88
+ if (events.length > maxEvents) {
89
+ events.shift();
90
+ dropped += 1;
91
+ }
92
+ });
93
+ // 2. THE BOUNDARIES — all three connections, which is the whole reason
94
+ // to call this instead of wiring it yourself. `getCommitCount` reads
95
+ // through the runner on every boundary, so it reports the count at
96
+ // that moment rather than a number captured now (when it is 0).
97
+ const boundary = boundaryRecorder({
98
+ getCommitCount: () => runner.getCommitCount(),
99
+ ...(options.boundaryDetail === 'lean' ? { snapshot: 'lean' } : {}),
100
+ });
101
+ const offAttach = runner.attach(boundary);
102
+ const offTyped = boundary.subscribe(runner);
103
+ let stopped = false;
104
+ return {
105
+ toRecording: () => ({
106
+ // Read at freeze time. Before the run there is no snapshot; during
107
+ // one it grows; after it, it is the finished run's.
108
+ snapshot: runner.getLastSnapshot(),
109
+ events: events.slice(),
110
+ // The one piece a run does not leave behind — it lives on the
111
+ // chart, which is built once and never changes.
112
+ structure: runner.getSpec().buildTimeStructure,
113
+ }),
114
+ boundary,
115
+ get eventCount() {
116
+ return events.length;
117
+ },
118
+ get droppedEvents() {
119
+ return dropped;
120
+ },
121
+ stop: () => {
122
+ // Idempotent: a consumer that stops in both a finally block and an
123
+ // unmount handler should not detach someone else's later recorder.
124
+ if (stopped)
125
+ return;
126
+ stopped = true;
127
+ offEvents();
128
+ offTyped();
129
+ offAttach();
130
+ },
131
+ };
132
+ }
133
+ //# sourceMappingURL=recordRun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordRun.js","sourceRoot":"","sources":["../../../../src/recorders/observability/recordRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAKH,OAAO,EAAE,gBAAgB,EAAyB,MAAM,uBAAuB,CAAC;AAqEhF,qEAAqE;AACrE,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;;;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AAS,EAAG,MAAM,CAAC,OAAO,EAAuC,CAAC,kBAAkB;SACrF,CAAC;QACF,QAAQ;QACR,IAAI,UAAU;YACZ,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QACD,IAAI,aAAa;YACf,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACT,mEAAmE;YACnE,mEAAmE;YACnE,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -5,14 +5,31 @@
5
5
  * `serializeTrace()` freezes that model into a `Trace` — plain JSON you can
6
6
  * persist (file, Redis, a bug report) and later rehydrate WITHOUT re-running
7
7
  * the agent. `agentfootprint-lens`'s `<Replay trace={…} />` consumes it and
8
- * rebuilds the flowchart via the existing translators.
8
+ * draws the flowchart via the existing translators.
9
9
  *
10
- * A `Trace` stores ONLY the domain-event log (the single source of truth the
11
- * Lens already reads). The step graph is ALWAYS a derived projection of those
12
- * events (footprint.js's "graph is derived, never post-processed" principle) —
13
- * it is rebuilt at render time, never stored. Storing a derived graph would be
14
- * redundant AND a redaction hazard: a second content surface a per-event
15
- * `redact` could never reach.
10
+ * A `Trace` stores the domain-event log (the single source of truth the Lens
11
+ * already reads) plus, since 7.8, the run's footprintjs snapshot. The step
12
+ * graph is ALWAYS a derived projection of those events (footprint.js's "graph
13
+ * is derived, never post-processed" principle) — it is rebuilt at render time,
14
+ * never stored. Storing a derived graph would be redundant AND a redaction
15
+ * hazard: a second content surface a per-event `redact` could never reach.
16
+ *
17
+ * WHAT A TRACE CAN AND CANNOT DRIVE
18
+ * ─────────────────────────────────
19
+ * `<Replay trace={…} />` draws the chart from `structure`, and that is all it
20
+ * draws: a static shape, not a lit-up path. It does not read `trace.events` —
21
+ * time-travel over them is a planned refinement, and until it lands an offline
22
+ * `<Replay>` is a strictly smaller view than the live `<Lens>`, not a match
23
+ * for it.
24
+ *
25
+ * For the full viewers — `<Lens>`, ExplainableShell, WhereFrom, the commit
26
+ * axis — what you want is a RECORDING: `{ snapshot, events, structure }`, the
27
+ * shape `recordRun()` produces and lens's `observeRecording()` consumes. Note
28
+ * `events` there means the TYPED agentfootprint stream (`runner.on('*')`),
29
+ * which is not the domain-event log a Trace carries: the two are different
30
+ * projections of the same run, and a Trace holds only the second. So a Trace
31
+ * with a `snapshot` can drive the snapshot-fed surfaces, but it is not itself
32
+ * a recording — reach for `recordRun()` when the destination is a viewer.
16
33
  *
17
34
  * PII / trust boundary: the event log carries real content — `llm.end.content`,
18
35
  * `tool.start.args`, `tool.end.result`, `context.injected.contentSummary`,
@@ -49,7 +66,8 @@ export interface TraceSummary {
49
66
  }
50
67
  /**
51
68
  * A JSON-lossless, UI-free snapshot of one run. Persist it, ship it, replay it.
52
- * `events` ARE the run (the graph is a derived projection, rebuilt at render).
69
+ * `events` ARE the timeline (the graph is a derived projection, rebuilt at
70
+ * render); `structure` is the chart; `snapshot` is the state the run left.
53
71
  */
54
72
  export interface Trace {
55
73
  /** Schema version. Bump on a breaking shape change. */
@@ -58,12 +76,36 @@ export interface Trace {
58
76
  readonly events: readonly DomainEvent[];
59
77
  /**
60
78
  * The serialized STATIC chart structure (footprint.js `buildTimeStructure`).
61
- * Design-time data (stage ids/names/types/edges) — UI-free. `<Replay>` rebuilds
62
- * the flowchart from this and overlays `events`, so an offline replay matches
63
- * the live `<Lens>` exactly. NOT runtime-redacted (it carries no user data; the
79
+ * Design-time data (stage ids/names/types/edges) — UI-free. `<Replay>` draws
80
+ * the flowchart from this. NOT runtime-redacted (it carries no user data; the
64
81
  * `redact` function targets runtime events).
82
+ *
83
+ * Absent, `<Replay>` has nothing to draw and says so.
65
84
  */
66
85
  readonly structure?: unknown;
86
+ /**
87
+ * The run's footprintjs snapshot (`runner.getLastSnapshot()`) — shared
88
+ * state, the commit log, and every attached recorder's data.
89
+ *
90
+ * This is the piece the snapshot-fed surfaces need and the event log cannot
91
+ * supply: ExplainableShell's memory and provenance panels, WhereFrom, and
92
+ * the commit axis all read the commit log, which is a footprintjs artifact
93
+ * and appears nowhere in `events`. Without it a Trace draws a chart and a
94
+ * timeline and nothing else — which is what every Trace captured before 7.8
95
+ * is, and why they replay as a static picture.
96
+ *
97
+ * `unknown` on purpose: this is footprintjs's shape, not agentfootprint's,
98
+ * and a Trace is a transport — it should not pin a peer's type into its own
99
+ * schema. Cast at the consumer.
100
+ *
101
+ * NOT redacted by `redact`, which runs per domain event and cannot reach
102
+ * inside a snapshot. This field carries whatever the run's own footprintjs
103
+ * redaction policy (`setRedactionPolicy()`) let through, so a run whose
104
+ * state holds secrets wants that policy set at run time — which is why
105
+ * `enable.localObservability({ includeSnapshot: true })` is opt-in and a
106
+ * redacted Trace does not quietly grow a second content surface.
107
+ */
108
+ readonly snapshot?: unknown;
67
109
  /** Optional headline totals. */
68
110
  readonly summary?: TraceSummary;
69
111
  /** Self-describing redaction state — travels with the trace. */
@@ -81,8 +123,14 @@ export interface SerializeTraceOptions {
81
123
  readonly redact?: (event: DomainEvent) => DomainEvent;
82
124
  /** Override the `redaction` label. Defaults to `'pii'` when `redact` is given, else `'none'`. */
83
125
  readonly redactionLabel?: TraceRedaction;
84
- /** The serialized static chart (`getSpec().buildTimeStructure`) — for `<Replay>` to rebuild the flowchart. */
126
+ /** The serialized static chart (`getSpec().buildTimeStructure`) — what `<Replay>` draws. */
85
127
  readonly structure?: unknown;
128
+ /**
129
+ * The run's footprintjs snapshot (`runner.getLastSnapshot()`) — the commit
130
+ * log and recorder data the snapshot-fed panels read. `enable.localObservability()`
131
+ * fills this for you; pass it explicitly when calling `serializeTrace` by hand.
132
+ */
133
+ readonly snapshot?: unknown;
86
134
  /** Optional precomputed headline rollup. */
87
135
  readonly summary?: TraceSummary;
88
136
  /** Wall-clock capture time. Pass `Date.now()` from the call site. */
@@ -102,10 +150,14 @@ export declare function redactContent(event: DomainEvent): DomainEvent;
102
150
  * `getEvents()` output.
103
151
  *
104
152
  * const trace = serializeTrace(handle.boundary.getEvents(), {
105
- * redact: redactContent, // PII stripped before it enters the trace
153
+ * redact: redactContent, // PII stripped before it enters the trace
154
+ * structure: agent.getSpec().buildTimeStructure, // the chart
155
+ * snapshot: agent.getLastSnapshot(), // state + commit log + recorders
106
156
  * capturedAtMs: Date.now(),
107
157
  * });
108
158
  * fs.writeFileSync('run.trace.json', JSON.stringify(trace));
159
+ *
160
+ * `enable.localObservability().getTrace()` passes all three for you.
109
161
  */
110
162
  export declare function serializeTrace(events: readonly DomainEvent[], options?: SerializeTraceOptions): Trace;
111
163
  /**
@@ -5,14 +5,31 @@
5
5
  * `serializeTrace()` freezes that model into a `Trace` — plain JSON you can
6
6
  * persist (file, Redis, a bug report) and later rehydrate WITHOUT re-running
7
7
  * the agent. `agentfootprint-lens`'s `<Replay trace={…} />` consumes it and
8
- * rebuilds the flowchart via the existing translators.
8
+ * draws the flowchart via the existing translators.
9
9
  *
10
- * A `Trace` stores ONLY the domain-event log (the single source of truth the
11
- * Lens already reads). The step graph is ALWAYS a derived projection of those
12
- * events (footprint.js's "graph is derived, never post-processed" principle) —
13
- * it is rebuilt at render time, never stored. Storing a derived graph would be
14
- * redundant AND a redaction hazard: a second content surface a per-event
15
- * `redact` could never reach.
10
+ * A `Trace` stores the domain-event log (the single source of truth the Lens
11
+ * already reads) plus, since 7.8, the run's footprintjs snapshot. The step
12
+ * graph is ALWAYS a derived projection of those events (footprint.js's "graph
13
+ * is derived, never post-processed" principle) — it is rebuilt at render time,
14
+ * never stored. Storing a derived graph would be redundant AND a redaction
15
+ * hazard: a second content surface a per-event `redact` could never reach.
16
+ *
17
+ * WHAT A TRACE CAN AND CANNOT DRIVE
18
+ * ─────────────────────────────────
19
+ * `<Replay trace={…} />` draws the chart from `structure`, and that is all it
20
+ * draws: a static shape, not a lit-up path. It does not read `trace.events` —
21
+ * time-travel over them is a planned refinement, and until it lands an offline
22
+ * `<Replay>` is a strictly smaller view than the live `<Lens>`, not a match
23
+ * for it.
24
+ *
25
+ * For the full viewers — `<Lens>`, ExplainableShell, WhereFrom, the commit
26
+ * axis — what you want is a RECORDING: `{ snapshot, events, structure }`, the
27
+ * shape `recordRun()` produces and lens's `observeRecording()` consumes. Note
28
+ * `events` there means the TYPED agentfootprint stream (`runner.on('*')`),
29
+ * which is not the domain-event log a Trace carries: the two are different
30
+ * projections of the same run, and a Trace holds only the second. So a Trace
31
+ * with a `snapshot` can drive the snapshot-fed surfaces, but it is not itself
32
+ * a recording — reach for `recordRun()` when the destination is a viewer.
16
33
  *
17
34
  * PII / trust boundary: the event log carries real content — `llm.end.content`,
18
35
  * `tool.start.args`, `tool.end.result`, `context.injected.contentSummary`,
@@ -66,13 +83,17 @@ export function redactContent(event) {
66
83
  * `getEvents()` output.
67
84
  *
68
85
  * const trace = serializeTrace(handle.boundary.getEvents(), {
69
- * redact: redactContent, // PII stripped before it enters the trace
86
+ * redact: redactContent, // PII stripped before it enters the trace
87
+ * structure: agent.getSpec().buildTimeStructure, // the chart
88
+ * snapshot: agent.getLastSnapshot(), // state + commit log + recorders
70
89
  * capturedAtMs: Date.now(),
71
90
  * });
72
91
  * fs.writeFileSync('run.trace.json', JSON.stringify(trace));
92
+ *
93
+ * `enable.localObservability().getTrace()` passes all three for you.
73
94
  */
74
95
  export function serializeTrace(events, options = {}) {
75
- const { redact, redactionLabel, structure, summary, capturedAtMs } = options;
96
+ const { redact, redactionLabel, structure, snapshot, summary, capturedAtMs } = options;
76
97
  // A fresh array either way, so a held Trace is detached from the live store.
77
98
  const safeEvents = redact ? events.map((e) => redact(e)) : events.slice();
78
99
  const redaction = redactionLabel ?? (redact ? 'pii' : 'none');
@@ -80,6 +101,12 @@ export function serializeTrace(events, options = {}) {
80
101
  version: 1,
81
102
  events: safeEvents,
82
103
  ...(structure !== undefined && { structure }),
104
+ // Held by reference, not cloned. footprintjs's `sharedState` is a live
105
+ // view of working memory, so a Trace taken mid-run keeps moving until the
106
+ // run ends — which is the same caveat `getSnapshot()` carries, and the
107
+ // reason `onRecorded` fires at the run's exit boundary. Serializing the
108
+ // Trace (its whole purpose) detaches it.
109
+ ...(snapshot !== undefined && { snapshot }),
83
110
  ...(summary !== undefined && { summary }),
84
111
  redaction,
85
112
  ...(capturedAtMs !== undefined && { capturedAtMs }),
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../src/recorders/observability/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,wBAAwB,EAAkB,MAAM,wBAAwB,CAAC;AA6DlF;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,SAAS,EAAE,CAAC;QAClE,KAAK,YAAY;YACf,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7E,KAAK,UAAU;YACb,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACjF,KAAK,kBAAkB;YACrB,OAAO,KAAK,CAAC,cAAc,KAAK,SAAS;gBACvC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE;gBAC5C,CAAC,CAAC,KAAK,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,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SAAS,IAAI,EAAE,YAAY,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,OAAO,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
@@ -3,9 +3,20 @@
3
3
  * an LLM call with rules-based reliability semantics, using the native
4
4
  * `decide()` DSL via `addDeciderFunction` decider stages.
5
5
  *
6
- * The returned chart is mounted as a subflow in the agent's chart at
7
- * Agent.build() time (only when reliability is configured). Inside the
8
- * subflow:
6
+ * ⚠ NOT REACHABLE FROM ANY SHIPPED PATH (verified 2026-07-28). This header
7
+ * used to say the chart "is mounted as a subflow in the agent's chart at
8
+ * Agent.build() time (only when reliability is configured)". It is not:
9
+ * `buildReliabilityGateChart` is exported from no barrel, and its only
10
+ * consumer in the repository is its own test
11
+ * (`test/reliability/gate-chart-7pattern.test.ts`). The live
12
+ * `.reliability()` path is `executeWithReliability`
13
+ * (`core/agent/stages/reliabilityExecution.ts`) driving
14
+ * `singleProviderCall` inline in `core/agent/stages/callLLM.ts` — which
15
+ * trades this chart's subflow visibility for streaming support. Keep this
16
+ * file honest rather than deleting it: it is the only implementation that
17
+ * honours the `providers` failover list (see MENTAL_MODEL §14 item 3).
18
+ *
19
+ * Inside the subflow, when something does mount it:
9
20
  *
10
21
  * PreCheck (decider) → CallProvider (function) → PostDecide (decider)
11
22
  * │
@@ -26,15 +37,18 @@
26
37
  * 'fallback' → call config.fallback(); $break() on success
27
38
  * 'fail-fast' → set failKind, $emit, $break(reason)
28
39
  *
29
- * The subflow is mounted WITHOUT `propagateBreak: true`. Subflow $break is
30
- * local — agent.ts adds a `TranslateFailFast` agent-level stage AFTER the
31
- * subflow that reads scope.reliabilityFailKind and converts it into an
32
- * agent-level `$break(reason)`. This split lets normal subflow exits
33
- * (`ok`/`fallback`) leave the agent running while fail-fast stops it.
40
+ * The design intends the subflow to be mounted WITHOUT `propagateBreak:
41
+ * true`, so subflow `$break` stays local and an agent-level
42
+ * `TranslateFailFast` stage reads `scope.reliabilityFailKind` and converts
43
+ * it into an agent-level `$break(reason)` — letting normal subflow exits
44
+ * (`ok`/`fallback`) leave the agent running while fail-fast stops it. That
45
+ * stage was never built (`grep TranslateFailFast` finds only comments), which
46
+ * is part of why nothing mounts this chart; the live path throws
47
+ * `ReliabilityFailFastError` from `Agent.run` instead.
34
48
  *
35
49
  * Three-channel discipline preserved:
36
50
  * • SCOPE STATE — failKind/failPayload/failReason mapped to parent via
37
- * outputMapper; consumed by agent's TranslateFailFast.
51
+ * outputMapper; for the intended TranslateFailFast.
38
52
  * • $emit — passive observability for external consumers.
39
53
  * • $break(reason)— control flow + human reason for narrative.
40
54
  */
@@ -3,9 +3,20 @@
3
3
  * an LLM call with rules-based reliability semantics, using the native
4
4
  * `decide()` DSL via `addDeciderFunction` decider stages.
5
5
  *
6
- * The returned chart is mounted as a subflow in the agent's chart at
7
- * Agent.build() time (only when reliability is configured). Inside the
8
- * subflow:
6
+ * ⚠ NOT REACHABLE FROM ANY SHIPPED PATH (verified 2026-07-28). This header
7
+ * used to say the chart "is mounted as a subflow in the agent's chart at
8
+ * Agent.build() time (only when reliability is configured)". It is not:
9
+ * `buildReliabilityGateChart` is exported from no barrel, and its only
10
+ * consumer in the repository is its own test
11
+ * (`test/reliability/gate-chart-7pattern.test.ts`). The live
12
+ * `.reliability()` path is `executeWithReliability`
13
+ * (`core/agent/stages/reliabilityExecution.ts`) driving
14
+ * `singleProviderCall` inline in `core/agent/stages/callLLM.ts` — which
15
+ * trades this chart's subflow visibility for streaming support. Keep this
16
+ * file honest rather than deleting it: it is the only implementation that
17
+ * honours the `providers` failover list (see MENTAL_MODEL §14 item 3).
18
+ *
19
+ * Inside the subflow, when something does mount it:
9
20
  *
10
21
  * PreCheck (decider) → CallProvider (function) → PostDecide (decider)
11
22
  * │
@@ -26,15 +37,18 @@
26
37
  * 'fallback' → call config.fallback(); $break() on success
27
38
  * 'fail-fast' → set failKind, $emit, $break(reason)
28
39
  *
29
- * The subflow is mounted WITHOUT `propagateBreak: true`. Subflow $break is
30
- * local — agent.ts adds a `TranslateFailFast` agent-level stage AFTER the
31
- * subflow that reads scope.reliabilityFailKind and converts it into an
32
- * agent-level `$break(reason)`. This split lets normal subflow exits
33
- * (`ok`/`fallback`) leave the agent running while fail-fast stops it.
40
+ * The design intends the subflow to be mounted WITHOUT `propagateBreak:
41
+ * true`, so subflow `$break` stays local and an agent-level
42
+ * `TranslateFailFast` stage reads `scope.reliabilityFailKind` and converts
43
+ * it into an agent-level `$break(reason)` — letting normal subflow exits
44
+ * (`ok`/`fallback`) leave the agent running while fail-fast stops it. That
45
+ * stage was never built (`grep TranslateFailFast` finds only comments), which
46
+ * is part of why nothing mounts this chart; the live path throws
47
+ * `ReliabilityFailFastError` from `Agent.run` instead.
34
48
  *
35
49
  * Three-channel discipline preserved:
36
50
  * • SCOPE STATE — failKind/failPayload/failReason mapped to parent via
37
- * outputMapper; consumed by agent's TranslateFailFast.
51
+ * outputMapper; for the intended TranslateFailFast.
38
52
  * • $emit — passive observability for external consumers.
39
53
  * • $break(reason)— control flow + human reason for narrative.
40
54
  */
@@ -42,6 +56,7 @@ import { decide, flowChart } from 'footprintjs';
42
56
  import { CircuitOpenError, admitCall, initialBreakerState, nextProbeTime, recordFailure, recordSuccess, } from './CircuitBreaker.js';
43
57
  import { classifyError } from './classifyError.js';
44
58
  import { typedEmit } from '../recorders/core/typedEmit.js';
59
+ import { resilienceHooks } from '../recorders/core/resilienceHooks.js';
45
60
  // ─── Stage IDs (also used for narrative/topology readability) ────────
46
61
  const STAGE_IDS = {
47
62
  INIT: 'reliability-init',
@@ -200,7 +215,19 @@ export function buildReliabilityGateChart(config) {
200
215
  throw new CircuitOpenError(providerEntry.name, nextState.lastErrorMessage, nextProbeTime(nextState, breakerConfig));
201
216
  }
202
217
  }
203
- const response = await providerEntry.provider.complete(scope.request);
218
+ // Hooks are passed here too, so a DECORATED provider does not go
219
+ // dark. This is not cross-emitting: the decorator's own account of
220
+ // its own fixed-cap decision merely happens to occur inside a
221
+ // reliability stage. The two families stay distinct —
222
+ // `reliability.*` = this rules loop's dynamic decisions, `error.*` =
223
+ // the decorator's.
224
+ //
225
+ // NOTE: this chart is currently DEAD — see the file header. The
226
+ // live `.reliability()` path is `executeWithReliability` driving
227
+ // `singleProviderCall` in `core/agent/stages/callLLM.ts`, which
228
+ // passes the same hooks. Wiring the dead site anyway keeps it from
229
+ // being a silent hole if the chart is ever revived.
230
+ const response = await providerEntry.provider.complete(scope.request, resilienceHooks(scope));
204
231
  scope.response = response;
205
232
  scope.error = undefined;
206
233
  scope.errorKind = 'ok';
@@ -1 +1 @@
1
- {"version":3,"file":"buildReliabilityGateChart.js","sourceRoot":"","sources":["../../../src/reliability/buildReliabilityGateChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,wEAAwE;AAExE,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,kBAAkB;IACxB,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;CAClB,CAAC;AAEX,qEAAqE;AACrE,uEAAuE;AACvE,wEAAwE;AACxE,uEAAuE;AACvE,MAAM,UAAU,GAAG;IACjB,oBAAoB;IACpB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;IAC9B,sBAAsB;IACtB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,gBAA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C,UAAU,CAAC,aAAa,EAAE,aAAa,EAAE,mBAAmB,CAAC;SAC/E,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC;SACnC,GAAG,EAAE;SACL,WAAW,CACV,cAAc,EACd,mBAAmB,EACnB,SAAS,CAAC,aAAa,EACvB,sDAAsD,CACvD;SACA,kBAAkB,CACjB,YAAY,EACZ,mBAAmB,EACnB,SAAS,CAAC,WAAW,EACrB,mCAAmC,CACpC;SACA,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC;SAC3D,iBAAiB,CAAC,UAAU,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC;SACpE,iBAAiB,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;SACpF,iBAAiB,CAAC,UAAU,CAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,CAAC;SAC7E,iBAAiB,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,EAAE,gBAAgB,CAAC;SAC9E,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;SAC9B,GAAG,EAAE;SACL,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;SAC3B,KAAK,EAAE,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"buildReliabilityGateChart.js","sourceRoot":"","sources":["../../../src/reliability/buildReliabilityGateChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO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,gBAAgB,CAAC;SAC9E,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;SAC9B,GAAG,EAAE;SACL,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;SAC3B,KAAK,EAAE,CAAC;AACb,CAAC"}
@@ -48,9 +48,12 @@
48
48
  *
49
49
  * HALF-OPEN ──[ probe failure ]──► OPEN (cooldown restarts)
50
50
  *
51
- * `stream()` is decorated identically. `name`/`flush`/`stop` pass
52
- * through unchanged (the consumer's existing observability hooks
53
- * still see the underlying provider's identity).
51
+ * `stream()` is decorated identically. `name` passes through unchanged
52
+ * (the consumer's existing observability hooks still see the underlying
53
+ * provider's identity), and the optional per-call `LLMCallHooks` is
54
+ * forwarded inward so a decorator nested inside this one can still
55
+ * report. Nothing else is copied — `LLMProvider` has exactly `name`,
56
+ * `complete` and the optional `stream`.
54
57
  *
55
58
  * **Scope: per-instance, NOT distributed.** Each `withCircuitBreaker(...)`
56
59
  * call holds its own breaker state in process memory. If you run 100
@@ -93,8 +96,15 @@ export interface WithCircuitBreakerOptions {
93
96
  * breaker for everyone.
94
97
  */
95
98
  readonly shouldCount?: (error: unknown) => boolean;
96
- /** Hook invoked on every state transition. Useful for emitting
97
- * `agentfootprint.resilience.circuit_state_changed`. */
99
+ /**
100
+ * Hook invoked on every state transition. This is the ONLY way to
101
+ * observe breaker state: there is no declared event for a breaker
102
+ * transition, so unlike `withFallback`/`withRetry` this decorator
103
+ * reports nothing through the in-run `LLMCallHooks` channel. A trip
104
+ * becomes visible in a trace only when composed under
105
+ * `withFallback`, whose `agentfootprint.fallback.triggered` carries
106
+ * the `CircuitOpenError` message as its `reason`.
107
+ */
98
108
  readonly onStateChange?: (state: CircuitState, reason: string) => void;
99
109
  }
100
110
  export type CircuitState = 'closed' | 'open' | 'half-open';
@@ -48,9 +48,12 @@
48
48
  *
49
49
  * HALF-OPEN ──[ probe failure ]──► OPEN (cooldown restarts)
50
50
  *
51
- * `stream()` is decorated identically. `name`/`flush`/`stop` pass
52
- * through unchanged (the consumer's existing observability hooks
53
- * still see the underlying provider's identity).
51
+ * `stream()` is decorated identically. `name` passes through unchanged
52
+ * (the consumer's existing observability hooks still see the underlying
53
+ * provider's identity), and the optional per-call `LLMCallHooks` is
54
+ * forwarded inward so a decorator nested inside this one can still
55
+ * report. Nothing else is copied — `LLMProvider` has exactly `name`,
56
+ * `complete` and the optional `stream`.
54
57
  *
55
58
  * **Scope: per-instance, NOT distributed.** Each `withCircuitBreaker(...)`
56
59
  * call holds its own breaker state in process memory. If you run 100
@@ -191,10 +194,13 @@ export function withCircuitBreaker(inner, options = {}) {
191
194
  }
192
195
  const wrapped = {
193
196
  name: inner.name,
194
- async complete(req) {
197
+ async complete(req, hooks) {
195
198
  rejectFastIfOpen();
196
199
  try {
197
- const res = await inner.complete(req);
200
+ // Forward `hooks` — this decorator reports nothing of its own, but
201
+ // it rebuilds a fresh provider object, so an inner decorator's
202
+ // reports are silently swallowed unless they're passed through.
203
+ const res = await inner.complete(req, hooks);
198
204
  recordSuccess();
199
205
  return res;
200
206
  }
@@ -208,15 +214,16 @@ export function withCircuitBreaker(inner, options = {}) {
208
214
  // it undefined so the consumer's existing capability check
209
215
  // (`if (provider.stream)`) still works correctly.
210
216
  ...(inner.stream && {
211
- async *stream(req) {
217
+ async *stream(req, hooks) {
212
218
  rejectFastIfOpen();
213
219
  let yieldedAnyChunk = false;
214
220
  try {
215
221
  // This stream() method is conditionally defined only when
216
222
  // inner.stream exists (see `...(inner.stream && {` above), so
217
223
  // inner.stream is guaranteed non-null inside this body.
224
+ // `hooks` is forwarded for the same reason as in complete().
218
225
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
219
- for await (const chunk of inner.stream(req)) {
226
+ for await (const chunk of inner.stream(req, hooks)) {
220
227
  yieldedAnyChunk = true;
221
228
  yield chunk;
222
229
  }