chore: drop runner shim and add committer helper

This commit is contained in:
Peter Steinberger
2025-12-09 17:24:25 +00:00
parent d04f7fc6e9
commit 1f19ca1665
25 changed files with 139 additions and 51 deletions

View File

@@ -62,7 +62,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
thinkLevel: "medium",
});
@@ -100,7 +99,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -142,7 +140,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -183,7 +180,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -240,7 +236,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
onAgentEvent: (evt) => events.push(evt),
});
@@ -281,7 +276,6 @@ describe("runCommandReply (pi)", () => {
systemSent: true,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -311,7 +305,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 10,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -344,7 +337,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -379,7 +371,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -411,7 +402,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
onPartialReply: onPartial,
verboseLevel: "off",
@@ -445,7 +435,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 1000,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});
@@ -475,7 +464,6 @@ describe("runCommandReply (pi)", () => {
systemSent: false,
timeoutMs: 100,
timeoutSeconds: 1,
commandRunner: vi.fn(),
enqueue: enqueueImmediate,
});

View File

@@ -15,7 +15,6 @@ import { logError } from "../logger.js";
import { getChildLogger } from "../logging.js";
import { splitMediaFromOutput } from "../media/parse.js";
import { enqueueCommand } from "../process/command-queue.js";
import type { runCommandWithTimeout } from "../process/exec.js";
import { runPiRpc } from "../process/tau-rpc.js";
import { applyTemplate, type TemplateContext } from "./templating.js";
import {
@@ -146,7 +145,7 @@ type CommandReplyConfig = NonNullable<WarelayConfig["inbound"]>["reply"] & {
mode: "command";
};
type EnqueueRunner = typeof enqueueCommand;
type EnqueueCommandFn = typeof enqueueCommand;
type ThinkLevel = "off" | "minimal" | "low" | "medium" | "high";
@@ -159,8 +158,7 @@ type CommandReplyParams = {
systemSent: boolean;
timeoutMs: number;
timeoutSeconds: number;
commandRunner: typeof runCommandWithTimeout;
enqueue?: EnqueueRunner;
enqueue?: EnqueueCommandFn;
thinkLevel?: ThinkLevel;
verboseLevel?: "off" | "on";
onPartialReply?: (payload: ReplyPayload) => Promise<void> | void;
@@ -347,7 +345,6 @@ export async function runCommandReply(
systemSent,
timeoutMs,
timeoutSeconds,
commandRunner: _commandRunner,
enqueue = enqueueCommand,
thinkLevel,
verboseLevel,

View File

@@ -1,6 +1,7 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import * as tauRpc from "../process/tau-rpc.js";
import * as commandReply from "./command-reply.js";
import { getReplyFromConfig } from "./reply.js";
const webMocks = vi.hoisted(() => ({
@@ -27,7 +28,7 @@ afterEach(() => {
describe("trigger handling", () => {
it("aborts even with timestamp prefix", async () => {
const runner = vi.fn();
const commandSpy = vi.spyOn(commandReply, "runCommandReply");
const res = await getReplyFromConfig(
{
Body: "[Dec 5 10:00] stop",
@@ -36,15 +37,14 @@ describe("trigger handling", () => {
},
{},
baseCfg,
runner,
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toBe("⚙️ Agent was aborted.");
expect(runner).not.toHaveBeenCalled();
expect(commandSpy).not.toHaveBeenCalled();
});
it("restarts even with prefix/whitespace", async () => {
const runner = vi.fn();
const commandSpy = vi.spyOn(commandReply, "runCommandReply");
const res = await getReplyFromConfig(
{
Body: " [Dec 5] /restart",
@@ -53,15 +53,14 @@ describe("trigger handling", () => {
},
{},
baseCfg,
runner,
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text?.startsWith("⚙️ Restarting" ?? "")).toBe(true);
expect(runner).not.toHaveBeenCalled();
expect(commandSpy).not.toHaveBeenCalled();
});
it("reports status without invoking the agent", async () => {
const runner = vi.fn();
const commandSpy = vi.spyOn(commandReply, "runCommandReply");
const res = await getReplyFromConfig(
{
Body: "/status",
@@ -70,11 +69,10 @@ describe("trigger handling", () => {
},
{},
baseCfg,
runner,
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Status");
expect(runner).not.toHaveBeenCalled();
expect(commandSpy).not.toHaveBeenCalled();
});
it("ignores think directives that only appear in the context wrapper", async () => {

View File

@@ -17,7 +17,6 @@ import { isVerbose, logVerbose } from "../globals.js";
import { buildProviderSummary } from "../infra/provider-summary.js";
import { triggerWarelayRestart } from "../infra/restart.js";
import { drainSystemEvents } from "../infra/system-events.js";
import { runCommandWithTimeout } from "../process/exec.js";
import { defaultRuntime } from "../runtime.js";
import { resolveHeartbeatSeconds } from "../web/reconnect.js";
import { getWebAuthAgeMs, webAuthExists } from "../web/session.js";
@@ -163,7 +162,6 @@ export async function getReplyFromConfig(
ctx: MsgContext,
opts?: GetReplyOptions,
configOverride?: WarelayConfig,
commandRunner: typeof runCommandWithTimeout = runCommandWithTimeout,
): Promise<ReplyPayload | ReplyPayload[] | undefined> {
// Choose reply from config: static text or external command stdout.
const cfg = configOverride ?? loadConfig();
@@ -737,7 +735,6 @@ export async function getReplyFromConfig(
systemSent,
timeoutMs,
timeoutSeconds,
commandRunner,
thinkLevel: resolvedThinkLevel,
verboseLevel: resolvedVerboseLevel,
onPartialReply: opts?.onPartialReply,

View File

@@ -22,7 +22,6 @@ import {
saveSessionStore,
} from "../config/sessions.js";
import { emitAgentEvent } from "../infra/agent-events.js";
import { runCommandWithTimeout } from "../process/exec.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { normalizeE164 } from "../utils.js";
@@ -319,7 +318,6 @@ export async function agentCommand(
systemSent,
timeoutMs,
timeoutSeconds,
commandRunner: runCommandWithTimeout,
thinkLevel: resolvedThinkLevel,
verboseLevel: resolvedVerboseLevel,
runId: sessionId,

View File

@@ -101,7 +101,7 @@ describe("web inbound media saves with extension", () => {
realSock.ev.emit("messages.upsert", upsert);
// Allow a brief window for the async handler to fire on slower runners.
// Allow a brief window for the async handler to fire on slower hosts.
for (let i = 0; i < 10; i++) {
if (onMessage.mock.calls.length > 0) break;
await new Promise((resolve) => setTimeout(resolve, 5));