Pinned pi SDK 0.85.1 bridge, Python supervisor, artifact exporter, scripted backend peer, image checks and boundary checks under agent/**. Review findings F1-F3 are recorded in docs/implementation/PI_AGENT_REVIEW.md.
20 lines
1.3 KiB
TypeScript
20 lines
1.3 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { localTools } from '../local-tools.js';
|
|
test('native shell bounds output and reports timeout as a failed tool', async t => {
|
|
const work = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-local-')); t.after(() => fs.rmSync(work, { recursive: true, force: true }));
|
|
const bash = localTools(work).find(tool => tool.name === 'bash')!;
|
|
await assert.rejects(bash.execute('sdk_output', { command: "python3 -c 'import sys; sys.stdout.write(\"x\"*2000000)'" }), /capped at 1 MiB/);
|
|
await assert.rejects(bash.execute('sdk_timeout', { command: 'sleep 10', timeout: 0.05 }), /timed out/);
|
|
});
|
|
test('native reads reject large and nonregular files without blocking', async t => {
|
|
const work = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-read-')); t.after(() => fs.rmSync(work, { recursive: true, force: true }));
|
|
const read = localTools(work).find(tool => tool.name === 'read')!;
|
|
fs.writeFileSync(path.join(work, 'large'), ''); fs.truncateSync(path.join(work, 'large'), 17 * 1024 * 1024);
|
|
await assert.rejects(read.execute('sdk_large', { path: path.join(work, 'large') }), /at most 16 MiB/);
|
|
await assert.rejects(read.execute('sdk_special', { path: '/dev/zero' }), /regular file/);
|
|
});
|