mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(cli): send version during daemon handshake
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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, {
|
||||
|
||||
15
packages/cli/src/version.ts
Normal file
15
packages/cli/src/version.ts
Normal 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.");
|
||||
}
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user