Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6797653
feat(vika): add native Windows source installation and platform adapters
openviking-superagent Nov 6, 2026
2895984
fix(vika): preserve Windows shell paths and Unicode login startup
openviking-superagent Nov 6, 2026
7ceb37a
fix(vika): respect redirected Windows roaming startup directory
openviking-superagent Nov 6, 2026
1a793a2
fix(vika): normalize Windows environments and isolate PM2 pipes
openviking-superagent Nov 6, 2026
8257185
fix(windows): enforce private directory ACLs without changing shared …
openviking-superagent Nov 6, 2026
125800b
fix(vika): canonicalize release aliases during PM2 verification
openviking-superagent Nov 6, 2026
f7be053
test(windows): exercise ACLs through Lark media cache and file delivery
openviking-superagent Nov 6, 2026
f6ae26d
fix(vika): use native PowerShell tools in Windows runtimes
openviking-superagent Nov 6, 2026
f09a032
test(vika): exercise native Windows source installation in CI
openviking-superagent Nov 6, 2026
bdccae0
fix(windows): isolate Windows PowerShell ACL module environment
openviking-superagent Nov 6, 2026
e595ae5
docs(vika): document native Windows feature coverage and acceptance gaps
openviking-superagent Nov 6, 2026
0f8bea6
test(vika): keep pending OV timeout fixture alive and document Window…
openviking-superagent Nov 6, 2026
4b356da
test(windows): cover Feishu events and OpenViking session contracts
openviking-superagent Nov 6, 2026
e26a9a6
test(vika): compare unexpanded user PATH during isolated install
openviking-superagent Nov 6, 2026
bafd228
docs(windows): record clean Linux regression and link audit reports
openviking-superagent Nov 6, 2026
83b724d
docs(windows): record successful native CI and installer verification
openviking-superagent Nov 6, 2026
60b2355
chore(windows): rename preview branch references to vika-win
openviking-superagent Nov 6, 2026
b65b380
test(windows): plant third-party ACEs without SeSecurityPrivilege
zrwangems Nov 6, 2026
5cb344f
docs(windows): list the full native test set for checkout validation
zrwangems Nov 6, 2026
d417579
Merge pull request #1 from openviking-superagent/fix/windows-acl-test…
openviking-superagent Nov 6, 2026
f273ea3
docs(windows): require non-elevated checkout validation
zrwangems Nov 6, 2026
e74667a
docs(vika): record native Windows preview blockers for one-command in…
zrwangems Nov 6, 2026
c3828a9
docs(vika): keep Windows model credentials user-local
zrwangems Nov 6, 2026
355c3e3
Merge pull request #2 from openviking-superagent/docs/windows-non-ele…
openviking-superagent Nov 6, 2026
984a4c1
fix(windows): bootstrap and verify Lark CLI when npm blocks postinstall
openviking-superagent Nov 6, 2026
8bcde77
Merge pull request #4 from openviking-superagent/fix/windows-npm12-lark
openviking-superagent Nov 6, 2026
4a52e8d
docs(vika): correct Windows model guidance and record baseline results
zrwangems Nov 6, 2026
4a15056
fix(cli): expand Windows-style tilde workspace paths
zrwangems Nov 6, 2026
3f8d4de
fix(cli): preserve POSIX tilde literals and run Windows regression
openviking-superagent Nov 7, 2026
f55d5ba
Merge pull request #3 from openviking-superagent/docs/windows-preview…
openviking-superagent Nov 7, 2026
4456fd8
Merge pull request #8 from openviking-superagent/fix/windows-workspac…
openviking-superagent Nov 7, 2026
ee7a0db
fix(core): distinguish delivered replies from failed runtime turns
openviking-superagent Nov 7, 2026
9af62aa
test(core): cover uncertain delivery and interim promotion boundaries
openviking-superagent Nov 7, 2026
f6d2031
fix(windows): hide background host and connector consoles
openviking-superagent Nov 7, 2026
ca7ebfa
fix(core): link final decisions on reclaimed delivery attempts
openviking-superagent Nov 7, 2026
a2077e6
Merge pull request #10 from openviking-superagent/fix/windows-acceptance
openviking-superagent Nov 7, 2026
3e95e8c
Merge remote-tracking branch 'origin/feat/vika' into sync/vika-win-up…
openviking-superagent Nov 7, 2026
80d3b44
Merge pull request #11 from openviking-superagent/sync/vika-win-upstr…
openviking-superagent Nov 7, 2026
8b99cb3
fix(windows): route installed pm2 shim through private transport
openviking-superagent Nov 7, 2026
3af2496
docs(windows): document bounded logs and PowerShell PM2 JSON parsing
openviking-superagent Nov 7, 2026
556124a
fix(windows): address process adapter isolation review and record nat…
openviking-superagent Nov 7, 2026
625a536
Merge remote-tracking branch 'origin/feat/vika' into fix/windows-pm2-…
openviking-superagent Nov 7, 2026
302ad0d
fix(vika): address Windows acceptance regressions and diagnostics
openviking-superagent Nov 7, 2026
40a436d
fix(vika): query process identity before creating lock file
openviking-superagent Nov 7, 2026
1ee6302
merge: sync feat/vika OV tools and preserve Windows adapters
openviking-superagent Nov 8, 2026
f0b5dfa
test(vika): use Windows-compatible control and durable fixtures
openviking-superagent Nov 8, 2026
464c2f1
fix(vika): preserve OpenCode config on non-elevated Windows
openviking-superagent Nov 8, 2026
875117d
fix(vika): close Windows OpenCode test portability gaps
openviking-superagent Nov 8, 2026
7f02e92
refactor(vika): consolidate Windows components and trim review artifacts
openviking-superagent Nov 8, 2026
2a9bfa4
refactor(vika): remove Windows installation and shell overrides
openviking-superagent Nov 8, 2026
744130a
refactor(vika): separate unrelated behavior fixes from Windows preview
openviking-superagent Nov 8, 2026
4fdf523
refactor(vika): isolate native platform adapters and preserve POSIX b…
openviking-superagent Nov 8, 2026
ba8af1d
test(vika): enforce platform isolation and upstream POSIX config parity
openviking-superagent Nov 8, 2026
df28f04
docs(vika): document the scoped Windows source preview and migration …
openviking-superagent Nov 8, 2026
66f21a1
fix(vika): preserve executable entrypoint shebangs
openviking-superagent Nov 8, 2026
89bbed7
refactor(vika): keep platform adapters limited to OS capabilities
openviking-superagent Nov 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vika/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Set up your machine (local or a cloud VM) with the software, projects, and tools

