@agentuity/telemetry 3.0.0-beta.0 → 3.0.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/telemetry",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-beta.2",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Agentuity employees and contributors",
6
6
  "type": "module",
@@ -23,8 +23,8 @@
23
23
  "prepublishOnly": "bun run clean && bun run build"
24
24
  },
25
25
  "dependencies": {
26
- "@agentuity/core": "3.0.0-beta.0",
27
- "@agentuity/server": "3.0.0-beta.0",
26
+ "@agentuity/core": "3.0.0-beta.2",
27
+ "@agentuity/server": "3.0.0-beta.2",
28
28
  "@opentelemetry/api": "^1.9.0",
29
29
  "@opentelemetry/api-logs": "^0.207.0",
30
30
  "@opentelemetry/auto-instrumentations-node": "^0.66.0",
@@ -36,32 +36,27 @@ This decouples the application from the OTLP endpoint and provides resilience.
36
36
 
37
37
  ## Configuration
38
38
 
39
- ### Enabling JSONL Exporters
39
+ `@agentuity/telemetry` auto-initializes from environment variables when imported. The JSONL exporters kick in whenever `AGENTUITY_CLOUD_EXPORT_DIR` (or the `jsonlBasePath` config option) is set; otherwise telemetry goes straight to the OTLP endpoint.
40
40
 
41
- By default, JSONL exporters are enabled. You can configure them via the `OtelConfig`:
41
+ ### Auto-initialized (recommended)
42
42
 
43
43
  ```typescript
44
- import { registerOtel } from '@agentuity/runtime/otel';
45
-
46
- registerOtel({
47
- name: 'my-app',
48
- version: '1.0.0',
49
- url: 'https://otel.example.com',
50
- useJsonlExporter: true, // Enable JSONL exporters (default: true)
51
- jsonlBasePath: './.agentuity/otel-data', // Directory for JSONL files
52
- });
44
+ // Setting AGENTUITY_CLOUD_EXPORT_DIR enables the JSONL exporters automatically.
45
+ // AGENTUITY_APP_NAME, AGENTUITY_APP_VERSION, AGENTUITY_REGION, etc. are picked
46
+ // up from the environment at import time.
47
+ import '@agentuity/telemetry';
53
48
  ```
54
49
 
55
- ### Disabling JSONL Exporters
56
-
57
- To use the original OTLP exporters (direct network calls):
50
+ ### Manual configuration
58
51
 
59
52
  ```typescript
60
- registerOtel({
53
+ import { registerTelemetry } from '@agentuity/telemetry';
54
+
55
+ registerTelemetry({
61
56
  name: 'my-app',
62
57
  version: '1.0.0',
63
58
  url: 'https://otel.example.com',
64
- useJsonlExporter: false, // Disable JSONL, use OTLP directly
59
+ jsonlBasePath: './.agentuity/otel-data', // omit to send via OTLP directly
65
60
  });
66
61
  ```
67
62
 
@@ -1,4 +0,0 @@
1
- export { internal } from './internal';
2
- export type { Logger } from '@agentuity/core';
3
- export { logger } from './user';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,3 +0,0 @@
1
- export { internal } from './internal';
2
- export { logger } from './user';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,79 +0,0 @@
1
- /**
2
- * Log levels for internal SDK logging
3
- */
4
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
5
- /**
6
- * Internal logger configuration
7
- */
8
- interface InternalLoggerConfig {
9
- level: LogLevel;
10
- context?: Record<string, unknown>;
11
- }
12
- /**
13
- * Simple internal logger that doesn't depend on other SDK modules
14
- * This logger is only for SDK internal diagnostics and debugging
15
- */
16
- declare class InternalLogger {
17
- private config;
18
- constructor();
19
- /**
20
- * Load configuration from environment variables
21
- */
22
- private loadConfig;
23
- /**
24
- * Check if a log level should be output based on current configuration
25
- */
26
- private shouldLog;
27
- /**
28
- * Format a log message with context
29
- */
30
- private formatMessage;
31
- /**
32
- * Log a debug message
33
- */
34
- debug(message: unknown, ...args: unknown[]): void;
35
- /**
36
- * Log an info message
37
- */
38
- info(message: unknown, ...args: unknown[]): void;
39
- /**
40
- * Log a warning message
41
- */
42
- warn(message: unknown, ...args: unknown[]): void;
43
- /**
44
- * Log an error message
45
- */
46
- error(message: unknown, ...args: unknown[]): void;
47
- /**
48
- * Update configuration at runtime
49
- */
50
- updateConfig(config: Partial<InternalLoggerConfig>): void;
51
- /**
52
- * Get current configuration
53
- */
54
- getConfig(): InternalLoggerConfig;
55
- /**
56
- * Check if logging is enabled
57
- */
58
- isEnabled(): boolean;
59
- /**
60
- * Create a child logger with additional context
61
- */
62
- child(context: Record<string, unknown>): InternalLogger;
63
- }
64
- /**
65
- * Internal logger for SDK use only
66
- * This is NOT exported from the main SDK index
67
- */
68
- export declare const internal: {
69
- debug: (message: unknown, ...args: unknown[]) => void;
70
- info: (message: unknown, ...args: unknown[]) => void;
71
- warn: (message: unknown, ...args: unknown[]) => void;
72
- error: (message: unknown, ...args: unknown[]) => void;
73
- updateConfig: (config: Partial<InternalLoggerConfig>) => void;
74
- getConfig: () => InternalLoggerConfig;
75
- isEnabled: () => boolean;
76
- child: (context: Record<string, unknown>) => InternalLogger;
77
- };
78
- export {};
79
- //# sourceMappingURL=internal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/logger/internal.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE;;GAEG;AACH,UAAU,oBAAoB;IAC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an = '\x1b[1;96m';
3
- const reset = '\x1b[0m';
4
- /**
5
- * Simple internal logger that doesn't depend on other SDK modules
6
- * This logger is only for SDK internal diagnostics and debugging
7
- */
8
- class InternalLogger {
9
- config;
10
- constructor() {
11
- this.config = this.loadConfig();
12
- }
13
- /**
14
- * Load configuration from environment variables
15
- */
16
- loadConfig() {
17
- const envLevel = process.env.AGENTUITY_SDK_LOG_LEVEL?.toLowerCase();
18
- // Validate log level
19
- const validLevels = ['debug', 'info', 'warn', 'error', 'silent'];
20
- const level = validLevels.includes(envLevel) ? envLevel : 'silent';
21
- return {
22
- level,
23
- context: {
24
- '@agentuity/source': 'sdk-internal',
25
- '@agentuity/timestamp': new Date().toISOString(),
26
- },
27
- };
28
- }
29
- /**
30
- * Check if a log level should be output based on current configuration
31
- */
32
- shouldLog(level) {
33
- if (this.config.level === 'silent')
34
- return false;
35
- const levelPriority = {
36
- debug: 0,
37
- info: 1,
38
- warn: 2,
39
- error: 3,
40
- silent: 4,
41
- };
42
- return levelPriority[level] >= levelPriority[this.config.level];
43
- }
44
- /**
45
- * Format a log message with context
46
- */
47
- formatMessage(message, ...args) {
48
- const formattedMessage = formatMessage(false, this.config.context, message, args);
49
- return `${cyan}[INTERNAL]${reset} ${formattedMessage}`;
50
- }
51
- /**
52
- * Log a debug message
53
- */
54
- debug(message, ...args) {
55
- if (this.shouldLog('debug')) {
56
- console.debug(this.formatMessage(message, ...args));
57
- }
58
- }
59
- /**
60
- * Log an info message
61
- */
62
- info(message, ...args) {
63
- if (this.shouldLog('info')) {
64
- console.info(this.formatMessage(message, ...args));
65
- }
66
- }
67
- /**
68
- * Log a warning message
69
- */
70
- warn(message, ...args) {
71
- if (this.shouldLog('warn')) {
72
- console.warn(this.formatMessage(message, ...args));
73
- }
74
- }
75
- /**
76
- * Log an error message
77
- */
78
- error(message, ...args) {
79
- if (this.shouldLog('error')) {
80
- console.error(this.formatMessage(message, ...args));
81
- }
82
- }
83
- /**
84
- * Update configuration at runtime
85
- */
86
- updateConfig(config) {
87
- this.config = { ...this.config, ...config };
88
- }
89
- /**
90
- * Get current configuration
91
- */
92
- getConfig() {
93
- return { ...this.config };
94
- }
95
- /**
96
- * Check if logging is enabled
97
- */
98
- isEnabled() {
99
- return this.config.level !== 'silent';
100
- }
101
- /**
102
- * Create a child logger with additional context
103
- */
104
- child(context) {
105
- const childLogger = new InternalLogger();
106
- childLogger.updateConfig({
107
- ...this.config,
108
- context: {
109
- ...this.config.context,
110
- ...context,
111
- },
112
- });
113
- return childLogger;
114
- }
115
- }
116
- // Singleton instance - not exported
117
- const internalLogger = new InternalLogger();
118
- /**
119
- * Internal logger for SDK use only
120
- * This is NOT exported from the main SDK index
121
- */
122
- export const internal = {
123
- debug: (message, ...args) => internalLogger.debug(message, ...args),
124
- info: (message, ...args) => internalLogger.info(message, ...args),
125
- warn: (message, ...args) => internalLogger.warn(message, ...args),
126
- error: (message, ...args) => internalLogger.error(message, ...args),
127
- // Utility methods
128
- updateConfig: (config) => internalLogger.updateConfig(config),
129
- getConfig: () => internalLogger.getConfig(),
130
- isEnabled: () => internalLogger.isEnabled(),
131
- child: (context) => internalLogger.child(context),
132
- };
133
- //# sourceMappingURL=internal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/logger/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,IAAI,GAAG,YAAY,CAAC;AAC1B,MAAM,KAAK,GAAG,SAAS,CAAC;AAexB;;;GAGG;AACH,MAAM,cAAc;IACX,MAAM,CAAuB;IAErC;QACC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACK,UAAU;QACjB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,WAAW,EAAE,CAAC;QAEpE,qBAAqB;QACrB,MAAM,WAAW,GAAe,CAAC,OAAO,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,OAAO,WAAW,CAAC;IACpB,CAAC;CACD;AAED,oCAAoC;AACpC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,KAAK,EAAE,CAAC,OAAgB,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IACvF,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IACrF,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IACrF,KAAK,EAAE,CAAC,OAAgB,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAEvF,kBAAkB;IAClB,YAAY,EAAE,CAAC,MAAqC,EAAE,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC;IAC5F,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE;IAC3C,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE;IAC3C,KAAK,EAAE,CAAC,OAAgC,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC;CAC1E,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { Logger } from '@agentuity/core';
2
- /**
3
- * User-facing logger instance
4
- * This is the logger that SDK consumers should use
5
- */
6
- export declare const logger: Logger;
7
- export type { Logger } from '@agentuity/core';
8
- //# sourceMappingURL=user.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/logger/user.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,MAIpB,CAAC;AAGF,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,7 +0,0 @@
1
- import { createLogger } from '@agentuity/server';
2
- /**
3
- * User-facing logger instance
4
- * This is the logger that SDK consumers should use
5
- */
6
- export const logger = createLogger((process.env.AGENTUITY_LOG_LEVEL || 'info'), false, (process.env.COLOR_SCHEME ?? 'dark'));
7
- //# sourceMappingURL=user.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/logger/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnE;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAW,YAAY,CACzC,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,MAAM,CAAa,EACvD,KAAK,EACL,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,MAAM,CAAgB,CACnD,CAAC"}
@@ -1,3 +0,0 @@
1
- export { internal } from './internal';
2
- export type { Logger } from '@agentuity/core';
3
- export { logger } from './user';
@@ -1,165 +0,0 @@
1
- import { formatMessage } from './util';
2
-
3
- const cyan = '\x1b[1;96m';
4
- const reset = '\x1b[0m';
5
-
6
- /**
7
- * Log levels for internal SDK logging
8
- */
9
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
10
-
11
- /**
12
- * Internal logger configuration
13
- */
14
- interface InternalLoggerConfig {
15
- level: LogLevel;
16
- context?: Record<string, unknown>;
17
- }
18
-
19
- /**
20
- * Simple internal logger that doesn't depend on other SDK modules
21
- * This logger is only for SDK internal diagnostics and debugging
22
- */
23
- class InternalLogger {
24
- private config: InternalLoggerConfig;
25
-
26
- constructor() {
27
- this.config = this.loadConfig();
28
- }
29
-
30
- /**
31
- * Load configuration from environment variables
32
- */
33
- private loadConfig(): InternalLoggerConfig {
34
- const envLevel = process.env.AGENTUITY_SDK_LOG_LEVEL?.toLowerCase();
35
-
36
- // Validate log level
37
- const validLevels: LogLevel[] = ['debug', 'info', 'warn', 'error', 'silent'];
38
- const level = validLevels.includes(envLevel as LogLevel) ? (envLevel as LogLevel) : 'silent';
39
-
40
- return {
41
- level,
42
- context: {
43
- '@agentuity/source': 'sdk-internal',
44
- '@agentuity/timestamp': new Date().toISOString(),
45
- },
46
- };
47
- }
48
-
49
- /**
50
- * Check if a log level should be output based on current configuration
51
- */
52
- private shouldLog(level: LogLevel): boolean {
53
- if (this.config.level === 'silent') return false;
54
-
55
- const levelPriority = {
56
- debug: 0,
57
- info: 1,
58
- warn: 2,
59
- error: 3,
60
- silent: 4,
61
- };
62
-
63
- return levelPriority[level] >= levelPriority[this.config.level];
64
- }
65
-
66
- /**
67
- * Format a log message with context
68
- */
69
- private formatMessage(message: unknown, ...args: unknown[]): string {
70
- const formattedMessage = formatMessage(false, this.config.context, message, args);
71
- return `${cyan}[INTERNAL]${reset} ${formattedMessage}`;
72
- }
73
-
74
- /**
75
- * Log a debug message
76
- */
77
- debug(message: unknown, ...args: unknown[]): void {
78
- if (this.shouldLog('debug')) {
79
- console.debug(this.formatMessage(message, ...args));
80
- }
81
- }
82
-
83
- /**
84
- * Log an info message
85
- */
86
- info(message: unknown, ...args: unknown[]): void {
87
- if (this.shouldLog('info')) {
88
- console.info(this.formatMessage(message, ...args));
89
- }
90
- }
91
-
92
- /**
93
- * Log a warning message
94
- */
95
- warn(message: unknown, ...args: unknown[]): void {
96
- if (this.shouldLog('warn')) {
97
- console.warn(this.formatMessage(message, ...args));
98
- }
99
- }
100
-
101
- /**
102
- * Log an error message
103
- */
104
- error(message: unknown, ...args: unknown[]): void {
105
- if (this.shouldLog('error')) {
106
- console.error(this.formatMessage(message, ...args));
107
- }
108
- }
109
-
110
- /**
111
- * Update configuration at runtime
112
- */
113
- updateConfig(config: Partial<InternalLoggerConfig>): void {
114
- this.config = { ...this.config, ...config };
115
- }
116
-
117
- /**
118
- * Get current configuration
119
- */
120
- getConfig(): InternalLoggerConfig {
121
- return { ...this.config };
122
- }
123
-
124
- /**
125
- * Check if logging is enabled
126
- */
127
- isEnabled(): boolean {
128
- return this.config.level !== 'silent';
129
- }
130
-
131
- /**
132
- * Create a child logger with additional context
133
- */
134
- child(context: Record<string, unknown>): InternalLogger {
135
- const childLogger = new InternalLogger();
136
- childLogger.updateConfig({
137
- ...this.config,
138
- context: {
139
- ...this.config.context,
140
- ...context,
141
- },
142
- });
143
- return childLogger;
144
- }
145
- }
146
-
147
- // Singleton instance - not exported
148
- const internalLogger = new InternalLogger();
149
-
150
- /**
151
- * Internal logger for SDK use only
152
- * This is NOT exported from the main SDK index
153
- */
154
- export const internal = {
155
- debug: (message: unknown, ...args: unknown[]) => internalLogger.debug(message, ...args),
156
- info: (message: unknown, ...args: unknown[]) => internalLogger.info(message, ...args),
157
- warn: (message: unknown, ...args: unknown[]) => internalLogger.warn(message, ...args),
158
- error: (message: unknown, ...args: unknown[]) => internalLogger.error(message, ...args),
159
-
160
- // Utility methods
161
- updateConfig: (config: Partial<InternalLoggerConfig>) => internalLogger.updateConfig(config),
162
- getConfig: () => internalLogger.getConfig(),
163
- isEnabled: () => internalLogger.isEnabled(),
164
- child: (context: Record<string, unknown>) => internalLogger.child(context),
165
- };
@@ -1,15 +0,0 @@
1
- import { type ColorScheme, createLogger } from '@agentuity/server';
2
- import type { LogLevel, Logger } from '@agentuity/core';
3
-
4
- /**
5
- * User-facing logger instance
6
- * This is the logger that SDK consumers should use
7
- */
8
- export const logger: Logger = createLogger(
9
- (process.env.AGENTUITY_LOG_LEVEL || 'info') as LogLevel,
10
- false,
11
- (process.env.COLOR_SCHEME ?? 'dark') as ColorScheme
12
- );
13
-
14
- // Re-export the Logger type for convenience
15
- export type { Logger } from '@agentuity/core';