refactor: replace agent_list polling with request/response RPC pattern

This commit is contained in:
Mohamed Boudra
2026-02-01 22:37:32 +07:00
parent 8971295c4d
commit bf9555829b
59 changed files with 2979 additions and 3637 deletions
+4 -21
View File
@@ -1,6 +1,6 @@
import type { Command } from 'commander'
import type { AgentPermissionRequest } from '@paseo/server'
import { connectToDaemon, getDaemonHost, resolveAgentId } from '../../utils/client.js'
import { connectToDaemon, getDaemonHost } from '../../utils/client.js'
import type { CommandOptions, ListResult, OutputSchema, CommandError } from '../../output/index.js'
/** Permission response item for display */
@@ -79,15 +79,8 @@ export async function runAllowCommand(
}
try {
// Request agent list
client.requestAgentList()
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
// Resolve agent ID
const resolvedAgentId = resolveAgentId(agentIdOrPrefix, agents)
if (!resolvedAgentId) {
const agent = await client.fetchAgent(agentIdOrPrefix)
if (!agent) {
await client.close()
const error: CommandError = {
code: 'AGENT_NOT_FOUND',
@@ -96,17 +89,7 @@ export async function runAllowCommand(
}
throw error
}
// Find the agent
const agent = agents.find((a) => a.id === resolvedAgentId)
if (!agent) {
await client.close()
const error: CommandError = {
code: 'AGENT_NOT_FOUND',
message: `Agent not found: ${resolvedAgentId}`,
}
throw error
}
const resolvedAgentId = agent.id
// Get pending permissions for this agent
const pendingPermissions = agent.pendingPermissions || []
+4 -21
View File
@@ -1,6 +1,6 @@
import type { Command } from 'commander'
import type { AgentPermissionRequest } from '@paseo/server'
import { connectToDaemon, getDaemonHost, resolveAgentId } from '../../utils/client.js'
import { connectToDaemon, getDaemonHost } from '../../utils/client.js'
import type { CommandOptions, ListResult, CommandError } from '../../output/index.js'
import { permitResponseSchema, type PermissionResponseItem } from './allow.js'
@@ -45,15 +45,8 @@ export async function runDenyCommand(
}
try {
// Request agent list
client.requestAgentList()
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
// Resolve agent ID
const resolvedAgentId = resolveAgentId(agentIdOrPrefix, agents)
if (!resolvedAgentId) {
const agent = await client.fetchAgent(agentIdOrPrefix)
if (!agent) {
await client.close()
const error: CommandError = {
code: 'AGENT_NOT_FOUND',
@@ -62,17 +55,7 @@ export async function runDenyCommand(
}
throw error
}
// Find the agent
const agent = agents.find((a) => a.id === resolvedAgentId)
if (!agent) {
await client.close()
const error: CommandError = {
code: 'AGENT_NOT_FOUND',
message: `Agent not found: ${resolvedAgentId}`,
}
throw error
}
const resolvedAgentId = agent.id
// Get pending permissions for this agent
const pendingPermissions = agent.pendingPermissions || []
+1 -7
View File
@@ -57,13 +57,7 @@ export async function runLsCommand(options: PermitLsOptions, _command: Command):
}
try {
// Request agent list
client.requestAgentList()
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
const agents = await client.fetchAgents()
await client.close()
// Collect all pending permissions from all agents