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.
@@ -16,11 +16,12 @@
16
16
  * only when this adapter is used; declared via
17
17
  * `peerDependenciesMeta.{name}.optional = true`).
18
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.
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.
24
25
  *
25
26
  * @example Basic
26
27
  * ```ts
@@ -47,40 +48,20 @@
47
48
  * ```
48
49
  */
49
50
  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
- }
51
+ import { type CloudwatchObservabilityOptions } from './cloudwatch.js';
52
+ /**
53
+ * AgentCore-specific options. Currently identical to the generic
54
+ * `CloudwatchObservabilityOptions` kept as a separate type for
55
+ * future-proofing (AgentCore-specific knobs like
56
+ * `agentcoreSessionId` propagation could land here without a
57
+ * breaking change).
58
+ */
59
+ export type AgentcoreObservabilityOptions = CloudwatchObservabilityOptions;
60
+ /**
61
+ * Build an AgentCore-flavored CloudWatch Logs observability strategy.
62
+ * Functionally identical to `cloudwatchObservability` except for the
63
+ * strategy `name`, which lets registry-lookup + diagnostics
64
+ * distinguish AgentCore-targeted shipping from generic CloudWatch.
65
+ */
84
66
  export declare function agentcoreObservability(opts: AgentcoreObservabilityOptions): ObservabilityStrategy;
85
- export {};
86
67
  //# sourceMappingURL=agentcore.d.ts.map
