UNPKG

@code-yeongyu/senpi

Version:

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

54 lines • 1.88 kB
import { Worker } from "node:worker_threads"; import { isBunBinary } from "../../../../config.js"; export class ResolverTimeoutError extends Error { constructor(detail) { super(`ETIMEDOUT: ${detail}`); this.code = "ETIMEDOUT"; this.name = "ResolverTimeoutError"; } } export class ResolverUnavailableError extends Error { constructor(detail) { super(`EUNAVAILABLE: ${detail}`); this.code = "EUNAVAILABLE"; this.name = "ResolverUnavailableError"; } } export class ResolverFailure extends Error { constructor(code) { super(code); this.name = "ResolverFailure"; this.code = code; } } const compiledWorkerEntry = typeof SENPI_PATH_IDENTITY_WORKER_ENTRY === "string" ? SENPI_PATH_IDENTITY_WORKER_ENTRY : "./src/core/extensions/builtin/permission-system/path-identity-worker.ts"; /** * Where the worker lives in each shipped layout: the compiled binary embeds it under its source path * (an explicit `bun build --compile` entry), the npm bundle emits it beside the host's chunk, and the * source tree runs the `.ts` file directly. */ export function workerEntryFor(moduleUrl) { if (isBunBinary) return compiledWorkerEntry; return new URL(moduleUrl.endsWith(".ts") ? "./path-identity-worker.ts" : "./path-identity-worker.js", moduleUrl); } export function workerTransport(entry) { const worker = new Worker(entry); worker.unref(); return { post: (request) => worker.postMessage(request), onMessage: (handler) => { worker.on("message", handler); }, onError: (handler) => { worker.on("error", handler); }, onExit: (handler) => { worker.on("exit", handler); }, terminate: () => worker.terminate(), }; } //# sourceMappingURL=path-identity-transport.js.map