From fe6fd20143fb99563edf4341be421e70db8182ce Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Thu, 26 Feb 2026 00:51:03 -0800 Subject: [PATCH] refactor: remove duplicate sleep() definitions in fly and daytona modules (#1944) Both fly.ts and daytona.ts defined a local `sleep` helper identical to the one already exported from shared/ssh.ts. Remove the local copies and import the shared function instead, consistent with all other cloud modules. Co-authored-by: spawn-qa-bot Co-authored-by: Claude Sonnet 4.6 --- packages/cli/package.json | 2 +- packages/cli/src/daytona/daytona.ts | 6 +----- packages/cli/src/fly/fly.ts | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 126f7daf..8ef43070 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/spawn", - "version": "0.10.19", + "version": "0.10.20", "type": "module", "bin": { "spawn": "cli.js" diff --git a/packages/cli/src/daytona/daytona.ts b/packages/cli/src/daytona/daytona.ts index 20424415..44c16569 100644 --- a/packages/cli/src/daytona/daytona.ts +++ b/packages/cli/src/daytona/daytona.ts @@ -20,7 +20,7 @@ import { getPackagesForTier, needsNode, needsBun, NODE_INSTALL_CMD } from "../sh import { parseJsonWith, parseJsonRaw, isString, toObjectArray, toRecord } from "@openrouter/spawn-shared"; import * as v from "valibot"; import { saveVmConnection } from "../history.js"; -import { spawnInteractive } from "../shared/ssh"; +import { sleep, spawnInteractive } from "../shared/ssh"; const DAYTONA_API_BASE = "https://app.daytona.io/api"; const DAYTONA_DASHBOARD_URL = "https://app.daytona.io/"; @@ -45,10 +45,6 @@ export function getState() { // ─── API Client ────────────────────────────────────────────────────────────── -function sleep(ms: number): Promise { - return new Promise((r) => setTimeout(r, ms)); -} - const LooseObject = v.record(v.string(), v.unknown()); /** Parse a JSON string into a Record via valibot, or null. */ diff --git a/packages/cli/src/fly/fly.ts b/packages/cli/src/fly/fly.ts index 8dcc4a2e..ffed766d 100644 --- a/packages/cli/src/fly/fly.ts +++ b/packages/cli/src/fly/fly.ts @@ -20,7 +20,7 @@ import type { CloudInitTier } from "../shared/agents"; import { getPackagesForTier, needsNode, needsBun, NODE_INSTALL_CMD } from "../shared/cloud-init"; import * as v from "valibot"; import { parseJsonWith, parseJsonRaw, isString, isNumber, toObjectArray } from "@openrouter/spawn-shared"; -import { killWithTimeout, spawnInteractive } from "../shared/ssh"; +import { killWithTimeout, sleep, spawnInteractive } from "../shared/ssh"; import { saveVmConnection } from "../history.js"; const FLY_API_BASE = "https://api.machines.dev/v1"; @@ -159,10 +159,6 @@ async function flyApi(method: string, endpoint: string, body?: string, maxRetrie // ─── Helpers ───────────────────────────────────────────────────────────────── -function sleep(ms: number): Promise { - return new Promise((r) => setTimeout(r, ms)); -} - const LooseObject = v.record(v.string(), v.unknown()); function parseJson(text: string): Record | null {