libretto 0.2.6 → 0.2.7

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.
@@ -168,8 +168,27 @@ class Logger {
168
168
  options
169
169
  });
170
170
  }
171
- info(event, data, options) {
172
- this.entry({ level: "info", event, data, options });
171
+ info(event, dataOrError, options) {
172
+ const data = dataOrError instanceof Error ? {
173
+ error: {
174
+ type: dataOrError.constructor.name,
175
+ message: dataOrError.message,
176
+ stack: dataOrError.stack || null
177
+ }
178
+ } : isObject(dataOrError) && dataOrError.error instanceof Error ? {
179
+ ...dataOrError,
180
+ error: {
181
+ type: dataOrError.error.constructor.name,
182
+ message: dataOrError.error.message,
183
+ stack: dataOrError.error.stack || null
184
+ }
185
+ } : isObject(dataOrError) ? dataOrError : dataOrError !== void 0 ? { error: dataOrError } : void 0;
186
+ this.entry({
187
+ level: "info",
188
+ event,
189
+ data,
190
+ options
191
+ });
173
192
  }
174
193
  withScope(scope, context = {}) {
175
194
  return new Logger([...this.scopes, scope], this.sinks, {
@@ -7,7 +7,7 @@ type LogOptions = {
7
7
  * implement withScope, withContext, flush, etc.
8
8
  */
9
9
  type MinimalLogger = {
10
- info: (event: string, data?: Record<string, any>) => void;
10
+ info: (event: string, data?: any) => void;
11
11
  warn: (event: string, data?: any) => void;
12
12
  error: (event: string, data?: any) => any;
13
13
  };
@@ -26,7 +26,9 @@ type LoggerApi = {
26
26
  warn: (event: string, data?: Error | ({
27
27
  error: Error;
28
28
  } & Record<string, any>) | unknown, options?: LogOptions) => void;
29
- info: (event: string, data?: Record<string, any>, options?: LogOptions) => void;
29
+ info: (event: string, data?: Error | ({
30
+ error: Error;
31
+ } & Record<string, any>) | unknown, options?: LogOptions) => void;
30
32
  /**
31
33
  * Context passed in will be attached to all entries in this scope.
32
34
  */
@@ -71,7 +73,9 @@ declare class Logger implements LoggerApi {
71
73
  warn(event: string, dataOrError?: Error | ({
72
74
  error: Error;
73
75
  } & Record<string, any>) | unknown, options?: LogOptions): void;
74
- info(event: string, data?: Record<string, any>, options?: LogOptions): void;
76
+ info(event: string, dataOrError?: Error | ({
77
+ error: Error;
78
+ } & Record<string, any>) | unknown, options?: LogOptions): void;
75
79
  withScope(scope: string, context?: Record<string, any>): LoggerApi;
76
80
  withContext(context: Record<string, any>): LoggerApi;
77
81
  withSink(sink: LoggerSink): Logger;
@@ -7,7 +7,7 @@ type LogOptions = {
7
7
  * implement withScope, withContext, flush, etc.
8
8
  */
9
9
  type MinimalLogger = {
10
- info: (event: string, data?: Record<string, any>) => void;
10
+ info: (event: string, data?: any) => void;
11
11
  warn: (event: string, data?: any) => void;
12
12
  error: (event: string, data?: any) => any;
13
13
  };
@@ -26,7 +26,9 @@ type LoggerApi = {
26
26
  warn: (event: string, data?: Error | ({
27
27
  error: Error;
28
28
  } & Record<string, any>) | unknown, options?: LogOptions) => void;
29
- info: (event: string, data?: Record<string, any>, options?: LogOptions) => void;
29
+ info: (event: string, data?: Error | ({
30
+ error: Error;
31
+ } & Record<string, any>) | unknown, options?: LogOptions) => void;
30
32
  /**
31
33
  * Context passed in will be attached to all entries in this scope.
32
34
  */
@@ -71,7 +73,9 @@ declare class Logger implements LoggerApi {
71
73
  warn(event: string, dataOrError?: Error | ({
72
74
  error: Error;
73
75
  } & Record<string, any>) | unknown, options?: LogOptions): void;
74
- info(event: string, data?: Record<string, any>, options?: LogOptions): void;
76
+ info(event: string, dataOrError?: Error | ({
77
+ error: Error;
78
+ } & Record<string, any>) | unknown, options?: LogOptions): void;
75
79
  withScope(scope: string, context?: Record<string, any>): LoggerApi;
76
80
  withContext(context: Record<string, any>): LoggerApi;
77
81
  withSink(sink: LoggerSink): Logger;
@@ -144,8 +144,27 @@ class Logger {
144
144
  options
145
145
  });
146
146
  }
147
- info(event, data, options) {
148
- this.entry({ level: "info", event, data, options });
147
+ info(event, dataOrError, options) {
148
+ const data = dataOrError instanceof Error ? {
149
+ error: {
150
+ type: dataOrError.constructor.name,
151
+ message: dataOrError.message,
152
+ stack: dataOrError.stack || null
153
+ }
154
+ } : isObject(dataOrError) && dataOrError.error instanceof Error ? {
155
+ ...dataOrError,
156
+ error: {
157
+ type: dataOrError.error.constructor.name,
158
+ message: dataOrError.error.message,
159
+ stack: dataOrError.error.stack || null
160
+ }
161
+ } : isObject(dataOrError) ? dataOrError : dataOrError !== void 0 ? { error: dataOrError } : void 0;
162
+ this.entry({
163
+ level: "info",
164
+ event,
165
+ data,
166
+ options
167
+ });
149
168
  }
150
169
  withScope(scope, context = {}) {
151
170
  return new Logger([...this.scopes, scope], this.sinks, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libretto",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "AI-powered browser automation library and CLI built on Playwright",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -105,15 +105,9 @@
105
105
  "zod": ">=3.0.0"
106
106
  },
107
107
  "peerDependenciesMeta": {
108
- "@ai-sdk/anthropic": {
109
- "optional": true
110
- },
111
- "@ai-sdk/google-vertex": {
112
- "optional": true
113
- },
114
- "@ai-sdk/openai": {
115
- "optional": true
116
- }
108
+ "@ai-sdk/anthropic": { "optional": true },
109
+ "@ai-sdk/google-vertex": { "optional": true },
110
+ "@ai-sdk/openai": { "optional": true }
117
111
  },
118
112
  "devDependencies": {
119
113
  "@ai-sdk/anthropic": "^3.0.53",