@@ -9,14 +9,14 @@ import {
|
9 | 9 | } from "../subagent-control.js"; |
10 | 10 | import { buildSubagentList } from "../subagent-list.js"; |
11 | 11 | import type { AnyAgentTool } from "./common.js"; |
12 | | -import { jsonResult, readNumberParam, readStringParam } from "./common.js"; |
| 12 | +import { jsonResult, readPositiveIntegerParam, readStringParam } from "./common.js"; |
13 | 13 | |
14 | 14 | const SUBAGENT_ACTIONS = ["list"] as const; |
15 | 15 | type SubagentAction = (typeof SUBAGENT_ACTIONS)[number]; |
16 | 16 | |
17 | 17 | const SubagentsToolSchema = Type.Object({ |
18 | 18 | action: optionalStringEnum(SUBAGENT_ACTIONS), |
19 | | -recentMinutes: Type.Optional(Type.Number({ minimum: 1 })), |
| 19 | +recentMinutes: Type.Optional(Type.Integer({ minimum: 1 })), |
20 | 20 | }); |
21 | 21 | |
22 | 22 | export function createSubagentsTool(opts?: { agentSessionKey?: string }): AnyAgentTool { |
@@ -30,15 +30,16 @@ export function createSubagentsTool(opts?: { agentSessionKey?: string }): AnyAge
|
30 | 30 | const params = args as Record<string, unknown>; |
31 | 31 | const action = (readStringParam(params, "action") ?? "list") as SubagentAction; |
32 | 32 | const cfg = getRuntimeConfig(); |
| 33 | +const recentMinutesRaw = readPositiveIntegerParam(params, "recentMinutes"); |
| 34 | +const recentMinutes = |
| 35 | +recentMinutesRaw === undefined |
| 36 | + ? DEFAULT_RECENT_MINUTES |
| 37 | + : Math.min(MAX_RECENT_MINUTES, recentMinutesRaw); |
33 | 38 | const controller = resolveSubagentController({ |
34 | 39 | cfg, |
35 | 40 | agentSessionKey: opts?.agentSessionKey, |
36 | 41 | }); |
37 | 42 | const runs = listControlledSubagentRuns(controller.controllerSessionKey); |
38 | | -const recentMinutesRaw = readNumberParam(params, "recentMinutes"); |
39 | | -const recentMinutes = recentMinutesRaw |
40 | | - ? Math.max(1, Math.min(MAX_RECENT_MINUTES, Math.floor(recentMinutesRaw))) |
41 | | - : DEFAULT_RECENT_MINUTES; |
42 | 43 | |
43 | 44 | if (action === "list") { |
44 | 45 | const list = buildSubagentList({ |
|