mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-07-09 17:28:45 +00:00
fix: orch (dynamic) version
This commit is contained in:
parent
122527b22a
commit
7f9300763e
2 changed files with 34 additions and 4 deletions
|
|
@ -1,9 +1,14 @@
|
|||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const CONFIG_DIR_NAME = ".pi";
|
||||
const ENV_ORCHESTRATOR_DIR = "PI_ORCHESTRATOR_DIR";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
/**
|
||||
* Detect if we're running as a Bun compiled binary.
|
||||
* Bun binaries have import.meta.url containing "$bunfs", "~BUN", or "%7EBUN" (Bun's virtual filesystem path)
|
||||
|
|
@ -11,6 +16,32 @@ const ENV_ORCHESTRATOR_DIR = "PI_ORCHESTRATOR_DIR";
|
|||
export const isBunBinary =
|
||||
import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
|
||||
|
||||
interface PackageJson {
|
||||
version?: string;
|
||||
}
|
||||
|
||||
function getPackageJsonPath(): string {
|
||||
let dir = __dirname;
|
||||
while (dir !== dirname(dir)) {
|
||||
const packageJsonPath = join(dir, "package.json");
|
||||
if (existsSync(packageJsonPath)) {
|
||||
return packageJsonPath;
|
||||
}
|
||||
dir = dirname(dir);
|
||||
}
|
||||
return join(__dirname, "package.json");
|
||||
}
|
||||
|
||||
let pkg: PackageJson = {};
|
||||
try {
|
||||
pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8")) as PackageJson;
|
||||
} catch (e: unknown) {
|
||||
const err = e as NodeJS.ErrnoException;
|
||||
if (err.code !== "ENOENT") throw e;
|
||||
}
|
||||
|
||||
export const VERSION: string = pkg.version || "0.0.0";
|
||||
|
||||
export function getOrchestratorDir(): string {
|
||||
const envDir = process.env[ENV_ORCHESTRATOR_DIR];
|
||||
if (envDir) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { hostname, platform } from "node:os";
|
||||
import { AuthStorage, type OAuthCredential } from "@earendil-works/pi-coding-agent";
|
||||
import { getOrchestratorDir, getSocketPath } from "./config.ts";
|
||||
import { getOrchestratorDir, getSocketPath, VERSION } from "./config.ts";
|
||||
import { loadMachine, saveMachine } from "./storage.ts";
|
||||
import type { InstanceRecord, MachineRecord, RadiusRegistration } from "./types.ts";
|
||||
|
||||
const DEFAULT_RADIUS_URL = "https://radius.pi.dev/";
|
||||
const DEFAULT_ORCHESTRATOR_BASE_PATH = "/v1/";
|
||||
const ORCHESTRATOR_VERSION = "0.79.6";
|
||||
const NOT_FOUND_RETRY_THRESHOLD = 3;
|
||||
const HEARTBEAT_BACKOFF_BASE_MS = 1_000;
|
||||
const HEARTBEAT_BACKOFF_MAX_MS = 30_000;
|
||||
|
|
@ -243,7 +242,7 @@ export class RadiusPresence {
|
|||
hostname: hostname(),
|
||||
platform: platform(),
|
||||
arch: process.arch,
|
||||
version: ORCHESTRATOR_VERSION,
|
||||
version: VERSION,
|
||||
capabilities: { spawn: true, relay: false, iroh: false },
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue