workflowskill 0.1.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.
@@ -0,0 +1,637 @@
1
+ //#region src/types/index.d.ts
2
+ /** The set of types available in workflow schemas. */
3
+ type SchemaType = 'string' | 'int' | 'float' | 'boolean' | 'array' | 'object';
4
+ /** Schema for a single field (workflow inputs, step inputs/outputs). */
5
+ interface FieldSchema {
6
+ type: SchemaType;
7
+ /** Value: literal or $-expression. Replaces legacy `source`/`default`. */
8
+ value?: unknown;
9
+ /** For array types: describes element shape. */
10
+ items?: FieldSchema;
11
+ /** For object types: describes property shapes. */
12
+ properties?: Record<string, SchemaType | FieldSchema>;
13
+ }
14
+ /** Workflow-level input parameter declaration. `default` provides a fallback for optional inputs, overridable at runtime. */
15
+ interface WorkflowInput {
16
+ type: SchemaType;
17
+ /** Default value for optional inputs. Overridable at runtime. */
18
+ default?: unknown;
19
+ /** For array types: describes element shape. */
20
+ items?: FieldSchema;
21
+ /** For object types: describes property shapes. */
22
+ properties?: Record<string, SchemaType | FieldSchema>;
23
+ }
24
+ /** Workflow-level output declaration. `value` is an expression resolving to the output from final runtime context. */
25
+ type WorkflowOutput = FieldSchema;
26
+ /** Step-level input declaration. `value` is either a literal or $-expression resolved at runtime. */
27
+ type StepInput = FieldSchema;
28
+ /** Step-level output declaration. `value` uses $result to map from raw executor result. */
29
+ type StepOutput$1 = FieldSchema;
30
+ /** Retry policy for a step. */
31
+ interface RetryPolicy {
32
+ /** Maximum number of retry attempts. */
33
+ max: number;
34
+ /** Delay between retries (e.g., "1s", "500ms"). */
35
+ delay: string;
36
+ /** Backoff multiplier applied to delay after each retry. */
37
+ backoff: number;
38
+ }
39
+ /** Error handling strategy for a step. */
40
+ type OnError = 'fail' | 'ignore';
41
+ type StepType = 'tool' | 'llm' | 'transform' | 'conditional' | 'exit';
42
+ /** Transform operation kinds. */
43
+ type TransformOperation = 'filter' | 'map' | 'sort';
44
+ /** Sort direction. */
45
+ type SortDirection = 'asc' | 'desc';
46
+ /** Exit statuses. */
47
+ type ExitStatus = 'success' | 'failed';
48
+ /** Common fields shared by all step types. */
49
+ interface StepBase {
50
+ /** Unique identifier within the workflow. */
51
+ id: string;
52
+ /** Step type discriminator. */
53
+ type: StepType;
54
+ /** Human-readable description. */
55
+ description?: string;
56
+ /** What this step expects. */
57
+ inputs: Record<string, StepInput>;
58
+ /** What this step produces. */
59
+ outputs: Record<string, StepOutput$1>;
60
+ /** Guard condition: if false, the step is skipped and output is null. */
61
+ condition?: string;
62
+ /** Iterate over an array. $item and $index available inside the step. */
63
+ each?: string;
64
+ /** Inter-iteration delay when combined with each. Format: "1s", "500ms". */
65
+ delay?: string;
66
+ /** Error handling strategy. Default: fail. */
67
+ on_error?: OnError;
68
+ /** Retry policy. */
69
+ retry?: RetryPolicy;
70
+ }
71
+ /** Tool step: invokes a registered tool. */
72
+ interface ToolStep extends StepBase {
73
+ type: 'tool';
74
+ /** Registered tool name. */
75
+ tool: string;
76
+ }
77
+ /** LLM step: calls a language model. */
78
+ interface LLMStep extends StepBase {
79
+ type: 'llm';
80
+ /** Model identifier (optional, falls back to platform default). */
81
+ model?: string;
82
+ /** Prompt template with $-expression interpolation. */
83
+ prompt: string;
84
+ /** Structured output hint (optional). */
85
+ response_format?: Record<string, unknown>;
86
+ }
87
+ /** Transform step: filter, map, or sort data. */
88
+ interface TransformFilterStep extends StepBase {
89
+ type: 'transform';
90
+ operation: 'filter';
91
+ /** Expression evaluated per item; items where true are kept. */
92
+ where: string;
93
+ }
94
+ interface TransformMapStep extends StepBase {
95
+ type: 'transform';
96
+ operation: 'map';
97
+ /** Object defining the output shape per item. Values may be expression references, literal primitives, or nested objects. */
98
+ expression: Record<string, unknown>;
99
+ }
100
+ interface TransformSortStep extends StepBase {
101
+ type: 'transform';
102
+ operation: 'sort';
103
+ /** Dot-notation path to the field to sort by. */
104
+ field: string;
105
+ /** Sort direction (default: asc). */
106
+ direction?: SortDirection;
107
+ }
108
+ type TransformStep = TransformFilterStep | TransformMapStep | TransformSortStep;
109
+ /** Conditional step: branch based on a condition. */
110
+ interface ConditionalStep extends StepBase {
111
+ type: 'conditional';
112
+ /** Expression to evaluate for branching. Overrides the common guard semantics. */
113
+ condition: string;
114
+ /** Step IDs to execute if condition is true. */
115
+ then: string[];
116
+ /** Step IDs to execute if condition is false (optional). */
117
+ else?: string[];
118
+ }
119
+ /** Exit step: terminates the workflow. */
120
+ interface ExitStep extends StepBase {
121
+ type: 'exit';
122
+ /** Termination status. */
123
+ status: ExitStatus;
124
+ /** Final output: expression string, or object literal (values may be expressions). */
125
+ output?: string | Record<string, unknown>;
126
+ }
127
+ /** Union of all step types. */
128
+ type Step = ToolStep | LLMStep | TransformStep | ConditionalStep | ExitStep;
129
+ /** The complete parsed workflow definition. */
130
+ interface WorkflowDefinition {
131
+ inputs: Record<string, WorkflowInput>;
132
+ outputs: Record<string, WorkflowOutput>;
133
+ steps: Step[];
134
+ }
135
+ /** SKILL.md frontmatter. */
136
+ interface SkillFrontmatter {
137
+ name: string;
138
+ description: string;
139
+ [key: string]: unknown;
140
+ }
141
+ /** A fully parsed skill file: frontmatter + workflow definition. */
142
+ interface ParsedSkill {
143
+ frontmatter: SkillFrontmatter;
144
+ workflow: WorkflowDefinition;
145
+ }
146
+ /** Token usage for an LLM step. */
147
+ interface TokenUsage {
148
+ input: number;
149
+ output: number;
150
+ }
151
+ /** Retry tracking for a step that was retried. */
152
+ interface RetryRecord {
153
+ /** Number of retry attempts (not counting the initial try). */
154
+ attempts: number;
155
+ /** Error messages from each failed attempt. */
156
+ errors: string[];
157
+ }
158
+ /** Status of a step in the run log. */
159
+ type StepRunStatus = 'success' | 'failed' | 'skipped';
160
+ /** A single step's record in the run log. */
161
+ interface StepRecord {
162
+ /** The step's declared identifier. */
163
+ id: string;
164
+ /** Which executor ran this step. */
165
+ executor: StepType;
166
+ /** Execution outcome. */
167
+ status: StepRunStatus;
168
+ /** Why the step was skipped (if applicable). */
169
+ reason?: string;
170
+ /** Wall-clock time for this step in milliseconds. */
171
+ duration_ms: number;
172
+ /** Resolved inputs that were passed to the executor. */
173
+ inputs?: Record<string, unknown>;
174
+ /** Number of iterations (if each was used). */
175
+ iterations?: number;
176
+ /** Token counts (LLM steps only). */
177
+ tokens?: TokenUsage;
178
+ /** The step's output (may be truncated in logs). */
179
+ output?: unknown;
180
+ /** Error details if the step failed. */
181
+ error?: string;
182
+ /** Retry tracking (only present when retries occurred). */
183
+ retries?: RetryRecord;
184
+ }
185
+ /** Aggregate summary in the run log. */
186
+ interface RunSummary {
187
+ steps_executed: number;
188
+ steps_skipped: number;
189
+ total_tokens: number;
190
+ total_duration_ms: number;
191
+ }
192
+ /** Final status of a workflow run. */
193
+ type RunStatus = 'success' | 'failed';
194
+ /** Structured error for pre-execution failures (parse or validate phases). */
195
+ interface RunLogError {
196
+ /** Which phase the failure occurred in. */
197
+ phase: 'parse' | 'validate' | 'execute';
198
+ /** Human-readable error message. */
199
+ message: string;
200
+ /** Detailed per-path errors (if available). */
201
+ details?: Array<{
202
+ path: string;
203
+ message: string;
204
+ }>;
205
+ }
206
+ /** The complete run log produced by a workflow execution. */
207
+ interface RunLog {
208
+ /** Unique run identifier. */
209
+ id: string;
210
+ /** Name of the workflow that was executed. */
211
+ workflow: string;
212
+ /** Final status. */
213
+ status: RunStatus;
214
+ /** Aggregate counts. */
215
+ summary: RunSummary;
216
+ /** ISO 8601 start timestamp. */
217
+ started_at: string;
218
+ /** ISO 8601 completion timestamp. */
219
+ completed_at: string;
220
+ /** Total wall-clock time in milliseconds. */
221
+ duration_ms: number;
222
+ /** The workflow inputs that were provided. */
223
+ inputs: Record<string, unknown>;
224
+ /** Ordered array of step records. */
225
+ steps: StepRecord[];
226
+ /** The workflow outputs that were produced. */
227
+ outputs: Record<string, unknown>;
228
+ /** Structured error for pre-execution failures. Present only when status is 'failed' due to parse/validate/execute errors. */
229
+ error?: RunLogError;
230
+ }
231
+ /** Discriminated union of events emitted by the runtime during workflow execution. */
232
+ type RuntimeEvent = {
233
+ type: 'workflow_start';
234
+ workflow: string;
235
+ totalSteps: number;
236
+ } | {
237
+ type: 'step_start';
238
+ stepId: string;
239
+ stepType: StepType;
240
+ tool?: string;
241
+ } | {
242
+ type: 'step_complete';
243
+ stepId: string;
244
+ status: StepRunStatus;
245
+ duration_ms: number;
246
+ tokens?: TokenUsage;
247
+ iterations?: number;
248
+ } | {
249
+ type: 'step_skip';
250
+ stepId: string;
251
+ reason: string;
252
+ } | {
253
+ type: 'step_retry';
254
+ stepId: string;
255
+ attempt: number;
256
+ error: string;
257
+ } | {
258
+ type: 'step_error';
259
+ stepId: string;
260
+ error: string;
261
+ onError: OnError;
262
+ } | {
263
+ type: 'each_progress';
264
+ stepId: string;
265
+ current: number;
266
+ total: number;
267
+ } | {
268
+ type: 'workflow_complete';
269
+ status: RunStatus;
270
+ duration_ms: number;
271
+ summary: RunSummary;
272
+ };
273
+ /** Minimal JSON Schema type for tool parameter/output descriptions. */
274
+ interface JsonSchema {
275
+ type?: string;
276
+ description?: string;
277
+ properties?: Record<string, JsonSchema>;
278
+ required?: string[];
279
+ items?: JsonSchema;
280
+ enum?: unknown[];
281
+ [key: string]: unknown;
282
+ }
283
+ /** Describes a tool's name, purpose, and parameter schemas. */
284
+ interface ToolDescriptor {
285
+ name: string;
286
+ description: string;
287
+ inputSchema?: JsonSchema;
288
+ outputSchema?: JsonSchema;
289
+ }
290
+ /** Result from a tool invocation. */
291
+ interface ToolResult {
292
+ output: unknown;
293
+ error?: string;
294
+ }
295
+ /** Tool adapter interface for invoking registered tools. */
296
+ interface ToolAdapter {
297
+ invoke(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
298
+ /** Check whether a tool is available. */
299
+ has(toolName: string): boolean;
300
+ /** List all available tools with their metadata. Optional for backward compatibility. */
301
+ list?(): ToolDescriptor[];
302
+ }
303
+ /** Result from an LLM call. */
304
+ interface LLMResult {
305
+ text: string;
306
+ tokens: TokenUsage;
307
+ }
308
+ /** LLM adapter interface for calling language models. */
309
+ interface LLMAdapter {
310
+ call(model: string | undefined, prompt: string, responseFormat?: Record<string, unknown>): Promise<LLMResult>;
311
+ }
312
+ /** Runtime context available during step execution. */
313
+ interface RuntimeContext {
314
+ /** Workflow-level inputs. */
315
+ inputs: Record<string, unknown>;
316
+ /** Outputs from completed steps, keyed by step ID. */
317
+ steps: Record<string, {
318
+ output: unknown;
319
+ }>;
320
+ /** Current item when inside an `each` loop. */
321
+ item?: unknown;
322
+ /** Current index when inside an `each` loop. */
323
+ index?: number;
324
+ /** Raw executor result, set during step output value mapping. */
325
+ result?: unknown;
326
+ }
327
+ /** A single validation error with context. */
328
+ interface ValidationError {
329
+ /** Which step or field the error relates to. */
330
+ path: string;
331
+ /** Human-readable error message. */
332
+ message: string;
333
+ }
334
+ /** Result of workflow validation. */
335
+ interface ValidationResult {
336
+ valid: boolean;
337
+ errors: ValidationError[];
338
+ }
339
+ //#endregion
340
+ //#region src/parser/index.d.ts
341
+ /** Error thrown when parsing fails. Includes structured details. */
342
+ declare class ParseError extends Error {
343
+ readonly details: ParseErrorDetail[];
344
+ constructor(message: string, details?: ParseErrorDetail[]);
345
+ }
346
+ interface ParseErrorDetail {
347
+ path: string;
348
+ message: string;
349
+ }
350
+ /**
351
+ * Parse a raw YAML string into a validated WorkflowDefinition.
352
+ * Use this when you already have the YAML content (e.g., from extractWorkflowBlock).
353
+ */
354
+ declare function parseWorkflowYaml(yaml: string): WorkflowDefinition;
355
+ /**
356
+ * Parse a SKILL.md file content into a fully typed ParsedSkill.
357
+ * Extracts frontmatter and workflow block, validates both.
358
+ */
359
+ declare function parseSkillMd(content: string): ParsedSkill;
360
+ /**
361
+ * Parse just the workflow block from SKILL.md content.
362
+ * Useful when you only need the workflow definition without frontmatter.
363
+ */
364
+ declare function parseWorkflowFromMd(content: string): WorkflowDefinition;
365
+ //#endregion
366
+ //#region src/expression/lexer.d.ts
367
+ declare class LexError extends Error {
368
+ readonly position: number;
369
+ constructor(message: string, position: number);
370
+ }
371
+ //#endregion
372
+ //#region src/expression/parser.d.ts
373
+ declare class ParseExprError extends Error {
374
+ readonly position: number;
375
+ constructor(message: string, position: number);
376
+ }
377
+ //#endregion
378
+ //#region src/expression/evaluator.d.ts
379
+ declare class EvalError extends Error {
380
+ constructor(message: string);
381
+ }
382
+ //#endregion
383
+ //#region src/expression/index.d.ts
384
+ /**
385
+ * Resolve a single expression string against a runtime context.
386
+ * Used for source, condition, where, each, and output fields.
387
+ * Example: "$steps.fetch.output.messages.length >= 5"
388
+ */
389
+ declare function resolveExpression(expr: string, context: RuntimeContext): unknown;
390
+ /**
391
+ * Interpolate $-references in a prompt template string.
392
+ * Only resolves references and property access (no operators).
393
+ * Objects/arrays are serialized as JSON. Null → empty string.
394
+ *
395
+ * Example: "Score this email: $steps.fetch.output.subject"
396
+ */
397
+ declare function interpolatePrompt(template: string, context: RuntimeContext): string;
398
+ //#endregion
399
+ //#region src/validator/index.d.ts
400
+ /**
401
+ * Validate a workflow definition before execution.
402
+ * Checks structural correctness, reference graph, type compatibility, and tool availability.
403
+ * Returns all errors found — does not fail fast.
404
+ */
405
+ declare function validateWorkflow(workflow: WorkflowDefinition, toolAdapter?: ToolAdapter): ValidationResult;
406
+ interface ValidateWorkflowSkillOptions {
407
+ content: string;
408
+ toolAdapter?: ToolAdapter;
409
+ }
410
+ interface ValidateWorkflowSkillResult {
411
+ valid: boolean;
412
+ errors: Array<{
413
+ path: string;
414
+ message: string;
415
+ }>;
416
+ name?: string;
417
+ stepCount?: number;
418
+ stepTypes?: string[];
419
+ }
420
+ /**
421
+ * Parse content and validate the workflow in one synchronous call.
422
+ * Matches the shape of the plugin's ValidateResult exactly.
423
+ */
424
+ declare function validateWorkflowSkill(options: ValidateWorkflowSkillOptions): ValidateWorkflowSkillResult;
425
+ //#endregion
426
+ //#region src/adapters/mock-tool-adapter.d.ts
427
+ /** Handler function for a registered mock tool. */
428
+ type ToolHandler = (args: Record<string, unknown>) => ToolResult | Promise<ToolResult>;
429
+ declare class MockToolAdapter implements ToolAdapter {
430
+ private tools;
431
+ /** Register a tool handler with optional descriptor metadata. */
432
+ register(toolName: string, handler: ToolHandler, descriptor?: Omit<ToolDescriptor, 'name'>): void;
433
+ has(toolName: string): boolean;
434
+ /** List all registered tools with their descriptors. */
435
+ list(): ToolDescriptor[];
436
+ invoke(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
437
+ }
438
+ //#endregion
439
+ //#region src/adapters/mock-llm-adapter.d.ts
440
+ type LLMHandler = (model: string | undefined, prompt: string, responseFormat?: Record<string, unknown>) => LLMResult | Promise<LLMResult>;
441
+ declare class MockLLMAdapter implements LLMAdapter {
442
+ private handler;
443
+ constructor(handler?: LLMHandler);
444
+ call(model: string | undefined, prompt: string, responseFormat?: Record<string, unknown>): Promise<LLMResult>;
445
+ }
446
+ //#endregion
447
+ //#region src/adapters/anthropic-llm-adapter.d.ts
448
+ declare class AnthropicLLMAdapter implements LLMAdapter {
449
+ private client;
450
+ constructor(apiKey: string);
451
+ call(model: string | undefined, prompt: string, responseFormat?: Record<string, unknown>): Promise<LLMResult>;
452
+ }
453
+ //#endregion
454
+ //#region src/config/index.d.ts
455
+ /** Google OAuth2 credentials for Gmail/Sheets tools. */
456
+ interface GoogleCredentials {
457
+ clientId: string;
458
+ clientSecret: string;
459
+ refreshToken: string;
460
+ }
461
+ /** WorkflowSkill configuration. */
462
+ interface WorkflowSkillConfig {
463
+ anthropicApiKey?: string;
464
+ googleCredentials?: GoogleCredentials;
465
+ }
466
+ /**
467
+ * Load configuration from environment variables, with .env fallback.
468
+ * Environment variables take precedence over .env file values.
469
+ *
470
+ * .env search order:
471
+ * 1. Explicit `cwd` parameter (for tests)
472
+ * 2. Package root (found by walking up from this module)
473
+ * 3. process.cwd()
474
+ */
475
+ declare function loadConfig(cwd?: string): WorkflowSkillConfig;
476
+ //#endregion
477
+ //#region src/dev-tools/dev-tool-adapter.d.ts
478
+ declare class DevToolAdapter implements ToolAdapter {
479
+ private tools;
480
+ private register;
481
+ has(toolName: string): boolean;
482
+ list(): ToolDescriptor[];
483
+ invoke(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
484
+ /**
485
+ * Create a DevToolAdapter with all available tools registered.
486
+ * Google tools are only registered if credentials are provided.
487
+ */
488
+ static create(config: WorkflowSkillConfig): Promise<DevToolAdapter>;
489
+ }
490
+ //#endregion
491
+ //#region src/executor/types.d.ts
492
+ /** Additional context attached to a step execution error. */
493
+ interface StepErrorContext {
494
+ /** Tool name if the error came from a tool step. */
495
+ tool?: string;
496
+ /** Expression string if the error came from expression resolution. */
497
+ expression?: string;
498
+ }
499
+ /** Error thrown by step executors. */
500
+ declare class StepExecutionError extends Error {
501
+ /** Whether this error is retriable (network errors, rate limits, transient API failures). */
502
+ readonly retriable: boolean;
503
+ /** Optional context about the error source. */
504
+ readonly context?: StepErrorContext | undefined;
505
+ constructor(message: string, /** Whether this error is retriable (network errors, rate limits, transient API failures). */
506
+
507
+ retriable?: boolean, /** Optional context about the error source. */
508
+
509
+ context?: StepErrorContext | undefined);
510
+ }
511
+ /** Result from a standard step execution (tool, llm, transform). */
512
+ interface StepOutput {
513
+ output: unknown;
514
+ tokens?: TokenUsage;
515
+ }
516
+ /** Result from a conditional step execution. */
517
+ interface ConditionalOutput {
518
+ branch: 'then' | 'else' | null;
519
+ stepIds: string[];
520
+ }
521
+ /** Result from an exit step execution. */
522
+ interface ExitOutput {
523
+ status: ExitStatus;
524
+ output: unknown;
525
+ }
526
+ //#endregion
527
+ //#region src/executor/transform.d.ts
528
+ /**
529
+ * Execute a transform step.
530
+ * Returns an object with the first declared output key mapped to the transformed array.
531
+ */
532
+ declare function executeTransform(step: TransformStep, resolvedInputs: Record<string, unknown>, context: RuntimeContext): Record<string, unknown>;
533
+ //#endregion
534
+ //#region src/executor/conditional.d.ts
535
+ /**
536
+ * Execute a conditional step.
537
+ * Evaluates the condition expression and returns the branch to execute.
538
+ * The runtime is responsible for executing the branch steps.
539
+ */
540
+ declare function executeConditional(step: ConditionalStep, context: RuntimeContext): ConditionalOutput;
541
+ //#endregion
542
+ //#region src/executor/exit.d.ts
543
+ /**
544
+ * Execute an exit step.
545
+ * Output can be:
546
+ * - A string expression: resolved against context
547
+ * - An object literal: each string value starting with $ is resolved, others kept as-is
548
+ * - Undefined: null output
549
+ */
550
+ declare function executeExit(step: ExitStep, context: RuntimeContext): ExitOutput;
551
+ //#endregion
552
+ //#region src/executor/tool.d.ts
553
+ /**
554
+ * Execute a tool step.
555
+ * Passes resolved inputs as the tool's arguments. Returns the tool's response.
556
+ * The runtime does not interpret the response (per spec).
557
+ */
558
+ declare function executeTool(step: ToolStep, resolvedInputs: Record<string, unknown>, toolAdapter: ToolAdapter): Promise<StepOutput>;
559
+ //#endregion
560
+ //#region src/executor/llm.d.ts
561
+ /**
562
+ * Execute an LLM step.
563
+ * Interpolates $-references in the prompt, calls the model, and returns the response.
564
+ * The response_format field is passed as a hint but not enforced (per spec).
565
+ * If the response is valid JSON, it's parsed; otherwise returned as text.
566
+ */
567
+ declare function executeLLM(step: LLMStep, _resolvedInputs: Record<string, unknown>, context: RuntimeContext, llmAdapter: LLMAdapter): Promise<StepOutput>;
568
+ //#endregion
569
+ //#region src/executor/index.d.ts
570
+ /** Discriminated result from dispatching a step. */
571
+ type DispatchResult = {
572
+ kind: 'output';
573
+ output: unknown;
574
+ tokens?: TokenUsage;
575
+ } | {
576
+ kind: 'branch';
577
+ branch: 'then' | 'else' | null;
578
+ stepIds: string[];
579
+ } | {
580
+ kind: 'exit';
581
+ status: ExitStatus;
582
+ output: unknown;
583
+ };
584
+ /**
585
+ * Dispatch a step to the appropriate executor.
586
+ * The runtime calls this for each step in the execution loop.
587
+ */
588
+ declare function dispatch(step: Step, resolvedInputs: Record<string, unknown>, context: RuntimeContext, toolAdapter: ToolAdapter, llmAdapter: LLMAdapter): Promise<DispatchResult>;
589
+ //#endregion
590
+ //#region src/runtime/index.d.ts
591
+ declare class WorkflowExecutionError extends Error {
592
+ readonly validationErrors?: ValidationError[] | undefined;
593
+ constructor(message: string, validationErrors?: ValidationError[] | undefined);
594
+ }
595
+ /**
596
+ * Build a minimal RunLog for a pre-execution failure (parse or validate phase).
597
+ * Every run attempt — even those that fail before execution begins — produces a structured artifact.
598
+ */
599
+ declare function buildFailedRunLog(workflowName: string, error: RunLogError, startedAt?: Date): RunLog;
600
+ interface RunOptions {
601
+ workflow: WorkflowDefinition;
602
+ inputs?: Record<string, unknown>;
603
+ toolAdapter: ToolAdapter;
604
+ llmAdapter: LLMAdapter;
605
+ workflowName?: string;
606
+ /** Optional callback for live progress events during execution. */
607
+ onEvent?: (event: RuntimeEvent) => void;
608
+ }
609
+ /**
610
+ * Execute a workflow and produce a run log.
611
+ * Phase 1: Validate the workflow definition.
612
+ * Phase 2: Execute steps in declaration order following the 8-step lifecycle.
613
+ */
614
+ declare function runWorkflow(options: RunOptions): Promise<RunLog>;
615
+ interface RunWorkflowSkillOptions {
616
+ /** SKILL.md content or raw workflow YAML block. */
617
+ content: string;
618
+ inputs?: Record<string, unknown>;
619
+ toolAdapter: ToolAdapter;
620
+ llmAdapter: LLMAdapter;
621
+ /** Fallback name used when content has no frontmatter. Defaults to 'inline'. */
622
+ workflowName?: string;
623
+ onEvent?: (event: RuntimeEvent) => void;
624
+ }
625
+ /**
626
+ * Parse content and execute the workflow in one call. Never throws.
627
+ * Empty or unparseable content → failed RunLog (phase: 'parse').
628
+ * Unexpected execution exception → failed RunLog (phase: 'execute').
629
+ * Validation failures are handled internally by runWorkflow.
630
+ */
631
+ declare function runWorkflowSkill(options: RunWorkflowSkillOptions): Promise<RunLog>;
632
+ //#endregion
633
+ //#region src/skill/index.d.ts
634
+ declare const AUTHORING_SKILL: string;
635
+ //#endregion
636
+ export { AUTHORING_SKILL, AnthropicLLMAdapter, type ConditionalOutput, ConditionalStep, DevToolAdapter, type DispatchResult, EvalError, type ExitOutput, ExitStatus, ExitStep, FieldSchema, type GoogleCredentials, JsonSchema, LLMAdapter, type LLMHandler, LLMResult, LLMStep, LexError, MockLLMAdapter, MockToolAdapter, OnError, ParseError, type ParseErrorDetail, ParseExprError, ParsedSkill, RetryPolicy, RetryRecord, RunLog, RunLogError, type RunOptions, RunStatus, RunSummary, type RunWorkflowSkillOptions, RuntimeContext, RuntimeEvent, SchemaType, SkillFrontmatter, SortDirection, Step, StepBase, type StepErrorContext, StepExecutionError, StepInput, type StepOutput, StepRecord, StepRunStatus, StepType, TokenUsage, ToolAdapter, ToolDescriptor, type ToolHandler, ToolResult, ToolStep, TransformFilterStep, TransformMapStep, TransformOperation, TransformSortStep, TransformStep, type ValidateWorkflowSkillOptions, type ValidateWorkflowSkillResult, ValidationError, ValidationResult, WorkflowDefinition, WorkflowExecutionError, WorkflowInput, WorkflowOutput, type WorkflowSkillConfig, buildFailedRunLog, dispatch, executeConditional, executeExit, executeLLM, executeTool, executeTransform, interpolatePrompt, loadConfig, parseSkillMd, parseWorkflowFromMd, parseWorkflowYaml, resolveExpression, runWorkflow, runWorkflowSkill, validateWorkflow, validateWorkflowSkill };
637
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/index.ts","../src/parser/index.ts","../src/expression/lexer.ts","../src/expression/parser.ts","../src/expression/evaluator.ts","../src/expression/index.ts","../src/validator/index.ts","../src/adapters/mock-tool-adapter.ts","../src/adapters/mock-llm-adapter.ts","../src/adapters/anthropic-llm-adapter.ts","../src/config/index.ts","../src/dev-tools/dev-tool-adapter.ts","../src/executor/types.ts","../src/executor/transform.ts","../src/executor/conditional.ts","../src/executor/exit.ts","../src/executor/tool.ts","../src/executor/llm.ts","../src/executor/index.ts","../src/runtime/index.ts","../src/skill/index.ts"],"mappings":";;KAMY,UAAA;;UAGK,WAAA;EACf,IAAA,EAAM,UAAA;EAJc;EAMpB,KAAA;EAH0B;EAK1B,KAAA,GAAQ,WAAA;EAJF;EAMN,UAAA,GAAa,MAAA,SAAe,UAAA,GAAa,WAAA;AAAA;;U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