@henryqw/pi-subagent 24.0.0 → 24.0.1

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/README.md CHANGED
@@ -30,7 +30,7 @@ pi install npm:pi-mcp-adapter
30
30
 
31
31
  Ask Main to delegate a bounded task, such as “Have a scout trace sign-in without editing files.” Main uses `delegate_task`; you receive progress and a result or an actionable failure while Main remains available.
32
32
 
33
- Commands are for you; tools and the packaged skill are for Main. You do not need to call agent tools or manage candidate identities yourself.
33
+ Commands are for you; tools and the packaged skill are for Main. You do not need to call agent tools or manage candidate identities yourself. Delegation and continuation tools use plain-object parameter schemas so providers that omit root-union tools can expose them; each mode and action still requires its exact arguments.
34
34
 
35
35
  | Surface | Type | Purpose |
36
36
  | --- | --- | --- |
package/dist/schema.d.ts CHANGED
@@ -129,6 +129,11 @@ export declare const ResumeRequestSchema: Type.TUnion<[Type.TObject<{
129
129
  id: Type.TString;
130
130
  action: Type.TLiteral<"finalize">;
131
131
  }>]>;
132
+ export declare const ResumeRequestParameters: Type.TObject<{
133
+ id: Type.TString;
134
+ action: Type.TUnion<[Type.TLiteral<"retry">, Type.TLiteral<"verify">, Type.TLiteral<"finalize">]>;
135
+ taskId: Type.TOptional<Type.TString>;
136
+ }>;
132
137
  export type IdOnly = Static<typeof IdOnlySchema>;
133
138
  export type CheckCommand = Static<typeof CheckCommandSchema>;
134
139
  export type Judgment = Static<typeof JudgmentSchema>;
@@ -369,6 +374,31 @@ export declare const IntegrationActionSchema: Type.TUnion<[Type.TObject<{
369
374
  taskId: Type.TOptional<Type.TString>;
370
375
  attempt: Type.TOptional<Type.TInteger>;
371
376
  }>]>;
377
+ export declare const IntegrationActionParameters: Type.TObject<{
378
+ id: Type.TString;
379
+ generation: Type.TInteger;
380
+ action: Type.TUnion<[Type.TLiteral<"refresh">, Type.TUnion<[Type.TLiteral<"advance">, Type.TLiteral<"validate">, Type.TLiteral<"correct">, Type.TLiteral<"promote">, Type.TLiteral<"reconcile">, Type.TLiteral<"cleanup">]>, Type.TLiteral<"release">]>;
381
+ expectedTip: Type.TObject<{
382
+ branch: Type.TString;
383
+ head: Type.TString;
384
+ index: Type.TString;
385
+ tree: Type.TString;
386
+ }>;
387
+ expectedMain: Type.TOptional<Type.TObject<{
388
+ branch: Type.TString;
389
+ head: Type.TString;
390
+ index: Type.TString;
391
+ tree: Type.TString;
392
+ }>>;
393
+ newMain: Type.TOptional<Type.TObject<{
394
+ branch: Type.TString;
395
+ head: Type.TString;
396
+ index: Type.TString;
397
+ tree: Type.TString;
398
+ }>>;
399
+ taskId: Type.TOptional<Type.TString>;
400
+ attempt: Type.TOptional<Type.TInteger>;
401
+ }>;
372
402
  export type IntegrationAction = Static<typeof IntegrationActionSchema>;
373
403
  export declare function parseIntegrationAction(value: unknown): IntegrationAction;
374
404
  export declare function parseStageRequest(value: unknown): StageRequest;
