agentfootprint 2.7.2 → 2.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 (68) hide show
  1. package/dist/core/RunnerBase.js +6 -0
  2. package/dist/core/RunnerBase.js.map +1 -1
  3. package/dist/esm/core/RunnerBase.js +6 -0
  4. package/dist/esm/core/RunnerBase.js.map +1 -1
  5. package/dist/esm/strategies/attach.js +227 -0
  6. package/dist/esm/strategies/attach.js.map +1 -0
  7. package/dist/esm/strategies/compose.js +158 -0
  8. package/dist/esm/strategies/compose.js.map +1 -0
  9. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.js +34 -0
  10. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.js.map +1 -0
  11. package/dist/esm/strategies/defaults/consoleObservability.js +61 -0
  12. package/dist/esm/strategies/defaults/consoleObservability.js.map +1 -0
  13. package/dist/esm/strategies/defaults/inMemorySinkCost.js +48 -0
  14. package/dist/esm/strategies/defaults/inMemorySinkCost.js.map +1 -0
  15. package/dist/esm/strategies/defaults/index.js +31 -0
  16. package/dist/esm/strategies/defaults/index.js.map +1 -0
  17. package/dist/esm/strategies/defaults/noopLens.js +29 -0
  18. package/dist/esm/strategies/defaults/noopLens.js.map +1 -0
  19. package/dist/esm/strategies/index.js +23 -0
  20. package/dist/esm/strategies/index.js.map +1 -0
  21. package/dist/esm/strategies/registry.js +102 -0
  22. package/dist/esm/strategies/registry.js.map +1 -0
  23. package/dist/esm/strategies/types.js +36 -0
  24. package/dist/esm/strategies/types.js.map +1 -0
  25. package/dist/strategies/attach.js +256 -0
  26. package/dist/strategies/attach.js.map +1 -0
  27. package/dist/strategies/compose.js +165 -0
  28. package/dist/strategies/compose.js.map +1 -0
  29. package/dist/strategies/defaults/chatBubbleLiveStatus.js +38 -0
  30. package/dist/strategies/defaults/chatBubbleLiveStatus.js.map +1 -0
  31. package/dist/strategies/defaults/consoleObservability.js +65 -0
  32. package/dist/strategies/defaults/consoleObservability.js.map +1 -0
  33. package/dist/strategies/defaults/inMemorySinkCost.js +52 -0
  34. package/dist/strategies/defaults/inMemorySinkCost.js.map +1 -0
  35. package/dist/strategies/defaults/index.js +38 -0
  36. package/dist/strategies/defaults/index.js.map +1 -0
  37. package/dist/strategies/defaults/noopLens.js +33 -0
  38. package/dist/strategies/defaults/noopLens.js.map +1 -0
  39. package/dist/strategies/index.js +47 -0
  40. package/dist/strategies/index.js.map +1 -0
  41. package/dist/strategies/registry.js +118 -0
  42. package/dist/strategies/registry.js.map +1 -0
  43. package/dist/strategies/types.js +37 -0
  44. package/dist/strategies/types.js.map +1 -0
  45. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  46. package/dist/types/core/runner.d.ts +29 -2
  47. package/dist/types/core/runner.d.ts.map +1 -1
  48. package/dist/types/strategies/attach.d.ts +48 -0
  49. package/dist/types/strategies/attach.d.ts.map +1 -0
  50. package/dist/types/strategies/compose.d.ts +49 -0
  51. package/dist/types/strategies/compose.d.ts.map +1 -0
  52. package/dist/types/strategies/defaults/chatBubbleLiveStatus.d.ts +37 -0
  53. package/dist/types/strategies/defaults/chatBubbleLiveStatus.d.ts.map +1 -0
  54. package/dist/types/strategies/defaults/consoleObservability.d.ts +43 -0
  55. package/dist/types/strategies/defaults/consoleObservability.d.ts.map +1 -0
  56. package/dist/types/strategies/defaults/inMemorySinkCost.d.ts +51 -0
  57. package/dist/types/strategies/defaults/inMemorySinkCost.d.ts.map +1 -0
  58. package/dist/types/strategies/defaults/index.d.ts +31 -0
  59. package/dist/types/strategies/defaults/index.d.ts.map +1 -0
  60. package/dist/types/strategies/defaults/noopLens.d.ts +29 -0
  61. package/dist/types/strategies/defaults/noopLens.d.ts.map +1 -0
  62. package/dist/types/strategies/index.d.ts +23 -0
  63. package/dist/types/strategies/index.d.ts.map +1 -0
  64. package/dist/types/strategies/registry.d.ts +71 -0
  65. package/dist/types/strategies/registry.d.ts.map +1 -0
  66. package/dist/types/strategies/types.d.ts +304 -0
  67. package/dist/types/strategies/types.d.ts.map +1 -0
  68. package/package.json +5 -5
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Default strategies — the four "shipped in core" sinks.
3
+ *
4
+ * `consoleObservability` — print events to console
5
+ * `inMemorySinkCost` — accumulate cost ticks in a process-local buffer
6
+ * `chatBubbleLiveStatus` — call a consumer-supplied line callback
7
+ * `noopLens` — drop graph updates (zero-arg fallback)
8
+ *
9
+ * Vendor strategies (datadog, otel, agentcore, cloudwatch, …) ship as
10
+ * separate subpaths with peer-dep on the vendor SDK. See
11
+ * `docs/inspiration/strategy-everywhere.md` for the AWS-first roadmap.
12
+ *
13
+ * ─────────────────────────────────────────────────────────────────
14
+ * Why defaults skip `validate()`:
15
+ *
16
+ * The optional `BaseStrategy.validate()` hook is the right place for
17
+ * runtime config checks (API keys, endpoint reachability, peer-dep
18
+ * presence). Defaults skip it by design — their inputs are TypeScript-
19
+ * checked at construction, and they don't talk to a remote vendor that
20
+ * might be misconfigured.
21
+ *
22
+ * Vendor strategies that DO talk to a remote (datadog, agentcore,
23
+ * cloudwatch) MUST implement `validate()` per the New Relic panel
24
+ * review — early-fail-with-useful-message beats silent zero-emission.
25
+ * ─────────────────────────────────────────────────────────────────
26
+ */
27
+ export { consoleObservability } from './consoleObservability.js';
28
+ export { inMemorySinkCost, } from './inMemorySinkCost.js';
29
+ export { chatBubbleLiveStatus } from './chatBubbleLiveStatus.js';
30
+ export { noopLens } from './noopLens.js';
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/strategies/defaults/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,oBAAoB,EAAoC,MAAM,2BAA2B,CAAC;AACnG,OAAO,EACL,gBAAgB,GAGjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAoC,MAAM,2BAA2B,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAwB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `noopLens()` — default LensStrategy.
3
+ *
4
+ * Pattern: Strategy. Wildcard fallback. Same role as `NoOpCacheStrategy`.
5
+ * Role: Drops every update. Used when no Lens vendor strategy is
6
+ * configured AND the consumer hasn't supplied a callback.
7
+ * Keeps `enable.lens()` callable without args without
8
+ * throwing — important for the zero-arg HelloWorld pattern.
9
+ *
10
+ * Use when:
11
+ * - You want the agent to run without a Lens UI (production
12
+ * server-side, headless eval, batch jobs)
13
+ * - Tier-1 of compose chains where you want the chain to compile
14
+ * even if the real Lens strategy is conditional
15
+ *
16
+ * Don't use when: you actually want to see the StepGraph. Use
17
+ * `lens-browser`, `lens-cli`, or `lens-jsonExport` from the
18
+ * vendor-strategy subpaths once they ship in v2.12+.
19
+ */
20
+ export function noopLens(opts = {}) {
21
+ return {
22
+ name: 'noop-lens',
23
+ capabilities: { interactive: false, serializable: false },
24
+ renderGraph(update) {
25
+ opts.onUpdate?.(update);
26
+ },
27
+ };
28
+ }
29
+ //# sourceMappingURL=noopLens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noopLens.js","sourceRoot":"","sources":["../../../../src/strategies/defaults/noopLens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAYH,MAAM,UAAU,QAAQ,CAAC,OAAwB,EAAE;IACjD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,YAAY,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE;QACzD,WAAW,CAAC,MAAkB;YAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `agentfootprint/strategies` — typed strategy interfaces + default
3
+ * sinks for the v2.8 grouped-enabler architecture.
4
+ *
5
+ * See:
6
+ * - `docs/inspiration/strategy-everywhere.md` — design memo + AWS-first roadmap
7
+ * - `types.ts` — typed interfaces (Observability, Cost, LiveStatus, Lens)
8
+ * - `defaults/` — the 4 in-core default strategies
9
+ *
10
+ * Vendor strategies ship as separate subpaths:
11
+ * - `agentfootprint/observability-agentcore` (v2.8.1)
12
+ * - `agentfootprint/observability-cloudwatch` (v2.8.2)
13
+ * - `agentfootprint/observability-xray` (v2.8.3)
14
+ * - `agentfootprint/observability-otel` (v2.9.x)
15
+ * - `agentfootprint/observability-datadog` (v2.9.x)
16
+ * - `agentfootprint/cost-stripe` (v2.10.x)
17
+ * - `agentfootprint/lens-browser` / `lens-cli` (v2.12.x)
18
+ */
19
+ export * from './types.js';
20
+ export * from './defaults/index.js';
21
+ export { composeObservability, composeCost, composeLiveStatus, composeLens } from './compose.js';
22
+ export { attachObservabilityStrategy, attachCostStrategy, attachLiveStatusStrategy, } from './attach.js';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strategies/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,GAIzB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Strategy registry — name → factory for each of the 4 groups.
3
+ *
4
+ * Mirrors `src/cache/strategyRegistry.ts` exactly: maps a string name
5
+ * to a factory function that takes vendor-specific config and returns
6
+ * a typed strategy instance. Vendor adapter subpaths self-register on
7
+ * import via side-effect.
8
+ *
9
+ * Two ways consumers wire a strategy:
10
+ *
11
+ * 1. By NAME (registry lookup) — the recommended path for vendor
12
+ * adapters:
13
+ * ```ts
14
+ * import 'agentfootprint/observability-datadog'; // self-registers 'datadog'
15
+ * agent.enable.observability({ vendor: 'datadog', config: { apiKey } });
16
+ * ```
17
+ *
18
+ * 2. By INSTANCE (explicit pass) — for custom in-house strategies
19
+ * or test mocks:
20
+ * ```ts
21
+ * agent.enable.observability({ strategy: myCustomStrategy });
22
+ * ```
23
+ *
24
+ * The two paths are mutually exclusive in `EnableOptions` — the type
25
+ * union enforces that consumers pick one.
26
+ *
27
+ * Lookup is exact-match by name (case-insensitive fallback). Unknown
28
+ * names return `undefined`; the consumer's `enable.X` then no-ops
29
+ * (per "do nothing if not configured" rule).
30
+ */
31
+ // ─── 4 registries (one per group) ────────────────────────────────────
32
+ const OBSERVABILITY_REGISTRY = new Map();
33
+ const COST_REGISTRY = new Map();
34
+ const LIVE_STATUS_REGISTRY = new Map();
35
+ const LENS_REGISTRY = new Map();
36
+ // ─── Register / lookup / list — observability ────────────────────────
37
+ /**
38
+ * Register a vendor observability strategy by name. Called from the
39
+ * vendor's subpath at module load (side-effect import):
40
+ *
41
+ * ```ts
42
+ * // agentfootprint/observability-datadog/index.ts
43
+ * import { registerObservabilityStrategy } from 'agentfootprint/strategies';
44
+ * registerObservabilityStrategy('datadog', (config) => datadogObservability(config));
45
+ * ```
46
+ *
47
+ * Replacing an existing registration is allowed — most-recent wins.
48
+ * Useful for test mocks.
49
+ */
50
+ export function registerObservabilityStrategy(name, factory) {
51
+ OBSERVABILITY_REGISTRY.set(name, factory);
52
+ }
53
+ /** Look up an observability factory by vendor name. Case-insensitive
54
+ * fallback. Returns `undefined` when the name is unknown — caller
55
+ * decides to noop or throw. */
56
+ export function getObservabilityStrategy(name) {
57
+ return OBSERVABILITY_REGISTRY.get(name) ?? OBSERVABILITY_REGISTRY.get(name.toLowerCase());
58
+ }
59
+ /** Diagnostic — list all registered vendor names. */
60
+ export function listObservabilityStrategies() {
61
+ return [...OBSERVABILITY_REGISTRY.keys()];
62
+ }
63
+ // ─── Cost ────────────────────────────────────────────────────────────
64
+ export function registerCostStrategy(name, factory) {
65
+ COST_REGISTRY.set(name, factory);
66
+ }
67
+ export function getCostStrategy(name) {
68
+ return COST_REGISTRY.get(name) ?? COST_REGISTRY.get(name.toLowerCase());
69
+ }
70
+ export function listCostStrategies() {
71
+ return [...COST_REGISTRY.keys()];
72
+ }
73
+ // ─── Live status ─────────────────────────────────────────────────────
74
+ export function registerLiveStatusStrategy(name, factory) {
75
+ LIVE_STATUS_REGISTRY.set(name, factory);
76
+ }
77
+ export function getLiveStatusStrategy(name) {
78
+ return LIVE_STATUS_REGISTRY.get(name) ?? LIVE_STATUS_REGISTRY.get(name.toLowerCase());
79
+ }
80
+ export function listLiveStatusStrategies() {
81
+ return [...LIVE_STATUS_REGISTRY.keys()];
82
+ }
83
+ // ─── Lens ────────────────────────────────────────────────────────────
84
+ export function registerLensStrategy(name, factory) {
85
+ LENS_REGISTRY.set(name, factory);
86
+ }
87
+ export function getLensStrategy(name) {
88
+ return LENS_REGISTRY.get(name) ?? LENS_REGISTRY.get(name.toLowerCase());
89
+ }
90
+ export function listLensStrategies() {
91
+ return [...LENS_REGISTRY.keys()];
92
+ }
93
+ // ─── Test helpers ────────────────────────────────────────────────────
94
+ /** Reset every registry to empty. Tests only — not in the public
95
+ * barrel. */
96
+ export function _resetRegistriesForTests() {
97
+ OBSERVABILITY_REGISTRY.clear();
98
+ COST_REGISTRY.clear();
99
+ LIVE_STATUS_REGISTRY.clear();
100
+ LENS_REGISTRY.clear();
101
+ }
102
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/strategies/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAmBH,wEAAwE;AAExE,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAgC,CAAC;AACvE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;AACrD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAA6B,CAAC;AACl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AAU,wBAAwB;IACtC,OAAO,CAAC,GAAG,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,wEAAwE;AAExE,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,OAAoB;IACrE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,wEAAwE;AAExE;cACc;AACd,MAAM,UAAU,wBAAwB;IACtC,sBAAsB,CAAC,KAAK,EAAE,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,CAAC;IACtB,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAC7B,aAAa,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Strategy interface types for the v2.8 grouped-enabler architecture.
3
+ *
4
+ * Pattern: Strategy + Bridge + Hexagonal port. See the design memo
5
+ * `docs/inspiration/strategy-everywhere.md`.
6
+ *
7
+ * Four groups, four typed strategy interfaces. Each follows the same
8
+ * shape (one canonical contract, locked at the type level):
9
+ *
10
+ * 1. `name: string` — registry key for auto-registration
11
+ * 2. `capabilities: {...}` — what this strategy supports
12
+ * 3. `onEvent(...)` — hot path; sync, side-effect-only
13
+ * 4. `flush?(): Promise<void>` — optional batch flushing
14
+ * 5. `stop?(): void` — optional teardown
15
+ *
16
+ * Design constraints (from the panel review):
17
+ * - **PASSIVE / non-blocking by construction.** Strategies are
18
+ * observers — they NEVER block the agent loop. Async work
19
+ * (HTTP shipment, disk I/O, batching) is the STRATEGY's internal
20
+ * concern: buffer in `onEvent` (sync), drain in `flush()` (async
21
+ * OK). The dispatcher never awaits a strategy's `onEvent`.
22
+ * - `onEvent` MUST be sync `void`. MUST NOT throw. Errors caught +
23
+ * routed to `_onError` at the dispatch layer; one bad strategy
24
+ * never breaks the agent loop.
25
+ * - Idempotent registration — registering the same `name` twice
26
+ * replaces, doesn't double-fire.
27
+ * - `stop()` is idempotent — halts everything that strategy enabled,
28
+ * nothing else, calling twice is a no-op.
29
+ * - `flush()` is optional, may be sync OR async — strategies that
30
+ * don't batch can omit it. Consumer's `agent.run()` lifecycle
31
+ * calls flush at boundary points (turn end, run end) so batched
32
+ * strategies don't lose tail events. Flush is the ONLY async
33
+ * path; the hot path is always sync.
34
+ */
35
+ export {};
36
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/strategies/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG"}
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ /**
3
+ * Wire each grouped strategy to its data source on the dispatcher /
4
+ * recorder substrate. These are the 4 `enable.*` facades' actual
5
+ * implementations; `RunnerBase.enable` calls them with the right
6
+ * dispatcher / attach handle.
7
+ *
8
+ * Pattern: every facade follows the same shape:
9
+ *
10
+ * 1. Resolve strategy (consumer-supplied OR default)
11
+ * 2. Run `strategy.validate?()` — early-fail on misconfig (New Relic
12
+ * panel review)
13
+ * 3. Set up subscription / projection
14
+ * 4. Apply per-strategy event-type filter (`relevantEventTypes`)
15
+ * 5. Apply per-call sample rate
16
+ * 6. Wrap calls in try/catch — route errors to `_onError` (passive
17
+ * recorder rule: never throw to caller)
18
+ * 7. Return Unsubscribe (or handle for lens)
19
+ */
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
33
+ }) : function(o, v) {
34
+ o["default"] = v;
35
+ });
36
+ var __importStar = (this && this.__importStar) || function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.attachLiveStatusStrategy = exports.attachCostStrategy = exports.attachObservabilityStrategy = void 0;
45
+ const footprintjs_1 = require("footprintjs");
46
+ const thinkingTemplates_js_1 = require("../recorders/observability/thinking/thinkingTemplates.js");
47
+ // Registry-lookup helpers (`getObservabilityStrategy` etc.) are
48
+ // defined in `./registry.js` and used by consumers via the
49
+ // `enable.*({ vendor, config })` path elsewhere — not used in the
50
+ // current attach() implementations, which take `opts.strategy` directly.
51
+ /**
52
+ * Sentinel returned when consumer calls `enable.X()` without supplying
53
+ * a strategy or vendor. We DON'T auto-default — that would be an
54
+ * unwelcome opinion. Consumer chose to call `enable.X` but didn't hand
55
+ * us anywhere to ship; just no-op silently and return a stoppable
56
+ * unsubscribe so the call site stays composable.
57
+ */
58
+ const NOOP_UNSUBSCRIBE = () => { };
59
+ /** Build a one-stage flowchart that performs `args.work(event)` and
60
+ * routes any thrown error to `args.onError`. The driver schedules
61
+ * this chart per event. */
62
+ function buildDetachWrapperChart(args) {
63
+ return (0, footprintjs_1.flowChart)('agentfootprint:detach:wrapper', async (scope) => {
64
+ const event = scope.$getArgs();
65
+ try {
66
+ args.work(event);
67
+ }
68
+ catch (err) {
69
+ args.onError?.(err instanceof Error ? err : new Error(String(err)), event);
70
+ }
71
+ }, 'wrap').build();
72
+ }
73
+ let detachExecutorSingleton;
74
+ /** Lazy-import a shared `FlowChartExecutor` we use purely as the
75
+ * bare-executor entry point for `detachAndForget` / `detachAndJoinLater`.
76
+ * No chart actually runs through it — we just need its detach methods. */
77
+ async function getDetachExecutor() {
78
+ if (detachExecutorSingleton)
79
+ return detachExecutorSingleton;
80
+ const fp = await Promise.resolve().then(() => __importStar(require('footprintjs')));
81
+ // Trivial host chart — never run, just satisfies the constructor.
82
+ const noopChart = fp.flowChart('agentfootprint:detach:host', async () => { }, 'host').build();
83
+ detachExecutorSingleton = new fp.FlowChartExecutor(noopChart);
84
+ return detachExecutorSingleton;
85
+ }
86
+ /**
87
+ * Build an event-handling function that respects `opts.detach`.
88
+ *
89
+ * - `opts.detach` undefined → returns a sync handler that runs
90
+ * `work(event)` inline and routes errors to `onError`. Same as
91
+ * pre-v2.8 behavior.
92
+ *
93
+ * - `opts.detach` set → returns a handler that schedules a wrapper
94
+ * chart on the driver. `mode === 'forget'` discards the handle;
95
+ * `mode === 'join-later'` delivers it to `opts.detach.onHandle`.
96
+ *
97
+ * The detached path is async-loaded — the executor singleton is built
98
+ * on first call so consumers who don't enable detach pay zero cost.
99
+ */
100
+ function buildEventHandler(detach, args) {
101
+ if (!detach) {
102
+ // Sync path — current behavior.
103
+ return (event) => {
104
+ try {
105
+ args.work(event);
106
+ }
107
+ catch (err) {
108
+ args.onError?.(err instanceof Error ? err : new Error(String(err)), event);
109
+ }
110
+ };
111
+ }
112
+ // Detached path — schedule via the driver. We need the wrapper chart
113
+ // (for the runChild side) and the executor (for the bare-executor
114
+ // entry point that returns / discards the handle).
115
+ const wrapperChart = buildDetachWrapperChart(args);
116
+ const mode = detach.mode ?? 'forget';
117
+ const onHandle = detach.onHandle;
118
+ if (mode === 'join-later' && !onHandle) {
119
+ throw new TypeError(`[enable.*] detach.mode === 'join-later' requires \`onHandle\`. ` +
120
+ `Without it, the returned DetachHandle would be unreachable. ` +
121
+ `Pass \`onHandle: (h) => myHandles.push(h)\` (and await later via ` +
122
+ `Promise.all(myHandles.map(h => h.wait()))).`);
123
+ }
124
+ return (event) => {
125
+ // Lazy-resolve the executor. The Promise here is fire-and-forget
126
+ // itself — we never await it, so the agent loop returns sync. Any
127
+ // error from the import OR the schedule call routes to onError.
128
+ getDetachExecutor()
129
+ .then((exec) => {
130
+ if (mode === 'forget') {
131
+ exec.detachAndForget(detach.driver, wrapperChart, event);
132
+ }
133
+ else {
134
+ const handle = exec.detachAndJoinLater(detach.driver, wrapperChart, event);
135
+ onHandle(handle);
136
+ }
137
+ })
138
+ .catch((err) => {
139
+ args.onError?.(err instanceof Error ? err : new Error(String(err)), event);
140
+ });
141
+ };
142
+ }
143
+ const TIER_FILTER = {
144
+ minimal: (t) => t.startsWith('agentfootprint.error.') || t.startsWith('agentfootprint.agent.'),
145
+ standard: (t) => !t.startsWith('agentfootprint.stream.token'),
146
+ firehose: () => true,
147
+ };
148
+ function attachObservabilityStrategy(dispatcher, opts = {}) {
149
+ const strategy = opts.strategy;
150
+ // Consumer chose to call enable.observability() but didn't supply
151
+ // a strategy. Don't auto-default — that imposes an opinion. Just
152
+ // no-op so the call site stays composable.
153
+ if (!strategy)
154
+ return NOOP_UNSUBSCRIBE;
155
+ strategy.validate?.();
156
+ const tierFilter = TIER_FILTER[opts.tier ?? 'standard'];
157
+ const sampleRate = opts.sampleRate ?? 1;
158
+ const relevant = strategy.relevantEventTypes
159
+ ? new Set(strategy.relevantEventTypes)
160
+ : null;
161
+ // Build the event handler ONCE per attach call. Sync if no
162
+ // `opts.detach`; otherwise schedules on the driver so the agent
163
+ // loop never blocks on slow exporters.
164
+ const handle = buildEventHandler(opts.detach, {
165
+ work: (event) => strategy.exportEvent(event),
166
+ onError: (err, event) => strategy._onError?.(err, event),
167
+ });
168
+ return dispatcher.on('*', (event) => {
169
+ if (!tierFilter(event.type))
170
+ return;
171
+ if (relevant && !relevant.has(event.type))
172
+ return;
173
+ if (sampleRate < 1 && Math.random() > sampleRate)
174
+ return;
175
+ handle(event);
176
+ });
177
+ }
178
+ exports.attachObservabilityStrategy = attachObservabilityStrategy;
179
+ /**
180
+ * Subscribe to `agentfootprint.cost.tick` events, project payload into
181
+ * the canonical `CostTick` shape, hand to strategy.
182
+ */
183
+ function attachCostStrategy(dispatcher, opts = {}) {
184
+ const strategy = opts.strategy;
185
+ if (!strategy)
186
+ return NOOP_UNSUBSCRIBE;
187
+ strategy.validate?.();
188
+ // Cost strategy detach mirrors observability — sync by default,
189
+ // schedules on the driver when `opts.detach` is set. Useful when
190
+ // `recordCost` does heavy work (per-tick DB write, vendor budget
191
+ // API, etc.).
192
+ const handle = buildEventHandler(opts.detach, {
193
+ work: (tickInput) => strategy.recordCost(tickInput),
194
+ onError: (err, tickInput) => strategy._onError?.(err, tickInput),
195
+ });
196
+ return dispatcher.on('agentfootprint.cost.tick', (event) => {
197
+ const p = event.payload;
198
+ const tick = {
199
+ cumulativeInputTokens: Number(p.cumulativeInputTokens ?? 0),
200
+ cumulativeOutputTokens: Number(p.cumulativeOutputTokens ?? 0),
201
+ cumulativeCostUsd: Number(p.cumulativeCostUsd ?? 0),
202
+ recentInputTokens: Number(p.recentInputTokens ?? 0),
203
+ recentOutputTokens: Number(p.recentOutputTokens ?? 0),
204
+ recentCostUsd: Number(p.recentCostUsd ?? 0),
205
+ model: String(p.model ?? 'unknown'),
206
+ ...(typeof p.iteration === 'number' ? { iteration: p.iteration } : {}),
207
+ ...(typeof p.runtimeStageId === 'string' ? { runtimeStageId: p.runtimeStageId } : {}),
208
+ };
209
+ handle(tick);
210
+ });
211
+ }
212
+ exports.attachCostStrategy = attachCostStrategy;
213
+ /**
214
+ * Subscribe to '*', maintain a rolling event log, project current
215
+ * thinking state on each event, render via templates, hand to strategy.
216
+ *
217
+ * Lower bound on emissions: dedupes — only fires `renderStatus` when
218
+ * the rendered line CHANGES (avoids floods on every token).
219
+ */
220
+ /** Sliding-window cap for `attachLiveStatusStrategy`'s internal event
221
+ * log. Long-lived agent servers would otherwise leak memory through
222
+ * unbounded growth (per OTel SIG panel review). The cap is high
223
+ * enough that `selectThinkingState` always sees the relevant recent
224
+ * history. */
225
+ const LIVE_STATUS_LOG_CAP = 1000;
226
+ function attachLiveStatusStrategy(dispatcher, opts) {
227
+ opts.strategy.validate?.();
228
+ const templates = { ...thinkingTemplates_js_1.defaultThinkingTemplates, ...(opts.templates ?? {}) };
229
+ const ctx = { appName: opts.appName ?? 'Agent' };
230
+ const eventLog = [];
231
+ let lastLine = null;
232
+ return dispatcher.on('*', (event) => {
233
+ eventLog.push(event);
234
+ // Sliding-window — drop oldest when over cap. O(1) amortized
235
+ // because shift() runs only once per overflow.
236
+ while (eventLog.length > LIVE_STATUS_LOG_CAP)
237
+ eventLog.shift();
238
+ const state = (0, thinkingTemplates_js_1.selectThinkingState)(eventLog);
239
+ if (!state) {
240
+ lastLine = null;
241
+ return;
242
+ }
243
+ const line = (0, thinkingTemplates_js_1.renderThinkingLine)(state, ctx, templates);
244
+ if (line === null || line === lastLine)
245
+ return;
246
+ lastLine = line;
247
+ try {
248
+ opts.strategy.renderStatus({ line, state });
249
+ }
250
+ catch (err) {
251
+ opts.strategy._onError?.(err instanceof Error ? err : new Error(String(err)), event);
252
+ }
253
+ });
254
+ }
255
+ exports.attachLiveStatusStrategy = attachLiveStatusStrategy;
256
+ //# sourceMappingURL=attach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach.js","sourceRoot":"","sources":["../../src/strategies/attach.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAwC;AAexC,mGAKkE;AAClE,gEAAgE;AAChE,2DAA2D;AAC3D,kEAAkE;AAClE,yEAAyE;AAEzE;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAgB,GAAG,EAAE,GAAE,CAA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