refactor: replace agent_list polling with request/response RPC pattern
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { Command } from 'commander'
|
||||
import { connectToDaemon, getDaemonHost, resolveAgentId } from '../../utils/client.js'
|
||||
import { connectToDaemon, getDaemonHost } from '../../utils/client.js'
|
||||
import type { CommandOptions, SingleResult, OutputSchema, CommandError } from '../../output/index.js'
|
||||
|
||||
/** Result type for agent stop command */
|
||||
@@ -53,13 +53,7 @@ export async function runStopCommand(
|
||||
}
|
||||
|
||||
try {
|
||||
// Request agent list
|
||||
client.requestAgentList()
|
||||
|
||||
// Wait a moment for the agent list to be populated
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
|
||||
let agents = client.listAgents()
|
||||
let agents = await client.fetchAgents()
|
||||
const stoppedIds: string[] = []
|
||||
|
||||
if (options.all) {
|
||||
@@ -76,8 +70,8 @@ export async function runStopCommand(
|
||||
})
|
||||
} else if (id) {
|
||||
// Stop specific agent
|
||||
const resolvedId = resolveAgentId(id, agents)
|
||||
if (!resolvedId) {
|
||||
const agent = await client.fetchAgent(id)
|
||||
if (!agent) {
|
||||
const error: CommandError = {
|
||||
code: 'AGENT_NOT_FOUND',
|
||||
message: `No agent found matching: ${id}`,
|
||||
@@ -85,7 +79,7 @@ export async function runStopCommand(
|
||||
}
|
||||
throw error
|
||||
}
|
||||
agents = agents.filter((a) => a.id === resolvedId)
|
||||
agents = [agent]
|
||||
}
|
||||
|
||||
// Stop each agent
|
||||
|
||||
Reference in New Issue
Block a user