@swizzy_ai/kit 1.0.4 → 1.0.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
@@ -90,13 +90,18 @@ declare class LLMClient {
90
90
  interface BungeeDestination {
91
91
  type: 'step';
92
92
  targetId: string;
93
+ config?: Record<string, any>;
93
94
  }
95
+
94
96
  interface BungeePlan {
95
97
  id: string;
96
98
  anchorId: string;
97
99
  destinations: BungeeDestination[];
98
100
  concurrency: number;
99
- configFn?: (index: number) => Record<string, any>;
101
+ optimistic?: boolean;
102
+ returnToAnchor?: boolean;
103
+ failWizardOnFailure?: boolean;
104
+ onComplete?: (wizard: any) => FlowControlSignal;
100
105
  }
101
106
 
102
107
  declare class BungeeBuilder {
@@ -105,17 +110,28 @@ declare class BungeeBuilder {
105
110
  /**
106
111
  * Add a single step execution.
107
112
  */
108
- readonly add: (stepId: string) => this;
113
+ readonly add: (stepId: string, config?: Record<string, any>) => this;
109
114
  /**
110
115
  * Add multiple executions based on count with config function.
111
116
  */
112
- readonly batch: (stepId: string, count: number, configFn: (index: number) => Record<string, any>) => this;
117
+ readonly batch: (stepId: string, count: number, configFn: (index: number) => Record<string, any>, options?: {
118
+ optimistic?: boolean;
119
+ returnToAnchor?: boolean;
120
+ failWizardOnFailure?: boolean;
121
+ }) => this;
113
122
  /**
114
123
  * Configure execution settings.
115
124
  */
116
125
  readonly config: (options: {
117
126
  concurrency?: number;
127
+ optimistic?: boolean;
128
+ returnToAnchor?: boolean;
129
+ failWizardOnFailure?: boolean;
118
130
  }) => this;
131
+ /**
132
+ * Set completion callback.
133
+ */
134
+ readonly onComplete: (callback: (wizard: any) => any) => this;
119
135
  /**
120
136
  * Trigger the Jump.
121
137
  */
@@ -127,6 +143,7 @@ declare class BungeeBuilder {
127
143
 
128
144
  interface WizardActions {
129
145
  updateContext: (updates: Record<string, any>) => void;
146
+ setState: (updates: Partial<any> | ((prevState: any) => Partial<any>)) => void;
130
147
  llmClient: LLMClient;
131
148
  goto: (stepId: string) => FlowControlSignal;
132
149
  next: () => FlowControlSignal;
@@ -142,7 +159,7 @@ type FlowControlSignal = 'NEXT' | 'STOP' | 'RETRY' | 'WAIT' | string | {
142
159
  type: 'BUNGEE_JUMP';
143
160
  plan: BungeePlan;
144
161
  };
145
- type Context = (workflowContext: any) => any;
162
+ type Context = (workflowContext: any) => any | Promise<any>;
146
163
  type ContextType = 'xml' | 'template' | 'both';
147
164
  interface StepConfig<T = any> {
148
165
  id: string;
@@ -154,6 +171,7 @@ interface StepConfig<T = any> {
154
171
  beforeRun?: () => Promise<void> | void;
155
172
  afterRun?: (result: T) => Promise<void> | void;
156
173
  model: string;
174
+ stream?: boolean;
157
175
  }
158
176
  declare class Step<T = any> {
159
177
  readonly id: string;
@@ -165,10 +183,11 @@ declare class Step<T = any> {
165
183
  readonly beforeRun?: () => Promise<void> | void;
166
184
  readonly afterRun?: (result: T) => Promise<void> | void;
167
185
  readonly model: string;
186
+ readonly stream?: boolean;
168
187
  executionCount: number;
169
188
  constructor(config: StepConfig<T>);
170
189
  validate(data: unknown): T;
171
- getContext(workflowContext: any): any;
190
+ getContext(workflowContext: any): Promise<any>;
172
191
  }
173
192
 
174
193
  interface TextStepConfig {
@@ -180,6 +199,7 @@ interface TextStepConfig {
180
199
  beforeRun?: () => Promise<void> | void;
181
200
  afterRun?: (result: string) => Promise<void> | void;
182
201
  model: string;
202
+ stream: boolean;
183
203
  }
184
204
  declare class TextStep extends Step<string> {
185
205
  constructor(config: TextStepConfig);
@@ -249,7 +269,7 @@ declare class Wizard {
249
269
  private isLoggingEnabled;
250
270
  private logger;
251
271
  private usageTracker;
252
- private contextManager;
272
+ private stateManager;
253
273
  private visualizationManager;
254
274
  private bungeeExecutor;
255
275
  private events;
@@ -298,19 +318,24 @@ declare class Wizard {
298
318
  * Uses streaming for regular steps to provide real-time parsing and UI updates.
299
319
  * TextStep and ComputeStep use different approaches (non-streaming).
300
320
  */
321
+ /**
322
+ * Generates data for a wizard step by calling the LLM.
323
+ * CLEANED VERSION: Separates formatting rules from logic to prevent hallucination.
324
+ */
301
325
  generateStepData(step: Step, stepContext: any): Promise<any>;
302
326
  private repairSchemaData;
303
327
  /**
304
- * Creates a streaming XML parser for incremental processing of LLM responses.
328
+ * Creates an improved streaming XML parser for incremental processing of LLM responses.
305
329
  *
306
- * This parser processes XML chunks as they arrive from the LLM, extracting
307
- * fields marked with tag-category="wizard" and parsing them based on their type attributes.
330
+ * This parser is designed to handle partial chunks robustly and provides better error recovery.
331
+ * It processes XML chunks as they arrive, extracting fields marked with tag-category="wizard".
308
332
  *
309
- * Key features:
310
- * - Incremental parsing: processes data as it streams in
311
- * - Buffer management: accumulates chunks until complete fields are available
312
- * - Type-aware parsing: handles strings, numbers, booleans, arrays, objects
313
- * - Real-time updates: returns partial results as fields complete
333
+ * Key improvements:
334
+ * - Better partial tag handling
335
+ * - More robust regex matching
336
+ * - Improved buffer management
337
+ * - Better error recovery for malformed chunks
338
+ * - State machine approach for parsing
314
339
  *
315
340
  * @returns An object with a push method that accepts text chunks and returns parse results
316
341
  */