@fifthrevision/axle 0.6.4 → 0.6.6

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/dist/index.d.ts CHANGED
@@ -18,9 +18,6 @@ interface Stats {
18
18
  in: number;
19
19
  out: number;
20
20
  }
21
- interface Task {
22
- readonly type: string;
23
- }
24
21
 
25
22
  interface RecorderLevelFunctions {
26
23
  log: (...message: (string | unknown | Error)[]) => void;
@@ -48,6 +45,162 @@ interface RecorderWriter {
48
45
  flush?(): Promise<void>;
49
46
  }
50
47
 
48
+ declare class Recorder {
49
+ instanceId: `${string}-${string}-${string}-${string}-${string}`;
50
+ private currentLevel;
51
+ private logs;
52
+ private writers;
53
+ private _debug;
54
+ private _info;
55
+ private _warn;
56
+ private _error;
57
+ constructor();
58
+ buildMethods(): void;
59
+ set level(level: LogLevel);
60
+ get level(): LogLevel;
61
+ get info(): RecorderLevelFunctions;
62
+ get warn(): RecorderLevelFunctions;
63
+ get error(): RecorderLevelFunctions;
64
+ get debug(): RecorderLevelFunctions;
65
+ subscribe(writer: RecorderWriter): void;
66
+ unsubscribe(writer: RecorderWriter): void;
67
+ private publish;
68
+ private logFunction;
69
+ private createLoggingFunction;
70
+ getLogs(level?: LogLevel): RecorderEntry[];
71
+ /**
72
+ * Ensures all writers have completed their pending operations
73
+ * Call this before exiting the process to ensure logs are written
74
+ */
75
+ shutdown(): Promise<void>;
76
+ }
77
+
78
+ interface Tool<TSchema extends ZodObject<any> = ZodObject<any>> {
79
+ name: string;
80
+ description: string;
81
+ schema: TSchema;
82
+ execute(input: z$1.infer<TSchema>): Promise<string>;
83
+ configure?(config: Record<string, any>): void;
84
+ }
85
+ type ToolDefinition = Pick<Tool, "name" | "description" | "schema">;
86
+
87
+ interface FileInfo {
88
+ path: string;
89
+ base64?: string;
90
+ content?: string;
91
+ mimeType: string;
92
+ size: number;
93
+ name: string;
94
+ type: "image" | "document" | "text";
95
+ }
96
+ type TextFileInfo = FileInfo & {
97
+ content: string;
98
+ base64?: never;
99
+ type: "text";
100
+ };
101
+ type Base64FileInfo = FileInfo & {
102
+ base64: string;
103
+ content?: never;
104
+ type: "image" | "document";
105
+ };
106
+
107
+ declare enum ResultType {
108
+ String = "string",
109
+ List = "string[]",
110
+ Number = "number",
111
+ Boolean = "boolean"
112
+ }
113
+ type ResultTypeUnion = `${ResultType}`;
114
+ type DeclarativeSchema = {
115
+ [key: string]: ResultTypeUnion | DeclarativeSchema | DeclarativeSchema[];
116
+ };
117
+ type OutputSchema = Record<string, z__default.ZodTypeAny>;
118
+ type InferedOutputSchema<T extends OutputSchema> = {
119
+ [K in keyof T]: z__default.output<T[K]>;
120
+ };
121
+
122
+ declare abstract class AbstractInstruct<T extends OutputSchema> {
123
+ readonly name = "instruct";
124
+ prompt: string;
125
+ system: string | null;
126
+ inputs: Record<string, string>;
127
+ tools: Record<string, Tool>;
128
+ files: Base64FileInfo[];
129
+ textReferences: Array<{
130
+ content: string;
131
+ name?: string;
132
+ }>;
133
+ instructions: string[];
134
+ schema: T;
135
+ rawResponse: string;
136
+ protected _taggedSections: {
137
+ tags: Record<string, string>;
138
+ remaining: string;
139
+ } | undefined;
140
+ protected _result: InferedOutputSchema<T> | undefined;
141
+ protected constructor(prompt: string, schema: T);
142
+ setInputs(inputs: Record<string, string>): void;
143
+ addInput(name: string, value: string): void;
144
+ addTools(tools: Tool[]): void;
145
+ addTool(tool: Tool): void;
146
+ addImage(file: FileInfo): void;
147
+ addDocument(file: FileInfo): void;
148
+ addFile(file: FileInfo): void;
149
+ addReference(textFile: FileInfo | TextFileInfo | string, options?: {
150
+ name?: string;
151
+ }): void;
152
+ addInstructions(instruction: string): void;
153
+ hasTools(): boolean;
154
+ hasFiles(): boolean;
155
+ get result(): InferedOutputSchema<T> | undefined;
156
+ compile(variables: Record<string, string>, runtime?: {
157
+ recorder?: Recorder;
158
+ options?: {
159
+ warnUnused?: boolean;
160
+ };
161
+ }): {
162
+ message: string;
163
+ instructions: string;
164
+ };
165
+ protected createUserMessage(variables: Record<string, string>, runtime?: {
166
+ recorder?: Recorder;
167
+ options?: {
168
+ warnUnused?: boolean;
169
+ };
170
+ }): string;
171
+ protected createInstructions(instructions?: string): string;
172
+ protected generateFieldInstructions(key: string, schema: z.ZodTypeAny): string;
173
+ finalize(rawValue: string, runtime?: {
174
+ recorder?: Recorder;
175
+ }): InferedOutputSchema<T>;
176
+ private preprocessValue;
177
+ protected parseTaggedSections(input: string): {
178
+ tags: Record<string, string>;
179
+ remaining: string;
180
+ };
181
+ }
182
+
183
+ declare class Instruct<T extends OutputSchema> extends AbstractInstruct<T> {
184
+ constructor(prompt: string, schema: T);
185
+ static with<T extends OutputSchema>(prompt: string, schema: T): Instruct<T>;
186
+ static with<T extends DeclarativeSchema>(prompt: string, schema: T): Instruct<OutputSchema>;
187
+ static with(prompt: string): Instruct<{
188
+ response: z.ZodString;
189
+ }>;
190
+ }
191
+
192
+ interface ActionContext {
193
+ input: string;
194
+ variables: Record<string, any>;
195
+ options?: ProgramOptions;
196
+ recorder?: Recorder;
197
+ }
198
+ interface Action {
199
+ name: string;
200
+ execute(context: ActionContext): Promise<string | void>;
201
+ }
202
+ type WorkflowStep = Instruct<any> | Action;
203
+
51
204
  interface StreamChunk {
52
205
  type: "start" | "text" | "tool-call-start" | "tool-call-delta" | "tool-call-complete" | "thinking-start" | "thinking-delta" | "complete" | "error";
53
206
  id?: string;
@@ -117,56 +270,6 @@ interface StreamErrorChunk extends StreamChunk {
117
270
  }
118
271
  type AnyStreamChunk = StreamStartChunk | StreamCompleteChunk | StreamTextChunk | StreamToolCallStartChunk | StreamToolCallCompleteChunk | StreamThinkingStartChunk | StreamThinkingDeltaChunk | StreamErrorChunk;
119
272
 
120
- declare class Recorder {
121
- instanceId: `${string}-${string}-${string}-${string}-${string}`;
122
- private currentLevel;
123
- private logs;
124
- private writers;
125
- private _debug;
126
- private _info;
127
- private _warn;
128
- private _error;
129
- constructor();
130
- buildMethods(): void;
131
- set level(level: LogLevel);
132
- get level(): LogLevel;
133
- get info(): RecorderLevelFunctions;
134
- get warn(): RecorderLevelFunctions;
135
- get error(): RecorderLevelFunctions;
136
- get debug(): RecorderLevelFunctions;
137
- subscribe(writer: RecorderWriter): void;
138
- unsubscribe(writer: RecorderWriter): void;
139
- private publish;
140
- private logFunction;
141
- private createLoggingFunction;
142
- getLogs(level?: LogLevel): RecorderEntry[];
143
- /**
144
- * Ensures all writers have completed their pending operations
145
- * Call this before exiting the process to ensure logs are written
146
- */
147
- shutdown(): Promise<void>;
148
- }
149
-
150
- interface FileInfo {
151
- path: string;
152
- base64?: string;
153
- content?: string;
154
- mimeType: string;
155
- size: number;
156
- name: string;
157
- type: "image" | "document" | "text";
158
- }
159
- type TextFileInfo = FileInfo & {
160
- content: string;
161
- base64?: never;
162
- type: "text";
163
- };
164
- type Base64FileInfo = FileInfo & {
165
- base64: string;
166
- content?: never;
167
- type: "image" | "document";
168
- };
169
-
170
273
  type AxleMessage = AxleUserMessage | AxleAssistantMessage | AxleToolCallMessage;
171
274
  interface AxleUserMessage {
172
275
  role: "user";
@@ -212,18 +315,6 @@ interface ContentPartToolCall {
212
315
  parameters: Record<string, unknown>;
213
316
  }
214
317
 
215
- type ToolDefinition<Z extends ZodObject = ZodObject> = {
216
- name: string;
217
- description?: string;
218
- schema: Z;
219
- };
220
- interface ToolExecutable<Z extends ZodObject = ZodObject> extends ToolDefinition<Z> {
221
- setConfig?: (config: {
222
- [key: string]: any;
223
- }) => void;
224
- execute: (params: z$1.infer<Z>) => Promise<string>;
225
- }
226
-
227
318
  type OllamaProviderConfig = {
228
319
  url?: string;
229
320
  model: string;
@@ -326,11 +417,11 @@ declare class AxleError extends Error {
326
417
  }
327
418
 
328
419
  interface Planner {
329
- plan(tasks: Task[]): Promise<Run[]>;
420
+ plan(steps: WorkflowStep[]): Promise<Run[]>;
330
421
  }
331
422
 
332
423
  interface Run {
333
- tasks: Task[];
424
+ steps: WorkflowStep[];
334
425
  variables: Record<string, any>;
335
426
  }
336
427
  interface SerializedExecutionResponse {
@@ -354,16 +445,16 @@ interface WorkflowExecutable {
354
445
  }) => Promise<WorkflowResult>;
355
446
  }
356
447
  interface DAGNodeDefinition {
357
- task: Task | Task[];
448
+ step: WorkflowStep | WorkflowStep[];
358
449
  dependsOn?: string | string[];
359
450
  }
360
451
  interface DAGConcurrentNodeDefinition {
361
452
  planner: Planner;
362
- tasks: Task[];
453
+ steps: WorkflowStep[];
363
454
  dependsOn?: string | string[];
364
455
  }
365
456
  interface DAGDefinition {
366
- [nodeName: string]: Task | Task[] | DAGNodeDefinition | DAGConcurrentNodeDefinition;
457
+ [nodeName: string]: WorkflowStep | WorkflowStep[] | DAGNodeDefinition | DAGConcurrentNodeDefinition;
367
458
  }
368
459
  interface DAGWorkflowOptions {
369
460
  continueOnError?: boolean;
@@ -379,10 +470,10 @@ declare class Axle {
379
470
  addWriter(writer: RecorderWriter): void;
380
471
  /**
381
472
  * The execute function takes in a list of Tasks
382
- * @param tasks
473
+ * @param steps
383
474
  * @returns
384
475
  */
385
- execute(...tasks: Task[]): Promise<WorkflowResult>;
476
+ execute(...steps: WorkflowStep[]): Promise<WorkflowResult>;
386
477
  /**
387
478
  * Execute a DAG workflow
388
479
  * @param dagDefinition - The DAG definition object
@@ -403,6 +494,21 @@ declare class Axle {
403
494
  static loadFileContent(filePath: string, encoding: "base64"): Promise<Base64FileInfo>;
404
495
  }
405
496
 
497
+ declare class ChainOfThought<T extends OutputSchema> extends AbstractInstruct<T> {
498
+ constructor(prompt: string, schema: T);
499
+ static with<T extends OutputSchema>(prompt: string, schema: T): ChainOfThought<T>;
500
+ static with<T extends DeclarativeSchema>(prompt: string, schema: T): ChainOfThought<OutputSchema>;
501
+ static with(prompt: string): ChainOfThought<{
502
+ response: z.ZodString;
503
+ }>;
504
+ createInstructions(instructions?: string): string;
505
+ finalize(rawValue: string, runtime?: {
506
+ recorder?: Recorder;
507
+ }): InferedOutputSchema<T> & {
508
+ thinking: string;
509
+ };
510
+ }
511
+
406
512
  declare const Models$2: {
407
513
  readonly CLAUDE_SONNET_4_5_20250929: "claude-sonnet-4-5-20250929";
408
514
  readonly CLAUDE_SONNET_4_5_LATEST: "claude-sonnet-4-5";
@@ -609,13 +715,134 @@ declare class OllamaProvider implements AIProvider {
609
715
  }): AsyncGenerator<AnyStreamChunk, void, unknown>;
610
716
  }
611
717
 
612
- declare const index$1_DEFAULT_OLLAMA_URL: typeof DEFAULT_OLLAMA_URL;
613
- declare namespace index$1 {
614
- export {
615
- index$1_DEFAULT_OLLAMA_URL as DEFAULT_OLLAMA_URL,
616
- NAME$1 as NAME,
617
- OllamaProvider as Provider,
618
- };
718
+ declare const NAME: "OpenAI";
719
+ declare class OpenAIProvider implements AIProvider {
720
+ name: "OpenAI";
721
+ client: OpenAI;
722
+ model: string;
723
+ constructor(apiKey: string, model?: string | undefined);
724
+ createGenerationRequest(params: {
725
+ messages: Array<AxleMessage>;
726
+ system?: string;
727
+ tools?: Array<ToolDefinition>;
728
+ context: {
729
+ recorder?: Recorder;
730
+ };
731
+ options?: {
732
+ temperature?: number;
733
+ top_p?: number;
734
+ max_tokens?: number;
735
+ frequency_penalty?: number;
736
+ presence_penalty?: number;
737
+ stop?: string | string[];
738
+ [key: string]: any;
739
+ };
740
+ }): Promise<ModelResult>;
741
+ createStreamingRequest(params: {
742
+ messages: Array<AxleMessage>;
743
+ system?: string;
744
+ tools?: Array<ToolDefinition>;
745
+ context: {
746
+ recorder?: Recorder;
747
+ };
748
+ options?: {
749
+ temperature?: number;
750
+ top_p?: number;
751
+ max_tokens?: number;
752
+ frequency_penalty?: number;
753
+ presence_penalty?: number;
754
+ stop?: string | string[];
755
+ [key: string]: any;
756
+ };
757
+ }): AsyncGenerator<AnyStreamChunk, void, unknown>;
758
+ }
759
+
760
+ interface GenerateOptions {
761
+ temperature?: number;
762
+ top_p?: number;
763
+ max_tokens?: number;
764
+ frequency_penalty?: number;
765
+ presence_penalty?: number;
766
+ stop?: string | string[];
767
+ [key: string]: any;
768
+ }
769
+ interface GenerateProps {
770
+ provider: AIProvider;
771
+ messages: Array<AxleMessage>;
772
+ system?: string;
773
+ tools?: Array<ToolDefinition>;
774
+ recorder?: Recorder;
775
+ options?: GenerateOptions;
776
+ }
777
+ declare function generate(props: GenerateProps): Promise<ModelResult>;
778
+
779
+ type ToolCallResult = {
780
+ type: "success";
781
+ content: string;
782
+ } | {
783
+ type: "error";
784
+ error: {
785
+ type: string;
786
+ message: string;
787
+ fatal?: boolean;
788
+ retryable?: boolean;
789
+ };
790
+ };
791
+ type GenerateWithToolsError = {
792
+ type: "model";
793
+ error: ModelError;
794
+ } | {
795
+ type: "tool";
796
+ error: {
797
+ name: string;
798
+ message: string;
799
+ };
800
+ };
801
+ type GenerateWithToolsResult = {
802
+ result: "success";
803
+ messages: AxleMessage[];
804
+ final?: AxleAssistantMessage;
805
+ usage?: Stats;
806
+ } | {
807
+ result: "error";
808
+ messages: AxleMessage[];
809
+ error: GenerateWithToolsError;
810
+ usage?: Stats;
811
+ };
812
+ interface GenerateWithToolsOptions {
813
+ provider: AIProvider;
814
+ messages: Array<AxleMessage>;
815
+ system?: string;
816
+ tools?: Array<ToolDefinition>;
817
+ onToolCall: (name: string, params: Record<string, unknown>) => Promise<ToolCallResult | null | undefined>;
818
+ maxIterations?: number;
819
+ recorder?: Recorder;
820
+ options?: GenerateOptions;
821
+ }
822
+ declare function generateWithTools(options: GenerateWithToolsOptions): Promise<GenerateWithToolsResult>;
823
+
824
+ interface StreamProps {
825
+ provider: AIProvider;
826
+ messages: Array<AxleMessage>;
827
+ system?: string;
828
+ tools?: Array<ToolDefinition>;
829
+ recorder?: Recorder;
830
+ options?: GenerateOptions;
831
+ }
832
+ interface StreamResult {
833
+ get final(): Promise<ModelResult>;
834
+ get current(): AxleAssistantMessage;
835
+ [Symbol.asyncIterator](): AsyncIterator<AnyStreamChunk>;
836
+ }
837
+ declare function stream(props: StreamProps): StreamResult;
838
+
839
+ declare const index$1_DEFAULT_OLLAMA_URL: typeof DEFAULT_OLLAMA_URL;
840
+ declare namespace index$1 {
841
+ export {
842
+ index$1_DEFAULT_OLLAMA_URL as DEFAULT_OLLAMA_URL,
843
+ NAME$1 as NAME,
844
+ OllamaProvider as Provider,
845
+ };
619
846
  }
620
847
 
621
848
  declare const Models: {
@@ -685,48 +912,6 @@ declare const Models: {
685
912
  };
686
913
  declare const DEFAULT_MODEL: "gpt-5";
687
914
 
688
- declare const NAME: "OpenAI";
689
- declare class OpenAIProvider implements AIProvider {
690
- name: "OpenAI";
691
- client: OpenAI;
692
- model: string;
693
- constructor(apiKey: string, model?: string | undefined);
694
- createGenerationRequest(params: {
695
- messages: Array<AxleMessage>;
696
- system?: string;
697
- tools?: Array<ToolDefinition>;
698
- context: {
699
- recorder?: Recorder;
700
- };
701
- options?: {
702
- temperature?: number;
703
- top_p?: number;
704
- max_tokens?: number;
705
- frequency_penalty?: number;
706
- presence_penalty?: number;
707
- stop?: string | string[];
708
- [key: string]: any;
709
- };
710
- }): Promise<ModelResult>;
711
- createStreamingRequest(params: {
712
- messages: Array<AxleMessage>;
713
- system?: string;
714
- tools?: Array<ToolDefinition>;
715
- context: {
716
- recorder?: Recorder;
717
- };
718
- options?: {
719
- temperature?: number;
720
- top_p?: number;
721
- max_tokens?: number;
722
- frequency_penalty?: number;
723
- presence_penalty?: number;
724
- stop?: string | string[];
725
- [key: string]: any;
726
- };
727
- }): AsyncGenerator<AnyStreamChunk, void, unknown>;
728
- }
729
-
730
915
  declare const index_DEFAULT_MODEL: typeof DEFAULT_MODEL;
731
916
  declare const index_Models: typeof Models;
732
917
  declare const index_NAME: typeof NAME;
@@ -739,215 +924,302 @@ declare namespace index {
739
924
  };
740
925
  }
741
926
 
742
- interface GenerateOptions {
743
- temperature?: number;
744
- top_p?: number;
745
- max_tokens?: number;
746
- frequency_penalty?: number;
747
- presence_penalty?: number;
748
- stop?: string | string[];
749
- [key: string]: any;
750
- }
751
- interface GenerateProps {
752
- provider: AIProvider;
753
- messages: Array<AxleMessage>;
754
- system?: string;
755
- tools?: Array<ToolDefinition>;
756
- recorder?: Recorder;
757
- options?: GenerateOptions;
758
- }
759
- declare function generate(props: GenerateProps): Promise<ModelResult>;
760
-
761
- interface StreamProps {
762
- provider: AIProvider;
763
- messages: Array<AxleMessage>;
764
- system?: string;
765
- tools?: Array<ToolDefinition>;
766
- recorder?: Recorder;
767
- options?: GenerateOptions;
768
- }
769
- interface StreamResult {
770
- get final(): Promise<ModelResult>;
771
- get current(): AxleAssistantMessage;
772
- [Symbol.asyncIterator](): AsyncIterator<AnyStreamChunk>;
773
- }
774
- declare function stream(props: StreamProps): StreamResult;
775
-
776
- declare enum ResultType {
777
- String = "string",
778
- List = "string[]",
779
- Number = "number",
780
- Boolean = "boolean"
781
- }
782
- type ResultTypeUnion = `${ResultType}`;
783
- type DeclarativeSchema = {
784
- [key: string]: ResultTypeUnion | DeclarativeSchema | DeclarativeSchema[];
785
- };
786
- type OutputSchema = Record<string, z__default.ZodTypeAny>;
787
- type InferedOutputSchema<T extends OutputSchema> = {
788
- [K in keyof T]: z__default.output<T[K]>;
789
- };
790
-
791
- declare abstract class AbstractInstruct<T extends OutputSchema> implements Task {
792
- readonly type = "instruct";
793
- prompt: string;
794
- system: string | null;
795
- inputs: Record<string, string>;
796
- tools: Record<string, ToolExecutable>;
797
- files: Base64FileInfo[];
798
- textReferences: Array<{
799
- content: string;
800
- name?: string;
801
- }>;
802
- instructions: string[];
803
- schema: T;
804
- rawResponse: string;
805
- protected _taggedSections: {
806
- tags: Record<string, string>;
807
- remaining: string;
808
- } | undefined;
809
- protected _result: InferedOutputSchema<T> | undefined;
810
- protected constructor(prompt: string, schema: T);
811
- setInputs(inputs: Record<string, string>): void;
812
- addInput(name: string, value: string): void;
813
- addTools(tools: ToolExecutable[]): void;
814
- addTool(tool: ToolExecutable): void;
815
- addImage(file: FileInfo): void;
816
- addDocument(file: FileInfo): void;
817
- addFile(file: FileInfo): void;
818
- addReference(textFile: FileInfo | TextFileInfo | string, options?: {
819
- name?: string;
820
- }): void;
821
- addInstructions(instruction: string): void;
822
- hasTools(): boolean;
823
- hasFiles(): boolean;
824
- get result(): InferedOutputSchema<T> | undefined;
825
- compile(variables: Record<string, string>, runtime?: {
826
- recorder?: Recorder;
827
- options?: {
828
- warnUnused?: boolean;
829
- };
830
- }): {
831
- message: string;
832
- instructions: string;
833
- };
834
- protected createUserMessage(variables: Record<string, string>, runtime?: {
835
- recorder?: Recorder;
836
- options?: {
837
- warnUnused?: boolean;
838
- };
839
- }): string;
840
- protected createInstructions(instructions?: string): string;
841
- protected generateFieldInstructions(key: string, schema: z.ZodTypeAny): string;
842
- finalize(rawValue: string, runtime?: {
843
- recorder?: Recorder;
844
- }): InferedOutputSchema<T>;
845
- private preprocessValue;
846
- protected parseTaggedSections(input: string): {
847
- tags: Record<string, string>;
848
- remaining: string;
849
- };
850
- }
927
+ declare const BraveProviderConfigSchema: z$1.ZodObject<{
928
+ "api-key": z$1.ZodString;
929
+ rateLimit: z$1.ZodOptional<z$1.ZodNumber>;
930
+ }, z$1.core.$strip>;
931
+ type BraveProviderConfig = z$1.infer<typeof BraveProviderConfigSchema>;
932
+ declare const JobSchema: z$1.ZodPipe<z$1.ZodTransform<any, any>, z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
933
+ type: z$1.ZodLiteral<"serial">;
934
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
935
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
936
+ uses: z$1.ZodLiteral<"chat">;
937
+ system: z$1.ZodOptional<z$1.ZodString>;
938
+ message: z$1.ZodString;
939
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
940
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
941
+ source: z$1.ZodLiteral<"file">;
942
+ pattern: z$1.ZodString;
943
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
944
+ }, z$1.core.$strip>>>;
945
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
946
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
947
+ file: z$1.ZodString;
948
+ }, z$1.core.$strip>>>;
949
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
950
+ file: z$1.ZodString;
951
+ }, z$1.core.$strip>>>;
952
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
953
+ file: z$1.ZodString;
954
+ }, z$1.core.$strip>>>;
955
+ }, z$1.core.$strip>, z$1.ZodObject<{
956
+ uses: z$1.ZodLiteral<"write-to-disk">;
957
+ output: z$1.ZodString;
958
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
959
+ }, z$1.core.$strip>], "uses">>;
960
+ }, z$1.core.$strip>, z$1.ZodObject<{
961
+ type: z$1.ZodLiteral<"batch">;
962
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
963
+ batch: z$1.ZodArray<z$1.ZodObject<{
964
+ type: z$1.ZodLiteral<"files">;
965
+ source: z$1.ZodString;
966
+ bind: z$1.ZodString;
967
+ "skip-if": z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
968
+ type: z$1.ZodLiteral<"file-exist">;
969
+ pattern: z$1.ZodString;
970
+ }, z$1.core.$strip>>>;
971
+ }, z$1.core.$strip>>;
972
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
973
+ uses: z$1.ZodLiteral<"chat">;
974
+ system: z$1.ZodOptional<z$1.ZodString>;
975
+ message: z$1.ZodString;
976
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
977
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
978
+ source: z$1.ZodLiteral<"file">;
979
+ pattern: z$1.ZodString;
980
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
981
+ }, z$1.core.$strip>>>;
982
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
983
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
984
+ file: z$1.ZodString;
985
+ }, z$1.core.$strip>>>;
986
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
987
+ file: z$1.ZodString;
988
+ }, z$1.core.$strip>>>;
989
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
990
+ file: z$1.ZodString;
991
+ }, z$1.core.$strip>>>;
992
+ }, z$1.core.$strip>, z$1.ZodObject<{
993
+ uses: z$1.ZodLiteral<"write-to-disk">;
994
+ output: z$1.ZodString;
995
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
996
+ }, z$1.core.$strip>], "uses">>;
997
+ }, z$1.core.$strip>], "type">>;
998
+ type Job = z$1.infer<typeof JobSchema>;
999
+ type SerialJob = Extract<Job, {
1000
+ type: "serial";
1001
+ }>;
1002
+ type BatchJob = Extract<Job, {
1003
+ type: "batch";
1004
+ }>;
1005
+ declare const DAGJobSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodPipe<z$1.ZodTransform<any, any>, z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
1006
+ type: z$1.ZodLiteral<"serial">;
1007
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1008
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
1009
+ uses: z$1.ZodLiteral<"chat">;
1010
+ system: z$1.ZodOptional<z$1.ZodString>;
1011
+ message: z$1.ZodString;
1012
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
1013
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1014
+ source: z$1.ZodLiteral<"file">;
1015
+ pattern: z$1.ZodString;
1016
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
1017
+ }, z$1.core.$strip>>>;
1018
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1019
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1020
+ file: z$1.ZodString;
1021
+ }, z$1.core.$strip>>>;
1022
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1023
+ file: z$1.ZodString;
1024
+ }, z$1.core.$strip>>>;
1025
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1026
+ file: z$1.ZodString;
1027
+ }, z$1.core.$strip>>>;
1028
+ }, z$1.core.$strip>, z$1.ZodObject<{
1029
+ uses: z$1.ZodLiteral<"write-to-disk">;
1030
+ output: z$1.ZodString;
1031
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1032
+ }, z$1.core.$strip>], "uses">>;
1033
+ dependsOn: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1034
+ }, z$1.core.$strip>, z$1.ZodObject<{
1035
+ type: z$1.ZodLiteral<"batch">;
1036
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1037
+ batch: z$1.ZodArray<z$1.ZodObject<{
1038
+ type: z$1.ZodLiteral<"files">;
1039
+ source: z$1.ZodString;
1040
+ bind: z$1.ZodString;
1041
+ "skip-if": z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1042
+ type: z$1.ZodLiteral<"file-exist">;
1043
+ pattern: z$1.ZodString;
1044
+ }, z$1.core.$strip>>>;
1045
+ }, z$1.core.$strip>>;
1046
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
1047
+ uses: z$1.ZodLiteral<"chat">;
1048
+ system: z$1.ZodOptional<z$1.ZodString>;
1049
+ message: z$1.ZodString;
1050
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
1051
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1052
+ source: z$1.ZodLiteral<"file">;
1053
+ pattern: z$1.ZodString;
1054
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
1055
+ }, z$1.core.$strip>>>;
1056
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1057
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1058
+ file: z$1.ZodString;
1059
+ }, z$1.core.$strip>>>;
1060
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1061
+ file: z$1.ZodString;
1062
+ }, z$1.core.$strip>>>;
1063
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1064
+ file: z$1.ZodString;
1065
+ }, z$1.core.$strip>>>;
1066
+ }, z$1.core.$strip>, z$1.ZodObject<{
1067
+ uses: z$1.ZodLiteral<"write-to-disk">;
1068
+ output: z$1.ZodString;
1069
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1070
+ }, z$1.core.$strip>], "uses">>;
1071
+ dependsOn: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1072
+ }, z$1.core.$strip>], "type">>>;
1073
+ type DAGJob = z$1.infer<typeof DAGJobSchema>;
851
1074
 
852
- declare class Instruct<T extends OutputSchema> extends AbstractInstruct<T> {
853
- constructor(prompt: string, schema: T);
854
- static with<T extends OutputSchema>(prompt: string, schema: T): Instruct<T>;
855
- static with<T extends DeclarativeSchema>(prompt: string, schema: T): Instruct<OutputSchema>;
856
- static with(prompt: string): Instruct<{
857
- response: z.ZodString;
858
- }>;
859
- }
1075
+ declare const braveSearchSchema: z.ZodObject<{
1076
+ searchTerm: z.ZodString;
1077
+ }, z.core.$strip>;
1078
+ declare class BraveSearchTool implements Tool<typeof braveSearchSchema> {
1079
+ name: string;
1080
+ description: string;
1081
+ schema: z.ZodObject<{
1082
+ searchTerm: z.ZodString;
1083
+ }, z.core.$strip>;
1084
+ apiKey: string;
1085
+ throttle: number | undefined;
1086
+ lastExecTime: number;
1087
+ constructor(config?: BraveProviderConfig);
1088
+ configure(config: BraveProviderConfig): void;
1089
+ execute(params: z.infer<typeof braveSearchSchema>): Promise<string>;
1090
+ }
1091
+ declare const braveSearchTool: BraveSearchTool;
860
1092
 
861
- declare class ChainOfThought<T extends OutputSchema> extends AbstractInstruct<T> {
862
- constructor(prompt: string, schema: T);
863
- static with<T extends OutputSchema>(prompt: string, schema: T): ChainOfThought<T>;
864
- static with<T extends DeclarativeSchema>(prompt: string, schema: T): ChainOfThought<OutputSchema>;
865
- static with(prompt: string): ChainOfThought<{
866
- response: z.ZodString;
1093
+ declare const calculatorSchema: z$1.ZodObject<{
1094
+ operation: z$1.ZodEnum<{
1095
+ add: "add";
1096
+ subtract: "subtract";
1097
+ multiply: "multiply";
1098
+ divide: "divide";
867
1099
  }>;
868
- createInstructions(instructions?: string): string;
869
- finalize(rawValue: string, runtime?: {
870
- recorder?: Recorder;
871
- }): InferedOutputSchema<T> & {
872
- thinking: string;
873
- };
874
- }
875
-
876
- interface WriteToDiskTask extends Task {
877
- type: "write-to-disk";
878
- output: string;
879
- keys: string[];
880
- }
881
- declare class WriteOutputTask implements WriteToDiskTask {
882
- output: string;
883
- keys: string[];
884
- type: "write-to-disk";
885
- constructor(output: string, keys?: string[]);
886
- }
1100
+ a: z$1.ZodNumber;
1101
+ b: z$1.ZodNumber;
1102
+ }, z$1.core.$strip>;
1103
+ declare const calculatorTool: Tool<typeof calculatorSchema>;
887
1104
 
888
- interface DAGJob {
889
- [name: string]: Job & {
890
- dependsOn?: string | string[];
891
- };
892
- }
893
- type Job = SerialJob | BatchJob;
894
- interface SerialJob {
895
- tools?: string[];
896
- steps: Step[];
897
- }
898
- interface BatchJob {
899
- tools?: string[];
900
- batch: BatchOptions[];
901
- steps: Step[];
902
- }
903
- interface SkipOptions {
904
- type: "file-exist";
905
- pattern: string;
906
- }
907
- interface BatchOptions {
908
- type: "files";
909
- source: string;
910
- bind: string;
911
- ["skip-if"]?: SkipOptions[];
912
- }
913
- type Step = ChatStep | WriteToDiskStep;
914
- interface StepBase {
915
- readonly uses: string;
916
- }
917
- interface ChatStep extends StepBase {
918
- uses: "chat";
919
- system?: string;
920
- message: string;
921
- output?: Record<string, ResultTypeUnion>;
922
- replace?: Replace[];
923
- tools?: string[];
924
- images?: ImageReference[];
925
- documents?: DocumentReference[];
926
- references?: TextFileReference[];
927
- }
928
- interface WriteToDiskStep extends StepBase {
929
- uses: "write-to-disk";
930
- output: string;
931
- keys?: string | string[];
932
- }
933
- interface Replace {
934
- source: "file";
935
- pattern: string;
936
- files: string | string[];
937
- }
938
- interface ImageReference {
939
- file: string;
940
- }
941
- interface DocumentReference {
942
- file: string;
943
- }
944
- interface TextFileReference {
945
- file: string;
1105
+ /**
1106
+ * WriteToDisk Action
1107
+ *
1108
+ * Writes content to a file on disk. This action is typically used as a workflow
1109
+ * step following an LLM call to persist the generated output.
1110
+ *
1111
+ * ## CLI Job Definition (YAML)
1112
+ *
1113
+ * In job YAML files, use the `write-to-disk` step type:
1114
+ *
1115
+ * ```yaml
1116
+ * steps:
1117
+ * - uses: chat
1118
+ * message: Generate a greeting for {{name}}
1119
+ * - uses: write-to-disk
1120
+ * output: ./output/greeting-{{name}}.txt
1121
+ * ```
1122
+ *
1123
+ * ### Properties
1124
+ *
1125
+ * | Property | Type | Required | Description |
1126
+ * |----------|----------------------|----------|--------------------------------------------------|
1127
+ * | `uses` | `"write-to-disk"` | Yes | Identifies this as a WriteToDisk step |
1128
+ * | `output` | `string` | Yes | File path template (supports `{{}}` placeholders)|
1129
+ * | `keys` | `string \| string[]` | No | Variable keys to include in output content |
1130
+ *
1131
+ * ### Examples
1132
+ *
1133
+ * **Basic usage** - writes the LLM response to a file:
1134
+ * ```yaml
1135
+ * - uses: write-to-disk
1136
+ * output: ./output/result.txt
1137
+ * ```
1138
+ *
1139
+ * **With path variables** - uses `{{}}` placeholders in path:
1140
+ * ```yaml
1141
+ * - uses: write-to-disk
1142
+ * output: ./output/greeting-{{name}}.txt
1143
+ * ```
1144
+ *
1145
+ * **With file pattern** (batch processing) - uses `*` to substitute file stem:
1146
+ * ```yaml
1147
+ * - uses: write-to-disk
1148
+ * output: ./output/results-*.txt
1149
+ * ```
1150
+ *
1151
+ * **With specific keys** - outputs only specified variables:
1152
+ * ```yaml
1153
+ * - uses: write-to-disk
1154
+ * output: ./output/summary.txt
1155
+ * keys: summary
1156
+ * ```
1157
+ *
1158
+ * **With multiple keys** - outputs multiple variables, each on a new line:
1159
+ * ```yaml
1160
+ * - uses: write-to-disk
1161
+ * output: ./output/report.txt
1162
+ * keys:
1163
+ * - title
1164
+ * - summary
1165
+ * - conclusion
1166
+ * ```
1167
+ *
1168
+ * ## Placeholder Styles
1169
+ *
1170
+ * This action uses `{{variable}}` placeholder style for all variable substitution:
1171
+ *
1172
+ * - **Path template** (`output`): Uses `{{variable}}` placeholders
1173
+ * - Example: `./output/greeting-{{name}}.txt`
1174
+ * - Also supports `*` for file stem substitution in batch processing
1175
+ *
1176
+ * - **Content template** (`keys`): Uses `{{variable}}` placeholders
1177
+ * - Default template: `{{response}}`
1178
+ * - When `keys` is specified, generates: `{{key1}}\n{{key2}}\n...`
1179
+ *
1180
+ * ## Variables Available
1181
+ *
1182
+ * All variables from the workflow context are available for substitution:
1183
+ * - `response` - The text response from the previous LLM step
1184
+ * - `$previous` - The full output object from the previous step
1185
+ * - `file` - File info object when processing batches (contains `stem`, `name`, `ext`, etc.)
1186
+ * - Any custom variables defined in the workflow or extracted by previous steps
1187
+ *
1188
+ * @see WriteToDiskStep in `src/cli/configs/types.ts` for the TypeScript interface
1189
+ * @see writeToDiskConverter in `src/cli/converters/writeToDisk.ts` for CLI conversion logic
1190
+ */
1191
+ declare class WriteToDisk implements Action {
1192
+ private pathTemplate;
1193
+ private contentTemplate;
1194
+ name: string;
1195
+ /**
1196
+ * Creates a new WriteToDisk action.
1197
+ *
1198
+ * @param pathTemplate - The file path template. Supports:
1199
+ * - `{{variable}}` placeholders for variable substitution
1200
+ * - `*` for file stem substitution (batch processing)
1201
+ * @param contentTemplate - The content template using `{{variable}}` placeholders.
1202
+ * Defaults to `{{response}}` to output the LLM response.
1203
+ */
1204
+ constructor(pathTemplate: string, contentTemplate?: string);
1205
+ /**
1206
+ * Executes the write-to-disk action.
1207
+ *
1208
+ * Resolves the path and content templates using workflow variables,
1209
+ * then writes the content to the resolved file path.
1210
+ *
1211
+ * @param context - The action execution context containing:
1212
+ * - `variables`: All workflow variables available for substitution
1213
+ * - `options`: Execution options (e.g., `dryRun`)
1214
+ * - `recorder`: Optional recorder for logging
1215
+ * @returns A promise that resolves when the file has been written
1216
+ */
1217
+ execute(context: ActionContext): Promise<void>;
946
1218
  }
947
1219
 
948
1220
  interface ConcurrentWorkflow {
949
1221
  (jobConfig: BatchJob): WorkflowExecutable;
950
- (planner: Planner, ...instructions: Task[]): WorkflowExecutable;
1222
+ (planner: Planner, ...steps: WorkflowStep[]): WorkflowExecutable;
951
1223
  }
952
1224
  declare const concurrentWorkflow: ConcurrentWorkflow;
953
1225
 
@@ -958,10 +1230,26 @@ declare const dagWorkflow: DAGWorkflow;
958
1230
 
959
1231
  interface SerialWorkflow {
960
1232
  (jobConfig: SerialJob): WorkflowExecutable;
961
- (...instructions: Task[]): WorkflowExecutable;
1233
+ (...steps: WorkflowStep[]): WorkflowExecutable;
962
1234
  }
963
1235
  declare const serialWorkflow: SerialWorkflow;
964
1236
 
1237
+ declare class Conversation {
1238
+ system: string;
1239
+ private _messages;
1240
+ constructor(messages?: AxleMessage[]);
1241
+ get messages(): AxleMessage[];
1242
+ addSystem(message: string): void;
1243
+ addUser(message: string): void;
1244
+ addUser(parts: AxleUserMessage["content"]): void;
1245
+ addAssistant(message: string): void;
1246
+ addAssistant(params: Omit<AxleAssistantMessage, "role">): void;
1247
+ addToolResults(input: Array<AxleToolCallResult>): void;
1248
+ add(messages: AxleMessage | AxleMessage[]): void;
1249
+ latest(): AxleMessage | undefined;
1250
+ toString(): string;
1251
+ }
1252
+
965
1253
  declare class ConsoleWriter implements RecorderWriter {
966
1254
  private tasks;
967
1255
  private entries;
@@ -982,20 +1270,5 @@ declare class ConsoleWriter implements RecorderWriter {
982
1270
  destroy(): void;
983
1271
  }
984
1272
 
985
- declare class Conversation {
986
- system: string;
987
- private _messages;
988
- constructor(messages?: AxleMessage[]);
989
- get messages(): AxleMessage[];
990
- addSystem(message: string): void;
991
- addUser(message: string): void;
992
- addUser(parts: AxleUserMessage["content"]): void;
993
- addAssistant(message: string): void;
994
- addAssistant(params: Omit<AxleAssistantMessage, "role">): void;
995
- addToolResults(input: Array<AxleToolCallResult>): void;
996
- latest(): AxleMessage | undefined;
997
- toString(): string;
998
- }
999
-
1000
- export { index$3 as Anthropic, Axle, AxleStopReason, ChainOfThought, ConsoleWriter, Conversation, index$2 as Gemini, Instruct, LogLevel, index$1 as Ollama, index as OpenAI, WriteOutputTask, concurrentWorkflow, dagWorkflow, generate, serialWorkflow, stream };
1001
- export type { AIProvider, AxleAssistantMessage, AxleMessage, AxleToolCallMessage, AxleToolCallResult, AxleUserMessage, ContentPart, ContentPartFile, ContentPartText, ContentPartThinking, ContentPartToolCall, DAGDefinition, DAGWorkflowOptions, FileInfo, SerializedExecutionResponse };
1273
+ export { index$3 as Anthropic, Axle, AxleStopReason, ChainOfThought, ConsoleWriter, Conversation, index$2 as Gemini, Instruct, LogLevel, index$1 as Ollama, index as OpenAI, WriteToDisk, braveSearchTool, calculatorTool, concurrentWorkflow, dagWorkflow, generate, generateWithTools, serialWorkflow, stream };
1274
+ export type { AIProvider, Action, ActionContext, AxleAssistantMessage, AxleMessage, AxleToolCallMessage, AxleToolCallResult, AxleUserMessage, ContentPart, ContentPartFile, ContentPartText, ContentPartThinking, ContentPartToolCall, DAGDefinition, DAGWorkflowOptions, FileInfo, SerializedExecutionResponse, Tool, ToolDefinition, WorkflowStep };