agentfootprint 2.7.3 → 2.8.1
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/README.md +157 -394
- package/dist/adapters/observability/agentcore.js +188 -0
- package/dist/adapters/observability/agentcore.js.map +1 -0
- package/dist/core/RunnerBase.js +6 -0
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/esm/adapters/observability/agentcore.js +184 -0
- package/dist/esm/adapters/observability/agentcore.js.map +1 -0
- package/dist/esm/core/RunnerBase.js +6 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/observability-providers.js +37 -0
- package/dist/esm/observability-providers.js.map +1 -0
- 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 +37 -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/observability-providers.js +41 -0
- package/dist/observability-providers.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 +61 -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/adapters/observability/agentcore.d.ts +86 -0
- package/dist/types/adapters/observability/agentcore.d.ts.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/observability-providers.d.ts +37 -0
- package/dist/types/observability-providers.d.ts.map +1 -0
- 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 +37 -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 +14 -5
|
@@ -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;AAC3D,SAAS,SAAS,CAAI,QAAwC;IAC5D,MAAM,MAAM,GAAwC,EAAE,CAAC;IACvD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAA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O;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,61 @@
|
|
|
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 under three GROUPED subpaths (matching the
|
|
12
|
+
* parallel-providers pattern v2.5 established for `llm-providers` /
|
|
13
|
+
* `tool-providers` / `memory-providers`). Each subpath holds N
|
|
14
|
+
* vendor-named factories — adding a vendor never adds a new subpath:
|
|
15
|
+
*
|
|
16
|
+
* - `agentfootprint/observability-providers`
|
|
17
|
+
* agentcoreObservability (v2.8.1)
|
|
18
|
+
* cloudwatchObservability (v2.8.2)
|
|
19
|
+
* xrayObservability (v2.8.3)
|
|
20
|
+
* otelObservability (v2.9.x)
|
|
21
|
+
* datadogObservability (v2.9.x)
|
|
22
|
+
*
|
|
23
|
+
* - `agentfootprint/cost-providers`
|
|
24
|
+
* stripeCost (v2.10.x)
|
|
25
|
+
*
|
|
26
|
+
* - `agentfootprint/lens-providers`
|
|
27
|
+
* browserLens / cliLens (v2.12.x)
|
|
28
|
+
*
|
|
29
|
+
* Each adapter lazy-imports its vendor SDK via `lib/lazyRequire.ts`,
|
|
30
|
+
* so consumers who never call a particular factory don't have to
|
|
31
|
+
* install that SDK. Peer-deps are declared in package.json with
|
|
32
|
+
* `peerDependenciesMeta.{name}.optional = true`.
|
|
33
|
+
*/
|
|
34
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
35
|
+
if (k2 === undefined) k2 = k;
|
|
36
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
37
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
38
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
39
|
+
}
|
|
40
|
+
Object.defineProperty(o, k2, desc);
|
|
41
|
+
}) : (function(o, m, k, k2) {
|
|
42
|
+
if (k2 === undefined) k2 = k;
|
|
43
|
+
o[k2] = m[k];
|
|
44
|
+
}));
|
|
45
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
46
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.attachLiveStatusStrategy = exports.attachCostStrategy = exports.attachObservabilityStrategy = exports.composeLens = exports.composeLiveStatus = exports.composeCost = exports.composeObservability = void 0;
|
|
50
|
+
__exportStar(require("./types.js"), exports);
|
|
51
|
+
__exportStar(require("./defaults/index.js"), exports);
|
|
52
|
+
var compose_js_1 = require("./compose.js");
|
|
53
|
+
Object.defineProperty(exports, "composeObservability", { enumerable: true, get: function () { return compose_js_1.composeObservability; } });
|
|
54
|
+
Object.defineProperty(exports, "composeCost", { enumerable: true, get: function () { return compose_js_1.composeCost; } });
|
|
55
|
+
Object.defineProperty(exports, "composeLiveStatus", { enumerable: true, get: function () { return compose_js_1.composeLiveStatus; } });
|
|
56
|
+
Object.defineProperty(exports, "composeLens", { enumerable: true, get: function () { return compose_js_1.composeLens; } });
|
|
57
|
+
var attach_js_1 = require("./attach.js");
|
|
58
|
+
Object.defineProperty(exports, "attachObservabilityStrategy", { enumerable: true, get: function () { return attach_js_1.attachObservabilityStrategy; } });
|
|
59
|
+
Object.defineProperty(exports, "attachCostStrategy", { enumerable: true, get: function () { return attach_js_1.attachCostStrategy; } });
|
|
60
|
+
Object.defineProperty(exports, "attachLiveStatusStrategy", { enumerable: true, get: function () { return attach_js_1.attachLiveStatusStrategy; } });
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;;;;;;;;;;;;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;A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AY,EAAE,OAAoB;IACrE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAFD,oDAEC;AAED,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,0CAEC;AAED,SAAgB,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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentcoreObservability — AWS Bedrock AgentCore observability adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ships every `AgentfootprintEvent` to **CloudWatch Logs** in a
|
|
5
|
+
* structured-JSON shape AgentCore's hosted-agent telemetry layer
|
|
6
|
+
* understands. Use when:
|
|
7
|
+
*
|
|
8
|
+
* 1. Your agent runs INSIDE AgentCore — events show up alongside
|
|
9
|
+
* AgentCore's own runtime telemetry in the same log group.
|
|
10
|
+
* 2. Your agent runs OUTSIDE AgentCore but you want to query agent
|
|
11
|
+
* behavior in CloudWatch Insights / X-Ray traces using the same
|
|
12
|
+
* schema AgentCore uses internally.
|
|
13
|
+
*
|
|
14
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
15
|
+
* Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
|
|
16
|
+
* only when this adapter is used; declared via
|
|
17
|
+
* `peerDependenciesMeta.{name}.optional = true`).
|
|
18
|
+
*
|
|
19
|
+
* Pattern: Adapter (GoF) — translates `AgentfootprintEvent` →
|
|
20
|
+
* CloudWatch Logs `PutLogEvents` payloads. Buffers in
|
|
21
|
+
* `exportEvent()` (sync, non-throwing); flushes in `flush()`
|
|
22
|
+
* (async batch). Default flush window: 1s OR 10 KB,
|
|
23
|
+
* whichever first — matches CloudWatch's own optimal batch.
|
|
24
|
+
*
|
|
25
|
+
* @example Basic
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { agentcoreObservability } from 'agentfootprint/observability-providers';
|
|
28
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
29
|
+
*
|
|
30
|
+
* agent.enable.observability({
|
|
31
|
+
* strategy: agentcoreObservability({
|
|
32
|
+
* region: 'us-east-1',
|
|
33
|
+
* logGroupName: '/agentfootprint/my-agent',
|
|
34
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
35
|
+
* }),
|
|
36
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Test injection (skip SDK require entirely)
|
|
41
|
+
* ```ts
|
|
42
|
+
* agentcoreObservability({
|
|
43
|
+
* _client: {
|
|
44
|
+
* putLogEvents: async (input) => { capturedBatches.push(input); },
|
|
45
|
+
* },
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
import type { ObservabilityStrategy } from '../../strategies/types.js';
|
|
50
|
+
export interface AgentcoreObservabilityOptions {
|
|
51
|
+
/** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
|
|
52
|
+
readonly region?: string;
|
|
53
|
+
/** CloudWatch Logs log group. **Required.** Must exist or your IAM
|
|
54
|
+
* role must allow `logs:CreateLogGroup`. */
|
|
55
|
+
readonly logGroupName: string;
|
|
56
|
+
/** CloudWatch Logs log stream within the group. Conventionally
|
|
57
|
+
* `<host>/<startTime>` so multi-instance deployments don't collide.
|
|
58
|
+
* Created on first put if it doesn't exist (or your role must
|
|
59
|
+
* allow `logs:CreateLogStream`). Defaults to `agentfootprint`. */
|
|
60
|
+
readonly logStreamName?: string;
|
|
61
|
+
/** Max events buffered before forced flush. Default 100. */
|
|
62
|
+
readonly maxBatchEvents?: number;
|
|
63
|
+
/** Max payload bytes (UTF-8) buffered before forced flush. Default
|
|
64
|
+
* 10240 (10 KB). CloudWatch hard caps at 1 MB / batch but we keep
|
|
65
|
+
* the default low so latency stays bounded. */
|
|
66
|
+
readonly maxBatchBytes?: number;
|
|
67
|
+
/** Forced-flush interval when traffic is sparse. Default 1000ms.
|
|
68
|
+
* `0` disables time-based flush — only size triggers fire. */
|
|
69
|
+
readonly flushIntervalMs?: number;
|
|
70
|
+
/** Test injection — bypasses SDK lazy-require entirely. When set,
|
|
71
|
+
* `region` / IAM are ignored. */
|
|
72
|
+
readonly _client?: CloudWatchLikeClient;
|
|
73
|
+
}
|
|
74
|
+
interface CloudWatchLikeClient {
|
|
75
|
+
putLogEvents(input: {
|
|
76
|
+
logGroupName: string;
|
|
77
|
+
logStreamName: string;
|
|
78
|
+
logEvents: ReadonlyArray<{
|
|
79
|
+
timestamp: number;
|
|
80
|
+
message: string;
|
|
81
|
+
}>;
|
|
82
|
+
}): Promise<unknown>;
|
|
83
|
+
}
|
|
84
|
+
export declare function agentcoreObservability(opts: AgentcoreObservabilityOptions): ObservabilityStrategy;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=agentcore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.d.ts","sourceRoot":"","sources":["../../../../src/adapters/observability/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE,MAAM,WAAW,6BAA6B;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;iDAC6C;IAC7C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;uEAGmE;IACnE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,4DAA4D;IAC5D,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;oDAEgD;IAChD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;mEAC+D;IAC/D,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;sCACkC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAID,UAAU,oBAAoB;IAC5B,YAAY,CAAC,KAAK,EAAE;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,aAAa,CAAC;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAClE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;AAUD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,6BAA6B,GAAG,qBAAqB,CA8GjG"}
|
|
@@ -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,UA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I,CAAC,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,WAAW;IAYzE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG,WAAW;IAU/C,QAAQ,CAAC,MAAM,EAAE,eAAe,CAe9B;IAIF;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAa1D;;;OAGG;IACH,SAAS,CAAC,WAAW,IAAI,SAAS;IAYlC;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,SAAS,MAAM,EAAE;IAI9C;;;;OAIG;IACH,SAAS,CAAC,aAAa,IAAI,eAAe;CAG3C"}
|
|
@@ -19,15 +19,22 @@ import type { AgentfootprintEvent, AgentfootprintEventType } from '../events/reg
|
|
|
19
19
|
import type { LoggingOptions } from '../recorders/observability/LoggingRecorder.js';
|
|
20
20
|
import type { ThinkingOptions } from '../recorders/observability/ThinkingRecorder.js';
|
|
21
21
|
import type { FlowchartHandle, FlowchartOptions } from '../recorders/observability/FlowchartRecorder.js';
|
|
22
|
+
import type { ObservabilityEnableOptions, CostEnableOptions, LiveStatusEnableOptions } from '../strategies/attach.js';
|
|
22
23
|
/**
|
|
23
24
|
* High-level feature-enable methods. Each attaches a pre-built observability
|
|
24
25
|
* recorder and returns an Unsubscribe function. Additional methods land in
|
|
25
26
|
* Phase 5 (lens, tracing, cost, guardrails, ...).
|
|
26
27
|
*/
|
|
27
28
|
export interface EnableNamespace {
|
|
28
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated v2.8 — use `enable.liveStatus({ strategy: chatBubbleLiveStatus({onLine}) })`.
|
|
31
|
+
* Kept for back-compat; removed in v3.0.
|
|
32
|
+
*/
|
|
29
33
|
thinking(opts: ThinkingOptions): Unsubscribe;
|
|
30
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated v2.8 — use `enable.observability({ strategy: pinoObservability({...}) })`
|
|
36
|
+
* or another vendor strategy. Kept for back-compat; removed in v3.0.
|
|
37
|
+
*/
|
|
31
38
|
logging(opts?: LoggingOptions): Unsubscribe;
|
|
32
39
|
/**
|
|
33
40
|
* Live composition graph — subflow / fork-branch / decision-branch
|
|
@@ -39,6 +46,26 @@ export interface EnableNamespace {
|
|
|
39
46
|
* at any time (not just via onUpdate).
|
|
40
47
|
*/
|
|
41
48
|
flowchart(opts?: FlowchartOptions): FlowchartHandle;
|
|
49
|
+
/**
|
|
50
|
+
* v2.8+ — grouped strategy enabler for observability. Pipes every
|
|
51
|
+
* typed event into a vendor strategy (Datadog, OTel, AgentCore,
|
|
52
|
+
* CloudWatch, …) or the default `consoleObservability()`. See
|
|
53
|
+
* `agentfootprint/strategies` + `docs/inspiration/strategy-everywhere.md`.
|
|
54
|
+
*/
|
|
55
|
+
observability(opts?: ObservabilityEnableOptions): Unsubscribe;
|
|
56
|
+
/**
|
|
57
|
+
* v2.8+ — grouped strategy enabler for cost. Subscribes the strategy
|
|
58
|
+
* to `cost.tick` events; defaults to `inMemorySinkCost()` for
|
|
59
|
+
* read-back / test inspection.
|
|
60
|
+
*/
|
|
61
|
+
cost(opts?: CostEnableOptions): Unsubscribe;
|
|
62
|
+
/**
|
|
63
|
+
* v2.8+ — grouped strategy enabler for chat-bubble live status.
|
|
64
|
+
* Maintains the thinking-state machine; calls strategy.renderStatus
|
|
65
|
+
* each time the rendered line changes (deduped — not on every token).
|
|
66
|
+
* Strategy is required (consumer must wire UI).
|
|
67
|
+
*/
|
|
68
|
+
liveStatus(opts: LiveStatusEnableOptions): Unsubscribe;
|
|
42
69
|
}
|
|
43
70
|
/**
|
|
44
71
|
* Every primitive (LLMCall, Agent), every composition (Sequence, Parallel,
|