refactor: rename session_state to agent_list and add subscriptions

This commit is contained in:
Mohamed Boudra
2026-01-30 13:39:40 +07:00
parent 5b32d0a56c
commit 0618dc6b0d
45 changed files with 2163 additions and 257 deletions
+18
View File
@@ -1,4 +1,6 @@
import { Command } from 'commander'
import { homedir } from 'node:os'
import { join } from 'node:path'
import { createAgentCommand } from './commands/agent/index.js'
import { createDaemonCommand } from './commands/daemon/index.js'
import { createPermitCommand } from './commands/permit/index.js'
@@ -13,6 +15,7 @@ import { runInspectCommand } from './commands/agent/inspect.js'
import { runWaitCommand } from './commands/agent/wait.js'
import { runAttachCommand } from './commands/agent/attach.js'
import { withOutput } from './output/index.js'
import { runSelfIdBridge } from '@paseo/server/self-id-bridge'
const VERSION = '0.1.0'
@@ -142,5 +145,20 @@ export function createCli(): Command {
// Worktree commands
program.addCommand(createWorktreeCommand())
// Self-ID bridge command (for internal use by agents to call set_title/set_branch)
program
.command('self-id-bridge')
.description('Stdio-to-HTTP bridge for Agent Self-ID MCP (internal use)')
.option('--socket <path>', 'Unix socket path', join(process.env.PASEO_HOME ?? join(homedir(), '.paseo'), 'self-id-mcp.sock'))
.option('--agent-id <id>', 'Caller agent ID')
.option('--debug', 'Enable debug logging to stderr')
.action(async (options) => {
await runSelfIdBridge({
socketPath: options.socket,
agentId: options.agentId,
debug: options.debug,
})
})
return program
}
+3 -3
View File
@@ -58,10 +58,10 @@ export async function runArchiveCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -118,10 +118,10 @@ export async function runAttachCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait for session state to be populated
// Wait for agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -217,10 +217,10 @@ export async function runInspectCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -92,10 +92,10 @@ export async function runLogsCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait for session state to be populated
// Wait for agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+2 -2
View File
@@ -115,8 +115,8 @@ export async function runLsCommand(
}
try {
// Request and wait for session state to get agent information
await client.waitForSessionState()
// Request and wait for agent list
await client.waitForAgentList()
let agents = client.listAgents()
+3 -3
View File
@@ -72,10 +72,10 @@ export async function runModeCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -140,10 +140,10 @@ export async function runSendCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -53,10 +53,10 @@ export async function runStopCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
let agents = client.listAgents()
+3 -3
View File
@@ -121,10 +121,10 @@ export async function runWaitCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -72,10 +72,10 @@ export async function runStatusCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+2 -2
View File
@@ -79,8 +79,8 @@ export async function runAllowCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+2 -2
View File
@@ -45,8 +45,8 @@ export async function runDenyCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -57,10 +57,10 @@ export async function runLsCommand(options: PermitLsOptions, _command: Command):
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+3 -3
View File
@@ -63,10 +63,10 @@ export async function runLsCommand(
}
try {
// Request session state to get agent information
client.requestSessionState()
// Request agent list
client.requestAgentList()
// Wait a moment for the session state to be populated
// Wait a moment for the agent list to be populated
await new Promise((resolve) => setTimeout(resolve, 500))
const agents = client.listAgents()
+1
View File
@@ -56,6 +56,7 @@ export async function connectToDaemon(options?: ConnectOptions): Promise<DaemonC
try {
await Promise.race([connectPromise, timeoutPromise])
client.subscribeAgentUpdates({ subscriptionId: `cli:${process.pid}` })
return client
} catch (err) {
await client.close().catch(() => {})