@ultrathink-solutions/openclaw-logfire 0.1.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +237 -0
  4. package/dist/config.d.ts +48 -0
  5. package/dist/config.d.ts.map +1 -0
  6. package/dist/config.js +130 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/context/propagation.d.ts +22 -0
  9. package/dist/context/propagation.d.ts.map +1 -0
  10. package/dist/context/propagation.js +93 -0
  11. package/dist/context/propagation.js.map +1 -0
  12. package/dist/context/span-store.d.ts +46 -0
  13. package/dist/context/span-store.d.ts.map +1 -0
  14. package/dist/context/span-store.js +63 -0
  15. package/dist/context/span-store.js.map +1 -0
  16. package/dist/events/inference-details.d.ts +21 -0
  17. package/dist/events/inference-details.d.ts.map +1 -0
  18. package/dist/events/inference-details.js +37 -0
  19. package/dist/events/inference-details.js.map +1 -0
  20. package/dist/hooks/agent-end.d.ts +33 -0
  21. package/dist/hooks/agent-end.d.ts.map +1 -0
  22. package/dist/hooks/agent-end.js +91 -0
  23. package/dist/hooks/agent-end.js.map +1 -0
  24. package/dist/hooks/before-agent-start.d.ts +22 -0
  25. package/dist/hooks/before-agent-start.d.ts.map +1 -0
  26. package/dist/hooks/before-agent-start.js +50 -0
  27. package/dist/hooks/before-agent-start.js.map +1 -0
  28. package/dist/hooks/before-tool-call.d.ts +20 -0
  29. package/dist/hooks/before-tool-call.d.ts.map +1 -0
  30. package/dist/hooks/before-tool-call.js +58 -0
  31. package/dist/hooks/before-tool-call.js.map +1 -0
  32. package/dist/hooks/message-received.d.ts +19 -0
  33. package/dist/hooks/message-received.d.ts.map +1 -0
  34. package/dist/hooks/message-received.js +35 -0
  35. package/dist/hooks/message-received.js.map +1 -0
  36. package/dist/hooks/tool-result-persist.d.ts +19 -0
  37. package/dist/hooks/tool-result-persist.d.ts.map +1 -0
  38. package/dist/hooks/tool-result-persist.js +62 -0
  39. package/dist/hooks/tool-result-persist.js.map +1 -0
  40. package/dist/index.d.ts +35 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +94 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/metrics/genai-metrics.d.ts +20 -0
  45. package/dist/metrics/genai-metrics.d.ts.map +1 -0
  46. package/dist/metrics/genai-metrics.js +56 -0
  47. package/dist/metrics/genai-metrics.js.map +1 -0
  48. package/dist/otel.d.ts +10 -0
  49. package/dist/otel.d.ts.map +1 -0
  50. package/dist/otel.js +70 -0
  51. package/dist/otel.js.map +1 -0
  52. package/dist/trace-link.d.ts +7 -0
  53. package/dist/trace-link.d.ts.map +1 -0
  54. package/dist/trace-link.js +14 -0
  55. package/dist/trace-link.js.map +1 -0
  56. package/dist/util.d.ts +38 -0
  57. package/dist/util.d.ts.map +1 -0
  58. package/dist/util.js +108 -0
  59. package/dist/util.js.map +1 -0
  60. package/openclaw.plugin.json +174 -0
  61. package/package.json +87 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;GAWG;AAWH;;;;GAIG;AACH,UAAU,SAAS;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,EAAE;QACN,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B,CAAC;IACF,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IACzD,eAAe,CAAC,OAAO,EAAE;QACvB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,IAAI,CAAC;QAClB,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAClC,GAAG,IAAI,CAAC;CACV;AAID,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CA6ErD"}
