UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

7 lines (6 loc) • 1.68 kB
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } } import{redactSensitiveOutput}from"./chunk-62OVOJPI.js";import{getDebugLogPath}from"./chunk-QJTWAOBX.js";import*as fs from"node:fs";import*as path from"node:path";import{inspect}from"node:util";function appendDebugLogEntry(header,text){let debugLogPath=getDebugLogPath(),prefix=`[${new Date().toISOString()}] ${header} `,redactedText=redactSensitiveOutput(text),suffix=redactedText.endsWith(` `)?"":` `;fs.mkdirSync(path.dirname(debugLogPath),{recursive:!0}),fs.appendFileSync(debugLogPath,`${prefix}${redactedText}${suffix}`,{mode:384}),fs.chmodSync(debugLogPath,384)}function appendHiddenTuiStdout(text){text.length!==0&&appendDebugLogEntry("hidden stdout while TUI active",text)}function appendUncaughtCrashLog(origin,error){appendDebugLogEntry(`uncaught crash (${origin})`,describeCrash(error))}function appendUnhandledRejectionLog(reason){appendDebugLogEntry("unhandled rejection",describeCrash(reason))}function describeCrash(error){if(error instanceof Error){let identity=`${error.name}: ${error.message}`,stack=typeof error.stack=="string"&&error.stack.length>0?error.stack:void 0;return stack===void 0||stack.startsWith(identity)?stack??identity:`${identity} ${stack}`}try{return typeof error=="string"?error:inspect(error,{depth:3})}catch{return"<unprintable crash value>"}}export{appendDebugLogEntry,appendHiddenTuiStdout,appendUncaughtCrashLog,appendUnhandledRejectionLog};