@compilr-dev/agents 0.0.1

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 (160) hide show
  1. package/README.md +1277 -0
  2. package/dist/agent.d.ts +1272 -0
  3. package/dist/agent.js +1912 -0
  4. package/dist/anchors/builtin.d.ts +24 -0
  5. package/dist/anchors/builtin.js +61 -0
  6. package/dist/anchors/index.d.ts +6 -0
  7. package/dist/anchors/index.js +5 -0
  8. package/dist/anchors/manager.d.ts +115 -0
  9. package/dist/anchors/manager.js +412 -0
  10. package/dist/anchors/types.d.ts +168 -0
  11. package/dist/anchors/types.js +10 -0
  12. package/dist/context/index.d.ts +12 -0
  13. package/dist/context/index.js +10 -0
  14. package/dist/context/manager.d.ts +224 -0
  15. package/dist/context/manager.js +770 -0
  16. package/dist/context/types.d.ts +377 -0
  17. package/dist/context/types.js +7 -0
  18. package/dist/costs/index.d.ts +8 -0
  19. package/dist/costs/index.js +7 -0
  20. package/dist/costs/tracker.d.ts +121 -0
  21. package/dist/costs/tracker.js +295 -0
  22. package/dist/costs/types.d.ts +157 -0
  23. package/dist/costs/types.js +8 -0
  24. package/dist/errors.d.ts +178 -0
  25. package/dist/errors.js +249 -0
  26. package/dist/guardrails/builtin.d.ts +27 -0
  27. package/dist/guardrails/builtin.js +223 -0
  28. package/dist/guardrails/index.d.ts +6 -0
  29. package/dist/guardrails/index.js +5 -0
  30. package/dist/guardrails/manager.d.ts +117 -0
  31. package/dist/guardrails/manager.js +288 -0
  32. package/dist/guardrails/types.d.ts +159 -0
  33. package/dist/guardrails/types.js +7 -0
  34. package/dist/hooks/index.d.ts +31 -0
  35. package/dist/hooks/index.js +29 -0
  36. package/dist/hooks/manager.d.ts +147 -0
  37. package/dist/hooks/manager.js +600 -0
  38. package/dist/hooks/types.d.ts +368 -0
  39. package/dist/hooks/types.js +12 -0
  40. package/dist/index.d.ts +45 -0
  41. package/dist/index.js +73 -0
  42. package/dist/mcp/client.d.ts +93 -0
  43. package/dist/mcp/client.js +287 -0
  44. package/dist/mcp/errors.d.ts +60 -0
  45. package/dist/mcp/errors.js +78 -0
  46. package/dist/mcp/index.d.ts +43 -0
  47. package/dist/mcp/index.js +45 -0
  48. package/dist/mcp/manager.d.ts +120 -0
  49. package/dist/mcp/manager.js +276 -0
  50. package/dist/mcp/tools.d.ts +54 -0
  51. package/dist/mcp/tools.js +99 -0
  52. package/dist/mcp/types.d.ts +150 -0
  53. package/dist/mcp/types.js +40 -0
  54. package/dist/memory/index.d.ts +8 -0
  55. package/dist/memory/index.js +7 -0
  56. package/dist/memory/loader.d.ts +114 -0
  57. package/dist/memory/loader.js +463 -0
  58. package/dist/memory/types.d.ts +182 -0
  59. package/dist/memory/types.js +8 -0
  60. package/dist/messages/index.d.ts +82 -0
  61. package/dist/messages/index.js +155 -0
  62. package/dist/permissions/index.d.ts +5 -0
  63. package/dist/permissions/index.js +4 -0
  64. package/dist/permissions/manager.d.ts +125 -0
  65. package/dist/permissions/manager.js +379 -0
  66. package/dist/permissions/types.d.ts +162 -0
  67. package/dist/permissions/types.js +7 -0
  68. package/dist/providers/claude.d.ts +90 -0
  69. package/dist/providers/claude.js +348 -0
  70. package/dist/providers/index.d.ts +8 -0
  71. package/dist/providers/index.js +11 -0
  72. package/dist/providers/mock.d.ts +133 -0
  73. package/dist/providers/mock.js +204 -0
  74. package/dist/providers/types.d.ts +168 -0
  75. package/dist/providers/types.js +4 -0
  76. package/dist/rate-limit/index.d.ts +45 -0
  77. package/dist/rate-limit/index.js +47 -0
  78. package/dist/rate-limit/limiter.d.ts +104 -0
  79. package/dist/rate-limit/limiter.js +326 -0
  80. package/dist/rate-limit/provider-wrapper.d.ts +112 -0
  81. package/dist/rate-limit/provider-wrapper.js +201 -0
  82. package/dist/rate-limit/retry.d.ts +108 -0
  83. package/dist/rate-limit/retry.js +287 -0
  84. package/dist/rate-limit/types.d.ts +181 -0
  85. package/dist/rate-limit/types.js +22 -0
  86. package/dist/rehearsal/file-analyzer.d.ts +22 -0
  87. package/dist/rehearsal/file-analyzer.js +351 -0
  88. package/dist/rehearsal/git-analyzer.d.ts +22 -0
  89. package/dist/rehearsal/git-analyzer.js +472 -0
  90. package/dist/rehearsal/index.d.ts +35 -0
  91. package/dist/rehearsal/index.js +36 -0
  92. package/dist/rehearsal/manager.d.ts +100 -0
  93. package/dist/rehearsal/manager.js +290 -0
  94. package/dist/rehearsal/types.d.ts +235 -0
  95. package/dist/rehearsal/types.js +8 -0
  96. package/dist/skills/index.d.ts +160 -0
  97. package/dist/skills/index.js +282 -0
  98. package/dist/state/agent-state.d.ts +41 -0
  99. package/dist/state/agent-state.js +88 -0
  100. package/dist/state/checkpointer.d.ts +110 -0
  101. package/dist/state/checkpointer.js +362 -0
  102. package/dist/state/errors.d.ts +66 -0
  103. package/dist/state/errors.js +88 -0
  104. package/dist/state/index.d.ts +35 -0
  105. package/dist/state/index.js +37 -0
  106. package/dist/state/serializer.d.ts +55 -0
  107. package/dist/state/serializer.js +172 -0
  108. package/dist/state/types.d.ts +312 -0
  109. package/dist/state/types.js +14 -0
  110. package/dist/tools/builtin/bash-output.d.ts +61 -0
  111. package/dist/tools/builtin/bash-output.js +90 -0
  112. package/dist/tools/builtin/bash.d.ts +150 -0
  113. package/dist/tools/builtin/bash.js +354 -0
  114. package/dist/tools/builtin/edit.d.ts +50 -0
  115. package/dist/tools/builtin/edit.js +215 -0
  116. package/dist/tools/builtin/glob.d.ts +62 -0
  117. package/dist/tools/builtin/glob.js +244 -0
  118. package/dist/tools/builtin/grep.d.ts +74 -0
  119. package/dist/tools/builtin/grep.js +363 -0
  120. package/dist/tools/builtin/index.d.ts +44 -0
  121. package/dist/tools/builtin/index.js +69 -0
  122. package/dist/tools/builtin/kill-shell.d.ts +44 -0
  123. package/dist/tools/builtin/kill-shell.js +80 -0
  124. package/dist/tools/builtin/read-file.d.ts +57 -0
  125. package/dist/tools/builtin/read-file.js +184 -0
  126. package/dist/tools/builtin/shell-manager.d.ts +176 -0
  127. package/dist/tools/builtin/shell-manager.js +337 -0
  128. package/dist/tools/builtin/task.d.ts +202 -0
  129. package/dist/tools/builtin/task.js +350 -0
  130. package/dist/tools/builtin/todo.d.ts +207 -0
  131. package/dist/tools/builtin/todo.js +453 -0
  132. package/dist/tools/builtin/utils.d.ts +27 -0
  133. package/dist/tools/builtin/utils.js +70 -0
  134. package/dist/tools/builtin/web-fetch.d.ts +96 -0
  135. package/dist/tools/builtin/web-fetch.js +290 -0
  136. package/dist/tools/builtin/write-file.d.ts +54 -0
  137. package/dist/tools/builtin/write-file.js +147 -0
  138. package/dist/tools/define.d.ts +60 -0
  139. package/dist/tools/define.js +65 -0
  140. package/dist/tools/index.d.ts +10 -0
  141. package/dist/tools/index.js +37 -0
  142. package/dist/tools/registry.d.ts +79 -0
  143. package/dist/tools/registry.js +151 -0
  144. package/dist/tools/types.d.ts +59 -0
  145. package/dist/tools/types.js +4 -0
  146. package/dist/tracing/hooks.d.ts +58 -0
  147. package/dist/tracing/hooks.js +377 -0
  148. package/dist/tracing/index.d.ts +51 -0
  149. package/dist/tracing/index.js +55 -0
  150. package/dist/tracing/logging.d.ts +78 -0
  151. package/dist/tracing/logging.js +310 -0
  152. package/dist/tracing/manager.d.ts +160 -0
  153. package/dist/tracing/manager.js +468 -0
  154. package/dist/tracing/otel.d.ts +102 -0
  155. package/dist/tracing/otel.js +246 -0
  156. package/dist/tracing/types.d.ts +346 -0
  157. package/dist/tracing/types.js +38 -0
  158. package/dist/utils/index.d.ts +23 -0
  159. package/dist/utils/index.js +44 -0
  160. package/package.json +79 -0
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Structured Logging Helpers
3
+ *
4
+ * Provides structured logging utilities for agent execution with:
5
+ * - JSON-formatted log output
6
+ * - Correlation IDs (trace, span, session)
7
+ * - Log levels
8
+ * - Child loggers with inherited context
9
+ */
10
+ /**
11
+ * Log level priorities (lower = more verbose)
12
+ */
13
+ const LOG_LEVEL_PRIORITY = {
14
+ debug: 0,
15
+ info: 1,
16
+ warn: 2,
17
+ error: 3,
18
+ };
19
+ /**
20
+ * Create a structured logger
21
+ *
22
+ * @param options - Logger options
23
+ * @returns StructuredLogger instance
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const logger = createStructuredLogger({
28
+ * level: 'info',
29
+ * serviceName: 'my-agent',
30
+ * prettyPrint: process.env.NODE_ENV !== 'production',
31
+ * });
32
+ *
33
+ * logger.info('Agent started', { version: '1.0.0' });
34
+ * logger.error('Tool failed', new Error('timeout'), { toolName: 'bash' });
35
+ *
36
+ * // Create child logger with context
37
+ * const sessionLogger = logger.child({ sessionId: 'abc123' });
38
+ * sessionLogger.info('Processing request'); // includes sessionId
39
+ * ```
40
+ */
41
+ export function createStructuredLogger(options = {}) {
42
+ const { level = 'info', serviceName = 'agent', prettyPrint = false, output = defaultOutput, context = {}, } = options;
43
+ const minLevel = LOG_LEVEL_PRIORITY[level];
44
+ // Correlation IDs
45
+ let traceId;
46
+ let spanId;
47
+ let sessionId;
48
+ function shouldLog(msgLevel) {
49
+ return LOG_LEVEL_PRIORITY[msgLevel] >= minLevel;
50
+ }
51
+ function createEntry(msgLevel, message, data, error) {
52
+ const entry = {
53
+ level: msgLevel,
54
+ message,
55
+ timestamp: new Date().toISOString(),
56
+ traceId,
57
+ spanId,
58
+ sessionId,
59
+ data: {
60
+ service: serviceName,
61
+ ...context,
62
+ ...data,
63
+ },
64
+ };
65
+ if (error) {
66
+ entry.error = {
67
+ name: error.name,
68
+ message: error.message,
69
+ stack: error.stack,
70
+ };
71
+ }
72
+ // Remove undefined values
73
+ if (!entry.traceId)
74
+ delete entry.traceId;
75
+ if (!entry.spanId)
76
+ delete entry.spanId;
77
+ if (!entry.sessionId)
78
+ delete entry.sessionId;
79
+ return entry;
80
+ }
81
+ function log(entry) {
82
+ if (prettyPrint) {
83
+ output(formatPretty(entry));
84
+ }
85
+ else {
86
+ output(entry);
87
+ }
88
+ }
89
+ const logger = {
90
+ debug(message, data) {
91
+ if (shouldLog('debug')) {
92
+ log(createEntry('debug', message, data));
93
+ }
94
+ },
95
+ info(message, data) {
96
+ if (shouldLog('info')) {
97
+ log(createEntry('info', message, data));
98
+ }
99
+ },
100
+ warn(message, data) {
101
+ if (shouldLog('warn')) {
102
+ log(createEntry('warn', message, data));
103
+ }
104
+ },
105
+ error(message, error, data) {
106
+ if (shouldLog('error')) {
107
+ log(createEntry('error', message, data, error));
108
+ }
109
+ },
110
+ child(childContext) {
111
+ return createStructuredLogger({
112
+ level,
113
+ serviceName,
114
+ prettyPrint,
115
+ output,
116
+ context: { ...context, ...childContext },
117
+ });
118
+ },
119
+ setCorrelation(newTraceId, newSpanId, newSessionId) {
120
+ traceId = newTraceId;
121
+ spanId = newSpanId;
122
+ sessionId = newSessionId;
123
+ },
124
+ };
125
+ return logger;
126
+ }
127
+ /**
128
+ * Default output function - writes to console with appropriate method
129
+ */
130
+ function defaultOutput(entry) {
131
+ const json = JSON.stringify(entry);
132
+ /* eslint-disable no-console */
133
+ switch (entry.level) {
134
+ case 'debug':
135
+ console.debug(json);
136
+ break;
137
+ case 'info':
138
+ console.info(json);
139
+ break;
140
+ case 'warn':
141
+ console.warn(json);
142
+ break;
143
+ case 'error':
144
+ console.error(json);
145
+ break;
146
+ }
147
+ /* eslint-enable no-console */
148
+ }
149
+ /**
150
+ * Format a log entry for pretty printing
151
+ */
152
+ function formatPretty(entry) {
153
+ const levelColors = {
154
+ debug: '\x1b[90m', // Gray
155
+ info: '\x1b[36m', // Cyan
156
+ warn: '\x1b[33m', // Yellow
157
+ error: '\x1b[31m', // Red
158
+ };
159
+ const reset = '\x1b[0m';
160
+ const color = levelColors[entry.level];
161
+ const levelStr = entry.level.toUpperCase().padEnd(5);
162
+ let line = `${color}${levelStr}${reset} ${entry.timestamp} ${entry.message}`;
163
+ // Add correlation IDs if present
164
+ const ids = [];
165
+ if (entry.traceId)
166
+ ids.push(`trace=${entry.traceId.slice(0, 8)}`);
167
+ if (entry.spanId)
168
+ ids.push(`span=${entry.spanId.slice(0, 8)}`);
169
+ if (entry.sessionId)
170
+ ids.push(`session=${entry.sessionId.slice(0, 8)}`);
171
+ if (ids.length > 0) {
172
+ line += ` [${ids.join(' ')}]`;
173
+ }
174
+ // Add data if present
175
+ if (entry.data && Object.keys(entry.data).length > 0) {
176
+ line += '\n ' + JSON.stringify(entry.data);
177
+ }
178
+ // Add error if present
179
+ if (entry.error) {
180
+ line += `\n ${color}Error: ${entry.error.name}: ${entry.error.message}${reset}`;
181
+ if (entry.error.stack) {
182
+ line += '\n ' + entry.error.stack.split('\n').slice(1).join('\n ');
183
+ }
184
+ }
185
+ // Return modified entry with formatted message for pretty output
186
+ return {
187
+ ...entry,
188
+ message: line,
189
+ };
190
+ }
191
+ /**
192
+ * Create a no-op logger (useful for testing or disabling logs)
193
+ */
194
+ export function createNoopLogger() {
195
+ const noop = () => { };
196
+ return {
197
+ debug: noop,
198
+ info: noop,
199
+ warn: noop,
200
+ error: noop,
201
+ child: () => createNoopLogger(),
202
+ setCorrelation: noop,
203
+ };
204
+ }
205
+ /**
206
+ * Create a logger that buffers entries (useful for testing)
207
+ */
208
+ export function createBufferedLogger() {
209
+ const entries = [];
210
+ const logger = createStructuredLogger({
211
+ level: 'debug',
212
+ output: (entry) => entries.push(entry),
213
+ });
214
+ return {
215
+ ...logger,
216
+ entries,
217
+ clear: () => {
218
+ entries.length = 0;
219
+ },
220
+ };
221
+ }
222
+ /**
223
+ * Format duration in human-readable format
224
+ */
225
+ export function formatDuration(ms) {
226
+ if (ms < 1000)
227
+ return `${String(ms)}ms`;
228
+ if (ms < 60000)
229
+ return `${(ms / 1000).toFixed(2)}s`;
230
+ const minutes = Math.floor(ms / 60000);
231
+ const seconds = ((ms % 60000) / 1000).toFixed(0);
232
+ return `${String(minutes)}m ${seconds}s`;
233
+ }
234
+ /**
235
+ * Format bytes in human-readable format
236
+ */
237
+ export function formatBytes(bytes) {
238
+ if (bytes < 1024)
239
+ return `${String(bytes)}B`;
240
+ if (bytes < 1024 * 1024)
241
+ return `${(bytes / 1024).toFixed(2)}KB`;
242
+ if (bytes < 1024 * 1024 * 1024)
243
+ return `${(bytes / (1024 * 1024)).toFixed(2)}MB`;
244
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)}GB`;
245
+ }
246
+ /**
247
+ * Redact sensitive data from an object
248
+ */
249
+ export function redactSensitive(data, sensitiveKeys = ['password', 'token', 'secret', 'apiKey', 'api_key', 'authorization']) {
250
+ const result = {};
251
+ for (const [key, value] of Object.entries(data)) {
252
+ const lowerKey = key.toLowerCase();
253
+ const isSensitive = sensitiveKeys.some((k) => lowerKey.includes(k.toLowerCase()));
254
+ if (isSensitive) {
255
+ result[key] = '[REDACTED]';
256
+ }
257
+ else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
258
+ result[key] = redactSensitive(value, sensitiveKeys);
259
+ }
260
+ else {
261
+ result[key] = value;
262
+ }
263
+ }
264
+ return result;
265
+ }
266
+ /**
267
+ * Create a logger that integrates with TracingManager
268
+ *
269
+ * @param tracingManager - TracingManager instance
270
+ * @param options - Logger options
271
+ * @returns StructuredLogger that auto-correlates with traces
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * const tracingManager = new TracingManager({ serviceName: 'my-agent' });
276
+ * const logger = createTracingLogger(tracingManager);
277
+ *
278
+ * // Logger automatically includes current trace/span IDs
279
+ * logger.info('Processing request');
280
+ * ```
281
+ */
282
+ export function createTracingLogger(tracingManager, options = {}) {
283
+ const baseLogger = createStructuredLogger(options);
284
+ const setCorrelationFromSpan = () => {
285
+ const span = tracingManager.getCurrentSpan();
286
+ if (span) {
287
+ baseLogger.setCorrelation(span.traceId, span.spanId);
288
+ }
289
+ };
290
+ return {
291
+ debug(message, data) {
292
+ setCorrelationFromSpan();
293
+ baseLogger.debug(message, data);
294
+ },
295
+ info(message, data) {
296
+ setCorrelationFromSpan();
297
+ baseLogger.info(message, data);
298
+ },
299
+ warn(message, data) {
300
+ setCorrelationFromSpan();
301
+ baseLogger.warn(message, data);
302
+ },
303
+ error(message, error, data) {
304
+ setCorrelationFromSpan();
305
+ baseLogger.error(message, error, data);
306
+ },
307
+ child: baseLogger.child.bind(baseLogger),
308
+ setCorrelation: baseLogger.setCorrelation.bind(baseLogger),
309
+ };
310
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * TracingManager - Manages distributed tracing for agent execution
3
+ *
4
+ * Provides:
5
+ * - Trace and span management with correlation IDs
6
+ * - OpenTelemetry-compatible span structure
7
+ * - Event emission for observability integrations
8
+ * - Optional export to OTel backends
9
+ */
10
+ import type { Span, SpanAttributes, SpanContext, SpanStatus, Trace, TracingManagerOptions, StartSpanOptions, EndSpanOptions, TracingEventHandler, TracingManagerInterface } from './types.js';
11
+ /**
12
+ * Manages distributed tracing for agent operations
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const tracing = new TracingManager({
17
+ * serviceName: 'my-agent',
18
+ * defaultAttributes: { environment: 'production' },
19
+ * });
20
+ *
21
+ * // Start a trace
22
+ * const traceId = tracing.startTrace();
23
+ *
24
+ * // Create spans
25
+ * const span = tracing.startSpan({ name: 'process-request' });
26
+ * span.attributes['request.id'] = '123';
27
+ *
28
+ * // End span and trace
29
+ * tracing.endSpan(span.spanId, { status: 'ok' });
30
+ * const trace = tracing.endTrace(traceId);
31
+ * ```
32
+ */
33
+ export declare class TracingManager implements TracingManagerInterface {
34
+ private readonly serviceName;
35
+ private readonly serviceVersion;
36
+ private readonly defaultAttributes;
37
+ private readonly maxSpansPerTrace;
38
+ private readonly autoGenerateTraceId;
39
+ private readonly traces;
40
+ private readonly spans;
41
+ private readonly activeSpanStack;
42
+ private readonly eventHandlers;
43
+ private readonly otelExporter?;
44
+ private spanIdCounter;
45
+ private traceIdCounter;
46
+ constructor(options?: TracingManagerOptions);
47
+ /**
48
+ * Start a new trace
49
+ *
50
+ * @param attributes - Additional trace-level attributes
51
+ * @returns Trace ID
52
+ */
53
+ startTrace(attributes?: SpanAttributes): string;
54
+ /**
55
+ * End a trace and optionally export it
56
+ *
57
+ * @param traceId - Trace ID to end
58
+ * @returns Completed trace or undefined if not found
59
+ */
60
+ endTrace(traceId: string): Trace | undefined;
61
+ /**
62
+ * Get a trace by ID
63
+ */
64
+ getTrace(traceId: string): Trace | undefined;
65
+ /**
66
+ * Get all active traces
67
+ */
68
+ getActiveTraces(): Trace[];
69
+ /**
70
+ * Clear a trace from memory
71
+ */
72
+ clearTrace(traceId: string): boolean;
73
+ /**
74
+ * Start a new span
75
+ *
76
+ * @param options - Span options
77
+ * @returns Created span
78
+ */
79
+ startSpan(options: StartSpanOptions): Span;
80
+ /**
81
+ * End a span
82
+ *
83
+ * @param spanId - Span ID to end
84
+ * @param options - End options
85
+ * @returns Ended span or undefined if not found
86
+ */
87
+ endSpan(spanId: string, options?: EndSpanOptions): Span | undefined;
88
+ /**
89
+ * Get a span by ID
90
+ */
91
+ getSpan(spanId: string): Span | undefined;
92
+ /**
93
+ * Get the current active span
94
+ */
95
+ getCurrentSpan(): Span | undefined;
96
+ /**
97
+ * Get current span context for propagation
98
+ */
99
+ getCurrentContext(): SpanContext | undefined;
100
+ /**
101
+ * Add an event to a span
102
+ *
103
+ * @param spanId - Span ID
104
+ * @param name - Event name
105
+ * @param attributes - Event attributes
106
+ */
107
+ addSpanEvent(spanId: string, name: string, attributes?: SpanAttributes): void;
108
+ /**
109
+ * Set attributes on a span
110
+ *
111
+ * @param spanId - Span ID
112
+ * @param attributes - Attributes to set
113
+ */
114
+ setSpanAttributes(spanId: string, attributes: SpanAttributes): void;
115
+ /**
116
+ * Set span status
117
+ *
118
+ * @param spanId - Span ID
119
+ * @param status - Status
120
+ * @param message - Optional status message
121
+ */
122
+ setSpanStatus(spanId: string, status: SpanStatus, message?: string): void;
123
+ /**
124
+ * Record an error on a span
125
+ *
126
+ * @param spanId - Span ID
127
+ * @param error - Error to record
128
+ */
129
+ recordError(spanId: string, error: Error): void;
130
+ /**
131
+ * Subscribe to tracing events
132
+ *
133
+ * @param handler - Event handler
134
+ * @returns Unsubscribe function
135
+ */
136
+ onEvent(handler: TracingEventHandler): () => void;
137
+ private emit;
138
+ /**
139
+ * Export a trace to configured exporter
140
+ */
141
+ private exportTrace;
142
+ /**
143
+ * Manually export a trace
144
+ */
145
+ export(traceId: string): Promise<void>;
146
+ private generateTraceId;
147
+ private generateSpanId;
148
+ /**
149
+ * Get tracing statistics
150
+ */
151
+ getStats(): {
152
+ activeTraces: number;
153
+ totalSpans: number;
154
+ activeSpans: number;
155
+ };
156
+ /**
157
+ * Clear all traces and spans
158
+ */
159
+ clear(): void;
160
+ }