@ian-pascoe/pi-minimal-subagents 0.4.0 → 0.5.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.
package/package.json
CHANGED
|
@@ -181,6 +181,138 @@ const DeleteDetailsSchema = Type.Object({
|
|
|
181
181
|
),
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
+
const CoordinatorTurnStatusOutputSchema = Type.Union([
|
|
185
|
+
Type.Literal("completed"),
|
|
186
|
+
Type.Literal("failed"),
|
|
187
|
+
Type.Literal("cancelled"),
|
|
188
|
+
Type.Literal("interrupted"),
|
|
189
|
+
]);
|
|
190
|
+
const CoordinatorTurnOutputSchema = Type.Object({
|
|
191
|
+
agent_id: Type.String(),
|
|
192
|
+
turn_id: Type.String(),
|
|
193
|
+
status: CoordinatorTurnStatusOutputSchema,
|
|
194
|
+
output: Type.String(),
|
|
195
|
+
error: Type.Optional(Type.String()),
|
|
196
|
+
usage: Type.Optional(RenderUsageSchema),
|
|
197
|
+
elapsed_ms: Type.Optional(Type.Number()),
|
|
198
|
+
});
|
|
199
|
+
const CoordinatorAgentSummaryOutputSchema = Type.Object({
|
|
200
|
+
agent_id: Type.String(),
|
|
201
|
+
parent_id: Type.String(),
|
|
202
|
+
state: Type.Union([Type.Literal("running"), Type.Literal("idle")]),
|
|
203
|
+
availability: Type.Union([Type.Literal("available"), Type.Literal("unavailable")]),
|
|
204
|
+
active_turn_id: Type.Optional(Type.String()),
|
|
205
|
+
latest_turn: Type.Optional(
|
|
206
|
+
Type.Object({
|
|
207
|
+
turn_id: Type.String(),
|
|
208
|
+
status: Type.Union([Type.Literal("running"), CoordinatorTurnStatusOutputSchema]),
|
|
209
|
+
}),
|
|
210
|
+
),
|
|
211
|
+
tools: Type.Array(Type.String()),
|
|
212
|
+
elapsed_ms: Type.Optional(Type.Number()),
|
|
213
|
+
latest_activity_at: Type.Optional(Type.String()),
|
|
214
|
+
task: Type.Optional(Type.String()),
|
|
215
|
+
child_count: Type.Number(),
|
|
216
|
+
children: Type.Array(Type.Unknown()),
|
|
217
|
+
model: Type.String(),
|
|
218
|
+
thinking_level: Type.String(),
|
|
219
|
+
});
|
|
220
|
+
const CoordinatorAgentDetailOutputSchema = Type.Object({
|
|
221
|
+
...CoordinatorAgentSummaryOutputSchema.properties,
|
|
222
|
+
session_file: Type.Optional(Type.String()),
|
|
223
|
+
launch_contract: Type.Object({
|
|
224
|
+
session_context: Type.String(),
|
|
225
|
+
project_context: Type.String(),
|
|
226
|
+
model: Type.String(),
|
|
227
|
+
thinking_level: Type.String(),
|
|
228
|
+
tools: Type.Optional(
|
|
229
|
+
Type.Union([
|
|
230
|
+
Type.Literal("none"),
|
|
231
|
+
Type.Literal("read"),
|
|
232
|
+
Type.Literal("modify"),
|
|
233
|
+
Type.Array(Type.String()),
|
|
234
|
+
]),
|
|
235
|
+
),
|
|
236
|
+
ordinary_tools: Type.Array(Type.String()),
|
|
237
|
+
delegation: Type.Optional(Type.Union([Type.Literal("none"), Type.Literal("fanout")])),
|
|
238
|
+
}),
|
|
239
|
+
capability_ceiling: Type.Array(Type.String()),
|
|
240
|
+
spawn_entry_id: Type.String(),
|
|
241
|
+
recent_messages: Type.Array(
|
|
242
|
+
Type.Object({
|
|
243
|
+
source_agent_id: Type.String(),
|
|
244
|
+
turn_id: Type.String(),
|
|
245
|
+
content: Type.String(),
|
|
246
|
+
}),
|
|
247
|
+
),
|
|
248
|
+
recent_activity: Type.Array(RenderRecentActivitySchema),
|
|
249
|
+
latest_result: Type.Optional(CoordinatorTurnOutputSchema),
|
|
250
|
+
missing_dependencies: Type.Array(Type.String()),
|
|
251
|
+
unavailable_reason: Type.Optional(Type.String()),
|
|
252
|
+
usage: Type.Optional(RenderUsageSchema),
|
|
253
|
+
});
|
|
254
|
+
const CoordinatorWaitMessageOutputSchema = Type.Object({
|
|
255
|
+
event: Type.Literal("message"),
|
|
256
|
+
agent_id: Type.String(),
|
|
257
|
+
turn_id: Type.String(),
|
|
258
|
+
message_id: Type.String(),
|
|
259
|
+
delivery_id: Type.Optional(Type.String()),
|
|
260
|
+
message: Type.String(),
|
|
261
|
+
});
|
|
262
|
+
const CoordinatorWaitSourceOutputSchema = {
|
|
263
|
+
source_agent_id: Type.String(),
|
|
264
|
+
source_turn_id: Type.String(),
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/** Final details schemas exposed to CodeMode for the six coordinator tools. */
|
|
268
|
+
export const CoordinatorToolOutputSchemas = {
|
|
269
|
+
subagent: Type.Object({
|
|
270
|
+
agent_id: Type.String(),
|
|
271
|
+
turn_id: Type.String(),
|
|
272
|
+
status: Type.Literal("running"),
|
|
273
|
+
agent: Type.Optional(CoordinatorAgentDetailOutputSchema),
|
|
274
|
+
}),
|
|
275
|
+
agent_message: Type.Object({
|
|
276
|
+
agent_id: Type.String(),
|
|
277
|
+
message_id: Type.String(),
|
|
278
|
+
disposition: Type.Union([
|
|
279
|
+
Type.Literal("delivered-via-wait"),
|
|
280
|
+
Type.Literal("queued"),
|
|
281
|
+
Type.Literal("failed"),
|
|
282
|
+
]),
|
|
283
|
+
error: Type.Optional(Type.String()),
|
|
284
|
+
}),
|
|
285
|
+
subagent_wait: Type.Union([
|
|
286
|
+
Type.Object({
|
|
287
|
+
...CoordinatorWaitMessageOutputSchema.properties,
|
|
288
|
+
...CoordinatorWaitSourceOutputSchema,
|
|
289
|
+
}),
|
|
290
|
+
Type.Object({
|
|
291
|
+
...CoordinatorTurnOutputSchema.properties,
|
|
292
|
+
event: Type.Literal("turn"),
|
|
293
|
+
messages: Type.Optional(Type.Array(CoordinatorWaitMessageOutputSchema)),
|
|
294
|
+
...CoordinatorWaitSourceOutputSchema,
|
|
295
|
+
}),
|
|
296
|
+
Type.Object({
|
|
297
|
+
event: Type.Literal("timeout"),
|
|
298
|
+
agent_id: Type.String(),
|
|
299
|
+
turn_id: Type.String(),
|
|
300
|
+
timeout_ms: Type.Number(),
|
|
301
|
+
agent: CoordinatorAgentDetailOutputSchema,
|
|
302
|
+
...CoordinatorWaitSourceOutputSchema,
|
|
303
|
+
}),
|
|
304
|
+
]),
|
|
305
|
+
subagent_status: Type.Union([
|
|
306
|
+
Type.Object({
|
|
307
|
+
parent_id: Type.String(),
|
|
308
|
+
agents: Type.Array(CoordinatorAgentSummaryOutputSchema),
|
|
309
|
+
}),
|
|
310
|
+
Type.Object({ agent: CoordinatorAgentDetailOutputSchema }),
|
|
311
|
+
]),
|
|
312
|
+
subagent_cancel: CancelDetailsSchema,
|
|
313
|
+
subagent_delete: DeleteDetailsSchema,
|
|
314
|
+
} as const;
|
|
315
|
+
|
|
184
316
|
const MessageRenderDetailsSchema = Type.Union([
|
|
185
317
|
CurrentMessageDetailsSchema,
|
|
186
318
|
LegacyMessageDetailsSchema,
|
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
renderCoordinatorToolResult,
|
|
17
17
|
type CoordinatorToolName,
|
|
18
18
|
} from "./minimal-subagents-rendering.js";
|
|
19
|
-
import
|
|
19
|
+
import {
|
|
20
|
+
CoordinatorToolOutputSchemas,
|
|
21
|
+
type CoordinatorToolCallInput,
|
|
22
|
+
} from "./minimal-subagents-render-contract.js";
|
|
20
23
|
import type { createCoordinatorToolSchemas } from "./minimal-subagents-tool-schemas.js";
|
|
21
24
|
import type {
|
|
22
25
|
AgentMessageResult,
|
|
@@ -86,6 +89,10 @@ type CoordinatorToolResultDetails =
|
|
|
86
89
|
| DeleteResult
|
|
87
90
|
| { agent_id: string; status: "waiting"; elapsed_ms: number };
|
|
88
91
|
|
|
92
|
+
type CoordinatorToolDefinition = ToolDefinition & {
|
|
93
|
+
readonly outputSchema: (typeof CoordinatorToolOutputSchemas)[keyof typeof CoordinatorToolOutputSchemas];
|
|
94
|
+
};
|
|
95
|
+
|
|
89
96
|
function createCoordinatorToolRendering(toolName: CoordinatorToolName) {
|
|
90
97
|
return {
|
|
91
98
|
renderCall: (args: CoordinatorToolCallInput, theme: Theme) =>
|
|
@@ -145,7 +152,7 @@ function callerSourceTurnId(
|
|
|
145
152
|
/** Create caller-bound definitions for the six coordinator tools shared by root and children. */
|
|
146
153
|
export function createCoordinatorToolDefinitions(
|
|
147
154
|
options: CoordinatorToolDefinitionOptions,
|
|
148
|
-
):
|
|
155
|
+
): CoordinatorToolDefinition[] {
|
|
149
156
|
const modelRolePromptGuidelines = buildModelRolePromptGuidelines(options.modelRoles ?? []);
|
|
150
157
|
const spawnTool = defineTool({
|
|
151
158
|
name: "subagent",
|
|
@@ -306,7 +313,14 @@ export function createCoordinatorToolDefinitions(
|
|
|
306
313
|
...createCoordinatorToolRendering("subagent_delete"),
|
|
307
314
|
});
|
|
308
315
|
|
|
309
|
-
const coordinatorTools = [
|
|
316
|
+
const coordinatorTools: CoordinatorToolDefinition[] = [
|
|
317
|
+
Object.assign(spawnTool, { outputSchema: CoordinatorToolOutputSchemas.subagent }),
|
|
318
|
+
Object.assign(messageTool, { outputSchema: CoordinatorToolOutputSchemas.agent_message }),
|
|
319
|
+
Object.assign(waitTool, { outputSchema: CoordinatorToolOutputSchemas.subagent_wait }),
|
|
320
|
+
Object.assign(statusTool, { outputSchema: CoordinatorToolOutputSchemas.subagent_status }),
|
|
321
|
+
Object.assign(cancelTool, { outputSchema: CoordinatorToolOutputSchemas.subagent_cancel }),
|
|
322
|
+
Object.assign(deleteTool, { outputSchema: CoordinatorToolOutputSchemas.subagent_delete }),
|
|
323
|
+
];
|
|
310
324
|
const allowFanoutTools = options.allowFanoutTools ?? options.callerId === "root";
|
|
311
325
|
return allowFanoutTools
|
|
312
326
|
? coordinatorTools
|