Vika supports runtimes such as Codex, Claude Code, and Pi, and connects to Feishu / Lark, WeChat, Telegram, Slack, QQ, and email. The CLI command is `vika`.

[Quick start](install.md) · [Features and architecture](docs/usage-reference.md) · [Configuration example](config.example.json) · [Contributing](../CONTRIBUTING.md)
[Quick start](install.md) · [Windows source preview](docs/windows.md) · [Features and architecture](docs/usage-reference.md) · [Configuration example](config.example.json) · [Contributing](../CONTRIBUTING.md)

## Why Vika

Expand Down
5 changes: 3 additions & 2 deletions vika/deployment-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'use strict';

const fs = require('node:fs');
const { homeDir } = require('./packages/daemon/src/platform/index.mjs');
const path = require('node:path');

const INSTANCE_ID = /^[a-z][a-z0-9-]{0,31}$/;
Expand Down Expand Up @@ -117,7 +118,7 @@ function resolveDeploymentManifestPath(env = process.env) {
}
return path.normalize(override);
}
const home = typeof env.HOME === 'string' ? env.HOME.trim() : '';
const home = typeof homeDir(env) === 'string' ? homeDir(env).trim() : '';
if (!home || !path.isAbsolute(home)) throw new Error('HOME must be an absolute path');
return path.join(path.normalize(home), '.vika', 'config.json');
}
Expand All @@ -136,7 +137,7 @@ function resolveSecretsFilePath(env = process.env) {
}
return path.normalize(override);
}
const home = typeof env.HOME === 'string' ? env.HOME.trim() : '';
const home = typeof homeDir(env) === 'string' ? homeDir(env).trim() : '';
if (!home || !path.isAbsolute(home)) return null;
return path.join(path.normalize(home), '.vika', 'secrets.env');
}
Expand Down
90 changes: 90 additions & 0 deletions vika/docs/windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Windows source preview

