agentfootprint 2.7.3 → 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.
- package/dist/core/RunnerBase.js +6 -0
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/RunnerBase.js +6 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/strategies/attach.js +227 -0
- package/dist/esm/strategies/attach.js.map +1 -0
- package/dist/esm/strategies/compose.js +158 -0
- package/dist/esm/strategies/compose.js.map +1 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.js +34 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.js.map +1 -0
- package/dist/esm/strategies/defaults/consoleObservability.js +61 -0
- package/dist/esm/strategies/defaults/consoleObservability.js.map +1 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.js +48 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.js.map +1 -0
- package/dist/esm/strategies/defaults/index.js +31 -0
- package/dist/esm/strategies/defaults/index.js.map +1 -0
- package/dist/esm/strategies/defaults/noopLens.js +29 -0
- package/dist/esm/strategies/defaults/noopLens.js.map +1 -0
- package/dist/esm/strategies/index.js +23 -0
- package/dist/esm/strategies/index.js.map +1 -0
- package/dist/esm/strategies/registry.js +102 -0
- package/dist/esm/strategies/registry.js.map +1 -0
- package/dist/esm/strategies/types.js +36 -0
- package/dist/esm/strategies/types.js.map +1 -0
- package/dist/strategies/attach.js +256 -0
- package/dist/strategies/attach.js.map +1 -0
- package/dist/strategies/compose.js +165 -0
- package/dist/strategies/compose.js.map +1 -0
- package/dist/strategies/defaults/chatBubbleLiveStatus.js +38 -0
- package/dist/strategies/defaults/chatBubbleLiveStatus.js.map +1 -0
- package/dist/strategies/defaults/consoleObservability.js +65 -0
- package/dist/strategies/defaults/consoleObservability.js.map +1 -0
- package/dist/strategies/defaults/inMemorySinkCost.js +52 -0
- package/dist/strategies/defaults/inMemorySinkCost.js.map +1 -0
- package/dist/strategies/defaults/index.js +38 -0
- package/dist/strategies/defaults/index.js.map +1 -0
- package/dist/strategies/defaults/noopLens.js +33 -0
- package/dist/strategies/defaults/noopLens.js.map +1 -0
- package/dist/strategies/index.js +47 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/registry.js +118 -0
- package/dist/strategies/registry.js.map +1 -0
- package/dist/strategies/types.js +37 -0
- package/dist/strategies/types.js.map +1 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/runner.d.ts +29 -2
- package/dist/types/core/runner.d.ts.map +1 -1
- package/dist/types/strategies/attach.d.ts +48 -0
- package/dist/types/strategies/attach.d.ts.map +1 -0
- package/dist/types/strategies/compose.d.ts +49 -0
- package/dist/types/strategies/compose.d.ts.map +1 -0
- package/dist/types/strategies/defaults/chatBubbleLiveStatus.d.ts +37 -0
- package/dist/types/strategies/defaults/chatBubbleLiveStatus.d.ts.map +1 -0
- package/dist/types/strategies/defaults/consoleObservability.d.ts +43 -0
- package/dist/types/strategies/defaults/consoleObservability.d.ts.map +1 -0
- package/dist/types/strategies/defaults/inMemorySinkCost.d.ts +51 -0
- package/dist/types/strategies/defaults/inMemorySinkCost.d.ts.map +1 -0
- package/dist/types/strategies/defaults/index.d.ts +31 -0
- package/dist/types/strategies/defaults/index.d.ts.map +1 -0
- package/dist/types/strategies/defaults/noopLens.d.ts +29 -0
- package/dist/types/strategies/defaults/noopLens.d.ts.map +1 -0
- package/dist/types/strategies/index.d.ts +23 -0
- package/dist/types/strategies/index.d.ts.map +1 -0
- package/dist/types/strategies/registry.d.ts +71 -0
- package/dist/types/strategies/registry.d.ts.map +1 -0
- package/dist/types/strategies/types.d.ts +304 -0
- package/dist/types/strategies/types.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `compose([...])` — fan-out combinator.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Composite. Same shape as React's children array, RxJS's
|
|
6
|
+
* `merge`, OTel's `MultiSpanProcessor`. Pass an array of
|
|
7
|
+
* strategies; get back a single strategy that fan-outs each
|
|
8
|
+
* call to every child.
|
|
9
|
+
*
|
|
10
|
+
* Use when:
|
|
11
|
+
* - Multi-vendor pipelines (`compose([datadog(), otel(), console()])`)
|
|
12
|
+
* - Test instrumentation alongside production sink
|
|
13
|
+
* (`compose([inMemorySink(), stripeBilling()])`) so test assertions
|
|
14
|
+
* can read ticks while production also ships
|
|
15
|
+
* - Tier-staging — local dev mirrors what production sees
|
|
16
|
+
*
|
|
17
|
+
* Per-child error isolation: if one child's `exportEvent` throws, the
|
|
18
|
+
* other children still receive the event. The throwing child's
|
|
19
|
+
* `_onError` is called (if present); otherwise the error is logged
|
|
20
|
+
* via `console.warn` once. One bad sink never breaks the chain.
|
|
21
|
+
*
|
|
22
|
+
* Capabilities are OR-ed across children — if any child supports a
|
|
23
|
+
* capability, the composite reports it as supported. The dispatcher
|
|
24
|
+
* uses this to decide whether to bother building event objects at all.
|
|
25
|
+
*
|
|
26
|
+
* Idempotent operations:
|
|
27
|
+
* - `flush()` — calls every child's `flush()` (sync or async)
|
|
28
|
+
* concurrently, awaits all
|
|
29
|
+
* - `stop()` — calls every child's `stop()` once, in order; failures
|
|
30
|
+
* in one child don't block the others
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.composeLens = exports.composeLiveStatus = exports.composeCost = exports.composeObservability = void 0;
|
|
34
|
+
// ─── Internal helpers ────────────────────────────────────────────────
|
|
35
|
+
/** Run `cb()` for every child; isolate errors via the child's
|
|
36
|
+
* `_onError` or a single `console.warn`. */
|
|
37
|
+
function safeForEach(children, cb) {
|
|
38
|
+
for (const child of children) {
|
|
39
|
+
try {
|
|
40
|
+
cb(child);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
44
|
+
if (child._onError) {
|
|
45
|
+
try {
|
|
46
|
+
child._onError(e);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Even _onError can throw; final fallback is silent drop —
|
|
50
|
+
// we MUST NOT propagate to the caller (passive recorder rule).
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
console.warn('[compose] child threw and has no _onError:', e.message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** OR-merge a capability bag across children. Generic over the
|
|
61
|
+
* concrete capability type — the runtime walk treats every entry as
|
|
62
|
+
* `boolean | undefined` regardless of the typed shape. */
|
|
63
|
+
function mergeCaps(children) {
|
|
64
|
+
const merged = {};
|
|
65
|
+
for (const c of children) {
|
|
66
|
+
for (const [k, v] of Object.entries(c.capabilities)) {
|
|
67
|
+
if (v === true)
|
|
68
|
+
merged[k] = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return merged;
|
|
72
|
+
}
|
|
73
|
+
/** Run every child's optional `flush` concurrently. */
|
|
74
|
+
async function flushAll(children) {
|
|
75
|
+
const promises = [];
|
|
76
|
+
for (const c of children) {
|
|
77
|
+
if (!c.flush)
|
|
78
|
+
continue;
|
|
79
|
+
try {
|
|
80
|
+
const result = c.flush();
|
|
81
|
+
if (result instanceof Promise)
|
|
82
|
+
promises.push(result.catch(() => { }));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// ignore — passive recorder rule
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (promises.length > 0)
|
|
89
|
+
await Promise.all(promises);
|
|
90
|
+
}
|
|
91
|
+
function stopAll(children) {
|
|
92
|
+
for (const c of children) {
|
|
93
|
+
if (!c.stop)
|
|
94
|
+
continue;
|
|
95
|
+
try {
|
|
96
|
+
c.stop();
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// ignore — passive recorder rule
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ─── Composite factories — one per strategy kind ─────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Compose multiple ObservabilityStrategies into a single fan-out.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const all = composeObservability([
|
|
109
|
+
* consoleObservability(),
|
|
110
|
+
* datadogObservability({ apiKey }),
|
|
111
|
+
* otelObservability(tracer),
|
|
112
|
+
* ]);
|
|
113
|
+
*/
|
|
114
|
+
function composeObservability(children) {
|
|
115
|
+
return {
|
|
116
|
+
name: 'compose',
|
|
117
|
+
capabilities: mergeCaps(children),
|
|
118
|
+
exportEvent(event) {
|
|
119
|
+
safeForEach(children, (c) => c.exportEvent(event));
|
|
120
|
+
},
|
|
121
|
+
flush: () => flushAll(children),
|
|
122
|
+
stop: () => stopAll(children),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
exports.composeObservability = composeObservability;
|
|
126
|
+
/** Compose CostStrategies. */
|
|
127
|
+
function composeCost(children) {
|
|
128
|
+
return {
|
|
129
|
+
name: 'compose',
|
|
130
|
+
capabilities: mergeCaps(children),
|
|
131
|
+
recordCost(tick) {
|
|
132
|
+
safeForEach(children, (c) => c.recordCost(tick));
|
|
133
|
+
},
|
|
134
|
+
flush: () => flushAll(children),
|
|
135
|
+
stop: () => stopAll(children),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
exports.composeCost = composeCost;
|
|
139
|
+
/** Compose LiveStatusStrategies. */
|
|
140
|
+
function composeLiveStatus(children) {
|
|
141
|
+
return {
|
|
142
|
+
name: 'compose',
|
|
143
|
+
capabilities: mergeCaps(children),
|
|
144
|
+
renderStatus(update) {
|
|
145
|
+
safeForEach(children, (c) => c.renderStatus(update));
|
|
146
|
+
},
|
|
147
|
+
flush: () => flushAll(children),
|
|
148
|
+
stop: () => stopAll(children),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
exports.composeLiveStatus = composeLiveStatus;
|
|
152
|
+
/** Compose LensStrategies. */
|
|
153
|
+
function composeLens(children) {
|
|
154
|
+
return {
|
|
155
|
+
name: 'compose',
|
|
156
|
+
capabilities: mergeCaps(children),
|
|
157
|
+
renderGraph(update) {
|
|
158
|
+
safeForEach(children, (c) => c.renderGraph(update));
|
|
159
|
+
},
|
|
160
|
+
flush: () => flushAll(children),
|
|
161
|
+
stop: () => stopAll(children),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
exports.composeLens = composeLens;
|
|
165
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/strategies/compose.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAaH,wEAAwE;AAExE;6CAC6C;AAC7C,SAAS,WAAW,CAClB,QAAsB,EACtB,EAAkB;IAElB,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,EAAE,CAAC,KAAK,CAAC,CAAC;QACZ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9D,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnB,IAAI,CAAC;oBACH,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACpB,CAAC;gBAAC,MAAM,CAAC;oBACP,2DAA2D;oBAC3D,+DAA+D;gBACjE,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,4CAA4C,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED;;2DAE2D;AAC3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AQ,CAAC;KAC9B,CAAC;AACJ,CAAC;AAVD,8CAUC;AAED,8BAA8B;AAC9B,SAAgB,WAAW,CAAC,QAAiC;IAC3D,OAAO;QACL,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC;QACjC,WAAW,CAAC,MAAkB;YAC5B,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC/B,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;KAC9B,CAAC;AACJ,CAAC;AAVD,kCAUC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `chatBubbleLiveStatus()` — default LiveStatusStrategy.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Strategy. Adapter for a consumer-supplied callback.
|
|
6
|
+
* Role: The "every chat UI" sink. Wraps a `(line: string) => void`
|
|
7
|
+
* callback so the consumer just hands us the function their
|
|
8
|
+
* chat-bubble component needs and we drive it on every
|
|
9
|
+
* rendered status update.
|
|
10
|
+
*
|
|
11
|
+
* Use when:
|
|
12
|
+
* - Building a chat UI (Neo, Lens, embedded widget) where the
|
|
13
|
+
* consumer owns rendering but not state derivation
|
|
14
|
+
* - Tier-1 of compose chains (`compose([chatBubble(setLine), stdout()])`
|
|
15
|
+
* so dev console mirrors what the user sees)
|
|
16
|
+
*
|
|
17
|
+
* The callback runs on EVERY status transition. Consumer can debounce
|
|
18
|
+
* / coalesce per their needs (we don't impose UI policy).
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.chatBubbleLiveStatus = void 0;
|
|
22
|
+
function chatBubbleLiveStatus(opts) {
|
|
23
|
+
return {
|
|
24
|
+
name: 'chat-bubble',
|
|
25
|
+
capabilities: { streaming: true },
|
|
26
|
+
renderStatus(update) {
|
|
27
|
+
opts.onLine(update.line);
|
|
28
|
+
},
|
|
29
|
+
validate() {
|
|
30
|
+
if (typeof opts.onLine !== 'function') {
|
|
31
|
+
throw new Error('chatBubbleLiveStatus: required `onLine` callback is missing or not a function. ' +
|
|
32
|
+
'Pass the function that should receive each rendered status line.');
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.chatBubbleLiveStatus = chatBubbleLiveStatus;
|
|
38
|
+
//# sourceMappingURL=chatBubbleLiveStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatBubbleLiveStatus.js","sourceRoot":"","sources":["../../../src/strategies/defaults/chatBubbleLiveStatus.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAqBH,SAAgB,oBAAoB,CAAC,IAAiC;IACpE,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;QACjC,YAAY,CAAC,MAAoB;YAC/B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QACD,QAAQ;YACN,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CACb,iFAAiF;oBAC/E,kEAAkE,CACrE,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAhBD,oDAgBC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `consoleObservability()` — default ObservabilityStrategy.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Strategy. Adapter for `globalThis.console`. Used when no
|
|
6
|
+
* vendor-specific strategy is configured (zero-config dev
|
|
7
|
+
* experience). Same role as `NoOpCacheStrategy` is for the
|
|
8
|
+
* cache layer.
|
|
9
|
+
* Role: Tier-1 fallback — print every event to the console with a
|
|
10
|
+
* one-line type+payload summary. Vendor-neutral, dependency-
|
|
11
|
+
* free, works in browser + Node + Deno + Bun.
|
|
12
|
+
*
|
|
13
|
+
* Use when:
|
|
14
|
+
* - Local development (`agent.enable.observability()` with no opts)
|
|
15
|
+
* - CI logs ("what events fired during this test?")
|
|
16
|
+
* - Tier-1 of compose chains (`compose([console(), datadog()])`)
|
|
17
|
+
*
|
|
18
|
+
* Don't use when: production. Console output is unstructured + can't
|
|
19
|
+
* be queried; switch to a vendor strategy (Datadog, OTel, CloudWatch).
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.consoleObservability = void 0;
|
|
23
|
+
/**
|
|
24
|
+
* Default formatter — emits a single structured JSON line per event.
|
|
25
|
+
* Honeycomb / Datadog / Loki / any structured-log pipeline can ingest
|
|
26
|
+
* directly; `grep` still works because every line is `{` … `}`.
|
|
27
|
+
*
|
|
28
|
+
* Shape: `{type, ...payload}` — flattens payload to top level so
|
|
29
|
+
* filter expressions like `.type == "agentfootprint.cost.tick"` work
|
|
30
|
+
* without nesting.
|
|
31
|
+
*/
|
|
32
|
+
const DEFAULT_FORMAT = (event) => {
|
|
33
|
+
const payload = typeof event.payload === 'object' && event.payload !== null
|
|
34
|
+
? event.payload
|
|
35
|
+
: { value: event.payload };
|
|
36
|
+
return safeJson({ type: event.type, ...payload });
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Factory. Returns a fresh ObservabilityStrategy each call so multiple
|
|
40
|
+
* agents in the same process get independent instances.
|
|
41
|
+
*/
|
|
42
|
+
function consoleObservability(opts = {}) {
|
|
43
|
+
const sink = opts.logger ?? globalThis.console;
|
|
44
|
+
const format = opts.format ?? DEFAULT_FORMAT;
|
|
45
|
+
return {
|
|
46
|
+
name: 'console',
|
|
47
|
+
capabilities: { events: true, logs: true },
|
|
48
|
+
exportEvent(event) {
|
|
49
|
+
sink.log(format(event));
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.consoleObservability = consoleObservability;
|
|
54
|
+
/** JSON.stringify with circular-safety. Avoids breaking the agent loop
|
|
55
|
+
* if a payload contains a circular ref. Returns the type alone if
|
|
56
|
+
* serialization fails. */
|
|
57
|
+
function safeJson(value) {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.stringify(value);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return '[unserializable]';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=consoleObservability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleObservability.js","sourceRoot":"","sources":["../../../src/strategies/defaults/consoleObservability.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAoBH;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAU,EAAE;IAC5D,MAAM,OAAO,GACX,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QACzD,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/B,OAAO,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,OAAoC,EAAE;IAEtC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,cAAc,CAAC;IAC7C,OAAO;QACL,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;QAC1C,WAAW,CAAC,KAA0B;YACpC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC;AAZD,oDAYC;AAED;;2BAE2B;AAC3B,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,kBAAkB,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `inMemorySinkCost()` — default CostStrategy.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Strategy. In-process accumulator. Same role as InMemoryStore
|
|
6
|
+
* for memory-providers.
|
|
7
|
+
* Role: Tier-1 fallback — accumulate cost ticks in a process-local
|
|
8
|
+
* array. Consumer reads via `getTicks()` or hooks `onRecord`
|
|
9
|
+
* for streaming. Vendor-free.
|
|
10
|
+
*
|
|
11
|
+
* Use when:
|
|
12
|
+
* - Tests / CI ("what cost did this run accrue?")
|
|
13
|
+
* - Local dev before billing integration
|
|
14
|
+
* - Tier-1 of compose chains (`compose([inMemorySink(), stripeBilling()])`
|
|
15
|
+
* so test assertions can read ticks while production also ships)
|
|
16
|
+
*
|
|
17
|
+
* Don't use when: process is long-running with high cost-tick volume —
|
|
18
|
+
* the buffer grows unbounded. Add a `maxTicks` cap (drops oldest) or
|
|
19
|
+
* pair with a streaming strategy (`stripeBilling`, `webhook`).
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.inMemorySinkCost = void 0;
|
|
23
|
+
function inMemorySinkCost(opts = {}) {
|
|
24
|
+
const buffer = [];
|
|
25
|
+
const cap = opts.maxTicks ?? Infinity;
|
|
26
|
+
return {
|
|
27
|
+
name: 'in-memory-sink',
|
|
28
|
+
capabilities: { streaming: true, enforcement: false },
|
|
29
|
+
recordCost(tick) {
|
|
30
|
+
buffer.push(tick);
|
|
31
|
+
// FIFO eviction when over cap.
|
|
32
|
+
while (buffer.length > cap)
|
|
33
|
+
buffer.shift();
|
|
34
|
+
opts.onRecord?.(tick);
|
|
35
|
+
},
|
|
36
|
+
getTicks() {
|
|
37
|
+
return buffer.slice();
|
|
38
|
+
},
|
|
39
|
+
getTicksCount() {
|
|
40
|
+
return buffer.length;
|
|
41
|
+
},
|
|
42
|
+
getTicksSince(idx) {
|
|
43
|
+
// Clamp negative / out-of-range. `slice` handles bounds.
|
|
44
|
+
return buffer.slice(Math.max(0, idx));
|
|
45
|
+
},
|
|
46
|
+
clear() {
|
|
47
|
+
buffer.length = 0;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.inMemorySinkCost = inMemorySinkCost;
|
|
52
|
+
//# sourceMappingURL=inMemorySinkCost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inMemorySinkCost.js","sourceRoot":"","sources":["../../../src/strategies/defaults/inMemorySinkCost.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAmCH,SAAgB,gBAAgB,CAAC,OAAgC,EAAE;IACjE,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC;IACtC,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE;QACrD,UAAU,CAAC,IAAc;YACvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,+BAA+B;YAC/B,OAAO,MAAM,CAAC,MAAM,GAAG,GAAG;gBAAE,MAAM,CAAC,KAAK,EAAE,CAAC;YAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,QAAQ;YACN,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;QACD,aAAa;YACX,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QACD,aAAa,CAAC,GAAW;YACvB,yDAAyD;YACzD,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,KAAK;YACH,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC;AA1BD,4CA0BC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Default strategies — the four "shipped in core" sinks.
|
|
4
|
+
*
|
|
5
|
+
* `consoleObservability` — print events to console
|
|
6
|
+
* `inMemorySinkCost` — accumulate cost ticks in a process-local buffer
|
|
7
|
+
* `chatBubbleLiveStatus` — call a consumer-supplied line callback
|
|
8
|
+
* `noopLens` — drop graph updates (zero-arg fallback)
|
|
9
|
+
*
|
|
10
|
+
* Vendor strategies (datadog, otel, agentcore, cloudwatch, …) ship as
|
|
11
|
+
* separate subpaths with peer-dep on the vendor SDK. See
|
|
12
|
+
* `docs/inspiration/strategy-everywhere.md` for the AWS-first roadmap.
|
|
13
|
+
*
|
|
14
|
+
* ─────────────────────────────────────────────────────────────────
|
|
15
|
+
* Why defaults skip `validate()`:
|
|
16
|
+
*
|
|
17
|
+
* The optional `BaseStrategy.validate()` hook is the right place for
|
|
18
|
+
* runtime config checks (API keys, endpoint reachability, peer-dep
|
|
19
|
+
* presence). Defaults skip it by design — their inputs are TypeScript-
|
|
20
|
+
* checked at construction, and they don't talk to a remote vendor that
|
|
21
|
+
* might be misconfigured.
|
|
22
|
+
*
|
|
23
|
+
* Vendor strategies that DO talk to a remote (datadog, agentcore,
|
|
24
|
+
* cloudwatch) MUST implement `validate()` per the New Relic panel
|
|
25
|
+
* review — early-fail-with-useful-message beats silent zero-emission.
|
|
26
|
+
* ─────────────────────────────────────────────────────────────────
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.noopLens = exports.chatBubbleLiveStatus = exports.inMemorySinkCost = exports.consoleObservability = void 0;
|
|
30
|
+
var consoleObservability_js_1 = require("./consoleObservability.js");
|
|
31
|
+
Object.defineProperty(exports, "consoleObservability", { enumerable: true, get: function () { return consoleObservability_js_1.consoleObservability; } });
|
|
32
|
+
var inMemorySinkCost_js_1 = require("./inMemorySinkCost.js");
|
|
33
|
+
Object.defineProperty(exports, "inMemorySinkCost", { enumerable: true, get: function () { return inMemorySinkCost_js_1.inMemorySinkCost; } });
|
|
34
|
+
var chatBubbleLiveStatus_js_1 = require("./chatBubbleLiveStatus.js");
|
|
35
|
+
Object.defineProperty(exports, "chatBubbleLiveStatus", { enumerable: true, get: function () { return chatBubbleLiveStatus_js_1.chatBubbleLiveStatus; } });
|
|
36
|
+
var noopLens_js_1 = require("./noopLens.js");
|
|
37
|
+
Object.defineProperty(exports, "noopLens", { enumerable: true, get: function () { return noopLens_js_1.noopLens; } });
|
|
38
|
+
//# 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,qEAAmG;AAA1F,+HAAA,oBAAoB,OAAA;AAC7B,6DAI+B;AAH7B,uHAAA,gBAAgB,OAAA;AAIlB,qEAAmG;AAA1F,+HAAA,oBAAoB,OAAA;AAC7B,6CAA+D;AAAtD,uGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `noopLens()` — default LensStrategy.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Strategy. Wildcard fallback. Same role as `NoOpCacheStrategy`.
|
|
6
|
+
* Role: Drops every update. Used when no Lens vendor strategy is
|
|
7
|
+
* configured AND the consumer hasn't supplied a callback.
|
|
8
|
+
* Keeps `enable.lens()` callable without args without
|
|
9
|
+
* throwing — important for the zero-arg HelloWorld pattern.
|
|
10
|
+
*
|
|
11
|
+
* Use when:
|
|
12
|
+
* - You want the agent to run without a Lens UI (production
|
|
13
|
+
* server-side, headless eval, batch jobs)
|
|
14
|
+
* - Tier-1 of compose chains where you want the chain to compile
|
|
15
|
+
* even if the real Lens strategy is conditional
|
|
16
|
+
*
|
|
17
|
+
* Don't use when: you actually want to see the StepGraph. Use
|
|
18
|
+
* `lens-browser`, `lens-cli`, or `lens-jsonExport` from the
|
|
19
|
+
* vendor-strategy subpaths once they ship in v2.12+.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.noopLens = void 0;
|
|
23
|
+
function noopLens(opts = {}) {
|
|
24
|
+
return {
|
|
25
|
+
name: 'noop-lens',
|
|
26
|
+
capabilities: { interactive: false, serializable: false },
|
|
27
|
+
renderGraph(update) {
|
|
28
|
+
opts.onUpdate?.(update);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.noopLens = noopLens;
|
|
33
|
+
//# 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,SAAgB,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;AARD,4BAQC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agentfootprint/strategies` — typed strategy interfaces + default
|
|
4
|
+
* sinks for the v2.8 grouped-enabler architecture.
|
|
5
|
+
*
|
|
6
|
+
* See:
|
|
7
|
+
* - `docs/inspiration/strategy-everywhere.md` — design memo + AWS-first roadmap
|
|
8
|
+
* - `types.ts` — typed interfaces (Observability, Cost, LiveStatus, Lens)
|
|
9
|
+
* - `defaults/` — the 4 in-core default strategies
|
|
10
|
+
*
|
|
11
|
+
* Vendor strategies ship as separate subpaths:
|
|
12
|
+
* - `agentfootprint/observability-agentcore` (v2.8.1)
|
|
13
|
+
* - `agentfootprint/observability-cloudwatch` (v2.8.2)
|
|
14
|
+
* - `agentfootprint/observability-xray` (v2.8.3)
|
|
15
|
+
* - `agentfootprint/observability-otel` (v2.9.x)
|
|
16
|
+
* - `agentfootprint/observability-datadog` (v2.9.x)
|
|
17
|
+
* - `agentfootprint/cost-stripe` (v2.10.x)
|
|
18
|
+
* - `agentfootprint/lens-browser` / `lens-cli` (v2.12.x)
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.attachLiveStatusStrategy = exports.attachCostStrategy = exports.attachObservabilityStrategy = exports.composeLens = exports.composeLiveStatus = exports.composeCost = exports.composeObservability = void 0;
|
|
36
|
+
__exportStar(require("./types.js"), exports);
|
|
37
|
+
__exportStar(require("./defaults/index.js"), exports);
|
|
38
|
+
var compose_js_1 = require("./compose.js");
|
|
39
|
+
Object.defineProperty(exports, "composeObservability", { enumerable: true, get: function () { return compose_js_1.composeObservability; } });
|
|
40
|
+
Object.defineProperty(exports, "composeCost", { enumerable: true, get: function () { return compose_js_1.composeCost; } });
|
|
41
|
+
Object.defineProperty(exports, "composeLiveStatus", { enumerable: true, get: function () { return compose_js_1.composeLiveStatus; } });
|
|
42
|
+
Object.defineProperty(exports, "composeLens", { enumerable: true, get: function () { return compose_js_1.composeLens; } });
|
|
43
|
+
var attach_js_1 = require("./attach.js");
|
|
44
|
+
Object.defineProperty(exports, "attachObservabilityStrategy", { enumerable: true, get: function () { return attach_js_1.attachObservabilityStrategy; } });
|
|
45
|
+
Object.defineProperty(exports, "attachCostStrategy", { enumerable: true, get: function () { return attach_js_1.attachCostStrategy; } });
|
|
46
|
+
Object.defineProperty(exports, "attachLiveStatusStrategy", { enumerable: true, get: function () { return attach_js_1.attachLiveStatusStrategy; } });
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,sDAAoC;AACpC,2CAAiG;AAAxF,kHAAA,oBAAoB,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAAE,yGAAA,WAAW,OAAA;AAC1E,yCAOqB;AANnB,wHAAA,2BAA2B,OAAA;AAC3B,+GAAA,kBAAkB,OAAA;AAClB,qHAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Strategy registry — name → factory for each of the 4 groups.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `src/cache/strategyRegistry.ts` exactly: maps a string name
|
|
6
|
+
* to a factory function that takes vendor-specific config and returns
|
|
7
|
+
* a typed strategy instance. Vendor adapter subpaths self-register on
|
|
8
|
+
* import via side-effect.
|
|
9
|
+
*
|
|
10
|
+
* Two ways consumers wire a strategy:
|
|
11
|
+
*
|
|
12
|
+
* 1. By NAME (registry lookup) — the recommended path for vendor
|
|
13
|
+
* adapters:
|
|
14
|
+
* ```ts
|
|
15
|
+
* import 'agentfootprint/observability-datadog'; // self-registers 'datadog'
|
|
16
|
+
* agent.enable.observability({ vendor: 'datadog', config: { apiKey } });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* 2. By INSTANCE (explicit pass) — for custom in-house strategies
|
|
20
|
+
* or test mocks:
|
|
21
|
+
* ```ts
|
|
22
|
+
* agent.enable.observability({ strategy: myCustomStrategy });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* The two paths are mutually exclusive in `EnableOptions` — the type
|
|
26
|
+
* union enforces that consumers pick one.
|
|
27
|
+
*
|
|
28
|
+
* Lookup is exact-match by name (case-insensitive fallback). Unknown
|
|
29
|
+
* names return `undefined`; the consumer's `enable.X` then no-ops
|
|
30
|
+
* (per "do nothing if not configured" rule).
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports._resetRegistriesForTests = exports.listLensStrategies = exports.getLensStrategy = exports.registerLensStrategy = exports.listLiveStatusStrategies = exports.getLiveStatusStrategy = exports.registerLiveStatusStrategy = exports.listCostStrategies = exports.getCostStrategy = exports.registerCostStrategy = exports.listObservabilityStrategies = exports.getObservabilityStrategy = exports.registerObservabilityStrategy = void 0;
|
|
34
|
+
// ─── 4 registries (one per group) ────────────────────────────────────
|
|
35
|
+
const OBSERVABILITY_REGISTRY = new Map();
|
|
36
|
+
const COST_REGISTRY = new Map();
|
|
37
|
+
const LIVE_STATUS_REGISTRY = new Map();
|
|
38
|
+
const LENS_REGISTRY = new Map();
|
|
39
|
+
// ─── Register / lookup / list — observability ────────────────────────
|
|
40
|
+
/**
|
|
41
|
+
* Register a vendor observability strategy by name. Called from the
|
|
42
|
+
* vendor's subpath at module load (side-effect import):
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* // agentfootprint/observability-datadog/index.ts
|
|
46
|
+
* import { registerObservabilityStrategy } from 'agentfootprint/strategies';
|
|
47
|
+
* registerObservabilityStrategy('datadog', (config) => datadogObservability(config));
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* Replacing an existing registration is allowed — most-recent wins.
|
|
51
|
+
* Useful for test mocks.
|
|
52
|
+
*/
|
|
53
|
+
function registerObservabilityStrategy(name, factory) {
|
|
54
|
+
OBSERVABILITY_REGISTRY.set(name, factory);
|
|
55
|
+
}
|
|
56
|
+
exports.registerObservabilityStrategy = registerObservabilityStrategy;
|
|
57
|
+
/** Look up an observability factory by vendor name. Case-insensitive
|
|
58
|
+
* fallback. Returns `undefined` when the name is unknown — caller
|
|
59
|
+
* decides to noop or throw. */
|
|
60
|
+
function getObservabilityStrategy(name) {
|
|
61
|
+
return OBSERVABILITY_REGISTRY.get(name) ?? OBSERVABILITY_REGISTRY.get(name.toLowerCase());
|
|
62
|
+
}
|
|
63
|
+
exports.getObservabilityStrategy = getObservabilityStrategy;
|
|
64
|
+
/** Diagnostic — list all registered vendor names. */
|
|
65
|
+
function listObservabilityStrategies() {
|
|
66
|
+
return [...OBSERVABILITY_REGISTRY.keys()];
|
|
67
|
+
}
|
|
68
|
+
exports.listObservabilityStrategies = listObservabilityStrategies;
|
|
69
|
+
// ─── Cost ────────────────────────────────────────────────────────────
|
|
70
|
+
function registerCostStrategy(name, factory) {
|
|
71
|
+
COST_REGISTRY.set(name, factory);
|
|
72
|
+
}
|
|
73
|
+
exports.registerCostStrategy = registerCostStrategy;
|
|
74
|
+
function getCostStrategy(name) {
|
|
75
|
+
return COST_REGISTRY.get(name) ?? COST_REGISTRY.get(name.toLowerCase());
|
|
76
|
+
}
|
|
77
|
+
exports.getCostStrategy = getCostStrategy;
|
|
78
|
+
function listCostStrategies() {
|
|
79
|
+
return [...COST_REGISTRY.keys()];
|
|
80
|
+
}
|
|
81
|
+
exports.listCostStrategies = listCostStrategies;
|
|
82
|
+
// ─── Live status ─────────────────────────────────────────────────────
|
|
83
|
+
function registerLiveStatusStrategy(name, factory) {
|
|
84
|
+
LIVE_STATUS_REGISTRY.set(name, factory);
|
|
85
|
+
}
|
|
86
|
+
exports.registerLiveStatusStrategy = registerLiveStatusStrategy;
|
|
87
|
+
function getLiveStatusStrategy(name) {
|
|
88
|
+
return LIVE_STATUS_REGISTRY.get(name) ?? LIVE_STATUS_REGISTRY.get(name.toLowerCase());
|
|
89
|
+
}
|
|
90
|
+
exports.getLiveStatusStrategy = getLiveStatusStrategy;
|
|
91
|
+
function listLiveStatusStrategies() {
|
|
92
|
+
return [...LIVE_STATUS_REGISTRY.keys()];
|
|
93
|
+
}
|
|
94
|
+
exports.listLiveStatusStrategies = listLiveStatusStrategies;
|
|
95
|
+
// ─── Lens ────────────────────────────────────────────────────────────
|
|
96
|
+
function registerLensStrategy(name, factory) {
|
|
97
|
+
LENS_REGISTRY.set(name, factory);
|
|
98
|
+
}
|
|
99
|
+
exports.registerLensStrategy = registerLensStrategy;
|
|
100
|
+
function getLensStrategy(name) {
|
|
101
|
+
return LENS_REGISTRY.get(name) ?? LENS_REGISTRY.get(name.toLowerCase());
|
|
102
|
+
}
|
|
103
|
+
exports.getLensStrategy = getLensStrategy;
|
|
104
|
+
function listLensStrategies() {
|
|
105
|
+
return [...LENS_REGISTRY.keys()];
|
|
106
|
+
}
|
|
107
|
+
exports.listLensStrategies = listLensStrategies;
|
|
108
|
+
// ─── Test helpers ────────────────────────────────────────────────────
|
|
109
|
+
/** Reset every registry to empty. Tests only — not in the public
|
|
110
|
+
* barrel. */
|
|
111
|
+
function _resetRegistriesForTests() {
|
|
112
|
+
OBSERVABILITY_REGISTRY.clear();
|
|
113
|
+
COST_REGISTRY.clear();
|
|
114
|
+
LIVE_STATUS_REGISTRY.clear();
|
|
115
|
+
LENS_REGISTRY.clear();
|
|
116
|
+
}
|
|
117
|
+
exports._resetRegistriesForTests = _resetRegistriesForTests;
|
|
118
|
+
//# 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;AAClE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;AAErD,wEAAwE;AAExE;;;;;;;;;;;;GAYG;AACH,SAAgB,6BAA6B,CAAC,IAAY,EAAE,OAA6B;IACvF,sBAAsB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAFD,sEAEC;AAED;;gCAEgC;AAChC,SAAgB,wBAAwB,CAAC,IAAY;IACnD,OAAO,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AAC5F,CAAC;AAFD,4DAEC;AAED,qDAAqD;AACrD,SAAgB,2BAA2B;IACzC,OAAO,CAAC,GAAG,sBAAsB,CAAC,IAA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gB,kBAAkB;IAChC,OAAO,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;AACnC,CAAC;AAFD,gDAEC;AAED,wEAAwE;AAExE;cACc;AACd,SAAgB,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;AALD,4DAKC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Strategy interface types for the v2.8 grouped-enabler architecture.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Strategy + Bridge + Hexagonal port. See the design memo
|
|
6
|
+
* `docs/inspiration/strategy-everywhere.md`.
|
|
7
|
+
*
|
|
8
|
+
* Four groups, four typed strategy interfaces. Each follows the same
|
|
9
|
+
* shape (one canonical contract, locked at the type level):
|
|
10
|
+
*
|
|
11
|
+
* 1. `name: string` — registry key for auto-registration
|
|
12
|
+
* 2. `capabilities: {...}` — what this strategy supports
|
|
13
|
+
* 3. `onEvent(...)` — hot path; sync, side-effect-only
|
|
14
|
+
* 4. `flush?(): Promise<void>` — optional batch flushing
|
|
15
|
+
* 5. `stop?(): void` — optional teardown
|
|
16
|
+
*
|
|
17
|
+
* Design constraints (from the panel review):
|
|
18
|
+
* - **PASSIVE / non-blocking by construction.** Strategies are
|
|
19
|
+
* observers — they NEVER block the agent loop. Async work
|
|
20
|
+
* (HTTP shipment, disk I/O, batching) is the STRATEGY's internal
|
|
21
|
+
* concern: buffer in `onEvent` (sync), drain in `flush()` (async
|
|
22
|
+
* OK). The dispatcher never awaits a strategy's `onEvent`.
|
|
23
|
+
* - `onEvent` MUST be sync `void`. MUST NOT throw. Errors caught +
|
|
24
|
+
* routed to `_onError` at the dispatch layer; one bad strategy
|
|
25
|
+
* never breaks the agent loop.
|
|
26
|
+
* - Idempotent registration — registering the same `name` twice
|
|
27
|
+
* replaces, doesn't double-fire.
|
|
28
|
+
* - `stop()` is idempotent — halts everything that strategy enabled,
|
|
29
|
+
* nothing else, calling twice is a no-op.
|
|
30
|
+
* - `flush()` is optional, may be sync OR async — strategies that
|
|
31
|
+
* don't batch can omit it. Consumer's `agent.run()` lifecycle
|
|
32
|
+
* calls flush at boundary points (turn end, run end) so batched
|
|
33
|
+
* strategies don't lose tail events. Flush is the ONLY async
|
|
34
|
+
* path; the hot path is always sync.
|
|
35
|
+
*/
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/strategies/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnerBase.d.ts","sourceRoot":"","sources":["../../../src/core/RunnerBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAGV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"RunnerBase.d.ts","sourceRoot":"","sources":["../../../src/core/RunnerBase.ts"],"names":[],"mappings":"AAAA;;;;;;;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