merge: integrate packaged Pi runtime resolution

# Conflicts:
#	tests/unit/pi-agent-server-process-real.test.ts
This commit is contained in:
inman
2026-09-03 10:46:18 +08:00
3 changed files with 122 additions and 1 deletions

View File

@@ -196,6 +196,32 @@ afterEach(async () => {
});
describe('Pi Agent Server real process', () => {
it('resolves runtime packages when the server resource is outside the project module tree', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-agent-server-packaged-layout-'));
roots.push(root);
const resourcesDir = path.join(root, 'product-resources', 'resources');
const configDir = path.join(root, 'config');
await Promise.all([
mkdir(resourcesDir, { recursive: true }),
mkdir(configDir, { recursive: true }),
]);
const serverPath = path.join(resourcesDir, 'pi-agent-server.mjs');
await copyFile(path.resolve('resources/pi-agent-server.mjs'), serverPath);
const runtimeRoot = path.resolve('node_modules/@earendil-works/pi-coding-agent');
const server = new PiAgentServerProcess({
executablePath: process.execPath,
serverPath,
runtimeRoot,
configDir,
});
try {
await expect(server.start()).resolves.toBeUndefined();
expect(server.processId).toBeTypeOf('number');
} finally {
await server.stop().catch(() => undefined);
}
}, 10_000);
it('executes two write-leased Bash calls without waiting for the HTTP idle timeout', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-agent-server-bash-batch-'));
roots.push(root);