style: format after gate
This commit is contained in:
@@ -5,10 +5,10 @@ import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|||||||
import { resolveHeartbeatPrompt } from "../auto-reply/heartbeat.js";
|
import { resolveHeartbeatPrompt } from "../auto-reply/heartbeat.js";
|
||||||
import type { ThinkLevel } from "../auto-reply/thinking.js";
|
import type { ThinkLevel } from "../auto-reply/thinking.js";
|
||||||
import type { ClawdbotConfig } from "../config/config.js";
|
import type { ClawdbotConfig } from "../config/config.js";
|
||||||
|
import { shouldLogVerbose } from "../globals.js";
|
||||||
import { createSubsystemLogger } from "../logging.js";
|
import { createSubsystemLogger } from "../logging.js";
|
||||||
import { runCommandWithTimeout } from "../process/exec.js";
|
import { runCommandWithTimeout } from "../process/exec.js";
|
||||||
import { resolveUserPath } from "../utils.js";
|
import { resolveUserPath } from "../utils.js";
|
||||||
import { shouldLogVerbose } from "../globals.js";
|
|
||||||
import {
|
import {
|
||||||
buildBootstrapContextFiles,
|
buildBootstrapContextFiles,
|
||||||
type EmbeddedContextFile,
|
type EmbeddedContextFile,
|
||||||
@@ -21,7 +21,10 @@ const log = createSubsystemLogger("agent/claude-cli");
|
|||||||
const CLAUDE_CLI_QUEUE_KEY = "global";
|
const CLAUDE_CLI_QUEUE_KEY = "global";
|
||||||
const CLAUDE_CLI_RUN_QUEUE = new Map<string, Promise<unknown>>();
|
const CLAUDE_CLI_RUN_QUEUE = new Map<string, Promise<unknown>>();
|
||||||
|
|
||||||
function enqueueClaudeCliRun<T>(key: string, task: () => Promise<T>): Promise<T> {
|
function enqueueClaudeCliRun<T>(
|
||||||
|
key: string,
|
||||||
|
task: () => Promise<T>,
|
||||||
|
): Promise<T> {
|
||||||
const prior = CLAUDE_CLI_RUN_QUEUE.get(key) ?? Promise.resolve();
|
const prior = CLAUDE_CLI_RUN_QUEUE.get(key) ?? Promise.resolve();
|
||||||
const chained = prior.catch(() => undefined).then(task);
|
const chained = prior.catch(() => undefined).then(task);
|
||||||
const tracked = chained.finally(() => {
|
const tracked = chained.finally(() => {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import type { ClawdbotConfig } from "../config/config.js";
|
import type { ClawdbotConfig } from "../config/config.js";
|
||||||
import { buildAllowedModelSet, modelKey, parseModelRef } from "./model-selection.js";
|
import {
|
||||||
|
buildAllowedModelSet,
|
||||||
|
modelKey,
|
||||||
|
parseModelRef,
|
||||||
|
} from "./model-selection.js";
|
||||||
|
|
||||||
const catalog = [
|
const catalog = [
|
||||||
{
|
{
|
||||||
@@ -30,9 +34,9 @@ describe("buildAllowedModelSet", () => {
|
|||||||
|
|
||||||
expect(allowed.allowAny).toBe(false);
|
expect(allowed.allowAny).toBe(false);
|
||||||
expect(allowed.allowedKeys.has(modelKey("openai", "gpt-4"))).toBe(true);
|
expect(allowed.allowedKeys.has(modelKey("openai", "gpt-4"))).toBe(true);
|
||||||
expect(
|
expect(allowed.allowedKeys.has(modelKey("claude-cli", "opus-4.5"))).toBe(
|
||||||
allowed.allowedKeys.has(modelKey("claude-cli", "opus-4.5")),
|
true,
|
||||||
).toBe(true);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes the default model when no allowlist is set", () => {
|
it("includes the default model when no allowlist is set", () => {
|
||||||
@@ -49,9 +53,9 @@ describe("buildAllowedModelSet", () => {
|
|||||||
|
|
||||||
expect(allowed.allowAny).toBe(true);
|
expect(allowed.allowAny).toBe(true);
|
||||||
expect(allowed.allowedKeys.has(modelKey("openai", "gpt-4"))).toBe(true);
|
expect(allowed.allowedKeys.has(modelKey("openai", "gpt-4"))).toBe(true);
|
||||||
expect(
|
expect(allowed.allowedKeys.has(modelKey("claude-cli", "opus-4.5"))).toBe(
|
||||||
allowed.allowedKeys.has(modelKey("claude-cli", "opus-4.5")),
|
true,
|
||||||
).toBe(true);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import crypto from "node:crypto";
|
import crypto from "node:crypto";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import type { TemplateContext } from "../templating.js";
|
|
||||||
import { onAgentEvent } from "../../infra/agent-events.js";
|
import { onAgentEvent } from "../../infra/agent-events.js";
|
||||||
|
import type { TemplateContext } from "../templating.js";
|
||||||
import type { FollowupRun, QueueSettings } from "./queue.js";
|
import type { FollowupRun, QueueSettings } from "./queue.js";
|
||||||
import { createMockTypingController } from "./test-helpers.js";
|
import { createMockTypingController } from "./test-helpers.js";
|
||||||
|
|
||||||
@@ -105,9 +104,7 @@ function createRun() {
|
|||||||
|
|
||||||
describe("runReplyAgent claude-cli routing", () => {
|
describe("runReplyAgent claude-cli routing", () => {
|
||||||
it("uses claude-cli runner for claude-cli provider", async () => {
|
it("uses claude-cli runner for claude-cli provider", async () => {
|
||||||
const randomSpy = vi
|
const randomSpy = vi.spyOn(crypto, "randomUUID").mockReturnValue("run-1");
|
||||||
.spyOn(crypto, "randomUUID")
|
|
||||||
.mockReturnValue("run-1");
|
|
||||||
const lifecyclePhases: string[] = [];
|
const lifecyclePhases: string[] = [];
|
||||||
const unsubscribe = onAgentEvent((evt) => {
|
const unsubscribe = onAgentEvent((evt) => {
|
||||||
if (evt.runId !== "run-1") return;
|
if (evt.runId !== "run-1") return;
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ import {
|
|||||||
} from "../../config/sessions.js";
|
} from "../../config/sessions.js";
|
||||||
import type { TypingMode } from "../../config/types.js";
|
import type { TypingMode } from "../../config/types.js";
|
||||||
import { logVerbose } from "../../globals.js";
|
import { logVerbose } from "../../globals.js";
|
||||||
import { emitAgentEvent, registerAgentRunContext } from "../../infra/agent-events.js";
|
import {
|
||||||
|
emitAgentEvent,
|
||||||
|
registerAgentRunContext,
|
||||||
|
} from "../../infra/agent-events.js";
|
||||||
import { defaultRuntime } from "../../runtime.js";
|
import { defaultRuntime } from "../../runtime.js";
|
||||||
import {
|
import {
|
||||||
estimateUsageCost,
|
estimateUsageCost,
|
||||||
|
|||||||
@@ -329,7 +329,9 @@ export function buildStatusMessage(args: StatusArgs): string {
|
|||||||
const usagePair = formatUsagePair(inputTokens, outputTokens);
|
const usagePair = formatUsagePair(inputTokens, outputTokens);
|
||||||
const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
|
const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
|
||||||
const usageCostLine =
|
const usageCostLine =
|
||||||
usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
|
usagePair && costLine
|
||||||
|
? `${usagePair} · ${costLine}`
|
||||||
|
: (usagePair ?? costLine);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
versionLine,
|
versionLine,
|
||||||
|
|||||||
@@ -672,7 +672,9 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
service.runtime?.status === "running"
|
service.runtime?.status === "running"
|
||||||
) {
|
) {
|
||||||
defaultRuntime.log(
|
defaultRuntime.log(
|
||||||
warnText("Warm-up: launch agents can take a few seconds. Try again shortly."),
|
warnText(
|
||||||
|
"Warm-up: launch agents can take a few seconds. Try again shortly.",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (rpc) {
|
if (rpc) {
|
||||||
@@ -680,8 +682,7 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
defaultRuntime.log(`${label("RPC probe:")} ${okText("ok")}`);
|
defaultRuntime.log(`${label("RPC probe:")} ${okText("ok")}`);
|
||||||
} else {
|
} else {
|
||||||
defaultRuntime.error(`${label("RPC probe:")} ${errorText("failed")}`);
|
defaultRuntime.error(`${label("RPC probe:")} ${errorText("failed")}`);
|
||||||
if (rpc.url)
|
if (rpc.url) defaultRuntime.error(`${label("RPC target:")} ${rpc.url}`);
|
||||||
defaultRuntime.error(`${label("RPC target:")} ${rpc.url}`);
|
|
||||||
const lines = String(rpc.error ?? "unknown")
|
const lines = String(rpc.error ?? "unknown")
|
||||||
.split(/\r?\n/)
|
.split(/\r?\n/)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
@@ -698,7 +699,9 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
}
|
}
|
||||||
} else if (service.loaded && service.runtime?.status === "stopped") {
|
} else if (service.loaded && service.runtime?.status === "stopped") {
|
||||||
defaultRuntime.error(
|
defaultRuntime.error(
|
||||||
errorText("Service is loaded but not running (likely exited immediately)."),
|
errorText(
|
||||||
|
"Service is loaded but not running (likely exited immediately).",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
for (const hint of renderRuntimeHints(
|
for (const hint of renderRuntimeHints(
|
||||||
service.runtime,
|
service.runtime,
|
||||||
@@ -736,7 +739,9 @@ function printDaemonStatus(status: DaemonStatus, opts: { json: boolean }) {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (addrs.length > 0) {
|
if (addrs.length > 0) {
|
||||||
defaultRuntime.log(`${label("Listening:")} ${infoText(addrs.join(", "))}`);
|
defaultRuntime.log(
|
||||||
|
`${label("Listening:")} ${infoText(addrs.join(", "))}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status.portCli && status.portCli.port !== status.port?.port) {
|
if (status.portCli && status.portCli.port !== status.port?.port) {
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ import {
|
|||||||
import { setVerbose } from "../globals.js";
|
import { setVerbose } from "../globals.js";
|
||||||
import { GatewayLockError } from "../infra/gateway-lock.js";
|
import { GatewayLockError } from "../infra/gateway-lock.js";
|
||||||
import { formatPortDiagnostics, inspectPortUsage } from "../infra/ports.js";
|
import { formatPortDiagnostics, inspectPortUsage } from "../infra/ports.js";
|
||||||
import { createSubsystemLogger, setConsoleSubsystemFilter } from "../logging.js";
|
import {
|
||||||
|
createSubsystemLogger,
|
||||||
|
setConsoleSubsystemFilter,
|
||||||
|
} from "../logging.js";
|
||||||
import { defaultRuntime } from "../runtime.js";
|
import { defaultRuntime } from "../runtime.js";
|
||||||
import { forceFreePortAndWait } from "./ports.js";
|
import { forceFreePortAndWait } from "./ports.js";
|
||||||
import { withProgress } from "./progress.js";
|
import { withProgress } from "./progress.js";
|
||||||
|
|||||||
@@ -275,8 +275,7 @@ export function shouldLogSubsystemToConsole(subsystem: string): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return consoleSubsystemFilter.some(
|
return consoleSubsystemFilter.some(
|
||||||
(prefix) =>
|
(prefix) => subsystem === prefix || subsystem.startsWith(`${prefix}/`),
|
||||||
subsystem === prefix || subsystem.startsWith(`${prefix}/`),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user