fix(cli): send version during daemon handshake

This commit is contained in:
Mohamed Boudra
2026-04-22 16:19:51 +07:00
parent 43b9123c5c
commit 9e3d8f0ec5
4 changed files with 26 additions and 16 deletions

View File

@@ -1,5 +1,4 @@
import { Command, Option } from "commander";
import { createRequire } from "node:module";
import { createAgentCommand } from "./commands/agent/index.js";
import { createDaemonCommand } from "./commands/daemon/index.js";
import { createChatCommand } from "./commands/chat/index.js";
@@ -30,20 +29,7 @@ import {
addJsonAndDaemonHostOptions,
addJsonOption,
} from "./utils/command-options.js";
const require = createRequire(import.meta.url);
type CliPackageJson = {
version?: unknown;
};
function resolveCliVersion(): string {
const packageJson = require("../package.json") as CliPackageJson;
if (typeof packageJson.version === "string" && packageJson.version.trim().length > 0) {
return packageJson.version.trim();
}
throw new Error("Unable to resolve @getpaseo/cli version from package.json.");
}
import { resolveCliVersion } from "./version.js";
const VERSION = resolveCliVersion();

View File

@@ -3,6 +3,7 @@ import { loadConfig, resolvePaseoHome, DaemonClient } from "@getpaseo/server";
import path from "node:path";
import WebSocket from "ws";
import { getOrCreateCliClientId } from "./client-id.js";
import { resolveCliVersion } from "../version.js";
export interface ConnectOptions {
host?: string;
@@ -207,6 +208,7 @@ export async function connectToDaemon(options?: ConnectOptions): Promise<DaemonC
url: target.url,
clientId,
clientType: "cli",
appVersion: resolveCliVersion(),
connectTimeoutMs: timeout,
webSocketFactory: (url: string, config?: { headers?: Record<string, string> }) =>
nodeWebSocketFactory(url, {

View File

@@ -0,0 +1,15 @@
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
type CliPackageJson = {
version?: unknown;
};
export function resolveCliVersion(): string {
const packageJson = require("../package.json") as CliPackageJson;
if (typeof packageJson.version === "string" && packageJson.version.trim().length > 0) {
return packageJson.version.trim();
}
throw new Error("Unable to resolve @getpaseo/cli version from package.json.");
}

View File

@@ -10,6 +10,7 @@ import {
resolveDaemonTarget,
resolveDefaultDaemonHosts,
} from "../src/utils/client.js";
import { resolveCliVersion } from "../src/version.js";
console.log("=== CLI IPC Target Helpers ===\n");
@@ -94,7 +95,13 @@ console.log("=== CLI IPC Target Helpers ===\n");
}
{
console.log("Test 6: local IPC still takes priority over configured TCP hosts");
console.log("Test 6: CLI app version resolves for daemon hello compatibility");
assert.match(resolveCliVersion(), /^\d+\.\d+\.\d+/);
console.log("✓ CLI app version resolves for daemon hello compatibility\n");
}
{
console.log("Test 7: local IPC still takes priority over configured TCP hosts");
const paseoHome = mkdtempSync(path.join(os.tmpdir(), "paseo-client-targets-order-"));
try {
mkdirSync(paseoHome, { recursive: true });