agentfootprint 2.8.1 → 2.8.3

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.
@@ -17,11 +17,12 @@
17
17
  * only when this adapter is used; declared via
18
18
  * `peerDependenciesMeta.{name}.optional = true`).
19
19
  *
20
- * Pattern: Adapter (GoF) translates `AgentfootprintEvent`
21
- * CloudWatch Logs `PutLogEvents` payloads. Buffers in
22
- * `exportEvent()` (sync, non-throwing); flushes in `flush()`
23
- * (async batch). Default flush window: 1s OR 10 KB,
24
- * whichever first matches CloudWatch's own optimal batch.
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.
25
26
  *
26
27
  * @example Basic
27
28
  * ```ts
@@ -49,140 +50,15 @@
49
50
  */
50
51
  Object.defineProperty(exports, "__esModule", { value: true });
51
52
  exports.agentcoreObservability = void 0;
52
- const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
53
- // ─── Strategy factory ────────────────────────────────────────────────
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
+ */
54
60
  function agentcoreObservability(opts) {
55
- if (!opts.logGroupName) {
56
- throw new TypeError(`[agentcoreObservability] \`logGroupName\` is required. ` +
57
- `Pass an existing CloudWatch log group, e.g. '/agentfootprint/my-agent'.`);
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);
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: 'agentcore',
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('[agentcoreObservability] flush failed:', e.message);
157
- });
158
- onErrorHook(err, event);
159
- },
160
- };
61
+ return (0, cloudwatch_js_1._buildCloudWatchObservability)(opts, 'agentcore');
161
62
  }
162
63
  exports.agentcoreObservability = agentcoreObservability;
163
- // ─── SDK client construction (lazy) ──────────────────────────────────
164
- function createCloudWatchClient(region) {
165
- let mod;
166
- try {
167
- mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-cloudwatch-logs');
168
- }
169
- catch {
170
- throw new Error('agentcoreObservability requires the `@aws-sdk/client-cloudwatch-logs` peer dependency.\n' +
171
- ' Install: npm install @aws-sdk/client-cloudwatch-logs\n' +
172
- ' Or pass `_client` for test injection.');
173
- }
174
- if (!mod.CloudWatchLogsClient || !mod.PutLogEventsCommand) {
175
- throw new Error('agentcoreObservability: `@aws-sdk/client-cloudwatch-logs` is installed but ' +
176
- '`CloudWatchLogsClient` / `PutLogEventsCommand` was not found. Update the SDK.');
177
- }
178
- const sdkClient = new mod.CloudWatchLogsClient({ ...(region && { region }) });
179
- return {
180
- async putLogEvents(input) {
181
- // Cast the SDK constructor to the call shape — same trick as the
182
- // memory adapter to stay forward-compat with SDK shape drift.
183
- const cmd = new mod.PutLogEventsCommand(input);
184
- await sdkClient.send(cmd);
185
- },
186
- };
187
- }
188
64
  //# sourceMappingURL=agentcore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/observability/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;;;AAGH,6DAAuD;AA8CvD,wEAAwE;AAExE,SAAgB,sBAAsB,CAAC,IAAmC;IACxE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACvB,MAAM,IAAI,SAAS,CACjB,yDAAyD;YACvD,yEAAyE,CAC5E,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,CAAC,CAAC;QAC7C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,SAAS,kBAAkB;QACzB,IAAI,KAAK,IAAI,eAAe,IAAI,CAAC,IAAI,OAAO;YAAE,OAAO;QACrD,KAAK,GAAG,UAAU,CAAC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ACxD,IAAI,GAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,GAAG,GAAG,IAAA,4BAAW,EAAsB,iCAAiC,CAAC,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,0FAA0F;YACxF,2DAA2D;YAC3D,yCAAyC,CAC5C,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,6EAA6E;YAC3E,+EAA+E,CAClF,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,iEAAiE;YACjE,8DAA8D;YAC9D,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"}
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;IAC7D,MAAM,cAAc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