@henryqw/pi-subagent 29.2.0 → 30.0.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/CONTEXT.md +1 -1
- package/README.md +11 -255
- package/dist/direct-herdr.d.ts +1 -1
- package/dist/direct-herdr.js +14 -4
- package/dist/ephemeral.d.ts +5 -1
- package/dist/ephemeral.js +60 -28
- package/dist/index.d.ts +10 -1
- package/dist/index.js +15 -4
- package/docs/measurement.md +62 -0
- package/docs/orchestration.md +25 -5
- package/examples/roles/oracle.md +10 -0
- package/examples/roles/planner.md +10 -0
- package/extensions/admission.ts +27 -3
- package/extensions/direct-native.ts +77 -0
- package/extensions/model-class-policy.ts +1 -1
- package/extensions/result-transport.ts +1 -1
- package/extensions/subagent.ts +344 -64
- package/extensions/workflow.ts +29 -16
- package/package.json +3 -4
package/extensions/workflow.ts
CHANGED
|
@@ -17,27 +17,27 @@ const TASK_NAME_MAX_LENGTH = 29;
|
|
|
17
17
|
const TaskNameSchema = Type.String({
|
|
18
18
|
minLength: 1,
|
|
19
19
|
maxLength: TASK_NAME_MAX_LENGTH,
|
|
20
|
-
description:
|
|
20
|
+
description: "Short display name",
|
|
21
21
|
pattern: DISPLAY_TEXT_CONTRACT.pattern,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const RoleSchema = Type.String({ minLength: 1, pattern: DISPLAY_TEXT_CONTRACT.pattern, description: "Configured Subagent role name" });
|
|
25
25
|
const TaskSchema = Type.String({ minLength: 1, description: "Bounded task packet" });
|
|
26
|
-
const ModelSchema = Type.String({ minLength: 1, pattern: DISPLAY_TEXT_CONTRACT.pattern, description: "
|
|
26
|
+
const ModelSchema = Type.String({ minLength: 1, pattern: DISPLAY_TEXT_CONTRACT.pattern, description: "Override provider/model" });
|
|
27
27
|
const ModelClassSchema = Type.Enum(PROFILE_NAMES, { type: "string", description: "Task model profile" });
|
|
28
28
|
const DirectKindSchema = Type.Enum(["text"], { type: "string" });
|
|
29
29
|
/** Main's honest per-task classification; only `write` reserves the checkout. Nothing enforces `read`. */
|
|
30
30
|
export const DIRECT_ACCESS = ["read", "write"] as const;
|
|
31
31
|
export type DirectAccess = (typeof DIRECT_ACCESS)[number];
|
|
32
32
|
const ACCESS_GUIDANCE = `Declare "write" when the task may change files, Git state, or external resources, otherwise "read". "read" is not enforced (no sandbox): it skips checkout admission and runs concurrently. Use mode isolated for checked writes.`;
|
|
33
|
-
const AccessSchema = Type.Enum(DIRECT_ACCESS, { type: "string", description:
|
|
34
|
-
const DryRunSchema = Type.Boolean({ description: "
|
|
35
|
-
const ContinueFromSchema = Type.String({ pattern: "^D[1-9][0-9]*\\.[1-9][0-9]*$", description: "
|
|
33
|
+
const AccessSchema = Type.Enum(DIRECT_ACCESS, { type: "string", description: "Use write for any potential mutation. Read is unsandboxed." });
|
|
34
|
+
const DryRunSchema = Type.Boolean({ description: "Validate and preview without launching." });
|
|
35
|
+
const ContinueFromSchema = Type.String({ pattern: "^D[1-9][0-9]*\\.[1-9][0-9]*$", description: "Resume the same Role and saved session, such as D7.1." });
|
|
36
36
|
|
|
37
37
|
const PathsSchema = Type.Array(Type.String({ minLength: 1 }), {
|
|
38
38
|
minItems: 1,
|
|
39
39
|
maxItems: 32,
|
|
40
|
-
description: "Write
|
|
40
|
+
description: "Write scope globs relative to the repo. Report only.",
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
export const DelegationSchema = Type.Object({
|
|
@@ -54,6 +54,7 @@ export const DelegationSchema = Type.Object({
|
|
|
54
54
|
|
|
55
55
|
export const DirectWorkflowSchema = Type.Object({
|
|
56
56
|
mode: Type.Literal("direct"),
|
|
57
|
+
wait: Type.Optional(Type.Boolean({ description: "Return the result in this call." })),
|
|
57
58
|
repositories: Type.Optional(RepositorySelectionSchema),
|
|
58
59
|
role: Type.Optional(RoleSchema),
|
|
59
60
|
name: Type.Optional(TaskNameSchema),
|
|
@@ -68,18 +69,25 @@ export const DirectWorkflowSchema = Type.Object({
|
|
|
68
69
|
chain: Type.Optional(Type.Array(DelegationSchema, { minItems: 1, maxItems: MAX_WORKFLOW_ENTRIES })),
|
|
69
70
|
}, { additionalProperties: false, description: "Direct mode: exactly one compact single, tasks, or chain workflow" });
|
|
70
71
|
|
|
72
|
+
const CancelSchema = Type.Object({
|
|
73
|
+
mode: Type.Literal("cancel"),
|
|
74
|
+
id: Type.String({ pattern: "^direct-[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$" }),
|
|
75
|
+
}, { additionalProperties: false });
|
|
76
|
+
|
|
71
77
|
// Parse each mode with its strict schema; expose a plain object root to tool providers.
|
|
78
|
+
const checkedTask = WorkspaceRequestSchema.properties.tasks.items.properties;
|
|
79
|
+
const checkedCommand = WorkspaceRequestSchema.properties.finalChecks.items.properties;
|
|
80
|
+
const providerChecks = Type.Array(Type.Object({ ...checkedCommand, repository: Type.Optional(checkedCommand.repository) }, { additionalProperties: false }), { maxItems: 32 });
|
|
81
|
+
// The model sees the common checked task fields once. Mode-specific parsers enforce all requirements.
|
|
82
|
+
const providerCheckedTask = Type.Object({ ...checkedTask, kind: Type.Enum(["text", "changeset"], { type: "string" }),
|
|
83
|
+
checks: Type.Optional(providerChecks), inputs: Type.Optional(RepositorySelectionSchema) }, { additionalProperties: false });
|
|
72
84
|
export const DelegateTaskParameters = Type.Object({
|
|
73
85
|
...DirectWorkflowSchema.properties,
|
|
74
|
-
mode: Type.Union([DirectWorkflowSchema.properties.mode, ExecuteRequestSchema.properties.mode]),
|
|
75
|
-
id: Type.Optional(ExecuteRequestSchema.properties.id),
|
|
86
|
+
mode: Type.Union([DirectWorkflowSchema.properties.mode, ExecuteRequestSchema.properties.mode, CancelSchema.properties.mode]),
|
|
87
|
+
id: Type.Optional(Type.Union([ExecuteRequestSchema.properties.id, CancelSchema.properties.id])),
|
|
76
88
|
goal: Type.Optional(ExecuteRequestSchema.properties.goal),
|
|
77
|
-
tasks: Type.Optional(Type.Union([
|
|
78
|
-
|
|
79
|
-
ExecuteRequestSchema.properties.tasks,
|
|
80
|
-
WorkspaceRequestSchema.properties.tasks,
|
|
81
|
-
])),
|
|
82
|
-
finalChecks: Type.Optional(Type.Union([ExecuteRequestSchema.properties.finalChecks, WorkspaceRequestSchema.properties.finalChecks])),
|
|
89
|
+
tasks: Type.Optional(Type.Array(Type.Union([DelegationSchema, providerCheckedTask]), { minItems: 1, maxItems: MAX_WORKFLOW_ENTRIES })),
|
|
90
|
+
finalChecks: Type.Optional(providerChecks),
|
|
83
91
|
finalJudgment: ExecuteRequestSchema.properties.finalJudgment,
|
|
84
92
|
dryRun: Type.Optional(DryRunSchema),
|
|
85
93
|
}, { additionalProperties: false });
|
|
@@ -89,8 +97,8 @@ export type WorkflowMode = "single" | "parallel" | "chain";
|
|
|
89
97
|
export type ParsedWorkflow = (
|
|
90
98
|
| { mode: "single"; delegations: [Delegation] }
|
|
91
99
|
| { mode: "parallel"; delegations: Delegation[] }
|
|
92
|
-
| { mode: "chain"; delegations: Delegation[] }) & { repositories?: RepositorySelection };
|
|
93
|
-
export type ParsedDelegateTask = ({ mode: "direct"; workflow: ParsedWorkflow } | { mode: "isolated"; request: ExecuteRequest } | { mode: "workspace"; request: WorkspaceRequest }) & { dryRun: boolean };
|
|
100
|
+
| { mode: "chain"; delegations: Delegation[] }) & { repositories?: RepositorySelection; wait?: true };
|
|
101
|
+
export type ParsedDelegateTask = ({ mode: "cancel"; id: string } | { mode: "direct"; workflow: ParsedWorkflow } | { mode: "isolated"; request: ExecuteRequest } | { mode: "workspace"; request: WorkspaceRequest }) & { dryRun: boolean };
|
|
94
102
|
|
|
95
103
|
type DirectInput = Static<typeof DirectWorkflowSchema>;
|
|
96
104
|
const DELEGATION_KEYS = ["role", "name", "task", "access", "paths", "continueFrom", "kind", "model", "modelClass"] as const;
|
|
@@ -170,6 +178,7 @@ export function parseWorkflow(value: unknown): ParsedWorkflow {
|
|
|
170
178
|
const workflow: ParsedWorkflow = mode === "single" ? { mode, delegations: [normalizeDelegation(input as Static<typeof DelegationSchema>, "workflow")] }
|
|
171
179
|
: mode === "parallel" ? { mode, delegations: input.tasks!.map((item, index) => normalizeDelegation(item, `tasks[${index}]`)) }
|
|
172
180
|
: { mode, delegations: input.chain!.map((item, index) => normalizeDelegation(item, `chain[${index}]`)) };
|
|
181
|
+
if (input.wait) workflow.wait = true;
|
|
173
182
|
if (input.repositories) {
|
|
174
183
|
workflow.repositories = parseRepositorySelection(input.repositories);
|
|
175
184
|
if (workflow.delegations.some((task) => task.continueFrom || task.paths)) throw new Error("Selected direct repositories do not support continueFrom or paths; use the repository-labelled change report and explicit task scope.");
|
|
@@ -184,6 +193,10 @@ export const writesCheckout = (workflow: ParsedWorkflow): boolean => workflow.de
|
|
|
184
193
|
|
|
185
194
|
/** `dryRun` is a tool-call option, not part of the direct workflow or the durable isolated request. */
|
|
186
195
|
export function parseDelegateTask(value: unknown): ParsedDelegateTask {
|
|
196
|
+
if (value && typeof value === "object" && "mode" in value && value.mode === "cancel") {
|
|
197
|
+
if (!Check(CancelSchema, value)) throw new Error("Cancellation requires only mode cancel and the exact direct workflow id.");
|
|
198
|
+
return { mode: "cancel", id: (value as Static<typeof CancelSchema>).id, dryRun: false };
|
|
199
|
+
}
|
|
187
200
|
let dryRun = false;
|
|
188
201
|
if (value && typeof value === "object" && !Array.isArray(value) && Object.hasOwn(value, "dryRun")) {
|
|
189
202
|
const { dryRun: option, ...rest } = value as Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-subagent",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "30.0.0",
|
|
4
4
|
"description": "Delegate bounded direct work or durable checked isolated task graphs to Pi roles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -72,9 +72,8 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@henryqw/pi-config-store": "^4.1.3",
|
|
74
74
|
"@henryqw/pi-herdr": "^0.7.0",
|
|
75
|
-
"@henryqw/pi-
|
|
76
|
-
"@henryqw/pi-
|
|
77
|
-
"@henryqw/pi-task-models": "^9.6.0",
|
|
75
|
+
"@henryqw/pi-process": "^0.3.0",
|
|
76
|
+
"@henryqw/pi-task-models": "^11.0.1",
|
|
78
77
|
"proper-lockfile": "^4.1.2"
|
|
79
78
|
},
|
|
80
79
|
"devDependencies": {
|