Switch to double quotes and reformat codebase with Biome

This commit is contained in:
Mohamed Boudra
2026-03-21 20:22:15 +07:00
parent ab40786882
commit f6579dbeb4
805 changed files with 38132 additions and 40175 deletions
+47 -41
View File
@@ -1,88 +1,94 @@
import type { Command } from 'commander'
import type { AgentPermissionRequest, AgentSnapshotPayload } from '@getpaseo/server'
import { connectToDaemon, getDaemonHost } from '../../utils/client.js'
import type { CommandOptions, ListResult, OutputSchema, CommandError } from '../../output/index.js'
import type { Command } from "commander";
import type { AgentPermissionRequest, AgentSnapshotPayload } from "@getpaseo/server";
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
import type { CommandOptions, ListResult, OutputSchema, CommandError } from "../../output/index.js";
/** Permission list item for display */
export interface PermissionListItem {
id: string
agentId: string
agentShortId: string
name: string
description: string
id: string;
agentId: string;
agentShortId: string;
name: string;
description: string;
}
/** Schema for permit ls output */
export const permitLsSchema: OutputSchema<PermissionListItem> = {
idField: 'id',
idField: "id",
columns: [
{ header: 'AGENT', field: 'agentShortId', width: 12 },
{ header: 'REQ_ID', field: 'id', width: 12 },
{ header: 'TOOL', field: 'name', width: 20 },
{ header: 'DESCRIPTION', field: 'description', width: 50 },
{ header: "AGENT", field: "agentShortId", width: 12 },
{ header: "REQ_ID", field: "id", width: 12 },
{ header: "TOOL", field: "name", width: 20 },
{ header: "DESCRIPTION", field: "description", width: 50 },
],
}
};
/** Transform agent snapshot + permission to list item */
function toListItem(agent: AgentSnapshotPayload, permission: AgentPermissionRequest): PermissionListItem {
function toListItem(
agent: AgentSnapshotPayload,
permission: AgentPermissionRequest,
): PermissionListItem {
return {
id: permission.id.slice(0, 8),
agentId: agent.id,
agentShortId: agent.id.slice(0, 7),
name: permission.name,
description: permission.description ?? '-',
}
description: permission.description ?? "-",
};
}
export type PermitLsResult = ListResult<PermissionListItem>
export type PermitLsResult = ListResult<PermissionListItem>;
export interface PermitLsOptions extends CommandOptions {
host?: string
host?: string;
}
export async function runLsCommand(options: PermitLsOptions, _command: Command): Promise<PermitLsResult> {
const host = getDaemonHost({ host: options.host })
export async function runLsCommand(
options: PermitLsOptions,
_command: Command,
): Promise<PermitLsResult> {
const host = getDaemonHost({ host: options.host });
let client
let client;
try {
client = await connectToDaemon({ host: options.host })
client = await connectToDaemon({ host: options.host });
} catch (err) {
const message = err instanceof Error ? err.message : String(err)
const message = err instanceof Error ? err.message : String(err);
const error: CommandError = {
code: 'DAEMON_NOT_RUNNING',
code: "DAEMON_NOT_RUNNING",
message: `Cannot connect to daemon at ${host}: ${message}`,
details: 'Start the daemon with: paseo daemon start',
}
throw error
details: "Start the daemon with: paseo daemon start",
};
throw error;
}
try {
const agentsPayload = await client.fetchAgents({ filter: { includeArchived: true } })
const agents = agentsPayload.entries.map((entry) => entry.agent)
await client.close()
const agentsPayload = await client.fetchAgents({ filter: { includeArchived: true } });
const agents = agentsPayload.entries.map((entry) => entry.agent);
await client.close();
// Collect all pending permissions from all agents
const items: PermissionListItem[] = []
const items: PermissionListItem[] = [];
for (const agent of agents) {
if (agent.pendingPermissions && agent.pendingPermissions.length > 0) {
for (const permission of agent.pendingPermissions) {
items.push(toListItem(agent, permission))
items.push(toListItem(agent, permission));
}
}
}
return {
type: 'list',
type: "list",
data: items,
schema: permitLsSchema,
}
};
} catch (err) {
await client.close().catch(() => {})
const message = err instanceof Error ? err.message : String(err)
await client.close().catch(() => {});
const message = err instanceof Error ? err.message : String(err);
const error: CommandError = {
code: 'LIST_PERMISSIONS_FAILED',
code: "LIST_PERMISSIONS_FAILED",
message: `Failed to list permissions: ${message}`,
}
throw error
};
throw error;
}
}