@fifthrevision/axle 0.6.4 → 0.6.5

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,6 +715,82 @@ declare class OllamaProvider implements AIProvider {
609
715
  }): AsyncGenerator<AnyStreamChunk, void, unknown>;
610
716
  }
611
717
 
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
+ interface StreamProps {
780
+ provider: AIProvider;
781
+ messages: Array<AxleMessage>;
782
+ system?: string;
783
+ tools?: Array<ToolDefinition>;
784
+ recorder?: Recorder;
785
+ options?: GenerateOptions;
786
+ }
787
+ interface StreamResult {
788
+ get final(): Promise<ModelResult>;
789
+ get current(): AxleAssistantMessage;
790
+ [Symbol.asyncIterator](): AsyncIterator<AnyStreamChunk>;
791
+ }
792
+ declare function stream(props: StreamProps): StreamResult;
793
+
612
794
  declare const index$1_DEFAULT_OLLAMA_URL: typeof DEFAULT_OLLAMA_URL;
613
795
  declare namespace index$1 {
614
796
  export {
@@ -685,48 +867,6 @@ declare const Models: {
685
867
  };
686
868
  declare const DEFAULT_MODEL: "gpt-5";
687
869
 
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
870
  declare const index_DEFAULT_MODEL: typeof DEFAULT_MODEL;
731
871
  declare const index_Models: typeof Models;
732
872
  declare const index_NAME: typeof NAME;
@@ -739,215 +879,302 @@ declare namespace index {
739
879
  };
740
880
  }
741
881
 
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
- }
882
+ declare const BraveProviderConfigSchema: z$1.ZodObject<{
883
+ "api-key": z$1.ZodString;
884
+ rateLimit: z$1.ZodOptional<z$1.ZodNumber>;
885
+ }, z$1.core.$strip>;
886
+ type BraveProviderConfig = z$1.infer<typeof BraveProviderConfigSchema>;
887
+ declare const JobSchema: z$1.ZodPipe<z$1.ZodTransform<any, any>, z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
888
+ type: z$1.ZodLiteral<"serial">;
889
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
890
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
891
+ uses: z$1.ZodLiteral<"chat">;
892
+ system: z$1.ZodOptional<z$1.ZodString>;
893
+ message: z$1.ZodString;
894
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
895
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
896
+ source: z$1.ZodLiteral<"file">;
897
+ pattern: z$1.ZodString;
898
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
899
+ }, z$1.core.$strip>>>;
900
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
901
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
902
+ file: z$1.ZodString;
903
+ }, z$1.core.$strip>>>;
904
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
905
+ file: z$1.ZodString;
906
+ }, z$1.core.$strip>>>;
907
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
908
+ file: z$1.ZodString;
909
+ }, z$1.core.$strip>>>;
910
+ }, z$1.core.$strip>, z$1.ZodObject<{
911
+ uses: z$1.ZodLiteral<"write-to-disk">;
912
+ output: z$1.ZodString;
913
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
914
+ }, z$1.core.$strip>], "uses">>;
915
+ }, z$1.core.$strip>, z$1.ZodObject<{
916
+ type: z$1.ZodLiteral<"batch">;
917
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
918
+ batch: z$1.ZodArray<z$1.ZodObject<{
919
+ type: z$1.ZodLiteral<"files">;
920
+ source: z$1.ZodString;
921
+ bind: z$1.ZodString;
922
+ "skip-if": z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
923
+ type: z$1.ZodLiteral<"file-exist">;
924
+ pattern: z$1.ZodString;
925
+ }, z$1.core.$strip>>>;
926
+ }, z$1.core.$strip>>;
927
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
928
+ uses: z$1.ZodLiteral<"chat">;
929
+ system: z$1.ZodOptional<z$1.ZodString>;
930
+ message: z$1.ZodString;
931
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
932
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
933
+ source: z$1.ZodLiteral<"file">;
934
+ pattern: z$1.ZodString;
935
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
936
+ }, z$1.core.$strip>>>;
937
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
938
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
939
+ file: z$1.ZodString;
940
+ }, z$1.core.$strip>>>;
941
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
942
+ file: z$1.ZodString;
943
+ }, z$1.core.$strip>>>;
944
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
945
+ file: z$1.ZodString;
946
+ }, z$1.core.$strip>>>;
947
+ }, z$1.core.$strip>, z$1.ZodObject<{
948
+ uses: z$1.ZodLiteral<"write-to-disk">;
949
+ output: z$1.ZodString;
950
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
951
+ }, z$1.core.$strip>], "uses">>;
952
+ }, z$1.core.$strip>], "type">>;
953
+ type Job = z$1.infer<typeof JobSchema>;
954
+ type SerialJob = Extract<Job, {
955
+ type: "serial";
956
+ }>;
957
+ type BatchJob = Extract<Job, {
958
+ type: "batch";
959
+ }>;
960
+ declare const DAGJobSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodPipe<z$1.ZodTransform<any, any>, z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
961
+ type: z$1.ZodLiteral<"serial">;
962
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
963
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
964
+ uses: z$1.ZodLiteral<"chat">;
965
+ system: z$1.ZodOptional<z$1.ZodString>;
966
+ message: z$1.ZodString;
967
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
968
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
969
+ source: z$1.ZodLiteral<"file">;
970
+ pattern: z$1.ZodString;
971
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
972
+ }, z$1.core.$strip>>>;
973
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
974
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
975
+ file: z$1.ZodString;
976
+ }, z$1.core.$strip>>>;
977
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
978
+ file: z$1.ZodString;
979
+ }, z$1.core.$strip>>>;
980
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
981
+ file: z$1.ZodString;
982
+ }, z$1.core.$strip>>>;
983
+ }, z$1.core.$strip>, z$1.ZodObject<{
984
+ uses: z$1.ZodLiteral<"write-to-disk">;
985
+ output: z$1.ZodString;
986
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
987
+ }, z$1.core.$strip>], "uses">>;
988
+ dependsOn: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
989
+ }, z$1.core.$strip>, z$1.ZodObject<{
990
+ type: z$1.ZodLiteral<"batch">;
991
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
992
+ batch: z$1.ZodArray<z$1.ZodObject<{
993
+ type: z$1.ZodLiteral<"files">;
994
+ source: z$1.ZodString;
995
+ bind: z$1.ZodString;
996
+ "skip-if": z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
997
+ type: z$1.ZodLiteral<"file-exist">;
998
+ pattern: z$1.ZodString;
999
+ }, z$1.core.$strip>>>;
1000
+ }, z$1.core.$strip>>;
1001
+ steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
1002
+ uses: z$1.ZodLiteral<"chat">;
1003
+ system: z$1.ZodOptional<z$1.ZodString>;
1004
+ message: z$1.ZodString;
1005
+ output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
1006
+ replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1007
+ source: z$1.ZodLiteral<"file">;
1008
+ pattern: z$1.ZodString;
1009
+ files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
1010
+ }, z$1.core.$strip>>>;
1011
+ tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1012
+ images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1013
+ file: z$1.ZodString;
1014
+ }, z$1.core.$strip>>>;
1015
+ documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1016
+ file: z$1.ZodString;
1017
+ }, z$1.core.$strip>>>;
1018
+ references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1019
+ file: z$1.ZodString;
1020
+ }, z$1.core.$strip>>>;
1021
+ }, z$1.core.$strip>, z$1.ZodObject<{
1022
+ uses: z$1.ZodLiteral<"write-to-disk">;
1023
+ output: z$1.ZodString;
1024
+ keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1025
+ }, z$1.core.$strip>], "uses">>;
1026
+ dependsOn: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1027
+ }, z$1.core.$strip>], "type">>>;
1028
+ type DAGJob = z$1.infer<typeof DAGJobSchema>;
851
1029
 
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
- }
1030
+ declare const braveSearchSchema: z.ZodObject<{
1031
+ searchTerm: z.ZodString;
1032
+ }, z.core.$strip>;
1033
+ declare class BraveSearchTool implements Tool<typeof braveSearchSchema> {
1034
+ name: string;
1035
+ description: string;
1036
+ schema: z.ZodObject<{
1037
+ searchTerm: z.ZodString;
1038
+ }, z.core.$strip>;
1039
+ apiKey: string;
1040
+ throttle: number | undefined;
1041
+ lastExecTime: number;
1042
+ constructor(config?: BraveProviderConfig);
1043
+ configure(config: BraveProviderConfig): void;
1044
+ execute(params: z.infer<typeof braveSearchSchema>): Promise<string>;
1045
+ }
1046
+ declare const braveSearchTool: BraveSearchTool;
860
1047
 
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;
1048
+ declare const calculatorSchema: z$1.ZodObject<{
1049
+ operation: z$1.ZodEnum<{
1050
+ add: "add";
1051
+ subtract: "subtract";
1052
+ multiply: "multiply";
1053
+ divide: "divide";
867
1054
  }>;
868
- createInstructions(instructions?: string): string;
869
- finalize(rawValue: string, runtime?: {
870
- recorder?: Recorder;
871
- }): InferedOutputSchema<T> & {
872
- thinking: string;
873
- };
874
- }
1055
+ a: z$1.ZodNumber;
1056
+ b: z$1.ZodNumber;
1057
+ }, z$1.core.$strip>;
1058
+ declare const calculatorTool: Tool<typeof calculatorSchema>;
875
1059
 
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
- }
887
-
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;
1060
+ /**
1061
+ * WriteToDisk Action
1062
+ *
1063
+ * Writes content to a file on disk. This action is typically used as a workflow
1064
+ * step following an LLM call to persist the generated output.
1065
+ *
1066
+ * ## CLI Job Definition (YAML)
1067
+ *
1068
+ * In job YAML files, use the `write-to-disk` step type:
1069
+ *
1070
+ * ```yaml
1071
+ * steps:
1072
+ * - uses: chat
1073
+ * message: Generate a greeting for {{name}}
1074
+ * - uses: write-to-disk
1075
+ * output: ./output/greeting-{{name}}.txt
1076
+ * ```
1077
+ *
1078
+ * ### Properties
1079
+ *
1080
+ * | Property | Type | Required | Description |
1081
+ * |----------|----------------------|----------|--------------------------------------------------|
1082
+ * | `uses` | `"write-to-disk"` | Yes | Identifies this as a WriteToDisk step |
1083
+ * | `output` | `string` | Yes | File path template (supports `{{}}` placeholders)|
1084
+ * | `keys` | `string \| string[]` | No | Variable keys to include in output content |
1085
+ *
1086
+ * ### Examples
1087
+ *
1088
+ * **Basic usage** - writes the LLM response to a file:
1089
+ * ```yaml
1090
+ * - uses: write-to-disk
1091
+ * output: ./output/result.txt
1092
+ * ```
1093
+ *
1094
+ * **With path variables** - uses `{{}}` placeholders in path:
1095
+ * ```yaml
1096
+ * - uses: write-to-disk
1097
+ * output: ./output/greeting-{{name}}.txt
1098
+ * ```
1099
+ *
1100
+ * **With file pattern** (batch processing) - uses `*` to substitute file stem:
1101
+ * ```yaml
1102
+ * - uses: write-to-disk
1103
+ * output: ./output/results-*.txt
1104
+ * ```
1105
+ *
1106
+ * **With specific keys** - outputs only specified variables:
1107
+ * ```yaml
1108
+ * - uses: write-to-disk
1109
+ * output: ./output/summary.txt
1110
+ * keys: summary
1111
+ * ```
1112
+ *
1113
+ * **With multiple keys** - outputs multiple variables, each on a new line:
1114
+ * ```yaml
1115
+ * - uses: write-to-disk
1116
+ * output: ./output/report.txt
1117
+ * keys:
1118
+ * - title
1119
+ * - summary
1120
+ * - conclusion
1121
+ * ```
1122
+ *
1123
+ * ## Placeholder Styles
1124
+ *
1125
+ * This action uses `{{variable}}` placeholder style for all variable substitution:
1126
+ *
1127
+ * - **Path template** (`output`): Uses `{{variable}}` placeholders
1128
+ * - Example: `./output/greeting-{{name}}.txt`
1129
+ * - Also supports `*` for file stem substitution in batch processing
1130
+ *
1131
+ * - **Content template** (`keys`): Uses `{{variable}}` placeholders
1132
+ * - Default template: `{{response}}`
1133
+ * - When `keys` is specified, generates: `{{key1}}\n{{key2}}\n...`
1134
+ *
1135
+ * ## Variables Available
1136
+ *
1137
+ * All variables from the workflow context are available for substitution:
1138
+ * - `response` - The text response from the previous LLM step
1139
+ * - `$previous` - The full output object from the previous step
1140
+ * - `file` - File info object when processing batches (contains `stem`, `name`, `ext`, etc.)
1141
+ * - Any custom variables defined in the workflow or extracted by previous steps
1142
+ *
1143
+ * @see WriteToDiskStep in `src/cli/configs/types.ts` for the TypeScript interface
1144
+ * @see writeToDiskConverter in `src/cli/converters/writeToDisk.ts` for CLI conversion logic
1145
+ */
1146
+ declare class WriteToDisk implements Action {
1147
+ private pathTemplate;
1148
+ private contentTemplate;
1149
+ name: string;
1150
+ /**
1151
+ * Creates a new WriteToDisk action.
1152
+ *
1153
+ * @param pathTemplate - The file path template. Supports:
1154
+ * - `{{variable}}` placeholders for variable substitution
1155
+ * - `*` for file stem substitution (batch processing)
1156
+ * @param contentTemplate - The content template using `{{variable}}` placeholders.
1157
+ * Defaults to `{{response}}` to output the LLM response.
1158
+ */
1159
+ constructor(pathTemplate: string, contentTemplate?: string);
1160
+ /**
1161
+ * Executes the write-to-disk action.
1162
+ *
1163
+ * Resolves the path and content templates using workflow variables,
1164
+ * then writes the content to the resolved file path.
1165
+ *
1166
+ * @param context - The action execution context containing:
1167
+ * - `variables`: All workflow variables available for substitution
1168
+ * - `options`: Execution options (e.g., `dryRun`)
1169
+ * - `recorder`: Optional recorder for logging
1170
+ * @returns A promise that resolves when the file has been written
1171
+ */
1172
+ execute(context: ActionContext): Promise<void>;
946
1173
  }