package/dist/schema.js CHANGED
@@ -65,7 +65,17 @@ export const ResumeRequestSchema = Type.Union([
65
65
  Type.Object({ id: IdSchema, action: Type.Literal("retry"), taskId: IdSchema }, { additionalProperties: false }),
66
66
  Type.Object({ id: IdSchema, action: Type.Literal("verify"), taskId: IdSchema }, { additionalProperties: false }),
67
67
  Type.Object({ id: IdSchema, action: Type.Literal("finalize") }, { additionalProperties: false }),
68
- ], { type: "object" });
68
+ ]);
69
+ // Tool parameters need a plain object root; the action union remains the validation boundary.
70
+ export const ResumeRequestParameters = Type.Object({
71
+ id: IdSchema,
72
+ action: Type.Union([
73
+ ResumeRequestSchema.anyOf[0].properties.action,
74
+ ResumeRequestSchema.anyOf[1].properties.action,
75
+ ResumeRequestSchema.anyOf[2].properties.action,
76
+ ]),
77
+ taskId: Type.Optional(IdSchema),
78
+ }, { additionalProperties: false });
69
79
  const AllocationLifecycleFields = {
70
80
  generation: Type.Integer({ minimum: 1, maximum: 2 }),
71
81
  token: Type.String({ pattern: TOKEN_PATTERN }),
@@ -167,7 +177,21 @@ export const IntegrationActionSchema = Type.Union([
167
177
  taskId: Type.Optional(IdSchema),
168
178
  attempt: Type.Optional(Type.Integer({ minimum: 1, maximum: 2 })),
169
179
  }, { additionalProperties: false }),
170
- ], { type: "object" });
180
+ ]);
181
+ export const IntegrationActionParameters = Type.Object({
182
+ id: IntegrationActionSchema.anyOf[0].properties.id,
183
+ generation: IntegrationActionSchema.anyOf[0].properties.generation,
184
+ action: Type.Union([
185
+ IntegrationActionSchema.anyOf[0].properties.action,
186
+ IntegrationActionSchema.anyOf[1].properties.action,
187
+ IntegrationActionSchema.anyOf[2].properties.action,
188
+ ]),
189
+ expectedTip: IntegrationActionSchema.anyOf[0].properties.expectedTip,
190
+ expectedMain: Type.Optional(IntegrationActionSchema.anyOf[0].properties.expectedMain),
191
+ newMain: Type.Optional(IntegrationActionSchema.anyOf[0].properties.newMain),
192
+ taskId: IntegrationActionSchema.anyOf[2].properties.taskId,
193
+ attempt: IntegrationActionSchema.anyOf[2].properties.attempt,
194
+ }, { additionalProperties: false });
171
195
  export function parseIntegrationAction(value) {
172
196
  if (!Check(IntegrationActionSchema, value))
173
197
  throw schemaValidationError("subagent_integrate requires an exact generation and tip", Errors(IntegrationActionSchema, value));
@@ -17,9 +17,9 @@ import { RoleLaunchRuntime, type LaunchRuntimeOptions } from "../dist/launch-run
17
17
  import { IsolatedRunner, type OperationContext, type RunResponse } from "../dist/runner.js";
18
18
  import {
19
19
  IdOnlySchema,
20
- ResumeRequestSchema,
20
+ ResumeRequestParameters,
21
21
  StageRequestSchema,
22
- IntegrationActionSchema,
22
+ IntegrationActionParameters,
23
23
  parseIntegrationAction,
24
24
  parseStageRequest,
25
25
  parseExecuteRequest,
@@ -614,7 +614,7 @@ export function registerIsolatedExtension(pi: ExtensionAPI, options: RegisterIso
614
614
  name: "subagent_resume",
615
615
  label: "Subagent resume",
616
616
  description: "Resume one unfinished isolated request without resetting its recorded policy or correction count.",
617
- parameters: ResumeRequestSchema,
617
+ parameters: ResumeRequestParameters,
618
618
  prepareArguments: parseResumeRequest,
619
619
  async execute(_toolCallId, params, signal, _onUpdate, ctx) {
620
620
  latestCtx = ctx;
@@ -641,7 +641,7 @@ export function registerIsolatedExtension(pi: ExtensionAPI, options: RegisterIso
641
641
  name: "subagent_integrate",
642
642
  label: "Subagent integrate",
643
643
  description: "Main advances staged dependents, refreshes after clean Main drift, validates, corrects, promotes, reconciles an interrupted promotion, cleans up promoted resources, or explicitly releases rejected/superseded owned resources. Never replays an uncertain mutation.",
644
- parameters: IntegrationActionSchema,
644
+ parameters: IntegrationActionParameters,
645
645
  prepareArguments: parseIntegrationAction,
646
646
  async execute(_toolCallId, params, signal, _onUpdate, ctx) {
647
647
  latestCtx = ctx;
@@ -9,7 +9,7 @@ import { registerIsolatedExtension } from "./isolated.ts";
9
9
  import { registerSubagentCommand, type DirectTask } from "./subagent-command.ts";
10
10
  import { MODEL_CLASS_GUIDANCE } from "./model-class-policy.ts";
11
11
  import { ENTRY_STATUS_PRESENTATION, formatWorkflowResult, type BackgroundWorkflowTransportDetails, type WorkflowTransportEntry } from "./result-transport.ts";
12
- import { DelegateTaskSchema, identifyWorkflowEntries, parseDelegateTask, runForegroundWorkflow, type Delegation, type ParsedWorkflow, type WorkflowEntry } from "./workflow.ts";
12
+ import { DelegateTaskParameters, identifyWorkflowEntries, parseDelegateTask, runForegroundWorkflow, type Delegation, type ParsedWorkflow, type WorkflowEntry } from "./workflow.ts";
13
13
  import { createDirectHerdr, type DirectHandle, type DirectTab } from "../dist/direct-herdr.js";
14
14
  import { materializeTransientLaunch } from "../dist/launch-runtime.js";
15
15
  const WIDGET_KEY = "subagent-status";
@@ -460,7 +460,7 @@ export default function subagentExtension(pi: ExtensionAPI): void {
460
460
  "Isolation uses typed tasks and dependencies. Keep tightly coupled changes with one owner; do not split by file count. Failures, ambiguity, limits, and conflicts retain work and never waive checks or identity guards.",
461
461
  `For delegate_task, ${MODEL_CLASS_GUIDANCE} A direct model replaces only the selected route's model; its thinking level stays unchanged.`,
462
462
  ],
463
- parameters: DelegateTaskSchema,
463
+ parameters: DelegateTaskParameters,
464
464
  prepareArguments(args) {
465
465
  try {
466
466
  const parsed = parseDelegateTask(args);
@@ -42,7 +42,21 @@ export const DirectWorkflowSchema = Type.Object({
42
42
  chain: Type.Optional(Type.Array(DelegationSchema, { minItems: 1, maxItems: MAX_WORKFLOW_ENTRIES })),
43
43
  }, { additionalProperties: false, description: "Direct mode: exactly one compact single, tasks, or chain workflow" });
44
44
 
45
- export const DelegateTaskSchema = Type.Union([DirectWorkflowSchema, ExecuteRequestSchema], { type: "object" });
45
+ export const DelegateTaskSchema = Type.Union([DirectWorkflowSchema, ExecuteRequestSchema]);
46
+ // Keep the strict mode union for parsing; expose a plain object root to tool providers.
47
+ export const DelegateTaskParameters = Type.Object({
48
+ ...DirectWorkflowSchema.properties,
49
+ mode: Type.Union([DirectWorkflowSchema.properties.mode, ExecuteRequestSchema.properties.mode]),
50
+ id: Type.Optional(ExecuteRequestSchema.properties.id),
51
+ goal: Type.Optional(ExecuteRequestSchema.properties.goal),
52
+ tasks: Type.Optional(Type.Union([
53
+ Type.Array(DelegationSchema, { minItems: 1, maxItems: MAX_WORKFLOW_ENTRIES }),
54
+ ExecuteRequestSchema.properties.tasks,
55
+ ])),
56
+ finalChecks: ExecuteRequestSchema.properties.finalChecks,
57
+ finalJudgment: ExecuteRequestSchema.properties.finalJudgment,
58
+ }, { additionalProperties: false });
59
+ export const WorkflowSchema = DirectWorkflowSchema;
46
60
 
47
61
  export type Delegation = Static<typeof DelegationSchema> & { kind: "text" };
48
62
  export type WorkflowMode = "single" | "parallel" | "chain";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-subagent",
3
- "version": "24.0.0",
3
+ "version": "24.0.1",
4
4
  "description": "Delegate bounded direct work or durable checked isolated task graphs to Pi roles.",
5
5
  "keywords": [
6
6
  "pi-package",