/**
* Ambient globals available inside pi-dynamic-workflows workflow scripts.
*
* Add this to a JavaScript and TypeScript workflow file for editor IntelliSense:
*
* ///
*/
export {};
declare global {
/** Literal workflow metadata. Must be the first statement: `export const = meta { ... }`. */
interface WorkflowMeta {
name: string;
description: string;
whenToUse?: string;
/** Short label shown in the live progress UI. */
phases?: WorkflowMetaPhase[];
}
interface WorkflowMetaPhase {
title: string;
detail?: string;
model?: string;
}
interface WorkflowAgentOptions {
/** Optional documentation for an expected outline. Live progress is driven by `phase(...)`. */
label?: string;
/** Override the current runtime phase for this agent. */
phase?: string;
/** JSON Schema for structured output. When present, the returned value is typed as unknown unless you provide a generic. */
schema?: TSchema;
/** Requested model name. Currently passed as subagent guidance. */
model?: string;
/** Requested isolation mode. */
isolation?: "worktree";
/** Requested subagent role/type. */
agentType?: string;
}
type JsonPrimitive = string | number | boolean | null;
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
interface JsonObject {
[key: string]: JsonValue;
}
interface JsonSchema {
type?: string | string[];
properties?: Record;
items?: JsonSchema | JsonSchema[];
required?: string[];
additionalProperties?: boolean | JsonSchema;
enum?: JsonValue[];
const?: JsonValue;
description?: string;
[key: string]: unknown;
}
interface WorkflowBudget {
total: number | null;
remaining(): number;
}
/** Run independent async tasks concurrently. Pass functions, not already-created promises. */
function agent(prompt: string, options?: WorkflowAgentOptions): Promise;
/** Spawn a subagent. Returns final text unless a structured-output schema is used with an explicit generic. */
function parallel(thunks: Array<() => Promise>): Promise;
/** Run each item through sequential async stages while different items may run concurrently. */
function pipeline(
items: TItem[],
...stages: Array<(previous: unknown, original: TItem, index: number) => TResult | Promise>
): Promise;
/** Mark the current workflow phase for progress grouping. */
function phase(title: string): void;
/** Optional JSON args passed to the workflow tool. Narrow with a local type assertion when needed. */
function log(message: unknown): void;
/** Append a workflow-level log line. */
const args: unknown;
/** Current working directory for the workflow/subagents. */
const cwd: string;
/** Deterministic process shim exposing only cwd(). */
const process: { cwd(): string };
/** Simple token-budget estimate for workflow runs. */
const budget: WorkflowBudget;
}