refactor: replace welcome message with server_info status payload
Unify the initial connection handshake and capability update paths. The server now sends a server_info status message on connect and whenever capabilities change, enabling the onboarding flow where voice becomes available after models are configured.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"description": "Paseo desktop app (Tauri wrapper)",
|
||||
"scripts": {
|
||||
"build:managed-runtime": "node ./scripts/build-managed-runtime.mjs",
|
||||
"prepare:managed-runtime": "npm --prefix ../.. run build:daemon && npm run build:managed-runtime",
|
||||
"prepare:managed-runtime": "npm --prefix ../.. run build:daemon && npm run build:managed-runtime && npm run validate:managed-runtime",
|
||||
"dev": "npm run prepare:managed-runtime && tauri dev",
|
||||
"build": "npm --prefix ../.. run build:web --workspace=@getpaseo/app && npm run prepare:managed-runtime && tauri build",
|
||||
"validate:managed-runtime": "node ./scripts/validate-managed-runtime.mjs",
|
||||
|
||||
@@ -213,6 +213,18 @@ function runCommand(command, args, options = {}) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function withManagedRuntimeNodeOptions(env = process.env) {
|
||||
const existing = env.NODE_OPTIONS?.trim() ?? "";
|
||||
if (existing.includes("--max-old-space-size")) {
|
||||
return env;
|
||||
}
|
||||
const nodeOptions = existing ? `${existing} --max-old-space-size=8192` : "--max-old-space-size=8192";
|
||||
return {
|
||||
...env,
|
||||
NODE_OPTIONS: nodeOptions,
|
||||
};
|
||||
}
|
||||
|
||||
async function extractNodeDistribution(archivePath, nodeArtifact) {
|
||||
const extractionRoot = await fs.mkdtemp(path.join(os.tmpdir(), "paseo-managed-runtime-node-"));
|
||||
if (nodeArtifact.extension === "zip") {
|
||||
@@ -260,6 +272,7 @@ async function packWorkspace(packageRoot, tarballRoot) {
|
||||
tarballRoot,
|
||||
], {
|
||||
cwd: packageRoot,
|
||||
env: withManagedRuntimeNodeOptions(process.env),
|
||||
});
|
||||
const [{ filename }] = JSON.parse(result.stdout.trim());
|
||||
if (!filename) {
|
||||
|
||||
@@ -55,8 +55,28 @@ for (const pkg of ["@getpaseo/relay", "@getpaseo/server", "@getpaseo/cli"]) {
|
||||
});
|
||||
}
|
||||
|
||||
const sherpaPlatformMap = {
|
||||
darwin: "darwin",
|
||||
linux: "linux",
|
||||
win32: "win",
|
||||
};
|
||||
const sherpaPlatform = sherpaPlatformMap[manifest.platform];
|
||||
assert.ok(
|
||||
sherpaPlatform,
|
||||
`Unsupported sherpa platform mapping for managed runtime validation: ${manifest.platform}`
|
||||
);
|
||||
|
||||
const sherpaNativePackage = `sherpa-onnx-${sherpaPlatform}-${manifest.arch}`;
|
||||
const sherpaNativePackageDir = path.join(runtimeRoot, "node_modules", sherpaNativePackage);
|
||||
await fs.access(sherpaNativePackageDir).catch(() => {
|
||||
throw new Error(
|
||||
`Missing bundled native speech dependency: ${sherpaNativePackage} (expected at ${sherpaNativePackageDir})`
|
||||
);
|
||||
});
|
||||
|
||||
console.log(`[validate-managed-runtime] PASS`);
|
||||
console.log(` runtimeId: ${manifest.runtimeId}`);
|
||||
console.log(` version: ${expectedVersion}`);
|
||||
console.log(` platform: ${manifest.platform}`);
|
||||
console.log(` arch: ${manifest.arch}`);
|
||||
console.log(` sherpaNativePackage: ${sherpaNativePackage}`);
|
||||
|
||||
@@ -333,8 +333,31 @@ fn bundled_runtime_root(app: &AppHandle) -> Result<PathBuf, String> {
|
||||
return Ok(candidate);
|
||||
}
|
||||
} else {
|
||||
log::info!("[runtime] resource_dir() unavailable");
|
||||
log::info!("[runtime] resource_dir() unavailable, resolving from executable path");
|
||||
}
|
||||
|
||||
// Fallback: resolve symlinks and search relative to the real executable location.
|
||||
// Handles CLI symlink invocation where Tauri can't resolve resource_dir.
|
||||
if let Ok(canonical) = std::env::current_exe().and_then(|p| p.canonicalize()) {
|
||||
let exe_dir = dunce::simplified(&canonical);
|
||||
if let Some(exe_dir) = exe_dir.parent() {
|
||||
let mut candidates = vec![exe_dir.join("resources"), exe_dir.to_path_buf()];
|
||||
if let Some(contents_dir) = exe_dir.parent() {
|
||||
candidates.push(contents_dir.join("Resources"));
|
||||
candidates.push(contents_dir.join("resources"));
|
||||
}
|
||||
for resource_dir in candidates {
|
||||
if let Some(found) = bundled_runtime_root_from_resource_dir(&resource_dir) {
|
||||
log::info!(
|
||||
"[runtime] found bundled runtime (via exe fallback) at {}",
|
||||
found.display()
|
||||
);
|
||||
return Ok(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::error!("[runtime] no managed runtime found");
|
||||
Err("Managed runtime resources are not bundled with this desktop build.".to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user