feat(coding-runtime): add managed Pi extension host

This commit is contained in:
2026-08-23 09:39:12 +08:00
parent 47159b3cbd
commit 3861c3286a
22 changed files with 1673 additions and 16 deletions

View File

@@ -7,6 +7,7 @@ import { createRequire } from 'node:module';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { PiWorkerProcess } from '../../electron/coding-runtime/pi/worker-process';
import { PiManagedExtensionHost } from '../../electron/coding-runtime/pi/extension-host';
const scratchRoots: string[] = [];
@@ -39,12 +40,23 @@ describe('locked Pi worker process smoke', () => {
const cwd = join(root, 'project');
await Promise.all([mkdir(configDir), mkdir(sessionDir), mkdir(cwd)]);
const extensionHost = new PiManagedExtensionHost();
const extension = await extensionHost.registerWorker({
conversationId: 'real-conversation',
generation: 1,
projectId: 'real-project',
extensionsDir: join(root, 'extensions'),
});
await extensionHost.bindRun('real-conversation', 1, 'real-run');
const worker = await new PiWorkerProcess({
executablePath: electronExecutable,
cliPath: join(packageRoot, 'dist', 'cli.js'),
cwd,
configDir,
sessionDir,
additionalArgs: ['--extension', extension.extensionPath],
env: extension.env,
sensitiveValues: extension.sensitiveValues,
commandTimeoutMs: 5_000,
}).start();
try {
@@ -53,9 +65,12 @@ describe('locked Pi worker process smoke', () => {
command: 'get_state',
success: true,
});
expect(worker.stderrDiagnostic).not.toContain('Failed to load extension');
await expect(worker.stop()).resolves.toMatchObject({ mode: 'stdin-close', code: 0 });
} finally {
await worker.stop().catch(() => undefined);
await extension.dispose();
await extensionHost.close();
}
}, 15_000);
});