pi-workflow-engine 0.10.0 → 0.10.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.
|
@@ -358,6 +358,8 @@ Use the workflow tool with a script argument, not a saved workflow name.
|
|
|
358
358
|
The script must start with export const meta = { ... } and default-export an async workflow function.
|
|
359
359
|
Use the injected Type object for schemas. Do not import anything or use dynamic import().
|
|
360
360
|
Set thinkingLevel explicitly on each agent() call.
|
|
361
|
+
Always pass a plain string as the first api.agent() argument; build prompts with template strings before calling agent().
|
|
362
|
+
If using \`isolation: "worktree"\`, remember api.agent() returns \`{ result, patch, changed }\`; read \`.result\` for the agent answer and \`.patch\` for the diff.
|
|
361
363
|
When the run is budgeted, guard expensive loops with \`while (api.budget.total && api.budget.remaining() > N) { ... }\`; api.agent() throws once the budget is spent.
|
|
362
364
|
Subagents receive no skills by default. When the brief asks for a skill or a stage clearly benefits from one, pass \`skills: ["skill-name"]\` on that agent call only.
|
|
363
365
|
Do not edit files unless the user explicitly requested edits.`;
|
|
@@ -566,6 +568,8 @@ export default function workflowEngine(pi: ExtensionAPI): void {
|
|
|
566
568
|
"Inline workflow scripts must use the injected `Type` object for schemas and must not contain imports or dynamic import().",
|
|
567
569
|
"Inline scripts may compose registered workflows in-process via `api.workflow(\"<name>\", args)` (e.g. `await api.workflow(\"code-review\", \"HEAD~3\")`); it returns the sub-workflow's result and nests one level only.",
|
|
568
570
|
"Subagents receive no skills by default. In inline workflows, pass `skills: [\"skill-name\"]` per `agent()` call when the user asks for a skill or a stage should use one; grant only the needed skills.",
|
|
571
|
+
"Always pass a plain string as the first `api.agent()` argument; build prompts with template strings before calling agent().",
|
|
572
|
+
"When using `isolation: \"worktree\"`, `api.agent()` returns `{ result, patch, changed }`; use `.result` for the answer and `.patch` for the isolated diff.",
|
|
569
573
|
"If an inline subagent needs grep/find/code-search helpers, use `tools: [\"read\", \"bash\", \"grep\", \"find\", \"ls\"]` plus `toolHints: [\"search\"]` so installed tools such as ast-grep, mgrep, ffgrep, or fffind are discovered dynamically.",
|
|
570
574
|
"`api.budget` exposes `{ total, spent(), remaining() }` (output tokens). When the run is budgeted, scale fleets from `budget.total` and guard loops with `while (budget.total && budget.remaining() > N) { await api.agent(...) }`; `api.agent()` throws once the ceiling is reached.",
|
|
571
575
|
"Every workflow tool call must provide exactly one of `name` or `script`, never both.",
|
|
@@ -354,6 +354,10 @@ async function recordJournalResult(rc: RunContext, label: string, key: string, v
|
|
|
354
354
|
* no event-stream parsing is needed.
|
|
355
355
|
*/
|
|
356
356
|
export async function runAgent(rc: RunContext, prompt: string, opts: AgentOptions = {}): Promise<unknown> {
|
|
357
|
+
if (typeof prompt !== "string") {
|
|
358
|
+
throw new Error(`agent() prompt must be a string; received ${describeAgentPrompt(prompt)}`);
|
|
359
|
+
}
|
|
360
|
+
|
|
357
361
|
const label = opts.label ?? "agent";
|
|
358
362
|
const phase = opts.phase ?? "Workflow";
|
|
359
363
|
const tags = { label, phase };
|
|
@@ -553,6 +557,12 @@ async function isolatedResult(rc: RunContext, worktreePath: string, result: unkn
|
|
|
553
557
|
return { result, patch: patch.patch, changed: patch.changed };
|
|
554
558
|
}
|
|
555
559
|
|
|
560
|
+
function describeAgentPrompt(value: unknown): string {
|
|
561
|
+
if (value === null) return "null";
|
|
562
|
+
if (Array.isArray(value)) return "array";
|
|
563
|
+
return typeof value;
|
|
564
|
+
}
|
|
565
|
+
|
|
556
566
|
function errorMessage(error: unknown): string {
|
|
557
567
|
return error instanceof Error ? error.message : String(error);
|
|
558
568
|
}
|
package/package.json
CHANGED