naisys
Version:
Node.js Autonomous Intelligence System
39 lines • 1.17 kB
JavaScript
import chalk from "chalk";
import { LlmRole } from "../llm/llmDtos.js";
import * as logService from "./logService.js";
export var OutputColor;
(function (OutputColor) {
OutputColor["comment"] = "greenBright";
OutputColor["error"] = "redBright";
OutputColor["llm"] = "magenta";
OutputColor["console"] = "white";
OutputColor["loading"] = "yellow";
OutputColor["subagent"] = "cyan";
})(OutputColor || (OutputColor = {}));
// color available on chalk
export function write(msg, color = OutputColor.console) {
console.log(chalk[color](msg));
}
/** Meant for non-content output we show in the console, but is not added to the context */
export function comment(msg) {
write(msg, OutputColor.comment);
}
export async function commentAndLog(msg) {
comment(msg);
await writeDbLog(msg, "comment");
}
export function error(msg) {
write(msg, OutputColor.error);
}
export async function errorAndLog(msg) {
error(msg);
await writeDbLog(msg, "error");
}
async function writeDbLog(msg, type) {
await logService.write({
role: LlmRole.User,
content: msg,
type,
});
}
//# sourceMappingURL=output.js.map