From 185727c696d73550e32df3df92f9f7afc7c9693a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 07:52:28 +0100 Subject: [PATCH] style: fix lint formatting --- src/agents/pi-tools.test.ts | 9 ++- src/agents/tools/message-tool.ts | 12 ++- src/cli/gateway-cli.coverage.test.ts | 4 +- src/cli/program.test.ts | 9 ++- src/cli/program.ts | 2 +- src/commands/message.ts | 15 ++-- src/infra/bonjour-discovery.test.ts | 114 ++++++++++++++------------- 7 files changed, 92 insertions(+), 73 deletions(-) diff --git a/src/agents/pi-tools.test.ts b/src/agents/pi-tools.test.ts index 94e8fcd2b..de754771c 100644 --- a/src/agents/pi-tools.test.ts +++ b/src/agents/pi-tools.test.ts @@ -66,7 +66,14 @@ describe("createClawdbotCodingTools", () => { it("preserves action enums in normalized schemas", () => { const tools = createClawdbotCodingTools(); - const toolNames = ["browser", "canvas", "nodes", "cron", "gateway", "message"]; + const toolNames = [ + "browser", + "canvas", + "nodes", + "cron", + "gateway", + "message", + ]; const collectActionValues = ( schema: unknown, diff --git a/src/agents/tools/message-tool.ts b/src/agents/tools/message-tool.ts index 9f8ba566a..29261cb1b 100644 --- a/src/agents/tools/message-tool.ts +++ b/src/agents/tools/message-tool.ts @@ -1,10 +1,10 @@ import { Type } from "@sinclair/typebox"; import { - sendMessage, - sendPoll, type MessagePollResult, type MessageSendResult, + sendMessage, + sendPoll, } from "../../infra/outbound/message.js"; import type { AnyAgentTool } from "./common.js"; import { @@ -64,7 +64,9 @@ export function createMessageTool(): AnyAgentTool { const gifPlayback = typeof params.gifPlayback === "boolean" ? params.gifPlayback : false; const bestEffort = - typeof params.bestEffort === "boolean" ? params.bestEffort : undefined; + typeof params.bestEffort === "boolean" + ? params.bestEffort + : undefined; const result: MessageSendResult = await sendMessage({ to, @@ -82,7 +84,9 @@ export function createMessageTool(): AnyAgentTool { if (action === "poll") { const to = readStringParam(params, "to", { required: true }); - const question = readStringParam(params, "question", { required: true }); + const question = readStringParam(params, "question", { + required: true, + }); const options = readStringArrayParam(params, "options", { required: true }) ?? []; const maxSelections = readNumberParam(params, "maxSelections", { diff --git a/src/cli/gateway-cli.coverage.test.ts b/src/cli/gateway-cli.coverage.test.ts index 98d52db62..1cf7f01a6 100644 --- a/src/cli/gateway-cli.coverage.test.ts +++ b/src/cli/gateway-cli.coverage.test.ts @@ -138,7 +138,9 @@ describe("gateway-cli coverage", () => { program.exitOverride(); registerGatewayCli(program); - await program.parseAsync(["gateway", "discover", "--json"], { from: "user" }); + await program.parseAsync(["gateway", "discover", "--json"], { + from: "user", + }); expect(discoverGatewayBeacons).toHaveBeenCalledTimes(1); expect(runtimeLogs.join("\n")).toContain('"beacons"'); diff --git a/src/cli/program.test.ts b/src/cli/program.test.ts index 7f8d676cb..6a215f582 100644 --- a/src/cli/program.test.ts +++ b/src/cli/program.test.ts @@ -48,9 +48,12 @@ describe("cli program", () => { it("runs message send with required options", async () => { const program = buildProgram(); - await program.parseAsync(["message", "send", "--to", "+1", "--message", "hi"], { - from: "user", - }); + await program.parseAsync( + ["message", "send", "--to", "+1", "--message", "hi"], + { + from: "user", + }, + ); expect(messageSendCommand).toHaveBeenCalled(); }); diff --git a/src/cli/program.ts b/src/cli/program.ts index 1b8f20675..d17f34bc2 100644 --- a/src/cli/program.ts +++ b/src/cli/program.ts @@ -8,8 +8,8 @@ import { import { configureCommand } from "../commands/configure.js"; import { doctorCommand } from "../commands/doctor.js"; import { healthCommand } from "../commands/health.js"; -import { onboardCommand } from "../commands/onboard.js"; import { messagePollCommand, messageSendCommand } from "../commands/message.js"; +import { onboardCommand } from "../commands/onboard.js"; import { sessionsCommand } from "../commands/sessions.js"; import { setupCommand } from "../commands/setup.js"; import { statusCommand } from "../commands/status.js"; diff --git a/src/commands/message.ts b/src/commands/message.ts index 63ce103fe..fced32348 100644 --- a/src/commands/message.ts +++ b/src/commands/message.ts @@ -9,10 +9,10 @@ import { formatOutboundDeliverySummary, } from "../infra/outbound/format.js"; import { - sendMessage, - sendPoll, type MessagePollResult, type MessageSendResult, + sendMessage, + sendPoll, } from "../infra/outbound/message.js"; import type { RuntimeEnv } from "../runtime.js"; import { normalizeMessageProvider } from "../utils/message-provider.js"; @@ -49,7 +49,11 @@ function parseIntOption(value: unknown, label: string): number | undefined { return parsed; } -function logSendDryRun(opts: MessageSendOpts, provider: string, runtime: RuntimeEnv) { +function logSendDryRun( + opts: MessageSendOpts, + provider: string, + runtime: RuntimeEnv, +) { runtime.log( `[dry-run] would send via ${provider} -> ${opts.to}: ${opts.message}${ opts.media ? ` (media ${opts.media})` : "" @@ -57,10 +61,7 @@ function logSendDryRun(opts: MessageSendOpts, provider: string, runtime: Runtime ); } -function logPollDryRun( - result: MessagePollResult, - runtime: RuntimeEnv, -) { +function logPollDryRun(result: MessagePollResult, runtime: RuntimeEnv) { runtime.log( `[dry-run] would send poll via ${result.provider} -> ${result.to}:\n Question: ${result.question}\n Options: ${result.options.join( ", ", diff --git a/src/infra/bonjour-discovery.test.ts b/src/infra/bonjour-discovery.test.ts index 353a0dab4..d30e726b1 100644 --- a/src/infra/bonjour-discovery.test.ts +++ b/src/infra/bonjour-discovery.test.ts @@ -1,23 +1,70 @@ import { describe, expect, it, vi } from "vitest"; import type { runCommandWithTimeout } from "../process/exec.js"; -import { WIDE_AREA_DISCOVERY_DOMAIN } from "./widearea-dns.js"; import { discoverGatewayBeacons } from "./bonjour-discovery.js"; +import { WIDE_AREA_DISCOVERY_DOMAIN } from "./widearea-dns.js"; describe("bonjour-discovery", () => { it("discovers beacons on darwin across local + wide-area domains", async () => { const calls: Array<{ argv: string[]; timeoutMs: number }> = []; - const run = vi.fn(async (argv: string[], options: { timeoutMs: number }) => { - calls.push({ argv, timeoutMs: options.timeoutMs }); - const domain = argv[3] ?? ""; + const run = vi.fn( + async (argv: string[], options: { timeoutMs: number }) => { + calls.push({ argv, timeoutMs: options.timeoutMs }); + const domain = argv[3] ?? ""; + + if (argv[0] === "dns-sd" && argv[1] === "-B") { + if (domain === "local.") { + return { + stdout: [ + "Add 2 3 local. _clawdbot-bridge._tcp. Studio Bridge", + "Add 2 3 local. _clawdbot-bridge._tcp. Laptop Bridge", + "", + ].join("\n"), + stderr: "", + code: 0, + signal: null, + killed: false, + }; + } + if (domain === WIDE_AREA_DISCOVERY_DOMAIN) { + return { + stdout: [ + `Add 2 3 ${WIDE_AREA_DISCOVERY_DOMAIN} _clawdbot-bridge._tcp. Tailnet Bridge`, + "", + ].join("\n"), + stderr: "", + code: 0, + signal: null, + killed: false, + }; + } + } + + if (argv[0] === "dns-sd" && argv[1] === "-L") { + const instance = argv[2] ?? ""; + const host = + instance === "Studio Bridge" + ? "studio.local" + : instance === "Laptop Bridge" + ? "laptop.local" + : "tailnet.local"; + const tailnetDns = + instance === "Tailnet Bridge" ? "studio.tailnet.ts.net" : ""; + const txtParts = [ + "txtvers=1", + `displayName=${instance.replace(" Bridge", "")}`, + `lanHost=${host}`, + "gatewayPort=18789", + "bridgePort=18790", + "sshPort=22", + tailnetDns ? `tailnetDns=${tailnetDns}` : null, + ].filter((v): v is string => Boolean(v)); - if (argv[0] === "dns-sd" && argv[1] === "-B") { - if (domain === "local.") { return { stdout: [ - "Add 2 3 local. _clawdbot-bridge._tcp. Studio Bridge", - "Add 2 3 local. _clawdbot-bridge._tcp. Laptop Bridge", + `${instance}._clawdbot-bridge._tcp. can be reached at ${host}:18790`, + txtParts.join(" "), "", ].join("\n"), stderr: "", @@ -26,55 +73,10 @@ describe("bonjour-discovery", () => { killed: false, }; } - if (domain === WIDE_AREA_DISCOVERY_DOMAIN) { - return { - stdout: [ - `Add 2 3 ${WIDE_AREA_DISCOVERY_DOMAIN} _clawdbot-bridge._tcp. Tailnet Bridge`, - "", - ].join("\n"), - stderr: "", - code: 0, - signal: null, - killed: false, - }; - } - } - if (argv[0] === "dns-sd" && argv[1] === "-L") { - const instance = argv[2] ?? ""; - const host = - instance === "Studio Bridge" - ? "studio.local" - : instance === "Laptop Bridge" - ? "laptop.local" - : "tailnet.local"; - const tailnetDns = - instance === "Tailnet Bridge" ? "studio.tailnet.ts.net" : ""; - const txtParts = [ - "txtvers=1", - `displayName=${instance.replace(" Bridge", "")}`, - `lanHost=${host}`, - "gatewayPort=18789", - "bridgePort=18790", - "sshPort=22", - tailnetDns ? `tailnetDns=${tailnetDns}` : null, - ].filter((v): v is string => Boolean(v)); - - return { - stdout: [ - `${instance}._clawdbot-bridge._tcp. can be reached at ${host}:18790`, - txtParts.join(" "), - "", - ].join("\n"), - stderr: "", - code: 0, - signal: null, - killed: false, - }; - } - - throw new Error(`unexpected argv: ${argv.join(" ")}`); - }); + throw new Error(`unexpected argv: ${argv.join(" ")}`); + }, + ); const beacons = await discoverGatewayBeacons({ platform: "darwin",