mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-14 12:23:16 +00:00
fix(cli): send version during daemon handshake
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { Command, Option } from "commander";
|
import { Command, Option } from "commander";
|
||||||
import { createRequire } from "node:module";
|
|
||||||
import { createAgentCommand } from "./commands/agent/index.js";
|
import { createAgentCommand } from "./commands/agent/index.js";
|
||||||
import { createDaemonCommand } from "./commands/daemon/index.js";
|
import { createDaemonCommand } from "./commands/daemon/index.js";
|
||||||
import { createChatCommand } from "./commands/chat/index.js";
|
import { createChatCommand } from "./commands/chat/index.js";
|
||||||
@@ -30,20 +29,7 @@ import {
|
|||||||
addJsonAndDaemonHostOptions,
|
addJsonAndDaemonHostOptions,
|
||||||
addJsonOption,
|
addJsonOption,
|
||||||
} from "./utils/command-options.js";
|
} from "./utils/command-options.js";
|
||||||
|
import { resolveCliVersion } from "./version.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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const VERSION = resolveCliVersion();
|
const VERSION = resolveCliVersion();
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { loadConfig, resolvePaseoHome, DaemonClient } from "@getpaseo/server";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import WebSocket from "ws";
|
import WebSocket from "ws";
|
||||||
import { getOrCreateCliClientId } from "./client-id.js";
|
import { getOrCreateCliClientId } from "./client-id.js";
|
||||||
|
import { resolveCliVersion } from "../version.js";
|
||||||
|
|
||||||
export interface ConnectOptions {
|
export interface ConnectOptions {
|
||||||
host?: string;
|
host?: string;
|
||||||
@@ -207,6 +208,7 @@ export async function connectToDaemon(options?: ConnectOptions): Promise<DaemonC
|
|||||||
url: target.url,
|
url: target.url,
|
||||||
clientId,
|
clientId,
|
||||||
clientType: "cli",
|
clientType: "cli",
|
||||||
|
appVersion: resolveCliVersion(),
|
||||||
connectTimeoutMs: timeout,
|
connectTimeoutMs: timeout,
|
||||||
webSocketFactory: (url: string, config?: { headers?: Record<string, string> }) =>
|
webSocketFactory: (url: string, config?: { headers?: Record<string, string> }) =>
|
||||||
nodeWebSocketFactory(url, {
|
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,
|
resolveDaemonTarget,
|
||||||
resolveDefaultDaemonHosts,
|
resolveDefaultDaemonHosts,
|
||||||
} from "../src/utils/client.js";
|
} from "../src/utils/client.js";
|
||||||
|
import { resolveCliVersion } from "../src/version.js";
|
||||||
|
|
||||||
console.log("=== CLI IPC Target Helpers ===\n");
|
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-"));
|
const paseoHome = mkdtempSync(path.join(os.tmpdir(), "paseo-client-targets-order-"));
|
||||||
try {
|
try {
|
||||||
mkdirSync(paseoHome, { recursive: true });
|
mkdirSync(paseoHome, { recursive: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user