pi-subagents-lite 1.0.2 → 1.2.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,77 +0,0 @@
1
- /**
2
- * stop-agent-tool.ts — StopAgent tool execute handler.
3
- *
4
- * Registered in index.ts alongside the Agent tool.
5
- * Uses manager.abort(id) to stop running or queued agents.
6
- *
7
- * Response formats:
8
- * - Success: "Stopped agent <short_id>"
9
- * - Not found: "Agent <id> not found. Running agents: <type>·<short_id>, ..."
10
- * - Already terminal: "Agent <id> is already <status>. Running agents: ..."
11
- */
12
-
13
- import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
14
- import { successResult, errorResult } from "./tool-execution.js";
15
- import { manager } from "./index.js";
16
- import { SHORT_ID_LENGTH } from "./types.js";
17
-
18
- // ============================================================================
19
- // Running agents list helper
20
- // ============================================================================
21
-
22
- /**
23
- * Build a compact list of running (or queued) agents.
24
- * Format: "type·short_id, type·short_id" — one line, easy for LLM to parse.
25
- */
26
- function formatRunningAgents(): string {
27
- const agents = manager.listAgents().filter(
28
- (a) => a.status === "running" || a.status === "queued",
29
- );
30
-
31
- if (agents.length === 0) return "none";
32
-
33
- return agents
34
- .map((a) => `${a.type}·${a.id.slice(0, SHORT_ID_LENGTH)}`)
35
- .join(", ");
36
- }
37
-
38
- // ============================================================================
39
- // Execute handler
40
- // ============================================================================
41
-
42
- export async function executeStopAgentTool(
43
- _toolCallId: string,
44
- params: Record<string, unknown>,
45
- _signal: AbortSignal | undefined,
46
- _onUpdate: ((update: any) => void) | undefined,
47
- _ctx: ExtensionContext,
48
- ): Promise<any> {
49
- const agentId = params.agent_id as string | undefined;
50
-
51
- if (!agentId) {
52
- return errorResult("agent_id is required");
53
- }
54
-
55
- const record = manager.getRecord(agentId);
56
-
57
- if (!record) {
58
- // Agent not found → return error + list of running agents
59
- return errorResult(
60
- `Agent ${agentId} not found. Running agents: ${formatRunningAgents()}`,
61
- );
62
- }
63
-
64
- // Check if already in a terminal state (not running or queued)
65
- if (record.status !== "running" && record.status !== "queued") {
66
- return successResult(
67
- `Agent ${agentId} is already ${record.status}. Running agents: ${formatRunningAgents()}`,
68
- );
69
- }
70
-
71
- // Attempt to stop the running/queued agent
72
- if (manager.abort(agentId)) {
73
- return successResult(`Stopped agent ${agentId.slice(0, SHORT_ID_LENGTH)}`);
74
- }
75
-
76
- return errorResult(`Failed to stop agent ${agentId}`);
77
- }