@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
67 lines • 2.79 kB
JavaScript
/**
* Wire vocabulary between the server and a session's tool child (senpi#3566).
*
* Every frame crosses the private channel as one length-prefixed binary frame (`codec.ts`), never as NDJSON. Payloads
* above `REF_THRESHOLD` never travel inline: they move as an acknowledged `PayloadRef` (`payload-ref.ts`) in either
* direction. `trace` is the only lossy frame class; it never carries a job result, a launch proof or a tick.
*/
const MIB = 1024 * 1024;
export const TOOL_CHILD_LIMITS = {
/** Largest encoded frame body, in bytes; a larger length header is refused before its body is allocated. */
frameBytes: 16 * MIB,
/** Ordinary jobs one child runs at once; nested jobs are bounded by `hostCallCapacity()` instead. */
jobs: 32,
/** Wake notifications awaiting `wake_ack`, by count and by summed size; the next one waits (never dropped). */
wakePending: 64,
/** A job's streamed updates awaiting `update_ack`; the job's next `update()` waits for credit (never dropped). */
updatesInFlight: 64,
wakePendingBytes: 1 * MIB,
HOST_CALL_ACTIVE: 8,
HOST_CALL_WAITING: 256,
/** A payload whose JSON exceeds this many bytes moves by reference, never inline. */
REF_THRESHOLD: 4 * MIB,
/** A ref still unacknowledged after this long is reported overdue (the writer still does not delete it). */
refAckMs: 30_000,
/** Bytes of ref files one side may own at once. */
refsBudget: 1024 * MIB,
tracePerSecond: 1024,
};
export const LAUNCH_CONTAINMENTS = ["own-group", "inherited", "job", "breakaway"];
export const LAUNCH_LIFETIMES = ["owned", "detached"];
/** Which surface asked for the process. */
export const LAUNCH_ORIGINS = ["tool", "terminal", "user_bash", "interpreter", "monitor", "kernel"];
/** The launch API the command came through; group semantics differ per API. */
export const LAUNCH_APIS = [
"bun.spawn",
"bun.spawnSync",
"bun.shell",
"cp.spawn",
"cp.spawnSync",
"cp.execFileSync",
"pty.spawn",
];
export const REF_NACK_REASONS = ["cancelled", "corrupt", "missing", "budget", "foreign"];
/** What a reverse call reaches on the server (DESIGN PART 1): a tool by `name`, the model, a reserved tool, the tool list. */
export const HOST_CALL_KINDS = [
"tool",
"completion",
"reserved",
"list_tools",
"authorize",
"lock_file",
"unlock_file",
];
/** Keys a `trace` detail may never carry: the lossy class never transports results, proofs or ticks. */
export const TRACE_RESERVED_KEYS = [
"value",
"valueRef",
"result",
"ref",
"args",
"argsRef",
"ackTick",
"invokeTick",
];
/** The only frame class a full budget may drop (counted). */
export const LOSSY_FRAME_TYPES = new Set(["trace"]);
//# sourceMappingURL=protocol.js.map