@@ -1 +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
+ {"version":3,"file":"agentcore.d.ts","sourceRoot":"","sources":["../../../../src/adapters/observability/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,MAAM,6BAA6B,GAAG,8BAA8B,CAAC;AAE3E;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,6BAA6B,GAAG,qBAAqB,CAEjG"}
@@ -0,0 +1,97 @@
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 type { ObservabilityStrategy } from '../../strategies/types.js';
42
+ export interface CloudwatchObservabilityOptions {
43
+ /** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
44
+ readonly region?: string;
45
+ /** CloudWatch Logs log group. **Required.** Must exist or your IAM
46
+ * role must allow `logs:CreateLogGroup`. */
47
+ readonly logGroupName: string;
48
+ /** CloudWatch Logs log stream within the group. Conventionally
49
+ * `<host>/<startTime>` so multi-instance deployments don't
50
+ * collide. Created on first put if it doesn't exist (or your
51
+ * role must allow `logs:CreateLogStream`). Defaults to
52
+ * `agentfootprint`. */
53
+ readonly logStreamName?: string;
54
+ /** Max events buffered before forced flush. Default 100. */
55
+ readonly maxBatchEvents?: number;
56
+ /** Max payload bytes (UTF-8) buffered before forced flush. Default
57
+ * 10240 (10 KB). CloudWatch hard caps at 1 MB / batch but we keep
58
+ * the default low so latency stays bounded. */
59
+ readonly maxBatchBytes?: number;
60
+ /** Forced-flush interval when traffic is sparse. Default 1000ms.
61
+ * `0` disables time-based flush — only size triggers fire. */
62
+ readonly flushIntervalMs?: number;
63
+ /** Test injection — bypasses SDK lazy-require entirely. When set,
64
+ * `region` / IAM are ignored. */
65
+ readonly _client?: CloudWatchLikeClient;
66
+ }
67
+ export interface CloudWatchLikeClient {
68
+ putLogEvents(input: {
69
+ logGroupName: string;
70
+ logStreamName: string;
71
+ logEvents: ReadonlyArray<{
72
+ timestamp: number;
73
+ message: string;
74
+ }>;
75
+ }): Promise<unknown>;
76
+ }
77
+ /**
78
+ * Internal: shared CloudWatch Logs base used by every adapter that
79
+ * ships to CWL. `cloudwatchObservability` is the public generic
80
+ * factory; `agentcoreObservability` calls this with AgentCore-flavored
81
+ * defaults.
82
+ *
83
+ * Exported for adapter authors only — consumers should call
84
+ * `cloudwatchObservability` or `agentcoreObservability` directly.
85
+ *
86
+ * @internal
87
+ */
88
+ export declare function _buildCloudWatchObservability(opts: CloudwatchObservabilityOptions, strategyName: string): ObservabilityStrategy;
89
+ /**
90
+ * Generic CloudWatch Logs observability adapter. See
91
+ * `CloudwatchObservabilityOptions` for the per-option contract.
92
+ *
93
+ * For AgentCore-specific conventions, use `agentcoreObservability`
94
+ * which thin-wraps this with AgentCore-flavored defaults.
95
+ */
96
+ export declare function cloudwatchObservability(opts: CloudwatchObservabilityOptions): ObservabilityStrategy;
97
+ //# sourceMappingURL=cloudwatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudwatch.d.ts","sourceRoot":"","sources":["../../../../src/adapters/observability/cloudwatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE,MAAM,WAAW,8BAA8B;IAC7C,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;iDAC6C;IAC7C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;4BAIwB;IACxB,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,MAAM,WAAW,oBAAoB;IACnC,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;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,8BAA8B,EACpC,YAAY,EAAE,MAAM,GACnB,qBAAqB,CA8GvB;AAID;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,8BAA8B,GACnC,qBAAqB,CAEvB"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * xrayObservability — AWS X-Ray distributed-tracing adapter.
3
+ *
4
+ * Maps agentfootprint's event taxonomy onto AWS X-Ray segment trees:
5
+ *
6
+ * agent.turn_start ↦ root segment (one trace per turn)
7
+ * agent.turn_end ↦ close root segment + flush
8
+ * agent.iteration_start ↦ push subsegment under root
9
+ * agent.iteration_end ↦ close iteration subsegment
10
+ * stream.llm_start ↦ push leaf subsegment (model call)
11
+ * stream.llm_end ↦ close llm subsegment
12
+ * stream.tool_start ↦ push leaf subsegment (tool call)
13
+ * stream.tool_end ↦ close tool subsegment
14
+ *
15
+ * The result in the X-Ray Trace Map: a hierarchical timeline of every
16
+ * agent run — turn → iteration → llm-call/tool-call — queryable in
17
+ * X-Ray Insights, joinable with the rest of your AWS distributed
18
+ * trace via `AWSTraceHeader` propagation (consumer's responsibility
19
+ * to wire upstream/downstream IDs).
20
+ *
21
+ * Subpath: `agentfootprint/observability-providers`
22
+ * Peer dep: `@aws-sdk/client-xray` (OPTIONAL — installed only when
23
+ * this adapter is used).
24
+ *
25
+ * Sampling:
26
+ * By default every turn produces one trace. Pass `sampleRate: 0.1`
27
+ * to sample 10% of turns — sampling decisions are made at
28
+ * `turn_start` and persist for the whole turn (so partial traces
29
+ * never reach X-Ray).
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { xrayObservability } from 'agentfootprint/observability-providers';
34
+ * import { microtaskBatchDriver } from 'footprintjs/detach';
35
+ *
36
+ * agent.enable.observability({
37
+ * strategy: xrayObservability({
38
+ * region: 'us-east-1',
39
+ * serviceName: 'my-agent',
40
+ * sampleRate: 0.1, // 10% sampling
41
+ * }),
42
+ * detach: { driver: microtaskBatchDriver, mode: 'forget' },
43
+ * });
44
+ * ```
45
+ *
46
+ * @example Test injection
47
+ * ```ts
48
+ * xrayObservability({
49
+ * serviceName: 'test',
50
+ * _client: {
51
+ * putTraceSegments: async (input) => { capturedDocs.push(input); },
52
+ * },
53
+ * });
54
+ * ```
55
+ */
56
+ import type { ObservabilityStrategy } from '../../strategies/types.js';
57
+ export interface XrayObservabilityOptions {
58
+ /** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
59
+ readonly region?: string;
60
+ /** Service name on every emitted segment. Surfaces in X-Ray's
61
+ * service map. Required. */
62
+ readonly serviceName: string;
63
+ /** 0..1 — fraction of turns to sample. Default `1.0` (every turn).
64
+ * Decisions are made at `turn_start` and persist for the whole
65
+ * turn so partial traces never reach X-Ray. */
66
+ readonly sampleRate?: number;
67
+ /** Max segments buffered before forced flush. X-Ray's
68
+ * `PutTraceSegments` API accepts up to 50 segments per call;
69
+ * default 25 keeps latency tight. */
70
+ readonly maxBatchSegments?: number;
71
+ /** Forced flush window for low-traffic agents. Default 1000ms.
72
+ * `0` disables time-based flush. */
73
+ readonly flushIntervalMs?: number;
74
+ /** Test injection — bypasses SDK lazy-require entirely. */
75
+ readonly _client?: XRayLikeClient;
76
+ }
77
+ export interface XRayLikeClient {
78
+ putTraceSegments(input: {
79
+ TraceSegmentDocuments: ReadonlyArray<string>;
80
+ }): Promise<unknown>;
81
+ }
82
+ export declare function xrayObservability(opts: XrayObservabilityOptions): ObservabilityStrategy;
83
+ //# sourceMappingURL=xray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xray.d.ts","sourceRoot":"","sources":["../../../../src/adapters/observability/xray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE,MAAM,WAAW,wBAAwB;IACvC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;iCAC6B;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;oDAEgD;IAChD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;0CAEsC;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;yCACqC;IACrC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAID,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,KAAK,EAAE;QAAE,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7F;AA6BD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,GAAG,qBAAqB,CAuQvF"}
@@ -27,11 +27,13 @@
27
27
  * ```
28
28
  *
29
29
  * Roadmap:
30
- * - agentcoreObservability ← v2.8.1 (this release)
30
+ * - agentcoreObservability ← v2.8.1
31
31
  * - cloudwatchObservability ← v2.8.2
32
- * - xrayObservability ← v2.8.3
32
+ * - xrayObservability ← v2.8.3 (this release)
33
33
  * - otelObservability ← v2.9.x
34
34
  * - datadogObservability ← v2.9.x
35
35
  */
36
36
  export { agentcoreObservability, type AgentcoreObservabilityOptions, } from './adapters/observability/agentcore.js';
37
+ export { cloudwatchObservability, type CloudwatchObservabilityOptions, } from './adapters/observability/cloudwatch.js';
38
+ export { xrayObservability, type XrayObservabilityOptions, type XRayLikeClient, } from './adapters/observability/xray.js';
37
39
  //# sourceMappingURL=observability-providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observability-providers.d.ts","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"observability-providers.d.ts","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,GACpC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACpB,MAAM,kCAAkC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",
@@ -171,6 +171,7 @@
171
171
  "@aws-sdk/client-bedrock-agent-runtime": "*",
172
172
  "@aws-sdk/client-bedrock-runtime": "*",
173
173
  "@aws-sdk/client-cloudwatch-logs": "*",
174
+ "@aws-sdk/client-xray": "*",
174
175
  "@modelcontextprotocol/sdk": "*",
175
176
  "footprintjs": ">=4.17.1",
176
177
  "ioredis": "*",
@@ -193,6 +194,9 @@
193
194
  "@aws-sdk/client-cloudwatch-logs": {
194
195
  "optional": true
195
196
  },
197
+ "@aws-sdk/client-xray": {
198
+ "optional": true
199
+ },
196
200
  "@modelcontextprotocol/sdk": {
197
201
  "optional": true
198
202
  },