This is a source-only preview for a trusted, single-user Windows 10/11 x64
workstation. It does not install the separate OpenViking server; configure an
existing OpenViking service. Native Windows and macOS validation of this
refactoring is still pending. Earlier Windows acceptance results for the full
fork do not certify this version.

## Prerequisites and startup

Install Node.js 24 LTS (minimum 22.19.0), npm, PM2, Git and Git Bash yourself.
Ensure `node`, `npm`, `pm2` and `bash` are on PATH. Pi and Durable retain their
upstream Bash tools; there is no PowerShell tool replacement. Configure and
log in to the model runtime you intend to use. No administrator rights are
required by Vika, but Windows policy may restrict junctions or process management.

From the checkout's `vika` directory, in PowerShell:

```powershell
npm ci --ignore-scripts
node scripts/install-lark-cli.mjs
npm run check:pi
npm run check:durable
$env:HOME = $env:USERPROFILE
$env:PM2_HOME = Join-Path $env:USERPROFILE '.vika\pm2'
$env:VIKA_CONFIG = Join-Path $env:USERPROFILE '.vika\windows-preview.json'
```

Create that manifest using [config.example.json](../config.example.json), keeping
only the `primary` instance initially. Replace all sample paths with absolute
Windows paths, set its OpenViking configuration, runtime and authenticated
connector profile. JSON paths can use forward slashes, such as `C:/Users/name/work`.
Keep configuration and data local, outside OneDrive or network shares. Do not
replace an existing working installation's configuration while evaluating this preview.

Launch from the same terminal after configuring the manifest:

```powershell
pm2 start ecosystem.config.cjs --only vika-primary,vika-web
pm2 describe vika-primary
pm2 logs vika-primary --lines 50 --nostream
pm2 stop vika-primary vika-web
```

PM2 is the user-installed, unmodified program. Vika does not patch its Windows
pipes or promise isolation between multiple PM2 homes. Use only the named apps;
never stop unrelated PM2 applications. These commands start the source checkout.
The release-oriented `vika start` expects an installed `current` release and is
not the source startup procedure. Updating a checkout requires restarting these
apps; it does not update a separate installed release.

## Supported scope and limits

- The adapter handles npm Node shims, environment key casing, process-tree
termination, action named pipes and OpenCode directory junctions/file copies.
File copies refresh when the runtime starts. Runtime and connector parity
still requires real-machine testing.
- Codex sends developer instructions through `thread/start` and `thread/resume`
RPC. Claude uses its documented `--append-system-prompt-file` option; install
a Claude version supporting that option. Pi/OpenCode already use files or RPC.
TraeX's corresponding RPC support is unverified, so its instructions still
use argv and remain subject to the Windows command-line limit.
- Pipe names contain a random per-process component and a user/instance digest.
An occupied pipe must fail startup; authority tokens guard action calls.
This is **not pipe-owner SID verification**. Multi-user/RDP isolation is not
established, and localhost Web access is not per-user authentication.
- Vika does not provision or verify Windows ACLs. Use private user-owned data,
workspace and temporary directories. No filesystem sandbox is claimed.
- Upgrade/updater, autostart, email and Windows release builds are disabled.
Autostart returns an unsupported-preview error. There is no Windows installer,
VBS startup entry or Windows CI workflow. Slack has no Windows bundled/default
executable; it requires an explicit `SLACK_CLI_BIN` and separate validation.

## Migration and validation

This replaces the full Windows fork's installation approach. Its installer,
`.vika/bin` launchers and patched `pm2.cmd` are no longer provided. Keep the old
checkout/commit and configuration for rollback; do not copy this tree over a
running installation. The previous logs options and unrelated lock, logging,
delivery, interruption and PM2 behavior fixes were split out for separate review.

