UNPKG

@code-yeongyu/senpi

Version:

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

38 lines • 1.29 kB
/** Helpers every eval kernel (JavaScript and Python) installs before any contribution runs. */ const KERNEL_BUILTIN_GLOBALS = new Set([ "agent", "completion", "display", "env", "log", "output", "parallel", "phase", "pipeline", "print", "read", "tool", "tool_schema", "tools", "workpool", "write", ]); export class KernelPreludeCollisionError extends Error { constructor(toolName, collidingExport) { super(`Tool "${toolName}" kernelPrelude export "${collidingExport}" collides with a built-in eval kernel global.`); this.name = "KernelPreludeCollisionError"; this.toolName = toolName; this.collidingExport = collidingExport; } } /** * The `kernelPrelude` a tool projects through `getAllTools()`. Throws when an export would shadow a built-in kernel * helper or a `__`-prefixed kernel internal, since installing it would break every later cell. */ export function projectKernelPrelude(toolName, prelude) { const collision = prelude?.exports.find((name) => KERNEL_BUILTIN_GLOBALS.has(name) || name.startsWith("__")); if (collision !== undefined) throw new KernelPreludeCollisionError(toolName, collision); return prelude; } //# sourceMappingURL=kernel-prelude.js.map