947
1174
 
948
1175
  interface ConcurrentWorkflow {
949
1176
  (jobConfig: BatchJob): WorkflowExecutable;
950
- (planner: Planner, ...instructions: Task[]): WorkflowExecutable;
1177
+ (planner: Planner, ...steps: WorkflowStep[]): WorkflowExecutable;
951
1178
  }
952
1179
  declare const concurrentWorkflow: ConcurrentWorkflow;
953
1180
 
@@ -958,10 +1185,25 @@ declare const dagWorkflow: DAGWorkflow;
958
1185
 
959
1186
  interface SerialWorkflow {
960
1187
  (jobConfig: SerialJob): WorkflowExecutable;
961
- (...instructions: Task[]): WorkflowExecutable;
1188
+ (...steps: WorkflowStep[]): WorkflowExecutable;
962
1189
  }
963
1190
  declare const serialWorkflow: SerialWorkflow;
964
1191
 
1192
+ declare class Conversation {
1193
+ system: string;
1194
+ private _messages;
1195
+ constructor(messages?: AxleMessage[]);
1196
+ get messages(): AxleMessage[];
1197
+ addSystem(message: string): void;
1198
+ addUser(message: string): void;
1199
+ addUser(parts: AxleUserMessage["content"]): void;
1200
+ addAssistant(message: string): void;
1201
+ addAssistant(params: Omit<AxleAssistantMessage, "role">): void;
1202
+ addToolResults(input: Array<AxleToolCallResult>): void;
1203
+ latest(): AxleMessage | undefined;
1204
+ toString(): string;
1205
+ }
1206
+
965
1207
  declare class ConsoleWriter implements RecorderWriter {
966
1208
  private tasks;
967
1209
  private entries;
@@ -982,20 +1224,5 @@ declare class ConsoleWriter implements RecorderWriter {
982
1224
  destroy(): void;
983
1225
  }
984
1226
 
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 };
1227
+ 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, serialWorkflow, stream };
1228
+ export type { AIProvider, Action, ActionContext, AxleAssistantMessage, AxleMessage, AxleToolCallMessage, AxleToolCallResult, AxleUserMessage, ContentPart, ContentPartFile, ContentPartText, ContentPartThinking, ContentPartToolCall, DAGDefinition, DAGWorkflowOptions, FileInfo, SerializedExecutionResponse, Tool, ToolDefinition, WorkflowStep };