agentfootprint 2.8.0 → 2.8.2
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 +64 -0
- package/dist/adapters/observability/agentcore.js.map +1 -0
- package/dist/adapters/observability/cloudwatch.js +203 -0
- package/dist/adapters/observability/cloudwatch.js.map +1 -0
- package/dist/esm/adapters/observability/agentcore.js +60 -0
- package/dist/esm/adapters/observability/agentcore.js.map +1 -0
- package/dist/esm/adapters/observability/cloudwatch.js +198 -0
- package/dist/esm/adapters/observability/cloudwatch.js.map +1 -0
- package/dist/esm/observability-providers.js +38 -0
- package/dist/esm/observability-providers.js.map +1 -0
- package/dist/esm/strategies/index.js +22 -8
- package/dist/esm/strategies/index.js.map +1 -1
- package/dist/observability-providers.js +43 -0
- package/dist/observability-providers.js.map +1 -0
- package/dist/strategies/index.js +22 -8
- package/dist/strategies/index.js.map +1 -1
- package/dist/types/adapters/observability/agentcore.d.ts +67 -0
- package/dist/types/adapters/observability/agentcore.d.ts.map +1 -0
- package/dist/types/adapters/observability/cloudwatch.d.ts +97 -0
- package/dist/types/adapters/observability/cloudwatch.d.ts.map +1 -0
- package/dist/types/observability-providers.d.ts +38 -0
- package/dist/types/observability-providers.d.ts.map +1 -0
- package/dist/types/strategies/index.d.ts +22 -8
- package/dist/types/strategies/index.d.ts.map +1 -1
- package/package.json +10 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentcoreObservability — AWS Bedrock AgentCore observability adapter.
|
|
4
|
+
*
|
|
5
|
+
* Ships every `AgentfootprintEvent` to **CloudWatch Logs** in a
|
|
6
|
+
* structured-JSON shape AgentCore's hosted-agent telemetry layer
|
|
7
|
+
* understands. Use when:
|
|
8
|
+
*
|
|
9
|
+
* 1. Your agent runs INSIDE AgentCore — events show up alongside
|
|
10
|
+
* AgentCore's own runtime telemetry in the same log group.
|
|
11
|
+
* 2. Your agent runs OUTSIDE AgentCore but you want to query agent
|
|
12
|
+
* behavior in CloudWatch Insights / X-Ray traces using the same
|
|
13
|
+
* schema AgentCore uses internally.
|
|
14
|
+
*
|
|
15
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
16
|
+
* Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
|
|
17
|
+
* only when this adapter is used; declared via
|
|
18
|
+
* `peerDependenciesMeta.{name}.optional = true`).
|
|
19
|
+
*
|
|
20
|
+
* **Implementation:** thin wrapper over `cloudwatchObservability`'s
|
|
21
|
+
* shared base. The only difference is the strategy `name` (used for
|
|
22
|
+
* registry lookup + diagnostics). All batching, flush, error-routing,
|
|
23
|
+
* and SDK-loading behavior is identical. As we evolve the CloudWatch
|
|
24
|
+
* shipping path (retry, sequence tokens, metrics emission), every
|
|
25
|
+
* CloudWatch-shaped adapter inherits the improvement.
|
|
26
|
+
*
|
|
27
|
+
* @example Basic
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { agentcoreObservability } from 'agentfootprint/observability-providers';
|
|
30
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
31
|
+
*
|
|
32
|
+
* agent.enable.observability({
|
|
33
|
+
* strategy: agentcoreObservability({
|
|
34
|
+
* region: 'us-east-1',
|
|
35
|
+
* logGroupName: '/agentfootprint/my-agent',
|
|
36
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
37
|
+
* }),
|
|
38
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example Test injection (skip SDK require entirely)
|
|
43
|
+
* ```ts
|
|
44
|
+
* agentcoreObservability({
|
|
45
|
+
* _client: {
|
|
46
|
+
* putLogEvents: async (input) => { capturedBatches.push(input); },
|
|
47
|
+
* },
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.agentcoreObservability = void 0;
|
|
53
|
+
const cloudwatch_js_1 = require("./cloudwatch.js");
|
|
54
|
+
/**
|
|
55
|
+
* Build an AgentCore-flavored CloudWatch Logs observability strategy.
|
|
56
|
+
* Functionally identical to `cloudwatchObservability` except for the
|
|
57
|
+
* strategy `name`, which lets registry-lookup + diagnostics
|
|
58
|
+
* distinguish AgentCore-targeted shipping from generic CloudWatch.
|
|
59
|
+
*/
|
|
60
|
+
function agentcoreObservability(opts) {
|
|
61
|
+
return (0, cloudwatch_js_1._buildCloudWatchObservability)(opts, 'agentcore');
|
|
62
|
+
}
|
|
63
|
+
exports.agentcoreObservability = agentcoreObservability;
|
|
64
|
+
//# sourceMappingURL=agentcore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/observability/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;;;AAIH,mDAGyB;AAWzB;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,IAAmC;IACxE,OAAO,IAAA,6CAA6B,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC;AAFD,wDAEC"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* cloudwatchObservability — Generic AWS CloudWatch Logs adapter.
|
|
4
|
+
*
|
|
5
|
+
* Ships every `AgentfootprintEvent` to a CloudWatch Logs stream. Use
|
|
6
|
+
* when you want agent telemetry alongside the rest of your AWS
|
|
7
|
+
* observability stack — CloudWatch Insights queries, alarms,
|
|
8
|
+
* cross-service correlation. Same SDK as `agentcoreObservability`
|
|
9
|
+
* but **without** the AgentCore-specific defaults (log-stream
|
|
10
|
+
* convention, format opinions). Use this when:
|
|
11
|
+
*
|
|
12
|
+
* 1. You're shipping to CloudWatch but NOT running inside Bedrock
|
|
13
|
+
* AgentCore (most common case).
|
|
14
|
+
* 2. You want full control over log group / stream / format and
|
|
15
|
+
* don't need AgentCore's hosted-agent telemetry conventions.
|
|
16
|
+
*
|
|
17
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
18
|
+
* Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
|
|
19
|
+
* only when this adapter is used; declared via
|
|
20
|
+
* `peerDependenciesMeta.{name}.optional = true`).
|
|
21
|
+
*
|
|
22
|
+
* This module also exports the underlying base function used by
|
|
23
|
+
* `agentcoreObservability` — keeps the per-event hot path in one
|
|
24
|
+
* place so improvements (batching, retry, backpressure) flow to
|
|
25
|
+
* every CloudWatch-shaped adapter automatically.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { cloudwatchObservability } from 'agentfootprint/observability-providers';
|
|
30
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
31
|
+
*
|
|
32
|
+
* agent.enable.observability({
|
|
33
|
+
* strategy: cloudwatchObservability({
|
|
34
|
+
* region: 'us-east-1',
|
|
35
|
+
* logGroupName: '/myapp/agent-prod',
|
|
36
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
37
|
+
* }),
|
|
38
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.cloudwatchObservability = exports._buildCloudWatchObservability = void 0;
|
|
44
|
+
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
45
|
+
// ─── Generic base — also used by agentcoreObservability ──────────────
|
|
46
|
+
/**
|
|
47
|
+
* Internal: shared CloudWatch Logs base used by every adapter that
|
|
48
|
+
* ships to CWL. `cloudwatchObservability` is the public generic
|
|
49
|
+
* factory; `agentcoreObservability` calls this with AgentCore-flavored
|
|
50
|
+
* defaults.
|
|
51
|
+
*
|
|
52
|
+
* Exported for adapter authors only — consumers should call
|
|
53
|
+
* `cloudwatchObservability` or `agentcoreObservability` directly.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
function _buildCloudWatchObservability(opts, strategyName) {
|
|
58
|
+
if (!opts.logGroupName) {
|
|
59
|
+
throw new TypeError(`[${strategyName}Observability] \`logGroupName\` is required. ` +
|
|
60
|
+
`Pass an existing CloudWatch log group, e.g. '/myapp/agent-prod'.`);
|
|
61
|
+
}
|
|
62
|
+
const logStreamName = opts.logStreamName ?? 'agentfootprint';
|
|
63
|
+
const maxBatchEvents = opts.maxBatchEvents ?? 100;
|
|
64
|
+
const maxBatchBytes = opts.maxBatchBytes ?? 10_240;
|
|
65
|
+
const flushIntervalMs = opts.flushIntervalMs ?? 1000;
|
|
66
|
+
// Buffered batch — drained by `flush()` / size-trigger / time-trigger.
|
|
67
|
+
const buffer = [];
|
|
68
|
+
let bufferBytes = 0;
|
|
69
|
+
let lastFlushPromise = Promise.resolve();
|
|
70
|
+
let timer;
|
|
71
|
+
let stopped = false;
|
|
72
|
+
let onErrorHook;
|
|
73
|
+
// Lazy-resolved on first flush so consumers who never trigger a
|
|
74
|
+
// flush (because nothing was emitted) don't even hit the SDK.
|
|
75
|
+
let client = opts._client;
|
|
76
|
+
function ensureClient() {
|
|
77
|
+
if (client)
|
|
78
|
+
return client;
|
|
79
|
+
client = createCloudWatchClient(opts.region, strategyName);
|
|
80
|
+
return client;
|
|
81
|
+
}
|
|
82
|
+
function scheduleTimedFlush() {
|
|
83
|
+
if (timer || flushIntervalMs <= 0 || stopped)
|
|
84
|
+
return;
|
|
85
|
+
timer = setTimeout(() => {
|
|
86
|
+
timer = undefined;
|
|
87
|
+
void doFlush();
|
|
88
|
+
}, flushIntervalMs);
|
|
89
|
+
}
|
|
90
|
+
async function doFlush() {
|
|
91
|
+
if (buffer.length === 0 || stopped)
|
|
92
|
+
return;
|
|
93
|
+
// Snapshot + clear so concurrent emits during the in-flight put
|
|
94
|
+
// accumulate into the next batch.
|
|
95
|
+
const batch = buffer.splice(0);
|
|
96
|
+
bufferBytes = 0;
|
|
97
|
+
try {
|
|
98
|
+
await ensureClient().putLogEvents({
|
|
99
|
+
logGroupName: opts.logGroupName,
|
|
100
|
+
logStreamName,
|
|
101
|
+
logEvents: batch,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
onErrorHook?.(err instanceof Error ? err : new Error(String(err)));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function enqueue(event) {
|
|
109
|
+
if (stopped)
|
|
110
|
+
return;
|
|
111
|
+
const message = JSON.stringify(event);
|
|
112
|
+
const bytes = Buffer.byteLength(message, 'utf8');
|
|
113
|
+
buffer.push({ timestamp: Date.now(), message });
|
|
114
|
+
bufferBytes += bytes;
|
|
115
|
+
if (buffer.length >= maxBatchEvents || bufferBytes >= maxBatchBytes) {
|
|
116
|
+
// Size trigger — flush immediately. Chain onto last to preserve
|
|
117
|
+
// CloudWatch's per-stream ordering requirement.
|
|
118
|
+
lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
scheduleTimedFlush();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
name: strategyName,
|
|
126
|
+
capabilities: { events: true, logs: true },
|
|
127
|
+
exportEvent: enqueue,
|
|
128
|
+
async flush() {
|
|
129
|
+
// Drain anything pending. Awaits both an in-flight put AND any
|
|
130
|
+
// newly-buffered events that arrived during it.
|
|
131
|
+
while (buffer.length > 0 || lastFlushPromise !== Promise.resolve()) {
|
|
132
|
+
const before = lastFlushPromise;
|
|
133
|
+
await before;
|
|
134
|
+
if (buffer.length > 0) {
|
|
135
|
+
lastFlushPromise = doFlush();
|
|
136
|
+
}
|
|
137
|
+
// Loop one more pass if the chained doFlush() queued more
|
|
138
|
+
// work, then bail.
|
|
139
|
+
if (lastFlushPromise === before && buffer.length === 0)
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
stop() {
|
|
144
|
+
stopped = true;
|
|
145
|
+
if (timer) {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
timer = undefined;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
_onError(err, event) {
|
|
151
|
+
// Capture for use inside doFlush (the strategy doesn't know what
|
|
152
|
+
// the consumer's error sink is unless they wire `_onError` via
|
|
153
|
+
// the strategy options. We store it on this hook so put-failures
|
|
154
|
+
// route correctly).
|
|
155
|
+
onErrorHook =
|
|
156
|
+
onErrorHook ??
|
|
157
|
+
((e) => {
|
|
158
|
+
// eslint-disable-next-line no-console
|
|
159
|
+
console.error(`[${strategyName}Observability] flush failed:`, e.message);
|
|
160
|
+
});
|
|
161
|
+
onErrorHook(err, event);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
exports._buildCloudWatchObservability = _buildCloudWatchObservability;
|
|
166
|
+
// ─── Public factory: cloudwatchObservability ─────────────────────────
|
|
167
|
+
/**
|
|
168
|
+
* Generic CloudWatch Logs observability adapter. See
|
|
169
|
+
* `CloudwatchObservabilityOptions` for the per-option contract.
|
|
170
|
+
*
|
|
171
|
+
* For AgentCore-specific conventions, use `agentcoreObservability`
|
|
172
|
+
* which thin-wraps this with AgentCore-flavored defaults.
|
|
173
|
+
*/
|
|
174
|
+
function cloudwatchObservability(opts) {
|
|
175
|
+
return _buildCloudWatchObservability(opts, 'cloudwatch');
|
|
176
|
+
}
|
|
177
|
+
exports.cloudwatchObservability = cloudwatchObservability;
|
|
178
|
+
// ─── SDK client construction (lazy) ──────────────────────────────────
|
|
179
|
+
function createCloudWatchClient(region, strategyName) {
|
|
180
|
+
let mod;
|
|
181
|
+
try {
|
|
182
|
+
mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-cloudwatch-logs');
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
throw new Error(`[${strategyName}Observability] requires the \`@aws-sdk/client-cloudwatch-logs\` peer dependency.\n` +
|
|
186
|
+
` Install: npm install @aws-sdk/client-cloudwatch-logs\n` +
|
|
187
|
+
` Or pass \`_client\` for test injection.`);
|
|
188
|
+
}
|
|
189
|
+
if (!mod.CloudWatchLogsClient || !mod.PutLogEventsCommand) {
|
|
190
|
+
throw new Error(`[${strategyName}Observability]: \`@aws-sdk/client-cloudwatch-logs\` is installed but ` +
|
|
191
|
+
`\`CloudWatchLogsClient\` / \`PutLogEventsCommand\` was not found. Update the SDK.`);
|
|
192
|
+
}
|
|
193
|
+
const sdkClient = new mod.CloudWatchLogsClient({ ...(region && { region }) });
|
|
194
|
+
return {
|
|
195
|
+
async putLogEvents(input) {
|
|
196
|
+
// Cast the SDK constructor to the call shape — same trick as
|
|
197
|
+
// the memory adapter to stay forward-compat with SDK shape drift.
|
|
198
|
+
const cmd = new mod.PutLogEventsCommand(input);
|
|
199
|
+
await sdkClient.send(cmd);
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=cloudwatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudwatch.js","sourceRoot":"","sources":["../../../src/adapters/observability/cloudwatch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;;;AAGH,6DAAuD;AA+CvD,wEAAwE;AAExE;;;;;;;;;;GAUG;AACH,SAAgB,6BAA6B,CAC3C,IAAoC,EACpC,YAAoB;IAEpB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACvB,MAAM,IAAI,SAAS,CACjB,IAAI,YAAY,+CAA+C;YAC7D,kEAAkE,CACrE,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,gBAAgB,CAAC;IA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,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,IAAI,YAAY,uEAAuE;YACrF,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAE3E,CAAC;IAEF,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,KAAK;YACtB,6DAA6D;YAC7D,kEAAkE;YAClE,MAAM,GAAG,GAAG,IAAK,GAAG,CAAC,mBAAmD,CAAC,KAAK,CAAC,CAAC;YAChF,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
* **Implementation:** thin wrapper over `cloudwatchObservability`'s
|
|
20
|
+
* shared base. The only difference is the strategy `name` (used for
|
|
21
|
+
* registry lookup + diagnostics). All batching, flush, error-routing,
|
|
22
|
+
* and SDK-loading behavior is identical. As we evolve the CloudWatch
|
|
23
|
+
* shipping path (retry, sequence tokens, metrics emission), every
|
|
24
|
+
* CloudWatch-shaped adapter inherits the improvement.
|
|
25
|
+
*
|
|
26
|
+
* @example Basic
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { agentcoreObservability } from 'agentfootprint/observability-providers';
|
|
29
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
30
|
+
*
|
|
31
|
+
* agent.enable.observability({
|
|
32
|
+
* strategy: agentcoreObservability({
|
|
33
|
+
* region: 'us-east-1',
|
|
34
|
+
* logGroupName: '/agentfootprint/my-agent',
|
|
35
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
36
|
+
* }),
|
|
37
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Test injection (skip SDK require entirely)
|
|
42
|
+
* ```ts
|
|
43
|
+
* agentcoreObservability({
|
|
44
|
+
* _client: {
|
|
45
|
+
* putLogEvents: async (input) => { capturedBatches.push(input); },
|
|
46
|
+
* },
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
import { _buildCloudWatchObservability, } from './cloudwatch.js';
|
|
51
|
+
/**
|
|
52
|
+
* Build an AgentCore-flavored CloudWatch Logs observability strategy.
|
|
53
|
+
* Functionally identical to `cloudwatchObservability` except for the
|
|
54
|
+
* strategy `name`, which lets registry-lookup + diagnostics
|
|
55
|
+
* distinguish AgentCore-targeted shipping from generic CloudWatch.
|
|
56
|
+
*/
|
|
57
|
+
export function agentcoreObservability(opts) {
|
|
58
|
+
return _buildCloudWatchObservability(opts, 'agentcore');
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=agentcore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/observability/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAIH,OAAO,EACL,6BAA6B,GAE9B,MAAM,iBAAiB,CAAC;AAWzB;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAmC;IACxE,OAAO,6BAA6B,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cloudwatchObservability — Generic AWS CloudWatch Logs adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ships every `AgentfootprintEvent` to a CloudWatch Logs stream. Use
|
|
5
|
+
* when you want agent telemetry alongside the rest of your AWS
|
|
6
|
+
* observability stack — CloudWatch Insights queries, alarms,
|
|
7
|
+
* cross-service correlation. Same SDK as `agentcoreObservability`
|
|
8
|
+
* but **without** the AgentCore-specific defaults (log-stream
|
|
9
|
+
* convention, format opinions). Use this when:
|
|
10
|
+
*
|
|
11
|
+
* 1. You're shipping to CloudWatch but NOT running inside Bedrock
|
|
12
|
+
* AgentCore (most common case).
|
|
13
|
+
* 2. You want full control over log group / stream / format and
|
|
14
|
+
* don't need AgentCore's hosted-agent telemetry conventions.
|
|
15
|
+
*
|
|
16
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
17
|
+
* Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
|
|
18
|
+
* only when this adapter is used; declared via
|
|
19
|
+
* `peerDependenciesMeta.{name}.optional = true`).
|
|
20
|
+
*
|
|
21
|
+
* This module also exports the underlying base function used by
|
|
22
|
+
* `agentcoreObservability` — keeps the per-event hot path in one
|
|
23
|
+
* place so improvements (batching, retry, backpressure) flow to
|
|
24
|
+
* every CloudWatch-shaped adapter automatically.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { cloudwatchObservability } from 'agentfootprint/observability-providers';
|
|
29
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
30
|
+
*
|
|
31
|
+
* agent.enable.observability({
|
|
32
|
+
* strategy: cloudwatchObservability({
|
|
33
|
+
* region: 'us-east-1',
|
|
34
|
+
* logGroupName: '/myapp/agent-prod',
|
|
35
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
36
|
+
* }),
|
|
37
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
import { lazyRequire } from '../../lib/lazyRequire.js';
|
|
42
|
+
// ─── Generic base — also used by agentcoreObservability ──────────────
|
|
43
|
+
/**
|
|
44
|
+
* Internal: shared CloudWatch Logs base used by every adapter that
|
|
45
|
+
* ships to CWL. `cloudwatchObservability` is the public generic
|
|
46
|
+
* factory; `agentcoreObservability` calls this with AgentCore-flavored
|
|
47
|
+
* defaults.
|
|
48
|
+
*
|
|
49
|
+
* Exported for adapter authors only — consumers should call
|
|
50
|
+
* `cloudwatchObservability` or `agentcoreObservability` directly.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export function _buildCloudWatchObservability(opts, strategyName) {
|
|
55
|
+
if (!opts.logGroupName) {
|
|
56
|
+
throw new TypeError(`[${strategyName}Observability] \`logGroupName\` is required. ` +
|
|
57
|
+
`Pass an existing CloudWatch log group, e.g. '/myapp/agent-prod'.`);
|
|
58
|
+
}
|
|
59
|
+
const logStreamName = opts.logStreamName ?? 'agentfootprint';
|
|
60
|
+
const maxBatchEvents = opts.maxBatchEvents ?? 100;
|
|
61
|
+
const maxBatchBytes = opts.maxBatchBytes ?? 10_240;
|
|
62
|
+
const flushIntervalMs = opts.flushIntervalMs ?? 1000;
|
|
63
|
+
// Buffered batch — drained by `flush()` / size-trigger / time-trigger.
|
|
64
|
+
const buffer = [];
|
|
65
|
+
let bufferBytes = 0;
|
|
66
|
+
let lastFlushPromise = Promise.resolve();
|
|
67
|
+
let timer;
|
|
68
|
+
let stopped = false;
|
|
69
|
+
let onErrorHook;
|
|
70
|
+
// Lazy-resolved on first flush so consumers who never trigger a
|
|
71
|
+
// flush (because nothing was emitted) don't even hit the SDK.
|
|
72
|
+
let client = opts._client;
|
|
73
|
+
function ensureClient() {
|
|
74
|
+
if (client)
|
|
75
|
+
return client;
|
|
76
|
+
client = createCloudWatchClient(opts.region, strategyName);
|
|
77
|
+
return client;
|
|
78
|
+
}
|
|
79
|
+
function scheduleTimedFlush() {
|
|
80
|
+
if (timer || flushIntervalMs <= 0 || stopped)
|
|
81
|
+
return;
|
|
82
|
+
timer = setTimeout(() => {
|
|
83
|
+
timer = undefined;
|
|
84
|
+
void doFlush();
|
|
85
|
+
}, flushIntervalMs);
|
|
86
|
+
}
|
|
87
|
+
async function doFlush() {
|
|
88
|
+
if (buffer.length === 0 || stopped)
|
|
89
|
+
return;
|
|
90
|
+
// Snapshot + clear so concurrent emits during the in-flight put
|
|
91
|
+
// accumulate into the next batch.
|
|
92
|
+
const batch = buffer.splice(0);
|
|
93
|
+
bufferBytes = 0;
|
|
94
|
+
try {
|
|
95
|
+
await ensureClient().putLogEvents({
|
|
96
|
+
logGroupName: opts.logGroupName,
|
|
97
|
+
logStreamName,
|
|
98
|
+
logEvents: batch,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
onErrorHook?.(err instanceof Error ? err : new Error(String(err)));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function enqueue(event) {
|
|
106
|
+
if (stopped)
|
|
107
|
+
return;
|
|
108
|
+
const message = JSON.stringify(event);
|
|
109
|
+
const bytes = Buffer.byteLength(message, 'utf8');
|
|
110
|
+
buffer.push({ timestamp: Date.now(), message });
|
|
111
|
+
bufferBytes += bytes;
|
|
112
|
+
if (buffer.length >= maxBatchEvents || bufferBytes >= maxBatchBytes) {
|
|
113
|
+
// Size trigger — flush immediately. Chain onto last to preserve
|
|
114
|
+
// CloudWatch's per-stream ordering requirement.
|
|
115
|
+
lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
scheduleTimedFlush();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
name: strategyName,
|
|
123
|
+
capabilities: { events: true, logs: true },
|
|
124
|
+
exportEvent: enqueue,
|
|
125
|
+
async flush() {
|
|
126
|
+
// Drain anything pending. Awaits both an in-flight put AND any
|
|
127
|
+
// newly-buffered events that arrived during it.
|
|
128
|
+
while (buffer.length > 0 || lastFlushPromise !== Promise.resolve()) {
|
|
129
|
+
const before = lastFlushPromise;
|
|
130
|
+
await before;
|
|
131
|
+
if (buffer.length > 0) {
|
|
132
|
+
lastFlushPromise = doFlush();
|
|
133
|
+
}
|
|
134
|
+
// Loop one more pass if the chained doFlush() queued more
|
|
135
|
+
// work, then bail.
|
|
136
|
+
if (lastFlushPromise === before && buffer.length === 0)
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
stop() {
|
|
141
|
+
stopped = true;
|
|
142
|
+
if (timer) {
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
timer = undefined;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
_onError(err, event) {
|
|
148
|
+
// Capture for use inside doFlush (the strategy doesn't know what
|
|
149
|
+
// the consumer's error sink is unless they wire `_onError` via
|
|
150
|
+
// the strategy options. We store it on this hook so put-failures
|
|
151
|
+
// route correctly).
|
|
152
|
+
onErrorHook =
|
|
153
|
+
onErrorHook ??
|
|
154
|
+
((e) => {
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
console.error(`[${strategyName}Observability] flush failed:`, e.message);
|
|
157
|
+
});
|
|
158
|
+
onErrorHook(err, event);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// ─── Public factory: cloudwatchObservability ─────────────────────────
|
|
163
|
+
/**
|
|
164
|
+
* Generic CloudWatch Logs observability adapter. See
|
|
165
|
+
* `CloudwatchObservabilityOptions` for the per-option contract.
|
|
166
|
+
*
|
|
167
|
+
* For AgentCore-specific conventions, use `agentcoreObservability`
|
|
168
|
+
* which thin-wraps this with AgentCore-flavored defaults.
|
|
169
|
+
*/
|
|
170
|
+
export function cloudwatchObservability(opts) {
|
|
171
|
+
return _buildCloudWatchObservability(opts, 'cloudwatch');
|
|
172
|
+
}
|
|
173
|
+
// ─── SDK client construction (lazy) ──────────────────────────────────
|
|
174
|
+
function createCloudWatchClient(region, strategyName) {
|
|
175
|
+
let mod;
|
|
176
|
+
try {
|
|
177
|
+
mod = lazyRequire('@aws-sdk/client-cloudwatch-logs');
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
throw new Error(`[${strategyName}Observability] requires the \`@aws-sdk/client-cloudwatch-logs\` peer dependency.\n` +
|
|
181
|
+
` Install: npm install @aws-sdk/client-cloudwatch-logs\n` +
|
|
182
|
+
` Or pass \`_client\` for test injection.`);
|
|
183
|
+
}
|
|
184
|
+
if (!mod.CloudWatchLogsClient || !mod.PutLogEventsCommand) {
|
|
185
|
+
throw new Error(`[${strategyName}Observability]: \`@aws-sdk/client-cloudwatch-logs\` is installed but ` +
|
|
186
|
+
`\`CloudWatchLogsClient\` / \`PutLogEventsCommand\` was not found. Update the SDK.`);
|
|
187
|
+
}
|
|
188
|
+
const sdkClient = new mod.CloudWatchLogsClient({ ...(region && { region }) });
|
|
189
|
+
return {
|
|
190
|
+
async putLogEvents(input) {
|
|
191
|
+
// Cast the SDK constructor to the call shape — same trick as
|
|
192
|
+
// the memory adapter to stay forward-compat with SDK shape drift.
|
|
193
|
+
const cmd = new mod.PutLogEventsCommand(input);
|
|
194
|
+
await sdkClient.send(cmd);
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=cloudwatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudwatch.js","sourceRoot":"","sources":["../../../../src/adapters/observability/cloudwatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA+CvD,wEAAwE;AAExE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,6BAA6B,CAC3C,IAAoC,EACpC,YAAoB;IAEpB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACvB,MAAM,IAAI,SAAS,CACjB,IAAI,YAAY,+CAA+C;YAC7D,kEAAkE,CACrE,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,gBAAgB,CAAC;IAC7D,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,GAAG,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,MAAM,CAAC;IACnD,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC;IAErD,uEAAuE;IACvE,MAAM,MAAM,GAAkD,EAAE,CAAC;IACjE,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,gBAAgB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IACxD,IAAI,KAAgD,CAAC;IACrD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,WAA4E,CAAC;IAEjF,gEAAgE;IAChE,8DAA8D;IAC9D,IAAI,MAAM,GAAqC,IAAI,CAAC,OAAO,CAAC;IAC5D,SAAS,YAAY;QACnB,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,MAAM,GAAG,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,SAAS,kBAAkB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AC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,wEAAwE;AAExE;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAoC;IAEpC,OAAO,6BAA6B,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED,wEAAwE;AAExE,SAAS,sBAAsB,CAC7B,MAA0B,EAC1B,YAAoB;IAEpB,IAAI,GAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,GAAG,GAAG,WAAW,CAAsB,iCAAiC,CAAC,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,IAAI,YAAY,oFAAoF;YAClG,2DAA2D;YAC3D,2CAA2C,CAC9C,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,IAAI,YAAY,uEAAuE;YACrF,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAE3E,CAAC;IAEF,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,KAAK;YACtB,6DAA6D;YAC7D,kEAAkE;YAClE,MAAM,GAAG,GAAG,IAAK,GAAG,CAAC,mBAAmD,CAAC,KAAK,CAAC,CAAC;YAChF,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/observability-providers — vendor observability strategies.
|
|
3
|
+
*
|
|
4
|
+
* Grouped subpath following the parallel-providers pattern v2.5
|
|
5
|
+
* established for `llm-providers` / `tool-providers` /
|
|
6
|
+
* `memory-providers`. Adding a new vendor adds an export here, NOT
|
|
7
|
+
* a new subpath — keeps `package.json#exports` from sprawling.
|
|
8
|
+
*
|
|
9
|
+
* Each adapter lazy-imports its vendor SDK via `lib/lazyRequire.ts`,
|
|
10
|
+
* so consumers who never call a particular factory don't have to
|
|
11
|
+
* install that SDK. Peer-deps are declared in package.json with
|
|
12
|
+
* `peerDependenciesMeta.{name}.optional = true`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { agentcoreObservability } from 'agentfootprint/observability-providers';
|
|
17
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
18
|
+
*
|
|
19
|
+
* agent.enable.observability({
|
|
20
|
+
* strategy: agentcoreObservability({
|
|
21
|
+
* region: 'us-east-1',
|
|
22
|
+
* logGroupName: '/agentfootprint/my-agent',
|
|
23
|
+
* }),
|
|
24
|
+
* // Recommended — keeps the agent loop unblocked by network latency.
|
|
25
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Roadmap:
|
|
30
|
+
* - agentcoreObservability ← v2.8.1
|
|
31
|
+
* - cloudwatchObservability ← v2.8.2 (this release)
|
|
32
|
+
* - xrayObservability ← v2.8.3
|
|
33
|
+
* - otelObservability ← v2.9.x
|
|
34
|
+
* - datadogObservability ← v2.9.x
|
|
35
|
+
*/
|
|
36
|
+
export { agentcoreObservability, } from './adapters/observability/agentcore.js';
|
|
37
|
+
export { cloudwatchObservability, } from './adapters/observability/cloudwatch.js';
|
|
38
|
+
//# sourceMappingURL=observability-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability-providers.js","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,uBAAuB,GAExB,MAAM,wCAAwC,CAAC"}
|
|
@@ -7,14 +7,28 @@
|
|
|
7
7
|
* - `types.ts` — typed interfaces (Observability, Cost, LiveStatus, Lens)
|
|
8
8
|
* - `defaults/` — the 4 in-core default strategies
|
|
9
9
|
*
|
|
10
|
-
* Vendor strategies ship
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - `agentfootprint/observability-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* Vendor strategies ship under three GROUPED subpaths (matching the
|
|
11
|
+
* parallel-providers pattern v2.5 established for `llm-providers` /
|
|
12
|
+
* `tool-providers` / `memory-providers`). Each subpath holds N
|
|
13
|
+
* vendor-named factories — adding a vendor never adds a new subpath:
|
|
14
|
+
*
|
|
15
|
+
* - `agentfootprint/observability-providers`
|
|
16
|
+
* agentcoreObservability (v2.8.1)
|
|
17
|
+
* cloudwatchObservability (v2.8.2)
|
|
18
|
+
* xrayObservability (v2.8.3)
|
|
19
|
+
* otelObservability (v2.9.x)
|
|
20
|
+
* datadogObservability (v2.9.x)
|
|
21
|
+
*
|
|
22
|
+
* - `agentfootprint/cost-providers`
|
|
23
|
+
* stripeCost (v2.10.x)
|
|
24
|
+
*
|
|
25
|
+
* - `agentfootprint/lens-providers`
|
|
26
|
+
* browserLens / cliLens (v2.12.x)
|
|
27
|
+
*
|
|
28
|
+
* Each adapter lazy-imports its vendor SDK via `lib/lazyRequire.ts`,
|
|
29
|
+
* so consumers who never call a particular factory don't have to
|
|
30
|
+
* install that SDK. Peer-deps are declared in package.json with
|
|
31
|
+
* `peerDependenciesMeta.{name}.optional = true`.
|
|
18
32
|
*/
|
|
19
33
|
export * from './types.js';
|
|
20
34
|
export * from './defaults/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strategies/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strategies/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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"}
|