From `vika`, run `npm test`. Run `npm run check` from Git Bash because the syntax
check uses POSIX shell loops. Platform isolation and POSIX configuration snapshots
run in the normal suite; macOS configuration selection on Linux is not a macOS
runtime test. On Windows, test normal-user startup/stop, descendant cleanup,
occupied pipes, long instructions and each connector/runtime you actually use.

Report issues with the commit, Windows/Node/npm/PM2/Git Bash versions, selected
runtime and connector, reproduction steps and sanitized error text. Do not post
raw configuration, credentials, `pm2 jlist` output or conversation contents.
17 changes: 10 additions & 7 deletions vika/ecosystem.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
'use strict';

const fs = require('node:fs');
const { homeDir: platformHomeDir } = require('./packages/daemon/src/platform/index.mjs');
const { capabilities } = require('./packages/daemon/src/capabilities.mjs');
const { ecosystemSearchPath, pm2Options } = require('./packages/updater/src/pm2-platform.mjs');
const path = require('node:path');
const {
CONTROL_ENV_MAX_BYTES,
Expand All @@ -27,6 +30,7 @@ const releaseNode = path.join(releaseDir, 'node', 'bin', 'node');
const common = Object.freeze({
interpreter: fs.existsSync(releaseNode) ? releaseNode : process.execPath,
exec_mode: 'fork',
...pm2Options(),
instances: 1,
autorestart: true,
wait_ready: true,
Expand All @@ -40,10 +44,9 @@ function defined(values) {
}

function buildEcosystem(sourceEnv = process.env) {
const homeDir = sourceEnv.HOME;
const homeDir = platformHomeDir(sourceEnv);
if (!homeDir || !path.isAbsolute(homeDir)) throw new Error('HOME must be an absolute path');
const baseDir = path.join(homeDir, '.vika');
const inheritedPath = sourceEnv.PATH || '';
const deployment = loadDeploymentManifest(sourceEnv);
if (deployment.agents.some((agent) => agent.port === 3737)) {
throw new Error('agent port 3737 conflicts with the shared Web port');
Expand Down Expand Up @@ -87,7 +90,7 @@ function buildEcosystem(sourceEnv = process.env) {
VIKA_VOLC_SESSION_ID: agent.volcSessionId || '',
VIKA_VOLC_ENVIRONMENT_ID: agent.volcEnvironmentId || '',
...openVikingAgentEnv(agent),
PATH: `${inheritedPath}:${fallbackPath}`,
PATH: ecosystemSearchPath(sourceEnv, fallbackPath),
}),
}));

Expand Down Expand Up @@ -132,10 +135,10 @@ function buildEcosystem(sourceEnv = process.env) {
VIKA_WEB_PORT: '3737',
VIKA_WEB_DEFAULT_INSTANCE: deployment.defaultInstance,
VIKA_WEB_INSTANCES: webTargetsJson,
PATH: `${inheritedPath}:${fallbackPath}`,
PATH: ecosystemSearchPath(sourceEnv, fallbackPath),
},
},
{
...(capabilities.updater ? [{
...common,
name: 'vika-updater',
script: path.join(updaterDir, 'src', 'main.mjs'),
Expand All @@ -154,9 +157,9 @@ function buildEcosystem(sourceEnv = process.env) {
// The updater drives the same pm2 daemon the vika command uses.
PM2_HOME: sourceEnv.PM2_HOME || path.join(baseDir, 'pm2'),
PM2_BIN: path.join(releaseDir, 'bin', 'pm2'),
PATH: `${inheritedPath}:${fallbackPath}`,
PATH: ecosystemSearchPath(sourceEnv, fallbackPath),
},
},
}] : []),
],
};
}
Expand Down
2 changes: 1 addition & 1 deletion vika/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"start": "node packages/daemon/src/main.mjs",
"start:daemon": "node packages/daemon/src/main.mjs",
"start:web": "node packages/web/src/main.mjs",
"check": "for file in scripts/*.sh bin/pm2; do sh -n \"$file\" || exit 1; done && for file in scripts/*.mjs scripts/release/*.mjs packages/daemon/src/*.mjs packages/daemon/src/actions/*.mjs packages/daemon/src/connectors/*.mjs packages/daemon/src/extensions/*.mjs packages/daemon/src/meeting/*.mjs packages/daemon/src/qq/*.mjs packages/daemon/src/telegram/*.mjs packages/daemon/src/slack/*.mjs packages/daemon/src/weixin/*.mjs packages/daemon/src/email/*.mjs packages/daemon/scripts/*.mjs packages/web/src/*.mjs packages/web/scripts/*.mjs packages/web/public/*.js packages/updater/src/*.mjs packages/cli/src/*.mjs packages/cli/bin/*.mjs; do node --check \"$file\" || exit 1; done",
"check": "for file in scripts/*.sh bin/pm2; do sh -n \"$file\" || exit 1; done && for file in scripts/*.mjs scripts/release/*.mjs packages/daemon/src/*.mjs packages/daemon/src/platform/*.mjs packages/daemon/src/actions/*.mjs packages/daemon/src/connectors/*.mjs packages/daemon/src/extensions/*.mjs packages/daemon/src/meeting/*.mjs packages/daemon/src/qq/*.mjs packages/daemon/src/telegram/*.mjs packages/daemon/src/slack/*.mjs packages/daemon/src/weixin/*.mjs packages/daemon/src/email/*.mjs packages/daemon/scripts/*.mjs packages/web/src/*.mjs packages/web/scripts/*.mjs packages/web/public/*.js packages/updater/src/*.mjs packages/cli/src/*.mjs packages/cli/bin/*.mjs; do node --check \"$file\" || exit 1; done",
"test": "node --test packages/daemon/test/*.test.mjs packages/web/test/*.test.mjs packages/updater/test/*.test.mjs packages/cli/test/*.test.mjs",
"simulator:claude-runtime": "node packages/daemon/simulator/claude-runtime-simulator.mjs",
"health": "node packages/web/scripts/healthcheck.mjs"
Expand Down
21 changes: 14 additions & 7 deletions vika/packages/cli/src/autostart.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
// SPDX-License-Identifier: AGPL-3.0

