desktop: the app's own CLI on the terminal PATH (launcher rewritten on every start; npm installs stay first)

This commit is contained in:
CRTkafa 2026-11-06 21:01:19 +07:00
parent 31f863ed06
commit 0950ef2c99
4 changed files with 133 additions and 0 deletions

View file

@ -28,6 +28,7 @@ import { androidSdk, detectTools } from './lib/tools';
import { compiled, pickCallEnv, runCommand, type RunOptions, type Running } from './lib/runner';
import { inputSchema, notSentProp, type ToolDef, TOOLS, toArgv, validateInput } from './mcp-tools';
import * as rt from './lib/rt';
import { ensureCliShim } from './lib/cli-shim';
type Id = string | number;
interface Msg { jsonrpc?: string; id?: Id | null; method?: string; params?: unknown }
@ -613,6 +614,8 @@ export async function serveStdio(): Promise<void> {
const send: Send = o => { process.stdout.write(JSON.stringify(o) + '\n'); };
const session = new Session(send);
console.error(`[storebound serve] ${pkg.version} on stdio (${DESKTOP_PROTOCOL}), waiting for session.hello`);
// the app's own CLI on the terminal PATH (lib/cli-shim.ts); only the bundled sidecar, after the handshake had its turn
if (compiled()) setTimeout(() => { for (const l of ensureCliShim()) console.error(`[storebound serve] ${l}`); }, 2000);
let buf = '';
const decoder = new TextDecoder();
const reader = rt.stdinStream().getReader();