chore(lint): clean up cli package warnings

This commit is contained in:
Mohamed Boudra
2026-04-23 23:12:13 +07:00
parent 31f1484150
commit dffd8c4343
18 changed files with 742 additions and 631 deletions
@@ -147,14 +147,6 @@ async function test_verify_logs(agentId: string): Promise<void> {
// Logs should have content from both tasks
assert(result.stdout.length > 0, "Logs should have content");
// The agent was asked to say specific things, check if either appears in logs
// This is a loose check since exact log format may vary
const logsLower = result.stdout.toLowerCase();
const hasInitialTask =
logsLower.includes("initial") || logsLower.includes("hello") || logsLower.includes("task");
const hasFollowUp =
logsLower.includes("follow") || logsLower.includes("complete") || logsLower.includes("task");
// At minimum, there should be log entries (we can't guarantee exact content)
assert(result.stdout.split("\n").length > 3, "Should have multiple log entries from both tasks");
+28 -21
View File
@@ -64,6 +64,29 @@ function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
interface PermitResult {
exitCode: number;
stdout: string;
}
function findMatchingPermission(
result: PermitResult,
agentId: string,
): { agentId?: string } | undefined {
if (result.exitCode !== 0) return undefined;
try {
const permissions = JSON.parse(result.stdout.trim());
if (!Array.isArray(permissions) || permissions.length === 0) return undefined;
return permissions.find(
(p: { agentId?: string }) =>
p.agentId?.startsWith(agentId.slice(0, 7)) ||
agentId.startsWith(p.agentId?.slice(0, 7) || ""),
);
} catch {
return undefined;
}
}
async function test_create_agent_with_permissions(): Promise<string> {
console.log("\n--- Test: Create agent in default mode (will request permissions) ---");
@@ -111,28 +134,12 @@ async function test_wait_for_permission_request(agentId: string): Promise<void>
while (Date.now() - startTime < maxWait) {
const result = await ctx.paseo(["permit", "ls", "--json"]);
if (result.exitCode === 0) {
try {
const permissions = JSON.parse(result.stdout.trim());
if (Array.isArray(permissions) && permissions.length > 0) {
// Check if any permission is for our agent
const ourPermission = permissions.find(
(p: { agentId?: string }) =>
p.agentId?.startsWith(agentId.slice(0, 7)) ||
agentId.startsWith(p.agentId?.slice(0, 7) || ""),
);
if (ourPermission) {
console.log("Permission request detected:", ourPermission);
console.log("PASS: Agent requested permission");
return;
}
}
} catch {
// JSON parse failed, continue polling
}
const ourPermission = findMatchingPermission(result, agentId);
if (ourPermission) {
console.log("Permission request detected:", ourPermission);
console.log("PASS: Agent requested permission");
return;
}
await sleep(pollInterval);
}
+6 -13
View File
@@ -126,24 +126,17 @@ async function terminateProcessTree(processRef: ChildProcess, timeoutMs: number)
signalProcessTree(pid, "SIGTERM");
await new Promise<void>((resolve) => {
let settled = false;
const finish = () => {
if (settled) {
return;
}
settled = true;
const done = () => resolve();
const onExit = () => {
clearTimeout(timeoutId);
resolve();
done();
};
const timeoutId = setTimeout(() => {
signalProcessTree(pid, "SIGKILL");
finish();
processRef.removeListener("exit", onExit);
done();
}, timeoutMs);
processRef.once("exit", () => {
finish();
});
processRef.once("exit", onExit);
});
}