@towles/tool 0.0.120 → 0.0.121
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/node_modules/@towles/shared/package.json +15 -0
- package/node_modules/@towles/shared/src/date-utils.test.ts +97 -0
- package/node_modules/@towles/shared/src/date-utils.ts +54 -0
- package/node_modules/@towles/shared/src/fs.ts +19 -0
- package/node_modules/@towles/shared/src/git/branch-name.test.ts +83 -0
- package/node_modules/@towles/shared/src/git/branch-name.ts +10 -0
- package/node_modules/@towles/shared/src/git/exec.ts +41 -0
- package/node_modules/@towles/shared/src/git/gh-cli-wrapper.test.ts +55 -0
- package/node_modules/@towles/shared/src/git/gh-cli-wrapper.ts +74 -0
- package/node_modules/@towles/shared/src/index.ts +8 -0
- package/node_modules/@towles/shared/src/render.test.ts +71 -0
- package/node_modules/@towles/shared/src/render.ts +36 -0
- package/package.json +4 -1
- package/packages/agentboard/apps/tui/src/components/DetailPanel.tsx +62 -1
- package/packages/agentboard/packages/runtime/package.json +1 -0
- package/packages/agentboard/packages/runtime/src/agents/watchers/claude-code.test.ts +38 -1
- package/packages/agentboard/packages/runtime/src/agents/watchers/claude-code.ts +106 -31
- package/packages/agentboard/packages/runtime/src/agents/watchers/claude-pid.test.ts +74 -0
- package/packages/agentboard/packages/runtime/src/agents/watchers/claude-pid.ts +57 -0
- package/packages/agentboard/packages/runtime/src/agents/watchers/claude-usage.test.ts +148 -0
- package/packages/agentboard/packages/runtime/src/agents/watchers/claude-usage.ts +78 -0
- package/packages/agentboard/packages/runtime/src/contracts/agent.ts +17 -0
- package/packages/agentboard/packages/runtime/src/server/pane-scanner.ts +10 -4
- package/packages/shared/node_modules/consola/LICENSE +47 -0
- package/packages/shared/node_modules/consola/README.md +352 -0
- package/packages/shared/node_modules/consola/basic.d.ts +1 -0
- package/packages/shared/node_modules/consola/browser.d.ts +1 -0
- package/packages/shared/node_modules/consola/core.d.ts +1 -0
- package/packages/shared/node_modules/consola/dist/basic.cjs +32 -0
- package/packages/shared/node_modules/consola/dist/basic.d.cts +23 -0
- package/packages/shared/node_modules/consola/dist/basic.d.mts +21 -0
- package/packages/shared/node_modules/consola/dist/basic.d.ts +23 -0
- package/packages/shared/node_modules/consola/dist/basic.mjs +24 -0
- package/packages/shared/node_modules/consola/dist/browser.cjs +84 -0
- package/packages/shared/node_modules/consola/dist/browser.d.cts +23 -0
- package/packages/shared/node_modules/consola/dist/browser.d.mts +21 -0
- package/packages/shared/node_modules/consola/dist/browser.d.ts +23 -0
- package/packages/shared/node_modules/consola/dist/browser.mjs +76 -0
- package/packages/shared/node_modules/consola/dist/chunks/prompt.cjs +288 -0
- package/packages/shared/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/packages/shared/node_modules/consola/dist/core.cjs +517 -0
- package/packages/shared/node_modules/consola/dist/core.d.cts +459 -0
- package/packages/shared/node_modules/consola/dist/core.d.mts +459 -0
- package/packages/shared/node_modules/consola/dist/core.d.ts +459 -0
- package/packages/shared/node_modules/consola/dist/core.mjs +512 -0
- package/packages/shared/node_modules/consola/dist/index.cjs +663 -0
- package/packages/shared/node_modules/consola/dist/index.d.cts +24 -0
- package/packages/shared/node_modules/consola/dist/index.d.mts +22 -0
- package/packages/shared/node_modules/consola/dist/index.d.ts +24 -0
- package/packages/shared/node_modules/consola/dist/index.mjs +651 -0
- package/packages/shared/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +75 -0
- package/packages/shared/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/packages/shared/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/packages/shared/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +312 -0
- package/packages/shared/node_modules/consola/dist/utils.cjs +64 -0
- package/packages/shared/node_modules/consola/dist/utils.d.cts +286 -0
- package/packages/shared/node_modules/consola/dist/utils.d.mts +286 -0
- package/packages/shared/node_modules/consola/dist/utils.d.ts +286 -0
- package/packages/shared/node_modules/consola/dist/utils.mjs +54 -0
- package/packages/shared/node_modules/consola/lib/index.cjs +10 -0
- package/packages/shared/node_modules/consola/package.json +136 -0
- package/packages/shared/node_modules/consola/utils.d.ts +1 -0
- package/packages/shared/tsconfig.json +0 -16
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
type SelectOption = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const kCancel: unique symbol;
|
|
7
|
+
type PromptCommonOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Specify how to handle a cancelled prompt (e.g. by pressing Ctrl+C).
|
|
10
|
+
*
|
|
11
|
+
* Default strategy is `"default"`.
|
|
12
|
+
*
|
|
13
|
+
* - `"default"` - Resolve the promise with the `default` value or `initial` value.
|
|
14
|
+
* - `"undefined`" - Resolve the promise with `undefined`.
|
|
15
|
+
* - `"null"` - Resolve the promise with `null`.
|
|
16
|
+
* - `"symbol"` - Resolve the promise with a symbol `Symbol.for("cancel")`.
|
|
17
|
+
* - `"reject"` - Reject the promise with an error.
|
|
18
|
+
*/
|
|
19
|
+
cancel?: "reject" | "default" | "undefined" | "null" | "symbol";
|
|
20
|
+
};
|
|
21
|
+
type TextPromptOptions = PromptCommonOptions & {
|
|
22
|
+
/**
|
|
23
|
+
* Specifies the prompt type as text.
|
|
24
|
+
* @optional
|
|
25
|
+
* @default "text"
|
|
26
|
+
*/
|
|
27
|
+
type?: "text";
|
|
28
|
+
/**
|
|
29
|
+
* The default text value.
|
|
30
|
+
* @optional
|
|
31
|
+
*/
|
|
32
|
+
default?: string;
|
|
33
|
+
/**
|
|
34
|
+
* A placeholder text displayed in the prompt.
|
|
35
|
+
* @optional
|
|
36
|
+
*/
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The initial text value.
|
|
40
|
+
* @optional
|
|
41
|
+
*/
|
|
42
|
+
initial?: string;
|
|
43
|
+
};
|
|
44
|
+
type ConfirmPromptOptions = PromptCommonOptions & {
|
|
45
|
+
/**
|
|
46
|
+
* Specifies the prompt type as confirm.
|
|
47
|
+
*/
|
|
48
|
+
type: "confirm";
|
|
49
|
+
/**
|
|
50
|
+
* The initial value for the confirm prompt.
|
|
51
|
+
* @optional
|
|
52
|
+
*/
|
|
53
|
+
initial?: boolean;
|
|
54
|
+
};
|
|
55
|
+
type SelectPromptOptions = PromptCommonOptions & {
|
|
56
|
+
/**
|
|
57
|
+
* Specifies the prompt type as select.
|
|
58
|
+
*/
|
|
59
|
+
type: "select";
|
|
60
|
+
/**
|
|
61
|
+
* The initial value for the select prompt.
|
|
62
|
+
* @optional
|
|
63
|
+
*/
|
|
64
|
+
initial?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The options to select from. See {@link SelectOption}.
|
|
67
|
+
*/
|
|
68
|
+
options: (string | SelectOption)[];
|
|
69
|
+
};
|
|
70
|
+
type MultiSelectOptions = PromptCommonOptions & {
|
|
71
|
+
/**
|
|
72
|
+
* Specifies the prompt type as multiselect.
|
|
73
|
+
*/
|
|
74
|
+
type: "multiselect";
|
|
75
|
+
/**
|
|
76
|
+
* The options to select from. See {@link SelectOption}.
|
|
77
|
+
*/
|
|
78
|
+
initial?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* The options to select from. See {@link SelectOption}.
|
|
81
|
+
*/
|
|
82
|
+
options: (string | SelectOption)[];
|
|
83
|
+
/**
|
|
84
|
+
* Whether the prompt requires at least one selection.
|
|
85
|
+
*/
|
|
86
|
+
required?: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Defines a combined type for all prompt options.
|
|
90
|
+
*/
|
|
91
|
+
type PromptOptions = TextPromptOptions | ConfirmPromptOptions | SelectPromptOptions | MultiSelectOptions;
|
|
92
|
+
type inferPromptReturnType<T extends PromptOptions> = T extends TextPromptOptions ? string : T extends ConfirmPromptOptions ? boolean : T extends SelectPromptOptions ? T["options"][number] extends SelectOption ? T["options"][number]["value"] : T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown;
|
|
93
|
+
type inferPromptCancalReturnType<T extends PromptOptions> = T extends {
|
|
94
|
+
cancel: "reject";
|
|
95
|
+
} ? never : T extends {
|
|
96
|
+
cancel: "default";
|
|
97
|
+
} ? inferPromptReturnType<T> : T extends {
|
|
98
|
+
cancel: "undefined";
|
|
99
|
+
} ? undefined : T extends {
|
|
100
|
+
cancel: "null";
|
|
101
|
+
} ? null : T extends {
|
|
102
|
+
cancel: "symbol";
|
|
103
|
+
} ? typeof kCancel : inferPromptReturnType<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Asynchronously prompts the user for input based on specified options.
|
|
106
|
+
* Supports text, confirm, select and multi-select prompts.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} message - The message to display in the prompt.
|
|
109
|
+
* @param {PromptOptions} [opts={}] - The prompt options. See {@link PromptOptions}.
|
|
110
|
+
* @returns {Promise<inferPromptReturnType<T>>} - A promise that resolves with the user's response, the type of which is inferred from the options. See {@link inferPromptReturnType}.
|
|
111
|
+
*/
|
|
112
|
+
declare function prompt<_ = any, __ = any, T extends PromptOptions = TextPromptOptions>(message: string, opts?: PromptOptions): Promise<inferPromptReturnType<T> | inferPromptCancalReturnType<T>>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Defines the level of logs as specific numbers or special number types.
|
|
116
|
+
*
|
|
117
|
+
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevel - Represents the log level.
|
|
118
|
+
* @default 0 - Represents the default log level.
|
|
119
|
+
*/
|
|
120
|
+
type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
|
121
|
+
/**
|
|
122
|
+
* A mapping of `LogType` to its corresponding numeric log level.
|
|
123
|
+
*
|
|
124
|
+
* @type {Record<LogType, number>} LogLevels - key-value pairs of log types to their numeric levels. See {@link LogType}.
|
|
125
|
+
*/
|
|
126
|
+
declare const LogLevels: Record<LogType, number>;
|
|
127
|
+
/**
|
|
128
|
+
* Lists the types of log messages supported by the system.
|
|
129
|
+
*
|
|
130
|
+
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogType - Represents the specific type of log message.
|
|
131
|
+
*/
|
|
132
|
+
type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
|
133
|
+
/**
|
|
134
|
+
* Maps `LogType` to a `Partial<LogObject>`, primarily defining the log level.
|
|
135
|
+
*
|
|
136
|
+
* @type {Record<LogType, Partial<LogObject>>} LogTypes - key-value pairs of log types to partial log objects, specifying log levels. See {@link LogType} and {@link LogObject}.
|
|
137
|
+
*/
|
|
138
|
+
declare const LogTypes: Record<LogType, Partial<LogObject>>;
|
|
139
|
+
|
|
140
|
+
interface ConsolaOptions {
|
|
141
|
+
/**
|
|
142
|
+
* An array of ConsolaReporter instances used to handle and output log messages.
|
|
143
|
+
*/
|
|
144
|
+
reporters: ConsolaReporter[];
|
|
145
|
+
/**
|
|
146
|
+
* A record mapping LogType to InputLogObject, defining the log configuration for each log type.
|
|
147
|
+
* See {@link LogType} and {@link InputLogObject}.
|
|
148
|
+
*/
|
|
149
|
+
types: Record<LogType, InputLogObject>;
|
|
150
|
+
/**
|
|
151
|
+
* The minimum log level to output. See {@link LogLevel}.
|
|
152
|
+
*/
|
|
153
|
+
level: LogLevel;
|
|
154
|
+
/**
|
|
155
|
+
* Default properties applied to all log messages unless overridden. See {@link InputLogObject}.
|
|
156
|
+
*/
|
|
157
|
+
defaults: InputLogObject;
|
|
158
|
+
/**
|
|
159
|
+
* The maximum number of times a log message can be repeated within a given timeframe.
|
|
160
|
+
*/
|
|
161
|
+
throttle: number;
|
|
162
|
+
/**
|
|
163
|
+
* The minimum time in milliseconds that must elapse before a throttled log message can be logged again.
|
|
164
|
+
*/
|
|
165
|
+
throttleMin: number;
|
|
166
|
+
/**
|
|
167
|
+
* The Node.js writable stream for standard output. See {@link NodeJS.WriteStream}.
|
|
168
|
+
* @optional
|
|
169
|
+
*/
|
|
170
|
+
stdout?: NodeJS.WriteStream;
|
|
171
|
+
/**
|
|
172
|
+
* The Node.js writeable stream for standard error output. See {@link NodeJS.WriteStream}.
|
|
173
|
+
* @optional
|
|
174
|
+
*/
|
|
175
|
+
stderr?: NodeJS.WriteStream;
|
|
176
|
+
/**
|
|
177
|
+
* A function that allows you to mock log messages for testing purposes.
|
|
178
|
+
* @optional
|
|
179
|
+
*/
|
|
180
|
+
mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
|
|
181
|
+
/**
|
|
182
|
+
* Custom prompt function to use. It can be undefined.
|
|
183
|
+
* @optional
|
|
184
|
+
*/
|
|
185
|
+
prompt?: typeof prompt | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Configuration options for formatting log messages. See {@link FormatOptions}.
|
|
188
|
+
*/
|
|
189
|
+
formatOptions: FormatOptions;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
|
|
193
|
+
*/
|
|
194
|
+
interface FormatOptions {
|
|
195
|
+
/**
|
|
196
|
+
* The maximum number of columns to output, affects formatting.
|
|
197
|
+
* @optional
|
|
198
|
+
*/
|
|
199
|
+
columns?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Whether to include timestamp information in log messages.
|
|
202
|
+
* @optional
|
|
203
|
+
*/
|
|
204
|
+
date?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Whether to use colors in the output.
|
|
207
|
+
* @optional
|
|
208
|
+
*/
|
|
209
|
+
colors?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Specifies whether or not the output should be compact. Accepts a boolean or numeric level of compactness.
|
|
212
|
+
* @optional
|
|
213
|
+
*/
|
|
214
|
+
compact?: boolean | number;
|
|
215
|
+
/**
|
|
216
|
+
* Error cause level.
|
|
217
|
+
*/
|
|
218
|
+
errorLevel?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Allows additional custom formatting options.
|
|
221
|
+
*/
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
}
|
|
224
|
+
interface InputLogObject {
|
|
225
|
+
/**
|
|
226
|
+
* The logging level of the message. See {@link LogLevel}.
|
|
227
|
+
* @optional
|
|
228
|
+
*/
|
|
229
|
+
level?: LogLevel;
|
|
230
|
+
/**
|
|
231
|
+
* A string tag to categorise or identify the log message.
|
|
232
|
+
* @optional
|
|
233
|
+
*/
|
|
234
|
+
tag?: string;
|
|
235
|
+
/**
|
|
236
|
+
* The type of log message, which affects how it's processed and displayed. See {@link LogType}.
|
|
237
|
+
* @optional
|
|
238
|
+
*/
|
|
239
|
+
type?: LogType;
|
|
240
|
+
/**
|
|
241
|
+
* The main log message text.
|
|
242
|
+
* @optional
|
|
243
|
+
*/
|
|
244
|
+
message?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Additional text or texts to be logged with the message.
|
|
247
|
+
* @optional
|
|
248
|
+
*/
|
|
249
|
+
additional?: string | string[];
|
|
250
|
+
/**
|
|
251
|
+
* Additional arguments to be logged with the message.
|
|
252
|
+
* @optional
|
|
253
|
+
*/
|
|
254
|
+
args?: any[];
|
|
255
|
+
/**
|
|
256
|
+
* The date and time when the log message was created.
|
|
257
|
+
* @optional
|
|
258
|
+
*/
|
|
259
|
+
date?: Date;
|
|
260
|
+
}
|
|
261
|
+
interface LogObject extends InputLogObject {
|
|
262
|
+
/**
|
|
263
|
+
* The logging level of the message, overridden if required. See {@link LogLevel}.
|
|
264
|
+
*/
|
|
265
|
+
level: LogLevel;
|
|
266
|
+
/**
|
|
267
|
+
* The type of log message, overridden if required. See {@link LogType}.
|
|
268
|
+
*/
|
|
269
|
+
type: LogType;
|
|
270
|
+
/**
|
|
271
|
+
* A string tag to categorise or identify the log message, overridden if necessary.
|
|
272
|
+
*/
|
|
273
|
+
tag: string;
|
|
274
|
+
/**
|
|
275
|
+
* Additional arguments to be logged with the message, overridden if necessary.
|
|
276
|
+
*/
|
|
277
|
+
args: any[];
|
|
278
|
+
/**
|
|
279
|
+
* The date and time the log message was created, overridden if necessary.
|
|
280
|
+
*/
|
|
281
|
+
date: Date;
|
|
282
|
+
/**
|
|
283
|
+
* Allows additional custom properties to be set on the log object.
|
|
284
|
+
*/
|
|
285
|
+
[key: string]: unknown;
|
|
286
|
+
}
|
|
287
|
+
interface ConsolaReporter {
|
|
288
|
+
/**
|
|
289
|
+
* Defines how a log message is processed and displayed by this reporter.
|
|
290
|
+
* @param logObj The LogObject containing the log information to process. See {@link LogObject}.
|
|
291
|
+
* @param ctx An object containing context information such as options. See {@link ConsolaOptions}.
|
|
292
|
+
*/
|
|
293
|
+
log: (logObj: LogObject, ctx: {
|
|
294
|
+
options: ConsolaOptions;
|
|
295
|
+
}) => void;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Consola class for logging management with support for pause/resume, mocking and customisable reporting.
|
|
300
|
+
* Provides flexible logging capabilities including level-based logging, custom reporters and integration options.
|
|
301
|
+
*
|
|
302
|
+
* @class Consola
|
|
303
|
+
*/
|
|
304
|
+
declare class Consola {
|
|
305
|
+
options: ConsolaOptions;
|
|
306
|
+
_lastLog: {
|
|
307
|
+
serialized?: string;
|
|
308
|
+
object?: LogObject;
|
|
309
|
+
count?: number;
|
|
310
|
+
time?: Date;
|
|
311
|
+
timeout?: ReturnType<typeof setTimeout>;
|
|
312
|
+
};
|
|
313
|
+
_mockFn?: ConsolaOptions["mockFn"];
|
|
314
|
+
/**
|
|
315
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
316
|
+
*
|
|
317
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
318
|
+
*/
|
|
319
|
+
constructor(options?: Partial<ConsolaOptions>);
|
|
320
|
+
/**
|
|
321
|
+
* Gets the current log level of the Consola instance.
|
|
322
|
+
*
|
|
323
|
+
* @returns {number} The current log level.
|
|
324
|
+
*/
|
|
325
|
+
get level(): LogLevel;
|
|
326
|
+
/**
|
|
327
|
+
* Sets the minimum log level that will be output by the instance.
|
|
328
|
+
*
|
|
329
|
+
* @param {number} level - The new log level to set.
|
|
330
|
+
*/
|
|
331
|
+
set level(level: LogLevel);
|
|
332
|
+
/**
|
|
333
|
+
* Displays a prompt to the user and returns the response.
|
|
334
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
335
|
+
*
|
|
336
|
+
* @template T
|
|
337
|
+
* @param {string} message - The message to display in the prompt.
|
|
338
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
339
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
340
|
+
*/
|
|
341
|
+
prompt<T extends PromptOptions>(message: string, opts?: T): Promise<(T extends TextPromptOptions ? string : T extends ConfirmPromptOptions ? boolean : T extends SelectPromptOptions ? T["options"][number] extends {
|
|
342
|
+
label: string;
|
|
343
|
+
value: string;
|
|
344
|
+
hint?: string;
|
|
345
|
+
} ? T["options"][number]["value"] : T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown) | (T extends {
|
|
346
|
+
cancel: "reject";
|
|
347
|
+
} ? never : T extends {
|
|
348
|
+
cancel: "default";
|
|
349
|
+
} ? T extends infer T_1 ? T_1 extends T ? T_1 extends TextPromptOptions ? string : T_1 extends ConfirmPromptOptions ? boolean : T_1 extends SelectPromptOptions ? T_1["options"][number] extends {
|
|
350
|
+
label: string;
|
|
351
|
+
value: string;
|
|
352
|
+
hint?: string;
|
|
353
|
+
} ? T_1["options"][number]["value"] : T_1["options"][number] : T_1 extends MultiSelectOptions ? T_1["options"] : unknown : never : never : T extends {
|
|
354
|
+
cancel: "undefined";
|
|
355
|
+
} ? undefined : T extends {
|
|
356
|
+
cancel: "null";
|
|
357
|
+
} ? null : T extends {
|
|
358
|
+
cancel: "symbol";
|
|
359
|
+
} ? typeof kCancel : T extends TextPromptOptions ? string : T extends ConfirmPromptOptions ? boolean : T extends SelectPromptOptions ? T["options"][number] extends {
|
|
360
|
+
label: string;
|
|
361
|
+
value: string;
|
|
362
|
+
hint?: string;
|
|
363
|
+
} ? T["options"][number]["value"] : T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown)>;
|
|
364
|
+
/**
|
|
365
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
366
|
+
*
|
|
367
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
368
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
369
|
+
*/
|
|
370
|
+
create(options: Partial<ConsolaOptions>): ConsolaInstance;
|
|
371
|
+
/**
|
|
372
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
373
|
+
*
|
|
374
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
375
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
376
|
+
*/
|
|
377
|
+
withDefaults(defaults: InputLogObject): ConsolaInstance;
|
|
378
|
+
/**
|
|
379
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
380
|
+
*
|
|
381
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
382
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
383
|
+
*/
|
|
384
|
+
withTag(tag: string): ConsolaInstance;
|
|
385
|
+
/**
|
|
386
|
+
* Adds a custom reporter to the Consola instance.
|
|
387
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
388
|
+
*
|
|
389
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
390
|
+
* @returns {Consola} The current Consola instance.
|
|
391
|
+
*/
|
|
392
|
+
addReporter(reporter: ConsolaReporter): this;
|
|
393
|
+
/**
|
|
394
|
+
* Removes a custom reporter from the Consola instance.
|
|
395
|
+
* If no reporter is specified, all reporters will be removed.
|
|
396
|
+
*
|
|
397
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
398
|
+
* @returns {Consola} The current Consola instance.
|
|
399
|
+
*/
|
|
400
|
+
removeReporter(reporter: ConsolaReporter): ConsolaReporter[] | this;
|
|
401
|
+
/**
|
|
402
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
403
|
+
*
|
|
404
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
405
|
+
* @returns {Consola} The current Consola instance.
|
|
406
|
+
*/
|
|
407
|
+
setReporters(reporters: ConsolaReporter[]): this;
|
|
408
|
+
wrapAll(): void;
|
|
409
|
+
restoreAll(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
412
|
+
*/
|
|
413
|
+
wrapConsole(): void;
|
|
414
|
+
/**
|
|
415
|
+
* Restores the original console methods, removing Consola overrides.
|
|
416
|
+
*/
|
|
417
|
+
restoreConsole(): void;
|
|
418
|
+
/**
|
|
419
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
420
|
+
*/
|
|
421
|
+
wrapStd(): void;
|
|
422
|
+
_wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
|
|
423
|
+
/**
|
|
424
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
425
|
+
*/
|
|
426
|
+
restoreStd(): void;
|
|
427
|
+
_restoreStream(stream?: NodeJS.WriteStream): void;
|
|
428
|
+
/**
|
|
429
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
430
|
+
*/
|
|
431
|
+
pauseLogs(): void;
|
|
432
|
+
/**
|
|
433
|
+
* Resumes logging, processing any queued logs.
|
|
434
|
+
*/
|
|
435
|
+
resumeLogs(): void;
|
|
436
|
+
/**
|
|
437
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
438
|
+
*
|
|
439
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
440
|
+
*/
|
|
441
|
+
mockTypes(mockFn?: ConsolaOptions["mockFn"]): void;
|
|
442
|
+
_wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => false | undefined;
|
|
443
|
+
_logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): false | undefined;
|
|
444
|
+
_log(logObj: LogObject): void;
|
|
445
|
+
}
|
|
446
|
+
interface LogFn {
|
|
447
|
+
(message: InputLogObject | any, ...args: any[]): void;
|
|
448
|
+
raw: (...args: any[]) => void;
|
|
449
|
+
}
|
|
450
|
+
type ConsolaInstance = Consola & Record<LogType, LogFn>;
|
|
451
|
+
/**
|
|
452
|
+
* Utility for creating a new Consola instance with optional configuration.
|
|
453
|
+
*
|
|
454
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Optional configuration options for the new Consola instance. See {@link ConsolaOptions}.
|
|
455
|
+
* @returns {ConsolaInstance} A new instance of Consola. See {@link ConsolaInstance}.
|
|
456
|
+
*/
|
|
457
|
+
declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
|
|
458
|
+
|
|
459
|
+
export { type ConfirmPromptOptions, Consola, type ConsolaInstance, type ConsolaOptions, type ConsolaReporter, type FormatOptions, type InputLogObject, type LogLevel, LogLevels, type LogObject, type LogType, LogTypes, type MultiSelectOptions, type PromptOptions, type SelectPromptOptions, type TextPromptOptions, createConsola };
|