fix(coding): resolve packaged Pi imports from runtime root
This commit is contained in:
1 parent
301c1496b0
commit
5d7a235987
3 files changed
+123
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment node
|
||||
|
||||
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import { copyFile, mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import { createServer, type ServerResponse } from 'node:http';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
@@ -165,6 +165,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);
|
||||
|
||||
Reference in new issue
Block a user