@agentsbloom/sdk 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +184 -254
- package/SECURITY.md +24 -19
- package/index.d.ts +355 -124
- package/index.js +1582 -342
- package/lib/ap2.js +1017 -422
- package/lib/http-signatures.js +874 -0
- package/lib/money.js +283 -0
- package/lib/outcomes.js +108 -0
- package/lib/protocol.d.ts +229 -0
- package/lib/protocol.js +85 -0
- package/lib/shared-store.js +298 -0
- package/lib/signature-base.js +436 -0
- package/lib/structured-fields.js +398 -0
- package/package.json +95 -81
- package/telemetry.js +77 -50
- package/assets/logo-mark.svg +0 -25
package/telemetry.js
CHANGED
|
@@ -1,50 +1,77 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OTLP trace exporter initialization for the AgentsBloom SDK.
|
|
3
|
-
*
|
|
4
|
-
* The OpenTelemetry SDK packages required to actually export spans
|
|
5
|
-
* (@opentelemetry/sdk-trace-node, sdk-trace-base, exporter-trace-otlp-http,
|
|
6
|
-
* resources, semantic-conventions) are loaded via dynamic import() so that
|
|
7
|
-
* a merchant application that never calls setupTelemetry() is never forced
|
|
8
|
-
* to install them. They are declared as optionalDependencies in
|
|
9
|
-
* package.json rather than dependencies.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
const {
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
/**
|
|
2
|
+
* OTLP trace exporter initialization for the AgentsBloom SDK.
|
|
3
|
+
*
|
|
4
|
+
* The OpenTelemetry SDK packages required to actually export spans
|
|
5
|
+
* (@opentelemetry/sdk-trace-node, sdk-trace-base, exporter-trace-otlp-http,
|
|
6
|
+
* resources, semantic-conventions) are loaded via dynamic import() so that
|
|
7
|
+
* a merchant application that never calls setupTelemetry() is never forced
|
|
8
|
+
* to install them. They are declared as optionalDependencies in
|
|
9
|
+
* package.json rather than dependencies.
|
|
10
|
+
*
|
|
11
|
+
* Dependency-audit note (2026-08): upgraded to the OpenTelemetry JS 2.x line
|
|
12
|
+
* (sdk-trace-*@2.10, resources@2.10, exporter-trace-otlp-http@0.221) which
|
|
13
|
+
* fixes GHSA-8988-4f7v-96qf and friends. The 2.x API differences this file
|
|
14
|
+
* absorbs:
|
|
15
|
+
* - `Resource` class is gone -> `resourceFromAttributes()`
|
|
16
|
+
* - `SemanticResourceAttributes.SERVICE_NAME` is gone ->
|
|
17
|
+
* `ATTR_SERVICE_NAME` from @opentelemetry/semantic-conventions
|
|
18
|
+
* - `provider.register()` no longer accepts a global logger/meter; plain
|
|
19
|
+
* registration is still supported.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
let optionalDependencyWarningLogged = false;
|
|
23
|
+
|
|
24
|
+
export async function initExporter({ otlpEndpoint, serviceName, samplingRatio, apiKey } = {}) {
|
|
25
|
+
try {
|
|
26
|
+
const { NodeTracerProvider } = await import('@opentelemetry/sdk-trace-node');
|
|
27
|
+
const { BatchSpanProcessor } = await import('@opentelemetry/sdk-trace-base');
|
|
28
|
+
const { OTLPTraceExporter } = await import('@opentelemetry/exporter-trace-otlp-http');
|
|
29
|
+
const { resourceFromAttributes } = await import('@opentelemetry/resources');
|
|
30
|
+
let serviceNameKey;
|
|
31
|
+
try {
|
|
32
|
+
({ ATTR_SERVICE_NAME: serviceNameKey } = await import('@opentelemetry/semantic-conventions'));
|
|
33
|
+
} catch {
|
|
34
|
+
// Very new/old semantic-conventions layouts fall back to the literal.
|
|
35
|
+
serviceNameKey = 'service.name';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const exporter = new OTLPTraceExporter({
|
|
39
|
+
url: `${otlpEndpoint}/v1/traces`,
|
|
40
|
+
// Only send an Authorization header when there is actually a credential;
|
|
41
|
+
// `Bearer ` with an empty value is a malformed header, not "no auth".
|
|
42
|
+
...(apiKey ? { headers: { Authorization: `Bearer ${apiKey}` } } : {}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// `samplingRatio` was accepted, logged as "sampling: N%", and then never
|
|
46
|
+
// used — every deployment exported 100% of spans regardless of the value,
|
|
47
|
+
// which is a cost and a data-volume surprise rather than a security bug,
|
|
48
|
+
// but it made the option a lie. Wire it up for real.
|
|
49
|
+
const ratio = Number.isFinite(samplingRatio) ? Math.min(1, Math.max(0, samplingRatio)) : 1;
|
|
50
|
+
let sampler;
|
|
51
|
+
if (ratio < 1) {
|
|
52
|
+
try {
|
|
53
|
+
const { TraceIdRatioBasedSampler, ParentBasedSampler } = await import('@opentelemetry/sdk-trace-base');
|
|
54
|
+
// Parent-based so a sampled distributed trace stays intact end to end.
|
|
55
|
+
sampler = new ParentBasedSampler({ root: new TraceIdRatioBasedSampler(ratio) });
|
|
56
|
+
} catch {
|
|
57
|
+
sampler = undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 2.x: span processors are passed at construction via `spanProcessors`
|
|
62
|
+
// (addSpanProcessor was removed from the public provider API).
|
|
63
|
+
const provider = new NodeTracerProvider({
|
|
64
|
+
resource: resourceFromAttributes({ [serviceNameKey || 'service.name']: serviceName }),
|
|
65
|
+
spanProcessors: [new BatchSpanProcessor(exporter)],
|
|
66
|
+
...(sampler ? { sampler } : {}),
|
|
67
|
+
});
|
|
68
|
+
provider.register();
|
|
69
|
+
return { provider, exporter };
|
|
70
|
+
} catch (err) {
|
|
71
|
+
if (!optionalDependencyWarningLogged) {
|
|
72
|
+
optionalDependencyWarningLogged = true;
|
|
73
|
+
console.warn(`🌸 AgentsBloom: OTel SDK packages unavailable, continuing without export. (${err?.message || 'unknown reason'})`);
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
package/assets/logo-mark.svg
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-labelledby="agentsbloom-title">
|
|
2
|
-
<title id="agentsbloom-title">AgentsBloom</title>
|
|
3
|
-
<style>
|
|
4
|
-
@media (prefers-color-scheme: dark) {
|
|
5
|
-
.s1 { stop-color: #4A90F7; }
|
|
6
|
-
.s2 { stop-color: #4EE2F8; }
|
|
7
|
-
.s3 { stop-color: #C3AFFF; }
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
|
-
<defs>
|
|
11
|
-
<linearGradient id="lotus-gradient" x1="0" y1="0" x2="1" y2="1">
|
|
12
|
-
<stop class="s1" offset="0%" stop-color="#1A73E8" />
|
|
13
|
-
<stop class="s2" offset="50%" stop-color="#22D3EE" />
|
|
14
|
-
<stop class="s3" offset="100%" stop-color="#A78BFA" />
|
|
15
|
-
</linearGradient>
|
|
16
|
-
</defs>
|
|
17
|
-
<g fill="url(#lotus-gradient)">
|
|
18
|
-
<path d="M32 52c1.6 2 2.7 3.7 3.3 5.2.2.6 0 1-.6 1.3l-2.7 1.5-2.7-1.5c-.6-.3-.8-.7-.6-1.3.6-1.5 1.7-3.2 3.3-5.2z" />
|
|
19
|
-
<path d="M14.5 20.8c.2-1 .7-1.2 1.6-.8 4.5 1.9 8 4.8 10.5 8.7 2.3 3.6 3.6 7.7 3.8 12.2 0 1-.4 1.4-1.3 1.1-4.7-1.5-8.4-4.3-11.1-8.4-2.6-4-3.8-8.3-3.5-12.8z" />
|
|
20
|
-
<path d="M49.5 20.8c-.2-1-.7-1.2-1.6-.8-4.5 1.9-8 4.8-10.5 8.7-2.3 3.6-3.6 7.7-3.8 12.2 0 1 .4 1.4 1.3 1.1 4.7-1.5 8.4-4.3 11.1-8.4 2.6-4 3.8-8.3 3.5-12.8z" />
|
|
21
|
-
<path d="M4 30c0-1 .3-1.5 1.3-1.6 6.5-.5 12.5 1.2 17.6 4.8 4.6 3.3 7.7 7.8 9.3 13.2.3 1 .1 1.6-.9 1.7-6.8.8-13-.7-18.4-4.6C7.5 39.6 4.3 34.9 4 30z" />
|
|
22
|
-
<path d="M60 30c0-1-.3-1.5-1.3-1.6-6.5-.5-12.5 1.2-17.6 4.8-4.6 3.3-7.7 7.8-9.3 13.2-.3 1-.1 1.6.9 1.7 6.8.8 13-.7 18.4-4.6C56.5 39.6 59.7 34.9 60 30z" />
|
|
23
|
-
<path d="M32 6c4.5 6 7.2 12 8 18 .8 6-.5 12-4 18l-4 6-4-6c-3.5-6-4.8-12-4-18 .8-6 3.5-12 8-18z" />
|
|
24
|
-
</g>
|
|
25
|
-
</svg>
|