import * as defaultPlatform from '../../daemon/src/platform/index.mjs';
import { capabilitiesFor } from '../../daemon/src/capabilities.mjs';

import { execFile as execFileCallback } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
Expand Down Expand Up @@ -61,19 +64,19 @@ export function launchAgent({ homeDir, pathValue }) {
}

function targets(homeDir, platform) {
return platform === 'darwin'
return platform.loginService === 'launchd'
? { file: path.join(homeDir, 'Library', 'LaunchAgents', `${LABEL}.plist`) }
: { file: path.join(homeDir, '.config', 'systemd', 'user', 'vika.service') };
}

export function autostartEnabled({ homeDir = os.homedir(), platform = process.platform } = {}) {
return fs.existsSync(targets(homeDir, platform).file);
export function autostartEnabled({ homeDir = os.homedir(), platform = defaultPlatform } = {}) {
return capabilitiesFor(platform).autostart && fs.existsSync(targets(homeDir, platform).file);
}

export async function autostartCommand([action, ...extra], {
env = process.env,
homeDir = os.homedir(),
platform = process.platform,
platform = defaultPlatform,
execFileImpl = execFile,
output = process.stdout,
uid = process.getuid?.(),
Expand All @@ -82,18 +85,22 @@ export async function autostartCommand([action, ...extra], {
output.write('usage: vika autostart <enable|disable>\n');
return 2;
}
if (!capabilitiesFor(platform).autostart) {
output.write('Autostart is not supported in the Windows preview\n');
return 1;
}
const { file } = targets(homeDir, platform);
if (action === 'disable') {
if (platform === 'darwin') await execFileImpl('launchctl', ['bootout', `gui/${uid}`, file]).catch(() => {});
if (platform.loginService === 'launchd') await execFileImpl('launchctl', ['bootout', `gui/${uid}`, file]).catch(() => {});
else await execFileImpl('systemctl', ['--user', 'disable', '--now', 'vika.service']).catch(() => {});
fs.rmSync(file, { force: true });
if (platform !== 'darwin') await execFileImpl('systemctl', ['--user', 'daemon-reload']).catch(() => {});
if (platform.loginService !== 'launchd') await execFileImpl('systemctl', ['--user', 'daemon-reload']).catch(() => {});
output.write(t('开机自启已关闭\n', 'Autostart is off\n'));
return 0;
}
const pathValue = env.PATH || '/usr/bin:/bin';
fs.mkdirSync(path.dirname(file), { recursive: true });
if (platform === 'darwin') {
if (platform.loginService === 'launchd') {
fs.mkdirSync(path.join(homeDir, '.vika', 'logs'), { recursive: true });
fs.writeFileSync(file, launchAgent({ homeDir, pathValue }));
await execFileImpl('launchctl', ['bootout', `gui/${uid}`, file]).catch(() => {});
Expand Down
15 changes: 11 additions & 4 deletions vika/packages/cli/src/control.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
// SPDX-License-Identifier: AGPL-3.0

import { execFile as execFileCallback, spawn } from 'node:child_process';
import { pm2Bin as platformPm2Bin } from '../../updater/src/pm2-platform.mjs';

import { capabilities } from '../../daemon/src/capabilities.mjs';

import { homeDir } from '../../daemon/src/platform/index.mjs';

import { execFile as execFileCallback, spawn } from '../../daemon/src/platform/index.mjs';
import fs from 'node:fs';
import { realpath } from 'node:fs/promises';
import http from 'node:http';
Expand Down Expand Up @@ -33,11 +39,11 @@ const UPDATER_APP = 'vika-updater';
const RELEASE_ROOT = fileURLToPath(new URL('../../../', import.meta.url));

export function pm2Defaults(env = process.env) {
const releasePm2 = path.join(RELEASE_ROOT, 'bin', 'pm2');
const releasePm2 = platformPm2Bin(RELEASE_ROOT);
return {
pm2Bin: env.PM2_BIN || (fs.existsSync(releasePm2) ? releasePm2 : 'pm2'),
// Vika's own pm2 daemon, apart from any pm2 the user runs.
pm2Env: cleanPm2ControlEnv({ ...env, PM2_HOME: env.PM2_HOME || path.join(env.HOME || '', '.vika', 'pm2') }),
pm2Env: cleanPm2ControlEnv({ ...env, PM2_HOME: env.PM2_HOME || path.join(homeDir(env) || '', '.vika', 'pm2') }),
};
}

Expand All @@ -63,7 +69,8 @@ export function appsFor(target, targets = loadTargets()) {
const instances = Object.entries(targets).map(([id, spec]) => ({ id, ...spec }));
const web = { id: 'web', ...SHARED_WEB };
const updater = { id: 'updater', app: UPDATER_APP };
if (target === undefined) return [...instances, web, updater];
if (target === undefined) return [...instances, web, ...(capabilities.updater ? [updater] : [])];
if (target === 'updater' && !capabilities.updater) throw new Error('Windows source installations do not support the release updater.');
if (target === 'web') return [web];
if (target === 'updater') return [updater];
const instance = instances.find((spec) => spec.id === target);
Expand Down
2 changes: 1 addition & 1 deletion vika/packages/cli/src/lark-cli.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
// SPDX-License-Identifier: AGPL-3.0

import { spawn } from 'node:child_process';
import { spawn } from '../../daemon/src/platform/index.mjs';

// The lark-cli calls setup needs: write the bot profile, authorize the owner
// as a user (the second QR code), read who authorized, send a greeting, list
Expand Down
16 changes: 7 additions & 9 deletions vika/packages/cli/src/qr.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
// SPDX-License-Identifier: AGPL-3.0

import * as defaultPlatform from '../../daemon/src/platform/index.mjs';

import { spawn } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
Expand All @@ -22,14 +24,10 @@ export function qrLines(url) {
}

// The program that opens a link on this machine's desktop; none on a server.
export function opener(env = process.env, platform = process.platform) {
if (platform === 'darwin') return 'open';
if (platform === 'linux' && (env.DISPLAY || env.WAYLAND_DISPLAY)) return 'xdg-open';
return null;
}
export { urlOpenCommand } from '../../daemon/src/platform/index.mjs';

export function openUrl(url, { env = process.env, platform = process.platform } = {}) {
const program = opener(env, platform);
export function openUrl(url, { env = process.env, platform = defaultPlatform } = {}) {
const program = platform.urlOpenCommand(env);
if (!program) return false;
try {
spawn(program, [url], { detached: true, stdio: 'ignore' }).on('error', () => {}).unref();
Expand Down Expand Up @@ -81,8 +79,8 @@ export function showScan(prompter, {
fs.writeFileSync(imagePath, qrPng(matrix), { mode: 0o600, flag: 'wx' });
process.on('exit', cleanupImage);
} catch { cleanupImage(); imageDirectory = null; imagePath = null; }
const canOpen = Boolean(opener(env));
const imageOpener = env.TERM_PROGRAM === 'vscode' || env.VSCODE_IPC_HOOK_CLI ? 'code' : opener(env);
const canOpen = Boolean(defaultPlatform.urlOpenCommand(env));
const imageOpener = env.TERM_PROGRAM === 'vscode' || env.VSCODE_IPC_HOOK_CLI ? 'code' : defaultPlatform.urlOpenCommand(env);
const unopened = () => say(t(`打不开,图片在 ${imagePath}`, `Could not open it; the image is at ${imagePath}`));
const actions = {
...(canOpen ? { o: [t('浏览器打开', 'open in browser'), () => {
Expand Down
6 changes: 4 additions & 2 deletions vika/packages/cli/src/runtime-probe.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
// SPDX-License-Identifier: AGPL-3.0

import { spawn } from 'node:child_process';
import { spawnDetached } from '../../daemon/src/platform/index.mjs';

import { spawn } from '../../daemon/src/platform/index.mjs';
import { sanitizeAgentChildEnv, terminateProcessTree } from '../../daemon/src/process-utils.mjs';
import { captureStartupStderr } from '../../daemon/src/runtime-diagnostics.mjs';
import { safeError } from '../../daemon/src/logger.mjs';
Expand All @@ -14,7 +16,7 @@ function probeInitialize(bin, { args, label, request, onAccepted = () => {}, env
try {
child = spawnImpl(bin, args, {
env: sanitizeAgentChildEnv(env), shell: false,
detached: process.platform !== 'win32', stdio: ['pipe', 'pipe', 'pipe'],
detached: spawnDetached, stdio: ['pipe', 'pipe', 'pipe'],
});
} catch (error) {
resolve({ compatible: false, reason: safeError(error).slice(0, 2000) });
Expand Down
14 changes: 3 additions & 11 deletions vika/packages/cli/src/runtimes.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
// SPDX-License-Identifier: AGPL-3.0

import { execFile as execFileCallback } from 'node:child_process';
import { execFile as execFileCallback } from '../../daemon/src/platform/index.mjs';
import fs from 'node:fs';
import path from 'node:path';
import { promisify } from 'node:util';
Expand All @@ -15,16 +15,8 @@ import { probeAcp, probeAppServer } from './runtime-probe.mjs';

const execFile = promisify(execFileCallback);

export function which(command, env = process.env) {
for (const directory of String(env.PATH || '').split(path.delimiter).filter(Boolean)) {
const candidate = path.join(directory, command);
try {
fs.accessSync(candidate, fs.constants.X_OK);
if (fs.statSync(candidate).isFile()) return candidate;
} catch {}
}
return null;
}
export { findExecutable as which } from '../../daemon/src/platform/index.mjs';
import { findExecutable as which } from '../../daemon/src/platform/index.mjs';

async function run(execFileImpl, command, args, env) {
try {
Expand Down
Loading