package/dist/index.js ADDED
@@ -0,0 +1,94 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * @ultrathink-solutions/openclaw-logfire
4
+ *
5
+ * Pydantic Logfire observability plugin for OpenClaw.
6
+ * OTEL GenAI semantic convention compliant.
7
+ *
8
+ * Minimal setup:
9
+ * 1. Set LOGFIRE_TOKEN env var
10
+ * 2. Add to openclaw.json:
11
+ * { "plugins": { "entries": { "logfire": { "enabled": true, "config": {} } } } }
12
+ * 3. Restart OpenClaw
13
+ */
14
+ import { resolveConfig } from './config.js';
15
+ import { initializeOtel } from './otel.js';
16
+ import { handleBeforeAgentStart } from './hooks/before-agent-start.js';
17
+ import { handleBeforeToolCall } from './hooks/before-tool-call.js';
18
+ import { handleToolResultPersist } from './hooks/tool-result-persist.js';
19
+ import { handleAgentEnd } from './hooks/agent-end.js';
20
+ import { handleMessageReceived } from './hooks/message-received.js';
21
+ let sdk = null;
22
+ export default function register(api) {
23
+ const config = resolveConfig(api.config);
24
+ // Validate token
25
+ if (!config.token) {
26
+ api.logger.error('Logfire plugin disabled: LOGFIRE_TOKEN not set. ' +
27
+ 'Export it as an env var or set plugins.entries.logfire.config.token');
28
+ return;
29
+ }
30
+ // Initialize OTEL SDK
31
+ try {
32
+ sdk = initializeOtel(config);
33
+ }
34
+ catch (err) {
35
+ api.logger.error(`Logfire plugin init failed: ${err}`);
36
+ return;
37
+ }
38
+ // Register lifecycle hooks
39
+ api.on('before_agent_start', ((event) => {
40
+ try {
41
+ handleBeforeAgentStart(event, config);
42
+ }
43
+ catch (err) {
44
+ api.logger.warn(`Logfire before_agent_start error: ${err}`);
45
+ }
46
+ }));
47
+ api.on('before_tool_call', ((event) => {
48
+ try {
49
+ handleBeforeToolCall(event, config);
50
+ }
51
+ catch (err) {
52
+ api.logger.warn(`Logfire before_tool_call error: ${err}`);
53
+ }
54
+ }));
55
+ api.on('tool_result_persist', ((event) => {
56
+ try {
57
+ handleToolResultPersist(event, config);
58
+ }
59
+ catch (err) {
60
+ api.logger.warn(`Logfire tool_result_persist error: ${err}`);
61
+ }
62
+ }));
63
+ api.on('agent_end', ((event) => {
64
+ try {
65
+ handleAgentEnd(event, config, api.logger);
66
+ }
67
+ catch (err) {
68
+ api.logger.warn(`Logfire agent_end error: ${err}`);
69
+ }
70
+ }));
71
+ api.on('message_received', ((event) => {
72
+ try {
73
+ handleMessageReceived(event, config);
74
+ }
75
+ catch (err) {
76
+ api.logger.warn(`Logfire message_received error: ${err}`);
77
+ }
78
+ }));
79
+ // Register service for clean shutdown
80
+ api.registerService({
81
+ id: 'logfire-otel',
82
+ start: () => {
83
+ const region = config.region === 'eu' ? 'EU' : 'US';
84
+ api.logger.info(`Logfire: exporting to ${region} (service: ${config.serviceName}, env: ${config.environment})`);
85
+ },
86
+ stop: async () => {
87
+ if (sdk) {
88
+ await sdk.shutdown();
89
+ api.logger.info('Logfire: OTEL SDK shut down');
90
+ }
91
+ },
92
+ });
93
+ }
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO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AAU,MAAM,CAAC,WAAW,GAAG,CAC/F,CAAC;QACJ,CAAC;QACD,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * OTEL GenAI semantic convention metrics.
3
+ *
4
+ * gen_ai.client.token.usage — Histogram of token counts
5
+ * gen_ai.client.operation.duration — Histogram of operation latency
6
+ *
7
+ * Bucket boundaries follow the spec recommendations.
8
+ */
9
+ export interface MetricAttributes {
10
+ agentName: string;
11
+ workspace: string;
12
+ providerName: string;
13
+ requestModel: string;
14
+ responseModel: string;
15
+ hasError: boolean;
16
+ errorType?: string;
17
+ }
18
+ export declare function recordTokenUsage(tokens: number, tokenType: 'input' | 'output', attrs: MetricAttributes): void;
19
+ export declare function recordOperationDuration(durationSeconds: number, attrs: MetricAttributes): void;
20
+ //# sourceMappingURL=genai-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genai-metrics.d.ts","sourceRoot":"","sources":["../../src/metrics/genai-metrics.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAiCH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,OAAO,GAAG,QAAQ,EAC7B,KAAK,EAAE,gBAAgB,GACtB,IAAI,CAUN;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,gBAAgB,GACtB,IAAI,CAYN"}
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * OTEL GenAI semantic convention metrics.
4
+ *
5
+ * gen_ai.client.token.usage — Histogram of token counts
6
+ * gen_ai.client.operation.duration — Histogram of operation latency
7
+ *
8
+ * Bucket boundaries follow the spec recommendations.
9
+ */
10
+ import { metrics } from '@opentelemetry/api';
11
+ const meter = metrics.getMeter('@ultrathink-solutions/openclaw-logfire', '0.1.0');
12
+ /** Spec bucket boundaries for token usage. */
13
+ const TOKEN_BUCKETS = [
14
+ 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304,
15
+ 16777216, 67108864,
16
+ ];
17
+ /** Spec bucket boundaries for operation duration (seconds). */
18
+ const DURATION_BUCKETS = [
19
+ 0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24, 20.48,
20
+ 40.96, 81.92,
21
+ ];
22
+ const tokenHistogram = meter.createHistogram('gen_ai.client.token.usage', {
23
+ description: 'Number of input and output tokens used',
24
+ unit: '{token}',
25
+ advice: { explicitBucketBoundaries: TOKEN_BUCKETS },
26
+ });
27
+ const durationHistogram = meter.createHistogram('gen_ai.client.operation.duration', {
28
+ description: 'GenAI operation duration',
29
+ unit: 's',
30
+ advice: { explicitBucketBoundaries: DURATION_BUCKETS },
31
+ });
32
+ export function recordTokenUsage(tokens, tokenType, attrs) {
33
+ tokenHistogram.record(tokens, {
34
+ 'gen_ai.operation.name': 'invoke_agent',
35
+ 'gen_ai.provider.name': attrs.providerName,
36
+ 'gen_ai.token.type': tokenType,
37
+ 'gen_ai.request.model': attrs.requestModel,
38
+ 'gen_ai.response.model': attrs.responseModel,
39
+ 'openclaw.agent_name': attrs.agentName,
40
+ 'openclaw.workspace': attrs.workspace,
41
+ });
42
+ }
43
+ export function recordOperationDuration(durationSeconds, attrs) {
44
+ durationHistogram.record(durationSeconds, {
45
+ 'gen_ai.operation.name': 'invoke_agent',
46
+ 'gen_ai.provider.name': attrs.providerName,
47
+ 'gen_ai.request.model': attrs.requestModel,
48
+ 'gen_ai.response.model': attrs.responseModel,
49
+ 'openclaw.agent_name': attrs.agentName,
50
+ 'openclaw.workspace': attrs.workspace,
51
+ ...(attrs.hasError && attrs.errorType
52
+ ? { 'error.type': attrs.errorType }
53
+ : {}),
54
+ });
55
+ }
56
+ //# sourceMappingURL=genai-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genai-metrics.js","sourceRoot":"","sources":["../../src/metrics/genai-metrics.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,wCAAwC,EAAE,OAAO,CAAC,CAAC;AAElF,8CAA8C;AAC9C,MAAM,aAAa,GAAG;IACpB,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACrE,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,+DAA+D;AAC/D,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK;IACxE,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,MAAM,cAAc,GAAG,KAAK,CAAC,eAAe,CAAC,2BAA2B,EAAE;IACxE,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,EAAE,wBAAwB,EAAE,aAAa,EAAE;CACpD,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,KAAK,CAAC,eAAe,CAC7C,kCAAkC,EAClC;IACE,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,EAAE,wBAAwB,EAAE,gBAAgB,EAAE;CACvD,CACF,CAAC;AAYF,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,SAA6B,EAC7B,KAAuB;IAEvB,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE;QAC5B,uBAAuB,EAAE,cAAc;QACvC,sBAAsB,EAAE,KAAK,CAAC,YAAY;QAC1C,mBAAmB,EAAE,SAAS;QAC9B,sBAAsB,EAAE,KAAK,CAAC,YAAY;QAC1C,uBAAuB,EAAE,KAAK,CAAC,aAAa;QAC5C,qBAAqB,EAAE,KAAK,CAAC,SAAS;QACtC,oBAAoB,EAAE,KAAK,CAAC,SAAS;KACtC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,eAAuB,EACvB,KAAuB;IAEvB,iBAAiB,CAAC,MAAM,CAAC,eAAe,EAAE;QACxC,uBAAuB,EAAE,cAAc;QACvC,sBAAsB,EAAE,KAAK,CAAC,YAAY;QAC1C,sBAAsB,EAAE,KAAK,CAAC,YAAY;QAC1C,uBAAuB,EAAE,KAAK,CAAC,aAAa;QAC5C,qBAAqB,EAAE,KAAK,CAAC,SAAS;QACtC,oBAAoB,EAAE,KAAK,CAAC,SAAS;QACrC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,SAAS;YACnC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,SAAS,EAAE;YACnC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC"}
package/dist/otel.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * OpenTelemetry SDK initialization targeting Logfire's OTLP endpoint.
3
+ *
4
+ * Logfire accepts traces and metrics over HTTP/protobuf (not gRPC).
5
+ * Authentication is a write token passed as the Authorization header.
6
+ */
7
+ import { NodeSDK } from '@opentelemetry/sdk-node';
8
+ import type { LogfirePluginConfig } from './config.js';
9
+ export declare function initializeOtel(config: LogfirePluginConfig): NodeSDK;
10
+ //# sourceMappingURL=otel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAalD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CA6DnE"}
package/dist/otel.js ADDED
@@ -0,0 +1,70 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * OpenTelemetry SDK initialization targeting Logfire's OTLP endpoint.
4
+ *
5
+ * Logfire accepts traces and metrics over HTTP/protobuf (not gRPC).
6
+ * Authentication is a write token passed as the Authorization header.
7
+ */
8
+ import { NodeSDK } from '@opentelemetry/sdk-node';
9
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
10
+ import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
11
+ import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
12
+ import { BatchSpanProcessor, SimpleSpanProcessor, } from '@opentelemetry/sdk-trace-base';
13
+ import { Resource } from '@opentelemetry/resources';
14
+ import { ATTR_SERVICE_NAME, SEMRESATTRS_DEPLOYMENT_ENVIRONMENT, } from '@opentelemetry/semantic-conventions';
15
+ const LOGFIRE_ENDPOINTS = {
16
+ us: 'https://logfire-us.pydantic.dev',
17
+ eu: 'https://logfire-eu.pydantic.dev',
18
+ };
19
+ export function initializeOtel(config) {
20
+ const token = config.token;
21
+ if (!token) {
22
+ throw new Error('@ultrathink-solutions/openclaw-logfire: LOGFIRE_TOKEN is required. ' +
23
+ 'Set it as an environment variable or in plugins.entries.logfire.config.token');
24
+ }
25
+ const baseEndpoint = LOGFIRE_ENDPOINTS[config.region] ?? LOGFIRE_ENDPOINTS.us;
26
+ const authHeaders = { Authorization: `Bearer ${token}` };
27
+ // Trace exporter
28
+ const traceExporter = new OTLPTraceExporter({
29
+ url: `${baseEndpoint}/v1/traces`,
30
+ headers: authHeaders,
31
+ });
32
+ // Resource attributes
33
+ const resourceAttrs = {
34
+ [ATTR_SERVICE_NAME]: config.serviceName,
35
+ [SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: config.environment,
36
+ ...config.resourceAttributes,
37
+ };
38
+ if (config.projectUrl) {
39
+ resourceAttrs['logfire.project_url'] = config.projectUrl;
40
+ }
41
+ const resource = new Resource(resourceAttrs);
42
+ // Span processor
43
+ const spanProcessor = config.spanProcessorType === 'simple'
44
+ ? new SimpleSpanProcessor(traceExporter)
45
+ : new BatchSpanProcessor(traceExporter, {
46
+ maxQueueSize: config.batchConfig.maxQueueSize,
47
+ maxExportBatchSize: config.batchConfig.maxExportBatchSize,
48
+ scheduledDelayMillis: config.batchConfig.scheduledDelayMs,
49
+ });
50
+ // SDK config
51
+ const sdkConfig = {
52
+ resource,
53
+ spanProcessors: [spanProcessor],
54
+ };
55
+ // Metrics exporter (optional)
56
+ if (config.enableMetrics) {
57
+ const metricExporter = new OTLPMetricExporter({
58
+ url: `${baseEndpoint}/v1/metrics`,
59
+ headers: authHeaders,
60
+ });
61
+ sdkConfig.metricReader = new PeriodicExportingMetricReader({
62
+ exporter: metricExporter,
63
+ exportIntervalMillis: config.metricsIntervalMs,
64
+ });
65
+ }
66
+ const sdk = new NodeSDK(sdkConfig);
67
+ sdk.start();
68
+ return sdk;
69
+ }
70
+ //# sourceMappingURL=otel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.js","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AA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IAC3D,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC;IAE7C,iBAAiB;IACjB,MAAM,aAAa,GACjB,MAAM,CAAC,iBAAiB,KAAK,QAAQ;QACnC,CAAC,CAAC,IAAI,mBAAmB,CAAC,aAAa,CAAC;QACxC,CAAC,CAAC,IAAI,kBAAkB,CAAC,aAAa,EAAE;YACpC,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,YAAY;YAC7C,kBAAkB,EAAE,MAAM,CAAC,WAAW,CAAC,kBAAkB;YACzD,oBAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,gBAAgB;SAC1D,CAAC,CAAC;IAET,aAAa;IACb,MAAM,SAAS,GAA6C;QAC1D,QAAQ;QACR,cAAc,EAAE,CAAC,aAAa,CAAC;KAChC,CAAC;IAEF,8BAA8B;IAC9B,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QACzB,MAAM,cAAc,GAAG,IAAI,kBAAkB,CAAC;YAC5C,GAAG,EAAE,GAAG,YAAY,aAAa;YACjC,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;QACH,SAAS,CAAC,YAAY,GAAG,IAAI,6BAA6B,CAAC;YACzD,QAAQ,EAAE,cAAc;YACxB,oBAAoB,EAAE,MAAM,CAAC,iBAAiB;SAC/C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IACnC,GAAG,CAAC,KAAK,EAAE,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Build clickable Logfire trace URLs.
3
+ *
4
+ * Format: {projectUrl}/explore?traceId={traceId}
5
+ */
6
+ export declare function buildLogfireTraceUrl(projectUrl: string, traceId: string, spanId?: string): string;
7
+ //# sourceMappingURL=trace-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-link.d.ts","sourceRoot":"","sources":["../src/trace-link.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAKR"}
@@ -0,0 +1,14 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Build clickable Logfire trace URLs.
4
+ *
5
+ * Format: {projectUrl}/explore?traceId={traceId}
6
+ */
7
+ export function buildLogfireTraceUrl(projectUrl, traceId, spanId) {
8
+ const base = projectUrl.replace(/\/$/, '');
9
+ const params = new URLSearchParams({ traceId });
10
+ if (spanId)
11
+ params.set('spanId', spanId);
12
+ return `${base}/explore?${params.toString()}`;
13
+ }
14
+ //# sourceMappingURL=trace-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-link.js","sourceRoot":"","sources":["../src/trace-link.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,OAAe,EACf,MAAe;IAEf,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAChD,IAAI,MAAM;QAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,GAAG,IAAI,YAAY,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AAChD,CAAC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Shared utilities: safe JSON serialization, truncation, secret redaction.
3
+ */
4
+ /**
5
+ * Serialize a value to JSON, handling circular refs and BigInts.
6
+ * Returns an empty string on failure rather than throwing.
7
+ */
8
+ export declare function safeJsonStringify(value: unknown): string;
9
+ /** Truncate a string to maxLength, appending "...[truncated]" if needed. */
10
+ export declare function truncate(value: string, maxLength: number): string;
11
+ /** Redact likely secrets from a string. */
12
+ export declare function redactSecrets(value: string): string;
13
+ /**
14
+ * Prepare a tool input/output value for recording as a span attribute.
15
+ * Serializes to JSON, optionally redacts secrets, and truncates.
16
+ */
17
+ export declare function prepareForCapture(value: unknown, maxLength: number, redact: boolean): string;
18
+ /**
19
+ * Extract workspace name from a workspace directory path.
20
+ * e.g., "/path/to/workspaces/chief-of-staff" -> "chief-of-staff"
21
+ */
22
+ export declare function extractWorkspaceName(workspaceDir: string | undefined): string;
23
+ /**
24
+ * Generate a short unique ID for tool call correlation.
25
+ * Uses timestamp + random suffix to avoid collisions without
26
+ * pulling in a uuid dependency.
27
+ */
28
+ export declare function generateCallId(): string;
29
+ /**
30
+ * Extract error details in a structured format suitable for OTEL
31
+ * exception semantic conventions.
32
+ */
33
+ export declare function extractErrorDetails(error: unknown): {
34
+ type: string;
35
+ message: string;
36
+ stacktrace: string;
37
+ };
38
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AACA;;GAEG;AASH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAcxD;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED,2CAA2C;AAC3C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAenD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,MAAM,CAMR;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI7E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAgBA"}
package/dist/util.js ADDED
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Shared utilities: safe JSON serialization, truncation, secret redaction.
4
+ */
5
+ /** Patterns that likely indicate secret values. */
6
+ const SECRET_PATTERNS = [
7
+ /(?:api[_-]?key|token|secret|password|auth|credential|bearer)\s*[:=]\s*["']?[^\s"',}{]{8,}/gi,
8
+ /(?:sk|pk|rk|pat|ghp|gho|glpat|xox[bpras])[_-][A-Za-z0-9_-]{10,}/g,
9
+ /eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g, // JWT
10
+ ];
11
+ /**
12
+ * Serialize a value to JSON, handling circular refs and BigInts.
13
+ * Returns an empty string on failure rather than throwing.
14
+ */
15
+ export function safeJsonStringify(value) {
16
+ const seen = new WeakSet();
17
+ try {
18
+ return JSON.stringify(value, (_key, val) => {
19
+ if (typeof val === 'bigint')
20
+ return val.toString();
21
+ if (typeof val === 'object' && val !== null) {
22
+ if (seen.has(val))
23
+ return '[Circular]';
24
+ seen.add(val);
25
+ }
26
+ return val;
27
+ });
28
+ }
29
+ catch {
30
+ return String(value);
31
+ }
32
+ }
33
+ /** Truncate a string to maxLength, appending "...[truncated]" if needed. */
34
+ export function truncate(value, maxLength) {
35
+ if (value.length <= maxLength)
36
+ return value;
37
+ return value.slice(0, maxLength) + '...[truncated]';
38
+ }
39
+ /** Redact likely secrets from a string. */
40
+ export function redactSecrets(value) {
41
+ let result = value;
42
+ for (const pattern of SECRET_PATTERNS) {
43
+ // Reset lastIndex for global regexes
44
+ pattern.lastIndex = 0;
45
+ result = result.replace(pattern, (match) => {
46
+ // Keep the key name, redact the value portion
47
+ const eqIdx = match.search(/[:=]/);
48
+ if (eqIdx !== -1) {
49
+ return match.slice(0, eqIdx + 1) + ' [REDACTED]';
50
+ }
51
+ return '[REDACTED]';
52
+ });
53
+ }
54
+ return result;
55
+ }
56
+ /**
57
+ * Prepare a tool input/output value for recording as a span attribute.
58
+ * Serializes to JSON, optionally redacts secrets, and truncates.
59
+ */
60
+ export function prepareForCapture(value, maxLength, redact) {
61
+ let str = typeof value === 'string' ? value : safeJsonStringify(value);
62
+ if (redact) {
63
+ str = redactSecrets(str);
64
+ }
65
+ return truncate(str, maxLength);
66
+ }
67
+ /**
68
+ * Extract workspace name from a workspace directory path.
69
+ * e.g., "/path/to/workspaces/chief-of-staff" -> "chief-of-staff"
70
+ */
71
+ export function extractWorkspaceName(workspaceDir) {
72
+ if (!workspaceDir)
73
+ return 'unknown';
74
+ const parts = workspaceDir.replace(/\/$/, '').split('/');
75
+ return parts[parts.length - 1] || 'unknown';
76
+ }
77
+ /**
78
+ * Generate a short unique ID for tool call correlation.
79
+ * Uses timestamp + random suffix to avoid collisions without
80
+ * pulling in a uuid dependency.
81
+ */
82
+ export function generateCallId() {
83
+ const ts = Date.now().toString(36);
84
+ const rand = Math.random().toString(36).slice(2, 8);
85
+ return `${ts}-${rand}`;
86
+ }
87
+ /**
88
+ * Extract error details in a structured format suitable for OTEL
89
+ * exception semantic conventions.
90
+ */
91
+ export function extractErrorDetails(error) {
92
+ if (error instanceof Error) {
93
+ return {
94
+ type: error.constructor.name || 'Error',
95
+ message: error.message,
96
+ stacktrace: error.stack ?? '',
97
+ };
98
+ }
99
+ if (typeof error === 'string') {
100
+ return { type: 'Error', message: error, stacktrace: '' };
101
+ }
102
+ return {
103
+ type: 'Error',
104
+ message: safeJsonStringify(error),
105
+ stacktrace: '',
106
+ };
107
+ }
108
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;GAEG;AAEH,mDAAmD;AAC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GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAKhD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,OAAO;YACvC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,UAAU,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;SAC9B,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO;QACL,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC;QACjC,UAAU,EAAE,EAAE;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,174 @@
1
+ {
2
+ "id": "logfire",
3
+ "kind": "observability",
4
+ "configSchema": {
5
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "token": {
10
+ "type": "string",
11
+ "description": "Logfire write token. Falls back to LOGFIRE_TOKEN env var."
12
+ },
13
+ "projectUrl": {
14
+ "type": "string",
15
+ "description": "Logfire project URL for clickable trace links."
16
+ },
17
+ "region": {
18
+ "type": "string",
19
+ "enum": ["us", "eu"],
20
+ "default": "us",
21
+ "description": "Logfire region (US or EU endpoint)."
22
+ },
23
+ "environment": {
24
+ "type": "string",
25
+ "default": "development",
26
+ "description": "Deployment environment label."
27
+ },
28
+ "serviceName": {
29
+ "type": "string",
30
+ "default": "openclaw-agent",
31
+ "description": "OTEL service name for resource identification."
32
+ },
33
+ "providerName": {
34
+ "type": "string",
35
+ "description": "GenAI provider name (e.g. 'anthropic', 'openai')."
36
+ },
37
+ "captureToolInput": {
38
+ "type": "boolean",
39
+ "default": true,
40
+ "description": "Record tool call arguments as span attributes."
41
+ },
42
+ "captureToolOutput": {
43
+ "type": "boolean",
44
+ "default": false,
45
+ "description": "Record tool results as span attributes (verbose)."
46
+ },
47
+ "toolInputMaxLength": {
48
+ "type": "integer",
49
+ "default": 2048,
50
+ "description": "Max character length for captured tool input."
51
+ },
52
+ "toolOutputMaxLength": {
53
+ "type": "integer",
54
+ "default": 512,
55
+ "description": "Max character length for captured tool output."
56
+ },
57
+ "captureStackTraces": {
58
+ "type": "boolean",
59
+ "default": true,
60
+ "description": "Include stack traces in error spans."
61
+ },
62
+ "captureMessageContent": {
63
+ "type": "boolean",
64
+ "default": false,
65
+ "description": "Record message text (privacy-sensitive)."
66
+ },
67
+ "captureToolDefinitions": {
68
+ "type": "boolean",
69
+ "default": false,
70
+ "description": "Record tool schemas in inference events."
71
+ },
72
+ "captureInferenceEvents": {
73
+ "type": "boolean",
74
+ "default": false,
75
+ "description": "Emit gen_ai.client.inference.operation.details events."
76
+ },
77
+ "redactSecrets": {
78
+ "type": "boolean",
79
+ "default": true,
80
+ "description": "Strip API keys, tokens, and JWTs from recorded data."
81
+ },
82
+ "distributedTracing": {
83
+ "type": "object",
84
+ "additionalProperties": false,
85
+ "properties": {
86
+ "enabled": {
87
+ "type": "boolean",
88
+ "default": false,
89
+ "description": "Enable W3C traceparent injection/extraction."
90
+ },
91
+ "injectIntoCommands": {
92
+ "type": "boolean",
93
+ "default": true,
94
+ "description": "Inject traceparent into curl/wget/httpie commands."
95
+ },
96
+ "extractFromWebhooks": {
97
+ "type": "boolean",
98
+ "default": true,
99
+ "description": "Extract traceparent from inbound webhook headers."
100
+ },
101
+ "urlPatterns": {
102
+ "type": "array",
103
+ "items": { "type": "string" },
104
+ "default": ["*"],
105
+ "description": "Glob patterns for URLs to inject traceparent into."
106
+ }
107
+ }
108
+ },
109
+ "enableMetrics": {
110
+ "type": "boolean",
111
+ "default": true,
112
+ "description": "Emit token usage and operation duration histograms."
113
+ },
114
+ "metricsIntervalMs": {
115
+ "type": "integer",
116
+ "default": 60000,
117
+ "description": "Metrics export interval in milliseconds."
118
+ },
119
+ "enableTraceLinks": {
120
+ "type": "boolean",
121
+ "default": true,
122
+ "description": "Log clickable Logfire trace URLs."
123
+ },
124
+ "logLevel": {
125
+ "type": "string",
126
+ "enum": ["debug", "info", "warn", "error"],
127
+ "default": "info",
128
+ "description": "Plugin log verbosity."
129
+ },
130
+ "resourceAttributes": {
131
+ "type": "object",
132
+ "additionalProperties": { "type": "string" },
133
+ "description": "Additional OTEL resource attributes."
134
+ },
135
+ "spanProcessorType": {
136
+ "type": "string",
137
+ "enum": ["batch", "simple"],
138
+ "default": "batch",
139
+ "description": "Span processor type. Use 'simple' for debugging."
140
+ },
141
+ "batchConfig": {
142
+ "type": "object",
143
+ "additionalProperties": false,
144
+ "properties": {
145
+ "maxQueueSize": { "type": "integer", "default": 2048 },
146
+ "maxExportBatchSize": { "type": "integer", "default": 512 },
147
+ "scheduledDelayMs": { "type": "integer", "default": 5000 }
148
+ }
149
+ }
150
+ }
151
+ },
152
+ "uiHints": {
153
+ "token": {
154
+ "label": "Write Token",
155
+ "placeholder": "Set via LOGFIRE_TOKEN env var",
156
+ "sensitive": true
157
+ },
158
+ "projectUrl": {
159
+ "label": "Project URL",
160
+ "placeholder": "https://logfire.pydantic.dev/org/project"
161
+ },
162
+ "region": {
163
+ "label": "Region"
164
+ },
165
+ "environment": {
166
+ "label": "Environment",
167
+ "placeholder": "production"
168
+ },
169
+ "serviceName": {
170
+ "label": "Service Name",
171
+ "placeholder": "openclaw-agent"
172
+ }
173
+ }
174
+ }