Spaces:
Configuration error

File size: 990 Bytes
023064b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { format } from 'util';
import { inMcpRuntime } from '../runtime/paths';

function writeLine(stream: NodeJS.WriteStream, message: string): void {
    stream.write(`${message}\n`);
}

function formatMessage(args: unknown[]): string {
    return format(...args);
}

export function logInfo(...args: unknown[]): void {
    const message = formatMessage(args);
    if (inMcpRuntime()) {
        writeLine(process.stderr, message);
        return;
    }

    console.log(message);
}

export function logWarn(...args: unknown[]): void {
    const message = formatMessage(args);
    if (inMcpRuntime()) {
        writeLine(process.stderr, message);
        return;
    }

    console.warn(message);
}

export function logError(...args: unknown[]): void {
    writeLine(process.stderr, formatMessage(args));
}

export function writeProgress(message: string): void {
    if (inMcpRuntime()) {
        process.stderr.write(message);
        return;
    }

    process.stdout.write(message);
}