@getpaseo/cli 0.16.0-beta.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
1
  import { Command } from "commander";
2
+ import { connectToDaemon } from "../../utils/client.js";
3
+ import { type AgentLookupClient } from "../../utils/agent-directory.js";
2
4
  import type { CommandOptions, SingleResult, OutputSchema } from "../../output/index.js";
3
5
  /** Result type for agent archive command */
4
6
  export interface AgentArchiveResult {
@@ -14,5 +16,12 @@ export interface AgentArchiveOptions extends CommandOptions {
14
16
  host?: string;
15
17
  }
16
18
  export type AgentArchiveCommandResult = SingleResult<AgentArchiveResult>;
19
+ export interface AgentArchiveClient extends AgentLookupClient {
20
+ archiveAgent(agentId: string): Promise<{
21
+ archivedAt: string;
22
+ }>;
23
+ close(): Promise<void>;
24
+ }
17
25
  export declare function runArchiveCommand(agentIdArg: string, options: AgentArchiveOptions, _command: Command): Promise<AgentArchiveCommandResult>;
26
+ export declare function archiveAgent(agentIdArg: string, options: AgentArchiveOptions, connect?: (options: Parameters<typeof connectToDaemon>[0]) => Promise<AgentArchiveClient>): Promise<AgentArchiveCommandResult>;
18
27
  //# sourceMappingURL=archive.d.ts.map
@@ -1,5 +1,5 @@
1
- import { connectToDaemon, resolveAgentId } from "../../utils/client.js";
2
- import { fetchAllAgents } from "../../utils/agent-directory.js";
1
+ import { connectToDaemon } from "../../utils/client.js";
2
+ import { resolveAgentEntry } from "../../utils/agent-directory.js";
3
3
  /** Schema for archive command output */
4
4
  export const archiveSchema = {
5
5
  idField: "agentId",
@@ -16,6 +16,9 @@ export function addArchiveOptions(cmd) {
16
16
  .option("--force", "Force archive running agent (interrupts active run first)");
17
17
  }
18
18
  export async function runArchiveCommand(agentIdArg, options, _command) {
19
+ return archiveAgent(agentIdArg, options);
20
+ }
21
+ export async function archiveAgent(agentIdArg, options, connect = connectToDaemon) {
19
22
  // Validate arguments
20
23
  if (!agentIdArg || agentIdArg.trim().length === 0) {
21
24
  const error = {
@@ -25,11 +28,10 @@ export async function runArchiveCommand(agentIdArg, options, _command) {
25
28
  };
26
29
  throw error;
27
30
  }
28
- const client = await connectToDaemon({ target: options.daemonTarget });
31
+ const client = await connect({ target: options.daemonTarget });
29
32
  try {
30
- const agents = await fetchAllAgents(client, { filter: { includeArchived: true } });
31
- const agentId = resolveAgentId(agentIdArg, agents);
32
- if (!agentId) {
33
+ const agent = await resolveAgentEntry(client, agentIdArg);
34
+ if (!agent) {
33
35
  const error = {
34
36
  code: "AGENT_NOT_FOUND",
35
37
  message: `Agent not found: ${agentIdArg}`,
@@ -37,10 +39,7 @@ export async function runArchiveCommand(agentIdArg, options, _command) {
37
39
  };
38
40
  throw error;
39
41
  }
40
- const agent = agents.find((entry) => entry.id === agentId);
41
- if (!agent) {
42
- throw new Error(`Resolved agent missing from fetched agents: ${agentId}`);
43
- }
42
+ const agentId = agent.id;
44
43
  // Check if agent is already archived
45
44
  if (agent.archivedAt) {
46
45
  const error = {
@@ -1,9 +1,16 @@
1
1
  import type { Command } from "commander";
2
+ import { connectToDaemon } from "../../utils/client.js";
3
+ import { type AgentLookupClient } from "../../utils/agent-directory.js";
2
4
  import type { CommandOptions, SingleResult } from "../../output/index.js";
3
5
  interface AgentDetachResult {
4
6
  agentId: string;
5
7
  status: "detached";
6
8
  }
9
+ export interface AgentDetachClient extends AgentLookupClient {
10
+ detachAgent(agentId: string): Promise<unknown>;
11
+ close(): Promise<void>;
12
+ }
7
13
  export declare function runDetachCommand(agentIdArg: string, options: CommandOptions, _command: Command): Promise<SingleResult<AgentDetachResult>>;
14
+ export declare function detachAgent(agentIdArg: string, options: CommandOptions, connect?: (options: Parameters<typeof connectToDaemon>[0]) => Promise<AgentDetachClient>): Promise<SingleResult<AgentDetachResult>>;
8
15
  export {};
9
16
  //# sourceMappingURL=detach.d.ts.map
@@ -1,4 +1,5 @@
1
- import { connectToDaemon, resolveAgentId } from "../../utils/client.js";
1
+ import { connectToDaemon } from "../../utils/client.js";
2
+ import { resolveAgentEntry } from "../../utils/agent-directory.js";
2
3
  const detachSchema = {
3
4
  idField: "agentId",
4
5
  columns: [
@@ -7,18 +8,34 @@ const detachSchema = {
7
8
  ],
8
9
  };
9
10
  export async function runDetachCommand(agentIdArg, options, _command) {
10
- const client = await connectToDaemon({ target: options.daemonTarget });
11
+ return detachAgent(agentIdArg, options);
12
+ }
13
+ export async function detachAgent(agentIdArg, options, connect = connectToDaemon) {
14
+ const client = await connect({ target: options.daemonTarget });
11
15
  try {
12
- const payload = await client.fetchAgents({ filter: { includeArchived: true } });
13
- const agentId = resolveAgentId(agentIdArg, payload.entries.map((entry) => entry.agent));
14
- if (!agentId) {
16
+ const agent = await resolveAgentEntry(client, agentIdArg);
17
+ if (!agent) {
15
18
  throw {
16
19
  code: "AGENT_NOT_FOUND",
17
20
  message: `Agent not found: ${agentIdArg}`,
18
21
  };
19
22
  }
20
- await client.detachAgent(agentId);
21
- return { type: "single", data: { agentId, status: "detached" }, schema: detachSchema };
23
+ await client.detachAgent(agent.id);
24
+ return {
25
+ type: "single",
26
+ data: { agentId: agent.id, status: "detached" },
27
+ schema: detachSchema,
28
+ };
29
+ }
30
+ catch (err) {
31
+ if (err && typeof err === "object" && "code" in err) {
32
+ throw err;
33
+ }
34
+ const message = err instanceof Error ? err.message : String(err);
35
+ throw {
36
+ code: "DETACH_FAILED",
37
+ message: `Failed to detach agent: ${message}`,
38
+ };
22
39
  }
23
40
  finally {
24
41
  await client.close().catch(() => undefined);
@@ -1,4 +1,6 @@
1
1
  import { Command } from "commander";
2
+ import { connectToDaemon } from "../../utils/client.js";
3
+ import { type AgentLookupClient } from "../../utils/agent-directory.js";
2
4
  import type { CommandOptions, SingleResult, OutputSchema } from "../../output/index.js";
3
5
  export interface AgentReloadResult {
4
6
  agentId: string;
@@ -11,5 +13,13 @@ export interface AgentReloadOptions extends CommandOptions {
11
13
  host?: string;
12
14
  }
13
15
  export type AgentReloadCommandResult = SingleResult<AgentReloadResult>;
16
+ export interface AgentReloadClient extends AgentLookupClient {
17
+ refreshAgent(agentId: string): Promise<{
18
+ agentId: string;
19
+ timelineSize?: number;
20
+ }>;
21
+ close(): Promise<void>;
22
+ }
14
23
  export declare function runReloadCommand(agentIdArg: string, options: AgentReloadOptions, _command: Command): Promise<AgentReloadCommandResult>;
24
+ export declare function reloadAgent(agentIdArg: string, options: AgentReloadOptions, connect?: (options: Parameters<typeof connectToDaemon>[0]) => Promise<AgentReloadClient>): Promise<AgentReloadCommandResult>;
15
25
  //# sourceMappingURL=reload.d.ts.map
@@ -1,4 +1,5 @@
1
- import { connectToDaemon, resolveAgentId } from "../../utils/client.js";
1
+ import { connectToDaemon } from "../../utils/client.js";
2
+ import { resolveAgentEntry } from "../../utils/agent-directory.js";
2
3
  export const reloadSchema = {
3
4
  idField: "agentId",
4
5
  columns: [
@@ -13,6 +14,9 @@ export function addReloadOptions(cmd) {
13
14
  .argument("<id>", "Agent ID, prefix, or name");
14
15
  }
15
16
  export async function runReloadCommand(agentIdArg, options, _command) {
17
+ return reloadAgent(agentIdArg, options);
18
+ }
19
+ export async function reloadAgent(agentIdArg, options, connect = connectToDaemon) {
16
20
  if (!agentIdArg || agentIdArg.trim().length === 0) {
17
21
  const error = {
18
22
  code: "MISSING_AGENT_ID",
@@ -21,12 +25,10 @@ export async function runReloadCommand(agentIdArg, options, _command) {
21
25
  };
22
26
  throw error;
23
27
  }
24
- const client = await connectToDaemon({ target: options.daemonTarget });
28
+ const client = await connect({ target: options.daemonTarget });
25
29
  try {
26
- const agentsPayload = await client.fetchAgents({ filter: { includeArchived: true } });
27
- const agents = agentsPayload.entries.map((entry) => entry.agent);
28
- const agentId = resolveAgentId(agentIdArg, agents);
29
- if (!agentId) {
30
+ const agent = await resolveAgentEntry(client, agentIdArg);
31
+ if (!agent) {
30
32
  const error = {
31
33
  code: "AGENT_NOT_FOUND",
32
34
  message: `Agent not found: ${agentIdArg}`,
@@ -34,7 +36,7 @@ export async function runReloadCommand(agentIdArg, options, _command) {
34
36
  };
35
37
  throw error;
36
38
  }
37
- const result = await client.refreshAgent(agentId);
39
+ const result = await client.refreshAgent(agent.id);
38
40
  await client.close();
39
41
  return {
40
42
  type: "single",
@@ -1,4 +1,5 @@
1
1
  import { Command } from "commander";
2
+ import { connectToDaemon } from "../../utils/client.js";
2
3
  import type { CommandOptions, SingleResult, OutputSchema } from "../../output/index.js";
3
4
  /** Result type for agent wait command */
4
5
  export interface AgentWaitResult {
@@ -12,6 +13,19 @@ export interface AgentWaitOptions extends CommandOptions {
12
13
  timeout?: string;
13
14
  host?: string;
14
15
  }
16
+ type WaitFinishState = Awaited<ReturnType<Awaited<ReturnType<typeof connectToDaemon>>["waitForFinish"]>>;
17
+ /**
18
+ * Turn the daemon's wait reply into the command result. Throws AGENT_NOT_FOUND when the
19
+ * daemon resolved no agent: it answers an unknown identifier with an error and no agent
20
+ * payload, while an agent that finished in error always comes with its payload.
21
+ */
22
+ export declare function buildWaitResult(args: {
23
+ state: WaitFinishState;
24
+ resolvedAgentId: string;
25
+ recentActivity: string | null;
26
+ timeoutLabel: string | null;
27
+ }): AgentWaitResult;
15
28
  export declare function addWaitOptions(cmd: Command): Command;
16
29
  export declare function runWaitCommand(agentIdArg: string, options: AgentWaitOptions, _command: Command): Promise<SingleResult<AgentWaitResult>>;
30
+ export {};
17
31
  //# sourceMappingURL=wait.d.ts.map
@@ -54,7 +54,12 @@ function parseWaitTimeout(timeout) {
54
54
  };
55
55
  }
56
56
  }
57
- function buildWaitResult(args) {
57
+ /**
58
+ * Turn the daemon's wait reply into the command result. Throws AGENT_NOT_FOUND when the
59
+ * daemon resolved no agent: it answers an unknown identifier with an error and no agent
60
+ * payload, while an agent that finished in error always comes with its payload.
61
+ */
62
+ export function buildWaitResult(args) {
58
63
  const { state, resolvedAgentId, recentActivity, timeoutLabel } = args;
59
64
  if (state.status === "timeout") {
60
65
  const timeoutMessage = timeoutLabel
@@ -77,6 +82,13 @@ function buildWaitResult(args) {
77
82
  };
78
83
  }
79
84
  if (state.status === "error") {
85
+ if (state.final === null) {
86
+ throw {
87
+ code: "AGENT_NOT_FOUND",
88
+ message: state.error ?? `Agent not found: ${resolvedAgentId}`,
89
+ details: "Use `paseo ls` to list available agents",
90
+ };
91
+ }
80
92
  return {
81
93
  agentId: resolvedAgentId,
82
94
  status: "error",
@@ -105,6 +117,7 @@ export async function runWaitCommand(agentIdArg, options, _command) {
105
117
  }
106
118
  const { timeoutMs, timeoutLabel } = parseWaitTimeout(options.timeout);
107
119
  const client = await connectToDaemon({ target: options.daemonTarget });
120
+ let reply;
108
121
  try {
109
122
  try {
110
123
  const state = await client.waitForFinish(agentIdArg, timeoutMs);
@@ -113,11 +126,7 @@ export async function runWaitCommand(agentIdArg, options, _command) {
113
126
  ? await getRecentActivityTranscript(client, resolvedAgentId)
114
127
  : null;
115
128
  await client.close();
116
- return {
117
- type: "single",
118
- data: buildWaitResult({ state, resolvedAgentId, recentActivity, timeoutLabel }),
119
- schema: agentWaitSchema,
120
- };
129
+ reply = { state, resolvedAgentId, recentActivity };
121
130
  }
122
131
  catch (waitErr) {
123
132
  await client.close().catch(() => { });
@@ -143,5 +152,10 @@ export async function runWaitCommand(agentIdArg, options, _command) {
143
152
  };
144
153
  throw error;
145
154
  }
155
+ return {
156
+ type: "single",
157
+ data: buildWaitResult({ ...reply, timeoutLabel }),
158
+ schema: agentWaitSchema,
159
+ };
146
160
  }
147
161
  //# sourceMappingURL=wait.js.map
@@ -1,7 +1,8 @@
1
1
  import type { AgentSnapshotPayload } from "@getpaseo/protocol/messages";
2
- import type { connectToDaemon } from "./client.js";
3
- type FetchAgentsOptions = NonNullable<Parameters<Awaited<ReturnType<typeof connectToDaemon>>["fetchAgents"]>[0]>;
4
- interface AgentDirectoryClient {
2
+ import { type connectToDaemon } from "./client.js";
3
+ type DaemonClient = Awaited<ReturnType<typeof connectToDaemon>>;
4
+ type FetchAgentsOptions = NonNullable<Parameters<DaemonClient["fetchAgents"]>[0]>;
5
+ export interface AgentDirectoryClient {
5
6
  fetchAgents(options?: FetchAgentsOptions): Promise<{
6
7
  entries: {
7
8
  agent: AgentSnapshotPayload;
@@ -11,7 +12,20 @@ interface AgentDirectoryClient {
11
12
  };
12
13
  }>;
13
14
  }
15
+ export interface AgentLookupClient extends AgentDirectoryClient {
16
+ fetchAgent(options: {
17
+ agentId: string;
18
+ }): Promise<{
19
+ agent: AgentSnapshotPayload;
20
+ } | null>;
21
+ }
14
22
  /** Read the complete directory without agents moving between pages as they update. */
15
23
  export declare function fetchAllAgents(client: AgentDirectoryClient, options?: Omit<FetchAgentsOptions, "page" | "sort" | "subscribe">): Promise<AgentSnapshotPayload[]>;
24
+ /**
25
+ * Resolve an agent by ID, prefix, or name from the directory, falling back to
26
+ * `fetch_agent` for agents omitted from `fetch_agents` (for example after their
27
+ * workspace or project was deleted).
28
+ */
29
+ export declare function resolveAgentEntry(client: AgentLookupClient, agentIdArg: string): Promise<AgentSnapshotPayload | null>;
16
30
  export {};
17
31
  //# sourceMappingURL=agent-directory.d.ts.map
@@ -1,3 +1,5 @@
1
+ import { resolveAgentId } from "./client.js";
2
+ const FULL_AGENT_UUID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
1
3
  /** Read the complete directory without agents moving between pages as they update. */
2
4
  export async function fetchAllAgents(client, options = {}) {
3
5
  const agents = [];
@@ -14,4 +16,33 @@ export async function fetchAllAgents(client, options = {}) {
14
16
  } while (cursor);
15
17
  return agents;
16
18
  }
19
+ /**
20
+ * Resolve an agent by ID, prefix, or name from the directory, falling back to
21
+ * `fetch_agent` for agents omitted from `fetch_agents` (for example after their
22
+ * workspace or project was deleted).
23
+ */
24
+ export async function resolveAgentEntry(client, agentIdArg) {
25
+ const trimmed = agentIdArg.trim();
26
+ if (!trimmed) {
27
+ return null;
28
+ }
29
+ const agents = await fetchAllAgents(client, { filter: { includeArchived: true } });
30
+ const listedId = resolveAgentId(agentIdArg, agents);
31
+ if (listedId) {
32
+ const match = agents.find((entry) => entry.id === listedId);
33
+ if (match) {
34
+ return match;
35
+ }
36
+ }
37
+ // COMPAT(fullAgentIdExact): daemons before v0.16.0 resolve a full agent ID
38
+ // that matches no agent to an agent titled with it, so archive, detach and
39
+ // reload accept their answer only when it is that ID. Remove after 2027-05-15.
40
+ if (FULL_AGENT_UUID_PATTERN.test(trimmed)) {
41
+ const agentId = trimmed.toLowerCase();
42
+ const fetchResult = await client.fetchAgent({ agentId });
43
+ return fetchResult?.agent.id === agentId ? fetchResult.agent : null;
44
+ }
45
+ const fetchResult = await client.fetchAgent({ agentId: trimmed });
46
+ return fetchResult?.agent ?? null;
47
+ }
17
48
  //# sourceMappingURL=agent-directory.js.map
@@ -185,6 +185,7 @@ export async function tryConnectToDaemon(options) {
185
185
  return null;
186
186
  }
187
187
  }
188
+ const FULL_AGENT_UUID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
188
189
  /**
189
190
  * Resolve an agent ID from a partial ID or name.
190
191
  * Supports:
@@ -199,6 +200,10 @@ export function resolveAgentId(idOrName, agents) {
199
200
  return null;
200
201
  }
201
202
  const query = idOrName.toLowerCase();
203
+ // A complete agent UUID is an exact identity, never a name search fallback.
204
+ if (FULL_AGENT_UUID_PATTERN.test(idOrName)) {
205
+ return agents.find((a) => a.id.toLowerCase() === query)?.id ?? null;
206
+ }
202
207
  // Try exact ID match first
203
208
  const exactMatch = agents.find((a) => a.id === idOrName);
204
209
  if (exactMatch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/cli",
3
- "version": "0.16.0-beta.1",
3
+ "version": "0.16.0",
4
4
  "description": "Paseo CLI - control your AI coding agents from the command line",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@clack/prompts": "^1.0.0",
32
- "@getpaseo/client": "0.16.0-beta.1",
33
- "@getpaseo/protocol": "0.16.0-beta.1",
34
- "@getpaseo/server": "0.16.0-beta.1",
32
+ "@getpaseo/client": "0.16.0",
33
+ "@getpaseo/protocol": "0.16.0",
34
+ "@getpaseo/server": "0.16.0",
35
35
  "chalk": "^5.3.0",
36
36
  "commander": "^12.0.0",
37
37
  "mime-types": "^2.1.35",