You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by wy...@apache.org on 2026/09/16 01:18:31 UTC
(maka) 12/29: feat(desktop): accept native host operators across SSH and WSL
This is an automated email from the ASF dual-hosted git repository.
M4n5ter pushed a commit to branch feat/runtime-host-rust
in repository https://gitbox.apache.org/repos/asf/maka.git
commit 4e66509fce68aa10b0f8812fe9f3742794e01991
Author: Wang <m4...@gmail.com>
AuthorDate: Tue Sep 15 16:41:58 2026 +0800
feat(desktop): accept native host operators across SSH and WSL
Generated-by: OpenAI Codex
---
.../__tests__/runtime-host-wsl-controller.test.ts | 13 +++---
apps/desktop/src/main/runtime-host-onboarding.ts | 3 +-
.../src/main/runtime-host-wsl-controller.ts | 11 +++--
.../src/__tests__/ssh-operator-activation.test.ts | 38 ++++++++++++++++
.../src/client/ssh-operator-activation.ts | 8 ++--
packages/runtime-host/src/operator/index.ts | 2 +
.../runtime-host/src/operator/operator-command.ts | 50 ++++++++++++++++++++++
packages/runtime-host/src/operator/setup-frame.ts | 4 +-
8 files changed, 111 insertions(+), 18 deletions(-)
diff --git a/apps/desktop/src/main/__tests__/runtime-host-wsl-controller.test.ts b/apps/desktop/src/main/__tests__/runtime-host-wsl-controller.test.ts
index 67e0c24cdc..78688e36cf 100644
--- a/apps/desktop/src/main/__tests__/runtime-host-wsl-controller.test.ts
+++ b/apps/desktop/src/main/__tests__/runtime-host-wsl-controller.test.ts
@@ -66,7 +66,7 @@ test('WSL management invokes the stable operator directly with the exact deploym
});
const result = await runDesktopRuntimeHostWslManagement({
distribution: 'Ubuntu',
- operator: OPERATOR,
+ operator: { kind: 'native', platform: 'posix', executablePath: '/opt/Maka Host/maka' },
action: 'configure',
expectedTarget: {
serviceId: 'a'.repeat(64),
@@ -102,8 +102,8 @@ test('WSL management invokes the stable operator directly with the exact deploym
'--distribution',
'Ubuntu',
'--exec',
- '/usr/bin/node',
- '/home/operator/.local/share/maka/operator.mjs',
+ '/opt/Maka Host/maka',
+ 'host',
'configure',
]);
assert.ok(launch?.args.includes('--expected-deployment-id'));
@@ -145,7 +145,7 @@ test('WSL setup forwards the development archive and its exact evidence', async
version: '0.2.0-development',
serviceId: 'b'.repeat(64),
deploymentId: '00000000-0000-4000-8000-000000000001',
- operator: { ...OPERATOR, modulePath: '/tmp/maka/operator.mjs' },
+ operator: { kind: 'native', platform: 'posix', executablePath: '/tmp/maka/maka' },
rootPath: '/tmp/maka/root',
rootId: 'a'.repeat(64),
endpoint: 'ws://127.0.0.1:7443/runtime-host',
@@ -160,7 +160,7 @@ test('WSL setup forwards the development archive and its exact evidence', async
};
const integrity = `sha512-${createHash('sha512').update('archive evidence').digest('base64')}`;
- await runDesktopRuntimeHostWslSetup({
+ const installed = await runDesktopRuntimeHostWslSetup({
distribution: 'Ubuntu',
setupPackage: {
kind: 'development_archive',
@@ -170,6 +170,9 @@ test('WSL setup forwards the development archive and its exact evidence', async
principalId: 'desktop-owner:pairing',
}, () => undefined, undefined, { processFactory, wslExecutable: 'wsl.exe' });
+ assert.deepEqual(installed.operator, {
+ kind: 'native', platform: 'posix', executablePath: '/tmp/maka/maka',
+ });
assert.deepEqual(launches[0], [
'--distribution',
'Ubuntu',
diff --git a/apps/desktop/src/main/runtime-host-onboarding.ts b/apps/desktop/src/main/runtime-host-onboarding.ts
index 14dac44db2..54e55b0b92 100644
--- a/apps/desktop/src/main/runtime-host-onboarding.ts
+++ b/apps/desktop/src/main/runtime-host-onboarding.ts
@@ -22,6 +22,7 @@ import type { IpcMain } from 'electron';
import {
parseRuntimeHostSetupEndpoint,
type RuntimeHostNodeOperatorCommand,
+ type RuntimeHostNativeOperatorCommand,
type RuntimeHostOperatorCommand,
type RuntimeHostSetupPhase,
} from '@maka/runtime-host/operator';
@@ -77,7 +78,7 @@ export function createDesktopRuntimeHostOnboarding(input: {
readonly rootPath: string;
readonly serviceId: string;
readonly deploymentId: string;
- readonly operator: RuntimeHostNodeOperatorCommand<'posix'>;
+ readonly operator: RuntimeHostNodeOperatorCommand<'posix'> | RuntimeHostNativeOperatorCommand<'posix'>;
}>;
readonly listWslDistributions: () => Promise<readonly string[]>;
readonly send: (snapshot: DesktopRuntimeHostOnboardingSnapshot) => void;
diff --git a/apps/desktop/src/main/runtime-host-wsl-controller.ts b/apps/desktop/src/main/runtime-host-wsl-controller.ts
index ba440ef916..59ef1a7af1 100644
--- a/apps/desktop/src/main/runtime-host-wsl-controller.ts
+++ b/apps/desktop/src/main/runtime-host-wsl-controller.ts
@@ -32,10 +32,10 @@ import {
RUNTIME_HOST_SERVICE_MANAGEMENT_FRAME_PREFIX,
RUNTIME_HOST_SETUP_FRAME_PREFIX,
RUNTIME_HOST_SETUP_SOURCE_PACKAGE_INTEGRITY_ENV,
- createRuntimeHostOperatorCommand,
decodeRuntimeHostPosixOperatorCommand,
runtimeHostOperatorInvocation,
type RuntimeHostNodeOperatorCommand,
+ type RuntimeHostNativeOperatorCommand,
type RuntimeHostPosixOperatorCommand,
type RuntimeHostSetupFrame,
type RuntimeHostSetupPhase,
@@ -50,7 +50,7 @@ const WSL_SETUP_STDERR_MAX_BYTES = 8 * 1024;
type RuntimeHostSetupCompleteFrame = Extract<RuntimeHostSetupFrame, { kind: 'complete' | 'existing_environment' }>;
type RuntimeHostWslSetupCompleteFrame = Omit<RuntimeHostSetupCompleteFrame, 'operator'> & {
- readonly operator: RuntimeHostNodeOperatorCommand<'posix'>;
+ readonly operator: RuntimeHostNodeOperatorCommand<'posix'> | RuntimeHostNativeOperatorCommand<'posix'>;
};
type RuntimeHostManagementTerminalFrame = Exclude<
RuntimeHostServiceManagementFrame,
@@ -202,11 +202,10 @@ export async function runDesktopRuntimeHostWslSetup(
}
return {
...frame,
- operator: createRuntimeHostOperatorCommand({
+ operator: {
+ ...frame.operator,
platform: 'posix',
- nodePath: frame.operator.nodePath,
- modulePath: frame.operator.modulePath,
- }),
+ },
};
},
onResult: () => onComplete?.(),
diff --git a/packages/runtime-host/src/__tests__/ssh-operator-activation.test.ts b/packages/runtime-host/src/__tests__/ssh-operator-activation.test.ts
index 927423add1..32d4ef2c95 100644
--- a/packages/runtime-host/src/__tests__/ssh-operator-activation.test.ts
+++ b/packages/runtime-host/src/__tests__/ssh-operator-activation.test.ts
@@ -36,6 +36,7 @@ import {
encodeRuntimeHostActivationFrame,
} from '../operator/activation-frame.js';
import { RUNTIME_HOST_PROTOCOL_VERSION } from '../protocol/index.js';
+import { decodeRuntimeHostOperatorCommand } from '../operator/operator-command.js';
const ROOT_ID = 'a'.repeat(64);
const execFileAsync = promisify(execFile);
@@ -114,6 +115,43 @@ test('POSIX operator commands apply environment before exec', async (t) => {
const { stdout } = await execFileAsync('/bin/sh', ['-c', command]);
assert.equal(stdout, "value with ' quotes");
+ const native = decodeRuntimeHostOperatorCommand({
+ kind: 'native',
+ platform: 'posix',
+ executablePath: '/bin/echo',
+ });
+ const nativeResult = await execFileAsync('/bin/sh', [
+ '-c',
+ runtimeHostSshOperatorRemoteCommand(native, ['activate', "literal ' $HOME ; value"]),
+ ]);
+ assert.equal(nativeResult.stdout, "host activate literal ' $HOME ; value\n");
+ const windows = runtimeHostSshOperatorRemoteCommand(
+ {
+ kind: 'native',
+ platform: 'win32',
+ executablePath: String.raw`C:\Program Files\Maka\maka.exe`,
+ },
+ ['activate', '--root-id', ROOT_ID],
+ );
+ const script = Buffer.from(windows.split(' ').at(-1)!, 'base64').toString('utf16le');
+ const payload = JSON.parse(
+ Buffer.from(script.match(/FromBase64String\('([^']+)'\)/u)![1], 'base64').toString('utf8'),
+ );
+ assert.equal(payload.executable, String.raw`C:\Program Files\Maka\maka.exe`);
+ assert.deepEqual(payload.args, ['host', 'activate', '--root-id', ROOT_ID]);
+ assert.throws(() =>
+ decodeRuntimeHostOperatorCommand({
+ kind: 'native',
+ platform: 'posix',
+ executablePath: 'maka',
+ }),
+ );
+ assert.throws(() =>
+ decodeRuntimeHostOperatorCommand({
+ ...native,
+ nodePath: '/usr/bin/node',
+ }),
+ );
assert.equal(
runtimeHostSshOperatorRemoteCommand(
{ kind: 'legacy_posix_executable', executablePath: '/opt/maka/operator' },
diff --git a/packages/runtime-host/src/client/ssh-operator-activation.ts b/packages/runtime-host/src/client/ssh-operator-activation.ts
index 3f49f217cf..aae1daecc4 100644
--- a/packages/runtime-host/src/client/ssh-operator-activation.ts
+++ b/packages/runtime-host/src/client/ssh-operator-activation.ts
@@ -143,20 +143,20 @@ export function runtimeHostSshOperatorRemoteCommand(
const deploymentRoot = quotePosix(posix.dirname(operatorPath));
return `if [ ! -e ${artifact} ]; then [ ! -e ${deploymentRoot} ] && exit 0; exit 1; fi; ${execute}`;
}
- if (operator.kind !== 'node') throw new Error('Windows Runtime Host operator must use Node');
+ const operatorPath = operator.kind === 'node' ? operator.modulePath : operator.executablePath;
const payload = Buffer.from(
JSON.stringify({
...invocation,
environment,
- modulePath: operator.modulePath,
- deploymentRoot: win32.dirname(operator.modulePath),
+ operatorPath,
+ deploymentRoot: win32.dirname(operatorPath),
missingOperatorIsSuccess: options.missingOperatorIsSuccess === true,
}),
'utf8',
).toString('base64');
const script = [
`$p=[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${payload}'))|ConvertFrom-Json`,
- `if($p.missingOperatorIsSuccess -and -not (Test-Path -LiteralPath $p.modulePath -PathType Leaf)){if(-not (Test-Path -LiteralPath $p.deploymentRoot)){exit 0}else{exit 1}}`,
+ `if($p.missingOperatorIsSuccess -and -not (Test-Path -LiteralPath $p.operatorPath -PathType Leaf)){if(-not (Test-Path -LiteralPath $p.deploymentRoot)){exit 0}else{exit 1}}`,
`foreach($e in $p.environment.psobject.Properties){[Environment]::SetEnvironmentVariable($e.Name,[string]$e.Value,'Process')}`,
`$code=1`,
`try{& ([string]$p.executable) @($p.args|ForEach-Object {[string]$_});$code=if($null -eq $LASTEXITCODE){1}else{$LASTEXITCODE}}catch{$code=1}`,
diff --git a/packages/runtime-host/src/operator/index.ts b/packages/runtime-host/src/operator/index.ts
index dc28112338..37a2250874 100644
--- a/packages/runtime-host/src/operator/index.ts
+++ b/packages/runtime-host/src/operator/index.ts
@@ -98,6 +98,7 @@ export {
} from './setup-frame.js';
export {
createRuntimeHostOperatorCommand,
+ createRuntimeHostNativeOperatorCommand,
createRuntimeHostLegacyPosixOperatorCommand,
decodeRuntimeHostOperatorCommand,
decodeRuntimeHostPosixOperatorCommand,
@@ -109,6 +110,7 @@ export {
type RuntimeHostPosixOperatorCommand,
type RuntimeHostLegacyPosixOperatorCommand,
type RuntimeHostNodeOperatorCommand,
+ type RuntimeHostNativeOperatorCommand,
} from './operator-command.js';
export {
RUNTIME_HOST_SETUP_SOURCE_PACKAGE_INTEGRITY_ENV,
diff --git a/packages/runtime-host/src/operator/operator-command.ts b/packages/runtime-host/src/operator/operator-command.ts
index 37581840e3..15f4d59d62 100644
--- a/packages/runtime-host/src/operator/operator-command.ts
+++ b/packages/runtime-host/src/operator/operator-command.ts
@@ -33,6 +33,15 @@ export interface RuntimeHostNodeOperatorCommand<
readonly modulePath: string;
}
+/** The native Maka CLI owns the complete host operator command tree. */
+export interface RuntimeHostNativeOperatorCommand<
+ Platform extends RuntimeHostOperatorPlatform = RuntimeHostOperatorPlatform,
+> {
+ readonly kind: 'native';
+ readonly platform: Platform;
+ readonly executablePath: string;
+}
+
/** Compatibility route for managed deployments created before the Node operator shipped. */
export interface RuntimeHostLegacyPosixOperatorCommand {
readonly kind: 'legacy_posix_executable';
@@ -41,10 +50,12 @@ export interface RuntimeHostLegacyPosixOperatorCommand {
export type RuntimeHostOperatorCommand =
| RuntimeHostNodeOperatorCommand
+ | RuntimeHostNativeOperatorCommand
| RuntimeHostLegacyPosixOperatorCommand;
export type RuntimeHostPosixOperatorCommand =
| RuntimeHostNodeOperatorCommand<'posix'>
+ | RuntimeHostNativeOperatorCommand<'posix'>
| RuntimeHostLegacyPosixOperatorCommand;
export function createRuntimeHostOperatorCommand<
@@ -71,6 +82,23 @@ export function createRuntimeHostLegacyPosixOperatorCommand(
});
}
+export function createRuntimeHostNativeOperatorCommand<
+ Platform extends RuntimeHostOperatorPlatform,
+>(input: {
+ readonly platform: Platform;
+ readonly executablePath: string;
+}): RuntimeHostNativeOperatorCommand<Platform> {
+ return Object.freeze({
+ kind: 'native',
+ platform: input.platform,
+ executablePath: requireAbsolutePath(
+ input.executablePath,
+ input.platform,
+ 'operator executable',
+ ),
+ });
+}
+
export function runtimeHostManagedOperatorCommand<Platform extends RuntimeHostOperatorPlatform>(
deployment: {
readonly deploymentRoot: string;
@@ -109,6 +137,19 @@ export function decodeRuntimeHostOperatorCommand(value: unknown): RuntimeHostOpe
);
}
const keys = Object.keys(record).sort();
+ if (record.kind === 'native') {
+ const expected = ['executablePath', 'kind', 'platform'];
+ if (keys.length !== expected.length || keys.some((key, index) => key !== expected[index])) {
+ throw new Error('Runtime Host operator command has unexpected fields');
+ }
+ if (record.platform !== 'posix' && record.platform !== 'win32') {
+ throw new Error('Runtime Host operator platform is invalid');
+ }
+ return createRuntimeHostNativeOperatorCommand({
+ platform: record.platform,
+ executablePath: requireString(record.executablePath, 'Runtime Host operator executable'),
+ });
+ }
const expected = ['kind', 'modulePath', 'nodePath', 'platform'];
if (keys.length !== expected.length || keys.some((key, index) => key !== expected[index])) {
throw new Error('Runtime Host operator command has unexpected fields');
@@ -132,6 +173,12 @@ export function decodeRuntimeHostPosixOperatorCommand(
if (command.platform !== 'posix') {
throw new Error('Runtime Host operator must target POSIX');
}
+ if (command.kind === 'native') {
+ return createRuntimeHostNativeOperatorCommand({
+ platform: 'posix',
+ executablePath: command.executablePath,
+ });
+ }
return createRuntimeHostOperatorCommand({
platform: 'posix',
nodePath: command.nodePath,
@@ -147,6 +194,9 @@ export function runtimeHostOperatorInvocation(
if (normalized.kind === 'legacy_posix_executable') {
return { executable: normalized.executablePath, args };
}
+ if (normalized.kind === 'native') {
+ return { executable: normalized.executablePath, args: ['host', ...args] };
+ }
return {
executable: normalized.nodePath,
args: [normalized.modulePath, ...args],
diff --git a/packages/runtime-host/src/operator/setup-frame.ts b/packages/runtime-host/src/operator/setup-frame.ts
index 24cd3350fa..aab67407e7 100644
--- a/packages/runtime-host/src/operator/setup-frame.ts
+++ b/packages/runtime-host/src/operator/setup-frame.ts
@@ -54,8 +54,8 @@ const environmentBindingFields = {
operator: z.unknown().transform((value, context) => {
try {
const command = decodeRuntimeHostOperatorCommand(value);
- if (command.kind !== 'node') {
- throw new Error('Runtime Host setup operator must be a Node command');
+ if (command.kind === 'legacy_posix_executable') {
+ throw new Error('Runtime Host setup operator must declare its target platform');
}
return command;
} catch (error) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org